qlogicagent 2.6.1 → 2.9.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 (137) hide show
  1. package/dist/agent.js +19 -17
  2. package/dist/cli.js +634 -367
  3. package/dist/index.js +631 -364
  4. package/dist/orchestration.js +15 -15
  5. package/dist/protocol.js +1 -1
  6. package/dist/types/agent/agent.d.ts +4 -1
  7. package/dist/types/agent/tool-loop.d.ts +3 -1
  8. package/dist/types/agent/tunable-defaults.d.ts +22 -1
  9. package/dist/types/agent/types.d.ts +7 -9
  10. package/dist/types/cli/handlers/agents-handler.d.ts +19 -0
  11. package/dist/types/cli/handlers/config-handler.d.ts +17 -0
  12. package/dist/types/cli/handlers/dream-handler.d.ts +5 -0
  13. package/dist/types/cli/handlers/files-handler.d.ts +15 -0
  14. package/dist/types/cli/handlers/media-handler.d.ts +13 -0
  15. package/dist/types/cli/handlers/memory-handler.d.ts +11 -0
  16. package/dist/types/cli/handlers/pet-handler.d.ts +21 -0
  17. package/dist/types/cli/handlers/product-handler.d.ts +32 -0
  18. package/dist/types/cli/handlers/project-handler.d.ts +19 -0
  19. package/dist/types/cli/handlers/session-handler.d.ts +38 -0
  20. package/dist/types/cli/handlers/settings-handler.d.ts +24 -0
  21. package/dist/types/cli/handlers/skills-handler.d.ts +20 -0
  22. package/dist/types/cli/handlers/solo-handler.d.ts +15 -0
  23. package/dist/types/cli/handlers/turn-handler.d.ts +17 -0
  24. package/dist/types/cli/main.d.ts +2 -2
  25. package/dist/types/cli/stdio-server.d.ts +94 -100
  26. package/dist/types/cli/tool-bootstrap.d.ts +7 -8
  27. package/dist/types/config/config.d.ts +1 -1
  28. package/dist/types/index.d.ts +2 -2
  29. package/dist/types/llm/index.d.ts +1 -31
  30. package/dist/types/orchestration/dag-scheduler.d.ts +46 -0
  31. package/dist/types/orchestration/index.d.ts +1 -1
  32. package/dist/types/orchestration/product-planner.d.ts +146 -0
  33. package/dist/types/orchestration/skill-improvement.d.ts +39 -0
  34. package/dist/types/orchestration/solo-evaluator.d.ts +26 -6
  35. package/dist/types/orchestration/solo-persistence.d.ts +5 -0
  36. package/dist/types/orchestration/tool-cascade.d.ts +2 -2
  37. package/dist/types/protocol/methods.d.ts +189 -6
  38. package/dist/types/protocol/notifications.d.ts +1 -1
  39. package/dist/types/protocol/wire/acp-protocol.d.ts +7 -0
  40. package/dist/types/protocol/wire/agent-events.d.ts +2 -2
  41. package/dist/types/protocol/wire/agent-methods.d.ts +6 -4
  42. package/dist/types/protocol/wire/gateway-rpc.d.ts +77 -4
  43. package/dist/types/protocol/wire/index.d.ts +1 -1
  44. package/dist/types/protocol/wire/memory-provider-lifecycle.d.ts +3 -1
  45. package/dist/types/protocol/wire/notification-payloads.d.ts +124 -4
  46. package/dist/types/runtime/execution/dream-agent.d.ts +33 -6
  47. package/dist/types/runtime/execution/forked-agent.d.ts +1 -1
  48. package/dist/types/runtime/execution/memory-decay.d.ts +17 -5
  49. package/dist/types/runtime/hooks/context-compression.d.ts +1 -1
  50. package/dist/types/runtime/hooks/memory-hooks.d.ts +10 -1
  51. package/dist/types/runtime/infra/acp-types.d.ts +92 -0
  52. package/dist/types/runtime/infra/agent-paths.d.ts +22 -25
  53. package/dist/types/runtime/infra/agent-process.d.ts +1 -1
  54. package/dist/types/runtime/infra/builtin-providers.d.ts +36 -0
  55. package/dist/types/runtime/infra/checkpoint-backend.d.ts +1 -1
  56. package/dist/types/runtime/infra/index.d.ts +1 -2
  57. package/dist/types/runtime/infra/key-pool.d.ts +120 -0
  58. package/dist/types/runtime/infra/media-persistence.d.ts +26 -15
  59. package/dist/types/runtime/infra/model-registry.d.ts +187 -0
  60. package/dist/types/runtime/infra/project-instructions-store.d.ts +3 -3
  61. package/dist/types/runtime/infra/project-store.d.ts +3 -0
  62. package/dist/types/runtime/infra/token-budget.d.ts +2 -2
  63. package/dist/types/runtime/infra/worktree-backend.d.ts +1 -1
  64. package/dist/types/runtime/pet/index.d.ts +8 -0
  65. package/dist/types/runtime/pet/pet-context-injection.d.ts +8 -0
  66. package/dist/types/runtime/pet/pet-file-loader.d.ts +62 -0
  67. package/dist/types/runtime/pet/pet-growth-engine.d.ts +60 -0
  68. package/dist/types/runtime/pet/pet-reaction-service.d.ts +33 -0
  69. package/dist/types/runtime/pet/pet-soul-service.d.ts +71 -0
  70. package/dist/types/runtime/prompt/environment-context.d.ts +10 -0
  71. package/dist/types/runtime/prompt/index.d.ts +1 -1
  72. package/dist/types/runtime/session/group-session-split.d.ts +38 -0
  73. package/dist/types/runtime/session/index.d.ts +4 -2
  74. package/dist/types/runtime/session/session-locator.d.ts +24 -0
  75. package/dist/types/runtime/session/session-memory.d.ts +4 -4
  76. package/dist/types/runtime/session/session-persistence.d.ts +47 -46
  77. package/dist/types/runtime/session/session-state.d.ts +3 -5
  78. package/dist/types/skills/index.d.ts +8 -2
  79. package/dist/types/skills/memory/implicit-extraction.d.ts +58 -0
  80. package/dist/types/skills/memory/local-embedding.d.ts +176 -0
  81. package/dist/types/skills/memory/local-memory-provider.d.ts +197 -0
  82. package/dist/types/skills/memory/local-store.d.ts +255 -0
  83. package/dist/types/skills/memory/memdir.d.ts +13 -5
  84. package/dist/types/skills/memory/memory-provider-factory.d.ts +48 -0
  85. package/dist/types/skills/memory/memory-tool.d.ts +30 -2
  86. package/dist/types/skills/permissions/denial-audit-log.d.ts +52 -0
  87. package/dist/types/skills/permissions/hook-runner.d.ts +14 -4
  88. package/dist/types/skills/permissions/permission-classifier.d.ts +1 -1
  89. package/dist/types/skills/skill-system/skill-lifecycle.d.ts +81 -0
  90. package/dist/types/skills/skill-system/skill-validation.d.ts +29 -0
  91. package/dist/types/skills/tools/exec-tool.d.ts +1 -1
  92. package/dist/types/skills/tools/search-tool.d.ts +1 -1
  93. package/dist/types/skills/tools.d.ts +3 -3
  94. package/dist/types/transport/acp-event-emitter.d.ts +1 -1
  95. package/dist/types/transport/acp-server.d.ts +7 -2
  96. package/package.json +19 -5
  97. package/dist/types/llm/adapters/aliyun-oss-file-upload-adapter.d.ts +0 -44
  98. package/dist/types/llm/adapters/gemini-file-upload-adapter.d.ts +0 -26
  99. package/dist/types/llm/adapters/hub-oss-file-upload-adapter.d.ts +0 -29
  100. package/dist/types/llm/adapters/index.d.ts +0 -10
  101. package/dist/types/llm/adapters/openai-file-upload-adapter.d.ts +0 -38
  102. package/dist/types/llm/adapters/volcengine-file-upload-adapter.d.ts +0 -24
  103. package/dist/types/llm/builtin-providers.d.ts +0 -10
  104. package/dist/types/llm/debug-transport.d.ts +0 -12
  105. package/dist/types/llm/file-upload-service.d.ts +0 -68
  106. package/dist/types/llm/gemini-schema-utils.d.ts +0 -17
  107. package/dist/types/llm/llm-client.d.ts +0 -43
  108. package/dist/types/llm/media-client.d.ts +0 -42
  109. package/dist/types/llm/media-transport.d.ts +0 -176
  110. package/dist/types/llm/model-catalog.d.ts +0 -53
  111. package/dist/types/llm/model-detection.d.ts +0 -22
  112. package/dist/types/llm/provider-def.d.ts +0 -203
  113. package/dist/types/llm/provider-registry.d.ts +0 -59
  114. package/dist/types/llm/provider-tool-api.d.ts +0 -44
  115. package/dist/types/llm/retry.d.ts +0 -37
  116. package/dist/types/llm/transport.d.ts +0 -281
  117. package/dist/types/llm/transports/anthropic-messages.d.ts +0 -65
  118. package/dist/types/llm/transports/gemini-cache-api.d.ts +0 -86
  119. package/dist/types/llm/transports/gemini-file-api.d.ts +0 -90
  120. package/dist/types/llm/transports/gemini-generatecontent.d.ts +0 -56
  121. package/dist/types/llm/transports/gemini-lyria-realtime.d.ts +0 -117
  122. package/dist/types/llm/transports/gemini-media.d.ts +0 -53
  123. package/dist/types/llm/transports/media-resolve.d.ts +0 -50
  124. package/dist/types/llm/transports/minimax-media.d.ts +0 -55
  125. package/dist/types/llm/transports/openai-chat.d.ts +0 -81
  126. package/dist/types/llm/transports/openai-media.d.ts +0 -24
  127. package/dist/types/llm/transports/openai-responses.d.ts +0 -63
  128. package/dist/types/llm/transports/qwen-media.d.ts +0 -50
  129. package/dist/types/llm/transports/realtime-transport.d.ts +0 -183
  130. package/dist/types/llm/transports/volcengine-grounding.d.ts +0 -58
  131. package/dist/types/llm/transports/volcengine-media.d.ts +0 -93
  132. package/dist/types/llm/transports/volcengine-responses.d.ts +0 -64
  133. package/dist/types/llm/transports/zhipu-media.d.ts +0 -82
  134. package/dist/types/llm/transports/zhipu-tool-api.d.ts +0 -35
  135. package/dist/types/runtime/infra/project-plan-store.d.ts +0 -27
  136. package/dist/types/skills/memory/qmemory-adapter.d.ts +0 -55
  137. package/dist/types/skills/memory/qmemory-http-client.d.ts +0 -16
