@cogenta/agents 0.2.1 → 0.4.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 (229) hide show
  1. package/dist/agents/builtins.d.ts +51 -0
  2. package/dist/agents/builtins.d.ts.map +1 -0
  3. package/dist/agents/builtins.js +190 -0
  4. package/dist/agents/builtins.js.map +1 -0
  5. package/dist/agents/orchestrator.d.ts +95 -0
  6. package/dist/agents/orchestrator.d.ts.map +1 -0
  7. package/dist/agents/orchestrator.js +285 -0
  8. package/dist/agents/orchestrator.js.map +1 -0
  9. package/dist/agents/store.d.ts +71 -0
  10. package/dist/agents/store.d.ts.map +1 -0
  11. package/dist/agents/store.js +211 -0
  12. package/dist/agents/store.js.map +1 -0
  13. package/dist/agents/types.d.ts +10 -0
  14. package/dist/agents/types.d.ts.map +1 -1
  15. package/dist/assist/agent-identity.d.ts +44 -0
  16. package/dist/assist/agent-identity.d.ts.map +1 -0
  17. package/dist/assist/agent-identity.js +136 -0
  18. package/dist/assist/agent-identity.js.map +1 -0
  19. package/dist/assist/chat.d.ts +2 -0
  20. package/dist/assist/chat.d.ts.map +1 -1
  21. package/dist/assist/chat.js +14 -5
  22. package/dist/assist/chat.js.map +1 -1
  23. package/dist/assist/classify.d.ts +3 -2
  24. package/dist/assist/classify.d.ts.map +1 -1
  25. package/dist/assist/classify.js +30 -11
  26. package/dist/assist/classify.js.map +1 -1
  27. package/dist/assist/faq.d.ts +3 -2
  28. package/dist/assist/faq.d.ts.map +1 -1
  29. package/dist/assist/faq.js +31 -13
  30. package/dist/assist/faq.js.map +1 -1
  31. package/dist/assist/runtime.d.ts +8 -2
  32. package/dist/assist/runtime.d.ts.map +1 -1
  33. package/dist/assist/runtime.js +2 -2
  34. package/dist/assist/runtime.js.map +1 -1
  35. package/dist/assist/toolset.d.ts +10 -0
  36. package/dist/assist/toolset.d.ts.map +1 -1
  37. package/dist/assist/toolset.js +36 -8
  38. package/dist/assist/toolset.js.map +1 -1
  39. package/dist/assist/usage.d.ts +58 -0
  40. package/dist/assist/usage.d.ts.map +1 -0
  41. package/dist/assist/usage.js +53 -0
  42. package/dist/assist/usage.js.map +1 -0
  43. package/dist/assist/writing.d.ts +10 -9
  44. package/dist/assist/writing.d.ts.map +1 -1
  45. package/dist/assist/writing.js +126 -58
  46. package/dist/assist/writing.js.map +1 -1
  47. package/dist/audit/with-audit.d.ts +13 -0
  48. package/dist/audit/with-audit.d.ts.map +1 -1
  49. package/dist/audit/with-audit.js +6 -0
  50. package/dist/audit/with-audit.js.map +1 -1
  51. package/dist/autonomy/levels.d.ts +37 -0
  52. package/dist/autonomy/levels.d.ts.map +1 -0
  53. package/dist/autonomy/levels.js +51 -0
  54. package/dist/autonomy/levels.js.map +1 -0
  55. package/dist/conversations/store.d.ts +62 -0
  56. package/dist/conversations/store.d.ts.map +1 -0
  57. package/dist/conversations/store.js +0 -0
  58. package/dist/conversations/store.js.map +1 -0
  59. package/dist/identity/context.d.ts +8 -0
  60. package/dist/identity/context.d.ts.map +1 -1
  61. package/dist/identity/context.js +19 -4
  62. package/dist/identity/context.js.map +1 -1
  63. package/dist/identity/markdown.d.ts +38 -0
  64. package/dist/identity/markdown.d.ts.map +1 -0
  65. package/dist/identity/markdown.js +85 -0
  66. package/dist/identity/markdown.js.map +1 -0
  67. package/dist/index.d.ts +56 -5
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +30 -3
  70. package/dist/index.js.map +1 -1
  71. package/dist/prompts/render.d.ts +23 -0
  72. package/dist/prompts/render.d.ts.map +1 -0
  73. package/dist/prompts/render.js +35 -0
  74. package/dist/prompts/render.js.map +1 -0
  75. package/dist/prompts/seeds.d.ts +34 -0
  76. package/dist/prompts/seeds.d.ts.map +1 -0
  77. package/dist/prompts/seeds.js +166 -0
  78. package/dist/prompts/seeds.js.map +1 -0
  79. package/dist/prompts/store.d.ts +8 -0
  80. package/dist/prompts/store.d.ts.map +1 -0
  81. package/dist/prompts/store.js +153 -0
  82. package/dist/prompts/store.js.map +1 -0
  83. package/dist/prompts/types.d.ts +51 -0
  84. package/dist/prompts/types.d.ts.map +1 -0
  85. package/dist/prompts/types.js +24 -0
  86. package/dist/prompts/types.js.map +1 -0
  87. package/dist/providers/anthropic.d.ts +21 -3
  88. package/dist/providers/anthropic.d.ts.map +1 -1
  89. package/dist/providers/anthropic.js +60 -12
  90. package/dist/providers/anthropic.js.map +1 -1
  91. package/dist/providers/catalog.d.ts +41 -0
  92. package/dist/providers/catalog.d.ts.map +1 -0
  93. package/dist/providers/catalog.js +85 -0
  94. package/dist/providers/catalog.js.map +1 -0
  95. package/dist/providers/content-parts.d.ts +12 -0
  96. package/dist/providers/content-parts.d.ts.map +1 -0
  97. package/dist/providers/content-parts.js +18 -0
  98. package/dist/providers/content-parts.js.map +1 -0
  99. package/dist/providers/defaults.d.ts +15 -0
  100. package/dist/providers/defaults.d.ts.map +1 -0
  101. package/dist/providers/defaults.js +15 -0
  102. package/dist/providers/defaults.js.map +1 -0
  103. package/dist/providers/google.d.ts +16 -3
  104. package/dist/providers/google.d.ts.map +1 -1
  105. package/dist/providers/google.js +54 -12
  106. package/dist/providers/google.js.map +1 -1
  107. package/dist/providers/openai.d.ts +32 -4
  108. package/dist/providers/openai.d.ts.map +1 -1
  109. package/dist/providers/openai.js +114 -21
  110. package/dist/providers/openai.js.map +1 -1
  111. package/dist/providers/registry.d.ts +31 -20
  112. package/dist/providers/registry.d.ts.map +1 -1
  113. package/dist/providers/registry.js +49 -7
  114. package/dist/providers/registry.js.map +1 -1
  115. package/dist/providers/request-signal.d.ts +23 -0
  116. package/dist/providers/request-signal.d.ts.map +1 -0
  117. package/dist/providers/request-signal.js +26 -0
  118. package/dist/providers/request-signal.js.map +1 -0
  119. package/dist/providers/resolve.d.ts +13 -0
  120. package/dist/providers/resolve.d.ts.map +1 -0
  121. package/dist/providers/resolve.js +30 -0
  122. package/dist/providers/resolve.js.map +1 -0
  123. package/dist/providers/store.d.ts +70 -0
  124. package/dist/providers/store.d.ts.map +1 -0
  125. package/dist/providers/store.js +308 -0
  126. package/dist/providers/store.js.map +1 -0
  127. package/dist/providers/tool-names.d.ts +9 -0
  128. package/dist/providers/tool-names.d.ts.map +1 -0
  129. package/dist/providers/tool-names.js +56 -0
  130. package/dist/providers/tool-names.js.map +1 -0
  131. package/dist/providers/types.d.ts +78 -3
  132. package/dist/providers/types.d.ts.map +1 -1
  133. package/dist/rag/reference-documents/ingest.d.ts +22 -0
  134. package/dist/rag/reference-documents/ingest.d.ts.map +1 -0
  135. package/dist/rag/reference-documents/ingest.js +69 -0
  136. package/dist/rag/reference-documents/ingest.js.map +1 -0
  137. package/dist/rag/reference-documents/store.d.ts +23 -0
  138. package/dist/rag/reference-documents/store.d.ts.map +1 -0
  139. package/dist/rag/reference-documents/store.js +140 -0
  140. package/dist/rag/reference-documents/store.js.map +1 -0
  141. package/dist/rag/reference-documents/types.d.ts +52 -0
  142. package/dist/rag/reference-documents/types.d.ts.map +1 -0
  143. package/dist/rag/reference-documents/types.js +32 -0
  144. package/dist/rag/reference-documents/types.js.map +1 -0
  145. package/dist/runtime/loop.d.ts +29 -7
  146. package/dist/runtime/loop.d.ts.map +1 -1
  147. package/dist/runtime/loop.js +200 -42
  148. package/dist/runtime/loop.js.map +1 -1
  149. package/dist/runtime/types.d.ts +4 -3
  150. package/dist/runtime/types.d.ts.map +1 -1
  151. package/dist/site-plan/analyse-brief.d.ts +8 -0
  152. package/dist/site-plan/analyse-brief.d.ts.map +1 -1
  153. package/dist/site-plan/analyse-brief.js +18 -7
  154. package/dist/site-plan/analyse-brief.js.map +1 -1
  155. package/dist/site-plan/approval.d.ts +2 -2
  156. package/dist/site-plan/approval.d.ts.map +1 -1
  157. package/dist/site-plan/approval.js +34 -4
  158. package/dist/site-plan/approval.js.map +1 -1
  159. package/dist/site-plan/content-model.d.ts +14 -0
  160. package/dist/site-plan/content-model.d.ts.map +1 -1
  161. package/dist/site-plan/content-model.js +52 -8
  162. package/dist/site-plan/content-model.js.map +1 -1
  163. package/dist/site-plan/demo-content.js +2 -3
  164. package/dist/site-plan/demo-content.js.map +1 -1
  165. package/dist/site-plan/propose-plan.d.ts +10 -0
  166. package/dist/site-plan/propose-plan.d.ts.map +1 -1
  167. package/dist/site-plan/propose-plan.js +25 -1
  168. package/dist/site-plan/propose-plan.js.map +1 -1
  169. package/dist/site-plan/site-context.d.ts +81 -0
  170. package/dist/site-plan/site-context.d.ts.map +1 -0
  171. package/dist/site-plan/site-context.js +76 -0
  172. package/dist/site-plan/site-context.js.map +1 -0
  173. package/dist/site-plan/skin-candidates.d.ts +7 -0
  174. package/dist/site-plan/skin-candidates.d.ts.map +1 -1
  175. package/dist/site-plan/skin-candidates.js +6 -0
  176. package/dist/site-plan/skin-candidates.js.map +1 -1
  177. package/dist/site-plan/structural-gaps.d.ts +32 -0
  178. package/dist/site-plan/structural-gaps.d.ts.map +1 -0
  179. package/dist/site-plan/structural-gaps.js +77 -0
  180. package/dist/site-plan/structural-gaps.js.map +1 -0
  181. package/dist/site-plan/types.d.ts +7 -0
  182. package/dist/site-plan/types.d.ts.map +1 -1
  183. package/dist/skills/frontmatter.d.ts +19 -1
  184. package/dist/skills/frontmatter.d.ts.map +1 -1
  185. package/dist/skills/frontmatter.js +29 -5
  186. package/dist/skills/frontmatter.js.map +1 -1
  187. package/dist/skills/library.d.ts +133 -0
  188. package/dist/skills/library.d.ts.map +1 -0
  189. package/dist/skills/library.js +332 -0
  190. package/dist/skills/library.js.map +1 -0
  191. package/dist/skills/types.d.ts +8 -1
  192. package/dist/skills/types.d.ts.map +1 -1
  193. package/dist/skin/generate.d.ts +10 -0
  194. package/dist/skin/generate.d.ts.map +1 -1
  195. package/dist/skin/generate.js +43 -4
  196. package/dist/skin/generate.js.map +1 -1
  197. package/dist/theme-creator/propose-theme.d.ts +77 -0
  198. package/dist/theme-creator/propose-theme.d.ts.map +1 -0
  199. package/dist/theme-creator/propose-theme.js +228 -0
  200. package/dist/theme-creator/propose-theme.js.map +1 -0
  201. package/dist/tools/core/agent-delegate.d.ts +8 -5
  202. package/dist/tools/core/agent-delegate.d.ts.map +1 -1
  203. package/dist/tools/core/agent-delegate.js +16 -6
  204. package/dist/tools/core/agent-delegate.js.map +1 -1
  205. package/dist/tools/core/content-browse.d.ts +74 -0
  206. package/dist/tools/core/content-browse.d.ts.map +1 -0
  207. package/dist/tools/core/content-browse.js +63 -0
  208. package/dist/tools/core/content-browse.js.map +1 -0
  209. package/dist/tools/core/content-schema.d.ts +86 -0
  210. package/dist/tools/core/content-schema.d.ts.map +1 -0
  211. package/dist/tools/core/content-schema.js +83 -0
  212. package/dist/tools/core/content-schema.js.map +1 -0
  213. package/dist/tools/core/deps-scan.d.ts +25 -0
  214. package/dist/tools/core/deps-scan.d.ts.map +1 -0
  215. package/dist/tools/core/deps-scan.js +85 -0
  216. package/dist/tools/core/deps-scan.js.map +1 -0
  217. package/dist/tools/core/media.d.ts +18 -2
  218. package/dist/tools/core/media.d.ts.map +1 -1
  219. package/dist/tools/core/media.js +8 -2
  220. package/dist/tools/core/media.js.map +1 -1
  221. package/dist/tools/core/not-found-log.d.ts +44 -0
  222. package/dist/tools/core/not-found-log.d.ts.map +1 -0
  223. package/dist/tools/core/not-found-log.js +32 -0
  224. package/dist/tools/core/not-found-log.js.map +1 -0
  225. package/dist/tools/core/redirects.d.ts +51 -0
  226. package/dist/tools/core/redirects.d.ts.map +1 -0
  227. package/dist/tools/core/redirects.js +50 -0
  228. package/dist/tools/core/redirects.js.map +1 -0
  229. package/package.json +6 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/prompts/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,gMAAgM;AAChM,eAAO,MAAM,0BAA0B,YACrC,MAAM,EACN,aAAa,EACb,KAAK,EACL,YAAY,EACZ,OAAO,EACP,OAAO,CACC,CAAA;AACV,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,0BAA0B,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 /**
2
+ * Fiche 45 — Prompt Settings, the shared template library every utility
3
+ * prompt in `@cogenta/agents` reads from. Same "real but local" tier as
4
+ * `agents/store.ts`/`skills/library.ts` (R1): a file on disk, no external
5
+ * service, no new dependency.
6
+ *
7
+ * A `PromptTemplate` is deliberately **not** a `SkillMetadata`/`AgentSkill`:
8
+ * a skill is a whole piece of context an agent loads ("how this site wants
9
+ * content written"); a prompt template is the single instruction line one
10
+ * specific tool call sends the model, with `{{placeholder}}` slots the tool
11
+ * fills in at call time (see `render.ts`). Different shape, different
12
+ * lifecycle, so a different store rather than overloading one interface for
13
+ * both.
14
+ */
15
+ /** Suggested vocabulary for the admin's category picker. The field itself stays a plain string — an open list, not a closed taxonomy (fiche 45 §3 task 1: "texte/traduction/agent/image/…"). */
16
+ export const PROMPT_TEMPLATE_CATEGORIES = [
17
+ 'text',
18
+ 'translation',
19
+ 'seo',
20
+ 'moderation',
21
+ 'agent',
22
+ 'image',
23
+ ];
24
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/prompts/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,gMAAgM;AAChM,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,MAAM;IACN,aAAa;IACb,KAAK;IACL,YAAY;IACZ,OAAO;IACP,OAAO;CACC,CAAA"}
@@ -2,6 +2,13 @@ import type { ChatRequest, ChatResponse, ProviderClient } from './types.js';
2
2
  type AnthropicContentBlock = {
3
3
  readonly type: 'text';
4
4
  readonly text: string;
5
+ } | {
6
+ readonly type: 'image';
7
+ readonly source: {
8
+ readonly type: 'base64';
9
+ readonly media_type: string;
10
+ readonly data: string;
11
+ };
5
12
  } | {
6
13
  readonly type: 'tool_use';
7
14
  readonly id: string;
@@ -36,16 +43,27 @@ interface AnthropicResponseBody {
36
43
  readonly output_tokens: number;
37
44
  };
38
45
  }
