@wrongstack/core 0.273.0 → 0.274.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.
Files changed (64) hide show
  1. package/dist/{agent-bridge-BZ2enORi.d.ts → agent-bridge-DFo21wmY.d.ts} +1 -1
  2. package/dist/{agent-subagent-runner-ehb4xGvd.d.ts → agent-subagent-runner-BwmkIDEd.d.ts} +7 -7
  3. package/dist/{brain-BxN2k2HP.d.ts → brain-gfZX3the.d.ts} +11 -5
  4. package/dist/{provider-model-resolve-DFd3IPpw.d.ts → codex-catalog-CooZ6mOl.d.ts} +47 -4
  5. package/dist/{compactor-72ug-ZRB.d.ts → compactor-riTOds0f.d.ts} +1 -1
  6. package/dist/{config-C8IYxlO8.d.ts → config-BxcrDzri.d.ts} +60 -4
  7. package/dist/{context-Dw55zZ_Q.d.ts → context-DERiLofu.d.ts} +60 -1
  8. package/dist/coordination/index.d.ts +27 -16
  9. package/dist/coordination/index.js +1641 -1398
  10. package/dist/coordination/index.js.map +1 -1
  11. package/dist/defaults/index.d.ts +26 -26
  12. package/dist/defaults/index.js +2154 -1466
  13. package/dist/defaults/index.js.map +1 -1
  14. package/dist/execution/index.d.ts +15 -15
  15. package/dist/execution/index.js +77 -9
  16. package/dist/execution/index.js.map +1 -1
  17. package/dist/execution/prompt-enhancer.d.ts +1 -1
  18. package/dist/extension/index.d.ts +6 -6
  19. package/dist/{global-mailbox-C9dsc9Y_.d.ts → global-mailbox-Cr8TW4t_.d.ts} +1 -1
  20. package/dist/{goal-preamble-NhflDjYb.d.ts → goal-preamble-CEhROp1e.d.ts} +9 -9
  21. package/dist/{goal-store-Cx363x7Z.d.ts → goal-store-xNSVxmpV.d.ts} +1 -1
  22. package/dist/hq/index.d.ts +5 -5
  23. package/dist/{index-B7fHDt0B.d.ts → index-00KPKAlm.d.ts} +5 -5
  24. package/dist/{index-BbVprU-9.d.ts → index-pDBSBE1r.d.ts} +2 -2
  25. package/dist/index.d.ts +72 -45
  26. package/dist/index.js +2840 -1769
  27. package/dist/index.js.map +1 -1
  28. package/dist/infrastructure/index.d.ts +6 -6
  29. package/dist/kernel/index.d.ts +11 -11
  30. package/dist/kernel/index.js.map +1 -1
  31. package/dist/{mcp-servers-B6fSRNC1.d.ts → mcp-servers-BIwRiOxe.d.ts} +3 -3
  32. package/dist/models/index.d.ts +5 -5
  33. package/dist/models/index.js +40 -2
  34. package/dist/models/index.js.map +1 -1
  35. package/dist/{models-registry-4C6Wr91w.d.ts → models-registry-8OorW51H.d.ts} +1 -1
  36. package/dist/{multi-agent-coordinator-q1skFeNP.d.ts → multi-agent-coordinator-CNx48Zoz.d.ts} +1 -1
  37. package/dist/{null-fleet-bus-C9rrgQwc.d.ts → null-fleet-bus-B4ZUJYL6.d.ts} +6 -6
  38. package/dist/observability/index.d.ts +2 -2
  39. package/dist/{parallel-eternal-engine-CtXly2Sf.d.ts → parallel-eternal-engine-rsIclDqO.d.ts} +9 -9
  40. package/dist/{path-resolver-Bim6G5Jz.d.ts → path-resolver-BqU-fwzD.d.ts} +3 -3
  41. package/dist/{permission-CC7XFYWG.d.ts → permission-Dgs3v-Xq.d.ts} +1 -1
  42. package/dist/{permission-policy-cYR4RJmw.d.ts → permission-policy-Dtht2k0e.d.ts} +2 -2
  43. package/dist/{pipeline-CNVKuQDQ.d.ts → pipeline-B-dpCFYS.d.ts} +2 -2
  44. package/dist/{plan-templates-C4wXMmiM.d.ts → plan-templates-B7MxyY2o.d.ts} +58 -5
  45. package/dist/{provider-runner-BpM0mdBE.d.ts → provider-runner-DrmpBE5l.d.ts} +3 -3
  46. package/dist/{retry-policy-BV7nzeAd.d.ts → retry-policy-hYxsm10a.d.ts} +1 -1
  47. package/dist/sdd/index.d.ts +12 -10
  48. package/dist/sdd/index.js +7 -0
  49. package/dist/sdd/index.js.map +1 -1
  50. package/dist/{secret-vault-eMBKfheR.d.ts → secret-vault-DnqIFhPF.d.ts} +1 -1
  51. package/dist/security/index.d.ts +5 -5
  52. package/dist/{selector-C4ORTOid.d.ts → selector-D21RjDIg.d.ts} +1 -1
  53. package/dist/{session-event-bridge-CeNpUL9w.d.ts → session-event-bridge-Dt54CTvq.d.ts} +1 -1
  54. package/dist/{session-reader-BepLSnGL.d.ts → session-reader-CceH13Kq.d.ts} +5 -4
  55. package/dist/storage/index.d.ts +46 -12
  56. package/dist/storage/index.js +2281 -1476
  57. package/dist/storage/index.js.map +1 -1
  58. package/dist/tools/index.d.ts +2 -2
  59. package/dist/types/index.d.ts +19 -19
  60. package/dist/types/index.js +162 -42
  61. package/dist/types/index.js.map +1 -1
  62. package/dist/utils/index.d.ts +2 -2
  63. package/dist/{worktree-manager-BDuXTaWL.d.ts → worktree-manager-DUfBbKzk.d.ts} +1 -1
  64. package/package.json +1 -1
