qlogicagent 2.2.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/dist/agent.js +10 -9
  2. package/dist/cli.js +213 -211
  3. package/dist/index.js +212 -210
  4. package/dist/orchestration.js +13 -12
  5. package/dist/protocol.js +1 -0
  6. package/dist/types/agent/constants.d.ts +4 -53
  7. package/dist/types/agent/tunable-defaults.d.ts +225 -0
  8. package/dist/types/agent/types.d.ts +24 -100
  9. package/dist/types/cli/stdio-server.d.ts +40 -0
  10. package/dist/types/cli/tool-bootstrap.d.ts +6 -0
  11. package/dist/types/contracts/index.d.ts +2 -3
  12. package/dist/types/llm/provider-def.d.ts +3 -0
  13. package/dist/types/llm/transport.d.ts +25 -25
  14. package/dist/types/llm/transports/anthropic-messages.d.ts +2 -2
  15. package/dist/types/llm/transports/gemini-generatecontent.d.ts +2 -2
  16. package/dist/types/llm/transports/openai-chat.d.ts +2 -2
  17. package/dist/types/llm/transports/openai-responses.d.ts +9 -9
  18. package/dist/types/llm/transports/volcengine-responses.d.ts +11 -11
  19. package/dist/types/orchestration/agent-instance.d.ts +15 -0
  20. package/dist/types/orchestration/skill-improvement.d.ts +39 -8
  21. package/dist/types/orchestration/solo-evaluator.d.ts +7 -0
  22. package/dist/types/orchestration/subagent/fork-subagent.d.ts +2 -2
  23. package/dist/types/orchestration/tool-loop/tool-choice-policy.d.ts +1 -1
  24. package/dist/types/protocol/methods.d.ts +143 -53
  25. package/dist/types/protocol/notifications.d.ts +4 -495
  26. package/dist/types/protocol/wire/acp-protocol.d.ts +411 -0
  27. package/dist/types/protocol/wire/agent-events.d.ts +32 -0
  28. package/dist/types/protocol/wire/agent-methods.d.ts +587 -0
  29. package/dist/types/protocol/wire/agent-rpc.d.ts +97 -0
  30. package/dist/types/protocol/wire/capability-manifest.d.ts +111 -0
  31. package/dist/types/protocol/wire/capability-transport.d.ts +207 -0
  32. package/dist/types/protocol/wire/channel-ingress.d.ts +29 -0
  33. package/dist/types/protocol/wire/channel.d.ts +89 -0
  34. package/dist/types/protocol/wire/chat-types.d.ts +87 -0
  35. package/dist/types/protocol/wire/checkpoint-runtime.d.ts +61 -0
  36. package/dist/types/protocol/wire/checkpoint.d.ts +72 -0
  37. package/dist/types/protocol/wire/execution.d.ts +391 -0
  38. package/dist/types/protocol/wire/gateway-rpc.d.ts +314 -0
  39. package/dist/types/protocol/wire/gateway.d.ts +62 -0
  40. package/dist/types/protocol/wire/hook-protocol.d.ts +37 -0
  41. package/dist/types/protocol/wire/index.d.ts +25 -0
  42. package/dist/types/protocol/wire/memory-provider-lifecycle.d.ts +80 -0
  43. package/dist/types/protocol/wire/notification-payloads.d.ts +581 -0
  44. package/dist/types/protocol/wire/provider-runtime-contract.d.ts +66 -0
  45. package/dist/types/protocol/wire/provider-runtime-core.d.ts +147 -0
  46. package/dist/types/protocol/wire/provider-runtime-io.d.ts +20 -0
  47. package/dist/types/protocol/wire/resource-manifest.d.ts +68 -0
  48. package/dist/types/protocol/wire/session.d.ts +32 -0
  49. package/dist/types/protocol/wire/thread-protocol.d.ts +157 -0
  50. package/dist/types/protocol/wire/transport.d.ts +57 -0
  51. package/dist/types/protocol/wire/turn.d.ts +208 -0
  52. package/dist/types/protocol/wire/web-capability.d.ts +51 -0
  53. package/dist/types/runtime/hooks/memory-hooks.d.ts +2 -5
  54. package/dist/types/runtime/hooks/skill-recall-hooks.d.ts +2 -4
  55. package/dist/types/runtime/infra/acp-types.d.ts +3 -142
  56. package/dist/types/runtime/infra/project-store.d.ts +6 -0
  57. package/dist/types/runtime/infra/skill-injector.d.ts +9 -2
  58. package/dist/types/runtime/infra/token-budget.d.ts +3 -3
  59. package/dist/types/runtime/session/index.d.ts +1 -1
  60. package/dist/types/runtime/session/session-memory.d.ts +46 -0
  61. package/dist/types/runtime/session/session-persistence.d.ts +34 -8
  62. package/dist/types/runtime/session/session-state.d.ts +4 -4
  63. package/dist/types/skills/memory/memory-tool.d.ts +1 -1
  64. package/dist/types/skills/memory/qmemory-adapter.d.ts +1 -1
  65. package/dist/types/skills/permissions/hook-runner.d.ts +4 -4
  66. package/dist/types/skills/permissions/permission-classifier.d.ts +2 -2
  67. package/dist/types/skills/skill-system/skill-source.d.ts +65 -0
  68. package/dist/types/skills/tools/project-switch-tool.d.ts +24 -0
  69. package/dist/types/skills/tools.d.ts +5 -5
  70. package/dist/types/transport/acp-event-emitter.d.ts +1 -1
  71. package/dist/types/transport/acp-server.d.ts +18 -9
  72. package/package.json +14 -3
@@ -0,0 +1,51 @@
1
+ export declare const WEB_CAPABILITY_ID_VALUES: readonly ["web_search", "web_fetch", "deep_research", "browser_execution"];
2
+ export type WebCapabilityId = (typeof WEB_CAPABILITY_ID_VALUES)[number];
3
+ export declare const WEB_CAPABILITY_FAMILY_VALUES: readonly ["web-intelligence", "browser-execution"];
4
+ export type WebCapabilityFamily = (typeof WEB_CAPABILITY_FAMILY_VALUES)[number];
5
+ export declare const WEB_TASK_MODE_VALUES: readonly ["discovery", "read-url", "multi-source-research", "interactive-browser"];
6
+ export type WebTaskMode = (typeof WEB_TASK_MODE_VALUES)[number];
7
+ export declare const WEB_EXECUTION_MODE_VALUES: readonly ["stateless", "render-backend", "interactive-session"];
8
+ export type WebExecutionMode = (typeof WEB_EXECUTION_MODE_VALUES)[number];
9
+ export declare const WEB_STATEFULNESS_VALUES: readonly ["stateless", "stateless-single-step", "stateful-session-required"];
10
+ export type WebStatefulness = (typeof WEB_STATEFULNESS_VALUES)[number];
11
+ export declare const WEB_APPROVAL_DEFAULT_VALUES: readonly ["required", "conditional", "none"];
12
+ export type WebApprovalDefault = (typeof WEB_APPROVAL_DEFAULT_VALUES)[number];
13
+ export declare const WEB_POLICY_RISK_CLASS_VALUES: readonly ["browser-read", "browser-authenticated-read", "browser-state-changing"];
14
+ export type WebPolicyRiskClass = (typeof WEB_POLICY_RISK_CLASS_VALUES)[number];
15
+ export declare const WEB_ACTION_SCOPE_VALUES: readonly ["read-page", "read-authenticated-page", "fill-form", "submit-form", "download-file", "reuse-session"];
16
+ export type WebActionScope = (typeof WEB_ACTION_SCOPE_VALUES)[number];
17
+ export declare const WEB_DEGRADATION_TARGET_VALUES: readonly ["web_search", "web_fetch", "deep_research", "blocked"];
18
+ export type WebDegradationTarget = (typeof WEB_DEGRADATION_TARGET_VALUES)[number];
19
+ export declare const WEB_ESCALATION_REASON_VALUES: readonly ["requires-interaction", "requires-login-state", "requires-rendered-dom", "requires-persistent-session", "requires-state-changing-action"];
20
+ export type WebEscalationReason = (typeof WEB_ESCALATION_REASON_VALUES)[number];
21
+ export declare const WEB_RETRY_POLICY_VALUES: readonly ["none", "same-capability-once", "degrade-only"];
22
+ export type WebRetryPolicy = (typeof WEB_RETRY_POLICY_VALUES)[number];
23
+ export interface WebCapabilityDescriptorContract {
24
+ capabilityId?: WebCapabilityId;
25
+ capabilityFamily?: WebCapabilityFamily;
26
+ taskMode?: WebTaskMode;
27
+ executionMode?: WebExecutionMode;
28
+ statefulness?: WebStatefulness;
29
+ approvalDefault?: WebApprovalDefault;
30
+ policyRiskClass?: WebPolicyRiskClass;
31
+ requiresRuntimeBackend?: boolean;
32
+ requiresHostBridge?: boolean;
33
+ supportsRenderBackend?: boolean;
34
+ supportsLoginState?: boolean;
35
+ supportsPersistentProfile?: boolean;
36
+ supportsSharedSessionReuse?: boolean;
37
+ supportsTransactionality?: "read-only" | "state-changing";
38
+ allowedActionScopes?: WebActionScope[];
39
+ degradationTarget?: WebDegradationTarget;
40
+ upgradeTargets?: WebCapabilityId[];
41
+ fallbackChain?: Array<"render-backend">;
42
+ escalationReasons?: WebEscalationReason[];
43
+ auditRequired?: boolean;
44
+ requiresUserVisibleStep?: boolean;
45
+ retryPolicy?: WebRetryPolicy;
46
+ repairAfterDenied?: boolean;
47
+ repairAfterUnavailable?: boolean;
48
+ displayRiskLabel?: string;
49
+ displayBlockedLabel?: string;
50
+ displayFallbackLabel?: string;
51
+ }
@@ -1,12 +1,9 @@
1
1
  import type { HookRegistry } from "../../contracts/hooks.js";
