qlogicagent 0.5.3 → 1.0.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 (104) hide show
  1. package/README.md +24 -23
  2. package/dist/agent.js +13 -13
  3. package/dist/cli.js +218 -184
  4. package/dist/contracts.js +1 -1
  5. package/dist/index.js +391 -20
  6. package/dist/orchestration.js +14 -105
  7. package/dist/types/agent/agent.d.ts +1 -1
  8. package/dist/types/agent/constants.d.ts +2 -2
  9. package/dist/types/agent/tool-access.d.ts +30 -0
  10. package/dist/types/agent/tool-loop.d.ts +2 -4
  11. package/dist/types/agent/types.d.ts +51 -13
  12. package/dist/types/cli/main.d.ts +3 -3
  13. package/dist/types/cli/stdio-server.d.ts +89 -7
  14. package/dist/types/cli/tool-bootstrap.d.ts +16 -5
  15. package/dist/types/cli/transport.d.ts +40 -0
  16. package/dist/types/contracts/index.d.ts +0 -1
  17. package/dist/types/contracts/todo.d.ts +9 -0
  18. package/dist/types/index.d.ts +3 -0
  19. package/dist/types/llm/index.d.ts +7 -1
  20. package/dist/types/llm/media-client.d.ts +43 -0
  21. package/dist/types/llm/media-transport.d.ts +80 -0
  22. package/dist/types/llm/model-catalog.d.ts +5 -5
  23. package/dist/types/llm/provider-def.d.ts +7 -0
  24. package/dist/types/llm/provider-registry.d.ts +1 -1
  25. package/dist/types/llm/transport.d.ts +2 -0
  26. package/dist/types/llm/transports/anthropic-messages.d.ts +34 -11
  27. package/dist/types/llm/transports/gemini-media.d.ts +21 -0
  28. package/dist/types/llm/transports/minimax-media.d.ts +21 -0
  29. package/dist/types/llm/transports/openai-chat.d.ts +1 -1
  30. package/dist/types/llm/transports/openai-media.d.ts +24 -0
  31. package/dist/types/llm/transports/qwen-media.d.ts +25 -0
  32. package/dist/types/llm/transports/volcengine-media.d.ts +34 -0
  33. package/dist/types/orchestration/index.d.ts +14 -112
  34. package/dist/types/orchestration/skill-improvement.d.ts +2 -2
  35. package/dist/types/orchestration/{fork-subagent.d.ts → subagent/fork-subagent.d.ts} +2 -4
  36. package/dist/types/orchestration/{tool-schema.d.ts → tool-loop/tool-schema.d.ts} +1 -2
  37. package/dist/types/protocol/index.d.ts +7 -0
  38. package/dist/types/protocol/methods.d.ts +380 -0
  39. package/dist/types/protocol/notifications.d.ts +296 -0
  40. package/dist/types/runtime/execution/dream-agent.d.ts +1 -1
  41. package/dist/types/runtime/execution/forked-agent.d.ts +1 -3
  42. package/dist/types/runtime/hooks/context-compression.d.ts +1 -1
  43. package/dist/types/runtime/infra/agent-paths.d.ts +57 -0
  44. package/dist/types/runtime/infra/checkpoint-backend.d.ts +8 -0
  45. package/dist/types/runtime/infra/disk-storage.d.ts +36 -0
  46. package/dist/types/runtime/infra/file-watcher.d.ts +2 -2
  47. package/dist/types/runtime/infra/index.d.ts +2 -0
  48. package/dist/types/runtime/infra/secure-storage.d.ts +1 -1
  49. package/dist/types/runtime/infra/task-runtime.d.ts +1 -1
  50. package/dist/types/runtime/prompt/environment-context.d.ts +1 -1
  51. package/dist/types/runtime/prompt/instruction-loader.d.ts +6 -6
  52. package/dist/types/runtime/session/index.d.ts +1 -1
  53. package/dist/types/runtime/session/session-memory.d.ts +0 -1
  54. package/dist/types/runtime/session/session-persistence.d.ts +1 -1
  55. package/dist/types/runtime/session/session-state.d.ts +18 -9
  56. package/dist/types/skills/index.d.ts +20 -26
  57. package/dist/types/skills/mcp/mcp-manager.d.ts +3 -4
  58. package/dist/types/skills/mcp/mcp-stdio-client.d.ts +1 -1
  59. package/dist/types/skills/{memory-store.d.ts → memory/memory-store.d.ts} +20 -0
  60. package/dist/types/skills/{memory-tool.d.ts → memory/memory-tool.d.ts} +20 -0
  61. package/dist/types/skills/{qmemory-adapter.d.ts → memory/qmemory-adapter.d.ts} +1 -0
  62. package/dist/types/skills/permissions/hook-runner.d.ts +1 -1
  63. package/dist/types/skills/permissions/settings-watcher.d.ts +2 -2
  64. package/dist/types/skills/plugins/plugin-api.d.ts +1 -1
  65. package/dist/types/skills/plugins/plugin-loader.d.ts +1 -4
  66. package/dist/types/skills/plugins/plugin-marketplace.d.ts +1 -1
  67. package/dist/types/skills/portable-tool.d.ts +34 -1
  68. package/dist/types/skills/todo-tool.d.ts +51 -42
  69. package/dist/types/skills/tools/instructions-tool.d.ts +20 -58
  70. package/dist/types/skills/tools/shell/shell-exec.d.ts +2 -0
  71. package/dist/types/skills/tools/skill-invoke-tool.d.ts +2 -2
  72. package/dist/types/skills/tools.d.ts +65 -0
  73. package/package.json +2 -2
  74. package/dist/types/contracts/skill-candidate.d.ts +0 -63
  75. package/dist/types/orchestration/curator-scheduler.d.ts +0 -119
  76. package/dist/types/orchestration/memory-provider.d.ts +0 -14
  77. package/dist/types/orchestration/skill-candidate.d.ts +0 -52
  78. package/dist/types/orchestration/skill-consolidation.d.ts +0 -123
  79. package/dist/types/orchestration/skill-similarity.d.ts +0 -98
  80. package/dist/types/orchestration/team-orchestration.d.ts +0 -195
  81. package/dist/types/orchestration/team-tool-loop-wiring.d.ts +0 -92
  82. package/dist/types/skills/memory-query-tool.d.ts +0 -43
  83. package/dist/types/skills/tool-registry.d.ts +0 -29
  84. package/dist/types/skills/tools/memory-tool.d.ts +0 -74
  85. package/dist/types/skills/tools/pdf-tool.d.ts +0 -66
  86. /package/dist/types/orchestration/{context-collapse.d.ts → context/context-collapse.d.ts} +0 -0
  87. /package/dist/types/orchestration/{context-compression.d.ts → context/context-compression.d.ts} +0 -0
  88. /package/dist/types/orchestration/{reactive-compact.d.ts → context/reactive-compact.d.ts} +0 -0
  89. /package/dist/types/orchestration/{turn-loop-guard.d.ts → context/turn-loop-guard.d.ts} +0 -0
  90. /package/dist/types/orchestration/{error-classification.d.ts → error-handling/error-classification.d.ts} +0 -0
  91. /package/dist/types/orchestration/{failover-classification.d.ts → error-handling/failover-classification.d.ts} +0 -0
  92. /package/dist/types/orchestration/{failover-error.d.ts → error-handling/failover-error.d.ts} +0 -0
  93. /package/dist/types/orchestration/{retry-loop.d.ts → error-handling/retry-loop.d.ts} +0 -0
  94. /package/dist/types/orchestration/{agent-registry.d.ts → subagent/agent-registry.d.ts} +0 -0
  95. /package/dist/types/orchestration/{task-types.d.ts → subagent/task-types.d.ts} +0 -0
  96. /package/dist/types/orchestration/{conversation-repair.d.ts → tool-loop/conversation-repair.d.ts} +0 -0
  97. /package/dist/types/orchestration/{tool-choice-policy.d.ts → tool-loop/tool-choice-policy.d.ts} +0 -0
  98. /package/dist/types/orchestration/{tool-loop-state.d.ts → tool-loop/tool-loop-state.d.ts} +0 -0
  99. /package/dist/types/skills/{memory-extractor.d.ts → memory/memory-extractor.d.ts} +0 -0
  100. /package/dist/types/skills/{skill-frontmatter.d.ts → skill-system/skill-frontmatter.d.ts} +0 -0
  101. /package/dist/types/skills/{skill-guard.d.ts → skill-system/skill-guard.d.ts} +0 -0
  102. /package/dist/types/skills/{skill-loader.d.ts → skill-system/skill-loader.d.ts} +0 -0
  103. /package/dist/types/skills/{skill-source.d.ts → skill-system/skill-source.d.ts} +0 -0
  104. /package/dist/types/skills/{skill-types.d.ts → skill-system/skill-types.d.ts} +0 -0
