openpond 0.0.36 → 0.0.38

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 (137) hide show
  1. package/README.md +4 -3
  2. package/dist/api/types.d.ts +0 -50
  3. package/dist/api.d.ts +2 -8
  4. package/dist/chunks/{app-layer-4AA4YYGK.js → app-layer-DPUJRNO2.js} +6 -3
  5. package/dist/chunks/{apps-V2JTB5MD.js → apps-AKBI6AS7.js} +16 -132
  6. package/dist/chunks/chunk-275WCETC.js +668 -0
  7. package/dist/chunks/{chunk-3DOOLZZM.js → chunk-43YI36NA.js} +1 -1
  8. package/dist/chunks/{chunk-NWQTF6O4.js → chunk-AHNFNWUN.js} +28 -3
  9. package/dist/chunks/{chunk-3JJBNVNX.js → chunk-AHPQTEIJ.js} +23 -19
  10. package/dist/chunks/chunk-FWLOFUPU.js +864 -0
  11. package/dist/chunks/{chunk-JAS6QZ2W.js → chunk-GB6VUZUA.js} +1 -1
  12. package/dist/chunks/{chunk-NVTC3XOA.js → chunk-GDZYDLEL.js} +8 -10
  13. package/dist/chunks/{chunk-G6WW2656.js → chunk-HLCTINEP.js} +1 -1
  14. package/dist/chunks/{chunk-MJT7EW5Q.js → chunk-HS2AGRDV.js} +1 -1
  15. package/dist/chunks/{chunk-CJSD5ADV.js → chunk-JWF37O5E.js} +2 -2
  16. package/dist/chunks/chunk-KSRWKXRB.js +12 -0
  17. package/dist/chunks/{chunk-7IPF4X3K.js → chunk-LZZM3IHS.js} +1004 -89
  18. package/dist/chunks/{chunk-TYYR7KWY.js → chunk-MPGSHXGF.js} +7 -5
  19. package/dist/chunks/chunk-MUMPWI4O.js +92 -0
  20. package/dist/chunks/{chunk-MSX2J653.js → chunk-QRM7XMAO.js} +5 -36
  21. package/dist/chunks/{chunk-65BVQIHR.js → chunk-SLMP353Q.js} +6 -6
  22. package/dist/chunks/chunk-T4QXKU5Y.js +1 -0
  23. package/dist/chunks/{chunk-GALAW74P.js → chunk-V35STJF4.js} +30 -11
  24. package/dist/chunks/{chunk-YLULZMWE.js → chunk-XCATKTK3.js} +51 -139
  25. package/dist/chunks/{chunk-LHYK6QO2.js → chunk-XEJ7XXUQ.js} +1 -0
  26. package/dist/chunks/{chunk-YRFQKUZD.js → chunk-XERQHYBO.js} +89 -27
  27. package/dist/chunks/{chunk-6L5WJF7T.js → chunk-YTJL6XPU.js} +2 -2
  28. package/dist/chunks/{chunk-NWVIUBJ3.js → chunk-ZI4GDAUB.js} +573 -1217
  29. package/dist/chunks/cli-2KBVNDRY.js +23 -0
  30. package/dist/chunks/{cli-RJHEE4FA.js → cli-7BKDWFNU.js} +5 -5
  31. package/dist/chunks/{core-commands-CQSPCVC4.js → core-commands-YN4RMWA3.js} +7 -4
  32. package/dist/chunks/{extend-4MZ75SHV.js → extend-REGNTBK3.js} +18 -13
  33. package/dist/chunks/extension-7K77DAVL.js +121 -0
  34. package/dist/chunks/{harness-YVZU42S7.js → harness-BHQRMXJR.js} +6 -3
  35. package/dist/chunks/{help-6SULYXVS.js → help-VREQNA4I.js} +2 -1
  36. package/dist/chunks/{opchat-XGS4AXHA.js → opchat-D63YTNSX.js} +12 -7
  37. package/dist/chunks/{organizations-4GFQ3NT2.js → organizations-I46KG7TC.js} +8 -5
  38. package/dist/chunks/{profile-VWMBIHIE.js → profile-WKZJHEPG.js} +11 -8
  39. package/dist/chunks/{project-agent-SQ6ODALG.js → project-agent-ZUC3YMCT.js} +10 -7
  40. package/dist/chunks/{sandbox-command-34S2V7BN.js → sandbox-command-AAOPFTI5.js} +7 -4
  41. package/dist/chunks/{sandbox-template-VP5HMGQI.js → sandbox-template-GKNVR4C5.js} +11 -7
  42. package/dist/chunks/{src-X3R3XIJT.js → src-MWDIK56B.js} +1997 -1247
  43. package/dist/chunks/{src-YHUMH6W6.js → src-RPW5TOPI.js} +3 -3
  44. package/dist/chunks/{teams-bot-EIVRNO5S.js → teams-bot-PSL3ZO6Z.js} +6 -3
  45. package/dist/chunks/{workspaces-2N52V3BI.js → workspaces-BPXC2DHT.js} +6 -2
  46. package/dist/cli.js +14 -11
  47. package/dist/client-types.d.ts +1 -9
  48. package/dist/client.d.ts +3 -3
  49. package/dist/index.js +27 -55
  50. package/dist/profile/local-profile-types.d.ts +1 -0
  51. package/dist/profile/profile-skills.d.ts +2 -0
  52. package/dist/web/assets/{AppDialog-j4N-gIi3.js → AppDialog-DrwJb_wG.js} +1 -1
  53. package/dist/web/assets/{AppsView-YiK3pqNb.js → AppsView-DPagLMsc.js} +1 -1
  54. package/dist/web/assets/{BrowserSidebar-BWFLEQ8j.js → BrowserSidebar-DMn2V8RV.js} +1 -1
  55. package/dist/web/assets/{CloudWorkView-3sS_1bhN.js → CloudWorkView-Cl_7mM3c.js} +1 -1
  56. package/dist/web/assets/{CommandMenu-B11OrTCq.js → CommandMenu-CHMQLez_.js} +1 -1
  57. package/dist/web/assets/{CommunityView-DXyXTWhP.js → CommunityView-DcHVDUk0.js} +1 -1
  58. package/dist/web/assets/{ComposerCreateImproveStrip-3NoRiJJq.js → ComposerCreateImproveStrip-BZ3Dgzmo.js} +1 -1
  59. package/dist/web/assets/{GetStartedView-CPV5lgVH.js → GetStartedView-DTRotFqz.js} +1 -1
  60. package/dist/web/assets/LabSkillSidebar-CVxtS9pd.css +1 -0
  61. package/dist/web/assets/LabSkillSidebar-D-PqFe1T.js +1 -0
  62. package/dist/web/assets/LabsRoute-BrJkBNig.css +1 -0
  63. package/dist/web/assets/LabsRoute-Dew1BwK5.js +3 -0
  64. package/dist/web/assets/MainChatThread-BaPxxzrw.js +2 -0
  65. package/dist/web/assets/{MakeAgentTutorialLearningPanel-C6F-kJQd.js → MakeAgentTutorialLearningPanel-CBsfnONQ.js} +2 -2
  66. package/dist/web/assets/{MarkdownText-CkVkr3P1.js → MarkdownText-DGLfAM_Z.js} +4 -4
  67. package/dist/web/assets/Messages-CIX9uTjX.js +10 -0
  68. package/dist/web/assets/NativeSkillSidebar-AP_uHn6g.js +1 -0
  69. package/dist/web/assets/{NewProjectDialog-DBMhkTvD.js → NewProjectDialog-C6lHkafU.js} +1 -1
  70. package/dist/web/assets/{PostTrainingLearningPanel-B1Rp7iIL.js → PostTrainingLearningPanel-CZEgPc8O.js} +2 -2
  71. package/dist/web/assets/{PostTrainingStatusPill-BGZ9h5eW.js → PostTrainingStatusPill-CeEpwUDB.js} +1 -1
  72. package/dist/web/assets/{ProfileSettingsSection-2NOHEz2b.js → ProfileSettingsSection-EumMLlEp.js} +1 -1
  73. package/dist/web/assets/RightChatPanelStack-MXBcx3zO.js +1 -0
  74. package/dist/web/assets/{SettingsView-uHhQnazW.css → SettingsView-Caljbns2.css} +1 -1
  75. package/dist/web/assets/SettingsView-DyURG_Uh.js +6 -0
  76. package/dist/web/assets/{TeamChatView-qVscSedQ.js → TeamChatView-D3v6aqJ3.js} +1 -1
  77. package/dist/web/assets/{TerminalOverlay-Bkw7XqMy.js → TerminalOverlay-BKl0p8pa.js} +1 -1
  78. package/dist/web/assets/{TrainingCreationPanel-COg1wvw8.js → TrainingCreationPanel-CfZQTuT5.js} +1 -1
  79. package/dist/web/assets/{TrainingDraftPanel-BNK2znmI.js → TrainingDraftPanel-DslRPSDW.js} +1 -1
  80. package/dist/web/assets/{UsageSettingsSection-CUxBaohC.js → UsageSettingsSection-zDAwzTGl.js} +1 -1
  81. package/dist/web/assets/WorkspaceDiffPanel-C_MZPPlL.js +14 -0
  82. package/dist/web/assets/{WorkspaceEnvironmentMenu-C0-mH7oF.js → WorkspaceEnvironmentMenu-BUAnn80j.js} +1 -1
  83. package/dist/web/assets/{WorkspaceGitDialogs-VvC2px0X.js → WorkspaceGitDialogs-Drbf4ujA.js} +1 -1
  84. package/dist/web/assets/{WorkspaceMonacoEditor-CUIwoHv1.js → WorkspaceMonacoEditor-DPGcG8fy.js} +3 -3
  85. package/dist/web/assets/{activity-BhqHgkfJ.js → activity-Dnr3jqb3.js} +1 -1
  86. package/dist/web/assets/{boxes-BpqUKFIm.js → boxes-BinC8UPn.js} +1 -1
  87. package/dist/web/assets/{chevron-up-BTn9DVRP.js → chevron-up-Bjp_-_Cb.js} +1 -1
  88. package/dist/web/assets/{circle-x-B9Qa8o5a.js → circle-x-ubnvEYuE.js} +1 -1
  89. package/dist/web/assets/{copy-BsYs6wBI.js → copy-B_ZCCUMz.js} +1 -1
  90. package/dist/web/assets/{create-pipeline-request-vxgKoAvv.js → create-pipeline-request-D6uLUxe9.js} +3 -3
  91. package/dist/web/assets/{cssMode-mw8RI2fR.js → cssMode-CKN9CcfG.js} +1 -1
  92. package/dist/web/assets/file-8HAMlTmQ.js +1 -0
  93. package/dist/web/assets/{git-branch-C7qQYFIs.js → git-branch-l2Zih3Bv.js} +1 -1
  94. package/dist/web/assets/{git-commit-horizontal-CbX4pTOA.js → git-commit-horizontal-Bxi8YPep.js} +1 -1
  95. package/dist/web/assets/{htmlMode-Cc4Czh_M.js → htmlMode-CeUcNhBZ.js} +1 -1
  96. package/dist/web/assets/index-BMFyOFRU.css +1 -0
  97. package/dist/web/assets/index-BzwcDzbT.js +1 -0
  98. package/dist/web/assets/index-KoQSSt_f.js +177 -0
  99. package/dist/web/assets/{info-BNGbwgtq.js → info-JTbDQxHx.js} +1 -1
  100. package/dist/web/assets/{jsonMode-CbqbqGVz.js → jsonMode-97z0Yz9u.js} +1 -1
  101. package/dist/web/assets/{lspLanguageFeatures-DKiKr5tH.js → lspLanguageFeatures-D4Tp-JmI.js} +1 -1
  102. package/dist/web/assets/{make-agent-tutorial-KKauJpB9.js → make-agent-tutorial-D6nBCgv-.js} +1 -1
  103. package/dist/web/assets/{monaco.contribution-Dxc4IxFM.js → monaco.contribution-B3j6oown.js} +2 -2
  104. package/dist/web/assets/{monaco.contribution-CNgwz_pw.js → monaco.contribution-BXHxPPWL.js} +2 -2
  105. package/dist/web/assets/{monaco.contribution-D_-wu578.js → monaco.contribution-C2P5zIzh.js} +2 -2
  106. package/dist/web/assets/{monaco.contribution-CdUAX47Q.js → monaco.contribution-C8c6OtGi.js} +2 -2
  107. package/dist/web/assets/{monitor-CNdx_GTg.js → monitor-kzHtxHnA.js} +1 -1
  108. package/dist/web/assets/{play-BLRANWaV.js → play-C-37dnR1.js} +1 -1
  109. package/dist/web/assets/{python-DYgDMu2R.js → python-CGpDXY7_.js} +1 -1
  110. package/dist/web/assets/{refresh-cw-BFjjwYNf.js → refresh-cw-BAaaPCXl.js} +1 -1
  111. package/dist/web/assets/{reply-D012cuZl.js → reply-9rehU13k.js} +1 -1
  112. package/dist/web/assets/{rotate-cw-CTfjlR4G.js → rotate-cw-C1Z_Xs23.js} +1 -1
  113. package/dist/web/assets/{save-B1zYlRyN.js → save-Cvxs3XyC.js} +1 -1
  114. package/dist/web/assets/{toggleHighContrast-D9XFH7EA.js → toggleHighContrast-CD42jH4g.js} +1 -1
  115. package/dist/web/assets/{tsMode-BU-tuKsY.js → tsMode-ZROIxEjv.js} +1 -1
  116. package/dist/web/assets/{upload-DU_81jvL.js → upload-DvCSGERK.js} +1 -1
  117. package/dist/web/assets/{wifi-off-TPsBnbGW.js → wifi-off-BIb94PkS.js} +1 -1
  118. package/dist/web/assets/{workers-NhWySRdT.js → workers-oYqbrVYG.js} +1 -1
  119. package/dist/web/assets/{yaml-DWXa_3ZL.js → yaml-WqBjNgOO.js} +1 -1
  120. package/dist/web/index.html +2 -2
  121. package/docs/command-reference.md +16 -1
  122. package/package.json +1 -1
  123. package/dist/chunks/cli-4JA3SIDE.js +0 -19
  124. package/dist/web/assets/LabsRoute-B_nsEZXy.js +0 -3
  125. package/dist/web/assets/LabsRoute-dNN-odU0.css +0 -1
  126. package/dist/web/assets/MainChatThread-Dg7p3R2O.js +0 -2
  127. package/dist/web/assets/Messages-C7uHGoFw.js +0 -10
  128. package/dist/web/assets/NativeSkillSidebar-BPpoHjEW.js +0 -1
  129. package/dist/web/assets/RightChatPanelStack-CLK7_zKe.js +0 -1
  130. package/dist/web/assets/SettingsView-BAqea_KX.js +0 -6
  131. package/dist/web/assets/WorkspaceDiffPanel-qfFj8IRq.js +0 -14
  132. package/dist/web/assets/credit-card-BCePAwMI.js +0 -1
  133. package/dist/web/assets/index-9tbdqUau.css +0 -1
  134. package/dist/web/assets/index-B_3z_lxq.js +0 -1
  135. package/dist/web/assets/index-Cr_RZ7GD.js +0 -177
  136. package/dist/web/tokens/eth.svg +0 -1
  137. package/dist/web/tokens/usdc.svg +0 -1
