zidane 6.3.8 → 6.3.9

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 (78) hide show
  1. package/dist/acp-cli.js +2 -2
  2. package/dist/{acp-CAX3tOEY.js → acp-dthcOo20.js} +3 -3
  3. package/dist/{acp-CAX3tOEY.js.map → acp-dthcOo20.js.map} +1 -1
  4. package/dist/acp.d.ts +1 -1
  5. package/dist/acp.js +1 -1
  6. package/dist/{agent-Emjeo5Ad.js → agent-XcXGROHb.js} +38 -18
  7. package/dist/agent-XcXGROHb.js.map +1 -0
  8. package/dist/agent.d.ts +1 -1
  9. package/dist/agent.js +2 -2
  10. package/dist/chat/pure.d.ts +3 -3
  11. package/dist/chat.d.ts +4 -4
  12. package/dist/chat.js +2 -2
  13. package/dist/{context-transport-3b0qpM2m.js → context-transport-DIVijS-Z.js} +3 -3
  14. package/dist/{context-transport-3b0qpM2m.js.map → context-transport-DIVijS-Z.js.map} +1 -1
  15. package/dist/contexts/daytona.d.ts +1 -1
  16. package/dist/contexts/e2b.d.ts +1 -1
  17. package/dist/eval.d.ts +1 -1
  18. package/dist/extensions.d.ts +1 -1
  19. package/dist/extensions.js +1 -1
  20. package/dist/headless.d.ts +1 -1
  21. package/dist/headless.js +1 -1
  22. package/dist/{index-DWXLcGB_.d.ts → index-DEqQQ8tN.d.ts} +30 -6
  23. package/dist/index-DEqQQ8tN.d.ts.map +1 -0
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +4 -4
  26. package/dist/{login-Cvx1nSVm.js → login-COaVj9kG.js} +2 -2
  27. package/dist/{login-Cvx1nSVm.js.map → login-COaVj9kG.js.map} +1 -1
  28. package/dist/{mcp-8bEHU4WB.js → mcp-CzUy5luo.js} +3 -3
  29. package/dist/{mcp-8bEHU4WB.js.map → mcp-CzUy5luo.js.map} +1 -1
  30. package/dist/mcp.d.ts +1 -1
  31. package/dist/mcp.js +1 -1
  32. package/dist/output/stream-json.d.ts +1 -1
  33. package/dist/output/terminal.d.ts +1 -1
  34. package/dist/presets.d.ts +1 -1
  35. package/dist/presets.js +1 -1
  36. package/dist/providers/anthropic.d.ts +1 -1
  37. package/dist/providers/arcee.d.ts +1 -1
  38. package/dist/providers/baseten.d.ts +1 -1
  39. package/dist/providers/cerebras.d.ts +1 -1
  40. package/dist/providers/local.d.ts +1 -1
  41. package/dist/providers/openai-compat.d.ts +1 -1
  42. package/dist/providers/openai.d.ts +1 -1
  43. package/dist/providers/openrouter.d.ts +1 -1
  44. package/dist/providers/xai.d.ts +1 -1
  45. package/dist/providers.d.ts +1 -1
  46. package/dist/{read-state-CNyeMG7W.js → read-state-Dt7UbVsd.js} +26 -2
  47. package/dist/read-state-Dt7UbVsd.js.map +1 -0
  48. package/dist/restate.d.ts +1 -1
  49. package/dist/restate.js +1 -1
  50. package/dist/session/sqlite.d.ts +1 -1
  51. package/dist/session.d.ts +1 -1
  52. package/dist/skills.d.ts +1 -1
  53. package/dist/{stdio-BKFpPNvX.js → stdio-D7Nf908h.js} +2 -2
  54. package/dist/{stdio-BKFpPNvX.js.map → stdio-D7Nf908h.js.map} +1 -1
  55. package/dist/{stdio-loader-DFDpBwwI.js → stdio-loader-C3ydQZyZ.js} +2 -2
  56. package/dist/{stdio-loader-DFDpBwwI.js.map → stdio-loader-C3ydQZyZ.js.map} +1 -1
  57. package/dist/{tool-formatters-Co5gl_7R.d.ts → tool-formatters-B0y_dlZ-.d.ts} +2 -2
  58. package/dist/{tool-formatters-Co5gl_7R.d.ts.map → tool-formatters-B0y_dlZ-.d.ts.map} +1 -1
  59. package/dist/tools/fetch-url.d.ts +1 -1
  60. package/dist/tools/web-search.d.ts +1 -1
  61. package/dist/tools.d.ts +1 -1
  62. package/dist/tools.js +2 -2
  63. package/dist/{transcript-anchors-DBPJr5Ks.d.ts → transcript-anchors-B93mTVIi.d.ts} +2 -2
  64. package/dist/{transcript-anchors-DBPJr5Ks.d.ts.map → transcript-anchors-B93mTVIi.d.ts.map} +1 -1
  65. package/dist/{transcript-anchors-DhBTqTyc.js → transcript-anchors-BeCn35OE.js} +3 -3
  66. package/dist/{transcript-anchors-DhBTqTyc.js.map → transcript-anchors-BeCn35OE.js.map} +1 -1
  67. package/dist/tui.d.ts +3 -3
  68. package/dist/tui.js +4 -4
  69. package/dist/{turn-operations-DokFalMC.d.ts → turn-operations-B-t6VR01.d.ts} +3 -3
  70. package/dist/{turn-operations-DokFalMC.d.ts.map → turn-operations-B-t6VR01.d.ts.map} +1 -1
  71. package/dist/types-BIarq1qE.js.map +1 -1
  72. package/dist/types.d.ts +1 -1
  73. package/docs/ARCHITECTURE.md +1 -1
  74. package/docs/CHAT.md +1 -1
  75. package/package.json +1 -1
  76. package/dist/agent-Emjeo5Ad.js.map +0 -1
  77. package/dist/index-DWXLcGB_.d.ts.map +0 -1
  78. package/dist/read-state-CNyeMG7W.js.map +0 -1
package/dist/mcp.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $p as McpToolSchema, Zp as McpServerConfig, ag as McpExecutionBinding, cg as createStderrLineEmitter, dg as expandMcpConfigEnv, fg as nonOwningMcpView, gg as wrapDiscoveredMcpTools, hg as resultToString, ig as McpConnection, lg as deriveMcpToolMeta, mg as normalizeMcpServers, og as attachStderrWarnPump, pg as normalizeMcpBlocks, rg as ConnectMcpServersOptions, sg as connectMcpServers, ug as expandEnvPlaceholders } from "./index-DWXLcGB_.js";
1
+ import { $p as McpToolSchema, Zp as McpServerConfig, ag as McpExecutionBinding, cg as createStderrLineEmitter, dg as expandMcpConfigEnv, fg as nonOwningMcpView, gg as wrapDiscoveredMcpTools, hg as resultToString, ig as McpConnection, lg as deriveMcpToolMeta, mg as normalizeMcpServers, og as attachStderrWarnPump, pg as normalizeMcpBlocks, rg as ConnectMcpServersOptions, sg as connectMcpServers, ug as expandEnvPlaceholders } from "./index-DEqQQ8tN.js";
2
2
  export { ConnectMcpServersOptions, McpConnection, McpExecutionBinding, type McpServerConfig, type McpToolSchema, attachStderrWarnPump, connectMcpServers, createStderrLineEmitter, deriveMcpToolMeta, expandEnvPlaceholders, expandMcpConfigEnv, nonOwningMcpView, normalizeMcpBlocks, normalizeMcpServers, resultToString, wrapDiscoveredMcpTools };
package/dist/mcp.js CHANGED
@@ -1,2 +1,2 @@
1
- import { a as expandEnvPlaceholders, c as normalizeMcpBlocks, d as wrapDiscoveredMcpTools, i as deriveMcpToolMeta, l as normalizeMcpServers, n as connectMcpServers, o as expandMcpConfigEnv, r as createStderrLineEmitter, s as nonOwningMcpView, t as attachStderrWarnPump, u as resultToString } from "./mcp-8bEHU4WB.js";
1
+ import { a as expandEnvPlaceholders, c as normalizeMcpBlocks, d as wrapDiscoveredMcpTools, i as deriveMcpToolMeta, l as normalizeMcpServers, n as connectMcpServers, o as expandMcpConfigEnv, r as createStderrLineEmitter, s as nonOwningMcpView, t as attachStderrWarnPump, u as resultToString } from "./mcp-CzUy5luo.js";
2
2
  export { attachStderrWarnPump, connectMcpServers, createStderrLineEmitter, deriveMcpToolMeta, expandEnvPlaceholders, expandMcpConfigEnv, nonOwningMcpView, normalizeMcpBlocks, normalizeMcpServers, resultToString, wrapDiscoveredMcpTools };