2
- import type { MemoryProvider } from "qlogicagent-runtime-contracts";
2
+ import type { MemoryProvider } from "../../protocol/wire/index.js";
3
3
  import type { Memdir } from "../../skills/memory/memdir.js";
4
4
  export declare const MEMORY_PREFETCH_CONFIG: {
5
- /** Max bytes of memory content to inject per session (CC: 60KB) */
6
5
  readonly MAX_SESSION_BYTES: number;
7
- /** Max results per recall query */
8
6
  readonly LIMIT_PER_RECALL: 10;
9
- /** Max entries in surfaced-path LRU set */
10
7
  readonly MAX_SURFACED_ENTRIES: 100;
11
8
  };
12
9
  export interface MemoryHooksDeps {
@@ -46,7 +43,7 @@ export declare function createMemoryPrefetchState(): MemoryPrefetchState;
46
43
  * Returns a cleanup function to unregister.
47
44
  */
48
45
  export declare function registerMemoryHooks(hooks: HookRegistry, deps: MemoryHooksDeps,
49
- /** Shared state pass the same object across hook re-registrations in a session. */
46
+ /** Shared state 鈥?pass the same object across hook re-registrations in a session. */
50
47
  prefetchState?: MemoryPrefetchState): () => void;
51
48
  export interface MemdirRecallHookDeps {
52
49
  /** MEMDIR instance (lazy: may be null at registration time). */
@@ -1,14 +1,12 @@
1
1
  import type { HookRegistry } from "../../contracts/hooks.js";
2
2
  export declare const SKILL_RECALL_CONFIG: {
3
- /** Max number of cross-project skills to inject per turn. */
4
3
  readonly MAX_RECALLED_SKILLS: 3;
5
- /** Max chars of skill content to include in recall context. */
6
4
  readonly MAX_SKILL_CONTENT_CHARS: 800;
7
- /** Cache TTL for known project skill index (ms). */
8
5
  readonly CACHE_TTL_MS: number;
9
6
  };
10
7
  /**
11
- * Detect whether user message contains retrospective/cross-reference semantics.
8
+ * Detect whether user message contains retrospective/cross-reference semantics
9
+ * OR similar-task patterns that could benefit from existing skills.
12
10
  * Returns extracted keywords for skill matching if triggered, or null.
13
11
  */
14
12
  export declare function detectRetrospectiveTrigger(message: string): string[] | null;
@@ -4,16 +4,8 @@
4
4
  * These types define the contract for discovering, registering, and managing
5
5
  * external ACP-compatible agent CLIs alongside qlogicagent's internal agents.
6
6
  */
7
- /**
8
- * Two-level agent taxonomy:
9
- * - sub-agent: internal qlogicagent instance, budget/tool restricted
10
- * - teammate: external ACP CLI agent, full capability
11
- */
12
- export type AgentCategory = "sub-agent" | "teammate";
13
- /** Communication protocol with the agent. */
14
- export type AgentProtocol = "internal" | "acp";
15
- /** Agent availability status. */
16
- export type AgentStatus = "available" | "unavailable" | "handshake_failed" | "not_installed";
7
+ import type { AgentCapabilities, CustomAgentDef, AgentConfig, ProductTaskStatus, ProductInstanceDef, ProductTaskDef } from "../../protocol/wire/index.js";
8
+ export type { AgentCategory, AgentProtocol, AgentStatus, AgentCapabilities, AgentDescriptor, CustomAgentDef, AgentConfig, SoloState, SoloAgentState, SoloAgentResult, SoloStatus, ProductPhase, ProductTaskStatus, ProductInstanceDef, ProductTaskDef, ProductStatus, ProductSummary, } from "../../protocol/wire/index.js";
17
9
  /** Pre-defined configuration for a known ACP backend. */
18
10
  export interface AcpBackendConfig {
19
11
  /** Backend ID, e.g. "claude" | "codex" | "goose". */
@@ -39,45 +31,6 @@ export interface AcpBackendConfig {
39
31
  /** Environment variable name for the base URL. */
40
32
  baseUrlEnvVar?: string;
41
33
  }
42
- /** Capabilities discovered during ACP handshake. */
43
- export interface AgentCapabilities {
44
- /** Whether the agent supports MCP server injection via session/new. */
45
- supportsMcp: boolean;
46
- /** Whether the agent supports session/resume. */
47
- supportsResume: boolean;
48
- /** Whether the agent sends usage_update notifications. */
49
- supportsUsageUpdate: boolean;
50
- /** Native skill directories, if any. */
51
- skillsDirs?: string[];
52
- }
53
- /**
54
- * Descriptor for a discovered or registered agent.
55
- * Returned by `agents.scan` and `agents.list` RPCs.
56
- */
57
- export interface AgentDescriptor {
58
- /** Backend ID, e.g. "claude", "codex", "qlogicagent". */
59
- id: string;
60
- /** Display name. */
61
- name: string;
62
- /** sub-agent (internal) or teammate (external). */
63
- category: AgentCategory;
64
- /** Communication protocol. */
65
- protocol: AgentProtocol;
66
- /** Current availability. */
67
- status: AgentStatus;
68
- /** Resolved CLI binary path (teammates only). */
69
- cliPath?: string;
70
- /** CLI version string (teammates only). */
71
- version?: string;
72
- /** Capabilities (populated after handshake). */
73
- capabilities?: AgentCapabilities;
74
- /** Whether auth is required. */
75
- authRequired: boolean;
76
- /** Whether user has configured this agent (apiKey / baseUrl). */
77
- hasConfig: boolean;
78
- /** Whether this agent supports LLM base URL redirection. */
79
- supportsBaseUrlOverride: boolean;
80
- }
81
34
  /**
82
35
  * Extended descriptor for external agents,
83
36
  * used internally by AgentProcessManager to spawn.
@@ -94,36 +47,6 @@ export interface ExternalAgentDescriptor {
94
47
  /** Communication protocol. */
95
48
  protocol: "acp";
96
49
  }
97
- /** User-provided custom agent definition for agents.config RPC. */
98
- export interface CustomAgentDef {
99
- /** Unique ID (user-chosen). */
100
- id: string;
101
- /** Display name. */
102
- name: string;
103
- /** CLI command or absolute path. */
104
- cliCommand: string;
105
- /** ACP mode launch arguments. */
106
- acpArgs: string[];
107
- /** Additional environment variables. */
108
- env?: Record<string, string>;
109
- /** Whether auth is required. */
110
- authRequired?: boolean;
111
- /** Native skill directories. */
112
- skillsDirs?: string[];
113
- /** Whether base URL override is supported. */
114
- supportsBaseUrlOverride?: boolean;
115
- }
116
- /** Persisted per-agent configuration. */
117
- export interface AgentConfig {
118
- apiKey?: string;
119
- baseUrl?: string;
120
- model?: string;
121
- env?: Record<string, string>;
122
- customArgs?: string[];
123
- customCliPath?: string;
124
- /** Model ID translation: qlogicModelId → externalModelId. */
125
- modelIdMap?: Record<string, string>;
126
- }
127
50
  /** Root config store schema (persisted to JSON). */
128
51
  export interface AgentConfigStoreData {
129
52
  /** Global gateway proxy URL. */
@@ -226,31 +149,10 @@ export interface AgentsRemoveConfigParams {
226
149
  export interface AgentsSetGatewayParams {
227
150
  url: string;
228
151
  }
229
- export type SoloState = "running" | "evaluating" | "completed" | "cancelled" | "failed";
230
- export type SoloAgentState = "pending" | "running" | "completed" | "failed";
231
- export interface SoloAgentResult {
232
- id: string;
233
- state: SoloAgentState;
234
- progress?: string;
235
- resultText?: string;
236
- diff?: string;
237
- usage?: {
238
- inputTokens: number;
239
- outputTokens: number;
240
- };
241
- error?: string;
242
- worktreePath?: string;
243
- }
244
152
  export interface SoloEvaluation {
245
153
  winnerId: string;
246
154
  reasoning: string;
247
155
  }
248
- export interface SoloStatus {
249
- soloId: string;
250
- state: SoloState;
251
- agents: SoloAgentResult[];
252
- evaluation?: SoloEvaluation;
253
- }
254
156
  /** solo.start RPC params. */
255
157
  export interface SoloStartParams {
256
158
  task: string;
@@ -266,9 +168,7 @@ export interface SoloSelectParams {
266
168
  soloId: string;
267
169
  winnerId: string;
268
170
  }
269
- export type ProductPhase = "active" | "paused" | "completed" | "failed";
270
171
  export type ProductInstanceState = "idle" | "running" | "completed" | "failed" | "paused";
271
- export type ProductTaskStatus = "pending" | "running" | "completed" | "failed" | "paused";
272
172
  /** Product budget configuration & runtime counters. */
273
173
  export interface ProductBudget {
274
174
  maxTotalTokens?: number;
@@ -276,19 +176,6 @@ export interface ProductBudget {
276
176
  usedTokens: number;
277
177
  elapsed: number;
278
178
  }
279
- /** Instance definition within a product. */
280
- export interface ProductInstanceDef {
281
- name: string;
282
- role: string;
283
- agentId: string;
284
- }
285
- /** Task definition within a product DAG. */
286
- export interface ProductTaskDef {
287
- taskId: string;
288
- assignee: string;
289
- prompt: string;
290
- dependsOn?: string[];
291
- }
292
179
  /** product.create RPC params. */
293
180
  export interface ProductCreateParams {
294
181
  name: string;
@@ -326,27 +213,6 @@ export interface ProductTaskState {
326
213
  startedAt?: string;
327
214
  completedAt?: string;
328
215
  }
329
- /** Full product status (product.status response). */
330
- export interface ProductStatus {
331
- productId: string;
332
- name: string;
333
- phase: ProductPhase;
334
- instances: ProductInstanceStatus[];
335
- tasks: ProductTaskState[];
336
- budget: ProductBudget;
337
- lastCheckpointAt: string;
338
- }
339
- /** Summary for product.list response. */
340
- export interface ProductSummary {
341
- productId: string;
342
- name: string;
343
- phase: ProductPhase;
344
- instanceCount: number;
345
- taskCount: number;
346
- completedTasks: number;
347
- createdAt: string;
348
- lastCheckpointAt: string;
349
- }
350
216
  /** agents.getGateway response. */
351
217
  export interface AgentsGetGatewayResult {
352
218
  url?: string;
@@ -402,9 +268,4 @@ export interface SoloDeleteParams {
402
268
  export interface ProductDeleteParams {
403
269
  productId: string;
404
270
  }
405
- /** Agent source attribution, attached to turn events when delegated. */
406
- export interface AgentSource {
407
- id: string;
408
- name: string;
409
- role: "main" | "teammate";
410
- }
271
+ export type { AgentSource } from "../../protocol/wire/index.js";
@@ -22,6 +22,12 @@ export declare function deleteProject(projectId: string): {
22
22
  switchedTo?: ProjectInfo;
23
23
  };
24
24
  export declare function getOrCreateDefaultProject(defaultWorkspaceDir: string): ProjectInfo;
25
+ export declare function renameProject(projectId: string, newName: string): ProjectInfo | null;
26
+ export declare function archiveProject(projectId: string): {
27
+ archived: boolean;
28
+ switchedTo?: ProjectInfo;
29
+ };
30
+ export declare function unarchiveProject(projectId: string): ProjectInfo | null;
25
31
  export declare function findByGroupId(groupId: string): ProjectInfo | null;
26
32
  export declare function archiveByGroupId(groupId: string): {
27
33
  archived: boolean;
@@ -9,8 +9,11 @@
9
9
  *
10
10
  * 2. **First-message prompt injection**: For agents without native skill
11
11
  * directory support, prepend skill instructions text to the first prompt.
12
+ * Subject to a token budget to prevent context bloat.
12
13
  */
13
14
  import type { AgentCapabilities } from "./acp-types.js";
15
+ import { SKILL_INJECTION_MAX_CHARS, SKILL_INJECTION_MAX_COUNT } from "../../agent/tunable-defaults.js";
16
+ export { SKILL_INJECTION_MAX_CHARS, SKILL_INJECTION_MAX_COUNT };
14
17
  export declare class SkillInjector {
15
18
  /**
16
19
  * Synchronize skills to an agent's native skill directory.
@@ -24,6 +27,9 @@ export declare class SkillInjector {
24
27
  * Build a skill description block to prepend to the first message
25
28
  * for agents that don't support native skill directories.
26
29
  *
30
+ * Respects SKILL_INJECTION_MAX_CHARS and SKILL_INJECTION_MAX_COUNT
31
+ * to prevent token bloat.
32
+ *
27
33
  * @param cwd - Project working directory (for project-level skills)
28
34
  * @returns Markdown text with skill instructions, or empty string if no skills.
29
35
  */
@@ -44,8 +50,9 @@ export declare class SkillInjector {
44
50
  */
45
51
  applySkills(capabilities?: AgentCapabilities, cwd?: string): string;
46
52
  /**
47
- * Collect all skill file paths from user-level and project-level dirs.
48
- * Only `.md` files are treated as skills.
53
+ * Collect all skill file paths from project-level and user-level dirs.
54
+ * Skills are stored as `<dir>/<skillName>/SKILL.md`.
55
+ * Priority: project > global (project listed first for budget-constrained injection).
49
56
  */
50
57
  private collectSkillPaths;
51
58
  }
@@ -1,11 +1,11 @@
1
1
  /**
2
- * Sub-agent Token Budget Enforcer CC-aligned budget limits.
2
+ * Sub-agent Token Budget Enforcer 鈥?CC-aligned budget limits.
3
3
  *
4
4
  * Prevents sub-agents from consuming infinite tokens by:
5
5
  * 1. Per-task token budget (from TaskStateBase.tokenBudget)
6
6
  * 2. Session-level aggregate budget (all tasks combined)
7
7
  * 3. Budget continuation messages (CC tokenBudget.ts pattern)
8
- * 4. Graceful degradation (warn force-stop, never hard-crash)
8
+ * 4. Graceful degradation (warn 鈫?force-stop, never hard-crash)
9
9
  *
10
10
  * CC reference: utils/tokenBudget.ts, main.tsx --max-budget-usd / --task-budget
11
11
  *
@@ -13,7 +13,7 @@
13
13
  * CC has no explicit per-sub-agent budget; they rely on session-level maxBudgetUsd.
14
14
  * We add per-task enforcement to prevent a single sub-agent from exhausting the budget.
15
15
  */
16
- import type { TokenUsage } from "../../agent/types.js";
16
+ import type { WireTokenUsage as TokenUsage } from "../../protocol/wire/index.js";
17
17
  export interface BudgetConfig {
18
18
  /** Per-task token budget (prompt + completion). 0 = unlimited. */
19
19
  taskBudgetTokens: number;
@@ -1,2 +1,2 @@
1
1
  export { SessionState, type SessionUsageSnapshot, type SessionCostSnapshot } from "./session-state.js";
2
- export { appendMessage, saveSessionState, loadSessionForResume, listSessions, deleteSession, pruneOldSessions, shouldGenerateTaskSummary, maybeGenerateTaskSummary, type SessionMetadata, type PersistedSession, type SessionListEntry, type TaskSummaryDeps, } from "./session-persistence.js";
2
+ export { appendMessage, saveSessionState, updateSessionMetadata, loadSessionForResume, listSessions, deleteSession, pruneOldSessions, shouldGenerateTaskSummary, maybeGenerateTaskSummary, type SessionMetadata, type PersistedSession, type SessionListEntry, type TaskSummaryDeps, } from "./session-persistence.js";
@@ -0,0 +1,46 @@
1
+ /**
2
+ * SessionMemory 鈥?In-memory session message store with JSONL persistence.
3
+ *
4
+ * CC alignment: messages live in memory during the session lifetime.
5
+ * JSONL is the sole persistent source of truth (for crash recovery).
6
+ * Gateway never owns message data 鈥?Agent is the single authority.
7
+ *
8
+ * Design:
9
+ * - Map<sessionId, ChatMessage[]> holds active session messages
10
+ * - On first access, lazy-loads from transcript.jsonl
11
+ * - appendMessage() writes to memory AND appends to JSONL atomically
12
+ * - getMessages() returns from memory (no disk I/O on hot path)
13
+ */
14
+ import type { ChatMessage } from "../../protocol/wire/index.js";
15
+ export declare class SessionMemory {
16
+ private sessions;
17
+ private projectRoot;
18
+ constructor(projectRoot?: string);
19
+ setProjectRoot(projectRoot: string): void;
20
+ /**
21
+ * Get messages for a session. Lazy-loads from JSONL on first access.
22
+ */
23
+ getMessages(sessionId: string): ChatMessage[];
24
+ /**
25
+ * Append a message to session memory and persist to JSONL.
26
+ */
27
+ appendMessage(sessionId: string, message: ChatMessage, turnId?: string): void;
28
+ /**
29
+ * Check if a session is loaded in memory.
30
+ */
31
+ hasSession(sessionId: string): boolean;
32
+ /**
33
+ * Initialize an empty session (for newly created sessions).
34
+ */
35
+ initSession(sessionId: string): void;
36
+ /**
37
+ * Drop a session from memory (e.g., on session.ended).
38
+ * Does NOT delete JSONL 鈥?data persists for future resume.
39
+ */
40
+ evictSession(sessionId: string): void;
41
+ /**
42
+ * Get the count of messages in a session.
43
+ */
44
+ getMessageCount(sessionId: string): number;
45
+ private loadFromDisk;
46
+ }
@@ -1,5 +1,5 @@
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)
@@ -9,18 +9,18 @@
9
9
  * Storage layout:
10
10
  * <project>/.qlogicagent/sessions/<session-id>/ (when projectRoot provided)
11
11
  * ~/.qlogicagent/sessions/<session-id>/ (fallback)
12
- * transcript.jsonl append-only message log
13
- * state.json cost snapshot + metadata
12
+ * transcript.jsonl 鈥?append-only message log
13
+ * state.json 鈥?cost snapshot + metadata
14
14
  *
15
15
  * Resume flow (CC processResumedConversation parity):
16
- * 1. loadSessionForResume(sessionId) messages + cost
16
+ * 1. loadSessionForResume(sessionId) 鈫?messages + cost
17
17
  * 2. Restore cost state into SessionState
18
18
  * 3. Feed messages as initial context to agent
19
19
  *
20
20
  * Reference: claude-code src/utils/sessionRestore.ts
21
21
  * claude-code src/utils/conversationRecovery.ts
22
22
  */
23
- import type { ChatMessage } from "../../agent/types.js";
23
+ import type { ChatMessage } from "../../protocol/wire/index.js";
24
24
  import type { SessionCostSnapshot } from "./session-state.js";
25
25
  export interface SessionMetadata {
26
26
  sessionId: string;
@@ -36,6 +36,22 @@ export interface SessionMetadata {
36
36
  taskSummary?: string;
37
37
  /** Timestamp of last task summary generation */
38
38
  taskSummaryGeneratedAt?: number;
39
+ /** ISO timestamp 鈥?session pinned in UI */
40
+ pinnedAt?: string;
41
+ /** ISO timestamp 鈥?session archived (soft-deleted) */
42
+ archivedAt?: string;
43
+ /** Project ID this session belongs to */
44
+ projectId?: string;
45
+ /** Session type: personal or group */
46
+ type?: "personal" | "group";
47
+ /** Owner user ID */
48
+ ownerId?: string;
49
+ /** Group key for group sessions */
50
+ groupKey?: string;
51
+ /** Group display name */
52
+ groupName?: string;
53
+ /** Group platform (wechat, dingtalk, etc.) */
54
+ groupPlatform?: string;
39
55
  }
40
56
  export interface PersistedSession {
41
57
  metadata: SessionMetadata;
@@ -48,6 +64,11 @@ export interface SessionListEntry {
48
64
  lastActiveAt: number;
49
65
  messageCount: number;
50
66
  model?: string;
67
+ pinnedAt?: string;
68
+ archivedAt?: string;
69
+ projectId?: string;
70
+ type?: "personal" | "group";
71
+ createdAt?: number;
51
72
  }
52
73
  /**
53
74
  * Append a message to the session transcript.
@@ -61,13 +82,18 @@ export declare function appendMessage(sessionId: string, message: ChatMessage, p
61
82
  */
62
83
  export declare function saveSessionState(sessionId: string, costSnapshot: SessionCostSnapshot, metadata: Partial<SessionMetadata>, projectRoot?: string): Promise<void>;
63
84
  /**
64
- * Load a persisted session for resume CC loadConversationForResume parity.
85
+ * Update specific metadata fields of a session without touching cost data.
86
+ * Used by session CRUD RPC (rename, pin, archive, move-to-project).
87
+ */
88
+ export declare function updateSessionMetadata(sessionId: string, patch: Partial<SessionMetadata>, projectRoot?: string): Promise<SessionMetadata | null>;
89
+ /**
90
+ * Load a persisted session for resume 鈥?CC loadConversationForResume parity.
65
91
  *
66
92
  * Returns null if the session doesn't exist or is corrupted.
67
93
  */
68
94
  export declare function loadSessionForResume(sessionId: string, projectRoot?: string): Promise<PersistedSession | null>;
69
95
  /**
70
- * List available sessions for resume CC ResumeConversation picker.
96
+ * List available sessions for resume 鈥?CC ResumeConversation picker.
71
97
  * Returns most-recent-first, up to `limit` entries.
72
98
  */
73
99
  export declare function listSessions(limit?: number, projectRoot?: string): Promise<SessionListEntry[]>;
@@ -92,6 +118,6 @@ export interface TaskSummaryDeps {
92
118
  export declare function shouldGenerateTaskSummary(metadata: SessionMetadata): boolean;
93
119
  /**
94
120
  * Generate and persist a task summary for a long session.
95
- * Fire-and-forget errors are swallowed.
121
+ * Fire-and-forget 鈥?errors are swallowed.
96
122
  */
97
123
  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
@@ -13,8 +13,8 @@
13
13
  *
14
14
  * Reference: claude-code src/bootstrap/state.ts, src/cost-tracker.ts
15
15
  */
16
- import type { TokenUsage } from "../../agent/types.js";
17
- /** Per-model usage accumulation CC modelUsage parity */
16
+ import type { WireTokenUsage as TokenUsage } from "../../protocol/wire/index.js";
17
+ /** Per-model usage accumulation 鈥?CC modelUsage parity */
18
18
  export interface ModelUsage {
19
19
  inputTokens: number;
20
20
  outputTokens: number;
@@ -59,7 +59,7 @@ export declare class SessionState {
59
59
  /** Get all model usages as a plain object */
60
60
  getAllModelUsage(): Record<string, ModelUsage>;
61
61
  /**
62
- * Add usage from an API response CC addToTotalSessionCost() parity.
62
+ * Add usage from an API response 鈥?CC addToTotalSessionCost() parity.
63
63
  * Tracks token counts only; pricing is handled by Hub/Admin.
64
64
  *
65
65
  * @param usage - Token counts from the API response
@@ -1,4 +1,4 @@
1
- import type { MemoryProvider, MemorySearchResult } from "qlogicagent-runtime-contracts";
1
+ import type { MemoryProvider, MemorySearchResult } from "../../protocol/wire/index.js";
2
2
  import type { Memdir } from "./memdir.js";
3
3
  export declare const MEMORY_TOOL_NAME: "memory";
4
4
  export declare const MEMORY_TOOL_LABEL = "Memory";
@@ -1,4 +1,4 @@
1
- import type { MemoryIngestOptions, MemoryProvider } from "qlogicagent-runtime-contracts";
1
+ import type { MemoryIngestOptions, MemoryProvider } from "../../protocol/wire/index.js";
2
2
  /** A pre-extracted memory item ready to be stored (no LLM needed). */
3
3
  export interface ExtractedMemoryItem {
4
4
  text: string;
@@ -1,5 +1,5 @@
1
1
  import type { HookRegistry } from "../../contracts/hooks.js";
2
- import type { ToolDefinition } from "../../agent/types.js";
2
+ import type { ToolDefinition } from "../../protocol/wire/index.js";
3
3
  import { PermissionRuleEngine } from "./rule-engine.js";
4
4
  import type { PermissionUpdate, ApprovalRequest, ApprovalResponse } from "./types.js";
5
5
  import { type ClassifierLLMCall } from "./permission-classifier.js";
@@ -47,11 +47,11 @@ export declare class PermissionChecker {
47
47
  private readonly permissionRole;
48
48
  private readonly pendingApprovals;
49
49
  private unregisterHook;
50
- /** Tool meta cache populated from ToolDefinition[] at agent creation */
50
+ /** Tool meta cache 鈥?populated from ToolDefinition[] at agent creation */
51
51
  private toolMetaCache;
52
- /** Classifier result cache avoids redundant LLM calls (CC permissionCache parity) */
52
+ /** Classifier result cache 鈥?avoids redundant LLM calls (CC permissionCache parity) */
53
53
  private classifierCache;
54
- /** Denial tracking state CC denialTracking.ts parity */
54
+ /** Denial tracking state 鈥?CC denialTracking.ts parity */
55
55
  private denialTracking;
56
56
  constructor(deps: PermissionCheckerDeps);
57
57
  /**
@@ -1,4 +1,4 @@
1
- import type { ChatMessage } from "../../agent/types.js";
1
+ import type { ChatMessage } from "../../protocol/wire/index.js";
2
2
  export interface ClassifierResult {
3
3
  shouldBlock: boolean;
4
4
  reason: string;
@@ -6,7 +6,7 @@ export interface ClassifierResult {
6
6
  durationMs: number;
7
7
  }
8
8
  /**
9
- * LLM call interface injected by the host so the classifier
9
+ * LLM call interface 鈥?injected by the host so the classifier
10
10
  * doesn't depend on a specific LLM client.
11
11
  */
12
12
  export interface ClassifierLLMCall {