@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
package/dist/templates.js
CHANGED
|
@@ -27,6 +27,7 @@ import { MOVE_FIELD } from "./trigger-composio.js";
|
|
|
27
27
|
import { triggerBodyIssues } from "./triggers.js";
|
|
28
28
|
import { definitionBodyIssues, inputIssues, inputSchemaOf, isObject, MODEL_REF, MODEL_TIER_NAMES, unknownFields } from "./validate.js";
|
|
29
29
|
import { schemaCheck } from "./answer-json.js";
|
|
30
|
+
import { webFixtureOf } from "./web-fake.js";
|
|
30
31
|
import { APPROVALS } from "./approvals.js";
|
|
31
32
|
export const TEMPLATES_DIR = fileURLToPath(new URL("../templates/", import.meta.url));
|
|
32
33
|
export const MANIFEST = "agent.md";
|
|
@@ -152,10 +153,10 @@ export class PackageError extends Error {
|
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
155
|
/** The source kinds whose accept rules a parameter may fill: a github trigger's, a webhook trigger's (a provider that
|
|
155
|
-
* sends every trigger of a project to one URL is filtered to the owner's own repository by them),
|
|
156
|
-
* trigger's. */
|
|
157
|
-
const FILTERED_KINDS = ["github", "webhook", "composio"];
|
|
158
|
-
/** A github, webhook or
|
|
156
|
+
* sends every trigger of a project to one URL is filtered to the owner's own repository by them), a composio
|
|
157
|
+
* trigger's, and a feed trigger's (the pull requests of one author, say). */
|
|
158
|
+
const FILTERED_KINDS = ["github", "webhook", "composio", "feed"];
|
|
159
|
+
/** A github, webhook, composio or feed source split at its where conditions' `in` values, the one place a parameter may fill it: `ins`, each
|
|
159
160
|
* condition's list, and `rest`, the source without them. */
|
|
160
161
|
function whereIns(source) {
|
|
161
162
|
const ins = [];
|
|
@@ -195,6 +196,16 @@ export function composioTriggerSkipped(packageName, trigger, why) {
|
|
|
195
196
|
const source = isObject(trigger.source) ? trigger.source : {};
|
|
196
197
|
return `The ${packageName} template's trigger ${String(trigger.name)} (Composio ${String(source.event)} on ${String(source.server)}) was not made: ${why}`;
|
|
197
198
|
}
|
|
199
|
+
/** Whether a feed trigger, its parameters filled, reads no feed: its urls one whole array parameter the apply was given
|
|
200
|
+
* empty. An apply skips it, never itself, as it skips a github trigger with GitHub not connected (a warning under
|
|
201
|
+
* triggers.<i>): the agent stands. */
|
|
202
|
+
export const feedLeftEmpty = (trigger) => isObject(trigger.source) && trigger.source.kind === "feed" && Array.isArray(trigger.source.urls) && !trigger.source.urls.length;
|
|
203
|
+
/** What an apply says of a feed trigger it skipped (feedLeftEmpty): which, and the parameter to set. `declared` is the
|
|
204
|
+
* package's own urls ("${parameters.status_feeds}"). */
|
|
205
|
+
export function feedTriggerEmpty(packageName, trigger, declared) {
|
|
206
|
+
const named = (typeof declared === "string" ? [...declared.matchAll(PLACEHOLDER)][0]?.[1] : undefined) ?? "its feeds parameter";
|
|
207
|
+
return `The ${packageName} template's feed trigger ${String(trigger.name)} was not made: no feeds given in ${named}. Apply again with ${named} set to the feeds it should read.`;
|
|
208
|
+
}
|
|
198
209
|
/** Where the owner makes a composio trigger an apply skipped, once what refused it is fixed. */
|
|
199
210
|
export const COMPOSIO_TRIGGER_FIX = "Once that's fixed, make it from Triggers → New app trigger for this agent, with the same event and config.";
|
|
200
211
|
/** What an apply says of a github trigger it skipped because GitHub is not connected here: what to do, and what the
|
|
@@ -243,8 +254,20 @@ const triggerFilled = (trigger, given) => {
|
|
|
243
254
|
// parameter's type (an integer config field gets an integer).
|
|
244
255
|
if (isObject(trigger.source) && trigger.source.kind === "composio" && isObject(trigger.source.config))
|
|
245
256
|
out.source = { ...out.source, config: inputFilled(trigger.source.config, given) };
|
|
257
|
+
// A feed trigger's urls as one placeholder alone take the array its parameter names, whole; a list's URLs are text.
|
|
258
|
+
if (isObject(trigger.source) && trigger.source.kind === "feed" && typeof trigger.source.urls === "string")
|
|
259
|
+
out.source = { ...out.source, urls: typedFilled(trigger.source.urls, given) };
|
|
246
260
|
return out;
|
|
247
261
|
};
|
|
262
|
+
/** The source of the package's trigger `name`, filled from the apply's `parameters` as an apply fills it (each parameter
|
|
263
|
+
* left out given its default): a template eval reads the feed URLs its case's trigger will read before it applies. */
|
|
264
|
+
export function filledSource(p, name, parameters) {
|
|
265
|
+
const trigger = p.triggers.find((one) => one.name === name);
|
|
266
|
+
if (!trigger)
|
|
267
|
+
return undefined;
|
|
268
|
+
const filledOne = triggerFilled(trigger, applyBodyOf(p, { parameters }).parameters);
|
|
269
|
+
return isObject(filledOne.source) ? filledOne.source : undefined;
|
|
270
|
+
}
|
|
248
271
|
/** An mcp entry's `pin` read: by tool, each one of the entry's `tools`, its arguments checked by the one rule every pin
|
|
249
272
|
* is (tool-plane.ts pinIssues, on the tool's gate name), text in it may hold `${parameters.<name>}` (checked with the
|
|
250
273
|
* other placeholders). Each problem is told through `bad`; a tool whose pin reads is kept. */
|
|
@@ -464,7 +487,7 @@ function fieldsSchema(value, of, bad) {
|
|
|
464
487
|
}
|
|
465
488
|
/** Reads the package at `from` (its folder, or its files: PackageFiles) checked whole: a valid package, or PackageError
|
|
466
489
|
* with every problem found. */
|
|
467
|
-
export function readPackage(from) {
|
|
490
|
+
export function readPackage(from, { evalFixtures = true } = {}) {
|
|
468
491
|
const src = typeof from === "string" ? folderFiles(from) : from;
|
|
469
492
|
const dir = src.where;
|
|
470
493
|
const problems = [];
|
|
@@ -717,11 +740,12 @@ export function readPackage(from) {
|
|
|
717
740
|
bad(MANIFEST, `\${parameters.${used}} names no parameter`);
|
|
718
741
|
}
|
|
719
742
|
// A placeholder fills text a run reads, a schedule's time (its cron and timezone, read as the schedule at apply), a
|
|
720
|
-
// github, webhook or
|
|
721
|
-
// config values (what Composio watches for it: the owner's repository, team or label)
|
|
722
|
-
//
|
|
723
|
-
//
|
|
724
|
-
//
|
|
743
|
+
// github, webhook, composio or feed trigger's where `in` values (the repository it takes, say), a composio trigger's
|
|
744
|
+
// config values (what Composio watches for it: the owner's repository, team or label), and a feed trigger's urls (a
|
|
745
|
+
// placeholder inside a URL, or the whole list as one naming an array parameter); a trigger's other settings, a
|
|
746
|
+
// composio trigger's server and event and a feed trigger's every_s, items and id among them, are the package's own,
|
|
747
|
+
// checked here. A parameter that sets a time has a default, so the schedule the package ships is checked here too; one
|
|
748
|
+
// a where, a composio config or a feed's urls take is required or has a default, so the trigger never fills empty.
|
|
725
749
|
triggers.forEach((trigger, i) => {
|
|
726
750
|
if (!isObject(trigger))
|
|
727
751
|
return;
|
|
@@ -730,12 +754,13 @@ export function readPackage(from) {
|
|
|
730
754
|
const fixed = Object.entries(trigger).flatMap(([key, value]) => key === "target" && isObject(value) ? Object.entries(value).filter(([k]) => k !== "input").map(([k, v]) => [`target.${k}`, v])
|
|
731
755
|
: key === "source" && timed && isObject(value) ? Object.entries(value).filter(([k]) => !SCHEDULE_FIELDS.includes(k)).map(([k, v]) => [`source.${k}`, v])
|
|
732
756
|
: key === "source" && filtered && isObject(value) && value.kind === "composio" ? Object.entries(whereIns(value).rest).filter(([k]) => k !== "config").map(([k, v]) => [`source.${k}`, v])
|
|
733
|
-
: key === "source" && filtered && isObject(value) ?
|
|
734
|
-
: key === "
|
|
735
|
-
:
|
|
757
|
+
: key === "source" && filtered && isObject(value) && value.kind === "feed" ? Object.entries(whereIns(value).rest).filter(([k]) => k !== "urls").map(([k, v]) => [`source.${k}`, v])
|
|
758
|
+
: key === "source" && filtered && isObject(value) ? [[key, whereIns(value).rest]]
|
|
759
|
+
: key === "enabled" && typeof value === "string" ? []
|
|
760
|
+
: [[key, value]]);
|
|
736
761
|
for (const [at, value] of fixed)
|
|
737
762
|
for (const [used] of strings(value).flatMap((text) => [...text.matchAll(PLACEHOLDER)]))
|
|
738
|
-
bad(MANIFEST, `triggers[${i}].${at} holds ${used}: a placeholder goes in display_name, the instructions, a trigger's target.input, a schedule's cron and timezone, a github, webhook or
|
|
763
|
+
bad(MANIFEST, `triggers[${i}].${at} holds ${used}: a placeholder goes in display_name, the instructions, a trigger's target.input, a schedule's cron and timezone, a github, webhook, composio or feed trigger's where in values, a composio trigger's config values, a feed trigger's urls, or an mcp pin's values`);
|
|
739
764
|
// enabled is true, false, or one boolean parameter with a default, filled at apply (triggerFilled): the trigger is on
|
|
740
765
|
// or off by the owner's answer, and by the package's default when the apply leaves it out.
|
|
741
766
|
if (typeof trigger.enabled === "string") {
|
|
@@ -755,6 +780,24 @@ export function readPackage(from) {
|
|
|
755
780
|
bad(MANIFEST, `parameters.${used} is used in triggers[${i}].source.accept, so it is required or has a default: a ${trigger.source.kind} trigger filled empty takes no event`);
|
|
756
781
|
}
|
|
757
782
|
}
|
|
783
|
+
// A feed's urls: a list whose URLs may hold placeholders, or one placeholder alone naming an array-of-strings
|
|
784
|
+
// parameter, filled whole; each parameter they name required or with a default, so the trigger never reads none.
|
|
785
|
+
if (isObject(trigger.source) && trigger.source.kind === "feed") {
|
|
786
|
+
const urls = trigger.source.urls;
|
|
787
|
+
if (typeof urls === "string") {
|
|
788
|
+
const rule = `triggers[${i}].source.urls is a list of URLs, or one placeholder alone, "\${parameters.<name>}", naming an array parameter of strings`;
|
|
789
|
+
const whole = WHOLE.exec(urls);
|
|
790
|
+
const spec = whole && Object.hasOwn(fields, whole[1]) ? fields[whole[1]] : undefined;
|
|
791
|
+
if (!whole)
|
|
792
|
+
bad(MANIFEST, rule);
|
|
793
|
+
else if (spec && (spec.type !== "array" || !isObject(spec.items) || spec.items.type !== "string"))
|
|
794
|
+
bad(MANIFEST, `${rule}: parameters.${whole[1]} is ${spec.type === "array" ? "an array of other than strings" : `a ${String(spec.type)}`}`);
|
|
795
|
+
}
|
|
796
|
+
for (const used of new Set(strings(urls).flatMap((text) => [...text.matchAll(PLACEHOLDER)].map((m) => m[1])))) {
|
|
797
|
+
if (Object.hasOwn(fields, used) && !parameters.required?.includes(used) && fields[used].default === undefined)
|
|
798
|
+
bad(MANIFEST, `parameters.${used} is used in triggers[${i}].source.urls, so it is required or has a default: a feed trigger filled empty reads no feed`);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
758
801
|
if (isObject(trigger.source) && trigger.source.kind === "composio") {
|
|
759
802
|
for (const used of new Set(strings(trigger.source.config).flatMap((text) => [...text.matchAll(PLACEHOLDER)].map((m) => m[1])))) {
|
|
760
803
|
if (Object.hasOwn(fields, used) && !parameters.required?.includes(used) && fields[used].default === undefined)
|
|
@@ -824,12 +867,25 @@ export function readPackage(from) {
|
|
|
824
867
|
const caseDoc = own.includes("case.yaml") ? parseDocument(text(`${at}/case.yaml`), { uniqueKeys: true }) : undefined;
|
|
825
868
|
if (caseDoc?.errors.length)
|
|
826
869
|
bad(`${at}/case.yaml`, "is not YAML");
|
|
827
|
-
// An email case's run is its trigger's, on the trigger's input (template-eval.ts): its prompt.md has no body.
|
|
828
|
-
const
|
|
870
|
+
// An email or feed case's run is its trigger's, on the trigger's input (template-eval.ts): its prompt.md has no body.
|
|
871
|
+
const caseJs = !!caseDoc && !caseDoc.errors.length && isObject(caseDoc.toJS()) ? caseDoc.toJS() : undefined;
|
|
872
|
+
const triggeredCase = caseJs !== undefined && (caseJs.email !== undefined || caseJs.feed !== undefined);
|
|
829
873
|
if (!own.includes("prompt.md"))
|
|
830
874
|
bad(at, "has no prompt.md");
|
|
831
|
-
else if (!
|
|
875
|
+
else if (!triggeredCase && !front(`${at}/prompt.md`, false)?.body.trim())
|
|
832
876
|
bad(`${at}/prompt.md`, "its body is empty: the body is the run's input");
|
|
877
|
+
// A case's web fixture is checked as eval-template checks it, in the same words (web-fake.ts).
|
|
878
|
+
if (evalFixtures && caseJs !== undefined && typeof caseJs.web === "string" && caseJs.web !== "unavailable" && own.includes(caseJs.web) && caseJs.web.startsWith("fixtures/")) {
|
|
879
|
+
let parsed;
|
|
880
|
+
try {
|
|
881
|
+
parsed = JSON.parse(text(`${at}/${caseJs.web}`));
|
|
882
|
+
}
|
|
883
|
+
catch (error) {
|
|
884
|
+
bad(`${at}/${caseJs.web}`, `is not JSON (${error.message})`);
|
|
885
|
+
}
|
|
886
|
+
if (parsed !== undefined)
|
|
887
|
+
webFixtureOf(parsed, `${at}/${caseJs.web}`, (message) => void problems.push(message));
|
|
888
|
+
}
|
|
833
889
|
const graders = own.filter((p) => p.startsWith("graders/"));
|
|
834
890
|
if (!graders.length)
|
|
835
891
|
bad(at, "has no graders/*.md");
|
|
@@ -867,6 +923,14 @@ export function readPackage(from) {
|
|
|
867
923
|
// hangs on the value (a pattern, a bound, a choice) is the apply's, on the value given. Its type, and whether the
|
|
868
924
|
// inputs name the field at all, are checked here.
|
|
869
925
|
const sampled = (field) => {
|
|
926
|
+
// A feed's URL filled from a parameter with no default holds a sample, no URL: the apply checks the value given.
|
|
927
|
+
const url = /^triggers\.(\d+)\.source\.urls(?:\[(\d+)\])?$/.exec(field);
|
|
928
|
+
if (url) {
|
|
929
|
+
const urls = p.triggers[Number(url[1])]?.source?.urls;
|
|
930
|
+
const named = (text) => strings(text).flatMap((one) => [...one.matchAll(PLACEHOLDER)].map((m) => m[1]));
|
|
931
|
+
const used = typeof urls === "string" ? named(urls) : Array.isArray(urls) && url[2] !== undefined ? named(urls[Number(url[2])]) : [];
|
|
932
|
+
return used.some((name) => Object.hasOwn(fields, name) && fields[name].default === undefined);
|
|
933
|
+
}
|
|
870
934
|
const at = /^triggers\.(\d+)\.target\.input\.([^.]+)/.exec(field);
|
|
871
935
|
const target = at ? p.triggers[Number(at[1])]?.target : undefined;
|
|
872
936
|
const value = at && isObject(target) && isObject(target.input) ? target.input[at[2]] : undefined;
|
|
@@ -878,8 +942,15 @@ export function readPackage(from) {
|
|
|
878
942
|
const at = /^triggers\.(\d+)\.enabled$/.exec(field);
|
|
879
943
|
return !!at && typeof p.triggers[Number(at[1])]?.enabled === "string";
|
|
880
944
|
};
|
|
945
|
+
// A feed trigger a parameter's default leaves with no feeds is skipped at apply (feedLeftEmpty), never refused: so its
|
|
946
|
+
// urls are not refused here. Every other field of it is checked, as the apply makes it once the owner sets urls.
|
|
947
|
+
const skippedAtApply = (field) => {
|
|
948
|
+
const at = /^triggers\.(\d+)\.source\.urls(?:\[\d+\])?$/.exec(field);
|
|
949
|
+
const trigger = at ? made.triggers[Number(at[1])] : undefined;
|
|
950
|
+
return !!trigger && feedLeftEmpty(trigger);
|
|
951
|
+
};
|
|
881
952
|
for (const issue of madeTriggerIssues(made.triggers, 0, p.inputSchema))
|
|
882
|
-
if (!saidEnabled(issue.field) && (["wrong_type", "not_allowed", "missing"].includes(issue.reason) || !sampled(issue.field)))
|
|
953
|
+
if (!saidEnabled(issue.field) && !skippedAtApply(issue.field) && (["wrong_type", "not_allowed", "missing"].includes(issue.reason) || !sampled(issue.field)))
|
|
883
954
|
bad(MANIFEST, `${issue.field.replace(/^triggers\.(\d+)\./, "triggers[$1].")}: ${issue.message}`);
|
|
884
955
|
if (problems.length)
|
|
885
956
|
throw new PackageError(dir, [...new Set(problems)]);
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
/** Apps whose id says little of the name a person knows them by. Any other id's last part is its name, capitalized. */
|
|
9
9
|
const APP_NAMES = {
|
|
10
10
|
"com.apple.systempreferences": "System Settings", "com.apple.iCal": "Calendar", "com.apple.finder": "Finder",
|
|
11
|
-
"com.android.settings": "Settings", "com.android.chrome": "Chrome", "
|
|
11
|
+
"com.android.settings": "Settings", "com.android.chrome": "Chrome", "com.android.deskclock": "Clock", "com.android.contacts": "Contacts",
|
|
12
|
+
"com.android.documentsui": "Files", "org.wikipedia": "Wikipedia", "xfce4-terminal": "Terminal", "org.xfce.terminal": "Terminal", xterm: "XTerm",
|
|
12
13
|
"firefox-esr": "Firefox", "google-chrome": "Chrome",
|
|
13
14
|
};
|
|
14
15
|
/** An app's id as a person names it: "com.apple.TextEdit" is TextEdit, "org.xfce.mousepad" Mousepad. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EntryLike } from "./timeline.js";
|
|
2
2
|
/** What fired a trigger: its definition's kind, never what its payload says. */
|
|
3
|
-
export declare const TRIGGER_SOURCES: readonly ["schedule", "webhook", "slack", "github", "composio", "email"];
|
|
3
|
+
export declare const TRIGGER_SOURCES: readonly ["schedule", "webhook", "slack", "github", "composio", "email", "feed"];
|
|
4
4
|
export type TriggerSource = (typeof TRIGGER_SOURCES)[number];
|
|
5
5
|
/** How a trigger's Timeline row names its source: "<label> <trigger>: <its first line>". */
|
|
6
6
|
export declare const TRIGGER_LABELS: Readonly<Record<TriggerSource, string>>;
|
package/dist/timeline/origin.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { obj, str } from "./util.js";
|
|
2
2
|
/** What fired a trigger: its definition's kind, never what its payload says. */
|
|
3
|
-
export const TRIGGER_SOURCES = ["schedule", "webhook", "slack", "github", "composio", "email"];
|
|
3
|
+
export const TRIGGER_SOURCES = ["schedule", "webhook", "slack", "github", "composio", "email", "feed"];
|
|
4
4
|
/** How a trigger's Timeline row names its source: "<label> <trigger>: <its first line>". */
|
|
5
|
-
export const TRIGGER_LABELS = { schedule: "Schedule", webhook: "Webhook", slack: "Slack", github: "GitHub", composio: "Composio", email: "Email" };
|
|
5
|
+
export const TRIGGER_LABELS = { schedule: "Schedule", webhook: "Webhook", slack: "Slack", github: "GitHub", composio: "Composio", email: "Email", feed: "Feed" };
|
|
6
6
|
const REASONS = new Set(["cap_raised", "approval", "handed_back", "output_retry"]);
|
|
7
7
|
const SOURCES = new Set(TRIGGER_SOURCES);
|
|
8
8
|
/** An entry kind that names the origin of the next user entry in its conversation whose text is exactly `text`: written
|
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.
|
|
@@ -76,7 +76,7 @@ export type TriggerAdapter = {
|
|
|
76
76
|
/** Whether each firing of a trigger of `source` starts its own run, its last run active or not (a webhook that takes
|
|
77
77
|
* only the events it names). Default false: a firing while the last run is active is skipped. */
|
|
78
78
|
concurrent?(source: Source): boolean;
|
|
79
|
-
/** For a clock source that polls (the email
|
|
79
|
+
/** For a clock source that polls (the email and feed triggers): what it finds when its time comes, read from outside the server.
|
|
80
80
|
* The engine fires each event it returns through the path a pushed event takes (`takes`, `concurrent`,
|
|
81
81
|
* max_active_runs, the day-kept keys, a run per event), records no `missed` row for a time it was not there for, and
|
|
82
82
|
* keeps the poll's cursor once its firings are recorded. A poll with no cursor is where its trigger starts watching:
|
|
@@ -95,14 +95,16 @@ export type PollContext = {
|
|
|
95
95
|
credentials(): Promise<unknown>;
|
|
96
96
|
};
|
|
97
97
|
/** One event a poll found: a pushed event's fields; `cursor`, the settings to keep once it and every event before it are
|
|
98
|
-
* recorded; `left`, when it is recorded as skipped and starts nothing, why (in words). */
|
|
98
|
+
* recorded (read by the engine of the last event it records alone, so a source may make it when asked); `left`, when it is recorded as skipped and starts nothing, why (in words). */
|
|
99
99
|
export type PolledEvent = PushEvent & {
|
|
100
100
|
cursor: Record<string, string>;
|
|
101
101
|
left?: string;
|
|
102
102
|
};
|
|
103
103
|
/** What a poll found: `check`, said on the trigger as its last check; `refused`, the source's credentials refused (the
|
|
104
|
-
* engine turns the trigger off at the third in a row, `detail` its words); `
|
|
105
|
-
* (a
|
|
104
|
+
* engine turns the trigger off at the third in a row, `detail` its words); `stop`, the source can't be read again as it
|
|
105
|
+
* is (every feed a feed trigger reads gone): the engine turns the trigger off now, its source unreadable, `detail` its
|
|
106
|
+
* words; `note`, one history line that starts no run (a first poll's, a reset's); `events`, oldest first; `cursor`, the
|
|
107
|
+
* settings to keep once every event is recorded. */
|
|
106
108
|
export type PollResult = {
|
|
107
109
|
check: {
|
|
108
110
|
ok: boolean;
|
|
@@ -111,6 +113,9 @@ export type PollResult = {
|
|
|
111
113
|
refused?: {
|
|
112
114
|
detail: string;
|
|
113
115
|
};
|
|
116
|
+
stop?: {
|
|
117
|
+
detail: string;
|
|
118
|
+
};
|
|
114
119
|
note?: string;
|
|
115
120
|
events?: PolledEvent[];
|
|
116
121
|
cursor?: Record<string, string>;
|
package/dist/trigger-adapters.js
CHANGED
|
@@ -3,4 +3,5 @@ import { schedule } from "./trigger-schedule.js";
|
|
|
3
3
|
import { github } from "./trigger-github.js";
|
|
4
4
|
import { webhook } from "./trigger-webhook.js";
|
|
5
5
|
import { email } from "./trigger-email.js";
|
|
6
|
-
|
|
6
|
+
import { feed } from "./trigger-feed.js";
|
|
7
|
+
export const TRIGGER_ADAPTERS = [schedule, webhook, github, composio, email, feed];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type TriggerAdapter } from "./trigger-adapter.js";
|
|
2
|
+
/** The most items one poll takes, across its feeds: the rest wait for the next. */
|
|
3
|
+
export declare const POLL_TAKES = 20;
|
|
4
|
+
/** The most feeds one trigger reads. */
|
|
5
|
+
export declare const MAX_FEEDS = 20;
|
|
6
|
+
/** How often a feed is read by default, in seconds. */
|
|
7
|
+
export declare const DEFAULT_EVERY_S = 900;
|
|
8
|
+
/** The keys a feed's seen set keeps at least (twice its feed's length when that is more). */
|
|
9
|
+
export declare const SEEN_KEPT = 1000;
|
|
10
|
+
/** Why `url` is no feed URL a trigger reads, or undefined: an http(s) URL, with no user or password in it. */
|
|
11
|
+
export declare function urlProblem(url: unknown): string | undefined;
|
|
12
|
+
export declare const feed: TriggerAdapter;
|