openpond 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/actions-command-QP3NMDK4.js +2 -0
- package/dist/chunks/app-layer-N7VFRVJ2.js +3 -0
- package/dist/chunks/app-server-runtime-OCLPUI7F.js +2 -0
- package/dist/chunks/apps-AMG75TI4.js +2 -0
- package/dist/chunks/chunk-22UARBPW.js +3 -0
- package/dist/chunks/chunk-3A7HZJNE.js +1 -0
- package/dist/chunks/chunk-3M53YXEI.js +2 -0
- package/dist/chunks/chunk-3NDRIQTI.js +2 -0
- package/dist/chunks/chunk-5BBVEWG3.js +2 -0
- package/dist/chunks/chunk-5O7ZVCMV.js +6 -0
- package/dist/chunks/chunk-6FA3GG5B.js +33 -0
- package/dist/chunks/chunk-6MI4KKWF.js +2 -0
- package/dist/chunks/chunk-BBG546O6.js +6 -0
- package/dist/chunks/chunk-BX4J2VDU.js +2 -0
- package/dist/chunks/chunk-BZMVB3GS.js +2 -0
- package/dist/chunks/chunk-C5LOZSVS.js +2 -0
- package/dist/chunks/chunk-CWQWV2T3.js +2 -0
- package/dist/chunks/chunk-DUA3QP6Y.js +19 -0
- package/dist/chunks/chunk-EAPFMACH.js +10 -0
- package/dist/chunks/chunk-ES2ISFJC.js +66 -0
- package/dist/chunks/chunk-F65NIZLM.js +2199 -0
- package/dist/chunks/chunk-FGJ5LFPL.js +5 -0
- package/dist/chunks/chunk-FTQLQJQV.js +2 -0
- package/dist/chunks/chunk-FY7OQ5RK.js +24 -0
- package/dist/chunks/chunk-FYCJSUFV.js +53 -0
- package/dist/chunks/chunk-GLUWATL5.js +2 -0
- package/dist/chunks/chunk-H7IWJN7L.js +17 -0
- package/dist/chunks/chunk-HZP5U2AA.js +3 -0
- package/dist/chunks/chunk-I5K74TOH.js +3 -0
- package/dist/chunks/chunk-IR3YJWPW.js +7 -0
- package/dist/chunks/chunk-KU7QOHFT.js +2872 -0
- package/dist/chunks/chunk-KV553EWX.js +16 -0
- package/dist/chunks/chunk-MGN6GLNZ.js +2 -0
- package/dist/chunks/chunk-OG5Q6NXK.js +28 -0
- package/dist/chunks/chunk-OGPHXXCD.js +1 -0
- package/dist/chunks/chunk-PI36UHRA.js +18 -0
- package/dist/chunks/chunk-RWSAGQTP.js +2 -0
- package/dist/chunks/chunk-SAE4OIPC.js +2 -0
- package/dist/chunks/chunk-SDO4FC4Q.js +2 -0
- package/dist/chunks/chunk-UKUVMXOW.js +12 -0
- package/dist/chunks/chunk-VCLCFK3O.js +36 -0
- package/dist/chunks/chunk-VYUMTRB3.js +5 -0
- package/dist/chunks/chunk-X37KMV27.js +1 -0
- package/dist/chunks/chunk-XDHAGACI.js +3 -0
- package/dist/chunks/chunk-XEOEKFG6.js +71 -0
- package/dist/chunks/chunk-ZF7TEGY5.js +5 -0
- package/dist/chunks/chunk-ZVOO7FKM.js +2 -0
- package/dist/chunks/cli-M2FG7SSI.js +2 -0
- package/dist/chunks/configuration-command-XBKBIZBO.js +2 -0
- package/dist/chunks/continual-D75WA7E7.js +7 -0
- package/dist/chunks/core-commands-LUZVWXQR.js +2 -0
- package/dist/chunks/database-X2CUV732.js +2 -0
- package/dist/chunks/desktop-test-KGC4JVJ7.js +3 -0
- package/dist/chunks/dist-NKLXFA37.js +2 -0
- package/dist/chunks/extension-NQ7N5LEY.js +5 -0
- package/dist/chunks/help-MWK66XZK.js +8 -0
- package/dist/chunks/module-ES6BEMUI-ZVL3F6NW.js +2 -0
- package/dist/chunks/module-asyncify-2EFITU5U-R7TVXNAE.js +2 -0
- package/dist/chunks/opchat-XJZA3QKZ.js +3 -0
- package/dist/chunks/organizations-UECDFEYE.js +2 -0
- package/dist/chunks/profile-KUMIZURM.js +3 -0
- package/dist/chunks/project-agent-NILMJHLV.js +2 -0
- package/dist/chunks/sandbox-command-QHH65OSE.js +2 -0
- package/dist/chunks/sandbox-template-N7I63PNU.js +10 -0
- package/dist/chunks/src-724HF43W.js +82 -0
- package/dist/chunks/src-VTKTTKQO.js +319 -0
- package/dist/chunks/taskset-PISBOILQ.js +2 -0
- package/dist/chunks/teams-bot-UV4RU53M.js +3 -0
- package/dist/chunks/training-2NDOWH5S.js +2 -0
- package/dist/chunks/workspaces-XXT4KUD3.js +2 -0
- package/dist/cli.js +3 -109
- package/dist/index.js +1 -31230
- package/dist/sandbox-template/manifest.js +1 -18380
- package/dist/web/assets/App-DxecRQUL.js +176 -0
- package/dist/web/assets/AppDialog-B65Eo3gp.js +1 -0
- package/dist/web/assets/AppTerminalPanel-B2EKQM7W.js +2 -0
- package/dist/web/assets/{AppsView-B1NUuAIf.js → AppsView-BBoVe7s2.js} +1 -1
- package/dist/web/assets/{BrowserSidebar-DOvYxXeP.js → BrowserSidebar-CSM1atSJ.js} +1 -1
- package/dist/web/assets/{CartesianChart-pOrYpzBr.js → CartesianChart-CJKfXiEG.js} +1 -1
- package/dist/web/assets/{CollaborationTabs-CgbR-MBJ.js → CollaborationTabs-BMZamWFC.js} +1 -1
- package/dist/web/assets/{CommandMenu-CrIr4qUX.js → CommandMenu-B3U1z2eo.js} +1 -1
- package/dist/web/assets/{CommunityView-CvAVQ_HZ.js → CommunityView-CTyRUcfy.js} +1 -1
- package/dist/web/assets/{ComposerCreateImproveStrip-DybcKwwd.js → ComposerCreateImproveStrip-D7usvRtK.js} +1 -1
- package/dist/web/assets/GetStartedView-Ibu7oKWJ.js +1 -0
- package/dist/web/assets/HostedModelLearningReview-qnzIkT70.js +1 -0
- package/dist/web/assets/HostedModelLearningSettings--PKjpYsy.js +1 -0
- package/dist/web/assets/LabModelVersionDetailPage-s9uUN6fV.js +1 -0
- package/dist/web/assets/{LabSkillSidebar-CuaYrtiu.js → LabSkillSidebar-BKYseMiJ.js} +1 -1
- package/dist/web/assets/LabsRoute-C1FWCoYb.css +1 -0
- package/dist/web/assets/LabsRoute-DoRs0K6v.js +32 -0
- package/dist/web/assets/MainChatThread-DvuyMcMB.js +2 -0
- package/dist/web/assets/MainPane-BWwcxgHD.js +8 -0
- package/dist/web/assets/{MarkdownText-DOlVQR8a.js → MarkdownText-D8XC5UT_.js} +1 -1
- package/dist/web/assets/{Messages-DMubppta.js → Messages-e4A8JUjD.js} +6 -6
- package/dist/web/assets/{NativeSkillSidebar-DSFwZ-od.js → NativeSkillSidebar-D2Joh8XB.js} +1 -1
- package/dist/web/assets/{NewExperienceSwitcher-Dj0ePIJ-.js → NewExperienceSwitcher-CzGebt2E.js} +1 -1
- package/dist/web/assets/{NewProjectDialog-B8NQV-Ji.js → NewProjectDialog-CdMTSxUE.js} +1 -1
- package/dist/web/assets/{OutputsPage-D_LDYTgV.js → OutputsPage-m7cSb8dW.js} +1 -1
- package/dist/web/assets/{ProjectsPage-xjDYPc_W.js → ProjectsPage-C9mz8W1g.js} +1 -1
- package/dist/web/assets/RightChatPanelStack-B4LEqKEj.js +1 -0
- package/dist/web/assets/{RightSidebarHomePanel-j0VckZUu.js → RightSidebarHomePanel-DOeUsH7h.js} +1 -1
- package/dist/web/assets/{ScheduledWorkPage-1aT4bBY-.js → ScheduledWorkPage-UXZSSWgA.js} +1 -1
- package/dist/web/assets/{SettingsView-BSpuMDpv.js → SettingsView-CQm1ai73.js} +7 -7
- package/dist/web/assets/TeamChatView-C4haojB7.js +3 -0
- package/dist/web/assets/{TerminalOverlay-CrSwUk2d.js → TerminalOverlay-p2GZsuyQ.js} +3 -3
- package/dist/web/assets/{TrainingCreationPanel-B4HMRwUg.js → TrainingCreationPanel-BYJSlO8X.js} +1 -1
- package/dist/web/assets/{TrainingDraftPanel-D4r1tN3I.js → TrainingDraftPanel-DR5KlayH.js} +1 -1
- package/dist/web/assets/{UsageSettingsSection-2aymqwIM.js → UsageSettingsSection-BQToNXE4.js} +5 -5
- package/dist/web/assets/{WorkSidebarPanel-B0X0OiR6.js → WorkSidebarPanel--EeytWeg.js} +1 -1
- package/dist/web/assets/WorkspaceDiffPanel-BrovSYhn.js +14 -0
- package/dist/web/assets/{WorkspaceEnvironmentMenu-OAfMEt7L.js → WorkspaceEnvironmentMenu-l-keRgvj.js} +3 -3
- package/dist/web/assets/{WorkspaceGitDialogs-YxcPH2Rq.js → WorkspaceGitDialogs-aicWzaZu.js} +1 -1
- package/dist/web/assets/{WorkspaceMonacoEditor-COKTiQZl.js → WorkspaceMonacoEditor-CO_E74jM.js} +36 -36
- package/dist/web/assets/{arrow-up-right-_TX-awvK.js → arrow-up-right-rwPXNfVn.js} +1 -1
- package/dist/web/assets/chat-file-links-B3jDstSC.js +1 -0
- package/dist/web/assets/chevron-up-D089nvYQ.js +1 -0
- package/dist/web/assets/{clipboard-CyRSS8Sy.js → clipboard-DwEExyU4.js} +1 -1
- package/dist/web/assets/{cloud-upload-uBJBUYTy.js → cloud-upload-D2he0-vQ.js} +1 -1
- package/dist/web/assets/{cssMode-BrXSsZYs.js → cssMode-DS4k0NcI.js} +1 -1
- package/dist/web/assets/{folder-open-DktdZNW7.js → folder-open-CAOLduKD.js} +1 -1
- package/dist/web/assets/{folder-plus-DO06i9Vo.js → folder-plus-D56MrxVT.js} +1 -1
- package/dist/web/assets/{git-commit-horizontal-zFSIkPs7.js → git-commit-horizontal-CeNM0oKJ.js} +1 -1
- package/dist/web/assets/{htmlMode-X9UMFkjt.js → htmlMode-Xkni5erh.js} +1 -1
- package/dist/web/assets/{index-ByQIHpc9.css → index-BGMzUaup.css} +1 -1
- package/dist/web/assets/{index-UOGdfLzi.js → index-KwyAyscP.js} +1 -1
- package/dist/web/assets/{info-BEJXUqCD.js → info-CcrBaEE_.js} +1 -1
- package/dist/web/assets/{jsonMode-DIsB-j2E.js → jsonMode-C4YPbQB7.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-CmZ17KpA.js → lspLanguageFeatures-CF5oMTz6.js} +1 -1
- package/dist/web/assets/{minimize-2-DumTpFtE.js → minimize-2-DzHQnInk.js} +1 -1
- package/dist/web/assets/{monaco.contribution-DJ_NmcHu.js → monaco.contribution-0EN4mGCC.js} +2 -2
- package/dist/web/assets/{monaco.contribution-YVDfJcG4.js → monaco.contribution-B4qcTP0w.js} +2 -2
- package/dist/web/assets/{monaco.contribution-LZEujgny.js → monaco.contribution-CJK_NrBm.js} +2 -2
- package/dist/web/assets/{monaco.contribution-D6w5PJji.js → monaco.contribution-CkPGKNd-.js} +2 -2
- package/dist/web/assets/{play-CLFeH7CU.js → play-p3-AMTPL.js} +1 -1
- package/dist/web/assets/{python-Djbda_qZ.js → python-B0kpTxAZ.js} +1 -1
- package/dist/web/assets/{refresh-cw-B4IpQ_7Q.js → refresh-cw-_jbTIzzr.js} +1 -1
- package/dist/web/assets/{save-BbTHztnA.js → save-Cy6hEotx.js} +1 -1
- package/dist/web/assets/{square-BJrVbmz6.js → square-DKQkcrOH.js} +1 -1
- package/dist/web/assets/{toggleHighContrast-BopU5W9S.js → toggleHighContrast-Bnk1VVVq.js} +1 -1
- package/dist/web/assets/{tsMode-CH_0_YDX.js → tsMode-BDrSVy7V.js} +1 -1
- package/dist/web/assets/{upload-UumVeufu.js → upload-COn0my_O.js} +1 -1
- package/dist/web/assets/{useLocalAgentSchedules-BRa23U7O.js → useLocalAgentSchedules-iZNB4Oee.js} +1 -1
- package/dist/web/assets/{wifi-off-BWJWivn6.js → wifi-off-Cqt-ZLXY.js} +1 -1
- package/dist/web/assets/{workers-pTe8RvSI.js → workers-hu0Ym93h.js} +1 -1
- package/dist/web/assets/{yaml-DNLASORn.js → yaml-D-JLDGL6.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +4 -3
- package/dist/chunks/actions-command-6N5XWMR6.js +0 -185
- package/dist/chunks/app-layer-F3CGXB33.js +0 -216
- package/dist/chunks/app-server-runtime-RHO5TFUC.js +0 -23
- package/dist/chunks/apps-L5XCL7QY.js +0 -429
- package/dist/chunks/chunk-26AMV5ZI.js +0 -634
- package/dist/chunks/chunk-3EB7I67T.js +0 -630
- package/dist/chunks/chunk-3ELF4FXY.js +0 -96
- package/dist/chunks/chunk-3VEYNDHN.js +0 -669
- package/dist/chunks/chunk-4KA25HUP.js +0 -5648
- package/dist/chunks/chunk-4L3ZJS2T.js +0 -1207
- package/dist/chunks/chunk-6SMNG6YA.js +0 -1303
- package/dist/chunks/chunk-7RIGZB7N.js +0 -1148
- package/dist/chunks/chunk-A6G3PFA5.js +0 -2164
- package/dist/chunks/chunk-BVY5JYM6.js +0 -512
- package/dist/chunks/chunk-DLQQIWN2.js +0 -648
- package/dist/chunks/chunk-FJ2JGB2N.js +0 -1373
- package/dist/chunks/chunk-FQS2QL5F.js +0 -14522
- package/dist/chunks/chunk-G65WAOJV.js +0 -1643
- package/dist/chunks/chunk-JTHL5XJ2.js +0 -1838
- package/dist/chunks/chunk-K4TZEHAW.js +0 -602
- package/dist/chunks/chunk-KCRCIQPD.js +0 -66
- package/dist/chunks/chunk-KSRWKXRB.js +0 -12
- package/dist/chunks/chunk-MUMPWI4O.js +0 -92
- package/dist/chunks/chunk-NTK22KJD.js +0 -10707
- package/dist/chunks/chunk-OCBRPU2K.js +0 -629
- package/dist/chunks/chunk-PS37DB5F.js +0 -183
- package/dist/chunks/chunk-R3C3MNSI.js +0 -140
- package/dist/chunks/chunk-SMNFI2FU.js +0 -113
- package/dist/chunks/chunk-UACZUFIA.js +0 -47
- package/dist/chunks/chunk-UZMVNKXM.js +0 -1275
- package/dist/chunks/chunk-VT6BLHMB.js +0 -67198
- package/dist/chunks/chunk-W5GKHH77.js +0 -168
- package/dist/chunks/chunk-X6F4LBTQ.js +0 -832
- package/dist/chunks/chunk-X7ZG4TSW.js +0 -3063
- package/dist/chunks/chunk-XA4KBDMY.js +0 -13723
- package/dist/chunks/chunk-YVCYVDNP.js +0 -746
- package/dist/chunks/chunk-ZNQEROWP.js +0 -254
- package/dist/chunks/cli-D2MUUBEX.js +0 -23
- package/dist/chunks/configuration-command-NR6JYIUD.js +0 -187
- package/dist/chunks/continual-37CE4LLJ.js +0 -803
- package/dist/chunks/core-commands-SWGIOZLW.js +0 -50
- package/dist/chunks/database-DEYUZDIM.js +0 -20
- package/dist/chunks/desktop-test-QOS7G5NE.js +0 -148
- package/dist/chunks/dist-AKYCQNNF.js +0 -187
- package/dist/chunks/extension-HJUJBQAD.js +0 -9378
- package/dist/chunks/help-J6PZ23IC.js +0 -67
- package/dist/chunks/opchat-ABX5YBAT.js +0 -169
- package/dist/chunks/organizations-CPNC47DO.js +0 -806
- package/dist/chunks/profile-Q3HB5MIO.js +0 -1136
- package/dist/chunks/project-agent-YHUBX4OR.js +0 -516
- package/dist/chunks/sandbox-command-YFL5QTWX.js +0 -1661
- package/dist/chunks/sandbox-template-Z6P7NTNF.js +0 -1655
- package/dist/chunks/src-7XEENEBI.js +0 -3628
- package/dist/chunks/src-KBBIV4NT.js +0 -56125
- package/dist/chunks/taskset-2TRZBRRT.js +0 -66
- package/dist/chunks/teams-bot-WD33NLH5.js +0 -146
- package/dist/chunks/training-4XH37UZB.js +0 -17
- package/dist/chunks/workspaces-WG2MH2WE.js +0 -99
- package/dist/web/assets/App-C9aGkxVg.js +0 -173
- package/dist/web/assets/AppDialog-CK6_lg8c.js +0 -1
- package/dist/web/assets/AppTerminalPanel-BKqgX4sd.js +0 -2
- package/dist/web/assets/GetStartedView-DVInkexN.js +0 -1
- package/dist/web/assets/LabModelVersionDetailPage-NaaPElmM.js +0 -1
- package/dist/web/assets/LabsRoute-BRR6x3SX.js +0 -2
- package/dist/web/assets/LabsRoute-CGFgymTX.css +0 -1
- package/dist/web/assets/MainChatThread-BfkjCZB9.js +0 -2
- package/dist/web/assets/MainPane-Gw-YK38n.js +0 -8
- package/dist/web/assets/RightChatPanelStack-BktRQ9wg.js +0 -1
- package/dist/web/assets/TeamChatView-BPWJbDf1.js +0 -3
- package/dist/web/assets/WorkspaceDiffPanel-Pg7GL0br.js +0 -14
- package/dist/web/assets/chat-file-links-CWLsRYvW.js +0 -1
- package/dist/web/assets/chevron-up--mNnEqha.js +0 -1
- package/dist/web/assets/index-BEPmTPIA.js +0 -1
|
@@ -1,1207 +0,0 @@
|
|
|
1
|
-
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
OpenPondApiError,
|
|
4
|
-
apiFetch,
|
|
5
|
-
createOpenPondSandboxClient,
|
|
6
|
-
readApiJson,
|
|
7
|
-
resolveOpChatApiBaseUrl,
|
|
8
|
-
sendHostedChatTurn
|
|
9
|
-
} from "./chunk-JTHL5XJ2.js";
|
|
10
|
-
import {
|
|
11
|
-
external_exports
|
|
12
|
-
} from "./chunk-FQS2QL5F.js";
|
|
13
|
-
|
|
14
|
-
// ../../packages/sdk/src/work.ts
|
|
15
|
-
var DEFAULT_MODEL = "openpond-chat";
|
|
16
|
-
var DEFAULT_MAX_STEPS = 24;
|
|
17
|
-
var MAX_TOOL_OUTPUT_CHARS = 4e4;
|
|
18
|
-
var MAX_WORK_COMMAND_CHARS = 2e4;
|
|
19
|
-
var WORK_OUTPUT_DIRECTORY = "outputs";
|
|
20
|
-
var WORK_INPUT_DIRECTORY = "inputs/previous-outputs";
|
|
21
|
-
var WORK_INPUT_MANIFEST = "inputs/.openpond-context.json";
|
|
22
|
-
var MAX_WORK_OUTPUTS = 100;
|
|
23
|
-
var MAX_WORK_INPUTS = 100;
|
|
24
|
-
var MAX_WORK_INPUT_BYTES = 100 * 1024 * 1024;
|
|
25
|
-
var OpenPondWorkClient = class {
|
|
26
|
-
#apiKey;
|
|
27
|
-
#apiBaseUrl;
|
|
28
|
-
#chatApiBaseUrl;
|
|
29
|
-
#sandboxes;
|
|
30
|
-
constructor(input) {
|
|
31
|
-
this.#apiKey = input.apiKey;
|
|
32
|
-
this.#apiBaseUrl = input.apiBaseUrl;
|
|
33
|
-
this.#chatApiBaseUrl = input.chatApiBaseUrl;
|
|
34
|
-
this.#sandboxes = input.sandboxes;
|
|
35
|
-
}
|
|
36
|
-
async run(input) {
|
|
37
|
-
const prompt = input.prompt.trim();
|
|
38
|
-
if (!prompt) throw new Error("Work prompt is required");
|
|
39
|
-
input.signal?.throwIfAborted();
|
|
40
|
-
const emit = async (event) => input.onEvent?.(event);
|
|
41
|
-
const cleanupPolicy = input.cleanup ?? "keep";
|
|
42
|
-
const lifecycle = initialLifecycle(cleanupPolicy);
|
|
43
|
-
let sandbox = null;
|
|
44
|
-
let outputBaseline = null;
|
|
45
|
-
let finalizationAttempted = false;
|
|
46
|
-
const maxSteps = boundedInteger(input.maxSteps, 1, 100, DEFAULT_MAX_STEPS);
|
|
47
|
-
let finalText = "";
|
|
48
|
-
try {
|
|
49
|
-
await emit({ type: "status", message: "Preparing sandbox" });
|
|
50
|
-
sandbox = await this.#resolveSandbox(input);
|
|
51
|
-
await emit({
|
|
52
|
-
type: "sandbox",
|
|
53
|
-
sandboxId: sandbox.id,
|
|
54
|
-
state: sandbox.state
|
|
55
|
-
});
|
|
56
|
-
await this.#stageInputs(sandbox.id, input.inputs ?? []);
|
|
57
|
-
outputBaseline = await this.#prepareOutputDirectory(sandbox.id);
|
|
58
|
-
const messages = [
|
|
59
|
-
{
|
|
60
|
-
role: "system",
|
|
61
|
-
content: systemPrompt(sandbox.id, (input.inputs?.length ?? 0) > 0)
|
|
62
|
-
},
|
|
63
|
-
...(input.history ?? []).map((message) => ({ ...message })),
|
|
64
|
-
{ role: "user", content: prompt }
|
|
65
|
-
];
|
|
66
|
-
for (let step = 1; step <= maxSteps; step += 1) {
|
|
67
|
-
input.signal?.throwIfAborted();
|
|
68
|
-
await emit({ type: "status", message: `Thinking \xB7 step ${step}` });
|
|
69
|
-
const completion = await sendHostedChatTurn({
|
|
70
|
-
apiBaseUrl: this.#chatApiBaseUrl,
|
|
71
|
-
token: this.#apiKey,
|
|
72
|
-
model: input.model?.trim() || DEFAULT_MODEL,
|
|
73
|
-
messages,
|
|
74
|
-
tools: WORK_TOOLS,
|
|
75
|
-
toolChoice: "auto",
|
|
76
|
-
signal: input.signal,
|
|
77
|
-
metadata: {
|
|
78
|
-
source: "openpond-sdk-work",
|
|
79
|
-
sandboxId: sandbox.id,
|
|
80
|
-
apiBaseUrl: this.#apiBaseUrl,
|
|
81
|
-
...input.metadata
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
const choice = completion.choices?.[0];
|
|
85
|
-
const assistantText = choice?.message?.content?.trim() ?? "";
|
|
86
|
-
const toolCalls = choice?.message?.tool_calls ?? [];
|
|
87
|
-
messages.push({
|
|
88
|
-
role: "assistant",
|
|
89
|
-
content: assistantText || null,
|
|
90
|
-
...toolCalls.length > 0 ? { tool_calls: toolCalls } : {}
|
|
91
|
-
});
|
|
92
|
-
if (assistantText) {
|
|
93
|
-
finalText = assistantText;
|
|
94
|
-
await emit({ type: "assistant", text: assistantText });
|
|
95
|
-
}
|
|
96
|
-
if (toolCalls.length === 0) {
|
|
97
|
-
const outputs = await this.#collectOutputs(sandbox.id, outputBaseline);
|
|
98
|
-
for (const output of outputs) await emit({ type: "output", output });
|
|
99
|
-
finalizationAttempted = true;
|
|
100
|
-
await this.#finalizeSandbox(sandbox.id, outputs, input, lifecycle, emit);
|
|
101
|
-
const result = {
|
|
102
|
-
sandboxId: sandbox.id,
|
|
103
|
-
text: finalText,
|
|
104
|
-
steps: step,
|
|
105
|
-
outputs,
|
|
106
|
-
lifecycle
|
|
107
|
-
};
|
|
108
|
-
await emit({ type: "done", ...result });
|
|
109
|
-
return result;
|
|
110
|
-
}
|
|
111
|
-
for (const [index, toolCall] of toolCalls.entries()) {
|
|
112
|
-
const result = await this.#executeTool(
|
|
113
|
-
sandbox.id,
|
|
114
|
-
toolCall,
|
|
115
|
-
index,
|
|
116
|
-
input.timeoutSeconds,
|
|
117
|
-
emit
|
|
118
|
-
);
|
|
119
|
-
messages.push(result);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
throw new Error(`Work did not finish within ${maxSteps} steps`);
|
|
123
|
-
} catch (error) {
|
|
124
|
-
if (sandbox && outputBaseline && !finalizationAttempted) {
|
|
125
|
-
try {
|
|
126
|
-
const outputs = await this.#collectOutputs(sandbox.id, outputBaseline);
|
|
127
|
-
for (const output of outputs) await emit({ type: "output", output });
|
|
128
|
-
await this.#finalizeSandbox(sandbox.id, outputs, input, lifecycle, emit);
|
|
129
|
-
} catch (finalizationError) {
|
|
130
|
-
attachWorkFailure(error, lifecycle, finalizationError);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
attachWorkFailure(error, lifecycle);
|
|
134
|
-
throw error;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
async deleteSandbox(sandboxId) {
|
|
138
|
-
const sandbox = await this.#sandboxes.get(sandboxId);
|
|
139
|
-
if (sandbox.state === "deleted") return;
|
|
140
|
-
await this.#sandboxes.delete(sandboxId);
|
|
141
|
-
}
|
|
142
|
-
async #stageInputs(sandboxId, inputs) {
|
|
143
|
-
if (inputs.length === 0) return;
|
|
144
|
-
if (inputs.length > MAX_WORK_INPUTS) {
|
|
145
|
-
throw new Error(`Work inputs exceed the ${MAX_WORK_INPUTS} file limit`);
|
|
146
|
-
}
|
|
147
|
-
const decodedBytes = inputs.reduce(
|
|
148
|
-
(total, input) => total + Buffer.byteLength(input.contentsBase64, "base64"),
|
|
149
|
-
0
|
|
150
|
-
);
|
|
151
|
-
if (decodedBytes > MAX_WORK_INPUT_BYTES) {
|
|
152
|
-
throw new Error(`Work inputs exceed the ${MAX_WORK_INPUT_BYTES} byte limit`);
|
|
153
|
-
}
|
|
154
|
-
await this.#sandboxes.mkdir(sandboxId, {
|
|
155
|
-
path: WORK_INPUT_DIRECTORY,
|
|
156
|
-
recursive: true
|
|
157
|
-
});
|
|
158
|
-
const usedNames = /* @__PURE__ */ new Set();
|
|
159
|
-
const manifest = [];
|
|
160
|
-
for (const [index, input] of inputs.entries()) {
|
|
161
|
-
const name = uniqueInputName(input, index, usedNames);
|
|
162
|
-
const stagedPath = `${WORK_INPUT_DIRECTORY}/${name}`;
|
|
163
|
-
await this.#sandboxes.uploadFileBase64(
|
|
164
|
-
sandboxId,
|
|
165
|
-
stagedPath,
|
|
166
|
-
input.contentsBase64
|
|
167
|
-
);
|
|
168
|
-
manifest.push({
|
|
169
|
-
id: input.id,
|
|
170
|
-
path: stagedPath,
|
|
171
|
-
name: input.name,
|
|
172
|
-
mimeType: input.mimeType ?? null,
|
|
173
|
-
checksumSha256: input.checksumSha256 ?? null,
|
|
174
|
-
revision: input.revision ?? null,
|
|
175
|
-
metadata: input.metadata ?? {}
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
await this.#sandboxes.uploadFile(
|
|
179
|
-
sandboxId,
|
|
180
|
-
WORK_INPUT_MANIFEST,
|
|
181
|
-
JSON.stringify({ version: 1, files: manifest }, null, 2)
|
|
182
|
-
);
|
|
183
|
-
}
|
|
184
|
-
async #finalizeSandbox(sandboxId, outputs, input, lifecycle, emit) {
|
|
185
|
-
lifecycle.persistence.outputCount = outputs.length;
|
|
186
|
-
if (outputs.length === 0) {
|
|
187
|
-
lifecycle.persistence.status = "not_needed";
|
|
188
|
-
} else if (input.persistOutput) {
|
|
189
|
-
lifecycle.persistence.status = "running";
|
|
190
|
-
for (const output of outputs) {
|
|
191
|
-
await emit({ type: "persistence", output, status: "started" });
|
|
192
|
-
try {
|
|
193
|
-
const download = lazyOutputDownload(this.#sandboxes, sandboxId, output);
|
|
194
|
-
await input.persistOutput({ output, download });
|
|
195
|
-
lifecycle.persistence.persistedCount += 1;
|
|
196
|
-
await emit({ type: "persistence", output, status: "succeeded" });
|
|
197
|
-
} catch (error) {
|
|
198
|
-
const message = errorMessage(error);
|
|
199
|
-
lifecycle.persistence.status = "failed";
|
|
200
|
-
lifecycle.persistence.error = message;
|
|
201
|
-
await emit({
|
|
202
|
-
type: "persistence",
|
|
203
|
-
output,
|
|
204
|
-
status: "failed",
|
|
205
|
-
error: message
|
|
206
|
-
});
|
|
207
|
-
if ((input.cleanup ?? "keep") !== "keep") {
|
|
208
|
-
await this.#cleanupSandbox(sandboxId, "stop", lifecycle, emit);
|
|
209
|
-
}
|
|
210
|
-
throw error;
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
lifecycle.persistence.status = "complete";
|
|
214
|
-
} else if ((input.cleanup ?? "keep") === "delete" && !input.discardOutputs) {
|
|
215
|
-
lifecycle.persistence.status = "failed";
|
|
216
|
-
lifecycle.persistence.error = "Deleting a Work sandbox with outputs requires persistOutput or discardOutputs: true";
|
|
217
|
-
await this.#cleanupSandbox(sandboxId, "stop", lifecycle, emit);
|
|
218
|
-
throw new Error(lifecycle.persistence.error);
|
|
219
|
-
} else {
|
|
220
|
-
lifecycle.persistence.status = "not_requested";
|
|
221
|
-
}
|
|
222
|
-
await this.#cleanupSandbox(
|
|
223
|
-
sandboxId,
|
|
224
|
-
input.cleanup ?? "keep",
|
|
225
|
-
lifecycle,
|
|
226
|
-
emit
|
|
227
|
-
);
|
|
228
|
-
}
|
|
229
|
-
async #cleanupSandbox(sandboxId, policy, lifecycle, emit) {
|
|
230
|
-
if (policy === "keep") return;
|
|
231
|
-
lifecycle.cleanup.status = "running";
|
|
232
|
-
await emit({ type: "cleanup", policy, status: "started" });
|
|
233
|
-
try {
|
|
234
|
-
const sandbox = policy === "delete" ? await this.#sandboxes.delete(sandboxId) : (await this.#sandboxes.stop(sandboxId)).sandbox;
|
|
235
|
-
lifecycle.cleanup.finalSandboxState = sandbox.state;
|
|
236
|
-
lifecycle.cleanup.status = policy === "delete" && sandbox.state === "deleted" || policy === "stop" && sandbox.state === "stopped" ? "complete" : "pending";
|
|
237
|
-
await emit({
|
|
238
|
-
type: "cleanup",
|
|
239
|
-
policy,
|
|
240
|
-
status: lifecycle.cleanup.status,
|
|
241
|
-
sandboxState: sandbox.state
|
|
242
|
-
});
|
|
243
|
-
} catch (error) {
|
|
244
|
-
const message = errorMessage(error);
|
|
245
|
-
lifecycle.cleanup.status = "failed";
|
|
246
|
-
lifecycle.cleanup.error = message;
|
|
247
|
-
await emit({ type: "cleanup", policy, status: "failed", error: message });
|
|
248
|
-
throw error;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
downloadOutput(sandboxId, output) {
|
|
252
|
-
return this.#sandboxes.downloadFileResponse(
|
|
253
|
-
sandboxId,
|
|
254
|
-
typeof output === "string" ? output : output.path
|
|
255
|
-
);
|
|
256
|
-
}
|
|
257
|
-
async #prepareOutputDirectory(sandboxId) {
|
|
258
|
-
await this.#sandboxes.mkdir(sandboxId, {
|
|
259
|
-
path: WORK_OUTPUT_DIRECTORY,
|
|
260
|
-
recursive: true
|
|
261
|
-
});
|
|
262
|
-
return outputSignatures(await this.#listOutputFiles(sandboxId));
|
|
263
|
-
}
|
|
264
|
-
async #collectOutputs(sandboxId, baseline) {
|
|
265
|
-
const files = await this.#listOutputFiles(sandboxId);
|
|
266
|
-
return files.filter((file) => baseline.get(file.path) !== outputSignature(file)).sort((left, right) => left.path.localeCompare(right.path)).slice(0, MAX_WORK_OUTPUTS).map(workOutputFromFile);
|
|
267
|
-
}
|
|
268
|
-
async #listOutputFiles(sandboxId) {
|
|
269
|
-
const listed = await this.#sandboxes.listFiles(sandboxId, {
|
|
270
|
-
path: WORK_OUTPUT_DIRECTORY,
|
|
271
|
-
recursive: true,
|
|
272
|
-
maxEntries: 500
|
|
273
|
-
});
|
|
274
|
-
return listed.files.filter(
|
|
275
|
-
(file) => file.type === "file" && !normalizedOutputPath(file.path).includes("/.openpond-")
|
|
276
|
-
);
|
|
277
|
-
}
|
|
278
|
-
async #resolveSandbox(input) {
|
|
279
|
-
if (input.sandboxId) {
|
|
280
|
-
const existing = await this.#sandboxes.get(input.sandboxId);
|
|
281
|
-
if (existing.state === "stopped") {
|
|
282
|
-
await this.#sandboxes.start(existing.id, { async: true });
|
|
283
|
-
} else if (existing.state === "deleted" || existing.state === "error") {
|
|
284
|
-
throw new Error(`Cannot resume sandbox ${existing.id} in state ${existing.state}`);
|
|
285
|
-
}
|
|
286
|
-
const ready = await this.#waitUntilRunning(existing.id, input.signal);
|
|
287
|
-
return ready;
|
|
288
|
-
}
|
|
289
|
-
const budgetUsd = input.budgetUsd?.trim() || "1.00";
|
|
290
|
-
const created = await this.#sandboxes.create(
|
|
291
|
-
{
|
|
292
|
-
...input.repo?.trim() ? { repo: input.repo.trim() } : {},
|
|
293
|
-
runtimeProfileId: "openpond-work-v1",
|
|
294
|
-
resources: { cpu: 2, memoryGb: 4, diskGb: 16 },
|
|
295
|
-
budget: { maxUsd: budgetUsd },
|
|
296
|
-
quotas: {
|
|
297
|
-
maxSpendUsd: budgetUsd,
|
|
298
|
-
maxDurationSeconds: 3600,
|
|
299
|
-
idleTimeoutSeconds: 900,
|
|
300
|
-
maxCommands: 200,
|
|
301
|
-
maxOpenPorts: 4
|
|
302
|
-
},
|
|
303
|
-
metadata: { source: "openpond-sdk-work", ...input.metadata }
|
|
304
|
-
},
|
|
305
|
-
{ async: true }
|
|
306
|
-
);
|
|
307
|
-
return this.#waitUntilRunning(created.id, input.signal);
|
|
308
|
-
}
|
|
309
|
-
async #waitUntilRunning(sandboxId, signal) {
|
|
310
|
-
const deadline = Date.now() + 12 * 6e4;
|
|
311
|
-
let sandbox = await this.#sandboxes.get(sandboxId);
|
|
312
|
-
while (Date.now() < deadline) {
|
|
313
|
-
signal?.throwIfAborted();
|
|
314
|
-
if (sandbox.state === "running") return sandbox;
|
|
315
|
-
if (sandbox.state === "error" || sandbox.state === "deleted") {
|
|
316
|
-
throw new Error(
|
|
317
|
-
`Sandbox ${sandbox.id} entered ${sandbox.state}${sandbox.logs.length ? `: ${sandbox.logs.join("\n")}` : ""}`
|
|
318
|
-
);
|
|
319
|
-
}
|
|
320
|
-
await sleep(2e3, signal);
|
|
321
|
-
sandbox = await this.#sandboxes.get(sandboxId);
|
|
322
|
-
}
|
|
323
|
-
throw new Error(`Sandbox ${sandboxId} did not become ready before timeout`);
|
|
324
|
-
}
|
|
325
|
-
async #executeTool(sandboxId, toolCall, index, timeoutSeconds, emit) {
|
|
326
|
-
const toolCallId = toolCall.id || `work_tool_${index}`;
|
|
327
|
-
const name = toolCall.function?.name;
|
|
328
|
-
if (name !== "run_command") {
|
|
329
|
-
return toolMessage(toolCallId, { error: `Unknown tool: ${name ?? "missing"}` });
|
|
330
|
-
}
|
|
331
|
-
let args;
|
|
332
|
-
try {
|
|
333
|
-
args = JSON.parse(toolCall.function?.arguments || "{}");
|
|
334
|
-
} catch (error) {
|
|
335
|
-
return toolMessage(toolCallId, { error: `Invalid tool arguments: ${errorMessage(error)}` });
|
|
336
|
-
}
|
|
337
|
-
const command = typeof args.command === "string" ? args.command.trim() : "";
|
|
338
|
-
if (!command) return toolMessage(toolCallId, { error: "command is required" });
|
|
339
|
-
if (command.length > MAX_WORK_COMMAND_CHARS) {
|
|
340
|
-
const output = `command exceeds the ${MAX_WORK_COMMAND_CHARS} character limit`;
|
|
341
|
-
await emit({ type: "tool", toolCallId, command, status: "failed", output });
|
|
342
|
-
return toolMessage(toolCallId, { status: "failed", error: output });
|
|
343
|
-
}
|
|
344
|
-
await emit({ type: "tool", toolCallId, command, status: "started" });
|
|
345
|
-
try {
|
|
346
|
-
const response = await this.#sandboxes.exec(sandboxId, {
|
|
347
|
-
command,
|
|
348
|
-
timeoutSeconds: boundedInteger(timeoutSeconds, 1, 900, 180)
|
|
349
|
-
});
|
|
350
|
-
const output = truncate(response.command.output, MAX_TOOL_OUTPUT_CHARS);
|
|
351
|
-
const status = response.command.status === "succeeded" ? "succeeded" : "failed";
|
|
352
|
-
await emit({
|
|
353
|
-
type: "tool",
|
|
354
|
-
toolCallId,
|
|
355
|
-
command,
|
|
356
|
-
status,
|
|
357
|
-
output,
|
|
358
|
-
exitCode: response.command.exitCode
|
|
359
|
-
});
|
|
360
|
-
return toolMessage(toolCallId, {
|
|
361
|
-
status: response.command.status,
|
|
362
|
-
exitCode: response.command.exitCode,
|
|
363
|
-
output
|
|
364
|
-
});
|
|
365
|
-
} catch (error) {
|
|
366
|
-
if (error instanceof OpenPondApiError) throw error;
|
|
367
|
-
const output = errorMessage(error);
|
|
368
|
-
await emit({ type: "tool", toolCallId, command, status: "failed", output });
|
|
369
|
-
return toolMessage(toolCallId, { status: "failed", error: output });
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
};
|
|
373
|
-
var WORK_TOOLS = [
|
|
374
|
-
{
|
|
375
|
-
type: "function",
|
|
376
|
-
function: {
|
|
377
|
-
name: "run_command",
|
|
378
|
-
description: "Run a shell command inside the persistent OpenPond sandbox. Use standard shell tools to inspect, edit, build, and test files. Commands start in the repository workspace.",
|
|
379
|
-
parameters: {
|
|
380
|
-
type: "object",
|
|
381
|
-
additionalProperties: false,
|
|
382
|
-
properties: {
|
|
383
|
-
command: {
|
|
384
|
-
type: "string",
|
|
385
|
-
minLength: 1,
|
|
386
|
-
maxLength: MAX_WORK_COMMAND_CHARS,
|
|
387
|
-
description: "Shell command to execute."
|
|
388
|
-
}
|
|
389
|
-
},
|
|
390
|
-
required: ["command"]
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
];
|
|
395
|
-
function systemPrompt(sandboxId, hasInputs) {
|
|
396
|
-
return [
|
|
397
|
-
"You are OpenPond Work, a careful coding agent operating in an isolated Linux sandbox.",
|
|
398
|
-
`The active sandbox is ${sandboxId}.`,
|
|
399
|
-
...hasInputs ? [
|
|
400
|
-
`Caller-provided durable files are staged under ${WORK_INPUT_DIRECTORY}; structured metadata is in ${WORK_INPUT_MANIFEST}.`
|
|
401
|
-
] : [],
|
|
402
|
-
"Use run_command to inspect the workspace, edit files, and validate your work.",
|
|
403
|
-
`Place completed user-facing files in ${WORK_OUTPUT_DIRECTORY}. The runtime collects new and revised files there automatically when the turn completes.`,
|
|
404
|
-
"Do the requested work completely. Preserve existing user changes and avoid destructive commands.",
|
|
405
|
-
"Keep the user informed with concise prose, but call tools whenever verification or file changes are needed.",
|
|
406
|
-
"Before finishing, run relevant tests and summarize the concrete result."
|
|
407
|
-
].join("\n");
|
|
408
|
-
}
|
|
409
|
-
function initialLifecycle(cleanupPolicy) {
|
|
410
|
-
return {
|
|
411
|
-
cleanupPolicy,
|
|
412
|
-
persistence: {
|
|
413
|
-
status: "not_requested",
|
|
414
|
-
outputCount: 0,
|
|
415
|
-
persistedCount: 0
|
|
416
|
-
},
|
|
417
|
-
cleanup: { status: "not_requested" }
|
|
418
|
-
};
|
|
419
|
-
}
|
|
420
|
-
function lazyOutputDownload(sandboxes, sandboxId, output) {
|
|
421
|
-
let pending = null;
|
|
422
|
-
return () => {
|
|
423
|
-
pending ??= sandboxes.downloadFileResponse(sandboxId, {
|
|
424
|
-
path: output.path,
|
|
425
|
-
maxBytes: Math.max(1, output.sizeBytes)
|
|
426
|
-
}).then((response) => {
|
|
427
|
-
const decodedBytes = Buffer.byteLength(
|
|
428
|
-
response.file.contentsBase64,
|
|
429
|
-
"base64"
|
|
430
|
-
);
|
|
431
|
-
if (response.file.truncated || response.file.returnedBytes !== response.file.totalSizeBytes || decodedBytes !== output.sizeBytes) {
|
|
432
|
-
throw new Error(`Output download was incomplete for ${output.name}`);
|
|
433
|
-
}
|
|
434
|
-
return response;
|
|
435
|
-
});
|
|
436
|
-
return pending;
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
function uniqueInputName(input, index, usedNames) {
|
|
440
|
-
const safeId = input.id.replace(/[^a-zA-Z0-9._-]+/g, "-").slice(0, 80) || `input-${index + 1}`;
|
|
441
|
-
const safeName = input.name.replace(/[^a-zA-Z0-9._-]+/g, "-").slice(-120) || "file";
|
|
442
|
-
const base = `${safeId}-${safeName}`;
|
|
443
|
-
let candidate = base;
|
|
444
|
-
let collision = 1;
|
|
445
|
-
while (usedNames.has(candidate)) {
|
|
446
|
-
collision += 1;
|
|
447
|
-
candidate = `${base}-${collision}`;
|
|
448
|
-
}
|
|
449
|
-
usedNames.add(candidate);
|
|
450
|
-
return candidate;
|
|
451
|
-
}
|
|
452
|
-
function attachWorkFailure(error, lifecycle, finalizationError) {
|
|
453
|
-
if (!error || typeof error !== "object") return;
|
|
454
|
-
Object.assign(error, {
|
|
455
|
-
workLifecycle: lifecycle,
|
|
456
|
-
...finalizationError ? { workFinalizationError: errorMessage(finalizationError) } : {}
|
|
457
|
-
});
|
|
458
|
-
}
|
|
459
|
-
function outputSignatures(files) {
|
|
460
|
-
return new Map(files.map((file) => [file.path, outputSignature(file)]));
|
|
461
|
-
}
|
|
462
|
-
function outputSignature(file) {
|
|
463
|
-
return `${file.sizeBytes}:${file.updatedAt}`;
|
|
464
|
-
}
|
|
465
|
-
function workOutputFromFile(file) {
|
|
466
|
-
const name = normalizedOutputPath(file.path).split("/").at(-1) || file.path;
|
|
467
|
-
const mimeType = workOutputMimeType(name);
|
|
468
|
-
return {
|
|
469
|
-
path: file.path,
|
|
470
|
-
name,
|
|
471
|
-
mimeType,
|
|
472
|
-
sizeBytes: file.sizeBytes,
|
|
473
|
-
updatedAt: file.updatedAt,
|
|
474
|
-
isBinary: file.isBinary ?? null,
|
|
475
|
-
previewable: file.previewable ?? (mimeType.startsWith("image/") || mimeType === "application/pdf" || mimeType.startsWith("text/"))
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
function normalizedOutputPath(value) {
|
|
479
|
-
return value.replaceAll("\\", "/");
|
|
480
|
-
}
|
|
481
|
-
function workOutputMimeType(name) {
|
|
482
|
-
const extension = name.toLowerCase().match(/\.[^.]+$/)?.[0] ?? "";
|
|
483
|
-
return WORK_OUTPUT_MIME_TYPES[extension] ?? "application/octet-stream";
|
|
484
|
-
}
|
|
485
|
-
var WORK_OUTPUT_MIME_TYPES = Object.freeze({
|
|
486
|
-
".avif": "image/avif",
|
|
487
|
-
".csv": "text/csv",
|
|
488
|
-
".docx": "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
489
|
-
".gif": "image/gif",
|
|
490
|
-
".html": "text/html",
|
|
491
|
-
".jpeg": "image/jpeg",
|
|
492
|
-
".jpg": "image/jpeg",
|
|
493
|
-
".json": "application/json",
|
|
494
|
-
".m4a": "audio/mp4",
|
|
495
|
-
".md": "text/markdown",
|
|
496
|
-
".mov": "video/quicktime",
|
|
497
|
-
".mp3": "audio/mpeg",
|
|
498
|
-
".mp4": "video/mp4",
|
|
499
|
-
".pdf": "application/pdf",
|
|
500
|
-
".png": "image/png",
|
|
501
|
-
".pptx": "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
502
|
-
".svg": "image/svg+xml",
|
|
503
|
-
".tsv": "text/tab-separated-values",
|
|
504
|
-
".txt": "text/plain",
|
|
505
|
-
".wav": "audio/wav",
|
|
506
|
-
".webm": "video/webm",
|
|
507
|
-
".webp": "image/webp",
|
|
508
|
-
".xlsx": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
509
|
-
});
|
|
510
|
-
function toolMessage(toolCallId, payload) {
|
|
511
|
-
return { role: "tool", tool_call_id: toolCallId, content: JSON.stringify(payload) };
|
|
512
|
-
}
|
|
513
|
-
function boundedInteger(value, minimum, maximum, fallback) {
|
|
514
|
-
if (!Number.isFinite(value)) return fallback;
|
|
515
|
-
return Math.min(maximum, Math.max(minimum, Math.floor(value)));
|
|
516
|
-
}
|
|
517
|
-
function truncate(value, maximum) {
|
|
518
|
-
if (value.length <= maximum) return value;
|
|
519
|
-
return `${value.slice(0, maximum)}
|
|
520
|
-
\u2026 output truncated by openpond-sdk`;
|
|
521
|
-
}
|
|
522
|
-
function errorMessage(error) {
|
|
523
|
-
return error instanceof Error ? error.message : String(error);
|
|
524
|
-
}
|
|
525
|
-
function sleep(milliseconds, signal) {
|
|
526
|
-
return new Promise((resolve, reject) => {
|
|
527
|
-
if (signal?.aborted) {
|
|
528
|
-
reject(signal.reason);
|
|
529
|
-
return;
|
|
530
|
-
}
|
|
531
|
-
const timer = setTimeout(resolve, milliseconds);
|
|
532
|
-
timer.unref?.();
|
|
533
|
-
signal?.addEventListener(
|
|
534
|
-
"abort",
|
|
535
|
-
() => {
|
|
536
|
-
clearTimeout(timer);
|
|
537
|
-
reject(signal.reason);
|
|
538
|
-
},
|
|
539
|
-
{ once: true }
|
|
540
|
-
);
|
|
541
|
-
});
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
// ../../packages/sdk/src/project-actions.ts
|
|
545
|
-
import { promises as fs } from "node:fs";
|
|
546
|
-
var OpenPondProjectActionsClient = class {
|
|
547
|
-
#apiKey;
|
|
548
|
-
#apiBaseUrl;
|
|
549
|
-
constructor(input) {
|
|
550
|
-
this.#apiKey = input.apiKey;
|
|
551
|
-
this.#apiBaseUrl = input.apiBaseUrl.replace(/\/+$/, "");
|
|
552
|
-
}
|
|
553
|
-
async list(input) {
|
|
554
|
-
const response = await apiFetch(
|
|
555
|
-
this.#apiBaseUrl,
|
|
556
|
-
this.#apiKey,
|
|
557
|
-
projectActionPath(input.projectId, "releases", input.teamId)
|
|
558
|
-
);
|
|
559
|
-
return (await readApiJson(response, "List Project Action releases")).releases;
|
|
560
|
-
}
|
|
561
|
-
async catalog(input) {
|
|
562
|
-
const response = await apiFetch(
|
|
563
|
-
this.#apiBaseUrl,
|
|
564
|
-
this.#apiKey,
|
|
565
|
-
projectActionPath(input.projectId, "catalog", input.teamId)
|
|
566
|
-
);
|
|
567
|
-
return (await readApiJson(response, "Get Project Action catalog")).catalog;
|
|
568
|
-
}
|
|
569
|
-
async publish(input) {
|
|
570
|
-
const [bundle, runner] = await Promise.all([
|
|
571
|
-
fs.readFile(input.build.bundlePath),
|
|
572
|
-
fs.readFile(input.build.runnerPath)
|
|
573
|
-
]);
|
|
574
|
-
const response = await apiFetch(
|
|
575
|
-
this.#apiBaseUrl,
|
|
576
|
-
this.#apiKey,
|
|
577
|
-
projectActionPath(input.projectId, "releases", input.teamId),
|
|
578
|
-
{
|
|
579
|
-
method: "POST",
|
|
580
|
-
body: JSON.stringify({
|
|
581
|
-
sourceRef: input.sourceRef,
|
|
582
|
-
sourceCommitSha: input.sourceCommitSha,
|
|
583
|
-
bundleBase64: bundle.toString("base64"),
|
|
584
|
-
runnerBase64: runner.toString("base64"),
|
|
585
|
-
registry: input.build.registry,
|
|
586
|
-
manifest: input.build.manifest,
|
|
587
|
-
metadata: input.metadata
|
|
588
|
-
})
|
|
589
|
-
}
|
|
590
|
-
);
|
|
591
|
-
return (await readApiJson(response, "Publish Project Actions")).release;
|
|
592
|
-
}
|
|
593
|
-
async run(input) {
|
|
594
|
-
const response = await apiFetch(
|
|
595
|
-
this.#apiBaseUrl,
|
|
596
|
-
this.#apiKey,
|
|
597
|
-
projectActionPath(input.projectId, `actions/${encodeURIComponent(input.actionId)}`, input.teamId),
|
|
598
|
-
{
|
|
599
|
-
method: "POST",
|
|
600
|
-
body: JSON.stringify({
|
|
601
|
-
input: input.value ?? {},
|
|
602
|
-
releaseId: input.releaseId,
|
|
603
|
-
idempotencyKey: input.idempotencyKey,
|
|
604
|
-
callerType: input.callerType ?? "sdk",
|
|
605
|
-
callerId: input.callerId
|
|
606
|
-
}),
|
|
607
|
-
signal: input.signal,
|
|
608
|
-
timeoutMs: 15 * 60 * 1e3
|
|
609
|
-
}
|
|
610
|
-
);
|
|
611
|
-
return (await readApiJson(response, "Run Project Action")).invocation;
|
|
612
|
-
}
|
|
613
|
-
};
|
|
614
|
-
function projectActionPath(projectId, suffix, teamId) {
|
|
615
|
-
return `/v1/project-actions/${encodeURIComponent(projectId)}/${suffix}?teamId=${encodeURIComponent(teamId)}`;
|
|
616
|
-
}
|
|
617
|
-
|
|
618
|
-
// ../../packages/sdk/src/profile-actions.ts
|
|
619
|
-
var OpenPondProfileActionsClient = class {
|
|
620
|
-
#apiKey;
|
|
621
|
-
#apiBaseUrl;
|
|
622
|
-
constructor(input) {
|
|
623
|
-
this.#apiKey = input.apiKey;
|
|
624
|
-
this.#apiBaseUrl = input.apiBaseUrl.replace(/\/+$/, "");
|
|
625
|
-
}
|
|
626
|
-
async catalog(input) {
|
|
627
|
-
const teamId = requiredValue(input.teamId, "teamId");
|
|
628
|
-
const search = new URLSearchParams({ teamId });
|
|
629
|
-
if (input.profileId?.trim()) search.set("profileId", input.profileId.trim());
|
|
630
|
-
if (input.profileName?.trim()) {
|
|
631
|
-
search.set("profileName", input.profileName.trim());
|
|
632
|
-
}
|
|
633
|
-
const response = await apiFetch(
|
|
634
|
-
this.#apiBaseUrl,
|
|
635
|
-
this.#apiKey,
|
|
636
|
-
`/v1/profile/actions?${search.toString()}`
|
|
637
|
-
);
|
|
638
|
-
return (await readApiJson(
|
|
639
|
-
response,
|
|
640
|
-
"Get Profile Action catalog"
|
|
641
|
-
)).catalog;
|
|
642
|
-
}
|
|
643
|
-
async run(input) {
|
|
644
|
-
const teamId = requiredValue(input.teamId, "teamId");
|
|
645
|
-
const actionKey = requiredValue(input.actionKey, "actionKey");
|
|
646
|
-
const idempotencyKey = requiredValue(input.idempotencyKey, "idempotencyKey");
|
|
647
|
-
const catalogVersion = requiredValue(input.catalogVersion, "catalogVersion");
|
|
648
|
-
const response = await apiFetch(
|
|
649
|
-
this.#apiBaseUrl,
|
|
650
|
-
this.#apiKey,
|
|
651
|
-
`/v1/profile/actions/run?${new URLSearchParams({ teamId }).toString()}`,
|
|
652
|
-
{
|
|
653
|
-
method: "POST",
|
|
654
|
-
headers: { "Content-Type": "application/json" },
|
|
655
|
-
body: JSON.stringify({
|
|
656
|
-
...input.profileId?.trim() ? { profileId: input.profileId.trim() } : {},
|
|
657
|
-
...input.profileName?.trim() ? { profileName: input.profileName.trim() } : {},
|
|
658
|
-
actionKey,
|
|
659
|
-
value: input.value ?? {},
|
|
660
|
-
conversationId: input.conversationId ?? null,
|
|
661
|
-
createConversation: input.createConversation,
|
|
662
|
-
conversationTitle: input.conversationTitle ?? null,
|
|
663
|
-
idempotencyKey,
|
|
664
|
-
catalogVersion,
|
|
665
|
-
externalCapabilityLeases: input.externalCapabilityLeases
|
|
666
|
-
})
|
|
667
|
-
}
|
|
668
|
-
);
|
|
669
|
-
return readApiJson(
|
|
670
|
-
response,
|
|
671
|
-
"Run Profile Action"
|
|
672
|
-
);
|
|
673
|
-
}
|
|
674
|
-
};
|
|
675
|
-
function requiredValue(value, name) {
|
|
676
|
-
const normalized = value.trim();
|
|
677
|
-
if (!normalized) throw new Error(`${name} is required`);
|
|
678
|
-
return normalized;
|
|
679
|
-
}
|
|
680
|
-
|
|
681
|
-
// ../../packages/sdk/src/workflows.ts
|
|
682
|
-
import { randomUUID } from "node:crypto";
|
|
683
|
-
var OpenPondWorkflowsClient = class {
|
|
684
|
-
#apiKey;
|
|
685
|
-
#apiBaseUrl;
|
|
686
|
-
constructor(input) {
|
|
687
|
-
this.#apiKey = input.apiKey;
|
|
688
|
-
this.#apiBaseUrl = input.apiBaseUrl.replace(/\/+$/, "");
|
|
689
|
-
}
|
|
690
|
-
async list(options = {}) {
|
|
691
|
-
return this.#request("", "List Workflows", {
|
|
692
|
-
signal: options.signal
|
|
693
|
-
});
|
|
694
|
-
}
|
|
695
|
-
async create(input, options = {}) {
|
|
696
|
-
return this.#request("", "Create Workflow", {
|
|
697
|
-
method: "POST",
|
|
698
|
-
body: JSON.stringify({
|
|
699
|
-
...input,
|
|
700
|
-
clientRequestId: input.clientRequestId?.trim() || randomUUID()
|
|
701
|
-
}),
|
|
702
|
-
signal: options.signal
|
|
703
|
-
});
|
|
704
|
-
}
|
|
705
|
-
async update(scheduleId, input, options = {}) {
|
|
706
|
-
return this.#request(
|
|
707
|
-
`/schedules/${encodeURIComponent(requiredId(scheduleId, "scheduleId"))}`,
|
|
708
|
-
"Update Workflow",
|
|
709
|
-
{
|
|
710
|
-
method: "PATCH",
|
|
711
|
-
body: JSON.stringify(input),
|
|
712
|
-
signal: options.signal
|
|
713
|
-
}
|
|
714
|
-
);
|
|
715
|
-
}
|
|
716
|
-
async delete(scheduleId, options = {}) {
|
|
717
|
-
return this.#request(
|
|
718
|
-
`/schedules/${encodeURIComponent(requiredId(scheduleId, "scheduleId"))}`,
|
|
719
|
-
"Delete Workflow",
|
|
720
|
-
{ method: "DELETE", signal: options.signal }
|
|
721
|
-
);
|
|
722
|
-
}
|
|
723
|
-
async runNow(scheduleId, input = {}, options = {}) {
|
|
724
|
-
return this.#request(
|
|
725
|
-
`/schedules/${encodeURIComponent(requiredId(scheduleId, "scheduleId"))}/run`,
|
|
726
|
-
"Run Workflow",
|
|
727
|
-
{
|
|
728
|
-
method: "POST",
|
|
729
|
-
body: JSON.stringify({
|
|
730
|
-
clientRequestId: input.clientRequestId?.trim() || randomUUID()
|
|
731
|
-
}),
|
|
732
|
-
signal: options.signal
|
|
733
|
-
}
|
|
734
|
-
);
|
|
735
|
-
}
|
|
736
|
-
async #request(suffix, label, options = {}) {
|
|
737
|
-
const response = await apiFetch(
|
|
738
|
-
this.#apiBaseUrl,
|
|
739
|
-
this.#apiKey,
|
|
740
|
-
`/v1/saved-work${suffix}`,
|
|
741
|
-
options
|
|
742
|
-
);
|
|
743
|
-
return readApiJson(response, label);
|
|
744
|
-
}
|
|
745
|
-
};
|
|
746
|
-
function requiredId(value, label) {
|
|
747
|
-
const normalized = value.trim();
|
|
748
|
-
if (!normalized) throw new Error(`${label} is required`);
|
|
749
|
-
return normalized;
|
|
750
|
-
}
|
|
751
|
-
|
|
752
|
-
// ../../node_modules/.pnpm/@openpond+harness@0.2.5/node_modules/@openpond/harness/dist/sha256.js
|
|
753
|
-
var INITIAL_STATE = new Uint32Array([
|
|
754
|
-
1779033703,
|
|
755
|
-
3144134277,
|
|
756
|
-
1013904242,
|
|
757
|
-
2773480762,
|
|
758
|
-
1359893119,
|
|
759
|
-
2600822924,
|
|
760
|
-
528734635,
|
|
761
|
-
1541459225
|
|
762
|
-
]);
|
|
763
|
-
var ROUND_CONSTANTS = new Uint32Array([
|
|
764
|
-
1116352408,
|
|
765
|
-
1899447441,
|
|
766
|
-
3049323471,
|
|
767
|
-
3921009573,
|
|
768
|
-
961987163,
|
|
769
|
-
1508970993,
|
|
770
|
-
2453635748,
|
|
771
|
-
2870763221,
|
|
772
|
-
3624381080,
|
|
773
|
-
310598401,
|
|
774
|
-
607225278,
|
|
775
|
-
1426881987,
|
|
776
|
-
1925078388,
|
|
777
|
-
2162078206,
|
|
778
|
-
2614888103,
|
|
779
|
-
3248222580,
|
|
780
|
-
3835390401,
|
|
781
|
-
4022224774,
|
|
782
|
-
264347078,
|
|
783
|
-
604807628,
|
|
784
|
-
770255983,
|
|
785
|
-
1249150122,
|
|
786
|
-
1555081692,
|
|
787
|
-
1996064986,
|
|
788
|
-
2554220882,
|
|
789
|
-
2821834349,
|
|
790
|
-
2952996808,
|
|
791
|
-
3210313671,
|
|
792
|
-
3336571891,
|
|
793
|
-
3584528711,
|
|
794
|
-
113926993,
|
|
795
|
-
338241895,
|
|
796
|
-
666307205,
|
|
797
|
-
773529912,
|
|
798
|
-
1294757372,
|
|
799
|
-
1396182291,
|
|
800
|
-
1695183700,
|
|
801
|
-
1986661051,
|
|
802
|
-
2177026350,
|
|
803
|
-
2456956037,
|
|
804
|
-
2730485921,
|
|
805
|
-
2820302411,
|
|
806
|
-
3259730800,
|
|
807
|
-
3345764771,
|
|
808
|
-
3516065817,
|
|
809
|
-
3600352804,
|
|
810
|
-
4094571909,
|
|
811
|
-
275423344,
|
|
812
|
-
430227734,
|
|
813
|
-
506948616,
|
|
814
|
-
659060556,
|
|
815
|
-
883997877,
|
|
816
|
-
958139571,
|
|
817
|
-
1322822218,
|
|
818
|
-
1537002063,
|
|
819
|
-
1747873779,
|
|
820
|
-
1955562222,
|
|
821
|
-
2024104815,
|
|
822
|
-
2227730452,
|
|
823
|
-
2361852424,
|
|
824
|
-
2428436474,
|
|
825
|
-
2756734187,
|
|
826
|
-
3204031479,
|
|
827
|
-
3329325298
|
|
828
|
-
]);
|
|
829
|
-
|
|
830
|
-
// ../../node_modules/.pnpm/@openpond+harness@0.2.5/node_modules/@openpond/harness/dist/common.js
|
|
831
|
-
var MAX_PORTABLE_PATH_BYTES = 2e3;
|
|
832
|
-
var MAX_PORTABLE_ASSET_BYTES = 25e7;
|
|
833
|
-
var ReleaseIdSchema = external_exports.string().trim().min(1).max(240);
|
|
834
|
-
var ReleaseHashSchema = external_exports.string().regex(/^[a-f0-9]{64}$/);
|
|
835
|
-
var ReleaseTimestampSchema = external_exports.string().datetime({ offset: true });
|
|
836
|
-
var MetadataSchema = external_exports.record(external_exports.string(), external_exports.unknown()).default({});
|
|
837
|
-
var ImmutableReleaseRefSchema = external_exports.object({
|
|
838
|
-
id: ReleaseIdSchema,
|
|
839
|
-
contentHash: ReleaseHashSchema
|
|
840
|
-
}).strict();
|
|
841
|
-
var ImmutableAssetRefSchema = external_exports.object({
|
|
842
|
-
id: ReleaseIdSchema,
|
|
843
|
-
path: external_exports.string().trim().min(1).max(MAX_PORTABLE_PATH_BYTES).refine(safeRelativePath),
|
|
844
|
-
contentHash: ReleaseHashSchema,
|
|
845
|
-
sizeBytes: external_exports.number().int().nonnegative().max(MAX_PORTABLE_ASSET_BYTES),
|
|
846
|
-
mediaType: external_exports.string().trim().min(1).max(200),
|
|
847
|
-
visibility: external_exports.enum(["policy", "verifier", "host_private"])
|
|
848
|
-
}).strict();
|
|
849
|
-
var ImmutableArtifactRefSchema = external_exports.object({
|
|
850
|
-
id: ReleaseIdSchema,
|
|
851
|
-
contentHash: ReleaseHashSchema,
|
|
852
|
-
mediaType: external_exports.string().trim().min(1).max(200).nullable().default(null),
|
|
853
|
-
sizeBytes: external_exports.number().int().nonnegative().max(MAX_PORTABLE_ASSET_BYTES).nullable().default(null)
|
|
854
|
-
}).strict();
|
|
855
|
-
var FailureClassSchema = external_exports.enum([
|
|
856
|
-
"policy_failure",
|
|
857
|
-
"grader_failure",
|
|
858
|
-
"environment_failure",
|
|
859
|
-
"infrastructure_failure",
|
|
860
|
-
"timeout",
|
|
861
|
-
"cancelled"
|
|
862
|
-
]);
|
|
863
|
-
function safeRelativePath(value) {
|
|
864
|
-
const normalized = value.replaceAll("\\", "/");
|
|
865
|
-
if (!normalized || normalized.startsWith("/") || normalized.includes("\0"))
|
|
866
|
-
return false;
|
|
867
|
-
return !normalized.split("/").some((part) => !part || part === "." || part === "..");
|
|
868
|
-
}
|
|
869
|
-
|
|
870
|
-
// ../../node_modules/.pnpm/@openpond+harness@0.2.5/node_modules/@openpond/harness/dist/refiner-profiles.js
|
|
871
|
-
var RefinerProposalRouteSchema = external_exports.enum(["memory", "prompt", "skill", "agent"]);
|
|
872
|
-
var RefinerExternalRouteSchema = external_exports.enum(["runtime", "product", "taskset", "training"]);
|
|
873
|
-
var RefinerReviewInstructionSchema = external_exports.object({
|
|
874
|
-
id: external_exports.string().trim().min(1).max(120).regex(/^[a-z0-9][a-z0-9._-]*$/),
|
|
875
|
-
text: external_exports.string().trim().min(1).max(1e4)
|
|
876
|
-
}).strict();
|
|
877
|
-
var RefinerReviewProfileSchema = external_exports.object({
|
|
878
|
-
schemaVersion: external_exports.literal("openpond.refinerReviewProfile.v1"),
|
|
879
|
-
id: external_exports.string().trim().min(1).max(120).regex(/^[a-z0-9][a-z0-9._-]*$/),
|
|
880
|
-
version: external_exports.string().trim().min(1).max(120),
|
|
881
|
-
name: external_exports.string().trim().min(1).max(200),
|
|
882
|
-
objective: external_exports.string().trim().min(1).max(1e4),
|
|
883
|
-
instructions: external_exports.array(RefinerReviewInstructionSchema).max(100),
|
|
884
|
-
allowedProposalRoutes: external_exports.array(RefinerProposalRouteSchema).max(4),
|
|
885
|
-
allowedExternalRoutes: external_exports.array(RefinerExternalRouteSchema).max(4)
|
|
886
|
-
}).strict().superRefine((profile, context) => {
|
|
887
|
-
const instructionIds = profile.instructions.map((instruction) => instruction.id);
|
|
888
|
-
if (new Set(instructionIds).size !== instructionIds.length) {
|
|
889
|
-
context.addIssue({ code: "custom", message: "instruction IDs must be unique", path: ["instructions"] });
|
|
890
|
-
}
|
|
891
|
-
if (new Set(profile.allowedProposalRoutes).size !== profile.allowedProposalRoutes.length) {
|
|
892
|
-
context.addIssue({ code: "custom", message: "proposal routes must be unique", path: ["allowedProposalRoutes"] });
|
|
893
|
-
}
|
|
894
|
-
if (new Set(profile.allowedExternalRoutes).size !== profile.allowedExternalRoutes.length) {
|
|
895
|
-
context.addIssue({ code: "custom", message: "external routes must be unique", path: ["allowedExternalRoutes"] });
|
|
896
|
-
}
|
|
897
|
-
});
|
|
898
|
-
var RefinerReleaseSchema = external_exports.object({
|
|
899
|
-
schemaVersion: external_exports.literal("openpond.refinerRelease.v1"),
|
|
900
|
-
id: external_exports.string().trim().min(1).max(240),
|
|
901
|
-
coreVersion: external_exports.string().trim().min(1).max(120),
|
|
902
|
-
coreHash: ReleaseHashSchema,
|
|
903
|
-
profile: RefinerReviewProfileSchema,
|
|
904
|
-
profileHash: ReleaseHashSchema,
|
|
905
|
-
composedPromptHash: ReleaseHashSchema,
|
|
906
|
-
createdAt: ReleaseTimestampSchema,
|
|
907
|
-
contentHash: ReleaseHashSchema
|
|
908
|
-
}).strict();
|
|
909
|
-
var RefinerBindingSchema = external_exports.object({
|
|
910
|
-
schemaVersion: external_exports.literal("openpond.refinerBinding.v1"),
|
|
911
|
-
channel: external_exports.literal("active"),
|
|
912
|
-
revision: external_exports.number().int().nonnegative(),
|
|
913
|
-
release: ImmutableReleaseRefSchema,
|
|
914
|
-
updatedAt: ReleaseTimestampSchema
|
|
915
|
-
}).strict();
|
|
916
|
-
var RefinerTransitionReceiptSchema = external_exports.object({
|
|
917
|
-
schemaVersion: external_exports.literal("openpond.refinerTransitionReceipt.v1"),
|
|
918
|
-
id: external_exports.string().trim().min(1).max(240),
|
|
919
|
-
operation: external_exports.enum(["initialize", "update", "activate", "rollback"]),
|
|
920
|
-
bindingChanged: external_exports.boolean(),
|
|
921
|
-
previousRelease: ImmutableReleaseRefSchema.nullable(),
|
|
922
|
-
nextRelease: ImmutableReleaseRefSchema,
|
|
923
|
-
actor: external_exports.string().trim().min(1).max(240),
|
|
924
|
-
reason: external_exports.string().trim().min(1).max(1e4),
|
|
925
|
-
authoringSkillHash: ReleaseHashSchema.nullable(),
|
|
926
|
-
validation: external_exports.object({ valid: external_exports.boolean(), messages: external_exports.array(external_exports.string().max(2e3)).max(100) }).strict(),
|
|
927
|
-
createdAt: ReleaseTimestampSchema,
|
|
928
|
-
contentHash: ReleaseHashSchema
|
|
929
|
-
}).strict();
|
|
930
|
-
|
|
931
|
-
// ../../node_modules/.pnpm/@openpond+harness@0.2.5/node_modules/@openpond/harness/dist/refiner.js
|
|
932
|
-
var RefinerNoActionDecisionSchema = external_exports.object({
|
|
933
|
-
schemaVersion: external_exports.literal("openpond.localHarnessRefinerDecision.v1"),
|
|
934
|
-
decision: external_exports.literal("no_action"),
|
|
935
|
-
reason: external_exports.string().trim().min(1).max(1e4)
|
|
936
|
-
}).strip();
|
|
937
|
-
var RefinerExternalRouteDecisionSchema = external_exports.object({
|
|
938
|
-
schemaVersion: external_exports.literal("openpond.localHarnessRefinerDecision.v1"),
|
|
939
|
-
decision: external_exports.literal("route"),
|
|
940
|
-
route: external_exports.enum(["runtime", "product", "taskset", "training"]),
|
|
941
|
-
summary: external_exports.string().trim().min(1).max(2e3),
|
|
942
|
-
expectedOutcome: external_exports.string().trim().min(1).max(1e4),
|
|
943
|
-
reason: external_exports.string().trim().min(1).max(1e4)
|
|
944
|
-
}).strip();
|
|
945
|
-
var RefinerProposalDecisionSchema = external_exports.object({
|
|
946
|
-
schemaVersion: external_exports.literal("openpond.localHarnessRefinerDecision.v1"),
|
|
947
|
-
decision: external_exports.literal("propose"),
|
|
948
|
-
route: external_exports.enum(["memory", "prompt", "skill", "agent"]),
|
|
949
|
-
operation: external_exports.enum(["create", "update", "delete"]),
|
|
950
|
-
target: external_exports.string().trim().min(1).max(2e3),
|
|
951
|
-
summary: external_exports.string().trim().min(1).max(2e3),
|
|
952
|
-
createContent: external_exports.string().min(1).max(2e4).nullable(),
|
|
953
|
-
find: external_exports.string().min(1).max(8e3).nullable(),
|
|
954
|
-
replace: external_exports.string().max(8e3).nullable(),
|
|
955
|
-
expectedOutcome: external_exports.string().trim().min(1).max(1e4),
|
|
956
|
-
reason: external_exports.string().trim().min(1).max(1e4)
|
|
957
|
-
}).strip().superRefine((decision, context) => {
|
|
958
|
-
if (decision.operation === "create" && (decision.createContent === null || decision.find !== null || decision.replace !== null)) {
|
|
959
|
-
context.addIssue({
|
|
960
|
-
code: "custom",
|
|
961
|
-
message: "create proposals require createContent and null find/replace",
|
|
962
|
-
path: ["createContent"]
|
|
963
|
-
});
|
|
964
|
-
}
|
|
965
|
-
if (decision.operation === "update" && (decision.createContent !== null || decision.find === null || decision.replace === null)) {
|
|
966
|
-
context.addIssue({
|
|
967
|
-
code: "custom",
|
|
968
|
-
message: "update proposals require one exact find/replace edit and null createContent",
|
|
969
|
-
path: ["find"]
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
if (decision.operation === "delete" && (decision.createContent !== null || decision.find !== null || decision.replace !== null)) {
|
|
973
|
-
context.addIssue({
|
|
974
|
-
code: "custom",
|
|
975
|
-
message: "delete proposals require null createContent/find/replace",
|
|
976
|
-
path: ["createContent"]
|
|
977
|
-
});
|
|
978
|
-
}
|
|
979
|
-
});
|
|
980
|
-
var LocalHarnessRefinerDecisionSchema = external_exports.discriminatedUnion("decision", [
|
|
981
|
-
RefinerNoActionDecisionSchema,
|
|
982
|
-
RefinerExternalRouteDecisionSchema,
|
|
983
|
-
RefinerProposalDecisionSchema
|
|
984
|
-
]);
|
|
985
|
-
var LocalHarnessRefinerDecisionV1Schema = LocalHarnessRefinerDecisionSchema;
|
|
986
|
-
var HarnessRefinerEvidenceBasisSchema = external_exports.object({
|
|
987
|
-
kind: external_exports.enum(["single_deterministic", "recurrent_independent"]),
|
|
988
|
-
supportingEvidenceIds: external_exports.array(external_exports.string().trim().min(1).max(2e3)).min(1).max(100),
|
|
989
|
-
counterevidence: external_exports.array(external_exports.string().trim().min(1).max(2e3)).max(20)
|
|
990
|
-
}).strict().superRefine((basis, context) => {
|
|
991
|
-
if (new Set(basis.supportingEvidenceIds).size !== basis.supportingEvidenceIds.length) {
|
|
992
|
-
context.addIssue({
|
|
993
|
-
code: "custom",
|
|
994
|
-
message: "supporting evidence IDs must be unique",
|
|
995
|
-
path: ["supportingEvidenceIds"]
|
|
996
|
-
});
|
|
997
|
-
}
|
|
998
|
-
if (basis.kind === "recurrent_independent" && basis.supportingEvidenceIds.length < 2) {
|
|
999
|
-
context.addIssue({
|
|
1000
|
-
code: "custom",
|
|
1001
|
-
message: "recurrent independent evidence requires at least two supplied incidents",
|
|
1002
|
-
path: ["supportingEvidenceIds"]
|
|
1003
|
-
});
|
|
1004
|
-
}
|
|
1005
|
-
});
|
|
1006
|
-
var RefinerNoActionDecisionV2Schema = external_exports.object({
|
|
1007
|
-
schemaVersion: external_exports.literal("openpond.localHarnessRefinerDecision.v2"),
|
|
1008
|
-
decision: external_exports.literal("no_action"),
|
|
1009
|
-
reason: external_exports.string().trim().min(1).max(1e4)
|
|
1010
|
-
}).strict();
|
|
1011
|
-
var RefinerExternalRouteDecisionV2Schema = external_exports.object({
|
|
1012
|
-
schemaVersion: external_exports.literal("openpond.localHarnessRefinerDecision.v2"),
|
|
1013
|
-
decision: external_exports.literal("route"),
|
|
1014
|
-
route: external_exports.enum(["runtime", "product", "taskset", "training"]),
|
|
1015
|
-
summary: external_exports.string().trim().min(1).max(2e3),
|
|
1016
|
-
evidenceBasis: HarnessRefinerEvidenceBasisSchema,
|
|
1017
|
-
expectedOutcome: external_exports.string().trim().min(1).max(1e4),
|
|
1018
|
-
reason: external_exports.string().trim().min(1).max(1e4)
|
|
1019
|
-
}).strict();
|
|
1020
|
-
var RefinerProposalDecisionV2Schema = external_exports.object({
|
|
1021
|
-
schemaVersion: external_exports.literal("openpond.localHarnessRefinerDecision.v2"),
|
|
1022
|
-
decision: external_exports.literal("propose"),
|
|
1023
|
-
route: external_exports.enum(["memory", "prompt", "skill", "agent"]),
|
|
1024
|
-
operation: external_exports.enum(["create", "update", "delete"]),
|
|
1025
|
-
target: external_exports.string().trim().min(1).max(2e3),
|
|
1026
|
-
summary: external_exports.string().trim().min(1).max(2e3),
|
|
1027
|
-
evidenceBasis: HarnessRefinerEvidenceBasisSchema,
|
|
1028
|
-
createContent: external_exports.string().min(1).max(2e4).nullable(),
|
|
1029
|
-
find: external_exports.string().min(1).max(8e3).nullable(),
|
|
1030
|
-
replace: external_exports.string().max(8e3).nullable(),
|
|
1031
|
-
expectedOutcome: external_exports.string().trim().min(1).max(1e4),
|
|
1032
|
-
reason: external_exports.string().trim().min(1).max(1e4)
|
|
1033
|
-
}).strict().superRefine((decision, context) => {
|
|
1034
|
-
if (decision.operation === "create" && (decision.createContent === null || decision.find !== null || decision.replace !== null)) {
|
|
1035
|
-
context.addIssue({
|
|
1036
|
-
code: "custom",
|
|
1037
|
-
message: "create proposals require createContent and null find/replace",
|
|
1038
|
-
path: ["createContent"]
|
|
1039
|
-
});
|
|
1040
|
-
}
|
|
1041
|
-
if (decision.operation === "update" && (decision.createContent !== null || decision.find === null || decision.replace === null)) {
|
|
1042
|
-
context.addIssue({
|
|
1043
|
-
code: "custom",
|
|
1044
|
-
message: "update proposals require one exact find/replace edit and null createContent",
|
|
1045
|
-
path: ["find"]
|
|
1046
|
-
});
|
|
1047
|
-
}
|
|
1048
|
-
if (decision.operation === "delete" && (decision.createContent !== null || decision.find !== null || decision.replace !== null)) {
|
|
1049
|
-
context.addIssue({
|
|
1050
|
-
code: "custom",
|
|
1051
|
-
message: "delete proposals require null createContent/find/replace",
|
|
1052
|
-
path: ["createContent"]
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
});
|
|
1056
|
-
var LocalHarnessRefinerDecisionV2Schema = external_exports.discriminatedUnion("decision", [
|
|
1057
|
-
RefinerNoActionDecisionV2Schema,
|
|
1058
|
-
RefinerExternalRouteDecisionV2Schema,
|
|
1059
|
-
RefinerProposalDecisionV2Schema
|
|
1060
|
-
]);
|
|
1061
|
-
var LocalHarnessRefinerDecisionAnySchema = external_exports.union([
|
|
1062
|
-
LocalHarnessRefinerDecisionV1Schema,
|
|
1063
|
-
LocalHarnessRefinerDecisionV2Schema
|
|
1064
|
-
]);
|
|
1065
|
-
var HarnessRefinerCapabilitiesSchema = external_exports.object({
|
|
1066
|
-
memory: external_exports.boolean(),
|
|
1067
|
-
prompt: external_exports.boolean(),
|
|
1068
|
-
skill: external_exports.boolean(),
|
|
1069
|
-
agent: external_exports.boolean()
|
|
1070
|
-
}).strict();
|
|
1071
|
-
var SourceKindSchema = external_exports.enum(["memory", "instruction", "skill", "agent"]);
|
|
1072
|
-
var RefinerSourceFileSchema = external_exports.object({
|
|
1073
|
-
path: external_exports.string().trim().min(1).max(2e3),
|
|
1074
|
-
kind: SourceKindSchema,
|
|
1075
|
-
content: external_exports.string().max(6e4),
|
|
1076
|
-
loaded: external_exports.boolean()
|
|
1077
|
-
}).strict();
|
|
1078
|
-
var RefinerSourceCatalogEntrySchema = external_exports.object({
|
|
1079
|
-
path: external_exports.string().trim().min(1).max(2e3),
|
|
1080
|
-
kind: SourceKindSchema,
|
|
1081
|
-
loaded: external_exports.boolean()
|
|
1082
|
-
}).strict();
|
|
1083
|
-
var LocalHarnessRefinerEvidenceSchema = external_exports.object({
|
|
1084
|
-
capabilities: HarnessRefinerCapabilitiesSchema,
|
|
1085
|
-
trigger: external_exports.record(external_exports.string(), external_exports.unknown()),
|
|
1086
|
-
observations: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).max(20),
|
|
1087
|
-
admissibleEvidenceIds: external_exports.array(external_exports.string().trim().min(1).max(2e3)).max(1e4),
|
|
1088
|
-
reviewPacket: external_exports.object({
|
|
1089
|
-
currentTurn: external_exports.object({
|
|
1090
|
-
id: external_exports.string().trim().min(1).max(2e3),
|
|
1091
|
-
status: external_exports.string().trim().min(1).max(100).nullable(),
|
|
1092
|
-
error: external_exports.string().max(2100).nullable(),
|
|
1093
|
-
prompt: external_exports.string().max(8100).nullable(),
|
|
1094
|
-
assistantOutput: external_exports.string().max(8100).nullable(),
|
|
1095
|
-
assistantOutputLinkCount: external_exports.number().int().nonnegative()
|
|
1096
|
-
}).strict(),
|
|
1097
|
-
priorConversation: external_exports.array(external_exports.object({
|
|
1098
|
-
turnId: external_exports.string().trim().min(1).max(2e3),
|
|
1099
|
-
status: external_exports.string().trim().min(1).max(100).nullable(),
|
|
1100
|
-
prompt: external_exports.string().max(3100).nullable(),
|
|
1101
|
-
assistantOutput: external_exports.string().max(3100).nullable()
|
|
1102
|
-
}).strict()).max(3),
|
|
1103
|
-
timeline: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).max(60),
|
|
1104
|
-
artifacts: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).max(30),
|
|
1105
|
-
artifactDiagnostics: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).max(20),
|
|
1106
|
-
executionProfile: external_exports.object({
|
|
1107
|
-
modelRequestCount: external_exports.number().int().nonnegative(),
|
|
1108
|
-
failedModelRequestCount: external_exports.number().int().nonnegative(),
|
|
1109
|
-
promptTokens: external_exports.number().int().nonnegative(),
|
|
1110
|
-
completionTokens: external_exports.number().int().nonnegative(),
|
|
1111
|
-
totalTokens: external_exports.number().int().nonnegative(),
|
|
1112
|
-
toolFailureCount: external_exports.number().int().nonnegative(),
|
|
1113
|
-
retryCount: external_exports.number().int().nonnegative(),
|
|
1114
|
-
recoveryCount: external_exports.number().int().nonnegative()
|
|
1115
|
-
}).strict(),
|
|
1116
|
-
priorIncidents: external_exports.array(external_exports.record(external_exports.string(), external_exports.unknown())).max(3),
|
|
1117
|
-
truncation: external_exports.object({
|
|
1118
|
-
timelineEventCount: external_exports.number().int().nonnegative(),
|
|
1119
|
-
includedTimelineEventCount: external_exports.number().int().nonnegative(),
|
|
1120
|
-
timelineTruncated: external_exports.boolean()
|
|
1121
|
-
}).strict()
|
|
1122
|
-
}).strict(),
|
|
1123
|
-
runtimeActivation: external_exports.object({
|
|
1124
|
-
admittedRelease: ImmutableReleaseRefSchema,
|
|
1125
|
-
currentRelease: ImmutableReleaseRefSchema,
|
|
1126
|
-
rebasedOntoCurrent: external_exports.boolean(),
|
|
1127
|
-
admittedSourceFiles: external_exports.array(RefinerSourceFileSchema).max(100),
|
|
1128
|
-
admittedSourceCatalog: external_exports.array(RefinerSourceCatalogEntrySchema).max(1e3)
|
|
1129
|
-
}).strict(),
|
|
1130
|
-
sourceFiles: external_exports.array(RefinerSourceFileSchema).max(100),
|
|
1131
|
-
sourceCatalog: external_exports.array(RefinerSourceCatalogEntrySchema).max(1e3),
|
|
1132
|
-
additionalEvidence: external_exports.unknown().nullable().optional()
|
|
1133
|
-
}).strict();
|
|
1134
|
-
var OverlayRefSchema = external_exports.object({
|
|
1135
|
-
id: external_exports.string().trim().min(1).max(240),
|
|
1136
|
-
revision: external_exports.number().int().nonnegative(),
|
|
1137
|
-
contentHash: ReleaseHashSchema
|
|
1138
|
-
}).strict();
|
|
1139
|
-
var HostedHarnessRefinerRequestSchema = external_exports.object({
|
|
1140
|
-
schemaVersion: external_exports.literal("openpond.hostedHarnessRefinerRequest.v2"),
|
|
1141
|
-
requestId: external_exports.string().trim().min(1).max(240),
|
|
1142
|
-
idempotencyKey: external_exports.string().trim().min(1).max(240),
|
|
1143
|
-
evidenceHash: ReleaseHashSchema,
|
|
1144
|
-
harness: external_exports.object({
|
|
1145
|
-
admittedRelease: ImmutableReleaseRefSchema,
|
|
1146
|
-
currentRelease: ImmutableReleaseRefSchema,
|
|
1147
|
-
overlay: OverlayRefSchema,
|
|
1148
|
-
workspace: external_exports.object({
|
|
1149
|
-
id: external_exports.string().trim().min(1).max(240),
|
|
1150
|
-
revision: external_exports.number().int().nonnegative(),
|
|
1151
|
-
sourceRevision: ReleaseHashSchema,
|
|
1152
|
-
channelRevision: external_exports.number().int().nonnegative()
|
|
1153
|
-
}).strict(),
|
|
1154
|
-
capabilities: HarnessRefinerCapabilitiesSchema
|
|
1155
|
-
}).strict(),
|
|
1156
|
-
evidence: LocalHarnessRefinerEvidenceSchema
|
|
1157
|
-
}).strict();
|
|
1158
|
-
var HostedHarnessRefinerUsageSchema = external_exports.object({
|
|
1159
|
-
promptTokens: external_exports.number().int().nonnegative(),
|
|
1160
|
-
completionTokens: external_exports.number().int().nonnegative(),
|
|
1161
|
-
totalTokens: external_exports.number().int().nonnegative()
|
|
1162
|
-
}).strict();
|
|
1163
|
-
var HostedHarnessRefinerResponseSchema = external_exports.object({
|
|
1164
|
-
schemaVersion: external_exports.literal("openpond.hostedHarnessRefinerResponse.v2"),
|
|
1165
|
-
requestId: external_exports.string().trim().min(1).max(240),
|
|
1166
|
-
evidenceHash: ReleaseHashSchema,
|
|
1167
|
-
admittedRelease: ImmutableReleaseRefSchema,
|
|
1168
|
-
currentRelease: ImmutableReleaseRefSchema,
|
|
1169
|
-
decision: LocalHarnessRefinerDecisionV2Schema,
|
|
1170
|
-
serviceRevision: external_exports.string().trim().min(1).max(240),
|
|
1171
|
-
usage: HostedHarnessRefinerUsageSchema
|
|
1172
|
-
}).strict();
|
|
1173
|
-
|
|
1174
|
-
// ../../packages/sdk/src/index.ts
|
|
1175
|
-
var OpenPondClient = class {
|
|
1176
|
-
sandboxes;
|
|
1177
|
-
work;
|
|
1178
|
-
workflows;
|
|
1179
|
-
actions;
|
|
1180
|
-
profileActions;
|
|
1181
|
-
constructor(options) {
|
|
1182
|
-
const apiKey = options.apiKey.trim();
|
|
1183
|
-
if (!apiKey) throw new Error("OpenPond API key is required");
|
|
1184
|
-
const apiBaseUrl = options.baseUrl?.trim() || "https://api.openpond.ai";
|
|
1185
|
-
this.sandboxes = createOpenPondSandboxClient({
|
|
1186
|
-
apiKey,
|
|
1187
|
-
baseUrl: apiBaseUrl,
|
|
1188
|
-
sandboxApiUrl: options.sandboxApiUrl
|
|
1189
|
-
});
|
|
1190
|
-
this.work = new OpenPondWorkClient({
|
|
1191
|
-
apiKey,
|
|
1192
|
-
apiBaseUrl,
|
|
1193
|
-
chatApiBaseUrl: options.chatApiUrl?.trim() || resolveOpChatApiBaseUrl({ apiBaseUrl, env: {} }),
|
|
1194
|
-
sandboxes: this.sandboxes
|
|
1195
|
-
});
|
|
1196
|
-
this.workflows = new OpenPondWorkflowsClient({ apiKey, apiBaseUrl });
|
|
1197
|
-
this.actions = new OpenPondProjectActionsClient({ apiKey, apiBaseUrl });
|
|
1198
|
-
this.profileActions = new OpenPondProfileActionsClient({ apiKey, apiBaseUrl });
|
|
1199
|
-
}
|
|
1200
|
-
};
|
|
1201
|
-
function createOpenPondClient(options) {
|
|
1202
|
-
return new OpenPondClient(options);
|
|
1203
|
-
}
|
|
1204
|
-
|
|
1205
|
-
export {
|
|
1206
|
-
createOpenPondClient
|
|
1207
|
-
};
|