@archships/dim-agent-sdk 0.0.3 → 0.0.5
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/README.md +27 -5
- package/dist/dim-agent-sdk/src/agent-core/agent-types.d.ts +3 -2
- package/dist/dim-agent-sdk/src/agent-core/{Agent.d.ts → agent.d.ts} +2 -2
- package/dist/dim-agent-sdk/src/agent-core/index.d.ts +10 -10
- package/dist/dim-agent-sdk/src/agent-core/{LoopRunner.d.ts → loop-runner.d.ts} +6 -5
- package/dist/dim-agent-sdk/src/agent-core/notifications.d.ts +1 -1
- package/dist/dim-agent-sdk/src/agent-core/session-state.d.ts +3 -2
- package/dist/dim-agent-sdk/src/agent-core/{Session.d.ts → session.d.ts} +48 -9
- package/dist/dim-agent-sdk/src/agent-core/{ToolExecutor.d.ts → tool-executor.d.ts} +2 -2
- package/dist/dim-agent-sdk/src/context/{AutoContextManager.d.ts → auto-context-manager.d.ts} +1 -1
- package/dist/dim-agent-sdk/src/context/index.d.ts +2 -2
- package/dist/dim-agent-sdk/src/contracts/event.d.ts +13 -7
- package/dist/dim-agent-sdk/src/contracts/state.d.ts +32 -1
- package/dist/dim-agent-sdk/src/index.d.ts +7 -6
- package/dist/dim-agent-sdk/src/persistence/index.d.ts +5 -5
- package/dist/dim-agent-sdk/src/persistence/{SnapshotCodec.d.ts → snapshot-codec.d.ts} +2 -1
- package/dist/dim-agent-sdk/src/plugin-host/index.d.ts +2 -2
- package/dist/dim-agent-sdk/src/plugin-host/{PluginHost.d.ts → plugin-host.d.ts} +4 -4
- package/dist/dim-agent-sdk/src/providers/aihubmix/adapter.d.ts +17 -0
- package/dist/dim-agent-sdk/src/providers/aihubmix/driver.d.ts +3 -0
- package/dist/dim-agent-sdk/src/providers/aihubmix/index.d.ts +2 -0
- package/dist/dim-agent-sdk/src/providers/aihubmix-responses/adapter.d.ts +17 -0
- package/dist/dim-agent-sdk/src/providers/aihubmix-responses/driver.d.ts +12 -0
- package/dist/dim-agent-sdk/src/providers/aihubmix-responses/index.d.ts +2 -0
- package/dist/dim-agent-sdk/src/providers/aihubmix-responses/state.d.ts +7 -0
- package/dist/dim-agent-sdk/src/providers/anthropic/adapter.d.ts +15 -4
- package/dist/dim-agent-sdk/src/providers/anthropic/driver.d.ts +3 -0
- package/dist/dim-agent-sdk/src/providers/anthropic/index.d.ts +2 -0
- package/dist/dim-agent-sdk/src/providers/anthropic/state.d.ts +6 -0
- package/dist/dim-agent-sdk/src/providers/core/create-provider-factory.d.ts +39 -0
- package/dist/dim-agent-sdk/src/providers/core/index.d.ts +2 -0
- package/dist/dim-agent-sdk/src/providers/deepseek/adapter.d.ts +11 -0
- package/dist/dim-agent-sdk/src/providers/deepseek/driver.d.ts +3 -0
- package/dist/dim-agent-sdk/src/providers/deepseek/index.d.ts +2 -0
- package/dist/dim-agent-sdk/src/providers/gemini/adapter.d.ts +3 -4
- package/dist/dim-agent-sdk/src/providers/gemini/driver.d.ts +3 -0
- package/dist/dim-agent-sdk/src/providers/gemini/index.d.ts +2 -0
- package/dist/dim-agent-sdk/src/providers/gemini/state.d.ts +5 -0
- package/dist/dim-agent-sdk/src/providers/index.d.ts +22 -8
- package/dist/dim-agent-sdk/src/providers/moonshotai/adapter.d.ts +11 -0
- package/dist/dim-agent-sdk/src/providers/moonshotai/driver.d.ts +3 -0
- package/dist/dim-agent-sdk/src/providers/moonshotai/index.d.ts +2 -0
- package/dist/dim-agent-sdk/src/providers/openai/adapter.d.ts +3 -4
- package/dist/dim-agent-sdk/src/providers/openai/driver.d.ts +3 -0
- package/dist/dim-agent-sdk/src/providers/openai/index.d.ts +2 -0
- package/dist/dim-agent-sdk/src/providers/openai-responses/adapter.d.ts +3 -4
- package/dist/dim-agent-sdk/src/providers/openai-responses/driver.d.ts +3 -0
- package/dist/dim-agent-sdk/src/providers/openai-responses/index.d.ts +2 -0
- package/dist/dim-agent-sdk/src/providers/openai-responses/state.d.ts +7 -0
- package/dist/dim-agent-sdk/src/providers/shared/ai-sdk-driver.d.ts +7 -0
- package/dist/dim-agent-sdk/src/providers/shared/auth-warning.d.ts +6 -0
- package/dist/dim-agent-sdk/src/providers/shared/fetch.d.ts +8 -0
- package/dist/dim-agent-sdk/src/providers/shared/http-error.d.ts +10 -0
- package/dist/dim-agent-sdk/src/providers/shared/prompt.d.ts +14 -0
- package/dist/dim-agent-sdk/src/providers/shared/reasoning.d.ts +30 -7
- package/dist/dim-agent-sdk/src/providers/shared/responses-state.d.ts +11 -0
- package/dist/dim-agent-sdk/src/providers/shared/usage.d.ts +4 -2
- package/dist/dim-agent-sdk/src/providers/xai/adapter.d.ts +11 -0
- package/dist/dim-agent-sdk/src/providers/xai/driver.d.ts +3 -0
- package/dist/dim-agent-sdk/src/providers/xai/index.d.ts +2 -0
- package/dist/dim-agent-sdk/src/providers/xai-responses/adapter.d.ts +11 -0
- package/dist/dim-agent-sdk/src/providers/xai-responses/driver.d.ts +3 -0
- package/dist/dim-agent-sdk/src/providers/xai-responses/index.d.ts +2 -0
- package/dist/dim-agent-sdk/src/providers/xai-responses/state.d.ts +7 -0
- package/dist/dim-agent-sdk/src/providers/zenmux/adapter.d.ts +13 -0
- package/dist/dim-agent-sdk/src/providers/zenmux/driver.d.ts +3 -0
- package/dist/dim-agent-sdk/src/providers/zenmux/index.d.ts +2 -0
- package/dist/dim-agent-sdk/src/services/index.d.ts +6 -6
- package/dist/dim-agent-sdk/src/tools/builtins/{EditTool.d.ts → edit-tool.d.ts} +1 -1
- package/dist/dim-agent-sdk/src/tools/builtins/{ExecTool.d.ts → exec-tool.d.ts} +1 -1
- package/dist/dim-agent-sdk/src/tools/builtins/index.d.ts +4 -4
- package/dist/dim-agent-sdk/src/tools/builtins/{ReadTool.d.ts → read-tool.d.ts} +1 -1
- package/dist/dim-agent-sdk/src/tools/builtins/{WriteTool.d.ts → write-tool.d.ts} +1 -1
- package/dist/dim-agent-sdk/src/tools/index.d.ts +2 -2
- package/dist/dim-plugin-api/src/index.d.ts +18 -1
- package/dist/{index.js → src/index.js} +4422 -3627
- package/dist/src/providers/aihubmix/index.js +636 -0
- package/dist/src/providers/aihubmix-responses/index.js +759 -0
- package/dist/src/providers/anthropic/index.js +743 -0
- package/dist/src/providers/core/index.js +92 -0
- package/dist/src/providers/deepseek/index.js +639 -0
- package/dist/src/providers/gemini/index.js +756 -0
- package/dist/src/providers/moonshotai/index.js +639 -0
- package/dist/src/providers/openai/index.js +499 -0
- package/dist/src/providers/openai-responses/index.js +727 -0
- package/dist/src/providers/xai/index.js +639 -0
- package/dist/src/providers/xai-responses/index.js +728 -0
- package/dist/src/providers/zenmux/index.js +642 -0
- package/package.json +74 -5
- package/dist/dim-agent-sdk/src/providers/anthropic/mapper.d.ts +0 -28
- package/dist/dim-agent-sdk/src/providers/gemini/mapper.d.ts +0 -30
- package/dist/dim-agent-sdk/src/providers/openai/mapper.d.ts +0 -15
- package/dist/dim-agent-sdk/src/providers/openai-responses/mapper.d.ts +0 -40
- /package/dist/dim-agent-sdk/src/agent-core/{createModel.d.ts → create-model.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/agent-core/{MessageFactory.d.ts → message-factory.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/agent-core/{ModelTurnCollector.d.ts → model-turn-collector.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/agent-core/{TerminationPolicy.d.ts → termination-policy.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/persistence/{FileStateStore.d.ts → file-state-store.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/persistence/{InMemoryStateStore.d.ts → in-memory-state-store.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/plugin-host/{HookPipeline.d.ts → hook-pipeline.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/services/{ExecGateway.d.ts → exec-gateway.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/services/{FileSystemGateway.d.ts → file-system-gateway.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/services/{GitGateway.d.ts → git-gateway.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/services/{ModelGateway.d.ts → model-gateway.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/services/{NetworkGateway.d.ts → network-gateway.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/services/{PermissionGateway.d.ts → permission-gateway.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/tools/{BaseTool.d.ts → base-tool.d.ts} +0 -0
- /package/dist/dim-agent-sdk/src/tools/{ToolRegistry.d.ts → tool-registry.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -34,8 +34,16 @@ const session = await agent.createSession({
|
|
|
34
34
|
systemPrompt: 'You are a coding agent. Use tools when needed.',
|
|
35
35
|
})
|
|
36
36
|
|
|
37
|
-
const
|
|
38
|
-
|
|
37
|
+
const itemId = session.send('Create hello.txt in the current directory and write hello world into it.')
|
|
38
|
+
|
|
39
|
+
for await (const event of session.receive()) {
|
|
40
|
+
if (event.itemId !== itemId)
|
|
41
|
+
continue
|
|
42
|
+
if (event.type === 'text_delta')
|
|
43
|
+
process.stdout.write(event.delta)
|
|
44
|
+
if (event.type === 'done')
|
|
45
|
+
console.log(event.message.content)
|
|
46
|
+
}
|
|
39
47
|
```
|
|
40
48
|
|
|
41
49
|
## Manual
|
|
@@ -48,8 +56,9 @@ console.log(message.content)
|
|
|
48
56
|
|
|
49
57
|
- Canonical content / message / tool / model / state contracts
|
|
50
58
|
- `createAgent()` -> `Agent` -> `Session`
|
|
51
|
-
-
|
|
52
|
-
-
|
|
59
|
+
- Queue-first session flow: `send()`, `sendBatch()`, `steer()`, `receive()`, `getQueueStatus()`
|
|
60
|
+
- Session events: `text_delta`, optional `thinking_delta`, `tool_call`, `plugin_event`, `tool_result`, `done`, `error`
|
|
61
|
+
- Provider adapters: `openai-compatible`, `openai-responses`, `anthropic`, `gemini`, `zenmux`, `aihubmix`, `aihubmix-responses`, `moonshotai`, `deepseek`, `xai`, `xai-responses`
|
|
53
62
|
- Builtin tools: `read`, `write`, `edit`, `exec`
|
|
54
63
|
- Hook-first plugin integration
|
|
55
64
|
- Runtime gateways: file system, git, exec, network, model
|
|
@@ -109,8 +118,20 @@ Current failure policy:
|
|
|
109
118
|
|
|
110
119
|
- `createOpenAIAdapter()`: OpenAI-compatible Chat Completions style; no official reasoning channel mapping
|
|
111
120
|
- `createOpenAIResponsesAdapter()`: official OpenAI Responses API; maps reasoning summaries into `thinking_delta`
|
|
112
|
-
- `createAnthropicAdapter()`: maps Claude thinking blocks into `thinking_delta`
|
|
121
|
+
- `createAnthropicAdapter()`: maps Claude thinking blocks into `thinking_delta`; when overriding `baseUrl`, the adapter appends `/v1` if it is missing
|
|
113
122
|
- `createGeminiAdapter()`: maps Gemini thought parts into `thinking_delta`
|
|
123
|
+
- `createZenMuxAdapter()`: ZenMux chat adapter; keeps ZenMux-native `reasoningEffort`
|
|
124
|
+
- `createAihubmixAdapter()` / `createAihubmixResponsesAdapter()`: AIHubMix chat + responses adapters; `responses` keeps `previousResponseId`. If you omit `apiKey`, you must inject the real upstream authentication inside custom `fetch`.
|
|
125
|
+
- `createMoonshotAIAdapter()`: MoonshotAI language model adapter with thinking budget mapping
|
|
126
|
+
- `createDeepSeekAdapter()`: DeepSeek chat adapter with reasoning -> `thinking_delta`
|
|
127
|
+
- `createXaiAdapter()` / `createXaiResponsesAdapter()`: xAI chat + responses adapters; `responses` keeps `previousResponseId`
|
|
128
|
+
- Builtin providers are also available from public subpaths such as `@archships/dim-agent-sdk/providers/openai` and `@archships/dim-agent-sdk/providers/xai-responses`
|
|
129
|
+
- Other deep internal imports are not part of the public API, even though package-local tests use path aliases against `src/*`
|
|
130
|
+
- Custom providers can follow the same factory pattern via `@archships/dim-agent-sdk/providers/core`
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
import { createProviderFactory } from '@archships/dim-agent-sdk/providers/core'
|
|
134
|
+
```
|
|
114
135
|
|
|
115
136
|
## Demo
|
|
116
137
|
|
|
@@ -175,6 +196,7 @@ The provider smoke layer reuses:
|
|
|
175
196
|
|
|
176
197
|
- `DIM_TEST_API_KEY`
|
|
177
198
|
- `DIM_TEST_BASE_URL`
|
|
199
|
+
- `DIM_TEST_BASE_URL_ANTHROPIC` (optional; enables the Anthropic smoke lane)
|
|
178
200
|
- `DIM_TEST_MODEL_ID` (optional)
|
|
179
201
|
|
|
180
202
|
Smoke tests assert stable invariants such as tool calls, `plugin_event`, notifications, and on-disk side effects. They intentionally avoid exact natural-language output matching.
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DimPlugin } from '@archships/dim-plugin-api';
|
|
2
|
-
import type { CompactionOptions, Message, MessageContentInput, ModelClient, Tool } from '../contracts';
|
|
2
|
+
import type { CompactionOptions, Message, MessageContentInput, MessageQueueConfig, ModelClient, Tool } from '../contracts';
|
|
3
3
|
import type { ContextManager } from '../context';
|
|
4
4
|
import type { StateStore } from '../persistence/store';
|
|
5
5
|
import type { PermissionSpec } from '../services';
|
|
6
|
-
import type { ToolRegistry } from '../tools/
|
|
6
|
+
import type { ToolRegistry } from '../tools/tool-registry';
|
|
7
7
|
import type { ApprovalHandler } from './approvals';
|
|
8
8
|
export interface AgentOptions {
|
|
9
9
|
model: ModelClient;
|
|
@@ -26,4 +26,5 @@ export interface CreateSessionOptions {
|
|
|
26
26
|
metadata?: Record<string, unknown>;
|
|
27
27
|
messages?: Message[];
|
|
28
28
|
systemPrompt?: MessageContentInput;
|
|
29
|
+
messageQueueConfig?: Partial<MessageQueueConfig>;
|
|
29
30
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { DimPlugin } from '@archships/dim-plugin-api';
|
|
2
2
|
import type { SessionSnapshot } from '../contracts';
|
|
3
3
|
import type { StateStore } from '../persistence/store';
|
|
4
|
-
import { PluginHost } from '../plugin-host/
|
|
4
|
+
import { PluginHost } from '../plugin-host/plugin-host';
|
|
5
5
|
import type { AgentServices, PermissionSpec } from '../services';
|
|
6
6
|
import { ToolRegistry } from '../tools';
|
|
7
7
|
import type { ApprovalHandler } from './approvals';
|
|
8
|
-
import { Session } from './
|
|
8
|
+
import { Session } from './session';
|
|
9
9
|
import type { AgentOptions, CreateSessionOptions } from './agent-types';
|
|
10
10
|
export declare class Agent {
|
|
11
11
|
readonly id: string;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
export { Agent, createAgent } from './
|
|
1
|
+
export { Agent, createAgent } from './agent';
|
|
2
2
|
export type { ApprovalContext, ApprovalHandler, ApprovalManager } from './approvals';
|
|
3
3
|
export { DefaultCompactionService, applyCompactionUpdate, buildCompactionPromptSegments, calculateThresholdTokens, clearCompactionState, cloneCompactionState, createEmptyCompactionState, didCompactionStateChange, estimateCompactionBudget, isCompactionRequired, normalizeCompactionState, projectMessagesForRequest, } from './compaction';
|
|
4
4
|
export { DefaultPluginStateService, clonePluginSessionStateEntry, clonePluginStateMap, normalizePluginStateMap, } from './plugin-state';
|
|
5
|
-
export { createModel } from './
|
|
5
|
+
export { createModel } from './create-model';
|
|
6
6
|
export { DefaultApprovalManager } from './approvals';
|
|
7
7
|
export { DefaultNotificationBus } from './notifications';
|
|
8
|
-
export { Session } from './
|
|
8
|
+
export { Session } from './session';
|
|
9
9
|
export { SessionExecutionError } from './errors';
|
|
10
10
|
export type { AgentOptions, CreateSessionOptions } from './agent-types';
|
|
11
|
-
export type { CreateAgentOptions } from './
|
|
12
|
-
export type { LoopRunnerDependencies, LoopRunnerRunOptions } from './
|
|
13
|
-
export type { CreateAssistantMessageInput, MessageFactory } from './
|
|
14
|
-
export type { CollectModelTurnOptions, ModelTurnCollector, ModelTurnResult } from './
|
|
11
|
+
export type { CreateAgentOptions } from './agent';
|
|
12
|
+
export type { LoopRunnerDependencies, LoopRunnerRunOptions } from './loop-runner';
|
|
13
|
+
export type { CreateAssistantMessageInput, MessageFactory } from './message-factory';
|
|
14
|
+
export type { CollectModelTurnOptions, ModelTurnCollector, ModelTurnResult } from './model-turn-collector';
|
|
15
15
|
export type { NotificationBus, NotificationContext } from './notifications';
|
|
16
16
|
export type { RuntimeSessionState } from './session-state';
|
|
17
|
-
export type { SessionOptions } from './
|
|
17
|
+
export type { SessionOptions } from './session';
|
|
18
18
|
export type { SubagentInvocation, SubagentResult, SubagentRuntime } from './subagent';
|
|
19
|
-
export type { TerminationDecision, TerminationPolicy } from './
|
|
20
|
-
export type { ToolExecutor, ToolExecutorExecuteOptions, ToolExecutorOptions } from './
|
|
19
|
+
export type { TerminationDecision, TerminationPolicy } from './termination-policy';
|
|
20
|
+
export type { ToolExecutor, ToolExecutorExecuteOptions, ToolExecutorOptions } from './tool-executor';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { AssistantMessage, MessageContentInput, SessionStreamEvent } from '../contracts';
|
|
2
2
|
import type { ContextManager } from '../context';
|
|
3
|
-
import type { PluginHost } from '../plugin-host/
|
|
4
|
-
import type { MessageFactory } from './
|
|
5
|
-
import type { ModelTurnCollector } from './
|
|
3
|
+
import type { PluginHost } from '../plugin-host/plugin-host';
|
|
4
|
+
import type { MessageFactory } from './message-factory';
|
|
5
|
+
import type { ModelTurnCollector } from './model-turn-collector';
|
|
6
6
|
import type { NotificationBus } from './notifications';
|
|
7
7
|
import type { RuntimeSessionState } from './session-state';
|
|
8
|
-
import type { TerminationPolicy } from './
|
|
9
|
-
import type { ToolExecutor } from './
|
|
8
|
+
import type { TerminationPolicy } from './termination-policy';
|
|
9
|
+
import type { ToolExecutor } from './tool-executor';
|
|
10
10
|
export interface LoopRunnerDependencies {
|
|
11
11
|
messageFactory: MessageFactory;
|
|
12
12
|
turnCollector: ModelTurnCollector;
|
|
@@ -19,6 +19,7 @@ export interface LoopRunnerDependencies {
|
|
|
19
19
|
export interface LoopRunnerRunOptions {
|
|
20
20
|
signal?: AbortSignal;
|
|
21
21
|
onDone?: (message: AssistantMessage) => Promise<void> | void;
|
|
22
|
+
persistentPromptSegments?: string[];
|
|
22
23
|
}
|
|
23
24
|
export declare class LoopRunner {
|
|
24
25
|
private readonly messageFactory;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SessionStatus } from '../contracts';
|
|
2
2
|
import type { NotificationPayload } from '@archships/dim-plugin-api';
|
|
3
|
-
import type { PluginHost } from '../plugin-host/
|
|
3
|
+
import type { PluginHost } from '../plugin-host/plugin-host';
|
|
4
4
|
import type { AgentServices } from '../services';
|
|
5
5
|
export interface NotificationContext {
|
|
6
6
|
sessionId?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CompactionOptions, CompactionState, Message, ModelClient, ModelRef, PluginSessionStateEntry, Usage } from '../contracts';
|
|
2
|
-
import type { ToolRegistry } from '../tools/
|
|
1
|
+
import type { CompactionOptions, CompactionState, Message, MessageQueueSnapshot, ModelClient, ModelRef, PluginSessionStateEntry, Usage } from '../contracts';
|
|
2
|
+
import type { ToolRegistry } from '../tools/tool-registry';
|
|
3
3
|
export interface RuntimeSessionState {
|
|
4
4
|
id: string;
|
|
5
5
|
model: ModelClient;
|
|
@@ -13,6 +13,7 @@ export interface RuntimeSessionState {
|
|
|
13
13
|
usage: Usage;
|
|
14
14
|
compaction: CompactionState;
|
|
15
15
|
pluginState: Record<string, PluginSessionStateEntry>;
|
|
16
|
+
messageQueue: MessageQueueSnapshot;
|
|
16
17
|
compactionOptions?: CompactionOptions;
|
|
17
18
|
createdAt: number;
|
|
18
19
|
updatedAt: number;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CompactionOptions, CompactionState, CompactionUpdate, Message, MessageContentInput, MessageQueueConfig, MessageQueueSnapshot, MessageQueueStatus, PendingMessageKind, ModelClient, ModelRef, PluginSessionStateEntry, SessionStatus, SessionSnapshot, SessionStreamEvent, Usage } from '../contracts';
|
|
2
2
|
import type { ContextManager } from '../context';
|
|
3
3
|
import type { StateStore } from '../persistence/store';
|
|
4
|
-
import type { PluginHost } from '../plugin-host/
|
|
4
|
+
import type { PluginHost } from '../plugin-host/plugin-host';
|
|
5
5
|
import type { AgentServices } from '../services';
|
|
6
|
-
import type { ToolRegistry } from '../tools/
|
|
6
|
+
import type { ToolRegistry } from '../tools/tool-registry';
|
|
7
7
|
import type { ApprovalManager } from './approvals';
|
|
8
8
|
import { DefaultCompactionService } from './compaction';
|
|
9
9
|
import { DefaultPluginStateService } from './plugin-state';
|
|
@@ -22,6 +22,8 @@ export interface SessionOptions {
|
|
|
22
22
|
usage?: Usage;
|
|
23
23
|
compaction?: CompactionState;
|
|
24
24
|
pluginState?: Record<string, PluginSessionStateEntry>;
|
|
25
|
+
messageQueue?: MessageQueueSnapshot;
|
|
26
|
+
messageQueueConfig?: Partial<MessageQueueConfig>;
|
|
25
27
|
compactionOptions?: CompactionOptions;
|
|
26
28
|
createdAt?: number;
|
|
27
29
|
updatedAt?: number;
|
|
@@ -33,6 +35,15 @@ export interface SessionOptions {
|
|
|
33
35
|
compactionService: DefaultCompactionService;
|
|
34
36
|
pluginStateService: DefaultPluginStateService;
|
|
35
37
|
}
|
|
38
|
+
interface SessionQueueSendOptions {
|
|
39
|
+
priority?: number;
|
|
40
|
+
}
|
|
41
|
+
interface SessionReceiveOptions {
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}
|
|
44
|
+
interface ClearQueueFilter {
|
|
45
|
+
kind?: PendingMessageKind;
|
|
46
|
+
}
|
|
36
47
|
export declare class Session {
|
|
37
48
|
readonly id: string;
|
|
38
49
|
readonly createdAt: number;
|
|
@@ -46,7 +57,14 @@ export declare class Session {
|
|
|
46
57
|
private readonly compactionService;
|
|
47
58
|
private readonly pluginStateService;
|
|
48
59
|
private readonly pluginControllers;
|
|
60
|
+
private readonly bufferedEvents;
|
|
61
|
+
private readonly stateChangeWaiters;
|
|
49
62
|
private activeRunCount;
|
|
63
|
+
private processingPromise;
|
|
64
|
+
private receiveActive;
|
|
65
|
+
private activeReceiveSignal?;
|
|
66
|
+
private haltProcessingUntilReceive;
|
|
67
|
+
private saveChain;
|
|
50
68
|
constructor(options: SessionOptions);
|
|
51
69
|
get messages(): Message[];
|
|
52
70
|
get usage(): Usage;
|
|
@@ -58,16 +76,37 @@ export declare class Session {
|
|
|
58
76
|
get updatedAt(): number;
|
|
59
77
|
getCwd(): string | undefined;
|
|
60
78
|
setCwd(cwd: string): void;
|
|
79
|
+
send(input: MessageContentInput, options?: SessionQueueSendOptions): string;
|
|
80
|
+
sendBatch(items: Array<{
|
|
81
|
+
input: MessageContentInput;
|
|
82
|
+
options?: SessionQueueSendOptions;
|
|
83
|
+
}>): string[];
|
|
84
|
+
steer(input: MessageContentInput, options?: SessionQueueSendOptions): string;
|
|
85
|
+
cancelQueuedItem(itemId: string): boolean;
|
|
86
|
+
getQueueStatus(): MessageQueueStatus;
|
|
87
|
+
clearQueue(filter?: ClearQueueFilter): number;
|
|
88
|
+
receive(options?: SessionReceiveOptions): AsyncGenerator<SessionStreamEvent, void, void>;
|
|
61
89
|
compact(update: CompactionUpdate): Promise<void>;
|
|
62
90
|
save(): Promise<void>;
|
|
91
|
+
private writeSnapshot;
|
|
63
92
|
toSnapshot(): SessionSnapshot;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
93
|
+
private enqueueItem;
|
|
94
|
+
private onQueueMutated;
|
|
95
|
+
private hasRunnableItems;
|
|
96
|
+
private ensureQueueProcessing;
|
|
97
|
+
private processQueue;
|
|
98
|
+
private dequeueNextRunnableItem;
|
|
99
|
+
private processQueuedItem;
|
|
100
|
+
private attachQueueContext;
|
|
101
|
+
private createErrorEvent;
|
|
102
|
+
private pushBufferedEvent;
|
|
103
|
+
private scheduleSave;
|
|
104
|
+
private persistStateQuietly;
|
|
105
|
+
private enqueueSave;
|
|
106
|
+
private waitForStateChange;
|
|
107
|
+
private notifyStateChange;
|
|
70
108
|
private createLoopRunner;
|
|
71
109
|
private readEstimatedInputTokens;
|
|
72
110
|
private createHookContext;
|
|
73
111
|
}
|
|
112
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CallToolResult, SessionPluginEvent, SessionStatus, ToolCall } from '../contracts';
|
|
2
|
-
import type { PluginHost } from '../plugin-host/
|
|
2
|
+
import type { PluginHost } from '../plugin-host/plugin-host';
|
|
3
3
|
import type { AgentServices } from '../services';
|
|
4
|
-
import type { ToolRegistry } from '../tools/
|
|
4
|
+
import type { ToolRegistry } from '../tools/tool-registry';
|
|
5
5
|
import type { ApprovalManager } from './approvals';
|
|
6
6
|
import type { NotificationBus } from './notifications';
|
|
7
7
|
export interface ToolExecutorExecuteOptions {
|
package/dist/dim-agent-sdk/src/context/{AutoContextManager.d.ts → auto-context-manager.d.ts}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PluginHost } from '../plugin-host/
|
|
1
|
+
import type { PluginHost } from '../plugin-host/plugin-host';
|
|
2
2
|
import type { AgentServices } from '../services';
|
|
3
3
|
import type { ContextItem, ContextManager, ContextResolveOptions } from './types';
|
|
4
4
|
export interface AutoContextManagerOptions {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { AutoContextManager } from './
|
|
2
|
-
export type { AutoContextManagerOptions } from './
|
|
1
|
+
export { AutoContextManager } from './auto-context-manager';
|
|
2
|
+
export type { AutoContextManagerOptions } from './auto-context-manager';
|
|
3
3
|
export type { CompactionBudgetInfo, CompactionCheckpoint, CompactionEstimator, CompactionEstimatorInput, CompactionOptions, CompactionService, CompactionState, CompactionTriggerReason, CompactionUpdate, } from './compaction';
|
|
4
4
|
export type { ContextItem, ContextManager, ContextResolveOptions } from './types';
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import type { SessionErrorPayload, Usage } from './common';
|
|
2
2
|
import type { AssistantMessage } from './message';
|
|
3
|
+
import type { PendingMessageKind } from './state';
|
|
3
4
|
import type { CallToolResult, ToolCall } from './tool';
|
|
5
|
+
export interface SessionQueueEventContext {
|
|
6
|
+
itemId?: string;
|
|
7
|
+
itemKind?: PendingMessageKind;
|
|
8
|
+
priority?: number;
|
|
9
|
+
}
|
|
4
10
|
export interface SessionPluginEvent {
|
|
5
11
|
type: 'plugin_event';
|
|
6
12
|
sessionId: string;
|
|
@@ -8,30 +14,30 @@ export interface SessionPluginEvent {
|
|
|
8
14
|
event: string;
|
|
9
15
|
data?: Record<string, unknown>;
|
|
10
16
|
}
|
|
11
|
-
export type SessionStreamEvent = {
|
|
17
|
+
export type SessionStreamEvent = ({
|
|
12
18
|
type: 'text_delta';
|
|
13
19
|
sessionId: string;
|
|
14
20
|
delta: string;
|
|
15
|
-
} | {
|
|
21
|
+
} & SessionQueueEventContext) | ({
|
|
16
22
|
type: 'thinking_delta';
|
|
17
23
|
sessionId: string;
|
|
18
24
|
delta: string;
|
|
19
|
-
} | {
|
|
25
|
+
} & SessionQueueEventContext) | ({
|
|
20
26
|
type: 'tool_call';
|
|
21
27
|
sessionId: string;
|
|
22
28
|
toolCall: ToolCall;
|
|
23
|
-
} | {
|
|
29
|
+
} & SessionQueueEventContext) | ({
|
|
24
30
|
type: 'tool_result';
|
|
25
31
|
sessionId: string;
|
|
26
32
|
toolCallId: string;
|
|
27
33
|
result: CallToolResult;
|
|
28
|
-
} | SessionPluginEvent | {
|
|
34
|
+
} & SessionQueueEventContext) | (SessionPluginEvent & SessionQueueEventContext) | ({
|
|
29
35
|
type: 'done';
|
|
30
36
|
sessionId: string;
|
|
31
37
|
message: AssistantMessage;
|
|
32
38
|
usage?: Usage;
|
|
33
|
-
} | {
|
|
39
|
+
} & SessionQueueEventContext) | ({
|
|
34
40
|
type: 'error';
|
|
35
41
|
sessionId: string;
|
|
36
42
|
error: SessionErrorPayload;
|
|
37
|
-
};
|
|
43
|
+
} & SessionQueueEventContext);
|
|
@@ -1,10 +1,40 @@
|
|
|
1
1
|
import type { CompactionState } from './compaction';
|
|
2
|
+
import type { MessageContentInput } from './content';
|
|
2
3
|
import type { PluginSessionStateEntry } from './plugin-state';
|
|
3
4
|
import type { Usage } from './common';
|
|
4
5
|
import type { Message } from './message';
|
|
5
6
|
import type { ModelRef } from './model';
|
|
7
|
+
export interface MessageQueueConfig {
|
|
8
|
+
autoProcessQueue: boolean;
|
|
9
|
+
maxQueueSize?: number;
|
|
10
|
+
}
|
|
11
|
+
export type PendingMessageKind = 'user' | 'steer';
|
|
12
|
+
export interface PendingMessage {
|
|
13
|
+
id: string;
|
|
14
|
+
input: MessageContentInput;
|
|
15
|
+
kind: PendingMessageKind;
|
|
16
|
+
priority: number;
|
|
17
|
+
enqueuedAt: number;
|
|
18
|
+
}
|
|
19
|
+
export interface MessageQueueSnapshot {
|
|
20
|
+
items: PendingMessage[];
|
|
21
|
+
config: MessageQueueConfig;
|
|
22
|
+
}
|
|
23
|
+
export interface MessageQueueStatusItem {
|
|
24
|
+
id: string;
|
|
25
|
+
kind: PendingMessageKind;
|
|
26
|
+
priority: number;
|
|
27
|
+
enqueuedAt: number;
|
|
28
|
+
preview: string;
|
|
29
|
+
}
|
|
30
|
+
export interface MessageQueueStatus {
|
|
31
|
+
length: number;
|
|
32
|
+
items: MessageQueueStatusItem[];
|
|
33
|
+
isProcessing: boolean;
|
|
34
|
+
config: MessageQueueConfig;
|
|
35
|
+
}
|
|
6
36
|
export interface SessionSnapshot {
|
|
7
|
-
schemaVersion: 1;
|
|
37
|
+
schemaVersion: 1 | 2;
|
|
8
38
|
sessionId: string;
|
|
9
39
|
model?: ModelRef;
|
|
10
40
|
cwd?: string;
|
|
@@ -15,6 +45,7 @@ export interface SessionSnapshot {
|
|
|
15
45
|
createdAt: number;
|
|
16
46
|
updatedAt: number;
|
|
17
47
|
metadata?: Record<string, unknown>;
|
|
48
|
+
messageQueue?: MessageQueueSnapshot;
|
|
18
49
|
}
|
|
19
50
|
export interface SessionStatus {
|
|
20
51
|
sessionId: string;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
export type { CallToolResult, CompactionBudgetInfo, CompactionCheckpoint, CompactionEstimator, CompactionEstimatorInput, CompactionOptions, CompactionService, CompactionState, CompactionTriggerReason, CompactionUpdate, ContentBlock, Message, MessageContentInput, ModelAdapter, ModelClient, ModelRequest, ModelStreamEvent, ModelStopReason, ModelRef, PluginSessionStateEntry, PluginStateService, SessionStatus, SessionPluginEvent, SessionSnapshot, SessionStreamEvent, Tool, ToolCall, ToolDefinition, ToolExecutionContext, ToolExecutionPluginEvent, ToolInputSchema, Usage, } from './contracts';
|
|
1
|
+
export type { CallToolResult, CompactionBudgetInfo, CompactionCheckpoint, CompactionEstimator, CompactionEstimatorInput, CompactionOptions, CompactionService, CompactionState, CompactionTriggerReason, CompactionUpdate, ContentBlock, Message, MessageContentInput, MessageQueueConfig, MessageQueueSnapshot, MessageQueueStatus, ModelAdapter, ModelClient, ModelRequest, ModelStreamEvent, ModelStopReason, ModelRef, PluginSessionStateEntry, PendingMessage, PendingMessageKind, PluginStateService, SessionStatus, SessionPluginEvent, SessionSnapshot, SessionStreamEvent, Tool, ToolCall, ToolDefinition, ToolExecutionContext, ToolExecutionPluginEvent, ToolInputSchema, Usage, } from './contracts';
|
|
2
2
|
export { normalizeContent } from './contracts/content-normalize';
|
|
3
|
-
export { Agent, createAgent } from './agent-core/
|
|
4
|
-
export type { CreateAgentOptions } from './agent-core/
|
|
3
|
+
export { Agent, createAgent } from './agent-core/agent';
|
|
4
|
+
export type { CreateAgentOptions } from './agent-core/agent';
|
|
5
5
|
export { DefaultCompactionService } from './agent-core/compaction';
|
|
6
|
-
export { Session } from './agent-core/
|
|
6
|
+
export { Session } from './agent-core/session';
|
|
7
7
|
export { SessionExecutionError } from './agent-core/errors';
|
|
8
8
|
export { FileStateStore, InMemoryStateStore } from './persistence';
|
|
9
9
|
export { BaseTool, EditTool, ExecTool, ReadTool, ToolRegistry, WriteTool, } from './tools';
|
|
10
10
|
export { appendToolCallArgsDelta, finalizeToolCall, startToolCall, } from './agent-core/tool-call';
|
|
11
11
|
export { normalizeToolResult, normalizeToolSchema } from './contracts/tool-normalize';
|
|
12
|
-
export { createAnthropicAdapter, createGeminiAdapter, createOpenAIAdapter, createOpenAIResponsesAdapter } from './providers';
|
|
13
|
-
export {
|
|
12
|
+
export { createAihubmixAdapter, createAihubmixResponsesAdapter, createAnthropicAdapter, createDeepSeekAdapter, createGeminiAdapter, createMoonshotAIAdapter, createOpenAIAdapter, createOpenAIResponsesAdapter, createXaiAdapter, createXaiResponsesAdapter, createZenMuxAdapter, } from './providers';
|
|
13
|
+
export type { AihubmixAdapterOptions, AihubmixResponsesAdapterOptions, AnthropicAdapterOptions, DeepSeekAdapterOptions, GeminiAdapterOptions, MoonshotAIAdapterOptions, OpenAIAdapterOptions, OpenAIResponsesAdapterOptions, XaiAdapterOptions, XaiResponsesAdapterOptions, ZenMuxAdapterOptions, } from './providers';
|
|
14
|
+
export { createModel } from './agent-core/create-model';
|
|
14
15
|
export type { ContextItem, ContextManager, ContextResolveOptions, } from './context';
|
|
15
16
|
export { AutoContextManager } from './context';
|
|
16
17
|
export type { AgentServices, ExecGateway, ExecOptions, ExecResult, FileSystemGateway, FileSystemPermission, GitGateway, GlobOptions, GrepMatch, GrepOptions, ModelGateway, NetworkGateway, PermissionSpec, } from './services';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { FileStateStore } from './
|
|
2
|
-
export type { FileStateStoreOptions } from './
|
|
3
|
-
export { InMemoryStateStore } from './
|
|
4
|
-
export { JsonSnapshotCodec, sessionSnapshotCodec } from './
|
|
5
|
-
export type { SnapshotCodec, SnapshotCodecInput } from './
|
|
1
|
+
export { FileStateStore } from './file-state-store';
|
|
2
|
+
export type { FileStateStoreOptions } from './file-state-store';
|
|
3
|
+
export { InMemoryStateStore } from './in-memory-state-store';
|
|
4
|
+
export { JsonSnapshotCodec, sessionSnapshotCodec } from './snapshot-codec';
|
|
5
|
+
export type { SnapshotCodec, SnapshotCodecInput } from './snapshot-codec';
|
|
6
6
|
export type { StateStore } from './store';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CompactionState, Message, ModelRef, PluginSessionStateEntry, SessionSnapshot, Usage } from '../contracts';
|
|
1
|
+
import type { CompactionState, Message, MessageQueueSnapshot, ModelRef, PluginSessionStateEntry, SessionSnapshot, Usage } from '../contracts';
|
|
2
2
|
export interface SnapshotCodecInput {
|
|
3
3
|
sessionId: string;
|
|
4
4
|
model?: ModelRef;
|
|
@@ -10,6 +10,7 @@ export interface SnapshotCodecInput {
|
|
|
10
10
|
createdAt: number;
|
|
11
11
|
updatedAt: number;
|
|
12
12
|
metadata?: Record<string, unknown>;
|
|
13
|
+
messageQueue?: MessageQueueSnapshot;
|
|
13
14
|
}
|
|
14
15
|
export interface SnapshotCodec {
|
|
15
16
|
encode(input: SnapshotCodecInput): SessionSnapshot;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { allowToolCall, askToolCall, continueHook, continueNotification, continueRun, denyToolCall, finalizeRun, provideToolResult, replaceHook, replaceNotification, replaceToolCall, stopHook, suppressNotification, } from './helpers';
|
|
2
|
-
export { HookPipeline } from './
|
|
3
|
-
export { PluginHost } from './
|
|
2
|
+
export { HookPipeline } from './hook-pipeline';
|
|
3
|
+
export { PluginHost } from './plugin-host';
|
|
4
4
|
export type { AgentMode, AnyHookRegistrationEntry, ApprovalDecision, ApprovalRequest, AskApprovalInput, ContextCompactBeforePayload, ContextContributor, ContextContributorInput, ContextItem, DimPlugin, HookControlResult, HookDescriptor, HookHandler, HookMatcher, HookMiddleware, HookMiddlewareResult, HookMode, HookName, HookObserver, HookPayloadMap, HookRegistration, HookRegistrationEntry, InternalHookName, NotificationControlResult, NotificationHookPayload, NotificationPayload, PermissionSpec, PluginContext, PluginManifest, PluginRuntimeContext, PluginSessionControllerContext, PluginSessionControllerFactory, PluginSessionStateEntry, PluginStateService, PluginServices, PluginSetupResult, PromptContributor, PromptContributorInput, PublicHookName, RunEndPayload, RunLoopDecision, RunStartPayload, RunStopControlResult, RunStopPayload, SessionStatus, SessionErrorHookPayload, SubagentStopPayload, ToolBeforeExecuteControlResult, } from './types';
|
|
@@ -3,7 +3,7 @@ import type { SessionStatus } from '../contracts';
|
|
|
3
3
|
import { PermissionGateway } from '../services';
|
|
4
4
|
import type { ActivityTracker, AgentServices } from '../services';
|
|
5
5
|
import type { Tool } from '../contracts';
|
|
6
|
-
import { HookPipeline } from './
|
|
6
|
+
import { HookPipeline } from './hook-pipeline';
|
|
7
7
|
import type { ContextContributorInput, DimPlugin, HookName, HookPayloadMap, PluginRuntimeContext, PromptContributorInput, RunStopPayload, ToolBeforeExecutePayload } from './types';
|
|
8
8
|
type SpecialHookName = 'notify.message' | 'run.stop' | 'tool.beforeExecute';
|
|
9
9
|
type StandardHookName = Exclude<HookName, SpecialHookName>;
|
|
@@ -41,13 +41,13 @@ export declare class PluginHost {
|
|
|
41
41
|
}): Promise<HookPayloadMap[N]>;
|
|
42
42
|
runToolBeforeExecute(payload: ToolBeforeExecutePayload, context?: Omit<PluginRuntimeContext, 'agentId' | 'services'> & {
|
|
43
43
|
services?: AgentServices;
|
|
44
|
-
}): Promise<import("./
|
|
44
|
+
}): Promise<import("./hook-pipeline").ToolBeforeExecuteHookResult>;
|
|
45
45
|
runNotifyMessage(payload: HookPayloadMap['notify.message'], context?: Omit<PluginRuntimeContext, 'agentId' | 'services'> & {
|
|
46
46
|
services?: AgentServices;
|
|
47
|
-
}): Promise<import("./
|
|
47
|
+
}): Promise<import("./hook-pipeline").NotifyMessageHookResult>;
|
|
48
48
|
runRunStop(payload: RunStopPayload, context?: Omit<PluginRuntimeContext, 'agentId' | 'services'> & {
|
|
49
49
|
services?: AgentServices;
|
|
50
|
-
}): Promise<import("./
|
|
50
|
+
}): Promise<import("./hook-pipeline").RunStopHookResult>;
|
|
51
51
|
runObservers<N extends HookName>(name: N, payload: HookPayloadMap[N], context?: Omit<PluginRuntimeContext, 'agentId' | 'services'> & {
|
|
52
52
|
services?: AgentServices;
|
|
53
53
|
}): Promise<void>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ConfiguredModelAdapter } from '../../contracts';
|
|
2
|
+
import { type ProviderFactoryOptionsBase } from '../core/create-provider-factory';
|
|
3
|
+
type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
4
|
+
export interface AihubmixAdapterOptions extends ProviderFactoryOptionsBase {
|
|
5
|
+
/**
|
|
6
|
+
* AIHubMix API key. When omitted, your custom fetch must attach the real
|
|
7
|
+
* upstream credentials before the request is sent.
|
|
8
|
+
*/
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
fetch?: FetchLike;
|
|
11
|
+
/**
|
|
12
|
+
* Compatibility mode forwarded to the AIHubMix provider package.
|
|
13
|
+
*/
|
|
14
|
+
compatibility?: 'strict' | 'compatible';
|
|
15
|
+
}
|
|
16
|
+
export declare const createAihubmixAdapter: (options: AihubmixAdapterOptions) => ConfiguredModelAdapter;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ConfiguredModelAdapter } from '../../contracts';
|
|
2
|
+
import { type ProviderFactoryOptionsBase } from '../core/create-provider-factory';
|
|
3
|
+
type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
4
|
+
export interface AihubmixResponsesAdapterOptions extends ProviderFactoryOptionsBase {
|
|
5
|
+
/**
|
|
6
|
+
* AIHubMix API key. When omitted, your custom fetch must attach the real
|
|
7
|
+
* upstream credentials before the request is sent.
|
|
8
|
+
*/
|
|
9
|
+
apiKey?: string;
|
|
10
|
+
fetch?: FetchLike;
|
|
11
|
+
/**
|
|
12
|
+
* Compatibility mode forwarded to the AIHubMix provider package.
|
|
13
|
+
*/
|
|
14
|
+
compatibility?: 'strict' | 'compatible';
|
|
15
|
+
}
|
|
16
|
+
export declare const createAihubmixResponsesAdapter: (options: AihubmixResponsesAdapterOptions) => ConfiguredModelAdapter;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ProviderDriver } from '../core/create-provider-factory';
|
|
2
|
+
import type { AihubmixResponsesAdapterOptions } from './adapter';
|
|
3
|
+
export declare const aihubmixResponsesDriver: ProviderDriver<AihubmixResponsesAdapterOptions>;
|
|
4
|
+
export declare function createReasoningAwareResponsesFetch(input: {
|
|
5
|
+
fetch?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
6
|
+
stripAuthorization: boolean;
|
|
7
|
+
requestReasoning: {
|
|
8
|
+
effort?: string;
|
|
9
|
+
summary?: string;
|
|
10
|
+
} | undefined;
|
|
11
|
+
}): typeof fetch;
|
|
12
|
+
export declare function parseJsonBody(body: BodyInit): unknown;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { LanguageModelV3GenerateResult } from '@ai-sdk/provider';
|
|
2
|
+
import type { Message } from '../../contracts';
|
|
3
|
+
export declare function sliceMessagesForAihubmixResponses(messages: Message[]): {
|
|
4
|
+
messages: Message[];
|
|
5
|
+
previousResponseId?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare function createAihubmixResponsesAssistantMetadata(result: LanguageModelV3GenerateResult): Record<string, unknown> | undefined;
|
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
import type { ConfiguredModelAdapter } from '../../contracts';
|
|
2
|
+
import { type ProviderFactoryOptionsBase } from '../core/create-provider-factory';
|
|
2
3
|
type FetchLike = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
|
3
|
-
export interface AnthropicAdapterOptions {
|
|
4
|
+
export interface AnthropicAdapterOptions extends ProviderFactoryOptionsBase {
|
|
5
|
+
/**
|
|
6
|
+
* Anthropic API key. When omitted, you must inject real upstream auth through
|
|
7
|
+
* custom fetch or explicit auth headers.
|
|
8
|
+
*/
|
|
4
9
|
apiKey?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Custom Anthropic base URL prefix.
|
|
12
|
+
* When the value does not end with `/v1`, the adapter appends `/v1`
|
|
13
|
+
* before handing it to the Anthropic AI SDK.
|
|
14
|
+
*/
|
|
5
15
|
baseUrl?: string;
|
|
6
|
-
defaultModel: string;
|
|
7
|
-
provider?: string;
|
|
8
16
|
fetch?: FetchLike;
|
|
17
|
+
/**
|
|
18
|
+
* Custom headers sent to the Anthropic AI SDK request layer.
|
|
19
|
+
*/
|
|
9
20
|
headers?: Record<string, string>;
|
|
10
21
|
anthropicVersion?: string;
|
|
11
22
|
}
|
|
12
|
-
export declare
|
|
23
|
+
export declare const createAnthropicAdapter: (options: AnthropicAdapterOptions) => ConfiguredModelAdapter;
|
|
13
24
|
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { LanguageModelV3GenerateResult } from '@ai-sdk/provider';
|
|
2
|
+
import type { AssistantMessage } from '../../contracts';
|
|
3
|
+
import type { AssistantPromptPart } from '../shared/prompt';
|
|
4
|
+
export declare function anthropicAssistantPrefixParts(message: AssistantMessage): AssistantPromptPart[];
|
|
5
|
+
export declare function hasAnthropicThinkingState(message: AssistantMessage): boolean;
|
|
6
|
+
export declare function createAnthropicAssistantMetadata(result: LanguageModelV3GenerateResult): Record<string, unknown> | undefined;
|