@brainbase-labs/cli 0.55.0 → 0.57.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1125 -602
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35182,7 +35182,7 @@ var require_dist2 = __commonJS((exports, module) => {
|
|
|
35182
35182
|
});
|
|
35183
35183
|
|
|
35184
35184
|
// src/index.ts
|
|
35185
|
-
var
|
|
35185
|
+
var import_picocolors84 = __toESM(require_picocolors(), 1);
|
|
35186
35186
|
import process14 from "node:process";
|
|
35187
35187
|
import fs96 from "node:fs";
|
|
35188
35188
|
|
|
@@ -36091,7 +36091,7 @@ function padStart(s, n) {
|
|
|
36091
36091
|
// package.json
|
|
36092
36092
|
var package_default = {
|
|
36093
36093
|
name: "@brainbase-labs/cli",
|
|
36094
|
-
version: "0.
|
|
36094
|
+
version: "0.57.0",
|
|
36095
36095
|
description: "Pack, share, and install agent templates across harnesses (Claude Code, Codex, ...).",
|
|
36096
36096
|
type: "module",
|
|
36097
36097
|
bin: {
|
|
@@ -55200,6 +55200,9 @@ function masControlPlaneBaseUrl(session) {
|
|
|
55200
55200
|
const controlPlane = process.env.BRAINBASE_CONTROL_PLANE_URL?.trim();
|
|
55201
55201
|
return normalizeControlPlaneUrl(controlPlane || session?.control_plane_url);
|
|
55202
55202
|
}
|
|
55203
|
+
function masEndpointUrl(pathname, session) {
|
|
55204
|
+
return `${masControlPlaneBaseUrl(session)}${pathname}`;
|
|
55205
|
+
}
|
|
55203
55206
|
function apiBase(session) {
|
|
55204
55207
|
const suffix = usesLegacyControlPlane() ? "/api/cli" : "/v2/cli";
|
|
55205
55208
|
return `${controlPlaneBaseUrl(session)}${suffix}`;
|
|
@@ -55737,6 +55740,23 @@ var masApi = {
|
|
|
55737
55740
|
createDesign(agentId, input) {
|
|
55738
55741
|
return masResourceRequest(`/agents/${encodeURIComponent(agentId)}/designs`, { method: "POST", body: JSON.stringify(input) });
|
|
55739
55742
|
},
|
|
55743
|
+
createOrchestrationFromAgent(input) {
|
|
55744
|
+
return masResourceRequest("/orchestrations", {
|
|
55745
|
+
method: "POST",
|
|
55746
|
+
body: JSON.stringify({
|
|
55747
|
+
group_id: input.group_id,
|
|
55748
|
+
name: input.name,
|
|
55749
|
+
description: input.description,
|
|
55750
|
+
members: [input.agent_id]
|
|
55751
|
+
})
|
|
55752
|
+
});
|
|
55753
|
+
},
|
|
55754
|
+
async getAgentSummary(agentId) {
|
|
55755
|
+
const body = await masReadRequest(`/agents/${encodeURIComponent(agentId)}`);
|
|
55756
|
+
const { name } = masNamedRecord(body, "agent", "title");
|
|
55757
|
+
const description = body.description;
|
|
55758
|
+
return { name, description: typeof description === "string" ? description : "" };
|
|
55759
|
+
},
|
|
55740
55760
|
async deleteDesign(agentId, designId) {
|
|
55741
55761
|
await masResourceRequest(`/agents/${encodeURIComponent(agentId)}/designs/${encodeURIComponent(designId)}`, { method: "DELETE" });
|
|
55742
55762
|
},
|
|
@@ -55972,6 +55992,13 @@ var api = {
|
|
|
55972
55992
|
getOrchestration(orchId) {
|
|
55973
55993
|
return request(`/orchestrations/${encodeURIComponent(orchId)}`);
|
|
55974
55994
|
},
|
|
55995
|
+
fireOrchestrationTrigger(orchId, triggerId, payload, idempotencyKey) {
|
|
55996
|
+
return masResourceRequest(`/orchestrations/${encodeURIComponent(orchId)}/triggers/${encodeURIComponent(triggerId)}/fire`, {
|
|
55997
|
+
method: "POST",
|
|
55998
|
+
headers: idempotencyKey ? { "Idempotency-Key": idempotencyKey } : {},
|
|
55999
|
+
body: JSON.stringify(payload)
|
|
56000
|
+
});
|
|
56001
|
+
},
|
|
55975
56002
|
getOrchestrationManifest(orchId) {
|
|
55976
56003
|
return request(`/orchestrations/${encodeURIComponent(orchId)}/manifest`);
|
|
55977
56004
|
},
|
|
@@ -82464,6 +82491,7 @@ var OrchestrationSyncStateSchema = exports_external.object({
|
|
|
82464
82491
|
members: exports_external.array(SyncedMemberSchema),
|
|
82465
82492
|
edges: exports_external.array(SyncedEdgeSchema),
|
|
82466
82493
|
triggers: exports_external.array(SyncedScheduleTriggerSchema).optional(),
|
|
82494
|
+
webhook_triggers: exports_external.array(SyncedScheduleTriggerSchema).optional(),
|
|
82467
82495
|
decisions: exports_external.array(SyncedDecisionSchema).optional(),
|
|
82468
82496
|
meta: SyncedOrchestrationMetaSchema.optional()
|
|
82469
82497
|
});
|
|
@@ -82849,7 +82877,7 @@ function printHelp3() {
|
|
|
82849
82877
|
}
|
|
82850
82878
|
|
|
82851
82879
|
// src/cli/orchestration.ts
|
|
82852
|
-
var
|
|
82880
|
+
var import_picocolors62 = __toESM(require_picocolors(), 1);
|
|
82853
82881
|
|
|
82854
82882
|
// src/cli/orchestration-pull.ts
|
|
82855
82883
|
import path98 from "node:path";
|
|
@@ -82896,16 +82924,29 @@ var ScheduleTriggerSchema = exports_external.object({
|
|
|
82896
82924
|
config: exports_external.record(exports_external.unknown()).optional(),
|
|
82897
82925
|
to: exports_external.array(TriggerEdgeSchema).default([])
|
|
82898
82926
|
});
|
|
82927
|
+
var WebhookTriggerSchema = exports_external.object({
|
|
82928
|
+
type: exports_external.literal("webhook"),
|
|
82929
|
+
node_id: exports_external.string().regex(UUID_RE, "must be a UUID"),
|
|
82930
|
+
is_active: exports_external.boolean().optional(),
|
|
82931
|
+
public: exports_external.boolean().optional(),
|
|
82932
|
+
config: exports_external.record(exports_external.unknown()).optional(),
|
|
82933
|
+
to: exports_external.array(TriggerEdgeSchema).default([])
|
|
82934
|
+
});
|
|
82935
|
+
var WRITABLE_TRIGGER_TYPES = new Set(["schedule", "webhook"]);
|
|
82899
82936
|
var ReadOnlyTriggerSchema = exports_external.object({
|
|
82900
|
-
type: exports_external.string().refine((value2) => value2
|
|
82901
|
-
message: "schedule triggers must use a UUID node_id"
|
|
82937
|
+
type: exports_external.string().refine((value2) => !WRITABLE_TRIGGER_TYPES.has(value2), {
|
|
82938
|
+
message: "schedule and webhook triggers must use a UUID node_id"
|
|
82902
82939
|
}),
|
|
82903
82940
|
node_id: exports_external.string().min(1),
|
|
82904
82941
|
is_active: exports_external.boolean().optional(),
|
|
82905
82942
|
config: exports_external.record(exports_external.unknown()).optional(),
|
|
82906
82943
|
to: exports_external.array(TriggerEdgeSchema).default([])
|
|
82907
82944
|
});
|
|
82908
|
-
var TriggerSchema = exports_external.union([
|
|
82945
|
+
var TriggerSchema = exports_external.union([
|
|
82946
|
+
ScheduleTriggerSchema,
|
|
82947
|
+
WebhookTriggerSchema,
|
|
82948
|
+
ReadOnlyTriggerSchema
|
|
82949
|
+
]);
|
|
82909
82950
|
var DECISION_MODELS = [
|
|
82910
82951
|
"jev",
|
|
82911
82952
|
"kev-4b",
|
|
@@ -82982,8 +83023,8 @@ function writeOrchManifest(cwd2, manifest) {
|
|
|
82982
83023
|
doc2.commentBefore = ` brainbase-orchestration.yaml — declarative orchestration manifest.
|
|
82983
83024
|
` + ` Committed to source control. Edit by hand, then
|
|
82984
83025
|
` + " `brainbase orchestration push`. Member agents live under ./agents/." + `
|
|
82985
|
-
Schedule triggers are writable. App/Pipedream triggers are
|
|
82986
|
-
` + " as read-only context and ignored by `orchestration push`.";
|
|
83026
|
+
Schedule and webhook triggers are writable. App/Pipedream triggers are
|
|
83027
|
+
` + " preserved as read-only context and ignored by `orchestration push`.";
|
|
82987
83028
|
fs83.writeFileSync(orchManifestPath(cwd2), String(doc2), "utf8");
|
|
82988
83029
|
}
|
|
82989
83030
|
function memberDir(cwd2, slug) {
|
|
@@ -83376,6 +83417,88 @@ function syncedScheduleTriggers(triggers) {
|
|
|
83376
83417
|
hash: scheduleTriggerHash(t)
|
|
83377
83418
|
}));
|
|
83378
83419
|
}
|
|
83420
|
+
var WEBHOOK_TRIGGER = "webhook-trigger";
|
|
83421
|
+
function webhookPublicFromConfig(config2) {
|
|
83422
|
+
const value2 = config2?.public_url;
|
|
83423
|
+
return value2 === undefined || value2 === true;
|
|
83424
|
+
}
|
|
83425
|
+
function webhookTriggerHash(t) {
|
|
83426
|
+
const canonical = {
|
|
83427
|
+
is_active: t.is_active,
|
|
83428
|
+
public: t.public,
|
|
83429
|
+
targets: t.targets.map((e2) => ({
|
|
83430
|
+
agent: e2.agent,
|
|
83431
|
+
description: e2.description,
|
|
83432
|
+
payload_schema: e2.payload_schema
|
|
83433
|
+
})).sort((a3, b4) => stableJson(a3) < stableJson(b4) ? -1 : 1)
|
|
83434
|
+
};
|
|
83435
|
+
return crypto6.createHash("sha256").update(stableJson(canonical)).digest("hex");
|
|
83436
|
+
}
|
|
83437
|
+
function webhookTriggerLabel(t) {
|
|
83438
|
+
const access = t.public ? "public URL" : "members only";
|
|
83439
|
+
const state = t.is_active ? "active" : "inactive";
|
|
83440
|
+
const targets = t.targets.length ? ` -> ${t.targets.map((e2) => e2.agent).join(", ")}` : "";
|
|
83441
|
+
return `webhook ${t.node_id} (${access}, ${state})${targets}`;
|
|
83442
|
+
}
|
|
83443
|
+
function cloudWebhookTriggers(cloud, slugForAgent) {
|
|
83444
|
+
return (cloud.triggers ?? []).filter((t) => t.trigger_type === "webhook").map((t) => ({
|
|
83445
|
+
node_id: canonicalUuid2(t.node_id),
|
|
83446
|
+
is_active: t.is_active ?? false,
|
|
83447
|
+
public: typeof t.public === "boolean" ? t.public : webhookPublicFromConfig(t.config),
|
|
83448
|
+
targets: t.edges.map((e2) => ({
|
|
83449
|
+
agent: slugForAgent(e2.to_agent_id, e2.to_slug ?? e2.to_agent_id),
|
|
83450
|
+
description: e2.description ?? "",
|
|
83451
|
+
payload_schema: e2.payload_schema ?? {}
|
|
83452
|
+
})),
|
|
83453
|
+
...t.id ? { id: t.id } : {},
|
|
83454
|
+
...t.fire_path ? { fire_path: t.fire_path } : {}
|
|
83455
|
+
}));
|
|
83456
|
+
}
|
|
83457
|
+
function manifestWebhookTriggers(manifest) {
|
|
83458
|
+
return (manifest?.triggers ?? []).filter((t) => t.type === "webhook").map((t) => ({
|
|
83459
|
+
node_id: canonicalUuid2(t.node_id),
|
|
83460
|
+
is_active: t.is_active ?? false,
|
|
83461
|
+
public: "public" in t && typeof t.public === "boolean" ? t.public : t.config ? webhookPublicFromConfig(t.config) : false,
|
|
83462
|
+
targets: t.to.map((e2) => ({
|
|
83463
|
+
agent: e2.agent,
|
|
83464
|
+
description: e2.description ?? "",
|
|
83465
|
+
payload_schema: e2.payload_schema ?? {}
|
|
83466
|
+
}))
|
|
83467
|
+
}));
|
|
83468
|
+
}
|
|
83469
|
+
function decideWebhookTriggerReconcile(input) {
|
|
83470
|
+
const rows = threeWayDiff({
|
|
83471
|
+
local: input.local.map((t) => ({
|
|
83472
|
+
type: WEBHOOK_TRIGGER,
|
|
83473
|
+
slug: t.node_id,
|
|
83474
|
+
hash: webhookTriggerHash(t)
|
|
83475
|
+
})),
|
|
83476
|
+
lock: (input.baseline ?? []).map((t) => ({
|
|
83477
|
+
type: WEBHOOK_TRIGGER,
|
|
83478
|
+
slug: canonicalUuid2(t.node_id),
|
|
83479
|
+
hash: t.hash,
|
|
83480
|
+
installedPaths: []
|
|
83481
|
+
})),
|
|
83482
|
+
cloud: input.cloud.map((t) => ({
|
|
83483
|
+
type: WEBHOOK_TRIGGER,
|
|
83484
|
+
slug: t.node_id,
|
|
83485
|
+
hash: webhookTriggerHash(t),
|
|
83486
|
+
files: []
|
|
83487
|
+
}))
|
|
83488
|
+
});
|
|
83489
|
+
return decideCollectionReconcile({
|
|
83490
|
+
rows,
|
|
83491
|
+
type: WEBHOOK_TRIGGER,
|
|
83492
|
+
claims: input.local.length > 0,
|
|
83493
|
+
force: input.force
|
|
83494
|
+
});
|
|
83495
|
+
}
|
|
83496
|
+
function syncedWebhookTriggers(triggers) {
|
|
83497
|
+
return triggers.map((t) => ({
|
|
83498
|
+
node_id: t.node_id,
|
|
83499
|
+
hash: webhookTriggerHash(t)
|
|
83500
|
+
}));
|
|
83501
|
+
}
|
|
83379
83502
|
var DECISION = "decision";
|
|
83380
83503
|
function manifestDecisions(manifest, slugToAgentId) {
|
|
83381
83504
|
const target = (t) => {
|
|
@@ -83570,11 +83693,15 @@ function syncedOrchestrationMeta(cloud) {
|
|
|
83570
83693
|
function triggersForManifest(triggers, slugFor) {
|
|
83571
83694
|
return triggers.map((trigger) => {
|
|
83572
83695
|
const schedule = trigger.trigger_type === "schedule";
|
|
83573
|
-
const
|
|
83696
|
+
const webhook = trigger.trigger_type === "webhook";
|
|
83697
|
+
const config2 = schedule ? scheduleTriggerConfigForManifest(trigger.config) : webhook ? undefined : trigger.config;
|
|
83574
83698
|
return {
|
|
83575
83699
|
type: trigger.trigger_type,
|
|
83576
83700
|
node_id: trigger.node_id,
|
|
83577
83701
|
is_active: trigger.is_active,
|
|
83702
|
+
...webhook ? {
|
|
83703
|
+
public: typeof trigger.public === "boolean" ? trigger.public : webhookPublicFromConfig(trigger.config)
|
|
83704
|
+
} : {},
|
|
83578
83705
|
...config2 && Object.keys(config2).length ? { config: config2 } : {},
|
|
83579
83706
|
to: trigger.edges.map((edge) => ({
|
|
83580
83707
|
agent: slugFor(edge.to_agent_id),
|
|
@@ -83790,6 +83917,7 @@ async function runOrchestrationPull(cwd2, args) {
|
|
|
83790
83917
|
payload_schema: e2.payload_schema ?? {}
|
|
83791
83918
|
})),
|
|
83792
83919
|
triggers: syncedScheduleTriggers(cloudScheduleTriggers(cloud, (agentId, fallback) => slugFor(agentId) || fallback)),
|
|
83920
|
+
webhook_triggers: syncedWebhookTriggers(cloudWebhookTriggers(cloud, (agentId, fallback) => slugFor(agentId) || fallback)),
|
|
83793
83921
|
...decisionBaseline ? { decisions: decisionBaseline } : {},
|
|
83794
83922
|
meta: syncedOrchestrationMeta(cloud)
|
|
83795
83923
|
});
|
|
@@ -83909,12 +84037,25 @@ function buildOrchestrationGraphPayload(manifest, slugToAgentId) {
|
|
|
83909
84037
|
}
|
|
83910
84038
|
}
|
|
83911
84039
|
const scheduleTriggers = (manifest.triggers ?? []).filter((t) => t.type === "schedule");
|
|
84040
|
+
const webhookTriggers = manifestWebhookTriggers(manifest);
|
|
83912
84041
|
const seenTriggerNodeIds = new Set;
|
|
84042
|
+
for (const t of webhookTriggers) {
|
|
84043
|
+
const nodeId = canonicalUuid2(t.node_id);
|
|
84044
|
+
if (seenTriggerNodeIds.has(nodeId)) {
|
|
84045
|
+
throw new Error(`Webhook trigger ${t.node_id} is duplicated.`);
|
|
84046
|
+
}
|
|
84047
|
+
seenTriggerNodeIds.add(nodeId);
|
|
84048
|
+
for (const e2 of t.targets) {
|
|
84049
|
+
if (!memberSlugs.has(e2.agent)) {
|
|
84050
|
+
throw new Error(`Trigger ${t.node_id} points to "${e2.agent}", which isn't in members.`);
|
|
84051
|
+
}
|
|
84052
|
+
}
|
|
84053
|
+
}
|
|
83913
84054
|
for (const t of scheduleTriggers) {
|
|
83914
|
-
if (seenTriggerNodeIds.has(t.node_id)) {
|
|
84055
|
+
if (seenTriggerNodeIds.has(canonicalUuid2(t.node_id))) {
|
|
83915
84056
|
throw new Error(`Schedule trigger ${t.node_id} is duplicated.`);
|
|
83916
84057
|
}
|
|
83917
|
-
seenTriggerNodeIds.add(t.node_id);
|
|
84058
|
+
seenTriggerNodeIds.add(canonicalUuid2(t.node_id));
|
|
83918
84059
|
const config2 = normalizeScheduleTriggerConfig(t.config);
|
|
83919
84060
|
const cron = config2.cron_expression;
|
|
83920
84061
|
if (typeof cron !== "string" || !cron.trim()) {
|
|
@@ -83952,6 +84093,17 @@ function buildOrchestrationGraphPayload(manifest, slugToAgentId) {
|
|
|
83952
84093
|
description: e2.description ?? "",
|
|
83953
84094
|
payload_schema: e2.payload_schema ?? {}
|
|
83954
84095
|
}))
|
|
84096
|
+
})),
|
|
84097
|
+
webhookTriggers: webhookTriggers.map((t) => ({
|
|
84098
|
+
node_id: t.node_id,
|
|
84099
|
+
type: "webhook",
|
|
84100
|
+
is_active: t.is_active,
|
|
84101
|
+
public: t.public,
|
|
84102
|
+
edges: t.targets.map((e2) => ({
|
|
84103
|
+
to_agent_id: slugToAgentId.get(e2.agent),
|
|
84104
|
+
description: e2.description,
|
|
84105
|
+
payload_schema: e2.payload_schema
|
|
84106
|
+
}))
|
|
83955
84107
|
}))
|
|
83956
84108
|
};
|
|
83957
84109
|
}
|
|
@@ -84098,6 +84250,20 @@ async function runOrchestrationPush(cwd2, args) {
|
|
|
84098
84250
|
const t = triggerByNode.get(nodeId);
|
|
84099
84251
|
return t ? scheduleTriggerLabel(t) : nodeId;
|
|
84100
84252
|
};
|
|
84253
|
+
const localWebhooks = manifestWebhookTriggers(manifest);
|
|
84254
|
+
const cloudWebhooks = cloudWebhookTriggers(cloud, slugForAgent);
|
|
84255
|
+
const webhookDecision = decideWebhookTriggerReconcile({
|
|
84256
|
+
local: localWebhooks,
|
|
84257
|
+
cloud: cloudWebhooks,
|
|
84258
|
+
baseline: lock?.webhook_triggers,
|
|
84259
|
+
force: !!args.force
|
|
84260
|
+
});
|
|
84261
|
+
const webhookByNode = new Map([...cloudWebhooks, ...localWebhooks].map((t) => [t.node_id, t]));
|
|
84262
|
+
const webhookLabelFor = (nodeId) => {
|
|
84263
|
+
const t = webhookByNode.get(nodeId);
|
|
84264
|
+
return t ? webhookTriggerLabel(t) : nodeId;
|
|
84265
|
+
};
|
|
84266
|
+
const blockedWebhooks = webhookDecision.kind === "blocked" ? webhookDecision : null;
|
|
84101
84267
|
const metaDecisions = decideOrchestrationMeta({
|
|
84102
84268
|
manifest,
|
|
84103
84269
|
cloud,
|
|
@@ -84122,7 +84288,7 @@ async function runOrchestrationPush(cwd2, args) {
|
|
|
84122
84288
|
return d3 ? decisionLabel(d3) : id;
|
|
84123
84289
|
};
|
|
84124
84290
|
const blockedDecisions = decisionPlan?.kind === "blocked" ? decisionPlan : null;
|
|
84125
|
-
if (blockedTriggers || blockedDecisions || metaConflicts.length > 0) {
|
|
84291
|
+
if (blockedTriggers || blockedWebhooks || blockedDecisions || metaConflicts.length > 0) {
|
|
84126
84292
|
const pullTargets = [];
|
|
84127
84293
|
const forceEffects = [];
|
|
84128
84294
|
if (blockedTriggers) {
|
|
@@ -84141,6 +84307,22 @@ async function runOrchestrationPush(cwd2, args) {
|
|
|
84141
84307
|
pullTargets.push(`${total} schedule trigger${total === 1 ? "" : "s"}`);
|
|
84142
84308
|
forceEffects.push("make your local schedule triggers authoritative (deleting the cloud ones above)");
|
|
84143
84309
|
}
|
|
84310
|
+
if (blockedWebhooks) {
|
|
84311
|
+
const { unseen, cloudModified, staleArchives } = blockedWebhooks;
|
|
84312
|
+
f2.error(unseen.length > 0 ? "Cannot push: the cloud has webhook triggers this folder has never seen." : "Cannot push: webhook triggers changed both locally and in the cloud.");
|
|
84313
|
+
for (const nodeId of unseen) {
|
|
84314
|
+
console.error(` ${import_picocolors53.default.red("!")} ${import_picocolors53.default.bold(webhookLabelFor(nodeId))} ${import_picocolors53.default.dim("(only in the cloud — pushing would delete it and its URL)")}`);
|
|
84315
|
+
}
|
|
84316
|
+
for (const nodeId of cloudModified) {
|
|
84317
|
+
console.error(` ${import_picocolors53.default.red("!")} ${import_picocolors53.default.bold(webhookLabelFor(nodeId))} ${import_picocolors53.default.dim("(edited in the cloud — pushing would overwrite that edit)")}`);
|
|
84318
|
+
}
|
|
84319
|
+
for (const nodeId of staleArchives) {
|
|
84320
|
+
console.error(` ${import_picocolors53.default.red("!")} ${import_picocolors53.default.bold(webhookLabelFor(nodeId))} ${import_picocolors53.default.dim("(deleted here, edited in the cloud since — pushing would delete that edit)")}`);
|
|
84321
|
+
}
|
|
84322
|
+
const total = unseen.length + cloudModified.length + staleArchives.length;
|
|
84323
|
+
pullTargets.push(`${total} webhook trigger${total === 1 ? "" : "s"}`);
|
|
84324
|
+
forceEffects.push("make your local webhook triggers authoritative (deleting or overwriting the cloud ones above)");
|
|
84325
|
+
}
|
|
84144
84326
|
if (blockedDecisions) {
|
|
84145
84327
|
const { unseen, cloudModified, staleArchives } = blockedDecisions;
|
|
84146
84328
|
f2.error(unseen.length > 0 ? "Cannot push: the cloud has decisions this folder has never seen." : "Cannot push: decisions changed both locally and in the cloud.");
|
|
@@ -84189,6 +84371,13 @@ async function runOrchestrationPush(cwd2, args) {
|
|
|
84189
84371
|
f2.warn(`${cloudTriggers.length} cloud schedule trigger${cloudTriggers.length === 1 ? "" : "s"} ${cloudTriggers.length === 1 ? "is" : "are"} not in ${import_picocolors53.default.bold(ORCH_MANIFEST_FILE)} and will be left untouched. Run ${import_picocolors53.default.cyan("brainbase orchestration pull")} to manage ${cloudTriggers.length === 1 ? "it" : "them"} from here.`);
|
|
84190
84372
|
}
|
|
84191
84373
|
const triggerDeletes = triggerDecision.kind === "reconcile" ? triggerDecision.archives : [];
|
|
84374
|
+
const webhookDeletes = webhookDecision.kind === "reconcile" ? webhookDecision.archives : [];
|
|
84375
|
+
const sendWebhooks = webhookDecision.kind === "reconcile" && (localWebhooks.length > 0 || webhookDeletes.length > 0);
|
|
84376
|
+
if (webhookDecision.kind === "skip") {
|
|
84377
|
+
const left = webhookDecision.unseen.length + webhookDecision.cloudModified.length;
|
|
84378
|
+
f2.warn(`${left} cloud webhook trigger${left === 1 ? "" : "s"} ${left === 1 ? "is" : "are"} not in ${import_picocolors53.default.bold(ORCH_MANIFEST_FILE)} and will be left untouched. Run ${import_picocolors53.default.cyan("brainbase orchestration pull")} to manage ${left === 1 ? "it" : "them"} from here.`);
|
|
84379
|
+
}
|
|
84380
|
+
const triggerCount = graph.triggers.length + (sendWebhooks ? graph.webhookTriggers.length : 0);
|
|
84192
84381
|
const decisionDeletes = decisionPlan?.kind === "reconcile" ? decisionPlan.archives : [];
|
|
84193
84382
|
const sendDecisions = decisionPlan?.kind === "reconcile" && (localDecisions.length > 0 || decisionDeletes.length > 0);
|
|
84194
84383
|
if (!cloudDecisionList && localDecisions.length > 0) {
|
|
@@ -84212,7 +84401,7 @@ async function runOrchestrationPush(cwd2, args) {
|
|
|
84212
84401
|
}
|
|
84213
84402
|
const plan = [""];
|
|
84214
84403
|
plan.push(` ${import_picocolors53.default.bold(link2.name)} ${import_picocolors53.default.dim(`(${link2.orchestration_id})`)}`);
|
|
84215
|
-
plan.push(` ${import_picocolors53.default.dim(`${manifest.members.length} member${manifest.members.length === 1 ? "" : "s"}, ${manifest.edges.length} edge${manifest.edges.length === 1 ? "" : "s"}, ${
|
|
84404
|
+
plan.push(` ${import_picocolors53.default.dim(`${manifest.members.length} member${manifest.members.length === 1 ? "" : "s"}, ${manifest.edges.length} edge${manifest.edges.length === 1 ? "" : "s"}, ${triggerCount} trigger${triggerCount === 1 ? "" : "s"}${sendDecisions ? `, ${decisionsPayload.length} decision${decisionsPayload.length === 1 ? "" : "s"}` : ""}`)}`);
|
|
84216
84405
|
plan.push("");
|
|
84217
84406
|
if (!args.graphOnly) {
|
|
84218
84407
|
plan.push(` ${import_picocolors53.default.dim("per-member agent push:")}`);
|
|
@@ -84228,6 +84417,13 @@ async function runOrchestrationPush(cwd2, args) {
|
|
|
84228
84417
|
}
|
|
84229
84418
|
plan.push("");
|
|
84230
84419
|
}
|
|
84420
|
+
if (webhookDeletes.length) {
|
|
84421
|
+
plan.push(` ${import_picocolors53.default.bold("webhook triggers this push will delete")} ${import_picocolors53.default.dim(`(${webhookDeletes.length})`)}`);
|
|
84422
|
+
for (const nodeId of webhookDeletes) {
|
|
84423
|
+
plan.push(` ${import_picocolors53.default.yellow("⨯")} ${webhookLabelFor(nodeId)}`);
|
|
84424
|
+
}
|
|
84425
|
+
plan.push("");
|
|
84426
|
+
}
|
|
84231
84427
|
if (decisionDeletes.length) {
|
|
84232
84428
|
plan.push(` ${import_picocolors53.default.bold("decisions this push will delete")} ${import_picocolors53.default.dim(`(${decisionDeletes.length})`)}`);
|
|
84233
84429
|
for (const id of decisionDeletes) {
|
|
@@ -84255,6 +84451,7 @@ async function runOrchestrationPush(cwd2, args) {
|
|
|
84255
84451
|
if (!autoProceed(args.yes)) {
|
|
84256
84452
|
const deletions = [
|
|
84257
84453
|
...triggerDeletes.length ? [`${triggerDeletes.length} schedule trigger${triggerDeletes.length === 1 ? "" : "s"}`] : [],
|
|
84454
|
+
...webhookDeletes.length ? [`${webhookDeletes.length} webhook trigger${webhookDeletes.length === 1 ? "" : "s"}`] : [],
|
|
84258
84455
|
...decisionDeletes.length ? [`${decisionDeletes.length} decision${decisionDeletes.length === 1 ? "" : "s"}`] : []
|
|
84259
84456
|
];
|
|
84260
84457
|
const ok = await se({
|
|
@@ -84304,7 +84501,8 @@ async function runOrchestrationPush(cwd2, args) {
|
|
|
84304
84501
|
...metaField("credit_limit"),
|
|
84305
84502
|
members: graph.memberIds,
|
|
84306
84503
|
edges: graph.edges,
|
|
84307
|
-
triggers: graph.triggers,
|
|
84504
|
+
triggers: sendWebhooks ? [...graph.triggers, ...graph.webhookTriggers] : graph.triggers,
|
|
84505
|
+
...sendWebhooks ? { replace_webhook_triggers: true } : {},
|
|
84308
84506
|
...sendDecisions ? { decisions: decisionsPayload } : {},
|
|
84309
84507
|
...lock?.revision != null ? { base_revision: lock.revision } : {}
|
|
84310
84508
|
});
|
|
@@ -84327,6 +84525,7 @@ async function runOrchestrationPush(cwd2, args) {
|
|
|
84327
84525
|
payload_schema: e2.payload_schema ?? {}
|
|
84328
84526
|
})),
|
|
84329
84527
|
triggers: triggerDecision.kind === "skip" ? lock?.triggers ?? [] : syncedScheduleTriggers(cloudScheduleTriggers(updated, slugForAgent)),
|
|
84528
|
+
webhook_triggers: webhookDecision.kind === "skip" ? lock?.webhook_triggers ?? [] : syncedWebhookTriggers(cloudWebhookTriggers(updated, slugForAgent)),
|
|
84330
84529
|
...settledDecisions ? { decisions: syncedDecisions(settledDecisions) } : lock?.decisions ? { decisions: lock.decisions } : {},
|
|
84331
84530
|
meta: nextOrchestrationMeta({
|
|
84332
84531
|
applied: updated,
|
|
@@ -84359,13 +84558,44 @@ function handleApiError6(err) {
|
|
|
84359
84558
|
}
|
|
84360
84559
|
|
|
84361
84560
|
// src/cli/orchestration-status.ts
|
|
84561
|
+
var import_picocolors55 = __toESM(require_picocolors(), 1);
|
|
84562
|
+
|
|
84563
|
+
// src/core/orchestration-webhooks.ts
|
|
84362
84564
|
var import_picocolors54 = __toESM(require_picocolors(), 1);
|
|
84565
|
+
function webhookEndpointUrl(firePath) {
|
|
84566
|
+
return masEndpointUrl(firePath, readAuth());
|
|
84567
|
+
}
|
|
84568
|
+
function webhookEndpointLines(triggers, indent = " ") {
|
|
84569
|
+
return triggers.flatMap((t) => [
|
|
84570
|
+
`${indent}${webhookTriggerLabel(t)}`,
|
|
84571
|
+
t.fire_path ? `${indent} ${import_picocolors54.default.dim("POST")} ${webhookEndpointUrl(t.fire_path)}` : `${indent} ${import_picocolors54.default.dim("member endpoint shows once the control plane is updated")}`
|
|
84572
|
+
]);
|
|
84573
|
+
}
|
|
84574
|
+
function resolveWebhookTrigger(cloud, ref) {
|
|
84575
|
+
const want = canonicalUuid2(ref.trim());
|
|
84576
|
+
const webhooks = cloudWebhookTriggers(cloud, (_id, fallback) => fallback);
|
|
84577
|
+
const match = webhooks.find((t) => canonicalUuid2(t.node_id) === want || t.id && canonicalUuid2(t.id) === want);
|
|
84578
|
+
if (!match) {
|
|
84579
|
+
const other = (cloud.triggers ?? []).find((t) => canonicalUuid2(t.node_id) === want || t.id && canonicalUuid2(t.id) === want);
|
|
84580
|
+
if (other) {
|
|
84581
|
+
throw new Error(`Trigger ${ref} is a ${other.trigger_type} trigger; only webhook triggers fire this way.`);
|
|
84582
|
+
}
|
|
84583
|
+
const known = webhooks.map((t) => t.node_id);
|
|
84584
|
+
throw new Error(known.length ? `No webhook trigger ${ref} in this orchestration. Its webhook triggers: ${known.join(", ")}.` : `No webhook trigger ${ref}: this orchestration has none.`);
|
|
84585
|
+
}
|
|
84586
|
+
if (!match.id) {
|
|
84587
|
+
throw new Error("This control plane does not return trigger ids yet, so the CLI cannot fire a trigger. Update the server, or use the web app.");
|
|
84588
|
+
}
|
|
84589
|
+
return match;
|
|
84590
|
+
}
|
|
84591
|
+
|
|
84592
|
+
// src/cli/orchestration-status.ts
|
|
84363
84593
|
async function runOrchestrationStatus(cwd2) {
|
|
84364
84594
|
banner("orchestration status — what changed locally, remotely, both");
|
|
84365
84595
|
const link2 = readOrchLink(cwd2);
|
|
84366
84596
|
if (!link2) {
|
|
84367
84597
|
failWarn("This folder is not linked to any orchestration.");
|
|
84368
|
-
f2.info(`Run ${
|
|
84598
|
+
f2.info(`Run ${import_picocolors55.default.cyan("brainbase orchestration pull <id>")} first.`);
|
|
84369
84599
|
return;
|
|
84370
84600
|
}
|
|
84371
84601
|
const localManifest = hasOrchManifest(cwd2) ? readOrchManifest(cwd2) : null;
|
|
@@ -84388,8 +84618,8 @@ async function runOrchestrationStatus(cwd2) {
|
|
|
84388
84618
|
}
|
|
84389
84619
|
const lines = [];
|
|
84390
84620
|
lines.push("");
|
|
84391
|
-
lines.push(` ${
|
|
84392
|
-
lines.push(` ${
|
|
84621
|
+
lines.push(` ${import_picocolors55.default.bold(link2.name)} ${import_picocolors55.default.dim(`(${link2.orchestration_id})`)}`);
|
|
84622
|
+
lines.push(` ${import_picocolors55.default.dim("revision")} cloud ${cloud.revision}${lock ? ` · lock ${lock.revision}` : " · never pulled"}`);
|
|
84393
84623
|
lines.push("");
|
|
84394
84624
|
const localSlugByAgentId = new Map;
|
|
84395
84625
|
for (const m3 of localManifest?.members ?? []) {
|
|
@@ -84403,12 +84633,12 @@ async function runOrchestrationStatus(cwd2) {
|
|
|
84403
84633
|
const membersAdded = [...localMemberSet].filter((s3) => !cloudMemberSet.has(s3));
|
|
84404
84634
|
const membersRemoved = [...cloudMemberSet].filter((s3) => !localMemberSet.has(s3));
|
|
84405
84635
|
if (membersAdded.length || membersRemoved.length) {
|
|
84406
|
-
lines.push(` ${
|
|
84636
|
+
lines.push(` ${import_picocolors55.default.bold("members")}`);
|
|
84407
84637
|
for (const slug of membersAdded) {
|
|
84408
|
-
lines.push(` ${
|
|
84638
|
+
lines.push(` ${import_picocolors55.default.yellow("→ push")} added in yaml: ${import_picocolors55.default.bold(slug)}`);
|
|
84409
84639
|
}
|
|
84410
84640
|
for (const slug of membersRemoved) {
|
|
84411
|
-
lines.push(` ${
|
|
84641
|
+
lines.push(` ${import_picocolors55.default.cyan("← pull")} added on cloud: ${import_picocolors55.default.bold(slug)}`);
|
|
84412
84642
|
}
|
|
84413
84643
|
lines.push("");
|
|
84414
84644
|
}
|
|
@@ -84423,11 +84653,11 @@ async function runOrchestrationStatus(cwd2) {
|
|
|
84423
84653
|
const edgesAdded = [...localEdges.keys()].filter((k3) => !cloudEdges.has(k3));
|
|
84424
84654
|
const edgesRemoved = [...cloudEdges.keys()].filter((k3) => !localEdges.has(k3));
|
|
84425
84655
|
if (edgesAdded.length || edgesRemoved.length) {
|
|
84426
|
-
lines.push(` ${
|
|
84656
|
+
lines.push(` ${import_picocolors55.default.bold("edges")}`);
|
|
84427
84657
|
for (const k3 of edgesAdded)
|
|
84428
|
-
lines.push(` ${
|
|
84658
|
+
lines.push(` ${import_picocolors55.default.yellow("→ push")} added in yaml: ${k3}`);
|
|
84429
84659
|
for (const k3 of edgesRemoved)
|
|
84430
|
-
lines.push(` ${
|
|
84660
|
+
lines.push(` ${import_picocolors55.default.cyan("← pull")} added on cloud: ${k3}`);
|
|
84431
84661
|
lines.push("");
|
|
84432
84662
|
}
|
|
84433
84663
|
const metaDecisions = decideOrchestrationMeta({
|
|
@@ -84437,17 +84667,17 @@ async function runOrchestrationStatus(cwd2) {
|
|
|
84437
84667
|
force: false
|
|
84438
84668
|
});
|
|
84439
84669
|
if (metaDecisions.length) {
|
|
84440
|
-
lines.push(` ${
|
|
84670
|
+
lines.push(` ${import_picocolors55.default.bold("orchestration metadata")}`);
|
|
84441
84671
|
for (const m3 of metaDecisions) {
|
|
84442
84672
|
if (m3.kind === "push") {
|
|
84443
|
-
lines.push(` ${
|
|
84673
|
+
lines.push(` ${import_picocolors55.default.yellow("→ push")} ${import_picocolors55.default.bold(m3.field)}: cloud ${import_picocolors55.default.dim(`"${m3.cloud}"`)} → local ${import_picocolors55.default.dim(`"${m3.local}"`)}`);
|
|
84444
84674
|
} else if (m3.kind === "keep") {
|
|
84445
|
-
lines.push(` ${
|
|
84675
|
+
lines.push(` ${import_picocolors55.default.cyan("← pull")} ${import_picocolors55.default.bold(m3.field)}: changed in the cloud to ${import_picocolors55.default.dim(`"${m3.cloud}"`)}; push leaves it alone ${import_picocolors55.default.dim(`(yaml still has "${m3.local}")`)}`);
|
|
84446
84676
|
} else {
|
|
84447
|
-
lines.push(` ${
|
|
84677
|
+
lines.push(` ${import_picocolors55.default.red("! conflict")} ${import_picocolors55.default.bold(m3.field)}: local ${import_picocolors55.default.dim(`"${m3.local}"`)} vs cloud ${import_picocolors55.default.dim(`"${m3.cloud}"`)} — push refuses until you pull or ${import_picocolors55.default.cyan("--force")}`);
|
|
84448
84678
|
}
|
|
84449
84679
|
}
|
|
84450
|
-
lines.push(` ${
|
|
84680
|
+
lines.push(` ${import_picocolors55.default.dim("fields the manifest omits, and fields only the cloud changed, are left alone")}`);
|
|
84451
84681
|
lines.push("");
|
|
84452
84682
|
}
|
|
84453
84683
|
const cloudTriggers = cloudScheduleTriggers(cloud, slugForAgent);
|
|
@@ -84472,32 +84702,81 @@ async function runOrchestrationStatus(cwd2) {
|
|
|
84472
84702
|
const triggersToPull = cloudTriggers.filter((t) => !localNodes.has(t.node_id));
|
|
84473
84703
|
const triggerDeletes = triggerPlan.kind === "reconcile" ? triggerPlan.archives : [];
|
|
84474
84704
|
if (triggersToPush.length || triggersToPull.length) {
|
|
84475
|
-
lines.push(` ${
|
|
84705
|
+
lines.push(` ${import_picocolors55.default.bold("schedule triggers")}`);
|
|
84476
84706
|
for (const t of triggersToPush) {
|
|
84477
|
-
lines.push(` ${
|
|
84707
|
+
lines.push(` ${import_picocolors55.default.yellow("→ push")} added/changed in yaml: ${scheduleTriggerLabel(t)}`);
|
|
84478
84708
|
}
|
|
84479
84709
|
for (const t of triggersToPull) {
|
|
84480
84710
|
const doomed = triggerDeletes.includes(t.node_id);
|
|
84481
|
-
lines.push(doomed ? ` ${
|
|
84711
|
+
lines.push(doomed ? ` ${import_picocolors55.default.red("⨯ push deletes")} ${scheduleTriggerLabel(t)}` : ` ${import_picocolors55.default.cyan("← pull")} only on cloud: ${scheduleTriggerLabel(t)}`);
|
|
84482
84712
|
}
|
|
84483
84713
|
lines.push("");
|
|
84484
84714
|
}
|
|
84485
84715
|
if (triggerPlan.kind === "blocked") {
|
|
84486
|
-
lines.push(` ${
|
|
84716
|
+
lines.push(` ${import_picocolors55.default.bold(import_picocolors55.default.red("schedule triggers: push blocked"))}`);
|
|
84487
84717
|
for (const nodeId of triggerPlan.unseen) {
|
|
84488
|
-
lines.push(` ${
|
|
84718
|
+
lines.push(` ${import_picocolors55.default.red("!")} ${triggerLabel(nodeId)} ${import_picocolors55.default.dim("— only in the cloud; pushing would delete it")}`);
|
|
84489
84719
|
}
|
|
84490
84720
|
for (const nodeId of triggerPlan.cloudModified) {
|
|
84491
|
-
lines.push(` ${
|
|
84721
|
+
lines.push(` ${import_picocolors55.default.red("!")} ${triggerLabel(nodeId)} ${import_picocolors55.default.dim("— edited in the cloud; pushing would overwrite that edit")}`);
|
|
84492
84722
|
}
|
|
84493
84723
|
for (const nodeId of triggerPlan.staleArchives) {
|
|
84494
|
-
lines.push(` ${
|
|
84724
|
+
lines.push(` ${import_picocolors55.default.red("!")} ${triggerLabel(nodeId)} ${import_picocolors55.default.dim("— deleted here, edited in the cloud since; pushing would delete that edit")}`);
|
|
84495
84725
|
}
|
|
84496
|
-
lines.push(` ${
|
|
84726
|
+
lines.push(` ${import_picocolors55.default.dim("run")} ${import_picocolors55.default.cyan("brainbase orchestration pull")} ${import_picocolors55.default.dim("first")}`);
|
|
84497
84727
|
lines.push("");
|
|
84498
84728
|
} else if (triggerPlan.kind === "skip") {
|
|
84499
84729
|
const left = untouchedRows(triggerPlan);
|
|
84500
|
-
lines.push(` ${
|
|
84730
|
+
lines.push(` ${import_picocolors55.default.dim(`${left.length} cloud schedule trigger${left.length === 1 ? "" : "s"} not managed by this manifest — push leaves ${left.length === 1 ? "it" : "them"} untouched`)}`);
|
|
84731
|
+
lines.push("");
|
|
84732
|
+
}
|
|
84733
|
+
const cloudWebhooks = cloudWebhookTriggers(cloud, slugForAgent);
|
|
84734
|
+
const localWebhooks = manifestWebhookTriggers(localManifest);
|
|
84735
|
+
const webhookPlan = decideWebhookTriggerReconcile({
|
|
84736
|
+
local: localWebhooks,
|
|
84737
|
+
cloud: cloudWebhooks,
|
|
84738
|
+
baseline: lock?.webhook_triggers,
|
|
84739
|
+
force: false
|
|
84740
|
+
});
|
|
84741
|
+
const webhookByNode = new Map([...cloudWebhooks, ...localWebhooks].map((t) => [t.node_id, t]));
|
|
84742
|
+
const webhookLabel = (nodeId) => {
|
|
84743
|
+
const t = webhookByNode.get(nodeId);
|
|
84744
|
+
return t ? webhookTriggerLabel(t) : nodeId;
|
|
84745
|
+
};
|
|
84746
|
+
const localWebhookNodes = new Set(localWebhooks.map((t) => t.node_id));
|
|
84747
|
+
const cloudWebhookByNode = new Map(cloudWebhooks.map((t) => [t.node_id, t]));
|
|
84748
|
+
const webhooksToPush = localWebhooks.filter((t) => {
|
|
84749
|
+
const remote = cloudWebhookByNode.get(t.node_id);
|
|
84750
|
+
return !remote || webhookTriggerHash(remote) !== webhookTriggerHash(t);
|
|
84751
|
+
});
|
|
84752
|
+
const webhooksToPull = cloudWebhooks.filter((t) => !localWebhookNodes.has(t.node_id));
|
|
84753
|
+
const webhookDeletes = webhookPlan.kind === "reconcile" ? webhookPlan.archives : [];
|
|
84754
|
+
if (webhooksToPush.length || webhooksToPull.length) {
|
|
84755
|
+
lines.push(` ${import_picocolors55.default.bold("webhook triggers")}`);
|
|
84756
|
+
for (const t of webhooksToPush) {
|
|
84757
|
+
lines.push(` ${import_picocolors55.default.yellow("→ push")} added/changed in yaml: ${webhookTriggerLabel(t)}`);
|
|
84758
|
+
}
|
|
84759
|
+
for (const t of webhooksToPull) {
|
|
84760
|
+
lines.push(webhookDeletes.includes(t.node_id) ? ` ${import_picocolors55.default.red("⨯ push deletes")} ${webhookTriggerLabel(t)}` : ` ${import_picocolors55.default.cyan("← pull")} only on cloud: ${webhookTriggerLabel(t)}`);
|
|
84761
|
+
}
|
|
84762
|
+
lines.push("");
|
|
84763
|
+
}
|
|
84764
|
+
if (webhookPlan.kind === "blocked") {
|
|
84765
|
+
lines.push(` ${import_picocolors55.default.bold(import_picocolors55.default.red("webhook triggers: push blocked"))}`);
|
|
84766
|
+
for (const nodeId of webhookPlan.unseen) {
|
|
84767
|
+
lines.push(` ${import_picocolors55.default.red("!")} ${webhookLabel(nodeId)} ${import_picocolors55.default.dim("— only in the cloud; pushing would delete it")}`);
|
|
84768
|
+
}
|
|
84769
|
+
for (const nodeId of webhookPlan.cloudModified) {
|
|
84770
|
+
lines.push(` ${import_picocolors55.default.red("!")} ${webhookLabel(nodeId)} ${import_picocolors55.default.dim("— edited in the cloud; pushing would overwrite that edit")}`);
|
|
84771
|
+
}
|
|
84772
|
+
for (const nodeId of webhookPlan.staleArchives) {
|
|
84773
|
+
lines.push(` ${import_picocolors55.default.red("!")} ${webhookLabel(nodeId)} ${import_picocolors55.default.dim("— deleted here, edited in the cloud since; pushing would delete that edit")}`);
|
|
84774
|
+
}
|
|
84775
|
+
lines.push(` ${import_picocolors55.default.dim("run")} ${import_picocolors55.default.cyan("brainbase orchestration pull")} ${import_picocolors55.default.dim("first")}`);
|
|
84776
|
+
lines.push("");
|
|
84777
|
+
} else if (webhookPlan.kind === "skip") {
|
|
84778
|
+
const left = untouchedRows(webhookPlan);
|
|
84779
|
+
lines.push(` ${import_picocolors55.default.dim(`${left.length} cloud webhook trigger${left.length === 1 ? "" : "s"} not managed by this manifest — push leaves ${left.length === 1 ? "it" : "them"} untouched`)}`);
|
|
84501
84780
|
lines.push("");
|
|
84502
84781
|
}
|
|
84503
84782
|
const localDecisions = manifestDecisions(localManifest, new Map([...localSlugByAgentId].map(([agentId, slug]) => [slug, agentId])));
|
|
@@ -84506,7 +84785,7 @@ async function runOrchestrationStatus(cwd2) {
|
|
|
84506
84785
|
let decisionsToPull = [];
|
|
84507
84786
|
if (!cloudDecisionList) {
|
|
84508
84787
|
if (localDecisions.length) {
|
|
84509
|
-
lines.push(` ${
|
|
84788
|
+
lines.push(` ${import_picocolors55.default.dim(`${localDecisions.length} decision${localDecisions.length === 1 ? "" : "s"} in yaml, but the cloud does not show decision nodes to this account — push leaves ${localDecisions.length === 1 ? "it" : "them"} alone`)}`);
|
|
84510
84789
|
lines.push("");
|
|
84511
84790
|
}
|
|
84512
84791
|
} else {
|
|
@@ -84530,31 +84809,31 @@ async function runOrchestrationStatus(cwd2) {
|
|
|
84530
84809
|
decisionsToPull = cloudDecisionList.filter((d3) => !localIds.has(d3.id));
|
|
84531
84810
|
const decisionDeletes = decisionPlan.kind === "reconcile" ? decisionPlan.archives : [];
|
|
84532
84811
|
if (decisionsToPush.length || decisionsToPull.length) {
|
|
84533
|
-
lines.push(` ${
|
|
84812
|
+
lines.push(` ${import_picocolors55.default.bold("decisions")}`);
|
|
84534
84813
|
for (const d3 of decisionsToPush) {
|
|
84535
|
-
lines.push(` ${
|
|
84814
|
+
lines.push(` ${import_picocolors55.default.yellow("→ push")} added/changed in yaml: ${decisionLabel(d3)}`);
|
|
84536
84815
|
}
|
|
84537
84816
|
for (const d3 of decisionsToPull) {
|
|
84538
|
-
lines.push(decisionDeletes.includes(d3.id) ? ` ${
|
|
84817
|
+
lines.push(decisionDeletes.includes(d3.id) ? ` ${import_picocolors55.default.red("⨯ push deletes")} ${decisionLabel(d3)}` : ` ${import_picocolors55.default.cyan("← pull")} only on cloud: ${decisionLabel(d3)}`);
|
|
84539
84818
|
}
|
|
84540
84819
|
lines.push("");
|
|
84541
84820
|
}
|
|
84542
84821
|
if (decisionPlan.kind === "blocked") {
|
|
84543
|
-
lines.push(` ${
|
|
84822
|
+
lines.push(` ${import_picocolors55.default.bold(import_picocolors55.default.red("decisions: push blocked"))}`);
|
|
84544
84823
|
for (const id of decisionPlan.unseen) {
|
|
84545
|
-
lines.push(` ${
|
|
84824
|
+
lines.push(` ${import_picocolors55.default.red("!")} ${label2(id)} ${import_picocolors55.default.dim("— only in the cloud; pushing would delete it")}`);
|
|
84546
84825
|
}
|
|
84547
84826
|
for (const id of decisionPlan.cloudModified) {
|
|
84548
|
-
lines.push(` ${
|
|
84827
|
+
lines.push(` ${import_picocolors55.default.red("!")} ${label2(id)} ${import_picocolors55.default.dim("— edited in the cloud; pushing would overwrite that edit")}`);
|
|
84549
84828
|
}
|
|
84550
84829
|
for (const id of decisionPlan.staleArchives) {
|
|
84551
|
-
lines.push(` ${
|
|
84830
|
+
lines.push(` ${import_picocolors55.default.red("!")} ${label2(id)} ${import_picocolors55.default.dim("— deleted here, edited in the cloud since; pushing would delete that edit")}`);
|
|
84552
84831
|
}
|
|
84553
|
-
lines.push(` ${
|
|
84832
|
+
lines.push(` ${import_picocolors55.default.dim("run")} ${import_picocolors55.default.cyan("brainbase orchestration pull")} ${import_picocolors55.default.dim("first")}`);
|
|
84554
84833
|
lines.push("");
|
|
84555
84834
|
} else if (decisionPlan.kind === "skip") {
|
|
84556
84835
|
const left = untouchedRows(decisionPlan);
|
|
84557
|
-
lines.push(` ${
|
|
84836
|
+
lines.push(` ${import_picocolors55.default.dim(`${left.length} cloud decision${left.length === 1 ? "" : "s"} not managed by this manifest — push leaves ${left.length === 1 ? "it" : "them"} untouched`)}`);
|
|
84558
84837
|
lines.push("");
|
|
84559
84838
|
}
|
|
84560
84839
|
}
|
|
@@ -84578,27 +84857,35 @@ async function runOrchestrationStatus(cwd2) {
|
|
|
84578
84857
|
}
|
|
84579
84858
|
}
|
|
84580
84859
|
if (memberDrift.length) {
|
|
84581
|
-
lines.push(` ${
|
|
84860
|
+
lines.push(` ${import_picocolors55.default.bold("member content drift")}`);
|
|
84582
84861
|
for (const d3 of memberDrift) {
|
|
84583
|
-
lines.push(` ${
|
|
84862
|
+
lines.push(` ${import_picocolors55.default.cyan("?")} ${import_picocolors55.default.bold(d3.slug)} ${import_picocolors55.default.dim("— " + d3.reason)}`);
|
|
84584
84863
|
}
|
|
84585
|
-
lines.push(` ${
|
|
84864
|
+
lines.push(` ${import_picocolors55.default.dim("cd into each member folder and run")} ${import_picocolors55.default.cyan("brainbase agent status")}`);
|
|
84586
84865
|
lines.push("");
|
|
84587
84866
|
}
|
|
84588
84867
|
const revisionDrift = lock?.revision != null && cloud.revision !== lock.revision;
|
|
84589
84868
|
if (revisionDrift) {
|
|
84590
|
-
lines.push(` ${
|
|
84591
|
-
lines.push(` ${
|
|
84869
|
+
lines.push(` ${import_picocolors55.default.bold("cloud revision")}`);
|
|
84870
|
+
lines.push(` ${import_picocolors55.default.cyan("← pull")} cloud changed since last pull: ${import_picocolors55.default.dim(`lock ${lock.revision} → cloud ${cloud.revision}`)}`);
|
|
84592
84871
|
lines.push("");
|
|
84593
84872
|
}
|
|
84594
|
-
|
|
84595
|
-
|
|
84873
|
+
const endpointLines = [];
|
|
84874
|
+
if (cloudWebhooks.length) {
|
|
84875
|
+
endpointLines.push(` ${import_picocolors55.default.bold("webhook endpoints")} ${import_picocolors55.default.dim("— fire with your credentials, or")} ${import_picocolors55.default.cyan("brainbase orchestration trigger fire <node_id>")}`);
|
|
84876
|
+
endpointLines.push(...webhookEndpointLines(cloudWebhooks, " "));
|
|
84877
|
+
endpointLines.push("");
|
|
84878
|
+
}
|
|
84879
|
+
if (!membersAdded.length && !membersRemoved.length && !edgesAdded.length && !edgesRemoved.length && !triggersToPush.length && !triggersToPull.length && !webhooksToPush.length && !webhooksToPull.length && !decisionsToPush.length && !decisionsToPull.length && !metaDecisions.length && !memberDrift.length && !revisionDrift) {
|
|
84880
|
+
lines.push(` ${import_picocolors55.default.green("✓")} everything is in sync`);
|
|
84596
84881
|
lines.push("");
|
|
84882
|
+
lines.push(...endpointLines);
|
|
84597
84883
|
console.log(lines.join(`
|
|
84598
84884
|
`));
|
|
84599
84885
|
return;
|
|
84600
84886
|
}
|
|
84601
|
-
lines.push(
|
|
84887
|
+
lines.push(...endpointLines);
|
|
84888
|
+
lines.push(` ${import_picocolors55.default.dim("run")} ${import_picocolors55.default.cyan("brainbase orchestration pull")} ${import_picocolors55.default.dim("to apply cloud changes,")} ${import_picocolors55.default.cyan("brainbase orchestration push")} ${import_picocolors55.default.dim("to send yours")}`);
|
|
84602
84889
|
lines.push("");
|
|
84603
84890
|
console.log(lines.join(`
|
|
84604
84891
|
`));
|
|
@@ -84613,7 +84900,7 @@ function stableJson2(value2) {
|
|
|
84613
84900
|
}
|
|
84614
84901
|
|
|
84615
84902
|
// src/cli/orchestration-list.ts
|
|
84616
|
-
var
|
|
84903
|
+
var import_picocolors56 = __toESM(require_picocolors(), 1);
|
|
84617
84904
|
async function runOrchestrationList(args) {
|
|
84618
84905
|
const json3 = args.json === true;
|
|
84619
84906
|
if (!json3)
|
|
@@ -84644,13 +84931,13 @@ async function runOrchestrationList(args) {
|
|
|
84644
84931
|
}
|
|
84645
84932
|
const lines = [""];
|
|
84646
84933
|
for (const o2 of items) {
|
|
84647
|
-
lines.push(` ${
|
|
84934
|
+
lines.push(` ${import_picocolors56.default.bold(o2.name)} ${import_picocolors56.default.dim(o2.id)}`);
|
|
84648
84935
|
if (o2.description)
|
|
84649
|
-
lines.push(` ${
|
|
84650
|
-
lines.push(` ${
|
|
84936
|
+
lines.push(` ${import_picocolors56.default.dim(o2.description)}`);
|
|
84937
|
+
lines.push(` ${import_picocolors56.default.dim(`${o2.member_count} member${o2.member_count === 1 ? "" : "s"} · ${o2.edge_count} edge${o2.edge_count === 1 ? "" : "s"}`)}`);
|
|
84651
84938
|
lines.push("");
|
|
84652
84939
|
}
|
|
84653
|
-
lines.push(` ${
|
|
84940
|
+
lines.push(` ${import_picocolors56.default.dim("pull one with")} ${import_picocolors56.default.cyan("brainbase orchestration pull <id>")}`);
|
|
84654
84941
|
lines.push("");
|
|
84655
84942
|
console.log(lines.join(`
|
|
84656
84943
|
`));
|
|
@@ -84658,7 +84945,7 @@ async function runOrchestrationList(args) {
|
|
|
84658
84945
|
|
|
84659
84946
|
// src/cli/orchestration-add-agent.ts
|
|
84660
84947
|
import fs86 from "node:fs";
|
|
84661
|
-
var
|
|
84948
|
+
var import_picocolors57 = __toESM(require_picocolors(), 1);
|
|
84662
84949
|
|
|
84663
84950
|
// src/core/orchestration-add.ts
|
|
84664
84951
|
function resolveOrgIdForGroup(groupId, orgsWithTeams) {
|
|
@@ -84723,7 +85010,7 @@ async function runOrchestrationAddAgent(cwd2, args) {
|
|
|
84723
85010
|
const link2 = readOrchLink(cwd2);
|
|
84724
85011
|
if (!link2 || !hasOrchManifest(cwd2)) {
|
|
84725
85012
|
failWarn("This folder is not a linked orchestration.");
|
|
84726
|
-
f2.info(`Run ${
|
|
85013
|
+
f2.info(`Run ${import_picocolors57.default.cyan("brainbase orchestration pull <id>")} first.`);
|
|
84727
85014
|
return;
|
|
84728
85015
|
}
|
|
84729
85016
|
let manifest;
|
|
@@ -84749,7 +85036,7 @@ async function runOrchestrationAddAgent(cwd2, args) {
|
|
|
84749
85036
|
while (manifest.members.some((m3) => m3.slug === candidate) || fs86.existsSync(memberDir(cwd2, candidate))) {
|
|
84750
85037
|
candidate = `${slug}-${++n}`;
|
|
84751
85038
|
}
|
|
84752
|
-
f2.info(`Slug ${
|
|
85039
|
+
f2.info(`Slug ${import_picocolors57.default.bold(slug)} is taken — using ${import_picocolors57.default.bold(candidate)}.`);
|
|
84753
85040
|
slug = candidate;
|
|
84754
85041
|
}
|
|
84755
85042
|
let payloadSchema;
|
|
@@ -84773,7 +85060,7 @@ async function runOrchestrationAddAgent(cwd2, args) {
|
|
|
84773
85060
|
const resolved = resolveOrgIdForGroup(link2.group_id, orgsWithTeams);
|
|
84774
85061
|
if (!resolved) {
|
|
84775
85062
|
sp.stop("Failed.");
|
|
84776
|
-
fail(`Could not find an org that owns group ${
|
|
85063
|
+
fail(`Could not find an org that owns group ${import_picocolors57.default.bold(link2.group_id)}. ` + `Pass ${import_picocolors57.default.cyan("--org <id>")} explicitly.`);
|
|
84777
85064
|
return;
|
|
84778
85065
|
}
|
|
84779
85066
|
orgId = resolved;
|
|
@@ -84790,14 +85077,14 @@ async function runOrchestrationAddAgent(cwd2, args) {
|
|
|
84790
85077
|
if (from.length === 0 && to2.length === 0 && isInteractive() && manifest.members.length > 0) {
|
|
84791
85078
|
const memberOptions = manifest.members.map((m3) => ({ value: m3.slug, label: m3.slug }));
|
|
84792
85079
|
const pickedFrom = await ae({
|
|
84793
|
-
message: `Connect ${
|
|
85080
|
+
message: `Connect ${import_picocolors57.default.bold(slug)} FROM which member(s)? — edges INTO ${slug} (space to select, enter to skip)`,
|
|
84794
85081
|
options: memberOptions,
|
|
84795
85082
|
required: false
|
|
84796
85083
|
});
|
|
84797
85084
|
if (Array.isArray(pickedFrom))
|
|
84798
85085
|
from = pickedFrom;
|
|
84799
85086
|
const pickedTo = await ae({
|
|
84800
|
-
message: `Connect ${
|
|
85087
|
+
message: `Connect ${import_picocolors57.default.bold(slug)} TO which member(s)? — edges OUT of ${slug} (space to select, enter to skip)`,
|
|
84801
85088
|
options: memberOptions,
|
|
84802
85089
|
required: false
|
|
84803
85090
|
});
|
|
@@ -84836,23 +85123,23 @@ async function runOrchestrationAddAgent(cwd2, args) {
|
|
|
84836
85123
|
}
|
|
84837
85124
|
writeOrchManifest(cwd2, updated);
|
|
84838
85125
|
if (args.noPush) {
|
|
84839
|
-
f2.info(`Manifest updated. Run ${
|
|
85126
|
+
f2.info(`Manifest updated. Run ${import_picocolors57.default.cyan("brainbase orchestration push")} to apply.`);
|
|
84840
85127
|
return;
|
|
84841
85128
|
}
|
|
84842
85129
|
await runOrchestrationPush(cwd2, { yes: true, graphOnly: true });
|
|
84843
85130
|
}
|
|
84844
85131
|
|
|
84845
85132
|
// src/cli/orchestration-create.ts
|
|
84846
|
-
var
|
|
85133
|
+
var import_picocolors58 = __toESM(require_picocolors(), 1);
|
|
84847
85134
|
async function runOrchestrationCreate(cwd2, args) {
|
|
84848
85135
|
banner("orchestration create — claim a brainbase-orchestration.yaml");
|
|
84849
85136
|
if (readOrchLink(cwd2)) {
|
|
84850
85137
|
failWarn("This folder is already linked to an orchestration.");
|
|
84851
|
-
f2.info(`Run ${
|
|
85138
|
+
f2.info(`Run ${import_picocolors58.default.cyan("brainbase orchestration push")} to update it.`);
|
|
84852
85139
|
return;
|
|
84853
85140
|
}
|
|
84854
85141
|
if (!hasOrchManifest(cwd2)) {
|
|
84855
|
-
failWarn(`No ${
|
|
85142
|
+
failWarn(`No ${import_picocolors58.default.bold(ORCH_MANIFEST_FILE)} here.`);
|
|
84856
85143
|
f2.info(`Create one, or pull an existing orchestration first.`);
|
|
84857
85144
|
return;
|
|
84858
85145
|
}
|
|
@@ -84885,10 +85172,10 @@ async function runOrchestrationCreate(cwd2, args) {
|
|
|
84885
85172
|
});
|
|
84886
85173
|
const plan = [
|
|
84887
85174
|
"",
|
|
84888
|
-
` ${
|
|
84889
|
-
` ${
|
|
84890
|
-
` ${
|
|
84891
|
-
` ${
|
|
85175
|
+
` ${import_picocolors58.default.bold(manifest.orchestration.name)}`,
|
|
85176
|
+
` ${import_picocolors58.default.dim("org")} ${import_picocolors58.default.bold(target.org.name)}`,
|
|
85177
|
+
` ${import_picocolors58.default.dim("team")} ${import_picocolors58.default.bold(target.team.name)}`,
|
|
85178
|
+
` ${import_picocolors58.default.dim("graph")} ${manifest.members.length} member${manifest.members.length === 1 ? "" : "s"}, ${manifest.edges.length} edge${manifest.edges.length === 1 ? "" : "s"}, ${graph.triggers.length + graph.webhookTriggers.length} trigger${graph.triggers.length + graph.webhookTriggers.length === 1 ? "" : "s"}`,
|
|
84892
85179
|
""
|
|
84893
85180
|
];
|
|
84894
85181
|
console.log(plan.join(`
|
|
@@ -84916,9 +85203,11 @@ async function runOrchestrationCreate(cwd2, args) {
|
|
|
84916
85203
|
credit_limit: manifest.orchestration.credit_limit,
|
|
84917
85204
|
members: graph.memberIds,
|
|
84918
85205
|
edges: graph.edges,
|
|
84919
|
-
triggers: graph.triggers
|
|
85206
|
+
triggers: [...graph.triggers, ...graph.webhookTriggers]
|
|
84920
85207
|
});
|
|
84921
|
-
sp.stop(`Created ${
|
|
85208
|
+
sp.stop(`Created ${import_picocolors58.default.bold(created.name)}.`);
|
|
85209
|
+
const slugForAgent = (agentId, fallback) => manifest.members.find((m3) => slugToAgentId.get(m3.slug) === agentId)?.slug ?? fallback;
|
|
85210
|
+
const webhooks = cloudWebhookTriggers(created, slugForAgent);
|
|
84922
85211
|
writeOrchLink(cwd2, {
|
|
84923
85212
|
schemaVersion: 1,
|
|
84924
85213
|
orchestration_id: created.id,
|
|
@@ -84944,11 +85233,12 @@ async function runOrchestrationCreate(cwd2, args) {
|
|
|
84944
85233
|
to_slug: e2.to_slug ?? e2.to_agent_id,
|
|
84945
85234
|
description: e2.description ?? "",
|
|
84946
85235
|
payload_schema: e2.payload_schema ?? {}
|
|
84947
|
-
}))
|
|
85236
|
+
})),
|
|
85237
|
+
webhook_triggers: syncedWebhookTriggers(webhooks)
|
|
84948
85238
|
});
|
|
84949
85239
|
const decisionCount = manifest.decisions?.length ?? 0;
|
|
84950
85240
|
if (decisionCount) {
|
|
84951
|
-
f2.info(`Run ${
|
|
85241
|
+
f2.info(`Run ${import_picocolors58.default.cyan("brainbase orchestration push")} to add the ${decisionCount} decision${decisionCount === 1 ? "" : "s"} in this manifest.`);
|
|
84952
85242
|
}
|
|
84953
85243
|
$e(`Created ${created.name} at revision ${created.revision}.`);
|
|
84954
85244
|
} catch (err) {
|
|
@@ -84971,8 +85261,98 @@ function handleApiError7(err) {
|
|
|
84971
85261
|
}
|
|
84972
85262
|
}
|
|
84973
85263
|
|
|
85264
|
+
// src/cli/orchestration-from-agent.ts
|
|
85265
|
+
var import_picocolors59 = __toESM(require_picocolors(), 1);
|
|
85266
|
+
var MEMBERSHIP_CONFLICT_CODE = "orchestration_membership_conflict";
|
|
85267
|
+
var MAX_NAME_LENGTH = 200;
|
|
85268
|
+
async function runOrchestrationFromAgent(cwd2, args) {
|
|
85269
|
+
const json3 = args.json === true;
|
|
85270
|
+
if (args.agentId !== undefined && !args.agentId.trim()) {
|
|
85271
|
+
fail3(json3, "The agent id is empty.", `Pass an agent id, or omit it to use the agent linked here.`);
|
|
85272
|
+
return;
|
|
85273
|
+
}
|
|
85274
|
+
const link2 = readLink(cwd2);
|
|
85275
|
+
const agentId = args.agentId?.trim() || link2?.agent_id;
|
|
85276
|
+
if (!agentId) {
|
|
85277
|
+
fail3(json3, "No agent given and this folder is not linked to one.", `Pass an agent id: ${import_picocolors59.default.cyan("brainbase orchestration from-agent <agent-id>")}`);
|
|
85278
|
+
return;
|
|
85279
|
+
}
|
|
85280
|
+
const fromLink = args.agentId === undefined && link2 !== null;
|
|
85281
|
+
if (!json3)
|
|
85282
|
+
banner("orchestration from-agent — turn an agent into an orchestration");
|
|
85283
|
+
let created;
|
|
85284
|
+
try {
|
|
85285
|
+
const teamId = args.teamId ?? (fromLink ? link2.team_id : (await resolveOrgAndTeam({
|
|
85286
|
+
orgId: args.orgId,
|
|
85287
|
+
allowPrompt: !json3,
|
|
85288
|
+
announce: !json3
|
|
85289
|
+
})).team.id);
|
|
85290
|
+
const agent = await masApi.getAgentSummary(agentId);
|
|
85291
|
+
const sp = json3 ? null : spinner();
|
|
85292
|
+
sp?.start("Creating orchestration…");
|
|
85293
|
+
try {
|
|
85294
|
+
created = await masApi.createOrchestrationFromAgent({
|
|
85295
|
+
agent_id: agentId,
|
|
85296
|
+
group_id: teamId,
|
|
85297
|
+
name: args.name ?? (agent.name.trim().slice(0, MAX_NAME_LENGTH) || "Orchestration"),
|
|
85298
|
+
description: args.description ?? agent.description
|
|
85299
|
+
});
|
|
85300
|
+
} catch (err) {
|
|
85301
|
+
sp?.stop("Failed.");
|
|
85302
|
+
throw err;
|
|
85303
|
+
}
|
|
85304
|
+
sp?.stop(`Created ${import_picocolors59.default.bold(sanitizeLabel(created.name))}.`);
|
|
85305
|
+
} catch (err) {
|
|
85306
|
+
if (err instanceof ApiError) {
|
|
85307
|
+
fail3(json3, err.message, hint(err), { status: err.status ?? null });
|
|
85308
|
+
return;
|
|
85309
|
+
}
|
|
85310
|
+
if (json3 && err instanceof Error) {
|
|
85311
|
+
fail3(json3, err.message, undefined, { status: null });
|
|
85312
|
+
return;
|
|
85313
|
+
}
|
|
85314
|
+
throw err;
|
|
85315
|
+
}
|
|
85316
|
+
if (json3) {
|
|
85317
|
+
console.log(JSON.stringify(created, null, 2));
|
|
85318
|
+
return;
|
|
85319
|
+
}
|
|
85320
|
+
console.log([
|
|
85321
|
+
"",
|
|
85322
|
+
` ${import_picocolors59.default.green("✓")} ${import_picocolors59.default.bold(sanitizeLabel(created.name))} ${import_picocolors59.default.dim(sanitizeLabel(created.id))}`,
|
|
85323
|
+
` ${import_picocolors59.default.dim("only member:")} ${sanitizeLabel(agentId)}`,
|
|
85324
|
+
"",
|
|
85325
|
+
` ${import_picocolors59.default.dim("work on its graph with")} ${import_picocolors59.default.cyan(`brainbase orchestration pull ${sanitizeLabel(created.id)}`)}`,
|
|
85326
|
+
""
|
|
85327
|
+
].join(`
|
|
85328
|
+
`));
|
|
85329
|
+
}
|
|
85330
|
+
function hint(err) {
|
|
85331
|
+
if (err.status === 409) {
|
|
85332
|
+
const code = err.body?.detail?.code;
|
|
85333
|
+
if (code === MEMBERSHIP_CONFLICT_CODE) {
|
|
85334
|
+
return "An agent belongs to one orchestration at a time. Remove it from that one first.";
|
|
85335
|
+
}
|
|
85336
|
+
return `Pick another name with ${import_picocolors59.default.cyan("--name <name>")}.`;
|
|
85337
|
+
}
|
|
85338
|
+
if (err.status === 400 || err.status === 403) {
|
|
85339
|
+
return `The agent must be in the team you create it in. Pick one with ${import_picocolors59.default.cyan("--team <id>")}.`;
|
|
85340
|
+
}
|
|
85341
|
+
return;
|
|
85342
|
+
}
|
|
85343
|
+
function fail3(json3, message, help, extra = {}) {
|
|
85344
|
+
if (json3)
|
|
85345
|
+
console.log(JSON.stringify({ error: message, ...extra }, null, 2));
|
|
85346
|
+
else {
|
|
85347
|
+
f2.error(sanitizeLabel(message));
|
|
85348
|
+
if (help)
|
|
85349
|
+
f2.info(help);
|
|
85350
|
+
}
|
|
85351
|
+
process.exitCode = 1;
|
|
85352
|
+
}
|
|
85353
|
+
|
|
84974
85354
|
// src/cli/orchestration-init.ts
|
|
84975
|
-
var
|
|
85355
|
+
var import_picocolors60 = __toESM(require_picocolors(), 1);
|
|
84976
85356
|
|
|
84977
85357
|
// src/core/orchestration-scaffold.ts
|
|
84978
85358
|
var import_yaml6 = __toESM(require_dist(), 1);
|
|
@@ -85007,6 +85387,13 @@ var FULL_TEMPLATE_EXAMPLES = {
|
|
|
85007
85387
|
is_active: false,
|
|
85008
85388
|
config: { cron_expression: "0 9 * * 1" },
|
|
85009
85389
|
to: [{ agent: "triage" }]
|
|
85390
|
+
},
|
|
85391
|
+
{
|
|
85392
|
+
type: "webhook",
|
|
85393
|
+
node_id: "00000000-0000-4000-8000-000000000001",
|
|
85394
|
+
is_active: false,
|
|
85395
|
+
public: false,
|
|
85396
|
+
to: [{ agent: "triage" }]
|
|
85010
85397
|
}
|
|
85011
85398
|
]
|
|
85012
85399
|
};
|
|
@@ -85061,6 +85448,10 @@ edges: []
|
|
|
85061
85448
|
${commented({ edges: ex.edges })}
|
|
85062
85449
|
|
|
85063
85450
|
# Schedule triggers start members on a cron (standard 5-field syntax).
|
|
85451
|
+
# Webhook triggers start them when something outside Brainbase POSTs to them.
|
|
85452
|
+
# A webhook's \`public\` switches its secret URL: off (the default), only
|
|
85453
|
+
# members fire it, with \`brainbase orchestration trigger fire <node_id>\`;
|
|
85454
|
+
# on, anyone holding the URL (shown in the web app) can.
|
|
85064
85455
|
# \`node_id\` is a UUID you generate once and keep, so pushes update the
|
|
85065
85456
|
# same trigger instead of creating another.
|
|
85066
85457
|
${commented({ triggers: ex.triggers })}
|
|
@@ -85091,7 +85482,7 @@ async function runOrchestrationInit(cwd2, args = {}) {
|
|
|
85091
85482
|
path: target,
|
|
85092
85483
|
created: false,
|
|
85093
85484
|
reason: "conflicting-flags",
|
|
85094
|
-
message: `Pass either ${
|
|
85485
|
+
message: `Pass either ${import_picocolors60.default.cyan("--minimal")} or ${import_picocolors60.default.cyan("--full")}, not both.`
|
|
85095
85486
|
});
|
|
85096
85487
|
}
|
|
85097
85488
|
if (readOrchLink(cwd2)) {
|
|
@@ -85099,7 +85490,7 @@ async function runOrchestrationInit(cwd2, args = {}) {
|
|
|
85099
85490
|
path: target,
|
|
85100
85491
|
created: false,
|
|
85101
85492
|
reason: "linked",
|
|
85102
|
-
message: `This folder is linked to an orchestration. Edit ${
|
|
85493
|
+
message: `This folder is linked to an orchestration. Edit ${import_picocolors60.default.bold(ORCH_MANIFEST_FILE)} and run ${import_picocolors60.default.cyan("brainbase orchestration push")}, or init in a new folder.`
|
|
85103
85494
|
});
|
|
85104
85495
|
}
|
|
85105
85496
|
const existed = hasOrchManifest(cwd2);
|
|
@@ -85108,7 +85499,7 @@ async function runOrchestrationInit(cwd2, args = {}) {
|
|
|
85108
85499
|
path: target,
|
|
85109
85500
|
created: false,
|
|
85110
85501
|
reason: "manifest-exists",
|
|
85111
|
-
message: `${
|
|
85502
|
+
message: `${import_picocolors60.default.bold(ORCH_MANIFEST_FILE)} already exists here. Edit it, or pass ${import_picocolors60.default.cyan("--force")} to overwrite it.`
|
|
85112
85503
|
});
|
|
85113
85504
|
}
|
|
85114
85505
|
const name = resolveScaffoldName(cwd2, args.name, FALLBACK_NAME2);
|
|
@@ -85118,7 +85509,7 @@ async function runOrchestrationInit(cwd2, args = {}) {
|
|
|
85118
85509
|
try {
|
|
85119
85510
|
writeOrchestrationScaffold(cwd2, { name }, { full: args.full });
|
|
85120
85511
|
} catch (err) {
|
|
85121
|
-
console.error(
|
|
85512
|
+
console.error(import_picocolors60.default.red(`Failed to write ${ORCH_MANIFEST_FILE}: ${err.message}`));
|
|
85122
85513
|
process.exitCode = 1;
|
|
85123
85514
|
return;
|
|
85124
85515
|
}
|
|
@@ -85126,10 +85517,10 @@ async function runOrchestrationInit(cwd2, args = {}) {
|
|
|
85126
85517
|
emit2({ path: target, created: true, name, template: template2 });
|
|
85127
85518
|
return;
|
|
85128
85519
|
}
|
|
85129
|
-
f2.success(`Wrote ${
|
|
85520
|
+
f2.success(`Wrote ${import_picocolors60.default.bold(ORCH_MANIFEST_FILE)}${existed ? " (overwritten)" : ""}.`);
|
|
85130
85521
|
console.log();
|
|
85131
|
-
console.log(tip(`Edit it, then run ${
|
|
85132
|
-
console.log(tip(`Then ${
|
|
85522
|
+
console.log(tip(`Edit it, then run ${import_picocolors60.default.cyan("brainbase orchestration create")} ${import_picocolors60.default.dim("— creates the orchestration and links this folder.")}`));
|
|
85523
|
+
console.log(tip(`Then ${import_picocolors60.default.cyan("brainbase orchestration add-agent <name>")} ${import_picocolors60.default.dim("— creates a member agent and wires it into the graph.")}`));
|
|
85133
85524
|
console.log();
|
|
85134
85525
|
}
|
|
85135
85526
|
function emit2(result2) {
|
|
@@ -85143,13 +85534,127 @@ function refuse2(json3, outcome) {
|
|
|
85143
85534
|
return;
|
|
85144
85535
|
}
|
|
85145
85536
|
console.error(`
|
|
85146
|
-
${
|
|
85537
|
+
${import_picocolors60.default.red(message)}
|
|
85147
85538
|
`);
|
|
85148
85539
|
}
|
|
85149
85540
|
|
|
85541
|
+
// src/cli/orchestration-trigger.ts
|
|
85542
|
+
var import_picocolors61 = __toESM(require_picocolors(), 1);
|
|
85543
|
+
var OPTIONS = [
|
|
85544
|
+
{ key: "data", names: ["--data", "-d"], kind: "value" },
|
|
85545
|
+
{ key: "idempotencyKey", names: ["--idempotency-key"], kind: "value" },
|
|
85546
|
+
{ key: "orchestration", names: ["--orchestration"], kind: "value" }
|
|
85547
|
+
];
|
|
85548
|
+
async function runOrchestrationTrigger(cwd2, args, opts) {
|
|
85549
|
+
const [sub, ...rest2] = args;
|
|
85550
|
+
if (sub !== "fire") {
|
|
85551
|
+
if (sub !== undefined && sub !== "help") {
|
|
85552
|
+
console.error(`Unknown orchestration trigger subcommand: ${sub}`);
|
|
85553
|
+
process.exitCode = 1;
|
|
85554
|
+
}
|
|
85555
|
+
printTriggerHelp();
|
|
85556
|
+
return;
|
|
85557
|
+
}
|
|
85558
|
+
let parsed;
|
|
85559
|
+
try {
|
|
85560
|
+
parsed = parseArgv(rest2, OPTIONS);
|
|
85561
|
+
} catch (err) {
|
|
85562
|
+
if (!(err instanceof ArgvParseError))
|
|
85563
|
+
throw err;
|
|
85564
|
+
return refuse3(err.message, opts);
|
|
85565
|
+
}
|
|
85566
|
+
const [ref, ...extra] = parsed.positionals;
|
|
85567
|
+
if (!ref || extra.length > 0) {
|
|
85568
|
+
return refuse3("Usage: brainbase orchestration trigger fire <trigger> [--data JSON] [--idempotency-key K]", opts);
|
|
85569
|
+
}
|
|
85570
|
+
let payload = {};
|
|
85571
|
+
const data = stringOption(parsed, "data");
|
|
85572
|
+
if (data !== undefined) {
|
|
85573
|
+
try {
|
|
85574
|
+
payload = JSON.parse(data);
|
|
85575
|
+
} catch (err) {
|
|
85576
|
+
return refuse3(`--data is not valid JSON: ${err.message}`, opts);
|
|
85577
|
+
}
|
|
85578
|
+
}
|
|
85579
|
+
const idempotencyKey = stringOption(parsed, "idempotencyKey");
|
|
85580
|
+
if (idempotencyKey !== undefined && !idempotencyKey.trim()) {
|
|
85581
|
+
return refuse3("--idempotency-key cannot be empty.", opts);
|
|
85582
|
+
}
|
|
85583
|
+
const orchestrationId = stringOption(parsed, "orchestration") ?? readOrchLink(cwd2)?.orchestration_id;
|
|
85584
|
+
if (!orchestrationId) {
|
|
85585
|
+
return refuse3(`This folder is not linked to an orchestration. Run it where ${ORCH_MANIFEST_FILE} lives, or pass --orchestration <id>.`, opts);
|
|
85586
|
+
}
|
|
85587
|
+
try {
|
|
85588
|
+
const trigger = resolveWebhookTrigger(await api.getOrchestration(orchestrationId), ref);
|
|
85589
|
+
const fire = await api.fireOrchestrationTrigger(orchestrationId, trigger.id, payload, idempotencyKey);
|
|
85590
|
+
reportFire(fire, webhookTriggerLabel(trigger), opts);
|
|
85591
|
+
} catch (err) {
|
|
85592
|
+
return refuse3(errorMessage2(err), opts);
|
|
85593
|
+
}
|
|
85594
|
+
}
|
|
85595
|
+
function reportFire(fire, label2, opts) {
|
|
85596
|
+
const failed = !fire.duplicate && !!fire.dispatch_error;
|
|
85597
|
+
if (failed)
|
|
85598
|
+
process.exitCode = 1;
|
|
85599
|
+
if (opts.json) {
|
|
85600
|
+
console.log(JSON.stringify(fire, null, 2));
|
|
85601
|
+
return;
|
|
85602
|
+
}
|
|
85603
|
+
const started = fire.dispatched_agent_ids?.length ?? 0;
|
|
85604
|
+
const tasks = `${started} task${started === 1 ? "" : "s"}`;
|
|
85605
|
+
if (fire.duplicate) {
|
|
85606
|
+
f2.info(`Already fired with this idempotency key (fire ${fire.fire_id}); nothing new started.`);
|
|
85607
|
+
} else if (failed) {
|
|
85608
|
+
fail(started > 0 ? `Fired ${label2} — started ${tasks}, then failed: ${fire.dispatch_error} (fire ${fire.fire_id})` : `Fired ${label2}, but nothing started: ${fire.dispatch_error} (fire ${fire.fire_id})`);
|
|
85609
|
+
} else {
|
|
85610
|
+
f2.success(`Fired ${label2} — started ${tasks} (fire ${fire.fire_id}).`);
|
|
85611
|
+
}
|
|
85612
|
+
}
|
|
85613
|
+
function refuse3(message, opts) {
|
|
85614
|
+
process.exitCode = 1;
|
|
85615
|
+
if (opts.json) {
|
|
85616
|
+
console.log(JSON.stringify({ error: message }, null, 2));
|
|
85617
|
+
} else {
|
|
85618
|
+
f2.error(message);
|
|
85619
|
+
}
|
|
85620
|
+
}
|
|
85621
|
+
function errorMessage2(err) {
|
|
85622
|
+
if (!(err instanceof ApiError))
|
|
85623
|
+
return err.message;
|
|
85624
|
+
if (err.status === 401)
|
|
85625
|
+
return "Your session is invalid. Run `brainbase login` and try again.";
|
|
85626
|
+
if (err.status === 403) {
|
|
85627
|
+
return `${err.message} Firing a trigger needs a login or an API key with publish scope.`;
|
|
85628
|
+
}
|
|
85629
|
+
if (err.status === 404)
|
|
85630
|
+
return `${err.message} (or you do not have access to this orchestration).`;
|
|
85631
|
+
return err.message;
|
|
85632
|
+
}
|
|
85633
|
+
function printTriggerHelp() {
|
|
85634
|
+
console.log([
|
|
85635
|
+
"",
|
|
85636
|
+
` ${import_picocolors61.default.bold("brainbase orchestration trigger fire")} ${import_picocolors61.default.dim("<trigger> [options]")}`,
|
|
85637
|
+
"",
|
|
85638
|
+
` ${import_picocolors61.default.dim("Fire a webhook trigger with your credentials, whether or not its URL is public. Starts real, billable runs.")}`,
|
|
85639
|
+
` ${import_picocolors61.default.dim("<trigger> is its node_id from")} ${ORCH_MANIFEST_FILE}${import_picocolors61.default.dim(", or its trigger id.")}`,
|
|
85640
|
+
"",
|
|
85641
|
+
` ${import_picocolors61.default.bold("Flags")}`,
|
|
85642
|
+
` ${import_picocolors61.default.dim("--data <json>")} the payload (default {})`,
|
|
85643
|
+
` ${import_picocolors61.default.dim("--idempotency-key <k>")} a retry with the same key fires once`,
|
|
85644
|
+
` ${import_picocolors61.default.dim("--orchestration <id>")} the orchestration, when this folder is not linked to one`,
|
|
85645
|
+
` ${import_picocolors61.default.dim("--json")} print the fire as JSON`,
|
|
85646
|
+
""
|
|
85647
|
+
].join(`
|
|
85648
|
+
`));
|
|
85649
|
+
}
|
|
85650
|
+
|
|
85150
85651
|
// src/cli/orchestration.ts
|
|
85151
85652
|
async function runOrchestration(cwd2, sub, args, opts) {
|
|
85152
85653
|
if (args.some((arg) => arg === "--help" || arg === "-h")) {
|
|
85654
|
+
if (sub === "trigger" || sub === "triggers") {
|
|
85655
|
+
await runOrchestrationTrigger(cwd2, ["help"], { json: opts.json });
|
|
85656
|
+
return;
|
|
85657
|
+
}
|
|
85153
85658
|
printHelp4();
|
|
85154
85659
|
return;
|
|
85155
85660
|
}
|
|
@@ -85170,6 +85675,16 @@ async function runOrchestration(cwd2, sub, args, opts) {
|
|
|
85170
85675
|
teamId: opts.teamId
|
|
85171
85676
|
});
|
|
85172
85677
|
return;
|
|
85678
|
+
case "from-agent":
|
|
85679
|
+
await runOrchestrationFromAgent(cwd2, {
|
|
85680
|
+
agentId: args[0],
|
|
85681
|
+
orgId: opts.orgId,
|
|
85682
|
+
teamId: opts.teamId,
|
|
85683
|
+
name: opts.name,
|
|
85684
|
+
description: opts.description,
|
|
85685
|
+
json: opts.json
|
|
85686
|
+
});
|
|
85687
|
+
return;
|
|
85173
85688
|
case "pull":
|
|
85174
85689
|
await runOrchestrationPull(cwd2, {
|
|
85175
85690
|
orchestrationId: args[0],
|
|
@@ -85187,6 +85702,10 @@ async function runOrchestration(cwd2, sub, args, opts) {
|
|
|
85187
85702
|
case "status":
|
|
85188
85703
|
await runOrchestrationStatus(cwd2);
|
|
85189
85704
|
return;
|
|
85705
|
+
case "trigger":
|
|
85706
|
+
case "triggers":
|
|
85707
|
+
await runOrchestrationTrigger(cwd2, args, { json: opts.json });
|
|
85708
|
+
return;
|
|
85190
85709
|
case "list":
|
|
85191
85710
|
case "ls":
|
|
85192
85711
|
await runOrchestrationList({ orgId: opts.orgId, teamId: opts.teamId, json: opts.json });
|
|
@@ -85216,7 +85735,7 @@ async function runOrchestration(cwd2, sub, args, opts) {
|
|
|
85216
85735
|
return;
|
|
85217
85736
|
default:
|
|
85218
85737
|
console.error(`Unknown orchestration subcommand: ${sub}
|
|
85219
|
-
${didYouMean(sub, ["create", "pull", "push", "status", "list", "delete", "add-agent"], "brainbase orchestration")}`);
|
|
85738
|
+
${didYouMean(sub, ["create", "from-agent", "pull", "push", "status", "list", "delete", "add-agent", "trigger"], "brainbase orchestration")}`);
|
|
85220
85739
|
printHelp4();
|
|
85221
85740
|
process.exit(1);
|
|
85222
85741
|
}
|
|
@@ -85224,25 +85743,28 @@ ${didYouMean(sub, ["create", "pull", "push", "status", "list", "delete", "add-ag
|
|
|
85224
85743
|
function printHelp4() {
|
|
85225
85744
|
const out = [];
|
|
85226
85745
|
out.push("");
|
|
85227
|
-
out.push(` ${
|
|
85746
|
+
out.push(` ${import_picocolors62.default.bold("brainbase orchestration")} ${import_picocolors62.default.dim("<sub> [options]")}`);
|
|
85228
85747
|
out.push("");
|
|
85229
|
-
out.push(` ${
|
|
85230
|
-
out.push(` ${
|
|
85231
|
-
out.push(` ${
|
|
85232
|
-
out.push(` ${
|
|
85233
|
-
out.push(` ${
|
|
85234
|
-
out.push(` ${
|
|
85235
|
-
out.push(` ${
|
|
85236
|
-
out.push(` ${
|
|
85748
|
+
out.push(` ${import_picocolors62.default.cyan("init")} ${import_picocolors62.default.dim("write a starter brainbase-orchestration.yaml here — offline, no login (--full for a commented template, --force to overwrite)")}`);
|
|
85749
|
+
out.push(` ${import_picocolors62.default.cyan("create")} ${import_picocolors62.default.dim("claim a local orchestration manifest and create it in the cloud")}`);
|
|
85750
|
+
out.push(` ${import_picocolors62.default.cyan("from-agent")} ${import_picocolors62.default.dim("[agent-id]")} ${import_picocolors62.default.dim("turn an existing agent (default: this folder's) into an orchestration")}`);
|
|
85751
|
+
out.push(` ${import_picocolors62.default.cyan("pull")} ${import_picocolors62.default.dim("<id>")} ${import_picocolors62.default.dim("fetch orchestration + every member agent into this folder")}`);
|
|
85752
|
+
out.push(` ${import_picocolors62.default.cyan("push")} ${import_picocolors62.default.dim("push each member, then update the orchestration graph")}`);
|
|
85753
|
+
out.push(` ${import_picocolors62.default.cyan("add-agent")} ${import_picocolors62.default.dim("<name>")} ${import_picocolors62.default.dim("create a member agent, wire edges (--from/--to), and push")}`);
|
|
85754
|
+
out.push(` ${import_picocolors62.default.cyan("status")} ${import_picocolors62.default.dim("show what would push and what would pull")}`);
|
|
85755
|
+
out.push(` ${import_picocolors62.default.cyan("trigger fire")} ${import_picocolors62.default.dim("<t>")} ${import_picocolors62.default.dim("fire a webhook trigger with your credentials (--data JSON, --idempotency-key K)")}`);
|
|
85756
|
+
out.push(` ${import_picocolors62.default.cyan("list")} ${import_picocolors62.default.dim("list orchestrations under a team")}`);
|
|
85757
|
+
out.push(` ${import_picocolors62.default.cyan("delete")} ${import_picocolors62.default.dim("<id>")} ${import_picocolors62.default.dim("permanently delete an orchestration graph — member agents are kept")}`);
|
|
85237
85758
|
out.push("");
|
|
85238
|
-
out.push(` ${
|
|
85239
|
-
out.push(` ${
|
|
85240
|
-
out.push(` ${
|
|
85241
|
-
out.push(` ${
|
|
85242
|
-
out.push(` ${
|
|
85243
|
-
out.push(` ${
|
|
85244
|
-
out.push(` ${
|
|
85245
|
-
out.push(` ${
|
|
85759
|
+
out.push(` ${import_picocolors62.default.bold("Flags")}`);
|
|
85760
|
+
out.push(` ${import_picocolors62.default.dim("--yes, -y")} skip confirmations (required for delete without a terminal)`);
|
|
85761
|
+
out.push(` ${import_picocolors62.default.dim("--json")} for init, from-agent, list and delete: machine-readable result`);
|
|
85762
|
+
out.push(` ${import_picocolors62.default.dim("--name <name>")} for init: orchestration name (default: this folder's name); for from-agent: default the agent's`);
|
|
85763
|
+
out.push(` ${import_picocolors62.default.dim("--description <text>")} for from-agent: orchestration description (default: the agent's)`);
|
|
85764
|
+
out.push(` ${import_picocolors62.default.dim("--harness <id>")} harness for newly-created member folders (default claude-code)`);
|
|
85765
|
+
out.push(` ${import_picocolors62.default.dim("--graph-only")} for push: only update members + edges, skip per-member push`, ` ${import_picocolors62.default.dim("--force")} for push: settle every conflict in your file's favour — deletes cloud schedule`, ` and webhook triggers this folder has never seen, and overwrites cloud-side edits to`, ` name, description, icon, icon_color and credit_limit`);
|
|
85766
|
+
out.push(` ${import_picocolors62.default.dim("--org <id>")} for create/list/from-agent: org id or slug (CLI vocab — DB teams.id)`);
|
|
85767
|
+
out.push(` ${import_picocolors62.default.dim("--team <id>")} for create/list/from-agent: team id (CLI vocab — DB groups.id)`);
|
|
85246
85768
|
out.push("");
|
|
85247
85769
|
console.log(out.join(`
|
|
85248
85770
|
`));
|
|
@@ -85287,11 +85809,11 @@ async function runRun(cwd2, args) {
|
|
|
85287
85809
|
}
|
|
85288
85810
|
|
|
85289
85811
|
// src/cli/publish.ts
|
|
85290
|
-
var
|
|
85812
|
+
var import_picocolors63 = __toESM(require_picocolors(), 1);
|
|
85291
85813
|
function runPublish() {
|
|
85292
85814
|
banner("publish — moved");
|
|
85293
|
-
f2.error(`${
|
|
85294
|
-
f2.info(`Use ${
|
|
85815
|
+
f2.error(`${import_picocolors63.default.bold("brainbase publish")} does not exist.`);
|
|
85816
|
+
f2.info(`Use ${import_picocolors63.default.cyan("brainbase agent push")} to send your local changes to the cloud.`);
|
|
85295
85817
|
process.exit(1);
|
|
85296
85818
|
}
|
|
85297
85819
|
|
|
@@ -85582,7 +86104,7 @@ async function runStatus(cwd2) {
|
|
|
85582
86104
|
}
|
|
85583
86105
|
|
|
85584
86106
|
// src/cli/token.ts
|
|
85585
|
-
var
|
|
86107
|
+
var import_picocolors64 = __toESM(require_picocolors(), 1);
|
|
85586
86108
|
|
|
85587
86109
|
// src/ui/ink/TokenCards.tsx
|
|
85588
86110
|
var jsx_dev_runtime17 = __toESM(require_jsx_dev_runtime(), 1);
|
|
@@ -85830,7 +86352,7 @@ async function showTokenListCard(props) {
|
|
|
85830
86352
|
|
|
85831
86353
|
// src/cli/token.ts
|
|
85832
86354
|
var DEFAULT_SCOPES = ["read", "publish"];
|
|
85833
|
-
var
|
|
86355
|
+
var MAX_NAME_LENGTH2 = 128;
|
|
85834
86356
|
var ALLOWED_SCOPES = ["read", "publish", "admin"];
|
|
85835
86357
|
function isAllowedScope(value2) {
|
|
85836
86358
|
return ALLOWED_SCOPES.includes(value2);
|
|
@@ -85973,8 +86495,8 @@ async function runTokenRename(args) {
|
|
|
85973
86495
|
const candidate = value2.trim();
|
|
85974
86496
|
if (!candidate)
|
|
85975
86497
|
return "Required.";
|
|
85976
|
-
if (candidate.length >
|
|
85977
|
-
return `Too long — keep the label to ${
|
|
86498
|
+
if (candidate.length > MAX_NAME_LENGTH2) {
|
|
86499
|
+
return `Too long — keep the label to ${MAX_NAME_LENGTH2} characters or fewer.`;
|
|
85978
86500
|
}
|
|
85979
86501
|
const clash = takenBy.get(candidate.toLowerCase());
|
|
85980
86502
|
if (clash) {
|
|
@@ -85999,7 +86521,7 @@ async function runTokenRename(args) {
|
|
|
85999
86521
|
}
|
|
86000
86522
|
}
|
|
86001
86523
|
if (name === target.name.trim()) {
|
|
86002
|
-
console.log(`${sym.ok} ${
|
|
86524
|
+
console.log(`${sym.ok} ${import_picocolors64.default.bold(target.name.trim())} already has that label; nothing to do.`);
|
|
86003
86525
|
return;
|
|
86004
86526
|
}
|
|
86005
86527
|
try {
|
|
@@ -86007,7 +86529,7 @@ async function runTokenRename(args) {
|
|
|
86007
86529
|
} catch (error2) {
|
|
86008
86530
|
throw withLoginHint(error2);
|
|
86009
86531
|
}
|
|
86010
|
-
console.log(`${sym.ok} Renamed ${
|
|
86532
|
+
console.log(`${sym.ok} Renamed ${import_picocolors64.default.dim(target.name)} → ${import_picocolors64.default.bold(name)}`);
|
|
86011
86533
|
}
|
|
86012
86534
|
async function runTokenRevoke(args) {
|
|
86013
86535
|
if (!args.id) {
|
|
@@ -86025,7 +86547,7 @@ async function runTokenRevoke(args) {
|
|
|
86025
86547
|
throw new Error(`No token with id ${args.id}. Run \`brainbase token list\` to see yours.`);
|
|
86026
86548
|
}
|
|
86027
86549
|
if (target.revoked_at) {
|
|
86028
|
-
reconcileDeadToken(target, `${
|
|
86550
|
+
reconcileDeadToken(target, `${import_picocolors64.default.bold(target.name)} is already revoked.`);
|
|
86029
86551
|
return;
|
|
86030
86552
|
}
|
|
86031
86553
|
const stored = readToken();
|
|
@@ -86035,7 +86557,7 @@ async function runTokenRevoke(args) {
|
|
|
86035
86557
|
flagHint: "Pass --yes to revoke it without a prompt."
|
|
86036
86558
|
})) {
|
|
86037
86559
|
const ok = await se({
|
|
86038
|
-
message: isLocalToken ? `Revoke ${
|
|
86560
|
+
message: isLocalToken ? `Revoke ${import_picocolors64.default.bold(target.name)} (${args.id})? This is the token this CLI is using, so it will stop working here too.` : `Revoke ${import_picocolors64.default.bold(target.name)} (${args.id})? CIs and machines using it will stop working.`,
|
|
86039
86561
|
initialValue: false
|
|
86040
86562
|
});
|
|
86041
86563
|
if (!ensureNotCancelled(ok))
|
|
@@ -86046,14 +86568,14 @@ async function runTokenRevoke(args) {
|
|
|
86046
86568
|
} catch (error2) {
|
|
86047
86569
|
if (error2 instanceof ApiError && error2.status === 404) {
|
|
86048
86570
|
if (isExpired2(target)) {
|
|
86049
|
-
reconcileDeadToken(target, `${
|
|
86571
|
+
reconcileDeadToken(target, `${import_picocolors64.default.bold(target.name)} had already expired.`);
|
|
86050
86572
|
return;
|
|
86051
86573
|
}
|
|
86052
86574
|
throw new Error(`The server reported no active token with id ${args.id}, but it listed one a moment ago. ` + "The local token has been left alone, since that key may still work. " + "If this server predates `DELETE /v1/registry/cli-tokens/{id}`, revoke from the web app instead.");
|
|
86053
86575
|
}
|
|
86054
86576
|
throw withLoginHint(error2);
|
|
86055
86577
|
}
|
|
86056
|
-
reconcileDeadToken(target, `Revoked ${
|
|
86578
|
+
reconcileDeadToken(target, `Revoked ${import_picocolors64.default.bold(target.name)}.`);
|
|
86057
86579
|
}
|
|
86058
86580
|
function reconcileDeadToken(target, headline) {
|
|
86059
86581
|
let outcome;
|
|
@@ -86087,7 +86609,7 @@ function reportLocalToken(headline, outcome) {
|
|
|
86087
86609
|
}
|
|
86088
86610
|
async function runTokenClear() {
|
|
86089
86611
|
if (!readToken()) {
|
|
86090
|
-
console.log(
|
|
86612
|
+
console.log(import_picocolors64.default.dim("No local token stored."));
|
|
86091
86613
|
return;
|
|
86092
86614
|
}
|
|
86093
86615
|
clearToken();
|
|
@@ -86187,31 +86709,31 @@ async function runToken(sub, rest2, args) {
|
|
|
86187
86709
|
function printTokenHelp() {
|
|
86188
86710
|
const out = [];
|
|
86189
86711
|
out.push("");
|
|
86190
|
-
out.push(` ${
|
|
86712
|
+
out.push(` ${import_picocolors64.default.bold("brainbase token")} ${import_picocolors64.default.dim("<command>")}`);
|
|
86191
86713
|
out.push("");
|
|
86192
|
-
out.push(` ${
|
|
86193
|
-
out.push(` ${
|
|
86194
|
-
out.push(` ${
|
|
86195
|
-
out.push(` ${
|
|
86196
|
-
out.push(` ${
|
|
86714
|
+
out.push(` ${import_picocolors64.default.cyan("create")} ${import_picocolors64.default.dim("issue a new long-lived CLI key (PAT)")}`);
|
|
86715
|
+
out.push(` ${import_picocolors64.default.cyan("list")} ${import_picocolors64.default.dim("show your tokens")}`);
|
|
86716
|
+
out.push(` ${import_picocolors64.default.cyan("rename")} ${import_picocolors64.default.dim("<id>")} ${import_picocolors64.default.dim("relabel a token by id")}`);
|
|
86717
|
+
out.push(` ${import_picocolors64.default.cyan("revoke")} ${import_picocolors64.default.dim("<id>")} ${import_picocolors64.default.dim("revoke a token by id")}`);
|
|
86718
|
+
out.push(` ${import_picocolors64.default.cyan("clear")} ${import_picocolors64.default.dim("forget the local token (does not revoke)")}`);
|
|
86197
86719
|
out.push("");
|
|
86198
|
-
out.push(` ${
|
|
86199
|
-
out.push(` ${
|
|
86200
|
-
out.push(` ${
|
|
86201
|
-
out.push(` ${
|
|
86720
|
+
out.push(` ${import_picocolors64.default.bold("create flags")}`);
|
|
86721
|
+
out.push(` ${import_picocolors64.default.cyan("--name, -n")} ${import_picocolors64.default.dim("<label>")} ${import_picocolors64.default.dim("token label (prompted if omitted)")}`);
|
|
86722
|
+
out.push(` ${import_picocolors64.default.cyan("--scopes")} ${import_picocolors64.default.dim("<list>")} ${import_picocolors64.default.dim("comma-separated; allowed: read, publish, admin")}`);
|
|
86723
|
+
out.push(` ${import_picocolors64.default.dim("default: read,publish")}`);
|
|
86202
86724
|
out.push("");
|
|
86203
|
-
out.push(` ${
|
|
86204
|
-
out.push(` ${
|
|
86725
|
+
out.push(` ${import_picocolors64.default.bold("rename flags")}`);
|
|
86726
|
+
out.push(` ${import_picocolors64.default.cyan("--name, -n")} ${import_picocolors64.default.dim("<label>")} ${import_picocolors64.default.dim("new label (prompted if omitted)")}`);
|
|
86205
86727
|
out.push("");
|
|
86206
86728
|
console.log(out.join(`
|
|
86207
86729
|
`));
|
|
86208
86730
|
}
|
|
86209
86731
|
|
|
86210
86732
|
// src/cli/integrations.ts
|
|
86211
|
-
var
|
|
86733
|
+
var import_picocolors66 = __toESM(require_picocolors(), 1);
|
|
86212
86734
|
|
|
86213
86735
|
// src/cli/integration-context.ts
|
|
86214
|
-
var
|
|
86736
|
+
var import_picocolors65 = __toESM(require_picocolors(), 1);
|
|
86215
86737
|
|
|
86216
86738
|
// src/core/integration-contexts-api.ts
|
|
86217
86739
|
var REQUEST_TIMEOUT_MS2 = 30000;
|
|
@@ -86360,7 +86882,7 @@ Both need your own \`brainbase login\` session and management rights on the
|
|
|
86360
86882
|
agent. BRAINBASE_TOKEN and the PAT saved by \`brainbase token create\` are refused.
|
|
86361
86883
|
`;
|
|
86362
86884
|
async function runIntegrationContext(cwd2, argv, options) {
|
|
86363
|
-
const { write: write3, fail:
|
|
86885
|
+
const { write: write3, fail: fail4 } = options;
|
|
86364
86886
|
const [action, ...rest2] = argv;
|
|
86365
86887
|
const parsed = parseContextArgs(rest2, "--application", "--max-lifetime", "--reason");
|
|
86366
86888
|
if (action === "help" || action === "--help" || action === "-h" || "help" in parsed) {
|
|
@@ -86369,36 +86891,36 @@ async function runIntegrationContext(cwd2, argv, options) {
|
|
|
86369
86891
|
}
|
|
86370
86892
|
if (action !== "create" && action !== "end") {
|
|
86371
86893
|
const problem = action ? `Unknown integrations context subcommand: ${sanitizeLabel(action)}.` : "Missing integrations context subcommand.";
|
|
86372
|
-
return
|
|
86894
|
+
return fail4(`${problem} ${CONTEXT_USAGE.split(`
|
|
86373
86895
|
`)[0]}`);
|
|
86374
86896
|
}
|
|
86375
86897
|
if ("error" in parsed)
|
|
86376
|
-
return
|
|
86898
|
+
return fail4(parsed.error);
|
|
86377
86899
|
const { values: values2, positionals } = parsed;
|
|
86378
86900
|
if (action === "create") {
|
|
86379
86901
|
if (positionals.length > 0)
|
|
86380
|
-
return
|
|
86902
|
+
return fail4(`Unexpected argument: ${sanitizeLabel(positionals[0])}. ${CREATE_USAGE}`);
|
|
86381
86903
|
if (values2.has("--reason"))
|
|
86382
|
-
return
|
|
86904
|
+
return fail4(`--reason is for \`context end\`. ${CREATE_USAGE}`);
|
|
86383
86905
|
const target = cloudTargetAgent(cwd2, options);
|
|
86384
86906
|
if (!target)
|
|
86385
|
-
return
|
|
86907
|
+
return fail4(NO_AGENT_MESSAGE);
|
|
86386
86908
|
if ("error" in target)
|
|
86387
|
-
return
|
|
86909
|
+
return fail4(target.error);
|
|
86388
86910
|
if (!UUID_PATTERN.test(target.agentId)) {
|
|
86389
|
-
return
|
|
86911
|
+
return fail4(`${sanitizeLabel(target.agentId)} is not an agent id. --agent takes the agent's UUID, as \`brainbase agent list\` shows it.`);
|
|
86390
86912
|
}
|
|
86391
86913
|
const agentId = target.agentId.toLowerCase();
|
|
86392
86914
|
const application = values2.get("--application");
|
|
86393
86915
|
if (application === undefined)
|
|
86394
|
-
return
|
|
86916
|
+
return fail4(`--application is required. ${CREATE_USAGE}`);
|
|
86395
86917
|
if (!APPLICATION_PATTERN.test(application)) {
|
|
86396
|
-
return
|
|
86918
|
+
return fail4(`--application must be 1-120 characters of lowercase letters, digits and . _ : / -, starting with a letter or digit (e.g. billing-sync); got "${sanitizeLabel(application)}".`);
|
|
86397
86919
|
}
|
|
86398
86920
|
const rawLifetime = values2.get("--max-lifetime");
|
|
86399
86921
|
const lifetime = rawLifetime === undefined ? DEFAULT_LIFETIME_S : parseMaxLifetime(rawLifetime);
|
|
86400
86922
|
if (typeof lifetime !== "number")
|
|
86401
|
-
return
|
|
86923
|
+
return fail4(lifetime.error);
|
|
86402
86924
|
let created;
|
|
86403
86925
|
try {
|
|
86404
86926
|
created = await integrationContextsApi.create({
|
|
@@ -86407,7 +86929,7 @@ async function runIntegrationContext(cwd2, argv, options) {
|
|
|
86407
86929
|
max_lifetime_s: lifetime
|
|
86408
86930
|
});
|
|
86409
86931
|
} catch (err) {
|
|
86410
|
-
return
|
|
86932
|
+
return fail4(`brainbase integrations context create failed: ${message(err)}`);
|
|
86411
86933
|
}
|
|
86412
86934
|
if (options.json) {
|
|
86413
86935
|
write3(JSON.stringify(created) + `
|
|
@@ -86418,24 +86940,24 @@ async function runIntegrationContext(cwd2, argv, options) {
|
|
|
86418
86940
|
return 0;
|
|
86419
86941
|
}
|
|
86420
86942
|
if (values2.has("--application") || values2.has("--max-lifetime")) {
|
|
86421
|
-
return
|
|
86943
|
+
return fail4(`--application and --max-lifetime are for \`context create\`. ${END_USAGE}`);
|
|
86422
86944
|
}
|
|
86423
86945
|
if (positionals.length !== 1)
|
|
86424
|
-
return
|
|
86946
|
+
return fail4(END_USAGE);
|
|
86425
86947
|
const contextId = positionals[0];
|
|
86426
86948
|
if (!UUID_PATTERN.test(contextId)) {
|
|
86427
|
-
return
|
|
86949
|
+
return fail4(`${sanitizeLabel(contextId)} is not a context id. Pass the context_id \`context create\` printed.`);
|
|
86428
86950
|
}
|
|
86429
86951
|
const reason = (values2.get("--reason") ?? DEFAULT_END_REASON).trim();
|
|
86430
86952
|
const reasonLength = [...reason].length;
|
|
86431
86953
|
if (reasonLength < 1 || reasonLength > MAX_REASON_LENGTH2) {
|
|
86432
|
-
return
|
|
86954
|
+
return fail4(`--reason must be 1-${MAX_REASON_LENGTH2} characters; got ${reasonLength}.`);
|
|
86433
86955
|
}
|
|
86434
86956
|
let ended;
|
|
86435
86957
|
try {
|
|
86436
86958
|
ended = await integrationContextsApi.end(contextId.toLowerCase(), reason);
|
|
86437
86959
|
} catch (err) {
|
|
86438
|
-
return
|
|
86960
|
+
return fail4(`brainbase integrations context end failed: ${message(err)}`);
|
|
86439
86961
|
}
|
|
86440
86962
|
const id = contextId.toLowerCase();
|
|
86441
86963
|
if (options.json) {
|
|
@@ -86444,7 +86966,7 @@ async function runIntegrationContext(cwd2, argv, options) {
|
|
|
86444
86966
|
return 0;
|
|
86445
86967
|
}
|
|
86446
86968
|
const state = sanitizeLabel(ended.state);
|
|
86447
|
-
write3(state === "ended" ? `${
|
|
86969
|
+
write3(state === "ended" ? `${import_picocolors65.default.green("✓")} Ended integration context ${id}. Its renewal handle and access grants no longer work.
|
|
86448
86970
|
` : `Integration context ${id} is ${state}. Its renewal handle and access grants no longer work.
|
|
86449
86971
|
`);
|
|
86450
86972
|
return 0;
|
|
@@ -86503,19 +87025,19 @@ function parseMaxLifetime(raw) {
|
|
|
86503
87025
|
function renderCreated(created, agentId, application) {
|
|
86504
87026
|
const id = sanitizeLabel(created.context_id);
|
|
86505
87027
|
const lines = [
|
|
86506
|
-
`${
|
|
86507
|
-
` ${
|
|
87028
|
+
`${import_picocolors65.default.green("✓")} Created integration context ${id}`,
|
|
87029
|
+
` ${import_picocolors65.default.dim(`agent ${agentId} · application ${application}`)}`,
|
|
86508
87030
|
"",
|
|
86509
87031
|
" Renewal handle:",
|
|
86510
87032
|
"",
|
|
86511
87033
|
` ${sanitizeLabel(created.renewal_handle)}`,
|
|
86512
87034
|
"",
|
|
86513
|
-
|
|
87035
|
+
import_picocolors65.default.yellow(" Store it now in the SDK program's secret store: it is shown only this once, and it rotates on every renewal, so the program must save the newest handle each time."),
|
|
86514
87036
|
"",
|
|
86515
87037
|
` Handle expires ${sanitizeLabel(created.renewal_expires_at ?? "unknown")}`,
|
|
86516
|
-
` Context ends ${sanitizeLabel(created.max_expires_at ?? "unknown")} ${
|
|
87038
|
+
` Context ends ${sanitizeLabel(created.max_expires_at ?? "unknown")} ${import_picocolors65.default.dim("(its maximum lifetime)")}`,
|
|
86517
87039
|
"",
|
|
86518
|
-
|
|
87040
|
+
import_picocolors65.default.dim(` End it sooner with \`brainbase integrations context end ${id}\`.`),
|
|
86519
87041
|
""
|
|
86520
87042
|
];
|
|
86521
87043
|
return lines.join(`
|
|
@@ -86552,7 +87074,7 @@ async function runIntegrations(cwd2, sub, argv, options) {
|
|
|
86552
87074
|
const write3 = options.write ?? ((s3) => process.stdout.write(s3));
|
|
86553
87075
|
const writeErr = options.writeErr ?? ((s3) => process.stderr.write(s3));
|
|
86554
87076
|
const api4 = { ...integrationsApi, ...options.api };
|
|
86555
|
-
const
|
|
87077
|
+
const fail4 = (message2) => {
|
|
86556
87078
|
if (options.json)
|
|
86557
87079
|
write3(JSON.stringify({ error: message2 }) + `
|
|
86558
87080
|
`);
|
|
@@ -86572,7 +87094,7 @@ async function runIntegrations(cwd2, sub, argv, options) {
|
|
|
86572
87094
|
agentId: options.agentId,
|
|
86573
87095
|
resolveAgentId: options.resolveAgentId,
|
|
86574
87096
|
write: write3,
|
|
86575
|
-
fail:
|
|
87097
|
+
fail: fail4
|
|
86576
87098
|
});
|
|
86577
87099
|
}
|
|
86578
87100
|
const isHelpFlag = (s3) => s3 === "--help" || s3 === "-h";
|
|
@@ -86585,7 +87107,7 @@ async function runIntegrations(cwd2, sub, argv, options) {
|
|
|
86585
87107
|
if (!sub || !known.includes(sub) && !isEffect) {
|
|
86586
87108
|
const problem = sub ? `Unknown integrations subcommand: ${sanitizeLabel(sub)}` : "Missing integrations subcommand.";
|
|
86587
87109
|
if (options.json)
|
|
86588
|
-
return
|
|
87110
|
+
return fail4(`${problem} ${USAGE.split(`
|
|
86589
87111
|
`)[0]}`);
|
|
86590
87112
|
writeErr(`${problem}
|
|
86591
87113
|
${USAGE}`);
|
|
@@ -86593,21 +87115,21 @@ ${USAGE}`);
|
|
|
86593
87115
|
}
|
|
86594
87116
|
const arg = sub === "search" ? argv.join(" ").trim() : argv[0];
|
|
86595
87117
|
if (sub !== "list" && (!arg || arg.startsWith("-") || sub !== "search" && argv.length > 1)) {
|
|
86596
|
-
return
|
|
87118
|
+
return fail4(`Usage: brainbase integrations ${sub} <${sub === "search" ? "query" : isEffect ? "app>[.<action>" : "app"}>`);
|
|
86597
87119
|
}
|
|
86598
87120
|
if (sub === "search") {
|
|
86599
87121
|
try {
|
|
86600
87122
|
const apps = await api4.searchApps(arg);
|
|
86601
87123
|
return out({ apps }, renderSearch(apps));
|
|
86602
87124
|
} catch (err) {
|
|
86603
|
-
return
|
|
87125
|
+
return fail4(`brainbase integrations search failed: ${message2(err)}`);
|
|
86604
87126
|
}
|
|
86605
87127
|
}
|
|
86606
87128
|
const target = cloudTargetAgent(cwd2, options);
|
|
86607
87129
|
if (!target)
|
|
86608
|
-
return
|
|
87130
|
+
return fail4(NO_AGENT_MESSAGE);
|
|
86609
87131
|
if ("error" in target)
|
|
86610
|
-
return
|
|
87132
|
+
return fail4(target.error);
|
|
86611
87133
|
const { agentId } = target;
|
|
86612
87134
|
try {
|
|
86613
87135
|
switch (sub) {
|
|
@@ -86627,7 +87149,7 @@ ${USAGE}`);
|
|
|
86627
87149
|
return await setEffect(agentId, sub, arg);
|
|
86628
87150
|
}
|
|
86629
87151
|
} catch (err) {
|
|
86630
|
-
return
|
|
87152
|
+
return fail4(`brainbase integrations ${sub} failed: ${message2(err)}`);
|
|
86631
87153
|
}
|
|
86632
87154
|
async function list3(agentId2) {
|
|
86633
87155
|
const [accounts, noAuthApps, permissions] = await Promise.all([
|
|
@@ -86680,40 +87202,40 @@ ${USAGE}`);
|
|
|
86680
87202
|
if (needsAccount(app))
|
|
86681
87203
|
return await connect2(agentId2, slug, app);
|
|
86682
87204
|
const added = await api4.addNoAuthApp(agentId2, slug);
|
|
86683
|
-
return out({ app: added.appSlug, name: added.name, needs_account: false, added: true }, `${
|
|
87205
|
+
return out({ app: added.appSlug, name: added.name, needs_account: false, added: true }, `${import_picocolors66.default.green("✓")} Added ${import_picocolors66.default.bold(label2(added.name))}. It needs no account; your agent can use it on its next turn.
|
|
86684
87206
|
`);
|
|
86685
87207
|
}
|
|
86686
87208
|
async function connect2(agentId2, slug, known2) {
|
|
86687
87209
|
const app = known2 ?? await api4.getApp(slug);
|
|
86688
87210
|
const name = label2(app.name || slug);
|
|
86689
87211
|
if (!needsAccount(app)) {
|
|
86690
|
-
return
|
|
87212
|
+
return fail4(`${name} needs no account. Run brainbase integrations add ${label2(slug)} instead.`);
|
|
86691
87213
|
}
|
|
86692
87214
|
const before2 = new Set((await api4.listAccounts(agentId2)).map((a3) => a3.id));
|
|
86693
87215
|
const token = await api4.createConnectToken(agentId2);
|
|
86694
87216
|
const url2 = connectUrl(token.connect_link_url, slug);
|
|
86695
87217
|
if (!url2)
|
|
86696
|
-
return
|
|
87218
|
+
return fail4("The server returned an unusable connect link.");
|
|
86697
87219
|
if (options.json) {
|
|
86698
87220
|
write3(JSON.stringify({ app: slug, url: url2, expires_at: token.expires_at ?? null }) + `
|
|
86699
87221
|
`);
|
|
86700
87222
|
return 0;
|
|
86701
87223
|
}
|
|
86702
87224
|
const interactive = options.interactive ?? isInteractive();
|
|
86703
|
-
write3(`Open this link to connect ${
|
|
87225
|
+
write3(`Open this link to connect ${import_picocolors66.default.bold(name)}:
|
|
86704
87226
|
|
|
86705
|
-
${
|
|
87227
|
+
${import_picocolors66.default.cyan(url2)}
|
|
86706
87228
|
|
|
86707
87229
|
`);
|
|
86708
|
-
write3(
|
|
87230
|
+
write3(import_picocolors66.default.dim(`Anyone with this link can connect an account to this agent until it expires, so do not share it.
|
|
86709
87231
|
`));
|
|
86710
87232
|
if (!options.noOpen && interactive) {
|
|
86711
|
-
write3(
|
|
87233
|
+
write3(import_picocolors66.default.dim(`Opening your browser…
|
|
86712
87234
|
`));
|
|
86713
87235
|
(options.openUrl ?? openInBrowser)(url2);
|
|
86714
87236
|
}
|
|
86715
87237
|
if (options.noWait) {
|
|
86716
|
-
write3(
|
|
87238
|
+
write3(import_picocolors66.default.dim("Not waiting. Run `brainbase integrations list` to see when it is connected.\n"));
|
|
86717
87239
|
return 0;
|
|
86718
87240
|
}
|
|
86719
87241
|
const controller = new AbortController;
|
|
@@ -86746,7 +87268,7 @@ ${USAGE}`);
|
|
|
86746
87268
|
if (spinner2)
|
|
86747
87269
|
spinner2.stop(text3, ok ? 0 : 2);
|
|
86748
87270
|
else if (ok)
|
|
86749
|
-
write3(`${
|
|
87271
|
+
write3(`${import_picocolors66.default.green("✔")} ${text3}
|
|
86750
87272
|
`);
|
|
86751
87273
|
else
|
|
86752
87274
|
writeErr(`${text3}
|
|
@@ -86770,27 +87292,27 @@ ${USAGE}`);
|
|
|
86770
87292
|
async function disconnect2(agentId2, slug) {
|
|
86771
87293
|
const accounts = (await api4.listAccounts(agentId2)).filter((a3) => isCredentialed(a3) && a3.app?.nameSlug === slug);
|
|
86772
87294
|
if (accounts.length === 0)
|
|
86773
|
-
return
|
|
87295
|
+
return fail4(`No connected ${label2(slug)} account on this agent.`);
|
|
86774
87296
|
let account = accounts[0];
|
|
86775
87297
|
if (options.account !== undefined) {
|
|
86776
87298
|
const chosen = accounts.find((a3) => a3.id === options.account);
|
|
86777
87299
|
if (!chosen)
|
|
86778
|
-
return
|
|
87300
|
+
return fail4(`${label2(options.account)} is not a ${label2(slug)} account on this agent. Its accounts: ${describeAccounts(accounts)}.`);
|
|
86779
87301
|
account = chosen;
|
|
86780
87302
|
} else if (accounts.length > 1) {
|
|
86781
|
-
return
|
|
87303
|
+
return fail4(`This agent has ${accounts.length} ${label2(slug)} accounts. Pick one with --account <id>: ${describeAccounts(accounts)}.`);
|
|
86782
87304
|
}
|
|
86783
87305
|
if (options.json && !options.yes) {
|
|
86784
|
-
return
|
|
87306
|
+
return fail4("`brainbase integrations disconnect --json` never prompts. Pass --yes to disconnect without one.");
|
|
86785
87307
|
}
|
|
86786
87308
|
const confirm = options.confirmDisconnect ?? promptForDisconnect;
|
|
86787
87309
|
const accountLabel = account.name ? `${label2(account.name)} (${account.id})` : account.id;
|
|
86788
87310
|
if (!await confirm(`Disconnect ${label2(slug)} account ${accountLabel}? Everyone using this agent loses it.`, options.yes)) {
|
|
86789
|
-
return out({ app: slug, account_id: account.id, disconnected: false, outcome: "declined" }, ` ${
|
|
87311
|
+
return out({ app: slug, account_id: account.id, disconnected: false, outcome: "declined" }, ` ${import_picocolors66.default.dim("Left alone.")}
|
|
86790
87312
|
`);
|
|
86791
87313
|
}
|
|
86792
87314
|
await api4.deleteAccount(agentId2, account.id);
|
|
86793
|
-
return out({ app: slug, account_id: account.id, disconnected: true }, `${
|
|
87315
|
+
return out({ app: slug, account_id: account.id, disconnected: true }, `${import_picocolors66.default.green("✓")} Disconnected ${import_picocolors66.default.bold(label2(slug))} account ${accountLabel}.
|
|
86794
87316
|
`);
|
|
86795
87317
|
}
|
|
86796
87318
|
async function remove2(agentId2, slug) {
|
|
@@ -86798,25 +87320,25 @@ ${USAGE}`);
|
|
|
86798
87320
|
if (!installed.some((a3) => a3.appSlug === slug)) {
|
|
86799
87321
|
const accounts = await api4.listAccounts(agentId2);
|
|
86800
87322
|
if (accounts.some((a3) => isCredentialed(a3) && a3.app?.nameSlug === slug)) {
|
|
86801
|
-
return
|
|
87323
|
+
return fail4(`${label2(slug)} is connected with an account. Run brainbase integrations disconnect ${label2(slug)} instead.`);
|
|
86802
87324
|
}
|
|
86803
|
-
return
|
|
87325
|
+
return fail4(`${label2(slug)} is not installed on this agent.`);
|
|
86804
87326
|
}
|
|
86805
87327
|
await api4.removeNoAuthApp(agentId2, slug);
|
|
86806
|
-
return out({ app: slug, removed: true }, `${
|
|
87328
|
+
return out({ app: slug, removed: true }, `${import_picocolors66.default.green("✓")} Removed ${import_picocolors66.default.bold(label2(slug))}.
|
|
86807
87329
|
`);
|
|
86808
87330
|
}
|
|
86809
87331
|
async function setEffect(agentId2, effect, raw) {
|
|
86810
87332
|
const [app, action] = raw.split(/\.(.*)/s, 2);
|
|
86811
87333
|
if (!app || action === "")
|
|
86812
|
-
return
|
|
87334
|
+
return fail4(`Usage: brainbase integrations ${effect} <app>[.<action>]`);
|
|
86813
87335
|
if (!permissionToken(app) || action !== undefined && !permissionToken(action)) {
|
|
86814
|
-
return
|
|
87336
|
+
return fail4(`${label2(raw)} is not an app or action name. Use the key \`brainbase integrations actions <app>\` shows.`);
|
|
86815
87337
|
}
|
|
86816
87338
|
const capability = pattern(appSlug(app), action);
|
|
86817
87339
|
await api4.setPermission(agentId2, capability, effect);
|
|
86818
87340
|
const scope = action ? `${label2(action)} on ${label2(app)}` : `every ${label2(app)} action without its own rule`;
|
|
86819
|
-
return out({ capability_pattern: capability, effect }, `${
|
|
87341
|
+
return out({ capability_pattern: capability, effect }, `${import_picocolors66.default.green("✓")} ${capability} → ${import_picocolors66.default.bold(effect)} ${import_picocolors66.default.dim(`(${scope})`)}
|
|
86820
87342
|
`);
|
|
86821
87343
|
}
|
|
86822
87344
|
}
|
|
@@ -86869,27 +87391,27 @@ async function promptForDisconnect(question, yes) {
|
|
|
86869
87391
|
return ensureNotCancelled(answer);
|
|
86870
87392
|
}
|
|
86871
87393
|
var EFFECT_COLOR = {
|
|
86872
|
-
allow:
|
|
86873
|
-
ask:
|
|
86874
|
-
deny:
|
|
87394
|
+
allow: import_picocolors66.default.green,
|
|
87395
|
+
ask: import_picocolors66.default.yellow,
|
|
87396
|
+
deny: import_picocolors66.default.red
|
|
86875
87397
|
};
|
|
86876
87398
|
function effectLabel(effect, width = 0) {
|
|
86877
|
-
return (EFFECT_COLOR[effect] ??
|
|
87399
|
+
return (EFFECT_COLOR[effect] ?? import_picocolors66.default.dim)(sanitizeLabel(effect).padEnd(width));
|
|
86878
87400
|
}
|
|
86879
87401
|
function renderList(rows, permissions) {
|
|
86880
87402
|
const lines = [""];
|
|
86881
87403
|
if (!permissions.permissionsAvailable) {
|
|
86882
|
-
lines.push(
|
|
87404
|
+
lines.push(import_picocolors66.default.yellow(" Integrations only work on Kafka agents for now; this agent cannot use them."), "");
|
|
86883
87405
|
}
|
|
86884
87406
|
if (rows.length === 0) {
|
|
86885
|
-
lines.push(
|
|
86886
|
-
lines.push(
|
|
87407
|
+
lines.push(import_picocolors66.default.dim(" No integrations on this agent."));
|
|
87408
|
+
lines.push(import_picocolors66.default.dim(" Find one with `brainbase integrations search <query>`, then `brainbase integrations add <app>`."), "");
|
|
86887
87409
|
return lines.join(`
|
|
86888
87410
|
`);
|
|
86889
87411
|
}
|
|
86890
87412
|
for (const row of rows) {
|
|
86891
87413
|
const healthy = row.accounts.every((a3) => a3.healthy);
|
|
86892
|
-
const mark = healthy ?
|
|
87414
|
+
const mark = healthy ? import_picocolors66.default.green("✓") : import_picocolors66.default.yellow("!");
|
|
86893
87415
|
const bits = [sanitizeLabel(row.name)];
|
|
86894
87416
|
if (!row.needs_account)
|
|
86895
87417
|
bits.push("no account needed");
|
|
@@ -86897,35 +87419,35 @@ function renderList(rows, permissions) {
|
|
|
86897
87419
|
bits.push(`account ${account.name ? sanitizeLabel(account.name) : account.id}${account.healthy ? "" : " (needs reconnecting)"}`);
|
|
86898
87420
|
}
|
|
86899
87421
|
const effect = row.effect ?? permissions.defaultEffect;
|
|
86900
|
-
lines.push(` ${mark} ${
|
|
87422
|
+
lines.push(` ${mark} ${import_picocolors66.default.bold(sanitizeLabel(row.app))} ${import_picocolors66.default.dim(bits.join(" · "))} ${effectLabel(effect)}${row.effect ? "" : import_picocolors66.default.dim(" (default)")}`);
|
|
86901
87423
|
}
|
|
86902
|
-
lines.push("",
|
|
87424
|
+
lines.push("", import_picocolors66.default.dim(" Run `brainbase integrations actions <app>` to see and set per-action permissions."), "");
|
|
86903
87425
|
return lines.join(`
|
|
86904
87426
|
`);
|
|
86905
87427
|
}
|
|
86906
87428
|
function renderSearch(apps) {
|
|
86907
87429
|
if (apps.length === 0)
|
|
86908
|
-
return
|
|
87430
|
+
return import_picocolors66.default.dim("No apps match.") + `
|
|
86909
87431
|
`;
|
|
86910
87432
|
const lines = [""];
|
|
86911
87433
|
for (const app of apps) {
|
|
86912
|
-
const
|
|
86913
|
-
lines.push(` ${
|
|
87434
|
+
const hint2 = needsAccount(app) ? "" : import_picocolors66.default.dim(" no account needed");
|
|
87435
|
+
lines.push(` ${import_picocolors66.default.bold(sanitizeLabel(app.nameSlug))} ${sanitizeLabel(app.name)}${hint2}`);
|
|
86914
87436
|
}
|
|
86915
|
-
lines.push("",
|
|
87437
|
+
lines.push("", import_picocolors66.default.dim(" Add one with `brainbase integrations add <app>`."), "");
|
|
86916
87438
|
return lines.join(`
|
|
86917
87439
|
`);
|
|
86918
87440
|
}
|
|
86919
87441
|
function renderActions(slug, rows) {
|
|
86920
87442
|
if (rows.length === 0)
|
|
86921
|
-
return
|
|
87443
|
+
return import_picocolors66.default.dim(`No actions found for ${sanitizeLabel(slug)}.`) + `
|
|
86922
87444
|
`;
|
|
86923
87445
|
const lines = [""];
|
|
86924
87446
|
for (const row of rows) {
|
|
86925
|
-
const source =
|
|
86926
|
-
lines.push(` ${effectLabel(row.effect, 5)} ${source} ${
|
|
87447
|
+
const source = import_picocolors66.default.dim((row.source === "action" ? "" : `(${row.source})`).padEnd(9));
|
|
87448
|
+
lines.push(` ${effectLabel(row.effect, 5)} ${source} ${import_picocolors66.default.bold(sanitizeLabel(row.key))} ${import_picocolors66.default.dim(sanitizeLabel(row.name))}`);
|
|
86927
87449
|
}
|
|
86928
|
-
lines.push("",
|
|
87450
|
+
lines.push("", import_picocolors66.default.dim(` Change one with \`brainbase integrations allow|ask|deny ${sanitizeLabel(slug)}.<action>\`, or the whole app with \`… ${sanitizeLabel(slug)}\`.`), "");
|
|
86929
87451
|
return lines.join(`
|
|
86930
87452
|
`);
|
|
86931
87453
|
}
|
|
@@ -86989,14 +87511,14 @@ async function waitForAccount(agentId, slug, before2, options) {
|
|
|
86989
87511
|
}
|
|
86990
87512
|
|
|
86991
87513
|
// src/cli/task.ts
|
|
86992
|
-
var
|
|
87514
|
+
var import_picocolors72 = __toESM(require_picocolors(), 1);
|
|
86993
87515
|
|
|
86994
87516
|
// src/cli/task-create.ts
|
|
86995
|
-
var
|
|
87517
|
+
var import_picocolors68 = __toESM(require_picocolors(), 1);
|
|
86996
87518
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
86997
87519
|
|
|
86998
87520
|
// src/cli/task-update.ts
|
|
86999
|
-
var
|
|
87521
|
+
var import_picocolors67 = __toESM(require_picocolors(), 1);
|
|
87000
87522
|
var TASK_UPDATE_USAGE = "brainbase task update <task-id> [--title <text> | --clear-title] [--metadata key=value]... [--unset-metadata <key>]... [--clear-metadata] [--model <id> | --clear-model] [--json]";
|
|
87001
87523
|
var TITLE_MAX = 200;
|
|
87002
87524
|
var MODEL_UNSUPPORTED = "This control plane does not support changing a task's model yet.";
|
|
@@ -87135,25 +87657,25 @@ function applyLabelEdit(current, edit) {
|
|
|
87135
87657
|
}
|
|
87136
87658
|
function format(task) {
|
|
87137
87659
|
const lines = [""];
|
|
87138
|
-
const title = task.title?.trim() ? sanitizeLabel(task.title) :
|
|
87139
|
-
lines.push(` ${
|
|
87660
|
+
const title = task.title?.trim() ? sanitizeLabel(task.title) : import_picocolors67.default.dim("(untitled)");
|
|
87661
|
+
lines.push(` ${import_picocolors67.default.green("updated")} ${import_picocolors67.default.bold(title)}`);
|
|
87140
87662
|
lines.push("");
|
|
87141
|
-
lines.push(` ${
|
|
87663
|
+
lines.push(` ${import_picocolors67.default.dim("task")} ${sanitizeLabel(task.id)}`);
|
|
87142
87664
|
if (task.model !== undefined) {
|
|
87143
|
-
const model = task.model?.trim() ? sanitizeLabel(task.model) :
|
|
87144
|
-
lines.push(` ${
|
|
87665
|
+
const model = task.model?.trim() ? sanitizeLabel(task.model) : import_picocolors67.default.dim("agent default");
|
|
87666
|
+
lines.push(` ${import_picocolors67.default.dim("model")} ${model}`);
|
|
87145
87667
|
}
|
|
87146
87668
|
const metadata = Object.entries(task.metadata ?? {});
|
|
87147
87669
|
lines.push("");
|
|
87148
|
-
lines.push(` ${
|
|
87670
|
+
lines.push(` ${import_picocolors67.default.bold(import_picocolors67.default.dim("METADATA"))}`);
|
|
87149
87671
|
if (metadata.length === 0) {
|
|
87150
|
-
lines.push(` ${
|
|
87672
|
+
lines.push(` ${import_picocolors67.default.dim("none")}`);
|
|
87151
87673
|
}
|
|
87152
87674
|
for (const [key2, value2] of metadata) {
|
|
87153
|
-
lines.push(` ${
|
|
87675
|
+
lines.push(` ${import_picocolors67.default.dim(sanitizeLabel(key2))} ${sanitizeLabel(value2)}`);
|
|
87154
87676
|
}
|
|
87155
87677
|
lines.push("");
|
|
87156
|
-
lines.push(` ${
|
|
87678
|
+
lines.push(` ${import_picocolors67.default.dim("read it with")} ${import_picocolors67.default.cyan(`brainbase task get ${sanitizeLabel(task.id)}`)}`, "");
|
|
87157
87679
|
return lines.join(`
|
|
87158
87680
|
`);
|
|
87159
87681
|
}
|
|
@@ -87291,24 +87813,24 @@ async function waitForCreatedTask(created, options, dependencies, version2) {
|
|
|
87291
87813
|
return;
|
|
87292
87814
|
}
|
|
87293
87815
|
if (outcome.kind === "timeout") {
|
|
87294
|
-
console.log(
|
|
87816
|
+
console.log(import_picocolors68.default.yellow(`Timed out after ${options.timeoutSeconds}s with the task still ${status}.`));
|
|
87295
87817
|
return;
|
|
87296
87818
|
}
|
|
87297
87819
|
if (outcome.kind === "interrupted") {
|
|
87298
|
-
console.log(
|
|
87820
|
+
console.log(import_picocolors68.default.yellow("Interrupted. The task is still running."));
|
|
87299
87821
|
return;
|
|
87300
87822
|
}
|
|
87301
|
-
console.log(code === 0 ?
|
|
87823
|
+
console.log(code === 0 ? import_picocolors68.default.green("Task completed.") : import_picocolors68.default.red(`Task finished as ${status}.`));
|
|
87302
87824
|
} finally {
|
|
87303
87825
|
process.removeListener("SIGINT", onSigint);
|
|
87304
87826
|
}
|
|
87305
87827
|
}
|
|
87306
87828
|
|
|
87307
87829
|
// src/cli/task-get.ts
|
|
87308
|
-
var
|
|
87830
|
+
var import_picocolors70 = __toESM(require_picocolors(), 1);
|
|
87309
87831
|
|
|
87310
87832
|
// src/cli/task-list.ts
|
|
87311
|
-
var
|
|
87833
|
+
var import_picocolors69 = __toESM(require_picocolors(), 1);
|
|
87312
87834
|
|
|
87313
87835
|
// src/core/agent-names.ts
|
|
87314
87836
|
async function agentNames(ids) {
|
|
@@ -87373,29 +87895,29 @@ function labelFilter(options) {
|
|
|
87373
87895
|
function formatTaskList(tasks, names, agentId, interfaceId, labelFiltered = false) {
|
|
87374
87896
|
const lines = [""];
|
|
87375
87897
|
if (tasks.length === 0 && labelFiltered) {
|
|
87376
|
-
lines.push(` ${
|
|
87898
|
+
lines.push(` ${import_picocolors69.default.dim("No tasks carry every label given with --metadata.")}`, "");
|
|
87377
87899
|
return lines.join(`
|
|
87378
87900
|
`);
|
|
87379
87901
|
}
|
|
87380
87902
|
if (tasks.length === 0 && interfaceId) {
|
|
87381
87903
|
const id = sanitizeLabel(interfaceId);
|
|
87382
|
-
lines.push(` ${
|
|
87904
|
+
lines.push(` ${import_picocolors69.default.dim(`No build conversations for interface ${id}.`)}`, "", ` ${import_picocolors69.default.dim("start one with")} ${import_picocolors69.default.cyan(`brainbase interface build ${id} "..."`)}`, "");
|
|
87383
87905
|
return lines.join(`
|
|
87384
87906
|
`);
|
|
87385
87907
|
}
|
|
87386
87908
|
if (tasks.length === 0) {
|
|
87387
|
-
lines.push(` ${
|
|
87909
|
+
lines.push(` ${import_picocolors69.default.dim(agentId ? `No tasks for agent ${agentId}.` : "No tasks yet.")}`, "", ` ${import_picocolors69.default.dim("start one with")} ${import_picocolors69.default.cyan('brainbase task create --message "..."')}`, "");
|
|
87388
87910
|
return lines.join(`
|
|
87389
87911
|
`);
|
|
87390
87912
|
}
|
|
87391
87913
|
for (const task of tasks) {
|
|
87392
|
-
const title = sanitizeLabel(task.title ?? "").trim() ||
|
|
87393
|
-
lines.push(` ${statusLabel(task.status)} ${
|
|
87394
|
-
lines.push(` ${
|
|
87395
|
-
lines.push(` ${
|
|
87914
|
+
const title = sanitizeLabel(task.title ?? "").trim() || import_picocolors69.default.dim("(untitled)");
|
|
87915
|
+
lines.push(` ${statusLabel(task.status)} ${import_picocolors69.default.bold(title)}`);
|
|
87916
|
+
lines.push(` ${import_picocolors69.default.dim(sanitizeLabel(task.id))}`);
|
|
87917
|
+
lines.push(` ${import_picocolors69.default.dim(`agent ${agentLabel(task.agent_id, names)} · created ${sanitizeLabel(task.created_at)}`)}`);
|
|
87396
87918
|
lines.push("");
|
|
87397
87919
|
}
|
|
87398
|
-
lines.push(` ${
|
|
87920
|
+
lines.push(` ${import_picocolors69.default.dim("inspect one with")} ${import_picocolors69.default.cyan("brainbase task get <id>")}`, "");
|
|
87399
87921
|
return lines.join(`
|
|
87400
87922
|
`);
|
|
87401
87923
|
}
|
|
@@ -87403,16 +87925,16 @@ function statusLabel(status) {
|
|
|
87403
87925
|
const padded = sanitizeLabel(status).padEnd(14);
|
|
87404
87926
|
switch (status) {
|
|
87405
87927
|
case "success":
|
|
87406
|
-
return
|
|
87928
|
+
return import_picocolors69.default.green(padded);
|
|
87407
87929
|
case "fail":
|
|
87408
|
-
return
|
|
87930
|
+
return import_picocolors69.default.red(padded);
|
|
87409
87931
|
case "need_more_info":
|
|
87410
|
-
return
|
|
87932
|
+
return import_picocolors69.default.yellow(padded);
|
|
87411
87933
|
case "running":
|
|
87412
87934
|
case "initializing":
|
|
87413
|
-
return
|
|
87935
|
+
return import_picocolors69.default.cyan(padded);
|
|
87414
87936
|
default:
|
|
87415
|
-
return
|
|
87937
|
+
return import_picocolors69.default.dim(padded);
|
|
87416
87938
|
}
|
|
87417
87939
|
}
|
|
87418
87940
|
|
|
@@ -87446,60 +87968,60 @@ async function readEvalRuns(task) {
|
|
|
87446
87968
|
}
|
|
87447
87969
|
function format2(task, evals, names) {
|
|
87448
87970
|
const lines = [""];
|
|
87449
|
-
const title = sanitizeLabel(task.title ?? "").trim() ||
|
|
87971
|
+
const title = sanitizeLabel(task.title ?? "").trim() || import_picocolors70.default.dim("(untitled)");
|
|
87450
87972
|
const id = sanitizeLabel(task.id);
|
|
87451
|
-
lines.push(` ${statusLabel(task.status)} ${
|
|
87973
|
+
lines.push(` ${statusLabel(task.status)} ${import_picocolors70.default.bold(title)}`);
|
|
87452
87974
|
lines.push("");
|
|
87453
|
-
lines.push(` ${
|
|
87454
|
-
lines.push(` ${
|
|
87975
|
+
lines.push(` ${import_picocolors70.default.dim("task")} ${id}`);
|
|
87976
|
+
lines.push(` ${import_picocolors70.default.dim("agent")} ${agentLabel(task.agent_id, names)}`);
|
|
87455
87977
|
if (task.model !== undefined) {
|
|
87456
|
-
const model = task.model?.trim() ? sanitizeLabel(task.model) :
|
|
87457
|
-
lines.push(` ${
|
|
87978
|
+
const model = task.model?.trim() ? sanitizeLabel(task.model) : import_picocolors70.default.dim("agent default");
|
|
87979
|
+
lines.push(` ${import_picocolors70.default.dim("model")} ${model}`);
|
|
87458
87980
|
}
|
|
87459
|
-
lines.push(` ${
|
|
87981
|
+
lines.push(` ${import_picocolors70.default.dim("created")} ${sanitizeLabel(task.created_at)}`);
|
|
87460
87982
|
if (task.parent_task_id) {
|
|
87461
|
-
lines.push(` ${
|
|
87983
|
+
lines.push(` ${import_picocolors70.default.dim("parent")} ${sanitizeLabel(task.parent_task_id)}`);
|
|
87462
87984
|
}
|
|
87463
87985
|
if (task.machine_id) {
|
|
87464
87986
|
const size2 = task.machine_size ? ` (size ${sanitizeLabel(task.machine_size)})` : "";
|
|
87465
|
-
lines.push(` ${
|
|
87987
|
+
lines.push(` ${import_picocolors70.default.dim("machine")} ${sanitizeLabel(task.machine_id)}${size2}`);
|
|
87466
87988
|
}
|
|
87467
87989
|
if (task.sandbox_id)
|
|
87468
|
-
lines.push(` ${
|
|
87990
|
+
lines.push(` ${import_picocolors70.default.dim("sandbox")} ${sanitizeLabel(task.sandbox_id)}`);
|
|
87469
87991
|
const [failure, ...failureRest] = sanitizeLines(failureSummary(task) ?? "").filter((line2) => line2.trim());
|
|
87470
87992
|
if (failure) {
|
|
87471
87993
|
const label3 = " failure ";
|
|
87472
87994
|
lines.push("");
|
|
87473
|
-
lines.push(` ${
|
|
87995
|
+
lines.push(` ${import_picocolors70.default.red("failure")} ${failure}`);
|
|
87474
87996
|
for (const line2 of failureRest)
|
|
87475
87997
|
lines.push(`${" ".repeat(label3.length)}${line2}`);
|
|
87476
87998
|
}
|
|
87477
87999
|
const metadata = Object.entries(task.metadata ?? {});
|
|
87478
88000
|
if (metadata.length > 0) {
|
|
87479
88001
|
lines.push("");
|
|
87480
|
-
lines.push(` ${
|
|
88002
|
+
lines.push(` ${import_picocolors70.default.bold(import_picocolors70.default.dim("METADATA"))}`);
|
|
87481
88003
|
for (const [key2, value2] of metadata) {
|
|
87482
|
-
lines.push(` ${
|
|
88004
|
+
lines.push(` ${import_picocolors70.default.dim(sanitizeLabel(key2))} ${sanitizeLabel(String(value2))}`);
|
|
87483
88005
|
}
|
|
87484
88006
|
}
|
|
87485
88007
|
lines.push("");
|
|
87486
|
-
lines.push(` ${
|
|
88008
|
+
lines.push(` ${import_picocolors70.default.bold(import_picocolors70.default.dim("EVAL VERDICTS"))}`);
|
|
87487
88009
|
if (evals.unavailable) {
|
|
87488
|
-
lines.push(` ${
|
|
88010
|
+
lines.push(` ${import_picocolors70.default.dim(sanitizeLabel(evals.unavailable))}`);
|
|
87489
88011
|
} else if (evals.runs.length === 0) {
|
|
87490
|
-
lines.push(` ${
|
|
88012
|
+
lines.push(` ${import_picocolors70.default.dim("none")}`);
|
|
87491
88013
|
} else {
|
|
87492
88014
|
for (const run of evals.runs) {
|
|
87493
|
-
const verdict = run.passed === true ?
|
|
88015
|
+
const verdict = run.passed === true ? import_picocolors70.default.green("pass") : run.passed === false ? import_picocolors70.default.red("fail") : import_picocolors70.default.dim(sanitizeLabel(run.status));
|
|
87494
88016
|
lines.push(` ${verdict} ${sanitizeLabel(run.eval_slug ?? run.eval_id)}`);
|
|
87495
88017
|
for (const line2 of sanitizeLines(run.reasoning ?? "")) {
|
|
87496
88018
|
if (line2.trim())
|
|
87497
|
-
lines.push(` ${
|
|
88019
|
+
lines.push(` ${import_picocolors70.default.dim(line2)}`);
|
|
87498
88020
|
}
|
|
87499
88021
|
}
|
|
87500
88022
|
}
|
|
87501
88023
|
lines.push("");
|
|
87502
|
-
lines.push(` ${
|
|
88024
|
+
lines.push(` ${import_picocolors70.default.dim("read its transcript with")} ${import_picocolors70.default.cyan(`brainbase task logs ${id}`)}`, "");
|
|
87503
88025
|
return lines.join(`
|
|
87504
88026
|
`);
|
|
87505
88027
|
}
|
|
@@ -87516,7 +88038,7 @@ function failureSummary(task) {
|
|
|
87516
88038
|
}
|
|
87517
88039
|
|
|
87518
88040
|
// src/cli/task-logs.ts
|
|
87519
|
-
var
|
|
88041
|
+
var import_picocolors71 = __toESM(require_picocolors(), 1);
|
|
87520
88042
|
|
|
87521
88043
|
// src/core/task-events.ts
|
|
87522
88044
|
var DEFAULT_RETRY_BUDGET_MS = 60000;
|
|
@@ -87799,14 +88321,14 @@ async function runTaskLogs(taskId, options = {}, dependencies = {}) {
|
|
|
87799
88321
|
console.log(renderEvent(event, messages));
|
|
87800
88322
|
}
|
|
87801
88323
|
if (ordered.length === 0) {
|
|
87802
|
-
console.log(
|
|
88324
|
+
console.log(import_picocolors71.default.dim("No events for this task yet."));
|
|
87803
88325
|
}
|
|
87804
88326
|
}
|
|
87805
88327
|
async function followTranscript(taskId, options, dependencies) {
|
|
87806
88328
|
const backfill = options.limit === undefined ? "" : `?backfill=${options.limit}`;
|
|
87807
88329
|
const { url: url2, resolveBearer } = await masStreamTarget(`/tasks/${encodeURIComponent(taskId)}/events/stream${backfill}`);
|
|
87808
88330
|
if (!options.json) {
|
|
87809
|
-
console.log(
|
|
88331
|
+
console.log(import_picocolors71.default.dim(`Following task ${taskId} — Ctrl-C to stop.`));
|
|
87810
88332
|
}
|
|
87811
88333
|
const setExitCode = dependencies.setExitCode ?? ((code) => process.exitCode = code);
|
|
87812
88334
|
const controller = new AbortController;
|
|
@@ -87848,13 +88370,13 @@ async function followTranscript(taskId, options, dependencies) {
|
|
|
87848
88370
|
} else if (options.json) {
|
|
87849
88371
|
console.log(JSON.stringify(frame));
|
|
87850
88372
|
} else {
|
|
87851
|
-
console.log(
|
|
88373
|
+
console.log(import_picocolors71.default.dim(frame.type));
|
|
87852
88374
|
}
|
|
87853
88375
|
},
|
|
87854
88376
|
onOpen: () => settle.noteFrame(),
|
|
87855
88377
|
onReconnect: (reason) => {
|
|
87856
88378
|
settle.noteDisconnected();
|
|
87857
|
-
console.error(
|
|
88379
|
+
console.error(import_picocolors71.default.dim(`reconnecting — ${reason}`));
|
|
87858
88380
|
}
|
|
87859
88381
|
});
|
|
87860
88382
|
if (interruptCode !== undefined)
|
|
@@ -88532,78 +89054,78 @@ ${didYouMean(sub, ["create", "list", "get", "logs", "send", "stop", "update", "d
|
|
|
88532
89054
|
function printHelp5() {
|
|
88533
89055
|
const out = [];
|
|
88534
89056
|
out.push("");
|
|
88535
|
-
out.push(` ${
|
|
89057
|
+
out.push(` ${import_picocolors72.default.bold("brainbase task")} ${import_picocolors72.default.dim("<sub> [options]")}`);
|
|
88536
89058
|
out.push("");
|
|
88537
|
-
out.push(` ${
|
|
88538
|
-
out.push(` ${
|
|
88539
|
-
out.push(` ${
|
|
88540
|
-
out.push(` ${
|
|
88541
|
-
out.push(` ${
|
|
88542
|
-
out.push(` ${
|
|
88543
|
-
out.push(` ${
|
|
88544
|
-
out.push(` ${
|
|
89059
|
+
out.push(` ${import_picocolors72.default.cyan("create")} ${import_picocolors72.default.dim("--message <text>")} ${import_picocolors72.default.dim("create a task and start its first run")}`);
|
|
89060
|
+
out.push(` ${import_picocolors72.default.cyan("list | ls")} ${import_picocolors72.default.dim("recent tasks you can reach (--json for scripts)")}`);
|
|
89061
|
+
out.push(` ${import_picocolors72.default.cyan("get")} ${import_picocolors72.default.dim("<task-id>")} ${import_picocolors72.default.dim("one task: status, agent, machine, eval verdicts")}`);
|
|
89062
|
+
out.push(` ${import_picocolors72.default.cyan("logs")} ${import_picocolors72.default.dim("<task-id> [--follow]")} ${import_picocolors72.default.dim("one line per event in the task's transcript, or tail it live")}`);
|
|
89063
|
+
out.push(` ${import_picocolors72.default.cyan("send")} ${import_picocolors72.default.dim("<task-id> <message>")} ${import_picocolors72.default.dim("send a follow-up, including while the agent is running")}`);
|
|
89064
|
+
out.push(` ${import_picocolors72.default.cyan("stop")} ${import_picocolors72.default.dim("<task-id>")} ${import_picocolors72.default.dim("stop execution and cancel pending follow-ups, retaining their text")}`);
|
|
89065
|
+
out.push(` ${import_picocolors72.default.cyan("update")} ${import_picocolors72.default.dim("<task-id>")} ${import_picocolors72.default.dim("rename a task, change its metadata labels, switch its model or reset it to the agent default, including while it runs")}`);
|
|
89066
|
+
out.push(` ${import_picocolors72.default.cyan("delete")} ${import_picocolors72.default.dim("<task-id>")} ${import_picocolors72.default.dim("permanently delete a stopped task and tear down its sandbox (--yes to skip the prompt)")}`);
|
|
88545
89067
|
out.push("");
|
|
88546
|
-
out.push(` ${
|
|
88547
|
-
out.push(` ${
|
|
88548
|
-
out.push(` ${
|
|
88549
|
-
out.push(` ${
|
|
88550
|
-
out.push(` ${
|
|
88551
|
-
out.push(` ${
|
|
88552
|
-
out.push(` ${
|
|
88553
|
-
out.push(` ${
|
|
88554
|
-
out.push(` ${
|
|
88555
|
-
out.push(` ${
|
|
89068
|
+
out.push(` ${import_picocolors72.default.bold("create flags")}`);
|
|
89069
|
+
out.push(` ${import_picocolors72.default.dim("--message <text>")} required first user message`);
|
|
89070
|
+
out.push(` ${import_picocolors72.default.dim("--agent <id>")} override the claimed agent in brainbase.agent.yaml`);
|
|
89071
|
+
out.push(` ${import_picocolors72.default.dim("--interface <id>")} open it as a build conversation for this interface (agent defaults to the interface's)`);
|
|
89072
|
+
out.push(` ${import_picocolors72.default.dim("--title <text>")} optional task title`);
|
|
89073
|
+
out.push(` ${import_picocolors72.default.dim("--model <id>")} optional model override`);
|
|
89074
|
+
out.push(` ${import_picocolors72.default.dim("--version <v>")} run a saved version of the agent: 12, v12 or a version id (\`agent versions list\`)`);
|
|
89075
|
+
out.push(` ${import_picocolors72.default.dim("--metadata key=value")} label the task (repeatable)`);
|
|
89076
|
+
out.push(` ${import_picocolors72.default.dim("--wait")} block until the task finishes; exit 1 unless it succeeded`);
|
|
89077
|
+
out.push(` ${import_picocolors72.default.dim("--timeout <secs>")} give up waiting after <secs> and exit 1 (needs --wait)`);
|
|
88556
89078
|
out.push("");
|
|
88557
|
-
out.push(` ${
|
|
88558
|
-
out.push(` ${
|
|
88559
|
-
out.push(` ${
|
|
88560
|
-
out.push(` ${
|
|
88561
|
-
out.push(` ${
|
|
89079
|
+
out.push(` ${import_picocolors72.default.bold("list flags")}`);
|
|
89080
|
+
out.push(` ${import_picocolors72.default.dim("--agent <id>")} only this agent's tasks`);
|
|
89081
|
+
out.push(` ${import_picocolors72.default.dim("--interface <id>")} only this interface's build conversations (hidden from a plain list)`);
|
|
89082
|
+
out.push(` ${import_picocolors72.default.dim("--metadata key=value")} only tasks carrying this label (repeatable; all must match)`);
|
|
89083
|
+
out.push(` ${import_picocolors72.default.dim("--limit <n>")} cap the page (1-200, server default 50)`);
|
|
88562
89084
|
out.push("");
|
|
88563
|
-
out.push(` ${
|
|
88564
|
-
out.push(` ${
|
|
88565
|
-
out.push(` ${
|
|
89085
|
+
out.push(` ${import_picocolors72.default.bold("logs flags")}`);
|
|
89086
|
+
out.push(` ${import_picocolors72.default.dim("--limit <n>")} stop after <n> events instead of the whole transcript; with --follow, the first page size`);
|
|
89087
|
+
out.push(` ${import_picocolors72.default.dim("--follow, -f")} stay attached and print events as they land, until the task finishes and any queued follow-ups have run`);
|
|
88566
89088
|
out.push("");
|
|
88567
|
-
out.push(` ${
|
|
88568
|
-
out.push(` ${
|
|
88569
|
-
out.push(` ${
|
|
88570
|
-
out.push(` ${
|
|
88571
|
-
out.push(` ${
|
|
88572
|
-
out.push(` ${
|
|
88573
|
-
out.push(` ${
|
|
88574
|
-
out.push(` ${
|
|
88575
|
-
out.push(` ${
|
|
89089
|
+
out.push(` ${import_picocolors72.default.bold("update flags")}`);
|
|
89090
|
+
out.push(` ${import_picocolors72.default.dim("--title <text>")} new title`);
|
|
89091
|
+
out.push(` ${import_picocolors72.default.dim("--clear-title")} remove the title; automatic titling may name the task again on a later turn`);
|
|
89092
|
+
out.push(` ${import_picocolors72.default.dim("--metadata key=value")} set one label, keeping the others (repeatable)`);
|
|
89093
|
+
out.push(` ${import_picocolors72.default.dim("--unset-metadata <key>")} remove one label (repeatable)`);
|
|
89094
|
+
out.push(` ${import_picocolors72.default.dim(" the server applies label edits in one step, so concurrent edits from other clients are kept")}`);
|
|
89095
|
+
out.push(` ${import_picocolors72.default.dim("--clear-metadata")} remove every label; with --metadata, the labels become exactly those given`);
|
|
89096
|
+
out.push(` ${import_picocolors72.default.dim("--model <id>")} switch the model the task's next turn runs on (the running turn keeps its model)`);
|
|
89097
|
+
out.push(` ${import_picocolors72.default.dim("--clear-model")} go back to the agent's default model from the next turn`);
|
|
88576
89098
|
out.push("");
|
|
88577
|
-
out.push(` ${
|
|
88578
|
-
out.push(` ${
|
|
88579
|
-
out.push(` ${
|
|
88580
|
-
out.push(` ${
|
|
89099
|
+
out.push(` ${import_picocolors72.default.bold("send flags")}`);
|
|
89100
|
+
out.push(` ${import_picocolors72.default.dim("--input-id <uuid>")} recover the same request using its original ID and identical message`);
|
|
89101
|
+
out.push(` ${import_picocolors72.default.dim(" omit it to send a new follow-up; an unconfirmed receipt is never automatically replayed")}`);
|
|
89102
|
+
out.push(` ${import_picocolors72.default.dim(" admission disabled/recovery unavailable means no input was admitted; retry the same ID after recovery")}`);
|
|
88581
89103
|
out.push("");
|
|
88582
|
-
out.push(` ${
|
|
88583
|
-
out.push(` ${
|
|
88584
|
-
out.push(` ${
|
|
89104
|
+
out.push(` ${import_picocolors72.default.bold("send and stop flags")}`);
|
|
89105
|
+
out.push(` ${import_picocolors72.default.dim("--generation <n>")} retain the printed generation when retrying; defaults to a fresh snapshot for a new operation`);
|
|
89106
|
+
out.push(` ${import_picocolors72.default.dim(" Stop errors may follow queued-input cancellation; retry the printed command to avoid stopping newer work")}`);
|
|
88585
89107
|
out.push("");
|
|
88586
|
-
out.push(` ${
|
|
88587
|
-
out.push(` ${
|
|
88588
|
-
out.push(` ${
|
|
88589
|
-
out.push(` ${
|
|
89108
|
+
out.push(` ${import_picocolors72.default.bold("every subcommand")}`);
|
|
89109
|
+
out.push(` ${import_picocolors72.default.dim("--json")} machine-readable output — create prints task_id, agent_id and status (with --version, also agent_version_id and version_number); list, get, logs, send, stop and update print the raw records; delete prints id and deleted`);
|
|
89110
|
+
out.push(` ${import_picocolors72.default.dim(" send and stop include expected_generation for safe retries; send also reports idempotency_replayed when present")}`);
|
|
89111
|
+
out.push(` ${import_picocolors72.default.dim(" logs --follow --json prints one record per line, since a live stream has no end to close on")}`);
|
|
88590
89112
|
out.push("");
|
|
88591
|
-
out.push(` ${
|
|
88592
|
-
out.push(` ${
|
|
88593
|
-
out.push(` ${
|
|
88594
|
-
out.push(` ${
|
|
89113
|
+
out.push(` ${import_picocolors72.default.dim("Exit codes with --wait:")} ${import_picocolors72.default.dim("0 succeeded · 1 failed, needs input, or timed out · 130 interrupted")}`);
|
|
89114
|
+
out.push(` ${import_picocolors72.default.dim("Exit codes with --follow:")} ${import_picocolors72.default.dim("0 task reached a terminal state · 1 stream refused, or unreachable for 60s · 130 interrupted (Ctrl-C) · 143 terminated")}`);
|
|
89115
|
+
out.push(` ${import_picocolors72.default.dim("Exit codes with send:")} ${import_picocolors72.default.dim("0 queued, dispatching, submitted or completed · 1 unconfirmed, cancelled, failed or request error")}`);
|
|
89116
|
+
out.push(` ${import_picocolors72.default.dim("Ctrl-C while waiting or following logs detaches; use task stop to cancel remote work.")}`);
|
|
88595
89117
|
out.push("");
|
|
88596
|
-
out.push(` ${
|
|
89118
|
+
out.push(` ${import_picocolors72.default.dim("Flag-like values:")} use ${import_picocolors72.default.cyan("--flag=value")} or ${import_picocolors72.default.cyan("--flag -- <value>")}`);
|
|
88597
89119
|
out.push("");
|
|
88598
89120
|
console.log(out.join(`
|
|
88599
89121
|
`));
|
|
88600
89122
|
}
|
|
88601
89123
|
|
|
88602
89124
|
// src/cli/machine.ts
|
|
88603
|
-
var
|
|
89125
|
+
var import_picocolors75 = __toESM(require_picocolors(), 1);
|
|
88604
89126
|
|
|
88605
89127
|
// src/cli/machine-list.ts
|
|
88606
|
-
var
|
|
89128
|
+
var import_picocolors73 = __toESM(require_picocolors(), 1);
|
|
88607
89129
|
async function runMachineList(args = {}) {
|
|
88608
89130
|
if (!args.json)
|
|
88609
89131
|
banner("machine list — sandboxes you can reach");
|
|
@@ -88621,7 +89143,7 @@ async function runMachineList(args = {}) {
|
|
|
88621
89143
|
function formatMachineList(machines, includedDead, names = new Map) {
|
|
88622
89144
|
const lines = [""];
|
|
88623
89145
|
if (machines.length === 0) {
|
|
88624
|
-
lines.push(` ${
|
|
89146
|
+
lines.push(` ${import_picocolors73.default.dim(includedDead ? "No machines." : "No live machines. Pass --all to include torn-down ones.")}`, "");
|
|
88625
89147
|
return lines.join(`
|
|
88626
89148
|
`);
|
|
88627
89149
|
}
|
|
@@ -88641,7 +89163,7 @@ function formatMachineList(machines, includedDead, names = new Map) {
|
|
|
88641
89163
|
const statusWidth = width((row) => row.status);
|
|
88642
89164
|
const sizeWidth = width((row) => row.size);
|
|
88643
89165
|
const agentWidth = width((row) => row.agent);
|
|
88644
|
-
lines.push(` ${
|
|
89166
|
+
lines.push(` ${import_picocolors73.default.dim([
|
|
88645
89167
|
header.id.padEnd(idWidth),
|
|
88646
89168
|
header.kind.padEnd(kindWidth),
|
|
88647
89169
|
header.status.padEnd(statusWidth),
|
|
@@ -88657,21 +89179,21 @@ function formatMachineList(machines, includedDead, names = new Map) {
|
|
|
88657
89179
|
row.dead ? status : statusTint(row.status, status),
|
|
88658
89180
|
row.size.padEnd(sizeWidth),
|
|
88659
89181
|
row.agent.padEnd(agentWidth),
|
|
88660
|
-
|
|
89182
|
+
import_picocolors73.default.dim(row.age)
|
|
88661
89183
|
].join(" ");
|
|
88662
|
-
lines.push(` ${row.dead ?
|
|
89184
|
+
lines.push(` ${row.dead ? import_picocolors73.default.dim(cells) : cells}`);
|
|
88663
89185
|
}
|
|
88664
|
-
lines.push("", ` ${
|
|
89186
|
+
lines.push("", ` ${import_picocolors73.default.dim("tear one down with")} ${import_picocolors73.default.cyan("brainbase machine rm <id>")}`, "");
|
|
88665
89187
|
return lines.join(`
|
|
88666
89188
|
`);
|
|
88667
89189
|
}
|
|
88668
89190
|
function statusTint(status, padded) {
|
|
88669
89191
|
switch (status) {
|
|
88670
89192
|
case "running":
|
|
88671
|
-
return
|
|
89193
|
+
return import_picocolors73.default.green(padded);
|
|
88672
89194
|
case "stopped":
|
|
88673
89195
|
case "starting":
|
|
88674
|
-
return
|
|
89196
|
+
return import_picocolors73.default.yellow(padded);
|
|
88675
89197
|
default:
|
|
88676
89198
|
return padded;
|
|
88677
89199
|
}
|
|
@@ -88694,7 +89216,7 @@ function age(createdAt) {
|
|
|
88694
89216
|
}
|
|
88695
89217
|
|
|
88696
89218
|
// src/cli/machine-rm.ts
|
|
88697
|
-
var
|
|
89219
|
+
var import_picocolors74 = __toESM(require_picocolors(), 1);
|
|
88698
89220
|
async function runMachineRm(args, dependencies = {}) {
|
|
88699
89221
|
const setExitCode = dependencies.setExitCode ?? ((code) => process.exitCode = code);
|
|
88700
89222
|
const machineId = args.machineId?.trim();
|
|
@@ -88708,7 +89230,7 @@ async function runMachineRm(args, dependencies = {}) {
|
|
|
88708
89230
|
if (args.json) {
|
|
88709
89231
|
console.log(JSON.stringify({ id: machineId, torn_down: false, outcome: "declined" }, null, 2));
|
|
88710
89232
|
} else {
|
|
88711
|
-
console.log(` ${
|
|
89233
|
+
console.log(` ${import_picocolors74.default.dim("Left alone.")}`);
|
|
88712
89234
|
}
|
|
88713
89235
|
return;
|
|
88714
89236
|
}
|
|
@@ -88726,7 +89248,7 @@ async function promptForTeardown(args) {
|
|
|
88726
89248
|
return true;
|
|
88727
89249
|
if (!args.json) {
|
|
88728
89250
|
console.log(`
|
|
88729
|
-
${
|
|
89251
|
+
${import_picocolors74.default.red("This destroys the sandbox.")} ${import_picocolors74.default.dim("Anything not committed out of it is lost. The machine row is kept for cost history.")}
|
|
88730
89252
|
`);
|
|
88731
89253
|
}
|
|
88732
89254
|
const answer = await se({
|
|
@@ -88738,9 +89260,9 @@ async function promptForTeardown(args) {
|
|
|
88738
89260
|
function formatMachineRm(machine) {
|
|
88739
89261
|
const lines = [""];
|
|
88740
89262
|
if (machine.destroyed_at) {
|
|
88741
|
-
lines.push(` ${
|
|
89263
|
+
lines.push(` ${import_picocolors74.default.green("✓")} ${machine.kind} sandbox ${machine.id} is torn down.`, ` ${import_picocolors74.default.dim(`destroyed_at ${machine.destroyed_at}`)}`);
|
|
88742
89264
|
} else {
|
|
88743
|
-
lines.push(` ${
|
|
89265
|
+
lines.push(` ${import_picocolors74.default.yellow("!")} ${machine.id} came back without a teardown timestamp (status ${machine.status}).`, ` ${import_picocolors74.default.dim("Re-check with `brainbase machine ls --all` before assuming it stopped billing.")}`);
|
|
88744
89266
|
}
|
|
88745
89267
|
lines.push("");
|
|
88746
89268
|
return lines.join(`
|
|
@@ -88781,25 +89303,25 @@ ${didYouMean(sub, ["ls", "rm"], "brainbase machine")}`);
|
|
|
88781
89303
|
function printHelp6() {
|
|
88782
89304
|
const out = [];
|
|
88783
89305
|
out.push("");
|
|
88784
|
-
out.push(` ${
|
|
89306
|
+
out.push(` ${import_picocolors75.default.bold("brainbase machine")} ${import_picocolors75.default.dim("<sub> [options]")}`);
|
|
88785
89307
|
out.push("");
|
|
88786
|
-
out.push(` ${
|
|
88787
|
-
out.push(` ${
|
|
89308
|
+
out.push(` ${import_picocolors75.default.cyan("ls")} ${import_picocolors75.default.dim("list your sandboxes — live ones only unless --all")}`);
|
|
89309
|
+
out.push(` ${import_picocolors75.default.cyan("rm")} ${import_picocolors75.default.dim("<id>")} ${import_picocolors75.default.dim("tear a sandbox down (terminal; the row is kept for cost history)")}`);
|
|
88788
89310
|
out.push("");
|
|
88789
|
-
out.push(` ${
|
|
88790
|
-
out.push(` ${
|
|
88791
|
-
out.push(` ${
|
|
88792
|
-
out.push(` ${
|
|
89311
|
+
out.push(` ${import_picocolors75.default.dim("--all")} ${import_picocolors75.default.dim("for ls: include machines already torn down")}`);
|
|
89312
|
+
out.push(` ${import_picocolors75.default.dim("--limit <n>")} ${import_picocolors75.default.dim("for ls: how many to fetch (1-200, default 50)")}`);
|
|
89313
|
+
out.push(` ${import_picocolors75.default.dim("--yes, -y")} ${import_picocolors75.default.dim("for rm: skip the confirmation")}`);
|
|
89314
|
+
out.push(` ${import_picocolors75.default.dim("--json")} ${import_picocolors75.default.dim("machine-readable output")}`);
|
|
88793
89315
|
out.push("");
|
|
88794
89316
|
console.log(out.join(`
|
|
88795
89317
|
`));
|
|
88796
89318
|
}
|
|
88797
89319
|
|
|
88798
89320
|
// src/cli/interface.ts
|
|
88799
|
-
var
|
|
89321
|
+
var import_picocolors81 = __toESM(require_picocolors(), 1);
|
|
88800
89322
|
|
|
88801
89323
|
// src/cli/interface-build.ts
|
|
88802
|
-
var
|
|
89324
|
+
var import_picocolors76 = __toESM(require_picocolors(), 1);
|
|
88803
89325
|
var USAGE2 = 'brainbase interface build <id> "<request>" [--timeout <seconds>] [--idempotency-key <key>] [--json]';
|
|
88804
89326
|
var SETTLE_TIMEOUT_MS = 120000;
|
|
88805
89327
|
async function reportingErrors(json3, work) {
|
|
@@ -88898,28 +89420,28 @@ function buildExitCode(outcome) {
|
|
|
88898
89420
|
function reportBuild(say, interfaceId, outcome, timeoutSeconds) {
|
|
88899
89421
|
switch (outcome.kind) {
|
|
88900
89422
|
case "built":
|
|
88901
|
-
say(` ${
|
|
89423
|
+
say(` ${import_picocolors76.default.dim("build")} ${safe(outcome.build.id)} ${import_picocolors76.default.green("succeeded")}`);
|
|
88902
89424
|
say("");
|
|
88903
|
-
say(` ${
|
|
89425
|
+
say(` ${import_picocolors76.default.dim("Next:")} ${import_picocolors76.default.cyan(`brainbase interface publish ${safe(interfaceId)}`)}`);
|
|
88904
89426
|
return;
|
|
88905
89427
|
case "failed": {
|
|
88906
89428
|
const reason = outcome.build?.error_summary ?? outcome.operation?.error ?? outcome.operation?.reason ?? null;
|
|
88907
|
-
say(` ${
|
|
89429
|
+
say(` ${import_picocolors76.default.dim("build")} ${outcome.build ? safe(outcome.build.id) : import_picocolors76.default.dim("none")} ${import_picocolors76.default.red("failed")}`);
|
|
88908
89430
|
if (reason)
|
|
88909
89431
|
say(` ${safeBlock(reason).split(`
|
|
88910
89432
|
`).join(`
|
|
88911
89433
|
`)}`);
|
|
88912
|
-
say(` ${
|
|
89434
|
+
say(` ${import_picocolors76.default.dim("Try again with")} ${import_picocolors76.default.cyan(`brainbase interface rebuild ${safe(interfaceId)}`)}`);
|
|
88913
89435
|
return;
|
|
88914
89436
|
}
|
|
88915
89437
|
case "busy":
|
|
88916
|
-
say(` ${
|
|
89438
|
+
say(` ${import_picocolors76.default.yellow(safe(outcome.message))}`);
|
|
88917
89439
|
return;
|
|
88918
89440
|
case "timeout":
|
|
88919
|
-
say(` ${
|
|
89441
|
+
say(` ${import_picocolors76.default.yellow(`Still building after ${timeoutSeconds}s.`)} ${import_picocolors76.default.dim(`It keeps going; check \`brainbase interface builds ${safe(interfaceId)}\`.`)}`);
|
|
88920
89442
|
return;
|
|
88921
89443
|
case "interrupted":
|
|
88922
|
-
say(` ${
|
|
89444
|
+
say(` ${import_picocolors76.default.yellow("Stopped waiting.")} ${import_picocolors76.default.dim(`The build keeps going; check \`brainbase interface builds ${safe(interfaceId)}\`.`)}`);
|
|
88923
89445
|
return;
|
|
88924
89446
|
default: {
|
|
88925
89447
|
const unreachable = outcome;
|
|
@@ -88966,8 +89488,8 @@ async function build(ctx) {
|
|
|
88966
89488
|
throw held;
|
|
88967
89489
|
}
|
|
88968
89490
|
const reattach = `brainbase task logs ${safe(taskId)} --follow`;
|
|
88969
|
-
say(` ${
|
|
88970
|
-
say(` ${
|
|
89491
|
+
say(` ${import_picocolors76.default.dim("Build conversation")} ${import_picocolors76.default.bold(safe(taskId))} ${import_picocolors76.default.dim(`on ${safe(before2.name)}`)}`);
|
|
89492
|
+
say(` ${import_picocolors76.default.dim(`If this stops early, reattach with \`${reattach}\`.`)}`);
|
|
88971
89493
|
const finish = (result2, exitCode) => {
|
|
88972
89494
|
if (json3)
|
|
88973
89495
|
console.log(JSON.stringify({ type: "result", task_id: taskId, ...result2 }));
|
|
@@ -88984,13 +89506,13 @@ async function build(ctx) {
|
|
|
88984
89506
|
});
|
|
88985
89507
|
} catch (error2) {
|
|
88986
89508
|
say("");
|
|
88987
|
-
say(` ${
|
|
88988
|
-
say(` ${
|
|
89509
|
+
say(` ${import_picocolors76.default.red(`Lost the conversation's event stream: ${safe(error2.message)}`)}`);
|
|
89510
|
+
say(` ${import_picocolors76.default.dim(`Conversation ${safe(taskId)} may still be running. Reattach with`)} ${import_picocolors76.default.cyan(reattach)}`);
|
|
88989
89511
|
finish({ version_id: null, build_id: null, status: "stream_lost", task_status: null }, 1);
|
|
88990
89512
|
return;
|
|
88991
89513
|
}
|
|
88992
89514
|
if (followExit !== undefined) {
|
|
88993
|
-
say(` ${
|
|
89515
|
+
say(` ${import_picocolors76.default.yellow("Stopped following.")} ${import_picocolors76.default.dim(`The conversation keeps running. Reattach with \`${reattach}\`.`)}`);
|
|
88994
89516
|
finish({ version_id: null, build_id: null, status: "interrupted", task_status: null }, followExit);
|
|
88995
89517
|
return;
|
|
88996
89518
|
}
|
|
@@ -89005,7 +89527,7 @@ async function build(ctx) {
|
|
|
89005
89527
|
if (settled.kind !== "terminal") {
|
|
89006
89528
|
const interrupted = settled.kind === "interrupted";
|
|
89007
89529
|
const status2 = settled.task?.status ?? null;
|
|
89008
|
-
say(` ${
|
|
89530
|
+
say(` ${import_picocolors76.default.yellow(interrupted ? "Stopped." : `The conversation is still ${safe(status2 ?? "running")}.`)} ${import_picocolors76.default.dim(`Check it with \`brainbase task get ${safe(taskId)}\`.`)}`);
|
|
89009
89531
|
finish({ version_id: null, build_id: null, status: interrupted ? "interrupted" : "task_unsettled", task_status: status2 }, interrupted ? SIGINT_EXIT_CODE : 1);
|
|
89010
89532
|
return;
|
|
89011
89533
|
}
|
|
@@ -89025,36 +89547,36 @@ async function build(ctx) {
|
|
|
89025
89547
|
}
|
|
89026
89548
|
const codes = [exitCodeForTaskStatus(task.status)];
|
|
89027
89549
|
say("");
|
|
89028
|
-
say(` ${
|
|
89550
|
+
say(` ${import_picocolors76.default.dim("conversation")} ${safe(taskId)} ${import_picocolors76.default.dim("ended")} ${safe(task.status)}`);
|
|
89029
89551
|
if (mine?.status === "failed") {
|
|
89030
89552
|
codes.push(1);
|
|
89031
89553
|
const why = [mine.reason, mine.error].filter(Boolean).map((part) => safe(part)).join(": ");
|
|
89032
|
-
say(` ${
|
|
89554
|
+
say(` ${import_picocolors76.default.red(`This conversation's build work failed${why ? ` (${why})` : ""}.`)}`);
|
|
89033
89555
|
} else if (task.status !== "success" && task.status !== "need_more_info") {
|
|
89034
|
-
say(` ${
|
|
89556
|
+
say(` ${import_picocolors76.default.red(`The conversation finished as ${safe(task.status)}.`)} ${import_picocolors76.default.dim(`See \`brainbase task logs ${safe(taskId)}\`.`)}`);
|
|
89035
89557
|
}
|
|
89036
89558
|
if (task.status === "need_more_info") {
|
|
89037
89559
|
const question = await lastAgentMessage(taskId);
|
|
89038
89560
|
say("");
|
|
89039
89561
|
if (question) {
|
|
89040
|
-
say(` ${
|
|
89562
|
+
say(` ${import_picocolors76.default.bold("The agent asks:")}`);
|
|
89041
89563
|
say(` ${safeBlock(question).split(`
|
|
89042
89564
|
`).join(`
|
|
89043
89565
|
`)}`);
|
|
89044
89566
|
} else {
|
|
89045
|
-
say(` ${
|
|
89567
|
+
say(` ${import_picocolors76.default.bold("The agent needs more from you before it can go on.")}`);
|
|
89046
89568
|
}
|
|
89047
89569
|
say("");
|
|
89048
|
-
say(` ${
|
|
89049
|
-
say(` ${
|
|
89570
|
+
say(` ${import_picocolors76.default.dim("Reply with")} ${import_picocolors76.default.cyan(`brainbase task send ${safe(taskId)} "<reply>"`)}`);
|
|
89571
|
+
say(` ${import_picocolors76.default.dim("then follow it with")} ${import_picocolors76.default.cyan(reattach)}`);
|
|
89050
89572
|
}
|
|
89051
89573
|
let status;
|
|
89052
89574
|
let buildId = null;
|
|
89053
89575
|
if (versionId) {
|
|
89054
89576
|
say("");
|
|
89055
|
-
say(` ${
|
|
89577
|
+
say(` ${import_picocolors76.default.dim("version")} ${safe(versionId)}`);
|
|
89056
89578
|
if (!json3)
|
|
89057
|
-
say(` ${
|
|
89579
|
+
say(` ${import_picocolors76.default.dim("Waiting for its build...")}`);
|
|
89058
89580
|
const buildKey = `${key2}-build`;
|
|
89059
89581
|
let outcome;
|
|
89060
89582
|
try {
|
|
@@ -89064,7 +89586,7 @@ async function build(ctx) {
|
|
|
89064
89586
|
signal: stop.signal,
|
|
89065
89587
|
now: deps.now,
|
|
89066
89588
|
idempotencyKey: buildKey,
|
|
89067
|
-
onStall: () => say(` ${
|
|
89589
|
+
onStall: () => say(` ${import_picocolors76.default.yellow("The build looks stalled; still waiting in case another worker picks it up.")}`)
|
|
89068
89590
|
});
|
|
89069
89591
|
} catch (error2) {
|
|
89070
89592
|
if (error2 instanceof LostResponseError) {
|
|
@@ -89080,9 +89602,9 @@ async function build(ctx) {
|
|
|
89080
89602
|
status = noVersionStatus(mine?.status === "failed", task.status);
|
|
89081
89603
|
if (status === "no_version") {
|
|
89082
89604
|
codes.push(1);
|
|
89083
|
-
say(` ${
|
|
89605
|
+
say(` ${import_picocolors76.default.red("The conversation finished without committing a version, so there is nothing to build.")}`);
|
|
89084
89606
|
} else if (task.status !== "need_more_info") {
|
|
89085
|
-
say(` ${
|
|
89607
|
+
say(` ${import_picocolors76.default.dim("This conversation produced no version, so there is nothing to build.")}`);
|
|
89086
89608
|
}
|
|
89087
89609
|
}
|
|
89088
89610
|
if (!json3)
|
|
@@ -89097,7 +89619,7 @@ async function build(ctx) {
|
|
|
89097
89619
|
var buildCommands = { build };
|
|
89098
89620
|
|
|
89099
89621
|
// src/cli/interface-lifecycle.ts
|
|
89100
|
-
var
|
|
89622
|
+
var import_picocolors78 = __toESM(require_picocolors(), 1);
|
|
89101
89623
|
|
|
89102
89624
|
// src/core/org-members.ts
|
|
89103
89625
|
async function listAllOrgMembers(orgId) {
|
|
@@ -89151,7 +89673,7 @@ function membersById(members) {
|
|
|
89151
89673
|
}
|
|
89152
89674
|
|
|
89153
89675
|
// src/cli/interface-read.ts
|
|
89154
|
-
var
|
|
89676
|
+
var import_picocolors77 = __toESM(require_picocolors(), 1);
|
|
89155
89677
|
function interfaceState(row) {
|
|
89156
89678
|
if (row.archived_at)
|
|
89157
89679
|
return "archived";
|
|
@@ -89173,11 +89695,11 @@ function threadsLabel(shared) {
|
|
|
89173
89695
|
function stateTint(state) {
|
|
89174
89696
|
switch (state) {
|
|
89175
89697
|
case "live":
|
|
89176
|
-
return
|
|
89698
|
+
return import_picocolors77.default.green;
|
|
89177
89699
|
case "building":
|
|
89178
|
-
return
|
|
89700
|
+
return import_picocolors77.default.yellow;
|
|
89179
89701
|
case "archived":
|
|
89180
|
-
return
|
|
89702
|
+
return import_picocolors77.default.dim;
|
|
89181
89703
|
case "draft":
|
|
89182
89704
|
return (cell) => cell;
|
|
89183
89705
|
default: {
|
|
@@ -89210,7 +89732,7 @@ async function list3(ctx) {
|
|
|
89210
89732
|
if (shown.length === 0) {
|
|
89211
89733
|
const empty = onlyArchived ? "No archived interfaces." : includeArchived ? "No interfaces. Create one with `brainbase interface create`." : await emptyWithoutArchived(agentId);
|
|
89212
89734
|
console.log(`
|
|
89213
|
-
${
|
|
89735
|
+
${import_picocolors77.default.dim(empty)}
|
|
89214
89736
|
`);
|
|
89215
89737
|
return;
|
|
89216
89738
|
}
|
|
@@ -89223,7 +89745,7 @@ async function list3(ctx) {
|
|
|
89223
89745
|
audienceWord(row),
|
|
89224
89746
|
ago(row.last_edited_at ?? row.created_at, now2)
|
|
89225
89747
|
]);
|
|
89226
|
-
console.log(["", ...table(cells, [null,
|
|
89748
|
+
console.log(["", ...table(cells, [null, import_picocolors77.default.bold, null, null, null, import_picocolors77.default.dim]), ""].join(`
|
|
89227
89749
|
`));
|
|
89228
89750
|
});
|
|
89229
89751
|
}
|
|
@@ -89257,13 +89779,13 @@ async function get2(ctx) {
|
|
|
89257
89779
|
out.push(field("id", safe(row.id)));
|
|
89258
89780
|
out.push(field("agent", agentLabel(safe(row.agent_id), await agentNames([row.agent_id]))));
|
|
89259
89781
|
out.push(field("state", stateTint(state)(state)));
|
|
89260
|
-
out.push(field("address", row.live_release ? safe(row.live_release.url) : `${safe(row.slug)} ${
|
|
89782
|
+
out.push(field("address", row.live_release ? safe(row.live_release.url) : `${safe(row.slug)} ${import_picocolors77.default.dim("(nothing live yet)")}`));
|
|
89261
89783
|
out.push(field("audience", audienceLabel(row)));
|
|
89262
89784
|
out.push(field("threads", threadsLabel(row.share_agent_threads)));
|
|
89263
|
-
out.push(field("live", row.live_release ? `${safe(row.live_release.id)} ${
|
|
89264
|
-
out.push(field("draft", row.draft_version_id ? safe(row.draft_version_id) :
|
|
89785
|
+
out.push(field("live", row.live_release ? `${safe(row.live_release.id)} ${import_picocolors77.default.dim(`published ${ago(row.live_release.published_at)}`)}` : import_picocolors77.default.dim("none")));
|
|
89786
|
+
out.push(field("draft", row.draft_version_id ? safe(row.draft_version_id) : import_picocolors77.default.dim("none yet")));
|
|
89265
89787
|
if (row.running_generation) {
|
|
89266
|
-
out.push(field("building", `conversation ${safe(row.running_generation.thread_id ?? "")} ${
|
|
89788
|
+
out.push(field("building", `conversation ${safe(row.running_generation.thread_id ?? "")} ${import_picocolors77.default.dim(`(follow it with \`brainbase task logs ${safe(row.running_generation.thread_id ?? "")} --follow\`)`)}`));
|
|
89267
89789
|
}
|
|
89268
89790
|
if (row.archived_at)
|
|
89269
89791
|
out.push(field("archived", ago(row.archived_at)));
|
|
@@ -89292,7 +89814,7 @@ async function open(ctx) {
|
|
|
89292
89814
|
}
|
|
89293
89815
|
console.log(safe(url2));
|
|
89294
89816
|
if (new URL(url2).hostname.endsWith("vercel.app")) {
|
|
89295
|
-
console.error(
|
|
89817
|
+
console.error(import_picocolors77.default.yellow("This is the raw Vercel deployment address, which sits behind Vercel protection and will not open for viewers. The control plane has no public interfaces domain configured."));
|
|
89296
89818
|
}
|
|
89297
89819
|
});
|
|
89298
89820
|
}
|
|
@@ -89330,7 +89852,7 @@ async function history(ctx, name) {
|
|
|
89330
89852
|
banner(`interface ${name} — ${safe(id)}`);
|
|
89331
89853
|
if (rows.length === 0) {
|
|
89332
89854
|
console.log(`
|
|
89333
|
-
${
|
|
89855
|
+
${import_picocolors77.default.dim(`No ${name} yet.`)}
|
|
89334
89856
|
`);
|
|
89335
89857
|
return;
|
|
89336
89858
|
}
|
|
@@ -89407,7 +89929,7 @@ function exactlyOne(parsed, flags) {
|
|
|
89407
89929
|
}
|
|
89408
89930
|
function peopleLine(access, members) {
|
|
89409
89931
|
const ids = grantIds(access);
|
|
89410
|
-
return ids.length ? namesOf(ids, members) :
|
|
89932
|
+
return ids.length ? namesOf(ids, members) : import_picocolors78.default.dim("nobody named");
|
|
89411
89933
|
}
|
|
89412
89934
|
function printAccess(row, access, members) {
|
|
89413
89935
|
console.log([
|
|
@@ -89503,11 +90025,11 @@ async function create3(ctx) {
|
|
|
89503
90025
|
const id = safe(created.id);
|
|
89504
90026
|
const out = [
|
|
89505
90027
|
"",
|
|
89506
|
-
` ${
|
|
90028
|
+
` ${import_picocolors78.default.green("Created")} ${import_picocolors78.default.bold(safe(created.name))}`,
|
|
89507
90029
|
"",
|
|
89508
90030
|
field("id", id),
|
|
89509
90031
|
field("agent", safe(created.agent_id)),
|
|
89510
|
-
field("address", `${safe(created.slug)} ${
|
|
90032
|
+
field("address", `${safe(created.slug)} ${import_picocolors78.default.dim("(nothing live yet)")}`),
|
|
89511
90033
|
field("threads", threadsLabel(created.share_agent_threads))
|
|
89512
90034
|
];
|
|
89513
90035
|
if (access) {
|
|
@@ -89519,11 +90041,11 @@ async function create3(ctx) {
|
|
|
89519
90041
|
out.push("", ` Nobody can open it until you choose who can: \`brainbase interface access ${id} --everyone\` or \`--people <emails>\`.`);
|
|
89520
90042
|
}
|
|
89521
90043
|
if (created.share_agent_threads) {
|
|
89522
|
-
out.push(` ${
|
|
90044
|
+
out.push(` ${import_picocolors78.default.dim(`To show viewers only their own conversations: \`brainbase interface threads ${id} --private\`.`)}`);
|
|
89523
90045
|
}
|
|
89524
90046
|
if (note)
|
|
89525
90047
|
out.push("", ` ${safe(note)}`);
|
|
89526
|
-
out.push("", ` ${
|
|
90048
|
+
out.push("", ` ${import_picocolors78.default.dim(`Next: \`brainbase interface build ${id} "<what to build>"\``)}`, "");
|
|
89527
90049
|
console.log(out.join(`
|
|
89528
90050
|
`));
|
|
89529
90051
|
if (readFailed) {
|
|
@@ -89659,7 +90181,7 @@ async function threads(ctx) {
|
|
|
89659
90181
|
printJson({ id: row.id, share_agent_threads: row.share_agent_threads });
|
|
89660
90182
|
return;
|
|
89661
90183
|
}
|
|
89662
|
-
const already = wanted === null ? "" : ` ${
|
|
90184
|
+
const already = wanted === null ? "" : ` ${import_picocolors78.default.dim("(already set; nothing changed)")}`;
|
|
89663
90185
|
console.log(`
|
|
89664
90186
|
${field("threads", `${threadsLabel(row.share_agent_threads)}${already}`)}
|
|
89665
90187
|
`);
|
|
@@ -89698,7 +90220,7 @@ async function rename(ctx) {
|
|
|
89698
90220
|
return;
|
|
89699
90221
|
}
|
|
89700
90222
|
console.log(`
|
|
89701
|
-
Renamed ${safe(updated.id)} to ${
|
|
90223
|
+
Renamed ${safe(updated.id)} to ${import_picocolors78.default.bold(safe(updated.name))}.
|
|
89702
90224
|
`);
|
|
89703
90225
|
});
|
|
89704
90226
|
}
|
|
@@ -89734,7 +90256,7 @@ async function address(ctx) {
|
|
|
89734
90256
|
}
|
|
89735
90257
|
const where = updated.live_release ? safe(updated.live_release.url) : safe(updated.slug);
|
|
89736
90258
|
console.log(`
|
|
89737
|
-
${safe(updated.name)} is now at ${
|
|
90259
|
+
${safe(updated.name)} is now at ${import_picocolors78.default.bold(where)}.
|
|
89738
90260
|
`);
|
|
89739
90261
|
});
|
|
89740
90262
|
}
|
|
@@ -89826,9 +90348,9 @@ var lifecycleCommands = {
|
|
|
89826
90348
|
};
|
|
89827
90349
|
|
|
89828
90350
|
// src/cli/interface-preview.ts
|
|
89829
|
-
var
|
|
90351
|
+
var import_picocolors79 = __toESM(require_picocolors(), 1);
|
|
89830
90352
|
function warn(line2) {
|
|
89831
|
-
console.error(
|
|
90353
|
+
console.error(import_picocolors79.default.yellow(line2));
|
|
89832
90354
|
}
|
|
89833
90355
|
var PREVIEW_TIMEOUT_SECONDS = 300;
|
|
89834
90356
|
var PROBE_INTERVAL_MS = 2000;
|
|
@@ -89918,12 +90440,12 @@ async function preview(ctx) {
|
|
|
89918
90440
|
const say = progress(json3);
|
|
89919
90441
|
const row = await interfacesApi.get(id);
|
|
89920
90442
|
const { taskId, why } = await pickConversation(row, stringOption(parsed, "task")?.trim() || undefined);
|
|
89921
|
-
say(
|
|
90443
|
+
say(import_picocolors79.default.dim(` Previewing ${why}, ${safe(taskId)}.`));
|
|
89922
90444
|
const started = await interfacesApi.startPreview(taskId, row.id);
|
|
89923
90445
|
const address2 = previewAddress(started, row);
|
|
89924
90446
|
let outcome = started.state === "serving" ? "serving" : "not_waited";
|
|
89925
90447
|
if (outcome !== "serving" && !noWait) {
|
|
89926
|
-
say(
|
|
90448
|
+
say(import_picocolors79.default.dim(" Starting the dev server in the sandbox…"));
|
|
89927
90449
|
outcome = await waitUntilServing(started, { timeoutMs: waitMs, deps: ctx.deps });
|
|
89928
90450
|
}
|
|
89929
90451
|
if (json3) {
|
|
@@ -89931,12 +90453,12 @@ async function preview(ctx) {
|
|
|
89931
90453
|
} else {
|
|
89932
90454
|
const out = [
|
|
89933
90455
|
"",
|
|
89934
|
-
` ${outcome === "serving" ?
|
|
90456
|
+
` ${outcome === "serving" ? import_picocolors79.default.green("Preview ready") : import_picocolors79.default.yellow("Preview starting")} ${import_picocolors79.default.bold(safe(started.name))}`,
|
|
89935
90457
|
"",
|
|
89936
|
-
field("address", address2 ? safe(address2) :
|
|
90458
|
+
field("address", address2 ? safe(address2) : import_picocolors79.default.dim(missingAddress(started))),
|
|
89937
90459
|
field("showing", showing(started, taskId)),
|
|
89938
90460
|
"",
|
|
89939
|
-
` ${
|
|
90461
|
+
` ${import_picocolors79.default.dim("Opens for people who can edit the agent, after signing in. Nothing is published.")}`,
|
|
89940
90462
|
""
|
|
89941
90463
|
];
|
|
89942
90464
|
console.log(out.join(`
|
|
@@ -89957,13 +90479,13 @@ async function preview(ctx) {
|
|
|
89957
90479
|
var previewCommands = { preview };
|
|
89958
90480
|
|
|
89959
90481
|
// src/cli/interface-release.ts
|
|
89960
|
-
var
|
|
90482
|
+
var import_picocolors80 = __toESM(require_picocolors(), 1);
|
|
89961
90483
|
var PUBLISH_TIMEOUT_SECONDS = 300;
|
|
89962
90484
|
var REBUILD_USAGE = "brainbase interface rebuild <id> [--version <version id>] [--yes]";
|
|
89963
90485
|
var PUBLISH_USAGE = "brainbase interface publish <id> [--build <build id>]";
|
|
89964
90486
|
var ROLLBACK_USAGE = "brainbase interface rollback <id> --release <release id>";
|
|
89965
90487
|
function warn2(line2) {
|
|
89966
|
-
console.error(
|
|
90488
|
+
console.error(import_picocolors80.default.yellow(line2));
|
|
89967
90489
|
}
|
|
89968
90490
|
function text3(value2) {
|
|
89969
90491
|
return typeof value2 === "string" && value2.trim() ? value2 : null;
|
|
@@ -89980,7 +90502,7 @@ async function follow(operationId, what, options) {
|
|
|
89980
90502
|
intervalMs: options.deps.pollIntervalMs,
|
|
89981
90503
|
signal: stop.signal,
|
|
89982
90504
|
now: options.deps.now,
|
|
89983
|
-
onStatus: (operation) => say(
|
|
90505
|
+
onStatus: (operation) => say(import_picocolors80.default.dim(` ${what} ${operation.status}`)),
|
|
89984
90506
|
onStall: () => warn2(`The ${what} looks stalled: its worker stopped checking in. Still waiting, in case another worker picks it up.`)
|
|
89985
90507
|
});
|
|
89986
90508
|
if (outcome.kind === "settled") {
|
|
@@ -89999,7 +90521,7 @@ function reportUnsuccessful(result2, what, options) {
|
|
|
89999
90521
|
if (options.json) {
|
|
90000
90522
|
printJson({ outcome: result2.outcome, operation_id: result2.operationId, operation: result2.operation });
|
|
90001
90523
|
} else if (result2.outcome === "failed") {
|
|
90002
|
-
console.error(
|
|
90524
|
+
console.error(import_picocolors80.default.red(`The ${what} failed (operation ${id}):`));
|
|
90003
90525
|
console.error(safeBlock(result2.operation?.error ?? "Brainbase gave no reason."));
|
|
90004
90526
|
} else if (result2.outcome === "timeout") {
|
|
90005
90527
|
warn2(`Stopped waiting after ${Math.round(options.timeoutMs / 1000)}s. The ${what} keeps running on the server (operation ${id}).`);
|
|
@@ -90059,7 +90581,7 @@ async function rebuild(ctx) {
|
|
|
90059
90581
|
if (json3)
|
|
90060
90582
|
printJson({ outcome: "started", operation_id: operationId, operation });
|
|
90061
90583
|
else
|
|
90062
|
-
console.log(
|
|
90584
|
+
console.log(import_picocolors80.default.dim(` Follow it with \`brainbase interface builds ${safe(id)}\`.`));
|
|
90063
90585
|
return;
|
|
90064
90586
|
}
|
|
90065
90587
|
const result2 = await follow(operationId, "build", { json: json3, timeoutMs: waitMs, deps: ctx.deps });
|
|
@@ -90071,8 +90593,8 @@ async function rebuild(ctx) {
|
|
|
90071
90593
|
}
|
|
90072
90594
|
const buildId = safe(result2.operation?.build_id ?? "");
|
|
90073
90595
|
const version2 = safe(result2.operation?.source_version_id ?? "");
|
|
90074
|
-
console.log(
|
|
90075
|
-
console.log(
|
|
90596
|
+
console.log(import_picocolors80.default.green(`✓ Build ${buildId} succeeded${version2 ? ` (version ${version2})` : ""}.`));
|
|
90597
|
+
console.log(import_picocolors80.default.dim(` Publish it with \`brainbase interface publish ${safe(id)} --build ${buildId}\`.`));
|
|
90076
90598
|
});
|
|
90077
90599
|
}
|
|
90078
90600
|
function liveBuildOf(row, releases) {
|
|
@@ -90130,7 +90652,7 @@ function describeBuild(buildId, builds) {
|
|
|
90130
90652
|
const build2 = builds.find((candidate) => candidate.id === buildId);
|
|
90131
90653
|
if (!build2)
|
|
90132
90654
|
return `build ${safe(buildId)}`;
|
|
90133
|
-
return `build ${safe(build2.id)} ${
|
|
90655
|
+
return `build ${safe(build2.id)} ${import_picocolors80.default.dim(`(version ${safe(build2.source_version_id)}, built ${ago(build2.created_at)})`)}`;
|
|
90134
90656
|
}
|
|
90135
90657
|
function reportAlreadyLive(json3, buildId, releaseId, url2) {
|
|
90136
90658
|
if (json3) {
|
|
@@ -90184,8 +90706,8 @@ async function publish(ctx) {
|
|
|
90184
90706
|
}
|
|
90185
90707
|
if (!json3) {
|
|
90186
90708
|
console.log("");
|
|
90187
|
-
console.log(` ${
|
|
90188
|
-
console.log(` ${
|
|
90709
|
+
console.log(` ${import_picocolors80.default.dim("Live now".padEnd(14))}${liveBuildId ? `${describeBuild(liveBuildId, builds)} at ${safe(row.live_release?.url)}` : row.live_release ? `release ${safe(row.live_release.id)} at ${safe(row.live_release.url)}` : import_picocolors80.default.dim("nothing")}`);
|
|
90710
|
+
console.log(` ${import_picocolors80.default.dim("Will publish".padEnd(14))}${describeBuild(buildId, builds)}`);
|
|
90189
90711
|
console.log("");
|
|
90190
90712
|
}
|
|
90191
90713
|
const proceed = await confirmChange({
|
|
@@ -90228,7 +90750,7 @@ async function publish(ctx) {
|
|
|
90228
90750
|
if (json3)
|
|
90229
90751
|
printJson({ outcome: "started", operation_id: operationId, operation });
|
|
90230
90752
|
else
|
|
90231
|
-
console.log(
|
|
90753
|
+
console.log(import_picocolors80.default.dim(` Check it with \`brainbase interface get ${safe(id)}\`.`));
|
|
90232
90754
|
return;
|
|
90233
90755
|
}
|
|
90234
90756
|
const result2 = await follow(operationId, "publish", { json: json3, timeoutMs: waitMs, deps: ctx.deps });
|
|
@@ -90245,11 +90767,11 @@ async function publish(ctx) {
|
|
|
90245
90767
|
printJson({ outcome: "succeeded", operation_id: operationId, operation: result2.operation, url: url2 });
|
|
90246
90768
|
return;
|
|
90247
90769
|
}
|
|
90248
|
-
console.log(
|
|
90770
|
+
console.log(import_picocolors80.default.green(`✓ Build ${safe(buildId)} is live.`));
|
|
90249
90771
|
if (url2)
|
|
90250
90772
|
console.log(` ${safe(url2)}`);
|
|
90251
90773
|
if (urlUnread) {
|
|
90252
|
-
console.log(
|
|
90774
|
+
console.log(import_picocolors80.default.dim(` Its address could not be read just now; see it with \`brainbase interface open ${safe(id)}\`.`));
|
|
90253
90775
|
}
|
|
90254
90776
|
});
|
|
90255
90777
|
}
|
|
@@ -90285,8 +90807,8 @@ async function rollback(ctx) {
|
|
|
90285
90807
|
}
|
|
90286
90808
|
if (!json3) {
|
|
90287
90809
|
console.log("");
|
|
90288
|
-
console.log(` ${
|
|
90289
|
-
console.log(` ${
|
|
90810
|
+
console.log(` ${import_picocolors80.default.dim("Live now".padEnd(16))}release ${safe(row.live_release.id)} at ${safe(row.live_release.url)}`);
|
|
90811
|
+
console.log(` ${import_picocolors80.default.dim("Will republish".padEnd(16))}release ${safe(releaseId)} ${import_picocolors80.default.dim("as a new release, with a new id")}`);
|
|
90290
90812
|
console.log("");
|
|
90291
90813
|
}
|
|
90292
90814
|
const proceed = await confirmChange({
|
|
@@ -90319,7 +90841,7 @@ async function rollback(ctx) {
|
|
|
90319
90841
|
printJson(release);
|
|
90320
90842
|
return;
|
|
90321
90843
|
}
|
|
90322
|
-
console.log(
|
|
90844
|
+
console.log(import_picocolors80.default.green(release.id === releaseId ? `✓ Release ${safe(releaseId)} is live (build ${safe(release.build_id)}).` : `✓ Republished release ${safe(releaseId)} as new release ${safe(release.id)} (build ${safe(release.build_id)}). It is live.`));
|
|
90323
90845
|
console.log(` ${safe(release.url)}`);
|
|
90324
90846
|
});
|
|
90325
90847
|
}
|
|
@@ -90354,14 +90876,14 @@ ${didYouMean(sub, Object.keys(COMMANDS2), "brainbase interface")}`);
|
|
|
90354
90876
|
await command({ cwd: cwd2, args, deps });
|
|
90355
90877
|
}
|
|
90356
90878
|
function line2(command, args, description) {
|
|
90357
|
-
return ` ${
|
|
90358
|
-
${
|
|
90879
|
+
return ` ${import_picocolors81.default.cyan(command)}${args ? ` ${import_picocolors81.default.dim(args)}` : ""}
|
|
90880
|
+
${import_picocolors81.default.dim(description)}`;
|
|
90359
90881
|
}
|
|
90360
90882
|
function printHelp7() {
|
|
90361
90883
|
const out = [];
|
|
90362
90884
|
out.push("");
|
|
90363
|
-
out.push(` ${
|
|
90364
|
-
out.push(` ${
|
|
90885
|
+
out.push(` ${import_picocolors81.default.bold("brainbase interface")} ${import_picocolors81.default.dim("<sub> [options]")}`);
|
|
90886
|
+
out.push(` ${import_picocolors81.default.dim("Dashboards for an agent: build them in a conversation, publish them, choose who can open them.")}`);
|
|
90365
90887
|
out.push("");
|
|
90366
90888
|
out.push(line2("ls", "[--agent <id>] [--archived | --only-archived]", "list interfaces you can see"));
|
|
90367
90889
|
out.push(line2("get", "<id>", "one interface: address, audience, live release, draft, running build conversation"));
|
|
@@ -90381,22 +90903,22 @@ function printHelp7() {
|
|
|
90381
90903
|
out.push(line2("rollback", "<id> --release <id>", "republish an earlier release; it goes live under a new release id"));
|
|
90382
90904
|
out.push(line2("preview", "<id> [--task <id>] [--no-wait]", "serve the unpublished draft from its build conversation and print the preview address"));
|
|
90383
90905
|
out.push("");
|
|
90384
|
-
out.push(` ${
|
|
90385
|
-
out.push(` ${
|
|
90386
|
-
out.push(` ${
|
|
90387
|
-
out.push(` ${
|
|
90388
|
-
out.push(` ${
|
|
90906
|
+
out.push(` ${import_picocolors81.default.dim("--json")} machine-readable output; never prompts`);
|
|
90907
|
+
out.push(` ${import_picocolors81.default.dim("--yes, -y")} skip confirmation (required without a terminal)`);
|
|
90908
|
+
out.push(` ${import_picocolors81.default.dim("--no-wait")} for rebuild and publish: return the operation at once; for preview: do not wait for the dev server`);
|
|
90909
|
+
out.push(` ${import_picocolors81.default.dim("--timeout <seconds>")} for build, rebuild, publish and preview: how long to wait (builds 900, publish and preview 300)`);
|
|
90910
|
+
out.push(` ${import_picocolors81.default.dim("--idempotency-key <key>")} replay a create, build, rebuild, publish or rollback whose answer was lost`);
|
|
90389
90911
|
out.push("");
|
|
90390
|
-
out.push(` ${
|
|
90391
|
-
out.push(` ${
|
|
90392
|
-
out.push(` ${
|
|
90912
|
+
out.push(` ${import_picocolors81.default.dim("People are emails (see `brainbase member ls`), user ids, or `me`. Audience members also need access to the agent.")}`);
|
|
90913
|
+
out.push(` ${import_picocolors81.default.dim("Audience: everyone (--everyone, `org` under --json) or chosen people (--people, `users` under --json).")}`);
|
|
90914
|
+
out.push(` ${import_picocolors81.default.dim("Exit codes: 0 done, 1 refused or failed, 130 interrupted (the server keeps working).")}`);
|
|
90393
90915
|
out.push("");
|
|
90394
90916
|
console.log(out.join(`
|
|
90395
90917
|
`));
|
|
90396
90918
|
}
|
|
90397
90919
|
|
|
90398
90920
|
// src/cli/member.ts
|
|
90399
|
-
var
|
|
90921
|
+
var import_picocolors82 = __toESM(require_picocolors(), 1);
|
|
90400
90922
|
async function runMember(sub, args, opts) {
|
|
90401
90923
|
if (args.some((arg) => arg === "--help" || arg === "-h")) {
|
|
90402
90924
|
printHelp8();
|
|
@@ -90439,7 +90961,7 @@ async function runMemberList(opts) {
|
|
|
90439
90961
|
function formatMemberList(members) {
|
|
90440
90962
|
if (members.length === 0)
|
|
90441
90963
|
return `
|
|
90442
|
-
${
|
|
90964
|
+
${import_picocolors82.default.dim("Nobody here you can see.")}
|
|
90443
90965
|
`;
|
|
90444
90966
|
const sorted = [...members].sort((a3, b4) => (a3.email ?? a3.id).localeCompare(b4.email ?? b4.id));
|
|
90445
90967
|
const rows = sorted.map((member) => ({
|
|
@@ -90453,24 +90975,24 @@ function formatMemberList(members) {
|
|
|
90453
90975
|
const roleWidth = Math.max(...rows.map((row) => row.role.length));
|
|
90454
90976
|
const lines = [""];
|
|
90455
90977
|
for (const row of rows) {
|
|
90456
|
-
lines.push(` ${row.email.padEnd(emailWidth)} ${row.name.padEnd(nameWidth)} ${
|
|
90978
|
+
lines.push(` ${row.email.padEnd(emailWidth)} ${row.name.padEnd(nameWidth)} ${import_picocolors82.default.dim(row.role.padEnd(roleWidth))} ${import_picocolors82.default.dim(row.teams)}`.trimEnd());
|
|
90457
90979
|
}
|
|
90458
|
-
lines.push("", ` ${
|
|
90980
|
+
lines.push("", ` ${import_picocolors82.default.dim("share a dashboard with one of them:")} ${import_picocolors82.default.cyan("brainbase interface access <id> --add <email>")}`, "");
|
|
90459
90981
|
return lines.join(`
|
|
90460
90982
|
`);
|
|
90461
90983
|
}
|
|
90462
90984
|
function printHelp8() {
|
|
90463
90985
|
const out = [];
|
|
90464
90986
|
out.push("");
|
|
90465
|
-
out.push(` ${
|
|
90987
|
+
out.push(` ${import_picocolors82.default.bold("brainbase member")} ${import_picocolors82.default.dim("<sub> [options]")}`);
|
|
90466
90988
|
out.push("");
|
|
90467
|
-
out.push(` ${
|
|
90989
|
+
out.push(` ${import_picocolors82.default.cyan("ls")} ${import_picocolors82.default.dim("the people in an organization you can see, with their emails, roles and teams")}`);
|
|
90468
90990
|
out.push("");
|
|
90469
|
-
out.push(` ${
|
|
90470
|
-
out.push(` ${
|
|
90991
|
+
out.push(` ${import_picocolors82.default.dim("--org <id-or-slug>")} ${import_picocolors82.default.dim("which organization (picked automatically when you are in one)")}`);
|
|
90992
|
+
out.push(` ${import_picocolors82.default.dim("--json")} ${import_picocolors82.default.dim("machine-readable output")}`);
|
|
90471
90993
|
out.push("");
|
|
90472
|
-
out.push(` ${
|
|
90473
|
-
out.push(` ${
|
|
90994
|
+
out.push(` ${import_picocolors82.default.dim("Owners and admins see everyone. Anyone else sees the owners, the admins, themselves")}`);
|
|
90995
|
+
out.push(` ${import_picocolors82.default.dim("and the people who share a team with them, as in the web app.")}`);
|
|
90474
90996
|
out.push("");
|
|
90475
90997
|
console.log(out.join(`
|
|
90476
90998
|
`));
|
|
@@ -92181,7 +92703,7 @@ async function runCommand(command, root, spec, context, options = {}) {
|
|
|
92181
92703
|
return error2;
|
|
92182
92704
|
return new BenchmarkCommandExecutionError(error2.code, error2.message, sanitizedOutput(stdout), sanitizedOutput(stderr), error2.durationMs);
|
|
92183
92705
|
};
|
|
92184
|
-
const
|
|
92706
|
+
const fail4 = (error2) => {
|
|
92185
92707
|
if (settled)
|
|
92186
92708
|
return;
|
|
92187
92709
|
settled = true;
|
|
@@ -92200,7 +92722,7 @@ async function runCommand(command, root, spec, context, options = {}) {
|
|
|
92200
92722
|
captured += chunk2.length;
|
|
92201
92723
|
context.remainingOutputBytes -= chunk2.length;
|
|
92202
92724
|
if (captured > spec.budget.max_output_bytes || context.remainingOutputBytes < 0) {
|
|
92203
|
-
|
|
92725
|
+
fail4(new BenchmarkPhaseError("output_limit_exceeded", `command output exceeded budget: ${command.id}`));
|
|
92204
92726
|
return;
|
|
92205
92727
|
}
|
|
92206
92728
|
target.push(chunk2);
|
|
@@ -92223,14 +92745,14 @@ async function runCommand(command, root, spec, context, options = {}) {
|
|
|
92223
92745
|
child.stdout?.on("data", (chunk2) => capture(stdout, chunk2));
|
|
92224
92746
|
child.stderr?.on("data", (chunk2) => capture(stderr, chunk2));
|
|
92225
92747
|
child.on("error", (error2) => {
|
|
92226
|
-
|
|
92748
|
+
fail4(new BenchmarkCommandExecutionError("command_start_failed", `failed to start ${command.id}: ${error2.message}`, Buffer.concat(stdout), Buffer.concat(stderr), Date.now() - started));
|
|
92227
92749
|
});
|
|
92228
92750
|
timer = setTimeout(() => {
|
|
92229
92751
|
if (reachesPhaseDeadline) {
|
|
92230
|
-
|
|
92752
|
+
fail4(new BenchmarkPhaseError("phase_timeout", "phase budget expired"));
|
|
92231
92753
|
return;
|
|
92232
92754
|
}
|
|
92233
|
-
|
|
92755
|
+
fail4(new BenchmarkCommandExecutionError("command_timeout", `command timed out: ${command.id}`, Buffer.concat(stdout), Buffer.concat(stderr), Date.now() - started));
|
|
92234
92756
|
}, timeoutMs3);
|
|
92235
92757
|
child.on("exit", (code, signal) => {
|
|
92236
92758
|
if (settled)
|
|
@@ -93563,7 +94085,7 @@ async function runBenchmarkPhase(specPathInput, resultPathInput, expectedPhase,
|
|
|
93563
94085
|
}
|
|
93564
94086
|
|
|
93565
94087
|
// src/cli/benchmark-control.ts
|
|
93566
|
-
var
|
|
94088
|
+
var import_picocolors83 = __toESM(require_picocolors(), 1);
|
|
93567
94089
|
import fs92 from "node:fs";
|
|
93568
94090
|
import path103 from "node:path";
|
|
93569
94091
|
|
|
@@ -96577,20 +97099,20 @@ async function emitCursorPages(output, fetchPage, options) {
|
|
|
96577
97099
|
function commandHelp() {
|
|
96578
97100
|
return [
|
|
96579
97101
|
"",
|
|
96580
|
-
` ${
|
|
97102
|
+
` ${import_picocolors83.default.bold("brainbase benchmark")} ${import_picocolors83.default.dim("<command> [options]")}`,
|
|
96581
97103
|
"",
|
|
96582
|
-
` ${
|
|
96583
|
-
` ${
|
|
96584
|
-
` ${
|
|
96585
|
-
` ${
|
|
96586
|
-
` ${
|
|
97104
|
+
` ${import_picocolors83.default.cyan("init | list | show | create | validate | pull | push")}`,
|
|
97105
|
+
` ${import_picocolors83.default.cyan("publish | revisions | import | export | archive | restore")}`,
|
|
97106
|
+
` ${import_picocolors83.default.cyan("run plan|start|watch|list|show|cancel|resume")}`,
|
|
97107
|
+
` ${import_picocolors83.default.cyan("results | diagnoses | attempt | artifacts | export-results")}`,
|
|
97108
|
+
` ${import_picocolors83.default.cyan("history | baseline show|set|clear")}`,
|
|
96587
97109
|
"",
|
|
96588
|
-
` ${
|
|
97110
|
+
` ${import_picocolors83.default.dim("Use --agent to override brainbase.agent.yaml, and --json or --jsonl for automation.")}`,
|
|
96589
97111
|
"",
|
|
96590
|
-
` ${
|
|
96591
|
-
` ${
|
|
96592
|
-
` ${
|
|
96593
|
-
` ${
|
|
97112
|
+
` ${import_picocolors83.default.bold("benchmark runtime (machine-only)")}`,
|
|
97113
|
+
` ${import_picocolors83.default.cyan("hydrate")} ${import_picocolors83.default.dim("--spec <path> --result <path> --json")}`,
|
|
97114
|
+
` ${import_picocolors83.default.cyan("evaluate")} ${import_picocolors83.default.dim("--spec <path> --result <path> --json")}`,
|
|
97115
|
+
` ${import_picocolors83.default.cyan("capabilities")} ${import_picocolors83.default.dim("--json")}`,
|
|
96594
97116
|
""
|
|
96595
97117
|
].join(`
|
|
96596
97118
|
`);
|
|
@@ -98050,7 +98572,7 @@ function retryDelayMs(attempt2, retryAfter) {
|
|
|
98050
98572
|
const base2 = Number.isFinite(seconds) ? seconds * 1000 : 1000 * 2 ** attempt2;
|
|
98051
98573
|
return Math.min(Math.max(base2, 0), MAX_RETRY_DELAY_MS) + Math.random() * 500;
|
|
98052
98574
|
}
|
|
98053
|
-
function
|
|
98575
|
+
function errorMessage3(status, text4) {
|
|
98054
98576
|
try {
|
|
98055
98577
|
const body = JSON.parse(text4);
|
|
98056
98578
|
const message3 = body.error?.message ?? body.detail;
|
|
@@ -98083,7 +98605,7 @@ async function postDecide(credential, body, options = {}) {
|
|
|
98083
98605
|
throw new DecideHttpError("The server sent an unreadable response", response.status);
|
|
98084
98606
|
}
|
|
98085
98607
|
}
|
|
98086
|
-
failure = new DecideHttpError(
|
|
98608
|
+
failure = new DecideHttpError(errorMessage3(response.status, text4), response.status);
|
|
98087
98609
|
if (!RETRY_STATUSES.has(response.status))
|
|
98088
98610
|
throw failure;
|
|
98089
98611
|
retryAfter = response.headers.get("retry-after");
|
|
@@ -98448,7 +98970,7 @@ var MAX_CONCURRENCY = 16;
|
|
|
98448
98970
|
var SUMMARY_UNCERTAIN_IDS = 20;
|
|
98449
98971
|
var SUMMARY_FAILED = 10;
|
|
98450
98972
|
var STOP_STATUSES = new Set([401, 402, 403, 404]);
|
|
98451
|
-
var
|
|
98973
|
+
var OPTIONS2 = [
|
|
98452
98974
|
{ key: "questions", names: ["--questions", "-q"], kind: "value" },
|
|
98453
98975
|
{ key: "items", names: ["--items"], kind: "value", multiple: true },
|
|
98454
98976
|
{ key: "jsonl", names: ["--jsonl"], kind: "value", multiple: true },
|
|
@@ -98595,7 +99117,7 @@ async function runDecide(cwd2, argv, deps = {}) {
|
|
|
98595
99117
|
const started = Date.now();
|
|
98596
99118
|
let parsed;
|
|
98597
99119
|
try {
|
|
98598
|
-
parsed = parseArgv(argv,
|
|
99120
|
+
parsed = parseArgv(argv, OPTIONS2);
|
|
98599
99121
|
} catch (error2) {
|
|
98600
99122
|
if (error2 instanceof ArgvParseError)
|
|
98601
99123
|
return usageError2(stderr, error2.message);
|
|
@@ -98859,217 +99381,218 @@ var SUBCOMMAND_OWNED_FLAGS = {
|
|
|
98859
99381
|
function help() {
|
|
98860
99382
|
const out = [];
|
|
98861
99383
|
out.push("");
|
|
98862
|
-
out.push(` ${brandTint("◆")} ${
|
|
98863
|
-
out.push(` ${
|
|
99384
|
+
out.push(` ${brandTint("◆")} ${import_picocolors84.default.bold("brainbase")} ${import_picocolors84.default.dim(`v${VERSION}`)}`);
|
|
99385
|
+
out.push(` ${import_picocolors84.default.dim("connect your local agent to the brainbase platform")}`);
|
|
98864
99386
|
out.push("");
|
|
98865
99387
|
out.push(divider("USAGE"));
|
|
98866
99388
|
out.push("");
|
|
98867
|
-
out.push(` ${
|
|
99389
|
+
out.push(` ${import_picocolors84.default.bold("brainbase")} ${import_picocolors84.default.dim("<command> [options]")}`);
|
|
98868
99390
|
out.push("");
|
|
98869
99391
|
out.push(divider("AUTH"));
|
|
98870
99392
|
out.push("");
|
|
98871
|
-
out.push(` ${
|
|
98872
|
-
out.push(` ${
|
|
98873
|
-
out.push(` ${
|
|
99393
|
+
out.push(` ${import_picocolors84.default.cyan("login")} ${import_picocolors84.default.dim(" open the web app and connect this device")}`);
|
|
99394
|
+
out.push(` ${import_picocolors84.default.cyan("logout")} ${import_picocolors84.default.dim(" clear the local session")}`);
|
|
99395
|
+
out.push(` ${import_picocolors84.default.cyan("whoami")} ${import_picocolors84.default.dim("[--json]")} ${import_picocolors84.default.dim(" show which credential is in use and what it covers")}`);
|
|
98874
99396
|
out.push("");
|
|
98875
99397
|
out.push(divider("DISCOVERY"));
|
|
98876
99398
|
out.push("");
|
|
98877
|
-
out.push(` ${
|
|
98878
|
-
out.push(` ${
|
|
98879
|
-
out.push(` ${
|
|
99399
|
+
out.push(` ${import_picocolors84.default.cyan("team list")} ${import_picocolors84.default.dim("show the teams you can create agents in")}`);
|
|
99400
|
+
out.push(` ${import_picocolors84.default.cyan("member ls")} ${import_picocolors84.default.dim("show the people in an organization, with the emails interface access takes")}`);
|
|
99401
|
+
out.push(` ${import_picocolors84.default.cyan("agent list")} ${import_picocolors84.default.dim("show a team's agents and their ids")}`);
|
|
98880
99402
|
out.push("");
|
|
98881
99403
|
out.push(divider("LINKED AGENT"));
|
|
98882
99404
|
out.push("");
|
|
98883
|
-
out.push(` ${
|
|
98884
|
-
out.push(` ${
|
|
98885
|
-
out.push(` ${
|
|
98886
|
-
out.push(` ${
|
|
98887
|
-
out.push(` ${
|
|
98888
|
-
out.push(` ${
|
|
98889
|
-
out.push(` ${
|
|
98890
|
-
out.push(` ${
|
|
98891
|
-
out.push(` ${
|
|
98892
|
-
out.push(` ${
|
|
98893
|
-
out.push(` ${
|
|
98894
|
-
out.push(` ${
|
|
98895
|
-
out.push(` ${
|
|
98896
|
-
out.push(` ${
|
|
98897
|
-
out.push(` ${
|
|
98898
|
-
out.push(` ${
|
|
98899
|
-
out.push(` ${
|
|
98900
|
-
out.push(` ${
|
|
99405
|
+
out.push(` ${import_picocolors84.default.cyan("agent init")} ${import_picocolors84.default.dim("write a starter brainbase.agent.yaml here — offline, no login needed")}`);
|
|
99406
|
+
out.push(` ${import_picocolors84.default.cyan("agent create")} ${import_picocolors84.default.dim("claim an unclaimed brainbase.agent.yaml and create the cloud agent")}`);
|
|
99407
|
+
out.push(` ${import_picocolors84.default.cyan("agent pull")} ${import_picocolors84.default.dim("[<id>]")} ${import_picocolors84.default.dim("bring cloud changes into this folder (--force to override; --run-entrypoint to also execute the agent entrypoint; --link to link first)")}`);
|
|
99408
|
+
out.push(` ${import_picocolors84.default.cyan("agent push")} ${import_picocolors84.default.dim("send local changes to the cloud (--force to overwrite cloud-side conflicts with local)")}`);
|
|
99409
|
+
out.push(` ${import_picocolors84.default.cyan("agent delete")} ${import_picocolors84.default.dim("<id>")} ${import_picocolors84.default.dim("permanently delete a cloud agent and every task it has run")}`);
|
|
99410
|
+
out.push(` ${import_picocolors84.default.cyan("agent unpack")} ${import_picocolors84.default.dim("install the claimed agent into a harness layout")}`);
|
|
99411
|
+
out.push(` ${import_picocolors84.default.cyan("link")} ${import_picocolors84.default.dim("attach this folder to an existing agent")}`);
|
|
99412
|
+
out.push(` ${import_picocolors84.default.cyan("agent status")} ${import_picocolors84.default.dim("show what would pull and what would push")}`);
|
|
99413
|
+
out.push(` ${import_picocolors84.default.cyan("agent connections")} ${import_picocolors84.default.dim("show which integrations this agent is wired to (--json for CI)")}`);
|
|
99414
|
+
out.push(` ${import_picocolors84.default.cyan("agent connect")} ${import_picocolors84.default.dim("<name>")} ${import_picocolors84.default.dim("connect chat, slack, meeting, github, linear or phone")}`);
|
|
99415
|
+
out.push(` ${import_picocolors84.default.cyan("agent disconnect")} ${import_picocolors84.default.dim("<name>")} ${import_picocolors84.default.dim("disable or disconnect an agent surface")}`);
|
|
99416
|
+
out.push(` ${import_picocolors84.default.cyan("agent surface")} ${import_picocolors84.default.dim("<name>")} ${import_picocolors84.default.dim("status, settings and setup for all six surfaces (--help)")}`);
|
|
99417
|
+
out.push(` ${import_picocolors84.default.cyan("agent versions")} ${import_picocolors84.default.dim("saved versions: list, show, diff, label, restore, pin and unpin (`agent versions --help`)")}`);
|
|
99418
|
+
out.push(` ${import_picocolors84.default.cyan("agent eval")} ${import_picocolors84.default.dim("<list|runs>")} ${import_picocolors84.default.dim("read eval definitions and judge verdicts (`agent eval --help`)")}`);
|
|
99419
|
+
out.push(` ${import_picocolors84.default.cyan("agent env")} ${import_picocolors84.default.dim("print export lines for `eval $(brainbase agent env)`")}`);
|
|
99420
|
+
out.push(` ${import_picocolors84.default.cyan("run")} ${import_picocolors84.default.dim("<cmd> [args...]")} ${import_picocolors84.default.dim("run <cmd> with secrets.env loaded into env")}`);
|
|
99421
|
+
out.push(` ${import_picocolors84.default.cyan("status")} ${import_picocolors84.default.dim("show what this folder is linked to")}`);
|
|
99422
|
+
out.push(` ${import_picocolors84.default.cyan("unlink")} ${import_picocolors84.default.dim("disconnect this folder")}`);
|
|
98901
99423
|
out.push("");
|
|
98902
99424
|
out.push(divider("TASKS"));
|
|
98903
99425
|
out.push("");
|
|
98904
|
-
out.push(` ${
|
|
98905
|
-
out.push(` ${
|
|
98906
|
-
out.push(` ${
|
|
98907
|
-
out.push(` ${
|
|
98908
|
-
out.push(` ${
|
|
98909
|
-
out.push(` ${
|
|
98910
|
-
out.push(` ${
|
|
98911
|
-
out.push(` ${
|
|
99426
|
+
out.push(` ${import_picocolors84.default.cyan("task create")} ${import_picocolors84.default.dim("--message <text>")} ${import_picocolors84.default.dim("create a managed task and start its first run (--wait to block on it; --interface <id> for a build conversation)")}`);
|
|
99427
|
+
out.push(` ${import_picocolors84.default.cyan("task list")} ${import_picocolors84.default.dim("recent tasks you can reach (--metadata k=v to filter by label; --interface <id> for its build conversations)")}`);
|
|
99428
|
+
out.push(` ${import_picocolors84.default.cyan("task get")} ${import_picocolors84.default.dim("<task-id>")} ${import_picocolors84.default.dim("one task: status, agent, machine, eval verdicts")}`);
|
|
99429
|
+
out.push(` ${import_picocolors84.default.cyan("task logs")} ${import_picocolors84.default.dim("<task-id> [--follow]")} ${import_picocolors84.default.dim("one line per event in the task's transcript, or tail it live")}`);
|
|
99430
|
+
out.push(` ${import_picocolors84.default.cyan("task send")} ${import_picocolors84.default.dim("<task-id> <message>")} ${import_picocolors84.default.dim("send a follow-up during execution, or queue it for the next turn")}`);
|
|
99431
|
+
out.push(` ${import_picocolors84.default.cyan("task stop")} ${import_picocolors84.default.dim("<task-id>")} ${import_picocolors84.default.dim("stop execution and cancel pending follow-ups, retaining their text")}`);
|
|
99432
|
+
out.push(` ${import_picocolors84.default.cyan("task update")} ${import_picocolors84.default.dim("<task-id>")} ${import_picocolors84.default.dim("rename a task, change its metadata labels, switch its model or reset it to the agent default, including while it runs")}`);
|
|
99433
|
+
out.push(` ${import_picocolors84.default.cyan("task delete")} ${import_picocolors84.default.dim("<task-id>")} ${import_picocolors84.default.dim("permanently delete a stopped task and tear down its sandbox")}`);
|
|
98912
99434
|
out.push("");
|
|
98913
99435
|
out.push(divider("INTERFACES"));
|
|
98914
99436
|
out.push("");
|
|
98915
|
-
out.push(` ${
|
|
98916
|
-
out.push(` ${
|
|
98917
|
-
out.push(` ${
|
|
98918
|
-
out.push(` ${
|
|
98919
|
-
out.push(` ${
|
|
98920
|
-
out.push(` ${
|
|
98921
|
-
out.push(` ${
|
|
99437
|
+
out.push(` ${import_picocolors84.default.cyan("interface ls")} ${import_picocolors84.default.dim("dashboards you can see (--agent to narrow)")}`);
|
|
99438
|
+
out.push(` ${import_picocolors84.default.cyan("interface create")} ${import_picocolors84.default.dim("--name <n>")} ${import_picocolors84.default.dim("create one on an agent, with who can open it")}`);
|
|
99439
|
+
out.push(` ${import_picocolors84.default.cyan("interface build")} ${import_picocolors84.default.dim('<id> "<ask>"')} ${import_picocolors84.default.dim("describe a change; the agent builds it while you watch")}`);
|
|
99440
|
+
out.push(` ${import_picocolors84.default.cyan("interface publish")} ${import_picocolors84.default.dim("<id>")} ${import_picocolors84.default.dim("make the newest succeeded build live")}`);
|
|
99441
|
+
out.push(` ${import_picocolors84.default.cyan("interface rollback")} ${import_picocolors84.default.dim("<id>")} ${import_picocolors84.default.dim("republish an earlier release under a new id (--release <id>)")}`);
|
|
99442
|
+
out.push(` ${import_picocolors84.default.cyan("interface access")} ${import_picocolors84.default.dim("<id>")} ${import_picocolors84.default.dim("show or set who can open it")}`);
|
|
99443
|
+
out.push(` ${import_picocolors84.default.cyan("interface --help")} ${import_picocolors84.default.dim("every interface subcommand")}`);
|
|
98922
99444
|
out.push("");
|
|
98923
99445
|
out.push(divider("SANDBOXES"));
|
|
98924
99446
|
out.push("");
|
|
98925
|
-
out.push(` ${
|
|
98926
|
-
out.push(` ${
|
|
99447
|
+
out.push(` ${import_picocolors84.default.cyan("machine ls")} ${import_picocolors84.default.dim("[--all]")} ${import_picocolors84.default.dim("list your sandboxes — live ones only unless --all")}`);
|
|
99448
|
+
out.push(` ${import_picocolors84.default.cyan("machine rm")} ${import_picocolors84.default.dim("<id>")} ${import_picocolors84.default.dim("tear a sandbox down (it bills until you do)")}`);
|
|
98927
99449
|
out.push("");
|
|
98928
99450
|
out.push(divider("BENCHMARKS"));
|
|
98929
99451
|
out.push("");
|
|
98930
|
-
out.push(` ${
|
|
98931
|
-
out.push(` ${
|
|
98932
|
-
out.push(` ${
|
|
98933
|
-
out.push(` ${
|
|
98934
|
-
out.push(` ${
|
|
99452
|
+
out.push(` ${import_picocolors84.default.cyan("benchmark list")} ${import_picocolors84.default.dim("list benchmarks for the linked agent")}`);
|
|
99453
|
+
out.push(` ${import_picocolors84.default.cyan("benchmark init")} ${import_picocolors84.default.dim("[directory]")} ${import_picocolors84.default.dim("scaffold a local benchmark")}`);
|
|
99454
|
+
out.push(` ${import_picocolors84.default.cyan("benchmark create")} ${import_picocolors84.default.dim("[path|-]")} ${import_picocolors84.default.dim("create a benchmark draft")}`);
|
|
99455
|
+
out.push(` ${import_picocolors84.default.cyan("benchmark run")} ${import_picocolors84.default.dim("<benchmark> --yes")} ${import_picocolors84.default.dim("plan and start a benchmark run")}`);
|
|
99456
|
+
out.push(` ${import_picocolors84.default.cyan("benchmark results")} ${import_picocolors84.default.dim("<run>")} ${import_picocolors84.default.dim("inspect normalized benchmark results")}`);
|
|
98935
99457
|
out.push("");
|
|
98936
99458
|
out.push(divider("BENCHMARK RUNTIME"));
|
|
98937
99459
|
out.push("");
|
|
98938
|
-
out.push(` ${
|
|
98939
|
-
out.push(` ${
|
|
98940
|
-
out.push(` ${
|
|
99460
|
+
out.push(` ${import_picocolors84.default.cyan("benchmark hydrate")} ${import_picocolors84.default.dim("--spec <path> --result <path> --json")}`);
|
|
99461
|
+
out.push(` ${import_picocolors84.default.cyan("benchmark evaluate")} ${import_picocolors84.default.dim("--spec <path> --result <path> --json")}`);
|
|
99462
|
+
out.push(` ${import_picocolors84.default.cyan("benchmark capabilities")} ${import_picocolors84.default.dim("--json")}`);
|
|
98941
99463
|
out.push("");
|
|
98942
99464
|
out.push(divider("ORCHESTRATIONS"));
|
|
98943
99465
|
out.push("");
|
|
98944
|
-
out.push(` ${
|
|
98945
|
-
out.push(` ${
|
|
98946
|
-
out.push(` ${
|
|
98947
|
-
out.push(` ${
|
|
98948
|
-
out.push(` ${
|
|
98949
|
-
out.push(` ${
|
|
98950
|
-
out.push(` ${
|
|
99466
|
+
out.push(` ${import_picocolors84.default.cyan("orchestration init")} ${import_picocolors84.default.dim("write a starter brainbase-orchestration.yaml here (offline, no login)")}`);
|
|
99467
|
+
out.push(` ${import_picocolors84.default.cyan("orchestration create")} ${import_picocolors84.default.dim("claim a local orchestration manifest and create it in the cloud")}`);
|
|
99468
|
+
out.push(` ${import_picocolors84.default.cyan("orchestration from-agent")} ${import_picocolors84.default.dim("turn an existing agent into an orchestration")}`);
|
|
99469
|
+
out.push(` ${import_picocolors84.default.cyan("orchestration list")} ${import_picocolors84.default.dim("list orchestrations under a team")}`);
|
|
99470
|
+
out.push(` ${import_picocolors84.default.cyan("orchestration pull")} ${import_picocolors84.default.dim("<id>")} ${import_picocolors84.default.dim("recursively fetch an orchestration + every member agent")}`);
|
|
99471
|
+
out.push(` ${import_picocolors84.default.cyan("orchestration push")} ${import_picocolors84.default.dim("recursively push each member, then update the graph")}`);
|
|
99472
|
+
out.push(` ${import_picocolors84.default.cyan("orchestration status")} ${import_picocolors84.default.dim("show what would push and what would pull")}`);
|
|
99473
|
+
out.push(` ${import_picocolors84.default.cyan("orchestration delete")} ${import_picocolors84.default.dim("<id>")} ${import_picocolors84.default.dim("permanently delete an orchestration graph (member agents are kept)")}`);
|
|
98951
99474
|
out.push("");
|
|
98952
99475
|
out.push(divider("TEMPLATES"));
|
|
98953
99476
|
out.push("");
|
|
98954
|
-
out.push(` ${
|
|
98955
|
-
out.push(` ${
|
|
98956
|
-
out.push(` ${
|
|
98957
|
-
out.push(` ${
|
|
98958
|
-
out.push(` ${
|
|
98959
|
-
out.push(` ${
|
|
98960
|
-
out.push(` ${
|
|
99477
|
+
out.push(` ${import_picocolors84.default.cyan("template pack")} ${import_picocolors84.default.dim("bundle the current agent into a template")}`);
|
|
99478
|
+
out.push(` ${import_picocolors84.default.cyan("template publish")} ${import_picocolors84.default.dim("upload a template to the registry")}`);
|
|
99479
|
+
out.push(` ${import_picocolors84.default.cyan("template search")} ${import_picocolors84.default.dim("[query]")} ${import_picocolors84.default.dim("search the registry")}`);
|
|
99480
|
+
out.push(` ${import_picocolors84.default.cyan("template info")} ${import_picocolors84.default.dim("<creator/slug>")} ${import_picocolors84.default.dim("show registry details for a template")}`);
|
|
99481
|
+
out.push(` ${import_picocolors84.default.cyan("template onboard")} ${import_picocolors84.default.dim("<creator/slug>")} ${import_picocolors84.default.dim("install (or refresh) a template")}`);
|
|
99482
|
+
out.push(` ${import_picocolors84.default.cyan("template list")} ${import_picocolors84.default.dim("show installed templates")}`);
|
|
99483
|
+
out.push(` ${import_picocolors84.default.cyan("template remove")} ${import_picocolors84.default.dim("<creator/slug>")} ${import_picocolors84.default.dim("uninstall a template")}`);
|
|
98961
99484
|
out.push("");
|
|
98962
99485
|
out.push(divider("SKILLS"));
|
|
98963
99486
|
out.push("");
|
|
98964
|
-
out.push(` ${
|
|
98965
|
-
out.push(` ${
|
|
98966
|
-
out.push(` ${
|
|
98967
|
-
out.push(` ${
|
|
98968
|
-
out.push(` ${
|
|
98969
|
-
out.push(` ${
|
|
98970
|
-
out.push(` ${
|
|
99487
|
+
out.push(` ${import_picocolors84.default.cyan("skill add")} ${import_picocolors84.default.dim("<source>")} ${import_picocolors84.default.dim("install a skill (github / git / brainbase)")}`);
|
|
99488
|
+
out.push(` ${import_picocolors84.default.cyan("skill list")} ${import_picocolors84.default.dim("show locally installed skills + their source")}`);
|
|
99489
|
+
out.push(` ${import_picocolors84.default.cyan("skill update")} ${import_picocolors84.default.dim("<slug>")} ${import_picocolors84.default.dim("re-fetch a skill from its recorded source")}`);
|
|
99490
|
+
out.push(` ${import_picocolors84.default.cyan("skill remove")} ${import_picocolors84.default.dim("<slug>")} ${import_picocolors84.default.dim("uninstall a skill")}`);
|
|
99491
|
+
out.push(` ${import_picocolors84.default.cyan("skill search")} ${import_picocolors84.default.dim("[query]")} ${import_picocolors84.default.dim("search the brainbase skill registry")}`);
|
|
99492
|
+
out.push(` ${import_picocolors84.default.cyan("skill info")} ${import_picocolors84.default.dim("<creator/slug>")} ${import_picocolors84.default.dim("show registry details for a skill")}`);
|
|
99493
|
+
out.push(` ${import_picocolors84.default.cyan("skill publish")} ${import_picocolors84.default.dim("[dir]")} ${import_picocolors84.default.dim("publish a SKILL.md folder (defaults to .)")}`);
|
|
98971
99494
|
out.push("");
|
|
98972
99495
|
out.push(divider("CLI TOKENS"));
|
|
98973
99496
|
out.push("");
|
|
98974
|
-
out.push(` ${
|
|
98975
|
-
out.push(` ${
|
|
98976
|
-
out.push(` ${
|
|
98977
|
-
out.push(` ${
|
|
99497
|
+
out.push(` ${import_picocolors84.default.cyan("token create")} ${import_picocolors84.default.dim("issue a long-lived CLI key for CI / scripts")}`);
|
|
99498
|
+
out.push(` ${import_picocolors84.default.cyan("token list")} ${import_picocolors84.default.dim("show your tokens")}`);
|
|
99499
|
+
out.push(` ${import_picocolors84.default.cyan("token rename")} ${import_picocolors84.default.dim("<id>")} ${import_picocolors84.default.dim("relabel a token")}`);
|
|
99500
|
+
out.push(` ${import_picocolors84.default.cyan("token revoke")} ${import_picocolors84.default.dim("<id>")} ${import_picocolors84.default.dim("revoke a token")}`);
|
|
98978
99501
|
out.push("");
|
|
98979
99502
|
out.push(divider("DECISIONS"));
|
|
98980
99503
|
out.push("");
|
|
98981
|
-
out.push(` ${
|
|
99504
|
+
out.push(` ${import_picocolors84.default.cyan("decide")} ${import_picocolors84.default.dim("-q <questions.json> <sources...>")} ${import_picocolors84.default.dim("answer decision-model questions over many files or rows in a few requests (`decide --help`)")}`);
|
|
98982
99505
|
out.push("");
|
|
98983
99506
|
out.push(divider("MCP"));
|
|
98984
99507
|
out.push("");
|
|
98985
|
-
out.push(` ${
|
|
98986
|
-
out.push(` ${
|
|
98987
|
-
out.push(` ${
|
|
99508
|
+
out.push(` ${import_picocolors84.default.cyan("mcp check")} ${import_picocolors84.default.dim("[--json]")} ${import_picocolors84.default.dim("verify MCP server connectivity through the brainbase proxy (runs at sandbox bootstrap)")}`);
|
|
99509
|
+
out.push(` ${import_picocolors84.default.cyan("mcp list")} ${import_picocolors84.default.dim("[--json]")} ${import_picocolors84.default.dim("show configured servers with OAuth state and expiry")}`);
|
|
99510
|
+
out.push(` ${import_picocolors84.default.cyan("mcp connect")} ${import_picocolors84.default.dim("<name>")} ${import_picocolors84.default.dim("authorize an OAuth-backed server: prints a single-use link, opens it, waits for approval")}`);
|
|
98988
99511
|
out.push("");
|
|
98989
99512
|
out.push(divider("INTEGRATIONS"));
|
|
98990
99513
|
out.push("");
|
|
98991
|
-
out.push(` ${
|
|
98992
|
-
out.push(` ${
|
|
98993
|
-
out.push(` ${
|
|
98994
|
-
out.push(` ${
|
|
98995
|
-
out.push(` ${
|
|
98996
|
-
out.push(` ${
|
|
98997
|
-
out.push(` ${
|
|
98998
|
-
out.push(` ${
|
|
98999
|
-
out.push(` ${
|
|
99000
|
-
out.push(` ${
|
|
99514
|
+
out.push(` ${import_picocolors84.default.cyan("integrations list")} ${import_picocolors84.default.dim("show the agent's Pipedream apps, accounts and app-level permission")}`);
|
|
99515
|
+
out.push(` ${import_picocolors84.default.cyan("integrations search")} ${import_picocolors84.default.dim("<query>")} ${import_picocolors84.default.dim("find apps in the Pipedream catalog")}`);
|
|
99516
|
+
out.push(` ${import_picocolors84.default.cyan("integrations actions")} ${import_picocolors84.default.dim("<app>")} ${import_picocolors84.default.dim("list an app's actions and whether each is allowed")}`);
|
|
99517
|
+
out.push(` ${import_picocolors84.default.cyan("integrations add")} ${import_picocolors84.default.dim("<app>")} ${import_picocolors84.default.dim("install an app; one that needs an account runs connect")}`);
|
|
99518
|
+
out.push(` ${import_picocolors84.default.cyan("integrations connect")} ${import_picocolors84.default.dim("<app>")} ${import_picocolors84.default.dim("open Pipedream's connect page for the app and wait for the account")}`);
|
|
99519
|
+
out.push(` ${import_picocolors84.default.cyan("integrations disconnect")} ${import_picocolors84.default.dim("<app>")} ${import_picocolors84.default.dim("delete the app's connected account")}`);
|
|
99520
|
+
out.push(` ${import_picocolors84.default.cyan("integrations remove")} ${import_picocolors84.default.dim("<app>")} ${import_picocolors84.default.dim("uninstall an app that needs no account")}`);
|
|
99521
|
+
out.push(` ${import_picocolors84.default.cyan("integrations allow|ask|deny")} ${import_picocolors84.default.dim("<app>[.<action>]")} ${import_picocolors84.default.dim("set the permission for an app or one of its actions")}`);
|
|
99522
|
+
out.push(` ${import_picocolors84.default.cyan("integrations context create")} ${import_picocolors84.default.dim("--application <name>")} ${import_picocolors84.default.dim("let a program outside Brainbase (the SDK) use the agent's integrations; prints a renewal handle once")}`);
|
|
99523
|
+
out.push(` ${import_picocolors84.default.cyan("integrations context end")} ${import_picocolors84.default.dim("<context-id>")} ${import_picocolors84.default.dim("end a standalone integration context now")}`);
|
|
99001
99524
|
out.push("");
|
|
99002
99525
|
out.push(divider("FLAGS"));
|
|
99003
99526
|
out.push("");
|
|
99004
|
-
out.push(` ${
|
|
99005
|
-
out.push(` ${
|
|
99006
|
-
out.push(` ${
|
|
99527
|
+
out.push(` ${import_picocolors84.default.dim("--harness <id>")} force harness for onboard / sync (e.g. claude-code)`);
|
|
99528
|
+
out.push(` ${import_picocolors84.default.dim("--scope <s>")} force scope: global | project`);
|
|
99529
|
+
out.push(` ${import_picocolors84.default.dim("--yes, -y")} skip confirmations / auto-overwrite`);
|
|
99007
99530
|
out.push(` ${" ".repeat("--yes, -y".length)} required for destructive commands with no terminal (pipes, CI)`);
|
|
99008
|
-
out.push(` ${
|
|
99009
|
-
out.push(` ${
|
|
99010
|
-
out.push(` ${
|
|
99011
|
-
out.push(` ${
|
|
99012
|
-
out.push(` ${
|
|
99013
|
-
out.push(` ${
|
|
99014
|
-
out.push(` ${
|
|
99015
|
-
out.push(` ${
|
|
99016
|
-
out.push(` ${
|
|
99017
|
-
out.push(` ${
|
|
99018
|
-
out.push(` ${
|
|
99019
|
-
out.push(` ${
|
|
99020
|
-
out.push(` ${
|
|
99021
|
-
out.push(` ${
|
|
99022
|
-
out.push(` ${
|
|
99023
|
-
out.push(` ${
|
|
99024
|
-
out.push(` ${
|
|
99025
|
-
out.push(` ${
|
|
99026
|
-
out.push(` ${
|
|
99027
|
-
out.push(` ${
|
|
99028
|
-
out.push(` ${
|
|
99029
|
-
out.push(` ${
|
|
99030
|
-
out.push(` ${
|
|
99031
|
-
out.push(` ${
|
|
99032
|
-
out.push(` ${
|
|
99033
|
-
out.push(` ${
|
|
99034
|
-
out.push(` ${
|
|
99035
|
-
out.push(` ${
|
|
99036
|
-
out.push(` ${
|
|
99037
|
-
out.push(` ${
|
|
99038
|
-
out.push(` ${
|
|
99039
|
-
out.push(` ${
|
|
99040
|
-
out.push(` ${
|
|
99041
|
-
out.push(` ${
|
|
99042
|
-
out.push(` ${
|
|
99043
|
-
out.push(` ${
|
|
99044
|
-
out.push(` ${
|
|
99531
|
+
out.push(` ${import_picocolors84.default.dim("--agent <id>")} for link/task create/mcp list/mcp connect/integrations: use this agent id explicitly instead of the linked folder's (task list: filter to it)`);
|
|
99532
|
+
out.push(` ${import_picocolors84.default.dim("--message <text>")} for task create: required first user message`);
|
|
99533
|
+
out.push(` ${import_picocolors84.default.dim("--title <text>")} for task create: optional task title; for task update: the new title`);
|
|
99534
|
+
out.push(` ${import_picocolors84.default.dim("--clear-title")} for task update: remove the title (automatic titling may name it again later)`);
|
|
99535
|
+
out.push(` ${import_picocolors84.default.dim("--metadata k=v")} for task create: label the task; for task list: only tasks with this label; for task update: set one label, keeping the others (all repeatable)`);
|
|
99536
|
+
out.push(` ${import_picocolors84.default.dim("--unset-metadata <k>")} for task update: remove one label (repeatable)`);
|
|
99537
|
+
out.push(` ${import_picocolors84.default.dim("--clear-metadata")} for task update: remove every label; with --metadata, keep only those given`);
|
|
99538
|
+
out.push(` ${import_picocolors84.default.dim("--model <id>")} for task create: optional model override; for task update: switch the model the task's next turn runs on (the running turn keeps its model)`);
|
|
99539
|
+
out.push(` ${import_picocolors84.default.dim("--clear-model")} for task update: go back to the agent's default model from the next turn`);
|
|
99540
|
+
out.push(` ${import_picocolors84.default.dim("--version <v>")} for task create: run a saved version of the agent (12, v12 or a version id)`);
|
|
99541
|
+
out.push(` ${import_picocolors84.default.dim("--wait")} for task create: block until the task finishes; exit 1 unless it succeeded`);
|
|
99542
|
+
out.push(` ${import_picocolors84.default.dim("--timeout <secs>")} for task create --wait: give up after <secs> and exit 1`);
|
|
99543
|
+
out.push(` ${import_picocolors84.default.dim("--limit <n>")} for task list (1-200), task logs (events to print; with --follow, the first page size) and machine ls`);
|
|
99544
|
+
out.push(` ${import_picocolors84.default.dim("--follow, -f")} for task logs: stay attached and print events as they land`);
|
|
99545
|
+
out.push(` ${import_picocolors84.default.dim("--org <id-or-slug>")} pick the organization (team/agent list, agent create, orchestration create/list)`);
|
|
99546
|
+
out.push(` ${import_picocolors84.default.dim("--team <id>")} pick the team, same commands (works without --org)`);
|
|
99547
|
+
out.push(` ${import_picocolors84.default.dim("--all-teams")} for agent list: every team in the org (the default with no terminal)`);
|
|
99548
|
+
out.push(` ${import_picocolors84.default.dim("--json")} machine-readable output for supported commands`);
|
|
99549
|
+
out.push(` ${import_picocolors84.default.dim("--no-tracking")} for link / agent pull --link: skip routing LLM traffic through brainbase`);
|
|
99550
|
+
out.push(` ${import_picocolors84.default.dim("--link")} for agent pull: link this folder to the agent first, as \`brainbase link --agent <id> --yes\` would, in one process`);
|
|
99551
|
+
out.push(` ${import_picocolors84.default.dim("--track")} for agent create: enable tracking non-interactively (off without a TTY)`);
|
|
99552
|
+
out.push(` ${import_picocolors84.default.dim("--shell <sh|fish>")} for agent env: pick output format (auto-detected from $SHELL)`);
|
|
99553
|
+
out.push(` ${import_picocolors84.default.dim("--bot-token <t>")} for agent connect slack (or BRAINBASE_SLACK_BOT_TOKEN, or stdin)`);
|
|
99554
|
+
out.push(` ${import_picocolors84.default.dim("--signing-secret <s>")} for agent connect slack (or BRAINBASE_SLACK_SIGNING_SECRET, or stdin)`);
|
|
99555
|
+
out.push(` ${import_picocolors84.default.dim("--bot-name <name>")} for agent connect meeting: the bot's display name`);
|
|
99556
|
+
out.push(` ${import_picocolors84.default.dim("--app-id <id> / --app-name <name>")} optional Slack app identity`);
|
|
99557
|
+
out.push(` ${import_picocolors84.default.dim("--bot-image-url <url>")} optional meeting bot image`);
|
|
99558
|
+
out.push(` ${import_picocolors84.default.dim("--full")} for agent/orchestration init: write a commented template covering every block`);
|
|
99559
|
+
out.push(` ${import_picocolors84.default.dim("--minimal")} for agent init: write the starter manifest (the default)`);
|
|
99560
|
+
out.push(` ${import_picocolors84.default.dim("--all")} for template list: include installs from other folders; for machine ls: include torn-down machines`);
|
|
99561
|
+
out.push(` ${import_picocolors84.default.dim("--web <url>")} for login: web app URL (default https://app.brainbaselabs.com)`);
|
|
99562
|
+
out.push(` ${import_picocolors84.default.dim("--no-open")} for mcp/integrations connect: print the link without opening a browser (implied with no terminal)`);
|
|
99563
|
+
out.push(` ${import_picocolors84.default.dim("--no-wait")} for mcp/integrations connect: print the link and exit instead of waiting`);
|
|
99564
|
+
out.push(` ${import_picocolors84.default.dim("--account <id>")} for integrations disconnect: which account, when the app has more than one`);
|
|
99565
|
+
out.push(` ${import_picocolors84.default.dim("--application <name>")} for integrations context create: names the program the context is for`);
|
|
99566
|
+
out.push(` ${import_picocolors84.default.dim("--max-lifetime <dur>")} for integrations context create: when the context ends at the latest, 60s-30d (default 7d)`);
|
|
99567
|
+
out.push(` ${import_picocolors84.default.dim("--reason <text>")} for integrations context end: recorded with the context`);
|
|
99045
99568
|
out.push("");
|
|
99046
99569
|
out.push(divider("ENV"));
|
|
99047
99570
|
out.push("");
|
|
99048
|
-
out.push(` ${
|
|
99049
|
-
out.push(` ${
|
|
99050
|
-
out.push(` ${
|
|
99051
|
-
out.push(` ${
|
|
99052
|
-
out.push(` ${
|
|
99053
|
-
out.push(` ${
|
|
99054
|
-
out.push(` ${
|
|
99055
|
-
out.push(` ${
|
|
99056
|
-
out.push(` ${
|
|
99057
|
-
out.push(` ${
|
|
99058
|
-
out.push(` ${
|
|
99571
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_HOME")} override the local config dir (default ~/.brainbase)`);
|
|
99572
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_DEBUG")} print full stack traces on error (any value; unset to disable)`);
|
|
99573
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_WEB_URL")} override the web app URL used by login, console links and integrations`);
|
|
99574
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_CONTROL_PLANE_URL")} override the MAS host (/v2/cli; task and interface commands use /v2/tasks and /v2/interfaces)`);
|
|
99575
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_API_URL")} legacy KLS host override (uses /api/cli; proxy/registry fallback)`);
|
|
99576
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_PROXY_URL")} override the model-proxy URL used by harness traffic (default https://api.v1.brainbaselabs.com)`);
|
|
99577
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_REGISTRY_URL")} override the registry API URL (default https://api.v1.brainbaselabs.com)`);
|
|
99578
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_TOKEN")} long-lived CLI PAT; outranks the login session and the PAT saved in token.json`);
|
|
99579
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_SKIP_AUTH")} bypass the auth gate for development`);
|
|
99580
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_NON_INTERACTIVE")} force non-interactive mode — skip/auto-default prompts (CI & agents)`);
|
|
99581
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_RUN_ENTRYPOINT")} =1 → agent pull executes the agent entrypoint (sandbox boots; or pass --run-entrypoint)`);
|
|
99059
99582
|
out.push("");
|
|
99060
|
-
out.push(` ${
|
|
99061
|
-
out.push(` ${
|
|
99062
|
-
out.push(` ${
|
|
99063
|
-
out.push(` ${
|
|
99064
|
-
out.push(` ${
|
|
99065
|
-
out.push(` ${
|
|
99066
|
-
out.push(` ${
|
|
99583
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_MEMORY_MCP_URL")} override the built-in memory MCP host`);
|
|
99584
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_BROWSER_MCP_URL")} override the built-in browser MCP host`);
|
|
99585
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_SLACK_MCP_URL")} override the built-in Slack MCP host`);
|
|
99586
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_MEETING_MCP_URL")} override the built-in meeting MCP host`);
|
|
99587
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_GITHUB_MCP_URL")} override the built-in GitHub MCP host`);
|
|
99588
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_LINEAR_MCP_URL")} override the built-in Linear MCP host`);
|
|
99589
|
+
out.push(` ${import_picocolors84.default.dim("BRAINBASE_ORCHESTRATION_MCP_URL")} override the built-in orchestration MCP host`);
|
|
99067
99590
|
out.push("");
|
|
99068
99591
|
out.push(divider("HARNESSES"));
|
|
99069
99592
|
out.push("");
|
|
99070
|
-
out.push(` ${
|
|
99071
|
-
out.push(` ${
|
|
99072
|
-
out.push(` ${
|
|
99593
|
+
out.push(` ${import_picocolors84.default.dim("•")} ${import_picocolors84.default.bold("claude-code")} ${import_picocolors84.default.dim("skills, mcps, agents, commands, playbooks, instructions, files")}`);
|
|
99594
|
+
out.push(` ${import_picocolors84.default.dim("•")} ${import_picocolors84.default.bold("codex")} ${import_picocolors84.default.dim("skills, mcps, commands, playbooks, instructions, files")}`);
|
|
99595
|
+
out.push(` ${import_picocolors84.default.dim("•")} ${import_picocolors84.default.bold("kafka")} ${import_picocolors84.default.dim("skills, mcps, agents, commands, playbooks, instructions, files")}`);
|
|
99073
99596
|
out.push("");
|
|
99074
99597
|
console.log(out.join(`
|
|
99075
99598
|
`));
|
|
@@ -99138,7 +99661,7 @@ function takeFlagOnce(args, names) {
|
|
|
99138
99661
|
return best.joinedValue;
|
|
99139
99662
|
}
|
|
99140
99663
|
const v3 = args[best.index + 1];
|
|
99141
|
-
if (v3 && !v3.startsWith("-")) {
|
|
99664
|
+
if (v3 !== undefined && !v3.startsWith("-")) {
|
|
99142
99665
|
args.splice(best.index, 2);
|
|
99143
99666
|
return v3;
|
|
99144
99667
|
}
|
|
@@ -99227,10 +99750,10 @@ async function requireAuth(cmd) {
|
|
|
99227
99750
|
if (storedPatFor(status.session))
|
|
99228
99751
|
return;
|
|
99229
99752
|
console.error("");
|
|
99230
|
-
console.error(` ${brandTint("◆")} ${
|
|
99753
|
+
console.error(` ${brandTint("◆")} ${import_picocolors84.default.bold("brainbase")}`);
|
|
99231
99754
|
console.error("");
|
|
99232
|
-
console.error(` ${
|
|
99233
|
-
console.error(` ${
|
|
99755
|
+
console.error(` ${import_picocolors84.default.red("✗")} You need to sign in to use ${import_picocolors84.default.bold("brainbase " + cmd)}.`);
|
|
99756
|
+
console.error(` ${import_picocolors84.default.dim(noUsableCredentialMessage())}`);
|
|
99234
99757
|
console.error("");
|
|
99235
99758
|
process14.exit(1);
|
|
99236
99759
|
}
|
|
@@ -99520,10 +100043,10 @@ ${didYouMean(cmd, COMMANDS3, "brainbase")}`);
|
|
|
99520
100043
|
} catch (err) {
|
|
99521
100044
|
const message3 = sanitizeLines(err.message).join(`
|
|
99522
100045
|
`);
|
|
99523
|
-
console.error(
|
|
100046
|
+
console.error(import_picocolors84.default.red(`
|
|
99524
100047
|
${message3}`));
|
|
99525
100048
|
if (err instanceof ApiError && err.status === 401 && !err.message.includes("brainbase login")) {
|
|
99526
|
-
console.error(` Run ${
|
|
100049
|
+
console.error(` Run ${import_picocolors84.default.cyan("brainbase login")} to connect this device.`);
|
|
99527
100050
|
}
|
|
99528
100051
|
if (process14.env.BRAINBASE_DEBUG)
|
|
99529
100052
|
console.error(err.stack);
|