@brainbase-labs/cli 0.52.0 → 0.54.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 +877 -499
- 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_picocolors81 = __toESM(require_picocolors(), 1);
|
|
35186
35186
|
import process14 from "node:process";
|
|
35187
35187
|
import fs94 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.54.0",
|
|
36095
36095
|
description: "Pack, share, and install agent templates across harnesses (Claude Code, Codex, ...).",
|
|
36096
36096
|
type: "module",
|
|
36097
36097
|
bin: {
|
|
@@ -67885,8 +67885,13 @@ function automationErrorEnvelope(command, error) {
|
|
|
67885
67885
|
};
|
|
67886
67886
|
}
|
|
67887
67887
|
|
|
67888
|
-
// src/
|
|
67889
|
-
|
|
67888
|
+
// src/ui/terminal-safe.ts
|
|
67889
|
+
function sanitizeLabel(s3) {
|
|
67890
|
+
return s3.replace(/\u001b\][\s\S]*?(?:\u0007|\u001b\\|$)/g, "").replace(/\u001b\[[\u0030-\u003f]*[\u0020-\u002f]*[\u0040-\u007e]?/g, "").replace(/\u001b[\s\S]?/g, "").replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g, "");
|
|
67891
|
+
}
|
|
67892
|
+
function sanitizeLines(s3) {
|
|
67893
|
+
return s3.split(/\r\n|[\n\r\u2028\u2029]/).map(sanitizeLabel);
|
|
67894
|
+
}
|
|
67890
67895
|
|
|
67891
67896
|
// src/core/fastapi-detail.ts
|
|
67892
67897
|
function record(value) {
|
|
@@ -67896,19 +67901,22 @@ function fastApiDetails(body) {
|
|
|
67896
67901
|
const detail = record(body)?.detail;
|
|
67897
67902
|
return Array.isArray(detail) ? detail.filter((entry) => !!record(entry)) : [];
|
|
67898
67903
|
}
|
|
67904
|
+
function fastApiValidationMessage(body) {
|
|
67905
|
+
const parts = fastApiDetails(body).map((entry) => {
|
|
67906
|
+
const msg = typeof entry.msg === "string" ? sanitizeLabel(entry.msg.trim()) : "";
|
|
67907
|
+
if (!msg)
|
|
67908
|
+
return null;
|
|
67909
|
+
const loc = Array.isArray(entry.loc) ? sanitizeLabel(entry.loc.filter((part) => part !== "body").map(String).join(".")) : "";
|
|
67910
|
+
return loc ? `${loc}: ${msg}` : msg;
|
|
67911
|
+
}).filter((part) => !!part);
|
|
67912
|
+
return parts.length ? parts.join("; ") : null;
|
|
67913
|
+
}
|
|
67899
67914
|
function rejectsBodyField(body, field) {
|
|
67900
67915
|
return fastApiDetails(body).some((entry) => entry.type === "extra_forbidden" && Array.isArray(entry.loc) && entry.loc[0] === "body" && entry.loc[1] === field);
|
|
67901
67916
|
}
|
|
67902
67917
|
|
|
67903
|
-
// src/ui/terminal-safe.ts
|
|
67904
|
-
function sanitizeLabel(s3) {
|
|
67905
|
-
return s3.replace(/\u001b\][\s\S]*?(?:\u0007|\u001b\\|$)/g, "").replace(/\u001b\[[\u0030-\u003f]*[\u0020-\u002f]*[\u0040-\u007e]?/g, "").replace(/\u001b[\s\S]?/g, "").replace(/[\u0000-\u001f\u007f-\u009f\u2028\u2029]/g, "");
|
|
67906
|
-
}
|
|
67907
|
-
function sanitizeLines(s3) {
|
|
67908
|
-
return s3.split(/\r\n|[\n\r\u2028\u2029]/).map(sanitizeLabel);
|
|
67909
|
-
}
|
|
67910
|
-
|
|
67911
67918
|
// src/core/interfaces-api.ts
|
|
67919
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
67912
67920
|
function isSettled(status) {
|
|
67913
67921
|
return status === "succeeded" || status === "failed";
|
|
67914
67922
|
}
|
|
@@ -68022,17 +68030,7 @@ function clean(value) {
|
|
|
68022
68030
|
`);
|
|
68023
68031
|
}
|
|
68024
68032
|
function fieldMessages(fields) {
|
|
68025
|
-
|
|
68026
|
-
return null;
|
|
68027
|
-
const parts = fields.map((entry) => {
|
|
68028
|
-
const item = record2(entry);
|
|
68029
|
-
if (!item)
|
|
68030
|
-
return null;
|
|
68031
|
-
const loc = Array.isArray(item.loc) ? sanitizeLabel(item.loc.filter((part) => part !== "body").map(String).join(".")) : "";
|
|
68032
|
-
const msg = text2(item.msg);
|
|
68033
|
-
return msg ? loc ? `${loc}: ${sanitizeLabel(msg)}` : sanitizeLabel(msg) : null;
|
|
68034
|
-
}).filter((part) => !!part);
|
|
68035
|
-
return parts.length ? parts.join("; ") : null;
|
|
68033
|
+
return fastApiValidationMessage({ detail: fields });
|
|
68036
68034
|
}
|
|
68037
68035
|
function toInterfaceError(error, options = {}) {
|
|
68038
68036
|
if (error instanceof InterfaceApiError || !(error instanceof ApiError))
|
|
@@ -68082,9 +68080,8 @@ function toInterfaceError(error, options = {}) {
|
|
|
68082
68080
|
break;
|
|
68083
68081
|
}
|
|
68084
68082
|
default:
|
|
68085
|
-
if (status === 422
|
|
68086
|
-
message =
|
|
68087
|
-
}
|
|
68083
|
+
if (status === 422)
|
|
68084
|
+
message = fastApiValidationMessage(body) ?? serverMessage;
|
|
68088
68085
|
}
|
|
68089
68086
|
const rawInterfaceId = text2(details?.interface_id);
|
|
68090
68087
|
const interfaceId = rawInterfaceId ? sanitizeLabel(rawInterfaceId) : null;
|
|
@@ -68450,6 +68447,7 @@ var REASONS = {
|
|
|
68450
68447
|
"versioning is paused": "versioning_paused",
|
|
68451
68448
|
"restore already in progress": "restore_in_progress"
|
|
68452
68449
|
};
|
|
68450
|
+
var PIN_CONFLICTS = new Set(["pin_changed", "not_pinned"]);
|
|
68453
68451
|
function sentence(value) {
|
|
68454
68452
|
const trimmed = value.trim();
|
|
68455
68453
|
const capital = trimmed.charAt(0).toUpperCase() + trimmed.slice(1);
|
|
@@ -68474,7 +68472,9 @@ function toVersionsError(error, agentId) {
|
|
|
68474
68472
|
const detail = record2(body?.detail);
|
|
68475
68473
|
const serverText = text2(body?.detail) ?? text2(detail?.message) ?? text2(body?.error);
|
|
68476
68474
|
const said = clean(serverText ?? error.message);
|
|
68477
|
-
const
|
|
68475
|
+
const detailCode = text2(detail?.code);
|
|
68476
|
+
const pinReason = status === 409 && detailCode && PIN_CONFLICTS.has(detailCode) ? detailCode : null;
|
|
68477
|
+
const reason = pinReason ?? (serverText ? REASONS[serverText.toLowerCase()] ?? null : null);
|
|
68478
68478
|
const details = {
|
|
68479
68479
|
status,
|
|
68480
68480
|
retry_after: retrySeconds(error.retryAfter),
|
|
@@ -68510,7 +68510,7 @@ function toVersionsError(error, agentId) {
|
|
|
68510
68510
|
break;
|
|
68511
68511
|
case 409:
|
|
68512
68512
|
code = "conflict";
|
|
68513
|
-
message = reason === "versioning_paused" ? "Versioning is paused on Brainbase, so nothing was changed. Try again later." : reason === "restore_in_progress" ? "A restore of this agent is already running. Wait for it to finish, then check `brainbase agent versions list`." : sentence(said);
|
|
68513
|
+
message = reason === "versioning_paused" ? "Versioning is paused on Brainbase, so nothing was changed. Try again later." : reason === "restore_in_progress" ? "A restore of this agent is already running. Wait for it to finish, then check `brainbase agent versions list`." : reason === "pin_changed" ? `Someone changed this agent's pin after it was read, so nothing was changed. Run \`brainbase agent versions list --agent ${sanitizeLabel(agentId)}\` to see the pin now, then try again.` : reason === "not_pinned" ? "The agent is not pinned, so there was nothing to unpin." : sentence(said);
|
|
68514
68514
|
break;
|
|
68515
68515
|
case 502:
|
|
68516
68516
|
if (details.sections?.some((section) => section.error !== null)) {
|
|
@@ -68638,11 +68638,21 @@ var agentVersionsApi = {
|
|
|
68638
68638
|
throw new AgentVersionsError("No answer came back from the restore in time, so whether it happened is unknown. " + `Run \`brainbase agent versions list --agent ${sanitizeLabel(agentId)}\` and look for a new rollback version before trying again.`, "outcome_unknown", null, NO_DETAILS);
|
|
68639
68639
|
}
|
|
68640
68640
|
},
|
|
68641
|
-
pin(agentId, versionId) {
|
|
68642
|
-
|
|
68641
|
+
async pin(agentId, versionId, currentPinId) {
|
|
68642
|
+
try {
|
|
68643
|
+
return await write2(agentId, pinPath(agentId), "PUT", {
|
|
68644
|
+
version_id: versionId,
|
|
68645
|
+
expected_version_id: currentPinId
|
|
68646
|
+
});
|
|
68647
|
+
} catch (error) {
|
|
68648
|
+
if (!(error instanceof ApiError && error.status === 422 && rejectsBodyField(error.body, "expected_version_id"))) {
|
|
68649
|
+
throw error;
|
|
68650
|
+
}
|
|
68651
|
+
return write2(agentId, pinPath(agentId), "PUT", { version_id: versionId });
|
|
68652
|
+
}
|
|
68643
68653
|
},
|
|
68644
|
-
unpin(agentId) {
|
|
68645
|
-
return write2(agentId, pinPath(agentId)
|
|
68654
|
+
unpin(agentId, pinnedVersionId) {
|
|
68655
|
+
return write2(agentId, `${pinPath(agentId)}${masListQuery({ expected_version_id: pinnedVersionId })}`, "DELETE");
|
|
68646
68656
|
}
|
|
68647
68657
|
};
|
|
68648
68658
|
|
|
@@ -81814,6 +81824,7 @@ function renderLines(lines, indent) {
|
|
|
81814
81824
|
var import_picocolors46 = __toESM(require_picocolors(), 1);
|
|
81815
81825
|
var PIN_NOTE = "New tasks will run this version's instructions, entrypoint, installed skills, tools, playbooks, harness and default model. " + "Secrets, credentials, machine settings, permission rules, connections and skill contents always stay current. " + "Tasks already running keep the version they started with.";
|
|
81816
81826
|
var UNPIN_NOTE = "New tasks will run the agent's current configuration again. Tasks already running keep the version they started with.";
|
|
81827
|
+
var NOT_PINNED_NOTE = "This agent is not pinned, so nothing changed.";
|
|
81817
81828
|
var PULL_NOTE = "This folder is now behind the cloud. Run `brainbase agent pull` to bring it up to date.";
|
|
81818
81829
|
function pinnedNote(pin) {
|
|
81819
81830
|
return `This agent is pinned to ${pinName(pin)}, so new tasks keep running that version, not the restored configuration, until you run \`brainbase agent versions unpin\`.`;
|
|
@@ -81995,18 +82006,18 @@ async function pin(ctx) {
|
|
|
81995
82006
|
const agentId = resolveAgentId(ctx.cwd, parsed);
|
|
81996
82007
|
const action = `Pinning agent ${sanitizeLabel(agentId)} to ${sanitizeLabel(ref)}`;
|
|
81997
82008
|
requireConsentPossible(yes, json3, action, ctx.deps);
|
|
81998
|
-
const { version: version2, capturePending } = await agentVersionsApi.resolve(agentId, ref);
|
|
82009
|
+
const { version: version2, pin: current, capturePending } = await agentVersionsApi.resolve(agentId, ref);
|
|
81999
82010
|
const accepted = await confirmChange({
|
|
82000
82011
|
yes,
|
|
82001
82012
|
json: json3,
|
|
82002
82013
|
action,
|
|
82003
|
-
consequence: PIN_NOTE,
|
|
82014
|
+
consequence: current ? `${PIN_NOTE} It is pinned to ${pinName(current)} now.` : PIN_NOTE,
|
|
82004
82015
|
question: `Pin the agent to ${versionName(version2)}?`,
|
|
82005
82016
|
deps: ctx.deps
|
|
82006
82017
|
});
|
|
82007
82018
|
if (!accepted)
|
|
82008
82019
|
return;
|
|
82009
|
-
const result2 = await agentVersionsApi.pin(agentId, version2.id);
|
|
82020
|
+
const result2 = await agentVersionsApi.pin(agentId, version2.id, current?.version_id ?? null);
|
|
82010
82021
|
const notes = [...pendingNotes(capturePending), PIN_NOTE];
|
|
82011
82022
|
if (json3) {
|
|
82012
82023
|
printJson({ ...result2, notes });
|
|
@@ -82018,6 +82029,24 @@ async function pin(ctx) {
|
|
|
82018
82029
|
printNotes(notes);
|
|
82019
82030
|
});
|
|
82020
82031
|
}
|
|
82032
|
+
function printNotPinned(json3) {
|
|
82033
|
+
if (json3) {
|
|
82034
|
+
printJson({ pinned_version_id: null, pinned_at: null, pinned_by: null, changed: false, notes: [NOT_PINNED_NOTE] });
|
|
82035
|
+
return;
|
|
82036
|
+
}
|
|
82037
|
+
console.log(`
|
|
82038
|
+
${NOT_PINNED_NOTE}
|
|
82039
|
+
`);
|
|
82040
|
+
}
|
|
82041
|
+
async function unpinIfStill(agentId, versionId) {
|
|
82042
|
+
try {
|
|
82043
|
+
return await agentVersionsApi.unpin(agentId, versionId);
|
|
82044
|
+
} catch (error2) {
|
|
82045
|
+
if (error2 instanceof AgentVersionsError && error2.reason === "not_pinned")
|
|
82046
|
+
return null;
|
|
82047
|
+
throw error2;
|
|
82048
|
+
}
|
|
82049
|
+
}
|
|
82021
82050
|
async function unpin(ctx) {
|
|
82022
82051
|
let json3 = wantsJson(ctx.args);
|
|
82023
82052
|
await runReportingErrors(() => json3, async () => {
|
|
@@ -82028,24 +82057,33 @@ async function unpin(ctx) {
|
|
|
82028
82057
|
const agentId = resolveAgentId(ctx.cwd, parsed);
|
|
82029
82058
|
const action = `Unpinning agent ${sanitizeLabel(agentId)}`;
|
|
82030
82059
|
requireConsentPossible(yes, json3, action, ctx.deps);
|
|
82060
|
+
const { pin: current } = await agentVersionsApi.latest(agentId);
|
|
82061
|
+
if (!current) {
|
|
82062
|
+
printNotPinned(json3);
|
|
82063
|
+
return;
|
|
82064
|
+
}
|
|
82031
82065
|
const accepted = await confirmChange({
|
|
82032
82066
|
yes,
|
|
82033
82067
|
json: json3,
|
|
82034
82068
|
action,
|
|
82035
82069
|
consequence: UNPIN_NOTE,
|
|
82036
|
-
question:
|
|
82070
|
+
question: `Unpin the agent from ${pinName(current)}?`,
|
|
82037
82071
|
deps: ctx.deps
|
|
82038
82072
|
});
|
|
82039
82073
|
if (!accepted)
|
|
82040
82074
|
return;
|
|
82041
|
-
const result2 = await
|
|
82075
|
+
const result2 = await unpinIfStill(agentId, current.version_id);
|
|
82076
|
+
if (!result2) {
|
|
82077
|
+
printNotPinned(json3);
|
|
82078
|
+
return;
|
|
82079
|
+
}
|
|
82042
82080
|
const notes = [UNPIN_NOTE];
|
|
82043
82081
|
if (json3) {
|
|
82044
|
-
printJson({ ...result2, notes });
|
|
82082
|
+
printJson({ ...result2, changed: true, notes });
|
|
82045
82083
|
return;
|
|
82046
82084
|
}
|
|
82047
82085
|
console.log(`
|
|
82048
|
-
${import_picocolors46.default.green("✓")} Unpinned
|
|
82086
|
+
${import_picocolors46.default.green("✓")} Unpinned from ${pinName(current)}
|
|
82049
82087
|
`);
|
|
82050
82088
|
printNotes(notes);
|
|
82051
82089
|
});
|
|
@@ -85723,7 +85761,324 @@ function printTokenHelp() {
|
|
|
85723
85761
|
}
|
|
85724
85762
|
|
|
85725
85763
|
// src/cli/integrations.ts
|
|
85764
|
+
var import_picocolors63 = __toESM(require_picocolors(), 1);
|
|
85765
|
+
|
|
85766
|
+
// src/cli/integration-context.ts
|
|
85726
85767
|
var import_picocolors62 = __toESM(require_picocolors(), 1);
|
|
85768
|
+
|
|
85769
|
+
// src/core/integration-contexts-api.ts
|
|
85770
|
+
var REQUEST_TIMEOUT_MS2 = 30000;
|
|
85771
|
+
var TOKEN_REFUSED_MESSAGE = "Integration contexts can only be created or ended with your own `brainbase login` session, and BRAINBASE_TOKEN is set. " + "Personal access tokens and task keys cannot create or end them. Unset BRAINBASE_TOKEN and run `brainbase login`.";
|
|
85772
|
+
async function resolveHumanSession() {
|
|
85773
|
+
if (process.env.BRAINBASE_TOKEN?.trim()) {
|
|
85774
|
+
throw new ApiError(TOKEN_REFUSED_MESSAGE, 401);
|
|
85775
|
+
}
|
|
85776
|
+
const session = await ensureFreshSession();
|
|
85777
|
+
if (session)
|
|
85778
|
+
return session;
|
|
85779
|
+
const stored = readToken() ? ` The PAT saved in ${TOKEN_FILE} cannot create or end integration contexts.` : "";
|
|
85780
|
+
const problem = readAuth() ? "Your login session has expired and could not be renewed." : "Not logged in.";
|
|
85781
|
+
throw new ApiError(`${problem} Run \`brainbase login\`.${stored}`, 401);
|
|
85782
|
+
}
|
|
85783
|
+
async function contextRequest(pathname, body, operation) {
|
|
85784
|
+
const session = await resolveHumanSession();
|
|
85785
|
+
const base2 = masControlPlaneBaseUrl(session);
|
|
85786
|
+
const send = async (refreshed) => {
|
|
85787
|
+
const current = refreshed ?? session;
|
|
85788
|
+
try {
|
|
85789
|
+
return await fetch(`${masControlPlaneBaseUrl(current)}/v2${pathname}`, {
|
|
85790
|
+
method: "POST",
|
|
85791
|
+
headers: {
|
|
85792
|
+
Authorization: `Bearer ${current.access_token}`,
|
|
85793
|
+
Accept: "application/json",
|
|
85794
|
+
"Content-Type": "application/json"
|
|
85795
|
+
},
|
|
85796
|
+
body: JSON.stringify(body),
|
|
85797
|
+
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS2)
|
|
85798
|
+
});
|
|
85799
|
+
} catch (err) {
|
|
85800
|
+
throw new ApiError(`Network error: ${err.message}`);
|
|
85801
|
+
}
|
|
85802
|
+
};
|
|
85803
|
+
const res = await sendWithAuthRetry(session, send);
|
|
85804
|
+
let text3;
|
|
85805
|
+
try {
|
|
85806
|
+
text3 = await res.text();
|
|
85807
|
+
} catch (err) {
|
|
85808
|
+
throw new ApiError(`Network error while reading the response: ${err.message}`);
|
|
85809
|
+
}
|
|
85810
|
+
let parsed = text3;
|
|
85811
|
+
try {
|
|
85812
|
+
parsed = text3 ? JSON.parse(text3) : null;
|
|
85813
|
+
} catch {}
|
|
85814
|
+
if (!res.ok) {
|
|
85815
|
+
throw new ApiError(contextErrorMessage(res.status, parsed, operation, base2), res.status, parsed);
|
|
85816
|
+
}
|
|
85817
|
+
return parsed;
|
|
85818
|
+
}
|
|
85819
|
+
function nonEmptyString(value2) {
|
|
85820
|
+
return typeof value2 === "string" && value2.length > 0;
|
|
85821
|
+
}
|
|
85822
|
+
function absentOrString(value2) {
|
|
85823
|
+
return value2 === undefined || typeof value2 === "string";
|
|
85824
|
+
}
|
|
85825
|
+
function isCreatedContext(value2) {
|
|
85826
|
+
const body = record(value2);
|
|
85827
|
+
return !!body && nonEmptyString(body.context_id) && nonEmptyString(body.renewal_handle) && absentOrString(body.renewal_expires_at) && absentOrString(body.max_expires_at);
|
|
85828
|
+
}
|
|
85829
|
+
function isEndedContext(value2) {
|
|
85830
|
+
return typeof record(value2)?.state === "string";
|
|
85831
|
+
}
|
|
85832
|
+
function contextErrorMessage(status, body, operation, base2) {
|
|
85833
|
+
const detail = record(body)?.detail;
|
|
85834
|
+
if (status === 404) {
|
|
85835
|
+
if (detail === "Not Found") {
|
|
85836
|
+
return `Standalone integration contexts are not enabled on this Brainbase deployment (${hostOf(base2)}).`;
|
|
85837
|
+
}
|
|
85838
|
+
if (detail === "agent not found" && operation.kind === "create") {
|
|
85839
|
+
return `Agent ${operation.agentId} was not found, or you cannot manage it. Creating an integration context needs management rights on the agent.`;
|
|
85840
|
+
}
|
|
85841
|
+
if (detail === "integration context not found" && operation.kind === "end") {
|
|
85842
|
+
return `Integration context ${operation.contextId} was not found, or you cannot manage its agent.`;
|
|
85843
|
+
}
|
|
85844
|
+
}
|
|
85845
|
+
if (status === 403 && record(detail)?.code === "human_credential_required") {
|
|
85846
|
+
return "Brainbase refused this credential: integration contexts can only be created or ended with your own `brainbase login` session. Run `brainbase login` and try again.";
|
|
85847
|
+
}
|
|
85848
|
+
if (status === 401) {
|
|
85849
|
+
return `Brainbase did not accept your login session (${sanitizeLabel(masApiErrorMessage(body, status))}). Run \`brainbase login\` to sign in again.`;
|
|
85850
|
+
}
|
|
85851
|
+
if (status === 422) {
|
|
85852
|
+
const fields = fastApiValidationMessage(body);
|
|
85853
|
+
if (fields)
|
|
85854
|
+
return `Brainbase rejected the request: ${fields}`;
|
|
85855
|
+
}
|
|
85856
|
+
return sanitizeLabel(masApiErrorMessage(body, status));
|
|
85857
|
+
}
|
|
85858
|
+
function hostOf(base2) {
|
|
85859
|
+
try {
|
|
85860
|
+
return new URL(base2).host;
|
|
85861
|
+
} catch {
|
|
85862
|
+
return sanitizeLabel(base2);
|
|
85863
|
+
}
|
|
85864
|
+
}
|
|
85865
|
+
var integrationContextsApi = {
|
|
85866
|
+
async create(input) {
|
|
85867
|
+
const created = await contextRequest("/integration-contexts", input, {
|
|
85868
|
+
kind: "create",
|
|
85869
|
+
agentId: input.agent_id
|
|
85870
|
+
});
|
|
85871
|
+
if (!isCreatedContext(created)) {
|
|
85872
|
+
throw new ApiError("Brainbase answered without a context id and renewal handle.");
|
|
85873
|
+
}
|
|
85874
|
+
return created;
|
|
85875
|
+
},
|
|
85876
|
+
async end(contextId, reason) {
|
|
85877
|
+
const ended = await contextRequest(`/integration-contexts/${encodeURIComponent(contextId)}/end`, { reason }, { kind: "end", contextId });
|
|
85878
|
+
if (!isEndedContext(ended)) {
|
|
85879
|
+
throw new ApiError("Brainbase answered without the context state.");
|
|
85880
|
+
}
|
|
85881
|
+
return ended;
|
|
85882
|
+
}
|
|
85883
|
+
};
|
|
85884
|
+
|
|
85885
|
+
// src/cli/integration-context.ts
|
|
85886
|
+
var MIN_LIFETIME_S = 60;
|
|
85887
|
+
var MAX_LIFETIME_S = 30 * 24 * 60 * 60;
|
|
85888
|
+
var DEFAULT_LIFETIME_S = 7 * 24 * 60 * 60;
|
|
85889
|
+
var DEFAULT_END_REASON = "ended with brainbase integrations context end";
|
|
85890
|
+
var MAX_REASON_LENGTH2 = 200;
|
|
85891
|
+
var APPLICATION_PATTERN = /^[a-z0-9][a-z0-9._:/-]{0,119}$/;
|
|
85892
|
+
var UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
85893
|
+
var UNIT_SECONDS = { "": 1, s: 1, m: 60, h: 3600, d: 86400 };
|
|
85894
|
+
var CONTEXT_USAGE = `Usage: brainbase integrations context <create|end> [--json]
|
|
85895
|
+
|
|
85896
|
+
create [--agent <id>] --application <name> [--max-lifetime <dur>]
|
|
85897
|
+
Let a program outside Brainbase (the Brainbase SDK) use the agent's
|
|
85898
|
+
integrations on your behalf. Prints a renewal handle once: store it in
|
|
85899
|
+
that program's secret store. It rotates on every renewal, so the program
|
|
85900
|
+
must keep the newest one.
|
|
85901
|
+
--agent the agent's id; defaults to the agent this folder is linked to
|
|
85902
|
+
--application names the program: up to 120 of a-z 0-9 . _ : / -,
|
|
85903
|
+
starting with a letter or digit (e.g. billing-sync)
|
|
85904
|
+
--max-lifetime when the context ends at the latest: 60s to 30d, as
|
|
85905
|
+
seconds or <n>s, <n>m, <n>h, <n>d. Default 7d.
|
|
85906
|
+
|
|
85907
|
+
end <context-id> [--reason <text>]
|
|
85908
|
+
End a context now. Its renewal handle and access grants stop working.
|
|
85909
|
+
--reason recorded with the context, 1-200 characters
|
|
85910
|
+
(default "${DEFAULT_END_REASON}")
|
|
85911
|
+
|
|
85912
|
+
Both need your own \`brainbase login\` session and management rights on the
|
|
85913
|
+
agent. BRAINBASE_TOKEN and the PAT saved by \`brainbase token create\` are refused.
|
|
85914
|
+
`;
|
|
85915
|
+
async function runIntegrationContext(cwd2, argv, options) {
|
|
85916
|
+
const { write: write3, fail: fail3 } = options;
|
|
85917
|
+
const [action, ...rest2] = argv;
|
|
85918
|
+
const parsed = parseContextArgs(rest2, "--application", "--max-lifetime", "--reason");
|
|
85919
|
+
if (action === "help" || action === "--help" || action === "-h" || "help" in parsed) {
|
|
85920
|
+
write3(CONTEXT_USAGE);
|
|
85921
|
+
return 0;
|
|
85922
|
+
}
|
|
85923
|
+
if (action !== "create" && action !== "end") {
|
|
85924
|
+
const problem = action ? `Unknown integrations context subcommand: ${sanitizeLabel(action)}.` : "Missing integrations context subcommand.";
|
|
85925
|
+
return fail3(`${problem} ${CONTEXT_USAGE.split(`
|
|
85926
|
+
`)[0]}`);
|
|
85927
|
+
}
|
|
85928
|
+
if ("error" in parsed)
|
|
85929
|
+
return fail3(parsed.error);
|
|
85930
|
+
const { values: values2, positionals } = parsed;
|
|
85931
|
+
if (action === "create") {
|
|
85932
|
+
if (positionals.length > 0)
|
|
85933
|
+
return fail3(`Unexpected argument: ${sanitizeLabel(positionals[0])}. ${CREATE_USAGE}`);
|
|
85934
|
+
if (values2.has("--reason"))
|
|
85935
|
+
return fail3(`--reason is for \`context end\`. ${CREATE_USAGE}`);
|
|
85936
|
+
const target = cloudTargetAgent(cwd2, options);
|
|
85937
|
+
if (!target)
|
|
85938
|
+
return fail3(NO_AGENT_MESSAGE);
|
|
85939
|
+
if ("error" in target)
|
|
85940
|
+
return fail3(target.error);
|
|
85941
|
+
if (!UUID_PATTERN.test(target.agentId)) {
|
|
85942
|
+
return fail3(`${sanitizeLabel(target.agentId)} is not an agent id. --agent takes the agent's UUID, as \`brainbase agent list\` shows it.`);
|
|
85943
|
+
}
|
|
85944
|
+
const agentId = target.agentId.toLowerCase();
|
|
85945
|
+
const application = values2.get("--application");
|
|
85946
|
+
if (application === undefined)
|
|
85947
|
+
return fail3(`--application is required. ${CREATE_USAGE}`);
|
|
85948
|
+
if (!APPLICATION_PATTERN.test(application)) {
|
|
85949
|
+
return fail3(`--application must be 1-120 characters of lowercase letters, digits and . _ : / -, starting with a letter or digit (e.g. billing-sync); got "${sanitizeLabel(application)}".`);
|
|
85950
|
+
}
|
|
85951
|
+
const rawLifetime = values2.get("--max-lifetime");
|
|
85952
|
+
const lifetime = rawLifetime === undefined ? DEFAULT_LIFETIME_S : parseMaxLifetime(rawLifetime);
|
|
85953
|
+
if (typeof lifetime !== "number")
|
|
85954
|
+
return fail3(lifetime.error);
|
|
85955
|
+
let created;
|
|
85956
|
+
try {
|
|
85957
|
+
created = await integrationContextsApi.create({
|
|
85958
|
+
agent_id: agentId,
|
|
85959
|
+
application,
|
|
85960
|
+
max_lifetime_s: lifetime
|
|
85961
|
+
});
|
|
85962
|
+
} catch (err) {
|
|
85963
|
+
return fail3(`brainbase integrations context create failed: ${message(err)}`);
|
|
85964
|
+
}
|
|
85965
|
+
if (options.json) {
|
|
85966
|
+
write3(JSON.stringify(created) + `
|
|
85967
|
+
`);
|
|
85968
|
+
return 0;
|
|
85969
|
+
}
|
|
85970
|
+
write3(renderCreated(created, agentId, application));
|
|
85971
|
+
return 0;
|
|
85972
|
+
}
|
|
85973
|
+
if (values2.has("--application") || values2.has("--max-lifetime")) {
|
|
85974
|
+
return fail3(`--application and --max-lifetime are for \`context create\`. ${END_USAGE}`);
|
|
85975
|
+
}
|
|
85976
|
+
if (positionals.length !== 1)
|
|
85977
|
+
return fail3(END_USAGE);
|
|
85978
|
+
const contextId = positionals[0];
|
|
85979
|
+
if (!UUID_PATTERN.test(contextId)) {
|
|
85980
|
+
return fail3(`${sanitizeLabel(contextId)} is not a context id. Pass the context_id \`context create\` printed.`);
|
|
85981
|
+
}
|
|
85982
|
+
const reason = (values2.get("--reason") ?? DEFAULT_END_REASON).trim();
|
|
85983
|
+
const reasonLength = [...reason].length;
|
|
85984
|
+
if (reasonLength < 1 || reasonLength > MAX_REASON_LENGTH2) {
|
|
85985
|
+
return fail3(`--reason must be 1-${MAX_REASON_LENGTH2} characters; got ${reasonLength}.`);
|
|
85986
|
+
}
|
|
85987
|
+
let ended;
|
|
85988
|
+
try {
|
|
85989
|
+
ended = await integrationContextsApi.end(contextId.toLowerCase(), reason);
|
|
85990
|
+
} catch (err) {
|
|
85991
|
+
return fail3(`brainbase integrations context end failed: ${message(err)}`);
|
|
85992
|
+
}
|
|
85993
|
+
const id = contextId.toLowerCase();
|
|
85994
|
+
if (options.json) {
|
|
85995
|
+
write3(JSON.stringify({ context_id: id, ...ended }) + `
|
|
85996
|
+
`);
|
|
85997
|
+
return 0;
|
|
85998
|
+
}
|
|
85999
|
+
const state = sanitizeLabel(ended.state);
|
|
86000
|
+
write3(state === "ended" ? `${import_picocolors62.default.green("✓")} Ended integration context ${id}. Its renewal handle and access grants no longer work.
|
|
86001
|
+
` : `Integration context ${id} is ${state}. Its renewal handle and access grants no longer work.
|
|
86002
|
+
`);
|
|
86003
|
+
return 0;
|
|
86004
|
+
}
|
|
86005
|
+
var CREATE_USAGE = "Usage: brainbase integrations context create [--agent <id>] --application <name> [--max-lifetime <dur>]";
|
|
86006
|
+
var END_USAGE = "Usage: brainbase integrations context end <context-id> [--reason <text>]";
|
|
86007
|
+
function parseContextArgs(rest2, ...valueFlags) {
|
|
86008
|
+
for (let i = 0;i < rest2.length; i++) {
|
|
86009
|
+
if (valueFlags.includes(rest2[i]))
|
|
86010
|
+
i++;
|
|
86011
|
+
else if (rest2[i] === "--help" || rest2[i] === "-h")
|
|
86012
|
+
return { help: true };
|
|
86013
|
+
}
|
|
86014
|
+
const values2 = new Map;
|
|
86015
|
+
const positionals = [];
|
|
86016
|
+
for (let i = 0;i < rest2.length; i++) {
|
|
86017
|
+
const arg = rest2[i];
|
|
86018
|
+
const eq = arg.indexOf("=");
|
|
86019
|
+
const name = arg.startsWith("--") && eq > 0 ? arg.slice(0, eq) : arg;
|
|
86020
|
+
if (valueFlags.includes(name)) {
|
|
86021
|
+
let value2;
|
|
86022
|
+
if (name !== arg) {
|
|
86023
|
+
value2 = arg.slice(eq + 1);
|
|
86024
|
+
} else {
|
|
86025
|
+
value2 = rest2[i + 1];
|
|
86026
|
+
if (value2 === undefined || name !== "--reason" && value2.startsWith("-")) {
|
|
86027
|
+
return { error: `${name} needs a value.` };
|
|
86028
|
+
}
|
|
86029
|
+
i++;
|
|
86030
|
+
}
|
|
86031
|
+
if (values2.has(name))
|
|
86032
|
+
return { error: `${name} was given more than once.` };
|
|
86033
|
+
values2.set(name, value2);
|
|
86034
|
+
continue;
|
|
86035
|
+
}
|
|
86036
|
+
if (arg.startsWith("-")) {
|
|
86037
|
+
return { error: `Unknown option for brainbase integrations context: ${sanitizeLabel(arg)}` };
|
|
86038
|
+
}
|
|
86039
|
+
positionals.push(arg);
|
|
86040
|
+
}
|
|
86041
|
+
return { values: values2, positionals };
|
|
86042
|
+
}
|
|
86043
|
+
function parseMaxLifetime(raw) {
|
|
86044
|
+
const match = /^(\d+)([smhd]?)$/i.exec(raw.trim());
|
|
86045
|
+
if (!match) {
|
|
86046
|
+
return { error: `--max-lifetime takes seconds or a duration such as 90m, 12h or 7d; got "${sanitizeLabel(raw)}".` };
|
|
86047
|
+
}
|
|
86048
|
+
const seconds = Number(match[1]) * UNIT_SECONDS[match[2].toLowerCase()];
|
|
86049
|
+
if (!Number.isSafeInteger(seconds) || seconds < MIN_LIFETIME_S || seconds > MAX_LIFETIME_S) {
|
|
86050
|
+
return {
|
|
86051
|
+
error: `--max-lifetime must be between 60s and 30d (${MAX_LIFETIME_S} seconds); got "${sanitizeLabel(raw)}".`
|
|
86052
|
+
};
|
|
86053
|
+
}
|
|
86054
|
+
return seconds;
|
|
86055
|
+
}
|
|
86056
|
+
function renderCreated(created, agentId, application) {
|
|
86057
|
+
const id = sanitizeLabel(created.context_id);
|
|
86058
|
+
const lines = [
|
|
86059
|
+
`${import_picocolors62.default.green("✓")} Created integration context ${id}`,
|
|
86060
|
+
` ${import_picocolors62.default.dim(`agent ${agentId} · application ${application}`)}`,
|
|
86061
|
+
"",
|
|
86062
|
+
" Renewal handle:",
|
|
86063
|
+
"",
|
|
86064
|
+
` ${sanitizeLabel(created.renewal_handle)}`,
|
|
86065
|
+
"",
|
|
86066
|
+
import_picocolors62.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."),
|
|
86067
|
+
"",
|
|
86068
|
+
` Handle expires ${sanitizeLabel(created.renewal_expires_at ?? "unknown")}`,
|
|
86069
|
+
` Context ends ${sanitizeLabel(created.max_expires_at ?? "unknown")} ${import_picocolors62.default.dim("(its maximum lifetime)")}`,
|
|
86070
|
+
"",
|
|
86071
|
+
import_picocolors62.default.dim(` End it sooner with \`brainbase integrations context end ${id}\`.`),
|
|
86072
|
+
""
|
|
86073
|
+
];
|
|
86074
|
+
return lines.join(`
|
|
86075
|
+
`);
|
|
86076
|
+
}
|
|
86077
|
+
function message(err) {
|
|
86078
|
+
return sanitizeLabel(err?.message ?? String(err));
|
|
86079
|
+
}
|
|
86080
|
+
|
|
86081
|
+
// src/cli/integrations.ts
|
|
85727
86082
|
var EFFECTS = ["allow", "ask", "deny"];
|
|
85728
86083
|
var USAGE = `Usage: brainbase integrations <command> [--agent <id>] [--json]
|
|
85729
86084
|
|
|
@@ -85735,6 +86090,12 @@ var USAGE = `Usage: brainbase integrations <command> [--agent <id>] [--json]
|
|
|
85735
86090
|
disconnect <app> delete the app's connected account [--account <id>] [--yes]
|
|
85736
86091
|
remove <app> uninstall an app that needs no account
|
|
85737
86092
|
allow|ask|deny <app>[.<action>] set the permission for an app or one action
|
|
86093
|
+
context create --application <name> [--max-lifetime <dur>]
|
|
86094
|
+
let a program outside Brainbase (the SDK) use the agent's
|
|
86095
|
+
integrations; prints a renewal handle once. Lifetime 60s-30d, default 7d
|
|
86096
|
+
context end <context-id> [--reason <text>]
|
|
86097
|
+
end a standalone integration context now
|
|
86098
|
+
(\`brainbase integrations context --help\` for details)
|
|
85738
86099
|
`;
|
|
85739
86100
|
var POLL_INTERVAL_MS2 = 2000;
|
|
85740
86101
|
var MAX_CONSECUTIVE_POLL_FAILURES2 = 5;
|
|
@@ -85744,12 +86105,12 @@ async function runIntegrations(cwd2, sub, argv, options) {
|
|
|
85744
86105
|
const write3 = options.write ?? ((s3) => process.stdout.write(s3));
|
|
85745
86106
|
const writeErr = options.writeErr ?? ((s3) => process.stderr.write(s3));
|
|
85746
86107
|
const api4 = { ...integrationsApi, ...options.api };
|
|
85747
|
-
const fail3 = (
|
|
86108
|
+
const fail3 = (message2) => {
|
|
85748
86109
|
if (options.json)
|
|
85749
|
-
write3(JSON.stringify({ error:
|
|
86110
|
+
write3(JSON.stringify({ error: message2 }) + `
|
|
85750
86111
|
`);
|
|
85751
86112
|
else
|
|
85752
|
-
writeErr(
|
|
86113
|
+
writeErr(message2 + `
|
|
85753
86114
|
`);
|
|
85754
86115
|
return 1;
|
|
85755
86116
|
};
|
|
@@ -85758,6 +86119,15 @@ async function runIntegrations(cwd2, sub, argv, options) {
|
|
|
85758
86119
|
` : human);
|
|
85759
86120
|
return 0;
|
|
85760
86121
|
};
|
|
86122
|
+
if (sub === "context") {
|
|
86123
|
+
return await runIntegrationContext(cwd2, argv, {
|
|
86124
|
+
json: options.json,
|
|
86125
|
+
agentId: options.agentId,
|
|
86126
|
+
resolveAgentId: options.resolveAgentId,
|
|
86127
|
+
write: write3,
|
|
86128
|
+
fail: fail3
|
|
86129
|
+
});
|
|
86130
|
+
}
|
|
85761
86131
|
const isHelpFlag = (s3) => s3 === "--help" || s3 === "-h";
|
|
85762
86132
|
if (sub === "help" || isHelpFlag(sub) || argv.some(isHelpFlag)) {
|
|
85763
86133
|
write3(USAGE);
|
|
@@ -85783,7 +86153,7 @@ ${USAGE}`);
|
|
|
85783
86153
|
const apps = await api4.searchApps(arg);
|
|
85784
86154
|
return out({ apps }, renderSearch(apps));
|
|
85785
86155
|
} catch (err) {
|
|
85786
|
-
return fail3(`brainbase integrations search failed: ${
|
|
86156
|
+
return fail3(`brainbase integrations search failed: ${message2(err)}`);
|
|
85787
86157
|
}
|
|
85788
86158
|
}
|
|
85789
86159
|
const target = cloudTargetAgent(cwd2, options);
|
|
@@ -85810,7 +86180,7 @@ ${USAGE}`);
|
|
|
85810
86180
|
return await setEffect(agentId, sub, arg);
|
|
85811
86181
|
}
|
|
85812
86182
|
} catch (err) {
|
|
85813
|
-
return fail3(`brainbase integrations ${sub} failed: ${
|
|
86183
|
+
return fail3(`brainbase integrations ${sub} failed: ${message2(err)}`);
|
|
85814
86184
|
}
|
|
85815
86185
|
async function list3(agentId2) {
|
|
85816
86186
|
const [accounts, noAuthApps, permissions] = await Promise.all([
|
|
@@ -85863,7 +86233,7 @@ ${USAGE}`);
|
|
|
85863
86233
|
if (needsAccount(app))
|
|
85864
86234
|
return await connect2(agentId2, slug, app);
|
|
85865
86235
|
const added = await api4.addNoAuthApp(agentId2, slug);
|
|
85866
|
-
return out({ app: added.appSlug, name: added.name, needs_account: false, added: true }, `${
|
|
86236
|
+
return out({ app: added.appSlug, name: added.name, needs_account: false, added: true }, `${import_picocolors63.default.green("✓")} Added ${import_picocolors63.default.bold(label2(added.name))}. It needs no account; your agent can use it on its next turn.
|
|
85867
86237
|
`);
|
|
85868
86238
|
}
|
|
85869
86239
|
async function connect2(agentId2, slug, known2) {
|
|
@@ -85883,20 +86253,20 @@ ${USAGE}`);
|
|
|
85883
86253
|
return 0;
|
|
85884
86254
|
}
|
|
85885
86255
|
const interactive = options.interactive ?? isInteractive();
|
|
85886
|
-
write3(`Open this link to connect ${
|
|
86256
|
+
write3(`Open this link to connect ${import_picocolors63.default.bold(name)}:
|
|
85887
86257
|
|
|
85888
|
-
${
|
|
86258
|
+
${import_picocolors63.default.cyan(url2)}
|
|
85889
86259
|
|
|
85890
86260
|
`);
|
|
85891
|
-
write3(
|
|
86261
|
+
write3(import_picocolors63.default.dim(`Anyone with this link can connect an account to this agent until it expires, so do not share it.
|
|
85892
86262
|
`));
|
|
85893
86263
|
if (!options.noOpen && interactive) {
|
|
85894
|
-
write3(
|
|
86264
|
+
write3(import_picocolors63.default.dim(`Opening your browser…
|
|
85895
86265
|
`));
|
|
85896
86266
|
(options.openUrl ?? openInBrowser)(url2);
|
|
85897
86267
|
}
|
|
85898
86268
|
if (options.noWait) {
|
|
85899
|
-
write3(
|
|
86269
|
+
write3(import_picocolors63.default.dim("Not waiting. Run `brainbase integrations list` to see when it is connected.\n"));
|
|
85900
86270
|
return 0;
|
|
85901
86271
|
}
|
|
85902
86272
|
const controller = new AbortController;
|
|
@@ -85929,7 +86299,7 @@ ${USAGE}`);
|
|
|
85929
86299
|
if (spinner2)
|
|
85930
86300
|
spinner2.stop(text3, ok ? 0 : 2);
|
|
85931
86301
|
else if (ok)
|
|
85932
|
-
write3(`${
|
|
86302
|
+
write3(`${import_picocolors63.default.green("✔")} ${text3}
|
|
85933
86303
|
`);
|
|
85934
86304
|
else
|
|
85935
86305
|
writeErr(`${text3}
|
|
@@ -85969,11 +86339,11 @@ ${USAGE}`);
|
|
|
85969
86339
|
const confirm = options.confirmDisconnect ?? promptForDisconnect;
|
|
85970
86340
|
const accountLabel = account.name ? `${label2(account.name)} (${account.id})` : account.id;
|
|
85971
86341
|
if (!await confirm(`Disconnect ${label2(slug)} account ${accountLabel}? Everyone using this agent loses it.`, options.yes)) {
|
|
85972
|
-
return out({ app: slug, account_id: account.id, disconnected: false, outcome: "declined" }, ` ${
|
|
86342
|
+
return out({ app: slug, account_id: account.id, disconnected: false, outcome: "declined" }, ` ${import_picocolors63.default.dim("Left alone.")}
|
|
85973
86343
|
`);
|
|
85974
86344
|
}
|
|
85975
86345
|
await api4.deleteAccount(agentId2, account.id);
|
|
85976
|
-
return out({ app: slug, account_id: account.id, disconnected: true }, `${
|
|
86346
|
+
return out({ app: slug, account_id: account.id, disconnected: true }, `${import_picocolors63.default.green("✓")} Disconnected ${import_picocolors63.default.bold(label2(slug))} account ${accountLabel}.
|
|
85977
86347
|
`);
|
|
85978
86348
|
}
|
|
85979
86349
|
async function remove2(agentId2, slug) {
|
|
@@ -85986,7 +86356,7 @@ ${USAGE}`);
|
|
|
85986
86356
|
return fail3(`${label2(slug)} is not installed on this agent.`);
|
|
85987
86357
|
}
|
|
85988
86358
|
await api4.removeNoAuthApp(agentId2, slug);
|
|
85989
|
-
return out({ app: slug, removed: true }, `${
|
|
86359
|
+
return out({ app: slug, removed: true }, `${import_picocolors63.default.green("✓")} Removed ${import_picocolors63.default.bold(label2(slug))}.
|
|
85990
86360
|
`);
|
|
85991
86361
|
}
|
|
85992
86362
|
async function setEffect(agentId2, effect, raw) {
|
|
@@ -85999,7 +86369,7 @@ ${USAGE}`);
|
|
|
85999
86369
|
const capability = pattern(appSlug(app), action);
|
|
86000
86370
|
await api4.setPermission(agentId2, capability, effect);
|
|
86001
86371
|
const scope = action ? `${label2(action)} on ${label2(app)}` : `every ${label2(app)} action without its own rule`;
|
|
86002
|
-
return out({ capability_pattern: capability, effect }, `${
|
|
86372
|
+
return out({ capability_pattern: capability, effect }, `${import_picocolors63.default.green("✓")} ${capability} → ${import_picocolors63.default.bold(effect)} ${import_picocolors63.default.dim(`(${scope})`)}
|
|
86003
86373
|
`);
|
|
86004
86374
|
}
|
|
86005
86375
|
}
|
|
@@ -86009,7 +86379,7 @@ function appSlug(raw) {
|
|
|
86009
86379
|
function label2(s3) {
|
|
86010
86380
|
return sanitizeLabel(s3);
|
|
86011
86381
|
}
|
|
86012
|
-
function
|
|
86382
|
+
function message2(err) {
|
|
86013
86383
|
return sanitizeLabel(err?.message ?? String(err));
|
|
86014
86384
|
}
|
|
86015
86385
|
function needsAccount(app) {
|
|
@@ -86052,27 +86422,27 @@ async function promptForDisconnect(question, yes) {
|
|
|
86052
86422
|
return ensureNotCancelled(answer);
|
|
86053
86423
|
}
|
|
86054
86424
|
var EFFECT_COLOR = {
|
|
86055
|
-
allow:
|
|
86056
|
-
ask:
|
|
86057
|
-
deny:
|
|
86425
|
+
allow: import_picocolors63.default.green,
|
|
86426
|
+
ask: import_picocolors63.default.yellow,
|
|
86427
|
+
deny: import_picocolors63.default.red
|
|
86058
86428
|
};
|
|
86059
86429
|
function effectLabel(effect, width = 0) {
|
|
86060
|
-
return (EFFECT_COLOR[effect] ??
|
|
86430
|
+
return (EFFECT_COLOR[effect] ?? import_picocolors63.default.dim)(sanitizeLabel(effect).padEnd(width));
|
|
86061
86431
|
}
|
|
86062
86432
|
function renderList(rows, permissions) {
|
|
86063
86433
|
const lines = [""];
|
|
86064
86434
|
if (!permissions.permissionsAvailable) {
|
|
86065
|
-
lines.push(
|
|
86435
|
+
lines.push(import_picocolors63.default.yellow(" Integrations only work on Kafka agents for now; this agent cannot use them."), "");
|
|
86066
86436
|
}
|
|
86067
86437
|
if (rows.length === 0) {
|
|
86068
|
-
lines.push(
|
|
86069
|
-
lines.push(
|
|
86438
|
+
lines.push(import_picocolors63.default.dim(" No integrations on this agent."));
|
|
86439
|
+
lines.push(import_picocolors63.default.dim(" Find one with `brainbase integrations search <query>`, then `brainbase integrations add <app>`."), "");
|
|
86070
86440
|
return lines.join(`
|
|
86071
86441
|
`);
|
|
86072
86442
|
}
|
|
86073
86443
|
for (const row of rows) {
|
|
86074
86444
|
const healthy = row.accounts.every((a3) => a3.healthy);
|
|
86075
|
-
const mark = healthy ?
|
|
86445
|
+
const mark = healthy ? import_picocolors63.default.green("✓") : import_picocolors63.default.yellow("!");
|
|
86076
86446
|
const bits = [sanitizeLabel(row.name)];
|
|
86077
86447
|
if (!row.needs_account)
|
|
86078
86448
|
bits.push("no account needed");
|
|
@@ -86080,35 +86450,35 @@ function renderList(rows, permissions) {
|
|
|
86080
86450
|
bits.push(`account ${account.name ? sanitizeLabel(account.name) : account.id}${account.healthy ? "" : " (needs reconnecting)"}`);
|
|
86081
86451
|
}
|
|
86082
86452
|
const effect = row.effect ?? permissions.defaultEffect;
|
|
86083
|
-
lines.push(` ${mark} ${
|
|
86453
|
+
lines.push(` ${mark} ${import_picocolors63.default.bold(sanitizeLabel(row.app))} ${import_picocolors63.default.dim(bits.join(" · "))} ${effectLabel(effect)}${row.effect ? "" : import_picocolors63.default.dim(" (default)")}`);
|
|
86084
86454
|
}
|
|
86085
|
-
lines.push("",
|
|
86455
|
+
lines.push("", import_picocolors63.default.dim(" Run `brainbase integrations actions <app>` to see and set per-action permissions."), "");
|
|
86086
86456
|
return lines.join(`
|
|
86087
86457
|
`);
|
|
86088
86458
|
}
|
|
86089
86459
|
function renderSearch(apps) {
|
|
86090
86460
|
if (apps.length === 0)
|
|
86091
|
-
return
|
|
86461
|
+
return import_picocolors63.default.dim("No apps match.") + `
|
|
86092
86462
|
`;
|
|
86093
86463
|
const lines = [""];
|
|
86094
86464
|
for (const app of apps) {
|
|
86095
|
-
const hint = needsAccount(app) ? "" :
|
|
86096
|
-
lines.push(` ${
|
|
86465
|
+
const hint = needsAccount(app) ? "" : import_picocolors63.default.dim(" no account needed");
|
|
86466
|
+
lines.push(` ${import_picocolors63.default.bold(sanitizeLabel(app.nameSlug))} ${sanitizeLabel(app.name)}${hint}`);
|
|
86097
86467
|
}
|
|
86098
|
-
lines.push("",
|
|
86468
|
+
lines.push("", import_picocolors63.default.dim(" Add one with `brainbase integrations add <app>`."), "");
|
|
86099
86469
|
return lines.join(`
|
|
86100
86470
|
`);
|
|
86101
86471
|
}
|
|
86102
86472
|
function renderActions(slug, rows) {
|
|
86103
86473
|
if (rows.length === 0)
|
|
86104
|
-
return
|
|
86474
|
+
return import_picocolors63.default.dim(`No actions found for ${sanitizeLabel(slug)}.`) + `
|
|
86105
86475
|
`;
|
|
86106
86476
|
const lines = [""];
|
|
86107
86477
|
for (const row of rows) {
|
|
86108
|
-
const source =
|
|
86109
|
-
lines.push(` ${effectLabel(row.effect, 5)} ${source} ${
|
|
86478
|
+
const source = import_picocolors63.default.dim((row.source === "action" ? "" : `(${row.source})`).padEnd(9));
|
|
86479
|
+
lines.push(` ${effectLabel(row.effect, 5)} ${source} ${import_picocolors63.default.bold(sanitizeLabel(row.key))} ${import_picocolors63.default.dim(sanitizeLabel(row.name))}`);
|
|
86110
86480
|
}
|
|
86111
|
-
lines.push("",
|
|
86481
|
+
lines.push("", import_picocolors63.default.dim(` Change one with \`brainbase integrations allow|ask|deny ${sanitizeLabel(slug)}.<action>\`, or the whole app with \`… ${sanitizeLabel(slug)}\`.`), "");
|
|
86112
86482
|
return lines.join(`
|
|
86113
86483
|
`);
|
|
86114
86484
|
}
|
|
@@ -86172,14 +86542,14 @@ async function waitForAccount(agentId, slug, before2, options) {
|
|
|
86172
86542
|
}
|
|
86173
86543
|
|
|
86174
86544
|
// src/cli/task.ts
|
|
86175
|
-
var
|
|
86545
|
+
var import_picocolors69 = __toESM(require_picocolors(), 1);
|
|
86176
86546
|
|
|
86177
86547
|
// src/cli/task-create.ts
|
|
86178
|
-
var
|
|
86548
|
+
var import_picocolors65 = __toESM(require_picocolors(), 1);
|
|
86179
86549
|
import { randomUUID as randomUUID4 } from "node:crypto";
|
|
86180
86550
|
|
|
86181
86551
|
// src/cli/task-update.ts
|
|
86182
|
-
var
|
|
86552
|
+
var import_picocolors64 = __toESM(require_picocolors(), 1);
|
|
86183
86553
|
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]";
|
|
86184
86554
|
var TITLE_MAX = 200;
|
|
86185
86555
|
var MODEL_UNSUPPORTED = "This control plane does not support changing a task's model yet.";
|
|
@@ -86318,25 +86688,25 @@ function applyLabelEdit(current, edit) {
|
|
|
86318
86688
|
}
|
|
86319
86689
|
function format(task) {
|
|
86320
86690
|
const lines = [""];
|
|
86321
|
-
const title = task.title?.trim() ? sanitizeLabel(task.title) :
|
|
86322
|
-
lines.push(` ${
|
|
86691
|
+
const title = task.title?.trim() ? sanitizeLabel(task.title) : import_picocolors64.default.dim("(untitled)");
|
|
86692
|
+
lines.push(` ${import_picocolors64.default.green("updated")} ${import_picocolors64.default.bold(title)}`);
|
|
86323
86693
|
lines.push("");
|
|
86324
|
-
lines.push(` ${
|
|
86694
|
+
lines.push(` ${import_picocolors64.default.dim("task")} ${sanitizeLabel(task.id)}`);
|
|
86325
86695
|
if (task.model !== undefined) {
|
|
86326
|
-
const model = task.model?.trim() ? sanitizeLabel(task.model) :
|
|
86327
|
-
lines.push(` ${
|
|
86696
|
+
const model = task.model?.trim() ? sanitizeLabel(task.model) : import_picocolors64.default.dim("agent default");
|
|
86697
|
+
lines.push(` ${import_picocolors64.default.dim("model")} ${model}`);
|
|
86328
86698
|
}
|
|
86329
86699
|
const metadata = Object.entries(task.metadata ?? {});
|
|
86330
86700
|
lines.push("");
|
|
86331
|
-
lines.push(` ${
|
|
86701
|
+
lines.push(` ${import_picocolors64.default.bold(import_picocolors64.default.dim("METADATA"))}`);
|
|
86332
86702
|
if (metadata.length === 0) {
|
|
86333
|
-
lines.push(` ${
|
|
86703
|
+
lines.push(` ${import_picocolors64.default.dim("none")}`);
|
|
86334
86704
|
}
|
|
86335
86705
|
for (const [key2, value2] of metadata) {
|
|
86336
|
-
lines.push(` ${
|
|
86706
|
+
lines.push(` ${import_picocolors64.default.dim(sanitizeLabel(key2))} ${sanitizeLabel(value2)}`);
|
|
86337
86707
|
}
|
|
86338
86708
|
lines.push("");
|
|
86339
|
-
lines.push(` ${
|
|
86709
|
+
lines.push(` ${import_picocolors64.default.dim("read it with")} ${import_picocolors64.default.cyan(`brainbase task get ${sanitizeLabel(task.id)}`)}`, "");
|
|
86340
86710
|
return lines.join(`
|
|
86341
86711
|
`);
|
|
86342
86712
|
}
|
|
@@ -86382,13 +86752,13 @@ async function resolveAgentId2(cwd2, agentId, interfaceId, readLocalManifest) {
|
|
|
86382
86752
|
return manifest.id;
|
|
86383
86753
|
}
|
|
86384
86754
|
function isPublishScopeError(error2) {
|
|
86385
|
-
const
|
|
86755
|
+
const message3 = error2 instanceof Error ? error2.message : String(error2);
|
|
86386
86756
|
const body = error2 && typeof error2 === "object" && "body" in error2 ? JSON.stringify(error2.body) : "";
|
|
86387
|
-
return /PAT lacks required scope:\s*publish/i.test(`${
|
|
86757
|
+
return /PAT lacks required scope:\s*publish/i.test(`${message3} ${body}`);
|
|
86388
86758
|
}
|
|
86389
86759
|
async function runTaskCreate(cwd2, options, dependencies = {}) {
|
|
86390
86760
|
const idempotencyKey = (dependencies.randomUUID ?? randomUUID4)();
|
|
86391
|
-
const
|
|
86761
|
+
const message3 = requiredValue(options.message, "--message");
|
|
86392
86762
|
const interfaceId = optionalValue(options.interfaceId, "--interface");
|
|
86393
86763
|
const agentId = await resolveAgentId2(cwd2, options.agentId, interfaceId, dependencies.readManifest ?? readManifest);
|
|
86394
86764
|
const title = optionalValue(options.title, "--title");
|
|
@@ -86398,7 +86768,7 @@ async function runTaskCreate(cwd2, options, dependencies = {}) {
|
|
|
86398
86768
|
const version2 = versionRef ? (await agentVersionsApi.resolve(agentId, versionRef)).version : undefined;
|
|
86399
86769
|
const input = {
|
|
86400
86770
|
agent_id: agentId,
|
|
86401
|
-
initial_messages: [{ role: "user", content:
|
|
86771
|
+
initial_messages: [{ role: "user", content: message3 }],
|
|
86402
86772
|
auto_run: true,
|
|
86403
86773
|
...title ? { title } : {},
|
|
86404
86774
|
...model ? { default_model: model } : {},
|
|
@@ -86474,24 +86844,24 @@ async function waitForCreatedTask(created, options, dependencies, version2) {
|
|
|
86474
86844
|
return;
|
|
86475
86845
|
}
|
|
86476
86846
|
if (outcome.kind === "timeout") {
|
|
86477
|
-
console.log(
|
|
86847
|
+
console.log(import_picocolors65.default.yellow(`Timed out after ${options.timeoutSeconds}s with the task still ${status}.`));
|
|
86478
86848
|
return;
|
|
86479
86849
|
}
|
|
86480
86850
|
if (outcome.kind === "interrupted") {
|
|
86481
|
-
console.log(
|
|
86851
|
+
console.log(import_picocolors65.default.yellow("Interrupted. The task is still running."));
|
|
86482
86852
|
return;
|
|
86483
86853
|
}
|
|
86484
|
-
console.log(code === 0 ?
|
|
86854
|
+
console.log(code === 0 ? import_picocolors65.default.green("Task completed.") : import_picocolors65.default.red(`Task finished as ${status}.`));
|
|
86485
86855
|
} finally {
|
|
86486
86856
|
process.removeListener("SIGINT", onSigint);
|
|
86487
86857
|
}
|
|
86488
86858
|
}
|
|
86489
86859
|
|
|
86490
86860
|
// src/cli/task-get.ts
|
|
86491
|
-
var
|
|
86861
|
+
var import_picocolors67 = __toESM(require_picocolors(), 1);
|
|
86492
86862
|
|
|
86493
86863
|
// src/cli/task-list.ts
|
|
86494
|
-
var
|
|
86864
|
+
var import_picocolors66 = __toESM(require_picocolors(), 1);
|
|
86495
86865
|
|
|
86496
86866
|
// src/core/agent-names.ts
|
|
86497
86867
|
async function agentNames(ids) {
|
|
@@ -86556,29 +86926,29 @@ function labelFilter(options) {
|
|
|
86556
86926
|
function formatTaskList(tasks, names, agentId, interfaceId, labelFiltered = false) {
|
|
86557
86927
|
const lines = [""];
|
|
86558
86928
|
if (tasks.length === 0 && labelFiltered) {
|
|
86559
|
-
lines.push(` ${
|
|
86929
|
+
lines.push(` ${import_picocolors66.default.dim("No tasks carry every label given with --metadata.")}`, "");
|
|
86560
86930
|
return lines.join(`
|
|
86561
86931
|
`);
|
|
86562
86932
|
}
|
|
86563
86933
|
if (tasks.length === 0 && interfaceId) {
|
|
86564
86934
|
const id = sanitizeLabel(interfaceId);
|
|
86565
|
-
lines.push(` ${
|
|
86935
|
+
lines.push(` ${import_picocolors66.default.dim(`No build conversations for interface ${id}.`)}`, "", ` ${import_picocolors66.default.dim("start one with")} ${import_picocolors66.default.cyan(`brainbase interface build ${id} "..."`)}`, "");
|
|
86566
86936
|
return lines.join(`
|
|
86567
86937
|
`);
|
|
86568
86938
|
}
|
|
86569
86939
|
if (tasks.length === 0) {
|
|
86570
|
-
lines.push(` ${
|
|
86940
|
+
lines.push(` ${import_picocolors66.default.dim(agentId ? `No tasks for agent ${agentId}.` : "No tasks yet.")}`, "", ` ${import_picocolors66.default.dim("start one with")} ${import_picocolors66.default.cyan('brainbase task create --message "..."')}`, "");
|
|
86571
86941
|
return lines.join(`
|
|
86572
86942
|
`);
|
|
86573
86943
|
}
|
|
86574
86944
|
for (const task of tasks) {
|
|
86575
|
-
const title = sanitizeLabel(task.title ?? "").trim() ||
|
|
86576
|
-
lines.push(` ${statusLabel(task.status)} ${
|
|
86577
|
-
lines.push(` ${
|
|
86578
|
-
lines.push(` ${
|
|
86945
|
+
const title = sanitizeLabel(task.title ?? "").trim() || import_picocolors66.default.dim("(untitled)");
|
|
86946
|
+
lines.push(` ${statusLabel(task.status)} ${import_picocolors66.default.bold(title)}`);
|
|
86947
|
+
lines.push(` ${import_picocolors66.default.dim(sanitizeLabel(task.id))}`);
|
|
86948
|
+
lines.push(` ${import_picocolors66.default.dim(`agent ${agentLabel(task.agent_id, names)} · created ${sanitizeLabel(task.created_at)}`)}`);
|
|
86579
86949
|
lines.push("");
|
|
86580
86950
|
}
|
|
86581
|
-
lines.push(` ${
|
|
86951
|
+
lines.push(` ${import_picocolors66.default.dim("inspect one with")} ${import_picocolors66.default.cyan("brainbase task get <id>")}`, "");
|
|
86582
86952
|
return lines.join(`
|
|
86583
86953
|
`);
|
|
86584
86954
|
}
|
|
@@ -86586,16 +86956,16 @@ function statusLabel(status) {
|
|
|
86586
86956
|
const padded = sanitizeLabel(status).padEnd(14);
|
|
86587
86957
|
switch (status) {
|
|
86588
86958
|
case "success":
|
|
86589
|
-
return
|
|
86959
|
+
return import_picocolors66.default.green(padded);
|
|
86590
86960
|
case "fail":
|
|
86591
|
-
return
|
|
86961
|
+
return import_picocolors66.default.red(padded);
|
|
86592
86962
|
case "need_more_info":
|
|
86593
|
-
return
|
|
86963
|
+
return import_picocolors66.default.yellow(padded);
|
|
86594
86964
|
case "running":
|
|
86595
86965
|
case "initializing":
|
|
86596
|
-
return
|
|
86966
|
+
return import_picocolors66.default.cyan(padded);
|
|
86597
86967
|
default:
|
|
86598
|
-
return
|
|
86968
|
+
return import_picocolors66.default.dim(padded);
|
|
86599
86969
|
}
|
|
86600
86970
|
}
|
|
86601
86971
|
|
|
@@ -86629,60 +86999,60 @@ async function readEvalRuns(task) {
|
|
|
86629
86999
|
}
|
|
86630
87000
|
function format2(task, evals, names) {
|
|
86631
87001
|
const lines = [""];
|
|
86632
|
-
const title = sanitizeLabel(task.title ?? "").trim() ||
|
|
87002
|
+
const title = sanitizeLabel(task.title ?? "").trim() || import_picocolors67.default.dim("(untitled)");
|
|
86633
87003
|
const id = sanitizeLabel(task.id);
|
|
86634
|
-
lines.push(` ${statusLabel(task.status)} ${
|
|
87004
|
+
lines.push(` ${statusLabel(task.status)} ${import_picocolors67.default.bold(title)}`);
|
|
86635
87005
|
lines.push("");
|
|
86636
|
-
lines.push(` ${
|
|
86637
|
-
lines.push(` ${
|
|
87006
|
+
lines.push(` ${import_picocolors67.default.dim("task")} ${id}`);
|
|
87007
|
+
lines.push(` ${import_picocolors67.default.dim("agent")} ${agentLabel(task.agent_id, names)}`);
|
|
86638
87008
|
if (task.model !== undefined) {
|
|
86639
|
-
const model = task.model?.trim() ? sanitizeLabel(task.model) :
|
|
86640
|
-
lines.push(` ${
|
|
87009
|
+
const model = task.model?.trim() ? sanitizeLabel(task.model) : import_picocolors67.default.dim("agent default");
|
|
87010
|
+
lines.push(` ${import_picocolors67.default.dim("model")} ${model}`);
|
|
86641
87011
|
}
|
|
86642
|
-
lines.push(` ${
|
|
87012
|
+
lines.push(` ${import_picocolors67.default.dim("created")} ${sanitizeLabel(task.created_at)}`);
|
|
86643
87013
|
if (task.parent_task_id) {
|
|
86644
|
-
lines.push(` ${
|
|
87014
|
+
lines.push(` ${import_picocolors67.default.dim("parent")} ${sanitizeLabel(task.parent_task_id)}`);
|
|
86645
87015
|
}
|
|
86646
87016
|
if (task.machine_id) {
|
|
86647
87017
|
const size2 = task.machine_size ? ` (size ${sanitizeLabel(task.machine_size)})` : "";
|
|
86648
|
-
lines.push(` ${
|
|
87018
|
+
lines.push(` ${import_picocolors67.default.dim("machine")} ${sanitizeLabel(task.machine_id)}${size2}`);
|
|
86649
87019
|
}
|
|
86650
87020
|
if (task.sandbox_id)
|
|
86651
|
-
lines.push(` ${
|
|
87021
|
+
lines.push(` ${import_picocolors67.default.dim("sandbox")} ${sanitizeLabel(task.sandbox_id)}`);
|
|
86652
87022
|
const [failure, ...failureRest] = sanitizeLines(failureSummary(task) ?? "").filter((line2) => line2.trim());
|
|
86653
87023
|
if (failure) {
|
|
86654
87024
|
const label3 = " failure ";
|
|
86655
87025
|
lines.push("");
|
|
86656
|
-
lines.push(` ${
|
|
87026
|
+
lines.push(` ${import_picocolors67.default.red("failure")} ${failure}`);
|
|
86657
87027
|
for (const line2 of failureRest)
|
|
86658
87028
|
lines.push(`${" ".repeat(label3.length)}${line2}`);
|
|
86659
87029
|
}
|
|
86660
87030
|
const metadata = Object.entries(task.metadata ?? {});
|
|
86661
87031
|
if (metadata.length > 0) {
|
|
86662
87032
|
lines.push("");
|
|
86663
|
-
lines.push(` ${
|
|
87033
|
+
lines.push(` ${import_picocolors67.default.bold(import_picocolors67.default.dim("METADATA"))}`);
|
|
86664
87034
|
for (const [key2, value2] of metadata) {
|
|
86665
|
-
lines.push(` ${
|
|
87035
|
+
lines.push(` ${import_picocolors67.default.dim(sanitizeLabel(key2))} ${sanitizeLabel(String(value2))}`);
|
|
86666
87036
|
}
|
|
86667
87037
|
}
|
|
86668
87038
|
lines.push("");
|
|
86669
|
-
lines.push(` ${
|
|
87039
|
+
lines.push(` ${import_picocolors67.default.bold(import_picocolors67.default.dim("EVAL VERDICTS"))}`);
|
|
86670
87040
|
if (evals.unavailable) {
|
|
86671
|
-
lines.push(` ${
|
|
87041
|
+
lines.push(` ${import_picocolors67.default.dim(sanitizeLabel(evals.unavailable))}`);
|
|
86672
87042
|
} else if (evals.runs.length === 0) {
|
|
86673
|
-
lines.push(` ${
|
|
87043
|
+
lines.push(` ${import_picocolors67.default.dim("none")}`);
|
|
86674
87044
|
} else {
|
|
86675
87045
|
for (const run of evals.runs) {
|
|
86676
|
-
const verdict = run.passed === true ?
|
|
87046
|
+
const verdict = run.passed === true ? import_picocolors67.default.green("pass") : run.passed === false ? import_picocolors67.default.red("fail") : import_picocolors67.default.dim(sanitizeLabel(run.status));
|
|
86677
87047
|
lines.push(` ${verdict} ${sanitizeLabel(run.eval_slug ?? run.eval_id)}`);
|
|
86678
87048
|
for (const line2 of sanitizeLines(run.reasoning ?? "")) {
|
|
86679
87049
|
if (line2.trim())
|
|
86680
|
-
lines.push(` ${
|
|
87050
|
+
lines.push(` ${import_picocolors67.default.dim(line2)}`);
|
|
86681
87051
|
}
|
|
86682
87052
|
}
|
|
86683
87053
|
}
|
|
86684
87054
|
lines.push("");
|
|
86685
|
-
lines.push(` ${
|
|
87055
|
+
lines.push(` ${import_picocolors67.default.dim("read its transcript with")} ${import_picocolors67.default.cyan(`brainbase task logs ${id}`)}`, "");
|
|
86686
87056
|
return lines.join(`
|
|
86687
87057
|
`);
|
|
86688
87058
|
}
|
|
@@ -86699,7 +87069,7 @@ function failureSummary(task) {
|
|
|
86699
87069
|
}
|
|
86700
87070
|
|
|
86701
87071
|
// src/cli/task-logs.ts
|
|
86702
|
-
var
|
|
87072
|
+
var import_picocolors68 = __toESM(require_picocolors(), 1);
|
|
86703
87073
|
|
|
86704
87074
|
// src/core/task-events.ts
|
|
86705
87075
|
var DEFAULT_RETRY_BUDGET_MS = 60000;
|
|
@@ -86775,12 +87145,12 @@ function followTaskEvents(options) {
|
|
|
86775
87145
|
onOpen?.();
|
|
86776
87146
|
});
|
|
86777
87147
|
source.addEventListener("error", (event) => {
|
|
86778
|
-
const { message:
|
|
87148
|
+
const { message: message3, code } = event;
|
|
86779
87149
|
if (source.readyState === source.CLOSED) {
|
|
86780
|
-
finish(streamError(
|
|
87150
|
+
finish(streamError(message3, code));
|
|
86781
87151
|
return;
|
|
86782
87152
|
}
|
|
86783
|
-
lastReason =
|
|
87153
|
+
lastReason = message3?.trim() || "connection lost";
|
|
86784
87154
|
onReconnect?.(lastReason);
|
|
86785
87155
|
if (downTimer === undefined) {
|
|
86786
87156
|
downTimer = setTimeout(() => {
|
|
@@ -86800,8 +87170,8 @@ function parseFrameData(raw) {
|
|
|
86800
87170
|
return raw;
|
|
86801
87171
|
}
|
|
86802
87172
|
}
|
|
86803
|
-
function streamError(
|
|
86804
|
-
const detail =
|
|
87173
|
+
function streamError(message3, code) {
|
|
87174
|
+
const detail = message3?.trim() || "the log stream closed";
|
|
86805
87175
|
switch (code) {
|
|
86806
87176
|
case 401:
|
|
86807
87177
|
return new ApiError(`Not authorized to read this task's events: ${detail}`, 401);
|
|
@@ -86982,14 +87352,14 @@ async function runTaskLogs(taskId, options = {}, dependencies = {}) {
|
|
|
86982
87352
|
console.log(renderEvent(event, messages));
|
|
86983
87353
|
}
|
|
86984
87354
|
if (ordered.length === 0) {
|
|
86985
|
-
console.log(
|
|
87355
|
+
console.log(import_picocolors68.default.dim("No events for this task yet."));
|
|
86986
87356
|
}
|
|
86987
87357
|
}
|
|
86988
87358
|
async function followTranscript(taskId, options, dependencies) {
|
|
86989
87359
|
const backfill = options.limit === undefined ? "" : `?backfill=${options.limit}`;
|
|
86990
87360
|
const { url: url2, resolveBearer } = await masStreamTarget(`/tasks/${encodeURIComponent(taskId)}/events/stream${backfill}`);
|
|
86991
87361
|
if (!options.json) {
|
|
86992
|
-
console.log(
|
|
87362
|
+
console.log(import_picocolors68.default.dim(`Following task ${taskId} — Ctrl-C to stop.`));
|
|
86993
87363
|
}
|
|
86994
87364
|
const setExitCode = dependencies.setExitCode ?? ((code) => process.exitCode = code);
|
|
86995
87365
|
const controller = new AbortController;
|
|
@@ -87031,13 +87401,13 @@ async function followTranscript(taskId, options, dependencies) {
|
|
|
87031
87401
|
} else if (options.json) {
|
|
87032
87402
|
console.log(JSON.stringify(frame));
|
|
87033
87403
|
} else {
|
|
87034
|
-
console.log(
|
|
87404
|
+
console.log(import_picocolors68.default.dim(frame.type));
|
|
87035
87405
|
}
|
|
87036
87406
|
},
|
|
87037
87407
|
onOpen: () => settle.noteFrame(),
|
|
87038
87408
|
onReconnect: (reason) => {
|
|
87039
87409
|
settle.noteDisconnected();
|
|
87040
|
-
console.error(
|
|
87410
|
+
console.error(import_picocolors68.default.dim(`reconnecting — ${reason}`));
|
|
87041
87411
|
}
|
|
87042
87412
|
});
|
|
87043
87413
|
if (interruptCode !== undefined)
|
|
@@ -87193,8 +87563,8 @@ function errorCode(error2) {
|
|
|
87193
87563
|
const code = detail.code;
|
|
87194
87564
|
return typeof code === "string" ? code : undefined;
|
|
87195
87565
|
}
|
|
87196
|
-
function jsonError(error2,
|
|
87197
|
-
return { ...errorShape(error2), message:
|
|
87566
|
+
function jsonError(error2, message3, status, code) {
|
|
87567
|
+
return { ...errorShape(error2), message: message3, status, ...code ? { code } : {} };
|
|
87198
87568
|
}
|
|
87199
87569
|
function stopRetryCommand(taskId, generation) {
|
|
87200
87570
|
const argument = /^[A-Za-z0-9_-]+$/.test(taskId) ? taskId : `'${sanitizeLabel(taskId).replaceAll("'", "'\\''")}'`;
|
|
@@ -87244,8 +87614,8 @@ function onInterrupt(handler) {
|
|
|
87244
87614
|
process.off(name, listener);
|
|
87245
87615
|
};
|
|
87246
87616
|
}
|
|
87247
|
-
async function runTaskSend(taskId,
|
|
87248
|
-
if (!
|
|
87617
|
+
async function runTaskSend(taskId, message3, options = {}) {
|
|
87618
|
+
if (!message3.trim())
|
|
87249
87619
|
throw new Error("The follow-up message must not be blank.");
|
|
87250
87620
|
const inputId = options.inputId?.trim().toLowerCase() ?? randomUUID5();
|
|
87251
87621
|
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(inputId)) {
|
|
@@ -87264,7 +87634,7 @@ async function runTaskSend(taskId, message2, options = {}) {
|
|
|
87264
87634
|
attempted = true;
|
|
87265
87635
|
result2 = await masApi.sendTaskInput(taskId, {
|
|
87266
87636
|
input_id: inputId,
|
|
87267
|
-
messages: [{ role: "user", content:
|
|
87637
|
+
messages: [{ role: "user", content: message3 }],
|
|
87268
87638
|
expected_generation: expectedGeneration
|
|
87269
87639
|
});
|
|
87270
87640
|
} catch (error2) {
|
|
@@ -87343,17 +87713,17 @@ async function runTaskStop(taskId, options = {}) {
|
|
|
87343
87713
|
${retry}
|
|
87344
87714
|
Omit --generation only for a deliberately new Stop.`;
|
|
87345
87715
|
}
|
|
87346
|
-
const
|
|
87716
|
+
const message3 = `${detail}${guidance}`;
|
|
87347
87717
|
if (options.json) {
|
|
87348
87718
|
console.log(JSON.stringify({
|
|
87349
87719
|
task_id: taskId,
|
|
87350
87720
|
expected_generation: expectedGeneration,
|
|
87351
|
-
error: jsonError(error2,
|
|
87721
|
+
error: jsonError(error2, message3, status, code)
|
|
87352
87722
|
}));
|
|
87353
87723
|
process.exitCode = 1;
|
|
87354
87724
|
return;
|
|
87355
87725
|
}
|
|
87356
|
-
throw new ApiError(
|
|
87726
|
+
throw new ApiError(message3, status, error2 instanceof ApiError ? error2.body : undefined);
|
|
87357
87727
|
}
|
|
87358
87728
|
if (options.json) {
|
|
87359
87729
|
console.log(JSON.stringify({ ...task, expected_generation: expectedGeneration }, null, 2));
|
|
@@ -87715,78 +88085,78 @@ ${didYouMean(sub, ["create", "list", "get", "logs", "send", "stop", "update", "d
|
|
|
87715
88085
|
function printHelp5() {
|
|
87716
88086
|
const out = [];
|
|
87717
88087
|
out.push("");
|
|
87718
|
-
out.push(` ${
|
|
88088
|
+
out.push(` ${import_picocolors69.default.bold("brainbase task")} ${import_picocolors69.default.dim("<sub> [options]")}`);
|
|
87719
88089
|
out.push("");
|
|
87720
|
-
out.push(` ${
|
|
87721
|
-
out.push(` ${
|
|
87722
|
-
out.push(` ${
|
|
87723
|
-
out.push(` ${
|
|
87724
|
-
out.push(` ${
|
|
87725
|
-
out.push(` ${
|
|
87726
|
-
out.push(` ${
|
|
87727
|
-
out.push(` ${
|
|
88090
|
+
out.push(` ${import_picocolors69.default.cyan("create")} ${import_picocolors69.default.dim("--message <text>")} ${import_picocolors69.default.dim("create a task and start its first run")}`);
|
|
88091
|
+
out.push(` ${import_picocolors69.default.cyan("list | ls")} ${import_picocolors69.default.dim("recent tasks you can reach (--json for scripts)")}`);
|
|
88092
|
+
out.push(` ${import_picocolors69.default.cyan("get")} ${import_picocolors69.default.dim("<task-id>")} ${import_picocolors69.default.dim("one task: status, agent, machine, eval verdicts")}`);
|
|
88093
|
+
out.push(` ${import_picocolors69.default.cyan("logs")} ${import_picocolors69.default.dim("<task-id> [--follow]")} ${import_picocolors69.default.dim("one line per event in the task's transcript, or tail it live")}`);
|
|
88094
|
+
out.push(` ${import_picocolors69.default.cyan("send")} ${import_picocolors69.default.dim("<task-id> <message>")} ${import_picocolors69.default.dim("send a follow-up, including while the agent is running")}`);
|
|
88095
|
+
out.push(` ${import_picocolors69.default.cyan("stop")} ${import_picocolors69.default.dim("<task-id>")} ${import_picocolors69.default.dim("stop execution and cancel pending follow-ups, retaining their text")}`);
|
|
88096
|
+
out.push(` ${import_picocolors69.default.cyan("update")} ${import_picocolors69.default.dim("<task-id>")} ${import_picocolors69.default.dim("rename a task, change its metadata labels, switch its model or reset it to the agent default, including while it runs")}`);
|
|
88097
|
+
out.push(` ${import_picocolors69.default.cyan("delete")} ${import_picocolors69.default.dim("<task-id>")} ${import_picocolors69.default.dim("permanently delete a stopped task and tear down its sandbox (--yes to skip the prompt)")}`);
|
|
87728
88098
|
out.push("");
|
|
87729
|
-
out.push(` ${
|
|
87730
|
-
out.push(` ${
|
|
87731
|
-
out.push(` ${
|
|
87732
|
-
out.push(` ${
|
|
87733
|
-
out.push(` ${
|
|
87734
|
-
out.push(` ${
|
|
87735
|
-
out.push(` ${
|
|
87736
|
-
out.push(` ${
|
|
87737
|
-
out.push(` ${
|
|
87738
|
-
out.push(` ${
|
|
88099
|
+
out.push(` ${import_picocolors69.default.bold("create flags")}`);
|
|
88100
|
+
out.push(` ${import_picocolors69.default.dim("--message <text>")} required first user message`);
|
|
88101
|
+
out.push(` ${import_picocolors69.default.dim("--agent <id>")} override the claimed agent in brainbase.agent.yaml`);
|
|
88102
|
+
out.push(` ${import_picocolors69.default.dim("--interface <id>")} open it as a build conversation for this interface (agent defaults to the interface's)`);
|
|
88103
|
+
out.push(` ${import_picocolors69.default.dim("--title <text>")} optional task title`);
|
|
88104
|
+
out.push(` ${import_picocolors69.default.dim("--model <id>")} optional model override`);
|
|
88105
|
+
out.push(` ${import_picocolors69.default.dim("--version <v>")} run a saved version of the agent: 12, v12 or a version id (\`agent versions list\`)`);
|
|
88106
|
+
out.push(` ${import_picocolors69.default.dim("--metadata key=value")} label the task (repeatable)`);
|
|
88107
|
+
out.push(` ${import_picocolors69.default.dim("--wait")} block until the task finishes; exit 1 unless it succeeded`);
|
|
88108
|
+
out.push(` ${import_picocolors69.default.dim("--timeout <secs>")} give up waiting after <secs> and exit 1 (needs --wait)`);
|
|
87739
88109
|
out.push("");
|
|
87740
|
-
out.push(` ${
|
|
87741
|
-
out.push(` ${
|
|
87742
|
-
out.push(` ${
|
|
87743
|
-
out.push(` ${
|
|
87744
|
-
out.push(` ${
|
|
88110
|
+
out.push(` ${import_picocolors69.default.bold("list flags")}`);
|
|
88111
|
+
out.push(` ${import_picocolors69.default.dim("--agent <id>")} only this agent's tasks`);
|
|
88112
|
+
out.push(` ${import_picocolors69.default.dim("--interface <id>")} only this interface's build conversations (hidden from a plain list)`);
|
|
88113
|
+
out.push(` ${import_picocolors69.default.dim("--metadata key=value")} only tasks carrying this label (repeatable; all must match)`);
|
|
88114
|
+
out.push(` ${import_picocolors69.default.dim("--limit <n>")} cap the page (1-200, server default 50)`);
|
|
87745
88115
|
out.push("");
|
|
87746
|
-
out.push(` ${
|
|
87747
|
-
out.push(` ${
|
|
87748
|
-
out.push(` ${
|
|
88116
|
+
out.push(` ${import_picocolors69.default.bold("logs flags")}`);
|
|
88117
|
+
out.push(` ${import_picocolors69.default.dim("--limit <n>")} stop after <n> events instead of the whole transcript; with --follow, the first page size`);
|
|
88118
|
+
out.push(` ${import_picocolors69.default.dim("--follow, -f")} stay attached and print events as they land, until the task finishes and any queued follow-ups have run`);
|
|
87749
88119
|
out.push("");
|
|
87750
|
-
out.push(` ${
|
|
87751
|
-
out.push(` ${
|
|
87752
|
-
out.push(` ${
|
|
87753
|
-
out.push(` ${
|
|
87754
|
-
out.push(` ${
|
|
87755
|
-
out.push(` ${
|
|
87756
|
-
out.push(` ${
|
|
87757
|
-
out.push(` ${
|
|
87758
|
-
out.push(` ${
|
|
88120
|
+
out.push(` ${import_picocolors69.default.bold("update flags")}`);
|
|
88121
|
+
out.push(` ${import_picocolors69.default.dim("--title <text>")} new title`);
|
|
88122
|
+
out.push(` ${import_picocolors69.default.dim("--clear-title")} remove the title; automatic titling may name the task again on a later turn`);
|
|
88123
|
+
out.push(` ${import_picocolors69.default.dim("--metadata key=value")} set one label, keeping the others (repeatable)`);
|
|
88124
|
+
out.push(` ${import_picocolors69.default.dim("--unset-metadata <key>")} remove one label (repeatable)`);
|
|
88125
|
+
out.push(` ${import_picocolors69.default.dim(" the server applies label edits in one step, so concurrent edits from other clients are kept")}`);
|
|
88126
|
+
out.push(` ${import_picocolors69.default.dim("--clear-metadata")} remove every label; with --metadata, the labels become exactly those given`);
|
|
88127
|
+
out.push(` ${import_picocolors69.default.dim("--model <id>")} switch the model the task's next turn runs on (the running turn keeps its model)`);
|
|
88128
|
+
out.push(` ${import_picocolors69.default.dim("--clear-model")} go back to the agent's default model from the next turn`);
|
|
87759
88129
|
out.push("");
|
|
87760
|
-
out.push(` ${
|
|
87761
|
-
out.push(` ${
|
|
87762
|
-
out.push(` ${
|
|
87763
|
-
out.push(` ${
|
|
88130
|
+
out.push(` ${import_picocolors69.default.bold("send flags")}`);
|
|
88131
|
+
out.push(` ${import_picocolors69.default.dim("--input-id <uuid>")} recover the same request using its original ID and identical message`);
|
|
88132
|
+
out.push(` ${import_picocolors69.default.dim(" omit it to send a new follow-up; an unconfirmed receipt is never automatically replayed")}`);
|
|
88133
|
+
out.push(` ${import_picocolors69.default.dim(" admission disabled/recovery unavailable means no input was admitted; retry the same ID after recovery")}`);
|
|
87764
88134
|
out.push("");
|
|
87765
|
-
out.push(` ${
|
|
87766
|
-
out.push(` ${
|
|
87767
|
-
out.push(` ${
|
|
88135
|
+
out.push(` ${import_picocolors69.default.bold("send and stop flags")}`);
|
|
88136
|
+
out.push(` ${import_picocolors69.default.dim("--generation <n>")} retain the printed generation when retrying; defaults to a fresh snapshot for a new operation`);
|
|
88137
|
+
out.push(` ${import_picocolors69.default.dim(" Stop errors may follow queued-input cancellation; retry the printed command to avoid stopping newer work")}`);
|
|
87768
88138
|
out.push("");
|
|
87769
|
-
out.push(` ${
|
|
87770
|
-
out.push(` ${
|
|
87771
|
-
out.push(` ${
|
|
87772
|
-
out.push(` ${
|
|
88139
|
+
out.push(` ${import_picocolors69.default.bold("every subcommand")}`);
|
|
88140
|
+
out.push(` ${import_picocolors69.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`);
|
|
88141
|
+
out.push(` ${import_picocolors69.default.dim(" send and stop include expected_generation for safe retries; send also reports idempotency_replayed when present")}`);
|
|
88142
|
+
out.push(` ${import_picocolors69.default.dim(" logs --follow --json prints one record per line, since a live stream has no end to close on")}`);
|
|
87773
88143
|
out.push("");
|
|
87774
|
-
out.push(` ${
|
|
87775
|
-
out.push(` ${
|
|
87776
|
-
out.push(` ${
|
|
87777
|
-
out.push(` ${
|
|
88144
|
+
out.push(` ${import_picocolors69.default.dim("Exit codes with --wait:")} ${import_picocolors69.default.dim("0 succeeded · 1 failed, needs input, or timed out · 130 interrupted")}`);
|
|
88145
|
+
out.push(` ${import_picocolors69.default.dim("Exit codes with --follow:")} ${import_picocolors69.default.dim("0 task reached a terminal state · 1 stream refused, or unreachable for 60s · 130 interrupted (Ctrl-C) · 143 terminated")}`);
|
|
88146
|
+
out.push(` ${import_picocolors69.default.dim("Exit codes with send:")} ${import_picocolors69.default.dim("0 queued, dispatching, submitted or completed · 1 unconfirmed, cancelled, failed or request error")}`);
|
|
88147
|
+
out.push(` ${import_picocolors69.default.dim("Ctrl-C while waiting or following logs detaches; use task stop to cancel remote work.")}`);
|
|
87778
88148
|
out.push("");
|
|
87779
|
-
out.push(` ${
|
|
88149
|
+
out.push(` ${import_picocolors69.default.dim("Flag-like values:")} use ${import_picocolors69.default.cyan("--flag=value")} or ${import_picocolors69.default.cyan("--flag -- <value>")}`);
|
|
87780
88150
|
out.push("");
|
|
87781
88151
|
console.log(out.join(`
|
|
87782
88152
|
`));
|
|
87783
88153
|
}
|
|
87784
88154
|
|
|
87785
88155
|
// src/cli/machine.ts
|
|
87786
|
-
var
|
|
88156
|
+
var import_picocolors72 = __toESM(require_picocolors(), 1);
|
|
87787
88157
|
|
|
87788
88158
|
// src/cli/machine-list.ts
|
|
87789
|
-
var
|
|
88159
|
+
var import_picocolors70 = __toESM(require_picocolors(), 1);
|
|
87790
88160
|
async function runMachineList(args = {}) {
|
|
87791
88161
|
if (!args.json)
|
|
87792
88162
|
banner("machine list — sandboxes you can reach");
|
|
@@ -87804,7 +88174,7 @@ async function runMachineList(args = {}) {
|
|
|
87804
88174
|
function formatMachineList(machines, includedDead, names = new Map) {
|
|
87805
88175
|
const lines = [""];
|
|
87806
88176
|
if (machines.length === 0) {
|
|
87807
|
-
lines.push(` ${
|
|
88177
|
+
lines.push(` ${import_picocolors70.default.dim(includedDead ? "No machines." : "No live machines. Pass --all to include torn-down ones.")}`, "");
|
|
87808
88178
|
return lines.join(`
|
|
87809
88179
|
`);
|
|
87810
88180
|
}
|
|
@@ -87824,7 +88194,7 @@ function formatMachineList(machines, includedDead, names = new Map) {
|
|
|
87824
88194
|
const statusWidth = width((row) => row.status);
|
|
87825
88195
|
const sizeWidth = width((row) => row.size);
|
|
87826
88196
|
const agentWidth = width((row) => row.agent);
|
|
87827
|
-
lines.push(` ${
|
|
88197
|
+
lines.push(` ${import_picocolors70.default.dim([
|
|
87828
88198
|
header.id.padEnd(idWidth),
|
|
87829
88199
|
header.kind.padEnd(kindWidth),
|
|
87830
88200
|
header.status.padEnd(statusWidth),
|
|
@@ -87840,21 +88210,21 @@ function formatMachineList(machines, includedDead, names = new Map) {
|
|
|
87840
88210
|
row.dead ? status : statusTint(row.status, status),
|
|
87841
88211
|
row.size.padEnd(sizeWidth),
|
|
87842
88212
|
row.agent.padEnd(agentWidth),
|
|
87843
|
-
|
|
88213
|
+
import_picocolors70.default.dim(row.age)
|
|
87844
88214
|
].join(" ");
|
|
87845
|
-
lines.push(` ${row.dead ?
|
|
88215
|
+
lines.push(` ${row.dead ? import_picocolors70.default.dim(cells) : cells}`);
|
|
87846
88216
|
}
|
|
87847
|
-
lines.push("", ` ${
|
|
88217
|
+
lines.push("", ` ${import_picocolors70.default.dim("tear one down with")} ${import_picocolors70.default.cyan("brainbase machine rm <id>")}`, "");
|
|
87848
88218
|
return lines.join(`
|
|
87849
88219
|
`);
|
|
87850
88220
|
}
|
|
87851
88221
|
function statusTint(status, padded) {
|
|
87852
88222
|
switch (status) {
|
|
87853
88223
|
case "running":
|
|
87854
|
-
return
|
|
88224
|
+
return import_picocolors70.default.green(padded);
|
|
87855
88225
|
case "stopped":
|
|
87856
88226
|
case "starting":
|
|
87857
|
-
return
|
|
88227
|
+
return import_picocolors70.default.yellow(padded);
|
|
87858
88228
|
default:
|
|
87859
88229
|
return padded;
|
|
87860
88230
|
}
|
|
@@ -87877,7 +88247,7 @@ function age(createdAt) {
|
|
|
87877
88247
|
}
|
|
87878
88248
|
|
|
87879
88249
|
// src/cli/machine-rm.ts
|
|
87880
|
-
var
|
|
88250
|
+
var import_picocolors71 = __toESM(require_picocolors(), 1);
|
|
87881
88251
|
async function runMachineRm(args, dependencies = {}) {
|
|
87882
88252
|
const setExitCode = dependencies.setExitCode ?? ((code) => process.exitCode = code);
|
|
87883
88253
|
const machineId = args.machineId?.trim();
|
|
@@ -87891,7 +88261,7 @@ async function runMachineRm(args, dependencies = {}) {
|
|
|
87891
88261
|
if (args.json) {
|
|
87892
88262
|
console.log(JSON.stringify({ id: machineId, torn_down: false, outcome: "declined" }, null, 2));
|
|
87893
88263
|
} else {
|
|
87894
|
-
console.log(` ${
|
|
88264
|
+
console.log(` ${import_picocolors71.default.dim("Left alone.")}`);
|
|
87895
88265
|
}
|
|
87896
88266
|
return;
|
|
87897
88267
|
}
|
|
@@ -87909,7 +88279,7 @@ async function promptForTeardown(args) {
|
|
|
87909
88279
|
return true;
|
|
87910
88280
|
if (!args.json) {
|
|
87911
88281
|
console.log(`
|
|
87912
|
-
${
|
|
88282
|
+
${import_picocolors71.default.red("This destroys the sandbox.")} ${import_picocolors71.default.dim("Anything not committed out of it is lost. The machine row is kept for cost history.")}
|
|
87913
88283
|
`);
|
|
87914
88284
|
}
|
|
87915
88285
|
const answer = await se({
|
|
@@ -87921,9 +88291,9 @@ async function promptForTeardown(args) {
|
|
|
87921
88291
|
function formatMachineRm(machine) {
|
|
87922
88292
|
const lines = [""];
|
|
87923
88293
|
if (machine.destroyed_at) {
|
|
87924
|
-
lines.push(` ${
|
|
88294
|
+
lines.push(` ${import_picocolors71.default.green("✓")} ${machine.kind} sandbox ${machine.id} is torn down.`, ` ${import_picocolors71.default.dim(`destroyed_at ${machine.destroyed_at}`)}`);
|
|
87925
88295
|
} else {
|
|
87926
|
-
lines.push(` ${
|
|
88296
|
+
lines.push(` ${import_picocolors71.default.yellow("!")} ${machine.id} came back without a teardown timestamp (status ${machine.status}).`, ` ${import_picocolors71.default.dim("Re-check with `brainbase machine ls --all` before assuming it stopped billing.")}`);
|
|
87927
88297
|
}
|
|
87928
88298
|
lines.push("");
|
|
87929
88299
|
return lines.join(`
|
|
@@ -87964,25 +88334,25 @@ ${didYouMean(sub, ["ls", "rm"], "brainbase machine")}`);
|
|
|
87964
88334
|
function printHelp6() {
|
|
87965
88335
|
const out = [];
|
|
87966
88336
|
out.push("");
|
|
87967
|
-
out.push(` ${
|
|
88337
|
+
out.push(` ${import_picocolors72.default.bold("brainbase machine")} ${import_picocolors72.default.dim("<sub> [options]")}`);
|
|
87968
88338
|
out.push("");
|
|
87969
|
-
out.push(` ${
|
|
87970
|
-
out.push(` ${
|
|
88339
|
+
out.push(` ${import_picocolors72.default.cyan("ls")} ${import_picocolors72.default.dim("list your sandboxes — live ones only unless --all")}`);
|
|
88340
|
+
out.push(` ${import_picocolors72.default.cyan("rm")} ${import_picocolors72.default.dim("<id>")} ${import_picocolors72.default.dim("tear a sandbox down (terminal; the row is kept for cost history)")}`);
|
|
87971
88341
|
out.push("");
|
|
87972
|
-
out.push(` ${
|
|
87973
|
-
out.push(` ${
|
|
87974
|
-
out.push(` ${
|
|
87975
|
-
out.push(` ${
|
|
88342
|
+
out.push(` ${import_picocolors72.default.dim("--all")} ${import_picocolors72.default.dim("for ls: include machines already torn down")}`);
|
|
88343
|
+
out.push(` ${import_picocolors72.default.dim("--limit <n>")} ${import_picocolors72.default.dim("for ls: how many to fetch (1-200, default 50)")}`);
|
|
88344
|
+
out.push(` ${import_picocolors72.default.dim("--yes, -y")} ${import_picocolors72.default.dim("for rm: skip the confirmation")}`);
|
|
88345
|
+
out.push(` ${import_picocolors72.default.dim("--json")} ${import_picocolors72.default.dim("machine-readable output")}`);
|
|
87976
88346
|
out.push("");
|
|
87977
88347
|
console.log(out.join(`
|
|
87978
88348
|
`));
|
|
87979
88349
|
}
|
|
87980
88350
|
|
|
87981
88351
|
// src/cli/interface.ts
|
|
87982
|
-
var
|
|
88352
|
+
var import_picocolors78 = __toESM(require_picocolors(), 1);
|
|
87983
88353
|
|
|
87984
88354
|
// src/cli/interface-build.ts
|
|
87985
|
-
var
|
|
88355
|
+
var import_picocolors73 = __toESM(require_picocolors(), 1);
|
|
87986
88356
|
var USAGE2 = 'brainbase interface build <id> "<request>" [--timeout <seconds>] [--idempotency-key <key>] [--json]';
|
|
87987
88357
|
var SETTLE_TIMEOUT_MS = 120000;
|
|
87988
88358
|
async function reportingErrors(json3, work) {
|
|
@@ -88009,8 +88379,8 @@ function heldBy(row, ownTaskId) {
|
|
|
88009
88379
|
const taskId = held.thread_id;
|
|
88010
88380
|
if (ownTaskId !== undefined && taskId === ownTaskId)
|
|
88011
88381
|
return null;
|
|
88012
|
-
const
|
|
88013
|
-
return cliRefusal("conflict", "generation_running",
|
|
88382
|
+
const message3 = taskId ? `Another build conversation (${safe(taskId)}) is working on this interface. Follow it with \`brainbase task logs ${safe(taskId)} --follow\`, or wait for it to finish and run this again.` : `A build conversation is working on this interface (operation ${safe(held.operation_id)}). Wait for it to finish and run this again.`;
|
|
88383
|
+
return cliRefusal("conflict", "generation_running", message3, {
|
|
88014
88384
|
operation_id: held.operation_id,
|
|
88015
88385
|
task_id: taskId
|
|
88016
88386
|
});
|
|
@@ -88081,28 +88451,28 @@ function buildExitCode(outcome) {
|
|
|
88081
88451
|
function reportBuild(say, interfaceId, outcome, timeoutSeconds) {
|
|
88082
88452
|
switch (outcome.kind) {
|
|
88083
88453
|
case "built":
|
|
88084
|
-
say(` ${
|
|
88454
|
+
say(` ${import_picocolors73.default.dim("build")} ${safe(outcome.build.id)} ${import_picocolors73.default.green("succeeded")}`);
|
|
88085
88455
|
say("");
|
|
88086
|
-
say(` ${
|
|
88456
|
+
say(` ${import_picocolors73.default.dim("Next:")} ${import_picocolors73.default.cyan(`brainbase interface publish ${safe(interfaceId)}`)}`);
|
|
88087
88457
|
return;
|
|
88088
88458
|
case "failed": {
|
|
88089
88459
|
const reason = outcome.build?.error_summary ?? outcome.operation?.error ?? outcome.operation?.reason ?? null;
|
|
88090
|
-
say(` ${
|
|
88460
|
+
say(` ${import_picocolors73.default.dim("build")} ${outcome.build ? safe(outcome.build.id) : import_picocolors73.default.dim("none")} ${import_picocolors73.default.red("failed")}`);
|
|
88091
88461
|
if (reason)
|
|
88092
88462
|
say(` ${safeBlock(reason).split(`
|
|
88093
88463
|
`).join(`
|
|
88094
88464
|
`)}`);
|
|
88095
|
-
say(` ${
|
|
88465
|
+
say(` ${import_picocolors73.default.dim("Try again with")} ${import_picocolors73.default.cyan(`brainbase interface rebuild ${safe(interfaceId)}`)}`);
|
|
88096
88466
|
return;
|
|
88097
88467
|
}
|
|
88098
88468
|
case "busy":
|
|
88099
|
-
say(` ${
|
|
88469
|
+
say(` ${import_picocolors73.default.yellow(safe(outcome.message))}`);
|
|
88100
88470
|
return;
|
|
88101
88471
|
case "timeout":
|
|
88102
|
-
say(` ${
|
|
88472
|
+
say(` ${import_picocolors73.default.yellow(`Still building after ${timeoutSeconds}s.`)} ${import_picocolors73.default.dim(`It keeps going; check \`brainbase interface builds ${safe(interfaceId)}\`.`)}`);
|
|
88103
88473
|
return;
|
|
88104
88474
|
case "interrupted":
|
|
88105
|
-
say(` ${
|
|
88475
|
+
say(` ${import_picocolors73.default.yellow("Stopped waiting.")} ${import_picocolors73.default.dim(`The build keeps going; check \`brainbase interface builds ${safe(interfaceId)}\`.`)}`);
|
|
88106
88476
|
return;
|
|
88107
88477
|
default: {
|
|
88108
88478
|
const unreachable = outcome;
|
|
@@ -88149,8 +88519,8 @@ async function build(ctx) {
|
|
|
88149
88519
|
throw held;
|
|
88150
88520
|
}
|
|
88151
88521
|
const reattach = `brainbase task logs ${safe(taskId)} --follow`;
|
|
88152
|
-
say(` ${
|
|
88153
|
-
say(` ${
|
|
88522
|
+
say(` ${import_picocolors73.default.dim("Build conversation")} ${import_picocolors73.default.bold(safe(taskId))} ${import_picocolors73.default.dim(`on ${safe(before2.name)}`)}`);
|
|
88523
|
+
say(` ${import_picocolors73.default.dim(`If this stops early, reattach with \`${reattach}\`.`)}`);
|
|
88154
88524
|
const finish = (result2, exitCode) => {
|
|
88155
88525
|
if (json3)
|
|
88156
88526
|
console.log(JSON.stringify({ type: "result", task_id: taskId, ...result2 }));
|
|
@@ -88167,13 +88537,13 @@ async function build(ctx) {
|
|
|
88167
88537
|
});
|
|
88168
88538
|
} catch (error2) {
|
|
88169
88539
|
say("");
|
|
88170
|
-
say(` ${
|
|
88171
|
-
say(` ${
|
|
88540
|
+
say(` ${import_picocolors73.default.red(`Lost the conversation's event stream: ${safe(error2.message)}`)}`);
|
|
88541
|
+
say(` ${import_picocolors73.default.dim(`Conversation ${safe(taskId)} may still be running. Reattach with`)} ${import_picocolors73.default.cyan(reattach)}`);
|
|
88172
88542
|
finish({ version_id: null, build_id: null, status: "stream_lost", task_status: null }, 1);
|
|
88173
88543
|
return;
|
|
88174
88544
|
}
|
|
88175
88545
|
if (followExit !== undefined) {
|
|
88176
|
-
say(` ${
|
|
88546
|
+
say(` ${import_picocolors73.default.yellow("Stopped following.")} ${import_picocolors73.default.dim(`The conversation keeps running. Reattach with \`${reattach}\`.`)}`);
|
|
88177
88547
|
finish({ version_id: null, build_id: null, status: "interrupted", task_status: null }, followExit);
|
|
88178
88548
|
return;
|
|
88179
88549
|
}
|
|
@@ -88188,7 +88558,7 @@ async function build(ctx) {
|
|
|
88188
88558
|
if (settled.kind !== "terminal") {
|
|
88189
88559
|
const interrupted = settled.kind === "interrupted";
|
|
88190
88560
|
const status2 = settled.task?.status ?? null;
|
|
88191
|
-
say(` ${
|
|
88561
|
+
say(` ${import_picocolors73.default.yellow(interrupted ? "Stopped." : `The conversation is still ${safe(status2 ?? "running")}.`)} ${import_picocolors73.default.dim(`Check it with \`brainbase task get ${safe(taskId)}\`.`)}`);
|
|
88192
88562
|
finish({ version_id: null, build_id: null, status: interrupted ? "interrupted" : "task_unsettled", task_status: status2 }, interrupted ? SIGINT_EXIT_CODE : 1);
|
|
88193
88563
|
return;
|
|
88194
88564
|
}
|
|
@@ -88208,36 +88578,36 @@ async function build(ctx) {
|
|
|
88208
88578
|
}
|
|
88209
88579
|
const codes = [exitCodeForTaskStatus(task.status)];
|
|
88210
88580
|
say("");
|
|
88211
|
-
say(` ${
|
|
88581
|
+
say(` ${import_picocolors73.default.dim("conversation")} ${safe(taskId)} ${import_picocolors73.default.dim("ended")} ${safe(task.status)}`);
|
|
88212
88582
|
if (mine?.status === "failed") {
|
|
88213
88583
|
codes.push(1);
|
|
88214
88584
|
const why = [mine.reason, mine.error].filter(Boolean).map((part) => safe(part)).join(": ");
|
|
88215
|
-
say(` ${
|
|
88585
|
+
say(` ${import_picocolors73.default.red(`This conversation's build work failed${why ? ` (${why})` : ""}.`)}`);
|
|
88216
88586
|
} else if (task.status !== "success" && task.status !== "need_more_info") {
|
|
88217
|
-
say(` ${
|
|
88587
|
+
say(` ${import_picocolors73.default.red(`The conversation finished as ${safe(task.status)}.`)} ${import_picocolors73.default.dim(`See \`brainbase task logs ${safe(taskId)}\`.`)}`);
|
|
88218
88588
|
}
|
|
88219
88589
|
if (task.status === "need_more_info") {
|
|
88220
88590
|
const question = await lastAgentMessage(taskId);
|
|
88221
88591
|
say("");
|
|
88222
88592
|
if (question) {
|
|
88223
|
-
say(` ${
|
|
88593
|
+
say(` ${import_picocolors73.default.bold("The agent asks:")}`);
|
|
88224
88594
|
say(` ${safeBlock(question).split(`
|
|
88225
88595
|
`).join(`
|
|
88226
88596
|
`)}`);
|
|
88227
88597
|
} else {
|
|
88228
|
-
say(` ${
|
|
88598
|
+
say(` ${import_picocolors73.default.bold("The agent needs more from you before it can go on.")}`);
|
|
88229
88599
|
}
|
|
88230
88600
|
say("");
|
|
88231
|
-
say(` ${
|
|
88232
|
-
say(` ${
|
|
88601
|
+
say(` ${import_picocolors73.default.dim("Reply with")} ${import_picocolors73.default.cyan(`brainbase task send ${safe(taskId)} "<reply>"`)}`);
|
|
88602
|
+
say(` ${import_picocolors73.default.dim("then follow it with")} ${import_picocolors73.default.cyan(reattach)}`);
|
|
88233
88603
|
}
|
|
88234
88604
|
let status;
|
|
88235
88605
|
let buildId = null;
|
|
88236
88606
|
if (versionId) {
|
|
88237
88607
|
say("");
|
|
88238
|
-
say(` ${
|
|
88608
|
+
say(` ${import_picocolors73.default.dim("version")} ${safe(versionId)}`);
|
|
88239
88609
|
if (!json3)
|
|
88240
|
-
say(` ${
|
|
88610
|
+
say(` ${import_picocolors73.default.dim("Waiting for its build...")}`);
|
|
88241
88611
|
const buildKey = `${key2}-build`;
|
|
88242
88612
|
let outcome;
|
|
88243
88613
|
try {
|
|
@@ -88247,7 +88617,7 @@ async function build(ctx) {
|
|
|
88247
88617
|
signal: stop.signal,
|
|
88248
88618
|
now: deps.now,
|
|
88249
88619
|
idempotencyKey: buildKey,
|
|
88250
|
-
onStall: () => say(` ${
|
|
88620
|
+
onStall: () => say(` ${import_picocolors73.default.yellow("The build looks stalled; still waiting in case another worker picks it up.")}`)
|
|
88251
88621
|
});
|
|
88252
88622
|
} catch (error2) {
|
|
88253
88623
|
if (error2 instanceof LostResponseError) {
|
|
@@ -88263,9 +88633,9 @@ async function build(ctx) {
|
|
|
88263
88633
|
status = noVersionStatus(mine?.status === "failed", task.status);
|
|
88264
88634
|
if (status === "no_version") {
|
|
88265
88635
|
codes.push(1);
|
|
88266
|
-
say(` ${
|
|
88636
|
+
say(` ${import_picocolors73.default.red("The conversation finished without committing a version, so there is nothing to build.")}`);
|
|
88267
88637
|
} else if (task.status !== "need_more_info") {
|
|
88268
|
-
say(` ${
|
|
88638
|
+
say(` ${import_picocolors73.default.dim("This conversation produced no version, so there is nothing to build.")}`);
|
|
88269
88639
|
}
|
|
88270
88640
|
}
|
|
88271
88641
|
if (!json3)
|
|
@@ -88280,7 +88650,7 @@ async function build(ctx) {
|
|
|
88280
88650
|
var buildCommands = { build };
|
|
88281
88651
|
|
|
88282
88652
|
// src/cli/interface-lifecycle.ts
|
|
88283
|
-
var
|
|
88653
|
+
var import_picocolors75 = __toESM(require_picocolors(), 1);
|
|
88284
88654
|
|
|
88285
88655
|
// src/core/org-members.ts
|
|
88286
88656
|
async function listAllOrgMembers(orgId) {
|
|
@@ -88334,7 +88704,7 @@ function membersById(members) {
|
|
|
88334
88704
|
}
|
|
88335
88705
|
|
|
88336
88706
|
// src/cli/interface-read.ts
|
|
88337
|
-
var
|
|
88707
|
+
var import_picocolors74 = __toESM(require_picocolors(), 1);
|
|
88338
88708
|
function interfaceState(row) {
|
|
88339
88709
|
if (row.archived_at)
|
|
88340
88710
|
return "archived";
|
|
@@ -88356,11 +88726,11 @@ function threadsLabel(shared) {
|
|
|
88356
88726
|
function stateTint(state) {
|
|
88357
88727
|
switch (state) {
|
|
88358
88728
|
case "live":
|
|
88359
|
-
return
|
|
88729
|
+
return import_picocolors74.default.green;
|
|
88360
88730
|
case "building":
|
|
88361
|
-
return
|
|
88731
|
+
return import_picocolors74.default.yellow;
|
|
88362
88732
|
case "archived":
|
|
88363
|
-
return
|
|
88733
|
+
return import_picocolors74.default.dim;
|
|
88364
88734
|
case "draft":
|
|
88365
88735
|
return (cell) => cell;
|
|
88366
88736
|
default: {
|
|
@@ -88393,7 +88763,7 @@ async function list3(ctx) {
|
|
|
88393
88763
|
if (shown.length === 0) {
|
|
88394
88764
|
const empty = onlyArchived ? "No archived interfaces." : includeArchived ? "No interfaces. Create one with `brainbase interface create`." : await emptyWithoutArchived(agentId);
|
|
88395
88765
|
console.log(`
|
|
88396
|
-
${
|
|
88766
|
+
${import_picocolors74.default.dim(empty)}
|
|
88397
88767
|
`);
|
|
88398
88768
|
return;
|
|
88399
88769
|
}
|
|
@@ -88406,7 +88776,7 @@ async function list3(ctx) {
|
|
|
88406
88776
|
audienceWord(row),
|
|
88407
88777
|
ago(row.last_edited_at ?? row.created_at, now2)
|
|
88408
88778
|
]);
|
|
88409
|
-
console.log(["", ...table(cells, [null,
|
|
88779
|
+
console.log(["", ...table(cells, [null, import_picocolors74.default.bold, null, null, null, import_picocolors74.default.dim]), ""].join(`
|
|
88410
88780
|
`));
|
|
88411
88781
|
});
|
|
88412
88782
|
}
|
|
@@ -88440,13 +88810,13 @@ async function get2(ctx) {
|
|
|
88440
88810
|
out.push(field("id", safe(row.id)));
|
|
88441
88811
|
out.push(field("agent", agentLabel(safe(row.agent_id), await agentNames([row.agent_id]))));
|
|
88442
88812
|
out.push(field("state", stateTint(state)(state)));
|
|
88443
|
-
out.push(field("address", row.live_release ? safe(row.live_release.url) : `${safe(row.slug)} ${
|
|
88813
|
+
out.push(field("address", row.live_release ? safe(row.live_release.url) : `${safe(row.slug)} ${import_picocolors74.default.dim("(nothing live yet)")}`));
|
|
88444
88814
|
out.push(field("audience", audienceLabel(row)));
|
|
88445
88815
|
out.push(field("threads", threadsLabel(row.share_agent_threads)));
|
|
88446
|
-
out.push(field("live", row.live_release ? `${safe(row.live_release.id)} ${
|
|
88447
|
-
out.push(field("draft", row.draft_version_id ? safe(row.draft_version_id) :
|
|
88816
|
+
out.push(field("live", row.live_release ? `${safe(row.live_release.id)} ${import_picocolors74.default.dim(`published ${ago(row.live_release.published_at)}`)}` : import_picocolors74.default.dim("none")));
|
|
88817
|
+
out.push(field("draft", row.draft_version_id ? safe(row.draft_version_id) : import_picocolors74.default.dim("none yet")));
|
|
88448
88818
|
if (row.running_generation) {
|
|
88449
|
-
out.push(field("building", `conversation ${safe(row.running_generation.thread_id ?? "")} ${
|
|
88819
|
+
out.push(field("building", `conversation ${safe(row.running_generation.thread_id ?? "")} ${import_picocolors74.default.dim(`(follow it with \`brainbase task logs ${safe(row.running_generation.thread_id ?? "")} --follow\`)`)}`));
|
|
88450
88820
|
}
|
|
88451
88821
|
if (row.archived_at)
|
|
88452
88822
|
out.push(field("archived", ago(row.archived_at)));
|
|
@@ -88475,7 +88845,7 @@ async function open(ctx) {
|
|
|
88475
88845
|
}
|
|
88476
88846
|
console.log(safe(url2));
|
|
88477
88847
|
if (new URL(url2).hostname.endsWith("vercel.app")) {
|
|
88478
|
-
console.error(
|
|
88848
|
+
console.error(import_picocolors74.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."));
|
|
88479
88849
|
}
|
|
88480
88850
|
});
|
|
88481
88851
|
}
|
|
@@ -88513,7 +88883,7 @@ async function history(ctx, name) {
|
|
|
88513
88883
|
banner(`interface ${name} — ${safe(id)}`);
|
|
88514
88884
|
if (rows.length === 0) {
|
|
88515
88885
|
console.log(`
|
|
88516
|
-
${
|
|
88886
|
+
${import_picocolors74.default.dim(`No ${name} yet.`)}
|
|
88517
88887
|
`);
|
|
88518
88888
|
return;
|
|
88519
88889
|
}
|
|
@@ -88590,7 +88960,7 @@ function exactlyOne(parsed, flags) {
|
|
|
88590
88960
|
}
|
|
88591
88961
|
function peopleLine(access, members) {
|
|
88592
88962
|
const ids = grantIds(access);
|
|
88593
|
-
return ids.length ? namesOf(ids, members) :
|
|
88963
|
+
return ids.length ? namesOf(ids, members) : import_picocolors75.default.dim("nobody named");
|
|
88594
88964
|
}
|
|
88595
88965
|
function printAccess(row, access, members) {
|
|
88596
88966
|
console.log([
|
|
@@ -88651,8 +89021,8 @@ async function create3(ctx) {
|
|
|
88651
89021
|
}
|
|
88652
89022
|
} catch (error2) {
|
|
88653
89023
|
readFailed = true;
|
|
88654
|
-
const
|
|
88655
|
-
accessError = error2 instanceof InterfaceApiError ? new InterfaceApiError(
|
|
89024
|
+
const message3 = `Created ${created.id}, but its audience could not be read, so it was not changed. ` + `Check it with \`brainbase interface access ${created.id}\`. (${error2.message})`;
|
|
89025
|
+
accessError = error2 instanceof InterfaceApiError ? new InterfaceApiError(message3, error2.code, error2.reason, error2.details, error2.status, error2.body) : new Error(message3);
|
|
88656
89026
|
}
|
|
88657
89027
|
}
|
|
88658
89028
|
if (audience && !note && !readFailed) {
|
|
@@ -88686,11 +89056,11 @@ async function create3(ctx) {
|
|
|
88686
89056
|
const id = safe(created.id);
|
|
88687
89057
|
const out = [
|
|
88688
89058
|
"",
|
|
88689
|
-
` ${
|
|
89059
|
+
` ${import_picocolors75.default.green("Created")} ${import_picocolors75.default.bold(safe(created.name))}`,
|
|
88690
89060
|
"",
|
|
88691
89061
|
field("id", id),
|
|
88692
89062
|
field("agent", safe(created.agent_id)),
|
|
88693
|
-
field("address", `${safe(created.slug)} ${
|
|
89063
|
+
field("address", `${safe(created.slug)} ${import_picocolors75.default.dim("(nothing live yet)")}`),
|
|
88694
89064
|
field("threads", threadsLabel(created.share_agent_threads))
|
|
88695
89065
|
];
|
|
88696
89066
|
if (access) {
|
|
@@ -88702,11 +89072,11 @@ async function create3(ctx) {
|
|
|
88702
89072
|
out.push("", ` Nobody can open it until you choose who can: \`brainbase interface access ${id} --everyone\` or \`--people <emails>\`.`);
|
|
88703
89073
|
}
|
|
88704
89074
|
if (created.share_agent_threads) {
|
|
88705
|
-
out.push(` ${
|
|
89075
|
+
out.push(` ${import_picocolors75.default.dim(`To show viewers only their own conversations: \`brainbase interface threads ${id} --private\`.`)}`);
|
|
88706
89076
|
}
|
|
88707
89077
|
if (note)
|
|
88708
89078
|
out.push("", ` ${safe(note)}`);
|
|
88709
|
-
out.push("", ` ${
|
|
89079
|
+
out.push("", ` ${import_picocolors75.default.dim(`Next: \`brainbase interface build ${id} "<what to build>"\``)}`, "");
|
|
88710
89080
|
console.log(out.join(`
|
|
88711
89081
|
`));
|
|
88712
89082
|
if (readFailed) {
|
|
@@ -88842,7 +89212,7 @@ async function threads(ctx) {
|
|
|
88842
89212
|
printJson({ id: row.id, share_agent_threads: row.share_agent_threads });
|
|
88843
89213
|
return;
|
|
88844
89214
|
}
|
|
88845
|
-
const already = wanted === null ? "" : ` ${
|
|
89215
|
+
const already = wanted === null ? "" : ` ${import_picocolors75.default.dim("(already set; nothing changed)")}`;
|
|
88846
89216
|
console.log(`
|
|
88847
89217
|
${field("threads", `${threadsLabel(row.share_agent_threads)}${already}`)}
|
|
88848
89218
|
`);
|
|
@@ -88881,7 +89251,7 @@ async function rename(ctx) {
|
|
|
88881
89251
|
return;
|
|
88882
89252
|
}
|
|
88883
89253
|
console.log(`
|
|
88884
|
-
Renamed ${safe(updated.id)} to ${
|
|
89254
|
+
Renamed ${safe(updated.id)} to ${import_picocolors75.default.bold(safe(updated.name))}.
|
|
88885
89255
|
`);
|
|
88886
89256
|
});
|
|
88887
89257
|
}
|
|
@@ -88917,7 +89287,7 @@ async function address(ctx) {
|
|
|
88917
89287
|
}
|
|
88918
89288
|
const where = updated.live_release ? safe(updated.live_release.url) : safe(updated.slug);
|
|
88919
89289
|
console.log(`
|
|
88920
|
-
${safe(updated.name)} is now at ${
|
|
89290
|
+
${safe(updated.name)} is now at ${import_picocolors75.default.bold(where)}.
|
|
88921
89291
|
`);
|
|
88922
89292
|
});
|
|
88923
89293
|
}
|
|
@@ -89009,9 +89379,9 @@ var lifecycleCommands = {
|
|
|
89009
89379
|
};
|
|
89010
89380
|
|
|
89011
89381
|
// src/cli/interface-preview.ts
|
|
89012
|
-
var
|
|
89382
|
+
var import_picocolors76 = __toESM(require_picocolors(), 1);
|
|
89013
89383
|
function warn(line2) {
|
|
89014
|
-
console.error(
|
|
89384
|
+
console.error(import_picocolors76.default.yellow(line2));
|
|
89015
89385
|
}
|
|
89016
89386
|
var PREVIEW_TIMEOUT_SECONDS = 300;
|
|
89017
89387
|
var PROBE_INTERVAL_MS = 2000;
|
|
@@ -89101,12 +89471,12 @@ async function preview(ctx) {
|
|
|
89101
89471
|
const say = progress(json3);
|
|
89102
89472
|
const row = await interfacesApi.get(id);
|
|
89103
89473
|
const { taskId, why } = await pickConversation(row, stringOption(parsed, "task")?.trim() || undefined);
|
|
89104
|
-
say(
|
|
89474
|
+
say(import_picocolors76.default.dim(` Previewing ${why}, ${safe(taskId)}.`));
|
|
89105
89475
|
const started = await interfacesApi.startPreview(taskId, row.id);
|
|
89106
89476
|
const address2 = previewAddress(started, row);
|
|
89107
89477
|
let outcome = started.state === "serving" ? "serving" : "not_waited";
|
|
89108
89478
|
if (outcome !== "serving" && !noWait) {
|
|
89109
|
-
say(
|
|
89479
|
+
say(import_picocolors76.default.dim(" Starting the dev server in the sandbox…"));
|
|
89110
89480
|
outcome = await waitUntilServing(started, { timeoutMs: waitMs, deps: ctx.deps });
|
|
89111
89481
|
}
|
|
89112
89482
|
if (json3) {
|
|
@@ -89114,12 +89484,12 @@ async function preview(ctx) {
|
|
|
89114
89484
|
} else {
|
|
89115
89485
|
const out = [
|
|
89116
89486
|
"",
|
|
89117
|
-
` ${outcome === "serving" ?
|
|
89487
|
+
` ${outcome === "serving" ? import_picocolors76.default.green("Preview ready") : import_picocolors76.default.yellow("Preview starting")} ${import_picocolors76.default.bold(safe(started.name))}`,
|
|
89118
89488
|
"",
|
|
89119
|
-
field("address", address2 ? safe(address2) :
|
|
89489
|
+
field("address", address2 ? safe(address2) : import_picocolors76.default.dim(missingAddress(started))),
|
|
89120
89490
|
field("showing", showing(started, taskId)),
|
|
89121
89491
|
"",
|
|
89122
|
-
` ${
|
|
89492
|
+
` ${import_picocolors76.default.dim("Opens for people who can edit the agent, after signing in. Nothing is published.")}`,
|
|
89123
89493
|
""
|
|
89124
89494
|
];
|
|
89125
89495
|
console.log(out.join(`
|
|
@@ -89140,19 +89510,19 @@ async function preview(ctx) {
|
|
|
89140
89510
|
var previewCommands = { preview };
|
|
89141
89511
|
|
|
89142
89512
|
// src/cli/interface-release.ts
|
|
89143
|
-
var
|
|
89513
|
+
var import_picocolors77 = __toESM(require_picocolors(), 1);
|
|
89144
89514
|
var PUBLISH_TIMEOUT_SECONDS = 300;
|
|
89145
89515
|
var REBUILD_USAGE = "brainbase interface rebuild <id> [--version <version id>] [--yes]";
|
|
89146
89516
|
var PUBLISH_USAGE = "brainbase interface publish <id> [--build <build id>]";
|
|
89147
89517
|
var ROLLBACK_USAGE = "brainbase interface rollback <id> --release <release id>";
|
|
89148
89518
|
function warn2(line2) {
|
|
89149
|
-
console.error(
|
|
89519
|
+
console.error(import_picocolors77.default.yellow(line2));
|
|
89150
89520
|
}
|
|
89151
89521
|
function text3(value2) {
|
|
89152
89522
|
return typeof value2 === "string" && value2.trim() ? value2 : null;
|
|
89153
89523
|
}
|
|
89154
|
-
function reword(error2,
|
|
89155
|
-
return new InterfaceApiError(
|
|
89524
|
+
function reword(error2, message3) {
|
|
89525
|
+
return new InterfaceApiError(message3, error2.code, error2.reason, error2.details, error2.status, error2.body);
|
|
89156
89526
|
}
|
|
89157
89527
|
async function follow(operationId, what, options) {
|
|
89158
89528
|
const stop = interruption(options.deps);
|
|
@@ -89163,7 +89533,7 @@ async function follow(operationId, what, options) {
|
|
|
89163
89533
|
intervalMs: options.deps.pollIntervalMs,
|
|
89164
89534
|
signal: stop.signal,
|
|
89165
89535
|
now: options.deps.now,
|
|
89166
|
-
onStatus: (operation) => say(
|
|
89536
|
+
onStatus: (operation) => say(import_picocolors77.default.dim(` ${what} ${operation.status}`)),
|
|
89167
89537
|
onStall: () => warn2(`The ${what} looks stalled: its worker stopped checking in. Still waiting, in case another worker picks it up.`)
|
|
89168
89538
|
});
|
|
89169
89539
|
if (outcome.kind === "settled") {
|
|
@@ -89182,7 +89552,7 @@ function reportUnsuccessful(result2, what, options) {
|
|
|
89182
89552
|
if (options.json) {
|
|
89183
89553
|
printJson({ outcome: result2.outcome, operation_id: result2.operationId, operation: result2.operation });
|
|
89184
89554
|
} else if (result2.outcome === "failed") {
|
|
89185
|
-
console.error(
|
|
89555
|
+
console.error(import_picocolors77.default.red(`The ${what} failed (operation ${id}):`));
|
|
89186
89556
|
console.error(safeBlock(result2.operation?.error ?? "Brainbase gave no reason."));
|
|
89187
89557
|
} else if (result2.outcome === "timeout") {
|
|
89188
89558
|
warn2(`Stopped waiting after ${Math.round(options.timeoutMs / 1000)}s. The ${what} keeps running on the server (operation ${id}).`);
|
|
@@ -89242,7 +89612,7 @@ async function rebuild(ctx) {
|
|
|
89242
89612
|
if (json3)
|
|
89243
89613
|
printJson({ outcome: "started", operation_id: operationId, operation });
|
|
89244
89614
|
else
|
|
89245
|
-
console.log(
|
|
89615
|
+
console.log(import_picocolors77.default.dim(` Follow it with \`brainbase interface builds ${safe(id)}\`.`));
|
|
89246
89616
|
return;
|
|
89247
89617
|
}
|
|
89248
89618
|
const result2 = await follow(operationId, "build", { json: json3, timeoutMs: waitMs, deps: ctx.deps });
|
|
@@ -89254,8 +89624,8 @@ async function rebuild(ctx) {
|
|
|
89254
89624
|
}
|
|
89255
89625
|
const buildId = safe(result2.operation?.build_id ?? "");
|
|
89256
89626
|
const version2 = safe(result2.operation?.source_version_id ?? "");
|
|
89257
|
-
console.log(
|
|
89258
|
-
console.log(
|
|
89627
|
+
console.log(import_picocolors77.default.green(`✓ Build ${buildId} succeeded${version2 ? ` (version ${version2})` : ""}.`));
|
|
89628
|
+
console.log(import_picocolors77.default.dim(` Publish it with \`brainbase interface publish ${safe(id)} --build ${buildId}\`.`));
|
|
89259
89629
|
});
|
|
89260
89630
|
}
|
|
89261
89631
|
function liveBuildOf(row, releases) {
|
|
@@ -89313,7 +89683,7 @@ function describeBuild(buildId, builds) {
|
|
|
89313
89683
|
const build2 = builds.find((candidate) => candidate.id === buildId);
|
|
89314
89684
|
if (!build2)
|
|
89315
89685
|
return `build ${safe(buildId)}`;
|
|
89316
|
-
return `build ${safe(build2.id)} ${
|
|
89686
|
+
return `build ${safe(build2.id)} ${import_picocolors77.default.dim(`(version ${safe(build2.source_version_id)}, built ${ago(build2.created_at)})`)}`;
|
|
89317
89687
|
}
|
|
89318
89688
|
function reportAlreadyLive(json3, buildId, releaseId, url2) {
|
|
89319
89689
|
if (json3) {
|
|
@@ -89367,8 +89737,8 @@ async function publish(ctx) {
|
|
|
89367
89737
|
}
|
|
89368
89738
|
if (!json3) {
|
|
89369
89739
|
console.log("");
|
|
89370
|
-
console.log(` ${
|
|
89371
|
-
console.log(` ${
|
|
89740
|
+
console.log(` ${import_picocolors77.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_picocolors77.default.dim("nothing")}`);
|
|
89741
|
+
console.log(` ${import_picocolors77.default.dim("Will publish".padEnd(14))}${describeBuild(buildId, builds)}`);
|
|
89372
89742
|
console.log("");
|
|
89373
89743
|
}
|
|
89374
89744
|
const proceed = await confirmChange({
|
|
@@ -89411,7 +89781,7 @@ async function publish(ctx) {
|
|
|
89411
89781
|
if (json3)
|
|
89412
89782
|
printJson({ outcome: "started", operation_id: operationId, operation });
|
|
89413
89783
|
else
|
|
89414
|
-
console.log(
|
|
89784
|
+
console.log(import_picocolors77.default.dim(` Check it with \`brainbase interface get ${safe(id)}\`.`));
|
|
89415
89785
|
return;
|
|
89416
89786
|
}
|
|
89417
89787
|
const result2 = await follow(operationId, "publish", { json: json3, timeoutMs: waitMs, deps: ctx.deps });
|
|
@@ -89428,11 +89798,11 @@ async function publish(ctx) {
|
|
|
89428
89798
|
printJson({ outcome: "succeeded", operation_id: operationId, operation: result2.operation, url: url2 });
|
|
89429
89799
|
return;
|
|
89430
89800
|
}
|
|
89431
|
-
console.log(
|
|
89801
|
+
console.log(import_picocolors77.default.green(`✓ Build ${safe(buildId)} is live.`));
|
|
89432
89802
|
if (url2)
|
|
89433
89803
|
console.log(` ${safe(url2)}`);
|
|
89434
89804
|
if (urlUnread) {
|
|
89435
|
-
console.log(
|
|
89805
|
+
console.log(import_picocolors77.default.dim(` Its address could not be read just now; see it with \`brainbase interface open ${safe(id)}\`.`));
|
|
89436
89806
|
}
|
|
89437
89807
|
});
|
|
89438
89808
|
}
|
|
@@ -89468,8 +89838,8 @@ async function rollback(ctx) {
|
|
|
89468
89838
|
}
|
|
89469
89839
|
if (!json3) {
|
|
89470
89840
|
console.log("");
|
|
89471
|
-
console.log(` ${
|
|
89472
|
-
console.log(` ${
|
|
89841
|
+
console.log(` ${import_picocolors77.default.dim("Live now".padEnd(16))}release ${safe(row.live_release.id)} at ${safe(row.live_release.url)}`);
|
|
89842
|
+
console.log(` ${import_picocolors77.default.dim("Will republish".padEnd(16))}release ${safe(releaseId)} ${import_picocolors77.default.dim("as a new release, with a new id")}`);
|
|
89473
89843
|
console.log("");
|
|
89474
89844
|
}
|
|
89475
89845
|
const proceed = await confirmChange({
|
|
@@ -89502,7 +89872,7 @@ async function rollback(ctx) {
|
|
|
89502
89872
|
printJson(release);
|
|
89503
89873
|
return;
|
|
89504
89874
|
}
|
|
89505
|
-
console.log(
|
|
89875
|
+
console.log(import_picocolors77.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.`));
|
|
89506
89876
|
console.log(` ${safe(release.url)}`);
|
|
89507
89877
|
});
|
|
89508
89878
|
}
|
|
@@ -89537,14 +89907,14 @@ ${didYouMean(sub, Object.keys(COMMANDS2), "brainbase interface")}`);
|
|
|
89537
89907
|
await command({ cwd: cwd2, args, deps });
|
|
89538
89908
|
}
|
|
89539
89909
|
function line2(command, args, description) {
|
|
89540
|
-
return ` ${
|
|
89541
|
-
${
|
|
89910
|
+
return ` ${import_picocolors78.default.cyan(command)}${args ? ` ${import_picocolors78.default.dim(args)}` : ""}
|
|
89911
|
+
${import_picocolors78.default.dim(description)}`;
|
|
89542
89912
|
}
|
|
89543
89913
|
function printHelp7() {
|
|
89544
89914
|
const out = [];
|
|
89545
89915
|
out.push("");
|
|
89546
|
-
out.push(` ${
|
|
89547
|
-
out.push(` ${
|
|
89916
|
+
out.push(` ${import_picocolors78.default.bold("brainbase interface")} ${import_picocolors78.default.dim("<sub> [options]")}`);
|
|
89917
|
+
out.push(` ${import_picocolors78.default.dim("Dashboards for an agent: build them in a conversation, publish them, choose who can open them.")}`);
|
|
89548
89918
|
out.push("");
|
|
89549
89919
|
out.push(line2("ls", "[--agent <id>] [--archived | --only-archived]", "list interfaces you can see"));
|
|
89550
89920
|
out.push(line2("get", "<id>", "one interface: address, audience, live release, draft, running build conversation"));
|
|
@@ -89564,22 +89934,22 @@ function printHelp7() {
|
|
|
89564
89934
|
out.push(line2("rollback", "<id> --release <id>", "republish an earlier release; it goes live under a new release id"));
|
|
89565
89935
|
out.push(line2("preview", "<id> [--task <id>] [--no-wait]", "serve the unpublished draft from its build conversation and print the preview address"));
|
|
89566
89936
|
out.push("");
|
|
89567
|
-
out.push(` ${
|
|
89568
|
-
out.push(` ${
|
|
89569
|
-
out.push(` ${
|
|
89570
|
-
out.push(` ${
|
|
89571
|
-
out.push(` ${
|
|
89937
|
+
out.push(` ${import_picocolors78.default.dim("--json")} machine-readable output; never prompts`);
|
|
89938
|
+
out.push(` ${import_picocolors78.default.dim("--yes, -y")} skip confirmation (required without a terminal)`);
|
|
89939
|
+
out.push(` ${import_picocolors78.default.dim("--no-wait")} for rebuild and publish: return the operation at once; for preview: do not wait for the dev server`);
|
|
89940
|
+
out.push(` ${import_picocolors78.default.dim("--timeout <seconds>")} for build, rebuild, publish and preview: how long to wait (builds 900, publish and preview 300)`);
|
|
89941
|
+
out.push(` ${import_picocolors78.default.dim("--idempotency-key <key>")} replay a create, build, rebuild, publish or rollback whose answer was lost`);
|
|
89572
89942
|
out.push("");
|
|
89573
|
-
out.push(` ${
|
|
89574
|
-
out.push(` ${
|
|
89575
|
-
out.push(` ${
|
|
89943
|
+
out.push(` ${import_picocolors78.default.dim("People are emails (see `brainbase member ls`), user ids, or `me`. Audience members also need access to the agent.")}`);
|
|
89944
|
+
out.push(` ${import_picocolors78.default.dim("Audience: everyone (--everyone, `org` under --json) or chosen people (--people, `users` under --json).")}`);
|
|
89945
|
+
out.push(` ${import_picocolors78.default.dim("Exit codes: 0 done, 1 refused or failed, 130 interrupted (the server keeps working).")}`);
|
|
89576
89946
|
out.push("");
|
|
89577
89947
|
console.log(out.join(`
|
|
89578
89948
|
`));
|
|
89579
89949
|
}
|
|
89580
89950
|
|
|
89581
89951
|
// src/cli/member.ts
|
|
89582
|
-
var
|
|
89952
|
+
var import_picocolors79 = __toESM(require_picocolors(), 1);
|
|
89583
89953
|
async function runMember(sub, args, opts) {
|
|
89584
89954
|
if (args.some((arg) => arg === "--help" || arg === "-h")) {
|
|
89585
89955
|
printHelp8();
|
|
@@ -89622,7 +89992,7 @@ async function runMemberList(opts) {
|
|
|
89622
89992
|
function formatMemberList(members) {
|
|
89623
89993
|
if (members.length === 0)
|
|
89624
89994
|
return `
|
|
89625
|
-
${
|
|
89995
|
+
${import_picocolors79.default.dim("Nobody here you can see.")}
|
|
89626
89996
|
`;
|
|
89627
89997
|
const sorted = [...members].sort((a3, b4) => (a3.email ?? a3.id).localeCompare(b4.email ?? b4.id));
|
|
89628
89998
|
const rows = sorted.map((member) => ({
|
|
@@ -89636,24 +90006,24 @@ function formatMemberList(members) {
|
|
|
89636
90006
|
const roleWidth = Math.max(...rows.map((row) => row.role.length));
|
|
89637
90007
|
const lines = [""];
|
|
89638
90008
|
for (const row of rows) {
|
|
89639
|
-
lines.push(` ${row.email.padEnd(emailWidth)} ${row.name.padEnd(nameWidth)} ${
|
|
90009
|
+
lines.push(` ${row.email.padEnd(emailWidth)} ${row.name.padEnd(nameWidth)} ${import_picocolors79.default.dim(row.role.padEnd(roleWidth))} ${import_picocolors79.default.dim(row.teams)}`.trimEnd());
|
|
89640
90010
|
}
|
|
89641
|
-
lines.push("", ` ${
|
|
90011
|
+
lines.push("", ` ${import_picocolors79.default.dim("share a dashboard with one of them:")} ${import_picocolors79.default.cyan("brainbase interface access <id> --add <email>")}`, "");
|
|
89642
90012
|
return lines.join(`
|
|
89643
90013
|
`);
|
|
89644
90014
|
}
|
|
89645
90015
|
function printHelp8() {
|
|
89646
90016
|
const out = [];
|
|
89647
90017
|
out.push("");
|
|
89648
|
-
out.push(` ${
|
|
90018
|
+
out.push(` ${import_picocolors79.default.bold("brainbase member")} ${import_picocolors79.default.dim("<sub> [options]")}`);
|
|
89649
90019
|
out.push("");
|
|
89650
|
-
out.push(` ${
|
|
90020
|
+
out.push(` ${import_picocolors79.default.cyan("ls")} ${import_picocolors79.default.dim("the people in an organization you can see, with their emails, roles and teams")}`);
|
|
89651
90021
|
out.push("");
|
|
89652
|
-
out.push(` ${
|
|
89653
|
-
out.push(` ${
|
|
90022
|
+
out.push(` ${import_picocolors79.default.dim("--org <id-or-slug>")} ${import_picocolors79.default.dim("which organization (picked automatically when you are in one)")}`);
|
|
90023
|
+
out.push(` ${import_picocolors79.default.dim("--json")} ${import_picocolors79.default.dim("machine-readable output")}`);
|
|
89654
90024
|
out.push("");
|
|
89655
|
-
out.push(` ${
|
|
89656
|
-
out.push(` ${
|
|
90025
|
+
out.push(` ${import_picocolors79.default.dim("Owners and admins see everyone. Anyone else sees the owners, the admins, themselves")}`);
|
|
90026
|
+
out.push(` ${import_picocolors79.default.dim("and the people who share a team with them, as in the web app.")}`);
|
|
89657
90027
|
out.push("");
|
|
89658
90028
|
console.log(out.join(`
|
|
89659
90029
|
`));
|
|
@@ -90105,8 +90475,8 @@ var BENCHMARK_CAPABILITIES = {
|
|
|
90105
90475
|
class BenchmarkPhaseError extends Error {
|
|
90106
90476
|
code;
|
|
90107
90477
|
details;
|
|
90108
|
-
constructor(code,
|
|
90109
|
-
super(
|
|
90478
|
+
constructor(code, message3, details) {
|
|
90479
|
+
super(message3);
|
|
90110
90480
|
this.code = code;
|
|
90111
90481
|
this.details = details;
|
|
90112
90482
|
this.name = "BenchmarkPhaseError";
|
|
@@ -90117,8 +90487,8 @@ class BenchmarkCommandExecutionError extends BenchmarkPhaseError {
|
|
|
90117
90487
|
stdout;
|
|
90118
90488
|
stderr;
|
|
90119
90489
|
durationMs;
|
|
90120
|
-
constructor(code,
|
|
90121
|
-
super(code,
|
|
90490
|
+
constructor(code, message3, stdout, stderr, durationMs) {
|
|
90491
|
+
super(code, message3);
|
|
90122
90492
|
this.stdout = stdout;
|
|
90123
90493
|
this.stderr = stderr;
|
|
90124
90494
|
this.durationMs = durationMs;
|
|
@@ -92746,7 +93116,7 @@ async function runBenchmarkPhase(specPathInput, resultPathInput, expectedPhase,
|
|
|
92746
93116
|
}
|
|
92747
93117
|
|
|
92748
93118
|
// src/cli/benchmark-control.ts
|
|
92749
|
-
var
|
|
93119
|
+
var import_picocolors80 = __toESM(require_picocolors(), 1);
|
|
92750
93120
|
import fs92 from "node:fs";
|
|
92751
93121
|
import path103 from "node:path";
|
|
92752
93122
|
|
|
@@ -92758,8 +93128,8 @@ var BENCHMARK_UPLOAD_MIN_BYTES_PER_SECOND = 256 * 1024;
|
|
|
92758
93128
|
class BenchmarkClientUsageError extends Error {
|
|
92759
93129
|
code = "invalid_arguments";
|
|
92760
93130
|
retryable = false;
|
|
92761
|
-
constructor(
|
|
92762
|
-
super(
|
|
93131
|
+
constructor(message3) {
|
|
93132
|
+
super(message3);
|
|
92763
93133
|
this.name = "BenchmarkClientUsageError";
|
|
92764
93134
|
}
|
|
92765
93135
|
}
|
|
@@ -92768,8 +93138,8 @@ class BenchmarkApiError extends ApiError {
|
|
|
92768
93138
|
code;
|
|
92769
93139
|
requestId;
|
|
92770
93140
|
retryable;
|
|
92771
|
-
constructor(
|
|
92772
|
-
super(
|
|
93141
|
+
constructor(message3, status, body, code, requestId, retryable) {
|
|
93142
|
+
super(message3, status, body);
|
|
92773
93143
|
this.code = code;
|
|
92774
93144
|
this.requestId = requestId;
|
|
92775
93145
|
this.name = "BenchmarkApiError";
|
|
@@ -95050,8 +95420,8 @@ function expectPositionals2(positionals, minimum, maximum, usage) {
|
|
|
95050
95420
|
throw usageError(`Usage: ${usage}`);
|
|
95051
95421
|
}
|
|
95052
95422
|
}
|
|
95053
|
-
function usageError(
|
|
95054
|
-
return Object.assign(new Error(
|
|
95423
|
+
function usageError(message3) {
|
|
95424
|
+
return Object.assign(new Error(message3), {
|
|
95055
95425
|
code: "invalid_arguments",
|
|
95056
95426
|
retryable: false
|
|
95057
95427
|
});
|
|
@@ -95760,20 +96130,20 @@ async function emitCursorPages(output, fetchPage, options) {
|
|
|
95760
96130
|
function commandHelp() {
|
|
95761
96131
|
return [
|
|
95762
96132
|
"",
|
|
95763
|
-
` ${
|
|
96133
|
+
` ${import_picocolors80.default.bold("brainbase benchmark")} ${import_picocolors80.default.dim("<command> [options]")}`,
|
|
95764
96134
|
"",
|
|
95765
|
-
` ${
|
|
95766
|
-
` ${
|
|
95767
|
-
` ${
|
|
95768
|
-
` ${
|
|
95769
|
-
` ${
|
|
96135
|
+
` ${import_picocolors80.default.cyan("init | list | show | create | validate | pull | push")}`,
|
|
96136
|
+
` ${import_picocolors80.default.cyan("publish | revisions | import | export | archive | restore")}`,
|
|
96137
|
+
` ${import_picocolors80.default.cyan("run plan|start|watch|list|show|cancel|resume")}`,
|
|
96138
|
+
` ${import_picocolors80.default.cyan("results | diagnoses | attempt | artifacts | export-results")}`,
|
|
96139
|
+
` ${import_picocolors80.default.cyan("history | baseline show|set|clear")}`,
|
|
95770
96140
|
"",
|
|
95771
|
-
` ${
|
|
96141
|
+
` ${import_picocolors80.default.dim("Use --agent to override brainbase.agent.yaml, and --json or --jsonl for automation.")}`,
|
|
95772
96142
|
"",
|
|
95773
|
-
` ${
|
|
95774
|
-
` ${
|
|
95775
|
-
` ${
|
|
95776
|
-
` ${
|
|
96143
|
+
` ${import_picocolors80.default.bold("benchmark runtime (machine-only)")}`,
|
|
96144
|
+
` ${import_picocolors80.default.cyan("hydrate")} ${import_picocolors80.default.dim("--spec <path> --result <path> --json")}`,
|
|
96145
|
+
` ${import_picocolors80.default.cyan("evaluate")} ${import_picocolors80.default.dim("--spec <path> --result <path> --json")}`,
|
|
96146
|
+
` ${import_picocolors80.default.cyan("capabilities")} ${import_picocolors80.default.dim("--json")}`,
|
|
95777
96147
|
""
|
|
95778
96148
|
].join(`
|
|
95779
96149
|
`);
|
|
@@ -96219,8 +96589,8 @@ async function runStart(cwd2, argv, deps) {
|
|
|
96219
96589
|
}
|
|
96220
96590
|
function pausedRunHint(runId, run, agentId) {
|
|
96221
96591
|
const reason = run.paused_reason;
|
|
96222
|
-
const
|
|
96223
|
-
const first = typeof
|
|
96592
|
+
const message3 = reason && typeof reason === "object" && !Array.isArray(reason) ? reason.message : undefined;
|
|
96593
|
+
const first = typeof message3 === "string" && message3.trim() ? `Run paused: ${message3.trim()}` : "Run paused.";
|
|
96224
96594
|
const agent = agentId ? ` --agent ${agentId}` : "";
|
|
96225
96595
|
return `${first}
|
|
96226
96596
|
Resume with: brainbase benchmark run resume ${runId} --yes${agent}`;
|
|
@@ -96876,7 +97246,7 @@ function parsePhaseArgs(args) {
|
|
|
96876
97246
|
throw new Error("--json is required for benchmark phase commands");
|
|
96877
97247
|
return { spec, result: result2, json: true };
|
|
96878
97248
|
}
|
|
96879
|
-
function argumentFailure(phase,
|
|
97249
|
+
function argumentFailure(phase, message3) {
|
|
96880
97250
|
const timestamp = new Date().toISOString();
|
|
96881
97251
|
return {
|
|
96882
97252
|
schema_version: "1",
|
|
@@ -96894,11 +97264,11 @@ function argumentFailure(phase, message2) {
|
|
|
96894
97264
|
outputs: [],
|
|
96895
97265
|
error: {
|
|
96896
97266
|
code: "invalid_arguments",
|
|
96897
|
-
message:
|
|
97267
|
+
message: message3
|
|
96898
97268
|
}
|
|
96899
97269
|
};
|
|
96900
97270
|
}
|
|
96901
|
-
function phaseFailure(invocation, startedAt, started, code,
|
|
97271
|
+
function phaseFailure(invocation, startedAt, started, code, message3) {
|
|
96902
97272
|
return {
|
|
96903
97273
|
schema_version: "1",
|
|
96904
97274
|
cli_version: VERSION,
|
|
@@ -96913,7 +97283,7 @@ function phaseFailure(invocation, startedAt, started, code, message2) {
|
|
|
96913
97283
|
steps: [],
|
|
96914
97284
|
inputs: [],
|
|
96915
97285
|
outputs: [],
|
|
96916
|
-
error: { code, message:
|
|
97286
|
+
error: { code, message: message3 }
|
|
96917
97287
|
};
|
|
96918
97288
|
}
|
|
96919
97289
|
function descendantPids2(parentPid) {
|
|
@@ -97241,208 +97611,213 @@ var SUBCOMMAND_OWNED_FLAGS = {
|
|
|
97241
97611
|
function help() {
|
|
97242
97612
|
const out = [];
|
|
97243
97613
|
out.push("");
|
|
97244
|
-
out.push(` ${brandTint("◆")} ${
|
|
97245
|
-
out.push(` ${
|
|
97614
|
+
out.push(` ${brandTint("◆")} ${import_picocolors81.default.bold("brainbase")} ${import_picocolors81.default.dim(`v${VERSION}`)}`);
|
|
97615
|
+
out.push(` ${import_picocolors81.default.dim("connect your local agent to the brainbase platform")}`);
|
|
97246
97616
|
out.push("");
|
|
97247
97617
|
out.push(divider("USAGE"));
|
|
97248
97618
|
out.push("");
|
|
97249
|
-
out.push(` ${
|
|
97619
|
+
out.push(` ${import_picocolors81.default.bold("brainbase")} ${import_picocolors81.default.dim("<command> [options]")}`);
|
|
97250
97620
|
out.push("");
|
|
97251
97621
|
out.push(divider("AUTH"));
|
|
97252
97622
|
out.push("");
|
|
97253
|
-
out.push(` ${
|
|
97254
|
-
out.push(` ${
|
|
97255
|
-
out.push(` ${
|
|
97623
|
+
out.push(` ${import_picocolors81.default.cyan("login")} ${import_picocolors81.default.dim(" open the web app and connect this device")}`);
|
|
97624
|
+
out.push(` ${import_picocolors81.default.cyan("logout")} ${import_picocolors81.default.dim(" clear the local session")}`);
|
|
97625
|
+
out.push(` ${import_picocolors81.default.cyan("whoami")} ${import_picocolors81.default.dim("[--json]")} ${import_picocolors81.default.dim(" show which credential is in use and what it covers")}`);
|
|
97256
97626
|
out.push("");
|
|
97257
97627
|
out.push(divider("DISCOVERY"));
|
|
97258
97628
|
out.push("");
|
|
97259
|
-
out.push(` ${
|
|
97260
|
-
out.push(` ${
|
|
97261
|
-
out.push(` ${
|
|
97629
|
+
out.push(` ${import_picocolors81.default.cyan("team list")} ${import_picocolors81.default.dim("show the teams you can create agents in")}`);
|
|
97630
|
+
out.push(` ${import_picocolors81.default.cyan("member ls")} ${import_picocolors81.default.dim("show the people in an organization, with the emails interface access takes")}`);
|
|
97631
|
+
out.push(` ${import_picocolors81.default.cyan("agent list")} ${import_picocolors81.default.dim("show a team's agents and their ids")}`);
|
|
97262
97632
|
out.push("");
|
|
97263
97633
|
out.push(divider("LINKED AGENT"));
|
|
97264
97634
|
out.push("");
|
|
97265
|
-
out.push(` ${
|
|
97266
|
-
out.push(` ${
|
|
97267
|
-
out.push(` ${
|
|
97268
|
-
out.push(` ${
|
|
97269
|
-
out.push(` ${
|
|
97270
|
-
out.push(` ${
|
|
97271
|
-
out.push(` ${
|
|
97272
|
-
out.push(` ${
|
|
97273
|
-
out.push(` ${
|
|
97274
|
-
out.push(` ${
|
|
97275
|
-
out.push(` ${
|
|
97276
|
-
out.push(` ${
|
|
97277
|
-
out.push(` ${
|
|
97278
|
-
out.push(` ${
|
|
97279
|
-
out.push(` ${
|
|
97280
|
-
out.push(` ${
|
|
97281
|
-
out.push(` ${
|
|
97282
|
-
out.push(` ${
|
|
97635
|
+
out.push(` ${import_picocolors81.default.cyan("agent init")} ${import_picocolors81.default.dim("write a starter brainbase.agent.yaml here — offline, no login needed")}`);
|
|
97636
|
+
out.push(` ${import_picocolors81.default.cyan("agent create")} ${import_picocolors81.default.dim("claim an unclaimed brainbase.agent.yaml and create the cloud agent")}`);
|
|
97637
|
+
out.push(` ${import_picocolors81.default.cyan("agent pull")} ${import_picocolors81.default.dim("[<id>]")} ${import_picocolors81.default.dim("bring cloud changes into this folder (--force to override; --run-entrypoint to also execute the agent entrypoint; --link to link first)")}`);
|
|
97638
|
+
out.push(` ${import_picocolors81.default.cyan("agent push")} ${import_picocolors81.default.dim("send local changes to the cloud (--force to overwrite cloud-side conflicts with local)")}`);
|
|
97639
|
+
out.push(` ${import_picocolors81.default.cyan("agent delete")} ${import_picocolors81.default.dim("<id>")} ${import_picocolors81.default.dim("permanently delete a cloud agent and every task it has run")}`);
|
|
97640
|
+
out.push(` ${import_picocolors81.default.cyan("agent unpack")} ${import_picocolors81.default.dim("install the claimed agent into a harness layout")}`);
|
|
97641
|
+
out.push(` ${import_picocolors81.default.cyan("link")} ${import_picocolors81.default.dim("attach this folder to an existing agent")}`);
|
|
97642
|
+
out.push(` ${import_picocolors81.default.cyan("agent status")} ${import_picocolors81.default.dim("show what would pull and what would push")}`);
|
|
97643
|
+
out.push(` ${import_picocolors81.default.cyan("agent connections")} ${import_picocolors81.default.dim("show which integrations this agent is wired to (--json for CI)")}`);
|
|
97644
|
+
out.push(` ${import_picocolors81.default.cyan("agent connect")} ${import_picocolors81.default.dim("<name>")} ${import_picocolors81.default.dim("connect chat, slack, meeting, github, linear or phone")}`);
|
|
97645
|
+
out.push(` ${import_picocolors81.default.cyan("agent disconnect")} ${import_picocolors81.default.dim("<name>")} ${import_picocolors81.default.dim("disable or disconnect an agent surface")}`);
|
|
97646
|
+
out.push(` ${import_picocolors81.default.cyan("agent surface")} ${import_picocolors81.default.dim("<name>")} ${import_picocolors81.default.dim("status, settings and setup for all six surfaces (--help)")}`);
|
|
97647
|
+
out.push(` ${import_picocolors81.default.cyan("agent versions")} ${import_picocolors81.default.dim("saved versions: list, show, diff, label, restore, pin and unpin (`agent versions --help`)")}`);
|
|
97648
|
+
out.push(` ${import_picocolors81.default.cyan("agent eval")} ${import_picocolors81.default.dim("<list|runs>")} ${import_picocolors81.default.dim("read eval definitions and judge verdicts (`agent eval --help`)")}`);
|
|
97649
|
+
out.push(` ${import_picocolors81.default.cyan("agent env")} ${import_picocolors81.default.dim("print export lines for `eval $(brainbase agent env)`")}`);
|
|
97650
|
+
out.push(` ${import_picocolors81.default.cyan("run")} ${import_picocolors81.default.dim("<cmd> [args...]")} ${import_picocolors81.default.dim("run <cmd> with secrets.env loaded into env")}`);
|
|
97651
|
+
out.push(` ${import_picocolors81.default.cyan("status")} ${import_picocolors81.default.dim("show what this folder is linked to")}`);
|
|
97652
|
+
out.push(` ${import_picocolors81.default.cyan("unlink")} ${import_picocolors81.default.dim("disconnect this folder")}`);
|
|
97283
97653
|
out.push("");
|
|
97284
97654
|
out.push(divider("TASKS"));
|
|
97285
97655
|
out.push("");
|
|
97286
|
-
out.push(` ${
|
|
97287
|
-
out.push(` ${
|
|
97288
|
-
out.push(` ${
|
|
97289
|
-
out.push(` ${
|
|
97290
|
-
out.push(` ${
|
|
97291
|
-
out.push(` ${
|
|
97292
|
-
out.push(` ${
|
|
97293
|
-
out.push(` ${
|
|
97656
|
+
out.push(` ${import_picocolors81.default.cyan("task create")} ${import_picocolors81.default.dim("--message <text>")} ${import_picocolors81.default.dim("create a managed task and start its first run (--wait to block on it; --interface <id> for a build conversation)")}`);
|
|
97657
|
+
out.push(` ${import_picocolors81.default.cyan("task list")} ${import_picocolors81.default.dim("recent tasks you can reach (--metadata k=v to filter by label; --interface <id> for its build conversations)")}`);
|
|
97658
|
+
out.push(` ${import_picocolors81.default.cyan("task get")} ${import_picocolors81.default.dim("<task-id>")} ${import_picocolors81.default.dim("one task: status, agent, machine, eval verdicts")}`);
|
|
97659
|
+
out.push(` ${import_picocolors81.default.cyan("task logs")} ${import_picocolors81.default.dim("<task-id> [--follow]")} ${import_picocolors81.default.dim("one line per event in the task's transcript, or tail it live")}`);
|
|
97660
|
+
out.push(` ${import_picocolors81.default.cyan("task send")} ${import_picocolors81.default.dim("<task-id> <message>")} ${import_picocolors81.default.dim("send a follow-up during execution, or queue it for the next turn")}`);
|
|
97661
|
+
out.push(` ${import_picocolors81.default.cyan("task stop")} ${import_picocolors81.default.dim("<task-id>")} ${import_picocolors81.default.dim("stop execution and cancel pending follow-ups, retaining their text")}`);
|
|
97662
|
+
out.push(` ${import_picocolors81.default.cyan("task update")} ${import_picocolors81.default.dim("<task-id>")} ${import_picocolors81.default.dim("rename a task, change its metadata labels, switch its model or reset it to the agent default, including while it runs")}`);
|
|
97663
|
+
out.push(` ${import_picocolors81.default.cyan("task delete")} ${import_picocolors81.default.dim("<task-id>")} ${import_picocolors81.default.dim("permanently delete a stopped task and tear down its sandbox")}`);
|
|
97294
97664
|
out.push("");
|
|
97295
97665
|
out.push(divider("INTERFACES"));
|
|
97296
97666
|
out.push("");
|
|
97297
|
-
out.push(` ${
|
|
97298
|
-
out.push(` ${
|
|
97299
|
-
out.push(` ${
|
|
97300
|
-
out.push(` ${
|
|
97301
|
-
out.push(` ${
|
|
97302
|
-
out.push(` ${
|
|
97303
|
-
out.push(` ${
|
|
97667
|
+
out.push(` ${import_picocolors81.default.cyan("interface ls")} ${import_picocolors81.default.dim("dashboards you can see (--agent to narrow)")}`);
|
|
97668
|
+
out.push(` ${import_picocolors81.default.cyan("interface create")} ${import_picocolors81.default.dim("--name <n>")} ${import_picocolors81.default.dim("create one on an agent, with who can open it")}`);
|
|
97669
|
+
out.push(` ${import_picocolors81.default.cyan("interface build")} ${import_picocolors81.default.dim('<id> "<ask>"')} ${import_picocolors81.default.dim("describe a change; the agent builds it while you watch")}`);
|
|
97670
|
+
out.push(` ${import_picocolors81.default.cyan("interface publish")} ${import_picocolors81.default.dim("<id>")} ${import_picocolors81.default.dim("make the newest succeeded build live")}`);
|
|
97671
|
+
out.push(` ${import_picocolors81.default.cyan("interface rollback")} ${import_picocolors81.default.dim("<id>")} ${import_picocolors81.default.dim("republish an earlier release under a new id (--release <id>)")}`);
|
|
97672
|
+
out.push(` ${import_picocolors81.default.cyan("interface access")} ${import_picocolors81.default.dim("<id>")} ${import_picocolors81.default.dim("show or set who can open it")}`);
|
|
97673
|
+
out.push(` ${import_picocolors81.default.cyan("interface --help")} ${import_picocolors81.default.dim("every interface subcommand")}`);
|
|
97304
97674
|
out.push("");
|
|
97305
97675
|
out.push(divider("SANDBOXES"));
|
|
97306
97676
|
out.push("");
|
|
97307
|
-
out.push(` ${
|
|
97308
|
-
out.push(` ${
|
|
97677
|
+
out.push(` ${import_picocolors81.default.cyan("machine ls")} ${import_picocolors81.default.dim("[--all]")} ${import_picocolors81.default.dim("list your sandboxes — live ones only unless --all")}`);
|
|
97678
|
+
out.push(` ${import_picocolors81.default.cyan("machine rm")} ${import_picocolors81.default.dim("<id>")} ${import_picocolors81.default.dim("tear a sandbox down (it bills until you do)")}`);
|
|
97309
97679
|
out.push("");
|
|
97310
97680
|
out.push(divider("BENCHMARKS"));
|
|
97311
97681
|
out.push("");
|
|
97312
|
-
out.push(` ${
|
|
97313
|
-
out.push(` ${
|
|
97314
|
-
out.push(` ${
|
|
97315
|
-
out.push(` ${
|
|
97316
|
-
out.push(` ${
|
|
97682
|
+
out.push(` ${import_picocolors81.default.cyan("benchmark list")} ${import_picocolors81.default.dim("list benchmarks for the linked agent")}`);
|
|
97683
|
+
out.push(` ${import_picocolors81.default.cyan("benchmark init")} ${import_picocolors81.default.dim("[directory]")} ${import_picocolors81.default.dim("scaffold a local benchmark")}`);
|
|
97684
|
+
out.push(` ${import_picocolors81.default.cyan("benchmark create")} ${import_picocolors81.default.dim("[path|-]")} ${import_picocolors81.default.dim("create a benchmark draft")}`);
|
|
97685
|
+
out.push(` ${import_picocolors81.default.cyan("benchmark run")} ${import_picocolors81.default.dim("<benchmark> --yes")} ${import_picocolors81.default.dim("plan and start a benchmark run")}`);
|
|
97686
|
+
out.push(` ${import_picocolors81.default.cyan("benchmark results")} ${import_picocolors81.default.dim("<run>")} ${import_picocolors81.default.dim("inspect normalized benchmark results")}`);
|
|
97317
97687
|
out.push("");
|
|
97318
97688
|
out.push(divider("BENCHMARK RUNTIME"));
|
|
97319
97689
|
out.push("");
|
|
97320
|
-
out.push(` ${
|
|
97321
|
-
out.push(` ${
|
|
97322
|
-
out.push(` ${
|
|
97690
|
+
out.push(` ${import_picocolors81.default.cyan("benchmark hydrate")} ${import_picocolors81.default.dim("--spec <path> --result <path> --json")}`);
|
|
97691
|
+
out.push(` ${import_picocolors81.default.cyan("benchmark evaluate")} ${import_picocolors81.default.dim("--spec <path> --result <path> --json")}`);
|
|
97692
|
+
out.push(` ${import_picocolors81.default.cyan("benchmark capabilities")} ${import_picocolors81.default.dim("--json")}`);
|
|
97323
97693
|
out.push("");
|
|
97324
97694
|
out.push(divider("ORCHESTRATIONS"));
|
|
97325
97695
|
out.push("");
|
|
97326
|
-
out.push(` ${
|
|
97327
|
-
out.push(` ${
|
|
97328
|
-
out.push(` ${
|
|
97329
|
-
out.push(` ${
|
|
97330
|
-
out.push(` ${
|
|
97331
|
-
out.push(` ${
|
|
97332
|
-
out.push(` ${
|
|
97696
|
+
out.push(` ${import_picocolors81.default.cyan("orchestration init")} ${import_picocolors81.default.dim("write a starter brainbase-orchestration.yaml here (offline, no login)")}`);
|
|
97697
|
+
out.push(` ${import_picocolors81.default.cyan("orchestration create")} ${import_picocolors81.default.dim("claim a local orchestration manifest and create it in the cloud")}`);
|
|
97698
|
+
out.push(` ${import_picocolors81.default.cyan("orchestration list")} ${import_picocolors81.default.dim("list orchestrations under a team")}`);
|
|
97699
|
+
out.push(` ${import_picocolors81.default.cyan("orchestration pull")} ${import_picocolors81.default.dim("<id>")} ${import_picocolors81.default.dim("recursively fetch an orchestration + every member agent")}`);
|
|
97700
|
+
out.push(` ${import_picocolors81.default.cyan("orchestration push")} ${import_picocolors81.default.dim("recursively push each member, then update the graph")}`);
|
|
97701
|
+
out.push(` ${import_picocolors81.default.cyan("orchestration status")} ${import_picocolors81.default.dim("show what would push and what would pull")}`);
|
|
97702
|
+
out.push(` ${import_picocolors81.default.cyan("orchestration delete")} ${import_picocolors81.default.dim("<id>")} ${import_picocolors81.default.dim("permanently delete an orchestration graph (member agents are kept)")}`);
|
|
97333
97703
|
out.push("");
|
|
97334
97704
|
out.push(divider("TEMPLATES"));
|
|
97335
97705
|
out.push("");
|
|
97336
|
-
out.push(` ${
|
|
97337
|
-
out.push(` ${
|
|
97338
|
-
out.push(` ${
|
|
97339
|
-
out.push(` ${
|
|
97340
|
-
out.push(` ${
|
|
97341
|
-
out.push(` ${
|
|
97342
|
-
out.push(` ${
|
|
97706
|
+
out.push(` ${import_picocolors81.default.cyan("template pack")} ${import_picocolors81.default.dim("bundle the current agent into a template")}`);
|
|
97707
|
+
out.push(` ${import_picocolors81.default.cyan("template publish")} ${import_picocolors81.default.dim("upload a template to the registry")}`);
|
|
97708
|
+
out.push(` ${import_picocolors81.default.cyan("template search")} ${import_picocolors81.default.dim("[query]")} ${import_picocolors81.default.dim("search the registry")}`);
|
|
97709
|
+
out.push(` ${import_picocolors81.default.cyan("template info")} ${import_picocolors81.default.dim("<creator/slug>")} ${import_picocolors81.default.dim("show registry details for a template")}`);
|
|
97710
|
+
out.push(` ${import_picocolors81.default.cyan("template onboard")} ${import_picocolors81.default.dim("<creator/slug>")} ${import_picocolors81.default.dim("install (or refresh) a template")}`);
|
|
97711
|
+
out.push(` ${import_picocolors81.default.cyan("template list")} ${import_picocolors81.default.dim("show installed templates")}`);
|
|
97712
|
+
out.push(` ${import_picocolors81.default.cyan("template remove")} ${import_picocolors81.default.dim("<creator/slug>")} ${import_picocolors81.default.dim("uninstall a template")}`);
|
|
97343
97713
|
out.push("");
|
|
97344
97714
|
out.push(divider("SKILLS"));
|
|
97345
97715
|
out.push("");
|
|
97346
|
-
out.push(` ${
|
|
97347
|
-
out.push(` ${
|
|
97348
|
-
out.push(` ${
|
|
97349
|
-
out.push(` ${
|
|
97350
|
-
out.push(` ${
|
|
97351
|
-
out.push(` ${
|
|
97352
|
-
out.push(` ${
|
|
97716
|
+
out.push(` ${import_picocolors81.default.cyan("skill add")} ${import_picocolors81.default.dim("<source>")} ${import_picocolors81.default.dim("install a skill (github / git / brainbase)")}`);
|
|
97717
|
+
out.push(` ${import_picocolors81.default.cyan("skill list")} ${import_picocolors81.default.dim("show locally installed skills + their source")}`);
|
|
97718
|
+
out.push(` ${import_picocolors81.default.cyan("skill update")} ${import_picocolors81.default.dim("<slug>")} ${import_picocolors81.default.dim("re-fetch a skill from its recorded source")}`);
|
|
97719
|
+
out.push(` ${import_picocolors81.default.cyan("skill remove")} ${import_picocolors81.default.dim("<slug>")} ${import_picocolors81.default.dim("uninstall a skill")}`);
|
|
97720
|
+
out.push(` ${import_picocolors81.default.cyan("skill search")} ${import_picocolors81.default.dim("[query]")} ${import_picocolors81.default.dim("search the brainbase skill registry")}`);
|
|
97721
|
+
out.push(` ${import_picocolors81.default.cyan("skill info")} ${import_picocolors81.default.dim("<creator/slug>")} ${import_picocolors81.default.dim("show registry details for a skill")}`);
|
|
97722
|
+
out.push(` ${import_picocolors81.default.cyan("skill publish")} ${import_picocolors81.default.dim("[dir]")} ${import_picocolors81.default.dim("publish a SKILL.md folder (defaults to .)")}`);
|
|
97353
97723
|
out.push("");
|
|
97354
97724
|
out.push(divider("CLI TOKENS"));
|
|
97355
97725
|
out.push("");
|
|
97356
|
-
out.push(` ${
|
|
97357
|
-
out.push(` ${
|
|
97358
|
-
out.push(` ${
|
|
97359
|
-
out.push(` ${
|
|
97726
|
+
out.push(` ${import_picocolors81.default.cyan("token create")} ${import_picocolors81.default.dim("issue a long-lived CLI key for CI / scripts")}`);
|
|
97727
|
+
out.push(` ${import_picocolors81.default.cyan("token list")} ${import_picocolors81.default.dim("show your tokens")}`);
|
|
97728
|
+
out.push(` ${import_picocolors81.default.cyan("token rename")} ${import_picocolors81.default.dim("<id>")} ${import_picocolors81.default.dim("relabel a token")}`);
|
|
97729
|
+
out.push(` ${import_picocolors81.default.cyan("token revoke")} ${import_picocolors81.default.dim("<id>")} ${import_picocolors81.default.dim("revoke a token")}`);
|
|
97360
97730
|
out.push("");
|
|
97361
97731
|
out.push(divider("MCP"));
|
|
97362
97732
|
out.push("");
|
|
97363
|
-
out.push(` ${
|
|
97364
|
-
out.push(` ${
|
|
97365
|
-
out.push(` ${
|
|
97733
|
+
out.push(` ${import_picocolors81.default.cyan("mcp check")} ${import_picocolors81.default.dim("[--json]")} ${import_picocolors81.default.dim("verify MCP server connectivity through the brainbase proxy (runs at sandbox bootstrap)")}`);
|
|
97734
|
+
out.push(` ${import_picocolors81.default.cyan("mcp list")} ${import_picocolors81.default.dim("[--json]")} ${import_picocolors81.default.dim("show configured servers with OAuth state and expiry")}`);
|
|
97735
|
+
out.push(` ${import_picocolors81.default.cyan("mcp connect")} ${import_picocolors81.default.dim("<name>")} ${import_picocolors81.default.dim("authorize an OAuth-backed server: prints a single-use link, opens it, waits for approval")}`);
|
|
97366
97736
|
out.push("");
|
|
97367
97737
|
out.push(divider("INTEGRATIONS"));
|
|
97368
97738
|
out.push("");
|
|
97369
|
-
out.push(` ${
|
|
97370
|
-
out.push(` ${
|
|
97371
|
-
out.push(` ${
|
|
97372
|
-
out.push(` ${
|
|
97373
|
-
out.push(` ${
|
|
97374
|
-
out.push(` ${
|
|
97375
|
-
out.push(` ${
|
|
97376
|
-
out.push(` ${
|
|
97739
|
+
out.push(` ${import_picocolors81.default.cyan("integrations list")} ${import_picocolors81.default.dim("show the agent's Pipedream apps, accounts and app-level permission")}`);
|
|
97740
|
+
out.push(` ${import_picocolors81.default.cyan("integrations search")} ${import_picocolors81.default.dim("<query>")} ${import_picocolors81.default.dim("find apps in the Pipedream catalog")}`);
|
|
97741
|
+
out.push(` ${import_picocolors81.default.cyan("integrations actions")} ${import_picocolors81.default.dim("<app>")} ${import_picocolors81.default.dim("list an app's actions and whether each is allowed")}`);
|
|
97742
|
+
out.push(` ${import_picocolors81.default.cyan("integrations add")} ${import_picocolors81.default.dim("<app>")} ${import_picocolors81.default.dim("install an app; one that needs an account runs connect")}`);
|
|
97743
|
+
out.push(` ${import_picocolors81.default.cyan("integrations connect")} ${import_picocolors81.default.dim("<app>")} ${import_picocolors81.default.dim("open Pipedream's connect page for the app and wait for the account")}`);
|
|
97744
|
+
out.push(` ${import_picocolors81.default.cyan("integrations disconnect")} ${import_picocolors81.default.dim("<app>")} ${import_picocolors81.default.dim("delete the app's connected account")}`);
|
|
97745
|
+
out.push(` ${import_picocolors81.default.cyan("integrations remove")} ${import_picocolors81.default.dim("<app>")} ${import_picocolors81.default.dim("uninstall an app that needs no account")}`);
|
|
97746
|
+
out.push(` ${import_picocolors81.default.cyan("integrations allow|ask|deny")} ${import_picocolors81.default.dim("<app>[.<action>]")} ${import_picocolors81.default.dim("set the permission for an app or one of its actions")}`);
|
|
97747
|
+
out.push(` ${import_picocolors81.default.cyan("integrations context create")} ${import_picocolors81.default.dim("--application <name>")} ${import_picocolors81.default.dim("let a program outside Brainbase (the SDK) use the agent's integrations; prints a renewal handle once")}`);
|
|
97748
|
+
out.push(` ${import_picocolors81.default.cyan("integrations context end")} ${import_picocolors81.default.dim("<context-id>")} ${import_picocolors81.default.dim("end a standalone integration context now")}`);
|
|
97377
97749
|
out.push("");
|
|
97378
97750
|
out.push(divider("FLAGS"));
|
|
97379
97751
|
out.push("");
|
|
97380
|
-
out.push(` ${
|
|
97381
|
-
out.push(` ${
|
|
97382
|
-
out.push(` ${
|
|
97752
|
+
out.push(` ${import_picocolors81.default.dim("--harness <id>")} force harness for onboard / sync (e.g. claude-code)`);
|
|
97753
|
+
out.push(` ${import_picocolors81.default.dim("--scope <s>")} force scope: global | project`);
|
|
97754
|
+
out.push(` ${import_picocolors81.default.dim("--yes, -y")} skip confirmations / auto-overwrite`);
|
|
97383
97755
|
out.push(` ${" ".repeat("--yes, -y".length)} required for destructive commands with no terminal (pipes, CI)`);
|
|
97384
|
-
out.push(` ${
|
|
97385
|
-
out.push(` ${
|
|
97386
|
-
out.push(` ${
|
|
97387
|
-
out.push(` ${
|
|
97388
|
-
out.push(` ${
|
|
97389
|
-
out.push(` ${
|
|
97390
|
-
out.push(` ${
|
|
97391
|
-
out.push(` ${
|
|
97392
|
-
out.push(` ${
|
|
97393
|
-
out.push(` ${
|
|
97394
|
-
out.push(` ${
|
|
97395
|
-
out.push(` ${
|
|
97396
|
-
out.push(` ${
|
|
97397
|
-
out.push(` ${
|
|
97398
|
-
out.push(` ${
|
|
97399
|
-
out.push(` ${
|
|
97400
|
-
out.push(` ${
|
|
97401
|
-
out.push(` ${
|
|
97402
|
-
out.push(` ${
|
|
97403
|
-
out.push(` ${
|
|
97404
|
-
out.push(` ${
|
|
97405
|
-
out.push(` ${
|
|
97406
|
-
out.push(` ${
|
|
97407
|
-
out.push(` ${
|
|
97408
|
-
out.push(` ${
|
|
97409
|
-
out.push(` ${
|
|
97410
|
-
out.push(` ${
|
|
97411
|
-
out.push(` ${
|
|
97412
|
-
out.push(` ${
|
|
97413
|
-
out.push(` ${
|
|
97414
|
-
out.push(` ${
|
|
97415
|
-
out.push(` ${
|
|
97416
|
-
out.push(` ${
|
|
97417
|
-
out.push(` ${
|
|
97756
|
+
out.push(` ${import_picocolors81.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)`);
|
|
97757
|
+
out.push(` ${import_picocolors81.default.dim("--message <text>")} for task create: required first user message`);
|
|
97758
|
+
out.push(` ${import_picocolors81.default.dim("--title <text>")} for task create: optional task title; for task update: the new title`);
|
|
97759
|
+
out.push(` ${import_picocolors81.default.dim("--clear-title")} for task update: remove the title (automatic titling may name it again later)`);
|
|
97760
|
+
out.push(` ${import_picocolors81.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)`);
|
|
97761
|
+
out.push(` ${import_picocolors81.default.dim("--unset-metadata <k>")} for task update: remove one label (repeatable)`);
|
|
97762
|
+
out.push(` ${import_picocolors81.default.dim("--clear-metadata")} for task update: remove every label; with --metadata, keep only those given`);
|
|
97763
|
+
out.push(` ${import_picocolors81.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)`);
|
|
97764
|
+
out.push(` ${import_picocolors81.default.dim("--clear-model")} for task update: go back to the agent's default model from the next turn`);
|
|
97765
|
+
out.push(` ${import_picocolors81.default.dim("--version <v>")} for task create: run a saved version of the agent (12, v12 or a version id)`);
|
|
97766
|
+
out.push(` ${import_picocolors81.default.dim("--wait")} for task create: block until the task finishes; exit 1 unless it succeeded`);
|
|
97767
|
+
out.push(` ${import_picocolors81.default.dim("--timeout <secs>")} for task create --wait: give up after <secs> and exit 1`);
|
|
97768
|
+
out.push(` ${import_picocolors81.default.dim("--limit <n>")} for task list (1-200), task logs (events to print; with --follow, the first page size) and machine ls`);
|
|
97769
|
+
out.push(` ${import_picocolors81.default.dim("--follow, -f")} for task logs: stay attached and print events as they land`);
|
|
97770
|
+
out.push(` ${import_picocolors81.default.dim("--org <id-or-slug>")} pick the organization (team/agent list, agent create, orchestration create/list)`);
|
|
97771
|
+
out.push(` ${import_picocolors81.default.dim("--team <id>")} pick the team, same commands (works without --org)`);
|
|
97772
|
+
out.push(` ${import_picocolors81.default.dim("--all-teams")} for agent list: every team in the org (the default with no terminal)`);
|
|
97773
|
+
out.push(` ${import_picocolors81.default.dim("--json")} machine-readable output for supported commands`);
|
|
97774
|
+
out.push(` ${import_picocolors81.default.dim("--no-tracking")} for link / agent pull --link: skip routing LLM traffic through brainbase`);
|
|
97775
|
+
out.push(` ${import_picocolors81.default.dim("--link")} for agent pull: link this folder to the agent first, as \`brainbase link --agent <id> --yes\` would, in one process`);
|
|
97776
|
+
out.push(` ${import_picocolors81.default.dim("--track")} for agent create: enable tracking non-interactively (off without a TTY)`);
|
|
97777
|
+
out.push(` ${import_picocolors81.default.dim("--shell <sh|fish>")} for agent env: pick output format (auto-detected from $SHELL)`);
|
|
97778
|
+
out.push(` ${import_picocolors81.default.dim("--bot-token <t>")} for agent connect slack (or BRAINBASE_SLACK_BOT_TOKEN, or stdin)`);
|
|
97779
|
+
out.push(` ${import_picocolors81.default.dim("--signing-secret <s>")} for agent connect slack (or BRAINBASE_SLACK_SIGNING_SECRET, or stdin)`);
|
|
97780
|
+
out.push(` ${import_picocolors81.default.dim("--bot-name <name>")} for agent connect meeting: the bot's display name`);
|
|
97781
|
+
out.push(` ${import_picocolors81.default.dim("--app-id <id> / --app-name <name>")} optional Slack app identity`);
|
|
97782
|
+
out.push(` ${import_picocolors81.default.dim("--bot-image-url <url>")} optional meeting bot image`);
|
|
97783
|
+
out.push(` ${import_picocolors81.default.dim("--full")} for agent/orchestration init: write a commented template covering every block`);
|
|
97784
|
+
out.push(` ${import_picocolors81.default.dim("--minimal")} for agent init: write the starter manifest (the default)`);
|
|
97785
|
+
out.push(` ${import_picocolors81.default.dim("--all")} for template list: include installs from other folders; for machine ls: include torn-down machines`);
|
|
97786
|
+
out.push(` ${import_picocolors81.default.dim("--web <url>")} for login: web app URL (default https://app.brainbaselabs.com)`);
|
|
97787
|
+
out.push(` ${import_picocolors81.default.dim("--no-open")} for mcp/integrations connect: print the link without opening a browser (implied with no terminal)`);
|
|
97788
|
+
out.push(` ${import_picocolors81.default.dim("--no-wait")} for mcp/integrations connect: print the link and exit instead of waiting`);
|
|
97789
|
+
out.push(` ${import_picocolors81.default.dim("--account <id>")} for integrations disconnect: which account, when the app has more than one`);
|
|
97790
|
+
out.push(` ${import_picocolors81.default.dim("--application <name>")} for integrations context create: names the program the context is for`);
|
|
97791
|
+
out.push(` ${import_picocolors81.default.dim("--max-lifetime <dur>")} for integrations context create: when the context ends at the latest, 60s-30d (default 7d)`);
|
|
97792
|
+
out.push(` ${import_picocolors81.default.dim("--reason <text>")} for integrations context end: recorded with the context`);
|
|
97418
97793
|
out.push("");
|
|
97419
97794
|
out.push(divider("ENV"));
|
|
97420
97795
|
out.push("");
|
|
97421
|
-
out.push(` ${
|
|
97422
|
-
out.push(` ${
|
|
97423
|
-
out.push(` ${
|
|
97424
|
-
out.push(` ${
|
|
97425
|
-
out.push(` ${
|
|
97426
|
-
out.push(` ${
|
|
97427
|
-
out.push(` ${
|
|
97428
|
-
out.push(` ${
|
|
97429
|
-
out.push(` ${
|
|
97430
|
-
out.push(` ${
|
|
97431
|
-
out.push(` ${
|
|
97796
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_HOME")} override the local config dir (default ~/.brainbase)`);
|
|
97797
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_DEBUG")} print full stack traces on error (any value; unset to disable)`);
|
|
97798
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_WEB_URL")} override the web app URL used by login, console links and integrations`);
|
|
97799
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_CONTROL_PLANE_URL")} override the MAS host (/v2/cli; task and interface commands use /v2/tasks and /v2/interfaces)`);
|
|
97800
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_API_URL")} legacy KLS host override (uses /api/cli; proxy/registry fallback)`);
|
|
97801
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_PROXY_URL")} override the model-proxy URL used by harness traffic (default https://api.v1.brainbaselabs.com)`);
|
|
97802
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_REGISTRY_URL")} override the registry API URL (default https://api.v1.brainbaselabs.com)`);
|
|
97803
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_TOKEN")} long-lived CLI PAT; outranks the login session and the PAT saved in token.json`);
|
|
97804
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_SKIP_AUTH")} bypass the auth gate for development`);
|
|
97805
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_NON_INTERACTIVE")} force non-interactive mode — skip/auto-default prompts (CI & agents)`);
|
|
97806
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_RUN_ENTRYPOINT")} =1 → agent pull executes the agent entrypoint (sandbox boots; or pass --run-entrypoint)`);
|
|
97432
97807
|
out.push("");
|
|
97433
|
-
out.push(` ${
|
|
97434
|
-
out.push(` ${
|
|
97435
|
-
out.push(` ${
|
|
97436
|
-
out.push(` ${
|
|
97437
|
-
out.push(` ${
|
|
97438
|
-
out.push(` ${
|
|
97439
|
-
out.push(` ${
|
|
97808
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_MEMORY_MCP_URL")} override the built-in memory MCP host`);
|
|
97809
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_BROWSER_MCP_URL")} override the built-in browser MCP host`);
|
|
97810
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_SLACK_MCP_URL")} override the built-in Slack MCP host`);
|
|
97811
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_MEETING_MCP_URL")} override the built-in meeting MCP host`);
|
|
97812
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_GITHUB_MCP_URL")} override the built-in GitHub MCP host`);
|
|
97813
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_LINEAR_MCP_URL")} override the built-in Linear MCP host`);
|
|
97814
|
+
out.push(` ${import_picocolors81.default.dim("BRAINBASE_ORCHESTRATION_MCP_URL")} override the built-in orchestration MCP host`);
|
|
97440
97815
|
out.push("");
|
|
97441
97816
|
out.push(divider("HARNESSES"));
|
|
97442
97817
|
out.push("");
|
|
97443
|
-
out.push(` ${
|
|
97444
|
-
out.push(` ${
|
|
97445
|
-
out.push(` ${
|
|
97818
|
+
out.push(` ${import_picocolors81.default.dim("•")} ${import_picocolors81.default.bold("claude-code")} ${import_picocolors81.default.dim("skills, mcps, agents, commands, playbooks, instructions, files")}`);
|
|
97819
|
+
out.push(` ${import_picocolors81.default.dim("•")} ${import_picocolors81.default.bold("codex")} ${import_picocolors81.default.dim("skills, mcps, commands, playbooks, instructions, files")}`);
|
|
97820
|
+
out.push(` ${import_picocolors81.default.dim("•")} ${import_picocolors81.default.bold("kafka")} ${import_picocolors81.default.dim("skills, mcps, agents, commands, playbooks, instructions, files")}`);
|
|
97446
97821
|
out.push("");
|
|
97447
97822
|
console.log(out.join(`
|
|
97448
97823
|
`));
|
|
@@ -97476,7 +97851,10 @@ var VALUE_TAKING_FLAGS = new Set([
|
|
|
97476
97851
|
"--bot-image-url",
|
|
97477
97852
|
"--task-id",
|
|
97478
97853
|
"--limit",
|
|
97479
|
-
"--file"
|
|
97854
|
+
"--file",
|
|
97855
|
+
"--application",
|
|
97856
|
+
"--max-lifetime",
|
|
97857
|
+
"--reason"
|
|
97480
97858
|
]);
|
|
97481
97859
|
function isValueOfPriorFlag2(args, index) {
|
|
97482
97860
|
return index > 0 && VALUE_TAKING_FLAGS.has(args[index - 1]);
|
|
@@ -97597,10 +97975,10 @@ async function requireAuth(cmd) {
|
|
|
97597
97975
|
if (storedPatFor(status.session))
|
|
97598
97976
|
return;
|
|
97599
97977
|
console.error("");
|
|
97600
|
-
console.error(` ${brandTint("◆")} ${
|
|
97978
|
+
console.error(` ${brandTint("◆")} ${import_picocolors81.default.bold("brainbase")}`);
|
|
97601
97979
|
console.error("");
|
|
97602
|
-
console.error(` ${
|
|
97603
|
-
console.error(` ${
|
|
97980
|
+
console.error(` ${import_picocolors81.default.red("✗")} You need to sign in to use ${import_picocolors81.default.bold("brainbase " + cmd)}.`);
|
|
97981
|
+
console.error(` ${import_picocolors81.default.dim(noUsableCredentialMessage())}`);
|
|
97604
97982
|
console.error("");
|
|
97605
97983
|
process14.exit(1);
|
|
97606
97984
|
}
|
|
@@ -97884,12 +98262,12 @@ ${didYouMean(cmd, COMMANDS3, "brainbase")}`);
|
|
|
97884
98262
|
process14.exit(1);
|
|
97885
98263
|
}
|
|
97886
98264
|
} catch (err) {
|
|
97887
|
-
const
|
|
98265
|
+
const message3 = sanitizeLines(err.message).join(`
|
|
97888
98266
|
`);
|
|
97889
|
-
console.error(
|
|
97890
|
-
${
|
|
98267
|
+
console.error(import_picocolors81.default.red(`
|
|
98268
|
+
${message3}`));
|
|
97891
98269
|
if (err instanceof ApiError && err.status === 401 && !err.message.includes("brainbase login")) {
|
|
97892
|
-
console.error(` Run ${
|
|
98270
|
+
console.error(` Run ${import_picocolors81.default.cyan("brainbase login")} to connect this device.`);
|
|
97893
98271
|
}
|
|
97894
98272
|
if (process14.env.BRAINBASE_DEBUG)
|
|
97895
98273
|
console.error(err.stack);
|