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
@@ -0,0 +1,296 @@
1
+ /**
2
+ * Centralized Notification Event Protocol — all JSON-RPC notification types
3
+ * that qlogicagent emits to external apps.
4
+ *
5
+ * This is the SINGLE SOURCE OF TRUTH for the agent's outbound event contract.
6
+ * Frontend, Electron, Hub, and test harness all consume these types.
7
+ *
8
+ * Reference: Codex app-server events, Claude Code streaming events,
9
+ * DeerFlow LangGraph stream modes.
10
+ */
11
+ import type { TokenUsage } from "../agent/types.js";
12
+ import type { TodoItem } from "../contracts/todo.js";
13
+ /** Embedded thread item for clients using the Thread protocol. */
14
+ export interface NotificationThreadItem {
15
+ id: string;
16
+ type: string;
17
+ role: "user" | "assistant" | "system";
18
+ text?: string;
19
+ toolName?: string;
20
+ toolCallId?: string;
21
+ arguments?: string;
22
+ output?: string;
23
+ approved?: boolean;
24
+ strategy?: string;
25
+ createdAt: string;
26
+ }
27
+ /** Turn started — always emitted first. */
28
+ export interface TurnStartNotification {
29
+ turnId: string;
30
+ /** Model being used for this turn (Codex parity). */
31
+ model?: string;
32
+ /** Provider id. */
33
+ provider?: string;
34
+ }
35
+ /** Streaming text chunk from the main agent. */
36
+ export interface TurnDeltaNotification {
37
+ turnId: string;
38
+ text: string;
39
+ item?: NotificationThreadItem;
40
+ }
41
+ /** Turn completed successfully. */
42
+ export interface TurnEndNotification {
43
+ turnId: string;
44
+ content: string;
45
+ usage?: TokenUsage;
46
+ model?: string;
47
+ provider?: string;
48
+ item?: NotificationThreadItem;
49
+ }
50
+ /** Turn failed. */
51
+ export interface TurnErrorNotification {
52
+ turnId: string;
53
+ error: string;
54
+ code?: string;
55
+ }
56
+ /** Agent self-recovered from an error (retry, conversation repair, etc.). */
57
+ export interface TurnRecoveryNotification {
58
+ turnId: string;
59
+ action: string;
60
+ detail?: string;
61
+ item?: NotificationThreadItem;
62
+ }
63
+ /** Tool invocation started — includes arguments for UI display. */
64
+ export interface TurnToolCallNotification {
65
+ turnId: string;
66
+ callId: string;
67
+ name: string;
68
+ /** Serialized arguments JSON. Enables UI to display "searching for X", "reading file Y". */
69
+ arguments?: string;
70
+ item?: NotificationThreadItem;
71
+ }
72
+ /**
73
+ * Tool execution completed.
74
+ * Includes truncated output for "Used X sources" style panels.
75
+ */
76
+ export interface TurnToolResultNotification {
77
+ turnId: string;
78
+ callId: string;
79
+ name: string;
80
+ ok: boolean;
81
+ error?: string;
82
+ /** Truncated tool output (max 2000 chars). Enables source preview panels. */
83
+ outputPreview?: string;
84
+ item?: NotificationThreadItem;
85
+ }
86
+ /** Tool execution blocked by permission system. */
87
+ export interface TurnToolBlockedNotification {
88
+ turnId: string;
89
+ callId: string;
90
+ name: string;
91
+ reason: string;
92
+ item?: NotificationThreadItem;
93
+ }
94
+ /**
95
+ * Reasoning/thinking token stream — separate from main delta.
96
+ * Enables DeerFlow-style collapsible thinking blocks.
97
+ *
98
+ * For models that support extended thinking (Claude, DeepSeek-R1, o1),
99
+ * reasoning content is streamed via this event instead of turn.delta.
100
+ */
101
+ export interface TurnReasoningDeltaNotification {
102
+ turnId: string;
103
+ text: string;
104
+ }
105
+ /** Plan/strategy update — rendered as DeerFlow Plan component. */
106
+ export interface TurnPlanUpdateNotification {
107
+ turnId: string;
108
+ slug: string;
109
+ content: string;
110
+ item?: NotificationThreadItem;
111
+ }
112
+ /** Suggestion items — interactive quick-action buttons. */
113
+ export interface TurnSuggestionsNotification {
114
+ turnId: string;
115
+ items: Array<{
116
+ text: string;
117
+ icon?: string;
118
+ action?: string;
119
+ }>;
120
+ }
121
+ /** Sub-agent (fork, skill, dream) started execution. */
122
+ export interface TurnSubagentStartedNotification {
123
+ turnId: string;
124
+ subagentId: string;
125
+ agentType: string;
126
+ prompt?: string;
127
+ }
128
+ /** Sub-agent streaming text chunk. */
129
+ export interface TurnSubagentDeltaNotification {
130
+ agentType: string;
131
+ subagentId?: string;
132
+ text: string;
133
+ }
134
+ /** Sub-agent completed execution. */
135
+ export interface TurnSubagentEndedNotification {
136
+ turnId: string;
137
+ subagentId: string;
138
+ agentType: string;
139
+ ok: boolean;
140
+ /** Truncated result (max 2000 chars). */
141
+ outputPreview?: string;
142
+ error?: string;
143
+ }
144
+ export type MediaResultType = "image" | "tts" | "video";
145
+ /** Structured media generation result — enables media preview cards. */
146
+ export interface TurnMediaResultNotification {
147
+ turnId: string;
148
+ mediaType: MediaResultType;
149
+ /** Local file path or URL. */
150
+ url: string;
151
+ /** Model used for generation. */
152
+ model?: string;
153
+ /** Provider id. */
154
+ provider?: string;
155
+ /** Duration in seconds (for TTS/video). */
156
+ durationSeconds?: number;
157
+ /** Image dimensions. */
158
+ width?: number;
159
+ height?: number;
160
+ /** MIME type (e.g. "audio/mpeg", "image/png"). */
161
+ mimeType?: string;
162
+ /** Billing info. */
163
+ billingUnit?: string;
164
+ billingQuantity?: number;
165
+ }
166
+ /** Full todo list updated — enables DeerFlow-style todo panel sync. */
167
+ export interface TurnTodosUpdatedNotification {
168
+ turnId?: string;
169
+ items: TodoItem[];
170
+ summary: {
171
+ total: number;
172
+ completed: number;
173
+ inProgress: number;
174
+ notStarted: number;
175
+ };
176
+ }
177
+ /** Infrastructure task state change (bash, agent fork, dream). */
178
+ export interface TaskUpdatedNotification {
179
+ taskId: string;
180
+ type: string;
181
+ lifecycle: string;
182
+ label?: string;
183
+ }
184
+ /** Long-running command execution progress (shell, script). */
185
+ export interface TurnExecProgressNotification {
186
+ output: string;
187
+ elapsedTimeSeconds: number;
188
+ totalLines: number;
189
+ totalBytes: number;
190
+ }
191
+ export type ArtifactType = "code" | "file" | "image" | "document" | "diagram" | "table";
192
+ /** Structured artifact produced by the agent — enables Canvas-style rendering. */
193
+ export interface TurnArtifactNotification {
194
+ turnId: string;
195
+ artifactId: string;
196
+ type: ArtifactType;
197
+ title: string;
198
+ /** File path (for file/code artifacts). */
199
+ filePath?: string;
200
+ /** Language id (for code artifacts). */
201
+ language?: string;
202
+ /** Content body (may be truncated for large artifacts). */
203
+ content?: string;
204
+ /** MIME type. */
205
+ mimeType?: string;
206
+ }
207
+ /** Agent requests user approval before executing a restricted tool. */
208
+ export interface ToolApprovalRequestNotification {
209
+ approvalId: string;
210
+ callId: string;
211
+ toolName: string;
212
+ arguments: string;
213
+ message?: string;
214
+ suggestions?: string[];
215
+ }
216
+ /** Skill instruction directive. */
217
+ export interface TurnSkillInstructionNotification {
218
+ turnId: string;
219
+ instruction: unknown;
220
+ }
221
+ /** Memory content changed (local md or QMemory). */
222
+ export interface MemoryUpdatedNotification {
223
+ source: string;
224
+ /** Memory target (memory, user, etc.). */
225
+ target?: string;
226
+ /** Number of entries. */
227
+ entryCount?: number;
228
+ /** Human-readable summary of what changed. */
229
+ summary?: string;
230
+ }
231
+ /** Session metadata changed (title, model, etc.). */
232
+ export interface SessionInfoNotification {
233
+ sessionId: string;
234
+ title?: string;
235
+ model?: string;
236
+ provider?: string;
237
+ cwd?: string;
238
+ turnCount?: number;
239
+ }
240
+ /** Permission rule saved/updated. */
241
+ export interface PermissionRuleUpdatedNotification {
242
+ /** Tool name glob pattern. */
243
+ pattern: string;
244
+ /** New permission behavior (allow, deny, ask). */
245
+ behavior: string;
246
+ }
247
+ /** Team created, updated, or destroyed. */
248
+ export interface TeamUpdatedNotification {
249
+ teamName: string;
250
+ action: "created" | "destroyed" | "member_joined" | "member_left";
251
+ members?: Array<{
252
+ agentName: string;
253
+ role: string;
254
+ }>;
255
+ }
256
+ export interface PongNotification {
257
+ }
258
+ /** Real-time token usage update (emitted after each LLM call within a turn). */
259
+ export interface TurnUsageUpdateNotification {
260
+ turnId: string;
261
+ usage: TokenUsage;
262
+ model?: string;
263
+ /** Cumulative cost estimate for this session (USD). */
264
+ sessionCostUSD?: number;
265
+ }
266
+ export interface NotificationMethodMap {
267
+ "turn.start": TurnStartNotification;
268
+ "turn.delta": TurnDeltaNotification;
269
+ "turn.end": TurnEndNotification;
270
+ "turn.error": TurnErrorNotification;
271
+ "turn.recovery": TurnRecoveryNotification;
272
+ "turn.tool_call": TurnToolCallNotification;
273
+ "turn.tool_result": TurnToolResultNotification;
274
+ "turn.tool_blocked": TurnToolBlockedNotification;
275
+ "turn.reasoning_delta": TurnReasoningDeltaNotification;
276
+ "turn.plan_update": TurnPlanUpdateNotification;
277
+ "turn.suggestions": TurnSuggestionsNotification;
278
+ "turn.subagent_started": TurnSubagentStartedNotification;
279
+ "turn.subagent_delta": TurnSubagentDeltaNotification;
280
+ "turn.subagent_ended": TurnSubagentEndedNotification;
281
+ "turn.media_result": TurnMediaResultNotification;
282
+ "turn.todos_updated": TurnTodosUpdatedNotification;
283
+ "task.updated": TaskUpdatedNotification;
284
+ "turn.exec_progress": TurnExecProgressNotification;
285
+ "turn.artifact": TurnArtifactNotification;
286
+ "tool.approval.request": ToolApprovalRequestNotification;
287
+ "turn.skill_instruction": TurnSkillInstructionNotification;
288
+ "memory.updated": MemoryUpdatedNotification;
289
+ "session.info": SessionInfoNotification;
290
+ "permission.rule_updated": PermissionRuleUpdatedNotification;
291
+ "team.updated": TeamUpdatedNotification;
292
+ "turn.usage_update": TurnUsageUpdateNotification;
293
+ "pong": PongNotification;
294
+ }
295
+ /** All known notification method names. */
296
+ export type NotificationMethod = keyof NotificationMethodMap;
@@ -10,7 +10,7 @@
10
10
  *
