@brainbase-labs/cli 0.62.0 → 0.63.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 +80 -17
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -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.63.0",
|
|
36095
36095
|
description: "Pack, share, and install agent templates across harnesses (Claude Code, Codex, ...).",
|
|
36096
36096
|
type: "module",
|
|
36097
36097
|
bin: {
|
|
@@ -56387,6 +56387,13 @@ async function linkRequest(pathname, init, unsupported) {
|
|
|
56387
56387
|
throw err;
|
|
56388
56388
|
}
|
|
56389
56389
|
}
|
|
56390
|
+
function parseAgentSecretsBody(body) {
|
|
56391
|
+
const secrets = body && typeof body === "object" ? body.secrets : undefined;
|
|
56392
|
+
if (!secrets || typeof secrets !== "object" || Array.isArray(secrets) || !Object.values(secrets).every((value) => typeof value === "string")) {
|
|
56393
|
+
throw new ApiError("The control plane returned an unreadable secrets response", undefined);
|
|
56394
|
+
}
|
|
56395
|
+
return { secrets };
|
|
56396
|
+
}
|
|
56390
56397
|
var api = {
|
|
56391
56398
|
listOrgs() {
|
|
56392
56399
|
return request("/orgs");
|
|
@@ -56503,11 +56510,7 @@ var api = {
|
|
|
56503
56510
|
},
|
|
56504
56511
|
async getAgentSecrets(agentId) {
|
|
56505
56512
|
const body = await request(`/agents/${encodeURIComponent(agentId)}/secrets`);
|
|
56506
|
-
|
|
56507
|
-
if (!secrets || typeof secrets !== "object" || Array.isArray(secrets) || !Object.values(secrets).every((value) => typeof value === "string")) {
|
|
56508
|
-
throw new ApiError("The control plane returned an unreadable secrets response", undefined);
|
|
56509
|
-
}
|
|
56510
|
-
return { secrets };
|
|
56513
|
+
return parseAgentSecretsBody(body);
|
|
56511
56514
|
},
|
|
56512
56515
|
putAgentSecrets(agentId, secrets, options) {
|
|
56513
56516
|
const { idempotent = false, ...transport } = options ?? {};
|
|
@@ -67919,6 +67922,61 @@ async function pickHarness(current) {
|
|
|
67919
67922
|
});
|
|
67920
67923
|
}
|
|
67921
67924
|
|
|
67925
|
+
// src/core/pull-bundle.ts
|
|
67926
|
+
import { gunzipSync } from "node:zlib";
|
|
67927
|
+
var PULL_BUNDLE_ENV = "BRAINBASE_PULL_BUNDLE";
|
|
67928
|
+
var PULL_BUNDLE_VERSION = 1;
|
|
67929
|
+
var PULL_BUNDLE_MAX_AGE_S = 120;
|
|
67930
|
+
var PULL_BUNDLE_MAX_SKEW_S = 60;
|
|
67931
|
+
function isObject2(value) {
|
|
67932
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
67933
|
+
}
|
|
67934
|
+
function isUsableComponent(component) {
|
|
67935
|
+
return isObject2(component) && typeof component.type === "string" && typeof component.slug === "string" && Array.isArray(component.files) && component.files.every((file) => isObject2(file) && typeof file.path === "string" && typeof file.content === "string");
|
|
67936
|
+
}
|
|
67937
|
+
function takePullBundle(agentId) {
|
|
67938
|
+
const raw = process.env[PULL_BUNDLE_ENV];
|
|
67939
|
+
delete process.env[PULL_BUNDLE_ENV];
|
|
67940
|
+
if (!raw)
|
|
67941
|
+
return { status: "absent" };
|
|
67942
|
+
let parsed;
|
|
67943
|
+
try {
|
|
67944
|
+
parsed = JSON.parse(gunzipSync(Buffer.from(raw, "base64")).toString("utf8"));
|
|
67945
|
+
} catch {
|
|
67946
|
+
return { status: "unusable", reason: "undecodable" };
|
|
67947
|
+
}
|
|
67948
|
+
if (!isObject2(parsed) || parsed.v !== PULL_BUNDLE_VERSION) {
|
|
67949
|
+
return { status: "unusable", reason: "version" };
|
|
67950
|
+
}
|
|
67951
|
+
if (parsed.agent_id !== agentId)
|
|
67952
|
+
return { status: "unusable", reason: "agent" };
|
|
67953
|
+
const nowS = Date.now() / 1000;
|
|
67954
|
+
if (typeof parsed.issued_at !== "number" || nowS - parsed.issued_at > PULL_BUNDLE_MAX_AGE_S || parsed.issued_at - nowS > PULL_BUNDLE_MAX_SKEW_S) {
|
|
67955
|
+
return { status: "unusable", reason: "stale" };
|
|
67956
|
+
}
|
|
67957
|
+
const { agent, manifest } = parsed;
|
|
67958
|
+
if (!isObject2(agent) || agent.id !== agentId) {
|
|
67959
|
+
return { status: "unusable", reason: "agent body" };
|
|
67960
|
+
}
|
|
67961
|
+
if (!isObject2(manifest) || manifest.agent_id !== agentId || typeof manifest.revision !== "number" || !Array.isArray(manifest.components) || !manifest.components.every(isUsableComponent)) {
|
|
67962
|
+
return { status: "unusable", reason: "manifest body" };
|
|
67963
|
+
}
|
|
67964
|
+
let secrets;
|
|
67965
|
+
try {
|
|
67966
|
+
secrets = parseAgentSecretsBody(parsed.secrets);
|
|
67967
|
+
} catch {
|
|
67968
|
+
return { status: "unusable", reason: "secrets body" };
|
|
67969
|
+
}
|
|
67970
|
+
return {
|
|
67971
|
+
status: "ok",
|
|
67972
|
+
bundle: {
|
|
67973
|
+
agent: withCloudRuntimeMode(agent),
|
|
67974
|
+
manifest,
|
|
67975
|
+
secrets
|
|
67976
|
+
}
|
|
67977
|
+
};
|
|
67978
|
+
}
|
|
67979
|
+
|
|
67922
67980
|
// src/cli/agent-pull.ts
|
|
67923
67981
|
async function runAgentPull(cwd2, args) {
|
|
67924
67982
|
banner("agent pull — bring cloud changes into this folder");
|
|
@@ -67927,11 +67985,16 @@ async function runAgentPull(cwd2, args) {
|
|
|
67927
67985
|
return;
|
|
67928
67986
|
const { agentId, override } = resolution;
|
|
67929
67987
|
let { existingManifest, lock, localComponents } = readLocalPullState(cwd2, override);
|
|
67988
|
+
const handed = takePullBundle(agentId);
|
|
67989
|
+
if (handed.status === "unusable") {
|
|
67990
|
+
f2.info(`Pull bundle not used (${handed.reason}); fetching from the cloud.`);
|
|
67991
|
+
}
|
|
67992
|
+
const bundle = handed.status === "ok" ? handed.bundle : undefined;
|
|
67930
67993
|
const sp = spinner();
|
|
67931
|
-
sp.start("Fetching agent…");
|
|
67932
|
-
const agentRequest = inFlight(api.getAgent(agentId));
|
|
67933
|
-
const manifestRequest = inFlight(api.getAgentManifest(agentId));
|
|
67934
|
-
const secretsRequest = pullReachesSecrets(args, existingManifest, lock, localComponents) ? inFlight(api.getAgentSecrets(agentId)) : undefined;
|
|
67994
|
+
sp.start(bundle ? "Reading agent from the boot bundle…" : "Fetching agent…");
|
|
67995
|
+
const agentRequest = inFlight(bundle ? Promise.resolve(bundle.agent) : api.getAgent(agentId));
|
|
67996
|
+
const manifestRequest = inFlight(bundle ? Promise.resolve(bundle.manifest) : api.getAgentManifest(agentId));
|
|
67997
|
+
const secretsRequest = bundle ? Promise.resolve(bundle.secrets) : pullReachesSecrets(args, existingManifest, lock, localComponents) ? inFlight(api.getAgentSecrets(agentId)) : undefined;
|
|
67935
67998
|
let cloudAgent;
|
|
67936
67999
|
let cloud;
|
|
67937
68000
|
try {
|
|
@@ -73494,7 +73557,7 @@ __export(exports_util, {
|
|
|
73494
73557
|
joinValues: () => joinValues,
|
|
73495
73558
|
issue: () => issue,
|
|
73496
73559
|
isPlainObject: () => isPlainObject2,
|
|
73497
|
-
isObject: () =>
|
|
73560
|
+
isObject: () => isObject3,
|
|
73498
73561
|
getSizableOrigin: () => getSizableOrigin,
|
|
73499
73562
|
getParsedType: () => getParsedType2,
|
|
73500
73563
|
getLengthableOrigin: () => getLengthableOrigin,
|
|
@@ -73632,7 +73695,7 @@ function esc(str2) {
|
|
|
73632
73695
|
return JSON.stringify(str2);
|
|
73633
73696
|
}
|
|
73634
73697
|
var captureStackTrace = Error.captureStackTrace ? Error.captureStackTrace : (..._args) => {};
|
|
73635
|
-
function
|
|
73698
|
+
function isObject3(data) {
|
|
73636
73699
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
73637
73700
|
}
|
|
73638
73701
|
var allowsEval = cached(() => {
|
|
@@ -73648,13 +73711,13 @@ var allowsEval = cached(() => {
|
|
|
73648
73711
|
}
|
|
73649
73712
|
});
|
|
73650
73713
|
function isPlainObject2(o2) {
|
|
73651
|
-
if (
|
|
73714
|
+
if (isObject3(o2) === false)
|
|
73652
73715
|
return false;
|
|
73653
73716
|
const ctor = o2.constructor;
|
|
73654
73717
|
if (ctor === undefined)
|
|
73655
73718
|
return true;
|
|
73656
73719
|
const prot = ctor.prototype;
|
|
73657
|
-
if (
|
|
73720
|
+
if (isObject3(prot) === false)
|
|
73658
73721
|
return false;
|
|
73659
73722
|
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
|
|
73660
73723
|
return false;
|
|
@@ -75255,7 +75318,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
75255
75318
|
return (payload, ctx) => fn(shape, payload, ctx);
|
|
75256
75319
|
};
|
|
75257
75320
|
let fastpass;
|
|
75258
|
-
const
|
|
75321
|
+
const isObject4 = isObject3;
|
|
75259
75322
|
const jit = !globalConfig.jitless;
|
|
75260
75323
|
const allowsEval2 = allowsEval;
|
|
75261
75324
|
const fastEnabled = jit && allowsEval2.value;
|
|
@@ -75264,7 +75327,7 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
75264
75327
|
inst._zod.parse = (payload, ctx) => {
|
|
75265
75328
|
value ?? (value = _normalized.value);
|
|
75266
75329
|
const input = payload.value;
|
|
75267
|
-
if (!
|
|
75330
|
+
if (!isObject4(input)) {
|
|
75268
75331
|
payload.issues.push({
|
|
75269
75332
|
expected: "object",
|
|
75270
75333
|
code: "invalid_type",
|
|
@@ -75423,7 +75486,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
|
|
|
75423
75486
|
});
|
|
75424
75487
|
inst._zod.parse = (payload, ctx) => {
|
|
75425
75488
|
const input = payload.value;
|
|
75426
|
-
if (!
|
|
75489
|
+
if (!isObject3(input)) {
|
|
75427
75490
|
payload.issues.push({
|
|
75428
75491
|
code: "invalid_type",
|
|
75429
75492
|
expected: "object",
|