@cogitator-ai/core 0.23.0 → 0.24.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 (120) hide show
  1. package/README.md +79 -0
  2. package/dist/agent-tool.d.ts +7 -1
  3. package/dist/agent-tool.d.ts.map +1 -1
  4. package/dist/agent-tool.js +4 -1
  5. package/dist/agent-tool.js.map +1 -1
  6. package/dist/agent.d.ts +6 -25
  7. package/dist/agent.d.ts.map +1 -1
  8. package/dist/agent.js +18 -3
  9. package/dist/agent.js.map +1 -1
  10. package/dist/cogitator/handoffs.d.ts +14 -0
  11. package/dist/cogitator/handoffs.d.ts.map +1 -0
  12. package/dist/cogitator/handoffs.js +53 -0
  13. package/dist/cogitator/handoffs.js.map +1 -0
  14. package/dist/cogitator/prompts.d.ts +69 -0
  15. package/dist/cogitator/prompts.d.ts.map +1 -0
  16. package/dist/cogitator/prompts.js +149 -0
  17. package/dist/cogitator/prompts.js.map +1 -0
  18. package/dist/cogitator/run-checkpoints.d.ts +20 -0
  19. package/dist/cogitator/run-checkpoints.d.ts.map +1 -0
  20. package/dist/cogitator/run-checkpoints.js +67 -0
  21. package/dist/cogitator/run-checkpoints.js.map +1 -0
  22. package/dist/cogitator/streaming.d.ts +9 -7
  23. package/dist/cogitator/streaming.d.ts.map +1 -1
  24. package/dist/cogitator/streaming.js +12 -1
  25. package/dist/cogitator/streaming.js.map +1 -1
  26. package/dist/cogitator/tool-executor.d.ts +1 -1
  27. package/dist/cogitator/tool-executor.d.ts.map +1 -1
  28. package/dist/cogitator/tool-executor.js +2 -2
  29. package/dist/cogitator/tool-executor.js.map +1 -1
  30. package/dist/constitutional/constitutional-ai.d.ts +7 -1
  31. package/dist/constitutional/constitutional-ai.d.ts.map +1 -1
  32. package/dist/constitutional/constitutional-ai.js +6 -2
  33. package/dist/constitutional/constitutional-ai.js.map +1 -1
  34. package/dist/constitutional/tool-guard.d.ts +3 -1
  35. package/dist/constitutional/tool-guard.d.ts.map +1 -1
  36. package/dist/constitutional/tool-guard.js +2 -2
  37. package/dist/constitutional/tool-guard.js.map +1 -1
  38. package/dist/index.d.ts +5 -0
  39. package/dist/index.d.ts.map +1 -1
  40. package/dist/index.js +4 -0
  41. package/dist/index.js.map +1 -1
  42. package/dist/learning/postgres-trace-store.d.ts +5 -1
  43. package/dist/learning/postgres-trace-store.d.ts.map +1 -1
  44. package/dist/learning/postgres-trace-store.js +23 -0
  45. package/dist/learning/postgres-trace-store.js.map +1 -1
  46. package/dist/learning/prompt-stores.d.ts +26 -0
  47. package/dist/learning/prompt-stores.d.ts.map +1 -0
  48. package/dist/learning/prompt-stores.js +97 -0
  49. package/dist/learning/prompt-stores.js.map +1 -0
  50. package/dist/llm/anthropic-thinking.d.ts +29 -0
  51. package/dist/llm/anthropic-thinking.d.ts.map +1 -0
  52. package/dist/llm/anthropic-thinking.js +100 -0
  53. package/dist/llm/anthropic-thinking.js.map +1 -0
  54. package/dist/llm/anthropic.d.ts +12 -0
  55. package/dist/llm/anthropic.d.ts.map +1 -1
  56. package/dist/llm/anthropic.js +138 -85
  57. package/dist/llm/anthropic.js.map +1 -1
  58. package/dist/llm/bedrock.d.ts.map +1 -1
  59. package/dist/llm/bedrock.js +136 -39
  60. package/dist/llm/bedrock.js.map +1 -1
  61. package/dist/llm/claude-models.d.ts +23 -0
  62. package/dist/llm/claude-models.d.ts.map +1 -1
  63. package/dist/llm/claude-models.js +50 -0
  64. package/dist/llm/claude-models.js.map +1 -1
  65. package/dist/llm/google.d.ts +12 -1
  66. package/dist/llm/google.d.ts.map +1 -1
  67. package/dist/llm/google.js +84 -12
  68. package/dist/llm/google.js.map +1 -1
  69. package/dist/llm/ollama.d.ts +6 -1
  70. package/dist/llm/ollama.d.ts.map +1 -1
  71. package/dist/llm/ollama.js +26 -0
  72. package/dist/llm/ollama.js.map +1 -1
  73. package/dist/llm/openai-compatible-base.d.ts.map +1 -1
  74. package/dist/llm/openai-compatible-base.js +29 -21
  75. package/dist/llm/openai-compatible-base.js.map +1 -1
  76. package/dist/llm/openai-responses.d.ts.map +1 -1
  77. package/dist/llm/openai-responses.js +20 -3
  78. package/dist/llm/openai-responses.js.map +1 -1
  79. package/dist/logger.d.ts.map +1 -1
  80. package/dist/logger.js +3 -5
  81. package/dist/logger.js.map +1 -1
  82. package/dist/runtime.d.ts +48 -1
  83. package/dist/runtime.d.ts.map +1 -1
  84. package/dist/runtime.js +556 -172
  85. package/dist/runtime.js.map +1 -1
  86. package/dist/security/pii.d.ts +44 -0
  87. package/dist/security/pii.d.ts.map +1 -0
  88. package/dist/security/pii.js +285 -0
  89. package/dist/security/pii.js.map +1 -0
  90. package/dist/skill.d.ts.map +1 -1
  91. package/dist/skill.js +16 -10
  92. package/dist/skill.js.map +1 -1
  93. package/dist/tools/audio-generate.d.ts +1 -1
  94. package/dist/tools/audio-generate.d.ts.map +1 -1
  95. package/dist/tools/audio-generate.js +2 -1
  96. package/dist/tools/audio-generate.js.map +1 -1
  97. package/dist/tools/audio-transcribe.d.ts.map +1 -1
  98. package/dist/tools/audio-transcribe.js +2 -1
  99. package/dist/tools/audio-transcribe.js.map +1 -1
  100. package/dist/tools/email.d.ts.map +1 -1
  101. package/dist/tools/email.js +10 -9
  102. package/dist/tools/email.js.map +1 -1
  103. package/dist/tools/github.d.ts.map +1 -1
  104. package/dist/tools/github.js +2 -1
  105. package/dist/tools/github.js.map +1 -1
  106. package/dist/tools/image-generate.d.ts +2 -2
  107. package/dist/tools/image-generate.d.ts.map +1 -1
  108. package/dist/tools/image-generate.js +2 -1
  109. package/dist/tools/image-generate.js.map +1 -1
  110. package/dist/tools/vector-search.d.ts.map +1 -1
  111. package/dist/tools/vector-search.js +8 -7
  112. package/dist/tools/vector-search.js.map +1 -1
  113. package/dist/tools/web-search.d.ts.map +1 -1
  114. package/dist/tools/web-search.js +7 -6
  115. package/dist/tools/web-search.js.map +1 -1
  116. package/dist/utils/env.d.ts +9 -0
  117. package/dist/utils/env.d.ts.map +1 -0
  118. package/dist/utils/env.js +26 -0
  119. package/dist/utils/env.js.map +1 -0
  120. package/package.json +6 -6
