qlogicagent 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 (226) hide show
  1. package/README.md +45 -45
  2. package/package.json +56 -42
  3. package/dist/agent/agent.d.ts +0 -43
  4. package/dist/agent/agent.js +0 -113
  5. package/dist/agent/tool-loop.d.ts +0 -64
  6. package/dist/agent/tool-loop.js +0 -575
  7. package/dist/agent/types.d.ts +0 -175
  8. package/dist/agent/types.js +0 -14
  9. package/dist/cli/main.d.ts +0 -11
  10. package/dist/cli/main.js +0 -23
  11. package/dist/cli/stdio-server.d.ts +0 -45
  12. package/dist/cli/stdio-server.js +0 -463
  13. package/dist/config/config.d.ts +0 -17
  14. package/dist/config/config.js +0 -21
  15. package/dist/contracts/hooks.d.ts +0 -120
  16. package/dist/contracts/hooks.js +0 -7
  17. package/dist/contracts/index.d.ts +0 -10
  18. package/dist/contracts/index.js +0 -10
  19. package/dist/contracts/planner.d.ts +0 -35
  20. package/dist/contracts/planner.js +0 -2
  21. package/dist/contracts/skill-candidate.d.ts +0 -63
  22. package/dist/contracts/skill-candidate.js +0 -195
  23. package/dist/contracts/todo.d.ts +0 -14
  24. package/dist/contracts/todo.js +0 -9
  25. package/dist/index.d.ts +0 -13
  26. package/dist/index.js +0 -15
  27. package/dist/llm/builtin-providers.d.ts +0 -10
  28. package/dist/llm/builtin-providers.js +0 -531
  29. package/dist/llm/index.d.ts +0 -15
  30. package/dist/llm/index.js +0 -14
  31. package/dist/llm/llm-client.d.ts +0 -43
  32. package/dist/llm/llm-client.js +0 -67
  33. package/dist/llm/model-catalog.d.ts +0 -53
  34. package/dist/llm/model-catalog.js +0 -191
  35. package/dist/llm/provider-def.d.ts +0 -59
  36. package/dist/llm/provider-def.js +0 -12
  37. package/dist/llm/provider-registry.d.ts +0 -54
  38. package/dist/llm/provider-registry.js +0 -147
  39. package/dist/llm/transport.d.ts +0 -62
  40. package/dist/llm/transport.js +0 -27
  41. package/dist/llm/transports/anthropic-messages.d.ts +0 -31
  42. package/dist/llm/transports/anthropic-messages.js +0 -293
  43. package/dist/llm/transports/openai-chat.d.ts +0 -36
  44. package/dist/llm/transports/openai-chat.js +0 -165
  45. package/dist/orchestration/agent-registry.d.ts +0 -41
  46. package/dist/orchestration/agent-registry.js +0 -116
  47. package/dist/orchestration/approval-aware-tool-plan.d.ts +0 -32
  48. package/dist/orchestration/approval-aware-tool-plan.js +0 -87
  49. package/dist/orchestration/context-compression.d.ts +0 -220
  50. package/dist/orchestration/context-compression.js +0 -583
  51. package/dist/orchestration/conversation-repair.d.ts +0 -61
  52. package/dist/orchestration/conversation-repair.js +0 -429
  53. package/dist/orchestration/curator-scheduler.d.ts +0 -119
  54. package/dist/orchestration/curator-scheduler.js +0 -135
  55. package/dist/orchestration/embedded-failover-policy.d.ts +0 -110
  56. package/dist/orchestration/embedded-failover-policy.js +0 -168
  57. package/dist/orchestration/error-classification.d.ts +0 -12
  58. package/dist/orchestration/error-classification.js +0 -77
  59. package/dist/orchestration/failover-classification.d.ts +0 -8
  60. package/dist/orchestration/failover-classification.js +0 -381
  61. package/dist/orchestration/failover-error.d.ts +0 -33
  62. package/dist/orchestration/failover-error.js +0 -198
  63. package/dist/orchestration/fork-subagent.d.ts +0 -100
  64. package/dist/orchestration/fork-subagent.js +0 -98
  65. package/dist/orchestration/index.d.ts +0 -120
  66. package/dist/orchestration/index.js +0 -267
  67. package/dist/orchestration/memory-flush-policy.d.ts +0 -57
  68. package/dist/orchestration/memory-flush-policy.js +0 -85
  69. package/dist/orchestration/memory-provider.d.ts +0 -14
  70. package/dist/orchestration/memory-provider.js +0 -2
  71. package/dist/orchestration/parallel-tool-calls.d.ts +0 -41
  72. package/dist/orchestration/parallel-tool-calls.js +0 -59
  73. package/dist/orchestration/prompt-cache-strategy.d.ts +0 -126
  74. package/dist/orchestration/prompt-cache-strategy.js +0 -228
  75. package/dist/orchestration/reactive-compact.d.ts +0 -73
  76. package/dist/orchestration/reactive-compact.js +0 -78
  77. package/dist/orchestration/retry-loop.d.ts +0 -22
  78. package/dist/orchestration/retry-loop.js +0 -24
  79. package/dist/orchestration/skill-candidate.d.ts +0 -52
  80. package/dist/orchestration/skill-candidate.js +0 -141
  81. package/dist/orchestration/skill-consolidation.d.ts +0 -123
  82. package/dist/orchestration/skill-consolidation.js +0 -220
  83. package/dist/orchestration/skill-improvement.d.ts +0 -59
  84. package/dist/orchestration/skill-improvement.js +0 -66
  85. package/dist/orchestration/skill-similarity.d.ts +0 -98
  86. package/dist/orchestration/skill-similarity.js +0 -131
  87. package/dist/orchestration/streaming-tool-executor.d.ts +0 -73
  88. package/dist/orchestration/streaming-tool-executor.js +0 -96
  89. package/dist/orchestration/team-orchestration.d.ts +0 -195
  90. package/dist/orchestration/team-orchestration.js +0 -369
  91. package/dist/orchestration/team-tool-loop-wiring.d.ts +0 -92
  92. package/dist/orchestration/team-tool-loop-wiring.js +0 -147
  93. package/dist/orchestration/tool-choice-policy.d.ts +0 -54
  94. package/dist/orchestration/tool-choice-policy.js +0 -164
  95. package/dist/orchestration/tool-loop-state.d.ts +0 -50
  96. package/dist/orchestration/tool-loop-state.js +0 -133
  97. package/dist/orchestration/tool-schema.d.ts +0 -39
  98. package/dist/orchestration/tool-schema.js +0 -297
  99. package/dist/orchestration/transcript-repair.d.ts +0 -42
  100. package/dist/orchestration/transcript-repair.js +0 -426
  101. package/dist/orchestration/turn-loop-guard.d.ts +0 -86
  102. package/dist/orchestration/turn-loop-guard.js +0 -92
  103. package/dist/orchestration/web-browser-policy.d.ts +0 -17
  104. package/dist/orchestration/web-browser-policy.js +0 -39
  105. package/dist/runtime/context-compression.d.ts +0 -61
  106. package/dist/runtime/context-compression.js +0 -274
  107. package/dist/runtime/hook-registry.d.ts +0 -12
  108. package/dist/runtime/hook-registry.js +0 -53
  109. package/dist/runtime/memory-hooks.d.ts +0 -23
  110. package/dist/runtime/memory-hooks.js +0 -65
  111. package/dist/runtime/tool-eligibility.d.ts +0 -59
  112. package/dist/runtime/tool-eligibility.js +0 -111
  113. package/dist/skills/index.d.ts +0 -108
  114. package/dist/skills/index.js +0 -82
  115. package/dist/skills/memory-extractor.d.ts +0 -64
  116. package/dist/skills/memory-extractor.js +0 -173
  117. package/dist/skills/memory-query-tool.d.ts +0 -43
  118. package/dist/skills/memory-query-tool.js +0 -127
  119. package/dist/skills/memory-store.d.ts +0 -66
  120. package/dist/skills/memory-store.js +0 -228
  121. package/dist/skills/memory-tool.d.ts +0 -67
  122. package/dist/skills/memory-tool.js +0 -192
  123. package/dist/skills/portable-tool.d.ts +0 -71
  124. package/dist/skills/portable-tool.js +0 -14
  125. package/dist/skills/qmemory-adapter.d.ts +0 -52
  126. package/dist/skills/qmemory-adapter.js +0 -165
  127. package/dist/skills/skill-frontmatter.d.ts +0 -19
  128. package/dist/skills/skill-frontmatter.js +0 -344
  129. package/dist/skills/skill-guard.d.ts +0 -23
  130. package/dist/skills/skill-guard.js +0 -229
  131. package/dist/skills/skill-loader.d.ts +0 -16
  132. package/dist/skills/skill-loader.js +0 -303
  133. package/dist/skills/skill-source.d.ts +0 -119
  134. package/dist/skills/skill-source.js +0 -126
  135. package/dist/skills/skill-types.d.ts +0 -199
  136. package/dist/skills/skill-types.js +0 -6
  137. package/dist/skills/think-tool.d.ts +0 -16
  138. package/dist/skills/think-tool.js +0 -59
  139. package/dist/skills/todo-tool.d.ts +0 -63
  140. package/dist/skills/todo-tool.js +0 -114
  141. package/dist/skills/tools/agent-tool.d.ts +0 -91
  142. package/dist/skills/tools/agent-tool.js +0 -142
  143. package/dist/skills/tools/apply-patch-tool.d.ts +0 -29
  144. package/dist/skills/tools/apply-patch-tool.js +0 -184
  145. package/dist/skills/tools/ask-user-tool.d.ts +0 -80
  146. package/dist/skills/tools/ask-user-tool.js +0 -121
  147. package/dist/skills/tools/brief-tool.d.ts +0 -74
  148. package/dist/skills/tools/brief-tool.js +0 -95
  149. package/dist/skills/tools/browser-tool.d.ts +0 -114
  150. package/dist/skills/tools/browser-tool.js +0 -155
  151. package/dist/skills/tools/checkpoint-tool.d.ts +0 -66
  152. package/dist/skills/tools/checkpoint-tool.js +0 -102
  153. package/dist/skills/tools/config-tool.d.ts +0 -63
  154. package/dist/skills/tools/config-tool.js +0 -143
  155. package/dist/skills/tools/cron-tool.d.ts +0 -116
  156. package/dist/skills/tools/cron-tool.js +0 -175
  157. package/dist/skills/tools/edit-tool.d.ts +0 -43
  158. package/dist/skills/tools/edit-tool.js +0 -70
  159. package/dist/skills/tools/exec-tool.d.ts +0 -102
  160. package/dist/skills/tools/exec-tool.js +0 -133
  161. package/dist/skills/tools/image-generate-tool.d.ts +0 -62
  162. package/dist/skills/tools/image-generate-tool.js +0 -67
  163. package/dist/skills/tools/instructions-tool.d.ts +0 -103
  164. package/dist/skills/tools/instructions-tool.js +0 -187
  165. package/dist/skills/tools/lsp-tool.d.ts +0 -153
  166. package/dist/skills/tools/lsp-tool.js +0 -227
  167. package/dist/skills/tools/mcp-client-types.d.ts +0 -269
  168. package/dist/skills/tools/mcp-client-types.js +0 -53
  169. package/dist/skills/tools/mcp-tool.d.ts +0 -249
  170. package/dist/skills/tools/mcp-tool.js +0 -503
  171. package/dist/skills/tools/memory-tool.d.ts +0 -74
  172. package/dist/skills/tools/memory-tool.js +0 -88
  173. package/dist/skills/tools/monitor-tool.d.ts +0 -113
  174. package/dist/skills/tools/monitor-tool.js +0 -131
  175. package/dist/skills/tools/music-generate-tool.d.ts +0 -55
  176. package/dist/skills/tools/music-generate-tool.js +0 -62
  177. package/dist/skills/tools/notify-tool.d.ts +0 -53
  178. package/dist/skills/tools/notify-tool.js +0 -62
  179. package/dist/skills/tools/patch-tool.d.ts +0 -45
  180. package/dist/skills/tools/patch-tool.js +0 -505
  181. package/dist/skills/tools/pdf-tool.d.ts +0 -66
  182. package/dist/skills/tools/pdf-tool.js +0 -88
  183. package/dist/skills/tools/plan-mode-tool.d.ts +0 -59
  184. package/dist/skills/tools/plan-mode-tool.js +0 -122
  185. package/dist/skills/tools/read-tool.d.ts +0 -51
  186. package/dist/skills/tools/read-tool.js +0 -84
  187. package/dist/skills/tools/repl-tool.d.ts +0 -70
  188. package/dist/skills/tools/repl-tool.js +0 -69
  189. package/dist/skills/tools/search-tool.d.ts +0 -112
  190. package/dist/skills/tools/search-tool.js +0 -225
  191. package/dist/skills/tools/send-message-tool.d.ts +0 -51
  192. package/dist/skills/tools/send-message-tool.js +0 -76
  193. package/dist/skills/tools/skill-list-tool.d.ts +0 -33
  194. package/dist/skills/tools/skill-list-tool.js +0 -54
  195. package/dist/skills/tools/skill-manage-tool.d.ts +0 -73
  196. package/dist/skills/tools/skill-manage-tool.js +0 -153
  197. package/dist/skills/tools/skill-view-tool.d.ts +0 -37
  198. package/dist/skills/tools/skill-view-tool.js +0 -72
  199. package/dist/skills/tools/sleep-tool.d.ts +0 -49
  200. package/dist/skills/tools/sleep-tool.js +0 -81
  201. package/dist/skills/tools/structured-output-tool.d.ts +0 -116
  202. package/dist/skills/tools/structured-output-tool.js +0 -176
  203. package/dist/skills/tools/task-tool.d.ts +0 -104
  204. package/dist/skills/tools/task-tool.js +0 -161
  205. package/dist/skills/tools/team-tool.d.ts +0 -89
  206. package/dist/skills/tools/team-tool.js +0 -105
  207. package/dist/skills/tools/tool-search-tool.d.ts +0 -51
  208. package/dist/skills/tools/tool-search-tool.js +0 -110
  209. package/dist/skills/tools/tts-tool.d.ts +0 -38
  210. package/dist/skills/tools/tts-tool.js +0 -45
  211. package/dist/skills/tools/video-edit-tool.d.ts +0 -69
  212. package/dist/skills/tools/video-edit-tool.js +0 -74
  213. package/dist/skills/tools/video-generate-tool.d.ts +0 -62
  214. package/dist/skills/tools/video-generate-tool.js +0 -66
  215. package/dist/skills/tools/video-merge-tool.d.ts +0 -105
  216. package/dist/skills/tools/video-merge-tool.js +0 -92
  217. package/dist/skills/tools/video-upscale-tool.d.ts +0 -45
  218. package/dist/skills/tools/video-upscale-tool.js +0 -52
  219. package/dist/skills/tools/web-fetch-tool.d.ts +0 -78
  220. package/dist/skills/tools/web-fetch-tool.js +0 -92
  221. package/dist/skills/tools/web-search-tool.d.ts +0 -57
  222. package/dist/skills/tools/web-search-tool.js +0 -86
  223. package/dist/skills/tools/worktree-tool.d.ts +0 -69
  224. package/dist/skills/tools/worktree-tool.js +0 -147
  225. package/dist/skills/tools/write-tool.d.ts +0 -45
  226. package/dist/skills/tools/write-tool.js +0 -81
