@ponderbot/cli 0.1.0-alpha.21 → 0.1.0-alpha.23
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/main.js +100 -62
- package/dist/main.js.map +1 -1
- package/package.json +2 -2
package/dist/main.js
CHANGED
|
@@ -29,7 +29,7 @@ const resolveProject = async () => {
|
|
|
29
29
|
projectDefinition: await loadProjectDefinition(resolve(project, "config"))
|
|
30
30
|
};
|
|
31
31
|
};
|
|
32
|
-
const resolveConfig = async (envName) => requireExecutionSpace(await resolveEnvironmentConfig(envName));
|
|
32
|
+
const resolveConfig = async (envName, spaceId) => requireExecutionSpace(await resolveEnvironmentConfig(envName), spaceId);
|
|
33
33
|
const resolveProjectReleaseConfig = async (envName) => resolveEnvironmentConfig(envName, { resolveApplicationOrigin: true });
|
|
34
34
|
const resolveDevConfig = async (envName) => requireExecutionSpace(await resolveEnvironmentConfig(envName ?? "development", {
|
|
35
35
|
requireDevAllowed: true,
|
|
@@ -70,11 +70,12 @@ const resolveEnvironmentConfig = async (envName, options = {}) => {
|
|
|
70
70
|
applicationOrigin
|
|
71
71
|
};
|
|
72
72
|
};
|
|
73
|
-
const requireExecutionSpace = (config) => {
|
|
74
|
-
|
|
73
|
+
const requireExecutionSpace = (config, spaceId) => {
|
|
74
|
+
const resolvedSpaceId = spaceId !== void 0 && spaceId.length > 0 ? spaceId : config.spaceId;
|
|
75
|
+
if (resolvedSpaceId === void 0 || resolvedSpaceId.length === 0) return exitConfig(`set the execution Space with --space, PONDERBOT_SPACE_ID, or spaceId for environment "${config.environment}" in ponderbot/config.ts`);
|
|
75
76
|
return {
|
|
76
77
|
...config,
|
|
77
|
-
spaceId:
|
|
78
|
+
spaceId: resolvedSpaceId
|
|
78
79
|
};
|
|
79
80
|
};
|
|
80
81
|
const resolveProjectApplicationOrigin = (projectDefinition) => {
|
|
@@ -348,6 +349,7 @@ const formatError = (error) => {
|
|
|
348
349
|
return String(error);
|
|
349
350
|
};
|
|
350
351
|
const lines = (data) => {
|
|
352
|
+
if (isRecord$1(data) && isRecord$1(data.release) && isRecord$1(data.resources)) return releaseCatalogLines(data.release, data.resources);
|
|
351
353
|
if (isStartedDevStack(data)) return [
|
|
352
354
|
"Ponderbot dev stack ready.",
|
|
353
355
|
` PONDERBOT_URL=${data.dev_environment.url}`,
|
|
@@ -361,14 +363,14 @@ const lines = (data) => {
|
|
|
361
363
|
...recordLines(data.registered)
|
|
362
364
|
];
|
|
363
365
|
if (isRecord$1(data) && data.ok === true && isRecord$1(data.counts)) return ["manifest valid", ...recordLines(data.counts)];
|
|
364
|
-
if (isRecord$1(data) && Array.isArray(data.spaces)) return ["id name status", ...data.spaces.map((space) =>
|
|
366
|
+
if (isRecord$1(data) && Array.isArray(data.spaces)) return ["id name status", ...data.spaces.map((space) => columns(space, spaceKeys))];
|
|
365
367
|
if (isRecord$1(data) && isRecord$1(data.space)) {
|
|
366
368
|
if (isRecord$1(data.budget) && isRecord$1(data.usage)) return spaceShowLines(data.space, data.budget, data.usage);
|
|
367
|
-
return [
|
|
369
|
+
return [columns(data.space, spaceKeys)];
|
|
368
370
|
}
|
|
369
371
|
if (isRecord$1(data) && isRecord$1(data.budget)) return recordLines(data.budget);
|
|
370
|
-
if (isRecord$1(data) && Array.isArray(data.models)) return ["ref provider model", ...data.models.map((model) =>
|
|
371
|
-
if (isRecord$1(data) && isRecord$1(data.model)) return [
|
|
372
|
+
if (isRecord$1(data) && Array.isArray(data.models)) return ["ref provider model", ...data.models.map((model) => columns(model, modelKeys))];
|
|
373
|
+
if (isRecord$1(data) && isRecord$1(data.model)) return [columns(data.model, modelKeys)];
|
|
372
374
|
if (isRecord$1(data) && isRecord$1(data.agent_model_refs)) return ["agent model", ...Object.entries(data.agent_model_refs).map(([agentRef, modelRef]) => `${agentRef} ${String(modelRef)}`)];
|
|
373
375
|
if (isRecord$1(data) && isRecord$1(data.run)) return lines(data.run);
|
|
374
376
|
if (isRecord$1(data) && data.type === "provider_auth" && typeof data.provider === "string" && typeof data.method === "string" && typeof data.space_id === "string") {
|
|
@@ -421,7 +423,7 @@ const recordLines = (data) => {
|
|
|
421
423
|
};
|
|
422
424
|
function spaceShowLines(space, budget, usage) {
|
|
423
425
|
return [
|
|
424
|
-
|
|
426
|
+
columns(space, spaceKeys),
|
|
425
427
|
"budget",
|
|
426
428
|
...recordLines(budget),
|
|
427
429
|
...spaceUsageLines(usage)
|
|
@@ -443,22 +445,53 @@ function spaceUsageLines(usage) {
|
|
|
443
445
|
const limitValue = (value) => {
|
|
444
446
|
return value === null ? "unlimited" : String(value);
|
|
445
447
|
};
|
|
446
|
-
const
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
448
|
+
const spaceKeys = [
|
|
449
|
+
"id",
|
|
450
|
+
"name",
|
|
451
|
+
"status"
|
|
452
|
+
];
|
|
453
|
+
const modelKeys = [
|
|
454
|
+
"ref",
|
|
455
|
+
"provider",
|
|
456
|
+
"model"
|
|
457
|
+
];
|
|
458
|
+
const releaseKeys = [
|
|
459
|
+
"id",
|
|
460
|
+
"manifest_name",
|
|
461
|
+
"environment",
|
|
462
|
+
"version",
|
|
463
|
+
"status"
|
|
464
|
+
];
|
|
465
|
+
const catalogKeys = {
|
|
466
|
+
agents: ["ref", "name"],
|
|
467
|
+
mcp_servers: [
|
|
468
|
+
"ref",
|
|
469
|
+
"url",
|
|
470
|
+
"tool_count"
|
|
471
|
+
],
|
|
472
|
+
actions: ["ref", "kind"],
|
|
473
|
+
skills: ["ref", "name"],
|
|
474
|
+
workflows: ["ref", "name"],
|
|
475
|
+
schedules: [
|
|
476
|
+
"ref",
|
|
477
|
+
"target_type",
|
|
478
|
+
"target_ref",
|
|
479
|
+
"mode",
|
|
480
|
+
"enabled",
|
|
481
|
+
"next_run_at"
|
|
482
|
+
],
|
|
483
|
+
webhooks: [
|
|
484
|
+
"ref",
|
|
485
|
+
"target_type",
|
|
486
|
+
"target_ref"
|
|
487
|
+
],
|
|
488
|
+
agent_groups: ["ref", "strategy"]
|
|
489
|
+
};
|
|
490
|
+
const columns = (record, keys) => {
|
|
491
|
+
if (!isRecord$1(record)) return String(record);
|
|
492
|
+
return keys.map((key) => record[key]).filter((value) => value !== void 0 && value !== null).map((value) => String(value)).join(" ");
|
|
493
|
+
};
|
|
494
|
+
const releaseCatalogLines = (release, resources) => [`release ${columns(release, releaseKeys)}`, ...Object.entries(resources).flatMap(([kind, entries]) => Array.isArray(entries) && entries.length > 0 ? [`${kind} (${entries.length})`, ...entries.map((entry) => ` ${columns(entry, catalogKeys[kind] ?? ["ref", "name"])}`)] : [])];
|
|
462
495
|
function recordSummary(record) {
|
|
463
496
|
const fields = [
|
|
464
497
|
field(record, "type") ?? field(record, "run_type") ?? field(record, "target_type"),
|
|
@@ -545,23 +578,21 @@ const createDevActionRunner = (client, config, options = {}) => {
|
|
|
545
578
|
try {
|
|
546
579
|
let { run } = await client.runs.show("action", actionRunId, spaceId);
|
|
547
580
|
if (state.stopped || run.runner !== "dev" || run.status !== "running") return;
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
if (!(isPonderbotError(claimError) && claimError.status === 409)) throw claimError;
|
|
553
|
-
({run} = await client.runs.show("action", actionRunId, spaceId));
|
|
554
|
-
if (state.stopped || run.runner !== "dev" || run.status !== "running") return;
|
|
555
|
-
blockClaim(state, {
|
|
556
|
-
actionRunId,
|
|
557
|
-
spaceId
|
|
558
|
-
});
|
|
559
|
-
console.error(formatError(claimError));
|
|
560
|
-
return;
|
|
561
|
-
}
|
|
581
|
+
try {
|
|
582
|
+
await client.dev.actionRuns.claim(actionRunId, spaceId);
|
|
583
|
+
} catch (claimError) {
|
|
584
|
+
if (!(isPonderbotError(claimError) && claimError.status === 409)) throw claimError;
|
|
562
585
|
({run} = await client.runs.show("action", actionRunId, spaceId));
|
|
563
586
|
if (state.stopped || run.runner !== "dev" || run.status !== "running") return;
|
|
587
|
+
blockClaim(state, {
|
|
588
|
+
actionRunId,
|
|
589
|
+
spaceId
|
|
590
|
+
});
|
|
591
|
+
console.error(formatError(claimError));
|
|
592
|
+
return;
|
|
564
593
|
}
|
|
594
|
+
({run} = await client.runs.show("action", actionRunId, spaceId));
|
|
595
|
+
if (state.stopped || run.runner !== "dev" || run.status !== "running") return;
|
|
565
596
|
const context = devCallContext(run, spaceId);
|
|
566
597
|
const actionExecution = devActionExecution(run);
|
|
567
598
|
const activeCallback = {
|
|
@@ -1723,8 +1754,8 @@ const modelProvider = (provider) => {
|
|
|
1723
1754
|
//#endregion
|
|
1724
1755
|
//#region src/provider-auth.ts
|
|
1725
1756
|
const providerAuth = async (options) => {
|
|
1726
|
-
const config = await resolveConfig(options.env);
|
|
1727
|
-
const spaceId =
|
|
1757
|
+
const config = await resolveConfig(options.env, options.space);
|
|
1758
|
+
const spaceId = config.spaceId;
|
|
1728
1759
|
const client = clientFor(config);
|
|
1729
1760
|
const registry = await client.modelProviders.list(spaceId);
|
|
1730
1761
|
const provider = await resolveProvider(options.provider, registry.providers);
|
|
@@ -2399,36 +2430,38 @@ program.command("provider").description("configure model provider credentials").
|
|
|
2399
2430
|
});
|
|
2400
2431
|
const model = program.command("model").description("manage Space model policy");
|
|
2401
2432
|
model.command("add <modelRef>").requiredOption("--provider <name>", "anthropic | fake | mistral | openai").requiredOption("--model <name>", "provider model name").option("--capability <name...>", "declared model capabilities").option("--fallback <modelRef...>", "ordered fallback model refs").option("--space <spaceId>", "target space (defaults to the configured space)").option("--env <name>", "environment").description("add or update a model in the Space catalog").action(async (modelRef, options) => {
|
|
2402
|
-
const config = await resolveConfig(options.env);
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
print(await clientFor(config).models.upsert(modelRef, modelDefinitionInput(options), spaceId), program.opts());
|
|
2433
|
+
const config = await resolveConfig(options.env, options.space);
|
|
2434
|
+
await runSpacesCommand("spaces:write", config.spaceId, async () => {
|
|
2435
|
+
print(await clientFor(config).models.upsert(modelRef, modelDefinitionInput(options)), program.opts());
|
|
2406
2436
|
});
|
|
2407
2437
|
});
|
|
2408
2438
|
model.command("list").option("--space <spaceId>", "target space (defaults to the configured space)").option("--env <name>", "environment").description("list models in the Space catalog").action(async (options) => {
|
|
2409
|
-
const config = await resolveConfig(options.env);
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
print(await clientFor(config).models.list(spaceId), program.opts());
|
|
2439
|
+
const config = await resolveConfig(options.env, options.space);
|
|
2440
|
+
await runSpacesCommand("spaces:read", config.spaceId, async () => {
|
|
2441
|
+
print(await clientFor(config).models.list(), program.opts());
|
|
2413
2442
|
});
|
|
2414
2443
|
});
|
|
2415
2444
|
model.command("assign <agentRef> <modelRef>").option("--space <spaceId>", "target space (defaults to the configured space)").option("--env <name>", "environment").description("assign a Space catalog model to an exact Agent ref").action(async (agentRef, modelRef, options) => {
|
|
2416
|
-
const config = await resolveConfig(options.env);
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
print(await clientFor(config).models.assign(agentRef, modelRef, spaceId), program.opts());
|
|
2445
|
+
const config = await resolveConfig(options.env, options.space);
|
|
2446
|
+
await runSpacesCommand("spaces:write", config.spaceId, async () => {
|
|
2447
|
+
print(await clientFor(config).models.assign(agentRef, modelRef), program.opts());
|
|
2420
2448
|
});
|
|
2421
2449
|
});
|
|
2422
2450
|
model.command("assignments").option("--space <spaceId>", "target space (defaults to the configured space)").option("--env <name>", "environment").description("list exact Agent model assignments for a Space").action(async (options) => {
|
|
2423
|
-
const config = await resolveConfig(options.env);
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
print(await clientFor(config).models.assignments(spaceId), program.opts());
|
|
2451
|
+
const config = await resolveConfig(options.env, options.space);
|
|
2452
|
+
await runSpacesCommand("spaces:read", config.spaceId, async () => {
|
|
2453
|
+
print(await clientFor(config).models.assignments(), program.opts());
|
|
2427
2454
|
});
|
|
2428
2455
|
});
|
|
2429
|
-
program.command("releases").
|
|
2456
|
+
const releases = program.command("releases").description("inspect manifest releases");
|
|
2457
|
+
releases.command("list", { isDefault: true }).option("--env <name>", "environment").description("list releases").action(async (options) => {
|
|
2430
2458
|
print(await clientFor(await resolveConfig(options.env)).releases.list(), program.opts());
|
|
2431
2459
|
});
|
|
2460
|
+
releases.command("catalog [releaseId]").option("--space <spaceId>", "target space (defaults to the configured space)").option("--env <name>", "environment").description("show the deployed resources of one release (defaults to the active release)").action(async (releaseId, options) => {
|
|
2461
|
+
const client = clientFor(await resolveConfig(options.env, options.space));
|
|
2462
|
+
const resolvedReleaseId = releaseId ?? activeReleaseId(await client.releases.list());
|
|
2463
|
+
print(await client.releases.catalog(resolvedReleaseId), program.opts());
|
|
2464
|
+
});
|
|
2432
2465
|
program.command("rollback <releaseId>").option("--env <name>", "environment").description("roll back to a release").action(async (releaseId, options) => {
|
|
2433
2466
|
print(await clientFor(await resolveConfig(options.env)).releases.rollback(releaseId), program.opts());
|
|
2434
2467
|
});
|
|
@@ -2444,14 +2477,14 @@ program.command("cancel <type> <id>").option("--env <name>", "environment").desc
|
|
|
2444
2477
|
const runType = parseRunType(type);
|
|
2445
2478
|
print(await clientFor(await resolveConfig(options.env)).runs.cancel(runType, id), program.opts());
|
|
2446
2479
|
});
|
|
2447
|
-
program.command("action").command("run <ref>").option("--input <json>", "input payload", "{}").option("--env <name>", "environment").option("--release-id <id>", "pinned release id").option("--manifest-name <name>", "current release selector").description("start an Action Run").action(async (ref, options) => {
|
|
2448
|
-
print(await clientFor(await resolveConfig(options.env)).actions.run(ref, JSON.parse(options.input), {
|
|
2480
|
+
program.command("action").command("run <ref>").option("--input <json>", "input payload", "{}").option("--space <spaceId>", "target space (defaults to the configured space)").option("--env <name>", "environment").option("--release-id <id>", "pinned release id").option("--manifest-name <name>", "current release selector").description("start an Action Run").action(async (ref, options) => {
|
|
2481
|
+
print(await clientFor(await resolveConfig(options.env, options.space)).actions.run(ref, JSON.parse(options.input), {
|
|
2449
2482
|
releaseId: options.releaseId,
|
|
2450
2483
|
manifestName: options.manifestName
|
|
2451
2484
|
}), program.opts());
|
|
2452
2485
|
});
|
|
2453
|
-
program.command("workflow").command("trigger <ref>").option("--input <json>", "input payload", "{}").option("--env <name>", "environment").option("--release-id <id>", "pinned release id").option("--manifest-name <name>", "current release selector").description("start a Workflow Run").action(async (ref, options) => {
|
|
2454
|
-
print(await clientFor(await resolveConfig(options.env)).workflows.trigger(ref, JSON.parse(options.input), {
|
|
2486
|
+
program.command("workflow").command("trigger <ref>").option("--input <json>", "input payload", "{}").option("--space <spaceId>", "target space (defaults to the configured space)").option("--env <name>", "environment").option("--release-id <id>", "pinned release id").option("--manifest-name <name>", "current release selector").description("start a Workflow Run").action(async (ref, options) => {
|
|
2487
|
+
print(await clientFor(await resolveConfig(options.env, options.space)).workflows.trigger(ref, JSON.parse(options.input), {
|
|
2455
2488
|
releaseId: options.releaseId,
|
|
2456
2489
|
manifestName: options.manifestName
|
|
2457
2490
|
}), program.opts());
|
|
@@ -2527,6 +2560,11 @@ const spaceCreateError = (error, spaceId) => {
|
|
|
2527
2560
|
if (isPonderbotError(error) && error.status === 409) return /* @__PURE__ */ new Error(`space "${spaceId}" already exists`);
|
|
2528
2561
|
return error;
|
|
2529
2562
|
};
|
|
2563
|
+
const activeReleaseId = ({ releases }) => {
|
|
2564
|
+
const newest = releases.filter((release) => release.status === "active").sort((left, right) => (right.deployed_at ?? "").localeCompare(left.deployed_at ?? ""))[0];
|
|
2565
|
+
if (newest === void 0) return fail(/* @__PURE__ */ new Error("no active release in this space - deploy one, or name a release id"), 2);
|
|
2566
|
+
return newest.id;
|
|
2567
|
+
};
|
|
2530
2568
|
//#endregion
|
|
2531
2569
|
export {};
|
|
2532
2570
|
|