qlogicagent 0.5.0 → 0.5.3

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 (173) hide show
  1. package/README.md +402 -402
  2. package/dist/agent.js +18 -0
  3. package/dist/cli.js +360 -0
  4. package/dist/contracts.js +1 -0
  5. package/dist/index.js +22 -0
  6. package/dist/orchestration.js +125 -0
  7. package/dist/types/agent/agent.d.ts +43 -0
  8. package/dist/types/agent/constants.d.ts +47 -0
  9. package/dist/types/agent/tool-loop.d.ts +96 -0
  10. package/dist/types/agent/types.d.ts +250 -0
  11. package/dist/types/cli/main.d.ts +11 -0
  12. package/dist/types/cli/stdio-server.d.ts +56 -0
  13. package/dist/types/cli/tool-bootstrap.d.ts +21 -0
  14. package/dist/types/config/config.d.ts +17 -0
  15. package/dist/types/contracts/hooks.d.ts +175 -0
  16. package/dist/types/contracts/index.d.ts +10 -0
  17. package/dist/types/contracts/planner.d.ts +35 -0
  18. package/dist/types/contracts/skill-candidate.d.ts +63 -0
  19. package/dist/types/contracts/todo.d.ts +14 -0
  20. package/dist/types/index.d.ts +13 -0
  21. package/dist/types/llm/builtin-providers.d.ts +10 -0
  22. package/dist/types/llm/debug-transport.d.ts +12 -0
  23. package/dist/types/llm/index.d.ts +16 -0
  24. package/dist/types/llm/llm-client.d.ts +43 -0
  25. package/dist/types/llm/model-catalog.d.ts +53 -0
  26. package/dist/types/llm/provider-def.d.ts +59 -0
  27. package/dist/types/llm/provider-registry.d.ts +54 -0
  28. package/dist/types/llm/transport.d.ts +62 -0
  29. package/dist/types/llm/transports/anthropic-messages.d.ts +31 -0
  30. package/dist/types/llm/transports/openai-chat.d.ts +36 -0
  31. package/dist/types/orchestration/agent-registry.d.ts +46 -0
  32. package/dist/types/orchestration/context-collapse.d.ts +58 -0
  33. package/dist/types/orchestration/context-compression.d.ts +301 -0
  34. package/dist/types/orchestration/conversation-repair.d.ts +61 -0
  35. package/dist/types/orchestration/curator-scheduler.d.ts +119 -0
  36. package/dist/types/orchestration/error-classification.d.ts +12 -0
  37. package/dist/types/orchestration/failover-classification.d.ts +8 -0
  38. package/dist/types/orchestration/failover-error.d.ts +33 -0
  39. package/dist/types/orchestration/fork-subagent.d.ts +100 -0
  40. package/dist/types/orchestration/index.d.ts +113 -0
  41. package/dist/types/orchestration/memory-provider.d.ts +14 -0
  42. package/dist/types/orchestration/reactive-compact.d.ts +73 -0
  43. package/dist/types/orchestration/retry-loop.d.ts +69 -0
  44. package/dist/types/orchestration/skill-candidate.d.ts +52 -0
  45. package/dist/types/orchestration/skill-consolidation.d.ts +123 -0
  46. package/dist/types/orchestration/skill-improvement.d.ts +59 -0
  47. package/dist/types/orchestration/skill-similarity.d.ts +98 -0
  48. package/dist/types/orchestration/task-types.d.ts +142 -0
  49. package/dist/types/orchestration/team-orchestration.d.ts +195 -0
  50. package/dist/types/orchestration/team-tool-loop-wiring.d.ts +92 -0
  51. package/dist/types/orchestration/tool-choice-policy.d.ts +54 -0
  52. package/dist/types/orchestration/tool-loop-state.d.ts +50 -0
  53. package/dist/types/orchestration/tool-schema.d.ts +39 -0
  54. package/dist/types/orchestration/turn-loop-guard.d.ts +86 -0
  55. package/dist/types/runtime/execution/dream-agent.d.ts +199 -0
  56. package/dist/types/runtime/execution/forked-agent.d.ts +111 -0
  57. package/dist/types/runtime/execution/index.d.ts +6 -0
  58. package/dist/types/runtime/execution/progress-tracker.d.ts +78 -0
  59. package/dist/types/runtime/execution/remote-agent.d.ts +63 -0
  60. package/dist/types/runtime/execution/streaming-tool-executor.d.ts +100 -0
  61. package/dist/types/runtime/execution/tool-eligibility.d.ts +59 -0
  62. package/dist/types/runtime/execution/tool-result-storage.d.ts +87 -0
  63. package/dist/types/runtime/hooks/context-compression.d.ts +61 -0
  64. package/dist/types/runtime/hooks/hook-registry.d.ts +12 -0
  65. package/dist/types/runtime/hooks/index.d.ts +3 -0
  66. package/dist/types/runtime/hooks/memory-hooks.d.ts +49 -0
  67. package/dist/types/runtime/index.d.ts +5 -0
  68. package/dist/types/runtime/infra/cleanup-registry.d.ts +23 -0
  69. package/dist/types/runtime/infra/file-watcher.d.ts +72 -0
  70. package/dist/types/runtime/infra/index.d.ts +6 -0
  71. package/dist/types/runtime/infra/secure-storage.d.ts +81 -0
  72. package/dist/types/runtime/infra/task-runtime.d.ts +108 -0
  73. package/dist/types/runtime/infra/token-budget.d.ts +92 -0
  74. package/dist/types/runtime/infra/worktree-backend.d.ts +85 -0
  75. package/dist/types/runtime/prompt/environment-context.d.ts +23 -0
  76. package/dist/types/runtime/prompt/index.d.ts +3 -0
  77. package/dist/types/runtime/prompt/instruction-loader.d.ts +64 -0
  78. package/dist/types/runtime/prompt/system-prompt-sections.d.ts +63 -0
  79. package/dist/types/runtime/session/index.d.ts +2 -0
  80. package/dist/types/runtime/session/session-memory.d.ts +91 -0
  81. package/dist/types/runtime/session/session-persistence.d.ts +94 -0
  82. package/dist/types/runtime/session/session-state.d.ts +117 -0
  83. package/dist/types/skills/index.d.ts +125 -0
  84. package/dist/types/skills/mcp/index.d.ts +3 -0
  85. package/dist/types/skills/mcp/mcp-http-client.d.ts +66 -0
  86. package/dist/types/skills/mcp/mcp-manager.d.ts +84 -0
  87. package/dist/types/skills/mcp/mcp-stdio-client.d.ts +84 -0
  88. package/dist/types/skills/memory-extractor.d.ts +64 -0
  89. package/dist/types/skills/memory-query-tool.d.ts +43 -0
  90. package/dist/types/skills/memory-store.d.ts +66 -0
  91. package/dist/types/skills/memory-tool.d.ts +67 -0
  92. package/dist/types/skills/permissions/bash-classifier.d.ts +30 -0
  93. package/dist/types/skills/permissions/classifier-cache.d.ts +51 -0
  94. package/dist/types/skills/permissions/denial-tracking.d.ts +42 -0
  95. package/dist/types/skills/permissions/hook-runner.d.ts +85 -0
  96. package/dist/types/skills/permissions/index.d.ts +12 -0
  97. package/dist/types/skills/permissions/permission-classifier.d.ts +41 -0
  98. package/dist/types/skills/permissions/rule-engine.d.ts +41 -0
  99. package/dist/types/skills/permissions/settings-watcher.d.ts +46 -0
  100. package/dist/types/skills/permissions/types.d.ts +113 -0
  101. package/dist/types/skills/plugins/index.d.ts +2 -0
  102. package/dist/types/skills/plugins/plugin-api.d.ts +38 -0
  103. package/dist/types/skills/plugins/plugin-loader.d.ts +45 -0
  104. package/dist/types/skills/plugins/plugin-marketplace.d.ts +61 -0
  105. package/dist/types/skills/portable-tool.d.ts +71 -0
  106. package/dist/types/skills/qmemory-adapter.d.ts +42 -0
  107. package/dist/types/skills/skill-frontmatter.d.ts +19 -0
  108. package/dist/types/skills/skill-guard.d.ts +23 -0
  109. package/dist/types/skills/skill-loader.d.ts +16 -0
  110. package/dist/types/skills/skill-source.d.ts +119 -0
  111. package/dist/types/skills/skill-types.d.ts +199 -0
  112. package/dist/types/skills/think-tool.d.ts +16 -0
  113. package/dist/types/skills/todo-tool.d.ts +63 -0
  114. package/dist/types/skills/tool-registry.d.ts +29 -0
  115. package/dist/types/skills/tools/agent-tool.d.ts +91 -0
  116. package/dist/types/skills/tools/apply-patch-tool.d.ts +29 -0
  117. package/dist/types/skills/tools/ask-user-tool.d.ts +80 -0
  118. package/dist/types/skills/tools/brief-tool.d.ts +74 -0
  119. package/dist/types/skills/tools/browser-tool.d.ts +114 -0
  120. package/dist/types/skills/tools/checkpoint-tool.d.ts +66 -0
  121. package/dist/types/skills/tools/config-tool.d.ts +63 -0
  122. package/dist/types/skills/tools/cron-tool.d.ts +116 -0
  123. package/dist/types/skills/tools/edit-tool.d.ts +43 -0
  124. package/dist/types/skills/tools/exec-tool.d.ts +97 -0
  125. package/dist/types/skills/tools/image-generate-tool.d.ts +62 -0
  126. package/dist/types/skills/tools/instructions-tool.d.ts +103 -0
  127. package/dist/types/skills/tools/lsp-tool.d.ts +153 -0
  128. package/dist/types/skills/tools/mcp-client-types.d.ts +269 -0
  129. package/dist/types/skills/tools/mcp-resource-tools.d.ts +14 -0
  130. package/dist/types/skills/tools/mcp-tool.d.ts +249 -0
  131. package/dist/types/skills/tools/memory-tool.d.ts +74 -0
  132. package/dist/types/skills/tools/monitor-tool.d.ts +113 -0
  133. package/dist/types/skills/tools/music-generate-tool.d.ts +55 -0
  134. package/dist/types/skills/tools/notebook-edit-tool.d.ts +15 -0
  135. package/dist/types/skills/tools/notify-tool.d.ts +53 -0
  136. package/dist/types/skills/tools/patch-tool.d.ts +45 -0
  137. package/dist/types/skills/tools/pdf-tool.d.ts +66 -0
  138. package/dist/types/skills/tools/plan-mode-tool.d.ts +98 -0
  139. package/dist/types/skills/tools/read-tool.d.ts +51 -0
  140. package/dist/types/skills/tools/repl-tool.d.ts +70 -0
  141. package/dist/types/skills/tools/search-tool.d.ts +112 -0
  142. package/dist/types/skills/tools/send-message-tool.d.ts +51 -0
  143. package/dist/types/skills/tools/shell/bash-provider.d.ts +26 -0
  144. package/dist/types/skills/tools/shell/command-classification.d.ts +44 -0
  145. package/dist/types/skills/tools/shell/command-semantics.d.ts +14 -0
  146. package/dist/types/skills/tools/shell/destructive-command-warning.d.ts +10 -0
  147. package/dist/types/skills/tools/shell/exec-permissions.d.ts +52 -0
  148. package/dist/types/skills/tools/shell/index.d.ts +17 -0
  149. package/dist/types/skills/tools/shell/powershell-provider.d.ts +15 -0
  150. package/dist/types/skills/tools/shell/shell-command.d.ts +54 -0
  151. package/dist/types/skills/tools/shell/shell-exec.d.ts +33 -0
  152. package/dist/types/skills/tools/shell/shell-provider.d.ts +85 -0
  153. package/dist/types/skills/tools/shell/task-output.d.ts +45 -0
  154. package/dist/types/skills/tools/skill-invoke-tool.d.ts +46 -0
  155. package/dist/types/skills/tools/skill-list-tool.d.ts +33 -0
  156. package/dist/types/skills/tools/skill-manage-tool.d.ts +73 -0
  157. package/dist/types/skills/tools/skill-view-tool.d.ts +37 -0
  158. package/dist/types/skills/tools/sleep-tool.d.ts +49 -0
  159. package/dist/types/skills/tools/structured-output-tool.d.ts +116 -0
  160. package/dist/types/skills/tools/task-tool.d.ts +104 -0
  161. package/dist/types/skills/tools/team-tool.d.ts +89 -0
  162. package/dist/types/skills/tools/tool-search-tool.d.ts +51 -0
  163. package/dist/types/skills/tools/tts-tool.d.ts +38 -0
  164. package/dist/types/skills/tools/video-edit-tool.d.ts +69 -0
  165. package/dist/types/skills/tools/video-generate-tool.d.ts +62 -0
  166. package/dist/types/skills/tools/video-merge-tool.d.ts +105 -0
  167. package/dist/types/skills/tools/video-upscale-tool.d.ts +45 -0
  168. package/dist/types/skills/tools/web-fetch-tool.d.ts +78 -0
  169. package/dist/types/skills/tools/web-search-tool.d.ts +57 -0
  170. package/dist/types/skills/tools/workflow-tool.d.ts +44 -0
  171. package/dist/types/skills/tools/worktree-tool.d.ts +69 -0
  172. package/dist/types/skills/tools/write-tool.d.ts +45 -0
  173. package/package.json +4 -2
