codeden 0.1.0 → 0.1.1
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 +18 -0
- package/dist/cli.js +214 -56089
- package/dist/cli.js.map +1 -1
- package/dist/main-BF0aQ9U8.js +57012 -0
- package/dist/main-BF0aQ9U8.js.map +1 -0
- package/dist/main-DaGFUbbW.js +59 -0
- package/dist/main-DaGFUbbW.js.map +1 -0
- package/dist/{runner-CoJjefjZ.js → runner-D8m3WdtS.js} +232 -98
- package/dist/runner-D8m3WdtS.js.map +1 -0
- package/dist/runner.js +16 -52
- package/dist/runner.js.map +1 -1
- package/dist/web/assets/{core-DpRfWkWN.js → core-BmMheb4i.js} +1 -1
- package/dist/web/assets/engine-oniguruma-CVzqqUIi.js +1 -0
- package/dist/web/assets/{highlighted-body-JLMTFACH-H03v731F.js → highlighted-body-JLMTFACH-nUCrIe8P.js} +1 -1
- package/dist/web/assets/{highlights-Dz1cMTeO.js → highlights-CdGBlIcw.js} +1 -1
- package/dist/web/assets/{index-BG4dO7iI.js → index-DKWZjMF1.js} +205 -205
- package/dist/web/assets/index-DfoaM4E6.css +1 -0
- package/dist/web/assets/langs-kfQh6fa2.js +1 -0
- package/dist/web/assets/mermaid-WFAXDIZX-BIq7_eYY.js +1 -0
- package/dist/web/assets/{shiki-NQ4ryC1Y.js → shiki-D8HIISPT.js} +2 -2
- package/dist/web/assets/{stream-tokenizer-BxwNb7lW.js → stream-tokenizer-BmWmYTv_.js} +1 -1
- package/dist/web/assets/{themes-CNX2CYCy.js → themes-CKsIQs7_.js} +2 -2
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/runner-CoJjefjZ.js.map +0 -1
- package/dist/web/assets/engine-oniguruma-C_TN-UZT.js +0 -1
- package/dist/web/assets/index-BpVrEjZE.css +0 -1
- package/dist/web/assets/langs-D6g8tc-L.js +0 -1
- package/dist/web/assets/mermaid-WFAXDIZX-DbjU3Ezf.js +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { t as startRunner } from "./runner-D8m3WdtS.js";
|
|
2
|
+
import { parseArgs } from "node:util";
|
|
3
|
+
// ../runner/src/main.ts
|
|
4
|
+
/**
|
|
5
|
+
* Runner process entry. Started detached by the server:
|
|
6
|
+
* node main.js --home <dir> [--fake] [--no-builtin] [--replay <fixture.json>] [--mcp-upstream <url>]
|
|
7
|
+
*/
|
|
8
|
+
const { values } = parseArgs({
|
|
9
|
+
options: {
|
|
10
|
+
home: { type: "string" },
|
|
11
|
+
fake: {
|
|
12
|
+
type: "boolean",
|
|
13
|
+
default: false
|
|
14
|
+
},
|
|
15
|
+
/** Skip the real Claude Code / Codex adapters (tests that only use Fake or Replay). */
|
|
16
|
+
"no-builtin": {
|
|
17
|
+
type: "boolean",
|
|
18
|
+
default: false
|
|
19
|
+
},
|
|
20
|
+
/** Serve a recorded fixture as the `replay` provider (repeatable). */
|
|
21
|
+
replay: {
|
|
22
|
+
type: "string",
|
|
23
|
+
multiple: true
|
|
24
|
+
},
|
|
25
|
+
"mcp-upstream": { type: "string" }
|
|
26
|
+
},
|
|
27
|
+
allowPositionals: false
|
|
28
|
+
});
|
|
29
|
+
const home = values.home ?? process.env.CODEDEN_HOME;
|
|
30
|
+
if (!home) {
|
|
31
|
+
console.error("codeden runner: --home or CODEDEN_HOME is required");
|
|
32
|
+
process.exit(2);
|
|
33
|
+
}
|
|
34
|
+
const log = (m) => console.log(`[${(/* @__PURE__ */ new Date()).toISOString()}] ${m}`);
|
|
35
|
+
try {
|
|
36
|
+
const runner = await startRunner({
|
|
37
|
+
home,
|
|
38
|
+
enableFakeProvider: values.fake,
|
|
39
|
+
builtinProviders: !values["no-builtin"],
|
|
40
|
+
replayFixtures: values.replay,
|
|
41
|
+
mcpUpstreamUrl: values["mcp-upstream"],
|
|
42
|
+
sweepDescendants: true,
|
|
43
|
+
log,
|
|
44
|
+
onShutdown: () => process.exit(0)
|
|
45
|
+
});
|
|
46
|
+
const stop = () => void runner.close().then(() => process.exit(0));
|
|
47
|
+
for (const signal of [
|
|
48
|
+
"SIGINT",
|
|
49
|
+
"SIGTERM",
|
|
50
|
+
"SIGHUP",
|
|
51
|
+
"SIGBREAK"
|
|
52
|
+
]) process.on(signal, stop);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
log(`failed to start: ${error instanceof Error ? error.message : String(error)}`);
|
|
55
|
+
process.exit(1);
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
58
|
+
|
|
59
|
+
//# sourceMappingURL=main-DaGFUbbW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main-DaGFUbbW.js","names":[],"sources":["../../runner/src/main.ts"],"sourcesContent":["/**\n * Runner process entry. Started detached by the server:\n * node main.js --home <dir> [--fake] [--no-builtin] [--replay <fixture.json>] [--mcp-upstream <url>]\n */\nimport { parseArgs } from \"node:util\";\nimport { startRunner } from \"./runner\";\n\nconst { values } = parseArgs({\n options: {\n home: { type: \"string\" },\n fake: { type: \"boolean\", default: false },\n /** Skip the real Claude Code / Codex adapters (tests that only use Fake or Replay). */\n \"no-builtin\": { type: \"boolean\", default: false },\n /** Serve a recorded fixture as the `replay` provider (repeatable). */\n replay: { type: \"string\", multiple: true },\n \"mcp-upstream\": { type: \"string\" },\n },\n allowPositionals: false,\n});\n\nconst home = values.home ?? process.env.CODEDEN_HOME;\nif (!home) {\n console.error(\"codeden runner: --home or CODEDEN_HOME is required\");\n process.exit(2);\n}\n\nconst log = (m: string) => console.log(`[${new Date().toISOString()}] ${m}`);\n\ntry {\n const runner = await startRunner({\n home,\n enableFakeProvider: values.fake,\n builtinProviders: !values[\"no-builtin\"],\n replayFixtures: values.replay,\n mcpUpstreamUrl: values[\"mcp-upstream\"],\n sweepDescendants: true,\n log,\n onShutdown: () => process.exit(0),\n });\n const stop = () => void runner.close().then(() => process.exit(0));\n for (const signal of [\"SIGINT\", \"SIGTERM\", \"SIGHUP\", \"SIGBREAK\"] as const) {\n process.on(signal, stop);\n }\n} catch (error) {\n log(`failed to start: ${error instanceof Error ? error.message : String(error)}`);\n process.exit(1);\n}\n"],"mappings":";;;;;;;AAOA,MAAM,EAAE,WAAW,UAAU;CAC3B,SAAS;EACP,MAAM,EAAE,MAAM,SAAS;EACvB,MAAM;GAAE,MAAM;GAAW,SAAS;EAAM;;EAExC,cAAc;GAAE,MAAM;GAAW,SAAS;EAAM;;EAEhD,QAAQ;GAAE,MAAM;GAAU,UAAU;EAAK;EACzC,gBAAgB,EAAE,MAAM,SAAS;CACnC;CACA,kBAAkB;AACpB,CAAC;AAED,MAAM,OAAO,OAAO,QAAQ,QAAQ,IAAI;AACxC,IAAI,CAAC,MAAM;CACT,QAAQ,MAAM,oDAAoD;CAClE,QAAQ,KAAK,CAAC;AAChB;AAEA,MAAM,OAAO,MAAc,QAAQ,IAAI,qBAAI,IAAI,KAAK,EAAA,CAAE,YAAY,EAAE,IAAI,GAAG;AAE3E,IAAI;CACF,MAAM,SAAS,MAAM,YAAY;EAC/B;EACA,oBAAoB,OAAO;EAC3B,kBAAkB,CAAC,OAAO;EAC1B,gBAAgB,OAAO;EACvB,gBAAgB,OAAO;EACvB,kBAAkB;EAClB;EACA,kBAAkB,QAAQ,KAAK,CAAC;CAClC,CAAC;CACD,MAAM,aAAa,KAAK,OAAO,MAAM,CAAC,CAAC,WAAW,QAAQ,KAAK,CAAC,CAAC;CACjE,KAAK,MAAM,UAAU;EAAC;EAAU;EAAW;EAAU;CAAU,GAC7D,QAAQ,GAAG,QAAQ,IAAI;AAE3B,SAAS,OAAO;CACd,IAAI,oBAAoB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;CAChF,QAAQ,KAAK,CAAC;AAChB"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { n as __require, r as __toESM, t as __commonJSMin } from "./rolldown-runtime-DegdyBIC.js";
|
|
2
2
|
import { createRequire } from "node:module";
|
|
3
3
|
import { accessSync, appendFileSync, chmodSync, closeSync, constants, existsSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
|
|
4
|
+
import { pathToFileURL } from "node:url";
|
|
4
5
|
import { homedir, tmpdir } from "node:os";
|
|
5
6
|
import path, { basename, dirname, extname, isAbsolute, join, relative, resolve } from "node:path";
|
|
6
7
|
import { createHash, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
|
|
7
8
|
import { execFile, spawn } from "node:child_process";
|
|
8
|
-
import { pathToFileURL } from "node:url";
|
|
9
9
|
import { createInterface } from "node:readline";
|
|
10
10
|
import { copyFile, mkdir, readFile, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
11
11
|
import { STATUS_CODES, ServerResponse, createServer } from "node:http";
|
|
@@ -9142,6 +9142,154 @@ const ConflictRecord = object({
|
|
|
9142
9142
|
createdAt: Timestamp,
|
|
9143
9143
|
resolvedAt: Timestamp.nullable()
|
|
9144
9144
|
});
|
|
9145
|
+
// ../../packages/contracts/src/updates.ts
|
|
9146
|
+
/**
|
|
9147
|
+
* `settings.updates.mode` (§16): `off` never asks the registry; `notify` checks and offers a
|
|
9148
|
+
* one-click update; `auto` also downloads a new version in the background so it starts on the
|
|
9149
|
+
* next launch (or right away with "Restart now").
|
|
9150
|
+
*/
|
|
9151
|
+
const UpdateMode = _enum([
|
|
9152
|
+
"off",
|
|
9153
|
+
"notify",
|
|
9154
|
+
"auto"
|
|
9155
|
+
]);
|
|
9156
|
+
/**
|
|
9157
|
+
* Where the running CodeDen came from. `packaged`: an npm install (`npx`, global or a
|
|
9158
|
+
* side-by-side version in `<home>/app`), which can update itself. `source`: the repository or
|
|
9159
|
+
* a workspace build, which never switches versions (pull and rebuild instead).
|
|
9160
|
+
*/
|
|
9161
|
+
const InstallSource = _enum(["packaged", "source"]);
|
|
9162
|
+
/**
|
|
9163
|
+
* Self-update progress. `installing`: npm is fetching `target` into `<home>/app/<target>`;
|
|
9164
|
+
* `installed`: it is ready and starts on the next launch (or with a restart); `restarting`:
|
|
9165
|
+
* the server is handing over to `target`; `failed`: see `installError`.
|
|
9166
|
+
*/
|
|
9167
|
+
const UpdateState = _enum([
|
|
9168
|
+
"idle",
|
|
9169
|
+
"installing",
|
|
9170
|
+
"installed",
|
|
9171
|
+
"restarting",
|
|
9172
|
+
"failed"
|
|
9173
|
+
]);
|
|
9174
|
+
/** A CodeDen version installed side by side in `<home>/app/<version>`. */
|
|
9175
|
+
const InstalledVersion = object({
|
|
9176
|
+
version: string(),
|
|
9177
|
+
/** `<home>/app/current.json` points at it: the launcher starts it. */
|
|
9178
|
+
current: boolean(),
|
|
9179
|
+
/** The CLI entry exists and its package reports this version. */
|
|
9180
|
+
valid: boolean()
|
|
9181
|
+
});
|
|
9182
|
+
/**
|
|
9183
|
+
* `GET /api/updates` (§16) and the `update` WebSocket message: the npm registry check plus the
|
|
9184
|
+
* one-click self-update state. The registry is asked on start and every 6 hours while the
|
|
9185
|
+
* mode is not `off`; `?refresh=1` checks again now. Nothing but the package name is sent.
|
|
9186
|
+
*/
|
|
9187
|
+
const UpdateStatus = object({
|
|
9188
|
+
/** The running version. */
|
|
9189
|
+
current: string(),
|
|
9190
|
+
/** Latest published version, null until a check succeeded. */
|
|
9191
|
+
latest: string().nullable(),
|
|
9192
|
+
/** `latest` is newer than `current`. */
|
|
9193
|
+
updateAvailable: boolean(),
|
|
9194
|
+
/** The mode is not `off` (and `CODEDEN_UPDATE_CHECK` is not `0`); when false nothing is fetched. */
|
|
9195
|
+
enabled: boolean(),
|
|
9196
|
+
mode: UpdateMode,
|
|
9197
|
+
checkedAt: Timestamp.nullable(),
|
|
9198
|
+
/** Why the last check failed (offline, registry error), else null. */
|
|
9199
|
+
error: string().nullable(),
|
|
9200
|
+
/** The manual way to update, e.g. `npm i -g codeden@latest`. */
|
|
9201
|
+
command: string(),
|
|
9202
|
+
source: InstallSource,
|
|
9203
|
+
state: UpdateState,
|
|
9204
|
+
/** The version being installed, installed and waiting for a restart, or restarting into. */
|
|
9205
|
+
target: string().nullable(),
|
|
9206
|
+
/** The latest npm output line while installing. */
|
|
9207
|
+
progress: string().nullable(),
|
|
9208
|
+
/** Why the last install, switch or restart failed. */
|
|
9209
|
+
installError: string().nullable(),
|
|
9210
|
+
/** This server can restart itself into another version (started by the `codeden` CLI). */
|
|
9211
|
+
canRestart: boolean(),
|
|
9212
|
+
/** What to run to restart by hand when it can't, e.g. `npx codeden`. */
|
|
9213
|
+
restartCommand: string(),
|
|
9214
|
+
/** Versions in `<home>/app`, newest first. */
|
|
9215
|
+
installed: array(InstalledVersion),
|
|
9216
|
+
/** The version "Roll back" would start (the previous one, or the copy you launched). */
|
|
9217
|
+
rollbackTo: string().nullable(),
|
|
9218
|
+
/** "Roll back" is possible (a previous version is recorded). */
|
|
9219
|
+
canRollback: boolean(),
|
|
9220
|
+
/** Set when the launcher could not start the pinned version and fell back. */
|
|
9221
|
+
warning: string().nullable()
|
|
9222
|
+
});
|
|
9223
|
+
/** `POST /api/updates/install`: install `version` (default: the latest) and restart into it. */
|
|
9224
|
+
const UpdateInstallRequest = object({
|
|
9225
|
+
version: string().min(1).optional(),
|
|
9226
|
+
/** Restart once installed (default true); false leaves it for the next launch. */
|
|
9227
|
+
restart: boolean().optional()
|
|
9228
|
+
});
|
|
9229
|
+
object({
|
|
9230
|
+
version: string(),
|
|
9231
|
+
/** Markdown from the GitHub Release body or the CHANGELOG section; null when unreachable. */
|
|
9232
|
+
body: string().nullable(),
|
|
9233
|
+
/** Where to read them in the browser. */
|
|
9234
|
+
url: string()
|
|
9235
|
+
});
|
|
9236
|
+
/**
|
|
9237
|
+
* `<home>/app/current.json`: which side-by-side version the `codeden` launcher starts. Written
|
|
9238
|
+
* by the server or `codeden update`; read (without zod, on the hot path) by the launcher in
|
|
9239
|
+
* `apps/cli/src/launcher.ts`, which must accept everything this schema accepts.
|
|
9240
|
+
*/
|
|
9241
|
+
const AppPointer = object({
|
|
9242
|
+
version: string().min(1),
|
|
9243
|
+
/** The version that ran before the switch ("Roll back" target), null when unknown. */
|
|
9244
|
+
previous: string().nullable(),
|
|
9245
|
+
updatedAt: Timestamp
|
|
9246
|
+
});
|
|
9247
|
+
/** True when version `a` is newer than `b` (`x.y.z`, prerelease tags sort before releases). */
|
|
9248
|
+
function isNewerVersion(a, b) {
|
|
9249
|
+
return compareVersions$1(a, b) > 0;
|
|
9250
|
+
}
|
|
9251
|
+
/** Compare two `x.y.z[-pre]` versions: negative when `a < b`, 0 when equal, positive when newer. */
|
|
9252
|
+
function compareVersions$1(a, b) {
|
|
9253
|
+
const parse = (v) => {
|
|
9254
|
+
const trimmed = v.trim().replace(/^v/, "");
|
|
9255
|
+
const dash = trimmed.indexOf("-");
|
|
9256
|
+
const core = dash === -1 ? trimmed : trimmed.slice(0, dash);
|
|
9257
|
+
const pre = dash === -1 ? "" : trimmed.slice(dash + 1);
|
|
9258
|
+
return {
|
|
9259
|
+
nums: core.split(".").map((n) => Number.parseInt(n, 10) || 0),
|
|
9260
|
+
pre
|
|
9261
|
+
};
|
|
9262
|
+
};
|
|
9263
|
+
const x = parse(a);
|
|
9264
|
+
const y = parse(b);
|
|
9265
|
+
for (let i = 0; i < 3; i++) {
|
|
9266
|
+
const d = (x.nums[i] ?? 0) - (y.nums[i] ?? 0);
|
|
9267
|
+
if (d !== 0) return d;
|
|
9268
|
+
}
|
|
9269
|
+
if (x.pre === y.pre) return 0;
|
|
9270
|
+
if (!x.pre) return 1;
|
|
9271
|
+
if (!y.pre) return -1;
|
|
9272
|
+
return comparePrerelease(x.pre, y.pre);
|
|
9273
|
+
}
|
|
9274
|
+
/** Dot-separated prerelease identifiers: numeric ones compare as numbers and sort first. */
|
|
9275
|
+
function comparePrerelease(a, b) {
|
|
9276
|
+
const xs = a.split(".");
|
|
9277
|
+
const ys = b.split(".");
|
|
9278
|
+
for (let i = 0; i < Math.max(xs.length, ys.length); i++) {
|
|
9279
|
+
const x = xs[i];
|
|
9280
|
+
const y = ys[i];
|
|
9281
|
+
if (x === void 0) return -1;
|
|
9282
|
+
if (y === void 0) return 1;
|
|
9283
|
+
const xn = /^\d+$/.test(x);
|
|
9284
|
+
const yn = /^\d+$/.test(y);
|
|
9285
|
+
if (xn && yn) {
|
|
9286
|
+
const d = Number(x) - Number(y);
|
|
9287
|
+
if (d !== 0) return d;
|
|
9288
|
+
} else if (xn !== yn) return xn ? -1 : 1;
|
|
9289
|
+
else if (x !== y) return x < y ? -1 : 1;
|
|
9290
|
+
}
|
|
9291
|
+
return 0;
|
|
9292
|
+
}
|
|
9145
9293
|
// ../../packages/contracts/src/settings.ts
|
|
9146
9294
|
/** `auto` lets CodeDen pick the first ready provider (Claude, then Codex). */
|
|
9147
9295
|
const ProviderChoice = union([literal("auto"), ProviderId]);
|
|
@@ -9253,7 +9401,11 @@ const Settings = object({
|
|
|
9253
9401
|
killSwitch: boolean().default(false) }).prefault({}),
|
|
9254
9402
|
/** Master switch; individual automations are still off by default (§10). */
|
|
9255
9403
|
automations: object({ enabled: boolean().default(true) }).prefault({}),
|
|
9256
|
-
|
|
9404
|
+
/**
|
|
9405
|
+
* Update checks and one-click self-update (§16). Settings saved before `mode` existed had
|
|
9406
|
+
* `check: false` to turn checks off; that reads as `mode: "off"`.
|
|
9407
|
+
*/
|
|
9408
|
+
updates: preprocess((value) => typeof value === "object" && value !== null && !("mode" in value) && value.check === false ? { mode: "off" } : value, object({ mode: UpdateMode.default("notify") }).prefault({})),
|
|
9257
9409
|
/** First-run setup (§14): set once the user finishes the detection checklist. */
|
|
9258
9410
|
setup: object({
|
|
9259
9411
|
completed: boolean().default(false),
|
|
@@ -9473,6 +9625,10 @@ const ServerToClientMessage = discriminatedUnion("type", [
|
|
|
9473
9625
|
type: literal("runner"),
|
|
9474
9626
|
runner: RunnerConnectionStatus
|
|
9475
9627
|
}),
|
|
9628
|
+
object({
|
|
9629
|
+
type: literal("update"),
|
|
9630
|
+
update: UpdateStatus
|
|
9631
|
+
}),
|
|
9476
9632
|
object({
|
|
9477
9633
|
type: literal("pong"),
|
|
9478
9634
|
id: string()
|
|
@@ -10618,41 +10774,6 @@ object({
|
|
|
10618
10774
|
/** Token id, used for revocation. */
|
|
10619
10775
|
jti: string().min(1)
|
|
10620
10776
|
});
|
|
10621
|
-
object({
|
|
10622
|
-
/** The running version. */
|
|
10623
|
-
current: string(),
|
|
10624
|
-
/** Latest published version, null until a check succeeded. */
|
|
10625
|
-
latest: string().nullable(),
|
|
10626
|
-
/** `latest` is newer than `current`. */
|
|
10627
|
-
updateAvailable: boolean(),
|
|
10628
|
-
/** `settings.updates.check`; when off, nothing is fetched. */
|
|
10629
|
-
enabled: boolean(),
|
|
10630
|
-
checkedAt: Timestamp.nullable(),
|
|
10631
|
-
/** Why the last check failed (offline, registry error), else null. */
|
|
10632
|
-
error: string().nullable(),
|
|
10633
|
-
/** How to update, e.g. `npm i -g codeden@latest`. */
|
|
10634
|
-
command: string()
|
|
10635
|
-
});
|
|
10636
|
-
/** True when version `a` is newer than `b` (`x.y.z`, prerelease tags sort before releases). */
|
|
10637
|
-
function isNewerVersion(a, b) {
|
|
10638
|
-
const parse = (v) => {
|
|
10639
|
-
const [core = "", pre = ""] = v.trim().replace(/^v/, "").split("-", 2);
|
|
10640
|
-
return {
|
|
10641
|
-
nums: core.split(".").map((n) => Number.parseInt(n, 10) || 0),
|
|
10642
|
-
pre
|
|
10643
|
-
};
|
|
10644
|
-
};
|
|
10645
|
-
const x = parse(a);
|
|
10646
|
-
const y = parse(b);
|
|
10647
|
-
for (let i = 0; i < 3; i++) {
|
|
10648
|
-
const d = (x.nums[i] ?? 0) - (y.nums[i] ?? 0);
|
|
10649
|
-
if (d !== 0) return d > 0;
|
|
10650
|
-
}
|
|
10651
|
-
if (x.pre === y.pre) return false;
|
|
10652
|
-
if (!x.pre) return true;
|
|
10653
|
-
if (!y.pre) return false;
|
|
10654
|
-
return x.pre > y.pre;
|
|
10655
|
-
}
|
|
10656
10777
|
// ../../packages/contracts/src/usage.ts
|
|
10657
10778
|
/**
|
|
10658
10779
|
* Usage and cost reports (§12.6). The server keeps a ledger with one row per turn: the
|
|
@@ -10899,12 +11020,18 @@ object({
|
|
|
10899
11020
|
budgets: array(BudgetStatus),
|
|
10900
11021
|
billing: record(ProviderId, BillingMode)
|
|
10901
11022
|
});
|
|
10902
|
-
// ../../packages/contracts/src/version.ts
|
|
10903
11023
|
/**
|
|
10904
|
-
* CodeDen release version.
|
|
10905
|
-
*
|
|
11024
|
+
* CodeDen release version. Server and runner exchange it during the runner handshake to detect
|
|
11025
|
+
* upgrades. The published entries (`dist/cli.js`, `dist/runner.js`) set
|
|
11026
|
+
* `globalThis.__CODEDEN_PACKAGE_VERSION__` from their own `package.json` before loading the
|
|
11027
|
+
* rest of the bundle, so the package version is the single source of truth at runtime;
|
|
11028
|
+
* everywhere else (workspace, tests) it is `SOURCE_VERSION`.
|
|
10906
11029
|
*/
|
|
10907
|
-
const CODEDEN_VERSION = "0.1.
|
|
11030
|
+
const CODEDEN_VERSION = packageVersion() ?? "0.1.1";
|
|
11031
|
+
function packageVersion() {
|
|
11032
|
+
const value = globalThis.__CODEDEN_PACKAGE_VERSION__;
|
|
11033
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
11034
|
+
}
|
|
10908
11035
|
// ../../packages/contracts/src/voice-api.ts
|
|
10909
11036
|
/**
|
|
10910
11037
|
* Optional cloud voice engines (§11.3). The browser's speech APIs stay the default; these
|
|
@@ -15936,7 +16063,7 @@ function toSdkUserMessage(input) {
|
|
|
15936
16063
|
parent_tool_use_id: null
|
|
15937
16064
|
};
|
|
15938
16065
|
}
|
|
15939
|
-
// ../../packages/providers/src/
|
|
16066
|
+
// ../../packages/providers/src/util/install-lock.ts
|
|
15940
16067
|
function isAlive$1(pid) {
|
|
15941
16068
|
try {
|
|
15942
16069
|
process.kill(pid, 0);
|
|
@@ -15988,7 +16115,7 @@ async function acquireInstallLock(file, opts = {}) {
|
|
|
15988
16115
|
await new Promise((resolve) => setTimeout(resolve, opts.pollMs ?? 500));
|
|
15989
16116
|
}
|
|
15990
16117
|
}
|
|
15991
|
-
// ../../packages/providers/src/
|
|
16118
|
+
// ../../packages/providers/src/util/npm.ts
|
|
15992
16119
|
/**
|
|
15993
16120
|
* How to run npm for on-demand installs. Prefers the npm that started us (`npm_execpath`,
|
|
15994
16121
|
* set under `npx`), then the npm shipped next to this Node binary, then `npm` on PATH.
|
|
@@ -16010,6 +16137,65 @@ function resolveNpm(env = process.env, execPath = process.execPath, platform = p
|
|
|
16010
16137
|
};
|
|
16011
16138
|
return resolveExecutable("npm");
|
|
16012
16139
|
}
|
|
16140
|
+
// ../../packages/providers/src/util/npm-run.ts
|
|
16141
|
+
/**
|
|
16142
|
+
* Run npm with `args` (on-demand installs: Claude Code support in `<home>/deps`, CodeDen
|
|
16143
|
+
* versions in `<home>/app`), streaming its output lines. Rejects with npm's own error summary
|
|
16144
|
+
* on a non-zero exit, and kills the process tree on timeout.
|
|
16145
|
+
*/
|
|
16146
|
+
function runNpm(npm, args, opts) {
|
|
16147
|
+
return new Promise((resolve, reject) => {
|
|
16148
|
+
const child = spawnResolved(npm, args, {
|
|
16149
|
+
cwd: opts.cwd,
|
|
16150
|
+
env: {
|
|
16151
|
+
...process.env,
|
|
16152
|
+
npm_config_update_notifier: "false",
|
|
16153
|
+
npm_config_progress: "false",
|
|
16154
|
+
...opts.env
|
|
16155
|
+
},
|
|
16156
|
+
stdio: [
|
|
16157
|
+
"ignore",
|
|
16158
|
+
"pipe",
|
|
16159
|
+
"pipe"
|
|
16160
|
+
],
|
|
16161
|
+
windowsHide: true
|
|
16162
|
+
});
|
|
16163
|
+
let output = "";
|
|
16164
|
+
const onData = (chunk) => {
|
|
16165
|
+
output = (output + chunk).slice(-2e4);
|
|
16166
|
+
for (const line of chunk.split(/\r?\n/)) {
|
|
16167
|
+
const text = line.trim();
|
|
16168
|
+
if (text) opts.onLine(text.slice(0, 300));
|
|
16169
|
+
}
|
|
16170
|
+
};
|
|
16171
|
+
child.stdout?.setEncoding("utf8").on("data", onData);
|
|
16172
|
+
child.stderr?.setEncoding("utf8").on("data", onData);
|
|
16173
|
+
const timer = setTimeout(() => {
|
|
16174
|
+
killTree$1(child);
|
|
16175
|
+
reject(/* @__PURE__ */ new Error(`npm timed out after ${Math.round(opts.timeoutMs / 1e3)}s`));
|
|
16176
|
+
}, opts.timeoutMs);
|
|
16177
|
+
child.on("error", (error) => {
|
|
16178
|
+
clearTimeout(timer);
|
|
16179
|
+
reject(/* @__PURE__ */ new Error(`Could not start npm: ${error.message}`));
|
|
16180
|
+
});
|
|
16181
|
+
child.on("close", (code) => {
|
|
16182
|
+
clearTimeout(timer);
|
|
16183
|
+
if (code === 0) return resolve();
|
|
16184
|
+
const reason = npmFailure(output);
|
|
16185
|
+
reject(/* @__PURE__ */ new Error(`npm install exited with code ${code}${reason ? `: ${reason}` : ""}`));
|
|
16186
|
+
});
|
|
16187
|
+
});
|
|
16188
|
+
}
|
|
16189
|
+
/**
|
|
16190
|
+
* The useful part of npm's error output: its error code and the first descriptive line
|
|
16191
|
+
* (`npm error code E404` + `npm error 404 Not Found - GET ...`), without stack frames.
|
|
16192
|
+
*/
|
|
16193
|
+
function npmFailure(output) {
|
|
16194
|
+
const lines = output.split(/\r?\n/).map((line) => line.trim()).filter((line) => /^npm (error|ERR!)/.test(line)).map((line) => line.replace(/^npm (error|ERR!)\s*/, "")).filter((line) => line && !/^(at |\{|\}|[a-z]\w*: |syscall|errno |A complete log)/.test(line));
|
|
16195
|
+
const summary = [lines.find((line) => line.startsWith("code ")), lines.find((line) => !line.startsWith("code "))].filter(Boolean).join(": ").slice(0, 500);
|
|
16196
|
+
if (summary) return summary;
|
|
16197
|
+
return output.trim().split(/\r?\n/).slice(-3).join(" ").slice(0, 500);
|
|
16198
|
+
}
|
|
16013
16199
|
// ../../packages/providers/src/claude/sdk/install.ts
|
|
16014
16200
|
/** The Claude Agent SDK package. */
|
|
16015
16201
|
const CLAUDE_SDK_PACKAGE = "@anthropic-ai/claude-agent-sdk";
|
|
@@ -16090,58 +16276,6 @@ async function runInstall(opts) {
|
|
|
16090
16276
|
release();
|
|
16091
16277
|
}
|
|
16092
16278
|
}
|
|
16093
|
-
function runNpm(npm, args, opts) {
|
|
16094
|
-
return new Promise((resolve, reject) => {
|
|
16095
|
-
const child = spawnResolved(npm, args, {
|
|
16096
|
-
cwd: opts.cwd,
|
|
16097
|
-
env: {
|
|
16098
|
-
...process.env,
|
|
16099
|
-
npm_config_update_notifier: "false",
|
|
16100
|
-
npm_config_progress: "false"
|
|
16101
|
-
},
|
|
16102
|
-
stdio: [
|
|
16103
|
-
"ignore",
|
|
16104
|
-
"pipe",
|
|
16105
|
-
"pipe"
|
|
16106
|
-
],
|
|
16107
|
-
windowsHide: true
|
|
16108
|
-
});
|
|
16109
|
-
let output = "";
|
|
16110
|
-
const onData = (chunk) => {
|
|
16111
|
-
output = (output + chunk).slice(-2e4);
|
|
16112
|
-
for (const line of chunk.split(/\r?\n/)) {
|
|
16113
|
-
const text = line.trim();
|
|
16114
|
-
if (text) opts.onLine(text.slice(0, 300));
|
|
16115
|
-
}
|
|
16116
|
-
};
|
|
16117
|
-
child.stdout?.setEncoding("utf8").on("data", onData);
|
|
16118
|
-
child.stderr?.setEncoding("utf8").on("data", onData);
|
|
16119
|
-
const timer = setTimeout(() => {
|
|
16120
|
-
killTree$1(child);
|
|
16121
|
-
reject(/* @__PURE__ */ new Error(`npm timed out after ${Math.round(opts.timeoutMs / 1e3)}s`));
|
|
16122
|
-
}, opts.timeoutMs);
|
|
16123
|
-
child.on("error", (error) => {
|
|
16124
|
-
clearTimeout(timer);
|
|
16125
|
-
reject(/* @__PURE__ */ new Error(`Could not start npm: ${error.message}`));
|
|
16126
|
-
});
|
|
16127
|
-
child.on("close", (code) => {
|
|
16128
|
-
clearTimeout(timer);
|
|
16129
|
-
if (code === 0) return resolve();
|
|
16130
|
-
const reason = npmFailure(output);
|
|
16131
|
-
reject(/* @__PURE__ */ new Error(`npm install exited with code ${code}${reason ? `: ${reason}` : ""}`));
|
|
16132
|
-
});
|
|
16133
|
-
});
|
|
16134
|
-
}
|
|
16135
|
-
/**
|
|
16136
|
-
* The useful part of npm's error output: its error code and the first descriptive line
|
|
16137
|
-
* (`npm error code E404` + `npm error 404 Not Found - GET ...`), without stack frames.
|
|
16138
|
-
*/
|
|
16139
|
-
function npmFailure(output) {
|
|
16140
|
-
const lines = output.split(/\r?\n/).map((line) => line.trim()).filter((line) => /^npm (error|ERR!)/.test(line)).map((line) => line.replace(/^npm (error|ERR!)\s*/, "")).filter((line) => line && !/^(at |\{|\}|[a-z]\w*: |syscall|errno |A complete log)/.test(line));
|
|
16141
|
-
const summary = [lines.find((line) => line.startsWith("code ")), lines.find((line) => !line.startsWith("code "))].filter(Boolean).join(": ").slice(0, 500);
|
|
16142
|
-
if (summary) return summary;
|
|
16143
|
-
return output.trim().split(/\r?\n/).slice(-3).join(" ").slice(0, 500);
|
|
16144
|
-
}
|
|
16145
16279
|
// ../../packages/providers/src/claude/sdk/load.ts
|
|
16146
16280
|
/** Where the SDK comes from in this process. `CODEDEN_CLAUDE_SDK=deps|workspace` overrides. */
|
|
16147
16281
|
function claudeSdkSource() {
|
|
@@ -26968,7 +27102,7 @@ const DEFAULT_DRAIN_TIMEOUT = 3e5;
|
|
|
26968
27102
|
*/
|
|
26969
27103
|
async function startRunner(opts) {
|
|
26970
27104
|
const log = opts.log ?? (() => {});
|
|
26971
|
-
const version = opts.version ??
|
|
27105
|
+
const version = opts.version ?? CODEDEN_VERSION;
|
|
26972
27106
|
const dir = join(opts.home, "runner");
|
|
26973
27107
|
mkdirSync(dir, { recursive: true });
|
|
26974
27108
|
const lockFile = join(dir, "runner.json");
|
|
@@ -27132,6 +27266,6 @@ async function startRunner(opts) {
|
|
|
27132
27266
|
close
|
|
27133
27267
|
};
|
|
27134
27268
|
}
|
|
27135
|
-
export {
|
|
27269
|
+
export { RunAutomationRequest as $, unknown as $n, Automation as $t, SessionFileQuery as A, McpServerTarget as An, isNewerVersion as At, BrowserClientMessage as B, custom as Bn, TriageIssueRequest as Bt, import_websocket_server as C, InboxItemKind as Cn, HealthResponse as Ct, CODEDEN_VERSION as D, AgentConfigLocator as Dn, UpdateInstallRequest as Dt, TtsRequest as E, AgentConfigListQuery as En, AppPointer as Et, ListNoticesQuery as F, datetime as Fn, GithubIssue as Ft, BrowserOpenRequest as G, looseObject as Gn, FactoryTriageRequest as Gt, BrowserHistoryRequest as H, int as Hn, parseGithubPrId as Ht, ResolveConflictRequest as I, _enum as In, GithubLabelRequest as It, AutomationFileFrontmatter as J, optional as Jn, PutVisionRequest as Jt, BrowserViewportRequest as K, number$1 as Kn, FactoryTuning as Kt, RoleMessageRequest as L, _null as Ln, GithubListQuery as Lt, RunnerToServerMessage as M, AutonomyLevel as Mn, NOTICE_BATCH_CODE as Mt, ServerLock as N, ProviderId as Nn, CreateGithubIssueRequest as Nt, UsageQuery as O, AgentConfigWriteRequest as On, UpdateStatus as Ot, ListConflictsQuery as P, ReasoningEffort as Pn, GithubCommentRequest as Pt, ListAutomationsQuery as Q, union as Qn, Artifact as Qt, UpdateSessionRequest as R, array as Rn, GithubPr as Rt, acquireInstallLock as S, InboxItem as Sn, UpdateProjectRequest as St, SttQuery as T, AgentConfigDiffRequest as Tn, Settings as Tt, BrowserNavigateRequest as U, intersection as Un, DiscoveryArea as Ut, BrowserDevServerRequest as V, discriminatedUnion as Vn, githubPrId as Vt, BrowserNewTabRequest as W, literal as Wn, FactoryCandidate as Wt, CreateAutomationRequest as X, record as Xn, SetAutonomyModeRequest as Xt, AutomationProjectRequest as Y, preprocess as Yn, ReviewVerdict as Yt, ListAutomationRunsQuery as Z, string as Zn, isFactoryMode as Zt, importClaudeSdkFrom as _, StartedBy as _n, SetSecretRequest as _t, Hono as a, DiffScope as an, UpdateAutomationProjectSettingsRequest as at, runNpm as b, DEFAULT_VISION_PATH as bn, ThreadItemsQuery as bt, serve as c, RestoreFilesRequest as cn, FileReadQuery as ct, createImageEngineRegistry as d, TerminalClientMessage as dn, ListSessionsQuery as dt, AutomationGuards as en, ZodError as er, SetAutomationEnabledRequest as et, IMAGE_ASPECT_RATIOS as f, TerminalQuery as fn, ResolveInboxRequest as ft, CLAUDE_SDK_VERSION as g, ConflictDecision as gn, SessionStartMeta as gt, claudeSdkSource as h, ProjectConfigFile as hn, SendMessageRequest as ht, killTree as i, SessionStatus as in, UpcomingRunsQuery as it, RunnerLock as j, McpServerUpsertRequest as jn, ConflictRecord as jt, UsageSettings as k, McpServerDiffRequest as kn, compareVersions$1 as kt, upgradeWebSocket as l, SessionResult as ln, FileWriteRequest as lt, ImageGenerationError as m, SessionOptions as mn, SecretKey as mt, readLock as n, TriagePolicy as nn, safeParse$1 as nr, TriageDecisionRequest as nt, tryDecodeURIComponent as o, GitCommitRequest as on, UpdateAutomationRequest as ot, resolveImageOutput as p, RunnerCommandResults as pn, RespondRequest as pt, BrowserWsQuery as q, object as qn, KillSwitchRequest as qt, isAlive as r, Session as rn, prettifyError as rr, TriageReport as rt, bufferToFormData as s, GitPushRequest as sn, CreateProjectRequest as st, startRunner as t, AutomationRun as tn, toJSONSchema as tr, StarterSetRequest as tt, ImageEngineRegistry as u, SpeechSummaryRequest as un, ListInboxQuery as ut, installClaudeSdk as v, WorkKey as vn, StartSessionRequest as vt, wrapper_default as w, AgentConfigDeleteQuery as wn, agentEventToNewEvent as wt, resolveNpm as x, FactoryLimits as xn, UiClientMessage as xt, isClaudeSdkInstalled as y, Project as yn, SteerRequest as yt, ImageTestRequest as z, boolean as zn, MergePrRequest as zt };
|
|
27136
27270
|
|
|
27137
|
-
//# sourceMappingURL=runner-
|
|
27271
|
+
//# sourceMappingURL=runner-D8m3WdtS.js.map
|