@@ -0,0 +1,668 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import {
3
+ mapUiBaseToApiBase,
4
+ resolveBaseUrl,
5
+ resolveSandboxApiUrlOption
6
+ } from "./chunk-GDZYDLEL.js";
7
+ import {
8
+ DEFAULT_CACHE_TTL_MS,
9
+ SANDBOX_RUNTIME_PROFILE_IDS,
10
+ createOpenPondSandboxClient,
11
+ getCachedApps,
12
+ getCachedTools,
13
+ getDeploymentLogs,
14
+ getDeploymentStatus,
15
+ listApps,
16
+ listUserTools,
17
+ loadConfig,
18
+ saveGlobalConfig,
19
+ setCachedApps,
20
+ setCachedTools
21
+ } from "./chunk-ZI4GDAUB.js";
22
+ import {
23
+ DEFAULT_OPENPOND_API_BASE_URL,
24
+ DEFAULT_OPENPOND_WEB_BASE_URL
25
+ } from "./chunk-KSRWKXRB.js";
26
+ import {
27
+ parseBooleanOption
28
+ } from "./chunk-MUMPWI4O.js";
29
+
30
+ // src/cli/common/auth.ts
31
+ import { stdin as input, stdout as output } from "node:process";
32
+ import { createInterface } from "node:readline/promises";
33
+ var UI_API_KEY_URL = `${DEFAULT_OPENPOND_WEB_BASE_URL}/settings/api-keys`;
34
+ function resolveApiKey(config) {
35
+ const envKey = process.env.OPENPOND_API_KEY?.trim();
36
+ if (envKey) return envKey;
37
+ const stored = config.apiKey?.trim();
38
+ if (stored) return stored;
39
+ const legacy = config.token?.trim();
40
+ if (legacy && legacy.startsWith("opk_")) return legacy;
41
+ return null;
42
+ }
43
+ async function promptForApiKey() {
44
+ if (!input.isTTY || !output.isTTY) {
45
+ throw new Error(
46
+ "OpenPond API key is required in non-interactive mode. Set OPENPOND_API_KEY or run `openpond login` in a terminal."
47
+ );
48
+ }
49
+ console.log("Open the OpenPond UI to create an API key:");
50
+ console.log(UI_API_KEY_URL);
51
+ const rl = createInterface({ input, output });
52
+ try {
53
+ const value = (await rl.question("Paste your OpenPond API key: ")).trim();
54
+ if (!value) {
55
+ throw new Error("API key is required");
56
+ }
57
+ if (!value.startsWith("opk_")) {
58
+ console.log("warning: API keys usually start with opk_.");
59
+ }
60
+ return value;
61
+ } finally {
62
+ rl.close();
63
+ }
64
+ }
65
+ async function ensureApiKey(config, baseUrl) {
66
+ const existing = resolveApiKey(config);
67
+ if (existing) return existing;
68
+ const apiKey = await promptForApiKey();
69
+ await saveGlobalConfig({
70
+ apiKey,
71
+ baseUrl,
72
+ activeProfile: config.activeProfile
73
+ });
74
+ console.log("saved api key to ~/.openpond/config.json");
75
+ return apiKey;
76
+ }
77
+
78
+ // src/cli/common/repo-format.ts
79
+ function resolveRepoUrl(response) {
80
+ if (response.repoUrl) return response.repoUrl;
81
+ if (response.gitHost && response.gitOwner && response.gitRepo) {
82
+ return `https://${response.gitHost}/${response.gitOwner}/${response.gitRepo}.git`;
83
+ }
84
+ throw new Error("repoUrl missing from API response");
85
+ }
86
+ function formatTokenizedRepoUrl(repoUrl, token) {
87
+ const url = new URL(repoUrl);
88
+ const encodedToken = encodeURIComponent(token);
89
+ return `${url.protocol}//x-access-token:${encodedToken}@${url.host}${url.pathname}`;
90
+ }
91
+ function formatTokenizedRepoUrlForPrint(repoUrl) {
92
+ const url = new URL(repoUrl);
93
+ return `${url.protocol}//x-access-token:$OPENPOND_API_KEY@${url.host}${url.pathname}`;
94
+ }
95
+ function redactToken(value) {
96
+ return value.replace(/x-access-token:[^@]+@/g, "x-access-token:***@");
97
+ }
98
+ function warnOnRepoHostMismatch(repoUrl) {
99
+ const envBase = process.env.OPENPOND_BASE_URL;
100
+ if (!envBase) return;
101
+ try {
102
+ const baseHost = new URL(envBase).hostname;
103
+ const repoHost = new URL(repoUrl).hostname;
104
+ if (baseHost && repoHost && baseHost !== repoHost) {
105
+ console.warn(
106
+ `warning: repo host (${repoHost}) does not match OPENPOND_BASE_URL (${baseHost})`
107
+ );
108
+ console.warn(
109
+ "warning: verify your git host configuration matches OPENPOND_BASE_URL."
110
+ );
111
+ }
112
+ } catch {
113
+ }
114
+ }
115
+ function parseHandleRepo(value) {
116
+ const parts = value.split("/").filter(Boolean);
117
+ if (parts.length !== 2) {
118
+ throw new Error("expected <handle>/<repo>");
119
+ }
120
+ return { handle: parts[0], repo: parts[1] };
121
+ }
122
+ function normalizeRepoName(value) {
123
+ return (value || "").trim().toLowerCase();
124
+ }
125
+
126
+ // src/cli/common/cache.ts
127
+ async function fetchAppsWithCache(params) {
128
+ if (!params.forceRefresh) {
129
+ const cached = await getCachedApps({
130
+ apiBase: params.apiBase,
131
+ apiKey: params.apiKey,
132
+ ttlMs: DEFAULT_CACHE_TTL_MS
133
+ });
134
+ if (cached) {
135
+ return cached;
136
+ }
137
+ }
138
+ const apps = await listApps(params.apiBase, params.apiKey);
139
+ await setCachedApps({
140
+ apiBase: params.apiBase,
141
+ apiKey: params.apiKey,
142
+ apps
143
+ });
144
+ return apps;
145
+ }
146
+ async function fetchToolsWithCache(params) {
147
+ if (!params.forceRefresh) {
148
+ const cached = await getCachedTools({
149
+ apiBase: params.apiBase,
150
+ apiKey: params.apiKey,
151
+ ttlMs: DEFAULT_CACHE_TTL_MS
152
+ });
153
+ if (cached) {
154
+ return cached;
155
+ }
156
+ }
157
+ const result = await listUserTools(params.apiBase, params.apiKey);
158
+ const tools = Array.isArray(result.tools) ? result.tools : [];
159
+ await setCachedTools({
160
+ apiBase: params.apiBase,
161
+ apiKey: params.apiKey,
162
+ tools
163
+ });
164
+ return tools;
165
+ }
166
+ async function resolveAppTarget(apiBase, apiKey, target) {
167
+ const { handle, repo } = parseHandleRepo(target);
168
+ const apps = await fetchAppsWithCache({ apiBase, apiKey });
169
+ const normalizedRepo = normalizeRepoName(repo);
170
+ const match = apps.find((app) => {
171
+ if (app.handle && app.handle !== handle) {
172
+ return false;
173
+ }
174
+ const candidates = [app.repo, app.gitRepo, app.id].map(normalizeRepoName);
175
+ return candidates.includes(normalizedRepo);
176
+ });
177
+ if (!match) {
178
+ throw new Error(`app not found for ${handle}/${repo}`);
179
+ }
180
+ return { app: match, handle, repo };
181
+ }
182
+ async function pollDeploymentLogs(params) {
183
+ const intervalMs = params.intervalMs ?? 5e3;
184
+ const timeoutMs = params.timeoutMs ?? 4 * 60 * 1e3;
185
+ const seen = /* @__PURE__ */ new Set();
186
+ const startedAt = Date.now();
187
+ while (Date.now() - startedAt < timeoutMs) {
188
+ const logs = await getDeploymentLogs(
189
+ params.baseUrl,
190
+ params.apiKey,
191
+ params.deploymentId
192
+ );
193
+ const newLogs = logs.filter((log) => !seen.has(log.id));
194
+ for (const log of newLogs) {
195
+ seen.add(log.id);
196
+ }
197
+ for (const log of newLogs) {
198
+ console.log(`${params.prefix}${log.message}`);
199
+ }
200
+ const status = await getDeploymentStatus(
201
+ params.baseUrl,
202
+ params.apiKey,
203
+ params.deploymentId
204
+ );
205
+ if (status.status === "failed") {
206
+ console.log(`${params.prefix}deployment failed`);
207
+ return;
208
+ }
209
+ if (status.status === "running" || status.status === "deployed") {
210
+ console.log(`${params.prefix}deployment complete`);
211
+ return;
212
+ }
213
+ await new Promise((resolve) => setTimeout(resolve, intervalMs));
214
+ }
215
+ console.log(`${params.prefix}deployment still in progress`);
216
+ }
217
+
218
+ // src/cli/common/prompts.ts
219
+ import { stdin as input2, stdout as output2 } from "node:process";
220
+ import { createInterface as createInterface2 } from "node:readline/promises";
221
+ async function readAllStdin() {
222
+ const chunks = [];
223
+ for await (const chunk of process.stdin) {
224
+ chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk)));
225
+ }
226
+ return Buffer.concat(chunks).toString("utf8").replace(/\r?\n$/, "");
227
+ }
228
+ function readMaskedLine(prompt) {
229
+ return new Promise((resolve, reject) => {
230
+ const stdin = process.stdin;
231
+ const stderr = process.stderr;
232
+ let value = "";
233
+ const wasRaw = stdin.isRaw;
234
+ function cleanup() {
235
+ stdin.off("data", onData);
236
+ if (stdin.setRawMode) stdin.setRawMode(wasRaw);
237
+ stdin.pause();
238
+ stderr.write("\n");
239
+ }
240
+ function onData(chunk) {
241
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
242
+ for (const byte of buffer) {
243
+ if (byte === 3) {
244
+ cleanup();
245
+ reject(new Error("secret prompt cancelled"));
246
+ return;
247
+ }
248
+ if (byte === 13 || byte === 10) {
249
+ cleanup();
250
+ resolve(value);
251
+ return;
252
+ }
253
+ if (byte === 127 || byte === 8) {
254
+ if (value.length > 0) {
255
+ value = value.slice(0, -1);
256
+ stderr.write("\b \b");
257
+ }
258
+ continue;
259
+ }
260
+ value += Buffer.from([byte]).toString("utf8");
261
+ stderr.write("*");
262
+ }
263
+ }
264
+ stderr.write(prompt);
265
+ stdin.resume();
266
+ if (stdin.setRawMode) stdin.setRawMode(true);
267
+ stdin.on("data", onData);
268
+ });
269
+ }
270
+ async function promptConfirm(question, defaultValue = false) {
271
+ const rl = createInterface2({ input: input2, output: output2 });
272
+ try {
273
+ const suffix = defaultValue ? "[Y/n]" : "[y/N]";
274
+ const answer = (await rl.question(`${question} ${suffix} `)).trim().toLowerCase();
275
+ if (!answer) return defaultValue;
276
+ return answer === "y" || answer === "yes";
277
+ } finally {
278
+ rl.close();
279
+ }
280
+ }
281
+ async function promptForPath(defaultPath) {
282
+ const rl = createInterface2({ input: input2, output: output2 });
283
+ try {
284
+ const answer = (await rl.question(`Local path (default: ${defaultPath}): `)).trim();
285
+ return answer || defaultPath;
286
+ } finally {
287
+ rl.close();
288
+ }
289
+ }
290
+
291
+ // src/cli/common/sandbox-options.ts
292
+ var SANDBOX_WORKFLOW_MODES = [
293
+ "readonly",
294
+ "attempt",
295
+ "feature",
296
+ "rollout",
297
+ "replay",
298
+ "template_build",
299
+ "scheduled_run",
300
+ "patch_only",
301
+ "hotfix",
302
+ "multi_feature_batch"
303
+ ];
304
+ var SANDBOX_RUNTIME_PROMOTION_POLICIES = ["none", "manual", "auto_after_checks"];
305
+ var SANDBOX_RUNTIME_PROFILES = [
306
+ ...SANDBOX_RUNTIME_PROFILE_IDS
307
+ ];
308
+ function resolveSandboxBaseUrl(config, options) {
309
+ const envName = typeof options.env === "string" ? options.env.trim().toLowerCase() : typeof options.environment === "string" ? options.environment.trim().toLowerCase() : "";
310
+ if (envName === "staging") {
311
+ return "https://api-new.staging-api.openpond.ai";
312
+ }
313
+ if (envName && envName !== "production") {
314
+ throw new Error("sandbox env must be staging or production");
315
+ }
316
+ const base = process.env.OPENPOND_SANDBOX_BASE_URL || process.env.OPENPOND_API_URL || config.apiBaseUrl || mapUiBaseToApiBase(process.env.OPENPOND_BASE_URL || config.baseUrl) || DEFAULT_OPENPOND_API_BASE_URL;
317
+ return base.replace(/\/$/, "");
318
+ }
319
+ async function resolveSandboxClient(options) {
320
+ const config = await loadConfig();
321
+ const uiBase = resolveBaseUrl(config);
322
+ const apiKey = await ensureApiKey(config, uiBase);
323
+ const sandboxApiUrl = resolveSandboxApiUrlOption(options) || process.env.OPENPOND_SANDBOX_API_URL?.trim() || null;
324
+ return createOpenPondSandboxClient(
325
+ sandboxApiUrl ? { apiKey, sandboxApiUrl } : { apiKey, baseUrl: resolveSandboxBaseUrl(config, options) }
326
+ );
327
+ }
328
+ function parseSandboxWorkflowModeOption(value) {
329
+ if (value === void 0) return void 0;
330
+ if (typeof value !== "string" || !value.trim()) {
331
+ throw new Error("workflow-mode must be a non-empty value");
332
+ }
333
+ const mode = value.trim();
334
+ if (!SANDBOX_WORKFLOW_MODES.includes(mode)) {
335
+ throw new Error(
336
+ `workflow-mode must be one of ${SANDBOX_WORKFLOW_MODES.join(", ")}`
337
+ );
338
+ }
339
+ return mode;
340
+ }
341
+ function parseSandboxRuntimePromotionPolicyOption(value) {
342
+ if (value === void 0) return void 0;
343
+ if (typeof value !== "string" || !value.trim()) {
344
+ throw new Error("runtime-promotion-policy must be a non-empty value");
345
+ }
346
+ const policy = value.trim();
347
+ if (!SANDBOX_RUNTIME_PROMOTION_POLICIES.includes(policy)) {
348
+ throw new Error(
349
+ `runtime-promotion-policy must be one of ${SANDBOX_RUNTIME_PROMOTION_POLICIES.join(
350
+ ", "
351
+ )}`
352
+ );
353
+ }
354
+ return policy;
355
+ }
356
+ function parseSandboxRuntimeProfileIdOption(value) {
357
+ if (typeof value !== "string" || !value.trim()) return void 0;
358
+ const runtimeProfileId = value.trim();
359
+ if (!SANDBOX_RUNTIME_PROFILES.includes(runtimeProfileId)) {
360
+ throw new Error(
361
+ `runtime-profile-id must be one of ${SANDBOX_RUNTIME_PROFILES.join(
362
+ ", "
363
+ )}`
364
+ );
365
+ }
366
+ return runtimeProfileId;
367
+ }
368
+ function parseSandboxEnvOptions(options) {
369
+ const refs = parseSandboxEnvAssignments(options.envRef, "env-ref").map(
370
+ ({ name, value }) => ({ name, secretRef: value })
371
+ );
372
+ const literals = parseSandboxEnvAssignments(
373
+ options.envLiteral,
374
+ "env-literal"
375
+ ).map(({ name, value }) => {
376
+ if (isSecretLikeEnvName(name) && !parseBooleanOption(options.allowPlainSecretEnv)) {
377
+ throw new Error(
378
+ `refusing plaintext value for secret-like env ${name}; create a sandbox secret and pass --env-ref ${name}=openpond://secret/...`
379
+ );
380
+ }
381
+ return { name, value };
382
+ });
383
+ const env = [...refs, ...literals];
384
+ const names = /* @__PURE__ */ new Set();
385
+ for (const item of env) {
386
+ if (names.has(item.name)) {
387
+ throw new Error(`duplicate sandbox env var: ${item.name}`);
388
+ }
389
+ names.add(item.name);
390
+ }
391
+ return env;
392
+ }
393
+ function parseSandboxTemplateEnvOptions(manifest, options) {
394
+ const env = parseSandboxEnvOptions(options);
395
+ const provided = new Set(env.map((item) => item.name));
396
+ const providedByName = new Map(env.map((item) => [item.name, item]));
397
+ for (const requirement of manifest.inputs.env) {
398
+ const value = providedByName.get(requirement.name);
399
+ if (value?.value !== void 0 && requirement.secret !== false) {
400
+ throw new Error(
401
+ `sandbox template env ${requirement.name} requires a secret ref. Pass --env-ref ${requirement.name}=openpond://secret/...`
402
+ );
403
+ }
404
+ }
405
+ const missing = manifest.inputs.env.filter((item) => item.required && !provided.has(item.name)).map((item) => item.name);
406
+ if (missing.length > 0) {
407
+ throw new Error(
408
+ `missing required sandbox template env refs: ${missing.join(
409
+ ", "
410
+ )}. Pass --env-ref NAME=openpond://secret/...`
411
+ );
412
+ }
413
+ return env;
414
+ }
415
+ function parseSandboxEnvAssignments(value, label) {
416
+ if (typeof value !== "string") return [];
417
+ return value.split(",").map((item) => item.trim()).filter(Boolean).map((item) => {
418
+ const separator = item.indexOf("=");
419
+ if (separator <= 0) {
420
+ throw new Error(`${label} entries must use NAME=value`);
421
+ }
422
+ const name = item.slice(0, separator).trim();
423
+ const entryValue = item.slice(separator + 1).trim();
424
+ if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(name)) {
425
+ throw new Error(`${label} has invalid env name: ${name}`);
426
+ }
427
+ if (!entryValue) {
428
+ throw new Error(`${label} value is required for ${name}`);
429
+ }
430
+ return { name, value: entryValue };
431
+ });
432
+ }
433
+ function isSecretLikeEnvName(name) {
434
+ return /(?:SECRET|TOKEN|KEY|PASSWORD|PASSWD|PRIVATE|CREDENTIAL|DATABASE_URL|DSN)/i.test(
435
+ name
436
+ );
437
+ }
438
+ async function readSandboxSecretValue(options, label) {
439
+ if (typeof options.value === "string" || typeof options.secretValue === "string") {
440
+ throw new Error(
441
+ "sandbox secret values must be provided with --stdin or the masked prompt"
442
+ );
443
+ }
444
+ const useStdin = parseBooleanOption(options.stdin);
445
+ if (useStdin) {
446
+ const value2 = await readAllStdin();
447
+ if (!value2) throw new Error(`${label} read no secret value from stdin`);
448
+ return value2;
449
+ }
450
+ if (!process.stdin.isTTY) {
451
+ throw new Error(`${label} requires --stdin when not running in a TTY`);
452
+ }
453
+ const value = await readMaskedLine(`${label}: `);
454
+ if (!value) throw new Error(`${label} cannot be empty`);
455
+ return value;
456
+ }
457
+ function summarizeSandboxSecret(secret) {
458
+ return {
459
+ id: secret.id,
460
+ teamId: secret.teamId,
461
+ name: secret.name,
462
+ scope: secret.scope,
463
+ status: secret.status,
464
+ secretRef: secret.secretRef,
465
+ currentVersion: secret.currentVersion,
466
+ updatedAt: secret.updatedAt,
467
+ lastUsedAt: secret.lastUsedAt,
468
+ attachedDestinations: secret.attachments?.length ?? 0
469
+ };
470
+ }
471
+
472
+ // ../../packages/cloud/src/process-runner.ts
473
+ import { Buffer as Buffer2 } from "node:buffer";
474
+ import { spawn } from "node:child_process";
475
+ var DEFAULT_PROCESS_TIMEOUT_MS = 10 * 60 * 1e3;
476
+ var DEFAULT_PROCESS_MAX_OUTPUT_BYTES = 2 * 1024 * 1024;
477
+ function runProcessCommand(command, args = [], options = {}) {
478
+ if (options.inherit && options.terminateWhenStdoutIncludes !== void 0) {
479
+ return Promise.reject(new Error("terminateWhenStdoutIncludes requires captured stdout"));
480
+ }
481
+ if (options.terminateWhenStdoutIncludes === "") {
482
+ return Promise.reject(new Error("terminateWhenStdoutIncludes must not be empty"));
483
+ }
484
+ return new Promise((resolve, reject) => {
485
+ const proc = spawn(command, args, {
486
+ cwd: options.cwd,
487
+ env: options.env ? { ...process.env, ...options.env } : void 0,
488
+ shell: options.shell,
489
+ detached: options.detached ?? process.platform !== "win32",
490
+ stdio: options.inherit ? "inherit" : [options.stdin === void 0 ? "ignore" : "pipe", "pipe", "pipe"]
491
+ });
492
+ const stdout = new BoundedOutput(maxOutputBytes(options));
493
+ const stderr = new BoundedOutput(maxOutputBytes(options));
494
+ let timedOut = false;
495
+ const timeoutMs = options.timeoutMs ?? DEFAULT_PROCESS_TIMEOUT_MS;
496
+ let timeout;
497
+ let forceKill;
498
+ let requestedTermination = null;
499
+ let settled = false;
500
+ const clearTimers = () => {
501
+ if (timeout) clearTimeout(timeout);
502
+ if (forceKill) clearTimeout(forceKill);
503
+ };
504
+ const requestTermination = (reason) => {
505
+ if (requestedTermination !== null || settled) return;
506
+ requestedTermination = reason;
507
+ timedOut = reason === "timeout";
508
+ if (timeout) {
509
+ clearTimeout(timeout);
510
+ timeout = void 0;
511
+ }
512
+ terminateProcessTree(proc.pid, "SIGTERM");
513
+ forceKill = setTimeout(() => {
514
+ if (proc.exitCode === null && proc.signalCode === null) terminateProcessTree(proc.pid, "SIGKILL");
515
+ }, 5e3);
516
+ };
517
+ if (timeoutMs > 0) {
518
+ timeout = setTimeout(() => {
519
+ requestTermination("timeout");
520
+ }, timeoutMs);
521
+ }
522
+ if (!options.inherit) {
523
+ proc.stdout?.on("data", (chunk) => {
524
+ stdout.append(chunk);
525
+ const marker = options.terminateWhenStdoutIncludes;
526
+ if (marker !== void 0 && stdout.text().includes(marker)) {
527
+ requestTermination("output");
528
+ }
529
+ });
530
+ proc.stderr?.on("data", (chunk) => {
531
+ stderr.append(chunk);
532
+ });
533
+ }
534
+ proc.on("error", (error) => {
535
+ clearTimers();
536
+ settled = true;
537
+ reject(error);
538
+ });
539
+ proc.on("close", (code, signal) => {
540
+ if (settled) return;
541
+ settled = true;
542
+ clearTimers();
543
+ resolve({
544
+ code,
545
+ signal,
546
+ terminationReason: requestedTermination ?? (signal ? "signal" : "exit"),
547
+ stdout: stdout.text(),
548
+ stderr: stderr.text(),
549
+ timedOut,
550
+ stdoutTruncated: stdout.truncated,
551
+ stderrTruncated: stderr.truncated
552
+ });
553
+ });
554
+ if (options.stdin !== void 0) {
555
+ proc.stdin?.end(options.stdin);
556
+ }
557
+ });
558
+ }
559
+ var BoundedOutput = class {
560
+ #chunks = [];
561
+ #maxBytes;
562
+ #bytes = 0;
563
+ truncated = false;
564
+ constructor(maxBytes) {
565
+ this.#maxBytes = maxBytes;
566
+ }
567
+ append(value) {
568
+ const chunk = Buffer2.isBuffer(value) ? value : Buffer2.from(value);
569
+ const remaining = this.#maxBytes - this.#bytes;
570
+ if (remaining <= 0) {
571
+ if (chunk.byteLength > 0) this.truncated = true;
572
+ return;
573
+ }
574
+ if (chunk.byteLength <= remaining) {
575
+ this.#chunks.push(chunk);
576
+ this.#bytes += chunk.byteLength;
577
+ return;
578
+ }
579
+ this.#chunks.push(chunk.subarray(0, remaining));
580
+ this.#bytes += remaining;
581
+ this.truncated = true;
582
+ }
583
+ text() {
584
+ const value = Buffer2.concat(this.#chunks, this.#bytes).toString("utf8");
585
+ return this.truncated ? `${value}
586
+ [truncated after ${this.#maxBytes} bytes]
587
+ ` : value;
588
+ }
589
+ };
590
+ function maxOutputBytes(options) {
591
+ const value = options.maxOutputBytes ?? DEFAULT_PROCESS_MAX_OUTPUT_BYTES;
592
+ return Math.max(0, Math.floor(value));
593
+ }
594
+ function terminateProcessTree(pid, signal) {
595
+ if (!pid) return;
596
+ if (process.platform === "win32") {
597
+ const args = ["/PID", String(pid), "/T"];
598
+ if (signal === "SIGKILL") args.push("/F");
599
+ const killer = spawn("taskkill", args, { stdio: "ignore", windowsHide: true });
600
+ killer.unref();
601
+ return;
602
+ }
603
+ try {
604
+ process.kill(-pid, signal);
605
+ } catch (error) {
606
+ if (error.code !== "ESRCH") throw error;
607
+ }
608
+ }
609
+
610
+ // src/cli/common/shell.ts
611
+ async function runCommand(command, args, options = {}) {
612
+ return runProcessCommand(command, args, {
613
+ cwd: options.cwd,
614
+ inherit: options.inherit,
615
+ timeoutMs: options.timeoutMs,
616
+ maxOutputBytes: options.maxOutputBytes,
617
+ terminateWhenStdoutIncludes: options.terminateWhenStdoutIncludes
618
+ });
619
+ }
620
+ async function runShellCommand(command, options = {}) {
621
+ const timeoutMs = options.timeoutSeconds === void 0 ? void 0 : options.timeoutSeconds * 1e3;
622
+ return runProcessCommand(command, [], {
623
+ cwd: options.cwd,
624
+ env: options.env,
625
+ shell: true,
626
+ inherit: options.inherit,
627
+ timeoutMs,
628
+ maxOutputBytes: options.maxOutputBytes
629
+ });
630
+ }
631
+ async function getGitRemoteUrl(cwd, remoteName) {
632
+ const result = await runCommand("git", ["remote", "get-url", remoteName], {
633
+ cwd
634
+ });
635
+ if (result.code !== 0) return null;
636
+ const url = result.stdout.trim();
637
+ return url.length > 0 ? url : null;
638
+ }
639
+
640
+ export {
641
+ resolveApiKey,
642
+ promptForApiKey,
643
+ ensureApiKey,
644
+ resolveRepoUrl,
645
+ formatTokenizedRepoUrl,
646
+ formatTokenizedRepoUrlForPrint,
647
+ redactToken,
648
+ warnOnRepoHostMismatch,
649
+ normalizeRepoName,
650
+ fetchAppsWithCache,
651
+ fetchToolsWithCache,
652
+ resolveAppTarget,
653
+ pollDeploymentLogs,
654
+ promptConfirm,
655
+ promptForPath,
656
+ resolveSandboxClient,
657
+ parseSandboxWorkflowModeOption,
658
+ parseSandboxRuntimePromotionPolicyOption,
659
+ parseSandboxRuntimeProfileIdOption,
660
+ parseSandboxEnvOptions,
661
+ parseSandboxTemplateEnvOptions,
662
+ readSandboxSecretValue,
663
+ summarizeSandboxSecret,
664
+ runProcessCommand,
665
+ runCommand,
666
+ runShellCommand,
667
+ getGitRemoteUrl
668
+ };
@@ -4,7 +4,7 @@ import {
4
4
  listOpChatModels,
5
5
  sendHostedChatTurn,
6
6
  streamHostedChatTurn
7
- } from "./chunk-G6WW2656.js";
7
+ } from "./chunk-HLCTINEP.js";
8
8
 
9
9
  // ../../packages/cloud/src/opchat-smoke.ts
10
10
  var DEFAULT_MODEL = "openpond-chat";