shraga 0.1.111 → 0.1.112

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.
@@ -5,6 +5,7 @@ import { homedir } from 'node:os';
5
5
  import { DATA_DIR, dataPath } from './paths.ts';
6
6
  import type { Directives } from './directives.ts';
7
7
  import type { ClaudeAccountRef } from './claude-account.ts';
8
+ import { findClaudeTranscript, type ClaudeResumeState } from './engine/claude-resume.ts';
8
9
 
9
10
  const SESSIONS_PATH = dataPath('sessions.json');
10
11
 
@@ -45,6 +46,8 @@ export interface SessionMeta {
45
46
  /** Claude login the last turn ran on (claude-code engine, subscription auth only). `personal` = the
46
47
  * requester's own routed login (claude-account.ts), false = the box's shared login. Never a token. */
47
48
  lastAccount?: ClaudeAccountRef;
49
+ /** claude-code engine SDK-resume mapping (opt-in flag) — see engine/claude-resume.ts. */
50
+ claudeResume?: ClaudeResumeState;
48
51
  forkedFrom?: string;
49
52
  }
50
53
 
@@ -383,6 +386,18 @@ export function setSessionModel(sessionId: string, model: string, engine?: strin
383
386
  }
384
387
  }
385
388
 
389
+ /** Store (or clear, with undefined) the claude-code resume mapping. `patch` merges into the existing one. */
390
+ export function setClaudeResume(sessionId: string, state: ClaudeResumeState | undefined, patch?: Partial<ClaudeResumeState>): void {
391
+ const sessions = loadIndex();
392
+ const s = sessions.find((x) => x.sessionId === sessionId);
393
+ if (!s) return;
394
+ if (patch) { if (!s.claudeResume) return; s.claudeResume = { ...s.claudeResume, ...patch }; }
395
+ else if (state) s.claudeResume = state;
396
+ else if (s.claudeResume) delete s.claudeResume;
397
+ else return;
398
+ saveIndex(sessions);
399
+ }
400
+
386
401
  export function getSessionsByScheduleId(scheduleId: string): SessionMeta[] {
387
402
  return loadIndex()
388
403
  .filter((s) => s.scheduleId === scheduleId)
@@ -528,16 +543,8 @@ export function getSessionAbortController(sessionId: string): AbortController |
528
543
  return globalSessionLocks.get(sessionId)?.abortController;
529
544
  }
530
545
 
531
- const CLAUDE_PROJECTS_DIR = path.join(homedir(), '.claude', 'projects');
532
-
533
546
  function findSessionFile(sessionId: string): string | null {
534
- if (!existsSync(CLAUDE_PROJECTS_DIR)) return null;
535
- for (const dir of readdirSync(CLAUDE_PROJECTS_DIR, { withFileTypes: true })) {
536
- if (!dir.isDirectory()) continue;
537
- const file = path.join(CLAUDE_PROJECTS_DIR, dir.name, `${sessionId}.jsonl`);
538
- if (existsSync(file)) return file;
539
- }
540
- return null;
547
+ return findClaudeTranscript(sessionId, path.join(homedir(), '.claude'));
541
548
  }
542
549
 
543
550
  // ── Our own conversation store ───────────────────────────────────────────────
@@ -52,6 +52,9 @@ export interface AgentSettings {
52
52
  skillDiscovery?: boolean;
53
53
  thinking?: 'adaptive' | 'enabled' | 'disabled';
54
54
  effort?: 'low' | 'medium' | 'high' | 'max';
55
+ /** claude-code engine: resume the SDK session across turns instead of re-sending the history
56
+ * (prompt-cache savings). Default off; a session's `[resume:on|off]` directive wins. */
57
+ sdkResume?: boolean;
55
58
  }
56
59
 
57
60
  export interface ShragaConfig {