11
11
  * Reference: claude-code src/services/autoDream/
12
12
  */
13
- import type { DreamTaskState, DreamTurn } from "../../orchestration/task-types.js";
13
+ import type { DreamTaskState, DreamTurn } from "../../orchestration/subagent/task-types.js";
14
14
  import type { ToolDefinition, ToolInvoker, AgentLogger, HookRegistry } from "../../agent/types.js";
15
15
  import type { LLMTransport } from "../../llm/transport.js";
16
16
  export interface DreamTriggerConfig {
@@ -77,10 +77,8 @@ export interface ForkedAgentParams {
77
77
  skipTranscript?: boolean;
78
78
  /** Token budget for this sub-agent. 0 or undefined = no limit. */
79
79
  budgetTokens?: number;
80
- /** Parent sidechain depth (propagated to child tool loop) */
80
+ /** Parent fork depth (propagated to child tool loop) */
81
81
  parentDepth?: number;
82
- /** Sidechain type for tool access policy (default "code-repair" = full) */
83
- sidechainType?: import("../../orchestration/index.js").SidechainType;
84
82
  }
85
83
  /**
86
84
  * Result of a forked agent run.
@@ -6,7 +6,7 @@ import type { LLMTransport } from "../../llm/transport.js";
6
6
  export declare function estimateTokens(msg: CompressibleMessage): number;
7
7
  /** Estimate total tokens for a message array. */
8
8
  export declare function estimateTotalTokens(messages: CompressibleMessage[]): number;
9
- export declare function getCompressionMetrics(): import("../../orchestration/context-compression.js").CompressionMetricsSnapshot;
9
+ export declare function getCompressionMetrics(): import("../../orchestration/index.js").CompressionMetricsSnapshot;
10
10
  export declare function getContextEngineRegistry(): ContextEngineRegistry;
11
11
  /**
12
12
  * Create a summarization callback using an injected LLM transport.
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Agent Paths — Centralized dot-directory name and path helpers.
3
+ *
4
+ * All filesystem paths under `~/.qlogicagent/` (user-level) or
5
+ * `<project>/.qlogicagent/` (project-level) must go through these
6
+ * helpers so the dot-dir name is defined in exactly one place.
7
+ */
8
+ /** Dot-directory name used for both user-level and project-level storage. */
9
+ export declare const AGENT_DOT_DIR = ".qlogicagent";
10
+ /** `~/.qlogicagent/` */
11
+ export declare function getUserAgentHome(): string;
12
+ /** `~/.qlogicagent/sessions/` */
13
+ export declare function getUserSessionsRoot(): string;
14
+ /** `~/.qlogicagent/sessions/{sessionId}` */
15
+ export declare function getUserSessionDir(sessionId: string): string;
16
+ /** `~/.qlogicagent/.credentials.json` */
17
+ export declare function getUserCredentialsPath(): string;
18
+ /** `~/.qlogicagent/plugins/` */
19
+ export declare function getUserPluginsDir(): string;
20
+ /** `~/.qlogicagent/skills/` */
21
+ export declare function getUserSkillsDir(): string;
22
+ /** `~/.qlogicagent/settings.json` */
23
+ export declare function getUserSettingsPath(): string;
24
+ /** `~/.qlogicagent/cache/` */
25
+ export declare function getUserCacheDir(): string;
26
+ /** `~/.qlogicagent/debug-logs/` */
27
+ export declare function getUserDebugLogsDir(): string;
28
+ /** `~/.qlogicagent/checkpoints/` or `~/.qlogicagent/checkpoints/{sessionId}` */
29
+ export declare function getUserCheckpointsDir(sessionId?: string): string;
30
+ /** `~/.qlogicagent/plugin-cache/` */
31
+ export declare function getUserPluginCacheDir(): string;
32
+ /** `~/.qlogicagent/mcp.json` */
33
+ export declare function getUserMcpConfigPath(): string;
34
+ /** `~/.qlogicagent/marketplace.json` */
35
+ export declare function getUserMarketplaceConfigPath(): string;
36
+ /** `~/.qlogicagent/workflows/` */
37
+ export declare function getUserWorkflowsDir(): string;
38
+ /** `~/.qlogicagent/INSTRUCTIONS.md` */
39
+ export declare function getUserInstructionsPath(): string;
40
+ /** `~/.qlogicagent/rules/` */
41
+ export declare function getUserRulesDir(): string;
42
+ /** `<cwd>/.qlogicagent/` */
43
+ export declare function getProjectAgentDir(cwd?: string): string;
44
+ /** `<cwd>/.qlogicagent/workflows/` */
45
+ export declare function getProjectWorkflowsDir(cwd?: string): string;
46
+ /** `<cwd>/.qlogicagent/plugins/` */
47
+ export declare function getProjectPluginsDir(cwd?: string): string;
48
+ /** `<cwd>/.qlogicagent/skills/` */
49
+ export declare function getProjectSkillsDir(cwd?: string): string;
50
+ /** `<cwd>/.qlogicagent/settings.json` */
51
+ export declare function getProjectSettingsPath(cwd?: string): string;
52
+ /** `<cwd>/.qlogicagent/INSTRUCTIONS.md` */
53
+ export declare function getProjectInstructionsPath(cwd?: string): string;
54
+ /** `<cwd>/.qlogicagent/rules/` */
55
+ export declare function getProjectRulesDir(cwd?: string): string;
56
+ /** `<gitRoot>/.qlogicagent/hooks/` */
57
+ export declare function getGitRootHooksDir(gitRoot: string): string;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Local Checkpoint Backend — git-based shadow repo implementation.
3
+ *
4
+ * Creates and manages checkpoint snapshots in `~/.qlogicagent/checkpoints/<sessionId>/`
5
+ * using a shadow git repository independent of the user's project .git.
6
+ */
7
+ import type { CheckpointToolDeps } from "../../skills/tools/checkpoint-tool.js";
8
+ export declare function createLocalCheckpointBackend(projectRoot: string, sessionId: string): CheckpointToolDeps;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Disk Storage Manager — unified atomic file I/O for agent self-managed storage.
3
+ *
4
+ * Provides:
5
+ * - Atomic write (tmp + rename) with dir auto-creation
6
+ * - JSON read/write helpers
7
+ * - MemoryStore disk persistence (auto-save on mutation)
8
+ */
9
+ /**
10
+ * Write data atomically: write to a temp file in the same directory,
11
+ * then rename over the target. This prevents partial/corrupted reads.
12
+ */
13
+ export declare function atomicWriteFile(filePath: string, data: string | Buffer): Promise<void>;
14
+ /**
15
+ * Read a JSON file. Returns `undefined` if the file does not exist.
16
+ */
17
+ export declare function readJsonFile<T = unknown>(filePath: string): Promise<T | undefined>;
18
+ /**
19
+ * Write a JSON file atomically.
20
+ */
21
+ export declare function writeJsonFile(filePath: string, data: unknown): Promise<void>;
22
+ /** Path to user-level memory file: `~/.qlogicagent/memory.json` */
23
+ export declare function getMemoryFilePath(): string;
24
+ export interface PersistedMemory {
25
+ memory: string;
26
+ user: string;
27
+ /** ISO 8601 timestamp of last save. */
28
+ savedAt: string;
29
+ }
30
+ /** Load persisted memory from disk. Returns undefined if no file exists. */
31
+ export declare function loadPersistedMemory(): Promise<PersistedMemory | undefined>;
32
+ /** Save memory to disk atomically. */
33
+ export declare function savePersistedMemory(data: {
34
+ memory: string;
35
+ user: string;
36
+ }): Promise<void>;
@@ -10,8 +10,8 @@
10
10
  * this is a lightweight change-awareness system.
11
11
  *
12
12
  * Watched paths:
13
- * - .openclaw/settings.json → permission hot-reload
14
- * - INSTRUCTIONS.md / .openclaw/INSTRUCTIONS.md → instruction re-load
13
+ * - .qlogicagent/settings.json → permission hot-reload
14
+ * - INSTRUCTIONS.md / .qlogicagent/INSTRUCTIONS.md → instruction re-load
15
15
  * - configurable additional patterns
16
16
  *
17
17
  * Reference: claude-code file-watcher usage throughout lifecycle
@@ -1,6 +1,8 @@
1
+ export { AGENT_DOT_DIR, getUserAgentHome, getUserSessionDir, getUserCredentialsPath, getUserPluginsDir, getUserSkillsDir, getUserSettingsPath, getUserCacheDir, getUserDebugLogsDir, getUserCheckpointsDir, getUserPluginCacheDir, getUserMcpConfigPath, getUserMarketplaceConfigPath, getUserWorkflowsDir, getUserInstructionsPath, getProjectAgentDir, getProjectWorkflowsDir, getProjectPluginsDir, getProjectSkillsDir, getProjectSettingsPath, getProjectInstructionsPath, getProjectRulesDir, getGitRootHooksDir, } from "./agent-paths.js";
1
2
  export { getBudgetContinuationMessage } from "./token-budget.js";
2
3
  export { type SecureStorage, saveApiKey, loadApiKey } from "./secure-storage.js";
3
4
  export { createFileWatcher, FileWatcher } from "./file-watcher.js";
4
5
  export { TaskStore } from "./task-runtime.js";
5
6
  export { createWorktreeBackend } from "./worktree-backend.js";
6
7
  export { registerCleanup, runCleanupFunctions } from "./cleanup-registry.js";
8
+ export { atomicWriteFile, readJsonFile, writeJsonFile, loadPersistedMemory, savePersistedMemory, getMemoryFilePath, type PersistedMemory, } from "./disk-storage.js";
@@ -7,7 +7,7 @@
7
7
  * - macOS Keychain / Windows Credential Manager can be added as plugins
8
8
  *
9
9
  * Storage layout:
10
- * ~/.openclaw/.credentials.json — API keys, OAuth tokens
10
+ * ~/.qlogicagent/.credentials.json — API keys, OAuth tokens
11
11
  *
12
12
  * Reference: claude-code-haha/src/utils/secureStorage/
13
13
  */
@@ -9,7 +9,7 @@
9
9
  * Architecture note: CC uses React-style setAppState(prev => next). We use
10
10
  * a simple Map-based store since we're in a subprocess (no React).
11
11
  */
12
- import type { TaskState, TaskType, TaskLifecycle, PermissionRole, IsolationMode, LocalAgentTaskState, LocalBashTaskState } from "../../orchestration/task-types.js";
12
+ import type { TaskState, TaskType, TaskLifecycle, PermissionRole, IsolationMode, LocalAgentTaskState, LocalBashTaskState } from "../../orchestration/subagent/task-types.js";
13
13
  import type { HookRegistry } from "../../contracts/hooks.js";
14
14
  /** Polling interval for running tasks (ms) */
15
15
  export declare const POLL_INTERVAL_MS = 1000;
@@ -20,4 +20,4 @@ export type ShellType = "bash" | "powershell" | "zsh" | "cmd" | "fish" | "unknow
20
20
  * Create a system prompt section that provides environment context.
21
21
  * Memoized — computed once per session (environment doesn't change mid-session).
22
22
  */
23
- export declare function createEnvironmentContextSection(): SystemPromptSection;
23
+ export declare function createEnvironmentContextSection(cwdOverride?: string): SystemPromptSection;
@@ -2,9 +2,9 @@
2
2
  * Instruction Loader — CC claudemd.ts parity (adapted for qlogicagent).
3
3
  *
4
4
  * Discovers and loads instruction files following CC's load order:
5
- * 1. User instructions (~/.openclaw/INSTRUCTIONS.md)
6
- * 2. Project instructions (INSTRUCTIONS.md, .openclaw/INSTRUCTIONS.md,
7
- * .openclaw/rules/*.md — walkup from cwd to git root)
5
+ * 1. User instructions (~/.qlogicagent/INSTRUCTIONS.md)
6
+ * 2. Project instructions (INSTRUCTIONS.md, .qlogicagent/INSTRUCTIONS.md,
7
+ * .qlogicagent/rules/*.md — walkup from cwd to git root)
8
8
  * 3. Local instructions (INSTRUCTIONS.local.md — private, not checked in)
9
9
  *
10
10
  * Features ported from CC:
@@ -33,11 +33,11 @@ export interface InstructionFileInfo {
33
33
  * Load all instruction files following CC's discovery order.
34
34
  *
35
35
  * Discovery order (priority: last loaded = highest):
36
- * 1. User: ~/.openclaw/INSTRUCTIONS.md, ~/.openclaw/rules/*.md
36
+ * 1. User: ~/.qlogicagent/INSTRUCTIONS.md, ~/.qlogicagent/rules/*.md
37
37
  * 2. Project: Walk from git root → cwd, each dir:
38
38
  * - INSTRUCTIONS.md
39
- * - .openclaw/INSTRUCTIONS.md
40
- * - .openclaw/rules/*.md (unconditional)
39
+ * - .qlogicagent/INSTRUCTIONS.md
40
+ * - .qlogicagent/rules/*.md (unconditional)
41
41
  * 3. Local: INSTRUCTIONS.local.md (per dir, walkup)
42
42
  *
43
43
  * @param cwd - Starting directory for walkup discovery
@@ -1,2 +1,2 @@
1
- export { SessionState, type SessionCostSnapshot } from "./session-state.js";
1
+ export { SessionState, type SessionUsageSnapshot, type SessionCostSnapshot } from "./session-state.js";
2
2
  export { appendMessage, saveSessionState, loadSessionForResume, listSessions, deleteSession, pruneOldSessions, shouldGenerateTaskSummary, maybeGenerateTaskSummary, type SessionMetadata, type PersistedSession, type SessionListEntry, type TaskSummaryDeps, } from "./session-persistence.js";
@@ -44,7 +44,6 @@ export type ForkedAgentRunner = (params: {
44
44
  log: AgentLogger;
45
45
  hooks?: HookRegistry;
46
46
  forkLabel: string;
47
- sidechainType?: "planner" | "research" | "plan-repair" | "code-repair" | "media-prep";
48
47
  maxTurns?: number;
49
48
  parentSignal?: AbortSignal;
50
49
  skipTranscript?: boolean;
@@ -7,7 +7,7 @@
7
7
  * 3. Session metadata (model, cwd, agent mode)
8
8
  *
9
9
  * Storage layout:
10
- * ~/.openclaw/sessions/<session-id>/
10
+ * ~/.qlogicagent/sessions/<session-id>/
11
11
  * transcript.jsonl — append-only message log
12
12
  * state.json — cost snapshot + metadata
13
13
  *
@@ -21,18 +21,24 @@ export interface ModelUsage {
21
21
  outputTokens: number;
22
22
  cacheRead: number;
23
23
  cacheCreation: number;
24
- costUSD: number;
24
+ /** Media generation call count (image/video/music/tts/3d) */
25
+ mediaCalls: number;
26
+ /** Total seconds of media output (video, music) */
27
+ mediaDurationSeconds: number;
28
+ /** Total characters processed (TTS) */
29
+ mediaCharacters: number;
25
30
  }
26
31
  /** Snapshot of the session state for persistence / restore */
27
- export interface SessionCostSnapshot {
32
+ export interface SessionUsageSnapshot {
28
33
  sessionId: string;
29
- totalCostUSD: number;
30
34
  modelUsage: Record<string, ModelUsage>;
31
35
  totalInputTokens: number;
32
36
  totalOutputTokens: number;
33
37
  turnCount: number;
34
38
  lastSavedAt: number;
35
39
  }
40
+ /** @deprecated Use SessionUsageSnapshot. Kept for persistence compat. */
41
+ export type SessionCostSnapshot = SessionUsageSnapshot;
36
42
  /** Thresholds for background memory extraction — CC sessionMemory.ts parity */
37
43
  export interface MemoryExtractionThresholds {
38
44
  /** Token threshold before FIRST extraction (default 10000) */
@@ -45,7 +51,6 @@ export interface MemoryExtractionThresholds {
45
51
  export declare class SessionState {
46
52
  readonly sessionId: string;
47
53
  private _trustAccepted;
48
- private _totalCostUSD;
49
54
  private _modelUsage;
50
55
  private _totalInputTokens;
51
56
  private _totalOutputTokens;
@@ -60,7 +65,6 @@ export declare class SessionState {
60
65
  constructor(sessionId: string, thresholds?: Partial<MemoryExtractionThresholds>);
61
66
  get trustAccepted(): boolean;
62
67
  setTrustAccepted(accepted: boolean): void;
63
- get totalCostUSD(): number;
64
68
  get totalInputTokens(): number;
65
69
  get totalOutputTokens(): number;
66
70
  get turnCount(): number;
@@ -71,12 +75,17 @@ export declare class SessionState {
71
75
  getAllModelUsage(): Record<string, ModelUsage>;
72
76
  /**
73
77
  * Add usage from an API response — CC addToTotalSessionCost() parity.
78
+ * Tracks token counts only; pricing is handled by Hub/Admin.
74
79
  *
75
80
  * @param usage - Token counts from the API response
76
81
  * @param model - Model identifier
77
- * @param costUSD - Calculated cost (caller computes based on pricing)
78
82
  */
79
- addUsage(usage: TokenUsage, model: string, costUSD?: number): void;
83
+ addUsage(usage: TokenUsage, model: string): void;
84
+ /**
85
+ * Add usage from a media generation call (non-token billing).
86
+ * Tracks quantities only (calls, seconds, characters); pricing is Hub/Admin's job.
87
+ */
88
+ addMediaUsage(model: string, billingUnit: string, quantity: number): void;
80
89
  /** Record a tool call (for extraction threshold tracking) */
81
90
  recordToolCall(): void;
82
91
  /** Increment turn count */
@@ -98,7 +107,7 @@ export declare class SessionState {
98
107
  * Create a snapshot for persistence.
99
108
  * CC saveCurrentSessionCosts() parity.
100
109
  */
101
- createSnapshot(): SessionCostSnapshot;
110
+ createSnapshot(): SessionUsageSnapshot;
102
111
  /**
103
112
  * Restore from a previous snapshot.
104
113
  * CC setCostStateForRestore() parity.
@@ -106,7 +115,7 @@ export declare class SessionState {
106
115
  * GUARD: Only restores if the snapshot's sessionId matches this session.
107
116
  * Prevents cross-session cost leakage (CC's lastSessionId guard).
108
117
  */
109
- restoreFromSnapshot(snapshot: SessionCostSnapshot): boolean;
118
+ restoreFromSnapshot(snapshot: SessionUsageSnapshot): boolean;
110
119
  /** Register a state change listener. Returns unsubscribe function. */
111
120
  onStateChange(listener: () => void): () => void;
112
121
  private notifyListeners;