mirror of
https://github.com/trustgraph-ai/trustgraph.git
synced 2026-07-01 17:39:39 +02: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>
This commit is contained in:
parent
28747e1a92
commit
5ed3f0e2d8
6 changed files with 236 additions and 1 deletions
|
|
@ -70,10 +70,18 @@ export interface AgentRequest {
|
|||
question: string;
|
||||
collection?: string;
|
||||
streaming?: boolean;
|
||||
group?: string[];
|
||||
state?: string;
|
||||
}
|
||||
|
||||
export interface AgentResponse {
|
||||
answer: string;
|
||||
/** Streaming chunk type */
|
||||
chunk_type?: "thought" | "observation" | "answer" | "error";
|
||||
content?: string;
|
||||
end_of_message?: boolean;
|
||||
end_of_dialog?: boolean;
|
||||
/** Legacy non-streaming fields */
|
||||
answer?: string;
|
||||
error?: TgError;
|
||||
endOfStream?: boolean;
|
||||
endOfSession?: boolean;
|
||||
|
|
@ -133,3 +141,161 @@ export interface PromptResponse {
|
|||
prompt: string;
|
||||
error?: TgError;
|
||||
}
|
||||
|
||||
// ---------- Pipeline types ----------
|
||||
|
||||
export interface PipelineMetadata {
|
||||
id: string;
|
||||
root: string;
|
||||
user: string;
|
||||
collection: string;
|
||||
}
|
||||
|
||||
export interface TextDocument {
|
||||
metadata: PipelineMetadata;
|
||||
text: string;
|
||||
documentId: string;
|
||||
}
|
||||
|
||||
export interface Chunk {
|
||||
metadata: PipelineMetadata;
|
||||
chunk: string;
|
||||
documentId: string;
|
||||
}
|
||||
|
||||
export interface EntityContext {
|
||||
entity: Term;
|
||||
context: string;
|
||||
chunkId: string;
|
||||
}
|
||||
|
||||
export interface EntityContexts {
|
||||
metadata: PipelineMetadata;
|
||||
entities: EntityContext[];
|
||||
}
|
||||
|
||||
export interface Triples {
|
||||
metadata: PipelineMetadata;
|
||||
triples: Triple[];
|
||||
}
|
||||
|
||||
// ---------- Document metadata ----------
|
||||
|
||||
export interface DocumentMetadata {
|
||||
id: string;
|
||||
time: number;
|
||||
kind: string;
|
||||
title: string;
|
||||
comments: string;
|
||||
user: string;
|
||||
tags: string[];
|
||||
parentId?: string;
|
||||
documentType: string; // "source" | "page" | "chunk" | "extracted"
|
||||
metadata?: Triple[];
|
||||
}
|
||||
|
||||
export interface ProcessingMetadata {
|
||||
id: string;
|
||||
documentId: string;
|
||||
time: number;
|
||||
flow: string;
|
||||
user: string;
|
||||
collection: string;
|
||||
tags: string[];
|
||||
}
|
||||
|
||||
// ---------- Librarian ----------
|
||||
|
||||
export type LibrarianOperation =
|
||||
| "add-document"
|
||||
| "remove-document"
|
||||
| "list-documents"
|
||||
| "get-document-metadata"
|
||||
| "get-document-content"
|
||||
| "add-child-document"
|
||||
| "list-children"
|
||||
| "add-processing"
|
||||
| "remove-processing"
|
||||
| "list-processing";
|
||||
|
||||
export interface LibrarianRequest {
|
||||
operation: LibrarianOperation;
|
||||
documentId?: string;
|
||||
processingId?: string;
|
||||
documentMetadata?: DocumentMetadata;
|
||||
processingMetadata?: ProcessingMetadata;
|
||||
content?: string; // base64
|
||||
user?: string;
|
||||
collection?: string;
|
||||
}
|
||||
|
||||
export interface LibrarianResponse {
|
||||
error?: TgError;
|
||||
documentMetadata?: DocumentMetadata;
|
||||
content?: string; // base64
|
||||
documents?: DocumentMetadata[];
|
||||
processing?: ProcessingMetadata[];
|
||||
}
|
||||
|
||||
// ---------- Knowledge core ----------
|
||||
|
||||
export type KnowledgeOperation =
|
||||
| "list-kg-cores"
|
||||
| "get-kg-core"
|
||||
| "delete-kg-core"
|
||||
| "put-kg-core"
|
||||
| "load-kg-core";
|
||||
|
||||
export interface KnowledgeRequest {
|
||||
operation: KnowledgeOperation;
|
||||
user?: string;
|
||||
id?: string;
|
||||
flow?: string;
|
||||
collection?: string;
|
||||
triples?: Triple[];
|
||||
graphEmbeddings?: { entity: Term; vectors: number[][] }[];
|
||||
}
|
||||
|
||||
export interface KnowledgeResponse {
|
||||
error?: TgError;
|
||||
ids?: string[];
|
||||
eos?: boolean;
|
||||
triples?: Triple[];
|
||||
graphEmbeddings?: { entity: Term; vectors: number[][] }[];
|
||||
}
|
||||
|
||||
// ---------- Collection management ----------
|
||||
|
||||
export type CollectionOperation =
|
||||
| "list-collections"
|
||||
| "update-collection"
|
||||
| "delete-collection";
|
||||
|
||||
export interface CollectionManagementRequest {
|
||||
operation: CollectionOperation;
|
||||
user?: string;
|
||||
collection?: string;
|
||||
name?: string;
|
||||
description?: string;
|
||||
tags?: string[];
|
||||
}
|
||||
|
||||
export interface CollectionManagementResponse {
|
||||
error?: TgError;
|
||||
collections?: { user: string; collection: string; name: string; description: string; tags: string[] }[];
|
||||
}
|
||||
|
||||
// ---------- Flow management ----------
|
||||
|
||||
export type FlowOperation = "list" | "get" | "start" | "stop";
|
||||
|
||||
export interface FlowRequest {
|
||||
operation: FlowOperation;
|
||||
id?: string;
|
||||
blueprint?: string;
|
||||
}
|
||||
|
||||
export interface FlowResponse {
|
||||
error?: TgError;
|
||||
flows?: { id: string; status: string; blueprint?: string }[];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,4 +59,20 @@ export const topics = {
|
|||
// Prompt
|
||||
promptRequest: topic("prompt-request"),
|
||||
promptResponse: topic("prompt-response"),
|
||||
|
||||
// Librarian (document management)
|
||||
librarianRequest: topic("librarian-request"),
|
||||
librarianResponse: topic("librarian-response"),
|
||||
|
||||
// Knowledge core management
|
||||
knowledgeRequest: topic("knowledge-request"),
|
||||
knowledgeResponse: topic("knowledge-response"),
|
||||
|
||||
// Collection management
|
||||
collectionManagementRequest: topic("collection-management-request"),
|
||||
collectionManagementResponse: topic("collection-management-response"),
|
||||
|
||||
// Flow management
|
||||
flowRequest: topic("flow-request"),
|
||||
flowResponse: topic("flow-response"),
|
||||
} as const;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue