@warmdrift/kgauto-compiler 2.0.0-alpha.58 → 2.0.0-alpha.59
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.d.mts +22 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +15 -6
- package/dist/index.mjs +15 -6
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -415,6 +415,28 @@ interface BrainConfig {
|
|
|
415
415
|
* arms the tracking, so good actors never see a false warning.
|
|
416
416
|
*/
|
|
417
417
|
warnOnDiscardedCompile?: boolean;
|
|
418
|
+
/**
|
|
419
|
+
* alpha.59 — per-leg timeout (ms) applied to every brain WRITE POST
|
|
420
|
+
* (record() primary + advisory secondary, recordOutcome(),
|
|
421
|
+
* recordShadowProbe()) via `AbortSignal.timeout`. Default 10000.
|
|
422
|
+
*
|
|
423
|
+
* Why: `sync: true` puts these fetches on the USER path (Edge consumers
|
|
424
|
+
* await record() before responding), and alpha.56's representation
|
|
425
|
+
* passthrough added a second sequential POST (advisory secondary) to that
|
|
426
|
+
* same path — an unbounded hang on either leg holds the user to the Edge
|
|
427
|
+
* limit (GE's `brainconfig-first-class-timeout` filing; GE bounded it at
|
|
428
|
+
* 3s via a hand-rolled fetchImpl wrapper every sync consumer had to
|
|
429
|
+
* rediscover).
|
|
430
|
+
*
|
|
431
|
+
* A fired timeout follows each leg's existing degraded-brain path
|
|
432
|
+
* (fire-and-forget: swallowed via onError; sync: `persistence_failed`
|
|
433
|
+
* result — never a throw into the user path). Wraps the configured
|
|
434
|
+
* `fetchImpl` rather than replacing it, so it composes with
|
|
435
|
+
* consumer-supplied impls. Set `0` to disable (pre-alpha.59 unbounded
|
|
436
|
+
* behavior). Brain-query reads (config tables) are cached + SWR and are
|
|
437
|
+
* not affected.
|
|
438
|
+
*/
|
|
439
|
+
timeoutMs?: number;
|
|
418
440
|
}
|
|
419
441
|
declare function configureBrain(config: BrainConfig): void;
|
|
420
442
|
declare function clearBrain(): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -415,6 +415,28 @@ interface BrainConfig {
|
|
|
415
415
|
* arms the tracking, so good actors never see a false warning.
|
|
416
416
|
*/
|
|
417
417
|
warnOnDiscardedCompile?: boolean;
|
|
418
|
+
/**
|
|
419
|
+
* alpha.59 — per-leg timeout (ms) applied to every brain WRITE POST
|
|
420
|
+
* (record() primary + advisory secondary, recordOutcome(),
|
|
421
|
+
* recordShadowProbe()) via `AbortSignal.timeout`. Default 10000.
|
|
422
|
+
*
|
|
423
|
+
* Why: `sync: true` puts these fetches on the USER path (Edge consumers
|
|
424
|
+
* await record() before responding), and alpha.56's representation
|
|
425
|
+
* passthrough added a second sequential POST (advisory secondary) to that
|
|
426
|
+
* same path — an unbounded hang on either leg holds the user to the Edge
|
|
427
|
+
* limit (GE's `brainconfig-first-class-timeout` filing; GE bounded it at
|
|
428
|
+
* 3s via a hand-rolled fetchImpl wrapper every sync consumer had to
|
|
429
|
+
* rediscover).
|
|
430
|
+
*
|
|
431
|
+
* A fired timeout follows each leg's existing degraded-brain path
|
|
432
|
+
* (fire-and-forget: swallowed via onError; sync: `persistence_failed`
|
|
433
|
+
* result — never a throw into the user path). Wraps the configured
|
|
434
|
+
* `fetchImpl` rather than replacing it, so it composes with
|
|
435
|
+
* consumer-supplied impls. Set `0` to disable (pre-alpha.59 unbounded
|
|
436
|
+
* behavior). Brain-query reads (config tables) are cached + SWR and are
|
|
437
|
+
* not affected.
|
|
438
|
+
*/
|
|
439
|
+
timeoutMs?: number;
|
|
418
440
|
}
|
|
419
441
|
declare function configureBrain(config: BrainConfig): void;
|
|
420
442
|
declare function clearBrain(): void;
|
package/dist/index.js
CHANGED
|
@@ -4417,6 +4417,15 @@ function resolvePricingAt(modelId, at = /* @__PURE__ */ new Date()) {
|
|
|
4417
4417
|
}
|
|
4418
4418
|
|
|
4419
4419
|
// src/brain.ts
|
|
4420
|
+
var DEFAULT_BRAIN_WRITE_TIMEOUT_MS = 1e4;
|
|
4421
|
+
function brainWriteFetch(config) {
|
|
4422
|
+
const base = config.fetchImpl ?? fetch;
|
|
4423
|
+
const timeoutMs = config.timeoutMs ?? DEFAULT_BRAIN_WRITE_TIMEOUT_MS;
|
|
4424
|
+
if (timeoutMs <= 0 || typeof AbortSignal === "undefined" || typeof AbortSignal.timeout !== "function") {
|
|
4425
|
+
return base;
|
|
4426
|
+
}
|
|
4427
|
+
return (input, init) => base(input, { ...init, signal: AbortSignal.timeout(timeoutMs) });
|
|
4428
|
+
}
|
|
4420
4429
|
var activeConfig;
|
|
4421
4430
|
function configureBrain(config) {
|
|
4422
4431
|
const endpoint = config.endpoint.replace(/\/outcomes\/?$/, "");
|
|
@@ -4562,7 +4571,7 @@ async function record(input) {
|
|
|
4562
4571
|
}
|
|
4563
4572
|
const payload = buildPayload(input, reg);
|
|
4564
4573
|
const config = activeConfig;
|
|
4565
|
-
const fetchFn = config
|
|
4574
|
+
const fetchFn = brainWriteFetch(config);
|
|
4566
4575
|
const send = async () => {
|
|
4567
4576
|
let outcomeId;
|
|
4568
4577
|
try {
|
|
@@ -4731,9 +4740,9 @@ function buildAdvisoryRow(outcomeId, a) {
|
|
|
4731
4740
|
code: a.code,
|
|
4732
4741
|
level: a.level,
|
|
4733
4742
|
message: a.message,
|
|
4734
|
-
|
|
4735
|
-
|
|
4736
|
-
|
|
4743
|
+
recommendation_type: a.recommendationType ?? null,
|
|
4744
|
+
suggestion: a.suggestion ?? null,
|
|
4745
|
+
docs_url: a.docsUrl ?? null
|
|
4737
4746
|
};
|
|
4738
4747
|
}
|
|
4739
4748
|
async function recordOutcome(input) {
|
|
@@ -4741,7 +4750,7 @@ async function recordOutcome(input) {
|
|
|
4741
4750
|
return { ok: false, reason: "brain_not_configured" };
|
|
4742
4751
|
}
|
|
4743
4752
|
const config = activeConfig;
|
|
4744
|
-
const fetchFn = config
|
|
4753
|
+
const fetchFn = brainWriteFetch(config);
|
|
4745
4754
|
const payload = {
|
|
4746
4755
|
outcome_id: input.outcomeId,
|
|
4747
4756
|
outcome: input.outcome,
|
|
@@ -4816,7 +4825,7 @@ function buildShadowProbeRow(input) {
|
|
|
4816
4825
|
async function recordShadowProbe(input) {
|
|
4817
4826
|
if (!activeConfig) return;
|
|
4818
4827
|
const config = activeConfig;
|
|
4819
|
-
const fetchFn = config
|
|
4828
|
+
const fetchFn = brainWriteFetch(config);
|
|
4820
4829
|
const row = buildShadowProbeRow(input);
|
|
4821
4830
|
const send = async () => {
|
|
4822
4831
|
try {
|
package/dist/index.mjs
CHANGED
|
@@ -2575,6 +2575,15 @@ function resolvePricingAt(modelId, at = /* @__PURE__ */ new Date()) {
|
|
|
2575
2575
|
}
|
|
2576
2576
|
|
|
2577
2577
|
// src/brain.ts
|
|
2578
|
+
var DEFAULT_BRAIN_WRITE_TIMEOUT_MS = 1e4;
|
|
2579
|
+
function brainWriteFetch(config) {
|
|
2580
|
+
const base = config.fetchImpl ?? fetch;
|
|
2581
|
+
const timeoutMs = config.timeoutMs ?? DEFAULT_BRAIN_WRITE_TIMEOUT_MS;
|
|
2582
|
+
if (timeoutMs <= 0 || typeof AbortSignal === "undefined" || typeof AbortSignal.timeout !== "function") {
|
|
2583
|
+
return base;
|
|
2584
|
+
}
|
|
2585
|
+
return (input, init) => base(input, { ...init, signal: AbortSignal.timeout(timeoutMs) });
|
|
2586
|
+
}
|
|
2578
2587
|
var activeConfig;
|
|
2579
2588
|
function configureBrain(config) {
|
|
2580
2589
|
const endpoint = config.endpoint.replace(/\/outcomes\/?$/, "");
|
|
@@ -2720,7 +2729,7 @@ async function record(input) {
|
|
|
2720
2729
|
}
|
|
2721
2730
|
const payload = buildPayload(input, reg);
|
|
2722
2731
|
const config = activeConfig;
|
|
2723
|
-
const fetchFn = config
|
|
2732
|
+
const fetchFn = brainWriteFetch(config);
|
|
2724
2733
|
const send = async () => {
|
|
2725
2734
|
let outcomeId;
|
|
2726
2735
|
try {
|
|
@@ -2889,9 +2898,9 @@ function buildAdvisoryRow(outcomeId, a) {
|
|
|
2889
2898
|
code: a.code,
|
|
2890
2899
|
level: a.level,
|
|
2891
2900
|
message: a.message,
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2901
|
+
recommendation_type: a.recommendationType ?? null,
|
|
2902
|
+
suggestion: a.suggestion ?? null,
|
|
2903
|
+
docs_url: a.docsUrl ?? null
|
|
2895
2904
|
};
|
|
2896
2905
|
}
|
|
2897
2906
|
async function recordOutcome(input) {
|
|
@@ -2899,7 +2908,7 @@ async function recordOutcome(input) {
|
|
|
2899
2908
|
return { ok: false, reason: "brain_not_configured" };
|
|
2900
2909
|
}
|
|
2901
2910
|
const config = activeConfig;
|
|
2902
|
-
const fetchFn = config
|
|
2911
|
+
const fetchFn = brainWriteFetch(config);
|
|
2903
2912
|
const payload = {
|
|
2904
2913
|
outcome_id: input.outcomeId,
|
|
2905
2914
|
outcome: input.outcome,
|
|
@@ -2974,7 +2983,7 @@ function buildShadowProbeRow(input) {
|
|
|
2974
2983
|
async function recordShadowProbe(input) {
|
|
2975
2984
|
if (!activeConfig) return;
|
|
2976
2985
|
const config = activeConfig;
|
|
2977
|
-
const fetchFn = config
|
|
2986
|
+
const fetchFn = brainWriteFetch(config);
|
|
2978
2987
|
const row = buildShadowProbeRow(input);
|
|
2979
2988
|
const send = async () => {
|
|
2980
2989
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@warmdrift/kgauto-compiler",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.59",
|
|
4
4
|
"description": "Prompt compiler + central learning brain for multi-model AI apps. Swap models without rewriting prompts.",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|