package/README.md CHANGED
@@ -59,6 +59,7 @@ console.log(result.output);
59
59
  - **Time Travel** - Checkpoint, replay, fork, and compare executions
60
60
  - **Causal Reasoning** - Pearl's do-calculus, counterfactuals, d-separation
61
61
  - **Resilience** - Retry, circuit breaker, and fallback patterns
62
+ - **PII Masking** - Personal data and secrets replaced with placeholders before they reach the provider
62
63
  - **Observability** - Full tracing with spans and callbacks
63
64
 
64
65
  ---
@@ -216,6 +217,31 @@ const variant = agent.clone({
216
217
  });
217
218
  ```
218
219
 
220
+ ### Reasoning and Prompt Caching
221
+
222
+ `reasoning` sets how hard a reasoning model thinks, in one vocabulary for every provider (Anthropic adaptive thinking and effort, OpenAI `reasoning.effort`, Gemini thinking levels or budgets, Ollama `think`), and can ask for a readable summary:
223
+
224
+ ```typescript
225
+ const analyst = new Agent({
226
+ name: 'analyst',
227
+ model: 'anthropic/claude-opus-5-5',
228
+ instructions: 'Explain the numbers.',
229
+ reasoning: { effort: 'high', summary: true }, // none | minimal | low | medium | high | xhigh | max
230
+ });
231
+
232
+ const result = await cog.run(analyst, {
233
+ input,
234
+ stream: true,
235
+ onReasoning: (d) => process.stdout.write(d),
236
+ });
237
+ result.reasoning; // the summary
238
+ result.usage.reasoningTokens; // billed as output
239
+ ```
240
+
241
+ Reasoning that has to travel with tool calls (Claude thinking blocks, OpenAI reasoning items, Gemini thought signatures) is sent back while the agent works through a tool loop.
242
+
243
+ Runs cache their prompt by default: Anthropic and Bedrock requests mark their stable prefix, OpenAI and Gemini cache on their own, and `usage.cachedInputTokens` / `cacheWriteTokens` are priced at the model's cache prices. `llm.promptCache: { ttl: '1h' }` or `false` changes it.
244
+
219
245
  ---
220
246
 
221
247
  ## Tools
@@ -240,6 +266,59 @@ const weatherTool = tool({
240
266
  });
241
267
  ```
242
268
 
