@nervekit/desktop 0.40.1 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -2
- package/THIRD-PARTY-LICENSES.txt +968 -30
- package/dist/bin.js +1 -0
- package/dist/{chunk-OY6PIAR7.js → chunk-2ICPO4UM.js} +5 -5
- package/dist/{chunk-SQ7CWNIT.js → chunk-3CZXUKLG.js} +1 -1
- package/dist/{chunk-QFXKQNMT.js → chunk-4OCDR4DU.js} +14 -17
- package/dist/chunk-62DQXVPO.js +69 -0
- package/dist/chunk-6GUJQURI.js +142 -0
- package/dist/{chunk-CEX2GWGZ.js → chunk-6IHXVT5H.js} +1 -1
- package/dist/{chunk-MH3SUHI2.js → chunk-6ZS7TA6E.js} +2 -2
- package/dist/chunk-7FSH3ABG.js +249 -0
- package/dist/chunk-7HGFEQSD.js +224 -0
- package/dist/chunk-7RPHIJT3.js +153 -0
- package/dist/{chunk-5Y3NEEOK.js → chunk-AAEIGAGD.js} +9 -9
- package/dist/{chunk-HKLAYK2Z.js → chunk-APY4TUR3.js} +210 -0
- package/dist/chunk-BACYVEE6.js +128 -0
- package/dist/chunk-BG2KGLIA.js +783 -0
- package/dist/{chunk-XBHEYY65.js → chunk-BN5YDZUZ.js} +1205 -326
- package/dist/chunk-BUD4JHBZ.js +7017 -0
- package/dist/{chunk-MN7PZ2PH.js → chunk-DDBE2VLT.js} +2 -2
- package/dist/chunk-EF7ZZKA3.js +168 -0
- package/dist/{chunk-TJR6ASRW.js → chunk-EUT45AKW.js} +22 -24
- package/dist/{chunk-L3YB2QLN.js → chunk-FCAIYPDJ.js} +2 -2
- package/dist/{chunk-AJGPULMX.js → chunk-FZ557YWE.js} +47603 -55411
- package/dist/chunk-HPINJGBO.js +359 -0
- package/dist/{chunk-H5UKINTD.js → chunk-IRRR3PWN.js} +68 -65
- package/dist/{chunk-CWHAK2HX.js → chunk-IVBMHEPK.js} +33 -55
- package/dist/{chunk-FESN7DND.js → chunk-JBEWFFOK.js} +1 -1
- package/dist/{chunk-CKVFGRVV.js → chunk-KEXKZKN4.js} +54 -7
- package/dist/{chunk-UGDIHDAR.js → chunk-KUFIFCB4.js} +1 -1
- package/dist/chunk-L5WGVYXM.js +42 -0
- package/dist/{chunk-ONWQH2W6.js → chunk-LGIIT2NF.js} +15 -18
- package/dist/{chunk-KSZJ3HGD.js → chunk-LP4APBBQ.js} +1 -1
- package/dist/{chunk-DBXMYYPJ.js → chunk-M3ELKCNA.js} +1 -1
- package/dist/chunk-MI6L5CEA.js +183 -0
- package/dist/chunk-N4OXAS3A.js +40 -0
- package/dist/chunk-N6BUYKF3.js +340 -0
- package/dist/{chunk-KIGB3FK6.js → chunk-NVVW3MWJ.js} +9 -8
- package/dist/{chunk-V53CETNZ.js → chunk-O5JHHRFN.js} +242 -105
- package/dist/{chunk-KQPEOUCA.js → chunk-O6FDXE54.js} +19 -23
- package/dist/{chunk-QWTKCUIZ.js → chunk-OMCM3MHS.js} +11 -9
- package/dist/{chunk-55OGZFNA.js → chunk-P72Y5ZBH.js} +31 -15
- package/dist/{chunk-AON37AL2.js → chunk-PVPJAGWR.js} +29 -4
- package/dist/{chunk-24GQ74HM.js → chunk-Q3C7TQ2M.js} +3 -3
- package/dist/chunk-Q5E4ZL2R.js +14 -0
- package/dist/chunk-QFK2SWD2.js +258 -0
- package/dist/chunk-RJR7DJJK.js +32 -0
- package/dist/{chunk-BXVRC3HF.js → chunk-RL52LSTV.js} +1 -1
- package/dist/{chunk-KAZFF2RD.js → chunk-RTB6CF7F.js} +137 -113
- package/dist/{chunk-TW6FURZ7.js → chunk-SDDKYMIP.js} +18313 -4317
- package/dist/{chunk-S2PITDVA.js → chunk-TQURLRHD.js} +1 -1
- package/dist/{chunk-2Z5FLMLE.js → chunk-TSAUBRRU.js} +1 -1
- package/dist/chunk-U3TEC52G.js +64 -0
- package/dist/chunk-U5KGV63C.js +39 -0
- package/dist/{chunk-FOFVPPPV.js → chunk-UVRULOOP.js} +10 -9
- package/dist/{chunk-QVHYARC2.js → chunk-VOATSLRG.js} +5 -1
- package/dist/{chunk-WXRYBXYR.js → chunk-W7LEYYFH.js} +53 -65
- package/dist/chunk-WC5HHPPM.js +22 -0
- package/dist/{chunk-3DGBM7UW.js → chunk-WG62RHZ2.js} +3 -3
- package/dist/{chunk-D7WIIZAV.js → chunk-WIQEPAUG.js} +10 -9
- package/dist/chunk-XM27UVWN.js +250 -0
- package/dist/{chunk-4MMJDHFX.js → chunk-XTUSLUQ7.js} +70 -71
- package/dist/{chunk-N5B2RRSS.js → chunk-Z6AY5VOZ.js} +47 -26
- package/dist/{chunk-I6NVW4NX.js → chunk-ZGWXLG5X.js} +29 -33
- package/dist/{chunk-XNYZEQ3U.js → chunk-ZUWBEV2O.js} +1 -1
- package/dist/chunk-ZVH6EB7S.js +29 -0
- package/dist/daemon.js +65 -26
- package/dist/extension-assets/atlassian/docs/confluence-raw.md +31 -0
- package/dist/extension-assets/atlassian/docs/confluence-writing.md +101 -0
- package/dist/extension-assets/atlassian/docs/jira-raw.md +16 -0
- package/dist/extension-assets/atlassian/docs/jira-workflows.md +77 -0
- package/dist/extension-assets/atlassian/docs/project-knowledge.md +25 -0
- package/dist/extension-assets/atlassian/docs/storage.md +58 -0
- package/dist/extension-assets/atlassian/icon.svg +20 -0
- package/dist/extension-assets/diagram/docs/diagrams.md +12 -0
- package/dist/extension-assets/imagegen/docs/imagegen.md +17 -0
- package/dist/extension-assets/web-search/icon.svg +1 -0
- package/dist/git-isolated-reader-helper.js +1 -1
- package/dist/html-to-markdown.worker.js +6 -7028
- package/dist/main.js +583 -164
- package/dist/preload.cjs +45 -2
- package/dist/quick-script-docs/runtime/documents.md +54 -0
- package/dist/quick-script-docs/runtime/files.md +11 -0
- package/dist/quick-script-docs/runtime/images.md +10 -0
- package/dist/sandbox-libraries/docx.LICENSE +21 -0
- package/dist/sandbox-libraries/docx.min.js +9 -0
- package/dist/sandbox-libraries/jszip.LICENSE +651 -0
- package/dist/sandbox-libraries/jszip.min.js +13 -0
- package/dist/sandbox-libraries/mammoth.LICENSE +22 -0
- package/dist/sandbox-libraries/mammoth.browser.min.js +13 -0
- package/dist/sandbox-libraries/papaparse.LICENSE +20 -0
- package/dist/sandbox-libraries/papaparse.min.js +7 -0
- package/dist/sandbox-libraries/pptxgen.bundle.js +96 -0
- package/dist/sandbox-libraries/pptxgenjs.LICENSE +21 -0
- package/dist/sandbox-libraries/xlsx.LICENSE +201 -0
- package/dist/sandbox-libraries/xlsx.full.min.js +24 -0
- package/dist/web/assets/{AsyncBashCenterHost-HGsdxUJ3.js → AsyncBashCenterHost-D2Sy43Ub.js} +1 -1
- package/dist/web/assets/ConversationListItem-DvxCcAYm.js +3 -0
- package/dist/web/assets/ConversationsWorkbenchPanel-YeNq9LRn.js +1 -0
- package/dist/web/assets/DiscoverCenterHost-B6K-QnBF.js +1 -0
- package/dist/web/assets/{FileCenterHost-DigJOU5M.js → FileCenterHost-Dlk53K5G.js} +1 -1
- package/dist/web/assets/FilesWorkbenchPanel-PeCu12oU.js +12 -0
- package/dist/web/assets/{GitDiffCenterHost-IuZfF3hG.js → GitDiffCenterHost-3_Ea0RyG.js} +1 -1
- package/dist/web/assets/{GitWorkbenchPanel-CScC0CfH.js → GitWorkbenchPanel-CYvCkOAW.js} +1 -1
- package/dist/web/assets/{LaunchCenterHost-CIu7bcoZ.js → LaunchCenterHost-CP773N_3.js} +1 -1
- package/dist/web/assets/LaunchConfigurationNotice-CtmZ1uIQ.js +1 -0
- package/dist/web/assets/{LaunchesWorkbenchPanel-Vy0Gm7gg.js → LaunchesWorkbenchPanel-DP3yVfkO.js} +1 -1
- package/dist/web/assets/LogsCenterHost-BFP0doQf.js +1 -0
- package/dist/web/assets/{MermaidCenterHost-DDh4ArdK.js → MermaidCenterHost-Bjl6Dvrq.js} +1 -1
- package/dist/web/assets/MobileFilesBody-CDp21MGZ.js +1 -0
- package/dist/web/assets/{MobileFilesHost-C1jev2Un.js → MobileFilesHost-DlJI_yau.js} +1 -1
- package/dist/web/assets/MobileLaunchOutputHost-y3TehLWF.js +1 -0
- package/dist/web/assets/MobileLaunchesHost-CBNtDTrs.js +2 -0
- package/dist/web/assets/MobileLogsHost-BSb2lydK.js +1 -0
- package/dist/web/assets/MobileNoteEditorHost-7yW7hIC2.js +1 -0
- package/dist/web/assets/{MobileNotesHost-BZeYpK9H.js → MobileNotesHost-CvDHzpAh.js} +1 -1
- package/dist/web/assets/{MobileProjectSettingsHost-U3Mx3EN8.js → MobileProjectSettingsHost-CjtPfyKT.js} +1 -1
- package/dist/web/assets/{MobileProjectSettingsPageHost-CMvxbjfs.js → MobileProjectSettingsPageHost-j_7N-B9L.js} +1 -1
- package/dist/web/assets/{MobileSettingsHost-CP8Z_-gH.js → MobileSettingsHost-DXIKNF01.js} +1 -1
- package/dist/web/assets/{MobileSettingsPageHost-BPjXKTMV.js → MobileSettingsPageHost-CEzo7J9p.js} +1 -1
- package/dist/web/assets/MobileSettingsPageScreen-99wMLRsn.js +1 -0
- package/dist/web/assets/NotesWorkbenchPanel-DqTwXBBv.js +1 -0
- package/dist/web/assets/ProjectSettingsCenterHost-D96cL0uH.js +1 -0
- package/dist/web/assets/{PullRequestCenterHost-CZhXfCX2.js → PullRequestCenterHost-DY0yPDK2.js} +1 -1
- package/dist/web/assets/PullRequestsWorkbenchPanel-D07LE8vJ.js +1 -0
- package/dist/web/assets/{SearchWorkbenchPanel-qLgszneN.js → SearchWorkbenchPanel-D2_3iXo8.js} +1 -1
- package/dist/web/assets/SettingsCenter-BQWc24di.js +1 -0
- package/dist/web/assets/SettingsCenterHost-BvgNfeZN.js +1 -0
- package/dist/web/assets/{SystemPromptCenterHost-ya5AvXsd.js → SystemPromptCenterHost-BLHkB7lp.js} +1 -1
- package/dist/web/assets/activity-notices-C9aphS1s.js +1 -0
- package/dist/web/assets/adapters-DNU88KT0.js +1 -0
- package/dist/web/assets/agent-profiles.svelte-DgI8wSS2.js +1 -0
- package/dist/web/assets/api-CHNbLvvY.js +1 -0
- package/dist/web/assets/center-tabs.svelte-CyhCD_6b.js +1 -0
- package/dist/web/assets/channel-6wGoOwGx.js +57 -0
- package/dist/web/assets/circle-question-mark-C7NgqbLL.js +1 -0
- package/dist/web/assets/code-DJR0pnqV.js +7 -0
- package/dist/web/assets/{confirm-dialog-Bw_IxcZD.js → confirm-dialog-BDjzMiC4.js} +1 -1
- package/dist/web/assets/{conversation-connection-3GxIuhbS.js → conversation-connection-mLNyfV2d.js} +1 -1
- package/dist/web/assets/dialog-CkRcLEJT.js +1 -0
- package/dist/web/assets/discover-Dh4m7djO.js +4 -0
- package/dist/web/assets/dist-DSApqEag.js +1 -0
- package/dist/web/assets/file-tabs.svelte-cX3MMyG6.js +2 -0
- package/dist/web/assets/filesystem-BbIXrkGB.js +1 -0
- package/dist/web/assets/{git-store.svelte-CM5k7yRU.js → git-store.svelte-D3uwRVnj.js} +1 -1
- package/dist/web/assets/{git.api-D2CfUXZW.js → git.api-CTu-tG8A.js} +1 -1
- package/dist/web/assets/index-BrxjAwg0.js +46 -0
- package/dist/web/assets/index-yEOHI1Z7.css +1 -0
- package/dist/web/assets/launches-CC4gLnSa.js +5 -0
- package/dist/web/assets/{launches.api-BZxyWF8t.js → launches.api-CaotSs6l.js} +1 -1
- package/dist/web/assets/launches.svelte-DDA5J-RZ.js +2 -0
- package/dist/web/assets/{message-square-CqLxHJuW.js → list-checks-zV9Dp7Cu.js} +1 -1
- package/dist/web/assets/{logs.api-Coi8HJuy.js → logs.api-DMmVlkSz.js} +1 -1
- package/dist/web/assets/{maintenance-state.svelte-CDO9i4dk.js → maintenance-state.svelte-l9v7Hg3i.js} +2 -2
- package/dist/web/assets/notify.svelte-BTEXJZ8P.js +1 -0
- package/dist/web/assets/popover-panel-C-weKOk3.js +5 -0
- package/dist/web/assets/pr-view-loader.svelte-C0NClMS6.js +1 -0
- package/dist/web/assets/progress-CKEsTSOk.js +1 -0
- package/dist/web/assets/scratch-notes-state.svelte-B_rY_-9q.js +1 -0
- package/dist/web/assets/{scratch-notes.api-Cbvag3bv.js → scratch-notes.api-B2gOOK6Z.js} +1 -1
- package/dist/web/assets/search-input-CEr0SmAB.js +1 -0
- package/dist/web/assets/settings-2-CWd8Y06n.js +1 -0
- package/dist/web/assets/settings-CRmC19nG.js +1 -0
- package/dist/web/assets/settings-CXoAzSmm.js +1 -0
- package/dist/web/assets/settings-actions.svelte-BB6u_lQ0.js +1 -0
- package/dist/web/assets/settings-page-controllers.svelte-al78EDTL.js +29 -0
- package/dist/web/assets/sheet-content-DauQ7hPL.js +1 -0
- package/dist/web/assets/shell-CYbWnH52.js +4 -0
- package/dist/web/assets/shell-layout.svelte-CmEWk428.js +2 -0
- package/dist/web/assets/textarea-BEZ65po_.js +1 -0
- package/dist/web/assets/views-BumCSQ3W.js +2 -0
- package/dist/web/assets/{workbench-connection-gGGv4o8i.js → workbench-connection-CGHdORw3.js} +1 -1
- package/dist/web/assets/{workspace-Cc47dGjw.js → workspace-CW738NJG.js} +1 -1
- package/dist/web/assets/{workspace-actions.svelte-B3oum_9S.js → workspace-actions.svelte-DL9xv7lJ.js} +1 -1
- package/dist/web/assets/workspace-selectors.svelte-BRJvPEBh.js +105 -0
- package/dist/web/index.html +142 -83
- package/dist/web/sw.js +1 -1
- package/dist/worker.js +14 -9
- package/package.json +8 -9
- package/dist/chunk-RUZ2UAYH.js +0 -365
- package/dist/guides/confluence/SKILL.md +0 -36
- package/dist/guides/jira/SKILL.md +0 -34
- package/dist/resize-worker.js +0 -168
- package/dist/web/assets/ConversationListItem-Caz2KiJH.js +0 -3
- package/dist/web/assets/ConversationsWorkbenchPanel-B6dzWkG1.js +0 -1
- package/dist/web/assets/DiscoverCenterHost-B186WBRA.js +0 -1
- package/dist/web/assets/FilesWorkbenchPanel-VPvx3Bmi.js +0 -12
- package/dist/web/assets/LaunchConfigurationNotice-5yb4cH27.js +0 -1
- package/dist/web/assets/LogsCenterHost-BXBozCYw.js +0 -1
- package/dist/web/assets/MobileFilesBody-Cda_7gDp.js +0 -1
- package/dist/web/assets/MobileLaunchOutputHost-Bsv12o2H.js +0 -1
- package/dist/web/assets/MobileLaunchesHost-C9VH-2bn.js +0 -2
- package/dist/web/assets/MobileLogsHost-BMDXc-WC.js +0 -1
- package/dist/web/assets/MobileNoteEditorHost-BA6WIY1Y.js +0 -1
- package/dist/web/assets/MobileSettingsPageScreen-C5rHdrUU.js +0 -1
- package/dist/web/assets/NotesWorkbenchPanel-Bf6rySTL.js +0 -1
- package/dist/web/assets/ProjectSettingsCenterHost-BVXpBixy.js +0 -1
- package/dist/web/assets/PullRequestsWorkbenchPanel-BBnZJVnI.js +0 -1
- package/dist/web/assets/SettingsCenter-7BfrBfiy.js +0 -1
- package/dist/web/assets/SettingsCenterHost-Ck5uHILP.js +0 -1
- package/dist/web/assets/adapters-DxJoo6Za.js +0 -1
- package/dist/web/assets/agent-profiles.svelte-D5YHPc90.js +0 -1
- package/dist/web/assets/api-eaGLre0q.js +0 -1
- package/dist/web/assets/center-tabs.svelte-JJGozG_H.js +0 -1
- package/dist/web/assets/channel-B503YLZR.js +0 -57
- package/dist/web/assets/chevron-left-DPEFG6UJ.js +0 -1
- package/dist/web/assets/circle-alert-Cp2l2jcj.js +0 -5
- package/dist/web/assets/clock-Db6f9HtS.js +0 -1
- package/dist/web/assets/code-BRQC0Tpn.js +0 -7
- package/dist/web/assets/dialog-DU4gXD1J.js +0 -1
- package/dist/web/assets/discover-B3I5g1_G.js +0 -4
- package/dist/web/assets/dist-B_NFPhKV.js +0 -1
- package/dist/web/assets/file-tabs.svelte-DKtVVVCq.js +0 -2
- package/dist/web/assets/filesystem-ReGivxAC.js +0 -1
- package/dist/web/assets/index-DIQuyMVT.css +0 -1
- package/dist/web/assets/index-FJEmK_L5.js +0 -48
- package/dist/web/assets/launches-DiAl56ED.js +0 -5
- package/dist/web/assets/launches.svelte-BVs1pAhl.js +0 -2
- package/dist/web/assets/notebook-pen-lVsLYSe4.js +0 -1
- package/dist/web/assets/notify.svelte-BKVBraTJ.js +0 -1
- package/dist/web/assets/pencil-BrlypebI.js +0 -1
- package/dist/web/assets/pr-view-loader.svelte-DcIwqDJV.js +0 -1
- package/dist/web/assets/progress-DBCSpVPn.js +0 -1
- package/dist/web/assets/scratch-notes-state.svelte-Br_WiMEp.js +0 -1
- package/dist/web/assets/search-input-zU4WCZiz.js +0 -1
- package/dist/web/assets/settings-2-8MSBUGAl.js +0 -1
- package/dist/web/assets/settings-9LBrw4Nv.js +0 -1
- package/dist/web/assets/settings-B7uXsflY.js +0 -1
- package/dist/web/assets/settings-actions.svelte-B8psX3cj.js +0 -1
- package/dist/web/assets/settings-page-controllers.svelte-CU0i08wo.js +0 -30
- package/dist/web/assets/shell-DB5Db5-E.js +0 -4
- package/dist/web/assets/shell-layout.svelte-BT2508sa.js +0 -2
- package/dist/web/assets/textarea-CeoFJ0-t.js +0 -1
- package/dist/web/assets/views-Z-n-GTYY.js +0 -2
- package/dist/web/assets/workspace-selectors.svelte-DLUlSgEE.js +0 -131
- /package/dist/{html-to-markdown.worker.js.LEGAL.txt → chunk-BUD4JHBZ.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-CKVFGRVV.js.LEGAL.txt → chunk-KEXKZKN4.js.LEGAL.txt} +0 -0
- /package/dist/{chunk-TW6FURZ7.js.LEGAL.txt → chunk-SDDKYMIP.js.LEGAL.txt} +0 -0
|
@@ -1,37 +1,45 @@
|
|
|
1
1
|
import { createRequire as __nerveCreateRequire } from "node:module";
|
|
2
2
|
const require = __nerveCreateRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
|
+
AGENT_PROFILE_LABEL_MAX_LENGTH,
|
|
5
|
+
AGENT_PROFILE_WHEN_TO_USE_MAX_LENGTH,
|
|
4
6
|
DiscardableMigrationError,
|
|
5
7
|
MIGRATION_METADATA,
|
|
6
8
|
NodeAgentBrowserCommandRunner,
|
|
7
9
|
NodeExecutionEnv,
|
|
8
10
|
acquireStorageHomeLock,
|
|
9
|
-
|
|
11
|
+
agentProfileInstructionsSchema,
|
|
12
|
+
agentProfileNameSchema,
|
|
10
13
|
atomicWriteJson,
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
bashToolSettingsSchema,
|
|
15
|
+
capabilitySkillsSchema,
|
|
16
|
+
compactionProfileSchema,
|
|
17
|
+
convertPermissionOverlayDocument,
|
|
18
|
+
convertRuleSetDocument,
|
|
14
19
|
coreMigrations,
|
|
15
20
|
createId,
|
|
16
21
|
defineStep,
|
|
17
22
|
external_exports,
|
|
23
|
+
hasEnabledRemovedToolRule,
|
|
24
|
+
imageExplanationToolSettingsSchema,
|
|
18
25
|
isRetriableRenameError,
|
|
19
|
-
leadConversationAgentSchema,
|
|
20
|
-
leadSettingsOverridesSchema,
|
|
21
26
|
loadSkills,
|
|
22
27
|
manifestBackupPath,
|
|
28
|
+
modelSelectionSchema,
|
|
23
29
|
pathExists,
|
|
24
30
|
permissionOverlayDocumentSchema,
|
|
25
31
|
permissionRuleSetIdSchema,
|
|
26
32
|
permissionRuleSetSchema,
|
|
27
33
|
planMigrations,
|
|
28
|
-
|
|
34
|
+
planPresentToolSettingsSchema,
|
|
35
|
+
pythonExecToolSettingsSchema,
|
|
29
36
|
readMigrationHome,
|
|
30
37
|
require_dist,
|
|
31
38
|
retryRename,
|
|
32
39
|
storagePaths,
|
|
40
|
+
thinkingLevelSchema,
|
|
33
41
|
validateName
|
|
34
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-FZ557YWE.js";
|
|
35
43
|
import {
|
|
36
44
|
__toESM
|
|
37
45
|
} from "./chunk-CWESUMYQ.js";
|
|
@@ -228,10 +236,10 @@ function applyQuarantine(ctx) {
|
|
|
228
236
|
function ownPaths(ctx, paths, root = ctx.paths.home) {
|
|
229
237
|
const boundary = resolve(root);
|
|
230
238
|
for (const path of paths) {
|
|
231
|
-
const
|
|
232
|
-
const rel = relative(boundary,
|
|
233
|
-
assert(rel && !isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${sep}`), `Owned path is outside its declared root: ${
|
|
234
|
-
toolkitState(ctx).owned.set(
|
|
239
|
+
const owned2 = resolve(path);
|
|
240
|
+
const rel = relative(boundary, owned2);
|
|
241
|
+
assert(rel && !isAbsolute(rel) && rel !== ".." && !rel.startsWith(`..${sep}`), `Owned path is outside its declared root: ${owned2}`);
|
|
242
|
+
toolkitState(ctx).owned.set(owned2, boundary);
|
|
235
243
|
}
|
|
236
244
|
}
|
|
237
245
|
function checkedJson(ctx, path, schema) {
|
|
@@ -250,9 +258,9 @@ function checkedJson(ctx, path, schema) {
|
|
|
250
258
|
const boundary = state.owned.get(path);
|
|
251
259
|
for (let entry2 = path; entry2 !== dirname(entry2) && relative(boundary, entry2) !== ""; entry2 = dirname(entry2))
|
|
252
260
|
assert(!lstatSync(entry2).isSymbolicLink(), `Owned JSON path traverses a symbolic link: ${entry2}`);
|
|
253
|
-
const
|
|
254
|
-
state.checkedText.set(path,
|
|
255
|
-
return schema.parse(JSON.parse(
|
|
261
|
+
const text3 = readFileSync(path, "utf8");
|
|
262
|
+
state.checkedText.set(path, text3);
|
|
263
|
+
return schema.parse(JSON.parse(text3));
|
|
256
264
|
} catch (error) {
|
|
257
265
|
if (state.unit)
|
|
258
266
|
throw error;
|
|
@@ -314,7 +322,7 @@ function quarantineSource(ctx, path, root) {
|
|
|
314
322
|
}
|
|
315
323
|
return path;
|
|
316
324
|
}
|
|
317
|
-
function quarantine(ctx, item,
|
|
325
|
+
function quarantine(ctx, item, payload2) {
|
|
318
326
|
const state = toolkitState(ctx);
|
|
319
327
|
const original = state.discardedDetails.find((entry2) => entry2.kind === item.kind && entry2.id === item.id);
|
|
320
328
|
if (original)
|
|
@@ -342,7 +350,7 @@ function quarantine(ctx, item, payload) {
|
|
|
342
350
|
}
|
|
343
351
|
ctx.fs.mkdir(path);
|
|
344
352
|
ctx.fs.mkdir(join(path, "payload"));
|
|
345
|
-
const sources = (
|
|
353
|
+
const sources = (payload2.files ?? []).map((file) => quarantineSource(ctx, file, payload2.root));
|
|
346
354
|
const reasonPath = join(path, "reason.json");
|
|
347
355
|
if (!existsSync2(reasonPath))
|
|
348
356
|
ctx.fs.write(reasonPath, JSON.stringify({
|
|
@@ -350,7 +358,7 @@ function quarantine(ctx, item, payload) {
|
|
|
350
358
|
...sources.length === 1 ? { originalPath: sources[0] } : {},
|
|
351
359
|
quarantinedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
352
360
|
}, null, 2));
|
|
353
|
-
if (
|
|
361
|
+
if (payload2.records) {
|
|
354
362
|
const recordsPath = join(path, "payload", "records.jsonl");
|
|
355
363
|
function* lines() {
|
|
356
364
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -359,7 +367,7 @@ function quarantine(ctx, item, payload) {
|
|
|
359
367
|
yield `${line}
|
|
360
368
|
`;
|
|
361
369
|
}
|
|
362
|
-
for (const row2 of
|
|
370
|
+
for (const row2 of payload2.records ?? []) {
|
|
363
371
|
const line = serializeRecord(row2);
|
|
364
372
|
const hash3 = createHash("sha256").update(line).digest("hex");
|
|
365
373
|
if (seen.has(hash3))
|
|
@@ -375,7 +383,7 @@ function quarantine(ctx, item, payload) {
|
|
|
375
383
|
const destination = join(path, "payload", basename(file));
|
|
376
384
|
if (!lstatSync(file, { throwIfNoEntry: false }))
|
|
377
385
|
continue;
|
|
378
|
-
if (
|
|
386
|
+
if (payload2.retainSource) {
|
|
379
387
|
const copy = (from, to) => {
|
|
380
388
|
const stat = lstatSync(from);
|
|
381
389
|
if (stat.isSymbolicLink()) {
|
|
@@ -392,7 +400,7 @@ function quarantine(ctx, item, payload) {
|
|
|
392
400
|
} else
|
|
393
401
|
ctx.fs.move(file, destination);
|
|
394
402
|
}
|
|
395
|
-
if (
|
|
403
|
+
if (payload2.setAside !== false && !state.setAside.some((entry2) => entry2.id === item.id && entry2.kind === item.kind))
|
|
396
404
|
state.setAside.push({ ...item, quarantinePath: path });
|
|
397
405
|
ctx.fs.write(join(ctx.scratchDir, "upgrade-report.json"), JSON.stringify({ setAside: state.setAside, losses: state.losses }));
|
|
398
406
|
};
|
|
@@ -725,18 +733,18 @@ function quarantineDiscardedConversations(ctx) {
|
|
|
725
733
|
}
|
|
726
734
|
}
|
|
727
735
|
for (const row2 of reader.db.prepare("SELECT * FROM domain_documents WHERE namespace IN ('conversation', 'agent', 'task', 'agent_inputs', 'agent_input_preparation')").iterate()) {
|
|
728
|
-
let
|
|
729
|
-
|
|
730
|
-
|
|
736
|
+
let owned2 = row2.namespace === "conversation" && row2.document_id === id;
|
|
737
|
+
owned2 ||= ["agent", "agent_inputs"].includes(String(row2.namespace)) && agents.has(String(row2.document_id));
|
|
738
|
+
owned2 ||= row2.namespace === "agent_input_preparation" && inputIds.has(String(row2.document_id));
|
|
731
739
|
try {
|
|
732
740
|
const data = decode(row2.data);
|
|
733
|
-
|
|
734
|
-
if (
|
|
741
|
+
owned2 ||= data.conversationId === id || Array.isArray(data.inputs) && data.inputs.some((input) => input.conversationId === id);
|
|
742
|
+
if (owned2 && row2.namespace === "task" && /^task_[A-Za-z0-9_-]+$/.test(String(row2.document_id)))
|
|
735
743
|
add(join3(ctx.paths.dataPath, "tasks", String(row2.document_id)));
|
|
736
744
|
} catch {
|
|
737
|
-
|
|
745
|
+
owned2 ||= reader.recordOwners(String(row2.namespace), row2).includes(id);
|
|
738
746
|
}
|
|
739
|
-
if (
|
|
747
|
+
if (owned2)
|
|
740
748
|
records.push({ table: "domain_documents", row: row2 });
|
|
741
749
|
}
|
|
742
750
|
ctx.quarantine({
|
|
@@ -796,8 +804,8 @@ function outputText(result) {
|
|
|
796
804
|
return content;
|
|
797
805
|
if (!Array.isArray(result.contentBlocks))
|
|
798
806
|
return void 0;
|
|
799
|
-
const
|
|
800
|
-
return
|
|
807
|
+
const text3 = result.contentBlocks.map(record).filter((block) => block.type === "text").map((block) => stringField(block.text)).filter((value) => value !== void 0).join("\n");
|
|
808
|
+
return text3.length > 0 ? text3 : void 0;
|
|
801
809
|
}
|
|
802
810
|
function webSearchResultPreview(value) {
|
|
803
811
|
const result = record(value);
|
|
@@ -850,41 +858,41 @@ function buildWebFetchTranscriptPreview(result) {
|
|
|
850
858
|
semanticOverflow: false
|
|
851
859
|
};
|
|
852
860
|
}
|
|
853
|
-
function headText(
|
|
854
|
-
if (
|
|
861
|
+
function headText(text3) {
|
|
862
|
+
if (text3 === void 0)
|
|
855
863
|
return { value: void 0, hidden: 0, hiddenLines: 0 };
|
|
856
|
-
const lineEnd = endAfterFirstLines(
|
|
864
|
+
const lineEnd = endAfterFirstLines(text3, WEB_PREVIEW_COUNT);
|
|
857
865
|
const charEnd = Math.min(lineEnd, WEB_PREVIEW_MAX_CHARS);
|
|
858
|
-
const hiddenLines = countLinesFrom(
|
|
859
|
-
const hiddenChars = Math.max(0,
|
|
866
|
+
const hiddenLines = countLinesFrom(text3, lineEnd);
|
|
867
|
+
const hiddenChars = Math.max(0, text3.length - charEnd);
|
|
860
868
|
return {
|
|
861
|
-
value:
|
|
869
|
+
value: text3.slice(0, charEnd),
|
|
862
870
|
hidden: hiddenLines > 0 ? hiddenLines : hiddenChars,
|
|
863
871
|
hiddenLines
|
|
864
872
|
};
|
|
865
873
|
}
|
|
866
|
-
function endAfterFirstLines(
|
|
874
|
+
function endAfterFirstLines(text3, count) {
|
|
867
875
|
let lines = 1;
|
|
868
|
-
for (let index = 0; index <
|
|
869
|
-
if (
|
|
876
|
+
for (let index = 0; index < text3.length; index += 1) {
|
|
877
|
+
if (text3[index] !== "\n")
|
|
870
878
|
continue;
|
|
871
879
|
if (lines >= count)
|
|
872
880
|
return index;
|
|
873
881
|
lines += 1;
|
|
874
882
|
}
|
|
875
|
-
return
|
|
883
|
+
return text3.length;
|
|
876
884
|
}
|
|
877
|
-
function countLinesFrom(
|
|
878
|
-
if (offset >=
|
|
885
|
+
function countLinesFrom(text3, offset) {
|
|
886
|
+
if (offset >= text3.length)
|
|
879
887
|
return 0;
|
|
880
888
|
let start = offset;
|
|
881
|
-
if (
|
|
889
|
+
if (text3[start] === "\n")
|
|
882
890
|
start += 1;
|
|
883
|
-
if (start >=
|
|
891
|
+
if (start >= text3.length)
|
|
884
892
|
return 0;
|
|
885
893
|
let lines = 1;
|
|
886
|
-
for (let index = start; index <
|
|
887
|
-
if (
|
|
894
|
+
for (let index = start; index < text3.length; index += 1) {
|
|
895
|
+
if (text3[index] === "\n")
|
|
888
896
|
lines += 1;
|
|
889
897
|
}
|
|
890
898
|
return lines;
|
|
@@ -893,14 +901,14 @@ function countLinesFrom(text2, offset) {
|
|
|
893
901
|
// packages/workbench-server/dist/infrastructure/migrations/steps/0001-conversation-core/user-projection/transcript-text-preview.js
|
|
894
902
|
var PREVIEW_COUNT = 6;
|
|
895
903
|
var MAX_PREVIEW_CHARS = 8 * 1024;
|
|
896
|
-
function firstLines(
|
|
897
|
-
if (
|
|
904
|
+
function firstLines(text3, count = PREVIEW_COUNT, maxChars = MAX_PREVIEW_CHARS) {
|
|
905
|
+
if (text3 === void 0)
|
|
898
906
|
return emptyTextPreview(void 0);
|
|
899
|
-
const lineEnd = endAfterFirstLines2(
|
|
907
|
+
const lineEnd = endAfterFirstLines2(text3, count);
|
|
900
908
|
const charEnd = Math.min(lineEnd, maxChars);
|
|
901
|
-
const value =
|
|
902
|
-
const hiddenLines = countLinesFrom2(
|
|
903
|
-
const hiddenChars = Math.max(0,
|
|
909
|
+
const value = text3.slice(0, charEnd);
|
|
910
|
+
const hiddenLines = countLinesFrom2(text3, lineEnd);
|
|
911
|
+
const hiddenChars = Math.max(0, text3.length - charEnd);
|
|
904
912
|
return {
|
|
905
913
|
value,
|
|
906
914
|
hidden: visibleHiddenCount(hiddenLines, hiddenChars),
|
|
@@ -908,14 +916,14 @@ function firstLines(text2, count = PREVIEW_COUNT, maxChars = MAX_PREVIEW_CHARS)
|
|
|
908
916
|
hiddenChars
|
|
909
917
|
};
|
|
910
918
|
}
|
|
911
|
-
function lastLines(
|
|
912
|
-
if (
|
|
919
|
+
function lastLines(text3, count = PREVIEW_COUNT) {
|
|
920
|
+
if (text3 === void 0)
|
|
913
921
|
return emptyTextPreview(void 0);
|
|
914
|
-
const logicalEnd =
|
|
915
|
-
const lineStart = startBeforeLastLines(
|
|
922
|
+
const logicalEnd = text3.endsWith("\n") ? text3.length - 1 : text3.length;
|
|
923
|
+
const lineStart = startBeforeLastLines(text3, logicalEnd, count);
|
|
916
924
|
const charStart = Math.max(lineStart, logicalEnd - MAX_PREVIEW_CHARS);
|
|
917
|
-
const value =
|
|
918
|
-
const hiddenLines = countLinesUntil(
|
|
925
|
+
const value = text3.slice(charStart, logicalEnd);
|
|
926
|
+
const hiddenLines = countLinesUntil(text3, lineStart);
|
|
919
927
|
const hiddenChars = Math.max(0, charStart);
|
|
920
928
|
return {
|
|
921
929
|
value,
|
|
@@ -930,25 +938,25 @@ function emptyTextPreview(value) {
|
|
|
930
938
|
function visibleHiddenCount(hiddenLines, hiddenChars) {
|
|
931
939
|
return hiddenLines > 0 ? hiddenLines : hiddenChars;
|
|
932
940
|
}
|
|
933
|
-
function endAfterFirstLines2(
|
|
941
|
+
function endAfterFirstLines2(text3, count) {
|
|
934
942
|
if (count <= 0)
|
|
935
943
|
return 0;
|
|
936
944
|
let lines = 1;
|
|
937
|
-
for (let index = 0; index <
|
|
938
|
-
if (
|
|
945
|
+
for (let index = 0; index < text3.length; index += 1) {
|
|
946
|
+
if (text3[index] !== "\n")
|
|
939
947
|
continue;
|
|
940
948
|
if (lines >= count)
|
|
941
949
|
return index;
|
|
942
950
|
lines += 1;
|
|
943
951
|
}
|
|
944
|
-
return
|
|
952
|
+
return text3.length;
|
|
945
953
|
}
|
|
946
|
-
function startBeforeLastLines(
|
|
954
|
+
function startBeforeLastLines(text3, logicalEnd, count) {
|
|
947
955
|
if (count <= 0)
|
|
948
956
|
return logicalEnd;
|
|
949
957
|
let remaining = count;
|
|
950
958
|
for (let index = logicalEnd - 1; index >= 0; index -= 1) {
|
|
951
|
-
if (
|
|
959
|
+
if (text3[index] !== "\n")
|
|
952
960
|
continue;
|
|
953
961
|
remaining -= 1;
|
|
954
962
|
if (remaining === 0)
|
|
@@ -956,30 +964,30 @@ function startBeforeLastLines(text2, logicalEnd, count) {
|
|
|
956
964
|
}
|
|
957
965
|
return 0;
|
|
958
966
|
}
|
|
959
|
-
function countLinesFrom2(
|
|
960
|
-
if (offset >=
|
|
967
|
+
function countLinesFrom2(text3, offset) {
|
|
968
|
+
if (offset >= text3.length)
|
|
961
969
|
return 0;
|
|
962
970
|
let start = offset;
|
|
963
|
-
if (
|
|
971
|
+
if (text3[start] === "\n")
|
|
964
972
|
start += 1;
|
|
965
|
-
if (start >=
|
|
973
|
+
if (start >= text3.length)
|
|
966
974
|
return 0;
|
|
967
975
|
let lines = 1;
|
|
968
|
-
for (let index = start; index <
|
|
969
|
-
if (
|
|
976
|
+
for (let index = start; index < text3.length; index += 1) {
|
|
977
|
+
if (text3[index] === "\n")
|
|
970
978
|
lines += 1;
|
|
971
979
|
}
|
|
972
980
|
return lines;
|
|
973
981
|
}
|
|
974
|
-
function countLinesUntil(
|
|
982
|
+
function countLinesUntil(text3, offset) {
|
|
975
983
|
if (offset <= 0)
|
|
976
984
|
return 0;
|
|
977
|
-
const end = Math.min(offset - 1,
|
|
985
|
+
const end = Math.min(offset - 1, text3.length);
|
|
978
986
|
if (end <= 0)
|
|
979
987
|
return 0;
|
|
980
988
|
let lines = 1;
|
|
981
989
|
for (let index = 0; index < end; index += 1) {
|
|
982
|
-
if (
|
|
990
|
+
if (text3[index] === "\n")
|
|
983
991
|
lines += 1;
|
|
984
992
|
}
|
|
985
993
|
return lines;
|
|
@@ -1045,10 +1053,10 @@ function outputText2(result) {
|
|
|
1045
1053
|
return stdout.endsWith("\n") ? `${stdout}${stderr}` : `${stdout}
|
|
1046
1054
|
${stderr}`;
|
|
1047
1055
|
}
|
|
1048
|
-
function withTextContent(result,
|
|
1049
|
-
if (
|
|
1056
|
+
function withTextContent(result, text3) {
|
|
1057
|
+
if (text3 === void 0)
|
|
1050
1058
|
return sanitizePreviewValue(result);
|
|
1051
|
-
const next = { ...result, content:
|
|
1059
|
+
const next = { ...result, content: text3 };
|
|
1052
1060
|
delete next.stdout;
|
|
1053
1061
|
delete next.stderr;
|
|
1054
1062
|
const blocks = arrayField(next.contentBlocks);
|
|
@@ -1335,10 +1343,10 @@ function withoutProducerArtifactClaims(value) {
|
|
|
1335
1343
|
function buildUserProjection(toolName2, args, result) {
|
|
1336
1344
|
let publicResult = withoutProducerArtifactClaims(result);
|
|
1337
1345
|
if (toolName2 === "explore" || toolName2.startsWith("task_") || toolName2.startsWith("subagent_")) {
|
|
1338
|
-
const
|
|
1339
|
-
if (
|
|
1346
|
+
const text3 = stringField2(record2(publicResult).content);
|
|
1347
|
+
if (text3) {
|
|
1340
1348
|
try {
|
|
1341
|
-
const value = JSON.parse(
|
|
1349
|
+
const value = JSON.parse(text3);
|
|
1342
1350
|
publicResult = toolName2 === "explore" ? { reports: value } : value;
|
|
1343
1351
|
} catch {
|
|
1344
1352
|
}
|
|
@@ -1356,9 +1364,9 @@ function buildUserProjection(toolName2, args, result) {
|
|
|
1356
1364
|
case "read": {
|
|
1357
1365
|
argsPreview = assignPathArgs(argsRecord);
|
|
1358
1366
|
if (result && typeof result === "object") {
|
|
1359
|
-
const
|
|
1360
|
-
if (
|
|
1361
|
-
const preview = firstLines(
|
|
1367
|
+
const text3 = stringField2(resultRecord.content);
|
|
1368
|
+
if (text3 !== void 0) {
|
|
1369
|
+
const preview = firstLines(text3);
|
|
1362
1370
|
resultPreview = withTextContent(resultRecord, preview.value);
|
|
1363
1371
|
({ hidden, noun } = textOverflowStats([preview]));
|
|
1364
1372
|
} else {
|
|
@@ -1448,15 +1456,15 @@ function buildUserProjection(toolName2, args, result) {
|
|
|
1448
1456
|
}
|
|
1449
1457
|
case "explain_image": {
|
|
1450
1458
|
const details = record2(resultRecord.details);
|
|
1451
|
-
const
|
|
1459
|
+
const explanation2 = firstLines(stringField2(details.explanation) ?? outputText2(resultRecord));
|
|
1452
1460
|
resultPreview = {
|
|
1453
|
-
...withTextContent(resultRecord,
|
|
1461
|
+
...withTextContent(resultRecord, explanation2.value),
|
|
1454
1462
|
details: {
|
|
1455
1463
|
...details,
|
|
1456
|
-
explanation:
|
|
1464
|
+
explanation: explanation2.value ?? ""
|
|
1457
1465
|
}
|
|
1458
1466
|
};
|
|
1459
|
-
({ hidden, noun } = textOverflowStats([
|
|
1467
|
+
({ hidden, noun } = textOverflowStats([explanation2]));
|
|
1460
1468
|
direction = "head";
|
|
1461
1469
|
break;
|
|
1462
1470
|
}
|
|
@@ -2376,13 +2384,13 @@ var conversationEventSchema = shape((value) => {
|
|
|
2376
2384
|
assert7(typeof value.id === "string" && typeof value.conversationId === "string");
|
|
2377
2385
|
assert7(Number.isSafeInteger(value.sequence) && value.sequence > 0);
|
|
2378
2386
|
object(value.payload);
|
|
2379
|
-
const
|
|
2387
|
+
const payload2 = value.payload;
|
|
2380
2388
|
if (value.type === "user_message")
|
|
2381
|
-
assert7(typeof
|
|
2389
|
+
assert7(typeof payload2.text === "string" && typeof payload2.originalText === "string");
|
|
2382
2390
|
else if (value.type === "assistant_message") {
|
|
2383
|
-
assert7(Array.isArray(
|
|
2384
|
-
object(
|
|
2385
|
-
for (const block of
|
|
2391
|
+
assert7(Array.isArray(payload2.content));
|
|
2392
|
+
object(payload2.usage);
|
|
2393
|
+
for (const block of payload2.content) {
|
|
2386
2394
|
assert7(["text", "thinking", "toolCall"].includes(block.type));
|
|
2387
2395
|
if (block.type === "toolCall") {
|
|
2388
2396
|
assert7(typeof block.id === "string" && typeof block.name === "string");
|
|
@@ -2390,16 +2398,16 @@ var conversationEventSchema = shape((value) => {
|
|
|
2390
2398
|
}
|
|
2391
2399
|
}
|
|
2392
2400
|
} else if (value.type === "tool_call_response") {
|
|
2393
|
-
assert7(Array.isArray(
|
|
2394
|
-
object(
|
|
2395
|
-
assert7(!("result" in
|
|
2396
|
-
assert7(["completed", "failed", "denied", "cancelled", "indeterminate"].includes(
|
|
2397
|
-
if (
|
|
2398
|
-
assert7(typeof
|
|
2401
|
+
assert7(Array.isArray(payload2.agentProjection));
|
|
2402
|
+
object(payload2.userProjection);
|
|
2403
|
+
assert7(!("result" in payload2) && !("modelContent" in payload2));
|
|
2404
|
+
assert7(["completed", "failed", "denied", "cancelled", "indeterminate"].includes(payload2.outcome));
|
|
2405
|
+
if (payload2.origin === "model")
|
|
2406
|
+
assert7(typeof payload2.providerCallId === "string" && typeof payload2.assistantEventId === "string");
|
|
2399
2407
|
} else if (value.type === "compaction")
|
|
2400
|
-
assert7(typeof
|
|
2408
|
+
assert7(typeof payload2.summary === "string");
|
|
2401
2409
|
else
|
|
2402
|
-
assert7(value.type === "system_event" && ["notification", "execution_state"].includes(
|
|
2410
|
+
assert7(value.type === "system_event" && ["notification", "execution_state"].includes(payload2.subtype));
|
|
2403
2411
|
});
|
|
2404
2412
|
var supervisionSchema = {
|
|
2405
2413
|
safeParse(value) {
|
|
@@ -2533,9 +2541,9 @@ async function checkConfiguration(input) {
|
|
|
2533
2541
|
});
|
|
2534
2542
|
if (value) {
|
|
2535
2543
|
checkedDocuments.set(path, value);
|
|
2536
|
-
const
|
|
2537
|
-
if (
|
|
2538
|
-
checkedTexts.set(path,
|
|
2544
|
+
const text3 = checkedText(input.context, path);
|
|
2545
|
+
if (text3 !== void 0)
|
|
2546
|
+
checkedTexts.set(path, text3);
|
|
2539
2547
|
}
|
|
2540
2548
|
} catch (error) {
|
|
2541
2549
|
if (runtime) {
|
|
@@ -2563,9 +2571,9 @@ var checkedDocuments = /* @__PURE__ */ new Map();
|
|
|
2563
2571
|
var checkedTexts = /* @__PURE__ */ new Map();
|
|
2564
2572
|
function consumeCheckedText(path) {
|
|
2565
2573
|
const key2 = resolve4(path);
|
|
2566
|
-
const
|
|
2574
|
+
const text3 = checkedTexts.get(key2);
|
|
2567
2575
|
checkedTexts.delete(key2);
|
|
2568
|
-
return
|
|
2576
|
+
return text3;
|
|
2569
2577
|
}
|
|
2570
2578
|
function consumeCheckedDocument(path) {
|
|
2571
2579
|
const key2 = resolve4(path);
|
|
@@ -2616,7 +2624,7 @@ function readJson(path, fallback = {}) {
|
|
|
2616
2624
|
return fallback;
|
|
2617
2625
|
}
|
|
2618
2626
|
}
|
|
2619
|
-
var digest2 = (
|
|
2627
|
+
var digest2 = (text3) => `sha256:${createHash5("sha256").update(text3).digest("hex")}`;
|
|
2620
2628
|
var normalizeDigest = (value) => value.startsWith("sha256:") ? value : `sha256:${value}`;
|
|
2621
2629
|
function convertSettings(document) {
|
|
2622
2630
|
let changed = false;
|
|
@@ -2641,10 +2649,10 @@ function convertSettings(document) {
|
|
|
2641
2649
|
}
|
|
2642
2650
|
return convertPermissionRules(document) || changed;
|
|
2643
2651
|
}
|
|
2644
|
-
function renameSuggestionFilter(
|
|
2645
|
-
const match =
|
|
2652
|
+
function renameSuggestionFilter(text3) {
|
|
2653
|
+
const match = text3.match(/^(---\r?\n)([\s\S]*?)(\r?\n---(?:\r?\n|$))/);
|
|
2646
2654
|
if (!match)
|
|
2647
|
-
return
|
|
2655
|
+
return text3;
|
|
2648
2656
|
const lines = match[2].split(/\r?\n/);
|
|
2649
2657
|
let when = false;
|
|
2650
2658
|
for (let index = 0; index < lines.length; index++) {
|
|
@@ -2659,7 +2667,7 @@ function renameSuggestionFilter(text2) {
|
|
|
2659
2667
|
lines[index] = line.replace(/^(\s+["']?)permissionLevels(?=["']?\s*:)/, "$1permissionRuleSets");
|
|
2660
2668
|
}
|
|
2661
2669
|
const newline = match[1].includes("\r") ? "\r\n" : "\n";
|
|
2662
|
-
return match[1] + lines.join(newline) + match[3] +
|
|
2670
|
+
return match[1] + lines.join(newline) + match[3] + text3.slice(match[0].length);
|
|
2663
2671
|
}
|
|
2664
2672
|
async function convertConfiguration(home, scratch, ctx) {
|
|
2665
2673
|
let settings = 0, suggestions = 0;
|
|
@@ -2707,8 +2715,8 @@ async function convertConfiguration(home, scratch, ctx) {
|
|
|
2707
2715
|
}
|
|
2708
2716
|
return { settings, suggestions };
|
|
2709
2717
|
}
|
|
2710
|
-
function predicate(
|
|
2711
|
-
const frontmatter =
|
|
2718
|
+
function predicate(text3) {
|
|
2719
|
+
const frontmatter = text3.match(/^---\r?\n([\s\S]*?)\r?\n---(?:\r?\n|$)/)?.[1];
|
|
2712
2720
|
if (!frontmatter)
|
|
2713
2721
|
return null;
|
|
2714
2722
|
const lines = frontmatter.split(/\r?\n/), index = lines.findIndex((line) => /^(?:enable-js|["']enable-js["']):/.test(line));
|
|
@@ -2749,7 +2757,7 @@ function convertPromptTrust(data, home, scratch) {
|
|
|
2749
2757
|
return approved ? { ...data, path, status, contentDigest: normalizeDigest(approved) } : null;
|
|
2750
2758
|
}
|
|
2751
2759
|
try {
|
|
2752
|
-
const
|
|
2760
|
+
const text3 = readFileSync3(path, "utf8"), current = digest2(text3);
|
|
2753
2761
|
const old = data.contentDigest ?? data.digest;
|
|
2754
2762
|
if (old) {
|
|
2755
2763
|
const conversions = readJson(join7(scratch, "suggestion-digests.json"));
|
|
@@ -2762,7 +2770,7 @@ function convertPromptTrust(data, home, scratch) {
|
|
|
2762
2770
|
contentDigest: converted ? current : approved
|
|
2763
2771
|
};
|
|
2764
2772
|
}
|
|
2765
|
-
const code = predicate(
|
|
2773
|
+
const code = predicate(text3);
|
|
2766
2774
|
if (status === "trusted" && (!code || digest2(code) !== normalizeDigest(data.predicateHash ?? "")))
|
|
2767
2775
|
return null;
|
|
2768
2776
|
return { ...data, path, status, contentDigest: current };
|
|
@@ -2830,30 +2838,30 @@ End with a short report using these headings: Changes (files and what changed),
|
|
|
2830
2838
|
};
|
|
2831
2839
|
var subagentTools = ["subagent_prompt", "subagent_status", "subagent_stop"];
|
|
2832
2840
|
var legacySubagentTools = ["subagent_new", "subagent_list"];
|
|
2833
|
-
function profileFile(name,
|
|
2834
|
-
return profileEntry.parse({ ...builtIns[name], model, thinking, compaction:
|
|
2841
|
+
function profileFile(name, model2, thinking, compaction3) {
|
|
2842
|
+
return profileEntry.parse({ ...builtIns[name], model: model2, thinking, compaction: compaction3 });
|
|
2835
2843
|
}
|
|
2836
2844
|
var modelId = (selection2) => selection2 && typeof selection2.provider === "string" && typeof selection2.modelId === "string" ? `${selection2.provider}/${selection2.modelId}` : null;
|
|
2837
2845
|
function customizedProfiles(harness2) {
|
|
2838
2846
|
const profiles = [];
|
|
2839
2847
|
const explore = harness2.exploreAgent;
|
|
2840
2848
|
if (explore) {
|
|
2841
|
-
const
|
|
2849
|
+
const model2 = modelId(explore.model);
|
|
2842
2850
|
const thinking = explore.thinkingLevel ?? "off";
|
|
2843
|
-
if (
|
|
2851
|
+
if (model2 || thinking !== "off")
|
|
2844
2852
|
profiles.push([
|
|
2845
2853
|
"explore",
|
|
2846
|
-
profileFile("explore",
|
|
2854
|
+
profileFile("explore", model2 ?? "lead", thinking, "inherit")
|
|
2847
2855
|
]);
|
|
2848
2856
|
}
|
|
2849
2857
|
const developer = harness2.asyncSubagent;
|
|
2850
2858
|
if (developer) {
|
|
2851
|
-
const
|
|
2859
|
+
const model2 = modelId(developer.model);
|
|
2852
2860
|
const profile = developer.compactionProfile ?? "inherit";
|
|
2853
|
-
if (
|
|
2861
|
+
if (model2 || profile !== "inherit")
|
|
2854
2862
|
profiles.push([
|
|
2855
2863
|
"developer",
|
|
2856
|
-
profileFile("developer",
|
|
2864
|
+
profileFile("developer", model2 ?? "lead", model2 ? developer.thinkingLevel ?? "lead" : "lead", profile === "inherit" ? "inherit" : {
|
|
2857
2865
|
profile,
|
|
2858
2866
|
...profile === "custom" ? {
|
|
2859
2867
|
triggerPercent: developer.customTriggerPercent,
|
|
@@ -2864,7 +2872,7 @@ function customizedProfiles(harness2) {
|
|
|
2864
2872
|
}
|
|
2865
2873
|
return profiles;
|
|
2866
2874
|
}
|
|
2867
|
-
var hash = (
|
|
2875
|
+
var hash = (text3) => createHash6("sha256").update(text3).digest("hex");
|
|
2868
2876
|
var own = (record4, name) => Object.hasOwn(record4, name) ? record4[name] : void 0;
|
|
2869
2877
|
function verifyAncestors(path, scope) {
|
|
2870
2878
|
const absolute = resolve5(path);
|
|
@@ -2925,8 +2933,8 @@ function convertProfileScope(root, markdownDirectory, customizations = [], disab
|
|
|
2925
2933
|
const oldPreferences = existing && !Object.hasOwn(existing, "schemaVersion") ? enabledPreferences.parse(existing) : void 0;
|
|
2926
2934
|
const document = profilesDocument.parse(oldPreferences || !hasTarget ? { schemaVersion: 1, profiles: {} } : existing);
|
|
2927
2935
|
const canonicalExploreEnabled = oldPreferences ? void 0 : own(document.profiles, "explore")?.enabled;
|
|
2928
|
-
const
|
|
2929
|
-
const verifiedResume =
|
|
2936
|
+
const receipt3 = options.receiptPath && existsSync9(options.receiptPath) ? profileConversionReceipt.parse(readJson(options.receiptPath)) : void 0;
|
|
2937
|
+
const verifiedResume = receipt3 && !oldPreferences && isDeepStrictEqual(receipt3.document, document);
|
|
2930
2938
|
const sources = {};
|
|
2931
2939
|
if (existsSync9(markdownDirectory)) {
|
|
2932
2940
|
assert10(lstatSync7(markdownDirectory).isDirectory(), "Expected regular profile directory");
|
|
@@ -2951,7 +2959,7 @@ function convertProfileScope(root, markdownDirectory, customizations = [], disab
|
|
|
2951
2959
|
const missingSkills = lowerSkills && typeof lowerSkills === "object" && upperSkills && typeof upperSkills === "object" ? Object.keys(lowerSkills).filter((key2) => !Object.hasOwn(upperSkills, key2)) : [];
|
|
2952
2960
|
assert10(!missingTools.length && !missingSkills.length, `Manual review required for legacy project subagent ${name} at ${path}: whole-definition capability shadowing cannot become sparse JSON without changing parent inheritance (tools: ${missingTools.join(", ") || "none"}; skills: ${missingSkills.join(", ") || "none"}). Resolve the selections explicitly in ${target3} and archive the reviewed conflicting Markdown before retrying; legacy files have not been removed.`);
|
|
2953
2961
|
}
|
|
2954
|
-
const resumedSource = verifiedResume && own(
|
|
2962
|
+
const resumedSource = verifiedResume && own(receipt3.sources, path) === hash(raw);
|
|
2955
2963
|
assert10(!current || isDeepStrictEqual(current, entry2) || resumedSource, `Subagent profile collision: ${name} at ${target3}`);
|
|
2956
2964
|
if (!current)
|
|
2957
2965
|
document.profiles[name] = entry2;
|
|
@@ -3682,16 +3690,16 @@ function mapMessage(mapping, row2, data, base, call) {
|
|
|
3682
3690
|
content: [{ type: "text", text: entry2.text ?? "" }],
|
|
3683
3691
|
isError: entry2.details?.isError
|
|
3684
3692
|
};
|
|
3685
|
-
const
|
|
3693
|
+
const payload2 = responsePayload(mapping, call ?? { id: entry2.details?.toolRecordId }, base.conversationId, fallback);
|
|
3686
3694
|
event = {
|
|
3687
3695
|
...base,
|
|
3688
3696
|
type: "tool_call_response",
|
|
3689
|
-
llmRepresentation:
|
|
3690
|
-
payload
|
|
3697
|
+
llmRepresentation: payload2.origin === "model" ? "tool_result" : "user",
|
|
3698
|
+
payload: payload2
|
|
3691
3699
|
};
|
|
3692
3700
|
} else if (message?.role === "user" || entry2.role === "user") {
|
|
3693
3701
|
const content = message?.content;
|
|
3694
|
-
const
|
|
3702
|
+
const text3 = typeof content === "string" ? content : Array.isArray(content) ? content.filter((block) => block.type === "text").map((block) => block.text).join("\n") : entry2.text ?? "";
|
|
3695
3703
|
if (Array.isArray(content) && content.some((block) => block.type !== "text"))
|
|
3696
3704
|
mapping.report.loss("User images cannot be represented by text-only user_message schema");
|
|
3697
3705
|
event = {
|
|
@@ -3699,8 +3707,8 @@ function mapMessage(mapping, row2, data, base, call) {
|
|
|
3699
3707
|
type: "user_message",
|
|
3700
3708
|
llmRepresentation: "user",
|
|
3701
3709
|
payload: {
|
|
3702
|
-
text:
|
|
3703
|
-
originalText: entry2.details?.originalText ??
|
|
3710
|
+
text: text3,
|
|
3711
|
+
originalText: entry2.details?.originalText ?? text3,
|
|
3704
3712
|
source: "user",
|
|
3705
3713
|
senderConversationId: null,
|
|
3706
3714
|
commandPreparation: null
|
|
@@ -3770,11 +3778,11 @@ function eventBase(mapping, row2, data, conversationId, sequence, previousEventI
|
|
|
3770
3778
|
}
|
|
3771
3779
|
|
|
3772
3780
|
// packages/workbench-server/dist/infrastructure/migrations/steps/0001-conversation-core/commands.js
|
|
3773
|
-
function findExecutableCommandBlocks(
|
|
3781
|
+
function findExecutableCommandBlocks(text3) {
|
|
3774
3782
|
const lines = [];
|
|
3775
|
-
for (let offset = 0; offset <
|
|
3776
|
-
const newline =
|
|
3777
|
-
lines.push({ text:
|
|
3783
|
+
for (let offset = 0; offset < text3.length; ) {
|
|
3784
|
+
const newline = text3.indexOf("\n", offset), end = newline < 0 ? text3.length : newline + 1;
|
|
3785
|
+
lines.push({ text: text3.slice(offset, end), offset });
|
|
3778
3786
|
offset = end;
|
|
3779
3787
|
}
|
|
3780
3788
|
const blocks = [];
|
|
@@ -3785,7 +3793,7 @@ function findExecutableCommandBlocks(text2) {
|
|
|
3785
3793
|
for (let end = index + 1; end < lines.length; end++) {
|
|
3786
3794
|
if (!new RegExp(`^ {0,3}${open3[1][0]}{${open3[1].length},}\\s*$`).test(lines[end].text.replace(/\r?\n$/, "")))
|
|
3787
3795
|
continue;
|
|
3788
|
-
const command =
|
|
3796
|
+
const command = text3.slice(line.offset + line.text.length, lines[end].offset).trim();
|
|
3789
3797
|
if (command)
|
|
3790
3798
|
blocks.push({
|
|
3791
3799
|
start: line.offset,
|
|
@@ -3798,17 +3806,17 @@ function findExecutableCommandBlocks(text2) {
|
|
|
3798
3806
|
}
|
|
3799
3807
|
return blocks;
|
|
3800
3808
|
}
|
|
3801
|
-
function replaceExecutableCommandBlocks(
|
|
3809
|
+
function replaceExecutableCommandBlocks(text3, replacements) {
|
|
3802
3810
|
let cursor = 0, result = "";
|
|
3803
3811
|
for (const replacement of [...replacements].sort((a, b) => a.block.start - b.block.start)) {
|
|
3804
3812
|
if (replacement.block.start < cursor)
|
|
3805
3813
|
throw new Error("Overlapping command receipts");
|
|
3806
|
-
result +=
|
|
3807
|
-
if (
|
|
3814
|
+
result += text3.slice(cursor, replacement.block.start) + replacement.text;
|
|
3815
|
+
if (text3[replacement.block.end - 1] === "\n" && !replacement.text.endsWith("\n"))
|
|
3808
3816
|
result += "\n";
|
|
3809
3817
|
cursor = replacement.block.end;
|
|
3810
3818
|
}
|
|
3811
|
-
return result +
|
|
3819
|
+
return result + text3.slice(cursor);
|
|
3812
3820
|
}
|
|
3813
3821
|
|
|
3814
3822
|
// packages/workbench-server/dist/infrastructure/migrations/steps/0001-conversation-core/input.mapper.js
|
|
@@ -3825,25 +3833,25 @@ function importPendingInput(mapping, conversationId, input) {
|
|
|
3825
3833
|
}
|
|
3826
3834
|
if (input.eligibility?.kind === "run")
|
|
3827
3835
|
mapping.report.loss("Pending run-targeted input retargeted to next turn after migration settlement");
|
|
3828
|
-
const
|
|
3829
|
-
const blocks = source === "system" ? [] : findExecutableCommandBlocks(
|
|
3836
|
+
const text3 = input.text ?? "";
|
|
3837
|
+
const blocks = source === "system" ? [] : findExecutableCommandBlocks(text3);
|
|
3830
3838
|
const receipts = input.importPreparation?.blocks ?? [];
|
|
3831
3839
|
const preparation = blocks.length ? commandPreparationSchema.parse({
|
|
3832
3840
|
blocks: blocks.map((block, index) => {
|
|
3833
|
-
const
|
|
3834
|
-
const state =
|
|
3841
|
+
const receipt3 = receipts.find((item) => item.index === index && item.command === block.command);
|
|
3842
|
+
const state = receipt3?.state === "completed" && receipt3.resultText ? "completed" : receipt3?.state === "running" ? "indeterminate" : "not_run";
|
|
3835
3843
|
return {
|
|
3836
3844
|
index,
|
|
3837
3845
|
command: block.command,
|
|
3838
3846
|
state,
|
|
3839
|
-
result: state === "completed" ? { stdout:
|
|
3847
|
+
result: state === "completed" ? { stdout: receipt3.resultText, stderr: "", exitCode: null } : null
|
|
3840
3848
|
};
|
|
3841
3849
|
})
|
|
3842
3850
|
}) : null;
|
|
3843
|
-
const preparedText = preparation ? replaceExecutableCommandBlocks(
|
|
3851
|
+
const preparedText = preparation ? replaceExecutableCommandBlocks(text3, preparation.blocks.map((block) => ({
|
|
3844
3852
|
block: blocks[block.index],
|
|
3845
3853
|
text: block.result?.stdout ?? `[Command ${block.state} during migration; it was not repeated: ${block.command}]`
|
|
3846
|
-
}))) : source === "system" ? null :
|
|
3854
|
+
}))) : source === "system" ? null : text3;
|
|
3847
3855
|
if (preparation?.blocks.some((block) => block.state !== "completed"))
|
|
3848
3856
|
mapping.report.loss("Pending command blocks settled without replaying external effects");
|
|
3849
3857
|
mapping.storage.inputs.insert({
|
|
@@ -3854,8 +3862,8 @@ function importPendingInput(mapping, conversationId, input) {
|
|
|
3854
3862
|
content: source === "system" ? {
|
|
3855
3863
|
subtype: "notification",
|
|
3856
3864
|
producer: input.origin.producer ?? "import",
|
|
3857
|
-
text:
|
|
3858
|
-
} :
|
|
3865
|
+
text: text3
|
|
3866
|
+
} : text3,
|
|
3859
3867
|
deliveryTarget: input.eligibility?.kind === "next_run" ? "next_execution" : "next_turn",
|
|
3860
3868
|
targetExecutionId: null,
|
|
3861
3869
|
commandPreparation: preparation,
|
|
@@ -3869,11 +3877,11 @@ function importPendingInput(mapping, conversationId, input) {
|
|
|
3869
3877
|
import { createHash as createHash9 } from "node:crypto";
|
|
3870
3878
|
function userMessageDigest(message) {
|
|
3871
3879
|
const content = message.content;
|
|
3872
|
-
const
|
|
3873
|
-
return digest3(
|
|
3880
|
+
const text3 = typeof content === "string" ? content : Array.isArray(content) ? content.filter((block) => block.type === "text").map((block) => block.text).join("\n") : "";
|
|
3881
|
+
return digest3(text3);
|
|
3874
3882
|
}
|
|
3875
|
-
function digest3(
|
|
3876
|
-
return createHash9("sha256").update(
|
|
3883
|
+
function digest3(text3) {
|
|
3884
|
+
return createHash9("sha256").update(text3).digest("hex");
|
|
3877
3885
|
}
|
|
3878
3886
|
function verifySelectedPath(input) {
|
|
3879
3887
|
const { reader, storage, summary } = input;
|
|
@@ -4046,12 +4054,12 @@ function importConversation(reader, mapping, conversation, agents, inputs2, task
|
|
|
4046
4054
|
if (call.toolName === "task_start" && !mapping.processLinks.has(call.id ?? String(row2.id))) {
|
|
4047
4055
|
const envelope = call.result ?? (call.resultPayload?.logicalPath ? readPayload(mapping.dataDir, call.resultPayload.logicalPath) : null);
|
|
4048
4056
|
const result = envelope?.result ?? envelope;
|
|
4049
|
-
const
|
|
4050
|
-
const bashId =
|
|
4057
|
+
const bash2 = result?.asyncBash ?? result?.details?.asyncBash;
|
|
4058
|
+
const bashId = bash2?.id ?? result?.bashId ?? result?.details?.bashId;
|
|
4051
4059
|
if (typeof bashId === "string" && bashId.startsWith("bash_"))
|
|
4052
4060
|
mapping.processLinks.set(call.id ?? String(row2.id), {
|
|
4053
4061
|
id: bashId,
|
|
4054
|
-
command:
|
|
4062
|
+
command: bash2?.command ?? call.args?.command
|
|
4055
4063
|
});
|
|
4056
4064
|
}
|
|
4057
4065
|
tools.set(String(row2.id), {
|
|
@@ -4345,14 +4353,14 @@ function importConversation(reader, mapping, conversation, agents, inputs2, task
|
|
|
4345
4353
|
if (preserveSelection)
|
|
4346
4354
|
scope.head = origin?.eventId ?? null;
|
|
4347
4355
|
ensureOrigin(scope, call);
|
|
4348
|
-
const
|
|
4356
|
+
const payload2 = responsePayload(mapping, call, scope.id);
|
|
4349
4357
|
append(scope, {
|
|
4350
4358
|
id: mapping.ids.get("evt", `response:${row2.id}`),
|
|
4351
4359
|
type: "tool_call_response",
|
|
4352
|
-
llmRepresentation:
|
|
4360
|
+
llmRepresentation: payload2.origin === "model" ? "tool_result" : "user",
|
|
4353
4361
|
createdAt: iso(call.settledAt ?? call.updatedAt),
|
|
4354
4362
|
turnId: call.turnId ? mapping.ids.get("turn", call.turnId) : null,
|
|
4355
|
-
payload
|
|
4363
|
+
payload: payload2
|
|
4356
4364
|
});
|
|
4357
4365
|
if (preserveSelection)
|
|
4358
4366
|
scope.head = selectedHead;
|
|
@@ -4375,14 +4383,14 @@ function importConversation(reader, mapping, conversation, agents, inputs2, task
|
|
|
4375
4383
|
status: "running",
|
|
4376
4384
|
error: "No durable result existed for this call at migration; its outcome is indeterminate and it was not replayed."
|
|
4377
4385
|
};
|
|
4378
|
-
const
|
|
4386
|
+
const payload2 = responsePayload(mapping, call, scope.id);
|
|
4379
4387
|
append(scope, {
|
|
4380
4388
|
id: mapping.ids.get("evt", `missing-response:${origin.eventId}:${providerCallId}`),
|
|
4381
4389
|
type: "tool_call_response",
|
|
4382
4390
|
llmRepresentation: "tool_result",
|
|
4383
4391
|
createdAt: origin.createdAt,
|
|
4384
4392
|
turnId: origin.turnId,
|
|
4385
|
-
payload
|
|
4393
|
+
payload: payload2
|
|
4386
4394
|
});
|
|
4387
4395
|
branchTails.set(origin.eventId, scope.head);
|
|
4388
4396
|
if (!cursor)
|
|
@@ -4442,11 +4450,11 @@ function importConversation(reader, mapping, conversation, agents, inputs2, task
|
|
|
4442
4450
|
while (sourceId) {
|
|
4443
4451
|
assert12(!seen.has(sourceId), `Source history cycle ${sourceId}`);
|
|
4444
4452
|
seen.add(sourceId);
|
|
4445
|
-
const
|
|
4446
|
-
assert12(
|
|
4447
|
-
if (
|
|
4448
|
-
oldUserDigests.push(
|
|
4449
|
-
sourceId =
|
|
4453
|
+
const receipt3 = sourceHistory.get(sourceId);
|
|
4454
|
+
assert12(receipt3, `Missing source leaf/predecessor ${sourceId}`);
|
|
4455
|
+
if (receipt3.userDigest)
|
|
4456
|
+
oldUserDigests.push(receipt3.userDigest);
|
|
4457
|
+
sourceId = receipt3.parent;
|
|
4450
4458
|
}
|
|
4451
4459
|
if (expectation.isRoot)
|
|
4452
4460
|
mapping.report.selectedPaths.roots++;
|
|
@@ -5115,13 +5123,13 @@ async function check(ctx, summary) {
|
|
|
5115
5123
|
if (problems.length)
|
|
5116
5124
|
fail(path.conversationId, `History verification failed: ${problems.join(", ")}`);
|
|
5117
5125
|
}
|
|
5118
|
-
for (const
|
|
5126
|
+
for (const receipt3 of summary.salvagedRecords ?? []) {
|
|
5119
5127
|
try {
|
|
5120
|
-
const event = storage.events.get(
|
|
5121
|
-
assert14(event?.type === "system_event" && event.llmRepresentation === "none" && event.payload.subtype === "notification" && event.payload.producer === "import:migration_loss", `Missing history-loss placeholder for ${
|
|
5122
|
-
assert14.equal(createHash10("sha256").update(event.payload.text).digest("hex"),
|
|
5128
|
+
const event = storage.events.get(receipt3.eventId);
|
|
5129
|
+
assert14(event?.type === "system_event" && event.llmRepresentation === "none" && event.payload.subtype === "notification" && event.payload.producer === "import:migration_loss", `Missing history-loss placeholder for ${receipt3.sourceRecordId}`);
|
|
5130
|
+
assert14.equal(createHash10("sha256").update(event.payload.text).digest("hex"), receipt3.textDigest, `Changed history-loss placeholder for ${receipt3.sourceRecordId}`);
|
|
5123
5131
|
} catch (error) {
|
|
5124
|
-
fail(
|
|
5132
|
+
fail(receipt3.conversationId, failureReason(error));
|
|
5125
5133
|
}
|
|
5126
5134
|
}
|
|
5127
5135
|
for (const [table, expected] of Object.entries(summary.counts)) {
|
|
@@ -5138,15 +5146,15 @@ async function check(ctx, summary) {
|
|
|
5138
5146
|
if (failures.has(sourceOf.get(conversationId) ?? conversationId))
|
|
5139
5147
|
continue;
|
|
5140
5148
|
try {
|
|
5141
|
-
const
|
|
5142
|
-
assertProjectedPayload(
|
|
5149
|
+
const text3 = String(row2.payload), payload2 = JSON.parse(text3), bytes = Buffer.byteLength(text3);
|
|
5150
|
+
assertProjectedPayload(payload2);
|
|
5143
5151
|
payloadCount++;
|
|
5144
5152
|
payloadTotal += bytes;
|
|
5145
5153
|
payloadMax = Math.max(payloadMax, bytes);
|
|
5146
5154
|
if (row2.type === "tool_call_response") {
|
|
5147
|
-
assert14(!("result" in
|
|
5148
|
-
assert14(Array.isArray(
|
|
5149
|
-
const assets =
|
|
5155
|
+
assert14(!("result" in payload2) && !("modelContent" in payload2), "Inline complete result in event");
|
|
5156
|
+
assert14(Array.isArray(payload2.agentProjection) && payload2.userProjection, "Missing projections");
|
|
5157
|
+
const assets = payload2.assetIds.map((id) => storage.assets.get(id));
|
|
5150
5158
|
assert14(assets.every(Boolean), "Missing response asset row");
|
|
5151
5159
|
const result = assets.find((asset) => asset.category === "payload" && asset.logicalPath.endsWith("/result.json"));
|
|
5152
5160
|
assert14(result, "Missing complete result asset");
|
|
@@ -5164,8 +5172,8 @@ async function check(ctx, summary) {
|
|
|
5164
5172
|
assert14(assets.some((asset) => asset.id === record4.assetId && asset.category === "image"), "Untracked image reference");
|
|
5165
5173
|
Object.values(record4).forEach(refs);
|
|
5166
5174
|
};
|
|
5167
|
-
refs(
|
|
5168
|
-
refs(
|
|
5175
|
+
refs(payload2.agentProjection);
|
|
5176
|
+
refs(payload2.userProjection);
|
|
5169
5177
|
refs(complete);
|
|
5170
5178
|
responseCount++;
|
|
5171
5179
|
responseTotal += bytes;
|
|
@@ -5196,10 +5204,10 @@ async function check(ctx, summary) {
|
|
|
5196
5204
|
}
|
|
5197
5205
|
}
|
|
5198
5206
|
assert14.equal(paths.size, summary.assets.trackedFiles, "Asset coverage changed");
|
|
5199
|
-
for (const
|
|
5200
|
-
const logical = summary.assets.relocatedPayloads[
|
|
5207
|
+
for (const receipt3 of summary.assets.sourceFiles) {
|
|
5208
|
+
const logical = summary.assets.relocatedPayloads[receipt3.logicalPath] ?? receipt3.logicalPath;
|
|
5201
5209
|
if (!paths.has(logical))
|
|
5202
|
-
fail(
|
|
5210
|
+
fail(receipt3.conversationId, `Untracked source asset: ${receipt3.logicalPath}`);
|
|
5203
5211
|
}
|
|
5204
5212
|
assert14.equal(summary.assets.sourceFiles.length, summary.assets.diskFiles, "Source asset receipt coverage changed");
|
|
5205
5213
|
assert14.equal(selected.roots + excluded.size, summary.sourceConversationCount, "Source conversation receipt coverage changed");
|
|
@@ -5487,9 +5495,9 @@ function safePath(path) {
|
|
|
5487
5495
|
function readText(path) {
|
|
5488
5496
|
safePath(path);
|
|
5489
5497
|
assert15(lstatSync12(path).isFile(), `Expected regular file: ${path}`);
|
|
5490
|
-
const bytes = readFileSync7(path),
|
|
5491
|
-
assert15(Buffer.from(
|
|
5492
|
-
return
|
|
5498
|
+
const bytes = readFileSync7(path), text3 = bytes.toString("utf8");
|
|
5499
|
+
assert15(Buffer.from(text3, "utf8").equals(bytes), `Non-UTF8 migration source: ${path}`);
|
|
5500
|
+
return text3;
|
|
5493
5501
|
}
|
|
5494
5502
|
function json(path) {
|
|
5495
5503
|
return JSON.parse(readText(path));
|
|
@@ -5577,13 +5585,13 @@ function convertProfileDocument(value) {
|
|
|
5577
5585
|
}
|
|
5578
5586
|
function dropProfileDefaults(profile) {
|
|
5579
5587
|
for (const section of ["recommendations", "requirements"]) {
|
|
5580
|
-
const
|
|
5581
|
-
if (!object4(
|
|
5588
|
+
const contribution2 = structuredClone(profile[section]);
|
|
5589
|
+
if (!object4(contribution2) || !object4(contribution2.skills))
|
|
5582
5590
|
continue;
|
|
5583
|
-
profile[section] =
|
|
5584
|
-
delete
|
|
5585
|
-
if (!Object.keys(
|
|
5586
|
-
delete
|
|
5591
|
+
profile[section] = contribution2;
|
|
5592
|
+
delete contribution2.skills.defaults;
|
|
5593
|
+
if (!Object.keys(contribution2.skills).length)
|
|
5594
|
+
delete contribution2.skills;
|
|
5587
5595
|
}
|
|
5588
5596
|
}
|
|
5589
5597
|
function convertAppliedProfileDocument(value) {
|
|
@@ -5600,14 +5608,14 @@ function upgradeProfileDocuments(ctx, verifyOnly = false) {
|
|
|
5600
5608
|
const roots = /* @__PURE__ */ new Map([
|
|
5601
5609
|
[ctx.paths.home, join14(ctx.paths.home, "data", "agent-profiles")]
|
|
5602
5610
|
]);
|
|
5603
|
-
function update(path, root,
|
|
5611
|
+
function update(path, root, convert3) {
|
|
5604
5612
|
let before, after;
|
|
5605
5613
|
try {
|
|
5606
5614
|
safePath(path);
|
|
5607
5615
|
if (!existsSync14(path))
|
|
5608
5616
|
return;
|
|
5609
5617
|
before = json(path);
|
|
5610
|
-
after =
|
|
5618
|
+
after = convert3(before);
|
|
5611
5619
|
} catch (error) {
|
|
5612
5620
|
ctx.quarantine({
|
|
5613
5621
|
kind: "configuration",
|
|
@@ -5645,6 +5653,372 @@ import { DatabaseSync as DatabaseSync4 } from "node:sqlite";
|
|
|
5645
5653
|
import assert18 from "node:assert/strict";
|
|
5646
5654
|
import { createHash as createHash11 } from "node:crypto";
|
|
5647
5655
|
|
|
5656
|
+
// packages/workbench-server/dist/infrastructure/migrations/steps/0002-agent-profiles/frozen-agent-schemas.js
|
|
5657
|
+
var krokiToolSettingsSchema = external_exports.object({
|
|
5658
|
+
url: external_exports.string().trim().min(1).max(2048).url().refine((value) => {
|
|
5659
|
+
try {
|
|
5660
|
+
const url = new URL(value);
|
|
5661
|
+
return ["http:", "https:"].includes(url.protocol) && !url.username && !url.password && !url.search && !url.hash;
|
|
5662
|
+
} catch {
|
|
5663
|
+
return false;
|
|
5664
|
+
}
|
|
5665
|
+
}, {
|
|
5666
|
+
message: "Use an HTTP(S) URL without credentials, query parameters, or fragments."
|
|
5667
|
+
}).transform((value) => {
|
|
5668
|
+
const url = new URL(value);
|
|
5669
|
+
if (!url.pathname.endsWith("/"))
|
|
5670
|
+
url.pathname += "/";
|
|
5671
|
+
return url.href;
|
|
5672
|
+
})
|
|
5673
|
+
}).strict();
|
|
5674
|
+
var openAiCodexImageGenerationSettingsSchema = external_exports.object({
|
|
5675
|
+
provider: external_exports.literal("openai-codex"),
|
|
5676
|
+
model: external_exports.enum(["gpt-image-2.5-flare", "gpt-image-2.5-sunburst"]),
|
|
5677
|
+
options: external_exports.object({
|
|
5678
|
+
quality: external_exports.enum(["auto", "low", "medium", "high", "xhigh", "max"]),
|
|
5679
|
+
size: external_exports.union([
|
|
5680
|
+
external_exports.literal("auto"),
|
|
5681
|
+
external_exports.string().regex(/^\d+x\d+$/).refine((value) => {
|
|
5682
|
+
const [width, height] = value.split("x").map(Number);
|
|
5683
|
+
if (!width || !height || width % 16 !== 0 || height % 16 !== 0) {
|
|
5684
|
+
return false;
|
|
5685
|
+
}
|
|
5686
|
+
const longEdge = Math.max(width, height);
|
|
5687
|
+
const shortEdge = Math.min(width, height);
|
|
5688
|
+
const pixels = width * height;
|
|
5689
|
+
return longEdge <= 3840 && longEdge / shortEdge <= 3 && pixels >= 655360 && pixels <= 8294400;
|
|
5690
|
+
})
|
|
5691
|
+
]),
|
|
5692
|
+
background: external_exports.enum(["auto", "opaque", "transparent"])
|
|
5693
|
+
})
|
|
5694
|
+
});
|
|
5695
|
+
var imageGenerationToolSettingsSchema = external_exports.discriminatedUnion("provider", [
|
|
5696
|
+
openAiCodexImageGenerationSettingsSchema
|
|
5697
|
+
]);
|
|
5698
|
+
var profileIdSchema = external_exports.string().trim().min(1).max(256);
|
|
5699
|
+
function payloadOf(settings) {
|
|
5700
|
+
return external_exports.object({ enabled: external_exports.boolean().optional(), settings: settings.optional() }).strict();
|
|
5701
|
+
}
|
|
5702
|
+
var accountPayload = external_exports.object({
|
|
5703
|
+
enabled: external_exports.boolean().optional(),
|
|
5704
|
+
profileId: profileIdSchema.optional()
|
|
5705
|
+
}).strict();
|
|
5706
|
+
var quickScriptIntegrationSchema = external_exports.object({ enabled: external_exports.boolean(), profileId: profileIdSchema.optional() }).strict();
|
|
5707
|
+
var quickScriptToolSettingsSchema = external_exports.object({
|
|
5708
|
+
jira: quickScriptIntegrationSchema.optional(),
|
|
5709
|
+
confluence: quickScriptIntegrationSchema.optional(),
|
|
5710
|
+
web: quickScriptIntegrationSchema.optional(),
|
|
5711
|
+
diagram: krokiToolSettingsSchema.optional()
|
|
5712
|
+
}).strict();
|
|
5713
|
+
var capabilityToolPayloadSchemas = {
|
|
5714
|
+
python_exec: payloadOf(pythonExecToolSettingsSchema),
|
|
5715
|
+
web_search: accountPayload,
|
|
5716
|
+
web_fetch: payloadOf(external_exports.never()),
|
|
5717
|
+
explain_image: payloadOf(imageExplanationToolSettingsSchema),
|
|
5718
|
+
generate_image: payloadOf(imageGenerationToolSettingsSchema),
|
|
5719
|
+
kroki_export: payloadOf(krokiToolSettingsSchema),
|
|
5720
|
+
plan_present: payloadOf(planPresentToolSettingsSchema),
|
|
5721
|
+
subagents: payloadOf(external_exports.never()),
|
|
5722
|
+
jira: accountPayload,
|
|
5723
|
+
confluence: accountPayload,
|
|
5724
|
+
quick_script: payloadOf(quickScriptToolSettingsSchema),
|
|
5725
|
+
bash: external_exports.object({ settings: bashToolSettingsSchema }).strict()
|
|
5726
|
+
};
|
|
5727
|
+
var model = modelSelectionSchema.strict();
|
|
5728
|
+
var nonempty = (value) => Object.keys(value).length > 0;
|
|
5729
|
+
var compaction = external_exports.strictObject({
|
|
5730
|
+
auto: external_exports.boolean(),
|
|
5731
|
+
profile: compactionProfileSchema,
|
|
5732
|
+
customTriggerPercent: external_exports.number().int().min(60).max(90)
|
|
5733
|
+
});
|
|
5734
|
+
var retry = external_exports.strictObject({
|
|
5735
|
+
enabled: external_exports.boolean(),
|
|
5736
|
+
maxRetries: external_exports.number().int().nonnegative(),
|
|
5737
|
+
baseDelayMs: external_exports.number().int().positive()
|
|
5738
|
+
});
|
|
5739
|
+
var bash = bashToolSettingsSchema.extend({
|
|
5740
|
+
autoPromotion: bashToolSettingsSchema.shape.autoPromotion.strict(),
|
|
5741
|
+
maxTimeoutMs: bashToolSettingsSchema.shape.maxTimeoutMs.removeDefault()
|
|
5742
|
+
}).strict();
|
|
5743
|
+
var explanation = imageExplanationToolSettingsSchema.extend({ model: model.optional() }).strict();
|
|
5744
|
+
var generation = openAiCodexImageGenerationSettingsSchema.extend({
|
|
5745
|
+
options: openAiCodexImageGenerationSettingsSchema.shape.options.strict()
|
|
5746
|
+
}).strict();
|
|
5747
|
+
var sourceDefaults = external_exports.strictObject({
|
|
5748
|
+
file: external_exports.boolean(),
|
|
5749
|
+
nerve: external_exports.boolean(),
|
|
5750
|
+
agentBrowser: external_exports.boolean()
|
|
5751
|
+
});
|
|
5752
|
+
var skills = capabilitySkillsSchema.partial().extend({ defaults: sourceDefaults.partial().optional() }).strict();
|
|
5753
|
+
function payload(settings) {
|
|
5754
|
+
return external_exports.strictObject({
|
|
5755
|
+
enabled: external_exports.boolean().optional(),
|
|
5756
|
+
settings: settings.optional()
|
|
5757
|
+
}).refine(nonempty, "Empty tool entry");
|
|
5758
|
+
}
|
|
5759
|
+
var toggle = external_exports.strictObject({ enabled: external_exports.boolean() });
|
|
5760
|
+
var account = capabilityToolPayloadSchemas.jira.refine(nonempty, "Empty tool entry");
|
|
5761
|
+
var quickScriptIntegration = quickScriptIntegrationSchema.partial().refine(nonempty);
|
|
5762
|
+
var quickScriptOverrides = external_exports.strictObject({
|
|
5763
|
+
jira: quickScriptIntegration.optional(),
|
|
5764
|
+
confluence: quickScriptIntegration.optional(),
|
|
5765
|
+
web: quickScriptIntegration.optional(),
|
|
5766
|
+
diagram: krokiToolSettingsSchema.partial().refine(nonempty).optional()
|
|
5767
|
+
}).refine(nonempty);
|
|
5768
|
+
var childToolShape = {
|
|
5769
|
+
python_exec: payload(pythonExecToolSettingsSchema.partial()),
|
|
5770
|
+
web_search: account,
|
|
5771
|
+
jira: account,
|
|
5772
|
+
confluence: account,
|
|
5773
|
+
quick_script: payload(quickScriptOverrides),
|
|
5774
|
+
web_fetch: toggle,
|
|
5775
|
+
explain_image: payload(explanation.partial().refine(nonempty)),
|
|
5776
|
+
generate_image: payload(generation),
|
|
5777
|
+
kroki_export: payload(krokiToolSettingsSchema.partial().refine(nonempty)),
|
|
5778
|
+
bash: external_exports.strictObject({ settings: bash.partial().refine(nonempty) })
|
|
5779
|
+
};
|
|
5780
|
+
var leadTools = external_exports.strictObject({
|
|
5781
|
+
...childToolShape,
|
|
5782
|
+
plan_present: payload(planPresentToolSettingsSchema.partial().refine(nonempty)),
|
|
5783
|
+
subagents: toggle
|
|
5784
|
+
}).partial();
|
|
5785
|
+
var childTools = external_exports.strictObject(childToolShape).partial();
|
|
5786
|
+
var launch = external_exports.strictObject({
|
|
5787
|
+
model: model.optional(),
|
|
5788
|
+
reasoningLevel: thinkingLevelSchema.optional()
|
|
5789
|
+
});
|
|
5790
|
+
var subagent = launch.extend({ enabled: external_exports.boolean().optional() }).refine(nonempty);
|
|
5791
|
+
var childShape = {
|
|
5792
|
+
model: model.optional(),
|
|
5793
|
+
reasoningLevel: thinkingLevelSchema.optional(),
|
|
5794
|
+
permissionRuleSetId: permissionRuleSetIdSchema.optional(),
|
|
5795
|
+
compaction: compaction.partial().optional(),
|
|
5796
|
+
retry: retry.partial().optional(),
|
|
5797
|
+
tools: childTools.optional(),
|
|
5798
|
+
skills: skills.optional()
|
|
5799
|
+
};
|
|
5800
|
+
var childSettingsOverridesSchema = external_exports.strictObject(childShape);
|
|
5801
|
+
var leadSettingsOverridesSchema = external_exports.strictObject({
|
|
5802
|
+
...childShape,
|
|
5803
|
+
tools: leadTools.optional(),
|
|
5804
|
+
subagents: external_exports.record(agentProfileNameSchema, subagent).optional()
|
|
5805
|
+
});
|
|
5806
|
+
var completeTools = external_exports.strictObject({
|
|
5807
|
+
python_exec: external_exports.strictObject({
|
|
5808
|
+
enabled: external_exports.boolean(),
|
|
5809
|
+
settings: pythonExecToolSettingsSchema
|
|
5810
|
+
}),
|
|
5811
|
+
web_search: capabilityToolPayloadSchemas.web_search.required({
|
|
5812
|
+
enabled: true
|
|
5813
|
+
}),
|
|
5814
|
+
jira: capabilityToolPayloadSchemas.jira.required({ enabled: true }),
|
|
5815
|
+
confluence: capabilityToolPayloadSchemas.confluence.required({
|
|
5816
|
+
enabled: true
|
|
5817
|
+
}),
|
|
5818
|
+
// Optional: configurations frozen before this tool existed omit it (= off).
|
|
5819
|
+
quick_script: capabilityToolPayloadSchemas.quick_script.required({ enabled: true }).optional(),
|
|
5820
|
+
web_fetch: toggle,
|
|
5821
|
+
explain_image: external_exports.strictObject({
|
|
5822
|
+
enabled: external_exports.boolean(),
|
|
5823
|
+
settings: explanation
|
|
5824
|
+
}),
|
|
5825
|
+
generate_image: external_exports.strictObject({
|
|
5826
|
+
enabled: external_exports.boolean(),
|
|
5827
|
+
settings: generation
|
|
5828
|
+
}),
|
|
5829
|
+
kroki_export: external_exports.strictObject({
|
|
5830
|
+
enabled: external_exports.boolean(),
|
|
5831
|
+
settings: krokiToolSettingsSchema
|
|
5832
|
+
}),
|
|
5833
|
+
bash: external_exports.strictObject({ settings: bash })
|
|
5834
|
+
});
|
|
5835
|
+
var completeChildSettingsSchema = childSettingsOverridesSchema.extend({
|
|
5836
|
+
reasoningLevel: thinkingLevelSchema,
|
|
5837
|
+
permissionRuleSetId: permissionRuleSetIdSchema,
|
|
5838
|
+
compaction,
|
|
5839
|
+
retry,
|
|
5840
|
+
tools: completeTools,
|
|
5841
|
+
skills: capabilitySkillsSchema.extend({ defaults: sourceDefaults }).strict()
|
|
5842
|
+
});
|
|
5843
|
+
var sha256HexSchema = external_exports.string().regex(/^[a-f0-9]{64}$/);
|
|
5844
|
+
var revision = external_exports.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
5845
|
+
var contribution = {
|
|
5846
|
+
name: agentProfileNameSchema,
|
|
5847
|
+
source: external_exports.enum(["builtin", "user", "project"]),
|
|
5848
|
+
sourceDigest: sha256HexSchema,
|
|
5849
|
+
instructions: agentProfileInstructionsSchema
|
|
5850
|
+
};
|
|
5851
|
+
var profileSettingsOverridesSchema = leadSettingsOverridesSchema.extend({
|
|
5852
|
+
skills: capabilitySkillsSchema.partial().strict().optional()
|
|
5853
|
+
});
|
|
5854
|
+
var appliedProfileSchema = external_exports.strictObject({
|
|
5855
|
+
...contribution,
|
|
5856
|
+
recommendations: profileSettingsOverridesSchema,
|
|
5857
|
+
requirements: profileSettingsOverridesSchema
|
|
5858
|
+
}).superRefine(checkOverlap);
|
|
5859
|
+
var agentPreferencesSchema = external_exports.strictObject({
|
|
5860
|
+
schemaVersion: external_exports.literal(1),
|
|
5861
|
+
revision,
|
|
5862
|
+
overrides: leadSettingsOverridesSchema
|
|
5863
|
+
});
|
|
5864
|
+
var receipt = external_exports.strictObject({
|
|
5865
|
+
id: external_exports.string().min(1),
|
|
5866
|
+
kind: external_exports.enum(["profile", "plan-approval"])
|
|
5867
|
+
});
|
|
5868
|
+
var conversationAgentContextSchema = external_exports.strictObject({
|
|
5869
|
+
instructions: agentProfileInstructionsSchema.optional(),
|
|
5870
|
+
systemPrompt: external_exports.string().optional()
|
|
5871
|
+
});
|
|
5872
|
+
var leadConversationAgentSchema = agentPreferencesSchema.extend({
|
|
5873
|
+
context: conversationAgentContextSchema.optional(),
|
|
5874
|
+
appliedProfile: appliedProfileSchema.nullable(),
|
|
5875
|
+
lastTransition: receipt.optional()
|
|
5876
|
+
});
|
|
5877
|
+
var childConversationAgentSchema = external_exports.strictObject({
|
|
5878
|
+
schemaVersion: external_exports.literal(1),
|
|
5879
|
+
revision,
|
|
5880
|
+
overrides: childSettingsOverridesSchema,
|
|
5881
|
+
appliedProfile: appliedProfileSchema.nullable(),
|
|
5882
|
+
frozenDefaults: completeChildSettingsSchema,
|
|
5883
|
+
context: conversationAgentContextSchema.optional(),
|
|
5884
|
+
lastTransition: receipt.optional()
|
|
5885
|
+
}).superRefine((v, ctx) => {
|
|
5886
|
+
if (v.appliedProfile)
|
|
5887
|
+
for (const section of ["recommendations", "requirements"]) {
|
|
5888
|
+
const parsed = childSettingsOverridesSchema.safeParse(v.appliedProfile[section]);
|
|
5889
|
+
if (!parsed.success)
|
|
5890
|
+
ctx.addIssue({
|
|
5891
|
+
code: "custom",
|
|
5892
|
+
path: ["appliedProfile", section],
|
|
5893
|
+
message: "Child-prohibited profile contribution"
|
|
5894
|
+
});
|
|
5895
|
+
}
|
|
5896
|
+
});
|
|
5897
|
+
var profileDefinitionSchema = external_exports.strictObject({
|
|
5898
|
+
schemaVersion: external_exports.literal(1),
|
|
5899
|
+
name: agentProfileNameSchema,
|
|
5900
|
+
label: external_exports.string().trim().min(1).max(AGENT_PROFILE_LABEL_MAX_LENGTH).optional(),
|
|
5901
|
+
whenToUse: external_exports.string().trim().min(1).max(AGENT_PROFILE_WHEN_TO_USE_MAX_LENGTH),
|
|
5902
|
+
/** Authored launch default (true if omitted), not availability or a requirement. */
|
|
5903
|
+
enabled: external_exports.boolean().optional(),
|
|
5904
|
+
usableBy: external_exports.enum(["lead", "subagent", "both"]),
|
|
5905
|
+
instructions: agentProfileInstructionsSchema,
|
|
5906
|
+
recommendations: profileSettingsOverridesSchema.optional(),
|
|
5907
|
+
requirements: profileSettingsOverridesSchema.optional()
|
|
5908
|
+
}).superRefine((v, ctx) => {
|
|
5909
|
+
checkOverlap(v, ctx);
|
|
5910
|
+
if (v.usableBy !== "lead") {
|
|
5911
|
+
for (const section of ["recommendations", "requirements"])
|
|
5912
|
+
if (v[section] && !childSettingsOverridesSchema.safeParse(v[section]).success)
|
|
5913
|
+
ctx.addIssue({
|
|
5914
|
+
code: "custom",
|
|
5915
|
+
path: [section],
|
|
5916
|
+
message: "Profile must be child-compatible"
|
|
5917
|
+
});
|
|
5918
|
+
}
|
|
5919
|
+
});
|
|
5920
|
+
var conversationDefaultsSchema = external_exports.strictObject({
|
|
5921
|
+
schemaVersion: external_exports.literal(1),
|
|
5922
|
+
revision,
|
|
5923
|
+
overrides: external_exports.strictObject({
|
|
5924
|
+
defaultAgentProfile: agentProfileNameSchema.optional(),
|
|
5925
|
+
scopedModels: external_exports.array(model).optional()
|
|
5926
|
+
})
|
|
5927
|
+
});
|
|
5928
|
+
var agentSummarySchema = external_exports.strictObject({
|
|
5929
|
+
model: model.optional(),
|
|
5930
|
+
reasoningLevel: thinkingLevelSchema.optional(),
|
|
5931
|
+
permissionRuleSetId: permissionRuleSetIdSchema.optional(),
|
|
5932
|
+
agentProfile: agentProfileNameSchema.optional()
|
|
5933
|
+
});
|
|
5934
|
+
var conversationAgentSummariesSchema = external_exports.strictObject({
|
|
5935
|
+
schemaVersion: external_exports.literal(1),
|
|
5936
|
+
entries: external_exports.record(external_exports.string().min(1), agentSummarySchema.extend({ observedDigest: sha256HexSchema }))
|
|
5937
|
+
});
|
|
5938
|
+
var configurationDiagnosticSchema = external_exports.strictObject({
|
|
5939
|
+
scope: external_exports.enum(["user", "project", "conversation"]),
|
|
5940
|
+
scopeId: external_exports.string().optional(),
|
|
5941
|
+
document: external_exports.string().min(1),
|
|
5942
|
+
path: external_exports.string(),
|
|
5943
|
+
schemaVersion: external_exports.number().int().optional(),
|
|
5944
|
+
code: external_exports.string().min(1),
|
|
5945
|
+
pointer: external_exports.string(),
|
|
5946
|
+
message: external_exports.string().optional(),
|
|
5947
|
+
affectedCapability: external_exports.string().min(1),
|
|
5948
|
+
recoveryChoices: external_exports.array(external_exports.enum(["retry", "reload", "repair", "reset", "upgrade"]))
|
|
5949
|
+
});
|
|
5950
|
+
var configurationSourceSchema = external_exports.enum([
|
|
5951
|
+
"builtin",
|
|
5952
|
+
"user",
|
|
5953
|
+
"project",
|
|
5954
|
+
"process",
|
|
5955
|
+
"recommendation",
|
|
5956
|
+
"conversation",
|
|
5957
|
+
"requirement",
|
|
5958
|
+
"frozen",
|
|
5959
|
+
"launch"
|
|
5960
|
+
]);
|
|
5961
|
+
var fieldProvenanceSchema = external_exports.strictObject({
|
|
5962
|
+
source: configurationSourceSchema,
|
|
5963
|
+
profile: agentProfileNameSchema.optional(),
|
|
5964
|
+
adjusted: external_exports.boolean().optional()
|
|
5965
|
+
}).superRefine((value, ctx) => {
|
|
5966
|
+
if ((value.source === "requirement" || value.source === "recommendation") && !value.profile)
|
|
5967
|
+
ctx.addIssue({
|
|
5968
|
+
code: "custom",
|
|
5969
|
+
path: ["profile"],
|
|
5970
|
+
message: "Profile contributions must identify the controlling profile"
|
|
5971
|
+
});
|
|
5972
|
+
});
|
|
5973
|
+
var resolutionDiagnosticSchema = external_exports.strictObject({
|
|
5974
|
+
code: external_exports.enum([
|
|
5975
|
+
"model-required",
|
|
5976
|
+
"reasoning-adjusted",
|
|
5977
|
+
"unsupported-reasoning",
|
|
5978
|
+
"missing-reference"
|
|
5979
|
+
]),
|
|
5980
|
+
pointer: external_exports.string()
|
|
5981
|
+
});
|
|
5982
|
+
var agentResolutionSchema = external_exports.strictObject({
|
|
5983
|
+
settings: leadSettingsOverridesSchema,
|
|
5984
|
+
provenance: external_exports.record(external_exports.string().regex(/^\/(?:[^~]|~[01])*$/), fieldProvenanceSchema),
|
|
5985
|
+
diagnostics: external_exports.array(resolutionDiagnosticSchema)
|
|
5986
|
+
});
|
|
5987
|
+
function escapePointer(value) {
|
|
5988
|
+
return value.replaceAll("~", "~0").replaceAll("/", "~1");
|
|
5989
|
+
}
|
|
5990
|
+
function canonicalSettingsEntries(value) {
|
|
5991
|
+
const entries = [];
|
|
5992
|
+
function walk2(node, path) {
|
|
5993
|
+
const atomic = /(?:^|\/)model$/.test(path) || path === "/tools/generate_image/settings" || path === "/tools/bash/settings/autoPromotion";
|
|
5994
|
+
if (node !== void 0 && (atomic || typeof node !== "object" || node === null || Array.isArray(node)))
|
|
5995
|
+
entries.push([path, node]);
|
|
5996
|
+
else if (node)
|
|
5997
|
+
for (const [key2, child] of Object.entries(node))
|
|
5998
|
+
walk2(child, `${path}/${escapePointer(key2)}`);
|
|
5999
|
+
}
|
|
6000
|
+
walk2(value, "");
|
|
6001
|
+
return entries;
|
|
6002
|
+
}
|
|
6003
|
+
function requirementOverlaps(recommendations = {}, requirements = {}) {
|
|
6004
|
+
const a = canonicalSettingsEntries(recommendations).map(([p]) => p), b = canonicalSettingsEntries(requirements).map(([p]) => p);
|
|
6005
|
+
function overlaps(x, y) {
|
|
6006
|
+
if (x === y || x.startsWith(y + "/") || y.startsWith(x + "/"))
|
|
6007
|
+
return true;
|
|
6008
|
+
const source = (p) => p.startsWith("/skills/defaults/") ? p.slice(17) : p.startsWith("/skills/") ? p.split("/")[2] : void 0;
|
|
6009
|
+
return source(x) !== void 0 && source(x) === source(y) && (x.startsWith("/skills/defaults/") || y.startsWith("/skills/defaults/"));
|
|
6010
|
+
}
|
|
6011
|
+
return a.filter((x) => b.some((y) => overlaps(x, y)));
|
|
6012
|
+
}
|
|
6013
|
+
function checkOverlap(v, ctx) {
|
|
6014
|
+
for (const pointer of requirementOverlaps(v.recommendations, v.requirements))
|
|
6015
|
+
ctx.addIssue({
|
|
6016
|
+
code: "custom",
|
|
6017
|
+
path: ["requirements"],
|
|
6018
|
+
message: `Recommendation/requirement overlap: ${pointer}`
|
|
6019
|
+
});
|
|
6020
|
+
}
|
|
6021
|
+
|
|
5648
6022
|
// packages/workbench-server/dist/infrastructure/migrations/steps/0002-agent-profiles/released-baseline.json
|
|
5649
6023
|
var released_baseline_default = {
|
|
5650
6024
|
harness: {
|
|
@@ -5899,7 +6273,7 @@ var optionalTools = [
|
|
|
5899
6273
|
"confluence"
|
|
5900
6274
|
];
|
|
5901
6275
|
var rename = (name) => name === "plan_mode_present" ? "plan_present" : name === "explore" || name.startsWith("subagent_") ? "subagents" : name;
|
|
5902
|
-
function
|
|
6276
|
+
function compaction2(value, report) {
|
|
5903
6277
|
const result = structuredClone(value);
|
|
5904
6278
|
for (const key2 of ["customKeepRecentPercent", "keepRecentPercent"])
|
|
5905
6279
|
if (key2 in result) {
|
|
@@ -5967,7 +6341,7 @@ function convertPreferencesV037(input, ctx) {
|
|
|
5967
6341
|
if (raw.scopedModels !== void 0)
|
|
5968
6342
|
creation.scopedModels = raw.scopedModels;
|
|
5969
6343
|
if (raw.compaction)
|
|
5970
|
-
overrides.compaction =
|
|
6344
|
+
overrides.compaction = compaction2(raw.compaction, ctx.report);
|
|
5971
6345
|
if (raw.retry)
|
|
5972
6346
|
overrides.retry = raw.retry;
|
|
5973
6347
|
const tools = {};
|
|
@@ -6037,9 +6411,9 @@ function convertPreferencesV037(input, ctx) {
|
|
|
6037
6411
|
const lower = ctx.inheritedSettings ?? {};
|
|
6038
6412
|
if (overrides.model)
|
|
6039
6413
|
overrides.model = { ...lower.model, ...overrides.model };
|
|
6040
|
-
const
|
|
6041
|
-
if (
|
|
6042
|
-
overrides.tools.generate_image.settings = merge(merge(released_baseline_default.harness.tools.imageGeneration, lower.tools?.generate_image?.settings ?? {}),
|
|
6414
|
+
const generation2 = overrides.tools?.generate_image?.settings;
|
|
6415
|
+
if (generation2 && raw.tools?.imageGeneration && !input.capabilities?.toolSettings?.generate_image)
|
|
6416
|
+
overrides.tools.generate_image.settings = merge(merge(released_baseline_default.harness.tools.imageGeneration, lower.tools?.generate_image?.settings ?? {}), generation2);
|
|
6043
6417
|
const promotion = overrides.tools?.bash?.settings?.autoPromotion;
|
|
6044
6418
|
if (promotion)
|
|
6045
6419
|
overrides.tools.bash.settings.autoPromotion = {
|
|
@@ -6047,11 +6421,11 @@ function convertPreferencesV037(input, ctx) {
|
|
|
6047
6421
|
...lower.tools?.bash?.settings?.autoPromotion,
|
|
6048
6422
|
...promotion
|
|
6049
6423
|
};
|
|
6050
|
-
const
|
|
6051
|
-
if (
|
|
6052
|
-
|
|
6424
|
+
const explanation2 = overrides.tools?.explain_image?.settings;
|
|
6425
|
+
if (explanation2?.model)
|
|
6426
|
+
explanation2.model = {
|
|
6053
6427
|
...lower.tools?.explain_image?.settings?.model,
|
|
6054
|
-
...
|
|
6428
|
+
...explanation2.model
|
|
6055
6429
|
};
|
|
6056
6430
|
}
|
|
6057
6431
|
const integrations = integration ? { ...integration, version: 2 } : void 0;
|
|
@@ -6076,9 +6450,9 @@ function splitCatalogV037(input, scope, ctx) {
|
|
|
6076
6450
|
const launches = {}, profiles = {};
|
|
6077
6451
|
for (const [name, value] of Object.entries(catalog.profiles)) {
|
|
6078
6452
|
const raw = value;
|
|
6079
|
-
const
|
|
6453
|
+
const launch2 = {};
|
|
6080
6454
|
if (raw.enabled !== void 0)
|
|
6081
|
-
|
|
6455
|
+
launch2.enabled = raw.enabled;
|
|
6082
6456
|
for (const [field, key2] of [
|
|
6083
6457
|
["model", "model"],
|
|
6084
6458
|
["thinking", "reasoningLevel"]
|
|
@@ -6089,16 +6463,16 @@ function splitCatalogV037(input, scope, ctx) {
|
|
|
6089
6463
|
if (field === "model") {
|
|
6090
6464
|
const slash = raw.model.indexOf("/");
|
|
6091
6465
|
assert18(slash > 0, "Invalid released model reference");
|
|
6092
|
-
|
|
6466
|
+
launch2.model = {
|
|
6093
6467
|
provider: raw.model.slice(0, slash),
|
|
6094
6468
|
modelId: raw.model.slice(slash + 1)
|
|
6095
6469
|
};
|
|
6096
6470
|
} else
|
|
6097
|
-
|
|
6471
|
+
launch2[key2] = raw[field];
|
|
6098
6472
|
}
|
|
6099
6473
|
}
|
|
6100
|
-
if (Object.keys(
|
|
6101
|
-
launches[name] =
|
|
6474
|
+
if (Object.keys(launch2).length)
|
|
6475
|
+
launches[name] = launch2;
|
|
6102
6476
|
const other = Object.keys(raw).filter((key2) => !["enabled", "model", "thinking"].includes(key2));
|
|
6103
6477
|
if (scope === "conversation") {
|
|
6104
6478
|
if (other.length)
|
|
@@ -6109,12 +6483,12 @@ function splitCatalogV037(input, scope, ctx) {
|
|
|
6109
6483
|
continue;
|
|
6110
6484
|
const complete = merge(Object.hasOwn(ctx.builtins, name) ? ctx.builtins[name] : {}, raw);
|
|
6111
6485
|
assert18(complete.description && complete.instructions !== void 0 && complete.model !== void 0 && complete.thinking !== void 0 && complete.permission !== void 0 && complete.compaction !== void 0 && complete.skills !== void 0, `Incomplete custom released profile: ${name}`);
|
|
6112
|
-
const recommendations = { ...
|
|
6486
|
+
const recommendations = { ...launch2 };
|
|
6113
6487
|
delete recommendations.enabled;
|
|
6114
6488
|
if (complete.permission !== void 0)
|
|
6115
6489
|
recommendations.permissionRuleSetId = complete.permission;
|
|
6116
6490
|
if (complete.compaction && complete.compaction !== "inherit")
|
|
6117
|
-
recommendations.compaction =
|
|
6491
|
+
recommendations.compaction = compaction2(complete.compaction, ctx.report);
|
|
6118
6492
|
for (const [tool, settings] of Object.entries(complete.tools ?? {}))
|
|
6119
6493
|
(recommendations.tools ??= {})[rename(tool)] = typeof settings === "boolean" ? { enabled: settings } : { settings };
|
|
6120
6494
|
if (complete.skills && complete.skills !== "none" && complete.skills !== "inherit")
|
|
@@ -6166,7 +6540,7 @@ function convertConversationV037(row2, input, ctx) {
|
|
|
6166
6540
|
if (input.harness !== void 0) {
|
|
6167
6541
|
const own2 = releasedConversationHarnessSchema.parse(input.harness);
|
|
6168
6542
|
if (own2.compaction)
|
|
6169
|
-
overrides.compaction =
|
|
6543
|
+
overrides.compaction = compaction2(own2.compaction, ctx.report);
|
|
6170
6544
|
}
|
|
6171
6545
|
if (input.subagents !== void 0)
|
|
6172
6546
|
overrides.subagents = splitCatalogV037(input.subagents, "conversation", ctx).launches;
|
|
@@ -6330,20 +6704,20 @@ function documentFiles(home, projects, conversations) {
|
|
|
6330
6704
|
return result;
|
|
6331
6705
|
}
|
|
6332
6706
|
function convertEventPayload(value) {
|
|
6333
|
-
const
|
|
6334
|
-
assert19(
|
|
6335
|
-
if (Array.isArray(
|
|
6336
|
-
for (const block of
|
|
6707
|
+
const payload2 = record3(structuredClone(value));
|
|
6708
|
+
assert19(payload2, "Expected event payload");
|
|
6709
|
+
if (Array.isArray(payload2.content))
|
|
6710
|
+
for (const block of payload2.content) {
|
|
6337
6711
|
const entry2 = record3(block);
|
|
6338
6712
|
if (entry2?.type === "toolCall")
|
|
6339
6713
|
entry2.name = toolName(entry2.name);
|
|
6340
6714
|
}
|
|
6341
|
-
if (Object.hasOwn(
|
|
6342
|
-
|
|
6343
|
-
const projection = record3(
|
|
6715
|
+
if (Object.hasOwn(payload2, "toolName"))
|
|
6716
|
+
payload2.toolName = toolName(payload2.toolName);
|
|
6717
|
+
const projection = record3(payload2.userProjection);
|
|
6344
6718
|
if (projection && Object.hasOwn(projection, "toolName"))
|
|
6345
6719
|
projection.toolName = toolName(projection.toolName);
|
|
6346
|
-
return
|
|
6720
|
+
return payload2;
|
|
6347
6721
|
}
|
|
6348
6722
|
function parsePolicySource(bytes, path, report) {
|
|
6349
6723
|
try {
|
|
@@ -6430,15 +6804,15 @@ function planMetadata(input) {
|
|
|
6430
6804
|
for (const event of input.events) {
|
|
6431
6805
|
const before = JSON.parse(event.payload);
|
|
6432
6806
|
const after = convertEventPayload(before);
|
|
6433
|
-
const
|
|
6807
|
+
const payload2 = objectValue(after);
|
|
6434
6808
|
const reasons = [];
|
|
6435
6809
|
if (JSON.stringify(before) !== JSON.stringify(after))
|
|
6436
6810
|
reasons.push("Renamed historical planning tool metadata in conversation_event.payload");
|
|
6437
|
-
const resolution = objectValue(
|
|
6811
|
+
const resolution = objectValue(payload2.interactionResolution);
|
|
6438
6812
|
if (resolution?.kind === "plan_review" && resolution.decision === "approve" && !Object.hasOwn(resolution, "confirmation")) {
|
|
6439
|
-
assert21(typeof
|
|
6440
|
-
const id =
|
|
6441
|
-
const request = requests.get(id) ?? historicalReviewRequest({ approvalProfile: objectValue(
|
|
6813
|
+
assert21(typeof payload2.toolCallId === "string", "Missing historical plan-review tool call ID");
|
|
6814
|
+
const id = payload2.toolCallId;
|
|
6815
|
+
const request = requests.get(id) ?? historicalReviewRequest({ approvalProfile: objectValue(payload2.arguments)?.approvalProfile }, id);
|
|
6442
6816
|
if (historicalReviewConfirmation(resolution, request, id))
|
|
6443
6817
|
reasons.push(eventConfirmationReason);
|
|
6444
6818
|
}
|
|
@@ -6757,87 +7131,87 @@ function prepareExport(io2, input) {
|
|
|
6757
7131
|
}
|
|
6758
7132
|
function applyExport(io2, receiptPath, proposed) {
|
|
6759
7133
|
const saved = io2.read(receiptPath);
|
|
6760
|
-
const
|
|
7134
|
+
const receipt3 = exportReceiptSchema.parse(saved === void 0 ? proposed : JSON.parse(saved));
|
|
6761
7135
|
if (saved !== void 0)
|
|
6762
|
-
assert23.deepEqual(
|
|
6763
|
-
for (const [path, source] of Object.entries(
|
|
7136
|
+
assert23.deepEqual(receipt3, proposed, "Changed migration plan");
|
|
7137
|
+
for (const [path, source] of Object.entries(receipt3.sources)) {
|
|
6764
7138
|
const bytes = io2.read(path), backup2 = io2.read(source.backup);
|
|
6765
7139
|
if (backup2 !== void 0)
|
|
6766
7140
|
assert23.equal(sha256(backup2), source.digest, "Changed original backup");
|
|
6767
|
-
const candidate =
|
|
7141
|
+
const candidate = receipt3.targets[path];
|
|
6768
7142
|
assert23(bytes !== void 0 && (sha256(bytes) === source.digest || saved !== void 0 && candidate && sha256(bytes) === candidate.digest), `Changed migration source: ${path}`);
|
|
6769
7143
|
if (backup2 === void 0) {
|
|
6770
7144
|
assert23.equal(sha256(bytes), source.digest, "Original missing before backup");
|
|
6771
7145
|
io2.write(source.backup, bytes);
|
|
6772
7146
|
}
|
|
6773
7147
|
}
|
|
6774
|
-
for (const [path, output] of Object.entries(
|
|
7148
|
+
for (const [path, output] of Object.entries(receipt3.targets)) {
|
|
6775
7149
|
validateTarget(output);
|
|
6776
7150
|
const actual = io2.read(path);
|
|
6777
|
-
assert23(actual === void 0 ||
|
|
7151
|
+
assert23(actual === void 0 || receipt3.sources[path] && sha256(actual) === receipt3.sources[path].digest || saved !== void 0 && sha256(actual) === output.digest, `Migration target collision or later edit: ${path}`);
|
|
6778
7152
|
}
|
|
6779
7153
|
if (saved === void 0)
|
|
6780
|
-
io2.write(receiptPath, jsonBytes(
|
|
6781
|
-
for (const [path, output] of Object.entries(
|
|
7154
|
+
io2.write(receiptPath, jsonBytes(receipt3));
|
|
7155
|
+
for (const [path, output] of Object.entries(receipt3.targets)) {
|
|
6782
7156
|
if (io2.read(path) !== output.bytes)
|
|
6783
7157
|
io2.write(path, output.bytes);
|
|
6784
7158
|
assert23.equal(io2.read(path), output.bytes, "Export readback mismatch");
|
|
6785
7159
|
}
|
|
6786
7160
|
}
|
|
6787
|
-
function verifyExport(io2,
|
|
6788
|
-
exportReceiptSchema.parse(
|
|
6789
|
-
assert23.equal(
|
|
6790
|
-
for (const [path, source] of Object.entries(
|
|
7161
|
+
function verifyExport(io2, receipt3, expectedRowDigest, allowRetired = false) {
|
|
7162
|
+
exportReceiptSchema.parse(receipt3);
|
|
7163
|
+
assert23.equal(receipt3.rowDigest, expectedRowDigest, "Released database row changed since export");
|
|
7164
|
+
for (const [path, source] of Object.entries(receipt3.sources)) {
|
|
6791
7165
|
const current = io2.read(path);
|
|
6792
|
-
if (!(allowRetired && current === void 0 &&
|
|
6793
|
-
assert23(current !== void 0 && sha256(current) === (
|
|
7166
|
+
if (!(allowRetired && current === void 0 && receipt3.retire.includes(path))) {
|
|
7167
|
+
assert23(current !== void 0 && sha256(current) === (receipt3.targets[path]?.digest ?? source.digest), `Source changed after export: ${path}`);
|
|
6794
7168
|
}
|
|
6795
7169
|
const original = io2.read(source.backup);
|
|
6796
7170
|
assert23(original !== void 0 && sha256(original) === source.digest, "Missing or changed protected original");
|
|
6797
7171
|
}
|
|
6798
|
-
for (const [path, output] of Object.entries(
|
|
7172
|
+
for (const [path, output] of Object.entries(receipt3.targets)) {
|
|
6799
7173
|
validateTarget(output);
|
|
6800
7174
|
assert23.equal(io2.read(path), output.bytes, `Missing or changed export: ${path}`);
|
|
6801
7175
|
}
|
|
6802
7176
|
}
|
|
6803
|
-
function retireExportSources(io2,
|
|
6804
|
-
verifyExport(io2,
|
|
6805
|
-
for (const path of
|
|
6806
|
-
assert23(!
|
|
7177
|
+
function retireExportSources(io2, receipt3) {
|
|
7178
|
+
verifyExport(io2, receipt3, receipt3.rowDigest, true);
|
|
7179
|
+
for (const path of receipt3.retire) {
|
|
7180
|
+
assert23(!receipt3.targets[path] && receipt3.sources[path], "Invalid source retirement");
|
|
6807
7181
|
const bytes = io2.read(path);
|
|
6808
7182
|
if (bytes === void 0)
|
|
6809
7183
|
continue;
|
|
6810
|
-
assert23.equal(sha256(bytes),
|
|
7184
|
+
assert23.equal(sha256(bytes), receipt3.sources[path].digest, "Source changed before retirement");
|
|
6811
7185
|
io2.remove(path);
|
|
6812
7186
|
}
|
|
6813
7187
|
}
|
|
6814
|
-
function preflightRollbackExport(io2,
|
|
6815
|
-
for (const [path, output] of Object.entries(
|
|
7188
|
+
function preflightRollbackExport(io2, receipt3) {
|
|
7189
|
+
for (const [path, output] of Object.entries(receipt3.targets)) {
|
|
6816
7190
|
const current = io2.read(path);
|
|
6817
|
-
assert23(current === void 0 || sha256(current) === output.digest ||
|
|
7191
|
+
assert23(current === void 0 || sha256(current) === output.digest || receipt3.sources[path] && sha256(current) === receipt3.sources[path].digest, `Rollback conflicts with later edit: ${path}`);
|
|
6818
7192
|
}
|
|
6819
|
-
for (const [path, source] of Object.entries(
|
|
7193
|
+
for (const [path, source] of Object.entries(receipt3.sources)) {
|
|
6820
7194
|
const backup2 = io2.read(source.backup), current = io2.read(path);
|
|
6821
7195
|
assert23(backup2 !== void 0 && sha256(backup2) === source.digest, "Rollback original unavailable");
|
|
6822
|
-
assert23(current === void 0 || sha256(current) === source.digest ||
|
|
7196
|
+
assert23(current === void 0 || sha256(current) === source.digest || receipt3.targets[path] && sha256(current) === receipt3.targets[path].digest, `Rollback source conflicts with later edit: ${path}`);
|
|
6823
7197
|
}
|
|
6824
7198
|
}
|
|
6825
|
-
function rollbackExport(io2,
|
|
6826
|
-
preflightRollbackExport(io2,
|
|
6827
|
-
for (const path of Object.keys(
|
|
6828
|
-
if (!
|
|
7199
|
+
function rollbackExport(io2, receipt3) {
|
|
7200
|
+
preflightRollbackExport(io2, receipt3);
|
|
7201
|
+
for (const path of Object.keys(receipt3.targets))
|
|
7202
|
+
if (!receipt3.sources[path])
|
|
6829
7203
|
io2.remove(path);
|
|
6830
|
-
for (const [path, source] of Object.entries(
|
|
7204
|
+
for (const [path, source] of Object.entries(receipt3.sources))
|
|
6831
7205
|
io2.write(path, io2.read(source.backup));
|
|
6832
7206
|
}
|
|
6833
7207
|
|
|
6834
7208
|
// packages/workbench-server/dist/infrastructure/migrations/steps/0002-agent-profiles/released-scope-targets.js
|
|
6835
|
-
function isolateScopeTargets(root, input, io2,
|
|
7209
|
+
function isolateScopeTargets(root, input, io2, targets2) {
|
|
6836
7210
|
try {
|
|
6837
|
-
for (const path of Object.keys(
|
|
7211
|
+
for (const path of Object.keys(targets2))
|
|
6838
7212
|
if (!input.snapshots.has(path) && io2.read(path) !== void 0)
|
|
6839
7213
|
throw new Error(`Existing conversion target requires manual reconciliation: ${path}`);
|
|
6840
|
-
return
|
|
7214
|
+
return targets2;
|
|
6841
7215
|
} catch (cause) {
|
|
6842
7216
|
const error = legacyScopeFailure(cause, root, io2);
|
|
6843
7217
|
if (!(error instanceof LegacyScopeError))
|
|
@@ -6847,7 +7221,7 @@ function isolateScopeTargets(root, input, io2, targets) {
|
|
|
6847
7221
|
}
|
|
6848
7222
|
}
|
|
6849
7223
|
function releasedScopeTargets(root, scope, before, context, result) {
|
|
6850
|
-
const
|
|
7224
|
+
const targets2 = {};
|
|
6851
7225
|
if (before.subagents) {
|
|
6852
7226
|
const split = splitCatalogV037(before.subagents, scope, context);
|
|
6853
7227
|
if (Object.keys(split.launches).length)
|
|
@@ -6855,15 +7229,15 @@ function releasedScopeTargets(root, scope, before, context, result) {
|
|
|
6855
7229
|
subagents: split.launches
|
|
6856
7230
|
});
|
|
6857
7231
|
for (const [name, profile] of Object.entries(split.profiles))
|
|
6858
|
-
|
|
7232
|
+
targets2[join17(root, scope === "project" ? "agent-profiles" : "data/agent-profiles", name + ".json")] = exportedTarget("profile", profile);
|
|
6859
7233
|
}
|
|
6860
7234
|
if (Object.keys(result.agent.overrides).length)
|
|
6861
|
-
|
|
7235
|
+
targets2[join17(root, "config/agent.json")] = exportedTarget("preferences", result.agent);
|
|
6862
7236
|
if (Object.keys(result.creation.overrides).length)
|
|
6863
|
-
|
|
7237
|
+
targets2[join17(root, "config/conversation-defaults.json")] = exportedTarget("creation", result.creation);
|
|
6864
7238
|
if (result.integrations)
|
|
6865
|
-
|
|
6866
|
-
return
|
|
7239
|
+
targets2[join17(root, "config/integrations.json")] = exportedTarget("integrations", result.integrations);
|
|
7240
|
+
return targets2;
|
|
6867
7241
|
}
|
|
6868
7242
|
|
|
6869
7243
|
// packages/workbench-server/dist/infrastructure/migrations/steps/0002-agent-profiles/released-archive.js
|
|
@@ -6946,24 +7320,24 @@ async function verifyConversationExports(io2, rows, receipts, allowRetired = fal
|
|
|
6946
7320
|
assert25.equal(expected.size, rows.length, "Duplicate released conversation row");
|
|
6947
7321
|
const seen = /* @__PURE__ */ new Set();
|
|
6948
7322
|
await progress?.(0);
|
|
6949
|
-
for (const
|
|
6950
|
-
if (
|
|
7323
|
+
for (const receipt3 of receipts) {
|
|
7324
|
+
if (receipt3.rowDigest === void 0)
|
|
6951
7325
|
continue;
|
|
6952
|
-
const id =
|
|
6953
|
-
assert25(
|
|
7326
|
+
const id = receipt3.identity.replace(/^conversation:/, "");
|
|
7327
|
+
assert25(receipt3.identity === `conversation:${id}` && expected.has(id), "Export has no released conversation row");
|
|
6954
7328
|
assert25(!seen.has(id), "Duplicate conversation export");
|
|
6955
7329
|
seen.add(id);
|
|
6956
7330
|
const row2 = expected.get(id);
|
|
6957
|
-
verifyExport(io2,
|
|
6958
|
-
const
|
|
6959
|
-
assert25.equal(
|
|
6960
|
-
const document = JSON.parse(
|
|
6961
|
-
if (!
|
|
7331
|
+
verifyExport(io2, receipt3, releasedRowDigest(row2), allowRetired);
|
|
7332
|
+
const targets2 = Object.values(receipt3.targets).filter((target3) => target3.kind === "lead" || target3.kind === "child");
|
|
7333
|
+
assert25.equal(targets2.length, 1, "Conversation export must own exactly one agent document");
|
|
7334
|
+
const document = JSON.parse(targets2[0].bytes);
|
|
7335
|
+
if (!receipt3.report.includes("Conversation settings set aside; see quarantine"))
|
|
6962
7336
|
assert25.deepEqual(document.context ?? {}, {
|
|
6963
7337
|
...row2.instructions !== null ? { instructions: row2.instructions } : {},
|
|
6964
7338
|
...row2.system_prompt !== null ? { systemPrompt: row2.system_prompt } : {}
|
|
6965
7339
|
}, "Conversation prompt context differs from released SQL");
|
|
6966
|
-
assert25.equal(
|
|
7340
|
+
assert25.equal(targets2[0].kind, row2.parent_conversation_id ? "child" : "lead", "Conversation export role changed");
|
|
6967
7341
|
await progress?.(seen.size);
|
|
6968
7342
|
}
|
|
6969
7343
|
assert25.equal(seen.size, expected.size, "Unverified conversation rows remain; SQL destruction is forbidden");
|
|
@@ -7091,8 +7465,8 @@ async function executeReleasedMigration(db, files, progress) {
|
|
|
7091
7465
|
}
|
|
7092
7466
|
async function retireReleasedSources(files) {
|
|
7093
7467
|
await files.verifyFiles();
|
|
7094
|
-
for (const
|
|
7095
|
-
await files.retire(
|
|
7468
|
+
for (const receipt3 of files.receipts)
|
|
7469
|
+
await files.retire(receipt3);
|
|
7096
7470
|
}
|
|
7097
7471
|
|
|
7098
7472
|
// packages/workbench-server/dist/infrastructure/migrations/steps/0002-agent-profiles/released-schema-verification.js
|
|
@@ -7154,20 +7528,20 @@ var databaseBackupReceiptSchema = external_exports.object({
|
|
|
7154
7528
|
planDigest: external_exports.string().regex(/^[a-f0-9]{64}$/),
|
|
7155
7529
|
digest: external_exports.string().regex(/^[a-f0-9]{64}$/).optional()
|
|
7156
7530
|
}).strict().refine((value) => value.phase !== "ready" || value.digest !== void 0, "Ready backup requires a digest");
|
|
7157
|
-
function
|
|
7531
|
+
function receipt2(io2, path) {
|
|
7158
7532
|
const bytes = io2.read(path);
|
|
7159
7533
|
if (bytes === void 0)
|
|
7160
7534
|
return void 0;
|
|
7161
7535
|
return databaseBackupReceiptSchema.parse(JSON.parse(typeof bytes === "string" ? bytes : Buffer.from(bytes).toString("utf8")));
|
|
7162
7536
|
}
|
|
7163
7537
|
function verifyDatabaseBackup(io2, receiptPath, target3, planDigest) {
|
|
7164
|
-
const saved =
|
|
7538
|
+
const saved = receipt2(io2, receiptPath);
|
|
7165
7539
|
assert27(saved?.phase === "ready" && saved.target === target3 && saved.planDigest === planDigest, "Database backup is not bound to this conversion plan");
|
|
7166
7540
|
const bytes = io2.read(target3);
|
|
7167
7541
|
assert27(bytes !== void 0 && sha256(bytes) === saved.digest, "Original database backup changed");
|
|
7168
7542
|
}
|
|
7169
7543
|
async function preserveDatabaseBackup(io2, input) {
|
|
7170
|
-
let saved =
|
|
7544
|
+
let saved = receipt2(io2, input.receiptPath);
|
|
7171
7545
|
if (!saved) {
|
|
7172
7546
|
assert27(io2.read(input.target) === void 0, "Unowned database backup collision");
|
|
7173
7547
|
saved = {
|
|
@@ -7494,11 +7868,11 @@ async function restoreReleasedDatabase(ctx, plan, archiveDirectory) {
|
|
|
7494
7868
|
const path = join20(directory, "original.sqlite"), receiptPath = join20(directory, "receipt.json");
|
|
7495
7869
|
if (!existsSync17(receiptPath))
|
|
7496
7870
|
return;
|
|
7497
|
-
const
|
|
7498
|
-
assert28.equal(
|
|
7499
|
-
if (
|
|
7871
|
+
const receipt3 = databaseBackupReceiptSchema.parse(json(receiptPath));
|
|
7872
|
+
assert28.equal(receipt3.planDigest, sha256(jsonBytes(plan)), "Rollback plan does not own database backup");
|
|
7873
|
+
if (receipt3.phase === "planned")
|
|
7500
7874
|
return;
|
|
7501
|
-
assert28.equal(
|
|
7875
|
+
assert28.equal(receipt3.phase, "ready");
|
|
7502
7876
|
const checker = new ReleasedSqliteBackend(ctx, plan, async () => {
|
|
7503
7877
|
}, archiveDirectory);
|
|
7504
7878
|
try {
|
|
@@ -7511,7 +7885,7 @@ async function restoreReleasedDatabase(ctx, plan, archiveDirectory) {
|
|
|
7511
7885
|
checker.close();
|
|
7512
7886
|
}
|
|
7513
7887
|
const bytes = readFileSync8(path);
|
|
7514
|
-
assert28.equal(sha256(bytes),
|
|
7888
|
+
assert28.equal(sha256(bytes), receipt3.digest);
|
|
7515
7889
|
for (const suffix of ["-wal", "-shm"])
|
|
7516
7890
|
rmSync9(ctx.paths.sqlitePath + suffix, { force: true });
|
|
7517
7891
|
writeProtected(ctx.paths.sqlitePath, bytes);
|
|
@@ -7573,26 +7947,26 @@ async function planExports(ctx) {
|
|
|
7573
7947
|
const user = userInput.before;
|
|
7574
7948
|
const receipts = [], rows = {}, trust = [];
|
|
7575
7949
|
const claimed = /* @__PURE__ */ new Set();
|
|
7576
|
-
function add(identity, root,
|
|
7577
|
-
for (const path2 of Object.keys(
|
|
7950
|
+
function add(identity, root, targets2, sources, retire, report, rowDigest) {
|
|
7951
|
+
for (const path2 of Object.keys(targets2)) {
|
|
7578
7952
|
assert29(!claimed.has(path2), `Duplicate conversion target: ${path2}`);
|
|
7579
7953
|
claimed.add(path2);
|
|
7580
7954
|
}
|
|
7581
|
-
ctx.ownPaths([...sources, ...Object.keys(
|
|
7955
|
+
ctx.ownPaths([...sources, ...Object.keys(targets2)], root);
|
|
7582
7956
|
const path = join21(archiveRoot(ctx), sha256(identity), "receipt.json");
|
|
7583
7957
|
for (const source of sources)
|
|
7584
7958
|
assert29.equal(sha256(files.read(source)), snapshots.get(source), "Source changed while planning conversion");
|
|
7585
|
-
const
|
|
7959
|
+
const receipt3 = prepareExport(files, {
|
|
7586
7960
|
identity,
|
|
7587
7961
|
backupDirectory: join21(archiveRoot(ctx), sha256(identity)),
|
|
7588
7962
|
sources,
|
|
7589
|
-
targets,
|
|
7963
|
+
targets: targets2,
|
|
7590
7964
|
rowDigest,
|
|
7591
7965
|
retire,
|
|
7592
7966
|
report
|
|
7593
7967
|
});
|
|
7594
|
-
receipts.push({ path, receipt:
|
|
7595
|
-
return
|
|
7968
|
+
receipts.push({ path, receipt: receipt3 });
|
|
7969
|
+
return receipt3;
|
|
7596
7970
|
}
|
|
7597
7971
|
const convertScopes = phaseProgress(ctx, "scope-settings", "Converting user settings", 1);
|
|
7598
7972
|
await convertScopes();
|
|
@@ -7614,7 +7988,7 @@ async function planExports(ctx) {
|
|
|
7614
7988
|
for (const [path, digest5] of input.snapshots)
|
|
7615
7989
|
snapshots.set(path, digest5);
|
|
7616
7990
|
const result = convertPreferencesV037({ ...before, scope: "user" }, context);
|
|
7617
|
-
const
|
|
7991
|
+
const targets2 = input.issues.length ? {} : isolateScopeTargets(root, input, files, releasedScopeTargets(root, "user", before, context, result));
|
|
7618
7992
|
for (const issue of input.issues)
|
|
7619
7993
|
ctx.quarantine({ kind: "configuration", id: issue.path, reason: issue.reason }, { files: [issue.path], retainSource: true });
|
|
7620
7994
|
for (const message of scopeIssueReport(input.issues))
|
|
@@ -7635,12 +8009,12 @@ async function planExports(ctx) {
|
|
|
7635
8009
|
reason: "Invalid policy JSON"
|
|
7636
8010
|
}, { files: [file.path], retainSource: true });
|
|
7637
8011
|
if (JSON.stringify(before2) !== JSON.stringify(after)) {
|
|
7638
|
-
|
|
8012
|
+
targets2[file.path] = exportedTarget("metadata", after);
|
|
7639
8013
|
sources.push(file.path);
|
|
7640
8014
|
report.push(`Converted planning-tool metadata: ${file.path}`);
|
|
7641
8015
|
}
|
|
7642
8016
|
}
|
|
7643
|
-
add(`scope:${root}`, root,
|
|
8017
|
+
add(`scope:${root}`, root, targets2, sources, sources.filter((path) => !input.issues.length && !Object.hasOwn(targets2, path)), report);
|
|
7644
8018
|
await convertScopes(++convertedScopes);
|
|
7645
8019
|
}
|
|
7646
8020
|
const convertConversations = phaseProgress(ctx, "conversation-settings", "Converting conversation settings", original.rows.length);
|
|
@@ -7806,10 +8180,10 @@ function completion(ctx, plan) {
|
|
|
7806
8180
|
await progress(++done);
|
|
7807
8181
|
}
|
|
7808
8182
|
},
|
|
7809
|
-
async retire(
|
|
8183
|
+
async retire(receipt3) {
|
|
7810
8184
|
if (retired === 0)
|
|
7811
8185
|
await retireProgress();
|
|
7812
|
-
retireExportSources(io(ctx),
|
|
8186
|
+
retireExportSources(io(ctx), receipt3);
|
|
7813
8187
|
await retireProgress(++retired);
|
|
7814
8188
|
},
|
|
7815
8189
|
committed() {
|
|
@@ -8304,12 +8678,517 @@ var step_default4 = defineStep({
|
|
|
8304
8678
|
}
|
|
8305
8679
|
});
|
|
8306
8680
|
|
|
8681
|
+
// packages/workbench-server/dist/infrastructure/migrations/steps/0005-extension-settings/step.js
|
|
8682
|
+
import { existsSync as existsSync22, lstatSync as lstatSync13, readdirSync as readdirSync11, readFileSync as readFileSync12 } from "node:fs";
|
|
8683
|
+
import { join as join24 } from "node:path";
|
|
8684
|
+
|
|
8685
|
+
// packages/workbench-server/dist/infrastructure/migrations/steps/0005-extension-settings/accounts.js
|
|
8686
|
+
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
8687
|
+
import { existsSync as existsSync21, readFileSync as readFileSync11 } from "node:fs";
|
|
8688
|
+
|
|
8689
|
+
// packages/workbench-server/dist/infrastructure/migrations/steps/0005-extension-settings/convert.js
|
|
8690
|
+
var KROKI_DEFAULT = "https://kroki.io/";
|
|
8691
|
+
var isRecord2 = (value) => !!value && typeof value === "object" && !Array.isArray(value);
|
|
8692
|
+
var omit = (value, key2) => Object.fromEntries(Object.entries(value).filter(([name]) => name !== key2));
|
|
8693
|
+
var string = (value) => typeof value === "string" && value.trim() ? value : void 0;
|
|
8694
|
+
var boolean = (value) => typeof value === "boolean" ? value : void 0;
|
|
8695
|
+
var REMOVED_TOOLS = /* @__PURE__ */ new Set([
|
|
8696
|
+
"jira",
|
|
8697
|
+
"confluence",
|
|
8698
|
+
"generate_image",
|
|
8699
|
+
"kroki_export",
|
|
8700
|
+
"explain_image"
|
|
8701
|
+
]);
|
|
8702
|
+
var IMAGEGEN_DEFAULTS = {
|
|
8703
|
+
backend: "openai-codex",
|
|
8704
|
+
model: "gpt-image-2.5-flare",
|
|
8705
|
+
quality: "auto",
|
|
8706
|
+
size: "auto",
|
|
8707
|
+
background: "auto"
|
|
8708
|
+
};
|
|
8709
|
+
function imageGenerationEntry(tool, complete) {
|
|
8710
|
+
if (!isRecord2(tool))
|
|
8711
|
+
return void 0;
|
|
8712
|
+
const settings = isRecord2(tool.settings) ? tool.settings : {};
|
|
8713
|
+
const options = isRecord2(settings.options) ? settings.options : {};
|
|
8714
|
+
const values = {};
|
|
8715
|
+
const set = (key2, value) => {
|
|
8716
|
+
const text3 = string(value);
|
|
8717
|
+
if (text3 && !(complete && text3 === IMAGEGEN_DEFAULTS[key2]))
|
|
8718
|
+
values[key2] = text3;
|
|
8719
|
+
};
|
|
8720
|
+
set("backend", settings.provider);
|
|
8721
|
+
set("model", settings.model);
|
|
8722
|
+
set("quality", options.quality);
|
|
8723
|
+
set("size", options.size);
|
|
8724
|
+
set("background", options.background);
|
|
8725
|
+
const enabled = boolean(tool.enabled);
|
|
8726
|
+
if (enabled === void 0 && Object.keys(values).length === 0)
|
|
8727
|
+
return void 0;
|
|
8728
|
+
return {
|
|
8729
|
+
version: 1,
|
|
8730
|
+
...enabled !== void 0 ? { enabled } : {},
|
|
8731
|
+
...Object.keys(values).length ? { settings: values } : {}
|
|
8732
|
+
};
|
|
8733
|
+
}
|
|
8734
|
+
var THINKING_LEVELS = /* @__PURE__ */ new Set([
|
|
8735
|
+
"off",
|
|
8736
|
+
"minimal",
|
|
8737
|
+
"low",
|
|
8738
|
+
"medium",
|
|
8739
|
+
"high",
|
|
8740
|
+
"xhigh",
|
|
8741
|
+
"max"
|
|
8742
|
+
]);
|
|
8743
|
+
function imageExplanationEntry(tool, complete) {
|
|
8744
|
+
if (!isRecord2(tool))
|
|
8745
|
+
return void 0;
|
|
8746
|
+
const source = isRecord2(tool.settings) ? tool.settings : {};
|
|
8747
|
+
const values = {};
|
|
8748
|
+
if (isRecord2(source.model)) {
|
|
8749
|
+
const provider = string(source.model.provider);
|
|
8750
|
+
const modelId2 = string(source.model.modelId);
|
|
8751
|
+
if (provider && modelId2)
|
|
8752
|
+
values.model = { provider, modelId: modelId2 };
|
|
8753
|
+
}
|
|
8754
|
+
const level = string(source.thinkingLevel);
|
|
8755
|
+
if (level && THINKING_LEVELS.has(level) && !(complete && level === "off"))
|
|
8756
|
+
values.thinkingLevel = level;
|
|
8757
|
+
const enabled = boolean(tool.enabled);
|
|
8758
|
+
if (enabled === void 0 && Object.keys(values).length === 0)
|
|
8759
|
+
return void 0;
|
|
8760
|
+
return {
|
|
8761
|
+
version: 1,
|
|
8762
|
+
...enabled !== void 0 ? { enabled } : {},
|
|
8763
|
+
...Object.keys(values).length ? { settings: values } : {}
|
|
8764
|
+
};
|
|
8765
|
+
}
|
|
8766
|
+
function extractFromTools(tools, loss, complete = false) {
|
|
8767
|
+
if (!isRecord2(tools))
|
|
8768
|
+
return { tools: void 0, entries: {} };
|
|
8769
|
+
if (!hasMovedFields(tools))
|
|
8770
|
+
return { tools, entries: {} };
|
|
8771
|
+
const quickScript = isRecord2(tools.quick_script) ? tools.quick_script : void 0;
|
|
8772
|
+
const qs = isRecord2(quickScript?.settings) ? quickScript.settings : {};
|
|
8773
|
+
const sub = (value) => isRecord2(value) ? value : {};
|
|
8774
|
+
const entries = {};
|
|
8775
|
+
const product = (name) => ({
|
|
8776
|
+
enabled: boolean(sub(qs[name]).enabled) ?? boolean(sub(tools[name]).enabled),
|
|
8777
|
+
account: string(sub(qs[name]).profileId) ?? string(sub(tools[name]).profileId)
|
|
8778
|
+
});
|
|
8779
|
+
const jira = product("jira");
|
|
8780
|
+
const confluence = product("confluence");
|
|
8781
|
+
if (jira.account && confluence.account && jira.account !== confluence.account)
|
|
8782
|
+
loss("Jira and Confluence used different Atlassian accounts; the Jira account was kept");
|
|
8783
|
+
const account2 = jira.account ?? confluence.account;
|
|
8784
|
+
const settings = {};
|
|
8785
|
+
if (account2)
|
|
8786
|
+
settings.account = account2;
|
|
8787
|
+
if (jira.enabled !== void 0)
|
|
8788
|
+
settings.jira = jira.enabled;
|
|
8789
|
+
if (confluence.enabled !== void 0)
|
|
8790
|
+
settings.confluence = confluence.enabled;
|
|
8791
|
+
if (Object.keys(settings).length)
|
|
8792
|
+
entries.atlassian = {
|
|
8793
|
+
version: 1,
|
|
8794
|
+
...jira.enabled || confluence.enabled ? { enabled: true } : {},
|
|
8795
|
+
settings
|
|
8796
|
+
};
|
|
8797
|
+
const web = sub(qs.web);
|
|
8798
|
+
const searchAccount = string(web.profileId) ?? string(sub(tools.web_search).profileId);
|
|
8799
|
+
const webEnabled = boolean(web.enabled) ?? (searchAccount && boolean(sub(tools.web_search).enabled) !== false ? true : void 0);
|
|
8800
|
+
if (searchAccount || webEnabled !== void 0)
|
|
8801
|
+
entries["web-search"] = {
|
|
8802
|
+
version: 1,
|
|
8803
|
+
...webEnabled !== void 0 ? { enabled: webEnabled } : {},
|
|
8804
|
+
...searchAccount ? { settings: { searchAccount } } : {}
|
|
8805
|
+
};
|
|
8806
|
+
const server = string(sub(qs.diagram).url) ?? string(sub(sub(tools.kroki_export).settings).url);
|
|
8807
|
+
if (server && !(complete && server === KROKI_DEFAULT))
|
|
8808
|
+
entries.diagram = { version: 1, settings: { server } };
|
|
8809
|
+
const image = imageGenerationEntry(tools.generate_image, complete);
|
|
8810
|
+
if (image)
|
|
8811
|
+
entries.imagegen = image;
|
|
8812
|
+
const explanation2 = imageExplanationEntry(tools.explain_image, complete);
|
|
8813
|
+
if (explanation2)
|
|
8814
|
+
entries["image-explanation"] = explanation2;
|
|
8815
|
+
const cleaned = {};
|
|
8816
|
+
for (const [name, entry2] of Object.entries(tools)) {
|
|
8817
|
+
if (REMOVED_TOOLS.has(name))
|
|
8818
|
+
continue;
|
|
8819
|
+
const drop = name === "web_search" ? "profileId" : name === "quick_script" ? "settings" : void 0;
|
|
8820
|
+
if (drop && isRecord2(entry2)) {
|
|
8821
|
+
const rest = omit(entry2, drop);
|
|
8822
|
+
if (Object.keys(rest).length)
|
|
8823
|
+
cleaned[name] = rest;
|
|
8824
|
+
} else
|
|
8825
|
+
cleaned[name] = entry2;
|
|
8826
|
+
}
|
|
8827
|
+
return {
|
|
8828
|
+
tools: Object.keys(cleaned).length ? cleaned : void 0,
|
|
8829
|
+
entries
|
|
8830
|
+
};
|
|
8831
|
+
}
|
|
8832
|
+
function mergeEntries(base, over) {
|
|
8833
|
+
const merged = structuredClone(base);
|
|
8834
|
+
for (const [id, entry2] of Object.entries(over)) {
|
|
8835
|
+
const current = merged[id];
|
|
8836
|
+
merged[id] = {
|
|
8837
|
+
version: 1,
|
|
8838
|
+
...entry2.enabled !== void 0 ? { enabled: entry2.enabled } : current?.enabled !== void 0 ? { enabled: current.enabled } : {},
|
|
8839
|
+
...current?.settings || entry2.settings ? { settings: { ...current?.settings, ...entry2.settings } } : {}
|
|
8840
|
+
};
|
|
8841
|
+
}
|
|
8842
|
+
return merged;
|
|
8843
|
+
}
|
|
8844
|
+
function withTools(value, section, tools) {
|
|
8845
|
+
const holder = value[section];
|
|
8846
|
+
if (!isRecord2(holder))
|
|
8847
|
+
return value;
|
|
8848
|
+
return {
|
|
8849
|
+
...value,
|
|
8850
|
+
[section]: { ...omit(holder, "tools"), ...tools ? { tools } : {} }
|
|
8851
|
+
};
|
|
8852
|
+
}
|
|
8853
|
+
function convertOverrides(document, loss) {
|
|
8854
|
+
const overrides = isRecord2(document.overrides) ? document.overrides : void 0;
|
|
8855
|
+
if (!overrides || !isRecord2(overrides.tools))
|
|
8856
|
+
return { document, entries: {} };
|
|
8857
|
+
const { tools, entries } = extractFromTools(overrides.tools, loss);
|
|
8858
|
+
return { document: withTools(document, "overrides", tools), entries };
|
|
8859
|
+
}
|
|
8860
|
+
function convertUserAgent(document, loss) {
|
|
8861
|
+
return convertOverrides(document, loss);
|
|
8862
|
+
}
|
|
8863
|
+
function profileSections(holder, loss) {
|
|
8864
|
+
let next = holder;
|
|
8865
|
+
const sections = {};
|
|
8866
|
+
for (const section of ["recommendations", "requirements"]) {
|
|
8867
|
+
const part = next[section];
|
|
8868
|
+
if (!isRecord2(part) || !isRecord2(part.tools))
|
|
8869
|
+
continue;
|
|
8870
|
+
const { tools, entries } = extractFromTools(part.tools, loss);
|
|
8871
|
+
next = withTools(next, section, tools);
|
|
8872
|
+
if (Object.keys(entries).length)
|
|
8873
|
+
sections[section] = entries;
|
|
8874
|
+
}
|
|
8875
|
+
const required = sections.requirements;
|
|
8876
|
+
const recommended = sections.recommendations;
|
|
8877
|
+
if (required && recommended)
|
|
8878
|
+
for (const [id, entry2] of Object.entries(required)) {
|
|
8879
|
+
const other = recommended[id];
|
|
8880
|
+
if (!other)
|
|
8881
|
+
continue;
|
|
8882
|
+
if (entry2.enabled !== void 0 && other.enabled !== void 0) {
|
|
8883
|
+
delete other.enabled;
|
|
8884
|
+
loss("A profile recommended and required the same extension switch; the requirement was kept");
|
|
8885
|
+
}
|
|
8886
|
+
for (const key2 of Object.keys(entry2.settings ?? {}))
|
|
8887
|
+
if (other.settings && key2 in other.settings) {
|
|
8888
|
+
delete other.settings[key2];
|
|
8889
|
+
loss("A profile recommended and required the same extension setting; the requirement was kept");
|
|
8890
|
+
}
|
|
8891
|
+
if (other.enabled === void 0 && !Object.keys(other.settings ?? {}).length)
|
|
8892
|
+
delete recommended[id];
|
|
8893
|
+
}
|
|
8894
|
+
return Object.keys(sections).length ? { holder: next, extensions: sections } : { holder };
|
|
8895
|
+
}
|
|
8896
|
+
function convertProfileDefinition(definition, loss) {
|
|
8897
|
+
const { holder, extensions } = profileSections(definition, loss);
|
|
8898
|
+
return extensions && !isRecord2(holder.extensions) ? { ...holder, extensions } : holder;
|
|
8899
|
+
}
|
|
8900
|
+
function convertConversationAgent(document, loss) {
|
|
8901
|
+
let next = document;
|
|
8902
|
+
let entries = {};
|
|
8903
|
+
if (isRecord2(next.frozenDefaults) && isRecord2(next.frozenDefaults.tools)) {
|
|
8904
|
+
const frozen = extractFromTools(next.frozenDefaults.tools, loss, true);
|
|
8905
|
+
next = withTools(next, "frozenDefaults", frozen.tools);
|
|
8906
|
+
entries = frozen.entries;
|
|
8907
|
+
}
|
|
8908
|
+
const overrides = convertOverrides(next, loss);
|
|
8909
|
+
next = overrides.document;
|
|
8910
|
+
entries = mergeEntries(entries, overrides.entries);
|
|
8911
|
+
if (isRecord2(next.appliedProfile)) {
|
|
8912
|
+
const { holder, extensions } = profileSections(next.appliedProfile, loss);
|
|
8913
|
+
next = {
|
|
8914
|
+
...next,
|
|
8915
|
+
appliedProfile: extensions && !isRecord2(holder.extensions) ? { ...holder, extensions } : holder
|
|
8916
|
+
};
|
|
8917
|
+
}
|
|
8918
|
+
return { document: next, entries };
|
|
8919
|
+
}
|
|
8920
|
+
function hasMovedFields(tools) {
|
|
8921
|
+
if (!isRecord2(tools))
|
|
8922
|
+
return false;
|
|
8923
|
+
return [...REMOVED_TOOLS].some((name) => name in tools) || isRecord2(tools.web_search) && "profileId" in tools.web_search || isRecord2(tools.quick_script) && "settings" in tools.quick_script;
|
|
8924
|
+
}
|
|
8925
|
+
|
|
8926
|
+
// packages/workbench-server/dist/infrastructure/migrations/steps/0005-extension-settings/accounts.js
|
|
8927
|
+
var apiKeySecret = (credential) => `provider:${credential}:apiKey`;
|
|
8928
|
+
function reshapeAccounts(source, loss) {
|
|
8929
|
+
if (!isRecord2(source.profiles))
|
|
8930
|
+
return void 0;
|
|
8931
|
+
const accounts = {};
|
|
8932
|
+
const renames = [];
|
|
8933
|
+
for (const [kind, profiles] of Object.entries(source.profiles)) {
|
|
8934
|
+
accounts[kind] = [];
|
|
8935
|
+
if (!Array.isArray(profiles))
|
|
8936
|
+
continue;
|
|
8937
|
+
for (const profile of profiles) {
|
|
8938
|
+
if (!isRecord2(profile) || typeof profile.id !== "string" || typeof profile.name !== "string") {
|
|
8939
|
+
loss("An account entry was not valid and was dropped");
|
|
8940
|
+
continue;
|
|
8941
|
+
}
|
|
8942
|
+
const { id, name, credential, ...rest } = profile;
|
|
8943
|
+
const fields = Object.fromEntries(Object.entries(rest).filter(([, value]) => value !== void 0 && value !== null && value !== ""));
|
|
8944
|
+
accounts[kind].push({ id, name, fields });
|
|
8945
|
+
renames.push({
|
|
8946
|
+
from: apiKeySecret(typeof credential === "string" ? credential : `${kind}:${id}`),
|
|
8947
|
+
to: apiKeySecret(`account:${kind}:${id}`)
|
|
8948
|
+
});
|
|
8949
|
+
}
|
|
8950
|
+
}
|
|
8951
|
+
return { document: { version: 2, accounts }, renames };
|
|
8952
|
+
}
|
|
8953
|
+
function renameSecrets(credentialsPath, keyPath, renames) {
|
|
8954
|
+
if (!renames.length || !existsSync21(credentialsPath) || !existsSync21(keyPath))
|
|
8955
|
+
return void 0;
|
|
8956
|
+
const key2 = Buffer.from(readFileSync11(keyPath, "utf8").trim(), "base64");
|
|
8957
|
+
if (key2.byteLength !== 32)
|
|
8958
|
+
throw new Error("Invalid Nerve master key.");
|
|
8959
|
+
const envelope = JSON.parse(readFileSync11(credentialsPath, "utf8"));
|
|
8960
|
+
const decipher = createDecipheriv("aes-256-gcm", key2, Buffer.from(envelope.iv, "base64"));
|
|
8961
|
+
decipher.setAuthTag(Buffer.from(envelope.tag, "base64"));
|
|
8962
|
+
const values = JSON.parse(Buffer.concat([
|
|
8963
|
+
decipher.update(Buffer.from(envelope.data, "base64")),
|
|
8964
|
+
decipher.final()
|
|
8965
|
+
]).toString("utf8"));
|
|
8966
|
+
let renamed = 0;
|
|
8967
|
+
for (const { from, to } of renames) {
|
|
8968
|
+
if (typeof values[from] !== "string")
|
|
8969
|
+
continue;
|
|
8970
|
+
if (!(to in values))
|
|
8971
|
+
values[to] = values[from];
|
|
8972
|
+
delete values[from];
|
|
8973
|
+
renamed++;
|
|
8974
|
+
}
|
|
8975
|
+
if (!renamed)
|
|
8976
|
+
return void 0;
|
|
8977
|
+
const iv = randomBytes(12);
|
|
8978
|
+
const cipher = createCipheriv("aes-256-gcm", key2, iv);
|
|
8979
|
+
const ordered = Object.fromEntries(Object.entries(values).sort(([a], [b]) => a.localeCompare(b)));
|
|
8980
|
+
const data = Buffer.concat([
|
|
8981
|
+
cipher.update(JSON.stringify(ordered), "utf8"),
|
|
8982
|
+
cipher.final()
|
|
8983
|
+
]);
|
|
8984
|
+
const sealed = {
|
|
8985
|
+
version: 1,
|
|
8986
|
+
algorithm: "A256GCM",
|
|
8987
|
+
iv: iv.toString("base64"),
|
|
8988
|
+
tag: cipher.getAuthTag().toString("base64"),
|
|
8989
|
+
data: data.toString("base64")
|
|
8990
|
+
};
|
|
8991
|
+
return { content: `${JSON.stringify(sealed, null, 2)}
|
|
8992
|
+
`, renamed };
|
|
8993
|
+
}
|
|
8994
|
+
|
|
8995
|
+
// packages/workbench-server/dist/infrastructure/migrations/steps/0005-extension-settings/step.js
|
|
8996
|
+
var text2 = (path) => {
|
|
8997
|
+
const stat = lstatSync13(path);
|
|
8998
|
+
if (stat.isSymbolicLink() || !stat.isFile())
|
|
8999
|
+
throw new Error(`Expected a regular file: ${path}`);
|
|
9000
|
+
return readFileSync12(path, "utf8");
|
|
9001
|
+
};
|
|
9002
|
+
var readObject = (path) => {
|
|
9003
|
+
const value = JSON.parse(text2(path));
|
|
9004
|
+
if (!isRecord2(value))
|
|
9005
|
+
throw new Error("Expected a JSON object");
|
|
9006
|
+
return value;
|
|
9007
|
+
};
|
|
9008
|
+
var serialize = (value) => `${JSON.stringify(value, null, 2)}
|
|
9009
|
+
`;
|
|
9010
|
+
function targets(context) {
|
|
9011
|
+
const { paths } = context;
|
|
9012
|
+
const found = [];
|
|
9013
|
+
const agent = join24(paths.configPath, "agent.json");
|
|
9014
|
+
if (existsSync22(agent))
|
|
9015
|
+
found.push({
|
|
9016
|
+
path: agent,
|
|
9017
|
+
kind: "user-agent",
|
|
9018
|
+
extensions: join24(paths.configPath, "extensions.json")
|
|
9019
|
+
});
|
|
9020
|
+
if (existsSync22(paths.permissionsConfigPath))
|
|
9021
|
+
found.push({ path: paths.permissionsConfigPath, kind: "permissions" });
|
|
9022
|
+
const ruleSets = join24(paths.configPath, "rule-sets");
|
|
9023
|
+
if (existsSync22(ruleSets)) {
|
|
9024
|
+
for (const file of readdirSync11(ruleSets).sort())
|
|
9025
|
+
if (file.endsWith(".json"))
|
|
9026
|
+
found.push({ path: join24(ruleSets, file), kind: "rule-set" });
|
|
9027
|
+
}
|
|
9028
|
+
if (existsSync22(paths.agentProfilesConfigPath)) {
|
|
9029
|
+
for (const file of readdirSync11(paths.agentProfilesConfigPath).sort())
|
|
9030
|
+
if (file.endsWith(".json"))
|
|
9031
|
+
found.push({
|
|
9032
|
+
path: join24(paths.agentProfilesConfigPath, file),
|
|
9033
|
+
kind: "profile"
|
|
9034
|
+
});
|
|
9035
|
+
}
|
|
9036
|
+
if (existsSync22(paths.conversationsPath))
|
|
9037
|
+
for (const id of readdirSync11(paths.conversationsPath).sort()) {
|
|
9038
|
+
const directory = join24(paths.conversationsPath, id, "config");
|
|
9039
|
+
const path = join24(directory, "agent.json");
|
|
9040
|
+
if (existsSync22(path))
|
|
9041
|
+
found.push({
|
|
9042
|
+
path,
|
|
9043
|
+
kind: "conversation-agent",
|
|
9044
|
+
extensions: join24(directory, "extensions.json")
|
|
9045
|
+
});
|
|
9046
|
+
const permissions = join24(directory, "permissions.json");
|
|
9047
|
+
if (existsSync22(permissions))
|
|
9048
|
+
found.push({ path: permissions, kind: "permissions" });
|
|
9049
|
+
}
|
|
9050
|
+
return found;
|
|
9051
|
+
}
|
|
9052
|
+
function owned(context) {
|
|
9053
|
+
const { paths } = context;
|
|
9054
|
+
return [
|
|
9055
|
+
join24(paths.configPath, "integrations.json"),
|
|
9056
|
+
paths.accountsConfigPath,
|
|
9057
|
+
paths.credentialsPath,
|
|
9058
|
+
...targets(context).flatMap((target3) => [
|
|
9059
|
+
target3.path,
|
|
9060
|
+
...target3.extensions ? [target3.extensions] : []
|
|
9061
|
+
])
|
|
9062
|
+
];
|
|
9063
|
+
}
|
|
9064
|
+
function extensionsDocument(entries, existing) {
|
|
9065
|
+
const stored = isRecord2(existing?.extensions) ? existing.extensions : {};
|
|
9066
|
+
return {
|
|
9067
|
+
schemaVersion: 1,
|
|
9068
|
+
revision: typeof existing?.revision === "number" ? existing.revision : 1,
|
|
9069
|
+
extensions: mergeEntries(entries, stored)
|
|
9070
|
+
};
|
|
9071
|
+
}
|
|
9072
|
+
function convert2(context, target3) {
|
|
9073
|
+
const losses = /* @__PURE__ */ new Map();
|
|
9074
|
+
const loss = (reason2) => losses.set(reason2, (losses.get(reason2) ?? 0) + 1);
|
|
9075
|
+
const source = readObject(target3.path);
|
|
9076
|
+
let document;
|
|
9077
|
+
let entries = {};
|
|
9078
|
+
if (target3.kind === "permissions" || target3.kind === "rule-set") {
|
|
9079
|
+
const converted = (target3.kind === "permissions" ? convertPermissionOverlayDocument : convertRuleSetDocument)(source, loss);
|
|
9080
|
+
if (converted.changed)
|
|
9081
|
+
context.fs.write(target3.path, serialize(converted.document));
|
|
9082
|
+
for (const [reason2, count] of losses)
|
|
9083
|
+
context.loss(reason2, count);
|
|
9084
|
+
return;
|
|
9085
|
+
}
|
|
9086
|
+
if (target3.kind === "profile")
|
|
9087
|
+
document = convertProfileDefinition(source, loss);
|
|
9088
|
+
else {
|
|
9089
|
+
const converted = target3.kind === "user-agent" ? convertUserAgent(source, loss) : convertConversationAgent(source, loss);
|
|
9090
|
+
document = converted.document;
|
|
9091
|
+
entries = converted.entries;
|
|
9092
|
+
}
|
|
9093
|
+
if (JSON.stringify(document) !== JSON.stringify(source))
|
|
9094
|
+
context.fs.write(target3.path, serialize(document));
|
|
9095
|
+
if (target3.extensions && Object.keys(entries).length) {
|
|
9096
|
+
const existing = existsSync22(target3.extensions) ? readObject(target3.extensions) : void 0;
|
|
9097
|
+
context.fs.write(target3.extensions, serialize(extensionsDocument(entries, existing)));
|
|
9098
|
+
}
|
|
9099
|
+
for (const [reason2, count] of losses)
|
|
9100
|
+
context.loss(reason2, count);
|
|
9101
|
+
}
|
|
9102
|
+
var step_default5 = defineStep({
|
|
9103
|
+
id: "0005-extension-settings",
|
|
9104
|
+
description: "Move account and tool options to extensions",
|
|
9105
|
+
ownedPaths: (context) => owned(context),
|
|
9106
|
+
async run(context) {
|
|
9107
|
+
const { paths } = context;
|
|
9108
|
+
const legacy = join24(paths.configPath, "integrations.json");
|
|
9109
|
+
if (existsSync22(legacy)) {
|
|
9110
|
+
await context.unit({ kind: "configuration", id: legacy }, () => {
|
|
9111
|
+
if (existsSync22(paths.accountsConfigPath))
|
|
9112
|
+
context.loss("config/integrations.json was left in place: config/accounts.json already exists");
|
|
9113
|
+
else
|
|
9114
|
+
context.fs.rename(legacy, paths.accountsConfigPath);
|
|
9115
|
+
});
|
|
9116
|
+
}
|
|
9117
|
+
if (existsSync22(paths.accountsConfigPath)) {
|
|
9118
|
+
if (context.discarded.has(paths.accountsConfigPath))
|
|
9119
|
+
context.quarantine({
|
|
9120
|
+
kind: "configuration",
|
|
9121
|
+
id: paths.accountsConfigPath,
|
|
9122
|
+
reason: "Set aside at user request after an upgrade failure"
|
|
9123
|
+
}, { files: [paths.accountsConfigPath], retainSource: true });
|
|
9124
|
+
else
|
|
9125
|
+
await context.unit({ kind: "configuration", id: paths.accountsConfigPath }, () => {
|
|
9126
|
+
const converted = reshapeAccounts(readObject(paths.accountsConfigPath), (reason2) => context.loss(reason2));
|
|
9127
|
+
if (!converted)
|
|
9128
|
+
return;
|
|
9129
|
+
context.fs.write(paths.accountsConfigPath, serialize(converted.document));
|
|
9130
|
+
const secrets = renameSecrets(paths.credentialsPath, paths.masterKeyPath, converted.renames);
|
|
9131
|
+
if (secrets)
|
|
9132
|
+
context.fs.write(paths.credentialsPath, secrets.content);
|
|
9133
|
+
});
|
|
9134
|
+
}
|
|
9135
|
+
const all = targets(context);
|
|
9136
|
+
context.progress("run", 0, all.length, "Moving extension settings");
|
|
9137
|
+
let done = 0;
|
|
9138
|
+
for (const target3 of all) {
|
|
9139
|
+
if (context.discarded.has(target3.path))
|
|
9140
|
+
context.quarantine({
|
|
9141
|
+
kind: "configuration",
|
|
9142
|
+
id: target3.path,
|
|
9143
|
+
reason: "Set aside at user request after an upgrade failure"
|
|
9144
|
+
}, { files: [target3.path], retainSource: true });
|
|
9145
|
+
else
|
|
9146
|
+
await context.unit({ kind: "configuration", id: target3.path }, () => convert2(context, target3));
|
|
9147
|
+
context.progress("run", ++done, all.length);
|
|
9148
|
+
}
|
|
9149
|
+
},
|
|
9150
|
+
async verify(context) {
|
|
9151
|
+
const { paths } = context;
|
|
9152
|
+
if (existsSync22(join24(paths.configPath, "integrations.json")) && !existsSync22(paths.accountsConfigPath))
|
|
9153
|
+
throw new Error("Integration accounts were not moved to accounts.json");
|
|
9154
|
+
if (existsSync22(paths.accountsConfigPath) && !context.discarded.has(paths.accountsConfigPath) && isRecord2(readObject(paths.accountsConfigPath).profiles))
|
|
9155
|
+
throw new Error("Accounts were not reshaped by kind");
|
|
9156
|
+
for (const target3 of targets(context)) {
|
|
9157
|
+
if (context.discarded.has(target3.path))
|
|
9158
|
+
continue;
|
|
9159
|
+
const document = readObject(target3.path);
|
|
9160
|
+
if (target3.kind === "permissions" || target3.kind === "rule-set") {
|
|
9161
|
+
if (hasEnabledRemovedToolRule(document))
|
|
9162
|
+
throw new Error(`Removed tools remain in ${target3.path}`);
|
|
9163
|
+
continue;
|
|
9164
|
+
}
|
|
9165
|
+
const sections = target3.kind === "profile" ? [document.recommendations, document.requirements] : [
|
|
9166
|
+
document.overrides,
|
|
9167
|
+
document.frozenDefaults,
|
|
9168
|
+
...isRecord2(document.appliedProfile) ? [
|
|
9169
|
+
document.appliedProfile.recommendations,
|
|
9170
|
+
document.appliedProfile.requirements
|
|
9171
|
+
] : []
|
|
9172
|
+
];
|
|
9173
|
+
for (const section of sections)
|
|
9174
|
+
if (isRecord2(section) && hasMovedFields(section.tools))
|
|
9175
|
+
throw new Error(`Moved settings remain in ${target3.path}`);
|
|
9176
|
+
if (target3.extensions && existsSync22(target3.extensions)) {
|
|
9177
|
+
const extensions = readObject(target3.extensions);
|
|
9178
|
+
if (extensions.schemaVersion !== 1 || typeof extensions.revision !== "number" || !isRecord2(extensions.extensions))
|
|
9179
|
+
throw new Error(`Invalid extension settings: ${target3.extensions}`);
|
|
9180
|
+
}
|
|
9181
|
+
}
|
|
9182
|
+
}
|
|
9183
|
+
});
|
|
9184
|
+
|
|
8307
9185
|
// packages/workbench-server/dist/infrastructure/migrations/steps/index.js
|
|
8308
9186
|
var implementations = [
|
|
8309
9187
|
step_default,
|
|
8310
9188
|
step_default2,
|
|
8311
9189
|
step_default3,
|
|
8312
|
-
step_default4
|
|
9190
|
+
step_default4,
|
|
9191
|
+
step_default5
|
|
8313
9192
|
];
|
|
8314
9193
|
if (implementations.length !== MIGRATION_METADATA.length)
|
|
8315
9194
|
throw new Error("Migration metadata and implementations must match.");
|
|
@@ -8323,8 +9202,8 @@ var MIGRATION_REGISTRY = Object.freeze(MIGRATION_METADATA.map((metadata, index)
|
|
|
8323
9202
|
// packages/workbench-server/dist/infrastructure/migrations/framework/filesystem.js
|
|
8324
9203
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
8325
9204
|
import assert30 from "node:assert/strict";
|
|
8326
|
-
import { closeSync as closeSync4, openSync as openSync4, existsSync as
|
|
8327
|
-
import { dirname as dirname12, join as
|
|
9205
|
+
import { closeSync as closeSync4, openSync as openSync4, existsSync as existsSync23, lstatSync as lstatSync14, mkdirSync as mkdirSync8, rmSync as rmSync10, writeFileSync as writeFileSync6 } from "node:fs";
|
|
9206
|
+
import { dirname as dirname12, join as join25 } from "node:path";
|
|
8328
9207
|
var MigrationFilesystem = class {
|
|
8329
9208
|
scratchDir;
|
|
8330
9209
|
readOnly = false;
|
|
@@ -8340,10 +9219,10 @@ var MigrationFilesystem = class {
|
|
|
8340
9219
|
];
|
|
8341
9220
|
}
|
|
8342
9221
|
recoverUnit() {
|
|
8343
|
-
const pending =
|
|
8344
|
-
if (!
|
|
9222
|
+
const pending = join25(this.scratchDir, "pending-unit");
|
|
9223
|
+
if (!existsSync23(pending))
|
|
8345
9224
|
return;
|
|
8346
|
-
if (!
|
|
9225
|
+
if (!existsSync23(join25(pending, "committed")))
|
|
8347
9226
|
new RollbackJournal(pending).restore();
|
|
8348
9227
|
setUnitJournal(void 0);
|
|
8349
9228
|
rmSync10(pending, { recursive: true, force: true });
|
|
@@ -8354,7 +9233,7 @@ var MigrationFilesystem = class {
|
|
|
8354
9233
|
if (this.readOnly)
|
|
8355
9234
|
return { finish() {
|
|
8356
9235
|
} };
|
|
8357
|
-
const pending =
|
|
9236
|
+
const pending = join25(this.scratchDir, "pending-unit");
|
|
8358
9237
|
const journal = new RollbackJournal(pending);
|
|
8359
9238
|
this.#unit = journal;
|
|
8360
9239
|
setUnitJournal(journal);
|
|
@@ -8364,7 +9243,7 @@ var MigrationFilesystem = class {
|
|
|
8364
9243
|
if (!success)
|
|
8365
9244
|
journal.restore();
|
|
8366
9245
|
else {
|
|
8367
|
-
const marker =
|
|
9246
|
+
const marker = join25(pending, "committed");
|
|
8368
9247
|
writeFileSync6(marker, "", { mode: 384 });
|
|
8369
9248
|
syncFile(marker);
|
|
8370
9249
|
syncDirectory(pending);
|
|
@@ -8404,15 +9283,15 @@ var MigrationFilesystem = class {
|
|
|
8404
9283
|
}
|
|
8405
9284
|
}
|
|
8406
9285
|
rename(from, to) {
|
|
8407
|
-
assert30(
|
|
8408
|
-
assert30(!
|
|
9286
|
+
assert30(lstatSync14(from, { throwIfNoEntry: false }), `Missing rename source ${from}`);
|
|
9287
|
+
assert30(!lstatSync14(to, { throwIfNoEntry: false }), `Destination already exists: ${to}`);
|
|
8409
9288
|
for (const journal of this.journals())
|
|
8410
9289
|
journal.recordRename(from, to);
|
|
8411
9290
|
renameWithRetrySync(from, to);
|
|
8412
9291
|
}
|
|
8413
9292
|
move(from, to) {
|
|
8414
|
-
if (!
|
|
8415
|
-
assert30(
|
|
9293
|
+
if (!lstatSync14(from, { throwIfNoEntry: false })) {
|
|
9294
|
+
assert30(lstatSync14(to, { throwIfNoEntry: false }), `Missing move source ${from}`);
|
|
8416
9295
|
return;
|
|
8417
9296
|
}
|
|
8418
9297
|
for (const journal of this.journals())
|
|
@@ -8421,9 +9300,9 @@ var MigrationFilesystem = class {
|
|
|
8421
9300
|
}
|
|
8422
9301
|
remove(path) {
|
|
8423
9302
|
this.journals();
|
|
8424
|
-
const stat =
|
|
9303
|
+
const stat = lstatSync14(path, { throwIfNoEntry: false });
|
|
8425
9304
|
if (stat?.isDirectory()) {
|
|
8426
|
-
const retained =
|
|
9305
|
+
const retained = join25(this.scratchDir, "removed", String(Date.now()) + "-" + Math.random().toString(36).slice(2));
|
|
8427
9306
|
mkdirSync8(dirname12(retained), { recursive: true, mode: 448 });
|
|
8428
9307
|
this.move(path, retained);
|
|
8429
9308
|
} else {
|
|
@@ -8434,7 +9313,7 @@ var MigrationFilesystem = class {
|
|
|
8434
9313
|
}
|
|
8435
9314
|
mkdir(path) {
|
|
8436
9315
|
const missing = [];
|
|
8437
|
-
for (let p = path; !
|
|
9316
|
+
for (let p = path; !existsSync23(p) && p !== dirname12(p); p = dirname12(p))
|
|
8438
9317
|
missing.push(p);
|
|
8439
9318
|
for (const p of missing.reverse()) {
|
|
8440
9319
|
for (const journal of this.journals())
|
|
@@ -8448,9 +9327,9 @@ var MigrationFilesystem = class {
|
|
|
8448
9327
|
};
|
|
8449
9328
|
|
|
8450
9329
|
// packages/workbench-server/dist/infrastructure/migrations/framework/context.js
|
|
8451
|
-
import { readFileSync as
|
|
9330
|
+
import { readFileSync as readFileSync13, realpathSync as realpathSync6 } from "node:fs";
|
|
8452
9331
|
import { appendFile, mkdir, statfs } from "node:fs/promises";
|
|
8453
|
-
import { join as
|
|
9332
|
+
import { join as join26 } from "node:path";
|
|
8454
9333
|
async function assertFreeDisk(path, required) {
|
|
8455
9334
|
const stats = await statfs(path, { bigint: true });
|
|
8456
9335
|
const available = stats.bavail * stats.bsize;
|
|
@@ -8458,10 +9337,10 @@ async function assertFreeDisk(path, required) {
|
|
|
8458
9337
|
throw new Error(`Migration requires ${required} free bytes; only ${available} available.`);
|
|
8459
9338
|
}
|
|
8460
9339
|
}
|
|
8461
|
-
var discardedItemsPath = (scratchDir) =>
|
|
9340
|
+
var discardedItemsPath = (scratchDir) => join26(scratchDir, "discarded.json");
|
|
8462
9341
|
function readDiscardedItems(scratchDir) {
|
|
8463
9342
|
try {
|
|
8464
|
-
const ids = JSON.parse(
|
|
9343
|
+
const ids = JSON.parse(readFileSync13(discardedItemsPath(scratchDir), "utf8"));
|
|
8465
9344
|
if (!Array.isArray(ids) || !ids.every((id) => typeof id === "string"))
|
|
8466
9345
|
throw new Error("Invalid discarded item list");
|
|
8467
9346
|
return new Set(ids);
|
|
@@ -8473,7 +9352,7 @@ function readDiscardedItems(scratchDir) {
|
|
|
8473
9352
|
}
|
|
8474
9353
|
function createStepContext(requestedPaths, id, description, onProgress) {
|
|
8475
9354
|
const paths = storagePaths(realpathSync6(requestedPaths.home));
|
|
8476
|
-
const scratchDir =
|
|
9355
|
+
const scratchDir = join26(paths.migrationWorkPath, id);
|
|
8477
9356
|
let logging = Promise.resolve();
|
|
8478
9357
|
let logError;
|
|
8479
9358
|
const context = {
|
|
@@ -8482,7 +9361,7 @@ function createStepContext(requestedPaths, id, description, onProgress) {
|
|
|
8482
9361
|
ownPaths: (paths2, root) => ownPaths(context, paths2, root),
|
|
8483
9362
|
unit: (item, fn, options) => runUnit(context, item, fn, options),
|
|
8484
9363
|
readJson: (path, schema) => checkedJson(context, path, schema),
|
|
8485
|
-
quarantine: (item,
|
|
9364
|
+
quarantine: (item, payload2) => quarantine(context, item, payload2),
|
|
8486
9365
|
loss: (reason2, count) => recordLoss(context, reason2, count),
|
|
8487
9366
|
scratchDir,
|
|
8488
9367
|
discarded: readDiscardedItems(scratchDir),
|
|
@@ -8490,7 +9369,7 @@ function createStepContext(requestedPaths, id, description, onProgress) {
|
|
|
8490
9369
|
log(message) {
|
|
8491
9370
|
logging = logging.then(async () => {
|
|
8492
9371
|
await mkdir(scratchDir, { recursive: true, mode: 448 });
|
|
8493
|
-
await appendFile(
|
|
9372
|
+
await appendFile(join26(scratchDir, "step.log"), `${(/* @__PURE__ */ new Date()).toISOString()} ${message}
|
|
8494
9373
|
`, { mode: 384 });
|
|
8495
9374
|
}).catch((error) => {
|
|
8496
9375
|
logError = error;
|
|
@@ -8510,9 +9389,9 @@ function createStepContext(requestedPaths, id, description, onProgress) {
|
|
|
8510
9389
|
}
|
|
8511
9390
|
|
|
8512
9391
|
// packages/workbench-server/dist/infrastructure/migrations/framework/recovery.js
|
|
8513
|
-
import { existsSync as
|
|
9392
|
+
import { existsSync as existsSync24 } from "node:fs";
|
|
8514
9393
|
import { copyFile, readFile, rm as rm2 } from "node:fs/promises";
|
|
8515
|
-
import { dirname as dirname13, join as
|
|
9394
|
+
import { dirname as dirname13, join as join27 } from "node:path";
|
|
8516
9395
|
async function readMigrationFailureReport(paths) {
|
|
8517
9396
|
try {
|
|
8518
9397
|
return JSON.parse(await readFile(paths.migrationFailureReportPath, "utf8"));
|
|
@@ -8543,8 +9422,8 @@ async function discardFailedItems(home, ids, options = {}) {
|
|
|
8543
9422
|
const unknown = ids.filter((id) => !failed.has(id));
|
|
8544
9423
|
if (!ids.length || unknown.length)
|
|
8545
9424
|
throw new Error(`Only items reported by the last upgrade attempt can be discarded${unknown.length ? `: ${unknown.join(", ")}` : ""}.`);
|
|
8546
|
-
const scratchDir =
|
|
8547
|
-
const dependencyPath =
|
|
9425
|
+
const scratchDir = join27(paths.migrationWorkPath, report.step);
|
|
9426
|
+
const dependencyPath = join27(scratchDir, "unit-dependencies.json");
|
|
8548
9427
|
const dependencies = await pathExists(dependencyPath) ? JSON.parse(await readFile(dependencyPath, "utf8")) : {};
|
|
8549
9428
|
const chosen = new Set(ids);
|
|
8550
9429
|
for (const id of chosen)
|
|
@@ -8552,7 +9431,7 @@ async function discardFailedItems(home, ids, options = {}) {
|
|
|
8552
9431
|
if (failed.has(child))
|
|
8553
9432
|
chosen.add(child);
|
|
8554
9433
|
const discarded = readDiscardedItems(scratchDir);
|
|
8555
|
-
const detailsPath =
|
|
9434
|
+
const detailsPath = join27(scratchDir, "discarded-details.json");
|
|
8556
9435
|
const details = await pathExists(detailsPath) ? JSON.parse(await readFile(detailsPath, "utf8")) : [];
|
|
8557
9436
|
for (const item of report.discardable ?? [])
|
|
8558
9437
|
if (chosen.has(item.id) && !details.some((saved) => saved.id === item.id))
|
|
@@ -8575,15 +9454,15 @@ async function rollbackFailedMigration(home, options = {}) {
|
|
|
8575
9454
|
if (entry2?.step.id !== report.step)
|
|
8576
9455
|
throw new Error(`Upgrade step ${report.step} is not pending.`);
|
|
8577
9456
|
const { context } = createStepContext(paths, entry2.step.id, entry2.step.description, () => void 0);
|
|
8578
|
-
if (
|
|
9457
|
+
if (existsSync24(join27(context.scratchDir, "verified.json")))
|
|
8579
9458
|
throw new Error("The failed upgrade cannot be rolled back.");
|
|
8580
9459
|
await entry2.step.rollback?.(context);
|
|
8581
|
-
if (
|
|
9460
|
+
if (existsSync24(join27(context.scratchDir, "rollback")))
|
|
8582
9461
|
new RollbackJournal(context.scratchDir).restore();
|
|
8583
9462
|
const baselineBackup = manifestBackupPath(paths);
|
|
8584
|
-
const restoredMarker =
|
|
9463
|
+
const restoredMarker = join27(context.scratchDir, "manifest-restored.json");
|
|
8585
9464
|
if (!await pathExists(restoredMarker)) {
|
|
8586
|
-
const backup2 = !manifest.migrations?.length && await pathExists(baselineBackup) ? baselineBackup :
|
|
9465
|
+
const backup2 = !manifest.migrations?.length && await pathExists(baselineBackup) ? baselineBackup : join27(context.scratchDir, "manifest.before.json");
|
|
8587
9466
|
if (!await pathExists(backup2))
|
|
8588
9467
|
throw new Error("Missing pre-step manifest rollback snapshot.");
|
|
8589
9468
|
const temporary = `${paths.manifestPath}.rollback`;
|
|
@@ -8595,7 +9474,7 @@ async function rollbackFailedMigration(home, options = {}) {
|
|
|
8595
9474
|
}
|
|
8596
9475
|
await rm2(baselineBackup, { force: true });
|
|
8597
9476
|
await rm2(context.scratchDir, { recursive: true, force: true });
|
|
8598
|
-
await rm2(
|
|
9477
|
+
await rm2(join27(paths.migrationWorkPath, "cleanup-needed.json"), {
|
|
8599
9478
|
force: true
|
|
8600
9479
|
});
|
|
8601
9480
|
await rm2(paths.migrationFailureReportPath, { force: true });
|