agentfootprint 2.12.1 → 2.14.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 (133) hide show
  1. package/dist/adapters/llm/AnthropicProvider.js +69 -2
  2. package/dist/adapters/llm/AnthropicProvider.js.map +1 -1
  3. package/dist/adapters/llm/BrowserAnthropicProvider.js +110 -2
  4. package/dist/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  5. package/dist/core/Agent.js +50 -1
  6. package/dist/core/Agent.js.map +1 -1
  7. package/dist/core/agent/AgentBuilder.js +112 -1
  8. package/dist/core/agent/AgentBuilder.js.map +1 -1
  9. package/dist/core/agent/buildAgentChart.js +20 -1
  10. package/dist/core/agent/buildAgentChart.js.map +1 -1
  11. package/dist/core/agent/stages/callLLM.js +51 -1
  12. package/dist/core/agent/stages/callLLM.js.map +1 -1
  13. package/dist/core/agent/stages/prepareFinal.js +12 -1
  14. package/dist/core/agent/stages/prepareFinal.js.map +1 -1
  15. package/dist/core/agent/stages/reliabilityExecution.js +194 -9
  16. package/dist/core/agent/stages/reliabilityExecution.js.map +1 -1
  17. package/dist/core/agent/stages/seed.js +4 -0
  18. package/dist/core/agent/stages/seed.js.map +1 -1
  19. package/dist/core/agent/stages/toolCalls.js +7 -0
  20. package/dist/core/agent/stages/toolCalls.js.map +1 -1
  21. package/dist/core/slots/buildThinkingSubflow.js +112 -0
  22. package/dist/core/slots/buildThinkingSubflow.js.map +1 -0
  23. package/dist/esm/adapters/llm/AnthropicProvider.js +69 -2
  24. package/dist/esm/adapters/llm/AnthropicProvider.js.map +1 -1
  25. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js +110 -2
  26. package/dist/esm/adapters/llm/BrowserAnthropicProvider.js.map +1 -1
  27. package/dist/esm/core/Agent.js +50 -1
  28. package/dist/esm/core/Agent.js.map +1 -1
  29. package/dist/esm/core/agent/AgentBuilder.js +112 -1
  30. package/dist/esm/core/agent/AgentBuilder.js.map +1 -1
  31. package/dist/esm/core/agent/buildAgentChart.js +20 -1
  32. package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
  33. package/dist/esm/core/agent/stages/callLLM.js +52 -2
  34. package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
  35. package/dist/esm/core/agent/stages/prepareFinal.js +12 -1
  36. package/dist/esm/core/agent/stages/prepareFinal.js.map +1 -1
  37. package/dist/esm/core/agent/stages/reliabilityExecution.js +191 -8
  38. package/dist/esm/core/agent/stages/reliabilityExecution.js.map +1 -1
  39. package/dist/esm/core/agent/stages/seed.js +4 -0
  40. package/dist/esm/core/agent/stages/seed.js.map +1 -1
  41. package/dist/esm/core/agent/stages/toolCalls.js +7 -0
  42. package/dist/esm/core/agent/stages/toolCalls.js.map +1 -1
  43. package/dist/esm/core/slots/buildThinkingSubflow.js +108 -0
  44. package/dist/esm/core/slots/buildThinkingSubflow.js.map +1 -0
  45. package/dist/esm/events/registry.js +8 -0
  46. package/dist/esm/events/registry.js.map +1 -1
  47. package/dist/esm/reliability/index.js +6 -0
  48. package/dist/esm/reliability/index.js.map +1 -1
  49. package/dist/esm/reliability/types.js.map +1 -1
  50. package/dist/esm/security/index.js +1 -0
  51. package/dist/esm/security/index.js.map +1 -1
  52. package/dist/esm/security/thinkingRedaction.js +66 -0
  53. package/dist/esm/security/thinkingRedaction.js.map +1 -0
  54. package/dist/esm/thinking/AnthropicThinkingHandler.js +111 -0
  55. package/dist/esm/thinking/AnthropicThinkingHandler.js.map +1 -0
  56. package/dist/esm/thinking/MockThinkingHandler.js +94 -0
  57. package/dist/esm/thinking/MockThinkingHandler.js.map +1 -0
  58. package/dist/esm/thinking/OpenAIThinkingHandler.js +72 -0
  59. package/dist/esm/thinking/OpenAIThinkingHandler.js.map +1 -0
  60. package/dist/esm/thinking/index.js +51 -0
  61. package/dist/esm/thinking/index.js.map +1 -0
  62. package/dist/esm/thinking/registry.js +46 -0
  63. package/dist/esm/thinking/registry.js.map +1 -0
  64. package/dist/esm/thinking/types.js +30 -0
  65. package/dist/esm/thinking/types.js.map +1 -0
  66. package/dist/events/registry.js +8 -0
  67. package/dist/events/registry.js.map +1 -1
  68. package/dist/reliability/index.js +10 -1
  69. package/dist/reliability/index.js.map +1 -1
  70. package/dist/reliability/types.js.map +1 -1
  71. package/dist/security/index.js +4 -1
  72. package/dist/security/index.js.map +1 -1
  73. package/dist/security/thinkingRedaction.js +70 -0
  74. package/dist/security/thinkingRedaction.js.map +1 -0
  75. package/dist/thinking/AnthropicThinkingHandler.js +114 -0
  76. package/dist/thinking/AnthropicThinkingHandler.js.map +1 -0
  77. package/dist/thinking/MockThinkingHandler.js +99 -0
  78. package/dist/thinking/MockThinkingHandler.js.map +1 -0
  79. package/dist/thinking/OpenAIThinkingHandler.js +75 -0
  80. package/dist/thinking/OpenAIThinkingHandler.js.map +1 -0
  81. package/dist/thinking/index.js +61 -0
  82. package/dist/thinking/index.js.map +1 -0
  83. package/dist/thinking/registry.js +50 -0
  84. package/dist/thinking/registry.js.map +1 -0
  85. package/dist/thinking/types.js +31 -0
  86. package/dist/thinking/types.js.map +1 -0
  87. package/dist/types/adapters/llm/AnthropicProvider.d.ts +11 -0
  88. package/dist/types/adapters/llm/AnthropicProvider.d.ts.map +1 -1
  89. package/dist/types/adapters/llm/BrowserAnthropicProvider.d.ts.map +1 -1
  90. package/dist/types/adapters/types.d.ts +121 -0
  91. package/dist/types/adapters/types.d.ts.map +1 -1
  92. package/dist/types/core/Agent.d.ts +16 -1
  93. package/dist/types/core/Agent.d.ts.map +1 -1
  94. package/dist/types/core/agent/AgentBuilder.d.ts +99 -0
  95. package/dist/types/core/agent/AgentBuilder.d.ts.map +1 -1
  96. package/dist/types/core/agent/buildAgentChart.d.ts +8 -0
  97. package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
  98. package/dist/types/core/agent/stages/callLLM.d.ts +13 -0
  99. package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
  100. package/dist/types/core/agent/stages/prepareFinal.d.ts.map +1 -1
  101. package/dist/types/core/agent/stages/reliabilityExecution.d.ts +72 -2
  102. package/dist/types/core/agent/stages/reliabilityExecution.d.ts.map +1 -1
  103. package/dist/types/core/agent/stages/seed.d.ts.map +1 -1
  104. package/dist/types/core/agent/stages/toolCalls.d.ts.map +1 -1
  105. package/dist/types/core/agent/types.d.ts +12 -0
  106. package/dist/types/core/agent/types.d.ts.map +1 -1
  107. package/dist/types/core/slots/buildThinkingSubflow.d.ts +41 -0
  108. package/dist/types/core/slots/buildThinkingSubflow.d.ts.map +1 -0
  109. package/dist/types/events/payloads.d.ts +149 -0
  110. package/dist/types/events/payloads.d.ts.map +1 -1
  111. package/dist/types/events/registry.d.ts +9 -1
  112. package/dist/types/events/registry.d.ts.map +1 -1
  113. package/dist/types/reliability/index.d.ts +2 -0
  114. package/dist/types/reliability/index.d.ts.map +1 -1
  115. package/dist/types/reliability/types.d.ts +72 -0
  116. package/dist/types/reliability/types.d.ts.map +1 -1
  117. package/dist/types/security/index.d.ts +1 -0
  118. package/dist/types/security/index.d.ts.map +1 -1
  119. package/dist/types/security/thinkingRedaction.d.ts +51 -0
  120. package/dist/types/security/thinkingRedaction.d.ts.map +1 -0
  121. package/dist/types/thinking/AnthropicThinkingHandler.d.ts +43 -0
  122. package/dist/types/thinking/AnthropicThinkingHandler.d.ts.map +1 -0
  123. package/dist/types/thinking/MockThinkingHandler.d.ts +51 -0
  124. package/dist/types/thinking/MockThinkingHandler.d.ts.map +1 -0
  125. package/dist/types/thinking/OpenAIThinkingHandler.d.ts +38 -0
  126. package/dist/types/thinking/OpenAIThinkingHandler.d.ts.map +1 -0
  127. package/dist/types/thinking/index.d.ts +52 -0
  128. package/dist/types/thinking/index.d.ts.map +1 -0
  129. package/dist/types/thinking/registry.d.ts +34 -0
  130. package/dist/types/thinking/registry.d.ts.map +1 -0
  131. package/dist/types/thinking/types.d.ts +163 -0
  132. package/dist/types/thinking/types.d.ts.map +1 -0
  133. package/package.json +6 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockThinkingHandler.d.ts","sourceRoot":"","sources":["../../../src/thinking/MockThinkingHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAiB,eAAe,EAAE,MAAM,YAAY,CAAC;AAEjE,gEAAgE;AAChE,UAAU,gBAAgB;IACxB,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC;QAC7B,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,mBAAmB,CAAC;QAChD,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAC3B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;KAC7B,CAAC,CAAC;CACJ;AAED,6DAA6D;AAC7D,UAAU,aAAa;IACrB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAiBD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,SAAS;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,GAC7E,gBAAgB,CASlB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,GAAG,aAAa,CAE5E;AAED,eAAO,MAAM,mBAAmB,EAAE,eA0CjC,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * OpenAIThinkingHandler — normalizes OpenAI's o1/o3 reasoning_summary
