@cef-ai/cli 1.5.0 → 1.7.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/dist/cli-program.d.ts +6 -5
- package/dist/cli-program.d.ts.map +1 -1
- package/dist/cli-program.js +66 -17
- package/dist/cli-program.js.map +1 -1
- package/dist/commands/build.d.ts +11 -0
- package/dist/commands/build.d.ts.map +1 -1
- package/dist/commands/build.js +48 -8
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/dev.d.ts +61 -0
- package/dist/commands/dev.d.ts.map +1 -0
- package/dist/commands/dev.js +239 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +33 -4
- package/dist/commands/init.js.map +1 -1
- package/dist/lib/env.d.ts +71 -0
- package/dist/lib/env.d.ts.map +1 -0
- package/dist/lib/env.js +78 -0
- package/dist/lib/env.js.map +1 -0
- package/dist/lib/widget-manifest.d.ts +48 -0
- package/dist/lib/widget-manifest.d.ts.map +1 -0
- package/dist/lib/widget-manifest.js +91 -0
- package/dist/lib/widget-manifest.js.map +1 -0
- package/dist/lib/widget-runtime-bundle.d.ts +7 -0
- package/dist/lib/widget-runtime-bundle.d.ts.map +1 -0
- package/dist/lib/widget-runtime-bundle.js +31 -0
- package/dist/lib/widget-runtime-bundle.js.map +1 -0
- package/dist/lib.d.ts +4 -0
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +2 -0
- package/dist/lib.js.map +1 -1
- package/package.json +4 -3
- package/templates/hello-world/cef.config.ts +38 -3
- package/templates/hello-world/package.json +6 -0
- package/templates/hello-world/src/agent.ts +28 -10
- package/templates/hello-world/test/agent.test.ts +13 -0
- package/templates/hello-world/tsconfig.json +1 -1
- package/templates/hello-world/widgets/hello/app.js +117 -7
- package/templates/hello-world/widgets/hello/index.html +20 -0
- package/templates/hello-world/widgets/hello/hello.html +0 -5
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `cef dev [widgetId]` — local widget dev server.
|
|
3
|
+
*
|
|
4
|
+
* Serves one widget from `cef.config.ts` on localhost so a developer can test
|
|
5
|
+
* it in a real browser. The page is served top-level (no host iframe), so
|
|
6
|
+
* `@cef-ai/widget-runtime`'s STANDALONE path runs automatically: it opens the
|
|
7
|
+
* interactive Cere embed-wallet (built from the baked `manifest.wallet`), the
|
|
8
|
+
* user connects, and the widget queries their dev vault — exactly like the
|
|
9
|
+
* production standalone link.
|
|
10
|
+
*
|
|
11
|
+
* The server:
|
|
12
|
+
* - serves `/widget-runtime.js` from the resolved workspace runtime bundle,
|
|
13
|
+
* - serves the entry HTML with `injectWidgetBridge` applied on every request
|
|
14
|
+
* (so edits to the entry are reflected on refresh),
|
|
15
|
+
* - serves any other file from the widget `dir` (static),
|
|
16
|
+
* - watches `dir` and live-reloads the browser on change (SSE; watch mode).
|
|
17
|
+
*
|
|
18
|
+
* The interactive browser auth loop is NOT headless-testable; unit tests cover
|
|
19
|
+
* the static serving (injected entry HTML, the runtime file, and a 404).
|
|
20
|
+
*/
|
|
21
|
+
import http from "node:http";
|
|
22
|
+
import fs from "node:fs";
|
|
23
|
+
import fsp from "node:fs/promises";
|
|
24
|
+
import path from "node:path";
|
|
25
|
+
import { injectWidgetBridge } from "@cef-ai/widget-runtime/build-tools";
|
|
26
|
+
import { flattenAgents, loadConfig } from "../build/load-config.js";
|
|
27
|
+
import { buildWidgetManifestForDecl } from "../lib/widget-manifest.js";
|
|
28
|
+
import { resolveWidgetRuntimeBundle, WIDGET_RUNTIME_BUNDLE_BASENAME, } from "../lib/widget-runtime-bundle.js";
|
|
29
|
+
const RUNTIME_ROUTE = `/${WIDGET_RUNTIME_BUNDLE_BASENAME}`;
|
|
30
|
+
/** SSE endpoint the injected live-reload client subscribes to (watch mode). */
|
|
31
|
+
const RELOAD_ROUTE = "/__cef_dev_reload";
|
|
32
|
+
const CONTENT_TYPES = {
|
|
33
|
+
".html": "text/html; charset=utf-8",
|
|
34
|
+
".htm": "text/html; charset=utf-8",
|
|
35
|
+
".js": "text/javascript; charset=utf-8",
|
|
36
|
+
".mjs": "text/javascript; charset=utf-8",
|
|
37
|
+
".css": "text/css; charset=utf-8",
|
|
38
|
+
".json": "application/json; charset=utf-8",
|
|
39
|
+
".svg": "image/svg+xml",
|
|
40
|
+
".png": "image/png",
|
|
41
|
+
".jpg": "image/jpeg",
|
|
42
|
+
".jpeg": "image/jpeg",
|
|
43
|
+
".gif": "image/gif",
|
|
44
|
+
".ico": "image/x-icon",
|
|
45
|
+
".webp": "image/webp",
|
|
46
|
+
".wasm": "application/wasm",
|
|
47
|
+
".map": "application/json; charset=utf-8",
|
|
48
|
+
};
|
|
49
|
+
function contentType(file) {
|
|
50
|
+
return CONTENT_TYPES[path.extname(file).toLowerCase()] ?? "application/octet-stream";
|
|
51
|
+
}
|
|
52
|
+
function resolveWidget(widgets, widgetId) {
|
|
53
|
+
if (widgets.length === 0) {
|
|
54
|
+
throw new Error("[cef dev] no widgets declared in cef.config.ts (add a `widgets[]` entry).");
|
|
55
|
+
}
|
|
56
|
+
if (widgetId === undefined)
|
|
57
|
+
return widgets[0];
|
|
58
|
+
const found = widgets.find((w) => w.id === widgetId);
|
|
59
|
+
if (!found) {
|
|
60
|
+
throw new Error(`[cef dev] widget "${widgetId}" not found. Declared: ${widgets
|
|
61
|
+
.map((w) => w.id)
|
|
62
|
+
.join(", ")}.`);
|
|
63
|
+
}
|
|
64
|
+
return found;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Start the dev server. Resolves once it is listening; the caller must
|
|
68
|
+
* `close()` it. Loads config, resolves the widget, builds the manifest, and
|
|
69
|
+
* wires the request handler + (optionally) a dir watcher.
|
|
70
|
+
*/
|
|
71
|
+
export async function cefDev(opts = {}) {
|
|
72
|
+
const cwd = opts.cwd ? path.resolve(opts.cwd) : process.cwd();
|
|
73
|
+
const configPath = opts.configPath
|
|
74
|
+
? path.resolve(cwd, opts.configPath)
|
|
75
|
+
: path.join(cwd, "cef.config.ts");
|
|
76
|
+
const configDir = path.dirname(configPath);
|
|
77
|
+
const host = opts.host ?? "127.0.0.1";
|
|
78
|
+
const log = opts.logger ?? ((m) => console.log(m));
|
|
79
|
+
const watch = opts.watch ?? true;
|
|
80
|
+
// Live reload (watch mode only): the served page opens an SSE stream on
|
|
81
|
+
// RELOAD_ROUTE; the file watcher pushes "reload" on change → the injected
|
|
82
|
+
// client calls location.reload(). Full-page reload (not HMR) — right level
|
|
83
|
+
// for a build-less HTML+JS widget. Disabled when `watch` is off (tests).
|
|
84
|
+
const liveReload = watch;
|
|
85
|
+
const reloadClients = new Set();
|
|
86
|
+
const reloadSnippet = liveReload
|
|
87
|
+
? `\n<script>/* cef dev live-reload */try{new EventSource(${JSON.stringify(RELOAD_ROUTE)}).onmessage=function(){location.reload()};}catch(e){}</script>\n`
|
|
88
|
+
: "";
|
|
89
|
+
const config = await loadConfig(configPath, configDir);
|
|
90
|
+
const leaves = flattenAgents(config);
|
|
91
|
+
// Collect every declared widget across leaf agents, remembering its agent.
|
|
92
|
+
const owners = [];
|
|
93
|
+
for (const agent of leaves) {
|
|
94
|
+
for (const w of agent.widgets ?? []) {
|
|
95
|
+
owners.push({ widget: w, alias: agent.alias ?? agent.id });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const chosen = resolveWidget(owners.map((o) => o.widget), opts.widgetId);
|
|
99
|
+
const owner = owners.find((o) => o.widget === chosen);
|
|
100
|
+
const dir = path.resolve(configDir, chosen.dir);
|
|
101
|
+
const { manifest, env, warnings } = buildWidgetManifestForDecl({
|
|
102
|
+
widget: chosen,
|
|
103
|
+
alias: owner.alias,
|
|
104
|
+
...(opts.env !== undefined ? { env: opts.env } : {}),
|
|
105
|
+
...(opts.asPubkey !== undefined ? { asPubkey: opts.asPubkey } : {}),
|
|
106
|
+
});
|
|
107
|
+
for (const msg of warnings)
|
|
108
|
+
log(`[cef dev] warning: ${msg}`);
|
|
109
|
+
const runtimeBundle = resolveWidgetRuntimeBundle();
|
|
110
|
+
if (!runtimeBundle) {
|
|
111
|
+
throw new Error(`[cef dev] @cef-ai/widget-runtime's dist/${WIDGET_RUNTIME_BUNDLE_BASENAME} ` +
|
|
112
|
+
`could not be resolved — build the widget-runtime package first.`);
|
|
113
|
+
}
|
|
114
|
+
const entryRoutes = new Set(["/", `/${chosen.entry}`]);
|
|
115
|
+
const server = http.createServer((req, res) => {
|
|
116
|
+
void handleRequest(req, res).catch((err) => {
|
|
117
|
+
res.statusCode = 500;
|
|
118
|
+
res.end(`500 ${err instanceof Error ? err.message : String(err)}`);
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
async function handleRequest(req, res) {
|
|
122
|
+
const rawPath = decodeURIComponent((req.url ?? "/").split("?")[0]);
|
|
123
|
+
if (rawPath === RUNTIME_ROUTE) {
|
|
124
|
+
const body = await fsp.readFile(runtimeBundle);
|
|
125
|
+
res.writeHead(200, { "content-type": contentType(RUNTIME_ROUTE) });
|
|
126
|
+
res.end(body);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
// Live-reload SSE stream: held open; the watcher writes "data: reload".
|
|
130
|
+
if (liveReload && rawPath === RELOAD_ROUTE) {
|
|
131
|
+
res.writeHead(200, {
|
|
132
|
+
"content-type": "text/event-stream",
|
|
133
|
+
"cache-control": "no-cache",
|
|
134
|
+
connection: "keep-alive",
|
|
135
|
+
});
|
|
136
|
+
res.write("retry: 1000\n\n");
|
|
137
|
+
reloadClients.add(res);
|
|
138
|
+
req.on("close", () => reloadClients.delete(res));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
// Entry HTML → inject the manifest + runtime <script> fresh each request.
|
|
142
|
+
if (entryRoutes.has(rawPath)) {
|
|
143
|
+
const html = await fsp.readFile(path.join(dir, chosen.entry), "utf8");
|
|
144
|
+
const injected = injectWidgetBridge(html, {
|
|
145
|
+
manifest,
|
|
146
|
+
runtimeUrl: RUNTIME_ROUTE,
|
|
147
|
+
});
|
|
148
|
+
res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
|
|
149
|
+
res.end(injected + reloadSnippet);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
// Static file from the widget dir (path-traversal guarded).
|
|
153
|
+
const rel = rawPath.replace(/^\/+/, "");
|
|
154
|
+
const target = path.resolve(dir, rel);
|
|
155
|
+
if (target !== dir && !target.startsWith(dir + path.sep)) {
|
|
156
|
+
res.writeHead(403).end("403 Forbidden");
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
let stat = null;
|
|
160
|
+
try {
|
|
161
|
+
stat = await fsp.stat(target);
|
|
162
|
+
}
|
|
163
|
+
catch {
|
|
164
|
+
stat = null;
|
|
165
|
+
}
|
|
166
|
+
if (!stat || !stat.isFile()) {
|
|
167
|
+
res.writeHead(404, { "content-type": "text/plain; charset=utf-8" });
|
|
168
|
+
res.end(`404 Not Found: ${rawPath}`);
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
const body = await fsp.readFile(target);
|
|
172
|
+
res.writeHead(200, { "content-type": contentType(target) });
|
|
173
|
+
res.end(body);
|
|
174
|
+
}
|
|
175
|
+
await new Promise((resolve) => {
|
|
176
|
+
server.listen(opts.port ?? 0, host, () => resolve());
|
|
177
|
+
});
|
|
178
|
+
const port = server.address().port;
|
|
179
|
+
const url = `http://${host}:${port}/`;
|
|
180
|
+
let watcher;
|
|
181
|
+
let reloadTimer;
|
|
182
|
+
if (watch) {
|
|
183
|
+
try {
|
|
184
|
+
watcher = fs.watch(dir, { recursive: true }, (_event, file) => {
|
|
185
|
+
// Debounce: a single save often fires several fs events.
|
|
186
|
+
if (reloadTimer)
|
|
187
|
+
clearTimeout(reloadTimer);
|
|
188
|
+
reloadTimer = setTimeout(() => {
|
|
189
|
+
log(`[cef dev] changed: ${file ?? "(dir)"} — reloading browser`);
|
|
190
|
+
for (const client of reloadClients) {
|
|
191
|
+
try {
|
|
192
|
+
client.write("data: reload\n\n");
|
|
193
|
+
}
|
|
194
|
+
catch {
|
|
195
|
+
reloadClients.delete(client);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}, 80);
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
// Some platforms don't support recursive watch; non-fatal.
|
|
203
|
+
log(`[cef dev] file watching unavailable on this platform`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
log(`[cef dev] serving widget "${chosen.id}" (env ${env}) from ${dir}`);
|
|
207
|
+
log(`[cef dev] open ${url}`);
|
|
208
|
+
if (liveReload) {
|
|
209
|
+
log(`[cef dev] live reload on — edits to the widget refresh the browser`);
|
|
210
|
+
}
|
|
211
|
+
log(`[cef dev] the page runs standalone — connect your Cere wallet in the browser to query your ${env} vault`);
|
|
212
|
+
return {
|
|
213
|
+
server,
|
|
214
|
+
url,
|
|
215
|
+
port,
|
|
216
|
+
host,
|
|
217
|
+
widgetId: chosen.id,
|
|
218
|
+
dir,
|
|
219
|
+
manifest,
|
|
220
|
+
warnings,
|
|
221
|
+
close: () => new Promise((resolve, reject) => {
|
|
222
|
+
if (reloadTimer)
|
|
223
|
+
clearTimeout(reloadTimer);
|
|
224
|
+
watcher?.close();
|
|
225
|
+
// End held-open SSE streams so server.close() can complete.
|
|
226
|
+
for (const client of reloadClients) {
|
|
227
|
+
try {
|
|
228
|
+
client.end();
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
/* already gone */
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
reloadClients.clear();
|
|
235
|
+
server.close((err) => (err ? reject(err) : resolve()));
|
|
236
|
+
}),
|
|
237
|
+
};
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,IAAI,MA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,IAAI;QACJ,IAAI;QACJ,QAAQ,EAAE,MAAM,CAAC,EAAE;QACnB,GAAG;QACH,QAAQ;QACR,QAAQ;QACR,KAAK,EAAE,GAAG,EAAE,CACV,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACpC,IAAI,WAAW;gBAAE,YAAY,CAAC,WAAW,CAAC,CAAC;YAC3C,OAAO,EAAE,KAAK,EAAE,CAAC;YACjB,4DAA4D;YAC5D,KAAK,MAAM,MAAM,IAAI,aAAa,EAAE,CAAC;gBACnC,IAAI,CAAC;oBACH,MAAM,CAAC,GAAG,EAAE,CAAC;gBACf,CAAC;gBAAC,MAAM,CAAC;oBACP,kBAAkB;gBACpB,CAAC;YACH,CAAC;YACD,aAAa,CAAC,KAAK,EAAE,CAAC;YACtB,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACzD,CAAC,CAAC;KACL,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAwBA,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,CAAC;AAE7D,MAAM,WAAW,cAAc;IAC7B,kFAAkF;IAClF,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,6EAA6E;IAC7E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,8DAA8D;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,0EAA0E;IAC1E,EAAE,CAAC,EAAE,cAAc,CAAC;IACpB,4DAA4D;IAC5D,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,4DAA4D;IAC5D,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,oDAAoD;IACpD,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,iFAAiF;IACjF,EAAE,CAAC,EAAE,OAAO,CAAC;IACb,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,kDAAkD;IAClD,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,EAAE,EAAE,cAAc,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,OAAO,CAAC;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAyBD,wBAAgB,oBAAoB,IAAI,cAAc,CAOrD;AAuDD,wBAAsB,OAAO,CAAC,IAAI,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC,CAgI/E"}
|
package/dist/commands/init.js
CHANGED
|
@@ -1,10 +1,22 @@
|
|
|
1
|
-
import { execFile } from "node:child_process";
|
|
1
|
+
import { execFile, spawn } from "node:child_process";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import * as readline from "node:readline/promises";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { promisify } from "node:util";
|
|
7
7
|
const execFileAsync = promisify(execFile);
|
|
8
|
+
/**
|
|
9
|
+
* Run a command with its stdio inherited so the child's own progress (e.g.
|
|
10
|
+
* `pnpm install`'s live "resolved/downloaded" output) streams straight to the
|
|
11
|
+
* terminal — real feedback, not a buffered one-liner. Rejects on non-zero exit.
|
|
12
|
+
*/
|
|
13
|
+
function runStreaming(cmd, args, cwd) {
|
|
14
|
+
return new Promise((resolve, reject) => {
|
|
15
|
+
const child = spawn(cmd, args, { cwd, stdio: "inherit" });
|
|
16
|
+
child.on("error", reject);
|
|
17
|
+
child.on("close", (code) => code === 0 ? resolve() : reject(new Error(`${cmd} exited with ${code}`)));
|
|
18
|
+
});
|
|
19
|
+
}
|
|
8
20
|
/** Files allowed to pre-exist in an otherwise-"empty" target. */
|
|
9
21
|
const SAFE_FILES = new Set([
|
|
10
22
|
".git",
|
|
@@ -99,15 +111,25 @@ export async function cefInit(opts = {}) {
|
|
|
99
111
|
const answer = (await rl.question(`${q} (${def}) `)).trim();
|
|
100
112
|
return answer || def;
|
|
101
113
|
};
|
|
114
|
+
// Progress notes to stderr (interactive runs only — keeps tests/programmatic
|
|
115
|
+
// callers quiet). The `<pm> install` step can take a minute; without these it
|
|
116
|
+
// looks like a hang and gets terminated.
|
|
117
|
+
const note = (msg) => {
|
|
118
|
+
if (interactive)
|
|
119
|
+
process.stderr.write(`${msg}\n`);
|
|
120
|
+
};
|
|
102
121
|
try {
|
|
103
122
|
const dirName = opts.dir ?? (await ask("Project directory", "my-agent"));
|
|
104
123
|
const targetDir = path.resolve(cwd, dirName);
|
|
105
124
|
const projectName = path.basename(targetDir);
|
|
106
|
-
|
|
125
|
+
// Default the agent id from the directory name — no prompt. Override with
|
|
126
|
+
// `--name`, or edit `id` in cef.config.ts later. This keeps `cef init <dir>`
|
|
127
|
+
// fully prompt-free; a bare `cef init` still prompts only for the directory.
|
|
128
|
+
const agentId = slugify(opts.name ?? projectName);
|
|
107
129
|
const pm = opts.pm ?? detectPackageManager();
|
|
108
130
|
const template = opts.template ?? "hello-world";
|
|
109
131
|
const ai = opts.ai ?? true;
|
|
110
|
-
const doInstall = opts.install ??
|
|
132
|
+
const doInstall = opts.install ?? false;
|
|
111
133
|
const doGit = opts.git ?? true;
|
|
112
134
|
const unsafe = await nonEmptyUnsafeEntries(targetDir);
|
|
113
135
|
if (unsafe.length > 0 && !opts.force) {
|
|
@@ -129,6 +151,7 @@ export async function cefInit(opts = {}) {
|
|
|
129
151
|
throw new Error(`[cef init] unknown template "${template}"`);
|
|
130
152
|
}
|
|
131
153
|
const vars = { projectName, agentId };
|
|
154
|
+
note(`\nScaffolding ${projectName}…`);
|
|
132
155
|
const written = [];
|
|
133
156
|
for (const rel of await walk(srcRoot)) {
|
|
134
157
|
const dest = mapDest(rel);
|
|
@@ -141,12 +164,15 @@ export async function cefInit(opts = {}) {
|
|
|
141
164
|
await fs.writeFile(destFile, substitute(raw, vars));
|
|
142
165
|
written.push(dest);
|
|
143
166
|
}
|
|
167
|
+
note(` ✓ ${written.length} files created`);
|
|
144
168
|
let gitInitialized = false;
|
|
145
169
|
if (doGit && !(await insideGitRepo(targetDir))) {
|
|
146
170
|
try {
|
|
171
|
+
note(" initializing git repository…");
|
|
147
172
|
await execFileAsync("git", ["init", "-q"], { cwd: targetDir });
|
|
148
173
|
await execFileAsync("git", ["add", "-A"], { cwd: targetDir });
|
|
149
174
|
gitInitialized = true;
|
|
175
|
+
note(" ✓ git initialized");
|
|
150
176
|
}
|
|
151
177
|
catch {
|
|
152
178
|
gitInitialized = false;
|
|
@@ -155,11 +181,14 @@ export async function cefInit(opts = {}) {
|
|
|
155
181
|
let installed = false;
|
|
156
182
|
if (doInstall) {
|
|
157
183
|
try {
|
|
158
|
-
|
|
184
|
+
note(`\nInstalling dependencies with ${pm}…`);
|
|
185
|
+
// Stream the installer's own output so the user sees real progress.
|
|
186
|
+
await runStreaming(pm, ["install"], targetDir);
|
|
159
187
|
installed = true;
|
|
160
188
|
}
|
|
161
189
|
catch {
|
|
162
190
|
installed = false;
|
|
191
|
+
note(` ! ${pm} install failed — run \`${pm} install\` in the project yourself`);
|
|
163
192
|
}
|
|
164
193
|
}
|
|
165
194
|
const relDir = path.relative(cwd, targetDir) || ".";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,KAAK,QAAQ,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C;;;;GAIG;AACH,SAAS,YAAY,CAAC,GAAW,EAAE,IAAc,EAAE,GAAW;IAC5D,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACrC,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC1D,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAC1B,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CACzB,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,GAAG,GAAG,gBAAgB,IAAI,EAAE,CAAC,CAAC,CACzE,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AA2CD,iEAAiE;AACjE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IACzB,MAAM;IACN,SAAS;IACT,YAAY;IACZ,WAAW;IACX,YAAY;CACb,CAAC,CA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QACH,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,IAAI,GAAG,CAAC;QACpD,MAAM,SAAS,GAAG;YAChB,MAAM,MAAM,EAAE;YACd,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;YACvC,GAAG,EAAE,OAAO;YACZ,GAAG,EAAE,YAAY;YACjB,GAAG,EAAE,uEAAuE;YAC5E,kEAAkE;SACnE,CAAC;QAEF,OAAO;YACL,GAAG,EAAE,SAAS;YACd,OAAO;YACP,WAAW;YACX,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE;YACrB,EAAE;YACF,SAAS;YACT,cAAc;YACd,OAAO,EAAE,EAAE;YACX,QAAQ;YACR,SAAS;SACV,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,EAAE,EAAE,KAAK,EAAE,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment selection shared by `cef push` / `cef deploy` / `cef publish`.
|
|
3
|
+
*
|
|
4
|
+
* A single `--env` (or `$CEF_ENV`) picks a whole environment — the DDC network
|
|
5
|
+
* for `push`, the orchestrator (platform API) URL for `deploy`, and the
|
|
6
|
+
* marketplace URL for `publish`. Individual `--preset` / `--endpoint` /
|
|
7
|
+
* `--marketplace` flags (and their env vars) still override the specific value.
|
|
8
|
+
*
|
|
9
|
+
* Defaults to `dev` so the common loop never accidentally targets mainnet.
|
|
10
|
+
*/
|
|
11
|
+
import type { DdcPreset } from "./ddc.js";
|
|
12
|
+
export type CefEnv = "dev" | "stage" | "prod";
|
|
13
|
+
/**
|
|
14
|
+
* Cere embed-wallet config for a widget's STANDALONE (interactive) auth path.
|
|
15
|
+
* `env` is the embed-wallet `WalletEnvironment`; `appId` is the Cere wallet
|
|
16
|
+
* application id.
|
|
17
|
+
*/
|
|
18
|
+
export interface WidgetWalletConfig {
|
|
19
|
+
appId: string;
|
|
20
|
+
env: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The full set of endpoints for one environment. One flat set per env is used
|
|
24
|
+
* across every command: `cef deploy` uses `orchestrator`; `cef publish` uses
|
|
25
|
+
* `marketplace`; `cef build`/`cef dev` bake `vault`/`gar`/`marketplace`/
|
|
26
|
+
* `s3GatewayAuthInfo`/`rpc` into the widget manifest (what
|
|
27
|
+
* `@cef-ai/widget-runtime` reads at boot to reach the user's vault, the Global
|
|
28
|
+
* Agent Registry, the marketplace, the DDC S3 gateway, and the Cere chain).
|
|
29
|
+
*/
|
|
30
|
+
export interface EnvConfig {
|
|
31
|
+
/** DDC network preset for `cef push`. */
|
|
32
|
+
ddcPreset: DdcPreset;
|
|
33
|
+
/** Orchestrator (platform API) base URL for `cef deploy`. */
|
|
34
|
+
orchestrator: string;
|
|
35
|
+
/** Marketplace base URL for `cef publish` + widget manifests. */
|
|
36
|
+
marketplace: string;
|
|
37
|
+
/** User-vault API base URL (widget manifests / `cef dev`). */
|
|
38
|
+
vault: string;
|
|
39
|
+
/** Global Agent Registry base URL. */
|
|
40
|
+
gar: string;
|
|
41
|
+
/** DDC S3 gateway auth-info URL. */
|
|
42
|
+
s3GatewayAuthInfo: string;
|
|
43
|
+
/** Cere chain RPC endpoint. */
|
|
44
|
+
rpc: string;
|
|
45
|
+
/** Cere embed-wallet config for standalone widget auth. */
|
|
46
|
+
wallet: WidgetWalletConfig;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Cere embed-wallet `appId` for CEF widgets. `cere-widget` is the shared
|
|
50
|
+
* widget app identity (distinct from demo apps like `cef-chat`). Override per
|
|
51
|
+
* deployment via `buildWidgetManifestForDecl`'s `walletAppId` arg or
|
|
52
|
+
* `$CEF_WALLET_APP_ID`.
|
|
53
|
+
*/
|
|
54
|
+
export declare const WIDGET_WALLET_APP_ID = "cere-widget";
|
|
55
|
+
/**
|
|
56
|
+
* Per-environment endpoint table. One flat set of endpoints per env.
|
|
57
|
+
*
|
|
58
|
+
* DDC presets: dev=devnet, stage=testnet, prod=mainnet.
|
|
59
|
+
*
|
|
60
|
+
* `dev` and `stage` (= the `compute.test` cluster) hosts are verified against
|
|
61
|
+
* the cef-chat reference config. `prod` hosts are UNVERIFIED (no prod config
|
|
62
|
+
* on disk) and mirror the pattern — pass `--endpoint` / `--marketplace`
|
|
63
|
+
* explicitly for prod if they're wrong.
|
|
64
|
+
*/
|
|
65
|
+
export declare const ENVIRONMENTS: Record<CefEnv, EnvConfig>;
|
|
66
|
+
export declare const DEFAULT_ENV: CefEnv;
|
|
67
|
+
/** Resolve the selected environment: `--env` flag, else `$CEF_ENV`, else dev. */
|
|
68
|
+
export declare function resolveEnv(flag?: string): CefEnv;
|
|
69
|
+
/** The full endpoint config for the selected environment. */
|
|
70
|
+
export declare function envConfig(flag?: string): EnvConfig;
|
|
71
|
+
//# sourceMappingURL=env.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.d.ts","sourceRoot":"","sources":["../../src/lib/env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,MAAM,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,MAAM,CAAC;AAE9C;;;;GAIG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,yCAAyC;IACzC,SAAS,EAAE,SAAS,CAAC;IACrB,6DAA6D;IAC7D,YAAY,EAAE,MAAM,CAAC;IACrB,iEAAiE;IACjE,WAAW,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,oCAAoC;IACpC,iBAAiB,EAAE,MAAM,CAAC;IAC1B,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,2DAA2D;IAC3D,MAAM,EAAE,kBAAkB,CAAC;CAC5B;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,gBAAgB,CAAC;AAElD;;;;;;;;;GASG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CA2ClD,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,MAAc,CAAC;AAEzC,iFAAiF;AACjF,wBAAgB,UAAU,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAQhD;AAED,6DAA6D;AAC7D,wBAAgB,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAElD"}
|
package/dist/lib/env.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cere embed-wallet `appId` for CEF widgets. `cere-widget` is the shared
|
|
3
|
+
* widget app identity (distinct from demo apps like `cef-chat`). Override per
|
|
4
|
+
* deployment via `buildWidgetManifestForDecl`'s `walletAppId` arg or
|
|
5
|
+
* `$CEF_WALLET_APP_ID`.
|
|
6
|
+
*/
|
|
7
|
+
export const WIDGET_WALLET_APP_ID = "cere-widget";
|
|
8
|
+
/**
|
|
9
|
+
* Per-environment endpoint table. One flat set of endpoints per env.
|
|
10
|
+
*
|
|
11
|
+
* DDC presets: dev=devnet, stage=testnet, prod=mainnet.
|
|
12
|
+
*
|
|
13
|
+
* `dev` and `stage` (= the `compute.test` cluster) hosts are verified against
|
|
14
|
+
* the cef-chat reference config. `prod` hosts are UNVERIFIED (no prod config
|
|
15
|
+
* on disk) and mirror the pattern — pass `--endpoint` / `--marketplace`
|
|
16
|
+
* explicitly for prod if they're wrong.
|
|
17
|
+
*/
|
|
18
|
+
export const ENVIRONMENTS = {
|
|
19
|
+
// All dev endpoints verified against the cef-chat reference app
|
|
20
|
+
// (`cef-chat/.env.example`): the user-vault host is `vault-api.compute…`
|
|
21
|
+
// (not `vault.compute…`).
|
|
22
|
+
dev: {
|
|
23
|
+
ddcPreset: "DEVNET",
|
|
24
|
+
orchestrator: "https://orchestrator.compute.dev.ddcdragon.com/",
|
|
25
|
+
marketplace: "https://agent-marketplace.compute.dev.ddcdragon.com",
|
|
26
|
+
vault: "https://vault-api.compute.dev.ddcdragon.com/",
|
|
27
|
+
gar: "https://gar.compute.dev.ddcdragon.com",
|
|
28
|
+
s3GatewayAuthInfo: "https://ddc-s3-gateway.compute.dev.ddcdragon.com/auth/info",
|
|
29
|
+
rpc: "wss://rpc.devnet.cere.network/ws",
|
|
30
|
+
// Wallet env follows the CEF env. NOTE: cef-chat historically pinned the
|
|
31
|
+
// embed-wallet to `prod` even against dev compute — if the `dev` wallet
|
|
32
|
+
// backend doesn't hold your account, override this or use `--env prod`.
|
|
33
|
+
wallet: { appId: WIDGET_WALLET_APP_ID, env: "dev" },
|
|
34
|
+
},
|
|
35
|
+
// "stage" = the TEST cluster (`compute.test`), verified against
|
|
36
|
+
// `cef-chat/.env.stage`. Not `compute.stage`.
|
|
37
|
+
stage: {
|
|
38
|
+
ddcPreset: "TESTNET",
|
|
39
|
+
orchestrator: "https://orchestrator.compute.test.ddcdragon.com/",
|
|
40
|
+
marketplace: "https://agent-marketplace.compute.test.ddcdragon.com",
|
|
41
|
+
vault: "https://vault-api.compute.test.ddcdragon.com/",
|
|
42
|
+
gar: "https://gar.compute.test.ddcdragon.com",
|
|
43
|
+
s3GatewayAuthInfo: "https://ddc-s3-gateway.compute.test.ddcdragon.com/auth/info",
|
|
44
|
+
rpc: "wss://rpc.testnet.cere.network/ws",
|
|
45
|
+
wallet: { appId: WIDGET_WALLET_APP_ID, env: "stage" },
|
|
46
|
+
},
|
|
47
|
+
// FLAG — prod endpoints are UNVERIFIED (no prod config found on disk; prod
|
|
48
|
+
// may use distinct hosts such as `vault.cere.io` / `marketplace.cere.network`).
|
|
49
|
+
// The `compute.prod.ddcdragon.com` hosts mirror the verified dev/test pattern.
|
|
50
|
+
// Override with explicit `--endpoint` / `--marketplace` for prod.
|
|
51
|
+
prod: {
|
|
52
|
+
ddcPreset: "MAINNET",
|
|
53
|
+
orchestrator: "https://orchestrator.compute.prod.ddcdragon.com/",
|
|
54
|
+
marketplace: "https://agent-marketplace.compute.prod.ddcdragon.com",
|
|
55
|
+
vault: "https://vault-api.compute.prod.ddcdragon.com/",
|
|
56
|
+
gar: "https://gar.compute.prod.ddcdragon.com",
|
|
57
|
+
s3GatewayAuthInfo: "https://ddc-s3-gateway.compute.prod.ddcdragon.com/auth/info",
|
|
58
|
+
rpc: "wss://rpc.mainnet.cere.network/ws",
|
|
59
|
+
wallet: { appId: WIDGET_WALLET_APP_ID, env: "prod" },
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
export const DEFAULT_ENV = "dev";
|
|
63
|
+
/** Resolve the selected environment: `--env` flag, else `$CEF_ENV`, else dev. */
|
|
64
|
+
export function resolveEnv(flag) {
|
|
65
|
+
const chosen = flag ?? process.env.CEF_ENV;
|
|
66
|
+
if (chosen === undefined || chosen === "")
|
|
67
|
+
return DEFAULT_ENV;
|
|
68
|
+
const lc = chosen.toLowerCase();
|
|
69
|
+
if (lc !== "dev" && lc !== "stage" && lc !== "prod") {
|
|
70
|
+
throw new Error(`--env must be dev, stage, or prod (got "${chosen}")`);
|
|
71
|
+
}
|
|
72
|
+
return lc;
|
|
73
|
+
}
|
|
74
|
+
/** The full endpoint config for the selected environment. */
|
|
75
|
+
export function envConfig(flag) {
|
|
76
|
+
return ENVIRONMENTS[resolveEnv(flag)];
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=env.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"env.js","sourceRoot":"","sources":["../../src/lib/env.ts"],"names":[],"mappings":"AAmDA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAC;AAElD;;;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,CAAC,GAAG,CAAC,OAAO,CAAC;IAC3C,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,EAAE;QAAE,OAAO,WAAW,CAAC;IAC9D,MAAM,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;IAChC,IAAI,EAAE,KAAK,KAAK,IAAI,EAAE,KAAK,OAAO,IAAI,EAAE,KAAK,MAAM,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,2CAA2C,MAAM,IAAI,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,EAAE,CAAC;AACZ,CAAC;AAED,6DAA6D;AAC7D,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,OAAO,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Widget manifest builder (build-time tooling).
|
|
3
|
+
*
|
|
4
|
+
* `@cef-ai/widget-runtime` *reads* a `WidgetManifest` at boot but never builds
|
|
5
|
+
* one — that is the CLI's job. This module assembles the arguments for the
|
|
6
|
+
* runtime's `buildWidgetManifest` from a `cef.config.ts` widget declaration, the
|
|
7
|
+
* resolved `--env` endpoints (see `./env.ts`), and the agent's AS pubkey.
|
|
8
|
+
*
|
|
9
|
+
* Used by both `cef build` (bakes the manifest into `dist/…/widgets/<id>/`) and
|
|
10
|
+
* `cef dev` (serves it inline), so the embedded and standalone paths get an
|
|
11
|
+
* identical manifest.
|
|
12
|
+
*/
|
|
13
|
+
import { type WidgetManifest } from "@cef-ai/widget-runtime/build-tools";
|
|
14
|
+
import type { ConfigWidget } from "../build/load-config.js";
|
|
15
|
+
import { type CefEnv } from "./env.js";
|
|
16
|
+
export interface BuildWidgetManifestArgs {
|
|
17
|
+
/** The widget declaration from `cef.config.ts`. */
|
|
18
|
+
widget: ConfigWidget;
|
|
19
|
+
/** Agent alias — the `cef.config.ts` `id`. Forms the manifest `agentId`. */
|
|
20
|
+
alias: string;
|
|
21
|
+
/** `--env` flag (falls back to `$CEF_ENV`, then `dev`). */
|
|
22
|
+
env?: string;
|
|
23
|
+
/**
|
|
24
|
+
* On-platform AS pubkey (bare hex). When present the manifest `agentId` is
|
|
25
|
+
* `<asPubkey>:<alias>`; when absent it falls back to the alias alone and a
|
|
26
|
+
* warning is emitted (queries need the full composite id at runtime).
|
|
27
|
+
*/
|
|
28
|
+
asPubkey?: string;
|
|
29
|
+
/** Override the wallet `appId` from the env table (e.g. `$CEF_WALLET_APP_ID`). */
|
|
30
|
+
walletAppId?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface BuildWidgetManifestOutput {
|
|
33
|
+
manifest: WidgetManifest;
|
|
34
|
+
/** Resolved env the endpoints came from. */
|
|
35
|
+
env: CefEnv;
|
|
36
|
+
/** Non-fatal advisories (missing asPubkey, dropped kind, …). */
|
|
37
|
+
warnings: string[];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Build a `WidgetManifest` for one widget declaration + resolved env.
|
|
41
|
+
*
|
|
42
|
+
* Deliberately tolerant: an unknown `kind` (WidgetDecl.kind is free-form) is
|
|
43
|
+
* dropped with a warning rather than throwing, so a `cef build` never fails on
|
|
44
|
+
* a widget the runtime doesn't render as a config-driven kind — the widget can
|
|
45
|
+
* still query the cubby via `window.WidgetRuntime`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function buildWidgetManifestForDecl(args: BuildWidgetManifestArgs): BuildWidgetManifestOutput;
|
|
48
|
+
//# sourceMappingURL=widget-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"widget-manifest.d.ts","sourceRoot":"","sources":["../../src/lib/widget-manifest.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAEL,KAAK,cAAc,EACpB,MAAM,oCAAoC,CAAC;AAG5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAyB,KAAK,MAAM,EAAE,MAAM,UAAU,CAAC;AAc9D,MAAM,WAAW,uBAAuB;IACtC,mDAAmD;IACnD,MAAM,EAAE,YAAY,CAAC;IACrB,4EAA4E;IAC5E,KAAK,EAAE,MAAM,CAAC;IACd,2DAA2D;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kFAAkF;IAClF,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,cAAc,CAAC;IACzB,4CAA4C;IAC5C,GAAG,EAAE,MAAM,CAAC;IACZ,gEAAgE;IAChE,QAAQ,EAAE,MAAM,EAAE,CAAC;CACpB;AAED;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,uBAAuB,GAC5B,yBAAyB,CA8D3B"}
|