agent-nuvira 3.1.3 → 3.3.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 (164) hide show
  1. package/dist/agents/agents/reasoner.d.ts +8 -0
  2. package/dist/agents/agents/reasoner.d.ts.map +1 -1
  3. package/dist/agents/agents/reasoner.js +53 -2
  4. package/dist/agents/agents/reasoner.js.map +1 -1
  5. package/dist/agents/agents/writer.d.ts +24 -0
  6. package/dist/agents/agents/writer.d.ts.map +1 -1
  7. package/dist/agents/agents/writer.js +200 -0
  8. package/dist/agents/agents/writer.js.map +1 -1
  9. package/dist/agents/composite-plan.d.ts +143 -0
  10. package/dist/agents/composite-plan.d.ts.map +1 -0
  11. package/dist/agents/composite-plan.js +399 -0
  12. package/dist/agents/composite-plan.js.map +1 -0
  13. package/dist/agents/long-form-plan.d.ts +156 -0
  14. package/dist/agents/long-form-plan.d.ts.map +1 -0
  15. package/dist/agents/long-form-plan.js +274 -0
  16. package/dist/agents/long-form-plan.js.map +1 -0
  17. package/dist/agents/orchestrator.d.ts +107 -0
  18. package/dist/agents/orchestrator.d.ts.map +1 -1
  19. package/dist/agents/orchestrator.js +501 -35
  20. package/dist/agents/orchestrator.js.map +1 -1
  21. package/dist/agents/prompt-assembly.d.ts +8 -0
  22. package/dist/agents/prompt-assembly.d.ts.map +1 -1
  23. package/dist/agents/prompt-assembly.js +17 -0
  24. package/dist/agents/prompt-assembly.js.map +1 -1
  25. package/dist/cli/chat.d.ts +33 -0
  26. package/dist/cli/chat.d.ts.map +1 -1
  27. package/dist/cli/chat.js +161 -7
  28. package/dist/cli/chat.js.map +1 -1
  29. package/dist/cli/execute.d.ts +12 -0
  30. package/dist/cli/execute.d.ts.map +1 -1
  31. package/dist/cli/execute.js +150 -2
  32. package/dist/cli/execute.js.map +1 -1
  33. package/dist/cli/loop-executor.d.ts +17 -0
  34. package/dist/cli/loop-executor.d.ts.map +1 -1
  35. package/dist/cli/loop-executor.js +160 -1
  36. package/dist/cli/loop-executor.js.map +1 -1
  37. package/dist/cli/models.d.ts.map +1 -1
  38. package/dist/cli/models.js +10 -0
  39. package/dist/cli/models.js.map +1 -1
  40. package/dist/cli/trace.d.ts +19 -0
  41. package/dist/cli/trace.d.ts.map +1 -1
  42. package/dist/cli/trace.js +109 -2
  43. package/dist/cli/trace.js.map +1 -1
  44. package/dist/gateway/registry.d.ts +31 -0
  45. package/dist/gateway/registry.d.ts.map +1 -1
  46. package/dist/gateway/registry.js +162 -13
  47. package/dist/gateway/registry.js.map +1 -1
  48. package/dist/inference/model-entitlement.d.ts +46 -0
  49. package/dist/inference/model-entitlement.d.ts.map +1 -0
  50. package/dist/inference/model-entitlement.js +98 -0
  51. package/dist/inference/model-entitlement.js.map +1 -0
  52. package/dist/inference/tool-call-utils.d.ts +10 -0
  53. package/dist/inference/tool-call-utils.d.ts.map +1 -1
  54. package/dist/inference/tool-call-utils.js +90 -0
  55. package/dist/inference/tool-call-utils.js.map +1 -1
  56. package/dist/learning/autonomy-policy.d.ts +370 -0
  57. package/dist/learning/autonomy-policy.d.ts.map +1 -0
  58. package/dist/learning/autonomy-policy.js +544 -0
  59. package/dist/learning/autonomy-policy.js.map +1 -0
  60. package/dist/learning/cost-tracker.d.ts +14 -0
  61. package/dist/learning/cost-tracker.d.ts.map +1 -1
  62. package/dist/learning/cost-tracker.js +22 -0
  63. package/dist/learning/cost-tracker.js.map +1 -1
  64. package/dist/learning/credential-fingerprint.d.ts +58 -0
  65. package/dist/learning/credential-fingerprint.d.ts.map +1 -0
  66. package/dist/learning/credential-fingerprint.js +126 -0
  67. package/dist/learning/credential-fingerprint.js.map +1 -0
  68. package/dist/learning/deliverable-class.d.ts +178 -0
  69. package/dist/learning/deliverable-class.d.ts.map +1 -0
  70. package/dist/learning/deliverable-class.js +504 -0
  71. package/dist/learning/deliverable-class.js.map +1 -0
  72. package/dist/learning/engine-router.d.ts +12 -1
  73. package/dist/learning/engine-router.d.ts.map +1 -1
  74. package/dist/learning/engine-router.js +28 -0
  75. package/dist/learning/engine-router.js.map +1 -1
  76. package/dist/learning/long-form.d.ts +252 -0
  77. package/dist/learning/long-form.d.ts.map +1 -0
  78. package/dist/learning/long-form.js +521 -0
  79. package/dist/learning/long-form.js.map +1 -0
  80. package/dist/learning/model-first-router.d.ts +17 -0
  81. package/dist/learning/model-first-router.d.ts.map +1 -1
  82. package/dist/learning/model-first-router.js +27 -0
  83. package/dist/learning/model-first-router.js.map +1 -1
  84. package/dist/learning/model-registry.d.ts +66 -4
  85. package/dist/learning/model-registry.d.ts.map +1 -1
  86. package/dist/learning/model-registry.js +67 -6
  87. package/dist/learning/model-registry.js.map +1 -1
  88. package/dist/learning/model-warmup.d.ts +97 -2
  89. package/dist/learning/model-warmup.d.ts.map +1 -1
  90. package/dist/learning/model-warmup.js +165 -60
  91. package/dist/learning/model-warmup.js.map +1 -1
  92. package/dist/learning/prompt-layers.d.ts +61 -0
  93. package/dist/learning/prompt-layers.d.ts.map +1 -0
  94. package/dist/learning/prompt-layers.js +140 -0
  95. package/dist/learning/prompt-layers.js.map +1 -0
  96. package/dist/learning/provider-limits.d.ts +66 -0
  97. package/dist/learning/provider-limits.d.ts.map +1 -0
  98. package/dist/learning/provider-limits.js +184 -0
  99. package/dist/learning/provider-limits.js.map +1 -0
  100. package/dist/learning/reasoning-trace.d.ts +125 -1
  101. package/dist/learning/reasoning-trace.d.ts.map +1 -1
  102. package/dist/learning/reasoning-trace.js +85 -2
  103. package/dist/learning/reasoning-trace.js.map +1 -1
  104. package/dist/learning/resilient-call.d.ts +36 -1
  105. package/dist/learning/resilient-call.d.ts.map +1 -1
  106. package/dist/learning/resilient-call.js +80 -5
  107. package/dist/learning/resilient-call.js.map +1 -1
  108. package/dist/learning/unattended-job.d.ts +350 -0
  109. package/dist/learning/unattended-job.d.ts.map +1 -0
  110. package/dist/learning/unattended-job.js +636 -0
  111. package/dist/learning/unattended-job.js.map +1 -0
  112. package/dist/learning/unattended-progress.d.ts +95 -0
  113. package/dist/learning/unattended-progress.d.ts.map +1 -0
  114. package/dist/learning/unattended-progress.js +147 -0
  115. package/dist/learning/unattended-progress.js.map +1 -0
  116. package/dist/learning/working-state.d.ts +109 -0
  117. package/dist/learning/working-state.d.ts.map +1 -0
  118. package/dist/learning/working-state.js +244 -0
  119. package/dist/learning/working-state.js.map +1 -0
  120. package/dist/nlu/conversation-gate.d.ts +33 -0
  121. package/dist/nlu/conversation-gate.d.ts.map +1 -1
  122. package/dist/nlu/conversation-gate.js +68 -3
  123. package/dist/nlu/conversation-gate.js.map +1 -1
  124. package/dist/tools/coding-tools.d.ts.map +1 -1
  125. package/dist/tools/coding-tools.js +95 -19
  126. package/dist/tools/coding-tools.js.map +1 -1
  127. package/dist/tools/edit-verification.d.ts +142 -0
  128. package/dist/tools/edit-verification.d.ts.map +1 -0
  129. package/dist/tools/edit-verification.js +262 -0
  130. package/dist/tools/edit-verification.js.map +1 -0
  131. package/dist/tools/git-tool.d.ts.map +1 -1
  132. package/dist/tools/git-tool.js +37 -4
  133. package/dist/tools/git-tool.js.map +1 -1
  134. package/dist/tools/registry.d.ts +30 -2
  135. package/dist/tools/registry.d.ts.map +1 -1
  136. package/dist/tools/registry.js +40 -11
  137. package/dist/tools/registry.js.map +1 -1
  138. package/dist/tools/run-cli.d.ts.map +1 -1
  139. package/dist/tools/run-cli.js +40 -13
  140. package/dist/tools/run-cli.js.map +1 -1
  141. package/dist/tools/run-terminal.d.ts +6 -1
  142. package/dist/tools/run-terminal.d.ts.map +1 -1
  143. package/dist/tools/run-terminal.js +158 -18
  144. package/dist/tools/run-terminal.js.map +1 -1
  145. package/dist/tools/tool-loop.d.ts +109 -0
  146. package/dist/tools/tool-loop.d.ts.map +1 -1
  147. package/dist/tools/tool-loop.js +362 -2
  148. package/dist/tools/tool-loop.js.map +1 -1
  149. package/dist/web-dashboard/chat-console.d.ts +8 -0
  150. package/dist/web-dashboard/chat-console.d.ts.map +1 -1
  151. package/dist/web-dashboard/chat-console.js +9 -0
  152. package/dist/web-dashboard/chat-console.js.map +1 -1
  153. package/dist/web-dashboard/chat-retry.d.ts.map +1 -1
  154. package/dist/web-dashboard/chat-retry.js +10 -2
  155. package/dist/web-dashboard/chat-retry.js.map +1 -1
  156. package/dist/web-dashboard/server.d.ts.map +1 -1
  157. package/dist/web-dashboard/server.js +80 -8
  158. package/dist/web-dashboard/server.js.map +1 -1
  159. package/dist/web-dashboard/src/types.d.ts +81 -4
  160. package/dist/web-dashboard/src/types.d.ts.map +1 -1
  161. package/package.json +1 -1
  162. package/src/web-dashboard/public/assets/{index-Co7Hk2FT.js → index-kCUkORm7.js} +2 -2
  163. package/src/web-dashboard/public/assets/{index-Co7Hk2FT.js.map → index-kCUkORm7.js.map} +1 -1
  164. package/src/web-dashboard/public/index.html +1 -1
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Prompt layers — deterministic splitting of a composed prompt into the
3
+ * layers that matter for review (enterprise hardening, session 3).
4
+ *
5
+ * WHY THIS EXISTS (the prompt audit of the last 30 traces):
6
+ * The trace stored ONE flat `promptPreview` capped at 300–500 chars, and for
7
+ * chat turns the preview deliberately shortened the system prompt to its first
8
+ * 80 characters. Result: in 106/106 chat steps the single most important
9
+ * artifact — the system prompt (persona, tool contract, response rules) — was
10
+ * INVISIBLE, and `promptDigest` hashed the whole thread so it could not show
11
+ * whether the stable layer was byte-stable (i.e. cacheable). Prompt
12
+ * engineering was, in practice, unreviewable.
13
+ *
14
+ * This module answers three questions from a flat prompt string, with no LLM
15
+ * and no caller changes:
16
+ * 1. Which bytes are the STABLE layer (identity / contract)?
17
+ * 2. Which are CONTEXT (project knowledge, recalled state, history, tools)?
18
+ * 3. Which are VOLATILE (the current task / ask)?
19
+ *
20
+ * Two transports are recognised because the codebase composes prompts two ways:
21
+ * - the chat thread serialisation: `[System]` / `[User]` / `[Assistant]` /
22
+ * `[Tool result]` markers (see `chat.ts` callModelWithTrace);
23
+ * - the layered assembler: `# Project Context` … `## Task` headings
24
+ * (see `agents/prompt-assembly.ts` assemblePrompt).
25
+ * Anything else falls back to a single `system` layer so a digest still detects
26
+ * change even when the shape is unknown.
27
+ */
28
+ import { createHash } from 'node:crypto';
29
+ function sha256Prefix(input, length = 16) {
30
+ try {
31
+ return createHash('sha256').update(input).digest('hex').slice(0, length);
32
+ }
33
+ catch {
34
+ return String(input.length);
35
+ }
36
+ }
37
+ /** The chat transport's role markers, at the START of a line. */
38
+ const CHAT_MARKER_RE = /^(?:\[System\]|\[User\]|\[Assistant\]|\[Tool result\])\s*$/;
39
+ /** The assembler transport's headings. */
40
+ const ASSEMBLED_CONTEXT_RE = /^#\s*Project Context\s*$/m;
41
+ const ASSEMBLED_VOLATILE_RE = /^##\s*Task\s*$/m;
42
+ /**
43
+ * Split a chat-thread serialisation. The LAST `[User]` block is the current
44
+ * ask (volatile); every earlier block — injected context, prior turns, tool
45
+ * results — is context; the leading `[System]` block is the stable layer.
46
+ */
47
+ function splitChatThread(text) {
48
+ const lines = text.split('\n');
49
+ // Index of each marker line.
50
+ const marks = [];
51
+ lines.forEach((l, i) => {
52
+ if (CHAT_MARKER_RE.test(l.trim()))
53
+ marks.push({ i, kind: l.trim() });
54
+ });
55
+ if (marks.length === 0)
56
+ return { system: text, context: '', volatile: '' };
57
+ const lastUser = [...marks].reverse().find((m) => m.kind === '[User]');
58
+ const sys = marks.find((m) => m.kind === '[System]');
59
+ // Slice boundaries: a block runs from a marker to the next marker.
60
+ const blockEnd = (idx) => {
61
+ const next = marks.find((m) => m.i > marks[idx].i);
62
+ return next ? next.i : lines.length;
63
+ };
64
+ const blockAt = (mark) => {
65
+ const pos = marks.findIndex((m) => m.i === mark.i);
66
+ return lines.slice(mark.i, blockEnd(pos)).join('\n');
67
+ };
68
+ const system = sys ? blockAt(sys) : '';
69
+ const volatile = lastUser ? blockAt(lastUser) : '';
70
+ const context = lines
71
+ .filter((_, i) => {
72
+ // Everything except the system block and the LAST user block.
73
+ if (sys && i >= sys.i && i < blockEnd(marks.findIndex((m) => m.i === sys.i)))
74
+ return false;
75
+ if (lastUser && i >= lastUser.i && i < blockEnd(marks.findIndex((m) => m.i === lastUser.i)))
76
+ return false;
77
+ return true;
78
+ })
79
+ .join('\n');
80
+ return { system, context: context.trim(), volatile };
81
+ }
82
+ /**
83
+ * Split an `assemblePrompt` result: everything before `# Project Context` is
84
+ * the stable layer, the Project Context block is context, and `## Task`
85
+ * onward is volatile.
86
+ */
87
+ function splitAssembledPrompt(text) {
88
+ const ctxMatch = ASSEMBLED_CONTEXT_RE.exec(text);
89
+ const volMatch = ASSEMBLED_VOLATILE_RE.exec(text);
90
+ const ctxAt = ctxMatch?.index ?? -1;
91
+ const volAt = volMatch?.index ?? -1;
92
+ if (ctxAt === -1 && volAt === -1) {
93
+ // Unknown shape — keep it as one stable layer so change is still detected.
94
+ return { system: text, context: '', volatile: '' };
95
+ }
96
+ const systemEnd = ctxAt !== -1 ? ctxAt : volAt;
97
+ const system = text.slice(0, systemEnd).trim();
98
+ const context = ctxAt === -1 ? '' : text.slice(ctxAt, volAt === -1 ? text.length : volAt).trim();
99
+ const volatile = volAt === -1 ? '' : text.slice(volAt).trim();
100
+ return { system, context, volatile };
101
+ }
102
+ /**
103
+ * Split a composed prompt into its stable / context / volatile layers.
104
+ * Deterministic and transport-aware; never throws.
105
+ */
106
+ export function splitPromptLayers(text) {
107
+ const t = text || '';
108
+ if (!t.trim())
109
+ return { system: '', context: '', volatile: '' };
110
+ try {
111
+ if (CHAT_MARKER_RE.test(t.split('\n')[0].trim()) || /\n\[User\]\s*$|\n\[User\]\n/.test(t)) {
112
+ return splitChatThread(t);
113
+ }
114
+ return splitAssembledPrompt(t);
115
+ }
116
+ catch {
117
+ return { system: t, context: '', volatile: '' };
118
+ }
119
+ }
120
+ /**
121
+ * Per-layer digests + sizes. The three digests SEPARATELY answer the review
122
+ * question the flat digest could not: did the stable layer change between
123
+ * steps (a cache-busting regression), or only the volatile one (expected)?
124
+ */
125
+ export function digestPromptLayers(layers) {
126
+ return {
127
+ systemDigest: sha256Prefix(layers.system),
128
+ contextDigest: sha256Prefix(layers.context),
129
+ volatileDigest: sha256Prefix(layers.volatile),
130
+ systemChars: layers.system.length,
131
+ contextChars: layers.context.length,
132
+ volatileChars: layers.volatile.length,
133
+ };
134
+ }
135
+ /** Convenience: split + digest in one call. */
136
+ export function digestPrompt(text) {
137
+ const layers = splitPromptLayers(text);
138
+ return { layers, digests: digestPromptLayers(layers) };
139
+ }
140
+ //# sourceMappingURL=prompt-layers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompt-layers.js","sourceRoot":"","sources":["../../src/learning/prompt-layers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAqBzC,SAAS,YAAY,CAAC,KAAa,EAAE,MAAM,GAAG,EAAE;IAC9C,IAAI,CAAC;QACH,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC3E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,iEAAiE;AACjE,MAAM,cAAc,GAAG,4DAA4D,CAAC;AAEpF,0CAA0C;AAC1C,MAAM,oBAAoB,GAAG,2BAA2B,CAAC;AACzD,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AAEhD;;;;GAIG;AACH,SAAS,eAAe,CAAC,IAAY;IACnC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,6BAA6B;IAC7B,MAAM,KAAK,GAAuC,EAAE,CAAC;IACrD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACrB,IAAI,cAAc,CAAC,IAAI,CAAC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CAAC,IAAI,EAAE,CAAC,IAAI,6BAA6B,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1F,OAAO,eAAe,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC;QACD,OAAO,oBAAoB,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;IAClD,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAoB;IACrD,OAAO;QACL,YAAY,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC;QACzC,aAAa,EAAE,YAAY,CAAC,MAAM,CAAC,OAAO,CAAC;QAC3C,cAAc,EAAE,YAAY,CAAC,MAAM,CAAC,QAAQ,CAAC;QAC7C,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;QACjC,YAAY,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM;QACnC,aAAa,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM;KACtC,CAAC;AACJ,CAAC;AAED,+CAA+C;AAC/C,MAAM,UAAU,YAAY,CAAC,IAAY;IACvC,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACvC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC;AACzD,CAAC"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Provider output-cap learning (enterprise-grade hardening, G15).
3
+ *
4
+ * WHY THIS EXISTS. A live unattended story run (12 pages, no human input)
5
+ * failed EVERY prose unit with the same provider rejection:
6
+ *
7
+ * Groq API error (400): {"error":{"message":"`max_tokens` must be less than
8
+ * or equal to `512`, the maximum value for `max_tokens` is less than the
9
+ * `context_window` for this model","param":"max_tokens"}}
10
+ *
11
+ * The cause was OUR constant, not the model pool: the prose path asks for
12
+ * `maxTokens: 8192` (~900 words with headroom) because a chapter needs it, and
13
+ * the routed model happened to permit only 512. So:
14
+ *
15
+ * - the agent looked broken ("Repair budget exhausted") when it was misconfigured;
16
+ * - `resolveMaxOutputTokens()` could not have prevented it — that heuristic
17
+ * reads the CONTEXT WINDOW, and this model advertises a large window with a
18
+ * tiny output cap, which is exactly the case the window heuristic cannot see;
19
+ * - the failure repeated 6 batches in a row, because nothing learned from it.
20
+ *
21
+ * Two disciplines come out of that, and this module is both:
22
+ *
23
+ * 1. `parseMaxTokensLimit()` — a provider that TELLS us its limit has told us
24
+ * the truth. Read it from the error instead of discarding it, so the retry
25
+ * is targeted at a number the provider itself named.
26
+ *
27
+ * 2. `rememberMaxTokensLimit()` / `clampMaxTokens()` — the learned limit is
28
+ * remembered per provider × model and applied PREDICTIVELY to later calls,
29
+ * so one rejection costs one wasted call per process instead of one per
30
+ * unit. Only ever clamps DOWN: a provider that accepts our request is
31
+ * never overruled by a stale or mis-parsed limit.
32
+ *
33
+ * Deliberately pure + process-local (no config writes): a provider contract is
34
+ * a runtime fact, and persisting a mis-parse would poison future sessions.
35
+ */
36
+ /**
37
+ * The smallest number any recognised phrasing names, or `null` when the error
38
+ * is not an output-cap rejection. Returning the SMALLEST is the safe read when
39
+ * a message contains several numbers: a retry that is too small still
40
+ * succeeds (shorter output), a retry that is too large fails again and wastes
41
+ * another call — and the whole point of this path is to stop wasting calls.
42
+ */
43
+ export declare function parseMaxTokensLimit(error: unknown): number | null;
44
+ /**
45
+ * Record a provider-named output cap. Ignored when the key is incomplete
46
+ * (a bare provider or model is too coarse to clamp against) or the value is
47
+ * not a positive integer. Also clamps against any already-learned value so a
48
+ * later, larger claim cannot raise the cap back up.
49
+ */
50
+ export declare function rememberMaxTokensLimit(provider: string | undefined, model: string | undefined, limit: number): void;
51
+ /** The learned cap for provider × model, or `undefined` when none is known. */
52
+ export declare function knownMaxTokensLimit(provider: string | undefined, model: string | undefined): number | undefined;
53
+ /**
54
+ * Apply the learned cap to a requested value. Only ever lowers: an unlearned
55
+ * pair and an already-small request both pass through unchanged, so a caller
56
+ * that deliberately asks for less keeps its value.
57
+ */
58
+ export declare function clampMaxTokens(requested: number | undefined, provider: string | undefined, model: string | undefined): number | undefined;
59
+ /**
60
+ * Read a cap out of an error and remember it. Returns the parsed limit (so the
61
+ * caller can retry with it) or `null` when the error was not a cap rejection.
62
+ */
63
+ export declare function learnMaxTokensLimitFromError(error: unknown, provider: string | undefined, model: string | undefined): number | null;
64
+ /** Test hook — clears the process-local table. */
65
+ export declare function resetLearnedMaxTokensLimits(): void;
66
+ //# sourceMappingURL=provider-limits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-limits.d.ts","sourceRoot":"","sources":["../../src/learning/provider-limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAsCH;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAajE;AA2CD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,KAAK,EAAE,MAAM,GACZ,IAAI,CAON;AAED,+EAA+E;AAC/E,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,GAAG,SAAS,CAIpB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,GAAG,SAAS,CAKpB;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,OAAO,EACd,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,KAAK,EAAE,MAAM,GAAG,SAAS,GACxB,MAAM,GAAG,IAAI,CAKf;AAED,kDAAkD;AAClD,wBAAgB,2BAA2B,IAAI,IAAI,CAElD"}
@@ -0,0 +1,184 @@
1
+ /**
2
+ * Provider output-cap learning (enterprise-grade hardening, G15).
3
+ *
4
+ * WHY THIS EXISTS. A live unattended story run (12 pages, no human input)
5
+ * failed EVERY prose unit with the same provider rejection:
6
+ *
7
+ * Groq API error (400): {"error":{"message":"`max_tokens` must be less than
8
+ * or equal to `512`, the maximum value for `max_tokens` is less than the
9
+ * `context_window` for this model","param":"max_tokens"}}
10
+ *
11
+ * The cause was OUR constant, not the model pool: the prose path asks for
12
+ * `maxTokens: 8192` (~900 words with headroom) because a chapter needs it, and
13
+ * the routed model happened to permit only 512. So:
14
+ *
15
+ * - the agent looked broken ("Repair budget exhausted") when it was misconfigured;
16
+ * - `resolveMaxOutputTokens()` could not have prevented it — that heuristic
17
+ * reads the CONTEXT WINDOW, and this model advertises a large window with a
18
+ * tiny output cap, which is exactly the case the window heuristic cannot see;
19
+ * - the failure repeated 6 batches in a row, because nothing learned from it.
20
+ *
21
+ * Two disciplines come out of that, and this module is both:
22
+ *
23
+ * 1. `parseMaxTokensLimit()` — a provider that TELLS us its limit has told us
24
+ * the truth. Read it from the error instead of discarding it, so the retry
25
+ * is targeted at a number the provider itself named.
26
+ *
27
+ * 2. `rememberMaxTokensLimit()` / `clampMaxTokens()` — the learned limit is
28
+ * remembered per provider × model and applied PREDICTIVELY to later calls,
29
+ * so one rejection costs one wasted call per process instead of one per
30
+ * unit. Only ever clamps DOWN: a provider that accepts our request is
31
+ * never overruled by a stale or mis-parsed limit.
32
+ *
33
+ * Deliberately pure + process-local (no config writes): a provider contract is
34
+ * a runtime fact, and persisting a mis-parse would poison future sessions.
35
+ */
36
+ /**
37
+ * camelCase → snake_case, lowercased, so one set of patterns covers
38
+ * `max_tokens`, `maxCompletionTokens` and `maxOutputTokens` alike. Without
39
+ * this, `maxOutputTokens must be <= 2048` (Gemini) reads as an unrelated
40
+ * error and the agent would keep failing the same way.
41
+ */
42
+ function normalize(text) {
43
+ return text.replace(/([a-z0-9])([A-Z])/g, '$1_$2').toLowerCase();
44
+ }
45
+ /** Guard: only text that talks about output caps can yield a limit. */
46
+ const MENTIONS_MAX_TOKENS = /max[_\s-]?(?:output[_\s-]|completion[_\s-])?tokens?/;
47
+ /** A max-output field name followed, within a short distance, by a number. */
48
+ const CAP_FIELD = 'max[_\\s-]?(?:output[_\\s-]|completion[_\\s-])?tokens?';
49
+ /**
50
+ * Phrasings observed across OpenAI-compatible providers (Groq, Together,
51
+ * Mistral, OpenRouter...), Anthropic and Gemini. Every pattern captures the
52
+ * named limit in group 1; the caller takes the SMALLEST of all matches.
53
+ */
54
+ const LIMIT_PATTERNS = [
55
+ // "max_tokens must be <= 512" / "must be less than or equal to 512"
56
+ new RegExp(`${CAP_FIELD}[\\s"'\`]*(?:must be )?(?:less than or equal to|no more than|at most|not exceed|<=?)\\s*["'\`]*(\\d+)`),
57
+ // "max_tokens: 8192 > 4096, which is the maximum allowed number of output tokens"
58
+ new RegExp(`${CAP_FIELD}[\\s"'\`]*[:=]?\\s*(\\d+)[\\s\\S]{0,160}?maximum allowed number of output tokens`),
59
+ // "...which is the maximum allowed number of output tokens for <model>"
60
+ /(\d+)[\s,)\]]*(?:which is |is )?the maximum allowed number of output tokens/i,
61
+ // "maximum value for max_tokens is 512"
62
+ new RegExp(`maximum(?: allowed)?(?: value)?(?: for| of)?[\\s"'\`]*${CAP_FIELD}[^\\d]{0,60}?(\\d+)`),
63
+ ];
64
+ /**
65
+ * The smallest number any recognised phrasing names, or `null` when the error
66
+ * is not an output-cap rejection. Returning the SMALLEST is the safe read when
67
+ * a message contains several numbers: a retry that is too small still
68
+ * succeeds (shorter output), a retry that is too large fails again and wastes
69
+ * another call — and the whole point of this path is to stop wasting calls.
70
+ */
71
+ export function parseMaxTokensLimit(error) {
72
+ const text = normalize(errorText(error));
73
+ if (!text || !MENTIONS_MAX_TOKENS.test(text))
74
+ return null;
75
+ const found = [];
76
+ for (const pattern of LIMIT_PATTERNS) {
77
+ const match = pattern.exec(text);
78
+ if (!match)
79
+ continue;
80
+ const value = Number.parseInt(match[1], 10);
81
+ if (Number.isFinite(value) && value > 0)
82
+ found.push(value);
83
+ }
84
+ if (found.length === 0)
85
+ return null;
86
+ return Math.min(...found);
87
+ }
88
+ /** Error → searchable text, digging into `cause` and attached bodies. */
89
+ function errorText(error) {
90
+ if (error == null)
91
+ return '';
92
+ if (typeof error === 'string')
93
+ return error;
94
+ if (typeof error === 'object') {
95
+ const withMessage = error;
96
+ const parts = [];
97
+ if (typeof withMessage.message === 'string')
98
+ parts.push(withMessage.message);
99
+ // Provider bodies are frequently nested under `cause`/`response.data`.
100
+ const cause = withMessage.cause;
101
+ if (cause && cause !== error)
102
+ parts.push(errorText(cause));
103
+ const response = withMessage.response;
104
+ if (response?.data !== undefined) {
105
+ try {
106
+ parts.push(typeof response.data === 'string' ? response.data : JSON.stringify(response.data));
107
+ }
108
+ catch {
109
+ /* best-effort */
110
+ }
111
+ }
112
+ if (parts.length > 0)
113
+ return parts.join('\n');
114
+ try {
115
+ return JSON.stringify(error);
116
+ }
117
+ catch {
118
+ return '';
119
+ }
120
+ }
121
+ return String(error);
122
+ }
123
+ // ── Learned limits ──────────────────────────────────────────────────────────
124
+ /** provider × model → the cap the provider itself named. Process-local. */
125
+ const learnedLimits = new Map();
126
+ function limitKey(provider, model) {
127
+ const p = (provider || '').trim().toLowerCase();
128
+ const m = (model || '').trim().toLowerCase();
129
+ if (!p || !m)
130
+ return null;
131
+ return `${p}::${m}`;
132
+ }
133
+ /**
134
+ * Record a provider-named output cap. Ignored when the key is incomplete
135
+ * (a bare provider or model is too coarse to clamp against) or the value is
136
+ * not a positive integer. Also clamps against any already-learned value so a
137
+ * later, larger claim cannot raise the cap back up.
138
+ */
139
+ export function rememberMaxTokensLimit(provider, model, limit) {
140
+ const key = limitKey(provider, model);
141
+ if (!key)
142
+ return;
143
+ if (!Number.isFinite(limit) || limit <= 0)
144
+ return;
145
+ const existing = learnedLimits.get(key);
146
+ const next = existing === undefined ? limit : Math.min(existing, limit);
147
+ learnedLimits.set(key, Math.floor(next));
148
+ }
149
+ /** The learned cap for provider × model, or `undefined` when none is known. */
150
+ export function knownMaxTokensLimit(provider, model) {
151
+ const key = limitKey(provider, model);
152
+ if (!key)
153
+ return undefined;
154
+ return learnedLimits.get(key);
155
+ }
156
+ /**
157
+ * Apply the learned cap to a requested value. Only ever lowers: an unlearned
158
+ * pair and an already-small request both pass through unchanged, so a caller
159
+ * that deliberately asks for less keeps its value.
160
+ */
161
+ export function clampMaxTokens(requested, provider, model) {
162
+ const limit = knownMaxTokensLimit(provider, model);
163
+ if (limit === undefined)
164
+ return requested;
165
+ if (requested === undefined)
166
+ return limit;
167
+ return Math.min(requested, limit);
168
+ }
169
+ /**
170
+ * Read a cap out of an error and remember it. Returns the parsed limit (so the
171
+ * caller can retry with it) or `null` when the error was not a cap rejection.
172
+ */
173
+ export function learnMaxTokensLimitFromError(error, provider, model) {
174
+ const limit = parseMaxTokensLimit(error);
175
+ if (limit === null)
176
+ return null;
177
+ rememberMaxTokensLimit(provider, model, limit);
178
+ return limit;
179
+ }
180
+ /** Test hook — clears the process-local table. */
181
+ export function resetLearnedMaxTokensLimits() {
182
+ learnedLimits.clear();
183
+ }
184
+ //# sourceMappingURL=provider-limits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-limits.js","sourceRoot":"","sources":["../../src/learning/provider-limits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH;;;;;GAKG;AACH,SAAS,SAAS,CAAC,IAAY;IAC7B,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;AACnE,CAAC;AAED,uEAAuE;AACvE,MAAM,mBAAmB,GAAG,qDAAqD,CAAC;AAElF,8EAA8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7B,QAA4B,EAC5B,KAAyB;IAEzB,MAAM,KAAK,GAAG,mBAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACnD,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,SAAS,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAC1C,OAAO,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;AACpC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAC1C,KAAc,EACd,QAA4B,EAC5B,KAAyB;IAEzB,MAAM,KAAK,GAAG,mBAAmB,CAAC,KAAK,CAAC,CAAC;IACzC,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,sBAAsB,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC/C,OAAO,KAAK,CAAC;AACf,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,2BAA2B;IACzC,aAAa,CAAC,KAAK,EAAE,CAAC;AACxB,CAAC"}
@@ -20,6 +20,7 @@
20
20
  * - Dashboard /api/traces endpoints (TracePanel)
