agent-sh 0.13.7 → 0.14.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/README.md +1 -1
- package/dist/agent/agent-loop.d.ts +13 -17
- package/dist/agent/agent-loop.js +118 -224
- package/dist/agent/conversation-state.d.ts +1 -1
- package/dist/agent/events.d.ts +218 -0
- package/dist/agent/events.js +1 -0
- package/dist/agent/host-types.d.ts +20 -0
- package/dist/agent/index.d.ts +5 -9
- package/dist/agent/index.js +269 -167
- package/dist/agent/llm-facade.d.ts +13 -0
- package/dist/{utils → agent}/llm-facade.js +1 -1
- package/dist/agent/nuclear-form.d.ts +1 -1
- package/dist/agent/providers/deepseek.js +2 -5
- package/dist/agent/providers/openai-compatible.js +2 -2
- package/dist/agent/providers/openai.js +2 -5
- package/dist/agent/providers/openrouter.js +5 -5
- package/dist/agent/subagent.d.ts +1 -1
- package/dist/agent/tool-protocol.d.ts +1 -1
- package/dist/agent/tool-registry.d.ts +1 -1
- package/dist/cli/auth/cli.js +11 -6
- package/dist/cli/auth/discover.d.ts +5 -0
- package/dist/cli/auth/discover.js +25 -0
- package/dist/cli/auth/keys.d.ts +5 -2
- package/dist/cli/auth/keys.js +22 -2
- package/dist/cli/index.d.ts +16 -0
- package/dist/cli/index.js +12 -2
- package/dist/core/event-bus.d.ts +28 -371
- package/dist/core/extension-loader.js +6 -6
- package/dist/core/index.d.ts +10 -29
- package/dist/core/index.js +32 -84
- package/dist/extensions/index.d.ts +2 -1
- package/dist/extensions/index.js +1 -1
- package/dist/extensions/slash-commands/events.d.ts +18 -0
- package/dist/extensions/slash-commands/events.js +1 -0
- package/dist/extensions/slash-commands/index.d.ts +15 -0
- package/dist/extensions/{slash-commands.js → slash-commands/index.js} +4 -3
- package/dist/shell/events.d.ts +85 -0
- package/dist/shell/events.js +1 -0
- package/dist/shell/index.d.ts +1 -0
- package/dist/shell/index.js +6 -0
- package/dist/shell/tui-renderer.js +0 -1
- package/examples/extensions/ash-acp-bridge/src/index.ts +2 -2
- package/examples/extensions/ashi/package.json +1 -1
- package/examples/extensions/ollama.ts +47 -42
- package/examples/extensions/opencode-bridge/README.md +4 -0
- package/examples/extensions/opencode-bridge/index.ts +3 -1
- package/examples/extensions/pi-bridge/index.ts +3 -4
- package/examples/extensions/zai-coding-plan.ts +2 -6
- package/package.json +1 -1
- package/dist/extensions/slash-commands.d.ts +0 -2
- package/dist/utils/llm-facade.d.ts +0 -11
- /package/dist/{utils → agent}/llm-client.d.ts +0 -0
- /package/dist/{utils → agent}/llm-client.js +0 -0
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import type { ProviderRegistration } from "./host-types.js";
|
|
2
|
+
import type { ToolDefinition, ToolResultDisplay } from "./types.js";
|
|
3
|
+
export interface AgentIdentity {
|
|
4
|
+
name: string;
|
|
5
|
+
version: string;
|
|
6
|
+
model?: string;
|
|
7
|
+
provider?: string;
|
|
8
|
+
contextWindow?: number;
|
|
9
|
+
}
|
|
10
|
+
declare module "../core/event-bus.js" {
|
|
11
|
+
interface BusEvents {
|
|
12
|
+
"agent:providers": {
|
|
13
|
+
providers: ProviderRegistration[];
|
|
14
|
+
};
|
|
15
|
+
"agent:providers:changed": Record<string, never>;
|
|
16
|
+
"provider:configure": {
|
|
17
|
+
id: string;
|
|
18
|
+
reasoningParams?: (level: string, model?: string) => Record<string, unknown>;
|
|
19
|
+
};
|
|
20
|
+
"agent:modes-changed": Record<string, never>;
|
|
21
|
+
"config:switch-provider": {
|
|
22
|
+
provider: string;
|
|
23
|
+
};
|
|
24
|
+
"agent:info": AgentIdentity;
|
|
25
|
+
"agent:tools": {
|
|
26
|
+
tools: ToolDefinition[];
|
|
27
|
+
};
|
|
28
|
+
"agent:instructions": {
|
|
29
|
+
instructions: Array<{
|
|
30
|
+
name: string;
|
|
31
|
+
text: string;
|
|
32
|
+
}>;
|
|
33
|
+
};
|
|
34
|
+
"agent:skills": {
|
|
35
|
+
skills: Array<{
|
|
36
|
+
name: string;
|
|
37
|
+
description: string;
|
|
38
|
+
filePath: string;
|
|
39
|
+
}>;
|
|
40
|
+
};
|
|
41
|
+
"agent:submit": {
|
|
42
|
+
query: string;
|
|
43
|
+
};
|
|
44
|
+
"agent:cancel-request": {
|
|
45
|
+
silent?: boolean;
|
|
46
|
+
};
|
|
47
|
+
"agent:append-user-message": {
|
|
48
|
+
text: string;
|
|
49
|
+
};
|
|
50
|
+
"agent:query": {
|
|
51
|
+
query: string;
|
|
52
|
+
};
|
|
53
|
+
"agent:reset-session": Record<string, never>;
|
|
54
|
+
"agent:compact-request": Record<string, never>;
|
|
55
|
+
"agent:thinking-chunk": {
|
|
56
|
+
text: string;
|
|
57
|
+
};
|
|
58
|
+
"agent:response-chunk": {
|
|
59
|
+
blocks: ContentBlock[];
|
|
60
|
+
};
|
|
61
|
+
"agent:response-done": {
|
|
62
|
+
response: string;
|
|
63
|
+
};
|
|
64
|
+
"agent:usage": {
|
|
65
|
+
prompt_tokens: number;
|
|
66
|
+
completion_tokens: number;
|
|
67
|
+
total_tokens: number;
|
|
68
|
+
};
|
|
69
|
+
"agent:processing-start": Record<string, never>;
|
|
70
|
+
"agent:processing-done": Record<string, never>;
|
|
71
|
+
"agent:cancelled": Record<string, never>;
|
|
72
|
+
"agent:error": {
|
|
73
|
+
message: string;
|
|
74
|
+
};
|
|
75
|
+
"agent:tool-call": {
|
|
76
|
+
tool: string;
|
|
77
|
+
args: Record<string, unknown>;
|
|
78
|
+
};
|
|
79
|
+
"agent:tool-output": {
|
|
80
|
+
tool: string;
|
|
81
|
+
output: string;
|
|
82
|
+
exitCode: number | null;
|
|
83
|
+
};
|
|
84
|
+
"agent:tool-batch": {
|
|
85
|
+
groups: Array<{
|
|
86
|
+
kind: string;
|
|
87
|
+
tools: Array<{
|
|
88
|
+
name: string;
|
|
89
|
+
displayDetail?: string;
|
|
90
|
+
}>;
|
|
91
|
+
}>;
|
|
92
|
+
};
|
|
93
|
+
"agent:tool-batch-complete": {
|
|
94
|
+
results: Array<{
|
|
95
|
+
name: string;
|
|
96
|
+
isError: boolean;
|
|
97
|
+
errorSummary?: string;
|
|
98
|
+
}>;
|
|
99
|
+
};
|
|
100
|
+
"agent:tool-started": {
|
|
101
|
+
title: string;
|
|
102
|
+
toolCallId?: string;
|
|
103
|
+
kind?: string;
|
|
104
|
+
icon?: string;
|
|
105
|
+
locations?: {
|
|
106
|
+
path: string;
|
|
107
|
+
line?: number | null;
|
|
108
|
+
}[];
|
|
109
|
+
rawInput?: unknown;
|
|
110
|
+
displayDetail?: string;
|
|
111
|
+
/** highlight.js identifier for rawInput.source. */
|
|
112
|
+
sourceLanguage?: string;
|
|
113
|
+
batchIndex?: number;
|
|
114
|
+
batchTotal?: number;
|
|
115
|
+
};
|
|
116
|
+
"agent:tool-completed": {
|
|
117
|
+
toolCallId?: string;
|
|
118
|
+
exitCode: number | null;
|
|
119
|
+
rawOutput?: unknown;
|
|
120
|
+
kind?: string;
|
|
121
|
+
resultDisplay?: ToolResultDisplay;
|
|
122
|
+
};
|
|
123
|
+
"agent:tool-output-chunk": {
|
|
124
|
+
chunk: string;
|
|
125
|
+
};
|
|
126
|
+
"tool:interactive-start": Record<string, never>;
|
|
127
|
+
"tool:interactive-end": Record<string, never>;
|
|
128
|
+
"agent:subagent-started": {
|
|
129
|
+
taskId: string;
|
|
130
|
+
task: string;
|
|
131
|
+
};
|
|
132
|
+
"agent:subagent-completed": {
|
|
133
|
+
taskId: string;
|
|
134
|
+
task: string;
|
|
135
|
+
result: string;
|
|
136
|
+
isError: boolean;
|
|
137
|
+
};
|
|
138
|
+
"agent:terminal-intercept": {
|
|
139
|
+
command: string;
|
|
140
|
+
cwd: string;
|
|
141
|
+
intercepted: boolean;
|
|
142
|
+
output: string;
|
|
143
|
+
};
|
|
144
|
+
"conversation:message-appended": {
|
|
145
|
+
role: "user" | "assistant" | "tool" | "system";
|
|
146
|
+
content: string;
|
|
147
|
+
toolName?: string;
|
|
148
|
+
toolArgs?: Record<string, unknown>;
|
|
149
|
+
isError?: boolean;
|
|
150
|
+
};
|
|
151
|
+
"conversation:after-compact": {
|
|
152
|
+
beforeTokens: number;
|
|
153
|
+
afterTokens: number;
|
|
154
|
+
evictedCount: number;
|
|
155
|
+
};
|
|
156
|
+
"context:get-stats": {
|
|
157
|
+
activeTokens: number;
|
|
158
|
+
totalTokens: number;
|
|
159
|
+
budgetTokens: number;
|
|
160
|
+
};
|
|
161
|
+
"context:snapshot": {
|
|
162
|
+
messages: unknown[];
|
|
163
|
+
contextWindow: number;
|
|
164
|
+
activeTokens: number;
|
|
165
|
+
};
|
|
166
|
+
"context:compact": {
|
|
167
|
+
strategy?: {
|
|
168
|
+
kind: "two-tier-pin";
|
|
169
|
+
target: number;
|
|
170
|
+
keepRecent?: number;
|
|
171
|
+
force?: boolean;
|
|
172
|
+
} | {
|
|
173
|
+
kind: "rewind";
|
|
174
|
+
toIndex: number;
|
|
175
|
+
} | {
|
|
176
|
+
kind: "replace";
|
|
177
|
+
messages: unknown[];
|
|
178
|
+
};
|
|
179
|
+
stats?: {
|
|
180
|
+
before: number;
|
|
181
|
+
after: number;
|
|
182
|
+
evictedCount: number;
|
|
183
|
+
};
|
|
184
|
+
};
|
|
185
|
+
"config:switch-model": {
|
|
186
|
+
model: string;
|
|
187
|
+
};
|
|
188
|
+
"config:get-models": {
|
|
189
|
+
models: {
|
|
190
|
+
model: string;
|
|
191
|
+
provider: string;
|
|
192
|
+
}[];
|
|
193
|
+
active: {
|
|
194
|
+
model: string;
|
|
195
|
+
provider: string;
|
|
196
|
+
} | null;
|
|
197
|
+
};
|
|
198
|
+
"config:set-thinking": {
|
|
199
|
+
level: string;
|
|
200
|
+
};
|
|
201
|
+
"config:get-thinking": {
|
|
202
|
+
level: string;
|
|
203
|
+
levels: string[];
|
|
204
|
+
supported: boolean;
|
|
205
|
+
};
|
|
206
|
+
"llm:request": {
|
|
207
|
+
messages: unknown[];
|
|
208
|
+
tools?: unknown;
|
|
209
|
+
model?: string;
|
|
210
|
+
max_tokens?: number;
|
|
211
|
+
reasoning_effort?: string;
|
|
212
|
+
};
|
|
213
|
+
"llm:chunk": {
|
|
214
|
+
chunk: unknown;
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -39,6 +39,23 @@ export interface LlmInterface {
|
|
|
39
39
|
reasoningEffort?: string;
|
|
40
40
|
}): LlmSession;
|
|
41
41
|
}
|
|
42
|
+
export interface ProviderRegistration {
|
|
43
|
+
id: string;
|
|
44
|
+
apiKey?: string;
|
|
45
|
+
baseURL?: string;
|
|
46
|
+
/** Falls back to models[0] when absent. */
|
|
47
|
+
defaultModel?: string;
|
|
48
|
+
models?: (string | {
|
|
49
|
+
id: string;
|
|
50
|
+
reasoning?: boolean;
|
|
51
|
+
contextWindow?: number;
|
|
52
|
+
maxTokens?: number;
|
|
53
|
+
echoReasoning?: boolean;
|
|
54
|
+
})[];
|
|
55
|
+
supportsReasoningEffort?: boolean;
|
|
56
|
+
/** Local daemons etc. — `auth list/login` shows "no auth required". */
|
|
57
|
+
noAuth?: boolean;
|
|
58
|
+
}
|
|
42
59
|
/** A model entry in the cycling list, optionally tied to a provider. */
|
|
43
60
|
export interface AgentMode {
|
|
44
61
|
model: string;
|
|
@@ -70,6 +87,9 @@ export interface AgentMode {
|
|
|
70
87
|
export interface AgentSurface {
|
|
71
88
|
llm: LlmInterface;
|
|
72
89
|
providers: {
|
|
90
|
+
/** Re-registering the same id replaces the prior contribution. */
|
|
91
|
+
register: (reg: ProviderRegistration) => () => void;
|
|
92
|
+
unregister: (id: string) => void;
|
|
73
93
|
configure: (id: string, opts: {
|
|
74
94
|
reasoningParams?: (level: string, model?: string) => Record<string, unknown>;
|
|
75
95
|
}) => void;
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
* are defined before user extensions activate. Mode resolution is
|
|
5
|
-
* deferred to `core:extensions-loaded`, giving runtime-registered
|
|
6
|
-
* providers (e.g. openrouter) a chance to register before we look up
|
|
7
|
-
* settings.defaultProvider. Without this deferral, a persisted
|
|
8
|
-
* `defaultProvider: "openrouter"` loses to a cold-start race and the
|
|
9
|
-
* backend bails silently.
|
|
2
|
+
* Mode resolution is deferred to `core:extensions-loaded` so a persisted
|
|
3
|
+
* `defaultProvider: "openrouter"` doesn't lose to a cold-start race.
|
|
10
4
|
*/
|
|
5
|
+
import "./events.js";
|
|
11
6
|
import type { ExtensionContext } from "../shell/host-types.js";
|
|
12
7
|
export default function agentBackend(ctx: ExtensionContext): void;
|
|
13
8
|
export type { AgentBackend } from "./types.js";
|
|
@@ -15,5 +10,6 @@ export type { ToolDefinition, ToolResult, ToolDisplayInfo } from "./types.js";
|
|
|
15
10
|
export { AgentLoop } from "./agent-loop.js";
|
|
16
11
|
export { ToolRegistry } from "./tool-registry.js";
|
|
17
12
|
export { runSubagent, type SubagentOptions } from "./subagent.js";
|
|
18
|
-
/**
|
|
13
|
+
/** Built-in providers register unconditionally so `auth list` can
|
|
14
|
+
* enumerate them; buildModes() skips entries without an apiKey. */
|
|
19
15
|
export declare function activateAgent(ctx: ExtensionContext): void;
|