@nexus-cortex/core 4.124.45 → 4.124.46
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/.env.defaults +41 -0
- package/dist/adapters/GatewayTranslationLayer.d.ts.map +1 -1
- package/dist/adapters/GatewayTranslationLayer.js +23 -0
- package/dist/adapters/GatewayTranslationLayer.js.map +1 -1
- package/dist/config/effectiveConfig.d.ts.map +1 -1
- package/dist/config/effectiveConfig.js +4 -0
- package/dist/config/effectiveConfig.js.map +1 -1
- package/dist/orchestrator/APIClient.d.ts.map +1 -1
- package/dist/orchestrator/APIClient.js +54 -15
- package/dist/orchestrator/APIClient.js.map +1 -1
- package/dist/orchestrator/CortexOrchestrator.d.ts.map +1 -1
- package/dist/orchestrator/CortexOrchestrator.js +3 -2
- package/dist/orchestrator/CortexOrchestrator.js.map +1 -1
- package/dist/orchestrator/appendOnlyHistory.d.ts.map +1 -1
- package/dist/orchestrator/appendOnlyHistory.js +4 -0
- package/dist/orchestrator/appendOnlyHistory.js.map +1 -1
- package/dist/orchestrator/transportEffortFixes.d.ts +62 -0
- package/dist/orchestrator/transportEffortFixes.d.ts.map +1 -0
- package/dist/orchestrator/transportEffortFixes.js +114 -0
- package/dist/orchestrator/transportEffortFixes.js.map +1 -0
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appendOnlyHistory.d.ts","sourceRoot":"","sources":["../../src/orchestrator/appendOnlyHistory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAOH,wBAAgB,mBAAmB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAEjF;AAED,wBAAgB,sBAAsB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAEpF;AAED,wBAAgB,sBAAsB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,OAAO,CAEpF;AAED,wBAAgB,yBAAyB,CAA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@@ export function isPreviousResponseUnavailable(err) {
|
|
|
70
70
|
.filter((x) => typeof x === 'string').join(' ');
|
|
71
71
|
if (/previous[_ ]?response/i.test(text) && /not[_ ]?found|expired|invalid|does not exist|unavailable|no longer|not stored|unknown/i.test(text))
|
|
72
72
|
return true;
|
|
73
|
+
// xAI (live probe 2026-10-02): 404 {"code":"not-found","error":"Response with id=resp_… not found"}; APIClient throws it as plain text
|
|
74
|
+
// ("XAI Responses API error 404: …") with no status field, so match the body wording itself.
|
|
75
|
+
if (/response with id\s*=?\s*['"]?resp_\S*['"]? not[ _-]?found/i.test(text))
|
|
76
|
+
return true;
|
|
73
77
|
return status === 404 && /\bresponse\b/i.test(text);
|
|
74
78
|
}
|
|
75
79
|
//# sourceMappingURL=appendOnlyHistory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appendOnlyHistory.js","sourceRoot":"","sources":["../../src/orchestrator/appendOnlyHistory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,SAAS,KAAK,CAAC,CAAqB;IAClC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC/C,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,GAAG,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACtE,OAAO,KAAK,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;AAC1C,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACzE,OAAO,KAAK,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,sBAAsB,CAAC,MAAyB,OAAO,CAAC,GAAG;IACzE,OAAO,KAAK,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC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Y;IACxD,MAAM,CAAC,GAAG,GAAU,CAAC;IACrB,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,EAAE,MAAM,IAAI,CAAC,EAAE,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,IAAI,GAAG,CAAC,CAAC;IACpG,MAAM,IAAI,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC;SACrG,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClD,IAAI,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,wFAAwF,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5J,uIAAuI;IACvI,6FAA6F;IAC7F,IAAI,4DAA4D,CAAC,IAAI,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IACzF,OAAO,MAAM,KAAK,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport reasoning-effort fixes (2026-10-02; stack-portability map
|
|
3
|
+
* .cortex/research/stack-portability-2026-10-02.md, note N1). Each is DARK behind its own env flag; with the flag off
|
|
4
|
+
* every caller takes its pre-existing code path unchanged (byte-identical requests).
|
|
5
|
+
*
|
|
6
|
+
* - CORTEX_OPENAI_TOOLS_REASONING: the gateway forwards the request/action effort for OpenAI reasoning cards even though they
|
|
7
|
+
* do not declare `reasoning.toggleable`, so CORTEX_ACTION_EFFORT reaches `reasoning.effort` on the RESPONSES API. Chat/completions
|
|
8
|
+
* is unchanged: R19b's drop stays because OpenAI still rejects reasoning_effort + function tools there (live probe 2026-10-03:
|
|
9
|
+
* gpt-5.4-nano + gpt-5.6-luna → 400 "use /v1/responses"); Responses accepts it with tools (200 on both).
|
|
10
|
+
* - CORTEX_ANTHROPIC_EFFORT: Anthropic adaptive-thinking families (claude-4.7 / 4.8 / claude-5 / claude-fable-5) got
|
|
11
|
+
* `thinking:{type:'adaptive'}` only, so the action effort never reached the wire. On: `output_config.effort` = the
|
|
12
|
+
* effort (low|medium|high|xhigh|max; GA, no beta header). Non-adaptive families: `max` was not in the budget map and
|
|
13
|
+
* fell to 10000; on, `max` maps to a large budget clamped below max_tokens (budget_tokens must be < max_tokens, >= 1024).
|
|
14
|
+
* - CORTEX_GEMINI_TOOLS_THINKING: Gemini thinkingConfig was never sent with tools (the @google/genai builders skipped
|
|
15
|
+
* it — "cannot coexist", a Gemini 2.0-era observation) and the REST builder only ever sent a card-level thinkingLevel.
|
|
16
|
+
* On: the action effort maps to generationConfig.thinkingConfig — `thinkingLevel` on Gemini 3.x, `thinkingBudget` on
|
|
17
|
+
* 2.5 and older — on REST and SDK, with or without tools.
|
|
18
|
+
*
|
|
19
|
+
* Pure helpers — no client state. Flags are resolved per call so tests/benches can flip them.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isOpenAIToolsReasoningEnabled(): boolean;
|
|
22
|
+
export declare function isAnthropicEffortEnabled(): boolean;
|
|
23
|
+
export declare function isGeminiToolsThinkingEnabled(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* `output_config.effort` value for an adaptive-thinking family, or undefined (send nothing → provider default).
|
|
26
|
+
* 'none' / unknown values send nothing (adaptive families have no "off" effort).
|
|
27
|
+
*/
|
|
28
|
+
export declare function anthropicOutputEffort(reasoningEffort: string | undefined): string | undefined;
|
|
29
|
+
/** Target thinking budget for effort `max` on budget_tokens families (before the max_tokens clamp). */
|
|
30
|
+
export declare const ANTHROPIC_MAX_EFFORT_BUDGET = 120000;
|
|
31
|
+
/** Visible-output room kept below max_tokens when clamping the `max` budget. */
|
|
32
|
+
export declare const ANTHROPIC_MAX_EFFORT_OUTPUT_ROOM = 1024;
|
|
33
|
+
/**
|
|
34
|
+
* budget_tokens for effort `max` on a non-adaptive family: ANTHROPIC_MAX_EFFORT_BUDGET clamped to
|
|
35
|
+
* max_tokens - ANTHROPIC_MAX_EFFORT_OUTPUT_ROOM (the API requires budget_tokens < max_tokens and >= 1024).
|
|
36
|
+
* Returns undefined when max_tokens is too small to honour the floor — the caller keeps its legacy value.
|
|
37
|
+
*/
|
|
38
|
+
export declare function anthropicMaxEffortBudget(maxTokens: number | undefined): number | undefined;
|
|
39
|
+
/** Gemini 3.x takes `thinkingLevel`; 2.5 and older take `thinkingBudget` (sending both is a 400). */
|
|
40
|
+
export declare function isGeminiThinkingLevelModel(modelId: string): boolean;
|
|
41
|
+
/** thinkingBudget per effort for Gemini 2.5 (Flash range 0-24576; Pro 128-32768 — every value here is valid on both). */
|
|
42
|
+
export declare const GEMINI_BUDGET_BY_EFFORT: Record<string, number>;
|
|
43
|
+
/** thinkingLevel per effort for Gemini 3.x (levels low|medium|high; xhigh/max clamp to high). */
|
|
44
|
+
export declare const GEMINI_LEVEL_BY_EFFORT: Record<string, string>;
|
|
45
|
+
/**
|
|
46
|
+
* The generationConfig.thinkingConfig for an effort, or undefined (none / unknown effort → send nothing, API default).
|
|
47
|
+
*/
|
|
48
|
+
export declare function geminiThinkingConfigForEffort(modelId: string, reasoningEffort: string | undefined): {
|
|
49
|
+
thinkingLevel: string;
|
|
50
|
+
} | {
|
|
51
|
+
thinkingBudget: number;
|
|
52
|
+
} | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* CORTEX_ACTION_EFFORT is filled into the request params AFTER the first request of each user turn is built
|
|
55
|
+
* (CortexOrchestrator initialPrepOpts vs the `??=` in the loop setup), so request 0 ran at the card default and
|
|
56
|
+
* requests 1+ at the action effort. On DeepSeek that is harmless (card 'medium' is coerced to 'high' server-side and
|
|
57
|
+
* the anchor-lift bust lands on the same boundary); on other providers it sends a different effort on request 0 and
|
|
58
|
+
* costs one extra cache break per user turn. DARK: CORTEX_ACTION_EFFORT_FIRST=on → request 0 gets the action effort
|
|
59
|
+
* when no ramp / request param set one. Off → undefined (byte-identical).
|
|
60
|
+
*/
|
|
61
|
+
export declare function firstRequestActionEffort(env?: NodeJS.ProcessEnv): string | undefined;
|
|
62
|
+
//# sourceMappingURL=transportEffortFixes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transportEffortFixes.d.ts","sourceRoot":"","sources":["../../src/orchestrator/transportEffortFixes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAOH,wBAAgB,6BAA6B,IAAI,OAAO,CAEvD;AACD,wBAAgB,wBAAwB,IAAI,OAAO,CAElD;AACD,wBAAgB,4BAA4B,IAAI,OAAO,CAEtD;AAQD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAG7F;AAED,uGAAuG;AACvG,eAAO,MAAM,2BAA2B,SAAS,CAAC;AAClD,gFAAgF;AAChF,eAAO,MAAM,gCAAgC,OAAO,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAK1F;AAMD,qGAAqG;AACrG,wBAAgB,0BAA0B,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEnE;AAED,yHAAyH;AACzH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAM1D,CAAC;AAEF,iGAAiG;AACjG,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMzD,CAAC;AAEF;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,MAAM,EACf,eAAe,EAAE,MAAM,GAAG,SAAS,GAClC;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,cAAc,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAQpE;AAMD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,GAAG,SAAS,CAIjG"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport reasoning-effort fixes (2026-10-02; stack-portability map
|
|
3
|
+
* .cortex/research/stack-portability-2026-10-02.md, note N1). Each is DARK behind its own env flag; with the flag off
|
|
4
|
+
* every caller takes its pre-existing code path unchanged (byte-identical requests).
|
|
5
|
+
*
|
|
6
|
+
* - CORTEX_OPENAI_TOOLS_REASONING: the gateway forwards the request/action effort for OpenAI reasoning cards even though they
|
|
7
|
+
* do not declare `reasoning.toggleable`, so CORTEX_ACTION_EFFORT reaches `reasoning.effort` on the RESPONSES API. Chat/completions
|
|
8
|
+
* is unchanged: R19b's drop stays because OpenAI still rejects reasoning_effort + function tools there (live probe 2026-10-03:
|
|
9
|
+
* gpt-5.4-nano + gpt-5.6-luna → 400 "use /v1/responses"); Responses accepts it with tools (200 on both).
|
|
10
|
+
* - CORTEX_ANTHROPIC_EFFORT: Anthropic adaptive-thinking families (claude-4.7 / 4.8 / claude-5 / claude-fable-5) got
|
|
11
|
+
* `thinking:{type:'adaptive'}` only, so the action effort never reached the wire. On: `output_config.effort` = the
|
|
12
|
+
* effort (low|medium|high|xhigh|max; GA, no beta header). Non-adaptive families: `max` was not in the budget map and
|
|
13
|
+
* fell to 10000; on, `max` maps to a large budget clamped below max_tokens (budget_tokens must be < max_tokens, >= 1024).
|
|
14
|
+
* - CORTEX_GEMINI_TOOLS_THINKING: Gemini thinkingConfig was never sent with tools (the @google/genai builders skipped
|
|
15
|
+
* it — "cannot coexist", a Gemini 2.0-era observation) and the REST builder only ever sent a card-level thinkingLevel.
|
|
16
|
+
* On: the action effort maps to generationConfig.thinkingConfig — `thinkingLevel` on Gemini 3.x, `thinkingBudget` on
|
|
17
|
+
* 2.5 and older — on REST and SDK, with or without tools.
|
|
18
|
+
*
|
|
19
|
+
* Pure helpers — no client state. Flags are resolved per call so tests/benches can flip them.
|
|
20
|
+
*/
|
|
21
|
+
function flagOn(raw) {
|
|
22
|
+
const v = String(raw ?? '').trim().toLowerCase();
|
|
23
|
+
return v === 'on' || v === 'true' || v === '1';
|
|
24
|
+
}
|
|
25
|
+
export function isOpenAIToolsReasoningEnabled() {
|
|
26
|
+
return flagOn(process.env.CORTEX_OPENAI_TOOLS_REASONING);
|
|
27
|
+
}
|
|
28
|
+
export function isAnthropicEffortEnabled() {
|
|
29
|
+
return flagOn(process.env.CORTEX_ANTHROPIC_EFFORT);
|
|
30
|
+
}
|
|
31
|
+
export function isGeminiToolsThinkingEnabled() {
|
|
32
|
+
return flagOn(process.env.CORTEX_GEMINI_TOOLS_THINKING);
|
|
33
|
+
}
|
|
34
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
35
|
+
// Anthropic
|
|
36
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
37
|
+
const ANTHROPIC_EFFORT_LEVELS = new Set(['low', 'medium', 'high', 'xhigh', 'max']);
|
|
38
|
+
/**
|
|
39
|
+
* `output_config.effort` value for an adaptive-thinking family, or undefined (send nothing → provider default).
|
|
40
|
+
* 'none' / unknown values send nothing (adaptive families have no "off" effort).
|
|
41
|
+
*/
|
|
42
|
+
export function anthropicOutputEffort(reasoningEffort) {
|
|
43
|
+
const e = String(reasoningEffort ?? '').trim().toLowerCase();
|
|
44
|
+
return ANTHROPIC_EFFORT_LEVELS.has(e) ? e : undefined;
|
|
45
|
+
}
|
|
46
|
+
/** Target thinking budget for effort `max` on budget_tokens families (before the max_tokens clamp). */
|
|
47
|
+
export const ANTHROPIC_MAX_EFFORT_BUDGET = 120000;
|
|
48
|
+
/** Visible-output room kept below max_tokens when clamping the `max` budget. */
|
|
49
|
+
export const ANTHROPIC_MAX_EFFORT_OUTPUT_ROOM = 1024;
|
|
50
|
+
/**
|
|
51
|
+
* budget_tokens for effort `max` on a non-adaptive family: ANTHROPIC_MAX_EFFORT_BUDGET clamped to
|
|
52
|
+
* max_tokens - ANTHROPIC_MAX_EFFORT_OUTPUT_ROOM (the API requires budget_tokens < max_tokens and >= 1024).
|
|
53
|
+
* Returns undefined when max_tokens is too small to honour the floor — the caller keeps its legacy value.
|
|
54
|
+
*/
|
|
55
|
+
export function anthropicMaxEffortBudget(maxTokens) {
|
|
56
|
+
const mt = Number(maxTokens);
|
|
57
|
+
if (!Number.isFinite(mt) || mt <= 0)
|
|
58
|
+
return undefined;
|
|
59
|
+
const b = Math.min(ANTHROPIC_MAX_EFFORT_BUDGET, Math.floor(mt) - ANTHROPIC_MAX_EFFORT_OUTPUT_ROOM);
|
|
60
|
+
return b >= 1024 ? b : undefined;
|
|
61
|
+
}
|
|
62
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
63
|
+
// Gemini
|
|
64
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
65
|
+
/** Gemini 3.x takes `thinkingLevel`; 2.5 and older take `thinkingBudget` (sending both is a 400). */
|
|
66
|
+
export function isGeminiThinkingLevelModel(modelId) {
|
|
67
|
+
return /^(models\/)?gemini-([3-9]|\d{2,})/i.test(String(modelId ?? '').trim());
|
|
68
|
+
}
|
|
69
|
+
/** thinkingBudget per effort for Gemini 2.5 (Flash range 0-24576; Pro 128-32768 — every value here is valid on both). */
|
|
70
|
+
export const GEMINI_BUDGET_BY_EFFORT = {
|
|
71
|
+
low: 2048,
|
|
72
|
+
medium: 8192,
|
|
73
|
+
high: 16384,
|
|
74
|
+
xhigh: 24576,
|
|
75
|
+
max: 24576,
|
|
76
|
+
};
|
|
77
|
+
/** thinkingLevel per effort for Gemini 3.x (levels low|medium|high; xhigh/max clamp to high). */
|
|
78
|
+
export const GEMINI_LEVEL_BY_EFFORT = {
|
|
79
|
+
low: 'low',
|
|
80
|
+
medium: 'medium',
|
|
81
|
+
high: 'high',
|
|
82
|
+
xhigh: 'high',
|
|
83
|
+
max: 'high',
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* The generationConfig.thinkingConfig for an effort, or undefined (none / unknown effort → send nothing, API default).
|
|
87
|
+
*/
|
|
88
|
+
export function geminiThinkingConfigForEffort(modelId, reasoningEffort) {
|
|
89
|
+
const e = String(reasoningEffort ?? '').trim().toLowerCase();
|
|
90
|
+
if (isGeminiThinkingLevelModel(modelId)) {
|
|
91
|
+
const level = GEMINI_LEVEL_BY_EFFORT[e];
|
|
92
|
+
return level ? { thinkingLevel: level } : undefined;
|
|
93
|
+
}
|
|
94
|
+
const budget = GEMINI_BUDGET_BY_EFFORT[e];
|
|
95
|
+
return budget !== undefined ? { thinkingBudget: budget } : undefined;
|
|
96
|
+
}
|
|
97
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
98
|
+
// CORTEX_ACTION_EFFORT_FIRST — request 0 of each user turn
|
|
99
|
+
// ---------------------------------------------------------------------------------------------------------
|
|
100
|
+
/**
|
|
101
|
+
* CORTEX_ACTION_EFFORT is filled into the request params AFTER the first request of each user turn is built
|
|
102
|
+
* (CortexOrchestrator initialPrepOpts vs the `??=` in the loop setup), so request 0 ran at the card default and
|
|
103
|
+
* requests 1+ at the action effort. On DeepSeek that is harmless (card 'medium' is coerced to 'high' server-side and
|
|
104
|
+
* the anchor-lift bust lands on the same boundary); on other providers it sends a different effort on request 0 and
|
|
105
|
+
* costs one extra cache break per user turn. DARK: CORTEX_ACTION_EFFORT_FIRST=on → request 0 gets the action effort
|
|
106
|
+
* when no ramp / request param set one. Off → undefined (byte-identical).
|
|
107
|
+
*/
|
|
108
|
+
export function firstRequestActionEffort(env = process.env) {
|
|
109
|
+
if (!flagOn(env.CORTEX_ACTION_EFFORT_FIRST))
|
|
110
|
+
return undefined;
|
|
111
|
+
const e = String(env.CORTEX_ACTION_EFFORT ?? '').trim();
|
|
112
|
+
return e || undefined;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=transportEffortFixes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transportEffortFixes.js","sourceRoot":"","sources":["../../src/orchestrator/transportEffortFixes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,SAAS,MAAM,CAAC,GAAuB;IACrC,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IACjD,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,MAAM,IAAI,CAAC,KAAK,GAAG,CAAC;AACjD,CAAC;AAED,MAAM,UAAU,6BAA6B;IAC3C,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;AAC3D,CAAC;AACD,MAAM,UAAU,wBAAwB;IACtC,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;AACrD,CAAC;AACD,MAAM,UAAU,4BAA4B;IAC1C,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;AAC1D,CAAC;AAED,4GAA4G;AAC5G,YAAY;AACZ,4GAA4G;AAE5G,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;AAEnF;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CAAC,eAAmC;IACvE,MAAM,CAAC,GAAG,MAAM,CAAC,eAAe,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC7D,OAAO,uBAAuB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACxD,CAAC;AAED,uGAAuG;AACvG,MAAM,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AAE,CAAC,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;IAC7D,IAAI,0BAA0B,CAAC,OAAO,CAAC,EAAE,CAAC;QACxC,MAAM,KAAK,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC;QACxC,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACtD,CAAC;IACD,MAAM,MAAM,GAAG,uBAAuB,CAAC,CAAC,CAAC,CAAC;IAC1C,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACvE,CAAC;AAED,4GAA4G;AAC5G,2DAA2D;AAC3D,4GAA4G;AAE5G;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC3E,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,0BAA0B,CAAC;QAAE,OAAO,SAAS,CAAC;IAC9D,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACxD,OAAO,CAAC,IAAI,SAAS,CAAC;AACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nexus-cortex/core",
|
|
3
|
-
"version": "4.124.
|
|
3
|
+
"version": "4.124.46",
|
|
4
4
|
"description": "Core orchestration library implementing Claude CLI architecture patterns",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"@google/generative-ai": "^0.2.1",
|
|
48
48
|
"@gradio/client": "^2.3.1",
|
|
49
49
|
"@modelcontextprotocol/sdk": "^1.20.2",
|
|
50
|
-
"@nexus-cortex/executors": "4.124.
|
|
51
|
-
"@nexus-cortex/types": "4.124.
|
|
50
|
+
"@nexus-cortex/executors": "4.124.46",
|
|
51
|
+
"@nexus-cortex/types": "4.124.46",
|
|
52
52
|
"@types/uuid": "^10.0.0",
|
|
53
53
|
"ajv": "^8.12.0",
|
|
54
54
|
"chokidar": "^3.6.0",
|