@agentproto/runtime 3.3.0 → 3.5.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.
@@ -78,6 +78,10 @@ interface ResumeStrategy {
78
78
  * why this exists and what silently omitting it breaks. Undefined for
79
79
  * a provider with no config-dir-isolated store. */
80
80
  configDirEnvVar?: string;
81
+ /** Absolute transcript path for a conversation id — see
82
+ * `ConversationStore.transcriptPath`. Present only when the provider's
83
+ * resume command also accepts a path in place of a bare id. */
84
+ transcriptPath?(cwd: string, conversationId: string, configDir?: string): string;
81
85
  }
82
86
  declare const RESUME_STRATEGIES: Record<string, ResumeStrategy>;
83
87
  /**
@@ -197,6 +201,30 @@ declare const RESUME_ID_REJECTED_RE: RegExp;
197
201
  * "not found", triggering the fresh-spawn fallback + digest injection.
198
202
  */
199
203
  declare function augmentWithFsResume<T extends FsProbeCandidate>(prev: T): Promise<T>;
204
+ /** What `probeNativeTranscript` found for a candidate's own transcript. */
205
+ interface NativeTranscriptProbe {
206
+ /** Directory that was (or would be) probed for the transcript. */
207
+ dir: string;
208
+ /** Absolute path of the transcript file the id maps to. */
209
+ path: string;
210
+ /** Whether that exact file exists on disk right now. */
211
+ exists: boolean;
212
+ }
213
+ /**
214
+ * Locate the candidate's own on-disk transcript for a provider whose native
215
+ * resume command accepts an absolute path (`ResumeStrategy.transcriptPath`).
216
+ * Returns `undefined` when the adapter declares no `transcriptPath`, or the
217
+ * candidate has no cwd / no conversation id to map — callers treat that as
218
+ * "nothing to upgrade, and no directory worth naming in diagnostics".
219
+ *
220
+ * The id lookup mirrors `decideRestartStrategy`'s (`resumeMetadata[storeAs]`),
221
+ * falling back to `adapterSessionId` (for claude-code the ACP session id IS
222
+ * the on-disk `.jsonl` uuid — acp-host.ts pins them equal) so a probe can
223
+ * still name the transcript it looked for when the sniffer never fired.
224
+ * `exists: false` is the honest "transcript not found" answer — never fall
225
+ * through to a sibling file (cross-session contamination, see fsProbe's doc).
226
+ */
227
+ declare function probeNativeTranscript(prev: FsProbeCandidate): Promise<NativeTranscriptProbe | undefined>;
200
228
  /**
201
229
  * Describe which resume path a restart used, for CLI banners / MCP
202
230
  * responses. Returns a short phrase like "resumed via claude --resume",
@@ -226,4 +254,4 @@ declare function describeResumePath(prev: RestartCandidate, opts?: DecideRestart
226
254
  */
227
255
  declare function tokenizeCommand(s: string): string[];
228
256
 
229
- export { type DecideRestartStrategyOptions, type FsProbeCandidate, RESUME_ID_REJECTED_RE, RESUME_STRATEGIES, type RestartCandidate, type RestartStrategy, type ResumeMetadataKey, type ResumeStrategy, augmentWithFsResume, decideRestartStrategy, describeResumePath, hasResumeStrategy, tokenizeCommand };
257
+ export { type DecideRestartStrategyOptions, type FsProbeCandidate, type NativeTranscriptProbe, RESUME_ID_REJECTED_RE, RESUME_STRATEGIES, type RestartCandidate, type RestartStrategy, type ResumeMetadataKey, type ResumeStrategy, augmentWithFsResume, decideRestartStrategy, describeResumePath, hasResumeStrategy, probeNativeTranscript, tokenizeCommand };
@@ -1,4 +1,4 @@
1
- import { join, resolve } from 'path';
1
+ import { join, resolve, dirname } from 'path';
2
2
  import { createReadStream, promises } from 'fs';
3
3
  import { homedir } from 'os';
4
4
  import { createInterface } from 'readline';
@@ -1639,6 +1639,7 @@ var init_conversation_store = __esm({
1639
1639
  // (default). Example: `claude --resume 0e483f81-1a44-4bec-9667-b37158450296`
1640
1640
  outputHint: /claude\s+--resume\s+([0-9a-f-]{8,})/i,
1641
1641
  attachArgv: (conversationId) => ["claude", "--resume", conversationId],
1642
+ transcriptPath: (cwd, conversationId, configDir) => join(claudeCodeProjectDir(cwd, configDir), `${conversationId}.jsonl`),
1642
1643
  configDirEnvVar: "CLAUDE_CONFIG_DIR",
1643
1644
  discover: discoverClaudeCode,
1644
1645
  read: readClaudeCode
@@ -1677,6 +1678,9 @@ var init_conversation_store = __esm({
1677
1678
  read: readPi
1678
1679
  }
1679
1680
  };
1681
+ new Set(
1682
+ Object.values(CONVERSATION_STORES).map((s) => s.storeAs)
1683
+ );
1680
1684
  }
1681
1685
  });
1682
1686
 
@@ -1691,6 +1695,7 @@ var RESUME_STRATEGIES = Object.fromEntries(
1691
1695
  outputHint: store.outputHint,
1692
1696
  storeAs: store.storeAs,
1693
1697
  ...store.configDirEnvVar ? { configDirEnvVar: store.configDirEnvVar } : {},
1698
+ ...store.transcriptPath ? { transcriptPath: store.transcriptPath } : {},
1694
1699
  fsProbe: async (cwd, prevStartedAt, expectedId, configDir) => {
1695
1700
  const candidates = await s.discover({
1696
1701
  cwd,
@@ -1767,6 +1772,21 @@ async function augmentWithFsResume(prev) {
1767
1772
  }
1768
1773
  };
1769
1774
  }
1775
+ async function probeNativeTranscript(prev) {
1776
+ if (!prev.adapterSlug || !prev.cwd) return void 0;
1777
+ const strategy = RESUME_STRATEGIES[prev.adapterSlug];
1778
+ if (!strategy?.transcriptPath) return void 0;
1779
+ const id = prev.resumeMetadata?.[strategy.storeAs] ?? prev.adapterSessionId;
1780
+ if (!id) return void 0;
1781
+ const path = strategy.transcriptPath(prev.cwd, id, prev.adapterConfigDir);
1782
+ let exists = false;
1783
+ try {
1784
+ exists = (await promises.stat(path)).isFile();
1785
+ } catch {
1786
+ exists = false;
1787
+ }
1788
+ return { dir: dirname(path), path, exists };
1789
+ }
1770
1790
  function describeResumePath(prev, opts = {}) {
1771
1791
  const mayPreferNative = prev.pty === true || opts.preferNativeTerminal === true;
1772
1792
  if (prev.adapterSlug && mayPreferNative) {
@@ -1812,6 +1832,6 @@ function tokenizeCommand(s) {
1812
1832
  return out;
1813
1833
  }
1814
1834
 
1815
- export { RESUME_ID_REJECTED_RE, RESUME_STRATEGIES, augmentWithFsResume, decideRestartStrategy, describeResumePath, hasResumeStrategy, tokenizeCommand };
1835
+ export { RESUME_ID_REJECTED_RE, RESUME_STRATEGIES, augmentWithFsResume, decideRestartStrategy, describeResumePath, hasResumeStrategy, probeNativeTranscript, tokenizeCommand };
1816
1836
  //# sourceMappingURL=resume-strategies.mjs.map
1817
1837
  //# sourceMappingURL=resume-strategies.mjs.map