269
+ ### Handoffs
270
+
271
+ `handoffs` lets an agent pass the conversation to another one: each target becomes a `transfer_to_<name>` tool, and the rest of the run goes on as the target — its instructions, tools and model — with the whole conversation:
272
+
273
+ ```typescript
274
+ const triage = new Agent({
275
+ name: 'triage',
276
+ model,
277
+ instructions: 'Hand the customer to the right specialist.',
278
+ handoffs: [billing, techSupport],
279
+ });
280
+
281
+ const result = await cog.run(triage, { input: 'How much do I owe on INV-204?' });
282
+ result.handoffs; // [{ from: 'triage', to: 'billing', reason }]
283
+ result.finalAgent; // 'billing'
284
+ ```
285
+
286
+ ### Approvals
287
+
288
+ A tool with `requiresApproval` (`true` or a function of its arguments) never runs without a person's decision. Decide inline with `onApproval`, or let the run pause and resume it later:
289
+
290
+ ```typescript
291
+ const result = await cog.run(agent, { input: 'Refund order A-1', threadId, userId });
292
+
293
+ if (result.status === 'paused') {
294
+ // result.pendingApprovals: [{ toolCallId, toolName, arguments, description }]
295
+ const done = await cog.resume(agent, threadId, {
296
+ userId,
297
+ decisions: { [result.pendingApprovals![0].toolCallId]: { approved: true } },
298
+ });
299
+ }
300
+ ```
301
+
302
+ Nothing of the paused turn runs until every call in it is decided. Paused runs live in the thread's memory (or process memory, or your `runCheckpoints` store), so a resume can come after a restart; a new message on the thread instead declines the waiting calls.
303
+
304
+ ### PII Masking
305
+
306
+ `security.pii` replaces emails, phones, card numbers (Luhn-checked), IBANs, SSNs, IP addresses, API keys and your own patterns with placeholders before every LLM request, so the provider never sees them:
307
+
308
+ ```typescript
309
+ const cog = new Cogitator({
310
+ security: {
311
+ pii: {
312
+ mode: 'mask', // 'redact' keeps placeholders in the answer, 'block' rejects such input
313
+ custom: [{ type: 'customer_id', pattern: /CUS-\d{6}/ }],
314
+ onDetect: (counts) => audit.log(counts), // { email: 1 } — never the values
315
+ },
316
+ },
317
+ });
318
+ ```
319
+
320
+ In `mask` mode the answer, its stream and tool call arguments get the real values back, so `send_email({ to: '[EMAIL_1]' })` reaches the tool as the real address. `PiiMasker`, `PiiVault` and `withPiiMasking` work outside a run too.
321
+
243
322
  ### Tool Context
244
323
 
245
324
  Every tool receives a context object:
@@ -1,4 +1,4 @@
1
- import type { Tool } from '@cogitator-ai/types';
1
+ import type { RunOptions, Tool } from '@cogitator-ai/types';
2
2
  import type { Agent } from './agent.js';
3
3
  import type { Cogitator } from './runtime.js';
