@superatomai/sdk-node 0.0.89-dsp → 0.0.91-dsp
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 +942 -942
- package/dist/index.d.mts +820 -119
- package/dist/index.d.ts +820 -119
- package/dist/index.js +118 -64
- package/dist/index.mjs +196 -147
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -24591,6 +24591,9 @@ async function handleDashboardAgentRequest(data, collections, sendMessage) {
|
|
|
24591
24591
|
}
|
|
24592
24592
|
|
|
24593
24593
|
// src/codingAgent/drivers/codex.ts
|
|
24594
|
+
import * as fs8 from "fs";
|
|
24595
|
+
import * as os2 from "os";
|
|
24596
|
+
import * as path9 from "path";
|
|
24594
24597
|
var dynamicImport = new Function("specifier", "return import(specifier)");
|
|
24595
24598
|
var codexModulePromise = null;
|
|
24596
24599
|
function loadCodex() {
|
|
@@ -24688,17 +24691,67 @@ function markerFor(event) {
|
|
|
24688
24691
|
return null;
|
|
24689
24692
|
}
|
|
24690
24693
|
}
|
|
24691
|
-
function buildEnv(opts) {
|
|
24692
|
-
|
|
24694
|
+
function buildEnv(opts, provider = null) {
|
|
24695
|
+
const extra = { ...provider?.env ?? {}, ...opts.env ?? {} };
|
|
24696
|
+
if (opts.inheritEnv) return Object.keys(extra).length ? { ...process.env, ...extra } : void 0;
|
|
24693
24697
|
const env = {};
|
|
24694
24698
|
for (const [k, v] of Object.entries(process.env)) {
|
|
24695
24699
|
if (v === void 0) continue;
|
|
24696
24700
|
if (envAllowed(k)) env[k] = v;
|
|
24697
24701
|
}
|
|
24698
|
-
return { ...env, ...
|
|
24702
|
+
return { ...env, ...extra };
|
|
24703
|
+
}
|
|
24704
|
+
var CODEX_DOC_MAX_BYTES = 256 * 1024;
|
|
24705
|
+
var CODEX_OPENROUTER_KEY_ENV = "CODEX_OPENROUTER_API_KEY";
|
|
24706
|
+
function tomlTopLevel(toml) {
|
|
24707
|
+
const i = toml.search(/^\s*\[/m);
|
|
24708
|
+
return i < 0 ? toml : toml.slice(0, i);
|
|
24709
|
+
}
|
|
24710
|
+
function readCodexConfig(env) {
|
|
24711
|
+
try {
|
|
24712
|
+
return fs8.readFileSync(path9.join(env.CODEX_HOME || path9.join(os2.homedir(), ".codex"), "config.toml"), "utf-8");
|
|
24713
|
+
} catch {
|
|
24714
|
+
return "";
|
|
24715
|
+
}
|
|
24716
|
+
}
|
|
24717
|
+
function codexDefaultProvider(env = process.env, configToml) {
|
|
24718
|
+
const choice = env.CODEX_MODEL_PROVIDER?.trim();
|
|
24719
|
+
if (choice && choice !== "openrouter") return null;
|
|
24720
|
+
if (!choice && /^\s*model_provider\s*=/m.test(tomlTopLevel(configToml ?? readCodexConfig(env)))) return null;
|
|
24721
|
+
const key = env.OPENROUTER_API_KEY?.trim();
|
|
24722
|
+
if (!key) return null;
|
|
24723
|
+
const root = env.SUPERATOM_LLM_PROXY_URL?.trim();
|
|
24724
|
+
const baseUrl = env.OPENROUTER_BASE_URL?.trim() || (root ? `${root.replace(/\/+$/, "")}/openrouter` : "https://openrouter.ai/api/v1");
|
|
24725
|
+
return {
|
|
24726
|
+
config: {
|
|
24727
|
+
model_provider: "openrouter",
|
|
24728
|
+
model_providers: { openrouter: { name: "OpenRouter", base_url: baseUrl, env_key: CODEX_OPENROUTER_KEY_ENV, wire_api: "responses" } },
|
|
24729
|
+
// codex's default compacts at ~112k tokens, well short of the model's window.
|
|
24730
|
+
model_auto_compact_token_limit: 23e4
|
|
24731
|
+
},
|
|
24732
|
+
env: { [CODEX_OPENROUTER_KEY_ENV]: key }
|
|
24733
|
+
};
|
|
24734
|
+
}
|
|
24735
|
+
function codexModelFor(model, provider) {
|
|
24736
|
+
return provider && model && !model.includes("/") ? `openai/${model}` : model;
|
|
24737
|
+
}
|
|
24738
|
+
function codexRunConfig(opts, provider = null) {
|
|
24739
|
+
return {
|
|
24740
|
+
// Tools reach codex as MCP servers; each server's name shows up on
|
|
24741
|
+
// every tool event, so the runner can tell ours from codex's own.
|
|
24742
|
+
...opts.mcpServers && Object.keys(opts.mcpServers).length ? { mcp_servers: opts.mcpServers } : {},
|
|
24743
|
+
// Per run, not ~/.codex/config.toml: a host without that line would run
|
|
24744
|
+
// the agent with no instructions at all. AGENTS.md still wins if present.
|
|
24745
|
+
...opts.instructionsFile && opts.instructionsFile !== "AGENTS.md" ? { project_doc_fallback_filenames: [opts.instructionsFile] } : {},
|
|
24746
|
+
project_doc_max_bytes: CODEX_DOC_MAX_BYTES,
|
|
24747
|
+
...provider?.config ?? {},
|
|
24748
|
+
// Last: a deployment's own value wins.
|
|
24749
|
+
...opts.extraConfig ?? {}
|
|
24750
|
+
};
|
|
24699
24751
|
}
|
|
24700
24752
|
function createCodexSession(opts) {
|
|
24701
|
-
const
|
|
24753
|
+
const provider = opts.apiKey || opts.baseUrl ? null : codexDefaultProvider();
|
|
24754
|
+
const model = codexModelFor(opts.model ?? process.env.CODEX_AGENT_MODEL, provider);
|
|
24702
24755
|
let thread = null;
|
|
24703
24756
|
let resumeId = opts.resumeId;
|
|
24704
24757
|
let threadId = opts.resumeId;
|
|
@@ -24719,21 +24772,12 @@ function createCodexSession(opts) {
|
|
|
24719
24772
|
async function ensureThread() {
|
|
24720
24773
|
if (thread) return thread;
|
|
24721
24774
|
const { Codex } = await loadCodex();
|
|
24722
|
-
const config2 =
|
|
24723
|
-
// Tools reach codex as MCP servers; each server's name shows up on
|
|
24724
|
-
// every tool event, so the runner can tell ours from codex's own.
|
|
24725
|
-
...opts.mcpServers && Object.keys(opts.mcpServers).length ? { mcp_servers: opts.mcpServers } : {},
|
|
24726
|
-
// Per run, not ~/.codex/config.toml: a host without that line would run
|
|
24727
|
-
// the agent with no instructions at all. AGENTS.md still wins if present.
|
|
24728
|
-
...opts.instructionsFile && opts.instructionsFile !== "AGENTS.md" ? { project_doc_fallback_filenames: [opts.instructionsFile] } : {},
|
|
24729
|
-
...opts.extraConfig ?? {}
|
|
24730
|
-
};
|
|
24775
|
+
const config2 = codexRunConfig(opts, provider);
|
|
24731
24776
|
const codex = new Codex({
|
|
24732
24777
|
...opts.apiKey ? { apiKey: opts.apiKey } : {},
|
|
24733
24778
|
...opts.baseUrl ? { baseUrl: opts.baseUrl } : {},
|
|
24734
|
-
env: buildEnv(opts),
|
|
24735
|
-
|
|
24736
|
-
...Object.keys(config2).length ? { config: config2 } : {}
|
|
24779
|
+
env: buildEnv(opts, provider),
|
|
24780
|
+
config: config2
|
|
24737
24781
|
});
|
|
24738
24782
|
thread = resumeId ? codex.resumeThread(resumeId, threadOptions()) : codex.startThread(threadOptions());
|
|
24739
24783
|
return thread;
|
|
@@ -24895,8 +24939,8 @@ ${marker}
|
|
|
24895
24939
|
|
|
24896
24940
|
// src/codingAgent/drivers/pi.ts
|
|
24897
24941
|
import * as crypto3 from "crypto";
|
|
24898
|
-
import * as
|
|
24899
|
-
import * as
|
|
24942
|
+
import * as fs9 from "fs";
|
|
24943
|
+
import * as path10 from "path";
|
|
24900
24944
|
var dynamicImport2 = new Function("specifier", "return import(specifier)");
|
|
24901
24945
|
var piModulePromise = null;
|
|
24902
24946
|
function loadPi() {
|
|
@@ -25063,9 +25107,9 @@ function startSweeper() {
|
|
|
25063
25107
|
}
|
|
25064
25108
|
function readInstructions(opts) {
|
|
25065
25109
|
if (!opts.instructionsFile) return void 0;
|
|
25066
|
-
const file =
|
|
25110
|
+
const file = path10.resolve(opts.cwd, opts.instructionsFile);
|
|
25067
25111
|
try {
|
|
25068
|
-
return { file, content:
|
|
25112
|
+
return { file, content: fs9.readFileSync(file, "utf-8") };
|
|
25069
25113
|
} catch {
|
|
25070
25114
|
return void 0;
|
|
25071
25115
|
}
|
|
@@ -25088,7 +25132,7 @@ function createPiSession(opts) {
|
|
|
25088
25132
|
agentsFilesOverride: (base) => instructions ? { agentsFiles: [{ path: instructions.file, content: instructions.content }] } : base
|
|
25089
25133
|
});
|
|
25090
25134
|
await resourceLoader.reload();
|
|
25091
|
-
const sessionManager = resumeFile &&
|
|
25135
|
+
const sessionManager = resumeFile && fs9.existsSync(resumeFile) ? pi.SessionManager.open(resumeFile) : pi.SessionManager.create(opts.cwd);
|
|
25092
25136
|
const live = {
|
|
25093
25137
|
running: false,
|
|
25094
25138
|
transcript: [],
|
|
@@ -25307,11 +25351,11 @@ function createCodingAgentSession(harness, opts) {
|
|
|
25307
25351
|
}
|
|
25308
25352
|
|
|
25309
25353
|
// src/codingAgent/registry.ts
|
|
25310
|
-
import * as
|
|
25354
|
+
import * as path11 from "path";
|
|
25311
25355
|
var agents = /* @__PURE__ */ new Map();
|
|
25312
25356
|
var config = {
|
|
25313
|
-
promptRoot:
|
|
25314
|
-
runtimeDir:
|
|
25357
|
+
promptRoot: path11.join(process.cwd(), ".prompts", "coding-agents"),
|
|
25358
|
+
runtimeDir: path11.join(process.cwd(), ".coding-agent-runtime"),
|
|
25315
25359
|
harness: "codex",
|
|
25316
25360
|
keepRuns: 20,
|
|
25317
25361
|
keepThreads: 200
|
|
@@ -25350,13 +25394,13 @@ function getCodingAgentsConfig() {
|
|
|
25350
25394
|
return config;
|
|
25351
25395
|
}
|
|
25352
25396
|
function resolvePromptDir(def) {
|
|
25353
|
-
return def.promptDir ||
|
|
25397
|
+
return def.promptDir || path11.join(config.promptRoot, def.id);
|
|
25354
25398
|
}
|
|
25355
25399
|
|
|
25356
25400
|
// src/codingAgent/runner.ts
|
|
25357
|
-
import * as
|
|
25401
|
+
import * as fs10 from "fs";
|
|
25358
25402
|
import * as fsp from "fs/promises";
|
|
25359
|
-
import * as
|
|
25403
|
+
import * as path12 from "path";
|
|
25360
25404
|
var DEFAULT_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
25361
25405
|
var inFlight = /* @__PURE__ */ new Set();
|
|
25362
25406
|
function slug(v) {
|
|
@@ -25366,11 +25410,11 @@ function resolveScope(def, opts) {
|
|
|
25366
25410
|
const scope = def.scope ?? (def.mode === "chat" ? "thread" : "project");
|
|
25367
25411
|
if (scope === "thread") {
|
|
25368
25412
|
const id = slug(opts.threadId || "default");
|
|
25369
|
-
return { key: `thread:${id}`, dirName:
|
|
25413
|
+
return { key: `thread:${id}`, dirName: path12.join("threads", id) };
|
|
25370
25414
|
}
|
|
25371
25415
|
if (scope === "user") {
|
|
25372
25416
|
const id = slug(opts.userId || "anonymous");
|
|
25373
|
-
return { key: `user:${id}`, dirName:
|
|
25417
|
+
return { key: `user:${id}`, dirName: path12.join("users", id) };
|
|
25374
25418
|
}
|
|
25375
25419
|
return { key: "project", dirName: "_project" };
|
|
25376
25420
|
}
|
|
@@ -25379,30 +25423,30 @@ function makeRunId() {
|
|
|
25379
25423
|
return `${t}-${Math.random().toString(36).slice(2, 8)}`;
|
|
25380
25424
|
}
|
|
25381
25425
|
function statePath(scopeDir) {
|
|
25382
|
-
return
|
|
25426
|
+
return path12.join(scopeDir, "_state.json");
|
|
25383
25427
|
}
|
|
25384
25428
|
function loadState(scopeDir) {
|
|
25385
25429
|
try {
|
|
25386
|
-
return JSON.parse(
|
|
25430
|
+
return JSON.parse(fs10.readFileSync(statePath(scopeDir), "utf-8"));
|
|
25387
25431
|
} catch {
|
|
25388
25432
|
return { turns: 0, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
25389
25433
|
}
|
|
25390
25434
|
}
|
|
25391
25435
|
function saveState(scopeDir, state) {
|
|
25392
25436
|
try {
|
|
25393
|
-
|
|
25394
|
-
|
|
25437
|
+
fs10.mkdirSync(scopeDir, { recursive: true });
|
|
25438
|
+
fs10.writeFileSync(statePath(scopeDir), JSON.stringify({ ...state, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2));
|
|
25395
25439
|
} catch (err) {
|
|
25396
25440
|
logger.warn(`[CodingAgent] failed to persist session state: ${err?.message ?? err}`);
|
|
25397
25441
|
}
|
|
25398
25442
|
}
|
|
25399
25443
|
async function clearTransient(dir) {
|
|
25400
|
-
await fsp.rm(
|
|
25444
|
+
await fsp.rm(path12.join(dir, "input"), { recursive: true, force: true });
|
|
25401
25445
|
}
|
|
25402
25446
|
function createWorkspace(dir, runId) {
|
|
25403
|
-
const abs = (rel) =>
|
|
25447
|
+
const abs = (rel) => path12.join(dir, rel);
|
|
25404
25448
|
const ensureDir = async (rel) => {
|
|
25405
|
-
await fsp.mkdir(
|
|
25449
|
+
await fsp.mkdir(path12.dirname(abs(rel)), { recursive: true });
|
|
25406
25450
|
};
|
|
25407
25451
|
return {
|
|
25408
25452
|
dir,
|
|
@@ -25431,7 +25475,7 @@ function createWorkspace(dir, runId) {
|
|
|
25431
25475
|
}
|
|
25432
25476
|
var INSTRUCTIONS_FILE = "system.md";
|
|
25433
25477
|
async function installInstructions(def, ws) {
|
|
25434
|
-
const src =
|
|
25478
|
+
const src = path12.join(resolvePromptDir(def), "system.md");
|
|
25435
25479
|
try {
|
|
25436
25480
|
await ws.write(INSTRUCTIONS_FILE, await fsp.readFile(src, "utf-8"));
|
|
25437
25481
|
} catch {
|
|
@@ -25445,7 +25489,7 @@ async function pruneThreads(agentId, threadsDir, keep) {
|
|
|
25445
25489
|
const dirs = (await fsp.readdir(threadsDir, { withFileTypes: true })).filter((e) => e.isDirectory());
|
|
25446
25490
|
if (dirs.length <= keep) return;
|
|
25447
25491
|
const aged = await Promise.all(dirs.map(async (e) => {
|
|
25448
|
-
const dir =
|
|
25492
|
+
const dir = path12.join(threadsDir, e.name);
|
|
25449
25493
|
const stat2 = await fsp.stat(statePath(dir)).catch(() => fsp.stat(dir));
|
|
25450
25494
|
return { name: e.name, dir, used: stat2.mtimeMs };
|
|
25451
25495
|
}));
|
|
@@ -25465,7 +25509,7 @@ async function pruneRuns(agentDir, keep) {
|
|
|
25465
25509
|
try {
|
|
25466
25510
|
const entries = (await fsp.readdir(agentDir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
25467
25511
|
for (const name of entries.slice(0, Math.max(0, entries.length - keep))) {
|
|
25468
|
-
await fsp.rm(
|
|
25512
|
+
await fsp.rm(path12.join(agentDir, name), { recursive: true, force: true });
|
|
25469
25513
|
}
|
|
25470
25514
|
} catch {
|
|
25471
25515
|
}
|
|
@@ -25483,17 +25527,17 @@ async function runCodingAgent(agentId, options = {}) {
|
|
|
25483
25527
|
}
|
|
25484
25528
|
const cfg = getCodingAgentsConfig();
|
|
25485
25529
|
const runId = makeRunId();
|
|
25486
|
-
const agentDir =
|
|
25530
|
+
const agentDir = path12.join(cfg.runtimeDir, def.id);
|
|
25487
25531
|
const policy = def.session ?? {};
|
|
25488
25532
|
const persistentWorkspace = policy.workspace === "persistent";
|
|
25489
25533
|
const persistentSession = policy.scope === "persistent";
|
|
25490
25534
|
const runAsJob = !(options.chat === true && def.mode === "task");
|
|
25491
25535
|
const { key: scopeKey, dirName } = resolveScope(def, { userId: options.userId, threadId: options.threadId });
|
|
25492
|
-
const scopeDir =
|
|
25493
|
-
const dir = options.workspaceDir || (persistentWorkspace ? scopeDir :
|
|
25494
|
-
|
|
25536
|
+
const scopeDir = path12.join(agentDir, dirName);
|
|
25537
|
+
const dir = options.workspaceDir || (persistentWorkspace ? scopeDir : path12.join(scopeDir, "runs", runId));
|
|
25538
|
+
fs10.mkdirSync(dir, { recursive: true });
|
|
25495
25539
|
if (persistentWorkspace && !options.workspaceDir) {
|
|
25496
|
-
|
|
25540
|
+
fs10.mkdirSync(path12.join(dir, "memory"), { recursive: true });
|
|
25497
25541
|
if (runAsJob) await clearTransient(dir);
|
|
25498
25542
|
}
|
|
25499
25543
|
const lockKey = persistentWorkspace || persistentSession ? `${def.id}:${scopeKey}` : `dir:${dir}`;
|
|
@@ -25602,7 +25646,7 @@ async function runCodingAgent(agentId, options = {}) {
|
|
|
25602
25646
|
onUsage: ctx.onUsage,
|
|
25603
25647
|
// Opt-in only: see stopOnDeliverable. Letting the turn end naturally
|
|
25604
25648
|
// is what makes usage reporting work at all.
|
|
25605
|
-
...outputPath && def.stopOnDeliverable ? { doneWhen: () =>
|
|
25649
|
+
...outputPath && def.stopOnDeliverable ? { doneWhen: () => fs10.existsSync(outputPath) } : {}
|
|
25606
25650
|
},
|
|
25607
25651
|
timeout.signal
|
|
25608
25652
|
);
|
|
@@ -25707,9 +25751,9 @@ Fix ONLY that, and rewrite the same file at the same path. Do not re-run any que
|
|
|
25707
25751
|
logger.info(
|
|
25708
25752
|
`[CodingAgent:${def.id}] ${runAsJob ? "run" : "chat"}=${runId} status=${record.status} ms=${record.ms} tokens=${record.usage.inputTokens}/${record.usage.outputTokens} tools=${record.usage.toolCalls}` + (record.applied ? ` applied="${record.applied.summary}"` : "") + (record.error ? ` error="${record.error}"` : "")
|
|
25709
25753
|
);
|
|
25710
|
-
if (!options.workspaceDir && !persistentWorkspace) await pruneRuns(
|
|
25711
|
-
if (!options.workspaceDir && dirName.startsWith(`threads${
|
|
25712
|
-
await pruneThreads(def.id,
|
|
25754
|
+
if (!options.workspaceDir && !persistentWorkspace) await pruneRuns(path12.join(scopeDir, "runs"), cfg.keepRuns);
|
|
25755
|
+
if (!options.workspaceDir && dirName.startsWith(`threads${path12.sep}`)) {
|
|
25756
|
+
await pruneThreads(def.id, path12.join(agentDir, "threads"), cfg.keepThreads);
|
|
25713
25757
|
}
|
|
25714
25758
|
}
|
|
25715
25759
|
}
|
|
@@ -25769,14 +25813,14 @@ ${assertReadOnlySql.toString().replace("export function", "function")}
|
|
|
25769
25813
|
`;
|
|
25770
25814
|
|
|
25771
25815
|
// src/codingAgent/tools/shims.ts
|
|
25772
|
-
import * as
|
|
25773
|
-
import * as
|
|
25774
|
-
var resolve3 = (target, name) => typeof target === "string" ?
|
|
25816
|
+
import * as fs11 from "fs";
|
|
25817
|
+
import * as path13 from "path";
|
|
25818
|
+
var resolve3 = (target, name) => typeof target === "string" ? path13.join(target, name) : target.pathTo(name);
|
|
25775
25819
|
function writeShims(defs, target) {
|
|
25776
25820
|
for (const def of defs) {
|
|
25777
25821
|
const file = resolve3(target, def.name);
|
|
25778
|
-
|
|
25779
|
-
|
|
25822
|
+
fs11.writeFileSync(file, def.body, "utf-8");
|
|
25823
|
+
fs11.chmodSync(file, 493);
|
|
25780
25824
|
}
|
|
25781
25825
|
return defs.map((def) => ({ name: `./${def.name}`, summary: def.summary }));
|
|
25782
25826
|
}
|
|
@@ -26043,17 +26087,17 @@ console.log(${JSON.stringify(
|
|
|
26043
26087
|
}
|
|
26044
26088
|
|
|
26045
26089
|
// src/codingAgent/triggers.ts
|
|
26046
|
-
import * as
|
|
26047
|
-
import * as
|
|
26090
|
+
import * as fs12 from "fs";
|
|
26091
|
+
import * as path14 from "path";
|
|
26048
26092
|
var EVENT_BURST_CAP = 200;
|
|
26049
26093
|
var capEvents = (events) => events.length > EVENT_BURST_CAP ? events.slice(-EVENT_BURST_CAP) : events;
|
|
26050
26094
|
function statePath2(agentId) {
|
|
26051
|
-
return
|
|
26095
|
+
return path14.join(getCodingAgentsConfig().runtimeDir, agentId, "_triggers.json");
|
|
26052
26096
|
}
|
|
26053
26097
|
function loadTriggerState(agentId) {
|
|
26054
26098
|
let raw;
|
|
26055
26099
|
try {
|
|
26056
|
-
raw = JSON.parse(
|
|
26100
|
+
raw = JSON.parse(fs12.readFileSync(statePath2(agentId), "utf-8"));
|
|
26057
26101
|
} catch {
|
|
26058
26102
|
return { counts: {}, pending: {} };
|
|
26059
26103
|
}
|
|
@@ -26073,8 +26117,8 @@ function loadTriggerState(agentId) {
|
|
|
26073
26117
|
function saveTriggerState(agentId, state) {
|
|
26074
26118
|
try {
|
|
26075
26119
|
const p = statePath2(agentId);
|
|
26076
|
-
|
|
26077
|
-
|
|
26120
|
+
fs12.mkdirSync(path14.dirname(p), { recursive: true });
|
|
26121
|
+
fs12.writeFileSync(p, JSON.stringify(state, null, 2));
|
|
26078
26122
|
} catch (err) {
|
|
26079
26123
|
logger.warn(`[CodingAgent:${agentId}] failed to persist trigger state: ${err?.message ?? err}`);
|
|
26080
26124
|
}
|
|
@@ -26210,13 +26254,13 @@ function describeTriggers() {
|
|
|
26210
26254
|
}
|
|
26211
26255
|
|
|
26212
26256
|
// src/codingAgent/collection.ts
|
|
26213
|
-
import * as
|
|
26214
|
-
import * as
|
|
26257
|
+
import * as fs13 from "fs";
|
|
26258
|
+
import * as path15 from "path";
|
|
26215
26259
|
function isChattable(agent) {
|
|
26216
26260
|
return agent.mode !== "task";
|
|
26217
26261
|
}
|
|
26218
26262
|
function registerCodingAgentCollection(sdk, config2 = {}) {
|
|
26219
|
-
const runtimeDir = config2.runtimeDir || process.env.CODING_AGENT_RUNTIME_DIR ||
|
|
26263
|
+
const runtimeDir = config2.runtimeDir || process.env.CODING_AGENT_RUNTIME_DIR || path15.join(process.cwd(), ".coding-agent-runtime");
|
|
26220
26264
|
const defaultHarness = config2.harness || process.env.CODING_AGENT_HARNESS || "codex";
|
|
26221
26265
|
const sessions = /* @__PURE__ */ new Map();
|
|
26222
26266
|
const running = /* @__PURE__ */ new Set();
|
|
@@ -26276,8 +26320,8 @@ function registerCodingAgentCollection(sdk, config2 = {}) {
|
|
|
26276
26320
|
...record.status === "skipped" ? { error: `${def.title} is in the middle of a run \u2014 try again in a moment.` } : record.error ? { error: record.error } : {}
|
|
26277
26321
|
};
|
|
26278
26322
|
}
|
|
26279
|
-
const cwd =
|
|
26280
|
-
|
|
26323
|
+
const cwd = path15.join(runtimeDir, "threads", threadId);
|
|
26324
|
+
fs13.mkdirSync(cwd, { recursive: true });
|
|
26281
26325
|
let session = sessions.get(threadId);
|
|
26282
26326
|
if (!session) {
|
|
26283
26327
|
session = createCodingAgentSession(harness || defaultHarness, {
|
|
@@ -27556,9 +27600,9 @@ function getLLMProviders() {
|
|
|
27556
27600
|
}
|
|
27557
27601
|
|
|
27558
27602
|
// src/auth/user-manager.ts
|
|
27559
|
-
import
|
|
27560
|
-
import
|
|
27561
|
-
import
|
|
27603
|
+
import fs14 from "fs";
|
|
27604
|
+
import path16 from "path";
|
|
27605
|
+
import os3 from "os";
|
|
27562
27606
|
var UserManager = class {
|
|
27563
27607
|
/**
|
|
27564
27608
|
* Initialize UserManager with file path and sync interval
|
|
@@ -27570,7 +27614,7 @@ var UserManager = class {
|
|
|
27570
27614
|
this.hasChanged = false;
|
|
27571
27615
|
this.syncInterval = null;
|
|
27572
27616
|
this.isInitialized = false;
|
|
27573
|
-
this.filePath =
|
|
27617
|
+
this.filePath = path16.join(os3.homedir(), ".superatom", "projects", projectId, "users.json");
|
|
27574
27618
|
this.syncIntervalMs = syncIntervalMs;
|
|
27575
27619
|
}
|
|
27576
27620
|
/**
|
|
@@ -27595,20 +27639,20 @@ var UserManager = class {
|
|
|
27595
27639
|
*/
|
|
27596
27640
|
async loadUsersFromFile() {
|
|
27597
27641
|
try {
|
|
27598
|
-
const dir =
|
|
27599
|
-
if (!
|
|
27642
|
+
const dir = path16.dirname(this.filePath);
|
|
27643
|
+
if (!fs14.existsSync(dir)) {
|
|
27600
27644
|
logger.info(`Creating directory structure: ${dir}`);
|
|
27601
|
-
|
|
27645
|
+
fs14.mkdirSync(dir, { recursive: true });
|
|
27602
27646
|
}
|
|
27603
|
-
if (!
|
|
27647
|
+
if (!fs14.existsSync(this.filePath)) {
|
|
27604
27648
|
logger.info(`Users file does not exist at ${this.filePath}, creating with empty users`);
|
|
27605
27649
|
const initialData = { users: [] };
|
|
27606
|
-
|
|
27650
|
+
fs14.writeFileSync(this.filePath, JSON.stringify(initialData, null, 4));
|
|
27607
27651
|
this.users = [];
|
|
27608
27652
|
this.hasChanged = false;
|
|
27609
27653
|
return;
|
|
27610
27654
|
}
|
|
27611
|
-
const fileContent =
|
|
27655
|
+
const fileContent = fs14.readFileSync(this.filePath, "utf-8");
|
|
27612
27656
|
const rawData = JSON.parse(fileContent);
|
|
27613
27657
|
const validatedData = UsersDataSchema.parse(rawData);
|
|
27614
27658
|
this.users = validatedData.users;
|
|
@@ -27627,16 +27671,16 @@ var UserManager = class {
|
|
|
27627
27671
|
return;
|
|
27628
27672
|
}
|
|
27629
27673
|
try {
|
|
27630
|
-
const dir =
|
|
27631
|
-
if (!
|
|
27632
|
-
|
|
27674
|
+
const dir = path16.dirname(this.filePath);
|
|
27675
|
+
if (!fs14.existsSync(dir)) {
|
|
27676
|
+
fs14.mkdirSync(dir, { recursive: true });
|
|
27633
27677
|
}
|
|
27634
27678
|
const usersToSave = this.users.map((user) => {
|
|
27635
27679
|
const { wsIds, ...userWithoutWsIds } = user;
|
|
27636
27680
|
return userWithoutWsIds;
|
|
27637
27681
|
});
|
|
27638
27682
|
const data = { users: usersToSave };
|
|
27639
|
-
|
|
27683
|
+
fs14.writeFileSync(this.filePath, JSON.stringify(data, null, 4));
|
|
27640
27684
|
this.hasChanged = false;
|
|
27641
27685
|
logger.debug(`Synced ${this.users.length} users to file (wsIds excluded)`);
|
|
27642
27686
|
} catch (error) {
|
|
@@ -27854,9 +27898,9 @@ var UserManager = class {
|
|
|
27854
27898
|
};
|
|
27855
27899
|
|
|
27856
27900
|
// src/dashboards/dashboard-manager.ts
|
|
27857
|
-
import
|
|
27858
|
-
import
|
|
27859
|
-
import
|
|
27901
|
+
import fs15 from "fs";
|
|
27902
|
+
import path17 from "path";
|
|
27903
|
+
import os4 from "os";
|
|
27860
27904
|
var DashboardManager = class {
|
|
27861
27905
|
/**
|
|
27862
27906
|
* Initialize DashboardManager with project ID
|
|
@@ -27864,8 +27908,8 @@ var DashboardManager = class {
|
|
|
27864
27908
|
*/
|
|
27865
27909
|
constructor(projectId = "snowflake-dataset") {
|
|
27866
27910
|
this.projectId = projectId;
|
|
27867
|
-
this.dashboardsBasePath =
|
|
27868
|
-
|
|
27911
|
+
this.dashboardsBasePath = path17.join(
|
|
27912
|
+
os4.homedir(),
|
|
27869
27913
|
".superatom",
|
|
27870
27914
|
"projects",
|
|
27871
27915
|
projectId,
|
|
@@ -27878,7 +27922,7 @@ var DashboardManager = class {
|
|
|
27878
27922
|
* @returns Full path to dashboard data.json file
|
|
27879
27923
|
*/
|
|
27880
27924
|
getDashboardPath(dashboardId) {
|
|
27881
|
-
return
|
|
27925
|
+
return path17.join(this.dashboardsBasePath, dashboardId, "data.json");
|
|
27882
27926
|
}
|
|
27883
27927
|
/**
|
|
27884
27928
|
* Create a new dashboard
|
|
@@ -27888,13 +27932,13 @@ var DashboardManager = class {
|
|
|
27888
27932
|
*/
|
|
27889
27933
|
createDashboard(dashboardId, dashboard) {
|
|
27890
27934
|
const dashboardPath = this.getDashboardPath(dashboardId);
|
|
27891
|
-
const dashboardDir =
|
|
27892
|
-
if (
|
|
27935
|
+
const dashboardDir = path17.dirname(dashboardPath);
|
|
27936
|
+
if (fs15.existsSync(dashboardPath)) {
|
|
27893
27937
|
throw new Error(`Dashboard '${dashboardId}' already exists`);
|
|
27894
27938
|
}
|
|
27895
27939
|
const validated = DSLRendererPropsSchema.parse(dashboard);
|
|
27896
|
-
|
|
27897
|
-
|
|
27940
|
+
fs15.mkdirSync(dashboardDir, { recursive: true });
|
|
27941
|
+
fs15.writeFileSync(dashboardPath, JSON.stringify(validated, null, 4));
|
|
27898
27942
|
logger.info(`Dashboard created: ${dashboardId}`);
|
|
27899
27943
|
return validated;
|
|
27900
27944
|
}
|
|
@@ -27905,12 +27949,12 @@ var DashboardManager = class {
|
|
|
27905
27949
|
*/
|
|
27906
27950
|
getDashboard(dashboardId) {
|
|
27907
27951
|
const dashboardPath = this.getDashboardPath(dashboardId);
|
|
27908
|
-
if (!
|
|
27952
|
+
if (!fs15.existsSync(dashboardPath)) {
|
|
27909
27953
|
logger.warn(`Dashboard not found: ${dashboardId}`);
|
|
27910
27954
|
return null;
|
|
27911
27955
|
}
|
|
27912
27956
|
try {
|
|
27913
|
-
const fileContent =
|
|
27957
|
+
const fileContent = fs15.readFileSync(dashboardPath, "utf-8");
|
|
27914
27958
|
const dashboard = JSON.parse(fileContent);
|
|
27915
27959
|
const validated = DSLRendererPropsSchema.parse(dashboard);
|
|
27916
27960
|
return validated;
|
|
@@ -27924,16 +27968,16 @@ var DashboardManager = class {
|
|
|
27924
27968
|
* @returns Array of dashboard objects with their IDs
|
|
27925
27969
|
*/
|
|
27926
27970
|
getAllDashboards() {
|
|
27927
|
-
if (!
|
|
27928
|
-
|
|
27971
|
+
if (!fs15.existsSync(this.dashboardsBasePath)) {
|
|
27972
|
+
fs15.mkdirSync(this.dashboardsBasePath, { recursive: true });
|
|
27929
27973
|
return [];
|
|
27930
27974
|
}
|
|
27931
27975
|
const dashboards = [];
|
|
27932
27976
|
try {
|
|
27933
|
-
const dashboardDirs =
|
|
27977
|
+
const dashboardDirs = fs15.readdirSync(this.dashboardsBasePath);
|
|
27934
27978
|
for (const dashboardId of dashboardDirs) {
|
|
27935
27979
|
const dashboardPath = this.getDashboardPath(dashboardId);
|
|
27936
|
-
if (
|
|
27980
|
+
if (fs15.existsSync(dashboardPath)) {
|
|
27937
27981
|
const dashboard = this.getDashboard(dashboardId);
|
|
27938
27982
|
if (dashboard) {
|
|
27939
27983
|
dashboards.push({ dashboardId, dashboard });
|
|
@@ -27955,13 +27999,13 @@ var DashboardManager = class {
|
|
|
27955
27999
|
*/
|
|
27956
28000
|
updateDashboard(dashboardId, dashboard) {
|
|
27957
28001
|
const dashboardPath = this.getDashboardPath(dashboardId);
|
|
27958
|
-
if (!
|
|
28002
|
+
if (!fs15.existsSync(dashboardPath)) {
|
|
27959
28003
|
logger.warn(`Dashboard not found for update: ${dashboardId}`);
|
|
27960
28004
|
return null;
|
|
27961
28005
|
}
|
|
27962
28006
|
try {
|
|
27963
28007
|
const validated = DSLRendererPropsSchema.parse(dashboard);
|
|
27964
|
-
|
|
28008
|
+
fs15.writeFileSync(dashboardPath, JSON.stringify(validated, null, 4));
|
|
27965
28009
|
logger.info(`Dashboard updated: ${dashboardId}`);
|
|
27966
28010
|
return validated;
|
|
27967
28011
|
} catch (error) {
|
|
@@ -27976,13 +28020,13 @@ var DashboardManager = class {
|
|
|
27976
28020
|
*/
|
|
27977
28021
|
deleteDashboard(dashboardId) {
|
|
27978
28022
|
const dashboardPath = this.getDashboardPath(dashboardId);
|
|
27979
|
-
const dashboardDir =
|
|
27980
|
-
if (!
|
|
28023
|
+
const dashboardDir = path17.dirname(dashboardPath);
|
|
28024
|
+
if (!fs15.existsSync(dashboardPath)) {
|
|
27981
28025
|
logger.warn(`Dashboard not found for deletion: ${dashboardId}`);
|
|
27982
28026
|
return false;
|
|
27983
28027
|
}
|
|
27984
28028
|
try {
|
|
27985
|
-
|
|
28029
|
+
fs15.rmSync(dashboardDir, { recursive: true, force: true });
|
|
27986
28030
|
logger.info(`Dashboard deleted: ${dashboardId}`);
|
|
27987
28031
|
return true;
|
|
27988
28032
|
} catch (error) {
|
|
@@ -27997,21 +28041,21 @@ var DashboardManager = class {
|
|
|
27997
28041
|
*/
|
|
27998
28042
|
dashboardExists(dashboardId) {
|
|
27999
28043
|
const dashboardPath = this.getDashboardPath(dashboardId);
|
|
28000
|
-
return
|
|
28044
|
+
return fs15.existsSync(dashboardPath);
|
|
28001
28045
|
}
|
|
28002
28046
|
/**
|
|
28003
28047
|
* Get dashboard count
|
|
28004
28048
|
* @returns Number of dashboards
|
|
28005
28049
|
*/
|
|
28006
28050
|
getDashboardCount() {
|
|
28007
|
-
if (!
|
|
28051
|
+
if (!fs15.existsSync(this.dashboardsBasePath)) {
|
|
28008
28052
|
return 0;
|
|
28009
28053
|
}
|
|
28010
28054
|
try {
|
|
28011
|
-
const dashboardDirs =
|
|
28055
|
+
const dashboardDirs = fs15.readdirSync(this.dashboardsBasePath);
|
|
28012
28056
|
return dashboardDirs.filter((dir) => {
|
|
28013
28057
|
const dashboardPath = this.getDashboardPath(dir);
|
|
28014
|
-
return
|
|
28058
|
+
return fs15.existsSync(dashboardPath);
|
|
28015
28059
|
}).length;
|
|
28016
28060
|
} catch (error) {
|
|
28017
28061
|
logger.error("Failed to get dashboard count:", error);
|
|
@@ -28021,9 +28065,9 @@ var DashboardManager = class {
|
|
|
28021
28065
|
};
|
|
28022
28066
|
|
|
28023
28067
|
// src/reports/report-manager.ts
|
|
28024
|
-
import
|
|
28025
|
-
import
|
|
28026
|
-
import
|
|
28068
|
+
import fs16 from "fs";
|
|
28069
|
+
import path18 from "path";
|
|
28070
|
+
import os5 from "os";
|
|
28027
28071
|
var ReportManager = class {
|
|
28028
28072
|
/**
|
|
28029
28073
|
* Initialize ReportManager with project ID
|
|
@@ -28031,8 +28075,8 @@ var ReportManager = class {
|
|
|
28031
28075
|
*/
|
|
28032
28076
|
constructor(projectId = "snowflake-dataset") {
|
|
28033
28077
|
this.projectId = projectId;
|
|
28034
|
-
this.reportsBasePath =
|
|
28035
|
-
|
|
28078
|
+
this.reportsBasePath = path18.join(
|
|
28079
|
+
os5.homedir(),
|
|
28036
28080
|
".superatom",
|
|
28037
28081
|
"projects",
|
|
28038
28082
|
projectId,
|
|
@@ -28045,7 +28089,7 @@ var ReportManager = class {
|
|
|
28045
28089
|
* @returns Full path to report data.json file
|
|
28046
28090
|
*/
|
|
28047
28091
|
getReportPath(reportId) {
|
|
28048
|
-
return
|
|
28092
|
+
return path18.join(this.reportsBasePath, reportId, "data.json");
|
|
28049
28093
|
}
|
|
28050
28094
|
/**
|
|
28051
28095
|
* Create a new report
|
|
@@ -28055,13 +28099,13 @@ var ReportManager = class {
|
|
|
28055
28099
|
*/
|
|
28056
28100
|
createReport(reportId, report) {
|
|
28057
28101
|
const reportPath = this.getReportPath(reportId);
|
|
28058
|
-
const reportDir =
|
|
28059
|
-
if (
|
|
28102
|
+
const reportDir = path18.dirname(reportPath);
|
|
28103
|
+
if (fs16.existsSync(reportPath)) {
|
|
28060
28104
|
throw new Error(`Report '${reportId}' already exists`);
|
|
28061
28105
|
}
|
|
28062
28106
|
const validated = DSLRendererPropsSchema2.parse(report);
|
|
28063
|
-
|
|
28064
|
-
|
|
28107
|
+
fs16.mkdirSync(reportDir, { recursive: true });
|
|
28108
|
+
fs16.writeFileSync(reportPath, JSON.stringify(validated, null, 4));
|
|
28065
28109
|
logger.info(`Report created: ${reportId}`);
|
|
28066
28110
|
return validated;
|
|
28067
28111
|
}
|
|
@@ -28072,12 +28116,12 @@ var ReportManager = class {
|
|
|
28072
28116
|
*/
|
|
28073
28117
|
getReport(reportId) {
|
|
28074
28118
|
const reportPath = this.getReportPath(reportId);
|
|
28075
|
-
if (!
|
|
28119
|
+
if (!fs16.existsSync(reportPath)) {
|
|
28076
28120
|
logger.warn(`Report not found: ${reportId}`);
|
|
28077
28121
|
return null;
|
|
28078
28122
|
}
|
|
28079
28123
|
try {
|
|
28080
|
-
const fileContent =
|
|
28124
|
+
const fileContent = fs16.readFileSync(reportPath, "utf-8");
|
|
28081
28125
|
const report = JSON.parse(fileContent);
|
|
28082
28126
|
const validated = DSLRendererPropsSchema2.parse(report);
|
|
28083
28127
|
return validated;
|
|
@@ -28091,16 +28135,16 @@ var ReportManager = class {
|
|
|
28091
28135
|
* @returns Array of report objects with their IDs
|
|
28092
28136
|
*/
|
|
28093
28137
|
getAllReports() {
|
|
28094
|
-
if (!
|
|
28095
|
-
|
|
28138
|
+
if (!fs16.existsSync(this.reportsBasePath)) {
|
|
28139
|
+
fs16.mkdirSync(this.reportsBasePath, { recursive: true });
|
|
28096
28140
|
return [];
|
|
28097
28141
|
}
|
|
28098
28142
|
const reports = [];
|
|
28099
28143
|
try {
|
|
28100
|
-
const reportDirs =
|
|
28144
|
+
const reportDirs = fs16.readdirSync(this.reportsBasePath);
|
|
28101
28145
|
for (const reportId of reportDirs) {
|
|
28102
28146
|
const reportPath = this.getReportPath(reportId);
|
|
28103
|
-
if (
|
|
28147
|
+
if (fs16.existsSync(reportPath)) {
|
|
28104
28148
|
const report = this.getReport(reportId);
|
|
28105
28149
|
if (report) {
|
|
28106
28150
|
reports.push({ reportId, report });
|
|
@@ -28122,13 +28166,13 @@ var ReportManager = class {
|
|
|
28122
28166
|
*/
|
|
28123
28167
|
updateReport(reportId, report) {
|
|
28124
28168
|
const reportPath = this.getReportPath(reportId);
|
|
28125
|
-
if (!
|
|
28169
|
+
if (!fs16.existsSync(reportPath)) {
|
|
28126
28170
|
logger.warn(`Report not found for update: ${reportId}`);
|
|
28127
28171
|
return null;
|
|
28128
28172
|
}
|
|
28129
28173
|
try {
|
|
28130
28174
|
const validated = DSLRendererPropsSchema2.parse(report);
|
|
28131
|
-
|
|
28175
|
+
fs16.writeFileSync(reportPath, JSON.stringify(validated, null, 4));
|
|
28132
28176
|
logger.info(`Report updated: ${reportId}`);
|
|
28133
28177
|
return validated;
|
|
28134
28178
|
} catch (error) {
|
|
@@ -28143,13 +28187,13 @@ var ReportManager = class {
|
|
|
28143
28187
|
*/
|
|
28144
28188
|
deleteReport(reportId) {
|
|
28145
28189
|
const reportPath = this.getReportPath(reportId);
|
|
28146
|
-
const reportDir =
|
|
28147
|
-
if (!
|
|
28190
|
+
const reportDir = path18.dirname(reportPath);
|
|
28191
|
+
if (!fs16.existsSync(reportPath)) {
|
|
28148
28192
|
logger.warn(`Report not found for deletion: ${reportId}`);
|
|
28149
28193
|
return false;
|
|
28150
28194
|
}
|
|
28151
28195
|
try {
|
|
28152
|
-
|
|
28196
|
+
fs16.rmSync(reportDir, { recursive: true, force: true });
|
|
28153
28197
|
logger.info(`Report deleted: ${reportId}`);
|
|
28154
28198
|
return true;
|
|
28155
28199
|
} catch (error) {
|
|
@@ -28164,21 +28208,21 @@ var ReportManager = class {
|
|
|
28164
28208
|
*/
|
|
28165
28209
|
reportExists(reportId) {
|
|
28166
28210
|
const reportPath = this.getReportPath(reportId);
|
|
28167
|
-
return
|
|
28211
|
+
return fs16.existsSync(reportPath);
|
|
28168
28212
|
}
|
|
28169
28213
|
/**
|
|
28170
28214
|
* Get report count
|
|
28171
28215
|
* @returns Number of reports
|
|
28172
28216
|
*/
|
|
28173
28217
|
getReportCount() {
|
|
28174
|
-
if (!
|
|
28218
|
+
if (!fs16.existsSync(this.reportsBasePath)) {
|
|
28175
28219
|
return 0;
|
|
28176
28220
|
}
|
|
28177
28221
|
try {
|
|
28178
|
-
const reportDirs =
|
|
28222
|
+
const reportDirs = fs16.readdirSync(this.reportsBasePath);
|
|
28179
28223
|
return reportDirs.filter((dir) => {
|
|
28180
28224
|
const reportPath = this.getReportPath(dir);
|
|
28181
|
-
return
|
|
28225
|
+
return fs16.existsSync(reportPath);
|
|
28182
28226
|
}).length;
|
|
28183
28227
|
} catch (error) {
|
|
28184
28228
|
logger.error("Failed to get report count:", error);
|
|
@@ -28672,8 +28716,8 @@ var CleanupService = class _CleanupService {
|
|
|
28672
28716
|
};
|
|
28673
28717
|
|
|
28674
28718
|
// src/dashboardAgent/collection.ts
|
|
28675
|
-
import
|
|
28676
|
-
import
|
|
28719
|
+
import path19 from "path";
|
|
28720
|
+
import fs17 from "fs";
|
|
28677
28721
|
|
|
28678
28722
|
// src/dashboardAgent/tools.ts
|
|
28679
28723
|
import { Type } from "typebox";
|
|
@@ -29005,16 +29049,16 @@ function textDelta(event) {
|
|
|
29005
29049
|
}
|
|
29006
29050
|
var runningDashboards = /* @__PURE__ */ new Set();
|
|
29007
29051
|
function registerDashboardAgentCollection(sdk, config2 = {}) {
|
|
29008
|
-
const piCwd = config2.cwd || process.env.PI_AGENT_DIR ||
|
|
29009
|
-
const runtimeDir = config2.runtimeDir || process.env.PI_AGENT_RUNTIME_DIR ||
|
|
29052
|
+
const piCwd = config2.cwd || process.env.PI_AGENT_DIR || path19.join(process.cwd(), ".prompts", "dashboard-agent");
|
|
29053
|
+
const runtimeDir = config2.runtimeDir || process.env.PI_AGENT_RUNTIME_DIR || path19.join(process.cwd(), ".pi-dashboard-agent-runtime");
|
|
29010
29054
|
const freshSession = config2.freshSession ?? process.env.PI_AGENT_FRESH_SESSION !== "false";
|
|
29011
|
-
const SESSIONS_FILE =
|
|
29012
|
-
const DRAFTS_DIR =
|
|
29013
|
-
const DASHBOARD_LOG_FILE =
|
|
29055
|
+
const SESSIONS_FILE = path19.join(runtimeDir, ".pi-dashboard-sessions.json");
|
|
29056
|
+
const DRAFTS_DIR = path19.join(runtimeDir, "drafts");
|
|
29057
|
+
const DASHBOARD_LOG_FILE = path19.join(runtimeDir, "dashboard.log");
|
|
29014
29058
|
function appendLog(text) {
|
|
29015
29059
|
try {
|
|
29016
|
-
|
|
29017
|
-
|
|
29060
|
+
fs17.mkdirSync(runtimeDir, { recursive: true });
|
|
29061
|
+
fs17.appendFileSync(DASHBOARD_LOG_FILE, text);
|
|
29018
29062
|
} catch (err) {
|
|
29019
29063
|
console.warn(`[DashboardAgent] Failed to write dashboard.log: ${err?.message ?? err}`);
|
|
29020
29064
|
}
|
|
@@ -29026,15 +29070,15 @@ ${fullPrompt}
|
|
|
29026
29070
|
--- Response ---
|
|
29027
29071
|
`;
|
|
29028
29072
|
try {
|
|
29029
|
-
|
|
29030
|
-
|
|
29073
|
+
fs17.mkdirSync(runtimeDir, { recursive: true });
|
|
29074
|
+
fs17.writeFileSync(DASHBOARD_LOG_FILE, header);
|
|
29031
29075
|
} catch (err) {
|
|
29032
29076
|
console.warn(`[DashboardAgent] Failed to write dashboard.log: ${err?.message ?? err}`);
|
|
29033
29077
|
}
|
|
29034
29078
|
}
|
|
29035
29079
|
function readDraft(dashboardId) {
|
|
29036
29080
|
try {
|
|
29037
|
-
const raw =
|
|
29081
|
+
const raw = fs17.readFileSync(path19.join(DRAFTS_DIR, `${dashboardId}.json`), "utf-8");
|
|
29038
29082
|
return JSON.parse(raw);
|
|
29039
29083
|
} catch (err) {
|
|
29040
29084
|
console.warn(`[DashboardAgent] Failed to read draft for ${dashboardId}: ${err?.message ?? err}`);
|
|
@@ -29043,7 +29087,7 @@ ${fullPrompt}
|
|
|
29043
29087
|
}
|
|
29044
29088
|
function loadSessionMap() {
|
|
29045
29089
|
try {
|
|
29046
|
-
return JSON.parse(
|
|
29090
|
+
return JSON.parse(fs17.readFileSync(SESSIONS_FILE, "utf-8"));
|
|
29047
29091
|
} catch {
|
|
29048
29092
|
return {};
|
|
29049
29093
|
}
|
|
@@ -29052,8 +29096,8 @@ ${fullPrompt}
|
|
|
29052
29096
|
const map = loadSessionMap();
|
|
29053
29097
|
map[dashboardId] = sessionFile;
|
|
29054
29098
|
try {
|
|
29055
|
-
|
|
29056
|
-
|
|
29099
|
+
fs17.mkdirSync(piCwd, { recursive: true });
|
|
29100
|
+
fs17.writeFileSync(SESSIONS_FILE, JSON.stringify(map, null, 2));
|
|
29057
29101
|
} catch (err) {
|
|
29058
29102
|
console.warn(`[DashboardAgent] Failed to persist session file for ${dashboardId}: ${err?.message ?? err}`);
|
|
29059
29103
|
}
|
|
@@ -29229,7 +29273,7 @@ ${turn.responseText ?? ""}`).join("\n\n");
|
|
|
29229
29273
|
console.warn(`[DashboardAgent] Failed to fetch previous responses for ${dashboardId}: ${err?.message ?? err}`);
|
|
29230
29274
|
}
|
|
29231
29275
|
}
|
|
29232
|
-
const draftPath =
|
|
29276
|
+
const draftPath = path19.join(DRAFTS_DIR, `${dashboardId}.json`);
|
|
29233
29277
|
const fullPrompt = [
|
|
29234
29278
|
`Dashboard ID: ${dashboardId}.`,
|
|
29235
29279
|
projectId ? `Project ID: ${projectId}.` : null,
|
|
@@ -29261,7 +29305,7 @@ ${previousResponseText}` : null,
|
|
|
29261
29305
|
let sessionManager;
|
|
29262
29306
|
if (!freshSession) {
|
|
29263
29307
|
const existingSessionFile = loadSessionMap()[dashboardId];
|
|
29264
|
-
if (existingSessionFile &&
|
|
29308
|
+
if (existingSessionFile && fs17.existsSync(existingSessionFile)) {
|
|
29265
29309
|
sessionManager = SessionManager.open(existingSessionFile, runtimeDir);
|
|
29266
29310
|
console.log(`[DashboardAgent] Resuming session file ${existingSessionFile} for dashboard ${dashboardId}`);
|
|
29267
29311
|
} else {
|
|
@@ -29340,7 +29384,7 @@ ${description}
|
|
|
29340
29384
|
};
|
|
29341
29385
|
signal?.addEventListener("abort", onAbort, { once: true });
|
|
29342
29386
|
try {
|
|
29343
|
-
|
|
29387
|
+
fs17.unlinkSync(draftPath);
|
|
29344
29388
|
} catch {
|
|
29345
29389
|
}
|
|
29346
29390
|
let result;
|
|
@@ -29360,7 +29404,7 @@ ${description}
|
|
|
29360
29404
|
signal?.removeEventListener("abort", onAbort);
|
|
29361
29405
|
if (freshSession && session.sessionFile) {
|
|
29362
29406
|
try {
|
|
29363
|
-
|
|
29407
|
+
fs17.unlinkSync(session.sessionFile);
|
|
29364
29408
|
} catch (err) {
|
|
29365
29409
|
console.warn(`[DashboardAgent] Failed to delete fresh-session file ${session.sessionFile}: ${err?.message ?? err}`);
|
|
29366
29410
|
}
|
|
@@ -30228,6 +30272,8 @@ export {
|
|
|
30228
30272
|
ANSWER_COMPONENT_NAMES,
|
|
30229
30273
|
BM25L,
|
|
30230
30274
|
CATEGORY_KEYS,
|
|
30275
|
+
CODEX_DOC_MAX_BYTES,
|
|
30276
|
+
CODEX_OPENROUTER_KEY_ENV,
|
|
30231
30277
|
CONTEXT_CONFIG,
|
|
30232
30278
|
CleanupService,
|
|
30233
30279
|
DEFAULT_AGENT_CONFIG,
|
|
@@ -30256,6 +30302,9 @@ export {
|
|
|
30256
30302
|
bridgePreamble,
|
|
30257
30303
|
captureContext,
|
|
30258
30304
|
clearContextTokens,
|
|
30305
|
+
codexDefaultProvider,
|
|
30306
|
+
codexModelFor,
|
|
30307
|
+
codexRunConfig,
|
|
30259
30308
|
constraintPoliciesFromConfig,
|
|
30260
30309
|
contextTokenCount,
|
|
30261
30310
|
createCodexSession,
|