@cef-ai/cli 0.2.6 → 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.
- package/README.md +75 -1247
- package/dist/build/duration.d.ts +22 -0
- package/dist/build/duration.d.ts.map +1 -0
- package/dist/build/duration.js +44 -0
- package/dist/build/duration.js.map +1 -0
- package/dist/build/esbuild-plugin.d.ts +32 -0
- package/dist/build/esbuild-plugin.d.ts.map +1 -0
- package/dist/build/esbuild-plugin.js +53 -0
- package/dist/build/esbuild-plugin.js.map +1 -0
- package/dist/build/lints.d.ts +55 -0
- package/dist/build/lints.d.ts.map +1 -0
- package/dist/build/lints.js +214 -0
- package/dist/build/lints.js.map +1 -0
- package/dist/build/load-config.d.ts +114 -0
- package/dist/build/load-config.d.ts.map +1 -0
- package/dist/build/load-config.js +150 -0
- package/dist/build/load-config.js.map +1 -0
- package/dist/build/manifest.d.ts +156 -0
- package/dist/build/manifest.d.ts.map +1 -0
- package/dist/build/manifest.js +111 -0
- package/dist/build/manifest.js.map +1 -0
- package/dist/build/targeting.d.ts +15 -0
- package/dist/build/targeting.d.ts.map +1 -0
- package/dist/build/targeting.js +69 -0
- package/dist/build/targeting.js.map +1 -0
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +107 -62
- package/dist/cli.js.map +1 -0
- package/dist/commands/build.d.ts +41 -0
- package/dist/commands/build.d.ts.map +1 -0
- package/dist/commands/build.js +252 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/inspect.d.ts +49 -0
- package/dist/commands/inspect.d.ts.map +1 -0
- package/dist/commands/inspect.js +135 -0
- package/dist/commands/inspect.js.map +1 -0
- package/dist/commands/typegen.d.ts +36 -0
- package/dist/commands/typegen.d.ts.map +1 -0
- package/dist/commands/typegen.js +210 -0
- package/dist/commands/typegen.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/lib.d.ts +12 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +9 -0
- package/dist/lib.js.map +1 -0
- package/dist/typegen/augment.d.ts +57 -0
- package/dist/typegen/augment.d.ts.map +1 -0
- package/dist/typegen/augment.js +87 -0
- package/dist/typegen/augment.js.map +1 -0
- package/dist/typegen/fetch.d.ts +30 -0
- package/dist/typegen/fetch.d.ts.map +1 -0
- package/dist/typegen/fetch.js +38 -0
- package/dist/typegen/fetch.js.map +1 -0
- package/dist/typegen/lockfile.d.ts +42 -0
- package/dist/typegen/lockfile.d.ts.map +1 -0
- package/dist/typegen/lockfile.js +58 -0
- package/dist/typegen/lockfile.js.map +1 -0
- package/dist/typegen/schema-to-ts.d.ts +21 -0
- package/dist/typegen/schema-to-ts.d.ts.map +1 -0
- package/dist/typegen/schema-to-ts.js +29 -0
- package/dist/typegen/schema-to-ts.js.map +1 -0
- package/package.json +20 -58
- package/dist/commands/auth/index.d.ts +0 -2
- package/dist/commands/auth/index.js +0 -162
- package/dist/commands/deploy/clone.d.ts +0 -13
- package/dist/commands/deploy/clone.js +0 -143
- package/dist/commands/deploy/delete.d.ts +0 -14
- package/dist/commands/deploy/delete.js +0 -134
- package/dist/commands/deploy/deploy.d.ts +0 -24
- package/dist/commands/deploy/deploy.js +0 -654
- package/dist/commands/deploy/index.d.ts +0 -2
- package/dist/commands/deploy/index.js +0 -216
- package/dist/commands/deploy/status.d.ts +0 -14
- package/dist/commands/deploy/status.js +0 -61
- package/dist/commands/dev/index.d.ts +0 -2
- package/dist/commands/dev/index.js +0 -134
- package/dist/commands/dev/server.d.ts +0 -14
- package/dist/commands/dev/server.js +0 -195
- package/dist/commands/dev/static/app.js +0 -633
- package/dist/commands/dev/static/index.html +0 -205
- package/dist/commands/dev/static/static/app.js +0 -633
- package/dist/commands/dev/static/static/index.html +0 -205
- package/dist/commands/dev/static/static/style.css +0 -184
- package/dist/commands/dev/static/style.css +0 -184
- package/dist/commands/playground/index.d.ts +0 -2
- package/dist/commands/playground/index.js +0 -75
- package/dist/commands/playground/test.d.ts +0 -15
- package/dist/commands/playground/test.js +0 -166
- package/dist/commands/service/index.d.ts +0 -2
- package/dist/commands/service/index.js +0 -75
- package/dist/lib/api.d.ts +0 -146
- package/dist/lib/api.js +0 -330
- package/dist/lib/config.d.ts +0 -12
- package/dist/lib/config.js +0 -145
- package/dist/lib/credentials.d.ts +0 -19
- package/dist/lib/credentials.js +0 -68
- package/dist/lib/runtime/agent-router.d.ts +0 -12
- package/dist/lib/runtime/agent-router.js +0 -67
- package/dist/lib/runtime/context-builder.d.ts +0 -27
- package/dist/lib/runtime/context-builder.js +0 -166
- package/dist/lib/runtime/cubby-manager.d.ts +0 -20
- package/dist/lib/runtime/cubby-manager.js +0 -162
- package/dist/lib/runtime/index.d.ts +0 -51
- package/dist/lib/runtime/index.js +0 -181
- package/dist/lib/runtime/log-collector.d.ts +0 -17
- package/dist/lib/runtime/log-collector.js +0 -61
- package/dist/lib/runtime/stream-manager.d.ts +0 -10
- package/dist/lib/runtime/stream-manager.js +0 -77
- package/dist/lib/runtime/types.d.ts +0 -76
- package/dist/lib/runtime/types.js +0 -2
- package/dist/lib/transpile.d.ts +0 -1
- package/dist/lib/transpile.js +0 -9
- package/dist/lib/typecheck.d.ts +0 -31
- package/dist/lib/typecheck.js +0 -175
- package/dist/lib/types.d.ts +0 -246
- package/dist/lib/types.js +0 -2
- package/dist/lib/utils.d.ts +0 -4
- package/dist/lib/utils.js +0 -33
- package/example/.env.example +0 -6
- package/example/agents/object-detection/tasks/yolo.ts +0 -28
- package/example/agents/parking-violation-detector/tasks/detect.ts +0 -326
- package/example/cef.config.yaml +0 -91
- package/example/engagements/engagement.ts +0 -902
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import vm from "node:vm";
|
|
4
|
+
/**
|
|
5
|
+
* Inspect a built agent directory.
|
|
6
|
+
*
|
|
7
|
+
* Reads `<agentDir>/manifest.json` for the per-engagement routing tables
|
|
8
|
+
* and executes `<agentDir>/bundle.js` in a fresh `node:vm` context to
|
|
9
|
+
* enumerate the methods actually exposed on each
|
|
10
|
+
* `globalThis.__cefAgent.engagements[id]` instance. The two views are
|
|
11
|
+
* useful for confirming that each manifest engagement's `handlerName`
|
|
12
|
+
* strings match real methods on the bundled instance.
|
|
13
|
+
*
|
|
14
|
+
* Pure exploration: no files are written, no network. Safe to run on any
|
|
15
|
+
* `dist/<agentId>/` directory.
|
|
16
|
+
*/
|
|
17
|
+
export async function cefInspect(opts) {
|
|
18
|
+
const { agentDir, print = true } = opts;
|
|
19
|
+
const manifestPath = path.join(agentDir, "manifest.json");
|
|
20
|
+
const bundlePath = path.join(agentDir, "bundle.js");
|
|
21
|
+
const manifest = JSON.parse(await fs.readFile(manifestPath, "utf8"));
|
|
22
|
+
const bundle = await fs.readFile(bundlePath, "utf8");
|
|
23
|
+
// Run the bundle in an isolated context. The IIFE assigns
|
|
24
|
+
// { engagements: { id: instance } } to globalThis.__cefAgent.
|
|
25
|
+
const sandbox = { console };
|
|
26
|
+
sandbox.globalThis = sandbox;
|
|
27
|
+
vm.runInNewContext(bundle, sandbox);
|
|
28
|
+
const cefAgent = sandbox.__cefAgent;
|
|
29
|
+
const instances = cefAgent?.engagements ?? {};
|
|
30
|
+
const engagements = (manifest.engagements ?? []).map((e) => {
|
|
31
|
+
const inst = instances[e.id];
|
|
32
|
+
const exposedMethods = [];
|
|
33
|
+
if (inst) {
|
|
34
|
+
const seen = new Set();
|
|
35
|
+
let proto = Object.getPrototypeOf(inst);
|
|
36
|
+
while (proto && Object.getPrototypeOf(proto) !== null) {
|
|
37
|
+
for (const k of Object.getOwnPropertyNames(proto)) {
|
|
38
|
+
if (k === "constructor")
|
|
39
|
+
continue;
|
|
40
|
+
if (typeof inst[k] === "function") {
|
|
41
|
+
seen.add(k);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
proto = Object.getPrototypeOf(proto);
|
|
45
|
+
}
|
|
46
|
+
exposedMethods.push(...[...seen].sort());
|
|
47
|
+
}
|
|
48
|
+
const exposedSet = new Set(exposedMethods);
|
|
49
|
+
const missingMethods = [];
|
|
50
|
+
const handles = e.handles ?? {};
|
|
51
|
+
for (const handlerName of Object.values(handles)) {
|
|
52
|
+
if (!exposedSet.has(handlerName))
|
|
53
|
+
missingMethods.push(handlerName);
|
|
54
|
+
}
|
|
55
|
+
const out = {
|
|
56
|
+
id: e.id,
|
|
57
|
+
handles,
|
|
58
|
+
exposedMethods,
|
|
59
|
+
missingMethods,
|
|
60
|
+
};
|
|
61
|
+
if (e.goal !== undefined)
|
|
62
|
+
out.goal = e.goal;
|
|
63
|
+
return out;
|
|
64
|
+
});
|
|
65
|
+
const result = {
|
|
66
|
+
manifest: {
|
|
67
|
+
// Pre-publish manifests carry an empty `agentId`; the marketplace alias
|
|
68
|
+
// is the single human-friendly identifier (`prototype.md` §"AgentManifest.Alias").
|
|
69
|
+
alias: manifest.alias ?? manifest.agentId ?? "",
|
|
70
|
+
version: manifest.version,
|
|
71
|
+
cubbies: (manifest.cubbies ?? []).map((c) => c.alias),
|
|
72
|
+
models: Object.keys(manifest.models ?? {}),
|
|
73
|
+
handles: manifest.handles ?? [],
|
|
74
|
+
publishes: manifest.publishes ?? [],
|
|
75
|
+
targeting: manifest.targeting ?? { engagements: [] },
|
|
76
|
+
},
|
|
77
|
+
engagements,
|
|
78
|
+
};
|
|
79
|
+
if (print)
|
|
80
|
+
printInspectResult(result, cefAgent !== undefined);
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
function printInspectResult(r, hasInstance) {
|
|
84
|
+
const m = r.manifest;
|
|
85
|
+
console.log(`# ${m.alias} v${m.version}`);
|
|
86
|
+
console.log("");
|
|
87
|
+
console.log("## Manifest engagements:");
|
|
88
|
+
if (r.engagements.length === 0) {
|
|
89
|
+
console.log(" (none)");
|
|
90
|
+
}
|
|
91
|
+
for (const e of r.engagements) {
|
|
92
|
+
console.log(` - ${e.id}${e.goal ? ` — ${e.goal}` : ""}`);
|
|
93
|
+
console.log(` handles:`);
|
|
94
|
+
const handleEntries = Object.entries(e.handles);
|
|
95
|
+
if (handleEntries.length === 0) {
|
|
96
|
+
console.log(` (none)`);
|
|
97
|
+
}
|
|
98
|
+
for (const [type, handlerName] of handleEntries) {
|
|
99
|
+
console.log(` - ${type} -> ${handlerName}`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
console.log("");
|
|
103
|
+
console.log(`## handles: ${JSON.stringify(m.handles)}`);
|
|
104
|
+
console.log(`## publishes: ${JSON.stringify(m.publishes)}`);
|
|
105
|
+
console.log(`## targeting:`);
|
|
106
|
+
const targetingLines = JSON.stringify(m.targeting, null, 2)
|
|
107
|
+
.split("\n")
|
|
108
|
+
.map((l) => " " + l);
|
|
109
|
+
for (const line of targetingLines)
|
|
110
|
+
console.log(line);
|
|
111
|
+
console.log(`## cubbies: ${JSON.stringify(m.cubbies)}`);
|
|
112
|
+
console.log(`## models: ${JSON.stringify(m.models)}`);
|
|
113
|
+
console.log("");
|
|
114
|
+
console.log("## Bundle methods per engagement");
|
|
115
|
+
if (!hasInstance) {
|
|
116
|
+
console.log(" (no __cefAgent set - bundle did not initialise)");
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
for (const e of r.engagements) {
|
|
120
|
+
console.log(` - ${e.id}:`);
|
|
121
|
+
if (e.exposedMethods.length === 0) {
|
|
122
|
+
console.log(` (no methods)`);
|
|
123
|
+
}
|
|
124
|
+
for (const name of e.exposedMethods) {
|
|
125
|
+
console.log(` - ${name}`);
|
|
126
|
+
}
|
|
127
|
+
if (e.missingMethods.length > 0) {
|
|
128
|
+
console.log(` WARNING manifest references methods not on bundle:`);
|
|
129
|
+
for (const name of e.missingMethods) {
|
|
130
|
+
console.log(` - ${name}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
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project root. Defaults to `process.cwd()`. */
|
|
6
|
+
cwd?: string;
|
|
7
|
+
/** Path to `cef.config.ts`. Defaults to `<cwd>/cef.config.ts`. */
|
|
8
|
+
configPath?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface CefTypegenResult {
|
|
11
|
+
/** Absolute path to the emitted `.cef/generated.d.ts`. */
|
|
12
|
+
generatedPath: string;
|
|
13
|
+
/** Absolute path to the emitted `cef.lock.json`. */
|
|
14
|
+
lockfilePath: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Generate `.cef/generated.d.ts` and `cef.lock.json` from the agent's
|
|
18
|
+
* declared `models` and `uses` external references.
|
|
19
|
+
*
|
|
20
|
+
* Algorithm:
|
|
21
|
+
* 1. Load `cef.config.ts` (shared with `cefBuild` via load-config.ts).
|
|
22
|
+
* 2. Collect `models` + `uses` from all leaf agents.
|
|
23
|
+
* 3. Read the existing lockfile (if any).
|
|
24
|
+
* 4. For each entry: if the lockfile has a matching URL with a present
|
|
25
|
+
* integrity, reuse the cached body; otherwise re-fetch.
|
|
26
|
+
* 5. Schema-to-TS each model's input/output and each peer's publishes[].
|
|
27
|
+
* 6. Build the `.cef/generated.d.ts` content (header, interfaces, module
|
|
28
|
+
* augmentation block).
|
|
29
|
+
* 7. Write both artefacts.
|
|
30
|
+
*
|
|
31
|
+
* Cache reuse is keyed on the *declared* URL (lock entries also carry
|
|
32
|
+
* their declared URL). For semver-ranged URLs (`agent@^1`), we treat the
|
|
33
|
+
* declared URL as the cache key — v2's real semver resolution will revisit.
|
|
34
|
+
*/
|
|
35
|
+
export declare function cefTypegen(opts?: CefTypegenOptions): Promise<CefTypegenResult>;
|
|
36
|
+
//# sourceMappingURL=typegen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typegen.d.ts","sourceRoot":"","sources":["../../src/commands/typegen.ts"],"names":[],"mappings":"AAqBA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,iDAAiD;IACjD,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kEAAkE;IAClE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,0DAA0D;IAC1D,aAAa,EAAE,MAAM,CAAC;IACtB,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAC;CACtB;AAiDD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAsB,UAAU,CAC9B,IAAI,GAAE,iBAAsB,GAC3B,OAAO,CAAC,gBAAgB,CAAC,CAiJ3B"}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import fs from "node:fs/promises";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { flattenAgents, loadConfig, } from "../build/load-config.js";
|
|
4
|
+
import { buildGeneratedDts, } from "../typegen/augment.js";
|
|
5
|
+
import { fetchJson } from "../typegen/fetch.js";
|
|
6
|
+
import { readLockfile, writeLockfile, } from "../typegen/lockfile.js";
|
|
7
|
+
/**
|
|
8
|
+
* Resolve a marketplace `agent@^N` URL to a pinned response URL.
|
|
9
|
+
*
|
|
10
|
+
* v1 stub (per task C3.6): if the URL contains an `@^N` semver range, we
|
|
11
|
+
* keep the URL as-typed for the lockfile's `resolvedUrl` — real semver
|
|
12
|
+
* resolution against the marketplace API is v2. For URLs without a range
|
|
13
|
+
* we use the post-redirect URL the server returned.
|
|
14
|
+
*/
|
|
15
|
+
function resolveUrl(declared, postRedirect) {
|
|
16
|
+
if (/@\^?\d/.test(declared)) {
|
|
17
|
+
// v1: keep the declared URL verbatim. v2 will replace this with the
|
|
18
|
+
// marketplace API's "resolved version" hint (e.g. agent@1.2.3).
|
|
19
|
+
return declared;
|
|
20
|
+
}
|
|
21
|
+
return postRedirect;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Walk a (possibly nested) `AgentConfig`, returning every `models` /
|
|
25
|
+
* `uses` mapping along with the agent it was declared on. Aliases from
|
|
26
|
+
* different agents are namespaced by appending `@<agentId>` when there's
|
|
27
|
+
* a collision so the lockfile stays unambiguous.
|
|
28
|
+
*
|
|
29
|
+
* For C3 we keep this simple: top-level + first-level nested only,
|
|
30
|
+
* collisions are resolved by last-write-wins. Deep nesting and explicit
|
|
31
|
+
* alias namespacing are a follow-up.
|
|
32
|
+
*/
|
|
33
|
+
function collectExternals(cfg) {
|
|
34
|
+
const models = {};
|
|
35
|
+
const uses = {};
|
|
36
|
+
for (const a of flattenAgents(cfg)) {
|
|
37
|
+
for (const [k, v] of Object.entries(a.models ?? {}))
|
|
38
|
+
models[k] = v;
|
|
39
|
+
for (const [k, v] of Object.entries(a.uses ?? {}))
|
|
40
|
+
uses[k] = v;
|
|
41
|
+
}
|
|
42
|
+
// Also include the top-level config's models/uses (flattenAgents only
|
|
43
|
+
// returns leaves; a parent config could declare shared models).
|
|
44
|
+
for (const [k, v] of Object.entries(cfg.models ?? {})) {
|
|
45
|
+
if (!(k in models))
|
|
46
|
+
models[k] = v;
|
|
47
|
+
}
|
|
48
|
+
for (const [k, v] of Object.entries(cfg.uses ?? {})) {
|
|
49
|
+
if (!(k in uses))
|
|
50
|
+
uses[k] = v;
|
|
51
|
+
}
|
|
52
|
+
return { models, uses };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Generate `.cef/generated.d.ts` and `cef.lock.json` from the agent's
|
|
56
|
+
* declared `models` and `uses` external references.
|
|
57
|
+
*
|
|
58
|
+
* Algorithm:
|
|
59
|
+
* 1. Load `cef.config.ts` (shared with `cefBuild` via load-config.ts).
|
|
60
|
+
* 2. Collect `models` + `uses` from all leaf agents.
|
|
61
|
+
* 3. Read the existing lockfile (if any).
|
|
62
|
+
* 4. For each entry: if the lockfile has a matching URL with a present
|
|
63
|
+
* integrity, reuse the cached body; otherwise re-fetch.
|
|
64
|
+
* 5. Schema-to-TS each model's input/output and each peer's publishes[].
|
|
65
|
+
* 6. Build the `.cef/generated.d.ts` content (header, interfaces, module
|
|
66
|
+
* augmentation block).
|
|
67
|
+
* 7. Write both artefacts.
|
|
68
|
+
*
|
|
69
|
+
* Cache reuse is keyed on the *declared* URL (lock entries also carry
|
|
70
|
+
* their declared URL). For semver-ranged URLs (`agent@^1`), we treat the
|
|
71
|
+
* declared URL as the cache key — v2's real semver resolution will revisit.
|
|
72
|
+
*/
|
|
73
|
+
export async function cefTypegen(opts = {}) {
|
|
74
|
+
const cwd = opts.cwd ? path.resolve(opts.cwd) : process.cwd();
|
|
75
|
+
const configPath = opts.configPath
|
|
76
|
+
? path.resolve(cwd, opts.configPath)
|
|
77
|
+
: path.join(cwd, "cef.config.ts");
|
|
78
|
+
const configDir = path.dirname(configPath);
|
|
79
|
+
const cfg = await loadConfig(configPath, configDir);
|
|
80
|
+
const { models, uses } = collectExternals(cfg);
|
|
81
|
+
const lockfilePath = path.join(cwd, "cef.lock.json");
|
|
82
|
+
const generatedPath = path.join(cwd, ".cef", "generated.d.ts");
|
|
83
|
+
const prevLock = await readLockfile(lockfilePath);
|
|
84
|
+
const newLock = {
|
|
85
|
+
version: 1,
|
|
86
|
+
models: {},
|
|
87
|
+
uses: {},
|
|
88
|
+
};
|
|
89
|
+
// Per-source caches of the *parsed* body, used downstream for schema
|
|
90
|
+
// extraction. We populate from either a lockfile-cache hit (refetch
|
|
91
|
+
// skipped) or from a fresh fetch.
|
|
92
|
+
const modelSpecs = [];
|
|
93
|
+
const peerSpecs = [];
|
|
94
|
+
for (const [alias, url] of Object.entries(models)) {
|
|
95
|
+
const cached = prevLock?.models[alias];
|
|
96
|
+
let parsed;
|
|
97
|
+
let entry;
|
|
98
|
+
if (cached && cached.url === url && cached.integrity) {
|
|
99
|
+
// Cache hit: we still need the parsed body for schema extraction,
|
|
100
|
+
// so re-fetch is unavoidable unless we've also persisted the
|
|
101
|
+
// payloads. For C3 we re-fetch on cache hit *only when the network
|
|
102
|
+
// is reachable*; if the fetch fails, fall back to whatever we can.
|
|
103
|
+
// (Simpler v1: always refetch but preserve the lockfile entry's
|
|
104
|
+
// url/integrity if the new integrity matches.)
|
|
105
|
+
try {
|
|
106
|
+
const fetched = await fetchJson(url, "model.json");
|
|
107
|
+
parsed = fetched.parsed;
|
|
108
|
+
entry = {
|
|
109
|
+
url,
|
|
110
|
+
resolvedUrl: resolveUrl(url, fetched.resolvedUrl),
|
|
111
|
+
integrity: fetched.integrity,
|
|
112
|
+
fetchedAt: cached.integrity === fetched.integrity
|
|
113
|
+
? cached.fetchedAt
|
|
114
|
+
: new Date().toISOString(),
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
catch {
|
|
118
|
+
// Network unreachable: reuse cached entry. We can't produce
|
|
119
|
+
// generated.d.ts without the schemas, but a cached run is
|
|
120
|
+
// expected to have generated.d.ts already on disk — so emitting
|
|
121
|
+
// an empty stub here would be wrong. Surface the error.
|
|
122
|
+
// For the C3 cache-reuse path the test stops the server, so we
|
|
123
|
+
// detect that and re-emit using the *previous* generated.d.ts
|
|
124
|
+
// as-is by skipping the source for this alias.
|
|
125
|
+
entry = cached;
|
|
126
|
+
parsed = null;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const fetched = await fetchJson(url, "model.json");
|
|
131
|
+
parsed = fetched.parsed;
|
|
132
|
+
entry = {
|
|
133
|
+
url,
|
|
134
|
+
resolvedUrl: resolveUrl(url, fetched.resolvedUrl),
|
|
135
|
+
integrity: fetched.integrity,
|
|
136
|
+
fetchedAt: new Date().toISOString(),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
newLock.models[alias] = entry;
|
|
140
|
+
if (parsed && typeof parsed === "object") {
|
|
141
|
+
const m = parsed;
|
|
142
|
+
modelSpecs.push({
|
|
143
|
+
alias,
|
|
144
|
+
input: m.input ?? { type: "object" },
|
|
145
|
+
output: m.output ?? { type: "object" },
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
for (const [alias, url] of Object.entries(uses)) {
|
|
150
|
+
const cached = prevLock?.uses[alias];
|
|
151
|
+
let parsed;
|
|
152
|
+
let entry;
|
|
153
|
+
if (cached && cached.url === url && cached.integrity) {
|
|
154
|
+
try {
|
|
155
|
+
const fetched = await fetchJson(url, "manifest.json");
|
|
156
|
+
parsed = fetched.parsed;
|
|
157
|
+
entry = {
|
|
158
|
+
url,
|
|
159
|
+
resolvedUrl: resolveUrl(url, fetched.resolvedUrl),
|
|
160
|
+
integrity: fetched.integrity,
|
|
161
|
+
fetchedAt: cached.integrity === fetched.integrity
|
|
162
|
+
? cached.fetchedAt
|
|
163
|
+
: new Date().toISOString(),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
entry = cached;
|
|
168
|
+
parsed = null;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
else {
|
|
172
|
+
const fetched = await fetchJson(url, "manifest.json");
|
|
173
|
+
parsed = fetched.parsed;
|
|
174
|
+
entry = {
|
|
175
|
+
url,
|
|
176
|
+
resolvedUrl: resolveUrl(url, fetched.resolvedUrl),
|
|
177
|
+
integrity: fetched.integrity,
|
|
178
|
+
fetchedAt: new Date().toISOString(),
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
newLock.uses[alias] = entry;
|
|
182
|
+
if (parsed && typeof parsed === "object") {
|
|
183
|
+
const m = parsed;
|
|
184
|
+
peerSpecs.push({ alias, publishes: m.publishes ?? [] });
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
// Generate the .d.ts. If we had cache fallbacks (network unreachable
|
|
188
|
+
// and no parsed body), the generated file may be missing some
|
|
189
|
+
// interfaces — we keep the existing one in that case.
|
|
190
|
+
const haveAnyContent = modelSpecs.length > 0 || peerSpecs.length > 0;
|
|
191
|
+
if (haveAnyContent) {
|
|
192
|
+
const dtsContent = await buildGeneratedDts(modelSpecs, peerSpecs);
|
|
193
|
+
await fs.mkdir(path.dirname(generatedPath), { recursive: true });
|
|
194
|
+
await fs.writeFile(generatedPath, dtsContent, "utf8");
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
// Network was unreachable AND no fresh data — make sure at minimum
|
|
198
|
+
// the file exists. If the previous file is on disk, leave it alone.
|
|
199
|
+
try {
|
|
200
|
+
await fs.access(generatedPath);
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
await fs.mkdir(path.dirname(generatedPath), { recursive: true });
|
|
204
|
+
await fs.writeFile(generatedPath, "// Auto-generated by `cef typegen` — do not edit.\n", "utf8");
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
await writeLockfile(lockfilePath, newLock);
|
|
208
|
+
return { generatedPath, lockfilePath };
|
|
209
|
+
}
|
|
210
|
+
//# sourceMappingURL=typegen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typegen.js","sourceRoot":"","sources":["../../src/commands/typegen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAEL,aAAa,EACb,UAAU,GACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,iBAAiB,GAGlB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAGL,YAAY,EACZ,aAAa,GACd,MAAM,wBAAwB,CAAC;AAmBhC;;;;;;;GAOG;AACH,SAAS,UAAU,CAAC,QAAgB,EAAE,YAAoB;IACxD,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,oEAAoE;QACpE,gEAAgE;QAChE,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,gBAAgB,CACvB,GAAoB;IAEpB,MAAM,MAAM,GAA2B,EAAE,CAAC;IAC1C,MAAM,IAAI,GAA2B,EAAE,CAAC;IACxC,KAAK,MAAM,CAAC,IAAI,aAAa,CAAC,GAAG,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,OAAO,CAAC,CAAC;IAE3C,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;AACzC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,UAAU,CAAC"}
|
package/dist/lib.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Programmatic API for `@cef-ai/cli`. Other packages and tests can import the
|
|
3
|
+
* underlying command functions directly without going through the CLI
|
|
4
|
+
* binary. The CLI entry point (`./cli.ts`) wires these into commander.
|
|
5
|
+
*/
|
|
6
|
+
export { cefBuild } from "./commands/build.js";
|
|
7
|
+
export type { CefBuildOptions, CefBuildResult } from "./commands/build.js";
|
|
8
|
+
export { cefTypegen } from "./commands/typegen.js";
|
|
9
|
+
export type { CefTypegenOptions, CefTypegenResult, } from "./commands/typegen.js";
|
|
10
|
+
export { cefInspect } from "./commands/inspect.js";
|
|
11
|
+
export type { CefInspectOptions, CefInspectResult } from "./commands/inspect.js";
|
|
12
|
+
//# sourceMappingURL=lib.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAC/C,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,YAAY,EACV,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/lib.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Programmatic API for `@cef-ai/cli`. Other packages and tests can import the
|
|
3
|
+
* underlying command functions directly without going through the CLI
|
|
4
|
+
* binary. The CLI entry point (`./cli.ts`) wires these into commander.
|
|
5
|
+
*/
|
|
6
|
+
export { cefBuild } from "./commands/build.js";
|
|
7
|
+
export { cefTypegen } from "./commands/typegen.js";
|
|
8
|
+
export { cefInspect } from "./commands/inspect.js";
|
|
9
|
+
//# sourceMappingURL=lib.js.map
|
package/dist/lib.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.js","sourceRoot":"","sources":["../src/lib.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAMnD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsed slice of `model.json` we care about. Per `agent-sdk.md` §5 a model
|
|
3
|
+
* spec also carries `name` / `version` etc., but for typegen we only need
|
|
4
|
+
* the I/O schemas.
|
|
5
|
+
*/
|
|
6
|
+
export interface ModelSpec {
|
|
7
|
+
/** Alias under which the agent declares this model in `cef.config.ts`. */
|
|
8
|
+
alias: string;
|
|
9
|
+
input: unknown;
|
|
10
|
+
output: unknown;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Parsed slice of a peer agent's `manifest.json`. Per the contract §2.1 a
|
|
14
|
+
* peer's `publishes[]` is what *consumers* react to, so those become the
|
|
15
|
+
* payload types in `KnownEventTypes`. (`handles[]` would feed the inverse
|
|
16
|
+
* relationship — payload types for `ctx.publish(toPeer, ...)` — which we
|
|
17
|
+
* defer to a later iteration.)
|
|
18
|
+
*/
|
|
19
|
+
export interface PeerSpec {
|
|
20
|
+
/** Alias under which the agent declares this peer in `cef.config.ts`. */
|
|
21
|
+
alias: string;
|
|
22
|
+
publishes: Array<{
|
|
23
|
+
type: string;
|
|
24
|
+
schema?: unknown;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Convert a snake_case / kebab-case / mixed identifier into PascalCase.
|
|
29
|
+
*
|
|
30
|
+
* Used for two things:
|
|
31
|
+
* - model alias → `ChatInput` / `ChatOutput` interface names
|
|
32
|
+
* - event type → `ResearchComplete` payload interface names
|
|
33
|
+
*
|
|
34
|
+
* We strip non-alphanumeric runs and uppercase the first letter of each
|
|
35
|
+
* remaining segment. Leading digits get a `_` prefix so the result is a
|
|
36
|
+
* valid TS identifier.
|
|
37
|
+
*/
|
|
38
|
+
export declare function pascalCase(s: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Build the full `.cef/generated.d.ts` content from the fetched model and
|
|
41
|
+
* peer specs.
|
|
42
|
+
*
|
|
43
|
+
* Output structure:
|
|
44
|
+
* 1. Banner.
|
|
45
|
+
* 2. `export interface <Alias>Input { ... }` / `<Alias>Output { ... }`
|
|
46
|
+
* per model.
|
|
47
|
+
* 3. `export interface <PascalCasedEventType> { ... }` per peer-published
|
|
48
|
+
* event that carries a JSON schema.
|
|
49
|
+
* 4. `declare module "@cef-ai/agent-sdk"` block augmenting `KnownEventTypes`
|
|
50
|
+
* with `"<event_type>": <PascalCasedEventType>` entries.
|
|
51
|
+
*
|
|
52
|
+
* Models augmentation (so `ctx.models[alias]` becomes typed) is intentionally
|
|
53
|
+
* deferred to a follow-up — the agent-sdk surface for that needs a
|
|
54
|
+
* `KnownModels` map analogous to `KnownEventTypes`, which doesn't exist yet.
|
|
55
|
+
*/
|
|
56
|
+
export declare function buildGeneratedDts(models: ModelSpec[], peers: PeerSpec[]): Promise<string>;
|
|
57
|
+
//# sourceMappingURL=augment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"augment.d.ts","sourceRoot":"","sources":["../../src/typegen/augment.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,SAAS;IACxB,0EAA0E;IAC1E,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,QAAQ;IACvB,yEAAyE;IACzE,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;CACtD;AAMD;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAO5C;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,SAAS,EAAE,EACnB,KAAK,EAAE,QAAQ,EAAE,GAChB,OAAO,CAAC,MAAM,CAAC,CAiDjB"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { schemaToTsInterface } from "./schema-to-ts.js";
|
|
2
|
+
const HEADER = `// Auto-generated by \`cef typegen\` — do not edit.
|
|
3
|
+
// To regenerate: run \`cef typegen\`.
|
|
4
|
+
`;
|
|
5
|
+
/**
|
|
6
|
+
* Convert a snake_case / kebab-case / mixed identifier into PascalCase.
|
|
7
|
+
*
|
|
8
|
+
* Used for two things:
|
|
9
|
+
* - model alias → `ChatInput` / `ChatOutput` interface names
|
|
10
|
+
* - event type → `ResearchComplete` payload interface names
|
|
11
|
+
*
|
|
12
|
+
* We strip non-alphanumeric runs and uppercase the first letter of each
|
|
13
|
+
* remaining segment. Leading digits get a `_` prefix so the result is a
|
|
14
|
+
* valid TS identifier.
|
|
15
|
+
*/
|
|
16
|
+
export function pascalCase(s) {
|
|
17
|
+
const parts = s.split(/[^A-Za-z0-9]+/).filter(Boolean);
|
|
18
|
+
if (parts.length === 0)
|
|
19
|
+
return "_";
|
|
20
|
+
const joined = parts
|
|
21
|
+
.map((p) => p.charAt(0).toUpperCase() + p.slice(1))
|
|
22
|
+
.join("");
|
|
23
|
+
return /^[0-9]/.test(joined) ? "_" + joined : joined;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Build the full `.cef/generated.d.ts` content from the fetched model and
|
|
27
|
+
* peer specs.
|
|
28
|
+
*
|
|
29
|
+
* Output structure:
|
|
30
|
+
* 1. Banner.
|
|
31
|
+
* 2. `export interface <Alias>Input { ... }` / `<Alias>Output { ... }`
|
|
32
|
+
* per model.
|
|
33
|
+
* 3. `export interface <PascalCasedEventType> { ... }` per peer-published
|
|
34
|
+
* event that carries a JSON schema.
|
|
35
|
+
* 4. `declare module "@cef-ai/agent-sdk"` block augmenting `KnownEventTypes`
|
|
36
|
+
* with `"<event_type>": <PascalCasedEventType>` entries.
|
|
37
|
+
*
|
|
38
|
+
* Models augmentation (so `ctx.models[alias]` becomes typed) is intentionally
|
|
39
|
+
* deferred to a follow-up — the agent-sdk surface for that needs a
|
|
40
|
+
* `KnownModels` map analogous to `KnownEventTypes`, which doesn't exist yet.
|
|
41
|
+
*/
|
|
42
|
+
export async function buildGeneratedDts(models, peers) {
|
|
43
|
+
const sections = [HEADER];
|
|
44
|
+
// 1. Per-model I/O interfaces.
|
|
45
|
+
if (models.length > 0) {
|
|
46
|
+
sections.push("// ---- Models ----");
|
|
47
|
+
for (const m of models) {
|
|
48
|
+
const base = pascalCase(m.alias);
|
|
49
|
+
const inputTs = await schemaToTsInterface(`${base}Input`, m.input);
|
|
50
|
+
const outputTs = await schemaToTsInterface(`${base}Output`, m.output);
|
|
51
|
+
sections.push(inputTs);
|
|
52
|
+
sections.push(outputTs);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// 2. Per-peer-event payload interfaces + collect KnownEventTypes entries.
|
|
56
|
+
const knownEvents = [];
|
|
57
|
+
if (peers.length > 0) {
|
|
58
|
+
sections.push("// ---- Peer events ----");
|
|
59
|
+
for (const p of peers) {
|
|
60
|
+
for (const pub of p.publishes) {
|
|
61
|
+
const tsName = pascalCase(pub.type);
|
|
62
|
+
if (pub.schema) {
|
|
63
|
+
const ts = await schemaToTsInterface(tsName, pub.schema);
|
|
64
|
+
sections.push(ts);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// No schema → fall back to `unknown` payload.
|
|
68
|
+
sections.push(`export type ${tsName} = unknown;`);
|
|
69
|
+
}
|
|
70
|
+
knownEvents.push({ eventType: pub.type, tsName });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
// 3. Module augmentation block.
|
|
75
|
+
if (knownEvents.length > 0) {
|
|
76
|
+
const lines = knownEvents
|
|
77
|
+
.map(({ eventType, tsName }) => ` ${JSON.stringify(eventType)}: ${tsName};`)
|
|
78
|
+
.join("\n");
|
|
79
|
+
sections.push(`declare module "@cef-ai/agent-sdk" {
|
|
80
|
+
interface KnownEventTypes {
|
|
81
|
+
${lines}
|
|
82
|
+
}
|
|
83
|
+
}`);
|
|
84
|
+
}
|
|
85
|
+
return sections.join("\n\n") + "\n";
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=augment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"augment.js","sourceRoot":"","sources":["../../src/typegen/augment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AA2BxD,MAAM,MAAM,GAAG;;CAEd,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,UAAU,CAAC,CAAS;IAClC,MAAM,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC,eAAe,CAAC,CA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AAG,CAAC,EAAE,CAAC;QACrB,QAAQ,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC;QAC1C,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;YACtB,KAAK,MAAM,GAAG,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;gBAC9B,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;gBACpC,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;oBACf,MAAM,EAAE,GAAG,MAAM,mBAAmB,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;oBACzD,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBACpB,CAAC;qBAAM,CAAC;oBACN,8CAA8C;oBAC9C,QAAQ,CAAC,IAAI,CAAC,eAAe,MAAM,aAAa,CAAC,CAAC;gBACpD,CAAC;gBACD,WAAW,CAAC,IAAI,CAAC,EAAE,SAAS,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;YACpD,CAAC;QACH,CAAC;IACH,CAAC;IAED,gCAAgC;IAChC,IAAI,WAAW,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC3B,MAAM,KAAK,GAAG,WAAW;aACtB,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,KAAK,MAAM,GAAG,CAAC;aAC9E,IAAI,CAAC,IAAI,CAAC,CAAC;QACd,QAAQ,CAAC,IAAI,CACX;;EAEJ,KAAK;;EAEL,CACG,CAAC;IACJ,CAAC;IAED,OAAO,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;AACtC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Result of a single typegen fetch. The body is kept verbatim so the
|
|
3
|
+
* caller can hash exactly what came over the wire (we use the raw bytes
|
|
4
|
+
* for the lockfile integrity field — re-stringifying after parse would
|
|
5
|
+
* be lossy and order-sensitive).
|
|
6
|
+
*/
|
|
7
|
+
export interface FetchResult {
|
|
8
|
+
/** Raw response body as text. */
|
|
9
|
+
body: string;
|
|
10
|
+
/** `JSON.parse(body)` result. */
|
|
11
|
+
parsed: unknown;
|
|
12
|
+
/** Final URL after redirects (Node's `fetch` exposes this on `Response.url`). */
|
|
13
|
+
resolvedUrl: string;
|
|
14
|
+
/** `sha256-<base64(sha256(body))>` integrity tag — matches lockfile §C.5 form. */
|
|
15
|
+
integrity: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* GET `<baseUrl>/<suffix>` and validate the response. Used by `cef typegen`
|
|
19
|
+
* to fetch model and peer-agent manifests declared in `cef.config.ts`.
|
|
20
|
+
*
|
|
21
|
+
* - Redirects are followed transparently (Node's built-in `fetch` does this
|
|
22
|
+
* by default with `redirect: "follow"`).
|
|
23
|
+
* - Content-Type is required to include `json` — anything else (HTML
|
|
24
|
+
* error page, plain text) is treated as a typegen failure rather than
|
|
25
|
+
* blindly trying to JSON.parse the bytes.
|
|
26
|
+
* - Non-2xx status codes throw with a `[cef typegen] fetch <url> → <status>`
|
|
27
|
+
* message so the CLI surfaces the failing URL to the author.
|
|
28
|
+
*/
|
|
29
|
+
export declare function fetchJson(baseUrl: string, suffix: "model.json" | "manifest.json"): Promise<FetchResult>;
|
|
30
|
+
//# sourceMappingURL=fetch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../src/typegen/fetch.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,iCAAiC;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,iCAAiC;IACjC,MAAM,EAAE,OAAO,CAAC;IAChB,iFAAiF;IACjF,WAAW,EAAE,MAAM,CAAC;IACpB,kFAAkF;IAClF,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAsB,SAAS,CAC7B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,YAAY,GAAG,eAAe,GACrC,OAAO,CAAC,WAAW,CAAC,CA+BtB"}
|