39
- /** Pure — no network. The whole reason this is separate from `createAnthropicClient` is to unit-test the mapping without a live call. */
40
- export declare function buildAnthropicRequest(request: ChatRequest): AnthropicRequestBody;
46
+ /**
47
+ * Pure no network. The whole reason this is separate from
48
+ * `createAnthropicClient` is to unit-test the mapping without a live call.
49
+ * `fallbackMaxTokens` is the client's own resolved `maxOutputTokens` (the
50
+ * admin's per-provider value, or the built-in floor) — applied only when
51
+ * `request.maxTokens` itself is absent, never overriding an explicit
52
+ * per-call value.
53
+ */
54
+ export declare function buildAnthropicRequest(request: ChatRequest, fallbackMaxTokens?: number): AnthropicRequestBody;
41
55
  /** Pure — no network. */
42
- export declare function parseAnthropicResponse(body: AnthropicResponseBody): ChatResponse;
56
+ export declare function parseAnthropicResponse(body: AnthropicResponseBody, decodeToolName?: (wire: string) => string): ChatResponse;
43
57
  export interface AnthropicClientConfig {
44
58
  readonly apiKey: string;
45
59
  readonly model: string;
46
60
  /** Overridable for tests — never for anything else. */
47
61
  readonly baseUrl?: string;
48
62
  readonly fetchImpl?: typeof fetch;
63
+ /** See `ProviderClient.maxOutputTokens`/`requestTimeoutMs`/`maxCorrectionAttempts`. */
64
+ readonly maxOutputTokens?: number;
65
+ readonly requestTimeoutMs?: number;
66
+ readonly maxCorrectionAttempts?: number;
49
67
  }
