@ap3x/cli 0.1.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 +34 -0
- package/dist/agent-session.d.ts +163 -0
- package/dist/agent-session.d.ts.map +1 -0
- package/dist/auth/anthropic-login.d.ts +98 -0
- package/dist/auth/anthropic-login.d.ts.map +1 -0
- package/dist/auth/codex-login.d.ts +80 -0
- package/dist/auth/codex-login.d.ts.map +1 -0
- package/dist/auth/copilot-login.d.ts +36 -0
- package/dist/auth/copilot-login.d.ts.map +1 -0
- package/dist/auth/login-dispatch.d.ts +76 -0
- package/dist/auth/login-dispatch.d.ts.map +1 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +15 -0
- package/dist/branding.d.ts +89 -0
- package/dist/branding.d.ts.map +1 -0
- package/dist/chunk-3WSVGI7R.js +10522 -0
- package/dist/cli.d.ts +135 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cron/agent-executor.d.ts +45 -0
- package/dist/cron/agent-executor.d.ts.map +1 -0
- package/dist/cron/cron-cli.d.ts +27 -0
- package/dist/cron/cron-cli.d.ts.map +1 -0
- package/dist/cron/schedule-file.d.ts +7 -0
- package/dist/cron/schedule-file.d.ts.map +1 -0
- package/dist/glob.d.ts +12 -0
- package/dist/glob.d.ts.map +1 -0
- package/dist/hooks/hooks-cli.d.ts +11 -0
- package/dist/hooks/hooks-cli.d.ts.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +462 -0
- package/dist/modes/index.d.ts +5 -0
- package/dist/modes/index.d.ts.map +1 -0
- package/dist/modes/interactive.d.ts +44 -0
- package/dist/modes/interactive.d.ts.map +1 -0
- package/dist/modes/print.d.ts +24 -0
- package/dist/modes/print.d.ts.map +1 -0
- package/dist/modes/render.d.ts +29 -0
- package/dist/modes/render.d.ts.map +1 -0
- package/dist/modes/rpc.d.ts +149 -0
- package/dist/modes/rpc.d.ts.map +1 -0
- package/dist/sdk.d.ts +95 -0
- package/dist/sdk.d.ts.map +1 -0
- package/dist/settings.d.ts +109 -0
- package/dist/settings.d.ts.map +1 -0
- package/dist/skills.d.ts +27 -0
- package/dist/skills.d.ts.map +1 -0
- package/dist/slash-commands.d.ts +79 -0
- package/dist/slash-commands.d.ts.map +1 -0
- package/dist/system-prompt.d.ts +21 -0
- package/dist/system-prompt.d.ts.map +1 -0
- package/dist/tools/a2a.d.ts +11 -0
- package/dist/tools/a2a.d.ts.map +1 -0
- package/dist/tools/bash.d.ts +4 -0
- package/dist/tools/bash.d.ts.map +1 -0
- package/dist/tools/context.d.ts +42 -0
- package/dist/tools/context.d.ts.map +1 -0
- package/dist/tools/edit.d.ts +16 -0
- package/dist/tools/edit.d.ts.map +1 -0
- package/dist/tools/find.d.ts +9 -0
- package/dist/tools/find.d.ts.map +1 -0
- package/dist/tools/grep.d.ts +9 -0
- package/dist/tools/grep.d.ts.map +1 -0
- package/dist/tools/index.d.ts +35 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/ls.d.ts +5 -0
- package/dist/tools/ls.d.ts.map +1 -0
- package/dist/tools/read.d.ts +9 -0
- package/dist/tools/read.d.ts.map +1 -0
- package/dist/tools/swarm.d.ts +42 -0
- package/dist/tools/swarm.d.ts.map +1 -0
- package/dist/tools/walk.d.ts +48 -0
- package/dist/tools/walk.d.ts.map +1 -0
- package/dist/tools/write.d.ts +9 -0
- package/dist/tools/write.d.ts.map +1 -0
- package/dist/trace/trace-cli.d.ts +9 -0
- package/dist/trace/trace-cli.d.ts.map +1 -0
- package/dist/utils/clipboard.d.ts +23 -0
- package/dist/utils/clipboard.d.ts.map +1 -0
- package/dist/utils/git.d.ts +13 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/highlight.d.ts +23 -0
- package/dist/utils/highlight.d.ts.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/resume.d.ts +9 -0
- package/dist/utils/resume.d.ts.map +1 -0
- package/dist/utils/version-check.d.ts +34 -0
- package/dist/utils/version-check.d.ts.map +1 -0
- package/package.json +45 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { AgentSessionRuntime } from "../sdk";
|
|
3
|
+
/**
|
|
4
|
+
* JSONL RPC mode (§10 #50). One JSON object per line in each direction. Every
|
|
5
|
+
* inbound command is validated with a zod schema BEFORE it touches the runtime;
|
|
6
|
+
* a malformed command yields a structured `error` response and never throws —
|
|
7
|
+
* this is the hardening contract. The wire shape is intentionally stable so
|
|
8
|
+
* embedders can rely on it.
|
|
9
|
+
*
|
|
10
|
+
* Inbound: { id, command, ...payload }
|
|
11
|
+
* Outbound: { id, ok: true, result } | { id, ok: false, error: { code, message } }
|
|
12
|
+
*/
|
|
13
|
+
/** A structured error attached to a failed response. */
|
|
14
|
+
export interface RpcError {
|
|
15
|
+
code: "invalid_request" | "unknown_command" | "runtime_error";
|
|
16
|
+
message: string;
|
|
17
|
+
/** zod issue details when the failure was a validation error. */
|
|
18
|
+
details?: unknown;
|
|
19
|
+
}
|
|
20
|
+
/** The outbound response envelope. */
|
|
21
|
+
export type RpcResponse = {
|
|
22
|
+
id: string | null;
|
|
23
|
+
ok: true;
|
|
24
|
+
result: unknown;
|
|
25
|
+
} | {
|
|
26
|
+
id: string | null;
|
|
27
|
+
ok: false;
|
|
28
|
+
error: RpcError;
|
|
29
|
+
};
|
|
30
|
+
/** Mutable per-connection session state the loop threads through commands. */
|
|
31
|
+
export interface RpcSessionState {
|
|
32
|
+
runtime: AgentSessionRuntime;
|
|
33
|
+
/** Count of prompts handled this connection (diagnostics). */
|
|
34
|
+
prompts: number;
|
|
35
|
+
}
|
|
36
|
+
/** The discriminated union of every recognized inbound command. */
|
|
37
|
+
export declare const RpcCommandSchema: z.ZodDiscriminatedUnion<"command", [z.ZodObject<{
|
|
38
|
+
command: z.ZodLiteral<"prompt">;
|
|
39
|
+
prompt: z.ZodString;
|
|
40
|
+
id: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
command: "prompt";
|
|
43
|
+
prompt: string;
|
|
44
|
+
id?: string | undefined;
|
|
45
|
+
}, {
|
|
46
|
+
command: "prompt";
|
|
47
|
+
prompt: string;
|
|
48
|
+
id?: string | undefined;
|
|
49
|
+
}>, z.ZodObject<{
|
|
50
|
+
command: z.ZodLiteral<"model">;
|
|
51
|
+
id: z.ZodOptional<z.ZodString>;
|
|
52
|
+
}, "strip", z.ZodTypeAny, {
|
|
53
|
+
command: "model";
|
|
54
|
+
id?: string | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
command: "model";
|
|
57
|
+
id?: string | undefined;
|
|
58
|
+
}>, z.ZodObject<{
|
|
59
|
+
command: z.ZodLiteral<"session">;
|
|
60
|
+
id: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
command: "session";
|
|
63
|
+
id?: string | undefined;
|
|
64
|
+
}, {
|
|
65
|
+
command: "session";
|
|
66
|
+
id?: string | undefined;
|
|
67
|
+
}>, z.ZodObject<{
|
|
68
|
+
command: z.ZodLiteral<"ping">;
|
|
69
|
+
id: z.ZodOptional<z.ZodString>;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
command: "ping";
|
|
72
|
+
id?: string | undefined;
|
|
73
|
+
}, {
|
|
74
|
+
command: "ping";
|
|
75
|
+
id?: string | undefined;
|
|
76
|
+
}>, z.ZodObject<{
|
|
77
|
+
command: z.ZodLiteral<"shutdown">;
|
|
78
|
+
id: z.ZodOptional<z.ZodString>;
|
|
79
|
+
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
command: "shutdown";
|
|
81
|
+
id?: string | undefined;
|
|
82
|
+
}, {
|
|
83
|
+
command: "shutdown";
|
|
84
|
+
id?: string | undefined;
|
|
85
|
+
}>]>;
|
|
86
|
+
/** A validated inbound command. */
|
|
87
|
+
export type RpcCommand = z.infer<typeof RpcCommandSchema>;
|
|
88
|
+
/** Distributive `Omit` so a union member keeps its own shape after dropping a key. */
|
|
89
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
90
|
+
/** An inbound command without its (client-assigned) request id. */
|
|
91
|
+
export type RpcCommandInput = DistributiveOmit<RpcCommand, "id">;
|
|
92
|
+
/** The set of recognized command names (for diagnostics / docs). */
|
|
93
|
+
export declare const RPC_COMMANDS: readonly ["prompt", "model", "session", "ping", "shutdown"];
|
|
94
|
+
/** A line-oriented input stream: yields one inbound line at a time. */
|
|
95
|
+
export interface RpcInput {
|
|
96
|
+
lines(): AsyncIterable<string>;
|
|
97
|
+
}
|
|
98
|
+
/** A line-oriented output sink. */
|
|
99
|
+
export interface RpcOutput {
|
|
100
|
+
write(line: string): void;
|
|
101
|
+
}
|
|
102
|
+
/** Frame a response object as a single JSONL line (trailing newline included). */
|
|
103
|
+
export declare function frameResponse(response: RpcResponse): string;
|
|
104
|
+
/** Adapt a Node Readable into an {@link RpcInput} splitting on newlines. */
|
|
105
|
+
export declare function nodeRpcInput(readable: NodeJS.ReadableStream): RpcInput;
|
|
106
|
+
/** Adapt a Node Writable into an {@link RpcOutput}. */
|
|
107
|
+
export declare function nodeRpcOutput(writable: NodeJS.WritableStream): RpcOutput;
|
|
108
|
+
/**
|
|
109
|
+
* Parse + validate one inbound line. Returns either a validated command or a
|
|
110
|
+
* structured error response — it NEVER throws on bad input. Blank lines are
|
|
111
|
+
* skipped (returns `undefined`).
|
|
112
|
+
*/
|
|
113
|
+
export declare function parseRpcLine(line: string): RpcCommand | RpcResponse | undefined;
|
|
114
|
+
/** Options for {@link runRpcMode}. */
|
|
115
|
+
export interface RpcModeOptions {
|
|
116
|
+
runtime: AgentSessionRuntime;
|
|
117
|
+
input: RpcInput;
|
|
118
|
+
output: RpcOutput;
|
|
119
|
+
signal?: AbortSignal;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Run the JSONL RPC loop until input ends or a `shutdown` command arrives.
|
|
123
|
+
* Returns a process exit code (0). Every line produces exactly one response
|
|
124
|
+
* line; bad input produces a structured error response without throwing.
|
|
125
|
+
*/
|
|
126
|
+
export declare function runRpcMode(options: RpcModeOptions): Promise<number>;
|
|
127
|
+
/**
|
|
128
|
+
* The embedder/test-facing counterpart to {@link runRpcMode}: it frames and
|
|
129
|
+
* sends commands and parses responses over the same JSONL wire. It is transport
|
|
130
|
+
* agnostic — you supply how a framed line is sent and how the next response line
|
|
131
|
+
* is read.
|
|
132
|
+
*/
|
|
133
|
+
export declare class RpcClient {
|
|
134
|
+
private readonly transport;
|
|
135
|
+
private counter;
|
|
136
|
+
constructor(transport: {
|
|
137
|
+
send(line: string): void | Promise<void>;
|
|
138
|
+
receive(): Promise<string>;
|
|
139
|
+
});
|
|
140
|
+
private nextId;
|
|
141
|
+
/** Send a command and await its response. */
|
|
142
|
+
send(command: RpcCommandInput): Promise<RpcResponse>;
|
|
143
|
+
/** Convenience: send a `prompt` command. */
|
|
144
|
+
prompt(prompt: string): Promise<RpcResponse>;
|
|
145
|
+
/** Convenience: send a `ping` command. */
|
|
146
|
+
ping(): Promise<RpcResponse>;
|
|
147
|
+
}
|
|
148
|
+
export {};
|
|
149
|
+
//# sourceMappingURL=rpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../../src/modes/rpc.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,QAAQ,CAAC;AAGlD;;;;;;;;;GASG;AAIH,wDAAwD;AACxD,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,iBAAiB,GAAG,iBAAiB,GAAG,eAAe,CAAC;IAC9D,OAAO,EAAE,MAAM,CAAC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
import { type AgentSession, type AgentSessionOptions, type AgentSessionServices, createAgentSession } from "./agent-session";
|
|
3
|
+
/**
|
|
4
|
+
* The AP3X CLI SDK surface. It re-exports the {@link AgentSession} composition
|
|
5
|
+
* and adds {@link AgentSessionRuntime}, a lifecycle wrapper that owns a session
|
|
6
|
+
* plus its backend and can swap the active session over a {@link SessionRepo}
|
|
7
|
+
* (new / switch / fork / import). The services split
|
|
8
|
+
* (createAgentSessionServices -> createAgentSessionFromServices) is the
|
|
9
|
+
* injection seam for tests + F2.
|
|
10
|
+
*/
|
|
11
|
+
export { AgentSession, type AgentSessionEvent, type AgentSessionListener, type AgentSessionOptions, type AgentSessionServices, createAgentSession, createAgentSessionFromServices, createAgentSessionServices, } from "./agent-session";
|
|
12
|
+
/** Injectable dependencies for {@link AgentSessionRuntime}'s session lifecycle. */
|
|
13
|
+
export interface AgentSessionRuntimeConfig {
|
|
14
|
+
/** The store new/switch/fork/import operate over. Defaults to a `JsonlSessionRepo`. */
|
|
15
|
+
repo?: SessionRepo;
|
|
16
|
+
/**
|
|
17
|
+
* Re-derive the services bound to a swapped session. The options factory
|
|
18
|
+
* supplies one that rebuilds a fresh backend (unless a backend was injected)
|
|
19
|
+
* seeded from the ATTACHED persisted session only — a fresh session yields an
|
|
20
|
+
* empty transcript, a resumed/forked session yields its history — never from
|
|
21
|
+
* the previous session's in-memory transcript. Used by every lifecycle swap.
|
|
22
|
+
*/
|
|
23
|
+
rebuild?: (session: Session | undefined) => AgentSessionServices;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A lifecycle-managed runtime around an {@link AgentSession}. Holds the resolved
|
|
27
|
+
* services (so the backend can be inspected and disposed) plus a
|
|
28
|
+
* {@link SessionRepo}, and exposes repo-backed session operations. Swapping the
|
|
29
|
+
* active session re-derives the services (fresh backend in production) and
|
|
30
|
+
* rebuilds the bound {@link AgentSession}, disposing the previous one so nothing
|
|
31
|
+
* stale keeps observing the old backend. F2 instantiates one per run mode.
|
|
32
|
+
*/
|
|
33
|
+
export declare class AgentSessionRuntime {
|
|
34
|
+
private activeSession;
|
|
35
|
+
private services;
|
|
36
|
+
private readonly repo;
|
|
37
|
+
private readonly rebuild;
|
|
38
|
+
constructor(services: AgentSessionServices, config?: AgentSessionRuntimeConfig);
|
|
39
|
+
/** The active {@link AgentSession}. Replaced (by identity) on every swap. */
|
|
40
|
+
get session(): AgentSession;
|
|
41
|
+
/** The persistent session tree currently bound, if any. */
|
|
42
|
+
get currentSession(): Session | undefined;
|
|
43
|
+
/** The underlying backend (for capability checks / advanced wiring). */
|
|
44
|
+
get backend(): AgentBackend;
|
|
45
|
+
/** Convenience pass-through to the active session's prompt queue. */
|
|
46
|
+
prompt(prompt: string, opts?: {
|
|
47
|
+
signal?: AbortSignal;
|
|
48
|
+
}): Promise<AgentRunResult>;
|
|
49
|
+
/** Mint a fresh persisted session and make it the active session. */
|
|
50
|
+
newSession(options?: SessionCreateOptions): Session;
|
|
51
|
+
/**
|
|
52
|
+
* Open an existing session by id and make it active. Surfaces the repo's
|
|
53
|
+
* `not_found` {@link SessionError} when the id is absent.
|
|
54
|
+
*/
|
|
55
|
+
switchSession(id: string): Session;
|
|
56
|
+
/**
|
|
57
|
+
* Fork the active session into a new independent id that shares history up to
|
|
58
|
+
* the fork point, then switch to it. `entryId` selects the fork point (omit to
|
|
59
|
+
* copy the whole session); `options` carries the repo's fork controls
|
|
60
|
+
* (`position`, `id`, `cwd`, `parentSessionId`).
|
|
61
|
+
*/
|
|
62
|
+
fork(entryId?: string, options?: Omit<SessionForkOptions, "entryId">): Session;
|
|
63
|
+
/**
|
|
64
|
+
* Import an external session `.jsonl` file into a NEW repo session containing
|
|
65
|
+
* its entries, then switch to it. Matches pi's input shape (a filesystem path,
|
|
66
|
+
* plus an optional cwd override). The imported entries are appended to a
|
|
67
|
+
* freshly-minted session and the file is re-opened so the leaf is
|
|
68
|
+
* reconstructed exactly as a normal open would (mirrors the repo's fork copy).
|
|
69
|
+
*/
|
|
70
|
+
importFromJsonl(inputPath: string, options?: {
|
|
71
|
+
cwdOverride?: string;
|
|
72
|
+
}): Session;
|
|
73
|
+
/**
|
|
74
|
+
* Rebuild the active services from the CURRENT session so the live backend
|
|
75
|
+
* re-seeds from its persisted history — e.g. after `/compact` appends a
|
|
76
|
+
* compaction boundary, the fresh backend starts from the compacted context.
|
|
77
|
+
* Surfaces `not_found` {@link SessionError} when no session is attached.
|
|
78
|
+
*/
|
|
79
|
+
reseed(): Session;
|
|
80
|
+
/** Release all resources held by the active session. */
|
|
81
|
+
dispose(): void;
|
|
82
|
+
private requireCurrentSession;
|
|
83
|
+
/**
|
|
84
|
+
* Re-point the runtime at `next`: rebuild the session-bound services and
|
|
85
|
+
* dispose the previous {@link AgentSession} so it stops observing the old
|
|
86
|
+
* backend. Subsequent prompt()s run (and persist) against `next`.
|
|
87
|
+
*/
|
|
88
|
+
private swap;
|
|
89
|
+
}
|
|
90
|
+
/** Build an {@link AgentSessionRuntime} from high-level options. */
|
|
91
|
+
export declare function createAgentSessionRuntime(options?: AgentSessionOptions): AgentSessionRuntime;
|
|
92
|
+
/** Build an {@link AgentSessionRuntime} from pre-resolved services. */
|
|
93
|
+
export declare function createAgentSessionRuntimeFromServices(services: AgentSessionServices, config?: AgentSessionRuntimeConfig): AgentSessionRuntime;
|
|
94
|
+
export { createAgentSession as createSession };
|
|
95
|
+
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,OAAO,EACP,oBAAoB,EACpB,kBAAkB,EAClB,WAAW,EACZ,MAAM,kBAAkB,CAAC;AAO1B,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,oBAAoB,EACzB,kBAAkB,EAGnB,MAAM,iBAAiB,CAAC;AAEzB;;;;;;;GAOG;AAEH,OAA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EAAE,MAAM,EAAE,OAAO,CAAC,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO;IAkB/E;;;;;OAKG;IACH,MAAM,IAAI,OAAO;IAIjB,wDAAwD;IACxD,OAAO,IAAI,IAAI;IAIf,OAAO,CAAC,qBAAqB;IAW7B;;;;OAIG;IACH,OAAO,CAAC,IAAI;CAOb;AAED,oEAAoE;AACpE,wBAAgB,yBAAyB,CAAC,OAAO,GAAE,mBAAwB,GAAG,mBAAmB,CAUhG;AAED,uEAAuE;AACvE,wBAAgB,qCAAqC,CACnD,QAAQ,EAAE,oBAAoB,EAC9B,MAAM,GAAE,yBAA8B,GACrC,mBAAmB,CAErB;AAGD,OAAO,EAAE,kBAAkB,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/** A named remote A2A peer reachable via the `call_agent` tool. */
|
|
2
|
+
export interface RemoteAgentConfig {
|
|
3
|
+
/** Base URL of the remote agent's A2A server (http(s)://host:port/). */
|
|
4
|
+
url: string;
|
|
5
|
+
/** Bearer token sent on every request to this peer. */
|
|
6
|
+
bearerToken?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The full AP3X CLI configuration surface. Every field is optional in the
|
|
10
|
+
* persisted/partial forms; {@link DEFAULT_SETTINGS} supplies a value for each so
|
|
11
|
+
* the resolved {@link Settings} is total.
|
|
12
|
+
*/
|
|
13
|
+
export interface Settings {
|
|
14
|
+
/** Default model id (e.g. "claude-sonnet-4-5"). */
|
|
15
|
+
model: string;
|
|
16
|
+
/** Default provider slug (e.g. "anthropic"). */
|
|
17
|
+
provider: string;
|
|
18
|
+
/** Reasoning / thinking intensity. */
|
|
19
|
+
thinking: "off" | "minimal" | "low" | "medium" | "high" | "xhigh";
|
|
20
|
+
/** Hard cap on assistant turns per run. */
|
|
21
|
+
maxLoops: number;
|
|
22
|
+
/** Tool execution strategy. */
|
|
23
|
+
toolExecution: "sequential" | "parallel";
|
|
24
|
+
/**
|
|
25
|
+
* Tool allowlist. An **empty** list means "no restriction" — every built-in
|
|
26
|
+
* tool is available. A non-empty list is an explicit allowlist the user opted
|
|
27
|
+
* into (via `-t`, `AP3X_ACTIVE_TOOLS`, or settings.json) and confines the
|
|
28
|
+
* model to exactly those tools.
|
|
29
|
+
*/
|
|
30
|
+
activeTools: string[];
|
|
31
|
+
/** Compact the conversation automatically when the budget is exceeded. */
|
|
32
|
+
autoCompact: boolean;
|
|
33
|
+
/** Default working directory ("" means "process cwd at launch"). */
|
|
34
|
+
cwd: string;
|
|
35
|
+
/** Custom shell path for bash; "" means auto-detect. */
|
|
36
|
+
shellPath: string;
|
|
37
|
+
/** Enforce the cross-platform destructive-command blocklist. */
|
|
38
|
+
enforceBlocklist: boolean;
|
|
39
|
+
/** Named remote A2A peers the `call_agent` tool may contact (name -> config). */
|
|
40
|
+
remoteAgents: Record<string, RemoteAgentConfig>;
|
|
41
|
+
/** Agent Card name published by `ap3x serve` ("" = the AP3X display name). */
|
|
42
|
+
a2aName: string;
|
|
43
|
+
/** Agent Card description published by `ap3x serve` ("" = a model-derived default). */
|
|
44
|
+
a2aDescription: string;
|
|
45
|
+
/** Bearer token `ap3x serve` requires from callers ("" = no auth). */
|
|
46
|
+
a2aBearerToken: string;
|
|
47
|
+
}
|
|
48
|
+
/** A partial settings object as persisted on disk or supplied by env/flags. */
|
|
49
|
+
export type PartialSettings = Partial<Settings>;
|
|
50
|
+
/** The baseline configuration used when nothing else is provided. */
|
|
51
|
+
export declare const DEFAULT_SETTINGS: Settings;
|
|
52
|
+
/**
|
|
53
|
+
* Validate and narrow an unknown value into a {@link PartialSettings}. Unknown
|
|
54
|
+
* keys and ill-typed values are dropped rather than throwing — a corrupt
|
|
55
|
+
* settings file degrades to defaults instead of crashing the CLI. This is the
|
|
56
|
+
* total-function equivalent of a schema parse for the persisted layer.
|
|
57
|
+
*/
|
|
58
|
+
export declare function parsePartialSettings(value: unknown): PartialSettings;
|
|
59
|
+
/**
|
|
60
|
+
* Parse a partial settings object from the AP3X environment. Recognized vars
|
|
61
|
+
* (all `AP3X_*`): MODEL, PROVIDER, THINKING, MAX_LOOPS, TOOL_EXECUTION,
|
|
62
|
+
* ACTIVE_TOOLS (comma-separated), AUTO_COMPACT, CWD, SHELL_PATH,
|
|
63
|
+
* ENFORCE_BLOCKLIST, A2A_BEARER_TOKEN. (`remoteAgents` is a structured map —
|
|
64
|
+
* file/flag layers only.)
|
|
65
|
+
*/
|
|
66
|
+
export declare function settingsFromEnv(env?: NodeJS.ProcessEnv): PartialSettings;
|
|
67
|
+
/**
|
|
68
|
+
* Merge partial settings with the canonical precedence: **flag > env > file >
|
|
69
|
+
* default**. Later arguments to this helper are lower priority; the layers are
|
|
70
|
+
* applied default-first so higher-priority defined keys win.
|
|
71
|
+
*/
|
|
72
|
+
export declare function mergeSettings(layers: {
|
|
73
|
+
flag?: PartialSettings;
|
|
74
|
+
env?: PartialSettings;
|
|
75
|
+
file?: PartialSettings;
|
|
76
|
+
defaults?: Settings;
|
|
77
|
+
}): Settings;
|
|
78
|
+
/**
|
|
79
|
+
* Loads, merges, and persists AP3X settings under `~/.ap3x/` (or an override).
|
|
80
|
+
* The resolved configuration always reflects precedence flag > env > file >
|
|
81
|
+
* default; only the file layer is persisted.
|
|
82
|
+
*/
|
|
83
|
+
export declare class SettingsManager {
|
|
84
|
+
private readonly path;
|
|
85
|
+
private readonly env;
|
|
86
|
+
private fileSettings;
|
|
87
|
+
constructor(options?: {
|
|
88
|
+
configDir?: string;
|
|
89
|
+
path?: string;
|
|
90
|
+
env?: NodeJS.ProcessEnv;
|
|
91
|
+
});
|
|
92
|
+
/** The absolute path of the backing settings file. */
|
|
93
|
+
get filePath(): string;
|
|
94
|
+
/** Load the persisted (file) layer from disk. Missing/invalid files yield {}. */
|
|
95
|
+
load(): Promise<PartialSettings>;
|
|
96
|
+
/** The currently-known file layer (call {@link load} first to populate it). */
|
|
97
|
+
get persisted(): PartialSettings;
|
|
98
|
+
/** Resolve effective settings, layering flags + env over the loaded file layer. */
|
|
99
|
+
resolve(flagSettings?: PartialSettings): Settings;
|
|
100
|
+
/**
|
|
101
|
+
* Persist a partial settings patch to the file layer, merging with existing.
|
|
102
|
+
*
|
|
103
|
+
* The write is atomic: the JSON is written to a sibling `.tmp` file and then
|
|
104
|
+
* renamed over the target, so a crash mid-write can never leave a truncated
|
|
105
|
+
* or corrupt `settings.json` — readers see either the old file or the new one.
|
|
106
|
+
*/
|
|
107
|
+
save(patch: PartialSettings): Promise<PartialSettings>;
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"settings.d.ts","sourceRoot":"","sources":["../src/settings.ts"],"names":[],"mappings":"AAIA,mEAAmE;AACnE,MAAM,WAAW,iBAAiB;IAChC,wEAAwE;IACxE,GAAG,EAAE,MAAM,CAAC;IACZ,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,sCAAsC;IACtC,QAAQ,EAAE,KAAK,GAAG,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IAClE,2CAA2C;IAC3C,QAAQ,EAAE,MAAM,CAAC;IACjB,+BAA+B;IAC/B,aAAa,EAAE,YAAY,GAAG,UAAU,CAAC;IACzC;;;;;OAKG;IACH,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,0EAA0E;IAC1E,WAAW,EAAE,OAAO,CAAC;IACrB,oEAAoE;IACpE,GAAG,EAAE,MAAM,CAAC;IACZ,wDAAwD;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,gEAAgE;IAChE,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iFAAiF;IACjF,Y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AAC,YAAY,GAAE,eAAoB,GAAG,QAAQ;IASrD;;;;;;OAMG;IACG,IAAI,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;CAc7D"}
|
package/dist/skills.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI skills discovery + system-prompt composition.
|
|
3
|
+
*
|
|
4
|
+
* The coding agent advertises skills via progressive disclosure: a compact
|
|
5
|
+
* `<available_skills>` catalog (name / description / location) goes into the
|
|
6
|
+
* system prompt, and the model loads a skill's full body with the read tool on
|
|
7
|
+
* demand. Skills live as top-level `*.md` files under `<configDir>/skills`
|
|
8
|
+
* (see `resolveSkillsDir`); parsing/catalog formatting come from agent-core.
|
|
9
|
+
*
|
|
10
|
+
* ponytail: top-level *.md listing only — the full discovery machinery
|
|
11
|
+
* (recursive traversal, ignore files, collision diagnostics) is a later slice.
|
|
12
|
+
*/
|
|
13
|
+
import { type Skill } from "@ap3x/agent-core";
|
|
14
|
+
/**
|
|
15
|
+
* Load every top-level `*.md` skill file in `dir` (sorted by file name for a
|
|
16
|
+
* deterministic catalog). A missing or unreadable directory yields `[]` — a
|
|
17
|
+
* host without a skills dir simply has no skills.
|
|
18
|
+
*/
|
|
19
|
+
export declare function loadSkillsFromDir(dir: string): Promise<Skill[]>;
|
|
20
|
+
/**
|
|
21
|
+
* Compose the final system prompt: the base coding prompt plus the skills
|
|
22
|
+
* catalog in the S1 `skills` slot. When the catalog is empty (no skills, or
|
|
23
|
+
* every skill hidden via `disableModelInvocation`) the base prompt is returned
|
|
24
|
+
* UNCHANGED — byte-identical to running without the skills subsystem.
|
|
25
|
+
*/
|
|
26
|
+
export declare function composeSystemPromptWithSkills(basePrompt: string, skills: readonly Skill[]): string;
|
|
27
|
+
//# sourceMappingURL=skills.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.d.ts","sourceRoot":"","sources":["../src/skills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAKH,OAAO,EAEL,KAAK,KAAK,EAIX,MAAM,kBAAkB,CAAC;AAE1B;;;;GAIG;AACH,wBAAsB,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC,CAYrE;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,SAAS,KAAK,EAAE,GACvB,MAAM,CAOR"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { AuthStorage } from "@ap3x/ai";
|
|
2
|
+
import type { AnthropicLoginResult, LoginAnthropicOptions } from "./auth/anthropic-login";
|
|
3
|
+
import type { LoginResult, LoginWithChatGPTOptions } from "./auth/codex-login";
|
|
4
|
+
import type { CopilotLoginResult, LoginGitHubCopilotOptions } from "./auth/copilot-login";
|
|
5
|
+
import type { AgentSessionRuntime } from "./sdk";
|
|
6
|
+
import type { Settings, SettingsManager } from "./settings";
|
|
7
|
+
/**
|
|
8
|
+
* Slash commands are TABLE-DRIVEN (§10 #52): a flat array of
|
|
9
|
+
* `{ name, description, handler }` records, looked up by name — never an
|
|
10
|
+
* if-ladder. There are deliberately NO easter-egg commands; any joke/vanity
|
|
11
|
+
* The set is a curated allowlist — see {@link SLASH_COMMANDS}. Handlers operate
|
|
12
|
+
* on an injected {@link SlashContext} so they test against a mock runtime + IO
|
|
13
|
+
* with no real terminal or network.
|
|
14
|
+
*/
|
|
15
|
+
/** The IO + state surface a slash handler may touch. All side-effects go here. */
|
|
16
|
+
export interface SlashContext {
|
|
17
|
+
/** The live agent runtime (session, backend, model). */
|
|
18
|
+
runtime: AgentSessionRuntime;
|
|
19
|
+
/** Settings manager for `/settings`, `/model`, `/reload`. */
|
|
20
|
+
settings: SettingsManager;
|
|
21
|
+
/** The resolved settings snapshot at dispatch time. */
|
|
22
|
+
resolved: Settings;
|
|
23
|
+
/** Write a line of output (renderer-injected; no direct stdout). */
|
|
24
|
+
print: (text: string) => void;
|
|
25
|
+
/** Auth storage seam for `/login` `/logout` (inject in-memory for tests). */
|
|
26
|
+
auth?: AuthStorage;
|
|
27
|
+
/**
|
|
28
|
+
* The ChatGPT OAuth login function, injectable so `/login` is testable without
|
|
29
|
+
* real browser / network / server IO. Defaults to {@link loginWithChatGPT}.
|
|
30
|
+
*/
|
|
31
|
+
loginCodex?: (options?: LoginWithChatGPTOptions) => Promise<LoginResult>;
|
|
32
|
+
/**
|
|
33
|
+
* The Anthropic (Claude Pro/Max) OAuth login function, injectable so `/login`
|
|
34
|
+
* on the anthropic provider is testable without real IO. Defaults to
|
|
35
|
+
* {@link loginAnthropic}.
|
|
36
|
+
*/
|
|
37
|
+
loginAnthropic?: (options?: LoginAnthropicOptions) => Promise<AnthropicLoginResult>;
|
|
38
|
+
/**
|
|
39
|
+
* The GitHub Copilot device-code login function, injectable so `/login` on
|
|
40
|
+
* the github-copilot provider is testable without real IO. Defaults to
|
|
41
|
+
* {@link loginGitHubCopilot}.
|
|
42
|
+
*/
|
|
43
|
+
loginCopilot?: (options?: LoginGitHubCopilotOptions) => Promise<CopilotLoginResult>;
|
|
44
|
+
/** A signal the mode loop reads to know it should exit (`/quit`). */
|
|
45
|
+
requestExit?: () => void;
|
|
46
|
+
/** Free-form argument string following the command name. */
|
|
47
|
+
args: string;
|
|
48
|
+
}
|
|
49
|
+
/** The result of dispatching a slash command. */
|
|
50
|
+
export interface SlashResult {
|
|
51
|
+
/** True when a command matched and ran (false ⇒ unknown command). */
|
|
52
|
+
handled: boolean;
|
|
53
|
+
/** True when the loop should terminate after this command (`/quit`). */
|
|
54
|
+
exit?: boolean;
|
|
55
|
+
/** A short status line a caller may surface; also printed via ctx.print. */
|
|
56
|
+
message?: string;
|
|
57
|
+
}
|
|
58
|
+
/** One row of the slash-command table. */
|
|
59
|
+
export interface SlashCommand {
|
|
60
|
+
name: string;
|
|
61
|
+
description: string;
|
|
62
|
+
handler: (ctx: SlashContext) => Promise<SlashResult> | SlashResult;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The canonical built-in slash-command table. Adding a command is a single new
|
|
66
|
+
* record; dispatch ({@link dispatchSlashCommand}) is a table lookup.
|
|
67
|
+
*/
|
|
68
|
+
export declare const BUILTIN_SLASH_COMMANDS: readonly SlashCommand[];
|
|
69
|
+
/** Look up a command by bare name (no leading slash). */
|
|
70
|
+
export declare function findSlashCommand(name: string): SlashCommand | undefined;
|
|
71
|
+
/** True when a line is a slash command (starts with a single `/`). */
|
|
72
|
+
export declare function isSlashCommand(line: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Parse and dispatch a slash-command line (e.g. `"/model claude-sonnet-4-5"`).
|
|
75
|
+
* Unknown commands return `{ handled: false }` and print a clean error — they
|
|
76
|
+
* never throw. The leading slash is required.
|
|
77
|
+
*/
|
|
78
|
+
export declare function dispatchSlashCommand(line: string, ctx: Omit<SlashContext, "args">): Promise<SlashResult>;
|
|
79
|
+
//# sourceMappingURL=slash-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slash-commands.d.ts","sourceRoot":"","sources":["../src/slash-commands.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,WAAW,EAAa,MAAM,UAAU,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC1F,OAAO,KAAK,EAAE,WAAW,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,KAAK,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAE1F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE5D;;;;;;;GAOG;AAEH,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,wDAAwD;IACxD,OAAO,EAAE,mBA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tE,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,WAAW,CAAC,CAatB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The runtime environment context fed to the coding agent's system prompt. This
|
|
3
|
+
* is what makes the agent OS-aware — without it the model defaults to POSIX
|
|
4
|
+
* commands (e.g. `google-chrome`, `open`, `xdg-open`) and runs them blindly on
|
|
5
|
+
* whatever platform it is actually on.
|
|
6
|
+
*/
|
|
7
|
+
export interface EnvContext {
|
|
8
|
+
platform: NodeJS.Platform;
|
|
9
|
+
shell: string;
|
|
10
|
+
shellKind: "bash" | "cmd" | "sh";
|
|
11
|
+
cwd: string;
|
|
12
|
+
date: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Build the coding-agent system prompt, embedding the live runtime environment
|
|
16
|
+
* so the model issues platform-correct commands and reports outcomes honestly.
|
|
17
|
+
*/
|
|
18
|
+
export declare function buildCodingAgentSystemPrompt(env: EnvContext): string;
|
|
19
|
+
/** Resolve the live {@link EnvContext} for the current process. */
|
|
20
|
+
export declare function resolveEnvContext(shellPath?: string): Promise<EnvContext>;
|
|
21
|
+
//# sourceMappingURL=system-prompt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../src/system-prompt.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC;IACjC,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;CACd;AAuCD;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAoBpE;AAED,mEAAmE;AACnE,wBAAsB,iBAAiB,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAS/E"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type AnyAgentTool } from "@ap3x/agent-core";
|
|
2
|
+
import type { ToolContext } from "./context";
|
|
3
|
+
/**
|
|
4
|
+
* `call_agent` — send a task to a remote A2A agent and return its final text.
|
|
5
|
+
* The remote is a whole primary agent (possibly an orchestrator), reached via
|
|
6
|
+
* transport negotiation (JSON-RPC preferred, then REST, then gRPC).
|
|
7
|
+
*/
|
|
8
|
+
export declare function createCallAgentTool(ctx: ToolContext): AnyAgentTool;
|
|
9
|
+
/** The A2A tool set (currently just `call_agent`). */
|
|
10
|
+
export declare function createA2aTools(ctx: ToolContext): AnyAgentTool[];
|
|
11
|
+
//# sourceMappingURL=a2a.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"a2a.d.ts","sourceRoot":"","sources":["../../src/tools/a2a.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,KAAK,YAAY,EAAc,MAAM,kBAAkB,CAAC;AAGjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAwB7C;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,WAAW,GAAG,YAAY,CA4ClE;AAED,sDAAsD;AACtD,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,YAAY,EAAE,CAE/D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bash.d.ts","sourceRoot":"","sources":["../../src/tools/bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAuC,MAAM,kBAAkB,CAAC;AAE1F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAuB7C,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,YAAY,CA+C7D"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type ExecutionEnv } from "@ap3x/agent-core";
|
|
2
|
+
import type { Model } from "@ap3x/ai";
|
|
3
|
+
import type { RemoteAgentConfig } from "../settings";
|
|
4
|
+
/**
|
|
5
|
+
* The swarm backend a session exposes to the orchestration tools: the resolved
|
|
6
|
+
* session model plus the resolved provider auth. Every orchestrated sub-agent is
|
|
7
|
+
* built on THIS model + auth, so a spun-up swarm runs on the same credentials
|
|
8
|
+
* (e.g. an OAuth subscription token) the CLI itself is using.
|
|
9
|
+
*/
|
|
10
|
+
export interface SwarmBackend {
|
|
11
|
+
/** The session's resolved model — every sub-agent is backed by it. */
|
|
12
|
+
model: Model<string>;
|
|
13
|
+
/** Resolved provider API key / bearer (forwarded to each sub-agent). */
|
|
14
|
+
apiKey?: string;
|
|
15
|
+
/** Resolved provider headers (e.g. an account-id header). */
|
|
16
|
+
headers?: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Ambient services a built-in tool needs to run: a filesystem + shell
|
|
20
|
+
* {@link ExecutionEnv}, plus an optional {@link SwarmBackend} for the
|
|
21
|
+
* orchestration tools. Factored out so tests can inject an in-memory or
|
|
22
|
+
* blocklist-disabled environment (and a faux-model swarm backend) without
|
|
23
|
+
* touching the real disk/shell or making network calls.
|
|
24
|
+
*/
|
|
25
|
+
export interface ToolContext {
|
|
26
|
+
env: ExecutionEnv;
|
|
27
|
+
/** Present when the session can orchestrate swarms (has a model + auth). */
|
|
28
|
+
swarm?: SwarmBackend;
|
|
29
|
+
/** Named remote A2A peers the `call_agent` tool may contact (settings allowlist). */
|
|
30
|
+
remoteAgents?: Record<string, RemoteAgentConfig>;
|
|
31
|
+
}
|
|
32
|
+
/** Build a default {@link ToolContext} backed by the real Node environment. */
|
|
33
|
+
export declare function createToolContext(options?: {
|
|
34
|
+
cwd?: string;
|
|
35
|
+
shellPath?: string;
|
|
36
|
+
enforceBlocklist?: boolean;
|
|
37
|
+
/** Opt-in: confine `write`/`edit`/append to the workspace root (default off). */
|
|
38
|
+
restrictWritesToWorkspace?: boolean;
|
|
39
|
+
swarm?: SwarmBackend;
|
|
40
|
+
remoteAgents?: Record<string, RemoteAgentConfig>;
|
|
41
|
+
}): ToolContext;
|
|
42
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/tools/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAoB,MAAM,kBAAkB,CAAC;AACvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD;;;;;GAKG;AACH,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,YAAY,CAAC;IAClB,4EAA4E;IAC5E,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAClD;AAED,+EAA+E;AAC/E,wBAAgB,iBAAiB,CAAC,OAAO,CAAC,EAAE;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,iFAAiF;IACjF,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC,KAAK,CAAC,EAAE,YAAY,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAClD,GAAG,WAAW,CAWd"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type AnyAgentTool } from "@ap3x/agent-core";
|
|
2
|
+
import type { ToolContext } from "./context";
|
|
3
|
+
/**
|
|
4
|
+
* `edit` — exact string replacement within a file. `oldText` must occur exactly
|
|
5
|
+
* once unless `replaceAll` is set. Pass `edits` to apply several replacements
|
|
6
|
+
* atomically (in order, against one read, one write — all succeed or none are
|
|
7
|
+
* written). This is a mutating tool: serialize it with
|
|
8
|
+
* {@link withFileMutationQueue}.
|
|
9
|
+
*
|
|
10
|
+
* Matching is line-ending agnostic: a leading BOM and CRLF/CR line endings are
|
|
11
|
+
* normalized to LF for matching and restored on write, so an LF `oldText`
|
|
12
|
+
* matches a Windows CRLF (or BOM-prefixed) file. Replacements are spliced
|
|
13
|
+
* literally — `$&`, `$1`, `$$` etc. in `newText` are inserted verbatim.
|
|
14
|
+
*/
|
|
15
|
+
export declare function createEditTool(ctx: ToolContext): AnyAgentTool;
|
|
16
|
+
//# sourceMappingURL=edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"edit.d.ts","sourceRoot":"","sources":["../../src/tools/edit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAc,MAAM,kBAAkB,CAAC;AAEjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAoC7C;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,YAAY,CA4G7D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AnyAgentTool } from "@ap3x/agent-core";
|
|
2
|
+
import type { ToolContext } from "./context";
|
|
3
|
+
/**
|
|
4
|
+
* `find` — locate files by glob pattern beneath a root directory. Traversal
|
|
5
|
+
* skips VCS/build dirs and is bounded. Matching uses a small in-house glob
|
|
6
|
+
* matcher (no external deps).
|
|
7
|
+
*/
|
|
8
|
+
export declare function createFindTool(ctx: ToolContext): AnyAgentTool;
|
|
9
|
+
//# sourceMappingURL=find.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find.d.ts","sourceRoot":"","sources":["../../src/tools/find.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAc,MAAM,kBAAkB,CAAC;AAGjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,YAAY,CA2C7D"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type AnyAgentTool } from "@ap3x/agent-core";
|
|
2
|
+
import type { ToolContext } from "./context";
|
|
3
|
+
/**
|
|
4
|
+
* `grep` — search file contents for a regular expression beneath a directory.
|
|
5
|
+
* Implemented in-process (no shelling out) so it is deterministic and testable.
|
|
6
|
+
* Returns `path:lineNumber:matchedLine` rows.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createGrepTool(ctx: ToolContext): AnyAgentTool;
|
|
9
|
+
//# sourceMappingURL=grep.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grep.d.ts","sourceRoot":"","sources":["../../src/tools/grep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAc,MAAM,kBAAkB,CAAC;AAGjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,YAAY,CAwE7D"}
|