openpond 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/actions-command-QP3NMDK4.js +2 -0
- package/dist/chunks/app-layer-N7VFRVJ2.js +3 -0
- package/dist/chunks/app-server-runtime-OCLPUI7F.js +2 -0
- package/dist/chunks/apps-AMG75TI4.js +2 -0
- package/dist/chunks/chunk-22UARBPW.js +3 -0
- package/dist/chunks/chunk-3A7HZJNE.js +1 -0
- package/dist/chunks/chunk-3M53YXEI.js +2 -0
- package/dist/chunks/chunk-3NDRIQTI.js +2 -0
- package/dist/chunks/chunk-5BBVEWG3.js +2 -0
- package/dist/chunks/chunk-5O7ZVCMV.js +6 -0
- package/dist/chunks/chunk-6FA3GG5B.js +33 -0
- package/dist/chunks/chunk-6MI4KKWF.js +2 -0
- package/dist/chunks/chunk-BBG546O6.js +6 -0
- package/dist/chunks/chunk-BX4J2VDU.js +2 -0
- package/dist/chunks/chunk-BZMVB3GS.js +2 -0
- package/dist/chunks/chunk-C5LOZSVS.js +2 -0
- package/dist/chunks/chunk-CWQWV2T3.js +2 -0
- package/dist/chunks/chunk-DUA3QP6Y.js +19 -0
- package/dist/chunks/chunk-EAPFMACH.js +10 -0
- package/dist/chunks/chunk-ES2ISFJC.js +66 -0
- package/dist/chunks/chunk-F65NIZLM.js +2199 -0
- package/dist/chunks/chunk-FGJ5LFPL.js +5 -0
- package/dist/chunks/chunk-FTQLQJQV.js +2 -0
- package/dist/chunks/chunk-FY7OQ5RK.js +24 -0
- package/dist/chunks/chunk-FYCJSUFV.js +53 -0
- package/dist/chunks/chunk-GLUWATL5.js +2 -0
- package/dist/chunks/chunk-H7IWJN7L.js +17 -0
- package/dist/chunks/chunk-HZP5U2AA.js +3 -0
- package/dist/chunks/chunk-I5K74TOH.js +3 -0
- package/dist/chunks/chunk-IR3YJWPW.js +7 -0
- package/dist/chunks/chunk-KU7QOHFT.js +2872 -0
- package/dist/chunks/chunk-KV553EWX.js +16 -0
- package/dist/chunks/chunk-MGN6GLNZ.js +2 -0
- package/dist/chunks/chunk-OG5Q6NXK.js +28 -0
- package/dist/chunks/chunk-OGPHXXCD.js +1 -0
- package/dist/chunks/chunk-PI36UHRA.js +18 -0
- package/dist/chunks/chunk-RWSAGQTP.js +2 -0
- package/dist/chunks/chunk-SAE4OIPC.js +2 -0
- package/dist/chunks/chunk-SDO4FC4Q.js +2 -0
- package/dist/chunks/chunk-UKUVMXOW.js +12 -0
- package/dist/chunks/chunk-VCLCFK3O.js +36 -0
- package/dist/chunks/chunk-VYUMTRB3.js +5 -0
- package/dist/chunks/chunk-X37KMV27.js +1 -0
- package/dist/chunks/chunk-XDHAGACI.js +3 -0
- package/dist/chunks/chunk-XEOEKFG6.js +71 -0
- package/dist/chunks/chunk-ZF7TEGY5.js +5 -0
- package/dist/chunks/chunk-ZVOO7FKM.js +2 -0
- package/dist/chunks/cli-M2FG7SSI.js +2 -0
- package/dist/chunks/configuration-command-XBKBIZBO.js +2 -0
- package/dist/chunks/continual-D75WA7E7.js +7 -0
- package/dist/chunks/core-commands-LUZVWXQR.js +2 -0
- package/dist/chunks/database-X2CUV732.js +2 -0
- package/dist/chunks/desktop-test-KGC4JVJ7.js +3 -0
- package/dist/chunks/dist-NKLXFA37.js +2 -0
- package/dist/chunks/extension-NQ7N5LEY.js +5 -0
- package/dist/chunks/help-MWK66XZK.js +8 -0
- package/dist/chunks/module-ES6BEMUI-ZVL3F6NW.js +2 -0
- package/dist/chunks/module-asyncify-2EFITU5U-R7TVXNAE.js +2 -0
- package/dist/chunks/opchat-XJZA3QKZ.js +3 -0
- package/dist/chunks/organizations-UECDFEYE.js +2 -0
- package/dist/chunks/profile-KUMIZURM.js +3 -0
- package/dist/chunks/project-agent-NILMJHLV.js +2 -0
- package/dist/chunks/sandbox-command-QHH65OSE.js +2 -0
- package/dist/chunks/sandbox-template-N7I63PNU.js +10 -0
- package/dist/chunks/src-724HF43W.js +82 -0
- package/dist/chunks/src-VTKTTKQO.js +319 -0
- package/dist/chunks/taskset-PISBOILQ.js +2 -0
- package/dist/chunks/teams-bot-UV4RU53M.js +3 -0
- package/dist/chunks/training-2NDOWH5S.js +2 -0
- package/dist/chunks/workspaces-XXT4KUD3.js +2 -0
- package/dist/cli.js +3 -109
- package/dist/index.js +1 -31230
- package/dist/sandbox-template/manifest.js +1 -18380
- package/dist/web/assets/App-DxecRQUL.js +176 -0
- package/dist/web/assets/AppDialog-B65Eo3gp.js +1 -0
- package/dist/web/assets/AppTerminalPanel-B2EKQM7W.js +2 -0
- package/dist/web/assets/{AppsView-B1NUuAIf.js → AppsView-BBoVe7s2.js} +1 -1
- package/dist/web/assets/{BrowserSidebar-DOvYxXeP.js → BrowserSidebar-CSM1atSJ.js} +1 -1
- package/dist/web/assets/{CartesianChart-pOrYpzBr.js → CartesianChart-CJKfXiEG.js} +1 -1
- package/dist/web/assets/{CollaborationTabs-CgbR-MBJ.js → CollaborationTabs-BMZamWFC.js} +1 -1
- package/dist/web/assets/{CommandMenu-CrIr4qUX.js → CommandMenu-B3U1z2eo.js} +1 -1
- package/dist/web/assets/{CommunityView-CvAVQ_HZ.js → CommunityView-CTyRUcfy.js} +1 -1
- package/dist/web/assets/{ComposerCreateImproveStrip-DybcKwwd.js → ComposerCreateImproveStrip-D7usvRtK.js} +1 -1
- package/dist/web/assets/GetStartedView-Ibu7oKWJ.js +1 -0
- package/dist/web/assets/HostedModelLearningReview-qnzIkT70.js +1 -0
- package/dist/web/assets/HostedModelLearningSettings--PKjpYsy.js +1 -0
- package/dist/web/assets/LabModelVersionDetailPage-s9uUN6fV.js +1 -0
- package/dist/web/assets/{LabSkillSidebar-CuaYrtiu.js → LabSkillSidebar-BKYseMiJ.js} +1 -1
- package/dist/web/assets/LabsRoute-C1FWCoYb.css +1 -0
- package/dist/web/assets/LabsRoute-DoRs0K6v.js +32 -0
- package/dist/web/assets/MainChatThread-DvuyMcMB.js +2 -0
- package/dist/web/assets/MainPane-BWwcxgHD.js +8 -0
- package/dist/web/assets/{MarkdownText-DOlVQR8a.js → MarkdownText-D8XC5UT_.js} +1 -1
- package/dist/web/assets/{Messages-DMubppta.js → Messages-e4A8JUjD.js} +6 -6
- package/dist/web/assets/{NativeSkillSidebar-DSFwZ-od.js → NativeSkillSidebar-D2Joh8XB.js} +1 -1
- package/dist/web/assets/{NewExperienceSwitcher-Dj0ePIJ-.js → NewExperienceSwitcher-CzGebt2E.js} +1 -1
- package/dist/web/assets/{NewProjectDialog-B8NQV-Ji.js → NewProjectDialog-CdMTSxUE.js} +1 -1
- package/dist/web/assets/{OutputsPage-D_LDYTgV.js → OutputsPage-m7cSb8dW.js} +1 -1
- package/dist/web/assets/{ProjectsPage-xjDYPc_W.js → ProjectsPage-C9mz8W1g.js} +1 -1
- package/dist/web/assets/RightChatPanelStack-B4LEqKEj.js +1 -0
- package/dist/web/assets/{RightSidebarHomePanel-j0VckZUu.js → RightSidebarHomePanel-DOeUsH7h.js} +1 -1
- package/dist/web/assets/{ScheduledWorkPage-1aT4bBY-.js → ScheduledWorkPage-UXZSSWgA.js} +1 -1
- package/dist/web/assets/{SettingsView-BSpuMDpv.js → SettingsView-CQm1ai73.js} +7 -7
- package/dist/web/assets/TeamChatView-C4haojB7.js +3 -0
- package/dist/web/assets/{TerminalOverlay-CrSwUk2d.js → TerminalOverlay-p2GZsuyQ.js} +3 -3
- package/dist/web/assets/{TrainingCreationPanel-B4HMRwUg.js → TrainingCreationPanel-BYJSlO8X.js} +1 -1
- package/dist/web/assets/{TrainingDraftPanel-D4r1tN3I.js → TrainingDraftPanel-DR5KlayH.js} +1 -1
- package/dist/web/assets/{UsageSettingsSection-2aymqwIM.js → UsageSettingsSection-BQToNXE4.js} +5 -5
- package/dist/web/assets/{WorkSidebarPanel-B0X0OiR6.js → WorkSidebarPanel--EeytWeg.js} +1 -1
- package/dist/web/assets/WorkspaceDiffPanel-BrovSYhn.js +14 -0
- package/dist/web/assets/{WorkspaceEnvironmentMenu-OAfMEt7L.js → WorkspaceEnvironmentMenu-l-keRgvj.js} +3 -3
- package/dist/web/assets/{WorkspaceGitDialogs-YxcPH2Rq.js → WorkspaceGitDialogs-aicWzaZu.js} +1 -1
- package/dist/web/assets/{WorkspaceMonacoEditor-COKTiQZl.js → WorkspaceMonacoEditor-CO_E74jM.js} +36 -36
- package/dist/web/assets/{arrow-up-right-_TX-awvK.js → arrow-up-right-rwPXNfVn.js} +1 -1
- package/dist/web/assets/chat-file-links-B3jDstSC.js +1 -0
- package/dist/web/assets/chevron-up-D089nvYQ.js +1 -0
- package/dist/web/assets/{clipboard-CyRSS8Sy.js → clipboard-DwEExyU4.js} +1 -1
- package/dist/web/assets/{cloud-upload-uBJBUYTy.js → cloud-upload-D2he0-vQ.js} +1 -1
- package/dist/web/assets/{cssMode-BrXSsZYs.js → cssMode-DS4k0NcI.js} +1 -1
- package/dist/web/assets/{folder-open-DktdZNW7.js → folder-open-CAOLduKD.js} +1 -1
- package/dist/web/assets/{folder-plus-DO06i9Vo.js → folder-plus-D56MrxVT.js} +1 -1
- package/dist/web/assets/{git-commit-horizontal-zFSIkPs7.js → git-commit-horizontal-CeNM0oKJ.js} +1 -1
- package/dist/web/assets/{htmlMode-X9UMFkjt.js → htmlMode-Xkni5erh.js} +1 -1
- package/dist/web/assets/{index-ByQIHpc9.css → index-BGMzUaup.css} +1 -1
- package/dist/web/assets/{index-UOGdfLzi.js → index-KwyAyscP.js} +1 -1
- package/dist/web/assets/{info-BEJXUqCD.js → info-CcrBaEE_.js} +1 -1
- package/dist/web/assets/{jsonMode-DIsB-j2E.js → jsonMode-C4YPbQB7.js} +1 -1
- package/dist/web/assets/{lspLanguageFeatures-CmZ17KpA.js → lspLanguageFeatures-CF5oMTz6.js} +1 -1
- package/dist/web/assets/{minimize-2-DumTpFtE.js → minimize-2-DzHQnInk.js} +1 -1
- package/dist/web/assets/{monaco.contribution-DJ_NmcHu.js → monaco.contribution-0EN4mGCC.js} +2 -2
- package/dist/web/assets/{monaco.contribution-YVDfJcG4.js → monaco.contribution-B4qcTP0w.js} +2 -2
- package/dist/web/assets/{monaco.contribution-LZEujgny.js → monaco.contribution-CJK_NrBm.js} +2 -2
- package/dist/web/assets/{monaco.contribution-D6w5PJji.js → monaco.contribution-CkPGKNd-.js} +2 -2
- package/dist/web/assets/{play-CLFeH7CU.js → play-p3-AMTPL.js} +1 -1
- package/dist/web/assets/{python-Djbda_qZ.js → python-B0kpTxAZ.js} +1 -1
- package/dist/web/assets/{refresh-cw-B4IpQ_7Q.js → refresh-cw-_jbTIzzr.js} +1 -1
- package/dist/web/assets/{save-BbTHztnA.js → save-Cy6hEotx.js} +1 -1
- package/dist/web/assets/{square-BJrVbmz6.js → square-DKQkcrOH.js} +1 -1
- package/dist/web/assets/{toggleHighContrast-BopU5W9S.js → toggleHighContrast-Bnk1VVVq.js} +1 -1
- package/dist/web/assets/{tsMode-CH_0_YDX.js → tsMode-BDrSVy7V.js} +1 -1
- package/dist/web/assets/{upload-UumVeufu.js → upload-COn0my_O.js} +1 -1
- package/dist/web/assets/{useLocalAgentSchedules-BRa23U7O.js → useLocalAgentSchedules-iZNB4Oee.js} +1 -1
- package/dist/web/assets/{wifi-off-BWJWivn6.js → wifi-off-Cqt-ZLXY.js} +1 -1
- package/dist/web/assets/{workers-pTe8RvSI.js → workers-hu0Ym93h.js} +1 -1
- package/dist/web/assets/{yaml-DNLASORn.js → yaml-D-JLDGL6.js} +1 -1
- package/dist/web/index.html +2 -2
- package/package.json +4 -3
- package/dist/chunks/actions-command-6N5XWMR6.js +0 -185
- package/dist/chunks/app-layer-F3CGXB33.js +0 -216
- package/dist/chunks/app-server-runtime-RHO5TFUC.js +0 -23
- package/dist/chunks/apps-L5XCL7QY.js +0 -429
- package/dist/chunks/chunk-26AMV5ZI.js +0 -634
- package/dist/chunks/chunk-3EB7I67T.js +0 -630
- package/dist/chunks/chunk-3ELF4FXY.js +0 -96
- package/dist/chunks/chunk-3VEYNDHN.js +0 -669
- package/dist/chunks/chunk-4KA25HUP.js +0 -5648
- package/dist/chunks/chunk-4L3ZJS2T.js +0 -1207
- package/dist/chunks/chunk-6SMNG6YA.js +0 -1303
- package/dist/chunks/chunk-7RIGZB7N.js +0 -1148
- package/dist/chunks/chunk-A6G3PFA5.js +0 -2164
- package/dist/chunks/chunk-BVY5JYM6.js +0 -512
- package/dist/chunks/chunk-DLQQIWN2.js +0 -648
- package/dist/chunks/chunk-FJ2JGB2N.js +0 -1373
- package/dist/chunks/chunk-FQS2QL5F.js +0 -14522
- package/dist/chunks/chunk-G65WAOJV.js +0 -1643
- package/dist/chunks/chunk-JTHL5XJ2.js +0 -1838
- package/dist/chunks/chunk-K4TZEHAW.js +0 -602
- package/dist/chunks/chunk-KCRCIQPD.js +0 -66
- package/dist/chunks/chunk-KSRWKXRB.js +0 -12
- package/dist/chunks/chunk-MUMPWI4O.js +0 -92
- package/dist/chunks/chunk-NTK22KJD.js +0 -10707
- package/dist/chunks/chunk-OCBRPU2K.js +0 -629
- package/dist/chunks/chunk-PS37DB5F.js +0 -183
- package/dist/chunks/chunk-R3C3MNSI.js +0 -140
- package/dist/chunks/chunk-SMNFI2FU.js +0 -113
- package/dist/chunks/chunk-UACZUFIA.js +0 -47
- package/dist/chunks/chunk-UZMVNKXM.js +0 -1275
- package/dist/chunks/chunk-VT6BLHMB.js +0 -67198
- package/dist/chunks/chunk-W5GKHH77.js +0 -168
- package/dist/chunks/chunk-X6F4LBTQ.js +0 -832
- package/dist/chunks/chunk-X7ZG4TSW.js +0 -3063
- package/dist/chunks/chunk-XA4KBDMY.js +0 -13723
- package/dist/chunks/chunk-YVCYVDNP.js +0 -746
- package/dist/chunks/chunk-ZNQEROWP.js +0 -254
- package/dist/chunks/cli-D2MUUBEX.js +0 -23
- package/dist/chunks/configuration-command-NR6JYIUD.js +0 -187
- package/dist/chunks/continual-37CE4LLJ.js +0 -803
- package/dist/chunks/core-commands-SWGIOZLW.js +0 -50
- package/dist/chunks/database-DEYUZDIM.js +0 -20
- package/dist/chunks/desktop-test-QOS7G5NE.js +0 -148
- package/dist/chunks/dist-AKYCQNNF.js +0 -187
- package/dist/chunks/extension-HJUJBQAD.js +0 -9378
- package/dist/chunks/help-J6PZ23IC.js +0 -67
- package/dist/chunks/opchat-ABX5YBAT.js +0 -169
- package/dist/chunks/organizations-CPNC47DO.js +0 -806
- package/dist/chunks/profile-Q3HB5MIO.js +0 -1136
- package/dist/chunks/project-agent-YHUBX4OR.js +0 -516
- package/dist/chunks/sandbox-command-YFL5QTWX.js +0 -1661
- package/dist/chunks/sandbox-template-Z6P7NTNF.js +0 -1655
- package/dist/chunks/src-7XEENEBI.js +0 -3628
- package/dist/chunks/src-KBBIV4NT.js +0 -56125
- package/dist/chunks/taskset-2TRZBRRT.js +0 -66
- package/dist/chunks/teams-bot-WD33NLH5.js +0 -146
- package/dist/chunks/training-4XH37UZB.js +0 -17
- package/dist/chunks/workspaces-WG2MH2WE.js +0 -99
- package/dist/web/assets/App-C9aGkxVg.js +0 -173
- package/dist/web/assets/AppDialog-CK6_lg8c.js +0 -1
- package/dist/web/assets/AppTerminalPanel-BKqgX4sd.js +0 -2
- package/dist/web/assets/GetStartedView-DVInkexN.js +0 -1
- package/dist/web/assets/LabModelVersionDetailPage-NaaPElmM.js +0 -1
- package/dist/web/assets/LabsRoute-BRR6x3SX.js +0 -2
- package/dist/web/assets/LabsRoute-CGFgymTX.css +0 -1
- package/dist/web/assets/MainChatThread-BfkjCZB9.js +0 -2
- package/dist/web/assets/MainPane-Gw-YK38n.js +0 -8
- package/dist/web/assets/RightChatPanelStack-BktRQ9wg.js +0 -1
- package/dist/web/assets/TeamChatView-BPWJbDf1.js +0 -3
- package/dist/web/assets/WorkspaceDiffPanel-Pg7GL0br.js +0 -14
- package/dist/web/assets/chat-file-links-CWLsRYvW.js +0 -1
- package/dist/web/assets/chevron-up--mNnEqha.js +0 -1
- package/dist/web/assets/index-BEPmTPIA.js +0 -1
|
@@ -1,512 +0,0 @@
|
|
|
1
|
-
import { createRequire as __openpondCreateRequire } from "node:module"; var require = __openpondCreateRequire(import.meta.url);
|
|
2
|
-
import {
|
|
3
|
-
DEFAULT_OPENPOND_OPCHAT_API_BASE_URL
|
|
4
|
-
} from "./chunk-KSRWKXRB.js";
|
|
5
|
-
|
|
6
|
-
// ../../packages/cloud/src/hosted-chat.ts
|
|
7
|
-
import { randomUUID } from "node:crypto";
|
|
8
|
-
function normalizeApiBaseUrl(value) {
|
|
9
|
-
const trimmed = normalizeOptionalOpChatApiBaseUrl(value);
|
|
10
|
-
if (!trimmed) throw new Error("apiBaseUrl is required");
|
|
11
|
-
return trimmed;
|
|
12
|
-
}
|
|
13
|
-
function trimTrailingSlashes(value) {
|
|
14
|
-
return value.replace(/\/+$/, "");
|
|
15
|
-
}
|
|
16
|
-
function normalizeOptionalOpChatApiBaseUrl(value) {
|
|
17
|
-
let trimmed = trimTrailingSlashes(value?.trim() ?? "");
|
|
18
|
-
if (!trimmed) return null;
|
|
19
|
-
trimmed = trimmed.replace(/\/chat\/completions$/i, "").replace(/\/models(?:\/[^/]+)?$/i, "");
|
|
20
|
-
if (trimmed.endsWith("/opchat/v1")) return trimmed;
|
|
21
|
-
if (trimmed.endsWith("/opchat")) return `${trimmed}/v1`;
|
|
22
|
-
if (trimmed.endsWith("/v1")) {
|
|
23
|
-
trimmed = trimmed.slice(0, -"/v1".length);
|
|
24
|
-
}
|
|
25
|
-
return `${trimTrailingSlashes(trimmed)}/opchat/v1`;
|
|
26
|
-
}
|
|
27
|
-
function resolveOpChatApiBaseUrl(options = {}) {
|
|
28
|
-
const runtimeEnv = options.env ?? (typeof process !== "undefined" ? process.env : {});
|
|
29
|
-
const explicit = normalizeOptionalOpChatApiBaseUrl(options.opChatApiBaseUrl) ?? normalizeOptionalOpChatApiBaseUrl(runtimeEnv.OPENPOND_OPCHAT_API_URL);
|
|
30
|
-
if (explicit) return explicit;
|
|
31
|
-
const migrationInput = normalizeOptionalOpChatApiBaseUrl(options.chatApiBaseUrl) ?? normalizeOptionalOpChatApiBaseUrl(runtimeEnv.OPENPOND_CHAT_API_URL) ?? normalizeOptionalOpChatApiBaseUrl(runtimeEnv.OPENPOND_GATEWAY_URL);
|
|
32
|
-
if (migrationInput) return migrationInput;
|
|
33
|
-
const apiBase = normalizeOptionalOpChatApiBaseUrl(options.apiBaseUrl) ?? normalizeOptionalOpChatApiBaseUrl(runtimeEnv.OPENPOND_API_URL);
|
|
34
|
-
return apiBase ?? DEFAULT_OPENPOND_OPCHAT_API_BASE_URL;
|
|
35
|
-
}
|
|
36
|
-
function requireToken(value) {
|
|
37
|
-
const trimmed = value.trim();
|
|
38
|
-
if (!trimmed) throw new Error("OpenPond API key is required");
|
|
39
|
-
return trimmed;
|
|
40
|
-
}
|
|
41
|
-
function hostedHeaders(token, accept, requestId) {
|
|
42
|
-
const headers = new Headers();
|
|
43
|
-
headers.set("Authorization", `Bearer ${requireToken(token)}`);
|
|
44
|
-
headers.set("Content-Type", "application/json");
|
|
45
|
-
headers.set("Accept", accept);
|
|
46
|
-
headers.set("x-openpond-client", "openpond-code");
|
|
47
|
-
headers.set("x-openpond-request-id", requestId || randomUUID());
|
|
48
|
-
return headers;
|
|
49
|
-
}
|
|
50
|
-
async function readError(response) {
|
|
51
|
-
const text = await response.text().catch(() => "");
|
|
52
|
-
if (!text) return response.statusText || `HTTP ${response.status}`;
|
|
53
|
-
try {
|
|
54
|
-
const payload = JSON.parse(text);
|
|
55
|
-
const error = typeof payload.error === "string" ? payload.error : payload.error && typeof payload.error === "object" && !Array.isArray(payload.error) ? payload.error : null;
|
|
56
|
-
const code = typeof payload.code === "string" ? payload.code : error && typeof error !== "string" && typeof error.code === "string" ? error.code : null;
|
|
57
|
-
const message = typeof payload.message === "string" ? payload.message : error && typeof error !== "string" && typeof error.message === "string" ? error.message : null;
|
|
58
|
-
const label = typeof error === "string" ? error : error && typeof error.type === "string" ? error.type : null;
|
|
59
|
-
return [code, label, message].filter(Boolean).join(": ") || text;
|
|
60
|
-
} catch {
|
|
61
|
-
return text;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
function buildHostedChatBody(options, stream) {
|
|
65
|
-
const body = {
|
|
66
|
-
model: options.model,
|
|
67
|
-
messages: options.messages,
|
|
68
|
-
stream
|
|
69
|
-
};
|
|
70
|
-
if (typeof options.temperature === "number") {
|
|
71
|
-
body.temperature = options.temperature;
|
|
72
|
-
}
|
|
73
|
-
if (typeof options.maxTokens === "number") {
|
|
74
|
-
body.max_tokens = options.maxTokens;
|
|
75
|
-
}
|
|
76
|
-
if (options.tools) {
|
|
77
|
-
body.tools = options.tools;
|
|
78
|
-
}
|
|
79
|
-
const toolChoice = options.toolChoice ?? options.tool_choice;
|
|
80
|
-
if (toolChoice !== void 0) {
|
|
81
|
-
body.tool_choice = toolChoice;
|
|
82
|
-
}
|
|
83
|
-
if (options.metadata) {
|
|
84
|
-
body.metadata = options.metadata;
|
|
85
|
-
}
|
|
86
|
-
return body;
|
|
87
|
-
}
|
|
88
|
-
async function listOpChatModels(options) {
|
|
89
|
-
const apiBaseUrl = normalizeApiBaseUrl(options.apiBaseUrl);
|
|
90
|
-
const requestUrl = `${apiBaseUrl}/models`;
|
|
91
|
-
const response = await fetch(requestUrl, {
|
|
92
|
-
method: "GET",
|
|
93
|
-
headers: hostedHeaders(options.token, "application/json"),
|
|
94
|
-
signal: options.signal
|
|
95
|
-
});
|
|
96
|
-
if (!response.ok) {
|
|
97
|
-
throw new Error(
|
|
98
|
-
`Hosted model list failed: ${response.status} ${await readError(
|
|
99
|
-
response
|
|
100
|
-
)}`
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
return await response.json();
|
|
104
|
-
}
|
|
105
|
-
async function getOpChatModel(options) {
|
|
106
|
-
const apiBaseUrl = normalizeApiBaseUrl(options.apiBaseUrl);
|
|
107
|
-
const requestUrl = `${apiBaseUrl}/models/${encodeURIComponent(options.model)}`;
|
|
108
|
-
const response = await fetch(
|
|
109
|
-
requestUrl,
|
|
110
|
-
{
|
|
111
|
-
method: "GET",
|
|
112
|
-
headers: hostedHeaders(options.token, "application/json"),
|
|
113
|
-
signal: options.signal
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
if (!response.ok) {
|
|
117
|
-
throw new Error(
|
|
118
|
-
`Hosted model lookup failed: ${response.status} ${await readError(
|
|
119
|
-
response
|
|
120
|
-
)}`
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
return await response.json();
|
|
124
|
-
}
|
|
125
|
-
async function sendHostedChatTurn(options) {
|
|
126
|
-
const apiBaseUrl = normalizeApiBaseUrl(options.apiBaseUrl);
|
|
127
|
-
const requestUrl = `${apiBaseUrl}/chat/completions`;
|
|
128
|
-
const response = await fetch(requestUrl, {
|
|
129
|
-
method: "POST",
|
|
130
|
-
headers: hostedHeaders(
|
|
131
|
-
options.token,
|
|
132
|
-
"application/json",
|
|
133
|
-
options.requestId
|
|
134
|
-
),
|
|
135
|
-
body: JSON.stringify(buildHostedChatBody(options, false)),
|
|
136
|
-
signal: options.signal
|
|
137
|
-
});
|
|
138
|
-
if (!response.ok) {
|
|
139
|
-
throw new Error(
|
|
140
|
-
`Hosted chat failed: ${response.status} ${await readError(response)}`
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
return await response.json();
|
|
144
|
-
}
|
|
145
|
-
async function* parseOpenAISSE(stream, signal) {
|
|
146
|
-
const reader = stream.getReader();
|
|
147
|
-
const decoder = new TextDecoder();
|
|
148
|
-
let buffer = "";
|
|
149
|
-
const readAbortError = () => signal?.reason instanceof Error ? signal.reason : new Error("hosted_chat_aborted");
|
|
150
|
-
try {
|
|
151
|
-
while (true) {
|
|
152
|
-
if (signal?.aborted) throw readAbortError();
|
|
153
|
-
const result = await reader.read();
|
|
154
|
-
if (result.done) break;
|
|
155
|
-
buffer += decoder.decode(result.value, { stream: true });
|
|
156
|
-
const lines = buffer.split("\n");
|
|
157
|
-
buffer = lines.pop() || "";
|
|
158
|
-
for (const line of lines) {
|
|
159
|
-
const trimmed = line.trim();
|
|
160
|
-
if (!trimmed.startsWith("data:")) continue;
|
|
161
|
-
const data = trimmed.slice(5).trim();
|
|
162
|
-
if (!data) continue;
|
|
163
|
-
if (data === "[DONE]") return;
|
|
164
|
-
yield JSON.parse(data);
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
} finally {
|
|
168
|
-
try {
|
|
169
|
-
reader.releaseLock();
|
|
170
|
-
} catch {
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
async function* streamHostedChatTurn(options) {
|
|
175
|
-
const apiBaseUrl = normalizeApiBaseUrl(options.apiBaseUrl);
|
|
176
|
-
const requestUrl = `${apiBaseUrl}/chat/completions`;
|
|
177
|
-
const response = await fetch(requestUrl, {
|
|
178
|
-
method: "POST",
|
|
179
|
-
headers: hostedHeaders(
|
|
180
|
-
options.token,
|
|
181
|
-
"text/event-stream",
|
|
182
|
-
options.requestId
|
|
183
|
-
),
|
|
184
|
-
body: JSON.stringify(buildHostedChatBody(options, true)),
|
|
185
|
-
signal: options.signal
|
|
186
|
-
});
|
|
187
|
-
if (!response.ok || !response.body) {
|
|
188
|
-
throw new Error(
|
|
189
|
-
`Hosted chat stream failed: ${response.status} ${await readError(
|
|
190
|
-
response
|
|
191
|
-
)}`
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
for await (const raw of parseOpenAISSE(response.body, options.signal)) {
|
|
195
|
-
const chunk = raw;
|
|
196
|
-
if (chunk.error) {
|
|
197
|
-
throw new Error(chunk.error.message || "Hosted chat stream error");
|
|
198
|
-
}
|
|
199
|
-
if (chunk.usage) {
|
|
200
|
-
yield { type: "usage", usage: chunk.usage, raw };
|
|
201
|
-
}
|
|
202
|
-
const choice = chunk.choices?.[0];
|
|
203
|
-
if (!choice) continue;
|
|
204
|
-
const content = choice.delta?.content;
|
|
205
|
-
if (content) {
|
|
206
|
-
yield { type: "text_delta", text: content, raw };
|
|
207
|
-
}
|
|
208
|
-
const reasoning = choice.delta?.reasoning_content;
|
|
209
|
-
if (reasoning) {
|
|
210
|
-
yield { type: "reasoning_delta", text: reasoning, raw };
|
|
211
|
-
}
|
|
212
|
-
const toolCalls = choice.delta?.tool_calls;
|
|
213
|
-
if (Array.isArray(toolCalls) && toolCalls.length > 0) {
|
|
214
|
-
yield { type: "tool_call_delta", toolCalls, raw };
|
|
215
|
-
}
|
|
216
|
-
if (choice.finish_reason !== void 0 && choice.finish_reason !== null) {
|
|
217
|
-
yield { type: "finish", finishReason: choice.finish_reason, raw };
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
// ../../packages/cloud/src/opchat-smoke.ts
|
|
223
|
-
var DEFAULT_MODEL = "openpond-chat";
|
|
224
|
-
var COMPATIBILITY_MODEL = "deepseek-v4-flash";
|
|
225
|
-
var INVALID_MODEL = "not-a-real-opchat-model";
|
|
226
|
-
async function runOpChatSmoke(options) {
|
|
227
|
-
const defaultModel = options.defaultModel || DEFAULT_MODEL;
|
|
228
|
-
const compatibilityModel = options.compatibilityModel || COMPATIBILITY_MODEL;
|
|
229
|
-
const invalidModel = options.invalidModel || INVALID_MODEL;
|
|
230
|
-
const log = options.log || (() => void 0);
|
|
231
|
-
log(`opchat base: ${options.apiBaseUrl}`);
|
|
232
|
-
const models = await listOpChatModels({
|
|
233
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
234
|
-
token: options.token
|
|
235
|
-
});
|
|
236
|
-
const listedModels = models.data.map((model) => model.id);
|
|
237
|
-
requireModel(listedModels, defaultModel);
|
|
238
|
-
requireModel(listedModels, compatibilityModel);
|
|
239
|
-
log(`models: ${listedModels.join(", ")}`);
|
|
240
|
-
const defaultLookup = await getOpChatModel({
|
|
241
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
242
|
-
token: options.token,
|
|
243
|
-
model: defaultModel
|
|
244
|
-
});
|
|
245
|
-
const compatibilityLookup = await getOpChatModel({
|
|
246
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
247
|
-
token: options.token,
|
|
248
|
-
model: compatibilityModel
|
|
249
|
-
});
|
|
250
|
-
const invalidModelError = await expectInvalidModel({
|
|
251
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
252
|
-
token: options.token,
|
|
253
|
-
model: invalidModel
|
|
254
|
-
});
|
|
255
|
-
log(`invalid model error: ${invalidModelError}`);
|
|
256
|
-
const nonStreaming = summarizeCompletion(
|
|
257
|
-
defaultModel,
|
|
258
|
-
await sendHostedChatTurn({
|
|
259
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
260
|
-
token: options.token,
|
|
261
|
-
model: defaultModel,
|
|
262
|
-
messages: [
|
|
263
|
-
{
|
|
264
|
-
role: "user",
|
|
265
|
-
content: "Reply with a short plain sentence confirming OpChat works."
|
|
266
|
-
}
|
|
267
|
-
],
|
|
268
|
-
metadata: { source: "openpond-code-opchat-smoke", mode: "non_stream" }
|
|
269
|
-
})
|
|
270
|
-
);
|
|
271
|
-
requireText(nonStreaming, `${defaultModel} non-streaming response`);
|
|
272
|
-
log(
|
|
273
|
-
`${defaultModel} non-stream: id=${nonStreaming.id ?? "unknown"} usage=${formatUsage(
|
|
274
|
-
nonStreaming.usage
|
|
275
|
-
)}`
|
|
276
|
-
);
|
|
277
|
-
const streaming = options.skipStream ? void 0 : await runStreamSmoke({
|
|
278
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
279
|
-
token: options.token,
|
|
280
|
-
model: defaultModel
|
|
281
|
-
});
|
|
282
|
-
if (streaming) {
|
|
283
|
-
log(
|
|
284
|
-
`${defaultModel} stream: chunks=${streaming.textDeltaCount} finish=${streaming.finishReason ?? "none"} usage=${formatUsage(streaming.usage)}`
|
|
285
|
-
);
|
|
286
|
-
}
|
|
287
|
-
const compatibilityNonStreaming = summarizeCompletion(
|
|
288
|
-
compatibilityModel,
|
|
289
|
-
await sendHostedChatTurn({
|
|
290
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
291
|
-
token: options.token,
|
|
292
|
-
model: compatibilityModel,
|
|
293
|
-
messages: [
|
|
294
|
-
{
|
|
295
|
-
role: "user",
|
|
296
|
-
content: "Reply with one short sentence confirming compatibility."
|
|
297
|
-
}
|
|
298
|
-
],
|
|
299
|
-
metadata: {
|
|
300
|
-
source: "openpond-code-opchat-smoke",
|
|
301
|
-
mode: "compatibility_non_stream"
|
|
302
|
-
}
|
|
303
|
-
})
|
|
304
|
-
);
|
|
305
|
-
requireText(
|
|
306
|
-
compatibilityNonStreaming,
|
|
307
|
-
`${compatibilityModel} non-streaming response`
|
|
308
|
-
);
|
|
309
|
-
log(
|
|
310
|
-
`${compatibilityModel} non-stream: id=${compatibilityNonStreaming.id ?? "unknown"} usage=${formatUsage(compatibilityNonStreaming.usage)}`
|
|
311
|
-
);
|
|
312
|
-
const toolCalling = options.skipTool ? void 0 : await runToolSmoke({
|
|
313
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
314
|
-
token: options.token,
|
|
315
|
-
model: defaultModel
|
|
316
|
-
});
|
|
317
|
-
if (toolCalling) {
|
|
318
|
-
log(
|
|
319
|
-
`${defaultModel} tool: calls=${toolCalling.toolCallCount} names=${toolCalling.toolNames.join(
|
|
320
|
-
","
|
|
321
|
-
)}`
|
|
322
|
-
);
|
|
323
|
-
}
|
|
324
|
-
return {
|
|
325
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
326
|
-
listedModels,
|
|
327
|
-
defaultModel,
|
|
328
|
-
compatibilityModel,
|
|
329
|
-
modelLookups: [defaultLookup.id, compatibilityLookup.id],
|
|
330
|
-
invalidModelError,
|
|
331
|
-
nonStreaming,
|
|
332
|
-
compatibilityNonStreaming,
|
|
333
|
-
...streaming ? { streaming } : {},
|
|
334
|
-
...toolCalling ? { toolCalling } : {}
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
async function expectInvalidModel(options) {
|
|
338
|
-
try {
|
|
339
|
-
await getOpChatModel(options);
|
|
340
|
-
} catch (error) {
|
|
341
|
-
return error instanceof Error ? error.message : String(error);
|
|
342
|
-
}
|
|
343
|
-
throw new Error(`expected invalid model ${options.model} to fail`);
|
|
344
|
-
}
|
|
345
|
-
async function runStreamSmoke(options) {
|
|
346
|
-
const startedAt = Date.now();
|
|
347
|
-
let firstTextAt = null;
|
|
348
|
-
let text = "";
|
|
349
|
-
let textDeltaCount = 0;
|
|
350
|
-
let finishReason = null;
|
|
351
|
-
let usage = null;
|
|
352
|
-
for await (const chunk of streamHostedChatTurn({
|
|
353
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
354
|
-
token: options.token,
|
|
355
|
-
model: options.model,
|
|
356
|
-
messages: [
|
|
357
|
-
{
|
|
358
|
-
role: "user",
|
|
359
|
-
content: "Reply with a short streamed sentence."
|
|
360
|
-
}
|
|
361
|
-
],
|
|
362
|
-
metadata: { source: "openpond-code-opchat-smoke", mode: "stream" }
|
|
363
|
-
})) {
|
|
364
|
-
if (chunk.type === "text_delta") {
|
|
365
|
-
firstTextAt ??= Date.now();
|
|
366
|
-
text += chunk.text;
|
|
367
|
-
textDeltaCount += 1;
|
|
368
|
-
} else if (chunk.type === "finish") {
|
|
369
|
-
finishReason = chunk.finishReason;
|
|
370
|
-
} else if (chunk.type === "usage") {
|
|
371
|
-
usage = chunk.usage;
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
if (textDeltaCount === 0 || !text.trim()) {
|
|
375
|
-
throw new Error("streaming response did not emit text deltas");
|
|
376
|
-
}
|
|
377
|
-
if (!finishReason) {
|
|
378
|
-
throw new Error("streaming response did not emit a terminal finish marker");
|
|
379
|
-
}
|
|
380
|
-
return {
|
|
381
|
-
model: options.model,
|
|
382
|
-
textDeltaCount,
|
|
383
|
-
textPreview: previewText(text),
|
|
384
|
-
firstTextMs: firstTextAt === null ? null : firstTextAt - startedAt,
|
|
385
|
-
totalMs: Date.now() - startedAt,
|
|
386
|
-
finishReason,
|
|
387
|
-
usage
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
async function runToolSmoke(options) {
|
|
391
|
-
const tools = [
|
|
392
|
-
{
|
|
393
|
-
type: "function",
|
|
394
|
-
function: {
|
|
395
|
-
name: "get_current_weather",
|
|
396
|
-
description: "Get the current weather for a city.",
|
|
397
|
-
parameters: {
|
|
398
|
-
type: "object",
|
|
399
|
-
properties: {
|
|
400
|
-
location: {
|
|
401
|
-
type: "string",
|
|
402
|
-
description: "City and region, for example Boston, MA."
|
|
403
|
-
}
|
|
404
|
-
},
|
|
405
|
-
required: ["location"]
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
];
|
|
410
|
-
const messages = [
|
|
411
|
-
{
|
|
412
|
-
role: "user",
|
|
413
|
-
content: "Use the get_current_weather tool for Boston, then wait for the result."
|
|
414
|
-
}
|
|
415
|
-
];
|
|
416
|
-
const toolCompletion = await sendHostedChatTurn({
|
|
417
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
418
|
-
token: options.token,
|
|
419
|
-
model: options.model,
|
|
420
|
-
messages,
|
|
421
|
-
tools,
|
|
422
|
-
toolChoice: "auto",
|
|
423
|
-
metadata: { source: "openpond-code-opchat-smoke", mode: "tool_call" }
|
|
424
|
-
});
|
|
425
|
-
const choice = toolCompletion.choices?.[0];
|
|
426
|
-
const toolCalls = choice?.message?.tool_calls ?? [];
|
|
427
|
-
if (toolCalls.length === 0) {
|
|
428
|
-
throw new Error("tool smoke did not receive an assistant tool call");
|
|
429
|
-
}
|
|
430
|
-
const toolResultMessages = buildToolResultMessages(toolCalls);
|
|
431
|
-
const followUp = summarizeCompletion(
|
|
432
|
-
options.model,
|
|
433
|
-
await sendHostedChatTurn({
|
|
434
|
-
apiBaseUrl: options.apiBaseUrl,
|
|
435
|
-
token: options.token,
|
|
436
|
-
model: options.model,
|
|
437
|
-
messages: [
|
|
438
|
-
...messages,
|
|
439
|
-
{
|
|
440
|
-
role: "assistant",
|
|
441
|
-
content: choice?.message?.content ?? null,
|
|
442
|
-
tool_calls: toolCalls
|
|
443
|
-
},
|
|
444
|
-
...toolResultMessages
|
|
445
|
-
],
|
|
446
|
-
metadata: { source: "openpond-code-opchat-smoke", mode: "tool_result" }
|
|
447
|
-
})
|
|
448
|
-
);
|
|
449
|
-
requireText(followUp, "tool follow-up response");
|
|
450
|
-
return {
|
|
451
|
-
model: options.model,
|
|
452
|
-
toolCallCount: toolCalls.length,
|
|
453
|
-
toolNames: toolCalls.map((toolCall) => toolCall.function?.name).filter((name) => Boolean(name)),
|
|
454
|
-
finishReason: choice?.finish_reason ?? null,
|
|
455
|
-
followUp
|
|
456
|
-
};
|
|
457
|
-
}
|
|
458
|
-
function buildToolResultMessages(toolCalls) {
|
|
459
|
-
return toolCalls.map((toolCall, index) => {
|
|
460
|
-
if (!toolCall.id) {
|
|
461
|
-
throw new Error(`tool call ${index} is missing an id`);
|
|
462
|
-
}
|
|
463
|
-
return {
|
|
464
|
-
role: "tool",
|
|
465
|
-
tool_call_id: toolCall.id,
|
|
466
|
-
content: JSON.stringify({
|
|
467
|
-
location: "Boston, MA",
|
|
468
|
-
temperature: "58 F",
|
|
469
|
-
conditions: "clear"
|
|
470
|
-
})
|
|
471
|
-
};
|
|
472
|
-
});
|
|
473
|
-
}
|
|
474
|
-
function summarizeCompletion(model, completion) {
|
|
475
|
-
const choice = completion.choices?.[0];
|
|
476
|
-
return {
|
|
477
|
-
model,
|
|
478
|
-
id: completion.id ?? null,
|
|
479
|
-
finishReason: choice?.finish_reason ?? null,
|
|
480
|
-
textPreview: previewText(choice?.message?.content ?? ""),
|
|
481
|
-
usage: completion.usage ?? null
|
|
482
|
-
};
|
|
483
|
-
}
|
|
484
|
-
function requireModel(models, expected) {
|
|
485
|
-
if (!models.includes(expected)) {
|
|
486
|
-
throw new Error(`model list did not include ${expected}`);
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
function requireText(summary, label) {
|
|
490
|
-
if (!summary.textPreview.trim()) {
|
|
491
|
-
throw new Error(`${label} did not include assistant text`);
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
function previewText(value, maxLength = 120) {
|
|
495
|
-
const normalized = value.replace(/\s+/g, " ").trim();
|
|
496
|
-
return normalized.length <= maxLength ? normalized : `${normalized.slice(0, maxLength - 1)}...`;
|
|
497
|
-
}
|
|
498
|
-
function formatUsage(usage) {
|
|
499
|
-
if (!usage) return "none";
|
|
500
|
-
return String(
|
|
501
|
-
usage.total_tokens ?? usage.input_tokens ?? usage.output_tokens ?? "unknown"
|
|
502
|
-
);
|
|
503
|
-
}
|
|
504
|
-
|
|
505
|
-
export {
|
|
506
|
-
resolveOpChatApiBaseUrl,
|
|
507
|
-
listOpChatModels,
|
|
508
|
-
getOpChatModel,
|
|
509
|
-
sendHostedChatTurn,
|
|
510
|
-
streamHostedChatTurn,
|
|
511
|
-
runOpChatSmoke
|
|
512
|
-
};
|