@hasna/skills 0.8.2 → 0.8.3
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/README.md +70 -2
- package/bin/index.js +585 -282
- package/bin/mcp.js +255 -109
- package/bin/migrate.js +82 -24
- package/bin/server.js +1222 -430
- package/bin/worker.js +395 -87
- package/dist/cli/commands/grants.d.ts +2 -0
- package/dist/index.js +1 -1
- package/dist/lib/execution-grant-client.d.ts +5 -0
- package/dist/lib/execution-grants.d.ts +49 -0
- package/dist/lib/selected-manifest.d.ts +6 -0
- package/dist/lib/selected-run.d.ts +9 -0
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/index.js +9205 -8724
- package/dist/server/execution-grant-store.d.ts +29 -0
- package/dist/server/execution-grants-api.d.ts +4 -0
- package/dist/server/sqlite-store.d.ts +2 -0
- package/dist/server/store.d.ts +3 -0
- package/dist/server/types.d.ts +2 -0
- package/migrations/postgres/0009_execution_grants.sql +15 -0
- package/migrations/sqlite/0009_execution_grants.sql +15 -0
- package/package.json +1 -1
package/bin/index.js
CHANGED
|
@@ -36868,7 +36868,7 @@ var package_default;
|
|
|
36868
36868
|
var init_package = __esm(() => {
|
|
36869
36869
|
package_default = {
|
|
36870
36870
|
name: "@hasna/skills",
|
|
36871
|
-
version: "0.8.
|
|
36871
|
+
version: "0.8.3",
|
|
36872
36872
|
description: "Skills library for AI coding agents",
|
|
36873
36873
|
type: "module",
|
|
36874
36874
|
bin: {
|
|
@@ -81403,18 +81403,213 @@ var init_execution_secrets = __esm(() => {
|
|
|
81403
81403
|
init_selection_cache();
|
|
81404
81404
|
});
|
|
81405
81405
|
|
|
81406
|
-
// src/lib/
|
|
81407
|
-
|
|
81408
|
-
|
|
81409
|
-
|
|
81410
|
-
|
|
81411
|
-
|
|
81406
|
+
// src/lib/execution-grants.ts
|
|
81407
|
+
import { posix, win32 } from "path";
|
|
81408
|
+
function grantIdentifier(v) {
|
|
81409
|
+
return typeof v === "string" && /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(v) && !v.includes("..");
|
|
81410
|
+
}
|
|
81411
|
+
function grantRecord(v) {
|
|
81412
|
+
return !!v && typeof v === "object" && !Array.isArray(v);
|
|
81413
|
+
}
|
|
81414
|
+
function keys2(v, required2, optional2 = []) {
|
|
81415
|
+
return required2.every((k) => Object.hasOwn(v, k)) && Object.keys(v).every((k) => required2.includes(k) || optional2.includes(k));
|
|
81416
|
+
}
|
|
81417
|
+
function invalid4() {
|
|
81418
|
+
throw new Error("Invalid execution grant policy: use exact selections, named actors and consumers, and vault reference names only.");
|
|
81419
|
+
}
|
|
81420
|
+
function authority(v) {
|
|
81421
|
+
if (typeof v !== "string" || v.length > 2048 || /[\x00-\x20\x7f]/.test(v))
|
|
81422
|
+
return false;
|
|
81423
|
+
try {
|
|
81424
|
+
const u = new URL(v);
|
|
81425
|
+
return (u.protocol === "https:" || u.protocol === "http:" && ["127.0.0.1", "localhost", "[::1]"].includes(u.hostname)) && !u.username && !u.password && !u.search && !u.hash && u.pathname.endsWith("/v1") && u.href === v;
|
|
81426
|
+
} catch {
|
|
81427
|
+
return false;
|
|
81428
|
+
}
|
|
81429
|
+
}
|
|
81430
|
+
function pathFlavor(value) {
|
|
81431
|
+
return value.startsWith("/") ? posix : win32;
|
|
81432
|
+
}
|
|
81433
|
+
function grantWorkspace(v) {
|
|
81434
|
+
if (typeof v !== "string" || !v || v.length > 4096 || /[\x00-\x1f\x7f]/.test(v))
|
|
81435
|
+
return false;
|
|
81436
|
+
const flavor = pathFlavor(v);
|
|
81437
|
+
if (flavor === win32 && !/^(?:[A-Za-z]:\\|\\\\[^\\]+\\[^\\]+)/.test(v))
|
|
81438
|
+
return false;
|
|
81439
|
+
return flavor.isAbsolute(v) && flavor.normalize(v) === v;
|
|
81440
|
+
}
|
|
81441
|
+
function selection(v) {
|
|
81442
|
+
return grantRecord(v) && keys2(v, ["slug", "version", "bundleDigest"]) && grantIdentifier(v.slug) && isValidSkillVersion(v.version) && typeof v.bundleDigest === "string" && /^sha256:[a-f0-9]{64}$/.test(v.bundleDigest);
|
|
81443
|
+
}
|
|
81444
|
+
function validateExecutionGrants(value) {
|
|
81445
|
+
if (!Array.isArray(value) || value.length > MAX_EXECUTION_GRANTS)
|
|
81446
|
+
invalid4();
|
|
81447
|
+
const ids = new Set;
|
|
81448
|
+
for (const g of value) {
|
|
81449
|
+
if (!grantRecord(g) || !keys2(g, [
|
|
81450
|
+
"id",
|
|
81451
|
+
"target",
|
|
81452
|
+
"selection",
|
|
81453
|
+
"actors",
|
|
81454
|
+
"consumers",
|
|
81455
|
+
"secretsAuthority",
|
|
81456
|
+
"bindings"
|
|
81457
|
+
], ["expiresAt"]) || !grantIdentifier(g.id) || ids.has(g.id) || g.target !== "local" || !selection(g.selection) || !authority(g.secretsAuthority))
|
|
81458
|
+
invalid4();
|
|
81459
|
+
ids.add(g.id);
|
|
81460
|
+
if (!Array.isArray(g.actors) || !g.actors.length || g.actors.length > 256 || !g.actors.every(grantIdentifier) || new Set(g.actors).size !== g.actors.length)
|
|
81461
|
+
invalid4();
|
|
81462
|
+
if (!Array.isArray(g.consumers) || !g.consumers.length || g.consumers.length > 256)
|
|
81463
|
+
invalid4();
|
|
81464
|
+
const consumers = new Set;
|
|
81465
|
+
for (const c of g.consumers) {
|
|
81466
|
+
if (!grantRecord(c) || !keys2(c, ["stationId", "workspaceDirectory"], ["includeDescendants"]) || !grantIdentifier(c.stationId) || !grantWorkspace(c.workspaceDirectory) || c.includeDescendants !== undefined && typeof c.includeDescendants !== "boolean")
|
|
81467
|
+
invalid4();
|
|
81468
|
+
const key = JSON.stringify([
|
|
81469
|
+
c.stationId,
|
|
81470
|
+
c.workspaceDirectory,
|
|
81471
|
+
c.includeDescendants === true
|
|
81472
|
+
]);
|
|
81473
|
+
if (consumers.has(key))
|
|
81474
|
+
invalid4();
|
|
81475
|
+
consumers.add(key);
|
|
81476
|
+
}
|
|
81477
|
+
if (!grantRecord(g.bindings) || !Object.keys(g.bindings).length)
|
|
81478
|
+
invalid4();
|
|
81479
|
+
try {
|
|
81480
|
+
declaredSecretNames(Object.keys(g.bindings));
|
|
81481
|
+
} catch {
|
|
81482
|
+
invalid4();
|
|
81483
|
+
}
|
|
81484
|
+
for (const ref of Object.values(g.bindings))
|
|
81485
|
+
if (typeof ref !== "string" || ref.length > 2048 || !/^[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(ref) || ref.split("/").some((p) => !p || p === "." || p === ".."))
|
|
81486
|
+
invalid4();
|
|
81487
|
+
if (g.expiresAt !== undefined && (typeof g.expiresAt !== "string" || !Number.isFinite(Date.parse(g.expiresAt)) || new Date(g.expiresAt).toISOString() !== g.expiresAt))
|
|
81488
|
+
invalid4();
|
|
81489
|
+
}
|
|
81490
|
+
if (Buffer.byteLength(JSON.stringify(value)) > MAX_EXECUTION_GRANT_BYTES - 2048)
|
|
81491
|
+
invalid4();
|
|
81492
|
+
return structuredClone(value);
|
|
81493
|
+
}
|
|
81494
|
+
function validateExecutionGrantPolicy(value) {
|
|
81495
|
+
if (!grantRecord(value) || !keys2(value, [
|
|
81496
|
+
"schema",
|
|
81497
|
+
"profileId",
|
|
81498
|
+
"workspaceId",
|
|
81499
|
+
"revision",
|
|
81500
|
+
"previousRevision",
|
|
81501
|
+
"updatedAt",
|
|
81502
|
+
"actorId",
|
|
81503
|
+
"grants"
|
|
81504
|
+
]) || value.schema !== "hasna.skills-execution-grants.v1" || ![value.profileId, value.workspaceId, value.revision, value.actorId].every(grantIdentifier) || value.previousRevision !== null && !grantIdentifier(value.previousRevision) || typeof value.updatedAt !== "string" || !Number.isFinite(Date.parse(value.updatedAt)))
|
|
81505
|
+
invalid4();
|
|
81506
|
+
validateExecutionGrants(value.grants);
|
|
81507
|
+
return structuredClone(value);
|
|
81508
|
+
}
|
|
81509
|
+
function validateExecutionGrantRequest(value) {
|
|
81510
|
+
if (!grantRecord(value) || !keys2(value, ["selection", "consumer"]) || !grantRecord(value.selection) || !keys2(value.selection, [
|
|
81511
|
+
"authority",
|
|
81512
|
+
"workspaceId",
|
|
81513
|
+
"profileId",
|
|
81514
|
+
"profileRevision",
|
|
81515
|
+
"slug",
|
|
81516
|
+
"version",
|
|
81517
|
+
"bundleDigest"
|
|
81518
|
+
]) || !grantRecord(value.consumer) || !keys2(value.consumer, ["stationId", "workspaceDirectory"]))
|
|
81519
|
+
invalid4();
|
|
81520
|
+
const { selection: s, consumer: c } = value;
|
|
81521
|
+
if (!selection({
|
|
81522
|
+
slug: s.slug,
|
|
81523
|
+
version: s.version,
|
|
81524
|
+
bundleDigest: s.bundleDigest
|
|
81525
|
+
}) || !authority(s.authority) || ![s.workspaceId, s.profileId, s.profileRevision, c.stationId].every(grantIdentifier) || !grantWorkspace(c.workspaceDirectory))
|
|
81526
|
+
invalid4();
|
|
81527
|
+
return structuredClone(value);
|
|
81528
|
+
}
|
|
81529
|
+
var MAX_EXECUTION_GRANTS = 256, MAX_EXECUTION_GRANT_BYTES;
|
|
81530
|
+
var init_execution_grants = __esm(() => {
|
|
81531
|
+
init_execution_secrets();
|
|
81532
|
+
init_skill_version();
|
|
81533
|
+
MAX_EXECUTION_GRANT_BYTES = 2 * 1024 * 1024;
|
|
81412
81534
|
});
|
|
81413
|
-
|
|
81414
|
-
|
|
81415
|
-
import {
|
|
81416
|
-
|
|
81417
|
-
|
|
81535
|
+
|
|
81536
|
+
// src/lib/execution-grant-client.ts
|
|
81537
|
+
import { isDeepStrictEqual as isDeepStrictEqual2 } from "util";
|
|
81538
|
+
function id(value) {
|
|
81539
|
+
if (!grantIdentifier(value))
|
|
81540
|
+
throw new Error("Invalid execution grant profile or revision identifier.");
|
|
81541
|
+
return encodeURIComponent(value);
|
|
81542
|
+
}
|
|
81543
|
+
async function request(path, init = {}, authority2) {
|
|
81544
|
+
try {
|
|
81545
|
+
const connection = await resolveSkillsConnection();
|
|
81546
|
+
if (!connection)
|
|
81547
|
+
throw new Error;
|
|
81548
|
+
const configured = skillsApiRequestUrl(connection.apiOrigin, "/api/v1/").replace(/\/+$/, "");
|
|
81549
|
+
if (authority2 !== undefined && authority2 !== configured)
|
|
81550
|
+
throw new Error;
|
|
81551
|
+
const response = await fetch(skillsApiRequestUrl(connection.apiOrigin, `/api/v1${path}`), {
|
|
81552
|
+
...init,
|
|
81553
|
+
redirect: "error",
|
|
81554
|
+
credentials: "omit",
|
|
81555
|
+
signal: AbortSignal.timeout(15000),
|
|
81556
|
+
headers: {
|
|
81557
|
+
"Content-Type": "application/json",
|
|
81558
|
+
"User-Agent": "hasna-skills",
|
|
81559
|
+
Authorization: `Bearer ${connection.apiKey}`,
|
|
81560
|
+
...init.headers
|
|
81561
|
+
}
|
|
81562
|
+
});
|
|
81563
|
+
if (!response.ok) {
|
|
81564
|
+
response.body?.cancel().catch(() => {});
|
|
81565
|
+
throw new SkillSelectionError("EXECUTION_GRANT_UNAVAILABLE", `Skills execution grant request failed (HTTP ${response.status}); no fallback was attempted.`);
|
|
81566
|
+
}
|
|
81567
|
+
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(await readBoundedResponse(response, MAX_EXECUTION_GRANT_BYTES)));
|
|
81568
|
+
} catch (error61) {
|
|
81569
|
+
if (error61 instanceof SkillSelectionError)
|
|
81570
|
+
throw error61;
|
|
81571
|
+
throw new SkillSelectionError("EXECUTION_GRANT_UNAVAILABLE", "The configured Skills execution grant service could not be reached or returned an invalid response; no fallback was attempted.");
|
|
81572
|
+
}
|
|
81573
|
+
}
|
|
81574
|
+
async function readExecutionGrantPolicy(profileId, revision) {
|
|
81575
|
+
const policy = validateExecutionGrantPolicy(await request(`/execution-grants/${id(profileId)}${revision === undefined ? "" : `/versions/${id(revision)}`}`));
|
|
81576
|
+
if (policy.profileId !== profileId || revision !== undefined && policy.revision !== revision)
|
|
81577
|
+
throw new Error("Execution grant policy response scope mismatch.");
|
|
81578
|
+
return policy;
|
|
81579
|
+
}
|
|
81580
|
+
async function saveExecutionGrantPolicy(profileId, grants, revision) {
|
|
81581
|
+
const snapshot = validateExecutionGrants(grants);
|
|
81582
|
+
if (revision !== undefined)
|
|
81583
|
+
id(revision);
|
|
81584
|
+
const policy = validateExecutionGrantPolicy(await request(`/execution-grants/${id(profileId)}`, {
|
|
81585
|
+
method: "PUT",
|
|
81586
|
+
headers: revision === undefined ? { "If-None-Match": "*" } : { "If-Match": `"${revision}"` },
|
|
81587
|
+
body: JSON.stringify({ grants: snapshot })
|
|
81588
|
+
}));
|
|
81589
|
+
if (policy.profileId !== profileId || policy.previousRevision !== (revision ?? null) || !isDeepStrictEqual2(policy.grants, snapshot)) {
|
|
81590
|
+
throw new Error("The API did not preserve the reviewed execution grant policy; read it before retrying.");
|
|
81591
|
+
}
|
|
81592
|
+
return policy;
|
|
81593
|
+
}
|
|
81594
|
+
async function resolveExecutionGrant(input2) {
|
|
81595
|
+
const snapshot = validateExecutionGrantRequest(input2);
|
|
81596
|
+
const value = await request(`/execution-grants/${id(snapshot.selection.profileId)}/resolve`, { method: "POST", body: JSON.stringify(snapshot) }, snapshot.selection.authority);
|
|
81597
|
+
if (!grantRecord(value) || Object.keys(value).length !== 3 || !grantIdentifier(value.policyRevision) || !grantIdentifier(value.grantId) || !grantRecord(value.bindings)) {
|
|
81598
|
+
throw new SkillSelectionError("INVALID_EXECUTION_GRANT", "The Skills API returned an invalid execution grant.");
|
|
81599
|
+
}
|
|
81600
|
+
if (!isDeepStrictEqual2(value.bindings.selection, snapshot.selection) || !isDeepStrictEqual2(value.bindings.consumer, snapshot.consumer)) {
|
|
81601
|
+
throw new SkillSelectionError("EXECUTION_GRANT_SCOPE_MISMATCH", "The Skills API returned a grant for a different selection or consumer.");
|
|
81602
|
+
}
|
|
81603
|
+
return value;
|
|
81604
|
+
}
|
|
81605
|
+
var init_execution_grant_client = __esm(() => {
|
|
81606
|
+
init_fleet_credentials();
|
|
81607
|
+
init_remote_files();
|
|
81608
|
+
init_selection_cache();
|
|
81609
|
+
init_execution_grants();
|
|
81610
|
+
});
|
|
81611
|
+
|
|
81612
|
+
// src/lib/selected-manifest.ts
|
|
81418
81613
|
function jsonEntry(entries, path) {
|
|
81419
81614
|
const entry = entries.find((candidate) => candidate.path === path);
|
|
81420
81615
|
if (!entry)
|
|
@@ -81435,11 +81630,28 @@ function describeEntries(entries) {
|
|
|
81435
81630
|
const kind = frontmatter?.kind === "instruction" || manifest.kind === "instruction" || packageJson.skills?.kind === "instruction" ? "instruction" : "executable";
|
|
81436
81631
|
return { kind, manifest, packageJson };
|
|
81437
81632
|
}
|
|
81633
|
+
var init_selected_manifest = __esm(() => {
|
|
81634
|
+
init_skill_validation();
|
|
81635
|
+
init_selection_cache();
|
|
81636
|
+
});
|
|
81637
|
+
|
|
81638
|
+
// src/lib/selected-run.ts
|
|
81639
|
+
var exports_selected_run = {};
|
|
81640
|
+
__export(exports_selected_run, {
|
|
81641
|
+
resolveSelectedRun: () => resolveSelectedRun,
|
|
81642
|
+
prepareSelectedSecretBindings: () => prepareSelectedSecretBindings,
|
|
81643
|
+
executeSelectedLocal: () => executeSelectedLocal
|
|
81644
|
+
});
|
|
81645
|
+
import { createHash as createHash14 } from "crypto";
|
|
81646
|
+
import { spawn as spawn2 } from "child_process";
|
|
81647
|
+
import { mkdirSync as mkdirSync13, mkdtempSync as mkdtempSync4, writeFileSync as writeFileSync13, realpathSync as realpathSync7 } from "fs";
|
|
81648
|
+
import { dirname as dirname15, join as join39, resolve as resolve12 } from "path";
|
|
81649
|
+
import { tmpdir, hostname as stationHostname2 } from "os";
|
|
81438
81650
|
async function resolveSelectedRun(spec, profileId, options = {}) {
|
|
81439
81651
|
const context = await resolveSelectionContext(profileId, options);
|
|
81440
|
-
const
|
|
81441
|
-
const entries = await readSelectedEntries(
|
|
81442
|
-
return { selection, profileId: context.receipt.profile.profileId, entries, ...describeEntries(entries), cacheDir: selectionCacheRoot(options) };
|
|
81652
|
+
const selection2 = exactProfileSelection(spec, context.receipt.profile);
|
|
81653
|
+
const entries = await readSelectedEntries(selection2, context, options);
|
|
81654
|
+
return { selection: selection2, profileId: context.receipt.profile.profileId, entries, ...describeEntries(entries), cacheDir: selectionCacheRoot(options) };
|
|
81443
81655
|
}
|
|
81444
81656
|
async function prepareSelectedSecretBindings(selected, cwd2 = process.cwd()) {
|
|
81445
81657
|
const entries = await readCachedSelection(selected.selection, { cacheDir: selected.cacheDir });
|
|
@@ -81454,8 +81666,8 @@ async function prepareSelectedSecretBindings(selected, cwd2 = process.cwd()) {
|
|
|
81454
81666
|
return selectedSecretBindingsTemplate({ selection: selected.selection, profileId: selected.profileId, cwd: cwd2 }, names);
|
|
81455
81667
|
}
|
|
81456
81668
|
async function executeSelectedLocal(selected, options = {}) {
|
|
81457
|
-
const
|
|
81458
|
-
const entries = await readCachedSelection(
|
|
81669
|
+
const selection2 = structuredClone(selected.selection), profileId = selected.profileId;
|
|
81670
|
+
const entries = await readCachedSelection(selection2, { cacheDir: selected.cacheDir });
|
|
81459
81671
|
if (!entries)
|
|
81460
81672
|
throw new SkillSelectionError("CACHED_BUNDLE_MISSING", "The selected local execution bundle is not cached.");
|
|
81461
81673
|
const { kind, manifest, packageJson } = describeEntries(entries);
|
|
@@ -81499,9 +81711,12 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
81499
81711
|
const names = declaredSecretNames(runtime.env);
|
|
81500
81712
|
if (options.secretBindings !== undefined && options.env !== undefined)
|
|
81501
81713
|
throw new SkillSelectionError("INVALID_SECRET_BINDINGS", "Choose explicit vault bindings or SDK environment values, never both.");
|
|
81502
|
-
|
|
81714
|
+
let bindings = options.secretBindings === undefined ? undefined : validateSelectedSecretBindings(options.secretBindings, { selection: selection2, profileId, cwd: options.cwd ?? process.cwd() }, names);
|
|
81503
81715
|
let secretEnv = {};
|
|
81504
|
-
|
|
81716
|
+
const shared = names.length > 0 && options.secretBindings === undefined && options.env === undefined;
|
|
81717
|
+
if (shared && options.sharedExecutionGrants === false)
|
|
81718
|
+
throw new SkillSelectionError("EXECUTION_GRANT_FRESH_SELECTION_REQUIRED", "Shared secret grants require a fresh API selection; cached execution is refused.");
|
|
81719
|
+
if (!bindings && !shared)
|
|
81505
81720
|
for (const name of names) {
|
|
81506
81721
|
const value = options.env && Object.hasOwn(options.env, name) ? options.env[name] : undefined;
|
|
81507
81722
|
if (value === undefined)
|
|
@@ -81531,17 +81746,31 @@ async function executeSelectedLocal(selected, options = {}) {
|
|
|
81531
81746
|
if (version2.exitCode !== 0 || actual !== runtime.version)
|
|
81532
81747
|
throw new SkillSelectionError("LOCAL_RUNTIME_VERSION_MISMATCH", "The installed runtime version differs from the version selected by the skill.");
|
|
81533
81748
|
}
|
|
81749
|
+
let executionGrant;
|
|
81750
|
+
if (shared) {
|
|
81751
|
+
const { authority: authority2, workspaceId, profileRevision, slug: slug2, version: version2, bundleDigest } = selection2;
|
|
81752
|
+
const request2 = {
|
|
81753
|
+
selection: { authority: authority2, workspaceId, profileId, profileRevision, slug: slug2, version: version2, bundleDigest },
|
|
81754
|
+
consumer: { stationId: process.env.HASNA_STATION || stationHostname2(), workspaceDirectory: realpathSync7(options.cwd ?? process.cwd()) }
|
|
81755
|
+
};
|
|
81756
|
+
const grant = await (options.resolveExecutionGrant ?? resolveExecutionGrant)(request2);
|
|
81757
|
+
if (!grant || !grantIdentifier(grant.policyRevision) || !grantIdentifier(grant.grantId))
|
|
81758
|
+
throw new SkillSelectionError("INVALID_EXECUTION_GRANT", "The Skills API returned an invalid execution grant.");
|
|
81759
|
+
bindings = validateSelectedSecretBindings(grant.bindings, { selection: selection2, profileId, cwd: options.cwd ?? process.cwd() }, names);
|
|
81760
|
+
executionGrant = { policyRevision: grant.policyRevision, grantId: grant.grantId };
|
|
81761
|
+
}
|
|
81534
81762
|
if (bindings)
|
|
81535
81763
|
secretEnv = await resolveSelectedSecrets(bindings, options.createSecretsClient);
|
|
81536
81764
|
const result2 = await subprocess([executable, ...runtimeName === "bun" ? ["--no-env-file"] : [], join39(runDirectory, declaredEntry), ...args], runDirectory, { ...env3, ...secretEnv }, input2, timeoutMs);
|
|
81537
81765
|
result2.stdout = redactExecutionSecrets(result2.stdout, secretEnv);
|
|
81538
81766
|
result2.stderr = redactExecutionSecrets(result2.stderr, secretEnv);
|
|
81539
81767
|
const receipt = {
|
|
81540
|
-
selection,
|
|
81768
|
+
selection: selection2,
|
|
81541
81769
|
target: "local",
|
|
81542
81770
|
runtime: runtimeName,
|
|
81543
81771
|
inputDigest: `sha256:${createHash14("sha256").update(input2).digest("hex")}`,
|
|
81544
81772
|
runDirectory,
|
|
81773
|
+
...executionGrant ? { executionGrant } : {},
|
|
81545
81774
|
...bindings ? { secretBinding: { schema: bindings.schema, selection: bindings.selection, consumer: bindings.consumer, secretsAuthority: bindings.secretsAuthority, bindings: bindings.bindings } } : {},
|
|
81546
81775
|
...result2
|
|
81547
81776
|
};
|
|
@@ -81595,9 +81824,11 @@ async function subprocess(command, cwd2, env3, input2, timeoutMs) {
|
|
|
81595
81824
|
});
|
|
81596
81825
|
}
|
|
81597
81826
|
var init_selected_run = __esm(() => {
|
|
81827
|
+
init_execution_grant_client();
|
|
81828
|
+
init_execution_grants();
|
|
81598
81829
|
init_selection_resolver();
|
|
81599
81830
|
init_selection_cache();
|
|
81600
|
-
|
|
81831
|
+
init_selected_manifest();
|
|
81601
81832
|
init_execution_secrets();
|
|
81602
81833
|
});
|
|
81603
81834
|
|
|
@@ -81802,13 +82033,13 @@ var init_util2 = __esm(() => {
|
|
|
81802
82033
|
});
|
|
81803
82034
|
};
|
|
81804
82035
|
util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object6) => {
|
|
81805
|
-
const
|
|
82036
|
+
const keys3 = [];
|
|
81806
82037
|
for (const key in object6) {
|
|
81807
82038
|
if (Object.prototype.hasOwnProperty.call(object6, key)) {
|
|
81808
|
-
|
|
82039
|
+
keys3.push(key);
|
|
81809
82040
|
}
|
|
81810
82041
|
}
|
|
81811
|
-
return
|
|
82042
|
+
return keys3;
|
|
81812
82043
|
};
|
|
81813
82044
|
util2.find = (arr, checker) => {
|
|
81814
82045
|
for (const item of arr) {
|
|
@@ -84129,8 +84360,8 @@ var init_types = __esm(() => {
|
|
|
84129
84360
|
if (this._cached !== null)
|
|
84130
84361
|
return this._cached;
|
|
84131
84362
|
const shape = this._def.shape();
|
|
84132
|
-
const
|
|
84133
|
-
this._cached = { shape, keys:
|
|
84363
|
+
const keys3 = util.objectKeys(shape);
|
|
84364
|
+
this._cached = { shape, keys: keys3 };
|
|
84134
84365
|
return this._cached;
|
|
84135
84366
|
}
|
|
84136
84367
|
_parse(input2) {
|
|
@@ -85759,18 +85990,18 @@ import { existsSync as existsSync27, mkdirSync as mkdirSync14, readFileSync as r
|
|
|
85759
85990
|
import { extname, join as join40, relative as relative6 } from "path";
|
|
85760
85991
|
function createSkillRun(params, targetDir = process.cwd()) {
|
|
85761
85992
|
const now3 = new Date;
|
|
85762
|
-
const
|
|
85993
|
+
const id2 = createRunId(now3);
|
|
85763
85994
|
const day = now3.toISOString().slice(0, 10);
|
|
85764
85995
|
const skillName = normalizeSkillName(params.skill);
|
|
85765
85996
|
const root = getProjectStateDir(targetDir);
|
|
85766
|
-
const runDir = join40(root, "runs", day,
|
|
85997
|
+
const runDir = join40(root, "runs", day, id2);
|
|
85767
85998
|
const logsDir = join40(runDir, "logs");
|
|
85768
|
-
const exportDir = join40(root, "exports", skillName,
|
|
85999
|
+
const exportDir = join40(root, "exports", skillName, id2);
|
|
85769
86000
|
mkdirSync14(logsDir, { recursive: true });
|
|
85770
86001
|
mkdirSync14(exportDir, { recursive: true });
|
|
85771
86002
|
mkdirSync14(join40(root, "tmp"), { recursive: true });
|
|
85772
86003
|
const record7 = {
|
|
85773
|
-
id,
|
|
86004
|
+
id: id2,
|
|
85774
86005
|
skill: skillName,
|
|
85775
86006
|
status: params.status ?? "running",
|
|
85776
86007
|
...params.prompt ? { prompt: params.prompt } : {},
|
|
@@ -85960,14 +86191,14 @@ var init_run_state = __esm(() => {
|
|
|
85960
86191
|
});
|
|
85961
86192
|
|
|
85962
86193
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/types.js
|
|
85963
|
-
function assertCompleteRequestPrompt(
|
|
85964
|
-
if (
|
|
85965
|
-
throw new TypeError(`Expected CompleteRequestPrompt, but got ${
|
|
86194
|
+
function assertCompleteRequestPrompt(request2) {
|
|
86195
|
+
if (request2.params.ref.type !== "ref/prompt") {
|
|
86196
|
+
throw new TypeError(`Expected CompleteRequestPrompt, but got ${request2.params.ref.type}`);
|
|
85966
86197
|
}
|
|
85967
86198
|
}
|
|
85968
|
-
function assertCompleteRequestResourceTemplate(
|
|
85969
|
-
if (
|
|
85970
|
-
throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${
|
|
86199
|
+
function assertCompleteRequestResourceTemplate(request2) {
|
|
86200
|
+
if (request2.params.ref.type !== "ref/resource") {
|
|
86201
|
+
throw new TypeError(`Expected CompleteRequestResourceTemplate, but got ${request2.params.ref.type}`);
|
|
85971
86202
|
}
|
|
85972
86203
|
}
|
|
85973
86204
|
var LATEST_PROTOCOL_VERSION = "2025-11-25", SUPPORTED_PROTOCOL_VERSIONS, RELATED_TASK_META_KEY = "io.modelcontextprotocol/related-task", JSONRPC_VERSION = "2.0", AssertObjectSchema, ProgressTokenSchema, CursorSchema, TaskCreationParamsSchema, TaskMetadataSchema, RelatedTaskMetadataSchema, RequestMetaSchema, BaseRequestParamsSchema, TaskAugmentedRequestParamsSchema, isTaskAugmentedRequestParams = (value) => TaskAugmentedRequestParamsSchema.safeParse(value).success, RequestSchema, NotificationsParamsSchema, NotificationSchema, ResultSchema, RequestIdSchema, JSONRPCRequestSchema, isJSONRPCRequest = (value) => JSONRPCRequestSchema.safeParse(value).success, JSONRPCNotificationSchema, isJSONRPCNotification = (value) => JSONRPCNotificationSchema.safeParse(value).success, JSONRPCResultResponseSchema, isJSONRPCResultResponse = (value) => JSONRPCResultResponseSchema.safeParse(value).success, ErrorCode, JSONRPCErrorResponseSchema, isJSONRPCErrorResponse = (value) => JSONRPCErrorResponseSchema.safeParse(value).success, JSONRPCMessageSchema, JSONRPCResponseSchema, EmptyResultSchema, CancelledNotificationParamsSchema, CancelledNotificationSchema, IconSchema, IconsSchema, BaseMetadataSchema, ImplementationSchema, FormElicitationCapabilitySchema, ElicitationCapabilitySchema, ClientTasksCapabilitySchema, ServerTasksCapabilitySchema, ClientCapabilitiesSchema, InitializeRequestParamsSchema, InitializeRequestSchema, ServerCapabilitiesSchema, InitializeResultSchema, InitializedNotificationSchema, PingRequestSchema, ProgressSchema, ProgressNotificationParamsSchema, ProgressNotificationSchema, PaginatedRequestParamsSchema, PaginatedRequestSchema, PaginatedResultSchema, TaskStatusSchema, TaskSchema, CreateTaskResultSchema, TaskStatusNotificationParamsSchema, TaskStatusNotificationSchema, GetTaskRequestSchema, GetTaskResultSchema, GetTaskPayloadRequestSchema, GetTaskPayloadResultSchema, ListTasksRequestSchema, ListTasksResultSchema, CancelTaskRequestSchema, CancelTaskResultSchema, ResourceContentsSchema, TextResourceContentsSchema, Base64Schema, BlobResourceContentsSchema, RoleSchema, AnnotationsSchema, ResourceSchema, ResourceTemplateSchema, ListResourcesRequestSchema, ListResourcesResultSchema, ListResourceTemplatesRequestSchema, ListResourceTemplatesResultSchema, ResourceRequestParamsSchema, ReadResourceRequestParamsSchema, ReadResourceRequestSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, SubscribeRequestParamsSchema, SubscribeRequestSchema, UnsubscribeRequestParamsSchema, UnsubscribeRequestSchema, ResourceUpdatedNotificationParamsSchema, ResourceUpdatedNotificationSchema, PromptArgumentSchema, PromptSchema, ListPromptsRequestSchema, ListPromptsResultSchema, GetPromptRequestParamsSchema, GetPromptRequestSchema, TextContentSchema, ImageContentSchema, AudioContentSchema, ToolUseContentSchema, EmbeddedResourceSchema, ResourceLinkSchema, ContentBlockSchema, PromptMessageSchema, GetPromptResultSchema, PromptListChangedNotificationSchema, ToolAnnotationsSchema, ToolExecutionSchema, ToolSchema, ListToolsRequestSchema, ListToolsResultSchema, CallToolResultSchema, CompatibilityCallToolResultSchema, CallToolRequestParamsSchema, CallToolRequestSchema, ToolListChangedNotificationSchema, ListChangedOptionsBaseSchema, LoggingLevelSchema, SetLevelRequestParamsSchema, SetLevelRequestSchema, LoggingMessageNotificationParamsSchema, LoggingMessageNotificationSchema, ModelHintSchema, ModelPreferencesSchema, ToolChoiceSchema, ToolResultContentSchema, SamplingContentSchema, SamplingMessageContentBlockSchema, SamplingMessageSchema, CreateMessageRequestParamsSchema, CreateMessageRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema, UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema, LegacyTitledEnumSchemaSchema, SingleSelectEnumSchemaSchema, UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema, MultiSelectEnumSchemaSchema, EnumSchemaSchema, PrimitiveSchemaDefinitionSchema, ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema, ElicitRequestParamsSchema, ElicitRequestSchema, ElicitationCompleteNotificationParamsSchema, ElicitationCompleteNotificationSchema, ElicitResultSchema, ResourceTemplateReferenceSchema, PromptReferenceSchema, CompleteRequestParamsSchema, CompleteRequestSchema, CompleteResultSchema, RootSchema, ListRootsRequestSchema, ListRootsResultSchema, RootsListChangedNotificationSchema, ClientRequestSchema, ClientNotificationSchema, ClientResultSchema, ServerRequestSchema, ServerNotificationSchema, ServerResultSchema, McpError, UrlElicitationRequiredError;
|
|
@@ -87881,7 +88112,7 @@ function parseMapDef(def, refs) {
|
|
|
87881
88112
|
if (refs.mapStrategy === "record") {
|
|
87882
88113
|
return parseRecordDef(def, refs);
|
|
87883
88114
|
}
|
|
87884
|
-
const
|
|
88115
|
+
const keys3 = parseDef(def.keyType._def, {
|
|
87885
88116
|
...refs,
|
|
87886
88117
|
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
87887
88118
|
}) || parseAnyDef(refs);
|
|
@@ -87894,7 +88125,7 @@ function parseMapDef(def, refs) {
|
|
|
87894
88125
|
maxItems: 125,
|
|
87895
88126
|
items: {
|
|
87896
88127
|
type: "array",
|
|
87897
|
-
items: [
|
|
88128
|
+
items: [keys3, values2],
|
|
87898
88129
|
minItems: 2,
|
|
87899
88130
|
maxItems: 2
|
|
87900
88131
|
}
|
|
@@ -88649,8 +88880,8 @@ class Protocol {
|
|
|
88649
88880
|
this._taskStore = _options?.taskStore;
|
|
88650
88881
|
this._taskMessageQueue = _options?.taskMessageQueue;
|
|
88651
88882
|
if (this._taskStore) {
|
|
88652
|
-
this.setRequestHandler(GetTaskRequestSchema, async (
|
|
88653
|
-
const task = await this._taskStore.getTask(
|
|
88883
|
+
this.setRequestHandler(GetTaskRequestSchema, async (request2, extra) => {
|
|
88884
|
+
const task = await this._taskStore.getTask(request2.params.taskId, extra.sessionId);
|
|
88654
88885
|
if (!task) {
|
|
88655
88886
|
throw new McpError(ErrorCode.InvalidParams, "Failed to retrieve task: Task not found");
|
|
88656
88887
|
}
|
|
@@ -88658,9 +88889,9 @@ class Protocol {
|
|
|
88658
88889
|
...task
|
|
88659
88890
|
};
|
|
88660
88891
|
});
|
|
88661
|
-
this.setRequestHandler(GetTaskPayloadRequestSchema, async (
|
|
88892
|
+
this.setRequestHandler(GetTaskPayloadRequestSchema, async (request2, extra) => {
|
|
88662
88893
|
const handleTaskResult = async () => {
|
|
88663
|
-
const taskId =
|
|
88894
|
+
const taskId = request2.params.taskId;
|
|
88664
88895
|
if (this._taskMessageQueue) {
|
|
88665
88896
|
let queuedMessage;
|
|
88666
88897
|
while (queuedMessage = await this._taskMessageQueue.dequeue(taskId, extra.sessionId)) {
|
|
@@ -88711,9 +88942,9 @@ class Protocol {
|
|
|
88711
88942
|
};
|
|
88712
88943
|
return await handleTaskResult();
|
|
88713
88944
|
});
|
|
88714
|
-
this.setRequestHandler(ListTasksRequestSchema, async (
|
|
88945
|
+
this.setRequestHandler(ListTasksRequestSchema, async (request2, extra) => {
|
|
88715
88946
|
try {
|
|
88716
|
-
const { tasks, nextCursor } = await this._taskStore.listTasks(
|
|
88947
|
+
const { tasks, nextCursor } = await this._taskStore.listTasks(request2.params?.cursor, extra.sessionId);
|
|
88717
88948
|
return {
|
|
88718
88949
|
tasks,
|
|
88719
88950
|
nextCursor,
|
|
@@ -88723,20 +88954,20 @@ class Protocol {
|
|
|
88723
88954
|
throw new McpError(ErrorCode.InvalidParams, `Failed to list tasks: ${error61 instanceof Error ? error61.message : String(error61)}`);
|
|
88724
88955
|
}
|
|
88725
88956
|
});
|
|
88726
|
-
this.setRequestHandler(CancelTaskRequestSchema, async (
|
|
88957
|
+
this.setRequestHandler(CancelTaskRequestSchema, async (request2, extra) => {
|
|
88727
88958
|
try {
|
|
88728
|
-
const task = await this._taskStore.getTask(
|
|
88959
|
+
const task = await this._taskStore.getTask(request2.params.taskId, extra.sessionId);
|
|
88729
88960
|
if (!task) {
|
|
88730
|
-
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${
|
|
88961
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found: ${request2.params.taskId}`);
|
|
88731
88962
|
}
|
|
88732
88963
|
if (isTerminal(task.status)) {
|
|
88733
88964
|
throw new McpError(ErrorCode.InvalidParams, `Cannot cancel task in terminal status: ${task.status}`);
|
|
88734
88965
|
}
|
|
88735
|
-
await this._taskStore.updateTaskStatus(
|
|
88736
|
-
this._clearTaskQueue(
|
|
88737
|
-
const cancelledTask = await this._taskStore.getTask(
|
|
88966
|
+
await this._taskStore.updateTaskStatus(request2.params.taskId, "cancelled", "Client cancelled task execution.", extra.sessionId);
|
|
88967
|
+
this._clearTaskQueue(request2.params.taskId);
|
|
88968
|
+
const cancelledTask = await this._taskStore.getTask(request2.params.taskId, extra.sessionId);
|
|
88738
88969
|
if (!cancelledTask) {
|
|
88739
|
-
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${
|
|
88970
|
+
throw new McpError(ErrorCode.InvalidParams, `Task not found after cancellation: ${request2.params.taskId}`);
|
|
88740
88971
|
}
|
|
88741
88972
|
return {
|
|
88742
88973
|
_meta: {},
|
|
@@ -88852,14 +89083,14 @@ class Protocol {
|
|
|
88852
89083
|
}
|
|
88853
89084
|
Promise.resolve().then(() => handler(notification)).catch((error61) => this._onerror(new Error(`Uncaught error in notification handler: ${error61}`)));
|
|
88854
89085
|
}
|
|
88855
|
-
_onrequest(
|
|
88856
|
-
const handler = this._requestHandlers.get(
|
|
89086
|
+
_onrequest(request2, extra) {
|
|
89087
|
+
const handler = this._requestHandlers.get(request2.method) ?? this.fallbackRequestHandler;
|
|
88857
89088
|
const capturedTransport = this._transport;
|
|
88858
|
-
const relatedTaskId =
|
|
89089
|
+
const relatedTaskId = request2.params?._meta?.[RELATED_TASK_META_KEY]?.taskId;
|
|
88859
89090
|
if (handler === undefined) {
|
|
88860
89091
|
const errorResponse = {
|
|
88861
89092
|
jsonrpc: "2.0",
|
|
88862
|
-
id:
|
|
89093
|
+
id: request2.id,
|
|
88863
89094
|
error: {
|
|
88864
89095
|
code: ErrorCode.MethodNotFound,
|
|
88865
89096
|
message: "Method not found"
|
|
@@ -88877,17 +89108,17 @@ class Protocol {
|
|
|
88877
89108
|
return;
|
|
88878
89109
|
}
|
|
88879
89110
|
const abortController = new AbortController;
|
|
88880
|
-
this._requestHandlerAbortControllers.set(
|
|
88881
|
-
const taskCreationParams = isTaskAugmentedRequestParams(
|
|
88882
|
-
const taskStore = this._taskStore ? this.requestTaskStore(
|
|
89111
|
+
this._requestHandlerAbortControllers.set(request2.id, abortController);
|
|
89112
|
+
const taskCreationParams = isTaskAugmentedRequestParams(request2.params) ? request2.params.task : undefined;
|
|
89113
|
+
const taskStore = this._taskStore ? this.requestTaskStore(request2, capturedTransport?.sessionId) : undefined;
|
|
88883
89114
|
const fullExtra = {
|
|
88884
89115
|
signal: abortController.signal,
|
|
88885
89116
|
sessionId: capturedTransport?.sessionId,
|
|
88886
|
-
_meta:
|
|
89117
|
+
_meta: request2.params?._meta,
|
|
88887
89118
|
sendNotification: async (notification) => {
|
|
88888
89119
|
if (abortController.signal.aborted)
|
|
88889
89120
|
return;
|
|
88890
|
-
const notificationOptions = { relatedRequestId:
|
|
89121
|
+
const notificationOptions = { relatedRequestId: request2.id };
|
|
88891
89122
|
if (relatedTaskId) {
|
|
88892
89123
|
notificationOptions.relatedTask = { taskId: relatedTaskId };
|
|
88893
89124
|
}
|
|
@@ -88897,7 +89128,7 @@ class Protocol {
|
|
|
88897
89128
|
if (abortController.signal.aborted) {
|
|
88898
89129
|
throw new McpError(ErrorCode.ConnectionClosed, "Request was cancelled");
|
|
88899
89130
|
}
|
|
88900
|
-
const requestOptions = { ...options, relatedRequestId:
|
|
89131
|
+
const requestOptions = { ...options, relatedRequestId: request2.id };
|
|
88901
89132
|
if (relatedTaskId && !requestOptions.relatedTask) {
|
|
88902
89133
|
requestOptions.relatedTask = { taskId: relatedTaskId };
|
|
88903
89134
|
}
|
|
@@ -88908,7 +89139,7 @@ class Protocol {
|
|
|
88908
89139
|
return await this.request(r2, resultSchema, requestOptions);
|
|
88909
89140
|
},
|
|
88910
89141
|
authInfo: extra?.authInfo,
|
|
88911
|
-
requestId:
|
|
89142
|
+
requestId: request2.id,
|
|
88912
89143
|
requestInfo: extra?.requestInfo,
|
|
88913
89144
|
taskId: relatedTaskId,
|
|
88914
89145
|
taskStore,
|
|
@@ -88918,16 +89149,16 @@ class Protocol {
|
|
|
88918
89149
|
};
|
|
88919
89150
|
Promise.resolve().then(() => {
|
|
88920
89151
|
if (taskCreationParams) {
|
|
88921
|
-
this.assertTaskHandlerCapability(
|
|
89152
|
+
this.assertTaskHandlerCapability(request2.method);
|
|
88922
89153
|
}
|
|
88923
|
-
}).then(() => handler(
|
|
89154
|
+
}).then(() => handler(request2, fullExtra)).then(async (result2) => {
|
|
88924
89155
|
if (abortController.signal.aborted) {
|
|
88925
89156
|
return;
|
|
88926
89157
|
}
|
|
88927
89158
|
const response = {
|
|
88928
89159
|
result: result2,
|
|
88929
89160
|
jsonrpc: "2.0",
|
|
88930
|
-
id:
|
|
89161
|
+
id: request2.id
|
|
88931
89162
|
};
|
|
88932
89163
|
if (relatedTaskId && this._taskMessageQueue) {
|
|
88933
89164
|
await this._enqueueTaskMessage(relatedTaskId, {
|
|
@@ -88944,7 +89175,7 @@ class Protocol {
|
|
|
88944
89175
|
}
|
|
88945
89176
|
const errorResponse = {
|
|
88946
89177
|
jsonrpc: "2.0",
|
|
88947
|
-
id:
|
|
89178
|
+
id: request2.id,
|
|
88948
89179
|
error: {
|
|
88949
89180
|
code: Number.isSafeInteger(error61["code"]) ? error61["code"] : ErrorCode.InternalError,
|
|
88950
89181
|
message: error61.message ?? "Internal error",
|
|
@@ -88961,8 +89192,8 @@ class Protocol {
|
|
|
88961
89192
|
await capturedTransport?.send(errorResponse);
|
|
88962
89193
|
}
|
|
88963
89194
|
}).catch((error61) => this._onerror(new Error(`Failed to send response: ${error61}`))).finally(() => {
|
|
88964
|
-
if (this._requestHandlerAbortControllers.get(
|
|
88965
|
-
this._requestHandlerAbortControllers.delete(
|
|
89195
|
+
if (this._requestHandlerAbortControllers.get(request2.id) === abortController) {
|
|
89196
|
+
this._requestHandlerAbortControllers.delete(request2.id);
|
|
88966
89197
|
}
|
|
88967
89198
|
});
|
|
88968
89199
|
}
|
|
@@ -89036,11 +89267,11 @@ class Protocol {
|
|
|
89036
89267
|
async close() {
|
|
89037
89268
|
await this._transport?.close();
|
|
89038
89269
|
}
|
|
89039
|
-
async* requestStream(
|
|
89270
|
+
async* requestStream(request2, resultSchema, options) {
|
|
89040
89271
|
const { task } = options ?? {};
|
|
89041
89272
|
if (!task) {
|
|
89042
89273
|
try {
|
|
89043
|
-
const result2 = await this.request(
|
|
89274
|
+
const result2 = await this.request(request2, resultSchema, options);
|
|
89044
89275
|
yield { type: "result", result: result2 };
|
|
89045
89276
|
} catch (error61) {
|
|
89046
89277
|
yield {
|
|
@@ -89052,7 +89283,7 @@ class Protocol {
|
|
|
89052
89283
|
}
|
|
89053
89284
|
let taskId;
|
|
89054
89285
|
try {
|
|
89055
|
-
const createResult = await this.request(
|
|
89286
|
+
const createResult = await this.request(request2, CreateTaskResultSchema, options);
|
|
89056
89287
|
if (createResult.task) {
|
|
89057
89288
|
taskId = createResult.task.taskId;
|
|
89058
89289
|
yield { type: "taskCreated", task: createResult.task };
|
|
@@ -89095,7 +89326,7 @@ class Protocol {
|
|
|
89095
89326
|
};
|
|
89096
89327
|
}
|
|
89097
89328
|
}
|
|
89098
|
-
request(
|
|
89329
|
+
request(request2, resultSchema, options) {
|
|
89099
89330
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
89100
89331
|
return new Promise((resolve13, reject2) => {
|
|
89101
89332
|
const earlyReject = (error61) => {
|
|
@@ -89107,9 +89338,9 @@ class Protocol {
|
|
|
89107
89338
|
}
|
|
89108
89339
|
if (this._options?.enforceStrictCapabilities === true) {
|
|
89109
89340
|
try {
|
|
89110
|
-
this.assertCapabilityForMethod(
|
|
89341
|
+
this.assertCapabilityForMethod(request2.method);
|
|
89111
89342
|
if (task) {
|
|
89112
|
-
this.assertTaskCapability(
|
|
89343
|
+
this.assertTaskCapability(request2.method);
|
|
89113
89344
|
}
|
|
89114
89345
|
} catch (e2) {
|
|
89115
89346
|
earlyReject(e2);
|
|
@@ -89119,16 +89350,16 @@ class Protocol {
|
|
|
89119
89350
|
options?.signal?.throwIfAborted();
|
|
89120
89351
|
const messageId = this._requestMessageId++;
|
|
89121
89352
|
const jsonrpcRequest = {
|
|
89122
|
-
...
|
|
89353
|
+
...request2,
|
|
89123
89354
|
jsonrpc: "2.0",
|
|
89124
89355
|
id: messageId
|
|
89125
89356
|
};
|
|
89126
89357
|
if (options?.onprogress) {
|
|
89127
89358
|
this._progressHandlers.set(messageId, options.onprogress);
|
|
89128
89359
|
jsonrpcRequest.params = {
|
|
89129
|
-
...
|
|
89360
|
+
...request2.params,
|
|
89130
89361
|
_meta: {
|
|
89131
|
-
...
|
|
89362
|
+
...request2.params?._meta || {},
|
|
89132
89363
|
progressToken: messageId
|
|
89133
89364
|
}
|
|
89134
89365
|
};
|
|
@@ -89304,8 +89535,8 @@ class Protocol {
|
|
|
89304
89535
|
setRequestHandler(requestSchema, handler) {
|
|
89305
89536
|
const method2 = getMethodLiteral(requestSchema);
|
|
89306
89537
|
this.assertRequestHandlerCapability(method2);
|
|
89307
|
-
this._requestHandlers.set(method2, (
|
|
89308
|
-
const parsed = parseWithCompat(requestSchema,
|
|
89538
|
+
this._requestHandlers.set(method2, (request2, extra) => {
|
|
89539
|
+
const parsed = parseWithCompat(requestSchema, request2);
|
|
89309
89540
|
return Promise.resolve(handler(parsed, extra));
|
|
89310
89541
|
});
|
|
89311
89542
|
}
|
|
@@ -89378,19 +89609,19 @@ class Protocol {
|
|
|
89378
89609
|
}, { once: true });
|
|
89379
89610
|
});
|
|
89380
89611
|
}
|
|
89381
|
-
requestTaskStore(
|
|
89612
|
+
requestTaskStore(request2, sessionId) {
|
|
89382
89613
|
const taskStore = this._taskStore;
|
|
89383
89614
|
if (!taskStore) {
|
|
89384
89615
|
throw new Error("No task store configured");
|
|
89385
89616
|
}
|
|
89386
89617
|
return {
|
|
89387
89618
|
createTask: async (taskParams) => {
|
|
89388
|
-
if (!
|
|
89619
|
+
if (!request2) {
|
|
89389
89620
|
throw new Error("No request provided");
|
|
89390
89621
|
}
|
|
89391
|
-
return await taskStore.createTask(taskParams,
|
|
89392
|
-
method:
|
|
89393
|
-
params:
|
|
89622
|
+
return await taskStore.createTask(taskParams, request2.id, {
|
|
89623
|
+
method: request2.method,
|
|
89624
|
+
params: request2.params
|
|
89394
89625
|
}, sessionId);
|
|
89395
89626
|
},
|
|
89396
89627
|
getTask: async (taskId) => {
|
|
@@ -91430,7 +91661,7 @@ var require_fast_deep_equal = __commonJS((exports, module) => {
|
|
|
91430
91661
|
if (a && b && typeof a == "object" && typeof b == "object") {
|
|
91431
91662
|
if (a.constructor !== b.constructor)
|
|
91432
91663
|
return false;
|
|
91433
|
-
var length, i,
|
|
91664
|
+
var length, i, keys3;
|
|
91434
91665
|
if (Array.isArray(a)) {
|
|
91435
91666
|
length = a.length;
|
|
91436
91667
|
if (length != b.length)
|
|
@@ -91446,15 +91677,15 @@ var require_fast_deep_equal = __commonJS((exports, module) => {
|
|
|
91446
91677
|
return a.valueOf() === b.valueOf();
|
|
91447
91678
|
if (a.toString !== Object.prototype.toString)
|
|
91448
91679
|
return a.toString() === b.toString();
|
|
91449
|
-
|
|
91450
|
-
length =
|
|
91680
|
+
keys3 = Object.keys(a);
|
|
91681
|
+
length = keys3.length;
|
|
91451
91682
|
if (length !== Object.keys(b).length)
|
|
91452
91683
|
return false;
|
|
91453
91684
|
for (i = length;i-- !== 0; )
|
|
91454
|
-
if (!Object.prototype.hasOwnProperty.call(b,
|
|
91685
|
+
if (!Object.prototype.hasOwnProperty.call(b, keys3[i]))
|
|
91455
91686
|
return false;
|
|
91456
91687
|
for (i = length;i-- !== 0; ) {
|
|
91457
|
-
var key =
|
|
91688
|
+
var key = keys3[i];
|
|
91458
91689
|
if (!equal(a[key], b[key]))
|
|
91459
91690
|
return false;
|
|
91460
91691
|
}
|
|
@@ -91617,10 +91848,10 @@ var require_resolve = __commonJS((exports) => {
|
|
|
91617
91848
|
}
|
|
91618
91849
|
return count;
|
|
91619
91850
|
}
|
|
91620
|
-
function getFullPath(resolver,
|
|
91851
|
+
function getFullPath(resolver, id2 = "", normalize3) {
|
|
91621
91852
|
if (normalize3 !== false)
|
|
91622
|
-
|
|
91623
|
-
const p = resolver.parse(
|
|
91853
|
+
id2 = normalizeId(id2);
|
|
91854
|
+
const p = resolver.parse(id2);
|
|
91624
91855
|
return _getFullPath(resolver, p);
|
|
91625
91856
|
}
|
|
91626
91857
|
exports.getFullPath = getFullPath;
|
|
@@ -91630,13 +91861,13 @@ var require_resolve = __commonJS((exports) => {
|
|
|
91630
91861
|
}
|
|
91631
91862
|
exports._getFullPath = _getFullPath;
|
|
91632
91863
|
var TRAILING_SLASH_HASH = /#\/?$/;
|
|
91633
|
-
function normalizeId(
|
|
91634
|
-
return
|
|
91864
|
+
function normalizeId(id2) {
|
|
91865
|
+
return id2 ? id2.replace(TRAILING_SLASH_HASH, "") : "";
|
|
91635
91866
|
}
|
|
91636
91867
|
exports.normalizeId = normalizeId;
|
|
91637
|
-
function resolveUrl(resolver, baseId,
|
|
91638
|
-
|
|
91639
|
-
return resolver.resolve(baseId,
|
|
91868
|
+
function resolveUrl(resolver, baseId, id2) {
|
|
91869
|
+
id2 = normalizeId(id2);
|
|
91870
|
+
return resolver.resolve(baseId, id2);
|
|
91640
91871
|
}
|
|
91641
91872
|
exports.resolveUrl = resolveUrl;
|
|
91642
91873
|
var ANCHOR = /^[a-z_][-a-z0-9._]*$/i;
|
|
@@ -92396,8 +92627,8 @@ var require_compile = __commonJS((exports) => {
|
|
|
92396
92627
|
if (Object.keys(root.schema).length > 0 && refPath === baseId) {
|
|
92397
92628
|
return getJsonPointer.call(this, p, root);
|
|
92398
92629
|
}
|
|
92399
|
-
const
|
|
92400
|
-
const schOrRef = this.refs[
|
|
92630
|
+
const id2 = (0, resolve_1.normalizeId)(refPath);
|
|
92631
|
+
const schOrRef = this.refs[id2] || this.schemas[id2];
|
|
92401
92632
|
if (typeof schOrRef == "string") {
|
|
92402
92633
|
const sch = resolveSchema.call(this, root, schOrRef);
|
|
92403
92634
|
if (typeof (sch === null || sch === undefined ? undefined : sch.schema) !== "object")
|
|
@@ -92408,7 +92639,7 @@ var require_compile = __commonJS((exports) => {
|
|
|
92408
92639
|
return;
|
|
92409
92640
|
if (!schOrRef.validate)
|
|
92410
92641
|
compileSchema.call(this, schOrRef);
|
|
92411
|
-
if (
|
|
92642
|
+
if (id2 === (0, resolve_1.normalizeId)(ref)) {
|
|
92412
92643
|
const { schema } = schOrRef;
|
|
92413
92644
|
const { schemaId } = this.opts;
|
|
92414
92645
|
const schId = schema[schemaId];
|
|
@@ -93314,12 +93545,12 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
93314
93545
|
component.scheme = decodeValidScheme(component.scheme);
|
|
93315
93546
|
uriTokens.push(component.scheme, ":");
|
|
93316
93547
|
}
|
|
93317
|
-
const
|
|
93318
|
-
if (
|
|
93548
|
+
const authority2 = recomposeAuthority(component);
|
|
93549
|
+
if (authority2 !== undefined) {
|
|
93319
93550
|
if (options.reference !== "suffix") {
|
|
93320
93551
|
uriTokens.push("//");
|
|
93321
93552
|
}
|
|
93322
|
-
uriTokens.push(
|
|
93553
|
+
uriTokens.push(authority2);
|
|
93323
93554
|
if (component.path && component.path[0] !== "/") {
|
|
93324
93555
|
uriTokens.push("/");
|
|
93325
93556
|
}
|
|
@@ -93332,7 +93563,7 @@ var require_fast_uri = __commonJS((exports, module) => {
|
|
|
93332
93563
|
if (pathNoScheme) {
|
|
93333
93564
|
s = serializePathEncoding(s, true);
|
|
93334
93565
|
}
|
|
93335
|
-
if (
|
|
93566
|
+
if (authority2 === undefined && s[0] === "/" && s[1] === "/") {
|
|
93336
93567
|
s = "/%2F" + s.slice(2);
|
|
93337
93568
|
}
|
|
93338
93569
|
uriTokens.push(s);
|
|
@@ -93802,15 +94033,15 @@ var require_core = __commonJS((exports) => {
|
|
|
93802
94033
|
this.addSchema(sch, undefined, _meta, _validateSchema);
|
|
93803
94034
|
return this;
|
|
93804
94035
|
}
|
|
93805
|
-
let
|
|
94036
|
+
let id2;
|
|
93806
94037
|
if (typeof schema === "object") {
|
|
93807
94038
|
const { schemaId } = this.opts;
|
|
93808
|
-
|
|
93809
|
-
if (
|
|
94039
|
+
id2 = schema[schemaId];
|
|
94040
|
+
if (id2 !== undefined && typeof id2 != "string") {
|
|
93810
94041
|
throw new Error(`schema ${schemaId} must be string`);
|
|
93811
94042
|
}
|
|
93812
94043
|
}
|
|
93813
|
-
key = (0, resolve_1.normalizeId)(key ||
|
|
94044
|
+
key = (0, resolve_1.normalizeId)(key || id2);
|
|
93814
94045
|
this._checkUnique(key);
|
|
93815
94046
|
this.schemas[key] = this._addSchema(schema, _meta, key, _validateSchema, true);
|
|
93816
94047
|
return this;
|
|
@@ -93880,11 +94111,11 @@ var require_core = __commonJS((exports) => {
|
|
|
93880
94111
|
case "object": {
|
|
93881
94112
|
const cacheKey = schemaKeyRef;
|
|
93882
94113
|
this._cache.delete(cacheKey);
|
|
93883
|
-
let
|
|
93884
|
-
if (
|
|
93885
|
-
|
|
93886
|
-
delete this.schemas[
|
|
93887
|
-
delete this.refs[
|
|
94114
|
+
let id2 = schemaKeyRef[this.opts.schemaId];
|
|
94115
|
+
if (id2) {
|
|
94116
|
+
id2 = (0, resolve_1.normalizeId)(id2);
|
|
94117
|
+
delete this.schemas[id2];
|
|
94118
|
+
delete this.refs[id2];
|
|
93888
94119
|
}
|
|
93889
94120
|
return this;
|
|
93890
94121
|
}
|
|
@@ -93988,10 +94219,10 @@ var require_core = __commonJS((exports) => {
|
|
|
93988
94219
|
}
|
|
93989
94220
|
}
|
|
93990
94221
|
_addSchema(schema, meta3, baseId, validateSchema = this.opts.validateSchema, addSchema = this.opts.addUsedSchema) {
|
|
93991
|
-
let
|
|
94222
|
+
let id2;
|
|
93992
94223
|
const { schemaId } = this.opts;
|
|
93993
94224
|
if (typeof schema == "object") {
|
|
93994
|
-
|
|
94225
|
+
id2 = schema[schemaId];
|
|
93995
94226
|
} else {
|
|
93996
94227
|
if (this.opts.jtd)
|
|
93997
94228
|
throw new Error("schema must be object");
|
|
@@ -94001,7 +94232,7 @@ var require_core = __commonJS((exports) => {
|
|
|
94001
94232
|
let sch = this._cache.get(schema);
|
|
94002
94233
|
if (sch !== undefined)
|
|
94003
94234
|
return sch;
|
|
94004
|
-
baseId = (0, resolve_1.normalizeId)(
|
|
94235
|
+
baseId = (0, resolve_1.normalizeId)(id2 || baseId);
|
|
94005
94236
|
const localRefs = resolve_1.getSchemaRefs.call(this, schema, baseId);
|
|
94006
94237
|
sch = new compile_1.SchemaEnv({ schema, schemaId, meta: meta3, baseId, localRefs });
|
|
94007
94238
|
this._cache.set(sch.schema, sch);
|
|
@@ -94014,9 +94245,9 @@ var require_core = __commonJS((exports) => {
|
|
|
94014
94245
|
this.validateSchema(schema, true);
|
|
94015
94246
|
return sch;
|
|
94016
94247
|
}
|
|
94017
|
-
_checkUnique(
|
|
94018
|
-
if (this.schemas[
|
|
94019
|
-
throw new Error(`schema with key or id "${
|
|
94248
|
+
_checkUnique(id2) {
|
|
94249
|
+
if (this.schemas[id2] || this.refs[id2]) {
|
|
94250
|
+
throw new Error(`schema with key or id "${id2}" already exists`);
|
|
94020
94251
|
}
|
|
94021
94252
|
}
|
|
94022
94253
|
_compileSchemaEnv(sch) {
|
|
@@ -94363,8 +94594,8 @@ var require_multipleOf = __commonJS((exports) => {
|
|
|
94363
94594
|
const { gen, data, schemaCode, it } = cxt;
|
|
94364
94595
|
const prec = it.opts.multipleOfPrecision;
|
|
94365
94596
|
const res = gen.let("res");
|
|
94366
|
-
const
|
|
94367
|
-
cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${
|
|
94597
|
+
const invalid5 = prec ? (0, codegen_1._)`Math.abs(Math.round(${res}) - ${res}) > 1e-${prec}` : (0, codegen_1._)`${res} !== parseInt(${res})`;
|
|
94598
|
+
cxt.fail$data((0, codegen_1._)`(${schemaCode} === 0 || (${res} = ${data}/${schemaCode}, ${invalid5}))`);
|
|
94368
94599
|
}
|
|
94369
94600
|
};
|
|
94370
94601
|
exports.default = def;
|
|
@@ -96404,8 +96635,8 @@ class ExperimentalServerTasks {
|
|
|
96404
96635
|
constructor(_server) {
|
|
96405
96636
|
this._server = _server;
|
|
96406
96637
|
}
|
|
96407
|
-
requestStream(
|
|
96408
|
-
return this._server.requestStream(
|
|
96638
|
+
requestStream(request2, resultSchema, options) {
|
|
96639
|
+
return this._server.requestStream(request2, resultSchema, options);
|
|
96409
96640
|
}
|
|
96410
96641
|
createMessageStream(params, options) {
|
|
96411
96642
|
const clientCapabilities = this._server.getClientCapabilities();
|
|
@@ -96430,7 +96661,7 @@ class ExperimentalServerTasks {
|
|
|
96430
96661
|
if (hasPreviousToolUse) {
|
|
96431
96662
|
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
96432
96663
|
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
96433
|
-
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((
|
|
96664
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id2) => toolResultIds.has(id2))) {
|
|
96434
96665
|
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
96435
96666
|
}
|
|
96436
96667
|
}
|
|
@@ -96536,12 +96767,12 @@ var init_server2 = __esm(() => {
|
|
|
96536
96767
|
this._capabilities = options?.capabilities ?? {};
|
|
96537
96768
|
this._instructions = options?.instructions;
|
|
96538
96769
|
this._jsonSchemaValidator = options?.jsonSchemaValidator ?? new AjvJsonSchemaValidator;
|
|
96539
|
-
this.setRequestHandler(InitializeRequestSchema, (
|
|
96770
|
+
this.setRequestHandler(InitializeRequestSchema, (request2) => this._oninitialize(request2));
|
|
96540
96771
|
this.setNotificationHandler(InitializedNotificationSchema, () => this.oninitialized?.());
|
|
96541
96772
|
if (this._capabilities.logging) {
|
|
96542
|
-
this.setRequestHandler(SetLevelRequestSchema, async (
|
|
96773
|
+
this.setRequestHandler(SetLevelRequestSchema, async (request2, extra) => {
|
|
96543
96774
|
const transportSessionId = extra.sessionId || extra.requestInfo?.headers["mcp-session-id"] || undefined;
|
|
96544
|
-
const { level } =
|
|
96775
|
+
const { level } = request2.params;
|
|
96545
96776
|
const parseResult = LoggingLevelSchema.safeParse(level);
|
|
96546
96777
|
if (parseResult.success) {
|
|
96547
96778
|
this._loggingLevels.set(transportSessionId, parseResult.data);
|
|
@@ -96576,14 +96807,14 @@ var init_server2 = __esm(() => {
|
|
|
96576
96807
|
}
|
|
96577
96808
|
const method2 = methodValue;
|
|
96578
96809
|
if (method2 === "tools/call") {
|
|
96579
|
-
const wrappedHandler = async (
|
|
96580
|
-
const validatedRequest = safeParse3(CallToolRequestSchema,
|
|
96810
|
+
const wrappedHandler = async (request2, extra) => {
|
|
96811
|
+
const validatedRequest = safeParse3(CallToolRequestSchema, request2);
|
|
96581
96812
|
if (!validatedRequest.success) {
|
|
96582
96813
|
const errorMessage = validatedRequest.error instanceof Error ? validatedRequest.error.message : String(validatedRequest.error);
|
|
96583
96814
|
throw new McpError(ErrorCode.InvalidParams, `Invalid tools/call request: ${errorMessage}`);
|
|
96584
96815
|
}
|
|
96585
96816
|
const { params } = validatedRequest.data;
|
|
96586
|
-
const result2 = await Promise.resolve(handler(
|
|
96817
|
+
const result2 = await Promise.resolve(handler(request2, extra));
|
|
96587
96818
|
if (params.task) {
|
|
96588
96819
|
const taskValidationResult = safeParse3(CreateTaskResultSchema, result2);
|
|
96589
96820
|
if (!taskValidationResult.success) {
|
|
@@ -96714,10 +96945,10 @@ var init_server2 = __esm(() => {
|
|
|
96714
96945
|
}
|
|
96715
96946
|
assertToolsCallTaskCapability(this._capabilities.tasks?.requests, method2, "Server");
|
|
96716
96947
|
}
|
|
96717
|
-
async _oninitialize(
|
|
96718
|
-
const requestedVersion =
|
|
96719
|
-
this._clientCapabilities =
|
|
96720
|
-
this._clientVersion =
|
|
96948
|
+
async _oninitialize(request2) {
|
|
96949
|
+
const requestedVersion = request2.params.protocolVersion;
|
|
96950
|
+
this._clientCapabilities = request2.params.capabilities;
|
|
96951
|
+
this._clientVersion = request2.params.clientInfo;
|
|
96721
96952
|
const protocolVersion = SUPPORTED_PROTOCOL_VERSIONS.includes(requestedVersion) ? requestedVersion : LATEST_PROTOCOL_VERSION;
|
|
96722
96953
|
return {
|
|
96723
96954
|
protocolVersion,
|
|
@@ -96762,7 +96993,7 @@ var init_server2 = __esm(() => {
|
|
|
96762
96993
|
if (hasPreviousToolUse) {
|
|
96763
96994
|
const toolUseIds = new Set(previousContent.filter((c) => c.type === "tool_use").map((c) => c.id));
|
|
96764
96995
|
const toolResultIds = new Set(lastContent.filter((c) => c.type === "tool_result").map((c) => c.toolUseId));
|
|
96765
|
-
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((
|
|
96996
|
+
if (toolUseIds.size !== toolResultIds.size || ![...toolUseIds].every((id2) => toolResultIds.has(id2))) {
|
|
96766
96997
|
throw new Error("ids of tool_result blocks and tool_use blocks from previous message do not match");
|
|
96767
96998
|
}
|
|
96768
96999
|
}
|
|
@@ -97220,33 +97451,33 @@ class McpServer {
|
|
|
97220
97451
|
return toolDefinition;
|
|
97221
97452
|
})
|
|
97222
97453
|
}));
|
|
97223
|
-
this.server.setRequestHandler(CallToolRequestSchema, async (
|
|
97454
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request2, extra) => {
|
|
97224
97455
|
try {
|
|
97225
|
-
const tool = this._registeredTools[
|
|
97456
|
+
const tool = this._registeredTools[request2.params.name];
|
|
97226
97457
|
if (!tool) {
|
|
97227
|
-
throw new McpError(ErrorCode.InvalidParams, `Tool ${
|
|
97458
|
+
throw new McpError(ErrorCode.InvalidParams, `Tool ${request2.params.name} not found`);
|
|
97228
97459
|
}
|
|
97229
97460
|
if (!tool.enabled) {
|
|
97230
|
-
throw new McpError(ErrorCode.InvalidParams, `Tool ${
|
|
97461
|
+
throw new McpError(ErrorCode.InvalidParams, `Tool ${request2.params.name} disabled`);
|
|
97231
97462
|
}
|
|
97232
|
-
const isTaskRequest = !!
|
|
97463
|
+
const isTaskRequest = !!request2.params.task;
|
|
97233
97464
|
const taskSupport = tool.execution?.taskSupport;
|
|
97234
97465
|
const isTaskHandler = "createTask" in tool.handler;
|
|
97235
97466
|
if ((taskSupport === "required" || taskSupport === "optional") && !isTaskHandler) {
|
|
97236
|
-
throw new McpError(ErrorCode.InternalError, `Tool ${
|
|
97467
|
+
throw new McpError(ErrorCode.InternalError, `Tool ${request2.params.name} has taskSupport '${taskSupport}' but was not registered with registerToolTask`);
|
|
97237
97468
|
}
|
|
97238
97469
|
if (taskSupport === "required" && !isTaskRequest) {
|
|
97239
|
-
throw new McpError(ErrorCode.MethodNotFound, `Tool ${
|
|
97470
|
+
throw new McpError(ErrorCode.MethodNotFound, `Tool ${request2.params.name} requires task augmentation (taskSupport: 'required')`);
|
|
97240
97471
|
}
|
|
97241
97472
|
if (taskSupport === "optional" && !isTaskRequest && isTaskHandler) {
|
|
97242
|
-
return await this.handleAutomaticTaskPolling(tool,
|
|
97473
|
+
return await this.handleAutomaticTaskPolling(tool, request2, extra);
|
|
97243
97474
|
}
|
|
97244
|
-
const args = await this.validateToolInput(tool,
|
|
97475
|
+
const args = await this.validateToolInput(tool, request2.params.arguments, request2.params.name);
|
|
97245
97476
|
const result2 = await this.executeToolHandler(tool, args, extra);
|
|
97246
97477
|
if (isTaskRequest) {
|
|
97247
97478
|
return result2;
|
|
97248
97479
|
}
|
|
97249
|
-
await this.validateToolOutput(tool, result2,
|
|
97480
|
+
await this.validateToolOutput(tool, result2, request2.params.name);
|
|
97250
97481
|
return result2;
|
|
97251
97482
|
} catch (error61) {
|
|
97252
97483
|
if (error61 instanceof McpError) {
|
|
@@ -97329,11 +97560,11 @@ class McpServer {
|
|
|
97329
97560
|
return await Promise.resolve(typedHandler(extra));
|
|
97330
97561
|
}
|
|
97331
97562
|
}
|
|
97332
|
-
async handleAutomaticTaskPolling(tool,
|
|
97563
|
+
async handleAutomaticTaskPolling(tool, request2, extra) {
|
|
97333
97564
|
if (!extra.taskStore) {
|
|
97334
97565
|
throw new Error("No task store provided for task-capable tool.");
|
|
97335
97566
|
}
|
|
97336
|
-
const args = await this.validateToolInput(tool,
|
|
97567
|
+
const args = await this.validateToolInput(tool, request2.params.arguments, request2.params.name);
|
|
97337
97568
|
const handler = tool.handler;
|
|
97338
97569
|
const taskExtra = { ...extra, taskStore: extra.taskStore };
|
|
97339
97570
|
const createTaskResult = args ? await Promise.resolve(handler.createTask(args, taskExtra)) : await Promise.resolve(handler.createTask(taskExtra));
|
|
@@ -97358,21 +97589,21 @@ class McpServer {
|
|
|
97358
97589
|
this.server.registerCapabilities({
|
|
97359
97590
|
completions: {}
|
|
97360
97591
|
});
|
|
97361
|
-
this.server.setRequestHandler(CompleteRequestSchema, async (
|
|
97362
|
-
switch (
|
|
97592
|
+
this.server.setRequestHandler(CompleteRequestSchema, async (request2) => {
|
|
97593
|
+
switch (request2.params.ref.type) {
|
|
97363
97594
|
case "ref/prompt":
|
|
97364
|
-
assertCompleteRequestPrompt(
|
|
97365
|
-
return this.handlePromptCompletion(
|
|
97595
|
+
assertCompleteRequestPrompt(request2);
|
|
97596
|
+
return this.handlePromptCompletion(request2, request2.params.ref);
|
|
97366
97597
|
case "ref/resource":
|
|
97367
|
-
assertCompleteRequestResourceTemplate(
|
|
97368
|
-
return this.handleResourceCompletion(
|
|
97598
|
+
assertCompleteRequestResourceTemplate(request2);
|
|
97599
|
+
return this.handleResourceCompletion(request2, request2.params.ref);
|
|
97369
97600
|
default:
|
|
97370
|
-
throw new McpError(ErrorCode.InvalidParams, `Invalid completion reference: ${
|
|
97601
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid completion reference: ${request2.params.ref}`);
|
|
97371
97602
|
}
|
|
97372
97603
|
});
|
|
97373
97604
|
this._completionHandlerInitialized = true;
|
|
97374
97605
|
}
|
|
97375
|
-
async handlePromptCompletion(
|
|
97606
|
+
async handlePromptCompletion(request2, ref) {
|
|
97376
97607
|
const prompt = this._registeredPrompts[ref.name];
|
|
97377
97608
|
if (!prompt) {
|
|
97378
97609
|
throw new McpError(ErrorCode.InvalidParams, `Prompt ${ref.name} not found`);
|
|
@@ -97384,7 +97615,7 @@ class McpServer {
|
|
|
97384
97615
|
return EMPTY_COMPLETION_RESULT;
|
|
97385
97616
|
}
|
|
97386
97617
|
const promptShape = getObjectShape(prompt.argsSchema);
|
|
97387
|
-
const field = promptShape?.[
|
|
97618
|
+
const field = promptShape?.[request2.params.argument.name];
|
|
97388
97619
|
if (!isCompletable(field)) {
|
|
97389
97620
|
return EMPTY_COMPLETION_RESULT;
|
|
97390
97621
|
}
|
|
@@ -97392,22 +97623,22 @@ class McpServer {
|
|
|
97392
97623
|
if (!completer) {
|
|
97393
97624
|
return EMPTY_COMPLETION_RESULT;
|
|
97394
97625
|
}
|
|
97395
|
-
const suggestions = await completer(
|
|
97626
|
+
const suggestions = await completer(request2.params.argument.value, request2.params.context);
|
|
97396
97627
|
return createCompletionResult(suggestions);
|
|
97397
97628
|
}
|
|
97398
|
-
async handleResourceCompletion(
|
|
97629
|
+
async handleResourceCompletion(request2, ref) {
|
|
97399
97630
|
const template2 = Object.values(this._registeredResourceTemplates).find((t2) => t2.resourceTemplate.uriTemplate.toString() === ref.uri);
|
|
97400
97631
|
if (!template2) {
|
|
97401
97632
|
if (this._registeredResources[ref.uri]) {
|
|
97402
97633
|
return EMPTY_COMPLETION_RESULT;
|
|
97403
97634
|
}
|
|
97404
|
-
throw new McpError(ErrorCode.InvalidParams, `Resource template ${
|
|
97635
|
+
throw new McpError(ErrorCode.InvalidParams, `Resource template ${request2.params.ref.uri} not found`);
|
|
97405
97636
|
}
|
|
97406
|
-
const completer = template2.resourceTemplate.completeCallback(
|
|
97637
|
+
const completer = template2.resourceTemplate.completeCallback(request2.params.argument.name);
|
|
97407
97638
|
if (!completer) {
|
|
97408
97639
|
return EMPTY_COMPLETION_RESULT;
|
|
97409
97640
|
}
|
|
97410
|
-
const suggestions = await completer(
|
|
97641
|
+
const suggestions = await completer(request2.params.argument.value, request2.params.context);
|
|
97411
97642
|
return createCompletionResult(suggestions);
|
|
97412
97643
|
}
|
|
97413
97644
|
setResourceRequestHandlers() {
|
|
@@ -97422,7 +97653,7 @@ class McpServer {
|
|
|
97422
97653
|
listChanged: true
|
|
97423
97654
|
}
|
|
97424
97655
|
});
|
|
97425
|
-
this.server.setRequestHandler(ListResourcesRequestSchema, async (
|
|
97656
|
+
this.server.setRequestHandler(ListResourcesRequestSchema, async (request2, extra) => {
|
|
97426
97657
|
const resources = Object.entries(this._registeredResources).filter(([_, resource]) => resource.enabled).map(([uri, resource]) => ({
|
|
97427
97658
|
uri,
|
|
97428
97659
|
name: resource.name,
|
|
@@ -97451,8 +97682,8 @@ class McpServer {
|
|
|
97451
97682
|
}));
|
|
97452
97683
|
return { resourceTemplates };
|
|
97453
97684
|
});
|
|
97454
|
-
this.server.setRequestHandler(ReadResourceRequestSchema, async (
|
|
97455
|
-
const uri = new URL(
|
|
97685
|
+
this.server.setRequestHandler(ReadResourceRequestSchema, async (request2, extra) => {
|
|
97686
|
+
const uri = new URL(request2.params.uri);
|
|
97456
97687
|
const resource = this._registeredResources[uri.toString()];
|
|
97457
97688
|
if (resource) {
|
|
97458
97689
|
if (!resource.enabled) {
|
|
@@ -97491,21 +97722,21 @@ class McpServer {
|
|
|
97491
97722
|
};
|
|
97492
97723
|
})
|
|
97493
97724
|
}));
|
|
97494
|
-
this.server.setRequestHandler(GetPromptRequestSchema, async (
|
|
97495
|
-
const prompt = this._registeredPrompts[
|
|
97725
|
+
this.server.setRequestHandler(GetPromptRequestSchema, async (request2, extra) => {
|
|
97726
|
+
const prompt = this._registeredPrompts[request2.params.name];
|
|
97496
97727
|
if (!prompt) {
|
|
97497
|
-
throw new McpError(ErrorCode.InvalidParams, `Prompt ${
|
|
97728
|
+
throw new McpError(ErrorCode.InvalidParams, `Prompt ${request2.params.name} not found`);
|
|
97498
97729
|
}
|
|
97499
97730
|
if (!prompt.enabled) {
|
|
97500
|
-
throw new McpError(ErrorCode.InvalidParams, `Prompt ${
|
|
97731
|
+
throw new McpError(ErrorCode.InvalidParams, `Prompt ${request2.params.name} disabled`);
|
|
97501
97732
|
}
|
|
97502
97733
|
if (prompt.argsSchema) {
|
|
97503
97734
|
const argsObj = normalizeObjectSchema(prompt.argsSchema);
|
|
97504
|
-
const parseResult = await safeParseAsync3(argsObj,
|
|
97735
|
+
const parseResult = await safeParseAsync3(argsObj, request2.params.arguments);
|
|
97505
97736
|
if (!parseResult.success) {
|
|
97506
97737
|
const error61 = "error" in parseResult ? parseResult.error : "Unknown error";
|
|
97507
97738
|
const errorMessage = getParseErrorMessage(error61);
|
|
97508
|
-
throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${
|
|
97739
|
+
throw new McpError(ErrorCode.InvalidParams, `Invalid arguments for prompt ${request2.params.name}: ${errorMessage}`);
|
|
97509
97740
|
}
|
|
97510
97741
|
const args = parseResult.data;
|
|
97511
97742
|
const cb = prompt.callback;
|
|
@@ -97933,8 +98164,8 @@ function invitationEmailIds(invitationId2, challengeId) {
|
|
|
97933
98164
|
return { invitationId: invitationId2, challengeId };
|
|
97934
98165
|
}
|
|
97935
98166
|
function invitationEmailInput(action, input2) {
|
|
97936
|
-
const
|
|
97937
|
-
if (!record8(input2) || Object.keys(input2).length !==
|
|
98167
|
+
const keys3 = ["invitationId", "token", "challengeId", "confirm", ...action === "accept" ? ["code"] : []];
|
|
98168
|
+
if (!record8(input2) || Object.keys(input2).length !== keys3.length || keys3.some((key) => !Object.hasOwn(input2, key)))
|
|
97938
98169
|
throw new InvitationEmailInputError;
|
|
97939
98170
|
const value = { ...input2 };
|
|
97940
98171
|
const ids = invitationEmailIds(value.invitationId, value.challengeId);
|
|
@@ -98043,9 +98274,9 @@ function checkedPublicationDeclaration(value) {
|
|
|
98043
98274
|
}
|
|
98044
98275
|
function checkedPublicationView(value, skillId, intentId, declaration) {
|
|
98045
98276
|
if (!exact(value, ["id", "skillId", "version", "expectedCurrentVersionId", "archiveSha256", "archiveByteSize", "state", "expiresAt", "createdAt", "versionId"]) || !publicationUuid(value.id) || value.skillId !== skillId || intentId !== undefined && value.id !== intentId || typeof value.version !== "string" || !value.version || value.version.length > 128 || /[\p{Cc}\p{Cs}]/u.test(value.version) || !(value.expectedCurrentVersionId === null || publicationUuid(value.expectedCurrentVersionId)) || !hash3(value.archiveSha256) || !Number.isSafeInteger(value.archiveByteSize) || Number(value.archiveByteSize) < 1 || Number(value.archiveByteSize) > PRIVATE_PUBLICATION_MAX_BYTES || typeof value.state !== "string" || !["awaiting_upload", "queued", "verifying", "needs_attention", "committed", "rejected", "cancelled", "expired"].includes(value.state) || !date6(value.expiresAt) || !date6(value.createdAt) || !(value.versionId === null || publicationUuid(value.versionId)) || value.state === "committed" && value.versionId === null)
|
|
98046
|
-
return
|
|
98277
|
+
return invalid5();
|
|
98047
98278
|
if (declaration && ["version", "expectedCurrentVersionId", "archiveSha256", "archiveByteSize"].some((k) => value[k] !== declaration[k]))
|
|
98048
|
-
return
|
|
98279
|
+
return invalid5();
|
|
98049
98280
|
return Object.freeze({ ...value });
|
|
98050
98281
|
}
|
|
98051
98282
|
async function boundedJson(url2, init, token, mutation, budget2 = 15000, signal) {
|
|
@@ -98068,7 +98299,7 @@ async function boundedJson(url2, init, token, mutation, budget2 = 15000, signal)
|
|
|
98068
98299
|
});
|
|
98069
98300
|
const length = response.headers.get("content-length");
|
|
98070
98301
|
if (length !== null && (!/^\d+$/.test(length) || Number(length) > 65536))
|
|
98071
|
-
return
|
|
98302
|
+
return invalid5();
|
|
98072
98303
|
reader = response.body?.getReader();
|
|
98073
98304
|
const chunks = [];
|
|
98074
98305
|
let size2 = 0;
|
|
@@ -98079,7 +98310,7 @@ async function boundedJson(url2, init, token, mutation, budget2 = 15000, signal)
|
|
|
98079
98310
|
break;
|
|
98080
98311
|
size2 += part.value.byteLength;
|
|
98081
98312
|
if (size2 > 65536)
|
|
98082
|
-
return
|
|
98313
|
+
return invalid5();
|
|
98083
98314
|
chunks.push(part.value);
|
|
98084
98315
|
}
|
|
98085
98316
|
if (controller.signal.aborted)
|
|
@@ -98089,7 +98320,7 @@ async function boundedJson(url2, init, token, mutation, budget2 = 15000, signal)
|
|
|
98089
98320
|
try {
|
|
98090
98321
|
body = JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes));
|
|
98091
98322
|
} catch {
|
|
98092
|
-
return
|
|
98323
|
+
return invalid5();
|
|
98093
98324
|
}
|
|
98094
98325
|
if (!response.ok) {
|
|
98095
98326
|
const code = record9(body) && typeof body.code === "string" && Object.hasOwn(failures2, body.code) ? body.code : null;
|
|
@@ -98165,7 +98396,7 @@ class RemotePrivatePublicationsClient {
|
|
|
98165
98396
|
const value = await boundedJson(path, { method: method2, ...method2 === "GET" ? {} : { body: JSON.stringify(declaration ?? {}) } }, this.#token, method2 !== "GET", options.timeoutMs, options.signal);
|
|
98166
98397
|
try {
|
|
98167
98398
|
if (!record9(value) || !Object.keys(value).every((k) => k === "upload" || k === "changed") || value.changed !== undefined && typeof value.changed !== "boolean")
|
|
98168
|
-
return
|
|
98399
|
+
return invalid5();
|
|
98169
98400
|
return checkedPublicationView(value.upload, skillId, intentId, declaration);
|
|
98170
98401
|
} catch (error61) {
|
|
98171
98402
|
if (method2 !== "GET")
|
|
@@ -98228,29 +98459,29 @@ class RemotePrivatePublicationsClient {
|
|
|
98228
98459
|
}
|
|
98229
98460
|
#upload(value, intent) {
|
|
98230
98461
|
if (!exact(value, ["upload"]) || !exact(value.upload, ["method", "uploadUrl", "headers", "expiresAt"]))
|
|
98231
|
-
return
|
|
98462
|
+
return invalid5();
|
|
98232
98463
|
const p = value.upload;
|
|
98233
98464
|
if (p.method !== "PUT" || typeof p.uploadUrl !== "string" || p.uploadUrl.length > 8192 || /[\x00-\x20\x7f]/.test(p.uploadUrl) || !date6(p.expiresAt) || Date.parse(p.expiresAt) - Date.now() < 1000 || Date.parse(p.expiresAt) - Date.now() > 300000 || Date.parse(p.expiresAt) > Date.parse(intent.expiresAt) || !exact(p.headers, ["content-type", "content-length", "x-amz-checksum-sha256", "x-amz-expected-bucket-owner"]) || p.headers["content-type"] !== "application/gzip" || p.headers["content-length"] !== String(intent.archiveByteSize) || p.headers["x-amz-checksum-sha256"] !== Buffer.from(intent.archiveSha256, "hex").toString("base64") || typeof p.headers["x-amz-expected-bucket-owner"] !== "string" || !/^\d{12}$/.test(p.headers["x-amz-expected-bucket-owner"]))
|
|
98234
|
-
return
|
|
98465
|
+
return invalid5();
|
|
98235
98466
|
let url2;
|
|
98236
98467
|
try {
|
|
98237
98468
|
url2 = new URL(p.uploadUrl);
|
|
98238
98469
|
} catch {
|
|
98239
|
-
return
|
|
98470
|
+
return invalid5();
|
|
98240
98471
|
}
|
|
98241
98472
|
if (url2.protocol !== "https:" || url2.port || url2.username || url2.password || url2.hash || !/^[a-z0-9][a-z0-9-]{1,61}[a-z0-9]\.s3\.[a-z]{2}(?:-[a-z]+)+-[1-9]\.amazonaws\.com$/.test(url2.hostname) || url2.pathname !== `/private-publication-staging/${this.organizationId}/${intent.id}/bundle.tgz` || !url2.search || url2.searchParams.get("X-Amz-Algorithm") !== "AWS4-HMAC-SHA256" || url2.searchParams.get("X-Amz-SignedHeaders") !== "content-length;content-type;host;x-amz-checksum-sha256;x-amz-expected-bucket-owner" || !/^[a-f0-9]{64}$/.test(url2.searchParams.get("X-Amz-Signature") ?? ""))
|
|
98242
|
-
return
|
|
98473
|
+
return invalid5();
|
|
98243
98474
|
const queryKeys = ["X-Amz-Algorithm", "X-Amz-Credential", "X-Amz-Date", "X-Amz-Expires", "X-Amz-Security-Token", "X-Amz-Signature", "X-Amz-SignedHeaders"];
|
|
98244
98475
|
if ([...url2.searchParams.keys()].sort().join(",") !== queryKeys.sort().join(","))
|
|
98245
|
-
return
|
|
98476
|
+
return invalid5();
|
|
98246
98477
|
const issued = url2.searchParams.get("X-Amz-Date"), ttl = url2.searchParams.get("X-Amz-Expires"), credential = url2.searchParams.get("X-Amz-Credential");
|
|
98247
98478
|
const timestamp3 = /^(\d{4})(\d\d)(\d\d)T(\d\d)(\d\d)(\d\d)Z$/.exec(issued);
|
|
98248
98479
|
const region = url2.hostname.split(".s3.")[1].split(".amazonaws.com")[0];
|
|
98249
98480
|
if (!timestamp3 || !/^[1-9]\d{0,2}$/.test(ttl) || Number(ttl) > 300 || !/^[A-Z0-9]{16,128}\//.test(credential) || credential.split("/").slice(1).join("/") !== `${issued.slice(0, 8)}/${region}/s3/aws4_request` || !/^[\x21-\x7e]{1,4096}$/.test(url2.searchParams.get("X-Amz-Security-Token")))
|
|
98250
|
-
return
|
|
98481
|
+
return invalid5();
|
|
98251
98482
|
const issuedAt = Date.parse(`${timestamp3[1]}-${timestamp3[2]}-${timestamp3[3]}T${timestamp3[4]}:${timestamp3[5]}:${timestamp3[6]}Z`);
|
|
98252
98483
|
if (!Number.isFinite(issuedAt) || issuedAt > Date.now() + 1000 || issuedAt + Number(ttl) * 1000 !== Date.parse(p.expiresAt))
|
|
98253
|
-
return
|
|
98484
|
+
return invalid5();
|
|
98254
98485
|
return { method: "PUT", uploadUrl: url2.href, expiresAt: p.expiresAt, headers: Object.freeze({ ...p.headers }) };
|
|
98255
98486
|
}
|
|
98256
98487
|
async wait(skillId, intentId, options = {}) {
|
|
@@ -98287,9 +98518,9 @@ class RemotePrivatePublicationsClient {
|
|
|
98287
98518
|
}
|
|
98288
98519
|
var PRIVATE_PUBLICATION_MAX_BYTES, failures2, PrivatePublicationError, bad = () => {
|
|
98289
98520
|
throw new PrivatePublicationError("INVALID_PUBLICATION_INPUT", "Invalid publication input or recovery data.");
|
|
98290
|
-
},
|
|
98521
|
+
}, invalid5 = () => {
|
|
98291
98522
|
throw new PrivatePublicationError("INVALID_PUBLICATION_RESPONSE", "The server returned an invalid publication result.");
|
|
98292
|
-
}, publicationUuid = (v) => typeof v === "string" && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(v), hash3 = (v) => typeof v === "string" && /^[a-f0-9]{64}$/.test(v), record9 = (v) => !!v && typeof v === "object" && !Array.isArray(v), exact = (v,
|
|
98523
|
+
}, publicationUuid = (v) => typeof v === "string" && /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/.test(v), hash3 = (v) => typeof v === "string" && /^[a-f0-9]{64}$/.test(v), record9 = (v) => !!v && typeof v === "object" && !Array.isArray(v), exact = (v, keys3) => record9(v) && Object.keys(v).sort().join(",") === keys3.sort().join(","), date6 = (v) => typeof v === "string" && /^\d{4}-\d\d-\d\dT[0-9:.]+(?:Z|[+-](?:[01]\d|2[0-3]):[0-5]\d)$/.test(v) && Number.isFinite(Date.parse(v)), publicationSha256 = (bytes) => createHash16("sha256").update(bytes).digest("hex");
|
|
98293
98524
|
var init_remote_private_publications = __esm(() => {
|
|
98294
98525
|
init_fleet_credentials();
|
|
98295
98526
|
init_remote_workspace_selection();
|
|
@@ -98481,18 +98712,18 @@ class RemoteSkillsAuthClient {
|
|
|
98481
98712
|
}
|
|
98482
98713
|
async resendWorkspaceInvitation(email4, code, context, invitationId2, input2) {
|
|
98483
98714
|
const target = workspaceContext(context), captured = invitationInput("resend", { ...input2, invitationId: invitationId2 });
|
|
98484
|
-
const { invitationId:
|
|
98485
|
-
return (await this.sessionClient(email4, code, target)).resendWorkspaceInvitation(target,
|
|
98715
|
+
const { invitationId: id2, ...options } = captured;
|
|
98716
|
+
return (await this.sessionClient(email4, code, target)).resendWorkspaceInvitation(target, id2, options);
|
|
98486
98717
|
}
|
|
98487
98718
|
async revokeWorkspaceInvitation(email4, code, context, invitationId2, input2) {
|
|
98488
98719
|
const target = workspaceContext(context), captured = invitationInput("revoke", { ...input2, invitationId: invitationId2 });
|
|
98489
|
-
const { invitationId:
|
|
98490
|
-
return (await this.sessionClient(email4, code, target)).revokeWorkspaceInvitation(target,
|
|
98720
|
+
const { invitationId: id2, ...options } = captured;
|
|
98721
|
+
return (await this.sessionClient(email4, code, target)).revokeWorkspaceInvitation(target, id2, options);
|
|
98491
98722
|
}
|
|
98492
98723
|
async acceptWorkspaceInvitation(email4, code, context, invitationId2, input2) {
|
|
98493
98724
|
const target = workspaceContext(context), captured = invitationInput("accept", { ...input2, invitationId: invitationId2 });
|
|
98494
|
-
const { invitationId:
|
|
98495
|
-
return (await this.sessionClient(email4, code, target)).acceptWorkspaceInvitation(target,
|
|
98725
|
+
const { invitationId: id2, ...options } = captured;
|
|
98726
|
+
return (await this.sessionClient(email4, code, target)).acceptWorkspaceInvitation(target, id2, options);
|
|
98496
98727
|
}
|
|
98497
98728
|
async createApiKey(email4, code, name, scopes, context) {
|
|
98498
98729
|
const capturedScopes = scopes === undefined ? undefined : [...scopes];
|
|
@@ -98934,7 +99165,7 @@ var init_recurring_customer = __esm(() => {
|
|
|
98934
99165
|
});
|
|
98935
99166
|
|
|
98936
99167
|
// src/lib/recurring-recovery.ts
|
|
98937
|
-
import { constants as constants12, closeSync as closeSync13, fsyncSync as fsyncSync2, fstatSync as fstatSync13, lstatSync as lstatSync19, mkdirSync as mkdirSync16, openSync as openSync13, readSync as readSync9, realpathSync as
|
|
99168
|
+
import { constants as constants12, closeSync as closeSync13, fsyncSync as fsyncSync2, fstatSync as fstatSync13, lstatSync as lstatSync19, mkdirSync as mkdirSync16, openSync as openSync13, readSync as readSync9, realpathSync as realpathSync8, renameSync as renameSync9, unlinkSync as unlinkSync5, writeFileSync as writeFileSync16 } from "fs";
|
|
98938
99169
|
import { dirname as dirname17, isAbsolute as isAbsolute11, join as join42, resolve as resolve13 } from "path";
|
|
98939
99170
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
98940
99171
|
|
|
@@ -98943,12 +99174,12 @@ class RecoveryOwner {
|
|
|
98943
99174
|
parents = [];
|
|
98944
99175
|
constructor(directory) {
|
|
98945
99176
|
this.directory = directory;
|
|
98946
|
-
if (!isAbsolute11(directory) || resolve13(directory) !== directory ||
|
|
98947
|
-
|
|
99177
|
+
if (!isAbsolute11(directory) || resolve13(directory) !== directory || realpathSync8(directory) !== directory)
|
|
99178
|
+
invalid6();
|
|
98948
99179
|
for (let path = directory;; path = dirname17(path)) {
|
|
98949
99180
|
const stat2 = lstatSync19(path);
|
|
98950
99181
|
if (!stat2.isDirectory() || stat2.isSymbolicLink())
|
|
98951
|
-
|
|
99182
|
+
invalid6();
|
|
98952
99183
|
this.parents.push({ path, dev: stat2.dev, ino: stat2.ino });
|
|
98953
99184
|
if (path === dirname17(path))
|
|
98954
99185
|
break;
|
|
@@ -98956,16 +99187,16 @@ class RecoveryOwner {
|
|
|
98956
99187
|
this.assert();
|
|
98957
99188
|
}
|
|
98958
99189
|
assert() {
|
|
98959
|
-
if (
|
|
98960
|
-
|
|
99190
|
+
if (realpathSync8(this.directory) !== this.directory)
|
|
99191
|
+
invalid6();
|
|
98961
99192
|
for (const prior of this.parents) {
|
|
98962
99193
|
const now3 = lstatSync19(prior.path);
|
|
98963
99194
|
if (!now3.isDirectory() || now3.isSymbolicLink() || now3.dev !== prior.dev || now3.ino !== prior.ino)
|
|
98964
|
-
|
|
99195
|
+
invalid6();
|
|
98965
99196
|
}
|
|
98966
99197
|
const own2 = lstatSync19(this.directory);
|
|
98967
99198
|
if ((own2.mode & 511) !== 448 || (own2.mode & 3584) !== 0 || process.getuid && own2.uid !== process.getuid())
|
|
98968
|
-
|
|
99199
|
+
invalid6();
|
|
98969
99200
|
}
|
|
98970
99201
|
read(name) {
|
|
98971
99202
|
this.assert();
|
|
@@ -98973,7 +99204,7 @@ class RecoveryOwner {
|
|
|
98973
99204
|
try {
|
|
98974
99205
|
const before2 = fstatSync13(fd);
|
|
98975
99206
|
if (!before2.isFile() || before2.nlink !== 1 || (before2.mode & 4095) !== 384 || before2.size < 1 || before2.size > 8192 || process.getuid && before2.uid !== process.getuid())
|
|
98976
|
-
|
|
99207
|
+
invalid6();
|
|
98977
99208
|
const bytes = Buffer.alloc(before2.size + 1);
|
|
98978
99209
|
let size2 = 0;
|
|
98979
99210
|
while (size2 < bytes.length) {
|
|
@@ -98984,7 +99215,7 @@ class RecoveryOwner {
|
|
|
98984
99215
|
}
|
|
98985
99216
|
const after2 = fstatSync13(fd), path = lstatSync19(join42(this.directory, name));
|
|
98986
99217
|
if (size2 !== before2.size || after2.size !== before2.size || before2.mtimeMs !== after2.mtimeMs || before2.ctimeMs !== after2.ctimeMs || path.dev !== before2.dev || path.ino !== before2.ino || !path.isFile() || path.isSymbolicLink())
|
|
98987
|
-
|
|
99218
|
+
invalid6();
|
|
98988
99219
|
this.assert();
|
|
98989
99220
|
return new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, size2));
|
|
98990
99221
|
} finally {
|
|
@@ -99016,11 +99247,11 @@ class RecoveryOwner {
|
|
|
99016
99247
|
}
|
|
99017
99248
|
saveState(state, expected) {
|
|
99018
99249
|
if (this.read("state.json") !== expected)
|
|
99019
|
-
|
|
99250
|
+
invalid6();
|
|
99020
99251
|
const name = `.state-${randomUUID6()}.json`;
|
|
99021
99252
|
this.write(name, state);
|
|
99022
99253
|
if (this.read("state.json") !== expected)
|
|
99023
|
-
|
|
99254
|
+
invalid6();
|
|
99024
99255
|
this.assert();
|
|
99025
99256
|
renameSync9(join42(this.directory, name), join42(this.directory, "state.json"));
|
|
99026
99257
|
this.sync();
|
|
@@ -99044,7 +99275,7 @@ class RecoveryOwner {
|
|
|
99044
99275
|
this.assert();
|
|
99045
99276
|
const now3 = lstatSync19(join42(this.directory, "operation.lock"));
|
|
99046
99277
|
if (owner.dev !== now3.dev || owner.ino !== now3.ino || !now3.isFile() || now3.isSymbolicLink())
|
|
99047
|
-
|
|
99278
|
+
invalid6();
|
|
99048
99279
|
unlinkSync5(join42(this.directory, "operation.lock"));
|
|
99049
99280
|
this.sync();
|
|
99050
99281
|
}
|
|
@@ -99055,10 +99286,10 @@ function load(owner) {
|
|
|
99055
99286
|
const stateText = owner.read("state.json"), state = stateSchema.parse(JSON.parse(stateText));
|
|
99056
99287
|
const intent = intentSchema.parse(JSON.parse(owner.read(`intent-${state.intentSha256}.json`)));
|
|
99057
99288
|
if (canonicalJsonSha256(intent) !== state.intentSha256 || normalizeSkillsApiOrigin(intent.apiOrigin) !== intent.apiOrigin || intent.operation === "activate" && intent.approval.acceptedTermsSha256 !== intent.termsSha256 || (state.phase === "observed" ? state.consentId === null : state.consentId !== null) || intent.operation === "revoke" && state.consentId !== null && state.consentId !== intent.consentId)
|
|
99058
|
-
|
|
99289
|
+
invalid6();
|
|
99059
99290
|
return { intent, state, stateText };
|
|
99060
99291
|
} catch {
|
|
99061
|
-
return
|
|
99292
|
+
return invalid6();
|
|
99062
99293
|
}
|
|
99063
99294
|
}
|
|
99064
99295
|
function bindRecurringRecovery(customer, intent) {
|
|
@@ -99078,8 +99309,8 @@ function base2(customer, organizationId) {
|
|
|
99078
99309
|
};
|
|
99079
99310
|
}
|
|
99080
99311
|
function create3(directory, intent) {
|
|
99081
|
-
if (!isAbsolute11(directory) || resolve13(directory) !== directory ||
|
|
99082
|
-
|
|
99312
|
+
if (!isAbsolute11(directory) || resolve13(directory) !== directory || realpathSync8(dirname17(directory)) !== dirname17(directory))
|
|
99313
|
+
invalid6();
|
|
99083
99314
|
mkdirSync16(directory, { mode: 448 });
|
|
99084
99315
|
const owner = new RecoveryOwner(directory), checked = intentSchema.parse(intent), intentSha256 = canonicalJsonSha256(checked);
|
|
99085
99316
|
owner.write(`intent-${intentSha256}.json`, checked);
|
|
@@ -99203,7 +99434,7 @@ async function continueRecurringRecovery(customer, directory, options) {
|
|
|
99203
99434
|
throw error61;
|
|
99204
99435
|
}
|
|
99205
99436
|
}
|
|
99206
|
-
var uuid12, sha2, common2, intentSchema, stateSchema,
|
|
99437
|
+
var uuid12, sha2, common2, intentSchema, stateSchema, invalid6 = () => {
|
|
99207
99438
|
throw new RecurringCustomerError("RECURRING_RECOVERY_INVALID", "The original recovery directory or record is invalid or changed. Preserve it; do not create a replacement activation automatically.");
|
|
99208
99439
|
};
|
|
99209
99440
|
var init_recurring_recovery = __esm(() => {
|
|
@@ -100968,9 +101199,9 @@ function registerOperationTools(server) {
|
|
|
100968
101199
|
return mcpError("SELECTED_INPUT_REQUIRED", "The selected cloud execution contract accepts declared JSON input, not legacy run arguments or quote receipts.");
|
|
100969
101200
|
const { CloudExecutionClient: CloudExecutionClient2 } = await Promise.resolve().then(() => (init_cloud_executions(), exports_cloud_executions));
|
|
100970
101201
|
const client = await CloudExecutionClient2.configured();
|
|
100971
|
-
const
|
|
100972
|
-
const run = await client.submit(
|
|
100973
|
-
return mcpJson({ selection, remote: true, run });
|
|
101202
|
+
const selection2 = resolved.selection;
|
|
101203
|
+
const run = await client.submit(selection2.slug, selection2.version, input2 ?? {}, idempotency_key ?? crypto.randomUUID(), selection2);
|
|
101204
|
+
return mcpJson({ selection: selection2, remote: true, run });
|
|
100974
101205
|
}
|
|
100975
101206
|
const result3 = await executeSelectedLocal2(resolved, { args, input: input2, cwd: process.cwd() });
|
|
100976
101207
|
return { ...mcpJson(result3), isError: result3.exitCode !== 0 };
|
|
@@ -101405,9 +101636,9 @@ function registerResourceMetaTools(server) {
|
|
|
101405
101636
|
existing.last_seen_at = new Date().toISOString();
|
|
101406
101637
|
return mcpJson({ ...existing, registered: false });
|
|
101407
101638
|
}
|
|
101408
|
-
const
|
|
101409
|
-
const ag = { id, name: a.name, last_seen_at: new Date().toISOString() };
|
|
101410
|
-
_agentReg.set(
|
|
101639
|
+
const id2 = Math.random().toString(36).slice(2, 10);
|
|
101640
|
+
const ag = { id: id2, name: a.name, last_seen_at: new Date().toISOString() };
|
|
101641
|
+
_agentReg.set(id2, ag);
|
|
101411
101642
|
return mcpJson({ ...ag, registered: true });
|
|
101412
101643
|
});
|
|
101413
101644
|
server.tool("heartbeat", "Update last_seen_at to signal agent is active.", { agent_id: exports_external.string() }, async (a) => {
|
|
@@ -101598,11 +101829,11 @@ function addSchedule(skill, cron, options = {}) {
|
|
|
101598
101829
|
if (!valid)
|
|
101599
101830
|
return { schedule: null, error: error61 };
|
|
101600
101831
|
const data = loadSchedules(options.targetDir);
|
|
101601
|
-
const
|
|
101832
|
+
const id2 = `${skill}-${Date.now()}`;
|
|
101602
101833
|
const now3 = new Date;
|
|
101603
101834
|
const nextRun = getNextRun(cron, now3);
|
|
101604
101835
|
const schedule = {
|
|
101605
|
-
id,
|
|
101836
|
+
id: id2,
|
|
101606
101837
|
name: options.name || `${skill} (${cron})`,
|
|
101607
101838
|
skill,
|
|
101608
101839
|
cron,
|
|
@@ -101643,9 +101874,9 @@ function getDueSchedules(targetDir) {
|
|
|
101643
101874
|
const now3 = new Date;
|
|
101644
101875
|
return listSchedules(targetDir).filter((s) => s.enabled && s.nextRun && new Date(s.nextRun) <= now3);
|
|
101645
101876
|
}
|
|
101646
|
-
function recordScheduleRun(
|
|
101877
|
+
function recordScheduleRun(id2, status, targetDir) {
|
|
101647
101878
|
const data = loadSchedules(targetDir);
|
|
101648
|
-
const schedule = data.schedules.find((s) => s.id ===
|
|
101879
|
+
const schedule = data.schedules.find((s) => s.id === id2);
|
|
101649
101880
|
if (!schedule)
|
|
101650
101881
|
return;
|
|
101651
101882
|
const now3 = new Date;
|
|
@@ -102135,11 +102366,11 @@ var init_private_publication_customer = __esm(() => {
|
|
|
102135
102366
|
});
|
|
102136
102367
|
|
|
102137
102368
|
// src/lib/private-publication-recovery.ts
|
|
102138
|
-
import { constants as constants13, closeSync as closeSync14, fsyncSync as fsyncSync3, fstatSync as fstatSync14, lstatSync as lstatSync20, mkdirSync as mkdirSync20, openSync as openSync14, readSync as readSync10, realpathSync as
|
|
102369
|
+
import { constants as constants13, closeSync as closeSync14, fsyncSync as fsyncSync3, fstatSync as fstatSync14, lstatSync as lstatSync20, mkdirSync as mkdirSync20, openSync as openSync14, readSync as readSync10, realpathSync as realpathSync9, renameSync as renameSync10, unlinkSync as unlinkSync6, writeFileSync as writeFileSync19 } from "fs";
|
|
102139
102370
|
import { dirname as dirname20, isAbsolute as isAbsolute13, join as join47, resolve as resolve14 } from "path";
|
|
102140
102371
|
import { randomUUID as randomUUID7 } from "crypto";
|
|
102141
102372
|
function safeDirectory(directory2) {
|
|
102142
|
-
if (!isAbsolute13(directory2) || directory2 !== resolve14(directory2) ||
|
|
102373
|
+
if (!isAbsolute13(directory2) || directory2 !== resolve14(directory2) || realpathSync9(directory2) !== directory2)
|
|
102143
102374
|
return fail3();
|
|
102144
102375
|
for (let path = directory2;; path = dirname20(path)) {
|
|
102145
102376
|
const stat2 = lstatSync20(path);
|
|
@@ -102277,7 +102508,7 @@ async function preparePrivatePublication(client, sourceDirectory, recoveryDirect
|
|
|
102277
102508
|
phase: "prepared",
|
|
102278
102509
|
intent: null
|
|
102279
102510
|
};
|
|
102280
|
-
if (!isAbsolute13(recoveryDirectory) || resolve14(recoveryDirectory) !== recoveryDirectory ||
|
|
102511
|
+
if (!isAbsolute13(recoveryDirectory) || resolve14(recoveryDirectory) !== recoveryDirectory || realpathSync9(dirname20(recoveryDirectory)) !== dirname20(recoveryDirectory))
|
|
102281
102512
|
return fail3();
|
|
102282
102513
|
mkdirSync20(recoveryDirectory, { mode: 448 });
|
|
102283
102514
|
safeDirectory(recoveryDirectory);
|
|
@@ -102992,17 +103223,17 @@ __export(exports_runtime, {
|
|
|
102992
103223
|
registerRuntime: () => registerRuntime
|
|
102993
103224
|
});
|
|
102994
103225
|
import { createHash as createHash18, randomUUID as randomUUID8 } from "crypto";
|
|
102995
|
-
import { lstatSync as lstatSync21, mkdirSync as mkdirSync22, readFileSync as readFileSync35, realpathSync as
|
|
103226
|
+
import { lstatSync as lstatSync21, mkdirSync as mkdirSync22, readFileSync as readFileSync35, realpathSync as realpathSync10, writeFileSync as writeFileSync21 } from "fs";
|
|
102996
103227
|
import { basename as basename6, isAbsolute as isAbsolute15, join as join49 } from "path";
|
|
102997
103228
|
import { createInterface } from "readline";
|
|
102998
103229
|
function registerRuntime(parent) {
|
|
102999
103230
|
parent.command("run").argument("<skill>", "Skill name").argument("[args...]", "Arguments to pass to the skill").allowUnknownOption(true).passThroughOptions(true).option("--json", "Output result as JSON", false).option("--remote", "Run on the configured server, using its catalog and quote", false).option("--target <target>", "Execution target: local or cloud").option("--secret-bindings <path>", "Reviewed, exact-selection local execution vault bindings (JSON file)").option("--secret-bindings-template", "Print a scoped bindings template without resolving secrets or running the skill", false).option("--input <json>", "Structured cloud execution input").option("--skill-version <version>", "Exact selected skill version").option("--selection-profile <id>", "Selected Skills profile").option("--session <id>", "Pinned Skills session").option("--cached", "Use the explicit verified selected cache", false).option("--yes", "Approve the server's quoted credit cost for this run", false).option("--idempotency-key <key>", "Reuse this key when retrying the same remote submission").option("--file <path>", "Attach a local input file to a remote run (repeatable)", (value, prior) => [...prior, value], []).option("--wait", "Poll remote runs until a terminal status", false).option("--poll-interval-ms <ms>", "Remote polling interval in milliseconds", "1000").option("--poll-timeout-ms <ms>", "Maximum time to wait for a remote run", "300000").description("Run a skill directly").action(async (name, args2, options) => handleRun(name, args2, options));
|
|
103000
103231
|
const executions = parent.command("executions").description("Inspect isolated cloud executions");
|
|
103001
103232
|
for (const operation of ["show", "logs", "artifacts", "cancel"]) {
|
|
103002
|
-
executions.command(operation).argument("<execution-id>").option("--json", "Output as JSON", false).action(async (
|
|
103233
|
+
executions.command(operation).argument("<execution-id>").option("--json", "Output as JSON", false).action(async (id2) => {
|
|
103003
103234
|
try {
|
|
103004
103235
|
const client = await CloudExecutionClient.configured();
|
|
103005
|
-
const value = operation === "show" ? await client.get(
|
|
103236
|
+
const value = operation === "show" ? await client.get(id2) : await client[operation](id2);
|
|
103006
103237
|
await writeCliOutput(JSON.stringify(value, null, 2));
|
|
103007
103238
|
} catch (error61) {
|
|
103008
103239
|
console.error(JSON.stringify({ error: error61.message }));
|
|
@@ -103010,14 +103241,14 @@ function registerRuntime(parent) {
|
|
|
103010
103241
|
}
|
|
103011
103242
|
});
|
|
103012
103243
|
}
|
|
103013
|
-
executions.command("download").argument("<execution-id>").argument("<artifact-name>").requiredOption("--output <path>", "New output file path").action(async (
|
|
103244
|
+
executions.command("download").argument("<execution-id>").argument("<artifact-name>").requiredOption("--output <path>", "New output file path").action(async (id2, name, options) => {
|
|
103014
103245
|
try {
|
|
103015
103246
|
const client = await CloudExecutionClient.configured();
|
|
103016
|
-
const manifest = await client.artifacts(
|
|
103247
|
+
const manifest = await client.artifacts(id2);
|
|
103017
103248
|
const expected = manifest.find((item) => item.name === name);
|
|
103018
103249
|
if (!expected)
|
|
103019
103250
|
throw new Error("Cloud artifact not found");
|
|
103020
|
-
const bytes = await client.download(
|
|
103251
|
+
const bytes = await client.download(id2, name);
|
|
103021
103252
|
if (bytes.length !== expected.byteSize || createHash18("sha256").update(bytes).digest("hex") !== expected.sha256)
|
|
103022
103253
|
throw new Error("Cloud artifact integrity verification failed");
|
|
103023
103254
|
writeFileSync21(options.output, bytes, { flag: "wx", mode: 384 });
|
|
@@ -103029,10 +103260,10 @@ function registerRuntime(parent) {
|
|
|
103029
103260
|
});
|
|
103030
103261
|
const runs = parent.command("runs").description("Inspect local skill run records");
|
|
103031
103262
|
runs.command("list").option("--remote", "List runs on the configured server", false).option("--json", "Output as JSON", false).option("--limit <n>", "Maximum number of runs", "20").option("--cursor <n>", "Local human-output offset; remote accepts only 0", "0").description("List recent skill runs").action((options) => options.remote ? handleRemoteRunsList(options) : handleRunsList(options));
|
|
103032
|
-
runs.command("logs").argument("<run-id>").option("--json", "Output as JSON", false).action((
|
|
103033
|
-
runs.command("cancel").argument("<run-id>").option("--json", "Output as JSON", false).action((
|
|
103034
|
-
runs.command("resume").argument("<run-id>").option("--json", "Output as JSON", false).action((
|
|
103035
|
-
runs.command("artifacts").argument("<run-id>").option("--json", "Output as JSON", false).action((
|
|
103263
|
+
runs.command("logs").argument("<run-id>").option("--json", "Output as JSON", false).action((id2, options) => execute(options, (client) => client.getRunLogs(id2)));
|
|
103264
|
+
runs.command("cancel").argument("<run-id>").option("--json", "Output as JSON", false).action((id2, options) => execute(options, (client) => client.cancelRun(id2)));
|
|
103265
|
+
runs.command("resume").argument("<run-id>").option("--json", "Output as JSON", false).action((id2, options) => execute(options, (client) => client.resumeRun(id2)));
|
|
103266
|
+
runs.command("artifacts").argument("<run-id>").option("--json", "Output as JSON", false).action((id2, options) => execute(options, (client) => client.getRunArtifacts(id2)));
|
|
103036
103267
|
runs.command("show").argument("<run-id>", "Run id").option("--json", "Output as JSON", false).description("Show a skill run record").action((runId2, options) => handleRunsShow(runId2, options));
|
|
103037
103268
|
runs.command("status").argument("<run-id>", "Remote run id, or local run id linked to a remote run").option("--json", "Output as JSON", false).description("Fetch remote run status").action((runId2, options) => handleRunsStatus(runId2, options));
|
|
103038
103269
|
const exportsCommand = parent.command("exports").description("Inspect or open skill run exports");
|
|
@@ -103112,8 +103343,8 @@ async function readUpdatedVersion(bunExecutable) {
|
|
|
103112
103343
|
const selected = Bun.which("skills");
|
|
103113
103344
|
if (!installed || !selected)
|
|
103114
103345
|
throw new Error("Updated command is unavailable");
|
|
103115
|
-
const selectedPath =
|
|
103116
|
-
if (selectedPath !==
|
|
103346
|
+
const selectedPath = realpathSync10(selected);
|
|
103347
|
+
if (selectedPath !== realpathSync10(installed))
|
|
103117
103348
|
throw new Error("Updated command is shadowed on PATH");
|
|
103118
103349
|
const version2 = (await readUpdateCommand([selectedPath, "--version"])).trim();
|
|
103119
103350
|
if (!new RegExp(SEMVER_PATTERN).test(version2))
|
|
@@ -103184,9 +103415,9 @@ async function handleSetup(options) {
|
|
|
103184
103415
|
}
|
|
103185
103416
|
}
|
|
103186
103417
|
if (!error61) {
|
|
103187
|
-
const
|
|
103188
|
-
configured =
|
|
103189
|
-
source =
|
|
103418
|
+
const authority2 = resolveSkillsApiOrigin();
|
|
103419
|
+
configured = authority2?.origin ?? null;
|
|
103420
|
+
source = authority2?.source ?? null;
|
|
103190
103421
|
}
|
|
103191
103422
|
const next = error61 ? ["skills auth login"] : configured ? ["skills auth login", "skills list --remote"] : ["skills list", "skills run <skill>"];
|
|
103192
103423
|
const payload = {
|
|
@@ -103343,7 +103574,7 @@ async function handleRun(name, args2, options) {
|
|
|
103343
103574
|
await writeCliOutput(JSON.stringify(await prepareSelectedSecretBindings(selected), null, 2));
|
|
103344
103575
|
return;
|
|
103345
103576
|
}
|
|
103346
|
-
const result4 = await executeSelectedLocal(selected, { args: args2, input: input2, cwd: process.cwd(), ...options.secretBindings ? { secretBindings: readSelectedSecretBindings(options.secretBindings) } : {} });
|
|
103577
|
+
const result4 = await executeSelectedLocal(selected, { args: args2, input: input2, cwd: process.cwd(), sharedExecutionGrants: !options.cached, ...options.secretBindings ? { secretBindings: readSelectedSecretBindings(options.secretBindings) } : {} });
|
|
103347
103578
|
if (options.json)
|
|
103348
103579
|
await writeCliOutput(JSON.stringify(result4, null, 2));
|
|
103349
103580
|
else {
|
|
@@ -104190,7 +104421,7 @@ This grants an additional recurring budget. Each occurrence reprices within the
|
|
|
104190
104421
|
rl.question(`Type ${acceptance} to approve these exact terms: `, (value) => finish(value === acceptance));
|
|
104191
104422
|
});
|
|
104192
104423
|
}
|
|
104193
|
-
function input2(action,
|
|
104424
|
+
function input2(action, id2, options) {
|
|
104194
104425
|
const value = {};
|
|
104195
104426
|
if (options.userId !== undefined)
|
|
104196
104427
|
value.userId = options.userId;
|
|
@@ -104199,9 +104430,9 @@ function input2(action, id, options) {
|
|
|
104199
104430
|
if (action === "preview")
|
|
104200
104431
|
value.request = readRequest(options.request);
|
|
104201
104432
|
if (["draft", "activate", "verification"].includes(action))
|
|
104202
|
-
value.draftId =
|
|
104433
|
+
value.draftId = id2;
|
|
104203
104434
|
if (["get", "revoke", "occurrences"].includes(action))
|
|
104204
|
-
value.consentId =
|
|
104435
|
+
value.consentId = id2;
|
|
104205
104436
|
if (action === "list" || action === "occurrences") {
|
|
104206
104437
|
if (options.limit !== undefined) {
|
|
104207
104438
|
if (!/^[1-9]\d{0,2}$/.test(options.limit))
|
|
@@ -104783,12 +105014,12 @@ function registerCreateSync(parent) {
|
|
|
104783
105014
|
const configCmd = parent.command("config").description("Manage skills configuration");
|
|
104784
105015
|
configCmd.command("show", { isDefault: true }).option("--json", "Output as JSON", false).description("Show current merged configuration").action((options) => {
|
|
104785
105016
|
const config2 = loadConfig();
|
|
104786
|
-
const
|
|
105017
|
+
const keys3 = Object.keys(config2);
|
|
104787
105018
|
if (options.json) {
|
|
104788
105019
|
console.log(JSON.stringify(config2, null, 2));
|
|
104789
105020
|
return;
|
|
104790
105021
|
}
|
|
104791
|
-
if (!
|
|
105022
|
+
if (!keys3.length) {
|
|
104792
105023
|
console.log(source_default.dim("No configuration set"));
|
|
104793
105024
|
return;
|
|
104794
105025
|
}
|
|
@@ -105334,12 +105565,12 @@ var init_agent_integration2 = __esm(() => {
|
|
|
105334
105565
|
});
|
|
105335
105566
|
|
|
105336
105567
|
// src/lib/profile-admin.ts
|
|
105337
|
-
function
|
|
105568
|
+
function id2(value) {
|
|
105338
105569
|
if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(value) || value.includes(".."))
|
|
105339
105570
|
throw new Error("Invalid Skills profile or station id");
|
|
105340
105571
|
return encodeURIComponent(value);
|
|
105341
105572
|
}
|
|
105342
|
-
async function
|
|
105573
|
+
async function request2(path, init = {}) {
|
|
105343
105574
|
const connection = await resolveSkillsConnection();
|
|
105344
105575
|
if (!connection)
|
|
105345
105576
|
throw new Error("Profile administration requires a configured Skills API");
|
|
@@ -105357,7 +105588,7 @@ async function request(path, init = {}) {
|
|
|
105357
105588
|
return JSON.parse(new TextDecoder().decode(await readBoundedResponse(response, MAX_PROFILE_DOCUMENT_BYTES)));
|
|
105358
105589
|
}
|
|
105359
105590
|
async function readSkillProfile(profileId) {
|
|
105360
|
-
const value = await
|
|
105591
|
+
const value = await request2(`/profiles/${id2(profileId)}`);
|
|
105361
105592
|
if (value.id !== profileId || !Array.isArray(value.selections) || value.selections.length > MAX_PROFILE_SELECTIONS || typeof value.revision !== "string")
|
|
105362
105593
|
throw new Error("Invalid Skills profile response");
|
|
105363
105594
|
return value;
|
|
@@ -105365,25 +105596,25 @@ async function readSkillProfile(profileId) {
|
|
|
105365
105596
|
async function saveSkillProfile(profileId, selections, revision) {
|
|
105366
105597
|
if (!Array.isArray(selections) || selections.length > MAX_PROFILE_SELECTIONS)
|
|
105367
105598
|
throw new Error(`A profile requires at most ${MAX_PROFILE_SELECTIONS} exact selections`);
|
|
105368
|
-
|
|
105599
|
+
id2(profileId);
|
|
105369
105600
|
const aliasError = selectionAliasError(selections);
|
|
105370
105601
|
if (aliasError)
|
|
105371
105602
|
throw new Error(aliasError);
|
|
105372
105603
|
if (revision !== undefined)
|
|
105373
|
-
|
|
105604
|
+
id2(revision);
|
|
105374
105605
|
const input3 = { selections }, bodyBytes = profileDocumentBytes(input3);
|
|
105375
105606
|
if (bodyBytes > MAX_PROFILE_DOCUMENT_BYTES)
|
|
105376
105607
|
throw new Error("Profile input exceeds the size limit");
|
|
105377
105608
|
const large = requiresProfileCapacity(selections, bodyBytes);
|
|
105378
|
-
const aliases = selections.some((
|
|
105609
|
+
const aliases = selections.some((selection2) => selection2.aliases?.length);
|
|
105379
105610
|
if (aliases || large) {
|
|
105380
|
-
const capabilities = await
|
|
105611
|
+
const capabilities = await request2("/capabilities");
|
|
105381
105612
|
if (aliases && capabilities?.selectionAliases !== true)
|
|
105382
105613
|
throw new Error("This Skills API does not advertise selection aliases. Upgrade the API before saving this profile.");
|
|
105383
105614
|
if (large)
|
|
105384
105615
|
assertAdvertisedProfileCapacity(capabilities, selections.length, bodyBytes);
|
|
105385
105616
|
}
|
|
105386
|
-
const value = await
|
|
105617
|
+
const value = await request2(`/profiles/${id2(profileId)}`, {
|
|
105387
105618
|
method: "PUT",
|
|
105388
105619
|
headers: revision ? { "If-Match": `"${revision}"` } : { "If-None-Match": "*" },
|
|
105389
105620
|
body: JSON.stringify(input3)
|
|
@@ -105395,7 +105626,7 @@ async function saveSkillProfile(profileId, selections, revision) {
|
|
|
105395
105626
|
return value;
|
|
105396
105627
|
}
|
|
105397
105628
|
async function readStationSkillState(stationId) {
|
|
105398
|
-
const value = await
|
|
105629
|
+
const value = await request2(`/stations/${id2(stationId)}/state`);
|
|
105399
105630
|
if (value.stationId !== stationId || !Array.isArray(value.selections) || value.selections.length > MAX_PROFILE_SELECTIONS)
|
|
105400
105631
|
throw new Error("Invalid Skills station response");
|
|
105401
105632
|
return value;
|
|
@@ -105435,9 +105666,9 @@ function readProfileInput(path) {
|
|
|
105435
105666
|
}
|
|
105436
105667
|
function registerProfiles(parent) {
|
|
105437
105668
|
const profiles = parent.command("profiles").description("Manage exact, shared skill selections through the API");
|
|
105438
|
-
profiles.command("show <id>").option("--json", "Output the profile as JSON", false).option("--save <path>", "Save a private snapshot for review or rollback").action(async (
|
|
105669
|
+
profiles.command("show <id>").option("--json", "Output the profile as JSON", false).option("--save <path>", "Save a private snapshot for review or rollback").action(async (id3, options) => {
|
|
105439
105670
|
try {
|
|
105440
|
-
const profile = await readSkillProfile(
|
|
105671
|
+
const profile = await readSkillProfile(id3), text3 = JSON.stringify(profile, null, 2);
|
|
105441
105672
|
if (options.save)
|
|
105442
105673
|
writeFileSync23(options.save, JSON.stringify(profile), { mode: 384, flag: "wx" });
|
|
105443
105674
|
await writeCliOutput(options.json ? text3 : `${profile.id} at ${profile.revision}: ${profile.selections.map((skill) => `${skill.slug}@${skill.version}`).join(", ")}`);
|
|
@@ -105446,20 +105677,20 @@ function registerProfiles(parent) {
|
|
|
105446
105677
|
process.exitCode = 1;
|
|
105447
105678
|
}
|
|
105448
105679
|
});
|
|
105449
|
-
profiles.command("set <id>").requiredOption("--file <path>", "JSON snapshot with a selections array").option("--if-match <revision>", "Replace only this existing revision; omission creates a new profile").option("--json", "Output the saved profile as JSON", false).description("Create or update a profile; use a saved snapshot with --if-match to roll back").action(async (
|
|
105680
|
+
profiles.command("set <id>").requiredOption("--file <path>", "JSON snapshot with a selections array").option("--if-match <revision>", "Replace only this existing revision; omission creates a new profile").option("--json", "Output the saved profile as JSON", false).description("Create or update a profile; use a saved snapshot with --if-match to roll back").action(async (id3, options) => {
|
|
105450
105681
|
try {
|
|
105451
105682
|
const text3 = readProfileInput(options.file);
|
|
105452
105683
|
const input3 = JSON.parse(text3);
|
|
105453
|
-
const profile = await saveSkillProfile(
|
|
105684
|
+
const profile = await saveSkillProfile(id3, input3.selections, options.ifMatch);
|
|
105454
105685
|
await writeCliOutput(options.json ? JSON.stringify(profile) : `Saved ${profile.id} at ${profile.revision}`);
|
|
105455
105686
|
} catch (error61) {
|
|
105456
105687
|
console.error(error61.message);
|
|
105457
105688
|
process.exitCode = 1;
|
|
105458
105689
|
}
|
|
105459
105690
|
});
|
|
105460
|
-
parent.command("station-state <id>").description("Read this actor's last applied skill selection on a station").option("--json", "Output the station receipt as JSON", false).action(async (
|
|
105691
|
+
parent.command("station-state <id>").description("Read this actor's last applied skill selection on a station").option("--json", "Output the station receipt as JSON", false).action(async (id3) => {
|
|
105461
105692
|
try {
|
|
105462
|
-
await writeCliOutput(JSON.stringify(await readStationSkillState(
|
|
105693
|
+
await writeCliOutput(JSON.stringify(await readStationSkillState(id3), null, 2));
|
|
105463
105694
|
} catch (error61) {
|
|
105464
105695
|
console.error(error61.message);
|
|
105465
105696
|
process.exitCode = 1;
|
|
@@ -105471,6 +105702,76 @@ var init_profiles = __esm(() => {
|
|
|
105471
105702
|
init_profile_limits();
|
|
105472
105703
|
});
|
|
105473
105704
|
|
|
105705
|
+
// src/cli/commands/grants.ts
|
|
105706
|
+
var exports_grants = {};
|
|
105707
|
+
__export(exports_grants, {
|
|
105708
|
+
registerGrants: () => registerGrants
|
|
105709
|
+
});
|
|
105710
|
+
import {
|
|
105711
|
+
constants as constants16,
|
|
105712
|
+
closeSync as closeSync17,
|
|
105713
|
+
fstatSync as fstatSync17,
|
|
105714
|
+
openSync as openSync17,
|
|
105715
|
+
readSync as readSync13,
|
|
105716
|
+
writeFileSync as writeFileSync24
|
|
105717
|
+
} from "fs";
|
|
105718
|
+
function readInput(path) {
|
|
105719
|
+
const fd = openSync17(path, constants16.O_RDONLY | constants16.O_NONBLOCK);
|
|
105720
|
+
try {
|
|
105721
|
+
const stat2 = fstatSync17(fd);
|
|
105722
|
+
if (!stat2.isFile() || stat2.size > MAX_EXECUTION_GRANT_BYTES)
|
|
105723
|
+
throw new Error("Grant input must be a regular file within the policy size limit.");
|
|
105724
|
+
const bytes = Buffer.alloc(MAX_EXECUTION_GRANT_BYTES + 1);
|
|
105725
|
+
let size2 = 0;
|
|
105726
|
+
while (size2 < bytes.length) {
|
|
105727
|
+
const count = readSync13(fd, bytes, size2, bytes.length - size2, null);
|
|
105728
|
+
if (!count)
|
|
105729
|
+
break;
|
|
105730
|
+
size2 += count;
|
|
105731
|
+
}
|
|
105732
|
+
if (size2 > MAX_EXECUTION_GRANT_BYTES)
|
|
105733
|
+
throw new Error("Grant input exceeds the policy size limit.");
|
|
105734
|
+
try {
|
|
105735
|
+
return JSON.parse(new TextDecoder("utf-8", { fatal: true }).decode(bytes.subarray(0, size2)));
|
|
105736
|
+
} catch {
|
|
105737
|
+
throw new Error("Grant input must be a JSON document containing a grants array.");
|
|
105738
|
+
}
|
|
105739
|
+
} finally {
|
|
105740
|
+
closeSync17(fd);
|
|
105741
|
+
}
|
|
105742
|
+
}
|
|
105743
|
+
function registerGrants(parent) {
|
|
105744
|
+
const grants = parent.command("grants").description("Manage shared execution grants containing vault references through the Skills API");
|
|
105745
|
+
grants.command("show <profile>").option("--revision <revision>", "Read an immutable policy revision").option("--save <path>", "Save a private policy snapshot for review or rollback").option("--json", "Output the full policy as JSON", false).action(async (profile, options) => {
|
|
105746
|
+
try {
|
|
105747
|
+
const policy = await readExecutionGrantPolicy(profile, options.revision);
|
|
105748
|
+
if (options.save)
|
|
105749
|
+
writeFileSync24(options.save, JSON.stringify(policy, null, 2), {
|
|
105750
|
+
mode: 384,
|
|
105751
|
+
flag: "wx"
|
|
105752
|
+
});
|
|
105753
|
+
await writeCliOutput(options.json ? JSON.stringify(policy) : `${policy.profileId} at ${policy.revision}: ${policy.grants.length} execution grants`);
|
|
105754
|
+
} catch (error61) {
|
|
105755
|
+
console.error(error61.message);
|
|
105756
|
+
process.exitCode = 1;
|
|
105757
|
+
}
|
|
105758
|
+
});
|
|
105759
|
+
grants.command("set <profile>").requiredOption("--file <path>", "Reviewed JSON policy with a grants array; empty revokes all shared grants").option("--if-match <revision>", "Replace exactly this revision; omission creates the initial policy").option("--json", "Output the saved policy as JSON", false).action(async (profile, options) => {
|
|
105760
|
+
try {
|
|
105761
|
+
const input3 = readInput(options.file);
|
|
105762
|
+
const policy = await saveExecutionGrantPolicy(profile, input3?.grants, options.ifMatch);
|
|
105763
|
+
await writeCliOutput(options.json ? JSON.stringify(policy) : `Saved execution grants for ${policy.profileId} at ${policy.revision}`);
|
|
105764
|
+
} catch (error61) {
|
|
105765
|
+
console.error(error61.message);
|
|
105766
|
+
process.exitCode = 1;
|
|
105767
|
+
}
|
|
105768
|
+
});
|
|
105769
|
+
}
|
|
105770
|
+
var init_grants = __esm(() => {
|
|
105771
|
+
init_execution_grant_client();
|
|
105772
|
+
init_execution_grants();
|
|
105773
|
+
});
|
|
105774
|
+
|
|
105474
105775
|
// src/lib/station-hydrate.ts
|
|
105475
105776
|
import { createHash as createHash20 } from "crypto";
|
|
105476
105777
|
import {
|
|
@@ -105479,7 +105780,7 @@ import {
|
|
|
105479
105780
|
readdirSync as readdirSync20,
|
|
105480
105781
|
readFileSync as readFileSync38,
|
|
105481
105782
|
statSync as statSync20,
|
|
105482
|
-
writeFileSync as
|
|
105783
|
+
writeFileSync as writeFileSync25
|
|
105483
105784
|
} from "fs";
|
|
105484
105785
|
import { dirname as dirname24, join as join52, resolve as resolve16, sep as sep10 } from "path";
|
|
105485
105786
|
function fail4(code2, message, detail = []) {
|
|
@@ -105757,7 +106058,7 @@ function writeStationHydration(options) {
|
|
|
105757
106058
|
};
|
|
105758
106059
|
const hydrationManifestPath = join52(dirname24(cacheRoot), `hydration-${options.stationId}.json`);
|
|
105759
106060
|
mkdirSync24(dirname24(hydrationManifestPath), { recursive: true });
|
|
105760
|
-
|
|
106061
|
+
writeFileSync25(hydrationManifestPath, `${JSON.stringify(hydration, null, 2)}
|
|
105761
106062
|
`);
|
|
105762
106063
|
return {
|
|
105763
106064
|
...base3,
|
|
@@ -105833,7 +106134,7 @@ var init_hydrate = __esm(() => {
|
|
|
105833
106134
|
|
|
105834
106135
|
// src/lib/prepare-skill.ts
|
|
105835
106136
|
import { createHash as createHash21, randomUUID as randomUUID9 } from "crypto";
|
|
105836
|
-
import { chmodSync as chmodSync3, existsSync as existsSync34, lstatSync as lstatSync23, mkdirSync as mkdirSync25, mkdtempSync as mkdtempSync6, readFileSync as readFileSync39, readdirSync as readdirSync21, renameSync as renameSync11, rmSync as rmSync8, writeFileSync as
|
|
106137
|
+
import { chmodSync as chmodSync3, existsSync as existsSync34, lstatSync as lstatSync23, mkdirSync as mkdirSync25, mkdtempSync as mkdtempSync6, readFileSync as readFileSync39, readdirSync as readdirSync21, renameSync as renameSync11, rmSync as rmSync8, writeFileSync as writeFileSync26 } from "fs";
|
|
105837
106138
|
import { tmpdir as tmpdir2 } from "os";
|
|
105838
106139
|
import { dirname as dirname25, isAbsolute as isAbsolute18, join as join53, relative as relative9, resolve as resolve17, sep as sep11 } from "path";
|
|
105839
106140
|
function prepareSkill(name, options) {
|
|
@@ -105881,10 +106182,10 @@ function prepareSkill(name, options) {
|
|
|
105881
106182
|
for (const file2 of before2.files) {
|
|
105882
106183
|
const destination = join53(staging, file2.path);
|
|
105883
106184
|
mkdirSync25(dirname25(destination), { recursive: true });
|
|
105884
|
-
|
|
106185
|
+
writeFileSync26(destination, file2.bytes, { mode: file2.mode });
|
|
105885
106186
|
}
|
|
105886
106187
|
const stagedManifest = join53(staging, "skill.json");
|
|
105887
|
-
|
|
106188
|
+
writeFileSync26(stagedManifest, `${JSON.stringify(candidate, null, 2)}
|
|
105888
106189
|
`);
|
|
105889
106190
|
const contentHash = computeContentHash(staging);
|
|
105890
106191
|
const changed3 = options.version !== previousVersion || kind !== manifest.kind || contentHash !== provenance?.content_hash;
|
|
@@ -105894,7 +106195,7 @@ function prepareSkill(name, options) {
|
|
|
105894
106195
|
candidate.provenance.content_hash = contentHash;
|
|
105895
106196
|
const candidateBytes = `${JSON.stringify(candidate, null, 2)}
|
|
105896
106197
|
`;
|
|
105897
|
-
|
|
106198
|
+
writeFileSync26(stagedManifest, candidateBytes);
|
|
105898
106199
|
validateRawCandidate(candidate);
|
|
105899
106200
|
validateRuntimeEntrypoint(candidate, staging);
|
|
105900
106201
|
const validation = validatePortableSkillDirectory(normalized, staging);
|
|
@@ -105908,7 +106209,7 @@ ${validation.issues.map((issue2) => `${issue2.code}: ${issue2.message}`).join(`
|
|
|
105908
106209
|
if (changed3 && !options.dryRun) {
|
|
105909
106210
|
const temporary = join53(path, `.skill-prepare-${randomUUID9()}.tmp`);
|
|
105910
106211
|
try {
|
|
105911
|
-
|
|
106212
|
+
writeFileSync26(temporary, candidateBytes, { flag: "wx", mode: manifestFile.mode });
|
|
105912
106213
|
chmodSync3(temporary, manifestFile.mode);
|
|
105913
106214
|
renameSync11(temporary, join53(path, "skill.json"));
|
|
105914
106215
|
} finally {
|
|
@@ -106440,7 +106741,7 @@ var init_schedule = __esm(() => {
|
|
|
106440
106741
|
});
|
|
106441
106742
|
|
|
106442
106743
|
// src/lib/registry-sync.ts
|
|
106443
|
-
import { mkdirSync as mkdirSync26, writeFileSync as
|
|
106744
|
+
import { mkdirSync as mkdirSync26, writeFileSync as writeFileSync27 } from "fs";
|
|
106444
106745
|
import { dirname as dirname26, relative as relative10 } from "path";
|
|
106445
106746
|
function createRegistrySyncArtifact(options = {}) {
|
|
106446
106747
|
const profile = options.profile ?? "all";
|
|
@@ -106499,7 +106800,7 @@ function createRegistrySyncArtifact(options = {}) {
|
|
|
106499
106800
|
}
|
|
106500
106801
|
function writeRegistrySyncArtifact(path, artifact) {
|
|
106501
106802
|
mkdirSync26(dirname26(path), { recursive: true });
|
|
106502
|
-
|
|
106803
|
+
writeFileSync27(path, `${JSON.stringify(artifact, null, 2)}
|
|
106503
106804
|
`);
|
|
106504
106805
|
}
|
|
106505
106806
|
function buildDocs(name) {
|
|
@@ -106564,10 +106865,10 @@ async function handleRegistrySync(options) {
|
|
|
106564
106865
|
await writeJson2(artifact, 2);
|
|
106565
106866
|
return;
|
|
106566
106867
|
}
|
|
106567
|
-
const
|
|
106868
|
+
const invalid7 = artifact.summary.invalidSkillCount ?? "not checked";
|
|
106568
106869
|
console.log(source_default.green(`Registry sync artifact written to ${options.output}`));
|
|
106569
106870
|
console.log(source_default.dim(` Skills: ${artifact.summary.skillCount}`));
|
|
106570
|
-
console.log(source_default.dim(` Invalid: ${
|
|
106871
|
+
console.log(source_default.dim(` Invalid: ${invalid7}`));
|
|
106571
106872
|
}
|
|
106572
106873
|
function registerPull(parent) {
|
|
106573
106874
|
parent.command("pull").argument("[names...]", "Skills to pull from the configured instance (name or name@version)").option("--all", "Pull every skill the instance serves", false).option("--for-machine", "Prepare this machine with the instance's full catalog (implies --all)", false).option("--json", "Output results as JSON", false).option("--selection-profile <id>", "Selection profile for stations using the Skills CLI cache").description("Fetch skills from the configured Skills instance into this machine's corpus").action(async (names, options) => {
|
|
@@ -107527,8 +107828,8 @@ Waiting for authentication...`));
|
|
|
107527
107828
|
}
|
|
107528
107829
|
function registerAuth(parent) {
|
|
107529
107830
|
const auth = parent.command("auth").description("Manage account authentication");
|
|
107530
|
-
const
|
|
107531
|
-
|
|
107831
|
+
const keys3 = auth.command("keys").description("Manage API keys on the configured instance");
|
|
107832
|
+
keys3.command("list").option("--json", "Output as JSON", false).requiredOption("--email <email>", "Account email for fresh reauthentication").requiredOption("--code <code>", "Fresh OTP requested through auth signup/login").action(async (options) => {
|
|
107532
107833
|
try {
|
|
107533
107834
|
const target = await captureProfileWorkspace("List API keys");
|
|
107534
107835
|
target.unchanged();
|
|
@@ -107537,7 +107838,7 @@ function registerAuth(parent) {
|
|
|
107537
107838
|
writeCommandError(error61, "Failed to list API keys", options.json);
|
|
107538
107839
|
}
|
|
107539
107840
|
});
|
|
107540
|
-
|
|
107841
|
+
keys3.command("create").argument("<name>").option("--scope <scope>", "Limit key scope (repeatable)", (value, all) => [...all, value], []).option("--json", "Output the newly created key as JSON", false).requiredOption("--email <email>", "Account email for fresh reauthentication").requiredOption("--code <code>", "Fresh OTP requested through auth signup/login").description("Create a key; the returned secret is shown once and must be stored securely").action(async (name, options) => {
|
|
107541
107842
|
try {
|
|
107542
107843
|
const target = await captureProfileWorkspace("Create API key");
|
|
107543
107844
|
const client = new RemoteSkillsAuthClient(target.origin);
|
|
@@ -107548,11 +107849,11 @@ function registerAuth(parent) {
|
|
|
107548
107849
|
writeCommandError(error61, "Failed to create API key", options.json);
|
|
107549
107850
|
}
|
|
107550
107851
|
});
|
|
107551
|
-
|
|
107852
|
+
keys3.command("revoke").argument("<key-id>").option("--json", "Output as JSON", false).requiredOption("--email <email>", "Account email for fresh reauthentication").requiredOption("--code <code>", "Fresh OTP requested through auth signup/login").action(async (id3, options) => {
|
|
107552
107853
|
try {
|
|
107553
107854
|
const target = await captureProfileWorkspace("Revoke API key");
|
|
107554
107855
|
target.unchanged();
|
|
107555
|
-
console.log(JSON.stringify(await new RemoteSkillsAuthClient(target.origin).revokeApiKey(options.email, options.code,
|
|
107856
|
+
console.log(JSON.stringify(await new RemoteSkillsAuthClient(target.origin).revokeApiKey(options.email, options.code, id3, target.context), null, 2));
|
|
107556
107857
|
} catch (error61) {
|
|
107557
107858
|
writeCommandError(error61, "Failed to revoke API key", options.json);
|
|
107558
107859
|
}
|
|
@@ -107905,13 +108206,13 @@ function registerWorkspaceInvitationCommands(workspace) {
|
|
|
107905
108206
|
else
|
|
107906
108207
|
command.option("--code-stdin", "Read a previously requested six-digit verification code from stdin");
|
|
107907
108208
|
command.action(async (...args2) => {
|
|
107908
|
-
const
|
|
108209
|
+
const id3 = targeted ? String(args2[0]) : undefined, options = args2[targeted ? 1 : 0];
|
|
107909
108210
|
try {
|
|
107910
108211
|
if (mutation && options.confirm !== true)
|
|
107911
108212
|
throw new WorkspaceInvitationInputError;
|
|
107912
|
-
let input3 = action === "list" ? { ...options.after === undefined ? {} : { after: options.after } } : action === "get" ? { invitationId:
|
|
108213
|
+
let input3 = action === "list" ? { ...options.after === undefined ? {} : { after: options.after } } : action === "get" ? { invitationId: id3 } : action === "issue" ? { email: options.recipient, role: options.role, idempotencyKey: options.idempotencyKey, confirm: true } : action === "resend" ? { invitationId: id3, expectedGeneration: Number(options.expectedGeneration), idempotencyKey: options.idempotencyKey, confirm: true } : action === "revoke" ? { invitationId: id3, expectedGeneration: Number(options.expectedGeneration), confirm: true } : { invitationId: id3, token: "", confirm: true };
|
|
107913
108214
|
if (action === "accept")
|
|
107914
|
-
invitationId(
|
|
108215
|
+
invitationId(id3);
|
|
107915
108216
|
else
|
|
107916
108217
|
input3 = invitationInput(action, input3);
|
|
107917
108218
|
const context2 = invitationProfileContext(options.userId, options.membershipId);
|
|
@@ -107942,7 +108243,7 @@ function registerWorkspaceInvitationCommands(workspace) {
|
|
|
107942
108243
|
if (code2 === null)
|
|
107943
108244
|
return;
|
|
107944
108245
|
if (action === "accept")
|
|
107945
|
-
input3 = invitationInput("accept", { invitationId:
|
|
108246
|
+
input3 = invitationInput("accept", { invitationId: id3, token, confirm: true });
|
|
107946
108247
|
target.unchanged();
|
|
107947
108248
|
const result2 = await invokeFreshInvitation(client, options.email, code2, context2, action, input3);
|
|
107948
108249
|
console.log(JSON.stringify(result2, null, options.json ? undefined : 2));
|
|
@@ -108332,7 +108633,7 @@ var init_storage2 = __esm(() => {
|
|
|
108332
108633
|
});
|
|
108333
108634
|
|
|
108334
108635
|
// src/lib/registry-reconcile.ts
|
|
108335
|
-
import { existsSync as existsSync36, readFileSync as readFileSync41, statSync as statSync21, writeFileSync as
|
|
108636
|
+
import { existsSync as existsSync36, readFileSync as readFileSync41, statSync as statSync21, writeFileSync as writeFileSync28 } from "fs";
|
|
108336
108637
|
import { join as join55 } from "path";
|
|
108337
108638
|
function isDirectory2(path) {
|
|
108338
108639
|
try {
|
|
@@ -108647,7 +108948,7 @@ async function reconcileRegistry(options = {}) {
|
|
|
108647
108948
|
runCount: readCursor(root).runCount + 1,
|
|
108648
108949
|
summary
|
|
108649
108950
|
};
|
|
108650
|
-
|
|
108951
|
+
writeFileSync28(join55(root, SYNC_CURSOR_FILE), `${JSON.stringify(cursor2, null, 2)}
|
|
108651
108952
|
`);
|
|
108652
108953
|
return {
|
|
108653
108954
|
corpusRoot: root,
|
|
@@ -116606,6 +116907,8 @@ var { registerAgentIntegration: registerAgentIntegration2 } = await Promise.reso
|
|
|
116606
116907
|
registerAgentIntegration2(program2);
|
|
116607
116908
|
var { registerProfiles: registerProfiles2 } = await Promise.resolve().then(() => (init_profiles(), exports_profiles));
|
|
116608
116909
|
registerProfiles2(program2);
|
|
116910
|
+
var { registerGrants: registerGrants2 } = await Promise.resolve().then(() => (init_grants(), exports_grants));
|
|
116911
|
+
registerGrants2(program2);
|
|
116609
116912
|
var { registerHydrate: registerHydrate2 } = await Promise.resolve().then(() => (init_hydrate(), exports_hydrate));
|
|
116610
116913
|
registerHydrate2(program2);
|
|
116611
116914
|
var { registerPortableSkillCommands: registerPortableSkillCommands2 } = await Promise.resolve().then(() => (init_portable_skills2(), exports_portable_skills));
|