veryfront 0.1.63 → 0.1.65
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.
- package/esm/deno.js +1 -1
- package/esm/src/agent/runtime/index.d.ts +1 -0
- package/esm/src/agent/runtime/index.d.ts.map +1 -1
- package/esm/src/agent/runtime/index.js +10 -2
- package/esm/src/channels/control-plane.d.ts +259 -0
- package/esm/src/channels/control-plane.d.ts.map +1 -0
- package/esm/src/channels/control-plane.js +212 -0
- package/esm/src/channels/invoke.d.ts +71 -44
- package/esm/src/channels/invoke.d.ts.map +1 -1
- package/esm/src/channels/invoke.js +33 -114
- package/esm/src/integrations/endpoint-executor.d.ts +1 -0
- package/esm/src/integrations/endpoint-executor.d.ts.map +1 -1
- package/esm/src/integrations/endpoint-executor.js +44 -0
- package/esm/src/internal-agents/ag-ui-sse.d.ts +35 -0
- package/esm/src/internal-agents/ag-ui-sse.d.ts.map +1 -0
- package/esm/src/internal-agents/ag-ui-sse.js +263 -0
- package/esm/src/internal-agents/control-plane-auth.d.ts +20 -0
- package/esm/src/internal-agents/control-plane-auth.d.ts.map +1 -0
- package/esm/src/internal-agents/control-plane-auth.js +56 -0
- package/esm/src/internal-agents/request-body.d.ts +9 -0
- package/esm/src/internal-agents/request-body.d.ts.map +1 -0
- package/esm/src/internal-agents/request-body.js +28 -0
- package/esm/src/internal-agents/run-stream.d.ts +14 -0
- package/esm/src/internal-agents/run-stream.d.ts.map +1 -0
- package/esm/src/internal-agents/run-stream.js +259 -0
- package/esm/src/internal-agents/schema.d.ts +268 -0
- package/esm/src/internal-agents/schema.d.ts.map +1 -0
- package/esm/src/internal-agents/schema.js +71 -0
- package/esm/src/internal-agents/session-manager.d.ts +63 -0
- package/esm/src/internal-agents/session-manager.d.ts.map +1 -0
- package/esm/src/internal-agents/session-manager.js +258 -0
- package/esm/src/platform/adapters/runtime/deno/adapter.d.ts.map +1 -1
- package/esm/src/platform/adapters/runtime/deno/adapter.js +4 -13
- package/esm/src/platform/compat/process.d.ts.map +1 -1
- package/esm/src/platform/compat/process.js +42 -5
- package/esm/src/server/handlers/request/agent-run-cancel.handler.d.ts +11 -0
- package/esm/src/server/handlers/request/agent-run-cancel.handler.d.ts.map +1 -0
- package/esm/src/server/handlers/request/agent-run-cancel.handler.js +62 -0
- package/esm/src/server/handlers/request/agent-run-resume.handler.d.ts +11 -0
- package/esm/src/server/handlers/request/agent-run-resume.handler.d.ts.map +1 -0
- package/esm/src/server/handlers/request/agent-run-resume.handler.js +77 -0
- package/esm/src/server/handlers/request/agent-stream.handler.d.ts +14 -0
- package/esm/src/server/handlers/request/agent-stream.handler.d.ts.map +1 -0
- package/esm/src/server/handlers/request/agent-stream.handler.js +86 -0
- package/esm/src/server/handlers/request/internal-agents-list.handler.d.ts +11 -0
- package/esm/src/server/handlers/request/internal-agents-list.handler.d.ts.map +1 -0
- package/esm/src/server/handlers/request/internal-agents-list.handler.js +73 -0
- package/esm/src/server/runtime-handler/index.d.ts.map +1 -1
- package/esm/src/server/runtime-handler/index.js +8 -0
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/src/agent/runtime/index.ts +12 -2
- package/src/src/channels/control-plane.ts +332 -0
- package/src/src/channels/invoke.ts +44 -164
- package/src/src/integrations/endpoint-executor.ts +51 -0
- package/src/src/internal-agents/ag-ui-sse.ts +327 -0
- package/src/src/internal-agents/control-plane-auth.ts +82 -0
- package/src/src/internal-agents/request-body.ts +42 -0
- package/src/src/internal-agents/run-stream.ts +354 -0
- package/src/src/internal-agents/schema.ts +102 -0
- package/src/src/internal-agents/session-manager.ts +358 -0
- package/src/src/platform/adapters/runtime/deno/adapter.ts +9 -11
- package/src/src/platform/compat/process.ts +56 -3
- package/src/src/server/handlers/request/agent-run-cancel.handler.ts +86 -0
- package/src/src/server/handlers/request/agent-run-resume.handler.ts +108 -0
- package/src/src/server/handlers/request/agent-stream.handler.ts +125 -0
- package/src/src/server/handlers/request/internal-agents-list.handler.ts +100 -0
- package/src/src/server/runtime-handler/index.ts +8 -0
package/esm/deno.js
CHANGED
|
@@ -54,6 +54,7 @@ export declare class AgentRuntime {
|
|
|
54
54
|
stream(messages: Message[], context?: Record<string, unknown>, callbacks?: {
|
|
55
55
|
onToolCall?: (toolCall: ToolCall) => void;
|
|
56
56
|
onChunk?: (chunk: string) => void;
|
|
57
|
+
onFinish?: (response: AgentResponse) => void;
|
|
57
58
|
}, modelOverride?: string, maxOutputTokensOverride?: number): Promise<ReadableStream<Uint8Array>>;
|
|
58
59
|
/**
|
|
59
60
|
* Execute agent loop (with tool calling)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAGlB,KAAK,OAAO,EAEZ,KAAK,QAAQ,EACd,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAe/D,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACpF,YAAY,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC1E,YAAY,EAAE,iBAAiB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAClG,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,gBAAgB,CAAC;AAqBxB;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,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{ type: "text-start", id: textPartId });
|
|
207
|
-
await this.executeAgentLoopStreaming(systemPrompt, memoryMessages, controller, encoder, callbacks, textPartId, toolContext, resolvedModelString, languageModel, maxOutputTokensOverride);
|
|
207
|
+
const response = await this.executeAgentLoopStreaming(systemPrompt, memoryMessages, controller, encoder, callbacks, textPartId, toolContext, resolvedModelString, languageModel, maxOutputTokensOverride);
|
|
208
|
+
callbacks?.onFinish?.(response);
|
|
208
209
|
sendSSE(controller, encoder, { type: "text-end", id: textPartId });
|
|
209
210
|
sendSSE(controller, encoder, { type: "message-finish" });
|
|
210
211
|
controller.close();
|
|
@@ -344,7 +345,10 @@ export class AgentRuntime {
|
|
|
344
345
|
try {
|
|
345
346
|
toolCall.status = "executing";
|
|
346
347
|
const startTime = Date.now();
|
|
347
|
-
const result = await executeTool(tc.toolName, toolCall.args, {
|
|
348
|
+
const result = await executeTool(tc.toolName, toolCall.args, {
|
|
349
|
+
agentId: this.id,
|
|
350
|
+
toolCallId: tc.toolCallId,
|
|
351
|
+
});
|
|
348
352
|
toolCall.status = "completed";
|
|
349
353
|
toolCall.result = result;
|
|
350
354
|
toolCall.executionTime = Date.now() - startTime;
|
|
@@ -429,6 +433,7 @@ export class AgentRuntime {
|
|
|
429
433
|
}
|
|
430
434
|
// Request-scoped skill policy (not class-level mutable state)
|
|
431
435
|
let activeSkillPolicy;
|
|
436
|
+
let finalFinishReason;
|
|
432
437
|
for (let step = 0; step < maxSteps; step++) {
|
|
433
438
|
sendSSE(controller, encoder, { type: "step-start" });
|
|
434
439
|
let tools = isLocalStreaming ? [] : getAvailableTools(this.config.tools, {
|
|
@@ -451,6 +456,7 @@ export class AgentRuntime {
|
|
|
451
456
|
onChunk: callbacks?.onChunk,
|
|
452
457
|
onUsage: (usage) => accumulateUsage(totalUsage, usage),
|
|
453
458
|
});
|
|
459
|
+
finalFinishReason = state.finishReason ?? finalFinishReason;
|
|
454
460
|
const streamParts = [];
|
|
455
461
|
if (state.accumulatedText)
|
|
456
462
|
streamParts.push({ type: "text", text: state.accumulatedText });
|
|
@@ -515,6 +521,7 @@ export class AgentRuntime {
|
|
|
515
521
|
callbacks?.onToolCall?.(toolCall);
|
|
516
522
|
const result = await executeTool(tc.name, toolCall.args, {
|
|
517
523
|
agentId: this.id,
|
|
524
|
+
toolCallId: tc.id,
|
|
518
525
|
...toolContext,
|
|
519
526
|
});
|
|
520
527
|
toolCall.status = "completed";
|
|
@@ -564,6 +571,7 @@ export class AgentRuntime {
|
|
|
564
571
|
toolCalls,
|
|
565
572
|
status: "completed",
|
|
566
573
|
usage: totalUsage,
|
|
574
|
+
metadata: finalFinishReason ? { finishReason: finalFinishReason } : undefined,
|
|
567
575
|
};
|
|
568
576
|
}
|
|
569
577
|
/**
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import type { Agent } from "../agent/index.js";
|
|
2
|
+
import type { HandlerContext } from "../types/index.js";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
export declare const ControlPlaneSurfaceSchema: z.ZodEnum<["studio", "channels", "a2a", "mcp"]>;
|
|
5
|
+
export declare const ControlPlaneAgentsListRequestSchema: z.ZodObject<{
|
|
6
|
+
requestId: z.ZodString;
|
|
7
|
+
projectId: z.ZodString;
|
|
8
|
+
surface: z.ZodEnum<["studio", "channels", "a2a", "mcp"]>;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
requestId: string;
|
|
11
|
+
projectId: string;
|
|
12
|
+
surface: "mcp" | "studio" | "channels" | "a2a";
|
|
13
|
+
}, {
|
|
14
|
+
requestId: string;
|
|
15
|
+
projectId: string;
|
|
16
|
+
surface: "mcp" | "studio" | "channels" | "a2a";
|
|
17
|
+
}>;
|
|
18
|
+
export declare const RuntimeAgentSkillSchema: z.ZodObject<{
|
|
19
|
+
id: z.ZodString;
|
|
20
|
+
name: z.ZodString;
|
|
21
|
+
description: z.ZodOptional<z.ZodString>;
|
|
22
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
23
|
+
examples: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
name: string;
|
|
26
|
+
id: string;
|
|
27
|
+
description?: string | undefined;
|
|
28
|
+
tags?: string[] | undefined;
|
|
29
|
+
examples?: string[] | undefined;
|
|
30
|
+
}, {
|
|
31
|
+
name: string;
|
|
32
|
+
id: string;
|
|
33
|
+
description?: string | undefined;
|
|
34
|
+
tags?: string[] | undefined;
|
|
35
|
+
examples?: string[] | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
export declare const RuntimeAgentSchema: z.ZodObject<{
|
|
38
|
+
id: z.ZodString;
|
|
39
|
+
name: z.ZodString;
|
|
40
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
41
|
+
model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
42
|
+
version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
43
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
44
|
+
id: z.ZodString;
|
|
45
|
+
name: z.ZodString;
|
|
46
|
+
description: z.ZodOptional<z.ZodString>;
|
|
47
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
48
|
+
examples: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
name: string;
|
|
51
|
+
id: string;
|
|
52
|
+
description?: string | undefined;
|
|
53
|
+
tags?: string[] | undefined;
|
|
54
|
+
examples?: string[] | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
name: string;
|
|
57
|
+
id: string;
|
|
58
|
+
description?: string | undefined;
|
|
59
|
+
tags?: string[] | undefined;
|
|
60
|
+
examples?: string[] | undefined;
|
|
61
|
+
}>, "many">>;
|
|
62
|
+
}, "strip", z.ZodTypeAny, {
|
|
63
|
+
name: string;
|
|
64
|
+
id: string;
|
|
65
|
+
description?: string | null | undefined;
|
|
66
|
+
version?: string | null | undefined;
|
|
67
|
+
model?: string | null | undefined;
|
|
68
|
+
skills?: {
|
|
69
|
+
name: string;
|
|
70
|
+
id: string;
|
|
71
|
+
description?: string | undefined;
|
|
72
|
+
tags?: string[] | undefined;
|
|
73
|
+
examples?: string[] | undefined;
|
|
74
|
+
}[] | undefined;
|
|
75
|
+
}, {
|
|
76
|
+
name: string;
|
|
77
|
+
id: string;
|
|
78
|
+
description?: string | null | undefined;
|
|
79
|
+
version?: string | null | undefined;
|
|
80
|
+
model?: string | null | undefined;
|
|
81
|
+
skills?: {
|
|
82
|
+
name: string;
|
|
83
|
+
id: string;
|
|
84
|
+
description?: string | undefined;
|
|
85
|
+
tags?: string[] | undefined;
|
|
86
|
+
examples?: string[] | undefined;
|
|
87
|
+
}[] | undefined;
|
|
88
|
+
}>;
|
|
89
|
+
export declare const RuntimeAgentListResponseSchema: z.ZodObject<{
|
|
90
|
+
agents: z.ZodArray<z.ZodObject<{
|
|
91
|
+
id: z.ZodString;
|
|
92
|
+
name: z.ZodString;
|
|
93
|
+
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
94
|
+
model: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
95
|
+
version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
96
|
+
skills: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
97
|
+
id: z.ZodString;
|
|
98
|
+
name: z.ZodString;
|
|
99
|
+
description: z.ZodOptional<z.ZodString>;
|
|
100
|
+
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
101
|
+
examples: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
name: string;
|
|
104
|
+
id: string;
|
|
105
|
+
description?: string | undefined;
|
|
106
|
+
tags?: string[] | undefined;
|
|
107
|
+
examples?: string[] | undefined;
|
|
108
|
+
}, {
|
|
109
|
+
name: string;
|
|
110
|
+
id: string;
|
|
111
|
+
description?: string | undefined;
|
|
112
|
+
tags?: string[] | undefined;
|
|
113
|
+
examples?: string[] | undefined;
|
|
114
|
+
}>, "many">>;
|
|
115
|
+
}, "strip", z.ZodTypeAny, {
|
|
116
|
+
name: string;
|
|
117
|
+
id: string;
|
|
118
|
+
description?: string | null | undefined;
|
|
119
|
+
version?: string | null | undefined;
|
|
120
|
+
model?: string | null | undefined;
|
|
121
|
+
skills?: {
|
|
122
|
+
name: string;
|
|
123
|
+
id: string;
|
|
124
|
+
description?: string | undefined;
|
|
125
|
+
tags?: string[] | undefined;
|
|
126
|
+
examples?: string[] | undefined;
|
|
127
|
+
}[] | undefined;
|
|
128
|
+
}, {
|
|
129
|
+
name: string;
|
|
130
|
+
id: string;
|
|
131
|
+
description?: string | null | undefined;
|
|
132
|
+
version?: string | null | undefined;
|
|
133
|
+
model?: string | null | undefined;
|
|
134
|
+
skills?: {
|
|
135
|
+
name: string;
|
|
136
|
+
id: string;
|
|
137
|
+
description?: string | undefined;
|
|
138
|
+
tags?: string[] | undefined;
|
|
139
|
+
examples?: string[] | undefined;
|
|
140
|
+
}[] | undefined;
|
|
141
|
+
}>, "many">;
|
|
142
|
+
}, "strip", z.ZodTypeAny, {
|
|
143
|
+
agents: {
|
|
144
|
+
name: string;
|
|
145
|
+
id: string;
|
|
146
|
+
description?: string | null | undefined;
|
|
147
|
+
version?: string | null | undefined;
|
|
148
|
+
model?: string | null | undefined;
|
|
149
|
+
skills?: {
|
|
150
|
+
name: string;
|
|
151
|
+
id: string;
|
|
152
|
+
description?: string | undefined;
|
|
153
|
+
tags?: string[] | undefined;
|
|
154
|
+
examples?: string[] | undefined;
|
|
155
|
+
}[] | undefined;
|
|
156
|
+
}[];
|
|
157
|
+
}, {
|
|
158
|
+
agents: {
|
|
159
|
+
name: string;
|
|
160
|
+
id: string;
|
|
161
|
+
description?: string | null | undefined;
|
|
162
|
+
version?: string | null | undefined;
|
|
163
|
+
model?: string | null | undefined;
|
|
164
|
+
skills?: {
|
|
165
|
+
name: string;
|
|
166
|
+
id: string;
|
|
167
|
+
description?: string | undefined;
|
|
168
|
+
tags?: string[] | undefined;
|
|
169
|
+
examples?: string[] | undefined;
|
|
170
|
+
}[] | undefined;
|
|
171
|
+
}[];
|
|
172
|
+
}>;
|
|
173
|
+
declare const dispatchClaimsSchema: z.ZodObject<{
|
|
174
|
+
iss: z.ZodString;
|
|
175
|
+
aud: z.ZodString;
|
|
176
|
+
sub: z.ZodString;
|
|
177
|
+
project_id: z.ZodString;
|
|
178
|
+
platform: z.ZodString;
|
|
179
|
+
body_sha256: z.ZodString;
|
|
180
|
+
iat: z.ZodNumber;
|
|
181
|
+
exp: z.ZodNumber;
|
|
182
|
+
}, "strip", z.ZodTypeAny, {
|
|
183
|
+
project_id: string;
|
|
184
|
+
platform: string;
|
|
185
|
+
sub: string;
|
|
186
|
+
iss: string;
|
|
187
|
+
aud: string;
|
|
188
|
+
body_sha256: string;
|
|
189
|
+
iat: number;
|
|
190
|
+
exp: number;
|
|
191
|
+
}, {
|
|
192
|
+
project_id: string;
|
|
193
|
+
platform: string;
|
|
194
|
+
sub: string;
|
|
195
|
+
iss: string;
|
|
196
|
+
aud: string;
|
|
197
|
+
body_sha256: string;
|
|
198
|
+
iat: number;
|
|
199
|
+
exp: number;
|
|
200
|
+
}>;
|
|
201
|
+
declare const controlPlaneClaimsSchema: z.ZodObject<{
|
|
202
|
+
iss: z.ZodString;
|
|
203
|
+
aud: z.ZodString;
|
|
204
|
+
sub: z.ZodString;
|
|
205
|
+
surface: z.ZodEnum<["studio", "channels", "a2a", "mcp"]>;
|
|
206
|
+
project_id: z.ZodString;
|
|
207
|
+
request_hash: z.ZodString;
|
|
208
|
+
iat: z.ZodNumber;
|
|
209
|
+
exp: z.ZodNumber;
|
|
210
|
+
}, "strip", z.ZodTypeAny, {
|
|
211
|
+
project_id: string;
|
|
212
|
+
sub: string;
|
|
213
|
+
surface: "mcp" | "studio" | "channels" | "a2a";
|
|
214
|
+
iss: string;
|
|
215
|
+
aud: string;
|
|
216
|
+
iat: number;
|
|
217
|
+
exp: number;
|
|
218
|
+
request_hash: string;
|
|
219
|
+
}, {
|
|
220
|
+
project_id: string;
|
|
221
|
+
sub: string;
|
|
222
|
+
surface: "mcp" | "studio" | "channels" | "a2a";
|
|
223
|
+
iss: string;
|
|
224
|
+
aud: string;
|
|
225
|
+
iat: number;
|
|
226
|
+
exp: number;
|
|
227
|
+
request_hash: string;
|
|
228
|
+
}>;
|
|
229
|
+
export type ControlPlaneSurface = z.infer<typeof ControlPlaneSurfaceSchema>;
|
|
230
|
+
export type ControlPlaneAgentsListRequest = z.infer<typeof ControlPlaneAgentsListRequestSchema>;
|
|
231
|
+
export type RuntimeAgentSkill = z.infer<typeof RuntimeAgentSkillSchema>;
|
|
232
|
+
export type RuntimeAgent = z.infer<typeof RuntimeAgentSchema>;
|
|
233
|
+
export type RuntimeAgentListResponse = z.infer<typeof RuntimeAgentListResponseSchema>;
|
|
234
|
+
export type DispatchClaims = z.infer<typeof dispatchClaimsSchema>;
|
|
235
|
+
export type ControlPlaneClaims = z.infer<typeof controlPlaneClaimsSchema>;
|
|
236
|
+
export interface RuntimeAgentDiscoveryDeps {
|
|
237
|
+
ensureProjectDiscovery: (ctx: HandlerContext) => Promise<void>;
|
|
238
|
+
getAgent: (id: string) => Agent | undefined;
|
|
239
|
+
getAllAgentIds: () => string[];
|
|
240
|
+
}
|
|
241
|
+
export declare function listRuntimeAgents(ctx: HandlerContext, deps: RuntimeAgentDiscoveryDeps): Promise<RuntimeAgentListResponse>;
|
|
242
|
+
export declare function verifyDispatchJws(jws: string, body: string, options: {
|
|
243
|
+
audience: string;
|
|
244
|
+
expectedPlatform?: string;
|
|
245
|
+
expectedProjectId?: string;
|
|
246
|
+
expectedSubject?: string;
|
|
247
|
+
maxAgeSeconds: number;
|
|
248
|
+
publicKeyPem: string;
|
|
249
|
+
}): Promise<DispatchClaims>;
|
|
250
|
+
export declare function verifyControlPlaneJws(jws: string, body: string, options: {
|
|
251
|
+
audience: string;
|
|
252
|
+
expectedProjectId?: string;
|
|
253
|
+
expectedSubject?: string;
|
|
254
|
+
expectedSurface?: ControlPlaneSurface;
|
|
255
|
+
maxAgeSeconds: number;
|
|
256
|
+
publicKeyPem: string;
|
|
257
|
+
}): Promise<ControlPlaneClaims>;
|
|
258
|
+
export {};
|
|
259
|
+
//# sourceMappingURL=control-plane.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-plane.d.ts","sourceRoot":"","sources":["../../../src/src/channels/control-plane.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAUxB,eAAO,MAAM,yBAAyB,iDAA+C,CAAC;AAEtF,eAAO,MAAM,mCAAmC;;;;;;;;;;;;EAI9C,CAAC;AAEH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;EAMlC,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAO7B,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAEzC,CAAC;AAEH,QAAA,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;EASxB,CAAC;AAEH,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAS5B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAC;AAChG,MAAM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,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;CACtB,GACA,OAAO,CAAC,kBAAkB,CAAC,CAmB7B"}
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
import * as dntShim from "../../_dnt.shims.js";
|
|
2
|
+
import { skillRegistry } from "../skill/registry.js";
|
|
3
|
+
import { base64urlEncodeBytes } from "../utils/base64url.js";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
const SIGNATURE_SKEW_SECONDS = 5;
|
|
6
|
+
const compactJwsHeaderSchema = z.object({
|
|
7
|
+
alg: z.literal("EdDSA"),
|
|
8
|
+
typ: z.string().optional(),
|
|
9
|
+
kid: z.string().optional(),
|
|
10
|
+
});
|
|
11
|
+
export const ControlPlaneSurfaceSchema = z.enum(["studio", "channels", "a2a", "mcp"]);
|
|
12
|
+
export const ControlPlaneAgentsListRequestSchema = z.object({
|
|
13
|
+
requestId: z.string().min(1),
|
|
14
|
+
projectId: z.string().min(1),
|
|
15
|
+
surface: ControlPlaneSurfaceSchema,
|
|
16
|
+
});
|
|
17
|
+
export const RuntimeAgentSkillSchema = z.object({
|
|
18
|
+
id: z.string().min(1),
|
|
19
|
+
name: z.string().min(1),
|
|
20
|
+
description: z.string().optional(),
|
|
21
|
+
tags: z.array(z.string()).optional(),
|
|
22
|
+
examples: z.array(z.string()).optional(),
|
|
23
|
+
});
|
|
24
|
+
export const RuntimeAgentSchema = z.object({
|
|
25
|
+
id: z.string().min(1),
|
|
26
|
+
name: z.string().min(1),
|
|
27
|
+
description: z.string().nullable().optional(),
|
|
28
|
+
model: z.string().nullable().optional(),
|
|
29
|
+
version: z.string().nullable().optional(),
|
|
30
|
+
skills: z.array(RuntimeAgentSkillSchema).optional(),
|
|
31
|
+
});
|
|
32
|
+
export const RuntimeAgentListResponseSchema = z.object({
|
|
33
|
+
agents: z.array(RuntimeAgentSchema),
|
|
34
|
+
});
|
|
35
|
+
const dispatchClaimsSchema = z.object({
|
|
36
|
+
iss: z.string(),
|
|
37
|
+
aud: z.string(),
|
|
38
|
+
sub: z.string(),
|
|
39
|
+
project_id: z.string(),
|
|
40
|
+
platform: z.string(),
|
|
41
|
+
body_sha256: z.string(),
|
|
42
|
+
iat: z.number().int(),
|
|
43
|
+
exp: z.number().int(),
|
|
44
|
+
});
|
|
45
|
+
const controlPlaneClaimsSchema = z.object({
|
|
46
|
+
iss: z.string(),
|
|
47
|
+
aud: z.string(),
|
|
48
|
+
sub: z.string(),
|
|
49
|
+
surface: ControlPlaneSurfaceSchema,
|
|
50
|
+
project_id: z.string(),
|
|
51
|
+
request_hash: z.string(),
|
|
52
|
+
iat: z.number().int(),
|
|
53
|
+
exp: z.number().int(),
|
|
54
|
+
});
|
|
55
|
+
function base64urlDecodeToBytes(input) {
|
|
56
|
+
const normalized = input
|
|
57
|
+
.replaceAll("-", "+")
|
|
58
|
+
.replaceAll("_", "/")
|
|
59
|
+
.padEnd(Math.ceil(input.length / 4) * 4, "=");
|
|
60
|
+
return toArrayBuffer(Uint8Array.from(atob(normalized), (char) => char.charCodeAt(0)));
|
|
61
|
+
}
|
|
62
|
+
function toArrayBuffer(bytes) {
|
|
63
|
+
const buffer = new ArrayBuffer(bytes.byteLength);
|
|
64
|
+
new Uint8Array(buffer).set(bytes);
|
|
65
|
+
return buffer;
|
|
66
|
+
}
|
|
67
|
+
function pemToDer(pem, label) {
|
|
68
|
+
const body = pem
|
|
69
|
+
.replace(`-----BEGIN ${label}-----`, "")
|
|
70
|
+
.replace(`-----END ${label}-----`, "")
|
|
71
|
+
.replace(/\s/g, "");
|
|
72
|
+
return toArrayBuffer(Uint8Array.from(atob(body), (char) => char.charCodeAt(0)));
|
|
73
|
+
}
|
|
74
|
+
async function importEd25519PublicKey(pem) {
|
|
75
|
+
return dntShim.crypto.subtle.importKey("spki", pemToDer(pem, "PUBLIC KEY"), "Ed25519", false, ["verify"]);
|
|
76
|
+
}
|
|
77
|
+
async function sha256Base64url(body) {
|
|
78
|
+
const hash = await dntShim.crypto.subtle.digest("SHA-256", new TextEncoder().encode(body));
|
|
79
|
+
return base64urlEncodeBytes(new Uint8Array(hash));
|
|
80
|
+
}
|
|
81
|
+
async function verifySignedRequestJws(jws, body, options) {
|
|
82
|
+
const parts = jws.split(".");
|
|
83
|
+
if (parts.length !== 3) {
|
|
84
|
+
throw new Error("Control-plane signature must be a compact JWS");
|
|
85
|
+
}
|
|
86
|
+
const encodedHeader = parts[0];
|
|
87
|
+
const encodedPayload = parts[1];
|
|
88
|
+
const encodedSignature = parts[2];
|
|
89
|
+
if (!encodedHeader || !encodedPayload || !encodedSignature) {
|
|
90
|
+
throw new Error("Control-plane signature must include header, payload, and signature");
|
|
91
|
+
}
|
|
92
|
+
const header = compactJwsHeaderSchema.parse(JSON.parse(new TextDecoder().decode(base64urlDecodeToBytes(encodedHeader))));
|
|
93
|
+
const claims = options.claimsSchema.parse(JSON.parse(new TextDecoder().decode(base64urlDecodeToBytes(encodedPayload))));
|
|
94
|
+
if (header.alg !== "EdDSA") {
|
|
95
|
+
throw new Error("Unsupported control-plane JWS algorithm");
|
|
96
|
+
}
|
|
97
|
+
const signingInput = new TextEncoder().encode(`${encodedHeader}.${encodedPayload}`);
|
|
98
|
+
const signature = base64urlDecodeToBytes(encodedSignature);
|
|
99
|
+
const publicKey = await importEd25519PublicKey(options.publicKeyPem);
|
|
100
|
+
const verified = await dntShim.crypto.subtle.verify("Ed25519", publicKey, signature, signingInput);
|
|
101
|
+
if (!verified) {
|
|
102
|
+
throw new Error("Control-plane signature verification failed");
|
|
103
|
+
}
|
|
104
|
+
if (claims.iss !== "veryfront-api") {
|
|
105
|
+
throw new Error("Control-plane issuer mismatch");
|
|
106
|
+
}
|
|
107
|
+
if (claims.aud !== options.audience) {
|
|
108
|
+
throw new Error("Control-plane audience mismatch");
|
|
109
|
+
}
|
|
110
|
+
if (options.expectedProjectId && claims.project_id !== options.expectedProjectId) {
|
|
111
|
+
throw new Error("Control-plane project mismatch");
|
|
112
|
+
}
|
|
113
|
+
if (options.expectedSubject && claims.sub !== options.expectedSubject) {
|
|
114
|
+
throw new Error("Control-plane subject mismatch");
|
|
115
|
+
}
|
|
116
|
+
if (options.scopedClaim && claims[options.scopedClaim.key] !== options.scopedClaim.value) {
|
|
117
|
+
throw new Error(`Control-plane ${options.scopedClaim.label} mismatch`);
|
|
118
|
+
}
|
|
119
|
+
const now = Math.floor(Date.now() / 1000);
|
|
120
|
+
if (claims.exp <= now) {
|
|
121
|
+
throw new Error("Control-plane signature expired");
|
|
122
|
+
}
|
|
123
|
+
if (claims.iat > now + SIGNATURE_SKEW_SECONDS) {
|
|
124
|
+
throw new Error("Control-plane signature issued in the future");
|
|
125
|
+
}
|
|
126
|
+
if (now - claims.iat > options.maxAgeSeconds) {
|
|
127
|
+
throw new Error("Control-plane signature is too old");
|
|
128
|
+
}
|
|
129
|
+
const requestHash = claims[options.hashClaimKey];
|
|
130
|
+
if (typeof requestHash !== "string") {
|
|
131
|
+
throw new Error("Control-plane request hash is missing");
|
|
132
|
+
}
|
|
133
|
+
const bodyHash = await sha256Base64url(body);
|
|
134
|
+
if (requestHash !== bodyHash) {
|
|
135
|
+
throw new Error("Control-plane body hash mismatch");
|
|
136
|
+
}
|
|
137
|
+
return claims;
|
|
138
|
+
}
|
|
139
|
+
function resolveAgentSkills(agent) {
|
|
140
|
+
if (!agent.config.skills) {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
return Array.from(skillRegistry.resolveForAgent(agent.config.skills).values())
|
|
144
|
+
.map((skill) => RuntimeAgentSkillSchema.parse({
|
|
145
|
+
id: skill.id,
|
|
146
|
+
name: skill.metadata.name || skill.id,
|
|
147
|
+
...(skill.metadata.description ? { description: skill.metadata.description } : {}),
|
|
148
|
+
}))
|
|
149
|
+
.sort((left, right) => left.name.localeCompare(right.name));
|
|
150
|
+
}
|
|
151
|
+
function getRuntimeAgentMetadata(agent) {
|
|
152
|
+
const rawConfig = agent.config;
|
|
153
|
+
return RuntimeAgentSchema.parse({
|
|
154
|
+
id: agent.id,
|
|
155
|
+
name: typeof rawConfig.name === "string" && rawConfig.name.trim().length > 0
|
|
156
|
+
? rawConfig.name
|
|
157
|
+
: agent.id,
|
|
158
|
+
description: typeof rawConfig.description === "string" ? rawConfig.description : null,
|
|
159
|
+
model: agent.config.model ?? null,
|
|
160
|
+
version: typeof rawConfig.version === "string" ? rawConfig.version : null,
|
|
161
|
+
skills: resolveAgentSkills(agent),
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
export async function listRuntimeAgents(ctx, deps) {
|
|
165
|
+
await deps.ensureProjectDiscovery(ctx);
|
|
166
|
+
const agents = deps.getAllAgentIds()
|
|
167
|
+
.map((id) => deps.getAgent(id))
|
|
168
|
+
.filter((agent) => Boolean(agent))
|
|
169
|
+
.map(getRuntimeAgentMetadata)
|
|
170
|
+
.sort((left, right) => left.name.localeCompare(right.name));
|
|
171
|
+
return RuntimeAgentListResponseSchema.parse({ agents });
|
|
172
|
+
}
|
|
173
|
+
export async function verifyDispatchJws(jws, body, options) {
|
|
174
|
+
return verifySignedRequestJws(jws, body, {
|
|
175
|
+
audience: options.audience,
|
|
176
|
+
claimsSchema: dispatchClaimsSchema,
|
|
177
|
+
expectedProjectId: options.expectedProjectId,
|
|
178
|
+
...(options.expectedSubject ? { expectedSubject: options.expectedSubject } : {}),
|
|
179
|
+
hashClaimKey: "body_sha256",
|
|
180
|
+
maxAgeSeconds: options.maxAgeSeconds,
|
|
181
|
+
publicKeyPem: options.publicKeyPem,
|
|
182
|
+
...(options.expectedPlatform
|
|
183
|
+
? {
|
|
184
|
+
scopedClaim: {
|
|
185
|
+
key: "platform",
|
|
186
|
+
label: "platform",
|
|
187
|
+
value: options.expectedPlatform,
|
|
188
|
+
},
|
|
189
|
+
}
|
|
190
|
+
: {}),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
export async function verifyControlPlaneJws(jws, body, options) {
|
|
194
|
+
return verifySignedRequestJws(jws, body, {
|
|
195
|
+
audience: options.audience,
|
|
196
|
+
claimsSchema: controlPlaneClaimsSchema,
|
|
197
|
+
expectedProjectId: options.expectedProjectId,
|
|
198
|
+
...(options.expectedSubject ? { expectedSubject: options.expectedSubject } : {}),
|
|
199
|
+
hashClaimKey: "request_hash",
|
|
200
|
+
maxAgeSeconds: options.maxAgeSeconds,
|
|
201
|
+
publicKeyPem: options.publicKeyPem,
|
|
202
|
+
...(options.expectedSurface
|
|
203
|
+
? {
|
|
204
|
+
scopedClaim: {
|
|
205
|
+
key: "surface",
|
|
206
|
+
label: "surface",
|
|
207
|
+
value: options.expectedSurface,
|
|
208
|
+
},
|
|
209
|
+
}
|
|
210
|
+
: {}),
|
|
211
|
+
});
|
|
212
|
+
}
|