run402 4.154.1 → 4.155.1
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/lib/buzz-notifications.mjs +5 -3
- package/lib/buzz.mjs +1 -1
- package/lib/buzz.test.mjs +6 -1
- package/lib/deploy-v2.mjs +26 -5
- package/lib/harness-context.mjs +2 -3
- package/lib/orgs.mjs +1 -1
- package/lib/remote-helper-session.mjs +18 -3
- package/lib/repos.mjs +1 -1
- package/lib/vault-daemon.mjs +10 -4
- package/package.json +2 -1
- package/sdk/dist/function-tools.d.ts +119 -0
- package/sdk/dist/function-tools.d.ts.map +1 -0
- package/sdk/dist/function-tools.js +280 -0
- package/sdk/dist/function-tools.js.map +1 -0
- package/sdk/dist/index.d.ts +3 -1
- package/sdk/dist/index.d.ts.map +1 -1
- package/sdk/dist/index.js +2 -1
- package/sdk/dist/index.js.map +1 -1
- package/sdk/dist/namespaces/auth.d.ts +16 -1
- package/sdk/dist/namespaces/auth.d.ts.map +1 -1
- package/sdk/dist/namespaces/auth.js.map +1 -1
- package/sdk/dist/namespaces/buzz.d.ts +4 -2
- package/sdk/dist/namespaces/buzz.d.ts.map +1 -1
- package/sdk/dist/namespaces/buzz.js +4 -2
- package/sdk/dist/namespaces/buzz.js.map +1 -1
- package/sdk/dist/namespaces/deploy.d.ts.map +1 -1
- package/sdk/dist/namespaces/deploy.js +127 -5
- package/sdk/dist/namespaces/deploy.js.map +1 -1
- package/sdk/dist/namespaces/deploy.types.d.ts +80 -22
- package/sdk/dist/namespaces/deploy.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/deploy.types.js +2 -0
- package/sdk/dist/namespaces/deploy.types.js.map +1 -1
- package/sdk/dist/namespaces/functions.d.ts.map +1 -1
- package/sdk/dist/namespaces/functions.js +4 -0
- package/sdk/dist/namespaces/functions.js.map +1 -1
- package/sdk/dist/namespaces/functions.types.d.ts +8 -1
- package/sdk/dist/namespaces/functions.types.d.ts.map +1 -1
- package/sdk/dist/namespaces/org.d.ts +1 -1
- package/sdk/dist/namespaces/org.js +1 -1
- package/sdk/dist/namespaces/org.types.d.ts +1 -1
- package/sdk/dist/namespaces/repos.d.ts +12 -12
- package/sdk/dist/namespaces/repos.d.ts.map +1 -1
- package/sdk/dist/namespaces/repos.js +9 -9
- package/sdk/dist/namespaces/repos.js.map +1 -1
- package/sdk/dist/namespaces/vault.crypto.js +2 -2
- package/sdk/dist/namespaces/vault.crypto.js.map +1 -1
- package/sdk/dist/node/deploy-manifest.d.ts.map +1 -1
- package/sdk/dist/node/deploy-manifest.js +9 -0
- package/sdk/dist/node/deploy-manifest.js.map +1 -1
- package/sdk/dist/node/index.d.ts +4 -2
- package/sdk/dist/node/index.d.ts.map +1 -1
- package/sdk/dist/node/index.js +13 -2
- package/sdk/dist/node/index.js.map +1 -1
- package/sdk/dist/node/tool-declarations.d.ts +88 -0
- package/sdk/dist/node/tool-declarations.d.ts.map +1 -0
- package/sdk/dist/node/tool-declarations.js +587 -0
- package/sdk/dist/node/tool-declarations.js.map +1 -0
- package/sdk/dist/node/vault-address.d.ts +2 -2
- package/sdk/dist/node/vault-address.js +2 -2
- package/sdk/dist/node/vault-address.js.map +1 -1
- package/sdk/dist/node/vault-keystore.d.ts +6 -6
- package/sdk/dist/node/vault-keystore.d.ts.map +1 -1
- package/sdk/dist/node/vault-keystore.js +5 -5
- package/sdk/dist/node/vault-keystore.js.map +1 -1
- package/sdk/dist/node/vault-member-bundle.js +1 -1
- package/sdk/dist/node/vault-member-bundle.js.map +1 -1
- package/sdk/dist/node/vault-prewarm.d.ts +23 -2
- package/sdk/dist/node/vault-prewarm.d.ts.map +1 -1
- package/sdk/dist/node/vault-prewarm.js +34 -2
- package/sdk/dist/node/vault-prewarm.js.map +1 -1
- package/sdk/dist/node/vault-publication.d.ts +13 -13
- package/sdk/dist/node/vault-publication.d.ts.map +1 -1
- package/sdk/dist/node/vault-publication.js +19 -20
- package/sdk/dist/node/vault-publication.js.map +1 -1
- package/sdk/dist/secret-gate.js +1 -1
- package/sdk/dist/secret-gate.js.map +1 -1
- package/sdk/dist/type-contract.d.ts.map +1 -1
- package/sdk/dist/type-contract.js +6 -0
- package/sdk/dist/type-contract.js.map +1 -1
- package/vault-surface.json +1 -1
|
@@ -61,9 +61,11 @@ THE WORKFLOW — configure -> authorize -> test -> live:
|
|
|
61
61
|
only — nothing that predates the route is ever delivered.
|
|
62
62
|
|
|
63
63
|
What can be routed:
|
|
64
|
-
event types
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
event types agent_claim_created, agent_claim_released,
|
|
65
|
+
agent_message_sent, deploy_activated,
|
|
66
|
+
error_fingerprints_observed, platform_incident,
|
|
67
|
+
platform_payment_received — the seven reviewed projectors.
|
|
68
|
+
Nothing else has one, so nothing else can be routed.
|
|
67
69
|
event classes security, billing_critical, destructive_lifecycle,
|
|
68
70
|
verification, and recovery may NEVER be routed to Buzz.
|
|
69
71
|
Omitting --event-type/--event-class routes every registered type / every
|
package/lib/buzz.mjs
CHANGED
|
@@ -46,7 +46,7 @@ Explicit consent/decision commands:
|
|
|
46
46
|
run402 buzz revoke <buzzae_id>
|
|
47
47
|
|
|
48
48
|
Project-event routing into a Buzz channel (configure → authorize → test → live):
|
|
49
|
-
run402 buzz notifications configure --org <uuid> --installation <buzzci_id> --name <route_name> --channel <uuid> --project <project_id> [--event-type <t> ...] [--event-class <c> ...] [--include-org-events]
|
|
49
|
+
run402 buzz notifications configure --org <uuid> --installation <buzzci_id> --name <route_name> --channel <uuid> (--project <project_id> [--project <project_id> ...] | --all-projects) [--event-type <t> ...] [--event-class <c> ...] [--include-org-events]
|
|
50
50
|
run402 buzz notifications status [--org <uuid> | <buzzper_id>]
|
|
51
51
|
run402 buzz notifications test <buzzper_id> [--wait]
|
|
52
52
|
run402 buzz notifications deliveries <buzzper_id> [--limit <n>] [--cursor <c>] [--delivery <buzzped_id>]
|
package/lib/buzz.test.mjs
CHANGED
|
@@ -54,6 +54,7 @@ describe("run402 buzz CLI", () => {
|
|
|
54
54
|
assert.match(stdout.join("\n"), /community installation/);
|
|
55
55
|
assert.match(stdout.join("\n"), /human adoption/);
|
|
56
56
|
assert.match(stdout.join("\n"), /agent enrollment/);
|
|
57
|
+
assert.match(stdout.join("\n"), /notifications configure [^\n]*--all-projects/);
|
|
57
58
|
});
|
|
58
59
|
|
|
59
60
|
it("reports an older gateway as unsupported without attempting a mutation", async () => {
|
|
@@ -282,7 +283,11 @@ describe("run402 buzz notifications CLI", () => {
|
|
|
282
283
|
const help = stdout.join("\n");
|
|
283
284
|
assert.match(help, /Usage:/);
|
|
284
285
|
assert.match(help, /configure -> authorize -> test -> live/);
|
|
285
|
-
|
|
286
|
+
// The seven routable types the gateway's BUZZ_ROUTE_FILTER_INVALID lists.
|
|
287
|
+
for (const t of ["agent_claim_created", "agent_claim_released", "agent_message_sent", "deploy_activated", "error_fingerprints_observed", "platform_incident", "platform_payment_received"]) {
|
|
288
|
+
assert.match(help, new RegExp(t));
|
|
289
|
+
}
|
|
290
|
+
assert.doesNotMatch(help, /three reviewed/);
|
|
286
291
|
assert.match(help, /may NEVER be routed/);
|
|
287
292
|
assert.match(help, /Buzz Desktop -> Settings -> Profile -> Identity/);
|
|
288
293
|
assert.match(help, /never a deadman channel/);
|
package/lib/deploy-v2.mjs
CHANGED
|
@@ -130,6 +130,8 @@ Options:
|
|
|
130
130
|
--print-manifest Export snake_case authoring JSON relative to the original manifest
|
|
131
131
|
directory. Unsupported constructs fail; no gateway calls or uploads.
|
|
132
132
|
--plan Ask the gateway for a reviewed plan. No upload or commit.
|
|
133
|
+
The plan's diff names what would change; diff.tools lists
|
|
134
|
+
the MCP tools it would add, remove, or change.
|
|
133
135
|
--no-rehearse Skip the automatic rehearsal. By default a migration-bearing plan
|
|
134
136
|
against a project with a live release is rehearsed on a contained
|
|
135
137
|
branch and committed only on a passing report (result.rehearsal);
|
|
@@ -188,6 +190,19 @@ Function capabilities:
|
|
|
188
190
|
Framework adapters use it for contracts such as "astro.ssr.v1"; omit it for
|
|
189
191
|
ordinary user-authored functions unless a documented helper requires it.
|
|
190
192
|
|
|
193
|
+
MCP tools:
|
|
194
|
+
A function file declares its tools beside the handler, as static literals:
|
|
195
|
+
export const tool = { description: "...", input: { type: "object", ... } };
|
|
196
|
+
export const tools = { list_notes: { method: "GET", path: "/api/notes", ... }, add_note: { ... } };
|
|
197
|
+
This command reads the export by parsing the source (never running it) and sends
|
|
198
|
+
it as functions.<name>.tools, [] when the source declares none. A declaration it
|
|
199
|
+
cannot carry fails here, before any request: MCP_TOOL_NOT_STATIC, MCP_TOOL_SCHEMA_INVALID,
|
|
200
|
+
MCP_TOOL_NAME_INVALID, MCP_TOOL_NAME_DUPLICATE, with the file, line and field.
|
|
201
|
+
The release entry is the only carrier: a manifest that writes "tools" on a function
|
|
202
|
+
is sent as written, and a function sent with no tools has none.
|
|
203
|
+
run402 deploy --plan shows diff.tools; run402 deploy releases active shows each
|
|
204
|
+
function's tools with their method and path.
|
|
205
|
+
|
|
191
206
|
Internationalization (routed functions):
|
|
192
207
|
"i18n": { "defaultLocale": "en", "locales": ["en", "es", "fr"], "detect": ["cookie:wl_locale", "accept-language"] }
|
|
193
208
|
Omit i18n to carry forward from base release; pass "i18n": null to clear the slice on the new release.
|
|
@@ -325,8 +340,11 @@ Subcommands:
|
|
|
325
340
|
diff Diff two release targets
|
|
326
341
|
|
|
327
342
|
Output:
|
|
328
|
-
get/active: { "release": {...} } # includes route inventory and inventory warnings when returned
|
|
329
|
-
|
|
343
|
+
get/active: { "release": {...} } # includes route inventory and inventory warnings when returned;
|
|
344
|
+
# functions[].tools lists each function's MCP tools
|
|
345
|
+
# (name, description, input, method, path)
|
|
346
|
+
diff: { "diff": {...} } # includes route added/removed/changed diff buckets, and
|
|
347
|
+
# tools.added/removed/changed by tool name
|
|
330
348
|
`;
|
|
331
349
|
|
|
332
350
|
const RELEASES_GET_HELP = `run402 deploy releases get — Fetch a release inventory by id
|
|
@@ -339,7 +357,8 @@ Options:
|
|
|
339
357
|
--site-limit <n> Maximum site path entries to include (gateway default: 5000)
|
|
340
358
|
|
|
341
359
|
Output:
|
|
342
|
-
stdout: { "release": {...} } # preserves full routes inventory and warnings
|
|
360
|
+
stdout: { "release": {...} } # preserves full routes inventory and warnings;
|
|
361
|
+
# functions[].tools lists each function's MCP tools
|
|
343
362
|
`;
|
|
344
363
|
|
|
345
364
|
const RELEASES_ACTIVE_HELP = `run402 deploy releases active — Fetch the active release inventory
|
|
@@ -352,7 +371,8 @@ Options:
|
|
|
352
371
|
--site-limit <n> Maximum site path entries to include (gateway default: 5000)
|
|
353
372
|
|
|
354
373
|
Output:
|
|
355
|
-
stdout: { "release": {...} } # preserves full routes inventory and warnings
|
|
374
|
+
stdout: { "release": {...} } # preserves full routes inventory and warnings;
|
|
375
|
+
# functions[].tools lists each function's MCP tools
|
|
356
376
|
`;
|
|
357
377
|
|
|
358
378
|
const RELEASES_DIFF_HELP = `run402 deploy releases diff — Diff two release targets
|
|
@@ -367,7 +387,8 @@ Options:
|
|
|
367
387
|
--limit <n> Maximum entries per site diff bucket (gateway default: 1000)
|
|
368
388
|
|
|
369
389
|
Output:
|
|
370
|
-
stdout: { "diff": {...} } # preserves routes.added/removed/changed
|
|
390
|
+
stdout: { "diff": {...} } # preserves routes.added/removed/changed and
|
|
391
|
+
# tools.added/removed/changed (MCP tool names)
|
|
371
392
|
`;
|
|
372
393
|
|
|
373
394
|
const RESOLVE_HELP = `run402 deploy resolve — Explain what a Run402 public URL would serve
|
package/lib/harness-context.mjs
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
* Best-effort session + task identity sourced from the AI harness running
|
|
3
3
|
* this CLI invocation (Claude Code, Codex, or Grok) — no network call, every source
|
|
4
4
|
* optional, the chain always terminates. Backs coordination-room presence
|
|
5
|
-
* resumption in rooms-context.mjs (
|
|
6
|
-
* presence-naming-ergonomics, tasks 2.2 / 3.1-3.2).
|
|
5
|
+
* resumption in rooms-context.mjs (decisions D-agent-presence-1 and -2).
|
|
7
6
|
*
|
|
8
7
|
* Session identity is what makes a presence RESUMABLE across a lost local
|
|
9
8
|
* cache (a fresh checkout, a wiped .run402/, a restarted machine): the
|
|
@@ -222,7 +221,7 @@ async function readCodexThreadTitle({ env, existsSyncImpl, homedirImpl }) {
|
|
|
222
221
|
/**
|
|
223
222
|
* Best-effort "what is this session working on", sourced from the harness's
|
|
224
223
|
* own thread title when the caller did not pass an explicit `task`. Design
|
|
225
|
-
*
|
|
224
|
+
* D-agent-presence-2 (run402-private): the thread title is the best
|
|
226
225
|
* "what am I working on" string in the system — automatic, human-meaningful,
|
|
227
226
|
* already maintained by the user — and the schema already has the right
|
|
228
227
|
* slot for it (`task` is display-only and already refreshed on every
|
package/lib/orgs.mjs
CHANGED
|
@@ -717,7 +717,7 @@ async function runMember(args) {
|
|
|
717
717
|
}
|
|
718
718
|
|
|
719
719
|
if (memberAction === "revoke-key") {
|
|
720
|
-
// vault-
|
|
720
|
+
// D-vault-human-envelopes-9: owner + step-up revokes a member's current
|
|
721
721
|
// vault encryption key — the ONLY rotation path for a member that shares
|
|
722
722
|
// an org with another custodian (a lost/rebuilt keystore fails
|
|
723
723
|
// VAULT_KEY_ROTATION_REQUIRED and points here). Adapter only.
|
|
@@ -145,7 +145,7 @@ const configModP = import("./config.mjs");
|
|
|
145
145
|
const { getSdk } = await sdkModP;
|
|
146
146
|
const { resolveWalletCore, enforceWalletExistsCore, WalletSelectionError } = await walletModP;
|
|
147
147
|
const { vaultRemoteAddressForm, vaultSlugReleasedInfo, parseVaultRemoteUrl, vaultDegradedReadNote } = await isoModP;
|
|
148
|
-
const { VAULT_R402_REF_NAMESPACE, hardenedGit, resolveGitInvocationRepo, readPinnedVaultRepo, pinVaultRepo, readVaultRestoreMarker, readVaultAutoGcThreshold, predialVaultObjectStore } = await nodeModP;
|
|
148
|
+
const { VAULT_R402_REF_NAMESPACE, hardenedGit, resolveGitInvocationRepo, readPinnedVaultRepo, pinVaultRepo, readVaultRestoreMarker, readVaultAutoGcThreshold, predialVaultObjectStore, predialVaultObjectStoreForProject } = await nodeModP;
|
|
149
149
|
const { walletFile, projectCredentialsFile, profileStateFile } = await configModP;
|
|
150
150
|
|
|
151
151
|
/**
|
|
@@ -321,6 +321,17 @@ function resolveRemoteAddress(argv) {
|
|
|
321
321
|
return null;
|
|
322
322
|
}
|
|
323
323
|
|
|
324
|
+
/**
|
|
325
|
+
* The id-form address git's argv names, or `null` (no address, or a slug
|
|
326
|
+
* that names no project id). The resident daemon's session-accept predial
|
|
327
|
+
* (vault-object-host-predial task 2.3) uses it to find a fresh clone
|
|
328
|
+
* target's repo in the keystore before the session module takes over.
|
|
329
|
+
*/
|
|
330
|
+
export function idFormRemoteAddress(argv) {
|
|
331
|
+
const address = resolveRemoteAddress(Array.isArray(argv) ? argv : []);
|
|
332
|
+
return address && vaultRemoteAddressForm(address) === "id" ? address : null;
|
|
333
|
+
}
|
|
334
|
+
|
|
324
335
|
/** `[+]<src>:<dst>` — an empty `<src>` is a deletion. */
|
|
325
336
|
function parsePushSpec(spec) {
|
|
326
337
|
const forced = spec.startsWith("+");
|
|
@@ -480,16 +491,20 @@ async function main(argv, { onBackgroundWork } = {}) {
|
|
|
480
491
|
// fallback path — this module IS that fallback; a daemon-forwarded
|
|
481
492
|
// session reaches the same code and gets the same predial for free).
|
|
482
493
|
// The repository is now known OFFLINE (no network read, matching
|
|
483
|
-
//
|
|
494
|
+
// D-vault-client-surface-11) — fire-and-forget dial the addressed repo's persisted
|
|
484
495
|
// object-store origin(s), if the local keystore has learned any, so
|
|
485
496
|
// it overlaps the rest of this session's local work exactly like the
|
|
486
497
|
// API-origin prewarm that already raced module load above. A repo
|
|
487
498
|
// with no local pin (never opened here before) or nothing persisted
|
|
488
499
|
// yet predials nothing — never a source of a new failure mode.
|
|
500
|
+
// Task 2.3: a fresh clone target carries no pin yet (a handoff
|
|
501
|
+
// `resume` clone always), so an id-form address resolves the repo
|
|
502
|
+
// from the keystore's own project→repo match instead — still offline.
|
|
489
503
|
void (async () => {
|
|
490
504
|
try {
|
|
491
505
|
const pinned = await readPinnedVaultRepo(resolvedRepo.repo_dir);
|
|
492
506
|
if (pinned) predialVaultObjectStore(pinned.repo_id);
|
|
507
|
+
else if (addressForm === "id") predialVaultObjectStoreForProject(address.project_id, address.org_id);
|
|
493
508
|
} catch {
|
|
494
509
|
/* best-effort: must never surface from repository resolution */
|
|
495
510
|
}
|
|
@@ -648,7 +663,7 @@ async function main(argv, { onBackgroundWork } = {}) {
|
|
|
648
663
|
fetchMarker = null;
|
|
649
664
|
}
|
|
650
665
|
}
|
|
651
|
-
// vault-
|
|
666
|
+
// D-vault-19, D-vault-client-surface-21: a marker-absent fetch target is,
|
|
652
667
|
// by construction, the WHOLESALE restore shape (a fresh `git clone`, or
|
|
653
668
|
// a target that never completed a restore) — declare restore intent
|
|
654
669
|
// here so a capable gateway's plan rides THIS state read, reused by
|
package/lib/repos.mjs
CHANGED
|
@@ -2894,7 +2894,7 @@ async function accessRevokeKey(args) {
|
|
|
2894
2894
|
*/
|
|
2895
2895
|
/**
|
|
2896
2896
|
* `repos access repin --principal <principal_id> --fingerprint <ek_…>` — a KEY-HOLDER
|
|
2897
|
-
* explicitly accepts a recipient's CHANGED key (vault-
|
|
2897
|
+
* explicitly accepts a recipient's CHANGED key (D-vault-client-surface-24).
|
|
2898
2898
|
* The session-start reconcile refuses `pinned_key_mismatch` and never
|
|
2899
2899
|
* bypasses it, not even after an owner's revoke — acceptance names the new
|
|
2900
2900
|
* fingerprint (the out-of-band verification point) and moves the local pin.
|
package/lib/vault-daemon.mjs
CHANGED
|
@@ -53,14 +53,14 @@ export async function runDaemon() {
|
|
|
53
53
|
// Load the heavy module ONCE — this is the entire point of residency.
|
|
54
54
|
// Its top-level await pulls the SDK graph; the prewarm dials the API
|
|
55
55
|
// origin so the first forwarded session rides a warm h2 connection.
|
|
56
|
-
const { prewarmVaultConnection, kickVaultConnection, predialVaultObjectStore } = await import("../sdk/dist/node/vault-prewarm.js");
|
|
56
|
+
const { prewarmVaultConnection, kickVaultConnection, predialVaultObjectStore, predialVaultObjectStoreForProject } = await import("../sdk/dist/node/vault-prewarm.js");
|
|
57
57
|
prewarmVaultConnection();
|
|
58
|
-
const { runHelperSession } = await import("./remote-helper-session.mjs");
|
|
58
|
+
const { runHelperSession, idFormRemoteAddress } = await import("./remote-helper-session.mjs");
|
|
59
59
|
// vault-object-host-predial task 2.2 — narrow, session-scoped imports
|
|
60
60
|
// (not the whole `#sdk/node` barrel) for the OFFLINE repo resolution the
|
|
61
61
|
// session-accept predial needs: a local git subprocess (`rev-parse
|
|
62
62
|
// --absolute-git-dir`) plus a local git-config read, never a network
|
|
63
|
-
// call (
|
|
63
|
+
// call (D-vault-client-surface-11).
|
|
64
64
|
const { resolveGitInvocationRepo } = await import("../sdk/dist/node/vault-snapshot.js");
|
|
65
65
|
const { readPinnedVaultRepo } = await import("../sdk/dist/node/vault-address.js");
|
|
66
66
|
|
|
@@ -202,13 +202,19 @@ export async function runDaemon() {
|
|
|
202
202
|
// --absolute-git-dir`) then `readPinnedVaultRepo` (a local
|
|
203
203
|
// `git config --local` read). Any resolution failure (no
|
|
204
204
|
// `GIT_DIR`, not a repository, no pin yet) predials nothing —
|
|
205
|
-
// never a network read to learn where to predial (
|
|
205
|
+
// never a network read to learn where to predial (D-vault-client-surface-11),
|
|
206
206
|
// and never allowed to delay or fail this session's accept.
|
|
207
207
|
void (async () => {
|
|
208
208
|
try {
|
|
209
209
|
const { repo_dir } = await resolveGitInvocationRepo(msg.env ?? {}, msg.cwd);
|
|
210
210
|
const pinned = await readPinnedVaultRepo(repo_dir);
|
|
211
211
|
if (pinned) predialVaultObjectStore(pinned.repo_id);
|
|
212
|
+
else {
|
|
213
|
+
// Task 2.3: a fresh clone target has no pin yet — find the
|
|
214
|
+
// addressed repo in the keystore by its project, offline.
|
|
215
|
+
const address = idFormRemoteAddress(msg.argv);
|
|
216
|
+
if (address) predialVaultObjectStoreForProject(address.project_id, address.org_id);
|
|
217
|
+
}
|
|
212
218
|
} catch {
|
|
213
219
|
/* best-effort: must never surface from session accept */
|
|
214
220
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "run402",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.155.1",
|
|
4
4
|
"description": "CLI for Run402 — full-stack backend infrastructure for AI agents: Postgres, auth, storage, serverless functions and atomic deploys. Paid with x402/MPP. Includes $0.03 image generation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"@scure/base": "1.2.6",
|
|
34
34
|
"@x402/evm": "2.29.0",
|
|
35
35
|
"@x402/fetch": "2.29.0",
|
|
36
|
+
"acorn": "^8.18.0",
|
|
36
37
|
"mppx": "^0.17.0",
|
|
37
38
|
"undici": "^7.29.0",
|
|
38
39
|
"viem": "^2.57.1"
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP tools on a function's release entry (`functions.<name>.tools`).
|
|
3
|
+
*
|
|
4
|
+
* A function file or an Astro endpoint file declares its tools beside the
|
|
5
|
+
* handler, as static literals:
|
|
6
|
+
*
|
|
7
|
+
* export const tool = { description: "…", input: { type: "object", … } };
|
|
8
|
+
* export const tools = { list_notes: { … }, add_note: { … } };
|
|
9
|
+
*
|
|
10
|
+
* Deploy tooling reads the export by parsing, never by running it (the Node
|
|
11
|
+
* extractor, `node/tool-declarations.ts`), and carries it in the release. The
|
|
12
|
+
* gateway takes a function's tools only from its release entry: an omitted
|
|
13
|
+
* `tools` means none, as with `triggers`.
|
|
14
|
+
*
|
|
15
|
+
* This module is the isomorphic half: the rules one entry obeys (shared by
|
|
16
|
+
* the extractor and by the spec check for `tools` passed as data), the
|
|
17
|
+
* refusal's shape, the error a deploy throws for it, and the slot the Node
|
|
18
|
+
* entry point installs its source reader into.
|
|
19
|
+
*/
|
|
20
|
+
import { Run402DeployError } from "./errors.js";
|
|
21
|
+
import type { FunctionToolSpec } from "./namespaces/deploy.types.js";
|
|
22
|
+
/** Codes a tool declaration is refused with before any request, and by the gateway at plan with HTTP 422. */
|
|
23
|
+
export type McpToolErrorCode = "MCP_TOOL_NOT_STATIC" | "MCP_TOOL_SCHEMA_INVALID" | "MCP_TOOL_NAME_INVALID" | "MCP_TOOL_NAME_DUPLICATE" | "MCP_TOOL_ROUTE_ELSEWHERE" | "MCP_TOOL_PATH_UNSUPPORTED";
|
|
24
|
+
/** Why a tool declaration is refused, as data. */
|
|
25
|
+
export interface ToolDeclarationProblem {
|
|
26
|
+
code: McpToolErrorCode;
|
|
27
|
+
message: string;
|
|
28
|
+
/** The source file as the caller named it; null for an inline source or for `tools` passed as data. */
|
|
29
|
+
file: string | null;
|
|
30
|
+
/** 1-based line in `file`. Present only when it is exact. */
|
|
31
|
+
line?: number;
|
|
32
|
+
/** Where in the export or the spec, e.g. `tools.add_note.input.type`. */
|
|
33
|
+
field_path: string;
|
|
34
|
+
/** The tool's name, when the declaration got far enough to have one. */
|
|
35
|
+
tool?: string;
|
|
36
|
+
}
|
|
37
|
+
export declare const MCP_TOOL_DESCRIPTION_MAX = 1024;
|
|
38
|
+
export declare const MCP_TOOL_TITLE_MAX = 128;
|
|
39
|
+
/** Serialized size ceiling for one declaration (description plus schema). */
|
|
40
|
+
export declare const MCP_TOOL_DECLARATION_MAX_BYTES: number;
|
|
41
|
+
/** MCP tool names: 1 to 128 of `A-Z a-z 0-9 _ - .`. */
|
|
42
|
+
export declare function isValidMcpToolName(name: string): boolean;
|
|
43
|
+
type EntryProblem = Pick<ToolDeclarationProblem, "code" | "message" | "field_path">;
|
|
44
|
+
export type FunctionToolEntryCheck = {
|
|
45
|
+
ok: true;
|
|
46
|
+
tool: FunctionToolSpec;
|
|
47
|
+
} | {
|
|
48
|
+
ok: false;
|
|
49
|
+
problem: EntryProblem;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* Split a tool path into its `{param}` names. A `{param}` stands for one whole
|
|
53
|
+
* path segment; a wildcard, a rest segment, or a parameter that is only part
|
|
54
|
+
* of a segment has no tool binding.
|
|
55
|
+
*/
|
|
56
|
+
export declare function toolPathParams(path: string): {
|
|
57
|
+
ok: true;
|
|
58
|
+
params: string[];
|
|
59
|
+
} | {
|
|
60
|
+
ok: false;
|
|
61
|
+
code: "MCP_TOOL_SCHEMA_INVALID" | "MCP_TOOL_PATH_UNSUPPORTED";
|
|
62
|
+
message: string;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Check one tool entry, already a plain value, against the rules every
|
|
66
|
+
* carrier shares, and return it with its fields in a fixed order.
|
|
67
|
+
* `pathParams` overrides the parameters read from `path` (an Astro endpoint's
|
|
68
|
+
* path is its route, never a field of the declaration).
|
|
69
|
+
*/
|
|
70
|
+
export declare function checkFunctionToolEntry(value: unknown, fieldPath: string, opts?: {
|
|
71
|
+
pathParams?: readonly string[];
|
|
72
|
+
}): FunctionToolEntryCheck;
|
|
73
|
+
/** One group of tools and where it came from: a function of a spec, or a source file of a build. */
|
|
74
|
+
export interface ToolNameGroup {
|
|
75
|
+
/** The function name or the file, as the refusal should name it. */
|
|
76
|
+
owner: string;
|
|
77
|
+
tools: ReadonlyArray<Pick<FunctionToolSpec, "name">>;
|
|
78
|
+
/** The name a tool with no `name` takes (a function file's single `tool`: the function name). */
|
|
79
|
+
defaultName?: string;
|
|
80
|
+
}
|
|
81
|
+
/** The first tool name two tools of one build share, with the two owners in the order given. */
|
|
82
|
+
export declare function findDuplicateToolName(groups: readonly ToolNameGroup[]): {
|
|
83
|
+
name: string;
|
|
84
|
+
owners: [string, string];
|
|
85
|
+
} | null;
|
|
86
|
+
/** `src/pages/api/notes.ts:12`, `functions.replace.api.source:12`, or just the name when there is no exact line. */
|
|
87
|
+
export declare function toolProblemLocation(problem: Pick<ToolDeclarationProblem, "file" | "line">, fallback?: string): string | null;
|
|
88
|
+
/**
|
|
89
|
+
* The error a deploy throws for a refused tool declaration, before any
|
|
90
|
+
* request: the gateway's code for the same condition, `resource`
|
|
91
|
+
* `functions.<function>.tools[.<tool>]`, the file, line and field path under
|
|
92
|
+
* `details`, and an `edit_request` next action.
|
|
93
|
+
*/
|
|
94
|
+
export declare function toolDeclarationError(problem: ToolDeclarationProblem, where: {
|
|
95
|
+
functionName: string;
|
|
96
|
+
sourceField?: string;
|
|
97
|
+
functions?: string[];
|
|
98
|
+
}): Run402DeployError;
|
|
99
|
+
/** What the installed reader is given: one function's entry source, as text. */
|
|
100
|
+
export interface FunctionToolLiftInput {
|
|
101
|
+
functionName: string;
|
|
102
|
+
source: string;
|
|
103
|
+
/** The source's path on disk, when it has one. */
|
|
104
|
+
file: string | null;
|
|
105
|
+
/** The spec field the source came from, e.g. `functions.replace.api.source`. */
|
|
106
|
+
sourceField: string;
|
|
107
|
+
}
|
|
108
|
+
/** Reads the tools a function's entry source declares; throws {@link Run402DeployError} on a refused declaration. */
|
|
109
|
+
export type FunctionToolLifter = (input: FunctionToolLiftInput) => FunctionToolSpec[];
|
|
110
|
+
/**
|
|
111
|
+
* Install the reader `apply` calls for every function source it reads when
|
|
112
|
+
* the entry names no `tools`. Reading a declaration means parsing JavaScript,
|
|
113
|
+
* which is Node-only, so `@run402/sdk/node` installs it when it loads; with
|
|
114
|
+
* none installed, `tools` is forwarded only when the caller passes it.
|
|
115
|
+
*/
|
|
116
|
+
export declare function installFunctionToolLifter(lifter: FunctionToolLifter | null): void;
|
|
117
|
+
export declare function installedFunctionToolLifter(): FunctionToolLifter | null;
|
|
118
|
+
export {};
|
|
119
|
+
//# sourceMappingURL=function-tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function-tools.d.ts","sourceRoot":"","sources":["../src/function-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,KAAK,EAA+C,gBAAgB,EAAE,MAA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