bamboo-agents 0.1.5-dev.49.eaaa602 → 0.1.5-dev.51.78fa2ce
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/VERSION +1 -1
- package/dist/index.js +615 -151
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3037,7 +3037,7 @@ var VERSION;
|
|
|
3037
3037
|
var init_version = __esm({
|
|
3038
3038
|
"src/version.ts"() {
|
|
3039
3039
|
"use strict";
|
|
3040
|
-
VERSION = "0.1.5-dev.
|
|
3040
|
+
VERSION = "0.1.5-dev.51.78fa2ce";
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
@@ -7243,6 +7243,75 @@ var init_knowledge_slots = __esm({
|
|
|
7243
7243
|
}
|
|
7244
7244
|
});
|
|
7245
7245
|
|
|
7246
|
+
// ../../src/lib/api-contracts/cli/save.ts
|
|
7247
|
+
function isSafeRepoPath(path2) {
|
|
7248
|
+
if (!path2 || path2.length > 512) return false;
|
|
7249
|
+
if (path2.startsWith("/") || path2.startsWith("~")) return false;
|
|
7250
|
+
if (path2.includes("\\")) return false;
|
|
7251
|
+
for (let i = 0; i < path2.length; i++) {
|
|
7252
|
+
if (path2.charCodeAt(i) < 32) return false;
|
|
7253
|
+
}
|
|
7254
|
+
if (path2.split("/").includes("..")) return false;
|
|
7255
|
+
return true;
|
|
7256
|
+
}
|
|
7257
|
+
var SaveEditSchema, SaveBatchRequestSchema, SaveFileResultSchema, SaveBatchResponseSchema;
|
|
7258
|
+
var init_save = __esm({
|
|
7259
|
+
"../../src/lib/api-contracts/cli/save.ts"() {
|
|
7260
|
+
init_zod();
|
|
7261
|
+
SaveEditSchema = external_exports.object({
|
|
7262
|
+
/** Canonical repo path, e.g. `brands/acme/knowledge/competitors.md`. */
|
|
7263
|
+
path: external_exports.string().min(1).max(512),
|
|
7264
|
+
/** UTF-8 file content. Required unless `delete` is true. */
|
|
7265
|
+
content: external_exports.string().optional(),
|
|
7266
|
+
/** Emit as a git-level deletion instead of a content write. */
|
|
7267
|
+
delete: external_exports.boolean().optional()
|
|
7268
|
+
}).refine((e) => e.delete === true || typeof e.content === "string", {
|
|
7269
|
+
message: "content is required unless delete is true"
|
|
7270
|
+
}).refine((e) => isSafeRepoPath(e.path), {
|
|
7271
|
+
message: "unsafe path: no '..' traversal, absolute paths, backslashes, or control chars",
|
|
7272
|
+
path: ["path"]
|
|
7273
|
+
});
|
|
7274
|
+
SaveBatchRequestSchema = external_exports.object({
|
|
7275
|
+
/** The changed + deleted files the client found vs the last-synced state. */
|
|
7276
|
+
edits: external_exports.array(SaveEditSchema).min(1).max(200),
|
|
7277
|
+
/** Human-readable summary surfaced in the PR body / commit trailer. */
|
|
7278
|
+
intent: external_exports.string().max(500).optional(),
|
|
7279
|
+
/** BAM-2588: classify-only preview — return the would-be routing, write nothing. */
|
|
7280
|
+
dry_run: external_exports.boolean().optional()
|
|
7281
|
+
});
|
|
7282
|
+
SaveFileResultSchema = external_exports.object({
|
|
7283
|
+
path: external_exports.string(),
|
|
7284
|
+
/** `auto` = merged to main; `queued` = opened/appended a review PR. */
|
|
7285
|
+
routed: external_exports.enum(["auto", "queued"]),
|
|
7286
|
+
/** Present when a PR was opened (queued, or auto via the queue-PR path). */
|
|
7287
|
+
pr_url: external_exports.string().optional(),
|
|
7288
|
+
pr_number: external_exports.number().optional()
|
|
7289
|
+
});
|
|
7290
|
+
SaveBatchResponseSchema = external_exports.object({
|
|
7291
|
+
/**
|
|
7292
|
+
* Aggregate routing decision from `executeKnowledgeWrite` for the whole
|
|
7293
|
+
* batch (the core routes a batch as one unit). `auto` when every edit
|
|
7294
|
+
* auto-merged, `queued` otherwise.
|
|
7295
|
+
*/
|
|
7296
|
+
routed: external_exports.enum(["auto", "queued"]),
|
|
7297
|
+
classification: external_exports.enum(["self_only", "cross_scope", "forbidden"]),
|
|
7298
|
+
/** Per-file detail. One entry per accepted edit. */
|
|
7299
|
+
files: external_exports.array(SaveFileResultSchema),
|
|
7300
|
+
/** Count of files that landed live (auto-merged). */
|
|
7301
|
+
live_count: external_exports.number().int().nonnegative(),
|
|
7302
|
+
/** Count of files queued for review. */
|
|
7303
|
+
queued_count: external_exports.number().int().nonnegative(),
|
|
7304
|
+
/** Present when a PR was opened for the batch. */
|
|
7305
|
+
pr_url: external_exports.string().optional(),
|
|
7306
|
+
pr_number: external_exports.number().optional(),
|
|
7307
|
+
/** Present on a rejected/forbidden batch — short machine-friendly reason. */
|
|
7308
|
+
reason: external_exports.string().optional(),
|
|
7309
|
+
/** BAM-2588: true when this was a --dry-run preview (nothing was written). */
|
|
7310
|
+
dry_run: external_exports.boolean().optional()
|
|
7311
|
+
});
|
|
7312
|
+
}
|
|
7313
|
+
});
|
|
7314
|
+
|
|
7246
7315
|
// ../../src/lib/api-contracts/cli/knowledge-save.ts
|
|
7247
7316
|
var knowledge_save_exports = {};
|
|
7248
7317
|
__export(knowledge_save_exports, {
|
|
@@ -7253,6 +7322,7 @@ var KnowledgeSaveRequestSchema, KnowledgeSaveResponseSchema;
|
|
|
7253
7322
|
var init_knowledge_save = __esm({
|
|
7254
7323
|
"../../src/lib/api-contracts/cli/knowledge-save.ts"() {
|
|
7255
7324
|
init_zod();
|
|
7325
|
+
init_save();
|
|
7256
7326
|
KnowledgeSaveRequestSchema = external_exports.object({
|
|
7257
7327
|
/** Canonical repo path, e.g. `brands/acme/knowledge/competitors.md`. Derived by the caller from `knowledge slots`. */
|
|
7258
7328
|
path: external_exports.string().min(1).max(512),
|
|
@@ -7262,6 +7332,9 @@ var init_knowledge_save = __esm({
|
|
|
7262
7332
|
delete: external_exports.boolean().optional(),
|
|
7263
7333
|
/** Human-readable summary surfaced in the PR body / commit trailer. */
|
|
7264
7334
|
intent: external_exports.string().max(500).optional()
|
|
7335
|
+
}).refine((r) => isSafeRepoPath(r.path), {
|
|
7336
|
+
message: "unsafe path: no '..' traversal, absolute paths, backslashes, or control chars",
|
|
7337
|
+
path: ["path"]
|
|
7265
7338
|
});
|
|
7266
7339
|
KnowledgeSaveResponseSchema = external_exports.object({
|
|
7267
7340
|
/** Routing outcome from `executeKnowledgeWrite`. */
|
|
@@ -7301,6 +7374,153 @@ var init_onboarding_status = __esm({
|
|
|
7301
7374
|
}
|
|
7302
7375
|
});
|
|
7303
7376
|
|
|
7377
|
+
// ../../src/lib/api-contracts/cli/agents.ts
|
|
7378
|
+
var agents_exports = {};
|
|
7379
|
+
__export(agents_exports, {
|
|
7380
|
+
CliAgentDetailSchema: () => CliAgentDetailSchema,
|
|
7381
|
+
CliAgentGetResponseSchema: () => CliAgentGetResponseSchema,
|
|
7382
|
+
CliAgentLifecycleStateSchema: () => CliAgentLifecycleStateSchema,
|
|
7383
|
+
CliAgentPauseResponseSchema: () => CliAgentPauseResponseSchema,
|
|
7384
|
+
CliAgentPublishResponseSchema: () => CliAgentPublishResponseSchema,
|
|
7385
|
+
CliAgentRowSchema: () => CliAgentRowSchema,
|
|
7386
|
+
CliAgentsListResponseSchema: () => CliAgentsListResponseSchema,
|
|
7387
|
+
CliBrandRowSchema: () => CliBrandRowSchema,
|
|
7388
|
+
CliBrandsListResponseSchema: () => CliBrandsListResponseSchema,
|
|
7389
|
+
CliCreateAgentRequestSchema: () => CliCreateAgentRequestSchema,
|
|
7390
|
+
CliCreateAgentResponseSchema: () => CliCreateAgentResponseSchema,
|
|
7391
|
+
CliTierCapSchema: () => CliTierCapSchema,
|
|
7392
|
+
CliUploadAgentRequestSchema: () => CliUploadAgentRequestSchema,
|
|
7393
|
+
CliUploadAgentResponseSchema: () => CliUploadAgentResponseSchema,
|
|
7394
|
+
CreateFromCliRequestSchema: () => CreateFromCliRequestSchema,
|
|
7395
|
+
CreateFromCliResponseSchema: () => CreateFromCliResponseSchema,
|
|
7396
|
+
UPLOAD_MAX_BYTES: () => UPLOAD_MAX_BYTES,
|
|
7397
|
+
UploadClaudeMdRequestSchema: () => UploadClaudeMdRequestSchema,
|
|
7398
|
+
UploadClaudeMdResponseSchema: () => UploadClaudeMdResponseSchema
|
|
7399
|
+
});
|
|
7400
|
+
var SlugSchema, NameSchema, BrandIdSchema, CliAgentRowSchema, CliTierCapSchema, CliAgentsListResponseSchema, CliCreateAgentRequestSchema, CliAgentMutationResponseBase, CliCreateAgentResponseSchema, UPLOAD_MAX_BYTES, CliUploadAgentRequestSchema, CliUploadAgentResponseSchema, CliBrandRowSchema, CliBrandsListResponseSchema, CliAgentLifecycleStateSchema, CliAgentDetailSchema, CliAgentGetResponseSchema, CliAgentPauseResponseSchema, CliAgentPublishResponseSchema, CreateFromCliRequestSchema, CreateFromCliResponseSchema, UploadClaudeMdRequestSchema, UploadClaudeMdResponseSchema;
|
|
7401
|
+
var init_agents = __esm({
|
|
7402
|
+
"../../src/lib/api-contracts/cli/agents.ts"() {
|
|
7403
|
+
init_zod();
|
|
7404
|
+
SlugSchema = external_exports.string().min(1).max(63).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "slug must be lowercase kebab-case");
|
|
7405
|
+
NameSchema = external_exports.string().min(1).max(120);
|
|
7406
|
+
BrandIdSchema = external_exports.string().uuid();
|
|
7407
|
+
CliAgentRowSchema = external_exports.object({
|
|
7408
|
+
id: external_exports.string().uuid(),
|
|
7409
|
+
name: external_exports.string(),
|
|
7410
|
+
/** `false` = user-created (eligible for picker choices).
|
|
7411
|
+
* `true` = pre-installed (MAM etc.) — shown informational-only. */
|
|
7412
|
+
is_auto_installed: external_exports.boolean(),
|
|
7413
|
+
/** Canonical kebab-case identifier — last segment of `folder_path`
|
|
7414
|
+
* (`brands/<brand>/agents/<slug>`). `null` for legacy rows whose
|
|
7415
|
+
* `folder_path` is missing or malformed. */
|
|
7416
|
+
slug: external_exports.string().nullable(),
|
|
7417
|
+
/**
|
|
7418
|
+
* BAM-2593 lifecycle fields. OPTIONAL on purpose: the BAM-2243 picker
|
|
7419
|
+
* pre-dates them and doesn't need them, and keeping them optional makes
|
|
7420
|
+
* a new-CLI → old-server response (which omits them) still parse. The
|
|
7421
|
+
* BAM-2593 server always populates them; the `bamboo agents list`
|
|
7422
|
+
* renderer shows the state when present.
|
|
7423
|
+
*/
|
|
7424
|
+
status: external_exports.enum(["draft", "ready", "broken"]).optional(),
|
|
7425
|
+
/** ISO timestamp when paused, else null. */
|
|
7426
|
+
paused_at: external_exports.string().nullable().optional(),
|
|
7427
|
+
/** Lite derived state (active/paused/inactive) — see CliAgentLifecycleStateSchema. */
|
|
7428
|
+
state: external_exports.enum(["active", "paused", "inactive"]).optional()
|
|
7429
|
+
});
|
|
7430
|
+
CliTierCapSchema = external_exports.object({
|
|
7431
|
+
limit: external_exports.number().int(),
|
|
7432
|
+
current: external_exports.number().int().nonnegative(),
|
|
7433
|
+
/** Display name for the user's tier (e.g. "Self-Serve"). */
|
|
7434
|
+
tier_name: external_exports.string().nullable()
|
|
7435
|
+
});
|
|
7436
|
+
CliAgentsListResponseSchema = external_exports.object({
|
|
7437
|
+
agents: external_exports.array(CliAgentRowSchema),
|
|
7438
|
+
tier_cap: CliTierCapSchema
|
|
7439
|
+
});
|
|
7440
|
+
CliCreateAgentRequestSchema = external_exports.object({
|
|
7441
|
+
brand_id: BrandIdSchema,
|
|
7442
|
+
name: NameSchema,
|
|
7443
|
+
slug: SlugSchema.optional()
|
|
7444
|
+
});
|
|
7445
|
+
CliAgentMutationResponseBase = external_exports.object({
|
|
7446
|
+
agent_id: external_exports.string().uuid(),
|
|
7447
|
+
/** e.g. "brands/acme/agents/paid-ads" — workspace-repo-relative. */
|
|
7448
|
+
folder_path: external_exports.string().min(1),
|
|
7449
|
+
/**
|
|
7450
|
+
* Whether the write landed straight on `main` (solo workspaces) or
|
|
7451
|
+
* was routed through a queue PR (multi-user — pending admin review).
|
|
7452
|
+
*/
|
|
7453
|
+
write_status: external_exports.enum(["instant-merged", "queued-pr"]),
|
|
7454
|
+
/**
|
|
7455
|
+
* True iff the agent already existed (slug idempotency hit). When
|
|
7456
|
+
* true, `write_status` may be `"instant-merged"` even though no file
|
|
7457
|
+
* write happened this call — the existing folder is the answer.
|
|
7458
|
+
*/
|
|
7459
|
+
reused: external_exports.boolean()
|
|
7460
|
+
});
|
|
7461
|
+
CliCreateAgentResponseSchema = CliAgentMutationResponseBase;
|
|
7462
|
+
UPLOAD_MAX_BYTES = 256 * 1024;
|
|
7463
|
+
CliUploadAgentRequestSchema = external_exports.object({
|
|
7464
|
+
brand_id: BrandIdSchema,
|
|
7465
|
+
name: NameSchema,
|
|
7466
|
+
slug: SlugSchema.optional(),
|
|
7467
|
+
/** Server caps at 256 KB and validates UTF-8. */
|
|
7468
|
+
claude_md_content: external_exports.string().min(1)
|
|
7469
|
+
});
|
|
7470
|
+
CliUploadAgentResponseSchema = CliAgentMutationResponseBase;
|
|
7471
|
+
CliBrandRowSchema = external_exports.object({
|
|
7472
|
+
id: external_exports.string().uuid(),
|
|
7473
|
+
name: external_exports.string()
|
|
7474
|
+
});
|
|
7475
|
+
CliBrandsListResponseSchema = external_exports.object({
|
|
7476
|
+
brands: external_exports.array(CliBrandRowSchema)
|
|
7477
|
+
});
|
|
7478
|
+
CliAgentLifecycleStateSchema = external_exports.enum([
|
|
7479
|
+
"active",
|
|
7480
|
+
"paused",
|
|
7481
|
+
"inactive"
|
|
7482
|
+
]);
|
|
7483
|
+
CliAgentDetailSchema = external_exports.object({
|
|
7484
|
+
id: external_exports.string().uuid(),
|
|
7485
|
+
name: external_exports.string(),
|
|
7486
|
+
slug: external_exports.string().nullable(),
|
|
7487
|
+
status: external_exports.enum(["draft", "ready", "broken"]),
|
|
7488
|
+
paused_at: external_exports.string().nullable(),
|
|
7489
|
+
state: CliAgentLifecycleStateSchema,
|
|
7490
|
+
is_auto_installed: external_exports.boolean(),
|
|
7491
|
+
is_system: external_exports.boolean(),
|
|
7492
|
+
template_key: external_exports.string().nullable(),
|
|
7493
|
+
execution_runtime: external_exports.string().nullable(),
|
|
7494
|
+
folder_path: external_exports.string().nullable(),
|
|
7495
|
+
repo_url: external_exports.string().nullable(),
|
|
7496
|
+
description: external_exports.string().nullable(),
|
|
7497
|
+
created_at: external_exports.string().nullable(),
|
|
7498
|
+
/** Brand m:m links (agent_brands → brands). */
|
|
7499
|
+
brands: external_exports.array(CliBrandRowSchema)
|
|
7500
|
+
});
|
|
7501
|
+
CliAgentGetResponseSchema = external_exports.object({
|
|
7502
|
+
agent: CliAgentDetailSchema
|
|
7503
|
+
});
|
|
7504
|
+
CliAgentPauseResponseSchema = external_exports.object({
|
|
7505
|
+
agent: external_exports.object({
|
|
7506
|
+
id: external_exports.string().uuid(),
|
|
7507
|
+
status: external_exports.enum(["draft", "ready", "broken"]),
|
|
7508
|
+
paused_at: external_exports.string().nullable()
|
|
7509
|
+
})
|
|
7510
|
+
});
|
|
7511
|
+
CliAgentPublishResponseSchema = external_exports.object({
|
|
7512
|
+
agent_id: external_exports.string().uuid(),
|
|
7513
|
+
repo_url: external_exports.string().nullable().optional(),
|
|
7514
|
+
folder_path: external_exports.string().nullable().optional(),
|
|
7515
|
+
reused: external_exports.boolean().optional()
|
|
7516
|
+
});
|
|
7517
|
+
CreateFromCliRequestSchema = CliCreateAgentRequestSchema;
|
|
7518
|
+
CreateFromCliResponseSchema = CliCreateAgentResponseSchema;
|
|
7519
|
+
UploadClaudeMdRequestSchema = CliUploadAgentRequestSchema;
|
|
7520
|
+
UploadClaudeMdResponseSchema = CliUploadAgentResponseSchema;
|
|
7521
|
+
}
|
|
7522
|
+
});
|
|
7523
|
+
|
|
7304
7524
|
// src/lib/paths.ts
|
|
7305
7525
|
import { homedir } from "node:os";
|
|
7306
7526
|
import { join } from "node:path";
|
|
@@ -12064,128 +12284,6 @@ var init_onboarding_next_prompt = __esm({
|
|
|
12064
12284
|
}
|
|
12065
12285
|
});
|
|
12066
12286
|
|
|
12067
|
-
// ../../src/lib/api-contracts/cli/agents.ts
|
|
12068
|
-
var SlugSchema, NameSchema, BrandIdSchema, CliAgentRowSchema, CliTierCapSchema, CliAgentsListResponseSchema, CliCreateAgentRequestSchema, CliAgentMutationResponseBase, CliCreateAgentResponseSchema, UPLOAD_MAX_BYTES, CliUploadAgentRequestSchema, CliUploadAgentResponseSchema, CliBrandRowSchema, CliBrandsListResponseSchema;
|
|
12069
|
-
var init_agents = __esm({
|
|
12070
|
-
"../../src/lib/api-contracts/cli/agents.ts"() {
|
|
12071
|
-
init_zod();
|
|
12072
|
-
SlugSchema = external_exports.string().min(1).max(63).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "slug must be lowercase kebab-case");
|
|
12073
|
-
NameSchema = external_exports.string().min(1).max(120);
|
|
12074
|
-
BrandIdSchema = external_exports.string().uuid();
|
|
12075
|
-
CliAgentRowSchema = external_exports.object({
|
|
12076
|
-
id: external_exports.string().uuid(),
|
|
12077
|
-
name: external_exports.string(),
|
|
12078
|
-
/** `false` = user-created (eligible for picker choices).
|
|
12079
|
-
* `true` = pre-installed (MAM etc.) — shown informational-only. */
|
|
12080
|
-
is_auto_installed: external_exports.boolean(),
|
|
12081
|
-
/** Canonical kebab-case identifier — last segment of `folder_path`
|
|
12082
|
-
* (`brands/<brand>/agents/<slug>`). `null` for legacy rows whose
|
|
12083
|
-
* `folder_path` is missing or malformed. */
|
|
12084
|
-
slug: external_exports.string().nullable()
|
|
12085
|
-
});
|
|
12086
|
-
CliTierCapSchema = external_exports.object({
|
|
12087
|
-
limit: external_exports.number().int(),
|
|
12088
|
-
current: external_exports.number().int().nonnegative(),
|
|
12089
|
-
/** Display name for the user's tier (e.g. "Self-Serve"). */
|
|
12090
|
-
tier_name: external_exports.string().nullable()
|
|
12091
|
-
});
|
|
12092
|
-
CliAgentsListResponseSchema = external_exports.object({
|
|
12093
|
-
agents: external_exports.array(CliAgentRowSchema),
|
|
12094
|
-
tier_cap: CliTierCapSchema
|
|
12095
|
-
});
|
|
12096
|
-
CliCreateAgentRequestSchema = external_exports.object({
|
|
12097
|
-
brand_id: BrandIdSchema,
|
|
12098
|
-
name: NameSchema,
|
|
12099
|
-
slug: SlugSchema.optional()
|
|
12100
|
-
});
|
|
12101
|
-
CliAgentMutationResponseBase = external_exports.object({
|
|
12102
|
-
agent_id: external_exports.string().uuid(),
|
|
12103
|
-
/** e.g. "brands/acme/agents/paid-ads" — workspace-repo-relative. */
|
|
12104
|
-
folder_path: external_exports.string().min(1),
|
|
12105
|
-
/**
|
|
12106
|
-
* Whether the write landed straight on `main` (solo workspaces) or
|
|
12107
|
-
* was routed through a queue PR (multi-user — pending admin review).
|
|
12108
|
-
*/
|
|
12109
|
-
write_status: external_exports.enum(["instant-merged", "queued-pr"]),
|
|
12110
|
-
/**
|
|
12111
|
-
* True iff the agent already existed (slug idempotency hit). When
|
|
12112
|
-
* true, `write_status` may be `"instant-merged"` even though no file
|
|
12113
|
-
* write happened this call — the existing folder is the answer.
|
|
12114
|
-
*/
|
|
12115
|
-
reused: external_exports.boolean()
|
|
12116
|
-
});
|
|
12117
|
-
CliCreateAgentResponseSchema = CliAgentMutationResponseBase;
|
|
12118
|
-
UPLOAD_MAX_BYTES = 256 * 1024;
|
|
12119
|
-
CliUploadAgentRequestSchema = external_exports.object({
|
|
12120
|
-
brand_id: BrandIdSchema,
|
|
12121
|
-
name: NameSchema,
|
|
12122
|
-
slug: SlugSchema.optional(),
|
|
12123
|
-
/** Server caps at 256 KB and validates UTF-8. */
|
|
12124
|
-
claude_md_content: external_exports.string().min(1)
|
|
12125
|
-
});
|
|
12126
|
-
CliUploadAgentResponseSchema = CliAgentMutationResponseBase;
|
|
12127
|
-
CliBrandRowSchema = external_exports.object({
|
|
12128
|
-
id: external_exports.string().uuid(),
|
|
12129
|
-
name: external_exports.string()
|
|
12130
|
-
});
|
|
12131
|
-
CliBrandsListResponseSchema = external_exports.object({
|
|
12132
|
-
brands: external_exports.array(CliBrandRowSchema)
|
|
12133
|
-
});
|
|
12134
|
-
}
|
|
12135
|
-
});
|
|
12136
|
-
|
|
12137
|
-
// ../../src/lib/api-contracts/cli/save.ts
|
|
12138
|
-
var SaveEditSchema, SaveBatchRequestSchema, SaveFileResultSchema, SaveBatchResponseSchema;
|
|
12139
|
-
var init_save = __esm({
|
|
12140
|
-
"../../src/lib/api-contracts/cli/save.ts"() {
|
|
12141
|
-
init_zod();
|
|
12142
|
-
SaveEditSchema = external_exports.object({
|
|
12143
|
-
/** Canonical repo path, e.g. `brands/acme/knowledge/competitors.md`. */
|
|
12144
|
-
path: external_exports.string().min(1).max(512),
|
|
12145
|
-
/** UTF-8 file content. Required unless `delete` is true. */
|
|
12146
|
-
content: external_exports.string().optional(),
|
|
12147
|
-
/** Emit as a git-level deletion instead of a content write. */
|
|
12148
|
-
delete: external_exports.boolean().optional()
|
|
12149
|
-
}).refine((e) => e.delete === true || typeof e.content === "string", {
|
|
12150
|
-
message: "content is required unless delete is true"
|
|
12151
|
-
});
|
|
12152
|
-
SaveBatchRequestSchema = external_exports.object({
|
|
12153
|
-
/** The changed + deleted files the client found vs the last-synced state. */
|
|
12154
|
-
edits: external_exports.array(SaveEditSchema).min(1).max(200),
|
|
12155
|
-
/** Human-readable summary surfaced in the PR body / commit trailer. */
|
|
12156
|
-
intent: external_exports.string().max(500).optional()
|
|
12157
|
-
});
|
|
12158
|
-
SaveFileResultSchema = external_exports.object({
|
|
12159
|
-
path: external_exports.string(),
|
|
12160
|
-
/** `auto` = merged to main; `queued` = opened/appended a review PR. */
|
|
12161
|
-
routed: external_exports.enum(["auto", "queued"]),
|
|
12162
|
-
/** Present when a PR was opened (queued, or auto via the queue-PR path). */
|
|
12163
|
-
pr_url: external_exports.string().optional(),
|
|
12164
|
-
pr_number: external_exports.number().optional()
|
|
12165
|
-
});
|
|
12166
|
-
SaveBatchResponseSchema = external_exports.object({
|
|
12167
|
-
/**
|
|
12168
|
-
* Aggregate routing decision from `executeKnowledgeWrite` for the whole
|
|
12169
|
-
* batch (the core routes a batch as one unit). `auto` when every edit
|
|
12170
|
-
* auto-merged, `queued` otherwise.
|
|
12171
|
-
*/
|
|
12172
|
-
routed: external_exports.enum(["auto", "queued"]),
|
|
12173
|
-
classification: external_exports.enum(["self_only", "cross_scope", "forbidden"]),
|
|
12174
|
-
/** Per-file detail. One entry per accepted edit. */
|
|
12175
|
-
files: external_exports.array(SaveFileResultSchema),
|
|
12176
|
-
/** Count of files that landed live (auto-merged). */
|
|
12177
|
-
live_count: external_exports.number().int().nonnegative(),
|
|
12178
|
-
/** Count of files queued for review. */
|
|
12179
|
-
queued_count: external_exports.number().int().nonnegative(),
|
|
12180
|
-
/** Present when a PR was opened for the batch. */
|
|
12181
|
-
pr_url: external_exports.string().optional(),
|
|
12182
|
-
pr_number: external_exports.number().optional(),
|
|
12183
|
-
/** Present on a rejected/forbidden batch — short machine-friendly reason. */
|
|
12184
|
-
reason: external_exports.string().optional()
|
|
12185
|
-
});
|
|
12186
|
-
}
|
|
12187
|
-
});
|
|
12188
|
-
|
|
12189
12287
|
// ../../src/lib/api-contracts/cli/context-health.ts
|
|
12190
12288
|
var ScopeKindSchema, ScopeSchema, CriterionMetricsSchema, StatusSchema, CriterionContributionSchema, CriterionResultSchema, BucketScoresSchema, ResolvedScopeSchema, GapsSchema, HealthyResponseSchema, UnavailableResponseSchema, ContextHealthResponseSchema;
|
|
12191
12289
|
var init_context_health = __esm({
|
|
@@ -12499,6 +12597,41 @@ async function createAgentFromCli(bambooSession, body) {
|
|
|
12499
12597
|
const json = await res.json();
|
|
12500
12598
|
return CliCreateAgentResponseSchema.parse(json);
|
|
12501
12599
|
}
|
|
12600
|
+
async function getCliAgent(bambooSession, agentId) {
|
|
12601
|
+
const res = await cliApiFetch(
|
|
12602
|
+
`${apiBase()}/api/v1/cli/agents/${encodeURIComponent(agentId)}`,
|
|
12603
|
+
{ headers: { Authorization: `Bearer ${bambooSession}` } }
|
|
12604
|
+
);
|
|
12605
|
+
if (!res.ok) throw await parseError(res);
|
|
12606
|
+
return CliAgentGetResponseSchema.parse(await res.json());
|
|
12607
|
+
}
|
|
12608
|
+
async function pauseCliAgent(bambooSession, agentId) {
|
|
12609
|
+
const res = await cliApiFetch(
|
|
12610
|
+
`${apiBase()}/api/v1/agents/${encodeURIComponent(agentId)}/pause`,
|
|
12611
|
+
{ method: "POST", headers: { Authorization: `Bearer ${bambooSession}` } }
|
|
12612
|
+
);
|
|
12613
|
+
if (!res.ok) throw await parseError(res);
|
|
12614
|
+
const json = await res.json();
|
|
12615
|
+
return CliAgentPauseResponseSchema.parse(json.data);
|
|
12616
|
+
}
|
|
12617
|
+
async function unpauseCliAgent(bambooSession, agentId) {
|
|
12618
|
+
const res = await cliApiFetch(
|
|
12619
|
+
`${apiBase()}/api/v1/agents/${encodeURIComponent(agentId)}/unpause`,
|
|
12620
|
+
{ method: "POST", headers: { Authorization: `Bearer ${bambooSession}` } }
|
|
12621
|
+
);
|
|
12622
|
+
if (!res.ok) throw await parseError(res);
|
|
12623
|
+
const json = await res.json();
|
|
12624
|
+
return CliAgentPauseResponseSchema.parse(json.data);
|
|
12625
|
+
}
|
|
12626
|
+
async function publishCliAgent(bambooSession, agentId) {
|
|
12627
|
+
const res = await cliApiFetch(
|
|
12628
|
+
`${apiBase()}/api/v1/agents/${encodeURIComponent(agentId)}/provision`,
|
|
12629
|
+
{ method: "POST", headers: { Authorization: `Bearer ${bambooSession}` } }
|
|
12630
|
+
);
|
|
12631
|
+
if (!res.ok) throw await parseError(res);
|
|
12632
|
+
const json = await res.json();
|
|
12633
|
+
return CliAgentPublishResponseSchema.parse(json.data);
|
|
12634
|
+
}
|
|
12502
12635
|
async function getAgentSkills(bambooSession, agentId) {
|
|
12503
12636
|
const res = await cliApiFetch(
|
|
12504
12637
|
`${apiBase()}/api/v1/agents/${encodeURIComponent(agentId)}/skills`,
|
|
@@ -13599,14 +13732,14 @@ async function runCaseA(ctx) {
|
|
|
13599
13732
|
if (choice === null) return null;
|
|
13600
13733
|
return choice === "1" ? runCreateFlow(ctx) : runUploadFlow(ctx);
|
|
13601
13734
|
}
|
|
13602
|
-
async function runCaseB(ctx,
|
|
13735
|
+
async function runCaseB(ctx, agents2, healthByAgentId) {
|
|
13603
13736
|
console.log(
|
|
13604
|
-
` You have ${
|
|
13605
|
-
|
|
13737
|
+
` You have ${agents2.length} user-created ${pluralize(
|
|
13738
|
+
agents2.length,
|
|
13606
13739
|
"agent"
|
|
13607
13740
|
)} so far:`
|
|
13608
13741
|
);
|
|
13609
|
-
for (const a of
|
|
13742
|
+
for (const a of agents2) {
|
|
13610
13743
|
console.log(
|
|
13611
13744
|
` \u2022 ${a.name} \u2014 ${formatHealth(healthByAgentId.get(a.id) ?? null)}`
|
|
13612
13745
|
);
|
|
@@ -13617,21 +13750,21 @@ async function runCaseB(ctx, agents, healthByAgentId) {
|
|
|
13617
13750
|
console.log(" 1) Create another agent");
|
|
13618
13751
|
console.log(" 2) Upload an existing CLAUDE.md/AGENTS.md");
|
|
13619
13752
|
console.log(
|
|
13620
|
-
` 3) Improve ${
|
|
13753
|
+
` 3) Improve ${agents2.length === 1 ? `"${agents2[0].name}"` : "an existing agent"} (run health check + next question)`
|
|
13621
13754
|
);
|
|
13622
13755
|
console.log("");
|
|
13623
13756
|
const choice = await promptChoice(" Choose [1-3]: ", ["1", "2", "3"]);
|
|
13624
13757
|
if (choice === null) return null;
|
|
13625
13758
|
if (choice === "1") return runCreateFlow(ctx);
|
|
13626
13759
|
if (choice === "2") return runUploadFlow(ctx);
|
|
13627
|
-
return runImproveExistingFlow(
|
|
13760
|
+
return runImproveExistingFlow(agents2);
|
|
13628
13761
|
}
|
|
13629
|
-
async function runCaseC(
|
|
13762
|
+
async function runCaseC(agents2, healthByAgentId) {
|
|
13630
13763
|
console.log(
|
|
13631
|
-
` You're at your tier's agent cap (${
|
|
13764
|
+
` You're at your tier's agent cap (${agents2.length}/${agents2.length}). Pick one to improve:`
|
|
13632
13765
|
);
|
|
13633
13766
|
console.log("");
|
|
13634
|
-
|
|
13767
|
+
agents2.forEach((a, idx) => {
|
|
13635
13768
|
console.log(
|
|
13636
13769
|
` ${idx + 1}) ${a.name} \u2014 ${formatHealth(healthByAgentId.get(a.id) ?? null)}`
|
|
13637
13770
|
);
|
|
@@ -13639,17 +13772,17 @@ async function runCaseC(agents, healthByAgentId) {
|
|
|
13639
13772
|
console.log("");
|
|
13640
13773
|
console.log(` (To add more agents, upgrade your plan at ${BILLING_URL})`);
|
|
13641
13774
|
console.log("");
|
|
13642
|
-
return runImproveExistingFlow(
|
|
13775
|
+
return runImproveExistingFlow(agents2);
|
|
13643
13776
|
}
|
|
13644
|
-
async function runImproveExistingFlow(
|
|
13645
|
-
const validChoices =
|
|
13777
|
+
async function runImproveExistingFlow(agents2) {
|
|
13778
|
+
const validChoices = agents2.map((_, idx2) => String(idx2 + 1));
|
|
13646
13779
|
const choice = await promptChoice(
|
|
13647
|
-
` Choose [1-${
|
|
13780
|
+
` Choose [1-${agents2.length}]: `,
|
|
13648
13781
|
validChoices
|
|
13649
13782
|
);
|
|
13650
13783
|
if (choice === null) return null;
|
|
13651
13784
|
const idx = Number.parseInt(choice, 10) - 1;
|
|
13652
|
-
return
|
|
13785
|
+
return agents2[idx]?.id ?? null;
|
|
13653
13786
|
}
|
|
13654
13787
|
async function runCreateFlow(ctx) {
|
|
13655
13788
|
if (!ctx.credentials) return null;
|
|
@@ -14567,6 +14700,7 @@ async function requireSession(opts) {
|
|
|
14567
14700
|
}
|
|
14568
14701
|
async function runSave(intent, options = {}) {
|
|
14569
14702
|
const opts = options;
|
|
14703
|
+
const dryRun = options.dryRun ?? false;
|
|
14570
14704
|
let workspacePath;
|
|
14571
14705
|
try {
|
|
14572
14706
|
workspacePath = (await resolveWorkspace()).path;
|
|
@@ -14600,6 +14734,19 @@ async function runSave(intent, options = {}) {
|
|
|
14600
14734
|
return;
|
|
14601
14735
|
}
|
|
14602
14736
|
const { deletes, writes, skipped } = planBatchFromPorcelain(entries);
|
|
14737
|
+
const unsafePath = [...writes, ...deletes].find((p) => !isSafeRepoPath(p));
|
|
14738
|
+
if (unsafePath) {
|
|
14739
|
+
emitError(
|
|
14740
|
+
{
|
|
14741
|
+
code: "unsafe_path",
|
|
14742
|
+
message: `refusing to save an unsafe path: ${unsafePath}`,
|
|
14743
|
+
hint: "Paths must be repo-relative \u2014 no '..', absolute paths, backslashes, or control chars."
|
|
14744
|
+
},
|
|
14745
|
+
opts,
|
|
14746
|
+
1
|
|
14747
|
+
);
|
|
14748
|
+
return;
|
|
14749
|
+
}
|
|
14603
14750
|
if (deletes.length === 0 && writes.length === 0) {
|
|
14604
14751
|
const payload2 = {
|
|
14605
14752
|
saved: 0,
|
|
@@ -14648,7 +14795,8 @@ async function runSave(intent, options = {}) {
|
|
|
14648
14795
|
try {
|
|
14649
14796
|
result = await saveWorkspace(session, {
|
|
14650
14797
|
edits,
|
|
14651
|
-
intent: intent?.trim() || void 0
|
|
14798
|
+
intent: intent?.trim() || void 0,
|
|
14799
|
+
dry_run: dryRun || void 0
|
|
14652
14800
|
});
|
|
14653
14801
|
} catch (err) {
|
|
14654
14802
|
if (err instanceof ApiError && err.status === 403) {
|
|
@@ -14675,7 +14823,7 @@ async function runSave(intent, options = {}) {
|
|
|
14675
14823
|
);
|
|
14676
14824
|
return;
|
|
14677
14825
|
}
|
|
14678
|
-
const { checkout, remove } = reconcilePlan(result.files, deletes);
|
|
14826
|
+
const { checkout, remove } = dryRun ? { checkout: [], remove: [] } : reconcilePlan(result.files, deletes);
|
|
14679
14827
|
if (checkout.length > 0 || remove.length > 0) {
|
|
14680
14828
|
try {
|
|
14681
14829
|
const branch = await currentBranch(workspacePath);
|
|
@@ -14707,17 +14855,27 @@ async function runSave(intent, options = {}) {
|
|
|
14707
14855
|
queued,
|
|
14708
14856
|
skipped: skipped.length,
|
|
14709
14857
|
pr_url: result.pr_url ?? null,
|
|
14710
|
-
files: result.files
|
|
14858
|
+
files: result.files,
|
|
14859
|
+
dry_run: dryRun
|
|
14711
14860
|
};
|
|
14712
14861
|
emitSuccess(payload, opts, () => {
|
|
14713
14862
|
human("", opts);
|
|
14863
|
+
const verb = dryRun ? "would go live" : "live";
|
|
14864
|
+
const qverb = dryRun ? "would queue for review" : "queued for review";
|
|
14714
14865
|
const parts = [];
|
|
14715
|
-
if (live > 0) parts.push(`${live}
|
|
14716
|
-
if (queued > 0) parts.push(`${queued}
|
|
14866
|
+
if (live > 0) parts.push(`${live} ${verb}`);
|
|
14867
|
+
if (queued > 0) parts.push(`${queued} ${qverb}`);
|
|
14717
14868
|
const summary = parts.length > 0 ? ` \u2014 ${parts.join(", ")}` : "";
|
|
14718
|
-
|
|
14719
|
-
|
|
14720
|
-
|
|
14869
|
+
if (dryRun) {
|
|
14870
|
+
human(
|
|
14871
|
+
` Dry run: ${total} file${total === 1 ? "" : "s"}${summary}. Nothing written.`,
|
|
14872
|
+
opts
|
|
14873
|
+
);
|
|
14874
|
+
} else {
|
|
14875
|
+
human(` Saved ${total} file${total === 1 ? "" : "s"}${summary}.`, opts);
|
|
14876
|
+
if (queued > 0 && result.pr_url) {
|
|
14877
|
+
human(` Review: ${result.pr_url}`, opts);
|
|
14878
|
+
}
|
|
14721
14879
|
}
|
|
14722
14880
|
if (skipped.length > 0) {
|
|
14723
14881
|
human(
|
|
@@ -14733,6 +14891,7 @@ var init_save2 = __esm({
|
|
|
14733
14891
|
"src/commands/save.ts"() {
|
|
14734
14892
|
"use strict";
|
|
14735
14893
|
init_api();
|
|
14894
|
+
init_save();
|
|
14736
14895
|
init_credentials();
|
|
14737
14896
|
init_workspace();
|
|
14738
14897
|
init_output();
|
|
@@ -16016,16 +16175,16 @@ async function resolveAgent(bambooSession, identifier) {
|
|
|
16016
16175
|
if (byName) return { id: byName.id, name: byName.name };
|
|
16017
16176
|
return null;
|
|
16018
16177
|
}
|
|
16019
|
-
function printAgentNotFound(identifier,
|
|
16178
|
+
function printAgentNotFound(identifier, agents2) {
|
|
16020
16179
|
console.error(`bamboo-agents: agent not found: ${identifier}`);
|
|
16021
|
-
if (
|
|
16180
|
+
if (agents2.length === 0) {
|
|
16022
16181
|
console.error(
|
|
16023
16182
|
"No agents in this org yet. Run `bamboo-agents` to create one."
|
|
16024
16183
|
);
|
|
16025
16184
|
} else {
|
|
16026
16185
|
console.error("");
|
|
16027
16186
|
console.error("Available agents (slug \u2014 name):");
|
|
16028
|
-
for (const a of
|
|
16187
|
+
for (const a of agents2) {
|
|
16029
16188
|
const label = a.slug ?? `${a.id.slice(0, 8)} (no slug)`;
|
|
16030
16189
|
console.error(` ${label} \u2014 ${a.name}`);
|
|
16031
16190
|
}
|
|
@@ -16749,6 +16908,271 @@ var init_onboarding = __esm({
|
|
|
16749
16908
|
}
|
|
16750
16909
|
});
|
|
16751
16910
|
|
|
16911
|
+
// src/commands/agents.ts
|
|
16912
|
+
var agents_exports2 = {};
|
|
16913
|
+
__export(agents_exports2, {
|
|
16914
|
+
runAgentsActivate: () => runAgentsActivate,
|
|
16915
|
+
runAgentsGet: () => runAgentsGet,
|
|
16916
|
+
runAgentsList: () => runAgentsList,
|
|
16917
|
+
runAgentsPause: () => runAgentsPause,
|
|
16918
|
+
runAgentsProvision: () => runAgentsProvision
|
|
16919
|
+
});
|
|
16920
|
+
async function requireSession7(opts) {
|
|
16921
|
+
const creds = await readCredentials();
|
|
16922
|
+
if (!creds) {
|
|
16923
|
+
emitError(
|
|
16924
|
+
{
|
|
16925
|
+
code: "not_signed_in",
|
|
16926
|
+
message: "not signed in.",
|
|
16927
|
+
hint: "Run `bamboo-agents login` first."
|
|
16928
|
+
},
|
|
16929
|
+
opts,
|
|
16930
|
+
1
|
|
16931
|
+
);
|
|
16932
|
+
throw new Error("unreachable");
|
|
16933
|
+
}
|
|
16934
|
+
return creds.bamboo_session;
|
|
16935
|
+
}
|
|
16936
|
+
function padRight4(s, n) {
|
|
16937
|
+
return s.length >= n ? s : s + " ".repeat(n - s.length);
|
|
16938
|
+
}
|
|
16939
|
+
async function resolveAgentRef(session, rawRef, opts) {
|
|
16940
|
+
const ref = rawRef.trim();
|
|
16941
|
+
let list;
|
|
16942
|
+
try {
|
|
16943
|
+
list = await listCliAgents(session);
|
|
16944
|
+
} catch (err) {
|
|
16945
|
+
emitError(
|
|
16946
|
+
{
|
|
16947
|
+
code: "agents_list_failed",
|
|
16948
|
+
message: `couldn't resolve agent "${ref}": ${err.message}`
|
|
16949
|
+
},
|
|
16950
|
+
opts,
|
|
16951
|
+
1
|
|
16952
|
+
);
|
|
16953
|
+
throw new Error("unreachable");
|
|
16954
|
+
}
|
|
16955
|
+
const agents2 = list.agents;
|
|
16956
|
+
const exactId = agents2.find((a) => a.id === ref);
|
|
16957
|
+
if (exactId) return exactId;
|
|
16958
|
+
const lower = ref.toLowerCase();
|
|
16959
|
+
const matches = agents2.filter(
|
|
16960
|
+
(a) => a.slug !== null && a.slug === lower || a.name.toLowerCase() === lower || ref.length >= 8 && a.id.startsWith(ref)
|
|
16961
|
+
);
|
|
16962
|
+
if (matches.length === 1) return matches[0];
|
|
16963
|
+
if (matches.length === 0) {
|
|
16964
|
+
emitError(
|
|
16965
|
+
{
|
|
16966
|
+
code: "agent_not_found",
|
|
16967
|
+
message: `no agent matches "${ref}".`,
|
|
16968
|
+
hint: "Run `bamboo-agents agents list` to see ids, slugs, and names."
|
|
16969
|
+
},
|
|
16970
|
+
opts,
|
|
16971
|
+
1
|
|
16972
|
+
);
|
|
16973
|
+
throw new Error("unreachable");
|
|
16974
|
+
}
|
|
16975
|
+
emitError(
|
|
16976
|
+
{
|
|
16977
|
+
code: "agent_ambiguous",
|
|
16978
|
+
message: `"${ref}" matches ${matches.length} agents: ${matches.map((a) => a.slug ?? a.id.slice(0, 8)).join(", ")}.`,
|
|
16979
|
+
hint: "Use the full id (from `bamboo-agents agents list`)."
|
|
16980
|
+
},
|
|
16981
|
+
opts,
|
|
16982
|
+
1
|
|
16983
|
+
);
|
|
16984
|
+
throw new Error("unreachable");
|
|
16985
|
+
}
|
|
16986
|
+
function printList(data, opts) {
|
|
16987
|
+
if (data.agents.length === 0) {
|
|
16988
|
+
human(" No agents yet. Create one with `bamboo-agents agents provision <name> --brand <id>`.", opts);
|
|
16989
|
+
return;
|
|
16990
|
+
}
|
|
16991
|
+
const nameW = Math.max(4, ...data.agents.map((a) => a.name.length));
|
|
16992
|
+
const slugW = Math.max(4, ...data.agents.map((a) => (a.slug ?? "\u2014").length));
|
|
16993
|
+
for (const a of data.agents) {
|
|
16994
|
+
const kind = a.is_auto_installed ? "[pre-installed]" : "";
|
|
16995
|
+
const state = a.state ?? "\u2014";
|
|
16996
|
+
human(
|
|
16997
|
+
` ${padRight4(a.name, nameW)} ${padRight4(a.slug ?? "\u2014", slugW)} ${padRight4(state, 9)} ${a.id} ${kind}`,
|
|
16998
|
+
opts
|
|
16999
|
+
);
|
|
17000
|
+
}
|
|
17001
|
+
const cap = data.tier_cap;
|
|
17002
|
+
const capStr = cap.limit < 0 ? `${cap.current} agents` : `${cap.current}/${cap.limit} agents`;
|
|
17003
|
+
human(` ${capStr}${cap.tier_name ? ` \xB7 ${cap.tier_name}` : ""}.`, opts);
|
|
17004
|
+
}
|
|
17005
|
+
async function runAgentsList(options) {
|
|
17006
|
+
const opts = options;
|
|
17007
|
+
const session = await requireSession7(opts);
|
|
17008
|
+
let data;
|
|
17009
|
+
try {
|
|
17010
|
+
data = await listCliAgents(session);
|
|
17011
|
+
} catch (err) {
|
|
17012
|
+
emitError(
|
|
17013
|
+
{ code: "agents_list_failed", message: `couldn't list agents: ${err.message}` },
|
|
17014
|
+
opts,
|
|
17015
|
+
1
|
|
17016
|
+
);
|
|
17017
|
+
return;
|
|
17018
|
+
}
|
|
17019
|
+
emitSuccess(data, opts, (d) => printList(d, opts));
|
|
17020
|
+
}
|
|
17021
|
+
function printDetail(agent, opts) {
|
|
17022
|
+
human(` ${agent.name} (${agent.id})`, opts);
|
|
17023
|
+
human(` state: ${agent.state} (status=${agent.status}${agent.paused_at ? ", paused" : ""})`, opts);
|
|
17024
|
+
human(` slug: ${agent.slug ?? "\u2014"}`, opts);
|
|
17025
|
+
human(` runtime: ${agent.execution_runtime ?? "\u2014"}`, opts);
|
|
17026
|
+
human(` template: ${agent.template_key ?? "\u2014"}`, opts);
|
|
17027
|
+
human(` folder: ${agent.folder_path ?? "\u2014"}`, opts);
|
|
17028
|
+
const brands = agent.brands.map((b) => b.name).join(", ") || "\u2014";
|
|
17029
|
+
human(` brands: ${brands}`, opts);
|
|
17030
|
+
if (agent.is_auto_installed) human(" (pre-installed)", opts);
|
|
17031
|
+
}
|
|
17032
|
+
async function runAgentsGet(agentRef, options) {
|
|
17033
|
+
const opts = options;
|
|
17034
|
+
const session = await requireSession7(opts);
|
|
17035
|
+
const row = await resolveAgentRef(session, agentRef, opts);
|
|
17036
|
+
let agent;
|
|
17037
|
+
try {
|
|
17038
|
+
agent = (await getCliAgent(session, row.id)).agent;
|
|
17039
|
+
} catch (err) {
|
|
17040
|
+
emitError(
|
|
17041
|
+
{ code: "agent_get_failed", message: `couldn't load agent: ${err.message}` },
|
|
17042
|
+
opts,
|
|
17043
|
+
1
|
|
17044
|
+
);
|
|
17045
|
+
return;
|
|
17046
|
+
}
|
|
17047
|
+
emitSuccess(agent, opts, (a) => printDetail(a, opts));
|
|
17048
|
+
}
|
|
17049
|
+
async function resolveBrandId(session, explicit, opts) {
|
|
17050
|
+
if (explicit) return explicit;
|
|
17051
|
+
let brands;
|
|
17052
|
+
try {
|
|
17053
|
+
brands = (await listCliBrands(session)).brands;
|
|
17054
|
+
} catch (err) {
|
|
17055
|
+
emitError(
|
|
17056
|
+
{ code: "brands_list_failed", message: `couldn't list brands: ${err.message}` },
|
|
17057
|
+
opts,
|
|
17058
|
+
1
|
|
17059
|
+
);
|
|
17060
|
+
throw new Error("unreachable");
|
|
17061
|
+
}
|
|
17062
|
+
if (brands.length === 1) return brands[0].id;
|
|
17063
|
+
emitError(
|
|
17064
|
+
{
|
|
17065
|
+
code: "brand_required",
|
|
17066
|
+
message: brands.length === 0 ? "no brands found for your org \u2014 create a brand first." : `multiple brands \u2014 pass --brand <id>. Options: ${brands.map((b) => `${b.name} (${b.id})`).join(", ")}.`,
|
|
17067
|
+
hint: "Specify the brand the agent belongs to with --brand <id>."
|
|
17068
|
+
},
|
|
17069
|
+
opts,
|
|
17070
|
+
1
|
|
17071
|
+
);
|
|
17072
|
+
throw new Error("unreachable");
|
|
17073
|
+
}
|
|
17074
|
+
async function runAgentsProvision(name, options) {
|
|
17075
|
+
const opts = options;
|
|
17076
|
+
const session = await requireSession7(opts);
|
|
17077
|
+
const brandId = await resolveBrandId(session, options.brand, opts);
|
|
17078
|
+
let result;
|
|
17079
|
+
try {
|
|
17080
|
+
result = await createAgentFromCli(session, {
|
|
17081
|
+
brand_id: brandId,
|
|
17082
|
+
name,
|
|
17083
|
+
...options.slug ? { slug: options.slug } : {}
|
|
17084
|
+
});
|
|
17085
|
+
} catch (err) {
|
|
17086
|
+
emitError(
|
|
17087
|
+
{ code: "agent_provision_failed", message: `couldn't provision agent: ${err.message}` },
|
|
17088
|
+
opts,
|
|
17089
|
+
1
|
|
17090
|
+
);
|
|
17091
|
+
return;
|
|
17092
|
+
}
|
|
17093
|
+
emitSuccess(result, opts, (r) => {
|
|
17094
|
+
const verb = r.reused ? "Already exists" : "Provisioned";
|
|
17095
|
+
human(` ${verb}: ${name} (${r.agent_id})`, opts);
|
|
17096
|
+
human(` folder: ${r.folder_path} \xB7 ${r.write_status}`, opts);
|
|
17097
|
+
if (!r.reused) human(" Agent is active.", opts);
|
|
17098
|
+
});
|
|
17099
|
+
}
|
|
17100
|
+
async function runAgentsPause(agentRef, options) {
|
|
17101
|
+
const opts = options;
|
|
17102
|
+
const session = await requireSession7(opts);
|
|
17103
|
+
const row = await resolveAgentRef(session, agentRef, opts);
|
|
17104
|
+
try {
|
|
17105
|
+
const res = await pauseCliAgent(session, row.id);
|
|
17106
|
+
emitSuccess(res, opts, () => human(` Paused ${row.name} (${row.id}).`, opts));
|
|
17107
|
+
} catch (err) {
|
|
17108
|
+
emitError(
|
|
17109
|
+
{ code: "agent_pause_failed", message: `couldn't pause agent: ${err.message}` },
|
|
17110
|
+
opts,
|
|
17111
|
+
1
|
|
17112
|
+
);
|
|
17113
|
+
}
|
|
17114
|
+
}
|
|
17115
|
+
async function runAgentsActivate(agentRef, options) {
|
|
17116
|
+
const opts = options;
|
|
17117
|
+
const session = await requireSession7(opts);
|
|
17118
|
+
const row = await resolveAgentRef(session, agentRef, opts);
|
|
17119
|
+
let state = row.state;
|
|
17120
|
+
let status = row.status;
|
|
17121
|
+
if (state === void 0 || status === void 0) {
|
|
17122
|
+
try {
|
|
17123
|
+
const d = (await getCliAgent(session, row.id)).agent;
|
|
17124
|
+
state = d.state;
|
|
17125
|
+
status = d.status;
|
|
17126
|
+
} catch (err) {
|
|
17127
|
+
emitError(
|
|
17128
|
+
{ code: "agent_get_failed", message: `couldn't read agent state: ${err.message}` },
|
|
17129
|
+
opts,
|
|
17130
|
+
1
|
|
17131
|
+
);
|
|
17132
|
+
return;
|
|
17133
|
+
}
|
|
17134
|
+
}
|
|
17135
|
+
try {
|
|
17136
|
+
if (state === "paused") {
|
|
17137
|
+
const res = await unpauseCliAgent(session, row.id);
|
|
17138
|
+
emitSuccess(
|
|
17139
|
+
{ agent_id: row.id, action: "unpaused", agent: res.agent },
|
|
17140
|
+
opts,
|
|
17141
|
+
() => human(` Activated ${row.name} (${row.id}) \u2014 unpaused.`, opts)
|
|
17142
|
+
);
|
|
17143
|
+
return;
|
|
17144
|
+
}
|
|
17145
|
+
if (status !== "ready") {
|
|
17146
|
+
const res = await publishCliAgent(session, row.id);
|
|
17147
|
+
emitSuccess(
|
|
17148
|
+
{ agent_id: res.agent_id, action: "published" },
|
|
17149
|
+
opts,
|
|
17150
|
+
() => human(` Activated ${row.name} (${row.id}) \u2014 published.`, opts)
|
|
17151
|
+
);
|
|
17152
|
+
return;
|
|
17153
|
+
}
|
|
17154
|
+
emitSuccess(
|
|
17155
|
+
{ agent_id: row.id, action: "noop" },
|
|
17156
|
+
opts,
|
|
17157
|
+
() => human(` ${row.name} (${row.id}) is already active.`, opts)
|
|
17158
|
+
);
|
|
17159
|
+
} catch (err) {
|
|
17160
|
+
emitError(
|
|
17161
|
+
{ code: "agent_activate_failed", message: `couldn't activate agent: ${err.message}` },
|
|
17162
|
+
opts,
|
|
17163
|
+
1
|
|
17164
|
+
);
|
|
17165
|
+
}
|
|
17166
|
+
}
|
|
17167
|
+
var init_agents2 = __esm({
|
|
17168
|
+
"src/commands/agents.ts"() {
|
|
17169
|
+
"use strict";
|
|
17170
|
+
init_credentials();
|
|
17171
|
+
init_api();
|
|
17172
|
+
init_output();
|
|
17173
|
+
}
|
|
17174
|
+
});
|
|
17175
|
+
|
|
16752
17176
|
// node_modules/commander/esm.mjs
|
|
16753
17177
|
var import_index = __toESM(require_commander(), 1);
|
|
16754
17178
|
var {
|
|
@@ -16859,12 +17283,13 @@ function zodToJsonSchema(schema) {
|
|
|
16859
17283
|
async function loadOutputSchemas() {
|
|
16860
17284
|
const map = /* @__PURE__ */ new Map();
|
|
16861
17285
|
try {
|
|
16862
|
-
const [history, changes, knowledgeSlots, knowledgeSave, onboarding2] = await Promise.all([
|
|
17286
|
+
const [history, changes, knowledgeSlots, knowledgeSave, onboarding2, agents2] = await Promise.all([
|
|
16863
17287
|
Promise.resolve().then(() => (init_history(), history_exports)).catch(() => null),
|
|
16864
17288
|
Promise.resolve().then(() => (init_changes(), changes_exports)).catch(() => null),
|
|
16865
17289
|
Promise.resolve().then(() => (init_knowledge_slots(), knowledge_slots_exports)).catch(() => null),
|
|
16866
17290
|
Promise.resolve().then(() => (init_knowledge_save(), knowledge_save_exports)).catch(() => null),
|
|
16867
|
-
Promise.resolve().then(() => (init_onboarding_status(), onboarding_status_exports)).catch(() => null)
|
|
17291
|
+
Promise.resolve().then(() => (init_onboarding_status(), onboarding_status_exports)).catch(() => null),
|
|
17292
|
+
Promise.resolve().then(() => (init_agents(), agents_exports)).catch(() => null)
|
|
16868
17293
|
]);
|
|
16869
17294
|
if (history?.HistoryResponseSchema) {
|
|
16870
17295
|
const s = zodToJsonSchema(history.HistoryResponseSchema);
|
|
@@ -16886,6 +17311,22 @@ async function loadOutputSchemas() {
|
|
|
16886
17311
|
const s = zodToJsonSchema(onboarding2.OnboardingStatusResponseSchema);
|
|
16887
17312
|
if (s) map.set("onboarding status", s);
|
|
16888
17313
|
}
|
|
17314
|
+
if (agents2?.CliAgentsListResponseSchema) {
|
|
17315
|
+
const s = zodToJsonSchema(agents2.CliAgentsListResponseSchema);
|
|
17316
|
+
if (s) map.set("agents list", s);
|
|
17317
|
+
}
|
|
17318
|
+
if (agents2?.CliAgentDetailSchema) {
|
|
17319
|
+
const s = zodToJsonSchema(agents2.CliAgentDetailSchema);
|
|
17320
|
+
if (s) map.set("agents get", s);
|
|
17321
|
+
}
|
|
17322
|
+
if (agents2?.CliCreateAgentResponseSchema) {
|
|
17323
|
+
const s = zodToJsonSchema(agents2.CliCreateAgentResponseSchema);
|
|
17324
|
+
if (s) map.set("agents provision", s);
|
|
17325
|
+
}
|
|
17326
|
+
if (agents2?.CliAgentPauseResponseSchema) {
|
|
17327
|
+
const s = zodToJsonSchema(agents2.CliAgentPauseResponseSchema);
|
|
17328
|
+
if (s) map.set("agents pause", s);
|
|
17329
|
+
}
|
|
16889
17330
|
} catch {
|
|
16890
17331
|
}
|
|
16891
17332
|
return map;
|
|
@@ -16982,7 +17423,7 @@ program2.command("doctor").description("Verify your local setup is ready + heal
|
|
|
16982
17423
|
const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
|
|
16983
17424
|
await runDoctor2({ quiet: options.quiet, autoHeal: options.autoHeal });
|
|
16984
17425
|
});
|
|
16985
|
-
program2.command("save [intent]").description("Save your workspace changes (routed write \u2014 auto-merges or queues)").option("--no-sync", "Skip the auto-sync git pull on this command").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").action(
|
|
17426
|
+
program2.command("save [intent]").description("Save your workspace changes (routed write \u2014 auto-merges or queues)").option("--no-sync", "Skip the auto-sync git pull on this command").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--dry-run", "Show what would be saved (routed auto/queue) without writing").action(
|
|
16986
17427
|
async (intent, options) => {
|
|
16987
17428
|
const { runSave: runSave2 } = await Promise.resolve().then(() => (init_save2(), save_exports));
|
|
16988
17429
|
await runSave2(intent, options);
|
|
@@ -17051,6 +17492,29 @@ onboarding.command("status").description("Composite onboarding gate (activation
|
|
|
17051
17492
|
const { runOnboardingStatus: runOnboardingStatus2 } = await Promise.resolve().then(() => (init_onboarding(), onboarding_exports));
|
|
17052
17493
|
await runOnboardingStatus2(options);
|
|
17053
17494
|
});
|
|
17495
|
+
var agents = program2.command("agents").description("Manage agents \u2014 list, get, provision, activate, pause");
|
|
17496
|
+
agents.command("list").description("List agents with their lifecycle state").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (options) => {
|
|
17497
|
+
const { runAgentsList: runAgentsList2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
17498
|
+
await runAgentsList2(options);
|
|
17499
|
+
});
|
|
17500
|
+
agents.command("get <agent>").description("Show one agent's full config (accepts id, slug, or name)").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (agent, options) => {
|
|
17501
|
+
const { runAgentsGet: runAgentsGet2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
17502
|
+
await runAgentsGet2(agent, options);
|
|
17503
|
+
});
|
|
17504
|
+
agents.command("provision <name>").description("Create a new agent (immediately active)").option("--brand <id>", "Brand the agent belongs to (auto-picked if you have exactly one)").option("--slug <slug>", "Optional kebab-case slug (derived from name otherwise)").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
17505
|
+
async (name, options) => {
|
|
17506
|
+
const { runAgentsProvision: runAgentsProvision2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
17507
|
+
await runAgentsProvision2(name, options);
|
|
17508
|
+
}
|
|
17509
|
+
);
|
|
17510
|
+
agents.command("activate <agent>").description("Activate an agent \u2014 unpause it (or publish a draft). Admin-only.").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (agent, options) => {
|
|
17511
|
+
const { runAgentsActivate: runAgentsActivate2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
17512
|
+
await runAgentsActivate2(agent, options);
|
|
17513
|
+
});
|
|
17514
|
+
agents.command("pause <agent>").description("Pause an agent \u2014 stops its scheduled runs. Admin-only.").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (agent, options) => {
|
|
17515
|
+
const { runAgentsPause: runAgentsPause2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
17516
|
+
await runAgentsPause2(agent, options);
|
|
17517
|
+
});
|
|
17054
17518
|
(async () => {
|
|
17055
17519
|
const rawArgs = process.argv.slice(2);
|
|
17056
17520
|
const { operands } = program2.parseOptions(rawArgs);
|