@cogitator-ai/tetsu 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAEvC,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,oBAAoB,EACpB,aAAa,EACb,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,OAAO,EACP,YAAY,EACZ,eAAe,EACf,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,gBAAgB,EAChB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GACf,MAAM,cAAc,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { Agent } from '@cogitator-ai/core';
2
+ import type { RunOptions, RunResult, StrategyResult, SwarmConfig, SwarmResourceUsage, SwarmRunOptions, Workflow, WorkflowExecuteOptions, WorkflowResult, WorkflowState } from '@cogitator-ai/types';
3
+ import type { AgentListResponseBody, AgentRunResponseBody, AuthContext, CogitatorDeps, SwarmListResponseBody, SwarmRunResponseBody, ToolListResponseBody, WorkflowListResponseBody, WorkflowRunResponseBody } from './types.js';
4
+ export declare function findAgent(deps: CogitatorDeps, name: string): Agent;
5
+ export declare function findWorkflow(deps: CogitatorDeps, name: string): Workflow<WorkflowState>;
6
+ export declare function findSwarm(deps: CogitatorDeps, name: string): SwarmConfig;
7
+ export declare function checkThreadAccess(deps: CogitatorDeps, auth: AuthContext | undefined, threadId: string | undefined): Promise<void>;
8
+ export declare function listAgents(deps: CogitatorDeps): AgentListResponseBody;
9
+ export declare function listTools(deps: CogitatorDeps): ToolListResponseBody;
10
+ export declare function listWorkflows(deps: CogitatorDeps): WorkflowListResponseBody;
11
+ export declare function listSwarms(deps: CogitatorDeps): SwarmListResponseBody;
12
+ export declare function toAgentRunResponse(result: RunResult): AgentRunResponseBody;
13
+ export declare function toWorkflowRunResponse(result: WorkflowResult<WorkflowState>): WorkflowRunResponseBody;
14
+ export declare function serializeSwarmUsage(usage: SwarmResourceUsage): {
15
+ totalTokens: number;
16
+ totalCost: number;
17
+ elapsedTime: number;
18
+ agentUsage: {
19
+ [k: string]: {
20
+ tokens: number;
21
+ cost: number;
22
+ runs: number;
23
+ duration: number;
24
+ };
25
+ };
26
+ };
27
+ interface SwarmHandle {
28
+ readonly id: string;
29
+ readonly name: string;
30
+ readonly strategyType: string;
31
+ getResourceUsage(): SwarmResourceUsage;
32
+ }
33
+ export declare function toSwarmRunResponse(swarm: SwarmHandle, result: StrategyResult): SwarmRunResponseBody;
34
+ export declare function runAgent(deps: CogitatorDeps, agent: Agent, options: RunOptions, auth: AuthContext | undefined): Promise<RunResult>;
35
+ export declare function executeWorkflow(deps: CogitatorDeps, workflow: Workflow<WorkflowState>, input: Record<string, unknown> | undefined, options: WorkflowExecuteOptions, signal: AbortSignal): Promise<WorkflowResult<WorkflowState>>;
36
+ export declare function executeSwarm(deps: CogitatorDeps, config: SwarmConfig, options: SwarmRunOptions, signal: AbortSignal, onStart?: (swarm: SwarmHandle) => void): Promise<{
37
+ swarm: SwarmHandle;
38
+ result: StrategyResult;
39
+ }>;
40
+ export {};
41
+ //# sourceMappingURL=operations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EACV,UAAU,EACV,SAAS,EACT,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,eAAe,EACf,QAAQ,EACR,sBAAsB,EACtB,cAAc,EACd,aAAa,EACd,MAAM,qBAAqB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M,CAAC;IAC9B,gBAAgB,IAAI,kBAAkB,CAAC;CACxC;AAED,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,cAAc,GACrB,oBAAoB,CAmBtB;AAED,wBAAgB,QAAQ,CACtB,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,UAAU,EACnB,IAAI,EAAE,WAAW,GAAG,SAAS,GAC5B,OAAO,CAAC,SAAS,CAAC,CAKpB;AAED,wBAAsB,eAAe,CACnC,IAAI,EAAE,aAAa,EACnB,QAAQ,EAAE,QAAQ,CAAC,aAAa,CAAC,EACjC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAC1C,OAAO,EAAE,sBAAsB,EAC/B,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CAWxC;AAED,wBAAsB,YAAY,CAChC,IAAI,EAAE,aAAa,EACnB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,WAAW,EACnB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GACrC,OAAO,CAAC;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,cAAc,CAAA;CAAE,CAAC,CAgBzD"}
@@ -0,0 +1,162 @@
1
+ import { httpError } from '@tetsujs/core';
2
+ import { importOptional } from './errors.js';
3
+ function getOwn(record, key) {
4
+ return record && Object.hasOwn(record, key) ? record[key] : undefined;
5
+ }
6
+ export function findAgent(deps, name) {
7
+ const agent = getOwn(deps.agents, name);
8
+ if (!agent)
9
+ throw httpError(404, 'AGENT_NOT_FOUND', `Agent '${name}' not found`);
10
+ return agent;
11
+ }
12
+ export function findWorkflow(deps, name) {
13
+ const workflow = getOwn(deps.workflows, name);
14
+ if (!workflow)
15
+ throw httpError(404, 'WORKFLOW_NOT_FOUND', `Workflow '${name}' not found`);
16
+ return workflow;
17
+ }
18
+ export function findSwarm(deps, name) {
19
+ const swarm = getOwn(deps.swarms, name);
20
+ if (!swarm)
21
+ throw httpError(404, 'SWARM_NOT_FOUND', `Swarm '${name}' not found`);
22
+ return swarm;
23
+ }
24
+ export async function checkThreadAccess(deps, auth, threadId) {
25
+ if (threadId === undefined || !deps.authorizeThread)
26
+ return;
27
+ if (!(await deps.authorizeThread(auth, threadId))) {
28
+ throw httpError(403, 'THREAD_FORBIDDEN', `Access to thread '${threadId}' is not allowed`);
29
+ }
30
+ }
31
+ export function listAgents(deps) {
32
+ return {
33
+ agents: Object.entries(deps.agents ?? {}).map(([name, agent]) => ({
34
+ name,
35
+ ...(agent.config.description !== undefined && { description: agent.config.description }),
36
+ tools: agent.config.tools?.map((tool) => tool.name) ?? [],
37
+ })),
38
+ };
39
+ }
40
+ export function listTools(deps) {
41
+ const tools = new Map();
42
+ for (const agent of Object.values(deps.agents ?? {})) {
43
+ for (const tool of agent.config.tools ?? []) {
44
+ if (tools.has(tool.name))
45
+ continue;
46
+ const schema = tool.toJSON();
47
+ tools.set(tool.name, {
48
+ name: schema.name,
49
+ description: schema.description,
50
+ parameters: schema.parameters,
51
+ });
52
+ }
53
+ }
54
+ return { tools: [...tools.values()] };
55
+ }
56
+ export function listWorkflows(deps) {
57
+ return {
58
+ workflows: Object.entries(deps.workflows ?? {}).map(([name, workflow]) => ({
59
+ name,
60
+ entryPoint: workflow.entryPoint,
61
+ nodes: [...workflow.nodes.keys()],
62
+ })),
63
+ };
64
+ }
65
+ export function listSwarms(deps) {
66
+ return {
67
+ swarms: Object.entries(deps.swarms ?? {}).map(([name, config]) => ({
68
+ name,
69
+ strategy: config.strategy,
70
+ agents: [
71
+ ...(config.supervisor ? [config.supervisor.name] : []),
72
+ ...(config.workers ?? []).map((agent) => agent.name),
73
+ ...(config.agents ?? []).map((agent) => agent.name),
74
+ ...(config.moderator ? [config.moderator.name] : []),
75
+ ],
76
+ })),
77
+ };
78
+ }
79
+ export function toAgentRunResponse(result) {
80
+ return {
81
+ output: result.output,
82
+ ...(result.structured !== undefined && { structured: result.structured }),
83
+ threadId: result.threadId,
84
+ usage: {
85
+ inputTokens: result.usage.inputTokens,
86
+ outputTokens: result.usage.outputTokens,
87
+ totalTokens: result.usage.totalTokens,
88
+ },
89
+ toolCalls: result.toolCalls.map((call) => ({
90
+ id: call.id,
91
+ name: call.name,
92
+ arguments: call.arguments,
93
+ })),
94
+ };
95
+ }
96
+ export function toWorkflowRunResponse(result) {
97
+ return {
98
+ workflowId: result.workflowId,
99
+ workflowName: result.workflowName,
100
+ state: result.state,
101
+ duration: result.duration,
102
+ nodeResults: Object.fromEntries(result.nodeResults),
103
+ };
104
+ }
105
+ export function serializeSwarmUsage(usage) {
106
+ return {
107
+ totalTokens: usage.totalTokens,
108
+ totalCost: usage.totalCost,
109
+ elapsedTime: usage.elapsedTime,
110
+ agentUsage: Object.fromEntries(usage.agentUsage),
111
+ };
112
+ }
113
+ export function toSwarmRunResponse(swarm, result) {
114
+ const usage = swarm.getResourceUsage();
115
+ return {
116
+ swarmId: swarm.id,
117
+ swarmName: swarm.name,
118
+ strategy: swarm.strategyType,
119
+ output: result.output,
120
+ agentResults: Object.fromEntries([...result.agentResults].map(([name, run]) => [
121
+ name,
122
+ { output: run.output, usage: { ...run.usage } },
123
+ ])),
124
+ usage: {
125
+ totalTokens: usage.totalTokens,
126
+ totalCost: usage.totalCost,
127
+ elapsedTime: usage.elapsedTime,
128
+ },
129
+ };
130
+ }
131
+ export function runAgent(deps, agent, options, auth) {
132
+ return deps.cogitator.run(agent, {
133
+ ...options,
134
+ ...(auth?.userId !== undefined && { userId: auth.userId }),
135
+ });
136
+ }
137
+ export async function executeWorkflow(deps, workflow, input, options, signal) {
138
+ const { WorkflowExecutor } = await importOptional(() => import('@cogitator-ai/workflows'), '@cogitator-ai/workflows');
139
+ const result = await new WorkflowExecutor(deps.cogitator).execute(workflow, input, {
140
+ ...options,
141
+ signal,
142
+ });
143
+ if (result.error)
144
+ throw result.error;
145
+ return result;
146
+ }
147
+ export async function executeSwarm(deps, config, options, signal, onStart) {
148
+ const { Swarm } = await importOptional(() => import('@cogitator-ai/swarms'), '@cogitator-ai/swarms');
149
+ signal.throwIfAborted();
150
+ const swarm = new Swarm(deps.cogitator, config);
151
+ const abort = () => swarm.abort();
152
+ signal.addEventListener('abort', abort, { once: true });
153
+ try {
154
+ onStart?.(swarm);
155
+ const result = await swarm.run(options);
156
+ return { swarm, result };
157
+ }
158
+ finally {
159
+ signal.removeEventListener('abort', abort);
160
+ }
161
+ }
162
+ //# sourceMappingURL=operations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operations.js","sourceRoot":"","sources":["../src/operations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAc1C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAa7C,SAAS,MAAM,CAAI,MAAqC,EAAE,GAAW;IACnE,OAAO,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,SAAS,CAAC,IAAmB,EAAE,IAAY;IACzD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACxC,IAAI,CAAC,KAAK;QAAE,MAAM,SAAS,CAAC,GAAG,EAAE,iBAAiB,EAAE,UAAU,IAAI,aAAa,CAAC,CAAC;IACjF,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,IAAmB,EAAE,IAAY;IAC5D,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC9C,IAAI,CAAC,QAAQ;QAAE,MAAM,SAAS,CAAC,GAAG,EAAE,oBAAoB,EAAE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AAG,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;IAClC,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;QACjB,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACxC,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAC3B,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC7C,CAAC;AACH,CAAC"}
@@ -0,0 +1,305 @@
1
+ import { z } from 'zod';
2
+ export declare const NameParams: z.ZodObject<{
3
+ name: z.ZodString;
4
+ }, z.core.$strip>;
5
+ export declare const ThreadParams: z.ZodObject<{
6
+ id: z.ZodString;
7
+ }, z.core.$strip>;
8
+ export declare const RunBody: z.ZodObject<{
9
+ input: z.ZodString;
10
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
11
+ threadId: z.ZodOptional<z.ZodString>;
12
+ }, z.core.$strip>;
13
+ export declare const SwarmRunBody: z.ZodObject<{
14
+ input: z.ZodString;
15
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
16
+ threadId: z.ZodOptional<z.ZodString>;
17
+ timeout: z.ZodOptional<z.ZodNumber>;
18
+ }, z.core.$strip>;
19
+ export declare const WorkflowRunBody: z.ZodObject<{
20
+ input: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
21
+ options: z.ZodOptional<z.ZodObject<{
22
+ maxConcurrency: z.ZodOptional<z.ZodNumber>;
23
+ maxIterations: z.ZodOptional<z.ZodNumber>;
24
+ checkpoint: z.ZodOptional<z.ZodBoolean>;
25
+ }, z.core.$strip>>;
26
+ }, z.core.$strip>;
27
+ export declare const AddMessageBody: z.ZodObject<{
28
+ role: z.ZodEnum<{
29
+ user: "user";
30
+ assistant: "assistant";
31
+ system: "system";
32
+ }>;
33
+ content: z.ZodString;
34
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
35
+ }, z.core.$strip>;
36
+ export declare const ToolCallSchema: z.ZodObject<{
37
+ id: z.ZodString;
38
+ name: z.ZodString;
39
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
40
+ }, z.core.$strip>;
41
+ export declare const MessageSchema: z.ZodObject<{
42
+ role: z.ZodEnum<{
43
+ user: "user";
44
+ assistant: "assistant";
45
+ system: "system";
46
+ tool: "tool";
47
+ }>;
48
+ content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
49
+ type: z.ZodLiteral<"text">;
50
+ text: z.ZodString;
51
+ }, z.core.$strip>, z.ZodObject<{
52
+ type: z.ZodLiteral<"image_url">;
53
+ image_url: z.ZodObject<{
54
+ url: z.ZodString;
55
+ detail: z.ZodOptional<z.ZodEnum<{
56
+ auto: "auto";
57
+ low: "low";
58
+ high: "high";
59
+ }>>;
60
+ }, z.core.$strip>;
61
+ }, z.core.$strip>, z.ZodObject<{
62
+ type: z.ZodLiteral<"image_base64">;
63
+ image_base64: z.ZodObject<{
64
+ data: z.ZodString;
65
+ media_type: z.ZodString;
66
+ }, z.core.$strip>;
67
+ }, z.core.$strip>]>>]>;
68
+ name: z.ZodOptional<z.ZodString>;
69
+ toolCallId: z.ZodOptional<z.ZodString>;
70
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
71
+ id: z.ZodString;
72
+ name: z.ZodString;
73
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
74
+ }, z.core.$strip>>>;
75
+ }, z.core.$strip>;
76
+ export declare const UsageSchema: z.ZodObject<{
77
+ inputTokens: z.ZodNumber;
78
+ outputTokens: z.ZodNumber;
79
+ totalTokens: z.ZodNumber;
80
+ }, z.core.$strip>;
81
+ export declare const HealthResponse: z.ZodObject<{
82
+ status: z.ZodLiteral<"ok">;
83
+ uptime: z.ZodNumber;
84
+ timestamp: z.ZodNumber;
85
+ }, z.core.$strip>;
86
+ export declare const ReadyResponse: z.ZodObject<{
87
+ status: z.ZodLiteral<"ok">;
88
+ }, z.core.$strip>;
89
+ export declare const AgentListResponse: z.ZodObject<{
90
+ agents: z.ZodArray<z.ZodObject<{
91
+ name: z.ZodString;
92
+ description: z.ZodOptional<z.ZodString>;
93
+ tools: z.ZodArray<z.ZodString>;
94
+ }, z.core.$strip>>;
95
+ }, z.core.$strip>;
96
+ export declare const AgentRunResponse: z.ZodObject<{
97
+ output: z.ZodString;
98
+ structured: z.ZodOptional<z.ZodUnknown>;
99
+ threadId: z.ZodString;
100
+ usage: z.ZodObject<{
101
+ inputTokens: z.ZodNumber;
102
+ outputTokens: z.ZodNumber;
103
+ totalTokens: z.ZodNumber;
104
+ }, z.core.$strip>;
105
+ toolCalls: z.ZodArray<z.ZodObject<{
106
+ id: z.ZodString;
107
+ name: z.ZodString;
108
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
109
+ }, z.core.$strip>>;
110
+ }, z.core.$strip>;
111
+ export declare const ThreadResponse: z.ZodObject<{
112
+ id: z.ZodString;
113
+ messages: z.ZodArray<z.ZodObject<{
114
+ role: z.ZodEnum<{
115
+ user: "user";
116
+ assistant: "assistant";
117
+ system: "system";
118
+ tool: "tool";
119
+ }>;
120
+ content: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
121
+ type: z.ZodLiteral<"text">;
122
+ text: z.ZodString;
123
+ }, z.core.$strip>, z.ZodObject<{
124
+ type: z.ZodLiteral<"image_url">;
125
+ image_url: z.ZodObject<{
126
+ url: z.ZodString;
127
+ detail: z.ZodOptional<z.ZodEnum<{
128
+ auto: "auto";
129
+ low: "low";
130
+ high: "high";
131
+ }>>;
132
+ }, z.core.$strip>;
133
+ }, z.core.$strip>, z.ZodObject<{
134
+ type: z.ZodLiteral<"image_base64">;
135
+ image_base64: z.ZodObject<{
136
+ data: z.ZodString;
137
+ media_type: z.ZodString;
138
+ }, z.core.$strip>;
139
+ }, z.core.$strip>]>>]>;
140
+ name: z.ZodOptional<z.ZodString>;
141
+ toolCallId: z.ZodOptional<z.ZodString>;
142
+ toolCalls: z.ZodOptional<z.ZodArray<z.ZodObject<{
143
+ id: z.ZodString;
144
+ name: z.ZodString;
145
+ arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
146
+ }, z.core.$strip>>>;
147
+ }, z.core.$strip>>;
148
+ createdAt: z.ZodNumber;
149
+ updatedAt: z.ZodNumber;
150
+ }, z.core.$strip>;
151
+ export declare const AddMessageResponse: z.ZodObject<{
152
+ success: z.ZodLiteral<true>;
153
+ }, z.core.$strip>;
154
+ export declare const ToolListResponse: z.ZodObject<{
155
+ tools: z.ZodArray<z.ZodObject<{
156
+ name: z.ZodString;
157
+ description: z.ZodOptional<z.ZodString>;
158
+ parameters: z.ZodRecord<z.ZodString, z.ZodUnknown>;
159
+ }, z.core.$strip>>;
160
+ }, z.core.$strip>;
161
+ export declare const WorkflowListResponse: z.ZodObject<{
162
+ workflows: z.ZodArray<z.ZodObject<{
163
+ name: z.ZodString;
164
+ entryPoint: z.ZodString;
165
+ nodes: z.ZodArray<z.ZodString>;
166
+ }, z.core.$strip>>;
167
+ }, z.core.$strip>;
168
+ export declare const WorkflowRunResponse: z.ZodObject<{
169
+ workflowId: z.ZodString;
170
+ workflowName: z.ZodString;
171
+ state: z.ZodRecord<z.ZodString, z.ZodUnknown>;
172
+ duration: z.ZodNumber;
173
+ nodeResults: z.ZodRecord<z.ZodString, z.ZodObject<{
174
+ output: z.ZodUnknown;
175
+ duration: z.ZodNumber;
176
+ }, z.core.$strip>>;
177
+ }, z.core.$strip>;
178
+ export declare const SwarmListResponse: z.ZodObject<{
179
+ swarms: z.ZodArray<z.ZodObject<{
180
+ name: z.ZodString;
181
+ strategy: z.ZodString;
182
+ agents: z.ZodArray<z.ZodString>;
183
+ }, z.core.$strip>>;
184
+ }, z.core.$strip>;
185
+ export declare const SwarmRunResponse: z.ZodObject<{
186
+ swarmId: z.ZodString;
187
+ swarmName: z.ZodString;
188
+ strategy: z.ZodString;
189
+ output: z.ZodUnknown;
190
+ agentResults: z.ZodRecord<z.ZodString, z.ZodObject<{
191
+ output: z.ZodString;
192
+ usage: z.ZodObject<{
193
+ inputTokens: z.ZodNumber;
194
+ outputTokens: z.ZodNumber;
195
+ totalTokens: z.ZodNumber;
196
+ cost: z.ZodNumber;
197
+ duration: z.ZodNumber;
198
+ }, z.core.$strip>;
199
+ }, z.core.$strip>>;
200
+ usage: z.ZodObject<{
201
+ totalTokens: z.ZodNumber;
202
+ totalCost: z.ZodNumber;
203
+ elapsedTime: z.ZodNumber;
204
+ }, z.core.$strip>;
205
+ }, z.core.$strip>;
206
+ export declare const BlackboardResponse: z.ZodObject<{
207
+ sections: z.ZodRecord<z.ZodString, z.ZodUnknown>;
208
+ }, z.core.$strip>;
209
+ export declare const SocketMessage: z.ZodDiscriminatedUnion<[z.ZodObject<{
210
+ type: z.ZodLiteral<"ping">;
211
+ id: z.ZodOptional<z.ZodString>;
212
+ }, z.core.$strip>, z.ZodObject<{
213
+ type: z.ZodLiteral<"stop">;
214
+ id: z.ZodOptional<z.ZodString>;
215
+ }, z.core.$strip>, z.ZodObject<{
216
+ type: z.ZodLiteral<"run">;
217
+ id: z.ZodOptional<z.ZodString>;
218
+ payload: z.ZodObject<{
219
+ type: z.ZodEnum<{
220
+ agent: "agent";
221
+ workflow: "workflow";
222
+ swarm: "swarm";
223
+ }>;
224
+ name: z.ZodString;
225
+ input: z.ZodString;
226
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
227
+ threadId: z.ZodOptional<z.ZodString>;
228
+ }, z.core.$strip>;
229
+ }, z.core.$strip>], "type">;
230
+ export declare function errorEnvelope<const E extends string>(error: E, description: string): z.ZodObject<{
231
+ status: z.ZodNumber;
232
+ message: z.ZodString;
233
+ error: z.ZodLiteral<E>;
234
+ }, z.core.$strip>;
235
+ /**
236
+ * The envelope of every `CogitatorError` that maps to `status`, plus `extra` codes
237
+ * the adapter answers with itself.
238
+ */
239
+ export declare function failureEnvelope(status: number, description: string, extra?: string[]): z.ZodObject<{
240
+ status: z.ZodNumber;
241
+ message: z.ZodString;
242
+ error: z.ZodEnum<{
243
+ [x: string]: string;
244
+ }>;
245
+ }, z.core.$strip>;
246
+ /** What a run of an agent, a workflow or a swarm can fail with, besides its own refusals. */
247
+ export declare const RUN_FAILURES: {
248
+ readonly 400: z.ZodObject<{
249
+ status: z.ZodNumber;
250
+ message: z.ZodString;
251
+ error: z.ZodEnum<{
252
+ [x: string]: string;
253
+ }>;
254
+ }, z.core.$strip>;
255
+ readonly 409: z.ZodObject<{
256
+ status: z.ZodNumber;
257
+ message: z.ZodString;
258
+ error: z.ZodEnum<{
259
+ [x: string]: string;
260
+ }>;
261
+ }, z.core.$strip>;
262
+ readonly 429: z.ZodObject<{
263
+ status: z.ZodNumber;
264
+ message: z.ZodString;
265
+ error: z.ZodEnum<{
266
+ [x: string]: string;
267
+ }>;
268
+ }, z.core.$strip>;
269
+ readonly 500: z.ZodObject<{
270
+ status: z.ZodNumber;
271
+ message: z.ZodString;
272
+ error: z.ZodEnum<{
273
+ [x: string]: string;
274
+ }>;
275
+ }, z.core.$strip>;
276
+ readonly 502: z.ZodObject<{
277
+ status: z.ZodNumber;
278
+ message: z.ZodString;
279
+ error: z.ZodEnum<{
280
+ [x: string]: string;
281
+ }>;
282
+ }, z.core.$strip>;
283
+ readonly 503: z.ZodObject<{
284
+ status: z.ZodNumber;
285
+ message: z.ZodString;
286
+ error: z.ZodEnum<{
287
+ [x: string]: string;
288
+ }>;
289
+ }, z.core.$strip>;
290
+ readonly 504: z.ZodObject<{
291
+ status: z.ZodNumber;
292
+ message: z.ZodString;
293
+ error: z.ZodEnum<{
294
+ [x: string]: string;
295
+ }>;
296
+ }, z.core.$strip>;
297
+ readonly 507: z.ZodObject<{
298
+ status: z.ZodNumber;
299
+ message: z.ZodString;
300
+ error: z.ZodEnum<{
301
+ [x: string]: string;
302
+ }>;
303
+ }, z.core.$strip>;
304
+ };
305
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../src/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,eAAO,MAAM,UAAU;;iBAAwC,CAAC;AAChE,eAAO,MAAM,YAAY;;iBAAsC,CAAC;AAEhE,eAAO,MAAM,OAAO;;;;iBAIlB,CAAC;AAEH,eAAO,MAAM,YAAY;;;;;iBAEvB,CAAC;AAEH,eAAO,MAAM,eAAe;;;;;;;iBAS1B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;iBAIzB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;iBAIzB,CAAC;AAcH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMxB,CAAC;AAEH,eAAO,MAAM,WAAW;;;;iBAItB,CAAC;AAEH,eAAO,MAAM,cAAc;;;;iBAIzB,CAAC;AAEH,eAAO,MAAM,aAAa;;iBAAwC,CAAC;AAEnE,eAAO,MAAM,iBAAiB;;;;;;iBAQ5B,CAAC;AAEH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;iBAM3B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAKzB,CAAC;AAEH,eAAO,MAAM,kBAAkB;;iBAAyC,CAAC;AAEzE,eAAO,MAAM,gBAAgB;;;;;;iBAQ3B,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;iBAQ/B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;iBAM9B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;iBA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