@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,471 @@
|
|
|
1
|
+
import * as z from "zod";
|
|
2
|
+
import {
|
|
3
|
+
AuthoredKind,
|
|
4
|
+
authoredKindOf,
|
|
5
|
+
pendingEntries,
|
|
6
|
+
pendingExportName
|
|
7
|
+
} from "../authoring/brand.mjs";
|
|
8
|
+
import {
|
|
9
|
+
AGENT_DYNAMIC_PREFIX,
|
|
10
|
+
COMBINED_MCP_SERVERS_EXPORT,
|
|
11
|
+
namedExportName,
|
|
12
|
+
SlotKind
|
|
13
|
+
} from "./layout.mjs";
|
|
14
|
+
import {
|
|
15
|
+
childPath,
|
|
16
|
+
dynamicEventsOf,
|
|
17
|
+
error,
|
|
18
|
+
isDynamicSentinel,
|
|
19
|
+
isEnvironmentLike,
|
|
20
|
+
isOpenRequestLike,
|
|
21
|
+
lowerConnection,
|
|
22
|
+
lowerEnvironment,
|
|
23
|
+
lowerInstructions,
|
|
24
|
+
lowerSkill,
|
|
25
|
+
lowerTool,
|
|
26
|
+
note,
|
|
27
|
+
sandboxProviderNameOf,
|
|
28
|
+
toJson
|
|
29
|
+
} from "./lower.mjs";
|
|
30
|
+
import {
|
|
31
|
+
entriesOf,
|
|
32
|
+
fieldOf,
|
|
33
|
+
isCallable,
|
|
34
|
+
isObjectLike,
|
|
35
|
+
isPlainObject,
|
|
36
|
+
isPromiseLike,
|
|
37
|
+
isString,
|
|
38
|
+
messageOf,
|
|
39
|
+
stringOrNull
|
|
40
|
+
} from "./values.mjs";
|
|
41
|
+
const describeDynamic = (value) => {
|
|
42
|
+
const provider = fieldOf(value, "provider");
|
|
43
|
+
let hint = null;
|
|
44
|
+
if (provider != null) {
|
|
45
|
+
const kind = fieldOf(provider, "kind");
|
|
46
|
+
const ref = fieldOf(provider, "providerRef");
|
|
47
|
+
const issues = [];
|
|
48
|
+
if ((kind === "package" || kind === "bundle") && provider != null) {
|
|
49
|
+
hint = { ref: toJson(provider, { path: "provider", issues }), name: null };
|
|
50
|
+
} else if (ref != null) {
|
|
51
|
+
hint = { ref: toJson(ref, { path: "provider", issues }), name: null };
|
|
52
|
+
} else {
|
|
53
|
+
hint = {
|
|
54
|
+
ref: null,
|
|
55
|
+
name: stringOrNull(fieldOf(provider, "name")) ?? stringOrNull(fieldOf(fieldOf(provider, "definition"), "name"))
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
type: "dynamic",
|
|
61
|
+
events: dynamicEventsOf(value),
|
|
62
|
+
description: stringOrNull(fieldOf(value, "description")),
|
|
63
|
+
preview: stringOrNull(fieldOf(value, "preview")),
|
|
64
|
+
provider: hint
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const collectAgentDynamics = (agent) => {
|
|
68
|
+
const found = [];
|
|
69
|
+
const walk = (value, path, depth) => {
|
|
70
|
+
if (depth > 32) return;
|
|
71
|
+
if (isDynamicSentinel(value)) {
|
|
72
|
+
found.push({ path, value });
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
value.forEach((item, index) => walk(item, childPath(path, index), depth + 1));
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (isPlainObject(value) || authoredKindOf(value) != null) {
|
|
80
|
+
for (const [key, item] of entriesOf(value)) walk(item, childPath(path, key), depth + 1);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
walk(fieldOf(fieldOf(agent, "harness"), "config"), "harness.config", 0);
|
|
84
|
+
return found;
|
|
85
|
+
};
|
|
86
|
+
const dynamicSlot = (value, path) => {
|
|
87
|
+
const described = describeDynamic(value);
|
|
88
|
+
const slot = { resolver: `${AGENT_DYNAMIC_PREFIX}${path}`, events: described.events };
|
|
89
|
+
if (described.description != null) slot["description"] = described.description;
|
|
90
|
+
if (described.preview != null) slot["preview"] = described.preview;
|
|
91
|
+
return { $dynamic: slot };
|
|
92
|
+
};
|
|
93
|
+
const isDefinedHarnessLike = (value) => isCallable(value) && isCallable(fieldOf(value, "describe")) && isCallable(fieldOf(value, "open"));
|
|
94
|
+
const KNOWN_AGENT_FIELDS = /* @__PURE__ */ new Set([
|
|
95
|
+
"name",
|
|
96
|
+
"description",
|
|
97
|
+
"avatarUrl",
|
|
98
|
+
"harness",
|
|
99
|
+
"tools",
|
|
100
|
+
"toolPolicy",
|
|
101
|
+
"secrets",
|
|
102
|
+
"channels"
|
|
103
|
+
]);
|
|
104
|
+
const HARNESS_CONFIG_FIELDS = /* @__PURE__ */ new Set([
|
|
105
|
+
"model",
|
|
106
|
+
"reasoning",
|
|
107
|
+
"credentials",
|
|
108
|
+
"permissions",
|
|
109
|
+
"permissionMode",
|
|
110
|
+
"instructions",
|
|
111
|
+
"skills",
|
|
112
|
+
"system",
|
|
113
|
+
"temperature",
|
|
114
|
+
"providerOptions",
|
|
115
|
+
"maxSteps",
|
|
116
|
+
"stopWhen"
|
|
117
|
+
]);
|
|
118
|
+
const unknownAgentField = (key) => {
|
|
119
|
+
if (HARNESS_CONFIG_FIELDS.has(key))
|
|
120
|
+
return `agent.ts field ${key} belongs in harness config (harness: serverlessPi({ ${key}: ... }))`;
|
|
121
|
+
if (key === "defaultTools")
|
|
122
|
+
return "agent.ts field defaultTools is not supported: base tools are declared with tools: baseTools({ ... }) and are off by default";
|
|
123
|
+
if (key === "subagents" || key === "memory") return `agent.ts field ${key} is not supported yet`;
|
|
124
|
+
return `agent.ts field ${key} is not an agent field (name, description, avatarUrl, harness, tools, toolPolicy, secrets, channels)`;
|
|
125
|
+
};
|
|
126
|
+
const describeHarness = (harness, ctx, issues) => {
|
|
127
|
+
if (harness == null) return null;
|
|
128
|
+
const ref = fieldOf(harness, "harness");
|
|
129
|
+
if (!isObjectLike(ref)) {
|
|
130
|
+
issues.push(error("agent.ts harness must be a harness binding, e.g. serverlessPi({ ... })"));
|
|
131
|
+
return null;
|
|
132
|
+
}
|
|
133
|
+
let refJson = toJson(ref, { path: "harness.harness", issues });
|
|
134
|
+
if (fieldOf(ref, "kind") === "bundle" && fieldOf(ref, "export") === "<pending>") {
|
|
135
|
+
const candidates = ctx.entries.flatMap(
|
|
136
|
+
(entry) => Object.entries(entry.namespace).filter(([, value]) => isDefinedHarnessLike(value)).map(([name]) => namedExportName(entry.layout.base, name))
|
|
137
|
+
);
|
|
138
|
+
if (candidates.length === 1 && candidates[0] != null)
|
|
139
|
+
refJson = { kind: "bundle", export: candidates[0] };
|
|
140
|
+
else
|
|
141
|
+
issues.push(
|
|
142
|
+
error(
|
|
143
|
+
"the custom harness must come from defineHarness in @finalai/agents, or be exported once"
|
|
144
|
+
)
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
const config = toJson(fieldOf(harness, "config") ?? {}, {
|
|
148
|
+
path: "harness.config",
|
|
149
|
+
issues,
|
|
150
|
+
visit: (value, path) => isDynamicSentinel(value) ? dynamicSlot(value, path) : void 0
|
|
151
|
+
});
|
|
152
|
+
return { harness: refJson, config };
|
|
153
|
+
};
|
|
154
|
+
const describeBaseTools = (tools, ctx, issues) => {
|
|
155
|
+
if (tools == null) return null;
|
|
156
|
+
if (authoredKindOf(tools) !== AuthoredKind.BaseTools) {
|
|
157
|
+
issues.push(error("agent.ts tools must be baseTools({ shell: target, files: target, ... })"));
|
|
158
|
+
return null;
|
|
159
|
+
}
|
|
160
|
+
const base = fieldOf(tools, "base");
|
|
161
|
+
const out = {};
|
|
162
|
+
const host = [];
|
|
163
|
+
if (!isPlainObject(base)) return { targets: out, host };
|
|
164
|
+
for (const [capability, target] of Object.entries(base)) {
|
|
165
|
+
if (target == null) continue;
|
|
166
|
+
if (authoredKindOf(target) === AuthoredKind.HarnessHost) {
|
|
167
|
+
host.push(capability);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
if (isString(target)) {
|
|
171
|
+
out[capability] = target;
|
|
172
|
+
continue;
|
|
173
|
+
}
|
|
174
|
+
const name = ctx.sandboxIdentity.get(target);
|
|
175
|
+
if (name == null) {
|
|
176
|
+
issues.push(
|
|
177
|
+
error(
|
|
178
|
+
`baseTools ${capability} is bound to a value that is not a sandbox target exported from sandbox.ts`
|
|
179
|
+
)
|
|
180
|
+
);
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
out[capability] = name;
|
|
184
|
+
}
|
|
185
|
+
return { targets: out, host };
|
|
186
|
+
};
|
|
187
|
+
const describeSecrets = (value, issues) => {
|
|
188
|
+
if (value == null) return null;
|
|
189
|
+
const parsed = z.array(z.string().min(1)).safeParse(value);
|
|
190
|
+
if (parsed.success) return parsed.data;
|
|
191
|
+
issues.push(error("agent.ts secrets must be a list of secret names"));
|
|
192
|
+
return null;
|
|
193
|
+
};
|
|
194
|
+
const describeAgent = (value, ctx, issues) => {
|
|
195
|
+
if (value == null) return null;
|
|
196
|
+
if (!isPlainObject(value)) {
|
|
197
|
+
issues.push(error("agent.ts must export defineAgent({ ... }) as its default export"));
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
200
|
+
for (const key of Object.keys(value)) {
|
|
201
|
+
if (!KNOWN_AGENT_FIELDS.has(key)) issues.push(error(unknownAgentField(key)));
|
|
202
|
+
}
|
|
203
|
+
const toolPolicyRaw = value["toolPolicy"];
|
|
204
|
+
let toolPolicy = null;
|
|
205
|
+
if (isPlainObject(toolPolicyRaw)) {
|
|
206
|
+
toolPolicy = {};
|
|
207
|
+
for (const [key, policy] of Object.entries(toolPolicyRaw)) {
|
|
208
|
+
if (policy === "allow" || policy === "ask") toolPolicy[key] = policy;
|
|
209
|
+
else issues.push(error(`agent.ts toolPolicy.${key} must be 'allow' or 'ask'`));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
const channelsRaw = value["channels"];
|
|
213
|
+
let channels = null;
|
|
214
|
+
if (Array.isArray(channelsRaw)) {
|
|
215
|
+
channels = channelsRaw.map((binding, index) => ({
|
|
216
|
+
key: stringOrNull(fieldOf(binding, "key")),
|
|
217
|
+
channel: toJson(fieldOf(binding, "channel") ?? null, {
|
|
218
|
+
path: `channels[${index}].channel`,
|
|
219
|
+
issues
|
|
220
|
+
}),
|
|
221
|
+
config: toJson(fieldOf(binding, "config") ?? {}, {
|
|
222
|
+
path: `channels[${index}].config`,
|
|
223
|
+
issues
|
|
224
|
+
})
|
|
225
|
+
}));
|
|
226
|
+
}
|
|
227
|
+
const baseToolsDescription = describeBaseTools(value["tools"], ctx, issues);
|
|
228
|
+
return {
|
|
229
|
+
type: "agent",
|
|
230
|
+
name: stringOrNull(value["name"]),
|
|
231
|
+
description: stringOrNull(value["description"]),
|
|
232
|
+
avatarUrl: stringOrNull(value["avatarUrl"]),
|
|
233
|
+
harness: describeHarness(value["harness"], ctx, issues),
|
|
234
|
+
tools: baseToolsDescription?.targets ?? null,
|
|
235
|
+
hostTools: baseToolsDescription?.host ?? null,
|
|
236
|
+
toolPolicy,
|
|
237
|
+
secrets: describeSecrets(value["secrets"], issues),
|
|
238
|
+
channels
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
const probeSelector = (selector, issues) => {
|
|
242
|
+
if (!isCallable(selector)) return null;
|
|
243
|
+
try {
|
|
244
|
+
const result = selector({
|
|
245
|
+
session: null,
|
|
246
|
+
secrets: { get: async () => null },
|
|
247
|
+
open: async () => {
|
|
248
|
+
throw new Error("sandboxes do not open while compiling");
|
|
249
|
+
}
|
|
250
|
+
});
|
|
251
|
+
if (isEnvironmentLike(result) || isOpenRequestLike(result)) return result;
|
|
252
|
+
if (isPromiseLike(result)) Promise.resolve(result).catch(() => void 0);
|
|
253
|
+
return null;
|
|
254
|
+
} catch (cause) {
|
|
255
|
+
issues.push(
|
|
256
|
+
error(
|
|
257
|
+
`sandbox.ts selector failed during compilation: ${String(cause)}; export its environment when it needs session context`
|
|
258
|
+
)
|
|
259
|
+
);
|
|
260
|
+
return null;
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
const describeSandbox = (namespace, issues) => {
|
|
264
|
+
const targets = {};
|
|
265
|
+
const providers = {};
|
|
266
|
+
const describeTarget = (value, exportName, path) => {
|
|
267
|
+
if (isDynamicSentinel(value))
|
|
268
|
+
return { exportName, environment: null, dynamic: describeDynamic(value) };
|
|
269
|
+
if (isEnvironmentLike(value) || isOpenRequestLike(value)) {
|
|
270
|
+
return { exportName, environment: lowerEnvironment(value, path, issues), dynamic: null };
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
};
|
|
274
|
+
for (const [name, value] of Object.entries(namespace)) {
|
|
275
|
+
if (name === "default") continue;
|
|
276
|
+
const exportName = namedExportName("sandbox", name);
|
|
277
|
+
const providerName = sandboxProviderNameOf(value);
|
|
278
|
+
if (providerName != null) {
|
|
279
|
+
providers[exportName] = providerName;
|
|
280
|
+
continue;
|
|
281
|
+
}
|
|
282
|
+
const target = describeTarget(value, exportName, `sandbox.ts ${name}`);
|
|
283
|
+
if (target != null) targets[name] = target;
|
|
284
|
+
}
|
|
285
|
+
const named = Object.keys(targets);
|
|
286
|
+
const fallback = describeTarget(namespace["default"], "sandbox", "sandbox.ts default export");
|
|
287
|
+
const selector = authoredKindOf(namespace["default"]) === AuthoredKind.SandboxSelector;
|
|
288
|
+
if (fallback != null) targets["default"] = fallback;
|
|
289
|
+
else if (namespace["default"] != null && !selector) {
|
|
290
|
+
issues.push(
|
|
291
|
+
error(
|
|
292
|
+
"sandbox.ts default export must be defineSandbox(selector), an environment, or defineDynamic(...)"
|
|
293
|
+
)
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
if (selector && named.length === 0 && fallback == null) {
|
|
297
|
+
const opened = probeSelector(namespace["default"], issues);
|
|
298
|
+
if (opened != null) {
|
|
299
|
+
targets["default"] = {
|
|
300
|
+
exportName: "sandbox",
|
|
301
|
+
environment: lowerEnvironment(opened, "sandbox.ts default export", issues),
|
|
302
|
+
dynamic: null
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
let defaultTarget = null;
|
|
307
|
+
if (targets["default"] != null) defaultTarget = "default";
|
|
308
|
+
else if (named.length === 1) defaultTarget = named[0] ?? null;
|
|
309
|
+
if (selector && defaultTarget == null) {
|
|
310
|
+
issues.push(
|
|
311
|
+
error(
|
|
312
|
+
named.length === 0 ? "sandbox.ts default export opens a sandbox but no environment is exported; export the environment it opens (export const computer = computer({ ... }))" : "sandbox.ts default export opens a sandbox but several environments are exported; the selector needs exactly one"
|
|
313
|
+
)
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
return { type: "sandbox", targets, providers, selector, defaultTarget };
|
|
317
|
+
};
|
|
318
|
+
const sandboxIdentityOf = (namespace, sandbox) => {
|
|
319
|
+
const identity = /* @__PURE__ */ new Map();
|
|
320
|
+
if (namespace == null || sandbox == null) return identity;
|
|
321
|
+
for (const [name, value] of Object.entries(namespace)) {
|
|
322
|
+
if (name === "default") {
|
|
323
|
+
if (sandbox.defaultTarget != null) identity.set(value, sandbox.defaultTarget);
|
|
324
|
+
} else if (sandbox.targets[name] != null) identity.set(value, name);
|
|
325
|
+
}
|
|
326
|
+
return identity;
|
|
327
|
+
};
|
|
328
|
+
const describeModuleValue = (entry, ctx, sandbox, issues) => {
|
|
329
|
+
const { layout, namespace } = entry;
|
|
330
|
+
const value = namespace["default"];
|
|
331
|
+
switch (layout.slot) {
|
|
332
|
+
case SlotKind.Agent:
|
|
333
|
+
return describeAgent(value, ctx, issues);
|
|
334
|
+
case SlotKind.Sandbox:
|
|
335
|
+
return sandbox;
|
|
336
|
+
case SlotKind.Instructions: {
|
|
337
|
+
if (isDynamicSentinel(value)) return describeDynamic(value);
|
|
338
|
+
const fragment = lowerInstructions(value, null);
|
|
339
|
+
if (fragment == null) {
|
|
340
|
+
issues.push(
|
|
341
|
+
error(
|
|
342
|
+
`${layout.path} must export defineInstructions({ content, role }) or defineDynamic(...)`
|
|
343
|
+
)
|
|
344
|
+
);
|
|
345
|
+
return null;
|
|
346
|
+
}
|
|
347
|
+
return { type: "instructions", role: fragment.role, content: fragment.content };
|
|
348
|
+
}
|
|
349
|
+
case SlotKind.Skill: {
|
|
350
|
+
if (isDynamicSentinel(value)) return describeDynamic(value);
|
|
351
|
+
const lowered = lowerSkill({ key: layout.key, value });
|
|
352
|
+
issues.push(...lowered.issues);
|
|
353
|
+
return { type: "skill", skill: toJson(lowered.skill, { path: layout.path, issues }) };
|
|
354
|
+
}
|
|
355
|
+
case SlotKind.Tool: {
|
|
356
|
+
if (isDynamicSentinel(value)) return describeDynamic(value);
|
|
357
|
+
const lowered = lowerTool({ name: layout.key, exportName: layout.base, value });
|
|
358
|
+
issues.push(...lowered.issues);
|
|
359
|
+
return {
|
|
360
|
+
type: "tool",
|
|
361
|
+
descriptor: toJson(lowered.descriptor, { path: layout.path, issues }),
|
|
362
|
+
approval: lowered.approval
|
|
363
|
+
};
|
|
364
|
+
}
|
|
365
|
+
case SlotKind.Connection: {
|
|
366
|
+
if (isDynamicSentinel(value)) return describeDynamic(value);
|
|
367
|
+
const lowered = lowerConnection({ key: layout.key, exportName: layout.base, value });
|
|
368
|
+
issues.push(...lowered.issues);
|
|
369
|
+
return {
|
|
370
|
+
type: "connection",
|
|
371
|
+
binding: toJson(lowered.binding, { path: layout.path, issues })
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
case SlotKind.Schedule:
|
|
375
|
+
return {
|
|
376
|
+
type: "schedule",
|
|
377
|
+
cron: stringOrNull(fieldOf(value, "cron")),
|
|
378
|
+
markdown: stringOrNull(fieldOf(value, "markdown")),
|
|
379
|
+
timezone: stringOrNull(fieldOf(value, "timezone")),
|
|
380
|
+
target: stringOrNull(fieldOf(value, "target"))
|
|
381
|
+
};
|
|
382
|
+
case SlotKind.Hook: {
|
|
383
|
+
const events = fieldOf(value, "events");
|
|
384
|
+
return {
|
|
385
|
+
type: "hook",
|
|
386
|
+
keys: entriesOf(events).map(([key]) => key)
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
case SlotKind.Channel: {
|
|
390
|
+
const routes = fieldOf(value, "routes");
|
|
391
|
+
return {
|
|
392
|
+
type: "channel",
|
|
393
|
+
disabled: fieldOf(value, "disabled") === true,
|
|
394
|
+
installed: toJson(fieldOf(value, "installed") ?? null, {
|
|
395
|
+
path: `${layout.path} installed`,
|
|
396
|
+
issues
|
|
397
|
+
}),
|
|
398
|
+
routes: Array.isArray(routes) ? routes.map((route) => ({
|
|
399
|
+
method: String(fieldOf(route, "method")),
|
|
400
|
+
path: String(fieldOf(route, "path"))
|
|
401
|
+
})) : [],
|
|
402
|
+
turnPolicy: stringOrNull(fieldOf(value, "turnPolicy")),
|
|
403
|
+
config: toJson(fieldOf(value, "config") ?? {}, { path: `${layout.path} config`, issues })
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
const describeBundle = (entries, synthesized) => {
|
|
409
|
+
const sandboxEntry = entries.find((entry) => entry.layout.slot === SlotKind.Sandbox) ?? null;
|
|
410
|
+
const sandboxIssues = [];
|
|
411
|
+
let sandbox = null;
|
|
412
|
+
if (sandboxEntry != null) {
|
|
413
|
+
try {
|
|
414
|
+
sandbox = describeSandbox(sandboxEntry.namespace, sandboxIssues);
|
|
415
|
+
} catch (cause) {
|
|
416
|
+
sandboxIssues.push(error(`sandbox.ts could not be described: ${messageOf(cause)}`));
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
const ctx = {
|
|
420
|
+
entries,
|
|
421
|
+
sandboxIdentity: sandboxIdentityOf(sandboxEntry?.namespace ?? null, sandbox)
|
|
422
|
+
};
|
|
423
|
+
const modules = entries.map((entry) => {
|
|
424
|
+
const issues = entry.layout.slot === SlotKind.Sandbox ? sandboxIssues : [];
|
|
425
|
+
const hasDefault = "default" in entry.namespace && entry.namespace["default"] !== void 0;
|
|
426
|
+
let value = null;
|
|
427
|
+
if (hasDefault || entry.layout.slot === SlotKind.Sandbox) {
|
|
428
|
+
try {
|
|
429
|
+
value = describeModuleValue(entry, ctx, sandbox, issues);
|
|
430
|
+
} catch (cause) {
|
|
431
|
+
issues.push(error(`${entry.layout.path} could not be described: ${messageOf(cause)}`));
|
|
432
|
+
}
|
|
433
|
+
} else if (entry.layout.slot !== SlotKind.Agent) {
|
|
434
|
+
issues.push(note(`${entry.layout.path} has no default export; treated as a helper module`));
|
|
435
|
+
}
|
|
436
|
+
return {
|
|
437
|
+
base: entry.layout.base,
|
|
438
|
+
path: entry.layout.path,
|
|
439
|
+
slot: entry.layout.slot,
|
|
440
|
+
key: entry.layout.key,
|
|
441
|
+
hasDefault,
|
|
442
|
+
issues,
|
|
443
|
+
value
|
|
444
|
+
};
|
|
445
|
+
});
|
|
446
|
+
return { modules, synthesized };
|
|
447
|
+
};
|
|
448
|
+
const synthesizedExports = (entries) => {
|
|
449
|
+
const out = [];
|
|
450
|
+
for (const entry of entries) {
|
|
451
|
+
if (entry.layout.slot !== SlotKind.Agent) continue;
|
|
452
|
+
for (const found of collectAgentDynamics(entry.namespace["default"])) {
|
|
453
|
+
out.push({ name: `${AGENT_DYNAMIC_PREFIX}${found.path}`, value: found.value });
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
for (const pending of pendingEntries())
|
|
457
|
+
out.push({ name: pendingExportName(pending.index), value: pending.value });
|
|
458
|
+
return out;
|
|
459
|
+
};
|
|
460
|
+
const needsCombinedMcpServers = (entries) => entries.some(
|
|
461
|
+
(entry) => (entry.layout.slot === SlotKind.Tool || entry.layout.slot === SlotKind.Connection) && isDynamicSentinel(entry.namespace["default"])
|
|
462
|
+
);
|
|
463
|
+
export {
|
|
464
|
+
COMBINED_MCP_SERVERS_EXPORT,
|
|
465
|
+
collectAgentDynamics,
|
|
466
|
+
describeBundle,
|
|
467
|
+
describeDynamic,
|
|
468
|
+
needsCombinedMcpServers,
|
|
469
|
+
synthesizedExports
|
|
470
|
+
};
|
|
471
|
+
//# sourceMappingURL=describe.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/runtime/describe.ts"],
|
|
4
|
+
"sourcesContent": ["import type { JsonObject, JsonValue } from '@finalai/agent-provider';\nimport * as z from 'zod';\nimport {\n AuthoredKind,\n authoredKindOf,\n pendingEntries,\n pendingExportName,\n} from \"../authoring/brand.mjs\";\nimport type {\n DescribedAgentIface,\n DescribedBundleIface,\n DescribedDynamicIface,\n DescribedModuleIface,\n DescribedSandboxIface,\n DescribedSandboxTargetIface,\n DescribedValue,\n} from \"./described.mjs\";\nimport {\n AGENT_DYNAMIC_PREFIX,\n COMBINED_MCP_SERVERS_EXPORT,\n namedExportName,\n SlotKind,\n type LayoutModuleIface,\n} from \"./layout.mjs\";\nimport {\n childPath,\n dynamicEventsOf,\n error,\n isDynamicSentinel,\n isEnvironmentLike,\n isOpenRequestLike,\n lowerConnection,\n lowerEnvironment,\n lowerInstructions,\n lowerSkill,\n lowerTool,\n note,\n sandboxProviderNameOf,\n toJson,\n type IssueIface,\n} from \"./lower.mjs\";\nimport {\n entriesOf,\n fieldOf,\n isCallable,\n isObjectLike,\n isPlainObject,\n isPromiseLike,\n isString,\n messageOf,\n stringOrNull,\n type AuthoredRecord,\n type AuthoredValue,\n} from \"./values.mjs\";\n\n// Static extraction, run inside the realm that evaluated the bundle. Reads\n// authored values; never calls tool bodies, resolvers or routes, and calls a\n// sandbox selector only to read the request a synchronous one returns.\n\nexport interface NamespaceEntryIface {\n layout: LayoutModuleIface;\n namespace: AuthoredRecord;\n}\n\nexport const describeDynamic = (value: AuthoredValue): DescribedDynamicIface => {\n const provider = fieldOf(value, 'provider');\n let hint: DescribedDynamicIface['provider'] = null;\n if (provider != null) {\n const kind = fieldOf(provider, 'kind');\n const ref = fieldOf(provider, 'providerRef');\n const issues: IssueIface[] = [];\n if ((kind === 'package' || kind === 'bundle') && provider != null) {\n hint = { ref: toJson(provider, { path: 'provider', issues }), name: null };\n } else if (ref != null) {\n hint = { ref: toJson(ref, { path: 'provider', issues }), name: null };\n } else {\n hint = {\n ref: null,\n name:\n stringOrNull(fieldOf(provider, 'name')) ??\n stringOrNull(fieldOf(fieldOf(provider, 'definition'), 'name')),\n };\n }\n }\n return {\n type: 'dynamic',\n events: dynamicEventsOf(value),\n description: stringOrNull(fieldOf(value, 'description')),\n preview: stringOrNull(fieldOf(value, 'preview')),\n provider: hint,\n };\n};\n\n// Dynamic sentinels inside agent.ts's harness config, addressed by their authored path. The bundle exports each as\n// `agent:<path>`.\nexport const collectAgentDynamics = (\n agent: AuthoredValue,\n): { path: string; value: AuthoredValue }[] => {\n const found: { path: string; value: AuthoredValue }[] = [];\n const walk = (value: AuthoredValue, path: string, depth: number): void => {\n if (depth > 32) return;\n if (isDynamicSentinel(value)) {\n found.push({ path, value });\n return;\n }\n if (Array.isArray(value)) {\n value.forEach((item, index) => walk(item, childPath(path, index), depth + 1));\n return;\n }\n if (isPlainObject(value) || authoredKindOf(value) != null) {\n for (const [key, item] of entriesOf(value)) walk(item, childPath(path, key), depth + 1);\n }\n };\n walk(fieldOf(fieldOf(agent, 'harness'), 'config'), 'harness.config', 0);\n return found;\n};\n\nconst dynamicSlot = (value: AuthoredValue, path: string): JsonValue => {\n const described = describeDynamic(value);\n const slot: JsonObject = { resolver: `${AGENT_DYNAMIC_PREFIX}${path}`, events: described.events };\n if (described.description != null) slot['description'] = described.description;\n if (described.preview != null) slot['preview'] = described.preview;\n return { $dynamic: slot };\n};\n\nconst isDefinedHarnessLike = (value: AuthoredValue): boolean =>\n isCallable(value) && isCallable(fieldOf(value, 'describe')) && isCallable(fieldOf(value, 'open'));\n\nconst KNOWN_AGENT_FIELDS: ReadonlySet<string> = new Set([\n 'name',\n 'description',\n 'avatarUrl',\n 'harness',\n 'tools',\n 'toolPolicy',\n 'secrets',\n 'channels',\n]);\n\n// Harness configuration belongs in the harness binding rather than top-level agent fields.\nconst HARNESS_CONFIG_FIELDS: ReadonlySet<string> = new Set([\n 'model',\n 'reasoning',\n 'credentials',\n 'permissions',\n 'permissionMode',\n 'instructions',\n 'skills',\n 'system',\n 'temperature',\n 'providerOptions',\n 'maxSteps',\n 'stopWhen',\n]);\n\nconst unknownAgentField = (key: string): string => {\n if (HARNESS_CONFIG_FIELDS.has(key))\n return `agent.ts field ${key} belongs in harness config (harness: serverlessPi({ ${key}: ... }))`;\n if (key === 'defaultTools')\n return 'agent.ts field defaultTools is not supported: base tools are declared with tools: baseTools({ ... }) and are off by default';\n if (key === 'subagents' || key === 'memory') return `agent.ts field ${key} is not supported yet`;\n return `agent.ts field ${key} is not an agent field (name, description, avatarUrl, harness, tools, toolPolicy, secrets, channels)`;\n};\n\ninterface DescribeContextIface {\n entries: NamespaceEntryIface[];\n sandboxIdentity: Map<AuthoredValue, string>;\n}\n\nconst describeHarness = (\n harness: AuthoredValue,\n ctx: DescribeContextIface,\n issues: IssueIface[],\n): DescribedAgentIface['harness'] => {\n if (harness == null) return null;\n const ref = fieldOf(harness, 'harness');\n if (!isObjectLike(ref)) {\n issues.push(error('agent.ts harness must be a harness binding, e.g. serverlessPi({ ... })'));\n return null;\n }\n let refJson = toJson(ref, { path: 'harness.harness', issues });\n if (fieldOf(ref, 'kind') === 'bundle' && fieldOf(ref, 'export') === '<pending>') {\n const candidates = ctx.entries.flatMap((entry) =>\n Object.entries(entry.namespace)\n .filter(([, value]) => isDefinedHarnessLike(value))\n .map(([name]) => namedExportName(entry.layout.base, name)),\n );\n if (candidates.length === 1 && candidates[0] != null)\n refJson = { kind: 'bundle', export: candidates[0] };\n else\n issues.push(\n error(\n 'the custom harness must come from defineHarness in @finalai/agents, or be exported once',\n ),\n );\n }\n const config = toJson(fieldOf(harness, 'config') ?? {}, {\n path: 'harness.config',\n issues,\n visit: (value, path) => (isDynamicSentinel(value) ? dynamicSlot(value, path) : undefined),\n });\n return { harness: refJson, config };\n};\n\n// Capabilities bound to sandbox targets (by export name) and those declared on\n// the harness's own host (`harnessHost`).\nconst describeBaseTools = (\n tools: AuthoredValue,\n ctx: DescribeContextIface,\n issues: IssueIface[],\n): { targets: Record<string, string>; host: string[] } | null => {\n if (tools == null) return null;\n if (authoredKindOf(tools) !== AuthoredKind.BaseTools) {\n issues.push(error('agent.ts tools must be baseTools({ shell: target, files: target, ... })'));\n return null;\n }\n const base = fieldOf(tools, 'base');\n const out: Record<string, string> = {};\n const host: string[] = [];\n if (!isPlainObject(base)) return { targets: out, host };\n for (const [capability, target] of Object.entries(base)) {\n if (target == null) continue;\n if (authoredKindOf(target) === AuthoredKind.HarnessHost) {\n host.push(capability);\n continue;\n }\n if (isString(target)) {\n out[capability] = target;\n continue;\n }\n const name = ctx.sandboxIdentity.get(target);\n if (name == null) {\n issues.push(\n error(\n `baseTools ${capability} is bound to a value that is not a sandbox target exported from sandbox.ts`,\n ),\n );\n continue;\n }\n out[capability] = name;\n }\n return { targets: out, host };\n};\n\nconst describeSecrets = (value: AuthoredValue, issues: IssueIface[]): string[] | null => {\n if (value == null) return null;\n const parsed = z.array(z.string().min(1)).safeParse(value);\n if (parsed.success) return parsed.data;\n issues.push(error('agent.ts secrets must be a list of secret names'));\n return null;\n};\n\nconst describeAgent = (\n value: AuthoredValue,\n ctx: DescribeContextIface,\n issues: IssueIface[],\n): DescribedAgentIface | null => {\n if (value == null) return null;\n if (!isPlainObject(value)) {\n issues.push(error('agent.ts must export defineAgent({ ... }) as its default export'));\n return null;\n }\n for (const key of Object.keys(value)) {\n if (!KNOWN_AGENT_FIELDS.has(key)) issues.push(error(unknownAgentField(key)));\n }\n const toolPolicyRaw = value['toolPolicy'];\n let toolPolicy: Record<string, string> | null = null;\n if (isPlainObject(toolPolicyRaw)) {\n toolPolicy = {};\n for (const [key, policy] of Object.entries(toolPolicyRaw)) {\n if (policy === 'allow' || policy === 'ask') toolPolicy[key] = policy;\n else issues.push(error(`agent.ts toolPolicy.${key} must be 'allow' or 'ask'`));\n }\n }\n const channelsRaw = value['channels'];\n let channels: DescribedAgentIface['channels'] = null;\n if (Array.isArray(channelsRaw)) {\n channels = channelsRaw.map((binding, index) => ({\n key: stringOrNull(fieldOf(binding, 'key')),\n channel: toJson(fieldOf(binding, 'channel') ?? null, {\n path: `channels[${index}].channel`,\n issues,\n }),\n config: toJson(fieldOf(binding, 'config') ?? {}, {\n path: `channels[${index}].config`,\n issues,\n }),\n }));\n }\n const baseToolsDescription = describeBaseTools(value['tools'], ctx, issues);\n return {\n type: 'agent',\n name: stringOrNull(value['name']),\n description: stringOrNull(value['description']),\n avatarUrl: stringOrNull(value['avatarUrl']),\n harness: describeHarness(value['harness'], ctx, issues),\n tools: baseToolsDescription?.targets ?? null,\n hostTools: baseToolsDescription?.host ?? null,\n toolPolicy,\n secrets: describeSecrets(value['secrets'], issues),\n channels,\n };\n};\n\nconst probeSelector = (selector: AuthoredValue, issues: IssueIface[]): AuthoredValue | null => {\n if (!isCallable(selector)) return null;\n try {\n const result = selector({\n session: null,\n secrets: { get: async () => null },\n open: async () => {\n throw new Error('sandboxes do not open while compiling');\n },\n });\n if (isEnvironmentLike(result) || isOpenRequestLike(result)) return result;\n // An async selector: what it opens is known only at session start.\n if (isPromiseLike(result)) Promise.resolve(result).catch(() => undefined);\n return null;\n } catch (cause) {\n issues.push(\n error(\n `sandbox.ts selector failed during compilation: ${String(cause)}; export its environment when it needs session context`,\n ),\n );\n return null;\n }\n};\n\nconst describeSandbox = (\n namespace: AuthoredRecord,\n issues: IssueIface[],\n): DescribedSandboxIface => {\n const targets: Record<string, DescribedSandboxTargetIface> = {};\n const providers: Record<string, string> = {};\n const describeTarget = (\n value: AuthoredValue,\n exportName: string,\n path: string,\n ): DescribedSandboxTargetIface | null => {\n if (isDynamicSentinel(value))\n return { exportName, environment: null, dynamic: describeDynamic(value) };\n if (isEnvironmentLike(value) || isOpenRequestLike(value)) {\n return { exportName, environment: lowerEnvironment(value, path, issues), dynamic: null };\n }\n return null;\n };\n for (const [name, value] of Object.entries(namespace)) {\n if (name === 'default') continue;\n const exportName = namedExportName('sandbox', name);\n const providerName = sandboxProviderNameOf(value);\n if (providerName != null) {\n providers[exportName] = providerName;\n continue;\n }\n const target = describeTarget(value, exportName, `sandbox.ts ${name}`);\n if (target != null) targets[name] = target;\n }\n const named = Object.keys(targets);\n const fallback = describeTarget(namespace['default'], 'sandbox', 'sandbox.ts default export');\n const selector = authoredKindOf(namespace['default']) === AuthoredKind.SandboxSelector;\n if (fallback != null) targets['default'] = fallback;\n else if (namespace['default'] != null && !selector) {\n issues.push(\n error(\n 'sandbox.ts default export must be defineSandbox(selector), an environment, or defineDynamic(...)',\n ),\n );\n }\n // A selector that opens an environment it creates itself\n // (`defineSandbox(() => computer().open())`) names no export\n // to bind; a synchronous one is called once to read the request it returns,\n // which becomes the default target.\n if (selector && named.length === 0 && fallback == null) {\n const opened = probeSelector(namespace['default'], issues);\n if (opened != null) {\n targets['default'] = {\n exportName: 'sandbox',\n environment: lowerEnvironment(opened, 'sandbox.ts default export', issues),\n dynamic: null,\n };\n }\n }\n let defaultTarget: string | null = null;\n if (targets['default'] != null) defaultTarget = 'default';\n else if (named.length === 1) defaultTarget = named[0] ?? null;\n if (selector && defaultTarget == null) {\n issues.push(\n error(\n named.length === 0\n ? 'sandbox.ts default export opens a sandbox but no environment is exported; export the environment it opens (export const computer = computer({ ... }))'\n : 'sandbox.ts default export opens a sandbox but several environments are exported; the selector needs exactly one',\n ),\n );\n }\n return { type: 'sandbox', targets, providers, selector, defaultTarget };\n};\n\nconst sandboxIdentityOf = (\n namespace: AuthoredRecord | null,\n sandbox: DescribedSandboxIface | null,\n): Map<AuthoredValue, string> => {\n const identity = new Map<AuthoredValue, string>();\n if (namespace == null || sandbox == null) return identity;\n for (const [name, value] of Object.entries(namespace)) {\n if (name === 'default') {\n if (sandbox.defaultTarget != null) identity.set(value, sandbox.defaultTarget);\n } else if (sandbox.targets[name] != null) identity.set(value, name);\n }\n return identity;\n};\n\nconst describeModuleValue = (\n entry: NamespaceEntryIface,\n ctx: DescribeContextIface,\n sandbox: DescribedSandboxIface | null,\n issues: IssueIface[],\n): DescribedValue | null => {\n const { layout, namespace } = entry;\n const value = namespace['default'];\n switch (layout.slot) {\n case SlotKind.Agent:\n return describeAgent(value, ctx, issues);\n case SlotKind.Sandbox:\n return sandbox;\n case SlotKind.Instructions: {\n if (isDynamicSentinel(value)) return describeDynamic(value);\n const fragment = lowerInstructions(value, null);\n if (fragment == null) {\n issues.push(\n error(\n `${layout.path} must export defineInstructions({ content, role }) or defineDynamic(...)`,\n ),\n );\n return null;\n }\n return { type: 'instructions', role: fragment.role, content: fragment.content };\n }\n case SlotKind.Skill: {\n if (isDynamicSentinel(value)) return describeDynamic(value);\n const lowered = lowerSkill({ key: layout.key, value });\n issues.push(...lowered.issues);\n return { type: 'skill', skill: toJson(lowered.skill, { path: layout.path, issues }) };\n }\n case SlotKind.Tool: {\n if (isDynamicSentinel(value)) return describeDynamic(value);\n const lowered = lowerTool({ name: layout.key, exportName: layout.base, value });\n issues.push(...lowered.issues);\n return {\n type: 'tool',\n descriptor: toJson(lowered.descriptor, { path: layout.path, issues }),\n approval: lowered.approval,\n };\n }\n case SlotKind.Connection: {\n if (isDynamicSentinel(value)) return describeDynamic(value);\n const lowered = lowerConnection({ key: layout.key, exportName: layout.base, value });\n issues.push(...lowered.issues);\n return {\n type: 'connection',\n binding: toJson(lowered.binding, { path: layout.path, issues }),\n };\n }\n case SlotKind.Schedule:\n return {\n type: 'schedule',\n cron: stringOrNull(fieldOf(value, 'cron')),\n markdown: stringOrNull(fieldOf(value, 'markdown')),\n timezone: stringOrNull(fieldOf(value, 'timezone')),\n target: stringOrNull(fieldOf(value, 'target')),\n };\n case SlotKind.Hook: {\n const events = fieldOf(value, 'events');\n return {\n type: 'hook',\n keys: entriesOf(events).map(([key]) => key),\n };\n }\n case SlotKind.Channel: {\n const routes = fieldOf(value, 'routes');\n return {\n type: 'channel',\n disabled: fieldOf(value, 'disabled') === true,\n installed: toJson(fieldOf(value, 'installed') ?? null, {\n path: `${layout.path} installed`,\n issues,\n }),\n routes: Array.isArray(routes)\n ? routes.map((route) => ({\n method: String(fieldOf(route, 'method')),\n path: String(fieldOf(route, 'path')),\n }))\n : [],\n turnPolicy: stringOrNull(fieldOf(value, 'turnPolicy')),\n config: toJson(fieldOf(value, 'config') ?? {}, { path: `${layout.path} config`, issues }),\n };\n }\n }\n};\n\nexport const describeBundle = (\n entries: NamespaceEntryIface[],\n synthesized: string[],\n): DescribedBundleIface => {\n const sandboxEntry = entries.find((entry) => entry.layout.slot === SlotKind.Sandbox) ?? null;\n const sandboxIssues: IssueIface[] = [];\n let sandbox: DescribedSandboxIface | null = null;\n if (sandboxEntry != null) {\n try {\n sandbox = describeSandbox(sandboxEntry.namespace, sandboxIssues);\n } catch (cause) {\n sandboxIssues.push(error(`sandbox.ts could not be described: ${messageOf(cause)}`));\n }\n }\n const ctx: DescribeContextIface = {\n entries,\n sandboxIdentity: sandboxIdentityOf(sandboxEntry?.namespace ?? null, sandbox),\n };\n const modules: DescribedModuleIface[] = entries.map((entry) => {\n const issues: IssueIface[] = entry.layout.slot === SlotKind.Sandbox ? sandboxIssues : [];\n const hasDefault = 'default' in entry.namespace && entry.namespace['default'] !== undefined;\n let value: DescribedValue | null = null;\n if (hasDefault || entry.layout.slot === SlotKind.Sandbox) {\n try {\n value = describeModuleValue(entry, ctx, sandbox, issues);\n } catch (cause) {\n issues.push(error(`${entry.layout.path} could not be described: ${messageOf(cause)}`));\n }\n } else if (entry.layout.slot !== SlotKind.Agent) {\n issues.push(note(`${entry.layout.path} has no default export; treated as a helper module`));\n }\n return {\n base: entry.layout.base,\n path: entry.layout.path,\n slot: entry.layout.slot,\n key: entry.layout.key,\n hasDefault,\n issues,\n value,\n };\n });\n return { modules, synthesized };\n};\n\n// Export names the bundle synthesizes, in the order describe and the isolate\n// both compute them.\nexport const synthesizedExports = (\n entries: NamespaceEntryIface[],\n): { name: string; value: AuthoredValue }[] => {\n const out: { name: string; value: AuthoredValue }[] = [];\n for (const entry of entries) {\n if (entry.layout.slot !== SlotKind.Agent) continue;\n for (const found of collectAgentDynamics(entry.namespace['default'])) {\n out.push({ name: `${AGENT_DYNAMIC_PREFIX}${found.path}`, value: found.value });\n }\n }\n for (const pending of pendingEntries())\n out.push({ name: pendingExportName(pending.index), value: pending.value });\n return out;\n};\n\nexport const needsCombinedMcpServers = (entries: NamespaceEntryIface[]): boolean =>\n entries.some(\n (entry) =>\n (entry.layout.slot === SlotKind.Tool || entry.layout.slot === SlotKind.Connection) &&\n isDynamicSentinel(entry.namespace['default']),\n );\n\nexport { COMBINED_MCP_SERVERS_EXPORT };\n"],
|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