50
68
  /**
51
69
  * The API key is injected here, at the runtime boundary, from
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,WAAW,EACX,YAAY,EACZ,cAAc,EAGf,MAAM,YAAY,CAAA;AAKnB,KAAK,qBAAqB,GACtB;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAChD;IACE,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAA;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,Q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CAmBd;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,uDAAuD;IACvD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,KAAK,CAAA;IACjC,uFAAuF;IACvF,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;IAClC,QAAQ,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAA;CACxC;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,qBAAqB,GAAG,cAAc,CA+DnF"}
@@ -1,4 +1,8 @@
1
1
  import { CogentaError } from '@cogenta/core';
2
+ import { textOnlyContent } from './content-parts.js';
3
+ import { FALLBACK_MAX_OUTPUT_TOKENS } from './defaults.js';
4
+ import { DEFAULT_PROVIDER_REQUEST_TIMEOUT_MS, requestSignalWithTimeout } from './request-signal.js';
5
+ import { createToolNameDecoder, encodeToolName } from './tool-names.js';
2
6
  const API_VERSION = '2023-06-01';
3
7
  const DEFAULT_BASE_URL = 'https://api.anthropic.com/v1/messages';
4
8
  const STOP_REASON = {
@@ -19,16 +23,36 @@ function toAnthropicMessage(message) {
19
23
  return {
20
24
  role: 'user',
21
25
  content: [
22
- { type: 'tool_result', tool_use_id: message.toolCallId, content: message.content ?? '' },
26
+ {
27
+ type: 'tool_result',
28
+ tool_use_id: message.toolCallId,
29
+ content: textOnlyContent(message.content) ?? '',
30
+ },
23
31
  ],
24
32
  };
25
33
  }
26
34
  const role = message.role === 'assistant' ? 'assistant' : 'user';
27
35
  const blocks = [];
28
- if (message.content !== undefined)
36
+ if (typeof message.content === 'string') {
29
37
  blocks.push({ type: 'text', text: message.content });
38
+ }
39
+ else if (message.content !== undefined) {
40
+ for (const part of message.content) {
41
+ blocks.push(part.type === 'text'
42
+ ? { type: 'text', text: part.text }
43
+ : {
44
+ type: 'image',
45
+ source: { type: 'base64', media_type: part.mediaType, data: part.data },
46
+ });
47
+ }
48
+ }
30
49
  for (const call of message.toolCalls ?? []) {
31
- blocks.push({ type: 'tool_use', id: call.id, name: call.name, input: call.input });
50
+ blocks.push({
51
+ type: 'tool_use',
52
+ id: call.id,
53
+ name: encodeToolName(call.name),
54
+ input: call.input,
55
+ });
32
56
  }
33
57
  // A plain string is equivalent to a single text block and reads better in
34
58
  // request logs — only messages that carry tool content need the array form.
@@ -37,18 +61,25 @@ function toAnthropicMessage(message) {
37
61
  }
38
62
  return { role, content: blocks };
39
63
  }
40
- /** Pure — no network. The whole reason this is separate from `createAnthropicClient` is to unit-test the mapping without a live call. */
41
- export function buildAnthropicRequest(request) {
64
+ /**
65
+ * Pure — no network. The whole reason this is separate from
66
+ * `createAnthropicClient` is to unit-test the mapping without a live call.
67
+ * `fallbackMaxTokens` is the client's own resolved `maxOutputTokens` (the
68
+ * admin's per-provider value, or the built-in floor) — applied only when
69
+ * `request.maxTokens` itself is absent, never overriding an explicit
70
+ * per-call value.
71
+ */
72
+ export function buildAnthropicRequest(request, fallbackMaxTokens = FALLBACK_MAX_OUTPUT_TOKENS) {
42
73
  return {
43
74
  model: request.model,
44
- max_tokens: request.maxTokens,
75
+ max_tokens: request.maxTokens ?? fallbackMaxTokens,
45
76
  ...(request.system === undefined ? {} : { system: request.system }),
46
77
  messages: request.messages.map(toAnthropicMessage),
47
78
  ...(request.tools === undefined
48
79
  ? {}
49
80
  : {
50
81
  tools: request.tools.map((tool) => ({
51
- name: tool.name,
82
+ name: encodeToolName(tool.name),
52
83
  description: tool.description,
53
84
  input_schema: tool.inputSchema,
54
85
  })),
@@ -57,7 +88,7 @@ export function buildAnthropicRequest(request) {
57
88
  };
58
89
  }
59
90
  /** Pure — no network. */
60
- export function parseAnthropicResponse(body) {
91
+ export function parseAnthropicResponse(body, decodeToolName = (wire) => wire) {
61
92
  const textParts = [];
62
93
  const toolCalls = [];
63
94
  for (const block of body.content) {
@@ -66,7 +97,7 @@ export function parseAnthropicResponse(body) {
66
97
  else if (block.type === 'tool_use') {
67
98
  toolCalls.push({
68
99
  id: block.id,
69
- name: block.name,
100
+ name: decodeToolName(block.name),
70
101
  input: (block.input ?? {}),
71
102
  });
72
103
  }
@@ -86,10 +117,19 @@ export function parseAnthropicResponse(body) {
86
117
  export function createAnthropicClient(config) {
87
118
  const doFetch = config.fetchImpl ?? fetch;
88
119
  const url = config.baseUrl ?? DEFAULT_BASE_URL;
120
+ const maxOutputTokens = config.maxOutputTokens ?? FALLBACK_MAX_OUTPUT_TOKENS;
121
+ const requestTimeoutMs = config.requestTimeoutMs ?? DEFAULT_PROVIDER_REQUEST_TIMEOUT_MS;
89
122
  return {
90
123
  name: 'anthropic',
91
124
  model: config.model,
125
+ supportsVision: true,
126
+ maxOutputTokens,
127
+ requestTimeoutMs,
128
+ ...(config.maxCorrectionAttempts === undefined
129
+ ? {}
130
+ : { maxCorrectionAttempts: config.maxCorrectionAttempts }),
92
131
  async chat(request, options) {
132
+ const signal = requestSignalWithTimeout(options?.signal, requestTimeoutMs);
93
133
  const response = await doFetch(url, {
94
134
  method: 'POST',
95
135
  headers: {
@@ -97,9 +137,17 @@ export function createAnthropicClient(config) {
97
137
  'x-api-key': config.apiKey,
98
138
  'anthropic-version': API_VERSION,
99
139
  },
100
- body: JSON.stringify(buildAnthropicRequest(request)),
101
- ...(options?.signal === undefined ? {} : { signal: options.signal }),
140
+ body: JSON.stringify(buildAnthropicRequest(request, maxOutputTokens)),
141
+ signal,
102
142
  }).catch((cause) => {
143
+ if (signal.aborted && options?.signal?.aborted !== true) {
144
+ throw new CogentaError({
145
+ code: 'PROVIDER_REQUEST_FAILED',
146
+ message: 'Anthropic did not answer in time.',
147
+ hint: 'The vendor may be slow or unreachable right now; retry, or check its status page.',
148
+ cause,
149
+ });
150
+ }
103
151
  throw new CogentaError({
104
152
  code: 'PROVIDER_REQUEST_FAILED',
105
153
  message: 'The request to Anthropic could not be sent.',
@@ -123,7 +171,7 @@ export function createAnthropicClient(config) {
123
171
  });
124
172
  }
125
173
  const body = (await response.json());
126
- return parseAnthropicResponse(body);
174
+ return parseAnthropicResponse(body, createToolNameDecoder(request));
127
175
  },
128
176
  };
129
177
  }
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.js","sourceRoot":"","sources":["../../src/providers/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAW5C,MAAM,WAAW,GAAG,YAAY,CAAA;AAChC,MAAM,gBAAgB,GAAG,uCAAuC,CAAA;AAoChE,MAAM,WAAW,GAA6D;IAC5E,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,eAAe;IAC9B,QAAQ,EAAE,UAAU;CACrB,CAAA;AAED,SAAS,kBAAkB,CAAC,OAAoB;IAC9C,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC5B,IAAI,OAAO,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;YACrC,MAAM,IAAI,YAAY,CAAC;gBACrB,IAAI,EAAE,2BAA2B;gBACjC,OAAO,EAAE,gDAAgD;gBACzD,IAAI,EAAE,6DAA6D;aACpE,CAAC,CAAA;QACJ,CAAC;QACD,OAAO;YACL,IAAI,EAAE,MAAM;YACZ,OAAO,EAAE;gBACP,EAAE,IAAI,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,EAAE;aACzF;SACF,CAAA;IACH,CAAC;IAED,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,KAAK,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAA;IAChE,MAAM,MAAM,GAA4B,EAAE,CAAA;IAC1C,IAAI,OAAO,CAAC,OAAO,KAAK,SAAS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M,KAAK,GAAG,EAAE,CAAC;gBAC5B,MAAM,IAAI,YAAY,CAAC;oBACrB,IAAI,EAAE,uBAAuB;oBAC7B,OAAO,EAAE,sCAAsC;oBAC/C,IAAI,EAAE,2DAA2D;iBAClE,CAAC,CAAA;YACJ,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,MAAM,IAAI,YAAY,CAAC;oBACrB,IAAI,EAAE,yBAAyB;oBAC/B,OAAO,EAAE,6BAA6B,QAAQ,CAAC,MAAM,GAAG;oBACxD,IAAI,EAAE,kDAAkD;oBACxD,OAAO,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE;iBACrC,CAAC,CAAA;YACJ,CAAC;YAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAA0B,CAAA;YAC7D,OAAO,sBAAsB,CAAC,IAAI,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAC,CAAA;QACrE,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Fiche 56 — the catalog of LLM providers this build knows how to talk to,
3
+ * as pure data. `registry.ts`'s `createProviderRegistry` is the only reader
4
+ * that matters functionally: an entry with `wireFormat: 'openai-compatible'`
5
+ * reuses `createOpenAiClient` completely unmodified, only pointed at a
6
+ * different `defaultBaseUrl` — this is the "zero new network code" the fiche
7
+ * asks for. OpenRouter, DeepSeek, Qwen (DashScope's compatible mode) and GLM
8
+ * (Zhipu/Z.ai) all speak the OpenAI Chat Completions wire format at their own
9
+ * URL; Anthropic and Google keep their own native adapters (different wire
10
+ * formats), listed here only so the admin's catalog screen has one list to
11
+ * render rather than three built-ins plus four extras.
12
+ *
13
+ * `knownModels` is a curated starting point for the admin's model picker,
14
+ * not an exhaustive or authoritative list — every vendor adds and retires
15
+ * models on its own schedule, and this list will drift the moment it is
16
+ * written (verified against each vendor's docs as of 2026-08, the ids most
17
+ * likely to still resolve at read time). The "custom model" text field
18
+ * (`ProviderConfigInput.model` — already free text before this fiche) is
19
+ * what actually lets an operator use anything a vendor ships tomorrow
20
+ * without a code change here.
21
+ */
22
+ export type ProviderWireFormat = 'openai-compatible' | 'anthropic' | 'google';
23
+ export interface ProviderCatalogEntry {
24
+ readonly id: string;
25
+ readonly label: string;
26
+ readonly wireFormat: ProviderWireFormat;
27
+ /**
28
+ * The full chat-completions URL this vendor's endpoint answers at — this
29
+ * codebase's `baseUrl` is always a complete URL, never a prefix a client
30
+ * appends to (see `openai.ts`'s own `DEFAULT_BASE_URL`). Present on every
31
+ * entry, including the native Anthropic/Google ones, purely as
32
+ * admin-facing documentation of where a request actually goes; only the
33
+ * `openai-compatible` entries feed it to `createOpenAiClient` when an
34
+ * operator has not overridden `baseUrl` themselves.
35
+ */
36
+ readonly defaultBaseUrl: string;
37
+ readonly knownModels: readonly string[];
38
+ }
39
+ export declare const KNOWN_PROVIDER_CATALOG: readonly ProviderCatalogEntry[];
40
+ export declare function findProviderCatalogEntry(id: string): ProviderCatalogEntry | undefined;
41
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/providers/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,MAAM,MAAM,kBAAkB,GAAG,mBAAmB,GAAG,WAAW,GAAG,QAAQ,CAAA;AAE7E,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,UAAU,EAAE,kBAAkB,CAAA;IACvC;;;;;;;;OAQG;IACH,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAA;CACxC;AAED,eAAO,MAAM,sBAAsB,EAAE,SAAS,oBAAoB,EA2DjE,CAAA;AAED,wBAAgB,wBAAwB,CAAC,EAAE,EAAE,MAAM,GAAG,oBAAoB,GAAG,SAAS,CAErF"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Fiche 56 — the catalog of LLM providers this build knows how to talk to,
3
+ * as pure data. `registry.ts`'s `createProviderRegistry` is the only reader
4
+ * that matters functionally: an entry with `wireFormat: 'openai-compatible'`
5
+ * reuses `createOpenAiClient` completely unmodified, only pointed at a
6
+ * different `defaultBaseUrl` — this is the "zero new network code" the fiche
7
+ * asks for. OpenRouter, DeepSeek, Qwen (DashScope's compatible mode) and GLM
8
+ * (Zhipu/Z.ai) all speak the OpenAI Chat Completions wire format at their own
9
+ * URL; Anthropic and Google keep their own native adapters (different wire
10
+ * formats), listed here only so the admin's catalog screen has one list to
11
+ * render rather than three built-ins plus four extras.
12
+ *
13
+ * `knownModels` is a curated starting point for the admin's model picker,
14
+ * not an exhaustive or authoritative list — every vendor adds and retires
15
+ * models on its own schedule, and this list will drift the moment it is
16
+ * written (verified against each vendor's docs as of 2026-08, the ids most
17
+ * likely to still resolve at read time). The "custom model" text field
18
+ * (`ProviderConfigInput.model` — already free text before this fiche) is
19
+ * what actually lets an operator use anything a vendor ships tomorrow
20
+ * without a code change here.
21
+ */
22
+ export const KNOWN_PROVIDER_CATALOG = [
23
+ {
24
+ id: 'anthropic',
25
+ label: 'Anthropic',
26
+ wireFormat: 'anthropic',
27
+ defaultBaseUrl: 'https://api.anthropic.com/v1/messages',
28
+ knownModels: ['claude-opus-5', 'claude-sonnet-5', 'claude-haiku-4-5'],
29
+ },
30
+ {
31
+ id: 'openai',
32
+ label: 'OpenAI',
33
+ wireFormat: 'openai-compatible',
34
+ defaultBaseUrl: 'https://api.openai.com/v1/chat/completions',
35
+ knownModels: ['gpt-5.2-chat-latest', 'gpt-5', 'gpt-5-mini'],
36
+ },
37
+ {
38
+ id: 'google',
39
+ label: 'Google',
40
+ wireFormat: 'google',
41
+ defaultBaseUrl: 'https://generativelanguage.googleapis.com/v1beta/models',
42
+ knownModels: ['gemini-3.1-pro', 'gemini-3.7-flash', 'gemini-2.5-flash-lite'],
43
+ },
44
+ // The four below are what fiche 56 actually adds: no new adapter, only a
45
+ // catalog entry pointing `openai-compatible` at a different vendor.
46
+ {
47
+ id: 'openrouter',
48
+ label: 'OpenRouter',
49
+ wireFormat: 'openai-compatible',
50
+ defaultBaseUrl: 'https://openrouter.ai/api/v1/chat/completions',
51
+ knownModels: [
52
+ 'openai/gpt-5.2-chat-latest',
53
+ 'anthropic/claude-sonnet-5',
54
+ 'google/gemini-3.1-pro',
55
+ ],
56
+ },
57
+ {
58
+ id: 'deepseek',
59
+ label: 'DeepSeek',
60
+ wireFormat: 'openai-compatible',
61
+ defaultBaseUrl: 'https://api.deepseek.com/chat/completions',
62
+ knownModels: ['deepseek-v4-pro', 'deepseek-v4-flash'],
63
+ },
64
+ {
65
+ id: 'qwen',
66
+ label: 'Qwen (DashScope)',
67
+ wireFormat: 'openai-compatible',
68
+ // The international (Singapore) region — the one DashScope's own docs
69
+ // lead with. An operator on the China or US region overrides `baseUrl`
70
+ // from the admin form, the same way any custom endpoint does.
71
+ defaultBaseUrl: 'https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions',
72
+ knownModels: ['qwen3-max', 'qwen-plus', 'qwen-turbo'],
73
+ },
74
+ {
75
+ id: 'glm',
76
+ label: 'GLM (Zhipu / Z.ai)',
77
+ wireFormat: 'openai-compatible',
78
+ defaultBaseUrl: 'https://api.z.ai/api/openai/v1/chat/completions',
79
+ knownModels: ['glm-4.7', 'glm-4.6', 'glm-4.5-flash'],
80
+ },
81
+ ];
82
+ export function findProviderCatalogEntry(id) {
83
+ return KNOWN_PROVIDER_CATALOG.find((entry) => entry.id === id);
84
+ }
85
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/providers/catalog.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;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AE,mBAAmB;QAC/B,cAAc,EAAE,iDAAiD;QACjE,WAAW,EAAE,CAAC,SAAS,EAAE,SAAS,EAAE,eAAe,CAAC;KACrD;CACF,CAAA;AAED,MAAM,UAAU,wBAAwB,CAAC,EAAU;IACjD,OAAO,sBAAsB,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;AAChE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { ChatContentPart } from './types.js';
2
+ /**
3
+ * Extracts the text of a message's `content`, dropping any image parts —
4
+ * used wherever a vendor's wire format only ever accepts a string (tool
5
+ * results, function responses). Every existing caller passes a plain
6
+ * string here already, so this is the identity function for them; an
7
+ * array of `ChatContentPart` (not something the runtime produces for a
8
+ * `tool`-role message today) degrades to its text parts joined together
9
+ * rather than failing to compile or throwing.
10
+ */
11
+ export declare function textOnlyContent(content: string | readonly ChatContentPart[] | undefined): string | undefined;
12
+ //# sourceMappingURL=content-parts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-parts.d.ts","sourceRoot":"","sources":["../../src/providers/content-parts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAEjD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,MAAM,GAAG,SAAS,eAAe,EAAE,GAAG,SAAS,GACvD,MAAM,GAAG,SAAS,CAMpB"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Extracts the text of a message's `content`, dropping any image parts —
3
+ * used wherever a vendor's wire format only ever accepts a string (tool
4
+ * results, function responses). Every existing caller passes a plain
5
+ * string here already, so this is the identity function for them; an
6
+ * array of `ChatContentPart` (not something the runtime produces for a
7
+ * `tool`-role message today) degrades to its text parts joined together
8
+ * rather than failing to compile or throwing.
9
+ */
10
+ export function textOnlyContent(content) {
11
+ if (content === undefined || typeof content === 'string')
12
+ return content;
13
+ return content
14
+ .filter((part) => part.type === 'text')
15
+ .map((part) => part.text)
16
+ .join('');
17
+ }
18
+ //# sourceMappingURL=content-parts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-parts.js","sourceRoot":"","sources":["../../src/providers/content-parts.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAwD;IAExD,IAAI,OAAO,KAAK,SAAS,IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,OAAO,CAAA;IACxE,OAAO,OAAO;SACX,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC;SACtC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC;SACxB,IAAI,CAAC,EAAE,CAAC,CAAA;AACb,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Built-in fallbacks, used only when an admin has not set the matching
3
+ * per-provider value from `/admin/providers`
4
+ * (`ProviderConfigStore`'s `maxOutputTokens`/`requestTimeoutMs`/
5
+ * `maxCorrectionAttempts`) — never picked over an admin's own choice, since
6
+ * only the admin knows which model they configured and what it actually
7
+ * needs. `8000`/`3` match the values a real, reproduced failure against a
8
+ * reasoning-tier model (DeepSeek's `deepseek-v4-flash`) already forced this
9
+ * codebase to converge on independently in more than one call site before
10
+ * this file existed — kept here as the one shared floor instead of staying
11
+ * duplicated per adapter.
12
+ */
13
+ export declare const FALLBACK_MAX_OUTPUT_TOKENS = 8000;
14
+ export declare const FALLBACK_MAX_CORRECTION_ATTEMPTS = 3;
15
+ //# sourceMappingURL=defaults.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/providers/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,OAAO,CAAA;AAC9C,eAAO,MAAM,gCAAgC,IAAI,CAAA"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Built-in fallbacks, used only when an admin has not set the matching
3
+ * per-provider value from `/admin/providers`
4
+ * (`ProviderConfigStore`'s `maxOutputTokens`/`requestTimeoutMs`/
5
+ * `maxCorrectionAttempts`) — never picked over an admin's own choice, since
6
+ * only the admin knows which model they configured and what it actually
7
+ * needs. `8000`/`3` match the values a real, reproduced failure against a
8
+ * reasoning-tier model (DeepSeek's `deepseek-v4-flash`) already forced this
9
+ * codebase to converge on independently in more than one call site before
10
+ * this file existed — kept here as the one shared floor instead of staying
11
+ * duplicated per adapter.
12
+ */
13
+ export const FALLBACK_MAX_OUTPUT_TOKENS = 8000;
14
+ export const FALLBACK_MAX_CORRECTION_ATTEMPTS = 3;
15
+ //# sourceMappingURL=defaults.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/providers/defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,IAAI,CAAA;AAC9C,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,CAAA"}
@@ -1,6 +1,11 @@
1
1
  import type { ChatRequest, ChatResponse, ProviderClient } from './types.js';
2
2
  type GooglePart = {
3
3
  readonly text: string;
4
+ } | {
5
+ readonly inlineData: {
6
+ readonly mimeType: string;
7
+ readonly data: string;
8
+ };
4
9
  } | {
5
10
  readonly functionCall: {
6
11
  readonly name: string;
@@ -47,15 +52,23 @@ interface GoogleResponseBody {
47
52
  readonly candidatesTokenCount: number;
48
53
  };
49
54
  }
55
+ /**
56
+ * Pure — no network. `fallbackMaxTokens` is the client's own resolved
57
+ * `maxOutputTokens` (the admin's per-provider value, or the built-in floor)
58
+ * — applied only when `request.maxTokens` itself is absent.
59
+ */
60
+ export declare function buildGoogleRequest(request: ChatRequest, fallbackMaxTokens?: number): GoogleRequestBody;
50
61
  /** Pure — no network. */
51
- export declare function buildGoogleRequest(request: ChatRequest): GoogleRequestBody;
52
- /** Pure — no network. */
53
- export declare function parseGoogleResponse(body: GoogleResponseBody): ChatResponse;
62
+ export declare function parseGoogleResponse(body: GoogleResponseBody, decodeToolName?: (wire: string) => string): ChatResponse;
54
63
  export interface GoogleClientConfig {
55
64
  readonly apiKey: string;
56
65
  readonly model: string;
57
66
  readonly baseUrl?: string;
58
67
  readonly fetchImpl?: typeof fetch;
68
+ /** See `ProviderClient.maxOutputTokens`/`requestTimeoutMs`/`maxCorrectionAttempts`. */
69
+ readonly maxOutputTokens?: number;
70
+ readonly requestTimeoutMs?: number;
71
+ readonly maxCorrectionAttempts?: number;
59
72
  }
60
73
  /** API key injected at the runtime boundary — never in a prompt or tool input (rule R7). */
61
74
  export declare function createGoogleClient(config: GoogleClientConfig): ProviderClient;
@@ -1 +1 @@
1
- {"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/providers/google.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,WAAW,EACX,YAAY,EACZ,cAAc,EAGf,MAAM,YAAY,CAAA;AAInB,KAAK,UAAU,GACX;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GACzB;IACE,QAAQ,CAAC,YAAY,EAAE;QACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;QACrB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;KACjD,CAAA;CACF,GACD;IACE,QAAQ,CAAC,gBAAgB,EAAE;QACzB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;QACrB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAA;KACrD,CAAA;CACF,CAAA;AAEL,UAAU,aAAa;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAA;IAC/B,QAAQ,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,CAAA;CAC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