@tenkicloud/mcp 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -145
- package/README.md +5 -8
- package/dist/client.d.ts +23 -5
- package/dist/client.js +76 -11
- package/dist/index.js +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +2 -4
- package/dist/tools/auth_status.js +1 -1
- package/dist/tools/common.d.ts +3 -1
- package/dist/tools/common.js +20 -2
- package/dist/tools/exec.js +38 -6
- package/dist/tools/git.js +1 -1
- package/dist/tools/previews.d.ts +4 -4
- package/dist/tools/previews.js +15 -37
- package/dist/tools/run.js +1 -1
- package/dist/tools/sandboxes.js +26 -20
- package/dist/tools/sessions_admin.d.ts +1 -1
- package/dist/tools/sessions_admin.js +1 -15
- package/dist/tools/snapshots.js +0 -12
- package/dist/tools/templates.js +14 -23
- package/dist/tools/volumes.d.ts +1 -1
- package/dist/tools/volumes.js +3 -20
- package/package.json +5 -5
- package/dist/tools/registry.d.ts +0 -18
- package/dist/tools/registry.js +0 -98
package/dist/tools/registry.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { ok } from "./common.js";
|
|
3
|
-
const VISIBILITY = { public: "REGISTRY_VISIBILITY_PUBLIC", private: "REGISTRY_VISIBILITY_PRIVATE" };
|
|
4
|
-
const IMAGE_KIND = { snapshot: "REGISTRY_IMAGE_KIND_SNAPSHOT", template: "REGISTRY_IMAGE_KIND_TEMPLATE" };
|
|
5
|
-
export function registerRegistry(server, client) {
|
|
6
|
-
// ── Publish ─────────────────────────────────────────────────────────────────
|
|
7
|
-
server.tool("tenki_publish_image", "Publish a custom sandbox image into the workspace registry from a snapshot or a template.", {
|
|
8
|
-
reference: z
|
|
9
|
-
.string()
|
|
10
|
-
.regex(/^[^:@]+$/, "publish takes the TAGLESS form <workspace>/<artifact> — the API rejects a tag or @snapshot here")
|
|
11
|
-
.describe("Target image reference in TAGLESS form <workspace>/<artifact>, e.g. myws/myimage — the API rejects a tag or @snapshot on publish."),
|
|
12
|
-
kind: z.enum(["snapshot", "template"]).describe("Source kind for the image contents."),
|
|
13
|
-
snapshot_id: z.string().optional().describe("Snapshot id to publish (required when kind=snapshot)."),
|
|
14
|
-
source_template_id: z.string().optional().describe("Template id to publish (required when kind=template)."),
|
|
15
|
-
visibility: z.enum(["public", "private"]).optional().describe("public (resolvable by anyone) or private (default)."),
|
|
16
|
-
}, async ({ reference, kind, snapshot_id, source_template_id, visibility }) => ok(await client.control("PublishRegistryImage", {
|
|
17
|
-
ref: reference,
|
|
18
|
-
kind: IMAGE_KIND[kind],
|
|
19
|
-
...(snapshot_id !== undefined ? { snapshotId: snapshot_id } : {}),
|
|
20
|
-
...(source_template_id !== undefined ? { sourceTemplateId: source_template_id } : {}),
|
|
21
|
-
...(visibility !== undefined ? { visibility: VISIBILITY[visibility] } : {}),
|
|
22
|
-
})));
|
|
23
|
-
// ── Get ─────────────────────────────────────────────────────────────────────
|
|
24
|
-
server.tool("tenki_get_image", "Retrieve one custom sandbox image from the registry by its reference.", { reference: z.string().describe("Image reference <workspace>/<artifact>[:tag].") }, async ({ reference }) => ok(await client.control("GetRegistryImage", { ref: reference })));
|
|
25
|
-
// ── List ────────────────────────────────────────────────────────────────────
|
|
26
|
-
server.tool("tenki_list_images", "List custom sandbox images in the registry, optionally filtered to a single workspace.", {
|
|
27
|
-
workspace_id: z.string().optional().describe("Optional workspace to filter the listed images by."),
|
|
28
|
-
page_size: z.number().int().positive().optional().describe("Max images to return per page."),
|
|
29
|
-
page_token: z.string().optional().describe("Pagination token from a previous response's nextPageToken."),
|
|
30
|
-
}, async ({ workspace_id, page_size, page_token }) => ok(await client.control("ListRegistryImages", {
|
|
31
|
-
...(workspace_id !== undefined ? { workspaceId: workspace_id } : {}),
|
|
32
|
-
...(page_size !== undefined ? { pageSize: page_size } : {}),
|
|
33
|
-
...(page_token !== undefined ? { pageToken: page_token } : {}),
|
|
34
|
-
})));
|
|
35
|
-
// ── Set visibility ────────────────────────────────────────────────────────────
|
|
36
|
-
server.tool("tenki_set_image_visibility", "Make a custom sandbox image public (publicly resolvable) or private (restricted to the workspace).", {
|
|
37
|
-
reference: z.string().describe("Image reference <workspace>/<artifact>[:tag]."),
|
|
38
|
-
visibility: z.enum(["public", "private"]).describe("Target visibility for the image."),
|
|
39
|
-
}, async ({ reference, visibility }) => ok(await client.control("SetRegistryImageVisibility", { ref: reference, visibility: VISIBILITY[visibility] })));
|
|
40
|
-
// ── Delete (whole image by ref, or one version by ids) ─────────────────────────
|
|
41
|
-
server.tool("tenki_delete_image", "Delete a custom sandbox image (by reference), or delete a single version (by image_id + snapshot_id).", {
|
|
42
|
-
reference: z.string().optional().describe("Image reference to delete the whole image."),
|
|
43
|
-
image_id: z.string().optional().describe("Image UUID (with snapshot_id) to delete a single version."),
|
|
44
|
-
snapshot_id: z.string().optional().describe("Snapshot UUID (with image_id) to delete a single version."),
|
|
45
|
-
}, async ({ reference, image_id, snapshot_id }) => {
|
|
46
|
-
if (image_id !== undefined && snapshot_id !== undefined) {
|
|
47
|
-
return ok(await client.control("DeleteRegistryImageVersion", { imageId: image_id, snapshotId: snapshot_id }));
|
|
48
|
-
}
|
|
49
|
-
if (reference !== undefined)
|
|
50
|
-
return ok(await client.control("DeleteRegistryImage", { ref: reference }));
|
|
51
|
-
throw new Error("Provide `reference` to delete an image, or `image_id`+`snapshot_id` to delete one version.");
|
|
52
|
-
});
|
|
53
|
-
// ── Resolve ref ────────────────────────────────────────────────────────────────
|
|
54
|
-
server.tool("tenki_resolve_image_ref", "Resolve a registry reference (tag or ref) to its concrete pinned digest/ref.", { registry_ref: z.string().describe("The registry reference to resolve, e.g. myws/myimage:latest.") }, async ({ registry_ref }) => {
|
|
55
|
-
const owner = await client.resolveOwner();
|
|
56
|
-
return ok(await client.control("ResolveRegistryRef", {
|
|
57
|
-
ref: registry_ref,
|
|
58
|
-
...(owner.workspaceId ? { workspaceId: owner.workspaceId } : {}),
|
|
59
|
-
}));
|
|
60
|
-
});
|
|
61
|
-
// ── Share ──────────────────────────────────────────────────────────────────────
|
|
62
|
-
server.tool("tenki_share_image", "Grant another workspace access to a custom sandbox image.", {
|
|
63
|
-
reference: z.string().describe("Image reference <workspace>/<artifact>[:tag]."),
|
|
64
|
-
grantee_workspace_id: z.string().describe("The workspace to grant access to."),
|
|
65
|
-
},
|
|
66
|
-
// ShareImage uses imageRef + targetWorkspaceId (not ref/granteeWorkspaceId).
|
|
67
|
-
async ({ reference, grantee_workspace_id }) => ok(await client.control("ShareImage", { imageRef: reference, targetWorkspaceId: grantee_workspace_id })));
|
|
68
|
-
// ── Unshare (revoke a share) ────────────────────────────────────────────────────
|
|
69
|
-
server.tool("tenki_unshare_image", "Revoke a previously-granted share on a custom sandbox image, by grant id or grantee workspace.", {
|
|
70
|
-
reference: z.string().describe("Image reference (use the TAGLESS <workspace>/<artifact> form)."),
|
|
71
|
-
grant_id: z.string().optional().describe("Specific share grant to revoke (preferred; provide this or grantee_workspace_id)."),
|
|
72
|
-
grantee_workspace_id: z.string().optional().describe("Workspace whose access to revoke."),
|
|
73
|
-
}, async ({ reference, grant_id, grantee_workspace_id }) => {
|
|
74
|
-
// Without one of these the server revokes nothing and still returns the
|
|
75
|
-
// image object, which reads as a successful revoke. Mirror the guard
|
|
76
|
-
// tenki_delete_image already applies to its own one-of.
|
|
77
|
-
if (!grant_id && !grantee_workspace_id) {
|
|
78
|
-
throw new Error("tenki_unshare_image: pass grant_id (preferred) or grantee_workspace_id. With neither, the API revokes nothing and returns the image unchanged, which looks like success.");
|
|
79
|
-
}
|
|
80
|
-
return ok(await client.control("UnshareRegistryImage", {
|
|
81
|
-
ref: reference,
|
|
82
|
-
...(grant_id !== undefined ? { grantId: grant_id } : {}),
|
|
83
|
-
...(grantee_workspace_id !== undefined ? { targetWorkspaceId: grantee_workspace_id } : {}),
|
|
84
|
-
}));
|
|
85
|
-
});
|
|
86
|
-
// ── List share grants ───────────────────────────────────────────────────────────
|
|
87
|
-
server.tool("tenki_list_image_share_grants", "List the share grants (workspaces granted access) on a custom sandbox image.", {
|
|
88
|
-
reference: z.string().describe("Image reference to list grants for (use the TAGLESS <workspace>/<artifact> form)."),
|
|
89
|
-
page_size: z.number().int().positive().optional().describe("Max grants to return per page."),
|
|
90
|
-
page_token: z.string().optional().describe("Pagination token from a previous response's nextPageToken."),
|
|
91
|
-
}, async ({ reference, page_size, page_token }) => ok(await client.control("ListRegistryShareGrants", {
|
|
92
|
-
ref: reference,
|
|
93
|
-
...(page_size !== undefined ? { pageSize: page_size } : {}),
|
|
94
|
-
...(page_token !== undefined ? { pageToken: page_token } : {}),
|
|
95
|
-
})));
|
|
96
|
-
// ── Revoke a specific share grant (by grant id) ─────────────────────────────────
|
|
97
|
-
server.tool("tenki_revoke_image_share_grant", "Revoke a specific registry-image share grant by its grant id.", { grant_id: z.string().describe("The share grant id (UUID) to revoke.") }, async ({ grant_id }) => ok(await client.control("RevokeRegistryShareGrant", { grantId: grant_id })));
|
|
98
|
-
}
|