@nexus-cortex/core 4.69.1 → 4.71.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.
Files changed (70) hide show
  1. package/dist/adapters/ChatCompletionsAPIAdapter.d.ts +17 -2
  2. package/dist/adapters/ChatCompletionsAPIAdapter.d.ts.map +1 -1
  3. package/dist/adapters/ChatCompletionsAPIAdapter.js +26 -3
  4. package/dist/adapters/ChatCompletionsAPIAdapter.js.map +1 -1
  5. package/dist/adapters/MessagesAPIAdapter.d.ts.map +1 -1
  6. package/dist/adapters/MessagesAPIAdapter.js +15 -0
  7. package/dist/adapters/MessagesAPIAdapter.js.map +1 -1
  8. package/dist/models/cards/deepseek/deepseek-v4-flash-vision-exp.d.ts +28 -0
  9. package/dist/models/cards/deepseek/deepseek-v4-flash-vision-exp.d.ts.map +1 -0
  10. package/dist/models/cards/deepseek/deepseek-v4-flash-vision-exp.js +47 -0
  11. package/dist/models/cards/deepseek/deepseek-v4-flash-vision-exp.js.map +1 -0
  12. package/dist/models/cards/deepseek/index.d.ts +5 -2
  13. package/dist/models/cards/deepseek/index.d.ts.map +1 -1
  14. package/dist/models/cards/deepseek/index.js +5 -2
  15. package/dist/models/cards/deepseek/index.js.map +1 -1
  16. package/dist/models/configurators/DeepSeekConfigurator.d.ts +5 -0
  17. package/dist/models/configurators/DeepSeekConfigurator.d.ts.map +1 -1
  18. package/dist/models/configurators/DeepSeekConfigurator.js +2 -0
  19. package/dist/models/configurators/DeepSeekConfigurator.js.map +1 -1
  20. package/dist/models/configurators/XAIConfigurator.d.ts +3 -0
  21. package/dist/models/configurators/XAIConfigurator.d.ts.map +1 -1
  22. package/dist/models/configurators/XAIConfigurator.js +1 -0
  23. package/dist/models/configurators/XAIConfigurator.js.map +1 -1
  24. package/dist/models/registry/ModularModelRegistry.d.ts.map +1 -1
  25. package/dist/models/registry/ModularModelRegistry.js +1 -0
  26. package/dist/models/registry/ModularModelRegistry.js.map +1 -1
  27. package/dist/orchestrator/CortexOrchestrator.d.ts +23 -0
  28. package/dist/orchestrator/CortexOrchestrator.d.ts.map +1 -1
  29. package/dist/orchestrator/CortexOrchestrator.js +628 -22
  30. package/dist/orchestrator/CortexOrchestrator.js.map +1 -1
  31. package/dist/orchestrator/imageTtl.d.ts +37 -0
  32. package/dist/orchestrator/imageTtl.d.ts.map +1 -0
  33. package/dist/orchestrator/imageTtl.js +72 -0
  34. package/dist/orchestrator/imageTtl.js.map +1 -0
  35. package/dist/orchestrator/inactionGuard.d.ts +42 -0
  36. package/dist/orchestrator/inactionGuard.d.ts.map +1 -0
  37. package/dist/orchestrator/inactionGuard.js +47 -0
  38. package/dist/orchestrator/inactionGuard.js.map +1 -0
  39. package/dist/orchestrator/requirementsVerification.d.ts +43 -0
  40. package/dist/orchestrator/requirementsVerification.d.ts.map +1 -0
  41. package/dist/orchestrator/requirementsVerification.js +87 -0
  42. package/dist/orchestrator/requirementsVerification.js.map +1 -0
  43. package/dist/tools/ToolProfile.d.ts +9 -0
  44. package/dist/tools/ToolProfile.d.ts.map +1 -1
  45. package/dist/tools/ToolProfile.js +26 -3
  46. package/dist/tools/ToolProfile.js.map +1 -1
  47. package/dist/tools/registries/BaseToolRegistry.d.ts.map +1 -1
  48. package/dist/tools/registries/BaseToolRegistry.js +42 -1
  49. package/dist/tools/registries/BaseToolRegistry.js.map +1 -1
  50. package/dist/training/DecisionPriorInjector.d.ts +7 -0
  51. package/dist/training/DecisionPriorInjector.d.ts.map +1 -1
  52. package/dist/training/DecisionPriorInjector.js +22 -0
  53. package/dist/training/DecisionPriorInjector.js.map +1 -1
  54. package/dist/training/DecisionStore.d.ts +39 -0
  55. package/dist/training/DecisionStore.d.ts.map +1 -1
  56. package/dist/training/DecisionStore.js +94 -0
  57. package/dist/training/DecisionStore.js.map +1 -1
  58. package/dist/training/errorFamily.d.ts +15 -0
  59. package/dist/training/errorFamily.d.ts.map +1 -0
  60. package/dist/training/errorFamily.js +40 -0
  61. package/dist/training/errorFamily.js.map +1 -0
  62. package/dist/training/loopLadder.d.ts +35 -0
  63. package/dist/training/loopLadder.d.ts.map +1 -0
  64. package/dist/training/loopLadder.js +58 -0
  65. package/dist/training/loopLadder.js.map +1 -0
  66. package/dist/training/toolOutcome.d.ts +20 -0
  67. package/dist/training/toolOutcome.d.ts.map +1 -0
  68. package/dist/training/toolOutcome.js +100 -0
  69. package/dist/training/toolOutcome.js.map +1 -0
  70. package/package.json +3 -3
