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