@@ -1,100 +0,0 @@
1
- /**
2
- * Fork Sub-Agent — CC-aligned fork mechanism for spawning child agents.
3
- *
4
- * Core design principles (aligned with Claude Code):
5
- * 1. Child agent shares parent's message prefix (prompt cache hit)
6
- * 2. Fork uses placeholder results to ensure byte-identical prefix across children
7
- * 3. Child has independent tool context (doesn't pollute parent state)
8
- * 4. Results flow back via AsyncGenerator (streaming backflow)
9
- * 5. Depth control via in-memory counter (not DB-based)
10
- */
11
- import type { AgentDefinition } from "./agent-registry.js";
12
- /** Sentinel tag injected into fork children to prevent recursive forking. */
13
- export declare const FORK_SENTINEL_TAG = "<fork-child-context>";
14
- /** Placeholder text used for all tool_results in shared prefix (ensures byte-identical prefix). */
15
- export declare const FORK_PLACEHOLDER_RESULT = "Fork started \u2014 processing in background";
16
- /** Maximum fork depth for in-memory agents (more permissive than DB sidechain). */
17
- export declare const MAX_FORK_DEPTH = 4;
18
- /** Maximum fork depth for DB-backed sidechains (more conservative). */
19
- export declare const MAX_SIDECHAIN_DB_DEPTH = 2;
20
- export interface ForkContext {
21
- /** Parent's full message history (becomes shared prefix for cache). */
22
- parentMessages: unknown[];
23
- /** Parent's rendered system prompt (byte-exact for cache hit). */
24
- systemPrompt: string;
25
- /** Parent's full tool pool (useExactTools=true pattern). */
26
- parentTools: string[];
27
- /** Current fork depth (0 = root). */
28
- depth: number;
29
- /** Abort signal from parent. */
30
- abortSignal?: AbortSignal;
31
- /** Parent's agent ID for lineage tracking. */
32
- parentAgentId: string;
33
- }
34
- export interface ForkChildConfig {
35
- /** The agent definition to run. */
36
- agent: AgentDefinition;
37
- /** Task-specific prompt for this child (the unique part after shared prefix). */
38
- taskPrompt: string;
39
- /** Optional override for max turns. */
40
- maxTurns?: number;
41
- /** Whether to run in background (async). */
42
- isAsync?: boolean;
43
- }
44
- export interface ForkChildMessage {
45
- role: "assistant" | "user" | "system";
46
- content: unknown;
47
- toolCalls?: unknown[];
48
- }
49
- export interface ForkResult {
50
- /** Whether the fork completed successfully. */
51
- ok: boolean;
52
- /** Child's final output text (summary). */
53
- output: string;
54
- /** Messages produced by the child (for result backflow). */
55
- messages: ForkChildMessage[];
56
- /** Total tokens consumed by the child. */
57
- tokensUsed: number;
58
- /** Whether the child hit its turn limit. */
59
- maxTurnsReached: boolean;
60
- /** Child's agent ID. */
61
- childAgentId: string;
62
- }
63
- /**
64
- * Check if current context is inside a fork child (prevents recursive forking).
65
- */
66
- export declare function isInForkChild(messages: unknown[]): boolean;
67
- /**
68
- * Check if fork depth allows spawning another child.
69
- */
70
- export declare function canForkAtDepth(currentDepth: number, mode?: "in-memory" | "db-sidechain"): boolean;
71
- /**
72
- * Build forked messages that ensure byte-identical prefix across all fork children.
73
- *
74
- * Strategy (aligned with CC's buildForkedMessages):
75
- * 1. Keep full parent message history (all tool_use blocks, thinking, text)
76
- * 2. Replace all pending tool_results with FORK_PLACEHOLDER_RESULT
77
- * 3. Append a single user message with the child-specific directive
78
- * → All children share the same prefix up to the directive → maximum cache hits.
79
- */
80
- export declare function buildForkedMessages(context: ForkContext, childConfig: ForkChildConfig): unknown[];
81
- /**
82
- * Build placeholder tool results for the shared prefix.
83
- * When parent has pending tool_calls, replace them all with identical placeholder text
84
- * so all fork children produce byte-identical API request prefix.
85
- */
86
- export declare function buildForkPlaceholderResults(pendingToolCallIds: string[]): Array<{
87
- role: "tool";
88
- tool_call_id: string;
89
- content: string;
90
- }>;
91
- /**
92
- * Resolve the effective tool set for a fork child.
93
- * CC pattern: useExactTools=true → child gets parent's full tool pool,
94
- * then filtered by agent definition.
95
- */
96
- export declare function resolveForkChildTools(parentTools: string[], agent: AgentDefinition): string[];
97
- /**
98
- * Generate a unique agent ID for a fork child.
99
- */
100
- export declare function generateForkChildAgentId(parentAgentId: string, agentName: string, depth: number): string;
@@ -1,98 +0,0 @@
1
- /**
2
- * Fork Sub-Agent — CC-aligned fork mechanism for spawning child agents.
3
- *
4
- * Core design principles (aligned with Claude Code):
5
- * 1. Child agent shares parent's message prefix (prompt cache hit)
6
- * 2. Fork uses placeholder results to ensure byte-identical prefix across children
7
- * 3. Child has independent tool context (doesn't pollute parent state)
8
- * 4. Results flow back via AsyncGenerator (streaming backflow)
9
- * 5. Depth control via in-memory counter (not DB-based)
10
- */
11
- /** Sentinel tag injected into fork children to prevent recursive forking. */
12
- export const FORK_SENTINEL_TAG = "<fork-child-context>";
13
- /** Placeholder text used for all tool_results in shared prefix (ensures byte-identical prefix). */
14
- export const FORK_PLACEHOLDER_RESULT = "Fork started \u2014 processing in background";
15
- /** Maximum fork depth for in-memory agents (more permissive than DB sidechain). */
16
- export const MAX_FORK_DEPTH = 4;
17
- /** Maximum fork depth for DB-backed sidechains (more conservative). */
18
- export const MAX_SIDECHAIN_DB_DEPTH = 2;
19
- /**
20
- * Check if current context is inside a fork child (prevents recursive forking).
21
- */
22
- export function isInForkChild(messages) {
23
- return JSON.stringify(messages).includes(FORK_SENTINEL_TAG);
24
- }
25
- /**
26
- * Check if fork depth allows spawning another child.
27
- */
28
- export function canForkAtDepth(currentDepth, mode = "in-memory") {
29
- const maxDepth = mode === "in-memory" ? MAX_FORK_DEPTH : MAX_SIDECHAIN_DB_DEPTH;
30
- return currentDepth < maxDepth;
31
- }
32
- /**
33
- * Build forked messages that ensure byte-identical prefix across all fork children.
34
- *
35
- * Strategy (aligned with CC's buildForkedMessages):
36
- * 1. Keep full parent message history (all tool_use blocks, thinking, text)
37
- * 2. Replace all pending tool_results with FORK_PLACEHOLDER_RESULT
38
- * 3. Append a single user message with the child-specific directive
39
- * → All children share the same prefix up to the directive → maximum cache hits.
40
- */
41
- export function buildForkedMessages(context, childConfig) {
42
- const messages = [...context.parentMessages];
43
- // Inject fork sentinel + child task as the unique tail
44
- const childDirective = {
45
- role: "user",
46
- content: [
47
- { type: "text", text: `${FORK_SENTINEL_TAG}\n\nYou are the "${childConfig.agent.name}" agent.\n\n${childConfig.taskPrompt}` },
48
- ],
49
- };
50
- messages.push(childDirective);
51
- return messages;
52
- }
53
- /**
54
- * Build placeholder tool results for the shared prefix.
55
- * When parent has pending tool_calls, replace them all with identical placeholder text
56
- * so all fork children produce byte-identical API request prefix.
57
- */
58
- export function buildForkPlaceholderResults(pendingToolCallIds) {
59
- return pendingToolCallIds.map((id) => ({
60
- role: "tool",
61
- tool_call_id: id,
62
- content: FORK_PLACEHOLDER_RESULT,
63
- }));
64
- }
65
- /**
66
- * Resolve the effective tool set for a fork child.
67
- * CC pattern: useExactTools=true → child gets parent's full tool pool,
68
- * then filtered by agent definition.
69
- */
70
- export function resolveForkChildTools(parentTools, agent) {
71
- if (agent.allowedTools && agent.allowedTools.length > 0) {
72
- const allowed = new Set(agent.allowedTools);
73
- return parentTools.filter((t) => allowed.has(t));
74
- }
75
- if (agent.toolAccessMode === "none")
76
- return [];
77
- if (agent.toolAccessMode === "read-only") {
78
- const writeTools = new Set([
79
- "file_edit", "create_file", "write_file", "replace_string_in_file",
80
- "multi_replace_string_in_file", "create_directory", "delete_file",
81
- "rename_file", "move_file", "exec", "run_in_terminal", "run_command",
82
- "git_commit", "git_push", "patch",
83
- ]);
84
- return parentTools.filter((t) => !writeTools.has(t));
85
- }
86
- // full access — remove agent_tool if canFork=false
87
- if (!agent.canFork) {
88
- return parentTools.filter((t) => t !== "agent_tool");
89
- }
90
- return [...parentTools];
91
- }
92
- /**
93
- * Generate a unique agent ID for a fork child.
94
- */
95
- export function generateForkChildAgentId(parentAgentId, agentName, depth) {
96
- const ts = Date.now().toString(36);
97
- return `${parentAgentId}:fork:${agentName}:d${depth}:${ts}`;
98
- }
@@ -1,120 +0,0 @@
1
- export { buildAssistantToolCallMessage, buildToolResultMessage, cleanToolSchemaForGemini, convertCapabilityToolManifestsToFunctionTools, convertFunctionTools, isXaiProvider, normalizeMessageTextContent, normalizeFunctionToolParameters, parseOpenAiToolCallsFromChatResponse, type CapabilityToolManifestLike, type FunctionToolDefinition, type FunctionToolSource, type ToolSchemaProvider, } from "./tool-schema.js";
2
- export { classifyError, classifyErrorFromReason, getRetryStrategy, type ErrorCategory, type RetryStrategy, } from "./error-classification.js";
3
- export { composeStrategies, composeAsyncStrategies, SlidingWindowStrategy, SummarizeOldStrategy, ToolResultTrimStrategy, HeadTailProtectedStrategy, IncrementalCompactStrategy, CacheAwareCompressionStrategy, CompressionMetricsCollector, ContextEngineRegistry, buildStructuredSummaryPrompt, computeAdaptiveBudget, isAsyncCompressionStrategy, selectCompressionTier, DEFAULT_ADAPTIVE_BUDGET_CONFIG, type AdaptiveBudgetConfig, type AsyncCompressionStrategy, type CacheAwareCompressionConfig, type CompressibleMessage, type CompressionEvent, type CompressionMetrics, type CompressionMetricsSnapshot, type CompressionResult, type CompressionStrategy, type CompressionTier, type ContextEngine, type HeadTailProtectionConfig, type IncrementalCompactConfig, type SummarizeFn, } from "./context-compression.js";
4
- export { buildSkillInstruction, shouldCreateSkill, shouldImproveSkill, type SkillCreateInstruction, type SkillImproveInstruction, type SkillInstruction, type SkillTurnResult, } from "./skill-improvement.js";
5
- export { buildSkillCandidateEffectivenessSummary, buildSkillCandidateEvidencePayload, buildSkillCandidateImprovementEvidenceBundle, buildSkillCandidateLatestReview, createDefaultSkillImprovementPolicy, normalizeSkillImprovementPolicy, type SkillCandidateImprovementEvidenceBundleContract, type SkillImprovementPolicyContract, } from "./skill-candidate.js";
6
- export declare const SIDECHAIN_TYPE_VALUES: readonly ["research", "planner", "plan-repair", "code-repair", "media-prep"];
7
- export type SidechainType = typeof SIDECHAIN_TYPE_VALUES[number];
8
- export type SidechainBudgetTier = "low" | "medium" | "high";
9
- export type SidechainMergePolicy = "summary-only" | "append-messages" | "replace-context" | "manual";
10
- export type SidechainToolAccessMode = "full" | "read-only" | "none";
11
- export interface SidechainTypePolicy {
12
- type: SidechainType;
13
- label: string;
14
- description: string;
15
- mergePolicy: SidechainMergePolicy;
16
- budgetTier: SidechainBudgetTier;
17
- budgetWeight: number;
18
- preferFullContext: boolean;
19
- preserveConversationHistory: boolean;
20
- toolAccessMode: SidechainToolAccessMode;
21
- }
22
- export type SidechainToolAccessDecision = "allowed" | "denied";
23
- export type SidechainToolAccessInheritance = "inherit" | "shrink";
24
- export type SidechainToolAccessReason = "default-allow" | "always-deny" | "leaf-deny";
25
- export interface SidechainToolAccessRule {
26
- toolName: string;
27
- decision: SidechainToolAccessDecision;
28
- inheritance: SidechainToolAccessInheritance;
29
- reason: SidechainToolAccessReason;
30
- }
31
- export interface SidechainToolAccessPolicy {
32
- deniedTools: string[];
33
- canSpawnChildren: boolean;
34
- defaultDecision: "allowed";
35
- defaultInheritance: "inherit";
36
- tools: SidechainToolAccessRule[];
37
- }
38
- export declare const SIDECHAIN_TOOL_DENY_ALWAYS: readonly ["gateway", "agents_list", "whatsapp_login", "session_status", "cron", "memory_query", "sessions_send"];
39
- export declare const SIDECHAIN_TOOL_DENY_LEAF: readonly ["sessions_list", "sessions_history", "sessions_spawn"];
40
- /** Tools that perform write/mutation operations — denied in read-only sidechain types. */
41
- export declare const SIDECHAIN_TOOL_DENY_WRITE: readonly ["file_edit", "create_file", "replace_string_in_file", "multi_replace_string_in_file", "create_directory", "run_in_terminal", "run_command", "delete_file", "rename_file", "move_file", "git_commit", "git_push", "manage_todo_list"];
42
- export declare function resolveSidechainToolAccessPolicy(params?: {
43
- depth?: number;
44
- maxDepth?: number;
45
- role?: "leaf" | "orchestrator";
46
- toolNames?: Iterable<string>;
47
- }): SidechainToolAccessPolicy;
48
- /**
49
- * Resolve tool access policy for a specific sidechain type.
50
- * Combines depth-based deny lists with type-specific access mode:
51
- * - "full": only depth-based denials apply
52
- * - "read-only": depth-based + all write/mutation tools denied
53
- * - "none": all tools denied
54
- */
55
- export declare function resolveSidechainToolAccessByType(params: {
56
- type: SidechainType;
57
- depth?: number;
58
- maxDepth?: number;
59
- role?: "leaf" | "orchestrator";
60
- toolNames?: Iterable<string>;
61
- }): SidechainToolAccessPolicy;
62
- export interface ToolCallAccessFilterResult<T> {
63
- allowed: T[];
64
- denied: Array<{
65
- toolCall: T;
66
- reason: string;
67
- }>;
68
- }
69
- /**
70
- * Filter tool_calls against a resolved access policy.
71
- * Returns allowed calls and denied calls with reasons.
72
- * T must have at least { id: string; function: { name: string } }.
73
- */
74
- export declare function filterToolCallsByAccessPolicy<T extends {
75
- id: string;
76
- function: {
77
- name: string;
78
- };
79
- }>(toolCalls: T[], policy: SidechainToolAccessPolicy): ToolCallAccessFilterResult<T>;
80
- export declare function listSidechainTypePolicies(): SidechainTypePolicy[];
81
- export declare function resolveSidechainTypePolicy(type: SidechainType): SidechainTypePolicy;
82
- export declare function resolveRepairSidechainType(params?: {
83
- toolNames?: Iterable<string>;
84
- preferCodeRepair?: boolean;
85
- trigger?: string;
86
- }): Extract<SidechainType, "plan-repair" | "code-repair">;
87
- export declare function resolveSidechainMergePolicyByType(type: SidechainType, overrides?: {
88
- forceManualReview?: boolean;
89
- preferFullContext?: boolean;
90
- preserveConversationHistory?: boolean;
91
- }): SidechainMergePolicy;
92
- export declare function resolveSidechainMergePolicy(params?: {
93
- preferFullContext?: boolean;
94
- forceManualReview?: boolean;
95
- preserveConversationHistory?: boolean;
96
- }): SidechainMergePolicy;
97
- export { applyToolChoiceCompatibility, applyToolChoicePolicy, filterEligibleTools, normalizeAnthropicFunctionToolDefinition, normalizeAnthropicToolChoice, type ApplyToolChoicePolicyInput, type ApplyToolChoicePolicyResult, type ToolEligibilityLike, type ToolChoiceCompatibilityPolicy, type ToolChoiceLike, type ToolChoiceToolLike, } from "./tool-choice-policy.js";
98
- export { downgradeOpenAiFunctionCallReasoningPairs, downgradeOpenAiReasoningBlocks, ensureAssistantReasoningContent, injectDanglingToolCallPlaceholders, repairOpenAiChatConversation, repairOpenAiResponsesItems, sanitizeOpenAiChatMessages, stripForcedStopAssistantToolMetadata, type ConversationRepairOptions, type ContentPart, type OpenAiChatMessageLike, type OpenAiChatToolCallRef, type OpenAiResponsesItemLike, type OpenAiToolCall, } from "./conversation-repair.js";
99
- export { classifyFailoverReason, classifyFailoverReasonFromHttpStatus, isCloudflareOrHtmlErrorPage, isFailoverErrorMessage, isModelNotFoundErrorMessage, isTimeoutErrorMessage, isTransientHttpError, type FailoverReason, } from "./failover-classification.js";
100
- export { FailoverError, coerceToFailoverError, describeFailoverError, isFailoverError, isTimeoutError, resolveFailoverReasonFromError, resolveFailoverStatus, } from "./failover-error.js";
101
- export { repairToolCallInputs, repairToolUseResultPairing, sanitizeToolCallInputs, sanitizeToolUseResultPairing, stripToolResultDetails, stripTransientErrorMessages, type ToolCallInputRepairOptions, type ToolCallInputRepairReport, type ToolUseRepairOptions, type ToolUseRepairReport, type TranscriptMessageLike, type TranscriptToolCallLike, } from "./transcript-repair.js";
102
- export { normalizeParallelToolCallsPreference, resolveParallelToolCallScheduling, type ParallelToolCallsPreference, type ResolveParallelToolCallSchedulingInput, type ResolveParallelToolCallSchedulingResult, type ToolCallBatch, type ToolCallLike, type ToolCapabilityLike, } from "./parallel-tool-calls.js";
103
- export { advanceToolLoopState, createToolLoopState, recoverToolLoopStateFromChatConversation, recoverToolLoopStateFromResponsesItems, settleToolLoopState, type RepairToolLoopStateResult, type ToolLoopRepairAction, type ToolLoopState, } from "./tool-loop-state.js";
104
- export { MEMORY_OBSERVATION_HOOK_VALUES, MEMORY_OBSERVATION_SOURCE_VALUES, MEMORY_WRITE_ACCESS_VALUES, type MemoryObservationHook, type MemoryObservationSource, type MemoryWriteAccess, type MemoryProviderLifecycleInvocation, } from "./memory-provider.js";
105
- export { hasAlreadyFlushedForCurrentCompaction, resolveMemoryFlushProjection, resolveMemoryFlushReadPlan, shouldRunMemoryFlush, type MemoryFlushCompactionStateLike, type MemoryFlushProjection, type MemoryFlushReadPlan, type MemoryFlushTokenStateLike, } from "./memory-flush-policy.js";
106
- export { executeBoundedRetryLoop, resolveScaledRetryIterations, } from "./retry-loop.js";
107
- export { buildAssistantFailoverErrorDetails, pickFallbackThinkingLevel, resolveAssistantFailureActionDecision, resolveAuthProfileFailoverReason, resolveFallbackThinkingDecision, resolvePromptErrorPolicy, resolvePromptFailureActionDecision, resolveRetryableFailureReason, shouldAttemptAssistantFailureRotation, shouldAttemptPromptFailureRotation, type EmbeddedAssistantFailureAction, type EmbeddedPromptErrorPolicyResolution, type EmbeddedPromptFailureAction, } from "./embedded-failover-policy.js";
108
- export { buildApprovalAwareReason, buildApprovalStepContext, summarizeApprovalAwareToolPlan, type ApprovalAwareToolCapability, type ApprovalAwareToolPlanStep, type ToolExecutionStepContext, } from "./approval-aware-tool-plan.js";
109
- export { resolveWebBrowserPolicy, type ResolveWebBrowserPolicyInput, type ResolveWebBrowserPolicyResult, } from "./web-browser-policy.js";
110
- export { applyCacheMarkers, computeCacheBreakpoints, createCacheBreakDetectionState, DEFAULT_PROMPT_CACHE_POLICY, detectCacheBreaks, estimateCacheSavingsRatio, quickHash, resolveForkCacheMarkerIndex, type CacheableMessage, type CacheBreakDetectionState, type CacheBreakEvent, type CacheBreakpoint, type CacheMarkingResult, type CacheRetention, type CacheSegmentKind, type PromptCachePolicy, } from "./prompt-cache-strategy.js";
111
- export { computeLifecycleTransitions, DEFAULT_CURATOR_SCHEDULE_POLICY, INITIAL_CURATOR_STATE, selectReviewCandidates, shouldRunCurator, type CuratorAutoTransitionResult, type CuratorGateInput, type CuratorGateResult, type CuratorLifecycleTransition, type CuratorSchedulePolicy, type CuratorSkillLifecycleState, type CuratorSkillRecord, type CuratorState, } from "./curator-scheduler.js";
112
- export { buildConsolidationPrompt, buildCuratorRunSummary, detectPrefixClusters, parseConsolidationOutput, reconcileConsolidationPlan, type ConsolidationAction, type ConsolidationPlan, type ConsolidationSkillSummary, type CuratorRunReport, type PruningAction, type ReconciledConsolidationPlan, type SkillPrefixCluster, } from "./skill-consolidation.js";
113
- export { bigramSimilarity, computeSimilarity, decideSimilarityAction, DEFAULT_SKILL_SIMILARITY_POLICY, findSimilarSkills, stepCountProximity, toolSetJaccard, type SimilarityDecision, type SimilarityScore, type SimilarSkillMatch, type SkillSimilarityPolicy, type SkillSimilarityProfile, } from "./skill-similarity.js";
114
- export { aggregateTeamResults, allocateTokenBudgets, buildAgentTaskPrompt, inferAggregationPolicy, inferExecutionMode, mapRoleToSidechainType, resolveAgentToolAccess, resolveExecutionOrder, resolveTeamPlan, shouldCancelTeam, TEAM_MAX_AGENTS, TEAM_MAX_DEPTH, validateTeamPlan, type AgentRole, type TeamAgentResult, type TeamAgentSpec, type TeamAggregationPolicy, type TeamExecutionMode, type TeamLifecycleState, type TeamPlan, type TeamResult, } from "./team-orchestration.js";
115
- export { canDispatchDuringStreaming, createStreamingToolExecutor, type StreamingToolCall, type StreamingToolExecutor, type StreamingToolExecutorConfig, type StreamingToolResult, type ToolExecutorFn, } from "./streaming-tool-executor.js";
116
- export { canForkAtDepth, buildForkedMessages, buildForkPlaceholderResults, FORK_PLACEHOLDER_RESULT, FORK_SENTINEL_TAG, generateForkChildAgentId, isInForkChild, MAX_FORK_DEPTH, MAX_SIDECHAIN_DB_DEPTH, resolveForkChildTools, type ForkChildConfig, type ForkChildMessage, type ForkContext, type ForkResult, } from "./fork-subagent.js";
117
- export { getBuiltInAgent, getBuiltInAgents, isBuiltInAgent, resolveAgentToolSet, type AgentDefinition, } from "./agent-registry.js";
118
- export { calculateTokenWarningState, createTurnLoopGuardState, resolveApiErrorRecovery, resolveOutputTokenEscalation, shouldAbortTurn, type ApiErrorRecovery, type TokenWarningState, type TurnLoopGuardConfig, type TurnLoopGuardState, } from "./turn-loop-guard.js";
119
- export { buildPostCompactRestorationMessage, computeToolDelta, createReactiveCompactState, DEFAULT_REACTIVE_COMPACT_CONFIG, shouldAttemptReactiveCompact, type PostCompactRestorationPayload, type ReactiveCompactConfig, type ReactiveCompactState, } from "./reactive-compact.js";
120
- export { aggregateTeamToolResults, mapTeamRequestToForkConfigs, resolveTeamExecutionPlan, type TeamAgentRequest, type TeamAggregatedResult, type TeamExecutionBatch, type TeamExecutionPlan, type TeamToolRequest, } from "./team-tool-loop-wiring.js";
@@ -1,267 +0,0 @@
1
- export { buildAssistantToolCallMessage, buildToolResultMessage, cleanToolSchemaForGemini, convertCapabilityToolManifestsToFunctionTools, convertFunctionTools, isXaiProvider, normalizeMessageTextContent, normalizeFunctionToolParameters, parseOpenAiToolCallsFromChatResponse, } from "./tool-schema.js";
2
- export { classifyError, classifyErrorFromReason, getRetryStrategy, } from "./error-classification.js";
3
- export { composeStrategies, composeAsyncStrategies, SlidingWindowStrategy, SummarizeOldStrategy, ToolResultTrimStrategy, HeadTailProtectedStrategy, IncrementalCompactStrategy, CacheAwareCompressionStrategy, CompressionMetricsCollector, ContextEngineRegistry, buildStructuredSummaryPrompt, computeAdaptiveBudget, isAsyncCompressionStrategy, selectCompressionTier, DEFAULT_ADAPTIVE_BUDGET_CONFIG, } from "./context-compression.js";
4
- export { buildSkillInstruction, shouldCreateSkill, shouldImproveSkill, } from "./skill-improvement.js";
5
- export { buildSkillCandidateEffectivenessSummary, buildSkillCandidateEvidencePayload, buildSkillCandidateImprovementEvidenceBundle, buildSkillCandidateLatestReview, createDefaultSkillImprovementPolicy, normalizeSkillImprovementPolicy, } from "./skill-candidate.js";
6
- export const SIDECHAIN_TYPE_VALUES = ["research", "planner", "plan-repair", "code-repair", "media-prep"];
7
- const SIDECHAIN_TYPE_POLICY_MAP = {
8
- research: {
9
- type: "research",
10
- label: "Research",
11
- description: "Independent retrieval or evidence gathering branches.",
12
- mergePolicy: "summary-only",
13
- budgetTier: "medium",
14
- budgetWeight: 2,
15
- preferFullContext: false,
16
- preserveConversationHistory: true,
17
- toolAccessMode: "read-only",
18
- },
19
- planner: {
20
- type: "planner",
21
- label: "Planner",
22
- description: "Planning and tool orchestration branches that may return structured context.",
23
- mergePolicy: "append-messages",
24
- budgetTier: "high",
25
- budgetWeight: 3,
26
- preferFullContext: true,
27
- preserveConversationHistory: true,
28
- toolAccessMode: "none",
29
- },
30
- "plan-repair": {
31
- type: "plan-repair",
32
- label: "Plan Repair",
33
- description: "Failure repair or fallback branches that re-plan tool choice, ordering, or approval strategy.",
34
- mergePolicy: "replace-context",
35
- budgetTier: "medium",
36
- budgetWeight: 2,
37
- preferFullContext: true,
38
- preserveConversationHistory: false,
39
- toolAccessMode: "none",
40
- },
41
- "code-repair": {
42
- type: "code-repair",
43
- label: "Code Repair",
44
- description: "Recovery branches focused on file edits, patch validation, or workspace mutation repair.",
45
- mergePolicy: "replace-context",
46
- budgetTier: "high",
47
- budgetWeight: 3,
48
- preferFullContext: true,
49
- preserveConversationHistory: false,
50
- toolAccessMode: "full",
51
- },
52
- "media-prep": {
53
- type: "media-prep",
54
- label: "Media Prep",
55
- description: "Preparation branches for media generation, normalization, or staging.",
56
- mergePolicy: "summary-only",
57
- budgetTier: "low",
58
- budgetWeight: 1,
59
- preferFullContext: false,
60
- preserveConversationHistory: false,
61
- toolAccessMode: "read-only",
62
- },
63
- };
64
- export const SIDECHAIN_TOOL_DENY_ALWAYS = [
65
- "gateway",
66
- "agents_list",
67
- "whatsapp_login",
68
- "session_status",
69
- "cron",
70
- "memory_query",
71
- "sessions_send",
72
- ];
73
- export const SIDECHAIN_TOOL_DENY_LEAF = [
74
- "sessions_list",
75
- "sessions_history",
76
- "sessions_spawn",
77
- ];
78
- /** Tools that perform write/mutation operations — denied in read-only sidechain types. */
79
- export const SIDECHAIN_TOOL_DENY_WRITE = [
80
- "file_edit",
81
- "create_file",
82
- "replace_string_in_file",
83
- "multi_replace_string_in_file",
84
- "create_directory",
85
- "run_in_terminal",
86
- "run_command",
87
- "delete_file",
88
- "rename_file",
89
- "move_file",
90
- "git_commit",
91
- "git_push",
92
- "manage_todo_list",
93
- ];
94
- export function resolveSidechainToolAccessPolicy(params = {}) {
95
- const maxDepth = Math.max(1, Math.floor(params.maxDepth ?? 2));
96
- const depth = typeof params.depth === "number" && Number.isFinite(params.depth)
97
- ? Math.max(0, Math.floor(params.depth))
98
- : maxDepth;
99
- const isLeaf = params.role ? params.role === "leaf" : depth >= maxDepth;
100
- const deniedTools = isLeaf
101
- ? [...SIDECHAIN_TOOL_DENY_ALWAYS, ...SIDECHAIN_TOOL_DENY_LEAF]
102
- : [...SIDECHAIN_TOOL_DENY_ALWAYS];
103
- const deniedSet = new Set(deniedTools);
104
- const toolNames = Array.isArray(params.toolNames)
105
- ? params.toolNames
106
- : params.toolNames
107
- ? Array.from(params.toolNames)
108
- : [];
109
- const tools = Array.from(new Set(toolNames.map((toolName) => toolName.trim()).filter(Boolean))).map((toolName) => {
110
- const denied = deniedSet.has(toolName);
111
- return {
112
- toolName,
113
- decision: denied ? "denied" : "allowed",
114
- inheritance: denied ? "shrink" : "inherit",
115
- reason: denied
116
- ? SIDECHAIN_TOOL_DENY_ALWAYS.includes(toolName)
117
- ? "always-deny"
118
- : "leaf-deny"
119
- : "default-allow",
120
- };
121
- });
122
- return {
123
- deniedTools,
124
- canSpawnChildren: !isLeaf,
125
- defaultDecision: "allowed",
126
- defaultInheritance: "inherit",
127
- tools,
128
- };
129
- }
130
- /**
131
- * Resolve tool access policy for a specific sidechain type.
132
- * Combines depth-based deny lists with type-specific access mode:
133
- * - "full": only depth-based denials apply
134
- * - "read-only": depth-based + all write/mutation tools denied
135
- * - "none": all tools denied
136
- */
137
- export function resolveSidechainToolAccessByType(params) {
138
- const policy = resolveSidechainTypePolicy(params.type);
139
- const basePolicy = resolveSidechainToolAccessPolicy({
140
- depth: params.depth,
141
- maxDepth: params.maxDepth,
142
- role: params.role,
143
- toolNames: params.toolNames,
144
- });
145
- if (policy.toolAccessMode === "full") {
146
- return basePolicy;
147
- }
148
- if (policy.toolAccessMode === "none") {
149
- const allToolNames = Array.isArray(params.toolNames)
150
- ? params.toolNames
151
- : params.toolNames ? Array.from(params.toolNames) : [];
152
- const uniqueNames = [...new Set(allToolNames.map((n) => n.trim()).filter(Boolean))];
153
- return {
154
- deniedTools: uniqueNames,
155
- canSpawnChildren: false,
156
- defaultDecision: "allowed",
157
- defaultInheritance: "inherit",
158
- tools: uniqueNames.map((toolName) => ({
159
- toolName,
160
- decision: "denied",
161
- inheritance: "shrink",
162
- reason: "always-deny",
163
- })),
164
- };
165
- }
166
- // "read-only": add write tools to deny list
167
- const writeSet = new Set(SIDECHAIN_TOOL_DENY_WRITE);
168
- const combinedDenied = [...new Set([...basePolicy.deniedTools, ...SIDECHAIN_TOOL_DENY_WRITE])];
169
- return {
170
- ...basePolicy,
171
- deniedTools: combinedDenied,
172
- tools: basePolicy.tools.map((rule) => {
173
- if (rule.decision === "denied")
174
- return rule;
175
- if (writeSet.has(rule.toolName)) {
176
- return { ...rule, decision: "denied", inheritance: "shrink", reason: "always-deny" };
177
- }
178
- return rule;
179
- }),
180
- };
181
- }
182
- /**
183
- * Filter tool_calls against a resolved access policy.
184
- * Returns allowed calls and denied calls with reasons.
185
- * T must have at least { id: string; function: { name: string } }.
186
- */
187
- export function filterToolCallsByAccessPolicy(toolCalls, policy) {
188
- const deniedSet = new Set(policy.deniedTools);
189
- const ruleMap = new Map(policy.tools.map((r) => [r.toolName, r]));
190
- const allowed = [];
191
- const denied = [];
192
- for (const tc of toolCalls) {
193
- const name = tc.function.name;
194
- const rule = ruleMap.get(name);
195
- if (rule?.decision === "denied") {
196
- denied.push({ toolCall: tc, reason: `tool "${name}" denied by sidechain policy: ${rule.reason}` });
197
- }
198
- else if (deniedSet.has(name)) {
199
- denied.push({ toolCall: tc, reason: `tool "${name}" is in sidechain deny list` });
200
- }
201
- else {
202
- allowed.push(tc);
203
- }
204
- }
205
- return { allowed, denied };
206
- }
207
- export function listSidechainTypePolicies() {
208
- return SIDECHAIN_TYPE_VALUES.map((type) => SIDECHAIN_TYPE_POLICY_MAP[type]);
209
- }
210
- export function resolveSidechainTypePolicy(type) {
211
- return SIDECHAIN_TYPE_POLICY_MAP[type];
212
- }
213
- export function resolveRepairSidechainType(params = {}) {
214
- if (params.preferCodeRepair) {
215
- return "code-repair";
216
- }
217
- const trigger = typeof params.trigger === "string" ? params.trigger.trim().toLowerCase() : "";
218
- if (trigger.includes("code") || trigger.includes("patch") || trigger.includes("workspace")) {
219
- return "code-repair";
220
- }
221
- const toolNames = Array.from(params.toolNames ?? []).map((toolName) => toolName.trim().toLowerCase()).filter(Boolean);
222
- const codeRepairHints = ["code", "edit", "patch", "diff", "file", "workspace", "git", "terminal"];
223
- return toolNames.some((toolName) => codeRepairHints.some((hint) => toolName.includes(hint)))
224
- ? "code-repair"
225
- : "plan-repair";
226
- }
227
- export function resolveSidechainMergePolicyByType(type, overrides = {}) {
228
- const policy = resolveSidechainTypePolicy(type);
229
- return resolveSidechainMergePolicy({
230
- forceManualReview: overrides.forceManualReview,
231
- preferFullContext: overrides.preferFullContext ?? policy.preferFullContext,
232
- preserveConversationHistory: overrides.preserveConversationHistory ?? policy.preserveConversationHistory,
233
- });
234
- }
235
- export function resolveSidechainMergePolicy(params = {}) {
236
- if (params.forceManualReview) {
237
- return "manual";
238
- }
239
- if (params.preferFullContext) {
240
- return params.preserveConversationHistory ? "append-messages" : "replace-context";
241
- }
242
- return "summary-only";
243
- }
244
- export { applyToolChoiceCompatibility, applyToolChoicePolicy, filterEligibleTools, normalizeAnthropicFunctionToolDefinition, normalizeAnthropicToolChoice, } from "./tool-choice-policy.js";
245
- export { downgradeOpenAiFunctionCallReasoningPairs, downgradeOpenAiReasoningBlocks, ensureAssistantReasoningContent, injectDanglingToolCallPlaceholders, repairOpenAiChatConversation, repairOpenAiResponsesItems, sanitizeOpenAiChatMessages, stripForcedStopAssistantToolMetadata, } from "./conversation-repair.js";
246
- export { classifyFailoverReason, classifyFailoverReasonFromHttpStatus, isCloudflareOrHtmlErrorPage, isFailoverErrorMessage, isModelNotFoundErrorMessage, isTimeoutErrorMessage, isTransientHttpError, } from "./failover-classification.js";
247
- export { FailoverError, coerceToFailoverError, describeFailoverError, isFailoverError, isTimeoutError, resolveFailoverReasonFromError, resolveFailoverStatus, } from "./failover-error.js";
248
- export { repairToolCallInputs, repairToolUseResultPairing, sanitizeToolCallInputs, sanitizeToolUseResultPairing, stripToolResultDetails, stripTransientErrorMessages, } from "./transcript-repair.js";
249
- export { normalizeParallelToolCallsPreference, resolveParallelToolCallScheduling, } from "./parallel-tool-calls.js";
250
- export { advanceToolLoopState, createToolLoopState, recoverToolLoopStateFromChatConversation, recoverToolLoopStateFromResponsesItems, settleToolLoopState, } from "./tool-loop-state.js";
251
- export { MEMORY_OBSERVATION_HOOK_VALUES, MEMORY_OBSERVATION_SOURCE_VALUES, MEMORY_WRITE_ACCESS_VALUES, } from "./memory-provider.js";
252
- export { hasAlreadyFlushedForCurrentCompaction, resolveMemoryFlushProjection, resolveMemoryFlushReadPlan, shouldRunMemoryFlush, } from "./memory-flush-policy.js";
253
- export { executeBoundedRetryLoop, resolveScaledRetryIterations, } from "./retry-loop.js";
254
- export { buildAssistantFailoverErrorDetails, pickFallbackThinkingLevel, resolveAssistantFailureActionDecision, resolveAuthProfileFailoverReason, resolveFallbackThinkingDecision, resolvePromptErrorPolicy, resolvePromptFailureActionDecision, resolveRetryableFailureReason, shouldAttemptAssistantFailureRotation, shouldAttemptPromptFailureRotation, } from "./embedded-failover-policy.js";
255
- export { buildApprovalAwareReason, buildApprovalStepContext, summarizeApprovalAwareToolPlan, } from "./approval-aware-tool-plan.js";
256
- export { resolveWebBrowserPolicy, } from "./web-browser-policy.js";
257
- export { applyCacheMarkers, computeCacheBreakpoints, createCacheBreakDetectionState, DEFAULT_PROMPT_CACHE_POLICY, detectCacheBreaks, estimateCacheSavingsRatio, quickHash, resolveForkCacheMarkerIndex, } from "./prompt-cache-strategy.js";
258
- export { computeLifecycleTransitions, DEFAULT_CURATOR_SCHEDULE_POLICY, INITIAL_CURATOR_STATE, selectReviewCandidates, shouldRunCurator, } from "./curator-scheduler.js";
259
- export { buildConsolidationPrompt, buildCuratorRunSummary, detectPrefixClusters, parseConsolidationOutput, reconcileConsolidationPlan, } from "./skill-consolidation.js";
260
- export { bigramSimilarity, computeSimilarity, decideSimilarityAction, DEFAULT_SKILL_SIMILARITY_POLICY, findSimilarSkills, stepCountProximity, toolSetJaccard, } from "./skill-similarity.js";
261
- export { aggregateTeamResults, allocateTokenBudgets, buildAgentTaskPrompt, inferAggregationPolicy, inferExecutionMode, mapRoleToSidechainType, resolveAgentToolAccess, resolveExecutionOrder, resolveTeamPlan, shouldCancelTeam, TEAM_MAX_AGENTS, TEAM_MAX_DEPTH, validateTeamPlan, } from "./team-orchestration.js";
262
- export { canDispatchDuringStreaming, createStreamingToolExecutor, } from "./streaming-tool-executor.js";
263
- export { canForkAtDepth, buildForkedMessages, buildForkPlaceholderResults, FORK_PLACEHOLDER_RESULT, FORK_SENTINEL_TAG, generateForkChildAgentId, isInForkChild, MAX_FORK_DEPTH, MAX_SIDECHAIN_DB_DEPTH, resolveForkChildTools, } from "./fork-subagent.js";
264
- export { getBuiltInAgent, getBuiltInAgents, isBuiltInAgent, resolveAgentToolSet, } from "./agent-registry.js";
265
- export { calculateTokenWarningState, createTurnLoopGuardState, resolveApiErrorRecovery, resolveOutputTokenEscalation, shouldAbortTurn, } from "./turn-loop-guard.js";
266
- export { buildPostCompactRestorationMessage, computeToolDelta, createReactiveCompactState, DEFAULT_REACTIVE_COMPACT_CONFIG, shouldAttemptReactiveCompact, } from "./reactive-compact.js";
267
- export { aggregateTeamToolResults, mapTeamRequestToForkConfigs, resolveTeamExecutionPlan, } from "./team-tool-loop-wiring.js";
@@ -1,57 +0,0 @@
1
- export interface MemoryFlushCompactionStateLike {
2
- compactionCount?: number;
3
- memoryFlushCompactionCount?: number;
4
- }
5
- export interface MemoryFlushTokenStateLike extends MemoryFlushCompactionStateLike {
6
- totalTokens?: number;
7
- totalTokensFresh?: boolean;
8
- }
9
- export interface MemoryFlushReadPlan {
10
- canAttemptFlush: boolean;
11
- flushThreshold: number;
12
- shouldReadTranscriptForOutput: boolean;
13
- shouldReadTranscript: boolean;
14
- shouldCheckTranscriptSizeForForcedFlush: boolean;
15
- shouldReadSessionLog: boolean;
16
- }
17
- export interface MemoryFlushProjection {
18
- shouldForceFlushByTranscriptSize: boolean;
19
- shouldPersistTranscriptPromptTokens: boolean;
20
- promptTokensSnapshot: number;
21
- hasFreshPromptTokensSnapshot: boolean;
22
- projectedTokenCount: number | undefined;
23
- tokenCountForFlush: number | undefined;
24
- }
25
- export declare function hasAlreadyFlushedForCurrentCompaction(entry: MemoryFlushCompactionStateLike): boolean;
26
- export declare function shouldRunMemoryFlush(params: {
27
- entry?: MemoryFlushTokenStateLike;
28
- tokenCount?: number;
29
- resolveFreshSessionTotalTokens: (entry: MemoryFlushTokenStateLike) => number | undefined;
30
- contextWindowTokens: number;
31
- reserveTokensFloor: number;
32
- softThresholdTokens: number;
33
- }): boolean;
34
- export declare function resolveMemoryFlushReadPlan(params: {
35
- memoryFlushWritable: boolean;
36
- isHeartbeat: boolean;
37
- isCli: boolean;
38
- hasSessionEntry: boolean;
39
- hasFreshPersistedPromptTokens: boolean;
40
- promptTokenEstimate?: number;
41
- persistedPromptTokens?: number;
42
- contextWindowTokens: number;
43
- reserveTokensFloor: number;
44
- softThresholdTokens: number;
45
- transcriptOutputReadBufferTokens: number;
46
- forceFlushTranscriptBytes: number;
47
- }): MemoryFlushReadPlan;
48
- export declare function resolveMemoryFlushProjection(params: {
49
- transcriptByteSize?: number;
50
- forceFlushTranscriptBytes: number;
51
- transcriptPromptTokens?: number;
52
- transcriptOutputTokens?: number;
53
- persistedPromptTokens?: number;
54
- hasFreshPersistedPromptTokens: boolean;
55
- promptTokenEstimate?: number;
56
- resolveEffectivePromptTokens: (promptTokensSnapshot: number, transcriptOutputTokens: number | undefined, promptTokenEstimate: number | undefined) => number | undefined;
57
- }): MemoryFlushProjection;