@@ -0,0 +1,20 @@
1
+ export interface ToolOutcome {
2
+ status: 'ok' | 'failed' | 'error';
3
+ /** Normalized failure fingerprint (present when status !== 'ok'). */
4
+ family?: string;
5
+ /** Normalized "same approach" hash — near-duplicate retries collide. */
6
+ approachHash: string;
7
+ /** Byte-sensitive input hash (the existing exact-prior key). */
8
+ exactHash: string;
9
+ }
10
+ interface ToolResultLike {
11
+ content: string;
12
+ is_error?: boolean;
13
+ metadata?: {
14
+ exitCode?: number | null;
15
+ } & Record<string, unknown>;
16
+ }
17
+ export declare function approachHash(toolName: string, input: unknown): string;
18
+ export declare function classifyToolOutcome(toolName: string, input: unknown, result: ToolResultLike): ToolOutcome;
19
+ export {};
20
+ //# sourceMappingURL=toolOutcome.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolOutcome.d.ts","sourceRoot":"","sources":["../../src/training/toolOutcome.ts"],"names":[],"mappings":"AAkBA,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,IAAI,GAAG,QAAQ,GAAG,OAAO,CAAC;IAClC,qEAAqE;IACrE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAC;IACrB,gEAAgE;IAChE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,cAAc;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnE;AA+BD,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,CAYrE;AAED,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,OAAO,EACd,MAAM,EAAE,cAAc,GACrB,WAAW,CAwBb"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * toolOutcome — the SINGLE failure semantics every guard consumes.
3
+ * (docs/UNIFIED_OUTCOME_LADDER.md; TB2 root cause: ShellTool returns a
4
+ * success result for exit!=0 commands, so consecutive-error breaking,
5
+ * decision-store priors, and the family lens all recorded thrash as wins.)
6
+ *
7
+ * status:
8
+ * ok — the tool ran and succeeded (exitCode 0, or no exit semantics
9
+ * and not an error result)
10
+ * failed — the tool RAN but did not succeed (nonzero exitCode in result
11
+ * metadata, or a recognized failure signature in content)
12
+ * error — transport/abort/exception results (wire is_error; untouched
13
+ * semantics — we never rewrite what the model sees)
14
+ */
15
+ import { createHash } from 'crypto';
16
+ import { classifyErrorFamily } from './errorFamily.js';
17
+ import { stableInputHash } from './DecisionStore.js';
18
+ /** Content signatures that mean "the command ran and failed" even when the
19
+ * result carries no exit metadata (older executors, remote shells). */
20
+ const FAILURE_SIGNATURES = [
21
+ /Command failed with exit code \d+/,
22
+ /Command timed out after/i,
23
+ ];
24
+ /** Normalize an input's text the way errorFamily normalizes error snippets:
25
+ * quoted strings, hex ids, paths, and digit runs collapse so "retry with a
26
+ * tweaked flag/version/path" lands on the same approach bucket. */
27
+ function normalizeApproachText(text) {
28
+ return text
29
+ .toLowerCase()
30
+ .replace(/(["'])(?:\\.|(?!\1).)*\1/g, '<q>')
31
+ .replace(/\b0x[0-9a-f]+\b/g, '<hex>')
32
+ .replace(/(?:^|[\s='"([{:,])((?:\/|(?:[a-z]:)?\\)[^\s'")\]},:]*)/g, ' <path>')
33
+ // Version-pin skeletons and option flags are RETRY VARIATION, not a new
34
+ // approach (probe-3 finding: `pkg`, `pkg==2.1`, `pkg --no-cache-dir` must
35
+ // land in one bucket or the ladder never counts past 1).
36
+ .replace(/[=<>!~]=[\w.*]+/g, '')
37
+ .replace(/(?:^|\s)--?[\w-]+(=\S*)?/g, ' ')
38
+ .replace(/\d+/g, '#')
39
+ // A standalone number token is a flag argument or count, not an approach.
40
+ .replace(/(?:^|\s)#+(?=\s|$)/g, ' ')
41
+ .replace(/\s+/g, ' ')
42
+ .trim()
43
+ .slice(0, 160);
44
+ }
45
+ export function approachHash(toolName, input) {
46
+ let text;
47
+ if (input && typeof input === 'object') {
48
+ // Sort keys so property order can't split a bucket; normalize each value.
49
+ const entries = Object.entries(input)
50
+ .sort(([a], [b]) => (a < b ? -1 : 1))
51
+ .map(([k, v]) => `${k}=${normalizeApproachText(typeof v === 'string' ? v : JSON.stringify(v))}`);
52
+ text = entries.join('|');
53
+ }
54
+ else {
55
+ text = normalizeApproachText(String(input));
56
+ }
57
+ return createHash('sha256').update(`${toolName}\n${text}`).digest('hex').slice(0, 16);
58
+ }
59
+ export function classifyToolOutcome(toolName, input, result) {
60
+ const exactHash = stableInputHash(input);
61
+ const aHash = approachHash(toolName, input);
62
+ const content = String(result.content ?? '');
63
+ let status;
64
+ if (result.is_error) {
65
+ status = 'error';
66
+ }
67
+ else {
68
+ const exit = result.metadata?.exitCode;
69
+ if (typeof exit === 'number' && exit !== 0)
70
+ status = 'failed';
71
+ else if (typeof exit === 'number')
72
+ status = 'ok';
73
+ else if (FAILURE_SIGNATURES.some((re) => re.test(content)))
74
+ status = 'failed';
75
+ else
76
+ status = 'ok';
77
+ }
78
+ return {
79
+ status,
80
+ ...(status !== 'ok'
81
+ ? { family: classifyErrorFamily(stripLeadingReminders(content).slice(0, 200)) || 'unclassified' }
82
+ : {}),
83
+ approachHash: aHash,
84
+ exactHash,
85
+ };
86
+ }
87
+ /** Loop-level classification sees results ALREADY augmented with prepended
88
+ * <system-reminder> blocks (processToolTraining runs first) — strip them so
89
+ * the family fingerprint reflects the tool's own output, not our reminder. */
90
+ function stripLeadingReminders(content) {
91
+ let out = content;
92
+ // eslint-disable-next-line no-constant-condition
93
+ while (true) {
94
+ const next = out.replace(/^\s*<system-reminder>[\s\S]*?<\/system-reminder>\s*/, '');
95
+ if (next === out)
96
+ return out;
97
+ out = next;
98
+ }
99
+ }
100
+ //# sourceMappingURL=toolOutcome.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toolOutcome.js","sourceRoot":"","sources":["../../src/training/toolOutcome.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAkBrD;wEACwE;AACxE,MAAM,kBAAkB,GAAG;IACzB,mCAAmC;IACnC,0BAA0B;CAC3B,CAAC;AAEF;;oEAEoE;AACpE,SAAS,qBAAqB,CAAC,IAAY;IACzC,OAAO,IAAI;SACR,WAAW,EAAE;SACb,OAAO,CAAC,2BAA2B,EAAE,KAAK,CAAC;SAC3C,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC;SACpC,OAAO,CAAC,yDAAyD,EAAE,SAAS,CAAC;QAC9E,wEAAwE;QACxE,0EAA0E;QAC1E,yDAAyD;SACxD,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC;SAC/B,OAAO,CAAC,2BAA2B,EAAE,GAAG,CAAC;SACzC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;QACrB,0EAA0E;SACzE,OAAO,CAAC,qBAAqB,EAAE,GAAG,CAAC;SACnC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE;SACN,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,QAAgB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AI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,GAAG,OAAO,CAAC;IACnB,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC;QACvC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,CAAC;YAAE,MAAM,GAAG,QAAQ,CAAC;aACzD,IAAI,OAAO,IAAI,KAAK,QAAQ;YAAE,MAAM,GAAG,IAAI,CAAC;aAC5C,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAAE,MAAM,GAAG,QAAQ,CAAC;;YACzE,MAAM,GAAG,IAAI,CAAC;IACrB,CAAC;IAED,OAAO;QACL,MAAM;QACN,GAAG,CAAC,MAAM,KAAK,IAAI;YACjB,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,qBAAqB,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,cAAc,EAAE;YACjG,CAAC,CAAC,EAAE,CAAC;QACP,YAAY,EAAE,KAAK;QACnB,SAAS;KACV,CAAC;AACJ,CAAC;AAED;;+EAE+E;AAC/E,SAAS,qBAAqB,CAAC,OAAe;IAC5C,IAAI,GAAG,GAAG,OAAO,CAAC;IAClB,iDAAiD;IACjD,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,qDAAqD,EAAE,EAAE,CAAC,CAAC;QACpF,IAAI,IAAI,KAAK,GAAG;YAAE,OAAO,GAAG,CAAC;QAC7B,GAAG,GAAG,IAAI,CAAC;IACb,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexus-cortex/core",
3
- "version": "4.69.1",
3
+ "version": "4.71.0",
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.69.1",
51
- "@nexus-cortex/types": "4.69.1",
50
+ "@nexus-cortex/executors": "4.71.0",
51
+ "@nexus-cortex/types": "4.71.0",
52
52
  "@types/uuid": "^10.0.0",
53
53
  "ajv": "^8.12.0",
54
54
  "chokidar": "^3.6.0",