@@ -0,0 +1,71 @@
1
+ /**
2
+ * PetSoulService — manages pet identity (hatching, persistence, stats).
3
+ *
4
+ * Hatching: deterministic identity via hash(userId) + LLM-generated soul.
5
+ * Persistence: stored in project workspace under .qlogicagent/pet/soul.json
6
+ */
7
+ export interface PetStats {
8
+ grip: number;
9
+ patience: number;
10
+ curiosity: number;
11
+ appetite: number;
12
+ humor: number;
13
+ }
14
+ export interface PetSoul {
15
+ name: string;
16
+ species: string;
17
+ personality: string;
18
+ catchphrase: string;
19
+ stats: PetStats;
20
+ rarity: string;
21
+ breed?: string;
22
+ breedColors?: {
23
+ primary: string;
24
+ secondary: string;
25
+ };
26
+ level: number;
27
+ experience: number;
28
+ hatchedAt: string;
29
+ }
30
+ /** Breed system (design §6.2): 7 breeds with deterministic hash selection. */
31
+ export interface PetBreed {
32
+ name: string;
33
+ colors: {
34
+ primary: string;
35
+ secondary: string;
36
+ };
37
+ rarity: string;
38
+ }
39
+ export declare class PetSoulService {
40
+ private workspaceDir;
41
+ private soul;
42
+ private storagePath;
43
+ constructor(workspaceDir: string);
44
+ /**
45
+ * Load existing soul from disk. Returns null if not hatched.
46
+ */
47
+ load(): PetSoul | null;
48
+ /**
49
+ * Hatch a new pet soul. Uses LLM for name/personality/catchphrase.
50
+ * If generateSoul is provided, uses it; otherwise falls back to defaults.
51
+ */
52
+ hatch(userId: string, generateSoul?: (rarity: string, stats: PetStats) => Promise<{
53
+ name: string;
54
+ personality: string;
55
+ catchphrase: string;
56
+ }>): Promise<PetSoul>;
57
+ /**
58
+ * Add experience points. Returns true if leveled up.
59
+ */
60
+ addExperience(xp: number): {
61
+ leveledUp: boolean;
62
+ level: number;
63
+ experience: number;
64
+ };
65
+ getSoul(): PetSoul | null;
66
+ /**
67
+ * Update soul (e.g., after growth/stat changes) and persist.
68
+ */
69
+ updateSoul(soul: PetSoul): void;
70
+ private persist;
71
+ }
@@ -35,3 +35,13 @@ export declare function createTaskGuidanceSection(domain?: TaskDomain): SystemPr
35
35
  * Tells the LLM when to use specialized tools vs. primitives.