@@ -1,4 +1,4 @@
1
- import { $n as HeadlessResult, Jn as FormattedHeadlessTurnEvent, Qn as HeadlessOutputFormat, Wi as Agent, Xn as HeadlessEvent, qn as FormattedHeadlessResult } from "../index-DWXLcGB_.js";
1
+ import { $n as HeadlessResult, Jn as FormattedHeadlessTurnEvent, Qn as HeadlessOutputFormat, Wi as Agent, Xn as HeadlessEvent, qn as FormattedHeadlessResult } from "../index-DEqQQ8tN.js";
2
2
 
3
3
  //#region src/output/stream-json.d.ts
4
4
  type StreamJsonOutputFormat = HeadlessOutputFormat;
@@ -1,4 +1,4 @@
1
- import { Ki as AgentHooks, Wi as Agent, t as Preset } from "../index-DWXLcGB_.js";
1
+ import { Ki as AgentHooks, Wi as Agent, t as Preset } from "../index-DEqQQ8tN.js";
2
2
 
3
3
  //#region src/output/terminal.d.ts
4
4
  interface TerminalOutputOptions {
package/dist/presets.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Gi as AgentHookMap, a as basicTools, i as _default, n as composePresets, r as definePreset, t as Preset } from "./index-DWXLcGB_.js";
1
+ import { Gi as AgentHookMap, a as basicTools, i as _default, n as composePresets, r as definePreset, t as Preset } from "./index-DEqQQ8tN.js";
2
2
  export { type AgentHookMap, Preset, _default as basic, basicTools, composePresets, definePreset };
package/dist/presets.js CHANGED
@@ -1,2 +1,2 @@
1
- import { ft as composePresets, ht as basic_default, mt as basicTools, pt as definePreset } from "./agent-Emjeo5Ad.js";
1
+ import { ft as composePresets, ht as basic_default, mt as basicTools, pt as definePreset } from "./agent-XcXGROHb.js";
2
2
  export { basic_default as basic, basicTools, composePresets, definePreset };
@@ -1,2 +1,2 @@
1
- import { _p as resolveAnthropicBetas, ap as AnthropicContextManagement, cp as EXTENDED_CACHE_TTL_BETA, dp as buildAnthropicClientOptions, fp as classifyAnthropicError, gp as resolveAnthropicAuthShape, hp as planAnthropicThinking, lp as anthropic, mp as defaultAnthropicMaxTokens, op as AnthropicParams, pp as credentialIdentity, sp as AnthropicThinkingPlan, up as applyAnthropicCacheBreakpoints, vp as resolveAnthropicMaxOutput } from "../index-DWXLcGB_.js";
1
+ import { _p as resolveAnthropicBetas, ap as AnthropicContextManagement, cp as EXTENDED_CACHE_TTL_BETA, dp as buildAnthropicClientOptions, fp as classifyAnthropicError, gp as resolveAnthropicAuthShape, hp as planAnthropicThinking, lp as anthropic, mp as defaultAnthropicMaxTokens, op as AnthropicParams, pp as credentialIdentity, sp as AnthropicThinkingPlan, up as applyAnthropicCacheBreakpoints, vp as resolveAnthropicMaxOutput } from "../index-DEqQQ8tN.js";
2
2
  export { AnthropicContextManagement, AnthropicParams, AnthropicThinkingPlan, EXTENDED_CACHE_TTL_BETA, anthropic, applyAnthropicCacheBreakpoints, buildAnthropicClientOptions, classifyAnthropicError, credentialIdentity, defaultAnthropicMaxTokens, planAnthropicThinking, resolveAnthropicAuthShape, resolveAnthropicBetas, resolveAnthropicMaxOutput };
@@ -1,2 +1,2 @@
1
- import { ip as arcee, rp as ArceeParams } from "../index-DWXLcGB_.js";
1
+ import { ip as arcee, rp as ArceeParams } from "../index-DEqQQ8tN.js";
2
2
  export { ArceeParams, arcee };
@@ -1,2 +1,2 @@
1
- import { ep as BasetenParams, np as planBasetenReasoning, tp as baseten } from "../index-DWXLcGB_.js";
1
+ import { ep as BasetenParams, np as planBasetenReasoning, tp as baseten } from "../index-DEqQQ8tN.js";
2
2
  export { BasetenParams, baseten, planBasetenReasoning };
@@ -1,2 +1,2 @@
1
- import { $f as cerebras, Qf as CerebrasParams } from "../index-DWXLcGB_.js";
1
+ import { $f as cerebras, Qf as CerebrasParams } from "../index-DEqQQ8tN.js";
2
2
  export { CerebrasParams, cerebras };
@@ -1,2 +1,2 @@
1
- import { Jf as LocalParams, Yf as local } from "../index-DWXLcGB_.js";
1
+ import { Jf as LocalParams, Yf as local } from "../index-DEqQQ8tN.js";
2
2
  export { LocalParams, local };
@@ -1,2 +1,2 @@
1
- import { Af as applyOAICacheBreakpoints, Bf as toOAIMessages, Cf as OAIMessage, Df as OpenAICompatParams, Ef as OpenAICompatHttpError, Ff as consumeSSE, Hf as userMessage, If as formatTools, Lf as mapOAIFinishReason, Mf as assistantMessage, Nf as buildAssistantContent, Of as OpenAICompatStreamError, Pf as classifyOpenAICompatError, Rf as openAICompatPromptMessage, Sf as ASSISTANT_TOOL_CALLS_TAG, Tf as OpenAICompatAuthHeader, Vf as toolResultsMessage, jf as applyOAIToolCacheBreakpoint, kf as TOOL_RESULTS_TAG, wf as OAITool, zf as openaiCompat } from "../index-DWXLcGB_.js";
1
+ import { Af as applyOAICacheBreakpoints, Bf as toOAIMessages, Cf as OAIMessage, Df as OpenAICompatParams, Ef as OpenAICompatHttpError, Ff as consumeSSE, Hf as userMessage, If as formatTools, Lf as mapOAIFinishReason, Mf as assistantMessage, Nf as buildAssistantContent, Of as OpenAICompatStreamError, Pf as classifyOpenAICompatError, Rf as openAICompatPromptMessage, Sf as ASSISTANT_TOOL_CALLS_TAG, Tf as OpenAICompatAuthHeader, Vf as toolResultsMessage, jf as applyOAIToolCacheBreakpoint, kf as TOOL_RESULTS_TAG, wf as OAITool, zf as openaiCompat } from "../index-DEqQQ8tN.js";
2
2
  export { ASSISTANT_TOOL_CALLS_TAG, OAIMessage, OAITool, OpenAICompatAuthHeader, OpenAICompatHttpError, OpenAICompatParams, OpenAICompatStreamError, TOOL_RESULTS_TAG, applyOAICacheBreakpoints, applyOAIToolCacheBreakpoint, assistantMessage, buildAssistantContent, classifyOpenAICompatError, consumeSSE, formatTools, mapOAIFinishReason, openAICompatPromptMessage, openaiCompat, toOAIMessages, toolResultsMessage, userMessage };
@@ -1,2 +1,2 @@
1
- import { Gf as mapCodexStopReason, Kf as openai, Uf as OpenAIParams, Wf as classifyOpenAIError, qf as toPiMessages } from "../index-DWXLcGB_.js";
1
+ import { Gf as mapCodexStopReason, Kf as openai, Uf as OpenAIParams, Wf as classifyOpenAIError, qf as toPiMessages } from "../index-DEqQQ8tN.js";
2
2
  export { OpenAIParams, classifyOpenAIError, mapCodexStopReason, openai, toPiMessages };
