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 { 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
|
|
|
|
2026-06-01 20:26:47 -05:00
|
|
|
declare const RequestResponseSpecType: unique symbol;
|
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-06-01 20:26:47 -05:00
|
|
|
export interface RequestResponseSpec<TReq, TRes> extends Spec {
|
|
|
|
|
readonly [RequestResponseSpecType]?: {
|
|
|
|
|
readonly request: TReq;
|
|
|
|
|
readonly response: TRes;
|
|
|
|
|
};
|
|
|
|
|
}
|
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-06-01 20:26:47 -05:00
|
|
|
export function makeRequestResponseSpec<TReq, TRes>(
|
|
|
|
|
name: string,
|
|
|
|
|
requestTopicName: string,
|
|
|
|
|
responseTopicName: string,
|
|
|
|
|
): RequestResponseSpec<TReq, TRes> {
|
|
|
|
|
const addEffect = Effect.fn("RequestResponseSpec.addEffect")(function* (
|
|
|
|
|
flow: Flow,
|
|
|
|
|
definition: FlowDefinition,
|
|
|
|
|
) {
|
|
|
|
|
const requestTopic = definition.topics?.[requestTopicName] ?? requestTopicName;
|
|
|
|
|
const responseTopic = definition.topics?.[responseTopicName] ?? responseTopicName;
|
2026-05-12 08:06:58 -05:00
|
|
|
const factory = yield* RequestResponseFactory;
|
|
|
|
|
const requestor = yield* factory.make<TReq, TRes>({
|
|
|
|
|
requestTopic,
|
|
|
|
|
responseTopic,
|
2026-06-01 20:26:47 -05:00
|
|
|
subscription: `${flow.processorId}-${flow.name}-${name}`,
|
2026-05-12 08:06:58 -05:00
|
|
|
});
|
2026-06-01 20:26:47 -05:00
|
|
|
flow.registerRequestor(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-06-01 20:26:47 -05:00
|
|
|
return {
|
|
|
|
|
name,
|
|
|
|
|
addEffect,
|
|
|
|
|
add: async (flow, pubsub, definition) => {
|
|
|
|
|
await flow.runInCompatibilityScope(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
|
|
|
}
|