qlogicagent 2.7.0 → 2.10.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.
- package/dist/agent.js +18 -18
- package/dist/cli.js +445 -433
- package/dist/index.js +444 -432
- package/dist/orchestration.js +6 -6
- package/dist/protocol.js +1 -1
- package/dist/types/agent/agent.d.ts +1 -1
- package/dist/types/agent/tool-loop.d.ts +1 -1
- package/dist/types/agent/tunable-defaults.d.ts +4 -0
- package/dist/types/agent/types.d.ts +7 -18
- package/dist/types/cli/handlers/agents-handler.d.ts +19 -0
- package/dist/types/cli/handlers/config-handler.d.ts +17 -0
- package/dist/types/cli/handlers/dream-handler.d.ts +5 -0
- package/dist/types/cli/handlers/files-handler.d.ts +15 -0
- package/dist/types/cli/handlers/media-handler.d.ts +13 -0
- package/dist/types/cli/handlers/memory-handler.d.ts +21 -0
- package/dist/types/cli/handlers/pet-handler.d.ts +28 -0
- package/dist/types/cli/handlers/product-handler.d.ts +32 -0
- package/dist/types/cli/handlers/project-handler.d.ts +19 -0
- package/dist/types/cli/handlers/session-handler.d.ts +38 -0
- package/dist/types/cli/handlers/settings-handler.d.ts +24 -0
- package/dist/types/cli/handlers/skills-handler.d.ts +20 -0
- package/dist/types/cli/handlers/solo-handler.d.ts +15 -0
- package/dist/types/cli/handlers/turn-handler.d.ts +17 -0
- package/dist/types/cli/main.d.ts +2 -2
- package/dist/types/cli/stdio-server.d.ts +90 -106
- package/dist/types/cli/tool-bootstrap.d.ts +4 -3
- package/dist/types/config/config.d.ts +1 -1
- package/dist/types/index.d.ts +2 -2
- package/dist/types/llm/index.d.ts +1 -31
- package/dist/types/orchestration/tool-cascade.d.ts +2 -2
- package/dist/types/protocol/methods.d.ts +153 -5
- package/dist/types/protocol/wire/agent-events.d.ts +2 -2
- package/dist/types/protocol/wire/agent-methods.d.ts +5 -3
- package/dist/types/protocol/wire/gateway-rpc.d.ts +125 -4
- package/dist/types/protocol/wire/index.d.ts +1 -1
- package/dist/types/protocol/wire/notification-payloads.d.ts +79 -1
- package/dist/types/runtime/execution/dream-agent.d.ts +1 -1
- package/dist/types/runtime/execution/forked-agent.d.ts +1 -1
- package/dist/types/runtime/hooks/context-compression.d.ts +1 -1
- package/dist/types/runtime/hooks/memory-hooks.d.ts +1 -1
- package/dist/types/runtime/infra/acp-types.d.ts +4 -0
- package/dist/types/runtime/infra/agent-paths.d.ts +22 -25
- package/dist/types/runtime/infra/agent-process.d.ts +1 -1
- package/dist/types/runtime/infra/builtin-providers.d.ts +36 -0
- package/dist/types/runtime/infra/checkpoint-backend.d.ts +1 -1
- package/dist/types/runtime/infra/index.d.ts +1 -2
- package/dist/types/runtime/infra/key-pool.d.ts +120 -0
- package/dist/types/runtime/infra/media-persistence.d.ts +26 -15
- package/dist/types/runtime/infra/model-registry.d.ts +187 -0
- package/dist/types/runtime/infra/project-instructions-store.d.ts +3 -3
- package/dist/types/runtime/infra/project-store.d.ts +3 -0
- package/dist/types/runtime/infra/token-budget.d.ts +2 -2
- package/dist/types/runtime/infra/worktree-backend.d.ts +1 -1
- package/dist/types/runtime/pet/index.d.ts +10 -0
- package/dist/types/runtime/pet/pet-consistency.d.ts +79 -0
- package/dist/types/runtime/pet/pet-context-injection.d.ts +8 -0
- package/dist/types/runtime/pet/pet-file-loader.d.ts +62 -0
- package/dist/types/runtime/pet/pet-growth-engine.d.ts +60 -0
- package/dist/types/runtime/pet/pet-reaction-service.d.ts +33 -0
- package/dist/types/runtime/pet/pet-skeleton.d.ts +70 -0
- package/dist/types/runtime/pet/pet-soul-service.d.ts +71 -0
- package/dist/types/runtime/session/group-session-split.d.ts +38 -0
- package/dist/types/runtime/session/index.d.ts +4 -2
- package/dist/types/runtime/session/session-locator.d.ts +24 -0
- package/dist/types/runtime/session/session-memory.d.ts +4 -4
- package/dist/types/runtime/session/session-persistence.d.ts +47 -46
- package/dist/types/runtime/session/session-state.d.ts +3 -5
- package/dist/types/skills/memory/local-memory-provider.d.ts +11 -1
- package/dist/types/skills/memory/local-store.d.ts +3 -2
- package/dist/types/skills/memory/memdir.d.ts +7 -4
- package/dist/types/skills/memory/memory-provider-factory.d.ts +2 -8
- package/dist/types/skills/permissions/denial-audit-log.d.ts +1 -1
- package/dist/types/skills/permissions/permission-classifier.d.ts +1 -1
- package/dist/types/skills/tools/search-tool.d.ts +1 -1
- package/dist/types/skills/tools.d.ts +3 -3
- package/dist/types/transport/acp-event-emitter.d.ts +1 -1
- package/dist/types/transport/acp-server.d.ts +2 -2
- package/package.json +2 -1
- package/dist/types/llm/adapters/aliyun-oss-file-upload-adapter.d.ts +0 -44
- package/dist/types/llm/adapters/gemini-file-upload-adapter.d.ts +0 -26
- package/dist/types/llm/adapters/hub-oss-file-upload-adapter.d.ts +0 -29
- package/dist/types/llm/adapters/index.d.ts +0 -10
- package/dist/types/llm/adapters/openai-file-upload-adapter.d.ts +0 -38
- package/dist/types/llm/adapters/volcengine-file-upload-adapter.d.ts +0 -24
- package/dist/types/llm/builtin-providers.d.ts +0 -10
- package/dist/types/llm/debug-transport.d.ts +0 -12
- package/dist/types/llm/file-upload-service.d.ts +0 -68
- package/dist/types/llm/gemini-schema-utils.d.ts +0 -17
- package/dist/types/llm/llm-client.d.ts +0 -43
- package/dist/types/llm/media-client.d.ts +0 -42
- package/dist/types/llm/media-transport.d.ts +0 -176
- package/dist/types/llm/model-catalog.d.ts +0 -82
- package/dist/types/llm/model-detection.d.ts +0 -22
- package/dist/types/llm/provider-def.d.ts +0 -203
- package/dist/types/llm/provider-registry.d.ts +0 -59
- package/dist/types/llm/provider-tool-api.d.ts +0 -44
- package/dist/types/llm/retry.d.ts +0 -37
- package/dist/types/llm/transport.d.ts +0 -281
- package/dist/types/llm/transports/anthropic-messages.d.ts +0 -65
- package/dist/types/llm/transports/gemini-cache-api.d.ts +0 -86
- package/dist/types/llm/transports/gemini-file-api.d.ts +0 -90
- package/dist/types/llm/transports/gemini-generatecontent.d.ts +0 -56
- package/dist/types/llm/transports/gemini-lyria-realtime.d.ts +0 -117
- package/dist/types/llm/transports/gemini-media.d.ts +0 -53
- package/dist/types/llm/transports/media-resolve.d.ts +0 -50
- package/dist/types/llm/transports/minimax-media.d.ts +0 -55
- package/dist/types/llm/transports/openai-chat.d.ts +0 -81
- package/dist/types/llm/transports/openai-media.d.ts +0 -24
- package/dist/types/llm/transports/openai-responses.d.ts +0 -63
- package/dist/types/llm/transports/qwen-media.d.ts +0 -50
- package/dist/types/llm/transports/realtime-transport.d.ts +0 -183
- package/dist/types/llm/transports/volcengine-grounding.d.ts +0 -58
- package/dist/types/llm/transports/volcengine-media.d.ts +0 -93
- package/dist/types/llm/transports/volcengine-responses.d.ts +0 -64
- package/dist/types/llm/transports/zhipu-media.d.ts +0 -82
- package/dist/types/llm/transports/zhipu-tool-api.d.ts +0 -35
- package/dist/types/runtime/infra/project-plan-store.d.ts +0 -27
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Session State
|
|
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
|
|
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
|
|
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
|
|
@@ -21,7 +21,7 @@ export interface ExtractedMemoryItem {
|
|
|
21
21
|
tags?: string[];
|
|
22
22
|
}
|
|
23
23
|
export interface LocalMemoryProviderConfig {
|
|
24
|
-
/**
|
|
24
|
+
/** Not used for L2 vector memory (always global). Kept for interface compat. */
|
|
25
25
|
projectRoot?: string;
|
|
26
26
|
/** Embedding configuration. If omitted, uses FTS-only search. */
|
|
27
27
|
embedding?: LocalEmbeddingConfig;
|
|
@@ -116,6 +116,16 @@ export declare class LocalMemoryProvider implements MemoryProvider {
|
|
|
116
116
|
date: string;
|
|
117
117
|
}>;
|
|
118
118
|
};
|
|
119
|
+
/**
|
|
120
|
+
* List full memory records for a user (paginated). Used by the memory atlas
|
|
121
|
+
* visualization, which needs the complete record shape (confidence, importance,
|
|
122
|
+
* accessCount, timestamps, tags) to drive its 3D rendering.
|
|
123
|
+
*/
|
|
124
|
+
list(userId: string, options?: {
|
|
125
|
+
page?: number;
|
|
126
|
+
pageSize?: number;
|
|
127
|
+
activeOnly?: boolean;
|
|
128
|
+
}): import("./local-store.js").MemoryRecord[];
|
|
119
129
|
/**
|
|
120
130
|
* Find memories by event date (±tolerance). For temporal context retrieval.
|
|
121
131
|
*/
|
|
@@ -249,6 +249,7 @@ export declare class LocalMemoryStore {
|
|
|
249
249
|
close(): void;
|
|
250
250
|
}
|
|
251
251
|
/**
|
|
252
|
-
* Resolve the database file path for
|
|
252
|
+
* Resolve the database file path for L2 vector memory storage.
|
|
253
|
+
* L2 vector memory is GLOBAL (cross-project knowledge), stored at ~/.qlogicagent/memory/.
|
|
253
254
|
*/
|
|
254
|
-
export declare function resolveMemoryDbPath(
|
|
255
|
+
export declare function resolveMemoryDbPath(): string;
|
|
@@ -4,10 +4,10 @@ export declare const INDEX_MAX_CHARS = 12288;
|
|
|
4
4
|
export declare const INDEX_MAX_LINES = 200;
|
|
5
5
|
/** Max chars for a single topic file. */
|
|
6
6
|
export declare const TOPIC_FILE_MAX_CHARS = 8192;
|
|
7
|
-
/** Root directory:
|
|
8
|
-
export declare function getMemdirPath(): string;
|
|
7
|
+
/** Root directory: <project>/.qlogicagent/memory/ */
|
|
8
|
+
export declare function getMemdirPath(projectRoot: string): string;
|
|
9
9
|
/** Full path to INDEX.md */
|
|
10
|
-
export declare function getIndexPath(): string;
|
|
10
|
+
export declare function getIndexPath(projectRoot: string): string;
|
|
11
11
|
export interface MemdirFileInfo {
|
|
12
12
|
name: string;
|
|
13
13
|
/** Size in bytes */
|
|
@@ -29,7 +29,7 @@ export declare function isMemoryContentSafe(text: string): boolean;
|
|
|
29
29
|
export declare class Memdir {
|
|
30
30
|
private readonly root;
|
|
31
31
|
private indexCache;
|
|
32
|
-
constructor(
|
|
32
|
+
constructor(projectRoot: string);
|
|
33
33
|
/** Get the root directory path of this MEMDIR. */
|
|
34
34
|
getRootPath(): string;
|
|
35
35
|
/** Ensure memdir exists with a default INDEX.md if missing. */
|
|
@@ -52,6 +52,9 @@ export declare class Memdir {
|
|
|
52
52
|
/**
|
|
53
53
|
* Auto-compact INDEX.md by removing oldest non-structural entries to make room.
|
|
54
54
|
* Returns the compacted content with the new entry appended, or null if impossible.
|
|
55
|
+
*
|
|
56
|
+
* Entry-aware: removes complete logical entries (a non-indented line plus its
|
|
57
|
+
* continuation lines that start with whitespace/'-') to avoid half-entries.
|
|
55
58
|
*/
|
|
56
59
|
private autoCompactIndex;
|
|
57
60
|
/** Replace text in INDEX.md (str_replace semantics). */
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import type { LocalEmbeddingConfig } from "./local-embedding.js";
|
|
8
8
|
import type { LocalMemoryProvider } from "./local-memory-provider.js";
|
|
9
9
|
export interface MemoryProviderFactoryConfig {
|
|
10
|
-
/**
|
|
10
|
+
/** Not used for L2 vector DB (always global). Kept for config compat. */
|
|
11
11
|
projectRoot?: string;
|
|
12
12
|
/** User ID prefix. */
|
|
13
13
|
userIdPrefix?: string;
|
|
@@ -44,11 +44,5 @@ export declare function createMemoryProvider(config: MemoryProviderFactoryConfig
|
|
|
44
44
|
* Layer 3: FTS5 pure text (NullEmbeddingProvider)
|
|
45
45
|
*
|
|
46
46
|
* @param projectRoot — Project root for local storage path
|
|
47
|
-
* @param embeddingOverride — TurnConfig.embeddingModel override (takes priority over env vars)
|
|
48
47
|
*/
|
|
49
|
-
export declare function resolveMemoryConfigFromEnv(projectRoot?: string
|
|
50
|
-
provider?: string;
|
|
51
|
-
model?: string;
|
|
52
|
-
apiKey?: string;
|
|
53
|
-
baseUrl?: string;
|
|
54
|
-
}): MemoryProviderFactoryConfig;
|
|
48
|
+
export declare function resolveMemoryConfigFromEnv(projectRoot?: string): MemoryProviderFactoryConfig;
|
|
@@ -38,7 +38,7 @@ export interface DenialAuditEntry {
|
|
|
38
38
|
export declare class DenialAuditLogger {
|
|
39
39
|
private filePath;
|
|
40
40
|
private writeQueue;
|
|
41
|
-
constructor(projectRoot
|
|
41
|
+
constructor(projectRoot: string);
|
|
42
42
|
/**
|
|
43
43
|
* Append a denial event to the audit log.
|
|
44
44
|
* Non-blocking; errors are swallowed to avoid disrupting agent flow.
|
|
@@ -6,7 +6,7 @@ export interface ClassifierResult {
|
|
|
6
6
|
durationMs: number;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* LLM call
|
|
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 {
|
|
@@ -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
|
|
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
|
|
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()
|
|
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()
|
|
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
|
|
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
|
|
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.
|
|
@@ -78,7 +78,7 @@ export interface AcpServerConfig {
|
|
|
78
78
|
verbose?: boolean;
|
|
79
79
|
}
|
|
80
80
|
/**
|
|
81
|
-
*
|
|
81
|
+
* AcpServermanages the ACP protocol state machine.
|
|
82
82
|
*
|
|
83
83
|
* Lifecycle:
|
|
84
84
|
* 1. Host connects (stdio)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "qlogicagent",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.10.0",
|
|
4
4
|
"description": "XiaozhiClaw Agent CLI — subprocess architecture (JSON-RPC over stdio)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"node": ">=22.0.0"
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
+
"@qlogic/provider-core": "workspace:*",
|
|
65
66
|
"better-sqlite3": "^12.10.0",
|
|
66
67
|
"dotenv": "^17.3.1",
|
|
67
68
|
"nanoid": "^5.1.5",
|
|
@@ -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;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Media Client factory — resolves ProviderDef → creates MediaTransport instances.
|
|
3
|
-
*
|
|
4
|
-
* Parallel to createLLMClient() but for generation models (image/video/music/3D).
|
|
5
|
-
* Uses the same ProviderRegistry to look up provider config, then instantiates
|
|
6
|
-
* the correct media transport adapter.
|
|
7
|
-
*
|
|
8
|
-
* The MediaClient holds a provider-keyed transport cache so that repeated
|
|
9
|
-
* generation calls reuse the same adapter instance.
|
|
10
|
-
*/
|
|
11
|
-
import type { MediaTransport } from "./media-transport.js";
|
|
12
|
-
import type { ProviderDef, MediaCapability, ModelInfo } from "./provider-def.js";
|
|
13
|
-
import type { ProviderRegistry } from "./provider-registry.js";
|
|
14
|
-
export interface MediaClientConfig {
|
|
15
|
-
registry: ProviderRegistry;
|
|
16
|
-
}
|
|
17
|
-
export interface ResolvedMediaModel {
|
|
18
|
-
providerId: string;
|
|
19
|
-
providerDef: ProviderDef;
|
|
20
|
-
modelInfo: ModelInfo;
|
|
21
|
-
mediaType: MediaCapability;
|
|
22
|
-
}
|
|
23
|
-
export declare class MediaClient {
|
|
24
|
-
private registry;
|
|
25
|
-
private transports;
|
|
26
|
-
constructor(config: MediaClientConfig);
|
|
27
|
-
/**
|
|
28
|
-
* Find a specific model by provider + model id for a given media type.
|
|
29
|
-
* Used by the user-designated model routing (no failover).
|
|
30
|
-
*/
|
|
31
|
-
resolveModelById(providerId: string, modelId: string, mediaType: MediaCapability): ResolvedMediaModel | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Get a MediaTransport for a specific provider.
|
|
34
|
-
* Creates and caches the adapter on first access.
|
|
35
|
-
*/
|
|
36
|
-
getTransport(providerId: string): MediaTransport | undefined;
|
|
37
|
-
/**
|
|
38
|
-
* List all available generation models across all providers.
|
|
39
|
-
*/
|
|
40
|
-
listMediaModels(mediaType?: MediaCapability): ResolvedMediaModel[];
|
|
41
|
-
private findModelInProvider;
|
|
42
|
-
}
|