@kitman-sh/cli 0.30.0 → 0.32.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 (29) hide show
  1. package/dist/{chunk-7j1kf6sa.js → chunk-1an3xh3b.js} +6 -6
  2. package/dist/{chunk-tsx0347c.js → chunk-1hgsf81a.js} +1 -1
  3. package/dist/{chunk-bv4gcq1h.js → chunk-3cneth9k.js} +7 -7
  4. package/dist/{chunk-samxkpbz.js → chunk-4qrb09w4.js} +3 -3
  5. package/dist/{chunk-wtea9nbk.js → chunk-4tzzmrz2.js} +25 -25
  6. package/dist/chunk-56gs4z53.js +399 -0
  7. package/dist/{chunk-39kjyh2y.js → chunk-5hp8ams4.js} +19 -19
  8. package/dist/{chunk-h2f26xbd.js → chunk-61dmxexa.js} +70 -28
  9. package/dist/{chunk-sw0dadq5.js → chunk-6e6t0f8y.js} +1 -1
  10. package/dist/{chunk-d4h1p51s.js → chunk-a0bjjbhg.js} +23 -23
  11. package/dist/{chunk-yr7np5eb.js → chunk-abyssa8p.js} +3 -3
  12. package/dist/{chunk-3xg9zbmy.js → chunk-acmyagwp.js} +10 -10
  13. package/dist/{chunk-tbmht2qb.js → chunk-af8kftyw.js} +10 -10
  14. package/dist/{chunk-r7m32p2j.js → chunk-ah59jrtr.js} +1 -1
  15. package/dist/{chunk-yaa3gkpx.js → chunk-awx0zevr.js} +9 -9
  16. package/dist/{chunk-js64y97w.js → chunk-c8eg05nh.js} +8 -4
  17. package/dist/{chunk-gap0vmj7.js → chunk-er0e8d8v.js} +14 -60
  18. package/dist/{chunk-0mg7k9b4.js → chunk-nb6h112w.js} +126 -122
  19. package/dist/{chunk-vz38kngm.js → chunk-q8e58p57.js} +2 -2
  20. package/dist/{chunk-1j38xtvp.js → chunk-qqb6djs7.js} +2 -2
  21. package/dist/{chunk-cehbrs1y.js → chunk-r3mjxsmn.js} +6 -6
  22. package/dist/{chunk-4qjfn1sa.js → chunk-rbpn35g5.js} +1 -1
  23. package/dist/{chunk-msn6rrx9.js → chunk-rnm5ybw4.js} +4 -4
  24. package/dist/{chunk-chxtmsns.js → chunk-x4d4t28n.js} +241 -109
  25. package/dist/{chunk-63cyj9dh.js → chunk-z0gqrc8c.js} +30 -25
  26. package/dist/{chunk-5kqt4bqp.js → chunk-znhjs0t6.js} +1 -1
  27. package/dist/index.js +4 -4
  28. package/package.json +1 -1
  29. package/dist/chunk-my92qn4x.js +0 -230
@@ -13,11 +13,11 @@ import {
13
13
  ArraySchema,
14
14
  decodeJsonStringOption,
15
15
  encodeUnknownJsonStringSync
16
- } from "./chunk-h2f26xbd.js";
16
+ } from "./chunk-61dmxexa.js";
17
17
  import {
18
18
  replaceSecretReferences,
19
19
  secretReferencesIn
20
- } from "./chunk-4qjfn1sa.js";
20
+ } from "./chunk-rbpn35g5.js";
21
21
 
22
22
  // packages/agent-runtime/src/srt-step.ts
23
23
  import { SandboxRuntimeConfigSchema } from "@anthropic-ai/sandbox-runtime";
@@ -15,8 +15,8 @@ import {
15
15
  writeSrtSettings2,
16
16
  srtStepArgv2,
17
17
  srtArgv2
18
- } from "./chunk-63cyj9dh.js";
19
- import"./chunk-h2f26xbd.js";
18
+ } from "./chunk-z0gqrc8c.js";
19
+ import"./chunk-61dmxexa.js";
20
20
  export {
21
21
  compiled2 as compiled,
22
22
  harnessesUnsupportedInDocker2 as harnessesUnsupportedInDocker,
@@ -96,8 +96,9 @@ import {
96
96
  Defect,
97
97
  Exit,
98
98
  toCodecJson
99
- } from "./chunk-h2f26xbd.js";
99
+ } from "./chunk-61dmxexa.js";
100
100
  import {
101
+ Clock,
101
102
  interrupt,
102
103
  getCurrent,
103
104
  makeUnsafe2,
@@ -108,9 +109,8 @@ import {
108
109
  shutdownUnsafe,
109
110
  fromQueue,
110
111
  unwrap
111
- } from "./chunk-63cyj9dh.js";
112
+ } from "./chunk-z0gqrc8c.js";
112
113
  import {
113
- Clock,
114
114
  empty,
115
115
  fromInput,
116
116
  merge,
@@ -123,7 +123,7 @@ import {
123
123
  ParseOptions,
124
124
  RpcClientDefect,
125
125
  RpcClientError
126
- } from "./chunk-0mg7k9b4.js";
126
+ } from "./chunk-nb6h112w.js";
127
127
 
