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,539 @@
1
+ import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
2
+ import {
3
+ consumeStream,
4
+ formatStreamItem
5
+ } from "./chunk-W5GKHH77.js";
6
+ import {
7
+ createAgentFromPrompt,
8
+ deployApp,
9
+ ensureApiKey,
10
+ executeUserTool,
11
+ fetchAppsWithCache,
12
+ fetchToolsWithCache,
13
+ getAppEnvironment,
14
+ getAppRuntimeSummary,
15
+ getUserPerformance,
16
+ loadConfig,
17
+ normalizeRepoName,
18
+ pollDeploymentLogs,
19
+ resolveAppTarget,
20
+ runAssistantMode,
21
+ submitBacktestDetail,
22
+ submitBacktestTx,
23
+ submitPositionsTx,
24
+ updateAppCodeVisibility,
25
+ updateAppEnvironment
26
+ } from "./chunk-XSAXENQD.js";
27
+ import {
28
+ resolveBaseUrl,
29
+ resolvePublicApiBaseUrl
30
+ } from "./chunk-5G4E547X.js";
31
+ import {
32
+ parseBooleanOption,
33
+ parseJsonOption,
34
+ parseTimeOption,
35
+ resolveTemplateEnvironment
36
+ } from "./chunk-3Y4EL3P6.js";
37
+ import "./chunk-UACZUFIA.js";
38
+
39
+ // src/cli/apps.ts
40
+ async function runAppsTools() {
41
+ const config = await loadConfig();
42
+ const uiBase = resolveBaseUrl(config);
43
+ const apiKey = await ensureApiKey(config, uiBase);
44
+ const apiBase = resolvePublicApiBaseUrl(config);
45
+ const tools = await fetchToolsWithCache({ apiBase, apiKey });
46
+ console.log(JSON.stringify(tools, null, 2));
47
+ }
48
+ async function runAppsList(options) {
49
+ const config = await loadConfig();
50
+ const uiBase = resolveBaseUrl(config);
51
+ const apiBase = resolvePublicApiBaseUrl(config);
52
+ const apiKey = await ensureApiKey(config, uiBase);
53
+ const handle = typeof options.handle === "string" ? String(options.handle) : void 0;
54
+ const normalizedHandle = handle ? normalizeRepoName(handle) : null;
55
+ const forceRefresh = options.refresh !== void 0 ? parseBooleanOption(options.refresh) : void 0;
56
+ const apps = await fetchAppsWithCache({
57
+ apiBase,
58
+ apiKey,
59
+ forceRefresh
60
+ });
61
+ const filtered = normalizedHandle ? apps.filter((app) => {
62
+ const candidate = normalizeRepoName(app.handle || app.gitOwner);
63
+ return candidate === normalizedHandle;
64
+ }) : apps;
65
+ if (filtered.length === 0) {
66
+ console.log("no apps found");
67
+ return;
68
+ }
69
+ if (parseBooleanOption(options.json)) {
70
+ console.log(JSON.stringify({ apps: filtered }, null, 2));
71
+ return;
72
+ }
73
+ for (const app of filtered) {
74
+ const owner = app.handle || app.gitOwner || "unknown";
75
+ const repo = app.repo || app.gitRepo || app.id;
76
+ const status = app.latestDeployment?.status || "no-deploy";
77
+ const branch = app.latestDeployment?.gitBranch || app.defaultBranch || "-";
78
+ const codeVisibility = app.codeVisibility || "unknown";
79
+ const sandbox = app.sandbox ? "yes" : "no";
80
+ console.log(
81
+ `${owner}/${repo} ${status} ${branch} code=${codeVisibility} sandbox=${sandbox} ${app.id}`
82
+ );
83
+ }
84
+ }
85
+ async function runAppsCodeVisibility(options, target) {
86
+ const visibility = typeof options.visibility === "string" ? options.visibility.trim() : typeof options.codeVisibility === "string" ? options.codeVisibility.trim() : "";
87
+ if (visibility !== "public" && visibility !== "private") {
88
+ throw new Error(
89
+ "usage: apps code-visibility <handle>/<repo> --visibility public|private"
90
+ );
91
+ }
92
+ const config = await loadConfig();
93
+ const uiBase = resolveBaseUrl(config);
94
+ const apiBase = resolvePublicApiBaseUrl(config);
95
+ const apiKey = await ensureApiKey(config, uiBase);
96
+ const { app, handle, repo } = await resolveAppTarget(apiBase, apiKey, target);
97
+ const result = await updateAppCodeVisibility(
98
+ apiBase,
99
+ apiKey,
100
+ app.id,
101
+ visibility
102
+ );
103
+ console.log(
104
+ `${handle}/${repo} code_visibility=${result.app?.codeVisibility ?? visibility} app_id=${app.id}`
105
+ );
106
+ }
107
+ async function runAppsPerformance(options) {
108
+ const config = await loadConfig();
109
+ const uiBase = resolveBaseUrl(config);
110
+ const apiKey = await ensureApiKey(config, uiBase);
111
+ const apiBase = resolvePublicApiBaseUrl(config);
112
+ const appId = typeof options.appId === "string" ? String(options.appId) : void 0;
113
+ const performance = await getUserPerformance(apiBase, apiKey, { appId });
114
+ console.log(JSON.stringify(performance, null, 2));
115
+ }
116
+ async function runAppsSummary(_options, target) {
117
+ const config = await loadConfig();
118
+ const uiBase = resolveBaseUrl(config);
119
+ const apiBase = resolvePublicApiBaseUrl(config);
120
+ const apiKey = await ensureApiKey(config, uiBase);
121
+ const { app } = await resolveAppTarget(apiBase, apiKey, target);
122
+ const summary = await getAppRuntimeSummary(apiBase, apiKey, app.id);
123
+ console.log(JSON.stringify(summary, null, 2));
124
+ }
125
+ async function runAppsAssistant(options, mode, target, contentParts) {
126
+ const prompt = (typeof options.prompt === "string" ? options.prompt : null) || contentParts.join(" ");
127
+ if (!prompt.trim()) {
128
+ throw new Error(
129
+ "usage: apps assistant <plan|performance> <handle>/<repo> --prompt <text>"
130
+ );
131
+ }
132
+ const config = await loadConfig();
133
+ const uiBase = resolveBaseUrl(config);
134
+ const apiBase = resolvePublicApiBaseUrl(config);
135
+ const apiKey = await ensureApiKey(config, uiBase);
136
+ const { app } = await resolveAppTarget(apiBase, apiKey, target);
137
+ const result = await runAssistantMode(apiBase, apiKey, {
138
+ appId: app.id,
139
+ mode,
140
+ prompt: prompt.trim()
141
+ });
142
+ console.log(JSON.stringify(result, null, 2));
143
+ }
144
+ async function runAppsAgentCreate(options, contentParts) {
145
+ const config = await loadConfig();
146
+ const uiBase = resolveBaseUrl(config);
147
+ const apiKey = await ensureApiKey(config, uiBase);
148
+ const apiBase = resolvePublicApiBaseUrl(config);
149
+ const prompt = (typeof options.prompt === "string" ? options.prompt : null) || contentParts.join(" ");
150
+ if (!prompt.trim()) {
151
+ throw new Error(
152
+ "usage: apps agent create --prompt <text> [--team-id <id>]"
153
+ );
154
+ }
155
+ const templateRepoUrl = typeof options.templateRepoUrl === "string" ? options.templateRepoUrl : void 0;
156
+ const templateBranch = typeof options.templateBranch === "string" ? options.templateBranch : void 0;
157
+ const templateLocalPath = typeof options.templateLocalPath === "string" ? options.templateLocalPath : void 0;
158
+ const teamId = typeof options.teamId === "string" && options.teamId.trim() ? options.teamId.trim() : void 0;
159
+ if (templateLocalPath && String(templateLocalPath).trim().length > 0) {
160
+ throw new Error("templateLocalPath is not supported; use templateRepoUrl");
161
+ }
162
+ const envVars = typeof options.env === "string" ? parseJsonOption(options.env, "env") : void 0;
163
+ if (envVars) {
164
+ if (typeof envVars !== "object" || Array.isArray(envVars)) {
165
+ throw new Error("env must be a JSON object");
166
+ }
167
+ for (const [key, value] of Object.entries(envVars)) {
168
+ if (typeof value !== "string") {
169
+ throw new Error(`env value for ${key} must be a string`);
170
+ }
171
+ }
172
+ }
173
+ const template = templateRepoUrl || templateBranch || envVars ? {
174
+ templateRepoUrl,
175
+ templateBranch,
176
+ envVars
177
+ } : void 0;
178
+ const deployEnvironment = typeof options.deployEnvironment === "string" ? options.deployEnvironment === "preview" ? "preview" : "production" : void 0;
179
+ const deployDisabled = options.deployDisabled !== void 0 ? parseBooleanOption(options.deployDisabled) : void 0;
180
+ const streamDeployLogs = options.streamDeployLogs !== void 0 ? parseBooleanOption(options.streamDeployLogs) : true;
181
+ const response = await createAgentFromPrompt(apiBase, apiKey, {
182
+ prompt: prompt.trim(),
183
+ ...teamId ? { teamId } : {},
184
+ ...template ? { template } : {},
185
+ ...deployEnvironment ? { deployEnvironment } : {},
186
+ ...deployDisabled !== void 0 ? { deployDisabled } : {},
187
+ streamDeployLogs
188
+ });
189
+ if (!response.ok) {
190
+ const text = await response.text().catch(() => "");
191
+ throw new Error(`agent create failed: ${response.status} ${text}`);
192
+ }
193
+ let conversationId = null;
194
+ let appId = null;
195
+ let deploymentId = null;
196
+ await consumeStream(response, {
197
+ onConversationId: (id) => {
198
+ conversationId = id;
199
+ },
200
+ onItems: (items) => {
201
+ for (const item of items) {
202
+ const line = formatStreamItem(item);
203
+ if (line) {
204
+ console.log(line);
205
+ }
206
+ const typed = item;
207
+ if (!appId && typeof typed.appId === "string") {
208
+ appId = typed.appId;
209
+ }
210
+ if (!deploymentId && typeof typed.deploymentId === "string") {
211
+ deploymentId = typed.deploymentId;
212
+ }
213
+ }
214
+ }
215
+ });
216
+ if (conversationId) {
217
+ console.log(`conversation_id: ${conversationId}`);
218
+ }
219
+ if (appId) {
220
+ console.log(`app_id: ${appId}`);
221
+ }
222
+ if (deploymentId) {
223
+ console.log(`deployment_id: ${deploymentId}`);
224
+ }
225
+ try {
226
+ await fetchAppsWithCache({ apiBase, apiKey, forceRefresh: true });
227
+ await fetchToolsWithCache({ apiBase, apiKey, forceRefresh: true });
228
+ } catch (error) {
229
+ console.warn("cache refresh failed", error);
230
+ }
231
+ }
232
+ async function runAppsToolsExecute(options, appId, deploymentId, toolName) {
233
+ const config = await loadConfig();
234
+ const uiBase = resolveBaseUrl(config);
235
+ const apiKey = await ensureApiKey(config, uiBase);
236
+ const apiBase = resolvePublicApiBaseUrl(config);
237
+ const methodRaw = typeof options.method === "string" ? String(options.method).toUpperCase() : void 0;
238
+ const method = methodRaw && ["GET", "POST", "PUT", "DELETE"].includes(methodRaw) ? methodRaw : void 0;
239
+ if (methodRaw && !method) {
240
+ throw new Error("method must be GET, POST, PUT, or DELETE");
241
+ }
242
+ const body = typeof options.body === "string" ? parseJsonOption(String(options.body), "body") : void 0;
243
+ const headers = typeof options.headers === "string" ? parseJsonOption(String(options.headers), "headers") : void 0;
244
+ const scheduleId = typeof options.scheduleId === "string" ? String(options.scheduleId) : void 0;
245
+ const notifyEmail = parseBooleanOption(options.notifyEmail);
246
+ const withSummary = parseBooleanOption(options.summary) || parseBooleanOption(options.withSummary);
247
+ const result = await executeUserTool(apiBase, apiKey, {
248
+ appId,
249
+ deploymentId,
250
+ toolName,
251
+ scheduleId,
252
+ method,
253
+ body,
254
+ headers,
255
+ notifyEmail: notifyEmail || void 0
256
+ });
257
+ console.log(JSON.stringify(result, null, 2));
258
+ if (withSummary && result.ok) {
259
+ const summary = await getAppRuntimeSummary(apiBase, apiKey, appId);
260
+ console.log(JSON.stringify({ summary }, null, 2));
261
+ }
262
+ }
263
+ async function runAppsEnvSet(options, target) {
264
+ const rawEnv = typeof options.env === "string" ? options.env : typeof options.vars === "string" ? options.vars : typeof options.envVars === "string" ? options.envVars : null;
265
+ if (!rawEnv) {
266
+ throw new Error("usage: apps env set <handle>/<repo> --env <json>");
267
+ }
268
+ const parsed = parseJsonOption(rawEnv, "env");
269
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
270
+ throw new Error("env must be a JSON object");
271
+ }
272
+ const envVars = {};
273
+ for (const [key, value] of Object.entries(
274
+ parsed
275
+ )) {
276
+ if (typeof value !== "string") {
277
+ throw new Error(`env value for ${key} must be a string`);
278
+ }
279
+ if (!key.startsWith("OPENTOOL_PUBLIC_")) {
280
+ throw new Error("only OPENTOOL_PUBLIC_ env vars can be set");
281
+ }
282
+ envVars[key] = value;
283
+ }
284
+ const config = await loadConfig();
285
+ const uiBase = resolveBaseUrl(config);
286
+ const apiBase = resolvePublicApiBaseUrl(config);
287
+ const apiKey = await ensureApiKey(config, uiBase);
288
+ const { app } = await resolveAppTarget(apiBase, apiKey, target);
289
+ const result = await updateAppEnvironment(apiBase, apiKey, app.id, {
290
+ envVars
291
+ });
292
+ console.log(JSON.stringify(result, null, 2));
293
+ }
294
+ async function runAppsEnvGet(_options, target) {
295
+ const config = await loadConfig();
296
+ const uiBase = resolveBaseUrl(config);
297
+ const apiBase = resolvePublicApiBaseUrl(config);
298
+ const apiKey = await ensureApiKey(config, uiBase);
299
+ const { app } = await resolveAppTarget(apiBase, apiKey, target);
300
+ const result = await getAppEnvironment(apiBase, apiKey, app.id);
301
+ console.log(JSON.stringify(result, null, 2));
302
+ }
303
+ async function runAppsDeploy(options, target) {
304
+ const config = await loadConfig();
305
+ const uiBase = resolveBaseUrl(config);
306
+ const apiBase = resolvePublicApiBaseUrl(config);
307
+ const apiKey = await ensureApiKey(config, uiBase);
308
+ const { app, handle, repo } = await resolveAppTarget(apiBase, apiKey, target);
309
+ const envRaw = typeof options.env === "string" ? options.env : typeof options.environment === "string" ? options.environment : void 0;
310
+ const environment = resolveTemplateEnvironment(envRaw);
311
+ const result = await deployApp(apiBase, apiKey, app.id, { environment });
312
+ console.log(JSON.stringify(result, null, 2));
313
+ const shouldWatch = parseBooleanOption(options.watch) || parseBooleanOption(options.wait) || parseBooleanOption(options.follow);
314
+ if (!shouldWatch) return;
315
+ await pollDeploymentLogs({
316
+ baseUrl: apiBase,
317
+ apiKey,
318
+ deploymentId: result.deploymentId,
319
+ prefix: `[${handle}/${repo}] `,
320
+ intervalMs: options.interval ? Number(options.interval) : void 0,
321
+ timeoutMs: options.timeout ? Number(options.timeout) : void 0
322
+ });
323
+ }
324
+ async function runAppsPositionsTx(options) {
325
+ const config = await loadConfig();
326
+ const uiBase = resolveBaseUrl(config);
327
+ const apiKey = await ensureApiKey(config, uiBase);
328
+ const apiBase = resolvePublicApiBaseUrl(config);
329
+ const methodRaw = typeof options.method === "string" ? String(options.method).toUpperCase() : "POST";
330
+ const method = methodRaw === "GET" ? "GET" : "POST";
331
+ if (methodRaw !== "GET" && methodRaw !== "POST") {
332
+ throw new Error("method must be GET or POST");
333
+ }
334
+ let query;
335
+ if (method === "GET" && typeof options.params === "string") {
336
+ const parsed = parseJsonOption(String(options.params), "params");
337
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
338
+ throw new Error("params must be a JSON object");
339
+ }
340
+ query = {};
341
+ for (const [key, value] of Object.entries(
342
+ parsed
343
+ )) {
344
+ if (value === void 0) continue;
345
+ query[key] = typeof value === "string" ? value : JSON.stringify(value);
346
+ }
347
+ }
348
+ const body = method === "POST" && typeof options.body === "string" ? parseJsonOption(String(options.body), "body") : void 0;
349
+ const result = await submitPositionsTx(apiBase, apiKey, {
350
+ method,
351
+ body,
352
+ query
353
+ });
354
+ console.log(JSON.stringify(result, null, 2));
355
+ }
356
+ function resolveStoreEventsParams(options) {
357
+ let params = {};
358
+ if (typeof options.params === "string") {
359
+ const parsed = parseJsonOption(String(options.params), "params");
360
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
361
+ throw new Error("params must be a JSON object");
362
+ }
363
+ for (const [key, value] of Object.entries(
364
+ parsed
365
+ )) {
366
+ if (value === void 0) continue;
367
+ params[key] = typeof value === "string" ? value : JSON.stringify(value);
368
+ }
369
+ }
370
+ const addParam = (key, value) => {
371
+ if (value === void 0 || value === "") return;
372
+ params[key] = value;
373
+ };
374
+ addParam(
375
+ "source",
376
+ typeof options.source === "string" ? options.source.trim() : void 0
377
+ );
378
+ addParam(
379
+ "walletAddress",
380
+ typeof options.walletAddress === "string" ? options.walletAddress.trim() : void 0
381
+ );
382
+ addParam(
383
+ "symbol",
384
+ typeof options.symbol === "string" ? options.symbol.trim() : void 0
385
+ );
386
+ addParam(
387
+ "cursor",
388
+ typeof options.cursor === "string" ? options.cursor.trim() : void 0
389
+ );
390
+ addParam(
391
+ "status",
392
+ typeof options.status === "string" ? options.status.trim() : void 0
393
+ );
394
+ addParam("since", parseTimeOption(options.since, "since"));
395
+ addParam("until", parseTimeOption(options.until, "until"));
396
+ if (typeof options.limit === "string" && options.limit.trim().length > 0) {
397
+ const parsed = Number.parseInt(options.limit, 10);
398
+ if (!Number.isFinite(parsed)) {
399
+ throw new Error("limit must be a number");
400
+ }
401
+ addParam("limit", String(parsed));
402
+ }
403
+ if (options.history !== void 0) {
404
+ addParam("history", parseBooleanOption(options.history) ? "true" : "false");
405
+ }
406
+ return Object.keys(params).length ? params : void 0;
407
+ }
408
+ function resolveBacktestEventsParams(options) {
409
+ let params = {};
410
+ if (typeof options.params === "string") {
411
+ const parsed = parseJsonOption(String(options.params), "params");
412
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
413
+ throw new Error("params must be a JSON object");
414
+ }
415
+ for (const [key, value] of Object.entries(
416
+ parsed
417
+ )) {
418
+ if (value === void 0) continue;
419
+ params[key] = typeof value === "string" ? value : JSON.stringify(value);
420
+ }
421
+ }
422
+ const addParam = (key, value) => {
423
+ if (value === void 0 || value === "") return;
424
+ params[key] = value;
425
+ };
426
+ addParam(
427
+ "source",
428
+ typeof options.source === "string" ? options.source.trim() : void 0
429
+ );
430
+ addParam(
431
+ "walletAddress",
432
+ typeof options.walletAddress === "string" ? options.walletAddress.trim() : void 0
433
+ );
434
+ addParam(
435
+ "symbol",
436
+ typeof options.symbol === "string" ? options.symbol.trim() : void 0
437
+ );
438
+ addParam(
439
+ "cursor",
440
+ typeof options.cursor === "string" ? options.cursor.trim() : void 0
441
+ );
442
+ addParam(
443
+ "status",
444
+ typeof options.status === "string" ? options.status.trim() : void 0
445
+ );
446
+ addParam(
447
+ "backtestRunId",
448
+ typeof options.runId === "string" ? options.runId.trim() : typeof options.backtestRunId === "string" ? options.backtestRunId.trim() : void 0
449
+ );
450
+ addParam("since", parseTimeOption(options.since, "since"));
451
+ addParam("until", parseTimeOption(options.until, "until"));
452
+ if (typeof options.limit === "string" && options.limit.trim().length > 0) {
453
+ const parsed = Number.parseInt(options.limit, 10);
454
+ if (!Number.isFinite(parsed)) {
455
+ throw new Error("limit must be a number");
456
+ }
457
+ addParam("limit", String(parsed));
458
+ }
459
+ return Object.keys(params).length ? params : void 0;
460
+ }
461
+ async function runAppsStoreEvents(options) {
462
+ const config = await loadConfig();
463
+ const uiBase = resolveBaseUrl(config);
464
+ const apiKey = await ensureApiKey(config, uiBase);
465
+ const apiBase = resolvePublicApiBaseUrl(config);
466
+ const query = resolveStoreEventsParams(options);
467
+ const result = await submitPositionsTx(apiBase, apiKey, {
468
+ method: "GET",
469
+ query
470
+ });
471
+ console.log(JSON.stringify(result, null, 2));
472
+ }
473
+ async function runBacktestEvents(options, target) {
474
+ const config = await loadConfig();
475
+ const uiBase = resolveBaseUrl(config);
476
+ const apiKey = await ensureApiKey(config, uiBase);
477
+ const apiBase = resolvePublicApiBaseUrl(config);
478
+ const { app } = await resolveAppTarget(apiBase, apiKey, target);
479
+ const query = {
480
+ ...resolveBacktestEventsParams(options) ?? {},
481
+ appId: app.id
482
+ };
483
+ const result = await submitBacktestTx(apiBase, apiKey, {
484
+ method: "GET",
485
+ query
486
+ });
487
+ console.log(JSON.stringify(result, null, 2));
488
+ }
489
+ async function runBacktestGet(options, target) {
490
+ const runId = typeof options.runId === "string" ? options.runId.trim() : typeof options.backtestRunId === "string" ? options.backtestRunId.trim() : "";
491
+ if (!runId) {
492
+ throw new Error("usage: backtest get <handle>/<repo> --run-id <id>");
493
+ }
494
+ const config = await loadConfig();
495
+ const uiBase = resolveBaseUrl(config);
496
+ const apiKey = await ensureApiKey(config, uiBase);
497
+ const apiBase = resolvePublicApiBaseUrl(config);
498
+ const { app } = await resolveAppTarget(apiBase, apiKey, target);
499
+ const result = await submitBacktestDetail(apiBase, apiKey, {
500
+ appId: app.id,
501
+ runId
502
+ });
503
+ console.log(JSON.stringify(result, null, 2));
504
+ }
505
+ async function runAppsTradeFacts(options) {
506
+ const config = await loadConfig();
507
+ const uiBase = resolveBaseUrl(config);
508
+ const apiKey = await ensureApiKey(config, uiBase);
509
+ const apiBase = resolvePublicApiBaseUrl(config);
510
+ const appId = typeof options.appId === "string" ? options.appId : void 0;
511
+ const performance = await getUserPerformance(apiBase, apiKey, { appId });
512
+ if (performance && typeof performance === "object" && "trades" in performance && Array.isArray(performance.trades)) {
513
+ console.log(
514
+ JSON.stringify(performance.trades, null, 2)
515
+ );
516
+ return;
517
+ }
518
+ console.log(JSON.stringify(performance, null, 2));
519
+ }
520
+ export {
521
+ resolveBacktestEventsParams,
522
+ resolveStoreEventsParams,
523
+ runAppsAgentCreate,
524
+ runAppsAssistant,
525
+ runAppsCodeVisibility,
526
+ runAppsDeploy,
527
+ runAppsEnvGet,
528
+ runAppsEnvSet,
529
+ runAppsList,
530
+ runAppsPerformance,
531
+ runAppsPositionsTx,
532
+ runAppsStoreEvents,
533
+ runAppsSummary,
534
+ runAppsTools,
535
+ runAppsToolsExecute,
536
+ runAppsTradeFacts,
537
+ runBacktestEvents,
538
+ runBacktestGet
539
+ };