bamboo-agents 0.1.5-dev.66.797bc1f → 0.1.5-dev.76.921eb32
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 +602 -166
- package/dist/index.js.map +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3037,7 +3037,7 @@ var VERSION;
|
|
|
3037
3037
|
var init_version = __esm({
|
|
3038
3038
|
"src/version.ts"() {
|
|
3039
3039
|
"use strict";
|
|
3040
|
-
VERSION = "0.1.5-dev.
|
|
3040
|
+
VERSION = "0.1.5-dev.76.921eb32";
|
|
3041
3041
|
}
|
|
3042
3042
|
});
|
|
3043
3043
|
|
|
@@ -7340,12 +7340,12 @@ var init_knowledge_save = __esm({
|
|
|
7340
7340
|
});
|
|
7341
7341
|
KnowledgeSaveResponseSchema = external_exports.object({
|
|
7342
7342
|
/** Routing outcome from `executeKnowledgeWrite`. */
|
|
7343
|
-
routed: external_exports.enum(["auto", "queued", "submitted", "rejected", "noop"]),
|
|
7343
|
+
routed: external_exports.enum(["auto", "queued", "submitted", "rejected", "noop", "conflict"]),
|
|
7344
7344
|
classification: external_exports.enum(["self_only", "cross_scope", "forbidden"]),
|
|
7345
7345
|
/** Present when a PR was opened (queued/submitted, or auto via queue-PR). */
|
|
7346
7346
|
pr_url: external_exports.string().optional(),
|
|
7347
7347
|
pr_number: external_exports.number().optional(),
|
|
7348
|
-
/** Present on `rejected` / `noop` — short machine-friendly reason. */
|
|
7348
|
+
/** Present on `rejected` / `noop` / `conflict` — short machine-friendly reason. */
|
|
7349
7349
|
reason: external_exports.string().optional()
|
|
7350
7350
|
});
|
|
7351
7351
|
}
|
|
@@ -7589,6 +7589,181 @@ var init_agents = __esm({
|
|
|
7589
7589
|
}
|
|
7590
7590
|
});
|
|
7591
7591
|
|
|
7592
|
+
// ../../src/lib/api-contracts/cli/eval-ab.ts
|
|
7593
|
+
var eval_ab_exports = {};
|
|
7594
|
+
__export(eval_ab_exports, {
|
|
7595
|
+
AB_RESULT_VIEW_PATH: () => AB_RESULT_VIEW_PATH,
|
|
7596
|
+
AbEligibilityPreviewSchema: () => AbEligibilityPreviewSchema,
|
|
7597
|
+
AgentAbTestsSnapshotSchema: () => AgentAbTestsSnapshotSchema,
|
|
7598
|
+
EvalAbEndResponseSchema: () => EvalAbEndResponseSchema,
|
|
7599
|
+
EvalAbRequestSchema: () => EvalAbRequestSchema,
|
|
7600
|
+
EvalAbResponseSchema: () => EvalAbResponseSchema,
|
|
7601
|
+
SkillAbTestSchema: () => SkillAbTestSchema,
|
|
7602
|
+
SkillAbTestStatusSchema: () => SkillAbTestStatusSchema
|
|
7603
|
+
});
|
|
7604
|
+
var AB_RESULT_VIEW_PATH, EvalAbRequestSchema, EvalAbResponseSchema, SkillAbTestStatusSchema, SkillAbTestSchema, AbEligibilityPreviewSchema, AgentAbTestsSnapshotSchema, EvalAbEndResponseSchema;
|
|
7605
|
+
var init_eval_ab = __esm({
|
|
7606
|
+
"../../src/lib/api-contracts/cli/eval-ab.ts"() {
|
|
7607
|
+
init_zod();
|
|
7608
|
+
AB_RESULT_VIEW_PATH = "/app/evals";
|
|
7609
|
+
EvalAbRequestSchema = external_exports.object({
|
|
7610
|
+
agent_id: external_exports.string().uuid().describe("The agent whose skill is under test. Must be in the caller's org."),
|
|
7611
|
+
skill_name: external_exports.string().min(1).describe(
|
|
7612
|
+
"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."
|
|
7613
|
+
),
|
|
7614
|
+
hypothesis: external_exports.string().min(1).describe(
|
|
7615
|
+
"Plain-language claim the edit is meant to produce \u2192 `skillopt_candidates.behavior_summary`. An experiment is a claim, not a diff."
|
|
7616
|
+
),
|
|
7617
|
+
candidate_body: external_exports.string().min(1).describe(
|
|
7618
|
+
"The full candidate SKILL.md body (frontmatter included). The baseline arm is pinned server-side from the published body \u2014 never sent."
|
|
7619
|
+
),
|
|
7620
|
+
brand_id: external_exports.string().uuid().optional().describe(
|
|
7621
|
+
"Only needed to disambiguate an agent assigned to more than one brand. Omitted = the agent's single brand."
|
|
7622
|
+
)
|
|
7623
|
+
});
|
|
7624
|
+
EvalAbResponseSchema = external_exports.object({
|
|
7625
|
+
/** The `eval_run_queue` batch both arms were staged into. */
|
|
7626
|
+
run_batch_id: external_exports.string().uuid(),
|
|
7627
|
+
/** The candidate's stable id (`skillopt_candidates.edit_id`). */
|
|
7628
|
+
edit_id: external_exports.string().uuid(),
|
|
7629
|
+
skill_name: external_exports.string(),
|
|
7630
|
+
brand_id: external_exports.string().uuid(),
|
|
7631
|
+
agent_id: external_exports.string().uuid(),
|
|
7632
|
+
/** Holdout cases the cycle will run over — chosen server-side, never passed in. */
|
|
7633
|
+
case_count: external_exports.number().int().positive(),
|
|
7634
|
+
/** Reps per ARM (not per case). `total_runs = case_count × reps_per_arm × 2`. */
|
|
7635
|
+
reps_per_arm: external_exports.number().int().positive(),
|
|
7636
|
+
/** Queue rows staged, across BOTH arms. */
|
|
7637
|
+
total_runs: external_exports.number().int().positive(),
|
|
7638
|
+
/**
|
|
7639
|
+
* The one line stating what will run, rendered server-side from the shared
|
|
7640
|
+
* `describeAbPlan` so the CLI, the sheet, and any future surface cannot drift
|
|
7641
|
+
* into three different sentences about the same 48 runs.
|
|
7642
|
+
*/
|
|
7643
|
+
plan: external_exports.string(),
|
|
7644
|
+
/** Relative link to the result view: `/app/evals?view=ab&batch=<id>`. */
|
|
7645
|
+
deep_link: external_exports.string()
|
|
7646
|
+
});
|
|
7647
|
+
SkillAbTestStatusSchema = external_exports.enum([
|
|
7648
|
+
"running",
|
|
7649
|
+
"resolved",
|
|
7650
|
+
"ended",
|
|
7651
|
+
"failed"
|
|
7652
|
+
]);
|
|
7653
|
+
SkillAbTestSchema = external_exports.object({
|
|
7654
|
+
skillName: external_exports.string(),
|
|
7655
|
+
batchId: external_exports.string().uuid(),
|
|
7656
|
+
status: SkillAbTestStatusSchema,
|
|
7657
|
+
runsCompleted: external_exports.number().int().nonnegative(),
|
|
7658
|
+
runsTotal: external_exports.number().int().nonnegative(),
|
|
7659
|
+
startedAt: external_exports.string(),
|
|
7660
|
+
lastGradedAt: external_exports.string().nullable(),
|
|
7661
|
+
resultLabel: external_exports.string().nullable()
|
|
7662
|
+
});
|
|
7663
|
+
AbEligibilityPreviewSchema = external_exports.object({
|
|
7664
|
+
caseCount: external_exports.number().int().nonnegative(),
|
|
7665
|
+
repsPerCase: external_exports.number().int().positive()
|
|
7666
|
+
});
|
|
7667
|
+
AgentAbTestsSnapshotSchema = external_exports.object({
|
|
7668
|
+
/**
|
|
7669
|
+
* `agents.ab_enabled` — the silent per-agent capability gate. When false the
|
|
7670
|
+
* tab renders no beaker at all, so `tests`/`eligibility` come back empty
|
|
7671
|
+
* (the server short-circuits before computing them).
|
|
7672
|
+
*/
|
|
7673
|
+
abEnabled: external_exports.boolean(),
|
|
7674
|
+
tests: external_exports.array(SkillAbTestSchema),
|
|
7675
|
+
eligibility: external_exports.record(external_exports.string(), AbEligibilityPreviewSchema)
|
|
7676
|
+
});
|
|
7677
|
+
EvalAbEndResponseSchema = external_exports.object({
|
|
7678
|
+
/** The batch that was ended. */
|
|
7679
|
+
batch_id: external_exports.string().uuid(),
|
|
7680
|
+
/** Always `ended` on success — the candidate's new terminal state. */
|
|
7681
|
+
status: external_exports.literal("ended"),
|
|
7682
|
+
/** Pending (never-served) queue rows removed. Graded rows are untouched. */
|
|
7683
|
+
pending_cancelled: external_exports.number().int().nonnegative()
|
|
7684
|
+
});
|
|
7685
|
+
}
|
|
7686
|
+
});
|
|
7687
|
+
|
|
7688
|
+
// src/lib/output.ts
|
|
7689
|
+
function isJsonMode(opts = {}) {
|
|
7690
|
+
if (opts.json === true) return true;
|
|
7691
|
+
return process.stdout.isTTY !== true;
|
|
7692
|
+
}
|
|
7693
|
+
function parseFields(raw) {
|
|
7694
|
+
if (!raw) return [];
|
|
7695
|
+
return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
7696
|
+
}
|
|
7697
|
+
function pluckPath(value, segments) {
|
|
7698
|
+
if (segments.length === 0) return value;
|
|
7699
|
+
if (value === null || value === void 0) return void 0;
|
|
7700
|
+
if (Array.isArray(value)) {
|
|
7701
|
+
return value.map((item) => pluckPath(item, segments)).filter((v) => v !== void 0);
|
|
7702
|
+
}
|
|
7703
|
+
if (typeof value === "object") {
|
|
7704
|
+
const [head, ...rest] = segments;
|
|
7705
|
+
return pluckPath(value[head], rest);
|
|
7706
|
+
}
|
|
7707
|
+
return void 0;
|
|
7708
|
+
}
|
|
7709
|
+
function projectFields(data, fields) {
|
|
7710
|
+
if (fields.length === 0) return data;
|
|
7711
|
+
if (data === null || typeof data !== "object" || Array.isArray(data)) {
|
|
7712
|
+
return data;
|
|
7713
|
+
}
|
|
7714
|
+
const out = {};
|
|
7715
|
+
for (const field of fields) {
|
|
7716
|
+
const segments = field.split(".").filter((s) => s.length > 0);
|
|
7717
|
+
if (segments.length === 0) continue;
|
|
7718
|
+
const value = pluckPath(data, segments);
|
|
7719
|
+
if (value === void 0) continue;
|
|
7720
|
+
out[field] = value;
|
|
7721
|
+
}
|
|
7722
|
+
return out;
|
|
7723
|
+
}
|
|
7724
|
+
function writeStdout(line) {
|
|
7725
|
+
process.stdout.write(line.endsWith("\n") ? line : line + "\n");
|
|
7726
|
+
}
|
|
7727
|
+
function writeStderr(line) {
|
|
7728
|
+
process.stderr.write(line.endsWith("\n") ? line : line + "\n");
|
|
7729
|
+
}
|
|
7730
|
+
function emitSuccess(data, opts, renderHuman) {
|
|
7731
|
+
if (isJsonMode(opts)) {
|
|
7732
|
+
const projected = projectFields(data, parseFields(opts.fields));
|
|
7733
|
+
const envelope = { ok: true, data: projected };
|
|
7734
|
+
writeStdout(JSON.stringify(envelope, null, 2));
|
|
7735
|
+
return;
|
|
7736
|
+
}
|
|
7737
|
+
if (opts.quiet) return;
|
|
7738
|
+
if (renderHuman) renderHuman(data);
|
|
7739
|
+
}
|
|
7740
|
+
function emitError(err, opts, exitCode) {
|
|
7741
|
+
if (isJsonMode(opts)) {
|
|
7742
|
+
const envelope = {
|
|
7743
|
+
ok: false,
|
|
7744
|
+
error: {
|
|
7745
|
+
code: err.code,
|
|
7746
|
+
message: err.message,
|
|
7747
|
+
...err.hint ? { hint: err.hint } : {}
|
|
7748
|
+
}
|
|
7749
|
+
};
|
|
7750
|
+
writeStdout(JSON.stringify(envelope, null, 2));
|
|
7751
|
+
} else if (!opts.quiet) {
|
|
7752
|
+
writeStderr(`bamboo-agents: ${err.message}`);
|
|
7753
|
+
if (err.hint) writeStderr(` ${err.hint}`);
|
|
7754
|
+
}
|
|
7755
|
+
if (exitCode !== void 0) process.exit(exitCode);
|
|
7756
|
+
}
|
|
7757
|
+
function human(line = "", opts = {}) {
|
|
7758
|
+
if (opts.quiet) return;
|
|
7759
|
+
writeStderr(line);
|
|
7760
|
+
}
|
|
7761
|
+
var init_output = __esm({
|
|
7762
|
+
"src/lib/output.ts"() {
|
|
7763
|
+
"use strict";
|
|
7764
|
+
}
|
|
7765
|
+
});
|
|
7766
|
+
|
|
7592
7767
|
// src/lib/paths.ts
|
|
7593
7768
|
import { homedir } from "node:os";
|
|
7594
7769
|
import { join } from "node:path";
|
|
@@ -7850,9 +8025,9 @@ password=${token}
|
|
|
7850
8025
|
const proc = child;
|
|
7851
8026
|
proc.stdin?.write(input);
|
|
7852
8027
|
proc.stdin?.end();
|
|
7853
|
-
await new Promise((
|
|
8028
|
+
await new Promise((resolve3, reject) => {
|
|
7854
8029
|
proc.on("exit", (code) => {
|
|
7855
|
-
if (code === 0)
|
|
8030
|
+
if (code === 0) resolve3();
|
|
7856
8031
|
else reject(new GitError(`git credential approve exited with code ${code}`));
|
|
7857
8032
|
});
|
|
7858
8033
|
proc.on("error", reject);
|
|
@@ -7872,7 +8047,7 @@ async function cloneRepo(repoFullName, targetDir) {
|
|
|
7872
8047
|
}
|
|
7873
8048
|
}
|
|
7874
8049
|
async function checkGitCredentialForGitHub() {
|
|
7875
|
-
return new Promise((
|
|
8050
|
+
return new Promise((resolve3) => {
|
|
7876
8051
|
const proc = execFile(
|
|
7877
8052
|
"git",
|
|
7878
8053
|
["credential", "fill"],
|
|
@@ -7882,12 +8057,12 @@ async function checkGitCredentialForGitHub() {
|
|
|
7882
8057
|
},
|
|
7883
8058
|
(err, stdout) => {
|
|
7884
8059
|
if (err) {
|
|
7885
|
-
|
|
8060
|
+
resolve3(false);
|
|
7886
8061
|
return;
|
|
7887
8062
|
}
|
|
7888
8063
|
const hasOurUsername = /^username=x-access-token\s*$/m.test(stdout);
|
|
7889
8064
|
const hasPassword = /^password=\S+/m.test(stdout);
|
|
7890
|
-
|
|
8065
|
+
resolve3(hasOurUsername && hasPassword);
|
|
7891
8066
|
}
|
|
7892
8067
|
);
|
|
7893
8068
|
proc.stdin?.write("protocol=https\nhost=github.com\n\n");
|
|
@@ -8539,14 +8714,14 @@ var init_open = __esm({
|
|
|
8539
8714
|
}
|
|
8540
8715
|
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
|
8541
8716
|
if (options.wait) {
|
|
8542
|
-
return new Promise((
|
|
8717
|
+
return new Promise((resolve3, reject) => {
|
|
8543
8718
|
subprocess.once("error", reject);
|
|
8544
8719
|
subprocess.once("close", (exitCode) => {
|
|
8545
8720
|
if (!options.allowNonzeroExitCode && exitCode > 0) {
|
|
8546
8721
|
reject(new Error(`Exited with code ${exitCode}`));
|
|
8547
8722
|
return;
|
|
8548
8723
|
}
|
|
8549
|
-
|
|
8724
|
+
resolve3(subprocess);
|
|
8550
8725
|
});
|
|
8551
8726
|
});
|
|
8552
8727
|
}
|
|
@@ -12598,7 +12773,10 @@ var init_context_health = __esm({
|
|
|
12598
12773
|
available: external_exports.literal(true),
|
|
12599
12774
|
scope: ScopeSchema,
|
|
12600
12775
|
grade: external_exports.enum(["A", "B", "C", "D", "F"]),
|
|
12601
|
-
|
|
12776
|
+
/** BAM-3751: `null` ⇒ never measured (no audit has scored this scope).
|
|
12777
|
+
* Mirrors `ScopeHealth.score`. Consumers render "not yet audited" —
|
|
12778
|
+
* never coerce with `?? 0` (that reintroduces the confident-0 bug). */
|
|
12779
|
+
score: external_exports.number().nullable(),
|
|
12602
12780
|
bucketScores: BucketScoresSchema,
|
|
12603
12781
|
results: external_exports.array(CriterionResultSchema),
|
|
12604
12782
|
resolvedScope: ResolvedScopeSchema.nullable(),
|
|
@@ -12646,6 +12824,44 @@ var init_install_token = __esm({
|
|
|
12646
12824
|
}
|
|
12647
12825
|
});
|
|
12648
12826
|
|
|
12827
|
+
// ../../src/lib/api-contracts/cli/usage.ts
|
|
12828
|
+
var DailyCountSchema, AgentUsageResponseSchema;
|
|
12829
|
+
var init_usage = __esm({
|
|
12830
|
+
"../../src/lib/api-contracts/cli/usage.ts"() {
|
|
12831
|
+
init_zod();
|
|
12832
|
+
DailyCountSchema = external_exports.object({
|
|
12833
|
+
date: external_exports.string(),
|
|
12834
|
+
callCount: external_exports.number()
|
|
12835
|
+
});
|
|
12836
|
+
AgentUsageResponseSchema = external_exports.object({
|
|
12837
|
+
available: external_exports.literal(true),
|
|
12838
|
+
orgId: external_exports.string(),
|
|
12839
|
+
/** Null for an org-wide read. */
|
|
12840
|
+
agentId: external_exports.string().nullable(),
|
|
12841
|
+
windowDays: external_exports.number(),
|
|
12842
|
+
windowStart: external_exports.string(),
|
|
12843
|
+
windowEnd: external_exports.string(),
|
|
12844
|
+
/** Explicit — true iff any tool_call rows fell in the window. */
|
|
12845
|
+
hasActivity: external_exports.boolean(),
|
|
12846
|
+
totalCalls: external_exports.number(),
|
|
12847
|
+
/** 30-min idle-gap sessionization per user_id — see lib doc for why (trace_id is
|
|
12848
|
+
* NOT usable: MCP tool calls mint a fresh one per call). */
|
|
12849
|
+
distinctSessions: external_exports.number(),
|
|
12850
|
+
toolCounts: external_exports.record(external_exports.string(), external_exports.number()),
|
|
12851
|
+
firstSeen: external_exports.string().nullable(),
|
|
12852
|
+
lastSeen: external_exports.string().nullable(),
|
|
12853
|
+
/** Sparse — only days with at least one call are included. */
|
|
12854
|
+
dailyCounts: external_exports.array(DailyCountSchema),
|
|
12855
|
+
/** True iff the read hit its row cap — counts above are a floor, not exact. */
|
|
12856
|
+
truncated: external_exports.boolean(),
|
|
12857
|
+
/** External (Claude/Cowork) emails custom-mapped to a Bamboo user for this
|
|
12858
|
+
* org, via `telemetry_email_mappings` (BAM-4014) — what OTEL enrichment
|
|
12859
|
+
* *can* see for this org, when it isn't desktop-gapped. */
|
|
12860
|
+
mappedExternalEmails: external_exports.array(external_exports.string())
|
|
12861
|
+
});
|
|
12862
|
+
}
|
|
12863
|
+
});
|
|
12864
|
+
|
|
12649
12865
|
// ../../src/lib/api-contracts/episodes/index.ts
|
|
12650
12866
|
var KnowledgeCiteSchema, EpisodeCiteSchema, NoPriorHistoryCiteSchema, CiteSchema, CitesArraySchema, DecompositionPartSchema, DecompositionSchema, InsightBodySchema, RecommendationBodySchema, ActionBodySchema, OutcomeBodySchema, FeedbackBodySchema, EpisodeBaseFields, EpisodeInsertSchema, EpisodeRowSchema;
|
|
12651
12867
|
var init_episodes = __esm({
|
|
@@ -12949,6 +13165,16 @@ async function getContextHealth(bambooSession, opts = {}) {
|
|
|
12949
13165
|
if (!res.ok) throw await parseError(res);
|
|
12950
13166
|
return ContextHealthResponseSchema.parse(await res.json());
|
|
12951
13167
|
}
|
|
13168
|
+
async function getAgentUsage(bambooSession, opts = {}) {
|
|
13169
|
+
const url = new URL(`${apiBase()}/api/v1/cli/usage`);
|
|
13170
|
+
if (opts.agentId) url.searchParams.set("agent_id", opts.agentId);
|
|
13171
|
+
if (opts.windowDays) url.searchParams.set("window_days", String(opts.windowDays));
|
|
13172
|
+
const res = await cliApiFetch(url.toString(), {
|
|
13173
|
+
headers: { Authorization: `Bearer ${bambooSession}` }
|
|
13174
|
+
});
|
|
13175
|
+
if (!res.ok) throw await parseError(res);
|
|
13176
|
+
return AgentUsageResponseSchema.parse(await res.json());
|
|
13177
|
+
}
|
|
12952
13178
|
async function getOnboardingStatus(bambooSession, opts = {}) {
|
|
12953
13179
|
const url = new URL(`${apiBase()}/api/v1/cli/onboarding/status`);
|
|
12954
13180
|
if (opts.brandId) url.searchParams.set("brand_id", opts.brandId);
|
|
@@ -13273,6 +13499,22 @@ async function postOutcomeEpisode(bambooSession, body) {
|
|
|
13273
13499
|
const json = await res.json();
|
|
13274
13500
|
return CliOutcomeEpisodeResponseSchema.parse(json);
|
|
13275
13501
|
}
|
|
13502
|
+
async function startAbTest(bambooSession, body) {
|
|
13503
|
+
const res = await cliApiFetch(`${apiBase()}/api/v1/eval/ab`, {
|
|
13504
|
+
method: "POST",
|
|
13505
|
+
headers: {
|
|
13506
|
+
Authorization: `Bearer ${bambooSession}`,
|
|
13507
|
+
"Content-Type": "application/json"
|
|
13508
|
+
},
|
|
13509
|
+
body: JSON.stringify(body)
|
|
13510
|
+
});
|
|
13511
|
+
if (!res.ok) throw await parseError(res);
|
|
13512
|
+
const json = await res.json();
|
|
13513
|
+
return EvalAbResponseSchema.parse(json.data);
|
|
13514
|
+
}
|
|
13515
|
+
function absoluteUrl(relativePath) {
|
|
13516
|
+
return `${apiBase()}${relativePath}`;
|
|
13517
|
+
}
|
|
13276
13518
|
async function postRecEpisode(bambooSession, body) {
|
|
13277
13519
|
const res = await cliApiFetch(`${apiBase()}/api/v1/cli/episodes/recommendation`, {
|
|
13278
13520
|
method: "POST",
|
|
@@ -13309,7 +13551,9 @@ var init_api = __esm({
|
|
|
13309
13551
|
init_onboarding_status();
|
|
13310
13552
|
init_context_health();
|
|
13311
13553
|
init_install_token();
|
|
13554
|
+
init_usage();
|
|
13312
13555
|
init_episodes2();
|
|
13556
|
+
init_eval_ab();
|
|
13313
13557
|
init_version();
|
|
13314
13558
|
PROD_DEFAULT_BASE = "https://withbamboo.com";
|
|
13315
13559
|
DEV_DEFAULT_BASE = "https://dev.withbamboo.com";
|
|
@@ -13362,7 +13606,7 @@ var init_api = __esm({
|
|
|
13362
13606
|
|
|
13363
13607
|
// src/lib/util.ts
|
|
13364
13608
|
function sleep(ms) {
|
|
13365
|
-
return new Promise((
|
|
13609
|
+
return new Promise((resolve3) => setTimeout(resolve3, ms));
|
|
13366
13610
|
}
|
|
13367
13611
|
var init_util2 = __esm({
|
|
13368
13612
|
"src/lib/util.ts"() {
|
|
@@ -13374,6 +13618,8 @@ var init_util2 = __esm({
|
|
|
13374
13618
|
var login_exports = {};
|
|
13375
13619
|
__export(login_exports, {
|
|
13376
13620
|
TOKEN_POLL: () => TOKEN_POLL,
|
|
13621
|
+
fetchGithubTokenForLogin: () => fetchGithubTokenForLogin,
|
|
13622
|
+
finishLogin: () => finishLogin,
|
|
13377
13623
|
handleMissingGithubToken: () => handleMissingGithubToken,
|
|
13378
13624
|
isAgentScopedKey: () => isAgentScopedKey,
|
|
13379
13625
|
runLogin: () => runLogin,
|
|
@@ -13433,8 +13679,8 @@ async function handleMissingGithubToken(bambooSession) {
|
|
|
13433
13679
|
async function startCallbackServer(expectedState) {
|
|
13434
13680
|
let resolveSession2;
|
|
13435
13681
|
let rejectSession;
|
|
13436
|
-
const session = new Promise((
|
|
13437
|
-
resolveSession2 =
|
|
13682
|
+
const session = new Promise((resolve3, reject) => {
|
|
13683
|
+
resolveSession2 = resolve3;
|
|
13438
13684
|
rejectSession = reject;
|
|
13439
13685
|
});
|
|
13440
13686
|
const server = createServer((req, res) => {
|
|
@@ -13492,10 +13738,10 @@ async function startCallbackServer(expectedState) {
|
|
|
13492
13738
|
server.close();
|
|
13493
13739
|
}, LOGIN_TIMEOUT_MS);
|
|
13494
13740
|
timer.unref();
|
|
13495
|
-
const port = await new Promise((
|
|
13741
|
+
const port = await new Promise((resolve3, reject) => {
|
|
13496
13742
|
server.once("listening", () => {
|
|
13497
13743
|
const addr = server.address();
|
|
13498
|
-
if (addr && typeof addr === "object")
|
|
13744
|
+
if (addr && typeof addr === "object") resolve3(addr.port);
|
|
13499
13745
|
else reject(new Error("Couldn't bind localhost port"));
|
|
13500
13746
|
});
|
|
13501
13747
|
server.once("error", reject);
|
|
@@ -13578,6 +13824,54 @@ async function runLoginWithToken(bambooSession) {
|
|
|
13578
13824
|
}
|
|
13579
13825
|
}
|
|
13580
13826
|
}
|
|
13827
|
+
async function fetchGithubTokenForLogin(bambooSession) {
|
|
13828
|
+
const tokenSpinner = ora("Fetching your GitHub token\u2026").start();
|
|
13829
|
+
try {
|
|
13830
|
+
const tokenResp = await getGithubToken(bambooSession);
|
|
13831
|
+
tokenSpinner.succeed("GitHub token retrieved");
|
|
13832
|
+
return tokenResp;
|
|
13833
|
+
} catch (err) {
|
|
13834
|
+
const status = err instanceof ApiError ? err.status : null;
|
|
13835
|
+
if (status === 404) {
|
|
13836
|
+
tokenSpinner.warn(
|
|
13837
|
+
"No GitHub token linked yet \u2014 opening browser to authorize Bamboo with GitHub\u2026"
|
|
13838
|
+
);
|
|
13839
|
+
} else if (status === 410) {
|
|
13840
|
+
tokenSpinner.warn(
|
|
13841
|
+
"Your GitHub token expired \u2014 opening browser to refresh authorization\u2026"
|
|
13842
|
+
);
|
|
13843
|
+
} else {
|
|
13844
|
+
tokenSpinner.warn(
|
|
13845
|
+
`Couldn't fetch GitHub token (${err.message}) \u2014 opening browser to (re)link GitHub\u2026`
|
|
13846
|
+
);
|
|
13847
|
+
}
|
|
13848
|
+
return handleMissingGithubToken(bambooSession);
|
|
13849
|
+
}
|
|
13850
|
+
}
|
|
13851
|
+
async function finishLogin(bambooSession, tokenResp) {
|
|
13852
|
+
await writeCredentials({
|
|
13853
|
+
bamboo_session: bambooSession,
|
|
13854
|
+
github_token: tokenResp?.access_token ?? "",
|
|
13855
|
+
github_token_expires_at: tokenResp?.expires_at ?? null,
|
|
13856
|
+
github_username: tokenResp?.github_username ?? null,
|
|
13857
|
+
written_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
13858
|
+
});
|
|
13859
|
+
if (!tokenResp) {
|
|
13860
|
+
console.log("");
|
|
13861
|
+
console.log(" Your Bamboo session is saved \u2014 GitHub isn't linked yet.");
|
|
13862
|
+
console.log(
|
|
13863
|
+
" Re-run `bamboo-agents login` when you're ready to link GitHub."
|
|
13864
|
+
);
|
|
13865
|
+
console.log("");
|
|
13866
|
+
process.exit(1);
|
|
13867
|
+
return;
|
|
13868
|
+
}
|
|
13869
|
+
console.log("");
|
|
13870
|
+
console.log(
|
|
13871
|
+
` \u2713 Logged in${tokenResp.github_username ? ` as @${tokenResp.github_username}` : ""}.`
|
|
13872
|
+
);
|
|
13873
|
+
console.log("");
|
|
13874
|
+
}
|
|
13581
13875
|
async function runLogin() {
|
|
13582
13876
|
const state = randomBytes2(32).toString("hex");
|
|
13583
13877
|
const code = verificationCode(state);
|
|
@@ -13603,43 +13897,8 @@ async function runLogin() {
|
|
|
13603
13897
|
process.exit(1);
|
|
13604
13898
|
}
|
|
13605
13899
|
spinner.succeed("Bamboo session captured");
|
|
13606
|
-
const
|
|
13607
|
-
|
|
13608
|
-
try {
|
|
13609
|
-
tokenResp = await getGithubToken(bambooSession);
|
|
13610
|
-
tokenSpinner.succeed("GitHub token retrieved");
|
|
13611
|
-
} catch (err) {
|
|
13612
|
-
if (err instanceof ApiError && err.status === 404) {
|
|
13613
|
-
tokenSpinner.warn(
|
|
13614
|
-
"No GitHub token linked yet \u2014 opening browser to authorize Bamboo with GitHub\u2026"
|
|
13615
|
-
);
|
|
13616
|
-
const polled = await handleMissingGithubToken(bambooSession);
|
|
13617
|
-
if (!polled) process.exit(1);
|
|
13618
|
-
tokenResp = polled;
|
|
13619
|
-
} else if (err instanceof ApiError && err.status === 410) {
|
|
13620
|
-
tokenSpinner.warn(
|
|
13621
|
-
"Your GitHub token expired \u2014 opening browser to refresh authorization\u2026"
|
|
13622
|
-
);
|
|
13623
|
-
const polled = await handleMissingGithubToken(bambooSession);
|
|
13624
|
-
if (!polled) process.exit(1);
|
|
13625
|
-
tokenResp = polled;
|
|
13626
|
-
} else {
|
|
13627
|
-
tokenSpinner.fail(`Couldn't fetch GitHub token: ${err.message}`);
|
|
13628
|
-
process.exit(1);
|
|
13629
|
-
}
|
|
13630
|
-
}
|
|
13631
|
-
await writeCredentials({
|
|
13632
|
-
bamboo_session: bambooSession,
|
|
13633
|
-
github_token: tokenResp.access_token,
|
|
13634
|
-
github_token_expires_at: tokenResp.expires_at,
|
|
13635
|
-
github_username: tokenResp.github_username ?? null,
|
|
13636
|
-
written_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
13637
|
-
});
|
|
13638
|
-
console.log("");
|
|
13639
|
-
console.log(
|
|
13640
|
-
` \u2713 Logged in${tokenResp.github_username ? ` as @${tokenResp.github_username}` : ""}.`
|
|
13641
|
-
);
|
|
13642
|
-
console.log("");
|
|
13900
|
+
const tokenResp = await fetchGithubTokenForLogin(bambooSession);
|
|
13901
|
+
await finishLogin(bambooSession, tokenResp);
|
|
13643
13902
|
}
|
|
13644
13903
|
var FALLBACK_RELINK_URL, LOGIN_TIMEOUT_MS, TOKEN_POLL;
|
|
13645
13904
|
var init_login = __esm({
|
|
@@ -13731,12 +13990,12 @@ async function promptStdin(question, opts = {}) {
|
|
|
13731
13990
|
}
|
|
13732
13991
|
}
|
|
13733
13992
|
function readOnce(rl, question) {
|
|
13734
|
-
return new Promise((
|
|
13993
|
+
return new Promise((resolve3) => {
|
|
13735
13994
|
let resolved = false;
|
|
13736
13995
|
const settle = (value) => {
|
|
13737
13996
|
if (resolved) return;
|
|
13738
13997
|
resolved = true;
|
|
13739
|
-
|
|
13998
|
+
resolve3(value);
|
|
13740
13999
|
};
|
|
13741
14000
|
rl.once("close", () => settle(null));
|
|
13742
14001
|
rl.question(question, (answer) => settle(answer));
|
|
@@ -15444,85 +15703,6 @@ var init_open2 = __esm({
|
|
|
15444
15703
|
}
|
|
15445
15704
|
});
|
|
15446
15705
|
|
|
15447
|
-
// src/lib/output.ts
|
|
15448
|
-
function isJsonMode(opts = {}) {
|
|
15449
|
-
if (opts.json === true) return true;
|
|
15450
|
-
return process.stdout.isTTY !== true;
|
|
15451
|
-
}
|
|
15452
|
-
function parseFields(raw) {
|
|
15453
|
-
if (!raw) return [];
|
|
15454
|
-
return raw.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
15455
|
-
}
|
|
15456
|
-
function pluckPath(value, segments) {
|
|
15457
|
-
if (segments.length === 0) return value;
|
|
15458
|
-
if (value === null || value === void 0) return void 0;
|
|
15459
|
-
if (Array.isArray(value)) {
|
|
15460
|
-
return value.map((item) => pluckPath(item, segments)).filter((v) => v !== void 0);
|
|
15461
|
-
}
|
|
15462
|
-
if (typeof value === "object") {
|
|
15463
|
-
const [head, ...rest] = segments;
|
|
15464
|
-
return pluckPath(value[head], rest);
|
|
15465
|
-
}
|
|
15466
|
-
return void 0;
|
|
15467
|
-
}
|
|
15468
|
-
function projectFields(data, fields) {
|
|
15469
|
-
if (fields.length === 0) return data;
|
|
15470
|
-
if (data === null || typeof data !== "object" || Array.isArray(data)) {
|
|
15471
|
-
return data;
|
|
15472
|
-
}
|
|
15473
|
-
const out = {};
|
|
15474
|
-
for (const field of fields) {
|
|
15475
|
-
const segments = field.split(".").filter((s) => s.length > 0);
|
|
15476
|
-
if (segments.length === 0) continue;
|
|
15477
|
-
const value = pluckPath(data, segments);
|
|
15478
|
-
if (value === void 0) continue;
|
|
15479
|
-
out[field] = value;
|
|
15480
|
-
}
|
|
15481
|
-
return out;
|
|
15482
|
-
}
|
|
15483
|
-
function writeStdout(line) {
|
|
15484
|
-
process.stdout.write(line.endsWith("\n") ? line : line + "\n");
|
|
15485
|
-
}
|
|
15486
|
-
function writeStderr(line) {
|
|
15487
|
-
process.stderr.write(line.endsWith("\n") ? line : line + "\n");
|
|
15488
|
-
}
|
|
15489
|
-
function emitSuccess(data, opts, renderHuman) {
|
|
15490
|
-
if (isJsonMode(opts)) {
|
|
15491
|
-
const projected = projectFields(data, parseFields(opts.fields));
|
|
15492
|
-
const envelope = { ok: true, data: projected };
|
|
15493
|
-
writeStdout(JSON.stringify(envelope, null, 2));
|
|
15494
|
-
return;
|
|
15495
|
-
}
|
|
15496
|
-
if (opts.quiet) return;
|
|
15497
|
-
if (renderHuman) renderHuman(data);
|
|
15498
|
-
}
|
|
15499
|
-
function emitError(err, opts, exitCode) {
|
|
15500
|
-
if (isJsonMode(opts)) {
|
|
15501
|
-
const envelope = {
|
|
15502
|
-
ok: false,
|
|
15503
|
-
error: {
|
|
15504
|
-
code: err.code,
|
|
15505
|
-
message: err.message,
|
|
15506
|
-
...err.hint ? { hint: err.hint } : {}
|
|
15507
|
-
}
|
|
15508
|
-
};
|
|
15509
|
-
writeStdout(JSON.stringify(envelope, null, 2));
|
|
15510
|
-
} else if (!opts.quiet) {
|
|
15511
|
-
writeStderr(`bamboo-agents: ${err.message}`);
|
|
15512
|
-
if (err.hint) writeStderr(` ${err.hint}`);
|
|
15513
|
-
}
|
|
15514
|
-
if (exitCode !== void 0) process.exit(exitCode);
|
|
15515
|
-
}
|
|
15516
|
-
function human(line = "", opts = {}) {
|
|
15517
|
-
if (opts.quiet) return;
|
|
15518
|
-
writeStderr(line);
|
|
15519
|
-
}
|
|
15520
|
-
var init_output = __esm({
|
|
15521
|
-
"src/lib/output.ts"() {
|
|
15522
|
-
"use strict";
|
|
15523
|
-
}
|
|
15524
|
-
});
|
|
15525
|
-
|
|
15526
15706
|
// src/commands/save.ts
|
|
15527
15707
|
var save_exports = {};
|
|
15528
15708
|
__export(save_exports, {
|
|
@@ -15825,7 +16005,12 @@ var init_save2 = __esm({
|
|
|
15825
16005
|
"brands/",
|
|
15826
16006
|
"agents/",
|
|
15827
16007
|
"knowledge/",
|
|
15828
|
-
|
|
16008
|
+
// BAM-3476: the plugin skills tree is THE skill-write destination
|
|
16009
|
+
// (BAM-3464) — root `skills/` is retired and dead-letters. The server's
|
|
16010
|
+
// routed-write core now bumps the lockstep plugin manifests automatically
|
|
16011
|
+
// for any plugin-skill edit in this batch (see `/api/v1/cli/save`), so a
|
|
16012
|
+
// local edit under `plugins/` is safe to send as-is.
|
|
16013
|
+
"plugins/",
|
|
15829
16014
|
"instructions/",
|
|
15830
16015
|
"org/"
|
|
15831
16016
|
];
|
|
@@ -16320,12 +16505,12 @@ async function choose(question, choices, defaultIndex = 0) {
|
|
|
16320
16505
|
}
|
|
16321
16506
|
}
|
|
16322
16507
|
function readOnce2(rl, question) {
|
|
16323
|
-
return new Promise((
|
|
16508
|
+
return new Promise((resolve3) => {
|
|
16324
16509
|
let resolved = false;
|
|
16325
16510
|
const settle = (value) => {
|
|
16326
16511
|
if (resolved) return;
|
|
16327
16512
|
resolved = true;
|
|
16328
|
-
|
|
16513
|
+
resolve3(value);
|
|
16329
16514
|
};
|
|
16330
16515
|
rl.once("close", () => settle(null));
|
|
16331
16516
|
rl.question(question, (answer) => settle(answer));
|
|
@@ -18233,7 +18418,7 @@ function printHealth(data, opts) {
|
|
|
18233
18418
|
const scopeLabel = scope.kind === "agent" ? `agent (${scope.agentId ?? "\u2014"})` : scope.kind === "brand" ? `brand (${scope.brandId ?? "\u2014"})` : "org";
|
|
18234
18419
|
human("", opts);
|
|
18235
18420
|
human(
|
|
18236
|
-
` Context health [${scopeLabel}]: ${gradeSymbol(grade)} ${grade} (score ${Math.round(score)}/100)`,
|
|
18421
|
+
score === null ? ` Context health [${scopeLabel}]: not yet audited` : ` Context health [${scopeLabel}]: ${gradeSymbol(grade)} ${grade} (score ${Math.round(score)}/100)`,
|
|
18237
18422
|
opts
|
|
18238
18423
|
);
|
|
18239
18424
|
const fmtBucket = (label, v) => ` ${label.padEnd(12)} ${v != null ? `${Math.round(v)}/100` : "n/a"}`;
|
|
@@ -18293,12 +18478,109 @@ var init_context = __esm({
|
|
|
18293
18478
|
}
|
|
18294
18479
|
});
|
|
18295
18480
|
|
|
18481
|
+
// src/commands/usage.ts
|
|
18482
|
+
var usage_exports = {};
|
|
18483
|
+
__export(usage_exports, {
|
|
18484
|
+
runUsage: () => runUsage
|
|
18485
|
+
});
|
|
18486
|
+
async function requireSession7(opts) {
|
|
18487
|
+
const creds = await readCredentials();
|
|
18488
|
+
if (!creds) {
|
|
18489
|
+
emitError(
|
|
18490
|
+
{
|
|
18491
|
+
code: "not_signed_in",
|
|
18492
|
+
message: "not signed in.",
|
|
18493
|
+
hint: "Run `bamboo-agents login` first."
|
|
18494
|
+
},
|
|
18495
|
+
opts,
|
|
18496
|
+
1
|
|
18497
|
+
);
|
|
18498
|
+
throw new Error("unreachable");
|
|
18499
|
+
}
|
|
18500
|
+
return creds.bamboo_session;
|
|
18501
|
+
}
|
|
18502
|
+
function printUsage(data, opts) {
|
|
18503
|
+
const scopeLabel = data.agentId ? `agent (${data.agentId})` : "org";
|
|
18504
|
+
human("", opts);
|
|
18505
|
+
human(` Usage [${scopeLabel}], last ${data.windowDays}d:`, opts);
|
|
18506
|
+
if (data.agentId) {
|
|
18507
|
+
human(
|
|
18508
|
+
" \u26A0 agent-scoped: OAuth/Cowork calls without an explicit agent_id argument aren't",
|
|
18509
|
+
opts
|
|
18510
|
+
);
|
|
18511
|
+
human(
|
|
18512
|
+
" attributed here and won't count \u2014 a real zero here doesn't rule out activity.",
|
|
18513
|
+
opts
|
|
18514
|
+
);
|
|
18515
|
+
human(" Cross-check with the org-wide read (no --agent) if this looks too quiet.", opts);
|
|
18516
|
+
}
|
|
18517
|
+
if (!data.hasActivity) {
|
|
18518
|
+
human(" No activity in this window.", opts);
|
|
18519
|
+
human("", opts);
|
|
18520
|
+
return;
|
|
18521
|
+
}
|
|
18522
|
+
human(` calls: ${data.totalCalls}`, opts);
|
|
18523
|
+
human(` sessions: ${data.distinctSessions}`, opts);
|
|
18524
|
+
human(` first: ${data.firstSeen}`, opts);
|
|
18525
|
+
human(` last: ${data.lastSeen}`, opts);
|
|
18526
|
+
human("", opts);
|
|
18527
|
+
const tools = Object.entries(data.toolCounts).sort(([, a], [, b]) => b - a);
|
|
18528
|
+
if (tools.length > 0) {
|
|
18529
|
+
human(" By tool:", opts);
|
|
18530
|
+
for (const [tool, count] of tools) {
|
|
18531
|
+
human(` ${tool.padEnd(24)} ${count}`, opts);
|
|
18532
|
+
}
|
|
18533
|
+
human("", opts);
|
|
18534
|
+
}
|
|
18535
|
+
if (data.truncated) {
|
|
18536
|
+
human(" \u26A0 row cap hit \u2014 counts above are a floor, not exact.", opts);
|
|
18537
|
+
human("", opts);
|
|
18538
|
+
}
|
|
18539
|
+
}
|
|
18540
|
+
async function runUsage(options) {
|
|
18541
|
+
const opts = options;
|
|
18542
|
+
const session = await requireSession7(opts);
|
|
18543
|
+
let windowDays;
|
|
18544
|
+
if (options.windowDays) {
|
|
18545
|
+
const parsed = Number(options.windowDays);
|
|
18546
|
+
if (!Number.isFinite(parsed) || parsed <= 0) {
|
|
18547
|
+
emitError(
|
|
18548
|
+
{ code: "invalid_window_days", message: "--window-days must be a positive number." },
|
|
18549
|
+
opts,
|
|
18550
|
+
1
|
|
18551
|
+
);
|
|
18552
|
+
return;
|
|
18553
|
+
}
|
|
18554
|
+
windowDays = parsed;
|
|
18555
|
+
}
|
|
18556
|
+
let data;
|
|
18557
|
+
try {
|
|
18558
|
+
data = await getAgentUsage(session, { agentId: options.agent, windowDays });
|
|
18559
|
+
} catch (err) {
|
|
18560
|
+
emitError(
|
|
18561
|
+
{ code: "usage_read_failed", message: `couldn't load usage: ${err.message}` },
|
|
18562
|
+
opts,
|
|
18563
|
+
1
|
|
18564
|
+
);
|
|
18565
|
+
return;
|
|
18566
|
+
}
|
|
18567
|
+
emitSuccess(data, opts, (d) => printUsage(d, opts));
|
|
18568
|
+
}
|
|
18569
|
+
var init_usage2 = __esm({
|
|
18570
|
+
"src/commands/usage.ts"() {
|
|
18571
|
+
"use strict";
|
|
18572
|
+
init_credentials();
|
|
18573
|
+
init_api();
|
|
18574
|
+
init_output();
|
|
18575
|
+
}
|
|
18576
|
+
});
|
|
18577
|
+
|
|
18296
18578
|
// src/commands/onboarding.ts
|
|
18297
18579
|
var onboarding_exports = {};
|
|
18298
18580
|
__export(onboarding_exports, {
|
|
18299
18581
|
runOnboardingStatus: () => runOnboardingStatus
|
|
18300
18582
|
});
|
|
18301
|
-
async function
|
|
18583
|
+
async function requireSession8(opts) {
|
|
18302
18584
|
const creds = await readCredentials();
|
|
18303
18585
|
if (!creds) {
|
|
18304
18586
|
emitError(
|
|
@@ -18327,7 +18609,7 @@ function printStatus(data, opts) {
|
|
|
18327
18609
|
}
|
|
18328
18610
|
async function runOnboardingStatus(options) {
|
|
18329
18611
|
const opts = options;
|
|
18330
|
-
const session = await
|
|
18612
|
+
const session = await requireSession8(opts);
|
|
18331
18613
|
let data;
|
|
18332
18614
|
try {
|
|
18333
18615
|
data = await getOnboardingStatus(session, { brandId: options.brand });
|
|
@@ -18359,7 +18641,7 @@ __export(brand_exports, {
|
|
|
18359
18641
|
runBrandEditor: () => runBrandEditor,
|
|
18360
18642
|
runBrandUpdate: () => runBrandUpdate
|
|
18361
18643
|
});
|
|
18362
|
-
async function
|
|
18644
|
+
async function requireSession9() {
|
|
18363
18645
|
const creds = await readCredentials();
|
|
18364
18646
|
if (!creds) {
|
|
18365
18647
|
console.error("bamboo-agents: not signed in. Run `bamboo-agents login` first.");
|
|
@@ -18372,7 +18654,7 @@ async function runBrandUpdate(brandId, options) {
|
|
|
18372
18654
|
console.error("bamboo-agents: `brand update` requires a brand id.");
|
|
18373
18655
|
process.exit(2);
|
|
18374
18656
|
}
|
|
18375
|
-
const session = await
|
|
18657
|
+
const session = await requireSession9();
|
|
18376
18658
|
let result;
|
|
18377
18659
|
try {
|
|
18378
18660
|
result = await patchBrand(session, brandId, options.website);
|
|
@@ -18393,7 +18675,7 @@ async function runBrandEditor(action, brandId, userId, options) {
|
|
|
18393
18675
|
console.error(`bamboo-agents: \`brand editor ${action}\` requires <brand-id> <user-id>.`);
|
|
18394
18676
|
process.exit(2);
|
|
18395
18677
|
}
|
|
18396
|
-
const session = await
|
|
18678
|
+
const session = await requireSession9();
|
|
18397
18679
|
let result;
|
|
18398
18680
|
try {
|
|
18399
18681
|
result = await postBrandEditor(session, brandId, { action, user_id: userId });
|
|
@@ -18432,7 +18714,7 @@ __export(agents_exports2, {
|
|
|
18432
18714
|
runAgentsProvision: () => runAgentsProvision,
|
|
18433
18715
|
runAgentsUpdate: () => runAgentsUpdate
|
|
18434
18716
|
});
|
|
18435
|
-
async function
|
|
18717
|
+
async function requireSession10(opts) {
|
|
18436
18718
|
const creds = await readCredentials();
|
|
18437
18719
|
if (!creds) {
|
|
18438
18720
|
emitError(
|
|
@@ -18519,7 +18801,7 @@ function printList(data, opts) {
|
|
|
18519
18801
|
}
|
|
18520
18802
|
async function runAgentsList(options) {
|
|
18521
18803
|
const opts = options;
|
|
18522
|
-
const session = await
|
|
18804
|
+
const session = await requireSession10(opts);
|
|
18523
18805
|
let data;
|
|
18524
18806
|
try {
|
|
18525
18807
|
data = await listCliAgents(session);
|
|
@@ -18546,7 +18828,7 @@ function printDetail(agent, opts) {
|
|
|
18546
18828
|
}
|
|
18547
18829
|
async function runAgentsGet(agentRef, options) {
|
|
18548
18830
|
const opts = options;
|
|
18549
|
-
const session = await
|
|
18831
|
+
const session = await requireSession10(opts);
|
|
18550
18832
|
const row = await resolveAgentRef(session, agentRef, opts);
|
|
18551
18833
|
let agent;
|
|
18552
18834
|
try {
|
|
@@ -18588,7 +18870,7 @@ async function resolveBrandId(session, explicit, opts) {
|
|
|
18588
18870
|
}
|
|
18589
18871
|
async function runAgentsProvision(name, options) {
|
|
18590
18872
|
const opts = options;
|
|
18591
|
-
const session = await
|
|
18873
|
+
const session = await requireSession10(opts);
|
|
18592
18874
|
const brandId = await resolveBrandId(session, options.brand, opts);
|
|
18593
18875
|
let result;
|
|
18594
18876
|
try {
|
|
@@ -18614,7 +18896,7 @@ async function runAgentsProvision(name, options) {
|
|
|
18614
18896
|
}
|
|
18615
18897
|
async function runAgentsPause(agentRef, options) {
|
|
18616
18898
|
const opts = options;
|
|
18617
|
-
const session = await
|
|
18899
|
+
const session = await requireSession10(opts);
|
|
18618
18900
|
const row = await resolveAgentRef(session, agentRef, opts);
|
|
18619
18901
|
try {
|
|
18620
18902
|
const res = await pauseCliAgent(session, row.id);
|
|
@@ -18629,7 +18911,7 @@ async function runAgentsPause(agentRef, options) {
|
|
|
18629
18911
|
}
|
|
18630
18912
|
async function runAgentsUpdate(agentRef, options) {
|
|
18631
18913
|
const opts = options;
|
|
18632
|
-
const session = await
|
|
18914
|
+
const session = await requireSession10(opts);
|
|
18633
18915
|
const body = {};
|
|
18634
18916
|
if (options.name !== void 0) body.name = options.name;
|
|
18635
18917
|
if (options.description !== void 0) body.description = options.description;
|
|
@@ -18660,7 +18942,7 @@ async function runAgentsUpdate(agentRef, options) {
|
|
|
18660
18942
|
}
|
|
18661
18943
|
async function runAgentsDelete(agentRef, options) {
|
|
18662
18944
|
const opts = options;
|
|
18663
|
-
const session = await
|
|
18945
|
+
const session = await requireSession10(opts);
|
|
18664
18946
|
const row = await resolveAgentRef(session, agentRef, opts);
|
|
18665
18947
|
try {
|
|
18666
18948
|
const res = await deleteCliAgent(session, row.id);
|
|
@@ -18682,7 +18964,7 @@ async function runAgentsDelete(agentRef, options) {
|
|
|
18682
18964
|
}
|
|
18683
18965
|
async function runAgentsClone(sourceRef, targetRef, options) {
|
|
18684
18966
|
const opts = options;
|
|
18685
|
-
const session = await
|
|
18967
|
+
const session = await requireSession10(opts);
|
|
18686
18968
|
const source = await resolveAgentRef(session, sourceRef, opts);
|
|
18687
18969
|
const target = await resolveAgentRef(session, targetRef, opts);
|
|
18688
18970
|
try {
|
|
@@ -18711,7 +18993,7 @@ async function runAgentsClone(sourceRef, targetRef, options) {
|
|
|
18711
18993
|
}
|
|
18712
18994
|
async function runAgentsEnableTemplate(agentRef, options) {
|
|
18713
18995
|
const opts = options;
|
|
18714
|
-
const session = await
|
|
18996
|
+
const session = await requireSession10(opts);
|
|
18715
18997
|
if (!options.template) {
|
|
18716
18998
|
emitError({ code: "template_required", message: "Provide --template <id>." }, opts, 2);
|
|
18717
18999
|
return;
|
|
@@ -18745,7 +19027,7 @@ async function runAgentsEnableTemplate(agentRef, options) {
|
|
|
18745
19027
|
}
|
|
18746
19028
|
async function runAgentsActivate(agentRef, options) {
|
|
18747
19029
|
const opts = options;
|
|
18748
|
-
const session = await
|
|
19030
|
+
const session = await requireSession10(opts);
|
|
18749
19031
|
const row = await resolveAgentRef(session, agentRef, opts);
|
|
18750
19032
|
let state = row.state;
|
|
18751
19033
|
let status = row.status;
|
|
@@ -18810,7 +19092,7 @@ __export(episode_exports, {
|
|
|
18810
19092
|
runEpisodeLogOutcome: () => runEpisodeLogOutcome,
|
|
18811
19093
|
runEpisodeLogRec: () => runEpisodeLogRec
|
|
18812
19094
|
});
|
|
18813
|
-
async function
|
|
19095
|
+
async function requireSession11() {
|
|
18814
19096
|
const creds = await readCredentials();
|
|
18815
19097
|
if (!creds) {
|
|
18816
19098
|
console.error("bamboo-agents: not signed in. Run `bamboo-agents login` first.");
|
|
@@ -18843,7 +19125,7 @@ async function runEpisodeLogOutcome(options) {
|
|
|
18843
19125
|
process.exit(2);
|
|
18844
19126
|
}
|
|
18845
19127
|
}
|
|
18846
|
-
const session = await
|
|
19128
|
+
const session = await requireSession11();
|
|
18847
19129
|
let result;
|
|
18848
19130
|
try {
|
|
18849
19131
|
result = await postOutcomeEpisode(session, {
|
|
@@ -18909,7 +19191,7 @@ async function runEpisodeLogRec(options) {
|
|
|
18909
19191
|
process.exit(2);
|
|
18910
19192
|
}
|
|
18911
19193
|
}
|
|
18912
|
-
const session = await
|
|
19194
|
+
const session = await requireSession11();
|
|
18913
19195
|
let result;
|
|
18914
19196
|
try {
|
|
18915
19197
|
result = await postRecEpisode(session, {
|
|
@@ -18948,6 +19230,107 @@ var init_episode = __esm({
|
|
|
18948
19230
|
}
|
|
18949
19231
|
});
|
|
18950
19232
|
|
|
19233
|
+
// src/commands/eval-ab.ts
|
|
19234
|
+
var eval_ab_exports2 = {};
|
|
19235
|
+
__export(eval_ab_exports2, {
|
|
19236
|
+
runEvalAblate: () => runEvalAblate
|
|
19237
|
+
});
|
|
19238
|
+
import { readFile as readFile9 } from "node:fs/promises";
|
|
19239
|
+
import { resolve as resolve2 } from "node:path";
|
|
19240
|
+
async function requireSession12(opts) {
|
|
19241
|
+
const creds = await readCredentials();
|
|
19242
|
+
if (!creds) {
|
|
19243
|
+
emitError(
|
|
19244
|
+
{
|
|
19245
|
+
code: "not_signed_in",
|
|
19246
|
+
message: "not signed in.",
|
|
19247
|
+
hint: "Run `bamboo-agents login` first."
|
|
19248
|
+
},
|
|
19249
|
+
opts,
|
|
19250
|
+
1
|
|
19251
|
+
);
|
|
19252
|
+
throw new Error("unreachable");
|
|
19253
|
+
}
|
|
19254
|
+
return creds.bamboo_session;
|
|
19255
|
+
}
|
|
19256
|
+
function printStaged(data, opts) {
|
|
19257
|
+
human("", opts);
|
|
19258
|
+
human(` A/B test started on "${data.skill_name}".`, opts);
|
|
19259
|
+
human("", opts);
|
|
19260
|
+
human(` ${data.plan}`, opts);
|
|
19261
|
+
human(
|
|
19262
|
+
` ${data.case_count} cases \xD7 ${data.reps_per_arm} reps \xD7 2 arms = ${data.total_runs} queued runs.`,
|
|
19263
|
+
opts
|
|
19264
|
+
);
|
|
19265
|
+
human("", opts);
|
|
19266
|
+
human(` Batch: ${data.run_batch_id}`, opts);
|
|
19267
|
+
human(` Results: ${absoluteUrl(data.deep_link)}`, opts);
|
|
19268
|
+
human("", opts);
|
|
19269
|
+
human(
|
|
19270
|
+
" Runs are served to the agent's eval runtime as it polls \u2014 results fill in over time.",
|
|
19271
|
+
opts
|
|
19272
|
+
);
|
|
19273
|
+
human("", opts);
|
|
19274
|
+
}
|
|
19275
|
+
async function runEvalAblate(options) {
|
|
19276
|
+
const opts = options;
|
|
19277
|
+
const session = await requireSession12(opts);
|
|
19278
|
+
let candidateBody;
|
|
19279
|
+
const bodyPath = resolve2(process.cwd(), options.body);
|
|
19280
|
+
try {
|
|
19281
|
+
candidateBody = await readFile9(bodyPath, "utf-8");
|
|
19282
|
+
} catch (err) {
|
|
19283
|
+
emitError(
|
|
19284
|
+
{
|
|
19285
|
+
code: "body_unreadable",
|
|
19286
|
+
message: `couldn't read the candidate body at ${bodyPath}: ${err.message}`,
|
|
19287
|
+
hint: "Pass --body <path> pointing at the candidate SKILL.md."
|
|
19288
|
+
},
|
|
19289
|
+
opts,
|
|
19290
|
+
1
|
|
19291
|
+
);
|
|
19292
|
+
return;
|
|
19293
|
+
}
|
|
19294
|
+
if (candidateBody.trim().length === 0) {
|
|
19295
|
+
emitError(
|
|
19296
|
+
{
|
|
19297
|
+
code: "body_empty",
|
|
19298
|
+
message: `${bodyPath} is empty \u2014 there's nothing to test.`
|
|
19299
|
+
},
|
|
19300
|
+
opts,
|
|
19301
|
+
1
|
|
19302
|
+
);
|
|
19303
|
+
return;
|
|
19304
|
+
}
|
|
19305
|
+
let data;
|
|
19306
|
+
try {
|
|
19307
|
+
data = await startAbTest(session, {
|
|
19308
|
+
agent_id: options.agent,
|
|
19309
|
+
skill_name: options.skill,
|
|
19310
|
+
hypothesis: options.hypothesis,
|
|
19311
|
+
candidate_body: candidateBody,
|
|
19312
|
+
...options.brand ? { brand_id: options.brand } : {}
|
|
19313
|
+
});
|
|
19314
|
+
} catch (err) {
|
|
19315
|
+
const e = err;
|
|
19316
|
+
emitError(
|
|
19317
|
+
{ code: e.errorCode ?? "ablate_failed", message: e.message },
|
|
19318
|
+
opts,
|
|
19319
|
+
1
|
|
19320
|
+
);
|
|
19321
|
+
return;
|
|
19322
|
+
}
|
|
19323
|
+
emitSuccess(data, opts, (d) => printStaged(d, opts));
|
|
19324
|
+
}
|
|
19325
|
+
var init_eval_ab2 = __esm({
|
|
19326
|
+
"src/commands/eval-ab.ts"() {
|
|
19327
|
+
"use strict";
|
|
19328
|
+
init_credentials();
|
|
19329
|
+
init_api();
|
|
19330
|
+
init_output();
|
|
19331
|
+
}
|
|
19332
|
+
});
|
|
19333
|
+
|
|
18951
19334
|
// node_modules/commander/esm.mjs
|
|
18952
19335
|
var import_index = __toESM(require_commander(), 1);
|
|
18953
19336
|
var {
|
|
@@ -19058,13 +19441,14 @@ function zodToJsonSchema(schema) {
|
|
|
19058
19441
|
async function loadOutputSchemas() {
|
|
19059
19442
|
const map = /* @__PURE__ */ new Map();
|
|
19060
19443
|
try {
|
|
19061
|
-
const [history, changes, knowledgeSlots, knowledgeSave, onboarding2, agents2] = await Promise.all([
|
|
19444
|
+
const [history, changes, knowledgeSlots, knowledgeSave, onboarding2, agents2, evalAb] = await Promise.all([
|
|
19062
19445
|
Promise.resolve().then(() => (init_history(), history_exports)).catch(() => null),
|
|
19063
19446
|
Promise.resolve().then(() => (init_changes(), changes_exports)).catch(() => null),
|
|
19064
19447
|
Promise.resolve().then(() => (init_knowledge_slots(), knowledge_slots_exports)).catch(() => null),
|
|
19065
19448
|
Promise.resolve().then(() => (init_knowledge_save(), knowledge_save_exports)).catch(() => null),
|
|
19066
19449
|
Promise.resolve().then(() => (init_onboarding_status(), onboarding_status_exports)).catch(() => null),
|
|
19067
|
-
Promise.resolve().then(() => (init_agents(), agents_exports)).catch(() => null)
|
|
19450
|
+
Promise.resolve().then(() => (init_agents(), agents_exports)).catch(() => null),
|
|
19451
|
+
Promise.resolve().then(() => (init_eval_ab(), eval_ab_exports)).catch(() => null)
|
|
19068
19452
|
]);
|
|
19069
19453
|
if (history?.HistoryResponseSchema) {
|
|
19070
19454
|
const s = zodToJsonSchema(history.HistoryResponseSchema);
|
|
@@ -19102,6 +19486,10 @@ async function loadOutputSchemas() {
|
|
|
19102
19486
|
const s = zodToJsonSchema(agents2.CliAgentPauseResponseSchema);
|
|
19103
19487
|
if (s) map.set("agents pause", s);
|
|
19104
19488
|
}
|
|
19489
|
+
if (evalAb?.EvalAbResponseSchema) {
|
|
19490
|
+
const s = zodToJsonSchema(evalAb.EvalAbResponseSchema);
|
|
19491
|
+
if (s) map.set("eval ablate", s);
|
|
19492
|
+
}
|
|
19105
19493
|
} catch {
|
|
19106
19494
|
}
|
|
19107
19495
|
return map;
|
|
@@ -19168,7 +19556,31 @@ function resolveIntrospection(rawArgs, operands) {
|
|
|
19168
19556
|
return null;
|
|
19169
19557
|
}
|
|
19170
19558
|
|
|
19559
|
+
// src/lib/misrouted-flags.ts
|
|
19560
|
+
var MISROUTED_FLAGS = /* @__PURE__ */ new Map([
|
|
19561
|
+
["--path", "knowledge save"],
|
|
19562
|
+
["--content", "knowledge save"],
|
|
19563
|
+
["--content-file", "knowledge save"],
|
|
19564
|
+
["--delete", "knowledge save"],
|
|
19565
|
+
["--intent", "knowledge save"]
|
|
19566
|
+
]);
|
|
19567
|
+
function detectMisroutedSaveFlag(rawArgs, operands) {
|
|
19568
|
+
if (operands[0] !== "save") return null;
|
|
19569
|
+
for (const arg of rawArgs) {
|
|
19570
|
+
const flag = arg.split("=", 1)[0];
|
|
19571
|
+
const target = MISROUTED_FLAGS.get(flag);
|
|
19572
|
+
if (!target) continue;
|
|
19573
|
+
return {
|
|
19574
|
+
code: "wrong_save_verb",
|
|
19575
|
+
message: `\`bamboo save\` does not accept ${flag}.`,
|
|
19576
|
+
hint: `\`save\` commits the whole working tree and takes the intent as a positional argument: \`bamboo save "<intent>"\`. To write one file by path, use \`bamboo ${target} ${flag} \u2026\` (see \`bamboo --schema ${target}\`).`
|
|
19577
|
+
};
|
|
19578
|
+
}
|
|
19579
|
+
return null;
|
|
19580
|
+
}
|
|
19581
|
+
|
|
19171
19582
|
// src/index.ts
|
|
19583
|
+
init_output();
|
|
19172
19584
|
var program2 = new Command();
|
|
19173
19585
|
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("--describe", "Emit full JSON manifest of every CLI command (machine introspection)").option("--schema <command>", "Emit JSON schema for one command by name, e.g. 'history' or 'knowledge save'");
|
|
19174
19586
|
program2.action(async () => {
|
|
@@ -19291,6 +19703,12 @@ context.command("health").description("Knowledge/context health \u2014 grade, sc
|
|
|
19291
19703
|
const { runContextHealth: runContextHealth2 } = await Promise.resolve().then(() => (init_context(), context_exports));
|
|
19292
19704
|
await runContextHealth2(options);
|
|
19293
19705
|
});
|
|
19706
|
+
program2.command("usage").description("Agent usage \u2014 sessions, per-tool call counts, first/last seen (from agent_logs)").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("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
19707
|
+
async (options) => {
|
|
19708
|
+
const { runUsage: runUsage2 } = await Promise.resolve().then(() => (init_usage2(), usage_exports));
|
|
19709
|
+
await runUsage2(options);
|
|
19710
|
+
}
|
|
19711
|
+
);
|
|
19294
19712
|
var onboarding = program2.command("onboarding").description("Onboarding status for CLI-first skills");
|
|
19295
19713
|
onboarding.command("status").description("Composite onboarding gate (activation milestones + knowledge health)").option("--brand <id>", "Scope to a brand_id (default: org)").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(async (options) => {
|
|
19296
19714
|
const { runOnboardingStatus: runOnboardingStatus2 } = await Promise.resolve().then(() => (init_onboarding(), onboarding_exports));
|
|
@@ -19374,20 +19792,33 @@ episode.command("log-rec").description(
|
|
|
19374
19792
|
const { runEpisodeLogRec: runEpisodeLogRec2 } = await Promise.resolve().then(() => (init_episode(), episode_exports));
|
|
19375
19793
|
await runEpisodeLogRec2(options);
|
|
19376
19794
|
});
|
|
19795
|
+
var evals = program2.command("eval").description("Evaluation surface \u2014 A/B a candidate skill against its baseline");
|
|
19796
|
+
evals.command("ablate").description(
|
|
19797
|
+
"Start an A/B test: stage a candidate skill body against the published baseline"
|
|
19798
|
+
).requiredOption("--agent <id>", "Agent id whose skill is under test").requiredOption("--skill <name>", "kebab-case skill name (must be one of this agent's own skills)").requiredOption(
|
|
19799
|
+
"--hypothesis <text>",
|
|
19800
|
+
"Plain-language claim the edit is meant to produce (an experiment is a claim, not a diff)"
|
|
19801
|
+
).requiredOption("--body <path>", "Path to the candidate SKILL.md").option("--brand <id>", "Brand id \u2014 only needed when the agent spans more than one brand").option("--json", "Emit a JSON envelope for agent consumption").option("--fields <list>", "Project only these dotted field paths from data (comma-separated)").option("--quiet", "Suppress human chatter (data/errors only)").option("--no-sync", "Skip the auto-sync git pull on this command").action(
|
|
19802
|
+
async (options) => {
|
|
19803
|
+
const { runEvalAblate: runEvalAblate2 } = await Promise.resolve().then(() => (init_eval_ab2(), eval_ab_exports2));
|
|
19804
|
+
await runEvalAblate2(options);
|
|
19805
|
+
}
|
|
19806
|
+
);
|
|
19377
19807
|
(async () => {
|
|
19378
19808
|
const rawArgs = process.argv.slice(2);
|
|
19379
19809
|
const { operands } = program2.parseOptions(rawArgs);
|
|
19380
19810
|
const introspection = resolveIntrospection(rawArgs, operands);
|
|
19381
19811
|
if (introspection?.mode === "describe") {
|
|
19382
19812
|
const manifest = await buildManifest(program2, VERSION);
|
|
19383
|
-
process.stdout.write(JSON.stringify(manifest, null, 2) + "\n");
|
|
19384
|
-
|
|
19813
|
+
process.stdout.write(JSON.stringify(manifest, null, 2) + "\n", () => process.exit(0));
|
|
19814
|
+
return;
|
|
19385
19815
|
}
|
|
19386
19816
|
if (introspection?.mode === "schema-missing") {
|
|
19387
19817
|
process.stderr.write(
|
|
19388
|
-
"bamboo-agents: --schema requires a command name, e.g. --schema history\n"
|
|
19818
|
+
"bamboo-agents: --schema requires a command name, e.g. --schema history\n",
|
|
19819
|
+
() => process.exit(1)
|
|
19389
19820
|
);
|
|
19390
|
-
|
|
19821
|
+
return;
|
|
19391
19822
|
}
|
|
19392
19823
|
if (introspection?.mode === "schema") {
|
|
19393
19824
|
const entry = await buildCommandSchema(
|
|
@@ -19398,12 +19829,17 @@ episode.command("log-rec").description(
|
|
|
19398
19829
|
if (entry === null) {
|
|
19399
19830
|
process.stderr.write(
|
|
19400
19831
|
`bamboo-agents: unknown command '${introspection.command}'. Run --describe for the full list.
|
|
19401
|
-
|
|
19832
|
+
`,
|
|
19833
|
+
() => process.exit(1)
|
|
19402
19834
|
);
|
|
19403
|
-
|
|
19835
|
+
return;
|
|
19404
19836
|
}
|
|
19405
|
-
process.stdout.write(JSON.stringify(entry, null, 2) + "\n");
|
|
19406
|
-
|
|
19837
|
+
process.stdout.write(JSON.stringify(entry, null, 2) + "\n", () => process.exit(0));
|
|
19838
|
+
return;
|
|
19839
|
+
}
|
|
19840
|
+
const misrouted = detectMisroutedSaveFlag(rawArgs, operands);
|
|
19841
|
+
if (misrouted) {
|
|
19842
|
+
emitError(misrouted, { json: rawArgs.includes("--json"), quiet: rawArgs.includes("--quiet") }, 1);
|
|
19407
19843
|
}
|
|
19408
19844
|
await program2.parseAsync(process.argv);
|
|
19409
19845
|
})().catch((err) => {
|