@wrongstack/core 0.73.1 → 0.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{agent-bridge-C0Ze7Ldm.d.ts → agent-bridge-EWdqs8v6.d.ts} +1 -1
- package/dist/{agent-subagent-runner-BmITbs1Q.d.ts → agent-subagent-runner-D8qW8OSC.d.ts} +2 -2
- package/dist/coordination/index.d.ts +7 -7
- package/dist/coordination/index.js +64 -6
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +11 -11
- package/dist/defaults/index.js +107 -45
- package/dist/defaults/index.js.map +1 -1
- package/dist/{events-BBAlxBuw.d.ts → events-CYaoLN5_.d.ts} +37 -0
- package/dist/execution/index.d.ts +6 -6
- package/dist/extension/index.d.ts +2 -2
- package/dist/{index-yQbZ2NQx.d.ts → index-DIxjTOga.d.ts} +2 -2
- package/dist/{index-BN6i2Nfg.d.ts → index-Dsda0uCn.d.ts} +1 -1
- package/dist/index.d.ts +96 -23
- package/dist/index.js +234 -25
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +3 -3
- package/dist/infrastructure/index.js +16 -2
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/kernel/index.d.ts +3 -3
- package/dist/kernel/index.js.map +1 -1
- package/dist/{logger-bOzkF5LL.d.ts → logger-BppKxDqZ.d.ts} +9 -0
- package/dist/{multi-agent-coordinator-BSBbZt0e.d.ts → multi-agent-coordinator-DpbG3wiy.d.ts} +1 -1
- package/dist/{null-fleet-bus-BCIRT_nV.d.ts → null-fleet-bus-u5ys3lW_.d.ts} +13 -4
- package/dist/observability/index.d.ts +1 -1
- package/dist/{parallel-eternal-engine-CjAYGaCw.d.ts → parallel-eternal-engine-Dn0P8Pbj.d.ts} +3 -3
- package/dist/{path-resolver-BnqXa9Ze.d.ts → path-resolver-B32v2JIq.d.ts} +1 -1
- package/dist/{plan-templates-DBgrTGPu.d.ts → plan-templates-BcUwLlMQ.d.ts} +7 -2
- package/dist/{provider-runner-n3KkHT_w.d.ts → provider-runner-CSi_7l0h.d.ts} +1 -1
- package/dist/sdd/index.d.ts +3 -3
- package/dist/storage/index.d.ts +3 -3
- package/dist/storage/index.js +22 -6
- package/dist/storage/index.js.map +1 -1
- package/dist/types/index.d.ts +10 -10
- package/dist/types/index.js +16 -2
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +12 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/{wstack-paths-eMXnY1_X.d.ts → wstack-paths-D7evAFWM.d.ts} +8 -1
- package/package.json +1 -1
package/dist/defaults/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export { D as DefaultLogger, a as DefaultLoggerOptions } from '../logger-
|
|
2
|
-
export { A as AbandonedSession, a as AttachmentStoreOptions, C as ConfigLoaderOptions, b as ConfigMigration, c as ConfigMigrationError, d as ConfigSource, D as DEFAULT_CONFIG_MIGRATIONS, e as DefaultAttachmentStore, f as DefaultConfigLoader, g as DefaultConfigStore, h as DefaultMemoryStore, i as DefaultSessionStore, M as MemoryStoreOptions, j as MigrationContext, k as MigrationResult, P as PersistedQueueItem, l as PlanFile, m as PlanItem, n as PlanTemplate, Q as QueueStore, R as RecoveryLock, o as RecoveryLockOptions, S as SessionAnalyzer, p as SessionStoreOptions, T as TodosCheckpointFile, q as addPlanItem, r as attachPlanCheckpoint, s as attachTodosCheckpoint, t as clearPlan, u as deriveTodosFromPlanItem, v as emptyPlan, w as formatPlan, x as formatPlanTemplates, y as getPlanTemplate, z as listPlanTemplates, B as loadPlan, E as loadTodosCheckpoint, F as removePlanItem, G as runConfigMigrations, H as savePlan, I as saveTodosCheckpoint, J as setPlanItemStatus } from '../plan-templates-
|
|
1
|
+
export { D as DefaultLogger, a as DefaultLoggerOptions } from '../logger-BppKxDqZ.js';
|
|
2
|
+
export { A as AbandonedSession, a as AttachmentStoreOptions, C as ConfigLoaderOptions, b as ConfigMigration, c as ConfigMigrationError, d as ConfigSource, D as DEFAULT_CONFIG_MIGRATIONS, e as DefaultAttachmentStore, f as DefaultConfigLoader, g as DefaultConfigStore, h as DefaultMemoryStore, i as DefaultSessionStore, M as MemoryStoreOptions, j as MigrationContext, k as MigrationResult, P as PersistedQueueItem, l as PlanFile, m as PlanItem, n as PlanTemplate, Q as QueueStore, R as RecoveryLock, o as RecoveryLockOptions, S as SessionAnalyzer, p as SessionStoreOptions, T as TodosCheckpointFile, q as addPlanItem, r as attachPlanCheckpoint, s as attachTodosCheckpoint, t as clearPlan, u as deriveTodosFromPlanItem, v as emptyPlan, w as formatPlan, x as formatPlanTemplates, y as getPlanTemplate, z as listPlanTemplates, B as loadPlan, E as loadTodosCheckpoint, F as removePlanItem, G as runConfigMigrations, H as savePlan, I as saveTodosCheckpoint, J as setPlanItemStatus } from '../plan-templates-BcUwLlMQ.js';
|
|
3
3
|
export { D as DefaultSessionReader } from '../session-reader-BIpwM60D.js';
|
|
4
4
|
export { A as AuditLevel, a as SessionEventBridge, b as SessionEventBridgeOptions, c as SessionSamplingOptions, T as ToolProgressSamplingOptions, d as createSessionEventBridge, r as resolveAuditLevel, e as resolveSessionLoggingConfig } from '../session-event-bridge-CDHxcmQU.js';
|
|
5
5
|
export { D as DirectorStateCheckpoint, a as DirectorStateSnapshot, b as DirectorSubagentState, c as DirectorTaskState, l as loadDirectorState } from '../director-state-BmYi3DGA.js';
|
|
6
6
|
export { D as DefaultSecretScrubber, a as DefaultSecretVault, S as SecretVaultOptions, d as decryptConfigSecrets, e as encryptConfigSecrets, m as migratePlaintextSecrets, r as rewriteConfigEncrypted } from '../secret-scrubber-7rSC_emZ.js';
|
|
7
7
|
export { A as AutoApprovePermissionPolicy, D as DefaultPermissionPolicy, P as PermissionPolicyOptions } from '../permission-policy-CBVx-d-8.js';
|
|
8
|
-
export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, E as EternalAutonomyEngine, c as EternalAutonomyOptions, d as EternalEngineState, H as HybridCompactor, I as IterationStage, P as ParallelEngineState, e as ParallelEternalEngine, f as ParallelEternalOptions, g as ParallelIterationStage, T as ToolExecutor } from '../parallel-eternal-engine-
|
|
8
|
+
export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolicy, E as EternalAutonomyEngine, c as EternalAutonomyOptions, d as EternalEngineState, H as HybridCompactor, I as IterationStage, P as ParallelEngineState, e as ParallelEternalEngine, f as ParallelEternalOptions, g as ParallelIterationStage, T as ToolExecutor } from '../parallel-eternal-engine-Dn0P8Pbj.js';
|
|
9
9
|
export { AutoCompactionMiddleware, AutonomousRunner, AutonomousRunnerOptions, AutonomyPromptContributorOptions, DefaultSkillLoader, DoneCheckResult, DoneConditionChecker, IntelligentCompactor, IntelligentCompactorOptions, SelectiveCompactor, SelectiveCompactorOptions, SkillLoaderOptions, buildGoalPreamble, makeAutonomyPromptContributor } from '../execution/index.js';
|
|
10
|
-
import { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-
|
|
10
|
+
import { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-CSi_7l0h.js';
|
|
11
11
|
import { q as Response } from '../context-y87Jc5ei.js';
|
|
12
|
-
export { a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, n as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a1 as makeAskTool, a2 as makeAssignTool, a3 as makeAwaitTasksTool, a4 as makeCollabDebugTool, a5 as makeDirectorSessionFactory, a6 as makeFleetEmitTool, a7 as makeFleetHealthTool, a8 as makeFleetSessionTool, a9 as makeFleetStatusTool, aa as makeFleetUsageTool, ab as makeRollUpTool, ac as makeSpawnTool, ad as makeTerminateTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-
|
|
13
|
-
export { A as AgentBudgetTier, a as AgentCapability, b as AgentDefinition, c as AgentPhase, D as DEFAULT_DISPATCH_ROLE, d as DefaultMultiAgentCoordinator, e as DispatchCandidate, f as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-
|
|
14
|
-
export { c as AgentFactory, d as AgentFactoryResult, e as AgentRunnerOptions, g as BudgetExceededError, h as BudgetKind, i as BudgetLimits, n as BudgetUsage, F as FleetBus, p as FleetEvent, q as FleetHandler, r as FleetUsage, s as FleetUsageAggregator, K as SubagentBudget, V as SubagentUsageSnapshot, _ as makeAgentSubagentRunner } from '../agent-subagent-runner-
|
|
15
|
-
export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-
|
|
12
|
+
export { a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, n as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a1 as makeAskTool, a2 as makeAssignTool, a3 as makeAwaitTasksTool, a4 as makeCollabDebugTool, a5 as makeDirectorSessionFactory, a6 as makeFleetEmitTool, a7 as makeFleetHealthTool, a8 as makeFleetSessionTool, a9 as makeFleetStatusTool, aa as makeFleetUsageTool, ab as makeRollUpTool, ac as makeSpawnTool, ad as makeTerminateTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-u5ys3lW_.js';
|
|
13
|
+
export { A as AgentBudgetTier, a as AgentCapability, b as AgentDefinition, c as AgentPhase, D as DEFAULT_DISPATCH_ROLE, d as DefaultMultiAgentCoordinator, e as DispatchCandidate, f as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-DpbG3wiy.js';
|
|
14
|
+
export { c as AgentFactory, d as AgentFactoryResult, e as AgentRunnerOptions, g as BudgetExceededError, h as BudgetKind, i as BudgetLimits, n as BudgetUsage, F as FleetBus, p as FleetEvent, q as FleetHandler, r as FleetUsage, s as FleetUsageAggregator, K as SubagentBudget, V as SubagentUsageSnapshot, _ as makeAgentSubagentRunner } from '../agent-subagent-runner-D8qW8OSC.js';
|
|
15
|
+
export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-EWdqs8v6.js';
|
|
16
16
|
export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-Cuq1C8V9.js';
|
|
17
17
|
export { DefaultModeStore, LLMSelector, LLMSelectorOptions, ModeLoaderOptions, loadProjectModes, loadUserModes } from '../models/index.js';
|
|
18
18
|
export { AISpecBuilder, AISpecBuilderOptions, AISpecPhase, AISpecSession, AutoExecutor, AutoExecutorOptions, BottleneckTask, CollectedAnswer, CriticalPathAnalysis, DefaultTaskStore, ExecutionSummary, GeneratedTask, RunResult, SPEC_TEMPLATES, SddParallelRun, SddParallelRunOptions, SddProgress, SddTaskDecomposer, SddTaskDecomposerOptions, SpecDiff, SpecDrivenDev, SpecDrivenDevOptions, SpecIndexEntry, SpecParser, SpecStore, SpecStoreOptions, SpecVersion, SpecVersioning, TaskBatch, TaskExecutionContext, TaskExecutionResult, TaskFlow, TaskFlowEventMap, TaskFlowEventName, TaskFlowExecutionContext, TaskFlowOptions, TaskFlowPhase, TaskGenerator, TaskGeneratorOptions, TaskGraphIndexEntry, TaskGraphStore, TaskGraphStoreOptions, TaskStore, TaskTracker, TaskTrackerOptions, TaskTransition, WaveResult, analyzeCriticalPath, createAutoExecutor, getTemplate, listTemplates, renderProgress, renderSpecAnalysis, renderTaskGraph, renderTaskList, templateToMarkdown } from '../sdd/index.js';
|
|
@@ -20,10 +20,10 @@ export { DefaultHealthRegistry, InMemoryMetricsSink, MetricsServerHandle, Metric
|
|
|
20
20
|
export { C as ContextManagerAction, a as ContextManagerInput, b as ContextManagerResult, c as ContextManagerToolOptions, d as allServers, e as awsServer, f as blockServer, g as braveSearchServer, h as context7Server, i as contextManagerTool, j as createContextManagerTool, k as everArtServer, l as filesystemServer, m as githubServer, n as googleMapsServer, o as miniMaxVisionServer, s as sentinelServer, p as slackServer, z as zaiVisionServer } from '../mcp-servers-T0O6UN_w.js';
|
|
21
21
|
export { D as DEFAULT_AUTONOMY_CONFIG, a as DEFAULT_CONTEXT_CONFIG, c as DEFAULT_TOOLS_CONFIG } from '../default-config-DEXI4jsl.js';
|
|
22
22
|
import '../logger-DDd5C--Z.js';
|
|
23
|
-
import '../events-
|
|
23
|
+
import '../events-CYaoLN5_.js';
|
|
24
24
|
import '../secret-scrubber-3MHDDAtm.js';
|
|
25
25
|
import '../memory-CEXuo7sz.js';
|
|
26
|
-
import '../wstack-paths-
|
|
26
|
+
import '../wstack-paths-D7evAFWM.js';
|
|
27
27
|
import '../config-Dy0CK_o6.js';
|
|
28
28
|
import '../models-registry-BcYJDKLm.js';
|
|
29
29
|
import '../secret-vault-DoISxaKO.js';
|
|
@@ -31,7 +31,7 @@ import '../input-reader-E-ffP2ee.js';
|
|
|
31
31
|
import '../permission-V5BLOrY6.js';
|
|
32
32
|
import '../compactor-D_ExJajC.js';
|
|
33
33
|
import '../retry-policy-CG3qvH_e.js';
|
|
34
|
-
import '../index-
|
|
34
|
+
import '../index-Dsda0uCn.js';
|
|
35
35
|
import '../system-prompt-CA11g6Jo.js';
|
|
36
36
|
import '../observability-BhnVLBLS.js';
|
|
37
37
|
import '../goal-store-C7jcumEh.js';
|
package/dist/defaults/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as crypto2 from 'crypto';
|
|
2
2
|
import { randomBytes, randomUUID, createCipheriv, createDecipheriv, createHash } from 'crypto';
|
|
3
3
|
import * as fsp from 'fs/promises';
|
|
4
|
-
import * as
|
|
4
|
+
import * as path3 from 'path';
|
|
5
5
|
import { isAbsolute, resolve } from 'path';
|
|
6
6
|
import * as fs5 from 'fs';
|
|
7
7
|
import * as os from 'os';
|
|
@@ -32,9 +32,9 @@ __export(atomic_write_exports, {
|
|
|
32
32
|
ensureDir: () => ensureDir
|
|
33
33
|
});
|
|
34
34
|
async function atomicWrite(targetPath, content, opts = {}) {
|
|
35
|
-
const dir =
|
|
35
|
+
const dir = path3.dirname(targetPath);
|
|
36
36
|
await fsp.mkdir(dir, { recursive: true });
|
|
37
|
-
const tmp =
|
|
37
|
+
const tmp = path3.join(dir, `.${path3.basename(targetPath)}.${randomBytes(6).toString("hex")}.tmp`);
|
|
38
38
|
try {
|
|
39
39
|
if (typeof content === "string") {
|
|
40
40
|
await fsp.writeFile(tmp, content, { flag: "wx", encoding: opts.encoding ?? "utf8" });
|
|
@@ -162,14 +162,16 @@ var DefaultLogger = class _DefaultLogger {
|
|
|
162
162
|
file;
|
|
163
163
|
bindings;
|
|
164
164
|
pretty;
|
|
165
|
+
stderr;
|
|
165
166
|
constructor(opts = {}) {
|
|
166
167
|
this.level = opts.level ?? process.env.WRONGSTACK_LOG_LEVEL ?? "info";
|
|
167
168
|
this.file = opts.file;
|
|
168
169
|
this.bindings = opts.bindings ?? {};
|
|
169
170
|
this.pretty = opts.pretty ?? true;
|
|
171
|
+
this.stderr = opts.stderr !== false;
|
|
170
172
|
if (this.file) {
|
|
171
173
|
try {
|
|
172
|
-
fs5.mkdirSync(
|
|
174
|
+
fs5.mkdirSync(path3.dirname(this.file), { recursive: true });
|
|
173
175
|
} catch {
|
|
174
176
|
}
|
|
175
177
|
}
|
|
@@ -194,6 +196,7 @@ var DefaultLogger = class _DefaultLogger {
|
|
|
194
196
|
level: this.level,
|
|
195
197
|
file: this.file,
|
|
196
198
|
pretty: this.pretty,
|
|
199
|
+
stderr: this.stderr,
|
|
197
200
|
bindings: { ...this.bindings, ...bindings }
|
|
198
201
|
});
|
|
199
202
|
}
|
|
@@ -213,6 +216,7 @@ var DefaultLogger = class _DefaultLogger {
|
|
|
213
216
|
} catch {
|
|
214
217
|
}
|
|
215
218
|
}
|
|
219
|
+
if (!this.stderr) return;
|
|
216
220
|
if (r <= LEVEL_RANK.warn || this.level === "debug" || this.level === "trace") {
|
|
217
221
|
const head = `${color.dim(ts)} ${COLORS[level](level.toUpperCase().padEnd(5))} ${msg}`;
|
|
218
222
|
if (ctx !== void 0) {
|
|
@@ -331,6 +335,16 @@ function isEmptyMessage(msg) {
|
|
|
331
335
|
}
|
|
332
336
|
|
|
333
337
|
// src/storage/session-store.ts
|
|
338
|
+
function sanitizeModel(model) {
|
|
339
|
+
return model.replace(/[^a-zA-Z0-9_-]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 40);
|
|
340
|
+
}
|
|
341
|
+
function generateSessionId(startedAt, model) {
|
|
342
|
+
const date = startedAt.slice(0, 10);
|
|
343
|
+
const time = startedAt.slice(11, 19).replace(/:/g, "-");
|
|
344
|
+
const suffix = randomBytes(2).toString("hex");
|
|
345
|
+
const modelPart = model ? `_${sanitizeModel(model)}` : "";
|
|
346
|
+
return `${date}/${time}Z${modelPart}_${suffix}`;
|
|
347
|
+
}
|
|
334
348
|
var DefaultSessionStore = class {
|
|
335
349
|
dir;
|
|
336
350
|
events;
|
|
@@ -342,17 +356,23 @@ var DefaultSessionStore = class {
|
|
|
342
356
|
}
|
|
343
357
|
/** Join session ID to its absolute path within the store directory. */
|
|
344
358
|
sessionPath(id, ext) {
|
|
345
|
-
return
|
|
359
|
+
return path3.join(this.dir, `${id}${ext}`);
|
|
346
360
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
361
|
+
/**
|
|
362
|
+
* Ensure the directory implied by the session ID exists. When the ID
|
|
363
|
+
* contains a date prefix like `2026-06-06/...`, this creates the date
|
|
364
|
+
* subdirectory so sessions group naturally by day.
|
|
365
|
+
*/
|
|
366
|
+
async ensureShardDir(id) {
|
|
367
|
+
const dirPath = path3.dirname(path3.join(this.dir, id));
|
|
368
|
+
await ensureDir(dirPath);
|
|
369
|
+
return dirPath;
|
|
350
370
|
}
|
|
351
371
|
async create(meta) {
|
|
352
372
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
353
|
-
const id = meta.id
|
|
373
|
+
const id = meta.id && meta.id.length > 0 ? meta.id : generateSessionId(startedAt, meta.model ?? meta.provider);
|
|
354
374
|
const shardDir = await this.ensureShardDir(id);
|
|
355
|
-
const file =
|
|
375
|
+
const file = path3.join(shardDir, `${path3.basename(id)}.jsonl`);
|
|
356
376
|
let handle;
|
|
357
377
|
try {
|
|
358
378
|
handle = await fsp.open(file, "a", 384);
|
|
@@ -445,7 +465,7 @@ var DefaultSessionStore = class {
|
|
|
445
465
|
const ids = [];
|
|
446
466
|
const entries = await fsp.readdir(dir, { withFileTypes: true });
|
|
447
467
|
for (const entry of entries) {
|
|
448
|
-
const full =
|
|
468
|
+
const full = path3.join(dir, entry.name);
|
|
449
469
|
if (entry.isDirectory()) {
|
|
450
470
|
ids.push(...await this.collectSessionIds(full));
|
|
451
471
|
} else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
@@ -601,7 +621,7 @@ var FileSessionWriter = class {
|
|
|
601
621
|
this.meta = meta;
|
|
602
622
|
this.events = events;
|
|
603
623
|
this.resumed = opts.resumed ?? false;
|
|
604
|
-
this.manifestFile = opts.dir ?
|
|
624
|
+
this.manifestFile = opts.dir ? path3.join(opts.dir, `${id}.summary.json`) : "";
|
|
605
625
|
this.filePath = opts.filePath ?? "";
|
|
606
626
|
this.secretScrubber = opts.secretScrubber;
|
|
607
627
|
this.summary = {
|
|
@@ -883,7 +903,7 @@ init_atomic_write();
|
|
|
883
903
|
var QueueStore = class {
|
|
884
904
|
file;
|
|
885
905
|
constructor(opts) {
|
|
886
|
-
this.file =
|
|
906
|
+
this.file = path3.join(opts.dir, "queue.json");
|
|
887
907
|
}
|
|
888
908
|
async write(items) {
|
|
889
909
|
if (items.length === 0) {
|
|
@@ -953,7 +973,7 @@ var DefaultAttachmentStore = class {
|
|
|
953
973
|
let data = input.data;
|
|
954
974
|
if (this.spoolDir && bytes >= this.spoolThreshold) {
|
|
955
975
|
await fsp.mkdir(this.spoolDir, { recursive: true });
|
|
956
|
-
spooledPath =
|
|
976
|
+
spooledPath = path3.join(this.spoolDir, `${id}.bin`);
|
|
957
977
|
await atomicWrite(spooledPath, input.data, {
|
|
958
978
|
encoding: input.kind === "image" ? "base64" : "utf8"
|
|
959
979
|
});
|
|
@@ -1141,7 +1161,7 @@ ${body.trim()}`);
|
|
|
1141
1161
|
async remember(text, scope = "project-memory") {
|
|
1142
1162
|
return this.runSerialized(scope, async () => {
|
|
1143
1163
|
const file = this.files[scope];
|
|
1144
|
-
await ensureDir(
|
|
1164
|
+
await ensureDir(path3.dirname(file));
|
|
1145
1165
|
let existing = "";
|
|
1146
1166
|
try {
|
|
1147
1167
|
existing = await fsp.readFile(file, "utf8");
|
|
@@ -1789,7 +1809,7 @@ var RecoveryLock = class {
|
|
|
1789
1809
|
sessionStore;
|
|
1790
1810
|
probe;
|
|
1791
1811
|
constructor(opts) {
|
|
1792
|
-
this.file =
|
|
1812
|
+
this.file = path3.join(opts.dir, LOCK_FILE);
|
|
1793
1813
|
this.pid = opts.pid ?? process.pid;
|
|
1794
1814
|
this.hostname = opts.hostname ?? os.hostname();
|
|
1795
1815
|
this.maxAgeMs = opts.maxAgeMs ?? DEFAULT_MAX_AGE_MS;
|
|
@@ -1847,7 +1867,7 @@ var RecoveryLock = class {
|
|
|
1847
1867
|
* null return before calling this.
|
|
1848
1868
|
*/
|
|
1849
1869
|
async write(sessionId) {
|
|
1850
|
-
await ensureDir(
|
|
1870
|
+
await ensureDir(path3.dirname(this.file));
|
|
1851
1871
|
const lock = {
|
|
1852
1872
|
v: 1,
|
|
1853
1873
|
sessionId,
|
|
@@ -2431,7 +2451,7 @@ async function loadTodosCheckpoint(filePath) {
|
|
|
2431
2451
|
const parsed = JSON.parse(raw);
|
|
2432
2452
|
if (parsed?.version !== 1 || !Array.isArray(parsed.todos)) return null;
|
|
2433
2453
|
return parsed.todos.filter(
|
|
2434
|
-
(t) => !!t && typeof t.id === "string" && typeof t.content === "string" && typeof t.status === "string"
|
|
2454
|
+
(t) => !!t && typeof t.id === "string" && typeof t.content === "string" && typeof t.status === "string" && (t.activeForm === void 0 || typeof t.activeForm === "string")
|
|
2435
2455
|
);
|
|
2436
2456
|
} catch {
|
|
2437
2457
|
return null;
|
|
@@ -3074,7 +3094,7 @@ var DefaultSecretVault = class {
|
|
|
3074
3094
|
} catch (err) {
|
|
3075
3095
|
if (err.code !== "ENOENT") throw err;
|
|
3076
3096
|
}
|
|
3077
|
-
fs5.mkdirSync(
|
|
3097
|
+
fs5.mkdirSync(path3.dirname(this.keyFile), { recursive: true });
|
|
3078
3098
|
const key = randomBytes(KEY_BYTES);
|
|
3079
3099
|
try {
|
|
3080
3100
|
fs5.writeFileSync(this.keyFile, key, { mode: 384, flag: "wx" });
|
|
@@ -3143,7 +3163,7 @@ async function rewriteConfigEncrypted(configPath, vault, patch) {
|
|
|
3143
3163
|
}
|
|
3144
3164
|
const merged = deepMerge2(current, patch ?? {});
|
|
3145
3165
|
const encrypted = encryptConfigSecrets(merged, vault);
|
|
3146
|
-
await fsp.mkdir(
|
|
3166
|
+
await fsp.mkdir(path3.dirname(configPath), { recursive: true });
|
|
3147
3167
|
await atomicWrite(configPath, JSON.stringify(encrypted, null, 2), { mode: 384 });
|
|
3148
3168
|
await restrictFilePermissions(configPath);
|
|
3149
3169
|
}
|
|
@@ -3367,9 +3387,9 @@ function getInputString(input, key) {
|
|
|
3367
3387
|
function pathLooksInsideProject(rawPath, projectRoot) {
|
|
3368
3388
|
if (!projectRoot) return false;
|
|
3369
3389
|
if (rawPath === "~" || rawPath.startsWith("~/") || rawPath.startsWith("~\\")) return false;
|
|
3370
|
-
const resolved =
|
|
3371
|
-
const relative2 =
|
|
3372
|
-
return !!relative2 && !relative2.startsWith("..") && !
|
|
3390
|
+
const resolved = path3.resolve(projectRoot, rawPath);
|
|
3391
|
+
const relative2 = path3.relative(projectRoot, resolved);
|
|
3392
|
+
return !!relative2 && !relative2.startsWith("..") && !path3.isAbsolute(relative2);
|
|
3373
3393
|
}
|
|
3374
3394
|
function tokenizeShell(command) {
|
|
3375
3395
|
return command.match(/"[^"]*"|'[^']*'|\S+/g)?.map((token) => token.replace(/^['"]|['"]$/g, "")) ?? [];
|
|
@@ -3379,7 +3399,7 @@ function pathTokenIsOutsideProject(token, projectRoot) {
|
|
|
3379
3399
|
if (token === "/" || token === "~" || token === "." || token === "..") return token !== ".";
|
|
3380
3400
|
if (token.includes("*")) return true;
|
|
3381
3401
|
if (token.startsWith("..") || token.includes("../") || token.includes("..\\")) return true;
|
|
3382
|
-
if (
|
|
3402
|
+
if (path3.isAbsolute(token) || token.startsWith("~/")) return !pathLooksInsideProject(token, projectRoot);
|
|
3383
3403
|
return false;
|
|
3384
3404
|
}
|
|
3385
3405
|
function hasDangerousDeleteTarget(tokens, start, projectRoot) {
|
|
@@ -4035,7 +4055,7 @@ var DefaultSkillLoader = class {
|
|
|
4035
4055
|
const entries = await fsp.readdir(dir, { withFileTypes: true });
|
|
4036
4056
|
for (const e of entries) {
|
|
4037
4057
|
if (!e.isDirectory()) continue;
|
|
4038
|
-
const skillFile =
|
|
4058
|
+
const skillFile = path3.join(dir, e.name, "SKILL.md");
|
|
4039
4059
|
try {
|
|
4040
4060
|
const raw = await fsp.readFile(skillFile, "utf8");
|
|
4041
4061
|
const meta = parseFrontmatter(raw);
|
|
@@ -6327,8 +6347,8 @@ var AutonomousRunner = class {
|
|
|
6327
6347
|
init_atomic_write();
|
|
6328
6348
|
var MAX_JOURNAL_ENTRIES = 500;
|
|
6329
6349
|
function goalFilePath(projectRoot) {
|
|
6330
|
-
const hash = createHash("sha256").update(
|
|
6331
|
-
return
|
|
6350
|
+
const hash = createHash("sha256").update(path3.resolve(projectRoot)).digest("hex").slice(0, 12);
|
|
6351
|
+
return path3.join(os.homedir(), ".wrongstack", "projects", hash, "goal.json");
|
|
6332
6352
|
}
|
|
6333
6353
|
async function loadGoal(filePath) {
|
|
6334
6354
|
let raw;
|
|
@@ -13842,7 +13862,7 @@ var Director = class _Director {
|
|
|
13842
13862
|
})),
|
|
13843
13863
|
usage: this.usage.snapshot()
|
|
13844
13864
|
};
|
|
13845
|
-
await fsp.mkdir(
|
|
13865
|
+
await fsp.mkdir(path3.dirname(this.manifestPath), { recursive: true });
|
|
13846
13866
|
await atomicWrite(this.manifestPath, JSON.stringify(manifest, null, 2), { mode: 384 });
|
|
13847
13867
|
return this.manifestPath;
|
|
13848
13868
|
}
|
|
@@ -14048,7 +14068,7 @@ var Director = class _Director {
|
|
|
14048
14068
|
*/
|
|
14049
14069
|
async readSession(subagentId, tail) {
|
|
14050
14070
|
if (!this.sessionsRoot) return null;
|
|
14051
|
-
const filePath =
|
|
14071
|
+
const filePath = path3.join(this.sessionsRoot, this.directorRunId, `${subagentId}.jsonl`);
|
|
14052
14072
|
let raw;
|
|
14053
14073
|
try {
|
|
14054
14074
|
raw = await fsp.readFile(filePath, "utf8");
|
|
@@ -14284,6 +14304,7 @@ function createDelegateTool(opts) {
|
|
|
14284
14304
|
if (typeof i.task !== "string" || !i.task.trim()) {
|
|
14285
14305
|
return { ok: false, error: "`task` is required." };
|
|
14286
14306
|
}
|
|
14307
|
+
const target = i.role ?? i.name ?? "subagent";
|
|
14287
14308
|
try {
|
|
14288
14309
|
let director = await opts.host.ensureDirector();
|
|
14289
14310
|
if (!director) {
|
|
@@ -14344,6 +14365,7 @@ function createDelegateTool(opts) {
|
|
|
14344
14365
|
if (!cfg.timeoutMs) {
|
|
14345
14366
|
cfg.timeoutMs = Math.max(3e4, timeoutMs - SUBAGENT_TIMEOUT_BUFFER_MS);
|
|
14346
14367
|
}
|
|
14368
|
+
opts.events?.emit("delegate.started", { target, task: i.task });
|
|
14347
14369
|
const subagentId = await director.spawn(cfg);
|
|
14348
14370
|
const taskId = await director.assign({
|
|
14349
14371
|
id: `${randomUUID()}`,
|
|
@@ -14378,6 +14400,17 @@ function createDelegateTool(opts) {
|
|
|
14378
14400
|
});
|
|
14379
14401
|
if ("__timeout" in result) {
|
|
14380
14402
|
const partial2 = await readSubagentPartial(opts, subagentId);
|
|
14403
|
+
opts.events?.emit("delegate.completed", {
|
|
14404
|
+
target,
|
|
14405
|
+
task: i.task,
|
|
14406
|
+
ok: false,
|
|
14407
|
+
status: "host_timeout",
|
|
14408
|
+
summary: `[${target}] timed out \u2014 no result within ${Math.round(timeoutMs / 1e3)}s`,
|
|
14409
|
+
durationMs: timeoutMs,
|
|
14410
|
+
iterations: partial2?.events ?? 0,
|
|
14411
|
+
toolCalls: partial2?.toolUsesObserved ?? 0,
|
|
14412
|
+
subagentId
|
|
14413
|
+
});
|
|
14381
14414
|
return {
|
|
14382
14415
|
ok: false,
|
|
14383
14416
|
stopReason: "host_timeout",
|
|
@@ -14394,6 +14427,24 @@ function createDelegateTool(opts) {
|
|
|
14394
14427
|
const retryable = result.error?.retryable;
|
|
14395
14428
|
const backoffMs = result.error?.backoffMs;
|
|
14396
14429
|
const summary = buildDelegateSummary(i.role, result);
|
|
14430
|
+
let costUsd;
|
|
14431
|
+
try {
|
|
14432
|
+
costUsd = dir.snapshot().perSubagent[result.subagentId]?.cost;
|
|
14433
|
+
} catch {
|
|
14434
|
+
costUsd = void 0;
|
|
14435
|
+
}
|
|
14436
|
+
opts.events?.emit("delegate.completed", {
|
|
14437
|
+
target,
|
|
14438
|
+
task: i.task,
|
|
14439
|
+
ok: result.status === "success",
|
|
14440
|
+
status: result.status,
|
|
14441
|
+
summary,
|
|
14442
|
+
durationMs: result.durationMs,
|
|
14443
|
+
iterations: result.iterations,
|
|
14444
|
+
toolCalls: result.toolCalls,
|
|
14445
|
+
costUsd,
|
|
14446
|
+
subagentId: result.subagentId
|
|
14447
|
+
});
|
|
14397
14448
|
return {
|
|
14398
14449
|
ok: result.status === "success",
|
|
14399
14450
|
status: result.status,
|
|
@@ -14415,10 +14466,21 @@ function createDelegateTool(opts) {
|
|
|
14415
14466
|
summary
|
|
14416
14467
|
};
|
|
14417
14468
|
} catch (err) {
|
|
14469
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
14470
|
+
opts.events?.emit("delegate.completed", {
|
|
14471
|
+
target,
|
|
14472
|
+
task: i.task,
|
|
14473
|
+
ok: false,
|
|
14474
|
+
status: "error",
|
|
14475
|
+
summary: `[${target}] failed \u2014 ${message}`,
|
|
14476
|
+
durationMs: 0,
|
|
14477
|
+
iterations: 0,
|
|
14478
|
+
toolCalls: 0
|
|
14479
|
+
});
|
|
14418
14480
|
return {
|
|
14419
14481
|
ok: false,
|
|
14420
14482
|
stopReason: "error",
|
|
14421
|
-
error:
|
|
14483
|
+
error: message
|
|
14422
14484
|
};
|
|
14423
14485
|
}
|
|
14424
14486
|
}
|
|
@@ -14505,13 +14567,13 @@ async function readSubagentPartial(opts, subagentId) {
|
|
|
14505
14567
|
if (!opts.sessionsRoot) return void 0;
|
|
14506
14568
|
const candidates = [];
|
|
14507
14569
|
if (opts.directorRunId) {
|
|
14508
|
-
candidates.push(
|
|
14570
|
+
candidates.push(path3.join(opts.sessionsRoot, opts.directorRunId, `${subagentId}.jsonl`));
|
|
14509
14571
|
} else {
|
|
14510
14572
|
try {
|
|
14511
14573
|
const entries = await fsp.readdir(opts.sessionsRoot, { withFileTypes: true });
|
|
14512
14574
|
for (const entry of entries) {
|
|
14513
14575
|
if (entry.isDirectory()) {
|
|
14514
|
-
candidates.push(
|
|
14576
|
+
candidates.push(path3.join(opts.sessionsRoot, entry.name, `${subagentId}.jsonl`));
|
|
14515
14577
|
}
|
|
14516
14578
|
}
|
|
14517
14579
|
} catch {
|
|
@@ -14558,9 +14620,9 @@ function makeDirectorSessionFactory(opts) {
|
|
|
14558
14620
|
let dir;
|
|
14559
14621
|
if (opts.store) {
|
|
14560
14622
|
store = opts.store;
|
|
14561
|
-
dir = opts.sessionsRoot ?
|
|
14623
|
+
dir = opts.sessionsRoot ? path3.join(opts.sessionsRoot, runId) : "(caller-managed)";
|
|
14562
14624
|
} else if (opts.sessionsRoot) {
|
|
14563
|
-
dir =
|
|
14625
|
+
dir = path3.join(opts.sessionsRoot, runId);
|
|
14564
14626
|
store = new DefaultSessionStore({ dir });
|
|
14565
14627
|
} else {
|
|
14566
14628
|
throw new Error("makeDirectorSessionFactory requires either `store` or `sessionsRoot`");
|
|
@@ -14764,7 +14826,7 @@ var DefaultModelsRegistry = class {
|
|
|
14764
14826
|
this.overlay = opts.overlay;
|
|
14765
14827
|
this.overlayUrl = opts.overlayUrl;
|
|
14766
14828
|
this.overlayFile = opts.overlayFile;
|
|
14767
|
-
this.overlayCacheFile = opts.overlayCacheFile ?? (opts.overlayUrl ?
|
|
14829
|
+
this.overlayCacheFile = opts.overlayCacheFile ?? (opts.overlayUrl ? path3.join(path3.dirname(opts.cacheFile), "models-overlay-cache.json") : void 0);
|
|
14768
14830
|
}
|
|
14769
14831
|
async load(opts = {}) {
|
|
14770
14832
|
if (this.payload && !opts.force) return this.payload;
|
|
@@ -14977,7 +15039,7 @@ var DefaultModelsRegistry = class {
|
|
|
14977
15039
|
}
|
|
14978
15040
|
/** Used by `wstack models refresh` to expose where the cache lives. */
|
|
14979
15041
|
cacheLocation() {
|
|
14980
|
-
return
|
|
15042
|
+
return path3.resolve(this.cacheFile);
|
|
14981
15043
|
}
|
|
14982
15044
|
};
|
|
14983
15045
|
function hasEntries(payload) {
|
|
@@ -15273,7 +15335,7 @@ var DefaultModeStore = class {
|
|
|
15273
15335
|
}
|
|
15274
15336
|
async loadActiveMode() {
|
|
15275
15337
|
try {
|
|
15276
|
-
const configPath =
|
|
15338
|
+
const configPath = path3.join(this.configDir, "mode.json");
|
|
15277
15339
|
const content = await fsp.readFile(configPath, "utf8");
|
|
15278
15340
|
const data = JSON.parse(content);
|
|
15279
15341
|
this.activeModeId = data.activeMode ?? null;
|
|
@@ -15284,7 +15346,7 @@ var DefaultModeStore = class {
|
|
|
15284
15346
|
async saveActiveMode() {
|
|
15285
15347
|
try {
|
|
15286
15348
|
await fsp.mkdir(this.configDir, { recursive: true });
|
|
15287
|
-
const configPath =
|
|
15349
|
+
const configPath = path3.join(this.configDir, "mode.json");
|
|
15288
15350
|
await atomicWrite(
|
|
15289
15351
|
configPath,
|
|
15290
15352
|
JSON.stringify({ activeMode: this.activeModeId }, null, 2)
|
|
@@ -15299,11 +15361,11 @@ async function loadProjectModes(modesDir) {
|
|
|
15299
15361
|
const entries = await fsp.readdir(modesDir);
|
|
15300
15362
|
for (const entry of entries) {
|
|
15301
15363
|
if (!entry.endsWith(".md") && !entry.endsWith(".txt")) continue;
|
|
15302
|
-
const filePath =
|
|
15364
|
+
const filePath = path3.join(modesDir, entry);
|
|
15303
15365
|
const stat5 = await fsp.stat(filePath);
|
|
15304
15366
|
if (!stat5.isFile()) continue;
|
|
15305
15367
|
const content = await fsp.readFile(filePath, "utf8");
|
|
15306
|
-
const id =
|
|
15368
|
+
const id = path3.basename(entry, path3.extname(entry));
|
|
15307
15369
|
modes.push({
|
|
15308
15370
|
id,
|
|
15309
15371
|
name: id.replace(/[-_]/g, " ").replace(/\b\w/g, (c) => c.toUpperCase()),
|
|
@@ -15319,7 +15381,7 @@ async function loadProjectModes(modesDir) {
|
|
|
15319
15381
|
async function loadUserModes(modesDir) {
|
|
15320
15382
|
const modes = [];
|
|
15321
15383
|
try {
|
|
15322
|
-
const manifestPath =
|
|
15384
|
+
const manifestPath = path3.join(modesDir, "modes.json");
|
|
15323
15385
|
const content = await fsp.readFile(manifestPath, "utf8");
|
|
15324
15386
|
const manifest = JSON.parse(content);
|
|
15325
15387
|
for (const mode of manifest.modes) {
|
|
@@ -16236,7 +16298,7 @@ var SpecStore = class {
|
|
|
16236
16298
|
indexPath;
|
|
16237
16299
|
constructor(opts) {
|
|
16238
16300
|
this.baseDir = opts.baseDir;
|
|
16239
|
-
this.indexPath =
|
|
16301
|
+
this.indexPath = path3.join(this.baseDir, "_index.json");
|
|
16240
16302
|
}
|
|
16241
16303
|
async save(spec) {
|
|
16242
16304
|
await ensureDir(this.baseDir);
|
|
@@ -16305,7 +16367,7 @@ var SpecStore = class {
|
|
|
16305
16367
|
return updated;
|
|
16306
16368
|
}
|
|
16307
16369
|
filePath(id) {
|
|
16308
|
-
return
|
|
16370
|
+
return path3.join(this.baseDir, `${id}.json`);
|
|
16309
16371
|
}
|
|
16310
16372
|
async readIndex() {
|
|
16311
16373
|
try {
|
|
@@ -16362,7 +16424,7 @@ var TaskGraphStore = class {
|
|
|
16362
16424
|
indexPath;
|
|
16363
16425
|
constructor(opts) {
|
|
16364
16426
|
this.baseDir = opts.baseDir;
|
|
16365
|
-
this.indexPath =
|
|
16427
|
+
this.indexPath = path3.join(this.baseDir, "_index.json");
|
|
16366
16428
|
}
|
|
16367
16429
|
async save(graph) {
|
|
16368
16430
|
await ensureDir(this.baseDir);
|
|
@@ -16400,7 +16462,7 @@ var TaskGraphStore = class {
|
|
|
16400
16462
|
}
|
|
16401
16463
|
}
|
|
16402
16464
|
filePath(id) {
|
|
16403
|
-
return
|
|
16465
|
+
return path3.join(this.baseDir, `${id}.json`);
|
|
16404
16466
|
}
|
|
16405
16467
|
async readIndex() {
|
|
16406
16468
|
try {
|