bamboo-agents 0.1.16-dev.136.c3da754 → 0.1.16-dev.138.224efdb
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 +1915 -929
- package/dist/index.js.map +3 -3
- 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.16-dev.
|
|
3040
|
+
VERSION = "0.1.16-dev.138.224efdb";
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
@@ -7354,7 +7354,14 @@ var init_knowledge_save = __esm({
|
|
|
7354
7354
|
});
|
|
7355
7355
|
KnowledgeSaveResponseSchema = external_exports.object({
|
|
7356
7356
|
/** Routing outcome from `executeKnowledgeWrite`. */
|
|
7357
|
-
routed: external_exports.enum([
|
|
7357
|
+
routed: external_exports.enum([
|
|
7358
|
+
"auto",
|
|
7359
|
+
"queued",
|
|
7360
|
+
"submitted",
|
|
7361
|
+
"rejected",
|
|
7362
|
+
"noop",
|
|
7363
|
+
"conflict"
|
|
7364
|
+
]),
|
|
7358
7365
|
classification: external_exports.enum(["self_only", "cross_scope", "forbidden"]),
|
|
7359
7366
|
/** Present when a PR was opened (queued/submitted, or auto via queue-PR). */
|
|
7360
7367
|
pr_url: external_exports.string().optional(),
|
|
@@ -7503,7 +7510,9 @@ var init_agents = __esm({
|
|
|
7503
7510
|
brand_id: BrandIdSchema.optional()
|
|
7504
7511
|
}).refine(
|
|
7505
7512
|
(d) => d.name !== void 0 || d.description !== void 0 || d.template_key !== void 0 || d.brand_id !== void 0,
|
|
7506
|
-
{
|
|
7513
|
+
{
|
|
7514
|
+
message: "Provide at least one field to update (name, description, template_key, brand_id)"
|
|
7515
|
+
}
|
|
7507
7516
|
);
|
|
7508
7517
|
CliUpdateAgentResponseSchema = external_exports.object({
|
|
7509
7518
|
agent_id: external_exports.string().uuid(),
|
|
@@ -7624,7 +7633,9 @@ var init_eval_ab = __esm({
|
|
|
7624
7633
|
init_zod();
|
|
7625
7634
|
AB_RESULT_VIEW_PATH = "/app/evals";
|
|
7626
7635
|
EvalAbRequestSchema = external_exports.object({
|
|
7627
|
-
agent_id: external_exports.string().uuid().describe(
|
|
7636
|
+
agent_id: external_exports.string().uuid().describe(
|
|
7637
|
+
"The agent whose skill is under test. Must be in the caller's org."
|
|
7638
|
+
),
|
|
7628
7639
|
skill_name: external_exports.string().min(1).describe(
|
|
7629
7640
|
"kebab-case skill name, e.g. `liveitup-amazon-weekly`. Must resolve to an `owned` skill (tier=agent) \u2014 `shared` and `library` skills are not testable."
|
|
7630
7641
|
),
|
|
@@ -7798,22 +7809,25 @@ function emitError(err, opts, exitCode) {
|
|
|
7798
7809
|
writeStdout(JSON.stringify(envelope, null, 2));
|
|
7799
7810
|
} else if (!opts.quiet) {
|
|
7800
7811
|
writeStderr(`bamboo-agents: [${err.code}] ${err.message}`);
|
|
7801
|
-
|
|
7802
|
-
(finding) => finding !== null && typeof finding === "object" && typeof finding.path === "string" && (finding.line === null || typeof finding.line === "number") && typeof finding.message === "string" && typeof finding.fix === "string"
|
|
7803
|
-
) : [];
|
|
7804
|
-
for (const finding of findings) {
|
|
7805
|
-
const location = `${finding.path}${finding.line === null ? "" : `:${finding.line}`}`;
|
|
7806
|
-
writeStderr(` ${location} ${finding.message}`);
|
|
7807
|
-
writeStderr(` Fix: ${finding.fix}`);
|
|
7808
|
-
}
|
|
7809
|
-
if (findings.length === 0 && typeof err.details?.reason === "string")
|
|
7810
|
-
writeStderr(` Reason: ${err.details.reason}`);
|
|
7811
|
-
if (err.details?.read_back !== void 0)
|
|
7812
|
-
writeStderr(` Read-back: ${JSON.stringify(err.details.read_back)}`);
|
|
7813
|
-
if (err.hint) writeStderr(` ${err.hint}`);
|
|
7812
|
+
printErrorDetails(err);
|
|
7814
7813
|
}
|
|
7815
7814
|
if (exitCode !== void 0) process.exit(exitCode);
|
|
7816
7815
|
}
|
|
7816
|
+
function printErrorDetails(err) {
|
|
7817
|
+
const findings = Array.isArray(err.details?.findings) ? err.details.findings.filter(
|
|
7818
|
+
(finding) => finding !== null && typeof finding === "object" && typeof finding.path === "string" && (finding.line === null || typeof finding.line === "number") && typeof finding.message === "string" && typeof finding.fix === "string"
|
|
7819
|
+
) : [];
|
|
7820
|
+
for (const finding of findings) {
|
|
7821
|
+
const location = `${finding.path}${finding.line === null ? "" : `:${finding.line}`}`;
|
|
7822
|
+
writeStderr(` ${location} ${finding.message}`);
|
|
7823
|
+
writeStderr(` Fix: ${finding.fix}`);
|
|
7824
|
+
}
|
|
7825
|
+
if (findings.length === 0 && typeof err.details?.reason === "string")
|
|
7826
|
+
writeStderr(` Reason: ${err.details.reason}`);
|
|
7827
|
+
if (err.details?.read_back !== void 0)
|
|
7828
|
+
writeStderr(` Read-back: ${JSON.stringify(err.details.read_back)}`);
|
|
7829
|
+
if (err.hint) writeStderr(` ${err.hint}`);
|
|
7830
|
+
}
|
|
7817
7831
|
function human(line = "", opts = {}) {
|
|
7818
7832
|
if (opts.quiet) return;
|
|
7819
7833
|
writeStderr(line);
|
|
@@ -7917,7 +7931,14 @@ var init_credentials = __esm({
|
|
|
7917
7931
|
});
|
|
7918
7932
|
|
|
7919
7933
|
// src/lib/state.ts
|
|
7920
|
-
import {
|
|
7934
|
+
import {
|
|
7935
|
+
readFile as readFile2,
|
|
7936
|
+
writeFile as writeFile2,
|
|
7937
|
+
mkdir as mkdir2,
|
|
7938
|
+
chmod as chmod2,
|
|
7939
|
+
rename,
|
|
7940
|
+
unlink
|
|
7941
|
+
} from "node:fs/promises";
|
|
7921
7942
|
import { randomBytes } from "node:crypto";
|
|
7922
7943
|
async function readConfig() {
|
|
7923
7944
|
try {
|
|
@@ -8072,7 +8093,9 @@ import { execFile } from "node:child_process";
|
|
|
8072
8093
|
import { promisify } from "node:util";
|
|
8073
8094
|
async function gitVersion() {
|
|
8074
8095
|
try {
|
|
8075
|
-
const { stdout } = await execFileP("git", ["--version"], {
|
|
8096
|
+
const { stdout } = await execFileP("git", ["--version"], {
|
|
8097
|
+
encoding: "utf8"
|
|
8098
|
+
});
|
|
8076
8099
|
const m = stdout.match(/git version (\d+)\.(\d+)\.(\d+)/);
|
|
8077
8100
|
if (!m) return null;
|
|
8078
8101
|
return [Number(m[1]), Number(m[2]), Number(m[3])];
|
|
@@ -8092,14 +8115,17 @@ username=x-access-token
|
|
|
8092
8115
|
password=${token}
|
|
8093
8116
|
|
|
8094
8117
|
`;
|
|
8095
|
-
const child = execFile("git", ["credential", "approve"], {
|
|
8118
|
+
const child = execFile("git", ["credential", "approve"], {
|
|
8119
|
+
encoding: "utf8"
|
|
8120
|
+
});
|
|
8096
8121
|
const proc = child;
|
|
8097
8122
|
proc.stdin?.write(input);
|
|
8098
8123
|
proc.stdin?.end();
|
|
8099
8124
|
await new Promise((resolve3, reject) => {
|
|
8100
8125
|
proc.on("exit", (code) => {
|
|
8101
8126
|
if (code === 0) resolve3();
|
|
8102
|
-
else
|
|
8127
|
+
else
|
|
8128
|
+
reject(new GitError(`git credential approve exited with code ${code}`));
|
|
8103
8129
|
});
|
|
8104
8130
|
proc.on("error", reject);
|
|
8105
8131
|
});
|
|
@@ -8182,9 +8208,13 @@ async function gitPullFFOnly(repoPath) {
|
|
|
8182
8208
|
}
|
|
8183
8209
|
async function getGitConfig(key) {
|
|
8184
8210
|
try {
|
|
8185
|
-
const { stdout } = await execFileP(
|
|
8186
|
-
|
|
8187
|
-
|
|
8211
|
+
const { stdout } = await execFileP(
|
|
8212
|
+
"git",
|
|
8213
|
+
["config", "--global", "--get", key],
|
|
8214
|
+
{
|
|
8215
|
+
encoding: "utf8"
|
|
8216
|
+
}
|
|
8217
|
+
);
|
|
8188
8218
|
return stdout.trim() || null;
|
|
8189
8219
|
} catch (err) {
|
|
8190
8220
|
if (err.code === 1) return null;
|
|
@@ -12797,18 +12827,36 @@ var init_investigation_review = __esm({
|
|
|
12797
12827
|
"../../src/lib/api-contracts/cli/investigation-review.ts"() {
|
|
12798
12828
|
init_zod();
|
|
12799
12829
|
InvestigationReviewDecisionSchema = external_exports.object({
|
|
12800
|
-
operation: external_exports.enum([
|
|
12830
|
+
operation: external_exports.enum([
|
|
12831
|
+
"conclude_claim",
|
|
12832
|
+
"block_claim",
|
|
12833
|
+
"retire_claim",
|
|
12834
|
+
"close",
|
|
12835
|
+
"reopen",
|
|
12836
|
+
"retire"
|
|
12837
|
+
]),
|
|
12801
12838
|
conclusion: external_exports.enum(["supported", "partial", "contradicted", "insufficient_evidence"]).optional(),
|
|
12802
12839
|
verdict_tier: external_exports.enum(["eyeballed", "tested", "reviewed"]).optional(),
|
|
12803
12840
|
decision: external_exports.enum(["merge", "more_evidence", "drop"]).optional(),
|
|
12804
12841
|
next_action: external_exports.string().trim().min(1).max(5e3).optional()
|
|
12805
12842
|
}).superRefine((value, ctx) => {
|
|
12806
12843
|
if (value.operation === "conclude_claim" && (!value.conclusion || !value.verdict_tier))
|
|
12807
|
-
ctx.addIssue({
|
|
12844
|
+
ctx.addIssue({
|
|
12845
|
+
code: external_exports.ZodIssueCode.custom,
|
|
12846
|
+
message: "A conclusion and verdict tier are required."
|
|
12847
|
+
});
|
|
12808
12848
|
if (value.operation === "conclude_claim" && value.decision === "more_evidence" && !value.next_action)
|
|
12809
|
-
ctx.addIssue({
|
|
12849
|
+
ctx.addIssue({
|
|
12850
|
+
code: external_exports.ZodIssueCode.custom,
|
|
12851
|
+
path: ["next_action"],
|
|
12852
|
+
message: "More evidence requires a next action."
|
|
12853
|
+
});
|
|
12810
12854
|
if (value.operation === "block_claim" && !value.next_action)
|
|
12811
|
-
ctx.addIssue({
|
|
12855
|
+
ctx.addIssue({
|
|
12856
|
+
code: external_exports.ZodIssueCode.custom,
|
|
12857
|
+
path: ["next_action"],
|
|
12858
|
+
message: "A blocker requires the next action that can unblock it."
|
|
12859
|
+
});
|
|
12812
12860
|
});
|
|
12813
12861
|
}
|
|
12814
12862
|
});
|
|
@@ -13654,7 +13702,8 @@ var init_eval_management = __esm({
|
|
|
13654
13702
|
|
|
13655
13703
|
// ../../src/lib/api-contracts/cli/inbox-management.ts
|
|
13656
13704
|
function inboxSourceVersionsMatch(current, reviewed) {
|
|
13657
|
-
if (typeof current !== "string" || typeof reviewed !== "string")
|
|
13705
|
+
if (typeof current !== "string" || typeof reviewed !== "string")
|
|
13706
|
+
return current === reviewed;
|
|
13658
13707
|
const canonicalUtc = (value) => value.replace(/\+00:00$/i, "Z");
|
|
13659
13708
|
return canonicalUtc(current) === canonicalUtc(reviewed);
|
|
13660
13709
|
}
|
|
@@ -14339,7 +14388,15 @@ var init_inbox_management = __esm({
|
|
|
14339
14388
|
operation: "annotation.command",
|
|
14340
14389
|
description: "Apply one server-advertised annotation routing command",
|
|
14341
14390
|
inputs: {
|
|
14342
|
-
required: [
|
|
14391
|
+
required: [
|
|
14392
|
+
"task_id",
|
|
14393
|
+
"source_version",
|
|
14394
|
+
"command_id",
|
|
14395
|
+
"command",
|
|
14396
|
+
"approved",
|
|
14397
|
+
"approved_effect",
|
|
14398
|
+
"approved_reversible"
|
|
14399
|
+
],
|
|
14343
14400
|
optional: ["brand_id", "target_user_id", "reason"],
|
|
14344
14401
|
server_injected: {}
|
|
14345
14402
|
},
|
|
@@ -14353,7 +14410,15 @@ var init_inbox_management = __esm({
|
|
|
14353
14410
|
operation: "annotation.complete",
|
|
14354
14411
|
description: "Write approved rubric labels and complete one annotation task",
|
|
14355
14412
|
inputs: {
|
|
14356
|
-
required: [
|
|
14413
|
+
required: [
|
|
14414
|
+
"task_id",
|
|
14415
|
+
"source_version",
|
|
14416
|
+
"command_id",
|
|
14417
|
+
"labels",
|
|
14418
|
+
"approved",
|
|
14419
|
+
"approved_effect",
|
|
14420
|
+
"approved_reversible"
|
|
14421
|
+
],
|
|
14357
14422
|
optional: ["brand_id", "reason"],
|
|
14358
14423
|
server_injected: { source: "cli" }
|
|
14359
14424
|
},
|
|
@@ -14475,11 +14540,13 @@ var init_inbox_management = __esm({
|
|
|
14475
14540
|
related_cli_commands: external_exports.array(external_exports.string())
|
|
14476
14541
|
});
|
|
14477
14542
|
InboxOrganizationsResponseSchema = external_exports.object({
|
|
14478
|
-
orgs: external_exports.array(
|
|
14479
|
-
|
|
14480
|
-
|
|
14481
|
-
|
|
14482
|
-
|
|
14543
|
+
orgs: external_exports.array(
|
|
14544
|
+
external_exports.object({
|
|
14545
|
+
id: external_exports.string().uuid(),
|
|
14546
|
+
name: external_exports.string().min(1),
|
|
14547
|
+
status: external_exports.string()
|
|
14548
|
+
})
|
|
14549
|
+
)
|
|
14483
14550
|
});
|
|
14484
14551
|
InboxMembersResponseSchema = external_exports.object({
|
|
14485
14552
|
meta: EvalManagementScopeSchema,
|
|
@@ -14489,16 +14556,20 @@ var init_inbox_management = __esm({
|
|
|
14489
14556
|
brand_id: external_exports.null(),
|
|
14490
14557
|
brand_name: external_exports.null()
|
|
14491
14558
|
}),
|
|
14492
|
-
members: external_exports.array(
|
|
14493
|
-
|
|
14494
|
-
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
|
|
14498
|
-
|
|
14499
|
-
|
|
14500
|
-
|
|
14501
|
-
|
|
14559
|
+
members: external_exports.array(
|
|
14560
|
+
external_exports.object({
|
|
14561
|
+
user_id: external_exports.string().uuid(),
|
|
14562
|
+
display_name: external_exports.string().min(1),
|
|
14563
|
+
email: external_exports.string().email().nullable(),
|
|
14564
|
+
membership_role: external_exports.string().min(1),
|
|
14565
|
+
brand_roles: external_exports.array(
|
|
14566
|
+
external_exports.object({
|
|
14567
|
+
brand_id: external_exports.string().uuid(),
|
|
14568
|
+
role: external_exports.enum(["editor", "viewer"])
|
|
14569
|
+
})
|
|
14570
|
+
)
|
|
14571
|
+
})
|
|
14572
|
+
)
|
|
14502
14573
|
});
|
|
14503
14574
|
OpportunityDecisionInputBaseSchema = external_exports.object({
|
|
14504
14575
|
opportunity_id: external_exports.string().uuid(),
|
|
@@ -14792,10 +14863,21 @@ var init_inbox_management = __esm({
|
|
|
14792
14863
|
task_id: external_exports.string().uuid(),
|
|
14793
14864
|
brand_id: external_exports.string().uuid().optional(),
|
|
14794
14865
|
command_id: external_exports.string().min(1).max(200).optional(),
|
|
14795
|
-
command_operation: external_exports.enum([
|
|
14796
|
-
|
|
14797
|
-
|
|
14798
|
-
|
|
14866
|
+
command_operation: external_exports.enum([
|
|
14867
|
+
"claim",
|
|
14868
|
+
"assign",
|
|
14869
|
+
"reassign",
|
|
14870
|
+
"escalate",
|
|
14871
|
+
"recall",
|
|
14872
|
+
"dismiss",
|
|
14873
|
+
"complete"
|
|
14874
|
+
]).optional()
|
|
14875
|
+
}).refine(
|
|
14876
|
+
(value) => Boolean(value.command_id) === Boolean(value.command_operation),
|
|
14877
|
+
{
|
|
14878
|
+
message: "command_id and command_operation must be supplied together"
|
|
14879
|
+
}
|
|
14880
|
+
)
|
|
14799
14881
|
}),
|
|
14800
14882
|
external_exports.object({
|
|
14801
14883
|
operation: external_exports.literal("annotation.command"),
|
|
@@ -14804,7 +14886,14 @@ var init_inbox_management = __esm({
|
|
|
14804
14886
|
brand_id: external_exports.string().uuid().optional(),
|
|
14805
14887
|
source_version: external_exports.number().int().positive(),
|
|
14806
14888
|
command_id: external_exports.string().min(1).max(200),
|
|
14807
|
-
command: external_exports.enum([
|
|
14889
|
+
command: external_exports.enum([
|
|
14890
|
+
"claim",
|
|
14891
|
+
"assign",
|
|
14892
|
+
"reassign",
|
|
14893
|
+
"escalate",
|
|
14894
|
+
"recall",
|
|
14895
|
+
"dismiss"
|
|
14896
|
+
]),
|
|
14808
14897
|
target_user_id: external_exports.string().uuid().optional(),
|
|
14809
14898
|
reason: external_exports.string().trim().min(1).max(1e3).optional(),
|
|
14810
14899
|
approved: external_exports.literal(true),
|
|
@@ -14827,7 +14916,10 @@ var init_inbox_management = __esm({
|
|
|
14827
14916
|
dismiss: { effect: "dismiss_annotation_task", reversible: false }
|
|
14828
14917
|
}[value.command];
|
|
14829
14918
|
if (value.approved_effect !== expected.effect || value.approved_reversible !== expected.reversible) {
|
|
14830
|
-
ctx.addIssue({
|
|
14919
|
+
ctx.addIssue({
|
|
14920
|
+
code: external_exports.ZodIssueCode.custom,
|
|
14921
|
+
message: "approval fingerprint does not match the annotation command"
|
|
14922
|
+
});
|
|
14831
14923
|
}
|
|
14832
14924
|
})
|
|
14833
14925
|
}),
|
|
@@ -14838,12 +14930,14 @@ var init_inbox_management = __esm({
|
|
|
14838
14930
|
brand_id: external_exports.string().uuid().optional(),
|
|
14839
14931
|
source_version: external_exports.number().int().positive(),
|
|
14840
14932
|
command_id: external_exports.string().min(1).max(200),
|
|
14841
|
-
labels: external_exports.array(
|
|
14842
|
-
|
|
14843
|
-
|
|
14844
|
-
|
|
14845
|
-
|
|
14846
|
-
|
|
14933
|
+
labels: external_exports.array(
|
|
14934
|
+
external_exports.object({
|
|
14935
|
+
criterion_key: external_exports.string().min(1).max(120),
|
|
14936
|
+
verdict: external_exports.enum(["pass", "fail", "n/a"]),
|
|
14937
|
+
note: external_exports.string().max(4e3).optional(),
|
|
14938
|
+
provenance: external_exports.enum(["blind", "flip", "anchored_agree"]).optional()
|
|
14939
|
+
})
|
|
14940
|
+
).min(1),
|
|
14847
14941
|
reason: external_exports.string().trim().min(1).max(1e3).optional(),
|
|
14848
14942
|
approved: external_exports.literal(true),
|
|
14849
14943
|
approved_effect: external_exports.literal("write_annotation_labels_and_complete_task"),
|
|
@@ -14948,7 +15042,11 @@ var init_inbox_management = __esm({
|
|
|
14948
15042
|
state: external_exports.literal("unknown"),
|
|
14949
15043
|
command_id: external_exports.string(),
|
|
14950
15044
|
instruction: external_exports.literal("inspect_source_before_retry"),
|
|
14951
|
-
reason: external_exports.enum([
|
|
15045
|
+
reason: external_exports.enum([
|
|
15046
|
+
"read_back_unavailable",
|
|
15047
|
+
"postcondition_not_observed",
|
|
15048
|
+
"command_receipt_unavailable"
|
|
15049
|
+
]),
|
|
14952
15050
|
read_back: OpportunitySnapshotSchema.optional()
|
|
14953
15051
|
});
|
|
14954
15052
|
OpportunityCommandSchema = external_exports.union([
|
|
@@ -14984,7 +15082,11 @@ var init_inbox_management = __esm({
|
|
|
14984
15082
|
state: external_exports.literal("unknown"),
|
|
14985
15083
|
command_id: external_exports.string(),
|
|
14986
15084
|
instruction: external_exports.literal("inspect_source_before_retry"),
|
|
14987
|
-
reason: external_exports.enum([
|
|
15085
|
+
reason: external_exports.enum([
|
|
15086
|
+
"transport_failed",
|
|
15087
|
+
"read_back_unavailable",
|
|
15088
|
+
"postcondition_not_observed"
|
|
15089
|
+
]).optional(),
|
|
14988
15090
|
read_back: external_exports.unknown().optional()
|
|
14989
15091
|
});
|
|
14990
15092
|
AnnotationSnapshotSchema = external_exports.object({
|
|
@@ -15082,6 +15184,14 @@ var init_inbox_management = __esm({
|
|
|
15082
15184
|
replayed: external_exports.boolean(),
|
|
15083
15185
|
read_back: ChangeReadBackSchema
|
|
15084
15186
|
}),
|
|
15187
|
+
external_exports.object({
|
|
15188
|
+
merged: external_exports.literal(false),
|
|
15189
|
+
pending: external_exports.literal(true),
|
|
15190
|
+
pr_number: external_exports.number().int().positive(),
|
|
15191
|
+
sha: external_exports.string(),
|
|
15192
|
+
self_approved: external_exports.boolean(),
|
|
15193
|
+
replayed: external_exports.boolean()
|
|
15194
|
+
}),
|
|
15085
15195
|
UnknownMutationReceiptSchema
|
|
15086
15196
|
])
|
|
15087
15197
|
}),
|
|
@@ -15305,7 +15415,11 @@ var init_inbox_management = __esm({
|
|
|
15305
15415
|
meta: EvalManagementScopeSchema
|
|
15306
15416
|
});
|
|
15307
15417
|
InboxManagementHttpErrorSchema = external_exports.object({
|
|
15308
|
-
error: external_exports.object({
|
|
15418
|
+
error: external_exports.object({
|
|
15419
|
+
code: external_exports.string(),
|
|
15420
|
+
message: external_exports.string(),
|
|
15421
|
+
details: external_exports.unknown().optional()
|
|
15422
|
+
}),
|
|
15309
15423
|
meta: EvalManagementScopeSchema
|
|
15310
15424
|
});
|
|
15311
15425
|
}
|
|
@@ -15477,7 +15591,11 @@ var init_episodes = __esm({
|
|
|
15477
15591
|
NoPriorHistoryCiteSchema = external_exports.object({
|
|
15478
15592
|
kind: external_exports.literal("no-prior-history")
|
|
15479
15593
|
});
|
|
15480
|
-
CiteSchema = external_exports.union([
|
|
15594
|
+
CiteSchema = external_exports.union([
|
|
15595
|
+
KnowledgeCiteSchema,
|
|
15596
|
+
EpisodeCiteSchema,
|
|
15597
|
+
NoPriorHistoryCiteSchema
|
|
15598
|
+
]);
|
|
15481
15599
|
CitesArraySchema = external_exports.array(CiteSchema);
|
|
15482
15600
|
DecompositionPartSchema = external_exports.object({
|
|
15483
15601
|
/** What this part is, e.g. "Google Ads" or "Week of Jun 2". */
|
|
@@ -15541,11 +15659,26 @@ var init_episodes = __esm({
|
|
|
15541
15659
|
idempotency_key: external_exports.string().min(1).max(256).optional()
|
|
15542
15660
|
});
|
|
15543
15661
|
EpisodeInsertSchema = external_exports.discriminatedUnion("type", [
|
|
15544
|
-
EpisodeBaseFields.extend({
|
|
15545
|
-
|
|
15546
|
-
|
|
15547
|
-
|
|
15548
|
-
EpisodeBaseFields.extend({
|
|
15662
|
+
EpisodeBaseFields.extend({
|
|
15663
|
+
type: external_exports.literal("insight"),
|
|
15664
|
+
body: InsightBodySchema
|
|
15665
|
+
}),
|
|
15666
|
+
EpisodeBaseFields.extend({
|
|
15667
|
+
type: external_exports.literal("recommendation"),
|
|
15668
|
+
body: RecommendationBodySchema
|
|
15669
|
+
}),
|
|
15670
|
+
EpisodeBaseFields.extend({
|
|
15671
|
+
type: external_exports.literal("action"),
|
|
15672
|
+
body: ActionBodySchema
|
|
15673
|
+
}),
|
|
15674
|
+
EpisodeBaseFields.extend({
|
|
15675
|
+
type: external_exports.literal("outcome"),
|
|
15676
|
+
body: OutcomeBodySchema
|
|
15677
|
+
}),
|
|
15678
|
+
EpisodeBaseFields.extend({
|
|
15679
|
+
type: external_exports.literal("feedback"),
|
|
15680
|
+
body: FeedbackBodySchema
|
|
15681
|
+
})
|
|
15549
15682
|
]);
|
|
15550
15683
|
EpisodeRowSchema = EpisodeBaseFields.extend({
|
|
15551
15684
|
id: external_exports.string().uuid(),
|
|
@@ -15599,9 +15732,13 @@ var init_eval_baseline_promote = __esm({
|
|
|
15599
15732
|
"../../src/lib/api-contracts/cli/eval-baseline-promote.ts"() {
|
|
15600
15733
|
init_zod();
|
|
15601
15734
|
Reason = external_exports.string().trim().min(1).max(2e3).describe("Why this run is the reference now. Recorded on the row.");
|
|
15602
|
-
PrUrl = external_exports.string().url().optional().describe(
|
|
15735
|
+
PrUrl = external_exports.string().url().optional().describe(
|
|
15736
|
+
"The PR this decision was made on, recorded as the row's source_url."
|
|
15737
|
+
);
|
|
15603
15738
|
EvalBaselinePromoteRunSchema = external_exports.object({
|
|
15604
|
-
run_id: external_exports.string().uuid().describe(
|
|
15739
|
+
run_id: external_exports.string().uuid().describe(
|
|
15740
|
+
"A completed qrels run in the caller's org \u2014 the id the correctness gate printed."
|
|
15741
|
+
),
|
|
15605
15742
|
reason: Reason,
|
|
15606
15743
|
pr_url: PrUrl,
|
|
15607
15744
|
// A body that says `demote: true` but fails the demote shape must not fall
|
|
@@ -15612,7 +15749,9 @@ var init_eval_baseline_promote = __esm({
|
|
|
15612
15749
|
demote: external_exports.literal(true),
|
|
15613
15750
|
brand_id: external_exports.string().uuid(),
|
|
15614
15751
|
qrels_version: external_exports.string().min(1).describe("The key to empty: its current baseline is tombstoned."),
|
|
15615
|
-
question_set_kind: external_exports.enum(["qrels", "sync_brain"]).default("qrels").describe(
|
|
15752
|
+
question_set_kind: external_exports.enum(["qrels", "sync_brain"]).default("qrels").describe(
|
|
15753
|
+
"The baseline key to tombstone. Absent on an un-upgraded CLI, which means qrels."
|
|
15754
|
+
),
|
|
15616
15755
|
reason: Reason,
|
|
15617
15756
|
pr_url: PrUrl
|
|
15618
15757
|
});
|
|
@@ -15742,10 +15881,18 @@ async function listInboxMembers(session, orgId) {
|
|
|
15742
15881
|
try {
|
|
15743
15882
|
result = InboxMembersResponseSchema.parse(json.data);
|
|
15744
15883
|
} catch {
|
|
15745
|
-
throw new ApiError(
|
|
15884
|
+
throw new ApiError(
|
|
15885
|
+
"The Inbox member list response was malformed.",
|
|
15886
|
+
502,
|
|
15887
|
+
"malformed_response"
|
|
15888
|
+
);
|
|
15746
15889
|
}
|
|
15747
15890
|
if (result.meta.requested_org_id !== orgId || result.meta.effective_org_id !== orgId) {
|
|
15748
|
-
throw new ApiError(
|
|
15891
|
+
throw new ApiError(
|
|
15892
|
+
"The Inbox member list was returned for a different organization.",
|
|
15893
|
+
502,
|
|
15894
|
+
"organization_scope_mismatch"
|
|
15895
|
+
);
|
|
15749
15896
|
}
|
|
15750
15897
|
return result;
|
|
15751
15898
|
}
|
|
@@ -15770,7 +15917,10 @@ async function getCliOrganizationScope(session, orgId) {
|
|
|
15770
15917
|
expires_at: external_exports.string()
|
|
15771
15918
|
}).optional()
|
|
15772
15919
|
}).parse(json);
|
|
15773
|
-
return {
|
|
15920
|
+
return {
|
|
15921
|
+
...parsed.scope,
|
|
15922
|
+
...parsed.operator ? { operator: parsed.operator } : {}
|
|
15923
|
+
};
|
|
15774
15924
|
}
|
|
15775
15925
|
async function callInboxManagement(session, orgId, call) {
|
|
15776
15926
|
const res = await cliApiFetch(`${apiBase()}/api/v1/inbox/manage`, {
|
|
@@ -15848,12 +15998,14 @@ function warnIfOperatorKeyNearExpiry(response) {
|
|
|
15848
15998
|
const remainingMs = Date.parse(expiresAt) - Date.now();
|
|
15849
15999
|
if (!Number.isFinite(remainingMs) || remainingMs > 14 * 864e5) return;
|
|
15850
16000
|
operatorExpiryWarningEmitted = true;
|
|
15851
|
-
console.error(
|
|
15852
|
-
|
|
15853
|
-
|
|
15854
|
-
|
|
15855
|
-
|
|
15856
|
-
|
|
16001
|
+
console.error(
|
|
16002
|
+
JSON.stringify({
|
|
16003
|
+
warning: "operator_key_expiring",
|
|
16004
|
+
expires_at: expiresAt,
|
|
16005
|
+
days_remaining: Math.max(0, Math.ceil(remainingMs / 864e5)),
|
|
16006
|
+
action: "Ask an FDE to rotate this agent's organization operator key."
|
|
16007
|
+
})
|
|
16008
|
+
);
|
|
15857
16009
|
}
|
|
15858
16010
|
async function getGithubToken(bambooSession) {
|
|
15859
16011
|
const res = await cliApiFetch(`${apiBase()}/api/auth/github/token`, {
|
|
@@ -16395,7 +16547,7 @@ async function getEvalManagementOperations(bambooSession, orgId) {
|
|
|
16395
16547
|
throw malformedEvalManagementResponse();
|
|
16396
16548
|
}
|
|
16397
16549
|
}
|
|
16398
|
-
|
|
16550
|
+
function buildEvalManagementRequest(bambooSession, call, orgId) {
|
|
16399
16551
|
const binding = EVAL_MANAGEMENT_BINDINGS.find(
|
|
16400
16552
|
(candidate) => candidate.operation === call.operation
|
|
16401
16553
|
);
|
|
@@ -16412,6 +16564,9 @@ async function callEvalManagement(bambooSession, call, orgId) {
|
|
|
16412
16564
|
"unsupported_organization_scope"
|
|
16413
16565
|
);
|
|
16414
16566
|
}
|
|
16567
|
+
return assembleEvalManagementRequest(bambooSession, call, binding, orgId);
|
|
16568
|
+
}
|
|
16569
|
+
function prepareEvalManagementInput(call, path2) {
|
|
16415
16570
|
const help = EVAL_MANAGEMENT_INPUTS[call.operation];
|
|
16416
16571
|
const missing = help.required.filter(
|
|
16417
16572
|
(field) => call.input[field] === void 0 || call.input[field] === null || call.input[field] === ""
|
|
@@ -16435,7 +16590,6 @@ async function callEvalManagement(bambooSession, call, orgId) {
|
|
|
16435
16590
|
);
|
|
16436
16591
|
}
|
|
16437
16592
|
const input = { ...call.input };
|
|
16438
|
-
let path2 = binding.path;
|
|
16439
16593
|
if (path2.includes("{id}")) {
|
|
16440
16594
|
const id = input.id;
|
|
16441
16595
|
if (typeof id !== "string" || id.length === 0) {
|
|
@@ -16451,6 +16605,10 @@ async function callEvalManagement(bambooSession, call, orgId) {
|
|
|
16451
16605
|
for (const [field, value] of Object.entries(help.server_injected ?? {})) {
|
|
16452
16606
|
input[field] = value;
|
|
16453
16607
|
}
|
|
16608
|
+
return { input, path: path2 };
|
|
16609
|
+
}
|
|
16610
|
+
function assembleEvalManagementRequest(bambooSession, call, binding, orgId) {
|
|
16611
|
+
const { input, path: path2 } = prepareEvalManagementInput(call, binding.path);
|
|
16454
16612
|
let url = `${apiBase()}${path2}`;
|
|
16455
16613
|
const init = {
|
|
16456
16614
|
method: binding.method,
|
|
@@ -16470,7 +16628,14 @@ async function callEvalManagement(bambooSession, call, orgId) {
|
|
|
16470
16628
|
init.headers["Content-Type"] = "application/json";
|
|
16471
16629
|
init.body = JSON.stringify(input);
|
|
16472
16630
|
}
|
|
16473
|
-
|
|
16631
|
+
return { url, init, isMutation: binding.method !== "GET" };
|
|
16632
|
+
}
|
|
16633
|
+
async function callEvalManagement(bambooSession, call, orgId) {
|
|
16634
|
+
const { url, init, isMutation } = buildEvalManagementRequest(
|
|
16635
|
+
bambooSession,
|
|
16636
|
+
call,
|
|
16637
|
+
orgId
|
|
16638
|
+
);
|
|
16474
16639
|
let res;
|
|
16475
16640
|
try {
|
|
16476
16641
|
res = await cliApiFetch(url, init);
|
|
@@ -16491,23 +16656,29 @@ async function callEvalManagement(bambooSession, call, orgId) {
|
|
|
16491
16656
|
});
|
|
16492
16657
|
result.data = parseEvalManagementOperationData(call, result.data, orgId);
|
|
16493
16658
|
assertExplicitOrgReceipt(result.scope, orgId);
|
|
16494
|
-
if (isMutation)
|
|
16495
|
-
const expectedBrand = call.input.brand_id;
|
|
16496
|
-
const expectedAgent = call.input.agent_id;
|
|
16497
|
-
if (typeof expectedBrand === "string" && result.scope?.brand_id?.toLowerCase() !== expectedBrand.toLowerCase())
|
|
16498
|
-
throw new Error("eval_management_scope_mismatch:brand_id");
|
|
16499
|
-
if (typeof expectedAgent === "string" && result.scope?.agent_id?.toLowerCase() !== expectedAgent.toLowerCase())
|
|
16500
|
-
throw new Error("eval_management_scope_mismatch:agent_id");
|
|
16501
|
-
}
|
|
16659
|
+
if (isMutation) assertEvalMutationScope(call, result);
|
|
16502
16660
|
return result;
|
|
16503
16661
|
} catch (error) {
|
|
16504
16662
|
if (error instanceof ApiError) throw error;
|
|
16505
16663
|
throw malformedEvalManagementResponse();
|
|
16506
16664
|
}
|
|
16507
16665
|
}
|
|
16666
|
+
function assertEvalMutationScope(call, result) {
|
|
16667
|
+
const expectedBrand = call.input.brand_id;
|
|
16668
|
+
const expectedAgent = call.input.agent_id;
|
|
16669
|
+
if (typeof expectedBrand === "string" && result.scope?.brand_id?.toLowerCase() !== expectedBrand.toLowerCase())
|
|
16670
|
+
throw new Error("eval_management_scope_mismatch:brand_id");
|
|
16671
|
+
if (typeof expectedAgent === "string" && result.scope?.agent_id?.toLowerCase() !== expectedAgent.toLowerCase())
|
|
16672
|
+
throw new Error("eval_management_scope_mismatch:agent_id");
|
|
16673
|
+
}
|
|
16508
16674
|
function unknownEvalMutationOutcome(call, orgId) {
|
|
16509
16675
|
const operation = call.operation;
|
|
16510
|
-
|
|
16676
|
+
let recovery = "Read the scoped investigation and repository receipt before retrying.";
|
|
16677
|
+
if (operation === "investigation.create") {
|
|
16678
|
+
recovery = `Do not blindly retry. Reconcile the selected scope first with: bamboo-agents eval manage investigation.list${orgId ? ` --org ${orgId}` : ""} --input '${JSON.stringify({ brand_id: call.input.brand_id, agent_id: call.input.agent_id, search: call.input.title })}'`;
|
|
16679
|
+
} else if (operation === "case.create") {
|
|
16680
|
+
recovery = "Do not blindly retry: a repeat create refuses with case_exists if the first landed. Read the case path in the workspace repo (or eval_cases by source_path) before retrying.";
|
|
16681
|
+
}
|
|
16511
16682
|
return new ApiError(
|
|
16512
16683
|
`The ${operation} request received no HTTP response, so its outcome is unknown. ${recovery}`,
|
|
16513
16684
|
502,
|
|
@@ -16697,7 +16868,9 @@ async function handleMissingGithubToken(bambooSession) {
|
|
|
16697
16868
|
return null;
|
|
16698
16869
|
}
|
|
16699
16870
|
await open_default(relinkUrl);
|
|
16700
|
-
const spinner = ora(
|
|
16871
|
+
const spinner = ora(
|
|
16872
|
+
"Waiting for GitHub authorization in your browser\u2026"
|
|
16873
|
+
).start();
|
|
16701
16874
|
const start = Date.now();
|
|
16702
16875
|
while (Date.now() - start < TOKEN_POLL.timeoutMs) {
|
|
16703
16876
|
await sleep(TOKEN_POLL.intervalMs);
|
|
@@ -16729,51 +16902,55 @@ async function startCallbackServer(expectedState) {
|
|
|
16729
16902
|
resolveSession2 = resolve3;
|
|
16730
16903
|
rejectSession = reject;
|
|
16731
16904
|
});
|
|
16732
|
-
const server = createServer(
|
|
16733
|
-
|
|
16734
|
-
|
|
16735
|
-
|
|
16736
|
-
|
|
16737
|
-
|
|
16738
|
-
|
|
16739
|
-
|
|
16740
|
-
|
|
16741
|
-
|
|
16742
|
-
|
|
16743
|
-
|
|
16744
|
-
|
|
16745
|
-
}
|
|
16746
|
-
if (req.method !== "POST") {
|
|
16747
|
-
res.writeHead(405, { "Content-Type": "text/plain" });
|
|
16748
|
-
res.end("Method not allowed");
|
|
16749
|
-
return;
|
|
16750
|
-
}
|
|
16751
|
-
const chunks = [];
|
|
16752
|
-
req.on("data", (c) => chunks.push(c));
|
|
16753
|
-
req.on("end", () => {
|
|
16754
|
-
let body;
|
|
16755
|
-
try {
|
|
16756
|
-
body = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
16757
|
-
} catch {
|
|
16758
|
-
respondCors(400, { error: "invalid_json" });
|
|
16759
|
-
return;
|
|
16760
|
-
}
|
|
16761
|
-
if (typeof body.session !== "string" || typeof body.state !== "string") {
|
|
16762
|
-
respondCors(400, { error: "missing_fields" });
|
|
16905
|
+
const server = createServer(
|
|
16906
|
+
(req, res) => {
|
|
16907
|
+
const respondCors = (status, body) => {
|
|
16908
|
+
res.writeHead(status, {
|
|
16909
|
+
"Content-Type": "application/json",
|
|
16910
|
+
"Access-Control-Allow-Origin": "*",
|
|
16911
|
+
"Access-Control-Allow-Methods": "POST, OPTIONS",
|
|
16912
|
+
"Access-Control-Allow-Headers": "Content-Type"
|
|
16913
|
+
});
|
|
16914
|
+
res.end(JSON.stringify(body));
|
|
16915
|
+
};
|
|
16916
|
+
if (req.method === "OPTIONS") {
|
|
16917
|
+
respondCors(204, {});
|
|
16763
16918
|
return;
|
|
16764
16919
|
}
|
|
16765
|
-
if (
|
|
16766
|
-
|
|
16767
|
-
|
|
16768
|
-
);
|
|
16769
|
-
respondCors(400, { error: "state_mismatch" });
|
|
16920
|
+
if (req.method !== "POST") {
|
|
16921
|
+
res.writeHead(405, { "Content-Type": "text/plain" });
|
|
16922
|
+
res.end("Method not allowed");
|
|
16770
16923
|
return;
|
|
16771
16924
|
}
|
|
16772
|
-
|
|
16773
|
-
|
|
16774
|
-
|
|
16775
|
-
|
|
16776
|
-
|
|
16925
|
+
const chunks = [];
|
|
16926
|
+
req.on("data", (c) => chunks.push(c));
|
|
16927
|
+
req.on("end", () => {
|
|
16928
|
+
let body;
|
|
16929
|
+
try {
|
|
16930
|
+
body = JSON.parse(
|
|
16931
|
+
Buffer.concat(chunks).toString("utf8")
|
|
16932
|
+
);
|
|
16933
|
+
} catch {
|
|
16934
|
+
respondCors(400, { error: "invalid_json" });
|
|
16935
|
+
return;
|
|
16936
|
+
}
|
|
16937
|
+
if (typeof body.session !== "string" || typeof body.state !== "string") {
|
|
16938
|
+
respondCors(400, { error: "missing_fields" });
|
|
16939
|
+
return;
|
|
16940
|
+
}
|
|
16941
|
+
if (body.state !== expectedState) {
|
|
16942
|
+
console.warn(
|
|
16943
|
+
" (ignored a callback with a mismatched state token \u2014 keep the browser tab open)"
|
|
16944
|
+
);
|
|
16945
|
+
respondCors(400, { error: "state_mismatch" });
|
|
16946
|
+
return;
|
|
16947
|
+
}
|
|
16948
|
+
respondCors(200, { ok: true });
|
|
16949
|
+
resolveSession2(body.session);
|
|
16950
|
+
setTimeout(() => server.close(), 100);
|
|
16951
|
+
});
|
|
16952
|
+
}
|
|
16953
|
+
);
|
|
16777
16954
|
server.on("error", rejectSession);
|
|
16778
16955
|
const timer = setTimeout(() => {
|
|
16779
16956
|
rejectSession(
|
|
@@ -16859,6 +17036,7 @@ async function runLoginWithToken(bambooSession) {
|
|
|
16859
17036
|
console.error("");
|
|
16860
17037
|
process.exit(1);
|
|
16861
17038
|
}
|
|
17039
|
+
// Falls through only when a test replaces process.exit with a returning mock.
|
|
16862
17040
|
case "network_error": {
|
|
16863
17041
|
console.error("");
|
|
16864
17042
|
console.error(` Network error: ${result.message}`);
|
|
@@ -16952,7 +17130,9 @@ async function runLogin() {
|
|
|
16952
17130
|
spinner.succeed("Bamboo session captured");
|
|
16953
17131
|
try {
|
|
16954
17132
|
const status = await getCliAuthStatus(bambooSession);
|
|
16955
|
-
if (status.memberships.length > 0 && status.pending_invites.length === 0 && status.memberships.every(
|
|
17133
|
+
if (status.memberships.length > 0 && status.pending_invites.length === 0 && status.memberships.every(
|
|
17134
|
+
(membership) => membership.org.workspace_managed === true
|
|
17135
|
+
)) {
|
|
16956
17136
|
await finishLogin(bambooSession, null, { managedWorkspace: true });
|
|
16957
17137
|
return;
|
|
16958
17138
|
}
|
|
@@ -17042,7 +17222,9 @@ async function promptStdin(question, opts = {}) {
|
|
|
17042
17222
|
if (trimmed.length > 0) return trimmed;
|
|
17043
17223
|
attempts += 1;
|
|
17044
17224
|
if (attempts > maxRetries || !isInteractive2) return null;
|
|
17045
|
-
console.log(
|
|
17225
|
+
console.log(
|
|
17226
|
+
" (Press Enter without typing to skip \u2014 or answer Boo's question.)"
|
|
17227
|
+
);
|
|
17046
17228
|
}
|
|
17047
17229
|
return null;
|
|
17048
17230
|
} finally {
|
|
@@ -17154,6 +17336,14 @@ async function runInit(options = {}) {
|
|
|
17154
17336
|
console.error("No credentials found. Run `bamboo-agents login` first.");
|
|
17155
17337
|
process.exit(2);
|
|
17156
17338
|
}
|
|
17339
|
+
const status = await loadInitStatus(creds);
|
|
17340
|
+
assertInitMembership(status);
|
|
17341
|
+
const membership = await resolveInitMembership(creds, status.memberships[0]);
|
|
17342
|
+
await checkInitGit();
|
|
17343
|
+
await installInitCredential(creds);
|
|
17344
|
+
await initializeWorkspacePath(membership, options);
|
|
17345
|
+
}
|
|
17346
|
+
async function loadInitStatus(creds) {
|
|
17157
17347
|
const statusSpinner = ora("Looking up your Bamboo orgs\u2026").start();
|
|
17158
17348
|
let status;
|
|
17159
17349
|
try {
|
|
@@ -17166,6 +17356,9 @@ async function runInit(options = {}) {
|
|
|
17166
17356
|
process.exit(1);
|
|
17167
17357
|
}
|
|
17168
17358
|
statusSpinner.stop();
|
|
17359
|
+
return status;
|
|
17360
|
+
}
|
|
17361
|
+
function assertInitMembership(status) {
|
|
17169
17362
|
if (status.pending_invites.length > 0 && status.memberships.length === 0) {
|
|
17170
17363
|
const invite = status.pending_invites[0];
|
|
17171
17364
|
console.error(
|
|
@@ -17183,10 +17376,13 @@ async function runInit(options = {}) {
|
|
|
17183
17376
|
console.error(
|
|
17184
17377
|
`You're in ${status.memberships.length} orgs \u2014 multi-org init isn't supported yet (BAM-773 follow-up).`
|
|
17185
17378
|
);
|
|
17186
|
-
console.error(
|
|
17379
|
+
console.error(
|
|
17380
|
+
`Orgs: ${status.memberships.map((m) => m.org.name).join(", ")}`
|
|
17381
|
+
);
|
|
17187
17382
|
process.exit(2);
|
|
17188
17383
|
}
|
|
17189
|
-
|
|
17384
|
+
}
|
|
17385
|
+
async function resolveInitMembership(creds, initialMembership) {
|
|
17190
17386
|
let membership;
|
|
17191
17387
|
if (initialMembership.workspace_ready && initialMembership.org.workspace_repo) {
|
|
17192
17388
|
membership = initialMembership;
|
|
@@ -17220,7 +17416,10 @@ async function runInit(options = {}) {
|
|
|
17220
17416
|
const pollSpinner = ora(
|
|
17221
17417
|
`Waiting for ${initialMembership.org.name}'s workspace to be ready\u2026`
|
|
17222
17418
|
).start();
|
|
17223
|
-
const result = await pollForWorkspaceReady(
|
|
17419
|
+
const result = await pollForWorkspaceReady(
|
|
17420
|
+
creds.bamboo_session,
|
|
17421
|
+
initialMembership
|
|
17422
|
+
);
|
|
17224
17423
|
if (!result.ok) {
|
|
17225
17424
|
if (result.reason === "session_expired") {
|
|
17226
17425
|
pollSpinner.fail(
|
|
@@ -17236,10 +17435,15 @@ async function runInit(options = {}) {
|
|
|
17236
17435
|
membership = result.membership;
|
|
17237
17436
|
pollSpinner.succeed(`Workspace ready: ${membership.org.workspace_repo}`);
|
|
17238
17437
|
}
|
|
17438
|
+
return membership;
|
|
17439
|
+
}
|
|
17440
|
+
async function checkInitGit() {
|
|
17239
17441
|
const gitSpinner = ora("Checking git\u2026").start();
|
|
17240
17442
|
const version = await gitVersion();
|
|
17241
17443
|
if (!version) {
|
|
17242
|
-
gitSpinner.fail(
|
|
17444
|
+
gitSpinner.fail(
|
|
17445
|
+
"git isn't installed or isn't on PATH. Install git, then re-run."
|
|
17446
|
+
);
|
|
17243
17447
|
process.exit(1);
|
|
17244
17448
|
}
|
|
17245
17449
|
if (!isGitRecentEnough(version)) {
|
|
@@ -17259,13 +17463,17 @@ async function runInit(options = {}) {
|
|
|
17259
17463
|
process.exit(1);
|
|
17260
17464
|
}
|
|
17261
17465
|
gitSpinner.succeed(`git ${version.join(".")} ready (${gitEmail})`);
|
|
17466
|
+
}
|
|
17467
|
+
async function installInitCredential(creds) {
|
|
17262
17468
|
if (creds.github_token) {
|
|
17263
17469
|
const credSpinner = ora("Installing GitHub credential into git\u2026").start();
|
|
17264
17470
|
try {
|
|
17265
17471
|
await installGithubCredential(creds.github_token);
|
|
17266
17472
|
credSpinner.succeed("GitHub credential installed");
|
|
17267
17473
|
} catch (err) {
|
|
17268
|
-
credSpinner.fail(
|
|
17474
|
+
credSpinner.fail(
|
|
17475
|
+
`Couldn't install git credential: ${err.message}`
|
|
17476
|
+
);
|
|
17269
17477
|
process.exit(1);
|
|
17270
17478
|
}
|
|
17271
17479
|
} else {
|
|
@@ -17273,6 +17481,8 @@ async function runInit(options = {}) {
|
|
|
17273
17481
|
" Skipping git credential install \u2014 credentials are headless (no GitHub token)."
|
|
17274
17482
|
);
|
|
17275
17483
|
}
|
|
17484
|
+
}
|
|
17485
|
+
async function initializeWorkspacePath(membership, options) {
|
|
17276
17486
|
const orgSlug = slugify(membership.org.name);
|
|
17277
17487
|
const canonicalPath = defaultClonePath(orgSlug);
|
|
17278
17488
|
let existingState;
|
|
@@ -17299,38 +17509,48 @@ async function runInit(options = {}) {
|
|
|
17299
17509
|
await rm(targetPath, { recursive: true, force: true });
|
|
17300
17510
|
resetSpinner.succeed(`Removed ${targetPath}`);
|
|
17301
17511
|
} catch (err) {
|
|
17302
|
-
resetSpinner.fail(
|
|
17512
|
+
resetSpinner.fail(
|
|
17513
|
+
`Couldn't remove ${targetPath}: ${err.message}`
|
|
17514
|
+
);
|
|
17303
17515
|
process.exit(1);
|
|
17304
17516
|
}
|
|
17305
17517
|
await cloneAndPersist(targetPath, membership);
|
|
17306
17518
|
return;
|
|
17307
17519
|
}
|
|
17308
17520
|
if (existingState) {
|
|
17309
|
-
|
|
17310
|
-
|
|
17311
|
-
|
|
17312
|
-
|
|
17313
|
-
|
|
17521
|
+
await initializeRecordedWorkspace(existingState, membership);
|
|
17522
|
+
return;
|
|
17523
|
+
}
|
|
17524
|
+
await initializeCanonicalWorkspace(canonicalPath, orgSlug, membership);
|
|
17525
|
+
}
|
|
17526
|
+
async function initializeRecordedWorkspace(existingState, membership) {
|
|
17527
|
+
let dirExists = false;
|
|
17528
|
+
try {
|
|
17529
|
+
await access(existingState.workspace_path);
|
|
17530
|
+
dirExists = true;
|
|
17531
|
+
} catch {
|
|
17532
|
+
}
|
|
17533
|
+
if (dirExists) {
|
|
17534
|
+
const existingRemote = await getRepoRemoteUrl(existingState.workspace_path);
|
|
17535
|
+
const matches = existingRemote != null && remoteUrlMatchesRepo(existingRemote, membership.org.workspace_repo);
|
|
17536
|
+
if (matches) {
|
|
17537
|
+
await writeConfig({
|
|
17538
|
+
org_id: membership.org.id,
|
|
17539
|
+
org_name: membership.org.name,
|
|
17540
|
+
workspace_repo: membership.org.workspace_repo,
|
|
17541
|
+
repo_path: existingState.workspace_path,
|
|
17542
|
+
installed_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
17543
|
+
});
|
|
17544
|
+
console.log("");
|
|
17545
|
+
console.log(` \u2713 Workspace already at ${existingState.workspace_path}`);
|
|
17546
|
+
console.log(
|
|
17547
|
+
" (init is idempotent \u2014 re-run with --reset to start over)"
|
|
17548
|
+
);
|
|
17549
|
+
console.log("");
|
|
17550
|
+
return;
|
|
17314
17551
|
}
|
|
17315
|
-
|
|
17316
|
-
|
|
17317
|
-
const matches = existingRemote != null && remoteUrlMatchesRepo(existingRemote, membership.org.workspace_repo);
|
|
17318
|
-
if (matches) {
|
|
17319
|
-
await writeConfig({
|
|
17320
|
-
org_id: membership.org.id,
|
|
17321
|
-
org_name: membership.org.name,
|
|
17322
|
-
workspace_repo: membership.org.workspace_repo,
|
|
17323
|
-
repo_path: existingState.workspace_path,
|
|
17324
|
-
installed_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
17325
|
-
});
|
|
17326
|
-
console.log("");
|
|
17327
|
-
console.log(` \u2713 Workspace already at ${existingState.workspace_path}`);
|
|
17328
|
-
console.log(" (init is idempotent \u2014 re-run with --reset to start over)");
|
|
17329
|
-
console.log("");
|
|
17330
|
-
return;
|
|
17331
|
-
}
|
|
17332
|
-
console.error(
|
|
17333
|
-
`
|
|
17552
|
+
console.error(
|
|
17553
|
+
`
|
|
17334
17554
|
${existingState.workspace_path} exists but its origin doesn't match your workspace repo.
|
|
17335
17555
|
|
|
17336
17556
|
` + (existingRemote ? ` Found origin: ${existingRemote}
|
|
@@ -17339,13 +17559,16 @@ async function runInit(options = {}) {
|
|
|
17339
17559
|
` : ` It's not a git repo (no origin remote).
|
|
17340
17560
|
|
|
17341
17561
|
`) + " Re-run with `bamboo-agents init --reset` to start over, or move the directory aside.\n"
|
|
17342
|
-
|
|
17343
|
-
|
|
17344
|
-
}
|
|
17345
|
-
console.log(` State points at ${existingState.workspace_path}, but the directory is missing \u2014 re-cloning there.`);
|
|
17346
|
-
await cloneAndPersist(existingState.workspace_path, membership);
|
|
17347
|
-
return;
|
|
17562
|
+
);
|
|
17563
|
+
process.exit(2);
|
|
17348
17564
|
}
|
|
17565
|
+
console.log(
|
|
17566
|
+
` State points at ${existingState.workspace_path}, but the directory is missing \u2014 re-cloning there.`
|
|
17567
|
+
);
|
|
17568
|
+
await cloneAndPersist(existingState.workspace_path, membership);
|
|
17569
|
+
return;
|
|
17570
|
+
}
|
|
17571
|
+
async function initializeCanonicalWorkspace(canonicalPath, orgSlug, membership) {
|
|
17349
17572
|
let canonicalExists = false;
|
|
17350
17573
|
try {
|
|
17351
17574
|
await access(canonicalPath);
|
|
@@ -17458,7 +17681,11 @@ var init_provision_phase = __esm({
|
|
|
17458
17681
|
name: "provision",
|
|
17459
17682
|
async probe(ctx) {
|
|
17460
17683
|
if (!ctx.credentials) {
|
|
17461
|
-
return {
|
|
17684
|
+
return {
|
|
17685
|
+
status: "needs_action",
|
|
17686
|
+
summary: "(no credentials)",
|
|
17687
|
+
reason: "Run `bamboo-agents login` first."
|
|
17688
|
+
};
|
|
17462
17689
|
}
|
|
17463
17690
|
let status;
|
|
17464
17691
|
try {
|
|
@@ -17564,7 +17791,9 @@ var init_provision_phase = __esm({
|
|
|
17564
17791
|
};
|
|
17565
17792
|
}
|
|
17566
17793
|
ctx.membership = result.membership;
|
|
17567
|
-
pollSpinner.succeed(
|
|
17794
|
+
pollSpinner.succeed(
|
|
17795
|
+
`Workspace ready: ${result.membership.org.workspace_repo}`
|
|
17796
|
+
);
|
|
17568
17797
|
return {
|
|
17569
17798
|
kind: "advanced",
|
|
17570
17799
|
summary: `Workspace ready: ${result.membership.org.workspace_repo}`
|
|
@@ -17713,7 +17942,13 @@ function mcpConfigPath(client) {
|
|
|
17713
17942
|
}
|
|
17714
17943
|
const plat = platform3();
|
|
17715
17944
|
if (plat === "darwin") {
|
|
17716
|
-
return join2(
|
|
17945
|
+
return join2(
|
|
17946
|
+
home,
|
|
17947
|
+
"Library",
|
|
17948
|
+
"Application Support",
|
|
17949
|
+
"Claude",
|
|
17950
|
+
"claude_desktop_config.json"
|
|
17951
|
+
);
|
|
17717
17952
|
}
|
|
17718
17953
|
if (plat === "win32") {
|
|
17719
17954
|
const appData = process.env.APPDATA;
|
|
@@ -17770,6 +18005,30 @@ function setBambooEntry(config, entry) {
|
|
|
17770
18005
|
}
|
|
17771
18006
|
};
|
|
17772
18007
|
}
|
|
18008
|
+
async function parseProbeResponse(response) {
|
|
18009
|
+
if (response.status === 401 || response.status === 403)
|
|
18010
|
+
return { status: "auth-failed", detail: `HTTP ${response.status}` };
|
|
18011
|
+
if (!response.ok)
|
|
18012
|
+
return { status: "unreachable", detail: `HTTP ${response.status}` };
|
|
18013
|
+
let body;
|
|
18014
|
+
try {
|
|
18015
|
+
body = await response.json();
|
|
18016
|
+
} catch {
|
|
18017
|
+
return { status: "invalid-response", detail: "non-JSON body" };
|
|
18018
|
+
}
|
|
18019
|
+
const message = body;
|
|
18020
|
+
if (typeof body !== "object" || body === null || message.jsonrpc !== "2.0" || !message.result?.serverInfo) {
|
|
18021
|
+
return {
|
|
18022
|
+
status: "invalid-response",
|
|
18023
|
+
detail: "missing initialize result.serverInfo"
|
|
18024
|
+
};
|
|
18025
|
+
}
|
|
18026
|
+
const serverInfo = message.result.serverInfo;
|
|
18027
|
+
return {
|
|
18028
|
+
status: "reachable",
|
|
18029
|
+
detail: typeof serverInfo.name === "string" ? serverInfo.name : void 0
|
|
18030
|
+
};
|
|
18031
|
+
}
|
|
17773
18032
|
async function probeMcpServer(url, token, options = {}) {
|
|
17774
18033
|
const controller = new AbortController();
|
|
17775
18034
|
const timeout = setTimeout(() => controller.abort(), PROBE_TIMEOUT_MS);
|
|
@@ -17795,28 +18054,7 @@ async function probeMcpServer(url, token, options = {}) {
|
|
|
17795
18054
|
}),
|
|
17796
18055
|
signal: controller.signal
|
|
17797
18056
|
});
|
|
17798
|
-
|
|
17799
|
-
return { status: "auth-failed", detail: `HTTP ${response.status}` };
|
|
17800
|
-
}
|
|
17801
|
-
if (!response.ok) {
|
|
17802
|
-
return { status: "unreachable", detail: `HTTP ${response.status}` };
|
|
17803
|
-
}
|
|
17804
|
-
let body;
|
|
17805
|
-
try {
|
|
17806
|
-
body = await response.json();
|
|
17807
|
-
} catch {
|
|
17808
|
-
return { status: "invalid-response", detail: "non-JSON body" };
|
|
17809
|
-
}
|
|
17810
|
-
if (typeof body !== "object" || body === null || // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17811
|
-
body.jsonrpc !== "2.0" || // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17812
|
-
!body.result?.serverInfo) {
|
|
17813
|
-
return { status: "invalid-response", detail: "missing initialize result.serverInfo" };
|
|
17814
|
-
}
|
|
17815
|
-
const serverInfo = body.result.serverInfo;
|
|
17816
|
-
return {
|
|
17817
|
-
status: "reachable",
|
|
17818
|
-
detail: typeof serverInfo.name === "string" ? serverInfo.name : void 0
|
|
17819
|
-
};
|
|
18057
|
+
return await parseProbeResponse(response);
|
|
17820
18058
|
} catch (err) {
|
|
17821
18059
|
if (err instanceof Error && err.name === "AbortError") {
|
|
17822
18060
|
return { status: "unreachable", detail: "timeout" };
|
|
@@ -17837,6 +18075,29 @@ var init_mcp_config = __esm({
|
|
|
17837
18075
|
});
|
|
17838
18076
|
|
|
17839
18077
|
// src/lib/phases-impl/install-mcp-phase.ts
|
|
18078
|
+
function mintFailure(err) {
|
|
18079
|
+
if (err instanceof ApiError) {
|
|
18080
|
+
if (err.errorCode === "no_active_install")
|
|
18081
|
+
return {
|
|
18082
|
+
kind: "needs_action",
|
|
18083
|
+
reason: "GitHub App isn't installed for this org. Run `bamboo-agents login` first."
|
|
18084
|
+
};
|
|
18085
|
+
if (err.errorCode === "no_workspace_repo")
|
|
18086
|
+
return {
|
|
18087
|
+
kind: "needs_action",
|
|
18088
|
+
reason: "Workspace repo doesn't exist yet. Run `bamboo-agents init` first."
|
|
18089
|
+
};
|
|
18090
|
+
return {
|
|
18091
|
+
kind: "needs_action",
|
|
18092
|
+
reason: `Could not mint Bamboo MCP API key: ${err.message}`
|
|
18093
|
+
};
|
|
18094
|
+
}
|
|
18095
|
+
const message = err instanceof Error ? err.message : "unknown error";
|
|
18096
|
+
return {
|
|
18097
|
+
kind: "needs_action",
|
|
18098
|
+
reason: `Could not mint Bamboo MCP API key: ${message}`
|
|
18099
|
+
};
|
|
18100
|
+
}
|
|
17840
18101
|
function isBambooEntryShape(entry) {
|
|
17841
18102
|
if (typeof entry !== "object" || entry === null) return false;
|
|
17842
18103
|
const e = entry;
|
|
@@ -17892,29 +18153,7 @@ var init_install_mcp_phase = __esm({
|
|
|
17892
18153
|
token = await mintCliInstallToken(ctx.credentials.bamboo_session);
|
|
17893
18154
|
} catch (err) {
|
|
17894
18155
|
spinner.fail("Could not mint Bamboo MCP credentials");
|
|
17895
|
-
|
|
17896
|
-
if (err.errorCode === "no_active_install") {
|
|
17897
|
-
return {
|
|
17898
|
-
kind: "needs_action",
|
|
17899
|
-
reason: "GitHub App isn't installed for this org. Run `bamboo-agents login` first."
|
|
17900
|
-
};
|
|
17901
|
-
}
|
|
17902
|
-
if (err.errorCode === "no_workspace_repo") {
|
|
17903
|
-
return {
|
|
17904
|
-
kind: "needs_action",
|
|
17905
|
-
reason: "Workspace repo doesn't exist yet. Run `bamboo-agents init` first."
|
|
17906
|
-
};
|
|
17907
|
-
}
|
|
17908
|
-
return {
|
|
17909
|
-
kind: "needs_action",
|
|
17910
|
-
reason: `Could not mint Bamboo MCP API key: ${err.message}`
|
|
17911
|
-
};
|
|
17912
|
-
}
|
|
17913
|
-
const message = err instanceof Error ? err.message : "unknown error";
|
|
17914
|
-
return {
|
|
17915
|
-
kind: "needs_action",
|
|
17916
|
-
reason: `Could not mint Bamboo MCP API key: ${message}`
|
|
17917
|
-
};
|
|
18156
|
+
return mintFailure(err);
|
|
17918
18157
|
}
|
|
17919
18158
|
const entry = {
|
|
17920
18159
|
type: "http",
|
|
@@ -17969,7 +18208,9 @@ async function runCaseA(ctx) {
|
|
|
17969
18208
|
console.log(" Let's set up YOUR first agent. How would you like to start?");
|
|
17970
18209
|
console.log("");
|
|
17971
18210
|
console.log(" 1) Create a new agent \u2014 I'll ask you a few questions");
|
|
17972
|
-
console.log(
|
|
18211
|
+
console.log(
|
|
18212
|
+
" 2) Upload an existing CLAUDE.md or AGENTS.md from your machine"
|
|
18213
|
+
);
|
|
17973
18214
|
console.log("");
|
|
17974
18215
|
const choice = await promptChoice(" Choose [1-2]: ", ["1", "2"]);
|
|
17975
18216
|
if (choice === null) return null;
|
|
@@ -18080,10 +18321,12 @@ async function runUploadFlow(ctx) {
|
|
|
18080
18321
|
console.log(" \u2026");
|
|
18081
18322
|
}
|
|
18082
18323
|
console.log("");
|
|
18083
|
-
const confirm2 = await promptChoice(
|
|
18084
|
-
"
|
|
18085
|
-
|
|
18086
|
-
|
|
18324
|
+
const confirm2 = await promptChoice(" Upload this? [y/n]: ", [
|
|
18325
|
+
"y",
|
|
18326
|
+
"n",
|
|
18327
|
+
"Y",
|
|
18328
|
+
"N"
|
|
18329
|
+
]);
|
|
18087
18330
|
if (confirm2 === null || confirm2.toLowerCase() !== "y") return null;
|
|
18088
18331
|
console.log("");
|
|
18089
18332
|
const name = await promptStdin(
|
|
@@ -18113,6 +18356,17 @@ async function runUploadFlow(ctx) {
|
|
|
18113
18356
|
return null;
|
|
18114
18357
|
}
|
|
18115
18358
|
}
|
|
18359
|
+
async function uploadFileInsideDirectory(requestedPath) {
|
|
18360
|
+
for (const name of UPLOAD_DEFAULT_PATHS) {
|
|
18361
|
+
const candidate = pathJoin(requestedPath, name);
|
|
18362
|
+
try {
|
|
18363
|
+
const cs = await stat(candidate);
|
|
18364
|
+
if (cs.isFile()) return candidate;
|
|
18365
|
+
} catch {
|
|
18366
|
+
}
|
|
18367
|
+
}
|
|
18368
|
+
return null;
|
|
18369
|
+
}
|
|
18116
18370
|
async function resolveUploadFile(ctx) {
|
|
18117
18371
|
const defaultsHint = UPLOAD_DEFAULT_PATHS.join(" or ");
|
|
18118
18372
|
let isFirstPrompt = true;
|
|
@@ -18135,24 +18389,16 @@ async function resolveUploadFile(ctx) {
|
|
|
18135
18389
|
try {
|
|
18136
18390
|
const s = await stat(requestedPath);
|
|
18137
18391
|
if (s.isDirectory()) {
|
|
18138
|
-
|
|
18139
|
-
for (const name of UPLOAD_DEFAULT_PATHS) {
|
|
18140
|
-
const candidate = pathJoin(requestedPath, name);
|
|
18141
|
-
try {
|
|
18142
|
-
const cs = await stat(candidate);
|
|
18143
|
-
if (cs.isFile()) {
|
|
18144
|
-
resolvedInside = candidate;
|
|
18145
|
-
break;
|
|
18146
|
-
}
|
|
18147
|
-
} catch {
|
|
18148
|
-
}
|
|
18149
|
-
}
|
|
18392
|
+
const resolvedInside = await uploadFileInsideDirectory(requestedPath);
|
|
18150
18393
|
if (!resolvedInside) {
|
|
18151
18394
|
console.log("");
|
|
18152
18395
|
console.log(
|
|
18153
18396
|
` ${requestedPath} is a directory and doesn't contain a ${UPLOAD_DEFAULT_PATHS.join(" or ")}.`
|
|
18154
18397
|
);
|
|
18155
|
-
await printDirectorySneakPeek(
|
|
18398
|
+
await printDirectorySneakPeek(
|
|
18399
|
+
ctx.cwd,
|
|
18400
|
+
pathJoin(requestedPath, UPLOAD_DEFAULT_PATHS[0])
|
|
18401
|
+
);
|
|
18156
18402
|
continue;
|
|
18157
18403
|
}
|
|
18158
18404
|
absPath = resolvedInside;
|
|
@@ -18326,10 +18572,7 @@ var init_pick_first_user_agent_phase = __esm({
|
|
|
18326
18572
|
await Promise.all(
|
|
18327
18573
|
userCreated.map(async (a) => {
|
|
18328
18574
|
try {
|
|
18329
|
-
const h = await getAgentHealth(
|
|
18330
|
-
ctx.credentials.bamboo_session,
|
|
18331
|
-
a.id
|
|
18332
|
-
);
|
|
18575
|
+
const h = await getAgentHealth(ctx.credentials.bamboo_session, a.id);
|
|
18333
18576
|
healthByAgentId.set(a.id, h?.score ?? null);
|
|
18334
18577
|
} catch {
|
|
18335
18578
|
healthByAgentId.set(a.id, null);
|
|
@@ -18338,9 +18581,7 @@ var init_pick_first_user_agent_phase = __esm({
|
|
|
18338
18581
|
);
|
|
18339
18582
|
console.log("");
|
|
18340
18583
|
if (preInstalled.length > 0) {
|
|
18341
|
-
console.log(
|
|
18342
|
-
" Your workspace already has these pre-installed agents:"
|
|
18343
|
-
);
|
|
18584
|
+
console.log(" Your workspace already has these pre-installed agents:");
|
|
18344
18585
|
for (const a of preInstalled) {
|
|
18345
18586
|
console.log(` \u2022 ${a.name} (sample)`);
|
|
18346
18587
|
}
|
|
@@ -18437,7 +18678,9 @@ var init_magic_moment_phase = __esm({
|
|
|
18437
18678
|
answer
|
|
18438
18679
|
);
|
|
18439
18680
|
console.log("");
|
|
18440
|
-
console.log(
|
|
18681
|
+
console.log(
|
|
18682
|
+
" \u2713 Saved to your workspace. Boo will use this in your first chat."
|
|
18683
|
+
);
|
|
18441
18684
|
return {
|
|
18442
18685
|
kind: "advanced",
|
|
18443
18686
|
summary: "answered Boo's first question"
|
|
@@ -18449,7 +18692,9 @@ var init_magic_moment_phase = __esm({
|
|
|
18449
18692
|
JSON.stringify({ path: next.save_path, error: msg })
|
|
18450
18693
|
);
|
|
18451
18694
|
console.log("");
|
|
18452
|
-
console.log(
|
|
18695
|
+
console.log(
|
|
18696
|
+
" (Couldn't save your answer right now \u2014 Boo will ask again in your first chat.)"
|
|
18697
|
+
);
|
|
18453
18698
|
return {
|
|
18454
18699
|
kind: "advanced",
|
|
18455
18700
|
summary: "answered Boo's first question (save retried in-app)"
|
|
@@ -18518,6 +18763,13 @@ var init_open_phase = __esm({
|
|
|
18518
18763
|
});
|
|
18519
18764
|
|
|
18520
18765
|
// src/lib/orchestrator-steps/health-line.ts
|
|
18766
|
+
function healthErrorCode(err) {
|
|
18767
|
+
if (err && typeof err === "object" && "errorCode" in err && err.errorCode) {
|
|
18768
|
+
return String(err.errorCode);
|
|
18769
|
+
}
|
|
18770
|
+
if (err instanceof Error) return err.message;
|
|
18771
|
+
return String(err);
|
|
18772
|
+
}
|
|
18521
18773
|
async function printHealthLine(ctx) {
|
|
18522
18774
|
if (!ctx.credentials?.bamboo_session) return;
|
|
18523
18775
|
if (!ctx.agentId) return;
|
|
@@ -18525,12 +18777,9 @@ async function printHealthLine(ctx) {
|
|
|
18525
18777
|
console.log(" Computing health score\u2026");
|
|
18526
18778
|
let health;
|
|
18527
18779
|
try {
|
|
18528
|
-
health = await getAgentHealth(
|
|
18529
|
-
ctx.credentials.bamboo_session,
|
|
18530
|
-
ctx.agentId
|
|
18531
|
-
);
|
|
18780
|
+
health = await getAgentHealth(ctx.credentials.bamboo_session, ctx.agentId);
|
|
18532
18781
|
} catch (err) {
|
|
18533
|
-
const code =
|
|
18782
|
+
const code = healthErrorCode(err);
|
|
18534
18783
|
console.log(
|
|
18535
18784
|
` Couldn't compute health: ${code} \u2014 re-run with --debug for details, or check \`bamboo-agents doctor\`.`
|
|
18536
18785
|
);
|
|
@@ -18681,25 +18930,48 @@ async function runAuthStatus(options) {
|
|
|
18681
18930
|
try {
|
|
18682
18931
|
const credential = await resolveSession();
|
|
18683
18932
|
if (!credential) {
|
|
18684
|
-
emitError(
|
|
18933
|
+
emitError(
|
|
18934
|
+
{
|
|
18935
|
+
code: "authentication_required",
|
|
18936
|
+
message: "Set BAMBOO_API_TOKEN or run bamboo-agents login."
|
|
18937
|
+
},
|
|
18938
|
+
options,
|
|
18939
|
+
1
|
|
18940
|
+
);
|
|
18685
18941
|
return;
|
|
18686
18942
|
}
|
|
18687
18943
|
const scope = await getCliOrganizationScope(credential);
|
|
18688
18944
|
const status = {
|
|
18689
18945
|
credential_kind: credential.startsWith("bam_") ? "api_key" : "user_session",
|
|
18690
|
-
organization: {
|
|
18946
|
+
organization: {
|
|
18947
|
+
id: scope.effective_org_id,
|
|
18948
|
+
name: scope.effective_org_name
|
|
18949
|
+
},
|
|
18691
18950
|
operator: scope.operator ?? null
|
|
18692
18951
|
};
|
|
18693
|
-
human(
|
|
18952
|
+
human(
|
|
18953
|
+
`Organization: ${scope.effective_org_name} (${scope.effective_org_id})`,
|
|
18954
|
+
options
|
|
18955
|
+
);
|
|
18694
18956
|
if (scope.operator) {
|
|
18695
18957
|
human(`Agent: ${scope.operator.agent_id}`, options);
|
|
18696
18958
|
human(`Capability: ${scope.operator.capability}`, options);
|
|
18697
|
-
human(
|
|
18959
|
+
human(
|
|
18960
|
+
`Key: ${scope.operator.key_id} (expires ${scope.operator.expires_at})`,
|
|
18961
|
+
options
|
|
18962
|
+
);
|
|
18698
18963
|
}
|
|
18699
18964
|
emitSuccess(status, options);
|
|
18700
18965
|
} catch (error) {
|
|
18701
18966
|
const value = error;
|
|
18702
|
-
emitError(
|
|
18967
|
+
emitError(
|
|
18968
|
+
{
|
|
18969
|
+
code: value.code ?? value.errorCode ?? "auth_status_failed",
|
|
18970
|
+
message: value.message ?? "Could not verify Bamboo authentication."
|
|
18971
|
+
},
|
|
18972
|
+
options,
|
|
18973
|
+
1
|
|
18974
|
+
);
|
|
18703
18975
|
}
|
|
18704
18976
|
}
|
|
18705
18977
|
var init_auth_status2 = __esm({
|
|
@@ -18735,11 +19007,9 @@ async function detectMacOS() {
|
|
|
18735
19007
|
}
|
|
18736
19008
|
async function detectWindows() {
|
|
18737
19009
|
try {
|
|
18738
|
-
await execFileP2(
|
|
18739
|
-
"
|
|
18740
|
-
|
|
18741
|
-
{ encoding: "utf8" }
|
|
18742
|
-
);
|
|
19010
|
+
await execFileP2("reg", ["query", "HKCU\\Software\\Classes\\claude"], {
|
|
19011
|
+
encoding: "utf8"
|
|
19012
|
+
});
|
|
18743
19013
|
return { kind: "installed" };
|
|
18744
19014
|
} catch {
|
|
18745
19015
|
return { kind: "missing" };
|
|
@@ -18789,7 +19059,9 @@ async function runOpen() {
|
|
|
18789
19059
|
const url = `claude://code/new?folder=${encodeURIComponent(workspacePath)}`;
|
|
18790
19060
|
await open_default(url);
|
|
18791
19061
|
console.log(`Opening Claude Code at ${workspacePath}\u2026`);
|
|
18792
|
-
console.log(
|
|
19062
|
+
console.log(
|
|
19063
|
+
"(Claude Desktop will ask you to trust the folder the first time.)"
|
|
19064
|
+
);
|
|
18793
19065
|
});
|
|
18794
19066
|
}
|
|
18795
19067
|
var DOWNLOAD_URL;
|
|
@@ -18835,7 +19107,8 @@ function parsePorcelain(out) {
|
|
|
18835
19107
|
return entries;
|
|
18836
19108
|
}
|
|
18837
19109
|
function isManagedPath(path2) {
|
|
18838
|
-
if (MANAGED_FILES.includes(path2))
|
|
19110
|
+
if (MANAGED_FILES.includes(path2))
|
|
19111
|
+
return true;
|
|
18839
19112
|
return MANAGED_PREFIXES.some((p) => path2.startsWith(p));
|
|
18840
19113
|
}
|
|
18841
19114
|
function isDeletion(entry) {
|
|
@@ -18903,6 +19176,92 @@ async function requireSession(opts) {
|
|
|
18903
19176
|
}
|
|
18904
19177
|
return session;
|
|
18905
19178
|
}
|
|
19179
|
+
function reportSaveError(err, opts) {
|
|
19180
|
+
if (err instanceof ApiError && err.status === 422) {
|
|
19181
|
+
const findings = err.details?.findings;
|
|
19182
|
+
const count = Array.isArray(findings) ? findings.length : null;
|
|
19183
|
+
emitError(
|
|
19184
|
+
{
|
|
19185
|
+
code: err.errorCode ?? "rejected",
|
|
19186
|
+
message: count === null ? `couldn't save \u2014 ${err.message}` : `couldn't save \u2014 ${count} problem${count === 1 ? "" : "s"} to fix.`,
|
|
19187
|
+
hint: "Fix each problem and run `bamboo-agents save` again.",
|
|
19188
|
+
details: err.details
|
|
19189
|
+
},
|
|
19190
|
+
opts,
|
|
19191
|
+
1
|
|
19192
|
+
);
|
|
19193
|
+
return;
|
|
19194
|
+
}
|
|
19195
|
+
if (err instanceof ApiError && err.status === 403) {
|
|
19196
|
+
emitError(
|
|
19197
|
+
{
|
|
19198
|
+
code: "forbidden",
|
|
19199
|
+
message: "couldn't save \u2014 you don't have permission to change some of these files.",
|
|
19200
|
+
hint: "Ask an org admin to review, or edit only your own brand/agent files."
|
|
19201
|
+
},
|
|
19202
|
+
opts,
|
|
19203
|
+
1
|
|
19204
|
+
);
|
|
19205
|
+
return;
|
|
19206
|
+
}
|
|
19207
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
19208
|
+
emitError(
|
|
19209
|
+
{
|
|
19210
|
+
code: "save_failed",
|
|
19211
|
+
message: `couldn't reach Bamboo to save your changes. (${message})`,
|
|
19212
|
+
hint: "Check your connection and run `bamboo-agents save` again."
|
|
19213
|
+
},
|
|
19214
|
+
opts,
|
|
19215
|
+
1
|
|
19216
|
+
);
|
|
19217
|
+
}
|
|
19218
|
+
async function refreshSavedPaths(workspacePath, checkout, remove, opts) {
|
|
19219
|
+
if (checkout.length > 0 || remove.length > 0) {
|
|
19220
|
+
try {
|
|
19221
|
+
const branch = await currentBranch(workspacePath);
|
|
19222
|
+
await gitC(workspacePath, ["fetch", "origin", branch]);
|
|
19223
|
+
if (checkout.length > 0)
|
|
19224
|
+
await gitC(workspacePath, [
|
|
19225
|
+
"checkout",
|
|
19226
|
+
`origin/${branch}`,
|
|
19227
|
+
"--",
|
|
19228
|
+
...checkout
|
|
19229
|
+
]);
|
|
19230
|
+
for (const path2 of remove)
|
|
19231
|
+
await rm2(join3(workspacePath, path2), { force: true });
|
|
19232
|
+
} catch {
|
|
19233
|
+
human(
|
|
19234
|
+
" (Saved, but couldn't refresh your local copy just now \u2014 it'll catch up on your next command.)",
|
|
19235
|
+
opts
|
|
19236
|
+
);
|
|
19237
|
+
}
|
|
19238
|
+
}
|
|
19239
|
+
}
|
|
19240
|
+
function saveIntent(intent) {
|
|
19241
|
+
return intent?.trim() || void 0;
|
|
19242
|
+
}
|
|
19243
|
+
async function readSaveEdits(workspacePath, writes, deletes, opts) {
|
|
19244
|
+
const edits = [];
|
|
19245
|
+
try {
|
|
19246
|
+
for (const path2 of writes) {
|
|
19247
|
+
const content = await readFile5(join3(workspacePath, path2), "utf8");
|
|
19248
|
+
edits.push({ path: path2, content });
|
|
19249
|
+
}
|
|
19250
|
+
} catch {
|
|
19251
|
+
emitError(
|
|
19252
|
+
{
|
|
19253
|
+
code: "read_failed",
|
|
19254
|
+
message: "couldn't read one of your changed files.",
|
|
19255
|
+
hint: "Make sure the file still exists, then run `bamboo-agents save` again."
|
|
19256
|
+
},
|
|
19257
|
+
opts,
|
|
19258
|
+
1
|
|
19259
|
+
);
|
|
19260
|
+
return null;
|
|
19261
|
+
}
|
|
19262
|
+
for (const path2 of deletes) edits.push({ path: path2, delete: true });
|
|
19263
|
+
return edits;
|
|
19264
|
+
}
|
|
18906
19265
|
async function runSave(intent, options = {}) {
|
|
18907
19266
|
const opts = options;
|
|
18908
19267
|
const dryRun = options.dryRun ?? false;
|
|
@@ -18969,103 +19328,30 @@ async function runSave(intent, options = {}) {
|
|
|
18969
19328
|
opts
|
|
18970
19329
|
);
|
|
18971
19330
|
} else {
|
|
18972
|
-
human(
|
|
19331
|
+
human(
|
|
19332
|
+
" Nothing to save \u2014 your workspace is already up to date.",
|
|
19333
|
+
opts
|
|
19334
|
+
);
|
|
18973
19335
|
}
|
|
18974
19336
|
human("", opts);
|
|
18975
19337
|
});
|
|
18976
19338
|
return;
|
|
18977
19339
|
}
|
|
18978
|
-
const edits =
|
|
18979
|
-
|
|
18980
|
-
for (const path2 of writes) {
|
|
18981
|
-
const content = await readFile5(join3(workspacePath, path2), "utf8");
|
|
18982
|
-
edits.push({ path: path2, content });
|
|
18983
|
-
}
|
|
18984
|
-
} catch {
|
|
18985
|
-
emitError(
|
|
18986
|
-
{
|
|
18987
|
-
code: "read_failed",
|
|
18988
|
-
message: "couldn't read one of your changed files.",
|
|
18989
|
-
hint: "Make sure the file still exists, then run `bamboo-agents save` again."
|
|
18990
|
-
},
|
|
18991
|
-
opts,
|
|
18992
|
-
1
|
|
18993
|
-
);
|
|
18994
|
-
return;
|
|
18995
|
-
}
|
|
18996
|
-
for (const path2 of deletes) {
|
|
18997
|
-
edits.push({ path: path2, delete: true });
|
|
18998
|
-
}
|
|
19340
|
+
const edits = await readSaveEdits(workspacePath, writes, deletes, opts);
|
|
19341
|
+
if (!edits) return;
|
|
18999
19342
|
let result;
|
|
19000
19343
|
try {
|
|
19001
19344
|
result = await saveWorkspace(session, {
|
|
19002
19345
|
edits,
|
|
19003
|
-
intent: intent
|
|
19346
|
+
intent: saveIntent(intent),
|
|
19004
19347
|
dry_run: dryRun || void 0
|
|
19005
19348
|
});
|
|
19006
19349
|
} catch (err) {
|
|
19007
|
-
|
|
19008
|
-
const findings = err.details?.findings;
|
|
19009
|
-
const count = Array.isArray(findings) ? findings.length : null;
|
|
19010
|
-
emitError(
|
|
19011
|
-
{
|
|
19012
|
-
code: err.errorCode ?? "rejected",
|
|
19013
|
-
message: count === null ? `couldn't save \u2014 ${err.message}` : `couldn't save \u2014 ${count} problem${count === 1 ? "" : "s"} to fix.`,
|
|
19014
|
-
hint: "Fix each problem and run `bamboo-agents save` again.",
|
|
19015
|
-
details: err.details
|
|
19016
|
-
},
|
|
19017
|
-
opts,
|
|
19018
|
-
1
|
|
19019
|
-
);
|
|
19020
|
-
return;
|
|
19021
|
-
}
|
|
19022
|
-
if (err instanceof ApiError && err.status === 403) {
|
|
19023
|
-
emitError(
|
|
19024
|
-
{
|
|
19025
|
-
code: "forbidden",
|
|
19026
|
-
message: "couldn't save \u2014 you don't have permission to change some of these files.",
|
|
19027
|
-
hint: "Ask an org admin to review, or edit only your own brand/agent files."
|
|
19028
|
-
},
|
|
19029
|
-
opts,
|
|
19030
|
-
1
|
|
19031
|
-
);
|
|
19032
|
-
return;
|
|
19033
|
-
}
|
|
19034
|
-
const message = err instanceof Error ? err.message : String(err);
|
|
19035
|
-
emitError(
|
|
19036
|
-
{
|
|
19037
|
-
code: "save_failed",
|
|
19038
|
-
message: `couldn't reach Bamboo to save your changes. (${message})`,
|
|
19039
|
-
hint: "Check your connection and run `bamboo-agents save` again."
|
|
19040
|
-
},
|
|
19041
|
-
opts,
|
|
19042
|
-
1
|
|
19043
|
-
);
|
|
19350
|
+
reportSaveError(err, opts);
|
|
19044
19351
|
return;
|
|
19045
19352
|
}
|
|
19046
19353
|
const { checkout, remove } = dryRun ? { checkout: [], remove: [] } : reconcilePlan(result.files, deletes);
|
|
19047
|
-
|
|
19048
|
-
try {
|
|
19049
|
-
const branch = await currentBranch(workspacePath);
|
|
19050
|
-
await gitC(workspacePath, ["fetch", "origin", branch]);
|
|
19051
|
-
if (checkout.length > 0) {
|
|
19052
|
-
await gitC(workspacePath, [
|
|
19053
|
-
"checkout",
|
|
19054
|
-
`origin/${branch}`,
|
|
19055
|
-
"--",
|
|
19056
|
-
...checkout
|
|
19057
|
-
]);
|
|
19058
|
-
}
|
|
19059
|
-
for (const path2 of remove) {
|
|
19060
|
-
await rm2(join3(workspacePath, path2), { force: true });
|
|
19061
|
-
}
|
|
19062
|
-
} catch {
|
|
19063
|
-
human(
|
|
19064
|
-
" (Saved, but couldn't refresh your local copy just now \u2014 it'll catch up on your next command.)",
|
|
19065
|
-
opts
|
|
19066
|
-
);
|
|
19067
|
-
}
|
|
19068
|
-
}
|
|
19354
|
+
await refreshSavedPaths(workspacePath, checkout, remove, opts);
|
|
19069
19355
|
const total = edits.length;
|
|
19070
19356
|
const live = result.live_count;
|
|
19071
19357
|
const queued = result.queued_count;
|
|
@@ -19183,7 +19469,12 @@ function classifyCloneHealth(input) {
|
|
|
19183
19469
|
}
|
|
19184
19470
|
async function currentBranchOrNull(repoPath) {
|
|
19185
19471
|
try {
|
|
19186
|
-
const out = await git(repoPath, [
|
|
19472
|
+
const out = await git(repoPath, [
|
|
19473
|
+
"symbolic-ref",
|
|
19474
|
+
"--quiet",
|
|
19475
|
+
"--short",
|
|
19476
|
+
"HEAD"
|
|
19477
|
+
]);
|
|
19187
19478
|
const name = out.trim();
|
|
19188
19479
|
return name || null;
|
|
19189
19480
|
} catch {
|
|
@@ -19228,7 +19519,9 @@ function formatSyncLine(input) {
|
|
|
19228
19519
|
parts.push(`cloud has ${behind} newer`);
|
|
19229
19520
|
}
|
|
19230
19521
|
if (ahead !== null && ahead > 0) {
|
|
19231
|
-
parts.push(
|
|
19522
|
+
parts.push(
|
|
19523
|
+
`${ahead} local commit${ahead === 1 ? "" : "s"} ahead (run \`bamboo-agents doctor\`)`
|
|
19524
|
+
);
|
|
19232
19525
|
}
|
|
19233
19526
|
const summary = parts.length === 0 ? "in sync" : parts.join(", ");
|
|
19234
19527
|
return `Sync: ${summary}`;
|
|
@@ -19237,7 +19530,9 @@ function formatSubscriptionLine(billing) {
|
|
|
19237
19530
|
switch (billing.state) {
|
|
19238
19531
|
case "trialing": {
|
|
19239
19532
|
const days = billing.trial_days_remaining;
|
|
19240
|
-
|
|
19533
|
+
let suffix = "";
|
|
19534
|
+
if (days === 1) suffix = " (1 day left)";
|
|
19535
|
+
else if (days !== null) suffix = ` (${days} days left)`;
|
|
19241
19536
|
return `Subscription: TRIAL${suffix} \u2014 subscribe at ${billing.billing_url}`;
|
|
19242
19537
|
}
|
|
19243
19538
|
case "active":
|
|
@@ -19249,6 +19544,39 @@ function formatSubscriptionLine(billing) {
|
|
|
19249
19544
|
return `Subscription: not yet started \u2014 subscribe at ${billing.billing_url}`;
|
|
19250
19545
|
}
|
|
19251
19546
|
}
|
|
19547
|
+
function statusRepoLabel(workspacePath, cfg, state) {
|
|
19548
|
+
return workspacePath ? cfg?.workspace_repo ?? state?.remote_url?.replace(/^https?:\/\/github\.com\//, "") ?? "(unknown)" : null;
|
|
19549
|
+
}
|
|
19550
|
+
async function statusSync(workspacePath) {
|
|
19551
|
+
if (!workspacePath) return null;
|
|
19552
|
+
const unsaved = await countUnsavedManagedEdits(workspacePath);
|
|
19553
|
+
const branch = await currentBranchOrNull(workspacePath);
|
|
19554
|
+
const ab = branch ? await aheadBehind(workspacePath, branch) : null;
|
|
19555
|
+
return { unsaved, behind: ab?.behind ?? null, ahead: ab?.ahead ?? null };
|
|
19556
|
+
}
|
|
19557
|
+
function statusCredentialFields(creds) {
|
|
19558
|
+
return {
|
|
19559
|
+
signed_in: !!creds,
|
|
19560
|
+
github_username: creds?.github_username ?? null,
|
|
19561
|
+
credentials_written_at: creds?.written_at ?? null,
|
|
19562
|
+
github_token_expires_at: creds?.github_token_expires_at ?? null
|
|
19563
|
+
};
|
|
19564
|
+
}
|
|
19565
|
+
function statusPayload(creds, state, cfg, workspacePath, repoLabel, sync, billing) {
|
|
19566
|
+
return {
|
|
19567
|
+
...statusCredentialFields(creds),
|
|
19568
|
+
workspace: {
|
|
19569
|
+
configured: !!workspacePath,
|
|
19570
|
+
repo: repoLabel,
|
|
19571
|
+
path: workspacePath,
|
|
19572
|
+
org: cfg?.org_name ?? state?.org_slug ?? null,
|
|
19573
|
+
installed_at: cfg?.installed_at ?? state?.cloned_at ?? null,
|
|
19574
|
+
last_sync: state?.last_sync ?? null,
|
|
19575
|
+
sync
|
|
19576
|
+
},
|
|
19577
|
+
subscription: billing
|
|
19578
|
+
};
|
|
19579
|
+
}
|
|
19252
19580
|
async function runStatus(options = {}) {
|
|
19253
19581
|
const opts = options;
|
|
19254
19582
|
return withFreshWorkspace(async () => {
|
|
@@ -19256,14 +19584,8 @@ async function runStatus(options = {}) {
|
|
|
19256
19584
|
const state = await readState().catch(() => null);
|
|
19257
19585
|
const cfg = await readConfig();
|
|
19258
19586
|
const workspacePath = state?.workspace_path ?? cfg?.repo_path ?? null;
|
|
19259
|
-
const repoLabel = workspacePath
|
|
19260
|
-
|
|
19261
|
-
if (workspacePath) {
|
|
19262
|
-
const unsaved = await countUnsavedManagedEdits(workspacePath);
|
|
19263
|
-
const branch = await currentBranchOrNull(workspacePath);
|
|
19264
|
-
const ab = branch ? await aheadBehind(workspacePath, branch) : null;
|
|
19265
|
-
sync = { unsaved, behind: ab?.behind ?? null, ahead: ab?.ahead ?? null };
|
|
19266
|
-
}
|
|
19587
|
+
const repoLabel = statusRepoLabel(workspacePath, cfg, state);
|
|
19588
|
+
const sync = await statusSync(workspacePath);
|
|
19267
19589
|
let billing = null;
|
|
19268
19590
|
if (creds?.bamboo_session) {
|
|
19269
19591
|
try {
|
|
@@ -19271,22 +19593,15 @@ async function runStatus(options = {}) {
|
|
|
19271
19593
|
} catch {
|
|
19272
19594
|
}
|
|
19273
19595
|
}
|
|
19274
|
-
const payload =
|
|
19275
|
-
|
|
19276
|
-
|
|
19277
|
-
|
|
19278
|
-
|
|
19279
|
-
|
|
19280
|
-
|
|
19281
|
-
|
|
19282
|
-
|
|
19283
|
-
org: cfg?.org_name ?? state?.org_slug ?? null,
|
|
19284
|
-
installed_at: cfg?.installed_at ?? state?.cloned_at ?? null,
|
|
19285
|
-
last_sync: state?.last_sync ?? null,
|
|
19286
|
-
sync
|
|
19287
|
-
},
|
|
19288
|
-
subscription: billing
|
|
19289
|
-
};
|
|
19596
|
+
const payload = statusPayload(
|
|
19597
|
+
creds,
|
|
19598
|
+
state,
|
|
19599
|
+
cfg,
|
|
19600
|
+
workspacePath,
|
|
19601
|
+
repoLabel,
|
|
19602
|
+
sync,
|
|
19603
|
+
billing
|
|
19604
|
+
);
|
|
19290
19605
|
emitSuccess(payload, opts, (d) => {
|
|
19291
19606
|
human("", opts);
|
|
19292
19607
|
human(" Bamboo CLI status", opts);
|
|
@@ -19304,12 +19619,18 @@ async function runStatus(options = {}) {
|
|
|
19304
19619
|
}
|
|
19305
19620
|
}
|
|
19306
19621
|
if (!d.workspace.configured) {
|
|
19307
|
-
human(
|
|
19622
|
+
human(
|
|
19623
|
+
" Workspace: not configured (run `bamboo-agents init`)",
|
|
19624
|
+
opts
|
|
19625
|
+
);
|
|
19308
19626
|
} else {
|
|
19309
19627
|
human(` Workspace: ${d.workspace.repo ?? "(unknown)"}`, opts);
|
|
19310
19628
|
human(` Repo path: ${d.workspace.path}`, opts);
|
|
19311
19629
|
human(` Org: ${d.workspace.org ?? "(unknown)"}`, opts);
|
|
19312
|
-
human(
|
|
19630
|
+
human(
|
|
19631
|
+
` Installed: ${d.workspace.installed_at ?? "(unknown)"}`,
|
|
19632
|
+
opts
|
|
19633
|
+
);
|
|
19313
19634
|
if (d.workspace.last_sync) {
|
|
19314
19635
|
human(` Last sync: ${d.workspace.last_sync}`, opts);
|
|
19315
19636
|
}
|
|
@@ -19339,7 +19660,15 @@ var init_status = __esm({
|
|
|
19339
19660
|
// src/lib/workspace-health.ts
|
|
19340
19661
|
import { execFile as execFile10 } from "node:child_process";
|
|
19341
19662
|
import { promisify as promisify10 } from "node:util";
|
|
19342
|
-
import {
|
|
19663
|
+
import {
|
|
19664
|
+
lstat,
|
|
19665
|
+
readlink,
|
|
19666
|
+
readdir as readdir2,
|
|
19667
|
+
mkdir as mkdir4,
|
|
19668
|
+
symlink,
|
|
19669
|
+
rm as rm3,
|
|
19670
|
+
access as access4
|
|
19671
|
+
} from "node:fs/promises";
|
|
19343
19672
|
import { join as join4, dirname as dirname3, resolve } from "node:path";
|
|
19344
19673
|
import { homedir as homedir3 } from "node:os";
|
|
19345
19674
|
function getStaleSyncHours() {
|
|
@@ -19352,7 +19681,12 @@ function getStaleSyncHours() {
|
|
|
19352
19681
|
function cloneSearchRoots(cwd) {
|
|
19353
19682
|
const overridden = process.env.BAMBOO_CLONE_SEARCH_DIRS;
|
|
19354
19683
|
const home = homedir3();
|
|
19355
|
-
const base = overridden ? overridden.split(":").filter(Boolean) : [
|
|
19684
|
+
const base = overridden ? overridden.split(":").filter(Boolean) : [
|
|
19685
|
+
home,
|
|
19686
|
+
join4(home, "Documents"),
|
|
19687
|
+
join4(home, "Downloads"),
|
|
19688
|
+
join4(home, "Desktop")
|
|
19689
|
+
];
|
|
19356
19690
|
const walk = [];
|
|
19357
19691
|
let cur = cwd ?? process.cwd();
|
|
19358
19692
|
for (let i = 0; i < 20; i++) {
|
|
@@ -19445,7 +19779,13 @@ async function checkAdapters(workspacePath) {
|
|
|
19445
19779
|
try {
|
|
19446
19780
|
s = await lstat(full);
|
|
19447
19781
|
} catch {
|
|
19448
|
-
out.push({
|
|
19782
|
+
out.push({
|
|
19783
|
+
path: path2,
|
|
19784
|
+
expectedTarget: target,
|
|
19785
|
+
ok: false,
|
|
19786
|
+
state: "missing",
|
|
19787
|
+
actualTarget: null
|
|
19788
|
+
});
|
|
19449
19789
|
continue;
|
|
19450
19790
|
}
|
|
19451
19791
|
if (!s.isSymbolicLink()) {
|
|
@@ -19462,11 +19802,23 @@ async function checkAdapters(workspacePath) {
|
|
|
19462
19802
|
try {
|
|
19463
19803
|
actual = await readlink(full);
|
|
19464
19804
|
} catch {
|
|
19465
|
-
out.push({
|
|
19805
|
+
out.push({
|
|
19806
|
+
path: path2,
|
|
19807
|
+
expectedTarget: target,
|
|
19808
|
+
ok: false,
|
|
19809
|
+
state: "missing",
|
|
19810
|
+
actualTarget: null
|
|
19811
|
+
});
|
|
19466
19812
|
continue;
|
|
19467
19813
|
}
|
|
19468
19814
|
if (actual === target) {
|
|
19469
|
-
out.push({
|
|
19815
|
+
out.push({
|
|
19816
|
+
path: path2,
|
|
19817
|
+
expectedTarget: target,
|
|
19818
|
+
ok: true,
|
|
19819
|
+
state: "ok",
|
|
19820
|
+
actualTarget: actual
|
|
19821
|
+
});
|
|
19470
19822
|
} else {
|
|
19471
19823
|
out.push({
|
|
19472
19824
|
path: path2,
|
|
@@ -19514,9 +19866,13 @@ function describeAge(lastSync) {
|
|
|
19514
19866
|
}
|
|
19515
19867
|
async function gitPullFfOnly(workspacePath) {
|
|
19516
19868
|
try {
|
|
19517
|
-
const { stderr } = await execFileP5(
|
|
19518
|
-
|
|
19519
|
-
|
|
19869
|
+
const { stderr } = await execFileP5(
|
|
19870
|
+
"git",
|
|
19871
|
+
["-C", workspacePath, "pull", "--ff-only"],
|
|
19872
|
+
{
|
|
19873
|
+
encoding: "utf8"
|
|
19874
|
+
}
|
|
19875
|
+
);
|
|
19520
19876
|
return { ok: true, stderr };
|
|
19521
19877
|
} catch (err) {
|
|
19522
19878
|
const e = err;
|
|
@@ -19802,7 +20158,11 @@ async function collectDriftFindings(state, cwd) {
|
|
|
19802
20158
|
};
|
|
19803
20159
|
}
|
|
19804
20160
|
}
|
|
19805
|
-
return {
|
|
20161
|
+
return {
|
|
20162
|
+
kind: "wrong_state",
|
|
20163
|
+
ok: true,
|
|
20164
|
+
summary: "state matches workspace"
|
|
20165
|
+
};
|
|
19806
20166
|
}
|
|
19807
20167
|
const better = cloneList.find((p) => p !== state.workspace_path);
|
|
19808
20168
|
if (better) {
|
|
@@ -19813,7 +20173,11 @@ async function collectDriftFindings(state, cwd) {
|
|
|
19813
20173
|
data: { recorded: state.workspace_path, actual: better }
|
|
19814
20174
|
};
|
|
19815
20175
|
}
|
|
19816
|
-
return {
|
|
20176
|
+
return {
|
|
20177
|
+
kind: "wrong_state",
|
|
20178
|
+
ok: true,
|
|
20179
|
+
summary: "no alternate clone to switch to"
|
|
20180
|
+
};
|
|
19817
20181
|
})();
|
|
19818
20182
|
const adapterFinding = await (async () => {
|
|
19819
20183
|
if (!stateExists) {
|
|
@@ -19826,7 +20190,11 @@ async function collectDriftFindings(state, cwd) {
|
|
|
19826
20190
|
const adapters = await checkAdapters(state.workspace_path);
|
|
19827
20191
|
const broken = adapters.filter((a) => !a.ok);
|
|
19828
20192
|
if (broken.length === 0) {
|
|
19829
|
-
return {
|
|
20193
|
+
return {
|
|
20194
|
+
kind: "missing_adapters",
|
|
20195
|
+
ok: true,
|
|
20196
|
+
summary: "all adapter symlinks present"
|
|
20197
|
+
};
|
|
19830
20198
|
}
|
|
19831
20199
|
return {
|
|
19832
20200
|
kind: "missing_adapters",
|
|
@@ -19932,7 +20300,9 @@ function slugMatch(a, b) {
|
|
|
19932
20300
|
}
|
|
19933
20301
|
async function healStaleState(finding, state, opts) {
|
|
19934
20302
|
console.log("");
|
|
19935
|
-
console.log(
|
|
20303
|
+
console.log(
|
|
20304
|
+
` \u2717 Recorded workspace path missing: ${finding.data?.workspace_path}`
|
|
20305
|
+
);
|
|
19936
20306
|
if (opts.quiet) return state;
|
|
19937
20307
|
const want = await confirm(" Re-run init to re-clone?", true);
|
|
19938
20308
|
if (!want) {
|
|
@@ -19973,14 +20343,19 @@ async function healMultiClone(finding, state, opts) {
|
|
|
19973
20343
|
if (nonCanonical.length > 0) {
|
|
19974
20344
|
console.log(" Other clones:");
|
|
19975
20345
|
for (const p of nonCanonical) console.log(` \u2022 ${p}`);
|
|
19976
|
-
const wantDelete = await confirm(
|
|
20346
|
+
const wantDelete = await confirm(
|
|
20347
|
+
" Delete the non-canonical clones?",
|
|
20348
|
+
false
|
|
20349
|
+
);
|
|
19977
20350
|
if (wantDelete) {
|
|
19978
20351
|
for (const p of nonCanonical) {
|
|
19979
20352
|
try {
|
|
19980
20353
|
await rm4(p, { recursive: true, force: true });
|
|
19981
20354
|
console.log(` \u2713 removed ${p}`);
|
|
19982
20355
|
} catch (err) {
|
|
19983
|
-
console.log(
|
|
20356
|
+
console.log(
|
|
20357
|
+
` \u2717 couldn't remove ${p}: ${err.message}`
|
|
20358
|
+
);
|
|
19984
20359
|
}
|
|
19985
20360
|
}
|
|
19986
20361
|
} else {
|
|
@@ -19994,7 +20369,9 @@ async function healWrongState(finding, state, opts) {
|
|
|
19994
20369
|
const recorded = finding.data?.recorded;
|
|
19995
20370
|
if (!actual || !recorded) return state;
|
|
19996
20371
|
console.log("");
|
|
19997
|
-
console.log(
|
|
20372
|
+
console.log(
|
|
20373
|
+
` \u2717 state.workspace_path = ${recorded}, but workspace lives at ${actual}`
|
|
20374
|
+
);
|
|
19998
20375
|
if (opts.quiet) return state;
|
|
19999
20376
|
const useActual = opts.autoHeal ? true : await confirm(` Update state.json \u2192 ${actual}?`, true);
|
|
20000
20377
|
if (useActual === null || !useActual) {
|
|
@@ -20013,7 +20390,9 @@ async function healMissingAdapters(finding, state, opts) {
|
|
|
20013
20390
|
if (opts.quiet) return state;
|
|
20014
20391
|
const want = opts.autoHeal ? true : await confirm(" Add the missing adapter symlinks?", true);
|
|
20015
20392
|
if (!want) {
|
|
20016
|
-
console.log(
|
|
20393
|
+
console.log(
|
|
20394
|
+
" Skipped. Add manually with `ln -s ../skills <path>` from your workspace root."
|
|
20395
|
+
);
|
|
20017
20396
|
return state;
|
|
20018
20397
|
}
|
|
20019
20398
|
try {
|
|
@@ -20030,7 +20409,9 @@ async function healMcpDrift(finding, state, opts) {
|
|
|
20030
20409
|
console.log(` \u2717 ${finding.summary}`);
|
|
20031
20410
|
if (reason === "unreachable") {
|
|
20032
20411
|
console.log(" Bamboo MCP server is unreachable \u2014 likely transient.");
|
|
20033
|
-
console.log(
|
|
20412
|
+
console.log(
|
|
20413
|
+
" Try again in a few minutes, or check status.withbamboo.com."
|
|
20414
|
+
);
|
|
20034
20415
|
return state;
|
|
20035
20416
|
}
|
|
20036
20417
|
if (opts.quiet) return state;
|
|
@@ -20041,8 +20422,10 @@ async function healMcpDrift(finding, state, opts) {
|
|
|
20041
20422
|
}
|
|
20042
20423
|
const creds = await readCredentials();
|
|
20043
20424
|
if (!creds) {
|
|
20044
|
-
console.log(
|
|
20045
|
-
|
|
20425
|
+
console.log(
|
|
20426
|
+
" \u2717 No Bamboo credentials \u2014 run `bamboo-agents login` first."
|
|
20427
|
+
);
|
|
20428
|
+
return state;
|
|
20046
20429
|
}
|
|
20047
20430
|
let token;
|
|
20048
20431
|
try {
|
|
@@ -20050,11 +20433,15 @@ async function healMcpDrift(finding, state, opts) {
|
|
|
20050
20433
|
} catch (err) {
|
|
20051
20434
|
const message = err instanceof Error ? err.message : "unknown error";
|
|
20052
20435
|
if (err instanceof ApiError && err.errorCode === "no_active_install") {
|
|
20053
|
-
console.log(
|
|
20436
|
+
console.log(
|
|
20437
|
+
" \u2717 GitHub App isn't installed \u2014 run `bamboo-agents login` first."
|
|
20438
|
+
);
|
|
20054
20439
|
return state;
|
|
20055
20440
|
}
|
|
20056
20441
|
if (err instanceof ApiError && err.errorCode === "no_workspace_repo") {
|
|
20057
|
-
console.log(
|
|
20442
|
+
console.log(
|
|
20443
|
+
" \u2717 Workspace repo doesn't exist \u2014 run `bamboo-agents init` first."
|
|
20444
|
+
);
|
|
20058
20445
|
return state;
|
|
20059
20446
|
}
|
|
20060
20447
|
console.log(` \u2717 Could not mint Bamboo MCP API key: ${message}`);
|
|
@@ -20065,6 +20452,10 @@ async function healMcpDrift(finding, state, opts) {
|
|
|
20065
20452
|
url: token.mcp_url,
|
|
20066
20453
|
headers: { Authorization: `Bearer ${token.api_key}` }
|
|
20067
20454
|
};
|
|
20455
|
+
await rewriteMcpClients(entry);
|
|
20456
|
+
return state;
|
|
20457
|
+
}
|
|
20458
|
+
async function rewriteMcpClients(entry) {
|
|
20068
20459
|
const clients = ["claude-code", "claude-desktop"];
|
|
20069
20460
|
let writeCount = 0;
|
|
20070
20461
|
for (const client of clients) {
|
|
@@ -20086,9 +20477,10 @@ async function healMcpDrift(finding, state, opts) {
|
|
|
20086
20477
|
}
|
|
20087
20478
|
}
|
|
20088
20479
|
if (writeCount === 0) {
|
|
20089
|
-
console.log(
|
|
20480
|
+
console.log(
|
|
20481
|
+
" \u2717 No client configs were writable. Is Claude Code installed?"
|
|
20482
|
+
);
|
|
20090
20483
|
}
|
|
20091
|
-
return state;
|
|
20092
20484
|
}
|
|
20093
20485
|
async function healStaleSync(_finding, state, opts) {
|
|
20094
20486
|
console.log("");
|
|
@@ -20110,6 +20502,29 @@ async function healStaleSync(_finding, state, opts) {
|
|
|
20110
20502
|
console.log(" Run `git pull` manually to diagnose.");
|
|
20111
20503
|
return state;
|
|
20112
20504
|
}
|
|
20505
|
+
function printDoctorChecks(baseChecks, drift) {
|
|
20506
|
+
console.log("");
|
|
20507
|
+
for (const c of baseChecks) {
|
|
20508
|
+
const mark = c.ok ? "\u2713" : "\u2717";
|
|
20509
|
+
console.log(` ${mark} ${c.name.padEnd(28)} ${c.detail}`);
|
|
20510
|
+
}
|
|
20511
|
+
if (drift) {
|
|
20512
|
+
console.log("");
|
|
20513
|
+
const labels = {
|
|
20514
|
+
stale_state: "Workspace path on disk",
|
|
20515
|
+
multi_clone: "Single clone",
|
|
20516
|
+
wrong_state: "State matches workspace",
|
|
20517
|
+
missing_adapters: "Cross-tool adapters",
|
|
20518
|
+
stale_sync: "Recent sync",
|
|
20519
|
+
mcp_drift: "Bamboo MCP installed"
|
|
20520
|
+
};
|
|
20521
|
+
for (const f of drift) {
|
|
20522
|
+
const mark = f.ok ? "\u2713" : "\u2717";
|
|
20523
|
+
console.log(` ${mark} ${labels[f.kind].padEnd(28)} ${f.summary}`);
|
|
20524
|
+
}
|
|
20525
|
+
}
|
|
20526
|
+
console.log("");
|
|
20527
|
+
}
|
|
20113
20528
|
async function runDoctor(options = {}) {
|
|
20114
20529
|
const opts = {
|
|
20115
20530
|
quiet: options.quiet === true,
|
|
@@ -20127,34 +20542,18 @@ async function runDoctor(options = {}) {
|
|
|
20127
20542
|
if (opts.quiet) {
|
|
20128
20543
|
const payload = {
|
|
20129
20544
|
ok: baseChecks.every((c) => c.ok) && (drift ?? []).every((d) => d.ok),
|
|
20130
|
-
checks: baseChecks.map((c) => ({
|
|
20545
|
+
checks: baseChecks.map((c) => ({
|
|
20546
|
+
name: c.name,
|
|
20547
|
+
ok: c.ok,
|
|
20548
|
+
detail: c.detail
|
|
20549
|
+
})),
|
|
20131
20550
|
drift: drift ?? []
|
|
20132
20551
|
};
|
|
20133
20552
|
console.log(JSON.stringify(payload, null, 2));
|
|
20134
20553
|
process.exit(payload.ok ? 0 : 1);
|
|
20135
20554
|
return;
|
|
20136
20555
|
}
|
|
20137
|
-
|
|
20138
|
-
for (const c of baseChecks) {
|
|
20139
|
-
const mark = c.ok ? "\u2713" : "\u2717";
|
|
20140
|
-
console.log(` ${mark} ${c.name.padEnd(28)} ${c.detail}`);
|
|
20141
|
-
}
|
|
20142
|
-
if (drift) {
|
|
20143
|
-
console.log("");
|
|
20144
|
-
const labels = {
|
|
20145
|
-
stale_state: "Workspace path on disk",
|
|
20146
|
-
multi_clone: "Single clone",
|
|
20147
|
-
wrong_state: "State matches workspace",
|
|
20148
|
-
missing_adapters: "Cross-tool adapters",
|
|
20149
|
-
stale_sync: "Recent sync",
|
|
20150
|
-
mcp_drift: "Bamboo MCP installed"
|
|
20151
|
-
};
|
|
20152
|
-
for (const f of drift) {
|
|
20153
|
-
const mark = f.ok ? "\u2713" : "\u2717";
|
|
20154
|
-
console.log(` ${mark} ${labels[f.kind].padEnd(28)} ${f.summary}`);
|
|
20155
|
-
}
|
|
20156
|
-
}
|
|
20157
|
-
console.log("");
|
|
20556
|
+
printDoctorChecks(baseChecks, drift);
|
|
20158
20557
|
const remaining = (drift ?? []).filter((f) => !f.ok);
|
|
20159
20558
|
if (remaining.length === 0) {
|
|
20160
20559
|
const baseFailures = baseChecks.filter((c) => !c.ok).length;
|
|
@@ -20165,7 +20564,12 @@ async function runDoctor(options = {}) {
|
|
|
20165
20564
|
console.log(" All checks passing.");
|
|
20166
20565
|
return;
|
|
20167
20566
|
}
|
|
20168
|
-
console.log(
|
|
20567
|
+
console.log(
|
|
20568
|
+
` ${remaining.length} drift issue(s) detected \u2014 let's fix them.`
|
|
20569
|
+
);
|
|
20570
|
+
await healDoctorDrift(state, remaining, opts, drift);
|
|
20571
|
+
}
|
|
20572
|
+
async function healDoctorDrift(state, remaining, opts, drift) {
|
|
20169
20573
|
let cur = state;
|
|
20170
20574
|
const order = [
|
|
20171
20575
|
"stale_state",
|
|
@@ -20207,7 +20611,9 @@ async function runDoctor(options = {}) {
|
|
|
20207
20611
|
console.log(" \u2713 Workspace healthy.");
|
|
20208
20612
|
return;
|
|
20209
20613
|
}
|
|
20210
|
-
console.log(
|
|
20614
|
+
console.log(
|
|
20615
|
+
` ${stillBroken.length} issue(s) remain \u2014 re-run \`bamboo-agents doctor\` after addressing.`
|
|
20616
|
+
);
|
|
20211
20617
|
process.exit(1);
|
|
20212
20618
|
}
|
|
20213
20619
|
var init_doctor = __esm({
|
|
@@ -20264,7 +20670,10 @@ async function runUpdate(options = {}) {
|
|
|
20264
20670
|
return;
|
|
20265
20671
|
}
|
|
20266
20672
|
human("", opts);
|
|
20267
|
-
human(
|
|
20673
|
+
human(
|
|
20674
|
+
" Your local copy has drifted in a way that can't auto-update.",
|
|
20675
|
+
opts
|
|
20676
|
+
);
|
|
20268
20677
|
human(
|
|
20269
20678
|
" Your workspace is a cached copy of the cloud \u2014 the safe fix is to refresh it from scratch.",
|
|
20270
20679
|
opts
|
|
@@ -20304,7 +20713,11 @@ async function runUpdate(options = {}) {
|
|
|
20304
20713
|
}
|
|
20305
20714
|
await bumpLastSync();
|
|
20306
20715
|
emitSuccess(
|
|
20307
|
-
{
|
|
20716
|
+
{
|
|
20717
|
+
status: "up_to_date",
|
|
20718
|
+
workspace: workspacePath,
|
|
20719
|
+
saved_before_update: unsaved
|
|
20720
|
+
},
|
|
20308
20721
|
opts,
|
|
20309
20722
|
() => {
|
|
20310
20723
|
human("", opts);
|
|
@@ -20328,6 +20741,53 @@ var init_update = __esm({
|
|
|
20328
20741
|
// src/lib/skills-local.ts
|
|
20329
20742
|
import { readdir as readdir3, readFile as readFile6, stat as stat2 } from "node:fs/promises";
|
|
20330
20743
|
import { join as join5 } from "node:path";
|
|
20744
|
+
function foldScalarLines(collected) {
|
|
20745
|
+
const parts = [];
|
|
20746
|
+
let buf = [];
|
|
20747
|
+
for (const c of collected) {
|
|
20748
|
+
if (c === "") {
|
|
20749
|
+
if (buf.length) {
|
|
20750
|
+
parts.push(buf.join(" "));
|
|
20751
|
+
buf = [];
|
|
20752
|
+
}
|
|
20753
|
+
parts.push("");
|
|
20754
|
+
} else buf.push(c);
|
|
20755
|
+
}
|
|
20756
|
+
if (buf.length) parts.push(buf.join(" "));
|
|
20757
|
+
return parts.join("\n").replace(/\n+/g, (m) => m.length > 1 ? "\n\n" : "\n");
|
|
20758
|
+
}
|
|
20759
|
+
function readBlockScalar(lines, start, style, chomp) {
|
|
20760
|
+
const collected = [];
|
|
20761
|
+
let nextIndex = start;
|
|
20762
|
+
while (nextIndex < lines.length) {
|
|
20763
|
+
const next = lines[nextIndex];
|
|
20764
|
+
if (next.trim() === "") {
|
|
20765
|
+
collected.push("");
|
|
20766
|
+
nextIndex++;
|
|
20767
|
+
continue;
|
|
20768
|
+
}
|
|
20769
|
+
if (!/^\s/.test(next)) break;
|
|
20770
|
+
collected.push(next.replace(/^\s+/, ""));
|
|
20771
|
+
nextIndex++;
|
|
20772
|
+
}
|
|
20773
|
+
while (collected.length && collected[collected.length - 1] === "")
|
|
20774
|
+
collected.pop();
|
|
20775
|
+
let value = style === ">" ? foldScalarLines(collected) : collected.join("\n");
|
|
20776
|
+
if (chomp !== "-") value += "\n";
|
|
20777
|
+
return { value, next: nextIndex };
|
|
20778
|
+
}
|
|
20779
|
+
function parseSimpleValue(raw) {
|
|
20780
|
+
let value = raw;
|
|
20781
|
+
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'"))
|
|
20782
|
+
value = value.slice(1, -1);
|
|
20783
|
+
if (value.startsWith("[") && value.endsWith("]")) {
|
|
20784
|
+
const inner = value.slice(1, -1).trim();
|
|
20785
|
+
return inner ? inner.split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")) : [];
|
|
20786
|
+
}
|
|
20787
|
+
if (value === "true") return true;
|
|
20788
|
+
if (value === "false") return false;
|
|
20789
|
+
return value;
|
|
20790
|
+
}
|
|
20331
20791
|
function parseSimpleFrontmatter(raw) {
|
|
20332
20792
|
const text = raw.replace(/\r\n/g, "\n");
|
|
20333
20793
|
const m = text.match(/^---\n([\s\S]*?)\n---\n?([\s\S]*)$/);
|
|
@@ -20346,68 +20806,21 @@ function parseSimpleFrontmatter(raw) {
|
|
|
20346
20806
|
const colon = line.indexOf(":");
|
|
20347
20807
|
if (colon < 0) continue;
|
|
20348
20808
|
const key = line.slice(0, colon).trim();
|
|
20349
|
-
|
|
20809
|
+
const value = line.slice(colon + 1).trim();
|
|
20350
20810
|
if (!key) continue;
|
|
20351
20811
|
const blockMatch = value.match(/^([>|])([+-]?)\s*$/);
|
|
20352
20812
|
if (blockMatch) {
|
|
20353
|
-
const
|
|
20354
|
-
|
|
20355
|
-
|
|
20356
|
-
|
|
20357
|
-
|
|
20358
|
-
|
|
20359
|
-
|
|
20360
|
-
|
|
20361
|
-
continue;
|
|
20362
|
-
}
|
|
20363
|
-
if (!/^\s/.test(next)) break;
|
|
20364
|
-
collected.push(next.replace(/^\s+/, ""));
|
|
20365
|
-
i++;
|
|
20366
|
-
}
|
|
20367
|
-
while (collected.length && collected[collected.length - 1] === "") {
|
|
20368
|
-
collected.pop();
|
|
20369
|
-
}
|
|
20370
|
-
let folded;
|
|
20371
|
-
if (style === ">") {
|
|
20372
|
-
const parts = [];
|
|
20373
|
-
let buf = [];
|
|
20374
|
-
for (const c of collected) {
|
|
20375
|
-
if (c === "") {
|
|
20376
|
-
if (buf.length) {
|
|
20377
|
-
parts.push(buf.join(" "));
|
|
20378
|
-
buf = [];
|
|
20379
|
-
}
|
|
20380
|
-
parts.push("");
|
|
20381
|
-
} else {
|
|
20382
|
-
buf.push(c);
|
|
20383
|
-
}
|
|
20384
|
-
}
|
|
20385
|
-
if (buf.length) parts.push(buf.join(" "));
|
|
20386
|
-
folded = parts.join("\n").replace(/\n+/g, (m2) => m2.length > 1 ? "\n\n" : "\n");
|
|
20387
|
-
} else {
|
|
20388
|
-
folded = collected.join("\n");
|
|
20389
|
-
}
|
|
20390
|
-
if (chomp !== "-") folded += "\n";
|
|
20391
|
-
data[key] = folded;
|
|
20392
|
-
continue;
|
|
20393
|
-
}
|
|
20394
|
-
if (value.startsWith('"') && value.endsWith('"') || value.startsWith("'") && value.endsWith("'")) {
|
|
20395
|
-
value = value.slice(1, -1);
|
|
20396
|
-
}
|
|
20397
|
-
if (value.startsWith("[") && value.endsWith("]")) {
|
|
20398
|
-
const inner = value.slice(1, -1).trim();
|
|
20399
|
-
data[key] = inner ? inner.split(",").map((s) => s.trim().replace(/^["']|["']$/g, "")) : [];
|
|
20400
|
-
continue;
|
|
20401
|
-
}
|
|
20402
|
-
if (value === "true") {
|
|
20403
|
-
data[key] = true;
|
|
20404
|
-
continue;
|
|
20405
|
-
}
|
|
20406
|
-
if (value === "false") {
|
|
20407
|
-
data[key] = false;
|
|
20813
|
+
const scalar = readBlockScalar(
|
|
20814
|
+
lines,
|
|
20815
|
+
i,
|
|
20816
|
+
blockMatch[1],
|
|
20817
|
+
blockMatch[2] ?? ""
|
|
20818
|
+
);
|
|
20819
|
+
data[key] = scalar.value;
|
|
20820
|
+
i = scalar.next;
|
|
20408
20821
|
continue;
|
|
20409
20822
|
}
|
|
20410
|
-
data[key] = value;
|
|
20823
|
+
data[key] = parseSimpleValue(value);
|
|
20411
20824
|
}
|
|
20412
20825
|
return { data, body };
|
|
20413
20826
|
}
|
|
@@ -20421,15 +20834,14 @@ function parseSkillContent(raw, sourcePath) {
|
|
|
20421
20834
|
const errors = [];
|
|
20422
20835
|
if (!name) errors.push("missing name");
|
|
20423
20836
|
if (name.length > 64) errors.push(`name > 64 chars (${name.length})`);
|
|
20424
|
-
if (name && !/^[a-z0-9-]+$/.test(name))
|
|
20837
|
+
if (name && !/^[a-z0-9-]+$/.test(name))
|
|
20838
|
+
errors.push("name must be kebab-case");
|
|
20425
20839
|
if (!description) errors.push("missing description");
|
|
20426
20840
|
if (description.length > 1024)
|
|
20427
20841
|
errors.push(`description > 1024 chars (${description.length})`);
|
|
20428
20842
|
if (body.split("\n").length > 500) errors.push("body > 500 lines");
|
|
20429
20843
|
if (errors.length) {
|
|
20430
|
-
console.warn(
|
|
20431
|
-
`bamboo-agents: skipping ${sourcePath}: ${errors.join("; ")}`
|
|
20432
|
-
);
|
|
20844
|
+
console.warn(`bamboo-agents: skipping ${sourcePath}: ${errors.join("; ")}`);
|
|
20433
20845
|
return null;
|
|
20434
20846
|
}
|
|
20435
20847
|
return {
|
|
@@ -20573,10 +20985,7 @@ async function runSkillsListImpl(options = {}) {
|
|
|
20573
20985
|
const list = await listCliAgents(bambooSession);
|
|
20574
20986
|
return printAgentNotFound(options.agent, list.agents);
|
|
20575
20987
|
}
|
|
20576
|
-
const { available, installed, custom: custom2, subscriptions } = await getAgentSkills(
|
|
20577
|
-
bambooSession,
|
|
20578
|
-
resolved.id
|
|
20579
|
-
);
|
|
20988
|
+
const { available, installed, custom: custom2, subscriptions } = await getAgentSkills(bambooSession, resolved.id);
|
|
20580
20989
|
const subscribedSet = new Set(subscriptions);
|
|
20581
20990
|
const filtered = [...installed, ...custom2, ...available].filter(
|
|
20582
20991
|
(s) => subscribedSet.has(s.name)
|
|
@@ -20629,10 +21038,7 @@ async function runSkillsListImpl(options = {}) {
|
|
|
20629
21038
|
console.log("");
|
|
20630
21039
|
return;
|
|
20631
21040
|
}
|
|
20632
|
-
const nameCol = Math.max(
|
|
20633
|
-
"name".length,
|
|
20634
|
-
...skills2.map((s) => s.name.length)
|
|
20635
|
-
);
|
|
21041
|
+
const nameCol = Math.max("name".length, ...skills2.map((s) => s.name.length));
|
|
20636
21042
|
const header = ` ${padRight("name", nameCol)} description`;
|
|
20637
21043
|
const rule = " " + "\u2500".repeat(nameCol) + " " + "\u2500".repeat(Math.min(60, 80 - nameCol));
|
|
20638
21044
|
console.log("");
|
|
@@ -20675,10 +21081,8 @@ function printSkillToStdout(skill) {
|
|
|
20675
21081
|
process.stdout.write("disable-model-invocation: true\n");
|
|
20676
21082
|
}
|
|
20677
21083
|
if (skill.allowedTools.length > 0) {
|
|
20678
|
-
process.stdout.write(
|
|
20679
|
-
|
|
20680
|
-
`
|
|
20681
|
-
);
|
|
21084
|
+
process.stdout.write(`allowed-tools: [${skill.allowedTools.join(", ")}]
|
|
21085
|
+
`);
|
|
20682
21086
|
}
|
|
20683
21087
|
process.stdout.write("---\n");
|
|
20684
21088
|
process.stdout.write("\n");
|
|
@@ -20720,9 +21124,7 @@ async function runSubscribeOp(action, agentIdentifier, skillName) {
|
|
|
20720
21124
|
console.error(
|
|
20721
21125
|
`bamboo-agents: \`skills ${action}\` requires an agent identifier and a skill name.`
|
|
20722
21126
|
);
|
|
20723
|
-
console.error(
|
|
20724
|
-
`Example: bamboo-agents skills ${action} "Paid Ads" walk-pr`
|
|
20725
|
-
);
|
|
21127
|
+
console.error(`Example: bamboo-agents skills ${action} "Paid Ads" walk-pr`);
|
|
20726
21128
|
process.exit(2);
|
|
20727
21129
|
}
|
|
20728
21130
|
const bambooSession = await requireSession2();
|
|
@@ -20915,11 +21317,17 @@ function padRight2(s, n) {
|
|
|
20915
21317
|
}
|
|
20916
21318
|
function printHuman(data, opts) {
|
|
20917
21319
|
human("", opts);
|
|
20918
|
-
human(
|
|
21320
|
+
human(
|
|
21321
|
+
" Knowledge slots \u2014 where a file belongs in the workspace repo:",
|
|
21322
|
+
opts
|
|
21323
|
+
);
|
|
20919
21324
|
human("", opts);
|
|
20920
21325
|
const kindW = Math.max(4, ...data.kinds.map((k) => k.kind.length));
|
|
20921
21326
|
const scopeW = Math.max(5, ...data.kinds.map((k) => k.scope.length));
|
|
20922
|
-
human(
|
|
21327
|
+
human(
|
|
21328
|
+
` ${padRight2("KIND", kindW)} ${padRight2("SCOPE", scopeW)} PATH`,
|
|
21329
|
+
opts
|
|
21330
|
+
);
|
|
20923
21331
|
for (const k of data.kinds) {
|
|
20924
21332
|
const pinned = k.filename_pinned ? " (filename pinned)" : "";
|
|
20925
21333
|
human(
|
|
@@ -20933,11 +21341,20 @@ function printHuman(data, opts) {
|
|
|
20933
21341
|
human(" Dimensions (tag freshly-written files with these):", opts);
|
|
20934
21342
|
const keyW = Math.max(3, ...data.dimensions.map((d) => d.key.length));
|
|
20935
21343
|
for (const d of data.dimensions) {
|
|
20936
|
-
human(
|
|
21344
|
+
human(
|
|
21345
|
+
` ${padRight2(d.key, keyW)} ${d.label} [${d.tags.join(", ")}]`,
|
|
21346
|
+
opts
|
|
21347
|
+
);
|
|
20937
21348
|
}
|
|
20938
21349
|
human("", opts);
|
|
20939
|
-
human(
|
|
20940
|
-
|
|
21350
|
+
human(
|
|
21351
|
+
" Substitute {brand} / {agent} with your workspace slugs, then write",
|
|
21352
|
+
opts
|
|
21353
|
+
);
|
|
21354
|
+
human(
|
|
21355
|
+
" the file natively and push a branch \u2014 routeWrite merges or queues it.",
|
|
21356
|
+
opts
|
|
21357
|
+
);
|
|
20941
21358
|
human("", opts);
|
|
20942
21359
|
}
|
|
20943
21360
|
async function runKnowledgeSlots(options) {
|
|
@@ -20989,7 +21406,10 @@ function printSaveResult(result, path2, opts) {
|
|
|
20989
21406
|
);
|
|
20990
21407
|
break;
|
|
20991
21408
|
case "noop":
|
|
20992
|
-
human(
|
|
21409
|
+
human(
|
|
21410
|
+
` \u2022 Nothing to do${result.reason ? ` (${result.reason})` : ""}.`,
|
|
21411
|
+
opts
|
|
21412
|
+
);
|
|
20993
21413
|
break;
|
|
20994
21414
|
}
|
|
20995
21415
|
}
|
|
@@ -21032,7 +21452,10 @@ async function runKnowledgeSave(options) {
|
|
|
21032
21452
|
});
|
|
21033
21453
|
} catch (err) {
|
|
21034
21454
|
emitError(
|
|
21035
|
-
{
|
|
21455
|
+
{
|
|
21456
|
+
code: "save_failed",
|
|
21457
|
+
message: `save failed: ${err.message}`
|
|
21458
|
+
},
|
|
21036
21459
|
opts,
|
|
21037
21460
|
1
|
|
21038
21461
|
);
|
|
@@ -21066,9 +21489,12 @@ var init_knowledge = __esm({
|
|
|
21066
21489
|
async function resolveOrganizationSelection(requested, listOrganizations) {
|
|
21067
21490
|
const query = requested.trim();
|
|
21068
21491
|
if (!query) {
|
|
21069
|
-
throw Object.assign(
|
|
21070
|
-
|
|
21071
|
-
|
|
21492
|
+
throw Object.assign(
|
|
21493
|
+
new Error("Pass the customer organization with --org."),
|
|
21494
|
+
{
|
|
21495
|
+
code: "organization_scope_required"
|
|
21496
|
+
}
|
|
21497
|
+
);
|
|
21072
21498
|
}
|
|
21073
21499
|
if (UUID.test(query)) return { id: query.toLowerCase() };
|
|
21074
21500
|
const { orgs } = await listOrganizations();
|
|
@@ -21078,7 +21504,9 @@ async function resolveOrganizationSelection(requested, listOrganizations) {
|
|
|
21078
21504
|
if (matches.length === 1) return matches[0];
|
|
21079
21505
|
if (matches.length === 0) {
|
|
21080
21506
|
throw Object.assign(
|
|
21081
|
-
new Error(
|
|
21507
|
+
new Error(
|
|
21508
|
+
`No organization matches "${query}". Run \`bamboo-agents inbox organizations ${JSON.stringify(query)}\` to inspect available organizations.`
|
|
21509
|
+
),
|
|
21082
21510
|
{ code: "organization_scope_not_found" }
|
|
21083
21511
|
);
|
|
21084
21512
|
}
|
|
@@ -21091,14 +21519,24 @@ async function resolveOrganizationSelection(requested, listOrganizations) {
|
|
|
21091
21519
|
}
|
|
21092
21520
|
async function resolveCredentialOrganization(session, selector) {
|
|
21093
21521
|
if (!session.startsWith("bam_")) {
|
|
21094
|
-
if (!selector)
|
|
21095
|
-
|
|
21522
|
+
if (!selector)
|
|
21523
|
+
throw Object.assign(
|
|
21524
|
+
new Error("Pass the customer organization with --org."),
|
|
21525
|
+
{ code: "organization_scope_required" }
|
|
21526
|
+
);
|
|
21527
|
+
return resolveOrganizationSelection(
|
|
21528
|
+
selector,
|
|
21529
|
+
() => listInboxOrganizations(session)
|
|
21530
|
+
);
|
|
21096
21531
|
}
|
|
21097
21532
|
const bound = await getCliOrganizationScope(session);
|
|
21098
21533
|
if (selector) {
|
|
21099
21534
|
const requested = selector.trim().toLowerCase();
|
|
21100
21535
|
if (requested !== bound.effective_org_id.toLowerCase() && requested !== bound.effective_org_name.toLowerCase()) {
|
|
21101
|
-
throw Object.assign(
|
|
21536
|
+
throw Object.assign(
|
|
21537
|
+
new Error("This API key is bound to a different organization."),
|
|
21538
|
+
{ code: "organization_scope_mismatch" }
|
|
21539
|
+
);
|
|
21102
21540
|
}
|
|
21103
21541
|
}
|
|
21104
21542
|
return { id: bound.effective_org_id, name: bound.effective_org_name };
|
|
@@ -21140,9 +21578,12 @@ function fail(error, output) {
|
|
|
21140
21578
|
const value = error;
|
|
21141
21579
|
const invalidInput = error instanceof SyntaxError || error instanceof ZodError;
|
|
21142
21580
|
const unknownOutcome = error.name === "AbortError";
|
|
21581
|
+
let fallbackCode = "inbox_operation_failed";
|
|
21582
|
+
if (unknownOutcome) fallbackCode = "unknown_outcome";
|
|
21583
|
+
else if (invalidInput) fallbackCode = "invalid_input";
|
|
21143
21584
|
emitError(
|
|
21144
21585
|
{
|
|
21145
|
-
code: value.code ?? value.errorCode ??
|
|
21586
|
+
code: value.code ?? value.errorCode ?? fallbackCode,
|
|
21146
21587
|
message: value.message ?? "Inbox operation failed."
|
|
21147
21588
|
},
|
|
21148
21589
|
output,
|
|
@@ -21173,12 +21614,24 @@ async function runInboxOperations(options) {
|
|
|
21173
21614
|
async function runInboxOrganizations(options) {
|
|
21174
21615
|
try {
|
|
21175
21616
|
const session = await inboxSession();
|
|
21176
|
-
const { orgs } = session.startsWith("bam_") ? {
|
|
21617
|
+
const { orgs } = session.startsWith("bam_") ? {
|
|
21618
|
+
orgs: [await getCliOrganizationScope(session)].map((scope) => ({
|
|
21619
|
+
id: scope.effective_org_id,
|
|
21620
|
+
name: scope.effective_org_name,
|
|
21621
|
+
status: "bound"
|
|
21622
|
+
}))
|
|
21623
|
+
} : await listInboxOrganizations(session);
|
|
21177
21624
|
const query = options.query?.trim() ?? "";
|
|
21178
21625
|
const normalized = query.toLowerCase();
|
|
21179
|
-
const organizations = query ? orgs.filter(
|
|
21180
|
-
|
|
21181
|
-
|
|
21626
|
+
const organizations = query ? orgs.filter(
|
|
21627
|
+
(org) => org.name.toLowerCase().includes(normalized) || org.id.toLowerCase().includes(normalized)
|
|
21628
|
+
) : orgs;
|
|
21629
|
+
for (const org of organizations)
|
|
21630
|
+
human(` ${org.name} (${org.id}) [${org.status}]`, options);
|
|
21631
|
+
emitSuccess(
|
|
21632
|
+
{ organizations, count: organizations.length, query: query || null },
|
|
21633
|
+
options
|
|
21634
|
+
);
|
|
21182
21635
|
} catch (error) {
|
|
21183
21636
|
fail(error, options);
|
|
21184
21637
|
}
|
|
@@ -21186,7 +21639,10 @@ async function runInboxOrganizations(options) {
|
|
|
21186
21639
|
async function runInboxMembers(options) {
|
|
21187
21640
|
try {
|
|
21188
21641
|
const session = await inboxSession();
|
|
21189
|
-
const organization = await resolveCredentialOrganization(
|
|
21642
|
+
const organization = await resolveCredentialOrganization(
|
|
21643
|
+
session,
|
|
21644
|
+
options.org
|
|
21645
|
+
);
|
|
21190
21646
|
const result = await listInboxMembers(session, organization.id);
|
|
21191
21647
|
if (result.scope.org_id !== organization.id) {
|
|
21192
21648
|
throw Object.assign(
|
|
@@ -21196,35 +21652,147 @@ async function runInboxMembers(options) {
|
|
|
21196
21652
|
}
|
|
21197
21653
|
const query = options.query?.trim() ?? "";
|
|
21198
21654
|
const normalized = query.toLowerCase();
|
|
21199
|
-
const exact = result.members.filter(
|
|
21200
|
-
|
|
21655
|
+
const exact = result.members.filter(
|
|
21656
|
+
(member) => member.display_name.toLowerCase() === normalized || member.email?.toLowerCase() === normalized || member.user_id.toLowerCase() === normalized
|
|
21657
|
+
);
|
|
21658
|
+
let matches = result.members;
|
|
21659
|
+
if (query) {
|
|
21660
|
+
matches = exact;
|
|
21661
|
+
if (exact.length === 0) {
|
|
21662
|
+
matches = result.members.filter(
|
|
21663
|
+
(member) => member.display_name.toLowerCase().includes(normalized) || member.email?.toLowerCase().includes(normalized) || member.user_id.toLowerCase().includes(normalized)
|
|
21664
|
+
);
|
|
21665
|
+
}
|
|
21666
|
+
}
|
|
21201
21667
|
if (query && matches.length !== 1) {
|
|
21202
|
-
const candidates = matches.map(
|
|
21668
|
+
const candidates = matches.map(
|
|
21669
|
+
(member) => `${member.display_name} (${member.email ?? "no email"}; ${member.user_id})`
|
|
21670
|
+
).join(", ");
|
|
21203
21671
|
throw Object.assign(
|
|
21204
|
-
new Error(
|
|
21205
|
-
|
|
21672
|
+
new Error(
|
|
21673
|
+
matches.length === 0 ? `No member of ${result.scope.org_name} matches "${query}".` : `Member "${query}" is ambiguous: ${candidates}. Use an exact email or user ID.`
|
|
21674
|
+
),
|
|
21675
|
+
{
|
|
21676
|
+
code: matches.length === 0 ? "member_not_found" : "member_ambiguous"
|
|
21677
|
+
}
|
|
21206
21678
|
);
|
|
21207
21679
|
}
|
|
21208
|
-
human(
|
|
21680
|
+
human(
|
|
21681
|
+
`Members of ${result.scope.org_name} (${result.scope.org_id})`,
|
|
21682
|
+
options
|
|
21683
|
+
);
|
|
21209
21684
|
for (const member of matches)
|
|
21210
|
-
human(
|
|
21211
|
-
|
|
21212
|
-
|
|
21213
|
-
|
|
21214
|
-
|
|
21215
|
-
|
|
21216
|
-
|
|
21217
|
-
|
|
21685
|
+
human(
|
|
21686
|
+
` ${member.display_name} (${member.email ?? "no email"}) \u2014 ${member.user_id} [${member.membership_role}]`,
|
|
21687
|
+
options
|
|
21688
|
+
);
|
|
21689
|
+
emitSuccess(
|
|
21690
|
+
{
|
|
21691
|
+
meta: result.meta,
|
|
21692
|
+
scope: result.scope,
|
|
21693
|
+
members: matches,
|
|
21694
|
+
count: matches.length,
|
|
21695
|
+
query: query || null
|
|
21696
|
+
},
|
|
21697
|
+
options
|
|
21698
|
+
);
|
|
21218
21699
|
} catch (error) {
|
|
21219
21700
|
fail(error, options);
|
|
21220
21701
|
}
|
|
21221
21702
|
}
|
|
21703
|
+
function mutationPreview(operation, input) {
|
|
21704
|
+
const brand2 = typeof input.brand_id === "string" ? { brand_id: input.brand_id } : {};
|
|
21705
|
+
if (operation === "opportunity.propose") {
|
|
21706
|
+
return InboxManagementCallSchema.parse({
|
|
21707
|
+
operation: "inbox.list",
|
|
21708
|
+
input: { ...brand2, limit: 1 }
|
|
21709
|
+
});
|
|
21710
|
+
}
|
|
21711
|
+
if (operation.startsWith("opportunity.")) {
|
|
21712
|
+
return InboxManagementCallSchema.parse({
|
|
21713
|
+
operation: "opportunity.get",
|
|
21714
|
+
input: { opportunity_id: input.opportunity_id, ...brand2 }
|
|
21715
|
+
});
|
|
21716
|
+
}
|
|
21717
|
+
if (operation.startsWith("fde_action.")) {
|
|
21718
|
+
return InboxManagementCallSchema.parse({
|
|
21719
|
+
operation: "fde_action.get",
|
|
21720
|
+
input: { id: input.id, ...brand2 }
|
|
21721
|
+
});
|
|
21722
|
+
}
|
|
21723
|
+
if (operation.startsWith("graph_recovery.")) {
|
|
21724
|
+
return InboxManagementCallSchema.parse({
|
|
21725
|
+
operation: "graph_recovery.get",
|
|
21726
|
+
input: { id: input.id, ...brand2 }
|
|
21727
|
+
});
|
|
21728
|
+
}
|
|
21729
|
+
if (operation.startsWith("annotation.")) {
|
|
21730
|
+
return InboxManagementCallSchema.parse({
|
|
21731
|
+
operation: "annotation.get",
|
|
21732
|
+
input: { task_id: input.task_id, ...brand2 }
|
|
21733
|
+
});
|
|
21734
|
+
}
|
|
21735
|
+
return InboxManagementCallSchema.parse({
|
|
21736
|
+
operation: "change.get",
|
|
21737
|
+
input: { pr_number: input.pr_number, ...brand2 }
|
|
21738
|
+
});
|
|
21739
|
+
}
|
|
21740
|
+
function mutationCommand(operation, input) {
|
|
21741
|
+
if (operation === "graph_recovery.select_predecessor")
|
|
21742
|
+
return "select_predecessor";
|
|
21743
|
+
if (operation === "annotation.complete") return "complete";
|
|
21744
|
+
return input.command;
|
|
21745
|
+
}
|
|
21746
|
+
function mutationSourceItem(isProposal, input) {
|
|
21747
|
+
if (isProposal) {
|
|
21748
|
+
return String(
|
|
21749
|
+
input.proposal && typeof input.proposal === "object" ? input.proposal.opportunity_key ?? "new stable-key proposal" : "new proposal"
|
|
21750
|
+
);
|
|
21751
|
+
}
|
|
21752
|
+
return String(
|
|
21753
|
+
input.opportunity_id ?? input.pr_number ?? input.id ?? input.task_id ?? "unknown"
|
|
21754
|
+
);
|
|
21755
|
+
}
|
|
21756
|
+
function inboxMutation(operation) {
|
|
21757
|
+
return operation.startsWith("change.") && !["change.get", "change.diff", "change.head"].includes(operation) || operation.startsWith("opportunity.") && operation !== "opportunity.get" || operation === "fde_action.command" || operation.startsWith("graph_recovery.") && operation !== "graph_recovery.get" || operation.startsWith("annotation.") && operation !== "annotation.get";
|
|
21758
|
+
}
|
|
21759
|
+
function mutationEffect(operation, input) {
|
|
21760
|
+
return operation === "annotation.command" ? ANNOTATION_COMMAND_EFFECTS[String(input.command)] : MUTATION_EFFECTS[operation];
|
|
21761
|
+
}
|
|
21762
|
+
function advertisedInboxCommands(preview, operation) {
|
|
21763
|
+
const receipt = preview.receipt && typeof preview.receipt === "object" ? preview.receipt : {};
|
|
21764
|
+
const action = receipt.action;
|
|
21765
|
+
const cycle = receipt.cycle;
|
|
21766
|
+
if (operation.startsWith("fde_action.")) return action?.supported_commands;
|
|
21767
|
+
if (operation.startsWith("graph_recovery."))
|
|
21768
|
+
return cycle?.next_legal_commands;
|
|
21769
|
+
if (operation.startsWith("annotation."))
|
|
21770
|
+
return receipt.task?.valid_next_actions;
|
|
21771
|
+
return null;
|
|
21772
|
+
}
|
|
21773
|
+
function inboxApprovalSummary(operation, input, preview, isProposal) {
|
|
21774
|
+
const recipient = input.recipient_name ? `; recipient: ${String(input.recipient_name)}` : "";
|
|
21775
|
+
const wording = input.approved_wording ? `; wording: ${JSON.stringify(input.approved_wording)}` : "";
|
|
21776
|
+
const mutation = mutationEffect(operation, input);
|
|
21777
|
+
const sourceItem = mutationSourceItem(isProposal, input);
|
|
21778
|
+
const command = input.command ? `; command: ${String(input.command)}` : "";
|
|
21779
|
+
const reason = input.reason ? `; reason: ${String(input.reason)}` : "";
|
|
21780
|
+
const commandId = input.command_id ? `; command ID: ${String(input.command_id)}` : "";
|
|
21781
|
+
return `Approval preview \u2014 organization: ${preview.scope.org_name} (${preview.scope.org_id}); brand: ${preview.scope.brand_name ?? "all brands"}; operation: ${operation}; source item: ${sourceItem}; source version: ${preview.source_version ?? "new proposal"}; effect: ${mutation?.effect ?? "unspecified"}; reversible: ${String(mutation?.reversible ?? "unspecified")}${command}${reason}${commandId}${recipient}${wording}`;
|
|
21782
|
+
}
|
|
21222
21783
|
async function runInboxManage(options) {
|
|
21223
21784
|
try {
|
|
21224
21785
|
const session = await inboxSession();
|
|
21225
|
-
const organization = await resolveCredentialOrganization(
|
|
21786
|
+
const organization = await resolveCredentialOrganization(
|
|
21787
|
+
session,
|
|
21788
|
+
options.org
|
|
21789
|
+
);
|
|
21226
21790
|
const orgId = organization.id;
|
|
21227
|
-
if (organization.name)
|
|
21791
|
+
if (organization.name)
|
|
21792
|
+
human(
|
|
21793
|
+
`Operating as organization: ${organization.name} (${orgId})`,
|
|
21794
|
+
options
|
|
21795
|
+
);
|
|
21228
21796
|
if (!InboxManageOperationSchema.safeParse(options.operation).success) {
|
|
21229
21797
|
throw Object.assign(
|
|
21230
21798
|
new Error(`Unsupported Inbox operation: ${options.operation}`),
|
|
@@ -21232,135 +21800,85 @@ async function runInboxManage(options) {
|
|
|
21232
21800
|
);
|
|
21233
21801
|
}
|
|
21234
21802
|
const input = await inputObject(options.input);
|
|
21235
|
-
|
|
21236
|
-
options.operation
|
|
21237
|
-
) || options.operation.startsWith("opportunity.") && options.operation !== "opportunity.get" || options.operation === "fde_action.command" || options.operation.startsWith("graph_recovery.") && options.operation !== "graph_recovery.get" || options.operation.startsWith("annotation.") && options.operation !== "annotation.get";
|
|
21238
|
-
if (isMutation) {
|
|
21239
|
-
const isProposal = options.operation === "opportunity.propose";
|
|
21240
|
-
const isOpportunity = options.operation.startsWith("opportunity.");
|
|
21241
|
-
const isFdeAction = options.operation.startsWith("fde_action.");
|
|
21242
|
-
const isGraphRecovery = options.operation.startsWith("graph_recovery.");
|
|
21243
|
-
const isAnnotation = options.operation.startsWith("annotation.");
|
|
21244
|
-
const previewCall = isProposal ? InboxManagementCallSchema.parse({
|
|
21245
|
-
operation: "inbox.list",
|
|
21246
|
-
input: {
|
|
21247
|
-
...typeof input.brand_id === "string" ? { brand_id: input.brand_id } : {},
|
|
21248
|
-
limit: 1
|
|
21249
|
-
}
|
|
21250
|
-
}) : isOpportunity ? InboxManagementCallSchema.parse({
|
|
21251
|
-
operation: "opportunity.get",
|
|
21252
|
-
input: {
|
|
21253
|
-
opportunity_id: input.opportunity_id,
|
|
21254
|
-
...typeof input.brand_id === "string" ? { brand_id: input.brand_id } : {}
|
|
21255
|
-
}
|
|
21256
|
-
}) : isFdeAction ? InboxManagementCallSchema.parse({
|
|
21257
|
-
operation: "fde_action.get",
|
|
21258
|
-
input: {
|
|
21259
|
-
id: input.id,
|
|
21260
|
-
...typeof input.brand_id === "string" ? { brand_id: input.brand_id } : {}
|
|
21261
|
-
}
|
|
21262
|
-
}) : isGraphRecovery ? InboxManagementCallSchema.parse({
|
|
21263
|
-
operation: "graph_recovery.get",
|
|
21264
|
-
input: {
|
|
21265
|
-
id: input.id,
|
|
21266
|
-
...typeof input.brand_id === "string" ? { brand_id: input.brand_id } : {}
|
|
21267
|
-
}
|
|
21268
|
-
}) : isAnnotation ? InboxManagementCallSchema.parse({
|
|
21269
|
-
operation: "annotation.get",
|
|
21270
|
-
input: {
|
|
21271
|
-
task_id: input.task_id,
|
|
21272
|
-
...typeof input.brand_id === "string" ? { brand_id: input.brand_id } : {}
|
|
21273
|
-
}
|
|
21274
|
-
}) : InboxManagementCallSchema.parse({
|
|
21275
|
-
operation: "change.get",
|
|
21276
|
-
input: {
|
|
21277
|
-
pr_number: input.pr_number,
|
|
21278
|
-
...typeof input.brand_id === "string" ? { brand_id: input.brand_id } : {}
|
|
21279
|
-
}
|
|
21280
|
-
});
|
|
21281
|
-
const preview = await callInboxManagement(
|
|
21282
|
-
session,
|
|
21283
|
-
orgId,
|
|
21284
|
-
previewCall
|
|
21285
|
-
);
|
|
21286
|
-
if (preview.scope.org_id !== orgId)
|
|
21287
|
-
throw Object.assign(
|
|
21288
|
-
new Error(
|
|
21289
|
-
`Requested organization ${orgId} but server resolved ${preview.scope.org_id}.`
|
|
21290
|
-
),
|
|
21291
|
-
{ code: "organization_scope_mismatch" }
|
|
21292
|
-
);
|
|
21293
|
-
const suppliedVersion = input.source_version ?? input.subject_revision;
|
|
21294
|
-
if (!isProposal && !isFdeAction && !inboxSourceVersionsMatch(preview.source_version, suppliedVersion))
|
|
21295
|
-
throw Object.assign(
|
|
21296
|
-
new Error(
|
|
21297
|
-
`The reviewed source revision ${String(suppliedVersion)} is stale; current revision is ${preview.source_version}.`
|
|
21298
|
-
),
|
|
21299
|
-
{ code: "stale_review_task" }
|
|
21300
|
-
);
|
|
21301
|
-
const previewReceipt = preview.receipt && typeof preview.receipt === "object" ? preview.receipt : {};
|
|
21302
|
-
const action = previewReceipt.action;
|
|
21303
|
-
const cycle = previewReceipt.cycle;
|
|
21304
|
-
const advertised = isFdeAction ? action?.supported_commands : isGraphRecovery ? cycle?.next_legal_commands : isAnnotation ? previewReceipt.task?.valid_next_actions : null;
|
|
21305
|
-
const requestedCommand = options.operation === "graph_recovery.select_predecessor" ? "select_predecessor" : options.operation === "annotation.complete" ? "complete" : input.command;
|
|
21306
|
-
if (Array.isArray(advertised) && !advertised.includes(requestedCommand))
|
|
21307
|
-
throw Object.assign(
|
|
21308
|
-
new Error(
|
|
21309
|
-
`Command ${String(requestedCommand)} is not advertised by the current source item.`
|
|
21310
|
-
),
|
|
21311
|
-
{ code: "invalid_transition" }
|
|
21312
|
-
);
|
|
21313
|
-
const recipient = input.recipient_name ? `; recipient: ${String(input.recipient_name)}` : "";
|
|
21314
|
-
const wording = input.approved_wording ? `; wording: ${JSON.stringify(input.approved_wording)}` : "";
|
|
21315
|
-
const mutation = options.operation === "annotation.command" ? ANNOTATION_COMMAND_EFFECTS[String(input.command)] : MUTATION_EFFECTS[options.operation];
|
|
21316
|
-
const sourceItem = isProposal ? String(
|
|
21317
|
-
input.proposal && typeof input.proposal === "object" ? input.proposal.opportunity_key ?? "new stable-key proposal" : "new proposal"
|
|
21318
|
-
) : String(
|
|
21319
|
-
input.opportunity_id ?? input.pr_number ?? input.id ?? input.task_id ?? "unknown"
|
|
21320
|
-
);
|
|
21321
|
-
const command = input.command ? `; command: ${String(input.command)}` : "";
|
|
21322
|
-
const reason = input.reason ? `; reason: ${String(input.reason)}` : "";
|
|
21323
|
-
const commandId = input.command_id ? `; command ID: ${String(input.command_id)}` : "";
|
|
21324
|
-
const previewSummary = `Approval preview \u2014 organization: ${preview.scope.org_name} (${preview.scope.org_id}); brand: ${preview.scope.brand_name ?? "all brands"}; operation: ${options.operation}; source item: ${sourceItem}; source version: ${preview.source_version ?? "new proposal"}; effect: ${mutation?.effect ?? "unspecified"}; reversible: ${String(mutation?.reversible ?? "unspecified")}${command}${reason}${commandId}${recipient}${wording}`;
|
|
21325
|
-
human(previewSummary, options);
|
|
21326
|
-
if (!options.approve) {
|
|
21327
|
-
throw Object.assign(
|
|
21328
|
-
new Error(
|
|
21329
|
-
`${options.quiet ? `${previewSummary}. ` : ""}This operation changes customer state. Review the preview and re-run with --approve to acknowledge its exact scope, source version, effect, and reversibility.`
|
|
21330
|
-
),
|
|
21331
|
-
{ code: "approval_required" }
|
|
21332
|
-
);
|
|
21333
|
-
}
|
|
21334
|
-
}
|
|
21335
|
-
if (options.approve) {
|
|
21336
|
-
input.approved = true;
|
|
21337
|
-
const mutation = options.operation === "annotation.command" ? ANNOTATION_COMMAND_EFFECTS[String(input.command)] : MUTATION_EFFECTS[options.operation];
|
|
21338
|
-
if (mutation) {
|
|
21339
|
-
input.approved_effect = mutation.effect;
|
|
21340
|
-
input.approved_reversible = mutation.reversible;
|
|
21341
|
-
}
|
|
21342
|
-
}
|
|
21343
|
-
const call = InboxManagementCallSchema.parse({
|
|
21344
|
-
operation: options.operation,
|
|
21345
|
-
input
|
|
21346
|
-
});
|
|
21347
|
-
const result = await callInboxManagement(session, orgId, call);
|
|
21348
|
-
if (result.meta.requested_org_id !== orgId || result.meta.effective_org_id !== orgId || result.scope.org_id !== orgId)
|
|
21349
|
-
throw Object.assign(
|
|
21350
|
-
new Error(
|
|
21351
|
-
`Requested organization ${orgId} but server resolved ${result.meta.effective_org_id}.`
|
|
21352
|
-
),
|
|
21353
|
-
{ code: "organization_scope_mismatch" }
|
|
21354
|
-
);
|
|
21355
|
-
human(
|
|
21356
|
-
`Resolved organization: ${result.scope.org_name} (${result.scope.org_id})`,
|
|
21357
|
-
options
|
|
21358
|
-
);
|
|
21359
|
-
emitSuccess(result, options);
|
|
21803
|
+
await executeInboxManagement(options, session, orgId, input);
|
|
21360
21804
|
} catch (error) {
|
|
21361
21805
|
fail(error, options);
|
|
21362
21806
|
}
|
|
21363
21807
|
}
|
|
21808
|
+
async function approveInboxMutation(options, session, orgId, input) {
|
|
21809
|
+
const isProposal = options.operation === "opportunity.propose";
|
|
21810
|
+
const isFdeAction = options.operation.startsWith("fde_action.");
|
|
21811
|
+
const previewCall = mutationPreview(options.operation, input);
|
|
21812
|
+
const preview = await callInboxManagement(session, orgId, previewCall);
|
|
21813
|
+
if (preview.scope.org_id !== orgId)
|
|
21814
|
+
throw Object.assign(
|
|
21815
|
+
new Error(
|
|
21816
|
+
`Requested organization ${orgId} but server resolved ${preview.scope.org_id}.`
|
|
21817
|
+
),
|
|
21818
|
+
{ code: "organization_scope_mismatch" }
|
|
21819
|
+
);
|
|
21820
|
+
const suppliedVersion = input.source_version ?? input.subject_revision;
|
|
21821
|
+
if (!isProposal && !isFdeAction && !inboxSourceVersionsMatch(preview.source_version, suppliedVersion))
|
|
21822
|
+
throw Object.assign(
|
|
21823
|
+
new Error(
|
|
21824
|
+
`The reviewed source revision ${String(suppliedVersion)} is stale; current revision is ${preview.source_version}.`
|
|
21825
|
+
),
|
|
21826
|
+
{ code: "stale_review_task" }
|
|
21827
|
+
);
|
|
21828
|
+
const advertised = advertisedInboxCommands(preview, options.operation);
|
|
21829
|
+
const requestedCommand = mutationCommand(options.operation, input);
|
|
21830
|
+
if (Array.isArray(advertised) && !advertised.includes(requestedCommand))
|
|
21831
|
+
throw Object.assign(
|
|
21832
|
+
new Error(
|
|
21833
|
+
`Command ${String(requestedCommand)} is not advertised by the current source item.`
|
|
21834
|
+
),
|
|
21835
|
+
{ code: "invalid_transition" }
|
|
21836
|
+
);
|
|
21837
|
+
const previewSummary = inboxApprovalSummary(
|
|
21838
|
+
options.operation,
|
|
21839
|
+
input,
|
|
21840
|
+
preview,
|
|
21841
|
+
isProposal
|
|
21842
|
+
);
|
|
21843
|
+
human(previewSummary, options);
|
|
21844
|
+
if (!options.approve) {
|
|
21845
|
+
throw Object.assign(
|
|
21846
|
+
new Error(
|
|
21847
|
+
`${options.quiet ? `${previewSummary}. ` : ""}This operation changes customer state. Review the preview and re-run with --approve to acknowledge its exact scope, source version, effect, and reversibility.`
|
|
21848
|
+
),
|
|
21849
|
+
{ code: "approval_required" }
|
|
21850
|
+
);
|
|
21851
|
+
}
|
|
21852
|
+
}
|
|
21853
|
+
async function executeInboxManagement(options, session, orgId, input) {
|
|
21854
|
+
if (inboxMutation(options.operation))
|
|
21855
|
+
await approveInboxMutation(options, session, orgId, input);
|
|
21856
|
+
if (options.approve) {
|
|
21857
|
+
input.approved = true;
|
|
21858
|
+
const mutation = mutationEffect(options.operation, input);
|
|
21859
|
+
if (mutation) {
|
|
21860
|
+
input.approved_effect = mutation.effect;
|
|
21861
|
+
input.approved_reversible = mutation.reversible;
|
|
21862
|
+
}
|
|
21863
|
+
}
|
|
21864
|
+
const call = InboxManagementCallSchema.parse({
|
|
21865
|
+
operation: options.operation,
|
|
21866
|
+
input
|
|
21867
|
+
});
|
|
21868
|
+
const result = await callInboxManagement(session, orgId, call);
|
|
21869
|
+
if (result.meta.requested_org_id !== orgId || result.meta.effective_org_id !== orgId || result.scope.org_id !== orgId)
|
|
21870
|
+
throw Object.assign(
|
|
21871
|
+
new Error(
|
|
21872
|
+
`Requested organization ${orgId} but server resolved ${result.meta.effective_org_id}.`
|
|
21873
|
+
),
|
|
21874
|
+
{ code: "organization_scope_mismatch" }
|
|
21875
|
+
);
|
|
21876
|
+
human(
|
|
21877
|
+
`Resolved organization: ${result.scope.org_name} (${result.scope.org_id})`,
|
|
21878
|
+
options
|
|
21879
|
+
);
|
|
21880
|
+
emitSuccess(result, options);
|
|
21881
|
+
}
|
|
21364
21882
|
var MUTATION_EFFECTS, ANNOTATION_COMMAND_EFFECTS;
|
|
21365
21883
|
var init_inbox_management2 = __esm({
|
|
21366
21884
|
"src/commands/inbox-management.ts"() {
|
|
@@ -21471,7 +21989,9 @@ async function readSelectionFile(path2) {
|
|
|
21471
21989
|
try {
|
|
21472
21990
|
raw = await readFile9(path2, "utf8");
|
|
21473
21991
|
} catch (err) {
|
|
21474
|
-
throw new Error(
|
|
21992
|
+
throw new Error(
|
|
21993
|
+
`couldn't read selection file ${path2}: ${err.message}`
|
|
21994
|
+
);
|
|
21475
21995
|
}
|
|
21476
21996
|
let json;
|
|
21477
21997
|
try {
|
|
@@ -21536,11 +22056,20 @@ function printReviseResult(result, opts) {
|
|
|
21536
22056
|
);
|
|
21537
22057
|
}
|
|
21538
22058
|
}
|
|
22059
|
+
function invalidPrNumber(prNumber) {
|
|
22060
|
+
return !Number.isInteger(prNumber) || prNumber <= 0;
|
|
22061
|
+
}
|
|
22062
|
+
function inboxRequestErrorCode(err, fallback2) {
|
|
22063
|
+
return err instanceof ApiError && err.errorCode ? err.errorCode : fallback2;
|
|
22064
|
+
}
|
|
22065
|
+
function trimOrUndefined(value) {
|
|
22066
|
+
return value?.trim() || void 0;
|
|
22067
|
+
}
|
|
21539
22068
|
async function runInboxRevise(options) {
|
|
21540
22069
|
const opts = options;
|
|
21541
22070
|
const session = await requireSession4(opts);
|
|
21542
22071
|
const prNumber = Number.parseInt(options.pr ?? "", 10);
|
|
21543
|
-
if (
|
|
22072
|
+
if (invalidPrNumber(prNumber)) {
|
|
21544
22073
|
emitError(
|
|
21545
22074
|
{
|
|
21546
22075
|
code: "invalid_pr",
|
|
@@ -21601,7 +22130,7 @@ async function runInboxRevise(options) {
|
|
|
21601
22130
|
selected_lines: selectedLines
|
|
21602
22131
|
});
|
|
21603
22132
|
} catch (err) {
|
|
21604
|
-
const code = err
|
|
22133
|
+
const code = inboxRequestErrorCode(err, "revise_failed");
|
|
21605
22134
|
emitError(
|
|
21606
22135
|
{ code, message: `revision request failed: ${err.message}` },
|
|
21607
22136
|
opts,
|
|
@@ -21616,7 +22145,7 @@ async function runInboxApplyRevision(options) {
|
|
|
21616
22145
|
const opts = options;
|
|
21617
22146
|
const session = await requireSession4(opts);
|
|
21618
22147
|
const prNumber = Number.parseInt(options.pr ?? "", 10);
|
|
21619
|
-
if (
|
|
22148
|
+
if (invalidPrNumber(prNumber)) {
|
|
21620
22149
|
emitError(
|
|
21621
22150
|
{
|
|
21622
22151
|
code: "invalid_pr",
|
|
@@ -21711,10 +22240,10 @@ async function runInboxApplyRevision(options) {
|
|
|
21711
22240
|
new_content: newContent,
|
|
21712
22241
|
commit_message: message,
|
|
21713
22242
|
file_sha: sha,
|
|
21714
|
-
branch: options.branch
|
|
22243
|
+
branch: trimOrUndefined(options.branch)
|
|
21715
22244
|
});
|
|
21716
22245
|
} catch (err) {
|
|
21717
|
-
const code = err
|
|
22246
|
+
const code = inboxRequestErrorCode(err, "apply_revision_failed");
|
|
21718
22247
|
emitError(
|
|
21719
22248
|
{ code, message: `apply-revision failed: ${err.message}` },
|
|
21720
22249
|
opts,
|
|
@@ -21723,7 +22252,10 @@ async function runInboxApplyRevision(options) {
|
|
|
21723
22252
|
return;
|
|
21724
22253
|
}
|
|
21725
22254
|
emitSuccess(result, opts, (r) => {
|
|
21726
|
-
human(
|
|
22255
|
+
human(
|
|
22256
|
+
` \u2713 Revision committed to ${r.branch} \u2014 the Inbox diff is updated.`,
|
|
22257
|
+
opts
|
|
22258
|
+
);
|
|
21727
22259
|
});
|
|
21728
22260
|
}
|
|
21729
22261
|
var SelectionFileSchema;
|
|
@@ -21944,11 +22476,16 @@ async function requireSession6(opts) {
|
|
|
21944
22476
|
return session;
|
|
21945
22477
|
}
|
|
21946
22478
|
function gradeSymbol(grade) {
|
|
21947
|
-
|
|
22479
|
+
if (grade === "A") return "\u2713";
|
|
22480
|
+
if (grade === "B" || grade === "C") return "\u2022";
|
|
22481
|
+
return "\u2717";
|
|
21948
22482
|
}
|
|
21949
22483
|
function printHealth(data, opts) {
|
|
21950
22484
|
const { grade, score, gaps, bucketScores, scope } = data;
|
|
21951
|
-
|
|
22485
|
+
let scopeLabel = "org";
|
|
22486
|
+
if (scope.kind === "agent") scopeLabel = `agent (${scope.agentId ?? "\u2014"})`;
|
|
22487
|
+
else if (scope.kind === "brand")
|
|
22488
|
+
scopeLabel = `brand (${scope.brandId ?? "\u2014"})`;
|
|
21952
22489
|
human("", opts);
|
|
21953
22490
|
human(
|
|
21954
22491
|
score === null ? ` Context health [${scopeLabel}]: not yet audited` : ` Context health [${scopeLabel}]: ${gradeSymbol(grade)} ${grade} (score ${Math.round(score)}/100)`,
|
|
@@ -22231,7 +22768,9 @@ __export(brand_exports, {
|
|
|
22231
22768
|
async function requireSession9() {
|
|
22232
22769
|
const creds = await readCredentials();
|
|
22233
22770
|
if (!creds) {
|
|
22234
|
-
console.error(
|
|
22771
|
+
console.error(
|
|
22772
|
+
"bamboo-agents: not signed in. Run `bamboo-agents login` first."
|
|
22773
|
+
);
|
|
22235
22774
|
process.exit(1);
|
|
22236
22775
|
}
|
|
22237
22776
|
return creds.bamboo_session;
|
|
@@ -22246,28 +22785,39 @@ async function runBrandUpdate(brandId, options) {
|
|
|
22246
22785
|
try {
|
|
22247
22786
|
result = await patchBrand(session, brandId, options.website);
|
|
22248
22787
|
} catch (err) {
|
|
22249
|
-
console.error(
|
|
22250
|
-
|
|
22788
|
+
console.error(
|
|
22789
|
+
`bamboo-agents: brand update failed: ${err.message}`
|
|
22790
|
+
);
|
|
22791
|
+
process.exit(1);
|
|
22251
22792
|
}
|
|
22252
22793
|
if (options.json) {
|
|
22253
22794
|
console.log(JSON.stringify(result));
|
|
22254
22795
|
return;
|
|
22255
22796
|
}
|
|
22256
22797
|
console.log("");
|
|
22257
|
-
console.log(
|
|
22798
|
+
console.log(
|
|
22799
|
+
` \u2713 Updated brand ${result.brand_id} \u2014 website ${result.website_url}`
|
|
22800
|
+
);
|
|
22258
22801
|
console.log("");
|
|
22259
22802
|
}
|
|
22260
22803
|
async function runBrandEditor(action, brandId, userId, options) {
|
|
22261
22804
|
if (!brandId || !userId) {
|
|
22262
|
-
console.error(
|
|
22805
|
+
console.error(
|
|
22806
|
+
`bamboo-agents: \`brand editor ${action}\` requires <brand-id> <user-id>.`
|
|
22807
|
+
);
|
|
22263
22808
|
process.exit(2);
|
|
22264
22809
|
}
|
|
22265
22810
|
const session = await requireSession9();
|
|
22266
22811
|
let result;
|
|
22267
22812
|
try {
|
|
22268
|
-
result = await postBrandEditor(session, brandId, {
|
|
22813
|
+
result = await postBrandEditor(session, brandId, {
|
|
22814
|
+
action,
|
|
22815
|
+
user_id: userId
|
|
22816
|
+
});
|
|
22269
22817
|
} catch (err) {
|
|
22270
|
-
console.error(
|
|
22818
|
+
console.error(
|
|
22819
|
+
`bamboo-agents: brand editor ${action} failed: ${err.message}`
|
|
22820
|
+
);
|
|
22271
22821
|
process.exit(1);
|
|
22272
22822
|
}
|
|
22273
22823
|
if (options.json) {
|
|
@@ -22296,7 +22846,10 @@ async function resolveBrandId(session, explicit, opts, hint = "Specify the brand
|
|
|
22296
22846
|
brands = (await listCliBrands(session)).brands;
|
|
22297
22847
|
} catch (err) {
|
|
22298
22848
|
emitError(
|
|
22299
|
-
{
|
|
22849
|
+
{
|
|
22850
|
+
code: "brands_list_failed",
|
|
22851
|
+
message: `couldn't list brands: ${err.message}`
|
|
22852
|
+
},
|
|
22300
22853
|
opts,
|
|
22301
22854
|
1
|
|
22302
22855
|
);
|
|
@@ -22403,7 +22956,10 @@ async function resolveAgentRef(session, rawRef, opts, orgId) {
|
|
|
22403
22956
|
}
|
|
22404
22957
|
function printList(data, opts) {
|
|
22405
22958
|
if (data.agents.length === 0) {
|
|
22406
|
-
human(
|
|
22959
|
+
human(
|
|
22960
|
+
" No agents yet. Create one with `bamboo-agents agents provision <name> --brand <id>`.",
|
|
22961
|
+
opts
|
|
22962
|
+
);
|
|
22407
22963
|
return;
|
|
22408
22964
|
}
|
|
22409
22965
|
const nameW = Math.max(4, ...data.agents.map((a) => a.name.length));
|
|
@@ -22430,20 +22986,31 @@ async function runAgentsList(options) {
|
|
|
22430
22986
|
data = await listCliAgents(session, scope.selected_org_id);
|
|
22431
22987
|
} catch (err) {
|
|
22432
22988
|
emitError(
|
|
22433
|
-
{
|
|
22989
|
+
{
|
|
22990
|
+
code: readScopeErrorCode(err, "agents_list_failed"),
|
|
22991
|
+
message: `couldn't list agents: ${err.message}`
|
|
22992
|
+
},
|
|
22434
22993
|
opts,
|
|
22435
22994
|
1
|
|
22436
22995
|
);
|
|
22437
22996
|
return;
|
|
22438
22997
|
}
|
|
22439
|
-
emitSuccess(
|
|
22440
|
-
|
|
22441
|
-
|
|
22442
|
-
|
|
22998
|
+
emitSuccess(
|
|
22999
|
+
data,
|
|
23000
|
+
opts,
|
|
23001
|
+
(d) => {
|
|
23002
|
+
printReadOrganizationScope(scope, opts);
|
|
23003
|
+
printList(d, opts);
|
|
23004
|
+
},
|
|
23005
|
+
scope
|
|
23006
|
+
);
|
|
22443
23007
|
}
|
|
22444
23008
|
function printDetail(agent, opts) {
|
|
22445
23009
|
human(` ${agent.name} (${agent.id})`, opts);
|
|
22446
|
-
human(
|
|
23010
|
+
human(
|
|
23011
|
+
` state: ${agent.state} (status=${agent.status}${agent.paused_at ? ", paused" : ""})`,
|
|
23012
|
+
opts
|
|
23013
|
+
);
|
|
22447
23014
|
human(` slug: ${agent.slug ?? "\u2014"}`, opts);
|
|
22448
23015
|
human(` runtime: ${agent.execution_runtime ?? "\u2014"}`, opts);
|
|
22449
23016
|
human(` template: ${agent.template_key ?? "\u2014"}`, opts);
|
|
@@ -22459,20 +23026,33 @@ async function runAgentsGet(agentRef, options) {
|
|
|
22459
23026
|
let scope;
|
|
22460
23027
|
try {
|
|
22461
23028
|
scope = await resolveReadOrganizationScope(session, options.org);
|
|
22462
|
-
const row = await resolveAgentRef(
|
|
23029
|
+
const row = await resolveAgentRef(
|
|
23030
|
+
session,
|
|
23031
|
+
agentRef,
|
|
23032
|
+
opts,
|
|
23033
|
+
scope.selected_org_id
|
|
23034
|
+
);
|
|
22463
23035
|
agent = (await getCliAgent(session, row.id, scope.selected_org_id)).agent;
|
|
22464
23036
|
} catch (err) {
|
|
22465
23037
|
emitError(
|
|
22466
|
-
{
|
|
23038
|
+
{
|
|
23039
|
+
code: readScopeErrorCode(err, "agent_get_failed"),
|
|
23040
|
+
message: `couldn't load agent: ${err.message}`
|
|
23041
|
+
},
|
|
22467
23042
|
opts,
|
|
22468
23043
|
1
|
|
22469
23044
|
);
|
|
22470
23045
|
return;
|
|
22471
23046
|
}
|
|
22472
|
-
emitSuccess(
|
|
22473
|
-
|
|
22474
|
-
|
|
22475
|
-
|
|
23047
|
+
emitSuccess(
|
|
23048
|
+
agent,
|
|
23049
|
+
opts,
|
|
23050
|
+
(a) => {
|
|
23051
|
+
printReadOrganizationScope(scope, opts);
|
|
23052
|
+
printDetail(a, opts);
|
|
23053
|
+
},
|
|
23054
|
+
scope
|
|
23055
|
+
);
|
|
22476
23056
|
}
|
|
22477
23057
|
async function runAgentsProvision(name, options) {
|
|
22478
23058
|
const opts = options;
|
|
@@ -22487,7 +23067,10 @@ async function runAgentsProvision(name, options) {
|
|
|
22487
23067
|
});
|
|
22488
23068
|
} catch (err) {
|
|
22489
23069
|
emitError(
|
|
22490
|
-
{
|
|
23070
|
+
{
|
|
23071
|
+
code: "agent_provision_failed",
|
|
23072
|
+
message: `couldn't provision agent: ${err.message}`
|
|
23073
|
+
},
|
|
22491
23074
|
opts,
|
|
22492
23075
|
1
|
|
22493
23076
|
);
|
|
@@ -22506,10 +23089,17 @@ async function runAgentsPause(agentRef, options) {
|
|
|
22506
23089
|
const row = await resolveAgentRef(session, agentRef, opts);
|
|
22507
23090
|
try {
|
|
22508
23091
|
const res = await pauseCliAgent(session, row.id);
|
|
22509
|
-
emitSuccess(
|
|
23092
|
+
emitSuccess(
|
|
23093
|
+
res,
|
|
23094
|
+
opts,
|
|
23095
|
+
() => human(` Paused ${row.name} (${row.id}).`, opts)
|
|
23096
|
+
);
|
|
22510
23097
|
} catch (err) {
|
|
22511
23098
|
emitError(
|
|
22512
|
-
{
|
|
23099
|
+
{
|
|
23100
|
+
code: "agent_pause_failed",
|
|
23101
|
+
message: `couldn't pause agent: ${err.message}`
|
|
23102
|
+
},
|
|
22513
23103
|
opts,
|
|
22514
23104
|
1
|
|
22515
23105
|
);
|
|
@@ -22537,10 +23127,17 @@ async function runAgentsUpdate(agentRef, options) {
|
|
|
22537
23127
|
const row = await resolveAgentRef(session, agentRef, opts);
|
|
22538
23128
|
try {
|
|
22539
23129
|
const res = await updateCliAgent(session, row.id, body);
|
|
22540
|
-
emitSuccess(
|
|
23130
|
+
emitSuccess(
|
|
23131
|
+
res,
|
|
23132
|
+
opts,
|
|
23133
|
+
() => human(` Updated ${row.name} (${row.id}).`, opts)
|
|
23134
|
+
);
|
|
22541
23135
|
} catch (err) {
|
|
22542
23136
|
emitError(
|
|
22543
|
-
{
|
|
23137
|
+
{
|
|
23138
|
+
code: "agent_update_failed",
|
|
23139
|
+
message: `couldn't update agent: ${err.message}`
|
|
23140
|
+
},
|
|
22544
23141
|
opts,
|
|
22545
23142
|
1
|
|
22546
23143
|
);
|
|
@@ -22562,7 +23159,10 @@ async function runAgentsDelete(agentRef, options) {
|
|
|
22562
23159
|
);
|
|
22563
23160
|
} catch (err) {
|
|
22564
23161
|
emitError(
|
|
22565
|
-
{
|
|
23162
|
+
{
|
|
23163
|
+
code: "agent_delete_failed",
|
|
23164
|
+
message: `couldn't delete agent: ${err.message}`
|
|
23165
|
+
},
|
|
22566
23166
|
opts,
|
|
22567
23167
|
1
|
|
22568
23168
|
);
|
|
@@ -22591,7 +23191,10 @@ async function runAgentsClone(sourceRef, targetRef, options) {
|
|
|
22591
23191
|
);
|
|
22592
23192
|
} catch (err) {
|
|
22593
23193
|
emitError(
|
|
22594
|
-
{
|
|
23194
|
+
{
|
|
23195
|
+
code: "agent_clone_failed",
|
|
23196
|
+
message: `couldn't clone agent: ${err.message}`
|
|
23197
|
+
},
|
|
22595
23198
|
opts,
|
|
22596
23199
|
1
|
|
22597
23200
|
);
|
|
@@ -22601,11 +23204,19 @@ async function runAgentsEnableTemplate(agentRef, options) {
|
|
|
22601
23204
|
const opts = options;
|
|
22602
23205
|
const session = await requireSession10(opts);
|
|
22603
23206
|
if (!options.template) {
|
|
22604
|
-
emitError(
|
|
23207
|
+
emitError(
|
|
23208
|
+
{ code: "template_required", message: "Provide --template <id>." },
|
|
23209
|
+
opts,
|
|
23210
|
+
2
|
|
23211
|
+
);
|
|
22605
23212
|
return;
|
|
22606
23213
|
}
|
|
22607
23214
|
if (!options.brand) {
|
|
22608
|
-
emitError(
|
|
23215
|
+
emitError(
|
|
23216
|
+
{ code: "brand_required", message: "Provide --brand <id>." },
|
|
23217
|
+
opts,
|
|
23218
|
+
2
|
|
23219
|
+
);
|
|
22609
23220
|
return;
|
|
22610
23221
|
}
|
|
22611
23222
|
const row = await resolveAgentRef(session, agentRef, opts);
|
|
@@ -22625,7 +23236,10 @@ async function runAgentsEnableTemplate(agentRef, options) {
|
|
|
22625
23236
|
);
|
|
22626
23237
|
} catch (err) {
|
|
22627
23238
|
emitError(
|
|
22628
|
-
{
|
|
23239
|
+
{
|
|
23240
|
+
code: "agent_enable_template_failed",
|
|
23241
|
+
message: `couldn't enable template: ${err.message}`
|
|
23242
|
+
},
|
|
22629
23243
|
opts,
|
|
22630
23244
|
1
|
|
22631
23245
|
);
|
|
@@ -22644,7 +23258,10 @@ async function runAgentsActivate(agentRef, options) {
|
|
|
22644
23258
|
status = d.status;
|
|
22645
23259
|
} catch (err) {
|
|
22646
23260
|
emitError(
|
|
22647
|
-
{
|
|
23261
|
+
{
|
|
23262
|
+
code: "agent_get_failed",
|
|
23263
|
+
message: `couldn't read agent state: ${err.message}`
|
|
23264
|
+
},
|
|
22648
23265
|
opts,
|
|
22649
23266
|
1
|
|
22650
23267
|
);
|
|
@@ -22677,7 +23294,10 @@ async function runAgentsActivate(agentRef, options) {
|
|
|
22677
23294
|
);
|
|
22678
23295
|
} catch (err) {
|
|
22679
23296
|
emitError(
|
|
22680
|
-
{
|
|
23297
|
+
{
|
|
23298
|
+
code: "agent_activate_failed",
|
|
23299
|
+
message: `couldn't activate agent: ${err.message}`
|
|
23300
|
+
},
|
|
22681
23301
|
opts,
|
|
22682
23302
|
1
|
|
22683
23303
|
);
|
|
@@ -22703,7 +23323,9 @@ __export(episode_exports, {
|
|
|
22703
23323
|
async function requireSession11() {
|
|
22704
23324
|
const creds = await readCredentials();
|
|
22705
23325
|
if (!creds) {
|
|
22706
|
-
console.error(
|
|
23326
|
+
console.error(
|
|
23327
|
+
"bamboo-agents: not signed in. Run `bamboo-agents login` first."
|
|
23328
|
+
);
|
|
22707
23329
|
process.exit(1);
|
|
22708
23330
|
}
|
|
22709
23331
|
return creds.bamboo_session;
|
|
@@ -22721,7 +23343,9 @@ async function runEpisodeLogOutcome(options) {
|
|
|
22721
23343
|
try {
|
|
22722
23344
|
metricsBefore = JSON.parse(options.metricsBefore);
|
|
22723
23345
|
} catch {
|
|
22724
|
-
console.error(
|
|
23346
|
+
console.error(
|
|
23347
|
+
`bamboo-agents: --metrics-before must be valid JSON, e.g. '{"cpa": 35}'.`
|
|
23348
|
+
);
|
|
22725
23349
|
process.exit(2);
|
|
22726
23350
|
}
|
|
22727
23351
|
}
|
|
@@ -22729,7 +23353,9 @@ async function runEpisodeLogOutcome(options) {
|
|
|
22729
23353
|
try {
|
|
22730
23354
|
metricsAfter = JSON.parse(options.metricsAfter);
|
|
22731
23355
|
} catch {
|
|
22732
|
-
console.error(
|
|
23356
|
+
console.error(
|
|
23357
|
+
`bamboo-agents: --metrics-after must be valid JSON, e.g. '{"cpa": 31}'.`
|
|
23358
|
+
);
|
|
22733
23359
|
process.exit(2);
|
|
22734
23360
|
}
|
|
22735
23361
|
}
|
|
@@ -22744,7 +23370,9 @@ async function runEpisodeLogOutcome(options) {
|
|
|
22744
23370
|
...metricsAfter ? { metrics_after: metricsAfter } : {}
|
|
22745
23371
|
});
|
|
22746
23372
|
} catch (err) {
|
|
22747
|
-
console.error(
|
|
23373
|
+
console.error(
|
|
23374
|
+
`bamboo-agents: outcome entry failed: ${err.message}`
|
|
23375
|
+
);
|
|
22748
23376
|
process.exit(1);
|
|
22749
23377
|
}
|
|
22750
23378
|
if (options.json) {
|
|
@@ -22773,6 +23401,10 @@ async function runEpisodeLogRec(options) {
|
|
|
22773
23401
|
);
|
|
22774
23402
|
process.exit(2);
|
|
22775
23403
|
}
|
|
23404
|
+
const { cites, actionItems } = recommendationInputs(options);
|
|
23405
|
+
await postRecommendation(options, cites, actionItems);
|
|
23406
|
+
}
|
|
23407
|
+
function recommendationInputs(options) {
|
|
22776
23408
|
let cites = [];
|
|
22777
23409
|
if (options.noPriorHistory) {
|
|
22778
23410
|
cites = [{ kind: "no-prior-history" }];
|
|
@@ -22791,7 +23423,8 @@ async function runEpisodeLogRec(options) {
|
|
|
22791
23423
|
if (options.actionItems) {
|
|
22792
23424
|
try {
|
|
22793
23425
|
actionItems = JSON.parse(options.actionItems);
|
|
22794
|
-
if (!Array.isArray(actionItems))
|
|
23426
|
+
if (!Array.isArray(actionItems))
|
|
23427
|
+
throw new Error("action-items must be a JSON array");
|
|
22795
23428
|
} catch (e) {
|
|
22796
23429
|
console.error(
|
|
22797
23430
|
`bamboo-agents: --action-items must be a valid JSON array of strings: ${e.message}`
|
|
@@ -22799,6 +23432,9 @@ async function runEpisodeLogRec(options) {
|
|
|
22799
23432
|
process.exit(2);
|
|
22800
23433
|
}
|
|
22801
23434
|
}
|
|
23435
|
+
return { cites, actionItems };
|
|
23436
|
+
}
|
|
23437
|
+
async function postRecommendation(options, cites, actionItems) {
|
|
22802
23438
|
const session = await requireSession11();
|
|
22803
23439
|
let result;
|
|
22804
23440
|
try {
|
|
@@ -22815,7 +23451,9 @@ async function runEpisodeLogRec(options) {
|
|
|
22815
23451
|
if (options.json) {
|
|
22816
23452
|
console.log(JSON.stringify({ ok: false, error: err.message }));
|
|
22817
23453
|
} else {
|
|
22818
|
-
console.error(
|
|
23454
|
+
console.error(
|
|
23455
|
+
`bamboo-agents: recommendation entry failed: ${err.message}`
|
|
23456
|
+
);
|
|
22819
23457
|
}
|
|
22820
23458
|
process.exit(1);
|
|
22821
23459
|
}
|
|
@@ -22826,7 +23464,9 @@ async function runEpisodeLogRec(options) {
|
|
|
22826
23464
|
if (!options.quiet) {
|
|
22827
23465
|
const kind = result.is_no_prior_history ? " (no prior history \u2014 cold start)" : "";
|
|
22828
23466
|
console.log("");
|
|
22829
|
-
console.log(
|
|
23467
|
+
console.log(
|
|
23468
|
+
` \u2713 Recommendation logged${kind} \u2014 episode ${result.episode_id}`
|
|
23469
|
+
);
|
|
22830
23470
|
console.log("");
|
|
22831
23471
|
}
|
|
22832
23472
|
}
|
|
@@ -22849,7 +23489,10 @@ import { readFile as readFile10 } from "node:fs/promises";
|
|
|
22849
23489
|
async function runEvalScope(options) {
|
|
22850
23490
|
const session = await requireSession12(options);
|
|
22851
23491
|
try {
|
|
22852
|
-
const organization = await resolveCredentialOrganization(
|
|
23492
|
+
const organization = await resolveCredentialOrganization(
|
|
23493
|
+
session,
|
|
23494
|
+
options.org
|
|
23495
|
+
);
|
|
22853
23496
|
const [brandResult, agentResult] = await Promise.all([
|
|
22854
23497
|
listCliBrands(session, organization.id),
|
|
22855
23498
|
listCliAgents(session, organization.id)
|
|
@@ -22977,20 +23620,26 @@ async function runEvalManage(options) {
|
|
|
22977
23620
|
);
|
|
22978
23621
|
emitSuccess(result, output);
|
|
22979
23622
|
} catch (error) {
|
|
22980
|
-
|
|
22981
|
-
const invalidInput = error instanceof SyntaxError || error instanceof ZodError || value.code === "ENOENT" || value.code === "EACCES";
|
|
22982
|
-
emitError(
|
|
22983
|
-
{
|
|
22984
|
-
code: invalidInput ? "invalid_input" : value.code ?? value.errorCode ?? "management_failed",
|
|
22985
|
-
message: value.message ?? "Management operation failed.",
|
|
22986
|
-
...value.details ? { details: value.details } : {},
|
|
22987
|
-
hint: value.status === 401 ? "Run `bamboo-agents login` to re-authenticate." : "Run `bamboo-agents eval operations --json` for supported names and bindings."
|
|
22988
|
-
},
|
|
22989
|
-
output,
|
|
22990
|
-
1
|
|
22991
|
-
);
|
|
23623
|
+
emitManagementError(error, output);
|
|
22992
23624
|
}
|
|
22993
23625
|
}
|
|
23626
|
+
function emitManagementError(error, output) {
|
|
23627
|
+
const value = error;
|
|
23628
|
+
const invalidInput = error instanceof SyntaxError || error instanceof ZodError || value.code === "ENOENT" || value.code === "EACCES";
|
|
23629
|
+
emitError(
|
|
23630
|
+
{
|
|
23631
|
+
code: invalidInput ? "invalid_input" : value.code ?? value.errorCode ?? "management_failed",
|
|
23632
|
+
message: value.message ?? "Management operation failed.",
|
|
23633
|
+
...value.details ? { details: value.details } : {},
|
|
23634
|
+
hint: value.status === 401 ? "Run `bamboo-agents login` to re-authenticate." : "Run `bamboo-agents eval operations --json` for supported names and bindings."
|
|
23635
|
+
},
|
|
23636
|
+
output,
|
|
23637
|
+
1
|
|
23638
|
+
);
|
|
23639
|
+
}
|
|
23640
|
+
function outcomeRecord(value) {
|
|
23641
|
+
return value && typeof value === "object" ? value : null;
|
|
23642
|
+
}
|
|
22994
23643
|
function managementOutcomeLine(result, readOnly) {
|
|
22995
23644
|
if (readOnly) {
|
|
22996
23645
|
const investigation = result.data && typeof result.data === "object" ? result.data : null;
|
|
@@ -22999,8 +23648,8 @@ function managementOutcomeLine(result, readOnly) {
|
|
|
22999
23648
|
}
|
|
23000
23649
|
return `Read ${result.operation}.`;
|
|
23001
23650
|
}
|
|
23002
|
-
const data = result.data
|
|
23003
|
-
const publication = data.publication
|
|
23651
|
+
const data = outcomeRecord(result.data) ?? {};
|
|
23652
|
+
const publication = outcomeRecord(data.publication);
|
|
23004
23653
|
if (publication?.status === "failed") {
|
|
23005
23654
|
const reason = publication.publication_error ?? publication.error;
|
|
23006
23655
|
return `Failed to publish ${result.operation}${typeof reason === "string" ? `: ${reason}` : "."}`;
|
|
@@ -23008,6 +23657,11 @@ function managementOutcomeLine(result, readOnly) {
|
|
|
23008
23657
|
if (result.operation.startsWith("case.")) {
|
|
23009
23658
|
return caseOutcomeLine(result.operation, data, publication);
|
|
23010
23659
|
}
|
|
23660
|
+
const publicationOutcome = publicationOutcomeLine(result, publication);
|
|
23661
|
+
if (publicationOutcome) return publicationOutcome;
|
|
23662
|
+
return operationOutcomeLine(result, data);
|
|
23663
|
+
}
|
|
23664
|
+
function publicationOutcomeLine(result, publication) {
|
|
23011
23665
|
if (publication?.status === "published" && publication.projection_status === "projected") {
|
|
23012
23666
|
return `Published ${result.operation} and projected it into Tests.`;
|
|
23013
23667
|
}
|
|
@@ -23023,6 +23677,9 @@ function managementOutcomeLine(result, readOnly) {
|
|
|
23023
23677
|
if (publication?.status === "noop") {
|
|
23024
23678
|
return `No change for ${result.operation}; the existing publication is current.`;
|
|
23025
23679
|
}
|
|
23680
|
+
return null;
|
|
23681
|
+
}
|
|
23682
|
+
function operationOutcomeLine(result, data) {
|
|
23026
23683
|
if (result.operation === "wave.schedule") {
|
|
23027
23684
|
const status = typeof data.status === "string" ? data.status : "recorded";
|
|
23028
23685
|
return `Scheduled the investigation wave; admission status is ${status}.`;
|
|
@@ -23033,7 +23690,12 @@ function managementOutcomeLine(result, readOnly) {
|
|
|
23033
23690
|
return "Updated the investigation wave without scheduling it.";
|
|
23034
23691
|
const lifecycle = result.operation.split(".")[1];
|
|
23035
23692
|
if (["hold", "resume", "cancel"].includes(lifecycle ?? "")) {
|
|
23036
|
-
|
|
23693
|
+
const verbs = {
|
|
23694
|
+
hold: "Held",
|
|
23695
|
+
resume: "Resumed",
|
|
23696
|
+
cancel: "Canceled pending work for"
|
|
23697
|
+
};
|
|
23698
|
+
return `${verbs[lifecycle]} the investigation.`;
|
|
23037
23699
|
}
|
|
23038
23700
|
if (["conclude_claim", "retire_claim", "close", "reopen", "retire"].includes(
|
|
23039
23701
|
lifecycle ?? ""
|
|
@@ -23050,23 +23712,31 @@ function caseOutcomeLine(operation, data, publication) {
|
|
|
23050
23712
|
const projected = publication?.projection_status === "projected";
|
|
23051
23713
|
const sourcePath = typeof data.source_path === "string" ? data.source_path : "the case";
|
|
23052
23714
|
if (operation === "case.attach" || operation === "case.detach") {
|
|
23053
|
-
|
|
23054
|
-
const verb2 = operation === "case.attach" ? "Attached" : "Detached";
|
|
23055
|
-
const membership = projected ? "Tests membership is projected" : "Tests membership projection is pending";
|
|
23056
|
-
if (status === "pending")
|
|
23057
|
-
return `${verb2} case references on ${claims} claim(s); the investigation revision is pending publication and ${membership.toLowerCase()}.`;
|
|
23058
|
-
if (status === "noop")
|
|
23059
|
-
return `No change: the ${claims} named claim(s) already carried those case references.`;
|
|
23060
|
-
return `${verb2} case references on ${claims} claim(s); ${membership}. No run was scheduled.`;
|
|
23061
|
-
}
|
|
23062
|
-
if (operation === "case.retire") {
|
|
23063
|
-
if (data.already_retired === true)
|
|
23064
|
-
return `${sourcePath} was already retired; nothing was written.`;
|
|
23065
|
-
const category = data.set_retired === true ? " and its category (last case)" : "";
|
|
23066
|
-
if (status === "pending")
|
|
23067
|
-
return `Retirement of ${sourcePath}${category} is queued for publication; the projected case stays active until it merges.`;
|
|
23068
|
-
return projected ? `Retired ${sourcePath}${category}: the file is removed and the projected case is inactive.` : `Retired ${sourcePath}${category}: the file is removed, but the projected case has not been marked inactive yet.`;
|
|
23715
|
+
return caseMembershipOutcome(operation, data, status, projected);
|
|
23069
23716
|
}
|
|
23717
|
+
if (operation === "case.retire")
|
|
23718
|
+
return caseRetirementOutcome(data, status, projected, sourcePath);
|
|
23719
|
+
return casePublicationOutcome(operation, data, status, projected, sourcePath);
|
|
23720
|
+
}
|
|
23721
|
+
function caseMembershipOutcome(operation, data, status, projected) {
|
|
23722
|
+
const claims = Array.isArray(data.claims) ? data.claims.length : 0;
|
|
23723
|
+
const verb = operation === "case.attach" ? "Attached" : "Detached";
|
|
23724
|
+
const membership = projected ? "Tests membership is projected" : "Tests membership projection is pending";
|
|
23725
|
+
if (status === "pending")
|
|
23726
|
+
return `${verb} case references on ${claims} claim(s); the investigation revision is pending publication and ${membership.toLowerCase()}.`;
|
|
23727
|
+
if (status === "noop")
|
|
23728
|
+
return `No change: the ${claims} named claim(s) already carried those case references.`;
|
|
23729
|
+
return `${verb} case references on ${claims} claim(s); ${membership}. No run was scheduled.`;
|
|
23730
|
+
}
|
|
23731
|
+
function caseRetirementOutcome(data, status, projected, sourcePath) {
|
|
23732
|
+
if (data.already_retired === true)
|
|
23733
|
+
return `${sourcePath} was already retired; nothing was written.`;
|
|
23734
|
+
const category = data.set_retired === true ? " and its category (last case)" : "";
|
|
23735
|
+
if (status === "pending")
|
|
23736
|
+
return `Retirement of ${sourcePath}${category} is queued for publication; the projected case stays active until it merges.`;
|
|
23737
|
+
return projected ? `Retired ${sourcePath}${category}: the file is removed and the projected case is inactive.` : `Retired ${sourcePath}${category}: the file is removed, but the projected case has not been marked inactive yet.`;
|
|
23738
|
+
}
|
|
23739
|
+
function casePublicationOutcome(operation, data, status, projected, sourcePath) {
|
|
23070
23740
|
const verb = operation === "case.create" ? "Authored" : "Updated";
|
|
23071
23741
|
const caseId = typeof data.case_id === "string" ? ` (eval_cases ${data.case_id})` : "";
|
|
23072
23742
|
if (status === "pending")
|
|
@@ -23243,12 +23913,19 @@ function render(data, opts) {
|
|
|
23243
23913
|
` Baseline promoted: run ${data.run_id} is the reference for qrels_version ${short(data.qrels_version)} (${data.question_set_kind})` + (data.previous_run_id ? ` (was ${data.previous_run_id}).` : " (the version had none)."),
|
|
23244
23914
|
opts
|
|
23245
23915
|
);
|
|
23246
|
-
human(
|
|
23916
|
+
human(
|
|
23917
|
+
" Re-run the PR's retrieval-evals check: it compares flat against its own run.",
|
|
23918
|
+
opts
|
|
23919
|
+
);
|
|
23247
23920
|
}
|
|
23248
23921
|
human("", opts);
|
|
23249
23922
|
}
|
|
23250
23923
|
async function runEvalPromote(options) {
|
|
23251
|
-
const opts = {
|
|
23924
|
+
const opts = {
|
|
23925
|
+
json: options.json,
|
|
23926
|
+
fields: options.fields,
|
|
23927
|
+
quiet: options.quiet
|
|
23928
|
+
};
|
|
23252
23929
|
let body;
|
|
23253
23930
|
if (options.demote) {
|
|
23254
23931
|
if (!options.brand || !options.qrelsVersion) {
|
|
@@ -23309,7 +23986,11 @@ async function runEvalPromote(options) {
|
|
|
23309
23986
|
emitSuccess(data, opts, (d) => render(d, opts));
|
|
23310
23987
|
} catch (err) {
|
|
23311
23988
|
const e = err;
|
|
23312
|
-
emitError(
|
|
23989
|
+
emitError(
|
|
23990
|
+
{ code: e.errorCode ?? "promote_failed", message: e.message },
|
|
23991
|
+
opts,
|
|
23992
|
+
1
|
|
23993
|
+
);
|
|
23313
23994
|
}
|
|
23314
23995
|
}
|
|
23315
23996
|
var init_eval_promote = __esm({
|
|
@@ -23348,7 +24029,10 @@ function slugifyTestSetName(name) {
|
|
|
23348
24029
|
}
|
|
23349
24030
|
function printCreated(data, opts) {
|
|
23350
24031
|
human("", opts);
|
|
23351
|
-
human(
|
|
24032
|
+
human(
|
|
24033
|
+
` Created "${data.name}" (${data.evidence_kind ?? "unclassified"}).`,
|
|
24034
|
+
opts
|
|
24035
|
+
);
|
|
23352
24036
|
human("", opts);
|
|
23353
24037
|
human(` Set: ${data.id}`, opts);
|
|
23354
24038
|
human(` Slug: ${data.slug}`, opts);
|
|
@@ -23357,11 +24041,11 @@ function printCreated(data, opts) {
|
|
|
23357
24041
|
human(" No cases yet \u2014 a set with none will not run. Add them next.", opts);
|
|
23358
24042
|
if (data.evidence_kind === "compare") {
|
|
23359
24043
|
human("", opts);
|
|
24044
|
+
human(" This classifies the set \u2014 it does not start a comparison.", opts);
|
|
23360
24045
|
human(
|
|
23361
|
-
"
|
|
24046
|
+
" Ablations run per skill: `bamboo-agents eval ablate --help`.",
|
|
23362
24047
|
opts
|
|
23363
24048
|
);
|
|
23364
|
-
human(" Ablations run per skill: `bamboo-agents eval ablate --help`.", opts);
|
|
23365
24049
|
}
|
|
23366
24050
|
human("", opts);
|
|
23367
24051
|
}
|
|
@@ -23541,7 +24225,10 @@ async function runEvalSetsAddCases(options) {
|
|
|
23541
24225
|
const added = finalIds.length - existingCount;
|
|
23542
24226
|
human("", opts);
|
|
23543
24227
|
if (options.replace) {
|
|
23544
|
-
human(
|
|
24228
|
+
human(
|
|
24229
|
+
` Set ${options.set} now holds exactly ${finalIds.length} cases.`,
|
|
24230
|
+
opts
|
|
24231
|
+
);
|
|
23545
24232
|
} else {
|
|
23546
24233
|
human(
|
|
23547
24234
|
` Added ${added} of ${incoming.length} to ${options.set} \u2014 ${finalIds.length} cases total.`,
|
|
@@ -23549,7 +24236,10 @@ async function runEvalSetsAddCases(options) {
|
|
|
23549
24236
|
);
|
|
23550
24237
|
const skipped = incoming.length - added;
|
|
23551
24238
|
if (skipped > 0) {
|
|
23552
|
-
human(
|
|
24239
|
+
human(
|
|
24240
|
+
` ${skipped} ${skipped === 1 ? "was" : "were"} already in the set.`,
|
|
24241
|
+
opts
|
|
24242
|
+
);
|
|
23553
24243
|
}
|
|
23554
24244
|
}
|
|
23555
24245
|
human("", opts);
|
|
@@ -23618,9 +24308,12 @@ var ENVELOPE = {
|
|
|
23618
24308
|
},
|
|
23619
24309
|
note: "Every --json (or piped) response is wrapped in this envelope. On success, `data` matches the command's `output_schema`. On failure, `error.code` is a stable string an agent can branch on. stdout carries only the envelope; human/diagnostic text goes to stderr."
|
|
23620
24310
|
};
|
|
24311
|
+
function schemaTypeName(schema) {
|
|
24312
|
+
return schema?._def?.typeName ?? "";
|
|
24313
|
+
}
|
|
23621
24314
|
function zodToJsonSchema(schema) {
|
|
23622
24315
|
const s = schema;
|
|
23623
|
-
const typeName = s
|
|
24316
|
+
const typeName = schemaTypeName(s);
|
|
23624
24317
|
switch (typeName) {
|
|
23625
24318
|
case "ZodString":
|
|
23626
24319
|
return { type: "string" };
|
|
@@ -23652,33 +24345,37 @@ function zodToJsonSchema(schema) {
|
|
|
23652
24345
|
return items ? { type: "array", items } : { type: "array" };
|
|
23653
24346
|
}
|
|
23654
24347
|
case "ZodObject": {
|
|
23655
|
-
|
|
23656
|
-
const properties = {};
|
|
23657
|
-
const required = [];
|
|
23658
|
-
for (const [key, value] of Object.entries(shape)) {
|
|
23659
|
-
const fieldSchema = zodToJsonSchema(value);
|
|
23660
|
-
if (fieldSchema !== null) {
|
|
23661
|
-
properties[key] = fieldSchema;
|
|
23662
|
-
}
|
|
23663
|
-
const fieldTypeName = value?._def?.typeName ?? "";
|
|
23664
|
-
if (fieldTypeName !== "ZodOptional") {
|
|
23665
|
-
required.push(key);
|
|
23666
|
-
}
|
|
23667
|
-
}
|
|
23668
|
-
const result = { type: "object", properties };
|
|
23669
|
-
if (required.length > 0) {
|
|
23670
|
-
result.required = required;
|
|
23671
|
-
}
|
|
23672
|
-
return result;
|
|
24348
|
+
return zodObjectSchema(s._def.shape());
|
|
23673
24349
|
}
|
|
23674
24350
|
default:
|
|
23675
24351
|
return null;
|
|
23676
24352
|
}
|
|
23677
24353
|
}
|
|
24354
|
+
function zodObjectSchema(shape) {
|
|
24355
|
+
const properties = {};
|
|
24356
|
+
const required = [];
|
|
24357
|
+
for (const [key, value] of Object.entries(shape)) {
|
|
24358
|
+
const fieldSchema = zodToJsonSchema(value);
|
|
24359
|
+
if (fieldSchema !== null) properties[key] = fieldSchema;
|
|
24360
|
+
const fieldTypeName = schemaTypeName(value);
|
|
24361
|
+
if (fieldTypeName !== "ZodOptional") required.push(key);
|
|
24362
|
+
}
|
|
24363
|
+
const result = { type: "object", properties };
|
|
24364
|
+
if (required.length > 0) result.required = required;
|
|
24365
|
+
return result;
|
|
24366
|
+
}
|
|
23678
24367
|
async function loadOutputSchemas() {
|
|
23679
24368
|
const map = /* @__PURE__ */ new Map();
|
|
23680
24369
|
try {
|
|
23681
|
-
const [
|
|
24370
|
+
const [
|
|
24371
|
+
history,
|
|
24372
|
+
changes,
|
|
24373
|
+
knowledgeSlots,
|
|
24374
|
+
knowledgeSave,
|
|
24375
|
+
onboarding2,
|
|
24376
|
+
agents2,
|
|
24377
|
+
evalAb
|
|
24378
|
+
] = await Promise.all([
|
|
23682
24379
|
Promise.resolve().then(() => (init_history(), history_exports)).catch(() => null),
|
|
23683
24380
|
Promise.resolve().then(() => (init_changes(), changes_exports)).catch(() => null),
|
|
23684
24381
|
Promise.resolve().then(() => (init_knowledge_slots(), knowledge_slots_exports)).catch(() => null),
|
|
@@ -23687,45 +24384,22 @@ async function loadOutputSchemas() {
|
|
|
23687
24384
|
Promise.resolve().then(() => (init_agents(), agents_exports)).catch(() => null),
|
|
23688
24385
|
Promise.resolve().then(() => (init_eval_ab(), eval_ab_exports)).catch(() => null)
|
|
23689
24386
|
]);
|
|
23690
|
-
|
|
23691
|
-
|
|
23692
|
-
|
|
23693
|
-
|
|
23694
|
-
|
|
23695
|
-
|
|
23696
|
-
|
|
23697
|
-
|
|
23698
|
-
|
|
23699
|
-
|
|
23700
|
-
|
|
23701
|
-
|
|
23702
|
-
|
|
23703
|
-
|
|
23704
|
-
|
|
23705
|
-
|
|
23706
|
-
if (onboarding2?.OnboardingStatusResponseSchema) {
|
|
23707
|
-
const s = zodToJsonSchema(onboarding2.OnboardingStatusResponseSchema);
|
|
23708
|
-
if (s) map.set("onboarding status", s);
|
|
23709
|
-
}
|
|
23710
|
-
if (agents2?.CliAgentsListResponseSchema) {
|
|
23711
|
-
const s = zodToJsonSchema(agents2.CliAgentsListResponseSchema);
|
|
23712
|
-
if (s) map.set("agents list", s);
|
|
23713
|
-
}
|
|
23714
|
-
if (agents2?.CliAgentDetailSchema) {
|
|
23715
|
-
const s = zodToJsonSchema(agents2.CliAgentDetailSchema);
|
|
23716
|
-
if (s) map.set("agents get", s);
|
|
23717
|
-
}
|
|
23718
|
-
if (agents2?.CliCreateAgentResponseSchema) {
|
|
23719
|
-
const s = zodToJsonSchema(agents2.CliCreateAgentResponseSchema);
|
|
23720
|
-
if (s) map.set("agents provision", s);
|
|
23721
|
-
}
|
|
23722
|
-
if (agents2?.CliAgentPauseResponseSchema) {
|
|
23723
|
-
const s = zodToJsonSchema(agents2.CliAgentPauseResponseSchema);
|
|
23724
|
-
if (s) map.set("agents pause", s);
|
|
23725
|
-
}
|
|
23726
|
-
if (evalAb?.EvalAbResponseSchema) {
|
|
23727
|
-
const s = zodToJsonSchema(evalAb.EvalAbResponseSchema);
|
|
23728
|
-
if (s) map.set("eval ablate", s);
|
|
24387
|
+
const schemas = [
|
|
24388
|
+
["history", history?.HistoryResponseSchema],
|
|
24389
|
+
["changes", changes?.ChangesResponseSchema],
|
|
24390
|
+
["knowledge slots", knowledgeSlots?.KnowledgeSlotsResponseSchema],
|
|
24391
|
+
["knowledge save", knowledgeSave?.KnowledgeSaveResponseSchema],
|
|
24392
|
+
["onboarding status", onboarding2?.OnboardingStatusResponseSchema],
|
|
24393
|
+
["agents list", agents2?.CliAgentsListResponseSchema],
|
|
24394
|
+
["agents get", agents2?.CliAgentDetailSchema],
|
|
24395
|
+
["agents provision", agents2?.CliCreateAgentResponseSchema],
|
|
24396
|
+
["agents pause", agents2?.CliAgentPauseResponseSchema],
|
|
24397
|
+
["eval ablate", evalAb?.EvalAbResponseSchema]
|
|
24398
|
+
];
|
|
24399
|
+
for (const [command, schema] of schemas) {
|
|
24400
|
+
if (!schema) continue;
|
|
24401
|
+
const converted = zodToJsonSchema(schema);
|
|
24402
|
+
if (converted) map.set(command, converted);
|
|
23729
24403
|
}
|
|
23730
24404
|
} catch {
|
|
23731
24405
|
}
|
|
@@ -23819,12 +24493,20 @@ function detectMisroutedSaveFlag(rawArgs, operands) {
|
|
|
23819
24493
|
// src/index.ts
|
|
23820
24494
|
init_output();
|
|
23821
24495
|
var program2 = new Command();
|
|
23822
|
-
program2.name("bamboo-agents").description("Set up your local Bamboo workspace and drop into Claude.").version(VERSION).option("--no-sync", "Skip the auto-sync git pull on this command").option(
|
|
24496
|
+
program2.name("bamboo-agents").description("Set up your local Bamboo workspace and drop into Claude.").version(VERSION).option("--no-sync", "Skip the auto-sync git pull on this command").option(
|
|
24497
|
+
"--describe",
|
|
24498
|
+
"Emit full JSON manifest of every CLI command (machine introspection)"
|
|
24499
|
+
).option(
|
|
24500
|
+
"--schema <command>",
|
|
24501
|
+
"Emit JSON schema for one command by name, e.g. 'history' or 'knowledge save'"
|
|
24502
|
+
);
|
|
23823
24503
|
program2.action(async () => {
|
|
23824
24504
|
const { runOrchestrator: runOrchestrator2 } = await Promise.resolve().then(() => (init_orchestrator(), orchestrator_exports));
|
|
23825
24505
|
await runOrchestrator2();
|
|
23826
24506
|
});
|
|
23827
|
-
program2.command("login").description(
|
|
24507
|
+
program2.command("login").description(
|
|
24508
|
+
"Sign in to Bamboo via your browser (or use --token for headless setup)"
|
|
24509
|
+
).option(
|
|
23828
24510
|
"--token <session>",
|
|
23829
24511
|
"Headless login with a pre-minted Bamboo session token (skips the browser flow). Used by managed agents + CI environments."
|
|
23830
24512
|
).action(async (opts) => {
|
|
@@ -23851,24 +24533,44 @@ program2.command("open").description("Launch Claude Code at your workspace").opt
|
|
|
23851
24533
|
const { runOpen: runOpen2 } = await Promise.resolve().then(() => (init_open2(), open_exports));
|
|
23852
24534
|
await runOpen2();
|
|
23853
24535
|
});
|
|
23854
|
-
program2.command("status").description("Show current Bamboo CLI state").option("--no-sync", "Skip the auto-sync git pull on this command").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
23855
|
-
|
|
23856
|
-
|
|
23857
|
-
|
|
24536
|
+
program2.command("status").description("Show current Bamboo CLI state").option("--no-sync", "Skip the auto-sync git pull on this command").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24537
|
+
"--fields <list>",
|
|
24538
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24539
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").action(
|
|
24540
|
+
async (options) => {
|
|
24541
|
+
const { runStatus: runStatus2 } = await Promise.resolve().then(() => (init_status(), status_exports));
|
|
24542
|
+
await runStatus2(options);
|
|
24543
|
+
}
|
|
24544
|
+
);
|
|
23858
24545
|
program2.command("doctor").description("Verify your local setup is ready + heal workspace drift").option("--quiet", "Emit JSON without prompting (CI / scripts)").option("--auto-heal", "Apply non-destructive fixes silently").action(async (options) => {
|
|
23859
24546
|
const { runDoctor: runDoctor2 } = await Promise.resolve().then(() => (init_doctor(), doctor_exports));
|
|
23860
24547
|
await runDoctor2({ quiet: options.quiet, autoHeal: options.autoHeal });
|
|
23861
24548
|
});
|
|
23862
|
-
program2.command("save [intent]").description(
|
|
24549
|
+
program2.command("save [intent]").description(
|
|
24550
|
+
"Save your workspace changes (routed write \u2014 auto-merges or queues)"
|
|
24551
|
+
).option("--no-sync", "Skip the auto-sync git pull on this command").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24552
|
+
"--fields <list>",
|
|
24553
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24554
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option(
|
|
24555
|
+
"--dry-run",
|
|
24556
|
+
"Show what would be saved (routed auto/queue) without writing"
|
|
24557
|
+
).action(
|
|
23863
24558
|
async (intent, options) => {
|
|
23864
24559
|
const { runSave: runSave2 } = await Promise.resolve().then(() => (init_save2(), save_exports));
|
|
23865
24560
|
await runSave2(intent, options);
|
|
23866
24561
|
}
|
|
23867
24562
|
);
|
|
23868
|
-
program2.command("update").alias("sync").description(
|
|
23869
|
-
|
|
23870
|
-
|
|
23871
|
-
|
|
24563
|
+
program2.command("update").alias("sync").description(
|
|
24564
|
+
"Update your workspace from the cloud (saves unsaved edits first, then pulls)"
|
|
24565
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24566
|
+
"--fields <list>",
|
|
24567
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24568
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").action(
|
|
24569
|
+
async (options) => {
|
|
24570
|
+
const { runUpdate: runUpdate2 } = await Promise.resolve().then(() => (init_update(), update_exports));
|
|
24571
|
+
await runUpdate2(options);
|
|
24572
|
+
}
|
|
24573
|
+
);
|
|
23872
24574
|
var skills = program2.command("skills").description("Read workspace skills from your local clone");
|
|
23873
24575
|
skills.command("list").description("List every skill in the workspace").option(
|
|
23874
24576
|
"--agent <slug>",
|
|
@@ -23900,171 +24602,411 @@ skills.command("apply <skill-name>").description(
|
|
|
23900
24602
|
await runSkillsApply2(skillName);
|
|
23901
24603
|
});
|
|
23902
24604
|
var knowledge = program2.command("knowledge").description("Knowledge surface for CLI-first skills");
|
|
23903
|
-
knowledge.command("slots").description(
|
|
23904
|
-
|
|
23905
|
-
|
|
23906
|
-
|
|
23907
|
-
|
|
23908
|
-
|
|
23909
|
-
|
|
23910
|
-
});
|
|
24605
|
+
knowledge.command("slots").description(
|
|
24606
|
+
"Print the knowledge slot schema (kind \xD7 scope \u2192 path) + dimensions"
|
|
24607
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24608
|
+
"--fields <list>",
|
|
24609
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24610
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24611
|
+
async (options) => {
|
|
24612
|
+
const { runKnowledgeSlots: runKnowledgeSlots2 } = await Promise.resolve().then(() => (init_knowledge(), knowledge_exports));
|
|
24613
|
+
await runKnowledgeSlots2(options);
|
|
24614
|
+
}
|
|
24615
|
+
);
|
|
24616
|
+
knowledge.command("save").description("Save a knowledge file (routed write \u2014 auto-merges or queues)").requiredOption(
|
|
24617
|
+
"--path <path>",
|
|
24618
|
+
"Repo path (from `knowledge slots`), e.g. brands/acme/knowledge/competitors.md"
|
|
24619
|
+
).option("--content <text>", "Inline file content").option("--content-file <file>", "Read file content from a local path").option("--delete", "Delete the file instead of writing content").option("--intent <text>", "Human-readable summary for the PR body").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24620
|
+
"--fields <list>",
|
|
24621
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24622
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24623
|
+
async (options) => {
|
|
24624
|
+
const { runKnowledgeSave: runKnowledgeSave2 } = await Promise.resolve().then(() => (init_knowledge(), knowledge_exports));
|
|
24625
|
+
await runKnowledgeSave2(options);
|
|
24626
|
+
}
|
|
24627
|
+
);
|
|
23911
24628
|
var inbox = program2.command("inbox").description("Actions on pending workspace PRs (the Inbox)");
|
|
23912
|
-
inbox.command("operations").description("List the supported customer Inbox operations").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
23913
|
-
|
|
23914
|
-
|
|
23915
|
-
|
|
23916
|
-
|
|
23917
|
-
|
|
23918
|
-
|
|
23919
|
-
}
|
|
23920
|
-
|
|
23921
|
-
|
|
23922
|
-
|
|
23923
|
-
|
|
23924
|
-
|
|
23925
|
-
|
|
23926
|
-
|
|
23927
|
-
});
|
|
23928
|
-
|
|
24629
|
+
inbox.command("operations").description("List the supported customer Inbox operations").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24630
|
+
"--fields <list>",
|
|
24631
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24632
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").action(
|
|
24633
|
+
async (options) => {
|
|
24634
|
+
const { runInboxOperations: runInboxOperations2 } = await Promise.resolve().then(() => (init_inbox_management2(), inbox_management_exports));
|
|
24635
|
+
await runInboxOperations2(options);
|
|
24636
|
+
}
|
|
24637
|
+
);
|
|
24638
|
+
inbox.command("organizations [query]").description("List or search customer organizations available for --org").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24639
|
+
"--fields <list>",
|
|
24640
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24641
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").action(
|
|
24642
|
+
async (query, options) => {
|
|
24643
|
+
const { runInboxOrganizations: runInboxOrganizations2 } = await Promise.resolve().then(() => (init_inbox_management2(), inbox_management_exports));
|
|
24644
|
+
await runInboxOrganizations2({ query, ...options });
|
|
24645
|
+
}
|
|
24646
|
+
);
|
|
24647
|
+
inbox.command("members").description(
|
|
24648
|
+
"Find a customer organization's members before assigning an Inbox opportunity"
|
|
24649
|
+
).option(
|
|
24650
|
+
"--org <uuid-or-name>",
|
|
24651
|
+
"Customer organization UUID or unique name (required for user sessions)"
|
|
24652
|
+
).option("--query <person>", "Find one member by name, email, or auth user ID").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24653
|
+
"--fields <list>",
|
|
24654
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24655
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").action(
|
|
24656
|
+
async (options) => {
|
|
24657
|
+
const { runInboxMembers: runInboxMembers2 } = await Promise.resolve().then(() => (init_inbox_management2(), inbox_management_exports));
|
|
24658
|
+
await runInboxMembers2(options);
|
|
24659
|
+
}
|
|
24660
|
+
);
|
|
24661
|
+
inbox.command("manage").description("Call one catalog-advertised customer Inbox operation").argument("<operation>", "Exact operation name").requiredOption(
|
|
24662
|
+
"--input <json-or-@file>",
|
|
24663
|
+
"JSON object, inline or loaded from @path"
|
|
24664
|
+
).option(
|
|
24665
|
+
"--org <uuid-or-name>",
|
|
24666
|
+
"Customer organization UUID or unique name (required for user sessions)"
|
|
24667
|
+
).option(
|
|
24668
|
+
"--approve",
|
|
24669
|
+
"Confirm the exact displayed mutation after user approval"
|
|
24670
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24671
|
+
"--fields <list>",
|
|
24672
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24673
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").action(
|
|
24674
|
+
async (operation, options) => {
|
|
24675
|
+
const { runInboxManage: runInboxManage2 } = await Promise.resolve().then(() => (init_inbox_management2(), inbox_management_exports));
|
|
24676
|
+
await runInboxManage2({ operation, ...options });
|
|
24677
|
+
}
|
|
24678
|
+
);
|
|
24679
|
+
inbox.command("revise").description(
|
|
24680
|
+
"Request a revision on a pending inbox PR (dispatches the source agent)"
|
|
24681
|
+
).requiredOption("--pr <number>", "PR number in the workspace repo").requiredOption(
|
|
24682
|
+
"--feedback <text>",
|
|
24683
|
+
"One sentence describing the change to make"
|
|
24684
|
+
).requiredOption(
|
|
24685
|
+
"--file <path>",
|
|
24686
|
+
"Repo-relative path of the file the feedback targets"
|
|
24687
|
+
).option(
|
|
24688
|
+
"--agent <id>",
|
|
24689
|
+
"Source agent id (default: resolved from the PR body)"
|
|
24690
|
+
).option(
|
|
23929
24691
|
"--selection-file <path>",
|
|
23930
24692
|
"JSON file with the selected diff lines (array of {kind, old_line, new_line, content})"
|
|
23931
|
-
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24693
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24694
|
+
"--fields <list>",
|
|
24695
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24696
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (options) => {
|
|
23932
24697
|
const { runInboxRevise: runInboxRevise2 } = await Promise.resolve().then(() => (init_inbox(), inbox_exports));
|
|
23933
24698
|
await runInboxRevise2(options);
|
|
23934
24699
|
});
|
|
23935
|
-
inbox.command("apply-revision").description(
|
|
23936
|
-
|
|
23937
|
-
|
|
23938
|
-
|
|
24700
|
+
inbox.command("apply-revision").description(
|
|
24701
|
+
"Commit revised file content to a pending inbox PR's head branch (the dispatched:false follow-up to `inbox revise`)"
|
|
24702
|
+
).requiredOption("--pr <number>", "PR number in the workspace repo").requiredOption(
|
|
24703
|
+
"--file <path>",
|
|
24704
|
+
"Repo-relative path of the file being revised"
|
|
24705
|
+
).requiredOption(
|
|
24706
|
+
"--content-file <path>",
|
|
24707
|
+
"Local file holding the COMPLETE revised content (edit the head_file from `inbox revise`)"
|
|
24708
|
+
).requiredOption(
|
|
24709
|
+
"--sha <sha>",
|
|
24710
|
+
"The file_sha from `inbox revise` (GitHub's stale-write check)"
|
|
24711
|
+
).requiredOption(
|
|
24712
|
+
"--message <text>",
|
|
24713
|
+
"Short commit message, e.g. 'revision: tighten tone in intro'"
|
|
24714
|
+
).option(
|
|
24715
|
+
"--branch <name>",
|
|
24716
|
+
"PR head branch from `inbox revise` (validated server-side)"
|
|
24717
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24718
|
+
"--fields <list>",
|
|
24719
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24720
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24721
|
+
async (options) => {
|
|
24722
|
+
const { runInboxApplyRevision: runInboxApplyRevision2 } = await Promise.resolve().then(() => (init_inbox(), inbox_exports));
|
|
24723
|
+
await runInboxApplyRevision2(options);
|
|
24724
|
+
}
|
|
24725
|
+
);
|
|
23939
24726
|
program2.command("history").description("Recent workspace actions (reverse-chronological)").option("--org <org>", "Read one organization (UUID or unique name)").option("--limit <n>", "Max entries (default 20, max 100)").option(
|
|
23940
24727
|
"--source <runtime>",
|
|
23941
24728
|
"Filter by runtime origin (boo | sandbox-boo | managed-agent)"
|
|
23942
|
-
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
23943
|
-
|
|
23944
|
-
|
|
23945
|
-
|
|
23946
|
-
|
|
24729
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24730
|
+
"--fields <list>",
|
|
24731
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24732
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24733
|
+
async (options) => {
|
|
24734
|
+
const { runHistory: runHistory2 } = await Promise.resolve().then(() => (init_history2(), history_exports2));
|
|
24735
|
+
await runHistory2(options);
|
|
24736
|
+
}
|
|
24737
|
+
);
|
|
24738
|
+
program2.command("changes").description("Structured change log \u2014 what was created/updated/deleted").option("--org <org>", "Read one organization (UUID or unique name)").option("--limit <n>", "Max entries (default 20, max 100)").option("--brand <id>", "Filter to one brand_id").option("--since <iso>", "Only changes at/after this ISO timestamp").option("--entity-type <type>", "Filter by entity type").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24739
|
+
"--fields <list>",
|
|
24740
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24741
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
23947
24742
|
async (options) => {
|
|
23948
24743
|
const { runChanges: runChanges2 } = await Promise.resolve().then(() => (init_history2(), history_exports2));
|
|
23949
24744
|
await runChanges2(options);
|
|
23950
24745
|
}
|
|
23951
24746
|
);
|
|
23952
24747
|
var context = program2.command("context").description("Context health for CLI-first skills");
|
|
23953
|
-
context.command("health").description("Knowledge/context health \u2014 grade, score, and gaps").option("--org <org>", "Read one organization (UUID or unique name)").option("--brand <id>", "Scope to a brand_id (default: org)").option("--agent <id>", "Scope to an agent_id").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
23954
|
-
|
|
23955
|
-
|
|
23956
|
-
|
|
23957
|
-
|
|
24748
|
+
context.command("health").description("Knowledge/context health \u2014 grade, score, and gaps").option("--org <org>", "Read one organization (UUID or unique name)").option("--brand <id>", "Scope to a brand_id (default: org)").option("--agent <id>", "Scope to an agent_id").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24749
|
+
"--fields <list>",
|
|
24750
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24751
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24752
|
+
async (options) => {
|
|
24753
|
+
const { runContextHealth: runContextHealth2 } = await Promise.resolve().then(() => (init_context(), context_exports));
|
|
24754
|
+
await runContextHealth2(options);
|
|
24755
|
+
}
|
|
24756
|
+
);
|
|
24757
|
+
program2.command("usage").description(
|
|
24758
|
+
"Agent usage \u2014 sessions, per-tool call counts, first/last seen (from agent_logs)"
|
|
24759
|
+
).option("--org <org>", "Read one organization (UUID or unique name)").option("--agent <id>", "Scope to an agent_id (default: org-wide)").option("--window-days <n>", "Trailing window in days (default: 14, max: 90)").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24760
|
+
"--fields <list>",
|
|
24761
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24762
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
23958
24763
|
async (options) => {
|
|
23959
24764
|
const { runUsage: runUsage2 } = await Promise.resolve().then(() => (init_usage2(), usage_exports));
|
|
23960
24765
|
await runUsage2(options);
|
|
23961
24766
|
}
|
|
23962
24767
|
);
|
|
23963
24768
|
var onboarding = program2.command("onboarding").description("Onboarding status for CLI-first skills");
|
|
23964
|
-
onboarding.command("status").description(
|
|
23965
|
-
|
|
23966
|
-
|
|
23967
|
-
|
|
24769
|
+
onboarding.command("status").description(
|
|
24770
|
+
"Composite onboarding gate (activation milestones + knowledge health)"
|
|
24771
|
+
).option("--org <org>", "Read one organization (UUID or unique name)").option("--brand <id>", "Scope to a brand_id (default: org)").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24772
|
+
"--fields <list>",
|
|
24773
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24774
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24775
|
+
async (options) => {
|
|
24776
|
+
const { runOnboardingStatus: runOnboardingStatus2 } = await Promise.resolve().then(() => (init_onboarding(), onboarding_exports));
|
|
24777
|
+
await runOnboardingStatus2(options);
|
|
24778
|
+
}
|
|
24779
|
+
);
|
|
23968
24780
|
var brand = program2.command("brand").description("Manage brand metadata + editors");
|
|
23969
|
-
brand.command("update <brand-id>").description("Update brand metadata (website URL)").requiredOption("--website <url>", "Brand website URL").option("--json", "Emit raw JSON").action(
|
|
23970
|
-
|
|
23971
|
-
|
|
23972
|
-
|
|
24781
|
+
brand.command("update <brand-id>").description("Update brand metadata (website URL)").requiredOption("--website <url>", "Brand website URL").option("--json", "Emit raw JSON").action(
|
|
24782
|
+
async (brandId, options) => {
|
|
24783
|
+
const { runBrandUpdate: runBrandUpdate2 } = await Promise.resolve().then(() => (init_brand2(), brand_exports));
|
|
24784
|
+
await runBrandUpdate2(brandId, options);
|
|
24785
|
+
}
|
|
24786
|
+
);
|
|
23973
24787
|
var brandEditor = brand.command("editor").description("Grant/revoke brand editor access (admin-only)");
|
|
23974
|
-
brandEditor.command("add <brand-id> <user-id>").description("Grant a user editor access on a brand").option("--json", "Emit raw JSON").action(
|
|
23975
|
-
|
|
23976
|
-
|
|
23977
|
-
|
|
23978
|
-
|
|
23979
|
-
|
|
23980
|
-
|
|
23981
|
-
|
|
24788
|
+
brandEditor.command("add <brand-id> <user-id>").description("Grant a user editor access on a brand").option("--json", "Emit raw JSON").action(
|
|
24789
|
+
async (brandId, userId, options) => {
|
|
24790
|
+
const { runBrandEditor: runBrandEditor2 } = await Promise.resolve().then(() => (init_brand2(), brand_exports));
|
|
24791
|
+
await runBrandEditor2("add", brandId, userId, options);
|
|
24792
|
+
}
|
|
24793
|
+
);
|
|
24794
|
+
brandEditor.command("remove <brand-id> <user-id>").description("Revoke a user's editor access on a brand").option("--json", "Emit raw JSON").action(
|
|
24795
|
+
async (brandId, userId, options) => {
|
|
24796
|
+
const { runBrandEditor: runBrandEditor2 } = await Promise.resolve().then(() => (init_brand2(), brand_exports));
|
|
24797
|
+
await runBrandEditor2("remove", brandId, userId, options);
|
|
24798
|
+
}
|
|
24799
|
+
);
|
|
23982
24800
|
var agents = program2.command("agents").description("Manage agents \u2014 list, get, provision, activate, pause");
|
|
23983
|
-
agents.command("list").description("List agents with their lifecycle state").option("--org <org>", "Read one organization (UUID or unique name)").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
23984
|
-
|
|
23985
|
-
|
|
23986
|
-
|
|
23987
|
-
|
|
23988
|
-
|
|
23989
|
-
|
|
23990
|
-
}
|
|
23991
|
-
|
|
24801
|
+
agents.command("list").description("List agents with their lifecycle state").option("--org <org>", "Read one organization (UUID or unique name)").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24802
|
+
"--fields <list>",
|
|
24803
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24804
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24805
|
+
async (options) => {
|
|
24806
|
+
const { runAgentsList: runAgentsList2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
24807
|
+
await runAgentsList2(options);
|
|
24808
|
+
}
|
|
24809
|
+
);
|
|
24810
|
+
agents.command("get <agent>").description("Show one agent's full config (accepts id, slug, or name)").option("--org <org>", "Read one organization (UUID or unique name)").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24811
|
+
"--fields <list>",
|
|
24812
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24813
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24814
|
+
async (agent, options) => {
|
|
24815
|
+
const { runAgentsGet: runAgentsGet2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
24816
|
+
await runAgentsGet2(agent, options);
|
|
24817
|
+
}
|
|
24818
|
+
);
|
|
24819
|
+
agents.command("provision <name>").description("Create a new agent (immediately active)").option(
|
|
24820
|
+
"--brand <id>",
|
|
24821
|
+
"Brand the agent belongs to (auto-picked if you have exactly one)"
|
|
24822
|
+
).option(
|
|
24823
|
+
"--slug <slug>",
|
|
24824
|
+
"Optional kebab-case slug (derived from name otherwise)"
|
|
24825
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24826
|
+
"--fields <list>",
|
|
24827
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24828
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
23992
24829
|
async (name, options) => {
|
|
23993
24830
|
const { runAgentsProvision: runAgentsProvision2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
23994
24831
|
await runAgentsProvision2(name, options);
|
|
23995
24832
|
}
|
|
23996
24833
|
);
|
|
23997
|
-
agents.command("update <agent>").description(
|
|
24834
|
+
agents.command("update <agent>").description(
|
|
24835
|
+
"Update an agent's name / description / template / brand (accepts id, slug, or name)"
|
|
24836
|
+
).option("--name <name>", "New agent name").option("--description <text>", "New description").option("--template <key>", "Template key").option(
|
|
24837
|
+
"--brand <id>",
|
|
24838
|
+
"Reassign to this brand (replaces the current assignment)"
|
|
24839
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24840
|
+
"--fields <list>",
|
|
24841
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24842
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
23998
24843
|
async (agent, options) => {
|
|
23999
24844
|
const { runAgentsUpdate: runAgentsUpdate2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
24000
24845
|
await runAgentsUpdate2(agent, options);
|
|
24001
24846
|
}
|
|
24002
24847
|
);
|
|
24003
|
-
agents.command("delete <agent>").description(
|
|
24004
|
-
|
|
24005
|
-
|
|
24006
|
-
|
|
24007
|
-
|
|
24848
|
+
agents.command("delete <agent>").description(
|
|
24849
|
+
"Delete a draft/broken agent (accepts id, slug, or name) \u2014 NOT reversible"
|
|
24850
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24851
|
+
"--fields <list>",
|
|
24852
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24853
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24854
|
+
async (agent, options) => {
|
|
24855
|
+
const { runAgentsDelete: runAgentsDelete2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
24856
|
+
await runAgentsDelete2(agent, options);
|
|
24857
|
+
}
|
|
24858
|
+
);
|
|
24859
|
+
agents.command("clone <source> <target>").description(
|
|
24860
|
+
"Clone files (+ brands) from <source> agent onto <target> (accept id, slug, or name)"
|
|
24861
|
+
).option("--no-brands", "Skip copying brand assignments (files only)").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24862
|
+
"--fields <list>",
|
|
24863
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24864
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24008
24865
|
async (source, target, options) => {
|
|
24009
24866
|
const { runAgentsClone: runAgentsClone2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
24010
24867
|
await runAgentsClone2(source, target, options);
|
|
24011
24868
|
}
|
|
24012
24869
|
);
|
|
24013
|
-
agents.command("enable-template <agent>").description(
|
|
24870
|
+
agents.command("enable-template <agent>").description(
|
|
24871
|
+
"Apply a template to an agent (template-only; Slack channel binding is set in the UI)"
|
|
24872
|
+
).requiredOption(
|
|
24873
|
+
"--template <id>",
|
|
24874
|
+
"Template id (e.g. marketing_account_manager)"
|
|
24875
|
+
).requiredOption("--brand <id>", "Brand id to scope the template to").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24876
|
+
"--fields <list>",
|
|
24877
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24878
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24014
24879
|
async (agent, options) => {
|
|
24015
24880
|
const { runAgentsEnableTemplate: runAgentsEnableTemplate2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
24016
24881
|
await runAgentsEnableTemplate2(agent, options);
|
|
24017
24882
|
}
|
|
24018
24883
|
);
|
|
24019
|
-
agents.command("activate <agent>").description(
|
|
24020
|
-
|
|
24021
|
-
|
|
24022
|
-
|
|
24023
|
-
|
|
24024
|
-
|
|
24025
|
-
|
|
24026
|
-
});
|
|
24884
|
+
agents.command("activate <agent>").description(
|
|
24885
|
+
"Activate an agent \u2014 unpause it (or publish a draft). Admin-only."
|
|
24886
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24887
|
+
"--fields <list>",
|
|
24888
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24889
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24890
|
+
async (agent, options) => {
|
|
24891
|
+
const { runAgentsActivate: runAgentsActivate2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
24892
|
+
await runAgentsActivate2(agent, options);
|
|
24893
|
+
}
|
|
24894
|
+
);
|
|
24895
|
+
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(
|
|
24896
|
+
"--fields <list>",
|
|
24897
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24898
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24899
|
+
async (agent, options) => {
|
|
24900
|
+
const { runAgentsPause: runAgentsPause2 } = await Promise.resolve().then(() => (init_agents2(), agents_exports2));
|
|
24901
|
+
await runAgentsPause2(agent, options);
|
|
24902
|
+
}
|
|
24903
|
+
);
|
|
24027
24904
|
var episode = program2.command("episode").description("Pilot decision-ledger \u2014 log outcomes against recommendations");
|
|
24028
24905
|
episode.command("log-outcome").description(
|
|
24029
24906
|
"Log an outcome episode chained to a recommendation (closes the accept\u2192result loop)"
|
|
24030
|
-
).requiredOption(
|
|
24031
|
-
|
|
24032
|
-
|
|
24033
|
-
|
|
24907
|
+
).requiredOption(
|
|
24908
|
+
"--rec <uuid>",
|
|
24909
|
+
"Recommendation episode id to chain this outcome to"
|
|
24910
|
+
).requiredOption("--brand <id>", "Brand id the recommendation belongs to").requiredOption(
|
|
24911
|
+
"--description <text>",
|
|
24912
|
+
"What happened after the recommendation was applied"
|
|
24913
|
+
).option(
|
|
24914
|
+
"--metrics-before <json>",
|
|
24915
|
+
`JSON object of metrics before the change, e.g. '{"cpa":35}'`
|
|
24916
|
+
).option(
|
|
24917
|
+
"--metrics-after <json>",
|
|
24918
|
+
`JSON object of metrics after the change, e.g. '{"cpa":31}'`
|
|
24919
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24920
|
+
async (options) => {
|
|
24921
|
+
const { runEpisodeLogOutcome: runEpisodeLogOutcome2 } = await Promise.resolve().then(() => (init_episode(), episode_exports));
|
|
24922
|
+
await runEpisodeLogOutcome2(options);
|
|
24923
|
+
}
|
|
24924
|
+
);
|
|
24034
24925
|
episode.command("log-rec").description(
|
|
24035
24926
|
"Log a cited recommendation episode (sandbox-Boo pilot runtime, BAM-2944)"
|
|
24036
|
-
).requiredOption("--brand <id>", "Brand id the recommendation belongs to").requiredOption(
|
|
24927
|
+
).requiredOption("--brand <id>", "Brand id the recommendation belongs to").requiredOption(
|
|
24928
|
+
"--title <text>",
|
|
24929
|
+
"Short imperative title for the recommendation"
|
|
24930
|
+
).requiredOption("--rationale <text>", "Explanation grounded in evidence").option(
|
|
24037
24931
|
"--cites <json>",
|
|
24038
24932
|
"JSON array of citations \u2014 [{path, excerpt, sha}] or [{episode_id}]. Omit when --no-prior-history is set."
|
|
24039
24933
|
).option(
|
|
24040
24934
|
"--no-prior-history",
|
|
24041
24935
|
"Brand has no prior knowledge to cite (cold-start). Mutually exclusive with --cites."
|
|
24042
|
-
).option("--action-items <json>", "Optional JSON array of action item strings").option(
|
|
24936
|
+
).option("--action-items <json>", "Optional JSON array of action item strings").option(
|
|
24937
|
+
"--conversation-id <uuid>",
|
|
24938
|
+
"Conversation UUID to link this episode to a Boo session"
|
|
24939
|
+
).option(
|
|
24940
|
+
"--idempotency-key <key>",
|
|
24941
|
+
"Client key \u2014 same key + same brand returns existing episode"
|
|
24942
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option("--quiet", "Suppress human chatter (data/errors only)").action(async (options) => {
|
|
24043
24943
|
const { runEpisodeLogRec: runEpisodeLogRec2 } = await Promise.resolve().then(() => (init_episode(), episode_exports));
|
|
24044
24944
|
await runEpisodeLogRec2(options);
|
|
24045
24945
|
});
|
|
24046
|
-
var evals = program2.command("eval").description(
|
|
24047
|
-
|
|
24048
|
-
|
|
24049
|
-
|
|
24050
|
-
|
|
24051
|
-
|
|
24052
|
-
|
|
24053
|
-
|
|
24054
|
-
|
|
24055
|
-
|
|
24056
|
-
|
|
24057
|
-
|
|
24058
|
-
|
|
24946
|
+
var evals = program2.command("eval").description(
|
|
24947
|
+
"Evaluation surface \u2014 A/B a candidate skill against its baseline"
|
|
24948
|
+
);
|
|
24949
|
+
evals.command("scope").description(
|
|
24950
|
+
"Resolve one organization and list its authoritative brands and agents"
|
|
24951
|
+
).option(
|
|
24952
|
+
"--org <uuid-or-name>",
|
|
24953
|
+
"Customer organization UUID or name (required for user sessions)"
|
|
24954
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24955
|
+
"--fields <list>",
|
|
24956
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24957
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").action(
|
|
24958
|
+
async (options) => {
|
|
24959
|
+
const { runEvalScope: runEvalScope2 } = await Promise.resolve().then(() => (init_eval_management2(), eval_management_exports));
|
|
24960
|
+
await runEvalScope2(options);
|
|
24961
|
+
}
|
|
24962
|
+
);
|
|
24963
|
+
evals.command("operations").description(
|
|
24964
|
+
"List the exact supported investigation, wave, and case management operations"
|
|
24965
|
+
).option(
|
|
24966
|
+
"--org <uuid-or-name>",
|
|
24967
|
+
"Operate in this organization (exact/unique names resolve authoritatively)"
|
|
24968
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24969
|
+
"--fields <list>",
|
|
24970
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24971
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").action(
|
|
24972
|
+
async (options) => {
|
|
24973
|
+
const { runEvalOperations: runEvalOperations2 } = await Promise.resolve().then(() => (init_eval_management2(), eval_management_exports));
|
|
24974
|
+
await runEvalOperations2(options);
|
|
24975
|
+
}
|
|
24976
|
+
);
|
|
24977
|
+
evals.command("manage").description("Call one canonical investigation, wave, or case operation").argument("<operation>", "Exact name from `eval operations`").requiredOption(
|
|
24978
|
+
"--input <json-or-@file>",
|
|
24979
|
+
"JSON object, inline or loaded from @path"
|
|
24980
|
+
).option(
|
|
24981
|
+
"--org <uuid-or-name>",
|
|
24982
|
+
"Operate in this organization (exact/unique names resolve authoritatively)"
|
|
24983
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
24984
|
+
"--fields <list>",
|
|
24985
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
24986
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24987
|
+
async (operation, options) => {
|
|
24988
|
+
const { runEvalManage: runEvalManage2 } = await Promise.resolve().then(() => (init_eval_management2(), eval_management_exports));
|
|
24989
|
+
await runEvalManage2({ operation, ...options });
|
|
24990
|
+
}
|
|
24991
|
+
);
|
|
24059
24992
|
evals.command("ablate").description(
|
|
24060
24993
|
"Start an A/B test: stage a candidate skill body against the published baseline"
|
|
24061
|
-
).requiredOption("--agent <id>", "Agent id whose skill is under test").requiredOption(
|
|
24994
|
+
).requiredOption("--agent <id>", "Agent id whose skill is under test").requiredOption(
|
|
24995
|
+
"--skill <name>",
|
|
24996
|
+
"kebab-case skill name (must be one of this agent's own skills)"
|
|
24997
|
+
).requiredOption(
|
|
24062
24998
|
"--hypothesis <text>",
|
|
24063
24999
|
"Plain-language claim the edit is meant to produce (an experiment is a claim, not a diff)"
|
|
24064
|
-
).requiredOption("--body <path>", "Path to the candidate SKILL.md").option(
|
|
25000
|
+
).requiredOption("--body <path>", "Path to the candidate SKILL.md").option(
|
|
25001
|
+
"--brand <id>",
|
|
25002
|
+
"Brand id \u2014 only needed when the agent spans more than one brand"
|
|
25003
|
+
).option(
|
|
24065
25004
|
"--set <id>",
|
|
24066
25005
|
"Test set id \u2014 run THIS set's cases instead of the skill-attributed holdout"
|
|
24067
|
-
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
25006
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
25007
|
+
"--fields <list>",
|
|
25008
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
25009
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24068
25010
|
async (options) => {
|
|
24069
25011
|
const { runEvalAblate: runEvalAblate2 } = await Promise.resolve().then(() => (init_eval_ab2(), eval_ab_exports2));
|
|
24070
25012
|
await runEvalAblate2(options);
|
|
@@ -24072,29 +25014,63 @@ evals.command("ablate").description(
|
|
|
24072
25014
|
);
|
|
24073
25015
|
evals.command("promote").description(
|
|
24074
25016
|
"Promote a correctness run as the baseline for its qrels version, or --demote the current one"
|
|
24075
|
-
).argument(
|
|
25017
|
+
).argument(
|
|
25018
|
+
"[run-id]",
|
|
25019
|
+
"Run id printed by the correctness gate (omit with --demote)"
|
|
25020
|
+
).requiredOption(
|
|
25021
|
+
"--reason <text>",
|
|
25022
|
+
"Why this run is the reference now \u2014 recorded on the row"
|
|
25023
|
+
).option("--pr <url>", "PR URL to record as the promotion's source").option(
|
|
25024
|
+
"--demote",
|
|
25025
|
+
"Write a tombstone: the version has no baseline until a human promotes one"
|
|
25026
|
+
).option("--brand <id>", "Brand id (with --demote)").option("--qrels-version <hash>", "qrels version to demote (with --demote)").option(
|
|
25027
|
+
"--kind <kind>",
|
|
25028
|
+
"Question set kind to demote: qrels | sync_brain (with --demote)"
|
|
25029
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
25030
|
+
"--fields <list>",
|
|
25031
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
25032
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24076
25033
|
async (runId, options) => {
|
|
24077
25034
|
const { runEvalPromote: runEvalPromote2 } = await Promise.resolve().then(() => (init_eval_promote(), eval_promote_exports));
|
|
24078
25035
|
await runEvalPromote2({ runId, ...options });
|
|
24079
25036
|
}
|
|
24080
25037
|
);
|
|
24081
|
-
var evalSets = evals.command("sets").description(
|
|
25038
|
+
var evalSets = evals.command("sets").description(
|
|
25039
|
+
"Test sets \u2014 the definition a run executes (cases attach separately)"
|
|
25040
|
+
);
|
|
24082
25041
|
evalSets.command("create").description("Create an empty test set of a given evidence kind").requiredOption("--name <text>", 'Human name, e.g. "Connector parity"').requiredOption(
|
|
24083
25042
|
"--kind <kind>",
|
|
24084
25043
|
"Evidence kind: golden_set | quiz | regression | probe | compare"
|
|
24085
25044
|
).requiredOption(
|
|
24086
25045
|
"--hypothesis <text>",
|
|
24087
25046
|
"The claim this set exists to settle \u2014 what the kind makes a good hypothesis differs"
|
|
24088
|
-
).option("--slug <slug>", "URL slug (derived from --name when omitted)").option("--agent <id>", "Scope the set to one agent (omit for brand-wide)").option(
|
|
25047
|
+
).option("--slug <slug>", "URL slug (derived from --name when omitted)").option("--agent <id>", "Scope the set to one agent (omit for brand-wide)").option(
|
|
25048
|
+
"--brand <id>",
|
|
25049
|
+
"Brand id \u2014 only needed when the org has more than one brand"
|
|
25050
|
+
).option(
|
|
25051
|
+
"--lifecycle <state>",
|
|
25052
|
+
"draft | active | paused | retired (default: draft)"
|
|
25053
|
+
).option("--priority <n>", "Integer ordering hint (default: 0)").option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
25054
|
+
"--fields <list>",
|
|
25055
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
25056
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24089
25057
|
async (options) => {
|
|
24090
25058
|
const { runEvalSetsCreate: runEvalSetsCreate2 } = await Promise.resolve().then(() => (init_eval_test_sets2(), eval_test_sets_exports));
|
|
24091
25059
|
await runEvalSetsCreate2(options);
|
|
24092
25060
|
}
|
|
24093
25061
|
);
|
|
24094
|
-
evalSets.command("add-cases").description(
|
|
25062
|
+
evalSets.command("add-cases").description(
|
|
25063
|
+
"Attach existing cases to a test set (adds by default; --replace overwrites)"
|
|
25064
|
+
).requiredOption("--set <id>", "Test set id").requiredOption("--cases <ids>", "Comma-separated eval case ids").option(
|
|
24095
25065
|
"--replace",
|
|
24096
25066
|
"Send exactly these cases, dropping any others. Without it, the current cases are read and merged"
|
|
24097
|
-
).option(
|
|
25067
|
+
).option(
|
|
25068
|
+
"--brand <id>",
|
|
25069
|
+
"Brand id \u2014 only needed when the org has more than one brand"
|
|
25070
|
+
).option("--json", "Emit a JSON envelope for agent consumption").option(
|
|
25071
|
+
"--fields <list>",
|
|
25072
|
+
"Project only these dotted field paths from data (comma-separated)"
|
|
25073
|
+
).option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
24098
25074
|
async (options) => {
|
|
24099
25075
|
const { runEvalSetsAddCases: runEvalSetsAddCases2 } = await Promise.resolve().then(() => (init_eval_set_cases(), eval_set_cases_exports));
|
|
24100
25076
|
await runEvalSetsAddCases2(options);
|
|
@@ -24106,7 +25082,10 @@ evalSets.command("add-cases").description("Attach existing cases to a test set (
|
|
|
24106
25082
|
const introspection = resolveIntrospection(rawArgs, operands);
|
|
24107
25083
|
if (introspection?.mode === "describe") {
|
|
24108
25084
|
const manifest = await buildManifest(program2, VERSION);
|
|
24109
|
-
process.stdout.write(
|
|
25085
|
+
process.stdout.write(
|
|
25086
|
+
JSON.stringify(manifest, null, 2) + "\n",
|
|
25087
|
+
() => process.exit(0)
|
|
25088
|
+
);
|
|
24110
25089
|
return;
|
|
24111
25090
|
}
|
|
24112
25091
|
if (introspection?.mode === "schema-missing") {
|
|
@@ -24130,12 +25109,19 @@ evalSets.command("add-cases").description("Attach existing cases to a test set (
|
|
|
24130
25109
|
);
|
|
24131
25110
|
return;
|
|
24132
25111
|
}
|
|
24133
|
-
process.stdout.write(
|
|
25112
|
+
process.stdout.write(
|
|
25113
|
+
JSON.stringify(entry, null, 2) + "\n",
|
|
25114
|
+
() => process.exit(0)
|
|
25115
|
+
);
|
|
24134
25116
|
return;
|
|
24135
25117
|
}
|
|
24136
25118
|
const misrouted = detectMisroutedSaveFlag(rawArgs, operands);
|
|
24137
25119
|
if (misrouted) {
|
|
24138
|
-
emitError(
|
|
25120
|
+
emitError(
|
|
25121
|
+
misrouted,
|
|
25122
|
+
{ json: rawArgs.includes("--json"), quiet: rawArgs.includes("--quiet") },
|
|
25123
|
+
1
|
|
25124
|
+
);
|
|
24139
25125
|
}
|
|
24140
25126
|
await program2.parseAsync(process.argv);
|
|
24141
25127
|
})().catch((err) => {
|