@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.js
CHANGED
|
@@ -34,6 +34,8 @@ __export(index_exports, {
|
|
|
34
34
|
ANSWER_COMPONENT_NAMES: () => ANSWER_COMPONENT_NAMES,
|
|
35
35
|
BM25L: () => BM25L,
|
|
36
36
|
CATEGORY_KEYS: () => CATEGORY_KEYS,
|
|
37
|
+
CODEX_DOC_MAX_BYTES: () => CODEX_DOC_MAX_BYTES,
|
|
38
|
+
CODEX_OPENROUTER_KEY_ENV: () => CODEX_OPENROUTER_KEY_ENV,
|
|
37
39
|
CONTEXT_CONFIG: () => CONTEXT_CONFIG,
|
|
38
40
|
CleanupService: () => CleanupService,
|
|
39
41
|
DEFAULT_AGENT_CONFIG: () => DEFAULT_AGENT_CONFIG,
|
|
@@ -62,6 +64,9 @@ __export(index_exports, {
|
|
|
62
64
|
bridgePreamble: () => bridgePreamble,
|
|
63
65
|
captureContext: () => captureContext,
|
|
64
66
|
clearContextTokens: () => clearContextTokens,
|
|
67
|
+
codexDefaultProvider: () => codexDefaultProvider,
|
|
68
|
+
codexModelFor: () => codexModelFor,
|
|
69
|
+
codexRunConfig: () => codexRunConfig,
|
|
65
70
|
constraintPoliciesFromConfig: () => constraintPoliciesFromConfig,
|
|
66
71
|
contextTokenCount: () => contextTokenCount,
|
|
67
72
|
createCodexSession: () => createCodexSession,
|
|
@@ -24704,6 +24709,9 @@ async function handleDashboardAgentRequest(data, collections, sendMessage) {
|
|
|
24704
24709
|
}
|
|
24705
24710
|
|
|
24706
24711
|
// src/codingAgent/drivers/codex.ts
|
|
24712
|
+
var fs8 = __toESM(require("fs"));
|
|
24713
|
+
var os2 = __toESM(require("os"));
|
|
24714
|
+
var path9 = __toESM(require("path"));
|
|
24707
24715
|
var dynamicImport = new Function("specifier", "return import(specifier)");
|
|
24708
24716
|
var codexModulePromise = null;
|
|
24709
24717
|
function loadCodex() {
|
|
@@ -24801,17 +24809,67 @@ function markerFor(event) {
|
|
|
24801
24809
|
return null;
|
|
24802
24810
|
}
|
|
24803
24811
|
}
|
|
24804
|
-
function buildEnv(opts) {
|
|
24805
|
-
|
|
24812
|
+
function buildEnv(opts, provider = null) {
|
|
24813
|
+
const extra = { ...provider?.env ?? {}, ...opts.env ?? {} };
|
|
24814
|
+
if (opts.inheritEnv) return Object.keys(extra).length ? { ...process.env, ...extra } : void 0;
|
|
24806
24815
|
const env = {};
|
|
24807
24816
|
for (const [k, v] of Object.entries(process.env)) {
|
|
24808
24817
|
if (v === void 0) continue;
|
|
24809
24818
|
if (envAllowed(k)) env[k] = v;
|
|
24810
24819
|
}
|
|
24811
|
-
return { ...env, ...
|
|
24820
|
+
return { ...env, ...extra };
|
|
24821
|
+
}
|
|
24822
|
+
var CODEX_DOC_MAX_BYTES = 256 * 1024;
|
|
24823
|
+
var CODEX_OPENROUTER_KEY_ENV = "CODEX_OPENROUTER_API_KEY";
|
|
24824
|
+
function tomlTopLevel(toml) {
|
|
24825
|
+
const i = toml.search(/^\s*\[/m);
|
|
24826
|
+
return i < 0 ? toml : toml.slice(0, i);
|
|
24827
|
+
}
|
|
24828
|
+
function readCodexConfig(env) {
|
|
24829
|
+
try {
|
|
24830
|
+
return fs8.readFileSync(path9.join(env.CODEX_HOME || path9.join(os2.homedir(), ".codex"), "config.toml"), "utf-8");
|
|
24831
|
+
} catch {
|
|
24832
|
+
return "";
|
|
24833
|
+
}
|
|
24834
|
+
}
|
|
24835
|
+
function codexDefaultProvider(env = process.env, configToml) {
|
|
24836
|
+
const choice = env.CODEX_MODEL_PROVIDER?.trim();
|
|
24837
|
+
if (choice && choice !== "openrouter") return null;
|
|
24838
|
+
if (!choice && /^\s*model_provider\s*=/m.test(tomlTopLevel(configToml ?? readCodexConfig(env)))) return null;
|
|
24839
|
+
const key = env.OPENROUTER_API_KEY?.trim();
|
|
24840
|
+
if (!key) return null;
|
|
24841
|
+
const root = env.SUPERATOM_LLM_PROXY_URL?.trim();
|
|
24842
|
+
const baseUrl = env.OPENROUTER_BASE_URL?.trim() || (root ? `${root.replace(/\/+$/, "")}/openrouter` : "https://openrouter.ai/api/v1");
|
|
24843
|
+
return {
|
|
24844
|
+
config: {
|
|
24845
|
+
model_provider: "openrouter",
|
|
24846
|
+
model_providers: { openrouter: { name: "OpenRouter", base_url: baseUrl, env_key: CODEX_OPENROUTER_KEY_ENV, wire_api: "responses" } },
|
|
24847
|
+
// codex's default compacts at ~112k tokens, well short of the model's window.
|
|
24848
|
+
model_auto_compact_token_limit: 23e4
|
|
24849
|
+
},
|
|
24850
|
+
env: { [CODEX_OPENROUTER_KEY_ENV]: key }
|
|
24851
|
+
};
|
|
24852
|
+
}
|
|
24853
|
+
function codexModelFor(model, provider) {
|
|
24854
|
+
return provider && model && !model.includes("/") ? `openai/${model}` : model;
|
|
24855
|
+
}
|
|
24856
|
+
function codexRunConfig(opts, provider = null) {
|
|
24857
|
+
return {
|
|
24858
|
+
// Tools reach codex as MCP servers; each server's name shows up on
|
|
24859
|
+
// every tool event, so the runner can tell ours from codex's own.
|
|
24860
|
+
...opts.mcpServers && Object.keys(opts.mcpServers).length ? { mcp_servers: opts.mcpServers } : {},
|
|
24861
|
+
// Per run, not ~/.codex/config.toml: a host without that line would run
|
|
24862
|
+
// the agent with no instructions at all. AGENTS.md still wins if present.
|
|
24863
|
+
...opts.instructionsFile && opts.instructionsFile !== "AGENTS.md" ? { project_doc_fallback_filenames: [opts.instructionsFile] } : {},
|
|
24864
|
+
project_doc_max_bytes: CODEX_DOC_MAX_BYTES,
|
|
24865
|
+
...provider?.config ?? {},
|
|
24866
|
+
// Last: a deployment's own value wins.
|
|
24867
|
+
...opts.extraConfig ?? {}
|
|
24868
|
+
};
|
|
24812
24869
|
}
|
|
24813
24870
|
function createCodexSession(opts) {
|
|
24814
|
-
const
|
|
24871
|
+
const provider = opts.apiKey || opts.baseUrl ? null : codexDefaultProvider();
|
|
24872
|
+
const model = codexModelFor(opts.model ?? process.env.CODEX_AGENT_MODEL, provider);
|
|
24815
24873
|
let thread = null;
|
|
24816
24874
|
let resumeId = opts.resumeId;
|
|
24817
24875
|
let threadId = opts.resumeId;
|
|
@@ -24832,21 +24890,12 @@ function createCodexSession(opts) {
|
|
|
24832
24890
|
async function ensureThread() {
|
|
24833
24891
|
if (thread) return thread;
|
|
24834
24892
|
const { Codex } = await loadCodex();
|
|
24835
|
-
const config2 =
|
|
24836
|
-
// Tools reach codex as MCP servers; each server's name shows up on
|
|
24837
|
-
// every tool event, so the runner can tell ours from codex's own.
|
|
24838
|
-
...opts.mcpServers && Object.keys(opts.mcpServers).length ? { mcp_servers: opts.mcpServers } : {},
|
|
24839
|
-
// Per run, not ~/.codex/config.toml: a host without that line would run
|
|
24840
|
-
// the agent with no instructions at all. AGENTS.md still wins if present.
|
|
24841
|
-
...opts.instructionsFile && opts.instructionsFile !== "AGENTS.md" ? { project_doc_fallback_filenames: [opts.instructionsFile] } : {},
|
|
24842
|
-
...opts.extraConfig ?? {}
|
|
24843
|
-
};
|
|
24893
|
+
const config2 = codexRunConfig(opts, provider);
|
|
24844
24894
|
const codex = new Codex({
|
|
24845
24895
|
...opts.apiKey ? { apiKey: opts.apiKey } : {},
|
|
24846
24896
|
...opts.baseUrl ? { baseUrl: opts.baseUrl } : {},
|
|
24847
|
-
env: buildEnv(opts),
|
|
24848
|
-
|
|
24849
|
-
...Object.keys(config2).length ? { config: config2 } : {}
|
|
24897
|
+
env: buildEnv(opts, provider),
|
|
24898
|
+
config: config2
|
|
24850
24899
|
});
|
|
24851
24900
|
thread = resumeId ? codex.resumeThread(resumeId, threadOptions()) : codex.startThread(threadOptions());
|
|
24852
24901
|
return thread;
|
|
@@ -25008,8 +25057,8 @@ ${marker}
|
|
|
25008
25057
|
|
|
25009
25058
|
// src/codingAgent/drivers/pi.ts
|
|
25010
25059
|
var crypto3 = __toESM(require("crypto"));
|
|
25011
|
-
var
|
|
25012
|
-
var
|
|
25060
|
+
var fs9 = __toESM(require("fs"));
|
|
25061
|
+
var path10 = __toESM(require("path"));
|
|
25013
25062
|
var dynamicImport2 = new Function("specifier", "return import(specifier)");
|
|
25014
25063
|
var piModulePromise = null;
|
|
25015
25064
|
function loadPi() {
|
|
@@ -25176,9 +25225,9 @@ function startSweeper() {
|
|
|
25176
25225
|
}
|
|
25177
25226
|
function readInstructions(opts) {
|
|
25178
25227
|
if (!opts.instructionsFile) return void 0;
|
|
25179
|
-
const file =
|
|
25228
|
+
const file = path10.resolve(opts.cwd, opts.instructionsFile);
|
|
25180
25229
|
try {
|
|
25181
|
-
return { file, content:
|
|
25230
|
+
return { file, content: fs9.readFileSync(file, "utf-8") };
|
|
25182
25231
|
} catch {
|
|
25183
25232
|
return void 0;
|
|
25184
25233
|
}
|
|
@@ -25201,7 +25250,7 @@ function createPiSession(opts) {
|
|
|
25201
25250
|
agentsFilesOverride: (base) => instructions ? { agentsFiles: [{ path: instructions.file, content: instructions.content }] } : base
|
|
25202
25251
|
});
|
|
25203
25252
|
await resourceLoader.reload();
|
|
25204
|
-
const sessionManager = resumeFile &&
|
|
25253
|
+
const sessionManager = resumeFile && fs9.existsSync(resumeFile) ? pi.SessionManager.open(resumeFile) : pi.SessionManager.create(opts.cwd);
|
|
25205
25254
|
const live = {
|
|
25206
25255
|
running: false,
|
|
25207
25256
|
transcript: [],
|
|
@@ -25420,11 +25469,11 @@ function createCodingAgentSession(harness, opts) {
|
|
|
25420
25469
|
}
|
|
25421
25470
|
|
|
25422
25471
|
// src/codingAgent/registry.ts
|
|
25423
|
-
var
|
|
25472
|
+
var path11 = __toESM(require("path"));
|
|
25424
25473
|
var agents = /* @__PURE__ */ new Map();
|
|
25425
25474
|
var config = {
|
|
25426
|
-
promptRoot:
|
|
25427
|
-
runtimeDir:
|
|
25475
|
+
promptRoot: path11.join(process.cwd(), ".prompts", "coding-agents"),
|
|
25476
|
+
runtimeDir: path11.join(process.cwd(), ".coding-agent-runtime"),
|
|
25428
25477
|
harness: "codex",
|
|
25429
25478
|
keepRuns: 20,
|
|
25430
25479
|
keepThreads: 200
|
|
@@ -25463,13 +25512,13 @@ function getCodingAgentsConfig() {
|
|
|
25463
25512
|
return config;
|
|
25464
25513
|
}
|
|
25465
25514
|
function resolvePromptDir(def) {
|
|
25466
|
-
return def.promptDir ||
|
|
25515
|
+
return def.promptDir || path11.join(config.promptRoot, def.id);
|
|
25467
25516
|
}
|
|
25468
25517
|
|
|
25469
25518
|
// src/codingAgent/runner.ts
|
|
25470
|
-
var
|
|
25519
|
+
var fs10 = __toESM(require("fs"));
|
|
25471
25520
|
var fsp = __toESM(require("fs/promises"));
|
|
25472
|
-
var
|
|
25521
|
+
var path12 = __toESM(require("path"));
|
|
25473
25522
|
var DEFAULT_TIMEOUT_MS = 15 * 60 * 1e3;
|
|
25474
25523
|
var inFlight = /* @__PURE__ */ new Set();
|
|
25475
25524
|
function slug(v) {
|
|
@@ -25479,11 +25528,11 @@ function resolveScope(def, opts) {
|
|
|
25479
25528
|
const scope = def.scope ?? (def.mode === "chat" ? "thread" : "project");
|
|
25480
25529
|
if (scope === "thread") {
|
|
25481
25530
|
const id = slug(opts.threadId || "default");
|
|
25482
|
-
return { key: `thread:${id}`, dirName:
|
|
25531
|
+
return { key: `thread:${id}`, dirName: path12.join("threads", id) };
|
|
25483
25532
|
}
|
|
25484
25533
|
if (scope === "user") {
|
|
25485
25534
|
const id = slug(opts.userId || "anonymous");
|
|
25486
|
-
return { key: `user:${id}`, dirName:
|
|
25535
|
+
return { key: `user:${id}`, dirName: path12.join("users", id) };
|
|
25487
25536
|
}
|
|
25488
25537
|
return { key: "project", dirName: "_project" };
|
|
25489
25538
|
}
|
|
@@ -25492,30 +25541,30 @@ function makeRunId() {
|
|
|
25492
25541
|
return `${t}-${Math.random().toString(36).slice(2, 8)}`;
|
|
25493
25542
|
}
|
|
25494
25543
|
function statePath(scopeDir) {
|
|
25495
|
-
return
|
|
25544
|
+
return path12.join(scopeDir, "_state.json");
|
|
25496
25545
|
}
|
|
25497
25546
|
function loadState(scopeDir) {
|
|
25498
25547
|
try {
|
|
25499
|
-
return JSON.parse(
|
|
25548
|
+
return JSON.parse(fs10.readFileSync(statePath(scopeDir), "utf-8"));
|
|
25500
25549
|
} catch {
|
|
25501
25550
|
return { turns: 0, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
|
|
25502
25551
|
}
|
|
25503
25552
|
}
|
|
25504
25553
|
function saveState(scopeDir, state) {
|
|
25505
25554
|
try {
|
|
25506
|
-
|
|
25507
|
-
|
|
25555
|
+
fs10.mkdirSync(scopeDir, { recursive: true });
|
|
25556
|
+
fs10.writeFileSync(statePath(scopeDir), JSON.stringify({ ...state, updatedAt: (/* @__PURE__ */ new Date()).toISOString() }, null, 2));
|
|
25508
25557
|
} catch (err) {
|
|
25509
25558
|
logger.warn(`[CodingAgent] failed to persist session state: ${err?.message ?? err}`);
|
|
25510
25559
|
}
|
|
25511
25560
|
}
|
|
25512
25561
|
async function clearTransient(dir) {
|
|
25513
|
-
await fsp.rm(
|
|
25562
|
+
await fsp.rm(path12.join(dir, "input"), { recursive: true, force: true });
|
|
25514
25563
|
}
|
|
25515
25564
|
function createWorkspace(dir, runId) {
|
|
25516
|
-
const abs = (rel) =>
|
|
25565
|
+
const abs = (rel) => path12.join(dir, rel);
|
|
25517
25566
|
const ensureDir = async (rel) => {
|
|
25518
|
-
await fsp.mkdir(
|
|
25567
|
+
await fsp.mkdir(path12.dirname(abs(rel)), { recursive: true });
|
|
25519
25568
|
};
|
|
25520
25569
|
return {
|
|
25521
25570
|
dir,
|
|
@@ -25544,7 +25593,7 @@ function createWorkspace(dir, runId) {
|
|
|
25544
25593
|
}
|
|
25545
25594
|
var INSTRUCTIONS_FILE = "system.md";
|
|
25546
25595
|
async function installInstructions(def, ws) {
|
|
25547
|
-
const src =
|
|
25596
|
+
const src = path12.join(resolvePromptDir(def), "system.md");
|
|
25548
25597
|
try {
|
|
25549
25598
|
await ws.write(INSTRUCTIONS_FILE, await fsp.readFile(src, "utf-8"));
|
|
25550
25599
|
} catch {
|
|
@@ -25558,7 +25607,7 @@ async function pruneThreads(agentId, threadsDir, keep) {
|
|
|
25558
25607
|
const dirs = (await fsp.readdir(threadsDir, { withFileTypes: true })).filter((e) => e.isDirectory());
|
|
25559
25608
|
if (dirs.length <= keep) return;
|
|
25560
25609
|
const aged = await Promise.all(dirs.map(async (e) => {
|
|
25561
|
-
const dir =
|
|
25610
|
+
const dir = path12.join(threadsDir, e.name);
|
|
25562
25611
|
const stat2 = await fsp.stat(statePath(dir)).catch(() => fsp.stat(dir));
|
|
25563
25612
|
return { name: e.name, dir, used: stat2.mtimeMs };
|
|
25564
25613
|
}));
|
|
@@ -25578,7 +25627,7 @@ async function pruneRuns(agentDir, keep) {
|
|
|
25578
25627
|
try {
|
|
25579
25628
|
const entries = (await fsp.readdir(agentDir, { withFileTypes: true })).filter((e) => e.isDirectory()).map((e) => e.name).sort();
|
|
25580
25629
|
for (const name of entries.slice(0, Math.max(0, entries.length - keep))) {
|
|
25581
|
-
await fsp.rm(
|
|
25630
|
+
await fsp.rm(path12.join(agentDir, name), { recursive: true, force: true });
|
|
25582
25631
|
}
|
|
25583
25632
|
} catch {
|
|
25584
25633
|
}
|
|
@@ -25596,17 +25645,17 @@ async function runCodingAgent(agentId, options = {}) {
|
|
|
25596
25645
|
}
|
|
25597
25646
|
const cfg = getCodingAgentsConfig();
|
|
25598
25647
|
const runId = makeRunId();
|
|
25599
|
-
const agentDir =
|
|
25648
|
+
const agentDir = path12.join(cfg.runtimeDir, def.id);
|
|
25600
25649
|
const policy = def.session ?? {};
|
|
25601
25650
|
const persistentWorkspace = policy.workspace === "persistent";
|
|
25602
25651
|
const persistentSession = policy.scope === "persistent";
|
|
25603
25652
|
const runAsJob = !(options.chat === true && def.mode === "task");
|
|
25604
25653
|
const { key: scopeKey, dirName } = resolveScope(def, { userId: options.userId, threadId: options.threadId });
|
|
25605
|
-
const scopeDir =
|
|
25606
|
-
const dir = options.workspaceDir || (persistentWorkspace ? scopeDir :
|
|
25607
|
-
|
|
25654
|
+
const scopeDir = path12.join(agentDir, dirName);
|
|
25655
|
+
const dir = options.workspaceDir || (persistentWorkspace ? scopeDir : path12.join(scopeDir, "runs", runId));
|
|
25656
|
+
fs10.mkdirSync(dir, { recursive: true });
|
|
25608
25657
|
if (persistentWorkspace && !options.workspaceDir) {
|
|
25609
|
-
|
|
25658
|
+
fs10.mkdirSync(path12.join(dir, "memory"), { recursive: true });
|
|
25610
25659
|
if (runAsJob) await clearTransient(dir);
|
|
25611
25660
|
}
|
|
25612
25661
|
const lockKey = persistentWorkspace || persistentSession ? `${def.id}:${scopeKey}` : `dir:${dir}`;
|
|
@@ -25715,7 +25764,7 @@ async function runCodingAgent(agentId, options = {}) {
|
|
|
25715
25764
|
onUsage: ctx.onUsage,
|
|
25716
25765
|
// Opt-in only: see stopOnDeliverable. Letting the turn end naturally
|
|
25717
25766
|
// is what makes usage reporting work at all.
|
|
25718
|
-
...outputPath && def.stopOnDeliverable ? { doneWhen: () =>
|
|
25767
|
+
...outputPath && def.stopOnDeliverable ? { doneWhen: () => fs10.existsSync(outputPath) } : {}
|
|
25719
25768
|
},
|
|
25720
25769
|
timeout.signal
|
|
25721
25770
|
);
|
|
@@ -25820,9 +25869,9 @@ Fix ONLY that, and rewrite the same file at the same path. Do not re-run any que
|
|
|
25820
25869
|
logger.info(
|
|
25821
25870
|
`[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}"` : "")
|
|
25822
25871
|
);
|
|
25823
|
-
if (!options.workspaceDir && !persistentWorkspace) await pruneRuns(
|
|
25824
|
-
if (!options.workspaceDir && dirName.startsWith(`threads${
|
|
25825
|
-
await pruneThreads(def.id,
|
|
25872
|
+
if (!options.workspaceDir && !persistentWorkspace) await pruneRuns(path12.join(scopeDir, "runs"), cfg.keepRuns);
|
|
25873
|
+
if (!options.workspaceDir && dirName.startsWith(`threads${path12.sep}`)) {
|
|
25874
|
+
await pruneThreads(def.id, path12.join(agentDir, "threads"), cfg.keepThreads);
|
|
25826
25875
|
}
|
|
25827
25876
|
}
|
|
25828
25877
|
}
|
|
@@ -25882,14 +25931,14 @@ ${assertReadOnlySql.toString().replace("export function", "function")}
|
|
|
25882
25931
|
`;
|
|
25883
25932
|
|
|
25884
25933
|
// src/codingAgent/tools/shims.ts
|
|
25885
|
-
var
|
|
25886
|
-
var
|
|
25887
|
-
var resolve3 = (target, name) => typeof target === "string" ?
|
|
25934
|
+
var fs11 = __toESM(require("fs"));
|
|
25935
|
+
var path13 = __toESM(require("path"));
|
|
25936
|
+
var resolve3 = (target, name) => typeof target === "string" ? path13.join(target, name) : target.pathTo(name);
|
|
25888
25937
|
function writeShims(defs, target) {
|
|
25889
25938
|
for (const def of defs) {
|
|
25890
25939
|
const file = resolve3(target, def.name);
|
|
25891
|
-
|
|
25892
|
-
|
|
25940
|
+
fs11.writeFileSync(file, def.body, "utf-8");
|
|
25941
|
+
fs11.chmodSync(file, 493);
|
|
25893
25942
|
}
|
|
25894
25943
|
return defs.map((def) => ({ name: `./${def.name}`, summary: def.summary }));
|
|
25895
25944
|
}
|
|
@@ -26156,17 +26205,17 @@ console.log(${JSON.stringify(
|
|
|
26156
26205
|
}
|
|
26157
26206
|
|
|
26158
26207
|
// src/codingAgent/triggers.ts
|
|
26159
|
-
var
|
|
26160
|
-
var
|
|
26208
|
+
var fs12 = __toESM(require("fs"));
|
|
26209
|
+
var path14 = __toESM(require("path"));
|
|
26161
26210
|
var EVENT_BURST_CAP = 200;
|
|
26162
26211
|
var capEvents = (events) => events.length > EVENT_BURST_CAP ? events.slice(-EVENT_BURST_CAP) : events;
|
|
26163
26212
|
function statePath2(agentId) {
|
|
26164
|
-
return
|
|
26213
|
+
return path14.join(getCodingAgentsConfig().runtimeDir, agentId, "_triggers.json");
|
|
26165
26214
|
}
|
|
26166
26215
|
function loadTriggerState(agentId) {
|
|
26167
26216
|
let raw;
|
|
26168
26217
|
try {
|
|
26169
|
-
raw = JSON.parse(
|
|
26218
|
+
raw = JSON.parse(fs12.readFileSync(statePath2(agentId), "utf-8"));
|
|
26170
26219
|
} catch {
|
|
26171
26220
|
return { counts: {}, pending: {} };
|
|
26172
26221
|
}
|
|
@@ -26186,8 +26235,8 @@ function loadTriggerState(agentId) {
|
|
|
26186
26235
|
function saveTriggerState(agentId, state) {
|
|
26187
26236
|
try {
|
|
26188
26237
|
const p = statePath2(agentId);
|
|
26189
|
-
|
|
26190
|
-
|
|
26238
|
+
fs12.mkdirSync(path14.dirname(p), { recursive: true });
|
|
26239
|
+
fs12.writeFileSync(p, JSON.stringify(state, null, 2));
|
|
26191
26240
|
} catch (err) {
|
|
26192
26241
|
logger.warn(`[CodingAgent:${agentId}] failed to persist trigger state: ${err?.message ?? err}`);
|
|
26193
26242
|
}
|
|
@@ -26323,13 +26372,13 @@ function describeTriggers() {
|
|
|
26323
26372
|
}
|
|
26324
26373
|
|
|
26325
26374
|
// src/codingAgent/collection.ts
|
|
26326
|
-
var
|
|
26327
|
-
var
|
|
26375
|
+
var fs13 = __toESM(require("fs"));
|
|
26376
|
+
var path15 = __toESM(require("path"));
|
|
26328
26377
|
function isChattable(agent) {
|
|
26329
26378
|
return agent.mode !== "task";
|
|
26330
26379
|
}
|
|
26331
26380
|
function registerCodingAgentCollection(sdk, config2 = {}) {
|
|
26332
|
-
const runtimeDir = config2.runtimeDir || process.env.CODING_AGENT_RUNTIME_DIR ||
|
|
26381
|
+
const runtimeDir = config2.runtimeDir || process.env.CODING_AGENT_RUNTIME_DIR || path15.join(process.cwd(), ".coding-agent-runtime");
|
|
26333
26382
|
const defaultHarness = config2.harness || process.env.CODING_AGENT_HARNESS || "codex";
|
|
26334
26383
|
const sessions = /* @__PURE__ */ new Map();
|
|
26335
26384
|
const running = /* @__PURE__ */ new Set();
|
|
@@ -26389,8 +26438,8 @@ function registerCodingAgentCollection(sdk, config2 = {}) {
|
|
|
26389
26438
|
...record.status === "skipped" ? { error: `${def.title} is in the middle of a run \u2014 try again in a moment.` } : record.error ? { error: record.error } : {}
|
|
26390
26439
|
};
|
|
26391
26440
|
}
|
|
26392
|
-
const cwd =
|
|
26393
|
-
|
|
26441
|
+
const cwd = path15.join(runtimeDir, "threads", threadId);
|
|
26442
|
+
fs13.mkdirSync(cwd, { recursive: true });
|
|
26394
26443
|
let session = sessions.get(threadId);
|
|
26395
26444
|
if (!session) {
|
|
26396
26445
|
session = createCodingAgentSession(harness || defaultHarness, {
|
|
@@ -30342,6 +30391,8 @@ var SuperatomSDK = class {
|
|
|
30342
30391
|
ANSWER_COMPONENT_NAMES,
|
|
30343
30392
|
BM25L,
|
|
30344
30393
|
CATEGORY_KEYS,
|
|
30394
|
+
CODEX_DOC_MAX_BYTES,
|
|
30395
|
+
CODEX_OPENROUTER_KEY_ENV,
|
|
30345
30396
|
CONTEXT_CONFIG,
|
|
30346
30397
|
CleanupService,
|
|
30347
30398
|
DEFAULT_AGENT_CONFIG,
|
|
@@ -30370,6 +30421,9 @@ var SuperatomSDK = class {
|
|
|
30370
30421
|
bridgePreamble,
|
|
30371
30422
|
captureContext,
|
|
30372
30423
|
clearContextTokens,
|
|
30424
|
+
codexDefaultProvider,
|
|
30425
|
+
codexModelFor,
|
|
30426
|
+
codexRunConfig,
|
|
30373
30427
|
constraintPoliciesFromConfig,
|
|
30374
30428
|
contextTokenCount,
|
|
30375
30429
|
createCodexSession,
|