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
@@ -4,6 +4,7 @@ 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";
6
6
  import type { PermissionRole } from "../../orchestration/subagent/task-types.js";
7
+ import { DenialAuditLogger } from "./denial-audit-log.js";
7
8
  export interface PermissionCheckerDeps {
8
9
  ruleEngine: PermissionRuleEngine;
9
10
  hookRegistry: HookRegistry;
@@ -35,6 +36,12 @@ export interface PermissionCheckerDeps {
35
36
  * - worker: classifier-only path, no approval dialog fallback
36
37
  */
37
38
  permissionRole?: PermissionRole;
39
+ /** Denial audit logger for persistent audit trail. */
40
+ auditLogger?: DenialAuditLogger;
41
+ /** Current session ID (for audit context). */
42
+ sessionId?: string;
43
+ /** Getter for current turn ID (changes per turn). */
44
+ getTurnId?: () => string;
38
45
  }
39
46
  export declare class PermissionChecker {
40
47
  private readonly ruleEngine;
@@ -46,12 +53,15 @@ export declare class PermissionChecker {
46
53
  private readonly getRecentMessages;
47
54
  private readonly permissionRole;
48
55
  private readonly pendingApprovals;
56
+ private readonly auditLogger;
57
+ private readonly sessionId;
58
+ private readonly getTurnId;
49
59
  private unregisterHook;
50
- /** Tool meta cache 鈥?populated from ToolDefinition[] at agent creation */
60
+ /** Tool meta cache populated from ToolDefinition[] at agent creation */
51
61
  private toolMetaCache;
52
- /** Classifier result cache 鈥?avoids redundant LLM calls (CC permissionCache parity) */
62
+ /** Classifier result cache avoids redundant LLM calls (CC permissionCache parity) */
53
63
  private classifierCache;
54
- /** Denial tracking state 鈥?CC denialTracking.ts parity */
64
+ /** Denial tracking state CC denialTracking.ts parity */
55
65
  private denialTracking;
56
66
  constructor(deps: PermissionCheckerDeps);
57
67
  /**
@@ -68,7 +78,7 @@ export declare class PermissionChecker {
68
78
  */
69
79
  setToolMeta(tools: ToolDefinition[]): void;
70
80
  get ruleEngineRef(): PermissionRuleEngine;
71
- /** Fire permission.denied hook + onDenied callback */
81
+ /** Fire permission.denied hook + onDenied callback + audit log */
72
82
  private fireDenied;
73
83
  private handleResult;
74
84
  /**
@@ -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 interfaceinjected by the host so the classifier
10
10
  * doesn't depend on a specific LLM client.
11
11
  */
12
12
  export interface ClassifierLLMCall {
@@ -0,0 +1,81 @@
1
+ export type SkillLifecycleState = "active" | "stale" | "archived";
2
+ export interface SkillLifecycleRecord {
3
+ name: string;
4
+ state: SkillLifecycleState;
5
+ createdAt: string;
6
+ lastUsedAt?: string;
7
+ lastViewedAt?: string;
8
+ lastPatchedAt?: string;
9
+ staleAt?: string;
10
+ archivedAt?: string;
11
+ pinned: boolean;
12
+ useCount: number;
13
+ source: "learned" | "created" | "installed" | "promoted";
14
+ }
15
+ export interface SkillLifecycleStore {
16
+ version: 1;
17
+ records: Record<string, SkillLifecycleRecord>;
18
+ }
19
+ export interface CuratorResult {
20
+ transitioned: Array<{
21
+ name: string;
22
+ from: SkillLifecycleState;
23
+ to: SkillLifecycleState;
24
+ }>;
25
+ skippedPinned: string[];
26
+ }
27
+ export declare function loadLifecycleStore(agentHome: string): SkillLifecycleStore;
28
+ export declare function saveLifecycleStore(agentHome: string, store: SkillLifecycleStore): void;
29
+ /**
30
+ * Ensure a lifecycle record exists for a skill. Creates one if missing.
31
+ */
32
+ export declare function ensureRecord(store: SkillLifecycleStore, name: string, source?: SkillLifecycleRecord["source"]): SkillLifecycleRecord;
33
+ /**
34
+ * Record a skill invocation — resets to active if stale.
35
+ */
36
+ export declare function recordInvocation(store: SkillLifecycleStore, name: string): void;
37
+ /**
38
+ * Record that a skill was viewed/listed.
39
+ */
40
+ export declare function recordView(store: SkillLifecycleStore, name: string): void;
41
+ /**
42
+ * Record that a skill was edited/patched.
43
+ */
44
+ export declare function recordPatch(store: SkillLifecycleStore, name: string): void;
45
+ export declare function pinSkill(store: SkillLifecycleStore, name: string): boolean;
46
+ export declare function unpinSkill(store: SkillLifecycleStore, name: string): boolean;
47
+ export declare function isPinned(store: SkillLifecycleStore, name: string): boolean;
48
+ /**
49
+ * Run curator evaluation on all skills. Transitions states based on inactivity.
50
+ * Pinned skills are never transitioned.
51
+ *
52
+ * Call this on agent idle, periodic timer, or explicit RPC.
53
+ */
54
+ export declare function runCurator(store: SkillLifecycleStore): CuratorResult;
55
+ /**
56
+ * Archive a skill on disk: move its directory to `.archive/` subfolder.
57
+ * Returns true if archival succeeded.
58
+ */
59
+ export declare function archiveSkillOnDisk(skillsDir: string, skillName: string): boolean;
60
+ /**
61
+ * Unarchive a skill: move from `.archive/` back to main skills dir.
62
+ * Resets state to active.
63
+ */
64
+ export declare function unarchiveSkillOnDisk(skillsDir: string, skillName: string): boolean;
65
+ /**
66
+ * Execute full curator cycle: evaluate state transitions + archive on disk.
67
+ * Returns curator result with all transitions made.
68
+ */
69
+ export declare function executeCuratorCycle(agentHome: string, skillsDir: string): CuratorResult;
70
+ /**
71
+ * Get all skills in a given state.
72
+ */
73
+ export declare function getSkillsByState(store: SkillLifecycleStore, state: SkillLifecycleState): SkillLifecycleRecord[];
74
+ /**
75
+ * Get lifecycle record for a skill. Returns undefined if not tracked.
76
+ */
77
+ export declare function getLifecycleRecord(store: SkillLifecycleStore, name: string): SkillLifecycleRecord | undefined;
78
+ /**
79
+ * Remove a lifecycle record (e.g., when skill is deleted).
80
+ */
81
+ export declare function removeRecord(store: SkillLifecycleStore, name: string): void;
@@ -0,0 +1,29 @@
1
+ export interface FrontmatterValidationResult {
2
+ valid: boolean;
3
+ errors: string[];
4
+ warnings: string[];
5
+ /** Parsed frontmatter if valid. */
6
+ parsed?: Record<string, string>;
7
+ }
8
+ /**
9
+ * Validate SKILL.md content for required frontmatter structure.
10
+ * Used before persisting agent-created skills.
11
+ */
12
+ export declare function validateSkillContent(content: string, expectedName?: string): FrontmatterValidationResult;
13
+ /**
14
+ * Generate valid SKILL.md content with proper frontmatter from minimal inputs.
15
+ * Used when auto-persisting skills from skill_instruction events.
16
+ */
17
+ export declare function generateSkillContent(params: {
18
+ name: string;
19
+ description: string;
20
+ tools?: string[];
21
+ body: string;
22
+ version?: string;
23
+ category?: string;
24
+ }): string;
25
+ /**
26
+ * Auto-fix common frontmatter issues in LLM-generated skill content.
27
+ * Returns fixed content or null if unfixable.
28
+ */
29
+ export declare function autoFixFrontmatter(content: string, name: string, description?: string): string | null;
@@ -14,7 +14,7 @@ export declare const EXEC_TOOL_SCHEMA: {
14
14
  readonly properties: {
15
15
  readonly command: {
16
16
  readonly type: "string";
17
- readonly description: "Shell command to execute. On Windows uses PowerShell, on Unix uses bash.";
17
+ readonly description: "Shell command to execute in PowerShell." | "Shell command to execute in bash. Use Unix-style commands (ls, cat, mkdir -p, etc.).";
18
18
  };
19
19
  readonly description: {
20
20
  readonly type: "string";
@@ -87,7 +87,7 @@ export interface SearchToolDeps {
87
87
  * The implementation may use ripgrep, native grep, or a custom engine.
88
88
  * Returns match records.
89
89
  * The host SHOULD auto-exclude VCS directories (.git, .svn, .hg, .bzr)
90
- * and enforce --max-columns 500 to avoid minified file noise.
90
+ * and enforcemax-columns 500 to avoid minified file noise.
91
91
  */
92
92
  grep(pattern: string, options: {
93
93
  cwd: string;
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Tool Registry 鈥?CC-aligned getAllBaseTools() pattern.
2
+ * Tool RegistryCC-aligned getAllBaseTools() pattern.
3
3
  *
4
4
  * CC reference: claude-code-haha/src/tools.ts
5
5
  *
@@ -52,7 +52,7 @@ export declare function getToolCount(): number;
52
52
  */
53
53
  export declare function executeTool(name: string, toolCallId: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<import("./portable-tool.js").PortableToolResult>;
54
54
  /**
55
- * CC: getTools() 鈥?return all enabled tools.
55
+ * CC: getTools()return all enabled tools.
56
56
  * Filters the pool by isEnabled() gate; disabled tools are invisible to callers.
57
57
  * CC reference: claude-code-haha/src/tools.ts getTools()
58
58
  */
@@ -73,7 +73,7 @@ export declare function isToolActivated(name: string): boolean;
73
73
  export declare function clearActivatedTools(): void;
74
74
  /**
75
75
  * Generate ToolDefinition[] manifest for LLM tool_use.
76
- * Filters by isEnabled() 鈥?disabled tools never reach the model.
76
+ * Filters by isEnabled()disabled tools never reach the model.
77
77
  * Deferred tools are excluded UNLESS they have been activated via tool_search.
78
78
  * CC: getTools() + manifest generation combined.
79
79
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * ACP Event Emitter 鈥?translates internal qlogicagent notifications to ACP
2
+ * ACP Event Emittertranslates internal qlogicagent notifications to ACP
3
3
  * session/update notifications.
4
4
  *
5
5
  * Maps the 47+ internal notification methods (turn.delta, turn.tool_call, etc.)
@@ -1,5 +1,5 @@
1
1
  /**
2
- * ACP Server 鈥?Agent-Client Protocol server layer for qlogicagent.
2
+ * ACP ServerAgent-Client Protocol server layer for qlogicagent.
3
3
  *
4
4
  * This module implements qlogicagent as an ACP Server, allowing any ACP-compliant
5
5
  * host (AionUI, Cursor, openclaw, etc.) to connect and interact with the agent.
@@ -60,7 +60,12 @@ export interface AcpRequestHandler {
60
60
  handleAcpSoloSelect(params: Record<string, unknown>): Promise<unknown>;
61
61
  handleAcpSoloCancel(params: Record<string, unknown>): Promise<unknown>;
62
62
  handleAcpSoloSubscribe(params: Record<string, unknown>): Promise<unknown>;
63
+ handleAcpSoloMessage(params: Record<string, unknown>): Promise<unknown>;
64
+ handleAcpSoloEvaluate(params: Record<string, unknown>): Promise<unknown>;
63
65
  handleAcpProductCreate(params: Record<string, unknown>): Promise<unknown>;
66
+ handleAcpProductPlan(params: Record<string, unknown>): Promise<unknown>;
67
+ handleAcpProductConfirm(params: Record<string, unknown>): Promise<unknown>;
68
+ handleAcpProductMessage(params: Record<string, unknown>): Promise<unknown>;
64
69
  handleAcpProductPause(params: Record<string, unknown>): Promise<unknown>;
65
70
  handleAcpProductResume(params: Record<string, unknown>): Promise<unknown>;
66
71
  handleAcpProductCancel(params: Record<string, unknown>): Promise<unknown>;
@@ -73,7 +78,7 @@ export interface AcpServerConfig {
73
78
  verbose?: boolean;
74
79
  }
75
80
  /**
76
- * AcpServer 鈥?manages the ACP protocol state machine.
81
+ * AcpServermanages the ACP protocol state machine.
77
82
  *
78
83
  * Lifecycle:
79
84
  * 1. Host connects (stdio)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qlogicagent",
3
- "version": "2.6.1",
3
+ "version": "2.9.0",
4
4
  "description": "XiaozhiClaw Agent CLI — subprocess architecture (JSON-RPC over stdio)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -34,10 +34,18 @@
34
34
  ],
35
35
  "typesVersions": {
36
36
  "*": {
37
- "protocol": ["./dist/types/protocol/wire/index.d.ts"],
38
- "agent": ["./dist/types/agent/agent.d.ts"],
39
- "contracts": ["./dist/types/contracts/index.d.ts"],
40
- "orchestration": ["./dist/types/orchestration/index.d.ts"]
37
+ "protocol": [
38
+ "./dist/types/protocol/wire/index.d.ts"
39
+ ],
40
+ "agent": [
41
+ "./dist/types/agent/agent.d.ts"
42
+ ],
43
+ "contracts": [
44
+ "./dist/types/contracts/index.d.ts"
45
+ ],
46
+ "orchestration": [
47
+ "./dist/types/orchestration/index.d.ts"
48
+ ]
41
49
  }
42
50
  },
43
51
  "scripts": {
@@ -54,12 +62,18 @@
54
62
  "node": ">=22.0.0"
55
63
  },
56
64
  "dependencies": {
65
+ "@qlogic/provider-core": "workspace:*",
66
+ "better-sqlite3": "^12.10.0",
57
67
  "dotenv": "^17.3.1",
58
68
  "nanoid": "^5.1.5",
59
69
  "pino": "^9.6.0",
60
70
  "pino-pretty": "^13.0.0"
61
71
  },
72
+ "optionalDependencies": {
73
+ "@xenova/transformers": "^2.17.2"
74
+ },
62
75
  "devDependencies": {
76
+ "@types/better-sqlite3": "^7.6.13",
63
77
  "@types/node": "^22.15.0",
64
78
  "esbuild": "^0.28.0",
65
79
  "tsx": "^4.19.0",
@@ -1,44 +0,0 @@
1
- /**
2
- * Aliyun OSS File Upload Adapter — direct upload to Alibaba Cloud OSS.
3
- *
4
- * Uploads files directly to OSS bucket using V1 signature (HMAC-SHA1).
5
- * No external dependencies — uses Node.js crypto + fetch.
6
- *
7
- * This is the **universal fallback adapter** for providers without a native
8
- * File Upload API (e.g. Anthropic). Ensures ALL file handling goes through
9
- * upload — never base64 inline.
10
- *
11
- * Environment variables:
12
- * OSS_ACCESS_KEY_ID — Aliyun AccessKey ID
13
- * OSS_ACCESS_KEY_SECRET — Aliyun AccessKey Secret
14
- * OSS_BUCKET — Bucket name (default: "qlogicagent")
15
- * OSS_REGION — Region (default: "cn-beijing")
16
- * OSS_ENDPOINT — Custom endpoint (default: derived from region)
17
- */
18
- import type { FileUploadAdapter, FileUploadResult } from "../file-upload-service.js";
19
- export interface AliyunOSSFileUploadConfig {
20
- /** Aliyun AccessKey ID. Required. */
21
- accessKeyId: string;
22
- /** Aliyun AccessKey Secret. Required. */
23
- accessKeySecret: string;
24
- /** OSS Bucket name. Default: "qlogicagent". */
25
- bucket?: string;
26
- /** OSS Region. Default: "cn-beijing". */
27
- region?: string;
28
- /** Custom OSS endpoint. Default: "{bucket}.oss-{region}.aliyuncs.com". */
29
- endpoint?: string;
30
- /** Upload path prefix. Default: "media". */
31
- pathPrefix?: string;
32
- /** Timeout ms. Default: 120_000. */
33
- timeoutMs?: number;
34
- }
35
- /**
36
- * Create an AliyunOSSFileUploadAdapter from environment variables.
37
- * Returns undefined if required env vars (OSS_ACCESS_KEY_ID, OSS_ACCESS_KEY_SECRET) are missing.
38
- */
39
- export declare function createAliyunOSSAdapterFromEnv(): AliyunOSSFileUploadAdapter | undefined;
40
- export declare class AliyunOSSFileUploadAdapter implements FileUploadAdapter {
41
- private readonly config;
42
- constructor(config: AliyunOSSFileUploadConfig);
43
- uploadFile(buffer: Buffer, filename: string, mimeType: string, _apiKey: string, signal?: AbortSignal): Promise<FileUploadResult>;
44
- }
@@ -1,26 +0,0 @@
1
- /**
2
- * Gemini File Upload Adapter.
3
- *
4
- * Implements the Google Gemini 2-step resumable upload protocol
5
- * into the unified FileUploadAdapter interface.
6
- *
7
- * Protocol:
8
- * 1. POST /upload/v1beta/files — initiate, get upload URL
9
- * 2. PUT {uploadUrl} — send bytes, finalize
10
- *
11
- * Returns a file URI (e.g. "files/abc123") that can be used in
12
- * generateContent requests as a file reference.
13
- */
14
- import type { FileUploadAdapter, FileUploadResult } from "../file-upload-service.js";
15
- export interface GeminiFileUploadConfig {
16
- /** Base URL (e.g. "https://generativelanguage.googleapis.com/v1beta") */
17
- baseUrl: string;
18
- /** Timeout ms. Default: 180_000. */
19
- timeoutMs?: number;
20
- }
21
- export declare class GeminiFileUploadAdapter implements FileUploadAdapter {
22
- private readonly config;
23
- constructor(config: GeminiFileUploadConfig);
24
- uploadFile(buffer: Buffer, filename: string, mimeType: string, apiKey: string, signal?: AbortSignal): Promise<FileUploadResult>;
25
- private waitForProcessing;
26
- }
@@ -1,29 +0,0 @@
1
- /**
2
- * Hub OSS File Upload Adapter — for providers without native File API (e.g. Anthropic).
3
- *
4
- * Uploads local files to the Hub's OSS relay endpoint, which stores them in
5
- * cloud object storage (Aliyun OSS / Tencent COS) and returns a public URL.
6
- * The LLM provider can then access the file via this public URL.
7
- *
8
- * This enables Anthropic (which only supports base64 inline or public URL)
9
- * to handle large files that exceed the base64 size limit (20MB).
10
- *
11
- * Endpoint: POST {hubBaseUrl}/api/v1/files/upload
12
- * Returns: { url: "https://oss-bucket.oss-cn-xxx.aliyuncs.com/..." }
13
- */
14
- import type { FileUploadAdapter, FileUploadResult } from "../file-upload-service.js";
15
- export interface HubOSSFileUploadConfig {
16
- /** Hub API base URL (e.g. "https://hub.xiaozhiclaw.com" or from env). */
17
- hubBaseUrl: string;
18
- /** Hub API key for authentication. */
19
- hubApiKey?: string;
20
- /** Timeout ms. Default: 120_000. */
21
- timeoutMs?: number;
22
- /** Provider name for result metadata. Default: "hub-oss". */
23
- provider?: string;
24
- }
25
- export declare class HubOSSFileUploadAdapter implements FileUploadAdapter {
26
- private readonly config;
27
- constructor(config: HubOSSFileUploadConfig);
28
- uploadFile(buffer: Buffer, filename: string, mimeType: string, _apiKey: string, signal?: AbortSignal): Promise<FileUploadResult>;
29
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * File Upload Adapters — barrel export.
3
- *
4
- * Provider-specific implementations of the FileUploadAdapter interface.
5
- */
6
- export { OpenAIFileUploadAdapter, type OpenAIFileUploadConfig } from "./openai-file-upload-adapter.js";
7
- export { VolcengineFileUploadAdapter, type VolcengineFileUploadConfig } from "./volcengine-file-upload-adapter.js";
8
- export { GeminiFileUploadAdapter, type GeminiFileUploadConfig } from "./gemini-file-upload-adapter.js";
9
- export { HubOSSFileUploadAdapter, type HubOSSFileUploadConfig } from "./hub-oss-file-upload-adapter.js";
10
- export { AliyunOSSFileUploadAdapter, type AliyunOSSFileUploadConfig, createAliyunOSSAdapterFromEnv } from "./aliyun-oss-file-upload-adapter.js";
@@ -1,38 +0,0 @@
1
- /**
2
- * OpenAI-compatible File Upload Adapter.
3
- *
4
- * Implements FileUploadAdapter for providers using the standard
5
- * POST /v1/files multipart upload endpoint:
6
- * - OpenAI
7
- * - Kimi (Moonshot)
8
- * - Minimax
9
- * - Qwen (via DashScope compatible endpoint)
10
- * - GLM (Zhipu)
11
- * - Any OpenAI-API-compatible provider
12
- *
13
- * The uploaded file gets a file_id which can be referenced in messages.
14
- * Some providers also return a direct download URL.
15
- */
16
- import type { FileUploadAdapter, FileUploadResult } from "../file-upload-service.js";
17
- export interface OpenAIFileUploadConfig {
18
- /** Base URL (e.g. "https://api.openai.com/v1" or "https://api.moonshot.cn/v1") */
19
- baseUrl: string;
20
- /** Provider name for result metadata. */
21
- provider: string;
22
- /** Extra headers to include (e.g. for Minimax group_id). */
23
- extraHeaders?: Record<string, string>;
24
- /** Upload purpose (default: "file-extract" for document understanding). */
25
- defaultPurpose?: string;
26
- /**
27
- * Whether the provider returns a download URL in the upload response.
28
- * If false, constructs URL from file_id (provider-specific).
29
- */
30
- returnsUrl?: boolean;
31
- /** Timeout for upload request (ms). Default: 120_000. */
32
- timeoutMs?: number;
33
- }
34
- export declare class OpenAIFileUploadAdapter implements FileUploadAdapter {
35
- private readonly config;
36
- constructor(config: OpenAIFileUploadConfig);
37
- uploadFile(buffer: Buffer, filename: string, mimeType: string, apiKey: string, signal?: AbortSignal): Promise<FileUploadResult>;
38
- }
@@ -1,24 +0,0 @@
1
- /**
2
- * Volcengine File Upload Adapter.
3
- *
4
- * Wraps the Volcengine /v3/files endpoint into the unified
5
- * FileUploadAdapter interface.
6
- *
7
- * Volcengine returns a file_id that can be used in API messages
8
- * as a file reference. Files uploaded this way can be referenced in
9
- * multimodal inputs via the file_id field.
10
- */
11
- import type { FileUploadAdapter, FileUploadResult } from "../file-upload-service.js";
12
- export interface VolcengineFileUploadConfig {
13
- /** Base URL (e.g. "https://ark.cn-beijing.volces.com/api") */
14
- baseUrl: string;
15
- /** Upload purpose. Default: "user_data". */
16
- defaultPurpose?: string;
17
- /** Timeout ms. Default: 120_000. */
18
- timeoutMs?: number;
19
- }
20
- export declare class VolcengineFileUploadAdapter implements FileUploadAdapter {
21
- private readonly config;
22
- constructor(config: VolcengineFileUploadConfig);
23
- uploadFile(buffer: Buffer, filename: string, mimeType: string, apiKey: string, signal?: AbortSignal): Promise<FileUploadResult>;
24
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * Builtin provider definitions — hardcoded fallback list (~30 providers).
3
- *
4
- * This is Layer 1 (lowest priority) of the three-layer merge strategy.
5
- * Used when remote model catalog is unavailable.
6
- *
7
- * Aligned with Hermes hermes_cli/models.py hardcoded fallback.
8
- */
9
- import type { ProviderDef } from "./provider-def.js";
10
- export declare const BUILTIN_PROVIDERS: ProviderDef[];
@@ -1,12 +0,0 @@
1
- import type { LLMTransport } from "./transport.js";
2
- /**
3
- * Check whether debug transport should be enabled.
4
- */
5
- export declare function isDebugTransportEnabled(): boolean;
6
- /**
7
- * Create a DebugTransport decorator that wraps a base LLMTransport,
8
- * logging request metadata + timing + usage to JSONL.
9
- *
10
- * CC parity: createDumpPromptsFetch — but vendor-agnostic via transport abstraction.
11
- */
12
- export declare function createDebugTransport(base: LLMTransport, sessionId: string): LLMTransport;
@@ -1,68 +0,0 @@
1
- /**
2
- * FileUploadService — Unified file upload abstraction for all LLM providers.
3
- *
4
- * Replaces the base64 approach in media-resolve.ts. When a local URL is
5
- * encountered, this service uploads the file to the current provider's
6
- * File API and returns a public URL or file_id.
7
- *
8
- * Supported providers:
9
- * - OpenAI-compatible (OpenAI, Kimi, Minimax, Qwen, GLM) — POST /v1/files
10
- * - Volcengine — POST /v3/files
11
- * - Google Gemini — Resumable upload protocol
12
- *
13
- * Architecture:
14
- * Transport layer calls resolveLocalMedia() before sending messages.
15
- * resolveLocalMedia() fetches local content and uploads to provider,
16
- * returning a public URL the LLM can access.
17
- */
18
- export interface FileUploadResult {
19
- /** Public URL accessible by the LLM provider. */
20
- url: string;
21
- /** Provider-specific file identifier (for reference/deletion). */
22
- fileId: string;
23
- /** Original filename. */
24
- filename: string;
25
- /** File size in bytes. */
26
- bytes: number;
27
- /** MIME type of the uploaded file. */
28
- mimeType: string;
29
- /** Provider that stored the file. */
30
- provider: string;
31
- }
32
- /**
33
- * Provider-specific upload adapter.
34
- * Each transport implements this to upload files to its own File API.
35
- */
36
- export interface FileUploadAdapter {
37
- /**
38
- * Upload a file buffer and return a publicly accessible URL.
39
- * @param buffer - File content
40
- * @param filename - Original filename (used for MIME detection)
41
- * @param mimeType - MIME type of the file
42
- * @param apiKey - Provider API key
43
- * @param signal - Abort signal
44
- */
45
- uploadFile(buffer: Buffer, filename: string, mimeType: string, apiKey: string, signal?: AbortSignal): Promise<FileUploadResult>;
46
- }
47
- /** Guess MIME type from filename extension. */
48
- export declare function guessMimeType(filename: string): string;
49
- /** Check if a URL points to a local/private address that cloud APIs cannot reach. */
50
- export declare function isLocalUrl(url: string): boolean;
51
- /**
52
- * Resolve a local URL by uploading its content to the provider's File API.
53
- * Public URLs are returned as-is (the LLM API can fetch them directly).
54
- *
55
- * @param url - The URL to resolve (may be local or public)
56
- * @param adapter - Provider-specific upload adapter
57
- * @param apiKey - API key for the upload
58
- * @param signal - Optional abort signal
59
- * @returns Public URL accessible by the LLM
60
- */
61
- export declare function resolveLocalMedia(url: string, adapter: FileUploadAdapter, apiKey: string, signal?: AbortSignal): Promise<string>;
62
- /**
63
- * Batch-resolve multiple URLs concurrently. Returns array in same order.
64
- * Local URLs are uploaded; public URLs pass through unchanged.
65
- * Supports concurrent uploads (up to `concurrency` limit, default 3).
66
- * Failures throw (caller should handle).
67
- */
68
- export declare function resolveLocalMediaBatch(urls: string[], adapter: FileUploadAdapter, apiKey: string, signal?: AbortSignal, concurrency?: number): Promise<string[]>;
@@ -1,17 +0,0 @@
1
- /**
2
- * Gemini JSON Schema cleaning utilities.
3
- *
4
- * Gemini's generateContent API rejects several standard JSON Schema keywords.
5
- * This module provides a shared recursive cleaner used by:
6
- * - GeminiGenerateContentTransport (tool declarations in request body)
7
- * - tool-schema.ts (provider-aware schema normalization at orchestration level)
8
- *
9
- * Keeping a single source of truth avoids drift between the two consumers.
10
- */
11
- /** Keywords that Gemini's generateContent API does not accept in tool schemas. */
12
- export declare const GEMINI_UNSUPPORTED_SCHEMA_KEYWORDS: Set<string>;
13
- /**
14
- * Recursively strip unsupported JSON Schema keywords from a schema object.
15
- * Safe to call multiple times (idempotent).
16
- */
17
- export declare function cleanSchemaForGemini(schema: unknown): unknown;
@@ -1,43 +0,0 @@
1
- /**
2
- * LLM Client factory — resolves ProviderDef → creates LLMTransport instance.
3
- *
4
- * Replaces the old createAdminInferProxyClient() call chain.
5
- * User API key + ProviderDef → direct provider connection.
6
- */
7
- import type { ProviderDef } from "./provider-def.js";
8
- import type { LLMTransport } from "./transport.js";
9
- import { ProviderRegistry } from "./provider-registry.js";
10
- export interface LLMClientConfig {
11
- /** Provider id, e.g. "deepseek" */
12
- provider: string;
13
- /** Model id, e.g. "deepseek-v4-flash" */
14
- model: string;
15
- /** User API key */
16
- apiKey: string;
17
- /** Optional base URL override */
18
- baseUrl?: string;
19
- }
20
- export interface LLMClient {
21
- transport: LLMTransport;
22
- apiKey: string;
23
- resolvedModel: string;
24
- providerDef: ProviderDef;
25
- }
26
- /**
27
- * Create an LLM client from config + registry.
28
- *
29
- * 1. Look up provider in registry
30
- * 2. Apply baseUrl override if provided
31
- * 3. Instantiate the correct transport
32
- */
33
- export declare function createLLMClient(config: LLMClientConfig, registry: ProviderRegistry): LLMClient;
34
- /**
35
- * Auto-detect provider from API key environment variables.
36
- * Scans registry for providers whose env vars are set.
37
- * Returns the first match.
38
- */
39
- export declare function autoDetectProvider(registry: ProviderRegistry): {
40
- providerId: string;
41
- apiKey: string;
42
- defaultModel: string;
43
- } | undefined;