openpond-code 0.1.0 → 0.1.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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/cli.js +135 -139
- package/dist/index.js +50 -55
- package/package.json +9 -1
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -102,7 +102,7 @@ await client.apps.agentCreate(
|
|
|
102
102
|
You can override hosts with `baseUrl`, `apiUrl`, and `toolUrl` in `createClient`, or
|
|
103
103
|
via `OPENPOND_BASE_URL`, `OPENPOND_API_URL`, and `OPENPOND_TOOL_URL`.
|
|
104
104
|
|
|
105
|
-
Examples live in `
|
|
105
|
+
Examples live in `examples`.
|
|
106
106
|
|
|
107
107
|
## Local TUI
|
|
108
108
|
|
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/cli-package.ts
|
|
4
|
-
import {spawn} from "node:child_process";
|
|
5
|
-
import {promises as fs3, existsSync} from "node:fs";
|
|
4
|
+
import { spawn } from "node:child_process";
|
|
5
|
+
import { promises as fs3, existsSync } from "node:fs";
|
|
6
6
|
import path3 from "node:path";
|
|
7
|
-
import {stdin as input, stdout as output} from "node:process";
|
|
8
|
-
import {createInterface} from "node:readline/promises";
|
|
7
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
8
|
+
import { createInterface } from "node:readline/promises";
|
|
9
9
|
|
|
10
10
|
// src/api.ts
|
|
11
11
|
async function apiFetch(baseUrl, token, path, init) {
|
|
@@ -257,10 +257,10 @@ async function getDeploymentDetail(apiBase, token, deploymentId) {
|
|
|
257
257
|
const payload = await response.json().catch(() => ({}));
|
|
258
258
|
return payload.deployment ?? null;
|
|
259
259
|
}
|
|
260
|
-
|
|
260
|
+
function normalizeToolPathSegment(toolName) {
|
|
261
261
|
const trimmed = toolName.trim().replace(/^\/+/, "");
|
|
262
262
|
return encodeURIComponent(trimmed || "tool");
|
|
263
|
-
}
|
|
263
|
+
}
|
|
264
264
|
function resolveWorkerBaseUrl(baseUrl) {
|
|
265
265
|
const trimmed = baseUrl.replace(/\/$/, "");
|
|
266
266
|
const workerEnv = process.env.OPENPOND_TOOL_URL;
|
|
@@ -287,8 +287,7 @@ function resolveWorkerBaseUrl(baseUrl) {
|
|
|
287
287
|
if (isLocal && port === "3000") {
|
|
288
288
|
return trimmed;
|
|
289
289
|
}
|
|
290
|
-
} catch {
|
|
291
|
-
}
|
|
290
|
+
} catch {}
|
|
292
291
|
return trimmed;
|
|
293
292
|
}
|
|
294
293
|
async function executeHostedTool(baseUrl, token, payload) {
|
|
@@ -320,13 +319,17 @@ async function executeHostedTool(baseUrl, token, payload) {
|
|
|
320
319
|
}
|
|
321
320
|
|
|
322
321
|
// src/cache.ts
|
|
323
|
-
import {promises as fs} from "node:fs";
|
|
322
|
+
import { promises as fs } from "node:fs";
|
|
324
323
|
import os from "node:os";
|
|
325
324
|
import path from "node:path";
|
|
326
|
-
var
|
|
325
|
+
var CACHE_DIR = ".openpond";
|
|
326
|
+
var CACHE_FILENAME = "cache.json";
|
|
327
|
+
var DEFAULT_STORE = { version: 1, byKey: {} };
|
|
328
|
+
var DEFAULT_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
329
|
+
function getCachePath() {
|
|
327
330
|
return path.join(os.homedir(), CACHE_DIR, CACHE_FILENAME);
|
|
328
|
-
}
|
|
329
|
-
|
|
331
|
+
}
|
|
332
|
+
function buildCacheKey(apiBase, apiKey) {
|
|
330
333
|
const trimmed = apiKey.trim();
|
|
331
334
|
const hint = trimmed.length > 12 ? `${trimmed.slice(0, 8)}_${trimmed.slice(-4)}` : trimmed;
|
|
332
335
|
try {
|
|
@@ -335,14 +338,14 @@ var buildCacheKey = function(apiBase, apiKey) {
|
|
|
335
338
|
} catch {
|
|
336
339
|
return `${apiBase}:${hint}`;
|
|
337
340
|
}
|
|
338
|
-
}
|
|
339
|
-
|
|
341
|
+
}
|
|
342
|
+
function isFresh(updatedAt, ttlMs) {
|
|
340
343
|
const timestamp = Date.parse(updatedAt);
|
|
341
344
|
if (Number.isNaN(timestamp)) {
|
|
342
345
|
return false;
|
|
343
346
|
}
|
|
344
347
|
return Date.now() - timestamp < ttlMs;
|
|
345
|
-
}
|
|
348
|
+
}
|
|
346
349
|
async function loadCache() {
|
|
347
350
|
try {
|
|
348
351
|
const raw = await fs.readFile(getCachePath(), "utf-8");
|
|
@@ -402,18 +405,16 @@ async function setCachedTools(params) {
|
|
|
402
405
|
store.byKey[cacheKey] = bucket;
|
|
403
406
|
await saveCache(store);
|
|
404
407
|
}
|
|
405
|
-
var CACHE_DIR = ".openpond";
|
|
406
|
-
var CACHE_FILENAME = "cache.json";
|
|
407
|
-
var DEFAULT_STORE = { version: 1, byKey: {} };
|
|
408
|
-
var DEFAULT_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
409
408
|
|
|
410
409
|
// src/config.ts
|
|
411
|
-
import {promises as fs2} from "node:fs";
|
|
410
|
+
import { promises as fs2 } from "node:fs";
|
|
412
411
|
import os2 from "node:os";
|
|
413
412
|
import path2 from "node:path";
|
|
414
|
-
var
|
|
413
|
+
var GLOBAL_DIRNAME = ".openpond";
|
|
414
|
+
var GLOBAL_CONFIG_FILENAME = "config.json";
|
|
415
|
+
function getGlobalConfigPath() {
|
|
415
416
|
return path2.join(os2.homedir(), GLOBAL_DIRNAME, GLOBAL_CONFIG_FILENAME);
|
|
416
|
-
}
|
|
417
|
+
}
|
|
417
418
|
async function loadConfigFile(filePath) {
|
|
418
419
|
try {
|
|
419
420
|
const raw = await fs2.readFile(filePath, "utf-8");
|
|
@@ -445,8 +446,6 @@ async function saveGlobalConfig(next) {
|
|
|
445
446
|
const payload = JSON.stringify(merged, null, 2);
|
|
446
447
|
await fs2.writeFile(filePath, payload, "utf-8");
|
|
447
448
|
}
|
|
448
|
-
var GLOBAL_DIRNAME = ".openpond";
|
|
449
|
-
var GLOBAL_CONFIG_FILENAME = "config.json";
|
|
450
449
|
|
|
451
450
|
// src/stream.ts
|
|
452
451
|
function normalizeDataFrames(raw) {
|
|
@@ -485,7 +484,7 @@ function normalizeDataFrames(raw) {
|
|
|
485
484
|
}
|
|
486
485
|
return { conversationId, items };
|
|
487
486
|
}
|
|
488
|
-
|
|
487
|
+
function extractUsage(raw) {
|
|
489
488
|
const frames = Array.isArray(raw) ? raw : raw && typeof raw === "object" && Array.isArray(raw.data) ? raw.data : [raw];
|
|
490
489
|
for (const frame of frames) {
|
|
491
490
|
if (!frame || typeof frame !== "object")
|
|
@@ -502,7 +501,7 @@ var extractUsage = function(raw) {
|
|
|
502
501
|
return { promptTokens, completionTokens, totalTokens };
|
|
503
502
|
}
|
|
504
503
|
return null;
|
|
505
|
-
}
|
|
504
|
+
}
|
|
506
505
|
async function consumeStream(response, callbacks) {
|
|
507
506
|
if (!response.body) {
|
|
508
507
|
throw new Error("Missing response body");
|
|
@@ -517,8 +516,7 @@ async function consumeStream(response, callbacks) {
|
|
|
517
516
|
}
|
|
518
517
|
try {
|
|
519
518
|
await reader.cancel();
|
|
520
|
-
} catch {
|
|
521
|
-
}
|
|
519
|
+
} catch {}
|
|
522
520
|
callbacks.onStop?.();
|
|
523
521
|
return true;
|
|
524
522
|
};
|
|
@@ -528,7 +526,8 @@ async function consumeStream(response, callbacks) {
|
|
|
528
526
|
break;
|
|
529
527
|
const chunk = decoder.decode(value, { stream: true });
|
|
530
528
|
const textChunk = remainder + chunk;
|
|
531
|
-
const lines = textChunk.split(
|
|
529
|
+
const lines = textChunk.split(`
|
|
530
|
+
`);
|
|
532
531
|
remainder = lines.pop() || "";
|
|
533
532
|
for (const line of lines) {
|
|
534
533
|
if (!line)
|
|
@@ -565,8 +564,7 @@ async function consumeStream(response, callbacks) {
|
|
|
565
564
|
if (typeof message === "string") {
|
|
566
565
|
throw new Error(message);
|
|
567
566
|
}
|
|
568
|
-
} catch {
|
|
569
|
-
}
|
|
567
|
+
} catch {}
|
|
570
568
|
continue;
|
|
571
569
|
}
|
|
572
570
|
if (line.startsWith("2:")) {
|
|
@@ -589,8 +587,7 @@ async function consumeStream(response, callbacks) {
|
|
|
589
587
|
if (await stopIfNeeded()) {
|
|
590
588
|
return;
|
|
591
589
|
}
|
|
592
|
-
} catch {
|
|
593
|
-
}
|
|
590
|
+
} catch {}
|
|
594
591
|
}
|
|
595
592
|
if (await stopIfNeeded()) {
|
|
596
593
|
return;
|
|
@@ -623,7 +620,7 @@ function formatStreamItem(item) {
|
|
|
623
620
|
}
|
|
624
621
|
|
|
625
622
|
// src/cli-package.ts
|
|
626
|
-
|
|
623
|
+
function parseArgs(argv) {
|
|
627
624
|
const args = [...argv];
|
|
628
625
|
const command = args.shift() || "";
|
|
629
626
|
const options = {};
|
|
@@ -640,18 +637,18 @@ var parseArgs = function(argv) {
|
|
|
640
637
|
}
|
|
641
638
|
}
|
|
642
639
|
return { command, options, rest };
|
|
643
|
-
}
|
|
644
|
-
|
|
640
|
+
}
|
|
641
|
+
function resolveBaseUrl(config) {
|
|
645
642
|
const envBase = process.env.OPENPOND_BASE_URL;
|
|
646
|
-
const base = envBase ||
|
|
643
|
+
const base = envBase || config.baseUrl || "https://openpond.ai";
|
|
647
644
|
return base.replace(/\/$/, "");
|
|
648
|
-
}
|
|
649
|
-
|
|
645
|
+
}
|
|
646
|
+
function resolvePublicApiBaseUrl() {
|
|
650
647
|
const envBase = process.env.OPENPOND_API_URL;
|
|
651
648
|
const base = envBase || "https://api.openpond.ai";
|
|
652
649
|
return base.replace(/\/$/, "");
|
|
653
|
-
}
|
|
654
|
-
|
|
650
|
+
}
|
|
651
|
+
function normalizeTemplateRepoUrl(input2, baseUrl) {
|
|
655
652
|
const trimmed = input2.trim();
|
|
656
653
|
if (!trimmed) {
|
|
657
654
|
throw new Error("template must be non-empty");
|
|
@@ -666,23 +663,23 @@ var normalizeTemplateRepoUrl = function(input2, baseUrl) {
|
|
|
666
663
|
throw new Error("template must be <owner>/<repo> or a full https URL");
|
|
667
664
|
}
|
|
668
665
|
return `${normalizedBase}/${owner}/${repo}.git`;
|
|
669
|
-
}
|
|
670
|
-
|
|
666
|
+
}
|
|
667
|
+
function parseJsonOption(value, label) {
|
|
671
668
|
try {
|
|
672
669
|
return JSON.parse(value);
|
|
673
670
|
} catch {
|
|
674
671
|
throw new Error(`${label} must be valid JSON`);
|
|
675
672
|
}
|
|
676
|
-
}
|
|
677
|
-
|
|
673
|
+
}
|
|
674
|
+
function parseBooleanOption(value) {
|
|
678
675
|
if (value === true)
|
|
679
676
|
return true;
|
|
680
677
|
if (typeof value === "string") {
|
|
681
678
|
return value.toLowerCase() === "true";
|
|
682
679
|
}
|
|
683
680
|
return false;
|
|
684
|
-
}
|
|
685
|
-
|
|
681
|
+
}
|
|
682
|
+
function parseTimeOption(value, label) {
|
|
686
683
|
if (typeof value !== "string")
|
|
687
684
|
return;
|
|
688
685
|
const trimmed = value.trim();
|
|
@@ -695,20 +692,20 @@ var parseTimeOption = function(value, label) {
|
|
|
695
692
|
return String(parsed);
|
|
696
693
|
}
|
|
697
694
|
throw new Error(`${label} must be a unix ms timestamp or ISO date`);
|
|
698
|
-
}
|
|
699
|
-
|
|
695
|
+
}
|
|
696
|
+
function resolveApiKey(config) {
|
|
700
697
|
const envKey = process.env.OPENPOND_API_KEY?.trim();
|
|
701
698
|
if (envKey)
|
|
702
699
|
return envKey;
|
|
703
|
-
const stored =
|
|
700
|
+
const stored = config.apiKey?.trim();
|
|
704
701
|
if (stored)
|
|
705
702
|
return stored;
|
|
706
|
-
const legacy =
|
|
703
|
+
const legacy = config.token?.trim();
|
|
707
704
|
if (legacy && legacy.startsWith("opk_"))
|
|
708
705
|
return legacy;
|
|
709
706
|
return null;
|
|
710
|
-
}
|
|
711
|
-
|
|
707
|
+
}
|
|
708
|
+
function resolveTemplateEnvironment(value) {
|
|
712
709
|
if (!value)
|
|
713
710
|
return "production";
|
|
714
711
|
const normalized = value.toLowerCase();
|
|
@@ -716,7 +713,8 @@ var resolveTemplateEnvironment = function(value) {
|
|
|
716
713
|
return normalized;
|
|
717
714
|
}
|
|
718
715
|
throw new Error("env must be preview or production");
|
|
719
|
-
}
|
|
716
|
+
}
|
|
717
|
+
var UI_API_KEY_URL = "https://openpond.ai/settings/api-keys";
|
|
720
718
|
async function promptForApiKey() {
|
|
721
719
|
console.log("Open the OpenPond UI to create an API key:");
|
|
722
720
|
console.log(UI_API_KEY_URL);
|
|
@@ -734,8 +732,8 @@ async function promptForApiKey() {
|
|
|
734
732
|
rl.close();
|
|
735
733
|
}
|
|
736
734
|
}
|
|
737
|
-
async function ensureApiKey(
|
|
738
|
-
const existing = resolveApiKey(
|
|
735
|
+
async function ensureApiKey(config, baseUrl) {
|
|
736
|
+
const existing = resolveApiKey(config);
|
|
739
737
|
if (existing)
|
|
740
738
|
return existing;
|
|
741
739
|
const apiKey = await promptForApiKey();
|
|
@@ -793,27 +791,27 @@ async function getGitRemoteUrl(cwd, remoteName) {
|
|
|
793
791
|
const url = result.stdout.trim();
|
|
794
792
|
return url.length > 0 ? url : null;
|
|
795
793
|
}
|
|
796
|
-
|
|
794
|
+
function resolveRepoUrl(response) {
|
|
797
795
|
if (response.repoUrl)
|
|
798
796
|
return response.repoUrl;
|
|
799
797
|
if (response.gitHost && response.gitOwner && response.gitRepo) {
|
|
800
798
|
return `https://${response.gitHost}/${response.gitOwner}/${response.gitRepo}.git`;
|
|
801
799
|
}
|
|
802
800
|
throw new Error("repoUrl missing from API response");
|
|
803
|
-
}
|
|
804
|
-
|
|
801
|
+
}
|
|
802
|
+
function formatTokenizedRepoUrl(repoUrl, token) {
|
|
805
803
|
const url = new URL(repoUrl);
|
|
806
804
|
const encodedToken = encodeURIComponent(token);
|
|
807
805
|
return `${url.protocol}//x-access-token:${encodedToken}@${url.host}${url.pathname}`;
|
|
808
|
-
}
|
|
809
|
-
|
|
806
|
+
}
|
|
807
|
+
function formatTokenizedRepoUrlForPrint(repoUrl) {
|
|
810
808
|
const url = new URL(repoUrl);
|
|
811
|
-
return `${url.protocol}//x-access-token
|
|
812
|
-
}
|
|
813
|
-
|
|
809
|
+
return `${url.protocol}//x-access-token:$OPENPOND_API_KEY@${url.host}${url.pathname}`;
|
|
810
|
+
}
|
|
811
|
+
function redactToken(value) {
|
|
814
812
|
return value.replace(/x-access-token:[^@]+@/g, "x-access-token:***@");
|
|
815
|
-
}
|
|
816
|
-
|
|
813
|
+
}
|
|
814
|
+
function warnOnRepoHostMismatch(repoUrl) {
|
|
817
815
|
const envBase = process.env.OPENPOND_BASE_URL;
|
|
818
816
|
if (!envBase)
|
|
819
817
|
return;
|
|
@@ -822,21 +820,20 @@ var warnOnRepoHostMismatch = function(repoUrl) {
|
|
|
822
820
|
const repoHost = new URL(repoUrl).hostname;
|
|
823
821
|
if (baseHost && repoHost && baseHost !== repoHost) {
|
|
824
822
|
console.warn(`warning: repo host (${repoHost}) does not match OPENPOND_BASE_URL (${baseHost})`);
|
|
825
|
-
console.warn("warning:
|
|
823
|
+
console.warn("warning: verify your git host configuration matches OPENPOND_BASE_URL.");
|
|
826
824
|
}
|
|
827
|
-
} catch {
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
var parseHandleRepo = function(value) {
|
|
825
|
+
} catch {}
|
|
826
|
+
}
|
|
827
|
+
function parseHandleRepo(value) {
|
|
831
828
|
const parts = value.split("/").filter(Boolean);
|
|
832
829
|
if (parts.length !== 2) {
|
|
833
830
|
throw new Error("expected <handle>/<repo>");
|
|
834
831
|
}
|
|
835
832
|
return { handle: parts[0], repo: parts[1] };
|
|
836
|
-
}
|
|
837
|
-
|
|
833
|
+
}
|
|
834
|
+
function normalizeRepoName(value) {
|
|
838
835
|
return (value || "").trim().toLowerCase();
|
|
839
|
-
}
|
|
836
|
+
}
|
|
840
837
|
async function fetchAppsWithCache(params) {
|
|
841
838
|
if (!params.forceRefresh) {
|
|
842
839
|
const cached = await getCachedApps({
|
|
@@ -926,28 +923,28 @@ async function pollDeploymentLogs(params) {
|
|
|
926
923
|
console.log(`${params.prefix}deployment still in progress`);
|
|
927
924
|
}
|
|
928
925
|
async function runTemplateStatus(_options, target) {
|
|
929
|
-
const
|
|
930
|
-
const uiBase = resolveBaseUrl(
|
|
926
|
+
const config = await loadConfig();
|
|
927
|
+
const uiBase = resolveBaseUrl(config);
|
|
931
928
|
const apiBase = resolvePublicApiBaseUrl();
|
|
932
|
-
const apiKey = await ensureApiKey(
|
|
929
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
933
930
|
const { app } = await resolveAppTarget(apiBase, apiKey, target);
|
|
934
931
|
const status = await getTemplateStatus(apiBase, apiKey, app.id);
|
|
935
932
|
console.log(JSON.stringify(status, null, 2));
|
|
936
933
|
}
|
|
937
934
|
async function runTemplateBranches(_options, target) {
|
|
938
|
-
const
|
|
939
|
-
const uiBase = resolveBaseUrl(
|
|
935
|
+
const config = await loadConfig();
|
|
936
|
+
const uiBase = resolveBaseUrl(config);
|
|
940
937
|
const apiBase = resolvePublicApiBaseUrl();
|
|
941
|
-
const apiKey = await ensureApiKey(
|
|
938
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
942
939
|
const { app } = await resolveAppTarget(apiBase, apiKey, target);
|
|
943
940
|
const branches = await listTemplateBranches(apiBase, apiKey, app.id);
|
|
944
941
|
console.log(JSON.stringify(branches, null, 2));
|
|
945
942
|
}
|
|
946
943
|
async function runTemplateUpdate(options, target) {
|
|
947
|
-
const
|
|
948
|
-
const uiBase = resolveBaseUrl(
|
|
944
|
+
const config = await loadConfig();
|
|
945
|
+
const uiBase = resolveBaseUrl(config);
|
|
949
946
|
const apiBase = resolvePublicApiBaseUrl();
|
|
950
|
-
const apiKey = await ensureApiKey(
|
|
947
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
951
948
|
const { app } = await resolveAppTarget(apiBase, apiKey, target);
|
|
952
949
|
const envRaw = typeof options.env === "string" ? options.env : typeof options.environment === "string" ? options.environment : undefined;
|
|
953
950
|
const environment = resolveTemplateEnvironment(envRaw);
|
|
@@ -956,7 +953,7 @@ async function runTemplateUpdate(options, target) {
|
|
|
956
953
|
});
|
|
957
954
|
console.log(JSON.stringify(result, null, 2));
|
|
958
955
|
}
|
|
959
|
-
|
|
956
|
+
function printHelp() {
|
|
960
957
|
console.log("OpenPond CLI (API key only)");
|
|
961
958
|
console.log("");
|
|
962
959
|
console.log("Usage:");
|
|
@@ -984,10 +981,10 @@ var printHelp = function() {
|
|
|
984
981
|
console.log("");
|
|
985
982
|
console.log("Env:");
|
|
986
983
|
console.log(" OPENPOND_API_KEY, OPENPOND_BASE_URL, OPENPOND_API_URL, OPENPOND_TOOL_URL");
|
|
987
|
-
}
|
|
984
|
+
}
|
|
988
985
|
async function runLogin(options) {
|
|
989
|
-
const
|
|
990
|
-
const baseUrl = resolveBaseUrl(
|
|
986
|
+
const config = await loadConfig();
|
|
987
|
+
const baseUrl = resolveBaseUrl(config);
|
|
991
988
|
const rawApiKey = typeof options.apiKey === "string" ? options.apiKey : typeof options.key === "string" ? options.key : null;
|
|
992
989
|
const apiKey = rawApiKey ? rawApiKey.trim() : await promptForApiKey();
|
|
993
990
|
if (!apiKey) {
|
|
@@ -1000,10 +997,10 @@ async function runLogin(options) {
|
|
|
1000
997
|
console.log("saved api key to ~/.openpond/config.json");
|
|
1001
998
|
}
|
|
1002
999
|
async function runToolList(options, target) {
|
|
1003
|
-
const
|
|
1004
|
-
const uiBase = resolveBaseUrl(
|
|
1000
|
+
const config = await loadConfig();
|
|
1001
|
+
const uiBase = resolveBaseUrl(config);
|
|
1005
1002
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1006
|
-
const apiKey = await ensureApiKey(
|
|
1003
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1007
1004
|
const { app } = await resolveAppTarget(apiBase, apiKey, target);
|
|
1008
1005
|
const branch = typeof options.branch === "string" ? String(options.branch) : undefined;
|
|
1009
1006
|
const latest = await getLatestDeploymentForApp(apiBase, apiKey, app.id, { branch });
|
|
@@ -1027,10 +1024,10 @@ async function runToolList(options, target) {
|
|
|
1027
1024
|
}
|
|
1028
1025
|
}
|
|
1029
1026
|
async function runToolRun(options, target, toolName) {
|
|
1030
|
-
const
|
|
1031
|
-
const uiBase = resolveBaseUrl(
|
|
1027
|
+
const config = await loadConfig();
|
|
1028
|
+
const uiBase = resolveBaseUrl(config);
|
|
1032
1029
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1033
|
-
const apiKey = await ensureApiKey(
|
|
1030
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1034
1031
|
const { app } = await resolveAppTarget(apiBase, apiKey, target);
|
|
1035
1032
|
const branch = typeof options.branch === "string" ? String(options.branch) : undefined;
|
|
1036
1033
|
const latest = await getLatestDeploymentForApp(apiBase, apiKey, app.id, { branch });
|
|
@@ -1061,10 +1058,10 @@ async function runToolRun(options, target, toolName) {
|
|
|
1061
1058
|
console.log(JSON.stringify(output2, null, 2));
|
|
1062
1059
|
}
|
|
1063
1060
|
async function runDeployWatch(options, target) {
|
|
1064
|
-
const
|
|
1065
|
-
const uiBase = resolveBaseUrl(
|
|
1061
|
+
const config = await loadConfig();
|
|
1062
|
+
const uiBase = resolveBaseUrl(config);
|
|
1066
1063
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1067
|
-
const apiKey = await ensureApiKey(
|
|
1064
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1068
1065
|
const { app, handle, repo } = await resolveAppTarget(apiBase, apiKey, target);
|
|
1069
1066
|
const branch = typeof options.branch === "string" ? String(options.branch) : undefined;
|
|
1070
1067
|
const deploymentId = typeof options.deploymentId === "string" ? String(options.deploymentId) : undefined;
|
|
@@ -1090,9 +1087,9 @@ async function runRepoCreate(options, nameParts) {
|
|
|
1090
1087
|
if (!trimmedName) {
|
|
1091
1088
|
throw new Error("usage: repo create --name <name> [--path <dir>] [--template <owner/repo|url>] [--template-branch <branch>] [--empty|--opentool] [--token] [--auto-schedule-migration <true|false>]");
|
|
1092
1089
|
}
|
|
1093
|
-
const
|
|
1094
|
-
const uiBase = resolveBaseUrl(
|
|
1095
|
-
const apiKey = await ensureApiKey(
|
|
1090
|
+
const config = await loadConfig();
|
|
1091
|
+
const uiBase = resolveBaseUrl(config);
|
|
1092
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1096
1093
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1097
1094
|
const templateInput = typeof options.template === "string" ? options.template.trim() : "";
|
|
1098
1095
|
if (templateInput && (options.empty === "true" || options.opentool === "true")) {
|
|
@@ -1214,7 +1211,7 @@ async function runRepoCreate(options, nameParts) {
|
|
|
1214
1211
|
console.log(`repo: ${response.gitOwner}/${response.gitRepo}`);
|
|
1215
1212
|
}
|
|
1216
1213
|
console.log(`remote: ${displayRemote}`);
|
|
1217
|
-
console.log(
|
|
1214
|
+
console.log('next: git add . && git commit -m "init"');
|
|
1218
1215
|
const defaultBranch = response.defaultBranch || "master";
|
|
1219
1216
|
console.log(`next: openpond repo push --path ${repoPath} --branch ${defaultBranch}`);
|
|
1220
1217
|
if (!useTokenRemote) {
|
|
@@ -1236,9 +1233,9 @@ async function resolveGitBranch(repoPath) {
|
|
|
1236
1233
|
return branch.length > 0 ? branch : null;
|
|
1237
1234
|
}
|
|
1238
1235
|
async function runRepoPush(options) {
|
|
1239
|
-
const
|
|
1240
|
-
const baseUrl = resolveBaseUrl(
|
|
1241
|
-
const apiKey = await ensureApiKey(
|
|
1236
|
+
const config = await loadConfig();
|
|
1237
|
+
const baseUrl = resolveBaseUrl(config);
|
|
1238
|
+
const apiKey = await ensureApiKey(config, baseUrl);
|
|
1242
1239
|
const rawPath = typeof options.path === "string" ? options.path : typeof options.dir === "string" ? options.dir : null;
|
|
1243
1240
|
const repoPath = path3.resolve(rawPath && rawPath.trim().length > 0 ? rawPath.trim() : ".");
|
|
1244
1241
|
const gitDir = path3.join(repoPath, ".git");
|
|
@@ -1303,18 +1300,18 @@ async function runOpentool(rawArgs) {
|
|
|
1303
1300
|
}
|
|
1304
1301
|
}
|
|
1305
1302
|
async function runAppsTools() {
|
|
1306
|
-
const
|
|
1307
|
-
const uiBase = resolveBaseUrl(
|
|
1308
|
-
const apiKey = await ensureApiKey(
|
|
1303
|
+
const config = await loadConfig();
|
|
1304
|
+
const uiBase = resolveBaseUrl(config);
|
|
1305
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1309
1306
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1310
1307
|
const tools = await fetchToolsWithCache({ apiBase, apiKey });
|
|
1311
1308
|
console.log(JSON.stringify(tools, null, 2));
|
|
1312
1309
|
}
|
|
1313
1310
|
async function runAppsList(options) {
|
|
1314
|
-
const
|
|
1315
|
-
const uiBase = resolveBaseUrl(
|
|
1311
|
+
const config = await loadConfig();
|
|
1312
|
+
const uiBase = resolveBaseUrl(config);
|
|
1316
1313
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1317
|
-
const apiKey = await ensureApiKey(
|
|
1314
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1318
1315
|
const handle = typeof options.handle === "string" ? String(options.handle) : undefined;
|
|
1319
1316
|
const normalizedHandle = handle ? normalizeRepoName(handle) : null;
|
|
1320
1317
|
const forceRefresh = options.refresh !== undefined ? parseBooleanOption(options.refresh) : undefined;
|
|
@@ -1340,18 +1337,18 @@ async function runAppsList(options) {
|
|
|
1340
1337
|
}
|
|
1341
1338
|
}
|
|
1342
1339
|
async function runAppsPerformance(options) {
|
|
1343
|
-
const
|
|
1344
|
-
const uiBase = resolveBaseUrl(
|
|
1345
|
-
const apiKey = await ensureApiKey(
|
|
1340
|
+
const config = await loadConfig();
|
|
1341
|
+
const uiBase = resolveBaseUrl(config);
|
|
1342
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1346
1343
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1347
1344
|
const appId = typeof options.appId === "string" ? String(options.appId) : undefined;
|
|
1348
1345
|
const performance = await getUserPerformance(apiBase, apiKey, { appId });
|
|
1349
1346
|
console.log(JSON.stringify(performance, null, 2));
|
|
1350
1347
|
}
|
|
1351
1348
|
async function runAppsAgentCreate(options, contentParts) {
|
|
1352
|
-
const
|
|
1353
|
-
const uiBase = resolveBaseUrl(
|
|
1354
|
-
const apiKey = await ensureApiKey(
|
|
1349
|
+
const config = await loadConfig();
|
|
1350
|
+
const uiBase = resolveBaseUrl(config);
|
|
1351
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1355
1352
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1356
1353
|
const prompt = (typeof options.prompt === "string" ? options.prompt : null) || contentParts.join(" ");
|
|
1357
1354
|
if (!prompt.trim()) {
|
|
@@ -1435,9 +1432,9 @@ async function runAppsAgentCreate(options, contentParts) {
|
|
|
1435
1432
|
}
|
|
1436
1433
|
}
|
|
1437
1434
|
async function runAppsToolsExecute(options, appId, deploymentId, toolName) {
|
|
1438
|
-
const
|
|
1439
|
-
const uiBase = resolveBaseUrl(
|
|
1440
|
-
const apiKey = await ensureApiKey(
|
|
1435
|
+
const config = await loadConfig();
|
|
1436
|
+
const uiBase = resolveBaseUrl(config);
|
|
1437
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1441
1438
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1442
1439
|
const methodRaw = typeof options.method === "string" ? String(options.method).toUpperCase() : undefined;
|
|
1443
1440
|
const method = methodRaw && ["GET", "POST", "PUT", "DELETE"].includes(methodRaw) ? methodRaw : undefined;
|
|
@@ -1479,28 +1476,28 @@ async function runAppsEnvSet(options, target) {
|
|
|
1479
1476
|
}
|
|
1480
1477
|
envVars[key] = value;
|
|
1481
1478
|
}
|
|
1482
|
-
const
|
|
1483
|
-
const uiBase = resolveBaseUrl(
|
|
1479
|
+
const config = await loadConfig();
|
|
1480
|
+
const uiBase = resolveBaseUrl(config);
|
|
1484
1481
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1485
|
-
const apiKey = await ensureApiKey(
|
|
1482
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1486
1483
|
const { app } = await resolveAppTarget(apiBase, apiKey, target);
|
|
1487
1484
|
const result = await updateAppEnvironment(apiBase, apiKey, app.id, { envVars });
|
|
1488
1485
|
console.log(JSON.stringify(result, null, 2));
|
|
1489
1486
|
}
|
|
1490
1487
|
async function runAppsEnvGet(_options, target) {
|
|
1491
|
-
const
|
|
1492
|
-
const uiBase = resolveBaseUrl(
|
|
1488
|
+
const config = await loadConfig();
|
|
1489
|
+
const uiBase = resolveBaseUrl(config);
|
|
1493
1490
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1494
|
-
const apiKey = await ensureApiKey(
|
|
1491
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1495
1492
|
const { app } = await resolveAppTarget(apiBase, apiKey, target);
|
|
1496
1493
|
const result = await getAppEnvironment(apiBase, apiKey, app.id);
|
|
1497
1494
|
console.log(JSON.stringify(result, null, 2));
|
|
1498
1495
|
}
|
|
1499
1496
|
async function runAppsDeploy(options, target) {
|
|
1500
|
-
const
|
|
1501
|
-
const uiBase = resolveBaseUrl(
|
|
1497
|
+
const config = await loadConfig();
|
|
1498
|
+
const uiBase = resolveBaseUrl(config);
|
|
1502
1499
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1503
|
-
const apiKey = await ensureApiKey(
|
|
1500
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1504
1501
|
const { app, handle, repo } = await resolveAppTarget(apiBase, apiKey, target);
|
|
1505
1502
|
const envRaw = typeof options.env === "string" ? options.env : typeof options.environment === "string" ? options.environment : undefined;
|
|
1506
1503
|
const environment = resolveTemplateEnvironment(envRaw);
|
|
@@ -1519,9 +1516,9 @@ async function runAppsDeploy(options, target) {
|
|
|
1519
1516
|
});
|
|
1520
1517
|
}
|
|
1521
1518
|
async function runAppsPositionsTx(options) {
|
|
1522
|
-
const
|
|
1523
|
-
const uiBase = resolveBaseUrl(
|
|
1524
|
-
const apiKey = await ensureApiKey(
|
|
1519
|
+
const config = await loadConfig();
|
|
1520
|
+
const uiBase = resolveBaseUrl(config);
|
|
1521
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1525
1522
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1526
1523
|
const methodRaw = typeof options.method === "string" ? String(options.method).toUpperCase() : "POST";
|
|
1527
1524
|
const method = methodRaw === "GET" ? "GET" : "POST";
|
|
@@ -1549,7 +1546,7 @@ async function runAppsPositionsTx(options) {
|
|
|
1549
1546
|
});
|
|
1550
1547
|
console.log(JSON.stringify(result, null, 2));
|
|
1551
1548
|
}
|
|
1552
|
-
|
|
1549
|
+
function resolveStoreEventsParams(options) {
|
|
1553
1550
|
let params = {};
|
|
1554
1551
|
if (typeof options.params === "string") {
|
|
1555
1552
|
const parsed = parseJsonOption(String(options.params), "params");
|
|
@@ -1585,11 +1582,11 @@ var resolveStoreEventsParams = function(options) {
|
|
|
1585
1582
|
addParam("history", parseBooleanOption(options.history) ? "true" : "false");
|
|
1586
1583
|
}
|
|
1587
1584
|
return Object.keys(params).length ? params : undefined;
|
|
1588
|
-
}
|
|
1585
|
+
}
|
|
1589
1586
|
async function runAppsStoreEvents(options) {
|
|
1590
|
-
const
|
|
1591
|
-
const uiBase = resolveBaseUrl(
|
|
1592
|
-
const apiKey = await ensureApiKey(
|
|
1587
|
+
const config = await loadConfig();
|
|
1588
|
+
const uiBase = resolveBaseUrl(config);
|
|
1589
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1593
1590
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1594
1591
|
const query = resolveStoreEventsParams(options);
|
|
1595
1592
|
const result = await submitPositionsTx(apiBase, apiKey, {
|
|
@@ -1599,9 +1596,9 @@ async function runAppsStoreEvents(options) {
|
|
|
1599
1596
|
console.log(JSON.stringify(result, null, 2));
|
|
1600
1597
|
}
|
|
1601
1598
|
async function runAppsTradeFacts(options) {
|
|
1602
|
-
const
|
|
1603
|
-
const uiBase = resolveBaseUrl(
|
|
1604
|
-
const apiKey = await ensureApiKey(
|
|
1599
|
+
const config = await loadConfig();
|
|
1600
|
+
const uiBase = resolveBaseUrl(config);
|
|
1601
|
+
const apiKey = await ensureApiKey(config, uiBase);
|
|
1605
1602
|
const apiBase = resolvePublicApiBaseUrl();
|
|
1606
1603
|
const appId = typeof options.appId === "string" ? options.appId : undefined;
|
|
1607
1604
|
const performance = await getUserPerformance(apiBase, apiKey, { appId });
|
|
@@ -1759,7 +1756,6 @@ async function main() {
|
|
|
1759
1756
|
printHelp();
|
|
1760
1757
|
process.exit(1);
|
|
1761
1758
|
}
|
|
1762
|
-
var UI_API_KEY_URL = "https://openpond.ai/settings/api-keys";
|
|
1763
1759
|
main().catch((error) => {
|
|
1764
1760
|
const message = error instanceof Error ? error.message : String(error);
|
|
1765
1761
|
console.error(message);
|
package/dist/index.js
CHANGED
|
@@ -317,10 +317,10 @@ async function getDeploymentDetail(apiBase, token, deploymentId) {
|
|
|
317
317
|
const payload = await response.json().catch(() => ({}));
|
|
318
318
|
return payload.deployment ?? null;
|
|
319
319
|
}
|
|
320
|
-
|
|
320
|
+
function normalizeToolPathSegment(toolName) {
|
|
321
321
|
const trimmed = toolName.trim().replace(/^\/+/, "");
|
|
322
322
|
return encodeURIComponent(trimmed || "tool");
|
|
323
|
-
}
|
|
323
|
+
}
|
|
324
324
|
function resolveWorkerBaseUrl(baseUrl) {
|
|
325
325
|
const trimmed = baseUrl.replace(/\/$/, "");
|
|
326
326
|
const workerEnv = process.env.OPENPOND_TOOL_URL;
|
|
@@ -347,8 +347,7 @@ function resolveWorkerBaseUrl(baseUrl) {
|
|
|
347
347
|
if (isLocal && port === "3000") {
|
|
348
348
|
return trimmed;
|
|
349
349
|
}
|
|
350
|
-
} catch {
|
|
351
|
-
}
|
|
350
|
+
} catch {}
|
|
352
351
|
return trimmed;
|
|
353
352
|
}
|
|
354
353
|
async function executeHostedTool(baseUrl, token, payload) {
|
|
@@ -380,13 +379,17 @@ async function executeHostedTool(baseUrl, token, payload) {
|
|
|
380
379
|
}
|
|
381
380
|
|
|
382
381
|
// src/cache.ts
|
|
383
|
-
import {promises as fs} from "node:fs";
|
|
382
|
+
import { promises as fs } from "node:fs";
|
|
384
383
|
import os from "node:os";
|
|
385
384
|
import path from "node:path";
|
|
386
|
-
var
|
|
385
|
+
var CACHE_DIR = ".openpond";
|
|
386
|
+
var CACHE_FILENAME = "cache.json";
|
|
387
|
+
var DEFAULT_STORE = { version: 1, byKey: {} };
|
|
388
|
+
var DEFAULT_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
389
|
+
function getCachePath() {
|
|
387
390
|
return path.join(os.homedir(), CACHE_DIR, CACHE_FILENAME);
|
|
388
|
-
}
|
|
389
|
-
|
|
391
|
+
}
|
|
392
|
+
function buildCacheKey(apiBase, apiKey) {
|
|
390
393
|
const trimmed = apiKey.trim();
|
|
391
394
|
const hint = trimmed.length > 12 ? `${trimmed.slice(0, 8)}_${trimmed.slice(-4)}` : trimmed;
|
|
392
395
|
try {
|
|
@@ -395,14 +398,14 @@ var buildCacheKey = function(apiBase, apiKey) {
|
|
|
395
398
|
} catch {
|
|
396
399
|
return `${apiBase}:${hint}`;
|
|
397
400
|
}
|
|
398
|
-
}
|
|
399
|
-
|
|
401
|
+
}
|
|
402
|
+
function isFresh(updatedAt, ttlMs) {
|
|
400
403
|
const timestamp = Date.parse(updatedAt);
|
|
401
404
|
if (Number.isNaN(timestamp)) {
|
|
402
405
|
return false;
|
|
403
406
|
}
|
|
404
407
|
return Date.now() - timestamp < ttlMs;
|
|
405
|
-
}
|
|
408
|
+
}
|
|
406
409
|
async function loadCache() {
|
|
407
410
|
try {
|
|
408
411
|
const raw = await fs.readFile(getCachePath(), "utf-8");
|
|
@@ -462,10 +465,6 @@ async function setCachedTools(params) {
|
|
|
462
465
|
store.byKey[cacheKey] = bucket;
|
|
463
466
|
await saveCache(store);
|
|
464
467
|
}
|
|
465
|
-
var CACHE_DIR = ".openpond";
|
|
466
|
-
var CACHE_FILENAME = "cache.json";
|
|
467
|
-
var DEFAULT_STORE = { version: 1, byKey: {} };
|
|
468
|
-
var DEFAULT_CACHE_TTL_MS = 60 * 60 * 1000;
|
|
469
468
|
|
|
470
469
|
// src/stream.ts
|
|
471
470
|
function normalizeDataFrames(raw) {
|
|
@@ -504,7 +503,7 @@ function normalizeDataFrames(raw) {
|
|
|
504
503
|
}
|
|
505
504
|
return { conversationId, items };
|
|
506
505
|
}
|
|
507
|
-
|
|
506
|
+
function extractUsage(raw) {
|
|
508
507
|
const frames = Array.isArray(raw) ? raw : raw && typeof raw === "object" && Array.isArray(raw.data) ? raw.data : [raw];
|
|
509
508
|
for (const frame of frames) {
|
|
510
509
|
if (!frame || typeof frame !== "object")
|
|
@@ -521,7 +520,7 @@ var extractUsage = function(raw) {
|
|
|
521
520
|
return { promptTokens, completionTokens, totalTokens };
|
|
522
521
|
}
|
|
523
522
|
return null;
|
|
524
|
-
}
|
|
523
|
+
}
|
|
525
524
|
async function consumeStream(response, callbacks) {
|
|
526
525
|
if (!response.body) {
|
|
527
526
|
throw new Error("Missing response body");
|
|
@@ -536,8 +535,7 @@ async function consumeStream(response, callbacks) {
|
|
|
536
535
|
}
|
|
537
536
|
try {
|
|
538
537
|
await reader.cancel();
|
|
539
|
-
} catch {
|
|
540
|
-
}
|
|
538
|
+
} catch {}
|
|
541
539
|
callbacks.onStop?.();
|
|
542
540
|
return true;
|
|
543
541
|
};
|
|
@@ -547,7 +545,8 @@ async function consumeStream(response, callbacks) {
|
|
|
547
545
|
break;
|
|
548
546
|
const chunk = decoder.decode(value, { stream: true });
|
|
549
547
|
const textChunk = remainder + chunk;
|
|
550
|
-
const lines = textChunk.split(
|
|
548
|
+
const lines = textChunk.split(`
|
|
549
|
+
`);
|
|
551
550
|
remainder = lines.pop() || "";
|
|
552
551
|
for (const line of lines) {
|
|
553
552
|
if (!line)
|
|
@@ -584,8 +583,7 @@ async function consumeStream(response, callbacks) {
|
|
|
584
583
|
if (typeof message === "string") {
|
|
585
584
|
throw new Error(message);
|
|
586
585
|
}
|
|
587
|
-
} catch {
|
|
588
|
-
}
|
|
586
|
+
} catch {}
|
|
589
587
|
continue;
|
|
590
588
|
}
|
|
591
589
|
if (line.startsWith("2:")) {
|
|
@@ -608,8 +606,7 @@ async function consumeStream(response, callbacks) {
|
|
|
608
606
|
if (await stopIfNeeded()) {
|
|
609
607
|
return;
|
|
610
608
|
}
|
|
611
|
-
} catch {
|
|
612
|
-
}
|
|
609
|
+
} catch {}
|
|
613
610
|
}
|
|
614
611
|
if (await stopIfNeeded()) {
|
|
615
612
|
return;
|
|
@@ -803,15 +800,17 @@ function computeAtr(bars, period = 14) {
|
|
|
803
800
|
return sum / period;
|
|
804
801
|
}
|
|
805
802
|
// src/config.ts
|
|
806
|
-
import {promises as fs2} from "node:fs";
|
|
803
|
+
import { promises as fs2 } from "node:fs";
|
|
807
804
|
import os2 from "node:os";
|
|
808
805
|
import path2 from "node:path";
|
|
806
|
+
var GLOBAL_DIRNAME = ".openpond";
|
|
807
|
+
var GLOBAL_CONFIG_FILENAME = "config.json";
|
|
809
808
|
function getConfigPath() {
|
|
810
809
|
return getGlobalConfigPath();
|
|
811
810
|
}
|
|
812
|
-
|
|
811
|
+
function getGlobalConfigPath() {
|
|
813
812
|
return path2.join(os2.homedir(), GLOBAL_DIRNAME, GLOBAL_CONFIG_FILENAME);
|
|
814
|
-
}
|
|
813
|
+
}
|
|
815
814
|
async function loadConfigFile(filePath) {
|
|
816
815
|
try {
|
|
817
816
|
const raw = await fs2.readFile(filePath, "utf-8");
|
|
@@ -849,29 +848,29 @@ async function saveGlobalConfig(next) {
|
|
|
849
848
|
const payload = JSON.stringify(merged, null, 2);
|
|
850
849
|
await fs2.writeFile(filePath, payload, "utf-8");
|
|
851
850
|
}
|
|
852
|
-
var GLOBAL_DIRNAME = ".openpond";
|
|
853
|
-
var GLOBAL_CONFIG_FILENAME = "config.json";
|
|
854
851
|
|
|
855
852
|
// src/index.ts
|
|
856
|
-
var
|
|
853
|
+
var DEFAULT_BASE_URL = "https://openpond.ai";
|
|
854
|
+
var DEFAULT_API_URL = "https://api.openpond.ai";
|
|
855
|
+
function resolveUrl(value) {
|
|
857
856
|
return value.replace(/\/$/, "");
|
|
858
|
-
}
|
|
859
|
-
|
|
857
|
+
}
|
|
858
|
+
function resolveBaseUrl(options) {
|
|
860
859
|
const envBase = process.env.OPENPOND_BASE_URL;
|
|
861
860
|
const base = options.baseUrl || envBase || DEFAULT_BASE_URL;
|
|
862
861
|
return resolveUrl(base.trim());
|
|
863
|
-
}
|
|
864
|
-
|
|
862
|
+
}
|
|
863
|
+
function resolveApiUrl(options) {
|
|
865
864
|
const envBase = process.env.OPENPOND_API_URL;
|
|
866
865
|
const base = options.apiUrl || envBase || DEFAULT_API_URL;
|
|
867
866
|
return resolveUrl(base.trim());
|
|
868
|
-
}
|
|
869
|
-
|
|
867
|
+
}
|
|
868
|
+
function resolveToolUrl(options, baseUrl) {
|
|
870
869
|
const envBase = process.env.OPENPOND_TOOL_URL;
|
|
871
870
|
const base = options.toolUrl || envBase || baseUrl;
|
|
872
871
|
return resolveUrl(base.trim());
|
|
873
|
-
}
|
|
874
|
-
|
|
872
|
+
}
|
|
873
|
+
function resolveApiKey(options) {
|
|
875
874
|
const explicit = options.apiKey?.trim();
|
|
876
875
|
if (explicit)
|
|
877
876
|
return explicit;
|
|
@@ -879,18 +878,18 @@ var resolveApiKey = function(options) {
|
|
|
879
878
|
if (envKey)
|
|
880
879
|
return envKey;
|
|
881
880
|
throw new Error("OPENPOND_API_KEY is required");
|
|
882
|
-
}
|
|
883
|
-
|
|
881
|
+
}
|
|
882
|
+
function parseHandleRepo(value) {
|
|
884
883
|
const parts = value.split("/").filter(Boolean);
|
|
885
884
|
if (parts.length !== 2) {
|
|
886
885
|
throw new Error("expected <handle>/<repo>");
|
|
887
886
|
}
|
|
888
887
|
return { handle: parts[0], repo: parts[1] };
|
|
889
|
-
}
|
|
890
|
-
|
|
888
|
+
}
|
|
889
|
+
function normalizeRepoName(value) {
|
|
891
890
|
return (value || "").trim().toLowerCase();
|
|
892
|
-
}
|
|
893
|
-
|
|
891
|
+
}
|
|
892
|
+
function normalizeToolSummary(tool) {
|
|
894
893
|
if (!tool || typeof tool !== "object") {
|
|
895
894
|
return { name: "unknown", raw: tool };
|
|
896
895
|
}
|
|
@@ -899,8 +898,8 @@ var normalizeToolSummary = function(tool) {
|
|
|
899
898
|
const name = typeof record.name === "string" ? record.name : typeof profile?.name === "string" ? profile.name : "unknown";
|
|
900
899
|
const description = typeof record.description === "string" ? record.description : typeof profile?.description === "string" ? profile.description : undefined;
|
|
901
900
|
return { name, description, raw: tool };
|
|
902
|
-
}
|
|
903
|
-
|
|
901
|
+
}
|
|
902
|
+
function extractDeploymentTools(detail) {
|
|
904
903
|
if (!detail)
|
|
905
904
|
return [];
|
|
906
905
|
if (Array.isArray(detail.toolsJson)) {
|
|
@@ -913,7 +912,7 @@ var extractDeploymentTools = function(detail) {
|
|
|
913
912
|
}
|
|
914
913
|
}
|
|
915
914
|
return [];
|
|
916
|
-
}
|
|
915
|
+
}
|
|
917
916
|
async function resolveAppTarget(params) {
|
|
918
917
|
const { handle, repo } = parseHandleRepo(params.target);
|
|
919
918
|
const apps = await fetchAppsWithCache({
|
|
@@ -985,7 +984,7 @@ async function fetchToolsWithCache(params) {
|
|
|
985
984
|
}
|
|
986
985
|
return tools;
|
|
987
986
|
}
|
|
988
|
-
|
|
987
|
+
function normalizeMethod(method) {
|
|
989
988
|
if (!method)
|
|
990
989
|
return "POST";
|
|
991
990
|
const upper = method.toUpperCase();
|
|
@@ -998,7 +997,7 @@ var normalizeMethod = function(method) {
|
|
|
998
997
|
default:
|
|
999
998
|
throw new Error("method must be GET, POST, PUT, or DELETE");
|
|
1000
999
|
}
|
|
1001
|
-
}
|
|
1000
|
+
}
|
|
1002
1001
|
async function consumeAgentCreateStream(response, callbacks) {
|
|
1003
1002
|
let conversationId;
|
|
1004
1003
|
let appId;
|
|
@@ -1226,8 +1225,7 @@ function createClient(options) {
|
|
|
1226
1225
|
if (useCache && refreshCacheFlag !== false) {
|
|
1227
1226
|
try {
|
|
1228
1227
|
await refreshCache();
|
|
1229
|
-
} catch {
|
|
1230
|
-
}
|
|
1228
|
+
} catch {}
|
|
1231
1229
|
}
|
|
1232
1230
|
return result;
|
|
1233
1231
|
},
|
|
@@ -1277,8 +1275,7 @@ function createClient(options) {
|
|
|
1277
1275
|
if (useCache && refreshCacheFlag !== false) {
|
|
1278
1276
|
try {
|
|
1279
1277
|
await refreshCache();
|
|
1280
|
-
} catch {
|
|
1281
|
-
}
|
|
1278
|
+
} catch {}
|
|
1282
1279
|
}
|
|
1283
1280
|
return result;
|
|
1284
1281
|
}
|
|
@@ -1288,8 +1285,6 @@ function createClient(options) {
|
|
|
1288
1285
|
}
|
|
1289
1286
|
};
|
|
1290
1287
|
}
|
|
1291
|
-
var DEFAULT_BASE_URL = "https://openpond.ai";
|
|
1292
|
-
var DEFAULT_API_URL = "https://api.openpond.ai";
|
|
1293
1288
|
export {
|
|
1294
1289
|
updateAppEnvironment,
|
|
1295
1290
|
submitPositionsTx,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openpond-code",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "OpenPond CLI (API key only)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -36,6 +36,14 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/openpond/openpond-code"
|
|
42
|
+
},
|
|
43
|
+
"homepage": "https://github.com/openpond/openpond-code",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/openpond/openpond-code/issues"
|
|
46
|
+
},
|
|
39
47
|
"engines": {
|
|
40
48
|
"node": ">=20.0.0"
|
|
41
49
|
},
|