openpond 0.0.48 → 0.0.49

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 (98) hide show
  1. package/dist/chunks/{app-layer-4PR4BS7N.js → app-layer-E2JWCA6D.js} +2 -2
  2. package/dist/chunks/{app-server-runtime-NR6VUXZG.js → app-server-runtime-OWEIHFEU.js} +6 -6
  3. package/dist/chunks/{apps-V7TF6RTV.js → apps-VQDIVGST.js} +2 -2
  4. package/dist/chunks/{chunk-CGVG46T5.js → chunk-3BR4ACFF.js} +1 -1
  5. package/dist/chunks/{chunk-VTCLHCHX.js → chunk-64LWPRGN.js} +2 -2
  6. package/dist/chunks/{chunk-I4CQJSZK.js → chunk-7G472COA.js} +451 -80
  7. package/dist/chunks/{chunk-37IPWV2S.js → chunk-7M4HGT5X.js} +1 -1
  8. package/dist/chunks/{chunk-4GHFK3DG.js → chunk-CNIMJPM5.js} +1305 -891
  9. package/dist/chunks/{chunk-HGJQUQAP.js → chunk-LRLDBKTI.js} +1 -1
  10. package/dist/chunks/{chunk-YYJH2WWX.js → chunk-NR2N6JAC.js} +1 -1
  11. package/dist/chunks/{chunk-IM67TWCC.js → chunk-NRLI3S72.js} +1 -1
  12. package/dist/chunks/{chunk-YBQTQWOY.js → chunk-QD4FR3O4.js} +32 -32
  13. package/dist/chunks/{chunk-RUEMWXU6.js → chunk-UJV3UYLP.js} +1 -1
  14. package/dist/chunks/{cli-7APSIEWR.js → cli-T6TTMVSU.js} +5 -5
  15. package/dist/chunks/{core-commands-O76V62SB.js → core-commands-UW4XTGXK.js} +3 -3
  16. package/dist/chunks/{desktop-test-N2UPF5PP.js → desktop-test-JTBPE7CH.js} +2 -2
  17. package/dist/chunks/{extension-XQBSBEVO.js → extension-VP7LMA32.js} +1 -1
  18. package/dist/chunks/{help-YSGYNWPJ.js → help-OZNCHHO3.js} +1 -1
  19. package/dist/chunks/{opchat-F5OFTH56.js → opchat-RY3QU5UJ.js} +2 -2
  20. package/dist/chunks/{organizations-EEQPOIAZ.js → organizations-GLKSXK3Q.js} +4 -4
  21. package/dist/chunks/{profile-3OGGNTDS.js → profile-JWUYJF23.js} +2 -2
  22. package/dist/chunks/{project-agent-LVOSTVE5.js → project-agent-L4EB7QFO.js} +2 -2
  23. package/dist/chunks/{sandbox-command-S3VMWGMH.js → sandbox-command-26255MSV.js} +2 -2
  24. package/dist/chunks/{sandbox-template-UDXW7LRZ.js → sandbox-template-6UDA3AEY.js} +3 -3
  25. package/dist/chunks/{src-EFVACWDG.js → src-7S66FU4P.js} +22 -21
  26. package/dist/chunks/{src-JMDVVYFD.js → src-GCZ2GMG3.js} +3 -3
  27. package/dist/chunks/{teams-bot-YRKKQDYL.js → teams-bot-PO3GOLWU.js} +2 -2
  28. package/dist/chunks/{workspaces-5LKGF3AG.js → workspaces-26IF6TQV.js} +2 -2
  29. package/dist/cli.js +13 -13
  30. package/dist/web/assets/{AppDialog-Bqw26W0m.js → AppDialog-BTOxCNC5.js} +1 -1
  31. package/dist/web/assets/{AppsView-CWhWKF1c.js → AppsView-Cm5x09IS.js} +1 -1
  32. package/dist/web/assets/{BrowserSidebar-MTkosLlw.js → BrowserSidebar-CIPh5JIn.js} +1 -1
  33. package/dist/web/assets/{CommandMenu-Bz9bpiwl.js → CommandMenu-DdR82TLd.js} +1 -1
  34. package/dist/web/assets/{CommunityView-BqFeUGPj.js → CommunityView-Dqu4cos1.js} +1 -1
  35. package/dist/web/assets/{ComposerCreateImproveStrip-B6BBqdaL.js → ComposerCreateImproveStrip-CW2QuI7r.js} +1 -1
  36. package/dist/web/assets/{GetStartedView-BsgErNU9.js → GetStartedView--CbCnzFQ.js} +1 -1
  37. package/dist/web/assets/{LabModelVersionDetailPage-BLnFb7Mt.js → LabModelVersionDetailPage-BPUvR5XP.js} +1 -1
  38. package/dist/web/assets/{LabSkillSidebar-Ba6gRUbM.js → LabSkillSidebar-CnuyFZ1G.js} +1 -1
  39. package/dist/web/assets/{LabsRoute-BFV7VPOU.js → LabsRoute-CYk2dzQp.js} +3 -3
  40. package/dist/web/assets/{MainChatThread-B283zmgR.js → MainChatThread-0Tc95p0t.js} +2 -2
  41. package/dist/web/assets/{MainPane-Lv073mMC.js → MainPane-Bke4JEHC.js} +3 -3
  42. package/dist/web/assets/{MarkdownText-CinDMr2e.js → MarkdownText-DTBS9xe7.js} +1 -1
  43. package/dist/web/assets/{Messages-okIKN3y-.js → Messages-Bae_sFx5.js} +1 -1
  44. package/dist/web/assets/{NativeSkillSidebar-B1QrK2aH.js → NativeSkillSidebar-DSoPD42b.js} +1 -1
  45. package/dist/web/assets/{NewProjectDialog-CcbDk9Py.js → NewProjectDialog-CmXg2GK7.js} +1 -1
  46. package/dist/web/assets/{OutputsPage-CmwXC2Xd.js → OutputsPage-XmIreC0M.js} +1 -1
  47. package/dist/web/assets/{RightChatPanelStack-CHOpwL1L.js → RightChatPanelStack-BMOtbjus.js} +1 -1
  48. package/dist/web/assets/{ScheduledWorkPage-BzSPcB3d.js → ScheduledWorkPage-Cn5a9VLV.js} +1 -1
  49. package/dist/web/assets/{SettingsView-CkmRV5NT.js → SettingsView-DXF8z3P2.js} +6 -6
  50. package/dist/web/assets/{TeamChatView-DevmTvuf.js → TeamChatView-CB_0oRid.js} +1 -1
  51. package/dist/web/assets/{TerminalOverlay-CteY7dSQ.js → TerminalOverlay-XhABQsCB.js} +1 -1
  52. package/dist/web/assets/{TrainingCreationPanel-AMq0npLN.js → TrainingCreationPanel-ChsDr2GP.js} +1 -1
  53. package/dist/web/assets/{TrainingDraftPanel-BVxPaBhF.js → TrainingDraftPanel-CDlpnno6.js} +1 -1
  54. package/dist/web/assets/{UsageSettingsSection-BPIzRNKL.js → UsageSettingsSection-NbX7_3Uz.js} +1 -1
  55. package/dist/web/assets/{WorkspaceDiffPanel-DMu3IIuX.js → WorkspaceDiffPanel-jaJU08NH.js} +3 -3
  56. package/dist/web/assets/{WorkspaceEnvironmentMenu-ConUKuWd.js → WorkspaceEnvironmentMenu-D0nvQmmj.js} +1 -1
  57. package/dist/web/assets/{WorkspaceGitDialogs-o76400dH.js → WorkspaceGitDialogs-C0PMpVfj.js} +1 -1
  58. package/dist/web/assets/{WorkspaceMonacoEditor-HwyVbn8h.js → WorkspaceMonacoEditor-6QNGzQUi.js} +3 -3
  59. package/dist/web/assets/{arrow-up-right-BKN-maHj.js → arrow-up-right-Cx2xjktp.js} +1 -1
  60. package/dist/web/assets/{chevron-up-CVs6VVxb.js → chevron-up-UF_r7JHT.js} +1 -1
  61. package/dist/web/assets/{circle-alert-C01fZFW7.js → circle-alert-BUHAQ7Du.js} +1 -1
  62. package/dist/web/assets/{cloud-upload-jtADHeTW.js → cloud-upload-Cc_ZQEAm.js} +1 -1
  63. package/dist/web/assets/{cssMode-xJZoI37_.js → cssMode-CrigFsxI.js} +1 -1
  64. package/dist/web/assets/{folder-open-DyyC6ByN.js → folder-open-D7a4t258.js} +1 -1
  65. package/dist/web/assets/{folder-plus-UGSTW1kn.js → folder-plus-CmeHTj5W.js} +1 -1
  66. package/dist/web/assets/{git-branch-D6gtbKJu.js → git-branch-CaVUghsI.js} +1 -1
  67. package/dist/web/assets/{git-commit-horizontal-C_GYw-SZ.js → git-commit-horizontal-oiDAVV_Y.js} +1 -1
  68. package/dist/web/assets/{htmlMode-BjKG829K.js → htmlMode-CLzM5GNi.js} +1 -1
  69. package/dist/web/assets/index-De6p2npi.js +1 -0
  70. package/dist/web/assets/index-UUM3pwfd.css +1 -0
  71. package/dist/web/assets/index-Ure41UF0.js +178 -0
  72. package/dist/web/assets/{info-z2hv9cD1.js → info-dTkimobU.js} +1 -1
  73. package/dist/web/assets/{jsonMode-DjZzpcCY.js → jsonMode-BBF67cOE.js} +1 -1
  74. package/dist/web/assets/{lspLanguageFeatures-B4RETEmT.js → lspLanguageFeatures-DHtN2nxz.js} +1 -1
  75. package/dist/web/assets/{monaco.contribution-I3nbx1nu.js → monaco.contribution-BClTZJd2.js} +2 -2
  76. package/dist/web/assets/{monaco.contribution-DJK2Dt3T.js → monaco.contribution-C_GWU01R.js} +2 -2
  77. package/dist/web/assets/{monaco.contribution-Du7kEHLz.js → monaco.contribution-DtM9AdPi.js} +2 -2
  78. package/dist/web/assets/{monaco.contribution-DCRifLw0.js → monaco.contribution-riAIDf7J.js} +2 -2
  79. package/dist/web/assets/{monitor-DCUsiZyp.js → monitor-POfnZCWw.js} +1 -1
  80. package/dist/web/assets/{play-DCKc0E80.js → play-CjWTsI9z.js} +1 -1
  81. package/dist/web/assets/{python-DwbW9406.js → python-CvZQM_g2.js} +1 -1
  82. package/dist/web/assets/{refresh-cw-D6okuGLV.js → refresh-cw-CeHT_tXT.js} +1 -1
  83. package/dist/web/assets/{reply-KIN_PSFi.js → reply-BkH8nKWG.js} +1 -1
  84. package/dist/web/assets/{save-D7tbQpM9.js → save-CmJ92Odx.js} +1 -1
  85. package/dist/web/assets/{square-BUG8bwGr.js → square-B00f_944.js} +1 -1
  86. package/dist/web/assets/{square-pen-CWS_8PrJ.js → square-pen-LHr8bFfZ.js} +1 -1
  87. package/dist/web/assets/{toggleHighContrast-CO8n70ql.js → toggleHighContrast-C6N52VOS.js} +1 -1
  88. package/dist/web/assets/{tsMode-f9Hqewvr.js → tsMode-CDIfvnHn.js} +1 -1
  89. package/dist/web/assets/{upload-DXI5er5D.js → upload-DK0-5jXz.js} +1 -1
  90. package/dist/web/assets/{useLocalAgentSchedules-BMvi6vmi.js → useLocalAgentSchedules-BUkZjV9E.js} +1 -1
  91. package/dist/web/assets/{wifi-off-B3ZtcrOA.js → wifi-off-BQGq-son.js} +1 -1
  92. package/dist/web/assets/{workers-CNGv6B0J.js → workers-BfcjsZ3C.js} +1 -1
  93. package/dist/web/assets/{yaml-C-tL3IVE.js → yaml-CNqgAihH.js} +1 -1
  94. package/dist/web/index.html +2 -2
  95. package/package.json +1 -1
  96. package/dist/web/assets/index-B8xSSlBW.js +0 -178
  97. package/dist/web/assets/index-C-1-yaL8.js +0 -1
  98. package/dist/web/assets/index-D9jTe16Q.css +0 -1
