@finalai/agent-definition 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @finalai/agent-definition might be problematic. Click here for more details.
- package/README.md +16 -0
- package/THIRD_PARTY_NOTICES.md +303 -0
- package/dist/compiler-assets/chunk-2CZRHOLL.ts +10 -0
- package/dist/compiler-assets/chunk-32O3ODZE.ts +39 -0
- package/dist/compiler-assets/chunk-5BK6FVRE.ts +75 -0
- package/dist/compiler-assets/chunk-6WR3PGNF.ts +0 -0
- package/dist/compiler-assets/chunk-7QP2CKPI.ts +30 -0
- package/dist/compiler-assets/chunk-7VSSVZM4.ts +55 -0
- package/dist/compiler-assets/chunk-7WGYG73V.ts +42 -0
- package/dist/compiler-assets/chunk-BLB6JGLO.ts +481 -0
- package/dist/compiler-assets/chunk-CWWRTRWW.ts +76 -0
- package/dist/compiler-assets/chunk-EVQIK62B.ts +188 -0
- package/dist/compiler-assets/chunk-GNR7XBPN.ts +3364 -0
- package/dist/compiler-assets/chunk-GTUZOATD.ts +10 -0
- package/dist/compiler-assets/chunk-HFS4KLEL.ts +10 -0
- package/dist/compiler-assets/chunk-HGW4YHAY.ts +6865 -0
- package/dist/compiler-assets/chunk-HNPUTP35.ts +172 -0
- package/dist/compiler-assets/chunk-JIPNTA56.ts +59 -0
- package/dist/compiler-assets/chunk-JNJE72EH.ts +10 -0
- package/dist/compiler-assets/chunk-JPY4L2UJ.ts +349 -0
- package/dist/compiler-assets/chunk-JTGTLYDT.ts +0 -0
- package/dist/compiler-assets/chunk-LUSAAV4L.ts +33 -0
- package/dist/compiler-assets/chunk-MZMSKIKU.ts +472 -0
- package/dist/compiler-assets/chunk-NMYHO2QN.ts +25 -0
- package/dist/compiler-assets/chunk-NYTOYKKF.ts +28 -0
- package/dist/compiler-assets/chunk-OWC6SFFF.ts +295 -0
- package/dist/compiler-assets/chunk-QMKWAFVZ.ts +59 -0
- package/dist/compiler-assets/chunk-QMWTDPNT.ts +79 -0
- package/dist/compiler-assets/chunk-RWUIMTBI.ts +13 -0
- package/dist/compiler-assets/chunk-SKTNMUO7.ts +64 -0
- package/dist/compiler-assets/chunk-T6WG4L4M.ts +19 -0
- package/dist/compiler-assets/chunk-TATN3PYK.ts +81 -0
- package/dist/compiler-assets/chunk-VHXHUU7L.ts +16 -0
- package/dist/compiler-assets/chunk-WMXMVFHM.ts +121 -0
- package/dist/compiler-assets/chunk-XHKPWT3G.ts +55 -0
- package/dist/compiler-assets/chunk-ZDLVA6XF.ts +476 -0
- package/dist/compiler-assets/src/authoring/agent.ts +10 -0
- package/dist/compiler-assets/src/authoring/approval.ts +19 -0
- package/dist/compiler-assets/src/authoring/brand.ts +23 -0
- package/dist/compiler-assets/src/authoring/channels.ts +26 -0
- package/dist/compiler-assets/src/authoring/connections.ts +10 -0
- package/dist/compiler-assets/src/authoring/context.ts +7 -0
- package/dist/compiler-assets/src/authoring/credentials.ts +21 -0
- package/dist/compiler-assets/src/authoring/dynamic.ts +10 -0
- package/dist/compiler-assets/src/authoring/harness.ts +17 -0
- package/dist/compiler-assets/src/authoring/hooks.ts +28 -0
- package/dist/compiler-assets/src/authoring/index.ts +110 -0
- package/dist/compiler-assets/src/authoring/instructions.ts +14 -0
- package/dist/compiler-assets/src/authoring/sandbox.ts +25 -0
- package/dist/compiler-assets/src/authoring/schedules.ts +10 -0
- package/dist/compiler-assets/src/authoring/skills.ts +10 -0
- package/dist/compiler-assets/src/authoring/tools.ts +23 -0
- package/dist/compiler-assets/src/compatibility.ts +14810 -0
- package/dist/compiler-assets/src/compiler/evaluate-child.mjs +77 -0
- package/dist/compiler-assets/src/index.ts +195 -0
- package/dist/compiler-assets/src/manifest.ts +72 -0
- package/dist/compiler-assets/src/resolve.ts +19 -0
- package/dist/compiler-assets/src/runtime/bundle.ts +72 -0
- package/dist/compiler-assets/src/runtime/describe.ts +31 -0
- package/dist/compiler-assets/src/runtime/described.ts +142 -0
- package/dist/compiler-assets/src/runtime/isolate.ts +28 -0
- package/dist/compiler-assets/src/runtime/layout.ts +15 -0
- package/dist/compiler-assets/src/runtime/lower.ts +52 -0
- package/dist/compiler-assets/src/runtime/schema-validation.ts +21 -0
- package/dist/compiler-assets/src/runtime/values.ts +38 -0
- package/dist/modules/authoring/agent.d.mts +22 -0
- package/dist/modules/authoring/agent.mjs +6 -0
- package/dist/modules/authoring/agent.mjs.map +7 -0
- package/dist/modules/authoring/approval.d.mts +17 -0
- package/dist/modules/authoring/approval.mjs +42 -0
- package/dist/modules/authoring/approval.mjs.map +7 -0
- package/dist/modules/authoring/brand.d.mts +27 -0
- package/dist/modules/authoring/brand.mjs +51 -0
- package/dist/modules/authoring/brand.mjs.map +7 -0
- package/dist/modules/authoring/channels.d.mts +41 -0
- package/dist/modules/authoring/channels.mjs +65 -0
- package/dist/modules/authoring/channels.mjs.map +7 -0
- package/dist/modules/authoring/connections.d.mts +23 -0
- package/dist/modules/authoring/connections.mjs +6 -0
- package/dist/modules/authoring/connections.mjs.map +7 -0
- package/dist/modules/authoring/context.d.mts +83 -0
- package/dist/modules/authoring/context.mjs +12 -0
- package/dist/modules/authoring/context.mjs.map +7 -0
- package/dist/modules/authoring/credentials.d.mts +10 -0
- package/dist/modules/authoring/credentials.mjs +31 -0
- package/dist/modules/authoring/credentials.mjs.map +7 -0
- package/dist/modules/authoring/dynamic.d.mts +30 -0
- package/dist/modules/authoring/dynamic.mjs +15 -0
- package/dist/modules/authoring/dynamic.mjs.map +7 -0
- package/dist/modules/authoring/harness.d.mts +85 -0
- package/dist/modules/authoring/harness.mjs +55 -0
- package/dist/modules/authoring/harness.mjs.map +7 -0
- package/dist/modules/authoring/hooks.d.mts +120 -0
- package/dist/modules/authoring/hooks.mjs +72 -0
- package/dist/modules/authoring/hooks.mjs.map +7 -0
- package/dist/modules/authoring/index.d.mts +27 -0
- package/dist/modules/authoring/index.mjs +63 -0
- package/dist/modules/authoring/index.mjs.map +7 -0
- package/dist/modules/authoring/instructions.d.mts +13 -0
- package/dist/modules/authoring/instructions.mjs +15 -0
- package/dist/modules/authoring/instructions.mjs.map +7 -0
- package/dist/modules/authoring/sandbox.d.mts +21 -0
- package/dist/modules/authoring/sandbox.mjs +13 -0
- package/dist/modules/authoring/sandbox.mjs.map +7 -0
- package/dist/modules/authoring/schedules.d.mts +8 -0
- package/dist/modules/authoring/schedules.mjs +6 -0
- package/dist/modules/authoring/schedules.mjs.map +7 -0
- package/dist/modules/authoring/skills.d.mts +8 -0
- package/dist/modules/authoring/skills.mjs +6 -0
- package/dist/modules/authoring/skills.mjs.map +7 -0
- package/dist/modules/authoring/tools.d.mts +80 -0
- package/dist/modules/authoring/tools.mjs +70 -0
- package/dist/modules/authoring/tools.mjs.map +7 -0
- package/dist/modules/compatibility.d.mts +36 -0
- package/dist/modules/compatibility.mjs +536 -0
- package/dist/modules/compatibility.mjs.map +7 -0
- package/dist/modules/compiler/assemble.d.mts +30 -0
- package/dist/modules/compiler/assemble.mjs +923 -0
- package/dist/modules/compiler/assemble.mjs.map +7 -0
- package/dist/modules/compiler/bundle.d.mts +22 -0
- package/dist/modules/compiler/bundle.mjs +385 -0
- package/dist/modules/compiler/bundle.mjs.map +7 -0
- package/dist/modules/compiler/diagnostics.d.mts +40 -0
- package/dist/modules/compiler/diagnostics.mjs +38 -0
- package/dist/modules/compiler/diagnostics.mjs.map +7 -0
- package/dist/modules/compiler/discovery.d.mts +36 -0
- package/dist/modules/compiler/discovery.mjs +158 -0
- package/dist/modules/compiler/discovery.mjs.map +7 -0
- package/dist/modules/compiler/evaluate.d.mts +13 -0
- package/dist/modules/compiler/evaluate.mjs +194 -0
- package/dist/modules/compiler/evaluate.mjs.map +7 -0
- package/dist/modules/compiler/files.d.mts +19 -0
- package/dist/modules/compiler/files.mjs +90 -0
- package/dist/modules/compiler/files.mjs.map +7 -0
- package/dist/modules/compiler/frontmatter.d.mts +9 -0
- package/dist/modules/compiler/frontmatter.mjs +34 -0
- package/dist/modules/compiler/frontmatter.mjs.map +7 -0
- package/dist/modules/compiler/index.d.mts +49 -0
- package/dist/modules/compiler/index.mjs +244 -0
- package/dist/modules/compiler/index.mjs.map +7 -0
- package/dist/modules/compiler/load.d.mts +8 -0
- package/dist/modules/compiler/load.mjs +45 -0
- package/dist/modules/compiler/load.mjs.map +7 -0
- package/dist/modules/compiler/local-isolate.d.mts +20 -0
- package/dist/modules/compiler/local-isolate.mjs +93 -0
- package/dist/modules/compiler/local-isolate.mjs.map +7 -0
- package/dist/modules/compiler/packages.d.mts +66 -0
- package/dist/modules/compiler/packages.mjs +307 -0
- package/dist/modules/compiler/packages.mjs.map +7 -0
- package/dist/modules/index.d.mts +7 -0
- package/dist/modules/index.mjs +25 -0
- package/dist/modules/index.mjs.map +7 -0
- package/dist/modules/manifest.d.mts +2 -0
- package/dist/modules/manifest.mjs +67 -0
- package/dist/modules/manifest.mjs.map +7 -0
- package/dist/modules/resolve.d.mts +24 -0
- package/dist/modules/resolve.mjs +176 -0
- package/dist/modules/resolve.mjs.map +7 -0
- package/dist/modules/runtime/bundle.d.mts +12 -0
- package/dist/modules/runtime/bundle.mjs +48 -0
- package/dist/modules/runtime/bundle.mjs.map +7 -0
- package/dist/modules/runtime/describe.d.mts +19 -0
- package/dist/modules/runtime/describe.mjs +471 -0
- package/dist/modules/runtime/describe.mjs.map +7 -0
- package/dist/modules/runtime/described.d.mts +376 -0
- package/dist/modules/runtime/described.mjs +116 -0
- package/dist/modules/runtime/described.mjs.map +7 -0
- package/dist/modules/runtime/isolate.d.mts +70 -0
- package/dist/modules/runtime/isolate.mjs +454 -0
- package/dist/modules/runtime/isolate.mjs.map +7 -0
- package/dist/modules/runtime/layout.d.mts +21 -0
- package/dist/modules/runtime/layout.mjs +24 -0
- package/dist/modules/runtime/layout.mjs.map +7 -0
- package/dist/modules/runtime/lower.d.mts +73 -0
- package/dist/modules/runtime/lower.mjs +463 -0
- package/dist/modules/runtime/lower.mjs.map +7 -0
- package/dist/modules/runtime/schema-validation.d.mts +21 -0
- package/dist/modules/runtime/schema-validation.mjs +238 -0
- package/dist/modules/runtime/schema-validation.mjs.map +7 -0
- package/dist/modules/runtime/values.d.mts +20 -0
- package/dist/modules/runtime/values.mjs +48 -0
- package/dist/modules/runtime/values.mjs.map +7 -0
- package/fixtures/acme-fleet/agent/agent.ts +74 -0
- package/fixtures/acme-fleet/agent/instructions.md +1 -0
- package/fixtures/assistant/agent/agent.ts +16 -0
- package/fixtures/assistant/agent/instructions.md +1 -0
- package/fixtures/assistant/agent/tools/current_time.ts +9 -0
- package/fixtures/assistant-with-tools/agent/agent.ts +16 -0
- package/fixtures/assistant-with-tools/agent/instructions.md +1 -0
- package/fixtures/assistant-with-tools/agent/tools/current_time.ts +9 -0
- package/fixtures/final-connection/agent/agent.ts +15 -0
- package/fixtures/final-connection/agent/connections/final.ts +9 -0
- package/fixtures/release-scout/agent/agent.ts +22 -0
- package/fixtures/release-scout/agent/channels/github-signature.ts +27 -0
- package/fixtures/release-scout/agent/channels/github.ts +38 -0
- package/fixtures/release-scout/agent/connections/linear.ts +9 -0
- package/fixtures/release-scout/agent/hooks/audit.ts +24 -0
- package/fixtures/release-scout/agent/instructions/org-context.ts +26 -0
- package/fixtures/release-scout/agent/instructions.md +2 -0
- package/fixtures/release-scout/agent/sandbox.ts +20 -0
- package/fixtures/release-scout/agent/schedules/daily-digest.md +7 -0
- package/fixtures/release-scout/agent/skills/triage/SKILL.md +8 -0
- package/fixtures/release-scout/agent/skills/triage/checklist.md +3 -0
- package/fixtures/release-scout/agent/tools/lookup_release_notes.ts +24 -0
- package/fixtures/tsconfig.json +5 -0
- package/package.json +94 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
import {
|
|
2
|
+
jsonObjectSchema,
|
|
3
|
+
jsonSchemaSchema,
|
|
4
|
+
jsonValueSchema
|
|
5
|
+
} from "./chunk-7QP2CKPI.ts";
|
|
6
|
+
import {
|
|
7
|
+
DynamicEvent,
|
|
8
|
+
containsDynamicSlot,
|
|
9
|
+
maybeDynamic
|
|
10
|
+
} from "./chunk-SKTNMUO7.ts";
|
|
11
|
+
import {
|
|
12
|
+
array,
|
|
13
|
+
boolean,
|
|
14
|
+
discriminatedUnion,
|
|
15
|
+
literal,
|
|
16
|
+
nativeEnum,
|
|
17
|
+
object,
|
|
18
|
+
partialRecord,
|
|
19
|
+
record,
|
|
20
|
+
string,
|
|
21
|
+
union
|
|
22
|
+
} from "./chunk-HGW4YHAY.ts";
|
|
23
|
+
|
|
24
|
+
// ../agent-provider/src/provider-ref.ts
|
|
25
|
+
var packageProviderRefSchema = object({
|
|
26
|
+
kind: literal("package" /* Package */),
|
|
27
|
+
specifier: string().min(1)
|
|
28
|
+
});
|
|
29
|
+
var bundleProviderRefSchema = object({
|
|
30
|
+
kind: literal("bundle" /* Bundle */),
|
|
31
|
+
export: string().min(1)
|
|
32
|
+
});
|
|
33
|
+
var providerRefSchema = discriminatedUnion("kind", [
|
|
34
|
+
packageProviderRefSchema,
|
|
35
|
+
bundleProviderRefSchema
|
|
36
|
+
]);
|
|
37
|
+
var packageRef = (specifier) => ({
|
|
38
|
+
kind: "package" /* Package */,
|
|
39
|
+
specifier
|
|
40
|
+
});
|
|
41
|
+
var bundleRef = (exportName) => ({
|
|
42
|
+
kind: "bundle" /* Bundle */,
|
|
43
|
+
export: exportName
|
|
44
|
+
});
|
|
45
|
+
var formatProviderRef = (ref) => ref.kind === "package" /* Package */ ? `package:${ref.specifier}` : `bundle:${ref.export}`;
|
|
46
|
+
|
|
47
|
+
// ../agent-provider/src/manifest.ts
|
|
48
|
+
var MANIFEST_VERSION = 2;
|
|
49
|
+
var BaseCapability = /* @__PURE__ */ ((BaseCapability2) => {
|
|
50
|
+
BaseCapability2["Shell"] = "shell";
|
|
51
|
+
BaseCapability2["Files"] = "files";
|
|
52
|
+
BaseCapability2["Process"] = "process";
|
|
53
|
+
BaseCapability2["Ports"] = "ports";
|
|
54
|
+
BaseCapability2["Browser"] = "browser";
|
|
55
|
+
BaseCapability2["ComputerUse"] = "computerUse";
|
|
56
|
+
return BaseCapability2;
|
|
57
|
+
})(BaseCapability || {});
|
|
58
|
+
var ToolApproval = /* @__PURE__ */ ((ToolApproval2) => {
|
|
59
|
+
ToolApproval2["Allow"] = "allow";
|
|
60
|
+
ToolApproval2["Ask"] = "ask";
|
|
61
|
+
return ToolApproval2;
|
|
62
|
+
})(ToolApproval || {});
|
|
63
|
+
var SandboxAccess = /* @__PURE__ */ ((SandboxAccess2) => {
|
|
64
|
+
SandboxAccess2["Read"] = "read";
|
|
65
|
+
SandboxAccess2["Execute"] = "execute";
|
|
66
|
+
SandboxAccess2["Write"] = "write";
|
|
67
|
+
return SandboxAccess2;
|
|
68
|
+
})(SandboxAccess || {});
|
|
69
|
+
var SandboxAttach = /* @__PURE__ */ ((SandboxAttach2) => {
|
|
70
|
+
SandboxAttach2["Lazy"] = "lazy";
|
|
71
|
+
SandboxAttach2["OnPrompt"] = "on-prompt";
|
|
72
|
+
return SandboxAttach2;
|
|
73
|
+
})(SandboxAttach || {});
|
|
74
|
+
var McpServerBindingKind = /* @__PURE__ */ ((McpServerBindingKind2) => {
|
|
75
|
+
McpServerBindingKind2["Worker"] = "worker";
|
|
76
|
+
McpServerBindingKind2["Http"] = "http";
|
|
77
|
+
return McpServerBindingKind2;
|
|
78
|
+
})(McpServerBindingKind || {});
|
|
79
|
+
var ScheduleTarget = /* @__PURE__ */ ((ScheduleTarget2) => {
|
|
80
|
+
ScheduleTarget2["OwnerDirect"] = "owner-direct";
|
|
81
|
+
ScheduleTarget2["BoundConversation"] = "bound-conversation";
|
|
82
|
+
return ScheduleTarget2;
|
|
83
|
+
})(ScheduleTarget || {});
|
|
84
|
+
var identitySchema = object({
|
|
85
|
+
name: string().min(1).max(120),
|
|
86
|
+
description: string().max(2e3).nullable(),
|
|
87
|
+
avatarUrl: string().url().nullable()
|
|
88
|
+
});
|
|
89
|
+
var InputApprovalKind = /* @__PURE__ */ ((InputApprovalKind2) => {
|
|
90
|
+
InputApprovalKind2["Tool"] = "tool";
|
|
91
|
+
InputApprovalKind2["Connection"] = "connection";
|
|
92
|
+
return InputApprovalKind2;
|
|
93
|
+
})(InputApprovalKind || {});
|
|
94
|
+
var inputApprovalSchema = object({
|
|
95
|
+
kind: nativeEnum(InputApprovalKind),
|
|
96
|
+
export: string().min(1),
|
|
97
|
+
// Connection default when absent; otherwise tools.approval[policyKey].
|
|
98
|
+
policyKey: string().min(1).optional(),
|
|
99
|
+
dynamic: jsonObjectSchema.optional()
|
|
100
|
+
});
|
|
101
|
+
var toolDescriptorSchema = object({
|
|
102
|
+
name: string().min(1),
|
|
103
|
+
description: string(),
|
|
104
|
+
inputSchema: jsonSchemaSchema,
|
|
105
|
+
outputSchema: jsonSchemaSchema.optional(),
|
|
106
|
+
annotations: object({
|
|
107
|
+
title: string().optional(),
|
|
108
|
+
readOnlyHint: boolean().optional(),
|
|
109
|
+
destructiveHint: boolean().optional(),
|
|
110
|
+
idempotentHint: boolean().optional(),
|
|
111
|
+
openWorldHint: boolean().optional()
|
|
112
|
+
}).optional(),
|
|
113
|
+
// Bundle export implementing it ('tools/lookup_release_notes').
|
|
114
|
+
export: string().min(1).optional(),
|
|
115
|
+
// Boundary snapshot used to reconstruct dynamic tools after isolate eviction.
|
|
116
|
+
dynamic: jsonObjectSchema.optional(),
|
|
117
|
+
inputApproval: inputApprovalSchema.optional()
|
|
118
|
+
});
|
|
119
|
+
var mcpAuthSchema = union([
|
|
120
|
+
object({ secretKey: string().min(1), headerName: string().min(1).nullable() }),
|
|
121
|
+
// Resolved by the broker to a session-scoped grant (Final's own MCP server).
|
|
122
|
+
object({ kind: literal("final-session") })
|
|
123
|
+
]);
|
|
124
|
+
var toolApprovalsSchema = record(string(), nativeEnum(ToolApproval)).nullable();
|
|
125
|
+
var workerMcpServerBindingSchema = object({
|
|
126
|
+
key: string().min(1),
|
|
127
|
+
kind: literal("worker" /* Worker */),
|
|
128
|
+
tools: array(toolDescriptorSchema),
|
|
129
|
+
approvals: toolApprovalsSchema
|
|
130
|
+
});
|
|
131
|
+
var httpMcpServerBindingSchema = object({
|
|
132
|
+
key: string().min(1),
|
|
133
|
+
kind: literal("http" /* Http */),
|
|
134
|
+
url: string().url(),
|
|
135
|
+
auth: mcpAuthSchema.nullable(),
|
|
136
|
+
headers: record(string(), string()).default({}),
|
|
137
|
+
// Null allows every tool the server lists, each with the default approval.
|
|
138
|
+
approvals: toolApprovalsSchema,
|
|
139
|
+
// Tools hidden even when `approvals` would expose them.
|
|
140
|
+
deny: array(string().min(1)).optional(),
|
|
141
|
+
// The authored resolver that produced this connection, for retained boundary values.
|
|
142
|
+
dynamicResolver: string().min(1).optional(),
|
|
143
|
+
inputApprovals: record(string(), inputApprovalSchema).optional()
|
|
144
|
+
});
|
|
145
|
+
var mcpServerBindingSchema = discriminatedUnion("kind", [
|
|
146
|
+
workerMcpServerBindingSchema,
|
|
147
|
+
httpMcpServerBindingSchema
|
|
148
|
+
]);
|
|
149
|
+
var sandboxBindingSchema = object({
|
|
150
|
+
provider: providerRefSchema,
|
|
151
|
+
// Provider-defined environment options (`computer`: a setup guide reference or
|
|
152
|
+
// inline guide plus start-time parameters). Validated by the provider.
|
|
153
|
+
environment: maybeDynamic(jsonValueSchema),
|
|
154
|
+
access: nativeEnum(SandboxAccess).default("write" /* Write */),
|
|
155
|
+
attach: nativeEnum(SandboxAttach).default("lazy" /* Lazy */)
|
|
156
|
+
});
|
|
157
|
+
var baseToolsSchema = object({
|
|
158
|
+
base: partialRecord(nativeEnum(BaseCapability), object({ target: string().min(1) })),
|
|
159
|
+
// Capabilities declared on the harness's own host with no sandbox target
|
|
160
|
+
// (`baseTools({ shell: harnessHost })`): only a harness that
|
|
161
|
+
// provides them natively (host-disableable, host-fixed) can serve them.
|
|
162
|
+
host: array(nativeEnum(BaseCapability)).optional()
|
|
163
|
+
});
|
|
164
|
+
var channelBindingSchema = object({
|
|
165
|
+
// Stable within the definition; publish maps it to a binding id.
|
|
166
|
+
key: string().min(1),
|
|
167
|
+
channel: providerRefSchema,
|
|
168
|
+
config: jsonObjectSchema.default({}),
|
|
169
|
+
source: string().optional()
|
|
170
|
+
});
|
|
171
|
+
var hookBindingSchema = object({
|
|
172
|
+
slug: string().min(1),
|
|
173
|
+
export: string().min(1),
|
|
174
|
+
events: array(string().min(1)).min(1)
|
|
175
|
+
});
|
|
176
|
+
var scheduleDefinitionSchema = object({
|
|
177
|
+
key: string().min(1),
|
|
178
|
+
cron: string().min(1),
|
|
179
|
+
timezone: string().min(1),
|
|
180
|
+
prompt: string().min(1),
|
|
181
|
+
target: nativeEnum(ScheduleTarget)
|
|
182
|
+
});
|
|
183
|
+
var bundleSchema = object({
|
|
184
|
+
// Absent on historical revisions: the host must inspect their resources.
|
|
185
|
+
hasPreparationFiles: boolean().optional(),
|
|
186
|
+
hash: string().min(1),
|
|
187
|
+
// Dynamic slot path → resolver export and events.
|
|
188
|
+
resolvers: record(
|
|
189
|
+
string(),
|
|
190
|
+
object({ export: string().min(1), events: array(nativeEnum(DynamicEvent)).min(1) })
|
|
191
|
+
)
|
|
192
|
+
});
|
|
193
|
+
var harnessBindingSchema = object({
|
|
194
|
+
harness: providerRefSchema,
|
|
195
|
+
// Validated against the harness's configSchema; may contain dynamic slots at
|
|
196
|
+
// any depth (an instruction fragment, the model).
|
|
197
|
+
config: maybeDynamic(jsonValueSchema)
|
|
198
|
+
});
|
|
199
|
+
var agentManifestSchema = object({
|
|
200
|
+
version: literal(MANIFEST_VERSION),
|
|
201
|
+
identity: identitySchema,
|
|
202
|
+
harness: harnessBindingSchema,
|
|
203
|
+
mcpServers: maybeDynamic(array(mcpServerBindingSchema)),
|
|
204
|
+
sandboxes: maybeDynamic(record(string(), sandboxBindingSchema)),
|
|
205
|
+
tools: baseToolsSchema,
|
|
206
|
+
toolPolicy: record(string(), nativeEnum(ToolApproval)),
|
|
207
|
+
// Organization secrets this agent may read, by name (`secrets.get`,
|
|
208
|
+
// MCP `secretKey`, `apiKey({ secret })`). Nothing else is readable;
|
|
209
|
+
// binding organization secrets requires an organization admin at publish.
|
|
210
|
+
secrets: array(string().min(1)).default([]),
|
|
211
|
+
channels: array(channelBindingSchema),
|
|
212
|
+
channelSources: record(string(), object({ path: string(), source: string(), disabled: boolean() })).optional(),
|
|
213
|
+
hooks: array(hookBindingSchema),
|
|
214
|
+
schedules: array(scheduleDefinitionSchema),
|
|
215
|
+
bundle: bundleSchema.nullable()
|
|
216
|
+
});
|
|
217
|
+
var resolvedAgentManifestSchema = agentManifestSchema.extend({
|
|
218
|
+
harness: object({ harness: providerRefSchema, config: jsonValueSchema }),
|
|
219
|
+
mcpServers: array(mcpServerBindingSchema),
|
|
220
|
+
sandboxes: record(string(), sandboxBindingSchema.extend({ environment: jsonValueSchema }))
|
|
221
|
+
}).superRefine((manifest, ctx) => {
|
|
222
|
+
if (containsDynamicSlot(manifest)) {
|
|
223
|
+
ctx.addIssue({
|
|
224
|
+
code: "custom",
|
|
225
|
+
message: "a resolved manifest must not contain dynamic slots"
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
var InstructionRole = /* @__PURE__ */ ((InstructionRole2) => {
|
|
230
|
+
InstructionRole2["System"] = "system";
|
|
231
|
+
InstructionRole2["User"] = "user";
|
|
232
|
+
return InstructionRole2;
|
|
233
|
+
})(InstructionRole || {});
|
|
234
|
+
var instructionFragmentSchema = object({
|
|
235
|
+
role: nativeEnum(InstructionRole),
|
|
236
|
+
content: string(),
|
|
237
|
+
// Source file, for the compatibility report and Build.
|
|
238
|
+
source: string().optional()
|
|
239
|
+
});
|
|
240
|
+
var skillFileSchema = object({ path: string().min(1), content: string() });
|
|
241
|
+
var skillBundleSchema = object({
|
|
242
|
+
key: string().min(1),
|
|
243
|
+
description: string().optional(),
|
|
244
|
+
files: array(skillFileSchema)
|
|
245
|
+
});
|
|
246
|
+
var emptyManifest = (name) => ({
|
|
247
|
+
version: MANIFEST_VERSION,
|
|
248
|
+
identity: { name, description: null, avatarUrl: null },
|
|
249
|
+
harness: {
|
|
250
|
+
harness: packageRef("@finalai/final-agent-provider/harnesses/serverless-final"),
|
|
251
|
+
config: {}
|
|
252
|
+
},
|
|
253
|
+
mcpServers: [],
|
|
254
|
+
sandboxes: {},
|
|
255
|
+
tools: { base: {} },
|
|
256
|
+
toolPolicy: {},
|
|
257
|
+
secrets: [],
|
|
258
|
+
channels: [],
|
|
259
|
+
hooks: [],
|
|
260
|
+
schedules: [],
|
|
261
|
+
bundle: null
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
export {
|
|
265
|
+
providerRefSchema,
|
|
266
|
+
bundleRef,
|
|
267
|
+
formatProviderRef,
|
|
268
|
+
MANIFEST_VERSION,
|
|
269
|
+
BaseCapability,
|
|
270
|
+
ToolApproval,
|
|
271
|
+
SandboxAccess,
|
|
272
|
+
SandboxAttach,
|
|
273
|
+
McpServerBindingKind,
|
|
274
|
+
ScheduleTarget,
|
|
275
|
+
identitySchema,
|
|
276
|
+
toolDescriptorSchema,
|
|
277
|
+
mcpAuthSchema,
|
|
278
|
+
workerMcpServerBindingSchema,
|
|
279
|
+
httpMcpServerBindingSchema,
|
|
280
|
+
mcpServerBindingSchema,
|
|
281
|
+
sandboxBindingSchema,
|
|
282
|
+
baseToolsSchema,
|
|
283
|
+
channelBindingSchema,
|
|
284
|
+
hookBindingSchema,
|
|
285
|
+
scheduleDefinitionSchema,
|
|
286
|
+
bundleSchema,
|
|
287
|
+
harnessBindingSchema,
|
|
288
|
+
agentManifestSchema,
|
|
289
|
+
resolvedAgentManifestSchema,
|
|
290
|
+
InstructionRole,
|
|
291
|
+
instructionFragmentSchema,
|
|
292
|
+
skillFileSchema,
|
|
293
|
+
skillBundleSchema,
|
|
294
|
+
emptyManifest
|
|
295
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {
|
|
2
|
+
harnessDescriptionSchema
|
|
3
|
+
} from "./chunk-JPY4L2UJ.ts";
|
|
4
|
+
import {
|
|
5
|
+
bundleRef
|
|
6
|
+
} from "./chunk-OWC6SFFF.ts";
|
|
7
|
+
import {
|
|
8
|
+
registerPending
|
|
9
|
+
} from "./chunk-XHKPWT3G.ts";
|
|
10
|
+
|
|
11
|
+
// src/authoring/harness.ts
|
|
12
|
+
var completeHarnessDescription = (authored) => {
|
|
13
|
+
const supports = {
|
|
14
|
+
observe: authored.supports?.observe ?? false,
|
|
15
|
+
resumeReplay: authored.supports?.resumeReplay ?? false,
|
|
16
|
+
fork: authored.supports?.fork ?? false,
|
|
17
|
+
authorMeta: authored.supports?.authorMeta ?? false
|
|
18
|
+
};
|
|
19
|
+
if (authored.supports?.nativeToolPolicy != null)
|
|
20
|
+
supports.nativeToolPolicy = authored.supports.nativeToolPolicy;
|
|
21
|
+
return harnessDescriptionSchema.parse({
|
|
22
|
+
...authored,
|
|
23
|
+
acp: { transports: authored.acp.transports, mcp: authored.acp.mcp ?? [] },
|
|
24
|
+
baseTools: authored.baseTools ?? {},
|
|
25
|
+
consumes: authored.consumes ?? [],
|
|
26
|
+
inference: {
|
|
27
|
+
vendors: authored.inference?.vendors ?? [],
|
|
28
|
+
kinds: authored.inference?.kinds ?? ["harness-owned" /* HarnessOwned */],
|
|
29
|
+
delivery: authored.inference?.delivery ?? "at-open" /* AtOpen */
|
|
30
|
+
},
|
|
31
|
+
supports
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
var defineHarness = (implementation) => {
|
|
35
|
+
let placeholder = null;
|
|
36
|
+
const binding = (config) => ({
|
|
37
|
+
harness: placeholder ?? bundleRef("<pending>"),
|
|
38
|
+
config,
|
|
39
|
+
definedHarness: true
|
|
40
|
+
});
|
|
41
|
+
const defined = Object.assign(binding, {
|
|
42
|
+
describe: async (args) => completeHarnessDescription(await implementation.describe(args)),
|
|
43
|
+
open: (args) => implementation.open({ ...args, sessionId: args.session.sessionId }),
|
|
44
|
+
resume: (args) => implementation.resume({ ...args, sessionId: args.session.sessionId }),
|
|
45
|
+
park: (ref, ctx) => implementation.park({ ...ref, ...ctx, ref }, ctx),
|
|
46
|
+
close: (ref, ctx) => implementation.close({ ...ref, ...ctx, ref }, ctx),
|
|
47
|
+
health: async (ref, ctx) => {
|
|
48
|
+
const health = await implementation.health({ ...ref, ...ctx, ref }, ctx);
|
|
49
|
+
return { ...health, checkedAt: health.checkedAt ?? (/* @__PURE__ */ new Date()).toISOString() };
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
placeholder = bundleRef(registerPending(defined));
|
|
53
|
+
return defined;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export {
|
|
57
|
+
completeHarnessDescription,
|
|
58
|
+
defineHarness
|
|
59
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import {
|
|
2
|
+
stamp
|
|
3
|
+
} from "./chunk-XHKPWT3G.ts";
|
|
4
|
+
import {
|
|
5
|
+
authoredRecordSchema,
|
|
6
|
+
isCallable
|
|
7
|
+
} from "./chunk-JIPNTA56.ts";
|
|
8
|
+
import {
|
|
9
|
+
looseObject
|
|
10
|
+
} from "./chunk-HGW4YHAY.ts";
|
|
11
|
+
|
|
12
|
+
// src/authoring/hooks.ts
|
|
13
|
+
var HookEvent = /* @__PURE__ */ ((HookEvent2) => {
|
|
14
|
+
HookEvent2["SessionOpened"] = "session.opened";
|
|
15
|
+
HookEvent2["TurnStarted"] = "turn.started";
|
|
16
|
+
HookEvent2["TurnEnded"] = "turn.ended";
|
|
17
|
+
HookEvent2["UserMessageChunk"] = "user_message_chunk";
|
|
18
|
+
HookEvent2["AgentMessageChunk"] = "agent_message_chunk";
|
|
19
|
+
HookEvent2["AgentMessage"] = "agent_message";
|
|
20
|
+
HookEvent2["AgentThoughtChunk"] = "agent_thought_chunk";
|
|
21
|
+
HookEvent2["ToolCall"] = "tool_call";
|
|
22
|
+
HookEvent2["ToolCallUpdate"] = "tool_call_update";
|
|
23
|
+
HookEvent2["ToolCallContentChunk"] = "tool_call_content_chunk";
|
|
24
|
+
HookEvent2["Plan"] = "plan";
|
|
25
|
+
HookEvent2["PendingCreated"] = "pending.created";
|
|
26
|
+
HookEvent2["PendingResolved"] = "pending.resolved";
|
|
27
|
+
HookEvent2["StateUpdate"] = "state_update";
|
|
28
|
+
HookEvent2["SessionFailed"] = "session.failed";
|
|
29
|
+
HookEvent2["SessionClosed"] = "session.closed";
|
|
30
|
+
HookEvent2["CompactionUpdate"] = "compaction_update";
|
|
31
|
+
HookEvent2["UsageUpdate"] = "usage_update";
|
|
32
|
+
HookEvent2["AvailableCommandsUpdate"] = "available_commands_update";
|
|
33
|
+
HookEvent2["CurrentModeUpdate"] = "current_mode_update";
|
|
34
|
+
HookEvent2["ConfigOptionUpdate"] = "config_option_update";
|
|
35
|
+
HookEvent2["SessionInfoUpdate"] = "session_info_update";
|
|
36
|
+
HookEvent2["Notice"] = "notice";
|
|
37
|
+
return HookEvent2;
|
|
38
|
+
})(HookEvent || {});
|
|
39
|
+
var HOOK_WILDCARD = "*";
|
|
40
|
+
var CANONICAL_EVENTS = new Set(Object.values(HookEvent));
|
|
41
|
+
var HookEventKeyKind = /* @__PURE__ */ ((HookEventKeyKind2) => {
|
|
42
|
+
HookEventKeyKind2["Canonical"] = "canonical";
|
|
43
|
+
HookEventKeyKind2["Wildcard"] = "wildcard";
|
|
44
|
+
HookEventKeyKind2["Unknown"] = "unknown";
|
|
45
|
+
return HookEventKeyKind2;
|
|
46
|
+
})(HookEventKeyKind || {});
|
|
47
|
+
var normalizeHookKey = (key) => {
|
|
48
|
+
if (key === HOOK_WILDCARD)
|
|
49
|
+
return { key, kind: "wildcard" /* Wildcard */, events: [HOOK_WILDCARD] };
|
|
50
|
+
if (CANONICAL_EVENTS.has(key) || key.startsWith("_final/")) {
|
|
51
|
+
return { key, kind: "canonical" /* Canonical */, events: [key] };
|
|
52
|
+
}
|
|
53
|
+
return { key, kind: "unknown" /* Unknown */, events: [] };
|
|
54
|
+
};
|
|
55
|
+
var defineHook = (definition) => stamp({ ...definition }, "hook" /* Hook */);
|
|
56
|
+
var keyMatches = (key, event) => key === event.type && (CANONICAL_EVENTS.has(key) || key.startsWith("_final/"));
|
|
57
|
+
var hookEventsSchema = looseObject({ events: authoredRecordSchema });
|
|
58
|
+
var hookHandlersFor = (hook, event) => {
|
|
59
|
+
const parsed = hookEventsSchema.safeParse(hook);
|
|
60
|
+
if (!parsed.success) return [];
|
|
61
|
+
const typed = [];
|
|
62
|
+
let wildcard = null;
|
|
63
|
+
for (const [key, handler] of Object.entries(parsed.data.events)) {
|
|
64
|
+
if (!isCallable(handler)) continue;
|
|
65
|
+
const invoke = (dispatched, ctx) => handler(dispatched, ctx);
|
|
66
|
+
if (key === HOOK_WILDCARD) wildcard = invoke;
|
|
67
|
+
else if (keyMatches(key, event)) typed.push(invoke);
|
|
68
|
+
}
|
|
69
|
+
return wildcard == null ? typed : [...typed, wildcard];
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export {
|
|
73
|
+
HookEvent,
|
|
74
|
+
HOOK_WILDCARD,
|
|
75
|
+
HookEventKeyKind,
|
|
76
|
+
normalizeHookKey,
|
|
77
|
+
defineHook,
|
|
78
|
+
hookHandlersFor
|
|
79
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// src/authoring/context.ts
|
|
2
|
+
var TranscriptRole = /* @__PURE__ */ ((TranscriptRole2) => {
|
|
3
|
+
TranscriptRole2["User"] = "user";
|
|
4
|
+
TranscriptRole2["Assistant"] = "assistant";
|
|
5
|
+
TranscriptRole2["Tool"] = "tool";
|
|
6
|
+
TranscriptRole2["Thought"] = "thought";
|
|
7
|
+
TranscriptRole2["Summary"] = "summary";
|
|
8
|
+
return TranscriptRole2;
|
|
9
|
+
})(TranscriptRole || {});
|
|
10
|
+
|
|
11
|
+
export {
|
|
12
|
+
TranscriptRole
|
|
13
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {
|
|
2
|
+
array,
|
|
3
|
+
json,
|
|
4
|
+
nativeEnum,
|
|
5
|
+
object,
|
|
6
|
+
record,
|
|
7
|
+
string,
|
|
8
|
+
union,
|
|
9
|
+
unknown
|
|
10
|
+
} from "./chunk-HGW4YHAY.ts";
|
|
11
|
+
|
|
12
|
+
// ../agent-provider/src/dynamic.ts
|
|
13
|
+
var DynamicEvent = /* @__PURE__ */ ((DynamicEvent2) => {
|
|
14
|
+
DynamicEvent2["SessionStarted"] = "session.started";
|
|
15
|
+
DynamicEvent2["TurnStarted"] = "turn.started";
|
|
16
|
+
return DynamicEvent2;
|
|
17
|
+
})(DynamicEvent || {});
|
|
18
|
+
var dynamicSlotSchema = object({
|
|
19
|
+
$dynamic: object({
|
|
20
|
+
// Bundle export that implements the resolver ('instructions/org-context').
|
|
21
|
+
resolver: string().min(1),
|
|
22
|
+
events: array(nativeEnum(DynamicEvent)).min(1),
|
|
23
|
+
// Final additions so Build can render a slot without resolving it.
|
|
24
|
+
description: string().optional(),
|
|
25
|
+
preview: string().optional()
|
|
26
|
+
})
|
|
27
|
+
});
|
|
28
|
+
var isDynamicSlot = (value) => dynamicSlotSchema.safeParse(value).success;
|
|
29
|
+
var slotOf = (value) => {
|
|
30
|
+
const parsed = dynamicSlotSchema.safeParse(value);
|
|
31
|
+
return parsed.success ? parsed.data : null;
|
|
32
|
+
};
|
|
33
|
+
var listSchema = array(json());
|
|
34
|
+
var objectSchema = record(string(), json());
|
|
35
|
+
var looseListSchema = array(unknown());
|
|
36
|
+
var looseObjectSchema = record(string(), unknown());
|
|
37
|
+
var maybeDynamic = (schema) => union([dynamicSlotSchema, schema]);
|
|
38
|
+
var indexPath = (parent, index) => `${parent}[${index}]`;
|
|
39
|
+
var keyPath = (parent, key) => parent.length === 0 ? key : `${parent}.${key}`;
|
|
40
|
+
var findDynamicSlots = (value, path = "") => {
|
|
41
|
+
const slot = slotOf(value);
|
|
42
|
+
if (slot != null) return [{ path, slot }];
|
|
43
|
+
const list = looseListSchema.safeParse(value);
|
|
44
|
+
if (list.success) {
|
|
45
|
+
return list.data.flatMap((item, index) => findDynamicSlots(item, indexPath(path, index)));
|
|
46
|
+
}
|
|
47
|
+
const object2 = looseObjectSchema.safeParse(value);
|
|
48
|
+
if (object2.success) {
|
|
49
|
+
return Object.entries(object2.data).flatMap(
|
|
50
|
+
([key, item]) => findDynamicSlots(item, keyPath(path, key))
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
return [];
|
|
54
|
+
};
|
|
55
|
+
var containsDynamicSlot = (value) => findDynamicSlots(value).length > 0;
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
DynamicEvent,
|
|
59
|
+
dynamicSlotSchema,
|
|
60
|
+
isDynamicSlot,
|
|
61
|
+
maybeDynamic,
|
|
62
|
+
findDynamicSlots,
|
|
63
|
+
containsDynamicSlot
|
|
64
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
stamp
|
|
3
|
+
} from "./chunk-XHKPWT3G.ts";
|
|
4
|
+
|
|
5
|
+
// src/authoring/dynamic.ts
|
|
6
|
+
var defineDynamic = (definition) => {
|
|
7
|
+
const sentinel = {
|
|
8
|
+
kind: "final:dynamic",
|
|
9
|
+
events: definition.events
|
|
10
|
+
};
|
|
11
|
+
if (definition.description != null) sentinel.description = definition.description;
|
|
12
|
+
if (definition.preview != null) sentinel.preview = definition.preview;
|
|
13
|
+
if (definition.provider != null) sentinel.provider = definition.provider;
|
|
14
|
+
return stamp(sentinel, "dynamic" /* Dynamic */);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export {
|
|
18
|
+
defineDynamic
|
|
19
|
+
};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import {
|
|
2
|
+
resultMatchesSchema
|
|
3
|
+
} from "./chunk-GNR7XBPN.ts";
|
|
4
|
+
import {
|
|
5
|
+
stamp
|
|
6
|
+
} from "./chunk-XHKPWT3G.ts";
|
|
7
|
+
import {
|
|
8
|
+
callableSchema,
|
|
9
|
+
isObjectLike,
|
|
10
|
+
optionalValueSchema
|
|
11
|
+
} from "./chunk-JIPNTA56.ts";
|
|
12
|
+
import {
|
|
13
|
+
array,
|
|
14
|
+
boolean,
|
|
15
|
+
looseObject,
|
|
16
|
+
object,
|
|
17
|
+
string,
|
|
18
|
+
union
|
|
19
|
+
} from "./chunk-HGW4YHAY.ts";
|
|
20
|
+
|
|
21
|
+
// src/authoring/tools.ts
|
|
22
|
+
var toolLabelSchema = union([
|
|
23
|
+
string(),
|
|
24
|
+
object({
|
|
25
|
+
start: callableSchema,
|
|
26
|
+
delta: callableSchema.optional(),
|
|
27
|
+
complete: callableSchema.optional()
|
|
28
|
+
})
|
|
29
|
+
]);
|
|
30
|
+
var defineTool = (definition) => stamp({ ...definition }, "tool" /* Tool */);
|
|
31
|
+
var toolNames = /* @__PURE__ */ new WeakMap();
|
|
32
|
+
var registerToolName = (tool, name) => {
|
|
33
|
+
if (!isObjectLike(tool)) return;
|
|
34
|
+
toolNames.set(tool, [...toolNames.get(tool) ?? [], name]);
|
|
35
|
+
};
|
|
36
|
+
var nameMatches = (qualified, name) => qualified === name || qualified.endsWith(`/${name}`) || qualified.endsWith(`__${name}`);
|
|
37
|
+
var toolCallUpdateSchema = looseObject({
|
|
38
|
+
status: string().nullish(),
|
|
39
|
+
toolName: string(),
|
|
40
|
+
rawOutput: optionalValueSchema
|
|
41
|
+
});
|
|
42
|
+
var mcpResultSchema = looseObject({
|
|
43
|
+
isError: boolean().optional(),
|
|
44
|
+
structuredContent: optionalValueSchema,
|
|
45
|
+
content: array(looseObject({ type: string(), text: string().optional() })).optional()
|
|
46
|
+
});
|
|
47
|
+
var toolOutputOf = (rawOutput) => {
|
|
48
|
+
const result = mcpResultSchema.safeParse(rawOutput);
|
|
49
|
+
if (!result.success) return { output: rawOutput, failed: false };
|
|
50
|
+
if (result.data.isError === true) return { output: null, failed: true };
|
|
51
|
+
if (result.data.structuredContent != null)
|
|
52
|
+
return { output: result.data.structuredContent, failed: false };
|
|
53
|
+
const text = result.data.content?.find((block) => block.type === "text")?.text;
|
|
54
|
+
if (text == null) return { output: rawOutput, failed: false };
|
|
55
|
+
try {
|
|
56
|
+
const parsed = JSON.parse(text);
|
|
57
|
+
return { output: parsed, failed: false };
|
|
58
|
+
} catch {
|
|
59
|
+
return { output: text, failed: false };
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
var isToolOutput = (tool, value) => resultMatchesSchema(tool.outputSchema, value);
|
|
63
|
+
var toolResultFrom = (event, tool) => {
|
|
64
|
+
if (event.type !== "tool_call_update") return void 0;
|
|
65
|
+
const data = toolCallUpdateSchema.safeParse(event.data);
|
|
66
|
+
if (!data.success) return void 0;
|
|
67
|
+
if (data.data.status != null && data.data.status !== "completed") return void 0;
|
|
68
|
+
const qualified = data.data.toolName;
|
|
69
|
+
const names = isObjectLike(tool) ? toolNames.get(tool) ?? [] : [];
|
|
70
|
+
if (!names.some((name) => nameMatches(qualified, name))) return void 0;
|
|
71
|
+
const { output, failed } = toolOutputOf(data.data.rawOutput);
|
|
72
|
+
if (failed) return void 0;
|
|
73
|
+
return isToolOutput(tool, output) ? output : void 0;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export {
|
|
77
|
+
toolLabelSchema,
|
|
78
|
+
defineTool,
|
|
79
|
+
registerToolName,
|
|
80
|
+
toolResultFrom
|
|
81
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import {
|
|
2
|
+
stamp
|
|
3
|
+
} from "./chunk-XHKPWT3G.ts";
|
|
4
|
+
|
|
5
|
+
// src/authoring/instructions.ts
|
|
6
|
+
var defineInstructions = (definition) => stamp(
|
|
7
|
+
{
|
|
8
|
+
content: definition.content,
|
|
9
|
+
role: definition.role === "user" /* User */ ? "user" /* User */ : "system" /* System */
|
|
10
|
+
},
|
|
11
|
+
"instructions" /* Instructions */
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
defineInstructions
|
|
16
|
+
};
|