21
21
  */
22
22
  import type { LLMCallFn } from '../agents/agent.js';
23
+ import { type PromptLayerDigests } from './prompt-layers.js';
23
24
  /** A compact routing snapshot captured at decision time (from AutoRouteResult). */
24
25
  export interface TraceRoutingSnapshot {
25
26
  provider: string;
@@ -64,6 +65,14 @@ export interface TraceStep {
64
65
  error?: string;
65
66
  /** Auto-router decision snapshot when the call was auto-routed. */
66
67
  routing?: TraceRoutingSnapshot;
68
+ /**
69
+ * PER-LAYER prompt digests (stable / context / volatile) + their sizes.
70
+ * The flat `promptDigest` hashes the whole thread, which grows every step —
71
+ * so it can never show whether the STABLE layer (system prompt) was
72
+ * byte-stable across steps. These three digests answer that, which is what
73
+ * makes prompt-caching regressions reviewable at all.
74
+ */
75
+ layers?: PromptLayerDigests;
67
76
  /** True when this step is a REPAIR re-prompt escalated to a stronger model
68
77
  * (v1.60.4 per-task/planner escalation — the routing snapshot then carries
69
78
  * the escalated decision at the next complexity level). */
@@ -100,6 +109,80 @@ export interface TraceOutcome {
100
109
  * instead of letting it read as work in progress.
101
110
  */
102
111
  unfulfilledPromise?: boolean;
112
+ /**
113
+ * True when this turn MUTATED the workspace (`edit_file`/`write_file`) and
114
+ * ran nothing that could observe the result (`run_terminal`/`test`/`browser`
115
+ * /`run_cli`). The edit is real but "it works" is unproven — the Trace tab
116
+ * surfaces this so an unverified change never reads as a verified one.
117
+ */
118
+ unverifiedEdit?: boolean;
119
+ /**
120
+ * True when the answer ASSERTED a completed code change while the turn was
121
+ * unverified (see `detectUnverifiedEditClaim`). This is the edit analogue of
122
+ * `unverifiedClaim` — the honesty flag for a false "I have fixed it".
123
+ */
124
+ unverifiedEditClaim?: boolean;
125
+ /**
126
+ * G13b — True when the request asked for an AUTHORED deliverable to be
127
+ * PRODUCED and the turn wrote NOTHING to disk (see
128
+ * `ToolLoopResult.undeliveredArtifact`). The reply may be excellent prose —
129
+ * the 12-page story that was composed into a chat window instead of a file —
130
+ * but the deliverable does not exist, so the Trace tab must not read it as
131
+ * finished work.
132
+ */
133
+ undeliveredArtifact?: boolean;
134
+ }
135
+ /**
136
+ * Which gate made a decision, or refused one.
137
+ *
138
+ * `confirmation` is the family the G18 audit could not see at all: a tool that
139
+ * declined to act until a human approved. `permission`/`verification`/
140
+ * `deliverable`/`promise` are the loop's own bounded nudges; `autonomy` is a
141
+ * gate that DECIDED to proceed on the request's own authorization; `budget` is
142
+ * a bound (step/continuation) being reached.
143
+ */
144
+ export type TraceGateName = 'permission' | 'verification' | 'deliverable' | 'promise' | 'confirmation' | 'workspace' | 'autonomy' | 'budget';
145
+ /**
146
+ * A NON-LLM fact about a turn: a tool call, a gate decision, or a refusal.
147
+ *
148
+ * WHY THIS IS NOT A `TraceStep`. `steps` are LLM calls — they carry a prompt
149
+ * digest, a model, tokens, and they feed `getTraceStats`. A tool call has none
150
+ * of those, and folding it in would corrupt every aggregate the Trace tab and
151
+ * the stats command already report. This is the separate, equally honest
152
+ * record: WHAT THE TURN DID, alongside what the model was asked.
153
+ *
154
+ * The gap it closes was recorded as G18: the loop engine wrote no trace at all,
155
+ * and the audit of the confirmation gates had to be done by reading code and
156
+ * driving the real tools, because "the trace store showed 0 refusals" meant
157
+ * "it cannot see refusals" — not "there were none".
158
+ */
159
+ export interface TraceEvent {
160
+ /** 1-based position within the trace's event list. */
161
+ seq: number;
162
+ /** Epoch ms when the event was recorded. */
163
+ timestamp: number;
164
+ /**
165
+ * `tool` — a tool call that actually ran (ok/error, duration, args);
166
+ * `gate` — a gate made a DECISION (nudge spent, or autonomy proceeded);
167
+ * `refusal` — a call was DECLINED (`Error:` result, confirmation gate,
168
+ * unknown/disabled tool, repeat dispatch);
169
+ * `decision` — a non-tool decision worth auditing (e.g. the provider walk
170
+ * abandoning a candidate, a loop bound being reached).
171
+ */
172
+ kind: 'tool' | 'gate' | 'refusal' | 'decision';
173
+ /** Tool name for `tool`/`refusal` events. */
174
+ tool?: string;
175
+ /** Which gate/nudge/bound this is about (see {@link TraceGateName}). */
176
+ gate?: TraceGateName;
177
+ /** One line, human-readable — the same wording the console prints. */
178
+ summary: string;
179
+ /** Bounded args preview for a tool call (what the gate actually saw). */
180
+ args?: string;
181
+ /** Bounded result/error preview (the evidence the verdict was read from). */
182
+ result?: string;
183
+ /** True when the call succeeded; false for an error or a refusal. */
184
+ ok?: boolean;
185
+ durationMs?: number;
103
186
  }
104
187
  /** A full reasoning trace — one pipeline execution. */
105
188
  export interface ReasoningTrace {
@@ -126,6 +209,21 @@ export interface ReasoningTrace {
126
209
  outcome?: TraceOutcome;
127
210
  /** LLM calls in execution order. */
128
211
  steps: TraceStep[];
212
+ /**
213
+ * Non-LLM facts about the run, in order: tool calls, gate decisions, and
214
+ * refusals (G18). Absent on traces written before this existed — readers must
215
+ * treat `undefined` as "no events were recorded", never as "none happened".
216
+ */
217
+ events?: TraceEvent[];
218
+ /**
219
+ * The FULL stable layer (system prompt), captured ONCE per trace.
220
+ * Previously every trace exposed only the first 80 characters of it, so the
221
+ * persona / tool contract / response rules were unreviewable. Capped to keep
222
+ * the trace file bounded; `systemPromptChars` records the true size.
223
+ */
224
+ systemPrompt?: string;
225
+ /** True length of the stable layer (before the storage cap). */
226
+ systemPromptChars?: number;
129
227
  }
130
228
  /** Aggregated stats over all stored traces. */
131
229
  export interface TraceStats {
@@ -139,6 +237,18 @@ export interface TraceStats {
139
237
  byAgentType: Record<string, number>;
140
238
  /** Steps by model. */
141
239
  byModel: Record<string, number>;
240
+ /**
241
+ * G18 — non-LLM facts recorded across all traces (tool calls, gate decisions,
242
+ * refusals). Counted separately from `totalSteps` on purpose: an event is not
243
+ * an LLM call, and adding it to the token/latency averages would make both
244
+ * wrong. `refusals` is the number the confirmation-gate audit could not obtain
245
+ * before this existed.
246
+ */
247
+ totalEvents: number;
248
+ /** How many of those events are refusals (declined calls). */
249
+ refusals: number;
250
+ /** How many are gate DECISIONS (a nudge spent, or autonomy proceeding). */
251
+ gateDecisions: number;
142
252
  updatedAt: number;
143
253
  }
144
254
  /** Context for withTraceCapture — everything a step needs except the call result. */
@@ -172,7 +282,18 @@ export declare function beginTrace(meta: {
172
282
  * Record one LLM call as a step in the trace. Best-effort: never throws.
173
283
  * seq is assigned automatically from the current step count.
174
284
  */
175
- export declare function recordStep(traceId: string, step: Omit<TraceStep, 'seq' | 'timestamp'>): void;
285
+ export declare function recordStep(traceId: string, step: Omit<TraceStep, 'seq' | 'timestamp'> & {
286
+ promptFull?: string;
287
+ }): void;
288
+ /**
289
+ * Record one NON-LLM event (a tool call, a gate decision, a refusal) — G18.
290
+ *
291
+ * Same contract as {@link recordStep}: best-effort, never throws, and the tail
292
+ * is kept when the cap is hit (the most recent actions are the ones an audit
293
+ * reads). The caller passes WHAT HAPPENED; `seq`/`timestamp` are assigned here
294
+ * so two recorders can never disagree about ordering.
295
+ */
296
+ export declare function recordTraceEvent(traceId: string, event: Omit<TraceEvent, 'seq' | 'timestamp'>): void;
176
297
  /**
177
298
  * Mark a trace finished (sets endedAt, durationMs, success). Idempotent: a
178
299
  * second endTrace (e.g. from a finally block after an early close) is a no-op.
@@ -188,6 +309,9 @@ export declare function buildTraceOutcome(input: {
188
309
  tools?: readonly string[];
189
310
  unverifiedActionClaim?: boolean;
190
311
  unfulfilledPromise?: boolean;
312
+ unverifiedEdit?: boolean;
313
+ unverifiedEditClaim?: boolean;
314
+ undeliveredArtifact?: boolean;
191
315
  }): TraceOutcome;
192
316
  /** Get one trace by id (null when missing). */
193
317
  export declare function getTrace(id: string): ReasoningTrace | null;
@@ -1 +1 @@
1
- {"version":3,"file":"reasoning-trace.d.ts","sourceRoot":"","sources":["../../src/learning/reasoning-trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAOH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAMpD,mFAAmF;AACnF,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,mCAAmC;AACnC,MAAM,WAAW,SAAS;IACxB,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;IAClB,mFAAmF;IACnF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uCAAuC;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,+DAA+D;IAC/D,YAAY,EAAE,MAAM,CAAC;IACrB,+DAA+D;IAC/D,aAAa,EAAE,MAAM,CAAC;I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