@@ -1,2 +1,2 @@
1
- import { bf as normalizeOpenRouterModelId, xf as openrouter, yf as OpenRouterParams } from "../index-DWXLcGB_.js";
1
+ import { bf as normalizeOpenRouterModelId, xf as openrouter, yf as OpenRouterParams } from "../index-DEqQQ8tN.js";
2
2
  export { OpenRouterParams, normalizeOpenRouterModelId, openrouter };
@@ -1,2 +1,2 @@
1
- import { ff as XaiParams, pf as xai } from "../index-DWXLcGB_.js";
1
+ import { ff as XaiParams, pf as xai } from "../index-DEqQQ8tN.js";
2
2
  export { XaiParams, xai };
@@ -1,2 +1,2 @@
1
- import { $f as cerebras, Ap as registerCustomOAuthProvider, Cp as OAuthParams, Df as OpenAICompatParams, Dp as extractRuntimeCredentials, Ef as OpenAICompatHttpError, Ep as credentialsFromParams, Jf as LocalParams, Kf as openai, Lf as mapOAIFinishReason, Mp as writeOAuthCredentials, Np as OAuthProviderInterface, Op as isOAuthAccessToken, Pf as classifyOpenAICompatError, Qf as CerebrasParams, Sp as resolvePromptCacheKey, Tf as OpenAICompatAuthHeader, Tp as credentialsFilePath, Uf as OpenAIParams, Xf as CursorParams, Yf as local, Zf as cursor, _f as sanitizeToolSchema, af as StreamCallbacks, bp as PromptCacheKeyOption, cf as ToolCall, df as TurnResult, ep as BasetenParams, ff as XaiParams, gf as SchemaSanitizeResult, hf as SchemaSanitizeProfile, if as ProviderCapabilities, ip as arcee, jp as resolveOAuthApiKey, kp as readOAuthCredentials, lf as ToolResult, lp as anthropic, mf as SchemaSanitizeOptions, nf as HistoryRepair, np as planBasetenReasoning, of as StreamOptions, op as AnthropicParams, pf as xai, rf as Provider, rp as ArceeParams, sf as TokenCountPayload, tp as baseten, uf as ToolSpec, up as applyAnthropicCacheBreakpoints, vf as sanitizeToolSpecs, wp as ResolveOAuthApiKeyOptions, xf as openrouter, xp as derivePromptCacheKey, yf as OpenRouterParams, yp as PromptCacheKeyContext, zf as openaiCompat } from "./index-DWXLcGB_.js";
1
+ import { $f as cerebras, Ap as registerCustomOAuthProvider, Cp as OAuthParams, Df as OpenAICompatParams, Dp as extractRuntimeCredentials, Ef as OpenAICompatHttpError, Ep as credentialsFromParams, Jf as LocalParams, Kf as openai, Lf as mapOAIFinishReason, Mp as writeOAuthCredentials, Np as OAuthProviderInterface, Op as isOAuthAccessToken, Pf as classifyOpenAICompatError, Qf as CerebrasParams, Sp as resolvePromptCacheKey, Tf as OpenAICompatAuthHeader, Tp as credentialsFilePath, Uf as OpenAIParams, Xf as CursorParams, Yf as local, Zf as cursor, _f as sanitizeToolSchema, af as StreamCallbacks, bp as PromptCacheKeyOption, cf as ToolCall, df as TurnResult, ep as BasetenParams, ff as XaiParams, gf as SchemaSanitizeResult, hf as SchemaSanitizeProfile, if as ProviderCapabilities, ip as arcee, jp as resolveOAuthApiKey, kp as readOAuthCredentials, lf as ToolResult, lp as anthropic, mf as SchemaSanitizeOptions, nf as HistoryRepair, np as planBasetenReasoning, of as StreamOptions, op as AnthropicParams, pf as xai, rf as Provider, rp as ArceeParams, sf as TokenCountPayload, tp as baseten, uf as ToolSpec, up as applyAnthropicCacheBreakpoints, vf as sanitizeToolSpecs, wp as ResolveOAuthApiKeyOptions, xf as openrouter, xp as derivePromptCacheKey, yf as OpenRouterParams, yp as PromptCacheKeyContext, zf as openaiCompat } from "./index-DEqQQ8tN.js";
2
2
  export { type AnthropicParams, type ArceeParams, type BasetenParams, type CerebrasParams, type CursorParams, HistoryRepair, type LocalParams, type OAuthParams, type OAuthProviderInterface, type OpenAICompatAuthHeader, OpenAICompatHttpError, type OpenAICompatParams, type OpenAIParams, type OpenRouterParams, type PromptCacheKeyContext, type PromptCacheKeyOption, Provider, ProviderCapabilities, type ResolveOAuthApiKeyOptions, type SchemaSanitizeOptions, type SchemaSanitizeProfile, type SchemaSanitizeResult, StreamCallbacks, StreamOptions, TokenCountPayload, ToolCall, ToolResult, ToolSpec, TurnResult, type XaiParams, anthropic, applyAnthropicCacheBreakpoints, arcee, baseten, cerebras, classifyOpenAICompatError, credentialsFilePath, credentialsFromParams, cursor, derivePromptCacheKey, extractRuntimeCredentials, isOAuthAccessToken, local, mapOAIFinishReason, openai, openaiCompat, openrouter, planBasetenReasoning, readOAuthCredentials, registerCustomOAuthProvider, resolveOAuthApiKey, resolvePromptCacheKey, sanitizeToolSchema, sanitizeToolSpecs, writeOAuthCredentials, xai };
@@ -61,6 +61,30 @@ function markReadStateElided(ctx, cwd, path) {
61
61
  }
62
62
  }