128
128
  // node_modules/.bun/effect@4.1.2/node_modules/effect/dist/workers/Transferable.js
129
129
  class Collector extends (/* @__PURE__ */ Service2()("effect/workers/Transferable/Collector")) {
@@ -483,7 +483,7 @@ var makeNoSerialization = /* @__PURE__ */ fnUntraced(function* (group, options)
483
483
  };
484
484
  });
485
485
  var clientIdCounter = 0;
486
- var make4 = /* @__PURE__ */ fnUntraced(function* (group, options) {
486
+ var make3 = /* @__PURE__ */ fnUntraced(function* (group, options) {
487
487
  const clientId = clientIdCounter++;
488
488
  const {
489
489
  codecFor,
@@ -829,4 +829,4 @@ var layerProtocolSocket = (options) => effect(Protocol)(makeProtocolSocket(optio
829
829
  class ConnectionHooks extends (/* @__PURE__ */ Service2()("effect/rpc/RpcClient/ConnectionHooks")) {
830
830
  }
831
831
 
832
- export { layerJson, make4, withHeaders, layerProtocolSocket, ConnectionHooks };
832
+ export { layerJson, make3, withHeaders, layerProtocolSocket, ConnectionHooks };
@@ -18,7 +18,7 @@ import {
18
18
  isMinLength,
19
19
  isMaxLength,
20
20
  FiniteFromString
21
- } from "./chunk-h2f26xbd.js";
21
+ } from "./chunk-61dmxexa.js";
22
22
 
23
23
  // packages/core/src/schema.ts
24
24
  var Days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-gap0vmj7.js";
2
+ import"./chunk-er0e8d8v.js";
3
3
  import {
4
4
  HERDR_CORE_GENERATION2,
5
5
  HERDR_CORE_INSTALL_COMMAND2,
@@ -12,9 +12,9 @@ import {
12
12
  herdrCoreLayer2,
13
13
  herdrCoreTransportLayer2,
14
14
  updateHerdrCore2
15
- } from "./chunk-0mg7k9b4.js";
16
- import"./chunk-63cyj9dh.js";
17
- import"./chunk-h2f26xbd.js";
15
+ } from "./chunk-nb6h112w.js";
16
+ import"./chunk-z0gqrc8c.js";
17
+ import"./chunk-61dmxexa.js";
18
18
  export {
19
19
  HERDR_CORE_GENERATION2 as HERDR_CORE_GENERATION,
20
20
  HERDR_CORE_INSTALL_COMMAND2 as HERDR_CORE_INSTALL_COMMAND,
@@ -43,7 +43,7 @@ import {
43
43
  isFailure2,
44
44
  hasInterrupts,
45
45
  makeUnsafe5,
46
- make16,
46
+ make15,
47
47
  _await,
48
48
  fail5,
49
49
  isDoneUnsafe,
@@ -172,55 +172,8 @@ import {
172
172
  decodeJsonStringSync,
173
173
  encodeUnknownJsonStringSync,
174
174
  storable
175
- } from "./chunk-h2f26xbd.js";
175
+ } from "./chunk-61dmxexa.js";
176
176
  import {
177
- join,
178
- interrupt,
179
- unbounded,
180
- publishUnsafe,
181
- unbounded2,
182
- offer,
183
- makeUnsafe3,
184
- make11,
185
- fromQueue,
186
- fromPubSub,
187
- map2,
188
- filter,
189
- take2,
190
- mapAccum,
191
- decodeText,
192
- encodeText,
193
- splitLines,
194
- run,
195
- runCollect,
196
- runFold,
197
- runHead,
198
- runForEach,
199
- FileSystem,
200
- Path,
201
- embeddedFile,
202
- extractEmbeddedFile,
203
- optionalEnv,
204
- operatorConfigHome,
205
- tempDirectoryScoped,
206
- harnessesUnsupportedInSrt2,
207
- harnessesUnsupportedInDocker2,
208
- compiled2,
209
- pinnedSrtCommand2,
210
- pinnedSrtStepCommand2,
211
- runSrtCli2,
212
- kitmanCacheDirectory2,
213
- srtSettings2,
214
- srtCacheEnvironment2,
215
- srtInheritedEnv2,
216
- inheritedEnvironment2,
217
- withOnlyEnvironment2,
218
- writeSrtSettings2,
219
- srtStepArgv2,
220
- srtArgv2
221
- } from "./chunk-63cyj9dh.js";
222
- import {
223
- currentTimeMillis,
224
177
  SecureRandom,
225
178
  layerWebCrypto,
226
179
  layer,
@@ -307,7 +260,54 @@ import {
307
260
  checkServicesFile,
308
261
  checkServices,
309
262
  serviceChecks
310
- } from "./chunk-0mg7k9b4.js";
263
+ } from "./chunk-nb6h112w.js";
264
+ import {
265
+ currentTimeMillis,
266
+ join,
267
+ interrupt,
268
+ unbounded,
269
+ publishUnsafe,
270
+ unbounded2,
271
+ offer,
272
+ makeUnsafe3,
273
+ make10,
274
+ fromQueue,
275
+ fromPubSub,
276
+ map2,
277
+ filter,
278
+ take2,
279
+ mapAccum,
280
+ decodeText,
281
+ encodeText,
282
+ splitLines,
283
+ run,
284
+ runCollect,
285
+ runFold,
286
+ runHead,
287
+ runForEach,
288
+ FileSystem,
289
+ Path,
290
+ embeddedFile,
291
+ extractEmbeddedFile,
292
+ optionalEnv,
293
+ operatorConfigHome,
294
+ tempDirectoryScoped,
295
+ harnessesUnsupportedInSrt2,
296
+ harnessesUnsupportedInDocker2,
297
+ compiled2,
298
+ pinnedSrtCommand2,
299
+ pinnedSrtStepCommand2,
300
+ runSrtCli2,
301
+ kitmanCacheDirectory2,
302
+ srtSettings2,
303
+ srtCacheEnvironment2,
304
+ srtInheritedEnv2,
305
+ inheritedEnvironment2,
306
+ withOnlyEnvironment2,
307
+ writeSrtSettings2,
308
+ srtStepArgv2,
309
+ srtArgv2
310
+ } from "./chunk-z0gqrc8c.js";
311
311
  import {
312
312
  writeAgentEnvironmentConfigFile2,
313
313
  readManifestSkillPaths2,
@@ -323,8 +323,8 @@ import {
323
323
  applyAgentEnvironmentMaterialization2,
324
324
  isPathWithin2,
325
325
  skillIdentity2
326
- } from "./chunk-yaa3gkpx.js";
327
- import"./chunk-yr7np5eb.js";
326
+ } from "./chunk-awx0zevr.js";
327
+ import"./chunk-abyssa8p.js";
328
328
  import {
329
329
  egressAllowed,
330
330
  writeSecretRegistry,
@@ -334,37 +334,39 @@ import {
334
334
  secretFilter2,
335
335
  opaqueTunnelRefusal2,
336
336
  isOpaqueConnectReason2
337
- } from "./chunk-vz38kngm.js";
337
+ } from "./chunk-q8e58p57.js";
338
338
  import {
339
339
  sliceBytes2,
340
340
  maxLineBytes2,
341
341
  linesPerTurn2,
342
342
  decodedOption2,
343
343
  decoded2,
344
- readOpencode2
345
- } from "./chunk-my92qn4x.js";
344
+ lookAtOpencode2,
345
+ readOpencode2,
346
+ databaseStamp2
347
+ } from "./chunk-56gs4z53.js";
346
348
  import {
347
349
  uploadRunFile,
348
350
  programLease,
349
351
  rpcRunFiles,
350
352
  programHostsEnv,
351
353
  undeclaredHostsEnv
352
- } from "./chunk-3xg9zbmy.js";
353
- import"./chunk-bv4gcq1h.js";
354
+ } from "./chunk-acmyagwp.js";
355
+ import"./chunk-3cneth9k.js";
354
356
  import {
355
357
  nextInt
356
- } from "./chunk-5kqt4bqp.js";
357
- import"./chunk-tsx0347c.js";
358
+ } from "./chunk-znhjs0t6.js";
359
+ import"./chunk-1hgsf81a.js";
358
360
  import {
359
361
  ChildProcessSpawner,
360
- make3
361
- } from "./chunk-gap0vmj7.js";
362
- import"./chunk-cehbrs1y.js";
362
+ make2
363
+ } from "./chunk-er0e8d8v.js";
364
+ import"./chunk-r3mjxsmn.js";
363
365
  import {
364
366
  Id,
365
367
  secretReference,
366
368
  secretPlaceholder
367
- } from "./chunk-4qjfn1sa.js";
369
+ } from "./chunk-rbpn35g5.js";
368
370
 
369
371
  // packages/core/src/sync-kit.ts
370
372
  import { createHash } from "crypto";
@@ -3648,7 +3650,7 @@ var removeRunnerContainers = (containers, runnerId) => containers.removeLabelled
3648
3650
 
3649
3651
  // packages/agent-runtime/src/harness-sessions.ts
3650
3652
  import { constants } from "fs";
3651
- import { open, readdir } from "fs/promises";
3653
+ import { lstat, open, readdir, stat } from "fs/promises";
3652
3654
  import { promisify } from "util";
3653
3655
  import { gunzip, gzip } from "zlib";
3654
3656
  var gzipped = promisify(gzip);
@@ -3700,7 +3702,7 @@ var sessionFiles = (root, depth, confinedTo) => gen(function* () {
3700
3702
  return yield* filesBelow(root, depth, walkLimit(confinedTo));
3701
3703
  }).pipe(orElseSucceed(() => []));
3702
3704
  var maxFirstLineBytes = 1024 * 1024;
3703
- var rolloutDirectory = (file) => gen(function* () {
3705
+ var readRolloutDirectory = (file) => gen(function* () {
3704
3706
  const start = new TextDecoder().decode(yield* readSessionRange(file, 0, maxFirstLineBytes));
3705
3707
  const line = getOrUndefined(decodeJsonStringOption(start.split(`
3706
3708
  `, 1)[0] ?? ""));
@@ -3709,11 +3711,27 @@ var rolloutDirectory = (file) => gen(function* () {
3709
3711
  }).pipe(orElseSucceed(() => {
3710
3712
  return;
3711
3713
  }));
3714
+ var rolloutDirectory = (file, known) => gen(function* () {
3715
+ if (known === undefined)
3716
+ return yield* readRolloutDirectory(file);
3717
+ const stamp = yield* sessionStamp(file).pipe(orElseSucceed(() => {
3718
+ return;
3719
+ }));
3720
+ if (stamp === undefined)
3721
+ return yield* readRolloutDirectory(file);
3722
+ const key = `${stamp.dev}:${stamp.ino}`;
3723
+ const cached = known.get(key);
3724
+ if (cached !== undefined && sameSessionStamp(cached.stamp, stamp))
3725
+ return cached.directory;
3726
+ const directory = yield* readRolloutDirectory(file);
3727
+ known.set(key, { stamp, directory });
3728
+ return directory;
3729
+ });
3712
3730
  var confinement = (location, place) => {
3713
3731
  const confinedTo = location.inConfigDir === true ? place.home : place.confinedTo;
3714
3732
  return confinedTo === undefined ? undefined : { confinedTo };
3715
3733
  };
3716
- var findSession = (adapter, place) => gen(function* () {
3734
+ var findSession = (adapter, place, rolloutDirectories) => gen(function* () {
3717
3735
  const location = adapter.session?.location;
3718
3736
  if (location === undefined)
3719
3737
  return;
@@ -3758,7 +3776,7 @@ var findSession = (adapter, place) => gen(function* () {
3758
3776
  if (id === undefined)
3759
3777
  continue;
3760
3778
  const file = { id, name, path, ...confined };
3761
- if (place.id === undefined ? (yield* rolloutDirectory(file)) === place.worktree : id === place.id)
3779
+ if (place.id === undefined ? (yield* rolloutDirectory(file, rolloutDirectories)) === place.worktree : id === place.id)
3762
3780
  return file;
3763
3781
  }
3764
3782
  return;
@@ -3786,7 +3804,7 @@ var openSession = (file) => gen(function* () {
3786
3804
  if (!opened.isFile() || opened.nlink !== 1n || named.dev !== opened.dev || getOrUndefined(named.ino) !== opened.ino || !isPathWithin2(yield* Path, yield* fs.realPath(root), real))
3787
3805
  return yield* new SessionFileRefused({ path: file.path, root });
3788
3806
  }
3789
- return { handle, size: Number(opened.size) };
3807
+ return { handle, size: Number(opened.size), stamp: stampOf(opened) };
3790
3808
  });
3791
3809
  var readAt = (handle, position, length) => map9(tryPromise(() => handle.read(new Uint8Array(length), 0, length, position)), ({ buffer, bytesRead }) => buffer.subarray(0, bytesRead));
3792
3810
  var readSessionRange = (file, position, length) => gen(function* () {
@@ -3810,8 +3828,15 @@ var sessionExtent = (file) => gen(function* () {
3810
3828
  const subagents = yield* subagentFiles(file);
3811
3829
  return subagents.reduce((total, { size }) => total + size, own);
3812
3830
  });
3813
- var packConfined = (file, root) => gen(function* () {
3814
- const { handle, size } = yield* openSession(file);
3831
+ var stampOf = (info) => ({
3832
+ dev: info.dev,
3833
+ ino: info.ino,
3834
+ size: info.size,
3835
+ mtimeNs: info.mtimeNs
3836
+ });
3837
+ var sessionStamp = (file) => map9(tryPromise(() => file.confinedTo === undefined ? stat(file.path, { bigint: true }) : lstat(file.path, { bigint: true })), stampOf);
3838
+ var sameSessionStamp = (left, right) => left !== undefined && right !== undefined && left.dev === right.dev && left.ino === right.ino && left.size === right.size && left.mtimeNs === right.mtimeNs;
3839
+ var packConfined = (handle, size, file, root) => gen(function* () {
3815
3840
  if (size > maxConfinedBytes)
3816
3841
  return yield* new SessionFileRefused({ path: file.path, root });
3817
3842
  const members = [];
@@ -3833,8 +3858,12 @@ var packConfined = (file, root) => gen(function* () {
3833
3858
  offset += member.length;
3834
3859
  }
3835
3860
  return packed;
3861
+ });
3862
+ var packStampedSession = (file) => gen(function* () {
3863
+ const { handle, size, stamp } = yield* openSession(file);
3864
+ const content = file.confinedTo === undefined ? new Uint8Array(yield* tryPromise(() => handle.readFile().then(gzipped))) : yield* packConfined(handle, size, file, file.confinedTo);
3865
+ return { content, stamp };
3836
3866
  }).pipe(scoped);
3837
- var packSession = (file) => file.confinedTo === undefined ? flatMap3(FileSystem, (fs) => fs.readFile(file.path)).pipe(flatMap3((content) => tryPromise(() => gzipped(content))), map9((content) => new Uint8Array(content))) : packConfined(file, file.confinedTo);
3838
3867
  var restoreSession = (adapter, place) => gen(function* () {
3839
3868
  const fs = yield* FileSystem;
3840
3869
  const location = adapter.session?.location;
@@ -3874,6 +3903,13 @@ var transcriptSource = (adapter, place) => gen(function* () {
3874
3903
  const store = place.configDir !== undefined && sandboxed !== undefined && (yield* fs.exists(`${place.configDir}/${sandboxed}`)) ? { database: `${place.configDir}/${sandboxed}`, confinedTo: place.configDir } : place.confinedTo === undefined ? { database: `${place.home}/${adapter.sessionDatabase}` } : undefined;
3875
3904
  if (store === undefined || !(yield* fs.exists(store.database)))
3876
3905
  return;
3906
+ if (store.confinedTo !== undefined)
3907
+ return {
3908
+ kind: "opencode_database",
3909
+ ...store,
3910
+ worktree: place.worktree,
3911
+ startedAt: place.startedAt ?? 0
3912
+ };
3877
3913
  const session = yield* readOpencode2(store, "newestSession", {
3878
3914
  worktree: place.worktree,
3879
3915
  startedAt: place.startedAt ?? 0
@@ -5745,6 +5781,7 @@ var batchSize = 100;
5745
5781
  var maxEventsPerLine = 1024;
5746
5782
  var maxBatchChars = 2 * 1024 * 1024;
5747
5783
  var maxUnsentChars = 16 * 1024 * 1024;
5784
+ var maxFailedLooks = 3;
5748
5785
  var maxFailingMillis = 30000;
5749
5786
  var firstResendMillis = 1000;
5750
5787
  var longestResendMillis = 30000;
@@ -6291,6 +6328,7 @@ var opencodeV2Part = (part) => {
6291
6328
  }
6292
6329
  };
6293
6330
  };
6331
+ var sandboxed = (source) => source.kind !== "file" && source.confinedTo !== undefined;
6294
6332
  var transcriptRelay = (input) => {
6295
6333
  const normalize = sessionNormalizer(input.harness);
6296
6334
  const tokens = tokenCounter(input.harness);
@@ -6318,6 +6356,12 @@ var transcriptRelay = (input) => {
6318
6356
  let refusal;
6319
6357
  let harnessError;
6320
6358
  let codexLimits;
6359
+ let lookedAt;
6360
+ let stampSeen;
6361
+ let failedAt;
6362
+ let failedLooks = 0;
6363
+ let lookedAtExtent;
6364
+ let found;
6321
6365
  let errorReadAt;
6322
6366
  let opencodeModel;
6323
6367
  const namedModel = (named) => {
@@ -6534,6 +6578,76 @@ var transcriptRelay = (input) => {
6534
6578
  openMessage.clear();
6535
6579
  closedTo = seq;
6536
6580
  }).pipe(uninterruptible);
6581
+ const sawFrame = (frame) => gen(function* () {
6582
+ switch (frame.kind) {
6583
+ case "found":
6584
+ found = frame.session ?? undefined;
6585
+ return true;
6586
+ case "extent":
6587
+ lookedAtExtent = frame.extent;
6588
+ yield* sawSession(frame.extent);
6589
+ return true;
6590
+ case "error":
6591
+ heard(opencodeProviderRefusal(frame.error));
6592
+ return true;
6593
+ case "model":
6594
+ namedModel(frame.model);
6595
+ errorReadAt = lookedAtExtent;
6596
+ return true;
6597
+ case "unsaid":
6598
+ yield* logWarning("runner_transcript_unread", frame.reason);
6599
+ return true;
6600
+ case "messages":
6601
+ for (const message of frame.messages)
6602
+ yield* sawMessage(message);
6603
+ break;
6604
+ case "open":
6605
+ for (const part of frame.parts)
6606
+ yield* uninterruptible(sawPart(part));
6607
+ break;
6608
+ case "past":
6609
+ for (const part of frame.parts)
6610
+ yield* sawPart(part).pipe(andThen2(sync2(() => {
6611
+ recordedTo = part.position;
6612
+ })), uninterruptible);
6613
+ }
6614
+ yield* flush;
6615
+ yield* yieldNow;
6616
+ return !backedUp();
6617
+ });
6618
+ const lookAt = (source) => gen(function* () {
6619
+ const { stamp, settled } = yield* databaseStamp2(source.database);
6620
+ const changed = stamp !== stampSeen;
6621
+ stampSeen = stamp;
6622
+ if (backedUp())
6623
+ yield* flush;
6624
+ if (backedUp()) {
6625
+ if (changed)
6626
+ progressAt = yield* currentTimeMillis;
6627
+ return;
6628
+ }
6629
+ if (settled && stamp === lookedAt)
6630
+ return;
6631
+ const sessionId = source.kind === "opencode_database" ? found?.id : source.sessionId;
6632
+ const whole = yield* lookAtOpencode2({
6633
+ database: source.database,
6634
+ confinedTo: source.confinedTo,
6635
+ ...sessionId === undefined ? undefined : { sessionId }
6636
+ }, {
6637
+ ...source.kind !== "opencode_database" ? { kind: source.kind } : found === undefined ? { find: { worktree: source.worktree, startedAt: source.startedAt } } : { kind: found.kind },
6638
+ closedTo,
6639
+ saidAt: errorReadAt ?? null,
6640
+ open: [...stages.keys()],
6641
+ recordedTo
6642
+ }, sawFrame).pipe(tapError2(() => sync2(() => {
6643
+ failedLooks = failedAt === stamp ? failedLooks + 1 : 1;
6644
+ failedAt = stamp;
6645
+ if (failedLooks >= maxFailedLooks)
6646
+ lookedAt = stamp;
6647
+ })));
6648
+ if (whole && settled)
6649
+ lookedAt = stamp;
6650
+ });
6537
6651
  const takeMessages = (source) => gen(function* () {
6538
6652
  const start = closedTo;
6539
6653
  for (const message of yield* readOpencode2(source, "messagesPast", { seq: closedTo }))
@@ -6558,6 +6672,8 @@ var transcriptRelay = (input) => {
6558
6672
  return tokensSpent([own, ...spent]) ?? "none";
6559
6673
  }),
6560
6674
  read: (source) => gen(function* () {
6675
+ if (sandboxed(source))
6676
+ return yield* lookAt(source);
6561
6677
  if (source.kind === "opencode_v2") {
6562
6678
  const extent = yield* readOpencode2(source, "extent", {});
6563
6679
  yield* sawSession(extent);
@@ -6864,31 +6980,37 @@ var keepSession = (rpc, lease, content) => gen(function* () {
6864
6980
  return yield* new SessionNotKept({ status: kept.status });
6865
6981
  return kept;
6866
6982
  }).pipe(scoped, timeout(checkpointTransfer.timeout));
6867
- var rpcStepCheckpoints = (rpc, signals, storage) => ({
6868
- resume: (work) => gen(function* () {
6869
- const point = yield* rpc.resumeCheckpoint({ lease: programLease(work) });
6870
- if (point === undefined)
6871
- return;
6872
- const { session, ...workspace } = point;
6873
- if (session === undefined)
6874
- return workspace;
6875
- const { url, headers, ...file } = session;
6876
- const content = yield* storage.execute(get(url).pipe(setHeaders(headers ?? {}))).pipe(flatMap3(filterStatusOk), flatMap3((response) => response.arrayBuffer), tapError2((error) => logWarning("runner_session_unreadable", error.message)), option2);
6877
- return isNone(content) ? workspace : { ...workspace, session: { ...file, content: new Uint8Array(content.value) } };
6878
- }),
6879
- save: (work, { session, ...workspace }) => gen(function* () {
6880
- const lease = programLease(work);
6881
- const kept = session === undefined ? undefined : yield* keepSession(rpc, lease, session.content).pipe(provideService(HttpClient, storage));
6882
- yield* rpc.saveCheckpoint({
6883
- lease,
6884
- checkpoint: {
6885
- ...workspace,
6886
- ...session === undefined || kept === undefined ? undefined : { session: { harness: session.harness, id: session.id, name: session.name, fileId: kept.id } }
6887
- }
6888
- });
6889
- }),
6890
- sessionUpdated: (work) => signals.sessionUpdated(work.id)
6891
- });
6983
+ var rpcStepCheckpoints = (rpc, signals, storage) => {
6984
+ const keptSessions = new WeakMap;
6985
+ return {
6986
+ resume: (work) => gen(function* () {
6987
+ const point = yield* rpc.resumeCheckpoint({ lease: programLease(work) });
6988
+ if (point === undefined)
6989
+ return;
6990
+ const { session, ...workspace } = point;
6991
+ if (session === undefined)
6992
+ return workspace;
6993
+ const { url, headers, ...file } = session;
6994
+ const content = yield* storage.execute(get(url).pipe(setHeaders(headers ?? {}))).pipe(flatMap3(filterStatusOk), flatMap3((response) => response.arrayBuffer), tapError2((error) => logWarning("runner_session_unreadable", error.message)), option2);
6995
+ return isNone(content) ? workspace : { ...workspace, session: { ...file, content: new Uint8Array(content.value) } };
6996
+ }),
6997
+ save: (work, { session, ...workspace }) => gen(function* () {
6998
+ const lease = programLease(work);
6999
+ const known = session === undefined ? undefined : keptSessions.get(session.content);
7000
+ const fileId = session === undefined ? undefined : known?.attemptId === work.id ? known.fileId : (yield* keepSession(rpc, lease, session.content).pipe(provideService(HttpClient, storage))).id;
7001
+ yield* rpc.saveCheckpoint({
7002
+ lease,
7003
+ checkpoint: {
7004
+ ...workspace,
7005
+ ...session === undefined || fileId === undefined ? undefined : { session: { harness: session.harness, id: session.id, name: session.name, fileId } }
7006
+ }
7007
+ }).pipe(tapError2(() => sync2(() => session !== undefined && keptSessions.delete(session.content))));
7008
+ if (session !== undefined && fileId !== undefined)
7009
+ keptSessions.set(session.content, { attemptId: work.id, fileId });
7010
+ }),
7011
+ sessionUpdated: (work) => signals.sessionUpdated(work.id)
7012
+ };
7013
+ };
6892
7014
  var gitIdentity = ["-c", "user.name=Kitman", "-c", "user.email=runner@kitman.invalid"];
6893
7015
  var srtMaskNames = [...DANGEROUS_FILES, ...DANGEROUS_DIRECTORIES.filter((name) => name !== ".git")];
6894
7016
  var stageAll = (worktree, git) => gen(function* () {
@@ -7149,6 +7271,7 @@ var freshDirectory = (directory) => gen(function* () {
7149
7271
  yield* fs.remove(directory, { recursive: true, force: true });
7150
7272
  yield* fs.makeDirectory(directory, { recursive: true });
7151
7273
  }).pipe(orDie);
7274
+ var harnessSessionFiles = { find: findSession, pack: packStampedSession };
7152
7275
  var stepAttempt = (input, resending) => (work) => gen(function* () {
7153
7276
  const checkouts = runCheckouts(input.rootDir, input.gitCredentials);
7154
7277
  const repoBinding = work.checkout === "none" ? undefined : work.repoBinding;
@@ -7216,22 +7339,31 @@ ${afterMergeFailed}`];
7216
7339
  };
7217
7340
  const sessionId = transcript !== undefined || adapter?.session?.start !== undefined ? session.id : undefined;
7218
7341
  let last = saved?.ref === checkpointRef(work) ? saved : {};
7342
+ const rolloutDirectories = new Map;
7343
+ const sessionFiles = input.sessionFiles ?? harnessSessionFiles;
7219
7344
  const checkpointTurn = makeUnsafe3(1);
7220
7345
  const takeCheckpoint = gen(function* () {
7221
7346
  if (input.checkpoints === undefined)
7222
7347
  return;
7223
7348
  const workspace = writable ? yield* pushCheckpoint(worktree, checkpointRef(work), last.tree, yield* checkouts.transferEnv(repoBinding)) : undefined;
7224
- const file = adapter === undefined ? undefined : yield* findSession(adapter, {
7225
- ...sessions,
7226
- worktree,
7227
- ...sessionId === undefined ? undefined : { id: sessionId }
7228
- });
7229
- const content = file === undefined ? undefined : yield* packSession(file).pipe(catch_((error) => as(logWarning("runner_session_unread", error.message), undefined)));
7349
+ const file = adapter === undefined ? undefined : yield* sessionFiles.find(adapter, { ...sessions, worktree, ...sessionId === undefined ? undefined : { id: sessionId } }, rolloutDirectories);
7350
+ const unchanged = file !== undefined && last.session?.harness === adapter?.id && last.session?.id === file.id && sameSessionStamp(last.sessionStamp, yield* sessionStamp(file).pipe(orElseSucceed(() => {
7351
+ return;
7352
+ })));
7353
+ const packed = file === undefined || unchanged ? undefined : yield* sessionFiles.pack(file).pipe(catch_((error) => as(logWarning("runner_session_unread", error.message), undefined)));
7354
+ const content = packed?.content;
7230
7355
  const sessionChanged = content !== undefined && !sameBytes(last.session?.content, content);
7356
+ if (packed !== undefined && !sessionChanged)
7357
+ last = { ...last, sessionStamp: packed.stamp };
7231
7358
  if (workspace === undefined && !sessionChanged)
7232
7359
  return;
7233
7360
  const session = file === undefined || content === undefined || adapter === undefined ? last.session ?? (transcript === undefined ? undefined : storedSession) : { harness: adapter.id, id: file.id, name: file.name, content };
7234
- const next = { ...last, ...workspace, ...session === undefined ? undefined : { session } };
7361
+ const next = {
7362
+ ...last,
7363
+ ...workspace,
7364
+ ...session === undefined ? undefined : { session },
7365
+ ...packed === undefined ? undefined : { sessionStamp: packed.stamp }
7366
+ };
7235
7367
  yield* input.checkpoints.save(work, {
7236
7368
  ...next.ref === undefined || next.revision === undefined ? undefined : { ref: next.ref, revision: next.revision },
7237
7369
  ...session === undefined ? undefined : { session }
@@ -8032,7 +8164,7 @@ var codexAppServer = (binary = "codex") => (env) => gen(function* () {
8032
8164
  const input = yield* unbounded2();
8033
8165
  const pending = new Map;
8034
8166
  let lastId = 0;
8035
- const handle = yield* spawner.spawn(make3(binary, ["app-server"], {
8167
+ const handle = yield* spawner.spawn(make2(binary, ["app-server"], {
8036
8168
  cwd: env.home,
8037
8169
  extendEnv: true,
8038
8170
  env: { HOME: env.home, CODEX_HOME: env.codexHome },
@@ -8055,7 +8187,7 @@ var codexAppServer = (binary = "codex") => (env) => gen(function* () {
8055
8187
  return {
8056
8188
  request: (method, params) => gen(function* () {
8057
8189
  const id = ++lastId;
8058
- const deferred = yield* make16();
8190
+ const deferred = yield* make15();
8059
8191
  pending.set(id, deferred);
8060
8192
  yield* send({ id, method, params });
8061
8193
  return yield* _await(deferred).pipe(mapError2((error) => new CodexAppServerFailed({ reason: `${method}: ${error.message}` })));
@@ -8195,10 +8327,10 @@ var handshake = [
8195
8327
  `).join("");
8196
8328
  var kitmanMcpPreflight = (mcp) => gen(function* () {
8197
8329
  const spawner = yield* ChildProcessSpawner;
8198
- const server = yield* spawner.spawn(make3(mcp.command, [...mcp.args], {
8330
+ const server = yield* spawner.spawn(make2(mcp.command, [...mcp.args], {
8199
8331
  extendEnv: true,
8200
8332
  env: mcp.env,
8201
- stdin: { stream: make11(new TextEncoder().encode(handshake)), endOnDone: false },
8333
+ stdin: { stream: make10(new TextEncoder().encode(handshake)), endOnDone: false },
8202
8334
  stderr: "ignore"
8203
8335
  }));
8204
8336
  const reply = yield* server.stdout.pipe(decodeText, splitLines, map2((line) => getOrUndefined(decodeJsonStringOption(line))), filter((message) => isJsonObject(message) && message.id === 2), runHead);
@@ -8271,8 +8403,8 @@ var programProcessExecutor = (input) => (work) => gen(function* () {
8271
8403
  };
8272
8404
  const exitCode = sandbox === undefined ? yield* gen(function* () {
8273
8405
  const spawner = yield* ChildProcessSpawner;
8274
- const handle = yield* spawner.spawn(make3(input.bun ?? process.execPath, [file], {
8275
- stdin: make11(new TextEncoder().encode(stdin)),
8406
+ const handle = yield* spawner.spawn(make2(input.bun ?? process.execPath, [file], {
8407
+ stdin: make10(new TextEncoder().encode(stdin)),
8276
8408
  stdout: "inherit",
8277
8409
  stderr: "inherit",
8278
8410
  extendEnv: false,