@@ -20,7 +20,7 @@ import {
20
20
  getBundledRuntimeVersion,
21
21
  loadOpenPondAccountContext,
22
22
  streamOpenPondHostedChatTurn
23
- } from "./chunk-IM67TWCC.js";
23
+ } from "./chunk-NRLI3S72.js";
24
24
  import {
25
25
  assertSafeBranchName,
26
26
  isGeneratedWorkspacePath,
@@ -33,14 +33,14 @@ import {
33
33
  truncatePatch,
34
34
  uniqueSortedPaths,
35
35
  workspaceImageContentType
36
- } from "./chunk-37IPWV2S.js";
36
+ } from "./chunk-7M4HGT5X.js";
37
37
  import {
38
38
  HOSTED_CHAT_SYSTEM_PROMPT,
39
39
  VERSION,
40
40
  event,
41
41
  now,
42
42
  textFromUnknown
43
- } from "./chunk-RUEMWXU6.js";
43
+ } from "./chunk-UJV3UYLP.js";
44
44
  import {
45
45
  AppPreferencesSchema,
46
46
  ApplyCreateImproveRunActionRequestSchema,
@@ -164,12 +164,13 @@ import {
164
164
  runAgentSdkProjectCommand,
165
165
  runProfileSkillCommand,
166
166
  sidebarFileBookmarkId
167
- } from "./chunk-CGVG46T5.js";
167
+ } from "./chunk-3BR4ACFF.js";
168
168
  import {
169
169
  AgentSnapshotSchema,
170
170
  AttemptReceiptSchema,
171
171
  CONNECTED_APP_PROVIDER_TOOL_NAMES,
172
172
  CONNECTED_APP_TOOL_CALL_ENDPOINT,
173
+ DEFAULT_EVALUATION_REVIEW_MAX_OUTPUT_TOKENS,
173
174
  DEFAULT_REFINEMENT_TRIGGER_POLICY,
174
175
  DEFAULT_REFINER_MAX_OUTPUT_TOKENS,
175
176
  DEFAULT_REFINER_TIMEOUT_MS,
@@ -186,6 +187,8 @@ import {
186
187
  HarnessRunOverlaySchema,
187
188
  HarnessTargetedValidationReceiptSchema,
188
189
  HarnessWorkspaceSchema,
190
+ HostedHarnessRefinerRequestSchema,
191
+ HostedHarnessRefinerResponseSchema,
189
192
  ImmutableReleaseRefSchema,
190
193
  ImprovementApplyReceiptSchema,
191
194
  ImprovementObservationSchema,
@@ -201,6 +204,7 @@ import {
201
204
  WorkProcessTraceSchema,
202
205
  aggregateEvaluationReceipts,
203
206
  assertContentHash,
207
+ authorHarnessEvaluationReviewWithModel,
204
208
  authorLocalHarnessRefinementWithModel,
205
209
  boundedObservationEvidence,
206
210
  boundedTriggerEvidence,
@@ -234,7 +238,7 @@ import {
234
238
  stableId,
235
239
  uniqueEventRefs,
236
240
  validateConnectedAppProviderOperationRequest
237
- } from "./chunk-I4CQJSZK.js";
241
+ } from "./chunk-7G472COA.js";
238
242
  import {
239
243
  external_exports
240
244
  } from "./chunk-WYDVQOBL.js";
@@ -656,7 +660,7 @@ var require_shell_quote = __commonJS({
656
660
  });
657
661
 
658
662
  // ../server/src/app-server-runtime.ts
659
- import path45 from "node:path";
663
+ import path46 from "node:path";
660
664
 
661
665
  // ../../packages/logging/dist/index.js
662
666
  import { promises as fs } from "node:fs";
@@ -5269,9 +5273,9 @@ var SqliteHarnessMemoryStore = class extends SqliteSidebarFileBookmarkStore {
5269
5273
 
5270
5274
  // ../server/src/store/store-harness-evaluation-review-settings.ts
5271
5275
  var DEFAULT_SETTINGS = {
5272
- enabled: false,
5273
- cadence: "manual",
5274
- maxEstimatedCostUsd: 0,
5276
+ enabled: true,
5277
+ cadence: "daily",
5278
+ maxEstimatedCostUsd: 0.1,
5275
5279
  nextRunAt: null,
5276
5280
  lastRunAt: null,
5277
5281
  lastResult: null,
@@ -5320,7 +5324,7 @@ var SqliteHarnessEvaluationReviewSettingsStore = class extends SqliteHarnessMemo
5320
5324
  FROM harness_evaluation_review_settings WHERE workspace_id = ?`,
5321
5325
  [workspaceId]
5322
5326
  );
5323
- if (!row) return { ...DEFAULT_SETTINGS };
5327
+ if (!row) return { ...DEFAULT_SETTINGS, nextRunAt: (/* @__PURE__ */ new Date()).toISOString() };
5324
5328
  const lastResult = row.last_review_id && row.last_review_hash && row.last_classification ? {
5325
5329
  id: row.last_review_id,
5326
5330
  contentHash: row.last_review_hash,
@@ -5815,8 +5819,16 @@ var SqliteHarnessWorkspaceStore = class extends SqliteHarnessEvaluationReviewSet
5815
5819
  if (proposal.overlay.id !== overlay.id || proposal.overlay.revision !== overlay.revision || proposal.overlay.contentHash !== overlay.contentHash) {
5816
5820
  throw new Error("Refiner proposal is not bound to the atomically frozen overlay.");
5817
5821
  }
5818
- if (proposal.baseHarnessRelease.id !== overlay.baseHarnessRelease.id || proposal.baseHarnessRelease.contentHash !== overlay.baseHarnessRelease.contentHash) {
5819
- throw new Error("Refiner proposal base release differs from the run overlay.");
5822
+ if (!sameReleaseRef(proposal.baseHarnessRelease, overlay.baseHarnessRelease)) {
5823
+ const rebasedFrom = proposal.metadata.rebasedFromHarnessRelease;
5824
+ const workspace = await this.readHarnessWorkspace(
5825
+ current.workspace.workspaceId
5826
+ );
5827
+ if (!workspace || !isReleaseRef(rebasedFrom) || !sameReleaseRef(rebasedFrom, overlay.baseHarnessRelease) || !workspace.currentChannel.release || !sameReleaseRef(workspace.currentChannel.release, proposal.baseHarnessRelease) || proposal.expectedWorkspace.workspaceId !== workspace.id || proposal.expectedWorkspace.revision !== workspace.revision || proposal.expectedWorkspace.sourceRevision !== workspace.sourceRevision || proposal.expectedWorkspace.channelRevision !== workspace.currentChannel.revision) {
5828
+ throw new Error(
5829
+ "Refiner proposal base release differs from both the run overlay and the atomically verified current workspace."
5830
+ );
5831
+ }
5820
5832
  }
5821
5833
  if (JSON.stringify(proposal.edits) !== JSON.stringify(input.edits)) {
5822
5834
  throw new Error("Refiner proposal edits differ from the atomically applied edits.");
@@ -6180,6 +6192,14 @@ var SqliteHarnessWorkspaceStore = class extends SqliteHarnessEvaluationReviewSet
6180
6192
  );
6181
6193
  }
6182
6194
  };
6195
+ function isReleaseRef(value) {
6196
+ if (!value || typeof value !== "object") return false;
6197
+ const candidate = value;
6198
+ return typeof candidate.id === "string" && typeof candidate.contentHash === "string";
6199
+ }
6200
+ function sameReleaseRef(left, right) {
6201
+ return left.id === right.id && left.contentHash === right.contentHash;
6202
+ }
6183
6203
 
6184
6204
  // ../server/src/harness/local-harness-workspace-service.ts
6185
6205
  var HARNESS_SOURCE_MANIFEST = "harness.json";
@@ -7560,7 +7580,7 @@ async function ensureLocalHarnessRunOverlay(input) {
7560
7580
  }
7561
7581
 
7562
7582
  // ../server/src/harness/local-harness-history.ts
7563
- import path6 from "node:path";
7583
+ import path8 from "node:path";
7564
7584
 
7565
7585
  // ../server/src/workspace-tools/workspace-tool-common.ts
7566
7586
  var MAX_READ_CHARS = 12e4;
@@ -7599,6 +7619,306 @@ function gitBasicAuthEnv(remoteUrl, token) {
7599
7619
  };
7600
7620
  }
7601
7621
 
7622
+ // ../server/src/harness/local-harness-refiner-context.ts
7623
+ import { execFile } from "node:child_process";
7624
+ import { promises as fs6 } from "node:fs";
7625
+ import path7 from "node:path";
7626
+ import { promisify } from "node:util";
7627
+
7628
+ // ../server/src/runtime/executable-search-path-bun-compat.ts
7629
+ import path6 from "node:path";
7630
+ function executableSearchPath(environment = process.env, platform = process.platform) {
7631
+ if (platform === "win32") return environment.PATH ?? "";
7632
+ const userHome = environment.HOME?.trim();
7633
+ const preferred = [
7634
+ userHome ? path6.join(userHome, ".local", "bin") : null,
7635
+ userHome ? path6.join(userHome, ".bun", "bin") : null,
7636
+ "/opt/homebrew/bin",
7637
+ "/usr/local/bin",
7638
+ "/usr/bin",
7639
+ "/bin",
7640
+ "/usr/sbin",
7641
+ "/sbin"
7642
+ ];
7643
+ const inherited = (environment.PATH ?? "").split(path6.delimiter).filter(Boolean);
7644
+ return Array.from(
7645
+ /* @__PURE__ */ new Set([...preferred.filter((entry) => Boolean(entry)), ...inherited])
7646
+ ).join(path6.delimiter);
7647
+ }
7648
+
7649
+ // ../server/src/harness/local-harness-refiner-context.ts
7650
+ var MAX_REFINER_SOURCE_BYTES = 6e4;
7651
+ var MAX_PDF_ARTIFACTS = 10;
7652
+ var MAX_PDF_BYTES = 20 * 1024 * 1024;
7653
+ var execFileAsync = promisify(execFile);
7654
+ async function loadBoundedRefinerContext(store, trigger, observations) {
7655
+ const [session, turn, events, turns] = await Promise.all([
7656
+ store.getSession(trigger.runRef),
7657
+ store.getTurn(trigger.turnId),
7658
+ store.runtimeEventsForSession(trigger.runRef, { limit: 1e3 }),
7659
+ store.turnsForSession(trigger.runRef, 1e3)
7660
+ ]);
7661
+ const orderedTurns = [...turns].sort(
7662
+ (left, right) => left.startedAt.localeCompare(right.startedAt)
7663
+ );
7664
+ const turnIndex = orderedTurns.findIndex((candidate) => candidate.id === trigger.turnId);
7665
+ const previousTurn = turnIndex > 0 ? orderedTurns[turnIndex - 1] : null;
7666
+ const eventRefs = new Map(
7667
+ observations.flatMap(
7668
+ (observation) => observation.eventRefs.map((reference) => [reference.id, reference])
7669
+ )
7670
+ );
7671
+ const exactEvents = events.filter((runtimeEvent) => eventRefs.has(runtimeEvent.id));
7672
+ for (const [eventId, reference] of eventRefs) {
7673
+ const runtimeEvent = exactEvents.find((candidate) => candidate.id === eventId);
7674
+ if (!runtimeEvent || contentHash(runtimeEvent) !== reference.contentHash) {
7675
+ throw new Error(`Refiner runtime event ${eventId} is unavailable or hash-mismatched.`);
7676
+ }
7677
+ }
7678
+ const evidenceEvents = selectRefinerEvidenceWindow({
7679
+ events,
7680
+ exactEvents,
7681
+ turnId: trigger.turnId,
7682
+ boundarySequence: trigger.boundary.eventSequence,
7683
+ limit: trigger.policy.maxEvidenceEvents
7684
+ });
7685
+ const assistantOutput = assistantOutputForTurn(events, trigger.turnId);
7686
+ return {
7687
+ task: {
7688
+ prompt: turn?.prompt ? redactAndBoundRefinerText(turn.prompt, 8e3) : null,
7689
+ assistantOutput,
7690
+ assistantOutputLinkCount: countAbsoluteLinks(assistantOutput),
7691
+ previousAssistantOutput: previousTurn ? assistantOutputForTurn(events, previousTurn.id) : null
7692
+ },
7693
+ artifactDiagnostics: await inspectBoundedPdfArtifactDiagnostics(session?.cwd),
7694
+ eventExcerpts: evidenceEvents.map((runtimeEvent) => {
7695
+ const data = asRecord(runtimeEvent.data);
7696
+ const result = asRecord(data.result);
7697
+ return {
7698
+ id: runtimeEvent.id,
7699
+ name: runtimeEvent.name,
7700
+ action: runtimeEvent.action ?? (typeof data.tool === "string" ? data.tool : null),
7701
+ status: runtimeEvent.status ?? null,
7702
+ command: textField(result.command, 3e3),
7703
+ error: textField(runtimeEvent.error, 2e3),
7704
+ output: textField(result.output, 2e3) ?? textField(runtimeEvent.output, 2e3),
7705
+ exitCode: typeof result.exitCode === "number" ? result.exitCode : null,
7706
+ timedOut: result.timedOut === true,
7707
+ stderr: textField(result.stderr, 3e3),
7708
+ stdout: textField(result.stdout, 3e3)
7709
+ };
7710
+ })
7711
+ };
7712
+ }
7713
+ async function inspectBoundedPdfArtifactDiagnostics(cwd) {
7714
+ if (!cwd) return [];
7715
+ let entries;
7716
+ try {
7717
+ entries = await fs6.readdir(cwd, { withFileTypes: true });
7718
+ } catch {
7719
+ return [];
7720
+ }
7721
+ const pdfs = entries.filter((entry) => entry.isFile() && entry.name.toLowerCase().endsWith(".pdf")).slice(0, MAX_PDF_ARTIFACTS);
7722
+ return Promise.all(
7723
+ pdfs.map(async (entry) => {
7724
+ const filename = path7.join(cwd, entry.name);
7725
+ try {
7726
+ const metadata = await fs6.stat(filename);
7727
+ if (metadata.size > MAX_PDF_BYTES) {
7728
+ return {
7729
+ path: entry.name,
7730
+ mediaType: "application/pdf",
7731
+ check: "pdf_text_bounds",
7732
+ status: "unavailable",
7733
+ reason: `artifact exceeds ${MAX_PDF_BYTES} byte inspection bound`
7734
+ };
7735
+ }
7736
+ const { stdout } = await execFileAsync("pdftotext", ["-bbox", filename, "-"], {
7737
+ env: { ...process.env, PATH: executableSearchPath() },
7738
+ maxBuffer: 8 * 1024 * 1024,
7739
+ timeout: 15e3
7740
+ });
7741
+ return pdfTextBoundsDiagnostic(entry.name, stdout);
7742
+ } catch (error) {
7743
+ return {
7744
+ path: entry.name,
7745
+ mediaType: "application/pdf",
7746
+ check: "pdf_text_bounds",
7747
+ status: "unavailable",
7748
+ reason: error instanceof Error ? error.message.slice(0, 500) : String(error).slice(0, 500)
7749
+ };
7750
+ }
7751
+ })
7752
+ );
7753
+ }
7754
+ function pdfTextBoundsDiagnostic(artifactPath, bboxXml) {
7755
+ const clipped = [];
7756
+ let pages = 0;
7757
+ for (const pageMatch of bboxXml.matchAll(
7758
+ /<page\s+width="([^"]+)"\s+height="([^"]+)"[^>]*>([\s\S]*?)<\/page>/g
7759
+ )) {
7760
+ pages += 1;
7761
+ const width = Number(pageMatch[1]);
7762
+ const height = Number(pageMatch[2]);
7763
+ for (const wordMatch of pageMatch[3].matchAll(
7764
+ /<word\s+xMin="([^"]+)"\s+yMin="([^"]+)"\s+xMax="([^"]+)"\s+yMax="([^"]+)"[^>]*>([\s\S]*?)<\/word>/g
7765
+ )) {
7766
+ const [xMin, yMin, xMax, yMax] = wordMatch.slice(1, 5).map(Number);
7767
+ if (xMin >= 0 && yMin >= 0 && xMax <= width && yMax <= height) continue;
7768
+ clipped.push({
7769
+ page: pages,
7770
+ text: decodeXmlText(wordMatch[5]).slice(0, 120),
7771
+ xMin,
7772
+ yMin,
7773
+ xMax,
7774
+ yMax,
7775
+ pageWidth: width,
7776
+ pageHeight: height
7777
+ });
7778
+ }
7779
+ }
7780
+ return {
7781
+ path: artifactPath,
7782
+ mediaType: "application/pdf",
7783
+ check: "pdf_text_bounds",
7784
+ status: clipped.length > 0 ? "failed" : "passed",
7785
+ pages,
7786
+ clippedTextCount: clipped.length,
7787
+ examples: clipped.slice(0, 10)
7788
+ };
7789
+ }
7790
+ function decodeXmlText(value) {
7791
+ return value.replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;|&apos;/g, "'");
7792
+ }
7793
+ function countAbsoluteLinks(value) {
7794
+ if (!value) return 0;
7795
+ return value.match(/https?:\/\/[^\s<>)\]}"']+/gi)?.length ?? 0;
7796
+ }
7797
+ function assistantOutputForTurn(events, turnId) {
7798
+ const output = events.filter(
7799
+ (runtimeEvent) => runtimeEvent.turnId === turnId && runtimeEvent.name === "assistant.delta" && typeof runtimeEvent.output === "string"
7800
+ ).sort(compareRuntimeEvents).map((runtimeEvent) => runtimeEvent.output).join("");
7801
+ return output ? redactAndBoundRefinerText(output, 8e3) : null;
7802
+ }
7803
+ async function loadExactObservations(store, workspaceId, trigger) {
7804
+ const available = await store.listHarnessImprovementArtifacts(
7805
+ workspaceId,
7806
+ "observation",
7807
+ 1e3
7808
+ );
7809
+ const byHash = new Map(
7810
+ available.map((artifact) => {
7811
+ const observation = ImprovementObservationSchema.parse(artifact);
7812
+ return [observation.contentHash, observation];
7813
+ })
7814
+ );
7815
+ return trigger.observations.map((reference) => {
7816
+ const observation = byHash.get(reference.contentHash);
7817
+ if (!observation || observation.id !== reference.id) {
7818
+ throw new Error(`Refiner observation ${reference.id} is unavailable or hash-mismatched.`);
7819
+ }
7820
+ return observation;
7821
+ });
7822
+ }
7823
+ async function readBoundedRefinerSource(bundlePath, trigger) {
7824
+ const loadedSkillNames = loadedSkillNamesFromTrigger(trigger);
7825
+ const sourceRoot = path7.resolve(bundlePath, "source");
7826
+ const manifest = HarnessSourceManifestSchema.parse(
7827
+ JSON.parse(await fs6.readFile(path7.join(sourceRoot, "harness.json"), "utf8"))
7828
+ );
7829
+ let remaining = MAX_REFINER_SOURCE_BYTES;
7830
+ const result = [];
7831
+ const catalog = manifest.files.filter(
7832
+ (file) => ["instruction", "skill", "agent"].includes(file.kind) && file.visibility === "policy"
7833
+ ).map((file) => ({
7834
+ path: file.path,
7835
+ kind: file.kind,
7836
+ loaded: file.kind === "skill" && loadedSkillNames.has(skillNameFromPath(file.path))
7837
+ }));
7838
+ for (const file of manifest.files) {
7839
+ if (!["instruction", "skill", "agent"].includes(file.kind) || file.visibility !== "policy" || !["text/markdown", "text/plain", "text/javascript"].includes(file.mediaType)) {
7840
+ continue;
7841
+ }
7842
+ const target = containedSourcePath(sourceRoot, file.path);
7843
+ const stats = await fs6.lstat(target);
7844
+ if (!stats.isFile() || stats.isSymbolicLink()) continue;
7845
+ const bytes = await fs6.readFile(target);
7846
+ if (bytes.byteLength > remaining) continue;
7847
+ result.push({
7848
+ path: file.path,
7849
+ kind: file.kind,
7850
+ content: bytes.toString("utf8"),
7851
+ loaded: file.kind === "skill" && loadedSkillNames.has(skillNameFromPath(file.path))
7852
+ });
7853
+ remaining -= bytes.byteLength;
7854
+ }
7855
+ return { manifest, files: result, catalog };
7856
+ }
7857
+ function selectRefinerEvidenceWindow(input) {
7858
+ const orderedExact = [...input.exactEvents].sort(compareRuntimeEvents);
7859
+ const firstEvidenceSequence = orderedExact.reduce(
7860
+ (first, runtimeEvent) => {
7861
+ if (runtimeEvent.sequence === void 0) return first;
7862
+ return first === null ? runtimeEvent.sequence : Math.min(first, runtimeEvent.sequence);
7863
+ },
7864
+ null
7865
+ );
7866
+ const candidates = input.events.filter(
7867
+ (runtimeEvent) => runtimeEvent.turnId === input.turnId && isRefinerEvidenceEvent(runtimeEvent) && (firstEvidenceSequence === null || runtimeEvent.sequence === void 0 || runtimeEvent.sequence >= firstEvidenceSequence) && (runtimeEvent.sequence === void 0 || runtimeEvent.sequence <= input.boundarySequence)
7868
+ ).sort(compareRuntimeEvents);
7869
+ if (candidates.length <= input.limit) return candidates;
7870
+ const exactIds = new Set(orderedExact.map((runtimeEvent) => runtimeEvent.id));
7871
+ const retainedExact = orderedExact.slice(0, input.limit);
7872
+ const remaining = input.limit - retainedExact.length;
7873
+ if (remaining <= 0) return retainedExact;
7874
+ const tail = candidates.filter((runtimeEvent) => !exactIds.has(runtimeEvent.id)).slice(-remaining);
7875
+ return [...retainedExact, ...tail].sort(compareRuntimeEvents);
7876
+ }
7877
+ function isRefinerEvidenceEvent(runtimeEvent) {
7878
+ return [
7879
+ "tool.completed",
7880
+ "workspace_action_result",
7881
+ "skill.loaded",
7882
+ "validation.completed"
7883
+ ].includes(runtimeEvent.name);
7884
+ }
7885
+ function compareRuntimeEvents(left, right) {
7886
+ return (left.sequence ?? Number.MAX_SAFE_INTEGER) - (right.sequence ?? Number.MAX_SAFE_INTEGER);
7887
+ }
7888
+ function textField(value, maxLength) {
7889
+ return typeof value === "string" ? redactAndBoundRefinerText(value, maxLength) : null;
7890
+ }
7891
+ function redactAndBoundRefinerText(value, maxLength) {
7892
+ const redacted = value.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi, "Bearer [redacted]").replace(
7893
+ /\b(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/gi,
7894
+ "$1$2[redacted]"
7895
+ );
7896
+ return redacted.length <= maxLength ? redacted : `${redacted.slice(0, maxLength)}
7897
+ [truncated]`;
7898
+ }
7899
+ function loadedSkillNamesFromTrigger(trigger) {
7900
+ const names = trigger.metadata.loadedSkillNames;
7901
+ if (!Array.isArray(names)) return /* @__PURE__ */ new Set();
7902
+ return new Set(
7903
+ names.filter((name) => typeof name === "string" && name.trim().length > 0)
7904
+ );
7905
+ }
7906
+ function skillNameFromPath(sourcePath) {
7907
+ const match = /^skills\/([^/]+)\/SKILL\.md$/.exec(sourcePath.replaceAll("\\", "/"));
7908
+ return match?.[1] ?? "";
7909
+ }
7910
+ function containedSourcePath(root, relativePath) {
7911
+ const target = path7.resolve(root, ...relativePath.replaceAll("\\", "/").split("/"));
7912
+ const relative = path7.relative(root, target);
7913
+ if (!relative || relative.startsWith("..") || path7.isAbsolute(relative)) {
7914
+ throw new Error(`Harness source path escapes its immutable bundle: ${relativePath}`);
7915
+ }
7916
+ return target;
7917
+ }
7918
+ function asRecord(value) {
7919
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
7920
+ }
7921
+
7602
7922
  // ../server/src/harness/local-harness-evaluation-review.ts
7603
7923
  var ReviewSourcePolicySchema = external_exports.object({
7604
7924
  sourceRef: external_exports.string().trim().min(1),
@@ -7615,16 +7935,26 @@ var LocalHarnessEvaluationReviewRequestSchema = external_exports.object({
7615
7935
  limits: external_exports.object({
7616
7936
  maxEvidence: external_exports.number().int().min(1).max(1e3).default(200),
7617
7937
  maxTokens: external_exports.number().int().min(1).max(1e6).default(5e4),
7618
- maxDurationMs: external_exports.number().int().min(1).max(6e4).default(5e3),
7619
- maxEstimatedCostUsd: external_exports.number().finite().nonnegative().default(0)
7938
+ maxDurationMs: external_exports.number().int().min(1).max(3e5).default(24e4),
7939
+ maxEstimatedCostUsd: external_exports.number().finite().nonnegative().default(0.1)
7620
7940
  }).strict().default({
7621
7941
  maxEvidence: 200,
7622
7942
  maxTokens: 5e4,
7623
- maxDurationMs: 5e3,
7624
- maxEstimatedCostUsd: 0
7943
+ maxDurationMs: 24e4,
7944
+ maxEstimatedCostUsd: 0.1
7625
7945
  })
7626
7946
  }).strict();
7627
- async function reviewSelectedLocalHarnessEvaluation(input) {
7947
+ var activeReviews = /* @__PURE__ */ new WeakMap();
7948
+ function reviewSelectedLocalHarnessEvaluation(input) {
7949
+ const active = activeReviews.get(input.store);
7950
+ if (active) return active;
7951
+ const review = runSelectedLocalHarnessEvaluation(input).finally(() => {
7952
+ if (activeReviews.get(input.store) === review) activeReviews.delete(input.store);
7953
+ });
7954
+ activeReviews.set(input.store, review);
7955
+ return review;
7956
+ }
7957
+ async function runSelectedLocalHarnessEvaluation(input) {
7628
7958
  const request = LocalHarnessEvaluationReviewRequestSchema.parse(input.request ?? {});
7629
7959
  const startedAt = performance.now();
7630
7960
  const selectedRelease = await resolveSelectedLocalHarnessRelease(input.store);
@@ -7635,12 +7965,13 @@ async function reviewSelectedLocalHarnessEvaluation(input) {
7635
7965
  if (!workspace) {
7636
7966
  throw new Error(`Selected Harness workspace ${selectedRelease.workspaceId} does not exist.`);
7637
7967
  }
7638
- const [reviews, routes, triggers, observations, applyReceipts] = await Promise.all([
7968
+ const [reviews, routes, triggers, observations, applyReceipts, outcomes] = await Promise.all([
7639
7969
  input.store.listHarnessImprovementArtifacts(workspace.id, "evaluation_review", 1e3),
7640
7970
  input.store.listHarnessImprovementArtifacts(workspace.id, "route_decision", 1e3),
7641
7971
  input.store.listHarnessImprovementArtifacts(workspace.id, "trigger_decision", 1e3),
7642
7972
  input.store.listHarnessImprovementArtifacts(workspace.id, "observation", 1e3),
7643
- input.store.listHarnessImprovementArtifacts(workspace.id, "apply_receipt", 1e3)
7973
+ input.store.listHarnessImprovementArtifacts(workspace.id, "apply_receipt", 1e3),
7974
+ input.store.listHarnessImprovementArtifacts(workspace.id, "refiner_outcome", 1e3)
7644
7975
  ]);
7645
7976
  const latestReview = reviews[0] ?? null;
7646
7977
  const previousWatermark = request.previousWatermark ?? latestReview?.nextWatermark ?? null;
@@ -7648,7 +7979,13 @@ async function reviewSelectedLocalHarnessEvaluation(input) {
7648
7979
  const typedTriggers = triggers;
7649
7980
  const typedObservations = observations;
7650
7981
  const typedApplyReceipts = applyReceipts;
7651
- if (request.previousWatermark === void 0 && latestReview && !typedRoutes.some((route) => route.createdAt > latestReview.nextWatermark.throughCreatedAt)) {
7982
+ const typedOutcomes = outcomes;
7983
+ const allArtifacts = [
7984
+ ...typedRoutes,
7985
+ ...typedObservations,
7986
+ ...typedOutcomes
7987
+ ];
7988
+ if (request.previousWatermark === void 0 && latestReview && !allArtifacts.some((artifact) => artifact.createdAt > latestReview.nextWatermark.throughCreatedAt)) {
7652
7989
  return latestReview;
7653
7990
  }
7654
7991
  const triggerByRef = new Map(
@@ -7659,97 +7996,267 @@ async function reviewSelectedLocalHarnessEvaluation(input) {
7659
7996
  );
7660
7997
  const policyBySource = new Map(request.sourcePolicies.map((policy) => [policy.sourceRef, policy]));
7661
7998
  const excludedEvidence = [];
7662
- const candidates = [];
7663
- let examined = 0;
7664
- let estimatedTokens = 0;
7665
- for (const routeDecision of typedRoutes.slice().sort((left, right) => left.createdAt.localeCompare(right.createdAt) || left.id.localeCompare(right.id))) {
7666
- if (performance.now() - startedAt >= request.limits.maxDurationMs) {
7999
+ const rawCandidates = [];
8000
+ const representedObservationKeys = /* @__PURE__ */ new Set();
8001
+ const routedTriggerKeys = new Set(typedRoutes.map((route) => artifactKey(route.trigger)));
8002
+ const eventsBySource = /* @__PURE__ */ new Map();
8003
+ const artifactDiagnosticsBySource = /* @__PURE__ */ new Map();
8004
+ const contextForObservation = async (observation) => {
8005
+ let sourceEvents = eventsBySource.get(observation.runRef);
8006
+ if (!sourceEvents) {
8007
+ sourceEvents = await input.store.runtimeEventsForSession(observation.runRef);
8008
+ eventsBySource.set(observation.runRef, sourceEvents);
8009
+ }
8010
+ const turnEvents = sourceEvents.filter((event2) => event2.turnId === observation.turnId);
8011
+ const [turn, session] = await Promise.all([
8012
+ input.store.getTurn(observation.turnId),
8013
+ input.store.getSession(observation.runRef)
8014
+ ]);
8015
+ let artifactDiagnostics = artifactDiagnosticsBySource.get(observation.runRef);
8016
+ if (!artifactDiagnostics) {
8017
+ artifactDiagnostics = await inspectBoundedPdfArtifactDiagnostics(session?.cwd);
8018
+ artifactDiagnosticsBySource.set(observation.runRef, artifactDiagnostics);
8019
+ }
8020
+ return {
8021
+ turn: turn ? {
8022
+ id: turn.id,
8023
+ prompt: boundedReviewText(turn.prompt, 2e3),
8024
+ startedAt: turn.startedAt,
8025
+ completedAt: turn.completedAt,
8026
+ status: turn.status,
8027
+ error: boundedReviewText(turn.error ?? "", 1e3)
8028
+ } : null,
8029
+ assistantOutput: boundedReviewText(
8030
+ turnEvents.filter((event2) => event2.name === "assistant.delta").map((event2) => event2.output ?? "").join(""),
8031
+ 6e3
8032
+ ),
8033
+ artifactDiagnostics,
8034
+ events: turnEvents.filter((event2) => [
8035
+ "tool.completed",
8036
+ "validation.completed",
8037
+ "workspace_action_result"
8038
+ ].includes(event2.name)).filter(
8039
+ (event2) => event2.status === "failed" || ["validation.completed", "workspace_action_result"].includes(event2.name)
8040
+ ).slice(-8).map(boundedReviewEvent)
8041
+ };
8042
+ };
8043
+ for (const routeDecision of typedRoutes) {
8044
+ const trigger = triggerByRef.get(artifactKey(routeDecision.trigger));
8045
+ if (!trigger) {
7667
8046
  excludedEvidence.push({
7668
8047
  evidence: artifactRef(routeDecision),
7669
8048
  sourcePolicy: null,
7670
- reason: "budget"
8049
+ reason: "unverified"
7671
8050
  });
7672
8051
  continue;
7673
8052
  }
7674
- if (previousWatermark && routeDecision.createdAt <= previousWatermark.throughCreatedAt) {
8053
+ const linkedObservations = trigger.observations.map((reference) => observationByRef.get(artifactKey(reference))).filter((value) => Boolean(value));
8054
+ for (const observation of linkedObservations) {
8055
+ representedObservationKeys.add(artifactKey(observation));
8056
+ }
8057
+ rawCandidates.push({
8058
+ id: `route_decision:${routeDecision.id}`,
8059
+ artifact: routeDecision,
8060
+ kind: "route_decision",
8061
+ sourceRef: linkedObservations[0]?.runRef ?? trigger.runRef,
8062
+ payload: {
8063
+ routeDecision,
8064
+ trigger,
8065
+ observations: linkedObservations,
8066
+ turnContexts: await uniqueTurnContexts(linkedObservations, contextForObservation)
8067
+ }
8068
+ });
8069
+ }
8070
+ for (const outcome of typedOutcomes) {
8071
+ if (routedTriggerKeys.has(artifactKey(outcome.trigger))) continue;
8072
+ const trigger = triggerByRef.get(artifactKey(outcome.trigger));
8073
+ if (!trigger) {
7675
8074
  excludedEvidence.push({
7676
- evidence: artifactRef(routeDecision),
8075
+ evidence: artifactRef(outcome),
7677
8076
  sourcePolicy: null,
7678
- reason: "before_watermark"
8077
+ reason: "unverified"
7679
8078
  });
7680
8079
  continue;
7681
8080
  }
7682
- if (examined >= request.limits.maxEvidence) {
8081
+ const linkedObservations = trigger.observations.map((reference) => observationByRef.get(artifactKey(reference))).filter((value) => Boolean(value));
8082
+ for (const observation of linkedObservations) {
8083
+ representedObservationKeys.add(artifactKey(observation));
8084
+ }
8085
+ const linkedApplyReceipts = outcome.proposal ? typedApplyReceipts.filter(
8086
+ (receipt2) => artifactKey(receipt2.proposal) === artifactKey(outcome.proposal)
8087
+ ) : [];
8088
+ rawCandidates.push({
8089
+ id: `refiner_outcome:${outcome.id}`,
8090
+ artifact: outcome,
8091
+ kind: "refiner_outcome",
8092
+ sourceRef: linkedObservations[0]?.runRef ?? trigger.runRef,
8093
+ payload: {
8094
+ outcome,
8095
+ trigger,
8096
+ observations: linkedObservations,
8097
+ turnContexts: await uniqueTurnContexts(linkedObservations, contextForObservation),
8098
+ applyReceipts: linkedApplyReceipts
8099
+ }
8100
+ });
8101
+ }
8102
+ for (const observation of typedObservations) {
8103
+ if (representedObservationKeys.has(artifactKey(observation))) continue;
8104
+ rawCandidates.push({
8105
+ id: `observation:${observation.id}`,
8106
+ artifact: observation,
8107
+ kind: "observation",
8108
+ sourceRef: observation.runRef,
8109
+ payload: {
8110
+ observation,
8111
+ turnContext: await contextForObservation(observation)
8112
+ }
8113
+ });
8114
+ }
8115
+ const candidates = [];
8116
+ const watermarkedArtifacts = [];
8117
+ let examined = 0;
8118
+ let estimatedTokens = 0;
8119
+ for (const candidate of rawCandidates.slice().sort(
8120
+ (left, right) => left.artifact.createdAt.localeCompare(right.artifact.createdAt) || left.id.localeCompare(right.id)
8121
+ )) {
8122
+ if (performance.now() - startedAt >= request.limits.maxDurationMs) {
7683
8123
  excludedEvidence.push({
7684
- evidence: artifactRef(routeDecision),
8124
+ evidence: artifactRef(candidate.artifact),
7685
8125
  sourcePolicy: null,
7686
8126
  reason: "budget"
7687
8127
  });
7688
8128
  continue;
7689
8129
  }
7690
- examined += 1;
7691
- const trigger = triggerByRef.get(artifactKey(routeDecision.trigger));
7692
- if (!trigger) {
8130
+ if (previousWatermark && candidate.artifact.createdAt <= previousWatermark.throughCreatedAt) {
7693
8131
  excludedEvidence.push({
7694
- evidence: artifactRef(routeDecision),
8132
+ evidence: artifactRef(candidate.artifact),
7695
8133
  sourcePolicy: null,
7696
- reason: "unverified"
8134
+ reason: "before_watermark"
7697
8135
  });
7698
8136
  continue;
7699
8137
  }
7700
- const observation = trigger.observations.map((reference) => observationByRef.get(artifactKey(reference)) ?? null).find((candidate) => candidate !== null) ?? null;
7701
- const proposalId = typeof routeDecision.metadata.proposalId === "string" ? routeDecision.metadata.proposalId : null;
7702
- if (proposalId && typedApplyReceipts.some(
7703
- (receipt2) => receipt2.proposal.id === proposalId && receipt2.decision === "applied"
7704
- )) {
8138
+ if (examined >= request.limits.maxEvidence) {
7705
8139
  excludedEvidence.push({
7706
- evidence: artifactRef(routeDecision),
8140
+ evidence: artifactRef(candidate.artifact),
7707
8141
  sourcePolicy: null,
7708
- reason: "resolved"
8142
+ reason: "budget"
7709
8143
  });
7710
8144
  continue;
7711
8145
  }
7712
- const candidateTokens = Math.ceil(JSON.stringify({ routeDecision, trigger, observation }).length / 4);
8146
+ examined += 1;
8147
+ const candidateTokens = Math.ceil(JSON.stringify(candidate.payload).length / 4);
7713
8148
  if (estimatedTokens + candidateTokens > request.limits.maxTokens) {
7714
8149
  excludedEvidence.push({
7715
- evidence: artifactRef(routeDecision),
8150
+ evidence: artifactRef(candidate.artifact),
7716
8151
  sourcePolicy: null,
7717
8152
  reason: "budget"
7718
8153
  });
7719
8154
  continue;
7720
8155
  }
7721
8156
  estimatedTokens += candidateTokens;
7722
- const sourceRef = observation?.runRef ?? trigger.runRef;
7723
- const policy = policyBySource.get(sourceRef);
8157
+ watermarkedArtifacts.push(candidate.artifact);
8158
+ const policy = policyBySource.get(candidate.sourceRef);
7724
8159
  if (!policy || policy.state !== "authorized") {
7725
8160
  excludedEvidence.push({
7726
- evidence: artifactRef(routeDecision),
8161
+ evidence: artifactRef(candidate.artifact),
7727
8162
  sourcePolicy: policy ? sourcePolicyRef(policy) : null,
7728
8163
  reason: policy && policy.state !== "authorized" ? policy.state : "unverified"
7729
8164
  });
7730
8165
  continue;
7731
8166
  }
7732
- candidates.push({
7733
- route: routeDecision.route,
7734
- family: recurrenceFamily(routeDecision.route, trigger, observation),
7735
- routeDecision,
7736
- trigger,
7737
- observation,
7738
- sourceRef
8167
+ candidates.push(candidate);
8168
+ }
8169
+ let modelDecision = {
8170
+ schemaVersion: "openpond.harnessEvaluationReviewModelDecision.v1",
8171
+ decision: "no_action",
8172
+ reason: "No authorized unresolved evidence qualified for model review.",
8173
+ ignoredEvidence: []
8174
+ };
8175
+ let modelUsage = { promptTokens: 0, completionTokens: 0, totalTokens: 0 };
8176
+ const navigation = { selectedIds: null };
8177
+ if (candidates.length > 0 && request.limits.maxEstimatedCostUsd === 0) {
8178
+ for (const candidate of candidates) {
8179
+ excludedEvidence.push({
8180
+ evidence: artifactRef(candidate.artifact),
8181
+ sourcePolicy: sourcePolicyRef(policyBySource.get(candidate.sourceRef)),
8182
+ reason: "budget"
8183
+ });
8184
+ }
8185
+ modelDecision = {
8186
+ schemaVersion: "openpond.harnessEvaluationReviewModelDecision.v1",
8187
+ decision: "no_action",
8188
+ reason: "Continuous review is disabled by a zero model-cost ceiling.",
8189
+ ignoredEvidence: candidates.map((candidate) => ({
8190
+ id: candidate.id,
8191
+ reason: "The configured model-cost ceiling is zero."
8192
+ }))
8193
+ };
8194
+ } else if (candidates.length > 0) {
8195
+ if (!input.stream) {
8196
+ throw new Error("Harness continuous review requires a model stream.");
8197
+ }
8198
+ modelDecision = await authorHarnessEvaluationReviewWithModel({
8199
+ evidence: candidates.map((candidate) => ({
8200
+ id: candidate.id,
8201
+ evidence: artifactRef(candidate.artifact),
8202
+ kind: candidate.kind,
8203
+ sourceRef: candidate.sourceRef,
8204
+ occurredAt: candidate.artifact.createdAt,
8205
+ payload: candidate.payload
8206
+ })),
8207
+ harnessRelease: artifactRef(selectedRelease.harnessRelease),
8208
+ previousReviews: reviews.slice(0, 20),
8209
+ stream: async function* (streamInput) {
8210
+ let invocationUsage = null;
8211
+ for await (const delta of input.stream(streamInput)) {
8212
+ if (delta.usage) invocationUsage = delta.usage;
8213
+ yield delta;
8214
+ }
8215
+ if (invocationUsage) {
8216
+ modelUsage = {
8217
+ promptTokens: modelUsage.promptTokens + invocationUsage.promptTokens,
8218
+ completionTokens: modelUsage.completionTokens + invocationUsage.completionTokens,
8219
+ totalTokens: modelUsage.totalTokens + invocationUsage.totalTokens
8220
+ };
8221
+ }
8222
+ },
8223
+ signal: input.signal ?? new AbortController().signal,
8224
+ timeoutMs: request.limits.maxDurationMs,
8225
+ onNavigation: (decision) => {
8226
+ navigation.selectedIds = new Set(decision.selectedEvidenceIds);
8227
+ }
8228
+ });
8229
+ }
8230
+ const deferredCandidates = navigation.selectedIds ? candidates.filter((candidate) => !navigation.selectedIds.has(candidate.id)) : [];
8231
+ for (const candidate of deferredCandidates) {
8232
+ excludedEvidence.push({
8233
+ evidence: artifactRef(candidate.artifact),
8234
+ sourcePolicy: sourcePolicyRef(policyBySource.get(candidate.sourceRef)),
8235
+ reason: "budget"
7739
8236
  });
7740
8237
  }
7741
- const deduplicated = deduplicateCandidates(candidates, excludedEvidence, policyBySource);
7742
- const grouped = groupCandidates(deduplicated);
7743
- const chosen = [...grouped.entries()].map(([family, items]) => ({ family, items })).sort((left, right) => right.items.length - left.items.length || left.family.localeCompare(right.family))[0] ?? null;
7744
- const decision = classify(chosen?.items ?? []);
7745
- const selectedEvidence = decision.classification === "no_action" ? [] : (chosen?.items ?? []).map((candidate) => evidenceRef(candidate, policyBySource.get(candidate.sourceRef)));
8238
+ const selectedCandidates = modelDecision.decision === "review" ? modelDecision.selectedEvidenceIds.map((id) => {
8239
+ const candidate = candidates.find((item) => item.id === id);
8240
+ if (!candidate) throw new Error(`Review selected unavailable evidence ${id}.`);
8241
+ return candidate;
8242
+ }) : [];
8243
+ const classification = modelDecision.decision === "review" ? modelDecision.classification : "no_action";
8244
+ const selectedEvidence = selectedCandidates.map(
8245
+ (candidate) => evidenceRef(candidate, policyBySource.get(candidate.sourceRef))
8246
+ );
7746
8247
  const createdAt = (input.now ?? (() => (/* @__PURE__ */ new Date()).toISOString()))();
7747
- const examinedCreatedAt = typedRoutes.filter((route) => !previousWatermark || route.createdAt > previousWatermark.throughCreatedAt).slice(0, request.limits.maxEvidence).map((route) => route.createdAt).sort().at(-1);
7748
- const throughCreatedAt = maxTimestamp(previousWatermark?.throughCreatedAt, examinedCreatedAt, createdAt);
8248
+ const deferredArtifactKeys = new Set(
8249
+ deferredCandidates.map((candidate) => artifactKey(candidate.artifact))
8250
+ );
8251
+ const examinedArtifacts = watermarkedArtifacts.filter(
8252
+ (artifact) => !deferredArtifactKeys.has(artifactKey(artifact))
8253
+ );
8254
+ const examinedCreatedAt = examinedArtifacts.map((artifact) => artifact.createdAt).sort().at(-1);
8255
+ const throughCreatedAt = examinedCreatedAt ? maxTimestamp(previousWatermark?.throughCreatedAt, examinedCreatedAt) : maxTimestamp(previousWatermark?.throughCreatedAt, createdAt);
7749
8256
  const cursor = contentHash({
7750
8257
  previousCursor: previousWatermark?.cursor ?? null,
7751
8258
  throughCreatedAt,
7752
- examined: typedRoutes.filter((route) => !previousWatermark || route.createdAt > previousWatermark.throughCreatedAt).slice(0, request.limits.maxEvidence).map(artifactRef)
8259
+ examined: examinedArtifacts.map(artifactRef)
7753
8260
  });
7754
8261
  const receiptId = `evaluation-review-${contentHash({
7755
8262
  workspaceId: workspace.id,
@@ -7767,33 +8274,43 @@ async function reviewSelectedLocalHarnessEvaluation(input) {
7767
8274
  nextWatermark: { cursor, throughCreatedAt },
7768
8275
  selectedEvidence,
7769
8276
  excludedEvidence,
7770
- claim: decision.classification === "no_action" || !chosen ? null : {
7771
- fingerprint: contentHash({ family: chosen.family, evidence: selectedEvidence.map((item) => item.occurrenceKey) }),
7772
- recurrenceFamily: chosen.family,
7773
- statement: decision.reason,
7774
- independentOccurrences: new Set(chosen.items.map((item) => item.sourceRef)).size,
7775
- unresolvedOccurrences: new Set(chosen.items.map((item) => item.sourceRef)).size
7776
- },
7777
- classification: decision.classification,
7778
- triage: decision.classification === "no_action" ? [] : [{
7779
- layer: triageLayer(decision.classification),
8277
+ claim: modelDecision.decision === "review" ? {
8278
+ fingerprint: contentHash({
8279
+ family: modelDecision.recurrenceFamily,
8280
+ evidence: selectedEvidence.map((item) => item.occurrenceKey)
8281
+ }),
8282
+ recurrenceFamily: modelDecision.recurrenceFamily,
8283
+ statement: modelDecision.statement,
8284
+ independentOccurrences: new Set(selectedCandidates.map((item) => item.sourceRef)).size,
8285
+ unresolvedOccurrences: new Set(selectedCandidates.map((item) => item.sourceRef)).size
8286
+ } : null,
8287
+ classification,
8288
+ triage: modelDecision.decision === "review" ? [{
8289
+ layer: modelDecision.triageLayer,
7780
8290
  status: "unresolved",
7781
- reason: decision.reason,
8291
+ reason: modelDecision.reason,
7782
8292
  evidenceRefs: selectedEvidence.map((item) => item.evidence)
7783
- }],
7784
- reason: decision.reason,
7785
- nextAuthority: nextAuthority(decision.classification),
8293
+ }] : [],
8294
+ reason: modelDecision.reason,
8295
+ nextAuthority: nextAuthority(classification),
7786
8296
  maxEstimatedCostUsd: request.limits.maxEstimatedCostUsd,
7787
8297
  tasksetProposal: null,
7788
8298
  evaluation: null,
7789
8299
  trainingQualification: null,
7790
- policyVersion: "local-harness-evaluation-review-v1",
8300
+ policyVersion: "public-model-driven-harness-review-v1",
7791
8301
  createdAt,
7792
8302
  metadata: {
7793
8303
  examinedEvidence: examined,
8304
+ fullyReviewedEvidence: navigation.selectedIds?.size ?? candidates.length,
7794
8305
  estimatedTokens,
7795
8306
  elapsedMs: performance.now() - startedAt,
7796
- explicitInvocation: true
8307
+ explicitInvocation: true,
8308
+ modelDecision: modelDecision.decision,
8309
+ modelConfidence: modelDecision.decision === "review" ? modelDecision.confidence : null,
8310
+ counterevidence: modelDecision.decision === "review" ? modelDecision.counterevidence : null,
8311
+ expectedOutcome: modelDecision.decision === "review" ? modelDecision.expectedOutcome : null,
8312
+ ignoredEvidence: modelDecision.ignoredEvidence,
8313
+ modelUsage
7797
8314
  }
7798
8315
  });
7799
8316
  await input.store.saveHarnessImprovementArtifact(workspace.id, "evaluation_review", receipt);
@@ -7808,66 +8325,19 @@ function artifactKey(artifact) {
7808
8325
  function sourcePolicyRef(policy) {
7809
8326
  return { policy: policy.policy, state: policy.state, checkedAt: policy.checkedAt };
7810
8327
  }
7811
- function recurrenceFamily(route, trigger, observation) {
7812
- return [
7813
- route,
7814
- observation?.deterministicClass ?? "unclassified",
7815
- observation?.tool?.name ?? trigger.deduplicationKey,
7816
- observation?.state ?? "unknown-state"
7817
- ].join(":");
7818
- }
7819
- function deduplicateCandidates(candidates, excluded, policies) {
7820
- const seen = /* @__PURE__ */ new Set();
7821
- return candidates.filter((candidate) => {
7822
- const key = `${candidate.family}:${candidate.sourceRef}`;
7823
- if (!seen.has(key)) {
7824
- seen.add(key);
7825
- return true;
7826
- }
7827
- excluded.push({
7828
- evidence: artifactRef(candidate.routeDecision),
7829
- sourcePolicy: sourcePolicyRef(policies.get(candidate.sourceRef)),
7830
- reason: "duplicate"
7831
- });
7832
- return false;
7833
- });
7834
- }
7835
- function groupCandidates(candidates) {
7836
- const groups = /* @__PURE__ */ new Map();
7837
- for (const candidate of candidates) {
7838
- groups.set(candidate.family, [...groups.get(candidate.family) ?? [], candidate]);
7839
- }
7840
- return groups;
7841
- }
7842
8328
  function evidenceRef(candidate, policy) {
7843
8329
  return {
7844
- evidence: artifactRef(candidate.routeDecision),
7845
- kind: "route_decision",
8330
+ evidence: artifactRef(candidate.artifact),
8331
+ kind: candidate.kind,
7846
8332
  sourceRef: candidate.sourceRef,
7847
8333
  sourcePolicy: sourcePolicyRef(policy),
7848
- occurrenceKey: contentHash({ family: candidate.family, sourceRef: candidate.sourceRef }),
7849
- occurredAt: candidate.routeDecision.createdAt
8334
+ occurrenceKey: contentHash({
8335
+ evidence: artifactRef(candidate.artifact),
8336
+ sourceRef: candidate.sourceRef
8337
+ }),
8338
+ occurredAt: candidate.artifact.createdAt
7850
8339
  };
7851
8340
  }
7852
- function classify(items) {
7853
- if (items.length === 0) {
7854
- return { classification: "no_action", reason: "No authorized unresolved evidence qualified for action." };
7855
- }
7856
- const route = items[0].route;
7857
- if (route === "runtime") {
7858
- return { classification: "runtime", reason: "Authorized unresolved evidence belongs to the runtime-service layer." };
7859
- }
7860
- if (route === "product") {
7861
- return { classification: "product", reason: "Authorized unresolved evidence belongs to the product layer." };
7862
- }
7863
- if (route === "taskset" || route === "training") {
7864
- if (items.length >= 3) {
7865
- return { classification: "taskset", reason: "Three or more independent unresolved occurrences qualify for Taskset proposal review." };
7866
- }
7867
- return { classification: "no_action", reason: "Taskset evidence has not met the three-occurrence recurrence threshold." };
7868
- }
7869
- return { classification: "harness_maintenance", reason: "Authorized unresolved evidence belongs to Harness maintenance." };
7870
- }
7871
8341
  function nextAuthority(classification) {
7872
8342
  if (classification === "runtime") return "runtime_service";
7873
8343
  if (classification === "product") return "product_team";
@@ -7876,16 +8346,53 @@ function nextAuthority(classification) {
7876
8346
  if (classification === "model_improvement") return "training_system";
7877
8347
  return "none";
7878
8348
  }
7879
- function triageLayer(classification) {
7880
- if (classification === "runtime") return "runtime";
7881
- if (classification === "product") return "product";
7882
- if (classification === "taskset") return "evaluation";
7883
- if (classification === "model_improvement") return "model";
7884
- return "harness";
7885
- }
7886
8349
  function maxTimestamp(...values) {
7887
8350
  return values.filter((value) => Boolean(value)).sort().at(-1);
7888
8351
  }
8352
+ function boundedReviewEvent(event2) {
8353
+ const data = asRecord2(event2.data);
8354
+ const result = asRecord2(data.result);
8355
+ return {
8356
+ id: event2.id,
8357
+ name: event2.name,
8358
+ action: event2.action ?? (typeof data.tool === "string" ? data.tool : null),
8359
+ status: event2.status ?? null,
8360
+ error: boundedReviewText(event2.error ?? "", 750),
8361
+ output: boundedReviewText(
8362
+ typeof result.output === "string" ? result.output : event2.output ?? "",
8363
+ 750
8364
+ ),
8365
+ stderr: boundedReviewText(
8366
+ typeof result.stderr === "string" ? result.stderr : "",
8367
+ 750
8368
+ ),
8369
+ exitCode: typeof result.exitCode === "number" ? result.exitCode : null,
8370
+ timedOut: result.timedOut === true
8371
+ };
8372
+ }
8373
+ async function uniqueTurnContexts(observations, load) {
8374
+ const byTurn = /* @__PURE__ */ new Map();
8375
+ for (const observation of observations) {
8376
+ byTurn.set(`${observation.runRef}:${observation.turnId}`, observation);
8377
+ }
8378
+ return Promise.all([...byTurn.values()].map(load));
8379
+ }
8380
+ function boundedReviewText(value, maxLength) {
8381
+ if (!value) return null;
8382
+ const redacted = value.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi, "Bearer [redacted]").replace(
8383
+ /\b(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/gi,
8384
+ "$1$2[redacted]"
8385
+ );
8386
+ if (redacted.length <= maxLength) return redacted;
8387
+ const marker = "\n[... middle omitted ...]\n";
8388
+ const available = Math.max(0, maxLength - marker.length);
8389
+ const headLength = Math.ceil(available / 2);
8390
+ const tailLength = Math.floor(available / 2);
8391
+ return `${redacted.slice(0, headLength)}${marker}${redacted.slice(-tailLength)}`;
8392
+ }
8393
+ function asRecord2(value) {
8394
+ return value && typeof value === "object" && !Array.isArray(value) ? value : {};
8395
+ }
7889
8396
 
7890
8397
  // ../server/src/harness/local-harness-evaluation-review-host.ts
7891
8398
  var SOURCE_POLICY_VERSION = "local-personal-work-v1";
@@ -7934,16 +8441,19 @@ async function reviewSelectedLocalHarnessEvaluationFromHost(input) {
7934
8441
  limits: {
7935
8442
  maxEvidence: 200,
7936
8443
  maxTokens: 5e4,
7937
- maxDurationMs: 5e3,
8444
+ maxDurationMs: 24e4,
7938
8445
  maxEstimatedCostUsd: input.maxEstimatedCostUsd
7939
8446
  }
7940
8447
  },
8448
+ stream: input.stream,
8449
+ signal: input.signal,
7941
8450
  now: input.now
7942
8451
  });
7943
8452
  }
7944
8453
 
7945
8454
  // ../server/src/harness/local-harness-evaluation-review-scheduler.ts
7946
8455
  var DEFAULT_TICK_MS = 15e3;
8456
+ var EVENT_DRIVEN_REVIEW_BATCH_SIZE = 10;
7947
8457
  function nextHarnessEvaluationReviewRunAt(cadence, from) {
7948
8458
  if (cadence === "manual") return null;
7949
8459
  const next = new Date(from);
@@ -7964,10 +8474,16 @@ function createLocalHarnessEvaluationReviewScheduler(input) {
7964
8474
  if (!workspace) return null;
7965
8475
  const settings = await input.store.getHarnessEvaluationReviewSettings(workspace.id);
7966
8476
  const startedAt = now2();
7967
- if (!settings.enabled || settings.cadence === "manual" || !settings.nextRunAt || settings.nextRunAt > startedAt) return null;
8477
+ if (!settings.enabled) return null;
8478
+ const scheduledDue = settings.cadence !== "manual" && Boolean(settings.nextRunAt) && settings.nextRunAt <= startedAt;
8479
+ const eventDrivenDue = await hasEventDrivenReviewBatch({
8480
+ store: input.store,
8481
+ workspaceId: workspace.id
8482
+ });
8483
+ if (!scheduledDue && !eventDrivenDue) return null;
7968
8484
  const claimed = {
7969
8485
  ...settings,
7970
- nextRunAt: nextHarnessEvaluationReviewRunAt(settings.cadence, startedAt),
8486
+ nextRunAt: scheduledDue ? nextHarnessEvaluationReviewRunAt(settings.cadence, startedAt) : settings.nextRunAt,
7971
8487
  lastRunAt: startedAt,
7972
8488
  lastError: null,
7973
8489
  updatedAt: startedAt
@@ -7981,6 +8497,7 @@ function createLocalHarnessEvaluationReviewScheduler(input) {
7981
8497
  store: input.store,
7982
8498
  workspaceId: workspace.id,
7983
8499
  maxEstimatedCostUsd: settings.maxEstimatedCostUsd,
8500
+ stream: input.stream,
7984
8501
  now: now2
7985
8502
  });
7986
8503
  await input.store.setHarnessEvaluationReviewSettings({
@@ -8035,6 +8552,18 @@ function createLocalHarnessEvaluationReviewScheduler(input) {
8035
8552
  runDueNow
8036
8553
  };
8037
8554
  }
8555
+ async function hasEventDrivenReviewBatch(input) {
8556
+ const [outcomes, reviews] = await Promise.all([
8557
+ input.store.listHarnessImprovementArtifacts(
8558
+ input.workspaceId,
8559
+ "refiner_outcome",
8560
+ EVENT_DRIVEN_REVIEW_BATCH_SIZE
8561
+ ),
8562
+ input.store.listHarnessImprovementArtifacts(input.workspaceId, "evaluation_review", 1)
8563
+ ]);
8564
+ const watermark = reviews[0]?.nextWatermark.throughCreatedAt ?? null;
8565
+ return outcomes.filter((outcome) => !watermark || outcome.createdAt > watermark).length >= EVENT_DRIVEN_REVIEW_BATCH_SIZE;
8566
+ }
8038
8567
 
8039
8568
  // ../server/src/harness/local-harness-history.ts
8040
8569
  function createLocalHarnessSettingsRoutePayloads(input) {
@@ -8046,6 +8575,7 @@ function createLocalHarnessSettingsRoutePayloads(input) {
8046
8575
  }),
8047
8576
  reviewHarnessEvaluationPayload: (payload) => reviewLocalHarnessEvaluationFromSettings({
8048
8577
  store: input.store,
8578
+ stream: input.evaluationReviewStream,
8049
8579
  request: parseHarnessEvaluationReviewRequest(payload)
8050
8580
  }),
8051
8581
  updateHarnessEvaluationReviewSchedulePayload: (payload) => updateLocalHarnessEvaluationReviewScheduleFromSettings({
@@ -8319,7 +8849,8 @@ async function reviewLocalHarnessEvaluationFromSettings(input) {
8319
8849
  const receipt = await reviewSelectedLocalHarnessEvaluationFromHost({
8320
8850
  store: input.store,
8321
8851
  workspaceId: input.request.workspaceId,
8322
- maxEstimatedCostUsd: input.request.maxEstimatedCostUsd ?? settings.maxEstimatedCostUsd
8852
+ maxEstimatedCostUsd: input.request.maxEstimatedCostUsd ?? settings.maxEstimatedCostUsd,
8853
+ stream: input.stream
8323
8854
  });
8324
8855
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
8325
8856
  await input.store.setHarnessEvaluationReviewSettings({
@@ -8387,9 +8918,9 @@ async function requireHarnessReleaseRecord(input) {
8387
8918
  return record6;
8388
8919
  }
8389
8920
  function releaseSourcePath(record6, filePath) {
8390
- const sourceRoot = path6.resolve(record6.bundlePath, "source");
8391
- const target = path6.resolve(sourceRoot, ...filePath.split("/"));
8392
- if (target !== sourceRoot && !target.startsWith(`${sourceRoot}${path6.sep}`)) {
8921
+ const sourceRoot = path8.resolve(record6.bundlePath, "source");
8922
+ const target = path8.resolve(sourceRoot, ...filePath.split("/"));
8923
+ if (target !== sourceRoot && !target.startsWith(`${sourceRoot}${path8.sep}`)) {
8393
8924
  throw new Error(`Harness release contains an unsafe file path: ${filePath}.`);
8394
8925
  }
8395
8926
  return target;
@@ -9430,10 +9961,10 @@ function mergeSystemMessages(messages) {
9430
9961
  ...nonSystemMessages
9431
9962
  ];
9432
9963
  }
9433
- function providerEndpointUrl(baseUrl, path46) {
9964
+ function providerEndpointUrl(baseUrl, path47) {
9434
9965
  const normalized = normalizeOpenAiCompatibleBaseUrl(baseUrl);
9435
9966
  if (!normalized) throw new Error("Provider base URL is required.");
9436
- return `${normalized}/${path46}`;
9967
+ return `${normalized}/${path47}`;
9437
9968
  }
9438
9969
  function normalizeOpenAiCompatibleBaseUrl(value) {
9439
9970
  const trimmed = (value ?? "").trim();
@@ -9449,13 +9980,13 @@ function normalizeOpenAiCompatibleBaseUrl(value) {
9449
9980
  }
9450
9981
  url.search = "";
9451
9982
  url.hash = "";
9452
- const path46 = url.pathname.replace(/\/+$/, "");
9453
- if (/\/chat\/completions$/i.test(path46)) {
9454
- url.pathname = path46.replace(/\/chat\/completions$/i, "") || "/";
9455
- } else if (/\/models$/i.test(path46)) {
9456
- url.pathname = path46.replace(/\/models$/i, "") || "/";
9983
+ const path47 = url.pathname.replace(/\/+$/, "");
9984
+ if (/\/chat\/completions$/i.test(path47)) {
9985
+ url.pathname = path47.replace(/\/chat\/completions$/i, "") || "/";
9986
+ } else if (/\/models$/i.test(path47)) {
9987
+ url.pathname = path47.replace(/\/models$/i, "") || "/";
9457
9988
  } else {
9458
- url.pathname = path46 || "/";
9989
+ url.pathname = path47 || "/";
9459
9990
  }
9460
9991
  return url.toString().replace(/\/+$/, "");
9461
9992
  }
@@ -10153,190 +10684,6 @@ async function recordLocalHarnessImprovementBoundary(input) {
10153
10684
  return detection;
10154
10685
  }
10155
10686
 
10156
- // ../server/src/harness/local-harness-refiner-context.ts
10157
- import { promises as fs6 } from "node:fs";
10158
- import path7 from "node:path";
10159
- var MAX_REFINER_SOURCE_BYTES = 6e4;
10160
- async function loadBoundedRefinerContext(store, trigger, observations) {
10161
- const [turn, events, turns] = await Promise.all([
10162
- store.getTurn(trigger.turnId),
10163
- store.runtimeEventsForSession(trigger.runRef, { limit: 1e3 }),
10164
- store.turnsForSession(trigger.runRef, 1e3)
10165
- ]);
10166
- const orderedTurns = [...turns].sort(
10167
- (left, right) => left.startedAt.localeCompare(right.startedAt)
10168
- );
10169
- const turnIndex = orderedTurns.findIndex((candidate) => candidate.id === trigger.turnId);
10170
- const previousTurn = turnIndex > 0 ? orderedTurns[turnIndex - 1] : null;
10171
- const eventRefs = new Map(
10172
- observations.flatMap(
10173
- (observation) => observation.eventRefs.map((reference) => [reference.id, reference])
10174
- )
10175
- );
10176
- const exactEvents = events.filter((runtimeEvent) => eventRefs.has(runtimeEvent.id));
10177
- for (const [eventId, reference] of eventRefs) {
10178
- const runtimeEvent = exactEvents.find((candidate) => candidate.id === eventId);
10179
- if (!runtimeEvent || contentHash(runtimeEvent) !== reference.contentHash) {
10180
- throw new Error(`Refiner runtime event ${eventId} is unavailable or hash-mismatched.`);
10181
- }
10182
- }
10183
- const evidenceEvents = selectRefinerEvidenceWindow({
10184
- events,
10185
- exactEvents,
10186
- turnId: trigger.turnId,
10187
- boundarySequence: trigger.boundary.eventSequence,
10188
- limit: trigger.policy.maxEvidenceEvents
10189
- });
10190
- return {
10191
- task: {
10192
- prompt: turn?.prompt ? redactAndBoundRefinerText(turn.prompt, 8e3) : null,
10193
- assistantOutput: assistantOutputForTurn(events, trigger.turnId),
10194
- previousAssistantOutput: previousTurn ? assistantOutputForTurn(events, previousTurn.id) : null
10195
- },
10196
- eventExcerpts: evidenceEvents.map((runtimeEvent) => {
10197
- const data = asRecord(runtimeEvent.data);
10198
- const result = asRecord(data.result);
10199
- return {
10200
- id: runtimeEvent.id,
10201
- name: runtimeEvent.name,
10202
- action: runtimeEvent.action ?? (typeof data.tool === "string" ? data.tool : null),
10203
- status: runtimeEvent.status ?? null,
10204
- command: textField(result.command, 3e3),
10205
- error: textField(runtimeEvent.error, 2e3),
10206
- output: textField(result.output, 2e3) ?? textField(runtimeEvent.output, 2e3),
10207
- exitCode: typeof result.exitCode === "number" ? result.exitCode : null,
10208
- timedOut: result.timedOut === true,
10209
- stderr: textField(result.stderr, 3e3),
10210
- stdout: textField(result.stdout, 3e3)
10211
- };
10212
- })
10213
- };
10214
- }
10215
- function assistantOutputForTurn(events, turnId) {
10216
- const output = events.filter(
10217
- (runtimeEvent) => runtimeEvent.turnId === turnId && runtimeEvent.name === "assistant.delta" && typeof runtimeEvent.output === "string"
10218
- ).sort(compareRuntimeEvents).map((runtimeEvent) => runtimeEvent.output).join("");
10219
- return output ? redactAndBoundRefinerText(output, 8e3) : null;
10220
- }
10221
- async function loadExactObservations(store, workspaceId, trigger) {
10222
- const available = await store.listHarnessImprovementArtifacts(
10223
- workspaceId,
10224
- "observation",
10225
- 1e3
10226
- );
10227
- const byHash = new Map(
10228
- available.map((artifact) => {
10229
- const observation = ImprovementObservationSchema.parse(artifact);
10230
- return [observation.contentHash, observation];
10231
- })
10232
- );
10233
- return trigger.observations.map((reference) => {
10234
- const observation = byHash.get(reference.contentHash);
10235
- if (!observation || observation.id !== reference.id) {
10236
- throw new Error(`Refiner observation ${reference.id} is unavailable or hash-mismatched.`);
10237
- }
10238
- return observation;
10239
- });
10240
- }
10241
- async function readBoundedRefinerSource(bundlePath, trigger) {
10242
- const loadedSkillNames = loadedSkillNamesFromTrigger(trigger);
10243
- const sourceRoot = path7.resolve(bundlePath, "source");
10244
- const manifest = HarnessSourceManifestSchema.parse(
10245
- JSON.parse(await fs6.readFile(path7.join(sourceRoot, "harness.json"), "utf8"))
10246
- );
10247
- let remaining = MAX_REFINER_SOURCE_BYTES;
10248
- const result = [];
10249
- const catalog = manifest.files.filter(
10250
- (file) => ["instruction", "skill", "agent"].includes(file.kind) && file.visibility === "policy"
10251
- ).map((file) => ({
10252
- path: file.path,
10253
- kind: file.kind,
10254
- loaded: file.kind === "skill" && loadedSkillNames.has(skillNameFromPath(file.path))
10255
- }));
10256
- for (const file of manifest.files) {
10257
- if (!["instruction", "skill", "agent"].includes(file.kind) || file.visibility !== "policy" || !["text/markdown", "text/plain", "text/javascript"].includes(file.mediaType)) {
10258
- continue;
10259
- }
10260
- const target = containedSourcePath(sourceRoot, file.path);
10261
- const stats = await fs6.lstat(target);
10262
- if (!stats.isFile() || stats.isSymbolicLink()) continue;
10263
- const bytes = await fs6.readFile(target);
10264
- if (bytes.byteLength > remaining) continue;
10265
- result.push({
10266
- path: file.path,
10267
- kind: file.kind,
10268
- content: bytes.toString("utf8"),
10269
- loaded: file.kind === "skill" && loadedSkillNames.has(skillNameFromPath(file.path))
10270
- });
10271
- remaining -= bytes.byteLength;
10272
- }
10273
- return { manifest, files: result, catalog };
10274
- }
10275
- function selectRefinerEvidenceWindow(input) {
10276
- const orderedExact = [...input.exactEvents].sort(compareRuntimeEvents);
10277
- const firstEvidenceSequence = orderedExact.reduce(
10278
- (first, runtimeEvent) => {
10279
- if (runtimeEvent.sequence === void 0) return first;
10280
- return first === null ? runtimeEvent.sequence : Math.min(first, runtimeEvent.sequence);
10281
- },
10282
- null
10283
- );
10284
- const candidates = input.events.filter(
10285
- (runtimeEvent) => runtimeEvent.turnId === input.turnId && isRefinerEvidenceEvent(runtimeEvent) && (firstEvidenceSequence === null || runtimeEvent.sequence === void 0 || runtimeEvent.sequence >= firstEvidenceSequence) && (runtimeEvent.sequence === void 0 || runtimeEvent.sequence <= input.boundarySequence)
10286
- ).sort(compareRuntimeEvents);
10287
- if (candidates.length <= input.limit) return candidates;
10288
- const exactIds = new Set(orderedExact.map((runtimeEvent) => runtimeEvent.id));
10289
- const retainedExact = orderedExact.slice(0, input.limit);
10290
- const remaining = input.limit - retainedExact.length;
10291
- if (remaining <= 0) return retainedExact;
10292
- const tail = candidates.filter((runtimeEvent) => !exactIds.has(runtimeEvent.id)).slice(-remaining);
10293
- return [...retainedExact, ...tail].sort(compareRuntimeEvents);
10294
- }
10295
- function isRefinerEvidenceEvent(runtimeEvent) {
10296
- return [
10297
- "tool.completed",
10298
- "workspace_action_result",
10299
- "skill.loaded",
10300
- "validation.completed"
10301
- ].includes(runtimeEvent.name);
10302
- }
10303
- function compareRuntimeEvents(left, right) {
10304
- return (left.sequence ?? Number.MAX_SAFE_INTEGER) - (right.sequence ?? Number.MAX_SAFE_INTEGER);
10305
- }
10306
- function textField(value, maxLength) {
10307
- return typeof value === "string" ? redactAndBoundRefinerText(value, maxLength) : null;
10308
- }
10309
- function redactAndBoundRefinerText(value, maxLength) {
10310
- const redacted = value.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi, "Bearer [redacted]").replace(
10311
- /\b(api[_-]?key|access[_-]?token|auth(?:orization)?|password|secret)(\s*[:=]\s*)([^\s,;]+)/gi,
10312
- "$1$2[redacted]"
10313
- );
10314
- return redacted.length <= maxLength ? redacted : `${redacted.slice(0, maxLength)}
10315
- [truncated]`;
10316
- }
10317
- function loadedSkillNamesFromTrigger(trigger) {
10318
- const names = trigger.metadata.loadedSkillNames;
10319
- if (!Array.isArray(names)) return /* @__PURE__ */ new Set();
10320
- return new Set(
10321
- names.filter((name) => typeof name === "string" && name.trim().length > 0)
10322
- );
10323
- }
10324
- function skillNameFromPath(sourcePath) {
10325
- const match = /^skills\/([^/]+)\/SKILL\.md$/.exec(sourcePath.replaceAll("\\", "/"));
10326
- return match?.[1] ?? "";
10327
- }
10328
- function containedSourcePath(root, relativePath) {
10329
- const target = path7.resolve(root, ...relativePath.replaceAll("\\", "/").split("/"));
10330
- const relative = path7.relative(root, target);
10331
- if (!relative || relative.startsWith("..") || path7.isAbsolute(relative)) {
10332
- throw new Error(`Harness source path escapes its immutable bundle: ${relativePath}`);
10333
- }
10334
- return target;
10335
- }
10336
- function asRecord(value) {
10337
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
10338
- }
10339
-
10340
10687
  // ../server/src/harness/local-harness-refiner-worker-support.ts
10341
10688
  async function findRefinerOutcome(store, workspaceId, trigger) {
10342
10689
  const outcomes = await store.listHarnessImprovementArtifacts(
@@ -10453,36 +10800,62 @@ async function runLocalHarnessRefinerWorker(input) {
10453
10800
  content: entry.content,
10454
10801
  loaded: true
10455
10802
  }));
10456
- source.catalog.push(...memorySource.map(({ path: path46, kind, loaded }) => ({ path: path46, kind, loaded })));
10803
+ source.catalog.push(...memorySource.map(({ path: path47, kind, loaded }) => ({ path: path47, kind, loaded })));
10457
10804
  source.files.push(...memorySource);
10458
10805
  const boundedContext = await loadBoundedRefinerContext(
10459
10806
  input.store,
10460
10807
  trigger,
10461
10808
  observations
10462
10809
  );
10463
- if (observations.every((observation) => observation.kind === "user_turn") && boundedContext.task.previousAssistantOutput === null) {
10464
- return persistNoAction({
10465
- store: input.store,
10466
- workspace,
10467
- overlay,
10468
- trigger,
10469
- observations,
10470
- reason: "The initial user turn has no prior result to improve and contains no execution evidence.",
10471
- now: input.now
10810
+ const refinerEvidence = {
10811
+ trigger: boundedTriggerEvidence(trigger),
10812
+ observations: observations.map(boundedObservationEvidence),
10813
+ task: boundedContext.task,
10814
+ eventExcerpts: boundedContext.eventExcerpts,
10815
+ artifactDiagnostics: boundedContext.artifactDiagnostics,
10816
+ sourceFiles: source.files,
10817
+ sourceCatalog: source.catalog
10818
+ };
10819
+ let decision;
10820
+ if (input.stream) {
10821
+ decision = await authorLocalHarnessRefinementWithModel({
10822
+ evidence: refinerEvidence,
10823
+ stream: input.stream,
10824
+ signal: input.signal
10825
+ });
10826
+ } else if (input.refine) {
10827
+ const request = HostedHarnessRefinerRequestSchema.parse({
10828
+ schemaVersion: "openpond.hostedHarnessRefinerRequest.v1",
10829
+ requestId: trigger.id,
10830
+ idempotencyKey: trigger.contentHash,
10831
+ evidenceHash: contentHash(refinerEvidence),
10832
+ harness: {
10833
+ admittedRelease: overlay.baseHarnessRelease,
10834
+ currentRelease: effectiveReleaseRef,
10835
+ overlay: overlayRef(overlay),
10836
+ workspace: {
10837
+ id: workspace.id,
10838
+ revision: workspace.revision,
10839
+ sourceRevision: workspace.sourceRevision,
10840
+ channelRevision: workspace.currentChannel.revision
10841
+ },
10842
+ capabilities: {
10843
+ memory: true,
10844
+ prompt: true,
10845
+ skill: true,
10846
+ agent: false
10847
+ }
10848
+ },
10849
+ evidence: refinerEvidence
10472
10850
  });
10851
+ const response = HostedHarnessRefinerResponseSchema.parse(
10852
+ await input.refine({ request, signal: input.signal })
10853
+ );
10854
+ assertHostedResponseBinding(request, response);
10855
+ decision = response.decision;
10856
+ } else {
10857
+ throw new Error("Harness Refiner requires a public model stream or managed adapter.");
10473
10858
  }
10474
- const decision = await authorLocalHarnessRefinementWithModel({
10475
- evidence: {
10476
- trigger: boundedTriggerEvidence(trigger),
10477
- observations: observations.map(boundedObservationEvidence),
10478
- task: boundedContext.task,
10479
- eventExcerpts: boundedContext.eventExcerpts,
10480
- sourceFiles: source.files,
10481
- sourceCatalog: source.catalog
10482
- },
10483
- stream: input.stream,
10484
- signal: input.signal
10485
- });
10486
10859
  if (decision.decision === "no_action") {
10487
10860
  return persistNoAction({
10488
10861
  store: input.store,
@@ -10582,6 +10955,11 @@ async function runLocalHarnessRefinerWorker(input) {
10582
10955
  observations
10583
10956
  });
10584
10957
  }
10958
+ function assertHostedResponseBinding(request, response) {
10959
+ if (response.requestId !== request.requestId || response.evidenceHash !== request.evidenceHash || response.admittedRelease.id !== request.harness.admittedRelease.id || response.admittedRelease.contentHash !== request.harness.admittedRelease.contentHash || response.currentRelease.id !== request.harness.currentRelease.id || response.currentRelease.contentHash !== request.harness.currentRelease.contentHash) {
10960
+ throw new Error("Managed Harness Refiner response binding does not match the request.");
10961
+ }
10962
+ }
10585
10963
  async function finishPersistedProposal(input) {
10586
10964
  const timestamp = (input.now ?? (() => (/* @__PURE__ */ new Date()).toISOString()))();
10587
10965
  let validations = await findProposalValidations(
@@ -11100,6 +11478,7 @@ function createLocalHarnessImprovementRuntime(input) {
11100
11478
  triggerId: trigger.id,
11101
11479
  timeoutMs: DEFAULT_REFINER_TIMEOUT_MS,
11102
11480
  maxOutputTokens: DEFAULT_REFINER_MAX_OUTPUT_TOKENS,
11481
+ execution: "public_package",
11103
11482
  recoveredAfterRestart
11104
11483
  }
11105
11484
  })
@@ -11138,6 +11517,7 @@ function createLocalHarnessImprovementRuntime(input) {
11138
11517
  queueWaitMs: Math.max(0, jobStartedAtMs - queuedAtMs),
11139
11518
  timeoutMs: DEFAULT_REFINER_TIMEOUT_MS,
11140
11519
  maxOutputTokens: DEFAULT_REFINER_MAX_OUTPUT_TOKENS,
11520
+ execution: "public_package",
11141
11521
  recoveredAfterRestart
11142
11522
  }
11143
11523
  })
@@ -11274,7 +11654,7 @@ function createLocalHarnessImprovementRuntime(input) {
11274
11654
 
11275
11655
  // ../server/src/harness/local-harness-model-tools.ts
11276
11656
  import { promises as fs7 } from "node:fs";
11277
- import path8 from "node:path";
11657
+ import path9 from "node:path";
11278
11658
  var MAX_INSPECT_BYTES = 24e3;
11279
11659
  function createLocalHarnessModelToolDefinitions(input) {
11280
11660
  return [
@@ -11379,9 +11759,9 @@ function createLocalHarnessModelToolDefinitions(input) {
11379
11759
  const runtime = await loadLocalHarnessRuntimeForAgentRun(input.store, context.session.id);
11380
11760
  if (!runtime) throw new Error("No Local Harness release is selected for this run.");
11381
11761
  const overlay = await input.store.getHarnessRunOverlay(context.session.id);
11382
- const sourceRoot = path8.join(runtime.release.bundlePath, "source");
11762
+ const sourceRoot = path9.join(runtime.release.bundlePath, "source");
11383
11763
  const manifest = HarnessSourceManifestSchema.parse(
11384
- JSON.parse(await fs7.readFile(path8.join(sourceRoot, "harness.json"), "utf8"))
11764
+ JSON.parse(await fs7.readFile(path9.join(sourceRoot, "harness.json"), "utf8"))
11385
11765
  );
11386
11766
  const requestedPath = typeof context.args.path === "string" ? context.args.path.trim().replaceAll("\\", "/") : null;
11387
11767
  let source = null;
@@ -11477,7 +11857,7 @@ function createLocalHarnessModelToolDefinitions(input) {
11477
11857
  (artifact) => artifact.runRef === context.session.id
11478
11858
  );
11479
11859
  const triggerRefs = new Set(triggers.map((artifact) => artifactRefKey(artifact)));
11480
- const relatedToTrigger = (artifact) => triggerRefs.has(artifactRefKey(asRecord2(artifact.trigger)));
11860
+ const relatedToTrigger = (artifact) => triggerRefs.has(artifactRefKey(asRecord3(artifact.trigger)));
11481
11861
  const routes = (await all("route_decision")).filter(
11482
11862
  (artifact) => artifact.schemaVersion === "openpond.improvementRouteDecision.v1"
11483
11863
  ).filter(relatedToTrigger);
@@ -11486,7 +11866,7 @@ function createLocalHarnessModelToolDefinitions(input) {
11486
11866
  ).filter(relatedToTrigger);
11487
11867
  const proposalRefs = new Set(
11488
11868
  outcomes.flatMap((artifact) => {
11489
- const proposal = asRecord2(artifact.proposal);
11869
+ const proposal = asRecord3(artifact.proposal);
11490
11870
  return proposal.id && proposal.contentHash ? [artifactRefKey(proposal)] : [];
11491
11871
  })
11492
11872
  );
@@ -11495,7 +11875,7 @@ function createLocalHarnessModelToolDefinitions(input) {
11495
11875
  ).filter(
11496
11876
  (artifact) => proposalRefs.has(artifactRefKey(artifact))
11497
11877
  );
11498
- const relatedToProposal = (artifact) => proposalRefs.has(artifactRefKey(asRecord2(artifact.proposal)));
11878
+ const relatedToProposal = (artifact) => proposalRefs.has(artifactRefKey(asRecord3(artifact.proposal)));
11499
11879
  const artifacts = [
11500
11880
  { kind: "trigger_decision", values: triggers },
11501
11881
  { kind: "route_decision", values: routes },
@@ -11515,7 +11895,7 @@ function createLocalHarnessModelToolDefinitions(input) {
11515
11895
  function artifactRefKey(artifact) {
11516
11896
  return `${String(artifact.id ?? "")}:${String(artifact.contentHash ?? "")}`;
11517
11897
  }
11518
- function asRecord2(value) {
11898
+ function asRecord3(value) {
11519
11899
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
11520
11900
  }
11521
11901
  function modelResult(callId, name, data) {
@@ -11533,10 +11913,10 @@ function boundedJson(value, maxLength) {
11533
11913
  return { truncated: true, json: serialized.slice(0, maxLength) };
11534
11914
  }
11535
11915
  function containedSourcePath2(sourceRoot, relativePath) {
11536
- const root = path8.resolve(sourceRoot);
11537
- const absolute = path8.resolve(root, ...relativePath.split("/"));
11538
- const relative = path8.relative(root, absolute);
11539
- if (!relative || relative.startsWith("..") || path8.isAbsolute(relative)) {
11916
+ const root = path9.resolve(sourceRoot);
11917
+ const absolute = path9.resolve(root, ...relativePath.split("/"));
11918
+ const relative = path9.relative(root, absolute);
11919
+ if (!relative || relative.startsWith("..") || path9.isAbsolute(relative)) {
11540
11920
  throw new Error(`Harness source path escapes its release: ${relativePath}`);
11541
11921
  }
11542
11922
  return absolute;
@@ -11546,7 +11926,7 @@ function containedSourcePath2(sourceRoot, relativePath) {
11546
11926
  var import_shell_quote = __toESM(require_shell_quote(), 1);
11547
11927
  import { spawn } from "node:child_process";
11548
11928
  import { randomUUID as randomUUID4 } from "node:crypto";
11549
- import path9 from "node:path";
11929
+ import path10 from "node:path";
11550
11930
 
11551
11931
  // ../server/src/workspace/workspace-execution-target.ts
11552
11932
  function resolveWorkspaceExecutionTarget(input) {
@@ -11655,7 +12035,7 @@ function createOpenPondCommandAccessService(deps) {
11655
12035
  const timeoutSeconds = normalizedTimeout(input.timeoutSeconds);
11656
12036
  const target = resolveWorkspaceExecutionTarget({ session: input.session });
11657
12037
  const cwd = resolveCommandCwd({ requestedCwd: input.cwd, session: input.session });
11658
- const explicitCwd = Boolean(input.cwd?.trim() && path9.isAbsolute(input.cwd.trim()));
12038
+ const explicitCwd = Boolean(input.cwd?.trim() && path10.isAbsolute(input.cwd.trim()));
11659
12039
  if (target.target === "sandbox" || !cwd || target.target !== "local" && !explicitCwd) {
11660
12040
  return blockedCommandResult(command, cwd, SELECT_PROJECT_MESSAGE, timeoutSeconds);
11661
12041
  }
@@ -11880,8 +12260,8 @@ function commandRiskLabel(command) {
11880
12260
  function resolveCommandCwd(input) {
11881
12261
  const requested = input.requestedCwd?.trim();
11882
12262
  if (requested) {
11883
- if (path9.isAbsolute(requested)) return path9.resolve(requested);
11884
- return input.session.cwd ? path9.resolve(input.session.cwd, requested) : null;
12263
+ if (path10.isAbsolute(requested)) return path10.resolve(requested);
12264
+ return input.session.cwd ? path10.resolve(input.session.cwd, requested) : null;
11885
12265
  }
11886
12266
  return input.session.cwd?.trim() || null;
11887
12267
  }
@@ -11915,7 +12295,10 @@ function runShellCommand(input) {
11915
12295
  const child = spawn(shellCommand.command, {
11916
12296
  cwd: input.cwd,
11917
12297
  shell: shellCommand.shell,
11918
- env: process.env,
12298
+ env: {
12299
+ ...process.env,
12300
+ PATH: executableSearchPath()
12301
+ },
11919
12302
  stdio: ["ignore", "pipe", "pipe"],
11920
12303
  detached: process.platform !== "win32"
11921
12304
  });
@@ -12146,13 +12529,13 @@ function createCloudConnectedAppToolExecutor(options = {}) {
12146
12529
  }
12147
12530
  async function resolveCloudConnectedAppToolTarget(options = {}) {
12148
12531
  const env = options.env ?? process.env;
12149
- const path46 = normalizeToolPath(env.OPENPOND_CONNECTED_APP_TOOL_PATH);
12532
+ const path47 = normalizeToolPath(env.OPENPOND_CONNECTED_APP_TOOL_PATH);
12150
12533
  const apiKey = env.OPENPOND_CONNECTED_APP_API_KEY?.trim() || env.OPENPOND_SANDBOX_API_KEY?.trim() || env.OPENPOND_API_KEY?.trim();
12151
12534
  if (apiKey) {
12152
12535
  return {
12153
12536
  apiBaseUrl: resolveCloudConnectedAppApiBaseUrl(env, null),
12154
12537
  apiKey,
12155
- path: path46
12538
+ path: path47
12156
12539
  };
12157
12540
  }
12158
12541
  const loadAccountContext = options.loadAccountContext ?? loadOpenPondAccountContext;
@@ -12164,7 +12547,7 @@ async function resolveCloudConnectedAppToolTarget(options = {}) {
12164
12547
  return {
12165
12548
  apiBaseUrl: resolveCloudConnectedAppApiBaseUrl(env, context.apiBaseUrl),
12166
12549
  apiKey: token,
12167
- path: path46
12550
+ path: path47
12168
12551
  };
12169
12552
  }
12170
12553
  function resolveCloudConnectedAppApiBaseUrl(env, accountApiBaseUrl) {
@@ -12203,9 +12586,9 @@ function normalizeApiBaseUrl(value) {
12203
12586
  }
12204
12587
  }
12205
12588
  function normalizeApiBasePath(pathname) {
12206
- let path46 = pathname.replace(/\/+$/, "");
12207
- path46 = path46.replace(/\/v1\/sandboxes$/i, "").replace(/\/api\/sandboxes$/i, "").replace(/\/sandboxes$/i, "").replace(/\/v1$/i, "");
12208
- return path46 || "/";
12589
+ let path47 = pathname.replace(/\/+$/, "");
12590
+ path47 = path47.replace(/\/v1\/sandboxes$/i, "").replace(/\/api\/sandboxes$/i, "").replace(/\/sandboxes$/i, "").replace(/\/v1$/i, "");
12591
+ return path47 || "/";
12209
12592
  }
12210
12593
  function normalizeOptionalUrl(value) {
12211
12594
  const trimmed = value?.trim();
@@ -12234,7 +12617,7 @@ function errorMessage(error) {
12234
12617
 
12235
12618
  // ../server/src/openpond/hosted-turn-helpers.ts
12236
12619
  import { promises as fs11 } from "node:fs";
12237
- import path13 from "node:path";
12620
+ import path14 from "node:path";
12238
12621
 
12239
12622
  // ../server/src/openpond/context-usage.ts
12240
12623
  var ESTIMATED_CHARS_PER_TOKEN = 4;
@@ -12763,37 +13146,37 @@ function isString(value) {
12763
13146
 
12764
13147
  // ../server/src/openpond/personalization.ts
12765
13148
  import { promises as fs9 } from "node:fs";
12766
- import path11 from "node:path";
13149
+ import path12 from "node:path";
12767
13150
 
12768
13151
  // ../server/src/paths.ts
12769
13152
  import { randomBytes as randomBytes2 } from "node:crypto";
12770
13153
  import { promises as fs8 } from "node:fs";
12771
13154
  import os from "node:os";
12772
- import path10 from "node:path";
13155
+ import path11 from "node:path";
12773
13156
  function appDataDir() {
12774
- return process.env.OPENPOND_APP_HOME || path10.join(os.homedir(), ".openpond", "openpond-app");
13157
+ return process.env.OPENPOND_APP_HOME || path11.join(os.homedir(), ".openpond", "openpond-app");
12775
13158
  }
12776
13159
  function providersConfigPath(storeDir) {
12777
- return path10.join(storeDir, "providers.json");
13160
+ return path11.join(storeDir, "providers.json");
12778
13161
  }
12779
13162
  function providerSecretsConfigPath(storeDir) {
12780
- return path10.join(storeDir, "provider-secrets.json");
13163
+ return path11.join(storeDir, "provider-secrets.json");
12781
13164
  }
12782
13165
  function providerSecretsKeyPath(storeDir) {
12783
- return path10.join(storeDir, "provider-secrets.key");
13166
+ return path11.join(storeDir, "provider-secrets.key");
12784
13167
  }
12785
13168
  function soulPath(storeDir) {
12786
- return path10.join(storeDir, "SOUL.md");
13169
+ return path11.join(storeDir, "SOUL.md");
12787
13170
  }
12788
13171
  function soulsDir(storeDir) {
12789
- return path10.join(storeDir, "souls");
13172
+ return path11.join(storeDir, "souls");
12790
13173
  }
12791
13174
  function personalizationStatePath(storeDir) {
12792
- return path10.join(storeDir, "personalization.json");
13175
+ return path11.join(storeDir, "personalization.json");
12793
13176
  }
12794
13177
  async function ensureCapabilityToken(storeDir) {
12795
13178
  await fs8.mkdir(storeDir, { recursive: true });
12796
- const tokenFile = path10.join(storeDir, "token");
13179
+ const tokenFile = path11.join(storeDir, "token");
12797
13180
  if (process.env.OPENPOND_APP_TOKEN) {
12798
13181
  await fs8.writeFile(tokenFile, process.env.OPENPOND_APP_TOKEN, { mode: 384 });
12799
13182
  return { token: process.env.OPENPOND_APP_TOKEN, tokenFile };
@@ -12835,7 +13218,7 @@ function fileTemplateId(filename) {
12835
13218
  function filenameFromTemplateId(templateId) {
12836
13219
  if (!templateId.startsWith(FILE_TEMPLATE_PREFIX)) return null;
12837
13220
  const filename = templateId.slice(FILE_TEMPLATE_PREFIX.length);
12838
- if (!filename || filename.includes("..") || path11.isAbsolute(filename)) return null;
13221
+ if (!filename || filename.includes("..") || path12.isAbsolute(filename)) return null;
12839
13222
  return filename;
12840
13223
  }
12841
13224
  async function readJsonFile(filePath) {
@@ -12856,7 +13239,7 @@ async function readSoulFile(filePath) {
12856
13239
  }
12857
13240
  }
12858
13241
  async function writeSoulFile(filePath, content) {
12859
- await fs9.mkdir(path11.dirname(filePath), { recursive: true });
13242
+ await fs9.mkdir(path12.dirname(filePath), { recursive: true });
12860
13243
  await fs9.writeFile(filePath, `${trimSoul(content)}
12861
13244
  `, { mode: 384 });
12862
13245
  }
@@ -12874,7 +13257,7 @@ async function writeActiveTemplateId(store, storeDir, activeTemplateId) {
12874
13257
  };
12875
13258
  await store.setCacheEntry(ACTIVE_TEMPLATE_CACHE_TYPE, ACTIVE_TEMPLATE_CACHE_KEY, activeTemplateId);
12876
13259
  const filePath = personalizationStatePath(storeDir);
12877
- await fs9.mkdir(path11.dirname(filePath), { recursive: true });
13260
+ await fs9.mkdir(path12.dirname(filePath), { recursive: true });
12878
13261
  await fs9.writeFile(filePath, `${JSON.stringify(state, null, 2)}
12879
13262
  `, { mode: 384 });
12880
13263
  return state;
@@ -12884,7 +13267,7 @@ async function listFileTemplates(storeDir) {
12884
13267
  const templates = [];
12885
13268
  for (const entry of entries) {
12886
13269
  if (!entry.isFile() || !/^soul-.+\.md$/i.test(entry.name)) continue;
12887
- const content = await readSoulFile(path11.join(storeDir, entry.name));
13270
+ const content = await readSoulFile(path12.join(storeDir, entry.name));
12888
13271
  if (!content) continue;
12889
13272
  templates.push({
12890
13273
  id: fileTemplateId(entry.name),
@@ -12898,7 +13281,7 @@ async function listFileTemplates(storeDir) {
12898
13281
  const legacyEntries = await fs9.readdir(legacyDirectory, { withFileTypes: true }).catch(() => []);
12899
13282
  for (const entry of legacyEntries) {
12900
13283
  if (!entry.isFile() || !entry.name.toLowerCase().endsWith(".md")) continue;
12901
- const content = await readSoulFile(path11.join(legacyDirectory, entry.name));
13284
+ const content = await readSoulFile(path12.join(legacyDirectory, entry.name));
12902
13285
  if (!content) continue;
12903
13286
  templates.push({
12904
13287
  id: fileTemplateId(`souls/${entry.name}`),
@@ -12920,7 +13303,7 @@ async function uniqueSoulFilename(storeDir, name) {
12920
13303
  let candidate = `soul-${base}.md`;
12921
13304
  for (let index = 2; ; index += 1) {
12922
13305
  try {
12923
- await fs9.access(path11.join(directory, candidate));
13306
+ await fs9.access(path12.join(directory, candidate));
12924
13307
  candidate = `soul-${base}-${index}.md`;
12925
13308
  } catch {
12926
13309
  return candidate;
@@ -12930,7 +13313,7 @@ async function uniqueSoulFilename(storeDir, name) {
12930
13313
  async function saveFileTemplate(storeDir, templateId, name, content) {
12931
13314
  const existingFilename = filenameFromTemplateId(templateId);
12932
13315
  const filename = existingFilename ?? await uniqueSoulFilename(storeDir, name);
12933
- await writeSoulFile(path11.join(storeDir, filename), content);
13316
+ await writeSoulFile(path12.join(storeDir, filename), content);
12934
13317
  return fileTemplateId(filename);
12935
13318
  }
12936
13319
  async function importActiveSoulFile(storeDir, templates) {
@@ -12939,7 +13322,7 @@ async function importActiveSoulFile(storeDir, templates) {
12939
13322
  const existing = templates.find((template) => template.content === activeSoul);
12940
13323
  if (existing) return existing.id;
12941
13324
  const filename = await uniqueSoulFilename(storeDir, "Imported SOUL");
12942
- await writeSoulFile(path11.join(storeDir, filename), activeSoul);
13325
+ await writeSoulFile(path12.join(storeDir, filename), activeSoul);
12943
13326
  return fileTemplateId(filename);
12944
13327
  }
12945
13328
  async function loadPersonalizationSettings(store, storeDir) {
@@ -12993,7 +13376,7 @@ var REPOSITORY_WORK_SYSTEM_CONTEXT = [
12993
13376
 
12994
13377
  // ../server/src/openpond/repository-instructions.ts
12995
13378
  import { promises as fs10 } from "node:fs";
12996
- import path12 from "node:path";
13379
+ import path13 from "node:path";
12997
13380
  var MAX_REPOSITORY_INSTRUCTION_FILE_BYTES = 64 * 1024;
12998
13381
  var REPOSITORY_INSTRUCTION_FILE_NAME = "AGENTS.md";
12999
13382
  var REPOSITORY_INSTRUCTION_OVERRIDE_FILE_NAME = "AGENTS.override.md";
@@ -13056,7 +13439,7 @@ function buildRepositoryInstructionContext(resolution) {
13056
13439
  }
13057
13440
  async function canonicalDirectory(inputPath) {
13058
13441
  try {
13059
- const resolved = await fs10.realpath(path12.resolve(inputPath));
13442
+ const resolved = await fs10.realpath(path13.resolve(inputPath));
13060
13443
  const stat = await fs10.stat(resolved);
13061
13444
  return stat.isDirectory() ? resolved : null;
13062
13445
  } catch {
@@ -13077,18 +13460,18 @@ function directoriesFromRoot(repositoryRoot, workingDirectory) {
13077
13460
  if (!isWithinDirectory(repositoryRoot, workingDirectory)) {
13078
13461
  return [workingDirectory];
13079
13462
  }
13080
- const relative = path12.relative(repositoryRoot, workingDirectory);
13463
+ const relative = path13.relative(repositoryRoot, workingDirectory);
13081
13464
  const directories = [repositoryRoot];
13082
13465
  if (!relative) return directories;
13083
13466
  let current = repositoryRoot;
13084
- for (const segment2 of relative.split(path12.sep)) {
13085
- current = path12.join(current, segment2);
13467
+ for (const segment2 of relative.split(path13.sep)) {
13468
+ current = path13.join(current, segment2);
13086
13469
  directories.push(current);
13087
13470
  }
13088
13471
  return directories;
13089
13472
  }
13090
13473
  async function readInstructionCandidate(input) {
13091
- const candidatePath = path12.join(input.directory, input.fileName);
13474
+ const candidatePath = path13.join(input.directory, input.fileName);
13092
13475
  let realPath;
13093
13476
  try {
13094
13477
  realPath = await fs10.realpath(candidatePath);
@@ -13125,7 +13508,7 @@ async function readInstructionCandidate(input) {
13125
13508
  status: "loaded",
13126
13509
  source: {
13127
13510
  absolutePath: realPath,
13128
- relativePath: path12.relative(input.repositoryRoot, candidatePath),
13511
+ relativePath: path13.relative(input.repositoryRoot, candidatePath),
13129
13512
  content: await fs10.readFile(realPath, "utf8")
13130
13513
  }
13131
13514
  };
@@ -13142,8 +13525,8 @@ function addSource(source, sources, seenSourcePaths) {
13142
13525
  sources.push(source);
13143
13526
  }
13144
13527
  function isWithinDirectory(rootPath, candidatePath) {
13145
- const relative = path12.relative(rootPath, candidatePath);
13146
- return relative === "" || !path12.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path12.sep}`);
13528
+ const relative = path13.relative(rootPath, candidatePath);
13529
+ return relative === "" || !path13.isAbsolute(relative) && relative !== ".." && !relative.startsWith(`..${path13.sep}`);
13147
13530
  }
13148
13531
 
13149
13532
  // ../server/src/runtime/experience-policy.ts
@@ -13283,8 +13666,8 @@ function workWorkspaceRequestBlocker(action, args) {
13283
13666
  }
13284
13667
  function workPathBlocker(rawPath, allowedRoots) {
13285
13668
  if (typeof rawPath !== "string") return "A bounded Work path is required.";
13286
- const path46 = rawPath.trim().replaceAll("\\", "/");
13287
- if (!path46 || path46.startsWith("/") || path46.split("/").some((part) => part === "..") || !allowedRoots.some((root) => path46 === root || path46.startsWith(`${root}/`))) {
13669
+ const path47 = rawPath.trim().replaceAll("\\", "/");
13670
+ if (!path47 || path47.startsWith("/") || path47.split("/").some((part) => part === "..") || !allowedRoots.some((root) => path47 === root || path47.startsWith(`${root}/`))) {
13288
13671
  return `Work paths must stay under ${allowedRoots.map((root) => `/workspace/${root}`).join(", ")}.`;
13289
13672
  }
13290
13673
  return null;
@@ -13682,7 +14065,7 @@ function isHybridWorkspaceSession(session) {
13682
14065
  async function looksLikeSandboxTemplateRepo(repoPath) {
13683
14066
  if (!repoPath) return false;
13684
14067
  try {
13685
- await fs11.access(path13.join(repoPath, OPENPOND_MANIFEST_FILE_NAME));
14068
+ await fs11.access(path14.join(repoPath, OPENPOND_MANIFEST_FILE_NAME));
13686
14069
  return true;
13687
14070
  } catch {
13688
14071
  return false;
@@ -13740,9 +14123,9 @@ function parseToolContent(content) {
13740
14123
  return null;
13741
14124
  }
13742
14125
  }
13743
- function stringFromPath(record6, path46) {
14126
+ function stringFromPath(record6, path47) {
13744
14127
  let current = record6;
13745
- for (const segment2 of path46) {
14128
+ for (const segment2 of path47) {
13746
14129
  if (Array.isArray(current)) {
13747
14130
  const index = Number(segment2);
13748
14131
  if (!Number.isInteger(index) || index < 0) return null;
@@ -14662,11 +15045,11 @@ function textFromUnknown2(value) {
14662
15045
  }
14663
15046
 
14664
15047
  // ../server/src/runtime/app-server-workspace.ts
14665
- import path19 from "node:path";
15048
+ import path20 from "node:path";
14666
15049
 
14667
15050
  // ../server/src/workspace-tools/workspace-tool-file-system.ts
14668
15051
  import { promises as fs12 } from "node:fs";
14669
- import path14 from "node:path";
15052
+ import path15 from "node:path";
14670
15053
  function normalizeWorkspacePath(input) {
14671
15054
  const normalized = input.replace(/\\/g, "/").replace(/^\.\/+/, "");
14672
15055
  if (!normalized.trim()) throw new Error("Path is required");
@@ -14679,15 +15062,15 @@ function normalizeWorkspacePath(input) {
14679
15062
  return parts.join("/");
14680
15063
  }
14681
15064
  function assertInside(root, target) {
14682
- const resolvedRoot = path14.resolve(root);
14683
- const resolvedTarget = path14.resolve(target);
14684
- if (resolvedTarget !== resolvedRoot && !resolvedTarget.startsWith(`${resolvedRoot}${path14.sep}`)) {
15065
+ const resolvedRoot = path15.resolve(root);
15066
+ const resolvedTarget = path15.resolve(target);
15067
+ if (resolvedTarget !== resolvedRoot && !resolvedTarget.startsWith(`${resolvedRoot}${path15.sep}`)) {
14685
15068
  throw new Error("Path escapes the workspace root");
14686
15069
  }
14687
15070
  }
14688
15071
  async function resolveForRead(repoPath, input) {
14689
15072
  const relativePath = normalizeWorkspacePath(input);
14690
- const targetPath = path14.resolve(repoPath, relativePath);
15073
+ const targetPath = path15.resolve(repoPath, relativePath);
14691
15074
  assertInside(repoPath, targetPath);
14692
15075
  const realRoot = await fs12.realpath(repoPath);
14693
15076
  const realTarget = await fs12.realpath(targetPath);
@@ -14696,7 +15079,7 @@ async function resolveForRead(repoPath, input) {
14696
15079
  }
14697
15080
  async function resolveForWrite(repoPath, input) {
14698
15081
  const relativePath = normalizeWorkspacePath(input);
14699
- const targetPath = path14.resolve(repoPath, relativePath);
15082
+ const targetPath = path15.resolve(repoPath, relativePath);
14700
15083
  assertInside(repoPath, targetPath);
14701
15084
  try {
14702
15085
  const realRoot = await fs12.realpath(repoPath);
@@ -14704,7 +15087,7 @@ async function resolveForWrite(repoPath, input) {
14704
15087
  assertInside(realRoot, realTarget);
14705
15088
  } catch (error) {
14706
15089
  if (error.code !== "ENOENT") throw error;
14707
- const parent = path14.dirname(targetPath);
15090
+ const parent = path15.dirname(targetPath);
14708
15091
  await fs12.mkdir(parent, { recursive: true });
14709
15092
  const realRoot = await fs12.realpath(repoPath);
14710
15093
  const realParent = await fs12.realpath(parent);
@@ -14713,10 +15096,10 @@ async function resolveForWrite(repoPath, input) {
14713
15096
  return { relativePath, targetPath };
14714
15097
  }
14715
15098
  async function nearestExistingParent(targetPath, root) {
14716
- let current = path14.dirname(targetPath);
14717
- const resolvedRoot = path14.resolve(root);
14718
- while (current !== path14.dirname(current)) {
14719
- if (current === resolvedRoot || current.startsWith(`${resolvedRoot}${path14.sep}`)) {
15099
+ let current = path15.dirname(targetPath);
15100
+ const resolvedRoot = path15.resolve(root);
15101
+ while (current !== path15.dirname(current)) {
15102
+ if (current === resolvedRoot || current.startsWith(`${resolvedRoot}${path15.sep}`)) {
14720
15103
  try {
14721
15104
  const stat = await fs12.lstat(current);
14722
15105
  if (stat.isDirectory()) return current;
@@ -14725,13 +15108,13 @@ async function nearestExistingParent(targetPath, root) {
14725
15108
  }
14726
15109
  }
14727
15110
  if (current === resolvedRoot) break;
14728
- current = path14.dirname(current);
15111
+ current = path15.dirname(current);
14729
15112
  }
14730
15113
  return resolvedRoot;
14731
15114
  }
14732
15115
  async function resolveForPreview(repoPath, input) {
14733
15116
  const relativePath = normalizeWorkspacePath(input);
14734
- const targetPath = path14.resolve(repoPath, relativePath);
15117
+ const targetPath = path15.resolve(repoPath, relativePath);
14735
15118
  assertInside(repoPath, targetPath);
14736
15119
  const realRoot = await fs12.realpath(repoPath);
14737
15120
  try {
@@ -14828,7 +15211,7 @@ async function deleteWorkspaceFile(repoPath, filePath) {
14828
15211
  // ../server/src/workspace-tools/workspace-tool-preview.ts
14829
15212
  import { promises as fs13 } from "node:fs";
14830
15213
  import os2 from "node:os";
14831
- import path15 from "node:path";
15214
+ import path16 from "node:path";
14832
15215
  async function readExistingFile(repoPath, filePath) {
14833
15216
  const { targetPath } = await resolveForPreview(repoPath, filePath);
14834
15217
  try {
@@ -14841,8 +15224,8 @@ async function readExistingFile(repoPath, filePath) {
14841
15224
  }
14842
15225
  }
14843
15226
  async function writeTempPreviewFile(root, relativePath, content) {
14844
- const target = path15.join(root, relativePath);
14845
- await fs13.mkdir(path15.dirname(target), { recursive: true });
15227
+ const target = path16.join(root, relativePath);
15228
+ await fs13.mkdir(path16.dirname(target), { recursive: true });
14846
15229
  await fs13.writeFile(target, content, "utf8");
14847
15230
  return target;
14848
15231
  }
@@ -14866,10 +15249,10 @@ async function previewFileChange(repoPath, filePath, nextContent) {
14866
15249
  if (status === "unchanged") {
14867
15250
  return { path: relativePath, status, additions: 0, deletions: 0, patch: "" };
14868
15251
  }
14869
- const tempRoot = await fs13.mkdtemp(path15.join(os2.tmpdir(), "openpond-preview-"));
15252
+ const tempRoot = await fs13.mkdtemp(path16.join(os2.tmpdir(), "openpond-preview-"));
14870
15253
  try {
14871
- const oldRoot = path15.join(tempRoot, "old");
14872
- const newRoot = path15.join(tempRoot, "new");
15254
+ const oldRoot = path16.join(tempRoot, "old");
15255
+ const newRoot = path16.join(tempRoot, "new");
14873
15256
  const oldArg = previousContent === null ? "/dev/null" : await writeTempPreviewFile(oldRoot, relativePath, previousContent);
14874
15257
  const newArg = nextContent === null ? "/dev/null" : await writeTempPreviewFile(newRoot, relativePath, nextContent);
14875
15258
  const diff = await runCommand("git", ["diff", "--no-index", "--unified=80", "--", oldArg, newArg], repoPath);
@@ -14934,7 +15317,7 @@ async function previewWorkspaceDeleteFile(repoPath, filePath) {
14934
15317
 
14935
15318
  // ../server/src/workspace-tools/workspace-tool-git.ts
14936
15319
  import { promises as fs14 } from "node:fs";
14937
- import path16 from "node:path";
15320
+ import path17 from "node:path";
14938
15321
  function parseBranchStatus(line) {
14939
15322
  const value = line.replace(/^##\s*/, "").trim();
14940
15323
  const [branchPart, trackingPartRaw] = value.split("...");
@@ -15016,7 +15399,7 @@ async function setWorkspaceOrigin(repoPath, remoteUrl, options = {}) {
15016
15399
  }
15017
15400
  async function lastFetchAt(repoPath) {
15018
15401
  const fetchHead = await runCommand("git", ["rev-parse", "--git-path", "FETCH_HEAD"], repoPath);
15019
- const fetchHeadPath = fetchHead.code === 0 && fetchHead.stdout.trim() ? path16.resolve(repoPath, fetchHead.stdout.trim()) : path16.join(repoPath, ".git", "FETCH_HEAD");
15402
+ const fetchHeadPath = fetchHead.code === 0 && fetchHead.stdout.trim() ? path17.resolve(repoPath, fetchHead.stdout.trim()) : path17.join(repoPath, ".git", "FETCH_HEAD");
15020
15403
  try {
15021
15404
  const stat = await fs14.stat(fetchHeadPath);
15022
15405
  return stat.mtime.toISOString();
@@ -15125,11 +15508,11 @@ async function getWorkspaceDeploymentSource(repoPath) {
15125
15508
 
15126
15509
  // ../server/src/openpond/resources.ts
15127
15510
  import { promises as fs16 } from "node:fs";
15128
- import path18 from "node:path";
15511
+ import path19 from "node:path";
15129
15512
 
15130
15513
  // ../server/src/openpond/workspace-resource-search.ts
15131
15514
  import { promises as fs15 } from "node:fs";
15132
- import path17 from "node:path";
15515
+ import path18 from "node:path";
15133
15516
  var DEFAULT_RESOURCE_SEARCH_LIMIT = 20;
15134
15517
  var MAX_RESOURCE_SEARCH_LIMIT = 100;
15135
15518
  var WORKSPACE_SEARCH_MAX_BYTES = 12e4;
@@ -15451,12 +15834,12 @@ function orderedCharacterScore(value, query) {
15451
15834
  return Math.min(1, compactness * 0.7 + boundaryBonus * 0.3);
15452
15835
  }
15453
15836
  function workspaceRelativePathQuery(repoPath, query) {
15454
- if (!path17.isAbsolute(query)) return query;
15455
- const relative = path17.relative(path17.resolve(repoPath), path17.resolve(query));
15456
- if (!relative || relative === ".." || relative.startsWith(`..${path17.sep}`) || path17.isAbsolute(relative)) {
15837
+ if (!path18.isAbsolute(query)) return query;
15838
+ const relative = path18.relative(path18.resolve(repoPath), path18.resolve(query));
15839
+ if (!relative || relative === ".." || relative.startsWith(`..${path18.sep}`) || path18.isAbsolute(relative)) {
15457
15840
  return query;
15458
15841
  }
15459
- return relative.split(path17.sep).join("/");
15842
+ return relative.split(path18.sep).join("/");
15460
15843
  }
15461
15844
  function workspaceSearchMode(filters) {
15462
15845
  const raw = filters?.matchMode ?? filters?.mode;
@@ -15476,7 +15859,7 @@ async function visibleWorkspaceFiles(repoPath) {
15476
15859
  }
15477
15860
  }
15478
15861
  async function readWorkspaceSearchText(repoPath, filePath) {
15479
- if (BINARY_EXTENSIONS.has(path17.extname(filePath).toLowerCase())) return null;
15862
+ if (BINARY_EXTENSIONS.has(path18.extname(filePath).toLowerCase())) return null;
15480
15863
  try {
15481
15864
  const { targetPath } = await resolveForRead(repoPath, filePath);
15482
15865
  const stat = await fs15.lstat(targetPath);
@@ -16020,7 +16403,7 @@ async function readWorkspaceFileResource(repoPath, identifier, request) {
16020
16403
  ...metadata,
16021
16404
  lineCount: countLines(content.text)
16022
16405
  },
16023
- relatedRefs: [workspaceDirRef(path18.dirname(filePath) === "." ? "" : path18.dirname(filePath))],
16406
+ relatedRefs: [workspaceDirRef(path19.dirname(filePath) === "." ? "" : path19.dirname(filePath))],
16024
16407
  truncation: content.truncation
16025
16408
  };
16026
16409
  }
@@ -16061,16 +16444,16 @@ async function readWorkspaceDirectoryResource(repoPath, identifier, request) {
16061
16444
  }
16062
16445
  async function resolveWorkspacePath(repoPath, relativePath) {
16063
16446
  const root = await fs16.realpath(repoPath);
16064
- const target = path18.resolve(root, relativePath || ".");
16447
+ const target = path19.resolve(root, relativePath || ".");
16065
16448
  assertInside2(root, target);
16066
16449
  const realTarget = await fs16.realpath(target);
16067
16450
  assertInside2(root, realTarget);
16068
16451
  return realTarget;
16069
16452
  }
16070
16453
  function assertInside2(root, target) {
16071
- const resolvedRoot = path18.resolve(root);
16072
- const resolvedTarget = path18.resolve(target);
16073
- if (resolvedTarget !== resolvedRoot && !resolvedTarget.startsWith(`${resolvedRoot}${path18.sep}`)) {
16454
+ const resolvedRoot = path19.resolve(root);
16455
+ const resolvedTarget = path19.resolve(target);
16456
+ if (resolvedTarget !== resolvedRoot && !resolvedTarget.startsWith(`${resolvedRoot}${path19.sep}`)) {
16074
16457
  throw new Error("Resource path escapes the workspace root");
16075
16458
  }
16076
16459
  }
@@ -16257,9 +16640,9 @@ function goalContextDocumentForRef(events, sessionId, identifier) {
16257
16640
  function goalContextDocumentsFromEvent(event2) {
16258
16641
  const output = [];
16259
16642
  const add = (candidate) => {
16260
- const record6 = asRecord3(candidate);
16643
+ const record6 = asRecord4(candidate);
16261
16644
  if (!record6 || !looksLikeGoalContextDocument(record6)) return;
16262
- const source = asRecord3(record6.source);
16645
+ const source = asRecord4(record6.source);
16263
16646
  const id = stringValue4(record6.id) ?? stringValue4(record6.documentId) ?? stringValue4(source?.path) ?? stringValue4(record6.title);
16264
16647
  if (!id) return;
16265
16648
  const title = stringValue4(record6.title) ?? stringValue4(record6.name) ?? stringValue4(source?.path) ?? id;
@@ -16298,7 +16681,7 @@ function goalContextDocumentsFromEvent(event2) {
16298
16681
  return output;
16299
16682
  }
16300
16683
  function collectGoalContextDocumentCandidates(value, add) {
16301
- const record6 = asRecord3(value);
16684
+ const record6 = asRecord4(value);
16302
16685
  if (!record6) {
16303
16686
  if (Array.isArray(value)) {
16304
16687
  for (const item of value) collectGoalContextDocumentCandidates(item, add);
@@ -16311,16 +16694,16 @@ function collectGoalContextDocumentCandidates(value, add) {
16311
16694
  for (const item of child) add(item);
16312
16695
  }
16313
16696
  }
16314
- const context = asRecord3(record6.context);
16697
+ const context = asRecord4(record6.context);
16315
16698
  if (Array.isArray(context?.items)) {
16316
16699
  for (const item of context.items) add(item);
16317
16700
  }
16318
- const goal = asRecord3(record6.goal);
16701
+ const goal = asRecord4(record6.goal);
16319
16702
  if (goal && goal !== record6) collectGoalContextDocumentCandidates(goal, add);
16320
16703
  }
16321
16704
  function looksLikeGoalContextDocument(record6) {
16322
16705
  const kind = stringValue4(record6.kind);
16323
- const sourceKind = stringValue4(asRecord3(record6.source)?.kind);
16706
+ const sourceKind = stringValue4(asRecord4(record6.source)?.kind);
16324
16707
  const role = stringValue4(record6.role);
16325
16708
  return kind === "document" || sourceKind === "profile_goal_doc" || role === "primary_context" || role === "supporting_context" || role === "handoff" || role === "test_plan";
16326
16709
  }
@@ -16383,7 +16766,7 @@ function stringValues(value) {
16383
16766
  function stringValue4(value) {
16384
16767
  return typeof value === "string" && value.trim() ? value.trim() : null;
16385
16768
  }
16386
- function asRecord3(value) {
16769
+ function asRecord4(value) {
16387
16770
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
16388
16771
  }
16389
16772
  function safeDecodeURIComponent(value) {
@@ -16394,7 +16777,7 @@ function safeDecodeURIComponent(value) {
16394
16777
  }
16395
16778
  }
16396
16779
  function isLikelyBinaryArtifactRef(value) {
16397
- return BINARY_EXTENSIONS2.has(path18.extname(value).toLowerCase());
16780
+ return BINARY_EXTENSIONS2.has(path19.extname(value).toLowerCase());
16398
16781
  }
16399
16782
  function snippetFromText(value, lowerQuery) {
16400
16783
  const lower = value.toLowerCase();
@@ -16407,7 +16790,7 @@ function snippetFromText(value, lowerQuery) {
16407
16790
  function contentTypeForPath(filePath) {
16408
16791
  const imageType = workspaceImageContentType(filePath);
16409
16792
  if (imageType) return imageType;
16410
- const extension = path18.extname(filePath).toLowerCase();
16793
+ const extension = path19.extname(filePath).toLowerCase();
16411
16794
  if (extension === ".json") return "application/json";
16412
16795
  if (extension === ".md" || extension === ".mdx") return "text/markdown";
16413
16796
  if ([".css", ".csv", ".html", ".js", ".jsx", ".ts", ".tsx", ".txt", ".yaml", ".yml"].includes(extension)) {
@@ -16416,7 +16799,7 @@ function contentTypeForPath(filePath) {
16416
16799
  return null;
16417
16800
  }
16418
16801
  async function isBinaryFile(targetPath, filePath) {
16419
- if (BINARY_EXTENSIONS2.has(path18.extname(filePath).toLowerCase())) return true;
16802
+ if (BINARY_EXTENSIONS2.has(path19.extname(filePath).toLowerCase())) return true;
16420
16803
  const file = await fs16.open(targetPath, "r");
16421
16804
  try {
16422
16805
  const sample = Buffer.alloc(TEXT_SAMPLE_BYTES);
@@ -17065,13 +17448,13 @@ function createSandboxRuntimeHandle(client, runtimeId, initial = null) {
17065
17448
  keepAlive,
17066
17449
  checkpoint: (input) => client.checkpointSandboxRuntime(runtimeId, input),
17067
17450
  files: {
17068
- write: async (path46, contents) => client.uploadFile((await resume()).id, path46, contents),
17069
- read: async (path46) => client.downloadFile((await resume()).id, path46),
17451
+ write: async (path47, contents) => client.uploadFile((await resume()).id, path47, contents),
17452
+ read: async (path47) => client.downloadFile((await resume()).id, path47),
17070
17453
  readResponse: async (input) => client.downloadFileResponse((await resume()).id, input),
17071
17454
  list: async (input = {}) => client.listFiles((await resume()).id, input),
17072
- delete: async (path46, input = {}) => client.deleteFile((await resume()).id, path46, input),
17455
+ delete: async (path47, input = {}) => client.deleteFile((await resume()).id, path47, input),
17073
17456
  search: async (input) => client.searchFiles((await resume()).id, input),
17074
- stat: async (path46) => client.statFile((await resume()).id, path46),
17457
+ stat: async (path47) => client.statFile((await resume()).id, path47),
17075
17458
  mkdir: async (input) => client.mkdir((await resume()).id, input),
17076
17459
  move: async (input) => client.moveFile((await resume()).id, input)
17077
17460
  },
@@ -17727,20 +18110,20 @@ var OpenPondSandboxInstanceClient = class {
17727
18110
  path: `/${encodeURIComponent(sandboxId)}/pty/${encodeURIComponent(ptyId)}/stream${query.size > 0 ? `?${query.toString()}` : ""}`
17728
18111
  });
17729
18112
  }
17730
- uploadFile(sandboxId, path46, contents) {
17731
- return this.uploadFileBase64(sandboxId, path46, Buffer.from(contents, "utf-8").toString("base64"));
18113
+ uploadFile(sandboxId, path47, contents) {
18114
+ return this.uploadFileBase64(sandboxId, path47, Buffer.from(contents, "utf-8").toString("base64"));
17732
18115
  }
17733
- uploadFileBase64(sandboxId, path46, contentsBase64) {
18116
+ uploadFileBase64(sandboxId, path47, contentsBase64) {
17734
18117
  return this.request(`/${encodeURIComponent(sandboxId)}/files`, {
17735
18118
  method: "POST",
17736
18119
  body: JSON.stringify({
17737
- path: path46,
18120
+ path: path47,
17738
18121
  contentsBase64
17739
18122
  })
17740
18123
  });
17741
18124
  }
17742
- async downloadFile(sandboxId, path46) {
17743
- const payload = await this.downloadFileResponse(sandboxId, path46);
18125
+ async downloadFile(sandboxId, path47) {
18126
+ const payload = await this.downloadFileResponse(sandboxId, path47);
17744
18127
  return Buffer.from(payload.file.contentsBase64, "base64").toString("utf-8");
17745
18128
  }
17746
18129
  downloadFileResponse(sandboxId, input) {
@@ -17764,16 +18147,16 @@ var OpenPondSandboxInstanceClient = class {
17764
18147
  query.set("maxEntries", String(input.maxEntries));
17765
18148
  return this.request(`/${encodeURIComponent(sandboxId)}/files?${query.toString()}`);
17766
18149
  }
17767
- deleteFile(sandboxId, path46, input = {}) {
17768
- const query = new URLSearchParams({ path: path46 });
18150
+ deleteFile(sandboxId, path47, input = {}) {
18151
+ const query = new URLSearchParams({ path: path47 });
17769
18152
  if (input.recursive !== void 0)
17770
18153
  query.set("recursive", String(input.recursive));
17771
18154
  return this.request(`/${encodeURIComponent(sandboxId)}/files?${query.toString()}`, {
17772
18155
  method: "DELETE"
17773
18156
  });
17774
18157
  }
17775
- statFile(sandboxId, path46) {
17776
- const query = new URLSearchParams({ stat: "1", path: path46 });
18158
+ statFile(sandboxId, path47) {
18159
+ const query = new URLSearchParams({ stat: "1", path: path47 });
17777
18160
  return this.request(`/${encodeURIComponent(sandboxId)}/files?${query.toString()}`);
17778
18161
  }
17779
18162
  mkdir(sandboxId, input) {
@@ -17949,12 +18332,12 @@ var OpenPondSandboxInstanceClient = class {
17949
18332
  body: JSON.stringify({ leaseId })
17950
18333
  });
17951
18334
  }
17952
- async request(path46, init = {}) {
17953
- const response = await apiFetch2(this.sandboxApiUrl, this.apiKey, path46, init);
18335
+ async request(path47, init = {}) {
18336
+ const response = await apiFetch2(this.sandboxApiUrl, this.apiKey, path47, init);
17954
18337
  return readApiJson(response, "Sandbox request");
17955
18338
  }
17956
- async requestApiRoot(path46, init = {}) {
17957
- const response = await apiFetch2(this.apiRootUrl, this.apiKey, path46, init);
18339
+ async requestApiRoot(path47, init = {}) {
18340
+ const response = await apiFetch2(this.apiRootUrl, this.apiKey, path47, init);
17958
18341
  return readApiJson(response, "OpenPond API request");
17959
18342
  }
17960
18343
  };
@@ -18632,7 +19015,7 @@ function normalizeOptionalUrl3(value) {
18632
19015
  const trimmed = value?.trim();
18633
19016
  return trimmed ? trimmed.replace(/\/$/, "") : null;
18634
19017
  }
18635
- function asRecord4(value) {
19018
+ function asRecord5(value) {
18636
19019
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
18637
19020
  }
18638
19021
  var UI_PURPOSE_METADATA_KEYS = ["workspacePurpose", "purpose"];
@@ -18659,7 +19042,7 @@ function sanitizeSandboxRuntimeInput(value) {
18659
19042
  return runtime;
18660
19043
  }
18661
19044
  function normalizeCreateInput(payload) {
18662
- const input = asRecord4(payload);
19045
+ const input = asRecord5(payload);
18663
19046
  if (input.sandboxRuntime) {
18664
19047
  throw new Error(
18665
19048
  "Sandbox runtime settings must use /v1/runtimes before materializing a sandbox."
@@ -18716,7 +19099,7 @@ function normalizeCreateInput(payload) {
18716
19099
  return out;
18717
19100
  }
18718
19101
  function normalizeSandboxRuntimeCreateInput(payload) {
18719
- const input = asRecord4(payload);
19102
+ const input = asRecord5(payload);
18720
19103
  const runtime = sanitizeSandboxRuntimeInput(input) ?? {};
18721
19104
  const out = {};
18722
19105
  if (typeof runtime.teamId === "string" && runtime.teamId.trim()) {
@@ -18763,10 +19146,10 @@ function normalizeSandboxRuntimeSandboxCreateInput(payload) {
18763
19146
  return normalizeCreateInput(payload);
18764
19147
  }
18765
19148
  function normalizeSnapshotCreateInput(payload) {
18766
- return asRecord4(payload);
19149
+ return asRecord5(payload);
18767
19150
  }
18768
19151
  function normalizeSandboxListInput(payload) {
18769
- const input = asRecord4(payload);
19152
+ const input = asRecord5(payload);
18770
19153
  const teamId = typeof input.teamId === "string" ? input.teamId.trim() : "";
18771
19154
  const projectId = typeof input.projectId === "string" ? input.projectId.trim() : "";
18772
19155
  const agentId = typeof input.agentId === "string" ? input.agentId.trim() : "";
@@ -18777,7 +19160,7 @@ function normalizeSandboxListInput(payload) {
18777
19160
  };
18778
19161
  }
18779
19162
  function normalizeReplayStartInput(payload) {
18780
- const input = asRecord4(payload);
19163
+ const input = asRecord5(payload);
18781
19164
  const teamId = typeof input.teamId === "string" ? input.teamId.trim() : "";
18782
19165
  const projectId = typeof input.projectId === "string" ? input.projectId.trim() : "";
18783
19166
  const {
@@ -18798,7 +19181,7 @@ function normalizeIntegrationStatusFilter(value) {
18798
19181
  return void 0;
18799
19182
  }
18800
19183
  function normalizeIntegrationAttachInput(payload) {
18801
- const input = asRecord4(payload);
19184
+ const input = asRecord5(payload);
18802
19185
  const connectionId = typeof input.connectionId === "string" ? input.connectionId.trim() : "";
18803
19186
  if (!connectionId) {
18804
19187
  throw new Error("Sandbox integration connection is required.");
@@ -18830,7 +19213,7 @@ function normalizeIntegrationLeaseRefsForRuntime(value) {
18830
19213
  return value.map((item) => normalizeIntegrationLeaseRefForRuntime(item));
18831
19214
  }
18832
19215
  function normalizeIntegrationLeaseRefForRuntime(value) {
18833
- const input = asRecord4(value);
19216
+ const input = asRecord5(value);
18834
19217
  const leaseId = typeof input.leaseId === "string" ? input.leaseId.trim() : "";
18835
19218
  if (!leaseId) {
18836
19219
  throw new Error("Sandbox integration leaseId is required.");
@@ -18905,7 +19288,7 @@ function validateIntegrationCapabilitiesForProvider(providerValue, capabilities)
18905
19288
  }
18906
19289
  }
18907
19290
  function normalizeIntegrationLeaseId(payload) {
18908
- const input = asRecord4(payload);
19291
+ const input = asRecord5(payload);
18909
19292
  const leaseId = typeof input.leaseId === "string" ? input.leaseId.trim() : "";
18910
19293
  if (!leaseId) {
18911
19294
  throw new Error("Sandbox integration lease is required.");
@@ -18967,20 +19350,20 @@ function normalizeIntegrationResourcePolicy(value) {
18967
19350
  }
18968
19351
  return value;
18969
19352
  }
18970
- function assertNoSensitiveResourcePolicyKeys(value, path46) {
19353
+ function assertNoSensitiveResourcePolicyKeys(value, path47) {
18971
19354
  if (!value || typeof value !== "object") return;
18972
- if (path46.length > 8) {
19355
+ if (path47.length > 8) {
18973
19356
  throw new Error("Sandbox integration resourcePolicy is too deeply nested.");
18974
19357
  }
18975
19358
  if (Array.isArray(value)) {
18976
- for (const item of value) assertNoSensitiveResourcePolicyKeys(item, path46);
19359
+ for (const item of value) assertNoSensitiveResourcePolicyKeys(item, path47);
18977
19360
  return;
18978
19361
  }
18979
19362
  for (const [key, child] of Object.entries(value)) {
18980
19363
  if (isSensitivePolicyKey(key)) {
18981
19364
  throw new Error("Sandbox integration resourcePolicy must not include secrets or credentials.");
18982
19365
  }
18983
- assertNoSensitiveResourcePolicyKeys(child, [...path46, key]);
19366
+ assertNoSensitiveResourcePolicyKeys(child, [...path47, key]);
18984
19367
  }
18985
19368
  }
18986
19369
  function isSensitivePolicyKey(key) {
@@ -18988,7 +19371,7 @@ function isSensitivePolicyKey(key) {
18988
19371
  return normalized.includes("accesstoken") || normalized.includes("refreshtoken") || normalized.includes("idtoken") || normalized.includes("oauth") || normalized.includes("bearer") || normalized.includes("authorization") || normalized.includes("cookie") || normalized.includes("secret") || normalized.includes("password") || normalized.includes("credential");
18989
19372
  }
18990
19373
  function normalizeExecInput(payload) {
18991
- const input = asRecord4(payload);
19374
+ const input = asRecord5(payload);
18992
19375
  const command = typeof input.command === "string" ? input.command.trim() : "";
18993
19376
  if (!command) throw new Error("Sandbox command is required.");
18994
19377
  const timeoutSeconds = typeof input.timeoutSeconds === "number" && Number.isFinite(input.timeoutSeconds) ? Math.max(1, Math.floor(input.timeoutSeconds)) : void 0;
@@ -18996,19 +19379,19 @@ function normalizeExecInput(payload) {
18996
19379
  return timeoutSeconds ? { command: pipefailCommand, timeoutSeconds } : { command: pipefailCommand };
18997
19380
  }
18998
19381
  function normalizeProcessStartInput(payload) {
18999
- const input = asRecord4(payload);
19382
+ const input = asRecord5(payload);
19000
19383
  const command = typeof input.command === "string" ? input.command.trim() : "";
19001
19384
  if (!command) throw new Error("Sandbox process command is required.");
19002
19385
  const timeoutSeconds = typeof input.timeoutSeconds === "number" && Number.isFinite(input.timeoutSeconds) ? Math.max(1, Math.floor(input.timeoutSeconds)) : void 0;
19003
19386
  return timeoutSeconds ? { command, timeoutSeconds } : { command };
19004
19387
  }
19005
19388
  function normalizeProcessCursorInput(payload) {
19006
- const input = asRecord4(payload);
19389
+ const input = asRecord5(payload);
19007
19390
  const since = Number(input.since);
19008
19391
  return Number.isFinite(since) ? { since: Math.max(0, Math.floor(since)) } : {};
19009
19392
  }
19010
19393
  function normalizeOpenPortInput(payload) {
19011
- const input = asRecord4(payload);
19394
+ const input = asRecord5(payload);
19012
19395
  const port = typeof input.port === "number" ? input.port : Number(input.port);
19013
19396
  if (!Number.isInteger(port) || port < SANDBOX_TEMPLATE_PREVIEW_PORT_MIN || port > SANDBOX_TEMPLATE_PREVIEW_PORT_MAX) {
19014
19397
  throw new Error(
@@ -19038,10 +19421,10 @@ function normalizeOpenPortInput(payload) {
19038
19421
  return out;
19039
19422
  }
19040
19423
  function normalizeSnapshotUpdateInput(payload) {
19041
- const input = asRecord4(payload);
19424
+ const input = asRecord5(payload);
19042
19425
  const out = {};
19043
19426
  if (input.template && typeof input.template === "object" && !Array.isArray(input.template)) {
19044
- const template = asRecord4(input.template);
19427
+ const template = asRecord5(input.template);
19045
19428
  const nextTemplate = {};
19046
19429
  if (typeof template.description === "string") {
19047
19430
  nextTemplate.description = template.description.trim();
@@ -19064,7 +19447,7 @@ function normalizeSnapshotUpdateInput(payload) {
19064
19447
  }
19065
19448
  }
19066
19449
  if (input.retention && typeof input.retention === "object" && !Array.isArray(input.retention)) {
19067
- const retention = asRecord4(input.retention);
19450
+ const retention = asRecord5(input.retention);
19068
19451
  const nextRetention = {};
19069
19452
  if (retention.class === "ephemeral" || retention.class === "cached" || retention.class === "pinned") {
19070
19453
  nextRetention.class = retention.class;
@@ -19084,7 +19467,7 @@ function normalizeSnapshotUpdateInput(payload) {
19084
19467
  return out;
19085
19468
  }
19086
19469
  function normalizeSnapshotValidateInput(payload) {
19087
- const input = asRecord4(payload);
19470
+ const input = asRecord5(payload);
19088
19471
  const cleanup = typeof input.cleanup === "string" ? input.cleanup.trim() : "";
19089
19472
  if (cleanup === "delete" || cleanup === "stop" || cleanup === "archive") {
19090
19473
  return { cleanup };
@@ -19092,7 +19475,7 @@ function normalizeSnapshotValidateInput(payload) {
19092
19475
  return {};
19093
19476
  }
19094
19477
  function normalizeForkInput(payload) {
19095
- const input = asRecord4(payload);
19478
+ const input = asRecord5(payload);
19096
19479
  const out = {};
19097
19480
  if (typeof input.snapshotId === "string" && input.snapshotId.trim()) {
19098
19481
  out.snapshotId = input.snapshotId.trim();
@@ -19148,7 +19531,7 @@ function normalizeSandboxEnvRefsForApp(value) {
19148
19531
  });
19149
19532
  }
19150
19533
  function normalizeTemplateLaunchInput(payload) {
19151
- const input = asRecord4(payload);
19534
+ const input = asRecord5(payload);
19152
19535
  const teamId = typeof input.teamId === "string" ? input.teamId.trim() : "";
19153
19536
  const projectId = typeof input.projectId === "string" ? input.projectId.trim() : "";
19154
19537
  const snapshotId = typeof input.snapshotId === "string" ? input.snapshotId.trim() : "";
@@ -19169,43 +19552,43 @@ function normalizeTemplateLaunchInput(payload) {
19169
19552
  };
19170
19553
  }
19171
19554
  function normalizeListFilesInput(payload) {
19172
- const input = asRecord4(payload);
19173
- const path46 = typeof input.path === "string" ? input.path.trim() : "";
19555
+ const input = asRecord5(payload);
19556
+ const path47 = typeof input.path === "string" ? input.path.trim() : "";
19174
19557
  const maxEntries = Number(input.maxEntries);
19175
19558
  return {
19176
- ...path46 ? { path: path46 } : {},
19559
+ ...path47 ? { path: path47 } : {},
19177
19560
  ...typeof input.recursive === "boolean" ? { recursive: input.recursive } : {},
19178
19561
  ...Number.isFinite(maxEntries) ? { maxEntries } : {}
19179
19562
  };
19180
19563
  }
19181
19564
  function normalizeSearchFilesInput(payload) {
19182
- const input = asRecord4(payload);
19565
+ const input = asRecord5(payload);
19183
19566
  const query = typeof input.query === "string" ? input.query.trim() : "";
19184
19567
  if (!query) {
19185
19568
  throw new Error("Sandbox file search query is required.");
19186
19569
  }
19187
- const path46 = typeof input.path === "string" ? input.path.trim() : "";
19570
+ const path47 = typeof input.path === "string" ? input.path.trim() : "";
19188
19571
  const maxResults = Number(input.maxResults);
19189
19572
  return {
19190
19573
  query,
19191
- ...path46 ? { path: path46 } : {},
19574
+ ...path47 ? { path: path47 } : {},
19192
19575
  ...Number.isFinite(maxResults) ? { maxResults } : {}
19193
19576
  };
19194
19577
  }
19195
19578
  function normalizeDeleteFileInput(payload) {
19196
- const input = asRecord4(payload);
19197
- const path46 = typeof input.path === "string" ? input.path.trim() : "";
19198
- if (!path46) {
19579
+ const input = asRecord5(payload);
19580
+ const path47 = typeof input.path === "string" ? input.path.trim() : "";
19581
+ if (!path47) {
19199
19582
  throw new Error("Sandbox file path is required.");
19200
19583
  }
19201
19584
  return {
19202
- path: path46,
19585
+ path: path47,
19203
19586
  recursive: typeof input.recursive === "boolean" ? input.recursive : void 0
19204
19587
  };
19205
19588
  }
19206
19589
  function normalizeDownloadFileInput(payload) {
19207
19590
  const input = normalizeDeleteFileInput(payload);
19208
- const raw = asRecord4(payload);
19591
+ const raw = asRecord5(payload);
19209
19592
  const offsetBytes = Number(raw.offsetBytes);
19210
19593
  const maxBytes = Number(raw.maxBytes);
19211
19594
  return {
@@ -19215,24 +19598,24 @@ function normalizeDownloadFileInput(payload) {
19215
19598
  };
19216
19599
  }
19217
19600
  function normalizeUploadFileInput(payload) {
19218
- const input = asRecord4(payload);
19219
- const path46 = typeof input.path === "string" ? input.path.trim() : "";
19601
+ const input = asRecord5(payload);
19602
+ const path47 = typeof input.path === "string" ? input.path.trim() : "";
19220
19603
  const contents = typeof input.contents === "string" ? input.contents : "";
19221
19604
  const contentsBase64 = typeof input.contentsBase64 === "string" ? input.contentsBase64.trim() : "";
19222
- if (!path46) {
19605
+ if (!path47) {
19223
19606
  throw new Error("Sandbox file path is required.");
19224
19607
  }
19225
19608
  if (!contents && !contentsBase64) {
19226
19609
  throw new Error("Sandbox file contents are required.");
19227
19610
  }
19228
19611
  return {
19229
- path: path46,
19612
+ path: path47,
19230
19613
  contents,
19231
19614
  contentsBase64
19232
19615
  };
19233
19616
  }
19234
19617
  function normalizeMoveFileInput(payload) {
19235
- const input = asRecord4(payload);
19618
+ const input = asRecord5(payload);
19236
19619
  const fromPath = typeof input.fromPath === "string" ? input.fromPath.trim() : "";
19237
19620
  const toPath = typeof input.toPath === "string" ? input.toPath.trim() : "";
19238
19621
  if (!fromPath || !toPath) {
@@ -19245,7 +19628,7 @@ function normalizeMoveFileInput(payload) {
19245
19628
  };
19246
19629
  }
19247
19630
  function normalizeGitBranchInput(payload) {
19248
- const input = asRecord4(payload);
19631
+ const input = asRecord5(payload);
19249
19632
  const branch = typeof input.branch === "string" ? input.branch.trim() : "";
19250
19633
  const startPoint = typeof input.startPoint === "string" ? input.startPoint.trim() : "";
19251
19634
  if (!branch) {
@@ -19258,10 +19641,10 @@ function normalizeGitBranchInput(payload) {
19258
19641
  };
19259
19642
  }
19260
19643
  function normalizeGitCommitInput(payload) {
19261
- const input = asRecord4(payload);
19644
+ const input = asRecord5(payload);
19262
19645
  const message = typeof input.message === "string" ? input.message.trim() : "";
19263
19646
  const all = input.all === true;
19264
- const paths = Array.isArray(input.paths) ? input.paths.filter((path46) => typeof path46 === "string" && path46.trim() !== "") : [];
19647
+ const paths = Array.isArray(input.paths) ? input.paths.filter((path47) => typeof path47 === "string" && path47.trim() !== "") : [];
19265
19648
  if (!message) {
19266
19649
  throw new Error("Sandbox git commit message is required.");
19267
19650
  }
@@ -19270,11 +19653,11 @@ function normalizeGitCommitInput(payload) {
19270
19653
  }
19271
19654
  return {
19272
19655
  message,
19273
- ...all ? { all: true } : { paths: paths.map((path46) => path46.trim()) }
19656
+ ...all ? { all: true } : { paths: paths.map((path47) => path47.trim()) }
19274
19657
  };
19275
19658
  }
19276
19659
  function normalizeGitPullInput(payload) {
19277
- const input = asRecord4(payload);
19660
+ const input = asRecord5(payload);
19278
19661
  const remote = typeof input.remote === "string" ? input.remote.trim() : "";
19279
19662
  const branch = typeof input.branch === "string" ? input.branch.trim() : "";
19280
19663
  const rebase = input.rebase === true;
@@ -19290,7 +19673,7 @@ function normalizeGitPullInput(payload) {
19290
19673
  };
19291
19674
  }
19292
19675
  function normalizeGitPushInput(payload) {
19293
- const input = asRecord4(payload);
19676
+ const input = asRecord5(payload);
19294
19677
  const remote = typeof input.remote === "string" ? input.remote.trim() : "";
19295
19678
  const branch = typeof input.branch === "string" ? input.branch.trim() : "";
19296
19679
  return {
@@ -19316,7 +19699,7 @@ async function sandboxRequestPayload(action) {
19316
19699
  };
19317
19700
  }
19318
19701
  if (action.type === "snapshot_catalog") {
19319
- const input = asRecord4(action.payload);
19702
+ const input = asRecord5(action.payload);
19320
19703
  const teamId = typeof input.teamId === "string" ? input.teamId.trim() : "";
19321
19704
  const projectId = typeof input.projectId === "string" ? input.projectId.trim() : "";
19322
19705
  const agentId = typeof input.agentId === "string" ? input.agentId.trim() : "";
@@ -19347,7 +19730,7 @@ async function sandboxRequestPayload(action) {
19347
19730
  };
19348
19731
  }
19349
19732
  if (action.type === "template_catalog") {
19350
- const input = asRecord4(action.payload);
19733
+ const input = asRecord5(action.payload);
19351
19734
  const teamId = typeof input.teamId === "string" ? input.teamId.trim() : "";
19352
19735
  const projectId = typeof input.projectId === "string" ? input.projectId.trim() : "";
19353
19736
  const query = typeof input.q === "string" ? input.q.trim() : "";
@@ -19369,7 +19752,7 @@ async function sandboxRequestPayload(action) {
19369
19752
  };
19370
19753
  }
19371
19754
  if (action.type === "integration_connections") {
19372
- const input = asRecord4(action.payload);
19755
+ const input = asRecord5(action.payload);
19373
19756
  const teamId = typeof input.teamId === "string" ? input.teamId.trim() : "";
19374
19757
  const projectId = typeof input.projectId === "string" ? input.projectId.trim() : "";
19375
19758
  const agentId = typeof input.agentId === "string" ? input.agentId.trim() : "";
@@ -19389,7 +19772,7 @@ async function sandboxRequestPayload(action) {
19389
19772
  };
19390
19773
  }
19391
19774
  if (action.type === "connected_app_status") {
19392
- const input = asRecord4(action.payload);
19775
+ const input = asRecord5(action.payload);
19393
19776
  const explicitTeamId = typeof input.teamId === "string" ? input.teamId.trim() : "";
19394
19777
  const projectId = typeof input.projectId === "string" ? input.projectId.trim() : "";
19395
19778
  const agentId = typeof input.agentId === "string" ? input.agentId.trim() : "";
@@ -19453,7 +19836,7 @@ async function sandboxRequestPayload(action) {
19453
19836
  };
19454
19837
  }
19455
19838
  if (action.type === "sandbox_runtime_preserve_source") {
19456
- const input = asRecord4(action.payload);
19839
+ const input = asRecord5(action.payload);
19457
19840
  return {
19458
19841
  ...await client.preserveSandboxRuntimeSource(
19459
19842
  action.runtimeId,
@@ -19468,7 +19851,7 @@ async function sandboxRequestPayload(action) {
19468
19851
  };
19469
19852
  }
19470
19853
  if (action.type === "sandbox_runtime_promote") {
19471
- const input = asRecord4(action.payload);
19854
+ const input = asRecord5(action.payload);
19472
19855
  return {
19473
19856
  ...await client.promoteSandboxRuntime(
19474
19857
  action.runtimeId,
@@ -19523,7 +19906,7 @@ async function sandboxRequestPayload(action) {
19523
19906
  };
19524
19907
  }
19525
19908
  if (action.type === "profile_push") {
19526
- const payload = asRecord4(action.payload);
19909
+ const payload = asRecord5(action.payload);
19527
19910
  const { teamId: _teamId, ...body } = payload;
19528
19911
  return {
19529
19912
  ...await requestSandboxPublicApiRoot({
@@ -19546,7 +19929,7 @@ async function sandboxRequestPayload(action) {
19546
19929
  sandboxApiUrl,
19547
19930
  path: "/projects",
19548
19931
  method: "POST",
19549
- body: asRecord4(action.payload)
19932
+ body: asRecord5(action.payload)
19550
19933
  }),
19551
19934
  account: account2
19552
19935
  };
@@ -19593,7 +19976,7 @@ async function sandboxRequestPayload(action) {
19593
19976
  };
19594
19977
  }
19595
19978
  if (action.type === "project_source_upload") {
19596
- const payload = asRecord4(action.payload);
19979
+ const payload = asRecord5(action.payload);
19597
19980
  const { teamId: _teamId, ...body } = payload;
19598
19981
  return {
19599
19982
  ...await requestSandboxPublicApiRoot({
@@ -19643,7 +20026,7 @@ async function sandboxRequestPayload(action) {
19643
20026
  sandboxApiUrl,
19644
20027
  path: "/agents",
19645
20028
  method: "POST",
19646
- body: asRecord4(action.payload)
20029
+ body: asRecord5(action.payload)
19647
20030
  }),
19648
20031
  account: account2
19649
20032
  };
@@ -19655,7 +20038,7 @@ async function sandboxRequestPayload(action) {
19655
20038
  sandboxApiUrl,
19656
20039
  path: `/agents/${encodeURIComponent(action.agentId)}/run`,
19657
20040
  method: "POST",
19658
- body: asRecord4(action.payload)
20041
+ body: asRecord5(action.payload)
19659
20042
  }),
19660
20043
  account: account2
19661
20044
  };
@@ -19674,7 +20057,7 @@ async function sandboxRequestPayload(action) {
19674
20057
  };
19675
20058
  }
19676
20059
  if (action.type === "agent_source_checks") {
19677
- const payload = asRecord4(action.payload);
20060
+ const payload = asRecord5(action.payload);
19678
20061
  const { teamId: _teamId, ...body } = payload;
19679
20062
  return {
19680
20063
  ...await requestSandboxPublicApiRoot({
@@ -19691,7 +20074,7 @@ async function sandboxRequestPayload(action) {
19691
20074
  };
19692
20075
  }
19693
20076
  if (action.type === "agent_source_publish") {
19694
- const payload = asRecord4(action.payload);
20077
+ const payload = asRecord5(action.payload);
19695
20078
  const { teamId: _teamId, ...body } = payload;
19696
20079
  return {
19697
20080
  ...await requestSandboxPublicApiRoot({
@@ -19762,7 +20145,7 @@ async function sandboxRequestPayload(action) {
19762
20145
  action.sandboxId
19763
20146
  )}/actions/${encodeURIComponent(action.actionName)}/run`,
19764
20147
  method: "POST",
19765
- body: asRecord4(action.payload)
20148
+ body: asRecord5(action.payload)
19766
20149
  }),
19767
20150
  account: account2
19768
20151
  };
@@ -19853,7 +20236,7 @@ async function sandboxRequestPayload(action) {
19853
20236
  if (action.type === "schedule_create") {
19854
20237
  return {
19855
20238
  ...await client.createSchedule(
19856
- asRecord4(action.payload)
20239
+ asRecord5(action.payload)
19857
20240
  ),
19858
20241
  account: account2
19859
20242
  };
@@ -20020,7 +20403,7 @@ async function sandboxRequestPayload(action) {
20020
20403
  return { ...await client.gitStatus(action.sandboxId), account: account2 };
20021
20404
  }
20022
20405
  if (action.type === "git_diff") {
20023
- const input = asRecord4(action.payload);
20406
+ const input = asRecord5(action.payload);
20024
20407
  const baseRef = typeof input.baseRef === "string" ? input.baseRef.trim() : "";
20025
20408
  return {
20026
20409
  ...await client.gitDiff(action.sandboxId, {
@@ -20030,7 +20413,7 @@ async function sandboxRequestPayload(action) {
20030
20413
  };
20031
20414
  }
20032
20415
  if (action.type === "git_export_patch") {
20033
- const input = asRecord4(action.payload);
20416
+ const input = asRecord5(action.payload);
20034
20417
  const baseRef = typeof input.baseRef === "string" ? input.baseRef.trim() : "";
20035
20418
  return {
20036
20419
  ...await client.gitExportPatch(action.sandboxId, {
@@ -20276,12 +20659,12 @@ function sandboxPublicApiRootUrl(sandboxApiUrl) {
20276
20659
  }
20277
20660
  return normalized.replace(/\/sandboxes\/?$/, "");
20278
20661
  }
20279
- function sandboxScopedCollectionPath(path46, queryInput) {
20662
+ function sandboxScopedCollectionPath(path47, queryInput) {
20280
20663
  const query = new URLSearchParams();
20281
20664
  if (queryInput.teamId) query.set("teamId", queryInput.teamId);
20282
20665
  if (queryInput.projectId) query.set("projectId", queryInput.projectId);
20283
20666
  if (queryInput.agentId) query.set("agentId", queryInput.agentId);
20284
- return `${path46}${query.size > 0 ? `?${query.toString()}` : ""}`;
20667
+ return `${path47}${query.size > 0 ? `?${query.toString()}` : ""}`;
20285
20668
  }
20286
20669
  async function requestSandboxApiRoot(params) {
20287
20670
  const response = await apiFetch(
@@ -20501,34 +20884,34 @@ async function executeAppServerSandboxTool(input) {
20501
20884
  });
20502
20885
  }
20503
20886
  async function editRemoteSandboxFile(input) {
20504
- const path46 = requiredString(input.args.path, "path");
20887
+ const path47 = requiredString(input.args.path, "path");
20505
20888
  const oldText = requiredString(input.args.oldText, "oldText");
20506
20889
  const newText = stringValue5(input.args.newText);
20507
- const downloaded = asRecord5(
20890
+ const downloaded = asRecord6(
20508
20891
  await input.sandboxRequest({
20509
20892
  type: "download_file",
20510
20893
  sandboxId: input.sandboxId,
20511
- payload: { path: path46, maxBytes: 1024 * 1024 }
20894
+ payload: { path: path47, maxBytes: 1024 * 1024 }
20512
20895
  })
20513
20896
  );
20514
- const file = asRecord5(downloaded.file);
20897
+ const file = asRecord6(downloaded.file);
20515
20898
  const content = optionalString(downloaded.contents) || optionalString(downloaded.content) || optionalString(file.contents) || optionalString(file.content) || decodeBase64(optionalString(file.contentsBase64));
20516
20899
  if (!content.includes(oldText)) {
20517
- throw new Error(`Text to replace was not found in ${path46}.`);
20900
+ throw new Error(`Text to replace was not found in ${path47}.`);
20518
20901
  }
20519
20902
  if (input.args.replaceAll !== true && content.indexOf(oldText) !== content.lastIndexOf(oldText)) {
20520
- throw new Error(`Text to replace is not unique in ${path46}.`);
20903
+ throw new Error(`Text to replace is not unique in ${path47}.`);
20521
20904
  }
20522
20905
  const nextContent = input.args.replaceAll === true ? content.split(oldText).join(newText) : content.replace(oldText, newText);
20523
20906
  return input.sandboxRequest({
20524
20907
  type: "upload_file",
20525
20908
  sandboxId: input.sandboxId,
20526
- payload: { path: path46, contents: nextContent }
20909
+ payload: { path: path47, contents: nextContent }
20527
20910
  });
20528
20911
  }
20529
20912
  function withDecodedFileContent(value) {
20530
- const result = asRecord5(value);
20531
- const file = asRecord5(result.file);
20913
+ const result = asRecord6(value);
20914
+ const file = asRecord6(result.file);
20532
20915
  const contentsBase64 = optionalString(file.contentsBase64);
20533
20916
  if (!contentsBase64) return value;
20534
20917
  return {
@@ -20543,7 +20926,7 @@ function decodeBase64(value) {
20543
20926
  if (!value) return "";
20544
20927
  return Buffer2.from(value, "base64").toString("utf8");
20545
20928
  }
20546
- function asRecord5(value) {
20929
+ function asRecord6(value) {
20547
20930
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
20548
20931
  }
20549
20932
  function stringValue5(value) {
@@ -20568,10 +20951,10 @@ function requiredNumber(value, name) {
20568
20951
 
20569
20952
  // ../server/src/runtime/app-server-workspace.ts
20570
20953
  function createAppServerWorkspace(input) {
20571
- const workspaceDir = path19.resolve(input.workspaceDir);
20954
+ const workspaceDir = path20.resolve(input.workspaceDir);
20572
20955
  const locks = /* @__PURE__ */ new Map();
20573
20956
  async function workspaceForSession(session) {
20574
- const repoPath = path19.resolve(session.cwd?.trim() || workspaceDir);
20957
+ const repoPath = path20.resolve(session.cwd?.trim() || workspaceDir);
20575
20958
  const app = workspaceApp(repoPath, session.updatedAt);
20576
20959
  const state = await loadWorkspaceStateAtPath(
20577
20960
  { workspacePath: repoPath, repoPath },
@@ -20729,7 +21112,7 @@ function createAppServerWorkspace(input) {
20729
21112
  function workspaceApp(repoPath, updatedAt) {
20730
21113
  return {
20731
21114
  id: localPathWorkspaceId(repoPath),
20732
- name: path19.basename(repoPath) || "Sandbox workspace",
21115
+ name: path20.basename(repoPath) || "Sandbox workspace",
20733
21116
  description: null,
20734
21117
  visibility: "private",
20735
21118
  gitOwner: null,
@@ -20748,7 +21131,7 @@ function sameDiff(current, baseline) {
20748
21131
  // ../server/src/runtime/bundled-authoring-skills.ts
20749
21132
  import { createHash as createHash3 } from "node:crypto";
20750
21133
  import { access, readFile } from "node:fs/promises";
20751
- import path20 from "node:path";
21134
+ import path21 from "node:path";
20752
21135
  import { fileURLToPath } from "node:url";
20753
21136
  var BUNDLED_AUTHORING_SKILL_NAMES = [
20754
21137
  "openpond-skill-authoring",
@@ -20767,7 +21150,7 @@ var REFERENCE_FILES = {
20767
21150
  "references/validation-and-repair.md"
20768
21151
  ]
20769
21152
  };
20770
- var moduleDirectory = path20.dirname(fileURLToPath(import.meta.url));
21153
+ var moduleDirectory = path21.dirname(fileURLToPath(import.meta.url));
20771
21154
  function isBundledAuthoringSkillName(value) {
20772
21155
  return BUNDLED_AUTHORING_SKILL_NAMES.includes(value);
20773
21156
  }
@@ -20781,7 +21164,7 @@ async function loadBundledAuthoringProfileSkill(name, repoRoot = process.cwd())
20781
21164
  if (!builtIn) throw new Error(`Built-in OpenPond authoring skill metadata not found: ${name}`);
20782
21165
  return {
20783
21166
  ...builtIn,
20784
- path: path20.join(root, "SKILL.md"),
21167
+ path: path21.join(root, "SKILL.md"),
20785
21168
  sourcePath: root,
20786
21169
  charCount: body.length,
20787
21170
  sourceHash: createHash3("sha256").update(body).digest("hex"),
@@ -20806,8 +21189,8 @@ async function readBundledAuthoringProfileSkill(name, repoRoot = process.cwd())
20806
21189
  async function loadBundledAuthoringSkillBundle(name, repoRoot = process.cwd()) {
20807
21190
  const root = await resolveBundledAuthoringSkillRoot(name, repoRoot);
20808
21191
  const [skill, ...references] = await Promise.all([
20809
- readFile(path20.join(root, "SKILL.md"), "utf8"),
20810
- ...REFERENCE_FILES[name].map((relativePath) => readFile(path20.join(root, relativePath), "utf8"))
21192
+ readFile(path21.join(root, "SKILL.md"), "utf8"),
21193
+ ...REFERENCE_FILES[name].map((relativePath) => readFile(path21.join(root, relativePath), "utf8"))
20811
21194
  ]);
20812
21195
  return [
20813
21196
  skill.trim(),
@@ -20819,14 +21202,14 @@ ${reference.trim()}`)
20819
21202
  }
20820
21203
  async function resolveBundledAuthoringSkillRoot(name, repoRoot = process.cwd(), executablePath = process.execPath) {
20821
21204
  const candidates = [
20822
- path20.resolve(repoRoot, "apps", "cli", "skills", name),
20823
- path20.resolve(repoRoot, "dist", "skills", name),
20824
- path20.resolve(path20.dirname(executablePath), "skills", name),
20825
- path20.resolve(moduleDirectory, "skills", name),
20826
- path20.resolve(moduleDirectory, "..", "skills", name)
21205
+ path21.resolve(repoRoot, "apps", "cli", "skills", name),
21206
+ path21.resolve(repoRoot, "dist", "skills", name),
21207
+ path21.resolve(path21.dirname(executablePath), "skills", name),
21208
+ path21.resolve(moduleDirectory, "skills", name),
21209
+ path21.resolve(moduleDirectory, "..", "skills", name)
20827
21210
  ];
20828
21211
  for (const candidate of candidates) {
20829
- if (await access(path20.join(candidate, "SKILL.md")).then(() => true, () => false)) return candidate;
21212
+ if (await access(path21.join(candidate, "SKILL.md")).then(() => true, () => false)) return candidate;
20830
21213
  }
20831
21214
  throw new Error(`Bundled OpenPond authoring skill ${name} was not found. Checked: ${candidates.join(", ")}`);
20832
21215
  }
@@ -20971,8 +21354,35 @@ function notificationMethod(name) {
20971
21354
  return "turn/event";
20972
21355
  }
20973
21356
 
21357
+ // ../server/src/harness/local-harness-evaluation-review-model.ts
21358
+ import { randomUUID as randomUUID6 } from "node:crypto";
21359
+ function createLocalHarnessEvaluationReviewModelStream(streamOpenPondHostedChatTurn2) {
21360
+ return async function* ({ messages, signal }) {
21361
+ for await (const delta of streamOpenPondHostedChatTurn2({
21362
+ model: DEFAULT_OPENPOND_CHAT_MODEL,
21363
+ messages,
21364
+ requestId: `harness-continuous-review:${randomUUID6()}`,
21365
+ reasoningEffort: "medium",
21366
+ maxTokens: DEFAULT_EVALUATION_REVIEW_MAX_OUTPUT_TOKENS,
21367
+ signal
21368
+ })) {
21369
+ if (delta.type === "text_delta" && delta.text) {
21370
+ yield { text: delta.text };
21371
+ } else if (delta.type === "usage") {
21372
+ yield {
21373
+ usage: {
21374
+ promptTokens: delta.usage.prompt_tokens ?? 0,
21375
+ completionTokens: delta.usage.completion_tokens ?? 0,
21376
+ totalTokens: delta.usage.total_tokens ?? 0
21377
+ }
21378
+ };
21379
+ }
21380
+ }
21381
+ };
21382
+ }
21383
+
20974
21384
  // ../server/src/harness/local-harness-taskset-review.ts
20975
- import path32 from "node:path";
21385
+ import path33 from "node:path";
20976
21386
 
20977
21387
  // ../../packages/taskset-sdk/dist/graders.js
20978
21388
  async function gradeAttempt(input) {
@@ -21123,7 +21533,7 @@ function normalizedFinalAnswer(value) {
21123
21533
 
21124
21534
  // ../../packages/taskset-sdk/dist/materialize.js
21125
21535
  import { access as access2, mkdir, readFile as readFile2, writeFile } from "node:fs/promises";
21126
- import path21 from "node:path";
21536
+ import path22 from "node:path";
21127
21537
 
21128
21538
  // ../../packages/taskset-sdk/dist/validation.js
21129
21539
  function validateTaskset(input) {
@@ -21318,13 +21728,13 @@ function validateWorkExecution(taskset, issues) {
21318
21728
  const assetIds = /* @__PURE__ */ new Set();
21319
21729
  const fileNames = /* @__PURE__ */ new Set();
21320
21730
  for (const [assetIndex, asset2] of (task.assets ?? []).entries()) {
21321
- const path46 = `tasks.${taskIndex}.assets.${assetIndex}`;
21731
+ const path47 = `tasks.${taskIndex}.assets.${assetIndex}`;
21322
21732
  if (assetIds.has(asset2.id)) {
21323
21733
  issues.push({
21324
21734
  code: "work_asset_duplicate_id",
21325
21735
  severity: "error",
21326
21736
  message: `Task ${task.id} repeats asset id ${asset2.id}.`,
21327
- path: `${path46}.id`
21737
+ path: `${path47}.id`
21328
21738
  });
21329
21739
  }
21330
21740
  if (fileNames.has(asset2.fileName)) {
@@ -21332,7 +21742,7 @@ function validateWorkExecution(taskset, issues) {
21332
21742
  code: "work_asset_duplicate_name",
21333
21743
  severity: "error",
21334
21744
  message: `Task ${task.id} repeats staged file name ${asset2.fileName}.`,
21335
- path: `${path46}.fileName`
21745
+ path: `${path47}.fileName`
21336
21746
  });
21337
21747
  }
21338
21748
  assetIds.add(asset2.id);
@@ -21342,7 +21752,7 @@ function validateWorkExecution(taskset, issues) {
21342
21752
  code: "work_asset_task_source_missing",
21343
21753
  severity: "error",
21344
21754
  message: `Asset ${asset2.id} references source ${asset2.sourceRefId} outside task ${task.id}.`,
21345
- path: `${path46}.sourceRefId`
21755
+ path: `${path47}.sourceRefId`
21346
21756
  });
21347
21757
  }
21348
21758
  const source = sourceById.get(asset2.sourceRefId);
@@ -21351,14 +21761,14 @@ function validateWorkExecution(taskset, issues) {
21351
21761
  code: "work_asset_source_missing",
21352
21762
  severity: "error",
21353
21763
  message: `Asset ${asset2.id} references missing source ${asset2.sourceRefId}.`,
21354
- path: `${path46}.sourceRefId`
21764
+ path: `${path47}.sourceRefId`
21355
21765
  });
21356
21766
  } else if ("sourceFileHashes" in source && !source.sourceFileHashes.includes(asset2.sha256)) {
21357
21767
  issues.push({
21358
21768
  code: "work_asset_hash_unregistered",
21359
21769
  severity: "error",
21360
21770
  message: `Asset ${asset2.id} hash is not registered by source ${asset2.sourceRefId}.`,
21361
- path: `${path46}.sha256`
21771
+ path: `${path47}.sha256`
21362
21772
  });
21363
21773
  }
21364
21774
  if (source && "kind" in source && source.kind === "uploaded_file" && !source.originalFileNames.includes(asset2.fileName)) {
@@ -21366,7 +21776,7 @@ function validateWorkExecution(taskset, issues) {
21366
21776
  code: "work_asset_name_unregistered",
21367
21777
  severity: "error",
21368
21778
  message: `Asset ${asset2.id} file name is not registered by source ${asset2.sourceRefId}.`,
21369
- path: `${path46}.fileName`
21779
+ path: `${path47}.fileName`
21370
21780
  });
21371
21781
  }
21372
21782
  if (source && "kind" in source && source.kind === "uploaded_file" && !source.mediaTypes.includes(asset2.mediaType)) {
@@ -21374,7 +21784,7 @@ function validateWorkExecution(taskset, issues) {
21374
21784
  code: "work_asset_media_type_unregistered",
21375
21785
  severity: "error",
21376
21786
  message: `Asset ${asset2.id} media type is not registered by source ${asset2.sourceRefId}.`,
21377
- path: `${path46}.mediaType`
21787
+ path: `${path47}.mediaType`
21378
21788
  });
21379
21789
  }
21380
21790
  if (asset2.split !== task.split) {
@@ -21382,20 +21792,20 @@ function validateWorkExecution(taskset, issues) {
21382
21792
  code: "work_asset_split_mismatch",
21383
21793
  severity: "error",
21384
21794
  message: `Asset ${asset2.id} is assigned to ${asset2.split}, not task split ${task.split}.`,
21385
- path: `${path46}.split`
21795
+ path: `${path47}.split`
21386
21796
  });
21387
21797
  }
21388
21798
  }
21389
21799
  const outputPaths = /* @__PURE__ */ new Set();
21390
21800
  for (const [outputIndex, output] of (task.requiredOutputs ?? []).entries()) {
21391
21801
  const normalized = output.path.replaceAll("\\", "/");
21392
- const path46 = `tasks.${taskIndex}.requiredOutputs.${outputIndex}.path`;
21802
+ const path47 = `tasks.${taskIndex}.requiredOutputs.${outputIndex}.path`;
21393
21803
  if (outputPaths.has(normalized)) {
21394
21804
  issues.push({
21395
21805
  code: "work_output_duplicate_path",
21396
21806
  severity: "error",
21397
21807
  message: `Task ${task.id} repeats required output path ${normalized}.`,
21398
- path: path46
21808
+ path: path47
21399
21809
  });
21400
21810
  }
21401
21811
  outputPaths.add(normalized);
@@ -21492,17 +21902,17 @@ async function buildTaskset(input, directory, options = {}) {
21492
21902
  const report = validateTaskset(taskset);
21493
21903
  if (!report.valid)
21494
21904
  throw new Error(report.issues.map((issue) => `${issue.code}: ${issue.message}`).join("\n"));
21495
- await mkdir(path21.join(directory, "data"), { recursive: true });
21496
- await mkdir(path21.join(directory, "graders"), { recursive: true });
21497
- await mkdir(path21.join(directory, "environment"), { recursive: true });
21498
- await mkdir(path21.join(directory, "fixtures"), { recursive: true });
21905
+ await mkdir(path22.join(directory, "data"), { recursive: true });
21906
+ await mkdir(path22.join(directory, "graders"), { recursive: true });
21907
+ await mkdir(path22.join(directory, "environment"), { recursive: true });
21908
+ await mkdir(path22.join(directory, "fixtures"), { recursive: true });
21499
21909
  const files = [
21500
- path21.join(directory, "taskset.json"),
21501
- path21.join(directory, "capabilities.json"),
21502
- path21.join(directory, "data", "tasks.jsonl"),
21503
- path21.join(directory, "graders", "graders.json"),
21504
- path21.join(directory, "fixtures", "grader-fixtures.json"),
21505
- path21.join(directory, "environment", "taskset.ts")
21910
+ path22.join(directory, "taskset.json"),
21911
+ path22.join(directory, "capabilities.json"),
21912
+ path22.join(directory, "data", "tasks.jsonl"),
21913
+ path22.join(directory, "graders", "graders.json"),
21914
+ path22.join(directory, "fixtures", "grader-fixtures.json"),
21915
+ path22.join(directory, "environment", "taskset.ts")
21506
21916
  ];
21507
21917
  await writeFile(files[0], canonicalJson(taskset), "utf8");
21508
21918
  await writeFile(files[1], canonicalJson(taskset.capabilities), "utf8");
@@ -21512,8 +21922,8 @@ async function buildTaskset(input, directory, options = {}) {
21512
21922
  await writeFile(files[5], generatedEnvironmentSource(taskset), "utf8");
21513
21923
  for (const generated of options.generatedFiles ?? []) {
21514
21924
  const relative = safeGeneratedPath(generated.path, generated.role);
21515
- const destination = path21.join(directory, relative);
21516
- await mkdir(path21.dirname(destination), { recursive: true });
21925
+ const destination = path22.join(directory, relative);
21926
+ await mkdir(path22.dirname(destination), { recursive: true });
21517
21927
  await writeFile(destination, generated.content, "utf8");
21518
21928
  files.push(destination);
21519
21929
  }
@@ -21522,7 +21932,7 @@ async function buildTaskset(input, directory, options = {}) {
21522
21932
  continue;
21523
21933
  const relative = safeGeneratedPath(grader.module, "verifier");
21524
21934
  try {
21525
- await access2(path21.join(directory, relative));
21935
+ await access2(path22.join(directory, relative));
21526
21936
  } catch {
21527
21937
  throw new Error(`Custom verifier ${grader.id} is missing generated source ${relative}.`);
21528
21938
  }
@@ -21531,7 +21941,7 @@ async function buildTaskset(input, directory, options = {}) {
21531
21941
  }
21532
21942
  function safeGeneratedPath(value, role) {
21533
21943
  const normalized = value.replaceAll("\\", "/");
21534
- if (path21.posix.isAbsolute(normalized) || normalized.split("/").includes(".."))
21944
+ if (path22.posix.isAbsolute(normalized) || normalized.split("/").includes(".."))
21535
21945
  throw new Error(`Generated ${role} path must stay inside the Taskset: ${value}.`);
21536
21946
  const prefix = role === "verifier" ? "graders/" : role === "environment" ? "environment/" : "fixtures/";
21537
21947
  if (!normalized.startsWith(prefix))
@@ -21773,18 +22183,18 @@ function uniqueObjects(values) {
21773
22183
  // ../server/src/training/task-authoring-skill.ts
21774
22184
  import { access as access3, readFile as readFile3 } from "node:fs/promises";
21775
22185
  import { createHash as createHash4 } from "node:crypto";
21776
- import path22 from "node:path";
22186
+ import path23 from "node:path";
21777
22187
  import { fileURLToPath as fileURLToPath2 } from "node:url";
21778
22188
  var SKILL_DIRECTORY = "openpond-taskset-authoring";
21779
22189
  var SKILL_ARTIFACT_FILE = "artifact.json";
21780
- var moduleDirectory2 = path22.dirname(fileURLToPath2(import.meta.url));
22190
+ var moduleDirectory2 = path23.dirname(fileURLToPath2(import.meta.url));
21781
22191
  async function loadTasksetAuthoringSkillBundle(repoRoot = process.cwd()) {
21782
22192
  return (await loadTasksetAuthoringSkillArtifact(repoRoot)).bundle;
21783
22193
  }
21784
22194
  async function loadTasksetAuthoringSkillArtifact(repoRoot = process.cwd()) {
21785
22195
  const skillRoot = await resolveTasksetAuthoringSkillRoot(repoRoot);
21786
22196
  const parsed = JSON.parse(
21787
- await readFile3(path22.join(skillRoot, SKILL_ARTIFACT_FILE), "utf8")
22197
+ await readFile3(path23.join(skillRoot, SKILL_ARTIFACT_FILE), "utf8")
21788
22198
  );
21789
22199
  if (parsed.schemaVersion !== 1 || parsed.skillName !== SKILL_DIRECTORY || !parsed.artifactVersion || !parsed.bundle || !/^[a-f0-9]{64}$/.test(parsed.contentHash)) {
21790
22200
  throw new Error("Bundled Taskset Authoring artifact is invalid.");
@@ -21810,7 +22220,7 @@ async function loadTasksetAuthoringProfileSkill(repoRoot = process.cwd()) {
21810
22220
  const builtIn = BUILT_IN_OPENPOND_PROFILE_SKILLS[0];
21811
22221
  return {
21812
22222
  ...builtIn,
21813
- path: path22.join(root, "SKILL.md"),
22223
+ path: path23.join(root, "SKILL.md"),
21814
22224
  sourcePath: root,
21815
22225
  charCount: body.length,
21816
22226
  sourceHash: artifact.contentHash,
@@ -21835,14 +22245,14 @@ async function readTasksetAuthoringProfileSkill(repoRoot = process.cwd()) {
21835
22245
  async function resolveTasksetAuthoringSkillRoot(repoRoot = process.cwd(), executablePath = process.execPath) {
21836
22246
  const candidates = [
21837
22247
  process.env.OPENPOND_TASKSET_AUTHORING_SKILL_ROOT,
21838
- path22.resolve(repoRoot, "apps", "cli", "skills", SKILL_DIRECTORY),
21839
- path22.resolve(repoRoot, "dist", "skills", SKILL_DIRECTORY),
21840
- path22.resolve(path22.dirname(executablePath), "skills", SKILL_DIRECTORY),
21841
- path22.resolve(moduleDirectory2, "skills", SKILL_DIRECTORY),
21842
- path22.resolve(moduleDirectory2, "..", "skills", SKILL_DIRECTORY)
22248
+ path23.resolve(repoRoot, "apps", "cli", "skills", SKILL_DIRECTORY),
22249
+ path23.resolve(repoRoot, "dist", "skills", SKILL_DIRECTORY),
22250
+ path23.resolve(path23.dirname(executablePath), "skills", SKILL_DIRECTORY),
22251
+ path23.resolve(moduleDirectory2, "skills", SKILL_DIRECTORY),
22252
+ path23.resolve(moduleDirectory2, "..", "skills", SKILL_DIRECTORY)
21843
22253
  ].filter((candidate) => Boolean(candidate));
21844
22254
  for (const candidate of candidates) {
21845
- if (await access3(path22.join(candidate, SKILL_ARTIFACT_FILE)).then(
22255
+ if (await access3(path23.join(candidate, SKILL_ARTIFACT_FILE)).then(
21846
22256
  () => true,
21847
22257
  () => false
21848
22258
  )) {
@@ -21853,8 +22263,8 @@ async function resolveTasksetAuthoringSkillRoot(repoRoot = process.cwd(), execut
21853
22263
  }
21854
22264
 
21855
22265
  // ../server/src/training/task-creator.ts
21856
- import { randomUUID as randomUUID8 } from "node:crypto";
21857
- import path24 from "node:path";
22266
+ import { randomUUID as randomUUID9 } from "node:crypto";
22267
+ import path25 from "node:path";
21858
22268
 
21859
22269
  // ../server/src/training/privacy.ts
21860
22270
  var SECRET_PATTERNS = [
@@ -21934,18 +22344,18 @@ function trajectoryMessages(task, trajectory) {
21934
22344
  }
21935
22345
 
21936
22346
  // ../server/src/training/cross-system-operations/expert-bootstrap-service.ts
21937
- import path23 from "node:path";
22347
+ import path24 from "node:path";
21938
22348
 
21939
22349
  // ../server/src/training/cross-system-operations/environment.ts
21940
22350
  import { Buffer as Buffer3 } from "node:buffer";
21941
22351
 
21942
22352
  // ../server/src/training/cross-system-operations/python-sandbox.ts
21943
- import { execFile, spawn as spawn2 } from "node:child_process";
22353
+ import { execFile as execFile2, spawn as spawn2 } from "node:child_process";
21944
22354
  import { tmpdir } from "node:os";
21945
22355
  import readline from "node:readline";
21946
- import { randomUUID as randomUUID6 } from "node:crypto";
21947
- import { promisify } from "node:util";
21948
- var execFileAsync = promisify(execFile);
22356
+ import { randomUUID as randomUUID7 } from "node:crypto";
22357
+ import { promisify as promisify2 } from "node:util";
22358
+ var execFileAsync2 = promisify2(execFile2);
21949
22359
  var DEFAULT_MAX_MEMORY_BYTES = 256 * 1024 * 1024;
21950
22360
  var DEFAULT_MEMORY_POLL_INTERVAL_MS = 100;
21951
22361
  var MAX_STDERR_BYTES = 4096;
@@ -22049,7 +22459,7 @@ var PersistentPythonSandbox = class {
22049
22459
  if (this.closed) throw new Error("Python sandbox is closed.");
22050
22460
  if (Buffer.byteLength(code, "utf8") > 1e4) throw new Error("Python code exceeds the 10,000-byte limit.");
22051
22461
  if (signal?.aborted) throw abortError(signal);
22052
- const id = `python_${randomUUID6()}`;
22462
+ const id = `python_${randomUUID7()}`;
22053
22463
  const result = new Promise((resolve, reject) => {
22054
22464
  const timer = setTimeout(() => {
22055
22465
  this.pending.delete(id);
@@ -22153,7 +22563,7 @@ async function readResidentMemoryBytes(pid) {
22153
22563
  if (!Number.isInteger(pid) || pid <= 0) return null;
22154
22564
  try {
22155
22565
  if (process.platform === "win32") {
22156
- const { stdout: stdout2 } = await execFileAsync(
22566
+ const { stdout: stdout2 } = await execFileAsync2(
22157
22567
  "powershell.exe",
22158
22568
  [
22159
22569
  "-NoProfile",
@@ -22166,7 +22576,7 @@ async function readResidentMemoryBytes(pid) {
22166
22576
  const bytes = Number(String(stdout2).trim());
22167
22577
  return Number.isFinite(bytes) && bytes >= 0 ? bytes : null;
22168
22578
  }
22169
- const { stdout } = await execFileAsync(
22579
+ const { stdout } = await execFileAsync2(
22170
22580
  "ps",
22171
22581
  ["-o", "rss=", "-p", String(pid)],
22172
22582
  { encoding: "utf8", timeout: 1e3, windowsHide: true }
@@ -23309,7 +23719,7 @@ function createCrossSystemExpertBootstrapService(deps) {
23309
23719
  const generatedFiles = await generatedTaskFiles(taskset, records, approval);
23310
23720
  await buildTaskset(
23311
23721
  updated,
23312
- path23.join(deps.storeDir, "training", "tasksets", updated.id),
23722
+ path24.join(deps.storeDir, "training", "tasksets", updated.id),
23313
23723
  { generatedFiles }
23314
23724
  );
23315
23725
  await deps.store.upsertTaskset(updated);
@@ -23849,7 +24259,7 @@ function isCrossSystemToolName(value) {
23849
24259
  }
23850
24260
 
23851
24261
  // ../server/src/training/cross-system-operations/rollout.ts
23852
- import { randomUUID as randomUUID7 } from "node:crypto";
24262
+ import { randomUUID as randomUUID8 } from "node:crypto";
23853
24263
 
23854
24264
  // ../server/src/openpond/native-tool-calls.ts
23855
24265
  var NativeToolCallAccumulator = class {
@@ -24106,47 +24516,47 @@ function localAdapterToolInstruction(tools, toolChoice) {
24106
24516
  }
24107
24517
  return crossSystemLocalToolSystemPrompt(toolChoice ?? "auto");
24108
24518
  }
24109
- function validateJsonSchema(value, schema, path46) {
24519
+ function validateJsonSchema(value, schema, path47) {
24110
24520
  if (Array.isArray(schema.anyOf)) {
24111
- return schema.anyOf.some((candidate) => isRecord4(candidate) && !validateJsonSchema(value, candidate, path46)) ? null : `${path46} does not match an allowed schema.`;
24521
+ return schema.anyOf.some((candidate) => isRecord4(candidate) && !validateJsonSchema(value, candidate, path47)) ? null : `${path47} does not match an allowed schema.`;
24112
24522
  }
24113
24523
  const type = schema.type;
24114
24524
  if (type === "object") {
24115
- if (!isRecord4(value)) return `${path46} must be an object.`;
24525
+ if (!isRecord4(value)) return `${path47} must be an object.`;
24116
24526
  const properties = isRecord4(schema.properties) ? schema.properties : {};
24117
24527
  const required = Array.isArray(schema.required) ? schema.required.filter((item) => typeof item === "string") : [];
24118
- for (const key of required) if (!Object.hasOwn(value, key)) return `${path46}.${key} is required.`;
24528
+ for (const key of required) if (!Object.hasOwn(value, key)) return `${path47}.${key} is required.`;
24119
24529
  if (schema.additionalProperties === false) {
24120
24530
  const extra = Object.keys(value).find((key) => !Object.hasOwn(properties, key));
24121
- if (extra) return `${path46}.${extra} is not allowed.`;
24531
+ if (extra) return `${path47}.${extra} is not allowed.`;
24122
24532
  }
24123
24533
  for (const [key, item] of Object.entries(value)) {
24124
24534
  const propertySchema = properties[key];
24125
24535
  if (isRecord4(propertySchema)) {
24126
- const issue = validateJsonSchema(item, propertySchema, `${path46}.${key}`);
24536
+ const issue = validateJsonSchema(item, propertySchema, `${path47}.${key}`);
24127
24537
  if (issue) return issue;
24128
24538
  }
24129
24539
  }
24130
24540
  } else if (type === "array") {
24131
- if (!Array.isArray(value)) return `${path46} must be an array.`;
24132
- if (typeof schema.minItems === "number" && value.length < schema.minItems) return `${path46} has too few items.`;
24133
- if (typeof schema.maxItems === "number" && value.length > schema.maxItems) return `${path46} has too many items.`;
24134
- if (schema.uniqueItems === true && new Set(value.map((item) => JSON.stringify(item))).size !== value.length) return `${path46} items must be unique.`;
24541
+ if (!Array.isArray(value)) return `${path47} must be an array.`;
24542
+ if (typeof schema.minItems === "number" && value.length < schema.minItems) return `${path47} has too few items.`;
24543
+ if (typeof schema.maxItems === "number" && value.length > schema.maxItems) return `${path47} has too many items.`;
24544
+ if (schema.uniqueItems === true && new Set(value.map((item) => JSON.stringify(item))).size !== value.length) return `${path47} items must be unique.`;
24135
24545
  if (isRecord4(schema.items)) for (let index = 0; index < value.length; index += 1) {
24136
- const issue = validateJsonSchema(value[index], schema.items, `${path46}[${index}]`);
24546
+ const issue = validateJsonSchema(value[index], schema.items, `${path47}[${index}]`);
24137
24547
  if (issue) return issue;
24138
24548
  }
24139
24549
  } else if (type === "string") {
24140
- if (typeof value !== "string") return `${path46} must be a string.`;
24141
- if (typeof schema.minLength === "number" && value.length < schema.minLength) return `${path46} is too short.`;
24142
- if (typeof schema.maxLength === "number" && value.length > schema.maxLength) return `${path46} is too long.`;
24143
- if (schema.format === "date" && !/^\d{4}-\d{2}-\d{2}$/.test(value)) return `${path46} must be an ISO date.`;
24550
+ if (typeof value !== "string") return `${path47} must be a string.`;
24551
+ if (typeof schema.minLength === "number" && value.length < schema.minLength) return `${path47} is too short.`;
24552
+ if (typeof schema.maxLength === "number" && value.length > schema.maxLength) return `${path47} is too long.`;
24553
+ if (schema.format === "date" && !/^\d{4}-\d{2}-\d{2}$/.test(value)) return `${path47} must be an ISO date.`;
24144
24554
  } else if (type === "integer") {
24145
- if (!Number.isInteger(value)) return `${path46} must be an integer.`;
24146
- if (typeof schema.minimum === "number" && Number(value) < schema.minimum) return `${path46} is below its minimum.`;
24147
- if (typeof schema.maximum === "number" && Number(value) > schema.maximum) return `${path46} exceeds its maximum.`;
24148
- } else if (type === "null" && value !== null) return `${path46} must be null.`;
24149
- if (Array.isArray(schema.enum) && !schema.enum.some((candidate) => Object.is(candidate, value))) return `${path46} is outside the allowed enum.`;
24555
+ if (!Number.isInteger(value)) return `${path47} must be an integer.`;
24556
+ if (typeof schema.minimum === "number" && Number(value) < schema.minimum) return `${path47} is below its minimum.`;
24557
+ if (typeof schema.maximum === "number" && Number(value) > schema.maximum) return `${path47} exceeds its maximum.`;
24558
+ } else if (type === "null" && value !== null) return `${path47} must be null.`;
24559
+ if (Array.isArray(schema.enum) && !schema.enum.some((candidate) => Object.is(candidate, value))) return `${path47} is outside the allowed enum.`;
24150
24560
  return null;
24151
24561
  }
24152
24562
  function parseArgumentsForHistory(value) {
@@ -24224,7 +24634,7 @@ function stableSuffix(name, args) {
24224
24634
 
24225
24635
  // ../server/src/training/cross-system-operations/rollout.ts
24226
24636
  async function runCrossSystemRollout(input) {
24227
- const id = input.trajectoryId ?? `cso_rollout_${randomUUID7()}`;
24637
+ const id = input.trajectoryId ?? `cso_rollout_${randomUUID8()}`;
24228
24638
  const startedAt = (/* @__PURE__ */ new Date()).toISOString();
24229
24639
  const environment = new CrossSystemEnvironment({
24230
24640
  attemptId: id,
@@ -25242,7 +25652,7 @@ function createTaskCreatorService(deps) {
25242
25652
  state: "failed",
25243
25653
  blockedReason: "OpenPond restarted during Taskset authoring. The reviewed evidence and proposal were preserved; start authoring again to continue.",
25244
25654
  transcript: [...snapshot.transcript, {
25245
- id: `task_message_${randomUUID8()}`,
25655
+ id: `task_message_${randomUUID9()}`,
25246
25656
  role: "assistant",
25247
25657
  text: "Taskset authoring stopped when OpenPond restarted. The reviewed evidence and any completed proposal were preserved.",
25248
25658
  createdAt: timestamp
@@ -25261,7 +25671,7 @@ function createTaskCreatorService(deps) {
25261
25671
  const timestamp = now();
25262
25672
  const source = TrainingSourceRefSchema.parse({
25263
25673
  schemaVersion: "openpond.trainingSource.v1",
25264
- id: `training_source_${randomUUID8()}`,
25674
+ id: `training_source_${randomUUID9()}`,
25265
25675
  profileId: input.profileId,
25266
25676
  sessionId: input.sessionId,
25267
25677
  turnIds,
@@ -25316,10 +25726,10 @@ function createTaskCreatorService(deps) {
25316
25726
  const sources = await requireSources(input.profileId, input.sourceIds);
25317
25727
  assertSourcesEligible(sources);
25318
25728
  const timestamp = now();
25319
- const disclosureApprovalId = input.analysisModel && sources.length ? `task_disclosure_${randomUUID8()}` : null;
25729
+ const disclosureApprovalId = input.analysisModel && sources.length ? `task_disclosure_${randomUUID9()}` : null;
25320
25730
  const request = TaskCreationRequestSchema.parse({
25321
25731
  schemaVersion: "openpond.taskCreationRequest.v1",
25322
- id: `task_creation_request_${randomUUID8()}`,
25732
+ id: `task_creation_request_${randomUUID9()}`,
25323
25733
  profileId: input.profileId,
25324
25734
  surface: input.surface,
25325
25735
  mode: input.mode,
@@ -25354,13 +25764,13 @@ function createTaskCreatorService(deps) {
25354
25764
  });
25355
25765
  const needsDisclosure = request.disclosure.status === "pending";
25356
25766
  const blockingQuestions = [
25357
- ...!request.objective && request.mode === "customize" ? [{ id: `task_question_${randomUUID8()}`, kind: "objective", prompt: "What repeatable capability should this Taskset teach or evaluate?", answer: null }] : [],
25358
- ...!sources.length && !input.buildSpecification ? [{ id: `task_question_${randomUUID8()}`, kind: "success_signal", prompt: "Add at least one successful example, correction, reviewer choice, or outcome-bearing run so the authoring model can ground this capability without fabricating demonstrations.", answer: null }] : []
25767
+ ...!request.objective && request.mode === "customize" ? [{ id: `task_question_${randomUUID9()}`, kind: "objective", prompt: "What repeatable capability should this Taskset teach or evaluate?", answer: null }] : [],
25768
+ ...!sources.length && !input.buildSpecification ? [{ id: `task_question_${randomUUID9()}`, kind: "success_signal", prompt: "Add at least one successful example, correction, reviewer choice, or outcome-bearing run so the authoring model can ground this capability without fabricating demonstrations.", answer: null }] : []
25359
25769
  ];
25360
25770
  const initialState = blockingQuestions.length ? "awaiting_questions" : needsDisclosure ? "awaiting_disclosure_approval" : "planning";
25361
25771
  let snapshot = TaskCreationSnapshotSchema.parse({
25362
25772
  schemaVersion: "openpond.taskCreationSnapshot.v1",
25363
- id: `task_creation_${randomUUID8()}`,
25773
+ id: `task_creation_${randomUUID9()}`,
25364
25774
  request,
25365
25775
  state: initialState,
25366
25776
  proposal: null,
@@ -25368,7 +25778,7 @@ function createTaskCreatorService(deps) {
25368
25778
  disclosureApprovalId,
25369
25779
  materializationApprovalId: null,
25370
25780
  blockingQuestions,
25371
- transcript: [{ id: `task_message_${randomUUID8()}`, role: "user", text: request.objective ?? "Create a Taskset from the selected conversations.", createdAt: timestamp }],
25781
+ transcript: [{ id: `task_message_${randomUUID9()}`, role: "user", text: request.objective ?? "Create a Taskset from the selected conversations.", createdAt: timestamp }],
25372
25782
  blockedReason: null,
25373
25783
  createdAt: timestamp,
25374
25784
  updatedAt: timestamp
@@ -25411,7 +25821,7 @@ function createTaskCreatorService(deps) {
25411
25821
  state: "planning",
25412
25822
  blockedReason: null,
25413
25823
  transcript: [...snapshot.transcript, {
25414
- id: `task_message_${randomUUID8()}`,
25824
+ id: `task_message_${randomUUID9()}`,
25415
25825
  role: "user",
25416
25826
  text: "Retry Taskset authoring with the same approved evidence and authoring configuration.",
25417
25827
  createdAt: timestamp
@@ -25464,7 +25874,7 @@ function createTaskCreatorService(deps) {
25464
25874
  );
25465
25875
  applying = await persist({ ...applying, proposal, updatedAt: now() });
25466
25876
  const taskset = await materializeTaskset(applying, proposal, sources);
25467
- return persist({ ...applying, state: "ready", materializedTasksetId: taskset.id, blockedReason: null, updatedAt: now(), transcript: [...applying.transcript, { id: `task_message_${randomUUID8()}`, role: "assistant", text: `Materialized ${taskset.name} with ${taskset.tasks.length} tasks and ${taskset.graders.length} graders.`, createdAt: now() }] });
25877
+ return persist({ ...applying, state: "ready", materializedTasksetId: taskset.id, blockedReason: null, updatedAt: now(), transcript: [...applying.transcript, { id: `task_message_${randomUUID9()}`, role: "assistant", text: `Materialized ${taskset.name} with ${taskset.tasks.length} tasks and ${taskset.graders.length} graders.`, createdAt: now() }] });
25468
25878
  } catch (error) {
25469
25879
  return persist({ ...applying, state: "failed", blockedReason: error instanceof Error ? error.message : String(error), updatedAt: now() });
25470
25880
  }
@@ -25476,7 +25886,7 @@ function createTaskCreatorService(deps) {
25476
25886
  if (!snapshot.request.analysisModel || !deps.authorProposal) throw new Error("Task Creator chat requires a configured authoring model.");
25477
25887
  if (["materializing", "validating", "ready", "cancelled"].includes(snapshot.state)) throw new Error(`Task Creator cannot revise a ${snapshot.state} creation.`);
25478
25888
  const timestamp = now();
25479
- const chatting = TaskCreationSnapshotSchema.parse({ ...snapshot, state: "planning", blockedReason: null, transcript: [...snapshot.transcript, { id: `task_message_${randomUUID8()}`, role: "user", text: instruction, createdAt: timestamp }], updatedAt: timestamp });
25889
+ const chatting = TaskCreationSnapshotSchema.parse({ ...snapshot, state: "planning", blockedReason: null, transcript: [...snapshot.transcript, { id: `task_message_${randomUUID9()}`, role: "user", text: instruction, createdAt: timestamp }], updatedAt: timestamp });
25480
25890
  await persist(chatting);
25481
25891
  const sources = await requireSources(snapshot.request.profileId, snapshot.request.sourceIds);
25482
25892
  try {
@@ -25514,7 +25924,7 @@ function createTaskCreatorService(deps) {
25514
25924
  ...manual ? [manual.evidence] : []
25515
25925
  ];
25516
25926
  if (snapshot.request.analysisModel) assertHostedAuthoringEvidenceBudget(evidence);
25517
- const proposalId = `task_proposal_${randomUUID8()}`;
25927
+ const proposalId = `task_proposal_${randomUUID9()}`;
25518
25928
  const authored = snapshot.request.analysisModel && deps.authorProposal ? await deps.authorProposal({ id: proposalId, model: snapshot.request.analysisModel, reasoningEffort: snapshot.request.analysisReasoningEffort, evidence, buildIntent: snapshot.request.buildIntent, buildSpecification: snapshot.request.buildSpecification, methodHint: snapshot.request.methodHint, signal, instruction: instruction ?? snapshot.request.objective, currentProposal }) : heuristicProposal(proposalId, snapshot, effectiveSources, evidence);
25519
25929
  const proposal = "proposal" in authored ? authored.proposal : authored;
25520
25930
  const repairHistory = "proposal" in authored ? authored.repairHistory : [];
@@ -25536,8 +25946,8 @@ function createTaskCreatorService(deps) {
25536
25946
  proposal: reviewed,
25537
25947
  blockedReason: null,
25538
25948
  repairHistory: [...snapshot.repairHistory, ...repairHistory],
25539
- materializationApprovalId: `task_materialization_${randomUUID8()}`,
25540
- transcript: [...snapshot.transcript, { id: `task_message_${randomUUID8()}`, role: "assistant", text: `Proposed \u201C${reviewed.name}\u201D. Review what should be learned, what should remain context, and the evidence before creating a Taskset.`, createdAt: now() }],
25949
+ materializationApprovalId: `task_materialization_${randomUUID9()}`,
25950
+ transcript: [...snapshot.transcript, { id: `task_message_${randomUUID9()}`, role: "assistant", text: `Proposed \u201C${reviewed.name}\u201D. Review what should be learned, what should remain context, and the evidence before creating a Taskset.`, createdAt: now() }],
25541
25951
  updatedAt: now()
25542
25952
  });
25543
25953
  }
@@ -25666,7 +26076,7 @@ function createTaskCreatorService(deps) {
25666
26076
  };
25667
26077
  const unhashed = TasksetSchema.parse({ ...draft, contentHash: "00000000" });
25668
26078
  const taskset = TasksetSchema.parse({ ...unhashed, contentHash: computeTasksetHash(unhashed) });
25669
- await buildTaskset(taskset, path24.join(deps.tasksetRootDir, taskset.id), {
26079
+ await buildTaskset(taskset, path25.join(deps.tasksetRootDir, taskset.id), {
25670
26080
  generatedFiles: [
25671
26081
  ...proposal.generatedFiles
25672
26082
  ]
@@ -25953,7 +26363,7 @@ function validateProposedExamples(proposal, evidence) {
25953
26363
  }
25954
26364
 
25955
26365
  // ../server/src/training/evaluation-service.ts
25956
- import path31 from "node:path";
26366
+ import path32 from "node:path";
25957
26367
 
25958
26368
  // ../server/src/training/evaluation-helpers.ts
25959
26369
  function fixtureAttempt(tasksetId, fixture, index) {
@@ -26122,12 +26532,12 @@ function metadataStrings(value) {
26122
26532
 
26123
26533
  // ../server/src/training/sandboxed-verifier.ts
26124
26534
  import { readFile as readFile4, realpath } from "node:fs/promises";
26125
- import path25 from "node:path";
26535
+ import path26 from "node:path";
26126
26536
  import vm from "node:vm";
26127
26537
  async function runSandboxedVerifier(input) {
26128
26538
  const root = await realpath(input.allowedRoot);
26129
- const modulePath = await realpath(path25.resolve(root, input.grader.module));
26130
- if (modulePath !== root && !modulePath.startsWith(`${root}${path25.sep}`)) throw new Error("Verifier module is outside the approved Taskset root.");
26539
+ const modulePath = await realpath(path26.resolve(root, input.grader.module));
26540
+ if (modulePath !== root && !modulePath.startsWith(`${root}${path26.sep}`)) throw new Error("Verifier module is outside the approved Taskset root.");
26131
26541
  const source = await readFile4(modulePath, "utf8");
26132
26542
  assertSandboxableSource(source);
26133
26543
  const functionSource = verifierFunctionSource(source, input.grader.exportName);
@@ -26136,7 +26546,7 @@ async function runSandboxedVerifier(input) {
26136
26546
  JSON: Object.freeze(JSON),
26137
26547
  Math: Object.freeze(Math)
26138
26548
  }), { name: `openpond-verifier:${input.grader.id}`, codeGeneration: { strings: false, wasm: false } });
26139
- const script = new vm.Script(`(${functionSource})`, { filename: path25.basename(modulePath) });
26549
+ const script = new vm.Script(`(${functionSource})`, { filename: path26.basename(modulePath) });
26140
26550
  const verifier = script.runInContext(context, { timeout: Math.min(input.grader.timeoutMs, 5e3) });
26141
26551
  if (typeof verifier !== "function") throw new Error("Verifier export did not evaluate to a function.");
26142
26552
  const result = await withTimeout(
@@ -26366,16 +26776,16 @@ function failureClassFor(outcome) {
26366
26776
  }
26367
26777
 
26368
26778
  // ../server/src/training/task-attempt-artifact-service.ts
26369
- import path26 from "node:path";
26779
+ import path27 from "node:path";
26370
26780
  import { mkdir as mkdir2, readFile as readFile5, writeFile as writeFile2 } from "node:fs/promises";
26371
26781
  async function persistJsonTaskAttemptArtifact(input) {
26372
- const directory = path26.join(
26782
+ const directory = path27.join(
26373
26783
  input.storeDir,
26374
26784
  "training",
26375
26785
  "evaluation-artifacts",
26376
26786
  input.tasksetId
26377
26787
  );
26378
- const file = path26.join(
26788
+ const file = path27.join(
26379
26789
  directory,
26380
26790
  `${input.attemptId}-${input.kind}.json`
26381
26791
  );
@@ -26399,7 +26809,7 @@ async function persistTaskAttemptOutputArtifact(input) {
26399
26809
  const checksum = sha256(bytes);
26400
26810
  if (bytes.byteLength !== input.expectedSizeBytes || checksum !== input.expectedSha256) {
26401
26811
  throw new Error(
26402
- `Saved Work output ${path26.basename(input.path)} no longer matches its OutputRef.`
26812
+ `Saved Work output ${path27.basename(input.path)} no longer matches its OutputRef.`
26403
26813
  );
26404
26814
  }
26405
26815
  return saveArtifact({
@@ -26444,7 +26854,7 @@ async function saveArtifact(input) {
26444
26854
  }
26445
26855
 
26446
26856
  // ../server/src/training/taskset-work-attempt-runner.ts
26447
- import path30 from "node:path";
26857
+ import path31 from "node:path";
26448
26858
  import { readFile as readFile7 } from "node:fs/promises";
26449
26859
 
26450
26860
  // ../server/src/openpond/model-tool-registry.ts
@@ -26452,7 +26862,7 @@ import { createHash as createHash6 } from "node:crypto";
26452
26862
 
26453
26863
  // ../server/src/openpond/command-artifacts.ts
26454
26864
  import { promises as fs17 } from "node:fs";
26455
- import path27 from "node:path";
26865
+ import path28 from "node:path";
26456
26866
  var ARTIFACT_CONTENT_TYPES = /* @__PURE__ */ new Map([
26457
26867
  [".avif", "image/avif"],
26458
26868
  [".csv", "text/csv"],
@@ -26501,10 +26911,10 @@ async function discoverCommandArtifacts(result, limit = 12) {
26501
26911
  const artifacts = [];
26502
26912
  const seen = /* @__PURE__ */ new Set();
26503
26913
  for (const candidate of candidates) {
26504
- const resolved = path27.isAbsolute(candidate) ? path27.resolve(candidate) : result.cwd ? path27.resolve(result.cwd, candidate) : null;
26914
+ const resolved = path28.isAbsolute(candidate) ? path28.resolve(candidate) : result.cwd ? path28.resolve(result.cwd, candidate) : null;
26505
26915
  if (!resolved || seen.has(resolved)) continue;
26506
26916
  const contentType = ARTIFACT_CONTENT_TYPES.get(
26507
- path27.extname(resolved).toLowerCase()
26917
+ path28.extname(resolved).toLowerCase()
26508
26918
  );
26509
26919
  if (!contentType) continue;
26510
26920
  try {
@@ -26514,7 +26924,7 @@ async function discoverCommandArtifacts(result, limit = 12) {
26514
26924
  artifacts.push({
26515
26925
  artifactRef: resolved,
26516
26926
  path: resolved,
26517
- title: path27.basename(resolved),
26927
+ title: path28.basename(resolved),
26518
26928
  contentType,
26519
26929
  sizeBytes: stat.size,
26520
26930
  binary: true
@@ -26554,7 +26964,7 @@ function collectJsonPaths(value, output) {
26554
26964
  function collectJsonStrings(value, output, depth = 0) {
26555
26965
  if (depth > 8 || value == null) return;
26556
26966
  if (typeof value === "string") {
26557
- const extension = path27.extname(value).toLowerCase();
26967
+ const extension = path28.extname(value).toLowerCase();
26558
26968
  if (ARTIFACT_CONTENT_TYPES.has(extension)) output.add(value);
26559
26969
  return;
26560
26970
  }
@@ -26648,7 +27058,7 @@ function createResourceModelToolDefinitions(deps) {
26648
27058
  scope,
26649
27059
  query: stringArg2(context.args, "query"),
26650
27060
  ...typeof context.args.limit === "number" ? { limit: context.args.limit } : {},
26651
- ...asRecord6(context.args.filters) ? { filters: asRecord6(context.args.filters) } : {}
27061
+ ...asRecord7(context.args.filters) ? { filters: asRecord7(context.args.filters) } : {}
26652
27062
  }
26653
27063
  });
26654
27064
  return resourceSearchResultToModelToolResult(context.callId, result2);
@@ -26662,7 +27072,7 @@ function createResourceModelToolDefinitions(deps) {
26662
27072
  args: {
26663
27073
  query: stringArg2(context.args, "query"),
26664
27074
  ...typeof context.args.limit === "number" ? { maxResults: context.args.limit } : {},
26665
- ...typeof asRecord6(context.args.filters)?.path === "string" ? { path: asRecord6(context.args.filters)?.path } : {}
27075
+ ...typeof asRecord7(context.args.filters)?.path === "string" ? { path: asRecord7(context.args.filters)?.path } : {}
26666
27076
  },
26667
27077
  source: "chat_action"
26668
27078
  },
@@ -27131,7 +27541,7 @@ function createWebFetchModelToolDefinition(input = {}) {
27131
27541
  function createWebSearchModelToolDefinition(deps) {
27132
27542
  return {
27133
27543
  name: "web_search",
27134
- description: "Search the web for current or external information. Cite by source title or source name in prose; the app renders clickable source pills, so do not paste raw URLs unless the user explicitly asks for URLs.",
27544
+ description: "Search the web for current or external information. The app renders clickable source pills automatically. Cite by source title or source name in prose by default; when the user explicitly requests URLs or linked evidence, use the result URLs in clickable Markdown links.",
27135
27545
  parameters: {
27136
27546
  type: "object",
27137
27547
  additionalProperties: false,
@@ -27179,7 +27589,7 @@ function createWebSearchModelToolDefinition(deps) {
27179
27589
  {
27180
27590
  ok: true,
27181
27591
  action: "web_search",
27182
- output: `Found ${result.results.length} web result${result.results.length === 1 ? "" : "s"}. Use the source titles or names for citations; do not paste raw URLs unless the user asks.`,
27592
+ output: `Found ${result.results.length} web result${result.results.length === 1 ? "" : "s"}. Source pills are automatic. Cite source titles or names by default; when the user requests URLs or linked evidence, use the result URLs in clickable Markdown links.`,
27183
27593
  data: { result: webSearchResultForModel(result) }
27184
27594
  },
27185
27595
  null,
@@ -27238,6 +27648,7 @@ function webSearchResultForModel(result) {
27238
27648
  id: item.id,
27239
27649
  citation: `[${index + 1}]`,
27240
27650
  title: item.title,
27651
+ url: item.url,
27241
27652
  snippet: item.snippet,
27242
27653
  sourceName: item.sourceName,
27243
27654
  domain: hostnameFromUrl2(item.url),
@@ -27418,7 +27829,7 @@ function createOpenPondActionModelToolDefinitions(deps) {
27418
27829
  })
27419
27830
  })) : [];
27420
27831
  const directAgentActions = deps.actionCatalog.filter((action) => {
27421
- const implementation = asRecord6(action.implementation);
27832
+ const implementation = asRecord7(action.implementation);
27422
27833
  const actionName = action.sourceActionId ?? action.name ?? action.id;
27423
27834
  return !CROSS_SYSTEM_TOOL_NAMES.includes(actionName) && (Boolean(action.agentId) || implementation?.type === "openpond-profile-action");
27424
27835
  });
@@ -27521,7 +27932,7 @@ function createOpenPondActionModelToolDefinitions(deps) {
27521
27932
  deps,
27522
27933
  resultToolName: "openpond_action_run",
27523
27934
  compactProfileResultForModel: true,
27524
- input: asRecord6(context.args.input) ?? {},
27935
+ input: asRecord7(context.args.input) ?? {},
27525
27936
  requestedProjectId: stringValue7(context.args.projectId) ?? void 0,
27526
27937
  requestedAgentId: stringValue7(context.args.agentId) ?? void 0
27527
27938
  });
@@ -27536,11 +27947,11 @@ function directOpenPondActionToolName(action) {
27536
27947
  return `agent_${slug}_${suffix}`;
27537
27948
  }
27538
27949
  function directOpenPondActionAliasName(action) {
27539
- const name = stringValue7(asRecord6(action.implementation)?.actionId) ?? action.sourceActionId ?? action.name ?? action.id;
27950
+ const name = stringValue7(asRecord7(action.implementation)?.actionId) ?? action.sourceActionId ?? action.name ?? action.id;
27540
27951
  return /^[A-Za-z0-9_-]{1,64}$/.test(name) ? name : null;
27541
27952
  }
27542
27953
  function actionInputSchema(action) {
27543
- const schema = asRecord6(action.inputSchema);
27954
+ const schema = asRecord7(action.inputSchema);
27544
27955
  if (schema?.type === "object") return structuredClone(schema);
27545
27956
  return {
27546
27957
  type: "object",
@@ -27550,7 +27961,7 @@ function actionInputSchema(action) {
27550
27961
  }
27551
27962
  async function executeScopedOpenPondAction(input) {
27552
27963
  const { action, context, deps, resultToolName } = input;
27553
- const implementation = asRecord6(action.implementation);
27964
+ const implementation = asRecord7(action.implementation);
27554
27965
  if (implementation?.type === "openpond-profile-action") {
27555
27966
  const executionTarget = resolveWorkspaceExecutionTarget({ session: context.session });
27556
27967
  if (isSandboxExecutionTarget(executionTarget)) {
@@ -27649,7 +28060,7 @@ async function executeScopedOpenPondAction(input) {
27649
28060
  return workspaceToolResultToModelToolResult(context.callId, resultToolName, result);
27650
28061
  }
27651
28062
  function compactProfileActionResult(value) {
27652
- const execution = asRecord6(value);
28063
+ const execution = asRecord7(value);
27653
28064
  const stdout = stringValue7(execution?.stdout);
27654
28065
  if (!stdout) return value;
27655
28066
  let payload;
@@ -27658,9 +28069,9 @@ function compactProfileActionResult(value) {
27658
28069
  } catch {
27659
28070
  return value;
27660
28071
  }
27661
- const actionResult = asRecord6(payload)?.result ?? payload;
27662
- const actionResultRecord = asRecord6(actionResult);
27663
- const metadata = asRecord6(actionResultRecord?.metadata);
28072
+ const actionResult = asRecord7(payload)?.result ?? payload;
28073
+ const actionResultRecord = asRecord7(actionResult);
28074
+ const metadata = asRecord7(actionResultRecord?.metadata);
27664
28075
  for (const key of ["snapshot", "decision", "submission", "receipt"]) {
27665
28076
  if (metadata && Object.hasOwn(metadata, key)) return metadata[key];
27666
28077
  }
@@ -27923,23 +28334,23 @@ function sandboxResourceRefForExecutionTarget(ref, target) {
27923
28334
  return null;
27924
28335
  }
27925
28336
  function gitChangedFileRefs(value, sandboxMode = false) {
27926
- const record6 = asRecord6(value);
27927
- const status = asRecord6(record6?.status);
28337
+ const record6 = asRecord7(value);
28338
+ const status = asRecord7(record6?.status);
27928
28339
  const files = Array.isArray(record6?.files) ? record6.files : Array.isArray(status?.files) ? status.files : [];
27929
28340
  return files.filter((item) => Boolean(item) && typeof item === "object" && !Array.isArray(item)).map((item) => stringValue7(item.path)).filter((item) => Boolean(item)).map((filePath) => `${sandboxMode ? "sandbox" : "workspace"}:file:${filePath}`);
27930
28341
  }
27931
28342
  function gitDiffText(value) {
27932
- const record6 = asRecord6(value);
27933
- return stringValue7(record6?.diff) ?? stringValue7(asRecord6(record6?.result)?.diff);
28343
+ const record6 = asRecord7(value);
28344
+ return stringValue7(record6?.diff) ?? stringValue7(asRecord7(record6?.result)?.diff);
27934
28345
  }
27935
28346
  function sandboxPathItems(value) {
27936
28347
  const records = nestedArraysForKeys(value, ["matches", "files", "entries"]);
27937
28348
  const items = [];
27938
28349
  for (const record6 of records) {
27939
- const path46 = stringValue7(record6.path) ?? stringValue7(record6.name);
27940
- if (!path46) continue;
28350
+ const path47 = stringValue7(record6.path) ?? stringValue7(record6.name);
28351
+ if (!path47) continue;
27941
28352
  items.push({
27942
- path: path46,
28353
+ path: path47,
27943
28354
  snippet: stringValue7(record6.text) ?? stringValue7(record6.snippet) ?? stringValue7(record6.content) ?? void 0,
27944
28355
  line: typeof record6.line === "number" ? record6.line : null,
27945
28356
  kind: stringValue7(record6.kind) ?? stringValue7(record6.type)
@@ -27965,7 +28376,7 @@ function nestedArraysForKeys(value, keys) {
27965
28376
  return output;
27966
28377
  }
27967
28378
  function sandboxFileContent(value) {
27968
- const record6 = asRecord6(value);
28379
+ const record6 = asRecord7(value);
27969
28380
  const file = sandboxFileRecord(value);
27970
28381
  const encoded = stringValue7(file?.contentsBase64) ?? stringValue7(record6?.contentsBase64);
27971
28382
  if (encoded && !sandboxFileMetadata(value, stringValue7(file?.path) ?? "").binary) {
@@ -27985,8 +28396,8 @@ function contentTypeForResourcePath(value) {
27985
28396
  return null;
27986
28397
  }
27987
28398
  function sandboxFileRecord(value) {
27988
- const record6 = asRecord6(value);
27989
- return asRecord6(record6?.file) ?? asRecord6(asRecord6(record6?.result)?.file);
28399
+ const record6 = asRecord7(value);
28400
+ return asRecord7(record6?.file) ?? asRecord7(asRecord7(record6?.result)?.file);
27990
28401
  }
27991
28402
  function sandboxFileMetadata(value, resourcePath) {
27992
28403
  const file = sandboxFileRecord(value);
@@ -28066,7 +28477,7 @@ function actionCatalogText(action) {
28066
28477
  ].filter((value) => typeof value === "string" && value.trim().length > 0).join(" ").toLowerCase();
28067
28478
  }
28068
28479
  function actionCatalogItemForModel(action) {
28069
- const implementation = asRecord6(action.implementation);
28480
+ const implementation = asRecord7(action.implementation);
28070
28481
  const directRunAllowed = implementation?.type !== "openpond-profile-action";
28071
28482
  return {
28072
28483
  actionId: action.id,
@@ -28097,7 +28508,7 @@ function failedActionToolResult(callId, name, message) {
28097
28508
  )
28098
28509
  };
28099
28510
  }
28100
- function asRecord6(value) {
28511
+ function asRecord7(value) {
28101
28512
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
28102
28513
  }
28103
28514
  function stringValue7(value) {
@@ -28108,12 +28519,12 @@ function numberValue3(value) {
28108
28519
  }
28109
28520
 
28110
28521
  // ../server/src/openpond/work-tool-registry.ts
28111
- import { randomUUID as randomUUID9 } from "node:crypto";
28522
+ import { randomUUID as randomUUID10 } from "node:crypto";
28112
28523
 
28113
28524
  // ../server/src/openpond/work-runtime-service.ts
28114
28525
  import { createHash as createHash7 } from "node:crypto";
28115
28526
  import { promises as fs18 } from "node:fs";
28116
- import path28 from "node:path";
28527
+ import path29 from "node:path";
28117
28528
  var WORK_RUNTIME_PROFILE_ID = "openpond-work-v1";
28118
28529
  var WORK_LAYOUT_COMMAND = "mkdir -p inputs work outputs";
28119
28530
  var WORK_RESET_COMMAND = "find /workspace/inputs /workspace/work /workspace/outputs -mindepth 1 -maxdepth 1 -exec rm -rf -- {} +";
@@ -28280,7 +28691,7 @@ function workPath(rawArea, rawPath, allowedAreas = ["inputs", "work", "outputs"]
28280
28691
  if (value.startsWith("/")) {
28281
28692
  throw new Error("Work paths must be relative to their selected area.");
28282
28693
  }
28283
- const normalized = path28.posix.normalize(value);
28694
+ const normalized = path29.posix.normalize(value);
28284
28695
  if (normalized === ".." || normalized.startsWith("../") || normalized.includes("/../")) {
28285
28696
  throw new Error("Work path escaped its selected area.");
28286
28697
  }
@@ -28879,7 +29290,7 @@ function createWorkModelToolDefinitions(deps) {
28879
29290
  const url = validHttpUrl(context.args.url);
28880
29291
  const validation = Array.isArray(context.args.validation) ? context.args.validation : [];
28881
29292
  const identity = {
28882
- id: randomUUID9(),
29293
+ id: randomUUID10(),
28883
29294
  title,
28884
29295
  sourceTaskId: context.session.id,
28885
29296
  sourceTurnId: context.turnId,
@@ -29041,10 +29452,10 @@ function validHttpUrl(value) {
29041
29452
 
29042
29453
  // ../server/src/training/taskset-work-cost-evidence.ts
29043
29454
  function workRuntimeCostEvidence(value) {
29044
- const record6 = asRecord7(value);
29045
- const sandbox = asRecord7(record6.sandbox);
29455
+ const record6 = asRecord8(value);
29456
+ const sandbox = asRecord8(record6.sandbox);
29046
29457
  const receiptValues = Array.isArray(record6.receipts) ? record6.receipts : Array.isArray(sandbox.receipts) ? sandbox.receipts : [];
29047
- const receipts = receiptValues.map(asRecord7);
29458
+ const receipts = receiptValues.map(asRecord8);
29048
29459
  const captured = receipts.flatMap((receipt) => {
29049
29460
  const id = typeof receipt.id === "string" ? receipt.id : null;
29050
29461
  const totalUsd = numericUsd(receipt.totalUsd);
@@ -29052,7 +29463,7 @@ function workRuntimeCostEvidence(value) {
29052
29463
  if (receipt.status !== "captured" || !id || totalUsd === null || durationSeconds === null) {
29053
29464
  return [];
29054
29465
  }
29055
- const settlement = asRecord7(receipt.mpp).mode;
29466
+ const settlement = asRecord8(receipt.mpp).mode;
29056
29467
  return [{
29057
29468
  id,
29058
29469
  totalUsd,
@@ -29097,14 +29508,14 @@ function numericUsd(value) {
29097
29508
  const parsed = Number(value);
29098
29509
  return Number.isFinite(parsed) && parsed >= 0 ? parsed : null;
29099
29510
  }
29100
- function asRecord7(value) {
29511
+ function asRecord8(value) {
29101
29512
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
29102
29513
  }
29103
29514
 
29104
29515
  // ../server/src/training/taskset-work-assets.ts
29105
29516
  import { createHash as createHash8 } from "node:crypto";
29106
29517
  import { lstat, readFile as readFile6 } from "node:fs/promises";
29107
- import path29 from "node:path";
29518
+ import path30 from "node:path";
29108
29519
  var DEFAULT_MAX_WORK_INPUT_BYTES = 25e7;
29109
29520
  var MAX_WORK_INPUT_BYTES2 = 1e9;
29110
29521
  async function resolveTasksetWorkAssets(input) {
@@ -29114,13 +29525,13 @@ async function resolveTasksetWorkAssets(input) {
29114
29525
  const sourceById = new Map(
29115
29526
  input.taskset.sourceRefs.map((source) => [source.id, source])
29116
29527
  );
29117
- const tasksetRoot = path29.resolve(
29528
+ const tasksetRoot = path30.resolve(
29118
29529
  input.storeDir,
29119
29530
  "training",
29120
29531
  "tasksets",
29121
29532
  input.taskset.id
29122
29533
  );
29123
- const assetRoot = path29.resolve(tasksetRoot, "assets");
29534
+ const assetRoot = path30.resolve(tasksetRoot, "assets");
29124
29535
  const resolved = [];
29125
29536
  for (const asset2 of input.task.assets ?? []) {
29126
29537
  if (asset2.split !== input.task.split) {
@@ -29140,8 +29551,8 @@ async function resolveTasksetWorkAssets(input) {
29140
29551
  );
29141
29552
  }
29142
29553
  assertEligibleSource(source, asset2);
29143
- const target = path29.resolve(tasksetRoot, asset2.artifactRef);
29144
- if (target === assetRoot || !target.startsWith(`${assetRoot}${path29.sep}`)) {
29554
+ const target = path30.resolve(tasksetRoot, asset2.artifactRef);
29555
+ if (target === assetRoot || !target.startsWith(`${assetRoot}${path30.sep}`)) {
29145
29556
  throw new Error(
29146
29557
  `Work asset ${asset2.id} must resolve inside the Taskset assets directory.`
29147
29558
  );
@@ -29492,7 +29903,7 @@ async function runTasksetWorkAttempt(input) {
29492
29903
  ]).slice(0, 20)}`,
29493
29904
  args: {
29494
29905
  path: requiredOutput.path,
29495
- suggestedName: path30.posix.basename(requiredOutput.path),
29906
+ suggestedName: path31.posix.basename(requiredOutput.path),
29496
29907
  validation: []
29497
29908
  },
29498
29909
  signal: controller.signal,
@@ -29767,9 +30178,9 @@ async function executeDefinition(input) {
29767
30178
  }
29768
30179
  function savedWorkOutput(args, result) {
29769
30180
  if (!result.ok || result.name !== "work_save_output") return null;
29770
- const data = asRecord8(result.data);
30181
+ const data = asRecord9(result.data);
29771
30182
  const parsed = FileOutputRefSchema.safeParse(data.outputRef);
29772
- const artifact = asRecord8(data.artifact);
30183
+ const artifact = asRecord9(data.artifact);
29773
30184
  const artifactPath = typeof artifact.path === "string" ? artifact.path : null;
29774
30185
  const relativePath = typeof args.path === "string" ? normalizedOutputPath(args.path) : null;
29775
30186
  if (!parsed.success || !artifactPath || !relativePath) return null;
@@ -29867,7 +30278,7 @@ function userPrompt(task) {
29867
30278
  return task.input.prompt.trim();
29868
30279
  }
29869
30280
  const messages = Array.isArray(task.input.messages) ? task.input.messages.flatMap((value) => {
29870
- const record6 = asRecord8(value);
30281
+ const record6 = asRecord9(value);
29871
30282
  return (record6.role === "system" || record6.role === "user") && typeof record6.content === "string" && record6.content.trim() ? [record6.content.trim()] : [];
29872
30283
  }) : [];
29873
30284
  if (messages.length) return messages.join("\n\n");
@@ -29880,7 +30291,7 @@ function workToolTurnLimit(taskset) {
29880
30291
  function normalizedOutputPath(value) {
29881
30292
  const normalized = value.trim().replaceAll("\\", "/");
29882
30293
  if (!normalized || normalized.startsWith("/")) return null;
29883
- const clean = path30.posix.normalize(normalized);
30294
+ const clean = path31.posix.normalize(normalized);
29884
30295
  if (clean === "." || clean === ".." || clean.startsWith("../") || clean.split("/").includes("..")) {
29885
30296
  return null;
29886
30297
  }
@@ -29893,7 +30304,7 @@ function throwIfAborted2(signal) {
29893
30304
  function errorMessage2(error) {
29894
30305
  return error instanceof Error ? error.message : String(error);
29895
30306
  }
29896
- function asRecord8(value) {
30307
+ function asRecord9(value) {
29897
30308
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
29898
30309
  }
29899
30310
  function elapsedMilliseconds(startedAt, completedAt) {
@@ -30862,7 +31273,7 @@ function createTaskEvaluationService(deps) {
30862
31273
  }
30863
31274
  await buildTaskset(
30864
31275
  updated,
30865
- path31.join(deps.storeDir, "training", "tasksets", updated.id)
31276
+ path32.join(deps.storeDir, "training", "tasksets", updated.id)
30866
31277
  );
30867
31278
  await deps.store.upsertTaskset(updated);
30868
31279
  return {
@@ -31007,7 +31418,7 @@ function createTaskEvaluationService(deps) {
31007
31418
  return void 0;
31008
31419
  }
31009
31420
  const profile = deps.storeDir ? null : await (deps.loadProfileState ?? loadOpenPondProfileState)();
31010
- const tasksetRoot = deps.storeDir ? path31.join(deps.storeDir, "training", "tasksets", tasksetId) : profile?.sourcePath ? path31.join(profile.sourcePath, "tasksets", tasksetId) : null;
31421
+ const tasksetRoot = deps.storeDir ? path32.join(deps.storeDir, "training", "tasksets", tasksetId) : profile?.sourcePath ? path32.join(profile.sourcePath, "tasksets", tasksetId) : null;
31011
31422
  const creationSnapshotId = typeof taskset.metadata.creationSnapshotId === "string" ? taskset.metadata.creationSnapshotId : null;
31012
31423
  const proposal = creationSnapshotId ? await deps.store.getTaskDesignProposal(creationSnapshotId) : null;
31013
31424
  if (tasksetRoot) {
@@ -31558,7 +31969,7 @@ async function createLocalHarnessTasksetReviewControl(input) {
31558
31969
  const tasksetAuthoringSkill = await loadTasksetAuthoringSkillArtifact();
31559
31970
  const taskCreator = createTaskCreatorService({
31560
31971
  store: input.store,
31561
- tasksetRootDir: path32.join(input.storeDir, "training", "tasksets"),
31972
+ tasksetRootDir: path33.join(input.storeDir, "training", "tasksets"),
31562
31973
  authoringSkillHash: contentHash(tasksetAuthoringSkill.bundle),
31563
31974
  loadProfileState: loadOpenPondProfileState
31564
31975
  });
@@ -31876,11 +32287,11 @@ function assistantDeltaKey(runtimeEvent) {
31876
32287
  }
31877
32288
 
31878
32289
  // ../server/src/runtime/turn-runner.ts
31879
- import { createHash as createHash9, randomUUID as randomUUID14 } from "node:crypto";
32290
+ import { createHash as createHash9, randomUUID as randomUUID15 } from "node:crypto";
31880
32291
 
31881
32292
  // ../server/src/chat-attachments.ts
31882
32293
  import { promises as fs19 } from "node:fs";
31883
- import path33 from "node:path";
32294
+ import path34 from "node:path";
31884
32295
  var ATTACHMENT_CONTEXT_TEXT_LIMIT = 12e4;
31885
32296
  var MAX_CHAT_ATTACHMENT_IMAGE_BYTES = 15 * 1024 * 1024;
31886
32297
  var CHAT_ATTACHMENT_TEXT_PREVIEW_MAX_BYTES = 2 * 1024 * 1024;
@@ -31941,7 +32352,7 @@ var CHAT_ATTACHMENT_TEXT_EXTENSIONS = /* @__PURE__ */ new Set([
31941
32352
  async function materializeChatAttachments(input) {
31942
32353
  const attachments = input.attachments ?? [];
31943
32354
  if (attachments.length === 0) return [];
31944
- const turnDir = path33.join(
32355
+ const turnDir = path34.join(
31945
32356
  input.attachmentRootDir,
31946
32357
  safeChatAttachmentPathSegment(input.sessionId),
31947
32358
  safeChatAttachmentPathSegment(input.turnId)
@@ -31961,8 +32372,8 @@ async function materializeChatAttachments(input) {
31961
32372
  usedNames,
31962
32373
  index + 1
31963
32374
  );
31964
- const localPath = path33.join(turnDir, safeName);
31965
- await fs19.mkdir(path33.dirname(localPath), { recursive: true });
32375
+ const localPath = path34.join(turnDir, safeName);
32376
+ await fs19.mkdir(path34.dirname(localPath), { recursive: true });
31966
32377
  await fs19.writeFile(
31967
32378
  localPath,
31968
32379
  Buffer.from(attachment.contentsBase64, "base64"),
@@ -32072,13 +32483,13 @@ async function readChatAttachmentImageFile(input) {
32072
32483
  storageName ?? ""
32073
32484
  );
32074
32485
  if (!storageName || !contentType) return null;
32075
- const turnDir = path33.resolve(
32486
+ const turnDir = path34.resolve(
32076
32487
  input.attachmentRootDir,
32077
32488
  sessionSegment,
32078
32489
  turnSegment
32079
32490
  );
32080
- const target = path33.resolve(turnDir, storageName);
32081
- if (target !== turnDir && !target.startsWith(`${turnDir}${path33.sep}`))
32491
+ const target = path34.resolve(turnDir, storageName);
32492
+ if (target !== turnDir && !target.startsWith(`${turnDir}${path34.sep}`))
32082
32493
  return null;
32083
32494
  try {
32084
32495
  const stat = await fs19.lstat(target);
@@ -32117,7 +32528,7 @@ function chatAttachmentImageContentType(mediaType, fileName) {
32117
32528
  if (CHAT_ATTACHMENT_IMAGE_MEDIA_TYPES.has(normalizedMediaType))
32118
32529
  return normalizedMediaType;
32119
32530
  return CHAT_ATTACHMENT_IMAGE_CONTENT_TYPES.get(
32120
- path33.extname(fileName).toLowerCase()
32531
+ path34.extname(fileName).toLowerCase()
32121
32532
  ) ?? null;
32122
32533
  }
32123
32534
  function safeChatAttachmentPathSegment(value) {
@@ -32127,18 +32538,18 @@ function cleanStorageName(value) {
32127
32538
  const trimmed = value.trim();
32128
32539
  if (!trimmed || trimmed === "." || trimmed === ".." || /[\\/]/.test(trimmed))
32129
32540
  return null;
32130
- return path33.basename(trimmed);
32541
+ return path34.basename(trimmed);
32131
32542
  }
32132
32543
  function chatAttachmentStoredFilePath(input) {
32133
32544
  const storageName = cleanStoragePath(input.storageName);
32134
32545
  if (!storageName) return null;
32135
- const turnDir = path33.resolve(
32546
+ const turnDir = path34.resolve(
32136
32547
  input.attachmentRootDir,
32137
32548
  safeChatAttachmentPathSegment(input.sessionId),
32138
32549
  safeChatAttachmentPathSegment(input.turnId)
32139
32550
  );
32140
- const absolutePath = path33.resolve(turnDir, storageName);
32141
- if (!absolutePath.startsWith(`${turnDir}${path33.sep}`)) return null;
32551
+ const absolutePath = path34.resolve(turnDir, storageName);
32552
+ if (!absolutePath.startsWith(`${turnDir}${path34.sep}`)) return null;
32142
32553
  return { absolutePath, storageName };
32143
32554
  }
32144
32555
  function cleanStoragePath(value) {
@@ -32154,7 +32565,7 @@ function chatAttachmentTextPreviewSupported(contentType, fileName) {
32154
32565
  if (normalizedType.startsWith("text/")) return true;
32155
32566
  if (CHAT_ATTACHMENT_TEXT_CONTENT_TYPES.has(normalizedType)) return true;
32156
32567
  return CHAT_ATTACHMENT_TEXT_EXTENSIONS.has(
32157
- path33.extname(fileName).toLowerCase()
32568
+ path34.extname(fileName).toLowerCase()
32158
32569
  );
32159
32570
  }
32160
32571
  function uniqueSafeFileName(name, usedNames, fallbackIndex) {
@@ -32163,7 +32574,7 @@ function uniqueSafeFileName(name, usedNames, fallbackIndex) {
32163
32574
  let candidate = safeName;
32164
32575
  let index = 2;
32165
32576
  while (usedNames.has(candidate)) {
32166
- const extension = path33.extname(safeName);
32577
+ const extension = path34.extname(safeName);
32167
32578
  const base = extension ? safeName.slice(0, -extension.length) : safeName;
32168
32579
  candidate = `${base}-${index}${extension}`;
32169
32580
  index += 1;
@@ -32933,7 +33344,7 @@ function resolveContextCompactionAdapter(provider) {
32933
33344
  }
32934
33345
 
32935
33346
  // ../server/src/openpond/context-compaction/index.ts
32936
- import { randomUUID as randomUUID10 } from "node:crypto";
33347
+ import { randomUUID as randomUUID11 } from "node:crypto";
32937
33348
 
32938
33349
  // ../server/src/openpond/context-compaction/file-ledger.ts
32939
33350
  function buildFileOperationLedger(records) {
@@ -32941,9 +33352,9 @@ function buildFileOperationLedger(records) {
32941
33352
  for (const record6 of records) {
32942
33353
  const paths = /* @__PURE__ */ new Set([...record6.filePaths, ...extractFilePaths(record6.body)]);
32943
33354
  if (paths.size === 0) continue;
32944
- for (const path46 of paths) {
32945
- const entry = entries.get(path46) ?? {
32946
- path: path46,
33355
+ for (const path47 of paths) {
33356
+ const entry = entries.get(path47) ?? {
33357
+ path: path47,
32947
33358
  operations: [],
32948
33359
  relevance: "referenced",
32949
33360
  latestStatus: "unknown",
@@ -32960,7 +33371,7 @@ function buildFileOperationLedger(records) {
32960
33371
  entry.latestStatus = "failed";
32961
33372
  }
32962
33373
  entry.relevance = relevanceForEntry(entry);
32963
- entries.set(path46, entry);
33374
+ entries.set(path47, entry);
32964
33375
  }
32965
33376
  }
32966
33377
  return [...entries.values()].sort((a, b) => relevanceRank(b.relevance) - relevanceRank(a.relevance) || a.path.localeCompare(b.path)).slice(0, 100);
@@ -33229,7 +33640,7 @@ function goalContextPreview(event2) {
33229
33640
  function subagentEventPreview(event2) {
33230
33641
  const run = subagentRunFromEvent(event2);
33231
33642
  if (!run) return eventPreview(event2);
33232
- const usage = asRecord9(run.metadata.usage);
33643
+ const usage = asRecord10(run.metadata.usage);
33233
33644
  const report = run.report;
33234
33645
  return [
33235
33646
  `run: subagent-run:${run.id}`,
@@ -33282,8 +33693,8 @@ function isDurableResourceRef(value) {
33282
33693
  return /^(workspace:(?:file|dir):|sandbox:(?:file|dir):|git:|event:|message:|artifact:|goal-context:|session:|subagent-run:)/.test(value);
33283
33694
  }
33284
33695
  function subagentRunFromEvent(event2) {
33285
- const data = asRecord9(event2.data);
33286
- const parsed = SubagentRunSchema.safeParse(asRecord9(data?.run));
33696
+ const data = asRecord10(event2.data);
33697
+ const parsed = SubagentRunSchema.safeParse(asRecord10(data?.run));
33287
33698
  return parsed.success ? parsed.data : null;
33288
33699
  }
33289
33700
  function subagentRefsPreview(refs, label) {
@@ -33322,7 +33733,7 @@ function extractFilePaths2(value) {
33322
33733
  }
33323
33734
  return [...paths].slice(0, 20);
33324
33735
  }
33325
- function asRecord9(value) {
33736
+ function asRecord10(value) {
33326
33737
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
33327
33738
  }
33328
33739
  function numberValue5(value) {
@@ -33585,7 +33996,7 @@ function hostedCompactionContextLimit(provider, model, maxContextTokens) {
33585
33996
  }
33586
33997
  async function streamCompactionSummary(input) {
33587
33998
  let text = "";
33588
- const requestId = `compact-${randomUUID10()}`;
33999
+ const requestId = `compact-${randomUUID11()}`;
33589
34000
  const streamCompactionChatTurn = input.streamCompactionChatTurn ?? defaultOpenPondCompactionStream;
33590
34001
  for await (const delta of streamCompactionChatTurn({
33591
34002
  provider: input.provider,
@@ -34653,17 +35064,17 @@ function createNativeToolRuntime(deps) {
34653
35064
  const name = stringFromRecord(record6, "name");
34654
35065
  const description = stringFromRecord(record6, "description");
34655
35066
  const body = stringFromRecord(record6, "body");
34656
- const path46 = stringFromRecord(record6, "path");
35067
+ const path47 = stringFromRecord(record6, "path");
34657
35068
  const sourceHash = stringFromRecord(record6, "sourceHash");
34658
35069
  const charCount = typeof record6.charCount === "number" ? record6.charCount : null;
34659
- if (!name || !description || !body || !path46 || !sourceHash || charCount === null) return null;
35070
+ if (!name || !description || !body || !path47 || !sourceHash || charCount === null) return null;
34660
35071
  const packagePath = stringFromRecord(record6, "packagePath");
34661
35072
  const resourceFiles = Array.isArray(record6.resourceFiles) ? record6.resourceFiles.filter((file) => typeof file === "string") : [];
34662
35073
  return {
34663
35074
  name,
34664
35075
  description,
34665
35076
  body,
34666
- path: path46,
35077
+ path: path47,
34667
35078
  sourceHash,
34668
35079
  charCount,
34669
35080
  ...packagePath ? { packagePath } : {},
@@ -34679,16 +35090,16 @@ function createNativeToolRuntime(deps) {
34679
35090
  const name = stringFromRecord(record6, "name");
34680
35091
  const description = stringFromRecord(record6, "description");
34681
35092
  const body = stringFromRecord(record6, "body");
34682
- const path46 = stringFromRecord(record6, "path");
35093
+ const path47 = stringFromRecord(record6, "path");
34683
35094
  const sourceHash = stringFromRecord(record6, "sourceHash");
34684
35095
  const provider = stringFromRecord(record6, "provider");
34685
35096
  const charCount = typeof record6.charCount === "number" ? record6.charCount : null;
34686
- if (!name || !description || !body || !path46 || !sourceHash || !provider || charCount === null) return null;
35097
+ if (!name || !description || !body || !path47 || !sourceHash || !provider || charCount === null) return null;
34687
35098
  return {
34688
35099
  name,
34689
35100
  description,
34690
35101
  body,
34691
- path: path46,
35102
+ path: path47,
34692
35103
  sourceHash,
34693
35104
  provider,
34694
35105
  charCount
@@ -35392,8 +35803,6 @@ function createHostedToolLoopRuntime(deps) {
35392
35803
  const maxHostedWorkspaceToolRounds = deps.maxHostedWorkspaceToolRounds;
35393
35804
  const maxRepeatedInvalidToolRequests = deps.maxRepeatedInvalidToolRequests;
35394
35805
  const appendRuntimeEvent = deps.appendRuntimeEvent;
35395
- const processHarnessImprovementBoundary = deps.processHarnessImprovementBoundary;
35396
- const recordCompletedToolBatch = (session, turn) => processHarnessImprovementBoundary?.({ session, turn, boundaryKind: "completed_tool_batch" });
35397
35806
  const safeUpsertModelUsageRecord = deps.upsertModelUsageRecord;
35398
35807
  const executeNativeToolCalls = deps.executeNativeToolCalls;
35399
35808
  const readProfileSkillForModel = deps.readProfileSkillForModel;
@@ -35662,7 +36071,6 @@ function createHostedToolLoopRuntime(deps) {
35662
36071
  for (const result of nativeResults) {
35663
36072
  messages.push(toolResultMessage(result));
35664
36073
  }
35665
- await recordCompletedToolBatch(session, params.turn);
35666
36074
  const blockingQuestion = nativeResults.find(
35667
36075
  (result) => result.turnControl === "await_user_input"
35668
36076
  );
@@ -35900,7 +36308,6 @@ function createHostedToolLoopRuntime(deps) {
35900
36308
  session = withDefaultExperience(await getSession(session.id));
35901
36309
  toolResults2.push(formatWorkspaceToolResultForModel(result));
35902
36310
  }
35903
- await recordCompletedToolBatch(session, params.turn);
35904
36311
  messages.push({
35905
36312
  role: "user",
35906
36313
  content: [
@@ -36555,9 +36962,9 @@ function manageSidebarFileToolInput(args) {
36555
36962
  if (action !== "pin" && action !== "save_for_later" && action !== "remove" && action !== "list") {
36556
36963
  throw new Error("action must be pin, save_for_later, remove, or list");
36557
36964
  }
36558
- const path46 = optionalStringArg(args, "path");
36559
- if (action !== "list" && !path46) throw new Error("path is required for this action");
36560
- return { action, ...path46 ? { path: path46 } : {} };
36965
+ const path47 = optionalStringArg(args, "path");
36966
+ if (action !== "list" && !path47) throw new Error("path is required for this action");
36967
+ return { action, ...path47 ? { path: path47 } : {} };
36561
36968
  }
36562
36969
  function manageSidebarFileToolResult(callId, result) {
36563
36970
  return {
@@ -36715,7 +37122,7 @@ function optionalBooleanArg(args, key) {
36715
37122
 
36716
37123
  // ../server/src/openpond/authoring-tool-registry.ts
36717
37124
  import { realpath as realpath2 } from "node:fs/promises";
36718
- import path34 from "node:path";
37125
+ import path35 from "node:path";
36719
37126
  function createAuthoringModelToolDefinitions(deps) {
36720
37127
  const definitions = [askUserDefinition()];
36721
37128
  if (!deps.loadProfileState) return definitions;
@@ -36921,7 +37328,7 @@ async function resolveAgentTarget(loadProfileState, context) {
36921
37328
  }
36922
37329
  const agent = profile.agents.find((candidate2) => candidate2.id === agentId);
36923
37330
  if (!agent?.enabled) throw new Error(`Enabled Profile Agent not found: ${agentId}`);
36924
- const candidate = agentId === "default" ? profile.sourcePath : path34.resolve(profile.sourcePath, "agents", agentId);
37331
+ const candidate = agentId === "default" ? profile.sourcePath : path35.resolve(profile.sourcePath, "agents", agentId);
36925
37332
  const canonicalRoot = await realpath2(profile.sourcePath);
36926
37333
  const canonicalTarget = await realpath2(candidate).catch(() => null);
36927
37334
  if (!canonicalTarget) throw new Error(`Profile Agent source does not exist: ${agentId}`);
@@ -36958,7 +37365,7 @@ function profileProjection(profile, turnMetadata, ref) {
36958
37365
  repoPath: profile.repoPath,
36959
37366
  sourcePath: profile.sourcePath,
36960
37367
  manifestPath: profile.manifestPath,
36961
- profileConfigPath: profile.sourcePath ? path34.join(profile.sourcePath, "settings", "profile.yaml") : null,
37368
+ profileConfigPath: profile.sourcePath ? path35.join(profile.sourcePath, "settings", "profile.yaml") : null,
36962
37369
  authoring: recordArg(turnMetadata, "authoringIntent"),
36963
37370
  skills: profile.skills.slice(0, 200).map((skill) => ({
36964
37371
  name: skill.name,
@@ -36974,7 +37381,7 @@ function profileProjection(profile, turnMetadata, ref) {
36974
37381
  id: agent.id,
36975
37382
  name: agent.name,
36976
37383
  path: agent.path,
36977
- sourcePath: profile.sourcePath ? agent.id === "default" ? profile.sourcePath : path34.resolve(profile.sourcePath, "agents", agent.id) : agent.path,
37384
+ sourcePath: profile.sourcePath ? agent.id === "default" ? profile.sourcePath : path35.resolve(profile.sourcePath, "agents", agent.id) : agent.path,
36978
37385
  enabled: agent.enabled,
36979
37386
  defaultAction: actions.find(
36980
37387
  (action) => action.sourceActionId === "chat" || action.id === `${agent.id}.chat`
@@ -37066,13 +37473,13 @@ function recordArg(value, key) {
37066
37473
  return candidate && typeof candidate === "object" && !Array.isArray(candidate) ? candidate : null;
37067
37474
  }
37068
37475
  function isWithin(root, candidate) {
37069
- const relative = path34.relative(root, candidate);
37070
- return relative === "" || !relative.startsWith("..") && !path34.isAbsolute(relative);
37476
+ const relative = path35.relative(root, candidate);
37477
+ return relative === "" || !relative.startsWith("..") && !path35.isAbsolute(relative);
37071
37478
  }
37072
37479
 
37073
37480
  // ../server/src/openpond/local-image-tool-registry.ts
37074
- import { execFile as execFile2 } from "node:child_process";
37075
- import path35 from "node:path";
37481
+ import { execFile as execFile3 } from "node:child_process";
37482
+ import path36 from "node:path";
37076
37483
  var SAMPLE_WIDTH = 12;
37077
37484
  var SAMPLE_HEIGHT = 8;
37078
37485
  var LUMINANCE_RAMP = " .:-=+*#%@";
@@ -37099,7 +37506,7 @@ function createLocalImageModelToolDefinition() {
37099
37506
  },
37100
37507
  execute: async (context) => {
37101
37508
  const requestedPath = stringArg6(context.args.path, "path");
37102
- const imagePath = path35.isAbsolute(requestedPath) ? path35.resolve(requestedPath) : context.session.cwd ? path35.resolve(context.session.cwd, requestedPath) : "";
37509
+ const imagePath = path36.isAbsolute(requestedPath) ? path36.resolve(requestedPath) : context.session.cwd ? path36.resolve(context.session.cwd, requestedPath) : "";
37103
37510
  if (!imagePath) throw new Error("A relative image path requires a selected local project.");
37104
37511
  const image = await readLocalImageFile(imagePath);
37105
37512
  if (!image) throw new Error(`Local image was not found or is not a supported image: ${imagePath}`);
@@ -37185,7 +37592,7 @@ function hexByte(value) {
37185
37592
  }
37186
37593
  function runImageCommand(command, args, signal) {
37187
37594
  return new Promise((resolve, reject) => {
37188
- execFile2(command, args, { encoding: "utf8", maxBuffer: 256 * 1024, signal }, (error, stdout) => {
37595
+ execFile3(command, args, { encoding: "utf8", maxBuffer: 256 * 1024, signal }, (error, stdout) => {
37189
37596
  if (error) {
37190
37597
  reject(new Error(`${command} could not inspect the image: ${error.message}`));
37191
37598
  return;
@@ -37354,7 +37761,7 @@ function assertCreateImproveMutationApproved(input) {
37354
37761
  }
37355
37762
 
37356
37763
  // ../server/src/runtime/create-pipeline-planner.ts
37357
- import { randomUUID as randomUUID11 } from "node:crypto";
37764
+ import { randomUUID as randomUUID12 } from "node:crypto";
37358
37765
  var PlannerQuestionOptionSchema = external_exports.object({
37359
37766
  id: external_exports.string().trim().min(1).optional(),
37360
37767
  label: external_exports.string().trim().min(1),
@@ -37524,8 +37931,8 @@ function createQuestionRun(run, decision, modelRef) {
37524
37931
  }
37525
37932
  function createPlanRun(run, decision, modelRef) {
37526
37933
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
37527
- const planId = `create_improve_plan_${randomUUID11()}`;
37528
- const approvalId = `approval_${randomUUID11()}`;
37934
+ const planId = `create_improve_plan_${randomUUID12()}`;
37935
+ const approvalId = `approval_${randomUUID12()}`;
37529
37936
  const target = plannedTarget(run.target, decision, run.objective);
37530
37937
  const sourceRoot = sourceRootForTarget(target);
37531
37938
  const actionShape = decision.actionShape;
@@ -37608,7 +38015,7 @@ function workflowCaptureForRun(run) {
37608
38015
  );
37609
38016
  return CreateImproveWorkflowCaptureSchema.parse({
37610
38017
  schemaVersion: "openpond.createImprove.workflowCapture.v1",
37611
- id: `workflow_capture_${randomUUID11()}`,
38018
+ id: `workflow_capture_${randomUUID12()}`,
37612
38019
  runId: run.id,
37613
38020
  command: run.command,
37614
38021
  objective: run.objective,
@@ -38057,12 +38464,12 @@ var KeyedRegistry = class {
38057
38464
  // ../server/src/runtime/local-create-pipeline.ts
38058
38465
  import { existsSync as existsSync2 } from "node:fs";
38059
38466
  import { cp, mkdir as mkdir3, readFile as readFile9 } from "node:fs/promises";
38060
- import path37 from "node:path";
38467
+ import path38 from "node:path";
38061
38468
 
38062
38469
  // ../server/src/runtime/local-create-pipeline-checks.ts
38063
38470
  import { existsSync } from "node:fs";
38064
38471
  import { readFile as readFile8 } from "node:fs/promises";
38065
- import path36 from "node:path";
38472
+ import path37 from "node:path";
38066
38473
  async function runLocalCreatePipelineChecks(input) {
38067
38474
  await assertLocalCreateSourceLayout(input.target);
38068
38475
  const checkMetadata = {};
@@ -38106,7 +38513,7 @@ async function runLocalCreatePipelineChecks(input) {
38106
38513
  const traceArtifactRef = traceRefFromCommandResult(parsedStdout);
38107
38514
  if (traceArtifactRef) {
38108
38515
  checkRefs.add(
38109
- path36.join(input.target.sourceRootRelativePath, traceArtifactRef)
38516
+ path37.join(input.target.sourceRootRelativePath, traceArtifactRef)
38110
38517
  );
38111
38518
  }
38112
38519
  checkMetadata[command.name] = {
@@ -38131,19 +38538,19 @@ async function assertLocalCreateSourceLayout(target) {
38131
38538
  `Codex did not create the expected agent source root: ${target.sourceRoot}`
38132
38539
  );
38133
38540
  }
38134
- const agentSourcePath = path36.join(target.sourceRoot, "agent", "agent.ts");
38541
+ const agentSourcePath = path37.join(target.sourceRoot, "agent", "agent.ts");
38135
38542
  if (!existsSync(agentSourcePath)) {
38136
38543
  throw new Error(
38137
38544
  `Codex did not create the expected SDK agent source: ${agentSourcePath}`
38138
38545
  );
38139
38546
  }
38140
- const rootManifestPath = path36.join(target.repoPath, "openpond-profile.json");
38547
+ const rootManifestPath = path37.join(target.repoPath, "openpond-profile.json");
38141
38548
  if (!existsSync(rootManifestPath)) {
38142
38549
  throw new Error(
38143
38550
  `Codex did not update the profile repo manifest: ${rootManifestPath}`
38144
38551
  );
38145
38552
  }
38146
- const profileManifestPath = path36.join(
38553
+ const profileManifestPath = path37.join(
38147
38554
  target.sourcePath,
38148
38555
  "settings",
38149
38556
  "profile.yaml"
@@ -38179,12 +38586,12 @@ async function assertLocalCreateSourceLayout(target) {
38179
38586
  }
38180
38587
  }
38181
38588
  async function assertGeneratedSdkArtifacts(target, requireEvalPass = true) {
38182
- const registryPath = path36.join(
38589
+ const registryPath = path37.join(
38183
38590
  target.sourceRoot,
38184
38591
  ".openpond",
38185
38592
  "action-registry.json"
38186
38593
  );
38187
- const evalResultsPath = path36.join(
38594
+ const evalResultsPath = path37.join(
38188
38595
  target.sourceRoot,
38189
38596
  ".openpond",
38190
38597
  "eval-results.json"
@@ -38251,44 +38658,44 @@ function parseJsonOutput(stdout) {
38251
38658
  return null;
38252
38659
  }
38253
38660
  }
38254
- function asRecord10(value) {
38661
+ function asRecord11(value) {
38255
38662
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
38256
38663
  }
38257
38664
  function recordArray(value) {
38258
38665
  if (!Array.isArray(value)) return null;
38259
38666
  return value.filter(
38260
- (item) => Boolean(asRecord10(item))
38667
+ (item) => Boolean(asRecord11(item))
38261
38668
  );
38262
38669
  }
38263
38670
  function traceRefFromCommandResult(value) {
38264
- const record6 = asRecord10(value);
38671
+ const record6 = asRecord11(value);
38265
38672
  const ref = stringValue9(record6?.traceArtifactRef);
38266
38673
  return ref?.startsWith(".openpond/") ? ref : null;
38267
38674
  }
38268
38675
  function summaryFromCommandResult(commandName, value) {
38269
- const record6 = asRecord10(value);
38676
+ const record6 = asRecord11(value);
38270
38677
  if (!record6) return null;
38271
38678
  if (commandName === "inspect") {
38272
38679
  return {
38273
38680
  actionCount: Array.isArray(record6.actionCatalog) ? record6.actionCatalog.length : null,
38274
- defaultAction: asRecord10(record6.agent)?.defaultAction ?? null,
38275
- projectName: asRecord10(record6.project)?.name ?? null
38681
+ defaultAction: asRecord11(record6.agent)?.defaultAction ?? null,
38682
+ projectName: asRecord11(record6.project)?.name ?? null
38276
38683
  };
38277
38684
  }
38278
38685
  if (commandName === "validate") {
38279
38686
  return {
38280
38687
  status: record6.status ?? null,
38281
- errors: asRecord10(record6.summary)?.errors ?? null,
38282
- warnings: asRecord10(record6.summary)?.warnings ?? null
38688
+ errors: asRecord11(record6.summary)?.errors ?? null,
38689
+ warnings: asRecord11(record6.summary)?.warnings ?? null
38283
38690
  };
38284
38691
  }
38285
38692
  if (commandName === "eval") {
38286
- return asRecord10(record6.summary);
38693
+ return asRecord11(record6.summary);
38287
38694
  }
38288
38695
  if (commandName === "direct-run") {
38289
38696
  return {
38290
- hasResult: Boolean(asRecord10(record6.result)),
38291
- resultKeys: Object.keys(asRecord10(record6.result) ?? {})
38697
+ hasResult: Boolean(asRecord11(record6.result)),
38698
+ resultKeys: Object.keys(asRecord11(record6.result) ?? {})
38292
38699
  };
38293
38700
  }
38294
38701
  return null;
@@ -38363,7 +38770,7 @@ async function applyApprovedLocalCreateImproveRun(snapshot, options = {}) {
38363
38770
  blockedReason: null,
38364
38771
  sourceRefs: [
38365
38772
  target.sourceRootRelativePath,
38366
- path37.join(target.profileRelativePath, "settings", "profile.yaml"),
38773
+ path38.join(target.profileRelativePath, "settings", "profile.yaml"),
38367
38774
  "openpond-profile.json"
38368
38775
  ],
38369
38776
  metadata: {
@@ -38389,7 +38796,7 @@ async function applyApprovedLocalCreateImproveRun(snapshot, options = {}) {
38389
38796
  allowedPaths: snapshot.plan?.sourcePlan.map((item) => item.path) ?? [],
38390
38797
  sourceRefs: [
38391
38798
  target.sourceRootRelativePath,
38392
- path37.join(target.profileRelativePath, "settings", "profile.yaml"),
38799
+ path38.join(target.profileRelativePath, "settings", "profile.yaml"),
38393
38800
  "openpond-profile.json"
38394
38801
  ],
38395
38802
  artifactRefs: [],
@@ -38518,7 +38925,7 @@ function agentCandidateId(runId) {
38518
38925
  return `agent_candidate_${runId}`;
38519
38926
  }
38520
38927
  function checkSummary(metadata) {
38521
- const evaluation = asRecord11(metadata?.eval);
38928
+ const evaluation = asRecord12(metadata?.eval);
38522
38929
  const total = typeof evaluation?.total === "number" ? evaluation.total : null;
38523
38930
  return total === null ? "Agent SDK checks and deterministic Evals passed." : `${total} Agent SDK Eval${total === 1 ? "" : "s"} passed.`;
38524
38931
  }
@@ -38535,14 +38942,14 @@ function resolveLocalCreatePipelineTarget(snapshot) {
38535
38942
  if (!repoPath)
38536
38943
  throw new Error("Local Create approval is missing a profile repo path.");
38537
38944
  const activeProfile = adapter.activeProfile?.trim() || "default";
38538
- const resolvedSourcePath = path37.resolve(sourcePath);
38539
- const resolvedRepoPath = path37.resolve(repoPath);
38945
+ const resolvedSourcePath = path38.resolve(sourcePath);
38946
+ const resolvedRepoPath = path38.resolve(repoPath);
38540
38947
  const agentId = normalizeAgentId(snapshot.target.id) ?? agentIdFromSourcePlan(snapshot) ?? slugFromObjective(snapshot.objective);
38541
38948
  const defaultAction = sourceActionIdForAgent(
38542
38949
  normalizeActionId(snapshot.plan?.defaultChatAction.key) ?? "chat",
38543
38950
  agentId
38544
38951
  );
38545
- const sourceRoot = snapshot.operation === "improve" && agentId === "default" ? resolvedSourcePath : path37.join(resolvedSourcePath, "agents", agentId);
38952
+ const sourceRoot = snapshot.operation === "improve" && agentId === "default" ? resolvedSourcePath : path38.join(resolvedSourcePath, "agents", agentId);
38546
38953
  return {
38547
38954
  activeProfile,
38548
38955
  agentId,
@@ -38551,11 +38958,11 @@ function resolveLocalCreatePipelineTarget(snapshot) {
38551
38958
  sourcePath: resolvedSourcePath,
38552
38959
  workspaceRoot: resolvedRepoPath,
38553
38960
  profileRelativePath: normalizeRelativePath(
38554
- path37.relative(resolvedRepoPath, resolvedSourcePath)
38961
+ path38.relative(resolvedRepoPath, resolvedSourcePath)
38555
38962
  ),
38556
38963
  sourceRoot,
38557
38964
  sourceRootRelativePath: normalizeRelativePath(
38558
- path37.relative(resolvedRepoPath, sourceRoot)
38965
+ path38.relative(resolvedRepoPath, sourceRoot)
38559
38966
  )
38560
38967
  };
38561
38968
  }
@@ -38699,20 +39106,20 @@ async function runModelBackedLocalCreateSourceApplication(input) {
38699
39106
  }
38700
39107
  async function applyPreparedHarnessSourceApplication(snapshot, target, env = process.env) {
38701
39108
  if (!scriptedOpenPondModelsEnabled(env)) return false;
38702
- const manifestPath = path37.join(
39109
+ const manifestPath = path38.join(
38703
39110
  target.workspaceRoot,
38704
39111
  HARNESS_PREPARED_SOURCE_MANIFEST
38705
39112
  );
38706
39113
  if (!existsSync2(manifestPath)) return false;
38707
39114
  const manifest = JSON.parse(await readFile9(manifestPath, "utf8"));
38708
- const root = asRecord11(manifest);
39115
+ const root = asRecord12(manifest);
38709
39116
  if (root?.schema !== "openpond.harnessPreparedSource.v1") {
38710
39117
  throw new Error(
38711
39118
  `${HARNESS_PREPARED_SOURCE_MANIFEST} must use schema openpond.harnessPreparedSource.v1.`
38712
39119
  );
38713
39120
  }
38714
- const agents = asRecord11(root.agents);
38715
- const agent = asRecord11(agents?.[target.agentId]);
39121
+ const agents = asRecord12(root.agents);
39122
+ const agent = asRecord12(agents?.[target.agentId]);
38716
39123
  const operation = asHarnessPreparedSourceOperation(
38717
39124
  agent?.[snapshot.operation]
38718
39125
  );
@@ -38745,20 +39152,20 @@ async function applyPreparedHarnessSourceApplication(snapshot, target, env = pro
38745
39152
  `Prepared harness registration source does not exist: ${registration.source}`
38746
39153
  );
38747
39154
  }
38748
- await mkdir3(path37.dirname(registrationTarget), { recursive: true });
39155
+ await mkdir3(path38.dirname(registrationTarget), { recursive: true });
38749
39156
  await cp(registrationSource, registrationTarget, { force: true });
38750
39157
  }
38751
39158
  return true;
38752
39159
  }
38753
39160
  function asHarnessPreparedSourceOperation(value) {
38754
- const operation = asRecord11(value);
39161
+ const operation = asRecord12(value);
38755
39162
  if (!operation || typeof operation.source !== "string" || !operation.source.trim())
38756
39163
  return null;
38757
39164
  if (operation.registrations !== void 0 && !Array.isArray(operation.registrations)) {
38758
39165
  throw new Error("Prepared harness source registrations must be an array.");
38759
39166
  }
38760
39167
  const registrations = (operation.registrations ?? []).map((value2) => {
38761
- const registration = asRecord11(value2);
39168
+ const registration = asRecord12(value2);
38762
39169
  if (!registration || typeof registration.source !== "string" || !registration.source.trim() || typeof registration.target !== "string" || !registration.target.trim()) {
38763
39170
  throw new Error(
38764
39171
  "Prepared harness source registrations require source and target paths."
@@ -38769,14 +39176,14 @@ function asHarnessPreparedSourceOperation(value) {
38769
39176
  return { source: operation.source, registrations };
38770
39177
  }
38771
39178
  function resolveHarnessManifestPath(workspaceRoot, relativePath, label) {
38772
- if (path37.isAbsolute(relativePath)) {
39179
+ if (path38.isAbsolute(relativePath)) {
38773
39180
  throw new Error(
38774
39181
  `Prepared harness ${label} must be relative to the profile repo.`
38775
39182
  );
38776
39183
  }
38777
- const root = path37.resolve(workspaceRoot);
38778
- const resolved = path37.resolve(root, relativePath);
38779
- if (resolved !== root && !resolved.startsWith(`${root}${path37.sep}`)) {
39184
+ const root = path38.resolve(workspaceRoot);
39185
+ const resolved = path38.resolve(root, relativePath);
39186
+ if (resolved !== root && !resolved.startsWith(`${root}${path38.sep}`)) {
38780
39187
  throw new Error(
38781
39188
  `Prepared harness ${label} must stay inside the profile repo.`
38782
39189
  );
@@ -38813,10 +39220,10 @@ async function localCreateSourceLayoutIsStable(target) {
38813
39220
  }
38814
39221
  async function sourceLayoutFingerprint(target) {
38815
39222
  const paths = [
38816
- path37.join(target.sourceRoot, "agent", "agent.ts"),
38817
- path37.join(target.sourceRoot, "package.json"),
38818
- path37.join(target.repoPath, "openpond-profile.json"),
38819
- path37.join(target.sourcePath, "settings", "profile.yaml")
39223
+ path38.join(target.sourceRoot, "agent", "agent.ts"),
39224
+ path38.join(target.sourceRoot, "package.json"),
39225
+ path38.join(target.repoPath, "openpond-profile.json"),
39226
+ path38.join(target.sourcePath, "settings", "profile.yaml")
38820
39227
  ];
38821
39228
  const parts = await Promise.all(
38822
39229
  paths.map(async (filePath) => {
@@ -38889,7 +39296,7 @@ function normalizeActionId(value) {
38889
39296
  const trimmed = value?.trim();
38890
39297
  return trimmed || null;
38891
39298
  }
38892
- function asRecord11(value) {
39299
+ function asRecord12(value) {
38893
39300
  return value && typeof value === "object" && !Array.isArray(value) ? value : null;
38894
39301
  }
38895
39302
  function sourceActionIdForAgent(actionId, agentId) {
@@ -38904,7 +39311,7 @@ function normalizeRelativePath(value) {
38904
39311
  }
38905
39312
 
38906
39313
  // ../server/src/runtime/create-pipeline/agent-evaluation.ts
38907
- import path38 from "node:path";
39314
+ import path39 from "node:path";
38908
39315
 
38909
39316
  // ../server/src/training/create-improve-taskset-lineage.ts
38910
39317
  function createEvidenceSnapshot(input) {
@@ -39175,15 +39582,15 @@ async function runNormalizedAgentEvaluation(input) {
39175
39582
  const results = Array.isArray(payload.results) ? payload.results : [];
39176
39583
  const sdkEvalRefs = results.map((evaluation) => stringValue11(evaluation.name)).filter((value) => Boolean(value));
39177
39584
  const artifactRefs = /* @__PURE__ */ new Set([
39178
- path38.posix.join(input.sourceRef, ".openpond/eval-results.json")
39585
+ path39.posix.join(input.sourceRef, ".openpond/eval-results.json")
39179
39586
  ]);
39180
39587
  for (const evaluation of results) {
39181
39588
  const trace = stringValue11(evaluation.traceArtifactRef);
39182
39589
  if (trace)
39183
- artifactRefs.add(path38.posix.join(input.sourceRef, normalizeRef(trace)));
39590
+ artifactRefs.add(path39.posix.join(input.sourceRef, normalizeRef(trace)));
39184
39591
  for (const artifact of stringArray4(evaluation.artifacts)) {
39185
39592
  artifactRefs.add(
39186
- path38.posix.join(input.sourceRef, normalizeRef(artifact))
39593
+ path39.posix.join(input.sourceRef, normalizeRef(artifact))
39187
39594
  );
39188
39595
  }
39189
39596
  }
@@ -39314,29 +39721,29 @@ function stringArray4(value) {
39314
39721
  import { existsSync as existsSync4 } from "node:fs";
39315
39722
  import { mkdir as mkdir5, realpath as realpath3, rm as rm2, writeFile as writeFile4 } from "node:fs/promises";
39316
39723
  import os3 from "node:os";
39317
- import path40 from "node:path";
39724
+ import path41 from "node:path";
39318
39725
 
39319
39726
  // ../server/src/runtime/create-pipeline/agent-improvement-git-helpers.ts
39320
39727
  import { existsSync as existsSync3 } from "node:fs";
39321
39728
  import { cp as cp2, lstat as lstat2, mkdir as mkdir4, rm, symlink, writeFile as writeFile3 } from "node:fs/promises";
39322
- import path39 from "node:path";
39729
+ import path40 from "node:path";
39323
39730
  function allowedAgentImprovementPaths(run, target) {
39324
39731
  const profilePath = normalizeRepoPath(target.profileRelativePath);
39325
39732
  const defaults = [
39326
39733
  normalizeRepoPath(target.sourceRootRelativePath),
39327
- path39.posix.join(profilePath, "evals"),
39328
- path39.posix.join(profilePath, "settings"),
39329
- path39.posix.join(profilePath, "package.json"),
39330
- path39.posix.join(profilePath, "tsconfig.json"),
39331
- path39.posix.join(profilePath, "openpond.lock"),
39332
- path39.posix.join(profilePath, ".gitignore"),
39734
+ path40.posix.join(profilePath, "evals"),
39735
+ path40.posix.join(profilePath, "settings"),
39736
+ path40.posix.join(profilePath, "package.json"),
39737
+ path40.posix.join(profilePath, "tsconfig.json"),
39738
+ path40.posix.join(profilePath, "openpond.lock"),
39739
+ path40.posix.join(profilePath, ".gitignore"),
39333
39740
  "openpond-profile.json"
39334
39741
  ];
39335
39742
  const planned = (run.plan?.sourcePlan ?? []).flatMap((item) => {
39336
39743
  const value = normalizeRepoPath(item.path);
39337
39744
  if (!value) return [];
39338
39745
  if (value === "." || value.startsWith(`${profilePath}/`)) return [value];
39339
- return [path39.posix.join(profilePath, value), value];
39746
+ return [path40.posix.join(profilePath, value), value];
39340
39747
  });
39341
39748
  return [.../* @__PURE__ */ new Set([...defaults, ...planned])];
39342
39749
  }
@@ -39378,7 +39785,7 @@ async function workingTreeMatchesCommit(input) {
39378
39785
  "rev-parse",
39379
39786
  `${input.commit}:${relativePath}`
39380
39787
  ]);
39381
- const absolutePath = path39.join(input.repoPath, ...relativePath.split("/"));
39788
+ const absolutePath = path40.join(input.repoPath, ...relativePath.split("/"));
39382
39789
  if (!blob) {
39383
39790
  if (existsSync3(absolutePath)) return false;
39384
39791
  continue;
@@ -39396,21 +39803,21 @@ async function workingTreeMatchesCommit(input) {
39396
39803
  async function linkCandidateDependencies(target, worktreePath) {
39397
39804
  const relativePaths = /* @__PURE__ */ new Set([
39398
39805
  "node_modules",
39399
- path39.posix.join(
39806
+ path40.posix.join(
39400
39807
  normalizeRepoPath(target.profileRelativePath),
39401
39808
  "node_modules"
39402
39809
  ),
39403
- path39.posix.join(
39810
+ path40.posix.join(
39404
39811
  normalizeRepoPath(target.sourceRootRelativePath),
39405
39812
  "node_modules"
39406
39813
  )
39407
39814
  ]);
39408
39815
  for (const relativePath of relativePaths) {
39409
- const sourcePath = path39.join(target.repoPath, ...relativePath.split("/"));
39410
- const destinationPath = path39.join(worktreePath, ...relativePath.split("/"));
39816
+ const sourcePath = path40.join(target.repoPath, ...relativePath.split("/"));
39817
+ const destinationPath = path40.join(worktreePath, ...relativePath.split("/"));
39411
39818
  if (!await directoryExists(sourcePath) || existsSync3(destinationPath))
39412
39819
  continue;
39413
- await mkdir4(path39.dirname(destinationPath), { recursive: true });
39820
+ await mkdir4(path40.dirname(destinationPath), { recursive: true });
39414
39821
  await symlink(
39415
39822
  sourcePath,
39416
39823
  destinationPath,
@@ -39426,7 +39833,7 @@ async function snapshotActiveProfileChanges(input) {
39426
39833
  );
39427
39834
  assertCommand(trackedDiff, "Unable to capture active Profile changes.");
39428
39835
  if (trackedDiff.stdout) {
39429
- const patchPath = path39.join(input.workspaceRoot, "active-profile.patch");
39836
+ const patchPath = path40.join(input.workspaceRoot, "active-profile.patch");
39430
39837
  await writeFile3(patchPath, trackedDiff.stdout, "utf8");
39431
39838
  const applied = await input.command(
39432
39839
  "git",
@@ -39446,12 +39853,12 @@ async function snapshotActiveProfileChanges(input) {
39446
39853
  );
39447
39854
  assertCommand(untracked, "Unable to inspect untracked Profile source.");
39448
39855
  for (const relativePath of untracked.stdout.split("\0").filter(snapshotEligiblePath)) {
39449
- const source = path39.join(input.repoPath, ...relativePath.split("/"));
39450
- const destination = path39.join(
39856
+ const source = path40.join(input.repoPath, ...relativePath.split("/"));
39857
+ const destination = path40.join(
39451
39858
  input.worktreePath,
39452
39859
  ...relativePath.split("/")
39453
39860
  );
39454
- await mkdir4(path39.dirname(destination), { recursive: true });
39861
+ await mkdir4(path40.dirname(destination), { recursive: true });
39455
39862
  await cp2(source, destination, {
39456
39863
  recursive: true,
39457
39864
  preserveTimestamps: true
@@ -39612,8 +40019,8 @@ function restoreAgentImprovementWorkspace(target, git) {
39612
40019
  ...target,
39613
40020
  repoPath: worktreePath,
39614
40021
  workspaceRoot: worktreePath,
39615
- sourcePath: path40.join(worktreePath, ...profileRelativePath.split("/")),
39616
- sourceRoot: path40.join(worktreePath, ...sourceRootRelativePath.split("/"))
40022
+ sourcePath: path41.join(worktreePath, ...profileRelativePath.split("/")),
40023
+ sourceRoot: path41.join(worktreePath, ...sourceRootRelativePath.split("/"))
39617
40024
  },
39618
40025
  git
39619
40026
  };
@@ -39668,13 +40075,13 @@ async function prepareAgentImprovementWorkspace(input) {
39668
40075
  );
39669
40076
  }
39670
40077
  const branch = candidateBranch(input.run, input.target.agentId);
39671
- const workspaceRoot = path40.join(
40078
+ const workspaceRoot = path41.join(
39672
40079
  os3.tmpdir(),
39673
40080
  "openpond-agent-improvements",
39674
- safePathSegment(path40.basename(repoPath) || "profile"),
40081
+ safePathSegment(path41.basename(repoPath) || "profile"),
39675
40082
  safePathSegment(input.run.id)
39676
40083
  );
39677
- const worktreePath = path40.join(workspaceRoot, "repo");
40084
+ const worktreePath = path41.join(workspaceRoot, "repo");
39678
40085
  await mkdir5(workspaceRoot, { recursive: true });
39679
40086
  const existingBranch = await command(
39680
40087
  "git",
@@ -39735,8 +40142,8 @@ async function prepareAgentImprovementWorkspace(input) {
39735
40142
  ...input.target,
39736
40143
  repoPath: worktreePath,
39737
40144
  workspaceRoot: worktreePath,
39738
- sourcePath: path40.join(worktreePath, ...profileRelativePath.split("/")),
39739
- sourceRoot: path40.join(worktreePath, ...sourceRootRelativePath.split("/"))
40145
+ sourcePath: path41.join(worktreePath, ...profileRelativePath.split("/")),
40146
+ sourceRoot: path41.join(worktreePath, ...sourceRootRelativePath.split("/"))
39740
40147
  },
39741
40148
  git: {
39742
40149
  baseBranch,
@@ -40033,7 +40440,7 @@ async function applyAgentImprovementCandidateLocally(input) {
40033
40440
  assertCommand(patch, "Unable to build the local Agent change.");
40034
40441
  if (!patch.stdout.trim())
40035
40442
  throw new Error("Agent candidate produced an empty local change.");
40036
- const patchPath = path40.join(
40443
+ const patchPath = path41.join(
40037
40444
  os3.tmpdir(),
40038
40445
  `openpond-agent-change-${safePathSegment(input.run.id)}-${Date.now()}.patch`
40039
40446
  );
@@ -40144,7 +40551,7 @@ async function cleanupAgentImprovementWorkspace(input) {
40144
40551
  await command("git", ["branch", "-D", input.git.branch], input.repoPath);
40145
40552
  }
40146
40553
  if (input.git.worktreePath) {
40147
- await rm2(path40.dirname(input.git.worktreePath), {
40554
+ await rm2(path41.dirname(input.git.worktreePath), {
40148
40555
  recursive: true,
40149
40556
  force: true
40150
40557
  }).catch(() => void 0);
@@ -40153,14 +40560,14 @@ async function cleanupAgentImprovementWorkspace(input) {
40153
40560
 
40154
40561
  // ../server/src/agents/agent-package-origin.ts
40155
40562
  import { promises as fs20 } from "node:fs";
40156
- import path41 from "node:path";
40563
+ import path42 from "node:path";
40157
40564
  async function readAgentPackageOrigin(agentRootPath, manifestHash) {
40158
- const originPath = path41.join(
40565
+ const originPath = path42.join(
40159
40566
  agentRootPath,
40160
40567
  ".openpond",
40161
40568
  "agent-package-origin.json"
40162
40569
  );
40163
- const origin = await fs20.readFile(originPath, "utf8").then((raw) => asRecord12(JSON.parse(raw))).catch(() => ({}));
40570
+ const origin = await fs20.readFile(originPath, "utf8").then((raw) => asRecord13(JSON.parse(raw))).catch(() => ({}));
40164
40571
  const versionId = stringValue13(origin.versionId);
40165
40572
  const digest = stringValue13(origin.digest);
40166
40573
  if (versionId && digest && /^[a-f0-9]{64}$/.test(digest) && versionId === `agent-${digest.slice(0, 20)}`) {
@@ -40178,7 +40585,7 @@ async function readAgentPackageOrigin(agentRootPath, manifestHash) {
40178
40585
  evalReceiptIds: []
40179
40586
  };
40180
40587
  }
40181
- function asRecord12(value) {
40588
+ function asRecord13(value) {
40182
40589
  return value && typeof value === "object" && !Array.isArray(value) ? value : {};
40183
40590
  }
40184
40591
  function stringValue13(value) {
@@ -41255,7 +41662,7 @@ function uniqueEvidence(run, evidence) {
41255
41662
  }
41256
41663
  async function verifyAppliedProfileCommit(input) {
41257
41664
  const command = input.command ?? (async (name, args, cwd, env) => {
41258
- const { runWorkspaceCommand } = await import("./workspaces-5LKGF3AG.js");
41665
+ const { runWorkspaceCommand } = await import("./workspaces-26IF6TQV.js");
41259
41666
  return runWorkspaceCommand(name, args, cwd, env);
41260
41667
  });
41261
41668
  const result = await command("git", ["rev-parse", "HEAD"], input.repoPath);
@@ -42046,7 +42453,7 @@ function subagentSystemContextForSession(session, delegation) {
42046
42453
  }
42047
42454
 
42048
42455
  // ../server/src/runtime/subagents/workspace-state.ts
42049
- import path42 from "node:path";
42456
+ import path43 from "node:path";
42050
42457
  var RETAINED_WORKSPACE_DAYS = 7;
42051
42458
  var RETAINED_WORKSPACE_MS = RETAINED_WORKSPACE_DAYS * 24 * 60 * 60 * 1e3;
42052
42459
  function subagentCleanupRetainReason(run, policy) {
@@ -42097,10 +42504,10 @@ function truthyRecordBoolean(record6, key) {
42097
42504
  return record6[key] === true;
42098
42505
  }
42099
42506
  function assertPathInside(input) {
42100
- const rootPath = path42.resolve(input.rootPath);
42101
- const targetPath = path42.resolve(input.targetPath);
42102
- const relative = path42.relative(rootPath, targetPath);
42103
- if (relative && !relative.startsWith("..") && !path42.isAbsolute(relative)) return;
42507
+ const rootPath = path43.resolve(input.rootPath);
42508
+ const targetPath = path43.resolve(input.targetPath);
42509
+ const relative = path43.relative(rootPath, targetPath);
42510
+ if (relative && !relative.startsWith("..") && !path43.isAbsolute(relative)) return;
42104
42511
  throw new Error(`${input.label} path must stay inside the isolated subagent workspace.`);
42105
42512
  }
42106
42513
  function addMillisecondsToIso(iso, ms) {
@@ -42264,7 +42671,7 @@ async function applySubagentPatch(run, options = {}) {
42264
42671
  // ../server/src/runtime/subagents/workspace-runtime.ts
42265
42672
  import { promises as fs21 } from "node:fs";
42266
42673
  import os4 from "node:os";
42267
- import path43 from "node:path";
42674
+ import path44 from "node:path";
42268
42675
  function createSubagentWorkspaceRuntime(deps) {
42269
42676
  const {
42270
42677
  attachmentRootDir,
@@ -42544,13 +42951,13 @@ function createSubagentWorkspaceRuntime(deps) {
42544
42951
  }
42545
42952
  const safeRunId = safeSubagentPathSegment(input.runId);
42546
42953
  const safeRoleId = safeSubagentPathSegment(input.role.id);
42547
- const workspaceRoot = path43.join(
42954
+ const workspaceRoot = path44.join(
42548
42955
  os4.tmpdir(),
42549
42956
  "openpond-subagents",
42550
- safeSubagentPathSegment(path43.basename(parentRepoPath) || "repo"),
42957
+ safeSubagentPathSegment(path44.basename(parentRepoPath) || "repo"),
42551
42958
  `${safeRoleId}-${safeRunId}`
42552
42959
  );
42553
- const worktreePath = path43.join(workspaceRoot, "repo");
42960
+ const worktreePath = path44.join(workspaceRoot, "repo");
42554
42961
  const branch = `openpond/subagent/${safeRoleId}/${safeRunId.slice(0, 24)}`;
42555
42962
  await fs21.rm(workspaceRoot, { recursive: true, force: true });
42556
42963
  await fs21.mkdir(workspaceRoot, { recursive: true });
@@ -42587,8 +42994,8 @@ function createSubagentWorkspaceRuntime(deps) {
42587
42994
  const links = [];
42588
42995
  const candidates = await localSubagentDependencyArtifactCandidates(input.parentRepoPath);
42589
42996
  for (const relativePath of candidates) {
42590
- const sourcePath = path43.join(input.parentRepoPath, ...relativePath.split("/"));
42591
- const targetPath = path43.join(input.worktreePath, ...relativePath.split("/"));
42997
+ const sourcePath = path44.join(input.parentRepoPath, ...relativePath.split("/"));
42998
+ const targetPath = path44.join(input.worktreePath, ...relativePath.split("/"));
42592
42999
  const sourceStat = await safeLstat(sourcePath);
42593
43000
  if (!sourceStat) {
42594
43001
  links.push({ path: relativePath, sourcePath, targetPath, status: "missing" });
@@ -42607,7 +43014,7 @@ function createSubagentWorkspaceRuntime(deps) {
42607
43014
  continue;
42608
43015
  }
42609
43016
  try {
42610
- await fs21.mkdir(path43.dirname(targetPath), { recursive: true });
43017
+ await fs21.mkdir(path44.dirname(targetPath), { recursive: true });
42611
43018
  await fs21.symlink(sourcePath, targetPath, process.platform === "win32" ? "junction" : "dir");
42612
43019
  links.push({ path: relativePath, sourcePath, targetPath, status: "linked" });
42613
43020
  } catch (error) {
@@ -42625,14 +43032,14 @@ function createSubagentWorkspaceRuntime(deps) {
42625
43032
  async function localSubagentDependencyArtifactCandidates(parentRepoPath) {
42626
43033
  const candidates = /* @__PURE__ */ new Set(["node_modules"]);
42627
43034
  for (const workspaceDir of await localWorkspacePackageDirs(parentRepoPath)) {
42628
- const relativePath = path43.posix.join(workspaceDir, "node_modules");
42629
- const sourcePath = path43.join(parentRepoPath, ...relativePath.split("/"));
43035
+ const relativePath = path44.posix.join(workspaceDir, "node_modules");
43036
+ const sourcePath = path44.join(parentRepoPath, ...relativePath.split("/"));
42630
43037
  if (await safeLstat(sourcePath)) candidates.add(relativePath);
42631
43038
  }
42632
43039
  return [...candidates];
42633
43040
  }
42634
43041
  async function localWorkspacePackageDirs(parentRepoPath) {
42635
- const packageJson = await readJsonFile2(path43.join(parentRepoPath, "package.json"));
43042
+ const packageJson = await readJsonFile2(path44.join(parentRepoPath, "package.json"));
42636
43043
  const workspaces = workspacePatternsFromPackageJson(packageJson);
42637
43044
  const dirs = [];
42638
43045
  for (const pattern of workspaces) {
@@ -42661,22 +43068,22 @@ function createSubagentWorkspaceRuntime(deps) {
42661
43068
  if (segment2 === "*") {
42662
43069
  const expanded = [];
42663
43070
  for (const relDir of relDirs) {
42664
- const absoluteDir = path43.join(parentRepoPath, ...relDir.split("/").filter(Boolean));
43071
+ const absoluteDir = path44.join(parentRepoPath, ...relDir.split("/").filter(Boolean));
42665
43072
  const entries = await safeReaddir(absoluteDir);
42666
43073
  for (const entry of entries) {
42667
43074
  if (!entry.isDirectory() || entry.name === "node_modules" || entry.name === ".git") continue;
42668
- expanded.push(path43.posix.join(relDir, entry.name));
43075
+ expanded.push(path44.posix.join(relDir, entry.name));
42669
43076
  }
42670
43077
  }
42671
43078
  relDirs = expanded;
42672
43079
  continue;
42673
43080
  }
42674
43081
  if (segment2.includes("*")) return [];
42675
- relDirs = relDirs.map((relDir) => path43.posix.join(relDir, segment2));
43082
+ relDirs = relDirs.map((relDir) => path44.posix.join(relDir, segment2));
42676
43083
  }
42677
43084
  const existing = [];
42678
43085
  for (const relDir of relDirs) {
42679
- const stat = await safeLstat(path43.join(parentRepoPath, ...relDir.split("/").filter(Boolean)));
43086
+ const stat = await safeLstat(path44.join(parentRepoPath, ...relDir.split("/").filter(Boolean)));
42680
43087
  if (stat?.isDirectory()) existing.push(relDir);
42681
43088
  }
42682
43089
  return existing;
@@ -42755,7 +43162,7 @@ function createSubagentWorkspaceRuntime(deps) {
42755
43162
  const patch = diffResult.stdout;
42756
43163
  const changed = Boolean(patch.trim());
42757
43164
  const patchArtifact = changed ? await durableSubagentPatchArtifact(run) : null;
42758
- const patchPath = patchArtifact?.patchPath ?? path43.join(workspaceRoot, "handoff.patch");
43165
+ const patchPath = patchArtifact?.patchPath ?? path44.join(workspaceRoot, "handoff.patch");
42759
43166
  if (changed) await fs21.writeFile(patchPath, patch, "utf8");
42760
43167
  const patchPreview = truncatePatch(patch);
42761
43168
  const patchRef = changed ? { kind: "file", id: patchPath, label: "Isolated child patch" } : null;
@@ -42790,7 +43197,7 @@ function createSubagentWorkspaceRuntime(deps) {
42790
43197
  };
42791
43198
  }
42792
43199
  async function durableSubagentPatchArtifact(run) {
42793
- const rootPath = path43.join(
43200
+ const rootPath = path44.join(
42794
43201
  attachmentRootDir,
42795
43202
  "subagents",
42796
43203
  safeSubagentPathSegment(run.parentSessionId),
@@ -42799,7 +43206,7 @@ function createSubagentWorkspaceRuntime(deps) {
42799
43206
  await fs21.mkdir(rootPath, { recursive: true });
42800
43207
  return {
42801
43208
  rootPath,
42802
- patchPath: path43.join(rootPath, "handoff.patch")
43209
+ patchPath: path44.join(rootPath, "handoff.patch")
42803
43210
  };
42804
43211
  }
42805
43212
  function captureSubagentSandboxForkHandoff(run, workspace) {
@@ -43742,7 +44149,7 @@ function sandboxRank(sandbox) {
43742
44149
  }
43743
44150
 
43744
44151
  // ../server/src/runtime/subagents/messaging-runtime.ts
43745
- import { randomUUID as randomUUID12 } from "node:crypto";
44152
+ import { randomUUID as randomUUID13 } from "node:crypto";
43746
44153
  function subagentActiveTurnIsDurablyTerminal(active, durableTurn) {
43747
44154
  return Boolean(
43748
44155
  active && durableTurn?.id === active.turn.id && durableTurn.status !== "in_progress"
@@ -43786,7 +44193,7 @@ function createSubagentMessagingRuntime(deps) {
43786
44193
  reason: delivered ? null : input.toRunId || input.toRole ? "No matching active child run was available for delivery." : "No target run or role was supplied."
43787
44194
  };
43788
44195
  let message = SubagentMessageSchema.parse({
43789
- id: randomUUID12(),
44196
+ id: randomUUID13(),
43790
44197
  fromRunId,
43791
44198
  toRunId: input.toRunId ?? null,
43792
44199
  toRole: input.toRole ?? null,
@@ -43861,7 +44268,7 @@ function createSubagentMessagingRuntime(deps) {
43861
44268
  reason: input.run.childSessionId ? null : "The child run has no child conversation."
43862
44269
  });
43863
44270
  const message = SubagentMessageSchema.parse({
43864
- id: randomUUID12(),
44271
+ id: randomUUID13(),
43865
44272
  fromRunId: input.context.session.subagentRunId ?? `parent:${input.context.session.id}`,
43866
44273
  toRunId: input.run.id,
43867
44274
  toRole: input.run.roleId,
@@ -44690,7 +45097,7 @@ function completionNotifications(run) {
44690
45097
  }
44691
45098
 
44692
45099
  // ../server/src/runtime/subagents/tool-runtime.ts
44693
- import { randomUUID as randomUUID13 } from "node:crypto";
45100
+ import { randomUUID as randomUUID14 } from "node:crypto";
44694
45101
  function createSubagentToolRuntime(deps) {
44695
45102
  const SUBAGENT_JOIN_WAIT_MS = 6e4;
44696
45103
  const SUBAGENT_JOIN_POLL_MS = 250;
@@ -44784,7 +45191,7 @@ function createSubagentToolRuntime(deps) {
44784
45191
  );
44785
45192
  }
44786
45193
  }
44787
- const runId = randomUUID13();
45194
+ const runId = randomUUID14();
44788
45195
  const createdAt = now();
44789
45196
  const childTurnPermissions = subagentChildTurnPermissions(
44790
45197
  context.turnPermissions,
@@ -45829,7 +46236,6 @@ function createTurnRunner(deps) {
45829
46236
  maxHostedWorkspaceToolRounds,
45830
46237
  maxRepeatedInvalidToolRequests,
45831
46238
  appendRuntimeEvent,
45832
- processHarnessImprovementBoundary: processHarnessImprovementBoundarySafely,
45833
46239
  upsertModelUsageRecord: safeUpsertModelUsageRecord,
45834
46240
  executeNativeToolCalls,
45835
46241
  readProfileSkillForModel,
@@ -46126,7 +46532,7 @@ function createTurnRunner(deps) {
46126
46532
  } : {}
46127
46533
  };
46128
46534
  const turn = {
46129
- id: randomUUID14(),
46535
+ id: randomUUID15(),
46130
46536
  sessionId,
46131
46537
  providerTurnId: null,
46132
46538
  modelRef: turnModelRef,
@@ -46842,7 +47248,7 @@ function createImproveLimit(value) {
46842
47248
  }
46843
47249
 
46844
47250
  // ../server/src/store/session-store.ts
46845
- import { randomUUID as randomUUID15 } from "node:crypto";
47251
+ import { randomUUID as randomUUID16 } from "node:crypto";
46846
47252
  function createSessionStore(deps) {
46847
47253
  const {
46848
47254
  store,
@@ -46855,7 +47261,7 @@ function createSessionStore(deps) {
46855
47261
  async function createSession(payload) {
46856
47262
  const input = CreateSessionRequestSchema.parse(payload);
46857
47263
  const createdAt = now();
46858
- const sessionId = randomUUID15();
47264
+ const sessionId = randomUUID16();
46859
47265
  const sessionCount = await store.sessionCount();
46860
47266
  const workspaceKind = input.workspaceKind ?? (input.appId ? "sandbox_app" : void 0);
46861
47267
  const openPondCommandAccessMode = input.openPondCommandAccessMode ?? (loadAppPreferences ? (await loadAppPreferences()).openPondCommandAccessMode : DEFAULT_OPENPOND_COMMAND_ACCESS_MODE);
@@ -47059,23 +47465,23 @@ function normalizeSession(session, sidebarPatch) {
47059
47465
 
47060
47466
  // ../server/src/workspace/project-directories.ts
47061
47467
  import os5 from "node:os";
47062
- import path44 from "node:path";
47468
+ import path45 from "node:path";
47063
47469
  var DEFAULT_NEW_PROJECTS_FOLDER = "OpenPond Projects";
47064
47470
  function expandHomeDirectory(inputPath) {
47065
47471
  if (inputPath === "~") return os5.homedir();
47066
47472
  if (inputPath.startsWith("~/") || inputPath.startsWith("~\\")) {
47067
- return path44.join(os5.homedir(), inputPath.slice(2));
47473
+ return path45.join(os5.homedir(), inputPath.slice(2));
47068
47474
  }
47069
47475
  return inputPath;
47070
47476
  }
47071
47477
  function defaultNewProjectDirectory() {
47072
- const documentsDir = process.env.OPENPOND_APP_DOCUMENTS_DIR?.trim() || path44.join(os5.homedir(), "Documents");
47073
- return path44.join(documentsDir, DEFAULT_NEW_PROJECTS_FOLDER);
47478
+ const documentsDir = process.env.OPENPOND_APP_DOCUMENTS_DIR?.trim() || path45.join(os5.homedir(), "Documents");
47479
+ return path45.join(documentsDir, DEFAULT_NEW_PROJECTS_FOLDER);
47074
47480
  }
47075
47481
  function normalizeProjectDirectory(inputPath) {
47076
47482
  const trimmed = inputPath?.trim();
47077
47483
  if (!trimmed) return defaultNewProjectDirectory();
47078
- return path44.resolve(expandHomeDirectory(trimmed));
47484
+ return path45.resolve(expandHomeDirectory(trimmed));
47079
47485
  }
47080
47486
 
47081
47487
  // ../server/src/preferences.ts
@@ -48644,13 +49050,13 @@ var APP_SERVER_COMPOSITION = [
48644
49050
  "jsonl_transport"
48645
49051
  ];
48646
49052
  async function createOpenPondAppServer(options = {}) {
48647
- const storeDir = path45.resolve(options.storeDir ?? appDataDir());
48648
- const workspaceDir = path45.resolve(options.workspaceDir ?? process.cwd());
49053
+ const storeDir = path46.resolve(options.storeDir ?? appDataDir());
49054
+ const workspaceDir = path46.resolve(options.workspaceDir ?? process.cwd());
48649
49055
  const version = options.version ?? VERSION;
48650
49056
  const runtimeVersion = getBundledRuntimeVersion();
48651
49057
  const logger = createLogger({
48652
49058
  channel: "app-server",
48653
- logDir: path45.join(storeDir, "logs"),
49059
+ logDir: path46.join(storeDir, "logs"),
48654
49060
  metadata: { version, runtimeVersion, placement: "hosted_work" }
48655
49061
  });
48656
49062
  const store = new SqliteStore(storeDir, { logger });
@@ -48658,6 +49064,7 @@ async function createOpenPondAppServer(options = {}) {
48658
49064
  options.streamOpenPondHostedChatTurn ?? streamOpenPondHostedChatTurn,
48659
49065
  { enabled: scriptedOpenPondModelsEnabled() }
48660
49066
  );
49067
+ const harnessEvaluationReviewStream = createLocalHarnessEvaluationReviewModelStream(streamOpenPondHostedChatTurn2);
48661
49068
  const {
48662
49069
  appendRuntimeEvent,
48663
49070
  closeEventSubscribers,
@@ -48755,7 +49162,7 @@ async function createOpenPondAppServer(options = {}) {
48755
49162
  });
48756
49163
  await harnessImprovement.reconcilePending();
48757
49164
  const turnRunner = createTurnRunner({
48758
- attachmentRootDir: path45.join(storeDir, "attachments"),
49165
+ attachmentRootDir: path46.join(storeDir, "attachments"),
48759
49166
  store,
48760
49167
  createSession,
48761
49168
  upsertApproval,
@@ -48831,7 +49238,8 @@ async function createOpenPondAppServer(options = {}) {
48831
49238
  let closing = false;
48832
49239
  const harnessSettings = createLocalHarnessSettingsRoutePayloads({
48833
49240
  store,
48834
- storeDir
49241
+ storeDir,
49242
+ evaluationReviewStream: harnessEvaluationReviewStream
48835
49243
  });
48836
49244
  const instance = createAppServer({
48837
49245
  ports: createAgentRuntimePorts({
@@ -48846,8 +49254,12 @@ async function createOpenPondAppServer(options = {}) {
48846
49254
  interruptSessionTurn: turnRunner.interruptSessionTurn,
48847
49255
  resolveApproval,
48848
49256
  inspectHarness: () => localHarnessHistoryPayload(store),
48849
- reviewHarnessProposal: createLocalHarnessSettingsRoutePayloads({ store, storeDir }).reviewHarnessProposalPayload,
48850
- reviewHarness: (request) => reviewSelectedLocalHarnessEvaluation({ store, request }),
49257
+ reviewHarnessProposal: harnessSettings.reviewHarnessProposalPayload,
49258
+ reviewHarness: (request) => reviewSelectedLocalHarnessEvaluation({
49259
+ store,
49260
+ request,
49261
+ stream: harnessEvaluationReviewStream
49262
+ }),
48851
49263
  acceptHarnessEvaluationReview: harnessTasksetReview.acceptEvaluationReview,
48852
49264
  materializeHarnessEvaluationTaskset: harnessTasksetReview.materializeEvaluationTaskset,
48853
49265
  runHarnessEvaluationBaseline: harnessTasksetReview.runEvaluationBaseline,
@@ -48899,7 +49311,7 @@ async function createOpenPondAppServer(options = {}) {
48899
49311
  function workspaceApp2(appId, workspaceDir) {
48900
49312
  return {
48901
49313
  id: appId || localPathWorkspaceId(workspaceDir),
48902
- name: path45.basename(workspaceDir) || "Sandbox workspace",
49314
+ name: path46.basename(workspaceDir) || "Sandbox workspace",
48903
49315
  description: null,
48904
49316
  visibility: "private",
48905
49317
  gitOwner: null,
@@ -48935,6 +49347,7 @@ export {
48935
49347
  loadLocalHarnessRuntimeForAgentRun,
48936
49348
  ensureLocalHarnessRunOverlay,
48937
49349
  trimOutput,
49350
+ executableSearchPath,
48938
49351
  reviewSelectedLocalHarnessEvaluation,
48939
49352
  createLocalHarnessEvaluationReviewScheduler,
48940
49353
  createLocalHarnessSettingsRoutePayloads,
@@ -48985,6 +49398,7 @@ export {
48985
49398
  loadBundledAuthoringSkills,
48986
49399
  readBundledAuthoringProfileSkill,
48987
49400
  createAgentRuntimePorts,
49401
+ createLocalHarnessEvaluationReviewModelStream,
48988
49402
  gradeAttempt,
48989
49403
  computeTasksetHash,
48990
49404
  startHarnessReviewTasksetAuthoring,