@parcha/agentrun-serve 0.1.0-beta.46 → 0.1.0-beta.48
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 +211 -1
- package/NOTICE +4 -0
- package/README.md +350 -53
- package/dist/acp-package.d.ts +53 -6
- package/dist/acp-package.js +3 -3
- package/dist/adapter-facts.d.ts +3 -4
- package/dist/adapter-facts.js +4 -4
- package/dist/adapters.d.ts +3 -5
- package/dist/adapters.js +1 -31
- package/dist/agents-store.d.ts +5 -3
- package/dist/agents-store.js +13 -8
- package/dist/answer-json.d.ts +10 -0
- package/dist/answer-json.js +24 -0
- package/dist/api-only.d.ts +11 -11
- package/dist/api-only.js +16 -11
- package/dist/archil-routes.js +2 -1
- package/dist/browser-live.d.ts +9 -4
- package/dist/browser-live.js +18 -5
- package/dist/cap.js +10 -2
- package/dist/chatgpt-plan.js +2 -1
- package/dist/cli.js +109 -41
- package/dist/composio-made.d.ts +19 -2
- package/dist/composio-made.js +17 -5
- package/dist/composio-preset.d.ts +42 -7
- package/dist/composio-preset.js +106 -70
- package/dist/composio-triggers.d.ts +9 -4
- package/dist/composio-triggers.js +20 -13
- package/dist/computer-attach.d.ts +11 -10
- package/dist/computer-attach.js +13 -14
- package/dist/computer-commands.d.ts +3 -0
- package/dist/computer-commands.js +3 -2
- package/dist/computer-lost.d.ts +4 -0
- package/dist/computer-lost.js +8 -3
- package/dist/computer-routes.d.ts +8 -5
- package/dist/computer-routes.js +7 -5
- package/dist/computer-setting.d.ts +2 -0
- package/dist/computer-setting.js +2 -0
- package/dist/computers.d.ts +14 -76
- package/dist/computers.js +24 -68
- package/dist/conformance.d.ts +4 -0
- package/dist/conformance.js +6 -0
- package/dist/console/assets/index-CTGegcKt.css +1 -0
- package/dist/console/assets/index-D1Se6mgG.js +715 -0
- package/dist/console/index.html +2 -2
- package/dist/cost-heal.d.ts +13 -0
- package/dist/cost-heal.js +27 -0
- package/dist/dial-relay.d.ts +6 -2
- package/dist/dial-relay.js +9 -12
- package/dist/email/routes.js +2 -1
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +5 -0
- package/dist/exa-keyless.d.ts +1 -1
- package/dist/exa-keyless.js +1 -1
- package/dist/faux-computers.d.ts +2 -3
- package/dist/faux-computers.js +9 -31
- package/dist/github-connection.js +2 -1
- package/dist/harness-archive.d.ts +19 -2
- package/dist/harness-archive.js +49 -15
- package/dist/harness-check.d.ts +75 -0
- package/dist/harness-check.js +518 -0
- package/dist/harness-cursor.d.ts +28 -0
- package/dist/harness-cursor.js +42 -0
- package/dist/harness-goose.d.ts +4 -29
- package/dist/harness-goose.js +6 -86
- package/dist/harness-module.d.ts +4 -0
- package/dist/harness-module.js +1 -0
- package/dist/harness-owned.d.ts +52 -0
- package/dist/harness-owned.js +92 -0
- package/dist/harness-recipe.d.ts +127 -0
- package/dist/harness-recipe.js +335 -0
- package/dist/harness-table.d.ts +120 -5
- package/dist/harness-table.js +280 -6
- package/dist/harness.d.ts +2 -0
- package/dist/harness.js +5 -4
- package/dist/host-check.d.ts +6 -0
- package/dist/host-check.js +14 -0
- package/dist/host.d.ts +10 -3
- package/dist/host.js +17 -3
- package/dist/import-sources.d.ts +2 -0
- package/dist/import-sources.js +2 -0
- package/dist/import-summary.d.ts +15 -5
- package/dist/import-summary.js +24 -8
- package/dist/import.d.ts +24 -4
- package/dist/import.js +108 -26
- package/dist/key-refusal.d.ts +3 -1
- package/dist/key-refusal.js +26 -5
- package/dist/key-words.d.ts +1 -1
- package/dist/key-words.js +4 -4
- package/dist/learn/check.d.ts +3 -0
- package/dist/learn/check.js +31 -20
- package/dist/learn/compile.js +12 -5
- package/dist/learn/promote.d.ts +80 -2
- package/dist/learn/promote.js +95 -3
- package/dist/learn/secrets.d.ts +4 -0
- package/dist/learn/secrets.js +23 -0
- package/dist/learned-nodes.d.ts +4 -3
- package/dist/learned-workflow.js +4 -1
- package/dist/learning-cost.d.ts +6 -16
- package/dist/learning-cost.js +6 -12
- package/dist/learning-model.d.ts +18 -0
- package/dist/learning-model.js +77 -0
- package/dist/learning-words.d.ts +2 -0
- package/dist/learning-words.js +1 -1
- package/dist/listen-first.d.ts +10 -0
- package/dist/listen-first.js +25 -1
- package/dist/llms.txt +2 -1
- package/dist/mcp-gateway.d.ts +2 -1
- package/dist/mcp-gateway.js +31 -15
- package/dist/mcp-probe.d.ts +18 -6
- package/dist/mcp-probe.js +41 -8
- package/dist/mcp-secret-writes.d.ts +8 -0
- package/dist/mcp-secret-writes.js +104 -4
- package/dist/mcp-servers-store.d.ts +11 -5
- package/dist/mcp-servers-store.js +46 -20
- package/dist/model-form.d.ts +2 -1
- package/dist/model-form.js +30 -16
- package/dist/model-gateway.d.ts +113 -0
- package/dist/model-gateway.js +433 -0
- package/dist/model.d.ts +5 -3
- package/dist/model.js +26 -18
- package/dist/monid.js +1 -1
- package/dist/native/binding.d.ts +4 -0
- package/dist/native/binding.js +9 -0
- package/dist/native/cli.d.ts +3 -2
- package/dist/native/cli.js +6 -5
- package/dist/openapi.d.ts +2 -0
- package/dist/openapi.js +356 -43
- package/dist/owner.d.ts +4 -2
- package/dist/owner.js +10 -4
- package/dist/page.d.ts +9 -0
- package/dist/page.js +10 -2
- package/dist/port-models.js +17 -10
- package/dist/provider.d.ts +3 -3
- package/dist/provider.js +12 -3
- package/dist/public-address.d.ts +28 -0
- package/dist/public-address.js +62 -0
- package/dist/run-launch.d.ts +1 -1
- package/dist/run-launch.js +1 -1
- package/dist/run-secrets.d.ts +3 -2
- package/dist/run-secrets.js +7 -4
- package/dist/run-trace.js +6 -3
- package/dist/runner/adapter-loop.d.ts +14 -8
- package/dist/runner/adapter-loop.js +58 -24
- package/dist/runner/adapter-run-spec.d.ts +15 -2
- package/dist/runner/adapter-run-spec.js +48 -10
- package/dist/runner/adapters/index.d.ts +4 -2
- package/dist/runner/adapters/index.js +6 -26
- package/dist/runner/adapters/pi.d.ts +5 -2
- package/dist/runner/adapters/pi.js +7 -4
- package/dist/runner/audit.d.ts +7 -0
- package/dist/runner/audit.js +15 -6
- package/dist/runner/claim-secrets.js +5 -1
- package/dist/runner/cli-run-spec.js +22 -10
- package/dist/runner/compare-end.d.ts +43 -0
- package/dist/runner/compare-end.js +95 -0
- package/dist/runner/computer-journal.d.ts +3 -0
- package/dist/runner/computer-journal.js +22 -2
- package/dist/runner/conformance/host-tools.d.ts +4 -0
- package/dist/runner/conformance/host-tools.js +14 -0
- package/dist/runner/harness-loops.d.ts +6 -1
- package/dist/runner/harness-loops.js +94 -54
- package/dist/runner/held.d.ts +5 -4
- package/dist/runner/journal-kinds.d.ts +4 -1
- package/dist/runner/journal-kinds.js +3 -0
- package/dist/runner/loop-contract.d.ts +10 -0
- package/dist/runner/main.d.ts +5 -5
- package/dist/runner/main.js +62 -11
- package/dist/runner/mcp-claim.js +40 -12
- package/dist/runner/meta-tools.js +4 -2
- package/dist/runner/metrics.d.ts +26 -0
- package/dist/runner/metrics.js +44 -1
- package/dist/runner/presence.d.ts +44 -0
- package/dist/runner/presence.js +96 -0
- package/dist/runner/promotion.d.ts +70 -7
- package/dist/runner/promotion.js +178 -28
- package/dist/runner/run-child-host.js +40 -10
- package/dist/runner/runner.d.ts +5 -0
- package/dist/runner/runner.js +8 -0
- package/dist/runner/sdk-loop.js +25 -1
- package/dist/runner/store-port.d.ts +3 -0
- package/dist/runner/store-secrets.js +19 -7
- package/dist/runner/workflow-first.d.ts +5 -2
- package/dist/runner/workflow-first.js +6 -3
- package/dist/runner/workflow-spec.js +3 -2
- package/dist/runs-over-store.d.ts +7 -2
- package/dist/runs-over-store.js +12 -4
- package/dist/sdk/check.d.ts +31 -0
- package/dist/sdk/check.js +58 -0
- package/dist/sdk/runs.d.ts +11 -3
- package/dist/sdk/runs.js +90 -15
- package/dist/sdk/schema.js +12 -4
- package/dist/secret-writes.d.ts +16 -3
- package/dist/secret-writes.js +28 -3
- package/dist/server-secrets-store.js +5 -0
- package/dist/server.d.ts +34 -2
- package/dist/server.js +437 -90
- package/dist/sign-ins-secrets.js +4 -1
- package/dist/skills/agentrun-serve/SKILL.md +11 -0
- package/dist/slack-url.d.ts +5 -0
- package/dist/slack-url.js +11 -0
- package/dist/slack.d.ts +107 -0
- package/dist/slack.js +292 -0
- package/dist/start-switches.d.ts +28 -0
- package/dist/start-switches.js +37 -0
- package/dist/stats.d.ts +1 -1
- package/dist/stats.js +2 -1
- package/dist/stop-signals.d.ts +11 -0
- package/dist/stop-signals.js +22 -0
- package/dist/store/agent-body.d.ts +1 -1
- package/dist/store/agent-body.js +2 -2
- package/dist/store/index.d.ts +3 -3
- package/dist/store/index.js +1 -1
- package/dist/store/postgres/migrations/0020_runners.sql +18 -0
- package/dist/store/postgres/store.d.ts +1 -1
- package/dist/store/postgres/store.js +4 -2
- package/dist/store/schema.d.ts +13 -5
- package/dist/store/schema.js +20 -11
- package/dist/store/seal.d.ts +16 -4
- package/dist/store/sqlite/store.d.ts +1 -1
- package/dist/store/sqlite/store.js +112 -28
- package/dist/store/store.d.ts +78 -24
- package/dist/store/store.js +11 -0
- package/dist/store-reads/analytics.js +3 -2
- package/dist/store-reads/cap.d.ts +7 -0
- package/dist/store-reads/cap.js +11 -1
- package/dist/store-reads/journal.js +27 -1
- package/dist/store-reads/learning.d.ts +23 -2
- package/dist/store-reads/learning.js +29 -8
- package/dist/store-reads/runs.d.ts +9 -0
- package/dist/store-reads/runs.js +19 -6
- package/dist/store-reads/stats.d.ts +4 -1
- package/dist/store-reads/stats.js +15 -6
- package/dist/store-view.d.ts +125 -14
- package/dist/store-view.js +156 -21
- package/dist/telemetry.d.ts +7 -7
- package/dist/telemetry.js +38 -15
- package/dist/template-eval.js +5 -2
- package/dist/template-github-permissions.d.ts +5 -1
- package/dist/template-github-permissions.js +7 -3
- package/dist/timeline/index.d.ts +1 -1
- package/dist/timeline/index.js +1 -1
- package/dist/timeline/timeline.d.ts +8 -0
- package/dist/timeline/timeline.js +30 -0
- package/dist/tool-gate.d.ts +8 -4
- package/dist/tool-gate.js +6 -7
- package/dist/tool-keys-store.js +2 -2
- package/dist/tool-keys.js +2 -1
- package/dist/tool-plane.d.ts +4 -0
- package/dist/tool-plane.js +12 -12
- package/dist/trigger-adapter.d.ts +3 -4
- package/dist/trigger-adapter.js +2 -2
- package/dist/trigger-composio.js +3 -3
- package/dist/trigger-email.js +0 -2
- package/dist/trigger-feed.js +0 -2
- package/dist/trigger-schedule.js +3 -0
- package/dist/trigger-secrets-shown.d.ts +6 -3
- package/dist/trigger-secrets-shown.js +22 -13
- package/dist/trigger-targets.d.ts +12 -3
- package/dist/trigger-targets.js +90 -10
- package/dist/triggers.d.ts +2 -2
- package/dist/validate.js +5 -1
- package/dist/viewer-credential.d.ts +25 -0
- package/dist/viewer-credential.js +51 -0
- package/dist/webhooks.d.ts +82 -8
- package/dist/webhooks.js +128 -45
- package/dist/wires.d.ts +6 -1
- package/dist/wires.js +5 -0
- package/dist/workspace/attach.d.ts +3 -2
- package/dist/workspace/attach.js +2 -1
- package/dist/workspace/attached-computers.d.ts +6 -8
- package/dist/workspace/attached-computers.js +27 -24
- package/dist/workspace/computer-deps.d.ts +2 -3
- package/dist/workspace/computer-deps.js +3 -6
- package/dist/workspace/computer-for-claim.js +72 -96
- package/dist/workspace/computer-kept.d.ts +0 -7
- package/dist/workspace/computer-kept.js +0 -17
- package/dist/workspace/resolve-computer.d.ts +23 -14
- package/dist/workspace/resolve-computer.js +66 -61
- package/dist/workspace/synced-folder.d.ts +20 -15
- package/dist/workspace/synced-folder.js +33 -43
- package/launcher/agentrun-serve +4 -1
- package/package.json +18 -10
- package/skills/agentrun-serve/SKILL.md +11 -0
- package/templates/README.md +1 -1
- package/templates/code-review/agent.md +2 -3
- package/templates/code-review/evals/mentions-defused/case.yaml +0 -1
- package/templates/code-review/evals/mentions-defused/fixtures/github-mcp.json +0 -27
- package/templates/code-review/evals/other-repo/case.yaml +0 -1
- package/templates/code-review/evals/other-repo/fixtures/github-mcp.json +0 -18
- package/templates/code-review/evals/other-repo/graders/no-other-repo.md +1 -1
- package/dist/console/assets/index-C2MYaUBa.css +0 -1
- package/dist/console/assets/index-CZZeCReB.js +0 -701
package/dist/template-eval.js
CHANGED
|
@@ -25,7 +25,8 @@ import { evalClock, LAYOUTS, mailboxAfter, mailboxFixtureOf, mailboxText, mailbo
|
|
|
25
25
|
import { caseFeeds, feedFixtureOf } from "./eval-feed.js";
|
|
26
26
|
import { EMAIL_TOOLS } from "./email/names.js";
|
|
27
27
|
import { CALENDAR_EVENTS } from "./calendar/names.js";
|
|
28
|
-
import { settingsKeyOf, shellToolOf } from "./tool-gate.js";
|
|
28
|
+
import { nameMapOf, settingsKeyOf, shellToolOf } from "./tool-gate.js";
|
|
29
|
+
import { builtinHarness } from "./harness-table.js";
|
|
29
30
|
import { webShownOf } from "./timeline/index.js";
|
|
30
31
|
import { ASK_TOOL, BOUND_TOOLS } from "./tools.js";
|
|
31
32
|
import { webFixtureOf } from "./web-fake.js";
|
|
@@ -918,10 +919,12 @@ async function waitRun(api, runId, deadline, signal, queueTimeoutMs = QUEUE_TIME
|
|
|
918
919
|
* its output's head as the rows of a calls=whole read carry them (tool_input, tool_result_text), else its previews. */
|
|
919
920
|
export function callsOf(rows, harness, toolkits = {}) {
|
|
920
921
|
const results = new Map(rows.filter((row) => row.kind === "tool_result" && row.tool_use_id).map((row) => [String(row.tool_use_id), row]));
|
|
922
|
+
// The rows are a server's, read over its API: the names are the built-in harness's, the only facts known here.
|
|
923
|
+
const names = nameMapOf(harness, builtinHarness(harness)?.facts);
|
|
921
924
|
return rows.filter((row) => row.kind === "tool_use" && typeof row.tool_name === "string").map((row) => {
|
|
922
925
|
const name = row.tool_name;
|
|
923
926
|
const result = results.get(String(row.tool_use_id));
|
|
924
|
-
const key = settingsKeyOf(harness, name);
|
|
927
|
+
const key = settingsKeyOf(harness, name, names);
|
|
925
928
|
const output = typeof result?.tool_result_text === "string" ? result.tool_result_text : (result?.tool_result_preview ?? null);
|
|
926
929
|
return { tool: shellToolOf(name) ?? (key === undefined ? undefined : onServerName(key, toolkits)) ?? name, name, preview: row.tool_input_preview ?? null, ...(isObject(row.tool_input) ? { arguments: row.tool_input } : {}), status: result?.tool_status ?? null, result: output };
|
|
927
930
|
});
|
|
@@ -16,11 +16,15 @@ export type Held = {
|
|
|
16
16
|
readonly unreadable: string;
|
|
17
17
|
};
|
|
18
18
|
/** Each GitHub MCP tool a template may grant that needs more than reading what the App's metadata gives: the permission
|
|
19
|
-
* and level GitHub's permission table for its request names, and what the template does instead when it can't.
|
|
19
|
+
* and level GitHub's permission table for its request names, and what the template does instead when it can't.
|
|
20
|
+
* `public`: GitHub's table states a permission for private resources, and this request works on a public repository
|
|
21
|
+
* without it (POST /repos/{owner}/{repo}/issues: "any user with pull access to a repository can create an issue"), so the
|
|
22
|
+
* warning is about private repositories and says what a public one does. */
|
|
20
23
|
export declare const TOOL_PERMISSIONS: Record<string, {
|
|
21
24
|
permission: string;
|
|
22
25
|
level: Level;
|
|
23
26
|
instead: string;
|
|
27
|
+
public?: string;
|
|
24
28
|
}>;
|
|
25
29
|
/** The warnings applying `pkg` adds: one for each GitHub MCP tool it grants that needs a permission an installation of the
|
|
26
30
|
* App does not hold (naming each installation's account and what it holds), on an MCP server `onApp` says runs on the App's
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { NOT_SET_UP } from "./runnable.js";
|
|
2
2
|
import { mcpToolName } from "./tool-names.js";
|
|
3
3
|
/** Each GitHub MCP tool a template may grant that needs more than reading what the App's metadata gives: the permission
|
|
4
|
-
* and level GitHub's permission table for its request names, and what the template does instead when it can't.
|
|
4
|
+
* and level GitHub's permission table for its request names, and what the template does instead when it can't.
|
|
5
|
+
* `public`: GitHub's table states a permission for private resources, and this request works on a public repository
|
|
6
|
+
* without it (POST /repos/{owner}/{repo}/issues: "any user with pull access to a repository can create an issue"), so the
|
|
7
|
+
* warning is about private repositories and says what a public one does. */
|
|
5
8
|
export const TOOL_PERMISSIONS = {
|
|
6
|
-
issue_write: { permission: "issues", level: "write", instead: "keeps its draft in its answer" },
|
|
9
|
+
issue_write: { permission: "issues", level: "write", instead: "keeps its draft in its answer", public: "On a public repository GitHub takes it without: anyone who can read one may open an issue there." },
|
|
7
10
|
};
|
|
8
11
|
/** Each permission as GitHub's App settings name it. */
|
|
9
12
|
const LABELS = { issues: "Issues", pull_requests: "Pull requests", contents: "Contents", metadata: "Metadata" };
|
|
@@ -38,7 +41,8 @@ export async function appPermissionWarnings(pkg, onApp, held) {
|
|
|
38
41
|
const short = map.installations.filter((installation) => !holds(installation.permissions[wants.permission], wants.level));
|
|
39
42
|
if (short.length) {
|
|
40
43
|
const holding = short.map(({ account, permissions }) => `${permissions[wants.permission] ? `${label}: ${permissions[wants.permission]}` : `no ${label} permission`} on ${account}`).join(", ");
|
|
41
|
-
|
|
44
|
+
const where = wants.public ? " on a private repository" : "";
|
|
45
|
+
warnings.push({ field: `grants.${name}`, reason: "not_allowed", message: `${name} needs ${label}: ${wants.level}${where}, and this server's GitHub App has ${holding}, so GitHub refuses it there: ${pkg.name} ${wants.instead}.${wants.public ? ` ${wants.public}` : ""} The App's owner can add ${label}: ${wants.level} to it on GitHub.` });
|
|
42
46
|
}
|
|
43
47
|
// Installations whose map was not read in time or at all: said apart, never passed as holding it.
|
|
44
48
|
if (map.unread?.length) {
|
package/dist/timeline/index.d.ts
CHANGED
|
@@ -6,4 +6,4 @@ export { costLabel, endedUsage, PAGE_CHANGED_ROW, RUN_RESUMED, toolCallWords, TU
|
|
|
6
6
|
export { FEEDBACK_SUFFIX, isFeedbackRow, isMessageRow, isUserEntry, MESSAGE_ORIGIN, messageOrigins, NOTE_SUFFIX, originMatcher, originOf, TRIGGER_LABELS, TRIGGER_SOURCES, type MessageOrigin, type TriggerSource } from "./origin.js";
|
|
7
7
|
export { cut, scrubUrl, scrubUrls } from "./util.js";
|
|
8
8
|
export { webCut, webShownOf, webWithin, type WebShown } from "./web-calls.js";
|
|
9
|
-
export { answeredRequests, BROWSER_CHARGE, CALL_ENDED_WITH_RUN, CALL_REFUSED, CALL_RESULT_CHARS, CAP_WRAPUP, CAPS, chargedTool, COMPUTER_NOTE, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, type AgentEventLike, type DecisionLike, type EntryLike, type RunMetrics, type SideSpend, type TimelineEvent, type TimelineKind, type TimelineOptions, type ToolMetrics, } from "./timeline.js";
|
|
9
|
+
export { answeredRequests, BROWSER_CHARGE, CALL_ENDED_WITH_RUN, compactionAnswers, CALL_REFUSED, CALL_RESULT_CHARS, CAP_WRAPUP, CAPS, chargedTool, COMPUTER_NOTE, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, type AgentEventLike, type DecisionLike, type EntryLike, type RunMetrics, type SideSpend, type TimelineEvent, type TimelineKind, type TimelineOptions, type ToolMetrics, } from "./timeline.js";
|
package/dist/timeline/index.js
CHANGED
|
@@ -6,4 +6,4 @@ export { costLabel, endedUsage, PAGE_CHANGED_ROW, RUN_RESUMED, toolCallWords, TU
|
|
|
6
6
|
export { FEEDBACK_SUFFIX, isFeedbackRow, isMessageRow, isUserEntry, MESSAGE_ORIGIN, messageOrigins, NOTE_SUFFIX, originMatcher, originOf, TRIGGER_LABELS, TRIGGER_SOURCES } from "./origin.js";
|
|
7
7
|
export { cut, scrubUrl, scrubUrls } from "./util.js";
|
|
8
8
|
export { webCut, webShownOf, webWithin } from "./web-calls.js";
|
|
9
|
-
export { answeredRequests, BROWSER_CHARGE, CALL_ENDED_WITH_RUN, CALL_REFUSED, CALL_RESULT_CHARS, CAP_WRAPUP, CAPS, chargedTool, COMPUTER_NOTE, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, } from "./timeline.js";
|
|
9
|
+
export { answeredRequests, BROWSER_CHARGE, CALL_ENDED_WITH_RUN, compactionAnswers, CALL_REFUSED, CALL_RESULT_CHARS, CAP_WRAPUP, CAPS, chargedTool, COMPUTER_NOTE, endedOnTurnEndingTool, HOST_PHASE, METRIC_NAMES, REQUEST_CONTINUED, REQUEST_COST, REQUEST_COST_LATE, REQUEST_COST_PENDING, REQUEST_ENDED, REQUEST_REFUSED, REQUEST_STARTED, runMetricsOf, runMetricsWithDecisions, timelineOf, timelineReducer, TOOL_COST, TOOL_STARTED, TOOL_UNMETERED, } from "./timeline.js";
|
|
@@ -201,6 +201,14 @@ export declare const REQUEST_CONTINUED = "agentrun.request_continued";
|
|
|
201
201
|
* cut at CAPS.summary, at `at` (ms) when the host gave the time it happened, else at the time of the log before it. No
|
|
202
202
|
* request, no cost; one without a summary shows nothing. */
|
|
203
203
|
export declare const HOST_PHASE = "agentrun.phase";
|
|
204
|
+
/** Whether `entry` is pi's compaction entry answering its summary request, the one rule both journal counters read (this
|
|
205
|
+
* timeline's meter, cap.ts openFigures): a summary request that left marked as a generation is answered by pi's
|
|
206
|
+
* pi.compaction entry, since pi stores no answer for it; one a host marked as a side request (`request: "compaction"`)
|
|
207
|
+
* is closed by its own cost entry, never by that entry. Fed every entry in the journal's order, `sideSummaries` counting
|
|
208
|
+
* the side summary requests since pi's last compaction entry, which are its own. */
|
|
209
|
+
export declare function compactionAnswers(entry: EntryLike, sideSummaries: {
|
|
210
|
+
count: number;
|
|
211
|
+
}): boolean;
|
|
204
212
|
/** Written on the root as a run's process opens to go on with a run its last process left unfinished: `after` is `crash`
|
|
205
213
|
* (that process died holding the run), `server_stop` (it drained as the server stopped) or `runner_lost` (a runner took
|
|
206
214
|
* the run over once the runner holding it, named by `runner`, let its lease run out), `generation` the new process's,
|
|
@@ -124,6 +124,21 @@ export const REQUEST_CONTINUED = "agentrun.request_continued";
|
|
|
124
124
|
export const HOST_PHASE = "agentrun.phase";
|
|
125
125
|
const COMPACTION = "compaction";
|
|
126
126
|
const isCompaction = (entry) => obj(entry.data)?.request === COMPACTION;
|
|
127
|
+
/** Whether `entry` is pi's compaction entry answering its summary request, the one rule both journal counters read (this
|
|
128
|
+
* timeline's meter, cap.ts openFigures): a summary request that left marked as a generation is answered by pi's
|
|
129
|
+
* pi.compaction entry, since pi stores no answer for it; one a host marked as a side request (`request: "compaction"`)
|
|
130
|
+
* is closed by its own cost entry, never by that entry. Fed every entry in the journal's order, `sideSummaries` counting
|
|
131
|
+
* the side summary requests since pi's last compaction entry, which are its own. */
|
|
132
|
+
export function compactionAnswers(entry, sideSummaries) {
|
|
133
|
+
if (entry.kind === REQUEST_STARTED && isCompaction(entry))
|
|
134
|
+
sideSummaries.count += 1;
|
|
135
|
+
if (entry.kind !== "pi.compaction")
|
|
136
|
+
return false;
|
|
137
|
+
if (sideSummaries.count === 0)
|
|
138
|
+
return true;
|
|
139
|
+
sideSummaries.count = 0;
|
|
140
|
+
return false;
|
|
141
|
+
}
|
|
127
142
|
/** A side request's mark: its `request` is a label (a generation's, a harness's request number, is not). */
|
|
128
143
|
const isSide = (entry) => typeof obj(entry.data)?.request === "string";
|
|
129
144
|
const unsent = (entry) => obj(entry.data)?.unsent === true;
|
|
@@ -241,6 +256,8 @@ function createMeter() {
|
|
|
241
256
|
// cost, or with an end when aborted.
|
|
242
257
|
let compactions = 0;
|
|
243
258
|
let compacting = 0;
|
|
259
|
+
// Compaction summaries a host marked as side requests since pi's last pi.compaction entry: that entry is theirs.
|
|
260
|
+
const sideSummaries = { count: 0 };
|
|
244
261
|
// How many are in flight: two side requests (a turn's parallel searches) may be.
|
|
245
262
|
let sidesOpen = 0;
|
|
246
263
|
const tokens = { input: 0, cacheRead: 0, cacheWrite: 0, output: 0 };
|
|
@@ -257,6 +274,7 @@ function createMeter() {
|
|
|
257
274
|
function push(entry) {
|
|
258
275
|
const message = entry.model?.[0];
|
|
259
276
|
const data = obj(entry.data);
|
|
277
|
+
const summaryAnswered = compactionAnswers(entry, sideSummaries);
|
|
260
278
|
if (entry.kind === "pi.assistant" && entry.recordedCall && message) {
|
|
261
279
|
// A call the loop's record kept (a CLI's, or one a tool of pi's nested): shown as an answer's call, never a request.
|
|
262
280
|
return "call";
|
|
@@ -276,6 +294,18 @@ function createMeter() {
|
|
|
276
294
|
continued -= 1;
|
|
277
295
|
return "continued";
|
|
278
296
|
}
|
|
297
|
+
else if (entry.kind === "pi.compaction") {
|
|
298
|
+
// pi's summary of the older context. A summary request that left through the run's own model port was marked as a
|
|
299
|
+
// generation is (no `request` label) and booked at its price, and pi stores no answer for it: its cost rides on the
|
|
300
|
+
// answer pi stores beside it (what the session booked since the last one), so this entry is that request's answer,
|
|
301
|
+
// at no cost of its own here, its tokens unknown to pi's entries. One a host marked as a side request is closed by
|
|
302
|
+
// its own cost entry, never here. Shown as its phase row all the same.
|
|
303
|
+
if (summaryAnswered && marked - answered - freeUnanswered - atMostUnanswered - (freeEnded ? 1 : 0) - (atMostEnded !== undefined ? 1 : 0) > 0) {
|
|
304
|
+
(requests += 1), (answered += 1);
|
|
305
|
+
addTokens(undefined);
|
|
306
|
+
}
|
|
307
|
+
return undefined;
|
|
308
|
+
}
|
|
279
309
|
else if (entry.kind === REQUEST_STARTED && isSide(entry)) {
|
|
280
310
|
compacting += 1;
|
|
281
311
|
sidesOpen += 1;
|
package/dist/tool-gate.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SHELL_FAMILY, SHELL_WATCHERS, shellToolOf } from "@parcha/agentrun-kernel/kernel";
|
|
2
|
+
import { type AdapterFacts } from "@parcha/agentrun-kernel";
|
|
2
3
|
import type { Workspace } from "./workspace/workspace.js";
|
|
3
4
|
import { type ToolSettingsRead } from "./tool-plane.js";
|
|
4
5
|
import { type SettingFrom } from "./refusal-words.js";
|
|
@@ -35,13 +36,14 @@ export type NameMap = ReadonlyMap<string, string>;
|
|
|
35
36
|
/** Every name a session on `harness` gives its tools, to the settings key each is held to: the shell family (bash's),
|
|
36
37
|
* table, own and decision tools, read_skill_file (`read`), the kinds' tools (a shared one by its first kind), nativeTools,
|
|
37
38
|
* the browser's registrations. The names are the host's own: each adapter maps its CLI's names to them (its facts'
|
|
38
|
-
* hostName). The first named wins.
|
|
39
|
-
|
|
39
|
+
* hostName). The first named wins. `facts`: the adapter's, as the owner's table has them (harness-table.ts factsOf: a
|
|
40
|
+
* module's harness's too); undefined for a harness with none (pi). */
|
|
41
|
+
export declare function nameMapOf(harness: string, facts: AdapterFacts | undefined): NameMap;
|
|
40
42
|
/** The settings key a call named `name` on `harness` is held to: a lookup in the session's names (`names`), then the open
|
|
41
43
|
* open family no list holds (a catalog name, `mcp:<server>/<tool>` or `monid:<provider>/<endpoint>`). Undefined: nothing
|
|
42
44
|
* maps it, and the gate asks (an MCP tool's or monid endpoint's wire name is read back by the loop, ClaimMcp.catalogOf,
|
|
43
45
|
* before the gate is asked). */
|
|
44
|
-
export declare function settingsKeyOf(harness: string, name: string, names
|
|
46
|
+
export declare function settingsKeyOf(harness: string, name: string, names: NameMap): string | undefined;
|
|
45
47
|
/** A pinned argument's scalar: `null` holds for a call that leaves the argument out (or gives null). */
|
|
46
48
|
export type PinScalar = string | number | boolean | null;
|
|
47
49
|
/** A pinned object argument's keys: the argument, when given (not left out, nor null), is an object whose keys are among
|
|
@@ -182,6 +184,7 @@ export declare function runGate(where: {
|
|
|
182
184
|
computer?: boolean;
|
|
183
185
|
effectOf?: (name: string) => ToolEffect | undefined;
|
|
184
186
|
argumentsOf?: ArgumentsOf;
|
|
187
|
+
facts: AdapterFacts | undefined;
|
|
185
188
|
}, runId: string, revision: {
|
|
186
189
|
kind: string;
|
|
187
190
|
body: {
|
|
@@ -219,7 +222,8 @@ export declare class RunGate {
|
|
|
219
222
|
computer?: boolean; /** The run's computer kind (its revision's setting): the key a computer tool's refusal and ask name on a tie (kindSetting). */
|
|
220
223
|
kind?: string;
|
|
221
224
|
effectOf?: (name: string) => ToolEffect | undefined; /** The arguments each MCP tool's listing in the run's pin declares (ClaimMcp.argumentsOf), for a pinned tool's closure (pinRefusal). */
|
|
222
|
-
argumentsOf?: ArgumentsOf;
|
|
225
|
+
argumentsOf?: ArgumentsOf; /** The harness's adapter facts on the owner's table (its native tools' names, nameMapOf); undefined for one with none. */
|
|
226
|
+
facts: AdapterFacts | undefined;
|
|
223
227
|
}, readServerSettings: () => ToolSettingsRead, overrides?: PermissionSettings, approvers?: boolean, approvals?: Approvals);
|
|
224
228
|
private names?;
|
|
225
229
|
/** A tool's permission now (permissionOf): the revision's own over the server's setting, read at each call, so a change
|
package/dist/tool-gate.js
CHANGED
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
import { COMPUTER_OP_TOOL, computerToolDefs, defaultPermissionOf, SHELL_FAMILY, SHELL_WATCHERS, shellPermission, shellToolOf } from "@parcha/agentrun-kernel/kernel";
|
|
28
28
|
import { READ_SKILL_FILE } from "@parcha/agentrun-kernel";
|
|
29
29
|
import { COMPUTER_ROOT } from "./workspace/paths.js";
|
|
30
|
-
import { builtinHarness } from "./harness-table.js";
|
|
31
30
|
import { META_TOOLS } from "./meta-tool-names.js";
|
|
32
31
|
import { DEFAULT_HARNESS } from "./harness.js";
|
|
33
32
|
import { DECISION_PROVIDER_KEYS, KIND_KEYS, SERVE_OWN_TOOLS } from "./tool-plane.js";
|
|
@@ -98,9 +97,9 @@ const STRICTNESS = { allow: 0, ask: 1, deny: 2 };
|
|
|
98
97
|
/** Every name a session on `harness` gives its tools, to the settings key each is held to: the shell family (bash's),
|
|
99
98
|
* table, own and decision tools, read_skill_file (`read`), the kinds' tools (a shared one by its first kind), nativeTools,
|
|
100
99
|
* the browser's registrations. The names are the host's own: each adapter maps its CLI's names to them (its facts'
|
|
101
|
-
* hostName). The first named wins.
|
|
102
|
-
|
|
103
|
-
|
|
100
|
+
* hostName). The first named wins. `facts`: the adapter's, as the owner's table has them (harness-table.ts factsOf: a
|
|
101
|
+
* module's harness's too); undefined for a harness with none (pi). */
|
|
102
|
+
export function nameMapOf(harness, facts) {
|
|
104
103
|
const names = new Map();
|
|
105
104
|
const name = (own, key) => void (names.has(own) || names.set(own, key));
|
|
106
105
|
for (const [own, key] of Object.entries(SHELL_FAMILY))
|
|
@@ -121,7 +120,7 @@ export function nameMapOf(harness) {
|
|
|
121
120
|
* open family no list holds (a catalog name, `mcp:<server>/<tool>` or `monid:<provider>/<endpoint>`). Undefined: nothing
|
|
122
121
|
* maps it, and the gate asks (an MCP tool's or monid endpoint's wire name is read back by the loop, ClaimMcp.catalogOf,
|
|
123
122
|
* before the gate is asked). */
|
|
124
|
-
export function settingsKeyOf(harness, name, names
|
|
123
|
+
export function settingsKeyOf(harness, name, names) {
|
|
125
124
|
const own = names.get(name);
|
|
126
125
|
if (own !== undefined)
|
|
127
126
|
return own;
|
|
@@ -350,7 +349,7 @@ export function previewOf(text) {
|
|
|
350
349
|
export function runGate(where, runId, revision, serverSettings, approvers) {
|
|
351
350
|
// The run's computer kind, from its revision's setting (as the claim starts it): a computer tool's words name it.
|
|
352
351
|
const kind = settingOfDefinition(revision.body)?.computer.kind;
|
|
353
|
-
return new RunGate({ root: where.root, work: where.work, runId, harness: revision.body.harness ?? DEFAULT_HARNESS, ...(where.computer === undefined ? {} : { computer: where.computer }), ...(kind !== undefined ? { kind } : {}), ...(where.effectOf ? { effectOf: where.effectOf } : {}), ...(where.argumentsOf ? { argumentsOf: where.argumentsOf } : {}) }, serverSettings, (revision.body.toolSettings ?? {}), approvers, approvalsOf(revision.body.approvals));
|
|
352
|
+
return new RunGate({ root: where.root, work: where.work, runId, harness: revision.body.harness ?? DEFAULT_HARNESS, ...(where.computer === undefined ? {} : { computer: where.computer }), ...(kind !== undefined ? { kind } : {}), ...(where.effectOf ? { effectOf: where.effectOf } : {}), ...(where.argumentsOf ? { argumentsOf: where.argumentsOf } : {}), facts: where.facts }, serverSettings, (revision.body.toolSettings ?? {}), approvers, approvalsOf(revision.body.approvals));
|
|
354
353
|
}
|
|
355
354
|
/** A run's tool gate on the runner: its policy, asked before each call's intent (decide). */
|
|
356
355
|
export class RunGate {
|
|
@@ -422,7 +421,7 @@ export class RunGate {
|
|
|
422
421
|
if (kinds)
|
|
423
422
|
return this.kindSetting(name, kinds).key;
|
|
424
423
|
const harness = this.where.harness ?? DEFAULT_HARNESS;
|
|
425
|
-
return settingsKeyOf(harness, name, (this.names ??= nameMapOf(harness)));
|
|
424
|
+
return settingsKeyOf(harness, name, (this.names ??= nameMapOf(harness, this.where.facts)));
|
|
426
425
|
}
|
|
427
426
|
/** A computer tool's settings keys (KIND_TOOLS), the run's own kind first (where.kind); undefined for any other tool. */
|
|
428
427
|
kindKeysOf(tool) {
|
package/dist/tool-keys-store.js
CHANGED
|
@@ -35,8 +35,8 @@ const fingerprint = (key) => createHmac("sha256", key).update("agentrun-serve se
|
|
|
35
35
|
/** What the start's log line says to a person when saved keys do not open, by why: where they are kept is the server's
|
|
36
36
|
* store (`kept=store`), and what to do is to save them again in the console's Settings. */
|
|
37
37
|
export const REENTER_SAID = {
|
|
38
|
-
seal_key_changed: "these saved keys were sealed under another seal key, so they do not open: save them again in Settings →
|
|
39
|
-
file_unreadable: "these saved keys do not read: save them again in Settings →
|
|
38
|
+
seal_key_changed: "these saved keys were sealed under another seal key, so they do not open: save them again in Settings → API Keys",
|
|
39
|
+
file_unreadable: "these saved keys do not read: save them again in Settings → API Keys",
|
|
40
40
|
};
|
|
41
41
|
/** The saved tool keys over the store. `toolKeysOverStore` builds it; the server awaits load() once before the first read. */
|
|
42
42
|
class ToolKeysOverStore {
|
package/dist/tool-keys.js
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
import { HARNESSES } from "./harness.js";
|
|
7
7
|
import { MODEL_KEYS } from "./model.js";
|
|
8
8
|
import { TOOL_KEY_ROWS } from "./key-words.js";
|
|
9
|
-
import { registerSecretWrite, secretMeta, secretName } from "./secret-writes.js";
|
|
9
|
+
import { registerSecretPage, registerSecretWrite, secretMeta, secretName } from "./secret-writes.js";
|
|
10
10
|
// Every value a person saves here is a secret (a tool's key, a model provider's key; BROWSERBASE_PROJECT_ID is kept the
|
|
11
11
|
// same way): saving one, replacing it or removing it takes the owner's session (secret-writes.ts), never the token.
|
|
12
12
|
registerSecretWrite("saveToolKey", () => true);
|
|
13
13
|
registerSecretWrite("deleteToolKey", () => true);
|
|
14
|
+
registerSecretPage(["saveToolKey", "deleteToolKey"], "/#/settings/keys");
|
|
14
15
|
export const SEAL_KEY_ENV = "AGENTRUN_SEAL_KEY";
|
|
15
16
|
/** Each key a person may save, fixed here: its kind, the fields it is entered as (BROWSERBASE_PROJECT_ID is no secret,
|
|
16
17
|
* and is kept the same way), and what it may unlock: tools by name, and `decisions.<id>`, a workflow's decision
|
package/dist/tool-plane.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { InputIssue } from "./errors.js";
|
|
2
2
|
import type { Settings } from "./store/index.js";
|
|
3
3
|
import { type HarnessId } from "./harness.js";
|
|
4
|
+
import type { AdapterFacts } from "@parcha/agentrun-kernel";
|
|
4
5
|
import { type ShellPlace } from "@parcha/agentrun-kernel/kernel";
|
|
5
6
|
import { type Permission, type Pin, type ToolEffect } from "./tool-gate.js";
|
|
6
7
|
import { type BashPolicy } from "./bash-read-only.js";
|
|
@@ -121,6 +122,9 @@ export type ResolveInput = {
|
|
|
121
122
|
openRouter?: boolean;
|
|
122
123
|
/** Its permission in force (tool-gate.ts); absent, allow. */
|
|
123
124
|
permission?: Permission;
|
|
125
|
+
/** The facts of the adapter the harness runs on (its own search, its wire), its owner's table entry's (harness-table.ts
|
|
126
|
+
* factsOf: a module's harness's too); undefined for one with none (pi). Always given: a caller names them. */
|
|
127
|
+
facts: AdapterFacts | undefined;
|
|
124
128
|
};
|
|
125
129
|
/** Whether a run on `harness` sends through OpenRouter, where a harness's own search does not run: false for one with
|
|
126
130
|
* none (and for pi, whose hosted search is asked of the model's provider). */
|
package/dist/tool-plane.js
CHANGED
|
@@ -25,8 +25,8 @@ import { PROVIDERS as COMPUTER_PROVIDERS } from "@parcha/agentrun-computer";
|
|
|
25
25
|
import { decisionKeysOf, PARALLEL_KEY_ENV } from "./decisions.js";
|
|
26
26
|
import { keyNeeded } from "./key-words.js";
|
|
27
27
|
import { DEFAULT_HARNESS, HARNESSES } from "./harness.js";
|
|
28
|
-
import {
|
|
29
|
-
import { viaOpenRouter,
|
|
28
|
+
import { factsOf as tableFactsOf, harnessOf } from "./harness-table.js";
|
|
29
|
+
import { viaOpenRouter, wireOf } from "./provider.js";
|
|
30
30
|
import { savedIn } from "./secrets.js";
|
|
31
31
|
import { hostModel } from "./model.js";
|
|
32
32
|
import { NEEDS_A_COMPUTER, NO_SHELL } from "@parcha/agentrun-kernel/kernel";
|
|
@@ -144,9 +144,9 @@ export const HOSTED_SEARCH_PROVIDERS = ["anthropic", "openai"];
|
|
|
144
144
|
const cappedOwn = (id, label, mode) => mode === "native"
|
|
145
145
|
? { id: `${id} under a spend cap: ${label}'s own search has per-use fees a spend cap cannot reserve yet, so web_search works under a cap through the default provider, auto`, why: `under a spend cap ${label}'s own search is not offered, since a cap cannot reserve its per-use fees yet` }
|
|
146
146
|
: { id: `${id} under a spend cap`, why: `under a spend cap ${label}'s own search is not offered, since its request has no input bound` };
|
|
147
|
-
/**
|
|
148
|
-
*
|
|
149
|
-
const
|
|
147
|
+
/** `harness`'s facts on `env`'s owner table, as a ResolveInput carries them (a stand-in keeps the facts of the harness it
|
|
148
|
+
* stands in for, harness-table.ts); undefined for one that has none. */
|
|
149
|
+
const withFacts = (env, harness) => ({ facts: tableFactsOf(env, harness) });
|
|
150
150
|
/** Whether a run on `harness` sends through OpenRouter, where a harness's own search does not run: false for one with
|
|
151
151
|
* none (and for pi, whose hosted search is asked of the model's provider). */
|
|
152
152
|
export const ownSearchViaOpenRouter = (env, harness, model) => {
|
|
@@ -164,13 +164,13 @@ function noNative(input) {
|
|
|
164
164
|
// provider-hosted tool) has none at all. Where there is none, `native` is unavailable, and `auto` goes to Parallel on
|
|
165
165
|
// the server's key (its fee booked and held by a cap, paid-calls.ts), else to keyless Exa.
|
|
166
166
|
const vendor = input.model?.slice(0, Math.max(0, input.model.indexOf("/")));
|
|
167
|
-
const facts =
|
|
167
|
+
const { facts } = input;
|
|
168
168
|
if (facts) {
|
|
169
169
|
if (!facts.webSearch)
|
|
170
170
|
return { id: `${input.harness}, whose model requests carry no provider-hosted tool`, why: `${facts.label}'s model requests carry no provider-hosted tool` };
|
|
171
171
|
if (input.openRouter)
|
|
172
172
|
return { id: `${input.harness} on OpenRouter`, why: `through OpenRouter ${facts.label}'s own search is not run, and its searches are not counted to price` };
|
|
173
|
-
if (input.gateway &&
|
|
173
|
+
if (input.gateway && wireOf(facts.wire)?.gateway)
|
|
174
174
|
return { id: `${input.harness} behind a gateway`, why: `behind a gateway ${facts.label} has no own search` };
|
|
175
175
|
return input.capped ? cappedOwn(input.harness, facts.label, facts.webSearch) : undefined;
|
|
176
176
|
}
|
|
@@ -182,7 +182,7 @@ function noNative(input) {
|
|
|
182
182
|
}
|
|
183
183
|
/** The native search of a run that has one, in a sentence. */
|
|
184
184
|
const nativeWhy = (input) => {
|
|
185
|
-
const facts =
|
|
185
|
+
const { facts } = input;
|
|
186
186
|
return facts?.webSearch ? `${facts.label}'s own search` : `${input.model?.startsWith("openai/") ? "OpenAI" : "Anthropic"}'s hosted search, for ${input.model}`;
|
|
187
187
|
};
|
|
188
188
|
/** What `capability` resolves to on a run of `input`, and why in a plain sentence (capabilities' `why`): one rule, so
|
|
@@ -205,7 +205,7 @@ export function explainCapability(capability, input) {
|
|
|
205
205
|
return { resolves: "exa-keyless", why: `keyless Exa, ${picked}: Exa's free search, no key` };
|
|
206
206
|
// Under ask, a harness's own search runs inside its CLI, where no call can wait for a person: none on claude-agent or
|
|
207
207
|
// codex then, and the kernel's search, which the gate holds, in its place. pi's is a tool of the run's, which it holds.
|
|
208
|
-
const asks = input.permission === "ask" &&
|
|
208
|
+
const asks = input.permission === "ask" && input.facts !== undefined;
|
|
209
209
|
const without = noNative(input);
|
|
210
210
|
if (chosen === "native" && asks && without === undefined)
|
|
211
211
|
return { resolves: NATIVE_ASKS, why: "native search cannot wait for an approval: it runs inside the harness's CLI" };
|
|
@@ -214,7 +214,7 @@ export function explainCapability(capability, input) {
|
|
|
214
214
|
return none === undefined ? { resolves: "native", why: nativeWhy(input) } : { resolves: `unavailable: no native search for ${none.id}`, why: `no native search for ${none.id}` };
|
|
215
215
|
// `auto` skips a harness's own search that has per-use fees (its facts' `native`: the provider's search tool), an
|
|
216
216
|
// explicit pick (`native`): Parallel on the server's key, else keyless Exa.
|
|
217
|
-
const facts =
|
|
217
|
+
const { facts } = input;
|
|
218
218
|
if (facts?.webSearch === "native")
|
|
219
219
|
return input.parallelKey ? { resolves: "parallel", why: key } : { resolves: "exa-keyless", why: `Exa's free keyless search, no key; ${facts.label}'s own search is an explicit pick` };
|
|
220
220
|
if (none === undefined)
|
|
@@ -291,7 +291,7 @@ export function explainsView(env, settings, overrides = {}, model) {
|
|
|
291
291
|
const input = { ...served(env), ...picked(name, settings, overrides) };
|
|
292
292
|
const each = HARNESSES.map((harness) => {
|
|
293
293
|
const on = model ?? hostModel(env, "default", harness);
|
|
294
|
-
return [harness, explainCapability(name, { ...input, ...(on ? { model: on } : {}), harness, openRouter: ownSearchViaOpenRouter(env, harness, on) })];
|
|
294
|
+
return [harness, explainCapability(name, { ...input, ...(on ? { model: on } : {}), harness, ...withFacts(env, harness), openRouter: ownSearchViaOpenRouter(env, harness, on) })];
|
|
295
295
|
});
|
|
296
296
|
return [name, { resolves: Object.fromEntries(each.map(([harness, said]) => [harness, said.resolves])), why: Object.fromEntries(each.map(([harness, said]) => [harness, said.why])) }];
|
|
297
297
|
}));
|
|
@@ -322,7 +322,7 @@ export function planeFor(env, tooling, settings, { capped = false, run = false }
|
|
|
322
322
|
if (!granted.includes(name))
|
|
323
323
|
continue;
|
|
324
324
|
const chosen = picked(name, settings, tooling.overrides, tooling.approvals ?? "ask");
|
|
325
|
-
plane[name] = resolveCapability(name, { ...served(env), harness, capped, openRouter: ownSearchViaOpenRouter(env, harness, model), ...(model ? { model } : {}), ...chosen, ...(run && chosen.permission === "deny" ? { permission: "ask" } : {}) });
|
|
325
|
+
plane[name] = resolveCapability(name, { ...served(env), harness, ...withFacts(env, harness), capped, openRouter: ownSearchViaOpenRouter(env, harness, model), ...(model ? { model } : {}), ...chosen, ...(run && chosen.permission === "deny" ? { permission: "ask" } : {}) });
|
|
326
326
|
}
|
|
327
327
|
// The model a search through its provider's hosted search asks (hosted-search.ts): pi's own web_search, and on
|
|
328
328
|
// another harness, whose agent searches with its own tool, a learned workflow's call node (learned-workflow.ts).
|
|
@@ -2,7 +2,7 @@ import type { InputIssue } from "./errors.js";
|
|
|
2
2
|
import type { SettingsSpec } from "./sealed-settings-store.js";
|
|
3
3
|
type Json = Record<string, unknown>;
|
|
4
4
|
/** Whether a run `adapter`'s firing starts is handed its trigger's last completed result: the one place it is decided
|
|
5
|
-
* (its previousResult, by default
|
|
5
|
+
* (its previousResult, by default false: a source opts in). */
|
|
6
6
|
export declare const carriesPrevious: (adapter: Pick<TriggerAdapter, "previousResult">) => boolean;
|
|
7
7
|
/** The most of a firing's payload passed on, in bytes of UTF-8 (triggers.ts cuts past it, at a character's start). A
|
|
8
8
|
* source that answers JSON fits its payload within it first (trigger-email.ts), so its JSON is never cut. */
|
|
@@ -28,9 +28,8 @@ export type TriggerAdapter = {
|
|
|
28
28
|
/** `clock`: it fires on its own times, read by the engine's timer (a source that polls, on each). `push`: a request delivered to the server fires it,
|
|
29
29
|
* keyed by the sender's own id, which a retry repeats. */
|
|
30
30
|
delivery: "clock" | "push";
|
|
31
|
-
/** Whether a run it starts is handed its trigger's last completed result (
|
|
32
|
-
*
|
|
33
|
-
* different person's (an email's sender), so one run's answer is never handed to the next. */
|
|
31
|
+
/** Whether a run it starts is handed its trigger's last completed result (previousResultOf). Default false. true only
|
|
32
|
+
* for a source whose runs repeat one job, never for one whose firings are different events. */
|
|
34
33
|
previousResult?: boolean;
|
|
35
34
|
/** Whether its words are its owner's (a run's message origin `owner`): true only when the owner wrote them as they set
|
|
36
35
|
* it up; never for words that come from outside. */
|
package/dist/trigger-adapter.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { unknownFields } from "./validate.js";
|
|
2
2
|
/** Whether a run `adapter`'s firing starts is handed its trigger's last completed result: the one place it is decided
|
|
3
|
-
* (its previousResult, by default
|
|
4
|
-
export const carriesPrevious = (adapter) => adapter.previousResult ??
|
|
3
|
+
* (its previousResult, by default false: a source opts in). */
|
|
4
|
+
export const carriesPrevious = (adapter) => adapter.previousResult ?? false;
|
|
5
5
|
/** The most of a firing's payload passed on, in bytes of UTF-8 (triggers.ts cuts past it, at a character's start). A
|
|
6
6
|
* source that answers JSON fits its payload within it first (trigger-email.ts), so its JSON is never cut. */
|
|
7
7
|
export const PAYLOAD_KEPT_BYTES = 16 * 1024;
|
package/dist/trigger-composio.js
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
// that scope. Every event of the project comes to that one route, checked once with the secret (trigger-signatures.ts's
|
|
7
7
|
// composio scheme); each trigger whose instance is the delivery's metadata.trigger_id and whose `accept` takes it fires,
|
|
8
8
|
// each its own run. This is the one way Composio's events start runs: a webhook trigger takes no composio signature.
|
|
9
|
-
// A config can hold a credential
|
|
10
|
-
//
|
|
11
|
-
//
|
|
9
|
+
// A config can hold a credential. Composio's trigger schemas mark no field secret (their `config` is a plain JSON
|
|
10
|
+
// schema: type, title, description, required), so a field is sealed by its name (sealedConfigFields), or as an address
|
|
11
|
+
// carrying a credential (credentialUrl): kept in this source's sealed settings, the trigger keeping SEALED_MASK in its
|
|
12
12
|
// place and the field named in `sealed_config`, so no answer, row or log holds it (composio-triggers.ts).
|
|
13
13
|
import { ACCEPT_SCHEMA, acceptOf, acceptRefusal } from "./trigger-accept.js";
|
|
14
14
|
import { closedSchema, unknownSourceFields } from "./trigger-adapter.js";
|
package/dist/trigger-email.js
CHANGED
|
@@ -138,8 +138,6 @@ export const email = {
|
|
|
138
138
|
label: "email trigger",
|
|
139
139
|
delivery: "clock",
|
|
140
140
|
owner: false,
|
|
141
|
-
// Each message is its sender's: one run's answer (to alice) is never handed to the next (bob's).
|
|
142
|
-
previousResult: false,
|
|
143
141
|
settings: { scope: "trigger", fields: { [CURSOR]: { public: true }, [LAST_CHECK]: { public: true } } },
|
|
144
142
|
describe: `{kind: "email", account?: "${DEFAULT_ACCOUNT}", mailbox?: "INBOX", every_s?: ${MIN_EVERY_S}, accept?: [{event: "${EVENT}", where?}]}`,
|
|
145
143
|
fires: "each new message in the server's email account's mailbox (`email`), read every every_s seconds, that its `accept` takes",
|
package/dist/trigger-feed.js
CHANGED
|
@@ -375,8 +375,6 @@ export const feed = {
|
|
|
375
375
|
label: "feed trigger",
|
|
376
376
|
delivery: "clock",
|
|
377
377
|
owner: false,
|
|
378
|
-
// Each item is its own: one run's answer is never handed to the next.
|
|
379
|
-
previousResult: false,
|
|
380
378
|
settings: { scope: "trigger", fields: { [CURSOR]: { public: true }, [LAST_CHECK]: { public: true } } },
|
|
381
379
|
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?}]}`,
|
|
382
380
|
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",
|
package/dist/trigger-schedule.js
CHANGED
|
@@ -40,6 +40,9 @@ export const schedule = {
|
|
|
40
40
|
label: "schedule",
|
|
41
41
|
delivery: "clock",
|
|
42
42
|
owner: true,
|
|
43
|
+
// Its runs repeat one job (a weekly digest): each is handed its trigger's last completed result, to leave out what
|
|
44
|
+
// that one reported.
|
|
45
|
+
previousResult: true,
|
|
43
46
|
describe: '{kind: "schedule", cron, timezone}, {kind: "schedule", at}, {kind: "schedule", every_s, start_at?}',
|
|
44
47
|
fires: `a cron line in a zone, one time, every N seconds (${MIN_EVERY_S} or more)`,
|
|
45
48
|
schemas: SCHEMAS,
|
|
@@ -2,9 +2,9 @@ import { type SecretMeta } from "./secret-writes.js";
|
|
|
2
2
|
import type { TriggerAdapter } from "./trigger-adapter.js";
|
|
3
3
|
/** What the token's answer says of a webhook trigger's secret, made and kept but not shown to it. */
|
|
4
4
|
export declare const TRIGGER_SECRET_WORDS = "Open the console to see this trigger's signing secret once: rotate it there.";
|
|
5
|
-
/** What the token's answer says of the outbound webhook's secret: the console
|
|
6
|
-
*
|
|
7
|
-
export declare const WEBHOOK_SECRET_WORDS = "Open the console to
|
|
5
|
+
/** What the token's answer says of the outbound webhook's secret: the console's Rotate secret makes a new one and shows it
|
|
6
|
+
* once. */
|
|
7
|
+
export declare const WEBHOOK_SECRET_WORDS = "Open Settings \u2192 Webhook in the console to rotate this webhook's signing secret and see the new one once.";
|
|
8
8
|
/** A webhook trigger's minted secret's metadata, named trigger:<id>: made by this server at a console's or a script's
|
|
9
9
|
* request (source console). `changedAt`: when it was made, where known (its create's or rotation's answer); its row
|
|
10
10
|
* keeps no time yet, so a read says null. */
|
|
@@ -31,6 +31,9 @@ export declare const webhookSecretMeta: (set: boolean, changedAt: string | null)
|
|
|
31
31
|
/** PUT /settings/webhook's answer: the minted value (the first save's) as `signing_secret` to a caller that may hold it,
|
|
32
32
|
* else the words. `view` carries the `secret` metadata already. */
|
|
33
33
|
export declare function webhookSaved(view: Record<string, unknown>, minted: string | undefined, mayHold: boolean): Record<string, unknown>;
|
|
34
|
+
/** POST /settings/webhook/secret's answer (the owner's session alone reaches it): the webhook as a read answers it, its
|
|
35
|
+
* `secret` metadata the new secret's, and the new value as `signing_secret`, this once. */
|
|
36
|
+
export declare const webhookRotated: (view: Record<string, unknown>, minted: string) => Record<string, unknown>;
|
|
34
37
|
/** What a trigger's view says of a secret its sealed settings keep but that does not open here (sealed under another seal
|
|
35
38
|
* key): unset, and why. */
|
|
36
39
|
export declare const TRIGGER_SECRET_UNOPENED = "Its signing secret does not open under this server's seal key: rotate it in the console.";
|
|
@@ -1,21 +1,27 @@
|
|
|
1
1
|
// Who sees a signing secret this server mints: a webhook trigger's (POST /triggers, POST /triggers/{id}/secret) and the
|
|
2
|
-
// outbound webhook's (the first PUT /settings/webhook). Each is shown once, as
|
|
3
|
-
// may write secrets (secret-writes.ts, the owner's signed-in session): the
|
|
4
|
-
// screens. The API token, which a run's process, an agent's MCP client or a
|
|
5
|
-
// secret's metadata (`secret`, the one SecretMeta shape) and the words that
|
|
6
|
-
//
|
|
7
|
-
// the
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
//
|
|
11
|
-
//
|
|
2
|
+
// outbound webhook's (the first PUT /settings/webhook, POST /settings/webhook/secret). Each is shown once, as
|
|
3
|
+
// `signing_secret`, and only to a caller that may write secrets (secret-writes.ts, the owner's signed-in session): the
|
|
4
|
+
// console's Triggers and Settings → Webhook screens. The API token, which a run's process, an agent's MCP client or a
|
|
5
|
+
// script may hold, gets what it made with the secret's metadata (`secret`, the one SecretMeta shape) and the words that
|
|
6
|
+
// send the person to the console for it.
|
|
7
|
+
// Rotating a trigger's secret, or the outbound webhook's, is a secret write: the token is refused it in the secret-write
|
|
8
|
+
// words, at the one check in the server's dispatch.
|
|
9
|
+
import { registerSecretPage, registerSecretWrite, secretMeta, secretName } from "./secret-writes.js";
|
|
10
|
+
// Replacing a trigger's secret or the outbound webhook's, and removing the outbound webhook (its secret goes with it), are
|
|
11
|
+
// secret writes. A trigger's create and the outbound webhook's first save mint one and write none the caller gave: the
|
|
12
|
+
// token may make them, and is shown no value.
|
|
12
13
|
registerSecretWrite("rotateTriggerSecret", () => true);
|
|
14
|
+
registerSecretWrite("rotateWebhookSecret", () => true);
|
|
13
15
|
registerSecretWrite("deleteWebhook", () => true);
|
|
16
|
+
// Where the owner finishes each in the console: the trigger's own page (Rotate), and Settings → Webhook (Rotate secret,
|
|
17
|
+
// Remove). The webhook's URL is never in a link: it can be a credential itself (webhooks.ts shownUrl).
|
|
18
|
+
registerSecretPage("rotateTriggerSecret", (_body, { params: [id] }) => (id && /^[A-Za-z0-9_-]{1,128}$/.test(id) ? `/#/triggers/${id}` : "/#/triggers"));
|
|
19
|
+
registerSecretPage(["rotateWebhookSecret", "deleteWebhook"], "/#/settings/webhook");
|
|
14
20
|
/** What the token's answer says of a webhook trigger's secret, made and kept but not shown to it. */
|
|
15
21
|
export const TRIGGER_SECRET_WORDS = "Open the console to see this trigger's signing secret once: rotate it there.";
|
|
16
|
-
/** What the token's answer says of the outbound webhook's secret: the console
|
|
17
|
-
*
|
|
18
|
-
export const WEBHOOK_SECRET_WORDS = "Open the console to
|
|
22
|
+
/** What the token's answer says of the outbound webhook's secret: the console's Rotate secret makes a new one and shows it
|
|
23
|
+
* once. */
|
|
24
|
+
export const WEBHOOK_SECRET_WORDS = "Open Settings → Webhook in the console to rotate this webhook's signing secret and see the new one once.";
|
|
19
25
|
/** A webhook trigger's minted secret's metadata, named trigger:<id>: made by this server at a console's or a script's
|
|
20
26
|
* request (source console). `changedAt`: when it was made, where known (its create's or rotation's answer); its row
|
|
21
27
|
* keeps no time yet, so a read says null. */
|
|
@@ -44,6 +50,9 @@ export function webhookSaved(view, minted, mayHold) {
|
|
|
44
50
|
return view;
|
|
45
51
|
return mayHold ? { ...view, signing_secret: minted } : { ...view, note: WEBHOOK_SECRET_WORDS };
|
|
46
52
|
}
|
|
53
|
+
/** POST /settings/webhook/secret's answer (the owner's session alone reaches it): the webhook as a read answers it, its
|
|
54
|
+
* `secret` metadata the new secret's, and the new value as `signing_secret`, this once. */
|
|
55
|
+
export const webhookRotated = (view, minted) => ({ ...view, signing_secret: minted });
|
|
47
56
|
/** The field an adapter mints for each of its triggers (a webhook's `secret`), if it mints one. */
|
|
48
57
|
const mintedField = (adapter) => adapter?.settings?.scope === "trigger" ? Object.entries(adapter.settings.fields).find(([, field]) => field.mint)?.[0] : undefined;
|
|
49
58
|
/** What a trigger's view says of a secret its sealed settings keep but that does not open here (sealed under another seal
|
|
@@ -22,17 +22,26 @@ export interface TriggerTargetDeps {
|
|
|
22
22
|
/** A run's v2 status, or null for an unknown run (the run view): the trigger engine's overlap and active-run checks. */
|
|
23
23
|
runStatus(runId: string): Promise<string | null>;
|
|
24
24
|
/** A completed run's result.output as GET /runs/{id} serves it (cut of the secrets it holds; null when it has none), and
|
|
25
|
-
* when it ended; undefined for a run that is unknown or did not complete (the run view).
|
|
25
|
+
* when it ended; undefined for a run that is unknown or did not complete (the run view). `carried`: the top-level
|
|
26
|
+
* fields the output schema it was checked against (its pinned revision's, never the agent's current one) names in
|
|
27
|
+
* `x-carried` (answer-json.ts carriedFields), absent when it names none. */
|
|
26
28
|
completedOutput(runId: string): Promise<{
|
|
27
29
|
output: unknown;
|
|
28
30
|
endedAt: string | null;
|
|
31
|
+
carried?: readonly string[];
|
|
29
32
|
} | undefined>;
|
|
30
33
|
}
|
|
31
34
|
/** The most bytes of a previous run's result a triggered run is handed, as JSON: past it, it is handed none, said so. */
|
|
32
35
|
export declare const PREVIOUS_RESULT_MAX_BYTES: number;
|
|
33
36
|
/** The words a triggered agentic run's message carries its trigger's previous result in (previousResultOf). */
|
|
34
37
|
export declare const previousResultWords: (runId: string, endedAt: string | null, json: string) => string;
|
|
35
|
-
/**
|
|
38
|
+
/** The words a triggered agentic run's message carries its trigger's previous result in when the whole of it is over
|
|
39
|
+
* PREVIOUS_RESULT_MAX_BYTES (`bytes`) but the fields its output schema names in x-carried fit: only those, by name, and
|
|
40
|
+
* per carried array the oldest entries dropped to make them fit (`dropped`, in x-carried order; none when they fit as
|
|
41
|
+
* they are). */
|
|
42
|
+
export declare const previousCarriedWords: (runId: string, endedAt: string | null, fields: readonly string[], bytes: number, json: string, dropped?: readonly (readonly [string, number])[]) => string;
|
|
43
|
+
/** What a triggered run is told when its trigger's previous result is over PREVIOUS_RESULT_MAX_BYTES (and no carried
|
|
44
|
+
* fields of it fit, its carried arrays' entries dropped). */
|
|
36
45
|
export declare const previousResultTooLarge: (runId: string) => string;
|
|
37
46
|
/** The trigger-facing run policy: the subset of the trigger engine's deps this module owns. The engine's other deps (an
|
|
38
47
|
* adapter's sealed settings, the failed-firing webhook) stay server-wired. */
|
|
@@ -40,7 +49,7 @@ export type TriggerTargets = {
|
|
|
40
49
|
targetIssues(target: Target): Promise<InputIssue[]>;
|
|
41
50
|
start(target: Extract<Target, {
|
|
42
51
|
kind: "start_run";
|
|
43
|
-
}>, input: Json, origin: RunTrigger, from: MessageOrigin, title
|
|
52
|
+
}>, input: Json, origin: RunTrigger, from: MessageOrigin, title: string | undefined, previous: boolean): Promise<{
|
|
44
53
|
run_id: string;
|
|
45
54
|
}>;
|
|
46
55
|
message(target: Extract<Target, {
|