@parcha/agentrun-serve 0.0.0-stage → 0.1.0-beta.29
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/CHANGELOG.md +560 -0
- package/LICENSE +202 -0
- package/NOTICE +5 -0
- package/README.md +1723 -2
- package/dist/adapters.d.ts +205 -0
- package/dist/adapters.js +459 -0
- package/dist/agents.d.ts +124 -0
- package/dist/agents.js +302 -0
- package/dist/app.d.ts +7 -0
- package/dist/app.js +324 -0
- package/dist/bound-files.d.ts +4 -0
- package/dist/bound-files.js +164 -0
- package/dist/box/record.d.ts +6 -0
- package/dist/box/record.js +41 -0
- package/dist/box/sweep.d.ts +53 -0
- package/dist/box/sweep.js +193 -0
- package/dist/box-image.d.ts +98 -0
- package/dist/box-image.js +283 -0
- package/dist/box-relay.d.ts +42 -0
- package/dist/box-relay.js +222 -0
- package/dist/boxes.d.ts +54 -0
- package/dist/boxes.js +182 -0
- package/dist/cap.d.ts +224 -0
- package/dist/cap.js +721 -0
- package/dist/catalog.d.ts +20 -0
- package/dist/catalog.js +53 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +167 -0
- package/dist/coding-tools.d.ts +31 -0
- package/dist/coding-tools.js +81 -0
- package/dist/console/THIRD-PARTY-NOTICES.txt +1141 -0
- package/dist/console/assets/index-BN7oVcO4.js +445 -0
- package/dist/console/assets/index-By-jkqki.css +1 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-BEIGL1Tu.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-400-normal-CIEtRijs.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-BB5xRk30.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-600-normal-EVf6-Yzo.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-BHyURHCj.woff +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-400-normal-C_uLvvQ5.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-Dj6eZy5f.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-cyrillic-ext-600-normal-DpeVePZf.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-400-normal-C190GLew.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-greek-400-normal-CNojz0t3.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-600-normal-3KAm9r92.woff +0 -0
- package/dist/console/assets/jetbrains-mono-greek-600-normal-H7WoG9Et.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-400-normal-B11XCQ5g.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-400-normal-V6pRDFza.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-600-normal-C8RAYTDA.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-600-normal-DXv3JcnD.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-Bc8Ftmh3.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-400-normal-DHMOLxAi.woff +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-BfB_LPfz.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-latin-ext-600-normal-DiQlUoE6.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-BeU3T8wf.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-400-normal-ByoDsISC.woff2 +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-CSpzN4cI.woff +0 -0
- package/dist/console/assets/jetbrains-mono-vietnamese-600-normal-Dtizs43-.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-400-normal-Cph9ettZ.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-400-normal-DfGZKnlb.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-600-normal-BGBUNdzT.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-600-normal-COje25QW.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-4l4lq8zr.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-400-normal-BGzXWJeR.woff +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-8_E36CQj.woff2 +0 -0
- package/dist/console/assets/schibsted-grotesk-latin-ext-600-normal-C27an7Zc.woff +0 -0
- package/dist/console/index.html +15 -0
- package/dist/daytona-api.d.ts +21 -0
- package/dist/daytona-api.js +101 -0
- package/dist/decision-rows.d.ts +11 -0
- package/dist/decision-rows.js +116 -0
- package/dist/decisions.d.ts +94 -0
- package/dist/decisions.js +184 -0
- package/dist/effort-guidance.d.ts +5 -0
- package/dist/effort-guidance.js +14 -0
- package/dist/environment.d.ts +5 -0
- package/dist/environment.js +11 -0
- package/dist/errors.d.ts +72 -0
- package/dist/errors.js +66 -0
- package/dist/exa-keyless.d.ts +35 -0
- package/dist/exa-keyless.js +202 -0
- package/dist/fetch-page.d.ts +114 -0
- package/dist/fetch-page.js +182 -0
- package/dist/files.d.ts +60 -0
- package/dist/files.js +153 -0
- package/dist/grade.d.ts +96 -0
- package/dist/grade.js +348 -0
- package/dist/graph-view.d.ts +100 -0
- package/dist/graph-view.js +212 -0
- package/dist/harness-app.d.ts +38 -0
- package/dist/harness-app.js +626 -0
- package/dist/harness.d.ts +53 -0
- package/dist/harness.js +74 -0
- package/dist/home-path.d.ts +27 -0
- package/dist/home-path.js +78 -0
- package/dist/host-tools.d.ts +20 -0
- package/dist/host-tools.js +140 -0
- package/dist/host.d.ts +39 -0
- package/dist/host.js +81 -0
- package/dist/hosted-search.d.ts +27 -0
- package/dist/hosted-search.js +129 -0
- package/dist/import-sources.d.ts +104 -0
- package/dist/import-sources.js +629 -0
- package/dist/import-summary.d.ts +25 -0
- package/dist/import-summary.js +75 -0
- package/dist/import-worker.d.ts +26 -0
- package/dist/import-worker.js +41 -0
- package/dist/import.d.ts +145 -0
- package/dist/import.js +1221 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +6 -0
- package/dist/key-check.d.ts +36 -0
- package/dist/key-check.js +108 -0
- package/dist/key-refusal.d.ts +51 -0
- package/dist/key-refusal.js +187 -0
- package/dist/learn/check.d.ts +99 -0
- package/dist/learn/check.js +259 -0
- package/dist/learn/grade.d.ts +79 -0
- package/dist/learn/grade.js +433 -0
- package/dist/learn/index.d.ts +7 -0
- package/dist/learn/index.js +11 -0
- package/dist/learn/invisible.d.ts +5 -0
- package/dist/learn/invisible.js +42 -0
- package/dist/learn/notes.d.ts +59 -0
- package/dist/learn/notes.js +146 -0
- package/dist/learn/reflect.d.ts +49 -0
- package/dist/learn/reflect.js +167 -0
- package/dist/learn/secrets.d.ts +18 -0
- package/dist/learn/secrets.js +111 -0
- package/dist/learn/skills.d.ts +84 -0
- package/dist/learn/skills.js +198 -0
- package/dist/learning-routes.d.ts +196 -0
- package/dist/learning-routes.js +609 -0
- package/dist/learning-run.d.ts +304 -0
- package/dist/learning-run.js +797 -0
- package/dist/learning-words.d.ts +73 -0
- package/dist/learning-words.js +171 -0
- package/dist/learning.d.ts +377 -0
- package/dist/learning.js +801 -0
- package/dist/llm.d.ts +40 -0
- package/dist/llm.js +37 -0
- package/dist/llms.txt +37 -0
- package/dist/mcp-servers.d.ts +115 -0
- package/dist/mcp-servers.js +445 -0
- package/dist/mcp.d.ts +51 -0
- package/dist/mcp.js +392 -0
- package/dist/model.d.ts +184 -0
- package/dist/model.js +484 -0
- package/dist/monid.d.ts +74 -0
- package/dist/monid.js +277 -0
- package/dist/openapi/agentrun-v2.openapi.json +4805 -0
- package/dist/openapi.d.ts +10 -0
- package/dist/openapi.js +1417 -0
- package/dist/owner.d.ts +55 -0
- package/dist/owner.js +222 -0
- package/dist/packs.d.ts +71 -0
- package/dist/packs.js +180 -0
- package/dist/page.d.ts +32 -0
- package/dist/page.js +133 -0
- package/dist/paid-calls.d.ts +46 -0
- package/dist/paid-calls.js +110 -0
- package/dist/pause.d.ts +68 -0
- package/dist/pause.js +97 -0
- package/dist/pdf-pages.d.ts +44 -0
- package/dist/pdf-pages.js +147 -0
- package/dist/place.d.ts +46 -0
- package/dist/place.js +105 -0
- package/dist/print.d.ts +20 -0
- package/dist/print.js +29 -0
- package/dist/propose.d.ts +38 -0
- package/dist/propose.js +82 -0
- package/dist/quiet-sqlite-warning.d.ts +1 -0
- package/dist/quiet-sqlite-warning.js +14 -0
- package/dist/request-start.d.ts +14 -0
- package/dist/request-start.js +226 -0
- package/dist/result.d.ts +3 -0
- package/dist/result.js +5 -0
- package/dist/rows.d.ts +46 -0
- package/dist/rows.js +121 -0
- package/dist/run-box.d.ts +134 -0
- package/dist/run-box.js +440 -0
- package/dist/run-manifest.d.ts +27 -0
- package/dist/run-manifest.js +60 -0
- package/dist/runnable.d.ts +80 -0
- package/dist/runnable.js +162 -0
- package/dist/runs.d.ts +840 -0
- package/dist/runs.js +2279 -0
- package/dist/secret-cut.d.ts +27 -0
- package/dist/secret-cut.js +109 -0
- package/dist/secrets.d.ts +50 -0
- package/dist/secrets.js +140 -0
- package/dist/server-lock.d.ts +44 -0
- package/dist/server-lock.js +140 -0
- package/dist/server.d.ts +626 -0
- package/dist/server.js +1756 -0
- package/dist/sessions.d.ts +4 -0
- package/dist/sessions.js +105 -0
- package/dist/skills.d.ts +31 -0
- package/dist/skills.js +68 -0
- package/dist/stats.d.ts +101 -0
- package/dist/stats.js +82 -0
- package/dist/tool-keys.d.ts +151 -0
- package/dist/tool-keys.js +273 -0
- package/dist/tool-plane.d.ts +143 -0
- package/dist/tool-plane.js +242 -0
- package/dist/tools.d.ts +147 -0
- package/dist/tools.js +253 -0
- package/dist/turn-end.d.ts +23 -0
- package/dist/turn-end.js +14 -0
- package/dist/turns.d.ts +34 -0
- package/dist/turns.js +202 -0
- package/dist/uploads.d.ts +104 -0
- package/dist/uploads.js +474 -0
- package/dist/usage.d.ts +29 -0
- package/dist/usage.js +58 -0
- package/dist/validate.d.ts +55 -0
- package/dist/validate.js +175 -0
- package/dist/web-fetch.d.ts +64 -0
- package/dist/web-fetch.js +262 -0
- package/dist/web-search.d.ts +54 -0
- package/dist/web-search.js +136 -0
- package/dist/webhooks.d.ts +182 -0
- package/dist/webhooks.js +487 -0
- package/dist/workspace-paths.d.ts +33 -0
- package/dist/workspace-paths.js +104 -0
- package/dist/workspace.d.ts +88 -0
- package/dist/workspace.js +369 -0
- package/launcher/agentrun-serve +109 -0
- package/package.json +94 -4
- package/skills/agentrun-serve/SKILL.md +128 -0
package/dist/sessions.js
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { ROOT_CONVERSATION_ID } from "@earendil-works/pi-durable";
|
|
2
|
+
import { SessionFenced } from "@parcha/agentrun-kernel";
|
|
3
|
+
import { FencedError } from "@parcha/pi-durable-disk";
|
|
4
|
+
const SESSION_KEY = "session.key";
|
|
5
|
+
const PAGE = 500;
|
|
6
|
+
export function durableSessions(harness, context) {
|
|
7
|
+
const holders = new Map();
|
|
8
|
+
const known = new Map();
|
|
9
|
+
// One creation per key at a time: two first opens at once share it, so a key names one conversation.
|
|
10
|
+
const creating = new Map();
|
|
11
|
+
const scan = async (id, each) => {
|
|
12
|
+
const conversation = await harness.conversation(id, context);
|
|
13
|
+
if (!conversation)
|
|
14
|
+
return;
|
|
15
|
+
for (let cursor;;) {
|
|
16
|
+
const page = await conversation.entries({ order: "ascending" }, PAGE, cursor, context);
|
|
17
|
+
for (const entry of page.items)
|
|
18
|
+
each(entry);
|
|
19
|
+
if (page.next === undefined)
|
|
20
|
+
return;
|
|
21
|
+
cursor = page.next;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const find = async (key) => {
|
|
25
|
+
if (!known.has(key)) {
|
|
26
|
+
await scan(ROOT_CONVERSATION_ID, (entry) => {
|
|
27
|
+
const data = entry.data;
|
|
28
|
+
// The first entry of a key names its conversation.
|
|
29
|
+
if (entry.kind === SESSION_KEY && typeof data?.key === "string" && data.conversation != null && !known.has(data.key))
|
|
30
|
+
known.set(data.key, data.conversation);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return known.get(key);
|
|
34
|
+
};
|
|
35
|
+
const read = async (key) => {
|
|
36
|
+
const id = await find(key);
|
|
37
|
+
const out = [];
|
|
38
|
+
if (id)
|
|
39
|
+
await scan(id, (entry) => out.push({ kind: entry.kind, data: (entry.data ?? null) }));
|
|
40
|
+
return out;
|
|
41
|
+
};
|
|
42
|
+
/** One commit, refused as SessionFenced when the run's lease is gone. */
|
|
43
|
+
const commit = async (key, change) => {
|
|
44
|
+
try {
|
|
45
|
+
return await harness.commit(change, context);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
// The lease's refusal can come as the cause of the Harness's own error.
|
|
49
|
+
for (let at = error; at; at = at.cause)
|
|
50
|
+
if (at instanceof FencedError || at instanceof SessionFenced)
|
|
51
|
+
throw new SessionFenced(key);
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const create = (key) => {
|
|
56
|
+
let made = creating.get(key);
|
|
57
|
+
if (!made) {
|
|
58
|
+
made = (async () => {
|
|
59
|
+
// The root holds the key's entry; a run's agent made it already, and one that has none gets it here.
|
|
60
|
+
await harness.root(context);
|
|
61
|
+
const id = await commit(key, async (tx) => {
|
|
62
|
+
// Read again in the commit: a key another process named meanwhile keeps its conversation.
|
|
63
|
+
for (let cursor;;) {
|
|
64
|
+
const page = await tx.scanEntries({ conversationId: ROOT_CONVERSATION_ID, order: "ascending" }, PAGE, cursor);
|
|
65
|
+
const named = page.items.find((entry) => entry.kind === SESSION_KEY && entry.data?.key === key);
|
|
66
|
+
if (named)
|
|
67
|
+
return named.data.conversation;
|
|
68
|
+
if (page.next === undefined)
|
|
69
|
+
break;
|
|
70
|
+
cursor = page.next;
|
|
71
|
+
}
|
|
72
|
+
const conversation = await tx.createConversation({ ownership: { kind: "ownerless" } });
|
|
73
|
+
await tx.appendEntry(ROOT_CONVERSATION_ID, { kind: SESSION_KEY, data: { key, conversation: conversation.id } });
|
|
74
|
+
return conversation.id;
|
|
75
|
+
});
|
|
76
|
+
known.set(key, id);
|
|
77
|
+
return id;
|
|
78
|
+
})().finally(() => creating.delete(key));
|
|
79
|
+
creating.set(key, made);
|
|
80
|
+
}
|
|
81
|
+
return made;
|
|
82
|
+
};
|
|
83
|
+
return {
|
|
84
|
+
read,
|
|
85
|
+
async open(key) {
|
|
86
|
+
const holder = (holders.get(key) ?? 0) + 1;
|
|
87
|
+
holders.set(key, holder);
|
|
88
|
+
const conversation = (await find(key)) ?? (await create(key));
|
|
89
|
+
const writer = {
|
|
90
|
+
key,
|
|
91
|
+
read: () => read(key),
|
|
92
|
+
async append(records) {
|
|
93
|
+
await commit(key, async (tx) => {
|
|
94
|
+
// Checked in the commit: an open that resolved before it fences this writer, whatever its own timing.
|
|
95
|
+
if (holders.get(key) !== holder)
|
|
96
|
+
throw new SessionFenced(key);
|
|
97
|
+
for (const record of records)
|
|
98
|
+
await tx.appendEntry(conversation, { kind: record.kind, data: record.data });
|
|
99
|
+
});
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
return writer;
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
package/dist/skills.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/** A skill: its name (its directory under `.agents/skills/`), and each of its files' text by its path inside that
|
|
2
|
+
* directory (`SKILL.md`, `reference/sources.md`). */
|
|
3
|
+
export type SkillFiles = {
|
|
4
|
+
name: string;
|
|
5
|
+
files: Record<string, string>;
|
|
6
|
+
};
|
|
7
|
+
/** A harness's check of the skills it would load: why it refuses them, or none. */
|
|
8
|
+
export type SkillCheck = (skills: readonly SkillFiles[]) => string[];
|
|
9
|
+
/** The most skill files read at once, so a run with many skill files stays under a low open-file limit. */
|
|
10
|
+
export declare const READS_AT_ONCE = 16;
|
|
11
|
+
/** The revision's instructions, then each skill's `<name>/SKILL.md` from the run's workspace, by name. */
|
|
12
|
+
export declare function promptOf(instructions: string, skillFiles: Iterable<string>, work: string): Promise<string>;
|
|
13
|
+
/**
|
|
14
|
+
* The revision's skills, by name, each with its files' text from the run's workspace (`work`). A file goes to the nearest
|
|
15
|
+
* skill above it (`team/review/checklist.md` to `team/review` when there is a `team/review/SKILL.md`, else to `team`); a
|
|
16
|
+
* file under no skill is no skill's. Only the revision's own files are read, through no link (workspace.ts): a refused
|
|
17
|
+
* read fails, as promptOf's does.
|
|
18
|
+
*/
|
|
19
|
+
export declare function skillsOf(skillFiles: Iterable<string>, work: string): Promise<SkillFiles[]>;
|
|
20
|
+
/** The skills a harness loads itself (`native`) and the ones that stay in the prompt (`inlined`), by its own check: each
|
|
21
|
+
* skill on its own, then the ones it takes as a set (the set has a size cap). A set it refuses is inlined whole. */
|
|
22
|
+
export declare function splitSkills(skills: readonly SkillFiles[], check: SkillCheck): {
|
|
23
|
+
native: SkillFiles[];
|
|
24
|
+
inlined: SkillFiles[];
|
|
25
|
+
};
|
|
26
|
+
/** A run's system prompt, and the skills its harness loads itself. With the harness's `check`, the skills it takes are
|
|
27
|
+
* its own and leave the prompt; with none, every skill's SKILL.md is in the prompt (promptOf). */
|
|
28
|
+
export declare function systemOf(instructions: string, skillFiles: Iterable<string>, work: string, check?: SkillCheck): Promise<{
|
|
29
|
+
system: string;
|
|
30
|
+
native: SkillFiles[];
|
|
31
|
+
}>;
|
package/dist/skills.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// A revision's skills as a run's harness gets them. pi and codex get every skill's SKILL.md inlined in the system prompt.
|
|
2
|
+
// claude-agent loads skills itself (its Skill tool, from a local plugin the adapter writes): it gets each skill whole, every
|
|
3
|
+
// file of it, and the prompt keeps only the skills its adapter would refuse. The adapter's own check (its exported
|
|
4
|
+
// skillProblems) says which: serve takes any <name>/SKILL.md, the adapter only a lowercase name, a SKILL.md whose front
|
|
5
|
+
// matter names the skill and describes it, plain file paths, and 1 MiB in all.
|
|
6
|
+
import { skillNames } from "./validate.js";
|
|
7
|
+
import { readWorkText } from "./workspace.js";
|
|
8
|
+
/** The most skill files read at once, so a run with many skill files stays under a low open-file limit. */
|
|
9
|
+
export const READS_AT_ONCE = 16;
|
|
10
|
+
/** `path` under the run's skills directory, as the workspace reads it. */
|
|
11
|
+
const skillPath = (path) => [".agents", "skills", path].join("/");
|
|
12
|
+
/** Each of `paths` under the run's skills directory as text, in order, READS_AT_ONCE at a time. Through no link
|
|
13
|
+
* (workspace.ts): a skill directory or file linked out of the workspace is refused, and the read fails. */
|
|
14
|
+
async function readSkillFiles(work, paths) {
|
|
15
|
+
const texts = [];
|
|
16
|
+
for (let at = 0; at < paths.length; at += READS_AT_ONCE) {
|
|
17
|
+
texts.push(...(await Promise.all(paths.slice(at, at + READS_AT_ONCE).map((path) => readWorkText(work, skillPath(path))))));
|
|
18
|
+
}
|
|
19
|
+
return texts;
|
|
20
|
+
}
|
|
21
|
+
/** The instructions, then each skill's SKILL.md, by name. */
|
|
22
|
+
function promptWith(instructions, skills) {
|
|
23
|
+
const blocks = skills.map(({ name, files }) => `<skill name="${name}">\n${(files["SKILL.md"] ?? "").trim()}\n</skill>`);
|
|
24
|
+
return [instructions.trim(), ...(blocks.length ? ["Your skills follow. Use the one that fits the step you are on.", ...blocks] : [])].join("\n\n");
|
|
25
|
+
}
|
|
26
|
+
/** The revision's instructions, then each skill's `<name>/SKILL.md` from the run's workspace, by name. */
|
|
27
|
+
export async function promptOf(instructions, skillFiles, work) {
|
|
28
|
+
const names = skillNames(skillFiles);
|
|
29
|
+
const texts = await readSkillFiles(work, names.map((name) => `${name}/SKILL.md`));
|
|
30
|
+
return promptWith(instructions, names.map((name, i) => ({ name, files: { "SKILL.md": texts[i] } })));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The revision's skills, by name, each with its files' text from the run's workspace (`work`). A file goes to the nearest
|
|
34
|
+
* skill above it (`team/review/checklist.md` to `team/review` when there is a `team/review/SKILL.md`, else to `team`); a
|
|
35
|
+
* file under no skill is no skill's. Only the revision's own files are read, through no link (workspace.ts): a refused
|
|
36
|
+
* read fails, as promptOf's does.
|
|
37
|
+
*/
|
|
38
|
+
export async function skillsOf(skillFiles, work) {
|
|
39
|
+
const paths = [...skillFiles].sort();
|
|
40
|
+
const names = skillNames(paths);
|
|
41
|
+
// The deepest first, so the first a path is under is the nearest.
|
|
42
|
+
const deepest = [...names].sort((a, b) => b.length - a.length);
|
|
43
|
+
const owned = paths.flatMap((path) => {
|
|
44
|
+
const name = deepest.find((skill) => path.startsWith(`${skill}/`));
|
|
45
|
+
return name === undefined ? [] : [{ name, path }];
|
|
46
|
+
});
|
|
47
|
+
const texts = await readSkillFiles(work, owned.map(({ path }) => path));
|
|
48
|
+
const entries = new Map(names.map((name) => [name, []]));
|
|
49
|
+
owned.forEach(({ name, path }, i) => entries.get(name).push([path.slice(name.length + 1), texts[i]]));
|
|
50
|
+
// Each file an own property of a plain object: assigned, a file named __proto__ would set the prototype instead.
|
|
51
|
+
return names.map((name) => ({ name, files: Object.fromEntries(entries.get(name)) }));
|
|
52
|
+
}
|
|
53
|
+
/** The skills a harness loads itself (`native`) and the ones that stay in the prompt (`inlined`), by its own check: each
|
|
54
|
+
* skill on its own, then the ones it takes as a set (the set has a size cap). A set it refuses is inlined whole. */
|
|
55
|
+
export function splitSkills(skills, check) {
|
|
56
|
+
const native = skills.filter((skill) => check([skill]).length === 0);
|
|
57
|
+
if (native.length && check(native).length)
|
|
58
|
+
return { native: [], inlined: [...skills] };
|
|
59
|
+
return { native, inlined: skills.filter((skill) => !native.includes(skill)) };
|
|
60
|
+
}
|
|
61
|
+
/** A run's system prompt, and the skills its harness loads itself. With the harness's `check`, the skills it takes are
|
|
62
|
+
* its own and leave the prompt; with none, every skill's SKILL.md is in the prompt (promptOf). */
|
|
63
|
+
export async function systemOf(instructions, skillFiles, work, check) {
|
|
64
|
+
if (!check)
|
|
65
|
+
return { system: await promptOf(instructions, skillFiles, work), native: [] };
|
|
66
|
+
const { native, inlined } = splitSkills(await skillsOf(skillFiles, work), check);
|
|
67
|
+
return { system: promptWith(instructions, inlined), native };
|
|
68
|
+
}
|
package/dist/stats.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { AnalyticsFilter, StoreAnalytics, StoreStats } from "@parcha/pi-durable-agent";
|
|
2
|
+
import { type Runs } from "./runs.js";
|
|
3
|
+
export declare function statsView(stats: StoreStats, runs: Runs): {
|
|
4
|
+
agents: number;
|
|
5
|
+
runs: {
|
|
6
|
+
total: number;
|
|
7
|
+
active: number;
|
|
8
|
+
needs_input: number;
|
|
9
|
+
failed: number;
|
|
10
|
+
needs_review: number;
|
|
11
|
+
status_unknown: number;
|
|
12
|
+
};
|
|
13
|
+
per_agent: {
|
|
14
|
+
agent_id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
runs: number;
|
|
17
|
+
}[];
|
|
18
|
+
cost: {
|
|
19
|
+
usd: number | null;
|
|
20
|
+
basis: string | null;
|
|
21
|
+
unknown_runs: number;
|
|
22
|
+
};
|
|
23
|
+
archived: {
|
|
24
|
+
agents: number;
|
|
25
|
+
runs: number;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
/** The query's `from` and `to` (RFC 3339 date-times) and `agent` (an agent id): 400 for one that is not. Each absent is
|
|
29
|
+
* no bound. */
|
|
30
|
+
export declare function analyticsFilter(url: URL): AnalyticsFilter;
|
|
31
|
+
export declare function analyticsView(a: StoreAnalytics, filter: AnalyticsFilter): {
|
|
32
|
+
filter: {
|
|
33
|
+
from: string | null;
|
|
34
|
+
to: string | null;
|
|
35
|
+
agent: string | null;
|
|
36
|
+
};
|
|
37
|
+
totals: {
|
|
38
|
+
input: number;
|
|
39
|
+
cache_read: number;
|
|
40
|
+
cache_write: number;
|
|
41
|
+
output: number;
|
|
42
|
+
requests: number;
|
|
43
|
+
unmetered: number;
|
|
44
|
+
runs: number;
|
|
45
|
+
completed: number;
|
|
46
|
+
needs_review: number;
|
|
47
|
+
failed: number;
|
|
48
|
+
runs_with_metrics: number;
|
|
49
|
+
tokens: number;
|
|
50
|
+
cost_usd: number | null;
|
|
51
|
+
unknown_cost_runs: number;
|
|
52
|
+
};
|
|
53
|
+
time: {
|
|
54
|
+
ended_runs: number;
|
|
55
|
+
wall_ms: number;
|
|
56
|
+
active_runs: number;
|
|
57
|
+
active_ms: number;
|
|
58
|
+
};
|
|
59
|
+
by_harness_effort: {
|
|
60
|
+
runs: number;
|
|
61
|
+
completed: number;
|
|
62
|
+
needs_review: number;
|
|
63
|
+
failed: number;
|
|
64
|
+
runs_with_metrics: number;
|
|
65
|
+
tokens: number;
|
|
66
|
+
cost_usd: number | null;
|
|
67
|
+
unknown_cost_runs: number;
|
|
68
|
+
harness: string;
|
|
69
|
+
effort: string | null;
|
|
70
|
+
}[];
|
|
71
|
+
by_day: {
|
|
72
|
+
runs: number;
|
|
73
|
+
completed: number;
|
|
74
|
+
needs_review: number;
|
|
75
|
+
failed: number;
|
|
76
|
+
runs_with_metrics: number;
|
|
77
|
+
tokens: number;
|
|
78
|
+
cost_usd: number | null;
|
|
79
|
+
unknown_cost_runs: number;
|
|
80
|
+
day: string;
|
|
81
|
+
}[];
|
|
82
|
+
by_source: {
|
|
83
|
+
runs: number;
|
|
84
|
+
completed: number;
|
|
85
|
+
needs_review: number;
|
|
86
|
+
failed: number;
|
|
87
|
+
runs_with_metrics: number;
|
|
88
|
+
tokens: number;
|
|
89
|
+
cost_usd: number | null;
|
|
90
|
+
unknown_cost_runs: number;
|
|
91
|
+
source: "live" | import("@parcha/pi-durable-agent").ImportSource;
|
|
92
|
+
}[];
|
|
93
|
+
tools: {
|
|
94
|
+
tool: string;
|
|
95
|
+
label: string;
|
|
96
|
+
calls: number;
|
|
97
|
+
errors: number;
|
|
98
|
+
}[];
|
|
99
|
+
};
|
|
100
|
+
/** How the runs that tried to learn fared: learning-run.ts's, beside the counts that use it, and named here as before. */
|
|
101
|
+
export { learningStats } from "./learning-run.js";
|
package/dist/stats.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { nameOf } from "@parcha/pi-durable-agent/timeline";
|
|
2
|
+
import { ApiError } from "./errors.js";
|
|
3
|
+
import { statusOf } from "./runs.js";
|
|
4
|
+
import { ID } from "./validate.js";
|
|
5
|
+
/** Where a running row this server holds is counted, by its status (a paused workflow run is held, so active). One it holds as ended, its end not yet written to
|
|
6
|
+
* the store, is neither active nor waiting: unknown. */
|
|
7
|
+
const BUCKET = { queued: "active", working: "active", paused: "active", input_required: "needs_input", completed: "status_unknown", failed: "status_unknown", cancelled: "status_unknown" };
|
|
8
|
+
/** As GET /usage rounds its sums; null stays null. */
|
|
9
|
+
const round = (usd) => (usd === null ? null : Math.round(usd * 1e6) / 1e6);
|
|
10
|
+
export function statsView(stats, runs) {
|
|
11
|
+
const running = { active: 0, needs_input: 0, status_unknown: 0 };
|
|
12
|
+
for (const id of stats.running) {
|
|
13
|
+
const run = runs.held(id);
|
|
14
|
+
running[run ? BUCKET[statusOf(run).status] : "status_unknown"] += 1;
|
|
15
|
+
}
|
|
16
|
+
const usd = round(stats.cost.usd);
|
|
17
|
+
return {
|
|
18
|
+
agents: stats.agents,
|
|
19
|
+
runs: { total: stats.runs.total, active: running.active, needs_input: running.needs_input, failed: stats.runs.failed, needs_review: stats.runs.escalated, status_unknown: running.status_unknown },
|
|
20
|
+
per_agent: stats.byAgent.map((a) => ({ agent_id: a.id, name: a.name, runs: a.runs })),
|
|
21
|
+
cost: { usd, basis: usd === null ? null : "estimate", unknown_runs: stats.cost.unknown },
|
|
22
|
+
archived: { agents: stats.archivedAgents, runs: stats.archivedRuns },
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
// ---- analytics: the runs' metrics summed (AgentStoreReader.analytics), over the runs `from`, `to` and `agent` pick ----
|
|
26
|
+
const DATE_TIME = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(\.\d{1,3})?(Z|[+-](\d{2}):(\d{2}))$/;
|
|
27
|
+
/** The UTC time an RFC 3339 date-time names, to the millisecond, or undefined for anything else: an impossible date or
|
|
28
|
+
* time, which Date.parse would roll forward (02-30 to 03-02), and a finer fraction, which it would cut (a bound of
|
|
29
|
+
* .0005 would read .000), included. */
|
|
30
|
+
function utcOf(text) {
|
|
31
|
+
const m = DATE_TIME.exec(text.toUpperCase());
|
|
32
|
+
if (!m)
|
|
33
|
+
return undefined;
|
|
34
|
+
const [year, month, day, hour, minute, second] = m.slice(1, 7).map(Number);
|
|
35
|
+
const date = new Date(0);
|
|
36
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
37
|
+
if (date.getUTCFullYear() !== year || date.getUTCMonth() !== month - 1 || date.getUTCDate() !== day || hour > 23 || minute > 59 || second > 59)
|
|
38
|
+
return undefined;
|
|
39
|
+
if (m[9] !== undefined && (Number(m[9]) > 23 || Number(m[10]) > 59))
|
|
40
|
+
return undefined;
|
|
41
|
+
const at = Date.parse(text.toUpperCase());
|
|
42
|
+
const iso = Number.isFinite(at) ? new Date(at).toISOString() : "";
|
|
43
|
+
return /^\d{4}-/.test(iso) ? iso : undefined;
|
|
44
|
+
}
|
|
45
|
+
/** The query's `from` and `to` (RFC 3339 date-times) and `agent` (an agent id): 400 for one that is not. Each absent is
|
|
46
|
+
* no bound. */
|
|
47
|
+
export function analyticsFilter(url) {
|
|
48
|
+
const filter = {};
|
|
49
|
+
for (const key of ["from", "to"]) {
|
|
50
|
+
const text = url.searchParams.get(key);
|
|
51
|
+
if (text === null)
|
|
52
|
+
continue;
|
|
53
|
+
const iso = utcOf(text);
|
|
54
|
+
if (iso === undefined)
|
|
55
|
+
throw new ApiError("bad_request", "from and to are RFC 3339 date-times that exist, to the millisecond");
|
|
56
|
+
filter[key] = iso;
|
|
57
|
+
}
|
|
58
|
+
const agent = url.searchParams.get("agent");
|
|
59
|
+
if (agent !== null) {
|
|
60
|
+
if (!ID.test(agent))
|
|
61
|
+
throw new ApiError("bad_request", "agent is an agent id");
|
|
62
|
+
filter.agent = agent;
|
|
63
|
+
}
|
|
64
|
+
return filter;
|
|
65
|
+
}
|
|
66
|
+
/** A group's counts: an escalated run is completed, and needs review; never failed. */
|
|
67
|
+
const group = (g) => ({ runs: g.runs, completed: g.completed, needs_review: g.needsReview, failed: g.failed, runs_with_metrics: g.runsWithMetrics, tokens: g.tokens, cost_usd: round(g.costUsd), unknown_cost_runs: g.unknownCostRuns });
|
|
68
|
+
export function analyticsView(a, filter) {
|
|
69
|
+
const t = a.totals;
|
|
70
|
+
return {
|
|
71
|
+
filter: { from: filter.from ?? null, to: filter.to ?? null, agent: filter.agent ?? null },
|
|
72
|
+
totals: { ...group(t), input: t.input, cache_read: t.cacheRead, cache_write: t.cacheWrite, output: t.output, requests: t.requests, unmetered: t.unmetered },
|
|
73
|
+
time: { ended_runs: a.time.endedRuns, wall_ms: a.time.wallMs, active_runs: a.time.activeRuns, active_ms: a.time.activeMs },
|
|
74
|
+
by_harness_effort: a.byHarnessEffort.map((g) => ({ harness: g.harness, effort: g.effort, ...group(g) })),
|
|
75
|
+
by_day: a.byDay.map((g) => ({ day: g.day, ...group(g) })),
|
|
76
|
+
by_source: a.bySource.map((g) => ({ source: g.source, ...group(g) })),
|
|
77
|
+
// Each tool by the name it was called (`tool`) and what a person calls it (`label`, the timeline's registry).
|
|
78
|
+
tools: a.tools.map((t) => ({ tool: t.tool, label: nameOf(t.tool), calls: t.calls, errors: t.errors })),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** How the runs that tried to learn fared: learning-run.ts's, beside the counts that use it, and named here as before. */
|
|
82
|
+
export { learningStats } from "./learning-run.js";
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { type KeyCheck } from "./key-check.js";
|
|
2
|
+
export declare const TOOL_KEYS_FILE = "tool-keys.json";
|
|
3
|
+
export declare const SEAL_KEY_ENV = "AGENTRUN_SEAL_KEY";
|
|
4
|
+
/** Each key a person may save, fixed here: its kind, the fields it is entered as (BROWSERBASE_PROJECT_ID is no secret,
|
|
5
|
+
* and is kept the same way), and what it may unlock: tools by name, and `decisions.<id>`, a workflow's decision
|
|
6
|
+
* provider. GET lists only those this server binds (unlockedBy), so a name here the server does not bind is never
|
|
7
|
+
* promised, and one shows by itself once the server binds it. A `tool` key's fields reach only the runs that name a
|
|
8
|
+
* tool it unlocks (runs.ts' secretsFor); a key of any other kind (a model's) reaches every run. */
|
|
9
|
+
export declare const TOOL_KEYS: readonly [{
|
|
10
|
+
readonly id: "parallel";
|
|
11
|
+
readonly kind: "tool";
|
|
12
|
+
readonly label: "Parallel";
|
|
13
|
+
readonly fields: readonly ["PARALLEL_API_KEY"];
|
|
14
|
+
readonly unlocks: readonly ["web_fetch", "web_search", "decisions.parallel"];
|
|
15
|
+
}, {
|
|
16
|
+
readonly id: "monid";
|
|
17
|
+
readonly kind: "tool";
|
|
18
|
+
readonly label: "Monid";
|
|
19
|
+
readonly fields: readonly ["MONID_API_KEY"];
|
|
20
|
+
readonly unlocks: readonly ["monid.discover", "monid.inspect", "monid.run"];
|
|
21
|
+
}, {
|
|
22
|
+
readonly id: "browserbase";
|
|
23
|
+
readonly kind: "tool";
|
|
24
|
+
readonly label: "Browserbase";
|
|
25
|
+
readonly fields: readonly ["BROWSERBASE_API_KEY", "BROWSERBASE_PROJECT_ID"];
|
|
26
|
+
readonly unlocks: readonly ["browser"];
|
|
27
|
+
}, {
|
|
28
|
+
readonly id: "typesafe";
|
|
29
|
+
readonly kind: "tool";
|
|
30
|
+
readonly label: "TypeSafe (Jev)";
|
|
31
|
+
readonly fields: readonly ["TYPESAFE_API_KEY"];
|
|
32
|
+
readonly unlocks: readonly ["decisions.jev"];
|
|
33
|
+
}, ...{
|
|
34
|
+
id: "anthropic" | "openai" | "openrouter";
|
|
35
|
+
kind: "model";
|
|
36
|
+
label: "Anthropic" | "OpenAI" | "OpenRouter";
|
|
37
|
+
fields: readonly ["ANTHROPIC_API_KEY" | "OPENAI_API_KEY" | "OPENROUTER_API_KEY"];
|
|
38
|
+
unlocks: readonly [];
|
|
39
|
+
harnesses: readonly ["pi" | "claude-agent" | "codex", "claude-agent"] | readonly ["pi" | "claude-agent" | "codex", "codex"] | readonly ["pi" | "claude-agent" | "codex", "claude-agent", "codex"];
|
|
40
|
+
}[]];
|
|
41
|
+
/** The fields of the `tool` rows: keys a tool or a decision provider reads, and no harness (the harnesses read their
|
|
42
|
+
* packages, their pins and their models' keys). A row of another kind (a model's) is outside them. */
|
|
43
|
+
export declare const TOOL_FIELDS: readonly string[];
|
|
44
|
+
/** What `candidates` unlock here, as capabilities show it: the tools of `tools` (capabilities' `tools`, available or
|
|
45
|
+
* not) and the providers of `providers` (its `workflows.decisions.providers`) named among them, and the harnesses
|
|
46
|
+
* that run those tools. A name neither holds is left out; a key that unlocks none of its names lists nothing. */
|
|
47
|
+
export declare function unlockedBy(candidates: readonly string[], tools: readonly {
|
|
48
|
+
name: string;
|
|
49
|
+
harnesses: readonly string[];
|
|
50
|
+
}[], providers: readonly {
|
|
51
|
+
id: string;
|
|
52
|
+
}[]): {
|
|
53
|
+
unlocks: string[];
|
|
54
|
+
harnesses: ("pi" | "claude-agent" | "codex")[];
|
|
55
|
+
};
|
|
56
|
+
/** What a row unlocks here: a `tool` row's, its tools and providers as capabilities bind them (unlockedBy); any other
|
|
57
|
+
* kind's (a model's), no tool, on those that run on it (its `harnesses`, when it names them) that this server runs
|
|
58
|
+
* (`offers`, harness.ts' harnessOffers) or would once its key is set: one unavailable only for want of a model key
|
|
59
|
+
* among whose `keys` is the row's (its first field). So OpenRouter's row names all three before any key is saved; a
|
|
60
|
+
* harness not installed, off its pins or too big for this host is left out. */
|
|
61
|
+
export declare function rowUnlocks(row: {
|
|
62
|
+
kind: string;
|
|
63
|
+
unlocks: readonly string[];
|
|
64
|
+
harnesses?: readonly string[];
|
|
65
|
+
fields?: readonly string[];
|
|
66
|
+
}, tools: Parameters<typeof unlockedBy>[1], providers: Parameters<typeof unlockedBy>[2], offers: readonly {
|
|
67
|
+
id: string;
|
|
68
|
+
available: boolean;
|
|
69
|
+
keys?: readonly string[];
|
|
70
|
+
}[]): {
|
|
71
|
+
unlocks: string[];
|
|
72
|
+
harnesses: ("pi" | "claude-agent" | "codex")[];
|
|
73
|
+
};
|
|
74
|
+
/** The key that unlocks the tool `name` (capabilities' `tools[].key`, so a page links "needs the X key" to it), if any. */
|
|
75
|
+
export declare const keyOf: (name: string) => string | undefined;
|
|
76
|
+
/** Why a stored value does not open, in the order a re-entry names one: no seal key now, another than it was sealed
|
|
77
|
+
* under, or the file (or its entry) damaged. */
|
|
78
|
+
export declare const UNREADABLE: readonly ["seal_key_missing", "seal_key_changed", "file_unreadable"];
|
|
79
|
+
/** The seal key `text` gives: 32 bytes in base64 (or base64url), else none. */
|
|
80
|
+
export declare function sealKeyOf(text: string | undefined): Buffer | undefined;
|
|
81
|
+
export declare class ToolKeys {
|
|
82
|
+
private readonly env;
|
|
83
|
+
private readonly say;
|
|
84
|
+
readonly file: string;
|
|
85
|
+
private readonly key;
|
|
86
|
+
private readonly sealCheck;
|
|
87
|
+
private said;
|
|
88
|
+
/** `env` is what the server is started with (withSecrets' `"own"`, never a saved key, or each would read as the
|
|
89
|
+
* server's and could not be deleted): a field it sets is the server's, and wins. `say` takes a log line's fields. */
|
|
90
|
+
constructor(data: string, env: NodeJS.ProcessEnv, say: (fields: Record<string, string>) => void);
|
|
91
|
+
/** The file's entries, none with no file; "unreadable" when it does not read as this format. A file from before checks
|
|
92
|
+
* has none. */
|
|
93
|
+
private kept;
|
|
94
|
+
private open;
|
|
95
|
+
/** The stored value of the field `name`, opened now (secrets.ts reads a saved key by name through this); undefined
|
|
96
|
+
* with none, or one that does not open, which view() asks for again: never a clear fallback. */
|
|
97
|
+
value(name: string): string | undefined;
|
|
98
|
+
/** Every stored value that opens, by field name. */
|
|
99
|
+
values(): Record<string, string>;
|
|
100
|
+
/** GET: each key's fields, whether set and where from (never a value), what it unlocks of what capabilities shows
|
|
101
|
+
* here (a model key: the harnesses `offers` says this server runs or would on the key), its check when its key (its first field) is
|
|
102
|
+
* stored here (null otherwise: the server's own is not checked here), and what to enter again, with why. */
|
|
103
|
+
view(offers?: Parameters<typeof rowUnlocks>[3]): {
|
|
104
|
+
keys: {
|
|
105
|
+
fields: ({
|
|
106
|
+
name: "TYPESAFE_API_KEY" | "PARALLEL_API_KEY" | "ANTHROPIC_API_KEY" | "OPENAI_API_KEY" | "OPENROUTER_API_KEY" | "BROWSERBASE_API_KEY" | "BROWSERBASE_PROJECT_ID" | "MONID_API_KEY";
|
|
107
|
+
set: boolean;
|
|
108
|
+
source: "server";
|
|
109
|
+
} | {
|
|
110
|
+
name: "TYPESAFE_API_KEY" | "PARALLEL_API_KEY" | "ANTHROPIC_API_KEY" | "OPENAI_API_KEY" | "OPENROUTER_API_KEY" | "BROWSERBASE_API_KEY" | "BROWSERBASE_PROJECT_ID" | "MONID_API_KEY";
|
|
111
|
+
set: boolean;
|
|
112
|
+
source: "stored";
|
|
113
|
+
} | {
|
|
114
|
+
stored_unreadable?: true | undefined;
|
|
115
|
+
name: "TYPESAFE_API_KEY" | "PARALLEL_API_KEY" | "ANTHROPIC_API_KEY" | "OPENAI_API_KEY" | "OPENROUTER_API_KEY" | "BROWSERBASE_API_KEY" | "BROWSERBASE_PROJECT_ID" | "MONID_API_KEY";
|
|
116
|
+
set: boolean;
|
|
117
|
+
source: null;
|
|
118
|
+
})[];
|
|
119
|
+
check: KeyCheck | null;
|
|
120
|
+
unlocks: string[];
|
|
121
|
+
harnesses: ("pi" | "claude-agent" | "codex")[];
|
|
122
|
+
id: "anthropic" | "openai" | "typesafe" | "openrouter" | "parallel" | "browserbase" | "monid";
|
|
123
|
+
kind: "model" | "tool";
|
|
124
|
+
label: "Anthropic" | "OpenAI" | "OpenRouter" | "Parallel" | "Monid" | "Browserbase" | "TypeSafe (Jev)";
|
|
125
|
+
}[];
|
|
126
|
+
reenter: {
|
|
127
|
+
reason: "seal_key_missing" | "seal_key_changed" | "file_unreadable";
|
|
128
|
+
fields: string[];
|
|
129
|
+
} | null;
|
|
130
|
+
};
|
|
131
|
+
/** A PUT's check, before save(): the key it sends (its row's first field; Browserbase's project id is no key) checked
|
|
132
|
+
* against its provider (key-check.ts), the fetch `fetchFor` gives for the row (undefined: none, so not checked), its
|
|
133
|
+
* wait cut by `stop`. The body is held to what save() takes first, so a save that would be refused sends nothing. A
|
|
134
|
+
* key the provider refuses is 422 in its words, and nothing is kept; undefined when the body sends no key: the row's
|
|
135
|
+
* check stays as it was. */
|
|
136
|
+
check(id: string, body: Record<string, unknown>, fetchFor: (id: string) => Promise<typeof fetch | undefined>, stop?: AbortSignal): Promise<KeyCheck | undefined>;
|
|
137
|
+
/** PUT: each of `body.values` sealed under the seal key, and `check` (check()'s) kept for the key when given; the key's
|
|
138
|
+
* other fields stay as they are. A key saved with no check (a caller other than the route) drops the one it had. */
|
|
139
|
+
save(id: string, body: Record<string, unknown>, check?: KeyCheck): void;
|
|
140
|
+
/** What a PUT may save: the key's row and the body's values, or 422 (the body), 409 (a field the server's, or no seal
|
|
141
|
+
* key). No message holds a value, or any part of one. */
|
|
142
|
+
private admit;
|
|
143
|
+
/** DELETE: the key's stored fields gone, and its check. Refused only when the server sets every field of it: none is
|
|
144
|
+
* the page's. */
|
|
145
|
+
remove(id: string): void;
|
|
146
|
+
private row;
|
|
147
|
+
/** 409 when this server's own environment (its launcher) sets one of `names`: that one wins, and is changed where the
|
|
148
|
+
* server is started. */
|
|
149
|
+
private notServers;
|
|
150
|
+
private write;
|
|
151
|
+
}
|