@@ -1,113 +1,15 @@
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";
1
+ export { buildAssistantToolCallMessage, buildToolResultMessage, type FunctionToolDefinition, } from "./tool-loop/tool-schema.js";
2
+ export { classifyError, getRetryStrategy, type ErrorCategory, type RetryStrategy, } from "./error-handling/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/context-compression.js";
4
+ export { snipCompactIfNeeded, type SnipResult, } from "./context/context-compression.js";
5
+ export { applyCollapsesIfNeeded as applyContextCollapsesIfNeeded, recoverFromOverflow as recoverContextCollapseFromOverflow, createCollapseStore, type CollapseStore, type CollapseStage, } from "./context/context-collapse.js";
6
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";
7
+ export { applyToolChoicePolicy, type ApplyToolChoicePolicyInput, type ApplyToolChoicePolicyResult, } from "./tool-loop/tool-choice-policy.js";
8
+ export { repairOpenAiChatConversation, type ConversationRepairOptions, type OpenAiChatMessageLike, type OpenAiToolCall, } from "./tool-loop/conversation-repair.js";
9
+ export { advanceToolLoopState, recoverToolLoopStateFromChatConversation, recoverToolLoopStateFromResponsesItems, settleToolLoopState, type RepairToolLoopStateResult, type ToolLoopRepairAction, type ToolLoopState, } from "./tool-loop/tool-loop-state.js";
10
+ export { isForegroundSource, isTransientCapacityError, computeRetryBackoff, isPersistentRetryEnabled, FallbackTriggeredError, type PersistentRetryConfig, } from "./error-handling/retry-loop.js";
11
+ export { canForkAtDepth, buildForkedMessages, buildForkPlaceholderResults, FORK_PLACEHOLDER_RESULT, FORK_SENTINEL_TAG, generateForkChildAgentId, isInForkChild, MAX_FORK_DEPTH, resolveForkChildTools, type ForkChildConfig, type ForkChildMessage, type ForkContext, type ForkResult, } from "./subagent/fork-subagent.js";
12
+ export { getBuiltInAgent, getBuiltInAgents, isBuiltInAgent, resolveAgentToolSet, type AgentDefinition, } from "./subagent/agent-registry.js";
13
+ 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 "./subagent/task-types.js";
14
+ export { calculateTokenWarningState, createTurnLoopGuardState, resolveApiErrorRecovery, resolveOutputTokenEscalation, shouldAbortTurn, type ApiErrorRecovery, type TokenWarningState, type TurnLoopGuardConfig, type TurnLoopGuardState, } from "./context/turn-loop-guard.js";
15
+ export { buildPostCompactRestorationMessage, createReactiveCompactState, shouldAttemptReactiveCompact, type ReactiveCompactConfig, type ReactiveCompactState, } from "./context/reactive-compact.js";
@@ -10,8 +10,8 @@ export interface SkillTurnResult {
10
10
  distinctToolCount: number;
11
11
  /** Was a multi-step orchestration (≥2 rounds) used? */
12
12
  multiStep: boolean;
13
- /** Did the turn involve a sidechain? */
14
- hasSidechain: boolean;
13
+ /** Did the turn involve a sub-agent fork? */
14
+ hasSubAgent: boolean;
15
15
  /** Optional user feedback signal (positive/negative/none) */
16
16
  feedback?: "positive" | "negative" | null;
17
17
  /** Skill name if an existing skill was used */
@@ -13,10 +13,8 @@ import type { AgentDefinition } from "./agent-registry.js";
13
13
  export declare const FORK_SENTINEL_TAG = "<fork-child-context>";
14
14
  /** Placeholder text used for all tool_results in shared prefix (ensures byte-identical prefix). */
15
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). */
16
+ /** Maximum fork depth for in-memory agents (CC: MAX_FORK_DEPTH). */
17
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
18
  export interface ForkContext {
21
19
  /** Parent's full message history (becomes shared prefix for cache). */
22
20
  parentMessages: unknown[];
@@ -67,7 +65,7 @@ export declare function isInForkChild(messages: unknown[]): boolean;
67
65
  /**
68
66
  * Check if fork depth allows spawning another child.
69
67
  */
70
- export declare function canForkAtDepth(currentDepth: number, mode?: "in-memory" | "db-sidechain"): boolean;
68
+ export declare function canForkAtDepth(currentDepth: number): boolean;
71
69
  /**
72
70
  * Build forked messages that ensure byte-identical prefix across all fork children.
73
71
  *
@@ -21,7 +21,6 @@ export interface CapabilityToolManifestLike {
21
21
  description?: string;
22
22
  requiredParameters?: string[];
23
23
  }
24
- export declare function isXaiProvider(modelProvider?: string, modelId?: string): boolean;
25
24
  export declare function normalizeFunctionToolParameters(parameters: Record<string, unknown> | undefined, options?: ToolSchemaProvider): Record<string, unknown>;
26
25
  export declare function convertFunctionTools(tools: readonly FunctionToolSource[], options?: ToolSchemaProvider): FunctionToolDefinition[];
27
26
  export declare function convertCapabilityToolManifestsToFunctionTools(tools: readonly CapabilityToolManifestLike[]): FunctionToolDefinition[];
@@ -30,7 +29,7 @@ export declare function parseOpenAiToolCallsFromChatResponse(responseBody: strin
30
29
  toolCalls: OpenAiToolCall[];
31
30
  responseText: string;
32
31
  };
33
- export declare function buildAssistantToolCallMessage(toolCalls: OpenAiToolCall[]): Record<string, unknown>;
32
+ export declare function buildAssistantToolCallMessage(toolCalls: OpenAiToolCall[], text?: string): Record<string, unknown>;
34
33
  export declare function buildToolResultMessage(callId: string, result: {
35
34
  ok: boolean;
36
35
  payload?: unknown;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Protocol barrel — centralized re-export of all agent RPC contracts.
3
+ *
4
+ * Import from here: `import type { NotificationMethod, RpcMethod } from "../protocol/index.js";`
5
+ */
6
+ export * from "./notifications.js";
7
+ export * from "./methods.js";
@@ -0,0 +1,380 @@
1
+ /**
2
+ * Centralized RPC Method Protocol — all JSON-RPC request methods
3
+ * that qlogicagent exposes to external apps.
4
+ *
5
+ * This is the SINGLE SOURCE OF TRUTH for the agent's inbound API contract.
6
+ *
7
+ * Reference: Codex app-server RPC, Claude Code JSON-RPC, GitHub Copilot Agent API.
8
+ */
9
+ import type { ChatMessage, ToolDefinition } from "../agent/types.js";
10
+ import type { TodoItem } from "../contracts/todo.js";
11
+ export interface InitializeParams {
12
+ protocolVersion: string;
13
+ host?: {
14
+ name: string;
15
+ version: string;
16
+ };
17
+ /** Legacy flat form. */
18
+ hostName?: string;
19
+ hostVersion?: string;
20
+ capabilities?: {
21
+ streaming?: boolean;
22
+ toolApproval?: boolean;
23
+ threads?: boolean;
24
+ };
25
+ config?: Record<string, unknown>;
26
+ }
27
+ export interface InitializeResult {
28
+ protocolVersion: string;
29
+ agent: {
30
+ name: string;
31
+ version: string;
32
+ };
33
+ capabilities: {
34
+ tools: string[];
35
+ streaming: boolean;
36
+ threads: boolean;
37
+ /** New: list of notification methods the agent can emit. */
38
+ notifications: string[];
39
+ /** New: list of RPC methods the agent supports. */
40
+ methods: string[];
41
+ };
42
+ }
43
+ export interface ThreadCreateParams {
44
+ id?: string;
45
+ title?: string;
46
+ cwd?: string;
47
+ config?: Record<string, unknown>;
48
+ }
49
+ export interface ThreadCreateResult {
50
+ id: string;
51
+ title?: string;
52
+ status: "active";
53
+ createdAt: string;
54
+ }
55
+ export interface ThreadListParams {
56
+ limit?: number;
57
+ }
58
+ export interface ThreadListResult {
59
+ threads: Array<{
60
+ id: string;
61
+ title?: string;
62
+ status: "active" | "archived";
63
+ turnCount?: number;
64
+ createdAt: string;
65
+ lastActiveAt: string;
66
+ }>;
67
+ }
68
+ export interface ThreadTurnParams {
69
+ turnId?: string;
70
+ sessionId: string;
71
+ messages?: ChatMessage[];
72
+ tools?: ToolDefinition[];
73
+ config?: Record<string, unknown>;
74
+ }
75
+ export interface ThreadTurnResult {
76
+ accepted: boolean;
77
+ turnId: string;
78
+ }
79
+ export interface SessionResumeParams {
80
+ sessionId: string;
81
+ }
82
+ export interface SessionResumeResult {
83
+ metadata: {
84
+ sessionId: string;
85
+ createdAt: number;
86
+ lastActiveAt: number;
87
+ model?: string;
88
+ cwd?: string;
89
+ turnCount: number;
90
+ messageCount: number;
91
+ title?: string;
92
+ };
93
+ messages: ChatMessage[];
94
+ costSnapshot?: Record<string, unknown>;
95
+ }
96
+ export interface SessionGetInfoParams {
97
+ sessionId?: string;
98
+ }
99
+ export interface SessionGetInfoResult {
100
+ sessionId: string;
101
+ /** Persistent storage paths for this session. */
102
+ paths: {
103
+ /** Session directory (~/.qlogicagent/sessions/<id>/). */
104
+ sessionDir: string;
105
+ /** Transcript file path. */
106
+ transcript: string;
107
+ /** Session state file path. */
108
+ state: string;
109
+ /** Agent home root (~/.qlogicagent/). */
110
+ agentHome: string;
111
+ /** User settings path. */
112
+ settings: string;
113
+ /** Current working directory. */
114
+ cwd: string;
115
+ };
116
+ model?: string;
117
+ provider?: string;
118
+ turnCount: number;
119
+ title?: string;
120
+ /** Cumulative token usage for the session. */
121
+ usage?: {
122
+ totalPromptTokens: number;
123
+ totalCompletionTokens: number;
124
+ totalCost?: number;
125
+ };
126
+ }
127
+ export interface MemoryListParams {
128
+ /** Filter by source: "local" (md files), "store" (in-memory), "qmemory" (remote). */
129
+ source?: "local" | "store" | "qmemory" | "all";
130
+ }
131
+ export interface MemoryListResult {
132
+ entries: Array<{
133
+ source: "local" | "store" | "qmemory";
134
+ target?: string;
135
+ path?: string;
136
+ entryCount: number;
137
+ charCount: number;
138
+ lastModified?: string;
139
+ }>;
140
+ }
141
+ export interface MemoryReadParams {
142
+ /** Source to read from. */
143
+ source: "local" | "store" | "qmemory";
144
+ /** Target within source (e.g. "memory", "user"). */
145
+ target?: string;
146
+ /** For local source, file path relative to agent home. */
147
+ path?: string;
148
+ }
149
+ export interface MemoryReadResult {
150
+ content: string;
151
+ source: string;
152
+ target?: string;
153
+ entryCount: number;
154
+ }
155
+ export interface MemoryWriteParams {
156
+ source: "local" | "store";
157
+ target?: string;
158
+ content: string;
159
+ /** Write mode: "append" adds to existing, "replace" overwrites. */
160
+ mode?: "append" | "replace";
161
+ }
162
+ export interface MemoryWriteResult {
163
+ ok: boolean;
164
+ entryCount: number;
165
+ message: string;
166
+ }
167
+ export interface MemoryDreamParams {
168
+ turnId?: string;
169
+ sessionId: string;
170
+ config?: Record<string, unknown>;
171
+ }
172
+ export interface MemoryDreamResult {
173
+ accepted: boolean;
174
+ turnId: string;
175
+ }
176
+ export interface ToolsListParams {
177
+ /** Filter by category. */
178
+ category?: "builtin" | "mcp" | "plugin" | "all";
179
+ /** Include full parameter schemas (default false — names only). */
180
+ includeSchema?: boolean;
181
+ }
182
+ export interface ToolsListResult {
183
+ tools: Array<{
184
+ name: string;
185
+ description: string;
186
+ category: "builtin" | "mcp" | "plugin";
187
+ /** Whether this tool requires approval. */
188
+ requiresApproval?: boolean;
189
+ /** Parameter schema (if includeSchema=true). */
190
+ parameters?: Record<string, unknown>;
191
+ }>;
192
+ }
193
+ export interface ConfigGetParams {
194
+ keys?: string[];
195
+ }
196
+ export interface ConfigGetResult {
197
+ config: Record<string, unknown>;
198
+ }
199
+ export interface ConfigUpdateParams {
200
+ settings: Record<string, unknown>;
201
+ }
202
+ export interface ConfigUpdateResult {
203
+ ok: boolean;
204
+ applied: string[];
205
+ rejected?: Array<{
206
+ key: string;
207
+ reason: string;
208
+ }>;
209
+ }
210
+ export interface TodosListParams {
211
+ /** Filter by status. */
212
+ status?: "not-started" | "in-progress" | "completed" | "all";
213
+ }
214
+ export interface TodosListResult {
215
+ items: TodoItem[];
216
+ summary: {
217
+ total: number;
218
+ completed: number;
219
+ inProgress: number;
220
+ notStarted: number;
221
+ };
222
+ }
223
+ export interface AgentPingResult {
224
+ status: "ok";
225
+ }
226
+ export interface AgentAbortParams {
227
+ turnId?: string;
228
+ }
229
+ export interface AgentAbortResult {
230
+ aborted: boolean;
231
+ }
232
+ export interface ToolApprovalResponseParams {
233
+ approvalId: string;
234
+ decision: "allow-once" | "allow-session" | "allow-always" | "deny";
235
+ updatedInput?: Record<string, unknown>;
236
+ permissionUpdate?: {
237
+ pattern: string;
238
+ behavior: string;
239
+ };
240
+ }
241
+ export interface MemorySearchParams {
242
+ query: string;
243
+ /** Max results (default 10). */
244
+ limit?: number;
245
+ /** Filter by userId (defaults to current session user). */
246
+ userId?: string;
247
+ }
248
+ export interface MemorySearchResult {
249
+ results: Array<{
250
+ id: string;
251
+ text: string;
252
+ score: number;
253
+ source: string;
254
+ metadata?: Record<string, unknown>;
255
+ }>;
256
+ }
257
+ export interface MemoryDeleteParams {
258
+ /** Source: "local" only (QMemory delete via adapter). */
259
+ source: "local" | "qmemory";
260
+ /** For local: target ("memory" | "user"). */
261
+ target?: string;
262
+ /** For local: substring to match and remove. For qmemory: memory block ID. */
263
+ match: string;
264
+ }
265
+ export interface MemoryDeleteResult {
266
+ ok: boolean;
267
+ removedCount: number;
268
+ message: string;
269
+ }
270
+ export interface TasksListParams {
271
+ /** Filter by lifecycle state. */
272
+ lifecycle?: "running" | "completed" | "failed" | "cancelled" | "all";
273
+ }
274
+ export interface TasksListResult {
275
+ tasks: Array<{
276
+ taskId: string;
277
+ type: string;
278
+ lifecycle: string;
279
+ label?: string;
280
+ }>;
281
+ }
282
+ export interface TasksCancelParams {
283
+ taskId: string;
284
+ }
285
+ export interface TasksCancelResult {
286
+ ok: boolean;
287
+ message: string;
288
+ }
289
+ export interface RpcMethodMap {
290
+ "initialize": {
291
+ params: InitializeParams;
292
+ result: InitializeResult;
293
+ };
294
+ "thread.create": {
295
+ params: ThreadCreateParams;
296
+ result: ThreadCreateResult;
297
+ };
298
+ "thread.list": {
299
+ params: ThreadListParams;
300
+ result: ThreadListResult;
301
+ };
302
+ "thread.turn": {
303
+ params: ThreadTurnParams;
304
+ result: ThreadTurnResult;
305
+ };
306
+ "session.resume": {
307
+ params: SessionResumeParams;
308
+ result: SessionResumeResult;
309
+ };
310
+ "session.getInfo": {
311
+ params: SessionGetInfoParams;
312
+ result: SessionGetInfoResult;
313
+ };
314
+ "memory.list": {
315
+ params: MemoryListParams;
316
+ result: MemoryListResult;
317
+ };
318
+ "memory.read": {
319
+ params: MemoryReadParams;
320
+ result: MemoryReadResult;
321
+ };
322
+ "memory.write": {
323
+ params: MemoryWriteParams;
324
+ result: MemoryWriteResult;
325
+ };
326
+ "memory.search": {
327
+ params: MemorySearchParams;
328
+ result: MemorySearchResult;
329
+ };
330
+ "memory.delete": {
331
+ params: MemoryDeleteParams;
332
+ result: MemoryDeleteResult;
333
+ };
334
+ "memory.dream": {
335
+ params: MemoryDreamParams;
336
+ result: MemoryDreamResult;
337
+ };
338
+ "tools.list": {
339
+ params: ToolsListParams;
340
+ result: ToolsListResult;
341
+ };
342
+ "config.get": {
343
+ params: ConfigGetParams;
344
+ result: ConfigGetResult;
345
+ };
346
+ "config.update": {
347
+ params: ConfigUpdateParams;
348
+ result: ConfigUpdateResult;
349
+ };
350
+ "todos.list": {
351
+ params: TodosListParams;
352
+ result: TodosListResult;
353
+ };
354
+ "tasks.list": {
355
+ params: TasksListParams;
356
+ result: TasksListResult;
357
+ };
358
+ "tasks.cancel": {
359
+ params: TasksCancelParams;
360
+ result: TasksCancelResult;
361
+ };
362
+ "agent.ping": {
363
+ params: undefined;
364
+ result: AgentPingResult;
365
+ };
366
+ "agent.abort": {
367
+ params: AgentAbortParams;
368
+ result: AgentAbortResult;
369
+ };
370
+ "tool.approval.response": {
371
+ params: ToolApprovalResponseParams;
372
+ result: {
373
+ received: boolean;
374
+ };
375
+ };
376
+ }
377
+ /** All known RPC method names. */
378
+ export type RpcMethod = keyof RpcMethodMap;
379
+ /** All RPC method names as a runtime array (for capabilities declaration). */
380
+ export declare const ALL_RPC_METHODS: RpcMethod[];