@ahpd/agent-claude 0.3.0 → 0.5.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 +6 -0
- package/dist/claude.d.ts +6 -8
- package/dist/claude.d.ts.map +1 -1
- package/dist/claude.js +93 -17
- package/dist/claude.js.map +1 -1
- package/dist/kinds.d.ts +29 -0
- package/dist/kinds.d.ts.map +1 -0
- package/dist/kinds.js +42 -0
- package/dist/kinds.js.map +1 -0
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +198 -9
- package/dist/session.js.map +1 -1
- package/dist/transcript.d.ts.map +1 -1
- package/dist/transcript.js +5 -0
- package/dist/transcript.js.map +1 -1
- package/package.json +2 -2
- package/src/claude.ts +94 -27
- package/src/kinds.ts +46 -0
- package/src/session.ts +191 -11
- package/src/transcript.ts +5 -0
package/README.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @ahpd/agent-claude
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@ahpd/agent-claude)
|
|
4
|
+
[](https://github.com/softov/ahpd/actions/workflows/ci.yml)
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+
|
|
3
9
|
The Claude backend for [`@ahpd/sdk`](https://www.npmjs.com/package/@ahpd/sdk).
|
|
4
10
|
|
|
5
11
|
## Install
|
package/dist/claude.d.ts
CHANGED
|
@@ -9,15 +9,13 @@ import type { Agent } from '@ahpd/sdk';
|
|
|
9
9
|
/** How to build the Claude backend. */
|
|
10
10
|
export interface ClaudeOptions {
|
|
11
11
|
/**
|
|
12
|
-
* The directories it
|
|
12
|
+
* The directories it lists, and where a session goes by default.
|
|
13
13
|
*
|
|
14
|
-
* The
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* This is also the catalogue's scope, so a directory left out is one whose
|
|
20
|
-
* sessions are neither listed nor openable.
|
|
14
|
+
* The catalogue's scope: past sessions in these directories are listed and
|
|
15
|
+
* openable, and ones elsewhere are not. The first is also where a new
|
|
16
|
+
* session goes when the client names no directory. A client that names one
|
|
17
|
+
* gets it, wherever on the machine it is - the connection token decided who
|
|
18
|
+
* may be here, the way it does on the reference host.
|
|
21
19
|
*/
|
|
22
20
|
paths: string[];
|
|
23
21
|
/** The id clients name. `claude` unless something else already is. */
|
package/dist/claude.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../src/claude.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"claude.d.ts","sourceRoot":"","sources":["../src/claude.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAc,MAAM,WAAW,CAAC;AAYnD;;;;;;GAMG;AAEH,uCAAuC;AACvC,MAAM,WAAW,aAAa;IAC5B;;;;;;;;OAQG;IACH,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,kFAAkF;AAClF,wBAAgB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,KAAK,CAsXpD"}
|
package/dist/claude.js
CHANGED
|
@@ -3,7 +3,9 @@ import { serversFor } from './mcp.js';
|
|
|
3
3
|
import { createSession, EFFORT_LABELS, EFFORTS } from './session.js';
|
|
4
4
|
import { turnsOf } from './transcript.js';
|
|
5
5
|
import { catalogue } from './catalog.js';
|
|
6
|
-
import {
|
|
6
|
+
import { existsSync, readdirSync } from 'node:fs';
|
|
7
|
+
import { homedir } from 'node:os';
|
|
8
|
+
import { isAbsolute, join } from 'node:path';
|
|
7
9
|
/**
|
|
8
10
|
* The resource a token for this backend is for.
|
|
9
11
|
*
|
|
@@ -22,26 +24,15 @@ export function claude(options) {
|
|
|
22
24
|
/**
|
|
23
25
|
* Which directory a session goes in.
|
|
24
26
|
*
|
|
25
|
-
* Named, or the first.
|
|
26
|
-
*
|
|
27
|
-
*
|
|
27
|
+
* Named, or the first. An absolute path is taken as it was given, so the
|
|
28
|
+
* session runs where the client said; a relative one has no meaning on a
|
|
29
|
+
* host whose own directory the client cannot see, and is refused.
|
|
28
30
|
*/
|
|
29
31
|
const workingDirectory = (asked) => {
|
|
30
32
|
if (asked === undefined)
|
|
31
33
|
return dir;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*
|
|
35
|
-
* This compared for equality, so a host told to serve `/home/you` served
|
|
36
|
-
* that one directory and refused every project inside it - which is the
|
|
37
|
-
* only kind of directory anybody opens. An editor asks for its workspace
|
|
38
|
-
* folder, and that is never the path somebody passed to `--path`.
|
|
39
|
-
*/
|
|
40
|
-
if (!dirs.some((served) => within(served, asked))) {
|
|
41
|
-
throw new Error(`This host does not serve ${asked}. It serves ${dirs.join(', ')}.`);
|
|
42
|
-
}
|
|
43
|
-
// What was asked for, not the root it sits under: the session runs where
|
|
44
|
-
// the client said.
|
|
34
|
+
if (!isAbsolute(asked))
|
|
35
|
+
throw new Error(`A working directory is an absolute path, not ${asked}.`);
|
|
45
36
|
return asked;
|
|
46
37
|
};
|
|
47
38
|
/*
|
|
@@ -169,6 +160,50 @@ export function claude(options) {
|
|
|
169
160
|
default: 'adaptive',
|
|
170
161
|
sessionMutable: false,
|
|
171
162
|
},
|
|
163
|
+
/*
|
|
164
|
+
* The sandbox, on the reference host's three words.
|
|
165
|
+
*
|
|
166
|
+
* A platform key the reference client draws a control for on every
|
|
167
|
+
* backend that declares it. The CLI has a sandbox of its own for shell
|
|
168
|
+
* commands, `sandbox.enabled` in its settings, and that is what the
|
|
169
|
+
* three values reach: `on` and `off` set it, `default` leaves it to the
|
|
170
|
+
* settings files. Live, because the flag settings take it mid-session.
|
|
171
|
+
*/
|
|
172
|
+
sandboxEnabled: {
|
|
173
|
+
scope: 'session',
|
|
174
|
+
type: 'string',
|
|
175
|
+
title: 'Sandbox',
|
|
176
|
+
description: 'Sandbox behavior for this session. Default follows the global setting.',
|
|
177
|
+
enum: ['default', 'on', 'off'],
|
|
178
|
+
enumLabels: ['Default', 'On', 'Off'],
|
|
179
|
+
default: 'default',
|
|
180
|
+
sessionMutable: true,
|
|
181
|
+
},
|
|
182
|
+
/*
|
|
183
|
+
* Scripts a client generated, sourced before every shell command.
|
|
184
|
+
*
|
|
185
|
+
* The reference client sends this only where a schema declares it, and
|
|
186
|
+
* `readOnly` because nobody types one: it carries the shell profile and
|
|
187
|
+
* the Python environment the window has selected for the folder. No
|
|
188
|
+
* `default`, so absent stays tellable from an explicit empty list.
|
|
189
|
+
*/
|
|
190
|
+
shellInitScripts: {
|
|
191
|
+
scope: 'session',
|
|
192
|
+
type: 'array',
|
|
193
|
+
title: 'Shell Init Script',
|
|
194
|
+
description: 'A script sourced before each built-in shell tool command.',
|
|
195
|
+
items: {
|
|
196
|
+
type: 'object',
|
|
197
|
+
title: 'Shell Init Script',
|
|
198
|
+
properties: {
|
|
199
|
+
shell: { type: 'string', title: 'Shell', enum: ['bash', 'powershell'] },
|
|
200
|
+
script: { type: 'string', title: 'Script' },
|
|
201
|
+
},
|
|
202
|
+
required: ['shell', 'script'],
|
|
203
|
+
},
|
|
204
|
+
readOnly: true,
|
|
205
|
+
sessionMutable: true,
|
|
206
|
+
},
|
|
172
207
|
/*
|
|
173
208
|
* Per-tool allow and deny, which is the slope the mode above is a cliff.
|
|
174
209
|
*
|
|
@@ -208,6 +243,7 @@ export function claude(options) {
|
|
|
208
243
|
// a control a client cannot show and cannot change.
|
|
209
244
|
...(perModelEffort ? {} : { effortLevel: 'high' }),
|
|
210
245
|
thinking: 'adaptive',
|
|
246
|
+
sandboxEnabled: 'default',
|
|
211
247
|
permissions: { allow: [], deny: [] },
|
|
212
248
|
...(style !== undefined ? { outputStyle: style } : {}),
|
|
213
249
|
});
|
|
@@ -238,6 +274,45 @@ export function claude(options) {
|
|
|
238
274
|
// catalogue of the directory it ran in, and a host serving several has
|
|
239
275
|
// one catalogue.
|
|
240
276
|
list: async () => (await Promise.all(dirs.map((served) => catalogue(served)))).flat(),
|
|
277
|
+
/*
|
|
278
|
+
* The transcript on disk, which is the CLI's own record of a session.
|
|
279
|
+
*
|
|
280
|
+
* `~/.claude/projects/<directory>/<id>.jsonl`, with the directory spelled
|
|
281
|
+
* the way the CLI spells it - every character that is not a letter or a
|
|
282
|
+
* digit made a dash - and `CLAUDE_CONFIG_DIR` in place of `~/.claude`
|
|
283
|
+
* where it is set. A session resumed elsewhere may have been written
|
|
284
|
+
* under the directory it started in, so the other projects are looked
|
|
285
|
+
* through before answering that there is none.
|
|
286
|
+
*/
|
|
287
|
+
stateFile: (id, directory) => {
|
|
288
|
+
if (!/^[A-Za-z0-9-]+$/.test(id))
|
|
289
|
+
return undefined;
|
|
290
|
+
const projects = join(process.env.CLAUDE_CONFIG_DIR ?? join(homedir(), '.claude'), 'projects');
|
|
291
|
+
const own = join(projects, directory.replace(/[^A-Za-z0-9]/g, '-'), `${id}.jsonl`);
|
|
292
|
+
if (existsSync(own))
|
|
293
|
+
return own;
|
|
294
|
+
let names;
|
|
295
|
+
try {
|
|
296
|
+
names = readdirSync(projects);
|
|
297
|
+
}
|
|
298
|
+
catch {
|
|
299
|
+
return undefined;
|
|
300
|
+
}
|
|
301
|
+
for (const name of names) {
|
|
302
|
+
const file = join(projects, name, `${id}.jsonl`);
|
|
303
|
+
if (existsSync(file))
|
|
304
|
+
return file;
|
|
305
|
+
}
|
|
306
|
+
return undefined;
|
|
307
|
+
},
|
|
308
|
+
// What to probe when the network is in question: the API, which answers
|
|
309
|
+
// an unauthenticated request with 401 - reached, and refusing - and the
|
|
310
|
+
// base URL the CLI would use where one is set.
|
|
311
|
+
endpoints: () => [{
|
|
312
|
+
name: 'Anthropic API',
|
|
313
|
+
url: `${(process.env.ANTHROPIC_BASE_URL ?? 'https://api.anthropic.com').replace(/\/$/, '')}/v1/models`,
|
|
314
|
+
expectedStatus: 401,
|
|
315
|
+
}],
|
|
241
316
|
// Whichever directory holds it. The transcript reader wants the one the
|
|
242
317
|
// session ran in, and only its own catalogue knows which that was.
|
|
243
318
|
transcript: async (id) => {
|
|
@@ -283,6 +358,7 @@ export function claude(options) {
|
|
|
283
358
|
: {}),
|
|
284
359
|
// The host's own tools, offered to the model beside this backend's.
|
|
285
360
|
...(start.tools && start.tools.length > 0 ? { tools: start.tools } : {}),
|
|
361
|
+
...(start.instructions && start.instructions.length > 0 ? { instructions: start.instructions } : {}),
|
|
286
362
|
settings: start.settings,
|
|
287
363
|
schema: start.schema,
|
|
288
364
|
emit: start.emit,
|
package/dist/claude.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../src/claude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"claude.js","sourceRoot":"","sources":["../src/claude.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AACtC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,IAA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C,WAAW,CAAC,SAAS,CAAC,EAAE,EAAE;gBAC9D,CAAC,CAAC,EAAE,CAAC;SACR,CAAC;KACH,CAAC;AACJ,CAAC"}
|
package/dist/kinds.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What kind of thing a tool call is, said where the reference client reads it.
|
|
3
|
+
*
|
|
4
|
+
* `_meta.toolKind` is not protocol. It is the one well-known key VS Code's
|
|
5
|
+
* agent window routes a tool call by: `terminal` goes to the command-and-output
|
|
6
|
+
* renderer, `subagent` to the subagent view, `search` and `read` to theirs, and
|
|
7
|
+
* a call with none is drawn as a generic tool - a name and a box. The reference
|
|
8
|
+
* host stamps it in its own adapters, and derives it for a "remote host" from
|
|
9
|
+
* a Copilot-internal permission payload this backend does not have; so it is
|
|
10
|
+
* stamped here, from the harness's own tool names, which are the one thing
|
|
11
|
+
* about a tool call this backend can be sure of.
|
|
12
|
+
*
|
|
13
|
+
* Names only. Nothing else about the call decides the kind, and a tool this
|
|
14
|
+
* table has not heard of is left unstamped rather than guessed at - the
|
|
15
|
+
* generic renderer is right for a tool nobody here knows.
|
|
16
|
+
*/
|
|
17
|
+
export type ToolKind = 'terminal' | 'read' | 'search' | 'subagent';
|
|
18
|
+
/** The kind of a tool by its harness name, or nothing for one the table lacks. */
|
|
19
|
+
export declare const toolKindOf: (name: string) => ToolKind | undefined;
|
|
20
|
+
/**
|
|
21
|
+
* The `_meta` a tool call carries from the moment it is announced.
|
|
22
|
+
*
|
|
23
|
+
* The reducer replaces a call's whole `_meta` whenever an action carries one,
|
|
24
|
+
* so anything added later - a progress line while it runs - has to be spread
|
|
25
|
+
* over this rather than sent alone. Absent for a tool with no kind, so a call
|
|
26
|
+
* that has nothing to say carries no empty bag.
|
|
27
|
+
*/
|
|
28
|
+
export declare const toolMetaOf: (name: string) => Record<string, unknown> | undefined;
|
|
29
|
+
//# sourceMappingURL=kinds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kinds.d.ts","sourceRoot":"","sources":["../src/kinds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,MAAM,MAAM,QAAQ,GAAG,UAAU,GAAG,MAAM,GAAG,QAAQ,GAAG,UAAU,CAAC;AAcnE,kFAAkF;AAClF,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,QAAQ,GAAG,SAAwB,CAAC;AAE9E;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,MAAM,MAAM,KAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAGnE,CAAC"}
|
package/dist/kinds.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What kind of thing a tool call is, said where the reference client reads it.
|
|
3
|
+
*
|
|
4
|
+
* `_meta.toolKind` is not protocol. It is the one well-known key VS Code's
|
|
5
|
+
* agent window routes a tool call by: `terminal` goes to the command-and-output
|
|
6
|
+
* renderer, `subagent` to the subagent view, `search` and `read` to theirs, and
|
|
7
|
+
* a call with none is drawn as a generic tool - a name and a box. The reference
|
|
8
|
+
* host stamps it in its own adapters, and derives it for a "remote host" from
|
|
9
|
+
* a Copilot-internal permission payload this backend does not have; so it is
|
|
10
|
+
* stamped here, from the harness's own tool names, which are the one thing
|
|
11
|
+
* about a tool call this backend can be sure of.
|
|
12
|
+
*
|
|
13
|
+
* Names only. Nothing else about the call decides the kind, and a tool this
|
|
14
|
+
* table has not heard of is left unstamped rather than guessed at - the
|
|
15
|
+
* generic renderer is right for a tool nobody here knows.
|
|
16
|
+
*/
|
|
17
|
+
const KINDS = {
|
|
18
|
+
Bash: 'terminal',
|
|
19
|
+
terminal: 'terminal',
|
|
20
|
+
Read: 'read',
|
|
21
|
+
Glob: 'search',
|
|
22
|
+
Grep: 'search',
|
|
23
|
+
WebSearch: 'search',
|
|
24
|
+
WebFetch: 'search',
|
|
25
|
+
Task: 'subagent',
|
|
26
|
+
Agent: 'subagent',
|
|
27
|
+
};
|
|
28
|
+
/** The kind of a tool by its harness name, or nothing for one the table lacks. */
|
|
29
|
+
export const toolKindOf = (name) => KINDS[name];
|
|
30
|
+
/**
|
|
31
|
+
* The `_meta` a tool call carries from the moment it is announced.
|
|
32
|
+
*
|
|
33
|
+
* The reducer replaces a call's whole `_meta` whenever an action carries one,
|
|
34
|
+
* so anything added later - a progress line while it runs - has to be spread
|
|
35
|
+
* over this rather than sent alone. Absent for a tool with no kind, so a call
|
|
36
|
+
* that has nothing to say carries no empty bag.
|
|
37
|
+
*/
|
|
38
|
+
export const toolMetaOf = (name) => {
|
|
39
|
+
const toolKind = toolKindOf(name);
|
|
40
|
+
return toolKind === undefined ? undefined : { toolKind };
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=kinds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kinds.js","sourceRoot":"","sources":["../src/kinds.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,MAAM,KAAK,GAAuC;IAChD,IAAI,EAAE,UAAU;IAChB,QAAQ,EAAE,UAAU;IACpB,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,QAAQ;IACd,SAAS,EAAE,QAAQ;IACnB,QAAQ,EAAE,QAAQ;IAClB,IAAI,EAAE,UAAU;IAChB,KAAK,EAAE,UAAU;CAClB,CAAC;AAEF,kFAAkF;AAClF,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAwB,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAE9E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,IAAY,EAAuC,EAAE;IAC9E,MAAM,QAAQ,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;IAClC,OAAO,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC;AAC3D,CAAC,CAAC"}
|
package/dist/session.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../src/session.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAKnF,OAAO,KAAK,EAAE,GAAG,EAA0C,OAAO,EAAE,cAAc,EAAY,MAAM,WAAW,CAAC;AAEhH;;;;;;;GAOG;AACH,eAAO,MAAM,OAAO,oDAAqD,CAAC;AAE1E,oFAAoF;AACpF,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,OAAO,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAEhE,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,GAAG,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC;AA2GnD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,MAAM,GAAE,OAAO,EAAO,EAAE,MAAM,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,GAAG,EAAE,CA4L1H;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAYpF;AAiGD,wBAAgB,aAAa,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,CA2xE9D"}
|