qlogicagent 0.3.0 → 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 (119) hide show
  1. package/README.md +45 -45
  2. package/package.json +1 -1
  3. package/dist/agent.js +0 -1
  4. package/dist/cli.js +0 -9
  5. package/dist/contracts.js +0 -1
  6. package/dist/index.js +0 -5
  7. package/dist/orchestration.js +0 -118
  8. package/dist/types/agent/agent.d.ts +0 -43
  9. package/dist/types/agent/tool-loop.d.ts +0 -64
  10. package/dist/types/agent/types.d.ts +0 -175
  11. package/dist/types/cli/main.d.ts +0 -11
  12. package/dist/types/cli/stdio-server.d.ts +0 -45
  13. package/dist/types/config/config.d.ts +0 -17
  14. package/dist/types/contracts/hooks.d.ts +0 -120
  15. package/dist/types/contracts/index.d.ts +0 -10
  16. package/dist/types/contracts/planner.d.ts +0 -35
  17. package/dist/types/contracts/skill-candidate.d.ts +0 -63
  18. package/dist/types/contracts/todo.d.ts +0 -14
  19. package/dist/types/index.d.ts +0 -13
  20. package/dist/types/llm/builtin-providers.d.ts +0 -10
  21. package/dist/types/llm/index.d.ts +0 -15
  22. package/dist/types/llm/llm-client.d.ts +0 -43
  23. package/dist/types/llm/model-catalog.d.ts +0 -53
  24. package/dist/types/llm/provider-def.d.ts +0 -59
  25. package/dist/types/llm/provider-registry.d.ts +0 -54
  26. package/dist/types/llm/transport.d.ts +0 -62
  27. package/dist/types/llm/transports/anthropic-messages.d.ts +0 -31
  28. package/dist/types/llm/transports/openai-chat.d.ts +0 -36
  29. package/dist/types/orchestration/agent-registry.d.ts +0 -41
  30. package/dist/types/orchestration/approval-aware-tool-plan.d.ts +0 -32
  31. package/dist/types/orchestration/context-compression.d.ts +0 -220
  32. package/dist/types/orchestration/conversation-repair.d.ts +0 -61
  33. package/dist/types/orchestration/curator-scheduler.d.ts +0 -119
  34. package/dist/types/orchestration/embedded-failover-policy.d.ts +0 -110
  35. package/dist/types/orchestration/error-classification.d.ts +0 -12
  36. package/dist/types/orchestration/failover-classification.d.ts +0 -8
  37. package/dist/types/orchestration/failover-error.d.ts +0 -33
  38. package/dist/types/orchestration/fork-subagent.d.ts +0 -100
  39. package/dist/types/orchestration/index.d.ts +0 -120
  40. package/dist/types/orchestration/memory-flush-policy.d.ts +0 -57
  41. package/dist/types/orchestration/memory-provider.d.ts +0 -14
  42. package/dist/types/orchestration/parallel-tool-calls.d.ts +0 -41
  43. package/dist/types/orchestration/prompt-cache-strategy.d.ts +0 -126
  44. package/dist/types/orchestration/reactive-compact.d.ts +0 -73
  45. package/dist/types/orchestration/retry-loop.d.ts +0 -22
  46. package/dist/types/orchestration/skill-candidate.d.ts +0 -52
  47. package/dist/types/orchestration/skill-consolidation.d.ts +0 -123
  48. package/dist/types/orchestration/skill-improvement.d.ts +0 -59
  49. package/dist/types/orchestration/skill-similarity.d.ts +0 -98
  50. package/dist/types/orchestration/streaming-tool-executor.d.ts +0 -73
  51. package/dist/types/orchestration/team-orchestration.d.ts +0 -195
  52. package/dist/types/orchestration/team-tool-loop-wiring.d.ts +0 -92
  53. package/dist/types/orchestration/tool-choice-policy.d.ts +0 -54
  54. package/dist/types/orchestration/tool-loop-state.d.ts +0 -50
  55. package/dist/types/orchestration/tool-schema.d.ts +0 -39
  56. package/dist/types/orchestration/transcript-repair.d.ts +0 -42
  57. package/dist/types/orchestration/turn-loop-guard.d.ts +0 -86
  58. package/dist/types/orchestration/web-browser-policy.d.ts +0 -17
  59. package/dist/types/runtime/context-compression.d.ts +0 -61
  60. package/dist/types/runtime/hook-registry.d.ts +0 -12
  61. package/dist/types/runtime/memory-hooks.d.ts +0 -23
  62. package/dist/types/runtime/tool-eligibility.d.ts +0 -59
  63. package/dist/types/skills/index.d.ts +0 -108
  64. package/dist/types/skills/memory-extractor.d.ts +0 -64
  65. package/dist/types/skills/memory-query-tool.d.ts +0 -43
  66. package/dist/types/skills/memory-store.d.ts +0 -66
  67. package/dist/types/skills/memory-tool.d.ts +0 -67
  68. package/dist/types/skills/portable-tool.d.ts +0 -71
  69. package/dist/types/skills/qmemory-adapter.d.ts +0 -52
  70. package/dist/types/skills/skill-frontmatter.d.ts +0 -19
  71. package/dist/types/skills/skill-guard.d.ts +0 -23
  72. package/dist/types/skills/skill-loader.d.ts +0 -16
  73. package/dist/types/skills/skill-source.d.ts +0 -119
  74. package/dist/types/skills/skill-types.d.ts +0 -199
  75. package/dist/types/skills/think-tool.d.ts +0 -16
  76. package/dist/types/skills/todo-tool.d.ts +0 -63
  77. package/dist/types/skills/tools/agent-tool.d.ts +0 -91
  78. package/dist/types/skills/tools/apply-patch-tool.d.ts +0 -29
  79. package/dist/types/skills/tools/ask-user-tool.d.ts +0 -80
  80. package/dist/types/skills/tools/brief-tool.d.ts +0 -74
  81. package/dist/types/skills/tools/browser-tool.d.ts +0 -114
  82. package/dist/types/skills/tools/checkpoint-tool.d.ts +0 -66
  83. package/dist/types/skills/tools/config-tool.d.ts +0 -63
  84. package/dist/types/skills/tools/cron-tool.d.ts +0 -116
  85. package/dist/types/skills/tools/edit-tool.d.ts +0 -43
  86. package/dist/types/skills/tools/exec-tool.d.ts +0 -102
  87. package/dist/types/skills/tools/image-generate-tool.d.ts +0 -62
  88. package/dist/types/skills/tools/instructions-tool.d.ts +0 -103
  89. package/dist/types/skills/tools/lsp-tool.d.ts +0 -153
  90. package/dist/types/skills/tools/mcp-client-types.d.ts +0 -269
  91. package/dist/types/skills/tools/mcp-tool.d.ts +0 -249
  92. package/dist/types/skills/tools/memory-tool.d.ts +0 -74
  93. package/dist/types/skills/tools/monitor-tool.d.ts +0 -113
  94. package/dist/types/skills/tools/music-generate-tool.d.ts +0 -55
  95. package/dist/types/skills/tools/notify-tool.d.ts +0 -53
  96. package/dist/types/skills/tools/patch-tool.d.ts +0 -45
  97. package/dist/types/skills/tools/pdf-tool.d.ts +0 -66
  98. package/dist/types/skills/tools/plan-mode-tool.d.ts +0 -59
  99. package/dist/types/skills/tools/read-tool.d.ts +0 -51
  100. package/dist/types/skills/tools/repl-tool.d.ts +0 -70
  101. package/dist/types/skills/tools/search-tool.d.ts +0 -112
  102. package/dist/types/skills/tools/send-message-tool.d.ts +0 -51
  103. package/dist/types/skills/tools/skill-list-tool.d.ts +0 -33
  104. package/dist/types/skills/tools/skill-manage-tool.d.ts +0 -73
  105. package/dist/types/skills/tools/skill-view-tool.d.ts +0 -37
  106. package/dist/types/skills/tools/sleep-tool.d.ts +0 -49
  107. package/dist/types/skills/tools/structured-output-tool.d.ts +0 -116
  108. package/dist/types/skills/tools/task-tool.d.ts +0 -104
  109. package/dist/types/skills/tools/team-tool.d.ts +0 -89
  110. package/dist/types/skills/tools/tool-search-tool.d.ts +0 -51
  111. package/dist/types/skills/tools/tts-tool.d.ts +0 -38
  112. package/dist/types/skills/tools/video-edit-tool.d.ts +0 -69
  113. package/dist/types/skills/tools/video-generate-tool.d.ts +0 -62
  114. package/dist/types/skills/tools/video-merge-tool.d.ts +0 -105
  115. package/dist/types/skills/tools/video-upscale-tool.d.ts +0 -45
  116. package/dist/types/skills/tools/web-fetch-tool.d.ts +0 -78
  117. package/dist/types/skills/tools/web-search-tool.d.ts +0 -57
  118. package/dist/types/skills/tools/worktree-tool.d.ts +0 -69
  119. package/dist/types/skills/tools/write-tool.d.ts +0 -45
