@parcha/agentrun-serve 0.1.0-beta.41 → 0.1.0-beta.43
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 +74 -0
- package/NOTICE +2 -0
- package/README.md +85 -19
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.js +3 -1
- package/dist/calendar/address.d.ts +49 -0
- package/dist/calendar/address.js +153 -0
- package/dist/calendar/fetch.d.ts +24 -0
- package/dist/calendar/fetch.js +146 -0
- package/dist/calendar/ics-faux.d.ts +39 -0
- package/dist/calendar/ics-faux.js +236 -0
- package/dist/calendar/labels.d.ts +3 -0
- package/dist/calendar/labels.js +61 -0
- package/dist/calendar/names.d.ts +52 -0
- package/dist/calendar/names.js +54 -0
- package/dist/calendar/parse.d.ts +108 -0
- package/dist/calendar/parse.js +625 -0
- package/dist/calendar/routes.d.ts +17 -0
- package/dist/calendar/routes.js +81 -0
- package/dist/calendar/tools.d.ts +23 -0
- package/dist/calendar/tools.js +124 -0
- package/dist/cli.js +3 -1
- package/dist/computer-record.d.ts +55 -0
- package/dist/computer-record.js +315 -0
- package/dist/computer-setting.d.ts +1 -0
- package/dist/computer-setting.js +15 -2
- package/dist/computers.js +2 -14
- package/dist/console/assets/index-BrcDSBD8.css +1 -0
- package/dist/console/assets/index-Bz6IWncl.js +711 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.js +0 -4
- package/dist/eval-feed.d.ts +2 -2
- package/dist/eval-feed.js +9 -5
- package/dist/feed/parse.d.ts +3 -2
- package/dist/feed/parse.js +9 -18
- package/dist/feed/pointer.d.ts +2 -0
- package/dist/feed/pointer.js +17 -0
- package/dist/file-types.js +1 -0
- package/dist/host-command.d.ts +3 -0
- package/dist/host-command.js +18 -0
- package/dist/host.d.ts +3 -0
- package/dist/host.js +3 -0
- package/dist/import-sources.js +25 -5
- package/dist/learn/audit.d.ts +123 -0
- package/dist/learn/audit.js +159 -0
- package/dist/learn/check.d.ts +14 -0
- package/dist/learn/check.js +194 -14
- package/dist/learn/compile.d.ts +75 -78
- package/dist/learn/compile.js +175 -176
- package/dist/learn/folder.d.ts +9 -0
- package/dist/learn/folder.js +13 -2
- package/dist/learn/promote.d.ts +138 -196
- package/dist/learn/promote.js +68 -184
- package/dist/learn/replay-calls.d.ts +5 -0
- package/dist/learn/replay-calls.js +12 -1
- package/dist/learn/secrets.d.ts +8 -0
- package/dist/learn/secrets.js +12 -0
- package/dist/learn/skills.js +2 -4
- package/dist/learn/workflow-nodes.d.ts +1 -2
- package/dist/learn/workflow-nodes.js +2 -3
- package/dist/learned-nodes.d.ts +9 -34
- package/dist/learned-nodes.js +11 -23
- package/dist/learned-workflow.d.ts +6 -8
- package/dist/learned-workflow.js +18 -57
- package/dist/learning-batch.d.ts +13 -5
- package/dist/learning-batch.js +34 -8
- package/dist/learning-cost.d.ts +11 -4
- package/dist/learning-cost.js +4 -2
- package/dist/learning-routes.js +1 -1
- package/dist/learning-setting.d.ts +38 -0
- package/dist/learning-setting.js +83 -0
- package/dist/learning-words.d.ts +3 -0
- package/dist/learning-words.js +3 -0
- package/dist/learning.d.ts +3 -2
- package/dist/learning.js +5 -3
- package/dist/mcp-oauth.d.ts +8 -0
- package/dist/mcp-oauth.js +7 -0
- package/dist/mcp-private-hosts.d.ts +13 -0
- package/dist/mcp-private-hosts.js +16 -0
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +195 -59
- package/dist/run-files.d.ts +6 -2
- package/dist/run-files.js +29 -7
- package/dist/run-launch.d.ts +6 -3
- package/dist/run-launch.js +2 -0
- package/dist/run-learning-served.d.ts +2 -2
- package/dist/run-reads-over-store.d.ts +5 -1
- package/dist/run-reads-over-store.js +8 -4
- package/dist/run-recordings.d.ts +20 -0
- package/dist/run-recordings.js +133 -0
- package/dist/runner/adapter-loop.d.ts +5 -1
- package/dist/runner/adapter-loop.js +20 -8
- package/dist/runner/adapter-run-spec.d.ts +16 -1
- package/dist/runner/adapter-run-spec.js +36 -11
- package/dist/runner/audit.d.ts +64 -0
- package/dist/runner/audit.js +338 -0
- package/dist/runner/beside.js +2 -2
- package/dist/runner/cli-run-spec.js +25 -12
- package/dist/runner/feedback-round.d.ts +9 -25
- package/dist/runner/feedback-round.js +19 -40
- package/dist/runner/harness-loops.js +1 -15
- package/dist/runner/journal-kinds.d.ts +0 -7
- package/dist/runner/journal-kinds.js +0 -7
- package/dist/runner/learning-dispatch.d.ts +0 -16
- package/dist/runner/learning-dispatch.js +4 -47
- package/dist/runner/learning-end.d.ts +62 -13
- package/dist/runner/learning-end.js +180 -74
- package/dist/runner/learning-factory.d.ts +1 -1
- package/dist/runner/learning-factory.js +1 -4
- package/dist/runner/learning-loop.d.ts +2 -38
- package/dist/runner/learning-loop.js +8 -116
- package/dist/runner/main.d.ts +11 -0
- package/dist/runner/main.js +30 -3
- package/dist/runner/mcp-run.d.ts +2 -2
- package/dist/runner/promotion.d.ts +78 -50
- package/dist/runner/promotion.js +371 -503
- package/dist/runner/reflect-hook.d.ts +15 -0
- package/dist/runner/reflect-hook.js +28 -14
- package/dist/runner/store-secrets.js +3 -1
- package/dist/runner/workflow-first.d.ts +6 -11
- package/dist/runner/workflow-first.js +24 -25
- package/dist/runs-over-store.d.ts +1 -1
- package/dist/sdk/runs.js +2 -1
- package/dist/secrets.js +2 -2
- package/dist/server.d.ts +4 -3
- package/dist/server.js +132 -26
- package/dist/store/agent-body.d.ts +5 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store/sqlite/store.js +1 -0
- package/dist/store/store.d.ts +3 -0
- package/dist/store-reads/learning.d.ts +18 -7
- package/dist/store-reads/learning.js +36 -23
- package/dist/store-reads/loop.d.ts +5 -39
- package/dist/store-reads/loop.js +21 -80
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +16 -2
- package/dist/template-eval.d.ts +7 -0
- package/dist/template-eval.js +54 -6
- package/dist/templates.d.ts +3 -1
- package/dist/templates.js +14 -1
- package/dist/timeline/computer.js +2 -1
- package/dist/tool-list.js +1 -0
- package/dist/tools.d.ts +7 -0
- package/dist/tools.js +11 -0
- package/dist/trigger-feed.js +67 -18
- package/dist/validate.js +7 -2
- package/dist/workspace/computer-for-claim.d.ts +7 -0
- package/dist/workspace/computer-for-claim.js +12 -2
- package/dist/workspace/paths.d.ts +4 -0
- package/dist/workspace/paths.js +9 -0
- package/dist/workspace/resolve-computer.d.ts +3 -1
- package/dist/workspace/run-tools.d.ts +1 -1
- package/dist/workspace/run-tools.js +14 -3
- package/launcher/agentrun-serve +31 -24
- package/package.json +10 -9
- package/templates/README.md +11 -2
- package/dist/console/assets/index-C3gNPz58.css +0 -1
- package/dist/console/assets/index-COGhx_2Z.js +0 -711
- package/dist/learn/general.d.ts +0 -69
- package/dist/learn/general.js +0 -75
- package/dist/learn/refit.d.ts +0 -48
- package/dist/learn/refit.js +0 -264
- package/dist/runner/step-guard.d.ts +0 -62
- package/dist/runner/step-guard.js +0 -93
package/dist/tool-list.js
CHANGED
|
@@ -11,6 +11,7 @@ export const TOOL_LIST = Object.freeze({
|
|
|
11
11
|
email_draft: { table: true, askable: true, replay: "never", host: true, blurb: "Save an email draft" },
|
|
12
12
|
email_send: { table: true, askable: true, replay: "never", host: true, asks: true, blurb: "Send an email" },
|
|
13
13
|
email_file: { table: true, askable: true, replay: "never", host: true, blurb: "File an email under a folder or label" },
|
|
14
|
+
calendar_events: { table: true, askable: true, replay: "safe", host: true, blurb: "Read the calendar's events" },
|
|
14
15
|
browser: { table: true, blurb: "Browse websites in a hosted browser" },
|
|
15
16
|
subagent: { table: true, blurb: "Run a task in a fresh helper conversation" },
|
|
16
17
|
pdf_pages: { table: true, blurb: "Turn a PDF's pages into images" },
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import "./email/labels.js";
|
|
2
|
+
import "./calendar/labels.js";
|
|
2
3
|
import type { TSchema } from "typebox";
|
|
3
4
|
import { type Extension, type Harness, type ToolRegistration, type Tx } from "@earendil-works/pi-durable";
|
|
4
5
|
import type { Revision } from "./agent-rows.js";
|
|
@@ -130,6 +131,12 @@ export type ToolHost = {
|
|
|
130
131
|
/** A template eval case's fake mail account (eval-mailbox.ts), the only account the run's email tools open: one saved
|
|
131
132
|
* elsewhere is refused. Only the eval's own runner sets it (runner/beside.ts evalFakes). */
|
|
132
133
|
emailFake?: EmailFake;
|
|
134
|
+
/** The server is a local install (its operator's mcpLoopback, runner/beside.ts): calendar_events may read a calendar on
|
|
135
|
+
* loopback, as a template eval's fake calendar is. Absent: never. */
|
|
136
|
+
calendarLoopback?: boolean;
|
|
137
|
+
/** That server's own addresses (Serve.own, AdapterSpecDeps.mcpOwn): calendar_events never reads on loopback at their
|
|
138
|
+
* ports, a redirect's hop included, as the server's own read (calendar/routes.ts) never does. */
|
|
139
|
+
serverOwn?: readonly string[];
|
|
133
140
|
};
|
|
134
141
|
/** A fake mail account's servers, on loopback (email/email-faux.ts), and the kind of server it plays: what email_file's
|
|
135
142
|
* description says, which a loopback account saved as `other` would otherwise read as folders. */
|
package/dist/tools.js
CHANGED
|
@@ -8,6 +8,9 @@ import { blurbOf, isHostTool } from "./tool-list.js";
|
|
|
8
8
|
import { EMAIL_DESCRIPTIONS, EMAIL_DRAFT, EMAIL_FILE, EMAIL_READ, EMAIL_SEARCH, EMAIL_SEND, fileSummary, sendSummary } from "./email/names.js";
|
|
9
9
|
// The email tools' timeline lines (registerLabel), registered as this module loads.
|
|
10
10
|
import "./email/labels.js";
|
|
11
|
+
import { CALENDAR_EVENTS, CALENDAR_SUMMARY } from "./calendar/names.js";
|
|
12
|
+
// calendar_events' timeline line (registerLabel), registered as this module loads.
|
|
13
|
+
import "./calendar/labels.js";
|
|
11
14
|
import { mcpNameOf } from "./tool-names.js";
|
|
12
15
|
import { appendFileSync } from "node:fs";
|
|
13
16
|
import { pathToFileURL } from "node:url";
|
|
@@ -604,6 +607,14 @@ export const TOOLS = Object.freeze({
|
|
|
604
607
|
[EMAIL_DRAFT]: emailTool(EMAIL_DRAFT),
|
|
605
608
|
[EMAIL_SEND]: emailTool(EMAIL_SEND),
|
|
606
609
|
[EMAIL_FILE]: emailTool(EMAIL_FILE),
|
|
610
|
+
// The server's calendar (calendar/tools.ts, saved with PUT /v2/settings/calendar), every harness's as web_fetch is; ical.js loads at the
|
|
611
|
+
// first bind.
|
|
612
|
+
[CALENDAR_EVENTS]: {
|
|
613
|
+
summary: CALENDAR_SUMMARY,
|
|
614
|
+
needs: [],
|
|
615
|
+
nodes: false,
|
|
616
|
+
bind: async (host) => (await import("./calendar/tools.js")).bindCalendar(host),
|
|
617
|
+
},
|
|
607
618
|
browser: browserTool,
|
|
608
619
|
// A pi run's subagent (runner/subagent.ts): a native tool of the run's root agent, bound by the runner's pi spec
|
|
609
620
|
// (adapter-run-spec.ts), never by this table; not a host tool (tool-list.ts `replay`), so another harness refuses it.
|
package/dist/trigger-feed.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pointed } from "./feed/pointer.js";
|
|
1
2
|
import { ACCEPT_SCHEMA, acceptOf, acceptRefusal } from "./trigger-accept.js";
|
|
2
3
|
import { closedSchema, PAYLOAD_KEPT_BYTES, unknownSourceFields } from "./trigger-adapter.js";
|
|
3
4
|
import { MAX_EVERY_S, MIN_EVERY_S } from "./trigger-schedule.js";
|
|
@@ -22,6 +23,8 @@ const LAST_CHECK = "last_check";
|
|
|
22
23
|
const URL_CHARS = 2000;
|
|
23
24
|
const POINTER = /^(\/([^~]|~[01])*)?$/;
|
|
24
25
|
const POINTER_CHARS = 300;
|
|
26
|
+
/** The most fields a JSON list's `fields` keeps of each item. */
|
|
27
|
+
const MAX_FIELDS = 50;
|
|
25
28
|
/** The source's own fields, checked: each issue through `bad`. Undefined when one does not read. */
|
|
26
29
|
function fieldsOf(value, bad) {
|
|
27
30
|
let failed = false;
|
|
@@ -47,15 +50,22 @@ function fieldsOf(value, bad) {
|
|
|
47
50
|
const every = value.every_s ?? DEFAULT_EVERY_S;
|
|
48
51
|
if (!Number.isSafeInteger(every) || every < MIN_EVERY_S || every > MAX_EVERY_S)
|
|
49
52
|
fail("every_s", "invalid", `every_s is a whole number of seconds, ${MIN_EVERY_S} to ${MAX_EVERY_S}`);
|
|
50
|
-
for (const name of ["items", "id"]) {
|
|
53
|
+
for (const name of ["items", "id", "updated"]) {
|
|
51
54
|
const pointer = value[name];
|
|
52
55
|
if (pointer === undefined)
|
|
53
56
|
continue;
|
|
54
57
|
const whole = name === "items";
|
|
55
58
|
if (typeof pointer !== "string" || pointer.length > POINTER_CHARS || !POINTER.test(pointer) || (!whole && !pointer)) {
|
|
56
|
-
|
|
59
|
+
if (name === "updated")
|
|
60
|
+
fail(name, "invalid", "updated is a JSON Pointer into a JSON list's item to the date it last changed (/updated_at): for a feed that is a JSON list");
|
|
61
|
+
else
|
|
62
|
+
fail(name, "invalid", whole ? `items is a JSON Pointer to a JSON list's array of items ("" for the whole document, /data/items): for a feed that is a JSON list` : `id is a JSON Pointer into a JSON list's item to its id (/id, /number): for a feed that is a JSON list`);
|
|
57
63
|
}
|
|
58
64
|
}
|
|
65
|
+
const fields = value.fields;
|
|
66
|
+
if (fields !== undefined && (!Array.isArray(fields) || fields.length < 1 || fields.length > MAX_FIELDS || fields.some((one) => typeof one !== "string" || !one || one.length > POINTER_CHARS || !POINTER.test(one)))) {
|
|
67
|
+
fail("fields", "invalid", `fields is a list of 1 to ${MAX_FIELDS} JSON Pointers into a JSON list's item (/number, /user/login): the payload's item keeps only these, for a feed that is a JSON list`);
|
|
68
|
+
}
|
|
59
69
|
const accept = value.accept === undefined ? undefined : acceptOf(value.accept, fail);
|
|
60
70
|
accept?.forEach((rule, i) => {
|
|
61
71
|
if (rule.event !== EVENT)
|
|
@@ -65,7 +75,7 @@ function fieldsOf(value, bad) {
|
|
|
65
75
|
});
|
|
66
76
|
if (failed)
|
|
67
77
|
return undefined;
|
|
68
|
-
return { kind: "feed", urls: urls, every_s: every, ...(value.items !== undefined ? { items: value.items } : {}), ...(value.id !== undefined ? { id: value.id } : {}), ...(accept ? { accept } : {}) };
|
|
78
|
+
return { kind: "feed", urls: urls, every_s: every, ...(value.items !== undefined ? { items: value.items } : {}), ...(value.id !== undefined ? { id: value.id } : {}), ...(value.updated !== undefined ? { updated: value.updated } : {}), ...(value.fields !== undefined ? { fields: value.fields } : {}), ...(accept ? { accept } : {}) };
|
|
69
79
|
}
|
|
70
80
|
/** Why `url` is no feed URL a trigger reads, or undefined: an http(s) URL, with no user or password in it. */
|
|
71
81
|
export function urlProblem(url) {
|
|
@@ -106,7 +116,7 @@ async function readOne(url, state, source, reach) {
|
|
|
106
116
|
if (!("body" in read))
|
|
107
117
|
return { url, ok: false, status: read.status, problem: `Couldn't read ${url}: HTTP ${read.status}.` };
|
|
108
118
|
try {
|
|
109
|
-
const feed = parseFeed(read.body, { ...(source.items !== undefined ? { items: source.items } : {}), ...(source.id !== undefined ? { id: source.id } : {}) });
|
|
119
|
+
const feed = parseFeed(read.body, { ...(source.items !== undefined ? { items: source.items } : {}), ...(source.id !== undefined ? { id: source.id } : {}), ...(source.updated !== undefined ? { updated: source.updated } : {}) });
|
|
110
120
|
return { url, ok: true, changed: true, feed, validators: { ...(read.etag ? { etag: read.etag } : {}), ...(read.modified ? { modified: read.modified } : {}) } };
|
|
111
121
|
}
|
|
112
122
|
catch (error) {
|
|
@@ -133,6 +143,9 @@ async function pooled(items, n, work) {
|
|
|
133
143
|
}));
|
|
134
144
|
return out;
|
|
135
145
|
}
|
|
146
|
+
/** `state`'s seen set as a map, a missing date null. A set saved before dates were told apart (no \`dates\`) holds 0 for one:
|
|
147
|
+
* read as missing for a JSON list, whose items had no dates then; an RSS, Atom or JSON Feed item's 0 stays a number. */
|
|
148
|
+
const seenOf = (state, list) => new Map((state.seen ?? []).map(([key, at]) => [key, at === 0 && list && state.dates !== 2 ? null : at]));
|
|
136
149
|
/** One feed's items, oldest first: as it serves them reversed (a feed lists newest first), then by date when every one
|
|
137
150
|
* has one. Each key once (its first, the newest). */
|
|
138
151
|
function oldestFirst(items) {
|
|
@@ -147,14 +160,16 @@ function oldestFirst(items) {
|
|
|
147
160
|
/** The payload an item fires with, within PAYLOAD_KEPT_BYTES: a JSON list's {id, link, title, item, update}, its raw item
|
|
148
161
|
* cut shallower until it fits; any other's {id, link, title, published, updated, author, summary, categories, feed,
|
|
149
162
|
* update}, its summary cut until it fits. */
|
|
150
|
-
function payloadOf(c, list, title) {
|
|
163
|
+
function payloadOf(c, list, title, fields) {
|
|
151
164
|
const { item, update } = c;
|
|
152
165
|
if (list) {
|
|
153
|
-
|
|
166
|
+
// `fields`, when the source names some, keep only those of the item, before the cap.
|
|
167
|
+
const raw = fields ? keeping(item.raw, fields) : item.raw;
|
|
168
|
+
const whole = { id: item.id, link: item.link, title: item.title, item: raw, update };
|
|
154
169
|
if (fits(whole))
|
|
155
170
|
return whole;
|
|
156
171
|
for (const [depth, chars] of [[3, 2000], [3, 300], [2, 2000], [2, 300], [1, 300], [1, 100]]) {
|
|
157
|
-
const cut = { ...whole, item: shallow(
|
|
172
|
+
const cut = { ...whole, item: shallow(raw, depth, chars), item_truncated: true };
|
|
158
173
|
if (fits(cut))
|
|
159
174
|
return cut;
|
|
160
175
|
}
|
|
@@ -170,6 +185,35 @@ function payloadOf(c, list, title) {
|
|
|
170
185
|
}
|
|
171
186
|
return { id: clipped(item.id, 200), link: clipped(item.link, 200), title: clipped(item.title, 200), published: iso(item.published), updated: iso(item.updated), author: null, summary: null, categories: [], feed: { title: null, url: c.url }, update };
|
|
172
187
|
}
|
|
188
|
+
/** `raw` with only the values at `pointers` kept, each at its own place (a list's kept entries compacted). Every
|
|
189
|
+
* container is built bare and every key set as an own property, so no name (\`__proto__\` too) reaches a prototype; only
|
|
190
|
+
* own keys of the item are read. */
|
|
191
|
+
function keeping(raw, pointers) {
|
|
192
|
+
const bare = (like) => (Array.isArray(like) ? [] : Object.create(null));
|
|
193
|
+
const own = (from, key) => (from !== null && typeof from === "object" && Object.hasOwn(from, key) ? from[key] : undefined);
|
|
194
|
+
const out = bare(raw);
|
|
195
|
+
for (const pointer of pointers) {
|
|
196
|
+
const value = pointed(raw, pointer);
|
|
197
|
+
if (value === undefined)
|
|
198
|
+
continue;
|
|
199
|
+
const keys = pointer.split("/").slice(1).map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
200
|
+
let from = raw;
|
|
201
|
+
let into = out;
|
|
202
|
+
keys.forEach((key, i) => {
|
|
203
|
+
const source = own(from, key);
|
|
204
|
+
if (i === keys.length - 1)
|
|
205
|
+
Object.defineProperty(into, key, { value, enumerable: true, writable: true, configurable: true });
|
|
206
|
+
else {
|
|
207
|
+
if (!Object.hasOwn(into, key))
|
|
208
|
+
Object.defineProperty(into, key, { value: bare(source), enumerable: true, writable: true, configurable: true });
|
|
209
|
+
into = into[key];
|
|
210
|
+
}
|
|
211
|
+
from = source;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
const dense = (value) => (Array.isArray(value) ? value.filter(() => true).map(dense) : value !== null && typeof value === "object" ? Object.fromEntries(Object.entries(value).map(([k, v]) => [k, dense(v)])) : value);
|
|
215
|
+
return dense(out);
|
|
216
|
+
}
|
|
173
217
|
const fits = (value) => Buffer.byteLength(JSON.stringify(value), "utf8") <= PAYLOAD_KEPT_BYTES;
|
|
174
218
|
const clipped = (text, n) => (text !== null && text.length > n ? `${text.slice(0, n - 1)}…` : text);
|
|
175
219
|
/** `value` with its objects and lists `depth` deep (deeper ones dropped), a list's first 20, its strings `chars` long. */
|
|
@@ -221,18 +265,19 @@ async function poll(source, reach, cursor) {
|
|
|
221
265
|
lists.set(read.url, feed.list);
|
|
222
266
|
if (!state.seen) {
|
|
223
267
|
// Its start: every item there now is seen, and starts nothing.
|
|
224
|
-
state.seen = items.map((item) => [hashed(item.key), item.updated
|
|
268
|
+
state.seen = items.map((item) => [hashed(item.key), item.updated]);
|
|
269
|
+
state.dates = 2;
|
|
225
270
|
started.push({ url: read.url, count: items.length });
|
|
226
271
|
continue;
|
|
227
272
|
}
|
|
228
273
|
present.set(read.url, items);
|
|
229
|
-
const seen =
|
|
274
|
+
const seen = seenOf(state, feed.list);
|
|
230
275
|
const fresh = [];
|
|
231
276
|
for (const item of items) {
|
|
232
277
|
const was = seen.get(hashed(item.key));
|
|
233
278
|
if (was === undefined)
|
|
234
279
|
fresh.push({ url: read.url, item, update: false, at: item.updated ?? item.published, n: 0 });
|
|
235
|
-
else if (item.updated !== null && item.updated > was)
|
|
280
|
+
else if (item.updated !== null && (was === null ? !feed.list : item.updated > was))
|
|
236
281
|
fresh.push({ url: read.url, item, update: true, at: item.updated, n: 0 });
|
|
237
282
|
}
|
|
238
283
|
candidates.push(fresh);
|
|
@@ -273,27 +318,29 @@ async function poll(source, reach, cursor) {
|
|
|
273
318
|
feeds[url] = state;
|
|
274
319
|
continue;
|
|
275
320
|
}
|
|
276
|
-
const
|
|
321
|
+
const list = lists.get(url) ?? false;
|
|
322
|
+
const seen = seenOf(state, list);
|
|
277
323
|
for (const item of items) {
|
|
278
324
|
const key = hashed(item.key);
|
|
279
325
|
const was = seen.get(key);
|
|
280
326
|
const mark = marks.get(`${url}\n${item.key}`);
|
|
281
327
|
seen.delete(key);
|
|
282
328
|
if (mark && mark.n < upTo)
|
|
283
|
-
seen.set(key, item.updated
|
|
329
|
+
seen.set(key, item.updated);
|
|
330
|
+
// A JSON list's item first seen with no date takes the one it gains, fired on never.
|
|
284
331
|
else if (was !== undefined)
|
|
285
|
-
seen.set(key, was);
|
|
332
|
+
seen.set(key, was === null && list ? item.updated : was);
|
|
286
333
|
}
|
|
287
334
|
const whole = !left.has(url) && !taken.slice(upTo).some((c) => c.url === url);
|
|
288
335
|
const { etag, modified, ...rest } = state;
|
|
289
|
-
feeds[url] = { ...rest, ...(whole && etag ? { etag } : {}), ...(whole && modified ? { modified } : {}), seen: [...seen.entries()].slice(-Math.max(SEEN_KEPT, 2 * items.length)) };
|
|
336
|
+
feeds[url] = { ...rest, dates: 2, ...(whole && etag ? { etag } : {}), ...(whole && modified ? { modified } : {}), seen: [...seen.entries()].slice(-Math.max(SEEN_KEPT, 2 * items.length)) };
|
|
290
337
|
}
|
|
291
338
|
return { [CURSOR]: JSON.stringify({ feeds }) };
|
|
292
339
|
};
|
|
293
340
|
const name = (url) => states[url]?.title ?? url;
|
|
294
341
|
const named = (urls) => (urls.length === 1 ? name(urls[0]) : `${urls.length} feeds`);
|
|
295
342
|
const events = taken.map((c) => {
|
|
296
|
-
const body = payloadOf(c, lists.get(c.url) ?? false, states[c.url]?.title ?? null);
|
|
343
|
+
const body = payloadOf(c, lists.get(c.url) ?? false, states[c.url]?.title ?? null, source.fields);
|
|
297
344
|
const key = `${c.url}\n${c.item.key}${c.item.updated !== null ? `\n${iso(c.item.updated)}` : ""}`;
|
|
298
345
|
// Its cursor made only when the engine asks for it (the last event it records, when the poll is cut short): never one
|
|
299
346
|
// whole cursor per item taken.
|
|
@@ -331,7 +378,7 @@ export const feed = {
|
|
|
331
378
|
// Each item is its own: one run's answer is never handed to the next.
|
|
332
379
|
previousResult: false,
|
|
333
380
|
settings: { scope: "trigger", fields: { [CURSOR]: { public: true }, [LAST_CHECK]: { public: true } } },
|
|
334
|
-
describe: `{kind: "feed", urls: ["https://..."], every_s?: ${DEFAULT_EVERY_S}, items?: "/data/items", id?: "/id", accept?: [{event: "${EVENT}", where?}]}`,
|
|
381
|
+
describe: `{kind: "feed", urls: ["https://..."], every_s?: ${DEFAULT_EVERY_S}, items?: "/data/items", id?: "/id", updated?: "/updated_at", fields?: ["/number", "/title"], accept?: [{event: "${EVENT}", where?}]}`,
|
|
335
382
|
fires: "each new or updated item in its feeds (`feed`: RSS, Atom, JSON Feed or a JSON list), read every every_s seconds, that its `accept` takes",
|
|
336
383
|
firedBy: "`feed`: an item new to one of its feeds, or one seen before with a later updated time, its key from the trigger, the feed's URL, the item's key and its updated time.",
|
|
337
384
|
schemas: [
|
|
@@ -339,14 +386,16 @@ export const feed = {
|
|
|
339
386
|
every_s: { type: "integer", minimum: MIN_EVERY_S, maximum: MAX_EVERY_S, default: DEFAULT_EVERY_S, description: "How often it reads its feeds, in seconds, on a grid from the epoch." },
|
|
340
387
|
items: { type: "string", maxLength: POINTER_CHARS, pattern: "^(/([^~]|~[01])*)?$", description: "For a JSON list: a JSON Pointer to its array of items. Absent: the whole document." },
|
|
341
388
|
id: { type: "string", minLength: 1, maxLength: POINTER_CHARS, pattern: "^/([^~]|~[01])*$", description: "For a JSON list: a JSON Pointer into each item to its id. Absent: /id." },
|
|
389
|
+
updated: { type: "string", minLength: 1, maxLength: POINTER_CHARS, pattern: "^/([^~]|~[01])*$", description: "For a JSON list: a JSON Pointer into each item to the date it last changed (/updated_at). An item whose date moves on fires again with update: true. Absent: a JSON list's item fires once." },
|
|
390
|
+
fields: { type: "array", minItems: 1, maxItems: MAX_FIELDS, items: { type: "string", minLength: 1, maxLength: POINTER_CHARS, pattern: "^/([^~]|~[01])*$" }, description: "For a JSON list: JSON Pointers into each item; the payload's item keeps only these, each at its own place, before the payload's size cap (a pull request that is large whole fits). Absent: the whole item, cut shallower when it is over the cap." },
|
|
342
391
|
accept: { ...ACCEPT_SCHEMA, description: `The items that start a run: each rule's event is "${EVENT}", its where reads the payload (/title, /link, /feed/url; a JSON list's /item/...). None: every item.` },
|
|
343
392
|
}),
|
|
344
393
|
],
|
|
345
394
|
sent: [
|
|
346
|
-
closedSchema({ kind: { const: "feed" }, urls: { type: "array", minItems: 1, maxItems: MAX_FEEDS, items: { type: "string" } }, every_s: { type: "integer", minimum: MIN_EVERY_S, maximum: MAX_EVERY_S } }, { items: { type: "string" }, id: { type: "string" }, accept: ACCEPT_SCHEMA }),
|
|
395
|
+
closedSchema({ kind: { const: "feed" }, urls: { type: "array", minItems: 1, maxItems: MAX_FEEDS, items: { type: "string" } }, every_s: { type: "integer", minimum: MIN_EVERY_S, maximum: MAX_EVERY_S } }, { items: { type: "string" }, id: { type: "string" }, updated: { type: "string" }, fields: { type: "array", items: { type: "string" } }, accept: ACCEPT_SCHEMA }),
|
|
347
396
|
],
|
|
348
397
|
parse(value, _now, bad, issues) {
|
|
349
|
-
issues.push(...unknownSourceFields(value, ["kind", "urls", "every_s", "items", "id", "accept"]));
|
|
398
|
+
issues.push(...unknownSourceFields(value, ["kind", "urls", "every_s", "items", "id", "updated", "fields", "accept"]));
|
|
350
399
|
return fieldsOf(value, bad);
|
|
351
400
|
},
|
|
352
401
|
wellFormed: (source) => fieldsOf(source, () => { }) !== undefined,
|
package/dist/validate.js
CHANGED
|
@@ -8,6 +8,7 @@ import { computerIssues, settingConflict } from "./computer-setting.js";
|
|
|
8
8
|
import { settingsIssues } from "./tool-plane.js";
|
|
9
9
|
import { APPROVALS } from "./approvals.js";
|
|
10
10
|
import { schemaCheck } from "./answer-json.js";
|
|
11
|
+
import { learningSettingIssue } from "./learning-setting.js";
|
|
11
12
|
export const ID = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
12
13
|
/** An inline agent's source or kind in its external reference (POST /runs): no colon, which the reference's key splits on. */
|
|
13
14
|
export const EXTERNAL_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
@@ -119,8 +120,12 @@ export function definitionIssues(definition, { at = "definition", creating = tru
|
|
|
119
120
|
if (d.learning !== undefined) {
|
|
120
121
|
if (d.workflow !== undefined)
|
|
121
122
|
out.push(issue(`${at}.learning`, "not_allowed", "A workflow revision does not learn: only an agentic run reflects on its work.", `Remove ${at}.learning.`));
|
|
122
|
-
else
|
|
123
|
-
|
|
123
|
+
else {
|
|
124
|
+
// true learns notes, skills and workflows, "notes" notes and skills alone; an object is on, with the loop's numbers.
|
|
125
|
+
const wrong = learningSettingIssue(d.learning, `${at}.learning`);
|
|
126
|
+
if (wrong)
|
|
127
|
+
out.push(issue(`${at}.learning`, "wrong_type", wrong));
|
|
128
|
+
}
|
|
124
129
|
}
|
|
125
130
|
// An agentic revision's structured answer: the JSON Schema its final answer's last fenced json block meets, read into a
|
|
126
131
|
// completed run's result.output (answer-json.ts structuredAnswer). A workflow's output is its workflow's own.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComputerProvider, ComputerSpec, HelloResult, Result, ScreenWatch, ScreenWatchHandlers, WatchOptions } from "@parcha/agentrun-computer";
|
|
2
|
+
import { type RecordInput } from "../computer-record.js";
|
|
2
3
|
import { type PlaceView } from "../computer-setting.js";
|
|
3
4
|
import { type KeyTable, type ProviderSettings } from "../computer-keys.js";
|
|
4
5
|
import type { Store } from "../store/index.js";
|
|
@@ -114,6 +115,12 @@ export interface ComputerForClaimDeps {
|
|
|
114
115
|
readonly revokeMount?: () => Promise<void>;
|
|
115
116
|
/** The live view's registration for a desktop or a phone (proxy-only). Absent: no view is opened. */
|
|
116
117
|
readonly openComputerView?: OpenComputerView;
|
|
118
|
+
/** Where the agent's setting asks for a video of its desktop's or phone's screen (computer.record): the run's
|
|
119
|
+
* recordings folder on this machine (paths.ts recordingsFolder) and where its lines on the run's timeline go
|
|
120
|
+
* (computer-record.ts startRecording; for tests, the program in ffmpeg's place and the bounds). The computer this claim
|
|
121
|
+
* attaches is recorded through a watch of its own, with or without a viewer, until its release, the run's end or its
|
|
122
|
+
* park. Absent: nothing is recorded. */
|
|
123
|
+
readonly recordings?: Pick<RecordInput, "folder" | "say" | "ffmpeg" | "limits">;
|
|
117
124
|
/** Told once, before the claim waits on its computer's image (a provider that makes its own: Docker's recipe built on
|
|
118
125
|
* a host that lacks it, or a named image pulled); never when the host has it. The run's caller says it on the run's
|
|
119
126
|
* timeline. Absent: nothing is said. */
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// for this run under this claim (labels agentrun.run and agentrun.epoch, the run's folder mounted only where the provider
|
|
4
4
|
// mounts it), with a hold and its live view when it is a desktop or a phone, and released once at the run's end. The hold
|
|
5
5
|
// goes back to the spec (`held`), whose adapter loop journals it and applies the owner's take-over and hand-back rows to it
|
|
6
|
-
// (runner/computer-journal.ts); the live view (computer-live.ts openClaimView) drives the same hold.
|
|
6
|
+
// (runner/computer-journal.ts); the live view (computer-live.ts openClaimView) drives the same hold. Where the setting
|
|
7
|
+
// asks for it (computer.record), the screen is recorded too (computer-record.ts), until the release or a park. A computer that cannot
|
|
7
8
|
// be had is refused in words with code computer_unavailable; kind none, or no setting where the server's default is none,
|
|
8
9
|
// is no computer.
|
|
9
10
|
//
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
// deleted, at the run's end. A run that finds it held by another run still going is refused, naming that run.
|
|
32
33
|
import { randomUUID } from "node:crypto";
|
|
33
34
|
import { isBrowserProvider, ownerFilter, releaseOlder, RUN_LABEL, runLabels } from "@parcha/agentrun-computer";
|
|
35
|
+
import { startRecording } from "../computer-record.js";
|
|
34
36
|
import { computerOfPlace } from "../computer-setting.js";
|
|
35
37
|
import { KEY_TABLE, providerOptions } from "../computer-keys.js";
|
|
36
38
|
import { getSealedKey } from "../server-keys.js";
|
|
@@ -558,7 +560,8 @@ store, deps) {
|
|
|
558
560
|
return launched;
|
|
559
561
|
},
|
|
560
562
|
};
|
|
561
|
-
const
|
|
563
|
+
const setting = await settingOf(launch, store);
|
|
564
|
+
const resolved = await resolveComputer(setting, deps.mode, kinds, side);
|
|
562
565
|
if ("refused" in resolved)
|
|
563
566
|
throw unavailable(resolved.refused);
|
|
564
567
|
if (resolved.kind === "none")
|
|
@@ -589,6 +592,7 @@ store, deps) {
|
|
|
589
592
|
let hold;
|
|
590
593
|
let held;
|
|
591
594
|
let view;
|
|
595
|
+
let recording;
|
|
592
596
|
if (computer && (computer.kind === "desktop" || computer.kind === "phone")) {
|
|
593
597
|
const theHold = computerHold();
|
|
594
598
|
if (deps.openComputerView && made?.watch) {
|
|
@@ -604,6 +608,9 @@ store, deps) {
|
|
|
604
608
|
}
|
|
605
609
|
view = opened.view;
|
|
606
610
|
}
|
|
611
|
+
// The agent asks for a video of the screen (computer.record): a watch of the recorder's own, while this claim holds it.
|
|
612
|
+
if (deps.recordings && made?.watch && setting?.record === true)
|
|
613
|
+
recording = startRecording({ ...deps.recordings, watch: made.watch, tag: made.id, kind: computer.kind });
|
|
607
614
|
// The run's end closes the hold (workspace/computer-hold.ts close()): a take in force ends `released` (the computer
|
|
608
615
|
// goes; the composer's `ended` ViewEnd maps onto it), the agent's open ask is let go at once, and nothing is taken after.
|
|
609
616
|
endHold = () => theHold.close();
|
|
@@ -612,6 +619,7 @@ store, deps) {
|
|
|
612
619
|
}
|
|
613
620
|
let released;
|
|
614
621
|
const release = (why = "released") => (released ??= (async () => {
|
|
622
|
+
await recording?.stop(typeof why === "object" ? "parked" : why);
|
|
615
623
|
await Promise.resolve(view?.close(why)).catch(() => undefined);
|
|
616
624
|
endHold();
|
|
617
625
|
try {
|
|
@@ -651,6 +659,8 @@ store, deps) {
|
|
|
651
659
|
// The live view ends (its frames and any take-over), saying what the run waits for and until when the computer is
|
|
652
660
|
// kept, never that it ended; the hold with it; the machine and its mount stay.
|
|
653
661
|
released = (async () => {
|
|
662
|
+
// The recording pauses: the claim that resumes the run goes on in a new file.
|
|
663
|
+
await recording?.stop("parked");
|
|
654
664
|
await Promise.resolve(view?.close({ parked: cause, until: row.until })).catch(() => undefined);
|
|
655
665
|
endHold();
|
|
656
666
|
await keeps.computer.close();
|
|
@@ -10,6 +10,10 @@ export declare const runKey: (agentId: string, runId: string) => string;
|
|
|
10
10
|
export declare const learningKey: (agentId: string) => string;
|
|
11
11
|
/** Run `runId`'s folder, the root of its Workspace: `<data>/disk/agents/<agent>/runs/<run>/work`. */
|
|
12
12
|
export declare const runFolder: (dataDir: string, agentId: string, runId: string) => string;
|
|
13
|
+
/** The recordings folder's name: beside a run's folder on this machine, and the run files route's path to it. */
|
|
14
|
+
export declare const RECORDINGS = "recordings";
|
|
15
|
+
/** Run `runId`'s recordings on this machine, beside its folder: `<data>/disk/agents/<agent>/runs/<run>/recordings`. */
|
|
16
|
+
export declare const recordingsFolder: (dataDir: string, agentId: string, runId: string) => string;
|
|
13
17
|
/** Agent `agentId`'s learning folder, the root of its learning Workspace: `<data>/disk/agents/<agent>/learning`. */
|
|
14
18
|
export declare const agentLearningFolder: (dataDir: string, agentId: string) => string;
|
|
15
19
|
/** Agent `agentId`'s home as a key from a disk's root: `agents/<agent>/home`. */
|
package/dist/workspace/paths.js
CHANGED
|
@@ -11,6 +11,11 @@
|
|
|
11
11
|
// no Workspace: a harness's working directory, and its private files
|
|
12
12
|
// in harness/<claim's epoch>, swept at that claim's end
|
|
13
13
|
// (runner/cli-run-spec.ts)
|
|
14
|
+
// <data>/disk/agents/<agent>/runs/<run>/recordings
|
|
15
|
+
// a run's screen recordings (recordingsFolder): beside work/, never in
|
|
16
|
+
// its Workspace, so the agent neither reads nor changes them; on this
|
|
17
|
+
// machine in either mode, as the runner records them
|
|
18
|
+
// (computer-record.ts)
|
|
14
19
|
// <agent> is the id in lower case, a dash, and 16 hex digits of the id's SHA-256, so ids that differ only in case never
|
|
15
20
|
// share a folder on a disk that folds case.
|
|
16
21
|
//
|
|
@@ -40,6 +45,10 @@ export const runKey = (agentId, runId) => `agents/${agentDirName(agentId)}/runs/
|
|
|
40
45
|
export const learningKey = (agentId) => `agents/${agentDirName(agentId)}/learning`;
|
|
41
46
|
/** Run `runId`'s folder, the root of its Workspace: `<data>/disk/agents/<agent>/runs/<run>/work`. */
|
|
42
47
|
export const runFolder = (dataDir, agentId, runId) => join(dataDir, DISK_DIR, runKey(agentId, runId));
|
|
48
|
+
/** The recordings folder's name: beside a run's folder on this machine, and the run files route's path to it. */
|
|
49
|
+
export const RECORDINGS = "recordings";
|
|
50
|
+
/** Run `runId`'s recordings on this machine, beside its folder: `<data>/disk/agents/<agent>/runs/<run>/recordings`. */
|
|
51
|
+
export const recordingsFolder = (dataDir, agentId, runId) => join(dirname(runFolder(dataDir, agentId, runId)), RECORDINGS);
|
|
43
52
|
/** Agent `agentId`'s learning folder, the root of its learning Workspace: `<data>/disk/agents/<agent>/learning`. */
|
|
44
53
|
export const agentLearningFolder = (dataDir, agentId) => join(dataDir, DISK_DIR, learningKey(agentId));
|
|
45
54
|
/** Agent `agentId`'s home as a key from a disk's root: `agents/<agent>/home`. */
|
|
@@ -10,7 +10,8 @@ export type { ComputerSettingKind, KindCapabilities, ProviderEntry, ShellPlace }
|
|
|
10
10
|
/** An agent's computer setting. `image`: the one of the provider's configurations it selects; absent, the default. A
|
|
11
11
|
* sandbox's may ask for GPUs. `persistent`: the agent keeps its own computer between runs (agent-computer.ts). A
|
|
12
12
|
* desktop's or a phone's `surface` and `exec` go to the run's tools on the RunComputer (run-tools.ts); `exec: false`
|
|
13
|
-
* also mounts no folder in it and gives the run no shell.
|
|
13
|
+
* also mounts no folder in it and gives the run no shell. A desktop's or a phone's `record`: the claim records its
|
|
14
|
+
* screen (computer-for-claim.ts, computer-record.ts). */
|
|
14
15
|
export type ComputerSetting = {
|
|
15
16
|
readonly kind: string;
|
|
16
17
|
readonly provider?: string | null;
|
|
@@ -19,6 +20,7 @@ export type ComputerSetting = {
|
|
|
19
20
|
readonly persistent?: boolean;
|
|
20
21
|
readonly surface?: "code" | "tools";
|
|
21
22
|
readonly exec?: boolean;
|
|
23
|
+
readonly record?: boolean;
|
|
22
24
|
};
|
|
23
25
|
/** Whether a computer (or its setting) takes its agent's programs away: `exec: false`. Only a desktop or a phone takes
|
|
24
26
|
* `exec` (computer-setting.ts refuses it on any other kind at save), so a computer without programs is one of those. */
|
|
@@ -92,7 +92,7 @@ export type RunHands = {
|
|
|
92
92
|
/** A desktop's or a phone's computer as a codemode script gets it bound; none for any other computer. */
|
|
93
93
|
readonly computer?: ScriptComputer;
|
|
94
94
|
/** The run's end, after its background processes are ended and before the computer is let go: bash's full outputs
|
|
95
|
-
* and its TMPDIR swept. */
|
|
95
|
+
* and its TMPDIR swept, through the computer when it mounts the folder. */
|
|
96
96
|
sweep(): Promise<void>;
|
|
97
97
|
};
|
|
98
98
|
/** The run's hands and host executors on `workspace`, attached to `computer` when its kind and provider mount the folder,
|
|
@@ -94,9 +94,20 @@ export async function runHands(workspace, claimed, options) {
|
|
|
94
94
|
...((computer?.kind === "desktop" || computer?.kind === "phone") && computer.surface ? { surface: computer.surface } : {}),
|
|
95
95
|
...(script ? { computer: script } : {}),
|
|
96
96
|
async sweep() {
|
|
97
|
-
// Through the run
|
|
98
|
-
|
|
99
|
-
|
|
97
|
+
// Through the Workspace the run wrote them through: the computer's when it mounts the folder, since on Archil the
|
|
98
|
+
// run's own Workspace is the disk's file API, which the mount's write delegation refuses until the computer's
|
|
99
|
+
// release. A computer that no longer answers leaves a Mode 1 folder to the run's own Workspace (a folder of this
|
|
100
|
+
// machine, which no delegation holds); a Mode 2 one keeps its scratch, said by the release's log.
|
|
101
|
+
for (const dir of [OUTPUT_DIR, TMP_DIR]) {
|
|
102
|
+
try {
|
|
103
|
+
await attached.remove(dir, { recursive: true, force: true });
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
if (mounted === undefined || options.mode === 2)
|
|
107
|
+
throw error;
|
|
108
|
+
await workspace.remove(dir, { recursive: true, force: true });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
100
111
|
},
|
|
101
112
|
};
|
|
102
113
|
}
|
package/launcher/agentrun-serve
CHANGED
|
@@ -8,10 +8,13 @@
|
|
|
8
8
|
# Each secret named below that is set goes into one pipe as NAME=VALUE and a NUL, AGENTRUN_SECRETS_LEN bytes in all,
|
|
9
9
|
# on fd AGENTRUN_SECRETS_FD; the server reads exactly that many bytes first thing and closes the pipe. First, each
|
|
10
10
|
# secret moves out of the environment into this shell's own memory, so no process it starts (mktemp, mkfifo, rm, env)
|
|
11
|
-
# inherits one; only this launcher's own initial environment,
|
|
12
|
-
# pipe is a FIFO whose name is gone before any secret is written, and only this shell writes it, with its
|
|
13
|
-
# printf
|
|
14
|
-
#
|
|
11
|
+
# inherits one; only this launcher's own initial environment ever held them, and its writer's, a fork of it (below). The
|
|
12
|
+
# pipe is a FIFO whose name is gone before any secret is written, and only that fork of this shell writes it, with its
|
|
13
|
+
# builtin printf, as the server reads, so the secrets may come to any length; it is gone once the last byte is in the
|
|
14
|
+
# pipe, or at its next write once the server has exited without reading. `env -u` drops every name from what COMMAND
|
|
15
|
+
# inherits too. The condition:
|
|
16
|
+
# this runs before any run's process exists. A process of the same user started earlier could open the FIFO while it is
|
|
17
|
+
# named.
|
|
15
18
|
#
|
|
16
19
|
# AGENTRUN_SEAL_KEY, the key the server keeps every secret under (src/seal-key.ts), is one of them. Not set, the
|
|
17
20
|
# server keeps its own in seal/seal.key in its data directory, beside the store, made at its first start: this launcher
|
|
@@ -25,8 +28,7 @@
|
|
|
25
28
|
#
|
|
26
29
|
# ARCHIL_API_KEY, the Archil account key, and every computer provider's key from E2B_API_KEY to MODAL_TOKEN_SECRET
|
|
27
30
|
# (src/computer-keys.ts COMPUTER_KEY_NAMES): only the server's and the runner's own code reads one (the Archil claim,
|
|
28
|
-
# a computer's create), and no run is handed one.
|
|
29
|
-
# pipe holds (below), so save it in Settings -> Computers instead, or use an Ed25519 key.
|
|
31
|
+
# a computer's create), and no run is handed one.
|
|
30
32
|
#
|
|
31
33
|
# After MODAL_TOKEN_SECRET, the keys of pi-ai's other providers, which a pi run's model may need (GEMINI_API_KEY,
|
|
32
34
|
# DEEPSEEK_API_KEY, Bedrock's AWS keys, ...): the server holds each, and a run's process gets one over its pipe only when
|
|
@@ -34,7 +36,7 @@
|
|
|
34
36
|
# here. Any other variable named like a key (a KEY, TOKEN, SECRET, PASSWORD, PASSWD, PASS, PAT, CREDENTIAL, CREDENTIALS or
|
|
35
37
|
# DSN segment, or a last PWD after another) stays in the server's environment, as this list does not take it, and in no
|
|
36
38
|
# run's: name it here to keep it from the server's too.
|
|
37
|
-
SECRETS='AGENTRUN_TOKEN AGENTRUN_TOKENS AGENTRUN_API_KEY AGENTRUN_STORE_URL AGENT_MODEL_API_KEY OPENAI_API_KEY ANTHROPIC_API_KEY BROWSERBASE_API_KEY BROWSERBASE_PROJECT_ID KERNEL_API_KEY OPENROUTER_API_KEY TYPESAFE_API_KEY PARALLEL_API_KEY MONID_API_KEY AGENTRUN_SEAL_KEY ARCHIL_API_KEY E2B_API_KEY ORGO_API_KEY PHONE_HARNESS_API_KEY AGENT37_API_KEY AGENT37_SSH_KEY DAYTONA_API_KEY MODAL_TOKEN_ID MODAL_TOKEN_SECRET ANTHROPIC_AUTH_TOKEN ANTHROPIC_OAUTH_TOKEN AI_GATEWAY_API_KEY ANT_LING_API_KEY AWS_ACCESS_KEY_ID AWS_BEARER_TOKEN_BEDROCK AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AZURE_OPENAI_API_KEY BASETEN_API_KEY CEREBRAS_API_KEY CLOUDFLARE_API_KEY COPILOT_GITHUB_TOKEN DEEPSEEK_API_KEY FIREWORKS_API_KEY GEMINI_API_KEY GOOGLE_CLOUD_API_KEY GROQ_API_KEY HF_TOKEN KIMI_API_KEY META_API_KEY MINIMAX_API_KEY MINIMAX_CN_API_KEY MISTRAL_API_KEY MOONSHOT_API_KEY NVIDIA_API_KEY OPENCODE_API_KEY QWEN_TOKEN_PLAN_API_KEY QWEN_TOKEN_PLAN_CN_API_KEY RADIUS_API_KEY TOGETHER_API_KEY XAI_API_KEY XIAOMI_API_KEY XIAOMI_TOKEN_PLAN_AMS_API_KEY XIAOMI_TOKEN_PLAN_CN_API_KEY XIAOMI_TOKEN_PLAN_SGP_API_KEY ZAI_API_KEY ZAI_CODING_CN_API_KEY'
|
|
39
|
+
SECRETS='AGENTRUN_TOKEN AGENTRUN_TOKENS AGENTRUN_API_KEY AGENTRUN_STORE_URL AGENT_MODEL_API_KEY OPENAI_API_KEY ANTHROPIC_API_KEY BROWSERBASE_API_KEY BROWSERBASE_PROJECT_ID KERNEL_API_KEY OPENROUTER_API_KEY TYPESAFE_API_KEY PARALLEL_API_KEY MONID_API_KEY AGENTRUN_SEAL_KEY ARCHIL_API_KEY E2B_API_KEY ORGO_API_KEY PHONE_HARNESS_API_KEY AGENT37_API_KEY AGENT37_SSH_KEY DAYTONA_API_KEY BOXD_API_KEY MORPH_API_KEY CLOUDFLARE_RELAY_TOKEN FLY_API_TOKEN MODAL_TOKEN_ID MODAL_TOKEN_SECRET ANTHROPIC_AUTH_TOKEN ANTHROPIC_OAUTH_TOKEN AI_GATEWAY_API_KEY ANT_LING_API_KEY AWS_ACCESS_KEY_ID AWS_BEARER_TOKEN_BEDROCK AWS_SECRET_ACCESS_KEY AWS_SESSION_TOKEN AZURE_OPENAI_API_KEY BASETEN_API_KEY CEREBRAS_API_KEY CLOUDFLARE_API_KEY COPILOT_GITHUB_TOKEN DEEPSEEK_API_KEY FIREWORKS_API_KEY GEMINI_API_KEY GOOGLE_CLOUD_API_KEY GROQ_API_KEY HF_TOKEN KIMI_API_KEY META_API_KEY MINIMAX_API_KEY MINIMAX_CN_API_KEY MISTRAL_API_KEY MOONSHOT_API_KEY NVIDIA_API_KEY OPENCODE_API_KEY QWEN_TOKEN_PLAN_API_KEY QWEN_TOKEN_PLAN_CN_API_KEY RADIUS_API_KEY TOGETHER_API_KEY XAI_API_KEY XIAOMI_API_KEY XIAOMI_TOKEN_PLAN_AMS_API_KEY XIAOMI_TOKEN_PLAN_CN_API_KEY XIAOMI_TOKEN_PLAN_SGP_API_KEY ZAI_API_KEY ZAI_CODING_CN_API_KEY'
|
|
38
40
|
set -eu
|
|
39
41
|
# Each secret out of the environment and into an unexported variable of this shell (agentrun_secret_<NAME>).
|
|
40
42
|
for name in $SECRETS; do
|
|
@@ -53,14 +55,18 @@ locale=${LC_ALL-}
|
|
|
53
55
|
locale_set=${LC_ALL+x}
|
|
54
56
|
LC_ALL=C
|
|
55
57
|
|
|
56
|
-
# Every other
|
|
58
|
+
# Every other program this launcher runs, it runs here, before it writes a secret.
|
|
57
59
|
dir=$(mktemp -d "${TMPDIR:-/tmp}/agentrun-serve.XXXXXX")
|
|
58
60
|
mkfifo -m 600 "$dir/secrets"
|
|
59
|
-
|
|
61
|
+
# The server's end read-only on 3, the writer's write-only on 4: once the server is gone, no read end is left, and the
|
|
62
|
+
# writer's next write fails (EPIPE) rather than wait. Opened read-write first, so neither one-way open waits for the other.
|
|
63
|
+
exec 4<>"$dir/secrets"
|
|
64
|
+
exec 3<"$dir/secrets"
|
|
65
|
+
exec 4>"$dir/secrets"
|
|
60
66
|
rm -f "$dir/secrets"
|
|
61
67
|
rmdir "$dir"
|
|
62
68
|
|
|
63
|
-
# From here to the exec: this shell's builtins only.
|
|
69
|
+
# From here to the exec: this shell's builtins and forks of it only.
|
|
64
70
|
total=0
|
|
65
71
|
for name in $SECRETS; do
|
|
66
72
|
eval "given=\${agentrun_secret_$name+x}"
|
|
@@ -68,20 +74,21 @@ for name in $SECRETS; do
|
|
|
68
74
|
eval "value=\${agentrun_secret_$name}"
|
|
69
75
|
total=$((total + ${#name} + ${#value} + 2))
|
|
70
76
|
done
|
|
71
|
-
#
|
|
72
|
-
#
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
for name in $SECRETS; do
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
77
|
+
# The writer: a fork of this shell, so still its builtin printf, with the launcher's command line, which holds no secret.
|
|
78
|
+
# It writes beside the server rather than before it, so a pipe of any size is enough. It holds no read end of the pipe and none of the caller's stdio (a
|
|
79
|
+
# caller waiting for its output to end waits for the server alone). Forked twice, it belongs to init (in the image, tini)
|
|
80
|
+
# and is reaped there, never left a zombie under a server that reaps only its own children.
|
|
81
|
+
(
|
|
82
|
+
(
|
|
83
|
+
for name in $SECRETS; do
|
|
84
|
+
eval "given=\${agentrun_secret_$name+x}"
|
|
85
|
+
[ -n "$given" ] || continue
|
|
86
|
+
eval "value=\${agentrun_secret_$name}"
|
|
87
|
+
printf '%s=%s\000' "$name" "$value" >&4 || exit 1
|
|
88
|
+
done
|
|
89
|
+
) &
|
|
90
|
+
) 3<&- </dev/null >/dev/null 2>&1
|
|
91
|
+
exec 4>&-
|
|
85
92
|
if [ -n "$locale_set" ]; then LC_ALL=$locale; else unset LC_ALL; fi
|
|
86
93
|
|
|
87
94
|
if [ "${1-}" = "--" ]; then
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parcha/agentrun-serve",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.43",
|
|
4
4
|
"description": "The AgentRun server: the /v2 API and console over one store, with runners that run your agents; the deployable process of the AgentRun platform.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agentrun",
|
|
@@ -54,20 +54,21 @@
|
|
|
54
54
|
"@earendil-works/pi-coding-agent": "1.5.2",
|
|
55
55
|
"@modelcontextprotocol/client": "2.4.0",
|
|
56
56
|
"@modelcontextprotocol/server": "2.4.0",
|
|
57
|
-
"@parcha/agentrun-computer": "0.1.0-beta.
|
|
58
|
-
"@parcha/agentrun-decisions": "0.1.0-beta.
|
|
59
|
-
"@parcha/agentrun-dsl": "0.1.0-beta.
|
|
60
|
-
"@parcha/agentrun-harness-claude": "0.1.0-beta.
|
|
61
|
-
"@parcha/agentrun-harness-codex": "0.1.0-beta.
|
|
62
|
-
"@parcha/agentrun-jev": "0.1.0-beta.
|
|
63
|
-
"@parcha/agentrun-kernel": "0.1.0-beta.
|
|
64
|
-
"@parcha/pi-browser": "0.1.0-beta.
|
|
57
|
+
"@parcha/agentrun-computer": "0.1.0-beta.43",
|
|
58
|
+
"@parcha/agentrun-decisions": "0.1.0-beta.43",
|
|
59
|
+
"@parcha/agentrun-dsl": "0.1.0-beta.43",
|
|
60
|
+
"@parcha/agentrun-harness-claude": "0.1.0-beta.43",
|
|
61
|
+
"@parcha/agentrun-harness-codex": "0.1.0-beta.43",
|
|
62
|
+
"@parcha/agentrun-jev": "0.1.0-beta.43",
|
|
63
|
+
"@parcha/agentrun-kernel": "0.1.0-beta.43",
|
|
64
|
+
"@parcha/pi-browser": "0.1.0-beta.43",
|
|
65
65
|
"@secretlint/core": "13.1.0",
|
|
66
66
|
"@secretlint/profiler": "13.1.0",
|
|
67
67
|
"@secretlint/secretlint-rule-preset-recommend": "13.1.0",
|
|
68
68
|
"croner": "11.0.0",
|
|
69
69
|
"disk": "1.12.0",
|
|
70
70
|
"fast-xml-parser": "4.5.7",
|
|
71
|
+
"ical.js": "2.2.1",
|
|
71
72
|
"imapflow": "2.11.0",
|
|
72
73
|
"ipaddr.js": "2.5.0",
|
|
73
74
|
"mailparser": "3.14.3",
|