@agentchatme/agent-core 0.3.1 → 0.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/README.md +34 -26
- package/dist/chunk-HOY2FERJ.js +26 -0
- package/dist/chunk-HOY2FERJ.js.map +1 -0
- package/dist/chunk-NCSF3CCV.js +139 -0
- package/dist/chunk-NCSF3CCV.js.map +1 -0
- package/dist/chunk-TH6XOVA3.js +283 -0
- package/dist/chunk-TH6XOVA3.js.map +1 -0
- package/dist/{chunk-4YF2K5ND.js → chunk-W3LYBKIV.js} +391 -888
- package/dist/chunk-W3LYBKIV.js.map +1 -0
- package/dist/daemon-entry.d.ts +127 -282
- package/dist/daemon-entry.js +308 -951
- package/dist/daemon-entry.js.map +1 -1
- package/dist/index.d.ts +63 -14
- package/dist/index.js +98 -137
- package/dist/index.js.map +1 -1
- package/dist/presets.d.ts +262 -0
- package/dist/presets.js +538 -0
- package/dist/presets.js.map +1 -0
- package/dist/runner-BzgsiS3V.d.ts +122 -0
- package/dist/served-manual-DZmEak4_.d.ts +368 -0
- package/package.json +8 -3
- package/dist/chunk-4YF2K5ND.js.map +0 -1
- package/dist/prompts-BUfpwUT7.d.ts +0 -630
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { TextsRuntime } from 'agentchatme';
|
|
2
|
+
import { a as RunProfile, b as RunRunner, f as RunPreflight, g as RunRequest, c as RunOutcome } from './runner-BzgsiS3V.js';
|
|
3
|
+
|
|
4
|
+
/** What a preset needs to build a runner acting as one agent. */
|
|
5
|
+
interface PresetContext {
|
|
6
|
+
/** The identity home of the agent the runs act as. Runs' file tools are kept off it where the runtime allows. */
|
|
7
|
+
readonly home: string;
|
|
8
|
+
/** The run's working directory. */
|
|
9
|
+
readonly workdir: string;
|
|
10
|
+
readonly profile: RunProfile;
|
|
11
|
+
/** The agent's key and API base, for the hosted tool server the runs reach. Never put on argv. */
|
|
12
|
+
readonly apiKey: string;
|
|
13
|
+
readonly apiBase: string;
|
|
14
|
+
/** The environment runs inherit (defaults to `process.env`). */
|
|
15
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
16
|
+
/** Test seam: the runtime's binary. */
|
|
17
|
+
readonly command?: string;
|
|
18
|
+
}
|
|
19
|
+
interface PresetInspection {
|
|
20
|
+
readonly ok: boolean;
|
|
21
|
+
readonly detail: string;
|
|
22
|
+
}
|
|
23
|
+
interface Preset {
|
|
24
|
+
/** The name a user types (`--preset <name>`). */
|
|
25
|
+
readonly name: string;
|
|
26
|
+
/** Human name for output. */
|
|
27
|
+
readonly label: string;
|
|
28
|
+
/** How the served texts spell the hosted tools for this runtime (`GET /v1/texts?runtime=`). */
|
|
29
|
+
readonly runtime: TextsRuntime;
|
|
30
|
+
/** Is the runtime installed, new enough and signed in? For `doctor` and `status`. */
|
|
31
|
+
inspect(env?: NodeJS.ProcessEnv, command?: string): PresetInspection;
|
|
32
|
+
/**
|
|
33
|
+
* A runner whose runs act as the agent in `ctx`: the hosted tool server is
|
|
34
|
+
* given to each run with that agent's key (a file or an environment
|
|
35
|
+
* variable, never an argument), whatever the runtime's own configuration
|
|
36
|
+
* registers. May write owner-only files into `ctx.home`.
|
|
37
|
+
*/
|
|
38
|
+
runner(ctx: PresetContext): RunRunner;
|
|
39
|
+
/**
|
|
40
|
+
* The hosted-tool configuration a listener's run of this preset sees, as
|
|
41
|
+
* lines for `doctor` (keys never printed): what the run is given, and what
|
|
42
|
+
* of the user's own configuration still applies.
|
|
43
|
+
*/
|
|
44
|
+
describeMcp(ctx: {
|
|
45
|
+
readonly home: string;
|
|
46
|
+
readonly apiBase: string;
|
|
47
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
48
|
+
}): string[];
|
|
49
|
+
/** Variables a service must capture for this runtime (where it keeps its config, when relocated). */
|
|
50
|
+
readonly serviceEnv: readonly string[];
|
|
51
|
+
/** Whether the run can read files under the identity home (decides how the manual is pointed to). */
|
|
52
|
+
readonly readsIdentityHome: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** `actual` (any text containing `x.y.z`) is at least `minimum`. False when either has no version in it. */
|
|
56
|
+
declare function semverAtLeast(actual: string, minimum: string): boolean;
|
|
57
|
+
|
|
58
|
+
declare const CLAUDE_CODE_PRESET = "claude-code";
|
|
59
|
+
/**
|
|
60
|
+
* Two flags set the floor:
|
|
61
|
+
* * `--permission-prompts none` — Claude Code v2.1.259.
|
|
62
|
+
* * `CLAUDE_CODE_MCP_STARTUP_WAIT_MS` — bounds how long the first
|
|
63
|
+
* non-interactive turn waits for the MCP servers `--allowedTools` names to
|
|
64
|
+
* connect. Added in v2.1.274. Without it a run could start before the
|
|
65
|
+
* hosted inbox tool is there.
|
|
66
|
+
*/
|
|
67
|
+
declare const MIN_CLAUDE_CODE_VERSION = "2.1.274";
|
|
68
|
+
/** The MCP server name the runs see; every hosted tool is `mcp__agentchat__<tool>`, as the served texts spell them. */
|
|
69
|
+
declare const CLAUDE_MCP_SERVER_NAME = "agentchat";
|
|
70
|
+
declare const AGENTCHAT_TOOL_ALLOW = "mcp__agentchat__*";
|
|
71
|
+
/** Built-in tools an `answer` run keeps: read-only files plus the web. */
|
|
72
|
+
declare const ANSWER_TOOLS: readonly ["Read", "Glob", "Grep", "WebSearch", "WebFetch"];
|
|
73
|
+
/** Built-in tools a `work` run additionally pre-approves. */
|
|
74
|
+
declare const WORK_TOOLS: readonly ["Bash", "Edit", "Write", "MultiEdit", "NotebookEdit"];
|
|
75
|
+
/** Env a parent Claude Code session leaks that would make the child think it is nested. */
|
|
76
|
+
declare const PARENT_ENV_KEYS: string[];
|
|
77
|
+
/** Claude Code's supported relocation knob. Unset is NOT the same as `~/.claude`. */
|
|
78
|
+
declare function claudeConfigDirFrom(env?: NodeJS.ProcessEnv): string | undefined;
|
|
79
|
+
/** `~/.claude`, or the relocated config dir. */
|
|
80
|
+
declare function claudeHomeFor(configDirOverride: string | undefined): string;
|
|
81
|
+
/**
|
|
82
|
+
* Where Claude Code keeps user-scoped MCP servers (and so any key registered
|
|
83
|
+
* there): `~/.claude.json`, or `$CLAUDE_CONFIG_DIR/.claude.json`.
|
|
84
|
+
*/
|
|
85
|
+
declare function claudeUserStatePathFor(configDirOverride: string | undefined): string;
|
|
86
|
+
declare function buildClaudeEnv(configDirOverride: string | undefined, source?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
87
|
+
/**
|
|
88
|
+
* Is Claude Code signed in? `claude auth status` prints JSON with a boolean
|
|
89
|
+
* `loggedIn` and exits 0 if logged in, 1 if not. When that JSON is there it is
|
|
90
|
+
* the answer. The file/keychain probes are a fallback for builds without the
|
|
91
|
+
* subcommand; the keychain probe is existence-only and never prompts — a
|
|
92
|
+
* resident listener must never trigger a keychain prompt.
|
|
93
|
+
*/
|
|
94
|
+
declare function claudeIsLoggedIn(configDirOverride?: string, command?: string): boolean;
|
|
95
|
+
declare function inspectClaudeRuntime(configDirOverride?: string, command?: string): PresetInspection;
|
|
96
|
+
/**
|
|
97
|
+
* The entry of `denied` that is `dir` or contains it, or null. Whole path
|
|
98
|
+
* segments only: `~/.claude/agentchat` does not contain `~/.claude/agentchat-workdir`.
|
|
99
|
+
*/
|
|
100
|
+
declare function deniedAncestorOf(dir: string, denied: readonly string[]): string | null;
|
|
101
|
+
declare function claudeProfileArgs(profile: RunProfile): string[];
|
|
102
|
+
interface ClaudeRunArgOptions {
|
|
103
|
+
/** `AGENTCHAT_RUN_MAX_BUDGET_USD`: stop the run once estimated spend reaches this (print mode only). */
|
|
104
|
+
readonly maxBudgetUsd?: string | undefined;
|
|
105
|
+
/**
|
|
106
|
+
* Absolute paths the run's file tools may not read (a directory covers its
|
|
107
|
+
* tree). Rendered as `Read(//<path>)` / `Read(//<dir>/**)` deny rules. A
|
|
108
|
+
* prompt-injected run could otherwise read the key and send it; the wake
|
|
109
|
+
* text should not be the only guard. POSIX paths only — on Windows the
|
|
110
|
+
* rule syntax for drive paths is undocumented, so nothing is rendered.
|
|
111
|
+
*/
|
|
112
|
+
readonly denyReadPaths?: readonly string[] | undefined;
|
|
113
|
+
/**
|
|
114
|
+
* A `--mcp-config` file holding the hosted server with the agent's key;
|
|
115
|
+
* with it, `--strict-mcp-config` makes it the run's only MCP server. Absent:
|
|
116
|
+
* the run uses the user-scope server the integration registered.
|
|
117
|
+
*/
|
|
118
|
+
readonly mcpConfigPath?: string | undefined;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* The deny paths no rule can carry: on Windows all of them (the rule syntax
|
|
122
|
+
* for drive paths is undocumented), elsewhere a relative path or one with a
|
|
123
|
+
* comma or whitespace. A run would be able to read these.
|
|
124
|
+
*/
|
|
125
|
+
declare function inexpressibleDenyPaths(paths: readonly string[]): string[];
|
|
126
|
+
/** `/Users/x/.claude/agentchat` → `Read(//Users/x/.claude/agentchat/**)` and `Read(//Users/x/.claude/agentchat)`. Paths no rule can carry are left out (`inexpressibleDenyPaths`). */
|
|
127
|
+
declare function readDenyRules(paths: readonly string[]): string[];
|
|
128
|
+
/**
|
|
129
|
+
* The full argument list for one headless run. The prompt goes on STDIN, not
|
|
130
|
+
* as a positional: the variadic `--allowedTools` (and `--mcp-config`) would
|
|
131
|
+
* otherwise swallow a trailing positional (verified on 2.1.220; `cat file |
|
|
132
|
+
* claude -p` is the documented piped form).
|
|
133
|
+
*/
|
|
134
|
+
declare function claudeRunArgs(profile: RunProfile, options?: ClaudeRunArgOptions): string[];
|
|
135
|
+
/** The `--mcp-config` document: the hosted server, by HTTP, with the agent's key. Owner-only on disk. */
|
|
136
|
+
declare function claudeMcpConfig(apiBase: string, apiKey: string): string;
|
|
137
|
+
interface ClaudeRunnerOptions {
|
|
138
|
+
readonly configDir: string | undefined;
|
|
139
|
+
/**
|
|
140
|
+
* The run's working directory; the `work` profile edits and runs shell here.
|
|
141
|
+
* Must lie outside `denyReadPaths`, or the run cannot read its own cwd —
|
|
142
|
+
* preflight says so once and still runs.
|
|
143
|
+
*/
|
|
144
|
+
readonly workdir: string;
|
|
145
|
+
readonly profile: RunProfile;
|
|
146
|
+
/** Paths every run's file tools are denied: the key store (identity home, the user-scope MCP state). */
|
|
147
|
+
readonly denyReadPaths: readonly string[];
|
|
148
|
+
/** See `ClaudeRunArgOptions.mcpConfigPath`. */
|
|
149
|
+
readonly mcpConfigPath?: string;
|
|
150
|
+
/** The one-line fix printed when the workdir sits inside a denied path. */
|
|
151
|
+
readonly workdirAdvice?: string;
|
|
152
|
+
/**
|
|
153
|
+
* A deny path no rule can carry (a comma or whitespace in it; every path on
|
|
154
|
+
* Windows): `warn` (default) logs it once and runs — the run can then read
|
|
155
|
+
* that path; `refuse` fails preflight with the reason, so no run starts.
|
|
156
|
+
*/
|
|
157
|
+
readonly inexpressibleDeny?: 'warn' | 'refuse';
|
|
158
|
+
/** Test seam: the binary to run. */
|
|
159
|
+
readonly command?: string;
|
|
160
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
161
|
+
}
|
|
162
|
+
declare class ClaudeRunner implements RunRunner {
|
|
163
|
+
private readonly options;
|
|
164
|
+
readonly name = "claude";
|
|
165
|
+
private readonly command;
|
|
166
|
+
/** The workdir warning is one line per process, not one per preflight (preflight repeats every few minutes). */
|
|
167
|
+
private warnedWorkdir;
|
|
168
|
+
private warnedDeny;
|
|
169
|
+
constructor(options: ClaudeRunnerOptions);
|
|
170
|
+
/** The denied path the configured workdir sits in, or null when the run can read its own cwd. */
|
|
171
|
+
workdirDeniedBy(): string | null;
|
|
172
|
+
preflight(): Promise<RunPreflight>;
|
|
173
|
+
/** The exact argv one run uses — exported for tests to pin per profile. */
|
|
174
|
+
args(): string[];
|
|
175
|
+
start(request: RunRequest): Promise<RunOutcome>;
|
|
176
|
+
}
|
|
177
|
+
/** Where a listener keeps the `--mcp-config` file for this preset, inside its identity home. */
|
|
178
|
+
declare function claudeMcpConfigPath(home: string): string;
|
|
179
|
+
declare const claudeCodePreset: Preset;
|
|
180
|
+
|
|
181
|
+
declare const CODEX_PRESET = "codex";
|
|
182
|
+
/** `--ephemeral`, `--sandbox`, `-C`, `--json` all exist on this version; older builds were not checked. */
|
|
183
|
+
declare const MIN_CODEX_VERSION = "0.154.0";
|
|
184
|
+
/** The `[mcp_servers.<name>]` table the runs use; tools are `mcp__agentchat__<tool>`, as the served texts spell them. */
|
|
185
|
+
declare const CODEX_MCP_SERVER_NAME = "agentchat";
|
|
186
|
+
/**
|
|
187
|
+
* The variable a listener's runs read the bearer token from. Deliberately not
|
|
188
|
+
* `AGENTCHAT_API_KEY`: Codex loads `$CODEX_HOME/.env` at startup, where an
|
|
189
|
+
* installed integration keeps ITS agent's key under that name.
|
|
190
|
+
*/
|
|
191
|
+
declare const LISTENER_KEY_ENV = "AGENTCHAT_LISTENER_API_KEY";
|
|
192
|
+
/**
|
|
193
|
+
* The final positional argument: `-` tells `codex exec` to read its
|
|
194
|
+
* instructions from stdin ("If not provided as an argument (or if `-` is
|
|
195
|
+
* used), instructions are read from stdin").
|
|
196
|
+
*/
|
|
197
|
+
declare const CODEX_PROMPT_FROM_STDIN = "-";
|
|
198
|
+
/** Codex's config root. Honouring CODEX_HOME matters: users relocate it. */
|
|
199
|
+
declare function codexHomeFrom(env?: NodeJS.ProcessEnv): string;
|
|
200
|
+
declare function inspectCodexRuntime(codexHome: string, command?: string): PresetInspection;
|
|
201
|
+
/** `codex login status` exits 0 when signed in. */
|
|
202
|
+
declare function codexIsLoggedIn(codexHome: string, command?: string): PresetInspection;
|
|
203
|
+
declare function codexProfileArgs(profile: RunProfile): string[];
|
|
204
|
+
/** Where a run's hosted tool server points, and which variable carries its bearer token. */
|
|
205
|
+
interface CodexMcpOverride {
|
|
206
|
+
readonly url: string;
|
|
207
|
+
readonly keyEnv: string;
|
|
208
|
+
}
|
|
209
|
+
/** The `-c` overrides that make `[mcp_servers.agentchat]` this agent's, for one run. TOML values, no key in them. */
|
|
210
|
+
declare function codexMcpOverrideArgs(override: CodexMcpOverride): string[];
|
|
211
|
+
/**
|
|
212
|
+
* The full argument list for one headless run. The prompt is NOT an argument:
|
|
213
|
+
* the runner writes it to stdin and closes it. An argument cannot carry it on
|
|
214
|
+
* Windows — npm installs codex as a `.cmd` shim, cross-spawn runs that through
|
|
215
|
+
* cmd.exe, and cmd.exe ends the command at the first line break, so every line
|
|
216
|
+
* after the first was silently dropped (caught by CI on windows-latest).
|
|
217
|
+
*/
|
|
218
|
+
declare function codexRunArgs(profile: RunProfile, options: {
|
|
219
|
+
workdir: string;
|
|
220
|
+
mcp?: CodexMcpOverride;
|
|
221
|
+
}): string[];
|
|
222
|
+
interface CodexRunnerOptions {
|
|
223
|
+
readonly codexHome: string;
|
|
224
|
+
/** The run's working root (`-C`); the `work` profile may write here. */
|
|
225
|
+
readonly workdir: string;
|
|
226
|
+
readonly profile: RunProfile;
|
|
227
|
+
/** The agent's key, read per run (a credential change between runs is followed). Null: none is set. */
|
|
228
|
+
readonly apiKey: () => string | null;
|
|
229
|
+
/** The variable the key is set under in the run's environment. */
|
|
230
|
+
readonly keyEnv: string;
|
|
231
|
+
/** Point the hosted server at this agent for each run (`-c` overrides); absent, config.toml decides. */
|
|
232
|
+
readonly mcp?: CodexMcpOverride;
|
|
233
|
+
/** Test seam: the binary to run. */
|
|
234
|
+
readonly command?: string;
|
|
235
|
+
readonly env?: NodeJS.ProcessEnv;
|
|
236
|
+
}
|
|
237
|
+
declare class CodexRunner implements RunRunner {
|
|
238
|
+
private readonly options;
|
|
239
|
+
readonly name = "codex";
|
|
240
|
+
private readonly command;
|
|
241
|
+
constructor(options: CodexRunnerOptions);
|
|
242
|
+
preflight(): Promise<RunPreflight>;
|
|
243
|
+
/** The exact argv one run uses — exported for tests to pin per profile. */
|
|
244
|
+
args(): string[];
|
|
245
|
+
/** The child environment: Codex's home and the key the hosted server needs, under the configured name. */
|
|
246
|
+
env(): NodeJS.ProcessEnv;
|
|
247
|
+
start(request: RunRequest): Promise<RunOutcome>;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The keys of `[mcp_servers.agentchat]` in a config.toml, or null when the
|
|
251
|
+
* table is absent. Keys only — a value can be a secret. A line scan, not a
|
|
252
|
+
* TOML parser: enough to say what a run's `-c` overrides merge over.
|
|
253
|
+
*/
|
|
254
|
+
declare function agentchatTableKeys(configToml: string): string[] | null;
|
|
255
|
+
declare const codexPreset: Preset;
|
|
256
|
+
|
|
257
|
+
/** Every preset, by the name a user types. */
|
|
258
|
+
declare const PRESETS: Readonly<Record<string, Preset>>;
|
|
259
|
+
declare function presetNamed(name: string): Preset | null;
|
|
260
|
+
declare function presetNames(): string[];
|
|
261
|
+
|
|
262
|
+
export { AGENTCHAT_TOOL_ALLOW, ANSWER_TOOLS, CLAUDE_CODE_PRESET, CLAUDE_MCP_SERVER_NAME, CODEX_MCP_SERVER_NAME, CODEX_PRESET, CODEX_PROMPT_FROM_STDIN, type ClaudeRunArgOptions, ClaudeRunner, type ClaudeRunnerOptions, type CodexMcpOverride, CodexRunner, type CodexRunnerOptions, LISTENER_KEY_ENV, MIN_CLAUDE_CODE_VERSION, MIN_CODEX_VERSION, PARENT_ENV_KEYS, PRESETS, type Preset, type PresetContext, type PresetInspection, WORK_TOOLS, agentchatTableKeys, buildClaudeEnv, claudeCodePreset, claudeConfigDirFrom, claudeHomeFor, claudeIsLoggedIn, claudeMcpConfig, claudeMcpConfigPath, claudeProfileArgs, claudeRunArgs, claudeUserStatePathFor, codexHomeFrom, codexIsLoggedIn, codexMcpOverrideArgs, codexPreset, codexProfileArgs, codexRunArgs, deniedAncestorOf, inexpressibleDenyPaths, inspectClaudeRuntime, inspectCodexRuntime, presetNamed, presetNames, readDenyRules, semverAtLeast };
|