@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,40 @@
|
|
|
1
|
+
export declare enum DiagnosticSeverity {
|
|
2
|
+
Error = "error",
|
|
3
|
+
Warning = "warning",
|
|
4
|
+
Note = "note"
|
|
5
|
+
}
|
|
6
|
+
export declare enum DiagnosticCode {
|
|
7
|
+
Input = "input",
|
|
8
|
+
RejectedSlot = "rejected-slot",
|
|
9
|
+
Bundle = "bundle",
|
|
10
|
+
NodeBuiltin = "node-builtin",
|
|
11
|
+
Evaluation = "evaluation",
|
|
12
|
+
Module = "module",
|
|
13
|
+
Conflict = "conflict",
|
|
14
|
+
Instructions = "instructions",
|
|
15
|
+
Skills = "skills",
|
|
16
|
+
Schedule = "schedule",
|
|
17
|
+
Hook = "hook",
|
|
18
|
+
Channel = "channel",
|
|
19
|
+
Sandbox = "sandbox",
|
|
20
|
+
Harness = "harness",
|
|
21
|
+
BaseTools = "base-tools",
|
|
22
|
+
Connections = "connections",
|
|
23
|
+
Manifest = "manifest",
|
|
24
|
+
Compatibility = "compatibility",
|
|
25
|
+
Secrets = "secrets",
|
|
26
|
+
Dependencies = "dependencies"
|
|
27
|
+
}
|
|
28
|
+
export interface DiagnosticIface {
|
|
29
|
+
severity: DiagnosticSeverity;
|
|
30
|
+
code: DiagnosticCode;
|
|
31
|
+
message: string;
|
|
32
|
+
path: string | null;
|
|
33
|
+
}
|
|
34
|
+
export declare const diagnostic: (args: {
|
|
35
|
+
severity: DiagnosticSeverity;
|
|
36
|
+
code: DiagnosticCode;
|
|
37
|
+
message: string;
|
|
38
|
+
path?: string | null;
|
|
39
|
+
}) => DiagnosticIface;
|
|
40
|
+
export declare const hasErrors: (diagnostics: readonly DiagnosticIface[]) => boolean;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
var DiagnosticSeverity = /* @__PURE__ */ ((DiagnosticSeverity2) => {
|
|
2
|
+
DiagnosticSeverity2["Error"] = "error";
|
|
3
|
+
DiagnosticSeverity2["Warning"] = "warning";
|
|
4
|
+
DiagnosticSeverity2["Note"] = "note";
|
|
5
|
+
return DiagnosticSeverity2;
|
|
6
|
+
})(DiagnosticSeverity || {});
|
|
7
|
+
var DiagnosticCode = /* @__PURE__ */ ((DiagnosticCode2) => {
|
|
8
|
+
DiagnosticCode2["Input"] = "input";
|
|
9
|
+
DiagnosticCode2["RejectedSlot"] = "rejected-slot";
|
|
10
|
+
DiagnosticCode2["Bundle"] = "bundle";
|
|
11
|
+
DiagnosticCode2["NodeBuiltin"] = "node-builtin";
|
|
12
|
+
DiagnosticCode2["Evaluation"] = "evaluation";
|
|
13
|
+
DiagnosticCode2["Module"] = "module";
|
|
14
|
+
DiagnosticCode2["Conflict"] = "conflict";
|
|
15
|
+
DiagnosticCode2["Instructions"] = "instructions";
|
|
16
|
+
DiagnosticCode2["Skills"] = "skills";
|
|
17
|
+
DiagnosticCode2["Schedule"] = "schedule";
|
|
18
|
+
DiagnosticCode2["Hook"] = "hook";
|
|
19
|
+
DiagnosticCode2["Channel"] = "channel";
|
|
20
|
+
DiagnosticCode2["Sandbox"] = "sandbox";
|
|
21
|
+
DiagnosticCode2["Harness"] = "harness";
|
|
22
|
+
DiagnosticCode2["BaseTools"] = "base-tools";
|
|
23
|
+
DiagnosticCode2["Connections"] = "connections";
|
|
24
|
+
DiagnosticCode2["Manifest"] = "manifest";
|
|
25
|
+
DiagnosticCode2["Compatibility"] = "compatibility";
|
|
26
|
+
DiagnosticCode2["Secrets"] = "secrets";
|
|
27
|
+
DiagnosticCode2["Dependencies"] = "dependencies";
|
|
28
|
+
return DiagnosticCode2;
|
|
29
|
+
})(DiagnosticCode || {});
|
|
30
|
+
const diagnostic = (args) => ({ ...args, path: args.path ?? null });
|
|
31
|
+
const hasErrors = (diagnostics) => diagnostics.some((item) => item.severity === "error" /* Error */);
|
|
32
|
+
export {
|
|
33
|
+
DiagnosticCode,
|
|
34
|
+
DiagnosticSeverity,
|
|
35
|
+
diagnostic,
|
|
36
|
+
hasErrors
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=diagnostics.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/compiler/diagnostics.ts"],
|
|
4
|
+
"sourcesContent": ["export enum DiagnosticSeverity {\n Error = 'error',\n Warning = 'warning',\n Note = 'note',\n}\n\nexport enum DiagnosticCode {\n Input = 'input',\n RejectedSlot = 'rejected-slot',\n Bundle = 'bundle',\n NodeBuiltin = 'node-builtin',\n Evaluation = 'evaluation',\n Module = 'module',\n Conflict = 'conflict',\n Instructions = 'instructions',\n Skills = 'skills',\n Schedule = 'schedule',\n Hook = 'hook',\n Channel = 'channel',\n Sandbox = 'sandbox',\n Harness = 'harness',\n BaseTools = 'base-tools',\n Connections = 'connections',\n Manifest = 'manifest',\n Compatibility = 'compatibility',\n Secrets = 'secrets',\n Dependencies = 'dependencies',\n}\n\nexport interface DiagnosticIface {\n severity: DiagnosticSeverity;\n code: DiagnosticCode;\n message: string;\n // Directory-relative source file, when one is responsible.\n path: string | null;\n}\n\nexport const diagnostic = (args: {\n severity: DiagnosticSeverity;\n code: DiagnosticCode;\n message: string;\n path?: string | null;\n}): DiagnosticIface => ({ ...args, path: args.path ?? null });\n\nexport const hasErrors = (diagnostics: readonly DiagnosticIface[]): boolean =>\n diagnostics.some((item) => item.severity === DiagnosticSeverity.Error);\n"],
|
|
5
|
+
"mappings": "AAAO,IAAK,qBAAL,kBAAKA,wBAAL;AACL,EAAAA,oBAAA,WAAQ;AACR,EAAAA,oBAAA,aAAU;AACV,EAAAA,oBAAA,UAAO;AAHG,SAAAA;AAAA,GAAA;AAML,IAAK,iBAAL,kBAAKC,oBAAL;AACL,EAAAA,gBAAA,WAAQ;AACR,EAAAA,gBAAA,kBAAe;AACf,EAAAA,gBAAA,YAAS;AACT,EAAAA,gBAAA,iBAAc;AACd,EAAAA,gBAAA,gBAAa;AACb,EAAAA,gBAAA,YAAS;AACT,EAAAA,gBAAA,cAAW;AACX,EAAAA,gBAAA,kBAAe;AACf,EAAAA,gBAAA,YAAS;AACT,EAAAA,gBAAA,cAAW;AACX,EAAAA,gBAAA,UAAO;AACP,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,eAAY;AACZ,EAAAA,gBAAA,iBAAc;AACd,EAAAA,gBAAA,cAAW;AACX,EAAAA,gBAAA,mBAAgB;AAChB,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,kBAAe;AApBL,SAAAA;AAAA,GAAA;AA+BL,MAAM,aAAa,CAAC,UAKH,EAAE,GAAG,MAAM,MAAM,KAAK,QAAQ,KAAK;AAEpD,MAAM,YAAY,CAAC,gBACxB,YAAY,KAAK,CAAC,SAAS,KAAK,aAAa,mBAAwB;",
|
|
6
|
+
"names": ["DiagnosticSeverity", "DiagnosticCode"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type LayoutModuleIface } from "../runtime/layout.mjs";
|
|
2
|
+
export declare const stripModuleExtension: (path: string) => string;
|
|
3
|
+
export declare const isModulePath: (path: string) => boolean;
|
|
4
|
+
export declare enum InstructionSourceKind {
|
|
5
|
+
Markdown = "markdown",
|
|
6
|
+
Module = "module"
|
|
7
|
+
}
|
|
8
|
+
export interface InstructionSourceIface {
|
|
9
|
+
path: string;
|
|
10
|
+
kind: InstructionSourceKind;
|
|
11
|
+
}
|
|
12
|
+
export interface SkillDirectoryIface {
|
|
13
|
+
key: string;
|
|
14
|
+
directory: string;
|
|
15
|
+
files: string[];
|
|
16
|
+
}
|
|
17
|
+
export interface RejectedSlotIface {
|
|
18
|
+
path: string;
|
|
19
|
+
message: string;
|
|
20
|
+
}
|
|
21
|
+
export interface DiscoveryIface {
|
|
22
|
+
modules: LayoutModuleIface[];
|
|
23
|
+
instructions: InstructionSourceIface[];
|
|
24
|
+
skillDirectories: SkillDirectoryIface[];
|
|
25
|
+
skillMarkdown: {
|
|
26
|
+
key: string;
|
|
27
|
+
path: string;
|
|
28
|
+
}[];
|
|
29
|
+
scheduleMarkdown: {
|
|
30
|
+
key: string;
|
|
31
|
+
path: string;
|
|
32
|
+
}[];
|
|
33
|
+
rejected: RejectedSlotIface[];
|
|
34
|
+
unsupported: RejectedSlotIface[];
|
|
35
|
+
}
|
|
36
|
+
export declare const discover: (paths: readonly string[]) => DiscoveryIface;
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
import { SlotKind } from "../runtime/layout.mjs";
|
|
3
|
+
const MODULE_EXTENSION = /\.(ts|mts|js|mjs)$/;
|
|
4
|
+
const stripModuleExtension = (path) => path.replace(MODULE_EXTENSION, "");
|
|
5
|
+
const isModulePath = (path) => MODULE_EXTENSION.test(path) && !path.endsWith(".d.ts");
|
|
6
|
+
var InstructionSourceKind = /* @__PURE__ */ ((InstructionSourceKind2) => {
|
|
7
|
+
InstructionSourceKind2["Markdown"] = "markdown";
|
|
8
|
+
InstructionSourceKind2["Module"] = "module";
|
|
9
|
+
return InstructionSourceKind2;
|
|
10
|
+
})(InstructionSourceKind || {});
|
|
11
|
+
const REJECTED_SLOTS = {
|
|
12
|
+
subagents: "subagents/ is not supported yet: delegating to subagents needs a harness capability for nested sessions, which no harness implements",
|
|
13
|
+
extensions: "extensions/ is not supported: extensions have no counterpart; package shared code and import it",
|
|
14
|
+
memory: "memory/ is not supported yet: memory will be a harness capability (a `memory` field in its config schema) with an MCP-contributed store"
|
|
15
|
+
};
|
|
16
|
+
const UNSUPPORTED_ROOT_FILES = /* @__PURE__ */ new Map([
|
|
17
|
+
[
|
|
18
|
+
"instrumentation",
|
|
19
|
+
"instrumentation is not supported; the session service records the ACP log and telemetry"
|
|
20
|
+
]
|
|
21
|
+
]);
|
|
22
|
+
const top = (path) => path.split("/")[0] ?? path;
|
|
23
|
+
const byName = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
24
|
+
const discover = (paths) => {
|
|
25
|
+
const sorted = [...paths].sort(byName);
|
|
26
|
+
const modules = [];
|
|
27
|
+
const add = (path, slot, key, base) => {
|
|
28
|
+
modules.push({ base: base ?? stripModuleExtension(path), path, slot, key });
|
|
29
|
+
};
|
|
30
|
+
const rejected = [];
|
|
31
|
+
const modulePaths = /* @__PURE__ */ new Map();
|
|
32
|
+
for (const path of sorted.filter(isModulePath)) {
|
|
33
|
+
const base = stripModuleExtension(path);
|
|
34
|
+
const previous = modulePaths.get(base);
|
|
35
|
+
if (previous != null)
|
|
36
|
+
rejected.push({
|
|
37
|
+
path,
|
|
38
|
+
message: `duplicate module ${base}: ${previous} and ${path}; keep one`
|
|
39
|
+
});
|
|
40
|
+
modulePaths.set(base, path);
|
|
41
|
+
}
|
|
42
|
+
const unsupported = [];
|
|
43
|
+
for (const [slot, message] of Object.entries(REJECTED_SLOTS)) {
|
|
44
|
+
const found = sorted.find((path) => top(path) === slot || stripModuleExtension(path) === slot);
|
|
45
|
+
if (found != null) rejected.push({ path: found, message });
|
|
46
|
+
}
|
|
47
|
+
for (const path of sorted) {
|
|
48
|
+
const message = UNSUPPORTED_ROOT_FILES.get(stripModuleExtension(path));
|
|
49
|
+
if (message != null && !path.includes("/")) unsupported.push({ path, message });
|
|
50
|
+
}
|
|
51
|
+
const agent = sorted.find(
|
|
52
|
+
(path) => !path.includes("/") && stripModuleExtension(path) === "agent" && isModulePath(path)
|
|
53
|
+
);
|
|
54
|
+
if (agent != null) add(agent, SlotKind.Agent, "agent");
|
|
55
|
+
const sandboxFile = sorted.find(
|
|
56
|
+
(path) => !path.includes("/") && stripModuleExtension(path) === "sandbox" && isModulePath(path)
|
|
57
|
+
);
|
|
58
|
+
const sandboxDirectory = sorted.filter((path) => top(path) === "sandbox" && path.includes("/"));
|
|
59
|
+
const sandboxIndex = sandboxDirectory.find(
|
|
60
|
+
(path) => posix.dirname(path) === "sandbox" && stripModuleExtension(path) === "sandbox/index" && isModulePath(path)
|
|
61
|
+
);
|
|
62
|
+
if (sandboxFile != null && sandboxDirectory.length > 0) {
|
|
63
|
+
rejected.push({
|
|
64
|
+
path: "sandbox",
|
|
65
|
+
message: "sandbox.ts and a sandbox/ directory are both present; keep one"
|
|
66
|
+
});
|
|
67
|
+
} else if (sandboxDirectory.length > 0 && sandboxIndex == null) {
|
|
68
|
+
rejected.push({
|
|
69
|
+
path: "sandbox",
|
|
70
|
+
message: "sandbox/ needs an index.ts that exports the sandbox targets (the same module as sandbox.ts)"
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const sandbox = sandboxFile ?? sandboxIndex;
|
|
74
|
+
if (sandbox != null) add(sandbox, SlotKind.Sandbox, "sandbox", "sandbox");
|
|
75
|
+
const instructions = [];
|
|
76
|
+
const rootInstructions = sorted.filter(
|
|
77
|
+
(path) => !path.includes("/") && (path === "instructions.md" || stripModuleExtension(path) === "instructions")
|
|
78
|
+
);
|
|
79
|
+
for (const path of rootInstructions.sort(
|
|
80
|
+
(a, b) => a.endsWith(".md") ? -1 : b.endsWith(".md") ? 1 : 0
|
|
81
|
+
)) {
|
|
82
|
+
if (path.endsWith(".md")) instructions.push({ path, kind: "markdown" /* Markdown */ });
|
|
83
|
+
else if (isModulePath(path)) {
|
|
84
|
+
instructions.push({ path, kind: "module" /* Module */ });
|
|
85
|
+
add(path, SlotKind.Instructions, "instructions");
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
for (const path of sorted) {
|
|
89
|
+
if (posix.dirname(path) !== "instructions") continue;
|
|
90
|
+
if (path.endsWith(".md")) instructions.push({ path, kind: "markdown" /* Markdown */ });
|
|
91
|
+
else if (isModulePath(path)) {
|
|
92
|
+
instructions.push({ path, kind: "module" /* Module */ });
|
|
93
|
+
add(path, SlotKind.Instructions, stripModuleExtension(posix.basename(path)));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
const skillDirectories = [];
|
|
97
|
+
const skillMarkdown = [];
|
|
98
|
+
for (const path of sorted) {
|
|
99
|
+
if (top(path) !== "skills") continue;
|
|
100
|
+
const parent = posix.dirname(path);
|
|
101
|
+
if (parent === "skills") {
|
|
102
|
+
if (path.endsWith(".md")) skillMarkdown.push({ key: posix.basename(path, ".md"), path });
|
|
103
|
+
else if (isModulePath(path))
|
|
104
|
+
add(path, SlotKind.Skill, stripModuleExtension(posix.basename(path)));
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
if (posix.basename(path) !== "SKILL.md") continue;
|
|
108
|
+
if (skillDirectories.some((skill) => parent.startsWith(`${skill.directory}/`))) continue;
|
|
109
|
+
skillDirectories.push({
|
|
110
|
+
key: posix.relative("skills", parent).split("/").join("_"),
|
|
111
|
+
directory: parent,
|
|
112
|
+
files: sorted.filter((file) => file.startsWith(`${parent}/`))
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
for (const path of sorted) {
|
|
116
|
+
if (posix.dirname(path) === "tools" && isModulePath(path)) {
|
|
117
|
+
add(path, SlotKind.Tool, stripModuleExtension(posix.basename(path)));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
for (const path of sorted) {
|
|
121
|
+
if (posix.dirname(path) === "connections" && isModulePath(path)) {
|
|
122
|
+
add(path, SlotKind.Connection, stripModuleExtension(posix.basename(path)));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const scheduleMarkdown = [];
|
|
126
|
+
for (const path of sorted) {
|
|
127
|
+
if (posix.dirname(path) !== "schedules") continue;
|
|
128
|
+
if (path.endsWith(".md")) scheduleMarkdown.push({ key: posix.basename(path, ".md"), path });
|
|
129
|
+
else if (isModulePath(path))
|
|
130
|
+
add(path, SlotKind.Schedule, stripModuleExtension(posix.basename(path)));
|
|
131
|
+
}
|
|
132
|
+
for (const path of sorted) {
|
|
133
|
+
if (top(path) === "hooks" && path.includes("/") && isModulePath(path)) {
|
|
134
|
+
add(path, SlotKind.Hook, stripModuleExtension(posix.relative("hooks", path)));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
for (const path of sorted) {
|
|
138
|
+
if (posix.dirname(path) === "channels" && isModulePath(path)) {
|
|
139
|
+
add(path, SlotKind.Channel, stripModuleExtension(posix.basename(path)));
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return {
|
|
143
|
+
modules,
|
|
144
|
+
instructions,
|
|
145
|
+
skillDirectories,
|
|
146
|
+
skillMarkdown,
|
|
147
|
+
scheduleMarkdown,
|
|
148
|
+
rejected,
|
|
149
|
+
unsupported
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
export {
|
|
153
|
+
InstructionSourceKind,
|
|
154
|
+
discover,
|
|
155
|
+
isModulePath,
|
|
156
|
+
stripModuleExtension
|
|
157
|
+
};
|
|
158
|
+
//# sourceMappingURL=discovery.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/compiler/discovery.ts"],
|
|
4
|
+
"sourcesContent": ["import { posix } from 'node:path';\nimport { SlotKind, type LayoutModuleIface } from \"../runtime/layout.mjs\";\n\n// Agent directory layout: agent.ts; instructions.md, instructions.ts, then instructions/*\n// (sorted, non-recursive, .md and .ts, one fragment each); skills/*/SKILL.md\n// (+ sibling files), skills/<name>.md and skills/<name>.ts; tools/*.ts;\n// connections/*.ts; schedules/*.md and schedules/*.ts; hooks/** (recursive);\n// channels/*.ts; sandbox.ts or sandbox/index.ts. subagents/, extensions/ and\n// memory/ are rejected.\n\nconst MODULE_EXTENSION = /\\.(ts|mts|js|mjs)$/;\n\nexport const stripModuleExtension = (path: string): string => path.replace(MODULE_EXTENSION, '');\n\nexport const isModulePath = (path: string): boolean =>\n MODULE_EXTENSION.test(path) && !path.endsWith('.d.ts');\n\nexport enum InstructionSourceKind {\n Markdown = 'markdown',\n Module = 'module',\n}\n\nexport interface InstructionSourceIface {\n path: string;\n kind: InstructionSourceKind;\n}\n\nexport interface SkillDirectoryIface {\n key: string;\n directory: string;\n // Directory-relative paths of every file in the skill, SKILL.md included.\n files: string[];\n}\n\nexport interface RejectedSlotIface {\n path: string;\n message: string;\n}\n\nexport interface DiscoveryIface {\n modules: LayoutModuleIface[];\n instructions: InstructionSourceIface[];\n skillDirectories: SkillDirectoryIface[];\n // skills/<name>.md\n skillMarkdown: { key: string; path: string }[];\n scheduleMarkdown: { key: string; path: string }[];\n rejected: RejectedSlotIface[];\n unsupported: RejectedSlotIface[];\n}\n\nconst REJECTED_SLOTS = {\n subagents:\n 'subagents/ is not supported yet: delegating to subagents needs a harness capability for nested sessions, which no harness implements',\n extensions:\n 'extensions/ is not supported: extensions have no counterpart; package shared code and import it',\n memory:\n 'memory/ is not supported yet: memory will be a harness capability (a `memory` field in its config schema) with an MCP-contributed store',\n};\n\nconst UNSUPPORTED_ROOT_FILES = new Map([\n [\n 'instrumentation',\n 'instrumentation is not supported; the session service records the ACP log and telemetry',\n ],\n]);\n\nconst top = (path: string): string => path.split('/')[0] ?? path;\n\nconst byName = (a: string, b: string): number => (a < b ? -1 : a > b ? 1 : 0);\n\nexport const discover = (paths: readonly string[]): DiscoveryIface => {\n const sorted = [...paths].sort(byName);\n const modules: LayoutModuleIface[] = [];\n const add = (path: string, slot: SlotKind, key: string, base?: string): void => {\n modules.push({ base: base ?? stripModuleExtension(path), path, slot, key });\n };\n const rejected: RejectedSlotIface[] = [];\n const modulePaths = new Map<string, string>();\n for (const path of sorted.filter(isModulePath)) {\n const base = stripModuleExtension(path);\n const previous = modulePaths.get(base);\n if (previous != null)\n rejected.push({\n path,\n message: `duplicate module ${base}: ${previous} and ${path}; keep one`,\n });\n modulePaths.set(base, path);\n }\n const unsupported: RejectedSlotIface[] = [];\n for (const [slot, message] of Object.entries(REJECTED_SLOTS)) {\n const found = sorted.find((path) => top(path) === slot || stripModuleExtension(path) === slot);\n if (found != null) rejected.push({ path: found, message });\n }\n for (const path of sorted) {\n const message = UNSUPPORTED_ROOT_FILES.get(stripModuleExtension(path));\n if (message != null && !path.includes('/')) unsupported.push({ path, message });\n }\n\n const agent = sorted.find(\n (path) => !path.includes('/') && stripModuleExtension(path) === 'agent' && isModulePath(path),\n );\n if (agent != null) add(agent, SlotKind.Agent, 'agent');\n // sandbox.ts, or a sandbox/ directory whose index module is the same module\n // (its other files are helpers it imports). Exports keep the `sandbox` base.\n const sandboxFile = sorted.find(\n (path) => !path.includes('/') && stripModuleExtension(path) === 'sandbox' && isModulePath(path),\n );\n const sandboxDirectory = sorted.filter((path) => top(path) === 'sandbox' && path.includes('/'));\n const sandboxIndex = sandboxDirectory.find(\n (path) =>\n posix.dirname(path) === 'sandbox' &&\n stripModuleExtension(path) === 'sandbox/index' &&\n isModulePath(path),\n );\n if (sandboxFile != null && sandboxDirectory.length > 0) {\n rejected.push({\n path: 'sandbox',\n message: 'sandbox.ts and a sandbox/ directory are both present; keep one',\n });\n } else if (sandboxDirectory.length > 0 && sandboxIndex == null) {\n rejected.push({\n path: 'sandbox',\n message:\n 'sandbox/ needs an index.ts that exports the sandbox targets (the same module as sandbox.ts)',\n });\n }\n const sandbox = sandboxFile ?? sandboxIndex;\n if (sandbox != null) add(sandbox, SlotKind.Sandbox, 'sandbox', 'sandbox');\n\n const instructions: InstructionSourceIface[] = [];\n const rootInstructions = sorted.filter(\n (path) =>\n !path.includes('/') &&\n (path === 'instructions.md' || stripModuleExtension(path) === 'instructions'),\n );\n for (const path of rootInstructions.sort((a, b) =>\n a.endsWith('.md') ? -1 : b.endsWith('.md') ? 1 : 0,\n )) {\n if (path.endsWith('.md')) instructions.push({ path, kind: InstructionSourceKind.Markdown });\n else if (isModulePath(path)) {\n instructions.push({ path, kind: InstructionSourceKind.Module });\n add(path, SlotKind.Instructions, 'instructions');\n }\n }\n for (const path of sorted) {\n if (posix.dirname(path) !== 'instructions') continue;\n if (path.endsWith('.md')) instructions.push({ path, kind: InstructionSourceKind.Markdown });\n else if (isModulePath(path)) {\n instructions.push({ path, kind: InstructionSourceKind.Module });\n add(path, SlotKind.Instructions, stripModuleExtension(posix.basename(path)));\n }\n }\n\n const skillDirectories: SkillDirectoryIface[] = [];\n const skillMarkdown: { key: string; path: string }[] = [];\n for (const path of sorted) {\n if (top(path) !== 'skills') continue;\n const parent = posix.dirname(path);\n if (parent === 'skills') {\n if (path.endsWith('.md')) skillMarkdown.push({ key: posix.basename(path, '.md'), path });\n else if (isModulePath(path))\n add(path, SlotKind.Skill, stripModuleExtension(posix.basename(path)));\n continue;\n }\n if (posix.basename(path) !== 'SKILL.md') continue;\n // A nested SKILL.md inside another skill belongs to that skill.\n if (skillDirectories.some((skill) => parent.startsWith(`${skill.directory}/`))) continue;\n skillDirectories.push({\n key: posix.relative('skills', parent).split('/').join('_'),\n directory: parent,\n files: sorted.filter((file) => file.startsWith(`${parent}/`)),\n });\n }\n\n for (const path of sorted) {\n if (posix.dirname(path) === 'tools' && isModulePath(path)) {\n add(path, SlotKind.Tool, stripModuleExtension(posix.basename(path)));\n }\n }\n for (const path of sorted) {\n if (posix.dirname(path) === 'connections' && isModulePath(path)) {\n add(path, SlotKind.Connection, stripModuleExtension(posix.basename(path)));\n }\n }\n const scheduleMarkdown: { key: string; path: string }[] = [];\n for (const path of sorted) {\n if (posix.dirname(path) !== 'schedules') continue;\n if (path.endsWith('.md')) scheduleMarkdown.push({ key: posix.basename(path, '.md'), path });\n else if (isModulePath(path))\n add(path, SlotKind.Schedule, stripModuleExtension(posix.basename(path)));\n }\n for (const path of sorted) {\n if (top(path) === 'hooks' && path.includes('/') && isModulePath(path)) {\n add(path, SlotKind.Hook, stripModuleExtension(posix.relative('hooks', path)));\n }\n }\n for (const path of sorted) {\n if (posix.dirname(path) === 'channels' && isModulePath(path)) {\n add(path, SlotKind.Channel, stripModuleExtension(posix.basename(path)));\n }\n }\n return {\n modules,\n instructions,\n skillDirectories,\n skillMarkdown,\n scheduleMarkdown,\n rejected,\n unsupported,\n };\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,aAAa;AACtB,SAAS,gBAAwC;AASjD,MAAM,mBAAmB;AAElB,MAAM,uBAAuB,CAAC,SAAyB,KAAK,QAAQ,kBAAkB,EAAE;AAExF,MAAM,eAAe,CAAC,SAC3B,iBAAiB,KAAK,IAAI,KAAK,CAAC,KAAK,SAAS,OAAO;AAEhD,IAAK,wBAAL,kBAAKA,2BAAL;AACL,EAAAA,uBAAA,cAAW;AACX,EAAAA,uBAAA,YAAS;AAFC,SAAAA;AAAA,GAAA;AAiCZ,MAAM,iBAA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AA,EACF;AACF;",
|
|
6
|
+
"names": ["InstructionSourceKind"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type DescribedBundleIface } from "../runtime/described.mjs";
|
|
2
|
+
export type EvaluationResult = {
|
|
3
|
+
ok: true;
|
|
4
|
+
described: DescribedBundleIface;
|
|
5
|
+
} | {
|
|
6
|
+
ok: false;
|
|
7
|
+
message: string;
|
|
8
|
+
};
|
|
9
|
+
export interface EvaluateOptionsIface {
|
|
10
|
+
packageRoot?: string;
|
|
11
|
+
allowCodeGenerationForTests?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const evaluateBundle: (code: string, options?: EvaluateOptionsIface) => Promise<EvaluationResult>;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { transform } from "esbuild";
|
|
2
|
+
import { execFile, spawn } from "node:child_process";
|
|
3
|
+
import { realpath } from "node:fs/promises";
|
|
4
|
+
import { resolve } from "node:path";
|
|
5
|
+
import * as z from "zod";
|
|
6
|
+
import { describedBundleSchema } from "../runtime/described.mjs";
|
|
7
|
+
import { DEFAULT_packageRoot } from "./bundle.mjs";
|
|
8
|
+
const GLOBAL_NAME = "__finalAgentBundle";
|
|
9
|
+
const PROCESS_TIMEOUT_MS = 2e4;
|
|
10
|
+
const MEMORY_LIMIT_MB = 256;
|
|
11
|
+
const MAX_OUTPUT_BYTES = 32 * 1024 * 1024;
|
|
12
|
+
const PROCESS_MEMORY_LIMIT_KB = 512 * 1024;
|
|
13
|
+
const MAX_EVALUATIONS = 2;
|
|
14
|
+
const MAX_QUEUED_EVALUATIONS = 16;
|
|
15
|
+
const evaluationWaiters = [];
|
|
16
|
+
let activeEvaluations = 0;
|
|
17
|
+
const childReplySchema = z.discriminatedUnion("ok", [
|
|
18
|
+
z.object({ ok: z.literal(true), described: z.string() }),
|
|
19
|
+
z.object({ ok: z.literal(false), message: z.string() })
|
|
20
|
+
]);
|
|
21
|
+
const messageOf = (cause) => cause instanceof Error ? cause.message : String(cause);
|
|
22
|
+
const runChild = async (args) => {
|
|
23
|
+
const entry = await realpath(
|
|
24
|
+
resolve(
|
|
25
|
+
args.options.packageRoot ?? DEFAULT_packageRoot,
|
|
26
|
+
"src",
|
|
27
|
+
"compiler",
|
|
28
|
+
"evaluate-child.mjs"
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
const flags = [
|
|
32
|
+
"--permission",
|
|
33
|
+
`--allow-fs-read=${entry}`,
|
|
34
|
+
`--max-old-space-size=${MEMORY_LIMIT_MB}`,
|
|
35
|
+
// V8's JIT code range exceeds Linux's data limit before evaluation starts.
|
|
36
|
+
"--jitless",
|
|
37
|
+
"--no-warnings",
|
|
38
|
+
...args.options.allowCodeGenerationForTests === true ? [] : ["--disallow-code-generation-from-strings"]
|
|
39
|
+
];
|
|
40
|
+
return new Promise((done, reject) => {
|
|
41
|
+
const child = process.platform === "linux" ? spawn(
|
|
42
|
+
"/bin/sh",
|
|
43
|
+
[
|
|
44
|
+
"-c",
|
|
45
|
+
`ulimit -d ${PROCESS_MEMORY_LIMIT_KB} || exit 1; exec /usr/bin/env -i "$@"`,
|
|
46
|
+
"evaluate",
|
|
47
|
+
process.execPath,
|
|
48
|
+
...flags,
|
|
49
|
+
entry
|
|
50
|
+
],
|
|
51
|
+
{
|
|
52
|
+
env: {},
|
|
53
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
54
|
+
}
|
|
55
|
+
) : spawn(process.execPath, [...flags, entry], {
|
|
56
|
+
env: {},
|
|
57
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
58
|
+
});
|
|
59
|
+
const stdout = [];
|
|
60
|
+
const stderr = [];
|
|
61
|
+
let size = 0;
|
|
62
|
+
let timedOut = false;
|
|
63
|
+
let overflowed = false;
|
|
64
|
+
let memoryExceeded = false;
|
|
65
|
+
let checkingMemory = false;
|
|
66
|
+
const memoryTimer = process.platform === "linux" ? null : setInterval(() => {
|
|
67
|
+
if (checkingMemory || child.pid == null) return;
|
|
68
|
+
checkingMemory = true;
|
|
69
|
+
execFile(
|
|
70
|
+
"/bin/ps",
|
|
71
|
+
["-o", "rss=", "-p", String(child.pid)],
|
|
72
|
+
{ env: {}, timeout: 1e3 },
|
|
73
|
+
(error, stdout2) => {
|
|
74
|
+
checkingMemory = false;
|
|
75
|
+
if (error == null && Number(stdout2.trim()) > PROCESS_MEMORY_LIMIT_KB) {
|
|
76
|
+
memoryExceeded = true;
|
|
77
|
+
child.kill("SIGKILL");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
}, 50);
|
|
82
|
+
const timer = setTimeout(() => {
|
|
83
|
+
timedOut = true;
|
|
84
|
+
child.kill("SIGKILL");
|
|
85
|
+
}, PROCESS_TIMEOUT_MS);
|
|
86
|
+
child.stdout.on("data", (chunk) => {
|
|
87
|
+
size += chunk.length;
|
|
88
|
+
if (size > MAX_OUTPUT_BYTES) {
|
|
89
|
+
overflowed = true;
|
|
90
|
+
child.kill("SIGKILL");
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
stdout.push(chunk);
|
|
94
|
+
});
|
|
95
|
+
child.stderr.on("data", (chunk) => {
|
|
96
|
+
if (stderr.reduce((total, item) => total + item.length, 0) < 64 * 1024) stderr.push(chunk);
|
|
97
|
+
});
|
|
98
|
+
child.on("error", (cause) => {
|
|
99
|
+
clearTimeout(timer);
|
|
100
|
+
if (memoryTimer != null) clearInterval(memoryTimer);
|
|
101
|
+
reject(cause);
|
|
102
|
+
});
|
|
103
|
+
child.on("close", (exitCode) => {
|
|
104
|
+
clearTimeout(timer);
|
|
105
|
+
if (memoryTimer != null) clearInterval(memoryTimer);
|
|
106
|
+
done({
|
|
107
|
+
stdout: Buffer.concat(stdout).toString("utf8"),
|
|
108
|
+
stderr: Buffer.concat(stderr).toString("utf8"),
|
|
109
|
+
exitCode,
|
|
110
|
+
timedOut,
|
|
111
|
+
overflowed,
|
|
112
|
+
memoryExceeded
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
child.stdin.on("error", () => void 0);
|
|
116
|
+
child.stdin.end(args.script);
|
|
117
|
+
});
|
|
118
|
+
};
|
|
119
|
+
const lastLine = (text) => text.trim().split("\n").at(-1) ?? "";
|
|
120
|
+
const evaluate = async (code, options = {}) => {
|
|
121
|
+
let script;
|
|
122
|
+
try {
|
|
123
|
+
const converted = await transform(code, {
|
|
124
|
+
format: "iife",
|
|
125
|
+
globalName: GLOBAL_NAME,
|
|
126
|
+
loader: "js",
|
|
127
|
+
target: "es2024"
|
|
128
|
+
});
|
|
129
|
+
script = `${converted.code}
|
|
130
|
+
;${GLOBAL_NAME}.__describe();`;
|
|
131
|
+
} catch (cause) {
|
|
132
|
+
const text = messageOf(cause);
|
|
133
|
+
return {
|
|
134
|
+
ok: false,
|
|
135
|
+
message: /top-level await/i.test(text) ? "authored modules may not use top-level await" : `could not prepare the bundle for evaluation: ${text}`
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
let output;
|
|
139
|
+
try {
|
|
140
|
+
output = await runChild({ script, options });
|
|
141
|
+
} catch (cause) {
|
|
142
|
+
return { ok: false, message: `could not start the evaluation process: ${messageOf(cause)}` };
|
|
143
|
+
}
|
|
144
|
+
if (output.memoryExceeded)
|
|
145
|
+
return { ok: false, message: "evaluating the authored modules exceeded its memory limit" };
|
|
146
|
+
if (output.timedOut) return { ok: false, message: "evaluating the authored modules timed out" };
|
|
147
|
+
if (output.overflowed)
|
|
148
|
+
return { ok: false, message: "evaluating the authored modules produced too much output" };
|
|
149
|
+
let reply;
|
|
150
|
+
try {
|
|
151
|
+
reply = childReplySchema.safeParse(JSON.parse(lastLine(output.stdout)));
|
|
152
|
+
} catch {
|
|
153
|
+
reply = null;
|
|
154
|
+
}
|
|
155
|
+
if (reply == null || !reply.success) {
|
|
156
|
+
const detail = lastLine(output.stderr);
|
|
157
|
+
return {
|
|
158
|
+
ok: false,
|
|
159
|
+
message: `evaluating the authored modules failed (exit ${output.exitCode ?? "signal"})${detail.length > 0 ? `: ${detail}` : ""}`
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
if (!reply.data.ok) return { ok: false, message: reply.data.message };
|
|
163
|
+
let described;
|
|
164
|
+
try {
|
|
165
|
+
described = describedBundleSchema.safeParse(JSON.parse(reply.data.described));
|
|
166
|
+
} catch {
|
|
167
|
+
return { ok: false, message: "the bundle did not describe itself" };
|
|
168
|
+
}
|
|
169
|
+
if (!described.success) {
|
|
170
|
+
return {
|
|
171
|
+
ok: false,
|
|
172
|
+
message: `the bundle description is malformed: ${described.error.message}`
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
return { ok: true, described: described.data };
|
|
176
|
+
};
|
|
177
|
+
const evaluateBundle = async (code, options = {}) => {
|
|
178
|
+
if (activeEvaluations >= MAX_EVALUATIONS) {
|
|
179
|
+
if (evaluationWaiters.length >= MAX_QUEUED_EVALUATIONS)
|
|
180
|
+
return { ok: false, message: "the definition compiler is busy; retry shortly" };
|
|
181
|
+
await new Promise((resolve2) => evaluationWaiters.push(resolve2));
|
|
182
|
+
} else activeEvaluations += 1;
|
|
183
|
+
try {
|
|
184
|
+
return await evaluate(code, options);
|
|
185
|
+
} finally {
|
|
186
|
+
const next = evaluationWaiters.shift();
|
|
187
|
+
if (next == null) activeEvaluations -= 1;
|
|
188
|
+
else next();
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
export {
|
|
192
|
+
evaluateBundle
|
|
193
|
+
};
|
|
194
|
+
//# sourceMappingURL=evaluate.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../src/compiler/evaluate.ts"],
|
|
4
|
+
"sourcesContent": ["import { transform } from 'esbuild';\nimport { execFile, spawn } from 'node:child_process';\nimport { realpath } from 'node:fs/promises';\nimport { resolve } from 'node:path';\nimport * as z from 'zod';\nimport { describedBundleSchema, type DescribedBundleIface } from \"../runtime/described.mjs\";\nimport { DEFAULT_packageRoot } from \"./bundle.mjs\";\n\nconst GLOBAL_NAME = '__finalAgentBundle';\n// The child's own vm timeout is 10 s; this bounds startup and output too.\nconst PROCESS_TIMEOUT_MS = 20_000;\nconst MEMORY_LIMIT_MB = 256;\nconst MAX_OUTPUT_BYTES = 32 * 1024 * 1024;\nconst PROCESS_MEMORY_LIMIT_KB = 512 * 1024;\nconst MAX_EVALUATIONS = 2;\nconst MAX_QUEUED_EVALUATIONS = 16;\nconst evaluationWaiters: (() => void)[] = [];\nlet activeEvaluations = 0;\n\nexport type EvaluationResult =\n | { ok: true; described: DescribedBundleIface }\n | { ok: false; message: string };\n\nexport interface EvaluateOptionsIface {\n // Root of the installed @finalai/agent-definition package (holds\n // src/compiler/evaluate-child.mjs); defaults to this source tree.\n packageRoot?: string;\n // Tests only: lets code generation from strings through, so a test can\n // prove the process boundary holds even when the vm boundary does not.\n allowCodeGenerationForTests?: boolean;\n}\n\nconst childReplySchema = z.discriminatedUnion('ok', [\n z.object({ ok: z.literal(true), described: z.string() }),\n z.object({ ok: z.literal(false), message: z.string() }),\n]);\n\nconst messageOf = (cause: unknown): string =>\n cause instanceof Error ? cause.message : String(cause);\n\ninterface ChildOutputIface {\n stdout: string;\n stderr: string;\n exitCode: number | null;\n timedOut: boolean;\n overflowed: boolean;\n memoryExceeded: boolean;\n}\n\n// Authored top-level code runs in its own Node process: empty environment, the\n// permission model granting only a read of the child entry (no other\n// filesystem access, network, child processes, workers, addons, WASI or\n// inspector), no code generation from strings, a heap cap and a hard timeout.\nconst runChild = async (args: {\n script: string;\n options: EvaluateOptionsIface;\n}): Promise<ChildOutputIface> => {\n const entry = await realpath(\n resolve(\n args.options.packageRoot ?? DEFAULT_packageRoot,\n 'src',\n 'compiler',\n 'evaluate-child.mjs',\n ),\n );\n const flags = [\n '--permission',\n `--allow-fs-read=${entry}`,\n `--max-old-space-size=${MEMORY_LIMIT_MB}`,\n // V8's JIT code range exceeds Linux's data limit before evaluation starts.\n '--jitless',\n '--no-warnings',\n ...(args.options.allowCodeGenerationForTests === true\n ? []\n : ['--disallow-code-generation-from-strings']),\n ];\n return new Promise((done, reject) => {\n // Linux RLIMIT_DATA also bounds anonymous mmap-backed ArrayBuffers. A heap\n // limit alone does not. macOS has no enforceable data-segment limit; monitor\n // RSS there as well as bounding concurrency and elapsed time.\n const child =\n process.platform === 'linux'\n ? spawn(\n '/bin/sh',\n [\n '-c',\n `ulimit -d ${PROCESS_MEMORY_LIMIT_KB} || exit 1; exec /usr/bin/env -i \"$@\"`,\n 'evaluate',\n process.execPath,\n ...flags,\n entry,\n ],\n {\n env: {},\n stdio: ['pipe', 'pipe', 'pipe'],\n },\n )\n : spawn(process.execPath, [...flags, entry], {\n env: {},\n stdio: ['pipe', 'pipe', 'pipe'],\n });\n const stdout: Buffer[] = [];\n const stderr: Buffer[] = [];\n let size = 0;\n let timedOut = false;\n let overflowed = false;\n let memoryExceeded = false;\n let checkingMemory = false;\n const memoryTimer =\n process.platform === 'linux'\n ? null\n : setInterval(() => {\n if (checkingMemory || child.pid == null) return;\n checkingMemory = true;\n execFile(\n '/bin/ps',\n ['-o', 'rss=', '-p', String(child.pid)],\n { env: {}, timeout: 1000 },\n (error, stdout) => {\n checkingMemory = false;\n if (error == null && Number(stdout.trim()) > PROCESS_MEMORY_LIMIT_KB) {\n memoryExceeded = true;\n child.kill('SIGKILL');\n }\n },\n );\n }, 50);\n const timer = setTimeout(() => {\n timedOut = true;\n child.kill('SIGKILL');\n }, PROCESS_TIMEOUT_MS);\n child.stdout.on('data', (chunk: Buffer) => {\n size += chunk.length;\n if (size > MAX_OUTPUT_BYTES) {\n overflowed = true;\n child.kill('SIGKILL');\n return;\n }\n stdout.push(chunk);\n });\n child.stderr.on('data', (chunk: Buffer) => {\n if (stderr.reduce((total, item) => total + item.length, 0) < 64 * 1024) stderr.push(chunk);\n });\n child.on('error', (cause) => {\n clearTimeout(timer);\n if (memoryTimer != null) clearInterval(memoryTimer);\n reject(cause);\n });\n child.on('close', (exitCode) => {\n clearTimeout(timer);\n if (memoryTimer != null) clearInterval(memoryTimer);\n done({\n stdout: Buffer.concat(stdout).toString('utf8'),\n stderr: Buffer.concat(stderr).toString('utf8'),\n exitCode,\n timedOut,\n overflowed,\n memoryExceeded,\n });\n });\n child.stdin.on('error', () => undefined);\n child.stdin.end(args.script);\n });\n};\n\nconst lastLine = (text: string): string => text.trim().split('\\n').at(-1) ?? '';\n\nconst evaluate = async (\n code: string,\n options: EvaluateOptionsIface = {},\n): Promise<EvaluationResult> => {\n let script: string;\n try {\n const converted = await transform(code, {\n format: 'iife',\n globalName: GLOBAL_NAME,\n loader: 'js',\n target: 'es2024',\n });\n script = `${converted.code}\\n;${GLOBAL_NAME}.__describe();`;\n } catch (cause) {\n const text = messageOf(cause);\n return {\n ok: false,\n message: /top-level await/i.test(text)\n ? 'authored modules may not use top-level await'\n : `could not prepare the bundle for evaluation: ${text}`,\n };\n }\n let output: ChildOutputIface;\n try {\n output = await runChild({ script, options });\n } catch (cause) {\n return { ok: false, message: `could not start the evaluation process: ${messageOf(cause)}` };\n }\n if (output.memoryExceeded)\n return { ok: false, message: 'evaluating the authored modules exceeded its memory limit' };\n if (output.timedOut) return { ok: false, message: 'evaluating the authored modules timed out' };\n if (output.overflowed)\n return { ok: false, message: 'evaluating the authored modules produced too much output' };\n let reply;\n try {\n reply = childReplySchema.safeParse(JSON.parse(lastLine(output.stdout)));\n } catch {\n reply = null;\n }\n if (reply == null || !reply.success) {\n const detail = lastLine(output.stderr);\n return {\n ok: false,\n message: `evaluating the authored modules failed (exit ${output.exitCode ?? 'signal'})${detail.length > 0 ? `: ${detail}` : ''}`,\n };\n }\n if (!reply.data.ok) return { ok: false, message: reply.data.message };\n let described;\n try {\n described = describedBundleSchema.safeParse(JSON.parse(reply.data.described));\n } catch {\n return { ok: false, message: 'the bundle did not describe itself' };\n }\n if (!described.success) {\n return {\n ok: false,\n message: `the bundle description is malformed: ${described.error.message}`,\n };\n }\n return { ok: true, described: described.data };\n};\n\nexport const evaluateBundle = async (\n code: string,\n options: EvaluateOptionsIface = {},\n): Promise<EvaluationResult> => {\n if (activeEvaluations >= MAX_EVALUATIONS) {\n if (evaluationWaiters.length >= MAX_QUEUED_EVALUATIONS)\n return { ok: false, message: 'the definition compiler is busy; retry shortly' };\n await new Promise<void>((resolve) => evaluationWaiters.push(resolve));\n } else activeEvaluations += 1;\n try {\n return await evaluate(code, options);\n } finally {\n const next = evaluationWaiters.shift();\n if (next == null) activeEvaluations -= 1;\n else next();\n }\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAC1B,SAAS,UAAU,aAAa;AAChC,SAAS,gBAAgB;AACzB,SAAS,eAAe;AACxB,YAAY,OAAO;AACnB,SAAS,6BAAwD;AACjE,SAAS,2BAA2B;AAEpC,MAAM,cAAc;AAEpB,MAAM,qBAAqB;AAC3B,MAAM,kBAAkB;AACxB,MAAM,mBAAmB,KAAK,OAAO;AACrC,MAAM,0BAA0B,MAAM;AACtC,MAAM,kBAAkB;AACxB,MAAM,yBAAyB;AAC/B,MAAM,oBAAoC,CAAC;AAC3C,IAAI,oBAAoB;AAexB,MAAM,mBAAmB,EAAE,mBAAmB,MAAM;AAAA,EAClD,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,IAAI,GAAG,WAAW,EAAE,OAAO,EAAE,CAAC;AAAA,EACvD,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,KAAK,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC;AACxD,CAAC;AAED,MAAM,YAAY,CAAC,UACjB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAevD,MAAM,WAAW,OAAO,SAGS;AAC/B,QAAM,QAAQ,MAAM;AAAA,IAClB;AAAA,MACE,KAAK,QAAQ,eAAe;AAAA,MAC5B;AAAA,MACA;AAAA,MACA;AAAA,IACF;AAAA,EACF;AACA,QAAM,QAAQ;AAAA,IACZ;AAAA,IACA,mBAAmB,KAAK;AAAA,IACxB,wBAAwB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,IAC1E;AAAA,EACF;AACA,SAAO,EAAE,IAAI,MAAM,WAAW,UAAU,KAAK;AAC/C;AAEO,MAAM,iBAAiB,OAC5B,MACA,UAAgC,CAAC,MACH;AAC9B,MAAI,qBAAqB,iBAAiB;AACxC,QAAI,kBAAkB,UAAU;AAC9B,aAAO,EAAE,IAAI,OAAO,SAAS,iDAAiD;AAChF,UAAM,IAAI,QAAc,CAACC,aAAY,kBAAkB,KAAKA,QAAO,CAAC;AAAA,EACtE,MAAO,sBAAqB;AAC5B,MAAI;AACF,WAAO,MAAM,SAAS,MAAM,OAAO;AAAA,EACrC,UAAE;AACA,UAAM,OAAO,kBAAkB,MAAM;AACrC,QAAI,QAAQ,KAAM,sBAAqB;AAAA,QAClC,MAAK;AAAA,EACZ;AACF;",
|
|
6
|
+
"names": ["stdout", "resolve"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const MAX_FILES = 400;
|
|
2
|
+
export declare const MAX_DEPTH = 10;
|
|
3
|
+
export declare const MAX_FILE_BYTES = 512000;
|
|
4
|
+
export interface DirectoryFilesIface {
|
|
5
|
+
root: string;
|
|
6
|
+
files: Record<string, string>;
|
|
7
|
+
}
|
|
8
|
+
export declare const readAgentDirectory: (directory: string) => Promise<DirectoryFilesIface>;
|
|
9
|
+
export interface NormalizedFilesIface {
|
|
10
|
+
files: Record<string, string>;
|
|
11
|
+
problems: {
|
|
12
|
+
path: string;
|
|
13
|
+
message: string;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
export declare const normalizeFiles: (input: Record<string, string>, options?: {
|
|
17
|
+
enforceSizeLimits?: boolean;
|
|
18
|
+
}) => NormalizedFilesIface;
|
|
19
|
+
export declare const preparationFiles: (files: Record<string, string>) => Record<string, string>;
|