3
+ * structured output into the framework's `ThinkingBlock[]` contract.
4
+ *
5
+ * OpenAI's reasoning_summary shape varies by model + API version:
6
+ *
7
+ * 1. Older o1 format — simple string:
8
+ * "I worked through the problem by first..."
9
+ *
10
+ * 2. Newer o3+ structured — array of summary items:
11
+ * [
12
+ * { type: 'summary_text', text: 'Identify the user request' },
13
+ * { type: 'summary_text', text: 'Choose appropriate tool' },
14
+ * ]
15
+ *
16
+ * 3. Missing entirely — most calls (gpt-4o, or o1/o3 without
17
+ * reasoning_summary param requested) → undefined raw input
18
+ *
19
+ * Handler dispatches on shape; output is `ThinkingBlock[]` with
20
+ * `summary: true` per Phase 1 contract — distinguishes structured-
21
+ * summary blocks from raw thinking content (Anthropic's shape).
22
+ *
23
+ * **No signature** — OpenAI doesn't sign reasoning. The output's
24
+ * `signature` field stays undefined. No round-trip integrity invariant
25
+ * (unlike Anthropic).
26
+ *
27
+ * **No `parseChunk`** — OpenAI doesn't stream reasoning content as of
28
+ * early 2026. Reasoning arrives only on the terminal response. Per
29
+ * Phase 1 design, `parseChunk` is optional; we omit entirely.
30
+ *
31
+ * **No `usage.thinking` computation** — reasoning_tokens lives on
32
+ * `response.usage.completion_tokens_details.reasoning_tokens` and is
33
+ * the OpenAIProvider's job to surface (deferred). Handler doesn't
34
+ * compute token counts.
35
+ */
36
+ import type { ThinkingHandler } from './types.js';
37
+ export declare const openAIThinkingHandler: ThinkingHandler;
38
+ //# sourceMappingURL=OpenAIThinkingHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OpenAIThinkingHandler.d.ts","sourceRoot":"","sources":["../../../src/thinking/OpenAIThinkingHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AAEH,OAAO,KAAK,EAAiB,eAAe,EAAE,MAAM,YAAY,CAAC;AAcjE,eAAO,MAAM,qBAAqB,EAAE,eAoCnC,CAAC"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * agentfootprint/thinking — extended-thinking subsystem (v2.14+).
3
+ *
4
+ * **Two-layer architecture:**
5
+ *
6
+ * • CONSUMER-FACING: `ThinkingHandler` — simple function-pair
7
+ * implemented by provider authors.
8
+ * • FRAMEWORK-INTERNAL: each handler is auto-wrapped in a real
9
+ * footprintjs subflow at chart build time;
10
+ * shows in trace as own runtimeStageId.
11
+ *
12
+ * **Auto-wire by provider name:**
13
+ *
14
+ * ```ts
15
+ * import { Agent } from 'agentfootprint';
16
+ *
17
+ * // Library scans SHIPPED_THINKING_HANDLERS, finds the handler
18
+ * // whose providerNames includes provider.name. Mounted as a
19
+ * // sub-subflow of sf-call-llm.
20
+ * const agent = Agent.create({ provider: anthropic({...}), model: '...' })
21
+ * .build();
22
+ *
23
+ * // Opt out:
24
+ * // .thinkingHandler(undefined)
25
+ * // Override with a custom handler:
26
+ * // .thinkingHandler(myCustomHandler)
27
+ * ```
28
+ *
29
+ * **Custom handlers:**
30
+ *
31
+ * ```ts
32
+ * import { type ThinkingHandler } from 'agentfootprint/thinking';
33
+ *
34
+ * export const geminiThinkingHandler: ThinkingHandler = {
35
+ * id: 'gemini',
36
+ * providerNames: ['gemini'],
37
+ * normalize(raw) { ... },
38
+ * parseChunk(chunk) { ... }, // optional
39
+ * };
40
+ * ```
41
+ *
42
+ * Failure isolation: handler `normalize()` throws are caught by the
43
+ * framework — emit `agentfootprint.agent.thinking_parse_failed`, drop
44
+ * the blocks, continue. Same graceful pattern as v2.11.6
45
+ * `tools.discovery_failed`.
46
+ */
47
+ export type { ThinkingBlock, ThinkingHandler } from './types.js';
48
+ export { mockThinkingHandler, mockAnthropicRaw, mockOpenAIRaw } from './MockThinkingHandler.js';
49
+ export { anthropicThinkingHandler } from './AnthropicThinkingHandler.js';
50
+ export { openAIThinkingHandler } from './OpenAIThinkingHandler.js';
51
+ export { SHIPPED_THINKING_HANDLERS, findThinkingHandler } from './registry.js';
52
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/thinking/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,YAAY,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEhG,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAC;AAEzE,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Registry — single source of truth for the framework's auto-wire
3
+ * logic AND the shared contract test.
4
+ *
5
+ * Phase 3 wiring scans this array at chart build time and selects the
6
+ * first handler whose `providerNames` includes the active
7
+ * `provider.name`. Phase 4a adds AnthropicThinkingHandler; Phase 5
8
+ * adds OpenAIThinkingHandler — append-only as new providers ship.
9
+ *
10
+ * Future provider authors:
11
+ * • Implement `ThinkingHandler` for your provider
12
+ * • Append to this array
13
+ * • The shared contract test in `test/thinking/contract.test.ts`
14
+ * verifies your handler honors the framework's invariants
15
+ */
16
+ import type { ThinkingHandler } from './types.js';
17
+ /**
18
+ * All thinking handlers shipped with the library. Append in alphabetical
19
+ * order (by `id`) so diffs stay readable as new handlers land.
20
+ */
21
+ export declare const SHIPPED_THINKING_HANDLERS: readonly ThinkingHandler[];
22
+ /**
23
+ * Look up a handler by `provider.name`. Returns the first match in
24
+ * `SHIPPED_THINKING_HANDLERS`. Returns `undefined` when no handler
25
+ * matches — framework treats this as "no thinking support for this
26
+ * provider", which is the correct default for providers that don't
27
+ * emit thinking content (gpt-3.5, mistral, etc.).
28
+ *
29
+ * Used by:
30
+ * • Phase 3 framework auto-wire (chart build time)
31
+ * • Tests verifying registry lookup
32
+ */
33
+ export declare function findThinkingHandler(providerName: string): ThinkingHandler | undefined;
34
+ //# sourceMappingURL=registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../src/thinking/registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAKH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE,SAAS,eAAe,EAI/D,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAKrF"}
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Thinking — public types for the v2.14 extended-thinking subsystem.
3
+ *
4
+ * Mental model — TWO-LAYER architecture:
5
+ *
6
+ * • CONSUMER-FACING: `ThinkingHandler` — a simple function-pair
7
+ * (id, providerNames, normalize, parseChunk?).
8
+ * Provider authors and custom-LLM consumers
9
+ * implement THIS shape.
10
+ *
11
+ * • FRAMEWORK-INTERNAL: each `ThinkingHandler` is auto-wrapped in a
12
+ * real footprintjs subflow at chart build time.
13
+ * The subflow gets its own `runtimeStageId`,
14
+ * narrative entry, and InOutRecorder boundary
15
+ * — full trace observability for free without
16
+ * the consumer writing flowchart code.
17
+ *
18
+ * Same pattern as how consumers write a `Tool` and the framework wraps
19
+ * dispatch in a tool-call subflow, or how consumers write a
20
+ * `ToolProvider` and the framework wraps `list()` in the Tools slot
21
+ * subflow.
22
+ *
23
+ * @see SHIPPED_THINKING_HANDLERS for the registry the framework uses
24
+ * to auto-wire by `provider.name` (Phase 3 wiring).
25
+ * @see MockThinkingHandler for the canonical example demonstrating
26
+ * both Anthropic-shape (signed blocks) and OpenAI-shape (multi-
27
+ * block summary) inputs.
28
+ */
29
+ /**
30
+ * One thinking block from an LLM response, normalized into a provider-
31
+ * agnostic shape. A response may contain multiple blocks (e.g. OpenAI's
32
+ * structured reasoning_summary emits one block per summary step).
33
+ *
34
+ * Discriminator `type`:
35
+ * - `'thinking'` — content is the model's reasoning
36
+ * - `'redacted_thinking'` — Anthropic emits this when reasoning
37
+ * trips a safety filter; content is
38
+ * EMPTY but `signature` is still required
39
+ * for round-trip on the next turn
40
+ */
41
+ export interface ThinkingBlock {
42
+ /**
43
+ * Block type discriminator. Required so consumers can distinguish
44
+ * normal thinking blocks from server-redacted ones (Anthropic-only
45
+ * today; other providers may produce only `'thinking'`).
46
+ */
47
+ readonly type: 'thinking' | 'redacted_thinking';
48
+ /**
49
+ * Reasoning content as plain text. EMPTY string when `type ===
50
+ * 'redacted_thinking'` (the model's reasoning was redacted by the
51
+ * provider's safety layer; only the signature remains).
52
+ */
53
+ readonly content: string;
54
+ /**
55
+ * Provider cryptographic signature for round-trip integrity.
56
+ *
57
+ * **Anthropic:** REQUIRED for any block emitted in a response that
58
+ * also contained tool_use. The signed block MUST be echoed
59
+ * byte-exact in the assistant message of subsequent tool_result
60
+ * turns — Anthropic validates the signature server-side and rejects
61
+ * (HTTP 400) requests where signed blocks are missing or modified.
62
+ *
63
+ * **OpenAI:** not used (their reasoning_summary doesn't sign blocks).
64
+ *
65
+ * **Future providers:** opaque to the framework; preserved as-is.
66
+ *
67
+ * The framework persists this field in `scope.history` so the
68
+ * provider's serialization layer (Phase 4b) can echo it back on the
69
+ * next request.
70
+ */
71
+ readonly signature?: string;
72
+ /**
73
+ * `true` when this block is a structured-summary step rather than
74
+ * raw thinking content. Set by `OpenAIThinkingHandler` for each step
75
+ * of `reasoning_summary`; never set by Anthropic. Consumers
76
+ * displaying thinking can render summary blocks differently
77
+ * (e.g. as numbered steps) from raw blocks (continuous prose).
78
+ */
79
+ readonly summary?: boolean;
80
+ /**
81
+ * Provider-specific metadata escape hatch for fields the normalized
82
+ * shape doesn't model.
83
+ *
84
+ * **ANTI-PATTERN:** providers MUST NOT include sensitive raw data
85
+ * here (PII, internal IDs, request tokens, customer data). Use the
86
+ * dedicated `signature` field for cryptographic material; nothing
87
+ * else identity-bearing. The framework excludes `providerMeta` from
88
+ * `getNarrative()` by default to avoid accidental audit-log leakage.
89
+ */
90
+ readonly providerMeta?: Readonly<Record<string, unknown>>;
91
+ }
92
+ /**
93
+ * The consumer-facing contract for thinking normalization. Provider
94
+ * authors and custom-LLM consumers implement this shape; the framework
95
+ * auto-wraps each handler in a real footprintjs subflow at chart build
96
+ * time so the trace shows it as a discrete `runtimeStageId` (e.g.
97
+ * `sf-call-llm/thinking-{id}#5`).
98
+ *
99
+ * The framework matches handlers to providers by `providerNames` —
100
+ * the first handler whose `providerNames` includes the active
101
+ * `provider.name` is auto-wired. Override per-agent via
102
+ * `.thinkingHandler(customHandler)` (Phase 3 wiring).
103
+ */
104
+ export interface ThinkingHandler {
105
+ /**
106
+ * Stable identifier used for `runtimeStageId`, telemetry, narrative
107
+ * entries, and the `agentfootprint.agent.thinking_parse_failed` event
108
+ * payload's `subflowId` field. Convention: lowercase + dash, e.g.
109
+ * `'anthropic'`, `'openai'`, `'mock'`.
110
+ */
111
+ readonly id: string;
112
+ /**
113
+ * Provider names this handler matches for auto-wire. The framework
114
+ * scans `SHIPPED_THINKING_HANDLERS` at chart build time and selects
115
+ * the first handler whose `providerNames` contains the active
116
+ * `provider.name`. Most handlers list one name; Bedrock-via-Anthropic
117
+ * style handlers may list multiple.
118
+ */
119
+ readonly providerNames: readonly string[];
120
+ /**
121
+ * Pure: raw provider data → normalized blocks.
122
+ *
123
+ * The framework wraps this call in a try/catch — throwing from
124
+ * `normalize()` does NOT abort the agent run. Instead the framework
125
+ * emits `agentfootprint.agent.thinking_parse_failed`, drops the
126
+ * thinking blocks (LLMMessage.thinkingBlocks remains undefined),
127
+ * and continues. Same graceful-failure pattern as v2.11.6
128
+ * `tools.discovery_failed`.
129
+ *
130
+ * Sync only in v2.14. Future widening to Promise return is a
131
+ * separate decision once a real consumer needs network-backed
132
+ * normalization.
133
+ *
134
+ * @param raw Provider-specific raw data — typically pulled from
135
+ * `LLMResponse.providerRef`. Handler is responsible for
136
+ * shape-checking; framework passes whatever the provider
137
+ * stashed.
138
+ * @returns Normalized blocks in the order they appeared in the
139
+ * response. Empty array when no thinking is present
140
+ * (preferred over `undefined` for type stability).
141
+ */
142
+ normalize(raw: unknown): readonly ThinkingBlock[];
143
+ /**
144
+ * Optional streaming hot-path. When provided AND the provider streams,
145
+ * the framework calls `parseChunk(chunk)` per provider chunk and
146
+ * emits `agentfootprint.stream.thinking_delta` events for any
147
+ * `thinkingDelta` returned. Handlers without streaming support omit
148
+ * this field; the framework still calls `normalize()` on the
149
+ * response's terminal `LLMResponse.providerRef`.
150
+ *
151
+ * @param chunk Provider-specific chunk shape (Anthropic emits
152
+ * `content_block_delta` events; OpenAI doesn't yet
153
+ * stream reasoning content).
154
+ * @returns Object with optional `thinkingDelta` text — when set,
155
+ * framework fires `stream.thinking_delta` event with the
156
+ * content. Return `{}` (or omit) for chunks that contain
157
+ * no thinking content.
158
+ */
159
+ parseChunk?(chunk: unknown): {
160
+ thinkingDelta?: string;
161
+ };
162
+ }
163
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/thinking/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAIH;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,mBAAmB,CAAC;IAEhD;;;;OAIG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAE5B;;;;;;OAMG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAE3B;;;;;;;;;OASG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC3D;AAID;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IAE1C;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,aAAa,EAAE,CAAC;IAElD;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG;QAAE,aAAa,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACzD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentfootprint",
3
- "version": "2.12.1",
3
+ "version": "2.14.0",
4
4
  "description": "The explainable agent framework — build AI agents you can explain, audit, and trust. Built on footprintjs.",
5
5
  "license": "MIT",
6
6
  "author": "Sanjay Krishna Anbalagan",
@@ -159,6 +159,11 @@
159
159
  "import": "./dist/esm/reliability/index.js",
160
160
  "require": "./dist/reliability/index.js"
161
161
  },
162
+ "./thinking": {
163
+ "types": "./dist/types/thinking/index.d.ts",
164
+ "import": "./dist/esm/thinking/index.js",
165
+ "require": "./dist/thinking/index.js"
166
+ },
162
167
  "./locales": {
163
168
  "types": "./dist/types/locales/index.d.ts",
164
169
  "import": "./dist/esm/locales/index.js",