openpond 0.0.30-bootstrap.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.
Files changed (193) hide show
  1. package/CHANGELOG.md +128 -0
  2. package/LICENSE +21 -0
  3. package/README.md +162 -0
  4. package/RELEASE.md +20 -0
  5. package/dist/api/core.d.ts +22 -0
  6. package/dist/api/deployments.d.ts +30 -0
  7. package/dist/api/types.d.ts +624 -0
  8. package/dist/api.d.ts +90 -0
  9. package/dist/cache.d.ts +22 -0
  10. package/dist/chunks/app-layer-YKXEQGOW.js +163 -0
  11. package/dist/chunks/apps-GGSIN2ZF.js +539 -0
  12. package/dist/chunks/chunk-3CC6MH35.js +1663 -0
  13. package/dist/chunks/chunk-3Y4EL3P6.js +1090 -0
  14. package/dist/chunks/chunk-4HYJG2JE.js +3875 -0
  15. package/dist/chunks/chunk-5G4E547X.js +294 -0
  16. package/dist/chunks/chunk-74O6FGVN.js +598 -0
  17. package/dist/chunks/chunk-AUJLPKGI.js +632 -0
  18. package/dist/chunks/chunk-BYAPLT37.js +744 -0
  19. package/dist/chunks/chunk-FUP7EGT7.js +1845 -0
  20. package/dist/chunks/chunk-I6HN3ZGW.js +88 -0
  21. package/dist/chunks/chunk-KRKGHVMQ.js +294 -0
  22. package/dist/chunks/chunk-LHYK6QO2.js +1300 -0
  23. package/dist/chunks/chunk-NLBKZZEK.js +224 -0
  24. package/dist/chunks/chunk-OG75GMVO.js +1 -0
  25. package/dist/chunks/chunk-Q57SVPEH.js +11663 -0
  26. package/dist/chunks/chunk-UACZUFIA.js +47 -0
  27. package/dist/chunks/chunk-VQX33YAG.js +5135 -0
  28. package/dist/chunks/chunk-W5GKHH77.js +168 -0
  29. package/dist/chunks/chunk-WYDVQOBL.js +17581 -0
  30. package/dist/chunks/chunk-XSAXENQD.js +4167 -0
  31. package/dist/chunks/chunk-Y6G6WRTG.js +210 -0
  32. package/dist/chunks/cli-NVKNE4AZ.js +11 -0
  33. package/dist/chunks/cli-X3HPLSOV.js +19 -0
  34. package/dist/chunks/core-commands-IM2UKLU4.js +41 -0
  35. package/dist/chunks/extend-YXCBULPO.js +84 -0
  36. package/dist/chunks/harness-GMK6IY2U.js +140 -0
  37. package/dist/chunks/help-LMH5FGT2.js +65 -0
  38. package/dist/chunks/opchat-BWXZ32GX.js +169 -0
  39. package/dist/chunks/organizations-4ISQRGMQ.js +738 -0
  40. package/dist/chunks/profile-NLDZDT3L.js +1110 -0
  41. package/dist/chunks/project-agent-ZPVO25HA.js +892 -0
  42. package/dist/chunks/sandbox-command-5GFJ2U3V.js +1652 -0
  43. package/dist/chunks/sandbox-template-LZN4F55Z.js +1646 -0
  44. package/dist/chunks/src-3RBI4DNN.js +3595 -0
  45. package/dist/chunks/src-EYXQS6XD.js +73427 -0
  46. package/dist/chunks/teams-bot-WP3FHKGA.js +137 -0
  47. package/dist/cli.js +77 -0
  48. package/dist/client-types.d.ts +222 -0
  49. package/dist/client.d.ts +19 -0
  50. package/dist/config.d.ts +184 -0
  51. package/dist/hosted-chat.d.ts +162 -0
  52. package/dist/index.d.ts +5 -0
  53. package/dist/index.js +25481 -0
  54. package/dist/indicators.d.ts +38 -0
  55. package/dist/opchat-smoke.d.ts +47 -0
  56. package/dist/private-json-file.d.ts +3 -0
  57. package/dist/profile/local-profile-types.d.ts +160 -0
  58. package/dist/profile/local-profile.d.ts +69 -0
  59. package/dist/profile/profile-catalog.d.ts +14 -0
  60. package/dist/profile/profile-git.d.ts +17 -0
  61. package/dist/profile/profile-promotion.d.ts +21 -0
  62. package/dist/profile/profile-setup-gate.d.ts +22 -0
  63. package/dist/profile/profile-skills.d.ts +30 -0
  64. package/dist/profile/profile-source-upload.d.ts +29 -0
  65. package/dist/profile/source-upload-cache.d.ts +29 -0
  66. package/dist/sandbox/async-request-options.d.ts +2 -0
  67. package/dist/sandbox/client-handles.d.ts +113 -0
  68. package/dist/sandbox/client.d.ts +348 -0
  69. package/dist/sandbox/runtime-handle.d.ts +36 -0
  70. package/dist/sandbox/sandbox-instance-client.d.ts +72 -0
  71. package/dist/sandbox/smoke.d.ts +3 -0
  72. package/dist/sandbox/stream.d.ts +7 -0
  73. package/dist/sandbox/types/billing.d.ts +176 -0
  74. package/dist/sandbox/types/client.d.ts +103 -0
  75. package/dist/sandbox/types/core.d.ts +140 -0
  76. package/dist/sandbox/types/index.d.ts +14 -0
  77. package/dist/sandbox/types/io.d.ts +240 -0
  78. package/dist/sandbox/types/microsoft-teams-bot.d.ts +51 -0
  79. package/dist/sandbox/types/org-project-agent.d.ts +610 -0
  80. package/dist/sandbox/types/record.d.ts +53 -0
  81. package/dist/sandbox/types/responses.d.ts +295 -0
  82. package/dist/sandbox/types/runtime-profiles.d.ts +15 -0
  83. package/dist/sandbox/types/runtime.d.ts +152 -0
  84. package/dist/sandbox/types/schedules.d.ts +141 -0
  85. package/dist/sandbox/types/snapshots.d.ts +205 -0
  86. package/dist/sandbox/types/workflow-modes.d.ts +1 -0
  87. package/dist/sandbox/types/workload-sources.d.ts +20 -0
  88. package/dist/sandbox/url.d.ts +2 -0
  89. package/dist/sandbox-template/manifest.d.ts +304 -0
  90. package/dist/sandbox-template/manifest.js +18381 -0
  91. package/dist/skills/openpond-cli/SKILL.md +49 -0
  92. package/dist/skills/openpond-desktop-harness/SKILL.md +113 -0
  93. package/dist/skills/openpond-desktop-harness/agents/openai.yaml +4 -0
  94. package/dist/skills/openpond-taskset-authoring/SKILL.md +38 -0
  95. package/dist/skills/openpond-taskset-authoring/references/graders-and-rewards.md +11 -0
  96. package/dist/skills/openpond-taskset-authoring/references/method-selection.md +12 -0
  97. package/dist/skills/openpond-taskset-authoring/references/privacy-and-provenance.md +8 -0
  98. package/dist/skills/openpond-taskset-authoring/references/task-design.md +13 -0
  99. package/dist/stream.d.ts +20 -0
  100. package/dist/types.d.ts +57 -0
  101. package/dist/urls.d.ts +4 -0
  102. package/dist/web/assets/AppsView-Bu-Nc3Ew.js +1 -0
  103. package/dist/web/assets/AppsView-DIhprTIC.css +1 -0
  104. package/dist/web/assets/BrowserSidebar-CCguQ-DR.js +1 -0
  105. package/dist/web/assets/BrowserSidebar-D9i7gQzw.css +1 -0
  106. package/dist/web/assets/CloudWorkView-DNoPIlMj.css +1 -0
  107. package/dist/web/assets/CloudWorkView-Dr3xqLE5.js +1 -0
  108. package/dist/web/assets/CommandMenu-CnodJFHD.js +1 -0
  109. package/dist/web/assets/CommandMenu-hNQCm8mw.css +1 -0
  110. package/dist/web/assets/CommunityView-CIbjNUZr.js +1 -0
  111. package/dist/web/assets/CommunityView-DSik4sd2.css +1 -0
  112. package/dist/web/assets/GetStartedView-C3ZrnEz5.css +1 -0
  113. package/dist/web/assets/GetStartedView-C8nyH_PT.js +1 -0
  114. package/dist/web/assets/LabsExtensions-GtJzxDnK.js +1 -0
  115. package/dist/web/assets/LabsProfile-DG7rWYur.js +1 -0
  116. package/dist/web/assets/LabsRoute-D6MDHBzq.js +2 -0
  117. package/dist/web/assets/LabsRoute-TEt9j1vB.css +1 -0
  118. package/dist/web/assets/LabsSignals-BfsDN86w.js +1 -0
  119. package/dist/web/assets/LabsSignals-D6iA6Ryl.css +1 -0
  120. package/dist/web/assets/NewProjectDialog-CaKiCoVS.js +1 -0
  121. package/dist/web/assets/ProfileSettingsSection-DTQS2DVL.css +1 -0
  122. package/dist/web/assets/ProfileSettingsSection-DxEzoF3K.js +1 -0
  123. package/dist/web/assets/ProfileView-CEscW7Ru.js +1 -0
  124. package/dist/web/assets/SettingsView-DwbGu8Kj.css +1 -0
  125. package/dist/web/assets/SettingsView-JIRR_FO4.js +63 -0
  126. package/dist/web/assets/TeamChatView-B5M1ThhJ.js +3 -0
  127. package/dist/web/assets/TeamChatView-Bx44q3WV.css +1 -0
  128. package/dist/web/assets/TerminalOverlay-C1iP4OS1.js +19 -0
  129. package/dist/web/assets/TerminalOverlay-DwBiZLwk.css +1 -0
  130. package/dist/web/assets/TrainingSettingsSection-BDYvI2te.js +1 -0
  131. package/dist/web/assets/TrainingView-CoCFK6W3.js +5 -0
  132. package/dist/web/assets/WorkspaceDiffPanel-CMxKQeo7.js +14 -0
  133. package/dist/web/assets/WorkspaceEnvironmentMenu-B8JJbwIz.js +32 -0
  134. package/dist/web/assets/WorkspaceEnvironmentMenu-DGIFdG3o.css +1 -0
  135. package/dist/web/assets/WorkspaceGitDialogs-B4sp9BGn.js +1 -0
  136. package/dist/web/assets/WorkspaceMonacoEditor-BBqimG5X.js +845 -0
  137. package/dist/web/assets/WorkspaceMonacoEditor-BwKcXIZw.css +1 -0
  138. package/dist/web/assets/boxes-DAaDUabq.js +1 -0
  139. package/dist/web/assets/codicon-ngg6Pgfi.ttf +0 -0
  140. package/dist/web/assets/css.worker-DBVD8oXr.js +93 -0
  141. package/dist/web/assets/cssMode-CBF1mieJ.js +1 -0
  142. package/dist/web/assets/dockerfile-BG73LgW2.js +1 -0
  143. package/dist/web/assets/editor.worker-CdQrwHl8.js +26 -0
  144. package/dist/web/assets/git-commit-horizontal-CAickXpN.js +1 -0
  145. package/dist/web/assets/git-dialogs-BZDqS1eT.css +1 -0
  146. package/dist/web/assets/html.worker-CwpTb9lJ.js +470 -0
  147. package/dist/web/assets/htmlMode-2u8OHtWO.js +1 -0
  148. package/dist/web/assets/index-BdY6A-YN.css +1 -0
  149. package/dist/web/assets/index-CU2qhUYV.js +195 -0
  150. package/dist/web/assets/index-Dz2B3-4C.js +1 -0
  151. package/dist/web/assets/info-CQNTh78o.js +1 -0
  152. package/dist/web/assets/json.worker-BoL8UZqY.js +58 -0
  153. package/dist/web/assets/jsonMode-C4CWXViX.js +7 -0
  154. package/dist/web/assets/lspLanguageFeatures-CBs_BOlB.js +4 -0
  155. package/dist/web/assets/markdown-BFxVWTOG.js +1 -0
  156. package/dist/web/assets/monaco.contribution-C1LUxAKf.js +2 -0
  157. package/dist/web/assets/monaco.contribution-Cpf6dWsh.js +2 -0
  158. package/dist/web/assets/monaco.contribution-lOXpG2xQ.js +2 -0
  159. package/dist/web/assets/monaco.contribution-sd3cFkcN.js +2 -0
  160. package/dist/web/assets/monitor-DsIswrMV.js +1 -0
  161. package/dist/web/assets/play-CeRw21NV.js +1 -0
  162. package/dist/web/assets/python-CXYq3BUl.js +1 -0
  163. package/dist/web/assets/refresh-cw-N5b_6AP5.js +1 -0
  164. package/dist/web/assets/reply-BSKjZrJg.js +1 -0
  165. package/dist/web/assets/save-D0oHH1a3.js +1 -0
  166. package/dist/web/assets/settings-lists-BEg6LMcy.css +1 -0
  167. package/dist/web/assets/shell-DiJ1NA_G.js +1 -0
  168. package/dist/web/assets/toggleHighContrast-B7NOMXDY.css +1 -0
  169. package/dist/web/assets/toggleHighContrast-DRjlcwes.js +62 -0
  170. package/dist/web/assets/training-model-data-BPrc68VG.js +1 -0
  171. package/dist/web/assets/ts.worker-BH9nVgjN.js +67718 -0
  172. package/dist/web/assets/tsMode-x-1A7ZcB.js +11 -0
  173. package/dist/web/assets/wifi-off-Dt52ofzh.js +1 -0
  174. package/dist/web/assets/workers-Ciff6Dzi.js +1 -0
  175. package/dist/web/assets/yaml-CB67Kxnz.js +1 -0
  176. package/dist/web/connected-apps/github.svg +3 -0
  177. package/dist/web/connected-apps/google.svg +6 -0
  178. package/dist/web/connected-apps/linear.svg +3 -0
  179. package/dist/web/connected-apps/microsoft.svg +6 -0
  180. package/dist/web/connected-apps/notion.svg +3 -0
  181. package/dist/web/connected-apps/openpond-mcp.svg +4 -0
  182. package/dist/web/connected-apps/slack.svg +6 -0
  183. package/dist/web/connected-apps/x.svg +3 -0
  184. package/dist/web/favicon-16x16.png +0 -0
  185. package/dist/web/favicon-32x32.png +0 -0
  186. package/dist/web/index.html +16 -0
  187. package/dist/web/openpond-icon.png +0 -0
  188. package/dist/web/openpond-wordlogo-white.png +0 -0
  189. package/dist/web/tokens/eth.svg +1 -0
  190. package/dist/web/tokens/usdc.svg +1 -0
  191. package/docs/agent-edit-check-status-json.md +132 -0
  192. package/docs/command-reference.md +695 -0
  193. package/package.json +84 -0