@@ -0,0 +1,113 @@
1
+ export { buildAssistantToolCallMessage, buildToolResultMessage, type FunctionToolDefinition, } from "./tool-schema.js";
2
+ export { classifyError, getRetryStrategy, type ErrorCategory, type RetryStrategy, } from "./error-classification.js";
3
+ export { composeStrategies, composeAsyncStrategies, SlidingWindowStrategy, SummarizeOldStrategy, ToolResultTrimStrategy, HeadTailProtectedStrategy, IncrementalCompactStrategy, CacheAwareCompressionStrategy, CompressionMetricsCollector, ContextEngineRegistry, MicroCompactStrategy, postCompactFileRecovery, type PostCompactRecoveryConfig, 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 { snipCompactIfNeeded, type SnipResult, } from "./context-compression.js";
5
+ export { applyCollapsesIfNeeded as applyContextCollapsesIfNeeded, recoverFromOverflow as recoverContextCollapseFromOverflow, createCollapseStore, type CollapseStore, type CollapseStage, } from "./context-collapse.js";
6
+ export { buildSkillInstruction, type SkillCreateInstruction, type SkillImproveInstruction, type SkillInstruction, type SkillTurnResult, } from "./skill-improvement.js";
7
+ export { buildSkillCandidateEffectivenessSummary, buildSkillCandidateEvidencePayload, buildSkillCandidateImprovementEvidenceBundle, buildSkillCandidateLatestReview, createDefaultSkillImprovementPolicy, normalizeSkillImprovementPolicy, type SkillCandidateImprovementEvidenceBundleContract, type SkillImprovementPolicyContract, } from "./skill-candidate.js";
8
+ export declare const SIDECHAIN_TYPE_VALUES: readonly ["research", "planner", "plan-repair", "code-repair", "media-prep"];
9
+ export type SidechainType = typeof SIDECHAIN_TYPE_VALUES[number];
10
+ export type SidechainBudgetTier = "low" | "medium" | "high";
11
+ export type SidechainMergePolicy = "summary-only" | "append-messages" | "replace-context" | "manual";
12
+ export type SidechainToolAccessMode = "full" | "read-only" | "none";
13
+ export interface SidechainTypePolicy {
14
+ type: SidechainType;
15
+ label: string;
16
+ description: string;
17
+ mergePolicy: SidechainMergePolicy;
18
+ budgetTier: SidechainBudgetTier;
19
+ budgetWeight: number;
20
+ preferFullContext: boolean;
21
+ preserveConversationHistory: boolean;
22
+ toolAccessMode: SidechainToolAccessMode;
23
+ }
24
+ export type SidechainToolAccessDecision = "allowed" | "denied";
25
+ export type SidechainToolAccessInheritance = "inherit" | "shrink";
26
+ export type SidechainToolAccessReason = "default-allow" | "always-deny" | "leaf-deny";
27
+ export interface SidechainToolAccessRule {
28
+ toolName: string;
29
+ decision: SidechainToolAccessDecision;
30
+ inheritance: SidechainToolAccessInheritance;
31
+ reason: SidechainToolAccessReason;
32
+ }
33
+ export interface SidechainToolAccessPolicy {
34
+ deniedTools: string[];
35
+ canSpawnChildren: boolean;
36
+ defaultDecision: "allowed";
37
+ defaultInheritance: "inherit";
38
+ tools: SidechainToolAccessRule[];
39
+ }
40
+ export declare const SIDECHAIN_TOOL_DENY_ALWAYS: readonly ["gateway", "agents_list", "whatsapp_login", "session_status", "cron", "memory_query", "sessions_send"];
41
+ export declare const SIDECHAIN_TOOL_DENY_LEAF: readonly ["sessions_list", "sessions_history", "sessions_spawn"];
42
+ /** Tools that perform write/mutation operations — denied in read-only sidechain types. */
43
+ 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"];
44
+ export declare function resolveSidechainToolAccessPolicy(params?: {
45
+ depth?: number;
46
+ maxDepth?: number;
47
+ role?: "leaf" | "orchestrator";
48
+ toolNames?: Iterable<string>;
49
+ }): SidechainToolAccessPolicy;
50
+ /**
51
+ * Resolve tool access policy for a specific sidechain type.
52
+ * Combines depth-based deny lists with type-specific access mode:
53
+ * - "full": only depth-based denials apply
54
+ * - "read-only": depth-based + all write/mutation tools denied
55
+ * - "none": all tools denied
56
+ */
57
+ export declare function resolveSidechainToolAccessByType(params: {
58
+ type: SidechainType;
59
+ depth?: number;
60
+ maxDepth?: number;
61
+ role?: "leaf" | "orchestrator";
62
+ toolNames?: Iterable<string>;
63
+ }): SidechainToolAccessPolicy;
64
+ export interface ToolCallAccessFilterResult<T> {
65
+ allowed: T[];
66
+ denied: Array<{
67
+ toolCall: T;
68
+ reason: string;
69
+ }>;
70
+ }
71
+ /**
72
+ * Filter tool_calls against a resolved access policy.
73
+ * Returns allowed calls and denied calls with reasons.
74
+ * T must have at least { id: string; function: { name: string } }.
75
+ */
76
+ export declare function filterToolCallsByAccessPolicy<T extends {
77
+ id: string;
78
+ function: {
79
+ name: string;
80
+ };
81
+ }>(toolCalls: T[], policy: SidechainToolAccessPolicy): ToolCallAccessFilterResult<T>;
82
+ export declare function listSidechainTypePolicies(): SidechainTypePolicy[];
83
+ export declare function resolveSidechainTypePolicy(type: SidechainType): SidechainTypePolicy;
84
+ export declare function resolveRepairSidechainType(params?: {
85
+ toolNames?: Iterable<string>;
86
+ preferCodeRepair?: boolean;
87
+ trigger?: string;
88
+ }): Extract<SidechainType, "plan-repair" | "code-repair">;
89
+ export declare function resolveSidechainMergePolicyByType(type: SidechainType, overrides?: {
90
+ forceManualReview?: boolean;
91
+ preferFullContext?: boolean;
92
+ preserveConversationHistory?: boolean;
93
+ }): SidechainMergePolicy;
94
+ export declare function resolveSidechainMergePolicy(params?: {
95
+ preferFullContext?: boolean;
96
+ forceManualReview?: boolean;
97
+ preserveConversationHistory?: boolean;
98
+ }): SidechainMergePolicy;
99
+ export { applyToolChoicePolicy, type ApplyToolChoicePolicyInput, type ApplyToolChoicePolicyResult, } from "./tool-choice-policy.js";
100
+ export { repairOpenAiChatConversation, type ConversationRepairOptions, type OpenAiChatMessageLike, type OpenAiToolCall, } from "./conversation-repair.js";
101
+ export { advanceToolLoopState, recoverToolLoopStateFromChatConversation, recoverToolLoopStateFromResponsesItems, settleToolLoopState, type RepairToolLoopStateResult, type ToolLoopRepairAction, type ToolLoopState, } from "./tool-loop-state.js";
102
+ 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";
103
+ export { isForegroundSource, isTransientCapacityError, computeRetryBackoff, isPersistentRetryEnabled, FallbackTriggeredError, type PersistentRetryConfig, } from "./retry-loop.js";
104
+ 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";
105
+ export { buildConsolidationPrompt, buildCuratorRunSummary, detectPrefixClusters, parseConsolidationOutput, reconcileConsolidationPlan, type ConsolidationAction, type ConsolidationPlan, type ConsolidationSkillSummary, type CuratorRunReport, type PruningAction, type ReconciledConsolidationPlan, type SkillPrefixCluster, } from "./skill-consolidation.js";
106
+ 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";
107
+ 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";
108
+ 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";
109
+ export { getBuiltInAgent, getBuiltInAgents, isBuiltInAgent, resolveAgentToolSet, type AgentDefinition, } from "./agent-registry.js";
110
+ export { createTaskState, filterToolsByRole, type IsolationMode, type PermissionRole, type TaskType, type TaskLifecycle, type TaskState, type TaskStateBase, type LocalBashTaskState, type LocalAgentTaskState, type RemoteAgentTaskState, type InProcessTeammateTaskState, type DreamTaskState, type DreamTurn, type DreamPhase, } from "./task-types.js";
111
+ export { calculateTokenWarningState, createTurnLoopGuardState, resolveApiErrorRecovery, resolveOutputTokenEscalation, shouldAbortTurn, type ApiErrorRecovery, type TokenWarningState, type TurnLoopGuardConfig, type TurnLoopGuardState, } from "./turn-loop-guard.js";
112
+ export { buildPostCompactRestorationMessage, createReactiveCompactState, shouldAttemptReactiveCompact, type ReactiveCompactConfig, type ReactiveCompactState, } from "./reactive-compact.js";
113
+ export { aggregateTeamToolResults, mapTeamRequestToForkConfigs, resolveTeamExecutionPlan, type TeamAgentRequest, type TeamAggregatedResult, type TeamExecutionBatch, type TeamExecutionPlan, type TeamToolRequest, } from "./team-tool-loop-wiring.js";
@@ -0,0 +1,14 @@
1
+ import { MEMORY_OBSERVATION_HOOK_VALUES, type MemoryObservationHook, MEMORY_OBSERVATION_SOURCE_VALUES, type MemoryObservationSource, MEMORY_WRITE_ACCESS_VALUES, type MemoryWriteAccess } from "qlogicagent-runtime-contracts";
2
+ export { MEMORY_OBSERVATION_HOOK_VALUES, type MemoryObservationHook, MEMORY_OBSERVATION_SOURCE_VALUES, type MemoryObservationSource, MEMORY_WRITE_ACCESS_VALUES, type MemoryWriteAccess, };
3
+ export interface MemoryProviderLifecycleInvocation {
4
+ hook: MemoryObservationHook;
5
+ source: MemoryObservationSource;
6
+ sessionId: string;
7
+ turnId?: string;
8
+ executionId?: string;
9
+ rootExecutionId?: string;
10
+ parentExecutionId?: string;
11
+ sidechainId?: string;
12
+ attemptId?: string;
13
+ writeAccess: MemoryWriteAccess;
14
+ }
@@ -0,0 +1,73 @@
1
+ /**
2
+ * Reactive Compact — Emergency context compression when API returns prompt-too-long.
3
+ *
4
+ * Aligned with Claude Code's reactive compact chain:
5
+ * 1. API 413 → withhold error → attempt reactive compact → retry
6
+ * 2. Only one reactive compact attempt per turn (prevent infinite loops)
7
+ * 3. Falls back to abort if compact fails
8
+ *
9
+ * Also handles post-compact restoration:
10
+ * - Todo list re-injection
11
+ * - Skill context re-injection
12
+ * - Tool delta re-injection (new/removed tools since last compact)
13
+ */
14
+ export interface ReactiveCompactConfig {
15
+ /** Maximum consecutive auto-compact failures before giving up (CC: 3). */
16
+ maxConsecutiveFailures: number;
17
+ /** Minimum messages to keep after reactive compact. */
18
+ minMessagesAfterCompact: number;
19
+ /** Target token usage after compact (percentage of context window). */
20
+ targetUsagePercent: number;
21
+ }
22
+ export declare const DEFAULT_REACTIVE_COMPACT_CONFIG: ReactiveCompactConfig;
23
+ export interface PostCompactRestorationPayload {
24
+ /** Current active todo list to re-inject after compact. */
25
+ todoList?: Array<{
26
+ id: number;
27
+ title: string;
28
+ status: string;
29
+ }>;
30
+ /** Active skill context (if LLM is executing a skill). */
31
+ activeSkillContext?: {
32
+ name: string;
33
+ step: number;
34
+ instructions: string;
35
+ };
36
+ /** Tool delta since last compact (tools added/removed from available set). */
37
+ toolDelta?: {
38
+ added: string[];
39
+ removed: string[];
40
+ };
41
+ /** Custom restoration blocks from memory hooks. */
42
+ customBlocks?: Array<{
43
+ label: string;
44
+ content: string;
45
+ }>;
46
+ }
47
+ /**
48
+ * Build the restoration message to inject after a compact operation.
49
+ * This ensures critical state survives context compression.
50
+ */
51
+ export declare function buildPostCompactRestorationMessage(payload: PostCompactRestorationPayload): string | null;
52
+ export interface ReactiveCompactState {
53
+ /** Number of consecutive compact failures. */
54
+ consecutiveFailures: number;
55
+ /** Whether reactive compact has been attempted in this turn. */
56
+ attemptedThisTurn: boolean;
57
+ /** Last compact timestamp. */
58
+ lastCompactAt: number | null;
59
+ /** Tool names at time of last compact (for delta calculation). */
60
+ toolsAtLastCompact: string[];
61
+ }
62
+ export declare function createReactiveCompactState(): ReactiveCompactState;
63
+ /**
64
+ * Determine if reactive compact should be attempted.
65
+ */
66
+ export declare function shouldAttemptReactiveCompact(state: ReactiveCompactState, config?: ReactiveCompactConfig): boolean;
67
+ /**
68
+ * Calculate the tool delta since last compact.
69
+ */
70
+ export declare function computeToolDelta(currentTools: string[], toolsAtLastCompact: string[]): {
71
+ added: string[];
72
+ removed: string[];
73
+ };
@@ -0,0 +1,69 @@
1
+ export declare function executeBoundedRetryLoop<TResult>(params: {
2
+ maxIterations: number;
3
+ onRetryLimit: (params: {
4
+ iterations: number;
5
+ maxIterations: number;
6
+ }) => Promise<TResult> | TResult;
7
+ executeIteration: (params: {
8
+ iteration: number;
9
+ }) => Promise<{
10
+ kind: "continue";
11
+ } | {
12
+ kind: "return";
13
+ result: TResult;
14
+ }>;
15
+ }): Promise<TResult>;
16
+ export declare function resolveScaledRetryIterations(params: {
17
+ candidateCount: number;
18
+ baseIterations?: number;
19
+ perCandidateIterations?: number;
20
+ minIterations?: number;
21
+ maxIterations?: number;
22
+ }): number;
23
+ export declare function isForegroundSource(source: string | undefined): boolean;
24
+ /** Is this a transient capacity error (429 or 529/overloaded)? */
25
+ export declare function isTransientCapacityError(status: number | undefined): boolean;
26
+ /**
27
+ * Compute exponential backoff delay with jitter.
28
+ * CC parity: withRetry.ts — BASE_DELAY_MS=500, 2^n backoff, capped.
29
+ */
30
+ export declare function computeRetryBackoff(attempt: number, baseDelayMs?: number, maxDelayMs?: number): number;
31
+ /**
32
+ * Persistent retry mode — for unattended sessions.
33
+ * Retries 429/529 indefinitely with higher backoff.
34
+ * Yields heartbeat events periodically so the host doesn't mark us idle.
35
+ *
36
+ * CC parity: withRetry.ts CLAUDE_CODE_UNATTENDED_RETRY
37
+ */
38
+ export interface PersistentRetryConfig {
39
+ /** Max backoff interval (CC: 5 min). */
40
+ maxBackoffMs: number;
41
+ /** Total cap before giving up (CC: 6 hours). */
42
+ resetCapMs: number;
43
+ /** Heartbeat interval during waits (CC: 30 seconds). */
44
+ heartbeatIntervalMs: number;
45
+ }
46
+ export declare const DEFAULT_PERSISTENT_RETRY_CONFIG: PersistentRetryConfig;
47
+ /**
48
+ * Check if persistent retry is enabled via environment variable.
49
+ * CC parity: CLAUDE_CODE_UNATTENDED_RETRY
50
+ */
51
+ export declare function isPersistentRetryEnabled(): boolean;
52
+ /**
53
+ * Error class for triggering model fallback after repeated 529s.
54
+ * CC parity: FallbackTriggeredError
55
+ */
56
+ export declare class FallbackTriggeredError extends Error {
57
+ readonly originalModel: string;
58
+ readonly fallbackModel: string;
59
+ constructor(originalModel: string, fallbackModel: string);
60
+ }
61
+ /**
62
+ * Error class for when retries are exhausted and cannot continue.
63
+ * CC parity: CannotRetryError
64
+ */
65
+ export declare class CannotRetryError extends Error {
66
+ readonly originalError: unknown;
67
+ readonly model: string;
68
+ constructor(originalError: unknown, model: string);
69
+ }
@@ -0,0 +1,52 @@
1
+ import { type SkillCandidateAction, type SkillCandidateArtifactContract, type SkillCandidateEffectivenessContract, type SkillCandidateReviewContract, type SkillCandidateSourceExecutionContract } from "../contracts/skill-candidate.js";
2
+ export type SkillImprovementPolicyContract = {
3
+ reviewRequired: boolean;
4
+ canaryRequired: boolean;
5
+ autoPromote: boolean;
6
+ minCanarySampleCount: number;
7
+ minSuccessRate: number;
8
+ maxRegressionRate: number;
9
+ maxCostIncreaseRate: number;
10
+ staleAfterHours: number;
11
+ };
12
+ export type SkillCandidateImprovementEvidenceBundleContract = {
13
+ artifact?: SkillCandidateArtifactContract | null;
14
+ sourceExecution?: SkillCandidateSourceExecutionContract | null;
15
+ sourceSessionKey?: string | null;
16
+ diffSummary?: string | null;
17
+ baselineCandidateId?: string | null;
18
+ rolloutNotes?: string | null;
19
+ validationRefs?: string[];
20
+ evidence?: Record<string, unknown>;
21
+ };
22
+ export declare function createDefaultSkillImprovementPolicy(overrides?: Partial<SkillImprovementPolicyContract>): SkillImprovementPolicyContract;
23
+ export declare function normalizeSkillImprovementPolicy(value: unknown, fallback?: SkillImprovementPolicyContract): SkillImprovementPolicyContract;
24
+ export declare function buildSkillCandidateEvidencePayload(params: {
25
+ evidence?: Record<string, unknown> | null;
26
+ artifact?: SkillCandidateArtifactContract | null;
27
+ sourceExecution?: SkillCandidateSourceExecutionContract | null;
28
+ sourceSessionKey?: string | null;
29
+ }): Record<string, unknown>;
30
+ export declare function buildSkillCandidateImprovementEvidenceBundle(params: SkillCandidateImprovementEvidenceBundleContract): Record<string, unknown>;
31
+ export declare function buildSkillCandidateLatestReview(params: {
32
+ action: SkillCandidateAction;
33
+ actor?: string | null;
34
+ notes?: string | null;
35
+ payload?: Record<string, unknown> | null;
36
+ createdAt?: string;
37
+ }): SkillCandidateReviewContract;
38
+ export declare function buildSkillCandidateEffectivenessSummary(params: {
39
+ phase: "canary" | "published";
40
+ sampleCount?: number;
41
+ successCount?: number;
42
+ failureCount?: number;
43
+ regressionCount?: number;
44
+ avgLatencyMs?: number;
45
+ avgCostUsd?: number;
46
+ score?: number;
47
+ staleReason?: string | null;
48
+ notes?: string | null;
49
+ summary?: Record<string, unknown> | null;
50
+ lastObservedAt?: string;
51
+ updatedAt?: string;
52
+ }): SkillCandidateEffectivenessContract;
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Skill consolidation strategy — pure decision logic for
3
+ * the Autonomous Curator's LLM-driven skill merging phase.
4
+ *
5
+ * This module:
6
+ * 1. Detects prefix clusters among skill names.
7
+ * 2. Builds the consolidation prompt for the LLM review agent.
8
+ * 3. Parses structured LLM output into actionable merge/prune plans.
9
+ * 4. Reconciles LLM intent against ground truth (existing skills).
10
+ *
11
+ * No I/O — the caller invokes the LLM and applies the results.
12
+ */
13
+ /** A skill summary fed to the LLM reviewer. */
14
+ export interface ConsolidationSkillSummary {
15
+ name: string;
16
+ description: string;
17
+ /** Comma-separated tool names the skill uses. */
18
+ tools: string;
19
+ useCount: number;
20
+ lastActivityAt: string | null;
21
+ state: "active" | "stale";
22
+ }
23
+ /** A single consolidation action proposed by the LLM. */
24
+ export interface ConsolidationAction {
25
+ /** Source skill to be absorbed. */
26
+ sourceSkill: string;
27
+ /** Target umbrella skill (existing or to-be-created). */
28
+ targetUmbrella: string;
29
+ /** Whether the target umbrella already exists. */
30
+ targetExists: boolean;
31
+ /** LLM's reason for the merge. */
32
+ reason: string;
33
+ }
34
+ /** A single pruning action proposed by the LLM. */
35
+ export interface PruningAction {
36
+ /** Skill to be archived (not deleted). */
37
+ skillName: string;
38
+ /** Reason for pruning. */
39
+ reason: string;
40
+ }
41
+ /** Full consolidation plan produced by parsing LLM output. */
42
+ export interface ConsolidationPlan {
43
+ consolidations: ConsolidationAction[];
44
+ prunings: PruningAction[];
45
+ /** Skills mentioned by LLM but not found in ground truth. */
46
+ hallucinations: string[];
47
+ }
48
+ /** Result of reconciling the LLM plan against ground truth. */
49
+ export interface ReconciledConsolidationPlan {
50
+ /** Validated consolidation actions (targets exist or are marked for creation). */
51
+ validConsolidations: ConsolidationAction[];
52
+ /** Validated pruning actions (skills exist). */
53
+ validPrunings: PruningAction[];
54
+ /** Rejected actions due to ground-truth mismatch. */
55
+ rejected: Array<{
56
+ action: string;
57
+ reason: string;
58
+ }>;
59
+ }
60
+ /** A detected cluster of skills sharing a naming prefix. */
61
+ export interface SkillPrefixCluster {
62
+ prefix: string;
63
+ skills: string[];
64
+ }
65
+ /**
66
+ * Detect prefix clusters among skill names.
67
+ *
68
+ * A cluster is ≥2 skills sharing a common hyphenated prefix of ≥2 chars.
69
+ * E.g. `["pr-review", "pr-merge", "pr-label"]` → cluster `"pr"`.
70
+ */
71
+ export declare function detectPrefixClusters(skillNames: readonly string[], minClusterSize?: number): SkillPrefixCluster[];
72
+ /**
73
+ * Build the consolidation review prompt for the LLM curator agent.
74
+ *
75
+ * The prompt instructs the model to:
76
+ * 1. Identify prefix clusters and overlapping skills.
77
+ * 2. Propose umbrella consolidations.
78
+ * 3. Mark redundant/trivial skills for pruning (archive, not delete).
79
+ * 4. Output a structured YAML block.
80
+ */
81
+ export declare function buildConsolidationPrompt(candidates: readonly ConsolidationSkillSummary[], existingUmbrellas: readonly string[], clusters: readonly SkillPrefixCluster[]): string;
82
+ /**
83
+ * Parse the LLM's structured YAML response into a ConsolidationPlan.
84
+ *
85
+ * Tolerant: handles minor formatting variations, ignores unknown fields.
86
+ */
87
+ export declare function parseConsolidationOutput(llmOutput: string, knownSkills: ReadonlySet<string>): ConsolidationPlan;
88
+ /**
89
+ * Reconcile the LLM's consolidation plan against ground truth.
90
+ *
91
+ * Validates that:
92
+ * - Source skills exist and aren't already consolidated in this plan.
93
+ * - Target umbrellas either exist or are new (will be created).
94
+ * - Pruning targets aren't also being consolidated.
95
+ */
96
+ export declare function reconcileConsolidationPlan(plan: ConsolidationPlan, knownSkills: ReadonlySet<string>): ReconciledConsolidationPlan;
97
+ /** Summary of a curator review run. */
98
+ export interface CuratorRunReport {
99
+ /** ISO-8601 timestamp of the run. */
100
+ runAt: string;
101
+ /** Duration in seconds. */
102
+ durationSeconds: number;
103
+ /** Number of skills checked for lifecycle transitions. */
104
+ autoTransitionsChecked: number;
105
+ /** Number of skills marked stale. */
106
+ autoMarkedStale: number;
107
+ /** Number of skills archived. */
108
+ autoArchived: number;
109
+ /** Number of skills reactivated. */
110
+ autoReactivated: number;
111
+ /** Number of LLM-proposed consolidations accepted. */
112
+ consolidationsAccepted: number;
113
+ /** Number of LLM-proposed prunings accepted. */
114
+ pruningsAccepted: number;
115
+ /** Number of LLM-proposed actions rejected. */
116
+ actionsRejected: number;
117
+ /** Number of hallucinated skill names. */
118
+ hallucinations: number;
119
+ }
120
+ /**
121
+ * Build a human-readable summary from a curator run report.
122
+ */
123
+ export declare function buildCuratorRunSummary(report: CuratorRunReport): string;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Skill self-learning: decides whether a completed turn should
3
+ * trigger skill creation or improvement instructions.
4
+ */
5
+ export interface SkillTurnResult {
6
+ ok: boolean;
7
+ /** Number of tool invocations in this turn */
8
+ toolCallCount: number;
9
+ /** Number of distinct tool names used */
10
+ distinctToolCount: number;
11
+ /** Was a multi-step orchestration (≥2 rounds) used? */
12
+ multiStep: boolean;
13
+ /** Did the turn involve a sidechain? */
14
+ hasSidechain: boolean;
15
+ /** Optional user feedback signal (positive/negative/none) */
16
+ feedback?: "positive" | "negative" | null;
17
+ /** Skill name if an existing skill was used */
18
+ existingSkillName?: string | null;
19
+ }
20
+ export interface SkillCreateInstruction {
21
+ type: "skill.create";
22
+ /** Suggested skill name derived from tool usage pattern */
23
+ suggestedName: string;
24
+ /** Short description of what the skill does */
25
+ description: string;
26
+ /** Tool names involved */
27
+ tools: string[];
28
+ /** Number of orchestration steps */
29
+ stepCount: number;
30
+ }
31
+ export interface SkillImproveInstruction {
32
+ type: "skill.improve";
33
+ /** Existing skill to improve */
34
+ skillName: string;
35
+ /** Reason for improvement */
36
+ reason: string;
37
+ }
38
+ export type SkillInstruction = SkillCreateInstruction | SkillImproveInstruction;
39
+ /**
40
+ * Determine whether a completed turn should produce a skill instruction.
41
+ *
42
+ * A new skill is suggested when:
43
+ * - The turn succeeded
44
+ * - It involved multi-step orchestration
45
+ * - It used ≥3 tool calls across ≥2 distinct tools
46
+ * - No existing skill was already applied
47
+ *
48
+ * An improvement is suggested when:
49
+ * - The turn used an existing skill but got negative feedback
50
+ */
51
+ export declare function shouldCreateSkill(result: SkillTurnResult): boolean;
52
+ export declare function shouldImproveSkill(result: SkillTurnResult): boolean;
53
+ /**
54
+ * Build a skill instruction from a turn result, or null if none is warranted.
55
+ */
56
+ export declare function buildSkillInstruction(result: SkillTurnResult, context: {
57
+ tools: string[];
58
+ suggestedName?: string;
59
+ }): SkillInstruction | null;
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Skill similarity — pure strategy for detecting near-duplicate skills
3
+ * before creation and during curator consolidation reviews.
4
+ *
5
+ * Computes multi-signal similarity between skills:
6
+ * 1. Tool-set Jaccard overlap (primary signal for auto-generated skills)
7
+ * 2. Title/description cosine bigram similarity (complementary signal)
8
+ * 3. Step-count proximity (minor signal for workflow complexity)
9
+ *
10
+ * No I/O — all functions are pure.
11
+ */
12
+ /** Minimal skill profile for similarity comparison. */
13
+ export interface SkillSimilarityProfile {
14
+ skillKey: string;
15
+ title: string;
16
+ tools: readonly string[];
17
+ stepCount?: number;
18
+ }
19
+ /** Result of a pairwise similarity comparison. */
20
+ export interface SimilarityScore {
21
+ /** Overall similarity [0, 1]. */
22
+ overall: number;
23
+ /** Tool-set Jaccard index [0, 1]. */
24
+ toolJaccard: number;
25
+ /** Title bigram similarity [0, 1]. */
26
+ titleSimilarity: number;
27
+ /** Step-count proximity [0, 1]. */
28
+ stepProximity: number;
29
+ }
30
+ /** A candidate detected as similar during pre-creation check. */
31
+ export interface SimilarSkillMatch {
32
+ existingSkillKey: string;
33
+ score: SimilarityScore;
34
+ }
35
+ /** Policy for similarity thresholds. */
36
+ export interface SkillSimilarityPolicy {
37
+ /**
38
+ * Overall similarity threshold to block creation and emit "improve"
39
+ * instead. Default: 0.75.
40
+ */
41
+ blockCreationThreshold: number;
42
+ /**
43
+ * Overall similarity threshold to flag for curator review.
44
+ * Default: 0.55.
45
+ */
46
+ curatorReviewThreshold: number;
47
+ /** Weight of toolJaccard in overall score. Default: 0.60. */
48
+ toolWeight: number;
49
+ /** Weight of titleSimilarity in overall score. Default: 0.30. */
50
+ titleWeight: number;
51
+ /** Weight of stepProximity in overall score. Default: 0.10. */
52
+ stepWeight: number;
53
+ }
54
+ export declare const DEFAULT_SKILL_SIMILARITY_POLICY: SkillSimilarityPolicy;
55
+ /**
56
+ * Compute Jaccard index between two tool sets.
57
+ * Returns 0 if both sets are empty.
58
+ */
59
+ export declare function toolSetJaccard(toolsA: readonly string[], toolsB: readonly string[]): number;
60
+ /**
61
+ * Compute character-bigram similarity between two strings.
62
+ * Uses Dice coefficient of bigram sets.
63
+ */
64
+ export declare function bigramSimilarity(a: string, b: string): number;
65
+ /**
66
+ * Compute step-count proximity [0, 1].
67
+ * Returns 1 when counts are identical, decreases with difference.
68
+ */
69
+ export declare function stepCountProximity(stepsA: number | undefined, stepsB: number | undefined): number;
70
+ /**
71
+ * Compute overall similarity between two skill profiles.
72
+ */
73
+ export declare function computeSimilarity(a: SkillSimilarityProfile, b: SkillSimilarityProfile, policy?: Partial<SkillSimilarityPolicy>): SimilarityScore;
74
+ /**
75
+ * Check a new skill candidate against existing skills for similarity.
76
+ *
77
+ * Returns all existing skills above curatorReviewThreshold, sorted
78
+ * by descending similarity. The caller should:
79
+ * - Block creation if any match ≥ blockCreationThreshold (emit improve instead)
80
+ * - Tag for curator review if match ≥ curatorReviewThreshold
81
+ */
82
+ export declare function findSimilarSkills(newSkill: SkillSimilarityProfile, existingSkills: readonly SkillSimilarityProfile[], policy?: Partial<SkillSimilarityPolicy>): SimilarSkillMatch[];
83
+ /**
84
+ * Determine creation decision based on similarity matches.
85
+ */
86
+ export type SimilarityDecision = {
87
+ action: "create";
88
+ reason: string;
89
+ } | {
90
+ action: "improve";
91
+ targetSkillKey: string;
92
+ reason: string;
93
+ } | {
94
+ action: "flag-for-review";
95
+ targetSkillKey: string;
96
+ reason: string;
97
+ };
98
+ export declare function decideSimilarityAction(matches: readonly SimilarSkillMatch[], policy?: Partial<SkillSimilarityPolicy>): SimilarityDecision;