@rudderhq/cli 0.3.4-canary.11 → 0.3.4-canary.13
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/index.js +946 -0
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11023,12 +11023,327 @@ var AGENT_CLI_CAPABILITIES = [
|
|
|
11023
11023
|
requiresAgentId: false,
|
|
11024
11024
|
requiresRunId: false,
|
|
11025
11025
|
attachesRunIdWhenAvailable: true
|
|
11026
|
+
},
|
|
11027
|
+
{
|
|
11028
|
+
id: "automation.list",
|
|
11029
|
+
command: "rudder automation list --org-id <id>",
|
|
11030
|
+
category: "automation",
|
|
11031
|
+
description: "List automations for an organization with compact local filters.",
|
|
11032
|
+
mutating: false,
|
|
11033
|
+
contract: "agent-v1",
|
|
11034
|
+
requiresOrgId: true,
|
|
11035
|
+
requiresAgentId: false,
|
|
11036
|
+
requiresRunId: false,
|
|
11037
|
+
attachesRunIdWhenAvailable: false
|
|
11038
|
+
},
|
|
11039
|
+
{
|
|
11040
|
+
id: "automation.get",
|
|
11041
|
+
command: "rudder automation get <automation-id>",
|
|
11042
|
+
category: "automation",
|
|
11043
|
+
description: "Read one automation detail including triggers and recent runs.",
|
|
11044
|
+
mutating: false,
|
|
11045
|
+
contract: "agent-v1",
|
|
11046
|
+
requiresOrgId: false,
|
|
11047
|
+
requiresAgentId: false,
|
|
11048
|
+
requiresRunId: false,
|
|
11049
|
+
attachesRunIdWhenAvailable: false
|
|
11050
|
+
},
|
|
11051
|
+
{
|
|
11052
|
+
id: "automation.runs",
|
|
11053
|
+
command: "rudder automation runs <automation-id>",
|
|
11054
|
+
category: "automation",
|
|
11055
|
+
description: "List recent runs for one automation.",
|
|
11056
|
+
mutating: false,
|
|
11057
|
+
contract: "agent-v1",
|
|
11058
|
+
requiresOrgId: false,
|
|
11059
|
+
requiresAgentId: false,
|
|
11060
|
+
requiresRunId: false,
|
|
11061
|
+
attachesRunIdWhenAvailable: false
|
|
11062
|
+
},
|
|
11063
|
+
{
|
|
11064
|
+
id: "automation.triggers.list",
|
|
11065
|
+
command: "rudder automation triggers list <automation-id>",
|
|
11066
|
+
category: "automation",
|
|
11067
|
+
description: "List triggers configured for one automation.",
|
|
11068
|
+
mutating: false,
|
|
11069
|
+
contract: "agent-v1",
|
|
11070
|
+
requiresOrgId: false,
|
|
11071
|
+
requiresAgentId: false,
|
|
11072
|
+
requiresRunId: false,
|
|
11073
|
+
attachesRunIdWhenAvailable: false
|
|
11074
|
+
},
|
|
11075
|
+
{
|
|
11076
|
+
id: "automation.create",
|
|
11077
|
+
command: "rudder automation create --org-id <id> --title <title> --assignee-agent-id <id>",
|
|
11078
|
+
category: "automation",
|
|
11079
|
+
description: "Create an automation through the governed automation API.",
|
|
11080
|
+
mutating: true,
|
|
11081
|
+
contract: "agent-v1",
|
|
11082
|
+
requiresOrgId: true,
|
|
11083
|
+
requiresAgentId: false,
|
|
11084
|
+
requiresRunId: false,
|
|
11085
|
+
attachesRunIdWhenAvailable: true
|
|
11086
|
+
},
|
|
11087
|
+
{
|
|
11088
|
+
id: "automation.update",
|
|
11089
|
+
command: "rudder automation update <automation-id>",
|
|
11090
|
+
category: "automation",
|
|
11091
|
+
description: "Update automation fields through the governed automation API.",
|
|
11092
|
+
mutating: true,
|
|
11093
|
+
contract: "agent-v1",
|
|
11094
|
+
requiresOrgId: false,
|
|
11095
|
+
requiresAgentId: false,
|
|
11096
|
+
requiresRunId: false,
|
|
11097
|
+
attachesRunIdWhenAvailable: true
|
|
11098
|
+
},
|
|
11099
|
+
{
|
|
11100
|
+
id: "automation.enable",
|
|
11101
|
+
command: "rudder automation enable <automation-id>",
|
|
11102
|
+
category: "automation",
|
|
11103
|
+
description: "Enable an automation by setting status to active.",
|
|
11104
|
+
mutating: true,
|
|
11105
|
+
contract: "agent-v1",
|
|
11106
|
+
requiresOrgId: false,
|
|
11107
|
+
requiresAgentId: false,
|
|
11108
|
+
requiresRunId: false,
|
|
11109
|
+
attachesRunIdWhenAvailable: true
|
|
11110
|
+
},
|
|
11111
|
+
{
|
|
11112
|
+
id: "automation.disable",
|
|
11113
|
+
command: "rudder automation disable <automation-id>",
|
|
11114
|
+
category: "automation",
|
|
11115
|
+
description: "Disable an automation by setting status to paused.",
|
|
11116
|
+
mutating: true,
|
|
11117
|
+
contract: "agent-v1",
|
|
11118
|
+
requiresOrgId: false,
|
|
11119
|
+
requiresAgentId: false,
|
|
11120
|
+
requiresRunId: false,
|
|
11121
|
+
attachesRunIdWhenAvailable: true
|
|
11122
|
+
},
|
|
11123
|
+
{
|
|
11124
|
+
id: "automation.run",
|
|
11125
|
+
command: "rudder automation run <automation-id>",
|
|
11126
|
+
category: "automation",
|
|
11127
|
+
description: "Trigger a manual automation run.",
|
|
11128
|
+
mutating: true,
|
|
11129
|
+
contract: "agent-v1",
|
|
11130
|
+
requiresOrgId: false,
|
|
11131
|
+
requiresAgentId: false,
|
|
11132
|
+
requiresRunId: false,
|
|
11133
|
+
attachesRunIdWhenAvailable: true
|
|
11134
|
+
},
|
|
11135
|
+
{
|
|
11136
|
+
id: "chat.list",
|
|
11137
|
+
command: "rudder chat list --org-id <id>",
|
|
11138
|
+
category: "chat",
|
|
11139
|
+
description: "List chat conversations without dumping full message history.",
|
|
11140
|
+
mutating: false,
|
|
11141
|
+
contract: "agent-v1",
|
|
11142
|
+
requiresOrgId: true,
|
|
11143
|
+
requiresAgentId: false,
|
|
11144
|
+
requiresRunId: false,
|
|
11145
|
+
attachesRunIdWhenAvailable: false
|
|
11146
|
+
},
|
|
11147
|
+
{
|
|
11148
|
+
id: "chat.search",
|
|
11149
|
+
command: "rudder chat search <query> --org-id <id>",
|
|
11150
|
+
category: "chat",
|
|
11151
|
+
description: "Search chats with bounded snippets and optional scope filtering.",
|
|
11152
|
+
mutating: false,
|
|
11153
|
+
contract: "agent-v1",
|
|
11154
|
+
requiresOrgId: true,
|
|
11155
|
+
requiresAgentId: false,
|
|
11156
|
+
requiresRunId: false,
|
|
11157
|
+
attachesRunIdWhenAvailable: false
|
|
11158
|
+
},
|
|
11159
|
+
{
|
|
11160
|
+
id: "chat.get",
|
|
11161
|
+
command: "rudder chat get <chat-id>",
|
|
11162
|
+
category: "chat",
|
|
11163
|
+
description: "Read one chat conversation record.",
|
|
11164
|
+
mutating: false,
|
|
11165
|
+
contract: "agent-v1",
|
|
11166
|
+
requiresOrgId: false,
|
|
11167
|
+
requiresAgentId: false,
|
|
11168
|
+
requiresRunId: false,
|
|
11169
|
+
attachesRunIdWhenAvailable: false
|
|
11170
|
+
},
|
|
11171
|
+
{
|
|
11172
|
+
id: "chat.messages",
|
|
11173
|
+
command: "rudder chat messages <chat-id>",
|
|
11174
|
+
category: "chat",
|
|
11175
|
+
description: "Read bounded chat messages, with transcript omitted unless requested.",
|
|
11176
|
+
mutating: false,
|
|
11177
|
+
contract: "agent-v1",
|
|
11178
|
+
requiresOrgId: false,
|
|
11179
|
+
requiresAgentId: false,
|
|
11180
|
+
requiresRunId: false,
|
|
11181
|
+
attachesRunIdWhenAvailable: false
|
|
11182
|
+
},
|
|
11183
|
+
{
|
|
11184
|
+
id: "chat.transcript",
|
|
11185
|
+
command: "rudder chat transcript <chat-id>",
|
|
11186
|
+
category: "chat",
|
|
11187
|
+
description: "Read chat messages with assistant transcript entries clipped in human output.",
|
|
11188
|
+
mutating: false,
|
|
11189
|
+
contract: "agent-v1",
|
|
11190
|
+
requiresOrgId: false,
|
|
11191
|
+
requiresAgentId: false,
|
|
11192
|
+
requiresRunId: false,
|
|
11193
|
+
attachesRunIdWhenAvailable: false
|
|
11194
|
+
},
|
|
11195
|
+
{
|
|
11196
|
+
id: "chat.read",
|
|
11197
|
+
command: "rudder chat read <chat-id>",
|
|
11198
|
+
category: "chat",
|
|
11199
|
+
description: "Read a bounded recent-message snapshot for one chat.",
|
|
11200
|
+
mutating: false,
|
|
11201
|
+
contract: "agent-v1",
|
|
11202
|
+
requiresOrgId: false,
|
|
11203
|
+
requiresAgentId: false,
|
|
11204
|
+
requiresRunId: false,
|
|
11205
|
+
attachesRunIdWhenAvailable: false
|
|
11206
|
+
},
|
|
11207
|
+
{
|
|
11208
|
+
id: "chat.create",
|
|
11209
|
+
command: "rudder chat create --org-id <id>",
|
|
11210
|
+
category: "chat",
|
|
11211
|
+
description: "Create a chat conversation.",
|
|
11212
|
+
mutating: true,
|
|
11213
|
+
contract: "agent-v1",
|
|
11214
|
+
requiresOrgId: true,
|
|
11215
|
+
requiresAgentId: false,
|
|
11216
|
+
requiresRunId: false,
|
|
11217
|
+
attachesRunIdWhenAvailable: true
|
|
11218
|
+
},
|
|
11219
|
+
{
|
|
11220
|
+
id: "chat.send",
|
|
11221
|
+
command: "rudder chat send <chat-id> --body <text>",
|
|
11222
|
+
category: "chat",
|
|
11223
|
+
description: "Send a chat message and persist the assistant reply through the server.",
|
|
11224
|
+
mutating: true,
|
|
11225
|
+
contract: "agent-v1",
|
|
11226
|
+
requiresOrgId: false,
|
|
11227
|
+
requiresAgentId: false,
|
|
11228
|
+
requiresRunId: false,
|
|
11229
|
+
attachesRunIdWhenAvailable: true
|
|
11230
|
+
},
|
|
11231
|
+
{
|
|
11232
|
+
id: "chat.archive",
|
|
11233
|
+
command: "rudder chat archive <chat-id>",
|
|
11234
|
+
category: "chat",
|
|
11235
|
+
description: "Archive a chat conversation without deleting it.",
|
|
11236
|
+
mutating: true,
|
|
11237
|
+
contract: "agent-v1",
|
|
11238
|
+
requiresOrgId: false,
|
|
11239
|
+
requiresAgentId: false,
|
|
11240
|
+
requiresRunId: false,
|
|
11241
|
+
attachesRunIdWhenAvailable: true
|
|
11242
|
+
},
|
|
11243
|
+
{
|
|
11244
|
+
id: "runs.list",
|
|
11245
|
+
command: "rudder runs list --org-id <id>",
|
|
11246
|
+
category: "runs",
|
|
11247
|
+
description: "List observed agent runs with filters for status, agent, issue, runtime, and time.",
|
|
11248
|
+
mutating: false,
|
|
11249
|
+
contract: "agent-v1",
|
|
11250
|
+
requiresOrgId: true,
|
|
11251
|
+
requiresAgentId: false,
|
|
11252
|
+
requiresRunId: false,
|
|
11253
|
+
attachesRunIdWhenAvailable: false
|
|
11254
|
+
},
|
|
11255
|
+
{
|
|
11256
|
+
id: "runs.get",
|
|
11257
|
+
command: "rudder runs get <run-id>",
|
|
11258
|
+
category: "runs",
|
|
11259
|
+
description: "Read one observed run detail.",
|
|
11260
|
+
mutating: false,
|
|
11261
|
+
contract: "agent-v1",
|
|
11262
|
+
requiresOrgId: false,
|
|
11263
|
+
requiresAgentId: false,
|
|
11264
|
+
requiresRunId: false,
|
|
11265
|
+
attachesRunIdWhenAvailable: false
|
|
11266
|
+
},
|
|
11267
|
+
{
|
|
11268
|
+
id: "runs.events",
|
|
11269
|
+
command: "rudder runs events <run-id>",
|
|
11270
|
+
category: "runs",
|
|
11271
|
+
description: "List persisted run events.",
|
|
11272
|
+
mutating: false,
|
|
11273
|
+
contract: "agent-v1",
|
|
11274
|
+
requiresOrgId: false,
|
|
11275
|
+
requiresAgentId: false,
|
|
11276
|
+
requiresRunId: false,
|
|
11277
|
+
attachesRunIdWhenAvailable: false
|
|
11278
|
+
},
|
|
11279
|
+
{
|
|
11280
|
+
id: "runs.log",
|
|
11281
|
+
command: "rudder runs log <run-id>",
|
|
11282
|
+
category: "runs",
|
|
11283
|
+
description: "Read stored run log content with clipped human output.",
|
|
11284
|
+
mutating: false,
|
|
11285
|
+
contract: "agent-v1",
|
|
11286
|
+
requiresOrgId: false,
|
|
11287
|
+
requiresAgentId: false,
|
|
11288
|
+
requiresRunId: false,
|
|
11289
|
+
attachesRunIdWhenAvailable: false
|
|
11290
|
+
},
|
|
11291
|
+
{
|
|
11292
|
+
id: "runs.transcript",
|
|
11293
|
+
command: "rudder runs transcript <run-id>",
|
|
11294
|
+
category: "runs",
|
|
11295
|
+
description: "Read the server-normalized run transcript, newest-first by default.",
|
|
11296
|
+
mutating: false,
|
|
11297
|
+
contract: "agent-v1",
|
|
11298
|
+
requiresOrgId: false,
|
|
11299
|
+
requiresAgentId: false,
|
|
11300
|
+
requiresRunId: false,
|
|
11301
|
+
attachesRunIdWhenAvailable: false
|
|
11302
|
+
},
|
|
11303
|
+
{
|
|
11304
|
+
id: "runs.errors",
|
|
11305
|
+
command: "rudder runs errors <run-id>",
|
|
11306
|
+
category: "runs",
|
|
11307
|
+
description: "List failed tool calls, stderr, runtime failures, and jump-to-context commands.",
|
|
11308
|
+
mutating: false,
|
|
11309
|
+
contract: "agent-v1",
|
|
11310
|
+
requiresOrgId: false,
|
|
11311
|
+
requiresAgentId: false,
|
|
11312
|
+
requiresRunId: false,
|
|
11313
|
+
attachesRunIdWhenAvailable: false
|
|
11314
|
+
},
|
|
11315
|
+
{
|
|
11316
|
+
id: "runs.cancel",
|
|
11317
|
+
command: "rudder runs cancel <run-id>",
|
|
11318
|
+
category: "runs",
|
|
11319
|
+
description: "Cancel a heartbeat run through the governed server route.",
|
|
11320
|
+
mutating: true,
|
|
11321
|
+
contract: "agent-v1",
|
|
11322
|
+
requiresOrgId: false,
|
|
11323
|
+
requiresAgentId: false,
|
|
11324
|
+
requiresRunId: false,
|
|
11325
|
+
attachesRunIdWhenAvailable: true
|
|
11326
|
+
},
|
|
11327
|
+
{
|
|
11328
|
+
id: "runs.retry",
|
|
11329
|
+
command: "rudder runs retry <run-id>",
|
|
11330
|
+
category: "runs",
|
|
11331
|
+
description: "Retry a failed, timed out, or cancelled run through the governed server route.",
|
|
11332
|
+
mutating: true,
|
|
11333
|
+
contract: "agent-v1",
|
|
11334
|
+
requiresOrgId: false,
|
|
11335
|
+
requiresAgentId: false,
|
|
11336
|
+
requiresRunId: false,
|
|
11337
|
+
attachesRunIdWhenAvailable: true
|
|
11026
11338
|
}
|
|
11027
11339
|
];
|
|
11028
11340
|
var CATEGORY_TITLES = {
|
|
11029
11341
|
agent: "Agent",
|
|
11030
11342
|
issue: "Issue",
|
|
11031
11343
|
project: "Project",
|
|
11344
|
+
automation: "Automation",
|
|
11345
|
+
chat: "Chat",
|
|
11346
|
+
runs: "Runs",
|
|
11032
11347
|
approval: "Approval",
|
|
11033
11348
|
skill: "Skill",
|
|
11034
11349
|
library: "Library"
|
|
@@ -12917,6 +13232,634 @@ async function readStdinText3() {
|
|
|
12917
13232
|
return Buffer.concat(chunks).toString("utf8");
|
|
12918
13233
|
}
|
|
12919
13234
|
|
|
13235
|
+
// src/commands/client/automation.ts
|
|
13236
|
+
init_dist();
|
|
13237
|
+
function registerAutomationCommands(program) {
|
|
13238
|
+
const automation = program.command("automation").description("Automation operations");
|
|
13239
|
+
addCommonClientOptions(
|
|
13240
|
+
automation.command("list").description(getAgentCliCapabilityById("automation.list").description).option("-O, --org-id <id>", "Organization ID").option("--status <status>", "Filter by automation status").option("--assignee-agent-id <id>", "Filter by assignee agent ID").option("--project-id <id>", "Filter by project ID").option("--output-mode <mode>", "Filter by output mode").action(async (opts) => {
|
|
13241
|
+
try {
|
|
13242
|
+
const ctx = resolveCommandContext(opts, { requireCompany: true });
|
|
13243
|
+
const rows = await ctx.api.get(`/api/orgs/${ctx.orgId}/automations`) ?? [];
|
|
13244
|
+
const filtered = rows.filter(
|
|
13245
|
+
(row) => (!opts.status || row.status === opts.status) && (!opts.assigneeAgentId || row.assigneeAgentId === opts.assigneeAgentId) && (!opts.projectId || row.projectId === opts.projectId) && (!opts.outputMode || row.outputMode === opts.outputMode)
|
|
13246
|
+
);
|
|
13247
|
+
printOutput(ctx.json ? filtered : filtered.map(formatAutomationListItem), { json: ctx.json });
|
|
13248
|
+
} catch (err) {
|
|
13249
|
+
handleCommandError(err);
|
|
13250
|
+
}
|
|
13251
|
+
}),
|
|
13252
|
+
{ includeCompany: false }
|
|
13253
|
+
);
|
|
13254
|
+
addCommonClientOptions(
|
|
13255
|
+
automation.command("get").description(getAgentCliCapabilityById("automation.get").description).argument("<automationId>", "Automation ID").action(async (automationId, opts) => {
|
|
13256
|
+
try {
|
|
13257
|
+
const ctx = resolveCommandContext(opts);
|
|
13258
|
+
const row = await ctx.api.get(`/api/automations/${encodeURIComponent(automationId)}`);
|
|
13259
|
+
printOutput(row, { json: ctx.json });
|
|
13260
|
+
} catch (err) {
|
|
13261
|
+
handleCommandError(err);
|
|
13262
|
+
}
|
|
13263
|
+
})
|
|
13264
|
+
);
|
|
13265
|
+
addCommonClientOptions(
|
|
13266
|
+
automation.command("runs").description(getAgentCliCapabilityById("automation.runs").description).argument("<automationId>", "Automation ID").option("--limit <n>", "Maximum runs to return", "50").action(async (automationId, opts) => {
|
|
13267
|
+
try {
|
|
13268
|
+
const ctx = resolveCommandContext(opts);
|
|
13269
|
+
const params = new URLSearchParams();
|
|
13270
|
+
if (opts.limit) params.set("limit", opts.limit);
|
|
13271
|
+
const rows = await ctx.api.get(
|
|
13272
|
+
`/api/automations/${encodeURIComponent(automationId)}/runs?${params.toString()}`
|
|
13273
|
+
) ?? [];
|
|
13274
|
+
printOutput(ctx.json ? rows : rows.map(formatAutomationRun), { json: ctx.json });
|
|
13275
|
+
} catch (err) {
|
|
13276
|
+
handleCommandError(err);
|
|
13277
|
+
}
|
|
13278
|
+
})
|
|
13279
|
+
);
|
|
13280
|
+
addCommonClientOptions(
|
|
13281
|
+
automation.command("triggers").description("Automation trigger operations").command("list").description(getAgentCliCapabilityById("automation.triggers.list").description).argument("<automationId>", "Automation ID").action(async (automationId, opts) => {
|
|
13282
|
+
try {
|
|
13283
|
+
const ctx = resolveCommandContext(opts);
|
|
13284
|
+
const row = await ctx.api.get(`/api/automations/${encodeURIComponent(automationId)}`);
|
|
13285
|
+
const triggers = row?.triggers ?? [];
|
|
13286
|
+
printOutput(triggers, { json: ctx.json });
|
|
13287
|
+
} catch (err) {
|
|
13288
|
+
handleCommandError(err);
|
|
13289
|
+
}
|
|
13290
|
+
})
|
|
13291
|
+
);
|
|
13292
|
+
addCommonClientOptions(
|
|
13293
|
+
automation.command("create").description(getAgentCliCapabilityById("automation.create").description).option("-O, --org-id <id>", "Organization ID").option("--payload <json>", "Raw automation create payload JSON").option("--title <title>", "Automation title").option("--description <text>", "Automation description").option("--assignee-agent-id <id>", "Assignee agent ID").option("--project-id <id>", "Project ID").option("--goal-id <id>", "Goal ID").option("--parent-issue-id <id>", "Parent issue ID").option("--priority <priority>", "Issue priority for tracked output").option("--status <status>", "Automation status").option("--output-mode <mode>", "Automation output mode").option("--concurrency-policy <policy>", "Automation concurrency policy").option("--catch-up-policy <policy>", "Automation catch-up policy").option("--notify-on-issue-created", "Notify when tracked issue output is created").action(async (opts) => {
|
|
13294
|
+
try {
|
|
13295
|
+
const ctx = resolveCommandContext(opts, { requireCompany: true });
|
|
13296
|
+
const payload = createAutomationSchema.parse(buildAutomationPayload(opts));
|
|
13297
|
+
const created = await ctx.api.post(`/api/orgs/${ctx.orgId}/automations`, payload);
|
|
13298
|
+
printOutput(created, { json: ctx.json });
|
|
13299
|
+
} catch (err) {
|
|
13300
|
+
handleCommandError(err);
|
|
13301
|
+
}
|
|
13302
|
+
}),
|
|
13303
|
+
{ includeCompany: false }
|
|
13304
|
+
);
|
|
13305
|
+
addCommonClientOptions(
|
|
13306
|
+
automation.command("update").description(getAgentCliCapabilityById("automation.update").description).argument("<automationId>", "Automation ID").option("--payload <json>", "Raw automation update payload JSON").option("--title <title>", "Automation title").option("--description <text>", "Automation description").option("--assignee-agent-id <id>", "Assignee agent ID").option("--project-id <id>", "Project ID").option("--goal-id <id>", "Goal ID").option("--parent-issue-id <id>", "Parent issue ID").option("--priority <priority>", "Issue priority for tracked output").option("--status <status>", "Automation status").option("--output-mode <mode>", "Automation output mode").option("--concurrency-policy <policy>", "Automation concurrency policy").option("--catch-up-policy <policy>", "Automation catch-up policy").option("--notify-on-issue-created", "Notify when tracked issue output is created").action(async (automationId, opts) => {
|
|
13307
|
+
try {
|
|
13308
|
+
const ctx = resolveCommandContext(opts);
|
|
13309
|
+
const payload = updateAutomationSchema.parse(buildAutomationPayload(opts));
|
|
13310
|
+
const updated = await ctx.api.patch(`/api/automations/${encodeURIComponent(automationId)}`, payload);
|
|
13311
|
+
printOutput(updated, { json: ctx.json });
|
|
13312
|
+
} catch (err) {
|
|
13313
|
+
handleCommandError(err);
|
|
13314
|
+
}
|
|
13315
|
+
})
|
|
13316
|
+
);
|
|
13317
|
+
addCommonClientOptions(
|
|
13318
|
+
automation.command("enable").description(getAgentCliCapabilityById("automation.enable").description).argument("<automationId>", "Automation ID").action(async (automationId, opts) => {
|
|
13319
|
+
try {
|
|
13320
|
+
const ctx = resolveCommandContext(opts);
|
|
13321
|
+
const updated = await ctx.api.patch(`/api/automations/${encodeURIComponent(automationId)}`, {
|
|
13322
|
+
status: "active"
|
|
13323
|
+
});
|
|
13324
|
+
printOutput(updated, { json: ctx.json });
|
|
13325
|
+
} catch (err) {
|
|
13326
|
+
handleCommandError(err);
|
|
13327
|
+
}
|
|
13328
|
+
})
|
|
13329
|
+
);
|
|
13330
|
+
addCommonClientOptions(
|
|
13331
|
+
automation.command("disable").description(getAgentCliCapabilityById("automation.disable").description).argument("<automationId>", "Automation ID").action(async (automationId, opts) => {
|
|
13332
|
+
try {
|
|
13333
|
+
const ctx = resolveCommandContext(opts);
|
|
13334
|
+
const updated = await ctx.api.patch(`/api/automations/${encodeURIComponent(automationId)}`, {
|
|
13335
|
+
status: "paused"
|
|
13336
|
+
});
|
|
13337
|
+
printOutput(updated, { json: ctx.json });
|
|
13338
|
+
} catch (err) {
|
|
13339
|
+
handleCommandError(err);
|
|
13340
|
+
}
|
|
13341
|
+
})
|
|
13342
|
+
);
|
|
13343
|
+
addCommonClientOptions(
|
|
13344
|
+
automation.command("run").description(getAgentCliCapabilityById("automation.run").description).argument("<automationId>", "Automation ID").option("--trigger-id <id>", "Trigger ID").option("--payload <json>", "Manual run payload JSON").option("--idempotency-key <key>", "Idempotency key").option("--source <source>", "Run source", "manual").action(async (automationId, opts) => {
|
|
13345
|
+
try {
|
|
13346
|
+
const ctx = resolveCommandContext(opts);
|
|
13347
|
+
const payload = runAutomationSchema.parse({
|
|
13348
|
+
triggerId: opts.triggerId,
|
|
13349
|
+
payload: opts.payload ? parseJsonOption(opts.payload, "--payload") : void 0,
|
|
13350
|
+
idempotencyKey: opts.idempotencyKey,
|
|
13351
|
+
source: opts.source
|
|
13352
|
+
});
|
|
13353
|
+
const run = await ctx.api.post(`/api/automations/${encodeURIComponent(automationId)}/run`, payload);
|
|
13354
|
+
printOutput(run, { json: ctx.json });
|
|
13355
|
+
} catch (err) {
|
|
13356
|
+
handleCommandError(err);
|
|
13357
|
+
}
|
|
13358
|
+
})
|
|
13359
|
+
);
|
|
13360
|
+
}
|
|
13361
|
+
function buildAutomationPayload(opts) {
|
|
13362
|
+
return {
|
|
13363
|
+
...parseJsonObjectOption(opts.payload, "--payload"),
|
|
13364
|
+
...definedRecord({
|
|
13365
|
+
title: opts.title,
|
|
13366
|
+
description: opts.description,
|
|
13367
|
+
assigneeAgentId: opts.assigneeAgentId,
|
|
13368
|
+
projectId: opts.projectId,
|
|
13369
|
+
goalId: opts.goalId,
|
|
13370
|
+
parentIssueId: opts.parentIssueId,
|
|
13371
|
+
priority: opts.priority,
|
|
13372
|
+
status: opts.status,
|
|
13373
|
+
outputMode: opts.outputMode,
|
|
13374
|
+
concurrencyPolicy: opts.concurrencyPolicy,
|
|
13375
|
+
catchUpPolicy: opts.catchUpPolicy,
|
|
13376
|
+
notifyOnIssueCreated: opts.notifyOnIssueCreated
|
|
13377
|
+
})
|
|
13378
|
+
};
|
|
13379
|
+
}
|
|
13380
|
+
function definedRecord(record) {
|
|
13381
|
+
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== void 0));
|
|
13382
|
+
}
|
|
13383
|
+
function parseJsonOption(value, label) {
|
|
13384
|
+
try {
|
|
13385
|
+
return JSON.parse(value);
|
|
13386
|
+
} catch (error) {
|
|
13387
|
+
throw new Error(`${label} must be valid JSON`);
|
|
13388
|
+
}
|
|
13389
|
+
}
|
|
13390
|
+
function parseJsonObjectOption(value, label) {
|
|
13391
|
+
if (!value) return {};
|
|
13392
|
+
const parsed = parseJsonOption(value, label);
|
|
13393
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
13394
|
+
throw new Error(`${label} must be a JSON object`);
|
|
13395
|
+
}
|
|
13396
|
+
return parsed;
|
|
13397
|
+
}
|
|
13398
|
+
function formatAutomationListItem(row) {
|
|
13399
|
+
const nextRunAt = row.triggers.map((trigger) => trigger.nextRunAt).filter(Boolean).sort()[0] ?? null;
|
|
13400
|
+
return {
|
|
13401
|
+
id: row.id,
|
|
13402
|
+
title: row.title,
|
|
13403
|
+
status: row.status,
|
|
13404
|
+
assigneeAgentId: row.assigneeAgentId,
|
|
13405
|
+
outputMode: row.outputMode,
|
|
13406
|
+
lastRun: row.lastRun?.status ?? "-",
|
|
13407
|
+
nextRunAt
|
|
13408
|
+
};
|
|
13409
|
+
}
|
|
13410
|
+
function formatAutomationRun(row) {
|
|
13411
|
+
return {
|
|
13412
|
+
id: row.id,
|
|
13413
|
+
status: row.status,
|
|
13414
|
+
source: row.source,
|
|
13415
|
+
triggeredAt: row.triggeredAt,
|
|
13416
|
+
linkedIssue: row.linkedIssue?.identifier ?? row.linkedIssueId ?? "-",
|
|
13417
|
+
linkedChatConversationId: row.linkedChatConversationId ?? "-",
|
|
13418
|
+
failureReason: row.failureReason ?? "-"
|
|
13419
|
+
};
|
|
13420
|
+
}
|
|
13421
|
+
|
|
13422
|
+
// src/commands/client/chat.ts
|
|
13423
|
+
init_dist();
|
|
13424
|
+
function registerChatCommands(program) {
|
|
13425
|
+
const chat = program.command("chat").description("Chat operations");
|
|
13426
|
+
addCommonClientOptions(
|
|
13427
|
+
chat.command("list").description(getAgentCliCapabilityById("chat.list").description).option("-O, --org-id <id>", "Organization ID").option("--status <status>", "active, resolved, archived, or all", "active").option("--query <text>", "Server-side chat search query").option("--limit <n>", "Maximum rows to print").action(async (opts) => {
|
|
13428
|
+
try {
|
|
13429
|
+
const ctx = resolveCommandContext(opts, { requireCompany: true });
|
|
13430
|
+
const rows = await listChats(ctx, opts);
|
|
13431
|
+
printOutput(ctx.json ? rows : rows.map(formatChatConversation), { json: ctx.json });
|
|
13432
|
+
} catch (err) {
|
|
13433
|
+
handleCommandError(err);
|
|
13434
|
+
}
|
|
13435
|
+
}),
|
|
13436
|
+
{ includeCompany: false }
|
|
13437
|
+
);
|
|
13438
|
+
addCommonClientOptions(
|
|
13439
|
+
chat.command("search").description(getAgentCliCapabilityById("chat.search").description).argument("<query>", "Search query").option("-O, --org-id <id>", "Organization ID").option("--status <status>", "active, resolved, archived, or all", "all").option("--scope <scope>", "Search scope: all, title, summary, messages", "all").option("--limit <n>", "Maximum rows to print", "20").option("--snippet-chars <n>", "Maximum snippet characters", "220").action(async (query, opts) => {
|
|
13440
|
+
try {
|
|
13441
|
+
const ctx = resolveCommandContext(opts, { requireCompany: true });
|
|
13442
|
+
const rows = await listChats(ctx, { ...opts, query });
|
|
13443
|
+
const filtered = filterChatSearchRows(rows, query, opts.scope ?? "all").slice(0, parseLimit(opts.limit, rows.length));
|
|
13444
|
+
const snippetChars = parseLimit(opts.snippetChars, 220);
|
|
13445
|
+
printOutput(
|
|
13446
|
+
ctx.json ? filtered : filtered.map((row) => formatChatSearchResult(row, snippetChars)),
|
|
13447
|
+
{ json: ctx.json }
|
|
13448
|
+
);
|
|
13449
|
+
} catch (err) {
|
|
13450
|
+
handleCommandError(err);
|
|
13451
|
+
}
|
|
13452
|
+
}),
|
|
13453
|
+
{ includeCompany: false }
|
|
13454
|
+
);
|
|
13455
|
+
addCommonClientOptions(
|
|
13456
|
+
chat.command("get").description(getAgentCliCapabilityById("chat.get").description).argument("<chatId>", "Chat conversation ID").action(async (chatId, opts) => {
|
|
13457
|
+
try {
|
|
13458
|
+
const ctx = resolveCommandContext(opts);
|
|
13459
|
+
const row = await ctx.api.get(`/api/chats/${encodeURIComponent(chatId)}`);
|
|
13460
|
+
printOutput(row, { json: ctx.json });
|
|
13461
|
+
} catch (err) {
|
|
13462
|
+
handleCommandError(err);
|
|
13463
|
+
}
|
|
13464
|
+
})
|
|
13465
|
+
);
|
|
13466
|
+
addCommonClientOptions(
|
|
13467
|
+
chat.command("messages").description(getAgentCliCapabilityById("chat.messages").description).argument("<chatId>", "Chat conversation ID").option("--include-transcript", "Include assistant transcript entries").option("--limit <n>", "Maximum messages to print").action(async (chatId, opts) => {
|
|
13468
|
+
try {
|
|
13469
|
+
const ctx = resolveCommandContext(opts);
|
|
13470
|
+
const messages = await getChatMessages(ctx, chatId, Boolean(opts.includeTranscript));
|
|
13471
|
+
const limited = limitNewest(messages, opts.limit);
|
|
13472
|
+
printOutput(ctx.json ? limited : limited.map(formatChatMessage), { json: ctx.json });
|
|
13473
|
+
} catch (err) {
|
|
13474
|
+
handleCommandError(err);
|
|
13475
|
+
}
|
|
13476
|
+
})
|
|
13477
|
+
);
|
|
13478
|
+
addCommonClientOptions(
|
|
13479
|
+
chat.command("transcript").description(getAgentCliCapabilityById("chat.transcript").description).argument("<chatId>", "Chat conversation ID").option("--limit <n>", "Maximum messages to print").option("--max-chars <n>", "Maximum transcript chars per message", "1200").action(async (chatId, opts) => {
|
|
13480
|
+
try {
|
|
13481
|
+
const ctx = resolveCommandContext(opts);
|
|
13482
|
+
const messages = await getChatMessages(ctx, chatId, true);
|
|
13483
|
+
const limited = limitNewest(messages, opts.limit);
|
|
13484
|
+
printOutput(
|
|
13485
|
+
ctx.json ? limited : limited.flatMap((message) => formatChatTranscriptMessage(message, parseLimit(opts.maxChars, 1200))),
|
|
13486
|
+
{ json: ctx.json }
|
|
13487
|
+
);
|
|
13488
|
+
} catch (err) {
|
|
13489
|
+
handleCommandError(err);
|
|
13490
|
+
}
|
|
13491
|
+
})
|
|
13492
|
+
);
|
|
13493
|
+
addCommonClientOptions(
|
|
13494
|
+
chat.command("read").description(getAgentCliCapabilityById("chat.read").description).argument("<chatId>", "Chat conversation ID").option("--include-transcript", "Include assistant transcript entries").option("--limit <n>", "Maximum recent messages", "20").action(async (chatId, opts) => {
|
|
13495
|
+
try {
|
|
13496
|
+
const ctx = resolveCommandContext(opts);
|
|
13497
|
+
const [conversation, messages] = await Promise.all([
|
|
13498
|
+
ctx.api.get(`/api/chats/${encodeURIComponent(chatId)}`),
|
|
13499
|
+
getChatMessages(ctx, chatId, Boolean(opts.includeTranscript))
|
|
13500
|
+
]);
|
|
13501
|
+
const recentMessages = limitNewest(messages, opts.limit);
|
|
13502
|
+
const payload = {
|
|
13503
|
+
conversation,
|
|
13504
|
+
messages: recentMessages
|
|
13505
|
+
};
|
|
13506
|
+
printOutput(ctx.json ? payload : recentMessages.map(formatChatMessage), { json: ctx.json });
|
|
13507
|
+
} catch (err) {
|
|
13508
|
+
handleCommandError(err);
|
|
13509
|
+
}
|
|
13510
|
+
})
|
|
13511
|
+
);
|
|
13512
|
+
addCommonClientOptions(
|
|
13513
|
+
chat.command("create").description(getAgentCliCapabilityById("chat.create").description).option("-O, --org-id <id>", "Organization ID").option("--payload <json>", "Raw chat create payload JSON").option("--title <title>", "Chat title").option("--summary <text>", "Chat summary").option("--preferred-agent-id <id>", "Preferred agent ID").option("--issue-creation-mode <mode>", "Issue creation mode").option("--plan-mode", "Create a plan-mode chat").action(async (opts) => {
|
|
13514
|
+
try {
|
|
13515
|
+
const ctx = resolveCommandContext(opts, { requireCompany: true });
|
|
13516
|
+
const payload = createChatConversationSchema.parse({
|
|
13517
|
+
...parseJsonObjectOption2(opts.payload, "--payload"),
|
|
13518
|
+
...definedRecord2({
|
|
13519
|
+
title: opts.title,
|
|
13520
|
+
summary: opts.summary,
|
|
13521
|
+
preferredAgentId: opts.preferredAgentId,
|
|
13522
|
+
issueCreationMode: opts.issueCreationMode,
|
|
13523
|
+
planMode: opts.planMode
|
|
13524
|
+
})
|
|
13525
|
+
});
|
|
13526
|
+
const created = await ctx.api.post(`/api/orgs/${ctx.orgId}/chats`, payload);
|
|
13527
|
+
printOutput(created, { json: ctx.json });
|
|
13528
|
+
} catch (err) {
|
|
13529
|
+
handleCommandError(err);
|
|
13530
|
+
}
|
|
13531
|
+
}),
|
|
13532
|
+
{ includeCompany: false }
|
|
13533
|
+
);
|
|
13534
|
+
addCommonClientOptions(
|
|
13535
|
+
chat.command("send").description(getAgentCliCapabilityById("chat.send").description).argument("<chatId>", "Chat conversation ID").option("--body <text>", "Message body").option("--edit-user-message-id <id>", "Regenerate/edit from a prior user message").action(async (chatId, opts) => {
|
|
13536
|
+
try {
|
|
13537
|
+
const ctx = resolveCommandContext(opts);
|
|
13538
|
+
const body = opts.body ?? await readStdin();
|
|
13539
|
+
const payload = addChatMessageSchema.parse({
|
|
13540
|
+
body,
|
|
13541
|
+
editUserMessageId: opts.editUserMessageId
|
|
13542
|
+
});
|
|
13543
|
+
const result = await ctx.api.post(`/api/chats/${encodeURIComponent(chatId)}/messages`, payload);
|
|
13544
|
+
printOutput(result, { json: ctx.json });
|
|
13545
|
+
} catch (err) {
|
|
13546
|
+
handleCommandError(err);
|
|
13547
|
+
}
|
|
13548
|
+
})
|
|
13549
|
+
);
|
|
13550
|
+
addCommonClientOptions(
|
|
13551
|
+
chat.command("archive").description(getAgentCliCapabilityById("chat.archive").description).argument("<chatId>", "Chat conversation ID").action(async (chatId, opts) => {
|
|
13552
|
+
try {
|
|
13553
|
+
const ctx = resolveCommandContext(opts);
|
|
13554
|
+
const payload = updateChatConversationSchema.parse({ status: "archived" });
|
|
13555
|
+
const updated = await ctx.api.patch(`/api/chats/${encodeURIComponent(chatId)}`, payload);
|
|
13556
|
+
printOutput(updated, { json: ctx.json });
|
|
13557
|
+
} catch (err) {
|
|
13558
|
+
handleCommandError(err);
|
|
13559
|
+
}
|
|
13560
|
+
})
|
|
13561
|
+
);
|
|
13562
|
+
}
|
|
13563
|
+
async function listChats(ctx, opts) {
|
|
13564
|
+
const params = new URLSearchParams();
|
|
13565
|
+
if (opts.status) params.set("status", opts.status);
|
|
13566
|
+
if (opts.query) params.set("q", opts.query);
|
|
13567
|
+
const rows = await ctx.api.get(`/api/orgs/${ctx.orgId}/chats?${params.toString()}`) ?? [];
|
|
13568
|
+
return rows.slice(0, parseLimit(opts.limit, rows.length));
|
|
13569
|
+
}
|
|
13570
|
+
async function getChatMessages(ctx, chatId, includeTranscript) {
|
|
13571
|
+
const params = new URLSearchParams();
|
|
13572
|
+
if (includeTranscript) params.set("includeTranscript", "true");
|
|
13573
|
+
return await ctx.api.get(`/api/chats/${encodeURIComponent(chatId)}/messages?${params.toString()}`) ?? [];
|
|
13574
|
+
}
|
|
13575
|
+
function filterChatSearchRows(rows, query, scope) {
|
|
13576
|
+
const normalized = query.toLowerCase();
|
|
13577
|
+
if (scope === "all") return rows;
|
|
13578
|
+
return rows.filter((row) => {
|
|
13579
|
+
if (scope === "title") return row.title.toLowerCase().includes(normalized);
|
|
13580
|
+
if (scope === "summary") return Boolean(row.summary?.toLowerCase().includes(normalized));
|
|
13581
|
+
if (scope === "messages") return Boolean(row.searchPreview?.toLowerCase().includes(normalized));
|
|
13582
|
+
return true;
|
|
13583
|
+
});
|
|
13584
|
+
}
|
|
13585
|
+
function formatChatConversation(row) {
|
|
13586
|
+
return {
|
|
13587
|
+
id: row.id,
|
|
13588
|
+
title: row.title,
|
|
13589
|
+
status: row.status,
|
|
13590
|
+
preferredAgentId: row.preferredAgentId ?? "-",
|
|
13591
|
+
unread: row.unreadCount,
|
|
13592
|
+
lastMessageAt: row.lastMessageAt ?? "-",
|
|
13593
|
+
preview: row.latestReplyPreview ?? row.latestUserMessagePreview ?? "-"
|
|
13594
|
+
};
|
|
13595
|
+
}
|
|
13596
|
+
function formatChatSearchResult(row, maxChars) {
|
|
13597
|
+
return {
|
|
13598
|
+
id: row.id,
|
|
13599
|
+
title: row.title,
|
|
13600
|
+
status: row.status,
|
|
13601
|
+
lastMessageAt: row.lastMessageAt ?? "-",
|
|
13602
|
+
snippet: clip(row.searchPreview ?? row.latestReplyPreview ?? row.latestUserMessagePreview ?? row.summary ?? "", maxChars)
|
|
13603
|
+
};
|
|
13604
|
+
}
|
|
13605
|
+
function formatChatMessage(row) {
|
|
13606
|
+
return {
|
|
13607
|
+
id: row.id,
|
|
13608
|
+
role: row.role,
|
|
13609
|
+
kind: row.kind,
|
|
13610
|
+
status: row.status,
|
|
13611
|
+
createdAt: row.createdAt,
|
|
13612
|
+
body: clip(row.body, 220),
|
|
13613
|
+
transcriptEntries: row.transcriptSummary?.entryCount ?? row.transcript?.length ?? 0
|
|
13614
|
+
};
|
|
13615
|
+
}
|
|
13616
|
+
function formatChatTranscriptMessage(row, maxChars) {
|
|
13617
|
+
const header = {
|
|
13618
|
+
id: row.id,
|
|
13619
|
+
role: row.role,
|
|
13620
|
+
kind: row.kind,
|
|
13621
|
+
status: row.status,
|
|
13622
|
+
createdAt: row.createdAt,
|
|
13623
|
+
body: clip(row.body, 220)
|
|
13624
|
+
};
|
|
13625
|
+
const transcriptRows = (row.transcript ?? []).map((entry, index) => ({
|
|
13626
|
+
id: `${row.id}:entry-${index + 1}`,
|
|
13627
|
+
messageId: row.id,
|
|
13628
|
+
role: row.role,
|
|
13629
|
+
entry: formatTranscriptEntry(entry, maxChars)
|
|
13630
|
+
}));
|
|
13631
|
+
return transcriptRows.length > 0 ? [header, ...transcriptRows] : [header];
|
|
13632
|
+
}
|
|
13633
|
+
function formatTranscriptEntry(entry, maxChars) {
|
|
13634
|
+
if (entry.kind === "tool_call") return `${entry.ts} tool_call ${entry.name} ${clip(JSON.stringify(entry.input), maxChars)}`;
|
|
13635
|
+
if (entry.kind === "tool_result") return `${entry.ts} tool_result ${entry.toolName ?? entry.toolUseId} ${entry.isError ? "ERROR " : ""}${clip(entry.content, maxChars)}`;
|
|
13636
|
+
if (entry.kind === "result") return `${entry.ts} result ${entry.isError ? "ERROR " : ""}${clip(entry.text || entry.errors.join("; "), maxChars)}`;
|
|
13637
|
+
if ("text" in entry) return `${entry.ts} ${entry.kind} ${clip(entry.text, maxChars)}`;
|
|
13638
|
+
return `${entry.ts} ${entry.kind}`;
|
|
13639
|
+
}
|
|
13640
|
+
function parseLimit(value, fallback) {
|
|
13641
|
+
const parsed = Number(value ?? fallback);
|
|
13642
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return fallback;
|
|
13643
|
+
return Math.floor(parsed);
|
|
13644
|
+
}
|
|
13645
|
+
function limitNewest(rows, limit) {
|
|
13646
|
+
if (!limit) return rows;
|
|
13647
|
+
return rows.slice(-parseLimit(limit, rows.length));
|
|
13648
|
+
}
|
|
13649
|
+
function clip(value, maxChars) {
|
|
13650
|
+
const text6 = value.replace(/\s+/g, " ").trim();
|
|
13651
|
+
if (text6.length <= maxChars) return text6;
|
|
13652
|
+
return `${text6.slice(0, Math.max(0, maxChars - 1))}\u2026`;
|
|
13653
|
+
}
|
|
13654
|
+
function parseJsonObjectOption2(value, label) {
|
|
13655
|
+
if (!value) return {};
|
|
13656
|
+
try {
|
|
13657
|
+
const parsed = JSON.parse(value);
|
|
13658
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
13659
|
+
throw new Error(`${label} must be a JSON object`);
|
|
13660
|
+
}
|
|
13661
|
+
return parsed;
|
|
13662
|
+
} catch (error) {
|
|
13663
|
+
if (error instanceof Error && error.message.includes("JSON object")) throw error;
|
|
13664
|
+
throw new Error(`${label} must be valid JSON`);
|
|
13665
|
+
}
|
|
13666
|
+
}
|
|
13667
|
+
function definedRecord2(record) {
|
|
13668
|
+
return Object.fromEntries(Object.entries(record).filter(([, value]) => value !== void 0));
|
|
13669
|
+
}
|
|
13670
|
+
async function readStdin() {
|
|
13671
|
+
const chunks = [];
|
|
13672
|
+
for await (const chunk of process.stdin) {
|
|
13673
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
13674
|
+
}
|
|
13675
|
+
return Buffer.concat(chunks).toString("utf8");
|
|
13676
|
+
}
|
|
13677
|
+
|
|
13678
|
+
// src/commands/client/runs.ts
|
|
13679
|
+
function registerRunsCommands(program) {
|
|
13680
|
+
const runs = program.command("runs").description("Run debugging operations");
|
|
13681
|
+
addCommonClientOptions(
|
|
13682
|
+
runs.command("list").description(getAgentCliCapabilityById("runs.list").description).option("-O, --org-id <id>", "Organization ID").option("--updated-after <iso>", "Only runs updated after this timestamp").option("--run-id-prefix <prefix>", "Filter by run ID prefix").option("--agent-id <id>", "Filter by agent ID").option("--status <status>", "Filter by run status").option("--runtime <type>", "Filter by runtime type").option("--issue-id <id>", "Filter by linked issue ID").option("--created-before <iso>", "Only runs created before this timestamp").option("--limit <n>", "Maximum rows", "200").action(async (opts) => {
|
|
13683
|
+
try {
|
|
13684
|
+
const ctx = resolveCommandContext(opts, { requireCompany: true });
|
|
13685
|
+
const rows = await ctx.api.get(`/api/run-intelligence/orgs/${ctx.orgId}/runs?${buildRunsListQuery(opts)}`) ?? [];
|
|
13686
|
+
printOutput(ctx.json ? rows : rows.map(formatRunListRow), { json: ctx.json });
|
|
13687
|
+
} catch (err) {
|
|
13688
|
+
handleCommandError(err);
|
|
13689
|
+
}
|
|
13690
|
+
}),
|
|
13691
|
+
{ includeCompany: false }
|
|
13692
|
+
);
|
|
13693
|
+
addCommonClientOptions(
|
|
13694
|
+
runs.command("get").description(getAgentCliCapabilityById("runs.get").description).argument("<runId>", "Run ID").action(async (runId, opts) => {
|
|
13695
|
+
try {
|
|
13696
|
+
const ctx = resolveCommandContext(opts);
|
|
13697
|
+
const row = await ctx.api.get(`/api/run-intelligence/runs/${encodeURIComponent(runId)}`);
|
|
13698
|
+
printOutput(row, { json: ctx.json });
|
|
13699
|
+
} catch (err) {
|
|
13700
|
+
handleCommandError(err);
|
|
13701
|
+
}
|
|
13702
|
+
})
|
|
13703
|
+
);
|
|
13704
|
+
addCommonClientOptions(
|
|
13705
|
+
runs.command("events").description(getAgentCliCapabilityById("runs.events").description).argument("<runId>", "Run ID").action(async (runId, opts) => {
|
|
13706
|
+
try {
|
|
13707
|
+
const ctx = resolveCommandContext(opts);
|
|
13708
|
+
const rows = await ctx.api.get(`/api/run-intelligence/runs/${encodeURIComponent(runId)}/events`) ?? [];
|
|
13709
|
+
printOutput(ctx.json ? rows : rows.map(formatRunEvent), { json: ctx.json });
|
|
13710
|
+
} catch (err) {
|
|
13711
|
+
handleCommandError(err);
|
|
13712
|
+
}
|
|
13713
|
+
})
|
|
13714
|
+
);
|
|
13715
|
+
addCommonClientOptions(
|
|
13716
|
+
runs.command("log").description(getAgentCliCapabilityById("runs.log").description).argument("<runId>", "Run ID").option("--max-chars <n>", "Maximum log characters for human output", "12000").action(async (runId, opts) => {
|
|
13717
|
+
try {
|
|
13718
|
+
const ctx = resolveCommandContext(opts);
|
|
13719
|
+
const row = await ctx.api.get(`/api/run-intelligence/runs/${encodeURIComponent(runId)}/log`);
|
|
13720
|
+
if (ctx.json) {
|
|
13721
|
+
printOutput(row, { json: true });
|
|
13722
|
+
} else {
|
|
13723
|
+
process.stdout.write(clip2(row?.content ?? "", parseLimit2(opts.maxChars, 12e3)) + "\n");
|
|
13724
|
+
}
|
|
13725
|
+
} catch (err) {
|
|
13726
|
+
handleCommandError(err);
|
|
13727
|
+
}
|
|
13728
|
+
})
|
|
13729
|
+
);
|
|
13730
|
+
addCommonClientOptions(
|
|
13731
|
+
runs.command("transcript").description(getAgentCliCapabilityById("runs.transcript").description).argument("<runId>", "Run ID").option("--errors-only", "Show only error transcript rows").option("--around-error <id>", "Show context around a run error id such as step-12").option("--context-turns <n>", "Turns around --around-error", "1").option("--chronological", "Show oldest-first instead of default newest-first").option("--narrative", "Use a narrative human layout").option("--max-chars <n>", "Maximum output characters per row", "1200").action(async (runId, opts) => {
|
|
13732
|
+
try {
|
|
13733
|
+
const ctx = resolveCommandContext(opts);
|
|
13734
|
+
const payload = await ctx.api.get(
|
|
13735
|
+
`/api/run-intelligence/runs/${encodeURIComponent(runId)}/transcript?${buildTranscriptQuery(opts)}`
|
|
13736
|
+
);
|
|
13737
|
+
if (ctx.json) {
|
|
13738
|
+
printOutput(payload, { json: true });
|
|
13739
|
+
} else if (opts.narrative) {
|
|
13740
|
+
printOutput((payload?.rows ?? []).map(formatRunTranscriptNarrative), { json: false });
|
|
13741
|
+
} else {
|
|
13742
|
+
printOutput((payload?.rows ?? []).map(formatRunTranscriptRow), { json: false });
|
|
13743
|
+
}
|
|
13744
|
+
} catch (err) {
|
|
13745
|
+
handleCommandError(err);
|
|
13746
|
+
}
|
|
13747
|
+
})
|
|
13748
|
+
);
|
|
13749
|
+
addCommonClientOptions(
|
|
13750
|
+
runs.command("errors").description(getAgentCliCapabilityById("runs.errors").description).argument("<runId>", "Run ID").option("--max-chars <n>", "Maximum output characters per error", "1200").action(async (runId, opts) => {
|
|
13751
|
+
try {
|
|
13752
|
+
const ctx = resolveCommandContext(opts);
|
|
13753
|
+
const params = new URLSearchParams();
|
|
13754
|
+
params.set("maxChars", String(parseLimit2(opts.maxChars, 1200)));
|
|
13755
|
+
const payload = await ctx.api.get(
|
|
13756
|
+
`/api/run-intelligence/runs/${encodeURIComponent(runId)}/errors?${params.toString()}`
|
|
13757
|
+
);
|
|
13758
|
+
printOutput(ctx.json ? payload : (payload?.errors ?? []).map(formatRunError), { json: ctx.json });
|
|
13759
|
+
} catch (err) {
|
|
13760
|
+
handleCommandError(err);
|
|
13761
|
+
}
|
|
13762
|
+
})
|
|
13763
|
+
);
|
|
13764
|
+
addCommonClientOptions(
|
|
13765
|
+
runs.command("cancel").description(getAgentCliCapabilityById("runs.cancel").description).argument("<runId>", "Run ID").action(async (runId, opts) => {
|
|
13766
|
+
try {
|
|
13767
|
+
const ctx = resolveCommandContext(opts);
|
|
13768
|
+
const row = await ctx.api.post(`/api/heartbeat-runs/${encodeURIComponent(runId)}/cancel`, {});
|
|
13769
|
+
printOutput(row, { json: ctx.json });
|
|
13770
|
+
} catch (err) {
|
|
13771
|
+
handleCommandError(err);
|
|
13772
|
+
}
|
|
13773
|
+
})
|
|
13774
|
+
);
|
|
13775
|
+
addCommonClientOptions(
|
|
13776
|
+
runs.command("retry").description(getAgentCliCapabilityById("runs.retry").description).argument("<runId>", "Run ID").action(async (runId, opts) => {
|
|
13777
|
+
try {
|
|
13778
|
+
const ctx = resolveCommandContext(opts);
|
|
13779
|
+
const row = await ctx.api.post(`/api/heartbeat-runs/${encodeURIComponent(runId)}/retry`, {});
|
|
13780
|
+
printOutput(row, { json: ctx.json });
|
|
13781
|
+
} catch (err) {
|
|
13782
|
+
handleCommandError(err);
|
|
13783
|
+
}
|
|
13784
|
+
})
|
|
13785
|
+
);
|
|
13786
|
+
}
|
|
13787
|
+
function buildRunsListQuery(opts) {
|
|
13788
|
+
const params = new URLSearchParams();
|
|
13789
|
+
if (opts.updatedAfter) params.set("updatedAfter", opts.updatedAfter);
|
|
13790
|
+
if (opts.runIdPrefix) params.set("runIdPrefix", opts.runIdPrefix);
|
|
13791
|
+
if (opts.agentId) params.set("agentId", opts.agentId);
|
|
13792
|
+
if (opts.status) params.set("status", opts.status);
|
|
13793
|
+
if (opts.runtime) params.set("runtime", opts.runtime);
|
|
13794
|
+
if (opts.issueId) params.set("issueId", opts.issueId);
|
|
13795
|
+
if (opts.createdBefore) params.set("createdBefore", opts.createdBefore);
|
|
13796
|
+
if (opts.limit) params.set("limit", opts.limit);
|
|
13797
|
+
return params.toString();
|
|
13798
|
+
}
|
|
13799
|
+
function buildTranscriptQuery(opts) {
|
|
13800
|
+
const params = new URLSearchParams();
|
|
13801
|
+
if (opts.errorsOnly) params.set("errorsOnly", "true");
|
|
13802
|
+
if (opts.aroundError) params.set("aroundError", opts.aroundError);
|
|
13803
|
+
params.set("contextTurns", String(parseLimit2(opts.contextTurns, 1)));
|
|
13804
|
+
params.set("order", opts.chronological || opts.narrative ? "oldest" : "newest");
|
|
13805
|
+
params.set("maxChars", String(parseLimit2(opts.maxChars, 1200)));
|
|
13806
|
+
return params.toString();
|
|
13807
|
+
}
|
|
13808
|
+
function formatRunListRow(row) {
|
|
13809
|
+
return {
|
|
13810
|
+
id: row.run.id,
|
|
13811
|
+
status: row.run.status,
|
|
13812
|
+
agent: row.agentName ?? row.run.agentId,
|
|
13813
|
+
runtime: row.bundle.agentRuntimeType,
|
|
13814
|
+
issue: row.issue?.identifier ?? row.issue?.id ?? "-",
|
|
13815
|
+
updatedAt: row.run.updatedAt
|
|
13816
|
+
};
|
|
13817
|
+
}
|
|
13818
|
+
function formatRunEvent(row) {
|
|
13819
|
+
return {
|
|
13820
|
+
seq: row.seq,
|
|
13821
|
+
level: row.level,
|
|
13822
|
+
stream: row.stream,
|
|
13823
|
+
message: row.message,
|
|
13824
|
+
createdAt: row.createdAt
|
|
13825
|
+
};
|
|
13826
|
+
}
|
|
13827
|
+
function formatRunTranscriptRow(row) {
|
|
13828
|
+
return {
|
|
13829
|
+
id: row.id,
|
|
13830
|
+
turn: row.turnIndex ?? "-",
|
|
13831
|
+
kind: row.kind,
|
|
13832
|
+
ts: row.ts,
|
|
13833
|
+
error: row.isError ? "yes" : "no",
|
|
13834
|
+
preview: row.preview || row.detailPreview,
|
|
13835
|
+
output: row.output.text
|
|
13836
|
+
};
|
|
13837
|
+
}
|
|
13838
|
+
function formatRunTranscriptNarrative(row) {
|
|
13839
|
+
const marker = row.isError ? "ERROR " : "";
|
|
13840
|
+
return `${row.id} ${row.ts} ${marker}${row.kind}: ${row.preview || row.detailPreview}
|
|
13841
|
+
${row.output.text}`;
|
|
13842
|
+
}
|
|
13843
|
+
function formatRunError(row) {
|
|
13844
|
+
return {
|
|
13845
|
+
id: row.id,
|
|
13846
|
+
type: row.type,
|
|
13847
|
+
turn: row.turnIndex ?? "-",
|
|
13848
|
+
summary: row.summary,
|
|
13849
|
+
output: row.output.text,
|
|
13850
|
+
context: row.transcriptContext?.command ?? "-"
|
|
13851
|
+
};
|
|
13852
|
+
}
|
|
13853
|
+
function parseLimit2(value, fallback) {
|
|
13854
|
+
const parsed = Number(value ?? fallback);
|
|
13855
|
+
if (!Number.isFinite(parsed) || parsed <= 0) return fallback;
|
|
13856
|
+
return Math.floor(parsed);
|
|
13857
|
+
}
|
|
13858
|
+
function clip2(value, maxChars) {
|
|
13859
|
+
if (value.length <= maxChars) return value;
|
|
13860
|
+
return `${value.slice(0, Math.max(0, maxChars - 1))}\u2026`;
|
|
13861
|
+
}
|
|
13862
|
+
|
|
12920
13863
|
// src/config/data-dir.ts
|
|
12921
13864
|
init_home();
|
|
12922
13865
|
import path21 from "node:path";
|
|
@@ -13297,6 +14240,9 @@ function createProgram() {
|
|
|
13297
14240
|
registerDashboardCommands(program);
|
|
13298
14241
|
registerSkillCommands(program);
|
|
13299
14242
|
registerLibraryCommands(program);
|
|
14243
|
+
registerAutomationCommands(program);
|
|
14244
|
+
registerChatCommands(program);
|
|
14245
|
+
registerRunsCommands(program);
|
|
13300
14246
|
registerLazyWorktreeCommands(program);
|
|
13301
14247
|
registerPluginCommands(program);
|
|
13302
14248
|
registerLazyBenchmarkCommands(program);
|