@@ -1,36 +0,0 @@
1
- /**
2
- * OpenAI Chat Completions Transport — SSE streaming implementation.
3
- *
4
- * Covers all OpenAI-compatible providers:
5
- * DeepSeek, Qwen, 硅基, Minimax, Moonshot, Groq, Together, OpenRouter, etc.
6
- *
7
- * POST {baseUrl}/v1/chat/completions with stream: true
8
- * Auth: Authorization: Bearer {apiKey}
9
- *
10
- * SSE format: lines prefixed with "data: ", JSON parsing per event.
11
- *
12
- * Adapted from admin-infer-proxy-client.ts SSE logic + Hermes openai_chat.py transport.
13
- */
14
- import type { LLMChunk, LLMRequest, LLMTransport } from "../transport.js";
15
- export interface OpenAIChatTransportConfig {
16
- baseUrl: string;
17
- /** Additional headers (e.g. for specific providers) */
18
- extraHeaders?: Record<string, string>;
19
- /** Timeout in ms (default 180_000) */
20
- timeoutMs?: number;
21
- /** Whether to include stream_options (default true). Set false for providers that reject it. */
22
- supportsStreamOptions?: boolean;
23
- /** Whether to omit temperature when it equals 0 (e.g. Moonshot rejects 0) */
24
- omitZeroTemperature?: boolean;
25
- }
26
- export declare class OpenAIChatTransport implements LLMTransport {
27
- private baseUrl;
28
- private extraHeaders;
29
- private timeoutMs;
30
- private supportsStreamOptions;
31
- private omitZeroTemperature;
32
- constructor(config: OpenAIChatTransportConfig);
33
- stream(request: LLMRequest, apiKey: string, signal?: AbortSignal): AsyncGenerator<LLMChunk>;
34
- private parseSSEStream;
35
- private mapChunk;
36
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * Built-in Agent Registry — CC-aligned agent definitions for fork/subagent.
3
- *
4
- * Each built-in agent defines a role with constrained tools, system prompt,
5
- * and execution budget. The LLM can invoke these via the AgentTool.
6
- */
7
- export interface AgentDefinition {
8
- /** Unique identifier for the agent (kebab-case). */
9
- name: string;
10
- /** Human-readable label. */
11
- label: string;
12
- /** Short description (appears in tool_search / LLM prompt). */
13
- description: string;
14
- /** Maximum turns this agent can execute before forced stop. */
15
- maxTurns: number;
16
- /** Tool access mode. */
17
- toolAccessMode: "full" | "read-only" | "none";
18
- /** Explicit allowed tool names (if empty, uses toolAccessMode filter). */
19
- allowedTools?: string[];
20
- /** Whether this agent can fork sub-agents itself. */
21
- canFork: boolean;
22
- /** System prompt override for this agent. */
23
- systemPromptSuffix?: string;
24
- }
25
- /**
26
- * Get the full list of built-in agent definitions.
27
- */
28
- export declare function getBuiltInAgents(): AgentDefinition[];
29
- /**
30
- * Look up a built-in agent by name.
31
- */
32
- export declare function getBuiltInAgent(name: string): AgentDefinition | undefined;
33
- /**
34
- * Check if a given agent name is a built-in agent.
35
- */
36
- export declare function isBuiltInAgent(name: string): boolean;
37
- /**
38
- * Resolve tool access for an agent definition.
39
- * Returns the set of tool names the agent is allowed to use.
40
- */
41
- export declare function resolveAgentToolSet(agent: AgentDefinition, availableTools: string[]): string[];
@@ -1,32 +0,0 @@
1
- import type { ToolCallBatch, ToolCallLike } from "./parallel-tool-calls.js";
2
- import type { ToolEligibilityLike } from "./tool-choice-policy.js";
3
- export type ToolExecutionStepContext = {
4
- stepIndex?: number;
5
- stepTotal?: number;
6
- stepSummary?: string;
7
- };
8
- export type ApprovalAwareToolCapability = {
9
- name: string;
10
- requiresApproval?: boolean;
11
- approvalMode?: string;
12
- };
13
- export type ApprovalAwareToolPlanStep = {
14
- stepIndex: number;
15
- stepCount: number;
16
- mode: "parallel" | "serial";
17
- callIds: string[];
18
- toolNames: string[];
19
- approvalRequired: boolean;
20
- approvalToolNames: string[];
21
- summary: string;
22
- };
23
- export declare function summarizeApprovalAwareToolPlan<TCall extends ToolCallLike>(params: {
24
- batches: Array<ToolCallBatch<TCall>>;
25
- toolCapabilities: readonly ApprovalAwareToolCapability[];
26
- eligibility?: readonly ToolEligibilityLike[];
27
- }): ApprovalAwareToolPlanStep[];
28
- export declare function buildApprovalAwareReason(params: {
29
- toolName: string;
30
- step: ApprovalAwareToolPlanStep | undefined;
31
- }): string;
32
- export declare function buildApprovalStepContext(step: ApprovalAwareToolPlanStep | undefined): ToolExecutionStepContext;
@@ -1,220 +0,0 @@
1
- export interface CompressibleMessage {
2
- role: string;
3
- content?: string | unknown;
4
- tool_call_id?: string;
5
- tool_calls?: unknown;
6
- name?: string;
7
- }
8
- export interface CompressionResult {
9
- messages: CompressibleMessage[];
10
- droppedCount: number;
11
- strategy: string;
12
- /** Phase 4: optional metrics from the compression pass */
13
- metrics?: CompressionMetrics;
14
- }
15
- export interface CompressionMetrics {
16
- tokensBefore: number;
17
- tokensAfter: number;
18
- compressionRatio: number;
19
- /** ms elapsed for this strategy pass */
20
- latencyMs: number;
21
- /** Whether an LLM call was made during this pass */
22
- usedLlm: boolean;
23
- /** Whether prompt cache was invalidated by compression */
24
- cacheInvalidated?: boolean;
25
- }
26
- export interface CompressionStrategy {
27
- compress(messages: CompressibleMessage[], budget: number): CompressionResult;
28
- }
29
- /**
30
- * Async compression strategy — required for LLM-based summarization.
31
- * Falls back to sync `compress` when the caller doesn't support async.
32
- */
33
- export interface AsyncCompressionStrategy extends CompressionStrategy {
34
- compressAsync(messages: CompressibleMessage[], budget: number): Promise<CompressionResult>;
35
- }
36
- export declare function isAsyncCompressionStrategy(s: CompressionStrategy): s is AsyncCompressionStrategy;
37
- /** Caller-provided LLM summarization function (wired by Hub). */
38
- export type SummarizeFn = (messages: CompressibleMessage[], instruction: string) => Promise<string>;
39
- export declare class SlidingWindowStrategy implements CompressionStrategy {
40
- private estimateTokens;
41
- constructor(estimateTokens: (msg: CompressibleMessage) => number);
42
- compress(messages: CompressibleMessage[], budget: number): CompressionResult;
43
- }
44
- export declare class SummarizeOldStrategy implements CompressionStrategy {
45
- private recentCount;
46
- private summarize;
47
- constructor(recentCount: number, summarize: (messages: CompressibleMessage[]) => string);
48
- compress(messages: CompressibleMessage[], _budget: number): CompressionResult;
49
- }
50
- export declare class ToolResultTrimStrategy implements CompressionStrategy {
51
- private maxToolResultChars;
52
- constructor(maxToolResultChars?: number);
53
- compress(messages: CompressibleMessage[], _budget: number): CompressionResult;
54
- }
55
- export declare function composeStrategies(...strategies: CompressionStrategy[]): CompressionStrategy;
56
- /**
57
- * Compose strategies with async support — if any strategy is async,
58
- * the pipeline becomes async.
59
- */
60
- export declare function composeAsyncStrategies(...strategies: CompressionStrategy[]): AsyncCompressionStrategy;
61
- /**
62
- * Build the structured 9-section summary instruction for the LLM.
63
- * Based on Claude Code's Full Compact mode, adapted for Hub.
64
- */
65
- export declare function buildStructuredSummaryPrompt(messagesToSummarize: CompressibleMessage[], opts?: {
66
- taskContext?: string;
67
- }): string;
68
- export interface HeadTailProtectionConfig {
69
- /** Number of initial user-assistant exchanges to protect (default: 1) */
70
- protectedHeadExchanges: number;
71
- /** Number of recent messages to always keep (default: 8 = ~4 exchanges) */
72
- protectedTailMessages: number;
73
- /** The summarization callback */
74
- summarize: SummarizeFn;
75
- /** Optional token estimator */
76
- estimateTokens?: (msg: CompressibleMessage) => number;
77
- /** Optional extra context for the summary prompt */
78
- taskContext?: string;
79
- }
80
- /**
81
- * Phase 2.2: Head/Tail protected summarization.
82
- *
83
- * Protects: system messages + first exchange + last N messages.
84
- * Compresses: middle section via LLM summarization.
85
- */
86
- export declare class HeadTailProtectedStrategy implements AsyncCompressionStrategy {
87
- private config;
88
- constructor(config: HeadTailProtectionConfig);
89
- compress(messages: CompressibleMessage[], _budget: number): CompressionResult;
90
- compressAsync(messages: CompressibleMessage[], budget: number): Promise<CompressionResult>;
91
- }
92
- export interface IncrementalCompactConfig {
93
- /** Messages newer than this count are never summarized (default: 12) */
94
- preserveRecentCount: number;
95
- /** Summarization callback */
96
- summarize: SummarizeFn;
97
- /** Token estimator */
98
- estimateTokens?: (msg: CompressibleMessage) => number;
99
- }
100
- /**
101
- * Phase 2.3: Incremental (partial) compaction.
102
- *
103
- * Only summarizes the oldest messages beyond the preserve window.
104
- * Avoids repeatedly re-summarizing already-compressed content.
105
- * If a previous summary marker exists, only new old messages are compressed.
106
- */
107
- export declare class IncrementalCompactStrategy implements AsyncCompressionStrategy {
108
- private config;
109
- constructor(config: IncrementalCompactConfig);
110
- compress(messages: CompressibleMessage[], _budget: number): CompressionResult;
111
- compressAsync(messages: CompressibleMessage[], budget: number): Promise<CompressionResult>;
112
- }
113
- export interface CacheAwareCompressionConfig {
114
- /** The inner strategy to delegate to */
115
- inner: CompressionStrategy;
116
- /** Token estimator */
117
- estimateTokens?: (msg: CompressibleMessage) => number;
118
- /**
119
- * Callback: notify when prompt cache was invalidated by compression.
120
- * Hub uses this to set pendingPostCompaction and track cache miss rate.
121
- */
122
- onCacheInvalidated?: (info: {
123
- droppedCount: number;
124
- strategy: string;
125
- }) => void;
126
- }
127
- /**
128
- * Phase 3: Cache-aware wrapper.
129
- *
130
- * Wraps any strategy and tracks whether compression invalidated the
131
- * provider prompt cache. System prompt prefix stability is preserved
132
- * by never modifying system[0] (the original system prompt).
133
- */
134
- export declare class CacheAwareCompressionStrategy implements AsyncCompressionStrategy {
135
- private config;
136
- constructor(config: CacheAwareCompressionConfig);
137
- compress(messages: CompressibleMessage[], budget: number): CompressionResult;
138
- compressAsync(messages: CompressibleMessage[], budget: number): Promise<CompressionResult>;
139
- }
140
- export interface AdaptiveBudgetConfig {
141
- /** Model context window size in tokens */
142
- modelContextWindow: number;
143
- /** Target usage ratio (0.0–1.0, default 0.75) — trigger compaction at this fraction */
144
- targetUsageRatio: number;
145
- /** Minimum guaranteed budget in tokens */
146
- minBudget: number;
147
- /** Maximum budget (usually = modelContextWindow) */
148
- maxBudget: number;
149
- }
150
- export declare const DEFAULT_ADAPTIVE_BUDGET_CONFIG: AdaptiveBudgetConfig;
151
- /**
152
- * Compute the adaptive token budget for a given model + message history.
153
- *
154
- * Adjusts based on model context window, and uses the target ratio
155
- * so compression triggers before hitting the hard limit.
156
- */
157
- export declare function computeAdaptiveBudget(config?: Partial<AdaptiveBudgetConfig>): number;
158
- /**
159
- * Decide which compression tier to use based on current token count vs budget.
160
- */
161
- export type CompressionTier = "none" | "trim-only" | "sliding-window" | "llm-summarize";
162
- export declare function selectCompressionTier(currentTokens: number, budget: number): CompressionTier;
163
- export interface CompressionEvent {
164
- timestamp: number;
165
- strategy: string;
166
- tokensBefore: number;
167
- tokensAfter: number;
168
- droppedCount: number;
169
- latencyMs: number;
170
- usedLlm: boolean;
171
- cacheInvalidated: boolean;
172
- tier: CompressionTier;
173
- }
174
- export interface CompressionMetricsSnapshot {
175
- totalCompressions: number;
176
- totalLlmCalls: number;
177
- totalCacheInvalidations: number;
178
- averageCompressionRatio: number;
179
- averageLatencyMs: number;
180
- totalTokensSaved: number;
181
- recentEvents: CompressionEvent[];
182
- }
183
- export declare class CompressionMetricsCollector {
184
- private events;
185
- private maxEvents;
186
- constructor(maxEvents?: number);
187
- record(event: CompressionEvent): void;
188
- snapshot(): CompressionMetricsSnapshot;
189
- reset(): void;
190
- }
191
- /**
192
- * A pluggable context engine. Only one can be active at a time.
193
- * The default engine uses the 4-layer compression funnel.
194
- */
195
- export interface ContextEngine {
196
- /** Unique engine identifier */
197
- readonly id: string;
198
- /** Human-readable label */
199
- readonly label: string;
200
- /** Compress messages for a turn */
201
- compressAsync(messages: CompressibleMessage[], budget: number, context?: {
202
- model?: string;
203
- sessionId?: string;
204
- }): Promise<CompressionResult>;
205
- }
206
- /**
207
- * Registry for context engines. Enforces single-active constraint.
208
- */
209
- export declare class ContextEngineRegistry {
210
- private engines;
211
- private activeId;
212
- register(engine: ContextEngine): void;
213
- activate(id: string): boolean;
214
- getActive(): ContextEngine | undefined;
215
- listEngines(): Array<{
216
- id: string;
217
- label: string;
218
- active: boolean;
219
- }>;
220
- }
@@ -1,61 +0,0 @@
1
- export interface OpenAiToolCall {
2
- id: string;
3
- type: "function";
4
- function: {
5
- name: string;
6
- arguments: string;
7
- };
8
- }
9
- export interface OpenAiChatToolCallRef {
10
- id?: string;
11
- function?: {
12
- name?: string;
13
- arguments?: string;
14
- };
15
- name?: string;
16
- [key: string]: unknown;
17
- }
18
- export interface OpenAiChatMessageLike {
19
- role: string;
20
- content?: unknown;
21
- tool_calls?: OpenAiChatToolCallRef[];
22
- tool_call_id?: string;
23
- [key: string]: unknown;
24
- }
25
- export interface OpenAiResponsesItemLike {
26
- type: string;
27
- id?: string;
28
- call_id?: string;
29
- role?: string;
30
- content?: unknown;
31
- status?: string;
32
- [key: string]: unknown;
33
- }
34
- export interface ConversationRepairOptions {
35
- stopReason?: string;
36
- placeholderToolResult?: string;
37
- placeholderFunctionCallOutput?: string;
38
- forcedStopReasons?: readonly string[];
39
- }
40
- type ContentPart = {
41
- type: string;
42
- text?: string;
43
- [key: string]: unknown;
44
- };
45
- export type { ContentPart };
46
- export declare function sanitizeOpenAiChatMessages<T extends OpenAiChatMessageLike>(messages: readonly T[]): T[];
47
- export declare function ensureAssistantReasoningContent<T extends Record<string, unknown>>(messages: readonly T[], defaultValue?: string): T[];
48
- export declare function stripForcedStopAssistantToolMetadata<T extends OpenAiChatMessageLike>(messages: readonly T[], options?: ConversationRepairOptions): T[];
49
- export declare function injectDanglingToolCallPlaceholders<T extends OpenAiChatMessageLike>(messages: readonly T[], options?: ConversationRepairOptions): T[];
50
- export declare function repairOpenAiChatConversation<T extends OpenAiChatMessageLike>(messages: readonly T[], options?: ConversationRepairOptions): T[];
51
- export declare function downgradeOpenAiFunctionCallReasoningPairs<T extends {
52
- role?: unknown;
53
- content?: unknown;
54
- toolCallId?: unknown;
55
- toolUseId?: unknown;
56
- }>(messages: readonly T[]): T[];
57
- export declare function downgradeOpenAiReasoningBlocks<T extends {
58
- role?: unknown;
59
- content?: unknown;
60
- }>(messages: readonly T[]): T[];
61
- export declare function repairOpenAiResponsesItems<T extends OpenAiResponsesItemLike>(items: readonly T[], options?: ConversationRepairOptions): T[];
@@ -1,119 +0,0 @@
1
- /**
2
- * Curator scheduler — pure strategy for autonomous skill library
3
- * maintenance. Decides WHEN to run the curator review cycle and
4
- * computes automatic lifecycle transitions (active → stale → archived).
5
- *
6
- * No I/O — all functions are pure; the caller supplies timestamps and
7
- * skill records, and receives transition instructions back.
8
- */
9
- /** Policy knobs for the curator scheduler. */
10
- export interface CuratorSchedulePolicy {
11
- /** Minimum idle seconds before curator may trigger (default: 7200 = 2 h). */
12
- minIdleSeconds: number;
13
- /** Minimum interval between curator runs in seconds (default: 604800 = 7 days). */
14
- intervalSeconds: number;
15
- /** Days without activity before marking a skill stale (default: 30). */
16
- staleAfterDays: number;
17
- /** Days without activity before archiving a stale skill (default: 90). */
18
- archiveAfterDays: number;
19
- /** Maximum skills to process in one LLM review pass (default: 50). */
20
- maxReviewBatchSize: number;
21
- }
22
- export declare const DEFAULT_CURATOR_SCHEDULE_POLICY: CuratorSchedulePolicy;
23
- /** Persistent curator state (stored by the host runtime). */
24
- export interface CuratorState {
25
- /** ISO-8601 timestamp of last curator run. */
26
- lastRunAt: string | null;
27
- /** Duration of last run in seconds. */
28
- lastRunDurationSeconds: number;
29
- /** Human-readable summary of last run. */
30
- lastRunSummary: string;
31
- /** Whether curator is paused by the user. */
32
- paused: boolean;
33
- /** Cumulative run count. */
34
- runCount: number;
35
- }
36
- export declare const INITIAL_CURATOR_STATE: CuratorState;
37
- /** Lifecycle state of an agent-created skill. */
38
- export type CuratorSkillLifecycleState = "active" | "stale" | "archived";
39
- /** Minimal skill activity record consumed by the scheduler. */
40
- export interface CuratorSkillRecord {
41
- /** Skill name / identifier. */
42
- name: string;
43
- /** Whether this skill was agent-created (only these are curated). */
44
- agentCreated: boolean;
45
- /** Current lifecycle state. */
46
- state: CuratorSkillLifecycleState;
47
- /** Whether the user pinned this skill (immune to auto-transitions). */
48
- pinned: boolean;
49
- /** ISO-8601 timestamp of last activity. */
50
- lastActivityAt: string | null;
51
- /** Cumulative use count. */
52
- useCount: number;
53
- /** ISO-8601 timestamp of creation. */
54
- createdAt: string;
55
- }
56
- /** Input for the gate check. */
57
- export interface CuratorGateInput {
58
- /** Current ISO-8601 timestamp. */
59
- now: string;
60
- /** Seconds the session has been idle. */
61
- idleSeconds: number;
62
- /** Current curator state. */
63
- state: CuratorState;
64
- /** Whether the feature is enabled at all. */
65
- enabled: boolean;
66
- /** Policy overrides. */
67
- policy?: Partial<CuratorSchedulePolicy>;
68
- }
69
- /** Result of the gate check: should the curator run? */
70
- export interface CuratorGateResult {
71
- shouldRun: boolean;
72
- reason: string;
73
- }
74
- /**
75
- * Determine whether the curator should run now.
76
- *
77
- * All gates must pass:
78
- * 1. Feature enabled
79
- * 2. Not paused
80
- * 3. Session idle ≥ minIdleSeconds
81
- * 4. Time since last run ≥ intervalSeconds
82
- */
83
- export declare function shouldRunCurator(input: CuratorGateInput): CuratorGateResult;
84
- /** A single lifecycle transition computed by the scheduler. */
85
- export interface CuratorLifecycleTransition {
86
- skillName: string;
87
- from: CuratorSkillLifecycleState;
88
- to: CuratorSkillLifecycleState;
89
- reason: string;
90
- }
91
- /** Summary of all auto-transitions in one pass. */
92
- export interface CuratorAutoTransitionResult {
93
- checked: number;
94
- transitions: CuratorLifecycleTransition[];
95
- markedStale: number;
96
- archived: number;
97
- reactivated: number;
98
- }
99
- /**
100
- * Compute automatic lifecycle transitions for agent-created skills.
101
- *
102
- * Pure function — no I/O, no mutations. The caller applies the
103
- * returned transitions to its skill storage.
104
- *
105
- * Rules:
106
- * - Pinned skills are never transitioned.
107
- * - Non-agent-created skills are skipped.
108
- * - active → stale: no activity for staleAfterDays.
109
- * - stale → archived: no activity for archiveAfterDays.
110
- * - stale/archived → active: if useCount increased (reactivation).
111
- */
112
- export declare function computeLifecycleTransitions(skills: readonly CuratorSkillRecord[], now: string, policy?: Partial<CuratorSchedulePolicy>): CuratorAutoTransitionResult;
113
- /**
114
- * Select skills that should be reviewed by the LLM curator.
115
- *
116
- * Only non-pinned, agent-created skills in active or stale state
117
- * are eligible for review. Returns at most maxReviewBatchSize names.
118
- */
119
- export declare function selectReviewCandidates(skills: readonly CuratorSkillRecord[], policy?: Partial<CuratorSchedulePolicy>): string[];
@@ -1,110 +0,0 @@
1
- export type EmbeddedPromptFailureAction<TThinkingLevel extends string = string, TFailoverReason extends string = string> = {
2
- kind: "retry-rotated";
3
- } | {
4
- kind: "retry-thinking";
5
- thinkLevel: TThinkingLevel;
6
- } | {
7
- kind: "throw-failover";
8
- reason: TFailoverReason | null;
9
- } | {
10
- kind: "unhandled";
11
- };
12
- export type EmbeddedAssistantFailureAction<TFailoverReason extends string = string> = {
13
- kind: "retry-rotated";
14
- } | {
15
- kind: "throw-failover";
16
- reason: TFailoverReason | null;
17
- } | {
18
- kind: "unhandled";
19
- };
20
- export type EmbeddedPromptErrorPolicyResolution<TThinkingLevel extends string = string, TFailoverReason extends string = string> = {
21
- kind: "noop";
22
- } | {
23
- kind: "return-error";
24
- errorKind: "role_ordering" | "image_size";
25
- text: string;
26
- message: string;
27
- } | {
28
- kind: "retry-rotated";
29
- } | {
30
- kind: "retry-thinking";
31
- thinkLevel: TThinkingLevel;
32
- } | {
33
- kind: "throw-failover";
34
- reason: TFailoverReason | null;
35
- } | {
36
- kind: "throw-original";
37
- };
38
- export declare function resolveRetryableFailureReason<TReason extends string = string>(params: {
39
- reason: TReason | null | undefined;
40
- nonRetryableReasons?: readonly TReason[];
41
- }): TReason | null;
42
- export declare function resolveAuthProfileFailoverReason<TFailoverReason extends string = string>(params: {
43
- allInCooldown: boolean;
44
- unavailableReason?: TFailoverReason | null;
45
- classifiedReason?: TFailoverReason | null;
46
- cooldownFallbackReason: TFailoverReason;
47
- defaultReason: TFailoverReason;
48
- }): TFailoverReason;
49
- export declare function resolveFallbackThinkingDecision<TThinkingLevel extends string = string>(params: {
50
- aborted: boolean;
51
- fallbackThinking?: TThinkingLevel;
52
- provider: string;
53
- modelId: string;
54
- }): {
55
- thinkLevel: TThinkingLevel;
56
- warningMessage: string;
57
- } | undefined;
58
- export declare function pickFallbackThinkingLevel<TThinkingLevel extends string = string>(params: {
59
- message?: string;
60
- attempted: Set<TThinkingLevel>;
61
- normalizeThinkLevel: (raw: string) => TThinkingLevel | undefined;
62
- offLevel?: TThinkingLevel;
63
- }): TThinkingLevel | undefined;
64
- export declare function shouldAttemptPromptFailureRotation<TFailoverReason extends string = string>(params: {
65
- promptFailoverFailure: boolean;
66
- promptFailoverReason: TFailoverReason | null;
67
- nonRotatableReasons?: readonly TFailoverReason[];
68
- }): boolean;
69
- export declare function shouldAttemptAssistantFailureRotation(params: {
70
- timedOut: boolean;
71
- timedOutDuringCompaction: boolean;
72
- failoverFailure: boolean;
73
- }): boolean;
74
- export declare function resolvePromptFailureActionDecision<TThinkingLevel extends string = string, TFailoverReason extends string = string>(params: {
75
- promptFailoverFailure: boolean;
76
- canRotate: boolean;
77
- fallbackThinking?: TThinkingLevel;
78
- fallbackConfigured: boolean;
79
- promptFailoverReason: TFailoverReason | null;
80
- }): EmbeddedPromptFailureAction<TThinkingLevel, TFailoverReason>;
81
- export declare function resolveAssistantFailureActionDecision<TFailoverReason extends string = string>(params: {
82
- timedOut: boolean;
83
- timedOutDuringCompaction: boolean;
84
- failoverFailure: boolean;
85
- canRotate: boolean;
86
- shouldThrowFailover: boolean;
87
- failoverReason: TFailoverReason | null;
88
- }): EmbeddedAssistantFailureAction<TFailoverReason>;
89
- export declare function resolvePromptErrorPolicy<TThinkingLevel extends string = string, TFailoverReason extends string = string>(params: {
90
- hasPromptError: boolean;
91
- aborted: boolean;
92
- errorText: string;
93
- roleAlternationError: boolean;
94
- imageSizeMaxMb?: number | null;
95
- promptFailureAction: EmbeddedPromptFailureAction<TThinkingLevel, TFailoverReason>;
96
- }): EmbeddedPromptErrorPolicyResolution<TThinkingLevel, TFailoverReason>;
97
- export declare function buildAssistantFailoverErrorDetails(params: {
98
- formattedAssistantErrorText?: string;
99
- assistantErrorMessage?: string;
100
- timedOut: boolean;
101
- rateLimitFailure: boolean;
102
- billingFailureMessage?: string;
103
- authFailure: boolean;
104
- failoverStatus?: number;
105
- timeoutDetectedFromMessage: boolean;
106
- timeoutStatus?: number;
107
- }): {
108
- message: string;
109
- status: number | undefined;
110
- };
@@ -1,12 +0,0 @@
1
- import type { FailoverReason } from "./failover-classification.js";
2
- export type ErrorCategory = "RETRYABLE_TRANSIENT" | "RETRYABLE_DEGRADED" | "NON_RETRYABLE_AUTH" | "NON_RETRYABLE_CONTENT" | "NON_RETRYABLE_QUOTA" | "TOOL_EXECUTION_FAILED";
3
- export interface RetryStrategy {
4
- retryable: boolean;
5
- maxRetries: number;
6
- baseDelayMs: number;
7
- backoffMultiplier: number;
8
- switchProvider: boolean;
9
- }
10
- export declare function classifyError(status: number | undefined, message?: string): ErrorCategory;
11
- export declare function classifyErrorFromReason(reason: FailoverReason): ErrorCategory;
12
- export declare function getRetryStrategy(category: ErrorCategory): RetryStrategy;
@@ -1,8 +0,0 @@
1
- export type FailoverReason = "auth" | "auth_permanent" | "format" | "rate_limit" | "overloaded" | "billing" | "timeout" | "model_not_found" | "session_expired" | "unknown";
2
- export declare function isTimeoutErrorMessage(raw: string): boolean;
3
- export declare function isCloudflareOrHtmlErrorPage(raw: string): boolean;
4
- export declare function isTransientHttpError(raw: string): boolean;
5
- export declare function classifyFailoverReasonFromHttpStatus(status: number | undefined, message?: string): FailoverReason | null;
6
- export declare function isModelNotFoundErrorMessage(raw: string): boolean;
7
- export declare function classifyFailoverReason(raw: string): FailoverReason | null;
8
- export declare function isFailoverErrorMessage(raw: string): boolean;
@@ -1,33 +0,0 @@
1
- import { type FailoverReason } from "./failover-classification.js";
2
- export declare class FailoverError extends Error {
3
- readonly reason: FailoverReason;
4
- readonly provider?: string;
5
- readonly model?: string;
6
- readonly profileId?: string;
7
- readonly status?: number;
8
- readonly code?: string;
9
- constructor(message: string, params: {
10
- reason: FailoverReason;
11
- provider?: string;
12
- model?: string;
13
- profileId?: string;
14
- status?: number;
15
- code?: string;
16
- cause?: unknown;
17
- });
18
- }
19
- export declare function isFailoverError(err: unknown): err is FailoverError;
20
- export declare function resolveFailoverStatus(reason: FailoverReason): number | undefined;
21
- export declare function isTimeoutError(err: unknown): boolean;
22
- export declare function resolveFailoverReasonFromError(err: unknown): FailoverReason | null;
23
- export declare function describeFailoverError(err: unknown): {
24
- message: string;
25
- reason?: FailoverReason;
26
- status?: number;
27
- code?: string;
28
- };
29
- export declare function coerceToFailoverError(err: unknown, context?: {
30
- provider?: string;
31
- model?: string;
32
- profileId?: string;
33
- }): FailoverError | null;