agenttwin 0.3.37 → 0.3.38

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 (83) hide show
  1. package/dist/api.js +2471 -1510
  2. package/dist/dashboard/assets/next/static/chunks/{1937-2369d8ef2eae7700.js → 1937-6c86fddc443de922.js} +1 -1
  3. package/dist/dashboard/assets/next/static/chunks/app/_not-found/page-2fd2e381a895d366.js +1 -0
  4. package/dist/dashboard/assets/next/static/chunks/app/about/page-40c8beec9496b8b7.js +1 -0
  5. package/dist/dashboard/assets/next/static/chunks/app/account/password/page-f73c2b9267b5d7e0.js +1 -0
  6. package/dist/dashboard/assets/next/static/chunks/app/api-policy/page-f4b72a7ad1e56298.js +1 -0
  7. package/dist/dashboard/assets/next/static/chunks/app/auth/page-f4b72a7ad1e56298.js +1 -0
  8. package/dist/dashboard/assets/next/static/chunks/app/{enterprise/page-11514cc52285b7f3.js → blog/layout-50a710e1993b90e4.js} +1 -1
  9. package/dist/dashboard/assets/next/static/chunks/app/compare/page-f4b72a7ad1e56298.js +1 -0
  10. package/dist/dashboard/assets/next/static/chunks/app/contact/page-f4b72a7ad1e56298.js +1 -0
  11. package/dist/dashboard/assets/next/static/chunks/app/dashboard/layout-209f837090dfdb78.js +1 -0
  12. package/dist/dashboard/assets/next/static/chunks/app/dashboard/{page-3d8c07ca2af8081c.js → page-9599e4d7dbe9d109.js} +1 -1
  13. package/dist/dashboard/assets/next/static/chunks/app/demo/{page-ac6e235c635cb130.js → page-31cfcdbb616ad4d4.js} +1 -1
  14. package/dist/dashboard/assets/next/static/chunks/app/developers/page-f4b72a7ad1e56298.js +1 -0
  15. package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-9d51ad46fff3ed1d.js +1 -0
  16. package/dist/dashboard/assets/next/static/chunks/app/dpa/page-f4b72a7ad1e56298.js +1 -0
  17. package/dist/dashboard/assets/next/static/chunks/app/enterprise/page-eaf9847de1de035e.js +1 -0
  18. package/dist/dashboard/assets/next/static/chunks/app/guides/page-f4b72a7ad1e56298.js +1 -0
  19. package/dist/dashboard/assets/next/static/chunks/app/{layout-8aa153f632f0aa20.js → layout-128b6774e096cd58.js} +1 -1
  20. package/dist/dashboard/assets/next/static/chunks/app/login/page-fd6021c3acb6bfba.js +1 -0
  21. package/dist/dashboard/assets/next/static/chunks/app/not-found-f4b72a7ad1e56298.js +1 -0
  22. package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-f115c111de9d5332.js +1 -0
  23. package/dist/dashboard/assets/next/static/chunks/app/{page-76277dc68b6a22bd.js → page-894aeddae568cc62.js} +1 -1
  24. package/dist/dashboard/assets/next/static/chunks/app/{blog/layout-6c159db381b82832.js → pricing/page-814d931ab23c41a1.js} +1 -1
  25. package/dist/dashboard/assets/next/static/chunks/app/privacy/page-f4b72a7ad1e56298.js +1 -0
  26. package/dist/dashboard/assets/next/static/chunks/app/sandbox/page-f4b72a7ad1e56298.js +1 -0
  27. package/dist/dashboard/assets/next/static/chunks/app/scoreboard/page-f4b72a7ad1e56298.js +1 -0
  28. package/dist/dashboard/assets/next/static/chunks/app/security/page-f4b72a7ad1e56298.js +1 -0
  29. package/dist/dashboard/assets/next/static/chunks/app/signup/page-fd6021c3acb6bfba.js +1 -0
  30. package/dist/dashboard/assets/next/static/chunks/app/status/{page-fd41c4e7838d9949.js → page-ff7cb74a07e7a9e2.js} +1 -1
  31. package/dist/dashboard/assets/next/static/chunks/app/subprocessors/page-f4b72a7ad1e56298.js +1 -0
  32. package/dist/dashboard/assets/next/static/chunks/app/terms/page-f4b72a7ad1e56298.js +1 -0
  33. package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/layout-b0875609e09201bf.js +1 -0
  34. package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/page-1dac0135be05c7c8.js +1 -0
  35. package/dist/dashboard/assets/next/static/chunks/app/v2/layout-7c6be3e291ee6a1d.js +1 -0
  36. package/dist/dashboard/assets/next/static/chunks/app/v2/login/page-893f3f867fbaab89.js +1 -0
  37. package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-d0d081d4ea987ae2.js +1 -0
  38. package/dist/dashboard/assets/next/static/chunks/app/v2/page-cfa46e7717999ca0.js +1 -0
  39. package/dist/dashboard/assets/next/static/chunks/app/v2/signup/page-893f3f867fbaab89.js +1 -0
  40. package/dist/dashboard/assets/next/static/chunks/app/what-is-agenttwin/page-f4b72a7ad1e56298.js +1 -0
  41. package/dist/dashboard/assets/next/static/chunks/{main-app-4051d8ba998bea15.js → main-app-916068fc13b0fb5b.js} +1 -1
  42. package/dist/dashboard/assets/next/static/chunks/{webpack-b1e92d10ff1fbc69.js → webpack-2f5d1da47be2abc8.js} +1 -1
  43. package/dist/dashboard/assets/next/static/css/8b41516b04992d45.css +1 -0
  44. package/dist/dashboard/index.html +2 -2
  45. package/dist/engine.js +4796 -1235
  46. package/dist/gateway.js +2476 -1510
  47. package/dist/worker.js +106 -24
  48. package/dist/world-host.js +187 -79
  49. package/package.json +3 -1
  50. package/dist/dashboard/assets/next/static/chunks/app/_not-found/page-b60a5aad66f3bf1d.js +0 -1
  51. package/dist/dashboard/assets/next/static/chunks/app/about/page-a30c6925cc9ac983.js +0 -1
  52. package/dist/dashboard/assets/next/static/chunks/app/account/password/page-0478a7f18cc5e31b.js +0 -1
  53. package/dist/dashboard/assets/next/static/chunks/app/api-policy/page-91ad6c5e4226778f.js +0 -1
  54. package/dist/dashboard/assets/next/static/chunks/app/auth/page-91ad6c5e4226778f.js +0 -1
  55. package/dist/dashboard/assets/next/static/chunks/app/compare/page-91ad6c5e4226778f.js +0 -1
  56. package/dist/dashboard/assets/next/static/chunks/app/contact/page-91ad6c5e4226778f.js +0 -1
  57. package/dist/dashboard/assets/next/static/chunks/app/dashboard/layout-0050f308b9f77c24.js +0 -1
  58. package/dist/dashboard/assets/next/static/chunks/app/developers/page-91ad6c5e4226778f.js +0 -1
  59. package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-c86920ba0d1f3bc0.js +0 -1
  60. package/dist/dashboard/assets/next/static/chunks/app/dpa/page-91ad6c5e4226778f.js +0 -1
  61. package/dist/dashboard/assets/next/static/chunks/app/guides/page-91ad6c5e4226778f.js +0 -1
  62. package/dist/dashboard/assets/next/static/chunks/app/login/page-99ebb4d265222728.js +0 -1
  63. package/dist/dashboard/assets/next/static/chunks/app/not-found-91ad6c5e4226778f.js +0 -1
  64. package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-9e59af0296c9366b.js +0 -1
  65. package/dist/dashboard/assets/next/static/chunks/app/pricing/page-c7015af858f4db8e.js +0 -1
  66. package/dist/dashboard/assets/next/static/chunks/app/privacy/page-91ad6c5e4226778f.js +0 -1
  67. package/dist/dashboard/assets/next/static/chunks/app/sandbox/page-91ad6c5e4226778f.js +0 -1
  68. package/dist/dashboard/assets/next/static/chunks/app/scoreboard/page-91ad6c5e4226778f.js +0 -1
  69. package/dist/dashboard/assets/next/static/chunks/app/security/page-91ad6c5e4226778f.js +0 -1
  70. package/dist/dashboard/assets/next/static/chunks/app/signup/page-99ebb4d265222728.js +0 -1
  71. package/dist/dashboard/assets/next/static/chunks/app/subprocessors/page-91ad6c5e4226778f.js +0 -1
  72. package/dist/dashboard/assets/next/static/chunks/app/terms/page-91ad6c5e4226778f.js +0 -1
  73. package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/layout-a79d128eb3b0b7d2.js +0 -1
  74. package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/page-a9fa05c9ae5c24dc.js +0 -1
  75. package/dist/dashboard/assets/next/static/chunks/app/v2/layout-2e97381ae7a59ba0.js +0 -1
  76. package/dist/dashboard/assets/next/static/chunks/app/v2/login/page-57afbac97afd31fa.js +0 -1
  77. package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-7c08d2c43f0be9d5.js +0 -1
  78. package/dist/dashboard/assets/next/static/chunks/app/v2/page-35998431fb40a9c9.js +0 -1
  79. package/dist/dashboard/assets/next/static/chunks/app/v2/signup/page-57afbac97afd31fa.js +0 -1
  80. package/dist/dashboard/assets/next/static/chunks/app/what-is-agenttwin/page-91ad6c5e4226778f.js +0 -1
  81. package/dist/dashboard/assets/next/static/css/96134c7d160c4fc3.css +0 -1
  82. /package/dist/dashboard/assets/next/static/{RsIyq0Rz3py_mKuoIqn42 → Jcm2T3zQdpRyYqps7LFDD}/_buildManifest.js +0 -0
  83. /package/dist/dashboard/assets/next/static/{RsIyq0Rz3py_mKuoIqn42 → Jcm2T3zQdpRyYqps7LFDD}/_ssgManifest.js +0 -0
