@treeseed/cli 0.8.7 → 0.8.8
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.
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { guidedResult } from "./utils.js";
|
|
2
|
+
import { createMarketClientForInvocation } from "./market-utils.js";
|
|
3
|
+
function required(value, message) {
|
|
4
|
+
if (typeof value === "string" && value.trim()) return value.trim();
|
|
5
|
+
throw new Error(message);
|
|
6
|
+
}
|
|
7
|
+
const handleCapacity = async (invocation, context) => {
|
|
8
|
+
const action = invocation.positionals[0] ?? "status";
|
|
9
|
+
const { profile, client } = createMarketClientForInvocation(invocation, context, { requireAuth: true });
|
|
10
|
+
const teamId = typeof invocation.args.team === "string" ? invocation.args.team : typeof profile.teamId === "string" ? profile.teamId : null;
|
|
11
|
+
if (action === "status") {
|
|
12
|
+
const team = required(teamId, "Usage: treeseed capacity status --team <team-id>");
|
|
13
|
+
const response = await client.teamCapacity(team);
|
|
14
|
+
const summary = response.payload.summary;
|
|
15
|
+
return guidedResult({
|
|
16
|
+
command: "capacity",
|
|
17
|
+
summary: "Team helper capacity status",
|
|
18
|
+
facts: [
|
|
19
|
+
{ label: "Market", value: profile.id },
|
|
20
|
+
{ label: "Team", value: team },
|
|
21
|
+
{ label: "Monthly remaining", value: summary?.monthlyRemainingCredits },
|
|
22
|
+
{ label: "Daily remaining", value: summary?.dailyRemainingCredits },
|
|
23
|
+
{ label: "Active providers", value: summary?.activeProviderCount }
|
|
24
|
+
],
|
|
25
|
+
report: { marketId: profile.id, teamId: team, capacity: response.payload }
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (action === "providers") {
|
|
29
|
+
const subcommand = invocation.positionals[1] ?? "list";
|
|
30
|
+
const team = required(teamId, "Usage: treeseed capacity providers list --team <team-id>");
|
|
31
|
+
if (subcommand === "list") {
|
|
32
|
+
const response = await client.teamCapacity(team);
|
|
33
|
+
const providers = response.payload.providers ?? [];
|
|
34
|
+
return guidedResult({
|
|
35
|
+
command: "capacity",
|
|
36
|
+
summary: `Found ${providers.length} helper capacity provider${providers.length === 1 ? "" : "s"}.`,
|
|
37
|
+
sections: [{
|
|
38
|
+
title: "Providers",
|
|
39
|
+
lines: providers.map((provider) => `${provider.id} ${provider.name} ${provider.status} workers=${provider.maxConcurrentWorkers ?? 0}`)
|
|
40
|
+
}],
|
|
41
|
+
report: { marketId: profile.id, teamId: team, providers }
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (subcommand === "connect") {
|
|
45
|
+
const response = await client.launchManagedCapacityProvider(team, { launchSource: "cli" });
|
|
46
|
+
return guidedResult({
|
|
47
|
+
command: "capacity",
|
|
48
|
+
summary: "TreeSeed-managed helper capacity is connected.",
|
|
49
|
+
facts: [
|
|
50
|
+
{ label: "Provider", value: response.payload.provider?.id },
|
|
51
|
+
{ label: "Security code prefix", value: response.payload.apiKey?.keyPrefix }
|
|
52
|
+
],
|
|
53
|
+
report: { marketId: profile.id, teamId: team, result: response.payload }
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
if (subcommand === "keys") {
|
|
57
|
+
const keyAction = invocation.positionals[2] ?? "reset";
|
|
58
|
+
const providerId = required(invocation.args.provider, "Usage: treeseed capacity providers keys reset --provider <provider-id>");
|
|
59
|
+
if (keyAction === "reset") {
|
|
60
|
+
const response = await client.resetCapacityProviderApiKey(providerId, { name: "Provider security code" });
|
|
61
|
+
return guidedResult({
|
|
62
|
+
command: "capacity",
|
|
63
|
+
summary: "Provider security code was reset.",
|
|
64
|
+
facts: [
|
|
65
|
+
{ label: "Provider", value: providerId },
|
|
66
|
+
{ label: "Prefix", value: response.payload.key?.keyPrefix },
|
|
67
|
+
{ label: "Security access code", value: response.payload.plaintextKey }
|
|
68
|
+
],
|
|
69
|
+
report: { marketId: profile.id, providerId, result: response.payload }
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (keyAction === "revoke") {
|
|
73
|
+
const keyId = required(invocation.args.key, "Usage: treeseed capacity providers keys revoke --provider <provider-id> --key <key-id>");
|
|
74
|
+
const response = await client.revokeCapacityProviderApiKey(providerId, keyId);
|
|
75
|
+
return guidedResult({
|
|
76
|
+
command: "capacity",
|
|
77
|
+
summary: "Provider security code was revoked.",
|
|
78
|
+
facts: [
|
|
79
|
+
{ label: "Provider", value: providerId },
|
|
80
|
+
{ label: "Key", value: keyId }
|
|
81
|
+
],
|
|
82
|
+
report: { marketId: profile.id, providerId, keyId, result: response.payload }
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return { exitCode: 1, stderr: [`Unknown capacity providers action: ${subcommand}`] };
|
|
87
|
+
}
|
|
88
|
+
if (action === "grants") {
|
|
89
|
+
const subcommand = invocation.positionals[1] ?? "list";
|
|
90
|
+
const team = required(teamId, "Usage: treeseed capacity grants list --team <team-id>");
|
|
91
|
+
if (subcommand === "list") {
|
|
92
|
+
const response = await client.capacityGrants(team);
|
|
93
|
+
return guidedResult({
|
|
94
|
+
command: "capacity",
|
|
95
|
+
summary: `Found ${response.payload.length} capacity grant${response.payload.length === 1 ? "" : "s"}.`,
|
|
96
|
+
sections: [{
|
|
97
|
+
title: "Grants",
|
|
98
|
+
lines: response.payload.map((grant) => `${grant.id} ${grant.grantScope} daily=${grant.dailyCreditLimit ?? "policy"} monthly=${grant.monthlyCreditLimit ?? "policy"}`)
|
|
99
|
+
}],
|
|
100
|
+
report: { marketId: profile.id, teamId: team, grants: response.payload }
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
if (subcommand === "create") {
|
|
104
|
+
const providerId = required(invocation.args.provider, "Usage: treeseed capacity grants create --team <team-id> --provider <provider-id>");
|
|
105
|
+
const response = await client.createCapacityGrant(team, {
|
|
106
|
+
capacityProviderId: providerId,
|
|
107
|
+
projectId: typeof invocation.args.project === "string" ? invocation.args.project : null,
|
|
108
|
+
environment: typeof invocation.args.environment === "string" ? invocation.args.environment : null,
|
|
109
|
+
dailyCreditLimit: Number(invocation.args.daily ?? 25),
|
|
110
|
+
monthlyCreditLimit: Number(invocation.args.monthly ?? 500),
|
|
111
|
+
overflowPolicy: typeof invocation.args.overflow === "string" ? invocation.args.overflow : "approval_required"
|
|
112
|
+
});
|
|
113
|
+
return guidedResult({
|
|
114
|
+
command: "capacity",
|
|
115
|
+
summary: "Capacity grant created.",
|
|
116
|
+
facts: [
|
|
117
|
+
{ label: "Grant", value: response.payload.id },
|
|
118
|
+
{ label: "Provider", value: providerId }
|
|
119
|
+
],
|
|
120
|
+
report: { marketId: profile.id, teamId: team, grant: response.payload }
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
return { exitCode: 1, stderr: [`Unknown capacity grants action: ${subcommand}`] };
|
|
124
|
+
}
|
|
125
|
+
if (action === "enqueue") {
|
|
126
|
+
const projectId = required(invocation.args.project, "Usage: treeseed capacity enqueue --project <project-id> --task-kind <kind>");
|
|
127
|
+
const response = await client.enqueueAgentTask(projectId, {
|
|
128
|
+
taskKind: typeof invocation.args.taskKind === "string" ? invocation.args.taskKind : typeof invocation.args.task === "string" ? invocation.args.task : "proposal.draft",
|
|
129
|
+
environment: typeof invocation.args.environment === "string" ? invocation.args.environment : "staging"
|
|
130
|
+
});
|
|
131
|
+
return guidedResult({
|
|
132
|
+
command: "capacity",
|
|
133
|
+
summary: "Budgeted agent task enqueued.",
|
|
134
|
+
facts: [
|
|
135
|
+
{ label: "Task", value: response.payload.task?.id },
|
|
136
|
+
{ label: "Reserved credits", value: response.payload.reservation?.reservedCredits }
|
|
137
|
+
],
|
|
138
|
+
report: { marketId: profile.id, projectId, result: response.payload }
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
return { exitCode: 1, stderr: [`Unknown capacity action: ${action}`] };
|
|
142
|
+
};
|
|
143
|
+
export {
|
|
144
|
+
handleCapacity
|
|
145
|
+
};
|
|
@@ -1460,6 +1460,47 @@ const CLI_ONLY_OPERATION_SPECS = [
|
|
|
1460
1460
|
executionMode: "handler",
|
|
1461
1461
|
handlerName: "projects"
|
|
1462
1462
|
},
|
|
1463
|
+
{
|
|
1464
|
+
id: "market.capacity",
|
|
1465
|
+
name: "capacity",
|
|
1466
|
+
aliases: [],
|
|
1467
|
+
group: "Utilities",
|
|
1468
|
+
summary: "Manage team helper capacity from the selected market.",
|
|
1469
|
+
description: "Inspect team helper credits, connect managed providers, rotate provider security codes, manage grants, and enqueue budgeted agent tasks.",
|
|
1470
|
+
provider: "default",
|
|
1471
|
+
related: ["teams", "projects", "agents"],
|
|
1472
|
+
usage: "treeseed capacity [status|providers|grants|enqueue]",
|
|
1473
|
+
arguments: [{ name: "action", description: "Capacity action.", required: false }],
|
|
1474
|
+
options: [
|
|
1475
|
+
{ name: "market", flags: "--market <id-or-url>", description: "Select a configured market id or direct market API URL.", kind: "string" },
|
|
1476
|
+
{ name: "team", flags: "--team <team-id>", description: "Team id for capacity status and grants.", kind: "string" },
|
|
1477
|
+
{ name: "provider", flags: "--provider <provider-id>", description: "Capacity provider id for grant or key actions.", kind: "string" },
|
|
1478
|
+
{ name: "project", flags: "--project <project-id>", description: "Project id for grant allocation or agent enqueue.", kind: "string" },
|
|
1479
|
+
{ name: "key", flags: "--key <key-id>", description: "Provider security code id to revoke.", kind: "string" },
|
|
1480
|
+
{ name: "taskKind", flags: "--task-kind <kind>", description: "Agent task signature for budgeted enqueue.", kind: "string" },
|
|
1481
|
+
{ name: "environment", flags: "--environment <environment>", description: "Project environment for grants or enqueue.", kind: "enum", values: ["local", "staging", "prod"] },
|
|
1482
|
+
{ name: "daily", flags: "--daily <credits>", description: "Daily credit limit for a created grant.", kind: "string" },
|
|
1483
|
+
{ name: "monthly", flags: "--monthly <credits>", description: "Monthly credit limit for a created grant.", kind: "string" },
|
|
1484
|
+
{ name: "json", flags: "--json", description: "Emit machine-readable JSON instead of human-readable text.", kind: "boolean" }
|
|
1485
|
+
],
|
|
1486
|
+
examples: [
|
|
1487
|
+
"treeseed capacity status --team team_123",
|
|
1488
|
+
"treeseed capacity providers connect --team team_123",
|
|
1489
|
+
"treeseed capacity providers keys reset --provider provider_123",
|
|
1490
|
+
"treeseed capacity grants create --team team_123 --provider provider_123 --daily 25",
|
|
1491
|
+
"treeseed capacity enqueue --project project_123 --task-kind proposal.draft"
|
|
1492
|
+
],
|
|
1493
|
+
help: {
|
|
1494
|
+
longSummary: ["Capacity talks to the market control plane so technical stewards can inspect helper credits, provider security codes, and budgeted agent task routing without opening the browser."],
|
|
1495
|
+
whenToUse: ["Use this after connecting to a market when provider health, budget allocation, or budgeted agent enqueue needs to be checked from a terminal."],
|
|
1496
|
+
beforeYouRun: ["Authenticate to the selected market and know the team, project, or provider id for the action you are taking."],
|
|
1497
|
+
automationNotes: ["Use `--json` when capturing provider keys, grant ids, task ids, or dashboard summaries in automation."]
|
|
1498
|
+
},
|
|
1499
|
+
helpVisible: true,
|
|
1500
|
+
helpFeatured: false,
|
|
1501
|
+
executionMode: "handler",
|
|
1502
|
+
handlerName: "capacity"
|
|
1503
|
+
},
|
|
1463
1504
|
{
|
|
1464
1505
|
id: "market.packs",
|
|
1465
1506
|
name: "packs",
|
package/dist/cli/registry.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export declare const COMMAND_HANDLERS: {
|
|
|
28
28
|
readonly market: import("./operations-types.js").TreeseedCommandHandler;
|
|
29
29
|
readonly teams: import("./operations-types.js").TreeseedCommandHandler;
|
|
30
30
|
readonly projects: import("./operations-types.js").TreeseedCommandHandler;
|
|
31
|
+
readonly capacity: import("./operations-types.js").TreeseedCommandHandler;
|
|
31
32
|
readonly packs: import("./operations-types.js").TreeseedCommandHandler;
|
|
32
33
|
readonly gh: import("./operations-types.js").TreeseedCommandHandler;
|
|
33
34
|
readonly railway: import("./operations-types.js").TreeseedCommandHandler;
|
package/dist/cli/registry.js
CHANGED
|
@@ -22,6 +22,7 @@ import { handleAuthWhoAmI } from "./handlers/auth-whoami.js";
|
|
|
22
22
|
import { handleMarket } from "./handlers/market.js";
|
|
23
23
|
import { handleTeams } from "./handlers/teams.js";
|
|
24
24
|
import { handleProjects } from "./handlers/projects.js";
|
|
25
|
+
import { handleCapacity } from "./handlers/capacity.js";
|
|
25
26
|
import { handlePacks } from "./handlers/packs.js";
|
|
26
27
|
import { handleToolWrapper } from "./handlers/tool-wrapper.js";
|
|
27
28
|
import {
|
|
@@ -73,6 +74,7 @@ const COMMAND_HANDLERS = {
|
|
|
73
74
|
market: handleMarket,
|
|
74
75
|
teams: handleTeams,
|
|
75
76
|
projects: handleProjects,
|
|
77
|
+
capacity: handleCapacity,
|
|
76
78
|
packs: handlePacks,
|
|
77
79
|
gh: handleToolWrapper,
|
|
78
80
|
railway: handleToolWrapper,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@treeseed/cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.8",
|
|
4
4
|
"description": "Operator-facing Treeseed CLI package.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"repository": {
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"release:publish": "node ./scripts/run-ts.mjs ./scripts/publish-package.ts"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@treeseed/sdk": "0.8.
|
|
48
|
+
"@treeseed/sdk": "0.8.8",
|
|
49
49
|
"ink": "^7.0.0",
|
|
50
50
|
"react": "^19.2.5"
|
|
51
51
|
},
|