@parcha/agentrun-serve 0.1.0-beta.40 → 0.1.0-beta.42
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 +130 -0
- package/NOTICE +2 -0
- package/README.md +149 -21
- package/dist/agent-rows.d.ts +1 -1
- package/dist/agents-store.js +3 -1
- package/dist/api-only.d.ts +3 -1
- package/dist/api-only.js +4 -2
- package/dist/api-token.d.ts +30 -0
- package/dist/api-token.js +89 -0
- 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 +22 -6
- package/dist/composio-made.d.ts +54 -0
- package/dist/composio-made.js +83 -0
- package/dist/composio-preset.d.ts +16 -8
- package/dist/composio-preset.js +106 -43
- package/dist/composio-triggers.d.ts +7 -2
- package/dist/composio-triggers.js +13 -7
- package/dist/computer-attach.d.ts +29 -11
- package/dist/computer-attach.js +141 -47
- package/dist/computer-keys.d.ts +4 -0
- package/dist/computer-keys.js +5 -0
- 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.d.ts +11 -1
- package/dist/computers.js +23 -26
- package/dist/console/assets/{index-B8Zn1Iqn.css → index-C3gNPz58.css} +1 -1
- package/dist/console/assets/index-DYJ_wj27.js +711 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.js +9 -2
- package/dist/eval-feed.d.ts +26 -0
- package/dist/eval-feed.js +72 -0
- package/dist/eval-mailbox.d.ts +4 -1
- package/dist/eval-mailbox.js +11 -3
- package/dist/exa-keyless.d.ts +1 -1
- package/dist/exa-keyless.js +1 -1
- package/dist/feed/feed-faux.d.ts +62 -0
- package/dist/feed/feed-faux.js +123 -0
- package/dist/feed/fetch.d.ts +41 -0
- package/dist/feed/fetch.js +128 -0
- package/dist/feed/parse.d.ts +42 -0
- package/dist/feed/parse.js +291 -0
- 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/learn/check.d.ts +17 -1
- package/dist/learn/check.js +240 -5
- package/dist/learn/compile.d.ts +48 -27
- package/dist/learn/compile.js +134 -101
- package/dist/learn/promote.d.ts +61 -5
- package/dist/learn/promote.js +12 -2
- package/dist/learned-nodes.d.ts +21 -4
- package/dist/learned-nodes.js +21 -8
- package/dist/learned-workflow.d.ts +3 -3
- package/dist/learned-workflow.js +14 -5
- package/dist/learning-setting.d.ts +23 -0
- package/dist/learning-setting.js +51 -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 +23 -1
- package/dist/mcp-oauth.js +46 -5
- package/dist/mcp-pin-first.d.ts +4 -2
- package/dist/mcp-pin-first.js +4 -3
- package/dist/mcp-private-hosts.d.ts +13 -0
- package/dist/mcp-private-hosts.js +16 -0
- package/dist/mcp-servers-store.d.ts +58 -5
- package/dist/mcp-servers-store.js +136 -17
- package/dist/mcp.d.ts +2 -2
- package/dist/mcp.js +2 -2
- package/dist/observation/http.d.ts +4 -1
- package/dist/observation/http.js +5 -4
- package/dist/openapi.d.ts +1 -0
- package/dist/openapi.js +151 -21
- package/dist/print.d.ts +6 -3
- package/dist/print.js +4 -2
- package/dist/run-files.d.ts +6 -2
- package/dist/run-files.js +29 -7
- package/dist/run-labels.d.ts +23 -0
- package/dist/run-labels.js +79 -0
- package/dist/run-learning-served.d.ts +1 -1
- 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/run-secrets.js +12 -4
- package/dist/runner/adapter-loop.d.ts +1 -1
- package/dist/runner/adapter-loop.js +94 -16
- package/dist/runner/adapter-run-spec.d.ts +19 -0
- package/dist/runner/adapter-run-spec.js +57 -36
- package/dist/runner/beside.d.ts +6 -3
- package/dist/runner/beside.js +9 -7
- package/dist/runner/cli-run-spec.js +41 -32
- package/dist/runner/conformance/harness.js +69 -14
- package/dist/runner/conformance/subject.d.ts +4 -1
- package/dist/runner/feedback-round.d.ts +9 -25
- package/dist/runner/feedback-round.js +22 -40
- package/dist/runner/learning-end.d.ts +17 -7
- package/dist/runner/learning-end.js +79 -53
- package/dist/runner/main.d.ts +12 -1
- package/dist/runner/main.js +31 -4
- package/dist/runner/mcp-claim.d.ts +3 -0
- package/dist/runner/mcp-claim.js +1 -1
- package/dist/runner/mcp-run.d.ts +6 -2
- package/dist/runner/mcp-run.js +5 -3
- package/dist/runner/model-route.d.ts +4 -2
- package/dist/runner/model-route.js +8 -8
- package/dist/runner/promotion.d.ts +44 -4
- package/dist/runner/promotion.js +323 -21
- package/dist/runner/reflect-hook.d.ts +5 -0
- package/dist/runner/reflect-hook.js +22 -14
- package/dist/runner/store-secrets.js +3 -1
- package/dist/runner/workflow-first.d.ts +6 -11
- package/dist/runner/workflow-first.js +16 -20
- package/dist/runs-over-store.d.ts +1 -1
- package/dist/runs-over-store.js +5 -2
- package/dist/sdk/runs.d.ts +7 -1
- package/dist/sdk/runs.js +21 -7
- package/dist/secret-cut.js +3 -1
- package/dist/secrets.js +5 -3
- package/dist/server.d.ts +31 -5
- package/dist/server.js +240 -61
- package/dist/store/agent-body.d.ts +5 -3
- package/dist/store/agent-body.js +14 -10
- package/dist/store/dialect.d.ts +3 -0
- package/dist/store/dialect.js +1 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/postgres/dialect.js +1 -0
- package/dist/store/postgres/migrations/0015_run_labels.sql +5 -0
- package/dist/store/postgres/migrations/0016_minted_tokens.sql +21 -0
- package/dist/store/schema.d.ts +9 -0
- package/dist/store/schema.js +26 -2
- package/dist/store/sqlite/connection.js +11 -3
- package/dist/store/sqlite/run-patch.d.ts +2 -1
- package/dist/store/sqlite/run-patch.js +3 -2
- package/dist/store/sqlite/store.js +64 -10
- package/dist/store/store.d.ts +38 -1
- package/dist/store-reads/journal.js +2 -1
- package/dist/store-reads/learning.d.ts +1 -1
- package/dist/store-reads/learning.js +6 -1
- package/dist/store-reads/loop.d.ts +1 -0
- package/dist/store-reads/loop.js +14 -4
- package/dist/store-reads/runs.d.ts +4 -3
- package/dist/store-reads/runs.js +3 -2
- package/dist/store-view.d.ts +5 -0
- package/dist/store-view.js +8 -2
- package/dist/template-eval.d.ts +11 -0
- package/dist/template-eval.js +177 -52
- package/dist/templates.d.ts +13 -1
- package/dist/templates.js +89 -18
- package/dist/timeline/computer.js +2 -1
- package/dist/timeline/origin.d.ts +1 -1
- package/dist/timeline/origin.js +2 -2
- package/dist/tool-list.js +1 -0
- package/dist/tools.d.ts +7 -0
- package/dist/tools.js +11 -0
- package/dist/trigger-adapter.d.ts +9 -4
- package/dist/trigger-adapters.js +2 -1
- package/dist/trigger-feed.d.ts +12 -0
- package/dist/trigger-feed.js +420 -0
- package/dist/triggers.d.ts +2 -1
- package/dist/triggers.js +23 -5
- package/dist/validate.js +7 -2
- package/dist/webhooks.js +9 -5
- package/dist/workspace/computer-deps.d.ts +5 -1
- package/dist/workspace/computer-deps.js +2 -2
- package/dist/workspace/computer-for-claim.d.ts +7 -0
- package/dist/workspace/computer-for-claim.js +12 -2
- package/dist/workspace/index.d.ts +1 -0
- package/dist/workspace/index.js +2 -0
- package/dist/workspace/paths.d.ts +4 -0
- package/dist/workspace/paths.js +9 -0
- package/dist/workspace/resolve-computer.d.ts +35 -4
- package/dist/workspace/resolve-computer.js +47 -9
- package/launcher/agentrun-serve +34 -22
- package/package.json +11 -9
- package/templates/README.md +38 -4
- package/dist/console/assets/index-Jbxjcmdp.js +0 -705
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// The server's calendar through /v2/settings/calendar (address.ts), the owner's session's alone: each of its operations is
|
|
2
|
+
// a secret write (secret-writes.ts), its view included, as the email account's is, since the address reads the calendar.
|
|
3
|
+
// GET /v2/settings/calendar {configured, host, name, time_zone}: never the address
|
|
4
|
+
// PUT /v2/settings/calendar {url} saved (webcal:// read as https://); the calendar read once for its own name and
|
|
5
|
+
// time zone, a read that fails saving it all the same (name and time_zone null)
|
|
6
|
+
// DELETE /v2/settings/calendar forgotten
|
|
7
|
+
// POST /v2/settings/calendar/test the saved calendar read (or the body's {url}, saved nowhere), answered in words:
|
|
8
|
+
// "Work: 214 events, time zone America/New_York, next: Standup, Mon Nov 17 09:30"
|
|
9
|
+
// ical.js loads at a read only (fetch.ts, parse.ts), never with the server.
|
|
10
|
+
import { registerSecretWrite } from "../secret-writes.js";
|
|
11
|
+
import { isObject } from "../validate.js";
|
|
12
|
+
import { bodyAddress, calendarView, noCalendar, openCalendar, removeCalendar, saveCalendar, scrubAddress } from "./address.js";
|
|
13
|
+
/** The routes, by their operation names. */
|
|
14
|
+
export const CALENDAR_ROUTES = new Set(["getCalendar", "saveCalendar", "deleteCalendar", "testCalendar"]);
|
|
15
|
+
for (const operation of CALENDAR_ROUTES)
|
|
16
|
+
registerSecretWrite(operation, () => true);
|
|
17
|
+
/** An event's start as a test says it, in the calendar's zone: "Mon Nov 17 09:30", or an all-day one's day, "Thu Nov 26". */
|
|
18
|
+
function whenOf(event, zone) {
|
|
19
|
+
if (event.all_day) {
|
|
20
|
+
const day = new Date(`${event.start}T12:00:00Z`);
|
|
21
|
+
return new Intl.DateTimeFormat("en-US", { timeZone: "UTC", weekday: "short", month: "short", day: "numeric" }).format(day).replace(",", "");
|
|
22
|
+
}
|
|
23
|
+
const parts = Object.fromEntries(new Intl.DateTimeFormat("en-US", { timeZone: zone, weekday: "short", month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", hourCycle: "h23" }).formatToParts(new Date(event.start)).map((part) => [part.type, part.value]));
|
|
24
|
+
return `${parts.weekday} ${parts.month} ${parts.day} ${parts.hour}:${parts.minute}`;
|
|
25
|
+
}
|
|
26
|
+
/** The calendar at `url` read and said in words; a read that fails, its words (never the address). */
|
|
27
|
+
async function tested(url, deps) {
|
|
28
|
+
const { CalendarError, readCalendar } = await import("./fetch.js");
|
|
29
|
+
const { RepeatsError, summaryOf } = await import("./parse.js");
|
|
30
|
+
// The address, and once read every address it was redirected to.
|
|
31
|
+
let secret = [url];
|
|
32
|
+
const scrub = (text) => scrubAddress(text, secret);
|
|
33
|
+
try {
|
|
34
|
+
const calendar = await readCalendar(url, await deps.reach(), deps.network, deps.signal);
|
|
35
|
+
secret = [url, ...calendar.followed];
|
|
36
|
+
const { count, next } = summaryOf(calendar, deps.now?.() ?? Date.now(), { scrub });
|
|
37
|
+
const name = calendar.name === null ? (URL.parse(url)?.host ?? "The calendar") : scrub(calendar.name);
|
|
38
|
+
const events = count === 1 ? "1 event" : `${count} events`;
|
|
39
|
+
const coming = next ? `next: ${next.title}, ${whenOf(next, calendar.zone)}` : "nothing in the next 62 days";
|
|
40
|
+
return { ok: true, message: scrub(`${name}: ${events}, time zone ${calendar.zone}, ${coming}`) };
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (error instanceof CalendarError)
|
|
44
|
+
return { ok: false, message: error.message };
|
|
45
|
+
if (error instanceof RepeatsError)
|
|
46
|
+
return { ok: false, message: `${error.message.charAt(0).toUpperCase()}${error.message.slice(1)}` };
|
|
47
|
+
return { ok: false, message: scrub(`The calendar couldn't be read (${String(error?.message ?? error).slice(0, 200)})`) };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** One route's answer (the dispatch sends it 200; DELETE's is undefined, 204). A body that does not read is 422. */
|
|
51
|
+
export async function calendarRoute(deps, name, body) {
|
|
52
|
+
switch (name) {
|
|
53
|
+
case "getCalendar":
|
|
54
|
+
return calendarView(deps.store, deps.sealKey);
|
|
55
|
+
case "saveCalendar": {
|
|
56
|
+
const url = bodyAddress(body);
|
|
57
|
+
// Read once for its own name (the address cut out of it) and time zone; a read that fails saves the address all the
|
|
58
|
+
// same.
|
|
59
|
+
let found = { name: null, zone: null };
|
|
60
|
+
try {
|
|
61
|
+
const { readCalendar } = await import("./fetch.js");
|
|
62
|
+
const calendar = await readCalendar(url, await deps.reach(), deps.network, deps.signal);
|
|
63
|
+
found = { name: calendar.name === null ? null : scrubAddress(calendar.name, [url, ...calendar.followed]), zone: calendar.zone };
|
|
64
|
+
}
|
|
65
|
+
catch { }
|
|
66
|
+
await saveCalendar(deps.store, deps.sealKey, { url, name: found.name, time_zone: found.zone });
|
|
67
|
+
return calendarView(deps.store, deps.sealKey);
|
|
68
|
+
}
|
|
69
|
+
case "deleteCalendar":
|
|
70
|
+
await removeCalendar(deps.store);
|
|
71
|
+
return undefined;
|
|
72
|
+
case "testCalendar": {
|
|
73
|
+
const given = body === undefined || body === null || (isObject(body) && Object.keys(body).length === 0) ? undefined : bodyAddress(body);
|
|
74
|
+
const url = given ?? (await openCalendar(deps.store, deps.sealKey))?.url;
|
|
75
|
+
if (!url)
|
|
76
|
+
throw noCalendar();
|
|
77
|
+
return tested(url, deps);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
throw new Error(`no calendar route ${name}`);
|
|
81
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type ToolRegistration } from "@earendil-works/pi-durable";
|
|
2
|
+
import type { ToolBinding, ToolHost } from "../tools.js";
|
|
3
|
+
/** An answer: the calendar's name and time zone, the window read (ISO, in that zone), its events, and whether there were
|
|
4
|
+
* more than it holds. */
|
|
5
|
+
export type CalendarAnswer = {
|
|
6
|
+
calendar: string;
|
|
7
|
+
time_zone: string;
|
|
8
|
+
from: string;
|
|
9
|
+
to: string;
|
|
10
|
+
events: readonly unknown[];
|
|
11
|
+
truncated: boolean;
|
|
12
|
+
};
|
|
13
|
+
/** An answer as the text the model reads, at most CALENDAR_ANSWER_MAX_CHARS characters of JSON, {calendar, time_zone, from,
|
|
14
|
+
* to, count, truncated, events}, a line for each field (lined): its own fields cut, the events that do not fit dropped
|
|
15
|
+
* from the end (truncated then true), and count the events it holds. */
|
|
16
|
+
export declare function calendarText(answer: CalendarAnswer): string;
|
|
17
|
+
/** An error's words, at most CALENDAR_ERROR_MAX_CHARS characters of JSON. */
|
|
18
|
+
export declare const calendarError: (words: string) => string;
|
|
19
|
+
/** The tool's registration over `host`, as the host's bound tests list it (emailRegistrations' twin). */
|
|
20
|
+
export declare const calendarRegistrations: (host: ToolHost) => ToolRegistration[];
|
|
21
|
+
/** calendar_events bound for the run `host` serves (tools.ts, its catalog entry). Nothing is read at bind: the calendar is
|
|
22
|
+
* opened at each call. */
|
|
23
|
+
export declare function bindCalendar(host: ToolHost): Promise<ToolBinding>;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
// calendar_events: the events of the server's one calendar (saved with PUT /v2/settings/calendar, address.ts) in a window, read from its
|
|
2
|
+
// iCal address (fetch.ts) and expanded (parse.ts). A host tool on every harness, bound beside web_fetch and the email tools
|
|
3
|
+
// (tool-list.ts `host`); the address is read in the runner, from the one store under its seal key, and is in no answer:
|
|
4
|
+
// each answer, and each error's words, has every form of it cut (address.ts scrubAddress) and passes the run's one redactor.
|
|
5
|
+
// An event's words are its organizer's, untrusted as a page's are (the description says so). Each answer is held under
|
|
6
|
+
// the host's result bound (CALENDAR_ANSWER_MAX_CHARS): the events that do not fit are dropped from the end, and the answer
|
|
7
|
+
// says `truncated`. Its head (the fields before `events`, count and truncated among them) is all the timeline's label reads:
|
|
8
|
+
// a row's redactor reads only a result's first 2,000 characters (key-refusal.ts redacted).
|
|
9
|
+
import { defineExtension, defineTool } from "@earendil-works/pi-durable";
|
|
10
|
+
import { cutJson } from "../email/answer.js";
|
|
11
|
+
import { forModel } from "../result.js";
|
|
12
|
+
import { isObject } from "../validate.js";
|
|
13
|
+
import { openCalendar, scrubAddress } from "./address.js";
|
|
14
|
+
import { CALENDAR_ANSWER_MAX_CHARS, CALENDAR_DESCRIPTION, CALENDAR_ERROR_MAX_CHARS, CALENDAR_EVENTS, NAME_MAX, NO_CALENDAR } from "./names.js";
|
|
15
|
+
/** `value` as JSON with a line break before each field and item: the longest line is one field's cut value. The run's
|
|
16
|
+
* redactor (key-refusal.ts redactedAnswer) reads an answer in pieces split at whitespace and gives "[redacted]" for a run
|
|
17
|
+
* of 8,192 characters with none, which compact JSON of a busy week (one-word titles, no description) is. */
|
|
18
|
+
const lined = (value) => {
|
|
19
|
+
if (Array.isArray(value))
|
|
20
|
+
return value.length ? `[\n${value.map(lined).join(",\n")}\n]` : "[]";
|
|
21
|
+
if (isObject(value)) {
|
|
22
|
+
const fields = Object.entries(value).filter(([, one]) => one !== undefined);
|
|
23
|
+
return fields.length ? `{\n${fields.map(([key, one]) => `${JSON.stringify(key)}:${lined(one)}`).join(",\n")}\n}` : "{}";
|
|
24
|
+
}
|
|
25
|
+
return JSON.stringify(value) ?? "null";
|
|
26
|
+
};
|
|
27
|
+
/** An answer as the text the model reads, at most CALENDAR_ANSWER_MAX_CHARS characters of JSON, {calendar, time_zone, from,
|
|
28
|
+
* to, count, truncated, events}, a line for each field (lined): its own fields cut, the events that do not fit dropped
|
|
29
|
+
* from the end (truncated then true), and count the events it holds. */
|
|
30
|
+
export function calendarText(answer) {
|
|
31
|
+
const head = {
|
|
32
|
+
calendar: cutJson(String(answer.calendar ?? ""), NAME_MAX),
|
|
33
|
+
time_zone: cutJson(String(answer.time_zone ?? ""), 100),
|
|
34
|
+
from: cutJson(String(answer.from ?? ""), 40),
|
|
35
|
+
to: cutJson(String(answer.to ?? ""), 40),
|
|
36
|
+
};
|
|
37
|
+
// The head, `"count":200,"truncated":false,"events":[]` and their line breaks, with room to spare.
|
|
38
|
+
let used = lined(head).length + 60;
|
|
39
|
+
const kept = [];
|
|
40
|
+
for (const event of answer.events) {
|
|
41
|
+
const size = lined(event).length + 2;
|
|
42
|
+
if (used + size > CALENDAR_ANSWER_MAX_CHARS)
|
|
43
|
+
break;
|
|
44
|
+
kept.push(event);
|
|
45
|
+
used += size;
|
|
46
|
+
}
|
|
47
|
+
return lined({ ...head, count: kept.length, truncated: answer.truncated || kept.length < answer.events.length, events: kept });
|
|
48
|
+
}
|
|
49
|
+
/** An error's words, at most CALENDAR_ERROR_MAX_CHARS characters of JSON. */
|
|
50
|
+
export const calendarError = (words) => cutJson(words, CALENDAR_ERROR_MAX_CHARS);
|
|
51
|
+
/** The tool, reading the calendar `host`'s store keeps. */
|
|
52
|
+
function calendarTool(host) {
|
|
53
|
+
return defineTool({
|
|
54
|
+
name: CALENDAR_EVENTS,
|
|
55
|
+
description: CALENDAR_DESCRIPTION,
|
|
56
|
+
parameters: {
|
|
57
|
+
type: "object",
|
|
58
|
+
additionalProperties: false,
|
|
59
|
+
properties: {
|
|
60
|
+
from: { type: "string", description: "The window's start: a date (2026-11-17, from its midnight in the calendar's time zone) or an ISO date-time with an offset. Default: now." },
|
|
61
|
+
to: { type: "string", description: "The window's end: a date (that day included) or an ISO date-time with an offset. Default: 7 days after from; at most 62 days after it." },
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
replay: "safe",
|
|
65
|
+
execute: async (args, _api, context) => {
|
|
66
|
+
if (!host.store || !host.sealKey)
|
|
67
|
+
return forModel(`${CALENDAR_EVENTS}: the calendar is read on the runner, which this run is not on.`, { isError: true });
|
|
68
|
+
const saved = await openCalendar(host.store, host.sealKey);
|
|
69
|
+
if (!saved)
|
|
70
|
+
return forModel(`${CALENDAR_EVENTS}: ${NO_CALENDAR}`, { isError: true });
|
|
71
|
+
// The saved address, and once read every address it was redirected to: each cut from the answer and the calendar's texts.
|
|
72
|
+
let secret = [saved.url];
|
|
73
|
+
const clean = (text) => {
|
|
74
|
+
const cut = scrubAddress(text, secret);
|
|
75
|
+
return host.redact ? host.redact(cut) : cut;
|
|
76
|
+
};
|
|
77
|
+
const failed = (words) => forModel(clean(calendarError(`${CALENDAR_EVENTS}: ${words}`)), { isError: true });
|
|
78
|
+
const given = (isObject(args) ? args : {});
|
|
79
|
+
const now = (host.now ?? new Date()).getTime();
|
|
80
|
+
const { CalendarError, readCalendar } = await import("./fetch.js");
|
|
81
|
+
const { eventsIn, isoIn, RepeatsError, serverZone, windowOf, WindowError, zoneNamed } = await import("./parse.js");
|
|
82
|
+
// Each text of the calendar's has the address cut out before it is cut short (parse.ts cut), and the answer again.
|
|
83
|
+
const scrub = (text) => scrubAddress(text, secret);
|
|
84
|
+
try {
|
|
85
|
+
// The window read first in the zone the save found, so a window refused is refused before any request.
|
|
86
|
+
windowOf(given, saved.time_zone ?? serverZone(), now);
|
|
87
|
+
// As the runner reaches an MCP server (runner/mcp-run.ts): the owner's private hosts, loopback on a local install,
|
|
88
|
+
// never at the ports of the server beside the runner (its own addresses, as calendar/routes.ts reads with them).
|
|
89
|
+
const { privateOAuthHosts } = await import("../mcp-private-hosts.js");
|
|
90
|
+
const reach = { ...(host.calendarLoopback ? { loopback: true } : {}), own: host.serverOwn ?? [], allowed: await privateOAuthHosts(host.store) };
|
|
91
|
+
const calendar = await readCalendar(saved.url, reach, undefined, context?.abortSignal);
|
|
92
|
+
secret = [saved.url, ...calendar.followed];
|
|
93
|
+
const window = windowOf(given, calendar.zone, now);
|
|
94
|
+
let found;
|
|
95
|
+
try {
|
|
96
|
+
found = eventsIn(calendar, window, { scrub });
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
if (error instanceof RepeatsError)
|
|
100
|
+
return failed(error.message);
|
|
101
|
+
throw new CalendarError(`the calendar's events couldn't be read (${String(error?.message ?? error).slice(0, 200)})`);
|
|
102
|
+
}
|
|
103
|
+
const zone = zoneNamed(calendar.zone);
|
|
104
|
+
const text = calendarText({ calendar: scrub(calendar.name ?? saved.name ?? "Calendar"), time_zone: calendar.zone, from: isoIn(window.start, zone), to: isoIn(window.end, zone), events: found.events, truncated: found.truncated });
|
|
105
|
+
return forModel(clean(text));
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
if (error instanceof CalendarError || error instanceof WindowError)
|
|
109
|
+
return failed(error.message);
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** The tool's registration over `host`, as the host's bound tests list it (emailRegistrations' twin). */
|
|
116
|
+
export const calendarRegistrations = (host) => [calendarTool(host)];
|
|
117
|
+
/** calendar_events bound for the run `host` serves (tools.ts, its catalog entry). Nothing is read at bind: the calendar is
|
|
118
|
+
* opened at each call. */
|
|
119
|
+
export async function bindCalendar(host) {
|
|
120
|
+
const [registration] = calendarRegistrations(host);
|
|
121
|
+
const extension = defineExtension({ name: "calendar-events", tools: [registration] });
|
|
122
|
+
host.install(extension);
|
|
123
|
+
return { tools: [registration], extensions: [extension] };
|
|
124
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -15,6 +15,7 @@ import { REPEAT_MS, stopOnSignals } from "./stop-signals.js";
|
|
|
15
15
|
import { canOpen } from "./host.js";
|
|
16
16
|
import { resetPassword } from "./owner.js";
|
|
17
17
|
import { banner } from "./print.js";
|
|
18
|
+
import { parseTokens } from "./api-token.js";
|
|
18
19
|
import { DEFAULT_PORT, fauxEnvOf, startServe } from "./server.js";
|
|
19
20
|
import { besideRunnerOptions, besideStopping, runnerBeside } from "./runner/beside.js";
|
|
20
21
|
import { apiOnlyFrom } from "./api-only.js";
|
|
@@ -73,7 +74,10 @@ Without --faux, a revision's model ("provider/model-id", or AGENT_MODEL when it
|
|
|
73
74
|
to AGENT_MODEL_FAST or AGENT_MODEL_STRONG, each falling back to AGENT_MODEL) is served by pi-ai's providers with their
|
|
74
75
|
keys from the environment, or, with AGENT_MODEL_BASE_URL, by that one OpenAI Responses gateway (AGENT_MODEL_API_KEY when
|
|
75
76
|
it needs a key). AGENTRUN_TOKEN, when set, is the token in place of DIR/.token's (a DIR/.token from an earlier start is removed), and is never printed; DIR/.token's is
|
|
76
|
-
printed only by the start that made it.
|
|
77
|
+
printed only by the start that made it. AGENTRUN_TOKENS, when set, holds more tokens as id:secret entries separated by
|
|
78
|
+
commas or whitespace (each secret 32 characters or more): every one opens what the token opens, AGENTRUN_TOKEN's id is
|
|
79
|
+
"default", and the request lines name the id of the token used, never a secret. Set alone, it takes DIR/.token's place.
|
|
80
|
+
AGENTRUN_PUBLIC_URL, when set, is the address people open (a container's
|
|
77
81
|
published port, or a proxy's URL), and the link printed uses it; with none, Render's RENDER_EXTERNAL_URL is.
|
|
78
82
|
AGENTRUN_FREE_MODEL_REQUESTS (default 60) is the most requests on free models ($0 in the catalog) a run makes, capped
|
|
79
83
|
or not (ChatGPT-plan requests don't count): the next is not sent and the run fails, spend_cap_reached. stdout gets one line per request, per run start and
|
|
@@ -92,7 +96,9 @@ Behind a proxy, set AGENTRUN_TRUSTED_PROXIES to its addresses or ranges (comma-s
|
|
|
92
96
|
uniquelocal) so each visitor counts by the address its X-Forwarded-For names; unset, that header is never read. Forgot the password: \`agentrun-serve reset-password --data DIR\` where the
|
|
93
97
|
data directory is (inside the container) clears it and signs every browser out, and the next visit sets a new one.
|
|
94
98
|
An MCP server on loopback (a 127.0.0.1 or localhost address) is refused unless AGENTRUN_MCP_ALLOW_LOOPBACK=1 is set at the
|
|
95
|
-
start: set it only on a machine you alone use, since loopback is this machine's other services too.
|
|
99
|
+
start: set it only on a machine you alone use, since loopback is this machine's other services too. A runner in its own
|
|
100
|
+
process reaches one only with the variable set in its own environment, on its own loopback (its own machine or
|
|
101
|
+
container), never at a server's own port (${DEFAULT_PORT}, or where the server says it listens).
|
|
96
102
|
|
|
97
103
|
\`agentrun-serve import\` reads the Claude Code, Codex and pi sessions in your own home (~/.claude/projects,
|
|
98
104
|
~/.codex/sessions, ~/.pi/agent/sessions) into the data directory, once: each project directory an agent, with its
|
|
@@ -331,6 +337,16 @@ if (budget !== undefined && !/^\d+$/.test(budget)) {
|
|
|
331
337
|
}
|
|
332
338
|
const data = values.data ?? defaultData();
|
|
333
339
|
const given = secret("AGENTRUN_TOKEN") || undefined;
|
|
340
|
+
// More tokens, each with an id (api-token.ts), for a rotation with no caller refused; never printed. A list that cannot
|
|
341
|
+
// be read stops here, in words that hold no secret.
|
|
342
|
+
let givenList;
|
|
343
|
+
try {
|
|
344
|
+
givenList = parseTokens(secret("AGENTRUN_TOKENS"));
|
|
345
|
+
}
|
|
346
|
+
catch (error) {
|
|
347
|
+
console.error(`${error.message}\n\n${USAGE}`);
|
|
348
|
+
process.exit(2);
|
|
349
|
+
}
|
|
334
350
|
// The stop is listened for before anything starts: a SIGTERM or SIGINT during the start (a platform's redeploy, the
|
|
335
351
|
// moment the banner shows) is kept, never the default end by signal that cuts what the start began. Once the start has
|
|
336
352
|
// what a stop closes, the stop below takes over (stopOnSignals), and a stop asked meanwhile runs it, through the same
|
|
@@ -370,7 +386,7 @@ try {
|
|
|
370
386
|
console.error(`agentrun-serve: ${error.message}`);
|
|
371
387
|
process.exit(1);
|
|
372
388
|
},
|
|
373
|
-
data, port, ...(values.port === undefined ? { nextFreePort: true } : {}), ...(values.listen ? { host: values.listen } : {}), ...(given ? { token: given } : {}), ...(values.faux ? { faux: values.faux } : {}), ...(values["faux-browser"] ? { fauxBrowser: values["faux-browser"] } : {}), ...(values["faux-github"] ? { fauxGitHub: true } : {}), allowHosts: values["allow-host"],
|
|
389
|
+
data, port, ...(values.port === undefined ? { nextFreePort: true } : {}), ...(values.listen ? { host: values.listen } : {}), ...(given ? { token: given } : {}), ...(givenList ? { tokens: givenList } : {}), ...(values.faux ? { faux: values.faux } : {}), ...(values["faux-browser"] ? { fauxBrowser: values["faux-browser"] } : {}), ...(values["faux-github"] ? { fauxGitHub: true } : {}), allowHosts: values["allow-host"],
|
|
374
390
|
...(values["max-runs"] !== undefined ? { maxRuns: Number(values["max-runs"]) } : {}),
|
|
375
391
|
...(values["drain-timeout"] ? { drainTimeout: values["drain-timeout"] } : {}), ...(values.documents ? { documents: values.documents } : {}), ...(values["allow-code-nodes"] ? { allowCodeNodes: true } : {}), ...(values.learning !== undefined ? { learning: values.learning } : {}), ...(values["grade-model"] ? { gradeModel: values["grade-model"] } : {}), ...(budget !== undefined ? { learningBudget: Number(budget) } : {}), log: (line) => void process.stdout.write(`${line}\n`),
|
|
376
392
|
// The public address is the server's with accounts on or off: the Host names it serves, the webhook URLs it gives.
|
|
@@ -405,7 +421,7 @@ if (!values["no-runner"] && askedAt === undefined) {
|
|
|
405
421
|
// server's AttachHub: a paired computer's socket is in this process, so only this runner takes one (--no-runner's
|
|
406
422
|
// separate runners refuse it in words). Its runs reach an MCP server on loopback only when this server is a local
|
|
407
423
|
// install (Serve.localInstall).
|
|
408
|
-
runnerProc = await runnerBeside(data, { loops, drainMs, env: besideRunEnv(process.env, fauxEnvOf(serveOptions)), janitor: true, hub: serve.attachHub, mcpLoopback: serve.localInstall });
|
|
424
|
+
runnerProc = await runnerBeside(data, { loops, drainMs, env: besideRunEnv(process.env, fauxEnvOf(serveOptions)), janitor: true, hub: serve.attachHub, dial: serve.dial, mcpLoopback: serve.localInstall, mcpOwn: serve.own });
|
|
409
425
|
}
|
|
410
426
|
catch (error) {
|
|
411
427
|
console.error(`agentrun-serve: the runner could not start: ${error.message}`);
|
|
@@ -414,8 +430,8 @@ if (!values["no-runner"] && askedAt === undefined) {
|
|
|
414
430
|
}
|
|
415
431
|
}
|
|
416
432
|
// A token from the environment is the operator's already, and the stored one is printed by the start that made it only.
|
|
417
|
-
const source = given ? "env" : serve.tokenMade ? "made" : "file";
|
|
418
|
-
for (const line of banner({ url: serve.url, baseUrl: serve.baseUrl, data, token: serve.token, source, accounts, ...(apiOnly ? { apiOnly } : {}), ...(serve.launchCode ? { launchCode: serve.launchCode } : {}), boxes: serve.boxesLine, ...(values.listen ? { listen: values.listen } : {}), ...(publicUrl ? { publicUrl } : {}) }))
|
|
433
|
+
const source = given ? "env" : givenList ? "list" : serve.tokenMade ? "made" : "file";
|
|
434
|
+
for (const line of banner({ url: serve.url, baseUrl: serve.baseUrl, data, token: serve.token, source, tokenIds: serve.tokenIds, accounts, ...(apiOnly ? { apiOnly } : {}), ...(serve.launchCode ? { launchCode: serve.launchCode } : {}), boxes: serve.boxesLine, ...(values.listen ? { listen: values.listen } : {}), ...(publicUrl ? { publicUrl } : {}) }))
|
|
419
435
|
console.log(line);
|
|
420
436
|
// Open setup (no public address, a loopback listener): the link that sets the password. Any other start printed the
|
|
421
437
|
// setup link with its code as the code was made (owner.ts).
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** A thing on Composio by its id, and whether this server made it. */
|
|
2
|
+
export type Made = {
|
|
3
|
+
id: string;
|
|
4
|
+
made: boolean;
|
|
5
|
+
};
|
|
6
|
+
/** What a preset server stands on at Composio: the user its address names, its auth config (none for a toolkit with no
|
|
7
|
+
* sign-in) and the connected accounts under it. */
|
|
8
|
+
export type ComposioMade = {
|
|
9
|
+
user: string;
|
|
10
|
+
auth_config: Made | null;
|
|
11
|
+
accounts: Made[];
|
|
12
|
+
};
|
|
13
|
+
/** What a delete does at Composio beyond the MCP server: what it removes, in order (the accounts before the auth config
|
|
14
|
+
* they are under), and what it keeps, each with whose it stays (`by`: the saved server that uses it too; none: this
|
|
15
|
+
* server didn't make it). */
|
|
16
|
+
export type Cleanup = {
|
|
17
|
+
remove: Thing[];
|
|
18
|
+
kept: (Thing & {
|
|
19
|
+
by?: string;
|
|
20
|
+
})[];
|
|
21
|
+
};
|
|
22
|
+
export type Thing = {
|
|
23
|
+
kind: "account" | "auth_config";
|
|
24
|
+
id: string;
|
|
25
|
+
};
|
|
26
|
+
/** The store.settings key a server's record lives under. */
|
|
27
|
+
export declare const composioMadeKey: (name: string) => string;
|
|
28
|
+
/** The settings value a record is stored as, bound to the server row it was written for. */
|
|
29
|
+
export declare const storedMade: (made: ComposioMade, row: {
|
|
30
|
+
createdAt: number;
|
|
31
|
+
}) => ComposioMade & {
|
|
32
|
+
of: number;
|
|
33
|
+
};
|
|
34
|
+
/** A stored record read for the row created at `createdAt`; undefined when there is none, it was written for another row,
|
|
35
|
+
* or it is not one (then nothing beyond the MCP server is removed). */
|
|
36
|
+
export declare function recordedMade(value: unknown, createdAt: number | undefined): ComposioMade | undefined;
|
|
37
|
+
/** A record a save writes, from what the preset found and made (`found`): a thing it found that a record of the server
|
|
38
|
+
* saved before over this row (`was`) or of another saved server (`others`) says was made here stays made here; and the
|
|
39
|
+
* accounts the server saved before had made, under the same auth config and user, stay its own. */
|
|
40
|
+
export declare function madeToWrite(found: ComposioMade, was: ComposioMade | undefined, others: readonly ComposioMade[]): ComposioMade;
|
|
41
|
+
/** What a removed server's record leaves to do, with the records of the servers still saved (`others`, by name): each
|
|
42
|
+
* thing it made that none of them uses is removed; one another uses is kept and passed to that one (`handover`: its record
|
|
43
|
+
* as it is to be written, owning it); one it didn't make is kept. */
|
|
44
|
+
export declare function cleanupOf(mine: ComposioMade, others: readonly [string, ComposioMade][], withConfig?: boolean): {
|
|
45
|
+
cleanup: Cleanup;
|
|
46
|
+
handover: [string, ComposioMade][];
|
|
47
|
+
};
|
|
48
|
+
/** What a save over a server leaves to do at Composio, with the records of the other servers saved (`others`, by name):
|
|
49
|
+
* what the record it replaces (`was`) made that the one written now (`now`) no longer stands on, an account of another
|
|
50
|
+
* user or auth config, and an auth config of another toolkit, each removed or passed on as a delete's is (cleanupOf). */
|
|
51
|
+
export declare function droppedOf(was: ComposioMade, now: ComposioMade, others: readonly [string, ComposioMade][]): {
|
|
52
|
+
cleanup: Cleanup;
|
|
53
|
+
handover: [string, ComposioMade][];
|
|
54
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// What the Composio preset made on Composio for a saved server beyond its MCP server (whose id the server's address
|
|
2
|
+
// names): the auth config it found or made, and the connected accounts it found ACTIVE or its connect links started,
|
|
3
|
+
// each marked whether this server made it (`made`). Recorded when the preset saves the server, one row of store.settings
|
|
4
|
+
// per server (composioMadeKey), bound to the server row it was written for (`of`, the row's created_at, which a save over
|
|
5
|
+
// the row keeps) as its source record is (mcp-sources.ts); read when the server is deleted. The delete removes what was
|
|
6
|
+
// made that no other saved server uses (cleanupOf), and passes what another one uses to that one's record, so the last
|
|
7
|
+
// of them to go removes it. What this server didn't make (an auth config or an account the owner had already, or one no
|
|
8
|
+
// record says it made, as for a server saved before this was recorded) is never removed. A save over the server does the
|
|
9
|
+
// same with what the record it replaces made that the new one no longer stands on (droppedOf).
|
|
10
|
+
import { isObject } from "./validate.js";
|
|
11
|
+
/** The store.settings key a server's record lives under. */
|
|
12
|
+
export const composioMadeKey = (name) => `mcp.composio/${name}`;
|
|
13
|
+
/** The settings value a record is stored as, bound to the server row it was written for. */
|
|
14
|
+
export const storedMade = (made, row) => ({ ...made, of: row.createdAt });
|
|
15
|
+
const ID = /^[A-Za-z0-9_.-]{1,128}$/;
|
|
16
|
+
const thingOf = (value) => (isObject(value) && typeof value.id === "string" && ID.test(value.id) && typeof value.made === "boolean" ? { id: value.id, made: value.made } : undefined);
|
|
17
|
+
/** A stored record read for the row created at `createdAt`; undefined when there is none, it was written for another row,
|
|
18
|
+
* or it is not one (then nothing beyond the MCP server is removed). */
|
|
19
|
+
export function recordedMade(value, createdAt) {
|
|
20
|
+
if (!isObject(value) || createdAt === undefined || value.of !== createdAt || typeof value.user !== "string" || !Array.isArray(value.accounts))
|
|
21
|
+
return undefined;
|
|
22
|
+
const config = value.auth_config === null ? null : thingOf(value.auth_config);
|
|
23
|
+
const accounts = value.accounts.map(thingOf);
|
|
24
|
+
if (config === undefined || accounts.some((account) => !account))
|
|
25
|
+
return undefined;
|
|
26
|
+
return { user: value.user, auth_config: config, accounts: accounts };
|
|
27
|
+
}
|
|
28
|
+
/** Whether `other` stands on `mine`'s account: under the same auth config, as the same user (Composio's MCP server picks
|
|
29
|
+
* the account by the two). */
|
|
30
|
+
const sharesAccounts = (mine, other) => mine.auth_config !== null && other.auth_config?.id === mine.auth_config.id && other.user === mine.user;
|
|
31
|
+
/** A record a save writes, from what the preset found and made (`found`): a thing it found that a record of the server
|
|
32
|
+
* saved before over this row (`was`) or of another saved server (`others`) says was made here stays made here; and the
|
|
33
|
+
* accounts the server saved before had made, under the same auth config and user, stay its own. */
|
|
34
|
+
export function madeToWrite(found, was, others) {
|
|
35
|
+
const all = [...(was ? [was] : []), ...others];
|
|
36
|
+
const madeHere = (id) => all.some((r) => r.auth_config?.id === id ? r.auth_config.made : false) || all.some((r) => r.accounts.some((a) => a.id === id && a.made));
|
|
37
|
+
const config = found.auth_config && { id: found.auth_config.id, made: found.auth_config.made || madeHere(found.auth_config.id) };
|
|
38
|
+
const accounts = found.accounts.map((a) => ({ id: a.id, made: a.made || madeHere(a.id) }));
|
|
39
|
+
const kept = was && sharesAccounts(found, was) ? was.accounts.filter((a) => a.made && !accounts.some((b) => b.id === a.id)) : [];
|
|
40
|
+
return { user: found.user, auth_config: config, accounts: [...accounts, ...kept] };
|
|
41
|
+
}
|
|
42
|
+
/** What a removed server's record leaves to do, with the records of the servers still saved (`others`, by name): each
|
|
43
|
+
* thing it made that none of them uses is removed; one another uses is kept and passed to that one (`handover`: its record
|
|
44
|
+
* as it is to be written, owning it); one it didn't make is kept. */
|
|
45
|
+
export function cleanupOf(mine, others, withConfig = true) {
|
|
46
|
+
const cleanup = { remove: [], kept: [] };
|
|
47
|
+
const handed = new Map();
|
|
48
|
+
const take = (name, record) => handed.get(name) ?? (handed.set(name, { ...record, accounts: [...record.accounts] }), handed.get(name));
|
|
49
|
+
for (const account of mine.accounts) {
|
|
50
|
+
const user = others.find(([, other]) => sharesAccounts(mine, other));
|
|
51
|
+
if (!account.made)
|
|
52
|
+
cleanup.kept.push({ kind: "account", id: account.id });
|
|
53
|
+
else if (user) {
|
|
54
|
+
cleanup.kept.push({ kind: "account", id: account.id, by: user[0] });
|
|
55
|
+
const record = take(user[0], user[1]);
|
|
56
|
+
record.accounts = [...record.accounts.filter((a) => a.id !== account.id), { id: account.id, made: true }];
|
|
57
|
+
}
|
|
58
|
+
else
|
|
59
|
+
cleanup.remove.push({ kind: "account", id: account.id });
|
|
60
|
+
}
|
|
61
|
+
if (mine.auth_config && withConfig) {
|
|
62
|
+
const config = mine.auth_config;
|
|
63
|
+
const user = others.find(([, other]) => other.auth_config?.id === config.id);
|
|
64
|
+
if (!config.made)
|
|
65
|
+
cleanup.kept.push({ kind: "auth_config", id: config.id });
|
|
66
|
+
else if (user) {
|
|
67
|
+
cleanup.kept.push({ kind: "auth_config", id: config.id, by: user[0] });
|
|
68
|
+
take(user[0], user[1]).auth_config = { id: config.id, made: true };
|
|
69
|
+
}
|
|
70
|
+
else
|
|
71
|
+
cleanup.remove.push({ kind: "auth_config", id: config.id });
|
|
72
|
+
}
|
|
73
|
+
return { cleanup, handover: [...handed] };
|
|
74
|
+
}
|
|
75
|
+
/** What a save over a server leaves to do at Composio, with the records of the other servers saved (`others`, by name):
|
|
76
|
+
* what the record it replaces (`was`) made that the one written now (`now`) no longer stands on, an account of another
|
|
77
|
+
* user or auth config, and an auth config of another toolkit, each removed or passed on as a delete's is (cleanupOf). */
|
|
78
|
+
export function droppedOf(was, now, others) {
|
|
79
|
+
const accounts = was.accounts.filter((account) => account.made && !now.accounts.some((kept) => kept.id === account.id));
|
|
80
|
+
// The auth config goes through only when this save stands on another one: its accounts are checked under it either way.
|
|
81
|
+
const config = was.auth_config !== null && was.auth_config.made && now.auth_config?.id !== was.auth_config.id;
|
|
82
|
+
return cleanupOf({ user: was.user, auth_config: was.auth_config, accounts }, others, config);
|
|
83
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Cleanup, ComposioMade } from "./composio-made.js";
|
|
1
2
|
import { type Json } from "./validate.js";
|
|
2
3
|
/** Another Composio than the real one, and its fetch: a test's fake (the same seam as `archilControl`). */
|
|
3
4
|
export type ComposioControl = {
|
|
@@ -26,7 +27,9 @@ export declare function composioTools(body: unknown, control: ComposioControl, s
|
|
|
26
27
|
* account left off, and the path ended in /mcp (Composio redirects the bare one, which the client refuses on purpose). */
|
|
27
28
|
export declare function composioAddress(generated: string): string;
|
|
28
29
|
/** PUT /settings/mcp-servers/{name}/composio: Composio makes the managed MCP server, `save` keeps it as a saved MCP server
|
|
29
|
-
* (`{url, auth}`: the key a sealed header), and a toolkit that needs the person's account says where to connect it.
|
|
30
|
+
* (`{url, auth}`: the key a sealed header), and a toolkit that needs the person's account says where to connect it.
|
|
31
|
+
* `save` gets what the server stands on there too (`stands`, composio-made.ts): the auth config found or made and the
|
|
32
|
+
* account found or started, each marked whether this save made it, for its delete to remove what was made. */
|
|
30
33
|
export declare function composioSave<T extends {
|
|
31
34
|
tools?: readonly {
|
|
32
35
|
name: string;
|
|
@@ -40,22 +43,27 @@ export declare function composioSave<T extends {
|
|
|
40
43
|
}, made: {
|
|
41
44
|
source: "composio";
|
|
42
45
|
toolkit: string | null;
|
|
43
|
-
}) => Promise<T>, name: string, signal?: AbortSignal, savedUrl?: () => Promise<string | undefined>): Promise<{
|
|
46
|
+
}, stands: ComposioMade) => Promise<T>, name: string, signal?: AbortSignal, savedUrl?: () => Promise<string | undefined>): Promise<{
|
|
44
47
|
server: T;
|
|
45
48
|
connect_url?: string;
|
|
46
49
|
not_served?: string[];
|
|
47
50
|
}>;
|
|
48
51
|
/** The Composio MCP server a saved preset address names (`/v3/mcp/<id>/mcp`, composioAddress): its id, or undefined. */
|
|
49
52
|
export declare const composioServerId: (address: string) => string | undefined;
|
|
50
|
-
/** What the answer to a delete says when
|
|
51
|
-
|
|
53
|
+
/** What the answer to a delete says when this server could not ask Composio at all (the saved key does not open here, or
|
|
54
|
+
* the address names no Composio server): all of it is left there, to remove by hand. `mcp`: the MCP server left, by its
|
|
55
|
+
* id when known (true: the one it made; false: none). `over`: a save over a server, which says what it keeps too. */
|
|
56
|
+
export declare const composioNote: (name: string, cleanup?: Cleanup, mcp?: string | boolean, over?: boolean) => {
|
|
52
57
|
removed: false;
|
|
53
58
|
note: string;
|
|
54
59
|
};
|
|
55
60
|
/** Deleting a preset server: the Composio MCP server `id` it made is deleted as `key` (the saved credential, held for this
|
|
56
|
-
* call only)
|
|
57
|
-
*
|
|
58
|
-
|
|
61
|
+
* call only), then what `cleanup` says this server made for it and nothing else uses (composio-made.ts: its connected
|
|
62
|
+
* accounts, then their auth config). Composio's 404 is "already gone"; a refusal, or no answer, leaves that one there and
|
|
63
|
+
* says so, for the delete of our own row to go on regardless. The answer says in words what went, what stays and why.
|
|
64
|
+
* A save over a server does the same with what the save before made that it left (ComposioDropped); no `id` when the
|
|
65
|
+
* row still names the MCP server it named. */
|
|
66
|
+
export declare function composioForget(control: ComposioControl, key: string, id: string | undefined, name: string, signal?: AbortSignal, cleanup?: Cleanup): Promise<{
|
|
59
67
|
removed: boolean;
|
|
60
|
-
note
|
|
68
|
+
note: string;
|
|
61
69
|
}>;
|