63
63
  /**
64
+ * Record one `requireReadBeforeEdit` drift refusal against `entry` and
65
+ * return the consecutive count (1 for the first). The caller composes the
66
+ * refusal message with {@link staleRefusalHint}.
67
+ */
68
+ function noteStaleRejection(map, key, entry) {
69
+ const count = (entry.staleRejections ?? 0) + 1;
70
+ map.set(key, {
71
+ ...entry,
72
+ staleRejections: count
73
+ });
74
+ return count;
75
+ }
76
+ /**
77
+ * Escalating suffix for a drift refusal. Empty on the first refusal — the
78
+ * base "re-read the file" advice is correct and sufficient. From the second
79
+ * consecutive refusal on, the model has demonstrably re-read and been
80
+ * refused again, so repeating the same advice reads as a broken tool;
81
+ * name the real hypothesis (an external writer) instead.
82
+ */
83
+ function staleRefusalHint(count) {
84
+ if (count < 2) return "";
85
+ return ` This is refusal #${count} since your last read — a process outside this session (editor auto-save, formatter, codegen watcher) may be rewriting the file between your reads.`;
86
+ }
87
+ /**
64
88
  * Canonical read-state key for a `(cwd, path)` pair.
65
89
  *
66
90
  * `ctx.execution.readFile(handle, path)` resolves the model-provided
@@ -408,6 +432,6 @@ function getToolDedupState(session) {
408
432
  return map;
409
433
  }
410
434
  //#endregion
411
- export { hydrateReadStateFromSessionAsync as a, resolveReadStateMap as c, hydrateReadStateFromSession as i, getToolDedupState as n, markReadStateElided as o, hashContent as r, readStateKey as s, getReadState as t };
435
+ export { hydrateReadStateFromSessionAsync as a, readStateKey as c, hydrateReadStateFromSession as i, resolveReadStateMap as l, getToolDedupState as n, markReadStateElided as o, hashContent as r, noteStaleRejection as s, getReadState as t, staleRefusalHint as u };
412
436
 
413
- //# sourceMappingURL=read-state-CNyeMG7W.js.map
437
+ //# sourceMappingURL=read-state-Dt7UbVsd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"read-state-Dt7UbVsd.js","names":[],"sources":["../src/tools/read-state.ts"],"sourcesContent":["/**\n * Per-session file read tracking + tool-dedup state.\n *\n * Two concerns, one module so they can share the `WeakMap<Session, …>`\n * pattern (state lives as long as the session does, GC'd alongside it —\n * no public schema changes, no persistence). Each section below stands\n * on its own; the two maps don't share keys or behavior.\n *\n * ## Read-state\n *\n * Shared between `read_file` (dedup re-reads) and `edit` / `multi_edit`\n * (`requireReadBeforeEdit` guard). The state map records, per canonical\n * absolute file path:\n *\n * - `contentHash` — 64-bit FNV-style hash of the bytes the model last saw. Identical\n * re-reads return a stub; edits compare against this hash to detect\n * stale content.\n * - `(offset, limit, maxBytes, lineNumbers)` — slice / shape of the last\n * read, so a wider re-read invalidates the prior stub and a different\n * `lineNumbers` mode doesn't dedup against the previous shape.\n * - `mtimeMs` — wall-clock at last read, diagnostic only.\n *\n * Resolution is split between two helpers so consumers don't have to\n * juggle the `Session` vs. explicit-map cases themselves:\n *\n * - {@link getReadState} returns the map keyed by `Session` instance.\n * - {@link resolveReadStateMap} prefers an explicit `ctx.readState`\n * (the path `spawn`'s `shareReadState` uses to forward the parent's\n * map into a sessionless child) and falls back to the session-keyed\n * lookup. Tools should call this helper, not `getReadState` directly.\n *\n * ## Tool-dedup\n *\n * Backs `behavior.dedupTools`. Records the most recent `(hash, result)`\n * per canonical tool name within a session. Same WeakMap pattern; no\n * cross-talk with the read-state map.\n */\n\nimport type { AliasMaps } from '../aliasing'\nimport type { Session } from '../session'\nimport type { SessionTurn, ToolResultContent } from '../types'\nimport { resolve } from 'node:path'\nimport { toCanonicalName } from '../aliasing'\nimport { toolResultToText } from '../types'\nimport { resolveOldString, styleReplacementForVia } from './edit-utils'\n\n// ---------------------------------------------------------------------------\n// Read-state\n// ---------------------------------------------------------------------------\n\nexport interface ReadStateEntry {\n contentHash: string\n /** Slice parameters for the last read. */\n offset: number\n limit: number\n maxBytes: number\n /**\n * Whether the prior read emitted line-number prefixes. Tracked so a\n * read with `lineNumbers: true` doesn't dedup against one with\n * `lineNumbers: false` (or vice versa) — the dedup stub would mislead\n * the model about the prior output's shape.\n */\n lineNumbers?: boolean\n /** Wall-clock at last read — diagnostic only, not used for invalidation. */\n mtimeMs: number\n /**\n * Consecutive `requireReadBeforeEdit` drift refusals on this file since\n * the last fresh read. Fuel for {@link staleRefusalHint}: one refusal is\n * routine (the model edited after an out-of-band mutation and just needs\n * to re-read), but repeated refusals mean re-reading isn't fixing it —\n * something OUTSIDE the session (editor auto-save, formatter, codegen\n * watcher) keeps rewriting the file, and the error message must say so\n * instead of repeating advice the model already followed. That repetition\n * is exactly what teaches models to abandon `edit` for raw shell writes\n * that bypass every guard.\n *\n * Cleared by any fresh read (`rememberRead` writes a flag-less entry) and\n * by any successful edit (the mutation-site refresh drops it).\n */\n staleRejections?: number\n /**\n * Set when the on-wire read output this entry tracks can no longer be\n * trusted as-is, so `read_file`'s dedup must MISS on the next identical\n * re-read — the \"unchanged since the previous read\" stub would otherwise\n * point at content the model can no longer see, or that is no longer true.\n *\n * Two writers:\n * - the wire transforms (stale-read elision, tail compaction), which REMOVE\n * the output from the on-wire history;\n * - the mutating tools (`edit` / `multi_edit` / `write_file`), which refresh\n * `contentHash` to the post-mutation bytes — without the flag that refresh\n * would make the very next re-read hash-match and dedup would claim the\n * PRE-mutation body is \"still current\". Marking at the mutation keeps\n * dedup honest in every `elideStaleReads` mode, including off.\n *\n * The entry stays registered either way — `requireReadBeforeEdit` must keep\n * passing (the contentHash still guards against disk drift; un-registering\n * here is what degraded models into shell-edit one-liner workarounds).\n * Cleared by the next fresh read (`rememberRead` writes a flag-less entry).\n */\n elided?: true\n}\n\nexport type ReadStateMap = Map<string, ReadStateEntry>\n\nconst STATE = new WeakMap<Session, ReadStateMap>()\n\n/**\n * Get or lazily create the per-session read-state map. Returns `undefined`\n * when no session is provided.\n *\n * Most tool callers should prefer {@link resolveReadStateMap}, which\n * additionally honors an explicit `ctx.readState` (the path\n * `spawn`'s `shareReadState: true` uses to forward the parent's map\n * into a sessionless child). Use this helper directly only when the\n * Session-keyed map is exactly what you want and you don't need to\n * accept an override.\n */\nexport function getReadState(session: Session | undefined): ReadStateMap | undefined {\n if (!session)\n return undefined\n let map = STATE.get(session)\n if (!map) {\n map = new Map()\n STATE.set(session, map)\n }\n return map\n}\n\n/**\n * Resolve the active read-state map from a tool context. An explicit\n * `ctx.readState` wins (used by `spawn`'s `shareReadState` opt-in to\n * forward the parent's map into a sessionless child); otherwise the\n * usual `Session`-keyed lookup applies.\n *\n * Tools should call this helper instead of `getReadState(ctx.session)`\n * directly so the `shareReadState` plumbing is honored uniformly.\n */\nexport function resolveReadStateMap(ctx: {\n session?: Session\n readState?: ReadStateMap\n}): ReadStateMap | undefined {\n return ctx.readState ?? getReadState(ctx.session)\n}\n\n/**\n * Mark a read-state entry as elided from the on-wire history WITHOUT\n * un-registering it.\n *\n * Used by the loop's `elideStaleReads` pass. The entry must survive —\n * deleting it made the `requireReadBeforeEdit` gate reject the very next\n * edit on a file the model had demonstrably read and just edited (the\n * gate's failure mode then defeats the gate: models degrade to raw shell\n * edits that bypass the guard entirely). The `elided` flag instead\n * defeats only the dedup stub: the next identical re-read returns the\n * full body again, and `rememberRead` clears the flag.\n *\n * No-op when the path has no entry in the resolved map(s).\n */\nexport function markReadStateElided(ctx: {\n session?: Session\n readState?: ReadStateMap\n}, cwd: string, path: string): void {\n const key = readStateKey(cwd, path)\n for (const map of [ctx.readState, ctx.session ? STATE.get(ctx.session) : undefined]) {\n const entry = map?.get(key)\n if (entry && entry.elided !== true)\n map!.set(key, { ...entry, elided: true })\n }\n}\n\n/**\n * Record one `requireReadBeforeEdit` drift refusal against `entry` and\n * return the consecutive count (1 for the first). The caller composes the\n * refusal message with {@link staleRefusalHint}.\n */\nexport function noteStaleRejection(map: ReadStateMap, key: string, entry: ReadStateEntry): number {\n const count = (entry.staleRejections ?? 0) + 1\n map.set(key, { ...entry, staleRejections: count })\n return count\n}\n\n/**\n * Escalating suffix for a drift refusal. Empty on the first refusal — the\n * base \"re-read the file\" advice is correct and sufficient. From the second\n * consecutive refusal on, the model has demonstrably re-read and been\n * refused again, so repeating the same advice reads as a broken tool;\n * name the real hypothesis (an external writer) instead.\n */\nexport function staleRefusalHint(count: number): string {\n if (count < 2)\n return ''\n return ` This is refusal #${count} since your last read — a process outside this session (editor auto-save, formatter, codegen watcher) may be rewriting the file between your reads.`\n}\n\n/**\n * Canonical read-state key for a `(cwd, path)` pair.\n *\n * `ctx.execution.readFile(handle, path)` resolves the model-provided\n * path against `handle.cwd` before touching disk — so `src/App.tsx`,\n * `./src/App.tsx`, and `/abs/cwd/src/App.tsx` all read the **same**\n * bytes. The read-state map MUST mirror that resolution: without it,\n * a model that reads `src/App.tsx` and then edits `./src/App.tsx`\n * trips the `requireReadBeforeEdit` gate for a file it demonstrably\n * already saw (the gate's \"has not been read in this session\" message\n * fires on a stale key).\n *\n * `node:path`'s `resolve(cwd, path)` short-circuits when `path` is\n * already absolute, so absolute and relative shapes converge on the\n * same canonical form. We don't `realpath()` symlinks — the file IS\n * the path the model addressed, not the realpath behind it; the host's\n * execution context decides how to dereference.\n */\nexport function readStateKey(cwd: string, path: string): string {\n return resolve(cwd, path)\n}\n\n/**\n * 64-bit content hash: two independent 32-bit FNV-1a-style lanes (different\n * offset bases + multipliers) concatenated as 16 hex chars. Fast,\n * non-cryptographic — but wide enough that the `requireReadBeforeEdit`\n * drift gate, which silently corrupts a file on a false \"unchanged\"\n * verdict, isn't betting on a 32-bit birthday bound (~1 in 4 billion per\n * pair; uncomfortably reachable over many files × many sessions). Entries\n * live only in per-session in-memory maps, so widening needs no\n * stored-format migration. Still cheaper than allocating a Buffer and\n * pulling in `crypto`.\n */\nexport function hashContent(text: string): string {\n let h1 = 0x811C9DC5 // FNV-1a offset basis\n let h2 = 0x7EE36237 // arbitrary distinct basis for the second lane\n for (let i = 0; i < text.length; i++) {\n const c = text.charCodeAt(i)\n h1 = Math.imul(h1 ^ c, 0x01000193) >>> 0 // FNV prime 16777619\n h2 = Math.imul(h2 ^ c, 0x85EBCA6B) >>> 0 // murmur3 fmix multiplier\n }\n return h1.toString(16).padStart(8, '0') + h2.toString(16).padStart(8, '0')\n}\n\nexport interface HydrateReadStateOptions {\n /** Canonical read-file tool name. Defaults to `read_file`. */\n readFileToolName?: string\n /** Canonical write-file tool name. Defaults to `write_file`. */\n writeFileToolName?: string\n /** Canonical edit tool name. Defaults to `edit`. */\n editToolName?: string\n /** Canonical multi-edit tool name. Defaults to `multi_edit`. */\n multiEditToolName?: string\n /** Agent-level default for omitted `read_file.lineNumbers`. */\n defaultLineNumbers?: boolean\n /**\n * Optional replay-only fallback for read_file results whose transcript output\n * is partial/truncated. Receives the model-provided path and should return\n * the current full text bytes to hash exactly like live read_file.\n */\n readFileForHash?: (path: string) => Promise<string | null | undefined>\n /**\n * Tool-name aliases in effect for the transcript being replayed. zidane's\n * loop canonicalizes tool-call names before persisting, so durable turns\n * normally already carry canonical names — but a transcript captured from a\n * host that persists WIRE names (the aliased form the model saw, e.g.\n * `Read` / `Edit`), or one imported from another stack, would otherwise be\n * unrecognized and hydrate nothing. When provided, each tool-call name is\n * resolved to canonical (`toCanonicalName`) before matching, so both the\n * canonical and the aliased shape are honored. No-op for already-canonical\n * names.\n */\n aliasMaps?: AliasMaps\n}\n\ntype NormalizedHydrateReadStateOptions = Required<Omit<HydrateReadStateOptions, 'readFileForHash' | 'aliasMaps'>> & {\n readFileForHash?: HydrateReadStateOptions['readFileForHash']\n aliasMaps?: AliasMaps\n}\n\ninterface PendingToolCall {\n name: string\n input: Record<string, unknown>\n}\n\ninterface KnownFile {\n content: string\n entry: ReadStateEntry\n}\n\nconst READ_FILE_DEFAULT_OFFSET = 1\nconst READ_FILE_DEFAULT_LIMIT = 2000\nconst READ_FILE_DEFAULT_MAX_BYTES = 262_144\nconst READ_FILE_FOOTER_RE = /\\n\\n…(?:read lines|truncated)/\nconst READ_FILE_LINE_RE = /^\\d{1,9}\\t(.*)$/\n\n/**\n * Rebuild the per-session read-state map from durable session turns.\n *\n * Durable replay runtimes may return recorded tool results without re-running\n * the tool body, so in-memory side effects like `readState.set(...)` can be\n * missing even though the transcript contains the successful `read_file`.\n * This helper is intentionally opt-in: live hosts keep the normal side-effect\n * behavior unless they call it themselves.\n *\n * Hydration only fills missing keys. Live in-memory state may already reflect a\n * newer read or edit from the current run, and durable history cannot prove it\n * is fresher. Relative paths are resolved against the current execution cwd,\n * matching replay hosts that run sessions from a stable workspace.\n */\nexport function hydrateReadStateFromSession(\n session: Session | undefined,\n cwd: string,\n options: HydrateReadStateOptions = {},\n): number {\n if (!session)\n return 0\n\n const readState = getReadState(session)\n if (!readState)\n return 0\n\n const normalized = normalizeHydrateReadStateOptions(options)\n const pending = new Map<string, PendingToolCall>()\n const known = new Map<string, KnownFile>()\n const preexistingKeys = new Set(readState.keys())\n let hydrated = 0\n\n for (const turn of session.turns) {\n for (const block of turn.content) {\n if (block.type === 'tool_call') {\n // Resolve wire aliases (e.g. `Read`/`Edit`) to canonical before\n // matching, and STORE the canonical name in `pending` so the\n // downstream `stateFromToolResult` dispatch (which keys off the\n // canonical tool-name options) lines up regardless of how the\n // transcript spelled the call.\n const canonicalName = canonicalToolCallName(block.name, normalized)\n if (\n canonicalName === normalized.readFileToolName\n || canonicalName === normalized.writeFileToolName\n || canonicalName === normalized.editToolName\n || canonicalName === normalized.multiEditToolName\n ) {\n pending.set(block.id, { name: canonicalName, input: block.input })\n }\n continue\n }\n\n if (block.type !== 'tool_result')\n continue\n\n const call = pending.get(block.callId)\n if (!call)\n continue\n pending.delete(block.callId)\n if (block.isError === true)\n continue\n\n const output = toolResultToText(block.output)\n const next = stateFromToolResult(call, output, turn, cwd, normalized, known)\n if (!next)\n continue\n\n if (!preexistingKeys.has(next.key)) {\n readState.set(next.key, next.file.entry)\n hydrated += 1\n }\n known.set(next.key, next.file)\n }\n }\n\n return hydrated\n}\n\n/**\n * Async replay hydrator for durable hosts that can cheaply read the current\n * full file through their execution context. Transcript-only reconstruction is\n * still preferred for full reads; partial/truncated read_file entries fall back\n * to `readFileForHash` and hash those full current bytes.\n */\nexport async function hydrateReadStateFromSessionAsync(\n session: Session | undefined,\n cwd: string,\n options: HydrateReadStateOptions = {},\n): Promise<number> {\n if (!session)\n return 0\n\n const readState = getReadState(session)\n if (!readState)\n return 0\n\n const normalized = normalizeHydrateReadStateOptions(options)\n const pending = new Map<string, PendingToolCall>()\n const known = new Map<string, KnownFile>()\n const preexistingKeys = new Set(readState.keys())\n let hydrated = 0\n\n for (const turn of session.turns) {\n for (const block of turn.content) {\n if (block.type === 'tool_call') {\n // Resolve wire aliases (e.g. `Read`/`Edit`) to canonical before\n // matching, and STORE the canonical name in `pending` so the\n // downstream `stateFromToolResult` dispatch (which keys off the\n // canonical tool-name options) lines up regardless of how the\n // transcript spelled the call.\n const canonicalName = canonicalToolCallName(block.name, normalized)\n if (\n canonicalName === normalized.readFileToolName\n || canonicalName === normalized.writeFileToolName\n || canonicalName === normalized.editToolName\n || canonicalName === normalized.multiEditToolName\n ) {\n pending.set(block.id, { name: canonicalName, input: block.input })\n }\n continue\n }\n\n if (block.type !== 'tool_result')\n continue\n\n const call = pending.get(block.callId)\n if (!call)\n continue\n pending.delete(block.callId)\n if (block.isError === true)\n continue\n\n const output = toolResultToText(block.output)\n const next = await stateFromToolResultAsync(call, output, turn, cwd, normalized, known)\n if (!next)\n continue\n\n if (!preexistingKeys.has(next.key)) {\n readState.set(next.key, next.file.entry)\n hydrated += 1\n }\n known.set(next.key, next.file)\n }\n }\n\n return hydrated\n}\n\nfunction normalizeHydrateReadStateOptions(options: HydrateReadStateOptions): NormalizedHydrateReadStateOptions {\n return {\n readFileToolName: options.readFileToolName ?? 'read_file',\n writeFileToolName: options.writeFileToolName ?? 'write_file',\n editToolName: options.editToolName ?? 'edit',\n multiEditToolName: options.multiEditToolName ?? 'multi_edit',\n defaultLineNumbers: options.defaultLineNumbers ?? true,\n ...(options.readFileForHash ? { readFileForHash: options.readFileForHash } : {}),\n ...(options.aliasMaps ? { aliasMaps: options.aliasMaps } : {}),\n }\n}\n\n/**\n * Resolve a transcript tool-call name to its canonical form for matching.\n * Honors `aliasMaps` (wire → canonical) when present; otherwise the name is\n * already canonical (zidane persists canonical names) and passes through.\n */\nfunction canonicalToolCallName(name: string, options: NormalizedHydrateReadStateOptions): string {\n return options.aliasMaps ? toCanonicalName(name, options.aliasMaps) : name\n}\n\nfunction stateFromToolResult(\n call: PendingToolCall,\n output: string,\n resultTurn: SessionTurn,\n cwd: string,\n options: NormalizedHydrateReadStateOptions,\n known: Map<string, KnownFile>,\n): { key: string, file: KnownFile } | undefined {\n if (call.name === options.readFileToolName)\n return readFileStateFromResult(call.input, output, resultTurn, cwd, options.defaultLineNumbers)\n if (call.name === options.writeFileToolName)\n return writeFileStateFromResult(call.input, output, resultTurn, cwd)\n if (call.name === options.editToolName)\n return editStateFromResult(call.input, output, resultTurn, cwd, known)\n if (call.name === options.multiEditToolName)\n return multiEditStateFromResult(call.input, output, resultTurn, cwd, known)\n return undefined\n}\n\nasync function stateFromToolResultAsync(\n call: PendingToolCall,\n output: string,\n resultTurn: SessionTurn,\n cwd: string,\n options: NormalizedHydrateReadStateOptions,\n known: Map<string, KnownFile>,\n): Promise<{ key: string, file: KnownFile } | undefined> {\n if (call.name === options.readFileToolName) {\n return await readFileStateFromResultAsync(call.input, output, resultTurn, cwd, {\n defaultLineNumbers: options.defaultLineNumbers,\n readFileForHash: options.readFileForHash,\n })\n }\n return stateFromToolResult(call, output, resultTurn, cwd, options, known)\n}\n\nfunction readFileStateFromResult(\n input: Record<string, unknown>,\n output: string,\n resultTurn: SessionTurn,\n cwd: string,\n defaultLineNumbers: boolean,\n): { key: string, file: KnownFile } | undefined {\n const path = typeof input.path === 'string' ? input.path : undefined\n if (!path || !isSuccessfulFullReadOutput(output))\n return undefined\n\n const lineNumbers = typeof input.lineNumbers === 'boolean' ? input.lineNumbers : defaultLineNumbers\n const content = lineNumbers ? stripReadFileLineNumbers(output) : output\n if (content === undefined)\n return undefined\n\n const entry: ReadStateEntry = {\n contentHash: hashContent(content),\n offset: normalizeReadInteger(input.offset, READ_FILE_DEFAULT_OFFSET),\n limit: normalizeReadInteger(input.limit, READ_FILE_DEFAULT_LIMIT),\n maxBytes: normalizeReadInteger(input.maxBytes, READ_FILE_DEFAULT_MAX_BYTES),\n lineNumbers,\n mtimeMs: resultTurn.createdAt,\n }\n return { key: readStateKey(cwd, path), file: { content, entry } }\n}\n\nasync function readFileStateFromResultAsync(\n input: Record<string, unknown>,\n output: string,\n resultTurn: SessionTurn,\n cwd: string,\n options: {\n defaultLineNumbers: boolean\n readFileForHash?: HydrateReadStateOptions['readFileForHash']\n },\n): Promise<{ key: string, file: KnownFile } | undefined> {\n const reconstructed = readFileStateFromResult(input, output, resultTurn, cwd, options.defaultLineNumbers)\n if (reconstructed)\n return reconstructed\n\n const path = typeof input.path === 'string' ? input.path : undefined\n if (!path || !options.readFileForHash || !isSuccessfulReadOutput(output))\n return undefined\n\n let content: string | null | undefined\n try {\n content = await options.readFileForHash(path)\n }\n catch {\n return undefined\n }\n if (typeof content !== 'string')\n return undefined\n\n const lineNumbers = typeof input.lineNumbers === 'boolean' ? input.lineNumbers : options.defaultLineNumbers\n const entry: ReadStateEntry = {\n contentHash: hashContent(content),\n offset: normalizeReadInteger(input.offset, READ_FILE_DEFAULT_OFFSET),\n limit: normalizeReadInteger(input.limit, READ_FILE_DEFAULT_LIMIT),\n maxBytes: normalizeReadInteger(input.maxBytes, READ_FILE_DEFAULT_MAX_BYTES),\n lineNumbers,\n mtimeMs: resultTurn.createdAt,\n }\n return { key: readStateKey(cwd, path), file: { content, entry } }\n}\n\nfunction writeFileStateFromResult(\n input: Record<string, unknown>,\n output: string,\n resultTurn: SessionTurn,\n cwd: string,\n): { key: string, file: KnownFile } | undefined {\n const path = typeof input.path === 'string' ? input.path : undefined\n const content = typeof input.content === 'string' ? input.content : undefined\n if (!path || content === undefined)\n return undefined\n if (!output.startsWith(`Created ${path} (`) && !output.startsWith(`Updated ${path} (`))\n return undefined\n\n return {\n key: readStateKey(cwd, path),\n file: {\n content,\n entry: {\n contentHash: hashContent(content),\n offset: 0,\n limit: Number.POSITIVE_INFINITY,\n maxBytes: Number.POSITIVE_INFINITY,\n mtimeMs: resultTurn.createdAt,\n // Mirrors the live seed in `write-file.ts`: the write superseded any\n // prior on-wire read output, so the first re-read on the resumed\n // session must miss dedup and serve the fresh body — otherwise the\n // mutation-site honesty fix evaporates across a process restart.\n elided: true,\n },\n },\n }\n}\n\nfunction editStateFromResult(\n input: Record<string, unknown>,\n output: string,\n resultTurn: SessionTurn,\n cwd: string,\n known: Map<string, KnownFile>,\n): { key: string, file: KnownFile } | undefined {\n const path = typeof input.path === 'string' ? input.path : undefined\n const oldString = typeof input.old_string === 'string' ? input.old_string : undefined\n const newString = typeof input.new_string === 'string' ? input.new_string : undefined\n if (!path || oldString === undefined || newString === undefined)\n return undefined\n if (!output.startsWith(`Edited ${path}: replaced `))\n return undefined\n\n const key = readStateKey(cwd, path)\n const prior = known.get(key)\n if (!prior)\n return undefined\n\n const nextContent = applyEdit(prior.content, oldString, newString, input.replace_all === true)\n if (nextContent === undefined)\n return undefined\n\n return {\n key,\n file: {\n content: nextContent,\n // `elided: true` mirrors the live refresh in `edit.ts`: the hash now\n // matches post-edit bytes while the replayed wire still shows the\n // pre-edit read, so dedup must miss on the next re-read.\n entry: { ...prior.entry, contentHash: hashContent(nextContent), mtimeMs: resultTurn.createdAt, elided: true },\n },\n }\n}\n\ninterface MultiEditStep {\n old_string?: unknown\n new_string?: unknown\n replace_all?: unknown\n}\n\nfunction multiEditStateFromResult(\n input: Record<string, unknown>,\n output: string,\n resultTurn: SessionTurn,\n cwd: string,\n known: Map<string, KnownFile>,\n): { key: string, file: KnownFile } | undefined {\n const path = typeof input.path === 'string' ? input.path : undefined\n const edits = Array.isArray(input.edits) ? (input.edits as MultiEditStep[]) : undefined\n if (!path || !edits)\n return undefined\n if (!output.startsWith(`Edited ${path}: applied `))\n return undefined\n\n const key = readStateKey(cwd, path)\n const prior = known.get(key)\n if (!prior)\n return undefined\n\n const applied = parseMultiEditAppliedSteps(output, edits.length)\n let current = prior.content\n for (let i = 0; i < edits.length; i++) {\n if (!applied.has(i))\n continue\n const step = edits[i]\n if (typeof step.old_string !== 'string' || typeof step.new_string !== 'string')\n return undefined\n const next = applyEdit(current, step.old_string, step.new_string, step.replace_all === true)\n if (next === undefined)\n return undefined\n current = next\n }\n\n return {\n key,\n file: {\n content: current,\n // same rationale as `editStateFromResult` above\n entry: { ...prior.entry, contentHash: hashContent(current), mtimeMs: resultTurn.createdAt, elided: true },\n },\n }\n}\n\nfunction applyEdit(content: string, oldString: string, newString: string, replaceAll: boolean): string | undefined {\n const match = resolveOldString(content, oldString)\n if (!match)\n return undefined\n if (match.occurrences > 1 && !replaceAll)\n return undefined\n const styledReplacement = styleReplacementForVia(newString, match.via, match.actual)\n return replaceAll\n ? content.split(match.actual).join(styledReplacement)\n : content.replace(match.actual, styledReplacement)\n}\n\nfunction parseMultiEditAppliedSteps(output: string, editCount: number): Set<number> {\n const annotationMatch = /<edit-outcomes>\\n([\\s\\S]*?)\\n<\\/edit-outcomes>/.exec(output)\n if (!annotationMatch) {\n return new Set(Array.from({ length: editCount }, (_, i) => i))\n }\n\n const applied = new Set<number>()\n for (const line of annotationMatch[1].split('\\n')) {\n const match = /^#(\\d+) applied$/.exec(line.trim())\n if (!match)\n continue\n const index = Number(match[1]) - 1\n if (index >= 0 && index < editCount)\n applied.add(index)\n }\n return applied\n}\n\nfunction isSuccessfulFullReadOutput(output: string): boolean {\n // Live read_file stores a hash of the raw full file before pagination or\n // truncation. Durable turns only contain rendered output, so partial reads\n // cannot be reconstructed safely; skip them and require a real re-read.\n if (!isSuccessfulReadOutput(output) || READ_FILE_FOOTER_RE.test(output))\n return false\n return true\n}\n\nfunction isSuccessfulReadOutput(output: string): boolean {\n if (output.length === 0)\n return true\n if (\n output.startsWith('File not found:')\n || output.startsWith('[binary file:')\n || output.startsWith('Image:')\n || output.startsWith('Document:')\n || output.startsWith('[image too large to inline:')\n || output.startsWith('[document:')\n || output.startsWith('[document too large to attach:')\n || output.startsWith('Image read failed:')\n || output.startsWith('Document read failed:')\n || output.includes(' unchanged since the previous read in this session ')\n ) {\n return false\n }\n return true\n}\n\nfunction stripReadFileLineNumbers(output: string): string | undefined {\n const lines = output.split('\\n')\n const stripped: string[] = []\n for (const line of lines) {\n const match = READ_FILE_LINE_RE.exec(line)\n if (!match)\n return undefined\n stripped.push(match[1])\n }\n return stripped.join('\\n')\n}\n\nfunction normalizeReadInteger(value: unknown, fallback: number): number {\n if (typeof value !== 'number' || !Number.isFinite(value) || value < 0)\n return fallback\n return Math.floor(value)\n}\n\n// ---------------------------------------------------------------------------\n// Tool-dedup\n// ---------------------------------------------------------------------------\n\nexport interface ToolDedupEntry {\n hash: string\n result: string | ToolResultContent[]\n /**\n * Number of replay-hits accumulated against this `(name, hash)` since\n * the most recent fresh dispatch. `0` immediately after a fresh\n * dispatch; incremented every time a `tool:gate` handler returns the\n * cached result for an identical input. Used by `dedup-tools` to\n * implement `mode: 'block-after'` — when the count crosses the\n * configured threshold, the gate stops replaying and refuses the call\n * with a `Blocked:` tool_result so the model breaks out of the loop.\n *\n * Resets to `0` on a hash change (a different input under the same\n * tool name is treated as a fresh sequence). Optional for back-compat\n * with consumers that built the entry directly; absent is treated as\n * `0`.\n */\n repeats?: number\n /**\n * The recorded result was a failure or noop verdict (wire `isError`, or\n * `outcome: 'failed' | 'noop'`). Such verdicts are state-dependent —\n * replaying one would freeze a transient failure into a permanent one —\n * so `dedup-tools` never substitutes them on a hash hit; the call\n * re-executes instead. The entry still exists so identical failing\n * calls keep counting toward `mode: 'block-after'` thresholds.\n */\n failed?: boolean\n}\n\nexport type ToolDedupMap = Map<string, ToolDedupEntry>\n\nconst TOOL_DEDUP_STATE = new WeakMap<Session, ToolDedupMap>()\n\n/**\n * Get or lazily create the per-session tool-dedup map. Returns `undefined`\n * when no session is provided — middleware should treat that as \"no dedup\".\n */\nexport function getToolDedupState(session: Session | undefined): ToolDedupMap | undefined {\n if (!session)\n return undefined\n let map = TOOL_DEDUP_STATE.get(session)\n if (!map) {\n map = new Map()\n TOOL_DEDUP_STATE.set(session, map)\n }\n return map\n}\n"],"mappings":";;;;;AAyGA,MAAM,wBAAQ,IAAI,QAA+B;;;;;;;;;;;;AAajD,SAAgB,aAAa,SAAwD;CACnF,IAAI,CAAC,SACH,OAAO,KAAA;CACT,IAAI,MAAM,MAAM,IAAI,OAAO;CAC3B,IAAI,CAAC,KAAK;EACR,sBAAM,IAAI,IAAI;EACd,MAAM,IAAI,S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AAK,MAAM,KAAK;AACzB;AAqCA,MAAM,mCAAmB,IAAI,QAA+B;;;;;AAM5D,SAAgB,kBAAkB,SAAwD;CACxF,IAAI,CAAC,SACH,OAAO,KAAA;CACT,IAAI,MAAM,iBAAiB,IAAI,OAAO;CACtC,IAAI,CAAC,KAAK;EACR,sBAAM,IAAI,IAAI;EACd,iBAAiB,IAAI,SAAS,GAAG;CACnC;CACA,OAAO;AACT"}
package/dist/restate.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { g as TaskExitInfo, h as TaskEntry, l as ExecutionHandle, o as DetachedTasksCapability } from "./types-M2DauK2D.js";
2
- import { Fp as AgentClock, Gm as ToolContext, Km as ToolDef, Mm as ToolResultContent, Om as ToolBatchExecutor, Pp as AgentBehavior, Xi as McpToolWrap, Yi as McpToolMeta, hh as SessionStore, of as StreamOptions, rf as Provider } from "./index-DWXLcGB_.js";
2
+ import { Fp as AgentClock, Gm as ToolContext, Km as ToolDef, Mm as ToolResultContent, Om as ToolBatchExecutor, Pp as AgentBehavior, Xi as McpToolWrap, Yi as McpToolMeta, hh as SessionStore, of as StreamOptions, rf as Provider } from "./index-DEqQQ8tN.js";
3
3
 
