@cef-ai/cli 0.2.7 → 0.3.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.
Files changed (127) hide show
  1. package/README.md +75 -1247
  2. package/dist/build/duration.d.ts +22 -0
  3. package/dist/build/duration.d.ts.map +1 -0
  4. package/dist/build/duration.js +44 -0
  5. package/dist/build/duration.js.map +1 -0
  6. package/dist/build/esbuild-plugin.d.ts +32 -0
  7. package/dist/build/esbuild-plugin.d.ts.map +1 -0
  8. package/dist/build/esbuild-plugin.js +53 -0
  9. package/dist/build/esbuild-plugin.js.map +1 -0
  10. package/dist/build/lints.d.ts +55 -0
  11. package/dist/build/lints.d.ts.map +1 -0
  12. package/dist/build/lints.js +214 -0
  13. package/dist/build/lints.js.map +1 -0
  14. package/dist/build/load-config.d.ts +114 -0
  15. package/dist/build/load-config.d.ts.map +1 -0
  16. package/dist/build/load-config.js +150 -0
  17. package/dist/build/load-config.js.map +1 -0
  18. package/dist/build/manifest.d.ts +156 -0
  19. package/dist/build/manifest.d.ts.map +1 -0
  20. package/dist/build/manifest.js +111 -0
  21. package/dist/build/manifest.js.map +1 -0
  22. package/dist/build/targeting.d.ts +15 -0
  23. package/dist/build/targeting.d.ts.map +1 -0
  24. package/dist/build/targeting.js +69 -0
  25. package/dist/build/targeting.js.map +1 -0
  26. package/dist/cli.d.ts +2 -2
  27. package/dist/cli.d.ts.map +1 -0
  28. package/dist/cli.js +107 -62
  29. package/dist/cli.js.map +1 -0
  30. package/dist/commands/build.d.ts +41 -0
  31. package/dist/commands/build.d.ts.map +1 -0
  32. package/dist/commands/build.js +252 -0
  33. package/dist/commands/build.js.map +1 -0
  34. package/dist/commands/inspect.d.ts +49 -0
  35. package/dist/commands/inspect.d.ts.map +1 -0
  36. package/dist/commands/inspect.js +135 -0
  37. package/dist/commands/inspect.js.map +1 -0
  38. package/dist/commands/typegen.d.ts +36 -0
  39. package/dist/commands/typegen.d.ts.map +1 -0
  40. package/dist/commands/typegen.js +210 -0
  41. package/dist/commands/typegen.js.map +1 -0
  42. package/dist/index.d.ts +6 -0
  43. package/dist/index.d.ts.map +1 -0
  44. package/dist/index.js +6 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/lib.d.ts +12 -0
  47. package/dist/lib.d.ts.map +1 -0
  48. package/dist/lib.js +9 -0
  49. package/dist/lib.js.map +1 -0
  50. package/dist/typegen/augment.d.ts +57 -0
  51. package/dist/typegen/augment.d.ts.map +1 -0
  52. package/dist/typegen/augment.js +87 -0
  53. package/dist/typegen/augment.js.map +1 -0
  54. package/dist/typegen/fetch.d.ts +30 -0
  55. package/dist/typegen/fetch.d.ts.map +1 -0
  56. package/dist/typegen/fetch.js +38 -0
  57. package/dist/typegen/fetch.js.map +1 -0
  58. package/dist/typegen/lockfile.d.ts +42 -0
  59. package/dist/typegen/lockfile.d.ts.map +1 -0
  60. package/dist/typegen/lockfile.js +58 -0
  61. package/dist/typegen/lockfile.js.map +1 -0
  62. package/dist/typegen/schema-to-ts.d.ts +21 -0
  63. package/dist/typegen/schema-to-ts.d.ts.map +1 -0
  64. package/dist/typegen/schema-to-ts.js +29 -0
  65. package/dist/typegen/schema-to-ts.js.map +1 -0
  66. package/package.json +20 -58
  67. package/dist/commands/auth/index.d.ts +0 -2
  68. package/dist/commands/auth/index.js +0 -162
  69. package/dist/commands/deploy/clone.d.ts +0 -13
  70. package/dist/commands/deploy/clone.js +0 -143
  71. package/dist/commands/deploy/delete.d.ts +0 -14
  72. package/dist/commands/deploy/delete.js +0 -134
  73. package/dist/commands/deploy/deploy.d.ts +0 -24
  74. package/dist/commands/deploy/deploy.js +0 -654
  75. package/dist/commands/deploy/index.d.ts +0 -2
  76. package/dist/commands/deploy/index.js +0 -216
  77. package/dist/commands/deploy/status.d.ts +0 -14
  78. package/dist/commands/deploy/status.js +0 -61
  79. package/dist/commands/dev/index.d.ts +0 -2
  80. package/dist/commands/dev/index.js +0 -134
  81. package/dist/commands/dev/server.d.ts +0 -14
  82. package/dist/commands/dev/server.js +0 -195
  83. package/dist/commands/dev/static/app.js +0 -633
  84. package/dist/commands/dev/static/index.html +0 -205
  85. package/dist/commands/dev/static/static/app.js +0 -633
  86. package/dist/commands/dev/static/static/index.html +0 -205
  87. package/dist/commands/dev/static/static/style.css +0 -184
  88. package/dist/commands/dev/static/style.css +0 -184
  89. package/dist/commands/playground/index.d.ts +0 -2
  90. package/dist/commands/playground/index.js +0 -75
  91. package/dist/commands/playground/test.d.ts +0 -15
  92. package/dist/commands/playground/test.js +0 -166
  93. package/dist/commands/service/index.d.ts +0 -2
  94. package/dist/commands/service/index.js +0 -89
  95. package/dist/lib/api.d.ts +0 -146
  96. package/dist/lib/api.js +0 -330
  97. package/dist/lib/config.d.ts +0 -12
  98. package/dist/lib/config.js +0 -145
  99. package/dist/lib/credentials.d.ts +0 -19
  100. package/dist/lib/credentials.js +0 -68
  101. package/dist/lib/runtime/agent-router.d.ts +0 -12
  102. package/dist/lib/runtime/agent-router.js +0 -67
  103. package/dist/lib/runtime/context-builder.d.ts +0 -27
  104. package/dist/lib/runtime/context-builder.js +0 -166
  105. package/dist/lib/runtime/cubby-manager.d.ts +0 -20
  106. package/dist/lib/runtime/cubby-manager.js +0 -162
  107. package/dist/lib/runtime/index.d.ts +0 -51
  108. package/dist/lib/runtime/index.js +0 -181
  109. package/dist/lib/runtime/log-collector.d.ts +0 -17
  110. package/dist/lib/runtime/log-collector.js +0 -61
  111. package/dist/lib/runtime/stream-manager.d.ts +0 -10
  112. package/dist/lib/runtime/stream-manager.js +0 -77
  113. package/dist/lib/runtime/types.d.ts +0 -76
  114. package/dist/lib/runtime/types.js +0 -2
  115. package/dist/lib/transpile.d.ts +0 -1
  116. package/dist/lib/transpile.js +0 -9
  117. package/dist/lib/typecheck.d.ts +0 -31
  118. package/dist/lib/typecheck.js +0 -175
  119. package/dist/lib/types.d.ts +0 -246
  120. package/dist/lib/types.js +0 -2
  121. package/dist/lib/utils.d.ts +0 -4
  122. package/dist/lib/utils.js +0 -33
  123. package/example/.env.example +0 -6
  124. package/example/agents/object-detection/tasks/yolo.ts +0 -28
  125. package/example/agents/parking-violation-detector/tasks/detect.ts +0 -326
  126. package/example/cef.config.yaml +0 -91
  127. package/example/engagements/engagement.ts +0 -902
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Tiny duration parser for author-facing config strings like `"15m"`,
3
+ * `"30s"`, `"1h"`, `"500ms"`, `"2d"`. Used by `cef build` to convert the
4
+ * `idleTimeout` field declared in `cef.config.ts` into the integer
5
+ * milliseconds the manifest carries.
6
+ *
7
+ * Grammar (case-sensitive, whitespace between number and unit ignored):
8
+ *
9
+ * <duration> ::= <integer | decimal> [<whitespace>] <unit>
10
+ * <unit> ::= "ms" | "s" | "m" | "h" | "d"
11
+ *
12
+ * Numbers may be integer or decimal (`"1.5h"` → 5_400_000 ms). The
13
+ * resulting milliseconds value is rounded down to an integer (the
14
+ * orchestrator's `IdleTimeout` is `int64`).
15
+ */
16
+ /**
17
+ * Parse a duration string into integer milliseconds. Throws with a
18
+ * `[@cef-ai/cli]`-prefixed message on malformed input so authors get a
19
+ * pointer back at their config.
20
+ */
21
+ export declare function parseDuration(input: string, fieldPath: string): number;
22
+ //# sourceMappingURL=duration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.d.ts","sourceRoot":"","sources":["../../src/build/duration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAYH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAoBtE"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Tiny duration parser for author-facing config strings like `"15m"`,
3
+ * `"30s"`, `"1h"`, `"500ms"`, `"2d"`. Used by `cef build` to convert the
4
+ * `idleTimeout` field declared in `cef.config.ts` into the integer
5
+ * milliseconds the manifest carries.
6
+ *
7
+ * Grammar (case-sensitive, whitespace between number and unit ignored):
8
+ *
9
+ * <duration> ::= <integer | decimal> [<whitespace>] <unit>
10
+ * <unit> ::= "ms" | "s" | "m" | "h" | "d"
11
+ *
12
+ * Numbers may be integer or decimal (`"1.5h"` → 5_400_000 ms). The
13
+ * resulting milliseconds value is rounded down to an integer (the
14
+ * orchestrator's `IdleTimeout` is `int64`).
15
+ */
16
+ const UNIT_MS = {
17
+ ms: 1,
18
+ s: 1_000,
19
+ m: 60 * 1_000,
20
+ h: 60 * 60 * 1_000,
21
+ d: 24 * 60 * 60 * 1_000,
22
+ };
23
+ const DURATION_RE = /^(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)$/;
24
+ /**
25
+ * Parse a duration string into integer milliseconds. Throws with a
26
+ * `[@cef-ai/cli]`-prefixed message on malformed input so authors get a
27
+ * pointer back at their config.
28
+ */
29
+ export function parseDuration(input, fieldPath) {
30
+ if (typeof input !== "string") {
31
+ throw new Error(`[@cef-ai/cli] ${fieldPath} must be a duration string (e.g. "15m"), got ${typeof input}`);
32
+ }
33
+ const match = DURATION_RE.exec(input.trim());
34
+ if (!match) {
35
+ throw new Error(`[@cef-ai/cli] ${fieldPath} "${input}" is not a valid duration. Expected "<number><unit>" where unit is one of: ms, s, m, h, d (e.g. "15m", "30s", "500ms", "1.5h").`);
36
+ }
37
+ const value = Number.parseFloat(match[1]);
38
+ const unit = match[2];
39
+ if (!Number.isFinite(value) || value < 0) {
40
+ throw new Error(`[@cef-ai/cli] ${fieldPath} "${input}" must be a non-negative duration`);
41
+ }
42
+ return Math.floor(value * UNIT_MS[unit]);
43
+ }
44
+ //# sourceMappingURL=duration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"duration.js","sourceRoot":"","sources":["../../src/build/duration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,OAAO,GAA2B;IACtC,EAAE,EAAE,CAAC;IACL,CAAC,EAAE,KAAK;IACR,CAAC,EAAE,EAAE,GAAG,KAAK;IACb,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,KAAK;IAClB,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK;CACxB,CAAC;AAEF,MAAM,WAAW,GAAG,kCAAkC,CAAC;AAEvD;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,SAAiB;IAC5D,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,iBAAiB,SAAS,gDAAgD,OAAO,KAAK,EAAE,CACzF,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IAC7C,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACb,iBAAiB,SAAS,KAAK,KAAK,iIAAiI,CACtK,CAAC;IACJ,CAAC;IACD,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;IACvB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CACb,iBAAiB,SAAS,KAAK,KAAK,mCAAmC,CACxE,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,OAAO,CAAC,IAAI,CAAE,CAAC,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * IIFE footer appended to every agent bundle.
3
+ *
4
+ * Contract (`sdk-runtime-integration-contract.md` §1, ADR-019 H2): the bundle
5
+ * exposes one INSTANCE PER ENGAGEMENT via
6
+ * `globalThis.__cefAgent = { engagements: { [engagementId]: instance } }`.
7
+ * Routing (which method handles which event, per-engagement) lives in the
8
+ * manifest the orchestrator reads.
9
+ *
10
+ * The build pipeline (`bundleAgent` in `commands/build.ts`) emits a temp
11
+ * wrapper module that re-exports each engagement's class as
12
+ * `export const engagements = { [id]: Class, ... }`. esbuild bundles that
13
+ * wrapper as an IIFE with `globalName: "__cefBundle"`, which makes
14
+ * `globalThis.__cefBundle.engagements` reachable here. We instantiate every
15
+ * class and assemble the public `__cefAgent` shape, then delete the
16
+ * intermediate `__cefBundle` global so the runtime sandbox sees a clean
17
+ * surface with only `__cefAgent` set.
18
+ *
19
+ * The footer does NOT assert per-class decorator presence — that check moved
20
+ * to build-time (`bundleAgent`), where the error message can name the
21
+ * specific engagement id. The footer only fails when the wrapper export is
22
+ * structurally missing, which is a build-pipeline bug rather than a user
23
+ * error.
24
+ */
25
+ export declare const IIFE_FOOTER: string;
26
+ /**
27
+ * Global name esbuild uses to expose the bundled module's exports. Kept in
28
+ * sync with {@link IIFE_FOOTER} above so callers can wire both pieces from
29
+ * a single source of truth.
30
+ */
31
+ export declare const ESBUILD_GLOBAL_NAME = "__cefBundle";
32
+ //# sourceMappingURL=esbuild-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esbuild-plugin.d.ts","sourceRoot":"","sources":["../../src/build/esbuild-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,WAAW,QAqBhB,CAAC;AAET;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,gBAAgB,CAAC"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * IIFE footer appended to every agent bundle.
3
+ *
4
+ * Contract (`sdk-runtime-integration-contract.md` §1, ADR-019 H2): the bundle
5
+ * exposes one INSTANCE PER ENGAGEMENT via
6
+ * `globalThis.__cefAgent = { engagements: { [engagementId]: instance } }`.
7
+ * Routing (which method handles which event, per-engagement) lives in the
8
+ * manifest the orchestrator reads.
9
+ *
10
+ * The build pipeline (`bundleAgent` in `commands/build.ts`) emits a temp
11
+ * wrapper module that re-exports each engagement's class as
12
+ * `export const engagements = { [id]: Class, ... }`. esbuild bundles that
13
+ * wrapper as an IIFE with `globalName: "__cefBundle"`, which makes
14
+ * `globalThis.__cefBundle.engagements` reachable here. We instantiate every
15
+ * class and assemble the public `__cefAgent` shape, then delete the
16
+ * intermediate `__cefBundle` global so the runtime sandbox sees a clean
17
+ * surface with only `__cefAgent` set.
18
+ *
19
+ * The footer does NOT assert per-class decorator presence — that check moved
20
+ * to build-time (`bundleAgent`), where the error message can name the
21
+ * specific engagement id. The footer only fails when the wrapper export is
22
+ * structurally missing, which is a build-pipeline bug rather than a user
23
+ * error.
24
+ */
25
+ export const IIFE_FOOTER = `
26
+ ;(function () {
27
+ var classes = (typeof globalThis.__cefBundle !== "undefined" && globalThis.__cefBundle.engagements)
28
+ ? globalThis.__cefBundle.engagements
29
+ : null;
30
+ if (!classes) {
31
+ throw new Error("@cef-ai/agent-sdk: bundle has no engagements (export const engagements missing from wrapper)");
32
+ }
33
+ var instances = {};
34
+ var ids = Object.keys(classes);
35
+ for (var i = 0; i < ids.length; i++) {
36
+ var id = ids[i];
37
+ var Cls = classes[id];
38
+ if (!Cls) {
39
+ throw new Error("@cef-ai/agent-sdk: engagement \\"" + id + "\\" has no class export");
40
+ }
41
+ instances[id] = new Cls();
42
+ }
43
+ globalThis.__cefAgent = { engagements: instances };
44
+ try { delete globalThis.__cefBundle; } catch (_) { globalThis.__cefBundle = undefined; }
45
+ })();
46
+ `.trim();
47
+ /**
48
+ * Global name esbuild uses to expose the bundled module's exports. Kept in
49
+ * sync with {@link IIFE_FOOTER} above so callers can wire both pieces from
50
+ * a single source of truth.
51
+ */
52
+ export const ESBUILD_GLOBAL_NAME = "__cefBundle";
53
+ //# sourceMappingURL=esbuild-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"esbuild-plugin.js","sourceRoot":"","sources":["../../src/build/esbuild-plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;;;;;;;;;;;;;;;;;;;;;CAqB1B,CAAC,IAAI,EAAE,CAAC;AAET;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,aAAa,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Static lint pass for `cef build`. Runs BEFORE bundling so authors get a
3
+ * clear, actionable error before esbuild has a chance to produce a bundle
4
+ * that the runtime would later reject. The rules are all syntactic, so we
5
+ * use `ts.createSourceFile` (no type-checker / Program) for speed.
6
+ *
7
+ * Rules enforced (per `agent-sdk.md` §7 + the build plan):
8
+ *
9
+ * - `@OnEvent(...)` argument MUST be a string literal.
10
+ * - `ctx.publish(t, ...)` first arg MUST be a string literal.
11
+ * - `ctx.cubby("alias")` first arg MUST be a string literal AND a declared
12
+ * alias from `cef.config.ts` `cubbies[].alias`.
13
+ * - `ctx.models.X` member access MUST refer to a declared model alias from
14
+ * `cef.config.ts` `models`.
15
+ * - `import x from "<m>"` / `require("<m>")` / `import("<m>")` against the
16
+ * banned module list (Node built-ins + sync DB/network npm packages).
17
+ *
18
+ * Lint failures THROW — there is no error-collection mode in v1; the first
19
+ * violation aborts the build with a single, well-formatted message.
20
+ *
21
+ * `lintAgentSource` also collects every literal `ctx.publish(t, ...)` first
22
+ * argument it encounters and returns the deduped sorted set as
23
+ * `publishes[]`. The caller (`cefBuild`) feeds this into the manifest when
24
+ * the user has not declared `publishes` in `cef.config.ts`.
25
+ *
26
+ * v1 scope: lints the agent's *entry file* only. Helper modules imported
27
+ * via `./` paths are not yet scanned. Banned-import rules still apply
28
+ * transitively at bundle time (esbuild will resolve them and inline their
29
+ * source, but the rules here will catch the import edge in the entry; deep
30
+ * import auditing is a follow-up if needed).
31
+ */
32
+ export interface LintInputBase {
33
+ declaredCubbyAliases: Set<string>;
34
+ declaredModelAliases: Set<string>;
35
+ }
36
+ export interface LintInputFromPath extends LintInputBase {
37
+ /** Absolute path to the agent's entry `.ts` file. */
38
+ entryPath: string;
39
+ source?: never;
40
+ sourceFilename?: never;
41
+ }
42
+ export interface LintInputFromSource extends LintInputBase {
43
+ /** Inline TypeScript source — used by tests and ad-hoc callers. */
44
+ source: string;
45
+ /** Filename used in error messages. Defaults to `<source>`. */
46
+ sourceFilename?: string;
47
+ entryPath?: never;
48
+ }
49
+ export type LintInput = LintInputFromPath | LintInputFromSource;
50
+ export interface LintResult {
51
+ /** Deduped, sorted list of literal `ctx.publish(...)` first-arg values. */
52
+ publishes: string[];
53
+ }
54
+ export declare function lintAgentSource(input: LintInput): LintResult;
55
+ //# sourceMappingURL=lints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lints.d.ts","sourceRoot":"","sources":["../../src/build/lints.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,WAAW,aAAa;IAC5B,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,iBAAkB,SAAQ,aAAa;IACtD,qDAAqD;IACrD,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,KAAK,CAAC;IACf,cAAc,CAAC,EAAE,KAAK,CAAC;CACxB;AAED,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,mEAAmE;IACnE,MAAM,EAAE,MAAM,CAAC;IACf,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,KAAK,CAAC;CACnB;AAED,MAAM,MAAM,SAAS,GAAG,iBAAiB,GAAG,mBAAmB,CAAC;AAEhE,MAAM,WAAW,UAAU;IACzB,2EAA2E;IAC3E,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AA+GD,wBAAgB,eAAe,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,CA+J5D"}
@@ -0,0 +1,214 @@
1
+ import fs from "node:fs";
2
+ import ts from "typescript";
3
+ /**
4
+ * Modules an agent is forbidden from importing. Per `agent-sdk.md` §7.
5
+ *
6
+ * Note `crypto` (and `node:crypto`) are banned: agents that need
7
+ * cryptographic primitives use the WebCrypto API exposed on
8
+ * `globalThis.crypto` by the runtime — no Node import is required.
9
+ */
10
+ const BANNED_NODE_MODULES = new Set([
11
+ "fs",
12
+ "fs/promises",
13
+ "path",
14
+ "net",
15
+ "tls",
16
+ "dgram",
17
+ "dns",
18
+ "http",
19
+ "https",
20
+ "http2",
21
+ "child_process",
22
+ "worker_threads",
23
+ "cluster",
24
+ "os",
25
+ "process",
26
+ "readline",
27
+ "repl",
28
+ "vm",
29
+ "stream",
30
+ "zlib",
31
+ "buffer",
32
+ "crypto",
33
+ ]);
34
+ /** Sync DB / network packages we don't allow agents to use. */
35
+ const BANNED_NPM_PACKAGES = new Set([
36
+ "pg",
37
+ "pg-native",
38
+ "mysql2",
39
+ "mysql",
40
+ "mongodb",
41
+ "redis",
42
+ "ioredis",
43
+ "sqlite3",
44
+ "better-sqlite3",
45
+ "ws",
46
+ "node-fetch",
47
+ "axios",
48
+ ]);
49
+ function isBannedModule(specifier) {
50
+ if (BANNED_NPM_PACKAGES.has(specifier))
51
+ return true;
52
+ // Match both `fs` and `node:fs`. Subpath imports (`fs/promises`,
53
+ // `node:fs/promises`) are matched against the base + full string.
54
+ const stripped = specifier.startsWith("node:") ? specifier.slice(5) : specifier;
55
+ if (BANNED_NODE_MODULES.has(stripped))
56
+ return true;
57
+ // Subpaths like `node:fs/promises` → check the head.
58
+ const head = stripped.split("/", 1)[0];
59
+ if (BANNED_NODE_MODULES.has(head))
60
+ return true;
61
+ return false;
62
+ }
63
+ function locFor(sf, node) {
64
+ const { line, character } = ts.getLineAndCharacterOfPosition(sf, node.getStart(sf));
65
+ return `${sf.fileName}:${line + 1}:${character + 1}`;
66
+ }
67
+ function lintError(sf, node, msg) {
68
+ return new Error(`[cef build] ${locFor(sf, node)} — ${msg}`);
69
+ }
70
+ function isOnEventDecorator(decorator) {
71
+ const expr = decorator.expression;
72
+ if (!ts.isCallExpression(expr))
73
+ return false;
74
+ const callee = expr.expression;
75
+ return ts.isIdentifier(callee) && callee.text === "OnEvent";
76
+ }
77
+ /**
78
+ * True when `expr` is the property-access chain `ctx.<name>`. We check the
79
+ * head identifier text rather than threading symbol resolution through the
80
+ * checker — agent code by convention names the context parameter `ctx`.
81
+ */
82
+ function isCtxAccess(expr, name) {
83
+ if (!ts.isPropertyAccessExpression(expr))
84
+ return false;
85
+ if (expr.name.text !== name)
86
+ return false;
87
+ const obj = expr.expression;
88
+ return ts.isIdentifier(obj) && obj.text === "ctx";
89
+ }
90
+ /**
91
+ * True when `expr` is `ctx.models` — used to detect `ctx.models.X` accesses
92
+ * regardless of what comes after.
93
+ */
94
+ function isCtxModels(expr) {
95
+ if (!ts.isPropertyAccessExpression(expr))
96
+ return false;
97
+ if (expr.name.text !== "models")
98
+ return false;
99
+ const obj = expr.expression;
100
+ return ts.isIdentifier(obj) && obj.text === "ctx";
101
+ }
102
+ function readSource(input) {
103
+ if (input.source !== undefined) {
104
+ return { source: input.source, filename: input.sourceFilename ?? "<source>" };
105
+ }
106
+ const source = fs.readFileSync(input.entryPath, "utf8");
107
+ return { source, filename: input.entryPath };
108
+ }
109
+ export function lintAgentSource(input) {
110
+ const { source, filename } = readSource(input);
111
+ const sf = ts.createSourceFile(filename, source, ts.ScriptTarget.ES2022, true, ts.ScriptKind.TS);
112
+ const publishes = new Set();
113
+ const declaredCubbies = input.declaredCubbyAliases;
114
+ const declaredModels = input.declaredModelAliases;
115
+ const visit = (node) => {
116
+ // -------- @OnEvent("...") --------
117
+ // ts.canHaveDecorators / ts.getDecorators is the modern API; fall back
118
+ // to the legacy `node.decorators` for older TS layouts that the source
119
+ // file may produce when SyntaxKind hasn't been re-canonicalised.
120
+ const decorators = ts.canHaveDecorators(node) ? ts.getDecorators(node) : undefined;
121
+ if (decorators) {
122
+ for (const d of decorators) {
123
+ if (isOnEventDecorator(d)) {
124
+ const args = d.expression.arguments;
125
+ if (args.length === 0 || !ts.isStringLiteralLike(args[0])) {
126
+ const got = args.length === 0
127
+ ? "no arguments"
128
+ : `${ts.SyntaxKind[args[0].kind]} "${args[0].getText(sf)}"`;
129
+ throw lintError(sf, args.length === 0 ? d : args[0], `@OnEvent argument must be a string literal (got ${got}). Use a literal like @OnEvent("user_message").`);
130
+ }
131
+ }
132
+ }
133
+ }
134
+ // -------- ctx.publish(t, ...) / ctx.cubby("...") --------
135
+ if (ts.isCallExpression(node)) {
136
+ const callee = node.expression;
137
+ // ctx.publish(...)
138
+ if (isCtxAccess(callee, "publish")) {
139
+ const arg0 = node.arguments[0];
140
+ if (!arg0 || !ts.isStringLiteralLike(arg0)) {
141
+ const got = !arg0
142
+ ? "no arguments"
143
+ : `${ts.SyntaxKind[arg0.kind]} "${arg0.getText(sf)}"`;
144
+ throw lintError(sf, arg0 ?? callee, `ctx.publish first argument must be a string literal (got ${got}). Use a literal event-type like ctx.publish("greeting", payload).`);
145
+ }
146
+ publishes.add(arg0.text);
147
+ }
148
+ // ctx.cubby("...")
149
+ if (isCtxAccess(callee, "cubby")) {
150
+ const arg0 = node.arguments[0];
151
+ if (!arg0 || !ts.isStringLiteralLike(arg0)) {
152
+ const got = !arg0
153
+ ? "no arguments"
154
+ : `${ts.SyntaxKind[arg0.kind]} "${arg0.getText(sf)}"`;
155
+ throw lintError(sf, arg0 ?? callee, `ctx.cubby first argument must be a string literal (got ${got}). Use a literal alias like ctx.cubby("history").`);
156
+ }
157
+ if (!declaredCubbies.has(arg0.text)) {
158
+ const declared = [...declaredCubbies].sort();
159
+ throw lintError(sf, arg0, `ctx.cubby alias "${arg0.text}" is not declared in cef.config.ts cubbies[] (declared: [${declared.join(", ")}]).`);
160
+ }
161
+ }
162
+ // require("...") — banned-import check via dynamic-call form.
163
+ if (ts.isIdentifier(callee) &&
164
+ callee.text === "require" &&
165
+ node.arguments.length === 1 &&
166
+ ts.isStringLiteralLike(node.arguments[0])) {
167
+ const spec = node.arguments[0].text;
168
+ if (isBannedModule(spec)) {
169
+ throw lintError(sf, node.arguments[0], `banned import "${spec}". Agent sandbox forbids Node built-ins and sync DB/network libs (see agent-sdk.md §7).`);
170
+ }
171
+ }
172
+ }
173
+ // import("...")
174
+ if (ts.isCallExpression(node) &&
175
+ node.expression.kind === ts.SyntaxKind.ImportKeyword &&
176
+ node.arguments.length === 1 &&
177
+ ts.isStringLiteralLike(node.arguments[0])) {
178
+ const spec = node.arguments[0].text;
179
+ if (isBannedModule(spec)) {
180
+ throw lintError(sf, node.arguments[0], `banned import "${spec}". Agent sandbox forbids Node built-ins and sync DB/network libs (see agent-sdk.md §7).`);
181
+ }
182
+ }
183
+ // -------- ctx.models.X --------
184
+ // PropertyAccess where `.expression` is `ctx.models`; the `name` text is
185
+ // the model alias being referenced.
186
+ if (ts.isPropertyAccessExpression(node) && isCtxModels(node.expression)) {
187
+ const alias = node.name.text;
188
+ if (!declaredModels.has(alias)) {
189
+ const declared = [...declaredModels].sort();
190
+ throw lintError(sf, node.name, `ctx.models.${alias} is not declared in cef.config.ts models (declared: [${declared.join(", ")}]).`);
191
+ }
192
+ }
193
+ // -------- import "..." --------
194
+ if (ts.isImportDeclaration(node) && ts.isStringLiteralLike(node.moduleSpecifier)) {
195
+ const spec = node.moduleSpecifier.text;
196
+ if (isBannedModule(spec)) {
197
+ throw lintError(sf, node.moduleSpecifier, `banned import "${spec}". Agent sandbox forbids Node built-ins and sync DB/network libs (see agent-sdk.md §7).`);
198
+ }
199
+ }
200
+ // export ... from "..." — same banned-list check.
201
+ if (ts.isExportDeclaration(node) &&
202
+ node.moduleSpecifier !== undefined &&
203
+ ts.isStringLiteralLike(node.moduleSpecifier)) {
204
+ const spec = node.moduleSpecifier.text;
205
+ if (isBannedModule(spec)) {
206
+ throw lintError(sf, node.moduleSpecifier, `banned import "${spec}". Agent sandbox forbids Node built-ins and sync DB/network libs (see agent-sdk.md §7).`);
207
+ }
208
+ }
209
+ ts.forEachChild(node, visit);
210
+ };
211
+ visit(sf);
212
+ return { publishes: [...publishes].sort() };
213
+ }
214
+ //# sourceMappingURL=lints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lints.js","sourceRoot":"","sources":["../../src/build/lints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzB,OAAO,EAAE,MAAM,YAAY,CAAC;AA4D5B;;;;;;GAMG;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAS;IAC1C,IAAI;IACJ,aAAa;IACb,MAAM;IACN,KAAK;IACL,KAAK;IACL,OAAO;IACP,KAAK;IACL,MAAM;IACN,OAAO;IACP,OAAO;IACP,eAAe;IACf,gBAAgB;IAChB,SAAS;IACT,IAAI;IACJ,SAAS;IACT,UAAU;IACV,MAAM;IACN,IAAI;IACJ,QAAQ;IACR,MAAM;IACN,QAAQ;IACR,QAAQ;CACT,CAAC,CAAC;AAEH,+DAA+D;AAC/D,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAS;IAC1C,IAAI;IACJ,WAAW;IACX,QAAQ;IACR,OAAO;IACP,SAAS;IACT,OAAO;IACP,SAAS;IACT,SAAS;IACT,gBAAgB;IAChB,IAAI;IACJ,YAAY;IACZ,OAAO;CACR,CAAC,CAAC;AAEH,SAAS,cAAc,CAAC,SAAiB;IACvC,IAAI,mBAAmB,CAAC,GAAG,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IACpD,iEAAiE;IACjE,kEAAkE;IAClE,MAAM,QAAQ,GAAG,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAChF,IAAI,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IACnD,qDAAqD;IACrD,MAAM,IAAI,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAE,CAAC;IACx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AC;IAC/B,CAAC,CAAC;IAEF,KAAK,CAAC,EAAE,CAAC,CAAC;IAEV,OAAO,EAAE,SAAS,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Selection rule (mirrored structurally from `@cef-ai/agent-sdk/config`).
3
+ * Vocabulary v1: `priority` | `weight` | `limit` (numeric values).
4
+ */
5
+ export interface Rule {
6
+ name: "priority" | "weight" | "limit";
7
+ value: number;
8
+ }
9
+ /** One row of `targeting.engagements[]`. */
10
+ export interface TargetingEngagement {
11
+ id: string;
12
+ rules?: Rule[];
13
+ }
14
+ /** Engagement-selection table emitted into the manifest. */
15
+ export interface Targeting {
16
+ engagements: TargetingEngagement[];
17
+ }
18
+ /** JSON Schema document, kept loose. */
19
+ export type JSONSchema = Record<string, unknown>;
20
+ /** Marketplace presentation card. */
21
+ export interface AgentCard {
22
+ name: string;
23
+ description: string;
24
+ iconUrl?: string;
25
+ capabilities?: string[];
26
+ }
27
+ /**
28
+ * Subset of `AgentConfig` (from `@cef-ai/agent-sdk/config`) consumed across
29
+ * the CLI commands. Re-declared here so commands don't need to import the
30
+ * SDK's config package for type-only access — keeps the runtime/build/
31
+ * typegen layers decoupled from the public config surface.
32
+ */
33
+ export interface AgentConfigLike {
34
+ id: string;
35
+ version: string;
36
+ alias?: string;
37
+ source?: string;
38
+ card?: AgentCard;
39
+ requiredScopes?: string[];
40
+ /** Per-Job idle timeout as a duration string (e.g. `"15m"`, `"30s"`,
41
+ * `"500ms"`); default `"30m"`. Parsed into ms by the build step. */
42
+ idleTimeout?: string;
43
+ entry?: string;
44
+ engagements?: Array<{
45
+ id: string;
46
+ entry: string;
47
+ }>;
48
+ agents?: AgentConfigLike[];
49
+ cubbies?: Array<{
50
+ alias: string;
51
+ migrations?: string;
52
+ }>;
53
+ settings?: Array<{
54
+ key: string;
55
+ type: "string" | "number" | "boolean" | "url" | "secret";
56
+ required?: boolean;
57
+ label?: string;
58
+ description?: string;
59
+ default?: unknown;
60
+ }>;
61
+ models?: Record<string, string>;
62
+ uses?: Record<string, string>;
63
+ eventSchemas?: Record<string, JSONSchema>;
64
+ targeting?: Targeting;
65
+ }
66
+ /** Single engagement, normalized for build-pipeline consumers. */
67
+ export interface NormalizedEngagement {
68
+ /** Stable engagement id (`[a-zA-Z][a-zA-Z0-9_-]*`). */
69
+ id: string;
70
+ /** Absolute path to the engagement entry source file. */
71
+ entry: string;
72
+ }
73
+ /**
74
+ * Compile `cef.config.ts` to a temp ESM file and dynamically import it.
75
+ *
76
+ * `@cef-ai/agent-sdk` and `@cef-ai/agent-sdk/config` are externalised so the
77
+ * `defineAgent` identity helper resolves from the host's node_modules at
78
+ * runtime — we don't want to bundle the SDK into the user's config.
79
+ *
80
+ * The temp file is placed inside an existing `node_modules` ancestor of
81
+ * the config (under `node_modules/.cef/config-cache/`), so node's ESM
82
+ * resolver finds the externalised packages without us having to create a
83
+ * stub `node_modules` next to the user's config.
84
+ *
85
+ * Shared by `cef build` and `cef typegen`.
86
+ */
87
+ export declare function loadConfig(configPath: string, configDir: string): Promise<AgentConfigLike>;
88
+ /**
89
+ * Flatten a (possibly nested) `AgentConfig` into a list of leaf agents.
90
+ * The single-agent case is a top-level config with `entry` (or
91
+ * `engagements`). The nested-agents case has an `agents[]` field; each
92
+ * entry is a full AgentConfig and is recursed into. We require either
93
+ * `entry` or `engagements[]` on every leaf.
94
+ */
95
+ export declare function flattenAgents(cfg: AgentConfigLike): AgentConfigLike[];
96
+ /**
97
+ * Normalize an agent's engagement-layer declaration into a list with absolute
98
+ * entry paths. Accepts either:
99
+ *
100
+ * - `entry: "./src/agent.ts"` shorthand → one engagement with id `"default"`.
101
+ * - `engagements: [{ id, entry }, ...]` explicit form → returned as-is with
102
+ * relative entry paths resolved against `configDir`.
103
+ *
104
+ * Validates:
105
+ * - exactly one of `entry`/`engagements` is provided,
106
+ * - `engagements[]` has at least one entry when present,
107
+ * - every engagement id matches `[a-zA-Z][a-zA-Z0-9_-]*`,
108
+ * - engagement ids are unique within the agent.
109
+ *
110
+ * Throws on any violation with `[@cef-ai/cli]`-prefixed errors so failures point
111
+ * authors at their `cef.config.ts`.
112
+ */
113
+ export declare function normalizeEngagements(agent: AgentConfigLike, configDir: string): NormalizedEngagement[];
114
+ //# sourceMappingURL=load-config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"load-config.d.ts","sourceRoot":"","sources":["../../src/build/load-config.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,UAAU,GAAG,QAAQ,GAAG,OAAO,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,4CAA4C;AAC5C,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;CAChB;AAED,4DAA4D;AAC5D,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,mBAAmB,EAAE,CAAC;CACpC;AAED,wCAAwC;AACxC,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEjD,qCAAqC;AACrC,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;yEACqE;IACrE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAA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