@archships/dim-agent-sdk 0.0.1 → 0.0.2
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 +115 -4
- package/dist/{agent-core → dim-agent-sdk/src/agent-core}/Agent.d.ts +7 -1
- package/dist/{agent-core → dim-agent-sdk/src/agent-core}/LoopRunner.d.ts +6 -0
- package/dist/{agent-core → dim-agent-sdk/src/agent-core}/Session.d.ts +26 -1
- package/dist/{agent-core → dim-agent-sdk/src/agent-core}/ToolExecutor.d.ts +11 -1
- package/dist/{agent-core → dim-agent-sdk/src/agent-core}/agent-types.d.ts +5 -2
- package/dist/dim-agent-sdk/src/agent-core/approvals.d.ts +25 -0
- package/dist/dim-agent-sdk/src/agent-core/compaction.d.ts +22 -0
- package/dist/{agent-core → dim-agent-sdk/src/agent-core}/errors.d.ts +1 -0
- package/dist/{agent-core → dim-agent-sdk/src/agent-core}/index.d.ts +7 -0
- package/dist/dim-agent-sdk/src/agent-core/notifications.d.ts +25 -0
- package/dist/dim-agent-sdk/src/agent-core/plugin-state.d.ts +24 -0
- package/dist/{agent-core → dim-agent-sdk/src/agent-core}/session-state.d.ts +4 -1
- package/dist/dim-agent-sdk/src/agent-core/session-status.d.ts +4 -0
- package/dist/dim-agent-sdk/src/agent-core/subagent.d.ts +14 -0
- package/dist/dim-agent-sdk/src/context/compaction.d.ts +1 -0
- package/dist/dim-agent-sdk/src/context/index.d.ts +4 -0
- package/dist/dim-agent-sdk/src/contracts/compaction.d.ts +52 -0
- package/dist/{contracts → dim-agent-sdk/src/contracts}/event.d.ts +8 -1
- package/dist/{contracts → dim-agent-sdk/src/contracts}/index.d.ts +2 -0
- package/dist/dim-agent-sdk/src/contracts/plugin-state.d.ts +11 -0
- package/dist/dim-agent-sdk/src/contracts/state.d.ts +29 -0
- package/dist/{contracts → dim-agent-sdk/src/contracts}/tool.d.ts +6 -0
- package/dist/{index.d.ts → dim-agent-sdk/src/index.d.ts} +2 -1
- package/dist/{persistence → dim-agent-sdk/src/persistence}/SnapshotCodec.d.ts +3 -1
- package/dist/dim-agent-sdk/src/plugin-host/HookPipeline.d.ts +30 -0
- package/dist/dim-agent-sdk/src/plugin-host/PluginHost.d.ts +58 -0
- package/dist/dim-agent-sdk/src/plugin-host/helpers.d.ts +6 -0
- package/dist/dim-agent-sdk/src/plugin-host/index.d.ts +4 -0
- package/dist/dim-agent-sdk/src/plugin-host/types.d.ts +1 -0
- package/dist/{services → dim-agent-sdk/src/services}/PermissionGateway.d.ts +3 -0
- package/dist/{services → dim-agent-sdk/src/services}/types.d.ts +3 -1
- package/dist/dim-plugin-api/src/index.d.ts +602 -0
- package/dist/index.js +1194 -166
- package/package.json +11 -4
- package/dist/context/index.d.ts +0 -3
- package/dist/contracts/state.d.ts +0 -14
- package/dist/plugin-host/HookPipeline.d.ts +0 -7
- package/dist/plugin-host/PluginHost.d.ts +0 -36
- package/dist/plugin-host/helpers.d.ts +0 -3
- package/dist/plugin-host/index.d.ts +0 -4
- package/dist/plugin-host/types.d.ts +0 -1
- /package/dist/{agent-core → dim-agent-sdk/src/agent-core}/MessageFactory.d.ts +0 -0
- /package/dist/{agent-core → dim-agent-sdk/src/agent-core}/ModelTurnCollector.d.ts +0 -0
- /package/dist/{agent-core → dim-agent-sdk/src/agent-core}/TerminationPolicy.d.ts +0 -0
- /package/dist/{agent-core → dim-agent-sdk/src/agent-core}/createModel.d.ts +0 -0
- /package/dist/{agent-core → dim-agent-sdk/src/agent-core}/tool-call.d.ts +0 -0
- /package/dist/{context → dim-agent-sdk/src/context}/AutoContextManager.d.ts +0 -0
- /package/dist/{context → dim-agent-sdk/src/context}/types.d.ts +0 -0
- /package/dist/{contracts → dim-agent-sdk/src/contracts}/common.d.ts +0 -0
- /package/dist/{contracts → dim-agent-sdk/src/contracts}/content-normalize.d.ts +0 -0
- /package/dist/{contracts → dim-agent-sdk/src/contracts}/content.d.ts +0 -0
- /package/dist/{contracts → dim-agent-sdk/src/contracts}/message.d.ts +0 -0
- /package/dist/{contracts → dim-agent-sdk/src/contracts}/model.d.ts +0 -0
- /package/dist/{contracts → dim-agent-sdk/src/contracts}/tool-normalize.d.ts +0 -0
- /package/dist/{persistence → dim-agent-sdk/src/persistence}/FileStateStore.d.ts +0 -0
- /package/dist/{persistence → dim-agent-sdk/src/persistence}/InMemoryStateStore.d.ts +0 -0
- /package/dist/{persistence → dim-agent-sdk/src/persistence}/index.d.ts +0 -0
- /package/dist/{persistence → dim-agent-sdk/src/persistence}/store.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/anthropic/adapter.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/anthropic/mapper.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/gemini/adapter.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/gemini/mapper.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/index.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/openai/adapter.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/openai/mapper.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/openai-responses/adapter.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/openai-responses/mapper.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/shared/http-error.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/shared/provider-state.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/shared/reasoning.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/shared/tool-call.d.ts +0 -0
- /package/dist/{providers → dim-agent-sdk/src/providers}/shared/usage.d.ts +0 -0
- /package/dist/{services → dim-agent-sdk/src/services}/ExecGateway.d.ts +0 -0
- /package/dist/{services → dim-agent-sdk/src/services}/FileSystemGateway.d.ts +0 -0
- /package/dist/{services → dim-agent-sdk/src/services}/GitGateway.d.ts +0 -0
- /package/dist/{services → dim-agent-sdk/src/services}/ModelGateway.d.ts +0 -0
- /package/dist/{services → dim-agent-sdk/src/services}/NetworkGateway.d.ts +0 -0
- /package/dist/{services → dim-agent-sdk/src/services}/activity.d.ts +0 -0
- /package/dist/{services → dim-agent-sdk/src/services}/index.d.ts +0 -0
- /package/dist/{services → dim-agent-sdk/src/services}/permissions.d.ts +0 -0
- /package/dist/{tools → dim-agent-sdk/src/tools}/BaseTool.d.ts +0 -0
- /package/dist/{tools → dim-agent-sdk/src/tools}/ToolRegistry.d.ts +0 -0
- /package/dist/{tools → dim-agent-sdk/src/tools}/builtins/EditTool.d.ts +0 -0
- /package/dist/{tools → dim-agent-sdk/src/tools}/builtins/ExecTool.d.ts +0 -0
- /package/dist/{tools → dim-agent-sdk/src/tools}/builtins/ReadTool.d.ts +0 -0
- /package/dist/{tools → dim-agent-sdk/src/tools}/builtins/WriteTool.d.ts +0 -0
- /package/dist/{tools → dim-agent-sdk/src/tools}/builtins/index.d.ts +0 -0
- /package/dist/{tools → dim-agent-sdk/src/tools}/builtins/utils.d.ts +0 -0
- /package/dist/{tools → dim-agent-sdk/src/tools}/index.d.ts +0 -0
- /package/dist/{tools → dim-agent-sdk/src/tools}/result.d.ts +0 -0
- /package/dist/{utils → dim-agent-sdk/src/utils}/guards.d.ts +0 -0
- /package/dist/{utils → dim-agent-sdk/src/utils}/id.d.ts +0 -0
- /package/dist/{utils → dim-agent-sdk/src/utils}/json.d.ts +0 -0
- /package/dist/{utils → dim-agent-sdk/src/utils}/usage.d.ts +0 -0
package/README.md
CHANGED
|
@@ -48,13 +48,63 @@ console.log(message.content)
|
|
|
48
48
|
|
|
49
49
|
- Canonical content / message / tool / model / state contracts
|
|
50
50
|
- `createAgent()` -> `Agent` -> `Session`
|
|
51
|
-
- Session stream events: `text_delta`, optional `thinking_delta`, `tool_call`, `tool_result`, `done`
|
|
51
|
+
- Session stream events: `text_delta`, optional `thinking_delta`, `tool_call`, `plugin_event`, `tool_result`, `done`
|
|
52
52
|
- Provider adapters: `openai-compatible`, `openai-responses`, `anthropic`, `gemini`
|
|
53
53
|
- Builtin tools: `read`, `write`, `edit`, `exec`
|
|
54
54
|
- Hook-first plugin integration
|
|
55
55
|
- Runtime gateways: file system, git, exec, network, model
|
|
56
|
+
- Namespaced plugin session state with snapshot restore support
|
|
56
57
|
- In-memory and file-based persistence
|
|
57
58
|
|
|
59
|
+
## Hook support
|
|
60
|
+
|
|
61
|
+
Supported public hooks in the current runtime:
|
|
62
|
+
|
|
63
|
+
- `run.start`
|
|
64
|
+
- `tool.beforeExecute`
|
|
65
|
+
- `tool.afterExecute`
|
|
66
|
+
- `context.compact.before`
|
|
67
|
+
- `notify.message`
|
|
68
|
+
- `run.stop`
|
|
69
|
+
- `run.end`
|
|
70
|
+
- `session.error`
|
|
71
|
+
|
|
72
|
+
Reserved / experimental hook names that are typed but not wired into the runtime yet:
|
|
73
|
+
|
|
74
|
+
- `subagent.stop`
|
|
75
|
+
|
|
76
|
+
Current failure policy:
|
|
77
|
+
|
|
78
|
+
- Sync middleware is blocking and fail-fast
|
|
79
|
+
- Observers are best-effort
|
|
80
|
+
- `mode: 'async'` is observer-only
|
|
81
|
+
- `timeoutMs` applies per hook handler
|
|
82
|
+
|
|
83
|
+
## Official plugin packages
|
|
84
|
+
|
|
85
|
+
| Package | Support level | Notes |
|
|
86
|
+
| --- | --- | --- |
|
|
87
|
+
| `@archships/dim-plugin-auto-compact` | supported | Official auto compaction plugin; requires `compaction.ownerPluginId: 'auto-compact'` |
|
|
88
|
+
| `@archships/dim-plugin-grep-glob` | supported | Registers `grep` and `glob` filesystem tools |
|
|
89
|
+
| `@archships/dim-plugin-mcp-client` | supported | Bridge-style MCP injection plugin for tools, context, and prompt segments |
|
|
90
|
+
| `@archships/dim-plugin-skills` | supported | Prompt contributor wrapper for reusable instructions |
|
|
91
|
+
| `@archships/dim-plugin-plan-mode` | supported | Controller-driven planning guardrail with reminder injection, read-only tool filtering, and `plan_exit` UI events |
|
|
92
|
+
| `@archships/dim-plugin-memory` | stub | Placeholder package; not part of the current supported surface |
|
|
93
|
+
| `@archships/dim-plugin-web` | stub | Placeholder package; not part of the current supported surface |
|
|
94
|
+
| `@archships/dim-plugin-scheduler` | stub | Placeholder package; not part of the current supported surface |
|
|
95
|
+
| `@archships/dim-plugin-deep-research` | stub | Placeholder package; not part of the current supported surface |
|
|
96
|
+
|
|
97
|
+
## Compaction and state model
|
|
98
|
+
|
|
99
|
+
- `session.messages` always keeps the full original history for UI and restore
|
|
100
|
+
- Canonical request projection is controlled by SDK compaction state: `cursor`, `systemSegments`, `checkpoints`
|
|
101
|
+
- `Session.getStatus()` returns the canonical read-only session status snapshot used by hook runtime context
|
|
102
|
+
- `Session.getPlugin(pluginId)` returns a session-scoped plugin controller when the plugin exposes one
|
|
103
|
+
- Plugins can persist their own namespaced session state through `pluginState`
|
|
104
|
+
- If `compaction.ownerPluginId` is configured, only that plugin can write canonical compaction through plugin services
|
|
105
|
+
- `Session.compact()` remains available as an app-level override
|
|
106
|
+
- Hook handlers receive the same canonical status through `context.status`, without exposing full message history or other plugins' state
|
|
107
|
+
|
|
58
108
|
## Provider notes
|
|
59
109
|
|
|
60
110
|
- `createOpenAIAdapter()`: OpenAI-compatible Chat Completions style; no official reasoning channel mapping
|
|
@@ -64,6 +114,67 @@ console.log(message.content)
|
|
|
64
114
|
|
|
65
115
|
## Demo
|
|
66
116
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
117
|
+
- `packages/dim-agent-sdk/demo/compaction-scripted.ts`: scripted compaction runtime demo
|
|
118
|
+
- `packages/dim-agent-sdk/demo/auto-compact-plugin.ts`: scripted official auto compact plugin demo
|
|
119
|
+
- `packages/dim-agent-sdk/demo/plan-mode-plugin.ts`: scripted official plan mode plugin demo
|
|
120
|
+
- `packages/dim-agent-sdk/demo/openai-tools.ts`: builtin tools smoke demo
|
|
121
|
+
- `packages/dim-agent-sdk/demo/openai-hooks.ts`: provider-backed Hook v2 scenario runner
|
|
122
|
+
|
|
123
|
+
`compaction-scripted.ts` does not require external model credentials and demonstrates manual compact required, request projection, restore, and the official auto compact plugin inside the lower-level compaction flow.
|
|
124
|
+
|
|
125
|
+
`openai-tools.ts` and `openai-hooks.ts` use `createOpenAIAdapter()` against the OpenAI-compatible Chat API and are intended for local repository development rather than package consumers.
|
|
126
|
+
|
|
127
|
+
Hook demo scenarios:
|
|
128
|
+
|
|
129
|
+
- `lifecycle`
|
|
130
|
+
- `approval-deny`
|
|
131
|
+
- `synthetic-result`
|
|
132
|
+
- `notification-control`
|
|
133
|
+
- `stop-finalize`
|
|
134
|
+
|
|
135
|
+
Run with the same environment variables used by the tools demo:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
bun run demo:hooks
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Run the scripted compaction demo locally:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
bun run demo:compaction
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Run the scripted auto compact plugin demo locally:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
bun run demo:auto-compact
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Run the scripted plan mode plugin demo locally:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
bun run demo:plan-mode
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Plan mode v2 notes:
|
|
160
|
+
|
|
161
|
+
- `plan_exit` emits `plugin_event` instead of directly disabling plan mode
|
|
162
|
+
- host applications can drive plan mode through `session.getPlugin('plan-mode')`
|
|
163
|
+
- enable / disable / exit resolution changes affect the next run, not the current in-flight run
|
|
164
|
+
|
|
165
|
+
## Testing
|
|
166
|
+
|
|
167
|
+
Local repository verification is split into three layers:
|
|
168
|
+
|
|
169
|
+
- `bun run test`: full local regression, including deterministic `test/e2e/*.e2e.test.ts`
|
|
170
|
+
- `bun run test:e2e`: deterministic end-to-end workflows for `plan-mode`, code-agent tool loops, auto-compact restore, and approval / permission boundaries
|
|
171
|
+
- `bun run test:plugins`: focused plugin contract and integration tests
|
|
172
|
+
- `bun run test:smoke`: env-gated provider smoke in `test/smoke/*.smoke.ts`
|
|
173
|
+
|
|
174
|
+
The provider smoke layer reuses:
|
|
175
|
+
|
|
176
|
+
- `DIM_TEST_API_KEY`
|
|
177
|
+
- `DIM_TEST_BASE_URL`
|
|
178
|
+
- `DIM_TEST_MODEL_ID` (optional)
|
|
179
|
+
|
|
180
|
+
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,10 @@
|
|
|
1
|
+
import type { DimPlugin } from '@archships/dim-plugin-api';
|
|
1
2
|
import type { SessionSnapshot } from '../contracts';
|
|
2
3
|
import type { StateStore } from '../persistence/store';
|
|
3
4
|
import { PluginHost } from '../plugin-host/PluginHost';
|
|
4
|
-
import type { DimPlugin } from '@archships/dim-plugin-api';
|
|
5
5
|
import type { AgentServices, PermissionSpec } from '../services';
|
|
6
6
|
import { ToolRegistry } from '../tools';
|
|
7
|
+
import type { ApprovalHandler } from './approvals';
|
|
7
8
|
import { Session } from './Session';
|
|
8
9
|
import type { AgentOptions, CreateSessionOptions } from './agent-types';
|
|
9
10
|
export declare class Agent {
|
|
@@ -17,6 +18,10 @@ export declare class Agent {
|
|
|
17
18
|
private readonly contextManager;
|
|
18
19
|
private readonly tracker;
|
|
19
20
|
private readonly permissionGateway;
|
|
21
|
+
private readonly approvalManager;
|
|
22
|
+
private readonly notificationBus;
|
|
23
|
+
private readonly compactionService;
|
|
24
|
+
private readonly pluginStateService;
|
|
20
25
|
constructor(options: AgentOptions);
|
|
21
26
|
createSession(options?: CreateSessionOptions): Promise<Session>;
|
|
22
27
|
restoreSession(sessionId: string): Promise<Session | null>;
|
|
@@ -25,5 +30,6 @@ export declare class Agent {
|
|
|
25
30
|
export interface CreateAgentOptions extends AgentOptions {
|
|
26
31
|
plugins?: DimPlugin[];
|
|
27
32
|
stateStore?: StateStore;
|
|
33
|
+
approvalHandler?: ApprovalHandler;
|
|
28
34
|
}
|
|
29
35
|
export declare function createAgent(options: CreateAgentOptions): Agent;
|
|
@@ -3,6 +3,7 @@ import type { ContextManager } from '../context';
|
|
|
3
3
|
import type { PluginHost } from '../plugin-host/PluginHost';
|
|
4
4
|
import type { MessageFactory } from './MessageFactory';
|
|
5
5
|
import type { ModelTurnCollector } from './ModelTurnCollector';
|
|
6
|
+
import type { NotificationBus } from './notifications';
|
|
6
7
|
import type { RuntimeSessionState } from './session-state';
|
|
7
8
|
import type { TerminationPolicy } from './TerminationPolicy';
|
|
8
9
|
import type { ToolExecutor } from './ToolExecutor';
|
|
@@ -13,6 +14,7 @@ export interface LoopRunnerDependencies {
|
|
|
13
14
|
terminationPolicy: TerminationPolicy;
|
|
14
15
|
contextManager: ContextManager;
|
|
15
16
|
pluginHost?: PluginHost;
|
|
17
|
+
notificationBus: NotificationBus;
|
|
16
18
|
}
|
|
17
19
|
export interface LoopRunnerRunOptions {
|
|
18
20
|
signal?: AbortSignal;
|
|
@@ -25,6 +27,10 @@ export declare class LoopRunner {
|
|
|
25
27
|
private readonly terminationPolicy;
|
|
26
28
|
private readonly contextManager;
|
|
27
29
|
private readonly pluginHost?;
|
|
30
|
+
private readonly notificationBus;
|
|
28
31
|
constructor(dependencies: LoopRunnerDependencies);
|
|
29
32
|
run(state: RuntimeSessionState, input: MessageContentInput, options?: LoopRunnerRunOptions): AsyncGenerator<SessionStreamEvent, AssistantMessage, void>;
|
|
33
|
+
private resolveRequestMessages;
|
|
34
|
+
private buildProjectedRequestMessages;
|
|
35
|
+
private createHookContext;
|
|
30
36
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import type { AssistantMessage, Message, MessageContentInput, ModelClient, ModelRef, SessionSnapshot, SessionStreamEvent, Usage } from '../contracts';
|
|
1
|
+
import type { AssistantMessage, CompactionOptions, CompactionState, CompactionUpdate, Message, MessageContentInput, 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
4
|
import type { PluginHost } from '../plugin-host/PluginHost';
|
|
5
5
|
import type { AgentServices } from '../services';
|
|
6
6
|
import type { ToolRegistry } from '../tools/ToolRegistry';
|
|
7
|
+
import type { ApprovalManager } from './approvals';
|
|
8
|
+
import { DefaultCompactionService } from './compaction';
|
|
9
|
+
import { DefaultPluginStateService } from './plugin-state';
|
|
10
|
+
import type { NotificationBus } from './notifications';
|
|
7
11
|
export interface SessionOptions {
|
|
8
12
|
id?: string;
|
|
9
13
|
model: ModelClient;
|
|
@@ -16,11 +20,18 @@ export interface SessionOptions {
|
|
|
16
20
|
reasoning?: Record<string, unknown>;
|
|
17
21
|
messages?: Message[];
|
|
18
22
|
usage?: Usage;
|
|
23
|
+
compaction?: CompactionState;
|
|
24
|
+
pluginState?: Record<string, PluginSessionStateEntry>;
|
|
25
|
+
compactionOptions?: CompactionOptions;
|
|
19
26
|
createdAt?: number;
|
|
20
27
|
updatedAt?: number;
|
|
21
28
|
pluginHost?: PluginHost;
|
|
22
29
|
contextManager: ContextManager;
|
|
23
30
|
services: AgentServices;
|
|
31
|
+
approvalManager: ApprovalManager;
|
|
32
|
+
notificationBus: NotificationBus;
|
|
33
|
+
compactionService: DefaultCompactionService;
|
|
34
|
+
pluginStateService: DefaultPluginStateService;
|
|
24
35
|
}
|
|
25
36
|
export declare class Session {
|
|
26
37
|
readonly id: string;
|
|
@@ -30,12 +41,24 @@ export declare class Session {
|
|
|
30
41
|
private readonly pluginHost?;
|
|
31
42
|
private readonly contextManager;
|
|
32
43
|
private readonly services;
|
|
44
|
+
private readonly approvalManager;
|
|
45
|
+
private readonly notificationBus;
|
|
46
|
+
private readonly compactionService;
|
|
47
|
+
private readonly pluginStateService;
|
|
48
|
+
private readonly pluginControllers;
|
|
49
|
+
private activeRunCount;
|
|
33
50
|
constructor(options: SessionOptions);
|
|
34
51
|
get messages(): Message[];
|
|
35
52
|
get usage(): Usage;
|
|
53
|
+
getStatus(): SessionStatus;
|
|
54
|
+
getCompactionState(): CompactionState;
|
|
55
|
+
getPluginState(pluginId: string): PluginSessionStateEntry | null;
|
|
56
|
+
listPluginStates(): Record<string, PluginSessionStateEntry>;
|
|
57
|
+
getPlugin<T = unknown>(pluginId: string): T | null;
|
|
36
58
|
get updatedAt(): number;
|
|
37
59
|
getCwd(): string | undefined;
|
|
38
60
|
setCwd(cwd: string): void;
|
|
61
|
+
compact(update: CompactionUpdate): Promise<void>;
|
|
39
62
|
save(): Promise<void>;
|
|
40
63
|
toSnapshot(): SessionSnapshot;
|
|
41
64
|
send(input: MessageContentInput, options?: {
|
|
@@ -45,4 +68,6 @@ export declare class Session {
|
|
|
45
68
|
signal?: AbortSignal;
|
|
46
69
|
}): AsyncGenerator<SessionStreamEvent, AssistantMessage, void>;
|
|
47
70
|
private createLoopRunner;
|
|
71
|
+
private readEstimatedInputTokens;
|
|
72
|
+
private createHookContext;
|
|
48
73
|
}
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
import type { CallToolResult, ToolCall } from '../contracts';
|
|
1
|
+
import type { CallToolResult, SessionPluginEvent, SessionStatus, ToolCall } from '../contracts';
|
|
2
2
|
import type { PluginHost } from '../plugin-host/PluginHost';
|
|
3
3
|
import type { AgentServices } from '../services';
|
|
4
4
|
import type { ToolRegistry } from '../tools/ToolRegistry';
|
|
5
|
+
import type { ApprovalManager } from './approvals';
|
|
6
|
+
import type { NotificationBus } from './notifications';
|
|
5
7
|
export interface ToolExecutorExecuteOptions {
|
|
6
8
|
signal?: AbortSignal;
|
|
7
9
|
cwd?: string;
|
|
10
|
+
requestId?: string;
|
|
11
|
+
iteration?: number;
|
|
12
|
+
status?: SessionStatus;
|
|
13
|
+
onEvent?: (event: SessionPluginEvent) => Promise<void> | void;
|
|
8
14
|
}
|
|
9
15
|
export interface ToolExecutor {
|
|
10
16
|
execute(toolCall: ToolCall, options?: ToolExecutorExecuteOptions): Promise<CallToolResult>;
|
|
@@ -15,6 +21,8 @@ export interface ToolExecutorOptions {
|
|
|
15
21
|
metadata?: Record<string, unknown>;
|
|
16
22
|
services: AgentServices;
|
|
17
23
|
pluginHost?: PluginHost;
|
|
24
|
+
approvalManager: ApprovalManager;
|
|
25
|
+
notificationBus: NotificationBus;
|
|
18
26
|
}
|
|
19
27
|
export declare class DefaultToolExecutor implements ToolExecutor {
|
|
20
28
|
private readonly sessionId;
|
|
@@ -22,6 +30,8 @@ export declare class DefaultToolExecutor implements ToolExecutor {
|
|
|
22
30
|
private readonly metadata?;
|
|
23
31
|
private readonly services;
|
|
24
32
|
private readonly pluginHost?;
|
|
33
|
+
private readonly approvalManager;
|
|
34
|
+
private readonly notificationBus;
|
|
25
35
|
constructor(options: ToolExecutorOptions);
|
|
26
36
|
execute(toolCall: ToolCall, options?: ToolExecutorExecuteOptions): Promise<CallToolResult>;
|
|
27
37
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { DimPlugin } from '@archships/dim-plugin-api';
|
|
2
|
+
import type { CompactionOptions, Message, MessageContentInput, ModelClient, Tool } from '../contracts';
|
|
2
3
|
import type { ContextManager } from '../context';
|
|
3
4
|
import type { StateStore } from '../persistence/store';
|
|
4
|
-
import type { DimPlugin } from '@archships/dim-plugin-api';
|
|
5
5
|
import type { PermissionSpec } from '../services';
|
|
6
6
|
import type { ToolRegistry } from '../tools/ToolRegistry';
|
|
7
|
+
import type { ApprovalHandler } from './approvals';
|
|
7
8
|
export interface AgentOptions {
|
|
8
9
|
model: ModelClient;
|
|
9
10
|
tools?: ToolRegistry | Tool[];
|
|
@@ -16,6 +17,8 @@ export interface AgentOptions {
|
|
|
16
17
|
contextManager?: ContextManager;
|
|
17
18
|
includeBuiltinTools?: boolean;
|
|
18
19
|
reasoning?: Record<string, unknown>;
|
|
20
|
+
approvalHandler?: ApprovalHandler;
|
|
21
|
+
compaction?: CompactionOptions;
|
|
19
22
|
}
|
|
20
23
|
export interface CreateSessionOptions {
|
|
21
24
|
sessionId?: string;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ApprovalDecision, ApprovalRequest } from '@archships/dim-plugin-api';
|
|
2
|
+
import type { SessionStatus } from '../contracts';
|
|
3
|
+
import type { NotificationBus } from './notifications';
|
|
4
|
+
export type ApprovalHandler = (request: ApprovalRequest) => ApprovalDecision | Promise<ApprovalDecision>;
|
|
5
|
+
export interface ApprovalContext {
|
|
6
|
+
sessionId: string;
|
|
7
|
+
requestId?: string;
|
|
8
|
+
iteration?: number;
|
|
9
|
+
cwd?: string;
|
|
10
|
+
status?: SessionStatus;
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export interface ApprovalManager {
|
|
14
|
+
requestApproval(request: ApprovalRequest, context: ApprovalContext): Promise<ApprovalDecision>;
|
|
15
|
+
}
|
|
16
|
+
export interface DefaultApprovalManagerOptions {
|
|
17
|
+
handler?: ApprovalHandler;
|
|
18
|
+
notifications?: NotificationBus;
|
|
19
|
+
}
|
|
20
|
+
export declare class DefaultApprovalManager implements ApprovalManager {
|
|
21
|
+
private readonly handler?;
|
|
22
|
+
private readonly notifications?;
|
|
23
|
+
constructor(options?: DefaultApprovalManagerOptions);
|
|
24
|
+
requestApproval(request: ApprovalRequest, context: ApprovalContext): Promise<ApprovalDecision>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CompactionBudgetInfo, CompactionEstimatorInput, CompactionOptions, CompactionService, CompactionServiceUpdate, CompactionState, CompactionUpdate, Message } from '../contracts';
|
|
2
|
+
import type { RuntimeSessionState } from './session-state';
|
|
3
|
+
export declare function createEmptyCompactionState(): CompactionState;
|
|
4
|
+
export declare function cloneCompactionState(state: CompactionState | undefined): CompactionState;
|
|
5
|
+
export declare function normalizeCompactionState(state: CompactionState | undefined, messages: Message[]): CompactionState;
|
|
6
|
+
export declare function applyCompactionUpdate(state: RuntimeSessionState, update: CompactionUpdate): CompactionState;
|
|
7
|
+
export declare function clearCompactionState(state: RuntimeSessionState): CompactionState;
|
|
8
|
+
export declare function projectMessagesForRequest(messages: Message[], compaction: CompactionState): Message[];
|
|
9
|
+
export declare function buildCompactionPromptSegments(compaction: CompactionState): string[];
|
|
10
|
+
export declare function calculateThresholdTokens(options: CompactionOptions): number;
|
|
11
|
+
export declare function estimateCompactionBudget(options: CompactionOptions, input: CompactionEstimatorInput): Promise<CompactionBudgetInfo>;
|
|
12
|
+
export declare function isCompactionRequired(options: CompactionOptions | undefined, budget: CompactionBudgetInfo | undefined): boolean;
|
|
13
|
+
export declare function didCompactionStateChange(before: CompactionState, after: CompactionState): boolean;
|
|
14
|
+
export declare class DefaultCompactionService implements CompactionService {
|
|
15
|
+
private readonly sessions;
|
|
16
|
+
registerSession(state: RuntimeSessionState): void;
|
|
17
|
+
unregisterSession(sessionId: string): void;
|
|
18
|
+
getState(sessionId: string): Promise<CompactionState>;
|
|
19
|
+
apply(update: CompactionServiceUpdate): Promise<CompactionState>;
|
|
20
|
+
clear(sessionId: string): Promise<CompactionState>;
|
|
21
|
+
private requireSession;
|
|
22
|
+
}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
export { Agent, createAgent } from './Agent';
|
|
2
|
+
export type { ApprovalContext, ApprovalHandler, ApprovalManager } from './approvals';
|
|
3
|
+
export { DefaultCompactionService, applyCompactionUpdate, buildCompactionPromptSegments, calculateThresholdTokens, clearCompactionState, cloneCompactionState, createEmptyCompactionState, didCompactionStateChange, estimateCompactionBudget, isCompactionRequired, normalizeCompactionState, projectMessagesForRequest, } from './compaction';
|
|
4
|
+
export { DefaultPluginStateService, clonePluginSessionStateEntry, clonePluginStateMap, normalizePluginStateMap, } from './plugin-state';
|
|
2
5
|
export { createModel } from './createModel';
|
|
6
|
+
export { DefaultApprovalManager } from './approvals';
|
|
7
|
+
export { DefaultNotificationBus } from './notifications';
|
|
3
8
|
export { Session } from './Session';
|
|
4
9
|
export { SessionExecutionError } from './errors';
|
|
5
10
|
export type { AgentOptions, CreateSessionOptions } from './agent-types';
|
|
@@ -7,7 +12,9 @@ export type { CreateAgentOptions } from './Agent';
|
|
|
7
12
|
export type { LoopRunnerDependencies, LoopRunnerRunOptions } from './LoopRunner';
|
|
8
13
|
export type { CreateAssistantMessageInput, MessageFactory } from './MessageFactory';
|
|
9
14
|
export type { CollectModelTurnOptions, ModelTurnCollector, ModelTurnResult } from './ModelTurnCollector';
|
|
15
|
+
export type { NotificationBus, NotificationContext } from './notifications';
|
|
10
16
|
export type { RuntimeSessionState } from './session-state';
|
|
11
17
|
export type { SessionOptions } from './Session';
|
|
18
|
+
export type { SubagentInvocation, SubagentResult, SubagentRuntime } from './subagent';
|
|
12
19
|
export type { TerminationDecision, TerminationPolicy } from './TerminationPolicy';
|
|
13
20
|
export type { ToolExecutor, ToolExecutorExecuteOptions, ToolExecutorOptions } from './ToolExecutor';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { SessionStatus } from '../contracts';
|
|
2
|
+
import type { NotificationPayload } from '@archships/dim-plugin-api';
|
|
3
|
+
import type { PluginHost } from '../plugin-host/PluginHost';
|
|
4
|
+
import type { AgentServices } from '../services';
|
|
5
|
+
export interface NotificationContext {
|
|
6
|
+
sessionId?: string;
|
|
7
|
+
requestId?: string;
|
|
8
|
+
iteration?: number;
|
|
9
|
+
cwd?: string;
|
|
10
|
+
status?: SessionStatus;
|
|
11
|
+
metadata?: Record<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
export interface NotificationBus {
|
|
14
|
+
emit(notification: NotificationPayload, context?: NotificationContext): Promise<NotificationPayload | undefined>;
|
|
15
|
+
}
|
|
16
|
+
export interface DefaultNotificationBusOptions {
|
|
17
|
+
pluginHost?: PluginHost;
|
|
18
|
+
services: AgentServices;
|
|
19
|
+
}
|
|
20
|
+
export declare class DefaultNotificationBus implements NotificationBus {
|
|
21
|
+
private readonly pluginHost?;
|
|
22
|
+
private readonly services;
|
|
23
|
+
constructor(options: DefaultNotificationBusOptions);
|
|
24
|
+
emit(notification: NotificationPayload, context?: NotificationContext): Promise<NotificationPayload | undefined>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { PluginSessionStateEntry, PluginStateService } from '../contracts';
|
|
2
|
+
import type { RuntimeSessionState } from './session-state';
|
|
3
|
+
export interface PluginStateManager extends PluginStateService {
|
|
4
|
+
getForPlugin(sessionId: string, pluginId: string): Promise<PluginSessionStateEntry | null>;
|
|
5
|
+
replaceForPlugin(sessionId: string, pluginId: string, entry: PluginSessionStateEntry): Promise<PluginSessionStateEntry>;
|
|
6
|
+
clearForPlugin(sessionId: string, pluginId: string): Promise<void>;
|
|
7
|
+
list(sessionId: string): Promise<Record<string, PluginSessionStateEntry>>;
|
|
8
|
+
}
|
|
9
|
+
export declare function clonePluginSessionStateEntry(entry: PluginSessionStateEntry | null | undefined): PluginSessionStateEntry | null;
|
|
10
|
+
export declare function clonePluginStateMap(state: Record<string, PluginSessionStateEntry> | undefined): Record<string, PluginSessionStateEntry>;
|
|
11
|
+
export declare function normalizePluginStateMap(state: Record<string, PluginSessionStateEntry> | undefined): Record<string, PluginSessionStateEntry>;
|
|
12
|
+
export declare class DefaultPluginStateService implements PluginStateManager {
|
|
13
|
+
private readonly sessions;
|
|
14
|
+
registerSession(state: RuntimeSessionState): void;
|
|
15
|
+
unregisterSession(sessionId: string): void;
|
|
16
|
+
get(sessionId: string): Promise<PluginSessionStateEntry | null>;
|
|
17
|
+
replace(sessionId: string, entry: PluginSessionStateEntry): Promise<PluginSessionStateEntry>;
|
|
18
|
+
clear(sessionId: string): Promise<void>;
|
|
19
|
+
getForPlugin(sessionId: string, pluginId: string): Promise<PluginSessionStateEntry | null>;
|
|
20
|
+
replaceForPlugin(sessionId: string, pluginId: string, entry: PluginSessionStateEntry): Promise<PluginSessionStateEntry>;
|
|
21
|
+
clearForPlugin(sessionId: string, pluginId: string): Promise<void>;
|
|
22
|
+
list(sessionId: string): Promise<Record<string, PluginSessionStateEntry>>;
|
|
23
|
+
private requireSession;
|
|
24
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Message, ModelClient, ModelRef, Usage } from '../contracts';
|
|
1
|
+
import type { CompactionOptions, CompactionState, Message, ModelClient, ModelRef, PluginSessionStateEntry, Usage } from '../contracts';
|
|
2
2
|
import type { ToolRegistry } from '../tools/ToolRegistry';
|
|
3
3
|
export interface RuntimeSessionState {
|
|
4
4
|
id: string;
|
|
@@ -11,6 +11,9 @@ export interface RuntimeSessionState {
|
|
|
11
11
|
reasoning?: Record<string, unknown>;
|
|
12
12
|
messages: Message[];
|
|
13
13
|
usage: Usage;
|
|
14
|
+
compaction: CompactionState;
|
|
15
|
+
pluginState: Record<string, PluginSessionStateEntry>;
|
|
16
|
+
compactionOptions?: CompactionOptions;
|
|
14
17
|
createdAt: number;
|
|
15
18
|
updatedAt: number;
|
|
16
19
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SessionStatus } from '../contracts';
|
|
2
|
+
import type { RuntimeSessionState } from './session-state';
|
|
3
|
+
export declare function createSessionStatus(state: RuntimeSessionState): SessionStatus;
|
|
4
|
+
export declare function cloneSessionStatus(status: SessionStatus | undefined): SessionStatus | undefined;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AssistantMessage, MessageContentInput } from '../contracts';
|
|
2
|
+
export interface SubagentInvocation {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
input: MessageContentInput;
|
|
6
|
+
metadata?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
|
+
export interface SubagentResult {
|
|
9
|
+
message: AssistantMessage;
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export interface SubagentRuntime {
|
|
13
|
+
run(invocation: SubagentInvocation): Promise<SubagentResult>;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { CompactionBudgetInfo, CompactionCheckpoint, CompactionEstimator, CompactionEstimatorInput, CompactionOptions, CompactionService, CompactionState, CompactionTriggerReason, CompactionUpdate, } from '../contracts/compaction';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { AutoContextManager } from './AutoContextManager';
|
|
2
|
+
export type { AutoContextManagerOptions } from './AutoContextManager';
|
|
3
|
+
export type { CompactionBudgetInfo, CompactionCheckpoint, CompactionEstimator, CompactionEstimatorInput, CompactionOptions, CompactionService, CompactionState, CompactionTriggerReason, CompactionUpdate, } from './compaction';
|
|
4
|
+
export type { ContextItem, ContextManager, ContextResolveOptions } from './types';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { Message } from './message';
|
|
2
|
+
import type { ModelRef } from './model';
|
|
3
|
+
import type { ToolDefinition } from './tool';
|
|
4
|
+
export type CompactionTriggerReason = 'manual' | 'threshold';
|
|
5
|
+
export interface CompactionCheckpoint {
|
|
6
|
+
id: string;
|
|
7
|
+
cursor: number;
|
|
8
|
+
systemSegments: string[];
|
|
9
|
+
summary?: string;
|
|
10
|
+
reason: CompactionTriggerReason;
|
|
11
|
+
createdAt: number;
|
|
12
|
+
metadata?: Record<string, unknown>;
|
|
13
|
+
}
|
|
14
|
+
export interface CompactionState {
|
|
15
|
+
cursor: number;
|
|
16
|
+
systemSegments: string[];
|
|
17
|
+
checkpoints: CompactionCheckpoint[];
|
|
18
|
+
}
|
|
19
|
+
export interface CompactionUpdate {
|
|
20
|
+
cursor: number;
|
|
21
|
+
systemSegments?: string[];
|
|
22
|
+
summary?: string;
|
|
23
|
+
reason?: CompactionTriggerReason;
|
|
24
|
+
metadata?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export interface CompactionBudgetInfo {
|
|
27
|
+
estimatedInputTokens: number;
|
|
28
|
+
thresholdTokens: number;
|
|
29
|
+
maxInputTokens: number;
|
|
30
|
+
}
|
|
31
|
+
export interface CompactionEstimatorInput {
|
|
32
|
+
model: ModelRef;
|
|
33
|
+
messages: Message[];
|
|
34
|
+
tools?: ToolDefinition[];
|
|
35
|
+
}
|
|
36
|
+
export type CompactionEstimator = (input: CompactionEstimatorInput) => number | Promise<number>;
|
|
37
|
+
export interface CompactionOptions {
|
|
38
|
+
enabled?: boolean;
|
|
39
|
+
maxInputTokens: number;
|
|
40
|
+
triggerTokens?: number;
|
|
41
|
+
triggerRatio?: number;
|
|
42
|
+
estimator?: CompactionEstimator;
|
|
43
|
+
ownerPluginId?: string;
|
|
44
|
+
}
|
|
45
|
+
export interface CompactionServiceUpdate extends CompactionUpdate {
|
|
46
|
+
sessionId: string;
|
|
47
|
+
}
|
|
48
|
+
export interface CompactionService {
|
|
49
|
+
getState(sessionId: string): Promise<CompactionState>;
|
|
50
|
+
apply(update: CompactionServiceUpdate): Promise<CompactionState>;
|
|
51
|
+
clear(sessionId: string): Promise<CompactionState>;
|
|
52
|
+
}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { SessionErrorPayload, Usage } from './common';
|
|
2
2
|
import type { AssistantMessage } from './message';
|
|
3
3
|
import type { CallToolResult, ToolCall } from './tool';
|
|
4
|
+
export interface SessionPluginEvent {
|
|
5
|
+
type: 'plugin_event';
|
|
6
|
+
sessionId: string;
|
|
7
|
+
pluginId: string;
|
|
8
|
+
event: string;
|
|
9
|
+
data?: Record<string, unknown>;
|
|
10
|
+
}
|
|
4
11
|
export type SessionStreamEvent = {
|
|
5
12
|
type: 'text_delta';
|
|
6
13
|
sessionId: string;
|
|
@@ -18,7 +25,7 @@ export type SessionStreamEvent = {
|
|
|
18
25
|
sessionId: string;
|
|
19
26
|
toolCallId: string;
|
|
20
27
|
result: CallToolResult;
|
|
21
|
-
} | {
|
|
28
|
+
} | SessionPluginEvent | {
|
|
22
29
|
type: 'done';
|
|
23
30
|
sessionId: string;
|
|
24
31
|
message: AssistantMessage;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export * from './common';
|
|
2
|
+
export * from './compaction';
|
|
2
3
|
export * from './content';
|
|
3
4
|
export * from './content-normalize';
|
|
4
5
|
export * from './event';
|
|
5
6
|
export * from './message';
|
|
6
7
|
export * from './model';
|
|
8
|
+
export * from './plugin-state';
|
|
7
9
|
export * from './state';
|
|
8
10
|
export * from './tool';
|
|
9
11
|
export * from './tool-normalize';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JsonObject } from './common';
|
|
2
|
+
export interface PluginSessionStateEntry {
|
|
3
|
+
version: number;
|
|
4
|
+
data: JsonObject;
|
|
5
|
+
updatedAt: number;
|
|
6
|
+
}
|
|
7
|
+
export interface PluginStateService {
|
|
8
|
+
get(sessionId: string): Promise<PluginSessionStateEntry | null>;
|
|
9
|
+
replace(sessionId: string, entry: PluginSessionStateEntry): Promise<PluginSessionStateEntry>;
|
|
10
|
+
clear(sessionId: string): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CompactionState } from './compaction';
|
|
2
|
+
import type { PluginSessionStateEntry } from './plugin-state';
|
|
3
|
+
import type { Usage } from './common';
|
|
4
|
+
import type { Message } from './message';
|
|
5
|
+
import type { ModelRef } from './model';
|
|
6
|
+
export interface SessionSnapshot {
|
|
7
|
+
schemaVersion: 1;
|
|
8
|
+
sessionId: string;
|
|
9
|
+
model?: ModelRef;
|
|
10
|
+
cwd?: string;
|
|
11
|
+
messages: Message[];
|
|
12
|
+
usage?: Usage;
|
|
13
|
+
compaction?: CompactionState;
|
|
14
|
+
pluginState?: Record<string, PluginSessionStateEntry>;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
updatedAt: number;
|
|
17
|
+
metadata?: Record<string, unknown>;
|
|
18
|
+
}
|
|
19
|
+
export interface SessionStatus {
|
|
20
|
+
sessionId: string;
|
|
21
|
+
model: ModelRef;
|
|
22
|
+
cwd?: string;
|
|
23
|
+
usage: Usage;
|
|
24
|
+
compaction: CompactionState;
|
|
25
|
+
messageCount: number;
|
|
26
|
+
createdAt: number;
|
|
27
|
+
updatedAt: number;
|
|
28
|
+
metadata?: Record<string, unknown>;
|
|
29
|
+
}
|
|
@@ -27,12 +27,18 @@ export interface CallToolResult {
|
|
|
27
27
|
structuredContent?: JsonObject;
|
|
28
28
|
isError?: boolean;
|
|
29
29
|
}
|
|
30
|
+
export interface ToolExecutionPluginEvent {
|
|
31
|
+
pluginId?: string;
|
|
32
|
+
event: string;
|
|
33
|
+
data?: JsonObject;
|
|
34
|
+
}
|
|
30
35
|
export interface ToolExecutionContext {
|
|
31
36
|
sessionId: string;
|
|
32
37
|
cwd?: string;
|
|
33
38
|
signal?: AbortSignal;
|
|
34
39
|
metadata?: Record<string, unknown>;
|
|
35
40
|
services?: AgentServices;
|
|
41
|
+
emitEvent?(event: ToolExecutionPluginEvent): Promise<void> | void;
|
|
36
42
|
}
|
|
37
43
|
export interface Tool {
|
|
38
44
|
readonly definition: ToolDefinition;
|