@brunobracaioli/aibrain 0.4.0-beta.31 → 0.4.0-beta.32
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/assets/jev-paid-pilot-terminal.mjs +4 -0
- package/dist/claude-observation.mjs +1 -1
- package/dist/cli.mjs +23 -4
- package/dist/engineering-pack.mjs +221 -31
- package/dist/launch.mjs +67 -6
- package/dist/manager/bus.mjs +20 -9
- package/dist/manager/launch-role.mjs +2 -0
- package/dist/mcp.mjs +40 -14
- package/dist/package.json +1 -1
- package/dist/policy.mjs +16 -0
- package/dist/process-snapshot.mjs +778 -0
- package/dist/release-manifest.json +7 -7
- package/dist/resources-next.mjs +498 -0
- package/dist/resources.mjs +963 -0
- package/package.json +1 -1
package/dist/mcp.mjs
CHANGED
|
@@ -550,21 +550,47 @@ function responseError(response, fallback) {
|
|
|
550
550
|
return fallback;
|
|
551
551
|
}
|
|
552
552
|
|
|
553
|
-
/**
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
553
|
+
/** Server tool error codes the client acts on, mapped to its own codes. */
|
|
554
|
+
const CLIENT_ERROR_CODES = new Map([
|
|
555
|
+
['FEATURE_DISABLED', 'mcp_feature_disabled'],
|
|
556
|
+
['TOOL_UNAVAILABLE', 'mcp_tool_unavailable'],
|
|
557
|
+
['PAID_PLAN_REQUIRED', 'mcp_paid_plan_required'],
|
|
558
|
+
['INVALID_INPUT', 'mcp_invalid_input'],
|
|
559
|
+
]);
|
|
560
|
+
/** A tool error text longer than this is not parsed as JSON. */
|
|
561
|
+
const MAX_ERROR_TEXT_JSON = 4_096;
|
|
562
|
+
|
|
563
|
+
/** @param {unknown} text @returns {string | undefined} */
|
|
564
|
+
function jsonErrorCode(text) {
|
|
565
|
+
if (typeof text !== 'string' || !text.startsWith('{') || text.length > MAX_ERROR_TEXT_JSON)
|
|
566
|
+
return undefined;
|
|
567
|
+
try {
|
|
568
|
+
const parsed = JSON.parse(text);
|
|
569
|
+
return isObject(parsed) && typeof parsed.error_code === 'string'
|
|
570
|
+
? parsed.error_code
|
|
562
571
|
: undefined;
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
572
|
+
} catch {
|
|
573
|
+
return undefined;
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/**
|
|
578
|
+
* The client code of a tool error, or undefined so the caller's fallback
|
|
579
|
+
* applies. The context tools put the server code in
|
|
580
|
+
* `structuredContent.error_code` and repeat that object as JSON text; older
|
|
581
|
+
* servers write `CODE: message` text. Only codes in CLIENT_ERROR_CODES map.
|
|
582
|
+
* @param {JsonObject | null} result @returns {string | undefined}
|
|
583
|
+
*/
|
|
584
|
+
function structuredErrorCode(result) {
|
|
585
|
+
if (!result || result.isError !== true) return undefined;
|
|
586
|
+
const structured = isObject(result.structuredContent) ? result.structuredContent : null;
|
|
587
|
+
const content = Array.isArray(result.content) ? result.content : [];
|
|
588
|
+
const text = content.find((item) => isObject(item) && typeof item.text === 'string')?.text;
|
|
589
|
+
const serverCode =
|
|
590
|
+
(typeof structured?.error_code === 'string' ? structured.error_code : undefined) ??
|
|
591
|
+
jsonErrorCode(text) ??
|
|
592
|
+
(typeof text === 'string' ? /^([A-Z_]{1,64})(?::|$)/u.exec(text)?.[1] : undefined);
|
|
593
|
+
return serverCode === undefined ? undefined : CLIENT_ERROR_CODES.get(serverCode);
|
|
568
594
|
}
|
|
569
595
|
|
|
570
596
|
/** @param {string} endpoint @param {string} token @returns {Promise<{ok:true, providerBatches:0, providerModel:null}>} */
|
package/dist/package.json
CHANGED
package/dist/policy.mjs
CHANGED
|
@@ -201,6 +201,22 @@ export function codexPolicyJson(policy) {
|
|
|
201
201
|
return serialized;
|
|
202
202
|
}
|
|
203
203
|
|
|
204
|
+
/**
|
|
205
|
+
* ASCII-only, any letter case: without the `u` flag a non-ASCII character never
|
|
206
|
+
* matches an ASCII letter, so look-alike characters are refused.
|
|
207
|
+
*/
|
|
208
|
+
const DISCLOSURE_ACCEPT_PATTERN = /^accept$/i;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Whether a typed answer accepts the setup disclosure: the word ACCEPT in any
|
|
212
|
+
* letter case, with only whitespace around it. It stays one explicit word; a
|
|
213
|
+
* generic yes never accepts (spec aibrain-subscriber-beta, setup step 2).
|
|
214
|
+
* @param {string} answer
|
|
215
|
+
*/
|
|
216
|
+
export function disclosureAnswerAccepted(answer) {
|
|
217
|
+
return DISCLOSURE_ACCEPT_PATTERN.test(answer.trim());
|
|
218
|
+
}
|
|
219
|
+
|
|
204
220
|
/** @param {ContextPolicy} policy */
|
|
205
221
|
export function publicPolicy(policy) {
|
|
206
222
|
return {
|