@@ -1,5 +1,5 @@
1
- import { T as Tool } from '../context-Dw55zZ_Q.js';
2
- import { c as MCPServerConfig, C as Config } from '../config-C8IYxlO8.js';
1
+ import { T as Tool } from '../context-DERiLofu.js';
2
+ import { c as MCPServerConfig, C as Config } from '../config-BxcrDzri.js';
3
3
  import '../dispatcher-types.d-BBeXBQgS.js';
4
4
  import 'node:https';
5
5
  import 'undici';
@@ -1,34 +1,34 @@
1
- export { A as AgentError, p as CacheTtl, n as Capabilities, z as ConfigError, i as ContentBlock, C as Context, B as ContextEvidenceState, D as ContextFileEvidence, E as ContextInit, F as ContextIntentEvidence, G as ContextRepeatedReadEvidence, H as ERROR_CODES, I as ErrorCode, K as ErrorSeverity, L as ErrorSubsystem, N as FileSnapshot, O as FsError, Q as ImageBlock, J as JSONSchema, V as JsonSchemaSpec, M as Message, W as MessageRole, h as Permission, X as PluginError, P as Provider, g as ProviderError, Y as ProviderErrorBody, a as ReasoningConfig, o as ReasoningEffort, R as ReasoningRequest, c as Request, _ as RequestCacheControl, d as Response, $ as ResponseFormat, u as ResumedSession, a0 as RiskTier, t as RunOptions, a2 as SafetySetting, a3 as SddError, v as SessionData, a4 as SessionError, S as SessionEvent, j as SessionMetadata, k as SessionStore, w as SessionSummary, b as SessionWriter, a7 as StopReason, a8 as StreamEvent, a9 as StreamHangError, q as TextBlock, aa as ThinkingBlock, x as TodoItem, T as Tool, ab as ToolCallContext, ac as ToolError, ad as ToolErrorCategory, ae as ToolErrorInfo, af as ToolEvidenceStatus, ag as ToolFinalEvent, ah as ToolIconId, m as ToolOutputMetadata, l as ToolProgressEvent, s as ToolResultBlock, ai as ToolStreamEvent, r as ToolUseBlock, U as Usage, aj as WrongStackError, ak as asBlocks, al as asText, an as isAgentError, ao as isConfigError, ap as isFsError, aq as isImageBlock, ar as isPluginError, as as isSddError, at as isSessionError, au as isTextBlock, av as isThinkingBlock, aw as isToolError, ax as isToolResultBlock, ay as isToolUseBlock, az as isWrongStackError, aA as toWrongStackError } from '../context-Dw55zZ_Q.js';
2
- export { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-BpM0mdBE.js';
3
- export { A as AdaptiveConcurrencyConfig, o as AutonomyConfig, p as CONTEXT_WINDOW_MODES, q as CircuitBreakerRuntimeConfig, C as Config, k as ConfigLoader, j as ConfigStore, r as ContextConfig, h as ContextWindowAggressiveOn, s as ContextWindowConfigLike, t as ContextWindowMode, u as ContextWindowModeId, i as ContextWindowPolicy, v as ContextWindowThresholds, w as CustomModelDefinition, D as DEFAULT_CONTEXT_WINDOW_MODE_ID, x as DEFAULT_TUI_THINKING_WORD, F as FeaturesConfig, g as HookEntry, H as HookEvent, m as HookInput, f as HookMatcher, n as HookOutcome, y as HqClientConfig, I as InProcessHook, z as IndexingConfig, L as LaunchConfig, B as LogConfig, E as MAX_TUI_THINKING_WORD_LENGTH, c as MCPServerConfig, d as ModelMatrixEntry, G as ModelRuntimeCacheConfig, J as ModelRuntimeConfig, K as ModelRuntimeParametersConfig, N as ModelRuntimeReasoningConfig, e as ModelsDevModel, a as ModelsDevPayload, O as ModelsDevProvider, M as ModelsRegistry, Q as PluginConfig, U as ProviderApiKey, P as ProviderConfig, b as ResolvedModel, R as ResolvedProvider, V as SessionLoggingConfig, S as ShellHook, X as SyncCategory, l as SyncConfig, T as TokenSavingTier, Y as ToolDescriptionMode, Z as ToolDescriptionModeConfig, _ as ToolsConfig, W as WireFamily, $ as formatContextWindowModeList, a0 as getContextWindowMode, a1 as isContextWindowModeId, a2 as listContextWindowModes, a3 as normalizeTokenSavingTier, a4 as normalizeTuiThinkingWord, a5 as resolveContextWindowPolicy } from '../config-C8IYxlO8.js';
4
- export { a as CompactReport, C as Compactor } from '../compactor-72ug-ZRB.js';
5
- export { a as PermissionDecision, P as PermissionPolicy, T as TrustPolicy } from '../permission-CC7XFYWG.js';
1
+ export { A as AgentError, p as CacheTtl, n as Capabilities, z as ConfigError, i as ContentBlock, C as Context, B as ContextEvidenceState, D as ContextFileEvidence, E as ContextInit, F as ContextIntentEvidence, G as ContextRepeatedReadEvidence, H as ERROR_CODES, I as ErrorCode, K as ErrorSeverity, L as ErrorSubsystem, N as FileSnapshot, O as FsError, Q as ImageBlock, J as JSONSchema, V as JsonSchemaSpec, M as Message, W as MessageRole, h as Permission, X as PluginError, P as Provider, g as ProviderError, Y as ProviderErrorBody, a as ReasoningConfig, o as ReasoningEffort, R as ReasoningRequest, c as Request, _ as RequestCacheControl, d as Response, $ as ResponseFormat, u as ResumedSession, a0 as RiskTier, t as RunOptions, a2 as SafetySetting, a3 as SddError, v as SessionData, a4 as SessionError, S as SessionEvent, j as SessionMetadata, k as SessionStore, w as SessionSummary, b as SessionWriter, a7 as StopReason, a8 as StreamEvent, a9 as StreamHangError, q as TextBlock, aa as ThinkingBlock, x as TodoItem, T as Tool, ab as ToolCallContext, ac as ToolError, ad as ToolErrorCategory, ae as ToolErrorInfo, af as ToolEvidenceStatus, ag as ToolFinalEvent, ah as ToolIconId, m as ToolOutputMetadata, l as ToolProgressEvent, s as ToolResultBlock, ai as ToolStreamEvent, r as ToolUseBlock, U as Usage, aj as WrongStackError, ak as asBlocks, al as asText, an as isAgentError, ao as isConfigError, ap as isFsError, aq as isImageBlock, ar as isPluginError, as as isSddError, at as isSessionError, au as isTextBlock, av as isThinkingBlock, aw as isToolError, ax as isToolResultBlock, ay as isToolUseBlock, az as isWrongStackError, aA as toWrongStackError } from '../context-DERiLofu.js';
2
+ export { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-DrmpBE5l.js';
3
+ export { A as AdaptiveConcurrencyConfig, o as AutonomyConfig, p as CONTEXT_WINDOW_MODES, q as CircuitBreakerRuntimeConfig, C as Config, k as ConfigLoader, j as ConfigStore, r as ContextConfig, h as ContextWindowAggressiveOn, s as ContextWindowConfigLike, t as ContextWindowMode, u as ContextWindowModeId, i as ContextWindowPolicy, v as ContextWindowThresholds, w as CustomModelDefinition, D as DEFAULT_CONTEXT_WINDOW_MODE_ID, x as DEFAULT_TUI_THINKING_WORD, E as ExecToolConfig, F as FeaturesConfig, g as HookEntry, H as HookEvent, m as HookInput, f as HookMatcher, n as HookOutcome, y as HqClientConfig, I as InProcessHook, z as IndexingConfig, L as LaunchConfig, B as LogConfig, G as MAX_TUI_THINKING_WORD_LENGTH, c as MCPServerConfig, d as ModelMatrixEntry, J as ModelRuntimeCacheConfig, K as ModelRuntimeConfig, N as ModelRuntimeParametersConfig, O as ModelRuntimeReasoningConfig, e as ModelsDevModel, a as ModelsDevPayload, Q as ModelsDevProvider, M as ModelsRegistry, U as PluginConfig, V as ProviderApiKey, P as ProviderConfig, b as ResolvedModel, R as ResolvedProvider, X as SessionLoggingConfig, S as ShellHook, Y as SyncCategory, l as SyncConfig, T as TokenSavingTier, Z as ToolDescriptionMode, _ as ToolDescriptionModeConfig, $ as ToolsConfig, W as WireFamily, a0 as formatContextWindowModeList, a1 as getContextWindowMode, a2 as isContextWindowModeId, a3 as listContextWindowModes, a4 as normalizeTokenSavingTier, a5 as normalizeTuiThinkingWord, a6 as resolveContextWindowPolicy } from '../config-BxcrDzri.js';
4
+ export { a as CompactReport, C as Compactor } from '../compactor-riTOds0f.js';
5
+ export { a as PermissionDecision, P as PermissionPolicy, T as TrustPolicy } from '../permission-Dgs3v-Xq.js';
6
6
  export { C as CheckpointInfo, R as RewindResult, a as RewindResultExtended, S as SessionRewinder } from '../session-rewinder-C9HnMkhP.js';
7
- export { a as AddAttachmentInput, c as Attachment, d as AttachmentKind, e as AttachmentMeta, b as AttachmentRef, A as AttachmentStore, D as DefaultSessionReader } from '../session-reader-BepLSnGL.js';
7
+ export { a as AddAttachmentInput, c as Attachment, d as AttachmentKind, e as AttachmentMeta, b as AttachmentRef, A as AttachmentStore, D as DefaultSessionReader } from '../session-reader-CceH13Kq.js';
8
8
  export { D as DEFAULT_AUTONOMY_CONFIG, a as DEFAULT_CIRCUIT_BREAKER_CONFIG, b as DEFAULT_CONTEXT_CONFIG, c as DEFAULT_SESSION_LOGGING_CONFIG, d as DEFAULT_SESSION_PRUNE_DAYS, e as DEFAULT_TOOLS_CONFIG } from '../default-config-BbX4ojZs.js';
9
- export { a as DefaultSecretScrubber, D as DefaultSecretVault, S as SecretVaultOptions, d as decryptConfigSecrets, e as encryptConfigSecrets, i as isSecretField, m as migratePlaintextSecrets, r as rewriteConfigEncrypted, b as rotateConfigKeys } from '../secret-vault-eMBKfheR.js';
9
+ export { a as DefaultSecretScrubber, D as DefaultSecretVault, S as SecretVaultOptions, d as decryptConfigSecrets, e as encryptConfigSecrets, i as isSecretField, m as migratePlaintextSecrets, r as rewriteConfigEncrypted, b as rotateConfigKeys } from '../secret-vault-DnqIFhPF.js';
10
10
  export { D as DefaultLogger, a as DefaultLoggerOptions, L as LogFormat, n as noOpLogger } from '../logger-DmmQhf4P.js';
11
- export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver-Bim6G5Jz.js';
12
- export { o as MEMORY_TYPE_LABELS, p as MemoryClearedPayload, q as MemoryConsolidatedPayload, b as MemoryEntry, r as MemoryForgottenPayload, s as MemoryPriority, d as MemoryRelevanceContext, t as MemoryRememberedPayload, M as MemoryScope, c as MemoryStore, u as MemoryType, S as ScoredEntry } from '../brain-BxN2k2HP.js';
13
- import { I as IterationStage, g as ParallelIterationStage } from '../parallel-eternal-engine-CtXly2Sf.js';
14
- export { C as CompactorOptions, D as DEFAULT_RECOVERY_STRATEGIES, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, R as RecoveryStrategy, T as ToolExecutor, h as buildRecoveryStrategies } from '../parallel-eternal-engine-CtXly2Sf.js';
11
+ export { D as DefaultPathResolver, a as DefaultTokenCounter } from '../path-resolver-BqU-fwzD.js';
12
+ export { o as MEMORY_TYPE_LABELS, p as MemoryClearedPayload, q as MemoryConsolidatedPayload, b as MemoryEntry, r as MemoryForgottenPayload, s as MemoryPriority, d as MemoryRelevanceContext, t as MemoryRememberedPayload, M as MemoryScope, c as MemoryStore, u as MemoryType, S as ScoredEntry } from '../brain-gfZX3the.js';
13
+ import { I as IterationStage, g as ParallelIterationStage } from '../parallel-eternal-engine-rsIclDqO.js';
14
+ export { C as CompactorOptions, D as DEFAULT_RECOVERY_STRATEGIES, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, R as RecoveryStrategy, T as ToolExecutor, h as buildRecoveryStrategies } from '../parallel-eternal-engine-rsIclDqO.js';
15
15
  export { b as SkillEntry, S as SkillLoader, a as SkillManifest } from '../skill-DGIXCtdv.js';
16
- export { B as BuildContext, b as ModelCapabilities, a as Renderer, S as SystemPromptBuilder } from '../pipeline-CNVKuQDQ.js';
16
+ export { B as BuildContext, b as ModelCapabilities, a as Renderer, S as SystemPromptBuilder } from '../pipeline-B-dpCFYS.js';
17
17
  export { I as InputReader, P as PromptOption } from '../input-reader-E-ffP2ee.js';
18
- export { K as CoordinatorEvents, C as CoordinatorStatus, D as DoneCondition, o as MCPRegistryView, r as MetricsSinkView, c as MultiAgentConfig, M as MultiAgentCoordinator, u as Plugin, P as PluginAPI, s as PluginCapabilities, t as PluginDependency, l as PluginPipelines, a1 as ProviderFactory, n as ProviderRegistryView, q as SessionWriterView, k as SlashCommand, p as SlashCommandRegistryView, e as SpawnResult, S as SubagentConfig, R as SubagentContext, U as SubagentError, V as SubagentErrorKind, W as SubagentRunContext, X as SubagentRunOutcome, d as SubagentRunner, _ as TaskDelegation, f as TaskResult, T as TaskSpec, m as ToolRegistryView } from '../agent-subagent-runner-ehb4xGvd.js';
19
- export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-4C6Wr91w.js';
18
+ export { K as CoordinatorEvents, C as CoordinatorStatus, D as DoneCondition, o as MCPRegistryView, r as MetricsSinkView, c as MultiAgentConfig, M as MultiAgentCoordinator, u as Plugin, P as PluginAPI, s as PluginCapabilities, t as PluginDependency, l as PluginPipelines, a1 as ProviderFactory, n as ProviderRegistryView, q as SessionWriterView, k as SlashCommand, p as SlashCommandRegistryView, e as SpawnResult, S as SubagentConfig, R as SubagentContext, U as SubagentError, V as SubagentErrorKind, W as SubagentRunContext, X as SubagentRunOutcome, d as SubagentRunner, _ as TaskDelegation, f as TaskResult, T as TaskSpec, m as ToolRegistryView } from '../agent-subagent-runner-BwmkIDEd.js';
19
+ export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from '../models-registry-8OorW51H.js';
20
20
  export { D as DEFAULT_MODES, b as Mode, a as ModeConfig, c as ModeManifest, M as ModeStore } from '../mode-CZlO9iU1.js';
21
- export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-BZ2enORi.js';
21
+ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMessage } from '../agent-bridge-DFo21wmY.js';
22
22
  export { D as DEFAULT_SPEC_TEMPLATE, S as SpecAnalysis, a as SpecApiEndpoint, b as SpecRequirement, c as SpecSection, d as SpecSectionType, e as SpecStatus, f as SpecTemplate, g as SpecValidationResult, h as Specification } from '../spec-TBi3Jr6T.js';
23
23
  export { C as CriticalPathResult, f as TaskAssignment, g as TaskDependency, h as TaskEdge, i as TaskFilter, d as TaskGraph, e as TaskNode, a as TaskPriority, c as TaskProgress, j as TaskSort, b as TaskStatus, T as TaskType, k as computeTaskProgress, l as findCriticalPath, t as topologicalSort } from '../task-graph-u1q9Jkyk.js';
24
24
  export { A as AggregateHealth, a as HealthCheck, b as HealthCheckResult, H as HealthRegistry, c as HealthStatus, d as MetricLabels, e as MetricSeries, M as MetricsSink, f as MetricsSnapshot, S as Span, T as Tracer } from '../observability-D-HZN_mF.js';
25
- export { S as SystemPromptContributor } from '../index-B7fHDt0B.js';
25
+ export { S as SystemPromptContributor } from '../index-00KPKAlm.js';
26
26
  import '../logger-B63L5bTg.js';
27
- import '../retry-policy-BV7nzeAd.js';
27
+ import '../retry-policy-hYxsm10a.js';
28
28
  import '../secret-vault-BAKpgFw_.js';
29
29
  import '../path-resolver-CPRj4bFY.js';
30
- import '../goal-store-Cx363x7Z.js';
31
- import '../multi-agent-coordinator-q1skFeNP.js';
30
+ import '../goal-store-xNSVxmpV.js';
31
+ import '../multi-agent-coordinator-CNx48Zoz.js';
32
32
  import 'node:events';
33
33
  import '../mailbox-types-Ct2hJq0P.js';
34
34
 
@@ -60,8 +60,8 @@ async function atomicWrite(targetPath, content, opts = {}) {
60
60
  }
61
61
  let mode;
62
62
  try {
63
- const stat2 = await fs.stat(targetPath);
64
- mode = stat2.mode & 511;
63
+ const stat3 = await fs.stat(targetPath);
64
+ mode = stat3.mode & 511;
65
65
  } catch {
66
66
  mode = opts.mode;
67
67
  }
@@ -299,11 +299,11 @@ function validateAgainstSchema(value, schema) {
299
299
  walk(value, schema, "", errors);
300
300
  return { ok: errors.length === 0, errors };
301
301
  }
302
- function walk(value, schema, path10, errors) {
302
+ function walk(value, schema, path11, errors) {
303
303
  if (schema.enum !== void 0) {
304
304
  if (!schema.enum.some((e) => deepEqual(e, value))) {
305
305
  errors.push({
306
- path: path10 || "<root>",
306
+ path: path11 || "<root>",
307
307
  message: `expected one of ${JSON.stringify(schema.enum)}, got ${JSON.stringify(value)}`
308
308
  });
309
309
  return;
@@ -312,7 +312,7 @@ function walk(value, schema, path10, errors) {
312
312
  if (typeof schema.type === "string") {
313
313
  if (!checkType(value, schema.type)) {
314
314
  errors.push({
315
- path: path10 || "<root>",
315
+ path: path11 || "<root>",
316
316
  message: `expected ${schema.type}, got ${describeType(value)}`
317
317
  });
318
318
  return;
@@ -322,20 +322,20 @@ function walk(value, schema, path10, errors) {
322
322
  const obj = value;
323
323
  for (const req of schema.required ?? []) {
324
324
  if (!(req in obj)) {
325
- errors.push({ path: joinPath(path10, req), message: "required property missing" });
325
+ errors.push({ path: joinPath(path11, req), message: "required property missing" });
326
326
  }
327
327
  }
328
328
  if (schema.properties) {
329
329
  for (const [key, subSchema] of Object.entries(schema.properties)) {
330
330
  if (key in obj) {
331
- walk(obj[key], subSchema, joinPath(path10, key), errors);
331
+ walk(obj[key], subSchema, joinPath(path11, key), errors);
332
332
  }
333
333
  }
334
334
  }
335
335
  }
336
336
  if (schema.type === "array" && Array.isArray(value) && schema.items) {
337
337
  for (let i = 0; i < value.length; i++) {
338
- walk(value[i], schema.items, `${path10}[${i}]`, errors);
338
+ walk(value[i], schema.items, `${path11}[${i}]`, errors);
339
339
  }
340
340
  }
341
341
  }
@@ -1947,8 +1947,8 @@ function unwrapDataKey(buf, keyFile) {
1947
1947
  function checkKeyFilePermissions(keyFile) {
1948
1948
  if (process.platform === "win32") return;
1949
1949
  try {
1950
- const stat2 = fs2.statSync(keyFile);
1951
- const actualMode = stat2.mode & 511;
1950
+ const stat3 = fs2.statSync(keyFile);
1951
+ const actualMode = stat3.mode & 511;
1952
1952
  if (actualMode !== KEY_FILE_MODE) {
1953
1953
  console.warn(JSON.stringify({
1954
1954
  level: "warn",
@@ -4750,7 +4750,7 @@ ${errorDetails}`,
4750
4750
  "tool.name": tool.name,
4751
4751
  "tool.mutating": tool.mutating,
4752
4752
  "tool.permission": tool.permission,
4753
- "tool.capabilities": JSON.stringify(tool.capabilities ?? []),
4753
+ "tool.capabilities": toolCapsForAudit.length > 0 ? JSON.stringify(tool.capabilities ?? []) : "[]",
4754
4754
  "tool.has_dangerous_capabilities": toolCapsForAudit.length > 0
4755
4755
  });
4756
4756
  try {
@@ -5162,6 +5162,28 @@ var ConversationState = class {
5162
5162
  this.ctx.messages.splice(this.ctx.messages.length, 0, message);
5163
5163
  this.emit({ kind: "message_appended", message });
5164
5164
  }
5165
+ /**
5166
+ * Append a content block to the trailing user message's content array.
5167
+ * Mutates only that one message (a single indexed assignment) — avoids
5168
+ * the O(n) array copy + token-cache re-walk that `replaceMessages()`
5169
+ * would do for a single-message edit. Used by the agent loop to fold
5170
+ * btw-notes / queued-mailbox blocks into the conversation.
5171
+ *
5172
+ * The block is folded only into a *user* message (preserves
5173
+ * user/assistant alternation between tool batches). Returns false when
5174
+ * there is no trailing user message to fold into — callers should
5175
+ * `appendMessage({ role: 'user', content: [block] })` instead.
5176
+ */
5177
+ appendBlockToLastUserMessage(block) {
5178
+ const arr = this.ctx.messages;
5179
+ const last = arr[arr.length - 1];
5180
+ if (!last || last.role !== "user") return false;
5181
+ const content = typeof last.content === "string" ? [{ type: "text", text: last.content }, block] : [...last.content, block];
5182
+ const updated = { ...last, content, _estTokens: computeMessageTokens({ ...last, content }) };
5183
+ arr[arr.length - 1] = updated;
5184
+ this.emit({ kind: "message_updated", index: arr.length - 1, message: updated });
5185
+ return true;
5186
+ }
5165
5187
  replaceMessages(messages) {
5166
5188
  let hasToolBlock = false;
5167
5189
  for (const m of messages) {
@@ -5404,26 +5426,82 @@ var Context = class {
5404
5426
  return this.tokenCounter.total();
5405
5427
  }
5406
5428
  };
5407
-
5408
- // src/storage/session-reader.ts
5409
- var DefaultSessionReader = class {
5429
+ var DefaultSessionReader = class _DefaultSessionReader {
5410
5430
  store;
5431
+ eventCache = /* @__PURE__ */ new Map();
5432
+ eventCacheMtimes = /* @__PURE__ */ new Map();
5433
+ static EVENT_CACHE_MAX_ENTRIES = 32;
5411
5434
  constructor(opts) {
5412
5435
  this.store = opts.store;
5413
5436
  }
5437
+ async loadCachedSessionData(sessionId) {
5438
+ const storeWithPath = this.store;
5439
+ const rootDir = storeWithPath.dir;
5440
+ if (!rootDir) {
5441
+ return await this.store.load(sessionId);
5442
+ }
5443
+ const sessionPath = path6.join(rootDir, `${sessionId}.jsonl`);
5444
+ let mtimeMs = null;
5445
+ try {
5446
+ const stat3 = await fs.stat(sessionPath);
5447
+ mtimeMs = stat3.mtimeMs;
5448
+ } catch {
5449
+ this.eventCache.delete(sessionId);
5450
+ this.eventCacheMtimes.delete(sessionId);
5451
+ return await this.store.load(sessionId);
5452
+ }
5453
+ const cachedMtime = this.eventCacheMtimes.get(sessionId);
5454
+ const cachedData = this.eventCache.get(sessionId);
5455
+ if (cachedData && cachedMtime === mtimeMs) {
5456
+ this.eventCache.delete(sessionId);
5457
+ this.eventCacheMtimes.delete(sessionId);
5458
+ this.eventCache.set(sessionId, cachedData);
5459
+ this.eventCacheMtimes.set(sessionId, mtimeMs);
5460
+ return cachedData;
5461
+ }
5462
+ const data = await this.store.load(sessionId);
5463
+ this.eventCache.delete(sessionId);
5464
+ this.eventCacheMtimes.delete(sessionId);
5465
+ this.eventCache.set(sessionId, data);
5466
+ this.eventCacheMtimes.set(sessionId, mtimeMs);
5467
+ while (this.eventCache.size > _DefaultSessionReader.EVENT_CACHE_MAX_ENTRIES) {
5468
+ const oldest = this.eventCache.keys().next().value;
5469
+ if (oldest === void 0) break;
5470
+ this.eventCache.delete(oldest);
5471
+ this.eventCacheMtimes.delete(oldest);
5472
+ }
5473
+ if (data.metadata.endedAt) {
5474
+ storeWithPath.clearLoadCache?.(sessionId);
5475
+ }
5476
+ return data;
5477
+ }
5414
5478
  async query(q = {}) {
5415
- const raw = await this.store.list(q.limit ? Math.max(q.limit, 100) : 1e3);
5416
- const titleNeedle = q.titleContains?.toLowerCase();
5417
- const filtered = raw.filter((s) => {
5418
- if (q.since && s.startedAt < q.since) return false;
5419
- if (q.until && s.startedAt > q.until) return false;
5420
- if (q.provider && s.provider !== q.provider) return false;
5421
- if (q.model && s.model !== q.model) return false;
5422
- if (q.minTokens !== void 0 && s.tokenTotal < q.minTokens) return false;
5423
- if (titleNeedle && !s.title.toLowerCase().includes(titleNeedle)) return false;
5424
- return true;
5425
- });
5426
- const out = filtered.map((s) => ({
5479
+ const storeWithFilter = this.store;
5480
+ let raw;
5481
+ if (typeof storeWithFilter.listFiltered === "function") {
5482
+ raw = await storeWithFilter.listFiltered({
5483
+ since: q.since,
5484
+ until: q.until,
5485
+ provider: q.provider,
5486
+ model: q.model,
5487
+ minTokens: q.minTokens,
5488
+ titleContains: q.titleContains,
5489
+ limit: q.limit
5490
+ });
5491
+ } else {
5492
+ const fetched = await this.store.list(q.limit ? Math.max(q.limit, 100) : 1e3);
5493
+ const titleNeedle = q.titleContains?.toLowerCase();
5494
+ raw = fetched.filter((s) => {
5495
+ if (q.since && s.startedAt < q.since) return false;
5496
+ if (q.until && s.startedAt > q.until) return false;
5497
+ if (q.provider && s.provider !== q.provider) return false;
5498
+ if (q.model && s.model !== q.model) return false;
5499
+ if (q.minTokens !== void 0 && s.tokenTotal < q.minTokens) return false;
5500
+ if (titleNeedle && !s.title.toLowerCase().includes(titleNeedle)) return false;
5501
+ return true;
5502
+ });
5503
+ }
5504
+ const out = raw.map((s) => ({
5427
5505
  id: s.id,
5428
5506
  title: s.title,
5429
5507
  startedAt: s.startedAt,
@@ -5434,7 +5512,7 @@ var DefaultSessionReader = class {
5434
5512
  return q.limit ? out.slice(0, q.limit) : out;
5435
5513
  }
5436
5514
  async *replay(sessionId) {
5437
- const data = await this.store.load(sessionId);
5515
+ const data = await this.loadCachedSessionData(sessionId);
5438
5516
  for (const e of data.events) yield e;
5439
5517
  }
5440
5518
  async search(q, sessionId, sessionQuery) {
@@ -5445,24 +5523,66 @@ var DefaultSessionReader = class {
5445
5523
  if (sessionId) {
5446
5524
  ids = [sessionId];
5447
5525
  } else {
5448
- const sessions = await this.store.list(1e3);
5449
- const titleNeedle = sessionQuery?.titleContains?.toLowerCase();
5450
- const filtered = sessions.filter((s) => {
5451
- if (sessionQuery?.since && s.startedAt < sessionQuery.since) return false;
5452
- if (sessionQuery?.until && s.startedAt > sessionQuery.until) return false;
5453
- if (sessionQuery?.provider && s.provider !== sessionQuery.provider) return false;
5454
- if (sessionQuery?.model && s.model !== sessionQuery.model) return false;
5455
- if (sessionQuery?.minTokens !== void 0 && s.tokenTotal < sessionQuery.minTokens) return false;
5456
- if (titleNeedle && !s.title.toLowerCase().includes(titleNeedle)) return false;
5457
- return true;
5458
- });
5459
- ids = filtered.map((s) => s.id);
5526
+ const storeWithFilter = this.store;
5527
+ let sessions;
5528
+ if (typeof storeWithFilter.listFiltered === "function") {
5529
+ sessions = await storeWithFilter.listFiltered({
5530
+ since: sessionQuery?.since,
5531
+ until: sessionQuery?.until,
5532
+ provider: sessionQuery?.provider,
5533
+ model: sessionQuery?.model,
5534
+ minTokens: sessionQuery?.minTokens,
5535
+ titleContains: sessionQuery?.titleContains,
5536
+ limit: 1e3
5537
+ });
5538
+ } else {
5539
+ sessions = await this.store.list(1e3);
5540
+ const titleNeedle = sessionQuery?.titleContains?.toLowerCase();
5541
+ sessions = sessions.filter((s) => {
5542
+ if (sessionQuery?.since && s.startedAt < sessionQuery.since) return false;
5543
+ if (sessionQuery?.until && s.startedAt > sessionQuery.until) return false;
5544
+ if (sessionQuery?.provider && s.provider !== sessionQuery.provider) return false;
5545
+ if (sessionQuery?.model && s.model !== sessionQuery.model) return false;
5546
+ if (sessionQuery?.minTokens !== void 0 && s.tokenTotal < sessionQuery.minTokens) return false;
5547
+ if (titleNeedle && !s.title.toLowerCase().includes(titleNeedle)) return false;
5548
+ return true;
5549
+ });
5550
+ }
5551
+ ids = sessions.map((s) => s.id);
5460
5552
  }
5461
5553
  const hits = [];
5554
+ const streaming = this.store.searchEvents?.bind(this.store);
5555
+ if (streaming) {
5556
+ for (const id of ids) {
5557
+ const matched = await streaming(
5558
+ id,
5559
+ (ev) => {
5560
+ if (allowedTypes && !allowedTypes.has(ev.type)) return false;
5561
+ const text = eventText(ev);
5562
+ if (text === null) return false;
5563
+ return matcher(text) !== null;
5564
+ },
5565
+ { limit: limit - hits.length }
5566
+ );
5567
+ for (const m of matched) {
5568
+ const text = expectDefined(eventText(m.event));
5569
+ const hit = expectDefined(matcher(text));
5570
+ hits.push({
5571
+ sessionId: id,
5572
+ eventIndex: m.eventIndex,
5573
+ ts: m.ts,
5574
+ type: m.event.type,
5575
+ snippet: snippetOf(text, hit.start, hit.end)
5576
+ });
5577
+ if (hits.length >= limit) return hits;
5578
+ }
5579
+ }
5580
+ return hits;
5581
+ }
5462
5582
  for (const id of ids) {
5463
5583
  let data;
5464
5584
  try {
5465
- data = await this.store.load(id);
5585
+ data = await this.loadCachedSessionData(id);
5466
5586
  } catch {
5467
5587
  continue;
5468
5588
  }
@@ -5486,7 +5606,7 @@ var DefaultSessionReader = class {
5486
5606
  return hits;
5487
5607
  }
5488
5608
  async export(sessionId, opts) {
5489
- const data = await this.store.load(sessionId);
5609
+ const data = await this.loadCachedSessionData(sessionId);
5490
5610
  const includeTools = opts.includeTools ?? true;
5491
5611
  const includeDiagnostics = opts.includeDiagnostics ?? true;
5492
5612
  const filtered = data.events.filter((e) => {
@@ -5507,7 +5627,7 @@ var DefaultSessionReader = class {
5507
5627
  return renderMarkdown(data.metadata, filtered);
5508
5628
  }
5509
5629
  async metadata(sessionId) {
5510
- const data = await this.store.load(sessionId);
5630
+ const data = await this.loadCachedSessionData(sessionId);
5511
5631
  return data.metadata;
5512
5632
  }
5513
5633
  };