@parcha/agentrun-serve 0.1.0-beta.56 → 0.1.0-beta.58
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 +281 -0
- package/README.md +246 -66
- package/dist/acp-package.d.ts +2 -0
- package/dist/adapters.d.ts +15 -3
- package/dist/adapters.js +17 -6
- package/dist/agent-package.d.ts +3 -3
- package/dist/agent-package.js +17 -8
- package/dist/api-keys.d.ts +76 -0
- package/dist/api-keys.js +217 -0
- package/dist/api-only.d.ts +15 -5
- package/dist/api-only.js +32 -8
- package/dist/box-paths.d.ts +4 -3
- package/dist/box-paths.js +7 -4
- package/dist/browser-hold.d.ts +23 -0
- package/dist/browser-hold.js +48 -0
- package/dist/browser-person.d.ts +3 -0
- package/dist/browser-person.js +4 -1
- package/dist/chatgpt-plan.d.ts +18 -8
- package/dist/chatgpt-plan.js +91 -34
- package/dist/claude-login-token.d.ts +117 -0
- package/dist/claude-login-token.js +737 -0
- package/dist/claude-login.d.ts +120 -22
- package/dist/claude-login.js +347 -63
- package/dist/claude-sign-in.d.ts +17 -6
- package/dist/claude-sign-in.js +42 -39
- package/dist/cli.js +33 -10
- package/dist/composio-made.d.ts +4 -0
- package/dist/composio-made.js +4 -0
- package/dist/composio-preset.d.ts +43 -2
- package/dist/composio-preset.js +92 -4
- package/dist/computer-attach.d.ts +35 -17
- package/dist/computer-attach.js +301 -49
- package/dist/computer-held-routes.d.ts +5 -4
- package/dist/computer-held-routes.js +29 -8
- package/dist/computer-held.d.ts +6 -1
- package/dist/computer-held.js +14 -0
- package/dist/computer-record.js +4 -2
- package/dist/computer-viewer.js +4 -1
- package/dist/computers.d.ts +10 -10
- package/dist/computers.js +5 -5
- package/dist/console/assets/{backend-Boh7tC4i.js → backend-CSAWUqtZ.js} +19 -19
- package/dist/console/assets/index-Bwn1oTem.css +1 -0
- package/dist/console/assets/index-DPh29cyz.js +747 -0
- package/dist/console/index.html +2 -2
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +1 -1
- package/dist/dial-relay.d.ts +25 -4
- package/dist/dial-relay.js +129 -1
- package/dist/docker-host-addresses.d.ts +22 -11
- package/dist/docker-host-addresses.js +38 -26
- package/dist/env-switch.d.ts +8 -0
- package/dist/env-switch.js +31 -2
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fal-price.d.ts +56 -20
- package/dist/fal-price.js +400 -90
- package/dist/handed-values.d.ts +43 -1
- package/dist/handed-values.js +119 -2
- package/dist/harness-archive.d.ts +13 -10
- package/dist/harness-archive.js +60 -34
- package/dist/harness-check.d.ts +3 -1
- package/dist/harness-check.js +25 -46
- package/dist/harness-keys.d.ts +73 -27
- package/dist/harness-keys.js +194 -61
- package/dist/harness-recipe-entry.d.ts +8 -7
- package/dist/harness-recipe-entry.js +21 -32
- package/dist/harness-recipe.d.ts +38 -25
- package/dist/harness-recipe.js +49 -36
- package/dist/harness-sign-in.js +12 -23
- package/dist/harness-table.d.ts +10 -3
- package/dist/harness-table.js +26 -21
- package/dist/harness.d.ts +1 -0
- package/dist/harness.js +17 -5
- package/dist/hosted-search.d.ts +1 -1
- package/dist/hosted-search.js +1 -2
- package/dist/import-worker.d.ts +4 -2
- package/dist/import-worker.js +9 -2
- package/dist/in-flight.d.ts +26 -0
- package/dist/in-flight.js +52 -0
- package/dist/key-refusal.d.ts +9 -4
- package/dist/key-refusal.js +107 -25
- package/dist/learn/ledger.d.ts +170 -0
- package/dist/learn/ledger.js +218 -0
- package/dist/learn/promote.d.ts +3 -3
- package/dist/learn/promote.js +1 -1
- package/dist/learn/secrets.d.ts +13 -3
- package/dist/learn/secrets.js +118 -17
- package/dist/learning-cost.d.ts +28 -23
- package/dist/learning-cost.js +19 -23
- package/dist/link-check.js +1 -1
- package/dist/live-reach.d.ts +2 -0
- package/dist/live-reach.js +2 -0
- package/dist/llms.txt +1 -1
- package/dist/marketplace.d.ts +77 -0
- package/dist/marketplace.js +224 -0
- package/dist/mcp-api-only-origins.d.ts +35 -0
- package/dist/mcp-api-only-origins.js +57 -0
- package/dist/mcp-gateway.d.ts +7 -5
- package/dist/mcp-gateway.js +9 -12
- package/dist/mcp-secret-writes.js +5 -3
- package/dist/mcp-servers-store.d.ts +28 -6
- package/dist/mcp-servers-store.js +53 -4
- package/dist/media-duration.d.ts +3 -0
- package/dist/media-duration.js +90 -9
- package/dist/micro.d.ts +2 -0
- package/dist/micro.js +2 -0
- package/dist/model-form.d.ts +5 -4
- package/dist/model-form.js +11 -7
- package/dist/model.d.ts +10 -6
- package/dist/model.js +16 -11
- package/dist/monid.d.ts +14 -1
- package/dist/monid.js +103 -26
- package/dist/ollama-provider.d.ts +7 -1
- package/dist/ollama-provider.js +14 -2
- package/dist/openapi.js +210 -37
- package/dist/otel/genai.d.ts +65 -0
- package/dist/otel/genai.js +116 -0
- package/dist/otel/tracer.d.ts +55 -0
- package/dist/otel/tracer.js +308 -0
- package/dist/page.d.ts +2 -0
- package/dist/page.js +3 -1
- package/dist/paid-calls.d.ts +1 -32
- package/dist/paid-calls.js +4 -39
- package/dist/place-offers.d.ts +4 -0
- package/dist/place-offers.js +7 -4
- package/dist/provider.d.ts +11 -2
- package/dist/provider.js +59 -8
- package/dist/redact/match.d.ts +30 -3
- package/dist/redact/match.js +422 -41
- package/dist/refusal-words.d.ts +11 -0
- package/dist/refusal-words.js +11 -0
- package/dist/run-census.d.ts +67 -0
- package/dist/run-census.js +240 -0
- package/dist/run-computer.d.ts +6 -3
- package/dist/run-computer.js +4 -1
- package/dist/run-cut.d.ts +15 -6
- package/dist/run-cut.js +30 -9
- package/dist/run-files.d.ts +3 -0
- package/dist/run-files.js +3 -0
- package/dist/run-launch.d.ts +12 -1
- package/dist/run-launch.js +9 -10
- package/dist/run-learning-served.d.ts +4 -2
- package/dist/run-model-key.d.ts +8 -0
- package/dist/run-model-key.js +31 -1
- package/dist/run-reads-over-store.d.ts +24 -6
- package/dist/run-reads-over-store.js +67 -23
- package/dist/run-recordings.d.ts +5 -1
- package/dist/run-recordings.js +39 -14
- package/dist/run-timeline-served.d.ts +2 -0
- package/dist/run-timeline-served.js +2 -2
- package/dist/run-usage.d.ts +1 -0
- package/dist/run-view.d.ts +1 -2
- package/dist/run-view.js +2 -1
- package/dist/runnable.d.ts +10 -1
- package/dist/runnable.js +20 -8
- package/dist/runner/adapter-loop.d.ts +11 -0
- package/dist/runner/adapter-loop.js +58 -26
- package/dist/runner/adapter-run-spec.d.ts +55 -11
- package/dist/runner/adapter-run-spec.js +183 -52
- package/dist/runner/adapters/pi.js +25 -3
- package/dist/runner/beside.d.ts +9 -2
- package/dist/runner/beside.js +27 -9
- package/dist/runner/big-writes.js +1 -10
- package/dist/runner/claim-secrets.d.ts +27 -10
- package/dist/runner/claim-secrets.js +49 -22
- package/dist/runner/cli-run-spec.d.ts +6 -0
- package/dist/runner/cli-run-spec.js +97 -38
- package/dist/runner/computer-journal.d.ts +9 -1
- package/dist/runner/computer-journal.js +26 -0
- package/dist/runner/conformance/harness.js +1 -1
- package/dist/runner/feedback-round.js +3 -0
- package/dist/runner/harness-loops.d.ts +6 -5
- package/dist/runner/harness-loops.js +7 -7
- package/dist/runner/held.d.ts +24 -6
- package/dist/runner/journal-kinds.d.ts +5 -0
- package/dist/runner/journal-kinds.js +5 -0
- package/dist/runner/main.d.ts +11 -6
- package/dist/runner/main.js +19 -9
- package/dist/runner/mcp-claim.js +31 -3
- package/dist/runner/mcp-run.d.ts +9 -0
- package/dist/runner/mcp-run.js +11 -5
- package/dist/runner/model-route.d.ts +17 -0
- package/dist/runner/model-route.js +120 -2
- package/dist/runner/presence.d.ts +11 -1
- package/dist/runner/presence.js +7 -0
- package/dist/runner/reflect-hook.js +1 -1
- package/dist/runner/run-child-host.d.ts +22 -8
- package/dist/runner/run-child-host.js +128 -41
- package/dist/runner/run-child.js +5 -2
- package/dist/runner/runner.d.ts +17 -3
- package/dist/runner/runner.js +130 -34
- package/dist/runner/save-slots.js +2 -1
- package/dist/runner/store-port.d.ts +1 -1
- package/dist/runner/store-secrets.d.ts +6 -0
- package/dist/runner/store-secrets.js +49 -7
- package/dist/runner/subagent.d.ts +11 -0
- package/dist/runner/subagent.js +16 -38
- package/dist/runner/workflow-first.d.ts +35 -15
- package/dist/runner/workflow-first.js +38 -25
- package/dist/runner/workflow-spec.js +4 -3
- package/dist/runs-over-store.d.ts +15 -6
- package/dist/runs-over-store.js +33 -21
- package/dist/scrub-command.d.ts +73 -0
- package/dist/scrub-command.js +307 -0
- package/dist/secret-cut.d.ts +73 -0
- package/dist/secret-cut.js +291 -4
- package/dist/secret-rules.d.ts +143 -0
- package/dist/secret-rules.js +2564 -0
- package/dist/secrets.d.ts +7 -0
- package/dist/secrets.js +20 -0
- package/dist/server-keys.d.ts +20 -0
- package/dist/server-keys.js +25 -6
- package/dist/server.d.ts +65 -13
- package/dist/server.js +470 -157
- package/dist/skills/agentrun-serve/SKILL.md +4 -0
- package/dist/slots.d.ts +9 -0
- package/dist/slots.js +45 -0
- package/dist/store/index.d.ts +1 -1
- package/dist/store/index.js +1 -1
- package/dist/store/journal/storage.js +1 -1
- package/dist/store/postgres/migrations/0027_run_launch_census.sql +31 -0
- package/dist/store/postgres/migrations/0028_learning_ledger.sql +44 -0
- package/dist/store/schema.d.ts +23 -0
- package/dist/store/schema.js +58 -2
- package/dist/store/seal.d.ts +6 -1
- package/dist/store/seal.js +5 -3
- package/dist/store/sqlite/run-launch.d.ts +9 -1
- package/dist/store/sqlite/run-launch.js +24 -13
- package/dist/store/sqlite/run-patch.d.ts +12 -2
- package/dist/store/sqlite/run-patch.js +42 -5
- package/dist/store/sqlite/store.js +105 -12
- package/dist/store/store.d.ts +57 -2
- package/dist/store/store.js +20 -0
- package/dist/store-reads/learning.d.ts +84 -124
- package/dist/store-reads/learning.js +210 -274
- package/dist/store-view.d.ts +3 -0
- package/dist/store-view.js +3 -3
- package/dist/suggestions.js +3 -2
- package/dist/template-eval.d.ts +39 -9
- package/dist/template-eval.js +191 -60
- package/dist/template-import.js +6 -2
- package/dist/templates.d.ts +10 -2
- package/dist/templates.js +28 -8
- package/dist/timeline/labels.d.ts +6 -4
- package/dist/timeline/labels.js +18 -6
- package/dist/timeline/timeline.d.ts +5 -0
- package/dist/timeline/timeline.js +14 -8
- package/dist/timeline/util.js +1 -1
- package/dist/timeline/web-calls.d.ts +22 -7
- package/dist/timeline/web-calls.js +106 -35
- package/dist/tool-gate.d.ts +42 -3
- package/dist/tool-gate.js +66 -5
- package/dist/tool-keys-store.d.ts +2 -4
- package/dist/tool-keys-store.js +5 -21
- package/dist/tool-keys.d.ts +2 -2
- package/dist/tool-keys.js +2 -2
- package/dist/tool-list.js +1 -1
- package/dist/tool-plane.d.ts +2 -2
- package/dist/tool-plane.js +35 -33
- package/dist/tools.js +13 -7
- package/dist/trigger-targets.d.ts +4 -0
- package/dist/trigger-targets.js +9 -2
- package/dist/triggers.d.ts +67 -4
- package/dist/triggers.js +171 -22
- package/dist/until.d.ts +3 -0
- package/dist/until.js +11 -0
- package/dist/web-fake.d.ts +1 -3
- package/dist/web-fake.js +7 -18
- package/dist/web-fetch.d.ts +6 -72
- package/dist/web-fetch.js +11 -265
- package/dist/web-run.d.ts +31 -0
- package/dist/web-run.js +90 -0
- package/dist/web-save.d.ts +10 -13
- package/dist/web-save.js +13 -55
- package/dist/web-search.d.ts +9 -127
- package/dist/web-search.js +23 -259
- package/dist/wires.d.ts +13 -0
- package/dist/wires.js +11 -0
- package/dist/workflow-run.d.ts +5 -4
- package/dist/workflow-run.js +5 -4
- package/dist/workspace/attached-computers.d.ts +32 -9
- package/dist/workspace/attached-computers.js +77 -13
- package/dist/workspace/computer-deps.d.ts +8 -2
- package/dist/workspace/computer-deps.js +10 -3
- package/dist/workspace/computer-for-claim.d.ts +12 -1
- package/dist/workspace/computer-for-claim.js +83 -11
- package/dist/workspace/computer-kept.d.ts +3 -0
- package/dist/workspace/computer-kept.js +11 -2
- package/dist/workspace/index.d.ts +1 -1
- package/dist/workspace/index.js +1 -1
- package/dist/workspace/kind-skills.d.ts +4 -0
- package/dist/workspace/kind-skills.js +9 -0
- package/dist/workspace/paired-route.d.ts +91 -0
- package/dist/workspace/paired-route.js +153 -0
- package/dist/workspace/synced-folder.js +3 -4
- package/dist/wrapped.d.ts +20 -6
- package/dist/wrapped.js +66 -25
- package/package.json +17 -11
- package/skills/agentrun-serve/SKILL.md +4 -0
- package/templates/README.md +32 -10
- package/dist/console/assets/index-CQ3cJRzI.js +0 -746
- package/dist/console/assets/index-DKkaS3a0.css +0 -1
- package/dist/exa-keyless.d.ts +0 -34
- package/dist/exa-keyless.js +0 -118
- package/dist/firecrawl-keyless.d.ts +0 -41
- package/dist/firecrawl-keyless.js +0 -152
- package/dist/keyless-mcp.d.ts +0 -36
- package/dist/keyless-mcp.js +0 -127
- package/dist/text-urls.d.ts +0 -38
- package/dist/text-urls.js +0 -170
- package/dist/web-fetch-direct.d.ts +0 -119
- package/dist/web-fetch-direct.js +0 -190
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// (runner/mcp-claim.ts), including the OAuth token refresh. So this server-side registry has NO headers()/headersForRun()
|
|
8
8
|
// and does NO token refresh: it is the owner's create/preview/save/refresh(tools)/remove and the OAuth sign-in, and nothing
|
|
9
9
|
// a run's launch calls.
|
|
10
|
+
import { offApiOnlyMcpOrigins } from "./mcp-api-only-origins.js";
|
|
10
11
|
import { ApiError, invalid } from "./errors.js";
|
|
11
12
|
import { authOf, canonical, credentialInQuery, credentialInQueryWords, credentialMissing, savedOrGiven, shownUrl, listServer, marked, MAX_OAUTH_VALUE_BYTES, nameOf, notFound, oauthValueValid, pricesListed, pricesOf, scopesValid, urlOf, } from "./mcp-probe.js";
|
|
12
13
|
import { listMcpServers, openMcpRow, putPendingSignIn, removeMcpServer, removeMcpServerIfCredential, rewriteMcpServer, saveMcpServerIfCredential, takePendingSignIn } from "./mcp-store.js";
|
|
@@ -15,8 +16,8 @@ import { checkPrivateHosts, privateOAuthHosts, savePrivateOAuthHosts } from "./m
|
|
|
15
16
|
import { credentialMark } from "./mcp-secret-writes.js";
|
|
16
17
|
import { secretMeta, secretName } from "./secret-writes.js";
|
|
17
18
|
import { dialAt, issuerOf, LOOPBACK, MAX_PENDING, MCP_SETTINGS_PAGE, mcpServerAt, McpSignIns, reasonOf, SIGN_IN_AGAIN, systemNetwork } from "./mcp-oauth.js";
|
|
18
|
-
import { cleanupOf, COMPOSIO_ORIGIN, composioEnvKey, composioKeyFromEnv, composioMadeKey, composioPerRun, droppedOf, madeToWrite, recordedMade, releasedOf, storedMade } from "./composio-made.js";
|
|
19
|
-
import { COMPOSIO_PER_RUN, COMPOSIO_USER, composioListingAddress, composioServerId } from "./composio-preset.js";
|
|
19
|
+
import { cleanupOf, COMPOSIO_ORIGIN, composioAccountKey, composioEnvKey, composioKeyFromEnv, composioMadeKey, composioPerRun, droppedOf, madeToWrite, recordedMade, releasedOf, storedMade } from "./composio-made.js";
|
|
20
|
+
import { accountLabel, asking, COMPOSIO_ACCOUNT_STATES, COMPOSIO_PER_RUN, COMPOSIO_USER, composioAccount, composioListingAddress, composioServerId } from "./composio-preset.js";
|
|
20
21
|
import { mcpSourceKey, recordedForAnother, savedByToken, sourceOf, sourceToWrite, standInGiven, storedSource, toolkitGiven } from "./mcp-sources.js";
|
|
21
22
|
import { SEAL_KEY_ENV, sealKeyOf } from "./tool-keys.js";
|
|
22
23
|
import { GITHUB_MCP_ONLY, GITHUB_MCP_ORIGIN, githubMcpUrl } from "./github.js";
|
|
@@ -224,6 +225,10 @@ export class McpServersOverStore {
|
|
|
224
225
|
const row = await this.store.mcp.server(name);
|
|
225
226
|
if (!row)
|
|
226
227
|
return undefined;
|
|
228
|
+
// A per_run server the API token saved at an origin no longer on the API-only list: refused before it is listed.
|
|
229
|
+
const off = await offApiOnlyMcpOrigins(this.store, name, row);
|
|
230
|
+
if (off)
|
|
231
|
+
throw new ApiError("agent_not_runnable", off);
|
|
227
232
|
const { toolkit } = await this.sourceOf(row);
|
|
228
233
|
const url = new URL(row.url);
|
|
229
234
|
const pinned = (tools) => {
|
|
@@ -465,8 +470,9 @@ export class McpServersOverStore {
|
|
|
465
470
|
this.nameTurns.delete(name);
|
|
466
471
|
}
|
|
467
472
|
}
|
|
468
|
-
/** POST refresh: list the saved server's tools again, keep them, and say what was added, removed and changed.
|
|
469
|
-
|
|
473
|
+
/** POST refresh: list the saved server's tools again, keep them, and say what was added, removed and changed. A
|
|
474
|
+
* Composio server's account is read again at Composio too (`composio`, where Composio is: checkAccount). */
|
|
475
|
+
async refresh(name, stop, composio) {
|
|
470
476
|
const was = await this.need(name);
|
|
471
477
|
const send = await this.reached(was.auth, new URL(was.url), stop);
|
|
472
478
|
const open = await this.opened(name, was, "name");
|
|
@@ -483,6 +489,8 @@ export class McpServersOverStore {
|
|
|
483
489
|
...(Object.keys(prices).length ? { prices } : {}), updatedAt: row.updatedAt,
|
|
484
490
|
};
|
|
485
491
|
}, "refresh", (fresh) => fresh.url === was.url && fresh.auth === was.auth);
|
|
492
|
+
if (composio)
|
|
493
|
+
await this.checkAccount(saved, composio, stop);
|
|
486
494
|
await this.store.flush();
|
|
487
495
|
return {
|
|
488
496
|
added: [...after.keys()].filter((tool) => !before.has(tool)),
|
|
@@ -491,6 +499,42 @@ export class McpServersOverStore {
|
|
|
491
499
|
server: await this.view(saved),
|
|
492
500
|
};
|
|
493
501
|
}
|
|
502
|
+
/** A Composio preset server's account read at Composio and kept (composioAccountKey) for every read of the server to
|
|
503
|
+
* say: connected or not, and each connected account's label. Only a server whose save recorded its user and auth config
|
|
504
|
+
* (composio-made.ts): one per-run (each run names its own account), of a toolkit with no sign-in (no auth config), or
|
|
505
|
+
* saved before that was recorded has none. A failure keeps `unknown`, and the refresh goes on: its tools are listed. */
|
|
506
|
+
async checkAccount(row, control, stop) {
|
|
507
|
+
if (row.auth !== "headers")
|
|
508
|
+
return;
|
|
509
|
+
const { source, toolkit } = await this.sourceOf(row);
|
|
510
|
+
const made = recordedMade(await this.store.settings.get(composioMadeKey(row.name)), row.createdAt);
|
|
511
|
+
if (source !== "composio" || !toolkit || !made?.auth_config || made.per_run)
|
|
512
|
+
return;
|
|
513
|
+
const of = { user: made.user, toolkit, auth_config: made.auth_config.id };
|
|
514
|
+
let account;
|
|
515
|
+
try {
|
|
516
|
+
const key = Object.entries((await this.opened(row.name, row, "api_key")).headers).find(([header]) => header.toLowerCase() === "x-api-key")?.[1];
|
|
517
|
+
account = key ? await composioAccount(asking(control, key, stop, "its account was not checked"), of) : { state: "unknown" };
|
|
518
|
+
}
|
|
519
|
+
catch {
|
|
520
|
+
account = { state: "unknown" };
|
|
521
|
+
}
|
|
522
|
+
await this.store.settings.put(composioAccountKey(row.name), { of: row.createdAt, ...of, ...account, checked_at: new Date().toISOString() });
|
|
523
|
+
}
|
|
524
|
+
/** The account a refresh last read for `row` (checkAccount), while it was read for what the server stands on now (its
|
|
525
|
+
* user, toolkit and auth config); none otherwise. */
|
|
526
|
+
async accountOf(row, toolkit) {
|
|
527
|
+
const kept = await this.store.settings.get(composioAccountKey(row.name));
|
|
528
|
+
if (!isObject(kept) || kept.of !== row.createdAt || !toolkit || kept.toolkit !== toolkit)
|
|
529
|
+
return undefined;
|
|
530
|
+
const made = recordedMade(await this.store.settings.get(composioMadeKey(row.name)), row.createdAt);
|
|
531
|
+
if (!made?.auth_config || made.per_run || kept.user !== made.user || kept.auth_config !== made.auth_config.id)
|
|
532
|
+
return undefined;
|
|
533
|
+
if (!COMPOSIO_ACCOUNT_STATES.includes(kept.state) || typeof kept.checked_at !== "string")
|
|
534
|
+
return undefined;
|
|
535
|
+
const labels = kept.state === "connected" && Array.isArray(kept.labels) ? kept.labels.map(accountLabel).filter((label) => !!label) : [];
|
|
536
|
+
return { state: kept.state, ...(labels.length ? { labels } : {}), checked_at: kept.checked_at };
|
|
537
|
+
}
|
|
494
538
|
/** Writes the owner's change over the row it read (`was`), its credential left as it is, by a compare-and-set on that
|
|
495
539
|
* credential (store.mcp.rewrite). A lost one (a run kept a refreshed set meanwhile) reads the row again and re-applies the
|
|
496
540
|
* change onto it, while `still` holds of it, at most REWRITE_TRIES writes; then it is refused in words, nothing written. */
|
|
@@ -540,6 +584,8 @@ export class McpServersOverStore {
|
|
|
540
584
|
// never read for another row (mcp-sources.ts), so a server saved again says what it is afresh.
|
|
541
585
|
if (!recordedForAnother(await this.store.settings.get(mcpSourceKey(name)), row.createdAt))
|
|
542
586
|
await this.store.settings.remove(mcpSourceKey(name));
|
|
587
|
+
if (!recordedForAnother(await this.store.settings.get(composioAccountKey(name)), row.createdAt))
|
|
588
|
+
await this.store.settings.remove(composioAccountKey(name));
|
|
543
589
|
// What it made at Composio that another saved server uses stays, that one's now (its record rewritten to own it); the
|
|
544
590
|
// rest the delete route removes there.
|
|
545
591
|
let cleanup;
|
|
@@ -802,6 +848,7 @@ export class McpServersOverStore {
|
|
|
802
848
|
// A refresh moves listed_at, not updated_at, so the two differ after a refresh (updatedAt for a row from before the
|
|
803
849
|
// column).
|
|
804
850
|
const listedAt = new Date(row.listedAt ?? row.updatedAt).toISOString();
|
|
851
|
+
const account = source === "composio" ? await this.accountOf(row, toolkit) : undefined;
|
|
805
852
|
return {
|
|
806
853
|
name,
|
|
807
854
|
// Its origin, the path and query held as a secret (shownUrl): the whole URL is only ever sent to the server itself.
|
|
@@ -826,6 +873,8 @@ export class McpServersOverStore {
|
|
|
826
873
|
listed_at: listedAt,
|
|
827
874
|
updated_at: updatedAt,
|
|
828
875
|
secret: secretOf(row, keyEnv),
|
|
876
|
+
// A Composio server's account as its last refresh read it: connected or not, and each connected one's label.
|
|
877
|
+
...(account ? { composio_account: account } : {}),
|
|
829
878
|
};
|
|
830
879
|
}
|
|
831
880
|
/** A body's URL, auth and prices, and a save's source and toolkit (`priced`: a save's body), or 422. */
|
package/dist/media-duration.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
/** The length of the media file `bytes`, in seconds; undefined when it can't be read from them. */
|
|
2
2
|
export declare function mediaSeconds(bytes: Uint8Array): number | undefined;
|
|
3
|
+
/** The length of the voice `bytes` play, in seconds: an MP3's frames or a PCM WAV's samples (playedMp3Seconds,
|
|
4
|
+
* playedWavSeconds). Undefined for anything else, an ISO file included: its only length is its movie header's. */
|
|
5
|
+
export declare function voiceSeconds(bytes: Uint8Array): number | undefined;
|
package/dist/media-duration.js
CHANGED
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
// A media file's length in seconds, read from its bytes alone: an ISO file's movie header (mp4, m4a, mov), a WAV's data
|
|
2
|
-
// chunk over its byte rate, an MP3's frame count (Xing, Info or VBRI) or, with none, its frames walked one by one. Pure:
|
|
3
|
-
//
|
|
4
|
-
|
|
2
|
+
// chunk over its byte rate, an MP3's frame count (Xing, Info or VBRI) or, with none, its frames walked one by one. Pure:
|
|
3
|
+
// no decoder, nothing read past the bytes given. Undefined for anything else, or a file cut short of the header its
|
|
4
|
+
// length is in. voiceSeconds reads a voice's length from what plays instead, for a file whose sender is billed by it.
|
|
5
|
+
/** Whether the bytes at `at` are `text`'s character codes. No allocation: a walk over a 32 MiB file calls it millions
|
|
6
|
+
* of times. */
|
|
7
|
+
const tag = (b, at, text) => {
|
|
8
|
+
if (at < 0 || b.length < at + text.length)
|
|
9
|
+
return false;
|
|
10
|
+
for (let i = 0; i < text.length; i++)
|
|
11
|
+
if (b[at + i] !== text.charCodeAt(i))
|
|
12
|
+
return false;
|
|
13
|
+
return true;
|
|
14
|
+
};
|
|
5
15
|
const u32 = (b, at) => (b[at] * 0x1000000) + (b[at + 1] << 16) + (b[at + 2] << 8) + b[at + 3];
|
|
6
16
|
const u32le = (b, at) => b[at] + (b[at + 1] << 8) + (b[at + 2] << 16) + b[at + 3] * 0x1000000;
|
|
17
|
+
const u16le = (b, at) => b[at] + (b[at + 1] << 8);
|
|
7
18
|
const length = (seconds) => (Number.isFinite(seconds) && seconds > 0 ? seconds : undefined);
|
|
8
19
|
/** The boxes of an ISO file between `from` and `to`: each one's type and where its body starts and ends. A box that runs
|
|
9
20
|
* past `to`, or is smaller than its own header, ends the walk. */
|
|
@@ -104,14 +115,16 @@ function walkedSeconds(b, at, end) {
|
|
|
104
115
|
}
|
|
105
116
|
return length(seconds);
|
|
106
117
|
}
|
|
118
|
+
/** Where an MP3's frames may start: past an ID3v2 tag, whose size is four 7-bit bytes, with a 10-byte footer when
|
|
119
|
+
* flagged; 0 with none. */
|
|
120
|
+
const id3End = (b) => (tag(b, 0, "ID3") && b.length >= 10 ? 10 + ((b[6] & 0x7f) << 21) + ((b[7] & 0x7f) << 14) + ((b[8] & 0x7f) << 7) + (b[9] & 0x7f) + (b[5] & 0x10 ? 10 : 0) : 0);
|
|
121
|
+
/** Where an MP3's frames end: before an ID3v1 tag (its last 128 bytes, from "TAG"), else at its end. */
|
|
122
|
+
const id3v1Start = (b) => b.length - (tag(b, b.length - 128, "TAG") ? 128 : 0);
|
|
107
123
|
/** An MP3's length: its first frame's Xing, Info or VBRI frame count times a frame's samples over its rate; with none,
|
|
108
124
|
* its frames walked one by one (a variable bitrate needs no header), the first taken only when another follows it. */
|
|
109
125
|
function mp3Seconds(b) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
if (tag(b, 0, "ID3") && b.length >= 10)
|
|
113
|
-
start = 10 + ((b[6] & 0x7f) << 21) + ((b[7] & 0x7f) << 14) + ((b[8] & 0x7f) << 7) + (b[9] & 0x7f) + (b[5] & 0x10 ? 10 : 0);
|
|
114
|
-
const end = b.length - (tag(b, b.length - 128, "TAG") ? 128 : 0);
|
|
126
|
+
const start = id3End(b);
|
|
127
|
+
const end = id3v1Start(b);
|
|
115
128
|
for (let at = start; at < Math.min(end, start + SYNC_SCAN); at++) {
|
|
116
129
|
const frame = frameAt(b, at);
|
|
117
130
|
if (!frame)
|
|
@@ -126,11 +139,79 @@ function mp3Seconds(b) {
|
|
|
126
139
|
}
|
|
127
140
|
return undefined;
|
|
128
141
|
}
|
|
142
|
+
/** Whether `b` is an ISO file (mp4, m4a, mov), by its first box. */
|
|
143
|
+
const isIso = (b) => ["ftyp", "moov", "mdat", "free", "wide"].some((type) => tag(b, 4, type));
|
|
129
144
|
/** The length of the media file `bytes`, in seconds; undefined when it can't be read from them. */
|
|
130
145
|
export function mediaSeconds(bytes) {
|
|
131
|
-
if (
|
|
146
|
+
if (isIso(bytes))
|
|
132
147
|
return isoSeconds(bytes);
|
|
133
148
|
if (tag(bytes, 0, "RIFF") && tag(bytes, 8, "WAVE"))
|
|
134
149
|
return wavSeconds(bytes);
|
|
135
150
|
return mp3Seconds(bytes);
|
|
136
151
|
}
|
|
152
|
+
// A voice's length, for a job billed by it whose sender made the file (a talking head): what a decoder plays, never a
|
|
153
|
+
// length a header states, which the sender could write short.
|
|
154
|
+
/** Whether the frame at `at` holds a Xing, Info or VBRI header, which a decoder reads as the file's header and does not
|
|
155
|
+
* play. */
|
|
156
|
+
const headerFrame = (b, at, frame) => tag(b, at + 4 + frame.side, "Xing") || tag(b, at + 4 + frame.side, "Info") || tag(b, at + 36, "VBRI");
|
|
157
|
+
/** An MP3 voice: every audio frame from its first byte to its last, each its samples over its rate, a last frame cut
|
|
158
|
+
* short counted whole. Only an ID3v2 tag and the zeros after it may come before the frames, and only an ID3v1 tag after;
|
|
159
|
+
* any other byte gives no length. A first frame holding a Xing, Info or VBRI header is skipped, as a decoder skips it,
|
|
160
|
+
* and the frame count it states is not read; a later frame is audio whatever it holds. */
|
|
161
|
+
function playedMp3Seconds(b) {
|
|
162
|
+
let at = id3End(b);
|
|
163
|
+
while (at < b.length && b[at] === 0)
|
|
164
|
+
at += 1;
|
|
165
|
+
const end = id3v1Start(b);
|
|
166
|
+
if (at >= end)
|
|
167
|
+
return undefined;
|
|
168
|
+
let seconds = 0;
|
|
169
|
+
for (let frame = frameAt(b, at), first = true; at < end; frame = frameAt(b, at), first = false) {
|
|
170
|
+
if (!frame)
|
|
171
|
+
return undefined;
|
|
172
|
+
if (!first || !headerFrame(b, at, frame))
|
|
173
|
+
seconds += frame.samples / frame.rate;
|
|
174
|
+
at += frame.bytes;
|
|
175
|
+
}
|
|
176
|
+
return length(seconds);
|
|
177
|
+
}
|
|
178
|
+
/** The WAV formats whose bytes play at the sample rate, by format tag, and the bits a sample each takes: integer PCM and
|
|
179
|
+
* IEEE float. Not the extensible header (0xFFFE): its GUID names the codec, which may be a compressed one. */
|
|
180
|
+
const PCM_BITS = new Map([[1, [8, 16, 24, 32]], [3, [32, 64]]]);
|
|
181
|
+
/** A WAV voice: every byte after its data chunk's header, to the end of the file (a decoder may play past a data size
|
|
182
|
+
* stated short), over its sample rate times its block align, a last frame cut short counted whole. Its one fmt chunk
|
|
183
|
+
* (a decoder plays by the first; a second is refused) must come before the data, name integer PCM or IEEE float
|
|
184
|
+
* (PCM_BITS) at 1 to 384 kHz, and agree with itself: block align is the channels times the bytes a sample, byte rate
|
|
185
|
+
* the sample rate times the block align. Anything else gives no length. */
|
|
186
|
+
function playedWavSeconds(b) {
|
|
187
|
+
let frame;
|
|
188
|
+
for (let at = 12; at + 8 <= b.length;) {
|
|
189
|
+
const size = u32le(b, at + 4);
|
|
190
|
+
if (tag(b, at, "fmt ")) {
|
|
191
|
+
if (frame || size < 16 || at + 24 > b.length)
|
|
192
|
+
return undefined;
|
|
193
|
+
const format = u16le(b, at + 8);
|
|
194
|
+
const channels = u16le(b, at + 10);
|
|
195
|
+
const rate = u32le(b, at + 12);
|
|
196
|
+
const byteRate = u32le(b, at + 16);
|
|
197
|
+
const align = u16le(b, at + 20);
|
|
198
|
+
const bits = u16le(b, at + 22);
|
|
199
|
+
if (!PCM_BITS.get(format)?.includes(bits) || channels < 1 || align !== channels * (bits / 8) || byteRate !== rate * align || rate < 1000 || rate > 384_000)
|
|
200
|
+
return undefined;
|
|
201
|
+
frame = { rate, align };
|
|
202
|
+
}
|
|
203
|
+
else if (tag(b, at, "data"))
|
|
204
|
+
return frame ? length(Math.ceil((b.length - at - 8) / frame.align) / frame.rate) : undefined;
|
|
205
|
+
at += 8 + size + (size % 2);
|
|
206
|
+
}
|
|
207
|
+
return undefined;
|
|
208
|
+
}
|
|
209
|
+
/** The length of the voice `bytes` play, in seconds: an MP3's frames or a PCM WAV's samples (playedMp3Seconds,
|
|
210
|
+
* playedWavSeconds). Undefined for anything else, an ISO file included: its only length is its movie header's. */
|
|
211
|
+
export function voiceSeconds(bytes) {
|
|
212
|
+
if (isIso(bytes))
|
|
213
|
+
return undefined;
|
|
214
|
+
if (tag(bytes, 0, "RIFF") && tag(bytes, 8, "WAVE"))
|
|
215
|
+
return playedWavSeconds(bytes);
|
|
216
|
+
return playedMp3Seconds(bytes);
|
|
217
|
+
}
|
package/dist/micro.d.ts
ADDED
package/dist/micro.js
ADDED
package/dist/model-form.d.ts
CHANGED
|
@@ -20,10 +20,11 @@ export type FreeModel = {
|
|
|
20
20
|
context_window: number;
|
|
21
21
|
};
|
|
22
22
|
/** The free models offered for `harness` on this server, besides pickerCandidates' (harness.ts harnessOffers drops those
|
|
23
|
-
* it does not run)
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
23
|
+
* it does not run): the models of the Ollama here (ollama-provider.ts, `ollama/<tag>`, each at $0 on this machine, in
|
|
24
|
+
* Ollama's order) on pi and on every harness whose wire the route translates them onto (wires.ts routed: Anthropic's
|
|
25
|
+
* Messages), then, on pi, with OpenRouter's key, OpenRouter's chat models whose catalog price is all zeros (pi-ai's own
|
|
26
|
+
* and serve's ADDED_MODELS), by id. None for a harness on any other wire (it runs its own wire's vendor), behind a gateway
|
|
27
|
+
* (its ids are its own) or with the faux model. */
|
|
27
28
|
export declare function freeCandidates(env: NodeJS.ProcessEnv, harness: string): Promise<FreeModel[]>;
|
|
28
29
|
/** The model `given` most likely means, in the form this harness takes, or undefined when none is obvious: the same id
|
|
29
30
|
* with a dot for a dash or the other way, a missing provider, or a name without its `claude-` ("Sonnet 5.5"). */
|
package/dist/model-form.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { factsOf } from "./harness-table.js";
|
|
6
6
|
import { FAUX_ENV, MODEL_KEYS } from "./model.js";
|
|
7
7
|
import { openRouterName } from "./provider.js";
|
|
8
|
-
import { wireOf } from "./wires.js";
|
|
8
|
+
import { routed, wireOf } from "./wires.js";
|
|
9
9
|
import { PLAN_PROVIDER, planOf, signedIn } from "./chatgpt-plan.js";
|
|
10
10
|
import { PLAN_HARNESSES } from "./harness.js";
|
|
11
11
|
// The default a harness billed to its own plan is named by (Cursor's, the one such harness: `cursor/default`). Already in
|
|
@@ -56,16 +56,20 @@ export function pickerCandidates(env, harness) {
|
|
|
56
56
|
return [...plan, ...PICKABLE.filter((p) => vendors.includes(p.vendor)).flatMap((p) => p.ids.map((id) => formOf(env, p.vendor, id)))];
|
|
57
57
|
}
|
|
58
58
|
/** The free models offered for `harness` on this server, besides pickerCandidates' (harness.ts harnessOffers drops those
|
|
59
|
-
* it does not run)
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
59
|
+
* it does not run): the models of the Ollama here (ollama-provider.ts, `ollama/<tag>`, each at $0 on this machine, in
|
|
60
|
+
* Ollama's order) on pi and on every harness whose wire the route translates them onto (wires.ts routed: Anthropic's
|
|
61
|
+
* Messages), then, on pi, with OpenRouter's key, OpenRouter's chat models whose catalog price is all zeros (pi-ai's own
|
|
62
|
+
* and serve's ADDED_MODELS), by id. None for a harness on any other wire (it runs its own wire's vendor), behind a gateway
|
|
63
|
+
* (its ids are its own) or with the faux model. */
|
|
63
64
|
export async function freeCandidates(env, harness) {
|
|
64
|
-
|
|
65
|
+
const facts = factsOf(env, harness);
|
|
66
|
+
if (env[FAUX_ENV] || env.AGENT_MODEL_BASE_URL)
|
|
65
67
|
return [];
|
|
66
68
|
const [{ builtinModels }, { withLocalModels, isFree }, { contextOf, OLLAMA_PROVIDER, ollamaModels }] = await Promise.all([import("@earendil-works/pi-ai/providers/all"), import("./local-models.js"), import("./ollama-provider.js")]);
|
|
69
|
+
if (facts && !routed(facts.wire, { provider: OLLAMA_PROVIDER }))
|
|
70
|
+
return [];
|
|
67
71
|
const local = (await ollamaModels(env)).filter((model) => model.capabilities.includes("completion")).map((model) => ({ id: `${OLLAMA_PROVIDER}/${model.name}`, context_window: contextOf(model, env) }));
|
|
68
|
-
if (!env.OPENROUTER_API_KEY)
|
|
72
|
+
if (facts || !env.OPENROUTER_API_KEY)
|
|
69
73
|
return local;
|
|
70
74
|
return [...local, ...withLocalModels(builtinModels()).getModels("openrouter").filter(isFree)
|
|
71
75
|
.map((model) => ({ id: `openrouter/${model.id}`, context_window: model.contextWindow }))
|
package/dist/model.d.ts
CHANGED
|
@@ -5,6 +5,8 @@ import { type HarnessEntry } from "./harness-table.js";
|
|
|
5
5
|
import type { Revision } from "./agent-rows.js";
|
|
6
6
|
/** The child's environment names the faux module by absolute path. */
|
|
7
7
|
export declare const FAUX_ENV = "AGENTRUN_SERVE_FAUX";
|
|
8
|
+
/** The provider of a --faux start's model (chooseModel), which stands in for the run's and sends no key. */
|
|
9
|
+
export declare const FAUX_PROVIDER = "faux";
|
|
8
10
|
/** The Ollama tags among a run's models (`ollama/<tag>`): what providerModels resolves for it, one /api/show each. */
|
|
9
11
|
export declare const ollamaTagsOf: (refs: Iterable<ModelRef | undefined>) => string[];
|
|
10
12
|
/** Whether the Ollama here is asked for its models under `env`: not under the faux model or a model gateway, which take
|
|
@@ -89,8 +91,9 @@ export declare const harnessRuns: (env: NodeJS.ProcessEnv, id: string, harness:
|
|
|
89
91
|
/** The model a revision that names none runs on with `harness`, for `tier`: the tier's own variable, else AGENT_MODEL,
|
|
90
92
|
* each only when `harness` runs it (harnessRuns; one it can't is skipped, never an error), else that of the first of
|
|
91
93
|
* MODEL_KEYS whose key is here (a placeholder behind a base URL counts) and that `harness` runs on, else, in a run's
|
|
92
|
-
* process that holds none of those keys, the one the server's keys gave it (DEFAULT_MODEL_ENV), else,
|
|
93
|
-
*
|
|
94
|
+
* process that holds none of those keys, the one the server's keys gave it (DEFAULT_MODEL_ENV), else, where `harness`
|
|
95
|
+
* runs it (pi, a harness on a wire the route translates it onto), the first model of the Ollama here that calls tools
|
|
96
|
+
* (localDefault). Undefined when none is: the harness has no default here. */
|
|
94
97
|
export declare function hostModel(env: NodeJS.ProcessEnv, tier?: Tier, harness?: string): string | undefined;
|
|
95
98
|
/** `route_prefix`: the routing prefix this server puts before a gateway's model ids (MODEL_PROVIDER), which a reader takes off
|
|
96
99
|
* to show the gateway's own id; null with any other source. */
|
|
@@ -159,10 +162,11 @@ export declare const PROVIDER_KEYS: Readonly<Record<string, readonly string[]>>;
|
|
|
159
162
|
/** The gateway's key (AGENT_MODEL_BASE_URL's), which its every model is reached on. */
|
|
160
163
|
export declare const GATEWAY_KEY_ENV = "AGENT_MODEL_API_KEY";
|
|
161
164
|
/** The model keys a pi run takes, by the models chooseModel picks for it: the keys of each one's provider (PROVIDER_KEYS),
|
|
162
|
-
* the default tier's from `ref` (an agentic revision's own) else the host's default, each other tier's
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
|
|
165
|
+
* the default tier's from `ref` (an agentic revision's own) else the host's default, each other tier's from `tierRefs`
|
|
166
|
+
* (a revision's model_tiers, as runModels takes them) else the host's model of that tier; through a gateway
|
|
167
|
+
* (`AGENT_MODEL_BASE_URL`), where every model is the gateway's, its key alone. Asked as chooseModel is, faux or not, so a
|
|
168
|
+
* run on the faux model is handed what a run on its model would be. */
|
|
169
|
+
export declare function modelKeys(env: NodeJS.ProcessEnv, ref: string | undefined, tiers?: readonly Tier[], tierRefs?: Readonly<Partial<Record<Tier, string>>>): string[];
|
|
166
170
|
/** `value` as a thinking level (THINKING_LEVELS, exactly), else undefined: a revision's `thinking` or the host's
|
|
167
171
|
* `AGENT_THINKING` that names none is no level. A run's effort is its own, else these (runs-over-store.ts prepareLaunch). */
|
|
168
172
|
export declare function thinkingLevel(value: unknown): ThinkingLevel | undefined;
|
package/dist/model.js
CHANGED
|
@@ -20,6 +20,8 @@ import { LOGIN_DEFAULT_MODEL, onClaudeLogin } from "./claude-login.js";
|
|
|
20
20
|
import { OLLAMA_PROVIDER, ollamaBase, ollamaHostRefused, ollamaModels, ollamaProvider, ollamaRelisted, ollamaShown, ollamaToolsModel } from "./ollama-provider.js";
|
|
21
21
|
/** The child's environment names the faux module by absolute path. */
|
|
22
22
|
export const FAUX_ENV = "AGENTRUN_SERVE_FAUX";
|
|
23
|
+
/** The provider of a --faux start's model (chooseModel), which stands in for the run's and sends no key. */
|
|
24
|
+
export const FAUX_PROVIDER = "faux";
|
|
23
25
|
/** The Ollama tags among a run's models (`ollama/<tag>`): what providerModels resolves for it, one /api/show each. */
|
|
24
26
|
export const ollamaTagsOf = (refs) => [...new Set([...refs].flatMap((ref) => (ref?.provider === OLLAMA_PROVIDER ? [ref.modelId] : [])))];
|
|
25
27
|
/** Whether the Ollama here is asked for its models under `env`: not under the faux model or a model gateway, which take
|
|
@@ -137,8 +139,9 @@ export const harnessRuns = (env, id, harness) => harnessOf(env, harness)?.runs(e
|
|
|
137
139
|
/** The model a revision that names none runs on with `harness`, for `tier`: the tier's own variable, else AGENT_MODEL,
|
|
138
140
|
* each only when `harness` runs it (harnessRuns; one it can't is skipped, never an error), else that of the first of
|
|
139
141
|
* MODEL_KEYS whose key is here (a placeholder behind a base URL counts) and that `harness` runs on, else, in a run's
|
|
140
|
-
* process that holds none of those keys, the one the server's keys gave it (DEFAULT_MODEL_ENV), else,
|
|
141
|
-
*
|
|
142
|
+
* process that holds none of those keys, the one the server's keys gave it (DEFAULT_MODEL_ENV), else, where `harness`
|
|
143
|
+
* runs it (pi, a harness on a wire the route translates it onto), the first model of the Ollama here that calls tools
|
|
144
|
+
* (localDefault). Undefined when none is: the harness has no default here. */
|
|
142
145
|
export function hostModel(env, tier = "default", harness = DEFAULT_HARNESS) {
|
|
143
146
|
return settingsModel(env, tier, harness) ?? localDefault(env, harness);
|
|
144
147
|
}
|
|
@@ -159,8 +162,9 @@ function settingsModel(env, tier, harness) {
|
|
|
159
162
|
}
|
|
160
163
|
/** The default with no key held: the first model of the Ollama here that calls tools (ollama-provider.ts
|
|
161
164
|
* ollamaToolsModel, from its last listing, which chooseModel asks for first), where `harness` runs it (harnessRuns, its
|
|
162
|
-
* entry's
|
|
163
|
-
* model that takes no tools is never a default: a run on it
|
|
165
|
+
* entry's: pi any model, an adapter its wire's vendor's and the models the route translates onto its wire); none behind a gateway or under the faux model. A
|
|
166
|
+
* model that takes no tools is never a default: a run on it gets its tools as text, and text tools are unreliable on
|
|
167
|
+
* small models. */
|
|
164
168
|
function localDefault(env, harness) {
|
|
165
169
|
if (!asksOllama(env))
|
|
166
170
|
return undefined;
|
|
@@ -184,7 +188,7 @@ export const MODEL_SOURCES = ["faux", "gateway", "providers", "chatgpt"];
|
|
|
184
188
|
export function modelSource(env) {
|
|
185
189
|
const each = (name) => Object.fromEntries(TIERS.map((tier) => [tier, name(tier)]));
|
|
186
190
|
if (env[FAUX_ENV])
|
|
187
|
-
return { source: "faux", route_prefix: null, ...each((tier) =>
|
|
191
|
+
return { source: "faux", route_prefix: null, ...each((tier) => `${FAUX_PROVIDER}/${fauxModel(env, tier)}`) };
|
|
188
192
|
if (env.AGENT_MODEL_BASE_URL)
|
|
189
193
|
return { source: "gateway", route_prefix: MODEL_PROVIDER, ...each((tier) => (hostModel(env, tier) ? `${MODEL_PROVIDER}/${hostModel(env, tier)}` : null)) };
|
|
190
194
|
if (signedIn(env) && !Object.values(PROVIDER_KEYS).flat().some((name) => env[name]))
|
|
@@ -242,7 +246,7 @@ async function choose(env, ref, tier, harness, relisted) {
|
|
|
242
246
|
if (typeof ref === "object")
|
|
243
247
|
return pinnedChoice(env, ref, tier, harness);
|
|
244
248
|
if (env[FAUX_ENV])
|
|
245
|
-
return { model: { provider:
|
|
249
|
+
return { model: { provider: FAUX_PROVIDER, modelId: fauxModel(env, tier) } };
|
|
246
250
|
// A host whose own settings name no model reads its default from the Ollama here (hostModel's localDefault): its
|
|
247
251
|
// listing first (ollamaModels: kept while fresh, asked now where none is, and a stale one asked again behind this
|
|
248
252
|
// choice), so a tag it took is never the last listing's for good. A ref, a key, a default or a plan never waits on it.
|
|
@@ -393,13 +397,14 @@ const REQUEST_KEYS = PROVIDER_KEYS["amazon-bedrock"];
|
|
|
393
397
|
/** The gateway's key (AGENT_MODEL_BASE_URL's), which its every model is reached on. */
|
|
394
398
|
export const GATEWAY_KEY_ENV = "AGENT_MODEL_API_KEY";
|
|
395
399
|
/** The model keys a pi run takes, by the models chooseModel picks for it: the keys of each one's provider (PROVIDER_KEYS),
|
|
396
|
-
* the default tier's from `ref` (an agentic revision's own) else the host's default, each other tier's
|
|
397
|
-
*
|
|
398
|
-
*
|
|
399
|
-
|
|
400
|
+
* the default tier's from `ref` (an agentic revision's own) else the host's default, each other tier's from `tierRefs`
|
|
401
|
+
* (a revision's model_tiers, as runModels takes them) else the host's model of that tier; through a gateway
|
|
402
|
+
* (`AGENT_MODEL_BASE_URL`), where every model is the gateway's, its key alone. Asked as chooseModel is, faux or not, so a
|
|
403
|
+
* run on the faux model is handed what a run on its model would be. */
|
|
404
|
+
export function modelKeys(env, ref, tiers = ["default"], tierRefs = {}) {
|
|
400
405
|
if (env.AGENT_MODEL_BASE_URL)
|
|
401
406
|
return [GATEWAY_KEY_ENV];
|
|
402
|
-
const named = tiers.map((tier) => (tier === "default" ? ref :
|
|
407
|
+
const named = tiers.map((tier) => (tier === "default" ? ref : tierRefs[tier]) ?? hostModel(env, tier));
|
|
403
408
|
const providers = named.flatMap((name) => (name && name.indexOf("/") > 0 ? [name.slice(0, name.indexOf("/"))] : []));
|
|
404
409
|
return [...new Set(providers.flatMap((provider) => PROVIDER_KEYS[provider] ?? []))];
|
|
405
410
|
}
|
package/dist/monid.d.ts
CHANGED
|
@@ -25,6 +25,8 @@ export type MonidOptions = {
|
|
|
25
25
|
/** The most a run is waited for, its first request and every read together (150 s: monid's runs take 1 to 120 s). */
|
|
26
26
|
waitMs?: number;
|
|
27
27
|
sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
|
|
28
|
+
/** When a save's reads (the listing, an inspect) stop being sent (epoch ms); READ_BUDGET_MS after the first, unset. */
|
|
29
|
+
readsEnd?: number;
|
|
28
30
|
};
|
|
29
31
|
/** What a run's answer says monid charged, in USD: its cost; else undefined when monid charged nothing (UNCHARGED), and
|
|
30
32
|
* null for every other answer, which may have been charged (one with no cost, FAILED, TIMED_OUT, a run stopped by its
|
|
@@ -77,16 +79,27 @@ type MonidPinOutcome = {
|
|
|
77
79
|
message: string;
|
|
78
80
|
}[];
|
|
79
81
|
};
|
|
82
|
+
/** One server's reads of monid's listing and inspects, shared by its saves (monidReads). */
|
|
83
|
+
export type MonidReads = Map<string, {
|
|
84
|
+
answer: Promise<unknown>;
|
|
85
|
+
at?: number;
|
|
86
|
+
}>;
|
|
87
|
+
/** The reads one server's saves share, by key and what is read: a read out now is joined, not sent again, and one that
|
|
88
|
+
* answered is reused for SHARED_READ_MS. One that failed is dropped once it ends: the next save reads anew. */
|
|
89
|
+
export declare const monidReads: () => MonidReads;
|
|
80
90
|
/** The monid grants among `grants` pinned against monid's listing on `key` (pinned at a save, never at a run): each
|
|
81
91
|
* provider's wildcard read as the endpoints monid lists for it now (at most MONID_WILDCARD_MAX), each endpoint inspected
|
|
82
92
|
* for its description, input and price; a grant `previous` made too carries its pin, unread (as server.ts mcpListingOf).
|
|
83
93
|
* A grant monid lists nothing for is refused, as is every grant to read with no key or monid unreadable. An endpoint
|
|
84
|
-
* with no fixed price (fixedUsd) is pinned with none, and warned of (usageWords). Undefined when no grant is monid's.
|
|
94
|
+
* with no fixed price (fixedUsd) is pinned with none, and warned of (usageWords). Undefined when no grant is monid's.
|
|
95
|
+
* With `shared` (monidReads), the listing and each inspect are read once for the saves that ask at once. */
|
|
85
96
|
export declare function pinMonid(grants: readonly string[], options: {
|
|
86
97
|
key: string | undefined;
|
|
87
98
|
fetch?: typeof fetch;
|
|
88
99
|
signal?: AbortSignal;
|
|
89
100
|
sleep?: MonidOptions["sleep"];
|
|
101
|
+
shared?: MonidReads;
|
|
102
|
+
budgetMs?: number;
|
|
90
103
|
previous?: {
|
|
91
104
|
grants: readonly string[];
|
|
92
105
|
pin: MonidPinBody | null;
|