ikarmic-forge 0.0.0-stage → 4.4.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/LICENSE +21 -0
- package/README.md +58 -2
- package/dist/acp/server.d.ts +53 -0
- package/dist/acp/server.d.ts.map +1 -0
- package/dist/acp/server.js +235 -0
- package/dist/acp/server.js.map +1 -0
- package/dist/app.d.ts +22 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +159 -0
- package/dist/app.js.map +1 -0
- package/dist/bin/forge.d.ts +3 -0
- package/dist/bin/forge.d.ts.map +1 -0
- package/dist/bin/forge.js +747 -0
- package/dist/bin/forge.js.map +1 -0
- package/dist/chat-files.d.ts +37 -0
- package/dist/chat-files.d.ts.map +1 -0
- package/dist/chat-files.js +152 -0
- package/dist/chat-files.js.map +1 -0
- package/dist/commands/acp.d.ts +4 -0
- package/dist/commands/acp.d.ts.map +1 -0
- package/dist/commands/acp.js +36 -0
- package/dist/commands/acp.js.map +1 -0
- package/dist/commands/ai-comments.d.ts +9 -0
- package/dist/commands/ai-comments.d.ts.map +1 -0
- package/dist/commands/ai-comments.js +43 -0
- package/dist/commands/ai-comments.js.map +1 -0
- package/dist/commands/architect.d.ts +9 -0
- package/dist/commands/architect.d.ts.map +1 -0
- package/dist/commands/architect.js +27 -0
- package/dist/commands/architect.js.map +1 -0
- package/dist/commands/checkpoint.d.ts +10 -0
- package/dist/commands/checkpoint.d.ts.map +1 -0
- package/dist/commands/checkpoint.js +168 -0
- package/dist/commands/checkpoint.js.map +1 -0
- package/dist/commands/config.d.ts +15 -0
- package/dist/commands/config.d.ts.map +1 -0
- package/dist/commands/config.js +180 -0
- package/dist/commands/config.js.map +1 -0
- package/dist/commands/diff.d.ts +29 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +90 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/hook.d.ts +10 -0
- package/dist/commands/hook.d.ts.map +1 -0
- package/dist/commands/hook.js +121 -0
- package/dist/commands/hook.js.map +1 -0
- package/dist/commands/mcp.d.ts +10 -0
- package/dist/commands/mcp.d.ts.map +1 -0
- package/dist/commands/mcp.js +110 -0
- package/dist/commands/mcp.js.map +1 -0
- package/dist/commands/orchestrator.d.ts +22 -0
- package/dist/commands/orchestrator.d.ts.map +1 -0
- package/dist/commands/orchestrator.js +113 -0
- package/dist/commands/orchestrator.js.map +1 -0
- package/dist/commands/plugin.d.ts +3 -0
- package/dist/commands/plugin.d.ts.map +1 -0
- package/dist/commands/plugin.js +62 -0
- package/dist/commands/plugin.js.map +1 -0
- package/dist/commands/policy.d.ts +2 -0
- package/dist/commands/policy.d.ts.map +1 -0
- package/dist/commands/policy.js +21 -0
- package/dist/commands/policy.js.map +1 -0
- package/dist/commands/skill.d.ts +13 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +194 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/spec.d.ts +13 -0
- package/dist/commands/spec.d.ts.map +1 -0
- package/dist/commands/spec.js +76 -0
- package/dist/commands/spec.js.map +1 -0
- package/dist/commands/watch.d.ts +15 -0
- package/dist/commands/watch.d.ts.map +1 -0
- package/dist/commands/watch.js +83 -0
- package/dist/commands/watch.js.map +1 -0
- package/dist/commands/worktree.d.ts +22 -0
- package/dist/commands/worktree.d.ts.map +1 -0
- package/dist/commands/worktree.js +187 -0
- package/dist/commands/worktree.js.map +1 -0
- package/dist/components/Approval.d.ts +9 -0
- package/dist/components/Approval.d.ts.map +1 -0
- package/dist/components/Approval.js +37 -0
- package/dist/components/Approval.js.map +1 -0
- package/dist/components/Footer.d.ts +22 -0
- package/dist/components/Footer.d.ts.map +1 -0
- package/dist/components/Footer.js +59 -0
- package/dist/components/Footer.js.map +1 -0
- package/dist/components/Header.d.ts +11 -0
- package/dist/components/Header.d.ts.map +1 -0
- package/dist/components/Header.js +23 -0
- package/dist/components/Header.js.map +1 -0
- package/dist/components/Spinner.d.ts +3 -0
- package/dist/components/Spinner.d.ts.map +1 -0
- package/dist/components/Spinner.js +8 -0
- package/dist/components/Spinner.js.map +1 -0
- package/dist/components/Stream.d.ts +10 -0
- package/dist/components/Stream.d.ts.map +1 -0
- package/dist/components/Stream.js +13 -0
- package/dist/components/Stream.js.map +1 -0
- package/dist/components/ToolEvent.d.ts +13 -0
- package/dist/components/ToolEvent.d.ts.map +1 -0
- package/dist/components/ToolEvent.js +54 -0
- package/dist/components/ToolEvent.js.map +1 -0
- package/dist/credential-store.d.ts +8 -0
- package/dist/credential-store.d.ts.map +1 -0
- package/dist/credential-store.js +37 -0
- package/dist/credential-store.js.map +1 -0
- package/dist/git-workflow.d.ts +16 -0
- package/dist/git-workflow.d.ts.map +1 -0
- package/dist/git-workflow.js +38 -0
- package/dist/git-workflow.js.map +1 -0
- package/dist/mcp-loader.d.ts +25 -0
- package/dist/mcp-loader.d.ts.map +1 -0
- package/dist/mcp-loader.js +99 -0
- package/dist/mcp-loader.js.map +1 -0
- package/dist/notify.d.ts +12 -0
- package/dist/notify.d.ts.map +1 -0
- package/dist/notify.js +47 -0
- package/dist/notify.js.map +1 -0
- package/dist/options.d.ts +407 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +792 -0
- package/dist/options.js.map +1 -0
- package/dist/repl-commands.d.ts +53 -0
- package/dist/repl-commands.d.ts.map +1 -0
- package/dist/repl-commands.js +141 -0
- package/dist/repl-commands.js.map +1 -0
- package/dist/repl.d.ts +52 -0
- package/dist/repl.d.ts.map +1 -0
- package/dist/repl.js +1174 -0
- package/dist/repl.js.map +1 -0
- package/dist/runner.d.ts +64 -0
- package/dist/runner.d.ts.map +1 -0
- package/dist/runner.js +61 -0
- package/dist/runner.js.map +1 -0
- package/dist/session-checkpoints.d.ts +6 -0
- package/dist/session-checkpoints.d.ts.map +1 -0
- package/dist/session-checkpoints.js +25 -0
- package/dist/session-checkpoints.js.map +1 -0
- package/dist/specialists-loader.d.ts +22 -0
- package/dist/specialists-loader.d.ts.map +1 -0
- package/dist/specialists-loader.js +38 -0
- package/dist/specialists-loader.js.map +1 -0
- package/dist/tool-display.d.ts +19 -0
- package/dist/tool-display.d.ts.map +1 -0
- package/dist/tool-display.js +57 -0
- package/dist/tool-display.js.map +1 -0
- package/package.json +70 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 IKarmic
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,59 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `forge` (IKarmic AI Forge CLI)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The terminal companion to the Forge agent engine. One-shot task runner with autonomous mode, streaming output, and a y/n approval prompt for destructive tools.
|
|
4
|
+
|
|
5
|
+
See the top-level [README.md](../../README.md) for full usage docs. Quick start:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
export ANTHROPIC_API_KEY=...
|
|
9
|
+
forge "summarize src/index.ts"
|
|
10
|
+
forge --auto "run the tests and fix any failures"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
JSON streaming mode for piping into other tools:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
forge --auto --json "rename getUserById to fetchUser" | jq 'select(.type=="tool_call")'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Skill and hook subcommands
|
|
20
|
+
|
|
21
|
+
The CLI auto-discovers skills from `./skills/`, `./.forge/skills/`, and
|
|
22
|
+
`~/.forge/skills/` on every run. The same applies to lifecycle hooks
|
|
23
|
+
from `~/.forge/settings.json` and `./.forge/settings.json`. Inspect them
|
|
24
|
+
with:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
forge skill list # every discovered SKILL.md
|
|
28
|
+
forge skill show commit-message # body + source path
|
|
29
|
+
forge skill install <github-url> # scaffold a SKILL.md stub
|
|
30
|
+
forge skill browse # print the marketplace catalog
|
|
31
|
+
|
|
32
|
+
forge hook list # every configured hook
|
|
33
|
+
forge hook test PreToolUse run_command # dispatch a synthetic event
|
|
34
|
+
forge hook test Stop # a non-tool event
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
See the [Skills system](../../README.md#skills-system) and
|
|
38
|
+
[Lifecycle hooks](../../README.md#lifecycle-hooks) sections of the root
|
|
39
|
+
README for the full format reference.
|
|
40
|
+
|
|
41
|
+
## Sandbox flags
|
|
42
|
+
|
|
43
|
+
The CLI exposes the agent's sandbox as command-line flags for one-off use. Useful when you want a tighter constraint set than your default config, e.g. when running against an unfamiliar codebase or letting an LLM loose on a single directory:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
# Only let the agent read/list/search under src/, refuse everything under secrets/
|
|
47
|
+
forge --allow-paths "src/**" --deny-paths "**/secrets/**,*.env" "summarize this project"
|
|
48
|
+
|
|
49
|
+
# Read-only mode: expose only read-only tools
|
|
50
|
+
forge --allow-tools "read_file,list_files,search_files" "audit this codebase"
|
|
51
|
+
|
|
52
|
+
# Restrict shell to npm/pnpm; deny network calls
|
|
53
|
+
forge --allow-commands "^(npm|pnpm|node)\b" --deny-tools "fetch_url" "install deps and run tests"
|
|
54
|
+
|
|
55
|
+
# Only allow HTTPS docs endpoints
|
|
56
|
+
forge --allow-urls "^https://(docs|api)\.example\.com" "fetch the latest changelog"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
All flags accept comma-separated lists. Paths use POSIX-style globs (`*`, `**`, `?`); commands and URLs are matched as JavaScript regexes. Run `forge --help` for the full list.
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Client Protocol (ACP) server: lets an ACP client (JetBrains AI Chat,
|
|
3
|
+
* Zed, Neovim plugins...) drive Forge over JSON-RPC 2.0 on newline-delimited
|
|
4
|
+
* stdio. Transport-agnostic: the caller feeds lines in via {@link AcpServer.handleLine}
|
|
5
|
+
* and receives lines through the `write` callback.
|
|
6
|
+
*
|
|
7
|
+
* Implemented (protocol version 1): initialize, session/new, session/prompt,
|
|
8
|
+
* session/cancel; agent -> client: session/update (message, thought, tool_call,
|
|
9
|
+
* tool_call_update) and session/request_permission.
|
|
10
|
+
*/
|
|
11
|
+
import type { AgentConfig, AgentEvent, AgentRunResult } from '@ikarmic/forge-core';
|
|
12
|
+
export declare const ACP_PROTOCOL_VERSION = 1;
|
|
13
|
+
/** Everything the server needs from the outside world. */
|
|
14
|
+
export interface AcpDeps {
|
|
15
|
+
/** Build the agent config for a session (model, tools, sandbox...). approve/abort are added by the server. */
|
|
16
|
+
createAgentConfig(cwd: string, sessionId: string): Promise<AgentConfig> | AgentConfig;
|
|
17
|
+
/** Run one agent turn. Defaults to core's Agent; injectable for tests. */
|
|
18
|
+
runAgent(config: AgentConfig, options: {
|
|
19
|
+
task: string;
|
|
20
|
+
history?: AgentRunResult['messages'];
|
|
21
|
+
abortSignal: AbortSignal;
|
|
22
|
+
onEvent: (e: AgentEvent) => void;
|
|
23
|
+
}): Promise<AgentRunResult>;
|
|
24
|
+
agentInfo?: {
|
|
25
|
+
name: string;
|
|
26
|
+
version: string;
|
|
27
|
+
};
|
|
28
|
+
newSessionId?: () => string;
|
|
29
|
+
}
|
|
30
|
+
export declare class AcpServer {
|
|
31
|
+
private readonly write;
|
|
32
|
+
private readonly deps;
|
|
33
|
+
private readonly sessions;
|
|
34
|
+
private readonly pending;
|
|
35
|
+
private nextRequestId;
|
|
36
|
+
private counter;
|
|
37
|
+
constructor(write: (line: string) => void, deps: AcpDeps);
|
|
38
|
+
/** Feed one line of input. Never throws. */
|
|
39
|
+
handleLine(line: string): Promise<void>;
|
|
40
|
+
private dispatch;
|
|
41
|
+
private prompt;
|
|
42
|
+
private askPermission;
|
|
43
|
+
private request;
|
|
44
|
+
private notify;
|
|
45
|
+
private send;
|
|
46
|
+
/** Abort every running prompt and fail outstanding client requests (call when the transport closes). */
|
|
47
|
+
close(): void;
|
|
48
|
+
}
|
|
49
|
+
/** ACP content blocks -> the plain-text task Forge runs. */
|
|
50
|
+
export declare function promptToText(prompt: unknown): string;
|
|
51
|
+
export declare function stopReasonFor(reason: string): string;
|
|
52
|
+
export declare function toolKind(name: string): string;
|
|
53
|
+
//# sourceMappingURL=server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/acp/server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAmB,MAAM,qBAAqB,CAAC;AAEpG,eAAO,MAAM,oBAAoB,IAAI,CAAC;AActC,0DAA0D;AAC1D,MAAM,WAAW,OAAO;IACtB,8GAA8G;IAC9G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AM,GAAG,MAAM,CAWpD;AAED,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAO7C"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
export const ACP_PROTOCOL_VERSION = 1;
|
|
2
|
+
const MAX_TOOL_TEXT = 4000;
|
|
3
|
+
export class AcpServer {
|
|
4
|
+
write;
|
|
5
|
+
deps;
|
|
6
|
+
sessions = new Map();
|
|
7
|
+
pending = new Map();
|
|
8
|
+
nextRequestId = 1;
|
|
9
|
+
counter = 0;
|
|
10
|
+
constructor(write, deps) {
|
|
11
|
+
this.write = write;
|
|
12
|
+
this.deps = deps;
|
|
13
|
+
}
|
|
14
|
+
/** Feed one line of input. Never throws. */
|
|
15
|
+
async handleLine(line) {
|
|
16
|
+
if (!line.trim())
|
|
17
|
+
return;
|
|
18
|
+
let msg;
|
|
19
|
+
try {
|
|
20
|
+
msg = JSON.parse(line);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
this.send({ jsonrpc: '2.0', id: null, error: { code: -32700, message: 'Parse error' } });
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// A reply to something we asked the client (e.g. session/request_permission).
|
|
27
|
+
if (msg.id !== undefined && msg.method === undefined) {
|
|
28
|
+
const p = this.pending.get(msg.id);
|
|
29
|
+
if (!p)
|
|
30
|
+
return;
|
|
31
|
+
this.pending.delete(msg.id);
|
|
32
|
+
if (msg.error)
|
|
33
|
+
p.reject(new Error(msg.error.message));
|
|
34
|
+
else
|
|
35
|
+
p.resolve(msg.result);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (!msg.method)
|
|
39
|
+
return;
|
|
40
|
+
const isRequest = msg.id !== undefined;
|
|
41
|
+
try {
|
|
42
|
+
const result = await this.dispatch(msg.method, msg.params ?? {});
|
|
43
|
+
if (isRequest)
|
|
44
|
+
this.send({ jsonrpc: '2.0', id: msg.id, result: result });
|
|
45
|
+
}
|
|
46
|
+
catch (err) {
|
|
47
|
+
if (!isRequest)
|
|
48
|
+
return; // notifications get no reply
|
|
49
|
+
const e = err;
|
|
50
|
+
this.send({ jsonrpc: '2.0', id: msg.id, error: { code: e.code ?? -32603, message: e.message } });
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
async dispatch(method, params) {
|
|
54
|
+
switch (method) {
|
|
55
|
+
case 'initialize':
|
|
56
|
+
return {
|
|
57
|
+
protocolVersion: ACP_PROTOCOL_VERSION,
|
|
58
|
+
agentCapabilities: { loadSession: false, promptCapabilities: { image: false, audio: false, embeddedContext: true } },
|
|
59
|
+
agentInfo: this.deps.agentInfo ?? { name: 'forge', version: '0.0.0' },
|
|
60
|
+
authMethods: [],
|
|
61
|
+
};
|
|
62
|
+
case 'session/new': {
|
|
63
|
+
const cwd = params.cwd;
|
|
64
|
+
if (typeof cwd !== 'string' || !cwd)
|
|
65
|
+
throw rpcError(-32602, 'session/new requires a cwd');
|
|
66
|
+
const id = this.deps.newSessionId?.() ?? `forge-acp-${Date.now().toString(36)}-${++this.counter}`;
|
|
67
|
+
this.sessions.set(id, { id, cwd, history: undefined, controller: undefined });
|
|
68
|
+
return { sessionId: id };
|
|
69
|
+
}
|
|
70
|
+
case 'session/prompt':
|
|
71
|
+
return this.prompt(params);
|
|
72
|
+
case 'session/cancel': {
|
|
73
|
+
this.sessions.get(String(params.sessionId))?.controller?.abort();
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
default:
|
|
77
|
+
throw rpcError(-32601, `Method not found: ${method}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async prompt(params) {
|
|
81
|
+
const session = this.sessions.get(String(params.sessionId));
|
|
82
|
+
if (!session)
|
|
83
|
+
throw rpcError(-32602, `Unknown session ${String(params.sessionId)}`);
|
|
84
|
+
if (session.controller)
|
|
85
|
+
throw rpcError(-32602, 'A prompt is already running for this session');
|
|
86
|
+
const task = promptToText(params.prompt);
|
|
87
|
+
if (!task.trim())
|
|
88
|
+
throw rpcError(-32602, 'Empty prompt');
|
|
89
|
+
const controller = new AbortController();
|
|
90
|
+
session.controller = controller;
|
|
91
|
+
const config = await this.deps.createAgentConfig(session.cwd, session.id);
|
|
92
|
+
const toolTitles = new Map();
|
|
93
|
+
const update = (u) => this.notify('session/update', { sessionId: session.id, update: u });
|
|
94
|
+
try {
|
|
95
|
+
const result = await this.deps.runAgent({
|
|
96
|
+
...config,
|
|
97
|
+
cwd: session.cwd,
|
|
98
|
+
approve: (req) => this.askPermission(session.id, req, toolTitles.get(req.id)),
|
|
99
|
+
}, {
|
|
100
|
+
task,
|
|
101
|
+
...(session.history ? { history: session.history } : {}),
|
|
102
|
+
abortSignal: controller.signal,
|
|
103
|
+
onEvent: (e) => {
|
|
104
|
+
switch (e.type) {
|
|
105
|
+
case 'text_delta':
|
|
106
|
+
update({ sessionUpdate: 'agent_message_chunk', content: { type: 'text', text: e.text } });
|
|
107
|
+
return;
|
|
108
|
+
case 'reasoning_delta':
|
|
109
|
+
update({ sessionUpdate: 'agent_thought_chunk', content: { type: 'text', text: e.text } });
|
|
110
|
+
return;
|
|
111
|
+
case 'tool_call': {
|
|
112
|
+
const title = `${e.name}${summarize(e.args)}`;
|
|
113
|
+
toolTitles.set(e.id, title);
|
|
114
|
+
update({ sessionUpdate: 'tool_call', toolCallId: e.id, title, kind: toolKind(e.name), status: 'in_progress', rawInput: e.args });
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
case 'tool_result':
|
|
118
|
+
update({
|
|
119
|
+
sessionUpdate: 'tool_call_update',
|
|
120
|
+
toolCallId: e.id,
|
|
121
|
+
status: e.isError ? 'failed' : 'completed',
|
|
122
|
+
content: [{ type: 'content', content: { type: 'text', text: clip(stringify(e.result)) } }],
|
|
123
|
+
});
|
|
124
|
+
return;
|
|
125
|
+
default:
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
session.history = result.messages;
|
|
131
|
+
return { stopReason: stopReasonFor(result.reason) };
|
|
132
|
+
}
|
|
133
|
+
finally {
|
|
134
|
+
session.controller = undefined;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
async askPermission(sessionId, req, title) {
|
|
138
|
+
try {
|
|
139
|
+
const res = (await this.request('session/request_permission', {
|
|
140
|
+
sessionId,
|
|
141
|
+
toolCall: { toolCallId: req.id, title: title ?? req.name, kind: toolKind(req.name), status: 'pending', rawInput: req.args },
|
|
142
|
+
options: [
|
|
143
|
+
{ optionId: 'allow', name: 'Allow', kind: 'allow_once' },
|
|
144
|
+
{ optionId: 'reject', name: 'Reject', kind: 'reject_once' },
|
|
145
|
+
],
|
|
146
|
+
}));
|
|
147
|
+
return res?.outcome?.outcome === 'selected' && res.outcome.optionId === 'allow';
|
|
148
|
+
}
|
|
149
|
+
catch {
|
|
150
|
+
return false; // no answer means no permission
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
request(method, params) {
|
|
154
|
+
const id = this.nextRequestId++;
|
|
155
|
+
return new Promise((resolve, reject) => {
|
|
156
|
+
this.pending.set(id, { resolve, reject });
|
|
157
|
+
this.send({ jsonrpc: '2.0', id, method, params: params });
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
notify(method, params) {
|
|
161
|
+
this.send({ jsonrpc: '2.0', method, params: params });
|
|
162
|
+
}
|
|
163
|
+
send(msg) {
|
|
164
|
+
this.write(JSON.stringify(msg));
|
|
165
|
+
}
|
|
166
|
+
/** Abort every running prompt and fail outstanding client requests (call when the transport closes). */
|
|
167
|
+
close() {
|
|
168
|
+
for (const s of this.sessions.values())
|
|
169
|
+
s.controller?.abort();
|
|
170
|
+
for (const p of this.pending.values())
|
|
171
|
+
p.reject(new Error('connection closed'));
|
|
172
|
+
this.pending.clear();
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
function rpcError(code, message) {
|
|
176
|
+
return Object.assign(new Error(message), { code });
|
|
177
|
+
}
|
|
178
|
+
/** ACP content blocks -> the plain-text task Forge runs. */
|
|
179
|
+
export function promptToText(prompt) {
|
|
180
|
+
if (typeof prompt === 'string')
|
|
181
|
+
return prompt;
|
|
182
|
+
if (!Array.isArray(prompt))
|
|
183
|
+
return '';
|
|
184
|
+
const parts = [];
|
|
185
|
+
for (const block of prompt) {
|
|
186
|
+
if (block.type === 'text' && typeof block.text === 'string')
|
|
187
|
+
parts.push(block.text);
|
|
188
|
+
else if (block.type === 'resource') {
|
|
189
|
+
const r = block.resource;
|
|
190
|
+
if (r?.text !== undefined)
|
|
191
|
+
parts.push(`<context path="${String(r.uri ?? '')}">\n${r.text}\n</context>`);
|
|
192
|
+
}
|
|
193
|
+
else if (block.type === 'resource_link') {
|
|
194
|
+
parts.push(`@${String(block.name ?? block.uri ?? '')} (${String(block.uri ?? '')})`);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
return parts.join('\n\n');
|
|
198
|
+
}
|
|
199
|
+
export function stopReasonFor(reason) {
|
|
200
|
+
switch (reason) {
|
|
201
|
+
case 'aborted':
|
|
202
|
+
return 'cancelled';
|
|
203
|
+
case 'max_iterations':
|
|
204
|
+
case 'max_duration':
|
|
205
|
+
case 'budget_exceeded':
|
|
206
|
+
return 'max_turn_requests';
|
|
207
|
+
default:
|
|
208
|
+
return 'end_turn';
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
export function toolKind(name) {
|
|
212
|
+
if (name === 'read_file' || name === 'read_image' || name === 'list_files' || name === 'memory_read')
|
|
213
|
+
return 'read';
|
|
214
|
+
if (name === 'write_file' || name === 'edit_file' || name === 'memory_write')
|
|
215
|
+
return 'edit';
|
|
216
|
+
if (name === 'run_command')
|
|
217
|
+
return 'execute';
|
|
218
|
+
if (name === 'fetch_url' || name.startsWith('browser'))
|
|
219
|
+
return 'fetch';
|
|
220
|
+
if (name === 'search_files' || name === 'find_symbol' || name === 'list_symbols' || name === 'find_references' || name === 'codebase_search')
|
|
221
|
+
return 'search';
|
|
222
|
+
return 'other';
|
|
223
|
+
}
|
|
224
|
+
function summarize(args) {
|
|
225
|
+
const a = (args ?? {});
|
|
226
|
+
const hint = a.path ?? a.command ?? a.pattern ?? a.query ?? a.url ?? a.name;
|
|
227
|
+
return typeof hint === 'string' ? `: ${hint.slice(0, 80)}` : '';
|
|
228
|
+
}
|
|
229
|
+
function stringify(v) {
|
|
230
|
+
return typeof v === 'string' ? v : JSON.stringify(v);
|
|
231
|
+
}
|
|
232
|
+
function clip(s) {
|
|
233
|
+
return s.length > MAX_TOOL_TEXT ? `${s.slice(0, MAX_TOOL_TEXT)}\n... (truncated)` : s;
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/acp/server.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AA+BtC,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B,MAAM,OAAO,SAAS;IAOD;IACA;IAPF,QAAQ,GAAG,IAAI,GAAG,EAAmB,CAAC;IACtC,OAAO,GAAG,IAAI,GAAG,EAAwE,CAAC;IACnG,aAAa,GAAG,CAAC,CAAC;IAClB,OAAO,GAAG,CAAC,CAAC;IAEpB,YACmB,KAA6B,EAC7B,IAAa;QADb,UAAK,GAAL,KAAK,CAAwB;QAC7B,SAAI,GAAJ,IAAI,CAAS;IAC7B,CAAC;IAEJ,4CAA4C;IAC5C,KAAK,CAAC,UAAU,CAAC,IAAY;QAC3B,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YAAE,OAAO;QACzB,IAAI,GAAe,CAAC;QACpB,IAAI,CAAC;YACH,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAe,CAAC;QACvC,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,IAAyB,EAAE,KAAK,EAAE,EAAE,IA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IAAI,EAAE,CAA4B,CAAC;IAClD,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,OAAO,IAAI,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,IAAI,CAAC;IAC5E,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAClE,CAAC;AAED,SAAS,SAAS,CAAC,CAAU;IAC3B,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;AACvD,CAAC;AAED,SAAS,IAAI,CAAC,CAAS;IACrB,OAAO,CAAC,CAAC,MAAM,GAAG,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC;AACxF,CAAC"}
|
package/dist/app.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { ForgeConfigFile, ModelConfig } from '@ikarmic/forge-core';
|
|
3
|
+
import type { AgentConfig } from '@ikarmic/forge-core';
|
|
4
|
+
export interface AppProps {
|
|
5
|
+
task: string;
|
|
6
|
+
baseConfig: AgentConfig;
|
|
7
|
+
model: ModelConfig;
|
|
8
|
+
display?: ForgeConfigFile['display'];
|
|
9
|
+
onResult: (result: {
|
|
10
|
+
reason: string;
|
|
11
|
+
inputTokens: number;
|
|
12
|
+
outputTokens: number;
|
|
13
|
+
durationMs: number;
|
|
14
|
+
iterations: number;
|
|
15
|
+
finalText: string;
|
|
16
|
+
costUsd?: number;
|
|
17
|
+
costKnown?: boolean;
|
|
18
|
+
}) => void;
|
|
19
|
+
onError: (err: Error) => void;
|
|
20
|
+
}
|
|
21
|
+
export declare function App({ task, baseConfig, model, display, onResult, onError }: AppProps): React.ReactElement;
|
|
22
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../src/app.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4D,MAAM,OAAO,CAAC;AAIjF,OAAO,KAAK,EAA+B,eAAe,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAQrG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAEvD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,WAAW,CAAC;IACxB,KAAK,EAAE,WAAW,CAAC;IACnB,OAAO,CAAC,EAAE,eAAe,CAAC,SAAS,CAAC,CAAC;IACrC,QAAQ,EAAE,CAAC,MAAM,EAAE;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,SAAS,CAAC,EAAE,OAAO,CAAC;KACrB,KAAK,IAAI,CAAC;IACX,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,CAAC;CAC/B;AAiBD,wBAAgB,GAAG,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,OAAY,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,QAAQ,GAAG,KAAK,CAAC,YAAY,CA8M9G"}
|
package/dist/app.js
ADDED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { Box, Text } from 'ink';
|
|
3
|
+
import { formatSteeringLine } from '@ikarmic/forge-core';
|
|
4
|
+
import { Approval } from './components/Approval.js';
|
|
5
|
+
import { Footer } from './components/Footer.js';
|
|
6
|
+
import { Header } from './components/Header.js';
|
|
7
|
+
import { Stream } from './components/Stream.js';
|
|
8
|
+
import { ToolEvent } from './components/ToolEvent.js';
|
|
9
|
+
import { startAgent } from './runner.js';
|
|
10
|
+
export function App({ task, baseConfig, model, display = {}, onResult, onError }) {
|
|
11
|
+
const [stream, setStream] = useState('');
|
|
12
|
+
const [streaming, setStreaming] = useState(false);
|
|
13
|
+
const [reasoningText, setReasoningText] = useState('');
|
|
14
|
+
const [reasoningStreaming, setReasoningStreaming] = useState(false);
|
|
15
|
+
const [tools, setTools] = useState([]);
|
|
16
|
+
const [iteration, setIteration] = useState(0);
|
|
17
|
+
const [maxIterations, setMaxIterations] = useState(baseConfig.maxIterations ?? 50);
|
|
18
|
+
const [status, setStatus] = useState('idle');
|
|
19
|
+
const [inputTokens, setInputTokens] = useState(0);
|
|
20
|
+
const [outputTokens, setOutputTokens] = useState(0);
|
|
21
|
+
const [cachedInputTokens, setCachedInputTokens] = useState(0);
|
|
22
|
+
const [durationMs, setDurationMs] = useState(0);
|
|
23
|
+
const [reason, setReason] = useState(undefined);
|
|
24
|
+
const [steeringLine, setSteeringLine] = useState(undefined);
|
|
25
|
+
const [pendingApproval, setPendingApproval] = useState(null);
|
|
26
|
+
const [costUsd, setCostUsd] = useState(undefined);
|
|
27
|
+
const [redactedCount, setRedactedCount] = useState(0);
|
|
28
|
+
const [cacheHits, setCacheHits] = useState(0);
|
|
29
|
+
const [cacheMisses, setCacheMisses] = useState(0);
|
|
30
|
+
const startedAtRef = useRef(0);
|
|
31
|
+
// Set by a `continuation` event: the next text_done carries only the
|
|
32
|
+
// continued step's text, so keep the streamed whole instead of replacing it.
|
|
33
|
+
const continuedRef = useRef(false);
|
|
34
|
+
const hooks = useMemo(() => ({
|
|
35
|
+
onEvent: (event) => {
|
|
36
|
+
switch (event.type) {
|
|
37
|
+
case 'iteration':
|
|
38
|
+
setIteration(event.iteration);
|
|
39
|
+
setMaxIterations(event.maxIterations);
|
|
40
|
+
setStatus('running');
|
|
41
|
+
break;
|
|
42
|
+
case 'text_delta':
|
|
43
|
+
setStreaming(true);
|
|
44
|
+
setStream((prev) => prev + event.text);
|
|
45
|
+
break;
|
|
46
|
+
case 'text_done':
|
|
47
|
+
setStreaming(false);
|
|
48
|
+
if (continuedRef.current) {
|
|
49
|
+
continuedRef.current = false;
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
setStream(event.text);
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
case 'continuation':
|
|
56
|
+
continuedRef.current = true;
|
|
57
|
+
break;
|
|
58
|
+
case 'reasoning_delta':
|
|
59
|
+
setReasoningStreaming(true);
|
|
60
|
+
setReasoningText((prev) => prev + event.text);
|
|
61
|
+
break;
|
|
62
|
+
case 'reasoning_done':
|
|
63
|
+
setReasoningStreaming(false);
|
|
64
|
+
setReasoningText(event.text);
|
|
65
|
+
break;
|
|
66
|
+
case 'tool_call':
|
|
67
|
+
setTools((prev) => [
|
|
68
|
+
...prev,
|
|
69
|
+
{ name: event.name, id: event.id, args: event.args, startedAt: Date.now() },
|
|
70
|
+
]);
|
|
71
|
+
break;
|
|
72
|
+
case 'tool_result':
|
|
73
|
+
setTools((prev) => prev.map((t) => t.id === event.id
|
|
74
|
+
? { ...t, result: event.result, isError: event.isError, durationMs: Date.now() - t.startedAt }
|
|
75
|
+
: t));
|
|
76
|
+
if (event.redacted !== undefined && event.redacted > 0) {
|
|
77
|
+
setRedactedCount((c) => c + event.redacted);
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
case 'usage':
|
|
81
|
+
setInputTokens(event.inputTokens);
|
|
82
|
+
setOutputTokens(event.outputTokens);
|
|
83
|
+
setCachedInputTokens(event.cachedInputTokens ?? 0);
|
|
84
|
+
break;
|
|
85
|
+
case 'cost':
|
|
86
|
+
setCostUsd(event.runningCostUsd);
|
|
87
|
+
break;
|
|
88
|
+
case 'cache_stats':
|
|
89
|
+
setCacheHits(event.hits);
|
|
90
|
+
setCacheMisses(event.misses);
|
|
91
|
+
break;
|
|
92
|
+
case 'steering':
|
|
93
|
+
setSteeringLine(formatSteeringLine(event));
|
|
94
|
+
break;
|
|
95
|
+
case 'error':
|
|
96
|
+
// Set status, but keep going: done event will fire
|
|
97
|
+
setStatus('error');
|
|
98
|
+
break;
|
|
99
|
+
case 'done':
|
|
100
|
+
setStatus(event.reason === 'error' ? 'error' : 'done');
|
|
101
|
+
setReason(event.reason);
|
|
102
|
+
setDurationMs(Date.now() - startedAtRef.current);
|
|
103
|
+
break;
|
|
104
|
+
case 'approval_requested':
|
|
105
|
+
// not used: handled via approve callback below
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
requestApproval: (request) => {
|
|
110
|
+
return new Promise((resolve) => {
|
|
111
|
+
setPendingApproval({ request, resolve });
|
|
112
|
+
});
|
|
113
|
+
},
|
|
114
|
+
}), []);
|
|
115
|
+
const handleApproval = useCallback((approved) => {
|
|
116
|
+
if (pendingApproval) {
|
|
117
|
+
pendingApproval.resolve(approved);
|
|
118
|
+
setPendingApproval(null);
|
|
119
|
+
}
|
|
120
|
+
}, [pendingApproval]);
|
|
121
|
+
useEffect(() => {
|
|
122
|
+
startedAtRef.current = Date.now();
|
|
123
|
+
setStatus('running');
|
|
124
|
+
const handle = startAgent({ baseConfig, task, hooks });
|
|
125
|
+
handle.promise
|
|
126
|
+
.then((res) => {
|
|
127
|
+
onResult({
|
|
128
|
+
reason: res.reason,
|
|
129
|
+
inputTokens: res.inputTokens,
|
|
130
|
+
outputTokens: res.outputTokens,
|
|
131
|
+
durationMs: res.durationMs,
|
|
132
|
+
iterations: res.iterations,
|
|
133
|
+
finalText: res.finalText,
|
|
134
|
+
costUsd: res.costUsd,
|
|
135
|
+
costKnown: res.costKnown,
|
|
136
|
+
});
|
|
137
|
+
})
|
|
138
|
+
.catch((err) => {
|
|
139
|
+
setStatus('error');
|
|
140
|
+
onError(err);
|
|
141
|
+
});
|
|
142
|
+
return () => handle.abort();
|
|
143
|
+
}, [task, baseConfig, hooks, onResult, onError]);
|
|
144
|
+
return (React.createElement(Box, { flexDirection: "column", paddingX: 1 },
|
|
145
|
+
React.createElement(Header, { model: model, iteration: iteration, maxIterations: maxIterations, status: status, auto: baseConfig.auto ?? false }),
|
|
146
|
+
React.createElement(Box, { flexDirection: "column", marginTop: 1 },
|
|
147
|
+
React.createElement(Box, null,
|
|
148
|
+
React.createElement(Text, { color: "gray" }, "\u250C\u2500 task")),
|
|
149
|
+
React.createElement(Box, { marginLeft: 2 },
|
|
150
|
+
React.createElement(Text, null, task))),
|
|
151
|
+
steeringLine && (React.createElement(Box, { marginLeft: 2 },
|
|
152
|
+
React.createElement(Text, { dimColor: true }, steeringLine))),
|
|
153
|
+
reasoningText && display.showReasoning !== false && (React.createElement(Stream, { text: reasoningText, streaming: reasoningStreaming, label: "reasoning" })),
|
|
154
|
+
stream && React.createElement(Stream, { text: stream, streaming: streaming }),
|
|
155
|
+
tools.map((t) => (React.createElement(ToolEvent, { key: t.id, name: t.name, args: t.args, ...(t.result !== undefined ? { result: t.result } : {}), ...(t.isError !== undefined ? { isError: t.isError } : {}), ...(t.durationMs !== undefined ? { durationMs: t.durationMs } : {}), pending: t.result === undefined, detail: display.detail ?? 'compact' }))),
|
|
156
|
+
pendingApproval && (React.createElement(Approval, { request: pendingApproval.request, onResolve: handleApproval })),
|
|
157
|
+
status === 'done' || status === 'error' ? (React.createElement(Footer, { inputTokens: inputTokens, outputTokens: outputTokens, ...(cachedInputTokens > 0 ? { cachedInputTokens } : {}), durationMs: durationMs, iteration: iteration, ...(costUsd !== undefined ? { costUsd } : {}), ...(redactedCount > 0 ? { redacted: redactedCount } : {}), ...(baseConfig.cacheSize !== 0 ? { cacheHits, cacheMisses } : {}), ...(reason ? { reason } : {}) })) : null));
|
|
158
|
+
}
|
|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