@@ -0,0 +1,632 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import {
3
+ parseSandboxEnvOptions,
4
+ parseSandboxRuntimeProfileIdOption,
5
+ parseSandboxRuntimePromotionPolicyOption,
6
+ parseSandboxWorkflowModeOption
7
+ } from "./chunk-XSAXENQD.js";
8
+ import {
9
+ parseBooleanOption,
10
+ parseCsvOption,
11
+ parseIntegerOption,
12
+ parseJsonOption,
13
+ parseNumberOption
14
+ } from "./chunk-3Y4EL3P6.js";
15
+
16
+ // src/cli/sandbox-helpers.ts
17
+ import { Buffer } from "node:buffer";
18
+ import { readdirSync, readFileSync, statSync } from "node:fs";
19
+ import path from "node:path";
20
+ var DOCKER_CONTEXT_MAX_FILES = 500;
21
+ var DOCKER_CONTEXT_MAX_FILE_BYTES = 8 * 1024 * 1024;
22
+ var DOCKER_CONTEXT_MAX_BYTES = 8 * 1024 * 1024;
23
+ async function createSandboxFromPlan(client, plan) {
24
+ if (!plan.sandboxRuntime && !plan.runtimeId) {
25
+ return {
26
+ sandbox: await waitForSandboxCreateReady(
27
+ client,
28
+ await client.create(plan.sandbox, { async: true })
29
+ )
30
+ };
31
+ }
32
+ const runtime = plan.runtimeId ? void 0 : await client.createSandboxRuntime(plan.sandboxRuntime);
33
+ const runtimeId = plan.runtimeId ?? runtime.id;
34
+ const result = await client.createSandboxRuntimeSandbox(
35
+ runtimeId,
36
+ plan.sandbox
37
+ );
38
+ return {
39
+ sandbox: await waitForSandboxCreateReady(client, result.sandbox),
40
+ runtime: result.runtime ?? runtime
41
+ };
42
+ }
43
+ async function waitForSandboxCreateReady(client, sandbox) {
44
+ if (sandbox.state === "running" || sandbox.state === "stopped") {
45
+ return sandbox;
46
+ }
47
+ if (sandbox.state === "error") {
48
+ throw new Error(
49
+ `sandbox create failed: ${sandbox.id}
50
+ ${sandbox.logs.join("\n")}`
51
+ );
52
+ }
53
+ const timeoutMs = 12 * 6e4;
54
+ const pollMs = 3e3;
55
+ const deadline = Date.now() + timeoutMs;
56
+ let latest = sandbox;
57
+ while (Date.now() < deadline) {
58
+ await new Promise((resolve) => setTimeout(resolve, pollMs));
59
+ latest = await client.get(sandbox.id);
60
+ if (latest.state === "running" || latest.state === "stopped") {
61
+ return latest;
62
+ }
63
+ if (latest.state === "error") {
64
+ throw new Error(
65
+ `sandbox create failed: ${latest.id}
66
+ ${latest.logs.join("\n")}`
67
+ );
68
+ }
69
+ }
70
+ throw new Error(
71
+ `sandbox create did not reach running state before timeout: ${latest.id} (${latest.state})`
72
+ );
73
+ }
74
+ function formatSandboxLine(sandbox) {
75
+ const mppMode = sandbox.reservation.mpp?.mode ?? "no-mpp";
76
+ const captured = sandbox.reservation.capturedUsd;
77
+ const budget = sandbox.budget.maxUsd;
78
+ const repo = sandbox.repo ?? "-";
79
+ return [
80
+ sandbox.id,
81
+ sandbox.state,
82
+ sandbox.runtimeDriver,
83
+ `spent=${captured}/${budget}`,
84
+ mppMode,
85
+ repo
86
+ ].join(" ");
87
+ }
88
+ function formatSnapshotCatalogLine(snapshot) {
89
+ const template = snapshot.template ? `${snapshot.template.name}@${snapshot.template.version}` : "-";
90
+ const retention = snapshot.replay?.retention?.class ?? snapshot.storageCost?.retentionClass ?? "-";
91
+ const replayState = snapshot.replay?.state ?? "-";
92
+ const monthlyUsd = snapshot.storageCost?.estimatedMonthlyUsd ?? "-";
93
+ return [
94
+ snapshot.id,
95
+ snapshot.kind,
96
+ snapshot.name,
97
+ snapshot.sandboxId,
98
+ `storage=${snapshot.storage ?? "-"}`,
99
+ `sizeGb=${snapshot.sizeGb ?? "-"}`,
100
+ `publishedSnapshot=${template}`,
101
+ `replay=${replayState}`,
102
+ `retention=${retention}`,
103
+ `monthlyUsd=${monthlyUsd}`,
104
+ snapshot.createdAt
105
+ ].join(" ");
106
+ }
107
+ function formatSandboxTemplateLine(template) {
108
+ const tags = template.tags && template.tags.length > 0 ? template.tags.join(",") : "-";
109
+ const retention = template.replay?.retention?.class ?? template.storageCost?.retentionClass ?? "-";
110
+ const replayState = template.replay?.state ?? "-";
111
+ const monthlyUsd = template.storageCost?.estimatedMonthlyUsd ?? "-";
112
+ return [
113
+ template.name,
114
+ `version=${template.version}`,
115
+ `snapshot=${template.snapshotId}`,
116
+ `sandbox=${template.sandboxId}`,
117
+ `visibility=${template.visibility}`,
118
+ `useCase=${template.useCase ?? "-"}`,
119
+ `tags=${tags}`,
120
+ `replay=${replayState}`,
121
+ `retention=${retention}`,
122
+ `monthlyUsd=${monthlyUsd}`,
123
+ template.createdAt
124
+ ].join(" ");
125
+ }
126
+ function formatTemplateBuildLine(build) {
127
+ return [
128
+ build.id,
129
+ `team=${build.teamId}`,
130
+ `status=${build.status}`,
131
+ `publish=${build.publishStatus ?? "-"}`,
132
+ `source=${build.sourceRepoUrl}`,
133
+ `branch=${build.sourceBranch}`,
134
+ `snapshot=${build.snapshotId ?? "-"}`,
135
+ `error=${build.error ?? "-"}`,
136
+ build.createdAt ?? "-"
137
+ ].join(" ");
138
+ }
139
+ function formatReplayLine(replay) {
140
+ return [
141
+ replay.id,
142
+ `team=${replay.teamId}`,
143
+ `state=${replay.state}`,
144
+ `snapshot=${replay.snapshotId}`,
145
+ `sandbox=${replay.sandboxId ?? "-"}`,
146
+ `command=${replay.commandId ?? "-"}`,
147
+ `exit=${replay.exitCode ?? "-"}`,
148
+ `cleanup=${replay.cleanup.action}:${replay.cleanup.status}`,
149
+ `error=${replay.error ?? "-"}`,
150
+ replay.createdAt
151
+ ].join(" ");
152
+ }
153
+ function summarizeReplayArtifact(artifact) {
154
+ return {
155
+ path: artifact.path,
156
+ status: artifact.status,
157
+ sizeBytes: artifact.sizeBytes,
158
+ error: artifact.error,
159
+ ...artifact.contentsBase64 ? {
160
+ contentsBase64: artifact.contentsBase64
161
+ } : {}
162
+ };
163
+ }
164
+ function normalizeSnapshotValidationCleanup(value) {
165
+ if (typeof value !== "string") return void 0;
166
+ const cleanup = value.trim();
167
+ if (cleanup === "delete" || cleanup === "stop" || cleanup === "archive") {
168
+ return cleanup;
169
+ }
170
+ throw new Error(
171
+ "snapshot-validate --cleanup must be delete, stop, or archive"
172
+ );
173
+ }
174
+ function normalizeReplayCleanup(value) {
175
+ if (typeof value !== "string") return void 0;
176
+ const cleanup = value.trim();
177
+ if (cleanup === "delete" || cleanup === "stop" || cleanup === "archive") {
178
+ return cleanup;
179
+ }
180
+ throw new Error("replay cleanup must be delete, stop, or archive");
181
+ }
182
+ function buildSandboxReplayInput(options) {
183
+ const snapshotId = typeof options.snapshotId === "string" && options.snapshotId.trim() ? options.snapshotId.trim() : typeof options.snapshot === "string" && options.snapshot.trim() ? options.snapshot.trim() : "";
184
+ if (!snapshotId) {
185
+ throw new Error("replay-start requires --snapshot-id <id>");
186
+ }
187
+ const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
188
+ const projectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
189
+ const sourceSandboxId = typeof options.sourceSandboxId === "string" && options.sourceSandboxId.trim() ? options.sourceSandboxId.trim() : "";
190
+ const entrypoint = typeof options.entrypoint === "string" && options.entrypoint.trim() ? options.entrypoint.trim() : "";
191
+ const params = typeof options.params === "string" && options.params.trim() ? parseJsonOption(options.params, "params") : {};
192
+ if (!params || typeof params !== "object" || Array.isArray(params)) {
193
+ throw new Error("params must be a JSON object");
194
+ }
195
+ const budgetUsd = typeof options.budgetUsd === "string" && options.budgetUsd.trim() ? options.budgetUsd.trim() : typeof options.budget === "string" && options.budget.trim() ? options.budget.trim() : "";
196
+ const maxDurationSeconds = parseIntegerOption(
197
+ options.maxDurationSeconds,
198
+ "max-duration-seconds"
199
+ );
200
+ const idleTimeoutSeconds = parseIntegerOption(
201
+ options.idleTimeoutSeconds,
202
+ "idle-timeout-seconds"
203
+ );
204
+ const artifactPaths = parseCsvOption(options.artifactPaths);
205
+ const idempotencyKey = typeof options.idempotencyKey === "string" && options.idempotencyKey.trim() ? options.idempotencyKey.trim() : "";
206
+ const cleanup = normalizeReplayCleanup(options.cleanup);
207
+ return {
208
+ snapshotId,
209
+ ...teamId ? { teamId } : {},
210
+ ...projectId ? { projectId } : {},
211
+ ...sourceSandboxId ? { sourceSandboxId } : {},
212
+ ...entrypoint ? { entrypoint } : {},
213
+ params,
214
+ ...budgetUsd ? { budget: { maxUsd: budgetUsd } } : {},
215
+ ...maxDurationSeconds !== void 0 ? { maxDurationSeconds } : {},
216
+ ...idleTimeoutSeconds !== void 0 ? { idleTimeoutSeconds } : {},
217
+ ...artifactPaths.length > 0 ? { artifactPaths } : {},
218
+ ...idempotencyKey ? { idempotencyKey } : {},
219
+ ...cleanup ? { cleanup } : {}
220
+ };
221
+ }
222
+ function buildSandboxCreateInput(options) {
223
+ const repo = typeof options.repo === "string" ? options.repo.trim() : "";
224
+ const command = typeof options.command === "string" && options.command.trim() ? options.command.trim() : void 0;
225
+ const budgetUsd = typeof options.budgetUsd === "string" && options.budgetUsd.trim() ? options.budgetUsd.trim() : typeof options.budget === "string" && options.budget.trim() ? options.budget.trim() : "0.05";
226
+ const cpu = parseNumberOption(options.cpu, "cpu");
227
+ const memoryGb = parseNumberOption(options.memoryGb, "memory-gb");
228
+ const diskGb = parseNumberOption(options.diskGb, "disk-gb");
229
+ const maxDurationSeconds = parseIntegerOption(
230
+ options.maxDurationSeconds,
231
+ "max-duration-seconds"
232
+ );
233
+ const idleTimeoutSeconds = parseIntegerOption(
234
+ options.idleTimeoutSeconds,
235
+ "idle-timeout-seconds"
236
+ );
237
+ const volumeName = typeof options.volumeName === "string" && options.volumeName.trim() ? options.volumeName.trim() : "";
238
+ const volumeMountPath = typeof options.volumeMountPath === "string" && options.volumeMountPath.trim() ? options.volumeMountPath.trim() : "";
239
+ const volumeStorageGb = parseIntegerOption(
240
+ options.volumeStorageGb,
241
+ "volume-storage-gb"
242
+ );
243
+ const volumeDeleteOnSandboxDelete = options.volumeDeleteOnSandboxDelete !== void 0 ? parseBooleanOption(options.volumeDeleteOnSandboxDelete) : void 0;
244
+ const integrationConnection = typeof options.integrationConnection === "string" ? options.integrationConnection.trim() : "";
245
+ const integrationCapabilities = parseCsvOption(
246
+ options.integrationCapabilities
247
+ );
248
+ const integrationScopes = parseCsvOption(options.integrationScopes);
249
+ const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
250
+ const requestedProjectId = typeof options.projectId === "string" ? options.projectId.trim() : "";
251
+ const sandboxRuntimeProjectId = typeof options.runtimeProjectId === "string" ? options.runtimeProjectId.trim() : "";
252
+ if (requestedProjectId && sandboxRuntimeProjectId && requestedProjectId !== sandboxRuntimeProjectId) {
253
+ throw new Error(
254
+ "project-id and runtime-project-id must match when both are set"
255
+ );
256
+ }
257
+ const projectId = requestedProjectId || sandboxRuntimeProjectId;
258
+ const requestedAgentId = typeof options.agentId === "string" ? options.agentId.trim() : "";
259
+ const sandboxRuntimeAgentId = typeof options.runtimeAgentId === "string" ? options.runtimeAgentId.trim() : "";
260
+ if (requestedAgentId && sandboxRuntimeAgentId && requestedAgentId !== sandboxRuntimeAgentId) {
261
+ throw new Error(
262
+ "agent-id and runtime-agent-id must match when both are set"
263
+ );
264
+ }
265
+ const agentId = requestedAgentId || sandboxRuntimeAgentId;
266
+ const sandboxWorkflowMode = parseSandboxWorkflowModeOption(options.workflowMode);
267
+ const sandboxRuntimePromotionPolicy = parseSandboxRuntimePromotionPolicyOption(options.runtimePromotionPolicy);
268
+ const workloadSource = buildSandboxWorkloadSourceInput(options);
269
+ const sourceArchive = buildDockerfileSourceArchiveInput(options);
270
+ const runtimeProfileId = parseSandboxRuntimeProfileIdOption(
271
+ options.runtimeProfileId
272
+ );
273
+ const sandboxRuntimeBaseBranch = typeof options.runtimeBaseBranch === "string" && options.runtimeBaseBranch.trim() ? options.runtimeBaseBranch.trim() : "";
274
+ const sandboxRuntimeBaseSha = typeof options.runtimeBaseSha === "string" && options.runtimeBaseSha.trim() ? options.runtimeBaseSha.trim() : "";
275
+ const runtimeId = typeof options.runtimeId === "string" && options.runtimeId.trim() ? options.runtimeId.trim() : "";
276
+ const sandboxRuntimeRequested = Boolean(
277
+ sandboxWorkflowMode || sandboxRuntimePromotionPolicy || sandboxRuntimeBaseBranch || sandboxRuntimeBaseSha || runtimeProfileId || runtimeId || sandboxRuntimeProjectId || sandboxRuntimeAgentId
278
+ );
279
+ const env = parseSandboxEnvOptions(options);
280
+ if (integrationConnection && integrationCapabilities.length === 0) {
281
+ throw new Error(
282
+ "integration-capabilities is required with integration-connection"
283
+ );
284
+ }
285
+ const sandbox = {
286
+ ...repo ? { repo } : {},
287
+ ...teamId ? { teamId } : {},
288
+ ...projectId ? { projectId } : {},
289
+ ...agentId ? { agentId } : {},
290
+ ...runtimeProfileId ? { runtimeProfileId } : {},
291
+ ...command ? { command } : {},
292
+ ...workloadSource ? { workloadSource } : {},
293
+ ...sourceArchive ? { sourceArchive } : {},
294
+ resources: {
295
+ ...cpu !== void 0 ? { cpu } : {},
296
+ ...memoryGb !== void 0 ? { memoryGb } : {},
297
+ ...diskGb !== void 0 ? { diskGb } : {}
298
+ },
299
+ budget: { maxUsd: budgetUsd },
300
+ quotas: {
301
+ maxSpendUsd: budgetUsd,
302
+ ...maxDurationSeconds !== void 0 ? { maxDurationSeconds } : {},
303
+ ...idleTimeoutSeconds !== void 0 ? { idleTimeoutSeconds } : {}
304
+ },
305
+ ...env.length > 0 ? { env } : {},
306
+ ...volumeName || volumeMountPath || volumeStorageGb !== void 0 ? {
307
+ volumes: [
308
+ {
309
+ ...volumeName ? { name: volumeName } : {},
310
+ ...volumeMountPath ? { mountPath: volumeMountPath } : {},
311
+ ...volumeStorageGb !== void 0 ? { storageGb: volumeStorageGb } : {},
312
+ ...volumeDeleteOnSandboxDelete !== void 0 ? { deleteOnSandboxDelete: volumeDeleteOnSandboxDelete } : {}
313
+ }
314
+ ]
315
+ } : {},
316
+ ...integrationConnection ? {
317
+ integrationConnectionLeases: [
318
+ {
319
+ connectionId: integrationConnection,
320
+ ...integrationScopes.length > 0 ? { scopes: integrationScopes } : {},
321
+ capabilities: integrationCapabilities,
322
+ ttlSeconds: 60 * 60
323
+ }
324
+ ]
325
+ } : {},
326
+ metadata: {
327
+ source: "openpond-code"
328
+ }
329
+ };
330
+ return {
331
+ sandbox,
332
+ ...sandboxRuntimeRequested && runtimeId ? { runtimeId } : {},
333
+ ...sandboxRuntimeRequested && !runtimeId ? {
334
+ sandboxRuntime: {
335
+ ...teamId ? { teamId } : {},
336
+ ...sandboxWorkflowMode ? { workflowMode: sandboxWorkflowMode } : {},
337
+ ...projectId ? { projectId } : {},
338
+ ...agentId ? { agentId } : {},
339
+ baseBranch: sandboxRuntimeBaseBranch || "master",
340
+ ...sandboxRuntimeBaseSha ? { baseSha: sandboxRuntimeBaseSha } : {},
341
+ ...sandboxRuntimePromotionPolicy ? { promotionPolicy: sandboxRuntimePromotionPolicy } : {},
342
+ ...runtimeProfileId ? { runtimeProfileId } : {}
343
+ }
344
+ } : {}
345
+ };
346
+ }
347
+ function isSafeDockerContextPath(filePath) {
348
+ return filePath.length > 0 && !filePath.includes("\0") && !path.isAbsolute(filePath) && !filePath.split(/[\\/]+/).some((part) => !part || part === "." || part === "..");
349
+ }
350
+ function shouldSkipDockerContextPath(filePath) {
351
+ return filePath.split(/[\\/]+/).some((segment) => {
352
+ const lower = segment.toLowerCase();
353
+ return lower === ".git" || lower === "node_modules" || lower === ".next" || lower === ".turbo" || lower.startsWith(".env");
354
+ });
355
+ }
356
+ function collectDockerContextFiles(params) {
357
+ const baseDir = params.baseDir ?? params.contextRoot;
358
+ const entries = readdirSync(baseDir, { withFileTypes: true });
359
+ const files = [];
360
+ for (const entry of entries) {
361
+ const absolutePath = path.join(baseDir, entry.name);
362
+ const relativePath = path.relative(params.contextRoot, absolutePath).replace(/\\/g, "/");
363
+ if (!relativePath || !isSafeDockerContextPath(relativePath) || shouldSkipDockerContextPath(relativePath)) {
364
+ continue;
365
+ }
366
+ if (entry.isDirectory()) {
367
+ files.push(
368
+ ...collectDockerContextFiles({
369
+ contextRoot: params.contextRoot,
370
+ baseDir: absolutePath
371
+ })
372
+ );
373
+ continue;
374
+ }
375
+ if (entry.isFile()) {
376
+ files.push(relativePath);
377
+ }
378
+ }
379
+ return files;
380
+ }
381
+ function buildDockerfileSourceArchiveInput(options) {
382
+ const dockerfilePath = stringOption(options.dockerfile);
383
+ if (!dockerfilePath) {
384
+ return void 0;
385
+ }
386
+ const contextPath = stringOption(options.dockerfileContext) || ".";
387
+ const contextRoot = path.resolve(process.cwd(), contextPath);
388
+ const contextStat = statSync(contextRoot);
389
+ if (!contextStat.isDirectory()) {
390
+ throw new Error(`dockerfile context must be a directory: ${contextPath}`);
391
+ }
392
+ const sourcePaths = collectDockerContextFiles({ contextRoot }).sort();
393
+ if (sourcePaths.length === 0) {
394
+ throw new Error(`dockerfile context has no files: ${contextPath}`);
395
+ }
396
+ if (sourcePaths.length > DOCKER_CONTEXT_MAX_FILES) {
397
+ throw new Error(
398
+ `dockerfile context has too many files: ${sourcePaths.length} > ${DOCKER_CONTEXT_MAX_FILES}`
399
+ );
400
+ }
401
+ let totalBytes = 0;
402
+ const entries = sourcePaths.map((sourcePath) => {
403
+ const absolutePath = path.resolve(contextRoot, sourcePath);
404
+ const relative = path.relative(contextRoot, absolutePath);
405
+ if (relative.startsWith("..") || path.isAbsolute(relative)) {
406
+ throw new Error(`dockerfile context path escapes context: ${sourcePath}`);
407
+ }
408
+ const stat = statSync(absolutePath);
409
+ if (stat.size > DOCKER_CONTEXT_MAX_FILE_BYTES) {
410
+ throw new Error(
411
+ `dockerfile context file is too large: ${sourcePath} (${stat.size} bytes)`
412
+ );
413
+ }
414
+ totalBytes += stat.size;
415
+ if (totalBytes > DOCKER_CONTEXT_MAX_BYTES) {
416
+ throw new Error(
417
+ `dockerfile context is too large: ${totalBytes} > ${DOCKER_CONTEXT_MAX_BYTES}`
418
+ );
419
+ }
420
+ return {
421
+ path: sourcePath,
422
+ type: "file",
423
+ contentsBase64: Buffer.from(readFileSync(absolutePath)).toString("base64")
424
+ };
425
+ });
426
+ return {
427
+ source: "client_upload",
428
+ ref: "client-upload",
429
+ archive: {
430
+ version: 1,
431
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
432
+ entries
433
+ }
434
+ };
435
+ }
436
+ function buildSandboxWorkloadSourceInput(options) {
437
+ const imageRef = stringOption(options.image);
438
+ const dockerfilePath = stringOption(options.dockerfile);
439
+ if (imageRef && dockerfilePath) {
440
+ throw new Error("sandbox create accepts only one of --image or --dockerfile");
441
+ }
442
+ const workspaceRoot = stringOption(options.runtimeWorkspaceRoot);
443
+ if (imageRef) {
444
+ return {
445
+ image: {
446
+ ref: imageRef,
447
+ ...stringOption(options.imageDigest) ? { digest: stringOption(options.imageDigest) } : {},
448
+ ...stringOption(options.registrySecretRef) ? { registrySecretRef: stringOption(options.registrySecretRef) } : {},
449
+ ...workspaceRoot ? { workspaceRoot } : {},
450
+ platform: "linux/amd64"
451
+ }
452
+ };
453
+ }
454
+ if (dockerfilePath) {
455
+ const buildArgs = parseDockerBuildArgs(options.dockerBuildArgs);
456
+ const registrySecretRefs = parseCsvOption(options.dockerRegistrySecretRefs);
457
+ return {
458
+ dockerfile: {
459
+ path: dockerfilePath,
460
+ context: stringOption(options.dockerfileContext) || ".",
461
+ ...stringOption(options.dockerfileTarget) ? { target: stringOption(options.dockerfileTarget) } : {},
462
+ ...Object.keys(buildArgs).length > 0 ? { buildArgs } : {},
463
+ ...registrySecretRefs.length > 0 ? { registrySecretRefs } : {},
464
+ ...workspaceRoot ? { workspaceRoot } : {},
465
+ platform: "linux/amd64"
466
+ }
467
+ };
468
+ }
469
+ return void 0;
470
+ }
471
+ function parseDockerBuildArgs(value) {
472
+ if (typeof value !== "string" || !value.trim()) {
473
+ return {};
474
+ }
475
+ const parsed = parseJsonOption(value, "docker-build-args");
476
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
477
+ throw new Error("docker-build-args must be a JSON object");
478
+ }
479
+ const result = {};
480
+ for (const [key, rawValue] of Object.entries(parsed)) {
481
+ if (typeof rawValue !== "string") {
482
+ throw new Error("docker-build-args values must be strings");
483
+ }
484
+ result[key] = rawValue;
485
+ }
486
+ return result;
487
+ }
488
+ function stringOption(value) {
489
+ return typeof value === "string" ? value.trim() : "";
490
+ }
491
+ function buildSandboxIntegrationAttachInput(options) {
492
+ const connectionId = typeof options.integrationConnection === "string" ? options.integrationConnection.trim() : "";
493
+ const capabilities = parseCsvOption(options.integrationCapabilities);
494
+ const scopes = parseCsvOption(options.integrationScopes);
495
+ if (!connectionId || capabilities.length === 0) {
496
+ throw new Error(
497
+ "usage: sandbox integration-attach <sandboxId> --integration-connection <id> --integration-capabilities <csv>"
498
+ );
499
+ }
500
+ return {
501
+ connectionId,
502
+ ...scopes.length > 0 ? { scopes } : {},
503
+ capabilities,
504
+ ttlSeconds: 60 * 60
505
+ };
506
+ }
507
+ function buildTemplateBuildCreateInput(options) {
508
+ const teamId = typeof options.teamId === "string" ? options.teamId.trim() : "";
509
+ const sourceRepoUrl = typeof options.sourceRepoUrl === "string" ? options.sourceRepoUrl.trim() : "";
510
+ const sourceProjectId = typeof options.sourceProjectId === "string" ? options.sourceProjectId.trim() : "";
511
+ const branch = typeof options.branch === "string" ? options.branch.trim() : "";
512
+ const manifestPath = typeof options.manifestPath === "string" ? options.manifestPath.trim() : "";
513
+ if (!teamId) {
514
+ throw new Error("published-snapshot-build-create requires --team-id <id>");
515
+ }
516
+ if (!sourceRepoUrl && !sourceProjectId) {
517
+ throw new Error(
518
+ "published-snapshot-build-create requires --source-repo-url <url> or --source-project-id <id>"
519
+ );
520
+ }
521
+ return {
522
+ teamId,
523
+ ...sourceRepoUrl ? { sourceRepoUrl } : {},
524
+ ...sourceProjectId ? { sourceProjectId } : {},
525
+ ...branch ? { branch } : {},
526
+ ...manifestPath ? { manifestPath } : {},
527
+ publish: parseBooleanOption(options.publish)
528
+ };
529
+ }
530
+ function buildSnapshotCreateInput(options) {
531
+ const name = typeof options.name === "string" ? options.name.trim() : "";
532
+ if (!name) {
533
+ throw new Error("snapshot-create requires --name <name>");
534
+ }
535
+ const templateName = typeof options.templateName === "string" ? options.templateName.trim() : "";
536
+ const templateVersion = typeof options.templateVersion === "string" && options.templateVersion.trim() ? options.templateVersion.trim() : "0.1.0";
537
+ const templateVisibility = typeof options.templateVisibility === "string" && options.templateVisibility.trim() ? options.templateVisibility.trim() : "private";
538
+ if (templateVisibility !== "private" && templateVisibility !== "team") {
539
+ throw new Error("template-visibility must be private or team");
540
+ }
541
+ const validationCommand = typeof options.validationCommand === "string" && options.validationCommand.trim() ? options.validationCommand.trim() : "test -d .";
542
+ const entrypointCommand = typeof options.entrypointCommand === "string" && options.entrypointCommand.trim() ? options.entrypointCommand.trim() : "true";
543
+ const useCase = typeof options.useCase === "string" && options.useCase.trim() ? options.useCase.trim() : void 0;
544
+ const description = typeof options.description === "string" && options.description.trim() ? options.description.trim() : void 0;
545
+ const tags = parseCsvOption(options.tags);
546
+ const input = {
547
+ ...parseBooleanOption(options.async) ? { async: true } : {},
548
+ name,
549
+ replay: {
550
+ entrypoints: [
551
+ {
552
+ command: entrypointCommand,
553
+ name: "default"
554
+ }
555
+ ],
556
+ retention: {
557
+ class: "pinned"
558
+ },
559
+ safety: {
560
+ cleanup: "delete",
561
+ idleTimeoutSeconds: 600,
562
+ internetEgress: "block",
563
+ maxDurationSeconds: 600,
564
+ maxSpendUsd: "0.05",
565
+ publicPreview: false
566
+ },
567
+ validation: {
568
+ commands: [
569
+ {
570
+ command: validationCommand
571
+ }
572
+ ]
573
+ }
574
+ }
575
+ };
576
+ if (templateName) {
577
+ input.template = {
578
+ name: templateName,
579
+ version: templateVersion,
580
+ ...description ? { description } : {},
581
+ ...tags.length > 0 ? { tags } : {},
582
+ visibility: templateVisibility,
583
+ ...useCase ? { useCase } : {}
584
+ };
585
+ }
586
+ return input;
587
+ }
588
+ function summarizeSandbox(sandbox) {
589
+ return {
590
+ id: sandbox.id,
591
+ state: sandbox.state,
592
+ runtimeDriver: sandbox.runtimeDriver,
593
+ repo: sandbox.repo,
594
+ runtimeId: sandbox.runtimeId ?? null,
595
+ repoRef: sandbox.repoRef ?? null,
596
+ sourceCommitSha: sandbox.sourceCommitSha ?? null,
597
+ budgetUsd: sandbox.budget.maxUsd,
598
+ capturedUsd: sandbox.reservation.capturedUsd,
599
+ reservationRef: sandbox.reservation.mpp?.reservationRef ?? null,
600
+ mppMode: sandbox.reservation.mpp?.mode ?? null,
601
+ integrationLeases: sandbox.integrationLeases?.map((lease) => ({
602
+ leaseId: lease.leaseId,
603
+ provider: lease.provider,
604
+ capabilities: lease.capabilities
605
+ })) ?? [],
606
+ previewPorts: sandbox.previewPorts.map((preview) => ({
607
+ port: preview.port,
608
+ label: preview.label,
609
+ url: preview.url,
610
+ customDomain: preview.customDomain ?? null
611
+ })),
612
+ latestReceipt: sandbox.receipts.at(-1)?.mpp.receiptRef ?? null
613
+ };
614
+ }
615
+
616
+ export {
617
+ createSandboxFromPlan,
618
+ waitForSandboxCreateReady,
619
+ formatSandboxLine,
620
+ formatSnapshotCatalogLine,
621
+ formatSandboxTemplateLine,
622
+ formatTemplateBuildLine,
623
+ formatReplayLine,
624
+ summarizeReplayArtifact,
625
+ normalizeSnapshotValidationCleanup,
626
+ buildSandboxReplayInput,
627
+ buildSandboxCreateInput,
628
+ buildSandboxIntegrationAttachInput,
629
+ buildTemplateBuildCreateInput,
630
+ buildSnapshotCreateInput,
631
+ summarizeSandbox
632
+ };