36
36
  */
37
37
  export declare function createToolGuidanceSection(): SystemPromptSection;
38
+ /**
39
+ * Create a system prompt section that instructs the model on response language.
40
+ * CC parity: only injected when language is explicitly set; when absent,
41
+ * the model follows the user's message language naturally.
42
+ *
43
+ * Key rule: always respond in the SAME language as the user's current message.
44
+ * This prevents confusion when system prompt contains mixed-language content
45
+ * (e.g., Chinese INDEX.md + English tool guidance).
46
+ */
47
+ export declare function createLanguageSection(language?: string): SystemPromptSection;
@@ -1,4 +1,4 @@
1
1
  export { assembleSystemPrompt, clearSystemPromptSections, systemPromptSection, type SystemPromptSection, } from "./system-prompt-sections.js";
2
2
  export { getInstructions, buildInstructionsPrompt, resetInstructionCache, } from "./instruction-loader.js";
3
- export { createEnvironmentContextSection, createTaskGuidanceSection, createToolGuidanceSection } from "./environment-context.js";
3
+ export { createEnvironmentContextSection, createTaskGuidanceSection, createToolGuidanceSection, createLanguageSection } from "./environment-context.js";
4
4
  export { detectTaskDomain, resolveTaskDomain, loadProjectTaskDomain, persistTaskDomain, shouldPersistDomain, type TaskDomain, type DomainResolutionContext } from "./task-domain.js";
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Group Session Auto-Split — detects idle group sessions and creates successor sessions.
3
+ *
4
+ * When a group chat message arrives and the last session activity was > N hours ago,
5
+ * the old session is sealed and a new session is created with:
6
+ * - previousSessionId linking to the predecessor
7
+ * - carryoverSummary (from predecessor's taskSummary or last messages)
8
+ * - Same groupKey, groupName, groupPlatform, projectId
9
+ *
10
+ * This prevents unbounded context growth in long-lived group chats.
11
+ */
12
+ import { type SessionMetadata } from "./session-persistence.js";
13
+ export interface GroupSplitResult {
14
+ /** Whether a split occurred */
15
+ split: boolean;
16
+ /** The session ID to use for the current turn (new or existing) */
17
+ activeSessionId: string;
18
+ /** If split, the sealed predecessor session ID */
19
+ sealedSessionId?: string;
20
+ }
21
+ /**
22
+ * Check whether a group session should be auto-split due to idle timeout.
23
+ * If yes, seal the old session and create a new successor.
24
+ *
25
+ * @param currentSession - The existing group session metadata
26
+ * @param projectRoot - The project workspace directory
27
+ * @returns Split result with the session ID to use
28
+ */
29
+ export declare function maybeAutoSplitGroupSession(currentSession: SessionMetadata, projectRoot: string): Promise<GroupSplitResult>;
30
+ /**
31
+ * Check whether a group session has exceeded MAX_TURNS hard limit.
32
+ * Called AFTER turn.end — soft-splits without interrupting the current turn.
33
+ *
34
+ * @param currentSession - The session that just finished a turn
35
+ * @param projectRoot - The project workspace directory
36
+ * @returns Split result (new session ready for next message, or no-op)
37
+ */
38
+ export declare function maybeHardLimitSplit(currentSession: SessionMetadata, projectRoot: string): Promise<GroupSplitResult>;
@@ -1,2 +1,4 @@
1
- export { SessionState, type SessionUsageSnapshot, type SessionCostSnapshot } from "./session-state.js";
2
- export { appendMessage, saveSessionState, updateSessionMetadata, loadSessionForResume, listSessions, deleteSession, pruneOldSessions, shouldGenerateTaskSummary, maybeGenerateTaskSummary, type SessionMetadata, type PersistedSession, type SessionListEntry, type TaskSummaryDeps, } from "./session-persistence.js";
1
+ export { SessionState, type SessionUsageSnapshot } from "./session-state.js";
2
+ export { SessionLocator } from "./session-locator.js";
3
+ export { appendMessage, saveSessionState, updateSessionMetadata, getSessionMetadata, loadSessionForResume, listSessions, deleteSession, pruneOldSessions, shouldGenerateTaskSummary, maybeGenerateTaskSummary, type SessionMetadata, type PersistedSession, type SessionListEntry, type TaskSummaryDeps, } from "./session-persistence.js";
4
+ export { maybeAutoSplitGroupSession, type GroupSplitResult } from "./group-session-split.js";
@@ -0,0 +1,24 @@
1
+ /**
2
+ * SessionLocator — resolves session storage paths from projectId.
3
+ *
4
+ * Every session operation uses this locator to determine the correct
5
+ * filesystem path based on the session's owning projectId.
6
+ * When projectId is missing, falls back to scanning all projects.
7
+ */
8
+ export declare class SessionLocator {
9
+ /** Get sessions root directory for a given projectId. */
10
+ getSessionsRoot(projectId: string): string;
11
+ /** Get the workspace dir for a project. */
12
+ getProjectWorkspaceDir(projectId: string): string;
13
+ /** Get the session directory path for a given projectId + sessionId. */
14
+ getSessionDir(projectId: string, sessionId: string): string;
15
+ /**
16
+ * Resolve the workspaceDir for a session given its projectId.
17
+ * If projectId is not provided, scans all projects for the session directory.
18
+ */
19
+ resolveWorkspaceDir(sessionId: string, projectId?: string): string;
20
+ /** Get the active project's workspace dir (for new session creation when no projectId specified). */
21
+ getActiveProjectWorkspaceDir(): string;
22
+ /** Get the active project's ID. */
23
+ getActiveProjectId(): string;
24
+ }
@@ -1,9 +1,9 @@
1
1
  /**
2
- * SessionMemory 鈥?In-memory session message store with JSONL persistence.
2
+ * SessionMemoryIn-memory session message store with JSONL persistence.
3
3
  *
4
4
  * CC alignment: messages live in memory during the session lifetime.
5
5
  * JSONL is the sole persistent source of truth (for crash recovery).
6
- * Gateway never owns message data 鈥?Agent is the single authority.
6
+ * Gateway never owns message dataAgent is the single authority.
7
7
  *
8
8
  * Design:
9
9
  * - Map<sessionId, ChatMessage[]> holds active session messages
@@ -15,7 +15,7 @@ import type { ChatMessage } from "../../protocol/wire/index.js";
15
15
  export declare class SessionMemory {
16
16
  private sessions;
17
17
  private projectRoot;
18
- constructor(projectRoot?: string);
18
+ constructor(projectRoot: string);
19
19
  setProjectRoot(projectRoot: string): void;
20
20
  /**
21
21
  * Get messages for a session. Lazy-loads from JSONL on first access.
@@ -35,7 +35,7 @@ export declare class SessionMemory {
35
35
  initSession(sessionId: string): void;
36
36
  /**
37
37
  * Drop a session from memory (e.g., on session.ended).
38
- * Does NOT delete JSONL 鈥?data persists for future resume.
38
+ * Does NOT delete JSONLdata persists for future resume.
39
39
  */
40
40
  evictSession(sessionId: string): void;
41
41
  /**
@@ -1,113 +1,113 @@
1
1
  /**
2
- * Session Persistence 鈥?CC sessionRestore.ts + conversationRecovery.ts parity.
2
+ * Session Persistence CC sessionRestore.ts + conversationRecovery.ts parity.
3
3
  *
4
4
  * Enables conversation resume by persisting:
5
5
  * 1. Message transcript (JSONL-based, append-only)
6
- * 2. Cost snapshot (atomic JSON)
7
- * 3. Session metadata (model, cwd, agent mode)
6
+ * 2. Session metadata (flat JSON, atomic write)
8
7
  *
9
- * Storage layout:
10
- * <project>/.qlogicagent/sessions/<session-id>/ (when projectRoot provided)
11
- * ~/.qlogicagent/sessions/<session-id>/ (fallback)
12
- * transcript.jsonl 鈥?append-only message log
13
- * state.json 鈥?cost snapshot + metadata
8
+ * Storage layout (ALL data lives under project workspace, NEVER global):
9
+ * <project>/.qlogicagent/sessions/<session-id>/
10
+ * transcript.jsonl — append-only message log
11
+ * metadata.json — flat session metadata + usage stats
14
12
  *
15
13
  * Resume flow (CC processResumedConversation parity):
16
- * 1. loadSessionForResume(sessionId) 鈫?messages + cost
17
- * 2. Restore cost state into SessionState
14
+ * 1. loadSessionForResume(sessionId) messages + metadata
15
+ * 2. Restore usage state into SessionState
18
16
  * 3. Feed messages as initial context to agent
19
- *
20
- * Reference: claude-code src/utils/sessionRestore.ts
21
- * claude-code src/utils/conversationRecovery.ts
22
17
  */
23
18
  import type { ChatMessage } from "../../protocol/wire/index.js";
24
- import type { SessionCostSnapshot } from "./session-state.js";
19
+ import type { SessionUsageSnapshot } from "./session-state.js";
25
20
  export interface SessionMetadata {
26
21
  sessionId: string;
27
- createdAt: number;
28
- lastActiveAt: number;
22
+ projectId: string;
23
+ createdAt: string;
24
+ lastActiveAt: string;
29
25
  model?: string;
30
26
  cwd?: string;
31
27
  turnCount: number;
32
28
  messageCount: number;
33
- /** Title / description (auto-generated or user-set) */
34
29
  title?: string;
35
- /** Task summary generated by LLM (CC maybeGenerateTaskSummary parity) */
36
30
  taskSummary?: string;
37
- /** Timestamp of last task summary generation */
38
31
  taskSummaryGeneratedAt?: number;
39
- /** ISO timestamp 鈥?session pinned in UI */
40
32
  pinnedAt?: string;
41
- /** ISO timestamp 鈥?session archived (soft-deleted) */
42
33
  archivedAt?: string;
43
- /** Project ID this session belongs to */
44
- projectId?: string;
45
- /** Session type: personal or group */
34
+ sealedAt?: string;
35
+ previousSessionId?: string;
36
+ carryoverSummary?: string;
46
37
  type?: "personal" | "group";
47
- /** Owner user ID */
48
38
  ownerId?: string;
49
- /** Group key for group sessions */
50
39
  groupKey?: string;
51
- /** Group display name */
52
40
  groupName?: string;
53
- /** Group platform (wechat, dingtalk, etc.) */
54
41
  groupPlatform?: string;
42
+ totalInputTokens?: number;
43
+ totalOutputTokens?: number;
55
44
  }
56
45
  export interface PersistedSession {
57
46
  metadata: SessionMetadata;
58
47
  messages: ChatMessage[];
59
- costSnapshot?: SessionCostSnapshot;
60
48
  }
61
49
  export interface SessionListEntry {
62
50
  sessionId: string;
63
51
  title?: string;
64
- lastActiveAt: number;
52
+ lastActiveAt: string;
65
53
  messageCount: number;
66
54
  model?: string;
67
55
  pinnedAt?: string;
68
56
  archivedAt?: string;
69
- projectId?: string;
57
+ sealedAt?: string;
58
+ projectId: string;
70
59
  type?: "personal" | "group";
71
- createdAt?: number;
60
+ createdAt: string;
61
+ groupKey?: string;
62
+ previousSessionId?: string;
63
+ carryoverSummary?: string | null;
72
64
  }
65
+ /**
66
+ * Load session metadata only (lightweight — no transcript loading).
67
+ * Returns null if session doesn't exist or metadata is unreadable.
68
+ */
69
+ export declare function getSessionMetadata(sessionId: string, projectRoot: string): SessionMetadata | null;
73
70
  /**
74
71
  * Append a message to the session transcript.
75
72
  * Creates the session directory if it doesn't exist.
76
73
  * When turnId is provided, it acts as a per-turn boundary marker enabling
77
74
  * reconciliation with Gateway's token_usage records.
75
+ *
76
+ * Robustness: catches disk-full and I/O errors without crashing the agent.
77
+ * Returns false if the write fails.
78
78
  */
79
- export declare function appendMessage(sessionId: string, message: ChatMessage, projectRoot?: string, turnId?: string): Promise<void>;
79
+ export declare function appendMessage(sessionId: string, message: ChatMessage, projectRoot: string, turnId?: string): Promise<boolean>;
80
80
  /**
81
- * Save session state (cost + metadata) atomically.
81
+ * Save session metadata + usage stats atomically (flat structure).
82
82
  */
83
- export declare function saveSessionState(sessionId: string, costSnapshot: SessionCostSnapshot, metadata: Partial<SessionMetadata>, projectRoot?: string): Promise<void>;
83
+ export declare function saveSessionState(sessionId: string, usageSnapshot: SessionUsageSnapshot, metadata: Partial<SessionMetadata>, projectRoot: string): Promise<void>;
84
84
  /**
85
85
  * Update specific metadata fields of a session without touching cost data.
86
86
  * Used by session CRUD RPC (rename, pin, archive, move-to-project).
87
87
  */
88
- export declare function updateSessionMetadata(sessionId: string, patch: Partial<SessionMetadata>, projectRoot?: string): Promise<SessionMetadata | null>;
88
+ export declare function updateSessionMetadata(sessionId: string, patch: Partial<Record<keyof SessionMetadata, SessionMetadata[keyof SessionMetadata] | null>>, projectRoot: string): Promise<SessionMetadata | null>;
89
89
  /**
90
- * Load a persisted session for resume 鈥?CC loadConversationForResume parity.
90
+ * Load a persisted session for resume CC loadConversationForResume parity.
91
91
  *
92
92
  * Returns null if the session doesn't exist or is corrupted.
93
93
  */
94
- export declare function loadSessionForResume(sessionId: string, projectRoot?: string): Promise<PersistedSession | null>;
94
+ export declare function loadSessionForResume(sessionId: string, projectRoot: string): Promise<PersistedSession | null>;
95
95
  /**
96
- * List available sessions for resume 鈥?CC ResumeConversation picker.
96
+ * List available sessions for resume CC ResumeConversation picker.
97
97
  * Returns most-recent-first, up to `limit` entries.
98
98
  */
99
- export declare function listSessions(limit?: number, projectRoot?: string): Promise<SessionListEntry[]>;
99
+ export declare function listSessions(limit: number | undefined, projectRoot: string): Promise<SessionListEntry[]>;
100
100
  /**
101
101
  * Delete a session (cleanup).
102
102
  */
103
- export declare function deleteSession(sessionId: string, projectRoot?: string): Promise<void>;
103
+ export declare function deleteSession(sessionId: string, projectRoot: string): Promise<void>;
104
104
  /**
105
105
  * Prune old sessions beyond MAX_SESSIONS limit.
106
106
  * Deletes oldest sessions first.
107
107
  */
108
- export declare function pruneOldSessions(projectRoot?: string): Promise<number>;
108
+ export declare function pruneOldSessions(projectRoot: string): Promise<number>;
109
109
  export interface TaskSummaryDeps {
110
- transport: import("../../llm/transport.js").LLMTransport;
110
+ transport: import("@qlogic/provider-core").LLMTransport;
111
111
  apiKey: string;
112
112
  model: string;
113
113
  }
@@ -117,7 +117,8 @@ export interface TaskSummaryDeps {
117
117
  */
118
118
  export declare function shouldGenerateTaskSummary(metadata: SessionMetadata): boolean;
119
119
  /**
120
- * Generate and persist a task summary for a long session.
121
- * Fire-and-forget 鈥?errors are swallowed.
120
+ * Generate a concise session title from the user's first message.
121
+ * Lightweight LLM call — one-shot, no tool loop.
122
122
  */
123
- export declare function maybeGenerateTaskSummary(sessionId: string, metadata: SessionMetadata, recentMessages: ChatMessage[], deps: TaskSummaryDeps, projectRoot?: string): Promise<string | null>;
123
+ export declare function generateSessionTitle(userMessage: string, deps: TaskSummaryDeps): Promise<string | null>;
124
+ export declare function maybeGenerateTaskSummary(sessionId: string, metadata: SessionMetadata, recentMessages: ChatMessage[], deps: TaskSummaryDeps, projectRoot: string): Promise<string | null>;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Session State 鈥?CC session state parity.
2
+ * Session State CC session state parity.
3
3
  *
4
4
  * Unified state container for a single agent session:
5
5
  * - Token usage / cost accumulation across turns
@@ -14,7 +14,7 @@
14
14
  * Reference: claude-code src/bootstrap/state.ts, src/cost-tracker.ts
15
15
  */
16
16
  import type { WireTokenUsage as TokenUsage } from "../../protocol/wire/index.js";
17
- /** Per-model usage accumulation 鈥?CC modelUsage parity */
17
+ /** Per-model usage accumulation CC modelUsage parity */
18
18
  export interface ModelUsage {
19
19
  inputTokens: number;
20
20
  outputTokens: number;
@@ -36,8 +36,6 @@ export interface SessionUsageSnapshot {
36
36
  turnCount: number;
37
37
  lastSavedAt: number;
38
38
  }
39
- /** @deprecated Use SessionUsageSnapshot. Kept for persistence compat. */
40
- export type SessionCostSnapshot = SessionUsageSnapshot;
41
39
  export declare class SessionState {
42
40
  readonly sessionId: string;
43
41
  private _trustAccepted;
@@ -59,7 +57,7 @@ export declare class SessionState {
59
57
  /** Get all model usages as a plain object */
60
58
  getAllModelUsage(): Record<string, ModelUsage>;
61
59
  /**
62
- * Add usage from an API response 鈥?CC addToTotalSessionCost() parity.
60
+ * Add usage from an API response CC addToTotalSessionCost() parity.
63
61
  * Tracks token counts only; pricing is handled by Hub/Admin.
64
62
  *
65
63
  * @param usage - Token counts from the API response
@@ -4,8 +4,10 @@ export { MEMORY_TOOL_NAME, MEMORY_TOOL_ACTIONS, MEMORY_TOOL_SCHEMA, MEMORY_TOOL_
4
4
  export type { MemoryToolAction, MemoryToolParams, MemoryToolResult, MemoryToolExecutorDeps, } from "./memory/memory-tool.js";
5
5
  export { Memdir, getMemdirPath, getIndexPath } from "./memory/memdir.js";
6
6
  export type { MemdirFileInfo, MemdirResult } from "./memory/memdir.js";
7
- export { createQMemoryAdapter } from "./memory/qmemory-adapter.js";
8
- export type { QMemoryAdapterConfig, QMemoryHealthStatus, ExtractedMemoryItem, DecayOptions, DecayResult } from "./memory/qmemory-adapter.js";
7
+ export { createMemoryProvider, resolveMemoryConfigFromEnv } from "./memory/memory-provider-factory.js";
8
+ export type { MemoryProviderFactoryConfig, MemoryProviderFactoryResult } from "./memory/memory-provider-factory.js";
9
+ export { LocalMemoryProvider } from "./memory/local-memory-provider.js";
10
+ export type { LocalMemoryProviderConfig, ExtractedMemoryItem } from "./memory/local-memory-provider.js";
9
11
  export { THINK_TOOL_NAME, THINK_TOOL_SCHEMA, createThinkTool } from "./think-tool.js";
10
12
  export type { ThinkToolParams } from "./think-tool.js";
11
13
  export { READ_TOOL_NAME, READ_TOOL_SCHEMA, createReadTool } from "./tools/read-tool.js";
@@ -95,6 +97,10 @@ export { scanSource, scanSkillDirectory, hasCriticalFindings, isScannable, } fro
95
97
  export type { SkillGuardDeps } from "./skill-system/skill-guard.js";
96
98
  export { installSkill, uninstallSkill, createEmptyLockfile, } from "./skill-system/skill-source.js";
97
99
  export type { TrustLevel, ScanVerdict, SkillSourceDescriptor, SkillFetchResult, SkillFetchDeps, SkillStorageDeps, SkillLockEntry, SkillLockfile, SkillInstallResult, } from "./skill-system/skill-source.js";
100
+ export { loadLifecycleStore, saveLifecycleStore, ensureRecord, recordInvocation, recordView, recordPatch, removeRecord, pinSkill, unpinSkill, runCurator, executeCuratorCycle, archiveSkillOnDisk, unarchiveSkillOnDisk, getSkillsByState, getLifecycleRecord, } from "./skill-system/skill-lifecycle.js";
101
+ export type { SkillLifecycleState, SkillLifecycleRecord, SkillLifecycleStore, CuratorResult, } from "./skill-system/skill-lifecycle.js";
102
+ export { validateSkillContent, generateSkillContent, autoFixFrontmatter, } from "./skill-system/skill-validation.js";
103
+ export type { FrontmatterValidationResult } from "./skill-system/skill-validation.js";
98
104
  export { McpStdioClient } from "./mcp/mcp-stdio-client.js";
99
105
  export { McpManager, parseMcpConfig } from "./mcp/mcp-manager.js";
100
106
  export type { McpServerEntry, McpManagerConfig } from "./mcp/mcp-manager.js";
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Implicit Memory Extraction — CC extractMemories lightweight port.
3
+ *
4
+ * Architecture:
5
+ * Layer 1: Zero-cost signal detection (regex) — decides if turn has extractable content
6
+ * Layer 2: Lightweight LLM pass (async, non-blocking) — extracts structured facts
7
+ *
8
+ * This runs AFTER turn.end, so the user already has their response.
9
+ * Layer 2 only fires for ~10-20% of turns (those with detectable signals).
10
+ *
11
+ * Reference: claude-code src/services/extractMemories/extractMemories.ts
12
+ */
13
+ import type { LocalMemoryProvider } from "./local-memory-provider.js";
14
+ export interface ExtractedFact {
15
+ text: string;
16
+ category: "personal_fact" | "preference" | "event" | "lesson" | "pattern" | "decision";
17
+ importance: number;
18
+ eventDate?: string;
19
+ }
20
+ export interface ImplicitExtractionDeps {
21
+ /** Local memory provider for writing extracted facts. */
22
+ localProvider: LocalMemoryProvider;
23
+ /** User ID. */
24
+ userId: string;
25
+ /** Logger. */
26
+ log: {
27
+ debug(msg: string): void;
28
+ warn(msg: string): void;
29
+ };
30
+ /**
31
+ * LLM invocation function (uses background/cheap model).
32
+ * Returns structured JSON string or null if unavailable.
33
+ */
34
+ llmExtract?: (prompt: string) => Promise<string | null>;
35
+ }
36
+ export interface TurnPair {
37
+ userMessage: string;
38
+ assistantMessage: string;
39
+ }
40
+ /**
41
+ * Layer 1: Detect if a user message contains signals worth extracting.
42
+ * Zero LLM cost — pure regex scanning.
43
+ *
44
+ * @returns true if the message likely contains extractable personal facts/events
45
+ */
46
+ export declare function hasExtractionSignal(userMessage: string): boolean;
47
+ /**
48
+ * Layer 2: Use a lightweight LLM to extract structured facts from a turn pair.
49
+ * Only called when Layer 1 signals are detected.
50
+ */
51
+ export declare function extractFactsViaLlm(turn: TurnPair, llmExtract: (prompt: string) => Promise<string | null>, today: string): Promise<ExtractedFact[]>;
52
+ /**
53
+ * Run the full implicit extraction pipeline for a completed turn.
54
+ * This is async and non-blocking — call it after turn.end.
55
+ *
56
+ * @returns Number of facts extracted and stored
57
+ */
58
+ export declare function runImplicitExtraction(turn: TurnPair, deps: ImplicitExtractionDeps): Promise<number>;
@@ -0,0 +1,176 @@
1
+ /**
2
+ * Local Embedding — Pluggable embedding interface for local memory.
3
+ *
4
+ * Provides a unified interface for text → vector embedding.
5
+ * Strategies:
6
+ * 1. "api" — calls an external embedding API (OpenAI-compatible)
7
+ * 2. "onnx" — @xenova/transformers for fully offline embedding
8
+ * 3. "none" — no embeddings, FTS-only search (zero-dep fallback)
9
+ */
10
+ export interface EmbeddingProvider {
11
+ readonly dimensions: number;
12
+ readonly model: string;
13
+ embed(text: string): Promise<Float32Array>;
14
+ embedBatch(texts: string[]): Promise<Float32Array[]>;
15
+ }
16
+ export interface EmbeddingApiConfig {
17
+ /** OpenAI-compatible embedding API base URL */
18
+ baseUrl: string;
19
+ /** API key */
20
+ apiKey: string;
21
+ /** Model name (e.g. "text-embedding-3-small") */
22
+ model: string;
23
+ /** Expected dimensions (default: 1536 for text-embedding-3-small) */
24
+ dimensions?: number;
25
+ /** Request timeout in ms (default: 10000) */
26
+ timeoutMs?: number;
27
+ /**
28
+ * Provider-specific API format.
29
+ * - "openai": Standard /v1/embeddings with input:string[] → data[].embedding (default)
30
+ * - "minimax": /v1/embeddings with texts:string[] → vectors[]
31
+ * - "volcengine": /v1/embeddings/multimodal with input:[{type,text}] → data.embedding
32
+ */
33
+ format?: "openai" | "minimax" | "volcengine";
34
+ }
35
+ export declare class NullEmbeddingProvider implements EmbeddingProvider {
36
+ readonly dimensions = 0;
37
+ readonly model = "none";
38
+ embed(_text: string): Promise<Float32Array>;
39
+ embedBatch(_texts: string[]): Promise<Float32Array[]>;
40
+ }
41
+ /**
42
+ * Wraps a primary EmbeddingProvider with automatic fallback to a local provider.
43
+ * When the primary fails (timeout, network error, 5xx), transparently retries with local.
44
+ *
45
+ * IMPORTANT: primary and fallback MUST have the same dimensions.
46
+ * If they differ, vectors in the same index will be incomparable.
47
+ * Use this only when both produce the same dimensionality (e.g. hub TEI bge-m3 1024d
48
+ * + local ONNX bge-m3-small 1024d).
49
+ */
50
+ export declare class FallbackEmbeddingProvider implements EmbeddingProvider {
51
+ readonly dimensions: number;
52
+ readonly model: string;
53
+ private primary;
54
+ private fallback;
55
+ private onFallback?;
56
+ constructor(opts: {
57
+ primary: EmbeddingProvider;
58
+ fallback: EmbeddingProvider;
59
+ onFallback?: (error: Error) => void;
60
+ });
61
+ embed(text: string): Promise<Float32Array>;
62
+ embedBatch(texts: string[]): Promise<Float32Array[]>;
63
+ }
64
+ export declare class ApiEmbeddingProvider implements EmbeddingProvider {
65
+ readonly dimensions: number;
66
+ readonly model: string;
67
+ private baseUrl;
68
+ private apiKey;
69
+ private timeoutMs;
70
+ private format;
71
+ constructor(config: EmbeddingApiConfig);
72
+ embed(text: string): Promise<Float32Array>;
73
+ embedBatch(texts: string[]): Promise<Float32Array[]>;
74
+ private buildRequest;
75
+ private parseResponse;
76
+ }
77
+ export interface LocalEmbeddingConfig {
78
+ strategy: "api" | "onnx" | "none";
79
+ api?: EmbeddingApiConfig;
80
+ onnx?: OnnxEmbeddingConfig;
81
+ /**
82
+ * When strategy=api, if the API fails (timeout/error), fallback to this.
83
+ * - "onnx": use local ONNX model (download on first use, ~23MB)
84
+ * - "none": give up embedding (FTS-only)
85
+ * Requires same dimensions for vector compatibility. Default ONNX model
86
+ * (bge-small-zh-v1.5, 512d) differs from bge-m3 (1024d).
87
+ * Accept dimension mismatch for degraded recall in fallback mode.
88
+ */
89
+ fallbackStrategy?: "onnx" | "none";
90
+ fallbackOnnx?: OnnxEmbeddingConfig;
91
+ }
92
+ export interface OnnxEmbeddingConfig {
93
+ /** Model ID for @xenova/transformers (default: "Xenova/bge-small-zh-v1.5") */
94
+ modelId?: string;
95
+ /** Expected dimensions (default: 512 for bge-small-zh-v1.5) */
96
+ dimensions?: number;
97
+ /** Max sequence length before truncation (default: 256) */
98
+ maxLength?: number;
99
+ /** Override local model path (for testing). */
100
+ localModelPath?: string;
101
+ }
102
+ /**
103
+ * Offline embedding provider using ONNX Runtime via @xenova/transformers.
104
+ *
105
+ * Model is lazily downloaded on first use (~24MB for bge-small-zh-v1.5 quantized).
106
+ * Subsequent loads are instant from local cache (~/.qlogicagent/models/).
107
+ *
108
+ * For China network: set ONNX_MODEL_MIRROR to OSS URL or HF_MIRROR=https://hf-mirror.com
109
+ */
110
+ export declare class OnnxEmbeddingProvider implements EmbeddingProvider {
111
+ readonly dimensions: number;
112
+ readonly model: string;
113
+ private maxLength;
114
+ private localModelPath;
115
+ private pipeline;
116
+ private loading;
117
+ constructor(config?: OnnxEmbeddingConfig);
118
+ private getPipeline;
119
+ embed(text: string): Promise<Float32Array>;
120
+ embedBatch(texts: string[]): Promise<Float32Array[]>;
121
+ /**
122
+ * Pre-download and load the ONNX model without blocking.
123
+ * Call this at process startup for instant readiness on first real embed().
124
+ */
125
+ warmup(): Promise<void>;
126
+ }
127
+ export interface WarmupResult {
128
+ onnxAvailable: boolean;
129
+ modelCached: boolean;
130
+ modelDownloaded: boolean;
131
+ dimensions: number;
132
+ error?: string;
133
+ }
134
+ /**
135
+ * Run at process startup to verify environment and pre-download ONNX model.
136
+ *
137
+ * - Checks if @xenova/transformers is installed
138
+ * - Checks if model already in local cache
139
+ * - If not cached, downloads from OSS CDN in background
140
+ * - Returns status for diagnostics logging
141
+ *
142
+ * Fire-and-forget: never throws, never blocks critical path.
143
+ */
144
+ export declare function warmupEmbeddingModel(config?: OnnxEmbeddingConfig): Promise<WarmupResult>;
145
+ /**
146
+ * Create an embedding provider based on configuration.
147
+ *
148
+ * Resolution order:
149
+ * 1. Explicit config (api/onnx/none)
150
+ * 2. Auto-detect: @xenova/transformers available → use ONNX (lazy download)
151
+ * 3. Fallback to NullEmbeddingProvider (FTS-only)
152
+ *
153
+ * When config.fallbackStrategy is set and strategy=api, wraps primary in
154
+ * FallbackEmbeddingProvider for automatic local retry on API failure.
155
+ */
156
+ export declare function createEmbeddingProvider(config?: LocalEmbeddingConfig): EmbeddingProvider;
157
+ /**
158
+ * Known provider → format mapping.
159
+ * Used by auto-cascade to build the correct EmbeddingApiConfig
160
+ * when the user's LLM provider also has an embedding API.
161
+ */
162
+ export declare const PROVIDER_EMBEDDING_REGISTRY: Record<string, {
163
+ format: "openai" | "minimax" | "volcengine";
164
+ baseUrl: string;
165
+ defaultModel: string;
166
+ defaultDimensions: number;
167
+ }>;
168
+ /**
169
+ * Resolve EmbeddingApiConfig from a known provider name + API key.
170
+ * Returns null if the provider has no known embedding endpoint.
171
+ */
172
+ export declare function resolveProviderEmbeddingConfig(provider: string, apiKey: string, overrides?: {
173
+ model?: string;
174
+ baseUrl?: string;
175
+ dimensions?: number;
176
+ }): EmbeddingApiConfig | null;