openpond 0.0.60 → 0.0.62
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.
- package/dist/chunks/{actions-command-BNVIILSL.js → actions-command-DZ6D7JTO.js} +2 -2
- package/dist/chunks/{app-layer-RNQXXM6L.js → app-layer-MSLVVYLM.js} +5 -5
- package/dist/chunks/{app-server-runtime-7LGK37P6.js → app-server-runtime-BRG7A5VD.js} +8 -8
- package/dist/chunks/{apps-LV3CSMLT.js → apps-6PAXKTB5.js} +5 -5
- package/dist/chunks/{chunk-XFZYNYRI.js → chunk-4NHAH3MT.js} +5979 -3817
- package/dist/chunks/{chunk-7QLVLGDM.js → chunk-64LYEFLR.js} +1 -1
- package/dist/chunks/{chunk-AHILPQXV.js → chunk-6JT34APP.js} +3 -3
- package/dist/chunks/{chunk-LMQ4MPQI.js → chunk-BFAL2CV3.js} +51 -57
- package/dist/chunks/{chunk-TOCZQEPW.js → chunk-FYB6ELFM.js} +1 -1
- package/dist/chunks/{chunk-RC3N77IV.js → chunk-GMX47RLP.js} +35 -33
- package/dist/chunks/{chunk-VG4H4TQG.js → chunk-IY2AW5F3.js} +1768 -57
- package/dist/chunks/{chunk-FHP7OMEI.js → chunk-J2REM7LE.js} +1 -1
- package/dist/chunks/{chunk-DXSHQ6TO.js → chunk-JGOP4GCK.js} +16 -5
- package/dist/chunks/{chunk-SKUS4NPW.js → chunk-K4JEWEJQ.js} +154 -5
- package/dist/chunks/{chunk-2J3LG4U7.js → chunk-KMBJLBQH.js} +2 -2
- package/dist/chunks/{chunk-LDRWEAOB.js → chunk-MBF44RYK.js} +1 -1
- package/dist/chunks/{chunk-NFNEENNR.js → chunk-OYWTQABY.js} +1 -1
- package/dist/chunks/{chunk-I23UKEYS.js → chunk-PLDCQVNW.js} +115 -18
- package/dist/chunks/{chunk-PVGJXCAK.js → chunk-T4FMK5GN.js} +54 -52
- package/dist/chunks/{chunk-63N6442Q.js → chunk-T55IL3GI.js} +1 -1
- package/dist/chunks/{cli-DBZ7S6ZF.js → cli-L25X2EZL.js} +7 -7
- package/dist/chunks/{core-commands-H2UC3LHG.js → core-commands-STKFZZVR.js} +6 -6
- package/dist/chunks/{desktop-test-TV64EY5A.js → desktop-test-ACKJN4UV.js} +5 -5
- package/dist/chunks/{extension-XMWCG6YG.js → extension-MVWXKSAD.js} +16 -51
- package/dist/chunks/{help-NEYFMHWQ.js → help-4MQ4EOIS.js} +1 -1
- package/dist/chunks/{opchat-ZL5JJQ5L.js → opchat-DUIZT4G6.js} +5 -5
- package/dist/chunks/{organizations-4IEC35QB.js → organizations-ATM4CZII.js} +7 -7
- package/dist/chunks/{profile-EVASCDIN.js → profile-5H3GF252.js} +12 -7
- package/dist/chunks/{project-agent-DMN64RZJ.js → project-agent-RSKSO5GT.js} +27 -7
- package/dist/chunks/{sandbox-command-WKGVO32R.js → sandbox-command-MTYSZR6P.js} +6 -6
- package/dist/chunks/{sandbox-template-BJUS4KJM.js → sandbox-template-RZ5AJ4KB.js} +7 -7
- package/dist/chunks/{src-KLQEJ6RO.js → src-PW337SIJ.js} +4 -4
- package/dist/chunks/{src-E2UCLY54.js → src-WKH7EP7W.js} +1273 -422
- package/dist/chunks/{teams-bot-HUXYJ6XA.js → teams-bot-FF3LDAYL.js} +5 -5
- package/dist/chunks/{workspaces-4OKABHI3.js → workspaces-QKADU2A6.js} +2 -2
- package/dist/cli.js +13 -13
- package/dist/index.js +16 -5
- package/dist/sandbox/client-handles.d.ts +2 -1
- package/dist/sandbox/client.d.ts +3 -1
- package/dist/sandbox/sandbox-instance-client.d.ts +2 -1
- package/dist/sandbox/types/org-project-agent.d.ts +23 -1
- package/dist/web/assets/{AppDialog-CxLYXiI1.js → AppDialog-1RkKL2v6.js} +1 -1
- package/dist/web/assets/{AppsView-CVTUkahv.js → AppsView-B6hDEt-h.js} +1 -1
- package/dist/web/assets/BrowserSidebar-CkAMOgiq.js +1 -0
- package/dist/web/assets/CommandMenu-9oAkS4X3.js +1 -0
- package/dist/web/assets/CommunityView-Dyuq5N28.js +1 -0
- package/dist/web/assets/ComposerCreateImproveStrip-D91cw5AT.js +1 -0
- package/dist/web/assets/{GetStartedView-l9MUYMYH.js → GetStartedView-BZpcZgjB.js} +1 -1
- package/dist/web/assets/LabModelVersionDetailPage-C0jNkciw.js +1 -0
- package/dist/web/assets/LabSkillSidebar-JGCPqTB1.js +1 -0
- package/dist/web/assets/LabsRoute-Dpv5Haqy.js +3 -0
- package/dist/web/assets/MainChatThread-B4_iIn3g.js +2 -0
- package/dist/web/assets/MainPane-o4HIxmNz.js +6 -0
- package/dist/web/assets/MarkdownText-DgS9KdyT.js +9 -0
- package/dist/web/assets/Messages-DjMa9H1T.js +10 -0
- package/dist/web/assets/NativeSkillSidebar-Q3fwLOiO.js +1 -0
- package/dist/web/assets/{NewProjectDialog-CiGPfI5s.js → NewProjectDialog-CUb0umRT.js} +1 -1
- package/dist/web/assets/OutputsPage-DD_1STRQ.js +1 -0
- package/dist/web/assets/RightChatPanelStack-2dFyjK7Z.js +1 -0
- package/dist/web/assets/ScheduledWorkPage-DPjweWpP.js +1 -0
- package/dist/web/assets/SettingsView-BS5m5vdt.css +1 -0
- package/dist/web/assets/SettingsView-DJGgGPL0.js +6 -0
- package/dist/web/assets/TeamChatView-CZmbzRk7.js +3 -0
- package/dist/web/assets/{TerminalOverlay-Bb0RJR04.js → TerminalOverlay-CpjrArXn.js} +1 -1
- package/dist/web/assets/TrainingCreationPanel-Tbj3qk8-.js +1 -0
- package/dist/web/assets/TrainingDraftPanel-BhggD-hn.js +1 -0
- package/dist/web/assets/{UsageSettingsSection-Cdc_jGFX.js → UsageSettingsSection-CXM6LKim.js} +1 -1
- package/dist/web/assets/WorkspaceDiffPanel-CoMkI8dY.js +14 -0
- package/dist/web/assets/WorkspaceEnvironmentMenu-CZyjk82C.js +32 -0
- package/dist/web/assets/{WorkspaceGitDialogs-CK6ahRty.js → WorkspaceGitDialogs-DTj3DOsf.js} +1 -1
- package/dist/web/assets/{WorkspaceMonacoEditor-BQoN7jWa.js → WorkspaceMonacoEditor-DaNMLEnU.js} +3 -3
- package/dist/web/assets/{arrow-up-right-CzBZuWNj.js → arrow-up-right-wvL_rSwe.js} +1 -1
- package/dist/web/assets/{chevron-up-DW-qEVSP.js → chevron-up-BbyiUcq_.js} +1 -1
- package/dist/web/assets/{cloud-upload-CjLR-8-r.js → cloud-upload-Bgv1fA6E.js} +1 -1
- package/dist/web/assets/{cssMode-CQQJhS7v.js → cssMode-BG9jdNNX.js} +1 -1
- package/dist/web/assets/{folder-open-BpUcIJHn.js → folder-open-CRAYp6pW.js} +1 -1
- package/dist/web/assets/{folder-plus-8NHsIAxQ.js → folder-plus-BgsuJVU0.js} +1 -1
- package/dist/web/assets/{git-branch-DO3iP_fL.js → git-branch-CicxCU5U.js} +1 -1
- package/dist/web/assets/{git-commit-horizontal-BSWa2I3g.js → git-commit-horizontal-BRkwl6bp.js} +1 -1
- package/dist/web/assets/{htmlMode-DaAKO9wk.js → htmlMode-B69EEM3s.js} +1 -1
- package/dist/web/assets/index-BGdmnwp7.js +1 -0
- package/dist/web/assets/index-Bt9mPk1q.css +1 -0
- package/dist/web/assets/index-Dcpm2LlR.js +178 -0
- package/dist/web/assets/{info-DiEvrUda.js → info-BxhCcEsF.js} +1 -1
- package/dist/web/assets/{jsonMode-Biu1ZTZ7.js → jsonMode-D0tzZkp2.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-lwoDxGgl.js → lspLanguageFeatures-DFpYfxMH.js} +1 -1
- package/dist/web/assets/{monaco.contribution-Ce2MS2Nv.js → monaco.contribution-BFP-1c-A.js} +2 -2
- package/dist/web/assets/{monaco.contribution-Ic8LKME8.js → monaco.contribution-BzGRrg8l.js} +2 -2
- package/dist/web/assets/{monaco.contribution-DzHhgeLy.js → monaco.contribution-K53jgqut.js} +2 -2
- package/dist/web/assets/{monaco.contribution-BqQSY5-t.js → monaco.contribution-lS_l56Q7.js} +2 -2
- package/dist/web/assets/{play-D9F3t5Cx.js → play-B8en8HVG.js} +1 -1
- package/dist/web/assets/{python-BhVCwr-K.js → python-DPtRb2z3.js} +1 -1
- package/dist/web/assets/{refresh-cw-DRN17xPU.js → refresh-cw-CRZeaNu7.js} +1 -1
- package/dist/web/assets/{save-CDZwpzlG.js → save-oO8erge1.js} +1 -1
- package/dist/web/assets/{square-Cf_AXs4a.js → square-CSULphDY.js} +1 -1
- package/dist/web/assets/{toggleHighContrast-Bb_m9pXM.js → toggleHighContrast-CmDdOtfT.js} +1 -1
- package/dist/web/assets/{tsMode-BaWkaSHN.js → tsMode-B0TCT940.js} +1 -1
- package/dist/web/assets/{upload-Cef29aCP.js → upload-dz-oCLFE.js} +1 -1
- package/dist/web/assets/{useLocalAgentSchedules-CAAqoZ0V.js → useLocalAgentSchedules-DPga1Kwi.js} +1 -1
- package/dist/web/assets/{wifi-off-C8cC22F6.js → wifi-off-BZpON33U.js} +1 -1
- package/dist/web/assets/{workers-GOdHtcZt.js → workers-DXVEq1Aw.js} +1 -1
- package/dist/web/assets/{yaml-jBIxwMeR.js → yaml-B8TBCEpi.js} +1 -1
- package/dist/web/index.html +2 -2
- package/docs/command-reference.md +2 -0
- package/package.json +1 -1
- package/dist/web/assets/BrowserSidebar-oHniLA05.js +0 -1
- package/dist/web/assets/CommandMenu-Db_5OiKs.js +0 -1
- package/dist/web/assets/CommunityView-HTwMEO-T.js +0 -1
- package/dist/web/assets/ComposerCreateImproveStrip-ER26yFe-.js +0 -1
- package/dist/web/assets/LabModelVersionDetailPage-Dgf-DlJi.js +0 -1
- package/dist/web/assets/LabSkillSidebar-CyX8sVm1.js +0 -1
- package/dist/web/assets/LabsRoute-BC1ST9qT.js +0 -3
- package/dist/web/assets/MainChatThread-BfW92Rv1.js +0 -2
- package/dist/web/assets/MainPane-DlciH8yR.js +0 -6
- package/dist/web/assets/MarkdownText-CyOeCVjf.js +0 -9
- package/dist/web/assets/Messages-BDtEbIKv.js +0 -9
- package/dist/web/assets/NativeSkillSidebar-D0BlvEtE.js +0 -1
- package/dist/web/assets/OutputsPage-DNU2yD7q.js +0 -1
- package/dist/web/assets/RightChatPanelStack-Cs63fQwk.js +0 -1
- package/dist/web/assets/ScheduledWorkPage-DMKHFbeE.js +0 -1
- package/dist/web/assets/SettingsView-C39BqlSI.css +0 -1
- package/dist/web/assets/SettingsView-L0g-g2fL.js +0 -6
- package/dist/web/assets/TeamChatView-CSVMTUAE.js +0 -3
- package/dist/web/assets/TrainingCreationPanel-VIWlpVV2.js +0 -1
- package/dist/web/assets/TrainingDraftPanel-MTYsR-Ry.js +0 -1
- package/dist/web/assets/WorkspaceDiffPanel-BgIbxMMu.js +0 -14
- package/dist/web/assets/WorkspaceEnvironmentMenu-C97GqYn9.js +0 -32
- package/dist/web/assets/circle-alert-B_xROoPY.js +0 -1
- package/dist/web/assets/folder-git-2-ktXin28y.js +0 -1
- package/dist/web/assets/folder-tLv6TMN2.js +0 -1
- package/dist/web/assets/index-BtiK52K1.js +0 -1
- package/dist/web/assets/index-CE2hroF6.css +0 -1
- package/dist/web/assets/index-DHxBMQIJ.js +0 -174
- package/dist/web/assets/square-pen-ChJgNiDm.js +0 -1
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
appDataDir,
|
|
10
10
|
asRecord,
|
|
11
11
|
attachModelTargetRefs,
|
|
12
|
+
autoTitlePromptFromPayload,
|
|
12
13
|
booleanValue,
|
|
13
14
|
chatAttachmentContext,
|
|
14
15
|
chatAttachmentImageContentType,
|
|
@@ -43,6 +44,7 @@ import {
|
|
|
43
44
|
createScriptedOpenPondChatStream,
|
|
44
45
|
createServerWorkQueues,
|
|
45
46
|
createSessionStore,
|
|
47
|
+
createSessionTitleService,
|
|
46
48
|
createTaskCreatorService,
|
|
47
49
|
createTaskEvaluationService,
|
|
48
50
|
createTasksetRef,
|
|
@@ -137,10 +139,11 @@ import {
|
|
|
137
139
|
upsertInternalSandboxProject,
|
|
138
140
|
validateOpenAiCompatibleProvider,
|
|
139
141
|
waitForWorkReceiptSettlement,
|
|
142
|
+
withPendingAutoTitle,
|
|
140
143
|
workspaceHasHead,
|
|
141
144
|
workspaceToolExperienceBlocker,
|
|
142
145
|
writeWorkspaceFile
|
|
143
|
-
} from "./chunk-
|
|
146
|
+
} from "./chunk-4NHAH3MT.js";
|
|
144
147
|
import {
|
|
145
148
|
appWorkspacePaths,
|
|
146
149
|
checkWorkspaceGitAvailability,
|
|
@@ -166,14 +169,14 @@ import {
|
|
|
166
169
|
runCommand,
|
|
167
170
|
startMacOSCommandLineToolsInstall,
|
|
168
171
|
workspaceImageContentType
|
|
169
|
-
} from "./chunk-
|
|
172
|
+
} from "./chunk-MBF44RYK.js";
|
|
170
173
|
import {
|
|
171
174
|
runOpenPondServerCli
|
|
172
|
-
} from "./chunk-
|
|
175
|
+
} from "./chunk-6JT34APP.js";
|
|
173
176
|
import {
|
|
174
177
|
createAppServer,
|
|
175
178
|
runAgentCompaction
|
|
176
|
-
} from "./chunk-
|
|
179
|
+
} from "./chunk-OYWTQABY.js";
|
|
177
180
|
import {
|
|
178
181
|
APP_PREFERENCES_CACHE_KEY,
|
|
179
182
|
APP_PREFERENCES_CACHE_TYPE,
|
|
@@ -185,7 +188,7 @@ import {
|
|
|
185
188
|
isCliEntrypoint,
|
|
186
189
|
now,
|
|
187
190
|
textFromUnknown
|
|
188
|
-
} from "./chunk-
|
|
191
|
+
} from "./chunk-FYB6ELFM.js";
|
|
189
192
|
import {
|
|
190
193
|
createOpenPondRepoApp,
|
|
191
194
|
getBundledRuntimeVersion,
|
|
@@ -199,7 +202,7 @@ import {
|
|
|
199
202
|
streamOpenPondHostedChatTurn,
|
|
200
203
|
switchOpenPondAccount,
|
|
201
204
|
updateOpenPondAccountConfig
|
|
202
|
-
} from "./chunk-
|
|
205
|
+
} from "./chunk-BFAL2CV3.js";
|
|
203
206
|
import {
|
|
204
207
|
AccountStateSchema,
|
|
205
208
|
AdapterValidationReceiptSchema,
|
|
@@ -432,17 +435,20 @@ import {
|
|
|
432
435
|
workFormatCapabilityForContentType,
|
|
433
436
|
workspacePathFromLocalPathWorkspaceId,
|
|
434
437
|
writeSourceUploadCache
|
|
435
|
-
} from "./chunk-
|
|
438
|
+
} from "./chunk-T4FMK5GN.js";
|
|
436
439
|
import "./chunk-QETF6ILG.js";
|
|
437
440
|
import {
|
|
441
|
+
ArtifactManifestSchema,
|
|
438
442
|
AttemptReceiptContentSchema,
|
|
439
443
|
AttemptReceiptSchema,
|
|
440
444
|
BenchmarkDefinitionSchema,
|
|
441
445
|
CONNECTED_APP_INTEGRATION_SKILLS,
|
|
442
446
|
DEFAULT_REFINER_MAX_OUTPUT_TOKENS,
|
|
443
447
|
EvidenceArtifactRefSchema,
|
|
448
|
+
ImmutableAssetRefSchema,
|
|
444
449
|
ImmutableReleaseRefSchema,
|
|
445
450
|
OPENPOND_MANIFEST_FILE_NAME,
|
|
451
|
+
RewardReceiptSchema,
|
|
446
452
|
SANDBOX_TEMPLATE_BUILD_PLAN_FILE_NAME,
|
|
447
453
|
SANDBOX_TEMPLATE_PREVIEW_PORT_MAX,
|
|
448
454
|
SANDBOX_TEMPLATE_PREVIEW_PORT_MIN,
|
|
@@ -470,17 +476,19 @@ import {
|
|
|
470
476
|
sandboxTemplateScaffoldFiles,
|
|
471
477
|
sha256,
|
|
472
478
|
validateSandboxTemplateYaml,
|
|
479
|
+
verifyArtifactManifest,
|
|
480
|
+
verifyRewardReceipt,
|
|
473
481
|
workEvidenceReceiptRef,
|
|
474
482
|
workSourceOpaqueRef,
|
|
475
483
|
workWorkspaceOpaqueRef
|
|
476
|
-
} from "./chunk-
|
|
484
|
+
} from "./chunk-IY2AW5F3.js";
|
|
477
485
|
import {
|
|
478
486
|
external_exports,
|
|
479
487
|
yaml
|
|
480
488
|
} from "./chunk-WYDVQOBL.js";
|
|
481
489
|
import {
|
|
482
490
|
withVercelProtectionBypass
|
|
483
|
-
} from "./chunk-
|
|
491
|
+
} from "./chunk-JGOP4GCK.js";
|
|
484
492
|
import {
|
|
485
493
|
__commonJS,
|
|
486
494
|
__require,
|
|
@@ -13333,9 +13341,9 @@ var require_dist = __commonJS({
|
|
|
13333
13341
|
});
|
|
13334
13342
|
|
|
13335
13343
|
// ../server/src/index.ts
|
|
13336
|
-
import
|
|
13344
|
+
import path62 from "node:path";
|
|
13337
13345
|
import { randomUUID as randomUUID24 } from "node:crypto";
|
|
13338
|
-
import { promises as
|
|
13346
|
+
import { promises as fs26 } from "node:fs";
|
|
13339
13347
|
|
|
13340
13348
|
// ../../packages/codex-provider/dist/client.js
|
|
13341
13349
|
import { spawn } from "node:child_process";
|
|
@@ -15351,6 +15359,12 @@ var FALLBACK_PROVIDER_PRESETS = [
|
|
|
15351
15359
|
contextWindow: 1048576,
|
|
15352
15360
|
capabilities: REASONING_MODEL_CAPABILITIES
|
|
15353
15361
|
},
|
|
15362
|
+
{
|
|
15363
|
+
id: "accounts/fireworks/models/nemotron-lightning-3p5-30b-a3b",
|
|
15364
|
+
displayName: "Nemotron Lightning 3.5 30B A3B",
|
|
15365
|
+
contextWindow: 262144,
|
|
15366
|
+
capabilities: REASONING_MODEL_CAPABILITIES
|
|
15367
|
+
},
|
|
15354
15368
|
{
|
|
15355
15369
|
id: "accounts/fireworks/models/minimax-m3",
|
|
15356
15370
|
displayName: "MiniMax M3",
|
|
@@ -20740,9 +20754,19 @@ function agentSdkRunScriptCommand(packageManager, scriptName) {
|
|
|
20740
20754
|
return `bun run ${scriptName}`;
|
|
20741
20755
|
return `pnpm run ${scriptName}`;
|
|
20742
20756
|
}
|
|
20757
|
+
function agentSdkRunJsonScriptCommand(packageManager, scriptName) {
|
|
20758
|
+
if (packageManager === "pnpm")
|
|
20759
|
+
return `pnpm --silent run ${scriptName}`;
|
|
20760
|
+
if (packageManager === "yarn")
|
|
20761
|
+
return `yarn --silent ${scriptName}`;
|
|
20762
|
+
if (packageManager === "npm")
|
|
20763
|
+
return `npm run --silent ${scriptName}`;
|
|
20764
|
+
if (packageManager === "bun")
|
|
20765
|
+
return `bun run --silent ${scriptName}`;
|
|
20766
|
+
return `pnpm --silent run ${scriptName}`;
|
|
20767
|
+
}
|
|
20743
20768
|
|
|
20744
20769
|
// ../../packages/cloud/dist/profile/project-source-upload-agent-sdk.js
|
|
20745
|
-
var OPENPOND_PNPM_PACKAGE_MANAGER = "pnpm@11.13.0";
|
|
20746
20770
|
var AGENT_SDK_VENDOR_TARBALL_PATH = ".openpond/vendor/openpond-agent-sdk.tgz";
|
|
20747
20771
|
var AGENT_SDK_VENDOR_NPM_DEPENDENCY_DIR = ".openpond/vendor/npm";
|
|
20748
20772
|
var AGENT_SDK_MATERIALIZED_DEPENDENCY_SPEC = `file:${AGENT_SDK_VENDOR_TARBALL_PATH}`;
|
|
@@ -20768,10 +20792,12 @@ async function buildAgentSdkMaterializedDependency(projectPath, packageJson) {
|
|
|
20768
20792
|
return null;
|
|
20769
20793
|
const tempDir = await fs9.mkdtemp(path15.join(tmpdir(), "openpond-agent-sdk-pack-"));
|
|
20770
20794
|
try {
|
|
20771
|
-
const sdkContents = sdkSource.kind === "package_root" ? await packOpenPondAgentSdkPackageRoot(sdkSource.packageRoot, tempDir) : sdkSource.tarballContents;
|
|
20795
|
+
const sdkContents = sdkSource.kind === "package_root" ? await packOpenPondAgentSdkPackageRoot(sdkSource.packageRoot, tempDir) : sdkSource.kind === "registry" ? await packOpenPondAgentSdkRegistryPackage(sdkSource.versionSpec, tempDir) : sdkSource.tarballContents;
|
|
20772
20796
|
const sdkDependencyTarballs = await packAgentSdkRuntimeDependencyTarballs({
|
|
20773
20797
|
sdkPackageJson: sdkSource.packageJson,
|
|
20774
20798
|
dependencyBaseDir: sdkSource.dependencyBaseDir,
|
|
20799
|
+
projectPackageJson: packageJson,
|
|
20800
|
+
projectPath,
|
|
20775
20801
|
tempDir
|
|
20776
20802
|
});
|
|
20777
20803
|
const packageManager = detectAgentSdkPackageManager(projectPath, packageJson);
|
|
@@ -20832,21 +20858,41 @@ ${details}` : ""}`);
|
|
|
20832
20858
|
return fs9.readFile(path15.join(tempDir, tarballName));
|
|
20833
20859
|
}
|
|
20834
20860
|
async function packAgentSdkRuntimeDependencyTarballs(params) {
|
|
20835
|
-
const
|
|
20836
|
-
const
|
|
20861
|
+
const sdkDependencies = recordStringMap(params.sdkPackageJson.dependencies);
|
|
20862
|
+
const projectDependencies = recordStringMap(params.projectPackageJson.dependencies);
|
|
20863
|
+
const projectDevDependencies = recordStringMap(params.projectPackageJson.devDependencies);
|
|
20864
|
+
delete projectDependencies["openpond-agent-sdk"];
|
|
20865
|
+
delete projectDevDependencies["openpond-agent-sdk"];
|
|
20866
|
+
const pending = [
|
|
20867
|
+
...Object.entries(sdkDependencies).map(([packageName, versionSpec]) => ({
|
|
20868
|
+
packageName,
|
|
20869
|
+
versionSpec,
|
|
20870
|
+
dependencyBaseDir: params.dependencyBaseDir
|
|
20871
|
+
})),
|
|
20872
|
+
...Object.entries(projectDependencies).map(([packageName, versionSpec]) => ({
|
|
20873
|
+
packageName,
|
|
20874
|
+
versionSpec,
|
|
20875
|
+
dependencyBaseDir: params.projectPath
|
|
20876
|
+
})),
|
|
20877
|
+
...Object.entries(projectDevDependencies).map(([packageName, versionSpec]) => ({
|
|
20878
|
+
packageName,
|
|
20879
|
+
versionSpec,
|
|
20880
|
+
dependencyBaseDir: params.projectPath
|
|
20881
|
+
}))
|
|
20882
|
+
].sort((left, right) => left.packageName.localeCompare(right.packageName));
|
|
20837
20883
|
const seen = /* @__PURE__ */ new Set();
|
|
20838
20884
|
const tarballs = [];
|
|
20839
20885
|
while (pending.length > 0) {
|
|
20840
|
-
const { packageName, versionSpec } = pending.shift();
|
|
20886
|
+
const { packageName, versionSpec, dependencyBaseDir } = pending.shift();
|
|
20841
20887
|
if (seen.has(packageName))
|
|
20842
20888
|
continue;
|
|
20843
20889
|
seen.add(packageName);
|
|
20844
20890
|
const packTarget = npmPackTargetForDependency({
|
|
20845
20891
|
packageName,
|
|
20846
20892
|
versionSpec,
|
|
20847
|
-
dependencyBaseDir
|
|
20893
|
+
dependencyBaseDir
|
|
20848
20894
|
});
|
|
20849
|
-
const pack = await runCommand2("npm", ["pack", "--silent", "--pack-destination", params.tempDir, packTarget], { cwd:
|
|
20895
|
+
const pack = await runCommand2("npm", ["pack", "--silent", "--pack-destination", params.tempDir, packTarget], { cwd: dependencyBaseDir });
|
|
20850
20896
|
if (pack.code !== 0) {
|
|
20851
20897
|
const details = [pack.stderr.trim(), pack.stdout.trim()].filter(Boolean).join("\n");
|
|
20852
20898
|
throw new Error(`failed to pack openpond-agent-sdk dependency ${packageName}${details ? `:
|
|
@@ -20857,7 +20903,12 @@ ${details}` : ""}`);
|
|
|
20857
20903
|
throw new Error(`failed to pack openpond-agent-sdk dependency ${packageName}: npm pack did not return a tarball name`);
|
|
20858
20904
|
}
|
|
20859
20905
|
const contents = await fs9.readFile(path15.join(params.tempDir, tarballName));
|
|
20860
|
-
|
|
20906
|
+
let packedPackageJson;
|
|
20907
|
+
try {
|
|
20908
|
+
packedPackageJson = readPackageJsonFromNpmTarball(contents);
|
|
20909
|
+
} catch (error) {
|
|
20910
|
+
throw new Error(`failed to inspect packed dependency ${packageName}: ${error instanceof Error ? error.message : String(error)}`);
|
|
20911
|
+
}
|
|
20861
20912
|
tarballs.push({
|
|
20862
20913
|
packageName,
|
|
20863
20914
|
source: "npm_dependency_tarball",
|
|
@@ -20868,12 +20919,20 @@ ${details}` : ""}`);
|
|
|
20868
20919
|
sizeBytes: contents.byteLength
|
|
20869
20920
|
});
|
|
20870
20921
|
for (const [dependencyName, dependencySpec] of Object.entries(recordStringMap(packedPackageJson.dependencies))) {
|
|
20871
|
-
pending.push({
|
|
20922
|
+
pending.push({
|
|
20923
|
+
packageName: dependencyName,
|
|
20924
|
+
versionSpec: dependencySpec,
|
|
20925
|
+
dependencyBaseDir
|
|
20926
|
+
});
|
|
20872
20927
|
}
|
|
20873
20928
|
for (const [dependencyName, dependencySpec] of Object.entries(recordStringMap(packedPackageJson.optionalDependencies))) {
|
|
20874
20929
|
if (!isSupportedSandboxOptionalDependency(dependencyName))
|
|
20875
20930
|
continue;
|
|
20876
|
-
pending.push({
|
|
20931
|
+
pending.push({
|
|
20932
|
+
packageName: dependencyName,
|
|
20933
|
+
versionSpec: dependencySpec,
|
|
20934
|
+
dependencyBaseDir
|
|
20935
|
+
});
|
|
20877
20936
|
}
|
|
20878
20937
|
}
|
|
20879
20938
|
return tarballs.sort((left, right) => left.packageName.localeCompare(right.packageName));
|
|
@@ -20895,6 +20954,25 @@ function npmPackTargetForDependency(params) {
|
|
|
20895
20954
|
function sanitizeNpmPackageNameForVendor(packageName) {
|
|
20896
20955
|
return packageName.replace(/^@/, "").replace(/[\/\\]/g, "__").replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
20897
20956
|
}
|
|
20957
|
+
async function packOpenPondAgentSdkRegistryPackage(versionSpec, tempDir) {
|
|
20958
|
+
const pack = await runCommand2("npm", [
|
|
20959
|
+
"pack",
|
|
20960
|
+
"--silent",
|
|
20961
|
+
"--pack-destination",
|
|
20962
|
+
tempDir,
|
|
20963
|
+
`openpond-agent-sdk@${versionSpec}`
|
|
20964
|
+
], { cwd: tempDir });
|
|
20965
|
+
if (pack.code !== 0) {
|
|
20966
|
+
const details = [pack.stderr.trim(), pack.stdout.trim()].filter(Boolean).join("\n");
|
|
20967
|
+
throw new Error(`failed to pack openpond-agent-sdk for source upload${details ? `:
|
|
20968
|
+
${details}` : ""}`);
|
|
20969
|
+
}
|
|
20970
|
+
const tarballName = pack.stdout.trim().split(/\r?\n/).filter(Boolean).pop();
|
|
20971
|
+
if (!tarballName) {
|
|
20972
|
+
throw new Error("failed to pack openpond-agent-sdk for source upload: npm pack did not return a tarball name");
|
|
20973
|
+
}
|
|
20974
|
+
return fs9.readFile(path15.join(tempDir, tarballName));
|
|
20975
|
+
}
|
|
20898
20976
|
function resolveLocalOpenPondAgentSdkMaterializationSource(projectPath, packageJson) {
|
|
20899
20977
|
const versionSpec = readOpenPondAgentSdkVersionSpec(packageJson);
|
|
20900
20978
|
if (versionSpec?.startsWith("file:")) {
|
|
@@ -20932,6 +21010,17 @@ function resolveLocalOpenPondAgentSdkMaterializationSource(projectPath, packageJ
|
|
|
20932
21010
|
};
|
|
20933
21011
|
}
|
|
20934
21012
|
}
|
|
21013
|
+
const installedPackageRoot = path15.join(projectPath, "node_modules", "openpond-agent-sdk");
|
|
21014
|
+
if (isOpenPondAgentSdkPackageRoot(installedPackageRoot)) {
|
|
21015
|
+
const installedPackageJson = JSON.parse(readFileSyncUtf8(path15.join(installedPackageRoot, "package.json")));
|
|
21016
|
+
const installedVersion = text(installedPackageJson.version);
|
|
21017
|
+
return {
|
|
21018
|
+
kind: "registry",
|
|
21019
|
+
versionSpec: installedVersion ?? versionSpec ?? "latest",
|
|
21020
|
+
dependencyBaseDir: installedPackageRoot,
|
|
21021
|
+
packageJson: installedPackageJson
|
|
21022
|
+
};
|
|
21023
|
+
}
|
|
20935
21024
|
return null;
|
|
20936
21025
|
}
|
|
20937
21026
|
function findOpenPondAgentSdkPackageRootInAncestors(projectPath) {
|
|
@@ -20982,12 +21071,12 @@ function readPackageJsonFromNpmTarball(tarballContents) {
|
|
|
20982
21071
|
}
|
|
20983
21072
|
const dataStart = offset + 512;
|
|
20984
21073
|
const dataEnd = dataStart + size;
|
|
20985
|
-
if (entryPath === "package/package.json") {
|
|
21074
|
+
if (entryPath === "package/package.json" || entryPath.endsWith("/package.json")) {
|
|
20986
21075
|
return JSON.parse(tarContents.subarray(dataStart, dataEnd).toString("utf8"));
|
|
20987
21076
|
}
|
|
20988
21077
|
offset = dataStart + Math.ceil(size / 512) * 512;
|
|
20989
21078
|
}
|
|
20990
|
-
throw new Error("failed to read
|
|
21079
|
+
throw new Error("failed to read npm package tarball: missing package.json");
|
|
20991
21080
|
}
|
|
20992
21081
|
function readTarString(header, start, length) {
|
|
20993
21082
|
const field = header.subarray(start, start + length);
|
|
@@ -21008,8 +21097,8 @@ function rewriteAgentSdkPackageJsonForMaterialization(packageJson, dependencyTar
|
|
|
21008
21097
|
if (Object.keys(overrides).length > 0) {
|
|
21009
21098
|
rewritten.overrides = overrides;
|
|
21010
21099
|
}
|
|
21011
|
-
if (packageManager === "unknown") {
|
|
21012
|
-
rewritten.packageManager
|
|
21100
|
+
if (packageManager === "pnpm" || packageManager === "unknown") {
|
|
21101
|
+
delete rewritten.packageManager;
|
|
21013
21102
|
}
|
|
21014
21103
|
for (const key of ["devDependencies", "peerDependencies"]) {
|
|
21015
21104
|
const entries = recordCopy(rewritten[key]);
|
|
@@ -21484,18 +21573,18 @@ function readAgentSdkProjectPackageJson(projectPath) {
|
|
|
21484
21573
|
}
|
|
21485
21574
|
function buildAgentSdkCommandHints(packageJson, packageManager) {
|
|
21486
21575
|
return {
|
|
21487
|
-
inspect: buildAgentSdkCommandHint(packageJson, packageManager, "agent:inspect", "openpond-agent inspect --json"),
|
|
21576
|
+
inspect: buildAgentSdkCommandHint(packageJson, packageManager, "agent:inspect", "openpond-agent inspect --json", true),
|
|
21488
21577
|
build: buildAgentSdkCommandHint(packageJson, packageManager, "agent:build", "openpond-agent build"),
|
|
21489
21578
|
validate: buildAgentSdkCommandHint(packageJson, packageManager, "agent:validate", "openpond-agent validate"),
|
|
21490
21579
|
eval: buildAgentSdkCommandHint(packageJson, packageManager, "agent:eval", "openpond-agent eval")
|
|
21491
21580
|
};
|
|
21492
21581
|
}
|
|
21493
|
-
function buildAgentSdkCommandHint(packageJson, packageManager, scriptName, fallback) {
|
|
21582
|
+
function buildAgentSdkCommandHint(packageJson, packageManager, scriptName, fallback, jsonOutput = false) {
|
|
21494
21583
|
const scripts = packageJson.scripts;
|
|
21495
21584
|
const hasScript = scripts && typeof scripts === "object" && !Array.isArray(scripts) && typeof scripts[scriptName] === "string";
|
|
21496
21585
|
if (!hasScript)
|
|
21497
21586
|
return fallback;
|
|
21498
|
-
return agentSdkRunScriptCommand(packageManager, scriptName);
|
|
21587
|
+
return jsonOutput ? agentSdkRunJsonScriptCommand(packageManager, scriptName) : agentSdkRunScriptCommand(packageManager, scriptName);
|
|
21499
21588
|
}
|
|
21500
21589
|
function readOpenPondAgentSdkVersionSpec2(packageJson) {
|
|
21501
21590
|
for (const key of ["dependencies", "devDependencies", "peerDependencies"]) {
|
|
@@ -21632,6 +21721,10 @@ async function materializeHostedProfileAgentSource(input) {
|
|
|
21632
21721
|
});
|
|
21633
21722
|
const sourceCommitSha = sandboxProjectSourceCommitSha(syncedProject) ?? sandboxProjectSourceCommitSha(uploadedProject);
|
|
21634
21723
|
const sourceRef = sandboxProjectSourceRef(syncedProject) ?? sandboxProjectSourceRef(uploadedProject) ?? input.sourceRef;
|
|
21724
|
+
const runtimeAgentExternalId = `openpond-profile-agent:${input.profileProjectId}:${input.profileName}:${input.agentId}`;
|
|
21725
|
+
const existingRuntimeAgent = (await input.client.agents.list({
|
|
21726
|
+
teamId: input.teamId
|
|
21727
|
+
})).find((candidate2) => candidate2.externalId === runtimeAgentExternalId);
|
|
21635
21728
|
const runtimeAgent = await input.client.agents.upsert({
|
|
21636
21729
|
teamId: input.teamId,
|
|
21637
21730
|
projectId: syncedProject.id,
|
|
@@ -21645,6 +21738,7 @@ async function materializeHostedProfileAgentSource(input) {
|
|
|
21645
21738
|
...sourceCommitSha ? { sourceCommitSha } : {}
|
|
21646
21739
|
},
|
|
21647
21740
|
metadata: {
|
|
21741
|
+
...existingRuntimeAgent?.metadata ?? {},
|
|
21648
21742
|
source: "openpond_profile_agent_materialization",
|
|
21649
21743
|
profileProjectId: input.profileProjectId,
|
|
21650
21744
|
profileName: input.profileName,
|
|
@@ -21653,7 +21747,7 @@ async function materializeHostedProfileAgentSource(input) {
|
|
|
21653
21747
|
localHead: input.localHead,
|
|
21654
21748
|
hostedHead: input.hostedHead
|
|
21655
21749
|
},
|
|
21656
|
-
externalId:
|
|
21750
|
+
externalId: runtimeAgentExternalId
|
|
21657
21751
|
});
|
|
21658
21752
|
const uploadMetadata = record(agentSdk.uploadMetadata);
|
|
21659
21753
|
const commands = record(uploadMetadata?.commands);
|
|
@@ -25413,11 +25507,11 @@ async function communityRequestPayload(action, dependencies = {}) {
|
|
|
25413
25507
|
const payload = await requestCommunityApi(request.path, request.init, dependencies);
|
|
25414
25508
|
return schemaForAction(action).parse(payload);
|
|
25415
25509
|
}
|
|
25416
|
-
async function requestCommunityApi(
|
|
25510
|
+
async function requestCommunityApi(path63, init = {}, dependencies = {}) {
|
|
25417
25511
|
const access5 = await resolveHostedApiAccess(dependencies);
|
|
25418
25512
|
const headers = hostedApiAuthHeaders(access5.token);
|
|
25419
25513
|
headers.set("Content-Type", "application/json");
|
|
25420
|
-
const response = await (dependencies.fetchImpl ?? fetch)(`${access5.apiBaseUrl}${
|
|
25514
|
+
const response = await (dependencies.fetchImpl ?? fetch)(`${access5.apiBaseUrl}${path63}`, {
|
|
25421
25515
|
...init,
|
|
25422
25516
|
headers
|
|
25423
25517
|
});
|
|
@@ -25586,11 +25680,11 @@ async function uploadCommunityAttachment(action, dependencies) {
|
|
|
25586
25680
|
)
|
|
25587
25681
|
);
|
|
25588
25682
|
}
|
|
25589
|
-
function post(
|
|
25590
|
-
return jsonRequest(
|
|
25683
|
+
function post(path63, body) {
|
|
25684
|
+
return jsonRequest(path63, "POST", body);
|
|
25591
25685
|
}
|
|
25592
|
-
function jsonRequest(
|
|
25593
|
-
return { path:
|
|
25686
|
+
function jsonRequest(path63, method, body) {
|
|
25687
|
+
return { path: path63, init: { method, body: JSON.stringify(body) } };
|
|
25594
25688
|
}
|
|
25595
25689
|
|
|
25596
25690
|
// ../server/src/api/routes/community-routes.ts
|
|
@@ -25962,13 +26056,13 @@ function verifySignedWorkspaceImageRequest(requestUrl, token) {
|
|
|
25962
26056
|
if (!appId || !rawPath || !expiresRaw || !signature) {
|
|
25963
26057
|
return { ok: false, status: 401, error: "Signed asset URL is missing required claims." };
|
|
25964
26058
|
}
|
|
25965
|
-
const
|
|
26059
|
+
const path63 = normalizeSignedWorkspaceImagePath(rawPath);
|
|
25966
26060
|
const expiresAt = Number(expiresRaw);
|
|
25967
|
-
if (!
|
|
26061
|
+
if (!path63 || !Number.isInteger(expiresAt)) {
|
|
25968
26062
|
return { ok: false, status: 401, error: "Signed asset URL is invalid." };
|
|
25969
26063
|
}
|
|
25970
26064
|
if (expiresAt < Date.now()) return { ok: false, status: 401, error: "Signed asset URL expired." };
|
|
25971
|
-
const claims = { appId: appId.trim(), path:
|
|
26065
|
+
const claims = { appId: appId.trim(), path: path63, expiresAt };
|
|
25972
26066
|
if (!safeSignatureEqual(signature, signWorkspaceImageClaims(claims, token))) {
|
|
25973
26067
|
return { ok: false, status: 401, error: "Signed asset URL signature is invalid." };
|
|
25974
26068
|
}
|
|
@@ -26062,9 +26156,9 @@ function requiredSearchParam(requestUrl, name) {
|
|
|
26062
26156
|
}
|
|
26063
26157
|
function normalizeSignedWorkspaceImagePath(value) {
|
|
26064
26158
|
if (/^file:\/\//i.test(value) || /^\//.test(value) || /^[A-Za-z]:[\\/]/.test(value)) return null;
|
|
26065
|
-
const
|
|
26066
|
-
if (!
|
|
26067
|
-
return
|
|
26159
|
+
const path63 = normalizeWorkspaceFilePath(value);
|
|
26160
|
+
if (!path63 || !workspaceImageContentType(path63)) return null;
|
|
26161
|
+
return path63;
|
|
26068
26162
|
}
|
|
26069
26163
|
function normalizeSignedLocalImagePath(value) {
|
|
26070
26164
|
const cleaned = normalizeSignedLocalAssetPath(value);
|
|
@@ -31602,7 +31696,7 @@ async function captureSandboxSourceReadbackArtifact(input) {
|
|
|
31602
31696
|
0,
|
|
31603
31697
|
patchPaths.length - SANDBOX_SOURCE_READBACK_MAX_FILES
|
|
31604
31698
|
);
|
|
31605
|
-
for (const
|
|
31699
|
+
for (const path63 of patchPaths.slice(0, SANDBOX_SOURCE_READBACK_MAX_FILES)) {
|
|
31606
31700
|
const remainingBytes = SANDBOX_SOURCE_READBACK_MAX_TOTAL_BYTES - totalReturnedBytes;
|
|
31607
31701
|
if (remainingBytes <= 0) {
|
|
31608
31702
|
skippedFiles += 1;
|
|
@@ -31617,7 +31711,7 @@ async function captureSandboxSourceReadbackArtifact(input) {
|
|
|
31617
31711
|
await sandboxRequestPayload({
|
|
31618
31712
|
type: "download_file",
|
|
31619
31713
|
sandboxId: input.sandboxId,
|
|
31620
|
-
payload: { path:
|
|
31714
|
+
payload: { path: path63, maxBytes }
|
|
31621
31715
|
})
|
|
31622
31716
|
);
|
|
31623
31717
|
const file = asRecord9(downloadPayload.file);
|
|
@@ -31625,7 +31719,7 @@ async function captureSandboxSourceReadbackArtifact(input) {
|
|
|
31625
31719
|
const returnedBytes = numberValue3(file.returnedBytes);
|
|
31626
31720
|
const sizeBytes = numberValue3(file.totalSizeBytes) ?? numberValue3(file.sizeBytes);
|
|
31627
31721
|
const entry = {
|
|
31628
|
-
path:
|
|
31722
|
+
path: path63,
|
|
31629
31723
|
sizeBytes,
|
|
31630
31724
|
returnedBytes,
|
|
31631
31725
|
isBinary,
|
|
@@ -31644,7 +31738,7 @@ async function captureSandboxSourceReadbackArtifact(input) {
|
|
|
31644
31738
|
files.push(entry);
|
|
31645
31739
|
} catch (error) {
|
|
31646
31740
|
files.push({
|
|
31647
|
-
path:
|
|
31741
|
+
path: path63,
|
|
31648
31742
|
sizeBytes: null,
|
|
31649
31743
|
returnedBytes: null,
|
|
31650
31744
|
isBinary: false,
|
|
@@ -31846,10 +31940,10 @@ ${message2}` : message2;
|
|
|
31846
31940
|
const file = asRecord9(payload.file);
|
|
31847
31941
|
const contentsBase64 = typeof file.contentsBase64 === "string" ? file.contentsBase64 : "";
|
|
31848
31942
|
const text3 = contentsBase64 ? Buffer11.from(contentsBase64, "base64").toString("utf8") : "";
|
|
31849
|
-
const
|
|
31850
|
-
return text3 ? `${
|
|
31943
|
+
const path63 = typeof file.path === "string" ? file.path : "file";
|
|
31944
|
+
return text3 ? `${path63}
|
|
31851
31945
|
|
|
31852
|
-
${text3}` : `Read ${
|
|
31946
|
+
${text3}` : `Read ${path63}`;
|
|
31853
31947
|
}
|
|
31854
31948
|
if (action === "sandbox_exec") {
|
|
31855
31949
|
const command = asRecord9(payload.command);
|
|
@@ -31886,31 +31980,31 @@ ${output}` : `Action ${actionName} ${status}`;
|
|
|
31886
31980
|
}
|
|
31887
31981
|
if (action === "sandbox_upload_file") {
|
|
31888
31982
|
const file = asRecord9(payload.file);
|
|
31889
|
-
const
|
|
31890
|
-
return appendPreservation(`Uploaded ${
|
|
31983
|
+
const path63 = typeof file.path === "string" ? file.path : "file";
|
|
31984
|
+
return appendPreservation(`Uploaded ${path63}.`);
|
|
31891
31985
|
}
|
|
31892
31986
|
if (action === "sandbox_write_file") {
|
|
31893
31987
|
const file = asRecord9(payload.file);
|
|
31894
|
-
const
|
|
31895
|
-
return appendPreservation(`Wrote ${
|
|
31988
|
+
const path63 = typeof file.path === "string" ? file.path : "file";
|
|
31989
|
+
return appendPreservation(`Wrote ${path63}.`);
|
|
31896
31990
|
}
|
|
31897
31991
|
if (action === "sandbox_edit_file") {
|
|
31898
31992
|
const edit = asRecord9(payload.edit);
|
|
31899
|
-
const
|
|
31993
|
+
const path63 = typeof edit.path === "string" ? edit.path : "file";
|
|
31900
31994
|
const replacements = typeof edit.replacements === "number" ? edit.replacements : 0;
|
|
31901
31995
|
return appendPreservation(
|
|
31902
|
-
`Edited ${
|
|
31996
|
+
`Edited ${path63} with ${replacements} replacement${replacements === 1 ? "" : "s"}.`
|
|
31903
31997
|
);
|
|
31904
31998
|
}
|
|
31905
31999
|
if (action === "sandbox_delete_file") {
|
|
31906
32000
|
const deleted = asRecord9(payload.deleted);
|
|
31907
|
-
const
|
|
31908
|
-
return appendPreservation(`Deleted ${
|
|
32001
|
+
const path63 = typeof deleted.path === "string" ? deleted.path : "file";
|
|
32002
|
+
return appendPreservation(`Deleted ${path63}.`);
|
|
31909
32003
|
}
|
|
31910
32004
|
if (action === "sandbox_mkdir") {
|
|
31911
32005
|
const directory = asRecord9(payload.directory);
|
|
31912
|
-
const
|
|
31913
|
-
return appendPreservation(`Created directory ${
|
|
32006
|
+
const path63 = typeof directory.path === "string" ? directory.path : "directory";
|
|
32007
|
+
return appendPreservation(`Created directory ${path63}.`);
|
|
31914
32008
|
}
|
|
31915
32009
|
if (action === "sandbox_move_file") {
|
|
31916
32010
|
const moved = asRecord9(payload.moved);
|
|
@@ -36120,7 +36214,7 @@ async function openTailscaleApp() {
|
|
|
36120
36214
|
|
|
36121
36215
|
// ../server/src/voice-transcription.ts
|
|
36122
36216
|
import { Buffer as Buffer12 } from "node:buffer";
|
|
36123
|
-
import { spawn as spawn5 } from "node:child_process";
|
|
36217
|
+
import { execFile as execFile6, spawn as spawn5 } from "node:child_process";
|
|
36124
36218
|
import { constants as fsConstants, promises as fs20 } from "node:fs";
|
|
36125
36219
|
import os7 from "node:os";
|
|
36126
36220
|
import path36 from "node:path";
|
|
@@ -36131,17 +36225,23 @@ var TRANSCRIPTION_TIMEOUT_MS = 12e4;
|
|
|
36131
36225
|
var MODEL_MIN_BYTES = 10 * 1024 * 1024;
|
|
36132
36226
|
var MODEL_MAX_BYTES = 2 * 1024 * 1024 * 1024;
|
|
36133
36227
|
var PROCESS_OUTPUT_MAX_CHARS = 64 * 1024;
|
|
36228
|
+
var WHISPER_CPP_VERSION = "v1.9.2";
|
|
36229
|
+
var WHISPER_CPP_RELEASE_BASE = `https://github.com/ggml-org/whisper.cpp/releases/download/${WHISPER_CPP_VERSION}`;
|
|
36230
|
+
var BINARY_DIR_NAME = "voice-binaries";
|
|
36231
|
+
var BINARY_MIN_BYTES = 5e5;
|
|
36232
|
+
var BINARY_MAX_BYTES = 1e8;
|
|
36134
36233
|
function createVoiceTranscriptionService(input) {
|
|
36135
36234
|
const modelName = normalizedModelName(process.env.OPENPOND_WHISPER_MODEL_NAME);
|
|
36136
36235
|
const modelPath = process.env.OPENPOND_WHISPER_MODEL?.trim() || path36.join(input.storeDir, "voice-models", `ggml-${modelName}.bin`);
|
|
36137
36236
|
let modelDownload = null;
|
|
36237
|
+
let binaryDownload = null;
|
|
36138
36238
|
const closeController = new AbortController();
|
|
36139
36239
|
const activeProcesses = /* @__PURE__ */ new Set();
|
|
36140
36240
|
const activeTranscriptions = /* @__PURE__ */ new Set();
|
|
36141
36241
|
let closing = false;
|
|
36142
36242
|
let closePromise = null;
|
|
36143
36243
|
async function status() {
|
|
36144
|
-
const binaryPath = await
|
|
36244
|
+
const binaryPath = await ensureBinary();
|
|
36145
36245
|
const modelReady = await fileExists4(modelPath);
|
|
36146
36246
|
return {
|
|
36147
36247
|
available: Boolean(binaryPath && (modelReady || canDownloadDefaultModel())),
|
|
@@ -36153,6 +36253,30 @@ function createVoiceTranscriptionService(input) {
|
|
|
36153
36253
|
installHint: binaryPath ? null : whisperInstallHint()
|
|
36154
36254
|
};
|
|
36155
36255
|
}
|
|
36256
|
+
async function ensureBinary() {
|
|
36257
|
+
const resolved = await resolveWhisperBinary();
|
|
36258
|
+
if (resolved) return resolved;
|
|
36259
|
+
const assetInfo = getPlatformAssetInfo();
|
|
36260
|
+
if (!assetInfo) return null;
|
|
36261
|
+
const binaryDir = path36.join(input.storeDir, BINARY_DIR_NAME);
|
|
36262
|
+
const binaryPath = path36.join(binaryDir, "whisper-cli");
|
|
36263
|
+
if (await fileExists4(binaryPath)) {
|
|
36264
|
+
const isExec = await executableExists2(binaryPath);
|
|
36265
|
+
if (isExec) return binaryPath;
|
|
36266
|
+
}
|
|
36267
|
+
if (!binaryDownload) {
|
|
36268
|
+
binaryDownload = downloadAndExtractWhisperBinary(
|
|
36269
|
+
binaryDir,
|
|
36270
|
+
binaryPath,
|
|
36271
|
+
assetInfo,
|
|
36272
|
+
input.logger,
|
|
36273
|
+
closeController.signal
|
|
36274
|
+
).finally(() => {
|
|
36275
|
+
binaryDownload = null;
|
|
36276
|
+
});
|
|
36277
|
+
}
|
|
36278
|
+
return binaryDownload;
|
|
36279
|
+
}
|
|
36156
36280
|
async function ensureModel() {
|
|
36157
36281
|
if (await fileExists4(modelPath)) return modelPath;
|
|
36158
36282
|
if (process.env.OPENPOND_WHISPER_MODEL?.trim()) {
|
|
@@ -36182,7 +36306,7 @@ function createVoiceTranscriptionService(input) {
|
|
|
36182
36306
|
}
|
|
36183
36307
|
async function runTranscription(payload) {
|
|
36184
36308
|
const request = parseVoiceTranscriptionRequest(payload);
|
|
36185
|
-
const binaryPath = await
|
|
36309
|
+
const binaryPath = await ensureBinary();
|
|
36186
36310
|
if (!binaryPath) throw new Error(whisperInstallHint());
|
|
36187
36311
|
const audio = Buffer12.from(request.audioBase64, "base64");
|
|
36188
36312
|
if (audio.byteLength === 0) throw new Error("No voice audio was recorded.");
|
|
@@ -36229,7 +36353,7 @@ function createVoiceTranscriptionService(input) {
|
|
|
36229
36353
|
closing = true;
|
|
36230
36354
|
closeController.abort();
|
|
36231
36355
|
for (const child of activeProcesses) stopVoiceProcess(child);
|
|
36232
|
-
closePromise = Promise.allSettled([...activeTranscriptions, ...modelDownload ? [modelDownload] : []]).then(() => {
|
|
36356
|
+
closePromise = Promise.allSettled([...activeTranscriptions, ...modelDownload ? [modelDownload] : [], ...binaryDownload ? [binaryDownload] : []]).then(() => {
|
|
36233
36357
|
if (activeProcesses.size > 0) {
|
|
36234
36358
|
throw new Error(`Voice transcription leaked ${activeProcesses.size} process(es).`);
|
|
36235
36359
|
}
|
|
@@ -36274,7 +36398,14 @@ async function runWhisper(input) {
|
|
|
36274
36398
|
reject(new Error("Voice transcription service is closed."));
|
|
36275
36399
|
return;
|
|
36276
36400
|
}
|
|
36277
|
-
const child = spawn5(input.binaryPath, args, {
|
|
36401
|
+
const child = spawn5(input.binaryPath, args, {
|
|
36402
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
36403
|
+
env: {
|
|
36404
|
+
...process.env,
|
|
36405
|
+
// Ensure whisper-cli can find shared libraries bundled alongside it
|
|
36406
|
+
LD_LIBRARY_PATH: [path36.dirname(input.binaryPath), process.env.LD_LIBRARY_PATH].filter(Boolean).join(":")
|
|
36407
|
+
}
|
|
36408
|
+
});
|
|
36278
36409
|
input.activeProcesses.add(child);
|
|
36279
36410
|
let stderr = "";
|
|
36280
36411
|
let stdout = "";
|
|
@@ -36447,13 +36578,158 @@ async function fileExists4(filePath) {
|
|
|
36447
36578
|
}
|
|
36448
36579
|
}
|
|
36449
36580
|
function whisperInstallHint() {
|
|
36581
|
+
if (process.platform === "darwin" || process.platform === "linux") {
|
|
36582
|
+
return "Could not auto-download whisper.cpp. Install it manually (e.g. `brew install whisper-cpp` on macOS or build from github.com/ggml-org/whisper.cpp), or set OPENPOND_WHISPER_CPP_BIN to the binary path.";
|
|
36583
|
+
}
|
|
36584
|
+
return "Local dictation requires whisper.cpp on macOS or Linux.";
|
|
36585
|
+
}
|
|
36586
|
+
function getPlatformAssetInfo() {
|
|
36450
36587
|
if (process.platform === "darwin") {
|
|
36451
|
-
return
|
|
36588
|
+
return { assetName: "whisper-bin-x64.zip", archiveType: "zip" };
|
|
36452
36589
|
}
|
|
36453
36590
|
if (process.platform === "linux") {
|
|
36454
|
-
|
|
36591
|
+
if (process.arch === "arm64") {
|
|
36592
|
+
return { assetName: "whisper-bin-ubuntu-arm64.tar.gz", archiveType: "tar.gz" };
|
|
36593
|
+
}
|
|
36594
|
+
if (process.arch === "x64") {
|
|
36595
|
+
return { assetName: "whisper-bin-ubuntu-x64.tar.gz", archiveType: "tar.gz" };
|
|
36596
|
+
}
|
|
36597
|
+
}
|
|
36598
|
+
return null;
|
|
36599
|
+
}
|
|
36600
|
+
async function downloadAndExtractWhisperBinary(binaryDir, finalBinaryPath, assetInfo, logger, signal) {
|
|
36601
|
+
const url = `${WHISPER_CPP_RELEASE_BASE}/${assetInfo.assetName}`;
|
|
36602
|
+
await fs20.mkdir(binaryDir, { recursive: true });
|
|
36603
|
+
const tempArchive = path36.join(binaryDir, `whisper-archive.${process.pid}.${Date.now()}.tmp`);
|
|
36604
|
+
const extractDir = path36.join(binaryDir, `extract-${process.pid}-${Date.now()}`);
|
|
36605
|
+
logger.info("downloading whisper binary", { url, targetDir: binaryDir });
|
|
36606
|
+
try {
|
|
36607
|
+
const response = await fetch(url, { signal, redirect: "follow" });
|
|
36608
|
+
if (!response.ok || !response.body) {
|
|
36609
|
+
throw new Error(`Unable to download whisper binary: ${response.status} ${response.statusText}`.trim());
|
|
36610
|
+
}
|
|
36611
|
+
const sizeBytes = await streamBinaryResponseToFile({
|
|
36612
|
+
response,
|
|
36613
|
+
targetPath: tempArchive,
|
|
36614
|
+
signal,
|
|
36615
|
+
minBytes: BINARY_MIN_BYTES,
|
|
36616
|
+
maxBytes: BINARY_MAX_BYTES
|
|
36617
|
+
});
|
|
36618
|
+
logger.info("whisper binary downloaded", { sizeBytes, extracting: true });
|
|
36619
|
+
await fs20.mkdir(extractDir, { recursive: true });
|
|
36620
|
+
if (assetInfo.archiveType === "tar.gz") {
|
|
36621
|
+
await runExtractionCommand("tar", ["xzf", tempArchive, "-C", extractDir], signal);
|
|
36622
|
+
} else {
|
|
36623
|
+
await runExtractionCommand("unzip", ["-o", tempArchive, "-d", extractDir], signal);
|
|
36624
|
+
}
|
|
36625
|
+
const foundBinary = await findWhisperBinaryInDirectory(extractDir);
|
|
36626
|
+
if (!foundBinary) {
|
|
36627
|
+
throw new Error("whisper-cli binary not found in downloaded archive.");
|
|
36628
|
+
}
|
|
36629
|
+
const binaryParentDir = path36.dirname(foundBinary);
|
|
36630
|
+
await fs20.mkdir(binaryDir, { recursive: true });
|
|
36631
|
+
await moveAllFiles(binaryParentDir, binaryDir);
|
|
36632
|
+
await fs20.chmod(finalBinaryPath, 493).catch(() => void 0);
|
|
36633
|
+
logger.info("whisper binary installed", { binaryPath: finalBinaryPath });
|
|
36634
|
+
return finalBinaryPath;
|
|
36635
|
+
} finally {
|
|
36636
|
+
await Promise.all([
|
|
36637
|
+
fs20.rm(tempArchive, { force: true }),
|
|
36638
|
+
fs20.rm(extractDir, { force: true, recursive: true })
|
|
36639
|
+
]);
|
|
36640
|
+
}
|
|
36641
|
+
}
|
|
36642
|
+
async function streamBinaryResponseToFile(input) {
|
|
36643
|
+
const declaredBytes = Number(input.response.headers.get("content-length"));
|
|
36644
|
+
if (Number.isFinite(declaredBytes) && declaredBytes > input.maxBytes) {
|
|
36645
|
+
throw new Error("Whisper binary download exceeds the configured byte limit.");
|
|
36646
|
+
}
|
|
36647
|
+
const reader = input.response.body?.getReader();
|
|
36648
|
+
if (!reader) throw new Error("Whisper binary download did not return a response body.");
|
|
36649
|
+
const file = await fs20.open(input.targetPath, "wx", 384);
|
|
36650
|
+
let sizeBytes = 0;
|
|
36651
|
+
try {
|
|
36652
|
+
try {
|
|
36653
|
+
while (true) {
|
|
36654
|
+
if (input.signal.aborted) throw new Error("Whisper binary download was cancelled.");
|
|
36655
|
+
const { done, value } = await reader.read();
|
|
36656
|
+
if (done) break;
|
|
36657
|
+
sizeBytes += value.byteLength;
|
|
36658
|
+
if (sizeBytes > input.maxBytes) {
|
|
36659
|
+
throw new Error("Whisper binary download exceeds the configured byte limit.");
|
|
36660
|
+
}
|
|
36661
|
+
await file.write(value);
|
|
36662
|
+
}
|
|
36663
|
+
} catch (error) {
|
|
36664
|
+
await reader.cancel().catch(() => void 0);
|
|
36665
|
+
throw error;
|
|
36666
|
+
} finally {
|
|
36667
|
+
await file.close();
|
|
36668
|
+
}
|
|
36669
|
+
} catch (error) {
|
|
36670
|
+
await fs20.rm(input.targetPath, { force: true });
|
|
36671
|
+
throw error;
|
|
36672
|
+
}
|
|
36673
|
+
if (sizeBytes < input.minBytes) {
|
|
36674
|
+
await fs20.rm(input.targetPath, { force: true });
|
|
36675
|
+
throw new Error("Downloaded whisper binary is incomplete.");
|
|
36676
|
+
}
|
|
36677
|
+
await fs20.chmod(input.targetPath, 384).catch(() => void 0);
|
|
36678
|
+
return sizeBytes;
|
|
36679
|
+
}
|
|
36680
|
+
async function runExtractionCommand(command, args, signal) {
|
|
36681
|
+
await new Promise((resolve, reject) => {
|
|
36682
|
+
if (signal.aborted) {
|
|
36683
|
+
reject(new Error("Whisper binary extraction was cancelled."));
|
|
36684
|
+
return;
|
|
36685
|
+
}
|
|
36686
|
+
const child = execFile6(command, args, { signal, maxBuffer: 10 * 1024 * 1024 }, (error) => {
|
|
36687
|
+
if (error) {
|
|
36688
|
+
reject(new Error(`Whisper binary extraction failed: ${error.message}`));
|
|
36689
|
+
return;
|
|
36690
|
+
}
|
|
36691
|
+
resolve();
|
|
36692
|
+
});
|
|
36693
|
+
if (child.exitCode === null && child.signalCode === null && signal.aborted) {
|
|
36694
|
+
child.kill("SIGTERM");
|
|
36695
|
+
}
|
|
36696
|
+
});
|
|
36697
|
+
}
|
|
36698
|
+
async function findWhisperBinaryInDirectory(directory) {
|
|
36699
|
+
const entries = await fs20.readdir(directory, { withFileTypes: true });
|
|
36700
|
+
for (const entry of entries) {
|
|
36701
|
+
const fullPath = path36.join(directory, entry.name);
|
|
36702
|
+
if (entry.isDirectory()) {
|
|
36703
|
+
const found = await findWhisperBinaryInDirectory(fullPath);
|
|
36704
|
+
if (found) return found;
|
|
36705
|
+
} else if (entry.isFile() && (entry.name === "whisper-cli" || entry.name === "whisper-cpp")) {
|
|
36706
|
+
if (await executableExists2(fullPath)) return fullPath;
|
|
36707
|
+
}
|
|
36708
|
+
}
|
|
36709
|
+
return null;
|
|
36710
|
+
}
|
|
36711
|
+
async function moveAllFiles(srcDir, destDir) {
|
|
36712
|
+
const entries = await fs20.readdir(srcDir, { withFileTypes: true });
|
|
36713
|
+
for (const entry of entries) {
|
|
36714
|
+
const srcPath = path36.join(srcDir, entry.name);
|
|
36715
|
+
const destPath = path36.join(destDir, entry.name);
|
|
36716
|
+
if (entry.isSymbolicLink()) {
|
|
36717
|
+
const linkTarget = await fs20.readlink(srcPath);
|
|
36718
|
+
await fs20.symlink(linkTarget, destPath).catch(() => void 0);
|
|
36719
|
+
await fs20.rm(srcPath, { force: true }).catch(() => void 0);
|
|
36720
|
+
} else if (entry.isDirectory()) {
|
|
36721
|
+
await fs20.mkdir(destPath, { recursive: true });
|
|
36722
|
+
await moveAllFiles(srcPath, destPath);
|
|
36723
|
+
await fs20.rmdir(srcPath).catch(() => void 0);
|
|
36724
|
+
} else if (entry.isFile()) {
|
|
36725
|
+
await fs20.rename(srcPath, destPath);
|
|
36726
|
+
if (entry.name === "whisper-cli" || entry.name === "whisper-cpp") {
|
|
36727
|
+
await fs20.chmod(destPath, 493).catch(() => void 0);
|
|
36728
|
+
} else if (entry.name.endsWith(".so") || entry.name.includes(".so.")) {
|
|
36729
|
+
await fs20.chmod(destPath, 493).catch(() => void 0);
|
|
36730
|
+
}
|
|
36731
|
+
}
|
|
36455
36732
|
}
|
|
36456
|
-
return "Local dictation requires whisper.cpp on macOS or Linux.";
|
|
36457
36733
|
}
|
|
36458
36734
|
|
|
36459
36735
|
// ../server/src/openpond/browser-control-queue.ts
|
|
@@ -36705,7 +36981,7 @@ function headerValue2(value) {
|
|
|
36705
36981
|
|
|
36706
36982
|
// ../server/src/agents/local-agent-scheduler.ts
|
|
36707
36983
|
var import_cron_parser = __toESM(require_dist(), 1);
|
|
36708
|
-
import { execFile as
|
|
36984
|
+
import { execFile as execFile7 } from "node:child_process";
|
|
36709
36985
|
import { randomUUID as randomUUID14 } from "node:crypto";
|
|
36710
36986
|
import { promises as fs21 } from "node:fs";
|
|
36711
36987
|
import path37 from "node:path";
|
|
@@ -36764,7 +37040,7 @@ function trimOutput2(value) {
|
|
|
36764
37040
|
}
|
|
36765
37041
|
|
|
36766
37042
|
// ../server/src/agents/local-agent-scheduler.ts
|
|
36767
|
-
var execFileAsync4 = promisify4(
|
|
37043
|
+
var execFileAsync4 = promisify4(execFile7);
|
|
36768
37044
|
var DEFAULT_TICK_MS = 15e3;
|
|
36769
37045
|
var DEFAULT_RECONCILE_MS = 6e4;
|
|
36770
37046
|
var INSPECT_TIMEOUT_MS = 6e4;
|
|
@@ -37530,11 +37806,11 @@ async function teamChatRequestPayload(action, dependencies = {}) {
|
|
|
37530
37806
|
const payload = await requestTeamChatApi(request.path, request.init, dependencies);
|
|
37531
37807
|
return schemaForAction2(action).parse(payload);
|
|
37532
37808
|
}
|
|
37533
|
-
async function requestTeamChatApi(
|
|
37809
|
+
async function requestTeamChatApi(path63, init = {}, dependencies = {}) {
|
|
37534
37810
|
const access5 = await resolveHostedApiAccess(dependencies);
|
|
37535
37811
|
const headers = hostedApiAuthHeaders(access5.token);
|
|
37536
37812
|
headers.set("Content-Type", "application/json");
|
|
37537
|
-
const response = await (dependencies.fetchImpl ?? fetch)(`${access5.apiBaseUrl}${
|
|
37813
|
+
const response = await (dependencies.fetchImpl ?? fetch)(`${access5.apiBaseUrl}${path63}`, {
|
|
37538
37814
|
...init,
|
|
37539
37815
|
headers
|
|
37540
37816
|
});
|
|
@@ -37766,11 +38042,11 @@ async function uploadTeamChatAttachment(action, dependencies) {
|
|
|
37766
38042
|
)
|
|
37767
38043
|
);
|
|
37768
38044
|
}
|
|
37769
|
-
function post2(
|
|
37770
|
-
return jsonRequest2(
|
|
38045
|
+
function post2(path63, body) {
|
|
38046
|
+
return jsonRequest2(path63, "POST", body);
|
|
37771
38047
|
}
|
|
37772
|
-
function jsonRequest2(
|
|
37773
|
-
return { path:
|
|
38048
|
+
function jsonRequest2(path63, method, body) {
|
|
38049
|
+
return { path: path63, init: { method, body: JSON.stringify(body) } };
|
|
37774
38050
|
}
|
|
37775
38051
|
|
|
37776
38052
|
// ../server/src/openpond/team-chat-executor.ts
|
|
@@ -40839,25 +41115,25 @@ var ManagedRlLocalRolloutExecutor = class {
|
|
|
40839
41115
|
}
|
|
40840
41116
|
throw lastError;
|
|
40841
41117
|
}
|
|
40842
|
-
async userRequest(
|
|
41118
|
+
async userRequest(path63, init) {
|
|
40843
41119
|
const headers = hostedApiAuthHeaders(this.input.access.token);
|
|
40844
41120
|
headers.set("accept", "application/json");
|
|
40845
41121
|
headers.set("content-type", "application/json");
|
|
40846
41122
|
headers.set("x-openpond-team-id", this.input.access.teamId);
|
|
40847
|
-
const requestUrl = `${this.input.access.apiBaseUrl}${
|
|
41123
|
+
const requestUrl = `${this.input.access.apiBaseUrl}${path63}`;
|
|
40848
41124
|
return requestJson(this.input.fetchImpl ?? fetch, requestUrl, {
|
|
40849
41125
|
...init,
|
|
40850
41126
|
headers: withVercelProtectionBypass(requestUrl, headers, this.input.env),
|
|
40851
41127
|
signal: this.abortController.signal
|
|
40852
41128
|
});
|
|
40853
41129
|
}
|
|
40854
|
-
policyRequest(
|
|
41130
|
+
policyRequest(path63, token, request, signal = this.abortController.signal) {
|
|
40855
41131
|
const headers = new Headers({
|
|
40856
41132
|
accept: "application/json",
|
|
40857
41133
|
authorization: `Bearer ${token}`,
|
|
40858
41134
|
"content-type": "application/json"
|
|
40859
41135
|
});
|
|
40860
|
-
const requestUrl = `${this.input.access.apiBaseUrl}${
|
|
41136
|
+
const requestUrl = `${this.input.access.apiBaseUrl}${path63}`;
|
|
40861
41137
|
return requestJson(
|
|
40862
41138
|
this.input.fetchImpl ?? fetch,
|
|
40863
41139
|
requestUrl,
|
|
@@ -41065,7 +41341,7 @@ function managedRunEvidence(detail, syncedAt) {
|
|
|
41065
41341
|
);
|
|
41066
41342
|
const finalGroup = [...detail.rolloutGroups].filter((group) => group.rewardMean != null).sort((left, right) => left.groupIndex - right.groupIndex).at(-1);
|
|
41067
41343
|
const lease = [...detail.gpuLeases].sort((left, right) => left.id.localeCompare(right.id)).at(-1);
|
|
41068
|
-
const
|
|
41344
|
+
const checkpoint2 = [...detail.checkpoints].filter((candidate2) => candidate2.state === "ready").sort(
|
|
41069
41345
|
(left, right) => Number(right.isFinal) - Number(left.isFinal) || Number(right.isLatest) - Number(left.isLatest) || right.policyVersion - left.policyVersion
|
|
41070
41346
|
).at(0);
|
|
41071
41347
|
return ManagedTrainingRunEvidenceSchema.parse({
|
|
@@ -41102,11 +41378,11 @@ function managedRunEvidence(detail, syncedAt) {
|
|
|
41102
41378
|
cost: {
|
|
41103
41379
|
totalUsd: decimal(detail.job.accruedSpendUsd)
|
|
41104
41380
|
},
|
|
41105
|
-
checkpoint:
|
|
41106
|
-
id:
|
|
41107
|
-
policyVersion:
|
|
41108
|
-
sha256:
|
|
41109
|
-
sizeBytes:
|
|
41381
|
+
checkpoint: checkpoint2 ? {
|
|
41382
|
+
id: checkpoint2.id,
|
|
41383
|
+
policyVersion: checkpoint2.policyVersion,
|
|
41384
|
+
sha256: checkpoint2.adapterSha256 ?? null,
|
|
41385
|
+
sizeBytes: checkpoint2.sizeBytes ?? null
|
|
41110
41386
|
} : null,
|
|
41111
41387
|
evaluations: detail.evaluations.map((evaluation) => ({
|
|
41112
41388
|
kind: evaluation.kind,
|
|
@@ -41211,19 +41487,19 @@ function managedTrainingEvents(input) {
|
|
|
41211
41487
|
}
|
|
41212
41488
|
});
|
|
41213
41489
|
}
|
|
41214
|
-
for (const
|
|
41490
|
+
for (const checkpoint2 of input.detail.checkpoints.filter(
|
|
41215
41491
|
(candidate2) => candidate2.state === "ready"
|
|
41216
41492
|
)) {
|
|
41217
41493
|
candidates.push({
|
|
41218
|
-
identity: `checkpoint:${
|
|
41219
|
-
timestamp:
|
|
41494
|
+
identity: `checkpoint:${checkpoint2.id}`,
|
|
41495
|
+
timestamp: checkpoint2.readyAt ?? checkpoint2.updatedAt,
|
|
41220
41496
|
type: "checkpoint",
|
|
41221
41497
|
payload: {
|
|
41222
|
-
checkpointId:
|
|
41223
|
-
policyVersion:
|
|
41224
|
-
sha256:
|
|
41225
|
-
sizeBytes:
|
|
41226
|
-
final:
|
|
41498
|
+
checkpointId: checkpoint2.id,
|
|
41499
|
+
policyVersion: checkpoint2.policyVersion,
|
|
41500
|
+
sha256: checkpoint2.adapterSha256 ?? null,
|
|
41501
|
+
sizeBytes: checkpoint2.sizeBytes ?? null,
|
|
41502
|
+
final: checkpoint2.isFinal
|
|
41227
41503
|
}
|
|
41228
41504
|
});
|
|
41229
41505
|
}
|
|
@@ -41237,7 +41513,7 @@ function managedTrainingEvents(input) {
|
|
|
41237
41513
|
payload: {
|
|
41238
41514
|
state: input.detail.job.state,
|
|
41239
41515
|
artifactCount: input.detail.checkpoints.filter(
|
|
41240
|
-
(
|
|
41516
|
+
(checkpoint2) => checkpoint2.state === "ready"
|
|
41241
41517
|
).length,
|
|
41242
41518
|
optimizerUpdates: input.detail.trainingSteps.filter(
|
|
41243
41519
|
(step) => step.state === "committed"
|
|
@@ -46740,8 +47016,8 @@ ${split.split}`) ?? {
|
|
|
46740
47016
|
inspectedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
46741
47017
|
metadata: {
|
|
46742
47018
|
sourceSchemaHash: contentHash(
|
|
46743
|
-
columns.map(({ path:
|
|
46744
|
-
path:
|
|
47019
|
+
columns.map(({ path: path63, logicalType: logicalType2, nullable }) => ({
|
|
47020
|
+
path: path63,
|
|
46745
47021
|
logicalType: logicalType2,
|
|
46746
47022
|
nullable
|
|
46747
47023
|
}))
|
|
@@ -46790,10 +47066,10 @@ function parquetSourceFile(value, repositoryId, revision) {
|
|
|
46790
47066
|
if (item?.dataset !== repositoryId || typeof item.config !== "string" || typeof item.split !== "string" || typeof item.filename !== "string" || !item.filename.toLowerCase().endsWith(".parquet")) {
|
|
46791
47067
|
return [];
|
|
46792
47068
|
}
|
|
46793
|
-
const
|
|
46794
|
-
if (!
|
|
47069
|
+
const path63 = [item.config, item.split, item.filename].flatMap((segment) => segment.split("/")).map((segment) => segment.trim()).filter(Boolean).join("/");
|
|
47070
|
+
if (!path63 || path63.split("/").includes("..")) return [];
|
|
46795
47071
|
return [{
|
|
46796
|
-
path:
|
|
47072
|
+
path: path63,
|
|
46797
47073
|
configuration: item.config,
|
|
46798
47074
|
split: item.split,
|
|
46799
47075
|
revision,
|
|
@@ -46866,8 +47142,8 @@ function sourceColumns(features, rows) {
|
|
|
46866
47142
|
});
|
|
46867
47143
|
}
|
|
46868
47144
|
}
|
|
46869
|
-
return [...paths.entries()].map(([
|
|
46870
|
-
path:
|
|
47145
|
+
return [...paths.entries()].map(([path63, value]) => ({
|
|
47146
|
+
path: path63,
|
|
46871
47147
|
logicalType: value.type,
|
|
46872
47148
|
nullable: value.nullable,
|
|
46873
47149
|
sampleValues: value.values.slice(0, 5)
|
|
@@ -46885,21 +47161,21 @@ function flattenRecord(value, prefix, paths, rows) {
|
|
|
46885
47161
|
return;
|
|
46886
47162
|
}
|
|
46887
47163
|
for (const [key, child] of Object.entries(value)) {
|
|
46888
|
-
const
|
|
47164
|
+
const path63 = prefix ? `${prefix}.${key}` : key;
|
|
46889
47165
|
if (child && typeof child === "object" && !Array.isArray(child)) {
|
|
46890
|
-
flattenRecord(child,
|
|
47166
|
+
flattenRecord(child, path63, paths, rows);
|
|
46891
47167
|
} else {
|
|
46892
|
-
paths.set(
|
|
47168
|
+
paths.set(path63, {
|
|
46893
47169
|
type: logicalType(child),
|
|
46894
|
-
nullable: rows.some((row) => nestedValue(row,
|
|
46895
|
-
values: rows.map((row) => nestedValue(row,
|
|
47170
|
+
nullable: rows.some((row) => nestedValue(row, path63) == null),
|
|
47171
|
+
values: rows.map((row) => nestedValue(row, path63)).filter((item) => item != null)
|
|
46896
47172
|
});
|
|
46897
47173
|
}
|
|
46898
47174
|
}
|
|
46899
47175
|
}
|
|
46900
|
-
function nestedValue(value,
|
|
47176
|
+
function nestedValue(value, path63) {
|
|
46901
47177
|
let current = value;
|
|
46902
|
-
for (const segment of
|
|
47178
|
+
for (const segment of path63.split(".")) {
|
|
46903
47179
|
const record11 = asRecord15(current);
|
|
46904
47180
|
if (!record11) return null;
|
|
46905
47181
|
current = record11[segment];
|
|
@@ -47225,7 +47501,7 @@ function graderFixtures(taskId, expected, split) {
|
|
|
47225
47501
|
output: fixture.output,
|
|
47226
47502
|
infrastructureError: fixture.infrastructureError,
|
|
47227
47503
|
expectedPassed: fixture.expectedPassed,
|
|
47228
|
-
expectedRewardEligible: fixture.
|
|
47504
|
+
expectedRewardEligible: fixture.label !== "infrastructure_failure",
|
|
47229
47505
|
metadata: {
|
|
47230
47506
|
artifactBacked: true,
|
|
47231
47507
|
artifactSplit: split
|
|
@@ -48089,6 +48365,8 @@ function errorMessage4(error) {
|
|
|
48089
48365
|
}
|
|
48090
48366
|
|
|
48091
48367
|
// ../server/src/training/harness-refiner-benchmark-protocol.ts
|
|
48368
|
+
var HARNESS_REFINER_BENCHMARK_MAX_INVOCATIONS_PER_TASK = 2;
|
|
48369
|
+
var HARNESS_REFINER_BENCHMARK_REFINER_TIMEOUT_MS = 18e4;
|
|
48092
48370
|
function createHarnessRefinerExecutionPlan(input) {
|
|
48093
48371
|
if (input.seeds.length !== 1 || input.repetitions !== 1) {
|
|
48094
48372
|
throw new Error(
|
|
@@ -48101,8 +48379,8 @@ function createHarnessRefinerExecutionPlan(input) {
|
|
|
48101
48379
|
const adaptation = taskIdsForSplit(input.taskset, benchmark.adaptationSplit);
|
|
48102
48380
|
const multiplier = input.seeds.length * input.repetitions;
|
|
48103
48381
|
return [
|
|
48104
|
-
planItem("baseline", benchmark.evaluationSplit, heldOut, multiplier),
|
|
48105
48382
|
planItem("adaptation", benchmark.adaptationSplit, adaptation, multiplier),
|
|
48383
|
+
planItem("baseline", benchmark.evaluationSplit, heldOut, multiplier),
|
|
48106
48384
|
planItem("candidate_adaptation", benchmark.adaptationSplit, adaptation, multiplier),
|
|
48107
48385
|
planItem("candidate", benchmark.evaluationSplit, heldOut, multiplier)
|
|
48108
48386
|
];
|
|
@@ -48291,7 +48569,8 @@ function createResultManifest(input) {
|
|
|
48291
48569
|
evidenceSnapshot: input.evidenceSnapshot,
|
|
48292
48570
|
lineage: input.lineage,
|
|
48293
48571
|
publicationPolicy: {
|
|
48294
|
-
|
|
48572
|
+
primaryReward: "deterministic_output_contract",
|
|
48573
|
+
supplementaryJudge: "not_executed_uncalibrated",
|
|
48295
48574
|
diagnosticPasses: 1,
|
|
48296
48575
|
confirmationPasses: 1,
|
|
48297
48576
|
uncertainty: "paired_per_case_descriptive"
|
|
@@ -48433,7 +48712,9 @@ function completedStage(input) {
|
|
|
48433
48712
|
attempt: result.attempt,
|
|
48434
48713
|
grade: result.grade,
|
|
48435
48714
|
artifacts: result.artifacts,
|
|
48436
|
-
receiptContentHash: result.portable.receipt.contentHash
|
|
48715
|
+
receiptContentHash: result.portable.receipt.contentHash,
|
|
48716
|
+
artifactManifest: result.portable.artifactManifest,
|
|
48717
|
+
rewardReceipt: result.portable.rewardReceipt
|
|
48437
48718
|
}))
|
|
48438
48719
|
};
|
|
48439
48720
|
}
|
|
@@ -48461,7 +48742,9 @@ async function combineRetriedBenchmarkStage(input) {
|
|
|
48461
48742
|
attempt: result.attempt,
|
|
48462
48743
|
grade: result.grade,
|
|
48463
48744
|
artifacts: result.artifacts,
|
|
48464
|
-
receiptContentHash: result.portable.receipt.contentHash
|
|
48745
|
+
receiptContentHash: result.portable.receipt.contentHash,
|
|
48746
|
+
artifactManifest: result.portable.artifactManifest,
|
|
48747
|
+
rewardReceipt: result.portable.rewardReceipt
|
|
48465
48748
|
},
|
|
48466
48749
|
receipt: result.portable.receipt
|
|
48467
48750
|
}
|
|
@@ -48560,7 +48843,8 @@ async function loadCompletedBenchmarkStage(input) {
|
|
|
48560
48843
|
attempt,
|
|
48561
48844
|
grade,
|
|
48562
48845
|
artifacts: await input.store.listTaskAttemptArtifacts({ attemptId: attempt.id }),
|
|
48563
|
-
receiptContentHash: portableReceiptContentHash(attempt)
|
|
48846
|
+
receiptContentHash: portableReceiptContentHash(attempt),
|
|
48847
|
+
...portableCanonicalReceipts(attempt)
|
|
48564
48848
|
};
|
|
48565
48849
|
}));
|
|
48566
48850
|
return { run, attempts: evidence };
|
|
@@ -48577,15 +48861,19 @@ async function loadBenchmarkAttemptEvidenceByIds(input) {
|
|
|
48577
48861
|
`Sequential adaptation evidence has ${selected.length}/${wanted.size} attempts.`
|
|
48578
48862
|
);
|
|
48579
48863
|
}
|
|
48864
|
+
const selectedById = new Map(selected.map((attempt) => [attempt.id, attempt]));
|
|
48580
48865
|
const gradesByAttempt = new Map(grades.map((grade) => [grade.attemptId, grade]));
|
|
48581
|
-
return Promise.all(
|
|
48866
|
+
return Promise.all(input.attemptIds.map(async (attemptId) => {
|
|
48867
|
+
const attempt = selectedById.get(attemptId);
|
|
48868
|
+
if (!attempt) throw new Error(`Sequential adaptation attempt ${attemptId} is unavailable.`);
|
|
48582
48869
|
const grade = gradesByAttempt.get(attempt.id);
|
|
48583
48870
|
if (!grade) throw new Error(`Attempt ${attempt.id} has no durable grade.`);
|
|
48584
48871
|
return {
|
|
48585
48872
|
attempt,
|
|
48586
48873
|
grade,
|
|
48587
48874
|
artifacts: await input.store.listTaskAttemptArtifacts({ attemptId: attempt.id }),
|
|
48588
|
-
receiptContentHash: portableReceiptContentHash(attempt)
|
|
48875
|
+
receiptContentHash: portableReceiptContentHash(attempt),
|
|
48876
|
+
...portableCanonicalReceipts(attempt)
|
|
48589
48877
|
};
|
|
48590
48878
|
}));
|
|
48591
48879
|
}
|
|
@@ -48602,6 +48890,25 @@ function portableReceiptContentHash(attempt) {
|
|
|
48602
48890
|
}
|
|
48603
48891
|
return hash3;
|
|
48604
48892
|
}
|
|
48893
|
+
function portableCanonicalReceipts(attempt) {
|
|
48894
|
+
try {
|
|
48895
|
+
const artifactManifest = ArtifactManifestSchema.parse(
|
|
48896
|
+
attempt.metadata.portableArtifactManifest
|
|
48897
|
+
);
|
|
48898
|
+
const rewardReceipt = RewardReceiptSchema.parse(
|
|
48899
|
+
attempt.metadata.portableRewardReceipt
|
|
48900
|
+
);
|
|
48901
|
+
if (!verifyArtifactManifest(artifactManifest) || !verifyRewardReceipt(rewardReceipt)) {
|
|
48902
|
+
throw new Error("Canonical reward evidence failed content-hash verification.");
|
|
48903
|
+
}
|
|
48904
|
+
return { artifactManifest, rewardReceipt };
|
|
48905
|
+
} catch (error) {
|
|
48906
|
+
throw new Error(
|
|
48907
|
+
`Attempt ${attempt.id} has no valid durable canonical reward evidence.`,
|
|
48908
|
+
{ cause: error }
|
|
48909
|
+
);
|
|
48910
|
+
}
|
|
48911
|
+
}
|
|
48605
48912
|
function objectRecord(value) {
|
|
48606
48913
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
48607
48914
|
}
|
|
@@ -48929,58 +49236,6 @@ function frozenToolEvidence(snapshot, mode, cohort) {
|
|
|
48929
49236
|
}
|
|
48930
49237
|
};
|
|
48931
49238
|
}
|
|
48932
|
-
async function benchmarkLineage(input) {
|
|
48933
|
-
const [outcomes, validations, applyReceipts] = await Promise.all([
|
|
48934
|
-
input.store.listHarnessImprovementArtifacts(
|
|
48935
|
-
input.workspaceId,
|
|
48936
|
-
"refiner_outcome",
|
|
48937
|
-
1e3
|
|
48938
|
-
),
|
|
48939
|
-
input.store.listHarnessImprovementArtifacts(
|
|
48940
|
-
input.workspaceId,
|
|
48941
|
-
"targeted_validation",
|
|
48942
|
-
1e4
|
|
48943
|
-
),
|
|
48944
|
-
input.store.listHarnessImprovementArtifacts(
|
|
48945
|
-
input.workspaceId,
|
|
48946
|
-
"apply_receipt",
|
|
48947
|
-
1e3
|
|
48948
|
-
)
|
|
48949
|
-
]);
|
|
48950
|
-
const adaptationEvidenceHash = contentHash(input.adaptationAttempts.map((result) => ({
|
|
48951
|
-
attempt: result.attempt.id,
|
|
48952
|
-
receipt: result.receiptContentHash,
|
|
48953
|
-
grade: contentHash(result.grade)
|
|
48954
|
-
})));
|
|
48955
|
-
const proposalResults = input.refinerResults.filter((result) => result.proposal);
|
|
48956
|
-
const requiredValidationsPassed = proposalResults.every(
|
|
48957
|
-
(result) => result.proposal.validationPlan.filter((plan) => plan.required).every((plan) => result.validations.some(
|
|
48958
|
-
(validation) => validation.validationId === plan.id && validation.status === "passed"
|
|
48959
|
-
))
|
|
48960
|
-
);
|
|
48961
|
-
const proposalHashes = new Set(
|
|
48962
|
-
proposalResults.map((result) => result.proposal.contentHash)
|
|
48963
|
-
);
|
|
48964
|
-
const appliedProposalHashes = new Set(applyReceipts.flatMap((artifact) => {
|
|
48965
|
-
const proposal = "proposal" in artifact ? artifact.proposal : null;
|
|
48966
|
-
return proposal && typeof proposal === "object" && "contentHash" in proposal ? [String(proposal.contentHash)] : [];
|
|
48967
|
-
}));
|
|
48968
|
-
const everyProposalHasReceipt = [...proposalHashes].every(
|
|
48969
|
-
(hash3) => appliedProposalHashes.has(hash3)
|
|
48970
|
-
);
|
|
48971
|
-
return {
|
|
48972
|
-
adaptationEvidenceHash,
|
|
48973
|
-
refinerInputHash: input.refinerInputHash,
|
|
48974
|
-
refinerOutcomeHash: contentHash(outcomes),
|
|
48975
|
-
validationHash: contentHash(validations),
|
|
48976
|
-
applyReceiptHash: contentHash(applyReceipts),
|
|
48977
|
-
candidateRelease: {
|
|
48978
|
-
id: input.candidateRelease.id,
|
|
48979
|
-
contentHash: input.candidateRelease.contentHash
|
|
48980
|
-
},
|
|
48981
|
-
valid: outcomes.length === input.refinerResults.length && requiredValidationsPassed && everyProposalHasReceipt
|
|
48982
|
-
};
|
|
48983
|
-
}
|
|
48984
49239
|
function comparisonInvalidReasons(input) {
|
|
48985
49240
|
const reasons = [];
|
|
48986
49241
|
for (const [label, run] of [
|
|
@@ -49064,7 +49319,7 @@ async function resumeHarnessRefinerComparison(input) {
|
|
|
49064
49319
|
tasksetId: taskset.id,
|
|
49065
49320
|
attemptIds: sequentialAttemptIds
|
|
49066
49321
|
});
|
|
49067
|
-
if (priorManifest.tasksetRelease.contentHash !==
|
|
49322
|
+
if (priorManifest.tasksetRelease.id !== baseline.run.tasksetRelease.id || priorManifest.tasksetRelease.contentHash !== baseline.run.tasksetRelease.contentHash || priorManifest.harness.baseline.contentHash !== baseline.run.harnessRelease.contentHash) {
|
|
49068
49323
|
throw new Error("Comparison recovery manifest drifted from the admitted benchmark.");
|
|
49069
49324
|
}
|
|
49070
49325
|
const currentReleaseRef = workspace.currentChannel.release;
|
|
@@ -49310,7 +49565,106 @@ async function resumeHarnessRefinerComparison(input) {
|
|
|
49310
49565
|
}));
|
|
49311
49566
|
}
|
|
49312
49567
|
|
|
49568
|
+
// ../server/src/training/harness-refiner-benchmark-lineage.ts
|
|
49569
|
+
async function benchmarkLineage(input) {
|
|
49570
|
+
const [outcomes, rawProposals, rawValidations, applyReceipts] = await Promise.all([
|
|
49571
|
+
input.store.listHarnessImprovementArtifacts(
|
|
49572
|
+
input.workspaceId,
|
|
49573
|
+
"refiner_outcome",
|
|
49574
|
+
1e3
|
|
49575
|
+
),
|
|
49576
|
+
input.store.listHarnessImprovementArtifacts(
|
|
49577
|
+
input.workspaceId,
|
|
49578
|
+
"proposal",
|
|
49579
|
+
1e3
|
|
49580
|
+
),
|
|
49581
|
+
input.store.listHarnessImprovementArtifacts(
|
|
49582
|
+
input.workspaceId,
|
|
49583
|
+
"targeted_validation",
|
|
49584
|
+
1e4
|
|
49585
|
+
),
|
|
49586
|
+
input.store.listHarnessImprovementArtifacts(
|
|
49587
|
+
input.workspaceId,
|
|
49588
|
+
"apply_receipt",
|
|
49589
|
+
1e3
|
|
49590
|
+
)
|
|
49591
|
+
]);
|
|
49592
|
+
const proposals = rawProposals;
|
|
49593
|
+
const validations = rawValidations;
|
|
49594
|
+
const adaptationEvidenceHash = contentHash(input.adaptationAttempts.map((result) => ({
|
|
49595
|
+
attempt: result.attempt.id,
|
|
49596
|
+
receipt: result.receiptContentHash,
|
|
49597
|
+
grade: contentHash(result.grade)
|
|
49598
|
+
})));
|
|
49599
|
+
const requiredValidationsPassed = proposals.every(
|
|
49600
|
+
(proposal) => proposal.validationPlan.filter((plan) => plan.required).every((plan) => validations.some(
|
|
49601
|
+
(validation) => validation.validationId === plan.id && validation.status === "passed"
|
|
49602
|
+
))
|
|
49603
|
+
);
|
|
49604
|
+
const proposalHashes = new Set(
|
|
49605
|
+
proposals.map((proposal) => proposal.contentHash)
|
|
49606
|
+
);
|
|
49607
|
+
const appliedProposalHashes = new Set(applyReceipts.flatMap((artifact) => {
|
|
49608
|
+
const proposal = "proposal" in artifact ? artifact.proposal : null;
|
|
49609
|
+
return proposal && typeof proposal === "object" && "contentHash" in proposal ? [String(proposal.contentHash)] : [];
|
|
49610
|
+
}));
|
|
49611
|
+
const everyProposalHasReceipt = [...proposalHashes].every(
|
|
49612
|
+
(hash3) => appliedProposalHashes.has(hash3)
|
|
49613
|
+
);
|
|
49614
|
+
return {
|
|
49615
|
+
adaptationEvidenceHash,
|
|
49616
|
+
refinerInputHash: input.refinerInputHash,
|
|
49617
|
+
refinerOutcomeHash: contentHash(outcomes),
|
|
49618
|
+
validationHash: contentHash(validations),
|
|
49619
|
+
applyReceiptHash: contentHash(applyReceipts),
|
|
49620
|
+
candidateRelease: {
|
|
49621
|
+
id: input.candidateRelease.id,
|
|
49622
|
+
contentHash: input.candidateRelease.contentHash
|
|
49623
|
+
},
|
|
49624
|
+
valid: outcomes.length === input.completedSteps.filter((step) => step.outcome).length && requiredValidationsPassed && everyProposalHasReceipt
|
|
49625
|
+
};
|
|
49626
|
+
}
|
|
49627
|
+
|
|
49313
49628
|
// ../server/src/training/harness-refiner-benchmark-refiner-stage.ts
|
|
49629
|
+
var MAX_REFINER_ARTIFACT_MANIFEST_ENTRIES = 100;
|
|
49630
|
+
var BenchmarkRefinerInvocationError = class extends Error {
|
|
49631
|
+
constructor(message2, details, options) {
|
|
49632
|
+
super(message2, options);
|
|
49633
|
+
this.details = details;
|
|
49634
|
+
}
|
|
49635
|
+
details;
|
|
49636
|
+
name = "BenchmarkRefinerInvocationError";
|
|
49637
|
+
};
|
|
49638
|
+
function benchmarkRefinerRewardPacket(input) {
|
|
49639
|
+
const manifestEntries = input.artifactManifest.entries.slice(
|
|
49640
|
+
0,
|
|
49641
|
+
MAX_REFINER_ARTIFACT_MANIFEST_ENTRIES
|
|
49642
|
+
);
|
|
49643
|
+
return {
|
|
49644
|
+
schemaVersion: "openpond.refinerRewardPacket.v1",
|
|
49645
|
+
attemptRef: input.rewardReceipt.attemptRef,
|
|
49646
|
+
artifactManifest: {
|
|
49647
|
+
ref: {
|
|
49648
|
+
id: input.artifactManifest.id,
|
|
49649
|
+
contentHash: input.artifactManifest.contentHash
|
|
49650
|
+
},
|
|
49651
|
+
entries: manifestEntries,
|
|
49652
|
+
entryCount: input.artifactManifest.entries.length,
|
|
49653
|
+
truncated: manifestEntries.length < input.artifactManifest.entries.length
|
|
49654
|
+
},
|
|
49655
|
+
rewardReceipt: input.rewardReceipt,
|
|
49656
|
+
attempt: {
|
|
49657
|
+
status: input.rewardReceipt.outcomeClass,
|
|
49658
|
+
infrastructureError: input.attempt.infrastructureError,
|
|
49659
|
+
outputPresent: typeof input.attempt.output.text === "string" && input.attempt.output.text.trim().length > 0,
|
|
49660
|
+
artifactCount: input.artifactCount,
|
|
49661
|
+
runtimeEventCount: input.attempt.runtimeEventRefs.length,
|
|
49662
|
+
modelRequestCount: Array.isArray(input.attempt.metadata.usage) ? input.attempt.metadata.usage.length : input.attempt.metadata.usage ? 1 : 0,
|
|
49663
|
+
latencyMs: input.attempt.latencyMs,
|
|
49664
|
+
usage: attemptUsageSummary(input.attempt.metadata.usage)
|
|
49665
|
+
}
|
|
49666
|
+
};
|
|
49667
|
+
}
|
|
49314
49668
|
async function materializeBenchmarkRefinerBoundary(input) {
|
|
49315
49669
|
const attempt = input.result.attempt;
|
|
49316
49670
|
const sessionId = stringMetadata2(attempt.metadata, "sessionId");
|
|
@@ -49361,7 +49715,17 @@ async function materializeBenchmarkRefinerBoundary(input) {
|
|
|
49361
49715
|
}
|
|
49362
49716
|
}
|
|
49363
49717
|
});
|
|
49364
|
-
|
|
49718
|
+
const existingTurn = await input.store.getTurn(turn.id);
|
|
49719
|
+
if (!existingTurn) {
|
|
49720
|
+
await input.store.insertTurn(turn);
|
|
49721
|
+
} else {
|
|
49722
|
+
await input.store.updateTurn(turn.id, (current) => TurnSchema.parse({
|
|
49723
|
+
...current,
|
|
49724
|
+
modelRef: turn.modelRef,
|
|
49725
|
+
metadata: { ...current.metadata, ...turn.metadata },
|
|
49726
|
+
harnessSnapshot: turn.harnessSnapshot
|
|
49727
|
+
}));
|
|
49728
|
+
}
|
|
49365
49729
|
const assistantOutput = attempt.output.text;
|
|
49366
49730
|
if (typeof assistantOutput === "string" && assistantOutput.trim()) {
|
|
49367
49731
|
await input.store.appendRuntimeEvent(event({
|
|
@@ -49374,26 +49738,14 @@ async function materializeBenchmarkRefinerBoundary(input) {
|
|
|
49374
49738
|
output: assistantOutput
|
|
49375
49739
|
}));
|
|
49376
49740
|
}
|
|
49377
|
-
const
|
|
49378
|
-
|
|
49379
|
-
|
|
49380
|
-
|
|
49381
|
-
|
|
49382
|
-
failureClass: input.result.grade.failureClass,
|
|
49383
|
-
rewardEligible: input.result.grade.rewardEligible,
|
|
49384
|
-
feedback: input.result.grade.feedback,
|
|
49385
|
-
evaluationCriteria: task.expectedOutput,
|
|
49386
|
-
attempt: {
|
|
49387
|
-
status: attempt.infrastructureError ? "infrastructure_failure" : "completed",
|
|
49388
|
-
infrastructureError: attempt.infrastructureError,
|
|
49389
|
-
outputPresent: typeof attempt.output.text === "string" && attempt.output.text.trim().length > 0,
|
|
49390
|
-
artifactCount: input.result.artifacts.length,
|
|
49391
|
-
runtimeEventCount: attempt.runtimeEventRefs.length,
|
|
49392
|
-
modelRequestCount: Array.isArray(attempt.metadata.usage) ? attempt.metadata.usage.length : attempt.metadata.usage ? 1 : 0,
|
|
49393
|
-
latencyMs: attempt.latencyMs,
|
|
49394
|
-
usage: attemptUsageSummary(attempt.metadata.usage)
|
|
49395
|
-
}
|
|
49741
|
+
const rewardPacket = benchmarkRefinerRewardPacket({
|
|
49742
|
+
attempt,
|
|
49743
|
+
artifactManifest: input.result.artifactManifest,
|
|
49744
|
+
rewardReceipt: input.result.rewardReceipt,
|
|
49745
|
+
artifactCount: input.result.artifacts.length
|
|
49396
49746
|
});
|
|
49747
|
+
const rewardEvidence = JSON.stringify(rewardPacket);
|
|
49748
|
+
const rewardPassed = input.result.rewardReceipt.status === "scored" && input.result.rewardReceipt.passed;
|
|
49397
49749
|
await input.store.appendRuntimeEvent(event({
|
|
49398
49750
|
sessionId: session.id,
|
|
49399
49751
|
turnId: turn.id,
|
|
@@ -49401,14 +49753,23 @@ async function materializeBenchmarkRefinerBoundary(input) {
|
|
|
49401
49753
|
source: "server",
|
|
49402
49754
|
appId: session.appId,
|
|
49403
49755
|
action: "taskset_grade",
|
|
49404
|
-
status:
|
|
49405
|
-
output:
|
|
49406
|
-
error:
|
|
49756
|
+
status: rewardPassed ? "completed" : "failed",
|
|
49757
|
+
output: rewardEvidence,
|
|
49758
|
+
error: rewardPassed ? void 0 : rewardEvidence,
|
|
49407
49759
|
data: {
|
|
49408
49760
|
result: {
|
|
49409
|
-
output:
|
|
49410
|
-
passed:
|
|
49411
|
-
|
|
49761
|
+
output: rewardEvidence,
|
|
49762
|
+
passed: rewardPassed,
|
|
49763
|
+
status: input.result.rewardReceipt.status,
|
|
49764
|
+
reward: input.result.rewardReceipt.reward,
|
|
49765
|
+
rewardReceiptRef: {
|
|
49766
|
+
id: input.result.rewardReceipt.id,
|
|
49767
|
+
contentHash: input.result.rewardReceipt.contentHash
|
|
49768
|
+
},
|
|
49769
|
+
artifactManifestRef: {
|
|
49770
|
+
id: input.result.artifactManifest.id,
|
|
49771
|
+
contentHash: input.result.artifactManifest.contentHash
|
|
49772
|
+
}
|
|
49412
49773
|
}
|
|
49413
49774
|
}
|
|
49414
49775
|
}));
|
|
@@ -49419,7 +49780,12 @@ async function runBenchmarkRefinerAfterAttempt(input) {
|
|
|
49419
49780
|
if (!boundary) {
|
|
49420
49781
|
throw new Error(`Adaptation attempt ${input.result.attempt.id} has no Refiner boundary.`);
|
|
49421
49782
|
}
|
|
49422
|
-
const
|
|
49783
|
+
const existingTrigger = await queuedTriggerForTurn({
|
|
49784
|
+
store: input.store,
|
|
49785
|
+
workspaceId: input.runtime.workspace.id,
|
|
49786
|
+
turnId: boundary.turn.id
|
|
49787
|
+
});
|
|
49788
|
+
const detection = existingTrigger ? { observations: [], trigger: existingTrigger } : await recordLocalHarnessImprovementBoundary({
|
|
49423
49789
|
store: input.store,
|
|
49424
49790
|
session: boundary.session,
|
|
49425
49791
|
turn: boundary.turn,
|
|
@@ -49435,37 +49801,274 @@ async function runBenchmarkRefinerAfterAttempt(input) {
|
|
|
49435
49801
|
input.budget.assertAvailable(`Refiner turn ${detection.trigger.id}`);
|
|
49436
49802
|
const usage = emptyUsageCategory();
|
|
49437
49803
|
let providerInvoked = false;
|
|
49804
|
+
let providerRequestCount = 0;
|
|
49805
|
+
let requestsWithAuthoritativeCost = 0;
|
|
49806
|
+
let estimatedCostUsd = 0;
|
|
49807
|
+
const startedAt = input.now();
|
|
49808
|
+
let result = null;
|
|
49809
|
+
let failure = null;
|
|
49438
49810
|
try {
|
|
49439
|
-
|
|
49811
|
+
result = await runLocalHarnessRefinerWorker({
|
|
49440
49812
|
store: input.store,
|
|
49441
49813
|
storeDir: input.storeDir,
|
|
49442
49814
|
trigger: detection.trigger,
|
|
49443
49815
|
stream: async function* (streamInput) {
|
|
49444
49816
|
providerInvoked = true;
|
|
49445
|
-
|
|
49446
|
-
|
|
49447
|
-
|
|
49448
|
-
|
|
49449
|
-
|
|
49450
|
-
|
|
49451
|
-
|
|
49817
|
+
providerRequestCount += 1;
|
|
49818
|
+
let requestHadAuthoritativeCost = false;
|
|
49819
|
+
estimatedCostUsd += conservativeRefinerRequestCost(
|
|
49820
|
+
streamInput.messages,
|
|
49821
|
+
input.admittedPricing
|
|
49822
|
+
);
|
|
49823
|
+
try {
|
|
49824
|
+
for await (const delta of input.refinerStream({
|
|
49825
|
+
...streamInput,
|
|
49826
|
+
model: input.model,
|
|
49827
|
+
pricing: input.admittedPricing
|
|
49828
|
+
})) {
|
|
49829
|
+
if (typeof delta.costUsd === "number") requestHadAuthoritativeCost = true;
|
|
49830
|
+
if (delta.usage !== void 0 || delta.costUsd !== void 0) {
|
|
49831
|
+
addUsage(usage, delta.usage, delta.costUsd);
|
|
49832
|
+
}
|
|
49833
|
+
if (delta.text) yield { text: delta.text };
|
|
49834
|
+
}
|
|
49835
|
+
} finally {
|
|
49836
|
+
if (requestHadAuthoritativeCost) requestsWithAuthoritativeCost += 1;
|
|
49452
49837
|
}
|
|
49453
49838
|
},
|
|
49454
49839
|
signal: input.signal,
|
|
49840
|
+
timeoutMs: HARNESS_REFINER_BENCHMARK_REFINER_TIMEOUT_MS,
|
|
49455
49841
|
now: input.now
|
|
49456
49842
|
});
|
|
49457
|
-
|
|
49458
|
-
|
|
49459
|
-
|
|
49460
|
-
|
|
49843
|
+
} catch (error) {
|
|
49844
|
+
failure = error;
|
|
49845
|
+
}
|
|
49846
|
+
const completedAt = input.now();
|
|
49847
|
+
const costBasis = providerInvoked ? usage.costUsd !== null && requestsWithAuthoritativeCost === providerRequestCount ? "authoritative" : "estimated" : "none";
|
|
49848
|
+
const chargedCost = costBasis === "authoritative" ? usage.costUsd : costBasis === "estimated" ? Math.max(usage.costUsd ?? 0, estimatedCostUsd) : null;
|
|
49849
|
+
if (providerInvoked) {
|
|
49850
|
+
try {
|
|
49851
|
+
input.budget.charge(chargedCost, "Refiner");
|
|
49461
49852
|
await checkpointRefinerUsage(
|
|
49462
49853
|
input.store,
|
|
49463
49854
|
input.modelRun.id,
|
|
49464
49855
|
usage,
|
|
49465
49856
|
input.budget.observedSpendUsd
|
|
49466
49857
|
);
|
|
49858
|
+
} catch (error) {
|
|
49859
|
+
failure ??= error;
|
|
49860
|
+
}
|
|
49861
|
+
}
|
|
49862
|
+
if (failure) {
|
|
49863
|
+
const message2 = failure instanceof Error ? failure.message : String(failure);
|
|
49864
|
+
const failureKind = benchmarkRefinerFailureKind(failure, input.signal);
|
|
49865
|
+
const retryable = failureKind !== "cancelled";
|
|
49866
|
+
await input.store.appendRuntimeEvent(event({
|
|
49867
|
+
sessionId: boundary.session.id,
|
|
49868
|
+
turnId: boundary.turn.id,
|
|
49869
|
+
name: "harness.refiner.failed",
|
|
49870
|
+
source: "server",
|
|
49871
|
+
appId: boundary.session.appId,
|
|
49872
|
+
status: "failed",
|
|
49873
|
+
output: message2,
|
|
49874
|
+
data: {
|
|
49875
|
+
trigger: {
|
|
49876
|
+
id: detection.trigger.id,
|
|
49877
|
+
contentHash: detection.trigger.contentHash
|
|
49878
|
+
},
|
|
49879
|
+
benchmark: true,
|
|
49880
|
+
modelRunId: input.modelRun.id,
|
|
49881
|
+
attemptId: input.result.attempt.id,
|
|
49882
|
+
failureKind,
|
|
49883
|
+
retryable,
|
|
49884
|
+
costBasis,
|
|
49885
|
+
estimatedCostUsd: costBasis === "estimated" ? estimatedCostUsd : null
|
|
49886
|
+
}
|
|
49887
|
+
})).catch(() => void 0);
|
|
49888
|
+
throw new BenchmarkRefinerInvocationError(message2, {
|
|
49889
|
+
trigger: detection.trigger,
|
|
49890
|
+
usage,
|
|
49891
|
+
costBasis,
|
|
49892
|
+
estimatedCostUsd: costBasis === "estimated" ? estimatedCostUsd : null,
|
|
49893
|
+
failureKind,
|
|
49894
|
+
retryable,
|
|
49895
|
+
startedAt,
|
|
49896
|
+
completedAt
|
|
49897
|
+
}, { cause: failure });
|
|
49898
|
+
}
|
|
49899
|
+
return {
|
|
49900
|
+
detection,
|
|
49901
|
+
result,
|
|
49902
|
+
invocation: {
|
|
49903
|
+
usage,
|
|
49904
|
+
costBasis,
|
|
49905
|
+
estimatedCostUsd: costBasis === "estimated" ? estimatedCostUsd : null,
|
|
49906
|
+
startedAt,
|
|
49907
|
+
completedAt
|
|
49908
|
+
}
|
|
49909
|
+
};
|
|
49910
|
+
}
|
|
49911
|
+
async function queuedTriggerForTurn(input) {
|
|
49912
|
+
const triggers = await input.store.listHarnessImprovementArtifacts(
|
|
49913
|
+
input.workspaceId,
|
|
49914
|
+
"trigger_decision",
|
|
49915
|
+
1e3
|
|
49916
|
+
);
|
|
49917
|
+
return triggers.find(
|
|
49918
|
+
(trigger) => trigger.turnId === input.turnId && trigger.decision === "queue_refiner"
|
|
49919
|
+
) ?? null;
|
|
49920
|
+
}
|
|
49921
|
+
function conservativeRefinerRequestCost(messages, pricing) {
|
|
49922
|
+
const inputCharacters = messages.reduce(
|
|
49923
|
+
(total, message2) => total + message2.content.length,
|
|
49924
|
+
0
|
|
49925
|
+
);
|
|
49926
|
+
const estimatedInputTokens = Math.ceil(inputCharacters / 3);
|
|
49927
|
+
return (estimatedInputTokens * pricing.inputUsdPerMillionTokens + DEFAULT_REFINER_MAX_OUTPUT_TOKENS * pricing.outputUsdPerMillionTokens) / 1e6;
|
|
49928
|
+
}
|
|
49929
|
+
function benchmarkRefinerFailureKind(error, signal) {
|
|
49930
|
+
if (signal.aborted) return "cancelled";
|
|
49931
|
+
const message2 = error instanceof Error ? error.message : String(error);
|
|
49932
|
+
if (/timed out|timeout/i.test(message2)) return "timeout";
|
|
49933
|
+
if (/invalid structured output|response limit|JSON/i.test(message2)) {
|
|
49934
|
+
return "invalid_output";
|
|
49935
|
+
}
|
|
49936
|
+
if (/provider|rate limit|billing|signed out|network|fetch/i.test(message2)) {
|
|
49937
|
+
return "provider_failure";
|
|
49938
|
+
}
|
|
49939
|
+
return "unknown";
|
|
49940
|
+
}
|
|
49941
|
+
|
|
49942
|
+
// ../server/src/training/harness-refiner-benchmark-sequential-checkpoint.ts
|
|
49943
|
+
import { promises as fs24 } from "node:fs";
|
|
49944
|
+
import path57 from "node:path";
|
|
49945
|
+
function createBenchmarkRefinerInvocationReceipt(input) {
|
|
49946
|
+
const core = {
|
|
49947
|
+
schemaVersion: "openpond.benchmarkRefinerInvocation.v1",
|
|
49948
|
+
id: `benchmark-refiner-invocation-${contentHash({
|
|
49949
|
+
taskId: input.taskId,
|
|
49950
|
+
attemptId: input.attemptId,
|
|
49951
|
+
invocationOrdinal: input.invocationOrdinal,
|
|
49952
|
+
trigger: input.trigger,
|
|
49953
|
+
status: input.status,
|
|
49954
|
+
startedAt: input.startedAt
|
|
49955
|
+
}).slice(0, 24)}`,
|
|
49956
|
+
...input
|
|
49957
|
+
};
|
|
49958
|
+
return { ...core, contentHash: contentHash(core) };
|
|
49959
|
+
}
|
|
49960
|
+
async function loadSequentialAdaptationCheckpoint(input) {
|
|
49961
|
+
const filePath = checkpointPath(input.storeDir, input.modelRunId);
|
|
49962
|
+
let parsed;
|
|
49963
|
+
try {
|
|
49964
|
+
parsed = JSON.parse(await fs24.readFile(filePath, "utf8"));
|
|
49965
|
+
} catch (error) {
|
|
49966
|
+
if (error.code === "ENOENT") return null;
|
|
49967
|
+
throw error;
|
|
49968
|
+
}
|
|
49969
|
+
return parseCheckpoint(parsed, input.modelRunId);
|
|
49970
|
+
}
|
|
49971
|
+
async function initializeSequentialAdaptationCheckpoint(input) {
|
|
49972
|
+
const existing = await loadSequentialAdaptationCheckpoint(input);
|
|
49973
|
+
if (existing) {
|
|
49974
|
+
if (!sameRef(existing.initialHarness, input.initialHarness)) {
|
|
49975
|
+
throw new Error("Sequential adaptation checkpoint changed its initial Harness release.");
|
|
49976
|
+
}
|
|
49977
|
+
return existing;
|
|
49978
|
+
}
|
|
49979
|
+
return writeSequentialAdaptationCheckpoint({
|
|
49980
|
+
storeDir: input.storeDir,
|
|
49981
|
+
checkpoint: checkpoint({
|
|
49982
|
+
modelRunId: input.modelRunId,
|
|
49983
|
+
initialHarness: input.initialHarness,
|
|
49984
|
+
steps: [],
|
|
49985
|
+
invocations: [],
|
|
49986
|
+
updatedAt: input.now
|
|
49987
|
+
})
|
|
49988
|
+
});
|
|
49989
|
+
}
|
|
49990
|
+
async function appendSequentialAdaptationInvocation(input) {
|
|
49991
|
+
const current = await initializeSequentialAdaptationCheckpoint({
|
|
49992
|
+
storeDir: input.storeDir,
|
|
49993
|
+
modelRunId: input.modelRunId,
|
|
49994
|
+
initialHarness: input.initialHarness,
|
|
49995
|
+
now: input.now
|
|
49996
|
+
});
|
|
49997
|
+
if (!input.invocation && !input.step) {
|
|
49998
|
+
throw new Error("A sequential checkpoint append requires an invocation or step.");
|
|
49999
|
+
}
|
|
50000
|
+
const invocations = input.invocation ? [
|
|
50001
|
+
...current.invocations.filter((item) => item.id !== input.invocation.id),
|
|
50002
|
+
input.invocation
|
|
50003
|
+
] : current.invocations;
|
|
50004
|
+
const steps = input.step ? [
|
|
50005
|
+
...current.steps.filter((item) => item.taskId !== input.step.taskId),
|
|
50006
|
+
input.step
|
|
50007
|
+
].sort((left, right) => left.ordinal - right.ordinal) : current.steps;
|
|
50008
|
+
return writeSequentialAdaptationCheckpoint({
|
|
50009
|
+
storeDir: input.storeDir,
|
|
50010
|
+
checkpoint: checkpoint({
|
|
50011
|
+
modelRunId: current.modelRunId,
|
|
50012
|
+
initialHarness: current.initialHarness,
|
|
50013
|
+
steps,
|
|
50014
|
+
invocations,
|
|
50015
|
+
updatedAt: input.now
|
|
50016
|
+
})
|
|
50017
|
+
});
|
|
50018
|
+
}
|
|
50019
|
+
function checkpoint(input) {
|
|
50020
|
+
const core = {
|
|
50021
|
+
schemaVersion: "openpond.sequentialAdaptationCheckpoint.v1",
|
|
50022
|
+
...input
|
|
50023
|
+
};
|
|
50024
|
+
return { ...core, contentHash: contentHash(core) };
|
|
50025
|
+
}
|
|
50026
|
+
async function writeSequentialAdaptationCheckpoint(input) {
|
|
50027
|
+
const filePath = checkpointPath(input.storeDir, input.checkpoint.modelRunId);
|
|
50028
|
+
const directory = path57.dirname(filePath);
|
|
50029
|
+
await fs24.mkdir(directory, { recursive: true });
|
|
50030
|
+
const temporaryPath = `${filePath}.${process.pid}.tmp`;
|
|
50031
|
+
await fs24.writeFile(
|
|
50032
|
+
temporaryPath,
|
|
50033
|
+
`${JSON.stringify(input.checkpoint, null, 2)}
|
|
50034
|
+
`,
|
|
50035
|
+
"utf8"
|
|
50036
|
+
);
|
|
50037
|
+
await fs24.rename(temporaryPath, filePath);
|
|
50038
|
+
return input.checkpoint;
|
|
50039
|
+
}
|
|
50040
|
+
function parseCheckpoint(value, modelRunId) {
|
|
50041
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
50042
|
+
throw new Error("Sequential adaptation checkpoint is malformed.");
|
|
50043
|
+
}
|
|
50044
|
+
const record11 = value;
|
|
50045
|
+
if (record11.schemaVersion !== "openpond.sequentialAdaptationCheckpoint.v1" || record11.modelRunId !== modelRunId || !record11.initialHarness || !Array.isArray(record11.steps) || !Array.isArray(record11.invocations) || typeof record11.updatedAt !== "string" || typeof record11.contentHash !== "string") {
|
|
50046
|
+
throw new Error("Sequential adaptation checkpoint is malformed.");
|
|
50047
|
+
}
|
|
50048
|
+
const { contentHash: admittedHash, ...core } = record11;
|
|
50049
|
+
if (contentHash(core) !== admittedHash) {
|
|
50050
|
+
throw new Error("Sequential adaptation checkpoint failed content-hash validation.");
|
|
50051
|
+
}
|
|
50052
|
+
const parsed = record11;
|
|
50053
|
+
for (const invocation of parsed.invocations) {
|
|
50054
|
+
const { contentHash: invocationHash, ...invocationCore } = invocation;
|
|
50055
|
+
if (contentHash(invocationCore) !== invocationHash) {
|
|
50056
|
+
throw new Error(`Refiner invocation ${invocation.id} failed content-hash validation.`);
|
|
49467
50057
|
}
|
|
49468
50058
|
}
|
|
50059
|
+
return parsed;
|
|
50060
|
+
}
|
|
50061
|
+
function checkpointPath(storeDir, modelRunId) {
|
|
50062
|
+
return path57.join(
|
|
50063
|
+
storeDir,
|
|
50064
|
+
"training",
|
|
50065
|
+
"harness-refiner-benchmarks",
|
|
50066
|
+
modelRunId,
|
|
50067
|
+
"sequential-adaptation.json"
|
|
50068
|
+
);
|
|
50069
|
+
}
|
|
50070
|
+
function sameRef(left, right) {
|
|
50071
|
+
return left.id === right.id && left.contentHash === right.contentHash;
|
|
49469
50072
|
}
|
|
49470
50073
|
|
|
49471
50074
|
// ../server/src/training/harness-refiner-benchmark-sequential-stage.ts
|
|
@@ -49473,58 +50076,143 @@ async function runSequentialHarnessAdaptation(input) {
|
|
|
49473
50076
|
const runRefinerAfterAttempt = input.adapters?.runRefinerAfterAttempt ?? runBenchmarkRefinerAfterAttempt;
|
|
49474
50077
|
const loadRuntimeFromRelease = input.adapters?.loadRuntimeFromRelease ?? loadLocalHarnessRuntimeFromRelease;
|
|
49475
50078
|
const buildLineage = input.adapters?.buildLineage ?? benchmarkLineage;
|
|
50079
|
+
const loadAttemptEvidenceByIds = input.adapters?.loadAttemptEvidenceByIds ?? loadBenchmarkAttemptEvidenceByIds;
|
|
49476
50080
|
await input.store.setHarnessBackgroundReviewSettings({
|
|
49477
50081
|
workspaceId: input.initialRuntime.workspace.id,
|
|
49478
50082
|
enabled: true,
|
|
49479
50083
|
updatedAt: input.now()
|
|
49480
50084
|
});
|
|
49481
|
-
|
|
49482
|
-
|
|
50085
|
+
const initialHarness = {
|
|
50086
|
+
id: input.initialRuntime.release.harnessRelease.id,
|
|
50087
|
+
contentHash: input.initialRuntime.release.harnessRelease.contentHash
|
|
50088
|
+
};
|
|
50089
|
+
let checkpoint2 = await initializeSequentialAdaptationCheckpoint({
|
|
50090
|
+
storeDir: input.storeDir,
|
|
50091
|
+
modelRunId: input.modelRun.id,
|
|
50092
|
+
initialHarness,
|
|
50093
|
+
now: input.now()
|
|
50094
|
+
});
|
|
50095
|
+
assertCheckpointTaskOrder(checkpoint2.steps, input.taskIds);
|
|
50096
|
+
let runtime = await restoreCheckpointRuntime({
|
|
50097
|
+
store: input.store,
|
|
50098
|
+
initialRuntime: input.initialRuntime,
|
|
50099
|
+
steps: checkpoint2.steps,
|
|
50100
|
+
loadRuntimeFromRelease
|
|
50101
|
+
});
|
|
50102
|
+
const attempts = checkpoint2.steps.length ? await loadAttemptEvidenceByIds({
|
|
50103
|
+
store: input.store,
|
|
50104
|
+
tasksetId: input.taskset.id,
|
|
50105
|
+
attemptIds: checkpoint2.steps.map((step) => step.attemptId)
|
|
50106
|
+
}) : [];
|
|
50107
|
+
const attemptsById = new Map(attempts.map((attempt) => [attempt.attempt.id, attempt]));
|
|
49483
50108
|
const refinerResults = [];
|
|
49484
|
-
const steps = [];
|
|
50109
|
+
const steps = [...checkpoint2.steps];
|
|
49485
50110
|
try {
|
|
49486
50111
|
for (const [ordinal, taskId] of input.taskIds.entries()) {
|
|
50112
|
+
if (ordinal < steps.length) continue;
|
|
49487
50113
|
input.signal.throwIfAborted();
|
|
49488
50114
|
const before = {
|
|
49489
50115
|
id: runtime.release.harnessRelease.id,
|
|
49490
50116
|
contentHash: runtime.release.harnessRelease.contentHash
|
|
49491
50117
|
};
|
|
49492
|
-
const
|
|
49493
|
-
|
|
49494
|
-
|
|
49495
|
-
|
|
49496
|
-
|
|
49497
|
-
|
|
49498
|
-
|
|
49499
|
-
|
|
49500
|
-
|
|
49501
|
-
|
|
49502
|
-
|
|
49503
|
-
|
|
49504
|
-
|
|
49505
|
-
|
|
49506
|
-
|
|
49507
|
-
|
|
49508
|
-
|
|
49509
|
-
|
|
49510
|
-
|
|
49511
|
-
|
|
49512
|
-
}
|
|
49513
|
-
|
|
49514
|
-
|
|
49515
|
-
|
|
49516
|
-
|
|
49517
|
-
|
|
49518
|
-
|
|
49519
|
-
|
|
49520
|
-
|
|
49521
|
-
|
|
49522
|
-
|
|
49523
|
-
|
|
49524
|
-
|
|
49525
|
-
|
|
49526
|
-
|
|
49527
|
-
|
|
50118
|
+
const priorInvocations = checkpoint2.invocations.filter(
|
|
50119
|
+
(invocation2) => invocation2.taskId === taskId
|
|
50120
|
+
);
|
|
50121
|
+
const lastInvocation = priorInvocations.at(-1);
|
|
50122
|
+
if (lastInvocation?.status === "failed" && priorInvocations.length >= HARNESS_REFINER_BENCHMARK_MAX_INVOCATIONS_PER_TASK) {
|
|
50123
|
+
throw new Error(
|
|
50124
|
+
`Sequential Refiner exhausted ${HARNESS_REFINER_BENCHMARK_MAX_INVOCATIONS_PER_TASK} admitted invocations for ${taskId}.`
|
|
50125
|
+
);
|
|
50126
|
+
}
|
|
50127
|
+
let evidence = lastInvocation?.status === "failed" ? attemptsById.get(lastInvocation.attemptId) : void 0;
|
|
50128
|
+
if (!evidence && lastInvocation?.status === "failed") {
|
|
50129
|
+
[evidence] = await loadAttemptEvidenceByIds({
|
|
50130
|
+
store: input.store,
|
|
50131
|
+
tasksetId: input.taskset.id,
|
|
50132
|
+
attemptIds: [lastInvocation.attemptId]
|
|
50133
|
+
});
|
|
50134
|
+
if (evidence) {
|
|
50135
|
+
attempts.push(evidence);
|
|
50136
|
+
attemptsById.set(evidence.attempt.id, evidence);
|
|
50137
|
+
}
|
|
50138
|
+
}
|
|
50139
|
+
if (!evidence) {
|
|
50140
|
+
const executed = await input.evaluation.execute({
|
|
50141
|
+
tasksetId: input.taskset.id,
|
|
50142
|
+
taskId,
|
|
50143
|
+
model: input.model,
|
|
50144
|
+
reasoningEffort: input.reasoningEffort,
|
|
50145
|
+
seed: input.seed,
|
|
50146
|
+
attempt: 0,
|
|
50147
|
+
sampling: { maxOutputTokens: 4096, temperature: 0, topP: 1 },
|
|
50148
|
+
releasedHarness: releasedHarness(runtime.release, runtime.instructionContext),
|
|
50149
|
+
hostedTokenPricing: input.admittedPricing,
|
|
50150
|
+
parentModelRunId: input.modelRun.id,
|
|
50151
|
+
signal: input.signal,
|
|
50152
|
+
toolEvidence: frozenToolEvidence(input.evidenceSnapshot, "replay", "adaptation")
|
|
50153
|
+
});
|
|
50154
|
+
await input.onAttemptComplete(executed);
|
|
50155
|
+
evidence = {
|
|
50156
|
+
attempt: executed.attempt,
|
|
50157
|
+
grade: executed.grade,
|
|
50158
|
+
artifacts: executed.artifacts,
|
|
50159
|
+
receiptContentHash: executed.portable.receipt.contentHash,
|
|
50160
|
+
artifactManifest: executed.portable.artifactManifest,
|
|
50161
|
+
rewardReceipt: executed.portable.rewardReceipt
|
|
50162
|
+
};
|
|
50163
|
+
attempts.push(evidence);
|
|
50164
|
+
attemptsById.set(evidence.attempt.id, evidence);
|
|
50165
|
+
}
|
|
50166
|
+
let refined;
|
|
50167
|
+
try {
|
|
50168
|
+
refined = await runRefinerAfterAttempt({
|
|
50169
|
+
store: input.store,
|
|
50170
|
+
storeDir: input.storeDir,
|
|
50171
|
+
modelRun: input.modelRun,
|
|
50172
|
+
model: input.model,
|
|
50173
|
+
taskset: input.taskset,
|
|
50174
|
+
runtime,
|
|
50175
|
+
result: evidence,
|
|
50176
|
+
budget: input.budget,
|
|
50177
|
+
admittedPricing: input.admittedPricing,
|
|
50178
|
+
refinerStream: input.refinerStream,
|
|
50179
|
+
signal: input.signal,
|
|
50180
|
+
now: input.now
|
|
50181
|
+
});
|
|
50182
|
+
} catch (error) {
|
|
50183
|
+
if (error instanceof BenchmarkRefinerInvocationError) {
|
|
50184
|
+
checkpoint2 = await appendSequentialAdaptationInvocation({
|
|
50185
|
+
storeDir: input.storeDir,
|
|
50186
|
+
modelRunId: input.modelRun.id,
|
|
50187
|
+
initialHarness,
|
|
50188
|
+
invocation: createBenchmarkRefinerInvocationReceipt({
|
|
50189
|
+
taskId,
|
|
50190
|
+
attemptId: evidence.attempt.id,
|
|
50191
|
+
invocationOrdinal: priorInvocations.length,
|
|
50192
|
+
trigger: {
|
|
50193
|
+
id: error.details.trigger.id,
|
|
50194
|
+
contentHash: error.details.trigger.contentHash
|
|
50195
|
+
},
|
|
50196
|
+
status: "failed",
|
|
50197
|
+
outcome: null,
|
|
50198
|
+
failure: {
|
|
50199
|
+
kind: error.details.failureKind,
|
|
50200
|
+
message: error.message.slice(0, 2e3),
|
|
50201
|
+
retryable: error.details.retryable
|
|
50202
|
+
},
|
|
50203
|
+
inputHarness: before,
|
|
50204
|
+
outputHarness: before,
|
|
50205
|
+
usage: error.details.usage,
|
|
50206
|
+
costBasis: error.details.costBasis,
|
|
50207
|
+
estimatedCostUsd: error.details.estimatedCostUsd,
|
|
50208
|
+
startedAt: error.details.startedAt,
|
|
50209
|
+
completedAt: error.details.completedAt
|
|
50210
|
+
}),
|
|
50211
|
+
now: error.details.completedAt
|
|
50212
|
+
});
|
|
50213
|
+
}
|
|
50214
|
+
throw error;
|
|
50215
|
+
}
|
|
49528
50216
|
if (refined.result) refinerResults.push(refined.result);
|
|
49529
50217
|
const workspace = await input.store.getHarnessWorkspace(runtime.workspace.id);
|
|
49530
50218
|
const releaseRef = workspace?.currentChannel.release;
|
|
@@ -49538,7 +50226,7 @@ async function runSequentialHarnessAdaptation(input) {
|
|
|
49538
50226
|
id: runtime.release.harnessRelease.id,
|
|
49539
50227
|
contentHash: runtime.release.harnessRelease.contentHash
|
|
49540
50228
|
};
|
|
49541
|
-
|
|
50229
|
+
const step = {
|
|
49542
50230
|
ordinal,
|
|
49543
50231
|
taskId,
|
|
49544
50232
|
attemptId: evidence.attempt.id,
|
|
@@ -49555,6 +50243,38 @@ async function runSequentialHarnessAdaptation(input) {
|
|
|
49555
50243
|
decision: refined.result.outcome.decision
|
|
49556
50244
|
} : null,
|
|
49557
50245
|
changed: before.contentHash !== after.contentHash
|
|
50246
|
+
};
|
|
50247
|
+
steps.push(step);
|
|
50248
|
+
const invocation = refined.result && refined.invocation ? createBenchmarkRefinerInvocationReceipt({
|
|
50249
|
+
taskId,
|
|
50250
|
+
attemptId: evidence.attempt.id,
|
|
50251
|
+
invocationOrdinal: priorInvocations.length,
|
|
50252
|
+
trigger: {
|
|
50253
|
+
id: refined.detection.trigger.id,
|
|
50254
|
+
contentHash: refined.detection.trigger.contentHash
|
|
50255
|
+
},
|
|
50256
|
+
status: "completed",
|
|
50257
|
+
outcome: {
|
|
50258
|
+
id: refined.result.outcome.id,
|
|
50259
|
+
contentHash: refined.result.outcome.contentHash,
|
|
50260
|
+
decision: refined.result.outcome.decision
|
|
50261
|
+
},
|
|
50262
|
+
failure: null,
|
|
50263
|
+
inputHarness: before,
|
|
50264
|
+
outputHarness: after,
|
|
50265
|
+
usage: refined.invocation.usage,
|
|
50266
|
+
costBasis: refined.invocation.costBasis,
|
|
50267
|
+
estimatedCostUsd: refined.invocation.estimatedCostUsd,
|
|
50268
|
+
startedAt: refined.invocation.startedAt,
|
|
50269
|
+
completedAt: refined.invocation.completedAt
|
|
50270
|
+
}) : void 0;
|
|
50271
|
+
checkpoint2 = await appendSequentialAdaptationInvocation({
|
|
50272
|
+
storeDir: input.storeDir,
|
|
50273
|
+
modelRunId: input.modelRun.id,
|
|
50274
|
+
initialHarness,
|
|
50275
|
+
invocation,
|
|
50276
|
+
step,
|
|
50277
|
+
now: input.now()
|
|
49558
50278
|
});
|
|
49559
50279
|
}
|
|
49560
50280
|
} finally {
|
|
@@ -49593,10 +50313,6 @@ async function runSequentialHarnessAdaptation(input) {
|
|
|
49593
50313
|
const costs = attempts.flatMap(
|
|
49594
50314
|
(evidence) => typeof evidence.attempt.costUsd === "number" ? [evidence.attempt.costUsd] : []
|
|
49595
50315
|
);
|
|
49596
|
-
const initialHarness = {
|
|
49597
|
-
id: input.initialRuntime.release.harnessRelease.id,
|
|
49598
|
-
contentHash: input.initialRuntime.release.harnessRelease.contentHash
|
|
49599
|
-
};
|
|
49600
50316
|
const finalHarness = {
|
|
49601
50317
|
id: runtime.release.harnessRelease.id,
|
|
49602
50318
|
contentHash: runtime.release.harnessRelease.contentHash
|
|
@@ -49633,7 +50349,7 @@ async function runSequentialHarnessAdaptation(input) {
|
|
|
49633
50349
|
store: input.store,
|
|
49634
50350
|
workspaceId: input.initialRuntime.workspace.id,
|
|
49635
50351
|
adaptationAttempts: attempts,
|
|
49636
|
-
|
|
50352
|
+
completedSteps: steps,
|
|
49637
50353
|
candidateRelease: finalHarness,
|
|
49638
50354
|
refinerInputHash: contentHash(attempts.map((evidence) => ({
|
|
49639
50355
|
attempt: evidence.attempt.id,
|
|
@@ -49650,6 +50366,26 @@ async function runSequentialHarnessAdaptation(input) {
|
|
|
49650
50366
|
refinerResults
|
|
49651
50367
|
};
|
|
49652
50368
|
}
|
|
50369
|
+
function assertCheckpointTaskOrder(steps, taskIds) {
|
|
50370
|
+
for (const [index, step] of steps.entries()) {
|
|
50371
|
+
if (step.ordinal !== index || step.taskId !== taskIds[index]) {
|
|
50372
|
+
throw new Error("Sequential adaptation checkpoint drifted from the admitted task order.");
|
|
50373
|
+
}
|
|
50374
|
+
}
|
|
50375
|
+
}
|
|
50376
|
+
async function restoreCheckpointRuntime(input) {
|
|
50377
|
+
const last = input.steps.at(-1);
|
|
50378
|
+
if (!last) return input.initialRuntime;
|
|
50379
|
+
const workspace = await input.store.getHarnessWorkspace(input.initialRuntime.workspace.id);
|
|
50380
|
+
if (!workspace?.currentChannel.release || workspace.currentChannel.release.id !== last.outputHarness.id || workspace.currentChannel.release.contentHash !== last.outputHarness.contentHash) {
|
|
50381
|
+
throw new Error("Sequential adaptation workspace drifted from its durable checkpoint.");
|
|
50382
|
+
}
|
|
50383
|
+
const release = await input.store.getHarnessReleaseRecord(last.outputHarness.contentHash);
|
|
50384
|
+
if (!release || release.harnessRelease.id !== last.outputHarness.id) {
|
|
50385
|
+
throw new Error("Sequential adaptation checkpoint release is unavailable.");
|
|
50386
|
+
}
|
|
50387
|
+
return input.loadRuntimeFromRelease({ workspace, release });
|
|
50388
|
+
}
|
|
49653
50389
|
function numericToken(record11, keys) {
|
|
49654
50390
|
for (const key of keys) {
|
|
49655
50391
|
const value = record11[key];
|
|
@@ -49680,7 +50416,7 @@ function createHarnessRefinerBenchmarkService(deps) {
|
|
|
49680
50416
|
});
|
|
49681
50417
|
if (!taskset.benchmark) throw new Error("Harness Refiner Taskset is unavailable.");
|
|
49682
50418
|
if (taskset.graders.some(
|
|
49683
|
-
(grader) => grader.kind === "model_judge" && grader.calibrationStatus !== "passed"
|
|
50419
|
+
(grader) => grader.kind === "model_judge" && grader.rewardEligible && grader.calibrationStatus !== "passed"
|
|
49684
50420
|
)) {
|
|
49685
50421
|
const calibration = await deps.evaluation.calibrateModelJudges(taskset.id);
|
|
49686
50422
|
if (!calibration.passed) {
|
|
@@ -49755,7 +50491,7 @@ function createHarnessRefinerBenchmarkService(deps) {
|
|
|
49755
50491
|
attemptPlan: executionPlan
|
|
49756
50492
|
},
|
|
49757
50493
|
evaluationProgress: {
|
|
49758
|
-
stage: "
|
|
50494
|
+
stage: "adaptation",
|
|
49759
50495
|
completedAttempts: 0,
|
|
49760
50496
|
totalAttempts: totalPlannedAttempts(executionPlan),
|
|
49761
50497
|
accounting: emptyEvaluationAccounting()
|
|
@@ -49802,13 +50538,23 @@ function createHarnessRefinerBenchmarkService(deps) {
|
|
|
49802
50538
|
}
|
|
49803
50539
|
if (activeRuns.has(modelRunId) || run.status === "running") return run;
|
|
49804
50540
|
const canResumeFromRefiner = run.evaluationProgress?.stage === "refiner" && run.evaluationProgress?.completedAttempts === completedBeforeStage(run.evaluation.attemptPlan, "candidate_adaptation");
|
|
50541
|
+
const candidateAdaptationStart = completedBeforeStage(
|
|
50542
|
+
run.evaluation.attemptPlan,
|
|
50543
|
+
"candidate_adaptation"
|
|
50544
|
+
);
|
|
50545
|
+
const candidateAdaptationEnd = candidateAdaptationStart + requirePlanStage(run.evaluation.attemptPlan, "candidate_adaptation").attemptCount;
|
|
50546
|
+
const sequentialCheckpoint = await loadSequentialAdaptationCheckpoint({
|
|
50547
|
+
storeDir: deps.storeDir,
|
|
50548
|
+
modelRunId: run.id
|
|
50549
|
+
});
|
|
50550
|
+
const canResumeFromCandidateAdaptation = run.evaluationProgress?.stage === "candidate_adaptation" && run.evaluationProgress.completedAttempts >= candidateAdaptationStart && run.evaluationProgress.completedAttempts <= candidateAdaptationEnd && Boolean(sequentialCheckpoint);
|
|
49805
50551
|
const hasCompletedComparisonCheckpoint = ["candidate_adaptation", "candidate", "comparison"].includes(
|
|
49806
50552
|
run.evaluationProgress?.stage ?? ""
|
|
49807
50553
|
) && run.evaluationProgress?.completedAttempts === totalPlannedAttempts(run.evaluation.attemptPlan);
|
|
49808
50554
|
const canResumeFromComparison = hasCompletedComparisonCheckpoint && Boolean(await loadLatestManagedResult(deps.storeDir, run.id));
|
|
49809
|
-
if (!["failed", "cancelled"].includes(run.status) || !canResumeFromRefiner && !canResumeFromComparison) {
|
|
50555
|
+
if (!["failed", "cancelled"].includes(run.status) || !canResumeFromRefiner && !canResumeFromCandidateAdaptation && !canResumeFromComparison) {
|
|
49810
50556
|
throw new Error(
|
|
49811
|
-
"Only a Harness Refiner run with a durable Refiner or comparison checkpoint can resume."
|
|
50557
|
+
"Only a Harness Refiner run with a durable Refiner, sequential adaptation, or comparison checkpoint can resume."
|
|
49812
50558
|
);
|
|
49813
50559
|
}
|
|
49814
50560
|
const project = await requireModelProject(deps.store, run.modelId, run.profileId);
|
|
@@ -49899,12 +50645,22 @@ function createHarnessRefinerBenchmarkService(deps) {
|
|
|
49899
50645
|
);
|
|
49900
50646
|
const candidatePlan = requirePlanStage(executionPlan, "candidate");
|
|
49901
50647
|
const resumeFromRefiner = modelRun.evaluationProgress?.stage === "refiner" && modelRun.evaluationProgress.completedAttempts === completedBeforeStage(executionPlan, "candidate_adaptation");
|
|
50648
|
+
const candidateAdaptationStart = completedBeforeStage(
|
|
50649
|
+
executionPlan,
|
|
50650
|
+
"candidate_adaptation"
|
|
50651
|
+
);
|
|
50652
|
+
const candidateAdaptationEnd = candidateAdaptationStart + candidateAdaptationPlan.attemptCount;
|
|
50653
|
+
const sequentialCheckpoint = await loadSequentialAdaptationCheckpoint({
|
|
50654
|
+
storeDir: deps.storeDir,
|
|
50655
|
+
modelRunId: modelRun.id
|
|
50656
|
+
});
|
|
50657
|
+
const resumeFromCandidateAdaptation = modelRun.evaluationProgress?.stage === "candidate_adaptation" && modelRun.evaluationProgress.completedAttempts >= candidateAdaptationStart && modelRun.evaluationProgress.completedAttempts <= candidateAdaptationEnd && Boolean(sequentialCheckpoint);
|
|
49902
50658
|
const resumeFromComparison = ["candidate_adaptation", "candidate", "comparison"].includes(
|
|
49903
50659
|
modelRun.evaluationProgress?.stage ?? ""
|
|
49904
50660
|
) && modelRun.evaluationProgress?.completedAttempts === totalAttempts;
|
|
49905
50661
|
const budget = new BenchmarkSpendBudget(
|
|
49906
50662
|
input.maximumSpendUsd,
|
|
49907
|
-
resumeFromRefiner || resumeFromComparison ? modelRun.evaluationProgress?.accounting?.observedSpendUsd ?? 0 : 0
|
|
50663
|
+
resumeFromRefiner || resumeFromCandidateAdaptation || resumeFromComparison ? modelRun.evaluationProgress?.accounting?.observedSpendUsd ?? 0 : 0
|
|
49908
50664
|
);
|
|
49909
50665
|
if (resumeFromComparison) {
|
|
49910
50666
|
return resumeHarnessRefinerComparison({
|
|
@@ -49931,7 +50687,7 @@ function createHarnessRefinerBenchmarkService(deps) {
|
|
|
49931
50687
|
}
|
|
49932
50688
|
let evidenceSnapshot = new BenchmarkEvidenceSnapshot();
|
|
49933
50689
|
const observeStageAttempts = (stage, label) => {
|
|
49934
|
-
let completedInStage = 0;
|
|
50690
|
+
let completedInStage = modelRun.evaluationProgress?.accounting?.attempts.filter((attempt) => attempt.phase === stage).length ?? 0;
|
|
49935
50691
|
return async (result) => {
|
|
49936
50692
|
context.signal.throwIfAborted();
|
|
49937
50693
|
budget.assertAvailable(label);
|
|
@@ -49960,7 +50716,7 @@ function createHarnessRefinerBenchmarkService(deps) {
|
|
|
49960
50716
|
let baseline;
|
|
49961
50717
|
let adaptation;
|
|
49962
50718
|
let adaptationAttempts;
|
|
49963
|
-
if (resumeFromRefiner) {
|
|
50719
|
+
if (resumeFromRefiner || resumeFromCandidateAdaptation) {
|
|
49964
50720
|
baseline = await loadCompletedBenchmarkStage({
|
|
49965
50721
|
store: deps.store,
|
|
49966
50722
|
modelRunId: modelRun.id,
|
|
@@ -49984,33 +50740,34 @@ function createHarnessRefinerBenchmarkService(deps) {
|
|
|
49984
50740
|
]
|
|
49985
50741
|
});
|
|
49986
50742
|
} else {
|
|
49987
|
-
const
|
|
50743
|
+
const executedAdaptation = await deps.evaluation.executeBenchmark({
|
|
49988
50744
|
tasksetId: taskset.id,
|
|
49989
50745
|
phase: "baseline",
|
|
49990
50746
|
model: input.model,
|
|
49991
50747
|
reasoningEffort: input.reasoningEffort,
|
|
49992
50748
|
seeds: input.seeds,
|
|
49993
50749
|
repetitions: input.repetitions,
|
|
49994
|
-
split:
|
|
49995
|
-
taskIds:
|
|
50750
|
+
split: adaptationPlan.split,
|
|
50751
|
+
taskIds: adaptationPlan.taskIds,
|
|
49996
50752
|
sampling: { maxOutputTokens: 4096, temperature: 0, topP: 1 },
|
|
49997
50753
|
releasedHarness: baselineHarness,
|
|
49998
50754
|
hostedTokenPricing: admittedPricing,
|
|
49999
50755
|
parentModelRunId: modelRun.id,
|
|
50000
50756
|
signal: context.signal,
|
|
50001
|
-
toolEvidence: frozenToolEvidence(evidenceSnapshot, "record", "
|
|
50002
|
-
onAttemptComplete: observeStageAttempts("
|
|
50757
|
+
toolEvidence: frozenToolEvidence(evidenceSnapshot, "record", "adaptation"),
|
|
50758
|
+
onAttemptComplete: observeStageAttempts("adaptation", "adaptation baseline")
|
|
50003
50759
|
});
|
|
50004
|
-
|
|
50760
|
+
adaptation = completedStage(executedAdaptation);
|
|
50761
|
+
adaptationAttempts = adaptation.attempts;
|
|
50005
50762
|
await ensureBaseVersion({
|
|
50006
50763
|
store: deps.store,
|
|
50007
50764
|
project: context.project,
|
|
50008
50765
|
modelRun,
|
|
50009
50766
|
model: input.model,
|
|
50010
|
-
baseline:
|
|
50767
|
+
baseline: executedAdaptation.attempts[0]
|
|
50011
50768
|
});
|
|
50012
|
-
if (
|
|
50013
|
-
throw new Error("
|
|
50769
|
+
if (adaptation.run.harnessRelease.id !== modelRun.harnessRelease.id || adaptation.run.harnessRelease.contentHash !== modelRun.harnessRelease.contentHash) {
|
|
50770
|
+
throw new Error("Adaptation baseline drifted from the admitted Harness release.");
|
|
50014
50771
|
}
|
|
50015
50772
|
await checkpointEvidenceSnapshot(
|
|
50016
50773
|
deps.store,
|
|
@@ -50019,29 +50776,31 @@ function createHarnessRefinerBenchmarkService(deps) {
|
|
|
50019
50776
|
evidenceSnapshot.manifest()
|
|
50020
50777
|
);
|
|
50021
50778
|
await updateProgress(deps.store, modelRun.id, {
|
|
50022
|
-
stage: "
|
|
50023
|
-
completedAttempts: completedBeforeStage(executionPlan, "
|
|
50779
|
+
stage: "baseline",
|
|
50780
|
+
completedAttempts: completedBeforeStage(executionPlan, "baseline"),
|
|
50024
50781
|
totalAttempts
|
|
50025
50782
|
});
|
|
50026
|
-
const
|
|
50783
|
+
const executedBaseline = await deps.evaluation.executeBenchmark({
|
|
50027
50784
|
tasksetId: taskset.id,
|
|
50028
50785
|
phase: "baseline",
|
|
50029
50786
|
model: input.model,
|
|
50030
50787
|
reasoningEffort: input.reasoningEffort,
|
|
50031
50788
|
seeds: input.seeds,
|
|
50032
50789
|
repetitions: input.repetitions,
|
|
50033
|
-
split:
|
|
50034
|
-
taskIds:
|
|
50790
|
+
split: baselinePlan.split,
|
|
50791
|
+
taskIds: baselinePlan.taskIds,
|
|
50035
50792
|
sampling: { maxOutputTokens: 4096, temperature: 0, topP: 1 },
|
|
50036
50793
|
releasedHarness: baselineHarness,
|
|
50037
50794
|
hostedTokenPricing: admittedPricing,
|
|
50038
50795
|
parentModelRunId: modelRun.id,
|
|
50039
50796
|
signal: context.signal,
|
|
50040
|
-
toolEvidence: frozenToolEvidence(evidenceSnapshot, "record", "
|
|
50041
|
-
onAttemptComplete: observeStageAttempts("
|
|
50797
|
+
toolEvidence: frozenToolEvidence(evidenceSnapshot, "record", "held_out"),
|
|
50798
|
+
onAttemptComplete: observeStageAttempts("baseline", "held-out baseline")
|
|
50042
50799
|
});
|
|
50043
|
-
|
|
50044
|
-
|
|
50800
|
+
baseline = completedStage(executedBaseline);
|
|
50801
|
+
if (baseline.run.harnessRelease.id !== modelRun.harnessRelease.id || baseline.run.harnessRelease.contentHash !== modelRun.harnessRelease.contentHash) {
|
|
50802
|
+
throw new Error("Held-out baseline drifted from the admitted Harness release.");
|
|
50803
|
+
}
|
|
50045
50804
|
await checkpointEvidenceSnapshot(
|
|
50046
50805
|
deps.store,
|
|
50047
50806
|
deps.storeDir,
|
|
@@ -50054,16 +50813,18 @@ function createHarnessRefinerBenchmarkService(deps) {
|
|
|
50054
50813
|
totalAttempts
|
|
50055
50814
|
});
|
|
50056
50815
|
}
|
|
50057
|
-
if (resumeFromRefiner && !modelRun.evaluationProgress?.evidenceSnapshot) {
|
|
50816
|
+
if ((resumeFromRefiner || resumeFromCandidateAdaptation) && !modelRun.evaluationProgress?.evidenceSnapshot) {
|
|
50058
50817
|
throw new Error(
|
|
50059
50818
|
"Sequential adaptation cannot resume because the interrupted run did not preserve its exact frozen evidence snapshot. Start a new run to preserve a valid causal comparison."
|
|
50060
50819
|
);
|
|
50061
50820
|
}
|
|
50062
|
-
|
|
50063
|
-
|
|
50064
|
-
|
|
50065
|
-
|
|
50066
|
-
|
|
50821
|
+
if (!resumeFromCandidateAdaptation) {
|
|
50822
|
+
await updateProgress(deps.store, modelRun.id, {
|
|
50823
|
+
stage: "candidate_adaptation",
|
|
50824
|
+
completedAttempts: candidateAdaptationStart,
|
|
50825
|
+
totalAttempts
|
|
50826
|
+
});
|
|
50827
|
+
}
|
|
50067
50828
|
const candidateAdaptation = await runSequentialHarnessAdaptation({
|
|
50068
50829
|
store: deps.store,
|
|
50069
50830
|
storeDir: deps.storeDir,
|
|
@@ -50295,13 +51056,13 @@ function createHarnessRefinerBenchmarkService(deps) {
|
|
|
50295
51056
|
}
|
|
50296
51057
|
|
|
50297
51058
|
// ../server/src/training/task-attempt-grader-evidence.ts
|
|
50298
|
-
import { execFile as
|
|
51059
|
+
import { execFile as execFile8 } from "node:child_process";
|
|
50299
51060
|
import { readFile as readFile15 } from "node:fs/promises";
|
|
50300
51061
|
import { promisify as promisify5 } from "node:util";
|
|
50301
51062
|
var MAX_ARTIFACTS = 5;
|
|
50302
51063
|
var MAX_ARTIFACT_BYTES = 20 * 1024 * 1024;
|
|
50303
51064
|
var MAX_EXTRACTED_CHARS = 4e4;
|
|
50304
|
-
var execFileAsync5 = promisify5(
|
|
51065
|
+
var execFileAsync5 = promisify5(execFile8);
|
|
50305
51066
|
function createTaskAttemptModelJudge(input) {
|
|
50306
51067
|
return async ({ grader, task, attempt }) => {
|
|
50307
51068
|
const usages = [];
|
|
@@ -50377,6 +51138,18 @@ async function loadTaskAttemptGraderEvidence(input) {
|
|
|
50377
51138
|
content: boundedText(stdout)
|
|
50378
51139
|
};
|
|
50379
51140
|
}
|
|
51141
|
+
if (isOpenXmlArtifact(artifact.mediaType)) {
|
|
51142
|
+
const extracted = await extractOpenXmlArtifact(
|
|
51143
|
+
artifact.path,
|
|
51144
|
+
artifact.mediaType
|
|
51145
|
+
);
|
|
51146
|
+
return {
|
|
51147
|
+
...base,
|
|
51148
|
+
extraction: "open_xml_text",
|
|
51149
|
+
content: boundedText(extracted.content),
|
|
51150
|
+
structure: extracted.structure
|
|
51151
|
+
};
|
|
51152
|
+
}
|
|
50380
51153
|
if (isTextArtifact(artifact.mediaType)) {
|
|
50381
51154
|
return {
|
|
50382
51155
|
...base,
|
|
@@ -50396,9 +51169,74 @@ async function loadTaskAttemptGraderEvidence(input) {
|
|
|
50396
51169
|
}
|
|
50397
51170
|
function isTextArtifact(mediaType) {
|
|
50398
51171
|
return Boolean(
|
|
50399
|
-
mediaType?.startsWith("text/") || mediaType === "application/json" || mediaType === "application/xml"
|
|
51172
|
+
mediaType?.startsWith("text/") || mediaType === "application/json" || mediaType === "application/javascript" || mediaType === "application/sql" || mediaType === "application/xml" || mediaType === "application/yaml"
|
|
50400
51173
|
);
|
|
50401
51174
|
}
|
|
51175
|
+
function isOpenXmlArtifact(mediaType) {
|
|
51176
|
+
return mediaType === "application/vnd.openxmlformats-officedocument.wordprocessingml.document" || mediaType === "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" || mediaType === "application/vnd.openxmlformats-officedocument.presentationml.presentation";
|
|
51177
|
+
}
|
|
51178
|
+
async function extractOpenXmlArtifact(artifactPath2, mediaType) {
|
|
51179
|
+
const options = {
|
|
51180
|
+
env: { ...process.env, PATH: executableSearchPath() },
|
|
51181
|
+
maxBuffer: 16 * 1024 * 1024,
|
|
51182
|
+
timeout: 15e3
|
|
51183
|
+
};
|
|
51184
|
+
const { stdout: listing } = await execFileAsync5(
|
|
51185
|
+
"unzip",
|
|
51186
|
+
["-Z1", artifactPath2],
|
|
51187
|
+
options
|
|
51188
|
+
);
|
|
51189
|
+
const entries = listing.split(/\r?\n/).filter(Boolean);
|
|
51190
|
+
const selected = openXmlTextEntries(entries, mediaType).slice(0, 250);
|
|
51191
|
+
const parts = [];
|
|
51192
|
+
for (const entry of selected) {
|
|
51193
|
+
const { stdout } = await execFileAsync5(
|
|
51194
|
+
"unzip",
|
|
51195
|
+
["-p", artifactPath2, entry],
|
|
51196
|
+
options
|
|
51197
|
+
);
|
|
51198
|
+
const text3 = readableXmlText(stdout);
|
|
51199
|
+
if (text3) parts.push(`[${entry}]
|
|
51200
|
+
${text3}`);
|
|
51201
|
+
}
|
|
51202
|
+
return {
|
|
51203
|
+
content: parts.join("\n\n"),
|
|
51204
|
+
structure: {
|
|
51205
|
+
archiveEntryCount: entries.length,
|
|
51206
|
+
extractedEntryCount: selected.length,
|
|
51207
|
+
sheetCount: entries.filter((entry) => /^xl\/worksheets\/sheet\d+\.xml$/.test(entry)).length,
|
|
51208
|
+
slideCount: entries.filter((entry) => /^ppt\/slides\/slide\d+\.xml$/.test(entry)).length,
|
|
51209
|
+
chartCount: entries.filter((entry) => /\/charts\/chart\d+\.xml$/.test(entry)).length,
|
|
51210
|
+
imageCount: entries.filter((entry) => /\/media\//.test(entry)).length
|
|
51211
|
+
}
|
|
51212
|
+
};
|
|
51213
|
+
}
|
|
51214
|
+
function openXmlTextEntries(entries, mediaType) {
|
|
51215
|
+
if (mediaType.includes("wordprocessingml")) {
|
|
51216
|
+
return entries.filter(
|
|
51217
|
+
(entry) => /^word\/(?:document|header\d+|footer\d+|footnotes|endnotes|comments)\.xml$/.test(entry)
|
|
51218
|
+
);
|
|
51219
|
+
}
|
|
51220
|
+
if (mediaType.includes("spreadsheetml")) {
|
|
51221
|
+
return entries.filter(
|
|
51222
|
+
(entry) => entry === "xl/workbook.xml" || entry === "xl/sharedStrings.xml" || /^xl\/worksheets\/sheet\d+\.xml$/.test(entry) || /^xl\/charts\/chart\d+\.xml$/.test(entry)
|
|
51223
|
+
);
|
|
51224
|
+
}
|
|
51225
|
+
return entries.filter(
|
|
51226
|
+
(entry) => /^ppt\/(?:slides\/slide\d+|notesSlides\/notesSlide\d+|charts\/chart\d+)\.xml$/.test(entry)
|
|
51227
|
+
).sort(naturalEntryOrder);
|
|
51228
|
+
}
|
|
51229
|
+
function naturalEntryOrder(left, right) {
|
|
51230
|
+
return left.localeCompare(right, void 0, { numeric: true });
|
|
51231
|
+
}
|
|
51232
|
+
function readableXmlText(value) {
|
|
51233
|
+
return decodeXmlEntities(
|
|
51234
|
+
value.replace(/<\/?(?:w:p|a:p|row|si|sheetData|c)(?:\s[^>]*)?>/g, "\n").replace(/<(?:w:tab|a:br)(?:\s[^>]*)?\/?\s*>/g, " ").replace(/<[^>]+>/g, " ")
|
|
51235
|
+
).split(/\r?\n/).map((line) => line.replace(/[\t ]+/g, " ").trim()).filter(Boolean).join("\n");
|
|
51236
|
+
}
|
|
51237
|
+
function decodeXmlEntities(value) {
|
|
51238
|
+
return value.replace(/&#x([0-9a-f]+);/gi, (_, hex) => String.fromCodePoint(Number.parseInt(hex, 16))).replace(/&#(\d+);/g, (_, decimal2) => String.fromCodePoint(Number.parseInt(decimal2, 10))).replaceAll(""", '"').replaceAll("'", "'").replaceAll("<", "<").replaceAll(">", ">").replaceAll("&", "&");
|
|
51239
|
+
}
|
|
50402
51240
|
function boundedText(value) {
|
|
50403
51241
|
return value.length <= MAX_EXTRACTED_CHARS ? value : `${value.slice(0, MAX_EXTRACTED_CHARS)}
|
|
50404
51242
|
[truncated]`;
|
|
@@ -50468,7 +51306,7 @@ function usageCost(usage, pricing) {
|
|
|
50468
51306
|
// ../server/src/training/benchmark-tasksets.ts
|
|
50469
51307
|
import { createHash as createHash15 } from "node:crypto";
|
|
50470
51308
|
import { mkdir as mkdir11, readFile as readFile16, writeFile as writeFile7 } from "node:fs/promises";
|
|
50471
|
-
import
|
|
51309
|
+
import path58 from "node:path";
|
|
50472
51310
|
var BUILTIN_DEFINITION_ID = "harness-refiner";
|
|
50473
51311
|
function createBenchmarkTasksetService(input) {
|
|
50474
51312
|
const now2 = input.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
|
|
@@ -50478,7 +51316,7 @@ function createBenchmarkTasksetService(input) {
|
|
|
50478
51316
|
if (existing?.benchmark?.releaseId === harnessRefinerBenchmarkRelease.id && existing.benchmark.releaseHash === harnessRefinerBenchmarkRelease.contentHash) {
|
|
50479
51317
|
return existing;
|
|
50480
51318
|
}
|
|
50481
|
-
const tasksetRoot =
|
|
51319
|
+
const tasksetRoot = path58.join(
|
|
50482
51320
|
input.storeDir,
|
|
50483
51321
|
"training",
|
|
50484
51322
|
"tasksets",
|
|
@@ -50498,7 +51336,7 @@ function createBenchmarkTasksetService(input) {
|
|
|
50498
51336
|
}
|
|
50499
51337
|
async function releaseForTaskset(taskset) {
|
|
50500
51338
|
if (taskset.purpose !== "benchmark" || !taskset.benchmark) return null;
|
|
50501
|
-
const releasePath =
|
|
51339
|
+
const releasePath = path58.resolve(
|
|
50502
51340
|
input.storeDir,
|
|
50503
51341
|
"training",
|
|
50504
51342
|
"tasksets",
|
|
@@ -50519,18 +51357,23 @@ function definitionForRelease(release) {
|
|
|
50519
51357
|
return createBenchmarkDefinition({
|
|
50520
51358
|
schemaVersion: "openpond.benchmarkDefinition.v1",
|
|
50521
51359
|
id: BUILTIN_DEFINITION_ID,
|
|
50522
|
-
title: "Harness Refiner
|
|
50523
|
-
description: "Measures whether sequential, evidence-driven Harness improvements
|
|
51360
|
+
title: "Harness Refiner 20260818 v2",
|
|
51361
|
+
description: "Measures whether sequential, evidence-driven Harness improvements change verified reward on a frozen cohort; foreground tokens are secondary.",
|
|
50524
51362
|
tasksetRelease: { id: release.id, contentHash: release.contentHash },
|
|
50525
51363
|
adaptationSplit: "validation",
|
|
50526
51364
|
evaluationSplit: "frozen_eval",
|
|
50527
|
-
primaryMetric: "
|
|
51365
|
+
primaryMetric: "success_rate",
|
|
50528
51366
|
qualityGate: "non_regression",
|
|
50529
51367
|
caseCounts: {
|
|
50530
51368
|
adaptation: release.tasks.filter((task) => task.split === "validation").length,
|
|
50531
51369
|
evaluation: release.tasks.filter((task) => task.split === "frozen_eval").length
|
|
50532
51370
|
},
|
|
50533
|
-
metadata: {
|
|
51371
|
+
metadata: {
|
|
51372
|
+
builtin: true,
|
|
51373
|
+
protocol: "sequential_product_lifecycle_v3",
|
|
51374
|
+
orderSeed: "harness-refiner-20260818-order-v1",
|
|
51375
|
+
secondaryMetrics: ["foreground_tokens"]
|
|
51376
|
+
}
|
|
50534
51377
|
});
|
|
50535
51378
|
}
|
|
50536
51379
|
async function projectRelease(input) {
|
|
@@ -50541,12 +51384,12 @@ async function projectRelease(input) {
|
|
|
50541
51384
|
input.release.tasks.flatMap((task) => task.artifactRefs)
|
|
50542
51385
|
);
|
|
50543
51386
|
const managedAssetById = /* @__PURE__ */ new Map();
|
|
50544
|
-
await mkdir11(
|
|
50545
|
-
await mkdir11(
|
|
50546
|
-
await mkdir11(
|
|
50547
|
-
await mkdir11(
|
|
51387
|
+
await mkdir11(path58.join(input.tasksetRoot, "assets"), { recursive: true });
|
|
51388
|
+
await mkdir11(path58.join(input.tasksetRoot, "benchmark"), { recursive: true });
|
|
51389
|
+
await mkdir11(path58.join(input.tasksetRoot, "rubrics"), { recursive: true });
|
|
51390
|
+
await mkdir11(path58.join(input.tasksetRoot, "verifiers"), { recursive: true });
|
|
50548
51391
|
await writeFile7(
|
|
50549
|
-
|
|
51392
|
+
path58.join(input.tasksetRoot, "benchmark", "taskset.release.json"),
|
|
50550
51393
|
JSON.stringify(input.release),
|
|
50551
51394
|
"utf8"
|
|
50552
51395
|
);
|
|
@@ -50555,9 +51398,9 @@ async function projectRelease(input) {
|
|
|
50555
51398
|
if (contentHash(contents) !== asset.contentHash) {
|
|
50556
51399
|
throw new Error(`Benchmark asset ${asset.path} failed its content hash.`);
|
|
50557
51400
|
}
|
|
50558
|
-
const fileName = `${asset.id}-${
|
|
50559
|
-
const artifactRef =
|
|
50560
|
-
await writeFile7(
|
|
51401
|
+
const fileName = `${asset.id}-${path58.basename(asset.path)}`;
|
|
51402
|
+
const artifactRef = path58.posix.join("assets", fileName);
|
|
51403
|
+
await writeFile7(path58.join(input.tasksetRoot, artifactRef), contents, "utf8");
|
|
50561
51404
|
managedAssetById.set(asset.id, {
|
|
50562
51405
|
artifactRef,
|
|
50563
51406
|
fileName,
|
|
@@ -50566,19 +51409,17 @@ async function projectRelease(input) {
|
|
|
50566
51409
|
mediaType: asset.mediaType
|
|
50567
51410
|
});
|
|
50568
51411
|
}
|
|
50569
|
-
const rubricGrader = input.release.graders.find(
|
|
50570
|
-
(grader) => grader.kind === "model_judge"
|
|
50571
|
-
);
|
|
50572
51412
|
const verifierGrader = input.release.graders.find(
|
|
50573
51413
|
(grader) => grader.kind === "custom_verifier"
|
|
50574
51414
|
);
|
|
50575
|
-
|
|
50576
|
-
|
|
51415
|
+
const supplementaryJudge = supplementaryModelJudge(input.release);
|
|
51416
|
+
if (!verifierGrader) {
|
|
51417
|
+
throw new Error("Benchmark release requires a custom verifier.");
|
|
50577
51418
|
}
|
|
50578
|
-
|
|
51419
|
+
await copyVerifierAsset(
|
|
50579
51420
|
input.assets,
|
|
50580
51421
|
input.tasksetRoot,
|
|
50581
|
-
|
|
51422
|
+
supplementaryJudge.rubricRef
|
|
50582
51423
|
);
|
|
50583
51424
|
await copyVerifierAsset(
|
|
50584
51425
|
input.assets,
|
|
@@ -50587,10 +51428,6 @@ async function projectRelease(input) {
|
|
|
50587
51428
|
);
|
|
50588
51429
|
const sourceId = `source-${input.tasksetId}`;
|
|
50589
51430
|
const tasks = input.release.tasks.map((task) => {
|
|
50590
|
-
const deliverable = stringValue11(task.expectedOutput?.deliverable);
|
|
50591
|
-
const validationKinds = Array.isArray(task.expectedOutput?.validation) ? task.expectedOutput.validation.filter(
|
|
50592
|
-
(value) => typeof value === "string"
|
|
50593
|
-
) : [];
|
|
50594
51431
|
return {
|
|
50595
51432
|
schemaVersion: "openpond.taskData.v1",
|
|
50596
51433
|
id: task.id,
|
|
@@ -50616,9 +51453,18 @@ async function projectRelease(input) {
|
|
|
50616
51453
|
metadata: { portableContentHash: asset.contentHash }
|
|
50617
51454
|
};
|
|
50618
51455
|
}),
|
|
50619
|
-
requiredOutputs:
|
|
51456
|
+
requiredOutputs: (task.requiredOutputs ?? []).map((output) => ({
|
|
51457
|
+
path: output.path,
|
|
51458
|
+
mediaType: output.mediaType,
|
|
51459
|
+
schemaRef: output.schemaRef?.id ?? null,
|
|
51460
|
+
maxBytes: output.maxBytes ?? void 0,
|
|
51461
|
+
metadata: output.metadata
|
|
51462
|
+
})),
|
|
50620
51463
|
tags: task.tags,
|
|
50621
|
-
metadata: {
|
|
51464
|
+
metadata: {
|
|
51465
|
+
portableTaskId: task.id,
|
|
51466
|
+
portableTaskRecord: task
|
|
51467
|
+
}
|
|
50622
51468
|
};
|
|
50623
51469
|
});
|
|
50624
51470
|
const sourceFileHashes = [...managedAssetById.values()].map((asset) => asset.sha256);
|
|
@@ -50636,29 +51482,9 @@ async function projectRelease(input) {
|
|
|
50636
51482
|
exportName: "verify",
|
|
50637
51483
|
timeoutMs: verifierGrader.timeoutMs,
|
|
50638
51484
|
networkPolicy: "none",
|
|
50639
|
-
metadata: { portableVerifierHash: verifierGrader.verifierRef.contentHash }
|
|
50640
|
-
},
|
|
50641
|
-
{
|
|
50642
|
-
id: rubricGrader.id,
|
|
50643
|
-
version: rubricGrader.version,
|
|
50644
|
-
label: "Task quality",
|
|
50645
|
-
kind: "model_judge",
|
|
50646
|
-
weight: rubricGrader.weight,
|
|
50647
|
-
hardGate: rubricGrader.hardGate,
|
|
50648
|
-
rewardEligible: false,
|
|
50649
|
-
privileged: rubricGrader.privileged,
|
|
50650
|
-
rubric,
|
|
50651
|
-
judge: { providerId: "openpond", modelId: "openpond-chat" },
|
|
50652
|
-
calibrationFixtureRefs: [
|
|
50653
|
-
"benchmark-positive",
|
|
50654
|
-
"benchmark-negative",
|
|
50655
|
-
"benchmark-boundary"
|
|
50656
|
-
],
|
|
50657
|
-
calibrationStatus: "pending",
|
|
50658
|
-
temperature: 0,
|
|
50659
51485
|
metadata: {
|
|
50660
|
-
|
|
50661
|
-
|
|
51486
|
+
portableVerifierHash: verifierGrader.verifierRef.contentHash,
|
|
51487
|
+
portableVerifierRef: verifierGrader.verifierRef
|
|
50662
51488
|
}
|
|
50663
51489
|
}
|
|
50664
51490
|
];
|
|
@@ -50719,6 +51545,7 @@ async function projectRelease(input) {
|
|
|
50719
51545
|
networkPolicy: input.release.environment.networkPolicy,
|
|
50720
51546
|
metadata: {
|
|
50721
51547
|
portableEnvironmentHash: contentHash(input.release.environment),
|
|
51548
|
+
portableTools: input.release.tools,
|
|
50722
51549
|
maxToolTurns: 40
|
|
50723
51550
|
}
|
|
50724
51551
|
},
|
|
@@ -50727,7 +51554,7 @@ async function projectRelease(input) {
|
|
|
50727
51554
|
taskKind: "single_agent",
|
|
50728
51555
|
supportedSignals: [],
|
|
50729
51556
|
compatibleMethods: ["none"],
|
|
50730
|
-
rewardKinds: ["deterministic"
|
|
51557
|
+
rewardKinds: ["deterministic"],
|
|
50731
51558
|
requiresTools: true,
|
|
50732
51559
|
requiresState: true,
|
|
50733
51560
|
requiresPrivilegedGrading: true,
|
|
@@ -50768,7 +51595,16 @@ async function projectRelease(input) {
|
|
|
50768
51595
|
portableTasksetRelease: {
|
|
50769
51596
|
id: input.release.id,
|
|
50770
51597
|
contentHash: input.release.contentHash
|
|
50771
|
-
}
|
|
51598
|
+
},
|
|
51599
|
+
supplementaryModelJudge: {
|
|
51600
|
+
id: supplementaryJudge.id,
|
|
51601
|
+
version: supplementaryJudge.version,
|
|
51602
|
+
rubricHash: supplementaryJudge.rubricRef.contentHash,
|
|
51603
|
+
calibrationStatus: supplementaryJudge.calibrationStatus,
|
|
51604
|
+
executable: false,
|
|
51605
|
+
rewardEligible: false
|
|
51606
|
+
},
|
|
51607
|
+
portableCapabilities: input.release.capabilities
|
|
50772
51608
|
}
|
|
50773
51609
|
});
|
|
50774
51610
|
return TasksetSchema.parse({
|
|
@@ -50784,7 +51620,7 @@ async function copyVerifierAsset(assets, tasksetRoot, asset) {
|
|
|
50784
51620
|
if (contentHash(contents) !== asset.contentHash) {
|
|
50785
51621
|
throw new Error(`Benchmark verifier asset ${asset.path} failed its content hash.`);
|
|
50786
51622
|
}
|
|
50787
|
-
await writeFile7(
|
|
51623
|
+
await writeFile7(path58.join(tasksetRoot, asset.path), contents, "utf8");
|
|
50788
51624
|
return contents;
|
|
50789
51625
|
}
|
|
50790
51626
|
function builtinAsset(assets, assetPath) {
|
|
@@ -50794,19 +51630,6 @@ function builtinAsset(assets, assetPath) {
|
|
|
50794
51630
|
}
|
|
50795
51631
|
return contents;
|
|
50796
51632
|
}
|
|
50797
|
-
function requiredOutputs(taskId, deliverable, validationKinds) {
|
|
50798
|
-
const output = deliverable === "pdf" ? { extension: "pdf", mediaType: "application/pdf" } : deliverable === "spreadsheet" ? {
|
|
50799
|
-
extension: "xlsx",
|
|
50800
|
-
mediaType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
50801
|
-
} : null;
|
|
50802
|
-
if (!output) return [];
|
|
50803
|
-
return [{
|
|
50804
|
-
path: `${taskId}.${output.extension}`,
|
|
50805
|
-
mediaType: output.mediaType,
|
|
50806
|
-
maxBytes: 1e7,
|
|
50807
|
-
metadata: { validationKinds }
|
|
50808
|
-
}];
|
|
50809
|
-
}
|
|
50810
51633
|
function benchmarkFixtures(taskId) {
|
|
50811
51634
|
return [
|
|
50812
51635
|
{
|
|
@@ -50830,7 +51653,7 @@ function benchmarkFixtures(taskId) {
|
|
|
50830
51653
|
},
|
|
50831
51654
|
infrastructureError: null,
|
|
50832
51655
|
expectedPassed: false,
|
|
50833
|
-
expectedRewardEligible:
|
|
51656
|
+
expectedRewardEligible: true,
|
|
50834
51657
|
metadata: {}
|
|
50835
51658
|
},
|
|
50836
51659
|
{
|
|
@@ -50840,7 +51663,7 @@ function benchmarkFixtures(taskId) {
|
|
|
50840
51663
|
output: { text: "The launch is moving to August 27 while testing finishes." },
|
|
50841
51664
|
infrastructureError: null,
|
|
50842
51665
|
expectedPassed: false,
|
|
50843
|
-
expectedRewardEligible:
|
|
51666
|
+
expectedRewardEligible: true,
|
|
50844
51667
|
metadata: {}
|
|
50845
51668
|
}
|
|
50846
51669
|
];
|
|
@@ -50848,16 +51671,29 @@ function benchmarkFixtures(taskId) {
|
|
|
50848
51671
|
function uniqueAssets(assets) {
|
|
50849
51672
|
return [...new Map(assets.map((asset) => [asset.id, asset])).values()];
|
|
50850
51673
|
}
|
|
50851
|
-
function
|
|
50852
|
-
|
|
51674
|
+
function supplementaryModelJudge(release) {
|
|
51675
|
+
const raw = release.metadata.supplementaryModelJudge;
|
|
51676
|
+
if (!raw || typeof raw !== "object" || Array.isArray(raw)) {
|
|
51677
|
+
throw new Error("Benchmark release has no supplementary model-judge metadata.");
|
|
51678
|
+
}
|
|
51679
|
+
const value = raw;
|
|
51680
|
+
if (typeof value.id !== "string" || typeof value.version !== "string" || value.calibrationStatus !== "pending" || value.executable !== false || value.rewardEligible !== false) {
|
|
51681
|
+
throw new Error("Benchmark supplementary model-judge metadata is invalid.");
|
|
51682
|
+
}
|
|
51683
|
+
return {
|
|
51684
|
+
id: value.id,
|
|
51685
|
+
version: value.version,
|
|
51686
|
+
calibrationStatus: value.calibrationStatus,
|
|
51687
|
+
rubricRef: ImmutableAssetRefSchema.parse(value.rubricRef)
|
|
51688
|
+
};
|
|
50853
51689
|
}
|
|
50854
51690
|
|
|
50855
51691
|
// ../server/src/training/local-taskset-work-runtime.ts
|
|
50856
|
-
import { execFile as
|
|
51692
|
+
import { execFile as execFile9 } from "node:child_process";
|
|
50857
51693
|
import { createHash as createHash16, randomUUID as randomUUID23 } from "node:crypto";
|
|
50858
|
-
import { existsSync as existsSync12, promises as
|
|
51694
|
+
import { existsSync as existsSync12, promises as fs25 } from "node:fs";
|
|
50859
51695
|
import os8 from "node:os";
|
|
50860
|
-
import
|
|
51696
|
+
import path59 from "node:path";
|
|
50861
51697
|
function createLocalTasksetWorkRuntime(deps) {
|
|
50862
51698
|
return {
|
|
50863
51699
|
createSession: async (payload) => {
|
|
@@ -50911,7 +51747,7 @@ async function executeLocalWorkspaceTool(input) {
|
|
|
50911
51747
|
const request = record10(input.payload);
|
|
50912
51748
|
const action = string2(request.action);
|
|
50913
51749
|
const args = record10(request.args);
|
|
50914
|
-
const root =
|
|
51750
|
+
const root = path59.resolve(input.session.cwd);
|
|
50915
51751
|
await ensureLayout(root);
|
|
50916
51752
|
try {
|
|
50917
51753
|
if (action === "sandbox_create" || action === "sandbox_start") {
|
|
@@ -50938,8 +51774,8 @@ async function executeLocalWorkspaceTool(input) {
|
|
|
50938
51774
|
if (action === "sandbox_upload_file") {
|
|
50939
51775
|
const target = localPath(root, string2(args.path));
|
|
50940
51776
|
const bytes2 = Buffer.from(string2(args.contentsBase64), "base64");
|
|
50941
|
-
await
|
|
50942
|
-
await
|
|
51777
|
+
await fs25.mkdir(path59.dirname(target), { recursive: true, mode: 448 });
|
|
51778
|
+
await fs25.writeFile(target, bytes2, { mode: 384 });
|
|
50943
51779
|
return ok(action, `Uploaded ${relative(root, target)}.`, fileData(target, bytes2));
|
|
50944
51780
|
}
|
|
50945
51781
|
if (action === "sandbox_list_files") {
|
|
@@ -50950,7 +51786,7 @@ async function executeLocalWorkspaceTool(input) {
|
|
|
50950
51786
|
if (action === "sandbox_read_file") {
|
|
50951
51787
|
const target = localPath(root, string2(args.path));
|
|
50952
51788
|
const maxBytes = integer(args.maxBytes, 512e3, 1, 1e6);
|
|
50953
|
-
const bytes2 = await
|
|
51789
|
+
const bytes2 = await fs25.readFile(target);
|
|
50954
51790
|
const bounded = bytes2.subarray(0, maxBytes);
|
|
50955
51791
|
return ok(action, bounded.toString("utf8"), {
|
|
50956
51792
|
path: relative(root, target),
|
|
@@ -50962,24 +51798,24 @@ async function executeLocalWorkspaceTool(input) {
|
|
|
50962
51798
|
if (action === "sandbox_write_file") {
|
|
50963
51799
|
const target = localPath(root, string2(args.path));
|
|
50964
51800
|
const contents = string2(args.content, true);
|
|
50965
|
-
await
|
|
50966
|
-
await
|
|
51801
|
+
await fs25.mkdir(path59.dirname(target), { recursive: true, mode: 448 });
|
|
51802
|
+
await fs25.writeFile(target, contents, { encoding: "utf8", mode: 384 });
|
|
50967
51803
|
return ok(action, `Wrote ${relative(root, target)}.`, fileData(target, Buffer.from(contents)));
|
|
50968
51804
|
}
|
|
50969
51805
|
if (action === "sandbox_edit_file") {
|
|
50970
51806
|
const target = localPath(root, string2(args.path));
|
|
50971
|
-
const contents = await
|
|
51807
|
+
const contents = await fs25.readFile(target, "utf8");
|
|
50972
51808
|
const oldText = string2(args.oldText);
|
|
50973
51809
|
if (!contents.includes(oldText)) {
|
|
50974
51810
|
return fail(action, "The exact text to replace was not found.");
|
|
50975
51811
|
}
|
|
50976
51812
|
const next = args.replaceAll === true ? contents.replaceAll(oldText, string2(args.newText, true)) : contents.replace(oldText, string2(args.newText, true));
|
|
50977
|
-
await
|
|
51813
|
+
await fs25.writeFile(target, next, { encoding: "utf8", mode: 384 });
|
|
50978
51814
|
return ok(action, `Edited ${relative(root, target)}.`, fileData(target, Buffer.from(next)));
|
|
50979
51815
|
}
|
|
50980
51816
|
if (action === "sandbox_delete_file") {
|
|
50981
51817
|
const target = localPath(root, string2(args.path));
|
|
50982
|
-
await
|
|
51818
|
+
await fs25.rm(target, { recursive: args.recursive === true, force: true });
|
|
50983
51819
|
return ok(action, `Deleted ${relative(root, target)}.`, { path: relative(root, target) });
|
|
50984
51820
|
}
|
|
50985
51821
|
if (action === "sandbox_exec") {
|
|
@@ -50992,7 +51828,7 @@ async function executeLocalWorkspaceTool(input) {
|
|
|
50992
51828
|
output: [result.stdout, result.stderr].filter(Boolean).join("\n").trim(),
|
|
50993
51829
|
data: {
|
|
50994
51830
|
command,
|
|
50995
|
-
cwd:
|
|
51831
|
+
cwd: path59.join(root, "work"),
|
|
50996
51832
|
exitCode: result.code,
|
|
50997
51833
|
stdout: result.stdout,
|
|
50998
51834
|
stderr: result.stderr
|
|
@@ -51001,24 +51837,24 @@ async function executeLocalWorkspaceTool(input) {
|
|
|
51001
51837
|
}
|
|
51002
51838
|
if (action === "sandbox_save_output") {
|
|
51003
51839
|
const source = localPath(root, string2(args.path));
|
|
51004
|
-
const bytes2 = await
|
|
51840
|
+
const bytes2 = await fs25.readFile(source);
|
|
51005
51841
|
if (bytes2.byteLength > WORK_OUTPUT_MAX_BYTES) {
|
|
51006
51842
|
return fail(action, `Work output exceeds ${WORK_OUTPUT_MAX_BYTES.toLocaleString()} bytes.`);
|
|
51007
51843
|
}
|
|
51008
51844
|
const title = safeName2(
|
|
51009
|
-
typeof args.suggestedName === "string" && args.suggestedName.trim() ? args.suggestedName :
|
|
51845
|
+
typeof args.suggestedName === "string" && args.suggestedName.trim() ? args.suggestedName : path59.basename(source)
|
|
51010
51846
|
);
|
|
51011
|
-
const contentType2 = WORK_OUTPUT_CONTENT_TYPES[
|
|
51847
|
+
const contentType2 = WORK_OUTPUT_CONTENT_TYPES[path59.extname(title).toLowerCase()];
|
|
51012
51848
|
if (!contentType2) return fail(action, `${title} is not a supported Work output format.`);
|
|
51013
|
-
const outputDir =
|
|
51849
|
+
const outputDir = path59.join(
|
|
51014
51850
|
input.deps.storeDir,
|
|
51015
51851
|
"work",
|
|
51016
51852
|
"outputs",
|
|
51017
51853
|
safeName2(input.session.id)
|
|
51018
51854
|
);
|
|
51019
|
-
await
|
|
51020
|
-
const destination =
|
|
51021
|
-
await
|
|
51855
|
+
await fs25.mkdir(outputDir, { recursive: true, mode: 448 });
|
|
51856
|
+
const destination = path59.join(outputDir, `001-${randomUUID23()}-${title}`);
|
|
51857
|
+
await fs25.writeFile(destination, bytes2, { mode: 384 });
|
|
51022
51858
|
const outputRef = FileOutputRefSchema.parse({
|
|
51023
51859
|
kind: "file",
|
|
51024
51860
|
id: `output-${createHash16("sha256").update(destination).digest("hex").slice(0, 24)}`,
|
|
@@ -51055,25 +51891,25 @@ async function executeLocalWorkspaceTool(input) {
|
|
|
51055
51891
|
}
|
|
51056
51892
|
async function ensureLayout(root) {
|
|
51057
51893
|
await Promise.all(["inputs", "work", "outputs"].map(
|
|
51058
|
-
(area) =>
|
|
51894
|
+
(area) => fs25.mkdir(path59.join(root, area), { recursive: true, mode: 448 })
|
|
51059
51895
|
));
|
|
51060
51896
|
}
|
|
51061
51897
|
function localPath(root, value) {
|
|
51062
51898
|
const normalized = value.replaceAll("\\", "/").replace(/^\/+/, "").replace(/^workspace(?:\/|$)/, "");
|
|
51063
|
-
const target =
|
|
51064
|
-
if (target !== root && !target.startsWith(`${root}${
|
|
51899
|
+
const target = path59.resolve(root, normalized);
|
|
51900
|
+
if (target !== root && !target.startsWith(`${root}${path59.sep}`)) {
|
|
51065
51901
|
throw new Error("Local Work path escaped its isolated workspace.");
|
|
51066
51902
|
}
|
|
51067
51903
|
return target;
|
|
51068
51904
|
}
|
|
51069
51905
|
async function listFiles2(root, target, recursive) {
|
|
51070
|
-
const stat7 = await
|
|
51906
|
+
const stat7 = await fs25.stat(target).catch(() => null);
|
|
51071
51907
|
if (!stat7) return [];
|
|
51072
51908
|
if (!stat7.isDirectory()) return [relative(root, target)];
|
|
51073
|
-
const entries = await
|
|
51909
|
+
const entries = await fs25.readdir(target, { withFileTypes: true });
|
|
51074
51910
|
const files = [];
|
|
51075
51911
|
for (const entry of entries.sort((left, right) => left.name.localeCompare(right.name))) {
|
|
51076
|
-
const item =
|
|
51912
|
+
const item = path59.join(target, entry.name);
|
|
51077
51913
|
files.push(relative(root, item));
|
|
51078
51914
|
if (recursive && entry.isDirectory()) files.push(...await listFiles2(root, item, true));
|
|
51079
51915
|
if (files.length >= 1e3) break;
|
|
@@ -51082,8 +51918,8 @@ async function listFiles2(root, target, recursive) {
|
|
|
51082
51918
|
}
|
|
51083
51919
|
function runCommand5(command, cwd, timeoutMs) {
|
|
51084
51920
|
return new Promise((resolve) => {
|
|
51085
|
-
const nodeRuntimeRoot =
|
|
51086
|
-
const localPythonRoot =
|
|
51921
|
+
const nodeRuntimeRoot = path59.dirname(path59.dirname(process.execPath));
|
|
51922
|
+
const localPythonRoot = path59.join(os8.homedir(), ".local", "lib");
|
|
51087
51923
|
const sandboxArgs = [
|
|
51088
51924
|
"--tmpfs",
|
|
51089
51925
|
"/",
|
|
@@ -51135,7 +51971,7 @@ function runCommand5(command, cwd, timeoutMs) {
|
|
|
51135
51971
|
"-lc",
|
|
51136
51972
|
command
|
|
51137
51973
|
];
|
|
51138
|
-
|
|
51974
|
+
execFile9(
|
|
51139
51975
|
"/bin/bwrap",
|
|
51140
51976
|
sandboxArgs,
|
|
51141
51977
|
{ cwd, timeout: timeoutMs, maxBuffer: 4 * 1024 * 1024 },
|
|
@@ -51202,7 +52038,7 @@ function integer(value, fallback, minimum, maximum) {
|
|
|
51202
52038
|
return typeof value === "number" && Number.isInteger(value) ? Math.min(maximum, Math.max(minimum, value)) : fallback;
|
|
51203
52039
|
}
|
|
51204
52040
|
function relative(root, target) {
|
|
51205
|
-
return
|
|
52041
|
+
return path59.relative(root, target).replaceAll(path59.sep, "/");
|
|
51206
52042
|
}
|
|
51207
52043
|
function safeName2(value) {
|
|
51208
52044
|
return value.replace(/[^a-zA-Z0-9._-]+/g, "-").replace(/^-+|-+$/g, "") || "output";
|
|
@@ -51257,12 +52093,12 @@ function createBenchmarkRuntimeComposition(input) {
|
|
|
51257
52093
|
// ../server/src/training/dataset-storage-service.ts
|
|
51258
52094
|
import { constants as constants3 } from "node:fs";
|
|
51259
52095
|
import { access as access4, mkdir as mkdir12, readFile as readFile18, rename as rename5, statfs as statfs2, writeFile as writeFile8 } from "node:fs/promises";
|
|
51260
|
-
import
|
|
52096
|
+
import path61 from "node:path";
|
|
51261
52097
|
|
|
51262
52098
|
// ../server/src/training/dataset-storage-discovery.ts
|
|
51263
52099
|
import { readdir as readdir4, readFile as readFile17 } from "node:fs/promises";
|
|
51264
52100
|
import os9 from "node:os";
|
|
51265
|
-
import
|
|
52101
|
+
import path60 from "node:path";
|
|
51266
52102
|
var NETWORK_FILE_SYSTEMS = /* @__PURE__ */ new Set([
|
|
51267
52103
|
"9p",
|
|
51268
52104
|
"afpfs",
|
|
@@ -51348,7 +52184,7 @@ function parseLinuxMountInfo(value, storeDir) {
|
|
|
51348
52184
|
candidates.push({
|
|
51349
52185
|
kind,
|
|
51350
52186
|
label: driveLabel(mountPath, source, kind),
|
|
51351
|
-
datasetStorePath: mountPath === "/" ?
|
|
52187
|
+
datasetStorePath: mountPath === "/" ? path60.join(storeDir, "datasets") : path60.join(mountPath, "OpenPond", "datasets"),
|
|
51352
52188
|
path: mountPath
|
|
51353
52189
|
});
|
|
51354
52190
|
}
|
|
@@ -51367,7 +52203,7 @@ function parseMacMountOutput(value, storeDir) {
|
|
|
51367
52203
|
candidates.push({
|
|
51368
52204
|
kind,
|
|
51369
52205
|
label: driveLabel(mountPath, source, kind),
|
|
51370
|
-
datasetStorePath: mountPath === "/" ?
|
|
52206
|
+
datasetStorePath: mountPath === "/" ? path60.join(storeDir, "datasets") : path60.join(mountPath, "OpenPond", "datasets"),
|
|
51371
52207
|
path: mountPath
|
|
51372
52208
|
});
|
|
51373
52209
|
}
|
|
@@ -51390,11 +52226,11 @@ function parseWindowsLogicalDisks(value, storeDir) {
|
|
|
51390
52226
|
const root = `${deviceId}\\`;
|
|
51391
52227
|
const volumeName = typeof record11.VolumeName === "string" ? record11.VolumeName.trim() : "";
|
|
51392
52228
|
const kind = driveType === 4 ? "network" : driveType === 2 ? "removable" : "local";
|
|
51393
|
-
const storeRoot =
|
|
52229
|
+
const storeRoot = path60.win32.parse(path60.win32.resolve(storeDir)).root.toLowerCase();
|
|
51394
52230
|
return [{
|
|
51395
52231
|
kind,
|
|
51396
52232
|
label: volumeName || (root.toLowerCase() === storeRoot ? "System disk" : deviceId.toUpperCase()),
|
|
51397
|
-
datasetStorePath: root.toLowerCase() === storeRoot ?
|
|
52233
|
+
datasetStorePath: root.toLowerCase() === storeRoot ? path60.win32.join(storeDir, "datasets") : path60.win32.join(root, "OpenPond", "datasets"),
|
|
51398
52234
|
path: root
|
|
51399
52235
|
}];
|
|
51400
52236
|
});
|
|
@@ -51408,25 +52244,25 @@ function storageKindForPath(value) {
|
|
|
51408
52244
|
}
|
|
51409
52245
|
async function discoverGvfsCandidates() {
|
|
51410
52246
|
const uid = typeof process.getuid === "function" ? process.getuid() : os9.userInfo().uid;
|
|
51411
|
-
const gvfsRoot =
|
|
52247
|
+
const gvfsRoot = path60.join("/run/user", String(uid), "gvfs");
|
|
51412
52248
|
const entries = await readdir4(gvfsRoot, { withFileTypes: true }).catch(() => []);
|
|
51413
52249
|
return entries.flatMap((entry) => {
|
|
51414
52250
|
if (!entry.isDirectory()) return [];
|
|
51415
|
-
const mountedPath =
|
|
52251
|
+
const mountedPath = path60.join(gvfsRoot, entry.name);
|
|
51416
52252
|
return [{
|
|
51417
52253
|
kind: "network",
|
|
51418
52254
|
label: labelForGvfsMount(entry.name),
|
|
51419
|
-
datasetStorePath:
|
|
52255
|
+
datasetStorePath: path60.join(mountedPath, "OpenPond", "datasets"),
|
|
51420
52256
|
path: mountedPath
|
|
51421
52257
|
}];
|
|
51422
52258
|
});
|
|
51423
52259
|
}
|
|
51424
52260
|
function systemStorageCandidate(storeDir, platform) {
|
|
51425
|
-
const root =
|
|
52261
|
+
const root = path60.parse(path60.resolve(storeDir)).root;
|
|
51426
52262
|
return {
|
|
51427
52263
|
kind: "local",
|
|
51428
52264
|
label: "System disk",
|
|
51429
|
-
datasetStorePath:
|
|
52265
|
+
datasetStorePath: path60.join(storeDir, "datasets"),
|
|
51430
52266
|
path: platform === "win32" ? root : root || "/"
|
|
51431
52267
|
};
|
|
51432
52268
|
}
|
|
@@ -51445,12 +52281,12 @@ function storageKind(input) {
|
|
|
51445
52281
|
}
|
|
51446
52282
|
function driveLabel(mountPath, source, kind) {
|
|
51447
52283
|
if (mountPath === "/") return "System disk";
|
|
51448
|
-
const mountName =
|
|
52284
|
+
const mountName = path60.basename(mountPath);
|
|
51449
52285
|
if (kind === "network") {
|
|
51450
52286
|
const sourceName = source.replace(/\/+$/, "").split("/").pop();
|
|
51451
52287
|
return decodeSafely(sourceName || mountName || source);
|
|
51452
52288
|
}
|
|
51453
|
-
return decodeSafely(mountName ||
|
|
52289
|
+
return decodeSafely(mountName || path60.basename(source) || source);
|
|
51454
52290
|
}
|
|
51455
52291
|
function labelForGvfsMount(name) {
|
|
51456
52292
|
const separator = name.indexOf(":");
|
|
@@ -51484,7 +52320,7 @@ function uniqueCandidates2(candidates) {
|
|
|
51484
52320
|
return [...unique2.values()];
|
|
51485
52321
|
}
|
|
51486
52322
|
function normalizedPath(value) {
|
|
51487
|
-
const normalized =
|
|
52323
|
+
const normalized = path60.normalize(value);
|
|
51488
52324
|
return process.platform === "win32" ? normalized.toLowerCase() : normalized;
|
|
51489
52325
|
}
|
|
51490
52326
|
|
|
@@ -51545,15 +52381,15 @@ var runCommandProbe = async (executable, args, options = {}) => {
|
|
|
51545
52381
|
|
|
51546
52382
|
// ../server/src/training/dataset-storage-service.ts
|
|
51547
52383
|
function createDatasetStorageService(input) {
|
|
51548
|
-
const directory =
|
|
51549
|
-
const settingsPath =
|
|
52384
|
+
const directory = path61.join(input.storeDir, "datasets");
|
|
52385
|
+
const settingsPath = path61.join(directory, "settings.json");
|
|
51550
52386
|
async function settings() {
|
|
51551
52387
|
try {
|
|
51552
52388
|
return DatasetStorageSettingsSchema.parse(JSON.parse(await readFile18(settingsPath, "utf8")));
|
|
51553
52389
|
} catch {
|
|
51554
52390
|
return DatasetStorageSettingsSchema.parse({
|
|
51555
52391
|
schemaVersion: "openpond.datasetStorageSettings.v1",
|
|
51556
|
-
datasetStorePath:
|
|
52392
|
+
datasetStorePath: path61.join(input.storeDir, "datasets"),
|
|
51557
52393
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
51558
52394
|
});
|
|
51559
52395
|
}
|
|
@@ -51565,7 +52401,7 @@ function createDatasetStorageService(input) {
|
|
|
51565
52401
|
platform: process.platform,
|
|
51566
52402
|
storeDir: input.storeDir
|
|
51567
52403
|
});
|
|
51568
|
-
if (!candidates.some((candidate2) =>
|
|
52404
|
+
if (!candidates.some((candidate2) => path61.resolve(candidate2.datasetStorePath) === path61.resolve(current.datasetStorePath))) {
|
|
51569
52405
|
candidates.push({
|
|
51570
52406
|
datasetStorePath: current.datasetStorePath,
|
|
51571
52407
|
kind: storageKindForPath(current.datasetStorePath),
|
|
@@ -51579,7 +52415,7 @@ function createDatasetStorageService(input) {
|
|
|
51579
52415
|
return {
|
|
51580
52416
|
...candidate2,
|
|
51581
52417
|
id: `dataset-storage-${Buffer.from(candidate2.path).toString("base64url").slice(0, 120)}`,
|
|
51582
|
-
configured:
|
|
52418
|
+
configured: path61.resolve(candidate2.datasetStorePath) === path61.resolve(current.datasetStorePath),
|
|
51583
52419
|
mounted: stats !== null,
|
|
51584
52420
|
freeBytes: stats ? Number(stats.bavail) * Number(stats.bsize) : null,
|
|
51585
52421
|
totalBytes: stats ? Number(stats.blocks) * Number(stats.bsize) : null,
|
|
@@ -51596,7 +52432,7 @@ function createDatasetStorageService(input) {
|
|
|
51596
52432
|
const request = UpdateDatasetStorageSettingsRequestSchema.parse(value);
|
|
51597
52433
|
const updated = DatasetStorageSettingsSchema.parse({
|
|
51598
52434
|
schemaVersion: "openpond.datasetStorageSettings.v1",
|
|
51599
|
-
datasetStorePath:
|
|
52435
|
+
datasetStorePath: path61.resolve(request.datasetStorePath),
|
|
51600
52436
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
51601
52437
|
});
|
|
51602
52438
|
if (!await ensureWritable(updated.datasetStorePath)) {
|
|
@@ -51752,10 +52588,10 @@ function createManagedAdapterRegistryClient(dependencies = {}) {
|
|
|
51752
52588
|
const fetchImpl = dependencies.fetchImpl ?? fetch;
|
|
51753
52589
|
const resolveRegistryAccess = dependencies.resolveRegistryAccess ?? ((teamId) => resolveManagedAdapterUserAccess({ teamId }));
|
|
51754
52590
|
const resolveInferenceAccess = dependencies.resolveInferenceAccess ?? ((teamId) => resolveManagedAdapterUserAccess({ teamId }));
|
|
51755
|
-
async function requestJson2(resolveAccess, teamId,
|
|
52591
|
+
async function requestJson2(resolveAccess, teamId, path63, init = {}) {
|
|
51756
52592
|
const access5 = await resolveAccess(teamId);
|
|
51757
52593
|
assertResolvedTeam(access5.teamId, teamId);
|
|
51758
|
-
const requestUrl = `${access5.apiBaseUrl}${
|
|
52594
|
+
const requestUrl = `${access5.apiBaseUrl}${path63}`;
|
|
51759
52595
|
const headers = withVercelProtectionBypass(
|
|
51760
52596
|
requestUrl,
|
|
51761
52597
|
hostedApiAuthHeaders(access5.token),
|
|
@@ -52385,10 +53221,10 @@ async function createOpenPondServer(options = {}) {
|
|
|
52385
53221
|
const harnessEvaluationReviewStream = createLocalHarnessEvaluationReviewModelStream(streamOpenPondHostedChatTurn2);
|
|
52386
53222
|
const executeWebSearch = createWebSearchExecutorFromEnv();
|
|
52387
53223
|
const executeConnectedAppTool = createCloudConnectedAppToolExecutor();
|
|
52388
|
-
const attachmentRootDir =
|
|
53224
|
+
const attachmentRootDir = path62.join(storeDir, "attachments");
|
|
52389
53225
|
const logger = createLogger({
|
|
52390
53226
|
channel: "server",
|
|
52391
|
-
logDir:
|
|
53227
|
+
logDir: path62.join(storeDir, "logs"),
|
|
52392
53228
|
metadata: {
|
|
52393
53229
|
version,
|
|
52394
53230
|
runtimeVersion
|
|
@@ -52578,14 +53414,27 @@ async function createOpenPondServer(options = {}) {
|
|
|
52578
53414
|
store,
|
|
52579
53415
|
defaultSessionCwd,
|
|
52580
53416
|
createManagedLocalWorkCwd: async (sessionId) => {
|
|
52581
|
-
const workspacePath =
|
|
52582
|
-
await
|
|
53417
|
+
const workspacePath = path62.join(storeDir, "work", "tasks", sessionId);
|
|
53418
|
+
await fs26.mkdir(workspacePath, { recursive: true, mode: 448 });
|
|
52583
53419
|
return workspacePath;
|
|
52584
53420
|
},
|
|
52585
53421
|
loadAppPreferences,
|
|
52586
53422
|
appendRuntimeEvent,
|
|
52587
53423
|
loadLastUsedProfile: async () => (await loadOpenPondProfileLibrary()).lastUsed
|
|
52588
53424
|
});
|
|
53425
|
+
const sessionTitleService = createSessionTitleService({
|
|
53426
|
+
appendRuntimeEvent,
|
|
53427
|
+
getSession,
|
|
53428
|
+
logger,
|
|
53429
|
+
stream: streamOpenPondHostedChatTurn2,
|
|
53430
|
+
updateSession
|
|
53431
|
+
});
|
|
53432
|
+
const createSessionWithAutoTitle = async (payload) => {
|
|
53433
|
+
const prompt = autoTitlePromptFromPayload(payload);
|
|
53434
|
+
const session = await createSession(withPendingAutoTitle(payload));
|
|
53435
|
+
if (prompt) sessionTitleService.schedule(session.id, prompt);
|
|
53436
|
+
return session;
|
|
53437
|
+
};
|
|
52589
53438
|
const {
|
|
52590
53439
|
activeWorkspace,
|
|
52591
53440
|
appendWorkspaceDiffEvent,
|
|
@@ -52682,7 +53531,7 @@ async function createOpenPondServer(options = {}) {
|
|
|
52682
53531
|
const tasksetAuthoringSkillText = tasksetAuthoringSkillArtifact.bundle;
|
|
52683
53532
|
const taskCreatorService = createTaskCreatorService({
|
|
52684
53533
|
store,
|
|
52685
|
-
tasksetRootDir:
|
|
53534
|
+
tasksetRootDir: path62.join(storeDir, "training", "tasksets"),
|
|
52686
53535
|
authoringSkillHash: contentHash(tasksetAuthoringSkillText),
|
|
52687
53536
|
loadCodexHistoryThread: (sessionId) => readCodexHistoryThreadPayload(sessionId, {
|
|
52688
53537
|
attachmentRootDir,
|
|
@@ -52711,7 +53560,7 @@ async function createOpenPondServer(options = {}) {
|
|
|
52711
53560
|
});
|
|
52712
53561
|
const datasetArtifactService = createDatasetArtifactService({
|
|
52713
53562
|
store,
|
|
52714
|
-
workerProjectDir:
|
|
53563
|
+
workerProjectDir: path62.resolve(process.cwd(), "python", "openpond-datasets")
|
|
52715
53564
|
});
|
|
52716
53565
|
const {
|
|
52717
53566
|
benchmarkTasksets,
|
|
@@ -52815,7 +53664,7 @@ async function createOpenPondServer(options = {}) {
|
|
|
52815
53664
|
const trainingChatSearchService = createTrainingChatSearchService({ store });
|
|
52816
53665
|
const datasetImportService = createDatasetImportService({
|
|
52817
53666
|
store,
|
|
52818
|
-
workerProjectDir:
|
|
53667
|
+
workerProjectDir: path62.resolve(
|
|
52819
53668
|
process.cwd(),
|
|
52820
53669
|
"python",
|
|
52821
53670
|
"openpond-datasets"
|
|
@@ -53039,7 +53888,7 @@ async function createOpenPondServer(options = {}) {
|
|
|
53039
53888
|
nextStep: response2.items.length === 0 ? "There are no pinned or saved files." : `Listed ${response2.items.length} sidebar file${response2.items.length === 1 ? "" : "s"}.`
|
|
53040
53889
|
};
|
|
53041
53890
|
}
|
|
53042
|
-
const
|
|
53891
|
+
const path63 = normalizeSidebarFilePath(requestedPath ?? "");
|
|
53043
53892
|
const workspaceId = session.workspaceId ?? session.localProjectId ?? session.appId;
|
|
53044
53893
|
if (!workspaceId) {
|
|
53045
53894
|
throw new Error(
|
|
@@ -53052,18 +53901,18 @@ async function createOpenPondServer(options = {}) {
|
|
|
53052
53901
|
workspaceKind,
|
|
53053
53902
|
workspaceId,
|
|
53054
53903
|
workspaceName,
|
|
53055
|
-
path:
|
|
53904
|
+
path: path63,
|
|
53056
53905
|
status: action === "pin" ? "pinned" : action === "save_for_later" ? "saved_for_later" : "none",
|
|
53057
53906
|
sourceSessionId: session.id
|
|
53058
53907
|
});
|
|
53059
53908
|
const changed = response.items.find(
|
|
53060
|
-
(item) => item.workspaceKind === workspaceKind && item.workspaceId === workspaceId && item.path ===
|
|
53909
|
+
(item) => item.workspaceKind === workspaceKind && item.workspaceId === workspaceId && item.path === path63
|
|
53061
53910
|
) ?? null;
|
|
53062
53911
|
const verb = action === "pin" ? "Pinned" : action === "save_for_later" ? "Saved" : "Removed";
|
|
53063
53912
|
return {
|
|
53064
53913
|
...response,
|
|
53065
53914
|
changed,
|
|
53066
|
-
nextStep: `${verb} ${
|
|
53915
|
+
nextStep: `${verb} ${path63}${action === "save_for_later" ? " for later" : ""}.`
|
|
53067
53916
|
};
|
|
53068
53917
|
},
|
|
53069
53918
|
listIntegrationConnections: listSandboxIntegrationConnections,
|
|
@@ -53579,13 +54428,14 @@ async function createOpenPondServer(options = {}) {
|
|
|
53579
54428
|
});
|
|
53580
54429
|
const harnessEvaluationReviewScheduler = createLocalHarnessEvaluationReviewScheduler({
|
|
53581
54430
|
store,
|
|
54431
|
+
storeDir,
|
|
53582
54432
|
stream: harnessEvaluationReviewStream,
|
|
53583
54433
|
isClosing: () => closing,
|
|
53584
54434
|
logger
|
|
53585
54435
|
});
|
|
53586
54436
|
const agentRuntime = createAppServer({
|
|
53587
54437
|
ports: createAgentRuntimePorts({
|
|
53588
|
-
createSession,
|
|
54438
|
+
createSession: createSessionWithAutoTitle,
|
|
53589
54439
|
getSession,
|
|
53590
54440
|
turnsForSession: (sessionId) => store.turnsForSession(sessionId, 1e3),
|
|
53591
54441
|
runtimeEventsForSession: (sessionId) => store.runtimeEventsForSession(sessionId),
|
|
@@ -53599,7 +54449,8 @@ async function createOpenPondServer(options = {}) {
|
|
|
53599
54449
|
reviewHarness: (request) => reviewSelectedLocalHarnessEvaluation({
|
|
53600
54450
|
store,
|
|
53601
54451
|
request,
|
|
53602
|
-
stream: harnessEvaluationReviewStream
|
|
54452
|
+
stream: harnessEvaluationReviewStream,
|
|
54453
|
+
continuation: { storeDir, stream: harnessEvaluationReviewStream }
|
|
53603
54454
|
}),
|
|
53604
54455
|
acceptHarnessEvaluationReview: async (request) => {
|
|
53605
54456
|
const profile = await loadOpenPondProfileState();
|
|
@@ -53763,7 +54614,7 @@ async function createOpenPondServer(options = {}) {
|
|
|
53763
54614
|
browserControlComplete: browserControlQueue.completeRequest,
|
|
53764
54615
|
browserControlStatus: browserControlQueue.status,
|
|
53765
54616
|
agentRuntime,
|
|
53766
|
-
createSession,
|
|
54617
|
+
createSession: createSessionWithAutoTitle,
|
|
53767
54618
|
patchSession: patchSessionPayload,
|
|
53768
54619
|
sendTurn,
|
|
53769
54620
|
runSessionCommand: runSessionCommandPayload,
|