@@ -92,7 +92,8 @@ async function createRequestSourceHook(app, spec, credentials, runtime) {
92
92
  const violationsPath = join(dir, "blocked.jsonl");
93
93
  const config = { root: runtime?.root ?? await realpath(resolve(app)), files: spec.files, origins: Object.values(credentials).map((c) => new URL(c.endpoint).origin), routes: Object.fromEntries((spec.fetchRoutes ?? []).map((r) => [r.origin, credentials[r.service]])), routing: !!spec.fetchRoutes, violationsFd: runtime?.violationsFd, stdioViolations: !!runtime?.stdioViolations, violationsPath: runtime?.violationsPath ?? violationsPath };
94
94
  const guard = "const hookKey=Symbol.for('agenttwin.requestHook.v1');if(globalThis[hookKey])return;Object.defineProperty(globalThis,hookKey,{value:true});\n";
95
- const hook = guard + applicationClockHook(spec.applicationClock) + `const config=${JSON.stringify(config)};
95
+ const orphanGuard = "if(process.platform!=='win32'){const launcher=process.ppid;setInterval(()=>{if(process.ppid!==launcher)process.exit(1);},1000).unref();}\n";
96
+ const hook = guard + orphanGuard + applicationClockHook(spec.applicationClock) + `const config=${JSON.stringify(config)};
96
97
  ` + String.raw`
97
98
  const http=require('node:http'),https=require('node:https'),path=require('node:path'),{fileURLToPath}=require('node:url');
98
99
  const origins=new Set(config.origins),files=new Set(config.files);
@@ -121,7 +122,7 @@ function esbuildBinary(real){const match=real.match(/^(.*[\/\\]node_modules[\/\\
121
122
  // Operating-system tools that only print facts about this machine and cannot open a connection. SDKs and frameworks
122
123
  // run them for a user-agent string (Stripe: uname; Next.js: sw_vers). Matched by their fixed system path, so a file of
123
124
  // the same name inside a project or earlier on PATH is still reported.
124
- const SYSTEM_INFO_BINARIES=new Set(['/usr/bin/uname','/bin/uname','/usr/bin/sw_vers','/usr/bin/arch','/usr/bin/nproc','/usr/bin/getconf']);
125
+ const SYSTEM_INFO_BINARIES=new Set(['/usr/bin/uname','/bin/uname','/usr/bin/sw_vers','/usr/bin/arch','/usr/bin/nproc','/usr/bin/getconf','/usr/sbin/sysctl']);
125
126
  function systemInfoBinary(real){return process.platform!=='win32'&&SYSTEM_INFO_BINARIES.has(real);}
126
127
  // pnpm's node_modules/.bin entries are sh scripts that exec node on the package's JS: the child is Node and loads the hook.
127
128
  function pnpmNodeShim(real,text){if(!/[\\/]node_modules[\\/]\.bin[\\/]/.test(real)||!/^#!\/bin\/sh/.test(text))return false;const execs=[...text.matchAll(/\bexec\s+(\S+)/g)].map(m=>m[1]);return execs.length>0&&execs.every(e=>/^(?:node|"\$basedir\/node)(?:\.exe)?"?$/.test(e));}
@@ -133,7 +134,21 @@ function hookedEnv(options){const env={...((options&&options.env)||process.env)}
133
134
  // git asked about the local checkout only (the commit a build stamps, the branch): no network, nothing written.
134
135
  const LOCAL_GIT=/^(rev-parse|describe|log|show|status|branch|symbolic-ref|ls-files|rev-list|config)$/;
135
136
  function localGit(name,words){if(name!=='git')return false;const sub=words.find(w=>!String(w).startsWith('-'));return !!sub&&LOCAL_GIT.test(String(sub))&&(sub!=='config'||words.some(w=>/^--get/.test(String(w))));}
136
- function checkExecutable(command,shell,options,args){let name='unknown',trusted=false;try{const text=String(command).trim();const first=(shell?(text.split(/\s+/).find(token=>!/^[A-Za-z_][A-Za-z0-9_]*=/.test(token))||''):text).replace(/^["']|["']$/g,'');name=path.basename(first).replace(/\.(exe|cmd)$/i,'')||'unknown';if(reportedSubprocesses.has(name)||reportedSubprocesses.size>=100)return;const file=first&&resolveCommand(first,options);trusted=!!file&&trustedExecutable(file,options);if(!trusted)trusted=localGit(name,shell?text.split(/\s+/).slice(1):(Array.isArray(args)?args:[]));}catch{trusted=false;}if(trusted||reportedSubprocesses.has(name)||reportedSubprocesses.size>=100)return;reportedSubprocesses.add(name);try{writeViolation({origin:('subprocess:'+name).slice(0,2048),reason:'unhooked-subprocess'});}catch{}}
137
+ // A package manager or task runner running a project script (pnpm run test, turbo run test) only launches it: the
138
+ // Node processes it starts inherit this hook through NODE_OPTIONS and are checked themselves. Installing or downloading
139
+ // (install, add, dlx) reaches the network, so it is not trusted.
140
+ const LAUNCHERS=/^(pnpm|pnpm-native|yarn|npm|npx|corepack|turbo)$/;
141
+ function scriptLauncher(name,words){if(!LAUNCHERS.test(name))return false;const plain=words.map(String).filter(w=>!w.startsWith('-'));if(plain.some(w=>/^(install|i|add|ci|dlx|create|init|publish|update|up|upgrade)$/.test(w)))return false;return plain.some(w=>/^(run|run-script|exec|test|t)$/.test(w));}
142
+ // npm runs a script as sh -c "<script>": judge the command the script runs (vitest, a Node CLI), not the shell itself.
143
+ const SHELLS=/^(sh|bash|dash|zsh)$/;
144
+ // A shell script is judged one command at a time (cd x && vitest run): builtins run nothing, exec X runs X.
145
+ const BUILTINS=/^(cd|export|set|unset|true|false|echo|printf|exit|test|\[|:|source|\.|shift|umask|wait|trap|type|command|pwd|read)$/;
146
+ function shellSegments(text){return String(text).split(/&&|\|\||;|\||\n/).map(t=>t.trim().replace(/^exec\s+/,'').replace(/^\(+|\)+$/g,'').trim()).filter(Boolean);}
147
+ // Tools that only read local state: Jest asks watchman which files changed.
148
+ // Local tools are trusted only from the system's own folders, never a same-named file inside the project.
149
+ const SYSTEM_DIRS=/^\/(usr\/(local\/)?)?s?bin$|^\/opt\/homebrew\/bin$/;
150
+ const LOCAL_TOOLS=/^(watchman|sleep|cat|ls|cp|mv|rm|mkdir|rmdir|touch|ln|chmod|readlink|realpath|mktemp|basename|dirname|head|tail|wc|sort|uniq|cut|tr|tee|grep|egrep|date|which|uname|printenv|diff|cmp|gzip|gunzip|zcat|seq|yes|nproc|id|whoami|hostname|stat|du|df|kill|ps|true|false)$/;
151
+ function checkExecutable(command,shell,options,args){if(!shell&&SHELLS.test(path.basename(String(command)))&&Array.isArray(args)&&args[0]==='-c'&&typeof args[1]==='string'){for(const part of shellSegments(args[1])){const word=(part.split(/\s+/).find(t=>!/^[A-Za-z_][A-Za-z0-9_]*=/.test(t))||'');if(word&&!BUILTINS.test(word))checkExecutable(part,true,options,[]);}return;}if(shell&&/&&|\|\||;|\|/.test(String(command))){for(const part of shellSegments(command)){const word=(part.split(/\s+/).find(t=>!/^[A-Za-z_][A-Za-z0-9_]*=/.test(t))||'');if(word&&!BUILTINS.test(word)&&part!==String(command).trim())checkExecutable(part,true,options,[]);}return;}{const tool=String(command).trim().split(/\s+/).find(t=>!/^[A-Za-z_][A-Za-z0-9_]*=/.test(t))||'';if(LOCAL_TOOLS.test(path.basename(tool))){let where='';try{where=resolveCommand(tool,options)||'';}catch{}if(tool==='watchman'||SYSTEM_DIRS.test(path.dirname(where)))return;}}let name='unknown',trusted=false;try{const text=String(command).trim();const first=(shell?(text.split(/\s+/).find(token=>!/^[A-Za-z_][A-Za-z0-9_]*=/.test(token))||''):text).replace(/^["']|["']$/g,'');name=path.basename(first).replace(/\.(exe|cmd)$/i,'')||'unknown';if(reportedSubprocesses.has(name)||reportedSubprocesses.size>=100)return;const file=first&&resolveCommand(first,options);trusted=!!file&&trustedExecutable(file,options);if(!trusted){const words=shell?text.split(/\s+/).slice(1):(Array.isArray(args)?args:[]);trusted=localGit(name,words)||scriptLauncher(name,words);}}catch{trusted=false;}if(trusted||reportedSubprocesses.has(name)||reportedSubprocesses.size>=100)return;reportedSubprocesses.add(name);try{writeViolation({origin:('subprocess:'+name).slice(0,2048),reason:'unhooked-subprocess'});}catch{}}
137
152
  // Puts the hooked env into the options argument at index i, inserting an options object when there is none.
138
153
  function withOptions(args,i){const out=[...args];const o=out[i];if(o&&typeof o==='object'&&!Array.isArray(o))out[i]=hookedEnv(o);else out.splice(Math.min(i,out.length),o==null&&i<out.length?1:0,hookedEnv({}));return out;}
139
154
  for(const name of ['spawn','spawnSync','execFile','execFileSync','fork']){const original=childProcess[name];if(typeof original!=='function')continue;childProcess[name]=function(file,...rest){const optionsAt=Array.isArray(rest[0])||(rest[0]==null&&rest.length>1)?2:1;const patched=withOptions([file,...rest],optionsAt);if(name!=='fork')checkExecutable(file,!!patched[optionsAt].shell,patched[optionsAt],Array.isArray(rest[0])?rest[0]:[]);return original.apply(this,patched);};}
@@ -300,11 +315,50 @@ function subscriptionItemOperation(method, id, params, data) {
300
315
  item.quantity = quantity;
301
316
  return { status: 200, body: item, collection, record: structuredClone(item), operation: "write" };
302
317
  }
318
+ function chargeCreate(params, data, sequence) {
319
+ const collection = "/v1/charges", charges = data[collection];
320
+ if (!charges) return void 0;
321
+ const allowed = ["amount", "currency", "source", "customer", "description", "receipt_email", "capture", "statement_descriptor"];
322
+ if (Object.keys(params).some((k) => !allowed.includes(k) && !/^metadata\[[^\]]+\]$/.test(k) && k !== "metadata")) return void 0;
323
+ const amount = Number(params.amount);
324
+ if (params.amount === void 0) return { ...stripeError(400, "parameter_missing", "Missing required param: amount.", "amount"), collection };
325
+ if (!Number.isInteger(amount) || amount < 50) return { ...stripeError(400, "amount_too_small", "Amount must be at least 50 cents", "amount"), collection };
326
+ if (typeof params.currency !== "string" || !params.currency) return { ...stripeError(400, "parameter_missing", "Missing required param: currency.", "currency"), collection };
327
+ if (params.source === void 0 && params.customer === void 0) return { ...stripeError(400, "parameter_missing", "Must provide source or customer.", "source"), collection };
328
+ if (params.source === "tok_chargeDeclined") {
329
+ const declined = stripeError(402, "card_declined", "Your card was declined.", "source");
330
+ declined.body.error.type = "card_error";
331
+ return { ...declined, collection };
332
+ }
333
+ const charge = {
334
+ id: nextId(charges, "ch", sequence),
335
+ object: "charge",
336
+ amount,
337
+ amount_refunded: 0,
338
+ amount_captured: params.capture === "false" || params.capture === false ? 0 : amount,
339
+ currency: params.currency.toLowerCase(),
340
+ customer: params.customer ?? null,
341
+ description: params.description ?? null,
342
+ receipt_email: params.receipt_email ?? null,
343
+ metadata: metadataOf(params),
344
+ payment_intent: null,
345
+ captured: !(params.capture === "false" || params.capture === false),
346
+ paid: true,
347
+ refunded: false,
348
+ status: "succeeded",
349
+ created: twinNowSeconds(17e8),
350
+ livemode: false,
351
+ payment_method_details: { type: "card", card: { brand: "visa", last4: "4242" } }
352
+ };
353
+ charges.push(charge);
354
+ return { status: 200, body: charge, collection, operation: "write" };
355
+ }
303
356
  function stripeOperation(method, path, params, data, sequence) {
304
357
  const item = /^\/v1\/subscription_items\/([^/]+)$/.exec(path);
305
358
  if (item) return subscriptionItemOperation(method, item[1], params, data);
306
359
  const error = stripeError;
307
360
  const other = /^\/v1\/(refunds|charges|events)(?:\/([^/]+))?$/.exec(path);
361
+ if (other?.[1] === "charges" && method === "POST" && !other[2]) return chargeCreate(params, data, sequence);
308
362
  if (other) return other[1] === "refunds" ? refundOperation(method, other[2], params, data, sequence) : readOnlyOperation(method, other[1], other[2], params, data);
309
363
  const match = /^\/v1\/(customers|payment_intents)(?:\/([^/]+))?(?:\/(confirm))?$/.exec(path);
310
364
  if (!match || !["GET", "POST"].includes(method)) return void 0;
@@ -3576,7 +3630,7 @@ function normalizeSeed(seed) {
3576
3630
  return createHash4("sha256").update(text2).digest("hex").slice(0, 32);
3577
3631
  }
3578
3632
  function faultOrdinals(selection, seed) {
3579
- const count = selection.type === "timeout-after-write" ? 1 : selection.count ?? 1;
3633
+ const count = selection.type === "timeout-after-write" || selection.type === "lost-reply" ? 1 : selection.count ?? 1;
3580
3634
  if (selection.schedule === "first") return Array.from({ length: Math.min(count, FAULT_SCHEDULE_WINDOW) }, (_, i) => i);
3581
3635
  const stream = new SeedStream(seed, `fault:${selection.type}:${selection.service}:${selection.path}`);
3582
3636
  const all = Array.from({ length: FAULT_SCHEDULE_WINDOW }, (_, i) => i);
@@ -5268,7 +5322,7 @@ function parseWorld(value) {
5268
5322
  if (!Array.isArray(v.files) || !v.files.length || v.files.length > 100 || !v.files.every((f) => typeof f === "string" && f.length > 0)) invalid("files must explicitly list 1\u2013100 application files");
5269
5323
  if (new Set(v.files).size !== v.files.length) invalid("files must be unique");
5270
5324
  if (!Array.isArray(v.command) || !v.command.length || !v.command.every((c) => typeof c === "string" && c.length > 0) || !RUNTIMES.test(v.command[0])) invalid("command must be an argv array starting with node, python, python3, uv, poetry, go, ruby, bundle, deno, bun or curl");
5271
- if (!Number.isInteger(v.timeoutSeconds) || Number(v.timeoutSeconds) < 1 || Number(v.timeoutSeconds) > 300) invalid("timeoutSeconds must be 1\u2013300");
5325
+ if (!Number.isInteger(v.timeoutSeconds) || Number(v.timeoutSeconds) < 1 || Number(v.timeoutSeconds) > 3600) invalid("timeoutSeconds must be 1\u20133600");
5272
5326
  if (v.workflowId !== void 0 && (typeof v.workflowId !== "string" || !v.workflowId)) invalid("workflowId must be a nonempty string");
5273
5327
  if (v.sourceBuild !== void 0 && (typeof v.sourceBuild !== "string" || !/^[a-f0-9]{64}$/.test(v.sourceBuild))) invalid("sourceBuild must be a SHA-256 build-record digest");
5274
5328
  if (v.twinClock !== void 0 && !validTwinClock(v.twinClock)) invalid("twinClock requires only now as a canonical UTC timestamp with milliseconds");
@@ -5340,7 +5394,7 @@ function parseWorld(value) {
5340
5394
  }
5341
5395
  }
5342
5396
  if (v.fault !== void 0) {
5343
- if (!object2(v.fault) || !(known2(v.fault) || requestPathFaults.has(String(v.fault.service)) && typeof v.fault.path === "string" && /^\/[a-zA-Z0-9_.:/-]+$/.test(v.fault.path) && !v.fault.path.includes("//")) || !FAULT_TYPES.includes(v.fault.type)) invalid("fault requires an existing service/path and a supported type: timeout-after-write, blackhole, server-error, duplicate-write or slow-response");
5397
+ if (!object2(v.fault) || !(known2(v.fault) || requestPathFaults.has(String(v.fault.service)) && typeof v.fault.path === "string" && /^\/[a-zA-Z0-9_.:/-]+$/.test(v.fault.path) && !v.fault.path.includes("//")) || !FAULT_TYPES.includes(v.fault.type)) invalid("fault requires an existing service/path and a supported type: timeout-after-write, lost-reply, blackhole, server-error, duplicate-write or slow-response");
5344
5398
  const f = v.fault;
5345
5399
  const allowed = ["service", "path", "type"];
5346
5400
  const count = f.count, windowMs = f.windowMs;
@@ -5358,7 +5412,7 @@ function parseWorld(value) {
5358
5412
  if (["blackhole", "duplicate-write", "slow-response"].includes(f.type)) allowed.push("count");
5359
5413
  }
5360
5414
  if (f.schedule !== void 0) {
5361
- if (f.type === "timeout-after-write" || !["seeded", "first"].includes(f.schedule)) invalid(`${f.type} fault does not take schedule ${String(f.schedule)}; use seeded or first`);
5415
+ if (f.type === "timeout-after-write" || f.type === "lost-reply" || !["seeded", "first"].includes(f.schedule)) invalid(`${f.type} fault does not take schedule ${String(f.schedule)}; use seeded or first`);
5362
5416
  allowed.push("schedule");
5363
5417
  }
5364
5418
  if (Object.keys(f).some((k) => !allowed.includes(k))) invalid(`unknown fault field for ${f.type}`);
@@ -5517,7 +5571,7 @@ var init_spec = __esm({
5517
5571
  // Enterprise twins: any subset of their optional collections; Snowflake tables are free-form.
5518
5572
  ...Object.fromEntries(ENTERPRISE_ADAPTERS.filter((a) => !FREEFORM_COLLECTION_ADAPTERS.includes(a)).map((a) => [a, []]))
5519
5573
  };
5520
- FAULT_TYPES = ["timeout-after-write", "blackhole", "server-error", "duplicate-write", "slow-response"];
5574
+ FAULT_TYPES = ["timeout-after-write", "lost-reply", "blackhole", "server-error", "duplicate-write", "slow-response"];
5521
5575
  PROPERTY_KINDS = ["unique-per-act", "no-loss", "effect-count"];
5522
5576
  RESERVED_ENV = /^(PATH|NODE_OPTIONS|AGENTTWIN_.*|DATABASE_URL|POSTGRES_URL|PG_URL|PG(HOST|PORT|USER|PASSWORD|DATABASE|SSLMODE)|REDIS_(URL|HOST|PORT|TLS_URL)|REDISHOST|REDISPORT|KV_URL|HTTPS?_PROXY|ALL_PROXY|NO_PROXY|SSL_CERT_FILE|REQUESTS_CA_BUNDLE|CURL_CA_BUNDLE|NODE_EXTRA_CA_CERTS|GRPC_DEFAULT_SSL_ROOTS_FILE_PATH)$/i;
5523
5577
  isServerPath = (path) => typeof path === "string" && path.length <= 4096 && path.startsWith("/") && !path.startsWith("//") && !path.includes("\\") && !/[\u0000-\u001f\u007f]/.test(path);
@@ -6016,8 +6070,9 @@ function seedActions(service, collections, at, tenant = {}) {
6016
6070
  for (const c of collections) {
6017
6071
  const last = c.path.split("/").filter(Boolean).pop() ?? "record", type = singular2(last.replace(/-/g, "_"));
6018
6072
  c.seed.forEach((row, i) => {
6019
- const id = typeof row.id === "string" && row.id ? row.id : `${type}_seed_${i + 1}`;
6020
- const fields = { ...tenant, ...Object.fromEntries(Object.entries(row).filter(([k]) => k !== "id")) };
6073
+ const numeric = typeof row.id === "number" && Number.isSafeInteger(row.id);
6074
+ const id = numeric ? String(row.id) : typeof row.id === "string" && row.id ? row.id : `${type}_seed_${i + 1}`;
6075
+ const fields = { ...tenant, ...numeric ? { id: row.id } : {}, ...Object.fromEntries(Object.entries(row).filter(([k]) => k !== "id")) };
6021
6076
  lines.push(JSON.stringify({ id: `twin:${service}:${type}.create:${id}:${at}:seed${i + 1}`, service, op: "set", operation: `${type}.create`, subject: { type, id }, occurredAt: at, actor: { kind: "system" }, fields }));
6022
6077
  });
6023
6078
  }
@@ -6529,6 +6584,12 @@ var init_http_world = __esm({
6529
6584
  respond(result.status, result.body, headers(result));
6530
6585
  }, fault.delayMs);
6531
6586
  this.timers.add(timer);
6587
+ } else if (!this.fired && result.operation === "write" && fault?.type === "lost-reply" && fault.service === service.name && (fault.path === result.collection || matchesFault(normalPath(req.url ?? "/", req.method)))) {
6588
+ this.fired = true;
6589
+ this.faultActions++;
6590
+ this.record(service.name, "fault", result.collection, "write committed; reply lost (connection closed before the response)");
6591
+ this.keyed(keyHeader2);
6592
+ res.socket?.destroy();
6532
6593
  } else respondSlowly(result.collection, result.operation ?? "request", result.status, result.body, headers(result));
6533
6594
  if (deliveries.length) this.push(service.name, deliveries, epoch);
6534
6595
  return;
@@ -6655,6 +6716,12 @@ var init_http_world = __esm({
6655
6716
  respond(faultResponse, reply);
6656
6717
  }, fault.delayMs);
6657
6718
  this.timers.add(timer);
6719
+ } else if (!this.fired && fault?.type === "lost-reply" && fault.service === service.name && fault.path === path) {
6720
+ this.fired = true;
6721
+ this.faultActions++;
6722
+ this.record(service.name, "fault", path, "write committed; reply lost (connection closed before the response)");
6723
+ this.keyed(keyHeader);
6724
+ res.socket?.destroy();
6658
6725
  } else respondSlowly(path, "write", faultResponse, reply);
6659
6726
  } catch {
6660
6727
  respond(500, { error: "world_request_error" });
@@ -7016,6 +7083,12 @@ var init_http_world = __esm({
7016
7083
  this.record(service.name, "fault", target, `write committed; response delayed ${fault.delayMs}ms`);
7017
7084
  this.keyed(requestKey);
7018
7085
  later(fault.delayMs, () => send(first.status, out, first.bytes));
7086
+ } else if (target && !this.fired && fault?.type === "lost-reply" && fault.service === service.name && (matchesFault(target) || matchesFault(path))) {
7087
+ this.fired = true;
7088
+ this.faultActions++;
7089
+ this.record(service.name, "fault", target, "write committed; reply lost (connection closed before the response)");
7090
+ this.keyed(requestKey);
7091
+ res.socket?.destroy();
7019
7092
  } else if (fault?.type === "slow-response" && faultOrdinalsFor && (matchesFault(target ?? path) || matchesFault(path)) && faultOrdinalsFor.includes(this.candidateIndex(faultKey))) {
7020
7093
  this.faultActions++;
7021
7094
  this.record(service.name, "fault", target ?? path, `slow-response: ${target ? "write" : "request"} applied; response delayed ${fault.delayMs}ms`);
@@ -7179,6 +7252,31 @@ var init_node_options = __esm({
7179
7252
  }
7180
7253
  });
7181
7254
 
7255
+ // src/flow/setup.ts
7256
+ import { spawn as spawn2, spawnSync } from "child_process";
7257
+ import { existsSync as existsSync3, mkdirSync, readFileSync as readFileSync2, readdirSync as readdirSync3 } from "fs";
7258
+ import { delimiter as delimiter2, join as join7, posix } from "path";
7259
+ var init_setup = __esm({
7260
+ "src/flow/setup.ts"() {
7261
+ "use strict";
7262
+ }
7263
+ });
7264
+
7265
+ // src/flow/node-runtime.ts
7266
+ import { spawnSync as spawnSync2 } from "child_process";
7267
+ import { createHash as createHash8 } from "crypto";
7268
+ import { existsSync as existsSync4, mkdirSync as mkdirSync2, readFileSync as readFileSync3, renameSync, rmSync, writeFileSync } from "fs";
7269
+ import { homedir } from "os";
7270
+ import { delimiter as delimiter3, join as join8 } from "path";
7271
+ var chosen, appNode;
7272
+ var init_node_runtime = __esm({
7273
+ "src/flow/node-runtime.ts"() {
7274
+ "use strict";
7275
+ init_setup();
7276
+ appNode = () => chosen ?? process.execPath;
7277
+ }
7278
+ });
7279
+
7182
7280
  // src/runtime/application-process.ts
7183
7281
  import { execFile as execFile2 } from "child_process";
7184
7282
  import { promisify as promisify2 } from "util";
@@ -7384,14 +7482,14 @@ var init_browser_process_windows = __esm({
7384
7482
  // src/runtime/browser-process.ts
7385
7483
  import { mkdtemp as mkdtemp4, writeFile as writeFile4, readFile, rm as rm4 } from "fs/promises";
7386
7484
  import { tmpdir as tmpdir4 } from "os";
7387
- import { join as join7 } from "path";
7485
+ import { join as join9 } from "path";
7388
7486
  import { execFile as execFile4 } from "child_process";
7389
7487
  import { promisify as promisify4 } from "util";
7390
7488
  async function ownBrowserProcess(executable) {
7391
7489
  if (process.platform === "win32") return withCleanup(windowsBrowserProcess(executable), async () => {
7392
7490
  });
7393
- const root = await mkdtemp4(join7(tmpdir4(), "agenttwin-browser-owner-"));
7394
- const pidFile = join7(root, "pid"), launcher = join7(root, "launch");
7491
+ const root = await mkdtemp4(join9(tmpdir4(), "agenttwin-browser-owner-"));
7492
+ const pidFile = join9(root, "pid"), launcher = join9(root, "launch");
7395
7493
  await writeFile4(launcher, `#!/bin/sh
7396
7494
  echo $$ > ${quote(pidFile)}
7397
7495
  exec ${quote(executable)} "$@"
@@ -7493,11 +7591,11 @@ var init_browser_process = __esm({
7493
7591
  // src/runtime/browser-directories.ts
7494
7592
  import { mkdtemp as mkdtemp5, mkdir as mkdir2, chown, chmod, rm as rm5 } from "fs/promises";
7495
7593
  import { tmpdir as tmpdir5 } from "os";
7496
- import { join as join8 } from "path";
7594
+ import { join as join10 } from "path";
7497
7595
  async function createBrowserDirectories(identity) {
7498
7596
  if (!Number.isSafeInteger(identity.uid) || identity.uid < 0 || !Number.isSafeInteger(identity.gid) || identity.gid < 0) throw new Error("Invalid browser identity");
7499
- const root = await mkdtemp5(join8(tmpdir5(), "agenttwin-browser-"));
7500
- const profile = join8(root, "profile"), artifacts = join8(root, "artifacts");
7597
+ const root = await mkdtemp5(join10(tmpdir5(), "agenttwin-browser-"));
7598
+ const profile = join10(root, "profile"), artifacts = join10(root, "artifacts");
7501
7599
  const close = () => rm5(root, { recursive: true, force: true });
7502
7600
  try {
7503
7601
  await mkdir2(profile, { mode: 448 });
@@ -8124,7 +8222,7 @@ var init_contracts = __esm({
8124
8222
 
8125
8223
  // src/runtime/cost-model.ts
8126
8224
  import { readFile as readFile2, writeFile as writeFile5 } from "fs/promises";
8127
- import { join as join9 } from "path";
8225
+ import { join as join11 } from "path";
8128
8226
  var init_cost_model = __esm({
8129
8227
  "src/runtime/cost-model.ts"() {
8130
8228
  "use strict";
@@ -8142,7 +8240,7 @@ var init_run_summary = __esm({
8142
8240
  });
8143
8241
 
8144
8242
  // src/runtime/generic-calls.ts
8145
- import { createHash as createHash8 } from "crypto";
8243
+ import { createHash as createHash9 } from "crypto";
8146
8244
  function canonical2(value) {
8147
8245
  return Array.isArray(value) ? `[${value.map(canonical2).join(",")}]` : value && typeof value === "object" ? `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonical2(value[k])}`).join(",")}}` : JSON.stringify(value ?? null);
8148
8246
  }
@@ -8218,7 +8316,10 @@ function callsFromWorldEvents(events, tierOf = () => void 0) {
8218
8316
  else if (e.operation === "auth-denied") calls.push(base("POST", e.path.split("?")[0], { outcome: "unauthorized", committed: false }));
8219
8317
  else if (e.operation === "fault") {
8220
8318
  const prior = last(e.service), method = /\((POST|PUT|PATCH|DELETE|GET)\)\s*$/.exec(e.detail)?.[1];
8221
- if (/^write committed|^slow-response: write/.test(e.detail) && prior) {
8319
+ if (/^write committed; reply lost/.test(e.detail) && prior) {
8320
+ prior.outcome = "lost-response";
8321
+ prior.committed = true;
8322
+ } else if (/^write committed|^slow-response: write/.test(e.detail) && prior) {
8222
8323
  prior.outcome = "timeout";
8223
8324
  prior.committed = true;
8224
8325
  } else if (/^duplicate-write: (one write committed as two|a single write was delivered twice)/.test(e.detail) && prior) prior.duplicated = true;
@@ -8274,7 +8375,7 @@ function faultWords(c) {
8274
8375
  }
8275
8376
  function genericChecks(calls, opts = {}) {
8276
8377
  const out = [], covered = opts.covered ?? (() => false);
8277
- const ordered = [...calls].sort((a, b) => a.sequence - b.sequence), writes = ordered.filter((c) => c.isWrite && c.outcome !== "blocked");
8378
+ const ordered = [...calls].sort((a, b) => a.sequence - b.sequence), writes = ordered.filter((c) => c.isWrite && c.outcome !== "blocked" && !TWIN_CONTROL.test(c.path));
8278
8379
  const claims = opts.claims ?? claimsOf(ordered, opts.output);
8279
8380
  const announcementSeqs = new Set(claims.map((c) => c.via).filter((v) => v !== void 0));
8280
8381
  for (const group of groupsOf(writes)) {
@@ -8418,7 +8519,7 @@ function genericWorldChecks(covers) {
8418
8519
  }
8419
8520
  }));
8420
8521
  }
8421
- var WRITE_METHODS, READ_LIKE, MODEL_HOST, VOLATILE, KEY_HEADERS, KEY_FIELDS, digest, stable, idLike, outcomeOf, parseSource, SUCCESS, FAILURE, TEXT_FIELDS, MESSAGING, polarityOf, RECIPIENT, isAnnouncement, AMOUNT, times, FAILED, AMBIGUOUS, label, sameRequest, succeeded, effects, sites, groupsOf, GENERIC_TITLES;
8522
+ var WRITE_METHODS, READ_LIKE, MODEL_HOST, VOLATILE, KEY_HEADERS, KEY_FIELDS, digest, stable, idLike, outcomeOf, parseSource, SUCCESS, FAILURE, TEXT_FIELDS, MESSAGING, polarityOf, RECIPIENT, isAnnouncement, AMOUNT, times, FAILED, AMBIGUOUS, label, sameRequest, succeeded, effects, sites, TWIN_CONTROL, groupsOf, GENERIC_TITLES;
8422
8523
  var init_generic_calls = __esm({
8423
8524
  "src/runtime/generic-calls.ts"() {
8424
8525
  "use strict";
@@ -8429,7 +8530,7 @@ var init_generic_calls = __esm({
8429
8530
  VOLATILE = /^(id|ts|created|created_at|updated_at|createdAt|updatedAt|timestamp|request_id|requestId|nonce|uuid|sequence|object|livemode)$|_at$/;
8430
8531
  KEY_HEADERS = ["idempotency-key", "x-idempotency-key", "x-request-id", "x-amz-client-token"];
8431
8532
  KEY_FIELDS = /^(idempotency_?key|ClientToken|ClientRequestToken|MessageDeduplicationId|client_token|request_id)$/i;
8432
- digest = (value) => `sha256:${createHash8("sha256").update(typeof value === "string" ? value : canonical2(value)).digest("hex").slice(0, 16)}`;
8533
+ digest = (value) => `sha256:${createHash9("sha256").update(typeof value === "string" ? value : canonical2(value)).digest("hex").slice(0, 16)}`;
8433
8534
  stable = (value) => Array.isArray(value) ? value.map(stable) : value && typeof value === "object" ? Object.fromEntries(Object.entries(value).filter(([k]) => !VOLATILE.test(k) && !KEY_FIELDS.test(k)).map(([k, v]) => [k, stable(v)])) : value;
8434
8535
  idLike = (segment) => /^\d+$/.test(segment) || /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(segment) || segment.length >= 3 && /\d/.test(segment) && /^[A-Za-z0-9_\-:.]+$/.test(segment) && !/^v\d+(\.\d+)*$/i.test(segment) && !/^\d{4}-\d{2}-\d{2}$/.test(segment) && !/^[A-Za-z]+\.(json|xml)$/.test(segment);
8435
8536
  outcomeOf = (status) => status === void 0 ? "ok" : status === 401 || status === 403 ? "unauthorized" : status === 429 ? "rate-limited" : status >= 500 ? "server-error" : status >= 400 ? "client-error" : "ok";
@@ -8459,6 +8560,7 @@ var init_generic_calls = __esm({
8459
8560
  succeeded = (c) => c.outcome === "ok" || c.outcome === "replayed";
8460
8561
  effects = (c) => c.committed === false || c.outcome === "replayed" || c.outcome === "blocked" ? 0 : (c.committed || c.outcome === "ok" ? 1 : 0) * (c.duplicated ? 2 : 1);
8461
8562
  sites = (calls) => [...new Map(calls.filter((c) => c.source).map((c) => [`${c.source.file}:${c.source.line}`, c.source])).values()];
8563
+ TWIN_CONTROL = /(^|\/)_twin\//;
8462
8564
  groupsOf = (writes) => {
8463
8565
  const groups2 = [];
8464
8566
  for (const c of writes) {
@@ -8504,12 +8606,17 @@ function groups(items, key2) {
8504
8606
  }
8505
8607
  return [...out.values()].filter((g) => g.length > 1);
8506
8608
  }
8507
- function faultPhrase(ctx) {
8609
+ function faultPhrase(ctx, evidence) {
8508
8610
  if (ctx.duplicateDelivery) return " when the triggering webhook was delivered twice";
8509
8611
  const f = ctx.fault;
8510
- if (!f || f.triggered === false || !ctx.events.some((e) => e.operation === "fault")) return "";
8612
+ const faults = ctx.events.filter((e) => e.operation === "fault" && (!f?.service || e.service === f.service)).map((e) => e.sequence);
8613
+ if (!f || f.triggered === false || !faults.length) return "";
8614
+ if (evidence?.length) {
8615
+ const caused = f.type === "duplicate-write" ? faults.some((at) => evidence.some((w) => w < at)) : faults.some((at) => evidence.some((w) => w > at) && (!(f.type === "timeout-after-write" || f.type === "lost-reply" || f.type === "slow-response") || evidence.some((w) => w < at)));
8616
+ if (!caused) return "";
8617
+ }
8511
8618
  const who = displayName(ctx.services, f.service);
8512
- return f.type === "timeout-after-write" ? ` when ${who} timed out after saving the write` : f.type === "server-error" ? ` when ${who} returned a 500` : f.type === "slow-response" ? ` when ${who} answered slower than your client timeout` : f.type === "blackhole" ? ` when ${who} dropped a request` : f.type === "duplicate-write" ? ` when ${who} received the same request twice` : ` when ${who} failed`;
8619
+ return f.type === "timeout-after-write" ? ` when ${who} timed out after saving the write` : f.type === "lost-reply" ? ` when ${who} saved the write and the connection closed before the reply` : f.type === "server-error" ? ` when ${who} returned a 500` : f.type === "slow-response" ? ` when ${who} answered slower than your client timeout` : f.type === "blackhole" ? ` when ${who} dropped a request` : f.type === "duplicate-write" ? ` when ${who} received the same request twice` : ` when ${who} failed`;
8513
8620
  }
8514
8621
  function messageChecks(adapter, path) {
8515
8622
  const noun = adapter === "slack" ? "Slack message" : "email", name = PROVIDER[adapter];
@@ -8529,7 +8636,7 @@ function messageChecks(adapter, path) {
8529
8636
  return groups(addedRows(rowsOf(ctx.initialState, s, path), rowsOf(ctx.finalState, s, path)), signature).map((group) => ({
8530
8637
  path,
8531
8638
  actual: { messages: group.map((r) => r.id), to: target(group[0]), text: text2(group[0]).slice(0, 200) },
8532
- finding: `Your agent sent the same ${noun} to ${target(group[0])} ${times2(group.length)}${faultPhrase(ctx)}`,
8639
+ finding: `Your agent sent the same ${noun} to ${target(group[0])} ${times2(group.length)}${faultPhrase(ctx, writeSequences(ctx, s, group.map((r) => r.id)))}`,
8533
8640
  impact: { count: group.length - 1 },
8534
8641
  evidence: writeSequences(ctx, s, group.map((r) => r.id))
8535
8642
  }));
@@ -8604,7 +8711,7 @@ var init_default_checks = __esm({
8604
8711
  };
8605
8712
  rowsOf = (state, service, path) => (state?.[service]?.[path] ?? []).filter((r) => !!r && typeof r === "object" && !Array.isArray(r));
8606
8713
  VOLATILE2 = /* @__PURE__ */ new Set(["id", "ts", "created", "created_at", "updated_at", "inserted_at", "createdAt", "updatedAt", "internalDate", "historyId", "threadId", "number", "iid", "latest_charge", "object", "sequence", "uuid"]);
8607
- volatileKey = (key2) => VOLATILE2.has(key2) || /_at$|At$/.test(key2) || /^(?:sid|guid|etag|uri|self|href)$/i.test(key2) || /^date_|_date$|^(?:created|updated|modified|sent)(?:_on|_time|_date)?$/i.test(key2) || /^(?:ending|starting|running|resulting)_?balance$|^balance_?after$/i.test(key2);
8714
+ volatileKey = (key2) => VOLATILE2.has(key2) || /_at$|At$/.test(key2) || /^(?:sid|guid|etag|uri|self|href)$/i.test(key2) || /^date$|^date_|_date$|^(?:created|updated|modified|sent)(?:_on|_time|_date)?$/i.test(key2) || /^(?:ending|starting|running|resulting)_?balance$|^balance_?after$/i.test(key2);
8608
8715
  canonical3 = (value) => Array.isArray(value) ? `[${value.map(canonical3).join(",")}]` : value && typeof value === "object" ? `{${Object.keys(value).sort().map((k) => `${JSON.stringify(k)}:${canonical3(value[k])}`).join(",")}}` : JSON.stringify(value ?? null);
8609
8716
  contentSignature = (row, collection) => {
8610
8717
  const type = (collection?.split("/").filter(Boolean).pop() ?? "").toLowerCase().replace(/[^a-z]/g, "").replace(/ies$/, "y").replace(/s$/, "");
@@ -8632,7 +8739,7 @@ var init_default_checks = __esm({
8632
8739
  out.push({
8633
8740
  path: "/v1/refunds",
8634
8741
  actual: { charge: group[0].charge, refunds: group.map((r) => r.id), amount, currency },
8635
- finding: `Your agent refunded ${String(group[0].charge)} ${times2(group.length)} (${money(amount, currency)} each)${faultPhrase(ctx)}`,
8742
+ finding: `Your agent refunded ${String(group[0].charge)} ${times2(group.length)} (${money(amount, currency)} each)${faultPhrase(ctx, writeSequences(ctx, s, group.map((r) => r.id)))}`,
8636
8743
  impact: { amount: extra, currency, count: group.length - 1 },
8637
8744
  evidence: writeSequences(ctx, s, group.map((r) => r.id))
8638
8745
  });
@@ -8667,7 +8774,7 @@ var init_default_checks = __esm({
8667
8774
  out.push({
8668
8775
  path: "/v1/payment_intents",
8669
8776
  actual: { paymentIntents: group.map((r) => r.id), amount, currency, succeeded: succeeded2.length },
8670
- finding: `Your agent created ${times2(group.length)} the same ${money(amount, currency)} payment${group[0].customer ? ` for ${String(group[0].customer)}` : ""}${faultPhrase(ctx)}`,
8777
+ finding: `Your agent created ${times2(group.length)} the same ${money(amount, currency)} payment${group[0].customer ? ` for ${String(group[0].customer)}` : ""}${faultPhrase(ctx, writeSequences(ctx, s, group.map((r) => r.id)))}`,
8671
8778
  impact: { amount: amount * Math.max(0, succeeded2.length - 1), currency, count: group.length - 1 },
8672
8779
  evidence: writeSequences(ctx, s, group.map((r) => r.id))
8673
8780
  });
@@ -8680,7 +8787,7 @@ var init_default_checks = __esm({
8680
8787
  out.push({
8681
8788
  path: "/v1/subscriptions",
8682
8789
  actual: { subscriptions: group.map((r) => r.id), customer: group[0].customer },
8683
- finding: `Your agent subscribed ${String(group[0].customer)} ${times2(group.length)} to the same plan${faultPhrase(ctx)}`,
8790
+ finding: `Your agent subscribed ${String(group[0].customer)} ${times2(group.length)} to the same plan${faultPhrase(ctx, writeSequences(ctx, s, group.map((r) => r.id)))}`,
8684
8791
  impact: perPeriod > 0 ? { amount: perPeriod * (group.length - 1), currency, count: group.length - 1, summary: `billed ${money(perPeriod, currency)} extra every billing period` } : { kind: "data-integrity", count: group.length - 1 },
8685
8792
  evidence: writeSequences(ctx, s, group.map((r) => r.id))
8686
8793
  });
@@ -8690,7 +8797,7 @@ var init_default_checks = __esm({
8690
8797
  out.push({
8691
8798
  path: "/v1/customers",
8692
8799
  actual: { customers: group.map((r) => r.id), email: group[0].email },
8693
- finding: `Your agent created ${times2(group.length)} the Stripe customer ${String(group[0].email)}${faultPhrase(ctx)}`,
8800
+ finding: `Your agent created ${times2(group.length)} the Stripe customer ${String(group[0].email)}${faultPhrase(ctx, writeSequences(ctx, s, group.map((r) => r.id)))}`,
8694
8801
  impact: { kind: "data-integrity", count: group.length - 1 },
8695
8802
  evidence: writeSequences(ctx, s, group.map((r) => r.id))
8696
8803
  });
@@ -8848,7 +8955,7 @@ var init_default_checks = __esm({
8848
8955
  out.push({
8849
8956
  path,
8850
8957
  actual: { records: group.map((r) => r.id ?? null), count: group.length },
8851
- finding: `Your agent created the same ${s} ${label2.replace(/s$/, "")} ${times2(group.length)}${faultPhrase(ctx)}`,
8958
+ finding: `Your agent created the same ${s} ${label2.replace(/s$/, "")} ${times2(group.length)}${faultPhrase(ctx, seq)}`,
8852
8959
  impact: { count: group.length - 1 },
8853
8960
  evidence: seq
8854
8961
  });
@@ -8876,7 +8983,7 @@ import { execFile as execFile5 } from "child_process";
8876
8983
  import { mkdtemp as mkdtemp6, readFile as readFile3, rm as rm6, writeFile as writeFile6 } from "fs/promises";
8877
8984
  import { createServer as createServer4, request as httpRequest } from "http";
8878
8985
  import { tmpdir as tmpdir6 } from "os";
8879
- import { join as join10 } from "path";
8986
+ import { join as join12 } from "path";
8880
8987
  import { createSecureContext, TLSSocket } from "tls";
8881
8988
  import { promisify as promisify5 } from "util";
8882
8989
  function matchRoute(routes2, host, pathname) {
@@ -8901,7 +9008,7 @@ function rewrite(r, p) {
8901
9008
  return p;
8902
9009
  }
8903
9010
  async function runAuthority(dir) {
8904
- const ca = { key: join10(dir, "ca.key"), cert: join10(dir, "ca.pem") };
9011
+ const ca = { key: join12(dir, "ca.key"), cert: join12(dir, "ca.pem") };
8905
9012
  await run2("openssl", [
8906
9013
  "req",
8907
9014
  "-x509",
@@ -8932,7 +9039,7 @@ async function runAuthority(dir) {
8932
9039
  let ctx = contexts.get(host);
8933
9040
  if (!ctx) {
8934
9041
  ctx = (async () => {
8935
- const base = join10(dir, host.replace(/[^a-z0-9.-]/gi, "_"));
9042
+ const base = join12(dir, host.replace(/[^a-z0-9.-]/gi, "_"));
8936
9043
  await writeFile6(base + ".ext", `basicConstraints=critical,CA:FALSE
8937
9044
  keyUsage=critical,digitalSignature
8938
9045
  extendedKeyUsage=serverAuth
@@ -8951,7 +9058,7 @@ authorityKeyIdentifier=keyid,issuer
8951
9058
  };
8952
9059
  }
8953
9060
  async function startTwinProxy(routes2) {
8954
- const dir = await mkdtemp6(join10(tmpdir6(), "agenttwin-proxy-"));
9061
+ const dir = await mkdtemp6(join12(tmpdir6(), "agenttwin-proxy-"));
8955
9062
  const authority = await runAuthority(dir).catch((error) => {
8956
9063
  throw new Error(`The twin proxy needs the openssl command to make this run's certificate authority: ${error instanceof Error ? error.message : error}`);
8957
9064
  });
@@ -9070,7 +9177,7 @@ var init_twin_proxy = __esm({
9070
9177
  // src/runtime/twin-routing.ts
9071
9178
  import { mkdtemp as mkdtemp7, readFile as readFile4, rm as rm7, writeFile as writeFile7 } from "fs/promises";
9072
9179
  import { tmpdir as tmpdir7 } from "os";
9073
- import { join as join11 } from "path";
9180
+ import { join as join13 } from "path";
9074
9181
  function twinRoutes(services, world, models) {
9075
9182
  const routes2 = [];
9076
9183
  for (const service of services) {
@@ -9287,7 +9394,7 @@ require('node:module').syncBuiltinESMExports();
9287
9394
  });
9288
9395
 
9289
9396
  // src/runtime/engines/ws-bridge.ts
9290
- import { createHash as createHash9 } from "crypto";
9397
+ import { createHash as createHash10 } from "crypto";
9291
9398
  import { Duplex } from "stream";
9292
9399
  function bridgeWebSocket(socket, first, accept) {
9293
9400
  let buffer = first, upgraded = false;
@@ -9333,7 +9440,7 @@ function bridgeWebSocket(socket, first, accept) {
9333
9440
  socket.end("HTTP/1.1 400 Bad Request\r\nContent-Type: text/plain\r\nConnection: close\r\n\r\nThis port speaks Postgres, over TCP or a WebSocket upgrade.\n");
9334
9441
  return;
9335
9442
  }
9336
- const acceptKey = createHash9("sha1").update(key2 + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
9443
+ const acceptKey = createHash10("sha1").update(key2 + "258EAFA5-E914-47DA-95CA-C5AB0DC85B11").digest("base64");
9337
9444
  const protocol = headers.get("sec-websocket-protocol")?.split(",")[0]?.trim();
9338
9445
  socket.write(`HTTP/1.1 101 Switching Protocols\r
9339
9446
  Upgrade: websocket\r
@@ -9923,7 +10030,7 @@ var init_postgres = __esm({
9923
10030
 
9924
10031
  // src/runtime/local-engines.ts
9925
10032
  import { readFile as readFile5 } from "fs/promises";
9926
- import { join as join12 } from "path";
10033
+ import { join as join14 } from "path";
9927
10034
  async function evaluatePostgresAssertions(postgres2, assertions) {
9928
10035
  const results = [];
9929
10036
  for (const assertion of assertions) {
@@ -9949,7 +10056,7 @@ async function startLocalEngines(app, spec) {
9949
10056
  postgres2 = await startPostgresEngine({ extensions: spec.postgres.extensions });
9950
10057
  started.push(postgres2);
9951
10058
  if (spec.postgres.seedFile) {
9952
- const sql = await readFile5(join12(app, spec.postgres.seedFile), "utf8");
10059
+ const sql = await readFile5(join14(app, spec.postgres.seedFile), "utf8");
9953
10060
  try {
9954
10061
  await postgres2.seed({ sql });
9955
10062
  } catch (error) {
@@ -10088,7 +10195,7 @@ var init_server_steps = __esm({
10088
10195
  });
10089
10196
 
10090
10197
  // src/runtime/local.ts
10091
- import { spawn as spawn2 } from "child_process";
10198
+ import { spawn as spawn3 } from "child_process";
10092
10199
  import { realpath as realpath3 } from "fs/promises";
10093
10200
  import { dirname as dirname2, resolve as resolve3 } from "path";
10094
10201
  async function sourceRoot(app, spec) {
@@ -10127,7 +10234,7 @@ async function executeLocal(app, spec, signal, existingWorld, seed, extraEnv = {
10127
10234
  Object.assign(env, proxy.env, { HOME: process.env.HOME ?? "", LANG: process.env.LANG ?? "C.UTF-8", PYTHONUNBUFFERED: "1", PYTHONDONTWRITEBYTECODE: "1" });
10128
10235
  if (process.env.VIRTUAL_ENV) env.VIRTUAL_ENV = process.env.VIRTUAL_ENV;
10129
10236
  }
10130
- const child = node ? spawn2(process.execPath, ["--require", hook.path, ...spec.command.slice(1)], { cwd: app, env, stdio: ["ignore", "pipe", "pipe"], detached: process.platform !== "win32" }) : spawn2(spec.command[0], spec.command.slice(1), { cwd: app, env, stdio: ["ignore", "pipe", "pipe"], detached: process.platform !== "win32" });
10237
+ const child = node ? spawn3(appNode(), ["--require", hook.path, ...spec.command.slice(1)], { cwd: app, env, stdio: ["ignore", "pipe", "pipe"], detached: process.platform !== "win32" }) : spawn3(spec.command[0], spec.command.slice(1), { cwd: app, env, stdio: ["ignore", "pipe", "pipe"], detached: process.platform !== "win32" });
10131
10238
  child.stdout.on("data", (b) => {
10132
10239
  stdout = (stdout + b.toString()).slice(-65536);
10133
10240
  });
@@ -10244,6 +10351,7 @@ var init_local = __esm({
10244
10351
  "src/runtime/local.ts"() {
10245
10352
  "use strict";
10246
10353
  init_node_options();
10354
+ init_node_runtime();
10247
10355
  init_application_process();
10248
10356
  init_browser_process();
10249
10357
  init_twin_clock();
@@ -10263,9 +10371,9 @@ var init_local = __esm({
10263
10371
  });
10264
10372
 
10265
10373
  // src/runtime/scenarios.ts
10266
- import { createHash as createHash10 } from "crypto";
10374
+ import { createHash as createHash11 } from "crypto";
10267
10375
  import { mkdir as mkdir3, readFile as readFile6, readdir, writeFile as writeFile8 } from "fs/promises";
10268
- import { join as join13 } from "path";
10376
+ import { join as join15 } from "path";
10269
10377
  import { isDeepStrictEqual as isDeepStrictEqual4 } from "util";
10270
10378
  function parseScenario(value) {
10271
10379
  const fail = (detail) => {
@@ -10304,7 +10412,7 @@ function reference(ref) {
10304
10412
  }
10305
10413
  async function loadScenario(cwd, ref) {
10306
10414
  const { id, version } = reference(ref);
10307
- const path = join13(cwd, ".agenttwin/scenarios", id, `${version}.json`);
10415
+ const path = join15(cwd, ".agenttwin/scenarios", id, `${version}.json`);
10308
10416
  const bytes = await readFile6(path);
10309
10417
  if (bytes.length > 2 * 1024 * 1024) throw new Error("Scenario exceeds 2 MiB");
10310
10418
  const scenario = parseScenario(JSON.parse(bytes.toString()));
@@ -10324,7 +10432,7 @@ var init_scenarios = __esm({
10324
10432
  identifier = /^[a-z][a-z0-9_]{0,39}$/;
10325
10433
  object3 = (v) => !!v && typeof v === "object" && !Array.isArray(v);
10326
10434
  sort = (v) => Array.isArray(v) ? v.map(sort) : object3(v) ? Object.fromEntries(Object.keys(v).sort().map((k) => [k, sort(v[k])])) : v;
10327
- scenarioDigest = (scenario) => createHash10("sha256").update(JSON.stringify(sort(scenario))).digest("hex");
10435
+ scenarioDigest = (scenario) => createHash11("sha256").update(JSON.stringify(sort(scenario))).digest("hex");
10328
10436
  }
10329
10437
  });
10330
10438
 
@@ -10356,7 +10464,7 @@ var init_exit = __esm({
10356
10464
 
10357
10465
  // src/runtime/stage-worker.ts
10358
10466
  import { copyFile, rm as rm8 } from "fs/promises";
10359
- import { basename, dirname as dirname3, join as join14 } from "path";
10467
+ import { basename, dirname as dirname3, join as join16 } from "path";
10360
10468
  import { fileURLToPath as fileURLToPath2 } from "url";
10361
10469
  var init_stage_worker = __esm({
10362
10470
  "src/runtime/stage-worker.ts"() {
@@ -10373,8 +10481,8 @@ var init_offline = __esm({
10373
10481
  });
10374
10482
 
10375
10483
  // src/runtime/credentials.ts
10376
- import { homedir } from "os";
10377
- import { join as join15 } from "path";
10484
+ import { homedir as homedir2 } from "os";
10485
+ import { join as join17 } from "path";
10378
10486
  import { readFile as readFile7, mkdir as mkdir4, writeFile as writeFile9, chmod as chmod2, rm as rm9 } from "fs/promises";
10379
10487
  var init_credentials = __esm({
10380
10488
  "src/runtime/credentials.ts"() {
@@ -10384,7 +10492,7 @@ var init_credentials = __esm({
10384
10492
 
10385
10493
  // src/runtime/remote.ts
10386
10494
  import { readFile as readFile8 } from "fs/promises";
10387
- import { join as join16 } from "path";
10495
+ import { join as join18 } from "path";
10388
10496
  var init_remote = __esm({
10389
10497
  "src/runtime/remote.ts"() {
10390
10498
  "use strict";
@@ -10407,7 +10515,7 @@ var init_docker_engine = __esm({
10407
10515
 
10408
10516
  // src/runtime/docker-postgres.ts
10409
10517
  import postgres from "postgres";
10410
- import { execFile as execFile7, spawn as spawn3 } from "child_process";
10518
+ import { execFile as execFile7, spawn as spawn4 } from "child_process";
10411
10519
  import { promisify as promisify7, isDeepStrictEqual as isDeepStrictEqual5 } from "util";
10412
10520
  import { randomBytes as randomBytes3, randomUUID as randomUUID4 } from "crypto";
10413
10521
  import { Duplex as Duplex2 } from "stream";
@@ -10431,11 +10539,11 @@ var init_stdio_fetch = __esm({
10431
10539
  });
10432
10540
 
10433
10541
  // src/runtime/docker.ts
10434
- import { execFile as execFile8, spawn as spawn4 } from "child_process";
10542
+ import { execFile as execFile8, spawn as spawn5 } from "child_process";
10435
10543
  import { promisify as promisify8 } from "util";
10436
10544
  import { chmod as chmod3, copyFile as copyFile2, mkdir as mkdir5, mkdtemp as mkdtemp8, readFile as readFile9, rm as rm10, writeFile as writeFile10 } from "fs/promises";
10437
10545
  import { tmpdir as tmpdir8 } from "os";
10438
- import { join as join17 } from "path";
10546
+ import { join as join19 } from "path";
10439
10547
  import { randomUUID as randomUUID5 } from "crypto";
10440
10548
  var exec7;
10441
10549
  var init_docker = __esm({
@@ -10489,7 +10597,7 @@ var init_git = __esm({
10489
10597
 
10490
10598
  // src/runtime/hosted-packs.ts
10491
10599
  import { readFile as readFile10, readdir as readdir2 } from "fs/promises";
10492
- import { join as join18 } from "path";
10600
+ import { join as join20 } from "path";
10493
10601
  var init_hosted_packs = __esm({
10494
10602
  "src/runtime/hosted-packs.ts"() {
10495
10603
  "use strict";
@@ -10501,8 +10609,8 @@ var init_hosted_packs = __esm({
10501
10609
  import { createRequire as createRequire3 } from "module";
10502
10610
  import { readFile as readFile11 } from "fs/promises";
10503
10611
  import { randomBytes as randomBytes4 } from "crypto";
10504
- import { homedir as homedir2 } from "os";
10505
- import { join as join19 } from "path";
10612
+ import { homedir as homedir3 } from "os";
10613
+ import { join as join21 } from "path";
10506
10614
  var init_e2b = __esm({
10507
10615
  "src/runtime/e2b.ts"() {
10508
10616
  "use strict";
@@ -10514,9 +10622,9 @@ var init_e2b = __esm({
10514
10622
  });
10515
10623
 
10516
10624
  // src/runtime/matrix.ts
10517
- import { createHash as createHash11 } from "crypto";
10625
+ import { createHash as createHash12 } from "crypto";
10518
10626
  import { mkdir as mkdir6, readFile as readFile12, writeFile as writeFile11 } from "fs/promises";
10519
- import { join as join20, relative, resolve as resolve4 } from "path";
10627
+ import { join as join22, relative, resolve as resolve4 } from "path";
10520
10628
  var init_matrix = __esm({
10521
10629
  "src/runtime/matrix.ts"() {
10522
10630
  "use strict";
@@ -10527,9 +10635,9 @@ var init_matrix = __esm({
10527
10635
  });
10528
10636
 
10529
10637
  // src/runtime/source-build.ts
10530
- import { createHash as createHash12 } from "crypto";
10638
+ import { createHash as createHash13 } from "crypto";
10531
10639
  import { lstat, readFile as readFile13, realpath as realpath4 } from "fs/promises";
10532
- import { isAbsolute as isAbsolute2, join as join21, relative as relative2, resolve as resolve5, sep } from "path";
10640
+ import { isAbsolute as isAbsolute2, join as join23, relative as relative2, resolve as resolve5, sep } from "path";
10533
10641
  import { isDeepStrictEqual as isDeepStrictEqual6 } from "util";
10534
10642
  var init_source_build = __esm({
10535
10643
  "src/runtime/source-build.ts"() {
@@ -10541,8 +10649,8 @@ var init_source_build = __esm({
10541
10649
  // src/commands/run.ts
10542
10650
  import { mkdtemp as mkdtemp9, mkdir as mkdir7, readFile as readFile14, writeFile as writeFile12, realpath as realpath5, lstat as lstat2, rm as rm11 } from "fs/promises";
10543
10651
  import { tmpdir as tmpdir9 } from "os";
10544
- import { basename as basename2, dirname as dirname4, isAbsolute as isAbsolute3, join as join22, relative as relative3, resolve as resolve6, sep as sep2 } from "path";
10545
- import { createHash as createHash13, randomUUID as randomUUID6 } from "crypto";
10652
+ import { basename as basename2, dirname as dirname4, isAbsolute as isAbsolute3, join as join24, relative as relative3, resolve as resolve6, sep as sep2 } from "path";
10653
+ import { createHash as createHash14, randomUUID as randomUUID6 } from "crypto";
10546
10654
  async function stageApplication(root, files, destination) {
10547
10655
  const canonicalRoot = await realpath5(root);
10548
10656
  const digests = {};
@@ -10555,10 +10663,10 @@ async function stageApplication(root, files, destination) {
10555
10663
  const contents = await readFile14(source);
10556
10664
  bytes += contents.length;
10557
10665
  if (bytes > 20 * 1024 * 1024) throw new CliError("Application files exceed 20 MiB; supply a smaller built bundle", { code: EXIT.USAGE });
10558
- const target = join22(destination, file);
10666
+ const target = join24(destination, file);
10559
10667
  await mkdir7(dirname4(target), { recursive: true });
10560
10668
  await writeFile12(target, contents, { mode: 420 });
10561
- digests[file] = createHash13("sha256").update(contents).digest("hex");
10669
+ digests[file] = createHash14("sha256").update(contents).digest("hex");
10562
10670
  }
10563
10671
  return digests;
10564
10672
  }
@@ -10591,28 +10699,28 @@ init_contracts();
10591
10699
  init_run();
10592
10700
  init_git();
10593
10701
  import { createServer as createServer6 } from "http";
10594
- import { randomBytes as randomBytes5, randomUUID as randomUUID7, createHash as createHash14 } from "crypto";
10702
+ import { randomBytes as randomBytes5, randomUUID as randomUUID7, createHash as createHash15 } from "crypto";
10595
10703
  import { mkdir as mkdir8, mkdtemp as mkdtemp10, readFile as readFile15, readdir as readdir3, rename, rm as rm12, writeFile as writeFile13 } from "fs/promises";
10596
- import { dirname as dirname5, join as join23, resolve as resolve7, relative as relative4, sep as sep3 } from "path";
10704
+ import { dirname as dirname5, join as join25, resolve as resolve7, relative as relative4, sep as sep3 } from "path";
10597
10705
  import { tmpdir as tmpdir10 } from "os";
10598
10706
  import { fileURLToPath as fileURLToPath3 } from "url";
10599
- import { spawn as spawn5 } from "child_process";
10707
+ import { spawn as spawn6 } from "child_process";
10600
10708
  var uuid = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/;
10601
- var hash2 = (spec) => createHash14("sha256").update(JSON.stringify(spec)).digest("hex");
10709
+ var hash2 = (spec) => createHash15("sha256").update(JSON.stringify(spec)).digest("hex");
10602
10710
  function duration(value) {
10603
10711
  if (!Number.isInteger(value) || value < 1 || value > 86400) throw new Error("ttlSeconds must be 1\u201386400");
10604
10712
  return value;
10605
10713
  }
10606
10714
  async function persist(directory2, session) {
10607
- const temporary = join23(directory2, `${randomUUID7()}.tmp`);
10715
+ const temporary = join25(directory2, `${randomUUID7()}.tmp`);
10608
10716
  await writeFile13(temporary, JSON.stringify(session, null, 2) + "\n", { mode: 384 });
10609
- await rename(temporary, join23(directory2, "session.json"));
10717
+ await rename(temporary, join25(directory2, "session.json"));
10610
10718
  }
10611
10719
  var view = ({ controlToken: _token, cwd: _cwd, file: _file, controlUrl: _control, ...session }) => session;
10612
10720
  async function serveWorldSession(directory2) {
10613
- const session = JSON.parse(await readFile15(join23(directory2, "session.json"), "utf8"));
10721
+ const session = JSON.parse(await readFile15(join25(directory2, "session.json"), "utf8"));
10614
10722
  if (session.status !== "provisioning" || !uuid.test(session.id)) throw new Error("Session is not awaiting provisioning");
10615
- const spec = parseWorld(JSON.parse(await readFile15(join23(directory2, "world.json"), "utf8")));
10723
+ const spec = parseWorld(JSON.parse(await readFile15(join25(directory2, "world.json"), "utf8")));
10616
10724
  const world = new HttpWorld(spec);
10617
10725
  let control;
10618
10726
  let timer;
@@ -10715,7 +10823,7 @@ async function serveWorldSession(directory2) {
10715
10823
  let current = parseWorld(JSON.parse(await readFile15(session.file, "utf8")));
10716
10824
  if (session.scenario) current = applyScenario(current, await loadScenario(session.cwd, session.scenario));
10717
10825
  if (hash2(current) !== hash2(spec)) throw new Error("World specification or scenario changed; provision a new world. Source patches are allowed.");
10718
- const stage = await mkdtemp10(join23(tmpdir10(), "agenttwin-session-run-"));
10826
+ const stage = await mkdtemp10(join25(tmpdir10(), "agenttwin-session-run-"));
10719
10827
  active = new AbortController();
10720
10828
  let result;
10721
10829
  try {
@@ -10731,15 +10839,15 @@ async function serveWorldSession(directory2) {
10731
10839
  const runId = randomUUID7();
10732
10840
  let project = "local-workspace";
10733
10841
  try {
10734
- project = JSON.parse(await readFile15(join23(session.cwd, ".agenttwin/inventory.json"), "utf8")).name ?? project;
10842
+ project = JSON.parse(await readFile15(join25(session.cwd, ".agenttwin/inventory.json"), "utf8")).name ?? project;
10735
10843
  } catch {
10736
10844
  }
10737
10845
  const receipt = { ...report, sourceDirectory: relative4(session.cwd, dirname5(session.file)).split(sep3).join("/"), runId, worldId: session.id, runtime: "local", project, git: await captureGit(session.cwd), createdAt: (/* @__PURE__ */ new Date()).toISOString(), sourceDigests, specDigest: hash2(spec), provenance: "CLI-reported execution; not independently attested" };
10738
- const out = join23(session.cwd, ".agenttwin/runs", runId);
10846
+ const out = join25(session.cwd, ".agenttwin/runs", runId);
10739
10847
  await mkdir8(out, { recursive: true, mode: 448 });
10740
- const evidencePath = join23(out, "run.json");
10848
+ const evidencePath = join25(out, "run.json");
10741
10849
  await writeFile13(evidencePath, JSON.stringify(receipt, null, 2) + "\n", { mode: 384 });
10742
- await writeFile13(join23(out, "world.json"), JSON.stringify(spec, null, 2) + "\n", { mode: 384 });
10850
+ await writeFile13(join25(out, "world.json"), JSON.stringify(spec, null, 2) + "\n", { mode: 384 });
10743
10851
  session.lastRunId = runId;
10744
10852
  result = { ...receipt, evidencePath };
10745
10853
  } finally {
@@ -10762,7 +10870,7 @@ async function serveWorldSession(directory2) {
10762
10870
  control.once("error", reject);
10763
10871
  control.listen(0, "127.0.0.1", resolve8);
10764
10872
  });
10765
- const latest = JSON.parse(await readFile15(join23(directory2, "session.json"), "utf8"));
10873
+ const latest = JSON.parse(await readFile15(join25(directory2, "session.json"), "utf8"));
10766
10874
  if (latest.status !== "provisioning") throw new Error("Provisioning was abandoned");
10767
10875
  session.controlUrl = `http://127.0.0.1:${control.address().port}`;
10768
10876
  if (stopping) throw new Error("World expired during provisioning");