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,598 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import {
3
+ checkOpenPondApiHealth,
4
+ createHeadlessApps,
5
+ createRepo,
6
+ deployLatestTemplate,
7
+ ensureApiKey,
8
+ executeHostedTool,
9
+ fetchAppsWithCache,
10
+ formatTokenizedRepoUrl,
11
+ formatTokenizedRepoUrlForPrint,
12
+ getDeploymentDetail,
13
+ getGitRemoteUrl,
14
+ getLatestDeploymentForApp,
15
+ getOpenPondAccount,
16
+ getTemplateStatus,
17
+ listConfiguredProfiles,
18
+ listTemplateBranches,
19
+ loadConfig,
20
+ pollDeploymentLogs,
21
+ promptConfirm,
22
+ promptForApiKey,
23
+ promptForPath,
24
+ redactToken,
25
+ resolveApiKey,
26
+ resolveAppTarget,
27
+ resolveRepoUrl,
28
+ runCommand,
29
+ saveProfileApiKey,
30
+ setActiveProfile,
31
+ submitBacktestRun,
32
+ warnOnRepoHostMismatch
33
+ } from "./chunk-XSAXENQD.js";
34
+ import {
35
+ normalizeTemplateRepoUrl,
36
+ resolveApiBaseUrlOption,
37
+ resolveBaseUrl,
38
+ resolveBaseUrlOption,
39
+ resolveChatApiBaseUrlOption,
40
+ resolvePublicApiBaseUrl
41
+ } from "./chunk-5G4E547X.js";
42
+ import {
43
+ compareSemver,
44
+ fetchLatestNpmVersion,
45
+ getInstalledCliVersion,
46
+ parseBooleanOption,
47
+ parseJsonOption,
48
+ resolveTemplateEnvironment
49
+ } from "./chunk-3Y4EL3P6.js";
50
+
51
+ // src/cli/core-commands.ts
52
+ import { promises as fs, existsSync } from "node:fs";
53
+ import path from "node:path";
54
+ import { stdin as input } from "node:process";
55
+ async function runTemplateStatus(_options, target) {
56
+ const config = await loadConfig();
57
+ const uiBase = resolveBaseUrl(config);
58
+ const apiBase = resolvePublicApiBaseUrl(config);
59
+ const apiKey = await ensureApiKey(config, uiBase);
60
+ const { app } = await resolveAppTarget(apiBase, apiKey, target);
61
+ const status = await getTemplateStatus(apiBase, apiKey, app.id);
62
+ console.log(JSON.stringify(status, null, 2));
63
+ }
64
+ async function runTemplateBranches(_options, target) {
65
+ const config = await loadConfig();
66
+ const uiBase = resolveBaseUrl(config);
67
+ const apiBase = resolvePublicApiBaseUrl(config);
68
+ const apiKey = await ensureApiKey(config, uiBase);
69
+ const { app } = await resolveAppTarget(apiBase, apiKey, target);
70
+ const branches = await listTemplateBranches(apiBase, apiKey, app.id);
71
+ console.log(JSON.stringify(branches, null, 2));
72
+ }
73
+ async function runTemplateUpdate(options, target) {
74
+ const config = await loadConfig();
75
+ const uiBase = resolveBaseUrl(config);
76
+ const apiBase = resolvePublicApiBaseUrl(config);
77
+ const apiKey = await ensureApiKey(config, uiBase);
78
+ const { app } = await resolveAppTarget(apiBase, apiKey, target);
79
+ const envRaw = typeof options.env === "string" ? options.env : typeof options.environment === "string" ? options.environment : void 0;
80
+ const environment = resolveTemplateEnvironment(envRaw);
81
+ const result = await deployLatestTemplate(apiBase, apiKey, app.id, {
82
+ environment
83
+ });
84
+ console.log(JSON.stringify(result, null, 2));
85
+ }
86
+ async function runLogin(options) {
87
+ const config = await loadConfig();
88
+ const baseUrl = resolveBaseUrl(config);
89
+ const rawApiKey = typeof options.apiKey === "string" ? options.apiKey : typeof options.key === "string" ? options.key : null;
90
+ const apiKey = rawApiKey ? rawApiKey.trim() : await promptForApiKey();
91
+ if (!apiKey) {
92
+ throw new Error("API key is required");
93
+ }
94
+ if (!apiKey.startsWith("opk_")) {
95
+ console.log("warning: API keys usually start with opk_.");
96
+ }
97
+ await saveProfileApiKey({
98
+ handle: config.activeProfile?.handle || "default",
99
+ apiKey,
100
+ baseUrl,
101
+ apiBaseUrl: config.apiBaseUrl,
102
+ chatApiBaseUrl: config.chatApiBaseUrl,
103
+ setActive: true
104
+ });
105
+ console.log("saved api key to ~/.openpond/config.json");
106
+ }
107
+ async function runProfiles(options, rest) {
108
+ const subcommand = rest[0] || "list";
109
+ if (subcommand === "list") {
110
+ const profiles = await listConfiguredProfiles();
111
+ console.log(JSON.stringify({ profiles }, null, 2));
112
+ return;
113
+ }
114
+ if (subcommand === "use") {
115
+ const handle = rest[1];
116
+ if (!handle) {
117
+ throw new Error("usage: profiles use <name> [--base-url <url>]");
118
+ }
119
+ const profile = await setActiveProfile(handle, {
120
+ baseUrl: resolveBaseUrlOption(options)
121
+ });
122
+ console.log(JSON.stringify({ profile }, null, 2));
123
+ return;
124
+ }
125
+ if (subcommand === "save") {
126
+ const handle = rest[1];
127
+ if (!handle) {
128
+ throw new Error(
129
+ "usage: profiles save <name> --api-key <key> [--base-url <url>] [--api-base-url <url>] [--chat-api-base-url <url>]"
130
+ );
131
+ }
132
+ const rawApiKey = typeof options.apiKey === "string" ? options.apiKey : typeof options.key === "string" ? options.key : null;
133
+ const apiKey = rawApiKey ? rawApiKey.trim() : await promptForApiKey();
134
+ const environment = typeof options.environment === "string" ? options.environment : typeof options.env === "string" ? options.env : void 0;
135
+ const profile = await saveProfileApiKey({
136
+ handle,
137
+ apiKey,
138
+ baseUrl: resolveBaseUrlOption(options),
139
+ apiBaseUrl: resolveApiBaseUrlOption(options),
140
+ chatApiBaseUrl: resolveChatApiBaseUrlOption(options),
141
+ environment,
142
+ setActive: true
143
+ });
144
+ console.log(JSON.stringify({ profile }, null, 2));
145
+ return;
146
+ }
147
+ throw new Error("usage: profiles <list|use|save> [args]");
148
+ }
149
+ async function runAccount() {
150
+ const config = await loadConfig();
151
+ const uiBase = resolveBaseUrl(config);
152
+ const apiBase = resolvePublicApiBaseUrl(config);
153
+ const apiKey = await ensureApiKey(config, uiBase);
154
+ const account = await getOpenPondAccount(apiBase, apiKey);
155
+ console.log(JSON.stringify(account, null, 2));
156
+ }
157
+ async function runHealth(_options) {
158
+ const config = await loadConfig();
159
+ const apiBase = resolvePublicApiBaseUrl(config);
160
+ const apiKey = resolveApiKey(config);
161
+ const health = await checkOpenPondApiHealth(apiBase, apiKey);
162
+ console.log(JSON.stringify(health, null, 2));
163
+ }
164
+ async function runToolList(options, target) {
165
+ const config = await loadConfig();
166
+ const uiBase = resolveBaseUrl(config);
167
+ const apiBase = resolvePublicApiBaseUrl(config);
168
+ const apiKey = await ensureApiKey(config, uiBase);
169
+ const { app } = await resolveAppTarget(apiBase, apiKey, target);
170
+ const branch = typeof options.branch === "string" ? String(options.branch) : void 0;
171
+ const latest = await getLatestDeploymentForApp(apiBase, apiKey, app.id, {
172
+ branch
173
+ });
174
+ if (!latest?.id) {
175
+ console.log("no deployments found");
176
+ return;
177
+ }
178
+ const detail = await getDeploymentDetail(apiBase, apiKey, latest.id);
179
+ const toolsRaw = (detail && Array.isArray(detail.toolsJson) ? detail.toolsJson : null) || (detail && typeof detail.metadataJson === "object" && detail.metadataJson ? detail.metadataJson.tools : null);
180
+ const tools = Array.isArray(toolsRaw) ? toolsRaw : [];
181
+ if (tools.length === 0) {
182
+ console.log("no tools found");
183
+ return;
184
+ }
185
+ for (const tool of tools) {
186
+ const record = tool;
187
+ const profile = record.profile || record.function;
188
+ const name = record.name || profile?.name || "unknown";
189
+ const description = record.description || profile?.description || "";
190
+ console.log(description ? `${name} - ${description}` : name);
191
+ }
192
+ }
193
+ async function runToolRun(options, target, toolName) {
194
+ const config = await loadConfig();
195
+ const uiBase = resolveBaseUrl(config);
196
+ const apiBase = resolvePublicApiBaseUrl(config);
197
+ const apiKey = await ensureApiKey(config, uiBase);
198
+ const { app } = await resolveAppTarget(apiBase, apiKey, target);
199
+ const branch = typeof options.branch === "string" ? String(options.branch) : void 0;
200
+ const latest = await getLatestDeploymentForApp(apiBase, apiKey, app.id, {
201
+ branch
202
+ });
203
+ if (!latest?.id) {
204
+ throw new Error("no deployments found");
205
+ }
206
+ let body = void 0;
207
+ if (typeof options.body === "string") {
208
+ try {
209
+ body = JSON.parse(options.body);
210
+ } catch {
211
+ throw new Error("tool body must be valid JSON");
212
+ }
213
+ }
214
+ const method = typeof options.method === "string" ? String(options.method).toUpperCase() : "POST";
215
+ const result = await executeHostedTool(uiBase, apiKey, {
216
+ appId: app.id,
217
+ deploymentId: latest.id,
218
+ toolName,
219
+ method,
220
+ body,
221
+ headers: apiKey ? { "openpond-api-key": apiKey } : void 0
222
+ });
223
+ if (!result.ok) {
224
+ throw new Error(result.error || `tool failed (${result.status})`);
225
+ }
226
+ const output = result.data ?? { ok: true };
227
+ console.log(JSON.stringify(output, null, 2));
228
+ }
229
+ async function runBacktestRun(options, target, toolName) {
230
+ const config = await loadConfig();
231
+ const uiBase = resolveBaseUrl(config);
232
+ const apiBase = resolvePublicApiBaseUrl(config);
233
+ const apiKey = await ensureApiKey(config, uiBase);
234
+ const { app } = await resolveAppTarget(apiBase, apiKey, target);
235
+ const branch = typeof options.branch === "string" ? String(options.branch) : void 0;
236
+ const deploymentId = typeof options.deploymentId === "string" ? String(options.deploymentId) : void 0;
237
+ const latest = deploymentId ? { id: deploymentId } : await getLatestDeploymentForApp(apiBase, apiKey, app.id, { branch });
238
+ if (!latest?.id) {
239
+ throw new Error("no deployments found");
240
+ }
241
+ const bodyRaw = typeof options.body === "string" ? parseJsonOption(String(options.body), "body") : {};
242
+ if (!bodyRaw || typeof bodyRaw !== "object" || Array.isArray(bodyRaw)) {
243
+ throw new Error("body must be a JSON object");
244
+ }
245
+ const method = typeof options.method === "string" ? String(options.method).toUpperCase() : "POST";
246
+ const payload = {
247
+ ...bodyRaw,
248
+ appId: app.id,
249
+ deploymentId: latest.id,
250
+ toolName,
251
+ method
252
+ };
253
+ const result = await submitBacktestRun(apiBase, apiKey, payload);
254
+ console.log(JSON.stringify(result, null, 2));
255
+ }
256
+ async function runDeployWatch(options, target) {
257
+ const config = await loadConfig();
258
+ const uiBase = resolveBaseUrl(config);
259
+ const apiBase = resolvePublicApiBaseUrl(config);
260
+ const apiKey = await ensureApiKey(config, uiBase);
261
+ const { app, handle, repo } = await resolveAppTarget(apiBase, apiKey, target);
262
+ const branch = typeof options.branch === "string" ? String(options.branch) : void 0;
263
+ const deploymentId = typeof options.deploymentId === "string" ? String(options.deploymentId) : void 0;
264
+ const latest = deploymentId ? { id: deploymentId } : await getLatestDeploymentForApp(apiBase, apiKey, app.id, {
265
+ branch
266
+ });
267
+ if (!latest?.id) {
268
+ console.log("no deployments found");
269
+ return;
270
+ }
271
+ await pollDeploymentLogs({
272
+ baseUrl: apiBase,
273
+ apiKey,
274
+ deploymentId: latest.id,
275
+ prefix: `[${handle}/${repo}] `,
276
+ intervalMs: options.interval ? Number(options.interval) : void 0,
277
+ timeoutMs: options.timeout ? Number(options.timeout) : void 0
278
+ });
279
+ }
280
+ async function runRepoCreate(options, nameParts) {
281
+ const name = (typeof options.name === "string" ? options.name : null) || nameParts.join(" ");
282
+ const trimmedName = name.trim();
283
+ if (!trimmedName) {
284
+ throw new Error(
285
+ "usage: repo create --name <name> [--team-id <id>] [--path <dir>] [--template <owner/repo|url>] [--template-branch <branch>] [--empty|--opentool] [--sandbox] [--token] [--auto-schedule-migration <true|false>]"
286
+ );
287
+ }
288
+ const config = await loadConfig();
289
+ const uiBase = resolveBaseUrl(config);
290
+ const apiKey = await ensureApiKey(config, uiBase);
291
+ const apiBase = resolvePublicApiBaseUrl(config);
292
+ const teamId = typeof options.teamId === "string" && options.teamId.trim() ? options.teamId.trim() : void 0;
293
+ const templateInput = typeof options.template === "string" ? options.template.trim() : "";
294
+ if (templateInput && (options.empty === "true" || options.opentool === "true")) {
295
+ throw new Error("choose one: --template or --empty/--opentool");
296
+ }
297
+ if (options.empty === "true" && options.opentool === "true") {
298
+ throw new Error("choose one: --empty or --opentool");
299
+ }
300
+ const description = typeof options.description === "string" ? options.description.trim() : void 0;
301
+ const templateBranch = typeof options.templateBranch === "string" && options.templateBranch.trim().length > 0 ? options.templateBranch.trim() : void 0;
302
+ const envVars = typeof options.env === "string" ? parseJsonOption(options.env, "env") : void 0;
303
+ if (envVars) {
304
+ if (typeof envVars !== "object" || Array.isArray(envVars)) {
305
+ throw new Error("env must be a JSON object");
306
+ }
307
+ for (const [key, value] of Object.entries(envVars)) {
308
+ if (typeof value !== "string") {
309
+ throw new Error(`env value for ${key} must be a string`);
310
+ }
311
+ }
312
+ }
313
+ if (templateInput) {
314
+ if (options.deployOnPush !== void 0) {
315
+ console.warn(
316
+ "deploy-on-push is not used for template create (auto deploys)"
317
+ );
318
+ }
319
+ const templateRepoUrl = normalizeTemplateRepoUrl(templateInput, uiBase);
320
+ const response2 = await createHeadlessApps(
321
+ apiBase,
322
+ apiKey,
323
+ [
324
+ {
325
+ name: trimmedName,
326
+ ...description ? { description } : {},
327
+ templateRepoUrl,
328
+ ...templateBranch ? { templateBranch } : {},
329
+ ...envVars ? { envVars } : {}
330
+ }
331
+ ],
332
+ teamId
333
+ );
334
+ const item = response2.items?.[0];
335
+ if (!item || item.status !== "ok" || !item.appId) {
336
+ throw new Error(item?.error || "Template create failed");
337
+ }
338
+ console.log(`app_id: ${item.appId}`);
339
+ if (item.deploymentId) {
340
+ console.log(`deployment_id: ${item.deploymentId}`);
341
+ }
342
+ if (item.conversationId) {
343
+ console.log(`conversation_id: ${item.conversationId}`);
344
+ }
345
+ return;
346
+ }
347
+ const defaultPath = process.cwd();
348
+ const rawPath = typeof options.path === "string" ? options.path : typeof options.dir === "string" ? options.dir : null;
349
+ const targetPath = rawPath && rawPath.trim().length > 0 ? rawPath.trim() : input.isTTY ? await promptForPath(defaultPath) : defaultPath;
350
+ const repoPath = path.resolve(targetPath);
351
+ if (existsSync(repoPath)) {
352
+ const stats = await fs.stat(repoPath);
353
+ if (!stats.isDirectory()) {
354
+ throw new Error(`path is not a directory: ${repoPath}`);
355
+ }
356
+ } else {
357
+ await fs.mkdir(repoPath, { recursive: true });
358
+ }
359
+ const entries = await fs.readdir(repoPath);
360
+ const nonGitEntries = entries.filter((entry) => entry !== ".git");
361
+ const isEmpty = nonGitEntries.length === 0;
362
+ const force = parseBooleanOption(options.yes) || parseBooleanOption(options.force);
363
+ if (!isEmpty && !force) {
364
+ const proceed = await promptConfirm(
365
+ `Directory is not empty (${repoPath}). Continue?`,
366
+ false
367
+ );
368
+ if (!proceed) {
369
+ console.log("aborted");
370
+ return;
371
+ }
372
+ }
373
+ const gitDir = path.join(repoPath, ".git");
374
+ const hasGit = existsSync(gitDir);
375
+ if (!hasGit) {
376
+ const proceed = force ? true : await promptConfirm("Initialize git repository here?", true);
377
+ if (!proceed) {
378
+ console.log("aborted");
379
+ return;
380
+ }
381
+ const result = await runCommand("git", ["init"], { cwd: repoPath });
382
+ if (result.code !== 0) {
383
+ throw new Error(
384
+ `git init failed: ${result.stderr.trim() || result.stdout.trim() || "unknown error"}`
385
+ );
386
+ }
387
+ }
388
+ const originUrl = await getGitRemoteUrl(repoPath, "origin");
389
+ if (originUrl && !force) {
390
+ const proceed = await promptConfirm(
391
+ `Remote "origin" already set (${originUrl}). Replace it?`,
392
+ false
393
+ );
394
+ if (!proceed) {
395
+ console.log("aborted");
396
+ return;
397
+ }
398
+ }
399
+ const repoInit = options.opentool === "true" ? "opentool" : "empty";
400
+ const sandbox = parseBooleanOption(options.sandbox);
401
+ const deployOnPush = parseBooleanOption(options.deployOnPush);
402
+ const autoScheduleMigrationOption = options.autoScheduleMigration;
403
+ const autoScheduleMigrationSpecified = typeof autoScheduleMigrationOption === "string" || typeof autoScheduleMigrationOption === "boolean";
404
+ const autoScheduleMigration = autoScheduleMigrationSpecified ? parseBooleanOption(autoScheduleMigrationOption) : void 0;
405
+ const response = await createRepo(apiBase, apiKey, {
406
+ name: trimmedName,
407
+ ...teamId ? { teamId } : {},
408
+ ...description ? { description } : {},
409
+ ...repoInit ? { repoInit } : {},
410
+ ...sandbox ? { sandbox: true } : {},
411
+ ...envVars ? { envVars } : {},
412
+ ...deployOnPush ? { deployOnPush: true } : {},
413
+ ...autoScheduleMigrationSpecified ? { autoScheduleMigration } : {}
414
+ });
415
+ const repoUrl = resolveRepoUrl(response);
416
+ warnOnRepoHostMismatch(repoUrl);
417
+ const useTokenRemote = parseBooleanOption(options.token) || parseBooleanOption(options.setRemoteToken);
418
+ const tokenRemote = formatTokenizedRepoUrl(repoUrl, apiKey);
419
+ const remoteUrl = useTokenRemote ? tokenRemote : repoUrl;
420
+ const remoteArgs = originUrl ? ["remote", "set-url", "origin", remoteUrl] : ["remote", "add", "origin", remoteUrl];
421
+ const remoteResult = await runCommand("git", remoteArgs, { cwd: repoPath });
422
+ if (remoteResult.code !== 0) {
423
+ throw new Error(
424
+ `git remote failed: ${redactToken(
425
+ remoteResult.stderr.trim() || remoteResult.stdout.trim() || "unknown error"
426
+ )}`
427
+ );
428
+ }
429
+ const displayRemote = useTokenRemote ? formatTokenizedRepoUrlForPrint(repoUrl) : repoUrl;
430
+ console.log(`app_id: ${response.appId}`);
431
+ if (response.gitOwner && response.gitRepo) {
432
+ console.log(`repo: ${response.gitOwner}/${response.gitRepo}`);
433
+ }
434
+ console.log(`remote: ${displayRemote}`);
435
+ console.log('next: git add . && git commit -m "init"');
436
+ const defaultBranch = response.defaultBranch || "master";
437
+ console.log(
438
+ `next: openpond repo push --path ${repoPath} --branch ${defaultBranch}`
439
+ );
440
+ if (!useTokenRemote) {
441
+ console.log(
442
+ `token-remote (non-interactive): git -C ${repoPath} remote set-url origin ${formatTokenizedRepoUrlForPrint(
443
+ repoUrl
444
+ )}`
445
+ );
446
+ }
447
+ try {
448
+ await fetchAppsWithCache({ apiBase, apiKey, forceRefresh: true });
449
+ } catch (error) {
450
+ console.warn("cache refresh failed", error);
451
+ }
452
+ }
453
+ async function resolveGitBranch(repoPath) {
454
+ const result = await runCommand(
455
+ "git",
456
+ ["rev-parse", "--abbrev-ref", "HEAD"],
457
+ {
458
+ cwd: repoPath
459
+ }
460
+ );
461
+ if (result.code !== 0) return null;
462
+ const branch = result.stdout.trim();
463
+ return branch.length > 0 ? branch : null;
464
+ }
465
+ async function runRepoPush(options) {
466
+ const config = await loadConfig();
467
+ const baseUrl = resolveBaseUrl(config);
468
+ const apiKey = await ensureApiKey(config, baseUrl);
469
+ const rawPath = typeof options.path === "string" ? options.path : typeof options.dir === "string" ? options.dir : null;
470
+ const repoPath = path.resolve(
471
+ rawPath && rawPath.trim().length > 0 ? rawPath.trim() : "."
472
+ );
473
+ const gitDir = path.join(repoPath, ".git");
474
+ if (!existsSync(gitDir)) {
475
+ throw new Error(`git repo not found at ${repoPath} (missing .git)`);
476
+ }
477
+ const originUrl = await getGitRemoteUrl(repoPath, "origin");
478
+ if (!originUrl) {
479
+ throw new Error("origin remote not set; run `openpond repo create` first");
480
+ }
481
+ warnOnRepoHostMismatch(originUrl);
482
+ const branchOption = typeof options.branch === "string" ? options.branch.trim() : "";
483
+ const resolvedBranch = branchOption || await resolveGitBranch(repoPath);
484
+ if (!resolvedBranch) {
485
+ throw new Error("unable to resolve git branch; pass --branch");
486
+ }
487
+ let tokenRemote;
488
+ try {
489
+ tokenRemote = formatTokenizedRepoUrl(originUrl, apiKey);
490
+ } catch {
491
+ throw new Error("origin remote must be https for tokenized pushes");
492
+ }
493
+ const keepTokenRemote = parseBooleanOption(options.keepTokenRemote) || parseBooleanOption(options.token) || parseBooleanOption(options.setRemoteToken);
494
+ const alreadyTokenized = originUrl.includes("x-access-token:");
495
+ const restoreUrl = !keepTokenRemote && !alreadyTokenized ? originUrl : null;
496
+ const previousPrompt = process.env.GIT_TERMINAL_PROMPT;
497
+ process.env.GIT_TERMINAL_PROMPT = "0";
498
+ try {
499
+ if (!alreadyTokenized) {
500
+ const setResult = await runCommand(
501
+ "git",
502
+ ["remote", "set-url", "origin", tokenRemote],
503
+ {
504
+ cwd: repoPath
505
+ }
506
+ );
507
+ if (setResult.code !== 0) {
508
+ throw new Error(
509
+ `git remote set-url failed: ${redactToken(
510
+ setResult.stderr.trim() || setResult.stdout.trim() || "unknown error"
511
+ )}`
512
+ );
513
+ }
514
+ }
515
+ const pushResult = await runCommand(
516
+ "git",
517
+ ["push", "-u", "origin", resolvedBranch],
518
+ {
519
+ cwd: repoPath,
520
+ inherit: true
521
+ }
522
+ );
523
+ if (pushResult.code !== 0) {
524
+ throw new Error("git push failed");
525
+ }
526
+ } finally {
527
+ if (restoreUrl) {
528
+ await runCommand("git", ["remote", "set-url", "origin", restoreUrl], {
529
+ cwd: repoPath
530
+ }).catch(() => null);
531
+ }
532
+ if (previousPrompt === void 0) {
533
+ delete process.env.GIT_TERMINAL_PROMPT;
534
+ } else {
535
+ process.env.GIT_TERMINAL_PROMPT = previousPrompt;
536
+ }
537
+ }
538
+ }
539
+ async function runOpentool(rawArgs) {
540
+ if (rawArgs.length === 0) {
541
+ throw new Error("usage: opentool <init|validate|build> [args]");
542
+ }
543
+ const command = process.platform === "win32" ? "npx.cmd" : "npx";
544
+ const result = await runCommand(command, ["opentool", ...rawArgs], {
545
+ inherit: true
546
+ });
547
+ if (result.code !== 0) {
548
+ throw new Error("opentool command failed");
549
+ }
550
+ }
551
+ async function runCheckUpdate() {
552
+ const packageName = "openpond";
553
+ const installed = getInstalledCliVersion();
554
+ const latest = await fetchLatestNpmVersion(packageName);
555
+ const installCommand = `npm i -g ${packageName}@${latest}`;
556
+ const cmp = compareSemver(installed, latest);
557
+ if (cmp === 0) {
558
+ console.log(`${packageName} is up to date (${installed})`);
559
+ return;
560
+ }
561
+ if (cmp === -1) {
562
+ console.log(`Update available: ${installed} -> ${latest}`);
563
+ console.log(`Run: ${installCommand}`);
564
+ return;
565
+ }
566
+ if (cmp === 1) {
567
+ console.log(
568
+ `Installed version (${installed}) is newer than npm latest (${latest}).`
569
+ );
570
+ return;
571
+ }
572
+ if (installed === latest) {
573
+ console.log(`${packageName} is up to date (${installed})`);
574
+ return;
575
+ }
576
+ console.log(`Installed: ${installed}`);
577
+ console.log(`Latest: ${latest}`);
578
+ console.log(`Run: ${installCommand}`);
579
+ }
580
+
581
+ export {
582
+ runTemplateStatus,
583
+ runTemplateBranches,
584
+ runTemplateUpdate,
585
+ runLogin,
586
+ runProfiles,
587
+ runAccount,
588
+ runHealth,
589
+ runToolList,
590
+ runToolRun,
591
+ runBacktestRun,
592
+ runDeployWatch,
593
+ runRepoCreate,
594
+ resolveGitBranch,
595
+ runRepoPush,
596
+ runOpentool,
597
+ runCheckUpdate
598
+ };