@sandbaseai/cli 0.1.7 → 0.1.9
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/assets/mcp-bridge.mjs +116 -7
- package/dist/a1-adapters.d.ts +40 -0
- package/dist/a1-adapters.js +313 -0
- package/dist/adapters/index.d.ts +1 -0
- package/dist/adapters/index.js +68 -8
- package/dist/b-adapters.d.ts +35 -0
- package/dist/b-adapters.js +167 -0
- package/dist/c-adapters.d.ts +41 -0
- package/dist/c-adapters.js +269 -0
- package/dist/claude-desktop.d.ts +61 -0
- package/dist/claude-desktop.js +50 -0
- package/dist/cli.js +22 -5
- package/dist/clients.d.ts +1 -1
- package/dist/clients.js +53 -32
- package/dist/commands.d.ts +11 -3
- package/dist/commands.js +486 -20
- package/dist/cowork.d.ts +53 -0
- package/dist/cowork.js +46 -0
- package/dist/desktop-bridge.d.ts +28 -0
- package/dist/desktop-bridge.js +27 -0
- package/dist/kiro-ide.d.ts +26 -0
- package/dist/kiro-ide.js +100 -0
- package/dist/paths.js +28 -3
- package/dist/skills-cli.d.ts +41 -0
- package/dist/skills-cli.js +213 -7
- package/dist/skills.js +16 -5
- package/dist/types.d.ts +7 -1
- package/dist/types.js +5 -1
- package/dist/warp-adapter.d.ts +26 -0
- package/dist/warp-adapter.js +154 -0
- package/package.json +2 -1
package/dist/cowork.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare const coworkMCPConfig = "{\n \"mcpServers\": {\n \"sandbase\": {\n \"command\": \"npx\",\n \"args\": [\"-y\", \"@sandbaseai/cli\", \"mcp-bridge\", \"--client\", \"cowork\"]\n }\n }\n}\n";
|
|
2
|
+
interface Source {
|
|
3
|
+
repository: string;
|
|
4
|
+
ref: string;
|
|
5
|
+
commit: string;
|
|
6
|
+
path: string;
|
|
7
|
+
}
|
|
8
|
+
interface Artifact {
|
|
9
|
+
kind: string;
|
|
10
|
+
version: string;
|
|
11
|
+
filename: string;
|
|
12
|
+
media_type: string;
|
|
13
|
+
sha256: string;
|
|
14
|
+
download_url: string;
|
|
15
|
+
source?: Source;
|
|
16
|
+
}
|
|
17
|
+
export interface CoworkManifest {
|
|
18
|
+
client: string;
|
|
19
|
+
artifacts: Artifact[];
|
|
20
|
+
}
|
|
21
|
+
export type CoworkStatus = "ready" | "missing" | "invalid";
|
|
22
|
+
export interface CoworkStateReadback {
|
|
23
|
+
ownership: CoworkStatus;
|
|
24
|
+
mcp: CoworkStatus;
|
|
25
|
+
skill: CoworkStatus;
|
|
26
|
+
admin: "confirmed" | "required" | "invalid";
|
|
27
|
+
}
|
|
28
|
+
export declare function coworkStatePath(home?: string): string;
|
|
29
|
+
export declare function readCoworkState(home?: string): Promise<CoworkStateReadback>;
|
|
30
|
+
export declare function recordCoworkArtifacts(manifest: CoworkManifest, mcpBytes?: Uint8Array, skillBytes?: Uint8Array, home?: string): Promise<{
|
|
31
|
+
path: string;
|
|
32
|
+
previous?: string;
|
|
33
|
+
changed: boolean;
|
|
34
|
+
readback: {
|
|
35
|
+
mcp: CoworkStatus;
|
|
36
|
+
skill: CoworkStatus;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
export declare function confirmCoworkAdministrator(input: {
|
|
40
|
+
mechanism: string;
|
|
41
|
+
approved: boolean;
|
|
42
|
+
}, home?: string): Promise<{
|
|
43
|
+
path: string;
|
|
44
|
+
previous?: string;
|
|
45
|
+
changed: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
export declare function rollbackCoworkState(result: {
|
|
48
|
+
path: string;
|
|
49
|
+
previous?: string;
|
|
50
|
+
changed: boolean;
|
|
51
|
+
}): Promise<void>;
|
|
52
|
+
export declare function removeCoworkState(home?: string): Promise<boolean>;
|
|
53
|
+
export {};
|
package/dist/cowork.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import { rm } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { atomicWrite, readOptional } from "./fs-safe.js";
|
|
5
|
+
import { sandbaseHome } from "./paths.js";
|
|
6
|
+
const owner = "sandbase-cli/cowork-connector";
|
|
7
|
+
const repository = "https://github.com/sandbaseai/sandbase-skills";
|
|
8
|
+
const commit = "a43b2272473615137c86637423285a641f64f64c";
|
|
9
|
+
const skillDigest = "4e32edb4f2f158333a19c7f64e777f354914adccd61314250770e2db7ff93087";
|
|
10
|
+
const mcpDigest = "d6a9cf4f1d4a8a3f3e7794f9996d7d35edd145efa5922c2e70e5f6f83559bae0";
|
|
11
|
+
export const coworkMCPConfig = '{\n "mcpServers": {\n "sandbase": {\n "command": "npx",\n "args": ["-y", "@sandbaseai/cli", "mcp-bridge", "--client", "cowork"]\n }\n }\n}\n';
|
|
12
|
+
const mcpState = { version: "1", sha256: mcpDigest };
|
|
13
|
+
const skillState = { version: "a43b227", sha256: skillDigest, source: { repository, ref: commit, commit, path: "SKILL.md" } };
|
|
14
|
+
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
15
|
+
export function coworkStatePath(home = sandbaseHome()) { return join(home, "desktop", "cowork-connector.json"); }
|
|
16
|
+
function inspect(manifest, mcpBytes, skillBytes) { if (manifest?.client !== "cowork" || manifest.artifacts?.length !== 2)
|
|
17
|
+
return { mcp: manifest ? "invalid" : "missing", skill: manifest ? "invalid" : "missing" }; const mcp = manifest.artifacts.find(a => a.kind === "mcp-config"), skill = manifest.artifacts.find(a => a.kind === "skill"), source = skill?.source; const mcpReady = !!mcp && !!mcpBytes && mcp.version === "1" && mcp.filename === "sandbase-cowork-mcp.json" && mcp.media_type === "application/json" && mcp.sha256 === mcpDigest && mcp.download_url === "/default/v1/desktop-onboarding/cowork/artifacts/mcp-config" && sha256(mcpBytes) === mcpDigest && Buffer.from(mcpBytes).toString("utf8") === coworkMCPConfig; const skillReady = !!skill && !!skillBytes && skill.version === "a43b227" && skill.filename === "sandbase-skill.zip" && skill.media_type === "application/zip" && skill.sha256 === skillDigest && skill.download_url === "/default/v1/desktop-onboarding/cowork/artifacts/skill" && source?.repository === repository && source.ref === commit && source.commit === commit && source.path === "SKILL.md" && sha256(skillBytes) === skillDigest; return { mcp: !mcp || !mcpBytes ? "missing" : mcpReady ? "ready" : "invalid", skill: !skill || !skillBytes ? "missing" : skillReady ? "ready" : "invalid" }; }
|
|
18
|
+
function valid(value) { if (!value || typeof value !== "object" || Array.isArray(value))
|
|
19
|
+
return false; const s = value; return s.schemaVersion === 1 && s.owner === owner && s.client === "cowork" && s.mechanism === "account_workspace_admin" && (!s.mcp || JSON.stringify(s.mcp) === JSON.stringify(mcpState)) && (!s.skill || JSON.stringify(s.skill) === JSON.stringify(skillState)) && (s.adminConfirmed === undefined || s.adminConfirmed === true); }
|
|
20
|
+
export async function readCoworkState(home = sandbaseHome()) { const raw = await readOptional(coworkStatePath(home)); if (!raw)
|
|
21
|
+
return { ownership: "missing", mcp: "missing", skill: "missing", admin: "required" }; try {
|
|
22
|
+
const state = JSON.parse(raw);
|
|
23
|
+
if (!valid(state))
|
|
24
|
+
return { ownership: "invalid", mcp: "invalid", skill: "invalid", admin: "invalid" };
|
|
25
|
+
return { ownership: "ready", mcp: state.mcp ? "ready" : "missing", skill: state.skill ? "ready" : "missing", admin: state.adminConfirmed ? "confirmed" : "required" };
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return { ownership: "invalid", mcp: "invalid", skill: "invalid", admin: "invalid" };
|
|
29
|
+
} }
|
|
30
|
+
async function update(home, mutate) { const path = coworkStatePath(home), previous = await readOptional(path), status = await readCoworkState(home); if (previous && status.ownership === "invalid")
|
|
31
|
+
throw new Error("Cowork connector ownership is unrecognized; no changes were made"); const state = previous ? JSON.parse(previous) : { schemaVersion: 1, owner, client: "cowork", mechanism: "account_workspace_admin" }; mutate(state); const next = JSON.stringify(state, null, 2) + "\n"; if (next === previous)
|
|
32
|
+
return { path, previous, changed: false }; await atomicWrite(path, next, 0o600); return { path, ...(previous === undefined ? {} : { previous }), changed: true }; }
|
|
33
|
+
export async function recordCoworkArtifacts(manifest, mcpBytes, skillBytes, home = sandbaseHome()) { const readback = inspect(manifest, mcpBytes, skillBytes); if (readback.mcp !== "ready" && readback.skill !== "ready")
|
|
34
|
+
return { path: coworkStatePath(home), changed: false, readback }; const result = await update(home, state => { if (readback.mcp === "ready")
|
|
35
|
+
state.mcp = mcpState; if (readback.skill === "ready")
|
|
36
|
+
state.skill = skillState; }); return { ...result, readback }; }
|
|
37
|
+
export async function confirmCoworkAdministrator(input, home = sandbaseHome()) { if (input.mechanism !== "account_workspace_admin" || input.approved !== true)
|
|
38
|
+
throw new Error("Cowork requires explicit account/workspace administrator confirmation; no changes were made"); return update(home, state => { state.adminConfirmed = true; }); }
|
|
39
|
+
export async function rollbackCoworkState(result) { if (!result.changed)
|
|
40
|
+
return; if (result.previous === undefined)
|
|
41
|
+
await rm(result.path, { force: true });
|
|
42
|
+
else
|
|
43
|
+
await atomicWrite(result.path, result.previous, 0o600); }
|
|
44
|
+
export async function removeCoworkState(home = sandbaseHome()) { const status = await readCoworkState(home); if (status.ownership === "missing")
|
|
45
|
+
return false; if (status.ownership === "invalid")
|
|
46
|
+
throw new Error("Cowork connector ownership is unrecognized; no changes were made"); await rm(coworkStatePath(home)); return true; }
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Client } from "./types.js";
|
|
2
|
+
export type DesktopClient = Extract<Client, "claude-desktop" | "cowork">;
|
|
3
|
+
export declare const desktopClients: readonly DesktopClient[];
|
|
4
|
+
declare const owner = "sandbase-cli/desktop-bridge";
|
|
5
|
+
export interface DesktopBridgeIdentity {
|
|
6
|
+
schemaVersion: 1;
|
|
7
|
+
owner: typeof owner;
|
|
8
|
+
client: DesktopClient;
|
|
9
|
+
launcher: "sandbase-mcp-bridge.mjs";
|
|
10
|
+
mcpArtifact: "mcp-config";
|
|
11
|
+
skillArtifact: "skill";
|
|
12
|
+
}
|
|
13
|
+
export declare function isDesktopClient(client: Client): client is DesktopClient;
|
|
14
|
+
export declare function desktopIdentityPath(client: DesktopClient, home?: string): string;
|
|
15
|
+
export declare function expectedDesktopIdentity(client: DesktopClient): DesktopBridgeIdentity;
|
|
16
|
+
export declare function readDesktopIdentity(client: DesktopClient, home?: string): Promise<"ready" | "missing" | "invalid">;
|
|
17
|
+
export declare function writeDesktopIdentity(client: DesktopClient, home?: string): Promise<{
|
|
18
|
+
path: string;
|
|
19
|
+
previous?: string;
|
|
20
|
+
changed: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
export declare function rollbackDesktopIdentity(result: {
|
|
23
|
+
path: string;
|
|
24
|
+
previous?: string;
|
|
25
|
+
changed: boolean;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
export declare function removeDesktopIdentity(client: DesktopClient, home?: string): Promise<boolean>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { rm } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { atomicWrite, readOptional } from "./fs-safe.js";
|
|
4
|
+
import { sandbaseHome } from "./paths.js";
|
|
5
|
+
export const desktopClients = ["claude-desktop", "cowork"];
|
|
6
|
+
const owner = "sandbase-cli/desktop-bridge";
|
|
7
|
+
export function isDesktopClient(client) { return desktopClients.includes(client); }
|
|
8
|
+
export function desktopIdentityPath(client, home = sandbaseHome()) { return join(home, "desktop", `${client}.json`); }
|
|
9
|
+
export function expectedDesktopIdentity(client) { return { schemaVersion: 1, owner, client, launcher: "sandbase-mcp-bridge.mjs", mcpArtifact: "mcp-config", skillArtifact: "skill" }; }
|
|
10
|
+
export async function readDesktopIdentity(client, home = sandbaseHome()) { const raw = await readOptional(desktopIdentityPath(client, home)); if (!raw)
|
|
11
|
+
return "missing"; try {
|
|
12
|
+
return JSON.stringify(JSON.parse(raw)) === JSON.stringify(expectedDesktopIdentity(client)) ? "ready" : "invalid";
|
|
13
|
+
}
|
|
14
|
+
catch {
|
|
15
|
+
return "invalid";
|
|
16
|
+
} }
|
|
17
|
+
export async function writeDesktopIdentity(client, home = sandbaseHome()) { const path = desktopIdentityPath(client, home); const previous = await readOptional(path); if (previous && await readDesktopIdentity(client, home) === "invalid")
|
|
18
|
+
throw new Error(`${client} SandBase artifact identity is unrecognized; no changes were made`); const next = JSON.stringify(expectedDesktopIdentity(client), null, 2) + "\n"; if (previous === next)
|
|
19
|
+
return { path, previous, changed: false }; await atomicWrite(path, next, 0o600); return { path, ...(previous === undefined ? {} : { previous }), changed: true }; }
|
|
20
|
+
export async function rollbackDesktopIdentity(result) { if (!result.changed)
|
|
21
|
+
return; if (result.previous === undefined)
|
|
22
|
+
await rm(result.path, { force: true });
|
|
23
|
+
else
|
|
24
|
+
await atomicWrite(result.path, result.previous, 0o600); }
|
|
25
|
+
export async function removeDesktopIdentity(client, home = sandbaseHome()) { const state = await readDesktopIdentity(client, home); if (state === "missing")
|
|
26
|
+
return false; if (state === "invalid")
|
|
27
|
+
throw new Error(`${client} SandBase artifact identity is unrecognized; no changes were made`); await rm(desktopIdentityPath(client, home)); return true; }
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type KiroIDEState = "missing" | "configured" | "confirmation_required" | "conflict" | "invalid";
|
|
2
|
+
export interface KiroIDEInspection {
|
|
3
|
+
state: KiroIDEState;
|
|
4
|
+
detail: string;
|
|
5
|
+
}
|
|
6
|
+
export interface KiroIDEResult {
|
|
7
|
+
path: string;
|
|
8
|
+
changed: boolean;
|
|
9
|
+
backup?: string;
|
|
10
|
+
identityPath: string;
|
|
11
|
+
identityChanged: boolean;
|
|
12
|
+
identityPrevious?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface KiroIDEUnregisterSnapshot {
|
|
15
|
+
path: string;
|
|
16
|
+
config: string;
|
|
17
|
+
identityPath: string;
|
|
18
|
+
identity: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function findKiroWorkspaceOverride(env?: NodeJS.ProcessEnv): Promise<string | undefined>;
|
|
21
|
+
export declare function inspectKiroIDE(env?: NodeJS.ProcessEnv, expectedBridge?: string): Promise<KiroIDEInspection>;
|
|
22
|
+
export declare function installKiroIDE(bridge: string, env?: NodeJS.ProcessEnv): Promise<KiroIDEResult>;
|
|
23
|
+
export declare function rollbackKiroIDE(result: KiroIDEResult): Promise<void>;
|
|
24
|
+
export declare function snapshotKiroIDEUnregister(env?: NodeJS.ProcessEnv): Promise<KiroIDEUnregisterSnapshot | undefined>;
|
|
25
|
+
export declare function restoreKiroIDEUnregister(snapshot: KiroIDEUnregisterSnapshot): Promise<void>;
|
|
26
|
+
export declare function unregisterKiroIDE(env?: NodeJS.ProcessEnv): Promise<boolean>;
|
package/dist/kiro-ide.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { dirname, isAbsolute, join } from "node:path";
|
|
2
|
+
import { rm } from "node:fs/promises";
|
|
3
|
+
import { atomicWrite, backup, readOptional, restore } from "./fs-safe.js";
|
|
4
|
+
import { configPath, sandbaseHome } from "./paths.js";
|
|
5
|
+
const marker = "sandbase-cli-kiro-ide-v1";
|
|
6
|
+
const ownerPath = (env = process.env) => join(sandbaseHome(env), "adapters", "kiro.json");
|
|
7
|
+
function object(value, label) { if (!value || typeof value !== "object" || Array.isArray(value))
|
|
8
|
+
throw new Error(`${label} must be an object`); return value; }
|
|
9
|
+
function root(raw, label) { return object(JSON.parse(raw), label); }
|
|
10
|
+
function entry(bridge) { return { command: "node", args: [bridge, "--client", "kiro"] }; }
|
|
11
|
+
function owned(value, bridge) { if (!value || typeof value !== "object" || Array.isArray(value))
|
|
12
|
+
return false; const candidate = value; return candidate.command === "node" && Array.isArray(candidate.args) && candidate.args.length === 3 && candidate.args[0] === bridge && candidate.args[1] === "--client" && candidate.args[2] === "kiro"; }
|
|
13
|
+
async function identity(env = process.env) { const raw = await readOptional(ownerPath(env)); if (raw === undefined)
|
|
14
|
+
return undefined; try {
|
|
15
|
+
const value = root(raw, "Kiro IDE identity");
|
|
16
|
+
return value.marker === marker && value.client === "kiro" && typeof value.bridge === "string" && isAbsolute(value.bridge) ? { bridge: value.bridge } : undefined;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return undefined;
|
|
20
|
+
} }
|
|
21
|
+
function parents(start) { const out = []; let current = start; for (;;) {
|
|
22
|
+
out.push(current);
|
|
23
|
+
const parent = dirname(current);
|
|
24
|
+
if (parent === current)
|
|
25
|
+
return out;
|
|
26
|
+
current = parent;
|
|
27
|
+
} }
|
|
28
|
+
export async function findKiroWorkspaceOverride(env = process.env) { const global = configPath("kiro", env); for (const directory of parents(env.PWD || process.cwd())) {
|
|
29
|
+
const path = join(directory, ".kiro", "settings", "mcp.json"), raw = await readOptional(path);
|
|
30
|
+
if (raw === undefined || path === global)
|
|
31
|
+
continue;
|
|
32
|
+
const parsed = root(raw, "Kiro workspace configuration"), servers = parsed.mcpServers === undefined ? {} : object(parsed.mcpServers, "Kiro workspace mcpServers");
|
|
33
|
+
if (servers.sandbase !== undefined)
|
|
34
|
+
return path;
|
|
35
|
+
} return undefined; }
|
|
36
|
+
export async function inspectKiroIDE(env = process.env, expectedBridge) { try {
|
|
37
|
+
const override = await findKiroWorkspaceOverride(env);
|
|
38
|
+
if (override)
|
|
39
|
+
return { state: "confirmation_required", detail: `higher-priority Kiro workspace SandBase entry at ${override} was left untouched` };
|
|
40
|
+
const raw = await readOptional(configPath("kiro", env));
|
|
41
|
+
if (raw === undefined)
|
|
42
|
+
return { state: "missing", detail: "Kiro IDE user configuration is missing" };
|
|
43
|
+
const parsed = root(raw, "Kiro IDE user configuration"), servers = parsed.mcpServers === undefined ? {} : object(parsed.mcpServers, "Kiro IDE user mcpServers");
|
|
44
|
+
if (servers.sandbase === undefined)
|
|
45
|
+
return { state: "missing", detail: "SandBase is not registered in Kiro IDE user settings" };
|
|
46
|
+
const id = await identity(env), bridge = expectedBridge || id?.bridge;
|
|
47
|
+
if (!bridge || !owned(servers.sandbase, bridge))
|
|
48
|
+
return { state: "conflict", detail: "the shared sandbase key is not owned by the Kiro IDE client (it may belong to kiro-cli or a third party)" };
|
|
49
|
+
return { state: "configured", detail: "Kiro IDE user MCP ownership is verified; reload the IDE and verify server/tools plus a safe call" };
|
|
50
|
+
}
|
|
51
|
+
catch (error) {
|
|
52
|
+
return { state: "invalid", detail: error instanceof Error ? error.message : "Kiro IDE configuration is invalid" };
|
|
53
|
+
} }
|
|
54
|
+
export async function installKiroIDE(bridge, env = process.env) { if (!isAbsolute(bridge))
|
|
55
|
+
throw new Error("kiro: managed bridge path must be absolute; no changes were made"); const before = await inspectKiroIDE(env, bridge); if (["confirmation_required", "conflict", "invalid"].includes(before.state))
|
|
56
|
+
throw new Error(`kiro: ${before.detail}; no changes were made`); const path = configPath("kiro", env), raw = await readOptional(path), text = raw === undefined || !raw.trim() ? "{}\n" : raw, parsed = root(text, "Kiro IDE user configuration"), servers = parsed.mcpServers === undefined ? {} : object(parsed.mcpServers, "Kiro IDE user mcpServers"), idPath = ownerPath(env), oldIdentity = await readOptional(idPath), nextIdentity = JSON.stringify({ marker, client: "kiro", bridge }, null, 2) + "\n", changed = !owned(servers.sandbase, bridge), identityChanged = oldIdentity !== nextIdentity, result = { path, changed, identityPath: idPath, identityChanged, ...(oldIdentity === undefined ? {} : { identityPrevious: oldIdentity }) }; try {
|
|
57
|
+
if (identityChanged)
|
|
58
|
+
await atomicWrite(idPath, nextIdentity);
|
|
59
|
+
if (changed) {
|
|
60
|
+
servers.sandbase = entry(bridge);
|
|
61
|
+
parsed.mcpServers = servers;
|
|
62
|
+
const saved = await backup(path);
|
|
63
|
+
if (saved !== undefined)
|
|
64
|
+
result.backup = saved;
|
|
65
|
+
await atomicWrite(path, JSON.stringify(parsed, null, 2) + "\n");
|
|
66
|
+
}
|
|
67
|
+
const after = await inspectKiroIDE(env, bridge);
|
|
68
|
+
if (after.state !== "configured")
|
|
69
|
+
throw new Error(`Kiro IDE readback failed: ${after.detail}`);
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
await rollbackKiroIDE(result);
|
|
74
|
+
throw error;
|
|
75
|
+
} }
|
|
76
|
+
export async function rollbackKiroIDE(result) { const work = []; if (result.changed)
|
|
77
|
+
work.push(restore(result.path, result.backup)); if (result.identityChanged)
|
|
78
|
+
work.push(result.identityPrevious === undefined ? rm(result.identityPath, { force: true }) : atomicWrite(result.identityPath, result.identityPrevious)); const settled = await Promise.allSettled(work); if (settled.some(item => item.status === "rejected"))
|
|
79
|
+
throw new Error("Kiro IDE rollback was incomplete"); }
|
|
80
|
+
export async function snapshotKiroIDEUnregister(env = process.env) { const inspection = await inspectKiroIDE(env); if (inspection.state === "missing")
|
|
81
|
+
return undefined; if (inspection.state !== "configured")
|
|
82
|
+
throw new Error(`kiro: ${inspection.detail}; no changes were made`); const [config, identityRaw] = await Promise.all([readOptional(configPath("kiro", env)), readOptional(ownerPath(env))]); if (config === undefined || identityRaw === undefined)
|
|
83
|
+
throw new Error("kiro: managed ownership state is incomplete; no changes were made"); return { path: configPath("kiro", env), config, identityPath: ownerPath(env), identity: identityRaw }; }
|
|
84
|
+
export async function restoreKiroIDEUnregister(snapshot) { await Promise.all([atomicWrite(snapshot.path, snapshot.config), atomicWrite(snapshot.identityPath, snapshot.identity)]); }
|
|
85
|
+
export async function unregisterKiroIDE(env = process.env) { const snapshot = await snapshotKiroIDEUnregister(env); if (!snapshot)
|
|
86
|
+
return false; try {
|
|
87
|
+
const parsed = root(snapshot.config, "Kiro IDE user configuration"), servers = object(parsed.mcpServers, "Kiro IDE user mcpServers");
|
|
88
|
+
delete servers.sandbase;
|
|
89
|
+
parsed.mcpServers = servers;
|
|
90
|
+
await atomicWrite(snapshot.path, JSON.stringify(parsed, null, 2) + "\n");
|
|
91
|
+
await rm(snapshot.identityPath, { force: true });
|
|
92
|
+
const after = await inspectKiroIDE(env);
|
|
93
|
+
if (after.state !== "missing")
|
|
94
|
+
throw new Error(`Kiro IDE removal readback failed: ${after.detail}`);
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
await restoreKiroIDEUnregister(snapshot);
|
|
99
|
+
throw error;
|
|
100
|
+
} }
|
package/dist/paths.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { homedir } from "node:os";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
|
|
3
|
+
import { existsSync } from "node:fs";
|
|
4
|
+
export function sandbaseHome(env = process.env) { return env.SANDBASE_HOME || join(env.HOME || homedir(), ".sandbase"); }
|
|
4
5
|
export function configPath(client, env = process.env) {
|
|
5
6
|
const home = env.HOME || homedir();
|
|
6
7
|
if (client === "codex")
|
|
@@ -11,13 +12,37 @@ export function configPath(client, env = process.env) {
|
|
|
11
12
|
return join(home, ".cursor", "mcp.json");
|
|
12
13
|
if (client === "hermes")
|
|
13
14
|
return env.HERMES_HOME ? join(env.HERMES_HOME, "config.yaml") : join(home, ".hermes", "config.yaml");
|
|
14
|
-
if (client === "claude-desktop")
|
|
15
|
-
return env.CLAUDE_DESKTOP_CONFIG || join(home, "Library", "Application Support", "Claude", "claude_desktop_config.json");
|
|
16
15
|
if (client === "gemini-cli")
|
|
17
16
|
return join(home, ".gemini", "settings.json");
|
|
18
17
|
if (client === "qwen-code")
|
|
19
18
|
return join(home, ".qwen", "settings.json");
|
|
19
|
+
if (client === "opencode") {
|
|
20
|
+
if (env.OPENCODE_CONFIG)
|
|
21
|
+
return env.OPENCODE_CONFIG;
|
|
22
|
+
const json = join(home, ".config", "opencode", "opencode.json");
|
|
23
|
+
const jsonc = join(home, ".config", "opencode", "opencode.jsonc");
|
|
24
|
+
return existsSync(json) || !existsSync(jsonc) ? json : jsonc;
|
|
25
|
+
}
|
|
26
|
+
if (client === "windsurf")
|
|
27
|
+
return join(home, ".codeium", "windsurf", "mcp_config.json");
|
|
20
28
|
if (client === "cursor-cli")
|
|
21
29
|
return join(home, ".cursor", "mcp.json");
|
|
30
|
+
if (client === "kimi-cli")
|
|
31
|
+
return join(env.KIMI_SHARE_DIR || join(home, ".kimi"), "mcp.json");
|
|
32
|
+
if (client === "kiro-cli")
|
|
33
|
+
return join(env.KIRO_HOME || join(home, ".kiro"), "settings", "mcp.json");
|
|
34
|
+
if (client === "kiro")
|
|
35
|
+
return join(home, ".kiro", "settings", "mcp.json");
|
|
36
|
+
if (client === "amp") {
|
|
37
|
+
const json = join(home, ".config", "amp", "settings.json");
|
|
38
|
+
const jsonc = join(home, ".config", "amp", "settings.jsonc");
|
|
39
|
+
return existsSync(json) || !existsSync(jsonc) ? json : jsonc;
|
|
40
|
+
}
|
|
41
|
+
if (client === "crush")
|
|
42
|
+
return env.CRUSH_GLOBAL_CONFIG || join(home, ".config", "crush", "crush.json");
|
|
43
|
+
if (client === "iflow-cli")
|
|
44
|
+
return join(home, ".iflow", "settings.json");
|
|
45
|
+
if (client === "warp")
|
|
46
|
+
return join(home, ".warp", ".mcp.json");
|
|
22
47
|
return join(sandbaseHome(env), "manual", `${client}.json`);
|
|
23
48
|
}
|
package/dist/skills-cli.d.ts
CHANGED
|
@@ -20,6 +20,11 @@ export interface NativeSkillResult {
|
|
|
20
20
|
code?: NativeSkillFailure;
|
|
21
21
|
message: string;
|
|
22
22
|
}
|
|
23
|
+
export interface NativeSkillRemovalPlan {
|
|
24
|
+
agent?: string;
|
|
25
|
+
owned: boolean;
|
|
26
|
+
result: NativeSkillResult;
|
|
27
|
+
}
|
|
23
28
|
export interface SkillsCommandResult {
|
|
24
29
|
code: number | null;
|
|
25
30
|
stdout: string;
|
|
@@ -27,10 +32,46 @@ export interface SkillsCommandResult {
|
|
|
27
32
|
}
|
|
28
33
|
export type SkillsCommandRunner = (args: readonly string[]) => Promise<SkillsCommandResult>;
|
|
29
34
|
export type SkillsReadbackVerifier = (json: string, agent: string) => Promise<boolean>;
|
|
35
|
+
/** Immutable public identity of the ClawHub Skill adapter. */
|
|
36
|
+
export declare const openClawSandbaseSkill: {
|
|
37
|
+
readonly slug: "@joeliu926/sandbase";
|
|
38
|
+
readonly name: "sandbase";
|
|
39
|
+
readonly page: "https://clawhub.ai/joeliu926/skills/sandbase";
|
|
40
|
+
};
|
|
41
|
+
export type OpenClawCommandRunner = (args: readonly string[]) => Promise<SkillsCommandResult>;
|
|
42
|
+
export type OpenClawReadbackVerifier = (json: string) => Promise<boolean>;
|
|
43
|
+
export type OpenClawMcpStatus = "configured" | "already_configured" | "missing" | "confirmation_required" | "failed" | "removed";
|
|
44
|
+
export interface OpenClawMcpResult {
|
|
45
|
+
status: OpenClawMcpStatus;
|
|
46
|
+
message: string;
|
|
47
|
+
}
|
|
48
|
+
export declare const systemOpenClawRunner: OpenClawCommandRunner;
|
|
49
|
+
/**
|
|
50
|
+
* OpenClaw's documented JSON readback reports an installed workspace Skill's
|
|
51
|
+
* name, loader source, and frontmatter homepage. Those three values are the
|
|
52
|
+
* only supported evidence used here; paths and raw SKILL.md contents are not
|
|
53
|
+
* considered ownership proof.
|
|
54
|
+
*/
|
|
55
|
+
export declare const verifyOpenClawSandbaseReadback: OpenClawReadbackVerifier;
|
|
56
|
+
/** Read only the managed OpenClaw MCP entry; malformed or foreign entries fail closed. */
|
|
57
|
+
export declare function inspectOpenClawMcp(runner?: OpenClawCommandRunner): Promise<OpenClawMcpResult>;
|
|
58
|
+
/**
|
|
59
|
+
* Configure the documented OpenClaw MCP registry. The credential deliberately
|
|
60
|
+
* remains in SandBase's restricted local store and is never included in this
|
|
61
|
+
* JSON value or passed to OpenClaw.
|
|
62
|
+
*/
|
|
63
|
+
export declare function installOpenClawMcp(bridgePath: string, runner?: OpenClawCommandRunner): Promise<OpenClawMcpResult>;
|
|
64
|
+
/** Remove only the exact managed entry, then prove that it is absent. */
|
|
65
|
+
export declare function removeOpenClawMcp(runner?: OpenClawCommandRunner): Promise<OpenClawMcpResult>;
|
|
66
|
+
export declare function installOpenClawSkill(runner?: OpenClawCommandRunner, verify?: OpenClawReadbackVerifier): Promise<NativeSkillResult>;
|
|
67
|
+
export declare function inspectOpenClawSkill(runner?: OpenClawCommandRunner, verify?: OpenClawReadbackVerifier): Promise<NativeSkillResult>;
|
|
68
|
+
export declare function removeOpenClawSkill(runner?: OpenClawCommandRunner, verify?: OpenClawReadbackVerifier): Promise<NativeSkillResult>;
|
|
30
69
|
/** Reject every mutable or incomplete source tuple before starting any child process. */
|
|
31
70
|
export declare function validateSandbaseSkillRelease(release?: typeof sandbaseSkillRelease): boolean;
|
|
32
71
|
export declare const systemSkillsRunner: SkillsCommandRunner;
|
|
33
72
|
export declare const verifySkillsReadback: SkillsReadbackVerifier;
|
|
34
73
|
export declare function installNativeSkill(client: Client, runner?: SkillsCommandRunner, verify?: SkillsReadbackVerifier): Promise<NativeSkillResult>;
|
|
35
74
|
export declare function inspectNativeSkill(client: Client, runner?: SkillsCommandRunner, verify?: SkillsReadbackVerifier): Promise<NativeSkillResult>;
|
|
75
|
+
export declare function planNativeSkillRemoval(client: Client, runner?: SkillsCommandRunner, verify?: SkillsReadbackVerifier): Promise<NativeSkillRemovalPlan>;
|
|
76
|
+
export declare function executeNativeSkillRemoval(plan: NativeSkillRemovalPlan, runner?: SkillsCommandRunner, verify?: SkillsReadbackVerifier): Promise<NativeSkillResult>;
|
|
36
77
|
export declare function removeNativeSkill(client: Client, runner?: SkillsCommandRunner, verify?: SkillsReadbackVerifier): Promise<NativeSkillResult>;
|
package/dist/skills-cli.js
CHANGED
|
@@ -15,6 +15,204 @@ export const sandbaseSkillRelease = {
|
|
|
15
15
|
export const skillsAgentRegistry = {
|
|
16
16
|
"kiro-cli": { skillsAgentId: "kiro-cli" },
|
|
17
17
|
};
|
|
18
|
+
/** Immutable public identity of the ClawHub Skill adapter. */
|
|
19
|
+
export const openClawSandbaseSkill = {
|
|
20
|
+
slug: "@joeliu926/sandbase",
|
|
21
|
+
name: "sandbase",
|
|
22
|
+
page: "https://clawhub.ai/joeliu926/skills/sandbase",
|
|
23
|
+
};
|
|
24
|
+
const openClawMcpName = "sandbase";
|
|
25
|
+
const openClawManagedEnvironment = { SANDBASE_CLI_MANAGED: "1" };
|
|
26
|
+
export const systemOpenClawRunner = async (args) => new Promise(resolve => {
|
|
27
|
+
const child = spawn("openclaw", [...args], { stdio: ["ignore", "pipe", "pipe"] });
|
|
28
|
+
let stdout = "";
|
|
29
|
+
let stderr = "";
|
|
30
|
+
let settled = false;
|
|
31
|
+
const finish = (result) => { if (settled)
|
|
32
|
+
return; settled = true; clearTimeout(timeout); resolve(result); };
|
|
33
|
+
// The OpenClaw CLI may initialize plugins before executing a local MCP or
|
|
34
|
+
// Skill command. Give that supported command enough time, while still
|
|
35
|
+
// treating a timeout as unavailable rather than as ownership proof.
|
|
36
|
+
const timeout = setTimeout(() => { child.kill(); finish({ code: null, stdout: "", stderr: "" }); }, 45_000);
|
|
37
|
+
child.stdout.on("data", data => { stdout += String(data); });
|
|
38
|
+
child.stderr.on("data", data => { stderr += String(data); });
|
|
39
|
+
child.on("error", () => finish({ code: null, stdout: "", stderr: "" }));
|
|
40
|
+
child.on("close", code => finish({ code, stdout, stderr }));
|
|
41
|
+
});
|
|
42
|
+
/**
|
|
43
|
+
* OpenClaw's documented JSON readback reports an installed workspace Skill's
|
|
44
|
+
* name, loader source, and frontmatter homepage. Those three values are the
|
|
45
|
+
* only supported evidence used here; paths and raw SKILL.md contents are not
|
|
46
|
+
* considered ownership proof.
|
|
47
|
+
*/
|
|
48
|
+
export const verifyOpenClawSandbaseReadback = async (json) => {
|
|
49
|
+
try {
|
|
50
|
+
const entry = JSON.parse(json);
|
|
51
|
+
return entry.name === openClawSandbaseSkill.name
|
|
52
|
+
&& entry.source === "workspace"
|
|
53
|
+
&& entry.homepage === openClawSandbaseSkill.page;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
function openClawUnavailable() {
|
|
60
|
+
return { status: "failed", code: "skills_cli_unavailable", message: "OpenClaw CLI is unavailable or does not support the required Skill readback; no SandBase Skill was changed." };
|
|
61
|
+
}
|
|
62
|
+
async function invokeOpenClaw(runner, args) {
|
|
63
|
+
try {
|
|
64
|
+
return await runner(args);
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function entryFrom(value) {
|
|
71
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
72
|
+
return undefined;
|
|
73
|
+
const candidate = value;
|
|
74
|
+
if (typeof candidate.command !== "string" || !Array.isArray(candidate.args) || !candidate.args.every(arg => typeof arg === "string"))
|
|
75
|
+
return undefined;
|
|
76
|
+
const env = candidate.env && typeof candidate.env === "object" && !Array.isArray(candidate.env)
|
|
77
|
+
? Object.fromEntries(Object.entries(candidate.env).filter((entry) => typeof entry[1] === "string"))
|
|
78
|
+
: {};
|
|
79
|
+
return { command: candidate.command, args: [...candidate.args], env };
|
|
80
|
+
}
|
|
81
|
+
/** Accept only documented JSON envelopes emitted by `openclaw mcp show`. */
|
|
82
|
+
function readMcpEntry(json) {
|
|
83
|
+
try {
|
|
84
|
+
const root = JSON.parse(json);
|
|
85
|
+
return entryFrom(root)
|
|
86
|
+
|| entryFrom(root.mcpServers?.[openClawMcpName])
|
|
87
|
+
|| entryFrom(root.servers?.[openClawMcpName])
|
|
88
|
+
|| entryFrom(root.mcp?.servers?.[openClawMcpName]);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function isManagedMcpEntry(entry) {
|
|
95
|
+
return entry.command === "node"
|
|
96
|
+
&& entry.args.length === 3
|
|
97
|
+
&& entry.args[0].endsWith("sandbase-mcp-bridge.mjs")
|
|
98
|
+
&& entry.args[1] === "--client"
|
|
99
|
+
&& entry.args[2] === "openclaw"
|
|
100
|
+
&& entry.env.SANDBASE_CLI_MANAGED === "1";
|
|
101
|
+
}
|
|
102
|
+
function desiredMcpEntry(bridgePath) {
|
|
103
|
+
return { command: "node", args: [bridgePath, "--client", "openclaw"], env: { ...openClawManagedEnvironment } };
|
|
104
|
+
}
|
|
105
|
+
function sameMcpEntry(left, right) {
|
|
106
|
+
return left.command === right.command
|
|
107
|
+
&& JSON.stringify(left.args) === JSON.stringify(right.args)
|
|
108
|
+
&& JSON.stringify(left.env) === JSON.stringify(right.env);
|
|
109
|
+
}
|
|
110
|
+
async function showOpenClawMcp(runner) {
|
|
111
|
+
const response = await invokeOpenClaw(runner, ["mcp", "show", openClawMcpName, "--json"]);
|
|
112
|
+
if (!response || response.code === null)
|
|
113
|
+
return { missing: false, unavailable: true };
|
|
114
|
+
if (response.code !== 0)
|
|
115
|
+
return { missing: response.code === 1, unavailable: response.code !== 1 };
|
|
116
|
+
const entry = readMcpEntry(response.stdout);
|
|
117
|
+
return entry ? { entry, missing: false, unavailable: false } : { missing: false, unavailable: true };
|
|
118
|
+
}
|
|
119
|
+
/** Read only the managed OpenClaw MCP entry; malformed or foreign entries fail closed. */
|
|
120
|
+
export async function inspectOpenClawMcp(runner = systemOpenClawRunner) {
|
|
121
|
+
const readback = await showOpenClawMcp(runner);
|
|
122
|
+
if (readback.missing)
|
|
123
|
+
return { status: "missing", message: "OpenClaw has no MCP server named sandbase." };
|
|
124
|
+
if (readback.unavailable || !readback.entry)
|
|
125
|
+
return { status: "failed", message: "OpenClaw CLI is unavailable or could not read back the sandbase MCP server." };
|
|
126
|
+
return isManagedMcpEntry(readback.entry)
|
|
127
|
+
? { status: "already_configured", message: "OpenClaw read back the managed SandBase MCP bridge." }
|
|
128
|
+
: { status: "confirmation_required", message: "An existing non-SandBase OpenClaw MCP server named sandbase was left untouched." };
|
|
129
|
+
}
|
|
130
|
+
async function setOpenClawMcp(runner, entry) {
|
|
131
|
+
const result = await invokeOpenClaw(runner, ["mcp", "set", openClawMcpName, JSON.stringify(entry)]);
|
|
132
|
+
return !!result && result.code === 0;
|
|
133
|
+
}
|
|
134
|
+
async function unsetOpenClawMcp(runner) {
|
|
135
|
+
const result = await invokeOpenClaw(runner, ["mcp", "unset", openClawMcpName]);
|
|
136
|
+
return !!result && result.code === 0;
|
|
137
|
+
}
|
|
138
|
+
async function rollbackOpenClawMcp(runner, previous) {
|
|
139
|
+
if (previous)
|
|
140
|
+
await setOpenClawMcp(runner, previous);
|
|
141
|
+
else
|
|
142
|
+
await unsetOpenClawMcp(runner);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Configure the documented OpenClaw MCP registry. The credential deliberately
|
|
146
|
+
* remains in SandBase's restricted local store and is never included in this
|
|
147
|
+
* JSON value or passed to OpenClaw.
|
|
148
|
+
*/
|
|
149
|
+
export async function installOpenClawMcp(bridgePath, runner = systemOpenClawRunner) {
|
|
150
|
+
const previous = await showOpenClawMcp(runner);
|
|
151
|
+
if (previous.unavailable)
|
|
152
|
+
return { status: "failed", message: "OpenClaw CLI is unavailable or does not support MCP readback; no MCP server was changed." };
|
|
153
|
+
if (previous.entry && !isManagedMcpEntry(previous.entry))
|
|
154
|
+
return { status: "confirmation_required", message: "An existing non-SandBase OpenClaw MCP server named sandbase was left untouched." };
|
|
155
|
+
const desired = desiredMcpEntry(bridgePath);
|
|
156
|
+
if (previous.entry && sameMcpEntry(previous.entry, desired))
|
|
157
|
+
return { status: "already_configured", message: "OpenClaw already has the managed SandBase MCP bridge." };
|
|
158
|
+
if (!(await setOpenClawMcp(runner, desired)))
|
|
159
|
+
return { status: "failed", message: "OpenClaw could not register the SandBase MCP server; no success was reported." };
|
|
160
|
+
const readback = await showOpenClawMcp(runner);
|
|
161
|
+
if (!readback.entry || readback.unavailable || !isManagedMcpEntry(readback.entry) || !sameMcpEntry(readback.entry, desired)) {
|
|
162
|
+
await rollbackOpenClawMcp(runner, previous.entry).catch(() => undefined);
|
|
163
|
+
return { status: "failed", message: "OpenClaw could not verify the managed SandBase MCP bridge; the prior MCP state was restored." };
|
|
164
|
+
}
|
|
165
|
+
return { status: "configured", message: "OpenClaw registered and read back the managed SandBase MCP bridge." };
|
|
166
|
+
}
|
|
167
|
+
/** Remove only the exact managed entry, then prove that it is absent. */
|
|
168
|
+
export async function removeOpenClawMcp(runner = systemOpenClawRunner) {
|
|
169
|
+
const before = await showOpenClawMcp(runner);
|
|
170
|
+
if (before.missing)
|
|
171
|
+
return { status: "missing", message: "OpenClaw has no SandBase MCP server to remove." };
|
|
172
|
+
if (before.unavailable || !before.entry)
|
|
173
|
+
return { status: "failed", message: "OpenClaw CLI is unavailable or could not read back the SandBase MCP server; nothing was removed." };
|
|
174
|
+
if (!isManagedMcpEntry(before.entry))
|
|
175
|
+
return { status: "confirmation_required", message: "OpenClaw MCP ownership could not be proven; the existing sandbase server was left untouched." };
|
|
176
|
+
if (!(await unsetOpenClawMcp(runner)))
|
|
177
|
+
return { status: "failed", message: "OpenClaw could not remove the managed SandBase MCP server." };
|
|
178
|
+
const after = await showOpenClawMcp(runner);
|
|
179
|
+
if (!after.missing)
|
|
180
|
+
return { status: "failed", message: "OpenClaw could not verify SandBase MCP removal; no removal success was reported." };
|
|
181
|
+
return { status: "removed", message: "OpenClaw removal of the managed SandBase MCP bridge was verified." };
|
|
182
|
+
}
|
|
183
|
+
async function inspectOpenClawSkillWith(runner, verify) {
|
|
184
|
+
const readback = await invokeOpenClaw(runner, ["skills", "info", openClawSandbaseSkill.name, "--json"]);
|
|
185
|
+
if (!readback || readback.code !== 0)
|
|
186
|
+
return openClawUnavailable();
|
|
187
|
+
return await verify(readback.stdout)
|
|
188
|
+
? { status: "already_installed", message: "OpenClaw reports the exact SandBase ClawHub Skill identity." }
|
|
189
|
+
: { status: "confirmation_required", message: "OpenClaw cannot prove the exact SandBase ClawHub Skill identity." };
|
|
190
|
+
}
|
|
191
|
+
export async function installOpenClawSkill(runner = systemOpenClawRunner, verify = verifyOpenClawSandbaseReadback) {
|
|
192
|
+
const before = await inspectOpenClawSkillWith(runner, verify);
|
|
193
|
+
if (before.status === "already_installed")
|
|
194
|
+
return before;
|
|
195
|
+
if (before.status === "failed")
|
|
196
|
+
return before;
|
|
197
|
+
const installed = await invokeOpenClaw(runner, ["skills", "install", openClawSandbaseSkill.slug]);
|
|
198
|
+
if (!installed || installed.code !== 0)
|
|
199
|
+
return openClawUnavailable();
|
|
200
|
+
const readback = await inspectOpenClawSkillWith(runner, verify);
|
|
201
|
+
if (readback.status !== "already_installed")
|
|
202
|
+
return { status: "failed", code: "readback_failed", message: "OpenClaw could not prove the exact SandBase ClawHub Skill identity; no success was reported." };
|
|
203
|
+
return { status: "installed", message: "OpenClaw installed and read back the exact SandBase ClawHub Skill identity." };
|
|
204
|
+
}
|
|
205
|
+
export async function inspectOpenClawSkill(runner = systemOpenClawRunner, verify = verifyOpenClawSandbaseReadback) {
|
|
206
|
+
return inspectOpenClawSkillWith(runner, verify);
|
|
207
|
+
}
|
|
208
|
+
export async function removeOpenClawSkill(runner = systemOpenClawRunner, verify = verifyOpenClawSandbaseReadback) {
|
|
209
|
+
const existing = await inspectOpenClawSkillWith(runner, verify);
|
|
210
|
+
if (existing.status !== "already_installed")
|
|
211
|
+
return existing.status === "failed" ? existing : { status: "confirmation_required", message: "OpenClaw cannot prove SandBase Skill ownership; no Skill was removed." };
|
|
212
|
+
// OpenClaw 2026.4.12 documents no `skills remove`/`uninstall` subcommand.
|
|
213
|
+
// Do not delete the workspace directory or infer a removal path ourselves.
|
|
214
|
+
return { status: "confirmation_required", message: "This OpenClaw version has no supported Skill removal command; the verified SandBase Skill was left unchanged." };
|
|
215
|
+
}
|
|
18
216
|
function versionAtLeast(actual, minimum) {
|
|
19
217
|
const parse = (value) => value.match(/\b(\d+)\.(\d+)\.(\d+)\b/)?.slice(1).map(Number);
|
|
20
218
|
const a = parse(actual);
|
|
@@ -130,22 +328,30 @@ export async function inspectNativeSkill(client, runner = systemSkillsRunner, ve
|
|
|
130
328
|
? { status: "already_installed", message: "Native SandBase Skill ownership is verified by Skills CLI readback." }
|
|
131
329
|
: { status: "confirmation_required", message: "Native SandBase Skill is not listed for this agent." };
|
|
132
330
|
}
|
|
133
|
-
export async function
|
|
331
|
+
export async function planNativeSkillRemoval(client, runner = systemSkillsRunner, verify = verifySkillsReadback) {
|
|
134
332
|
const checked = await probe(client, runner);
|
|
135
333
|
if ("status" in checked)
|
|
136
|
-
return checked;
|
|
334
|
+
return { owned: false, result: checked };
|
|
137
335
|
const before = await invoke(runner, ["list", "-g", "-a", checked.agent, "--json"]);
|
|
138
336
|
if (!before || before.code !== 0)
|
|
139
|
-
return unavailable();
|
|
337
|
+
return { owned: false, result: unavailable() };
|
|
140
338
|
if (!(await verify(before.stdout, checked.agent)))
|
|
141
|
-
return { status: "confirmation_required", message: "Skills CLI cannot prove SandBase ownership for this agent; no native Skill was removed." };
|
|
339
|
+
return { agent: checked.agent, owned: false, result: { status: "confirmation_required", message: "Skills CLI cannot prove SandBase ownership for this agent; no native Skill was removed." } };
|
|
340
|
+
return { agent: checked.agent, owned: true, result: { status: "already_installed", message: "Native SandBase Skill ownership is verified by Skills CLI readback." } };
|
|
341
|
+
}
|
|
342
|
+
export async function executeNativeSkillRemoval(plan, runner = systemSkillsRunner, verify = verifySkillsReadback) {
|
|
343
|
+
if (!plan.owned || !plan.agent)
|
|
344
|
+
return plan.result;
|
|
142
345
|
// Skills CLI removes by its first-party Skill name, never by a URL. This is
|
|
143
346
|
// reached only after source, agent and digest ownership have been proven.
|
|
144
|
-
const removed = await invoke(runner, ["remove", "sandbase", "-g", "-a",
|
|
347
|
+
const removed = await invoke(runner, ["remove", "sandbase", "-g", "-a", plan.agent]);
|
|
145
348
|
if (!removed || removed.code !== 0)
|
|
146
349
|
return unavailable();
|
|
147
|
-
const readback = await invoke(runner, ["list", "-g", "-a",
|
|
148
|
-
if (!readback || readback.code !== 0 || await verify(readback.stdout,
|
|
350
|
+
const readback = await invoke(runner, ["list", "-g", "-a", plan.agent, "--json"]);
|
|
351
|
+
if (!readback || readback.code !== 0 || await verify(readback.stdout, plan.agent))
|
|
149
352
|
return { status: "failed", code: "readback_failed", message: "Skills CLI could not prove native Skill removal; no removal success was reported." };
|
|
150
353
|
return { status: "removed", message: "Native SandBase Skill removal was verified by Skills CLI readback." };
|
|
151
354
|
}
|
|
355
|
+
export async function removeNativeSkill(client, runner = systemSkillsRunner, verify = verifySkillsReadback) {
|
|
356
|
+
return executeNativeSkillRemoval(await planNativeSkillRemoval(client, runner, verify), runner, verify);
|
|
357
|
+
}
|