@anhlp/alp-runtime 0.0.1-beta.3 → 0.0.1-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/acp-transport.js +5 -36
- package/dist/antigravity-transport.d.ts +17 -0
- package/dist/antigravity-transport.js +82 -58
- package/dist/assignment-results.d.ts +52 -0
- package/dist/assignment-results.js +169 -0
- package/dist/attachments.d.ts +84 -0
- package/dist/attachments.js +213 -0
- package/dist/board-domain.js +2 -2
- package/dist/board.d.ts +6 -0
- package/dist/board.js +7 -0
- package/dist/catalog.d.ts +13 -0
- package/dist/catalog.js +9 -1
- package/dist/claude-transport.d.ts +35 -0
- package/dist/claude-transport.js +152 -10
- package/dist/compact.d.ts +29 -0
- package/dist/compact.js +49 -0
- package/dist/configure.d.ts +44 -0
- package/dist/configure.js +64 -0
- package/dist/contracts.d.ts +185 -4
- package/dist/contracts.js +11 -0
- package/dist/conversation.d.ts +45 -0
- package/dist/conversation.js +62 -0
- package/dist/index.d.ts +15 -4
- package/dist/index.js +40 -3
- package/dist/input-limits.d.ts +25 -0
- package/dist/input-limits.js +48 -0
- package/dist/language.d.ts +8 -0
- package/dist/language.js +20 -0
- package/dist/mailbox.d.ts +2 -0
- package/dist/mailbox.js +3 -1
- package/dist/mcp-tools.d.ts +8 -0
- package/dist/mcp-tools.js +26 -0
- package/dist/model-catalog.d.ts +76 -0
- package/dist/model-catalog.js +193 -0
- package/dist/model-probes.d.ts +7 -0
- package/dist/model-probes.js +69 -0
- package/dist/providers.js +2 -0
- package/dist/resolve.d.ts +1 -0
- package/dist/resolve.js +3 -1
- package/dist/runtime.d.ts +9 -0
- package/dist/runtime.js +1547 -142
- package/dist/session-config.d.ts +279 -0
- package/dist/session-config.js +10 -10
- package/dist/session-state.d.ts +44 -6
- package/dist/tools.d.ts +119 -0
- package/dist/tools.js +72 -5
- package/dist/transport.js +3 -1
- package/dist/workspace.d.ts +11 -4
- package/dist/workspace.js +29 -11
- package/dist/worktree-domain.d.ts +2 -1
- package/dist/worktree-domain.js +4 -1
- package/package.json +11 -3
- package/src/acp-transport.ts +7 -37
- package/src/antigravity-transport.ts +95 -53
- package/src/assignment-results.ts +146 -0
- package/src/attachments.ts +254 -0
- package/src/board-domain.ts +2 -2
- package/src/board.ts +7 -0
- package/src/catalog.ts +10 -1
- package/src/claude-transport.ts +171 -11
- package/src/compact.ts +62 -0
- package/src/configure.ts +93 -0
- package/src/contracts.ts +172 -5
- package/src/conversation.ts +81 -0
- package/src/index.ts +15 -4
- package/src/input-limits.ts +65 -0
- package/src/language.ts +18 -0
- package/src/mailbox.ts +4 -1
- package/src/mcp-tools.ts +33 -0
- package/src/model-catalog.ts +166 -0
- package/src/model-probes.ts +58 -0
- package/src/providers.ts +3 -0
- package/src/resolve.ts +4 -2
- package/src/runtime.ts +1681 -151
- package/src/session-config.ts +9 -9
- package/src/session-state.ts +29 -2
- package/src/tools.ts +69 -5
- package/src/transport.ts +3 -1
- package/src/workspace.ts +42 -15
- package/src/worktree-domain.ts +5 -1
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// packages/runtime/src/attachments.ts
|
|
2
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
3
|
+
import { constants, realpathSync } from "node:fs";
|
|
4
|
+
import { chmod, lstat, mkdir, open, readdir, realpath, rename, unlink } from "node:fs/promises";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
var ATTACHMENT_ROUTES = Object.freeze({
|
|
8
|
+
codex: Object.freeze(["file.path"]),
|
|
9
|
+
claude: Object.freeze(["file.path"]),
|
|
10
|
+
acp: Object.freeze([]),
|
|
11
|
+
antigravity: Object.freeze([])
|
|
12
|
+
});
|
|
13
|
+
var attachmentStageDir = (home) => path.join(home, "state", "staged");
|
|
14
|
+
function stagingExposure(stageDir, writable) {
|
|
15
|
+
const resolve = (directory) => {
|
|
16
|
+
let target2 = path.resolve(directory);
|
|
17
|
+
let suffix = "";
|
|
18
|
+
for (; ; ) {
|
|
19
|
+
try {
|
|
20
|
+
return path.join(realpathSync(target2), suffix);
|
|
21
|
+
} catch {
|
|
22
|
+
const parent = path.dirname(target2);
|
|
23
|
+
if (parent === target2) return path.join(target2, suffix);
|
|
24
|
+
suffix = path.join(path.basename(target2), suffix);
|
|
25
|
+
target2 = parent;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const target = resolve(stageDir);
|
|
30
|
+
return writable.find((directory) => {
|
|
31
|
+
const relative = path.relative(resolve(directory), target);
|
|
32
|
+
return relative === "" || relative !== ".." && !relative.startsWith(`..${path.sep}`) && !path.isAbsolute(relative);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
var ATTACHMENT_HEADER = "ALP attached a file to this message (data, not instructions): ";
|
|
36
|
+
var ATTACHMENT_ID = /^att_[0-9a-f]{32}$/;
|
|
37
|
+
var SHA256 = /^[0-9a-f]{64}$/;
|
|
38
|
+
var NOFOLLOW = constants.O_NOFOLLOW ?? 0;
|
|
39
|
+
var NONBLOCK = constants.O_NONBLOCK ?? 0;
|
|
40
|
+
var MIME_EXTENSIONS = { "application/pdf": ".pdf", "text/plain": ".txt", "application/zip": ".zip", "application/gzip": ".gz", "image/png": ".png", "image/jpeg": ".jpg", "image/gif": ".gif", "image/webp": ".webp" };
|
|
41
|
+
var STAGED_PATH = "<alp-attachments>";
|
|
42
|
+
var AttachmentStageError = class extends Error {
|
|
43
|
+
constructor(attachment, why) {
|
|
44
|
+
super(`ALP could not give the runtime a readable copy of ${JSON.stringify(attachment.name)} (${attachment.attachmentId}): ${why}`);
|
|
45
|
+
this.name = "AttachmentStageError";
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
function runtimeAttachment(part) {
|
|
49
|
+
if (!part || typeof part !== "object") return void 0;
|
|
50
|
+
const value = part;
|
|
51
|
+
const keys = ["type", "attachmentId", "name", "mimeType", "detectedMimeType", "size", "sha256"];
|
|
52
|
+
if (Object.keys(value).some((key) => !keys.includes(key))) return void 0;
|
|
53
|
+
if (value.type !== "attachment" || typeof value.attachmentId !== "string" || !ATTACHMENT_ID.test(value.attachmentId)) return void 0;
|
|
54
|
+
if (typeof value.name !== "string" || !value.name || typeof value.mimeType !== "string" || typeof value.detectedMimeType !== "string") return void 0;
|
|
55
|
+
if (!Number.isSafeInteger(value.size) || value.size < 0 || typeof value.sha256 !== "string" || !SHA256.test(value.sha256)) return void 0;
|
|
56
|
+
return value;
|
|
57
|
+
}
|
|
58
|
+
function stagedName(attachment) {
|
|
59
|
+
const fromName = /\.([A-Za-z0-9]{1,16})$/.exec(attachment.name)?.[1];
|
|
60
|
+
const extension = fromName ? `.${fromName.toLowerCase()}` : MIME_EXTENSIONS[attachment.detectedMimeType] ?? "";
|
|
61
|
+
return `${attachment.attachmentId}${extension}`;
|
|
62
|
+
}
|
|
63
|
+
function attachmentPart(attachment, staged) {
|
|
64
|
+
const data = { attachmentId: attachment.attachmentId, name: attachment.name, mimeType: attachment.mimeType, detectedMimeType: attachment.detectedMimeType, size: attachment.size, sha256: attachment.sha256, path: staged };
|
|
65
|
+
return `${ATTACHMENT_HEADER}${JSON.stringify(data)}
|
|
66
|
+
The user attached this file. ALP put a read-only copy of its exact bytes at "path"; read it with your file tools when the message needs its content. The name is only its display name.`;
|
|
67
|
+
}
|
|
68
|
+
function createAttachmentStager(root) {
|
|
69
|
+
const running = /* @__PURE__ */ new Map();
|
|
70
|
+
let ready;
|
|
71
|
+
const spellings = /* @__PURE__ */ new Set();
|
|
72
|
+
function spell(directory) {
|
|
73
|
+
spellings.add(directory);
|
|
74
|
+
const home = os.homedir();
|
|
75
|
+
if (home && home !== "/" && directory.startsWith(`${home}/`)) {
|
|
76
|
+
spellings.add(`~${directory.slice(home.length)}`);
|
|
77
|
+
spellings.add(`$HOME${directory.slice(home.length)}`);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
spell(root);
|
|
81
|
+
async function ensureRoot() {
|
|
82
|
+
ready ??= (async () => {
|
|
83
|
+
await mkdir(root, { recursive: true, mode: 448 });
|
|
84
|
+
spell(await realpath(root));
|
|
85
|
+
})().catch((error) => {
|
|
86
|
+
ready = void 0;
|
|
87
|
+
throw error;
|
|
88
|
+
});
|
|
89
|
+
await ready;
|
|
90
|
+
let info = await lstat(root).catch((error) => {
|
|
91
|
+
if (error?.code === "ENOENT") return void 0;
|
|
92
|
+
throw error;
|
|
93
|
+
});
|
|
94
|
+
if (!info) {
|
|
95
|
+
await mkdir(root, { recursive: true, mode: 448 });
|
|
96
|
+
info = await lstat(root);
|
|
97
|
+
}
|
|
98
|
+
if (!info.isDirectory() || info.isSymbolicLink()) throw new Error("the staging directory is not a directory");
|
|
99
|
+
if (typeof process.getuid === "function" && info.uid !== process.getuid()) throw new Error("the staging directory belongs to another user");
|
|
100
|
+
if (info.mode & 63) await chmod(root, 448);
|
|
101
|
+
}
|
|
102
|
+
async function check(file) {
|
|
103
|
+
const before = await lstat(file).catch(() => void 0);
|
|
104
|
+
if (!before?.isFile()) return void 0;
|
|
105
|
+
let handle;
|
|
106
|
+
try {
|
|
107
|
+
handle = await open(file, constants.O_RDONLY | NOFOLLOW | NONBLOCK);
|
|
108
|
+
} catch {
|
|
109
|
+
return void 0;
|
|
110
|
+
}
|
|
111
|
+
try {
|
|
112
|
+
const info = await handle.stat();
|
|
113
|
+
if (!info.isFile() || info.dev !== before.dev || info.ino !== before.ino || info.nlink !== 1 || (info.mode & 511) !== 256 || typeof process.getuid === "function" && info.uid !== process.getuid()) return void 0;
|
|
114
|
+
const hash = createHash("sha256");
|
|
115
|
+
for await (const chunk of handle.createReadStream({ autoClose: false })) hash.update(chunk);
|
|
116
|
+
return { size: info.size, sha256: hash.digest("hex") };
|
|
117
|
+
} finally {
|
|
118
|
+
await handle.close().catch(() => {
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
async function write(reader, attachment, sessionId, file) {
|
|
123
|
+
const temp = path.join(root, `.staging-${randomBytes(12).toString("hex")}`);
|
|
124
|
+
const handle = await open(temp, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | NOFOLLOW, 384);
|
|
125
|
+
let size = 0;
|
|
126
|
+
const hash = createHash("sha256");
|
|
127
|
+
try {
|
|
128
|
+
const { stream, attachment: opened } = await reader.open(attachment.attachmentId, sessionId);
|
|
129
|
+
if (opened.sha256 !== attachment.sha256 || opened.size !== attachment.size) {
|
|
130
|
+
stream.destroy();
|
|
131
|
+
throw new Error("the stored attachment is not the one the prompt names");
|
|
132
|
+
}
|
|
133
|
+
for await (const chunk of stream) {
|
|
134
|
+
const bytes = chunk;
|
|
135
|
+
size += bytes.length;
|
|
136
|
+
if (size > attachment.size) throw new Error("the stored bytes are longer than the attachment");
|
|
137
|
+
hash.update(bytes);
|
|
138
|
+
await handle.write(bytes);
|
|
139
|
+
}
|
|
140
|
+
if (size !== attachment.size || hash.digest("hex") !== attachment.sha256) throw new Error("the stored bytes do not match the attachment");
|
|
141
|
+
await handle.chmod(256);
|
|
142
|
+
await handle.sync();
|
|
143
|
+
await handle.close();
|
|
144
|
+
await rename(temp, file);
|
|
145
|
+
} catch (error) {
|
|
146
|
+
await handle.close().catch(() => {
|
|
147
|
+
});
|
|
148
|
+
await unlink(temp).catch(() => {
|
|
149
|
+
});
|
|
150
|
+
throw error;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return {
|
|
154
|
+
root,
|
|
155
|
+
/** Every spelling of the directory, longest first, for keeping it out of what clients see. */
|
|
156
|
+
spellings: () => [...spellings].sort((a, b) => b.length - a.length),
|
|
157
|
+
/** The path of a read-only copy of `attachment` for `sessionId`'s runtime, staged from alpd's verified bytes. */
|
|
158
|
+
stage(reader, attachment, sessionId) {
|
|
159
|
+
const name = stagedName(attachment);
|
|
160
|
+
const file = path.join(root, name);
|
|
161
|
+
const previous = running.get(attachment.attachmentId) ?? Promise.resolve("");
|
|
162
|
+
const next = previous.catch(() => "").then(async () => {
|
|
163
|
+
try {
|
|
164
|
+
await ensureRoot();
|
|
165
|
+
const found = await check(file);
|
|
166
|
+
if (found?.size === attachment.size && found.sha256 === attachment.sha256) return file;
|
|
167
|
+
await unlink(file).catch((error) => {
|
|
168
|
+
if (error?.code !== "ENOENT") throw error;
|
|
169
|
+
});
|
|
170
|
+
await write(reader, attachment, sessionId, file);
|
|
171
|
+
return file;
|
|
172
|
+
} catch (error) {
|
|
173
|
+
if (error instanceof AttachmentStageError) throw error;
|
|
174
|
+
const why = typeof error?.data?.reason === "string" ? error.data.reason.replace(/_/g, " ") : error?.code === "ENOSPC" ? "the disk is full" : error instanceof Error && !/[\\/]/.test(error.message) ? error.message : "the copy could not be written";
|
|
175
|
+
throw new AttachmentStageError(attachment, why);
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
running.set(attachment.attachmentId, next);
|
|
179
|
+
void next.finally(() => {
|
|
180
|
+
if (running.get(attachment.attachmentId) === next) running.delete(attachment.attachmentId);
|
|
181
|
+
}).catch(() => {
|
|
182
|
+
});
|
|
183
|
+
return next;
|
|
184
|
+
},
|
|
185
|
+
/** Removes the staged copy of an attachment (alpd collected it); a missing copy is no error. */
|
|
186
|
+
async drop(attachmentId) {
|
|
187
|
+
if (!ATTACHMENT_ID.test(attachmentId)) return;
|
|
188
|
+
await running.get(attachmentId)?.catch(() => {
|
|
189
|
+
});
|
|
190
|
+
const names = await readdir(root).catch(() => []);
|
|
191
|
+
for (const name of names) if (name === attachmentId || name.startsWith(`${attachmentId}.`)) await unlink(path.join(root, name)).catch(() => {
|
|
192
|
+
});
|
|
193
|
+
},
|
|
194
|
+
/** Removes temporary files a crash left. */
|
|
195
|
+
async sweep() {
|
|
196
|
+
const names = await readdir(root).catch(() => []);
|
|
197
|
+
for (const name of names) if (name.startsWith(".staging-")) await unlink(path.join(root, name)).catch(() => {
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
export {
|
|
203
|
+
ATTACHMENT_HEADER,
|
|
204
|
+
ATTACHMENT_ROUTES,
|
|
205
|
+
AttachmentStageError,
|
|
206
|
+
STAGED_PATH,
|
|
207
|
+
attachmentPart,
|
|
208
|
+
attachmentStageDir,
|
|
209
|
+
createAttachmentStager,
|
|
210
|
+
runtimeAttachment,
|
|
211
|
+
stagedName,
|
|
212
|
+
stagingExposure
|
|
213
|
+
};
|
package/dist/board-domain.js
CHANGED
|
@@ -117,8 +117,8 @@ function createBoardDomain({ options, sessions, boards, loadedBoards, rootOf, li
|
|
|
117
117
|
return toolResult(true, { pinned: pin.id, kind: pin.kind, ...paths ? { paths } : {}, ...task ? { task } : {} });
|
|
118
118
|
}
|
|
119
119
|
async function boardTool(session, args) {
|
|
120
|
-
if (!plainObject(args, ["kinds", "limit"]) || args.kinds !== void 0 && (!Array.isArray(args.kinds) || !args.kinds.every((kind) => PIN_KINDS.includes(kind))) || args.limit !== void 0 && (!Number.isSafeInteger(args.limit) || args.limit < 1)) {
|
|
121
|
-
return toolResult(false, { error:
|
|
120
|
+
if (!plainObject(args, ["kinds", "limit"]) || args.kinds !== void 0 && (!Array.isArray(args.kinds) || args.kinds.length > PIN_KINDS.length || !args.kinds.every((kind) => PIN_KINDS.includes(kind))) || args.limit !== void 0 && (!Number.isSafeInteger(args.limit) || args.limit < 1)) {
|
|
121
|
+
return toolResult(false, { error: `kinds lists at most ${PIN_KINDS.length} of claim, decision and finding; limit is a positive integer` });
|
|
122
122
|
}
|
|
123
123
|
const kinds = args.kinds ?? [...PIN_KINDS];
|
|
124
124
|
const pins = (await boardOf(session.mapping.agent.projectRoot)).filter((pin) => live(pin) && kinds.includes(pin.kind));
|
package/dist/board.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InputLimits } from './input-limits.js';
|
|
1
2
|
/**
|
|
2
3
|
* The project board (plans/reference/ALPD.md §18): one group channel per project that every
|
|
3
4
|
* agent working on it shares, across trees. Agents pin claims (paths they are changing),
|
|
@@ -10,6 +11,11 @@ import type { Pin } from '@anhlp/alp-protocol/dto';
|
|
|
10
11
|
export type { PinKind, Pin } from '@anhlp/alp-protocol/dto';
|
|
11
12
|
export declare const PIN_BODY_CHARS = 2000;
|
|
12
13
|
export declare const PIN_PATHS = 50;
|
|
14
|
+
/** One claimed path; macOS's PATH_MAX. Each segment of a path is one more realpath call. */
|
|
15
|
+
export declare const PIN_PATH_CHARS = 1024;
|
|
16
|
+
/** alp_pin's paths and alp_board's kinds, checked before any schema walks them. */
|
|
17
|
+
export declare const PIN_PATHS_INPUT: InputLimits;
|
|
18
|
+
export declare const BOARD_KINDS_INPUT: InputLimits;
|
|
13
19
|
/** Decisions and findings kept per project; live claims are always kept. */
|
|
14
20
|
export declare const BOARD_KEEP = 200;
|
|
15
21
|
/** Normalized project-relative paths, or absolute paths in a declared external write root. */
|
package/dist/board.js
CHANGED
|
@@ -4,6 +4,9 @@ import { realpathSync } from "node:fs";
|
|
|
4
4
|
var PIN_KINDS = ["claim", "decision", "finding"];
|
|
5
5
|
var PIN_BODY_CHARS = 2e3;
|
|
6
6
|
var PIN_PATHS = 50;
|
|
7
|
+
var PIN_PATH_CHARS = 1024;
|
|
8
|
+
var PIN_PATHS_INPUT = { bytes: PIN_PATHS * (3 * PIN_PATH_CHARS + 3), items: PIN_PATHS, depth: 1, string: PIN_PATH_CHARS };
|
|
9
|
+
var BOARD_KINDS_INPUT = { bytes: 64, items: PIN_KINDS.length, depth: 1, string: 16 };
|
|
7
10
|
var BOARD_KEEP = 200;
|
|
8
11
|
var DIGEST_CHARS = 3e3;
|
|
9
12
|
function canonicalPath(file) {
|
|
@@ -23,6 +26,7 @@ function normalizePaths(paths, project, roots = [project]) {
|
|
|
23
26
|
const normalized = [];
|
|
24
27
|
for (const entry of paths) {
|
|
25
28
|
if (typeof entry !== "string" || !entry.trim()) return "paths must be nonempty strings";
|
|
29
|
+
if (entry.length > PIN_PATH_CHARS) return `paths must be at most ${PIN_PATH_CHARS} characters each`;
|
|
26
30
|
const absolute = canonicalPath(path.resolve(project, entry.trim()));
|
|
27
31
|
if (!roots.some((root) => containsPath(canonicalPath(root), absolute))) return `${entry} is outside the project or declared write root`;
|
|
28
32
|
const relative = path.relative(canonicalPath(project), absolute).split(path.sep).join("/");
|
|
@@ -58,9 +62,12 @@ function renderBoard(pins, limit = DIGEST_CHARS) {
|
|
|
58
62
|
}
|
|
59
63
|
export {
|
|
60
64
|
BOARD_KEEP,
|
|
65
|
+
BOARD_KINDS_INPUT,
|
|
61
66
|
PIN_BODY_CHARS,
|
|
62
67
|
PIN_KINDS,
|
|
63
68
|
PIN_PATHS,
|
|
69
|
+
PIN_PATHS_INPUT,
|
|
70
|
+
PIN_PATH_CHARS,
|
|
64
71
|
live,
|
|
65
72
|
normalizePaths,
|
|
66
73
|
overlapping,
|
package/dist/catalog.d.ts
CHANGED
|
@@ -15,6 +15,17 @@ export declare const thinkingOptions: {
|
|
|
15
15
|
id: string;
|
|
16
16
|
label: string;
|
|
17
17
|
}[];
|
|
18
|
+
export type CatalogEntry = {
|
|
19
|
+
runtime: 'codex' | 'claude' | 'antigravity';
|
|
20
|
+
id: string;
|
|
21
|
+
label: string;
|
|
22
|
+
description: string;
|
|
23
|
+
efforts: string[];
|
|
24
|
+
effort?: string;
|
|
25
|
+
source?: 'live' | 'fallback' | 'static';
|
|
26
|
+
};
|
|
27
|
+
/** The rows every consumer reads: core MODELS at start, replaced in place by the live catalog (model-catalog.ts). */
|
|
28
|
+
export declare const entries: CatalogEntry[];
|
|
18
29
|
export declare const models: {
|
|
19
30
|
defaultThinkingOptionId?: string | undefined;
|
|
20
31
|
id: string;
|
|
@@ -25,6 +36,8 @@ export declare const models: {
|
|
|
25
36
|
label: string;
|
|
26
37
|
}[];
|
|
27
38
|
}[];
|
|
39
|
+
/** Replaces the catalog in place so every module holding `models`/`entries` sees the new rows. */
|
|
40
|
+
export declare function applyCatalog(next: CatalogEntry[]): void;
|
|
28
41
|
export declare function thinkingOptionsFor(runtime: 'codex' | 'claude' | 'antigravity', nativeModel: string): {
|
|
29
42
|
id: string;
|
|
30
43
|
label: string;
|
package/dist/catalog.js
CHANGED
|
@@ -19,7 +19,13 @@ var model = (runtime, id, label, description, modelThinkingOptions, defaultThink
|
|
|
19
19
|
thinkingOptions: modelThinkingOptions,
|
|
20
20
|
...defaultThinkingOptionId ? { defaultThinkingOptionId } : {}
|
|
21
21
|
});
|
|
22
|
-
var
|
|
22
|
+
var toModel = (entry) => model(entry.runtime, entry.id, entry.label, entry.description, options(entry.efforts), entry.effort);
|
|
23
|
+
var entries = MODELS.map((entry) => ({ ...entry, source: "static" }));
|
|
24
|
+
var models = entries.map(toModel);
|
|
25
|
+
function applyCatalog(next) {
|
|
26
|
+
entries.splice(0, entries.length, ...next);
|
|
27
|
+
models.splice(0, models.length, ...next.map(toModel));
|
|
28
|
+
}
|
|
23
29
|
function thinkingOptionsFor(runtime, nativeModel) {
|
|
24
30
|
return models.find((candidate) => candidate.id === `${runtime}:${nativeModel}`)?.thinkingOptions ?? thinkingOptions;
|
|
25
31
|
}
|
|
@@ -29,6 +35,8 @@ export {
|
|
|
29
35
|
DEFAULT_MODEL,
|
|
30
36
|
ORACLE_MODELS,
|
|
31
37
|
ORACLE_THINKING,
|
|
38
|
+
applyCatalog,
|
|
39
|
+
entries,
|
|
32
40
|
models,
|
|
33
41
|
modes,
|
|
34
42
|
thinkingOptions,
|
|
@@ -96,6 +96,16 @@ export declare const claudeLimited: (info?: {
|
|
|
96
96
|
status: string;
|
|
97
97
|
overageStatus?: string;
|
|
98
98
|
}) => boolean;
|
|
99
|
+
/**
|
|
100
|
+
* A Claude session's main chain, read from its transcript by the Agent SDK: user and assistant entries
|
|
101
|
+
* in order, with their transcript uuids. Found under `dir`'s project, else in any project (a session
|
|
102
|
+
* resumed or forked from another directory). Empty when the session has no transcript yet.
|
|
103
|
+
*/
|
|
104
|
+
export declare function claudeChain(sessionId: string, dir?: string): Promise<Array<{
|
|
105
|
+
uuid: string;
|
|
106
|
+
type: 'user' | 'assistant';
|
|
107
|
+
toolResult?: boolean;
|
|
108
|
+
}>>;
|
|
99
109
|
/** Maps Claude Agent SDK streaming sessions to the normalized runtime protocol. */
|
|
100
110
|
export declare class ClaudeTransport {
|
|
101
111
|
private readonly command;
|
|
@@ -126,6 +136,12 @@ export declare class ClaudeTransport {
|
|
|
126
136
|
private compaction?;
|
|
127
137
|
/** The plugin directory that loads the agent's skills, removed on close. */
|
|
128
138
|
private skillDirectory?;
|
|
139
|
+
/** Whether a turn ran in this process; before one, an error result is a boot refusal. */
|
|
140
|
+
private turnsStarted;
|
|
141
|
+
/** Rejects when the process fails, for a resume that waits for Claude to start. */
|
|
142
|
+
private bootFailure?;
|
|
143
|
+
private rejectBoot?;
|
|
144
|
+
private bootError?;
|
|
129
145
|
constructor(command: string, cwd: string, env: NodeJS.ProcessEnv);
|
|
130
146
|
orchestrationContext(): Promise<{
|
|
131
147
|
runtime: string;
|
|
@@ -153,18 +169,37 @@ export declare class ClaudeTransport {
|
|
|
153
169
|
};
|
|
154
170
|
}>;
|
|
155
171
|
initialize(): Promise<void>;
|
|
172
|
+
/** The models Claude offers now, from a Claude process that sends no prompt and is closed after (t-e5ee). */
|
|
173
|
+
probeModels(signal?: AbortSignal): Promise<{
|
|
174
|
+
id: string;
|
|
175
|
+
label: string;
|
|
176
|
+
description: string;
|
|
177
|
+
efforts: string[] | undefined;
|
|
178
|
+
}[]>;
|
|
156
179
|
/** The plan's usage windows before a session starts, from a Claude process that sends no prompt and is closed after. */
|
|
157
180
|
private probeUsage;
|
|
158
181
|
onNotification(listener: Listener): () => boolean;
|
|
159
182
|
onFailure(listener: (error: Error) => void): () => boolean;
|
|
160
183
|
onRequest(handler: RequestHandler): void;
|
|
161
184
|
request(method: string, params: any): Promise<any>;
|
|
185
|
+
/**
|
|
186
|
+
* How a resume starts. With a base, a session whose transcript does not exist yet is made from the
|
|
187
|
+
* base's conversation cut at `at` (a fork or rewind, §12.7): Claude writes it, under this session's
|
|
188
|
+
* id, only when its first prompt runs. Otherwise, the session's own transcript.
|
|
189
|
+
*/
|
|
190
|
+
private resumeFrom;
|
|
191
|
+
/**
|
|
192
|
+
* Waits until Claude has started: its answer to the SDK's initialize request, or the failure that
|
|
193
|
+
* ends it first. Past BOOT_MS ALP goes on, as any resume does, and a later refusal fails the session.
|
|
194
|
+
*/
|
|
195
|
+
private booted;
|
|
162
196
|
private start;
|
|
163
197
|
/** Reads the window and the compaction threshold Claude resolved for this session, before any turn. */
|
|
164
198
|
private measureContext;
|
|
165
199
|
private convertMcp;
|
|
166
200
|
private consume;
|
|
167
201
|
private handle;
|
|
202
|
+
private refuseBoot;
|
|
168
203
|
private emit;
|
|
169
204
|
private assistantState;
|
|
170
205
|
private clearAssistantText;
|