@warmdrift/kgauto-compiler 2.0.0-alpha.52 → 2.0.0-alpha.54
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/brain-proxy.d.mts +87 -0
- package/dist/brain-proxy.d.ts +87 -0
- package/dist/brain-proxy.js +121 -0
- package/dist/brain-proxy.mjs +6 -0
- package/dist/{chunk-HHWBB46W.mjs → chunk-IIMPJZNH.mjs} +1 -1
- package/dist/chunk-NGPB3D53.mjs +97 -0
- package/dist/{chunk-CXH7KC4D.mjs → chunk-QKXTMVCT.mjs} +57 -0
- package/dist/glassbox/index.d.mts +3 -3
- package/dist/glassbox/index.d.ts +3 -3
- package/dist/glassbox-routes/format.d.mts +2 -2
- package/dist/glassbox-routes/format.d.ts +2 -2
- package/dist/glassbox-routes/index.d.mts +4 -4
- package/dist/glassbox-routes/index.d.ts +4 -4
- package/dist/glassbox-routes/index.js +57 -0
- package/dist/glassbox-routes/index.mjs +2 -2
- package/dist/glassbox-routes/react/index.d.mts +2 -2
- package/dist/glassbox-routes/react/index.d.ts +2 -2
- package/dist/index.d.mts +24 -9
- package/dist/index.d.ts +24 -9
- package/dist/index.js +193 -9
- package/dist/index.mjs +46 -11
- package/dist/{ir-rUUojj0s.d.ts → ir-BiXAMyji.d.ts} +10 -1
- package/dist/{ir-dDcG8Pvu.d.mts → ir-CAlLBu5d.d.mts} +10 -1
- package/dist/profiles.d.mts +1 -1
- package/dist/profiles.d.ts +1 -1
- package/dist/profiles.js +57 -0
- package/dist/profiles.mjs +1 -1
- package/dist/{types-vGo-h0tZ.d.mts → types-C_dkNMA_.d.mts} +1 -1
- package/dist/{types-BTeRoSvM.d.mts → types-Dj5FLhBV.d.mts} +1 -1
- package/dist/{types-B_pdPjxm.d.ts → types-DsA8JFOp.d.ts} +1 -1
- package/dist/{types-UXPxWabQ.d.ts → types-hEDGehpz.d.ts} +1 -1
- package/package.json +7 -2
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@warmdrift/kgauto-compiler/brain-proxy` — consumer brain-forward factory.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this exists (the 4-consumer silent-drop class, 2026-07-06 s62)
|
|
5
|
+
*
|
|
6
|
+
* The library's `record()` / `recordOutcome()` / `recordShadowProbe()` /
|
|
7
|
+
* advisory paths all POST to a consumer-hosted proxy that forwards the row to
|
|
8
|
+
* the shared Supabase brain (the consumer holds the service-role key; kgauto's
|
|
9
|
+
* library never sees it). Every consumer hand-rolled that proxy layer — and a
|
|
10
|
+
* 4-consumer audit found every one silently broken in a *different* shape:
|
|
11
|
+
*
|
|
12
|
+
* - tt-intelligence: middleware blocked 2 of 3 routes — server-to-server
|
|
13
|
+
* POSTs 307-redirected to /login (missing public-path allowlist entry).
|
|
14
|
+
* - inspire-central: the `/outcomes` proxy carried a column whitelist frozen
|
|
15
|
+
* at alpha.7 that stripped `fell_over_from` / `fallback_reason`
|
|
16
|
+
* (migration 018 columns) — Glass-Box fallback telemetry silently NULL.
|
|
17
|
+
* - playbacksam: the `/probe_outcomes` whitelist would strip alpha.53's
|
|
18
|
+
* `error_class` — every future migration column drops on the floor.
|
|
19
|
+
* - global-expansion: mounted 1 of 4 routes — advisory POSTs 404 silently.
|
|
20
|
+
*
|
|
21
|
+
* Same L-142 / L-117 silent-drop family, four independent shapes, all in the
|
|
22
|
+
* layer consumers hand-roll. This factory kills the *class*: kgauto owns the
|
|
23
|
+
* forward handler, the consumer mounts ONE catch-all route. No column
|
|
24
|
+
* whitelist — the body is forwarded verbatim (`{ ...body }`), so any future
|
|
25
|
+
* migration column passes through untouched. One middleware/public-path entry
|
|
26
|
+
* (`/api/kgauto/v2/`) covers all four segments, which structurally prevents
|
|
27
|
+
* the tt-intel middleware-drift failure.
|
|
28
|
+
*
|
|
29
|
+
* ## Mounting recipes
|
|
30
|
+
*
|
|
31
|
+
* ### (a) Next.js app-router catch-all — ONE file, ONE middleware entry
|
|
32
|
+
*
|
|
33
|
+
* // app/api/kgauto/v2/[segment]/route.ts
|
|
34
|
+
* import { createBrainForwardRoutes } from '@warmdrift/kgauto-compiler/brain-proxy';
|
|
35
|
+
* const routes = createBrainForwardRoutes({
|
|
36
|
+
* ingestSecret: process.env.KGAUTO_INGEST_SECRET!,
|
|
37
|
+
* brainUrl: process.env.KGAUTO_BRAIN_URL!, // https://xxxx.supabase.co
|
|
38
|
+
* serviceKey: process.env.KGAUTO_BRAIN_SERVICE_KEY!,
|
|
39
|
+
* });
|
|
40
|
+
* export const POST = (req: Request, { params }: { params: { segment: string } }) =>
|
|
41
|
+
* routes.handle(req, params.segment);
|
|
42
|
+
*
|
|
43
|
+
* // middleware.ts — ONE public-path entry covers ALL four segments.
|
|
44
|
+
* // This is the structural fix for the tt-intel drift: you cannot mount
|
|
45
|
+
* // 3-of-4 routes and forget the 4th, because the catch-all is one file
|
|
46
|
+
* // and the allowlist is one prefix.
|
|
47
|
+
* const PUBLIC_PATHS = [ ... '/api/kgauto/v2/' ];
|
|
48
|
+
*
|
|
49
|
+
* ### (b) Plain Vercel edge function, per segment
|
|
50
|
+
*
|
|
51
|
+
* // api/kgauto/probe_outcomes.ts
|
|
52
|
+
* export const config = { runtime: 'edge' };
|
|
53
|
+
* const routes = createBrainForwardRoutes({ ... });
|
|
54
|
+
* export default (req: Request) => routes.handle(req, 'probe_outcomes');
|
|
55
|
+
*
|
|
56
|
+
* The library appends the segment path to the consumer's `endpoint`, so the
|
|
57
|
+
* consumer's `KGAUTO_V2_BRAIN_URL` (the value passed to `configureBrain`)
|
|
58
|
+
* must be the base that resolves to `.../api/kgauto/v2` — i.e. the last path
|
|
59
|
+
* segment of each library POST (`outcomes`, `probe_outcomes`, …) is what
|
|
60
|
+
* `handle()` receives as `segment`.
|
|
61
|
+
*/
|
|
62
|
+
interface BrainForwardConfig {
|
|
63
|
+
/** Bearer token consumers' callers must present (usually KGAUTO_INGEST_SECRET). */
|
|
64
|
+
ingestSecret: string;
|
|
65
|
+
/** Brain Supabase project URL (e.g. https://xxxx.supabase.co). */
|
|
66
|
+
brainUrl: string;
|
|
67
|
+
/** Brain service-role key (server-side only). */
|
|
68
|
+
serviceKey: string;
|
|
69
|
+
/** Optional fetch impl for tests. */
|
|
70
|
+
fetchImpl?: typeof fetch;
|
|
71
|
+
}
|
|
72
|
+
interface BrainForwardRoutes {
|
|
73
|
+
/**
|
|
74
|
+
* Web-standard handler. `segment` is the last path segment of the library's
|
|
75
|
+
* POST URL (e.g. 'outcomes', 'probe_outcomes'). In a Next.js catch-all this
|
|
76
|
+
* is `params.segment`. Never throws — every error path returns a `Response`.
|
|
77
|
+
*/
|
|
78
|
+
handle(req: Request, segment: string): Promise<Response>;
|
|
79
|
+
/**
|
|
80
|
+
* The path segments this factory serves. Consumers can use it for route
|
|
81
|
+
* generation, allowlist construction, or tests.
|
|
82
|
+
*/
|
|
83
|
+
segments: readonly string[];
|
|
84
|
+
}
|
|
85
|
+
declare function createBrainForwardRoutes(config: BrainForwardConfig): BrainForwardRoutes;
|
|
86
|
+
|
|
87
|
+
export { type BrainForwardConfig, type BrainForwardRoutes, createBrainForwardRoutes };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@warmdrift/kgauto-compiler/brain-proxy` — consumer brain-forward factory.
|
|
3
|
+
*
|
|
4
|
+
* ## Why this exists (the 4-consumer silent-drop class, 2026-07-06 s62)
|
|
5
|
+
*
|
|
6
|
+
* The library's `record()` / `recordOutcome()` / `recordShadowProbe()` /
|
|
7
|
+
* advisory paths all POST to a consumer-hosted proxy that forwards the row to
|
|
8
|
+
* the shared Supabase brain (the consumer holds the service-role key; kgauto's
|
|
9
|
+
* library never sees it). Every consumer hand-rolled that proxy layer — and a
|
|
10
|
+
* 4-consumer audit found every one silently broken in a *different* shape:
|
|
11
|
+
*
|
|
12
|
+
* - tt-intelligence: middleware blocked 2 of 3 routes — server-to-server
|
|
13
|
+
* POSTs 307-redirected to /login (missing public-path allowlist entry).
|
|
14
|
+
* - inspire-central: the `/outcomes` proxy carried a column whitelist frozen
|
|
15
|
+
* at alpha.7 that stripped `fell_over_from` / `fallback_reason`
|
|
16
|
+
* (migration 018 columns) — Glass-Box fallback telemetry silently NULL.
|
|
17
|
+
* - playbacksam: the `/probe_outcomes` whitelist would strip alpha.53's
|
|
18
|
+
* `error_class` — every future migration column drops on the floor.
|
|
19
|
+
* - global-expansion: mounted 1 of 4 routes — advisory POSTs 404 silently.
|
|
20
|
+
*
|
|
21
|
+
* Same L-142 / L-117 silent-drop family, four independent shapes, all in the
|
|
22
|
+
* layer consumers hand-roll. This factory kills the *class*: kgauto owns the
|
|
23
|
+
* forward handler, the consumer mounts ONE catch-all route. No column
|
|
24
|
+
* whitelist — the body is forwarded verbatim (`{ ...body }`), so any future
|
|
25
|
+
* migration column passes through untouched. One middleware/public-path entry
|
|
26
|
+
* (`/api/kgauto/v2/`) covers all four segments, which structurally prevents
|
|
27
|
+
* the tt-intel middleware-drift failure.
|
|
28
|
+
*
|
|
29
|
+
* ## Mounting recipes
|
|
30
|
+
*
|
|
31
|
+
* ### (a) Next.js app-router catch-all — ONE file, ONE middleware entry
|
|
32
|
+
*
|
|
33
|
+
* // app/api/kgauto/v2/[segment]/route.ts
|
|
34
|
+
* import { createBrainForwardRoutes } from '@warmdrift/kgauto-compiler/brain-proxy';
|
|
35
|
+
* const routes = createBrainForwardRoutes({
|
|
36
|
+
* ingestSecret: process.env.KGAUTO_INGEST_SECRET!,
|
|
37
|
+
* brainUrl: process.env.KGAUTO_BRAIN_URL!, // https://xxxx.supabase.co
|
|
38
|
+
* serviceKey: process.env.KGAUTO_BRAIN_SERVICE_KEY!,
|
|
39
|
+
* });
|
|
40
|
+
* export const POST = (req: Request, { params }: { params: { segment: string } }) =>
|
|
41
|
+
* routes.handle(req, params.segment);
|
|
42
|
+
*
|
|
43
|
+
* // middleware.ts — ONE public-path entry covers ALL four segments.
|
|
44
|
+
* // This is the structural fix for the tt-intel drift: you cannot mount
|
|
45
|
+
* // 3-of-4 routes and forget the 4th, because the catch-all is one file
|
|
46
|
+
* // and the allowlist is one prefix.
|
|
47
|
+
* const PUBLIC_PATHS = [ ... '/api/kgauto/v2/' ];
|
|
48
|
+
*
|
|
49
|
+
* ### (b) Plain Vercel edge function, per segment
|
|
50
|
+
*
|
|
51
|
+
* // api/kgauto/probe_outcomes.ts
|
|
52
|
+
* export const config = { runtime: 'edge' };
|
|
53
|
+
* const routes = createBrainForwardRoutes({ ... });
|
|
54
|
+
* export default (req: Request) => routes.handle(req, 'probe_outcomes');
|
|
55
|
+
*
|
|
56
|
+
* The library appends the segment path to the consumer's `endpoint`, so the
|
|
57
|
+
* consumer's `KGAUTO_V2_BRAIN_URL` (the value passed to `configureBrain`)
|
|
58
|
+
* must be the base that resolves to `.../api/kgauto/v2` — i.e. the last path
|
|
59
|
+
* segment of each library POST (`outcomes`, `probe_outcomes`, …) is what
|
|
60
|
+
* `handle()` receives as `segment`.
|
|
61
|
+
*/
|
|
62
|
+
interface BrainForwardConfig {
|
|
63
|
+
/** Bearer token consumers' callers must present (usually KGAUTO_INGEST_SECRET). */
|
|
64
|
+
ingestSecret: string;
|
|
65
|
+
/** Brain Supabase project URL (e.g. https://xxxx.supabase.co). */
|
|
66
|
+
brainUrl: string;
|
|
67
|
+
/** Brain service-role key (server-side only). */
|
|
68
|
+
serviceKey: string;
|
|
69
|
+
/** Optional fetch impl for tests. */
|
|
70
|
+
fetchImpl?: typeof fetch;
|
|
71
|
+
}
|
|
72
|
+
interface BrainForwardRoutes {
|
|
73
|
+
/**
|
|
74
|
+
* Web-standard handler. `segment` is the last path segment of the library's
|
|
75
|
+
* POST URL (e.g. 'outcomes', 'probe_outcomes'). In a Next.js catch-all this
|
|
76
|
+
* is `params.segment`. Never throws — every error path returns a `Response`.
|
|
77
|
+
*/
|
|
78
|
+
handle(req: Request, segment: string): Promise<Response>;
|
|
79
|
+
/**
|
|
80
|
+
* The path segments this factory serves. Consumers can use it for route
|
|
81
|
+
* generation, allowlist construction, or tests.
|
|
82
|
+
*/
|
|
83
|
+
segments: readonly string[];
|
|
84
|
+
}
|
|
85
|
+
declare function createBrainForwardRoutes(config: BrainForwardConfig): BrainForwardRoutes;
|
|
86
|
+
|
|
87
|
+
export { type BrainForwardConfig, type BrainForwardRoutes, createBrainForwardRoutes };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/brain-proxy.ts
|
|
21
|
+
var brain_proxy_exports = {};
|
|
22
|
+
__export(brain_proxy_exports, {
|
|
23
|
+
createBrainForwardRoutes: () => createBrainForwardRoutes
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(brain_proxy_exports);
|
|
26
|
+
var SEGMENT_TO_TABLE = {
|
|
27
|
+
outcomes: "compile_outcomes",
|
|
28
|
+
compile_outcome_advisories: "compile_outcome_advisories",
|
|
29
|
+
compile_outcome_quality: "compile_outcome_quality",
|
|
30
|
+
probe_outcomes: "probe_outcomes"
|
|
31
|
+
};
|
|
32
|
+
var KNOWN_SEGMENTS = Object.keys(SEGMENT_TO_TABLE);
|
|
33
|
+
var JSON_HEADERS = { "Content-Type": "application/json" };
|
|
34
|
+
function jsonResponse(status, body) {
|
|
35
|
+
return new Response(JSON.stringify(body), { status, headers: JSON_HEADERS });
|
|
36
|
+
}
|
|
37
|
+
function bearerOf(req) {
|
|
38
|
+
const header = req.headers.get("Authorization") ?? "";
|
|
39
|
+
const match = /^Bearer\s+(.+)$/i.exec(header);
|
|
40
|
+
return match?.[1]?.trim() ?? "";
|
|
41
|
+
}
|
|
42
|
+
function requireString(name, value) {
|
|
43
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
44
|
+
throw new Error(`createBrainForwardRoutes: ${name} is required`);
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
function createBrainForwardRoutes(config) {
|
|
49
|
+
const ingestSecret = requireString("ingestSecret", config.ingestSecret);
|
|
50
|
+
const brainUrl = requireString("brainUrl", config.brainUrl).replace(/\/+$/, "");
|
|
51
|
+
const serviceKey = requireString("serviceKey", config.serviceKey);
|
|
52
|
+
const fetchFn = config.fetchImpl ?? fetch;
|
|
53
|
+
async function handle(req, segment) {
|
|
54
|
+
try {
|
|
55
|
+
if (req.method !== "POST") {
|
|
56
|
+
return jsonResponse(405, {
|
|
57
|
+
error: "method-not-allowed",
|
|
58
|
+
method: req.method,
|
|
59
|
+
allowed: ["POST"]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
const table = SEGMENT_TO_TABLE[segment];
|
|
63
|
+
if (!table) {
|
|
64
|
+
return jsonResponse(404, {
|
|
65
|
+
error: "unknown-brain-forward-segment",
|
|
66
|
+
segment,
|
|
67
|
+
known: KNOWN_SEGMENTS
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
if (bearerOf(req) !== ingestSecret) {
|
|
71
|
+
return jsonResponse(401, { error: "unauthorized" });
|
|
72
|
+
}
|
|
73
|
+
let body;
|
|
74
|
+
try {
|
|
75
|
+
body = await req.json();
|
|
76
|
+
} catch {
|
|
77
|
+
return jsonResponse(400, { error: "invalid-json" });
|
|
78
|
+
}
|
|
79
|
+
const row = Array.isArray(body) ? body : { ...body };
|
|
80
|
+
let brainRes;
|
|
81
|
+
try {
|
|
82
|
+
brainRes = await fetchFn(`${brainUrl}/rest/v1/${table}`, {
|
|
83
|
+
method: "POST",
|
|
84
|
+
headers: {
|
|
85
|
+
apikey: serviceKey,
|
|
86
|
+
Authorization: `Bearer ${serviceKey}`,
|
|
87
|
+
"Content-Type": "application/json",
|
|
88
|
+
Prefer: "return=minimal"
|
|
89
|
+
},
|
|
90
|
+
body: JSON.stringify(row)
|
|
91
|
+
});
|
|
92
|
+
} catch (err) {
|
|
93
|
+
return jsonResponse(502, {
|
|
94
|
+
error: "brain-unreachable",
|
|
95
|
+
table,
|
|
96
|
+
detail: err instanceof Error ? err.message : String(err)
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
if (brainRes.ok) {
|
|
100
|
+
return jsonResponse(201, { ok: true });
|
|
101
|
+
}
|
|
102
|
+
const text = await brainRes.text().catch(() => "<no body>");
|
|
103
|
+
return jsonResponse(brainRes.status, {
|
|
104
|
+
error: "brain-write-failed",
|
|
105
|
+
table,
|
|
106
|
+
status: brainRes.status,
|
|
107
|
+
detail: text
|
|
108
|
+
});
|
|
109
|
+
} catch (err) {
|
|
110
|
+
return jsonResponse(500, {
|
|
111
|
+
error: "brain-forward-internal-error",
|
|
112
|
+
detail: err instanceof Error ? err.message : String(err)
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return { handle, segments: KNOWN_SEGMENTS };
|
|
117
|
+
}
|
|
118
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
119
|
+
0 && (module.exports = {
|
|
120
|
+
createBrainForwardRoutes
|
|
121
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// src/brain-proxy.ts
|
|
2
|
+
var SEGMENT_TO_TABLE = {
|
|
3
|
+
outcomes: "compile_outcomes",
|
|
4
|
+
compile_outcome_advisories: "compile_outcome_advisories",
|
|
5
|
+
compile_outcome_quality: "compile_outcome_quality",
|
|
6
|
+
probe_outcomes: "probe_outcomes"
|
|
7
|
+
};
|
|
8
|
+
var KNOWN_SEGMENTS = Object.keys(SEGMENT_TO_TABLE);
|
|
9
|
+
var JSON_HEADERS = { "Content-Type": "application/json" };
|
|
10
|
+
function jsonResponse(status, body) {
|
|
11
|
+
return new Response(JSON.stringify(body), { status, headers: JSON_HEADERS });
|
|
12
|
+
}
|
|
13
|
+
function bearerOf(req) {
|
|
14
|
+
const header = req.headers.get("Authorization") ?? "";
|
|
15
|
+
const match = /^Bearer\s+(.+)$/i.exec(header);
|
|
16
|
+
return match?.[1]?.trim() ?? "";
|
|
17
|
+
}
|
|
18
|
+
function requireString(name, value) {
|
|
19
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
20
|
+
throw new Error(`createBrainForwardRoutes: ${name} is required`);
|
|
21
|
+
}
|
|
22
|
+
return value;
|
|
23
|
+
}
|
|
24
|
+
function createBrainForwardRoutes(config) {
|
|
25
|
+
const ingestSecret = requireString("ingestSecret", config.ingestSecret);
|
|
26
|
+
const brainUrl = requireString("brainUrl", config.brainUrl).replace(/\/+$/, "");
|
|
27
|
+
const serviceKey = requireString("serviceKey", config.serviceKey);
|
|
28
|
+
const fetchFn = config.fetchImpl ?? fetch;
|
|
29
|
+
async function handle(req, segment) {
|
|
30
|
+
try {
|
|
31
|
+
if (req.method !== "POST") {
|
|
32
|
+
return jsonResponse(405, {
|
|
33
|
+
error: "method-not-allowed",
|
|
34
|
+
method: req.method,
|
|
35
|
+
allowed: ["POST"]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
const table = SEGMENT_TO_TABLE[segment];
|
|
39
|
+
if (!table) {
|
|
40
|
+
return jsonResponse(404, {
|
|
41
|
+
error: "unknown-brain-forward-segment",
|
|
42
|
+
segment,
|
|
43
|
+
known: KNOWN_SEGMENTS
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (bearerOf(req) !== ingestSecret) {
|
|
47
|
+
return jsonResponse(401, { error: "unauthorized" });
|
|
48
|
+
}
|
|
49
|
+
let body;
|
|
50
|
+
try {
|
|
51
|
+
body = await req.json();
|
|
52
|
+
} catch {
|
|
53
|
+
return jsonResponse(400, { error: "invalid-json" });
|
|
54
|
+
}
|
|
55
|
+
const row = Array.isArray(body) ? body : { ...body };
|
|
56
|
+
let brainRes;
|
|
57
|
+
try {
|
|
58
|
+
brainRes = await fetchFn(`${brainUrl}/rest/v1/${table}`, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: {
|
|
61
|
+
apikey: serviceKey,
|
|
62
|
+
Authorization: `Bearer ${serviceKey}`,
|
|
63
|
+
"Content-Type": "application/json",
|
|
64
|
+
Prefer: "return=minimal"
|
|
65
|
+
},
|
|
66
|
+
body: JSON.stringify(row)
|
|
67
|
+
});
|
|
68
|
+
} catch (err) {
|
|
69
|
+
return jsonResponse(502, {
|
|
70
|
+
error: "brain-unreachable",
|
|
71
|
+
table,
|
|
72
|
+
detail: err instanceof Error ? err.message : String(err)
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (brainRes.ok) {
|
|
76
|
+
return jsonResponse(201, { ok: true });
|
|
77
|
+
}
|
|
78
|
+
const text = await brainRes.text().catch(() => "<no body>");
|
|
79
|
+
return jsonResponse(brainRes.status, {
|
|
80
|
+
error: "brain-write-failed",
|
|
81
|
+
table,
|
|
82
|
+
status: brainRes.status,
|
|
83
|
+
detail: text
|
|
84
|
+
});
|
|
85
|
+
} catch (err) {
|
|
86
|
+
return jsonResponse(500, {
|
|
87
|
+
error: "brain-forward-internal-error",
|
|
88
|
+
detail: err instanceof Error ? err.message : String(err)
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return { handle, segments: KNOWN_SEGMENTS };
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
createBrainForwardRoutes
|
|
97
|
+
};
|
|
@@ -1356,6 +1356,63 @@ var PROFILES_RAW = [
|
|
|
1356
1356
|
critique: 5
|
|
1357
1357
|
// +1 vs 2.5-flash — but still below Sonnet/Opus reasoning floor
|
|
1358
1358
|
}
|
|
1359
|
+
},
|
|
1360
|
+
{
|
|
1361
|
+
// Auto-onboarded 2026-07-01 from `claude-sonnet-4-6`; VERIFIED 2026-07-02
|
|
1362
|
+
// against the claude-api reference (cc-portfolio ratification pass). The
|
|
1363
|
+
// clone got context right (1M) and pricing right at sticker ($3/$15 —
|
|
1364
|
+
// NOTE an introductory $2/$10 per MTok runs through 2026-08-31; sticker
|
|
1365
|
+
// encoded here per the time-bounded-pricing convention, intro belongs in
|
|
1366
|
+
// brain kgauto_pricing if worth capturing). The clone got max output WRONG:
|
|
1367
|
+
// Sonnet 5 is 128k, not 4-6's 64k — corrected. New tokenizer (~30% more
|
|
1368
|
+
// tokens for the same text vs 4-6): byte-budget consumers should re-baseline.
|
|
1369
|
+
// API quirks (claude-api ref): (a) NON-DEFAULT temperature/top_p/top_k
|
|
1370
|
+
// return 400 — moot for kgauto's own call() path (ANTHROPIC_LOWERING_BASE
|
|
1371
|
+
// emits no sampling params) but a REAL hazard for compileForAISDKv6
|
|
1372
|
+
// consumers that pass temperature themselves (tt-intel scoring uses temp:0
|
|
1373
|
+
// for determinism — that 400s on this model; noted to consumers via the
|
|
1374
|
+
// contract). (b) Omitting `thinking` runs ADAPTIVE by default (4-6 ran
|
|
1375
|
+
// thinking-off) — output spend shifts. (c) Supports effort xhigh. status:
|
|
1376
|
+
// 'preview' per the Fable precedent — no brain evidence yet; promotion to
|
|
1377
|
+
// 'current' is an explicit call. (L-049/L-081.)
|
|
1378
|
+
id: "claude-sonnet-5",
|
|
1379
|
+
verifiedAgainstDocs: "2026-07-02",
|
|
1380
|
+
provider: "anthropic",
|
|
1381
|
+
status: "preview",
|
|
1382
|
+
maxContextTokens: 1e6,
|
|
1383
|
+
maxOutputTokens: 128e3,
|
|
1384
|
+
maxTools: 64,
|
|
1385
|
+
parallelToolCalls: true,
|
|
1386
|
+
structuredOutput: "grammar",
|
|
1387
|
+
systemPromptMode: "inline",
|
|
1388
|
+
streaming: true,
|
|
1389
|
+
cliffs: [],
|
|
1390
|
+
costInputPer1m: 3,
|
|
1391
|
+
costOutputPer1m: 15,
|
|
1392
|
+
lowering: ANTHROPIC_LOWERING_BASE,
|
|
1393
|
+
recovery: [
|
|
1394
|
+
{ signal: "rate_limit", action: "escalate", reason: "429 \u2014 escalate" },
|
|
1395
|
+
{ signal: "model_not_found", action: "escalate", reason: "Deprecated \u2014 escalate (L-061)" }
|
|
1396
|
+
],
|
|
1397
|
+
strengths: ["quality", "tool_use", "long_context", "cache_friendly", "extended_thinking"],
|
|
1398
|
+
weaknesses: [],
|
|
1399
|
+
notes: "Sonnet 5 (2026-06): near-Opus quality on coding/agentic work at Sonnet cost. Verified 2026-07-02 against the claude-api reference: 1M ctx, 128k out (clone's 64k corrected), $3/$15 sticker (intro $2/$10 through 2026-08-31). New tokenizer ~30% more tokens vs sonnet-4-6. Consumer hazards: non-default temperature/top_p/top_k 400 (temp:0 rejected \u2014 deterministic-scoring consumers must omit); thinking defaults to adaptive when omitted. status:preview \u2014 no brain evidence yet; earns placement via the machinery.",
|
|
1400
|
+
// Master plan §6.2 anchor. Tier 0 for plan/generate/ask/extract/transform
|
|
1401
|
+
// in starter chains; tier 1 cross-provider for hunt/summarize/classify.
|
|
1402
|
+
archetypePerf: {
|
|
1403
|
+
ask: 9,
|
|
1404
|
+
generate: 9,
|
|
1405
|
+
plan: 9,
|
|
1406
|
+
critique: 9,
|
|
1407
|
+
extract: 9,
|
|
1408
|
+
transform: 9,
|
|
1409
|
+
hunt: 7,
|
|
1410
|
+
// strong but Flash beats on parallel tool throughput
|
|
1411
|
+
summarize: 8,
|
|
1412
|
+
// overkill for tolerant archetype
|
|
1413
|
+
classify: 8
|
|
1414
|
+
// overkill
|
|
1415
|
+
}
|
|
1359
1416
|
}
|
|
1360
1417
|
];
|
|
1361
1418
|
var ALIASES = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
export { A as AdvisoryFiredData, C as CompileDoneData, a as CompileStartData, E as ExecuteAttemptData, b as ExecuteSuccessData, F as FallbackWalkedData, c as GLASSBOX_STREAM_TTL_MS, d as GlassboxEventKind, e as GlassboxPubSub } from '../types-
|
|
3
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-C_dkNMA_.mjs';
|
|
2
|
+
export { A as AdvisoryFiredData, C as CompileDoneData, a as CompileStartData, E as ExecuteAttemptData, b as ExecuteSuccessData, F as FallbackWalkedData, c as GLASSBOX_STREAM_TTL_MS, d as GlassboxEventKind, e as GlassboxPubSub } from '../types-C_dkNMA_.mjs';
|
|
3
|
+
import '../ir-CAlLBu5d.mjs';
|
|
4
4
|
import '../dialect.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
package/dist/glassbox/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
export { A as AdvisoryFiredData, C as CompileDoneData, a as CompileStartData, E as ExecuteAttemptData, b as ExecuteSuccessData, F as FallbackWalkedData, c as GLASSBOX_STREAM_TTL_MS, d as GlassboxEventKind, e as GlassboxPubSub } from '../types-
|
|
3
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-hEDGehpz.js';
|
|
2
|
+
export { A as AdvisoryFiredData, C as CompileDoneData, a as CompileStartData, E as ExecuteAttemptData, b as ExecuteSuccessData, F as FallbackWalkedData, c as GLASSBOX_STREAM_TTL_MS, d as GlassboxEventKind, e as GlassboxPubSub } from '../types-hEDGehpz.js';
|
|
3
|
+
import '../ir-BiXAMyji.js';
|
|
4
4
|
import '../dialect.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-
|
|
3
|
-
export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-
|
|
4
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-C_dkNMA_.mjs';
|
|
2
|
+
import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-Dj5FLhBV.mjs';
|
|
3
|
+
export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-Dj5FLhBV.mjs';
|
|
4
|
+
import '../ir-CAlLBu5d.mjs';
|
|
5
5
|
import '../dialect.mjs';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { G as GlassboxEvent } from '../types-
|
|
2
|
-
import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-
|
|
3
|
-
export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-
|
|
4
|
-
import '../ir-
|
|
1
|
+
import { G as GlassboxEvent } from '../types-hEDGehpz.js';
|
|
2
|
+
import { a as TraceDetail, b as TraceSummary, c as TraceCounterfactual } from '../types-DsA8JFOp.js';
|
|
3
|
+
export { A as AdvisoryRecord, T as TraceHealth, d as TraceSectionRewrite } from '../types-DsA8JFOp.js';
|
|
4
|
+
import '../ir-BiXAMyji.js';
|
|
5
5
|
import '../dialect.js';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -1410,6 +1410,63 @@ var PROFILES_RAW = [
|
|
|
1410
1410
|
critique: 5
|
|
1411
1411
|
// +1 vs 2.5-flash — but still below Sonnet/Opus reasoning floor
|
|
1412
1412
|
}
|
|
1413
|
+
},
|
|
1414
|
+
{
|
|
1415
|
+
// Auto-onboarded 2026-07-01 from `claude-sonnet-4-6`; VERIFIED 2026-07-02
|
|
1416
|
+
// against the claude-api reference (cc-portfolio ratification pass). The
|
|
1417
|
+
// clone got context right (1M) and pricing right at sticker ($3/$15 —
|
|
1418
|
+
// NOTE an introductory $2/$10 per MTok runs through 2026-08-31; sticker
|
|
1419
|
+
// encoded here per the time-bounded-pricing convention, intro belongs in
|
|
1420
|
+
// brain kgauto_pricing if worth capturing). The clone got max output WRONG:
|
|
1421
|
+
// Sonnet 5 is 128k, not 4-6's 64k — corrected. New tokenizer (~30% more
|
|
1422
|
+
// tokens for the same text vs 4-6): byte-budget consumers should re-baseline.
|
|
1423
|
+
// API quirks (claude-api ref): (a) NON-DEFAULT temperature/top_p/top_k
|
|
1424
|
+
// return 400 — moot for kgauto's own call() path (ANTHROPIC_LOWERING_BASE
|
|
1425
|
+
// emits no sampling params) but a REAL hazard for compileForAISDKv6
|
|
1426
|
+
// consumers that pass temperature themselves (tt-intel scoring uses temp:0
|
|
1427
|
+
// for determinism — that 400s on this model; noted to consumers via the
|
|
1428
|
+
// contract). (b) Omitting `thinking` runs ADAPTIVE by default (4-6 ran
|
|
1429
|
+
// thinking-off) — output spend shifts. (c) Supports effort xhigh. status:
|
|
1430
|
+
// 'preview' per the Fable precedent — no brain evidence yet; promotion to
|
|
1431
|
+
// 'current' is an explicit call. (L-049/L-081.)
|
|
1432
|
+
id: "claude-sonnet-5",
|
|
1433
|
+
verifiedAgainstDocs: "2026-07-02",
|
|
1434
|
+
provider: "anthropic",
|
|
1435
|
+
status: "preview",
|
|
1436
|
+
maxContextTokens: 1e6,
|
|
1437
|
+
maxOutputTokens: 128e3,
|
|
1438
|
+
maxTools: 64,
|
|
1439
|
+
parallelToolCalls: true,
|
|
1440
|
+
structuredOutput: "grammar",
|
|
1441
|
+
systemPromptMode: "inline",
|
|
1442
|
+
streaming: true,
|
|
1443
|
+
cliffs: [],
|
|
1444
|
+
costInputPer1m: 3,
|
|
1445
|
+
costOutputPer1m: 15,
|
|
1446
|
+
lowering: ANTHROPIC_LOWERING_BASE,
|
|
1447
|
+
recovery: [
|
|
1448
|
+
{ signal: "rate_limit", action: "escalate", reason: "429 \u2014 escalate" },
|
|
1449
|
+
{ signal: "model_not_found", action: "escalate", reason: "Deprecated \u2014 escalate (L-061)" }
|
|
1450
|
+
],
|
|
1451
|
+
strengths: ["quality", "tool_use", "long_context", "cache_friendly", "extended_thinking"],
|
|
1452
|
+
weaknesses: [],
|
|
1453
|
+
notes: "Sonnet 5 (2026-06): near-Opus quality on coding/agentic work at Sonnet cost. Verified 2026-07-02 against the claude-api reference: 1M ctx, 128k out (clone's 64k corrected), $3/$15 sticker (intro $2/$10 through 2026-08-31). New tokenizer ~30% more tokens vs sonnet-4-6. Consumer hazards: non-default temperature/top_p/top_k 400 (temp:0 rejected \u2014 deterministic-scoring consumers must omit); thinking defaults to adaptive when omitted. status:preview \u2014 no brain evidence yet; earns placement via the machinery.",
|
|
1454
|
+
// Master plan §6.2 anchor. Tier 0 for plan/generate/ask/extract/transform
|
|
1455
|
+
// in starter chains; tier 1 cross-provider for hunt/summarize/classify.
|
|
1456
|
+
archetypePerf: {
|
|
1457
|
+
ask: 9,
|
|
1458
|
+
generate: 9,
|
|
1459
|
+
plan: 9,
|
|
1460
|
+
critique: 9,
|
|
1461
|
+
extract: 9,
|
|
1462
|
+
transform: 9,
|
|
1463
|
+
hunt: 7,
|
|
1464
|
+
// strong but Flash beats on parallel tool throughput
|
|
1465
|
+
summarize: 8,
|
|
1466
|
+
// overkill for tolerant archetype
|
|
1467
|
+
classify: 8
|
|
1468
|
+
// overkill
|
|
1469
|
+
}
|
|
1413
1470
|
}
|
|
1414
1471
|
];
|
|
1415
1472
|
var ALIASES = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ARCHETYPE_FLOOR_DEFAULT,
|
|
3
3
|
getDefaultFallbackChain
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-IIMPJZNH.mjs";
|
|
5
5
|
import {
|
|
6
6
|
tryGetProfile
|
|
7
|
-
} from "../chunk-
|
|
7
|
+
} from "../chunk-QKXTMVCT.mjs";
|
|
8
8
|
import {
|
|
9
9
|
subscribe,
|
|
10
10
|
subscribeApp
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { a as TraceDetail } from '../../types-
|
|
3
|
-
import '../../ir-
|
|
2
|
+
import { a as TraceDetail } from '../../types-Dj5FLhBV.mjs';
|
|
3
|
+
import '../../ir-CAlLBu5d.mjs';
|
|
4
4
|
import '../../dialect.mjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { a as TraceDetail } from '../../types-
|
|
3
|
-
import '../../ir-
|
|
2
|
+
import { a as TraceDetail } from '../../types-DsA8JFOp.js';
|
|
3
|
+
import '../../ir-BiXAMyji.js';
|
|
4
4
|
import '../../dialect.js';
|
|
5
5
|
|
|
6
6
|
/**
|