@finalai/agent-definition 0.5.0 → 0.6.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.
- package/HOSTING.md +7 -7
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/compiler-assets/{chunk-FU5VHNO4.ts → chunk-3R7MNW5L.ts} +1 -1
- package/dist/compiler-assets/{chunk-7KPWSOMK.ts → chunk-3SDZJK7K.ts} +1 -1
- package/dist/compiler-assets/{chunk-KTXTYIF4.ts → chunk-4A4EQHYK.ts} +57 -20
- package/dist/compiler-assets/{chunk-S5ON7OBR.ts → chunk-4MJF3ALN.ts} +5 -5
- package/dist/compiler-assets/{chunk-QVHDGZAN.ts → chunk-4T2URCJZ.ts} +2 -2
- package/dist/compiler-assets/{chunk-7MDGEPFT.ts → chunk-6K3WO73F.ts} +1 -1
- package/dist/compiler-assets/{chunk-KMBQVNAJ.ts → chunk-AMYJRTAC.ts} +3 -3
- package/dist/compiler-assets/{chunk-OVAUXBQU.ts → chunk-BHNF7BEJ.ts} +86 -17
- package/dist/compiler-assets/{chunk-L7E6UQX3.ts → chunk-CORCFNEY.ts} +3 -3
- package/dist/compiler-assets/{chunk-4ERFBLH7.ts → chunk-DRHDNSCQ.ts} +4 -4
- package/dist/compiler-assets/{chunk-O3JKMLDP.ts → chunk-EKR4AEM5.ts} +3 -3
- package/dist/compiler-assets/{chunk-YOE37BRR.ts → chunk-FE7PIPSW.ts} +57 -10
- package/dist/compiler-assets/{chunk-V5E4RKG6.ts → chunk-FFI2K5IJ.ts} +4 -4
- package/dist/compiler-assets/{chunk-36MVFRMA.ts → chunk-IZJMGIAH.ts} +2 -2
- package/dist/compiler-assets/{chunk-KTBNDKGJ.ts → chunk-JZTF36V2.ts} +2 -1
- package/dist/compiler-assets/{chunk-XJNO7EHQ.ts → chunk-KNYB36DW.ts} +2 -2
- package/dist/compiler-assets/{chunk-TFPXCL5W.ts → chunk-L7YJCQVB.ts} +4 -4
- package/dist/compiler-assets/{chunk-WJPAUIVM.ts → chunk-LGGJ6S3U.ts} +1 -1
- package/dist/compiler-assets/{chunk-JW4Y5OAP.ts → chunk-LIRONA4O.ts} +6 -6
- package/dist/compiler-assets/{chunk-ZICJVGG7.ts → chunk-MM4JCZSK.ts} +7 -7
- package/dist/compiler-assets/{chunk-VI5WBWUX.ts → chunk-MPZMRU56.ts} +4 -4
- package/dist/compiler-assets/chunk-PLQKTBKO.ts +27 -0
- package/dist/compiler-assets/{chunk-GOIK7WNT.ts → chunk-Q26ZPNVB.ts} +31 -12
- package/dist/compiler-assets/{chunk-Z7HGOUC2.ts → chunk-RTC7AJBS.ts} +1 -1
- package/dist/compiler-assets/{chunk-OX46N5EP.ts → chunk-TCXQ4GLM.ts} +1 -1
- package/dist/compiler-assets/{chunk-R4IHPPTB.ts → chunk-UUQAHJRT.ts} +2 -2
- package/dist/compiler-assets/{chunk-KNFPKVUS.ts → chunk-XCX6VAK7.ts} +1 -1
- package/dist/compiler-assets/{chunk-OBFQTLWC.ts → chunk-Y73DOSSB.ts} +3 -3
- package/dist/compiler-assets/{chunk-2LYL3UFK.ts → chunk-YAO6DUQO.ts} +4 -4
- package/dist/compiler-assets/src/authoring/agent.ts +4 -4
- package/dist/compiler-assets/src/authoring/approval.ts +7 -7
- package/dist/compiler-assets/src/authoring/brand.ts +3 -3
- package/dist/compiler-assets/src/authoring/channels.ts +6 -8
- package/dist/compiler-assets/src/authoring/connections.ts +11 -11
- package/dist/compiler-assets/src/authoring/credentials.ts +7 -7
- package/dist/compiler-assets/src/authoring/dynamic.ts +8 -8
- package/dist/compiler-assets/src/authoring/harness.ts +9 -9
- package/dist/compiler-assets/src/authoring/hooks.ts +10 -10
- package/dist/compiler-assets/src/authoring/index.ts +27 -26
- package/dist/compiler-assets/src/authoring/instructions.ts +9 -9
- package/dist/compiler-assets/src/authoring/sandbox.ts +11 -11
- package/dist/compiler-assets/src/authoring/schedules.ts +4 -4
- package/dist/compiler-assets/src/authoring/skills.ts +4 -4
- package/dist/compiler-assets/src/authoring/tools.ts +9 -9
- package/dist/compiler-assets/src/compatibility.ts +6 -6
- package/dist/compiler-assets/src/hosted-bindings.ts +6 -6
- package/dist/compiler-assets/src/index.ts +30 -27
- package/dist/compiler-assets/src/manifest.ts +6 -4
- package/dist/compiler-assets/src/resolve.ts +5 -5
- package/dist/compiler-assets/src/runtime/bundle.ts +17 -18
- package/dist/compiler-assets/src/runtime/describe.ts +14 -14
- package/dist/compiler-assets/src/runtime/described.ts +28 -16
- package/dist/compiler-assets/src/runtime/isolate.ts +16 -17
- package/dist/compiler-assets/src/runtime/lower.ts +13 -13
- package/dist/compiler-assets/src/runtime/schema-validation.ts +4 -4
- package/dist/compiler-assets/src/runtime/values.ts +2 -2
- package/dist/modules/authoring/agent.d.mts +25 -1
- package/dist/modules/authoring/agent.mjs.map +2 -2
- package/dist/modules/authoring/brand.d.mts +1 -0
- package/dist/modules/authoring/brand.mjs +1 -0
- package/dist/modules/authoring/brand.mjs.map +2 -2
- package/dist/modules/authoring/channels.d.mts +13 -96
- package/dist/modules/authoring/channels.mjs +6 -52
- package/dist/modules/authoring/channels.mjs.map +3 -3
- package/dist/modules/authoring/index.d.mts +1 -1
- package/dist/modules/authoring/index.mjs +2 -0
- package/dist/modules/authoring/index.mjs.map +2 -2
- package/dist/modules/compiler/assemble.d.mts +0 -4
- package/dist/modules/compiler/assemble.mjs +55 -23
- package/dist/modules/compiler/assemble.mjs.map +2 -2
- package/dist/modules/compiler/bundle.mjs.map +1 -1
- package/dist/modules/compiler/index.d.mts +1 -4
- package/dist/modules/compiler/index.mjs +4 -3
- package/dist/modules/compiler/index.mjs.map +2 -2
- package/dist/modules/manifest.d.mts +2 -2
- package/dist/modules/manifest.mjs +2 -0
- package/dist/modules/manifest.mjs.map +2 -2
- package/dist/modules/runtime/describe.mjs +49 -2
- package/dist/modules/runtime/describe.mjs.map +2 -2
- package/dist/modules/runtime/described.d.mts +94 -3
- package/dist/modules/runtime/described.mjs +14 -2
- package/dist/modules/runtime/described.mjs.map +2 -2
- package/dist/modules/runtime/isolate.d.mts +3 -2
- package/dist/modules/runtime/isolate.mjs +2 -0
- package/dist/modules/runtime/isolate.mjs.map +2 -2
- package/fixtures/release-scout/agent/channels/github.ts +2 -38
- package/fixtures/release-scout/agent/hooks/audit.ts +1 -1
- package/fixtures/release-scout/agent/instructions/org-context.ts +1 -1
- package/package.json +4 -4
- package/dist/compiler-assets/chunk-ISYIPH2T.ts +0 -120
- package/dist/compiler-assets/chunk-JRKGCYWA.ts +0 -87
|
@@ -36,6 +36,19 @@ declare const describedAgentSchema: z.ZodObject<{
|
|
|
36
36
|
key: z.ZodNullable<z.ZodString>;
|
|
37
37
|
channel: z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>;
|
|
38
38
|
config: z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>;
|
|
39
|
+
install: z.ZodNullable<z.ZodString>;
|
|
40
|
+
credentials: z.ZodNullable<z.ZodObject<{
|
|
41
|
+
app: z.ZodNullable<z.ZodString>;
|
|
42
|
+
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
43
|
+
}, z.core.$strip>>;
|
|
44
|
+
surface: z.ZodNullable<z.ZodObject<{
|
|
45
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
46
|
+
method: z.ZodString;
|
|
47
|
+
path: z.ZodString;
|
|
48
|
+
}, z.core.$strip>>;
|
|
49
|
+
listeners: z.ZodArray<z.ZodString>;
|
|
50
|
+
placeKinds: z.ZodArray<z.ZodString>;
|
|
51
|
+
}, z.core.$strip>>;
|
|
39
52
|
}, z.core.$strip>>>;
|
|
40
53
|
}, z.core.$strip>;
|
|
41
54
|
export declare const describedEnvironmentSchema: z.ZodObject<{
|
|
@@ -113,6 +126,19 @@ export declare const describedValueSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
113
126
|
key: z.ZodNullable<z.ZodString>;
|
|
114
127
|
channel: z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>;
|
|
115
128
|
config: z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>;
|
|
129
|
+
install: z.ZodNullable<z.ZodString>;
|
|
130
|
+
credentials: z.ZodNullable<z.ZodObject<{
|
|
131
|
+
app: z.ZodNullable<z.ZodString>;
|
|
132
|
+
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
133
|
+
}, z.core.$strip>>;
|
|
134
|
+
surface: z.ZodNullable<z.ZodObject<{
|
|
135
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
136
|
+
method: z.ZodString;
|
|
137
|
+
path: z.ZodString;
|
|
138
|
+
}, z.core.$strip>>;
|
|
139
|
+
listeners: z.ZodArray<z.ZodString>;
|
|
140
|
+
placeKinds: z.ZodArray<z.ZodString>;
|
|
141
|
+
}, z.core.$strip>>;
|
|
116
142
|
}, z.core.$strip>>>;
|
|
117
143
|
}, z.core.$strip>, z.ZodObject<{
|
|
118
144
|
type: z.ZodLiteral<"dynamic">;
|
|
@@ -156,7 +182,20 @@ export declare const describedValueSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
|
|
|
156
182
|
method: z.ZodString;
|
|
157
183
|
path: z.ZodString;
|
|
158
184
|
}, z.core.$strip>>;
|
|
159
|
-
|
|
185
|
+
room: z.ZodBoolean;
|
|
186
|
+
invalidFields: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
187
|
+
credentials: z.ZodNullable<z.ZodObject<{
|
|
188
|
+
app: z.ZodNullable<z.ZodString>;
|
|
189
|
+
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
190
|
+
}, z.core.$strip>>;
|
|
191
|
+
surface: z.ZodObject<{
|
|
192
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
193
|
+
method: z.ZodString;
|
|
194
|
+
path: z.ZodString;
|
|
195
|
+
}, z.core.$strip>>;
|
|
196
|
+
listeners: z.ZodArray<z.ZodString>;
|
|
197
|
+
placeKinds: z.ZodArray<z.ZodString>;
|
|
198
|
+
}, z.core.$strip>;
|
|
160
199
|
config: z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>;
|
|
161
200
|
disabled: z.ZodDefault<z.ZodBoolean>;
|
|
162
201
|
installed: z.ZodDefault<z.ZodNullable<z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>>>;
|
|
@@ -216,6 +255,19 @@ export declare const describedModuleSchema: z.ZodObject<{
|
|
|
216
255
|
key: z.ZodNullable<z.ZodString>;
|
|
217
256
|
channel: z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>;
|
|
218
257
|
config: z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>;
|
|
258
|
+
install: z.ZodNullable<z.ZodString>;
|
|
259
|
+
credentials: z.ZodNullable<z.ZodObject<{
|
|
260
|
+
app: z.ZodNullable<z.ZodString>;
|
|
261
|
+
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
262
|
+
}, z.core.$strip>>;
|
|
263
|
+
surface: z.ZodNullable<z.ZodObject<{
|
|
264
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
265
|
+
method: z.ZodString;
|
|
266
|
+
path: z.ZodString;
|
|
267
|
+
}, z.core.$strip>>;
|
|
268
|
+
listeners: z.ZodArray<z.ZodString>;
|
|
269
|
+
placeKinds: z.ZodArray<z.ZodString>;
|
|
270
|
+
}, z.core.$strip>>;
|
|
219
271
|
}, z.core.$strip>>>;
|
|
220
272
|
}, z.core.$strip>, z.ZodObject<{
|
|
221
273
|
type: z.ZodLiteral<"dynamic">;
|
|
@@ -259,7 +311,20 @@ export declare const describedModuleSchema: z.ZodObject<{
|
|
|
259
311
|
method: z.ZodString;
|
|
260
312
|
path: z.ZodString;
|
|
261
313
|
}, z.core.$strip>>;
|
|
262
|
-
|
|
314
|
+
room: z.ZodBoolean;
|
|
315
|
+
invalidFields: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
316
|
+
credentials: z.ZodNullable<z.ZodObject<{
|
|
317
|
+
app: z.ZodNullable<z.ZodString>;
|
|
318
|
+
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
319
|
+
}, z.core.$strip>>;
|
|
320
|
+
surface: z.ZodObject<{
|
|
321
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
322
|
+
method: z.ZodString;
|
|
323
|
+
path: z.ZodString;
|
|
324
|
+
}, z.core.$strip>>;
|
|
325
|
+
listeners: z.ZodArray<z.ZodString>;
|
|
326
|
+
placeKinds: z.ZodArray<z.ZodString>;
|
|
327
|
+
}, z.core.$strip>;
|
|
263
328
|
config: z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>;
|
|
264
329
|
disabled: z.ZodDefault<z.ZodBoolean>;
|
|
265
330
|
installed: z.ZodDefault<z.ZodNullable<z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>>>;
|
|
@@ -321,6 +386,19 @@ export declare const describedBundleSchema: z.ZodObject<{
|
|
|
321
386
|
key: z.ZodNullable<z.ZodString>;
|
|
322
387
|
channel: z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>;
|
|
323
388
|
config: z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>;
|
|
389
|
+
install: z.ZodNullable<z.ZodString>;
|
|
390
|
+
credentials: z.ZodNullable<z.ZodObject<{
|
|
391
|
+
app: z.ZodNullable<z.ZodString>;
|
|
392
|
+
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
393
|
+
}, z.core.$strip>>;
|
|
394
|
+
surface: z.ZodNullable<z.ZodObject<{
|
|
395
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
396
|
+
method: z.ZodString;
|
|
397
|
+
path: z.ZodString;
|
|
398
|
+
}, z.core.$strip>>;
|
|
399
|
+
listeners: z.ZodArray<z.ZodString>;
|
|
400
|
+
placeKinds: z.ZodArray<z.ZodString>;
|
|
401
|
+
}, z.core.$strip>>;
|
|
324
402
|
}, z.core.$strip>>>;
|
|
325
403
|
}, z.core.$strip>, z.ZodObject<{
|
|
326
404
|
type: z.ZodLiteral<"dynamic">;
|
|
@@ -364,7 +442,20 @@ export declare const describedBundleSchema: z.ZodObject<{
|
|
|
364
442
|
method: z.ZodString;
|
|
365
443
|
path: z.ZodString;
|
|
366
444
|
}, z.core.$strip>>;
|
|
367
|
-
|
|
445
|
+
room: z.ZodBoolean;
|
|
446
|
+
invalidFields: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
447
|
+
credentials: z.ZodNullable<z.ZodObject<{
|
|
448
|
+
app: z.ZodNullable<z.ZodString>;
|
|
449
|
+
secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
450
|
+
}, z.core.$strip>>;
|
|
451
|
+
surface: z.ZodObject<{
|
|
452
|
+
routes: z.ZodArray<z.ZodObject<{
|
|
453
|
+
method: z.ZodString;
|
|
454
|
+
path: z.ZodString;
|
|
455
|
+
}, z.core.$strip>>;
|
|
456
|
+
listeners: z.ZodArray<z.ZodString>;
|
|
457
|
+
placeKinds: z.ZodArray<z.ZodString>;
|
|
458
|
+
}, z.core.$strip>;
|
|
368
459
|
config: z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>;
|
|
369
460
|
disabled: z.ZodDefault<z.ZodBoolean>;
|
|
370
461
|
installed: z.ZodDefault<z.ZodNullable<z.ZodType<import("@finalai/agent-provider").JsonValue, unknown, z.core.$ZodTypeInternals<import("@finalai/agent-provider").JsonValue, unknown>>>>;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
agentAvatarSchema,
|
|
3
|
+
channelCredentialsSchema,
|
|
4
|
+
channelSurfaceSchema,
|
|
3
5
|
hostedBindingRequirementSchema,
|
|
4
6
|
jsonValueSchema
|
|
5
7
|
} from "@finalai/agent-provider";
|
|
@@ -31,7 +33,14 @@ const describedAgentSchema = z.object({
|
|
|
31
33
|
toolPolicy: z.record(z.string(), z.string()).nullable(),
|
|
32
34
|
secrets: z.array(z.string()).nullable(),
|
|
33
35
|
channels: z.array(
|
|
34
|
-
z.object({
|
|
36
|
+
z.object({
|
|
37
|
+
key: z.string().nullable(),
|
|
38
|
+
channel: jsonValueSchema,
|
|
39
|
+
config: jsonValueSchema,
|
|
40
|
+
install: z.string().nullable(),
|
|
41
|
+
credentials: channelCredentialsSchema.nullable(),
|
|
42
|
+
surface: channelSurfaceSchema.nullable()
|
|
43
|
+
})
|
|
35
44
|
).nullable()
|
|
36
45
|
});
|
|
37
46
|
const describedInstructionsSchema = z.object({
|
|
@@ -60,7 +69,10 @@ const describedHookSchema = z.object({ type: z.literal("hook"), keys: z.array(z.
|
|
|
60
69
|
const describedChannelSchema = z.object({
|
|
61
70
|
type: z.literal("channel"),
|
|
62
71
|
routes: z.array(z.object({ method: z.string(), path: z.string() })),
|
|
63
|
-
|
|
72
|
+
room: z.boolean(),
|
|
73
|
+
invalidFields: z.array(z.string()).default([]),
|
|
74
|
+
credentials: channelCredentialsSchema.nullable(),
|
|
75
|
+
surface: channelSurfaceSchema,
|
|
64
76
|
config: jsonValueSchema,
|
|
65
77
|
disabled: z.boolean().default(false),
|
|
66
78
|
installed: jsonValueSchema.nullable().default(null)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/runtime/described.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n agentAvatarSchema,\n hostedBindingRequirementSchema,\n jsonValueSchema,\n} from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport { SlotKind } from \"./layout.mjs\";\nimport { IssueSeverity } from \"./lower.mjs\";\n\n// The static description of a bundle's authored modules, produced inside the\n// evaluation realm and parsed by the compiler. Everything is JSON.\n\nexport const issueSchema = z.object({ severity: z.nativeEnum(IssueSeverity), message: z.string() });\n\nconst providerHintSchema = z.object({\n ref: jsonValueSchema.nullable(),\n name: z.string().nullable(),\n});\n\nexport const describedDynamicSchema = z.object({\n type: z.literal('dynamic'),\n events: z.array(z.string()),\n description: z.string().nullable(),\n preview: z.string().nullable(),\n requiredBindings: z.array(hostedBindingRequirementSchema).optional(),\n provider: providerHintSchema.nullable(),\n});\n\nconst describedAgentSchema = z.object({\n type: z.literal('agent'),\n name: z.string().nullable(),\n description: z.string().nullable(),\n avatar: agentAvatarSchema.nullable().default(null),\n harness: z.object({ harness: jsonValueSchema, config: jsonValueSchema }).nullable(),\n tools: z.record(z.string(), z.string()).nullable(),\n // Capabilities bound to `harnessHost` (the harness's own host, no target).\n hostTools: z.array(z.string()).nullable().default(null),\n toolPolicy: z.record(z.string(), z.string()).nullable(),\n secrets: z.array(z.string()).nullable(),\n channels: z\n .array(\n z.object({
|
|
5
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,YAAY,OAAO;AACnB,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAKvB,MAAM,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,aAAa,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC;AAElG,MAAM,qBAAqB,EAAE,OAAO;AAAA,EAClC,KAAK,gBAAgB,SAAS;AAAA,EAC9B,MAAM,EAAE,OAAO,EAAE,SAAS;AAC5B,CAAC;AAEM,MAAM,yBAAyB,EAAE,OAAO;AAAA,EAC7C,MAAM,EAAE,QAAQ,SAAS;AAAA,EACzB,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EAC1B,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,kBAAkB,EAAE,MAAM,8BAA8B,EAAE,SAAS;AAAA,EACnE,UAAU,mBAAmB,SAAS;AACxC,CAAC;AAED,MAAM,uBAAuB,EAAE,OAAO;AAAA,EACpC,MAAM,EAAE,QAAQ,OAAO;AAAA,EACvB,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,QAAQ,kBAAkB,SAAS,EAAE,QAAQ,IAAI;AAAA,EACjD,SAAS,EAAE,OAAO,EAAE,SAAS,iBAAiB,QAAQ,gBAAgB,CAAC,EAAE,SAAS;AAAA,EAClF,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA;AAAA,EAEjD,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,QAAQ,IAAI;AAAA,EACtD,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACtD,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA,EACtC,UAAU,EACP;AAAA,IACC,EAAE,OAAO,
|
|
4
|
+
"sourcesContent": ["import {\n agentAvatarSchema,\n channelCredentialsSchema,\n channelSurfaceSchema,\n hostedBindingRequirementSchema,\n jsonValueSchema,\n} from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport { SlotKind } from \"./layout.mjs\";\nimport { IssueSeverity } from \"./lower.mjs\";\n\n// The static description of a bundle's authored modules, produced inside the\n// evaluation realm and parsed by the compiler. Everything is JSON.\n\nexport const issueSchema = z.object({ severity: z.nativeEnum(IssueSeverity), message: z.string() });\n\nconst providerHintSchema = z.object({\n ref: jsonValueSchema.nullable(),\n name: z.string().nullable(),\n});\n\nexport const describedDynamicSchema = z.object({\n type: z.literal('dynamic'),\n events: z.array(z.string()),\n description: z.string().nullable(),\n preview: z.string().nullable(),\n requiredBindings: z.array(hostedBindingRequirementSchema).optional(),\n provider: providerHintSchema.nullable(),\n});\n\nconst describedAgentSchema = z.object({\n type: z.literal('agent'),\n name: z.string().nullable(),\n description: z.string().nullable(),\n avatar: agentAvatarSchema.nullable().default(null),\n harness: z.object({ harness: jsonValueSchema, config: jsonValueSchema }).nullable(),\n tools: z.record(z.string(), z.string()).nullable(),\n // Capabilities bound to `harnessHost` (the harness's own host, no target).\n hostTools: z.array(z.string()).nullable().default(null),\n toolPolicy: z.record(z.string(), z.string()).nullable(),\n secrets: z.array(z.string()).nullable(),\n channels: z\n .array(\n z.object({\n key: z.string().nullable(),\n channel: jsonValueSchema,\n config: jsonValueSchema,\n install: z.string().nullable(),\n credentials: channelCredentialsSchema.nullable(),\n surface: channelSurfaceSchema.nullable(),\n }),\n )\n .nullable(),\n});\n\nconst describedInstructionsSchema = z.object({\n type: z.literal('instructions'),\n role: z.string(),\n content: z.string(),\n});\n\nconst describedSkillSchema = z.object({ type: z.literal('skill'), skill: jsonValueSchema });\n\nconst describedToolSchema = z.object({\n type: z.literal('tool'),\n descriptor: jsonValueSchema,\n approval: z.string(),\n});\n\nconst describedConnectionSchema = z.object({\n type: z.literal('connection'),\n binding: jsonValueSchema,\n});\n\nconst describedScheduleSchema = z.object({\n type: z.literal('schedule'),\n cron: z.string().nullable(),\n markdown: z.string().nullable(),\n timezone: z.string().nullable(),\n target: z.string().nullable(),\n});\n\nconst describedHookSchema = z.object({ type: z.literal('hook'), keys: z.array(z.string()) });\n\nconst describedChannelSchema = z.object({\n type: z.literal('channel'),\n routes: z.array(z.object({ method: z.string(), path: z.string() })),\n room: z.boolean(),\n invalidFields: z.array(z.string()).default([]),\n credentials: channelCredentialsSchema.nullable(),\n surface: channelSurfaceSchema,\n config: jsonValueSchema,\n disabled: z.boolean().default(false),\n installed: jsonValueSchema.nullable().default(null),\n});\n\nexport const describedEnvironmentSchema = z.object({\n providerName: z.string(),\n providerRef: jsonValueSchema.nullable(),\n options: jsonValueSchema,\n openOptions: jsonValueSchema.nullable(),\n});\n\nconst describedSandboxTargetSchema = z.object({\n exportName: z.string(),\n environment: describedEnvironmentSchema.nullable(),\n dynamic: describedDynamicSchema.nullable(),\n});\n\nconst describedSandboxSchema = z.object({\n type: z.literal('sandbox'),\n targets: z.record(z.string(), describedSandboxTargetSchema),\n // Bundle export name \u2192 provider name, for providers defined in sandbox.ts.\n providers: z.record(z.string(), z.string()),\n selector: z.boolean(),\n defaultTarget: z.string().nullable(),\n});\n\nexport const describedValueSchema = z.discriminatedUnion('type', [\n describedAgentSchema,\n describedDynamicSchema,\n describedInstructionsSchema,\n describedSkillSchema,\n describedToolSchema,\n describedConnectionSchema,\n describedScheduleSchema,\n describedHookSchema,\n describedChannelSchema,\n describedSandboxSchema,\n]);\n\nexport const describedModuleSchema = z.object({\n base: z.string(),\n path: z.string(),\n slot: z.nativeEnum(SlotKind),\n key: z.string(),\n hasDefault: z.boolean(),\n issues: z.array(issueSchema),\n value: describedValueSchema.nullable(),\n});\n\nexport const describedBundleSchema = z.object({\n modules: z.array(describedModuleSchema),\n // Exports the bundle synthesizes beyond the authored ones.\n synthesized: z.array(z.string()),\n});\n\nexport type DescribedIssueIface = z.infer<typeof issueSchema>;\nexport type DescribedDynamicIface = z.infer<typeof describedDynamicSchema>;\nexport type DescribedAgentIface = z.infer<typeof describedAgentSchema>;\nexport type DescribedSandboxIface = z.infer<typeof describedSandboxSchema>;\nexport type DescribedSandboxTargetIface = z.infer<typeof describedSandboxTargetSchema>;\nexport type DescribedEnvironmentIface = z.infer<typeof describedEnvironmentSchema>;\nexport type DescribedValue = z.infer<typeof describedValueSchema>;\nexport type DescribedModuleIface = z.infer<typeof describedModuleSchema>;\nexport type DescribedBundleIface = z.infer<typeof describedBundleSchema>;\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,YAAY,OAAO;AACnB,SAAS,gBAAgB;AACzB,SAAS,qBAAqB;AAKvB,MAAM,cAAc,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,aAAa,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC;AAElG,MAAM,qBAAqB,EAAE,OAAO;AAAA,EAClC,KAAK,gBAAgB,SAAS;AAAA,EAC9B,MAAM,EAAE,OAAO,EAAE,SAAS;AAC5B,CAAC;AAEM,MAAM,yBAAyB,EAAE,OAAO;AAAA,EAC7C,MAAM,EAAE,QAAQ,SAAS;AAAA,EACzB,QAAQ,EAAE,MAAM,EAAE,OAAO,CAAC;AAAA,EAC1B,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,kBAAkB,EAAE,MAAM,8BAA8B,EAAE,SAAS;AAAA,EACnE,UAAU,mBAAmB,SAAS;AACxC,CAAC;AAED,MAAM,uBAAuB,EAAE,OAAO;AAAA,EACpC,MAAM,EAAE,QAAQ,OAAO;AAAA,EACvB,MAAM,EAAE,OAAO,EAAE,SAAS;AAAA,EAC1B,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,QAAQ,kBAAkB,SAAS,EAAE,QAAQ,IAAI;AAAA,EACjD,SAAS,EAAE,OAAO,EAAE,SAAS,iBAAiB,QAAQ,gBAAgB,CAAC,EAAE,SAAS;AAAA,EAClF,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAAE,SAAS;AAAA;AAAA,EAEjD,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,SAAS,EAAE,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AA,EACA;AACF,CAAC;AAEM,MAAM,wBAAwB,EAAE,OAAO;AAAA,EAC5C,MAAM,EAAE,OAAO;AAAA,EACf,MAAM,EAAE,OAAO;AAAA,EACf,MAAM,EAAE,WAAW,QAAQ;AAAA,EAC3B,KAAK,EAAE,OAAO;AAAA,EACd,YAAY,EAAE,QAAQ;AAAA,EACtB,QAAQ,EAAE,MAAM,WAAW;AAAA,EAC3B,OAAO,qBAAqB,SAAS;AACvC,CAAC;AAEM,MAAM,wBAAwB,EAAE,OAAO;AAAA,EAC5C,SAAS,EAAE,MAAM,qBAAqB;AAAA;AAAA,EAEtC,aAAa,EAAE,MAAM,EAAE,OAAO,CAAC;AACjC,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { HostedBindingsIface } from '@finalai/agent-provider';
|
|
2
|
-
import { DynamicEvent, ToolApproval, type ChannelReceiveResult, type ChannelSocketIface, type InputApprovalIface, type JsonObject, type JsonValue } from '@finalai/agent-provider';
|
|
2
|
+
import { DynamicEvent, ToolApproval, type RoomReceiveResult, type ChannelReceiveContextIface, type ChannelReceiveResult, type ChannelSocketIface, type InputApprovalIface, type JsonObject, type JsonValue } from '@finalai/agent-provider';
|
|
3
3
|
import { type DynamicResolveContextIface, type ToolContextIface } from "../authoring/context.mjs";
|
|
4
4
|
import type { DynamicBoundaryEventIface } from "../authoring/dynamic.mjs";
|
|
5
5
|
import { type HookContextIface, type HookDispatchEventIface } from "../authoring/hooks.mjs";
|
|
@@ -34,11 +34,12 @@ export interface ChannelRouteArgsIface {
|
|
|
34
34
|
export: string;
|
|
35
35
|
request: Request;
|
|
36
36
|
configuration?: JsonObject;
|
|
37
|
+
context?: ChannelReceiveContextIface;
|
|
37
38
|
path: string;
|
|
38
39
|
secrets: {
|
|
39
40
|
get(name: string): Promise<string | null>;
|
|
40
41
|
};
|
|
41
|
-
receive: (input: JsonValue) => Promise<ChannelReceiveResult>;
|
|
42
|
+
receive: (input: JsonValue) => Promise<RoomReceiveResult | ChannelReceiveResult>;
|
|
42
43
|
}
|
|
43
44
|
export interface ChannelSocketArgsIface extends ChannelRouteArgsIface {
|
|
44
45
|
socket: ChannelSocketIface;
|
|
@@ -419,6 +419,7 @@ const createIsolateRuntime = (modules) => {
|
|
|
419
419
|
);
|
|
420
420
|
if (route == null) return null;
|
|
421
421
|
const response = await route.handler({
|
|
422
|
+
...args.context,
|
|
422
423
|
request: args.request,
|
|
423
424
|
secrets: args.secrets,
|
|
424
425
|
receive: args.receive,
|
|
@@ -438,6 +439,7 @@ const createIsolateRuntime = (modules) => {
|
|
|
438
439
|
);
|
|
439
440
|
if (route == null) return null;
|
|
440
441
|
const response = await route.handler({
|
|
442
|
+
...args.context,
|
|
441
443
|
request: args.request,
|
|
442
444
|
secrets: args.secrets,
|
|
443
445
|
receive: args.receive
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/runtime/isolate.ts"],
|
|
4
|
-
"sourcesContent": ["import type { HostedBindingsIface } from '@finalai/agent-provider';\nimport {\n ConversationKind,\n DynamicEvent,\n InputApprovalKind,\n jsonObjectSchema,\n jsonValueSchema,\n McpServerBindingKind,\n mcpServerBindingSchema,\n ParticipantKind,\n providerRefSchema,\n ToolApproval,\n unopenedRequestOf,\n type ChannelReceiveResult,\n type ChannelSocketIface,\n type InputApprovalIface,\n type JsonObject,\n type JsonValue,\n type McpServerBinding,\n type ToolDescriptorIface,\n} from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport { lowerApproval } from \"../authoring/approval.mjs\";\nimport { AuthoredKind, authoredKindOf, stamp } from \"../authoring/brand.mjs\";\nimport {\n TranscriptRole,\n type DynamicResolveContextIface,\n type ToolContextIface,\n} from \"../authoring/context.mjs\";\nimport type { DynamicBoundaryEventIface } from \"../authoring/dynamic.mjs\";\nimport {\n hookHandlersFor,\n type HookContextIface,\n type HookDispatchEventIface,\n} from \"../authoring/hooks.mjs\";\nimport { registerToolName, toolLabelSchema } from \"../authoring/tools.mjs\";\nimport { AUTHORED_SERVER_KEY } from \"./layout.mjs\";\nimport {\n isDynamicSentinel,\n isEnvironmentLike,\n isOpenRequestLike,\n lowerConnection,\n lowerEnvironment,\n lowerInstructions,\n lowerSkill,\n lowerTool,\n toJson,\n type IssueIface,\n} from \"./lower.mjs\";\nimport { validateSchemaValue } from \"./schema-validation.mjs\";\nimport {\n authoredRecordSchema,\n callableSchema,\n entriesOf,\n fieldOf,\n isAsyncIterable,\n isCallable,\n isObjectLike,\n isPlainObject,\n messageOf,\n optionalValueSchema,\n type AuthoredCallable,\n type AuthoredRecord,\n type AuthoredValue,\n} from \"./values.mjs\";\n\n// What an agent bundle exposes to the Worker isolate that runs it (B4/B7):\n// the authored module map plus helpers that run its exports. The bundle is\n// the only place authored code executes.\n\nexport interface RunToolArgsIface {\n export: string;\n input: AuthoredValue;\n dynamic?: JsonValue;\n ctx: ToolContextIface;\n // Each yield of an async-generator execute, for MCP progress notifications.\n onProgress?: (value: JsonValue, label?: string) => void;\n}\n\nexport interface RunToolResultIface {\n output: JsonValue;\n // toModelOutput's projection, when the tool has one.\n modelOutput: JsonValue | null;\n}\n\nexport interface ResolveDynamicArgsIface {\n export: string;\n event: DynamicEvent;\n payload: DynamicBoundaryEventIface;\n ctx: DynamicResolveContextIface;\n // Names a single returned skill (defaults to the export's last path segment).\n key?: string;\n}\n\nexport interface DispatchHookArgsIface {\n export: string;\n event: HookDispatchEventIface;\n ctx: HookContextIface;\n}\n\nexport interface HookFailureIface {\n message: string;\n}\n\nexport interface ChannelRouteArgsIface {\n export: string;\n request: Request;\n configuration?: JsonObject;\n // The route path relative to the channel's mount point ('/webhook').\n path: string;\n secrets: { get(name: string): Promise<string | null> };\n receive: (input: JsonValue) => Promise<ChannelReceiveResult>;\n}\n\nexport interface ChannelSocketArgsIface extends ChannelRouteArgsIface {\n socket: ChannelSocketIface;\n}\n\nexport interface IsolateRuntimeIface {\n evaluateApproval(args: {\n reference: InputApprovalIface;\n bindings?: HostedBindingsIface;\n input: AuthoredValue;\n secrets: { get(name: string): Promise<string | null> };\n }): Promise<ToolApproval>;\n runTool(args: RunToolArgsIface): Promise<RunToolResultIface>;\n resolveDynamic(args: ResolveDynamicArgsIface): Promise<JsonValue | null>;\n dispatchHook(\n args: DispatchHookArgsIface,\n ): Promise<{ handled: number; failures: HookFailureIface[] }>;\n // Null when no route of the channel matches the method and path.\n handleChannelRoute(args: ChannelRouteArgsIface): Promise<Response | null>;\n handleChannelSocket(args: ChannelSocketArgsIface): Promise<Response | void | null>;\n}\n\nconst jsonOf = (value: AuthoredValue, path: string): JsonValue => {\n const issues: IssueIface[] = [];\n const json = toJson(value, { path, issues });\n const failure = issues.find((issue) => issue.severity === 'error');\n if (failure != null) throw new Error(failure.message);\n return json;\n};\n\nconst lastSegment = (exportName: string): string => {\n const base = exportName.split('#')[0] ?? exportName;\n return base.split('/').at(-1) ?? base;\n};\n\n// Lowers a resolver's return value to manifest JSON by what it is.\nexport const lowerResolvedValue = (value: AuthoredValue, key: string): JsonValue | null => {\n if (value == null) return null;\n const kind = authoredKindOf(value);\n if (kind === AuthoredKind.Instructions)\n return jsonOf(lowerInstructions(value, null), 'instructions');\n if (kind === AuthoredKind.Skill) {\n const lowered = lowerSkill({ key, value });\n const failure = lowered.issues.find((issue) => issue.severity === 'error');\n if (failure != null) throw new Error(failure.message);\n return jsonOf(lowered.skill, 'skill');\n }\n if (isEnvironmentLike(value) || isOpenRequestLike(value)) {\n const issues: IssueIface[] = [];\n const environment = lowerEnvironment(value, 'environment', issues);\n return jsonOf(environment, 'environment');\n }\n if (isPlainObject(value)) {\n const entries = entriesOf(value);\n if (\n entries.length > 0 &&\n entries.every(([, item]) => authoredKindOf(item) === AuthoredKind.Skill)\n ) {\n return entries.map(([entryKey, item]) =>\n jsonOf(lowerSkill({ key: entryKey, value: item }).skill, 'skill'),\n );\n }\n }\n return jsonOf(value, 'resolved value');\n};\n\nexport interface CombinedEntryIface {\n kind: 'tool' | 'connection';\n key: string;\n exportName: string;\n value: AuthoredValue;\n}\n\nconst throwOnErrors = (issues: IssueIface[]): void => {\n const failure = issues.find((issue) => issue.severity === 'error');\n if (failure != null) throw new Error(failure.message);\n};\n\n// A resolver for the whole `mcpServers` field, used when any tool or\n// connection is dynamic: the manifest stores one slot and the session gets\n// the static and resolved entries together.\nexport const combineMcpServers = (entries: CombinedEntryIface[]): AuthoredValue => {\n const handler =\n (event: DynamicEvent) =>\n async (payload: DynamicBoundaryEventIface, ctx: DynamicResolveContextIface) => {\n const previous = z.array(mcpServerBindingSchema).safeParse(ctx.previousValue).data ?? [];\n const tools: ToolDescriptorIface[] = [];\n const approvals: Record<string, ToolApproval> = {};\n const connections: McpServerBinding[] = [];\n const addTool = (\n name: string,\n exportName: string,\n value: AuthoredValue,\n resolver?: string,\n ): void => {\n const lowered = lowerTool({ name, exportName, value });\n throwOnErrors(lowered.issues);\n registerToolName(value, name);\n if (resolver != null) {\n const snapshot = jsonObjectSchema.parse(\n jsonOf(\n {\n resolver,\n name,\n event,\n payload,\n session: ctx.session,\n messages: ctx.messages,\n channel: ctx.channel,\n },\n 'dynamic tool boundary',\n ),\n );\n lowered.descriptor.dynamic = snapshot;\n if (lowered.descriptor.inputApproval != null)\n lowered.descriptor.inputApproval = {\n ...lowered.descriptor.inputApproval,\n dynamic: snapshot,\n };\n }\n tools.push(lowered.descriptor);\n approvals[name] = lowered.approval;\n };\n const addConnection = (\n key: string,\n exportName: string,\n value: AuthoredValue,\n resolver?: string,\n ): void => {\n const lowered = lowerConnection({ key, exportName, value });\n throwOnErrors(lowered.issues);\n if (resolver != null && lowered.binding.inputApprovals != null) {\n const snapshot = jsonObjectSchema.parse(\n jsonOf(\n {\n resolver,\n name: key,\n event,\n payload,\n session: ctx.session,\n messages: ctx.messages,\n channel: ctx.channel,\n },\n 'dynamic connection boundary',\n ),\n );\n lowered.binding.inputApprovals = Object.fromEntries(\n Object.entries(lowered.binding.inputApprovals).map(([name, reference]) => [\n name,\n { ...reference, dynamic: snapshot },\n ]),\n );\n }\n connections.push(\n resolver == null ? lowered.binding : { ...lowered.binding, dynamicResolver: resolver },\n );\n };\n for (const entry of entries) {\n const add =\n entry.kind === 'tool'\n ? addTool\n : (name: string, exportName: string, value: AuthoredValue) =>\n addConnection(name, exportName, value);\n if (!isDynamicSentinel(entry.value)) {\n add(entry.key, entry.exportName, entry.value);\n continue;\n }\n const resolve = fieldOf(fieldOf(entry.value, 'events'), event);\n if (!isCallable(resolve)) {\n for (const server of previous) {\n if (\n entry.kind === 'connection' &&\n server.kind === McpServerBindingKind.Http &&\n server.dynamicResolver === entry.exportName\n ) {\n connections.push(server);\n } else if (entry.kind === 'tool' && server.kind === McpServerBindingKind.Worker) {\n for (const tool of server.tools) {\n if (tool.dynamic?.['resolver'] !== entry.exportName) continue;\n tools.push(tool);\n approvals[tool.name] = Object.hasOwn(server.approvals ?? {}, tool.name)\n ? (server.approvals?.[tool.name] ?? ToolApproval.Allow)\n : ToolApproval.Allow;\n }\n }\n }\n continue;\n }\n const result = await resolve(payload, ctx);\n if (result == null) continue;\n const kind = authoredKindOf(result);\n if (kind === AuthoredKind.Tool || kind === AuthoredKind.Connection) {\n if (entry.kind === 'tool') addTool(entry.key, entry.exportName, result, entry.exportName);\n else addConnection(entry.key, entry.exportName, result, entry.exportName);\n } else if (isPlainObject(result)) {\n for (const [name, item] of entriesOf(result)) {\n if (entry.kind === 'tool')\n addTool(name, `${entry.exportName}#${name}`, item, entry.exportName);\n else addConnection(name, `${entry.exportName}#${name}`, item, entry.exportName);\n }\n }\n }\n const servers: McpServerBinding[] = [];\n if (tools.length > 0) {\n servers.push({\n key: AUTHORED_SERVER_KEY,\n kind: McpServerBindingKind.Worker,\n tools,\n approvals,\n });\n }\n return jsonOf([...servers, ...connections], 'mcpServers');\n };\n return stamp(\n {\n kind: 'final:dynamic' as const,\n events: {\n [DynamicEvent.SessionStarted]: handler(DynamicEvent.SessionStarted),\n [DynamicEvent.TurnStarted]: handler(DynamicEvent.TurnStarted),\n },\n },\n AuthoredKind.Dynamic,\n );\n};\n\nconst matchRoute = (pattern: string, path: string): boolean => {\n const patternParts = pattern.split('/').filter((part) => part.length > 0);\n const pathParts = path.split('/').filter((part) => part.length > 0);\n if (patternParts.length !== pathParts.length) return false;\n return patternParts.every((part, index) => part.startsWith(':') || part === pathParts[index]);\n};\n\nconst toolModuleSchema = z.looseObject({\n execute: callableSchema,\n inputSchema: optionalValueSchema,\n outputSchema: optionalValueSchema,\n toModelOutput: callableSchema.optional(),\n label: toolLabelSchema.nullish(),\n});\n\nconst sentinelSchema = z.looseObject({ events: authoredRecordSchema });\n\nconst channelModuleSchema = z.looseObject({\n configure: callableSchema.optional(),\n routes: z.array(z.looseObject({ method: z.string(), path: z.string(), handler: callableSchema })),\n});\n\nconst dynamicToolBoundarySchema = z.object({\n resolver: z.string(),\n name: z.string(),\n event: z.nativeEnum(DynamicEvent),\n payload: z.object({\n type: z.nativeEnum(DynamicEvent),\n prompt: z.array(jsonValueSchema).nullable(),\n }),\n session: z.object({\n id: z.string(),\n organizationId: z.string(),\n definitionId: z.string(),\n revisionId: z.string(),\n conversation: z\n .object({\n id: z.string(),\n kind: z.nativeEnum(ConversationKind),\n title: z.string().nullable(),\n metadata: jsonObjectSchema,\n participants: z.array(\n z.object({\n id: z.string(),\n kind: z.nativeEnum(ParticipantKind),\n displayName: z.string(),\n userId: z.string().nullable(),\n }),\n ),\n })\n .nullable(),\n author: z\n .object({\n participantId: z.string().nullable(),\n userId: z.string().nullable(),\n displayName: z.string(),\n })\n .nullable(),\n turn: z.object({ id: z.string() }).nullable(),\n harness: providerRefSchema,\n }),\n messages: z.array(\n z.object({\n role: z.nativeEnum(TranscriptRole),\n content: z.array(jsonValueSchema),\n toolCallId: z.string().nullable(),\n seq: z.number(),\n }),\n ),\n channel: z.object({ kind: z.string().nullable() }),\n});\n\nexport const createIsolateRuntime = (modules: AuthoredRecord): IsolateRuntimeIface => {\n const lookup = (name: string): AuthoredValue => {\n if (!(name in modules)) throw new Error(`bundle has no export ${name}`);\n return modules[name];\n };\n const resolveAuthored = async (args: {\n bindings?: HostedBindingsIface;\n exportName: string;\n dynamic?: JsonValue;\n kind: InputApprovalKind;\n secrets: { get(name: string): Promise<string | null> };\n }): Promise<AuthoredValue> => {\n if (args.dynamic == null) return lookup(args.exportName);\n const boundary = dynamicToolBoundarySchema.parse(args.dynamic);\n if (\n args.exportName !== boundary.resolver &&\n args.exportName !== `${boundary.resolver}#${boundary.name}`\n )\n throw new Error('dynamic export does not match its boundary');\n const sentinel = lookup(boundary.resolver);\n if (!isDynamicSentinel(sentinel)) throw new Error('dynamic resolver is not a defineDynamic');\n const resolve = fieldOf(fieldOf(sentinel, 'events'), boundary.event);\n if (!isCallable(resolve)) throw new Error('dynamic resolver has no boundary handler');\n const result = await resolve(boundary.payload, {\n session: boundary.session,\n messages: boundary.messages,\n channel: boundary.channel,\n secrets: args.secrets,\n bindings: args.bindings,\n });\n const expected =\n args.kind === InputApprovalKind.Tool ? AuthoredKind.Tool : AuthoredKind.Connection;\n return authoredKindOf(result) === expected ? result : fieldOf(result, boundary.name);\n };\n return {\n evaluateApproval: async ({ reference, input, secrets, bindings }) => {\n const value = await resolveAuthored({\n exportName: reference.export,\n dynamic: reference.dynamic,\n kind: reference.kind,\n secrets,\n bindings,\n });\n let policy: AuthoredValue;\n let validated: AuthoredValue = input;\n if (reference.kind === InputApprovalKind.Tool) {\n const tool = toolModuleSchema.parse(value);\n validated = await validateSchemaValue({\n schema: tool.inputSchema,\n value: input,\n what: 'approval input',\n });\n policy = fieldOf(value, 'approval');\n } else {\n if (authoredKindOf(value) !== AuthoredKind.Connection)\n throw new Error('approval export is not a connection');\n policy =\n reference.policyKey == null\n ? fieldOf(value, 'approval')\n : fieldOf(fieldOf(fieldOf(value, 'tools'), 'approval'), reference.policyKey);\n }\n const lowered = lowerApproval(policy);\n const predicate = fieldOf(policy, 'predicate');\n if (lowered.error != null || !lowered.inputDependent || !isCallable(predicate))\n throw new Error('approval reference has no valid input predicate');\n return z.boolean().parse(await predicate(validated)) ? ToolApproval.Ask : ToolApproval.Allow;\n },\n runTool: async (args) => {\n const value = await resolveAuthored({\n exportName: args.export,\n dynamic: args.dynamic,\n kind: InputApprovalKind.Tool,\n secrets: args.ctx.secrets,\n bindings: args.ctx.bindings,\n });\n if (args.dynamic != null)\n registerToolName(value, dynamicToolBoundarySchema.parse(args.dynamic).name);\n const parsed = toolModuleSchema.safeParse(value);\n if (!parsed.success) throw new Error(`${args.export} is not a tool`);\n const tool = parsed.data;\n const input = await validateSchemaValue({\n schema: tool.inputSchema,\n value: args.input,\n what: 'tool input',\n });\n const label = isObjectLike(tool.label) ? tool.label : null;\n const statusLabel = async (\n callback: AuthoredCallable | undefined,\n values: AuthoredValue[],\n ): Promise<string | undefined> => {\n if (callback == null) return undefined;\n try {\n const text = z.string().safeParse(await callback(...values));\n return text.success ? text.data : undefined;\n } catch {\n // Display labels must not turn a completed side effect into a tool failure.\n return undefined;\n }\n };\n const started = await statusLabel(label?.start, [input]);\n if (started != null) args.onProgress?.(null, started);\n const result = await tool.execute(input, args.ctx);\n let output: AuthoredValue = result;\n if (isAsyncIterable(result)) {\n for await (const item of result) {\n output = item;\n args.onProgress?.(\n jsonOf(item, 'tool progress'),\n await statusLabel(label?.delta, [input, item]),\n );\n }\n }\n const validated = await validateSchemaValue({\n schema: tool.outputSchema,\n value: output,\n what: 'tool output',\n });\n const modelOutput = tool.toModelOutput == null ? null : await tool.toModelOutput(validated);\n const completed = await statusLabel(label?.complete, [input, validated]);\n if (completed != null) args.onProgress?.(null, completed);\n return {\n output: jsonOf(validated ?? null, 'tool output'),\n modelOutput: modelOutput == null ? null : jsonOf(modelOutput, 'tool model output'),\n };\n },\n resolveDynamic: async (args) => {\n const sentinel = lookup(args.export);\n const parsed = sentinelSchema.safeParse(sentinel);\n if (!isDynamicSentinel(sentinel) || !parsed.success) {\n throw new Error(`${args.export} is not a defineDynamic resolver`);\n }\n const resolve = parsed.data.events[args.event];\n if (!isCallable(resolve)) return null;\n let result: AuthoredValue;\n try {\n result = await resolve(args.payload, args.ctx);\n } catch (cause) {\n // Dynamic handlers describe configurations; live setup belongs in defineSandbox.\n // `async () => environment.open(...)` is lowered as a request.\n const request = unopenedRequestOf(cause);\n if (request == null) throw cause;\n result = request;\n }\n return lowerResolvedValue(result, args.key ?? lastSegment(args.export));\n },\n dispatchHook: async (args) => {\n const handlers = hookHandlersFor(lookup(args.export), args.event);\n const failures: HookFailureIface[] = [];\n for (const invoke of handlers) {\n try {\n await invoke(args.event, args.ctx);\n } catch (cause) {\n failures.push({ message: messageOf(cause) });\n }\n }\n return { handled: handlers.length, failures };\n },\n handleChannelSocket: async (args) => {\n const original = channelModuleSchema.safeParse(lookup(args.export));\n if (!original.success) return null;\n const parsed =\n original.data.configure == null\n ? original\n : channelModuleSchema.safeParse(await original.data.configure(args.configuration ?? {}));\n if (!parsed.success) throw new Error(`${args.export} configured channel is invalid`);\n const route = parsed.data.routes.find(\n (candidate) => candidate.method === 'WS' && matchRoute(candidate.path, args.path),\n );\n if (route == null) return null;\n const response = await route.handler({\n request: args.request,\n secrets: args.secrets,\n receive: args.receive,\n socket: args.socket,\n });\n if (response != null && !(response instanceof Response))\n throw new Error(`${args.export} socket route returned an invalid response`);\n return response;\n },\n handleChannelRoute: async (args) => {\n const original = channelModuleSchema.safeParse(lookup(args.export));\n if (!original.success) return null;\n const parsed =\n original.data.configure == null\n ? original\n : channelModuleSchema.safeParse(await original.data.configure(args.configuration ?? {}));\n if (!parsed.success) throw new Error(`${args.export} configured channel is invalid`);\n const route = parsed.data.routes.find(\n (candidate) =>\n candidate.method === args.request.method && matchRoute(candidate.path, args.path),\n );\n if (route == null) return null;\n const response = await route.handler({\n request: args.request,\n secrets: args.secrets,\n receive: args.receive,\n });\n if (!(response instanceof Response)) {\n throw new Error(`${args.export} route ${args.path} did not return a Response`);\n }\n return response;\n },\n };\n};\n"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S,KAAK;AAAA,QACd,SAAS,KAAK;AAAA,MAChB,CAAC;AACD,UAAI,EAAE,oBAAoB,WAAW;AACnC,cAAM,IAAI,MAAM,GAAG,KAAK,MAAM,UAAU,KAAK,IAAI,4BAA4B;AAAA,MAC/E;AACA,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
|
|
4
|
+
"sourcesContent": ["import type { HostedBindingsIface } from '@finalai/agent-provider';\nimport {\n ConversationKind,\n DynamicEvent,\n InputApprovalKind,\n jsonObjectSchema,\n jsonValueSchema,\n McpServerBindingKind,\n mcpServerBindingSchema,\n ParticipantKind,\n providerRefSchema,\n ToolApproval,\n unopenedRequestOf,\n type RoomReceiveResult,\n type ChannelReceiveContextIface,\n type ChannelReceiveResult,\n type ChannelSocketIface,\n type InputApprovalIface,\n type JsonObject,\n type JsonValue,\n type McpServerBinding,\n type ToolDescriptorIface,\n} from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport { lowerApproval } from \"../authoring/approval.mjs\";\nimport { AuthoredKind, authoredKindOf, stamp } from \"../authoring/brand.mjs\";\nimport {\n TranscriptRole,\n type DynamicResolveContextIface,\n type ToolContextIface,\n} from \"../authoring/context.mjs\";\nimport type { DynamicBoundaryEventIface } from \"../authoring/dynamic.mjs\";\nimport {\n hookHandlersFor,\n type HookContextIface,\n type HookDispatchEventIface,\n} from \"../authoring/hooks.mjs\";\nimport { registerToolName, toolLabelSchema } from \"../authoring/tools.mjs\";\nimport { AUTHORED_SERVER_KEY } from \"./layout.mjs\";\nimport {\n isDynamicSentinel,\n isEnvironmentLike,\n isOpenRequestLike,\n lowerConnection,\n lowerEnvironment,\n lowerInstructions,\n lowerSkill,\n lowerTool,\n toJson,\n type IssueIface,\n} from \"./lower.mjs\";\nimport { validateSchemaValue } from \"./schema-validation.mjs\";\nimport {\n authoredRecordSchema,\n callableSchema,\n entriesOf,\n fieldOf,\n isAsyncIterable,\n isCallable,\n isObjectLike,\n isPlainObject,\n messageOf,\n optionalValueSchema,\n type AuthoredCallable,\n type AuthoredRecord,\n type AuthoredValue,\n} from \"./values.mjs\";\n\n// What an agent bundle exposes to the Worker isolate that runs it (B4/B7):\n// the authored module map plus helpers that run its exports. The bundle is\n// the only place authored code executes.\n\nexport interface RunToolArgsIface {\n export: string;\n input: AuthoredValue;\n dynamic?: JsonValue;\n ctx: ToolContextIface;\n // Each yield of an async-generator execute, for MCP progress notifications.\n onProgress?: (value: JsonValue, label?: string) => void;\n}\n\nexport interface RunToolResultIface {\n output: JsonValue;\n // toModelOutput's projection, when the tool has one.\n modelOutput: JsonValue | null;\n}\n\nexport interface ResolveDynamicArgsIface {\n export: string;\n event: DynamicEvent;\n payload: DynamicBoundaryEventIface;\n ctx: DynamicResolveContextIface;\n // Names a single returned skill (defaults to the export's last path segment).\n key?: string;\n}\n\nexport interface DispatchHookArgsIface {\n export: string;\n event: HookDispatchEventIface;\n ctx: HookContextIface;\n}\n\nexport interface HookFailureIface {\n message: string;\n}\n\nexport interface ChannelRouteArgsIface {\n export: string;\n request: Request;\n configuration?: JsonObject;\n context?: ChannelReceiveContextIface;\n // The route path relative to the channel's mount point ('/webhook').\n path: string;\n secrets: { get(name: string): Promise<string | null> };\n receive: (input: JsonValue) => Promise<RoomReceiveResult | ChannelReceiveResult>;\n}\n\nexport interface ChannelSocketArgsIface extends ChannelRouteArgsIface {\n socket: ChannelSocketIface;\n}\n\nexport interface IsolateRuntimeIface {\n evaluateApproval(args: {\n reference: InputApprovalIface;\n bindings?: HostedBindingsIface;\n input: AuthoredValue;\n secrets: { get(name: string): Promise<string | null> };\n }): Promise<ToolApproval>;\n runTool(args: RunToolArgsIface): Promise<RunToolResultIface>;\n resolveDynamic(args: ResolveDynamicArgsIface): Promise<JsonValue | null>;\n dispatchHook(\n args: DispatchHookArgsIface,\n ): Promise<{ handled: number; failures: HookFailureIface[] }>;\n // Null when no route of the channel matches the method and path.\n handleChannelRoute(args: ChannelRouteArgsIface): Promise<Response | null>;\n handleChannelSocket(args: ChannelSocketArgsIface): Promise<Response | void | null>;\n}\n\nconst jsonOf = (value: AuthoredValue, path: string): JsonValue => {\n const issues: IssueIface[] = [];\n const json = toJson(value, { path, issues });\n const failure = issues.find((issue) => issue.severity === 'error');\n if (failure != null) throw new Error(failure.message);\n return json;\n};\n\nconst lastSegment = (exportName: string): string => {\n const base = exportName.split('#')[0] ?? exportName;\n return base.split('/').at(-1) ?? base;\n};\n\n// Lowers a resolver's return value to manifest JSON by what it is.\nexport const lowerResolvedValue = (value: AuthoredValue, key: string): JsonValue | null => {\n if (value == null) return null;\n const kind = authoredKindOf(value);\n if (kind === AuthoredKind.Instructions)\n return jsonOf(lowerInstructions(value, null), 'instructions');\n if (kind === AuthoredKind.Skill) {\n const lowered = lowerSkill({ key, value });\n const failure = lowered.issues.find((issue) => issue.severity === 'error');\n if (failure != null) throw new Error(failure.message);\n return jsonOf(lowered.skill, 'skill');\n }\n if (isEnvironmentLike(value) || isOpenRequestLike(value)) {\n const issues: IssueIface[] = [];\n const environment = lowerEnvironment(value, 'environment', issues);\n return jsonOf(environment, 'environment');\n }\n if (isPlainObject(value)) {\n const entries = entriesOf(value);\n if (\n entries.length > 0 &&\n entries.every(([, item]) => authoredKindOf(item) === AuthoredKind.Skill)\n ) {\n return entries.map(([entryKey, item]) =>\n jsonOf(lowerSkill({ key: entryKey, value: item }).skill, 'skill'),\n );\n }\n }\n return jsonOf(value, 'resolved value');\n};\n\nexport interface CombinedEntryIface {\n kind: 'tool' | 'connection';\n key: string;\n exportName: string;\n value: AuthoredValue;\n}\n\nconst throwOnErrors = (issues: IssueIface[]): void => {\n const failure = issues.find((issue) => issue.severity === 'error');\n if (failure != null) throw new Error(failure.message);\n};\n\n// A resolver for the whole `mcpServers` field, used when any tool or\n// connection is dynamic: the manifest stores one slot and the session gets\n// the static and resolved entries together.\nexport const combineMcpServers = (entries: CombinedEntryIface[]): AuthoredValue => {\n const handler =\n (event: DynamicEvent) =>\n async (payload: DynamicBoundaryEventIface, ctx: DynamicResolveContextIface) => {\n const previous = z.array(mcpServerBindingSchema).safeParse(ctx.previousValue).data ?? [];\n const tools: ToolDescriptorIface[] = [];\n const approvals: Record<string, ToolApproval> = {};\n const connections: McpServerBinding[] = [];\n const addTool = (\n name: string,\n exportName: string,\n value: AuthoredValue,\n resolver?: string,\n ): void => {\n const lowered = lowerTool({ name, exportName, value });\n throwOnErrors(lowered.issues);\n registerToolName(value, name);\n if (resolver != null) {\n const snapshot = jsonObjectSchema.parse(\n jsonOf(\n {\n resolver,\n name,\n event,\n payload,\n session: ctx.session,\n messages: ctx.messages,\n channel: ctx.channel,\n },\n 'dynamic tool boundary',\n ),\n );\n lowered.descriptor.dynamic = snapshot;\n if (lowered.descriptor.inputApproval != null)\n lowered.descriptor.inputApproval = {\n ...lowered.descriptor.inputApproval,\n dynamic: snapshot,\n };\n }\n tools.push(lowered.descriptor);\n approvals[name] = lowered.approval;\n };\n const addConnection = (\n key: string,\n exportName: string,\n value: AuthoredValue,\n resolver?: string,\n ): void => {\n const lowered = lowerConnection({ key, exportName, value });\n throwOnErrors(lowered.issues);\n if (resolver != null && lowered.binding.inputApprovals != null) {\n const snapshot = jsonObjectSchema.parse(\n jsonOf(\n {\n resolver,\n name: key,\n event,\n payload,\n session: ctx.session,\n messages: ctx.messages,\n channel: ctx.channel,\n },\n 'dynamic connection boundary',\n ),\n );\n lowered.binding.inputApprovals = Object.fromEntries(\n Object.entries(lowered.binding.inputApprovals).map(([name, reference]) => [\n name,\n { ...reference, dynamic: snapshot },\n ]),\n );\n }\n connections.push(\n resolver == null ? lowered.binding : { ...lowered.binding, dynamicResolver: resolver },\n );\n };\n for (const entry of entries) {\n const add =\n entry.kind === 'tool'\n ? addTool\n : (name: string, exportName: string, value: AuthoredValue) =>\n addConnection(name, exportName, value);\n if (!isDynamicSentinel(entry.value)) {\n add(entry.key, entry.exportName, entry.value);\n continue;\n }\n const resolve = fieldOf(fieldOf(entry.value, 'events'), event);\n if (!isCallable(resolve)) {\n for (const server of previous) {\n if (\n entry.kind === 'connection' &&\n server.kind === McpServerBindingKind.Http &&\n server.dynamicResolver === entry.exportName\n ) {\n connections.push(server);\n } else if (entry.kind === 'tool' && server.kind === McpServerBindingKind.Worker) {\n for (const tool of server.tools) {\n if (tool.dynamic?.['resolver'] !== entry.exportName) continue;\n tools.push(tool);\n approvals[tool.name] = Object.hasOwn(server.approvals ?? {}, tool.name)\n ? (server.approvals?.[tool.name] ?? ToolApproval.Allow)\n : ToolApproval.Allow;\n }\n }\n }\n continue;\n }\n const result = await resolve(payload, ctx);\n if (result == null) continue;\n const kind = authoredKindOf(result);\n if (kind === AuthoredKind.Tool || kind === AuthoredKind.Connection) {\n if (entry.kind === 'tool') addTool(entry.key, entry.exportName, result, entry.exportName);\n else addConnection(entry.key, entry.exportName, result, entry.exportName);\n } else if (isPlainObject(result)) {\n for (const [name, item] of entriesOf(result)) {\n if (entry.kind === 'tool')\n addTool(name, `${entry.exportName}#${name}`, item, entry.exportName);\n else addConnection(name, `${entry.exportName}#${name}`, item, entry.exportName);\n }\n }\n }\n const servers: McpServerBinding[] = [];\n if (tools.length > 0) {\n servers.push({\n key: AUTHORED_SERVER_KEY,\n kind: McpServerBindingKind.Worker,\n tools,\n approvals,\n });\n }\n return jsonOf([...servers, ...connections], 'mcpServers');\n };\n return stamp(\n {\n kind: 'final:dynamic' as const,\n events: {\n [DynamicEvent.SessionStarted]: handler(DynamicEvent.SessionStarted),\n [DynamicEvent.TurnStarted]: handler(DynamicEvent.TurnStarted),\n },\n },\n AuthoredKind.Dynamic,\n );\n};\n\nconst matchRoute = (pattern: string, path: string): boolean => {\n const patternParts = pattern.split('/').filter((part) => part.length > 0);\n const pathParts = path.split('/').filter((part) => part.length > 0);\n if (patternParts.length !== pathParts.length) return false;\n return patternParts.every((part, index) => part.startsWith(':') || part === pathParts[index]);\n};\n\nconst toolModuleSchema = z.looseObject({\n execute: callableSchema,\n inputSchema: optionalValueSchema,\n outputSchema: optionalValueSchema,\n toModelOutput: callableSchema.optional(),\n label: toolLabelSchema.nullish(),\n});\n\nconst sentinelSchema = z.looseObject({ events: authoredRecordSchema });\n\nconst channelModuleSchema = z.looseObject({\n configure: callableSchema.optional(),\n routes: z.array(z.looseObject({ method: z.string(), path: z.string(), handler: callableSchema })),\n});\n\nconst dynamicToolBoundarySchema = z.object({\n resolver: z.string(),\n name: z.string(),\n event: z.nativeEnum(DynamicEvent),\n payload: z.object({\n type: z.nativeEnum(DynamicEvent),\n prompt: z.array(jsonValueSchema).nullable(),\n }),\n session: z.object({\n id: z.string(),\n organizationId: z.string(),\n definitionId: z.string(),\n revisionId: z.string(),\n conversation: z\n .object({\n id: z.string(),\n kind: z.nativeEnum(ConversationKind),\n title: z.string().nullable(),\n metadata: jsonObjectSchema,\n participants: z.array(\n z.object({\n id: z.string(),\n kind: z.nativeEnum(ParticipantKind),\n displayName: z.string(),\n userId: z.string().nullable(),\n }),\n ),\n })\n .nullable(),\n author: z\n .object({\n participantId: z.string().nullable(),\n userId: z.string().nullable(),\n displayName: z.string(),\n })\n .nullable(),\n turn: z.object({ id: z.string() }).nullable(),\n harness: providerRefSchema,\n }),\n messages: z.array(\n z.object({\n role: z.nativeEnum(TranscriptRole),\n content: z.array(jsonValueSchema),\n toolCallId: z.string().nullable(),\n seq: z.number(),\n }),\n ),\n channel: z.object({ kind: z.string().nullable() }),\n});\n\nexport const createIsolateRuntime = (modules: AuthoredRecord): IsolateRuntimeIface => {\n const lookup = (name: string): AuthoredValue => {\n if (!(name in modules)) throw new Error(`bundle has no export ${name}`);\n return modules[name];\n };\n const resolveAuthored = async (args: {\n bindings?: HostedBindingsIface;\n exportName: string;\n dynamic?: JsonValue;\n kind: InputApprovalKind;\n secrets: { get(name: string): Promise<string | null> };\n }): Promise<AuthoredValue> => {\n if (args.dynamic == null) return lookup(args.exportName);\n const boundary = dynamicToolBoundarySchema.parse(args.dynamic);\n if (\n args.exportName !== boundary.resolver &&\n args.exportName !== `${boundary.resolver}#${boundary.name}`\n )\n throw new Error('dynamic export does not match its boundary');\n const sentinel = lookup(boundary.resolver);\n if (!isDynamicSentinel(sentinel)) throw new Error('dynamic resolver is not a defineDynamic');\n const resolve = fieldOf(fieldOf(sentinel, 'events'), boundary.event);\n if (!isCallable(resolve)) throw new Error('dynamic resolver has no boundary handler');\n const result = await resolve(boundary.payload, {\n session: boundary.session,\n messages: boundary.messages,\n channel: boundary.channel,\n secrets: args.secrets,\n bindings: args.bindings,\n });\n const expected =\n args.kind === InputApprovalKind.Tool ? AuthoredKind.Tool : AuthoredKind.Connection;\n return authoredKindOf(result) === expected ? result : fieldOf(result, boundary.name);\n };\n return {\n evaluateApproval: async ({ reference, input, secrets, bindings }) => {\n const value = await resolveAuthored({\n exportName: reference.export,\n dynamic: reference.dynamic,\n kind: reference.kind,\n secrets,\n bindings,\n });\n let policy: AuthoredValue;\n let validated: AuthoredValue = input;\n if (reference.kind === InputApprovalKind.Tool) {\n const tool = toolModuleSchema.parse(value);\n validated = await validateSchemaValue({\n schema: tool.inputSchema,\n value: input,\n what: 'approval input',\n });\n policy = fieldOf(value, 'approval');\n } else {\n if (authoredKindOf(value) !== AuthoredKind.Connection)\n throw new Error('approval export is not a connection');\n policy =\n reference.policyKey == null\n ? fieldOf(value, 'approval')\n : fieldOf(fieldOf(fieldOf(value, 'tools'), 'approval'), reference.policyKey);\n }\n const lowered = lowerApproval(policy);\n const predicate = fieldOf(policy, 'predicate');\n if (lowered.error != null || !lowered.inputDependent || !isCallable(predicate))\n throw new Error('approval reference has no valid input predicate');\n return z.boolean().parse(await predicate(validated)) ? ToolApproval.Ask : ToolApproval.Allow;\n },\n runTool: async (args) => {\n const value = await resolveAuthored({\n exportName: args.export,\n dynamic: args.dynamic,\n kind: InputApprovalKind.Tool,\n secrets: args.ctx.secrets,\n bindings: args.ctx.bindings,\n });\n if (args.dynamic != null)\n registerToolName(value, dynamicToolBoundarySchema.parse(args.dynamic).name);\n const parsed = toolModuleSchema.safeParse(value);\n if (!parsed.success) throw new Error(`${args.export} is not a tool`);\n const tool = parsed.data;\n const input = await validateSchemaValue({\n schema: tool.inputSchema,\n value: args.input,\n what: 'tool input',\n });\n const label = isObjectLike(tool.label) ? tool.label : null;\n const statusLabel = async (\n callback: AuthoredCallable | undefined,\n values: AuthoredValue[],\n ): Promise<string | undefined> => {\n if (callback == null) return undefined;\n try {\n const text = z.string().safeParse(await callback(...values));\n return text.success ? text.data : undefined;\n } catch {\n // Display labels must not turn a completed side effect into a tool failure.\n return undefined;\n }\n };\n const started = await statusLabel(label?.start, [input]);\n if (started != null) args.onProgress?.(null, started);\n const result = await tool.execute(input, args.ctx);\n let output: AuthoredValue = result;\n if (isAsyncIterable(result)) {\n for await (const item of result) {\n output = item;\n args.onProgress?.(\n jsonOf(item, 'tool progress'),\n await statusLabel(label?.delta, [input, item]),\n );\n }\n }\n const validated = await validateSchemaValue({\n schema: tool.outputSchema,\n value: output,\n what: 'tool output',\n });\n const modelOutput = tool.toModelOutput == null ? null : await tool.toModelOutput(validated);\n const completed = await statusLabel(label?.complete, [input, validated]);\n if (completed != null) args.onProgress?.(null, completed);\n return {\n output: jsonOf(validated ?? null, 'tool output'),\n modelOutput: modelOutput == null ? null : jsonOf(modelOutput, 'tool model output'),\n };\n },\n resolveDynamic: async (args) => {\n const sentinel = lookup(args.export);\n const parsed = sentinelSchema.safeParse(sentinel);\n if (!isDynamicSentinel(sentinel) || !parsed.success) {\n throw new Error(`${args.export} is not a defineDynamic resolver`);\n }\n const resolve = parsed.data.events[args.event];\n if (!isCallable(resolve)) return null;\n let result: AuthoredValue;\n try {\n result = await resolve(args.payload, args.ctx);\n } catch (cause) {\n // Dynamic handlers describe configurations; live setup belongs in defineSandbox.\n // `async () => environment.open(...)` is lowered as a request.\n const request = unopenedRequestOf(cause);\n if (request == null) throw cause;\n result = request;\n }\n return lowerResolvedValue(result, args.key ?? lastSegment(args.export));\n },\n dispatchHook: async (args) => {\n const handlers = hookHandlersFor(lookup(args.export), args.event);\n const failures: HookFailureIface[] = [];\n for (const invoke of handlers) {\n try {\n await invoke(args.event, args.ctx);\n } catch (cause) {\n failures.push({ message: messageOf(cause) });\n }\n }\n return { handled: handlers.length, failures };\n },\n handleChannelSocket: async (args) => {\n const original = channelModuleSchema.safeParse(lookup(args.export));\n if (!original.success) return null;\n const parsed =\n original.data.configure == null\n ? original\n : channelModuleSchema.safeParse(await original.data.configure(args.configuration ?? {}));\n if (!parsed.success) throw new Error(`${args.export} configured channel is invalid`);\n const route = parsed.data.routes.find(\n (candidate) => candidate.method === 'WS' && matchRoute(candidate.path, args.path),\n );\n if (route == null) return null;\n const response = await route.handler({\n ...args.context,\n request: args.request,\n secrets: args.secrets,\n receive: args.receive,\n socket: args.socket,\n });\n if (response != null && !(response instanceof Response))\n throw new Error(`${args.export} socket route returned an invalid response`);\n return response;\n },\n handleChannelRoute: async (args) => {\n const original = channelModuleSchema.safeParse(lookup(args.export));\n if (!original.success) return null;\n const parsed =\n original.data.configure == null\n ? original\n : channelModuleSchema.safeParse(await original.data.configure(args.configuration ?? {}));\n if (!parsed.success) throw new Error(`${args.export} configured channel is invalid`);\n const route = parsed.data.routes.find(\n (candidate) =>\n candidate.method === args.request.method && matchRoute(candidate.path, args.path),\n );\n if (route == null) return null;\n const response = await route.handler({\n ...args.context,\n request: args.request,\n secrets: args.secrets,\n receive: args.receive,\n });\n if (!(response instanceof Response)) {\n throw new Error(`${args.export} route ${args.path} did not return a Response`);\n }\n return response;\n },\n };\n};\n"],
|
|
5
|
+
"mappings": "AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAUK;AACP,YAAY,OAAO;AACnB,SAAS,qBAAqB;AAC9B,SAAS,cAAc,gBAAgB,aAAa;AACpD;AAAA,EACE;AAAA,OAGK;AAEP;AAAA,EACE;AAAA,OAGK;AACP,SAAS,kBAAkB,uBAAuB;AAClD,SAAS,2BAA2B;AACpC;AAAA,EACE;AA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ithubSignature } from './github-signature';
|
|
4
|
-
|
|
5
|
-
const actionSchema = z.object({ action: z.string() });
|
|
6
|
-
const releaseEventSchema = actionSchema.extend({ release: z.object({ tag_name: z.string() }) });
|
|
7
|
-
|
|
8
|
-
export default defineChannel({
|
|
9
|
-
routes: [
|
|
10
|
-
POST('/webhook', async ({ request, secrets, receive }) => {
|
|
11
|
-
const body = await request.text();
|
|
12
|
-
if (
|
|
13
|
-
!(await verifyGithubSignature(request, body, await secrets.get('github-webhook-secret')))
|
|
14
|
-
) {
|
|
15
|
-
return new Response(null, { status: 401 });
|
|
16
|
-
}
|
|
17
|
-
let raw: unknown;
|
|
18
|
-
try {
|
|
19
|
-
raw = JSON.parse(body);
|
|
20
|
-
} catch {
|
|
21
|
-
return new Response(null, { status: 400 });
|
|
22
|
-
}
|
|
23
|
-
const action = actionSchema.safeParse(raw);
|
|
24
|
-
if (!action.success) return new Response(null, { status: 400 });
|
|
25
|
-
if (action.data.action !== 'published') return new Response(null, { status: 204 });
|
|
26
|
-
const parsed = releaseEventSchema.safeParse(raw);
|
|
27
|
-
if (!parsed.success) return new Response(null, { status: 400 });
|
|
28
|
-
await receive({
|
|
29
|
-
target: { kind: 'bound-conversation' },
|
|
30
|
-
content: [
|
|
31
|
-
{ type: 'text', text: `GitHub release published: ${parsed.data.release.tag_name}` },
|
|
32
|
-
],
|
|
33
|
-
});
|
|
34
|
-
return new Response(null, { status: 202 });
|
|
35
|
-
}),
|
|
36
|
-
],
|
|
37
|
-
turnPolicy: 'steer',
|
|
38
|
-
});
|
|
1
|
+
import { webhookChannel } from '@finalai/final-agent-provider/channels/webhook';
|
|
2
|
+
export default webhookChannel({ secret: 'github-webhook-secret' });
|
|
@@ -15,7 +15,7 @@ export default defineHook({
|
|
|
15
15
|
console.warn('release notes missing', { tag: event.data.rawInput['tag'] });
|
|
16
16
|
},
|
|
17
17
|
async '*'(event, ctx) {
|
|
18
|
-
await fetch('https://audit.
|
|
18
|
+
await fetch('https://audit.example.com/events', {
|
|
19
19
|
method: 'POST',
|
|
20
20
|
body: JSON.stringify({ id: event.meta.id, session: ctx.session.id, type: event.type }),
|
|
21
21
|
});
|
|
@@ -11,7 +11,7 @@ export default defineDynamic({
|
|
|
11
11
|
preview: 'Release calendar: 2.4.1 on 2026-10-10. On-call: @mina.',
|
|
12
12
|
events: {
|
|
13
13
|
'session.started': async (_event, ctx) => {
|
|
14
|
-
const url = new URL('https://ops.
|
|
14
|
+
const url = new URL('https://ops.example.com/calendar');
|
|
15
15
|
url.searchParams.set('org', ctx.session.organizationId);
|
|
16
16
|
const res = await fetch(url);
|
|
17
17
|
const text = await res.text();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@finalai/agent-definition",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Provider-independent agent authoring, manifest schemas, directory compiler, and harness compatibility reports.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"registry": "https://registry.npmjs.org/"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
|
-
"@finalai/agent-protocol": "0.
|
|
79
|
-
"@finalai/agent-provider": "0.
|
|
78
|
+
"@finalai/agent-protocol": "0.7.0",
|
|
79
|
+
"@finalai/agent-provider": "0.6.0",
|
|
80
80
|
"ajv": "^8.20.0",
|
|
81
81
|
"ajv-formats": "^3.0.1",
|
|
82
82
|
"croner": "^10.0.1",
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"json-schema-library": "11.6.5",
|
|
85
85
|
"re2js": "2.8.6",
|
|
86
86
|
"yaml": "^2.8.3",
|
|
87
|
-
"zod": "4.6.
|
|
87
|
+
"zod": "4.6.6"
|
|
88
88
|
},
|
|
89
89
|
"engines": {
|
|
90
90
|
"node": ">=26"
|