4
4
  //#region src/restate/types.d.ts
5
5
  /**
package/dist/restate.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { n as buildAliasMaps } from "./aliasing-lVFbm81n.js";
2
2
  import { r as coerceToolResultContent } from "./types-BIarq1qE.js";
3
- import { a as hydrateReadStateFromSessionAsync } from "./read-state-CNyeMG7W.js";
3
+ import { a as hydrateReadStateFromSessionAsync } from "./read-state-Dt7UbVsd.js";
4
4
  import { createHash } from "node:crypto";
5
5
  //#region src/restate/awakeable.ts
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { hh as SessionStore } from "../index-DWXLcGB_.js";
1
+ import { hh as SessionStore } from "../index-DEqQQ8tN.js";
2
2
 
3
3
  //#region src/session/sqlite.d.ts
4
4
  interface SqliteStoreOptions {
package/dist/session.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { Ah as createFileMapStore, Ch as setExtensionSessionState, Dh as createMemoryStore, Eh as createRemoteStore, Gh as dropInvalidToolPairings, Nh as PairingDrop, Oh as FileMapAdapter, Ph as PairingDropKind, Sh as resumeChainRunIds, Th as RemoteStoreOptions, Uh as autoDetectAndConvert, Vh as ToWireMessagesOptions, Xh as fromOpenAI, Yh as fromAnthropic, _h as currentExtensionSession, _m as SessionContentBlock, bh as getExtensionSessionState, bm as SessionMessage, dh as Session, eg as toAnthropic, fh as SessionData, gh as createSession, hh as SessionStore, kh as FileMapStoreOptions, lh as CreateSessionOptions, mh as SessionRun, ng as toWireMessages, ph as SessionMetaRow, tg as toOpenAI, uh as LoadSessionOptions, vh as deleteExtensionSessionState, wh as withExtensionSession, xh as loadSession, xm as SessionTurn, yh as demoteStaleRunningStatus } from "./index-DWXLcGB_.js";
1
+ import { Ah as createFileMapStore, Ch as setExtensionSessionState, Dh as createMemoryStore, Eh as createRemoteStore, Gh as dropInvalidToolPairings, Nh as PairingDrop, Oh as FileMapAdapter, Ph as PairingDropKind, Sh as resumeChainRunIds, Th as RemoteStoreOptions, Uh as autoDetectAndConvert, Vh as ToWireMessagesOptions, Xh as fromOpenAI, Yh as fromAnthropic, _h as currentExtensionSession, _m as SessionContentBlock, bh as getExtensionSessionState, bm as SessionMessage, dh as Session, eg as toAnthropic, fh as SessionData, gh as createSession, hh as SessionStore, kh as FileMapStoreOptions, lh as CreateSessionOptions, mh as SessionRun, ng as toWireMessages, ph as SessionMetaRow, tg as toOpenAI, uh as LoadSessionOptions, vh as deleteExtensionSessionState, wh as withExtensionSession, xh as loadSession, xm as SessionTurn, yh as demoteStaleRunningStatus } from "./index-DEqQQ8tN.js";
2
2
  export { CreateSessionOptions, type FileMapAdapter, type FileMapStoreOptions, LoadSessionOptions, type PairingDrop, type PairingDropKind, type RemoteStoreOptions, Session, type SessionContentBlock, SessionData, type SessionMessage, SessionMetaRow, SessionRun, SessionStore, type SessionTurn, type ToWireMessagesOptions, autoDetectAndConvert, createFileMapStore, createMemoryStore, createRemoteStore, createSession, currentExtensionSession, deleteExtensionSessionState, demoteStaleRunningStatus, dropInvalidToolPairings, fromAnthropic, fromOpenAI, getExtensionSessionState, loadSession, resumeChainRunIds, setExtensionSessionState, toAnthropic, toOpenAI, toWireMessages, withExtensionSession };
package/dist/skills.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $s as resolveSkills, Cc as installAllowedToolsGate, Dc as SkillActivationState, Ec as DeactivationReason, Gs as SkillValidationResult, Hs as writeSkillToDisk, Js as parseAllowedToolPattern, Ks as isToolAllowedByUnion, Oc as SkillActivationStateOptions, Qs as validateSkillName, Sc as IMPLICITLY_ALLOWED_SKILL_TOOLS, Tc as ActiveSkill, Us as writeSkillsToDisk, Vs as defineSkill, Ws as SkillValidationIssue, Xs as validateResourcePathReal, Ys as validateResourcePath, Zs as validateSkillForWrite, _c as getDefaultScanPaths, ac as SkillInstallCandidate, ah as SkillDiagnostic, bc as parseSkillFile, cc as SkillInstallOptions, ch as SkillsConfig, dc as installSkillFromSpec, ec as InterpolateShellCommandsOptions, fc as listSkillCandidates, gc as discoverSkills, hc as SourcedScanPath, ic as SkillCandidateDetail, ih as SkillConfig, kc as createSkillActivationState, lc as SkillInstallResult, mc as readSkillProvenance, nc as stripShellInterpolations, oc as SkillInstallError, oh as SkillResource, pc as parseSkillInstallSpec, qs as matchesAllowedTool, rc as SKILL_PROVENANCE_FILE, rh as ShellInterpolationApproval, sc as SkillInstallErrorCode, sh as SkillSource, tc as interpolateShellCommands, uc as SkillInstallSpec, vc as inferSource, wc as ActivationVia, xc as buildCatalog, yc as parseFrontmatter } from "./index-DWXLcGB_.js";
1
+ import { $s as resolveSkills, Cc as installAllowedToolsGate, Dc as SkillActivationState, Ec as DeactivationReason, Gs as SkillValidationResult, Hs as writeSkillToDisk, Js as parseAllowedToolPattern, Ks as isToolAllowedByUnion, Oc as SkillActivationStateOptions, Qs as validateSkillName, Sc as IMPLICITLY_ALLOWED_SKILL_TOOLS, Tc as ActiveSkill, Us as writeSkillsToDisk, Vs as defineSkill, Ws as SkillValidationIssue, Xs as validateResourcePathReal, Ys as validateResourcePath, Zs as validateSkillForWrite, _c as getDefaultScanPaths, ac as SkillInstallCandidate, ah as SkillDiagnostic, bc as parseSkillFile, cc as SkillInstallOptions, ch as SkillsConfig, dc as installSkillFromSpec, ec as InterpolateShellCommandsOptions, fc as listSkillCandidates, gc as discoverSkills, hc as SourcedScanPath, ic as SkillCandidateDetail, ih as SkillConfig, kc as createSkillActivationState, lc as SkillInstallResult, mc as readSkillProvenance, nc as stripShellInterpolations, oc as SkillInstallError, oh as SkillResource, pc as parseSkillInstallSpec, qs as matchesAllowedTool, rc as SKILL_PROVENANCE_FILE, rh as ShellInterpolationApproval, sc as SkillInstallErrorCode, sh as SkillSource, tc as interpolateShellCommands, uc as SkillInstallSpec, vc as inferSource, wc as ActivationVia, xc as buildCatalog, yc as parseFrontmatter } from "./index-DEqQQ8tN.js";
2
2
  export { type ActivationVia, type ActiveSkill, type DeactivationReason, IMPLICITLY_ALLOWED_SKILL_TOOLS, type InterpolateShellCommandsOptions, SKILL_PROVENANCE_FILE, type ShellInterpolationApproval, type SkillActivationState, type SkillActivationStateOptions, type SkillCandidateDetail, type SkillConfig, type SkillDiagnostic, type SkillInstallCandidate, SkillInstallError, type SkillInstallErrorCode, type SkillInstallOptions, type SkillInstallResult, type SkillInstallSpec, type SkillResource, type SkillSource, type SkillValidationIssue, type SkillValidationResult, type SkillsConfig, type SourcedScanPath, buildCatalog, createSkillActivationState, defineSkill, discoverSkills, getDefaultScanPaths, inferSource, installAllowedToolsGate, installSkillFromSpec, interpolateShellCommands, isToolAllowedByUnion, listSkillCandidates, matchesAllowedTool, parseAllowedToolPattern, parseFrontmatter, parseSkillFile, parseSkillInstallSpec, readSkillProvenance, resolveSkills, stripShellInterpolations, validateResourcePath, validateResourcePathReal, validateSkillForWrite, validateSkillName, writeSkillToDisk, writeSkillsToDisk };
@@ -1,4 +1,4 @@
1
- import { kr as __exportAll } from "./transcript-anchors-DhBTqTyc.js";
1
+ import { kr as __exportAll } from "./transcript-anchors-BeCn35OE.js";
2
2
  import * as z from "zod/v4";
3
3
  //#region node_modules/.bun/@modelcontextprotocol+sdk@1.29.0/node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
4
4
  const RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task";
@@ -1910,4 +1910,4 @@ function serializeMessage(message) {
1910
1910
  //#endregion
1911
1911
  export { serializeMessage as n, stdio_exports as r, ReadBuffer as t };
1912
1912
 
1913
- //# sourceMappingURL=stdio-BKFpPNvX.js.map
1913
+ //# sourceMappingURL=stdio-D7Nf908h.js.map