4
4
  export interface AgentAsToolOptions {
@@ -7,6 +7,12 @@ export interface AgentAsToolOptions {
7
7
  timeout?: number;
8
8
  includeUsage?: boolean;
9
9
  includeToolCalls?: boolean;
10
+ /**
11
+ * Decides the calls of the inner agent that need approval. Without it they
12
+ * are declined, since a delegated run cannot wait for a person; the inner
13
+ * agent is told why and answers accordingly.
14
+ */
15
+ onApproval?: RunOptions['onApproval'];
10
16
  }
11
17
  export interface AgentToolResult {
12
18
  output: string;
@@ -1 +1 @@
1
- {"version":3,"file":"agent-tool.d.ts","sourceRoot":"","sources":["../src/agent-tool.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAe,MAAM,qBAAqB,CAAC;AAC7D,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAI3C,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE;QACN,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,WAAW,EAAE,MAAM,CAAC;QACpB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,SAAS,CAAC,EAAE,KAA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,WAAW,CACzB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,kBAAkB,GAC1B,IAAI,CAAC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,eAAe,CAAC,CAmDzC"}
@@ -4,7 +4,7 @@ const DEFAULT_SCHEMA = z.object({
4
4
  task: z.string().describe('The task to delegate to the agent'),
5
5
  });
6
6
  export function agentAsTool(cogitator, agent, options) {
7
- const { name, description, timeout, includeUsage = false, includeToolCalls = false } = options;
7
+ const { name, description, timeout, includeUsage = false, includeToolCalls = false, onApproval, } = options;
8
8
  return tool({
9
9
  name,
10
10
  description,
@@ -18,6 +18,9 @@ export function agentAsTool(cogitator, agent, options) {
18
18
  input: params.task,
19
19
  timeout: effectiveTimeout,
20
20
  signal: context.signal,
21
+ ...(context.userId !== undefined && { userId: context.userId }),
22
+ onApproval: onApproval ??
23
+ (() => ({ approved: false, reason: 'no one can approve calls of a delegated agent' })),
21
24
  });
22
25
  return {
23
26
  output: result.output,
@@ -1 +1 @@
1
- {"version":3,"file":"agent-tool.js","sourceRoot":"","sources":["../src/agent-tool.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwBxB,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,mCAAmC,CAAC;CAC/D,CAAC,CAAC;AAEH,MAAM,UAAU,WAAW,CACzB,SAAoB,EACpB,KAAY,EACZ,OAA2B;IAE3B,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,GAAG,KAAK,EAAE,gBAAgB,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IAE/F,OAAO,IAAI,CAAC;QACV,IAAI;QACJ,WAAW;QACX,UAAU,EAAE,cAAc;QAC1B,OA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CAAC;oBACnD,GAAG,CAAC,gBAAgB,IAAI;wBACtB,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;4BACvC,IAAI,EAAE,EAAE,CAAC,IAAI;4BACb,SAAS,EAAE,EAAE,CAAC,SAAS;yBACxB,CAAC,CAAC;qBACJ,CAAC;iBACH,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO;oBACL,MAAM,EAAE,EAAE;oBACV,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;iBAC9D,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
package/dist/agent.d.ts CHANGED
@@ -2,32 +2,7 @@ import type { Agent as IAgent, AgentConfig, Tool, AgentSnapshot, DeserializeOpti
2
2
  export declare class AgentDeserializationError extends Error {
3
3
  constructor(message: string);
4
4
  }
5
- /**
6
- * AI agent that can execute tasks using LLM and tools.
7
- *
8
- * @example
9
- * ```ts
10
- * import { Agent, tool } from '@cogitator-ai/core';
11
- * import { z } from 'zod';
12
- *
13
- * const searchTool = tool({
14
- * name: 'search',
15
- * description: 'Search the web',
16
- * parameters: z.object({ query: z.string() }),
17
- * execute: async ({ query }) => ({ results: [] }),
18
- * });
19
- *
20
- * const agent = new Agent({
21
- * name: 'researcher',
22
- * model: 'anthropic/claude-sonnet-5-5',
23
- * instructions: 'You are a research assistant.',
24
- * tools: [searchTool],
25
- * });
26
- * ```
27
- */
28
5
  export declare class Agent implements IAgent {
29
- /** Unique identifier for this agent instance */
30
- readonly id: string;
31
6
  /** Human-readable name of the agent */
32
7
  readonly name: string;
33
8
  /** Full configuration including model, instructions, tools, and parameters */
@@ -45,6 +20,12 @@ export declare class Agent implements IAgent {
45
20
  * @param config.timeout - Run timeout in milliseconds (default: 120000)
46
21
  */
47
22
  constructor(config: AgentConfig);
23
+ /**
24
+ * Unique identifier for this agent instance: `config.id`, or one generated
25
+ * on first read — not in the constructor, so agents can be created at module
26
+ * scope where generating random values is not allowed (Cloudflare Workers).
27
+ */
28
+ get id(): string;
48
29
  /** LLM model identifier */
49
30
  get model(): string | undefined;
50
31
  /** System prompt defining agent behavior */
@@ -1 +1 @@
1
- {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,IAAI,MAAM,EACf,WAAW,EACX,IAAI,EACJ,aAAa,EACb,kBAAkB,EAGnB,MAAM,qBAAqB,CAAC;AAM7B,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,OAAO,EAAE,MAAM;CAI5B;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,qBAAa,KAAM,YAAW,MAAM;IAClC,gDAAgD;IAChD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B;;;;;;;;;;;OAWG;gBACS,MAAM,EAAE,WAAW;IAiB/B,2BAA2B;IAC3B,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,4CAA4C;IAC5C,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,oCAAoC;IACpC,IAAI,KAAK,IAAI,IAAI,EAAE,CAElB;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,KAAK;IAQ7C;;;;;;;;;;;OAWG;IACH,SAAS,IAAI,aAAa;IAyB1B;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,GAAE,kBAAuB,GAAG,KAAK;IA6CpF;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,aAAa;CAiBtE"}
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,KAAK,IAAI,MAAM,EACf,WAAW,EACX,IAAI,EACJ,aAAa,EACb,kBAAkB,EAGnB,MAAM,qBAAqB,CAAC;AAM7B,qBAAa,yBAA0B,SAAQ,KAAK;gBACtC,OAAO,EAAE,MAAM;CAI5B;AA2BD,qBAAa,KAAM,YAAW,MAAM;IAClC,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B;;;;;;;;;;;OAWG;gBACS,MAAM,EAAE,WAAW;IAgB/B;;;;OAIG;IACH,IAAI,EAAE,IAAI,MAAM,CAQf;IAED,2BAA2B;IAC3B,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,4CAA4C;IAC5C,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,oCAAoC;IACpC,IAAI,KAAK,IAAI,IAAI,EAAE,CAElB;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,WAAW,CAAC,GAAG,KAAK;IAQ7C;;;;;;;;;;;OAWG;IACH,SAAS,IAAI,aAAa;IA0B1B;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,WAAW,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,GAAE,kBAAuB,GAAG,KAAK;IA8CpF;;;;;OAKG;IACH,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,IAAI,aAAa;CAiBtE"}
package/dist/agent.js CHANGED
@@ -30,9 +30,8 @@ export class AgentDeserializationError extends Error {
30
30
  * });
31
31
  * ```
32
32
  */
33
+ const generatedIds = new WeakMap();
33
34
  export class Agent {
34
- /** Unique identifier for this agent instance */
35
- id;
36
35
  /** Human-readable name of the agent */
37
36
  name;
38
37
  /** Full configuration including model, instructions, tools, and parameters */
@@ -50,7 +49,6 @@ export class Agent {
50
49
  * @param config.timeout - Run timeout in milliseconds (default: 120000)
51
50
  */
52
51
  constructor(config) {
53
- this.id = config.id ?? `agent_${nanoid(12)}`;
54
52
  this.name = config.name;
55
53
  let finalConfig = { ...config };
56
54
  if (config.skills && config.skills.length > 0) {
@@ -63,6 +61,21 @@ export class Agent {
63
61
  ...finalConfig,
64
62
  };
65
63
  }
64
+ /**
65
+ * Unique identifier for this agent instance: `config.id`, or one generated
66
+ * on first read — not in the constructor, so agents can be created at module
67
+ * scope where generating random values is not allowed (Cloudflare Workers).
68
+ */
69
+ get id() {
70
+ if (this.config.id)
71
+ return this.config.id;
72
+ let id = generatedIds.get(this);
73
+ if (!id) {
74
+ id = `agent_${nanoid(12)}`;
75
+ generatedIds.set(this, id);
76
+ }
77
+ return id;
78
+ }
66
79
  /** LLM model identifier */
67
80
  get model() {
68
81
  return this.config.model;
@@ -122,6 +135,7 @@ export class Agent {
122
135
  maxTokens: this.config.maxTokens,
123
136
  stopSequences: this.config.stopSequences,
124
137
  responseFormat: serializeResponseFormat(this.config.responseFormat),
138
+ ...(this.config.reasoning && { reasoning: this.config.reasoning }),
125
139
  maxIterations: this.config.maxIterations,
126
140
  timeout: this.config.timeout,
127
141
  },
@@ -179,6 +193,7 @@ export class Agent {
179
193
  maxTokens: snapshot.config.maxTokens,
180
194
  stopSequences: snapshot.config.stopSequences,
181
195
  responseFormat: deserializeResponseFormat(snapshot, overrides?.responseFormat),
196
+ ...(snapshot.config.reasoning && { reasoning: snapshot.config.reasoning }),
182
197
  maxIterations: snapshot.config.maxIterations,
183
198
  timeout: snapshot.config.timeout,
184
199
  ...overrides,
package/dist/agent.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"agent.js","sourceRoot":"","sources":["../src/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ACJ,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { Agent as IAgent, Tool } from '@cogitator-ai/types';
2
+ export interface HandoffTools {
3
+ tools: Tool[];
4
+ /** The agent each handoff tool hands over to, by tool name */
5
+ targets: Map<string, IAgent>;
6
+ }
7
+ /** The `transfer_to_<name>` tools of an agent's `handoffs`. */
8
+ export declare function handoffTools(agent: IAgent): HandoffTools;
9
+ /**
10
+ * The agent called `name` among `entry` and the agents it can reach through
11
+ * handoffs, for resuming a run that paused after a handoff.
12
+ */
13
+ export declare function findHandoffAgent(entry: IAgent, name: string): IAgent | undefined;
14
+ //# sourceMappingURL=handoffs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoffs.d.ts","sourceRoot":"","sources":["../../src/cogitator/handoffs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,IAAI,MAAM,EAAW,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAQ1E,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,8DAA8D;IAC9D,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC9B;AAED,+DAA+D;AAC/D,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAyBxD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAWhF"}
@@ -0,0 +1,53 @@
1
+ import { z } from 'zod';
2
+ import { tool } from '../tool.js';
3
+ const handoffParameters = z.object({
4
+ reason: z.string().optional().describe('Why the conversation goes to this agent'),
5
+ });
6
+ /** The `transfer_to_<name>` tools of an agent's `handoffs`. */
7
+ export function handoffTools(agent) {
8
+ const tools = [];
9
+ const targets = new Map();
10
+ for (const entry of agent.config.handoffs ?? []) {
11
+ const { agent: target, toolName, description } = toHandoff(entry);
12
+ const name = toolName ?? `transfer_to_${toToolName(target.name)}`;
13
+ targets.set(name, target);
14
+ tools.push(tool({
15
+ name,
16
+ description: description ??
17
+ `Hand the conversation over to ${target.name}${target.config.description ? `: ${target.config.description}` : '.'}`,
18
+ parameters: handoffParameters,
19
+ execute: async ({ reason }) => ({
20
+ transferred: true,
21
+ to: target.name,
22
+ ...(reason && { reason }),
23
+ }),
24
+ }));
25
+ }
26
+ return { tools, targets };
27
+ }
28
+ /**
29
+ * The agent called `name` among `entry` and the agents it can reach through
30
+ * handoffs, for resuming a run that paused after a handoff.
31
+ */
32
+ export function findHandoffAgent(entry, name) {
33
+ const seen = new Set();
34
+ const queue = [entry];
35
+ while (queue.length > 0) {
36
+ const current = queue.shift();
37
+ if (seen.has(current))
38
+ continue;
39
+ seen.add(current);
40
+ if (current.name === name)
41
+ return current;
42
+ for (const next of current.config.handoffs ?? [])
43
+ queue.push(toHandoff(next).agent);
44
+ }
45
+ return undefined;
46
+ }
47
+ function toHandoff(entry) {
48
+ return 'agent' in entry ? entry : { agent: entry };
49
+ }
50
+ function toToolName(name) {
51
+ return name.replace(/[^a-zA-Z0-9_-]+/g, '_').replace(/^_+|_+$/g, '') || 'agent';
52
+ }
53
+ //# sourceMappingURL=handoffs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handoffs.js","sourceRoot":"","sources":["../../src/cogitator/handoffs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAE/B,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,yCAAyC,CAAC;CAClF,CAAC,CAAC;AAQH,+DAA+D;AAC/D,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,MAAM,OAAO,GAAG,IAAI,GAAG,EA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YAAE,SAAS;QAChC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAClB,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI;YAAE,OAAO,OAAO,CAAC;QAC1C,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE;YAAE,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,SAAS,CAAC,KAAuB;IACxC,OAAO,OAAO,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AACrD,CAAC;AAED,SAAS,UAAU,CAAC,IAAY;IAC9B,OAAO,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC;AAClF,CAAC"}
@@ -0,0 +1,69 @@
1
+ import type { ABTest, ABTestOutcome, InstructionSource, InstructionVersion, PromptsConfig, RunPrompt, RunResult } from '@cogitator-ai/types';
2
+ import type { Agent } from '../agent.js';
3
+ import { type RollbackResult } from '../learning/rollback-manager.js';
4
+ /** An agent, or the key its instructions are versioned under. */
5
+ export type PromptTarget = Agent | string;
6
+ export interface StartABTestOptions {
7
+ name: string;
8
+ /** The instructions to test against the current ones */
9
+ treatment: string;
10
+ description?: string;
11
+ /** Share of threads that get the treatment (default 0.5) */
12
+ treatmentAllocation?: number;
13
+ minSampleSize?: number;
14
+ /** Milliseconds after which the test completes even without a clear winner */
15
+ maxDuration?: number;
16
+ confidenceLevel?: number;
17
+ }
18
+ /** The instructions a run uses, and what to record its outcome against. */
19
+ export interface PromptResolution {
20
+ instructions: string;
21
+ prompt: RunPrompt;
22
+ }
23
+ /**
24
+ * Versioned instructions and A/B tests for agents: deploy a new version,
25
+ * roll back, see each version's metrics, and test new instructions against
26
+ * the current ones on live traffic.
27
+ *
28
+ * Versions are kept per agent `id` when it was set explicitly, else per
29
+ * `name`, so they outlive the process.
30
+ */
31
+ export declare class PromptRegistry {
32
+ private readonly config;
33
+ private readonly versions;
34
+ private readonly rollback;
35
+ private readonly abTesting;
36
+ constructor(config?: PromptsConfig);
37
+ /** Deploy `instructions` as the agent's new current version. */
38
+ deploy(target: PromptTarget, instructions: string, source?: InstructionSource): Promise<InstructionVersion>;
39
+ /** The version runs of the agent use now, if any was deployed. */
40
+ current(target: PromptTarget): Promise<InstructionVersion | null>;
41
+ /** Versions of the agent, newest first. */
42
+ history(target: PromptTarget, limit?: number): Promise<InstructionVersion[]>;
43
+ /** Make an earlier version current again (as a new version), or the previous one. */
44
+ rollbackTo(target: PromptTarget, versionId?: string): Promise<RollbackResult>;
45
+ /**
46
+ * Test `treatment` against the current instructions: each thread gets one
47
+ * of them until the test completes.
48
+ */
49
+ startABTest(target: PromptTarget, options: StartABTestOptions): Promise<ABTest>;
50
+ /** The running A/B test of the agent, if any. */
51
+ activeABTest(target: PromptTarget): Promise<ABTest | null>;
52
+ /** Complete a test now; deploys the winner when `autoDeployWinner` is on. */
53
+ completeABTest(testId: string): Promise<ABTestOutcome>;
54
+ /**
55
+ * The instructions a run of `agent` in `threadId` uses: the running A/B
56
+ * test's variant for that thread, else the current version, else the
57
+ * agent's own.
58
+ */
59
+ resolve(agent: Agent, threadId: string): Promise<PromptResolution>;
60
+ /** Record how a run went against the version or A/B variant it used. */
61
+ record(prompt: RunPrompt, outcome: {
62
+ result?: RunResult;
63
+ durationMs: number;
64
+ }): Promise<void>;
65
+ private deployWinner;
66
+ }
67
+ /** The key an agent's instructions are versioned under. */
68
+ export declare function promptKey(target: PromptTarget): string;
69
+ //# sourceMappingURL=prompts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../src/cogitator/prompts.ts"],"names":[],"mappings":"AAAA,OAAO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AAC,MAAM,EAAE,YAAY,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAI5E,qFAAqF;IACrF,UAAU,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAO7E;;;OAGG;IACG,WAAW,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,MAAM,CAAC;IAwBrF,iDAAiD;IACjD,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAI1D,6EAA6E;IACvE,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAM5D;;;;OAIG;IACG,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAmBxE,wEAAwE;IAClE,MAAM,CACV,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,SAAS,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAClD,OAAO,CAAC,IAAI,CAAC;YAwBF,YAAY;CAQ3B;AAED,2DAA2D;AAC3D,wBAAgB,SAAS,CAAC,MAAM,EAAE,YAAY,GAAG,MAAM,CAEtD"}
@@ -0,0 +1,149 @@
1
+ import { ABTestingFramework } from '../learning/ab-testing.js';
2
+ import { RollbackManager } from '../learning/rollback-manager.js';
3
+ import { InMemoryABTestStore, InMemoryInstructionVersionStore } from '../learning/prompt-stores.js';
4
+ import { getLogger } from '../logger.js';
5
+ /**
6
+ * Versioned instructions and A/B tests for agents: deploy a new version,
7
+ * roll back, see each version's metrics, and test new instructions against
8
+ * the current ones on live traffic.
9
+ *
10
+ * Versions are kept per agent `id` when it was set explicitly, else per
11
+ * `name`, so they outlive the process.
12
+ */
13
+ export class PromptRegistry {
14
+ config;
15
+ versions;
16
+ rollback;
17
+ abTesting;
18
+ constructor(config = {}) {
19
+ this.config = config;
20
+ this.versions = config.versions ?? new InMemoryInstructionVersionStore();
21
+ const abTests = config.abTests ?? new InMemoryABTestStore();
22
+ this.rollback = new RollbackManager({ store: this.versions });
23
+ this.abTesting = new ABTestingFramework({ store: abTests });
24
+ }
25
+ /** Deploy `instructions` as the agent's new current version. */
26
+ deploy(target, instructions, source = 'manual') {
27
+ return this.rollback.deployVersion(promptKey(target), instructions, source);
28
+ }
29
+ /** The version runs of the agent use now, if any was deployed. */
30
+ current(target) {
31
+ return this.rollback.getCurrentVersion(promptKey(target));
32
+ }
33
+ /** Versions of the agent, newest first. */
34
+ history(target, limit) {
35
+ return this.rollback.getVersionHistory(promptKey(target), limit);
36
+ }
37
+ /** Make an earlier version current again (as a new version), or the previous one. */
38
+ rollbackTo(target, versionId) {
39
+ const key = promptKey(target);
40
+ return versionId
41
+ ? this.rollback.rollbackTo(key, versionId)
42
+ : this.rollback.rollbackToPrevious(key);
43
+ }
44
+ /**
45
+ * Test `treatment` against the current instructions: each thread gets one
46
+ * of them until the test completes.
47
+ */
48
+ async startABTest(target, options) {
49
+ const key = promptKey(target);
50
+ const control = (await this.current(key))?.instructions ??
51
+ (typeof target === 'string' ? undefined : target.instructions);
52
+ if (control === undefined) {
53
+ throw new Error(`No current instructions for "${key}" to test against`);
54
+ }
55
+ const test = await this.abTesting.createTest({
56
+ agentId: key,
57
+ name: options.name,
58
+ ...(options.description && { description: options.description }),
59
+ controlInstructions: control,
60
+ treatmentInstructions: options.treatment,
61
+ ...(options.treatmentAllocation !== undefined && {
62
+ treatmentAllocation: options.treatmentAllocation,
63
+ }),
64
+ ...(options.minSampleSize !== undefined && { minSampleSize: options.minSampleSize }),
65
+ ...(options.maxDuration !== undefined && { maxDuration: options.maxDuration }),
66
+ ...(options.confidenceLevel !== undefined && { confidenceLevel: options.confidenceLevel }),
67
+ });
68
+ return this.abTesting.startTest(test.id);
69
+ }
70
+ /** The running A/B test of the agent, if any. */
71
+ activeABTest(target) {
72
+ return this.abTesting.getActiveTest(promptKey(target));
73
+ }
74
+ /** Complete a test now; deploys the winner when `autoDeployWinner` is on. */
75
+ async completeABTest(testId) {
76
+ const { test, outcome } = await this.abTesting.completeTest(testId);
77
+ await this.deployWinner(test, outcome);
78
+ return outcome;
79
+ }
80
+ /**
81
+ * The instructions a run of `agent` in `threadId` uses: the running A/B
82
+ * test's variant for that thread, else the current version, else the
83
+ * agent's own.
84
+ */
85
+ async resolve(agent, threadId) {
86
+ const key = promptKey(agent);
87
+ const test = await this.abTesting.getActiveTest(key);
88
+ if (test) {
89
+ const variant = stickyVariant(test, threadId);
90
+ return {
91
+ instructions: this.abTesting.getInstructionsForVariant(test, variant),
92
+ prompt: { key, abTest: { id: test.id, variant } },
93
+ };
94
+ }
95
+ const version = await this.rollback.getCurrentVersion(key);
96
+ return version
97
+ ? {
98
+ instructions: version.instructions,
99
+ prompt: { key, versionId: version.id, version: version.version },
100
+ }
101
+ : { instructions: agent.instructions, prompt: { key } };
102
+ }
103
+ /** Record how a run went against the version or A/B variant it used. */
104
+ async record(prompt, outcome) {
105
+ const { result, durationMs } = outcome;
106
+ const score = result ? await (this.config.score?.(result) ?? 1) : 0;
107
+ const cost = result?.usage.cost ?? 0;
108
+ if (prompt.abTest) {
109
+ await this.abTesting.recordResult(prompt.abTest.id, prompt.abTest.variant, score, durationMs, cost);
110
+ const finished = await this.abTesting.checkAndCompleteIfReady(prompt.abTest.id);
111
+ if (finished) {
112
+ const test = await this.abTesting.getTest(prompt.abTest.id);
113
+ if (test)
114
+ await this.deployWinner(test, finished);
115
+ }
116
+ }
117
+ if (prompt.versionId) {
118
+ await this.rollback.recordMetrics(prompt.key, score, durationMs, cost, result !== undefined);
119
+ }
120
+ }
121
+ async deployWinner(test, outcome) {
122
+ if (!this.config.autoDeployWinner || outcome.winner !== 'treatment')
123
+ return;
124
+ await this.rollback.deployVersion(test.agentId, test.treatmentInstructions, 'ab_test', test.id);
125
+ getLogger().info('Deployed the winning instructions of an A/B test', {
126
+ agent: test.agentId,
127
+ test: test.id,
128
+ });
129
+ }
130
+ }
131
+ /** The key an agent's instructions are versioned under. */
132
+ export function promptKey(target) {
133
+ return typeof target === 'string' ? target : (target.config.id ?? target.name);
134
+ }
135
+ /** The same variant for every run of a thread, spread by the test's allocation. */
136
+ function stickyVariant(test, threadId) {
137
+ let hash = 2166136261;
138
+ for (const char of `${test.id}:${threadId}`) {
139
+ hash ^= char.charCodeAt(0);
140
+ hash = Math.imul(hash, 16777619);
141
+ }
142
+ hash ^= hash >>> 16;
143
+ hash = Math.imul(hash, 0x85ebca6b);
144
+ hash ^= hash >>> 13;
145
+ hash = Math.imul(hash, 0xc2b2ae35);
146
+ hash ^= hash >>> 16;
147
+ return (hash >>> 0) / 4294967296 < test.treatmentAllocation ? 'treatment' : 'control';
148
+ }
149
+ //# sourceMappingURL=prompts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../src/cogitator/prompts.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAuB,MAAM,8BAA8B,CAAC;AACpF,OAAO,EAAE,mBAAmB,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AACjG,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAwBtC;;;;;;;GAOG;AACH,MAAM,OAAO,cAAc;IAKI;IAJZ,QAAQ,CAA0B;IAClC,QAAQ,CAAkB;IAC1B,SAAS,CAAqB;IAE/C,YAA6B,SAAwB,EAAE;QAA1B,WAAM,GAAN,MAAM,CAAoB;QACrD,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,IAAI,+BAA+B,EAAE,CAAC;QACzE,MAAM,OAAO,GAAgB,MAAM,CAAC,OAAO,IAAI,IAAI,mBAAmB,EAAE,CAAC;QACzE,IAAI,C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itator-ai/types';
2
+ /** Paused runs in process memory; they are lost when the process exits. */
3
+ export declare class InMemoryRunCheckpointStore implements RunCheckpointStore {
4
+ private readonly checkpoints;
5
+ save(checkpoint: RunCheckpoint): Promise<void>;
6
+ load(threadId: string): Promise<RunCheckpoint | null>;
7
+ delete(threadId: string): Promise<void>;
8
+ }
9
+ /**
10
+ * Paused runs kept in their thread's metadata, so they last as long as the
11
+ * memory adapter's threads do (Redis, Postgres, SQLite, MongoDB).
12
+ */
13
+ export declare class ThreadRunCheckpointStore implements RunCheckpointStore {
14
+ private readonly memory;
15
+ constructor(memory: MemoryAdapter);
16
+ save(checkpoint: RunCheckpoint): Promise<void>;
17
+ load(threadId: string): Promise<RunCheckpoint | null>;
18
+ delete(threadId: string): Promise<void>;
19
+ }
20
+ //# sourceMappingURL=run-checkpoints.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run-checkpoints.d.ts","sourceRoot":"","sources":["../../src/cogitator/run-checkpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAE5F,2EAA2E;AAC3E,qBAAa,0BAA2B,YAAW,kBAAkB;IACnE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoC;IAE1D,IAAI,CAAC,UAAU,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9C,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAKrD,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C;AAID;;;GAGG;AACH,qBAAa,wBAAyB,YAAW,kBAAkB;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAE5C,IAAI,CAAC,UAAU,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAoB9C,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAOrD,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAO9C"}