@wrongstack/core 0.9.0 → 0.9.4
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-Bad3ZGQ7.d.ts → agent-bridge-DMVOX0cF.d.ts} +1 -1
- package/dist/{agent-subagent-runner-Cc8sRJOF.d.ts → agent-subagent-runner-DaF_EgRG.d.ts} +3 -3
- package/dist/{compactor-Mw7-rNyb.d.ts → compactor-DVTKL7XD.d.ts} +1 -1
- package/dist/{config-Bi4Q0fnz.d.ts → config-SkMIDN9L.d.ts} +22 -2
- package/dist/{context-z2x5gv_V.d.ts → context-BRNbHmRM.d.ts} +6 -0
- package/dist/coordination/index.d.ts +12 -12
- package/dist/coordination/index.js +58 -37
- package/dist/coordination/index.js.map +1 -1
- package/dist/{default-config-DvRSTELf.d.ts → default-config-Uzla85H-.d.ts} +5 -1
- package/dist/defaults/index.d.ts +23 -23
- package/dist/defaults/index.js +102 -72
- package/dist/defaults/index.js.map +1 -1
- package/dist/{events-yCpJD4wa.d.ts → events-CiG9qUM_.d.ts} +1 -1
- package/dist/execution/index.d.ts +14 -14
- package/dist/execution/index.js.map +1 -1
- package/dist/extension/index.d.ts +6 -6
- package/dist/{index-Dl3PaD7f.d.ts → index-Bsha5K4D.d.ts} +8 -8
- package/dist/{index-SxpnwRlJ.d.ts → index-CP8638Wm.d.ts} +5 -5
- package/dist/index.d.ts +148 -39
- package/dist/index.js +1545 -98
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +6 -6
- package/dist/kernel/index.d.ts +9 -9
- package/dist/{mcp-servers-n2L9ohMX.d.ts → mcp-servers-BouUWYW6.d.ts} +3 -3
- package/dist/models/index.d.ts +2 -2
- package/dist/{multi-agent-C8uY45AY.d.ts → multi-agent-3ZnTB1aT.d.ts} +2 -2
- package/dist/{multi-agent-coordinator-C7YbZUY8.d.ts → multi-agent-coordinator-DTXF2aAl.d.ts} +2 -2
- package/dist/{null-fleet-bus-Bb2jVLKr.d.ts → null-fleet-bus-Chrc_3Pp.d.ts} +6 -6
- package/dist/observability/index.d.ts +2 -2
- package/dist/{path-resolver-DnC1nOjb.d.ts → path-resolver-TcJfc29Y.d.ts} +2 -2
- package/dist/{permission-policy-BBa1M1xc.d.ts → permission-policy-BpCGYBud.d.ts} +2 -2
- package/dist/{plan-templates-Cc-04Z8o.d.ts → plan-templates-envSmNlZ.d.ts} +10 -5
- package/dist/{provider-runner-C4ouU7--.d.ts → provider-runner-BEpikbbN.d.ts} +3 -3
- package/dist/{retry-policy-OwtKNxo8.d.ts → retry-policy-BYkq0ugs.d.ts} +1 -1
- package/dist/sdd/index.d.ts +8 -8
- package/dist/{secret-scrubber-CyE1-EMG.d.ts → secret-scrubber-DttNiGYA.d.ts} +1 -1
- package/dist/{secret-scrubber-C0n1EqrC.d.ts → secret-scrubber-QSeI0ADi.d.ts} +1 -1
- package/dist/security/index.d.ts +4 -4
- package/dist/security/index.js +5 -2
- package/dist/security/index.js.map +1 -1
- package/dist/{selector-DkvgYVS4.d.ts → selector-pox8abg0.d.ts} +1 -1
- package/dist/{session-reader-DsadjyF9.d.ts → session-reader-CSWcb5Ga.d.ts} +1 -1
- package/dist/storage/index.d.ts +77 -8
- package/dist/storage/index.js +433 -62
- package/dist/storage/index.js.map +1 -1
- package/dist/{system-prompt-CWA6ml-d.d.ts → system-prompt-Bs-Wliab.d.ts} +1 -1
- package/dist/{tool-executor-Ch25BDwa.d.ts → tool-executor-CsktM3h9.d.ts} +4 -4
- package/dist/types/index.d.ts +16 -16
- package/dist/types/index.js +8 -2
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/dist/{wstack-paths-CJYrjQU8.d.ts → wstack-paths-BCgmTNlG.d.ts} +4 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { b as BridgeTransport, B as BridgeMessage, A as AgentBridge, a as AgentBridgeConfig } from './multi-agent-
|
|
1
|
+
import { b as BridgeTransport, B as BridgeMessage, A as AgentBridge, a as AgentBridgeConfig } from './multi-agent-3ZnTB1aT.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* In-memory pub/sub transport for agent-to-agent messaging.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as Agent, f as AgentInput } from './index-
|
|
2
|
-
import { E as EventBus } from './events-
|
|
3
|
-
import { n as SubagentConfig, v as TaskSpec, t as SubagentRunner } from './multi-agent-
|
|
1
|
+
import { c as Agent, f as AgentInput } from './index-CP8638Wm.js';
|
|
2
|
+
import { E as EventBus } from './events-CiG9qUM_.js';
|
|
3
|
+
import { n as SubagentConfig, v as TaskSpec, t as SubagentRunner } from './multi-agent-3ZnTB1aT.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Single fleet-wide event with subagent attribution. Whatever a child
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { W as WireFamily } from './models-registry-BcYJDKLm.js';
|
|
2
|
-
import { P as Permission } from './context-
|
|
2
|
+
import { P as Permission } from './context-BRNbHmRM.js';
|
|
3
3
|
|
|
4
4
|
type ContextWindowModeId = 'balanced' | 'frugal' | 'deep' | 'archival';
|
|
5
5
|
type ContextWindowAggressiveOn = 'hard' | 'soft' | 'warn';
|
|
@@ -161,6 +161,19 @@ interface FeaturesConfig {
|
|
|
161
161
|
/** Discover + load skills from disk. */
|
|
162
162
|
skills: boolean;
|
|
163
163
|
}
|
|
164
|
+
interface AutonomyConfig {
|
|
165
|
+
/** ms to wait before auto-proceeding in 'auto' mode. Default: 45000. */
|
|
166
|
+
autoProceedDelayMs?: number;
|
|
167
|
+
}
|
|
168
|
+
type SyncCategory = 'settings' | 'skills' | 'prompts' | 'memory' | 'history';
|
|
169
|
+
interface SyncConfig {
|
|
170
|
+
enabled: boolean;
|
|
171
|
+
repo: string;
|
|
172
|
+
/** GitHub token (fine-grained PAT). Encrypted at rest via SecretVault. */
|
|
173
|
+
githubToken: string;
|
|
174
|
+
categories: SyncCategory[];
|
|
175
|
+
lastSyncedAt?: string;
|
|
176
|
+
}
|
|
164
177
|
interface Config {
|
|
165
178
|
version: 1;
|
|
166
179
|
provider: string;
|
|
@@ -176,6 +189,13 @@ interface Config {
|
|
|
176
189
|
features: FeaturesConfig;
|
|
177
190
|
yolo?: boolean;
|
|
178
191
|
cwd?: string;
|
|
192
|
+
/** Autonomy mode configuration (auto-proceed delay, etc.). */
|
|
193
|
+
autonomy?: AutonomyConfig;
|
|
194
|
+
/**
|
|
195
|
+
* Cloud sync configuration. Stored separately in sync.json to avoid
|
|
196
|
+
* accidentally committing the GitHub token to project configs.
|
|
197
|
+
*/
|
|
198
|
+
sync?: SyncConfig;
|
|
179
199
|
/**
|
|
180
200
|
* Per-plugin namespaced config sections. Each plugin reads its own
|
|
181
201
|
* subtree via `ConfigStore.getExtension(pluginName)`. Plugins should
|
|
@@ -228,4 +248,4 @@ interface ConfigStore {
|
|
|
228
248
|
watch(cb: (next: Readonly<Config>, prev: Readonly<Config>) => void): () => void;
|
|
229
249
|
}
|
|
230
250
|
|
|
231
|
-
export { CONTEXT_WINDOW_MODES as C, DEFAULT_CONTEXT_WINDOW_MODE_ID as D, type FeaturesConfig as F, type LogConfig as L, type MCPServerConfig as M, type PluginConfig as P, type ToolsConfig as T, type Config as a, type ConfigLoader as b, type ConfigStore as c, type ContextConfig as d, type ContextWindowAggressiveOn as e, type ContextWindowConfigLike as f, type ContextWindowMode as g, type ContextWindowModeId as h, type ContextWindowPolicy as i, type ContextWindowThresholds as j, type ProviderApiKey as k, type ProviderConfig as l,
|
|
251
|
+
export { type AutonomyConfig as A, CONTEXT_WINDOW_MODES as C, DEFAULT_CONTEXT_WINDOW_MODE_ID as D, type FeaturesConfig as F, type LogConfig as L, type MCPServerConfig as M, type PluginConfig as P, type SyncCategory as S, type ToolsConfig as T, type Config as a, type ConfigLoader as b, type ConfigStore as c, type ContextConfig as d, type ContextWindowAggressiveOn as e, type ContextWindowConfigLike as f, type ContextWindowMode as g, type ContextWindowModeId as h, type ContextWindowPolicy as i, type ContextWindowThresholds as j, type ProviderApiKey as k, type ProviderConfig as l, type SyncConfig as m, formatContextWindowModeList as n, getContextWindowMode as o, isContextWindowModeId as p, listContextWindowModes as q, resolveContextWindowPolicy as r };
|
|
@@ -581,6 +581,8 @@ interface SessionMetadata {
|
|
|
581
581
|
provider?: string;
|
|
582
582
|
startedAt: string;
|
|
583
583
|
endedAt?: string;
|
|
584
|
+
/** Set when a session is closed with open tool calls — used to restore pending state on resume. */
|
|
585
|
+
pendingToolUses?: string[];
|
|
584
586
|
}
|
|
585
587
|
type SessionEvent = {
|
|
586
588
|
type: 'session_start';
|
|
@@ -635,6 +637,7 @@ type SessionEvent = {
|
|
|
635
637
|
type: 'session_end';
|
|
636
638
|
ts: string;
|
|
637
639
|
usage: Usage;
|
|
640
|
+
pendingToolUses?: string[];
|
|
638
641
|
} | {
|
|
639
642
|
type: 'mode_changed';
|
|
640
643
|
ts: string;
|
|
@@ -781,6 +784,9 @@ interface SessionWriter {
|
|
|
781
784
|
* having to recompute the path from session metadata.
|
|
782
785
|
*/
|
|
783
786
|
readonly transcriptPath?: string;
|
|
787
|
+
/** IDs of tool_use blocks that have been sent but not yet received a tool_result.
|
|
788
|
+
* Used by the REPL to serialize pending state into `session_end` for proper resume. */
|
|
789
|
+
readonly pendingToolUses: string[];
|
|
784
790
|
append(event: SessionEvent): Promise<void>;
|
|
785
791
|
close(): Promise<void>;
|
|
786
792
|
/**
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export { A as ACP_AGENTS, 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, C as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, h as DEFAULT_SUBAGENT_BASELINE, i as DelegateHost, j as Director, k as DirectorPromptParts, l as DirectorSessionFactory, m as DirectorSessionFactoryOptions, F as FLEET_ROSTER, n as FLEET_ROSTER_BUDGETS, o as FLEET_ROSTER_WITHACP, p as FleetCostCapError, q as FleetManager, r as FleetManagerOptions, s as FleetRosterBudget, t as FleetSpawnBudgetError, I as ICoordinator, u as IFleetManager, N 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, E as createDelegateTool, G as getAgentDefinition, H as makeDirectorSessionFactory, J as rosterSummaryFromConfigs } from '../null-fleet-bus-
|
|
2
|
-
import { b as AgentDefinition } from '../multi-agent-coordinator-
|
|
3
|
-
export { T as AGENT_TOOL_PRESETS, A as AgentBudgetTier, a as AgentCapability, 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, H as HEAVY_BUDGET, L as LIGHT_BUDGET, M as MEDIUM_BUDGET, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-
|
|
4
|
-
export { c as BudgetExceededError, d as BudgetKind, e as BudgetLimits, f as BudgetNegotiationMode, g as BudgetThresholdDecision, h as BudgetThresholdHandler, i as BudgetThresholdSignal, j as BudgetUsage, m as SubagentBudget } from '../multi-agent-
|
|
5
|
-
export { A as AgentFactory, a as AgentFactoryResult, b as AgentRunnerOptions, F as FleetBus, c as FleetEvent, d as FleetHandler, e as FleetUsage, f as FleetUsageAggregator, S as SubagentUsageSnapshot, m as makeAgentSubagentRunner } from '../agent-subagent-runner-
|
|
6
|
-
export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-
|
|
7
|
-
import '../context-
|
|
1
|
+
export { A as ACP_AGENTS, 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, C as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, h as DEFAULT_SUBAGENT_BASELINE, i as DelegateHost, j as Director, k as DirectorPromptParts, l as DirectorSessionFactory, m as DirectorSessionFactoryOptions, F as FLEET_ROSTER, n as FLEET_ROSTER_BUDGETS, o as FLEET_ROSTER_WITHACP, p as FleetCostCapError, q as FleetManager, r as FleetManagerOptions, s as FleetRosterBudget, t as FleetSpawnBudgetError, I as ICoordinator, u as IFleetManager, N 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, E as createDelegateTool, G as getAgentDefinition, H as makeDirectorSessionFactory, J as rosterSummaryFromConfigs } from '../null-fleet-bus-Chrc_3Pp.js';
|
|
2
|
+
import { b as AgentDefinition } from '../multi-agent-coordinator-DTXF2aAl.js';
|
|
3
|
+
export { T as AGENT_TOOL_PRESETS, A as AgentBudgetTier, a as AgentCapability, 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, H as HEAVY_BUDGET, L as LIGHT_BUDGET, M as MEDIUM_BUDGET, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-DTXF2aAl.js';
|
|
4
|
+
export { c as BudgetExceededError, d as BudgetKind, e as BudgetLimits, f as BudgetNegotiationMode, g as BudgetThresholdDecision, h as BudgetThresholdHandler, i as BudgetThresholdSignal, j as BudgetUsage, m as SubagentBudget } from '../multi-agent-3ZnTB1aT.js';
|
|
5
|
+
export { A as AgentFactory, a as AgentFactoryResult, b as AgentRunnerOptions, F as FleetBus, c as FleetEvent, d as FleetHandler, e as FleetUsage, f as FleetUsageAggregator, S as SubagentUsageSnapshot, m as makeAgentSubagentRunner } from '../agent-subagent-runner-DaF_EgRG.js';
|
|
6
|
+
export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-DMVOX0cF.js';
|
|
7
|
+
import '../context-BRNbHmRM.js';
|
|
8
8
|
import '../director-state-BmYi3DGA.js';
|
|
9
|
-
import '../events-
|
|
9
|
+
import '../events-CiG9qUM_.js';
|
|
10
10
|
import 'node:events';
|
|
11
|
-
import '../index-
|
|
11
|
+
import '../index-CP8638Wm.js';
|
|
12
12
|
import '../logger-DDd5C--Z.js';
|
|
13
|
-
import '../system-prompt-
|
|
13
|
+
import '../system-prompt-Bs-Wliab.js';
|
|
14
14
|
import '../observability-BhnVLBLS.js';
|
|
15
|
-
import '../secret-scrubber-
|
|
16
|
-
import '../config-
|
|
15
|
+
import '../secret-scrubber-DttNiGYA.js';
|
|
16
|
+
import '../config-SkMIDN9L.js';
|
|
17
17
|
import '../models-registry-BcYJDKLm.js';
|
|
18
18
|
|
|
19
19
|
/** Phase 1 · Discovery — map the territory before any work begins. */
|
|
@@ -5891,24 +5891,30 @@ var DefaultSessionStore = class {
|
|
|
5891
5891
|
this.dir = opts.dir;
|
|
5892
5892
|
this.events = opts.events;
|
|
5893
5893
|
}
|
|
5894
|
-
|
|
5894
|
+
/** Join session ID to its absolute path within the store directory. */
|
|
5895
|
+
sessionPath(id, ext) {
|
|
5896
|
+
return path4.join(this.dir, `${id}${ext}`);
|
|
5897
|
+
}
|
|
5898
|
+
async ensureShardDir(_id) {
|
|
5895
5899
|
await ensureDir(this.dir);
|
|
5900
|
+
return this.dir;
|
|
5901
|
+
}
|
|
5902
|
+
async create(meta) {
|
|
5896
5903
|
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5897
5904
|
const id = meta.id ?? `${startedAt.replace(/[:.]/g, "-")}-${randomBytes(2).toString("hex")}`;
|
|
5898
|
-
const
|
|
5905
|
+
const shardDir = await this.ensureShardDir(id);
|
|
5906
|
+
const file = path4.join(shardDir, `${id}.jsonl`);
|
|
5899
5907
|
let handle;
|
|
5900
5908
|
try {
|
|
5901
5909
|
handle = await fsp4.open(file, "a", 384);
|
|
5902
5910
|
} catch (err) {
|
|
5903
5911
|
throw new Error(
|
|
5904
5912
|
`Failed to open session file: ${err instanceof Error ? err.message : String(err)}`,
|
|
5905
|
-
{
|
|
5906
|
-
cause: err
|
|
5907
|
-
}
|
|
5913
|
+
{ cause: err }
|
|
5908
5914
|
);
|
|
5909
5915
|
}
|
|
5910
5916
|
try {
|
|
5911
|
-
return new FileSessionWriter(id, handle, startedAt, meta, this.events, { dir:
|
|
5917
|
+
return new FileSessionWriter(id, handle, startedAt, meta, this.events, { dir: shardDir, filePath: file });
|
|
5912
5918
|
} catch (err) {
|
|
5913
5919
|
await handle.close().catch(() => {
|
|
5914
5920
|
});
|
|
@@ -5916,15 +5922,7 @@ var DefaultSessionStore = class {
|
|
|
5916
5922
|
}
|
|
5917
5923
|
}
|
|
5918
5924
|
async resume(id) {
|
|
5919
|
-
const file =
|
|
5920
|
-
try {
|
|
5921
|
-
await fsp4.access(file, fsp4.constants.R_OK);
|
|
5922
|
-
} catch {
|
|
5923
|
-
throw new Error(
|
|
5924
|
-
`Session "${id}" not found \u2014 the session file does not exist or was deleted.`,
|
|
5925
|
-
{ cause: new Error("ENOENT") }
|
|
5926
|
-
);
|
|
5927
|
-
}
|
|
5925
|
+
const file = this.sessionPath(id, ".jsonl");
|
|
5928
5926
|
const data = await this.load(id);
|
|
5929
5927
|
let handle;
|
|
5930
5928
|
try {
|
|
@@ -5956,7 +5954,7 @@ var DefaultSessionStore = class {
|
|
|
5956
5954
|
}
|
|
5957
5955
|
}
|
|
5958
5956
|
async load(id) {
|
|
5959
|
-
const file =
|
|
5957
|
+
const file = this.sessionPath(id, ".jsonl");
|
|
5960
5958
|
const raw = await fsp4.readFile(file, "utf8");
|
|
5961
5959
|
const lines = raw.split("\n").filter((l) => l.trim());
|
|
5962
5960
|
const events = [];
|
|
@@ -5976,8 +5974,7 @@ var DefaultSessionStore = class {
|
|
|
5976
5974
|
async list(limit = 20) {
|
|
5977
5975
|
try {
|
|
5978
5976
|
await ensureDir(this.dir);
|
|
5979
|
-
const
|
|
5980
|
-
const ids = files.filter((f) => f.endsWith(".jsonl")).map((f) => f.replace(/\.jsonl$/, ""));
|
|
5977
|
+
const ids = await this.collectSessionIds(this.dir);
|
|
5981
5978
|
const sessions = await Promise.all(ids.map((id) => this.summaryFor(id).catch(() => null)));
|
|
5982
5979
|
const out = sessions.filter((s) => s !== null);
|
|
5983
5980
|
out.sort((a, b) => {
|
|
@@ -5990,13 +5987,27 @@ var DefaultSessionStore = class {
|
|
|
5990
5987
|
return [];
|
|
5991
5988
|
}
|
|
5992
5989
|
}
|
|
5990
|
+
/** Recursively collect all session IDs from shard subdirectories. */
|
|
5991
|
+
async collectSessionIds(dir) {
|
|
5992
|
+
const ids = [];
|
|
5993
|
+
const entries = await fsp4.readdir(dir, { withFileTypes: true });
|
|
5994
|
+
for (const entry of entries) {
|
|
5995
|
+
const full = path4.join(dir, entry.name);
|
|
5996
|
+
if (entry.isDirectory()) {
|
|
5997
|
+
ids.push(...await this.collectSessionIds(full));
|
|
5998
|
+
} else if (entry.isFile() && entry.name.endsWith(".jsonl")) {
|
|
5999
|
+
ids.push(entry.name.replace(/\.jsonl$/, ""));
|
|
6000
|
+
}
|
|
6001
|
+
}
|
|
6002
|
+
return ids;
|
|
6003
|
+
}
|
|
5993
6004
|
async summaryFor(id) {
|
|
5994
|
-
const manifest =
|
|
6005
|
+
const manifest = this.sessionPath(id, ".summary.json");
|
|
5995
6006
|
try {
|
|
5996
6007
|
const raw = await fsp4.readFile(manifest, "utf8");
|
|
5997
6008
|
return JSON.parse(raw);
|
|
5998
6009
|
} catch {
|
|
5999
|
-
const full =
|
|
6010
|
+
const full = this.sessionPath(id, ".jsonl");
|
|
6000
6011
|
const stat3 = await fsp4.stat(full);
|
|
6001
6012
|
const summary = await this.summarize(id, stat3.mtime.toISOString());
|
|
6002
6013
|
await atomicWrite(manifest, JSON.stringify(summary), { mode: 384 }).catch((err) => {
|
|
@@ -6009,12 +6020,13 @@ var DefaultSessionStore = class {
|
|
|
6009
6020
|
}
|
|
6010
6021
|
}
|
|
6011
6022
|
async delete(id) {
|
|
6012
|
-
await fsp4.unlink(
|
|
6013
|
-
await fsp4.unlink(
|
|
6023
|
+
await fsp4.unlink(this.sessionPath(id, ".jsonl"));
|
|
6024
|
+
await fsp4.unlink(this.sessionPath(id, ".summary.json")).catch(() => void 0);
|
|
6014
6025
|
}
|
|
6015
6026
|
async clearHistory(id) {
|
|
6016
|
-
|
|
6017
|
-
const
|
|
6027
|
+
await this.ensureShardDir(id);
|
|
6028
|
+
const file = this.sessionPath(id, ".jsonl");
|
|
6029
|
+
const meta = this.sessionPath(id, ".summary.json");
|
|
6018
6030
|
const record = `${JSON.stringify({
|
|
6019
6031
|
type: "session_start",
|
|
6020
6032
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -6058,7 +6070,8 @@ var DefaultSessionStore = class {
|
|
|
6058
6070
|
startedAt: start?.ts ?? (/* @__PURE__ */ new Date(0)).toISOString(),
|
|
6059
6071
|
endedAt: end?.ts,
|
|
6060
6072
|
model: start?.model,
|
|
6061
|
-
provider: start?.provider
|
|
6073
|
+
provider: start?.provider,
|
|
6074
|
+
pendingToolUses: end?.pendingToolUses
|
|
6062
6075
|
};
|
|
6063
6076
|
}
|
|
6064
6077
|
replay(events, sessionId = "unknown") {
|
|
@@ -6158,9 +6171,6 @@ var FileSessionWriter = class {
|
|
|
6158
6171
|
tokenIn = 0;
|
|
6159
6172
|
tokenOut = 0;
|
|
6160
6173
|
filePath;
|
|
6161
|
-
/** Public accessor for the JSONL path — required by SessionWriter so
|
|
6162
|
-
* observability surfaces (`/fleet log`, FleetPanel) can locate the
|
|
6163
|
-
* transcript without recomputing the path from session metadata. */
|
|
6164
6174
|
get transcriptPath() {
|
|
6165
6175
|
return this.filePath || void 0;
|
|
6166
6176
|
}
|
|
@@ -6168,13 +6178,16 @@ var FileSessionWriter = class {
|
|
|
6168
6178
|
resumed;
|
|
6169
6179
|
appendFailCount = 0;
|
|
6170
6180
|
lastAppendWarnAt = 0;
|
|
6171
|
-
// Rewind support: track pending file changes and prompt index
|
|
6172
6181
|
promptIndex = 0;
|
|
6173
6182
|
pendingFileSnapshots = [];
|
|
6174
|
-
|
|
6183
|
+
/** Tracks open tool_use IDs during the current run to serialize on close for resume. */
|
|
6184
|
+
openToolUses = /* @__PURE__ */ new Set();
|
|
6175
6185
|
recordFileChange(input) {
|
|
6176
6186
|
this.pendingFileSnapshots.push(input);
|
|
6177
6187
|
}
|
|
6188
|
+
get pendingToolUses() {
|
|
6189
|
+
return Array.from(this.openToolUses);
|
|
6190
|
+
}
|
|
6178
6191
|
async writeSessionStartLazy() {
|
|
6179
6192
|
const record = `${JSON.stringify({
|
|
6180
6193
|
type: this.resumed ? "session_resumed" : "session_start",
|
|
@@ -6217,13 +6230,12 @@ var FileSessionWriter = class {
|
|
|
6217
6230
|
}
|
|
6218
6231
|
}
|
|
6219
6232
|
}
|
|
6220
|
-
/**
|
|
6221
|
-
* Watch events as they're appended and keep the summary state hot, so
|
|
6222
|
-
* `close()` can flush a `<id>.summary.json` manifest without re-reading
|
|
6223
|
-
* the JSONL. `list()` reads only manifests, turning a per-session full
|
|
6224
|
-
* parse into a single stat+read.
|
|
6225
|
-
*/
|
|
6226
6233
|
observeForSummary(event) {
|
|
6234
|
+
if (event.type === "tool_use") {
|
|
6235
|
+
this.openToolUses.add(event.id);
|
|
6236
|
+
} else if (event.type === "tool_result") {
|
|
6237
|
+
this.openToolUses.delete(event.id);
|
|
6238
|
+
}
|
|
6227
6239
|
if (event.type === "user_input" && this.summary.title === "(empty session)") {
|
|
6228
6240
|
this.summary = { ...this.summary, title: userInputTitle(event.content) };
|
|
6229
6241
|
} else if (event.type === "llm_response") {
|
|
@@ -6317,7 +6329,16 @@ var FileSessionWriter = class {
|
|
|
6317
6329
|
}
|
|
6318
6330
|
}
|
|
6319
6331
|
const truncated = kept.join("\n");
|
|
6320
|
-
|
|
6332
|
+
const tmpPath = `${this.filePath}.rewind.tmp`;
|
|
6333
|
+
await fsp4.writeFile(tmpPath, truncated + "\n", "utf8");
|
|
6334
|
+
try {
|
|
6335
|
+
await this.handle.close();
|
|
6336
|
+
await fsp4.rename(tmpPath, this.filePath);
|
|
6337
|
+
this.handle = await fsp4.open(this.filePath, "a", 384);
|
|
6338
|
+
} catch (err) {
|
|
6339
|
+
await fsp4.unlink(tmpPath).catch(() => void 0);
|
|
6340
|
+
throw err;
|
|
6341
|
+
}
|
|
6321
6342
|
await this.append({
|
|
6322
6343
|
type: "rewound",
|
|
6323
6344
|
ts: (/* @__PURE__ */ new Date()).toISOString(),
|