feat: add schema foundation for document pipeline, agent, and deployment
Add missing topics (librarian, knowledge, collection-management, flow),
pipeline message types (TextDocument, Chunk, Triples, EntityContexts),
service message types (Librarian, Knowledge, Collection, Flow CRUD),
and update AgentResponse for streaming chunk format.
Add RequestResponseSpec enabling flow-scoped request/response calls
(needed by knowledge extraction and agent services). Add requestor
registry to Flow class with proper lifecycle management.
Add end_of_dialog to gateway's isComplete() check for agent streaming.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 00:11:29 -05:00
|
|
|
/**
|
|
|
|
|
* Request/response specification — declares a request/response client for a flow.
|
|
|
|
|
*
|
|
|
|
|
* Enables FlowProcessor handlers to make request/response calls to other services
|
|
|
|
|
* (e.g., calling the prompt service or LLM from within a knowledge extraction handler).
|
|
|
|
|
*
|
|
|
|
|
* Python reference: trustgraph-base/trustgraph/base/prompt_client_spec.py
|
|
|
|
|
*/
|
|
|
|
|
|
2026-05-12 08:06:58 -05:00
|
|
|
import { Effect } from "effect";
|
feat: add schema foundation for document pipeline, agent, and deployment
Add missing topics (librarian, knowledge, collection-management, flow),
pipeline message types (TextDocument, Chunk, Triples, EntityContexts),
service message types (Librarian, Knowledge, Collection, Flow CRUD),
and update AgentResponse for streaming chunk format.
Add RequestResponseSpec enabling flow-scoped request/response calls
(needed by knowledge extraction and agent services). Add requestor
registry to Flow class with proper lifecycle management.
Add end_of_dialog to gateway's isComplete() check for agent streaming.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 00:11:29 -05:00
|
|
|
import type { Spec } from "./types.js";
|
|
|
|
|
import type { PubSubBackend } from "../backend/types.js";
|
|
|
|
|
import type { Flow, FlowDefinition } from "../processor/flow.js";
|
2026-05-12 08:06:58 -05:00
|
|
|
import {
|
|
|
|
|
RequestResponseFactory,
|
|
|
|
|
type EffectRequestResponse,
|
|
|
|
|
} from "../messaging/runtime.js";
|
feat: add schema foundation for document pipeline, agent, and deployment
Add missing topics (librarian, knowledge, collection-management, flow),
pipeline message types (TextDocument, Chunk, Triples, EntityContexts),
service message types (Librarian, Knowledge, Collection, Flow CRUD),
and update AgentResponse for streaming chunk format.
Add RequestResponseSpec enabling flow-scoped request/response calls
(needed by knowledge extraction and agent services). Add requestor
registry to Flow class with proper lifecycle management.
Add end_of_dialog to gateway's isComplete() check for agent streaming.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 00:11:29 -05:00
|
|
|
|
|
|
|
|
export class RequestResponseSpec<TReq, TRes> implements Spec {
|
2026-05-12 08:06:58 -05:00
|
|
|
public readonly name: string;
|
|
|
|
|
private readonly requestTopicName: string;
|
|
|
|
|
private readonly responseTopicName: string;
|
feat: add schema foundation for document pipeline, agent, and deployment
Add missing topics (librarian, knowledge, collection-management, flow),
pipeline message types (TextDocument, Chunk, Triples, EntityContexts),
service message types (Librarian, Knowledge, Collection, Flow CRUD),
and update AgentResponse for streaming chunk format.
Add RequestResponseSpec enabling flow-scoped request/response calls
(needed by knowledge extraction and agent services). Add requestor
registry to Flow class with proper lifecycle management.
Add end_of_dialog to gateway's isComplete() check for agent streaming.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 00:11:29 -05:00
|
|
|
|
2026-05-12 08:06:58 -05:00
|
|
|
constructor(
|
|
|
|
|
name: string,
|
|
|
|
|
requestTopicName: string,
|
|
|
|
|
responseTopicName: string,
|
|
|
|
|
) {
|
|
|
|
|
this.name = name;
|
|
|
|
|
this.requestTopicName = requestTopicName;
|
|
|
|
|
this.responseTopicName = responseTopicName;
|
|
|
|
|
}
|
feat: add schema foundation for document pipeline, agent, and deployment
Add missing topics (librarian, knowledge, collection-management, flow),
pipeline message types (TextDocument, Chunk, Triples, EntityContexts),
service message types (Librarian, Knowledge, Collection, Flow CRUD),
and update AgentResponse for streaming chunk format.
Add RequestResponseSpec enabling flow-scoped request/response calls
(needed by knowledge extraction and agent services). Add requestor
registry to Flow class with proper lifecycle management.
Add end_of_dialog to gateway's isComplete() check for agent streaming.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 00:11:29 -05:00
|
|
|
|
2026-05-12 08:06:58 -05:00
|
|
|
addEffect(flow: Flow, definition: FlowDefinition) {
|
|
|
|
|
const spec = this;
|
|
|
|
|
return Effect.gen(function* () {
|
|
|
|
|
const requestTopic = definition.topics?.[spec.requestTopicName] ?? spec.requestTopicName;
|
|
|
|
|
const responseTopic = definition.topics?.[spec.responseTopicName] ?? spec.responseTopicName;
|
|
|
|
|
const factory = yield* RequestResponseFactory;
|
|
|
|
|
const requestor = yield* factory.make<TReq, TRes>({
|
|
|
|
|
requestTopic,
|
|
|
|
|
responseTopic,
|
|
|
|
|
subscription: `${flow.processorId}-${flow.name}-${spec.name}`,
|
|
|
|
|
});
|
|
|
|
|
flow.registerRequestor(spec.name, requestor as EffectRequestResponse<unknown, unknown>);
|
feat: add schema foundation for document pipeline, agent, and deployment
Add missing topics (librarian, knowledge, collection-management, flow),
pipeline message types (TextDocument, Chunk, Triples, EntityContexts),
service message types (Librarian, Knowledge, Collection, Flow CRUD),
and update AgentResponse for streaming chunk format.
Add RequestResponseSpec enabling flow-scoped request/response calls
(needed by knowledge extraction and agent services). Add requestor
registry to Flow class with proper lifecycle management.
Add end_of_dialog to gateway's isComplete() check for agent streaming.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 00:11:29 -05:00
|
|
|
});
|
2026-05-12 08:06:58 -05:00
|
|
|
}
|
feat: add schema foundation for document pipeline, agent, and deployment
Add missing topics (librarian, knowledge, collection-management, flow),
pipeline message types (TextDocument, Chunk, Triples, EntityContexts),
service message types (Librarian, Knowledge, Collection, Flow CRUD),
and update AgentResponse for streaming chunk format.
Add RequestResponseSpec enabling flow-scoped request/response calls
(needed by knowledge extraction and agent services). Add requestor
registry to Flow class with proper lifecycle management.
Add end_of_dialog to gateway's isComplete() check for agent streaming.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 00:11:29 -05:00
|
|
|
|
2026-05-12 08:06:58 -05:00
|
|
|
async add(flow: Flow, pubsub: PubSubBackend, definition: FlowDefinition): Promise<void> {
|
|
|
|
|
await flow.runInCompatibilityScope(this.addEffect(flow, definition), pubsub);
|
feat: add schema foundation for document pipeline, agent, and deployment
Add missing topics (librarian, knowledge, collection-management, flow),
pipeline message types (TextDocument, Chunk, Triples, EntityContexts),
service message types (Librarian, Knowledge, Collection, Flow CRUD),
and update AgentResponse for streaming chunk format.
Add RequestResponseSpec enabling flow-scoped request/response calls
(needed by knowledge extraction and agent services). Add requestor
registry to Flow class with proper lifecycle management.
Add end_of_dialog to gateway's isComplete() check for agent streaming.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-06 00:11:29 -05:00
|
|
|
}
|
|
|
|
|
}
|