run402-mcp 4.154.0 → 4.155.0
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/dist/docs/llms-sdk.txt +24 -6
- package/package.json +3 -3
- package/schemas/release-spec.v1.json +71 -0
- package/sdk/README.md +12 -0
- 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/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/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 +3 -1
- package/sdk/dist/node/index.d.ts.map +1 -1
- package/sdk/dist/node/index.js +12 -1
- package/sdk/dist/node/index.js.map +1 -1
- package/sdk/dist/node/paid-fetch.d.ts +17 -0
- package/sdk/dist/node/paid-fetch.d.ts.map +1 -1
- package/sdk/dist/node/paid-fetch.js +62 -2
- package/sdk/dist/node/paid-fetch.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/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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/namespaces/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAwB3C,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EAQtB,WAAW,EACX,oBAAoB,EAEpB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"deploy.d.ts","sourceRoot":"","sources":["../../src/namespaces/deploy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAwB3C,OAAO,KAAK,EACV,YAAY,EACZ,sBAAsB,EAQtB,WAAW,EACX,oBAAoB,EAEpB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EAOvB,sBAAsB,EACtB,oBAAoB,EAUpB,iBAAiB,EAGjB,YAAY,EACZ,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,gBAAgB,EAChB,2BAA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AM,CAAA;KAAE,GACxB,OAAO,CAAC,oBAAoB,CAAC,CAiB/B;IAED;;;;OAIG;IACG,aAAa,CACjB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GACxB,OAAO,CAAC,mBAAmB,CAAC,CAuB9B;IAED;;;;OAIG;IACG,gBAAgB,CACpB,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE,wBAAwB,GAC7B,OAAO,CAAC,uBAAuB,CAAC,CAkClC;IAED;;;;OAIG;IACG,UAAU,CAAC,IAAI,EAAE,2BAA2B,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA2B7E;IAED;;;;OAIG;IACG,gBAAgB,CACpB,IAAI,EAAE,uBAAuB,GAC5B,OAAO,CAAC,sBAAsB,CAAC,CAmBjC;IAED;;;;OAIG;IACG,IAAI,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC,CA6BlE;IAED;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAUxE;CACF;AA+4ED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,IAAI,OAAO,CAAC,UAAU,CAAC,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;iEAG6D;IAC7D,KAAK,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;CACvC;AA8qFD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAKrD"}
|
|
@@ -27,6 +27,7 @@ import { ROUTE_PRICING_NETWORKS, ROUTE_HTTP_METHODS, isModernPlanMigrationDiff,
|
|
|
27
27
|
import { ApiError, LocalError, PaymentRequired, Run402DeployError, Unauthorized, isNoResponseError, isRun402Error, isTransferFreezeError, } from "../errors.js";
|
|
28
28
|
import { assertAssetMetadata, assertExifPolicy, } from "./assets-validation.js";
|
|
29
29
|
import { withSiteRemovalSummaries } from "./site-removal-summary.js";
|
|
30
|
+
import { checkFunctionToolEntry, findDuplicateToolName, installedFunctionToolLifter, toolDeclarationError, } from "../function-tools.js";
|
|
30
31
|
// ─── Constants ───────────────────────────────────────────────────────────────
|
|
31
32
|
const PLAN_BODY_LIMIT_BYTES = 5 * 1024 * 1024;
|
|
32
33
|
const COMMIT_POLL_INITIAL_MS = 1_000;
|
|
@@ -1044,6 +1045,7 @@ function functionToCoreSpec(fn) {
|
|
|
1044
1045
|
...(fn.config !== undefined ? { config: fn.config } : {}),
|
|
1045
1046
|
...(fn.deps !== undefined ? { deps: fn.deps } : {}),
|
|
1046
1047
|
...(fn.triggers !== undefined ? { triggers: fn.triggers } : {}),
|
|
1048
|
+
...(fn.tools !== undefined ? { tools: fn.tools } : {}),
|
|
1047
1049
|
...(fn.requireAuth !== undefined ? { requireAuth: fn.requireAuth } : {}),
|
|
1048
1050
|
...(fn.requireRole !== undefined ? { requireRole: fn.requireRole } : {}),
|
|
1049
1051
|
...(fn.class !== undefined ? { class: fn.class } : {}),
|
|
@@ -1066,6 +1068,9 @@ function functionToWire(fn) {
|
|
|
1066
1068
|
: {}),
|
|
1067
1069
|
...(fn.deps !== undefined ? { deps: fn.deps } : {}),
|
|
1068
1070
|
...(fn.triggers !== undefined ? { triggers: fn.triggers } : {}),
|
|
1071
|
+
// A tool entry's members are single words or MCP's own annotation names,
|
|
1072
|
+
// so the SDK shape is the wire shape.
|
|
1073
|
+
...(fn.tools !== undefined ? { tools: fn.tools } : {}),
|
|
1069
1074
|
...(fn.requireAuth !== undefined ? { require_auth: fn.requireAuth } : {}),
|
|
1070
1075
|
...(fn.requireRole !== undefined
|
|
1071
1076
|
? { require_role: fn.requireRole === null ? null : requireRoleToWire(fn.requireRole) }
|
|
@@ -2524,6 +2529,7 @@ const FUNCTION_SPEC_FIELDS = new Set([
|
|
|
2524
2529
|
"config",
|
|
2525
2530
|
"deps",
|
|
2526
2531
|
"triggers",
|
|
2532
|
+
"tools",
|
|
2527
2533
|
"schedule",
|
|
2528
2534
|
"requireAuth",
|
|
2529
2535
|
"requireRole",
|
|
@@ -2700,6 +2706,25 @@ function validateFunctionMap(value, resource) {
|
|
|
2700
2706
|
requireObject(entry.files, `${resource}.${name}.files`);
|
|
2701
2707
|
}
|
|
2702
2708
|
validateFunctionTriggers(entry.triggers, `${resource}.${name}.triggers`);
|
|
2709
|
+
validateFunctionTools(entry.tools, `${resource}.${name}.tools`, name);
|
|
2710
|
+
}
|
|
2711
|
+
}
|
|
2712
|
+
/**
|
|
2713
|
+
* `tools` passed as data obeys the rules a declaration read from source does,
|
|
2714
|
+
* and is refused with the same codes before any request.
|
|
2715
|
+
*/
|
|
2716
|
+
function validateFunctionTools(value, resource, functionName) {
|
|
2717
|
+
if (value === undefined)
|
|
2718
|
+
return;
|
|
2719
|
+
if (!Array.isArray(value))
|
|
2720
|
+
throw invalidSpec(`ReleaseSpec.${resource} must be an array`, resource);
|
|
2721
|
+
for (const [index, entry] of value.entries()) {
|
|
2722
|
+
const fieldPath = `${resource}[${index}]`;
|
|
2723
|
+
const checked = checkFunctionToolEntry(entry, fieldPath);
|
|
2724
|
+
if (!checked.ok) {
|
|
2725
|
+
const name = isRecord(entry) && typeof entry.name === "string" ? entry.name : undefined;
|
|
2726
|
+
throw toolDeclarationError({ ...checked.problem, file: null, ...(name !== undefined ? { tool: name } : {}) }, { functionName });
|
|
2727
|
+
}
|
|
2703
2728
|
}
|
|
2704
2729
|
}
|
|
2705
2730
|
function validateFunctionTriggers(value, resource) {
|
|
@@ -3447,6 +3472,9 @@ function normalizePlanResponse(plan) {
|
|
|
3447
3472
|
const warnings = withSiteRemovalSummaries(Array.isArray(raw.warnings) ? raw.warnings : []);
|
|
3448
3473
|
const missingContent = Array.isArray(raw.missing_content) ? raw.missing_content : [];
|
|
3449
3474
|
if (raw.kind === "plan_response") {
|
|
3475
|
+
// The plan's tools bucket sits beside the other buckets; a gateway that
|
|
3476
|
+
// nests it under `diff` is read the same way.
|
|
3477
|
+
const tools = raw.tools ?? raw.diff?.tools;
|
|
3450
3478
|
const diff = {
|
|
3451
3479
|
is_noop: raw.is_noop,
|
|
3452
3480
|
summary: raw.summary,
|
|
@@ -3458,6 +3486,7 @@ function normalizePlanResponse(plan) {
|
|
|
3458
3486
|
subdomains: raw.subdomains,
|
|
3459
3487
|
routes: raw.routes,
|
|
3460
3488
|
static_assets: raw.static_assets,
|
|
3489
|
+
...(tools ? { tools } : {}),
|
|
3461
3490
|
...(raw.public_paths ? { public_paths: raw.public_paths } : {}),
|
|
3462
3491
|
...(raw.site_settings ? { site_settings: raw.site_settings } : {}),
|
|
3463
3492
|
};
|
|
@@ -3798,16 +3827,17 @@ async function normalizeReleaseSpec(client, spec, opts = {}) {
|
|
|
3798
3827
|
if (spec.functions) {
|
|
3799
3828
|
const fns = {};
|
|
3800
3829
|
if (spec.functions.replace) {
|
|
3801
|
-
fns.replace = await normalizeFunctionMap(spec.functions.replace, rememberRelease);
|
|
3830
|
+
fns.replace = await normalizeFunctionMap(spec.functions.replace, rememberRelease, "functions.replace");
|
|
3802
3831
|
}
|
|
3803
3832
|
if (spec.functions.patch) {
|
|
3804
3833
|
fns.patch = {};
|
|
3805
3834
|
if (spec.functions.patch.set) {
|
|
3806
|
-
fns.patch.set = await normalizeFunctionMap(spec.functions.patch.set, rememberRelease);
|
|
3835
|
+
fns.patch.set = await normalizeFunctionMap(spec.functions.patch.set, rememberRelease, "functions.patch.set");
|
|
3807
3836
|
}
|
|
3808
3837
|
if (spec.functions.patch.delete)
|
|
3809
3838
|
fns.patch.delete = spec.functions.patch.delete;
|
|
3810
3839
|
}
|
|
3840
|
+
assertUniqueToolNames(fns);
|
|
3811
3841
|
normalized.functions = fns;
|
|
3812
3842
|
}
|
|
3813
3843
|
if (spec.site) {
|
|
@@ -3871,14 +3901,14 @@ async function normalizeReleaseSpec(client, spec, opts = {}) {
|
|
|
3871
3901
|
}
|
|
3872
3902
|
return { normalized, byteReaders };
|
|
3873
3903
|
}
|
|
3874
|
-
async function normalizeFunctionMap(map, remember) {
|
|
3904
|
+
async function normalizeFunctionMap(map, remember, resource) {
|
|
3875
3905
|
const out = {};
|
|
3876
3906
|
for (const [name, fn] of Object.entries(map)) {
|
|
3877
|
-
out[name] = await normalizeFunction(fn, remember);
|
|
3907
|
+
out[name] = await normalizeFunction(fn, remember, { name, resource: `${resource}.${name}` });
|
|
3878
3908
|
}
|
|
3879
3909
|
return out;
|
|
3880
3910
|
}
|
|
3881
|
-
async function normalizeFunction(fn, remember) {
|
|
3911
|
+
async function normalizeFunction(fn, remember, where) {
|
|
3882
3912
|
const out = {
|
|
3883
3913
|
runtime: fn.runtime ?? "node22",
|
|
3884
3914
|
};
|
|
@@ -3898,15 +3928,107 @@ async function normalizeFunction(fn, remember) {
|
|
|
3898
3928
|
out.class = fn.class;
|
|
3899
3929
|
if (fn.capabilities !== undefined)
|
|
3900
3930
|
out.capabilities = [...fn.capabilities];
|
|
3931
|
+
// The entry source, when this call reads it: what a tool reader is given.
|
|
3932
|
+
let entry = null;
|
|
3901
3933
|
if (fn.source !== undefined) {
|
|
3902
3934
|
const resolved = await resolveContent(fn.source, "function source");
|
|
3903
3935
|
out.source = remember(resolved);
|
|
3936
|
+
if (!isPreResolvedContent(fn.source)) {
|
|
3937
|
+
entry = {
|
|
3938
|
+
text: async () => new TextDecoder().decode(await resolved.reader()),
|
|
3939
|
+
file: fsPathOf(fn.source),
|
|
3940
|
+
field: `${where.resource}.source`,
|
|
3941
|
+
};
|
|
3942
|
+
}
|
|
3904
3943
|
}
|
|
3905
3944
|
if (fn.files) {
|
|
3906
3945
|
out.files = await normalizeFileSet(fn.files, remember);
|
|
3946
|
+
const entrySource = fn.entrypoint && !isLocalDirRef(fn.files) ? fn.files[fn.entrypoint] : undefined;
|
|
3947
|
+
if (entry === null && entrySource !== undefined && isRereadableContent(entrySource)) {
|
|
3948
|
+
entry = {
|
|
3949
|
+
text: async () => new TextDecoder().decode(await (await resolveContent(entrySource, "function entrypoint")).reader()),
|
|
3950
|
+
file: fsPathOf(entrySource),
|
|
3951
|
+
field: `${where.resource}.files[${JSON.stringify(fn.entrypoint)}]`,
|
|
3952
|
+
};
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
// A stated `tools`, even `[]`, is sent as written. Otherwise the tools are
|
|
3956
|
+
// read from the entry source, when a reader is installed (`@run402/sdk/node`
|
|
3957
|
+
// installs one) and this call read that source: `[]` when it declares none.
|
|
3958
|
+
if (fn.tools !== undefined) {
|
|
3959
|
+
out.tools = fn.tools.map((tool) => ({ ...tool }));
|
|
3960
|
+
}
|
|
3961
|
+
else {
|
|
3962
|
+
const lift = installedFunctionToolLifter();
|
|
3963
|
+
if (lift && entry) {
|
|
3964
|
+
out.tools = lift({ functionName: where.name, source: await entry.text(), file: entry.file, sourceField: entry.field });
|
|
3965
|
+
}
|
|
3907
3966
|
}
|
|
3908
3967
|
return out;
|
|
3909
3968
|
}
|
|
3969
|
+
/** A `ContentRef` (bare, or wrapped as `{ data }`): bytes already in CAS that this call never reads. */
|
|
3970
|
+
function isPreResolvedContent(source) {
|
|
3971
|
+
if (isContentRef(source))
|
|
3972
|
+
return true;
|
|
3973
|
+
if (isDataWrapper(source))
|
|
3974
|
+
return isPreResolvedContent(source.data);
|
|
3975
|
+
return false;
|
|
3976
|
+
}
|
|
3977
|
+
/** A source that can be read again after normalization read it once (everything but a stream or a `ContentRef`). */
|
|
3978
|
+
function isRereadableContent(source) {
|
|
3979
|
+
if (isDataWrapper(source))
|
|
3980
|
+
return isRereadableContent(source.data);
|
|
3981
|
+
return !isContentRef(source) && !isReadableStream(source);
|
|
3982
|
+
}
|
|
3983
|
+
function isDataWrapper(source) {
|
|
3984
|
+
return (typeof source === "object" &&
|
|
3985
|
+
source !== null &&
|
|
3986
|
+
!Array.isArray(source) &&
|
|
3987
|
+
!(source instanceof Uint8Array) &&
|
|
3988
|
+
!(source instanceof ArrayBuffer) &&
|
|
3989
|
+
!(typeof Blob !== "undefined" && source instanceof Blob) &&
|
|
3990
|
+
!isReadableStream(source) &&
|
|
3991
|
+
!isFsFileSource(source) &&
|
|
3992
|
+
"data" in source);
|
|
3993
|
+
}
|
|
3994
|
+
/** The path on disk a source reads, when it is a file handle. */
|
|
3995
|
+
function fsPathOf(source) {
|
|
3996
|
+
if (isFsFileSource(source))
|
|
3997
|
+
return source.path;
|
|
3998
|
+
if (isDataWrapper(source))
|
|
3999
|
+
return fsPathOf(source.data);
|
|
4000
|
+
return null;
|
|
4001
|
+
}
|
|
4002
|
+
/**
|
|
4003
|
+
* Tool names are unique in a release. Two tools of this spec sharing one is
|
|
4004
|
+
* refused here, naming both functions; the gateway checks the functions the
|
|
4005
|
+
* spec does not name.
|
|
4006
|
+
*/
|
|
4007
|
+
function assertUniqueToolNames(fns) {
|
|
4008
|
+
const groups = [];
|
|
4009
|
+
const collect = (map) => {
|
|
4010
|
+
for (const [name, fn] of Object.entries(map ?? {})) {
|
|
4011
|
+
if (fn.tools && fn.tools.length > 0)
|
|
4012
|
+
groups.push({ owner: name, tools: fn.tools, defaultName: name });
|
|
4013
|
+
}
|
|
4014
|
+
};
|
|
4015
|
+
collect(fns.replace);
|
|
4016
|
+
collect(fns.patch?.set);
|
|
4017
|
+
const duplicate = findDuplicateToolName(groups);
|
|
4018
|
+
if (!duplicate)
|
|
4019
|
+
return;
|
|
4020
|
+
const [first, second] = duplicate.owners;
|
|
4021
|
+
const where = first === second
|
|
4022
|
+
? `function \`${first}\` declares it twice`
|
|
4023
|
+
: `functions \`${first}\` and \`${second}\` both declare it`;
|
|
4024
|
+
throw toolDeclarationError({
|
|
4025
|
+
code: "MCP_TOOL_NAME_DUPLICATE",
|
|
4026
|
+
message: `Two tools are named \`${duplicate.name}\`: ${where}. A tool name is unique in a release; rename one.`,
|
|
4027
|
+
file: null,
|
|
4028
|
+
field_path: `functions.${second}.tools`,
|
|
4029
|
+
tool: duplicate.name,
|
|
4030
|
+
}, { functionName: second, functions: [...new Set(duplicate.owners)] });
|
|
4031
|
+
}
|
|
3910
4032
|
function normalizeFunctionTriggers(triggers) {
|
|
3911
4033
|
const runOf = (run) => ({
|
|
3912
4034
|
...(run.event_type !== undefined ? { event_type: run.event_type } : {}),
|