agent-sh 0.13.0 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent/index.js +2 -1
- package/dist/utils/llm-client.d.ts +16 -26
- package/dist/utils/llm-client.js +15 -26
- package/examples/extensions/ashi/package.json +1 -1
- package/examples/extensions/ashi/src/cli.ts +51 -1
- package/examples/extensions/ashi/src/components.ts +5 -10
- package/examples/extensions/ashi/src/frontend.ts +1 -1
- package/package.json +13 -1
package/dist/agent/index.js
CHANGED
|
@@ -117,11 +117,12 @@ export default function agentBackend(ctx) {
|
|
|
117
117
|
const llmClient = new LlmClient({ apiKey: "not-configured", model: "not-configured" });
|
|
118
118
|
ctx.define("llm:get-client", () => llmClient);
|
|
119
119
|
ctx.define("llm:invoke", (messages, opts) => {
|
|
120
|
+
const effort = opts?.reasoningEffort;
|
|
120
121
|
return llmClient.complete({
|
|
121
122
|
messages: messages,
|
|
122
123
|
max_tokens: opts?.maxTokens,
|
|
123
124
|
model: opts?.model,
|
|
124
|
-
reasoning_effort:
|
|
125
|
+
...(effort && effort !== "off" ? { reasoning_effort: effort } : {}),
|
|
125
126
|
});
|
|
126
127
|
});
|
|
127
128
|
let modes = [];
|
|
@@ -24,30 +24,20 @@ export declare class LlmClient {
|
|
|
24
24
|
constructor(config: LlmClientConfig);
|
|
25
25
|
/** Swap the underlying client config at runtime (e.g. provider switch). */
|
|
26
26
|
reconfigure(newConfig: LlmClientConfig): void;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
* Returns an async iterable of chunks.
|
|
30
|
-
*/
|
|
31
|
-
stream(opts: {
|
|
32
|
-
messages: ChatCompletionMessageParam[];
|
|
33
|
-
tools?: ChatCompletionTool[];
|
|
34
|
-
model?: string;
|
|
35
|
-
max_tokens?: number;
|
|
36
|
-
/** Reasoning effort: "off" | "low" | "medium" | "high". Provider-dependent;
|
|
37
|
-
* "off" matches agent-loop's thinkingLevel and omits the field. */
|
|
38
|
-
reasoning_effort?: string;
|
|
39
|
-
signal?: AbortSignal;
|
|
40
|
-
}): import("openai").APIPromise<import("openai/core/streaming.mjs").Stream<OpenAI.Chat.Completions.ChatCompletionChunk>>;
|
|
41
|
-
/**
|
|
42
|
-
* Single-shot completion (no streaming) — for fast-path features.
|
|
43
|
-
* Returns the text content of the first choice.
|
|
44
|
-
*/
|
|
45
|
-
complete(opts: {
|
|
46
|
-
messages: ChatCompletionMessageParam[];
|
|
47
|
-
model?: string;
|
|
48
|
-
max_tokens?: number;
|
|
49
|
-
/** Reasoning effort: "off" | "low" | "medium" | "high". Provider-dependent;
|
|
50
|
-
* "off" matches agent-loop's thinkingLevel and omits the field. */
|
|
51
|
-
reasoning_effort?: string;
|
|
52
|
-
}): Promise<string>;
|
|
27
|
+
stream(opts: StreamOpts): import("openai").APIPromise<import("openai/core/streaming.mjs").Stream<OpenAI.Chat.Completions.ChatCompletionChunk>>;
|
|
28
|
+
complete(opts: CompleteOpts): Promise<string>;
|
|
53
29
|
}
|
|
30
|
+
/** Known fields are typed; extras are forwarded verbatim to the SDK so
|
|
31
|
+
* provider hooks can ship non-standard params (thinking, reasoning, …). */
|
|
32
|
+
export type StreamOpts = {
|
|
33
|
+
messages: ChatCompletionMessageParam[];
|
|
34
|
+
tools?: ChatCompletionTool[];
|
|
35
|
+
model?: string;
|
|
36
|
+
max_tokens?: number;
|
|
37
|
+
signal?: AbortSignal;
|
|
38
|
+
} & Record<string, unknown>;
|
|
39
|
+
export type CompleteOpts = {
|
|
40
|
+
messages: ChatCompletionMessageParam[];
|
|
41
|
+
model?: string;
|
|
42
|
+
max_tokens?: number;
|
|
43
|
+
} & Record<string, unknown>;
|
package/dist/utils/llm-client.js
CHANGED
|
@@ -35,39 +35,28 @@ export class LlmClient {
|
|
|
35
35
|
});
|
|
36
36
|
this.model = newConfig.model;
|
|
37
37
|
}
|
|
38
|
-
/**
|
|
39
|
-
* Create a streaming chat completion.
|
|
40
|
-
* Returns an async iterable of chunks.
|
|
41
|
-
*/
|
|
42
38
|
stream(opts) {
|
|
43
|
-
const
|
|
39
|
+
const { signal, messages, tools, model, max_tokens, ...rest } = opts;
|
|
44
40
|
const body = {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
...rest,
|
|
42
|
+
model: model ?? this.model,
|
|
43
|
+
messages,
|
|
44
|
+
tools: tools?.length ? tools : undefined,
|
|
45
|
+
max_tokens: max_tokens ?? 65536,
|
|
49
46
|
stream: true,
|
|
50
47
|
stream_options: { include_usage: true },
|
|
51
|
-
...(sendEffort
|
|
52
|
-
? { reasoning_effort: opts.reasoning_effort }
|
|
53
|
-
: {}),
|
|
54
48
|
};
|
|
55
|
-
return this.client.chat.completions.create(body, { signal
|
|
49
|
+
return this.client.chat.completions.create(body, { signal });
|
|
56
50
|
}
|
|
57
|
-
/**
|
|
58
|
-
* Single-shot completion (no streaming) — for fast-path features.
|
|
59
|
-
* Returns the text content of the first choice.
|
|
60
|
-
*/
|
|
61
51
|
async complete(opts) {
|
|
62
|
-
const
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
});
|
|
52
|
+
const { messages, model, max_tokens, ...rest } = opts;
|
|
53
|
+
const body = {
|
|
54
|
+
...rest,
|
|
55
|
+
model: model ?? this.model,
|
|
56
|
+
messages,
|
|
57
|
+
max_tokens: max_tokens ?? 1024,
|
|
58
|
+
};
|
|
59
|
+
const response = await this.client.chat.completions.create(body);
|
|
71
60
|
return response.choices[0]?.message?.content ?? "";
|
|
72
61
|
}
|
|
73
62
|
}
|
|
@@ -54,8 +54,58 @@ function parseArgs(argv: string[]): AppConfig & { extensions?: string[] } {
|
|
|
54
54
|
return { shell: "/bin/sh", model, apiKey, baseURL, provider, backend, extensions };
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
+
const MANAGEMENT_HELP = `ashi — ash backend, pi-tui frontend
|
|
58
|
+
|
|
59
|
+
Management:
|
|
60
|
+
ashi install <name> [--force] Install an extension
|
|
61
|
+
ashi uninstall <name> Remove an installed extension
|
|
62
|
+
ashi list List installed extensions
|
|
63
|
+
ashi auth login [provider] Store an API key
|
|
64
|
+
ashi auth logout <provider> Remove a stored key
|
|
65
|
+
ashi auth list Show configured providers
|
|
66
|
+
ashi init [--force] Scaffold ~/.agent-sh/ (settings, AGENTS.md)
|
|
67
|
+
|
|
68
|
+
Launch (default):
|
|
69
|
+
ashi [--provider <name>] [--model <id>] [--api-key <key>] [--base-url <url>]
|
|
70
|
+
[--backend <name>] [-e <ext>[,<ext>...]]
|
|
71
|
+
|
|
72
|
+
Reads ~/.agent-sh/settings.json for providers and defaults.`;
|
|
73
|
+
|
|
57
74
|
async function main(): Promise<void> {
|
|
58
|
-
const
|
|
75
|
+
const rawArgs = process.argv.slice(2);
|
|
76
|
+
const sub = rawArgs[0];
|
|
77
|
+
const rest = rawArgs.slice(1);
|
|
78
|
+
|
|
79
|
+
if (sub === "install" || sub === "uninstall" || sub === "list") {
|
|
80
|
+
const { runInstall, runUninstall, runList } = await import("agent-sh/cli/install");
|
|
81
|
+
if (sub === "install") await runInstall(rest[0] ?? "", { force: rest.includes("--force") });
|
|
82
|
+
else if (sub === "uninstall") await runUninstall(rest[0] ?? "");
|
|
83
|
+
else runList();
|
|
84
|
+
process.exit(0);
|
|
85
|
+
}
|
|
86
|
+
if (sub === "auth") {
|
|
87
|
+
const { runAuth } = await import("agent-sh/cli/auth");
|
|
88
|
+
await runAuth(rest);
|
|
89
|
+
process.exit(0);
|
|
90
|
+
}
|
|
91
|
+
if (sub === "init") {
|
|
92
|
+
const { runInit } = await import("agent-sh/cli/init");
|
|
93
|
+
runInit({ force: rest.includes("--force") });
|
|
94
|
+
process.exit(0);
|
|
95
|
+
}
|
|
96
|
+
if (sub === "--help" || sub === "-h") {
|
|
97
|
+
process.stdout.write(MANAGEMENT_HELP + "\n");
|
|
98
|
+
process.exit(0);
|
|
99
|
+
}
|
|
100
|
+
if (sub && !sub.startsWith("-")) {
|
|
101
|
+
process.stderr.write(`ashi: unknown subcommand "${sub}".\n`);
|
|
102
|
+
process.stderr.write("Available: install, uninstall, list, auth, init\n");
|
|
103
|
+
process.stderr.write("Run `ashi --help` for details.\n");
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// ── Pi-tui frontend
|
|
108
|
+
const config = parseArgs(rawArgs);
|
|
59
109
|
|
|
60
110
|
if (!process.stdin.isTTY) {
|
|
61
111
|
process.stderr.write("ashi requires a TTY for interactive rendering.\n");
|
|
@@ -61,7 +61,6 @@ export class AssistantMessage extends Container {
|
|
|
61
61
|
|
|
62
62
|
export class ThinkingBlock extends Container {
|
|
63
63
|
private md: Markdown;
|
|
64
|
-
private placeholder: Text;
|
|
65
64
|
private buffer = "";
|
|
66
65
|
private hidden = false;
|
|
67
66
|
private mdTheme: MarkdownTheme;
|
|
@@ -71,7 +70,6 @@ export class ThinkingBlock extends Container {
|
|
|
71
70
|
this.md = new Markdown("", 1, 0, mdTheme, {
|
|
72
71
|
color: (t) => theme.italic(theme.fg("thinkingText", t)),
|
|
73
72
|
});
|
|
74
|
-
this.placeholder = new Text(theme.italic(theme.fg("thinkingText", "Thinking…")), 1, 0);
|
|
75
73
|
this.addChild(new Spacer(1));
|
|
76
74
|
this.addChild(this.md);
|
|
77
75
|
}
|
|
@@ -87,15 +85,12 @@ export class ThinkingBlock extends Container {
|
|
|
87
85
|
if (hidden === this.hidden) return;
|
|
88
86
|
this.hidden = hidden;
|
|
89
87
|
this.clear();
|
|
88
|
+
if (hidden) return;
|
|
90
89
|
this.addChild(new Spacer(1));
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
color: (t) => theme.italic(theme.fg("thinkingText", t)),
|
|
96
|
-
});
|
|
97
|
-
this.addChild(this.md);
|
|
98
|
-
}
|
|
90
|
+
this.md = new Markdown(this.buffer, 1, 0, this.mdTheme, {
|
|
91
|
+
color: (t) => theme.italic(theme.fg("thinkingText", t)),
|
|
92
|
+
});
|
|
93
|
+
this.addChild(this.md);
|
|
99
94
|
}
|
|
100
95
|
}
|
|
101
96
|
|
|
@@ -186,7 +186,7 @@ export function mountAshi(
|
|
|
186
186
|
let lastToolResult: ToolResultView | null = null;
|
|
187
187
|
let loader: Loader | null = null;
|
|
188
188
|
let processing = false;
|
|
189
|
-
let hideThinking =
|
|
189
|
+
let hideThinking = true;
|
|
190
190
|
|
|
191
191
|
const renderState = (): { state: Record<string, unknown>; invalidate: () => void } => ({
|
|
192
192
|
state: {},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-sh",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "A shell-first terminal where AI is one keystroke away",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/core/index.js",
|
|
@@ -89,6 +89,18 @@
|
|
|
89
89
|
"./executor": {
|
|
90
90
|
"types": "./dist/utils/executor.d.ts",
|
|
91
91
|
"default": "./dist/utils/executor.js"
|
|
92
|
+
},
|
|
93
|
+
"./cli/install": {
|
|
94
|
+
"types": "./dist/cli/install.d.ts",
|
|
95
|
+
"default": "./dist/cli/install.js"
|
|
96
|
+
},
|
|
97
|
+
"./cli/init": {
|
|
98
|
+
"types": "./dist/cli/init.d.ts",
|
|
99
|
+
"default": "./dist/cli/init.js"
|
|
100
|
+
},
|
|
101
|
+
"./cli/auth": {
|
|
102
|
+
"types": "./dist/cli/auth/cli.d.ts",
|
|
103
|
+
"default": "./dist/cli/auth/cli.js"
|
|
92
104
|
}
|
|
93
105
|
},
|
|
94
106
|
"files": [
|