@sudohackin/toolring-mcp 0.0.0-stage → 0.10.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.
Files changed (77) hide show
  1. package/AGENT-INSTRUCTIONS.ru.md +136 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1144 -2
  4. package/RUN-BASH.ru.md +34 -0
  5. package/TOOL-STDOUT.md +50 -0
  6. package/bin/toolring.js +2 -0
  7. package/dist/argv-policy.d.ts +493 -0
  8. package/dist/argv-policy.js +211 -0
  9. package/dist/argv-policy.js.map +1 -0
  10. package/dist/bash-process.d.ts +3 -0
  11. package/dist/bash-process.js +98 -0
  12. package/dist/bash-process.js.map +1 -0
  13. package/dist/bash-when.d.ts +44 -0
  14. package/dist/bash-when.js +119 -0
  15. package/dist/bash-when.js.map +1 -0
  16. package/dist/call-policy.d.ts +20 -0
  17. package/dist/call-policy.js +74 -0
  18. package/dist/call-policy.js.map +1 -0
  19. package/dist/call.d.ts +107 -0
  20. package/dist/call.js +90 -0
  21. package/dist/call.js.map +1 -0
  22. package/dist/catalog.d.ts +30 -0
  23. package/dist/catalog.js +34 -0
  24. package/dist/catalog.js.map +1 -0
  25. package/dist/command-plan.d.ts +34 -0
  26. package/dist/command-plan.js +229 -0
  27. package/dist/command-plan.js.map +1 -0
  28. package/dist/config.d.ts +4559 -0
  29. package/dist/config.js +459 -0
  30. package/dist/config.js.map +1 -0
  31. package/dist/connections.d.ts +17 -0
  32. package/dist/connections.js +87 -0
  33. package/dist/connections.js.map +1 -0
  34. package/dist/default-tools.yaml +15 -0
  35. package/dist/executor.d.ts +39 -0
  36. package/dist/executor.js +166 -0
  37. package/dist/executor.js.map +1 -0
  38. package/dist/index.d.ts +2 -0
  39. package/dist/index.js +288 -0
  40. package/dist/index.js.map +1 -0
  41. package/dist/module-contract.d.ts +98 -0
  42. package/dist/module-contract.js +4 -0
  43. package/dist/module-contract.js.map +1 -0
  44. package/dist/modules/json.d.ts +14 -0
  45. package/dist/modules/json.js +14 -0
  46. package/dist/modules/json.js.map +1 -0
  47. package/dist/modules/text.d.ts +14 -0
  48. package/dist/modules/text.js +14 -0
  49. package/dist/modules/text.js.map +1 -0
  50. package/dist/modules.d.ts +17 -0
  51. package/dist/modules.js +113 -0
  52. package/dist/modules.js.map +1 -0
  53. package/dist/pipeline-io.d.ts +15 -0
  54. package/dist/pipeline-io.js +112 -0
  55. package/dist/pipeline-io.js.map +1 -0
  56. package/dist/pipeline-parser.d.ts +8 -0
  57. package/dist/pipeline-parser.js +111 -0
  58. package/dist/pipeline-parser.js.map +1 -0
  59. package/dist/pipeline.d.ts +32 -0
  60. package/dist/pipeline.js +409 -0
  61. package/dist/pipeline.js.map +1 -0
  62. package/dist/schema.d.ts +38 -0
  63. package/dist/schema.js +113 -0
  64. package/dist/schema.js.map +1 -0
  65. package/dist/server.d.ts +38 -0
  66. package/dist/server.js +447 -0
  67. package/dist/server.js.map +1 -0
  68. package/dist/stdout-protocol.d.ts +4 -0
  69. package/dist/stdout-protocol.js +21 -0
  70. package/dist/stdout-protocol.js.map +1 -0
  71. package/dist/tool-stream.d.ts +6 -0
  72. package/dist/tool-stream.js +30 -0
  73. package/dist/tool-stream.js.map +1 -0
  74. package/docs/bash-policy.ru.md +211 -0
  75. package/package.json +68 -4
  76. package/skills/toolring/SKILL.md +22 -0
  77. package/skills/toolring-authoring/SKILL.md +63 -0
package/dist/call.d.ts ADDED
@@ -0,0 +1,107 @@
1
+ import { type ToolringConfig } from "./config.js";
2
+ import { type CreateServerOptions } from "./server.js";
3
+ import type { StreamConsumer } from "./tool-stream.js";
4
+ /** Wait for each stdout write before asking the handler for its next chunk. */
5
+ export declare const streamToStdout: StreamConsumer;
6
+ export { parseConfig } from "./config.js";
7
+ /** Invoke a configured tool from a script using the same argv and policy as the CLI. */
8
+ export declare function callConfiguredTool(cfg: ToolringConfig, name: string, tokens: string[], opts?: CreateServerOptions & {
9
+ stream?: StreamConsumer;
10
+ connection?: string;
11
+ }): Promise<{
12
+ [x: string]: unknown;
13
+ content: ({
14
+ type: "text";
15
+ text: string;
16
+ annotations?: {
17
+ audience?: ("user" | "assistant")[] | undefined;
18
+ priority?: number | undefined;
19
+ lastModified?: string | undefined;
20
+ } | undefined;
21
+ _meta?: {
22
+ [x: string]: unknown;
23
+ } | undefined;
24
+ } | {
25
+ type: "image";
26
+ data: string;
27
+ mimeType: string;
28
+ annotations?: {
29
+ audience?: ("user" | "assistant")[] | undefined;
30
+ priority?: number | undefined;
31
+ lastModified?: string | undefined;
32
+ } | undefined;
33
+ _meta?: {
34
+ [x: string]: unknown;
35
+ } | undefined;
36
+ } | {
37
+ type: "audio";
38
+ data: string;
39
+ mimeType: string;
40
+ annotations?: {
41
+ audience?: ("user" | "assistant")[] | undefined;
42
+ priority?: number | undefined;
43
+ lastModified?: string | undefined;
44
+ } | undefined;
45
+ _meta?: {
46
+ [x: string]: unknown;
47
+ } | undefined;
48
+ } | {
49
+ uri: string;
50
+ name: string;
51
+ type: "resource_link";
52
+ description?: string | undefined;
53
+ mimeType?: string | undefined;
54
+ size?: number | undefined;
55
+ annotations?: {
56
+ audience?: ("user" | "assistant")[] | undefined;
57
+ priority?: number | undefined;
58
+ lastModified?: string | undefined;
59
+ } | undefined;
60
+ _meta?: {
61
+ [x: string]: unknown;
62
+ } | undefined;
63
+ icons?: {
64
+ src: string;
65
+ mimeType?: string | undefined;
66
+ sizes?: string[] | undefined;
67
+ theme?: "light" | "dark" | undefined;
68
+ }[] | undefined;
69
+ title?: string | undefined;
70
+ } | {
71
+ type: "resource";
72
+ resource: {
73
+ uri: string;
74
+ text: string;
75
+ mimeType?: string | undefined;
76
+ _meta?: {
77
+ [x: string]: unknown;
78
+ } | undefined;
79
+ } | {
80
+ uri: string;
81
+ blob: string;
82
+ mimeType?: string | undefined;
83
+ _meta?: {
84
+ [x: string]: unknown;
85
+ } | undefined;
86
+ };
87
+ annotations?: {
88
+ audience?: ("user" | "assistant")[] | undefined;
89
+ priority?: number | undefined;
90
+ lastModified?: string | undefined;
91
+ } | undefined;
92
+ _meta?: {
93
+ [x: string]: unknown;
94
+ } | undefined;
95
+ })[];
96
+ _meta?: {
97
+ [x: string]: unknown;
98
+ progressToken?: string | number | undefined;
99
+ "io.modelcontextprotocol/related-task"?: {
100
+ taskId: string;
101
+ } | undefined;
102
+ } | undefined;
103
+ structuredContent?: {
104
+ [x: string]: unknown;
105
+ } | undefined;
106
+ isError?: boolean | undefined;
107
+ }>;
package/dist/call.js ADDED
@@ -0,0 +1,90 @@
1
+ import { z } from "zod";
2
+ import { commandToolSchema, moduleArgsSchema, moduleCallSchema, pipelineModuleAlias, prefixedName } from "./config.js";
3
+ import { prepareConnections } from "./connections.js";
4
+ import { buildZodShape, parseInput } from "./schema.js";
5
+ import { parseToolTokens } from "./pipeline-io.js";
6
+ import { stageDecision, planExternalCommand } from "./pipeline.js";
7
+ import { preparePlanners } from "./command-plan.js";
8
+ import { createToolHandler } from "./server.js";
9
+ /** Wait for each stdout write before asking the handler for its next chunk. */
10
+ export const streamToStdout = async (chunks, stopSource) => {
11
+ const stdout = process.stdout;
12
+ let closed = false;
13
+ let writeError;
14
+ const onClose = () => {
15
+ closed = true;
16
+ stopSource();
17
+ };
18
+ const onError = (error) => {
19
+ writeError = error;
20
+ stopSource();
21
+ };
22
+ stdout.on("error", onError);
23
+ stdout.on("close", onClose);
24
+ try {
25
+ for await (const chunk of chunks) {
26
+ await new Promise((resolve, reject) => stdout.write(chunk, error => {
27
+ if (error) {
28
+ onError(error);
29
+ reject(error);
30
+ }
31
+ else
32
+ resolve();
33
+ }));
34
+ }
35
+ }
36
+ catch (error) {
37
+ // A consumer such as head can finish while the generator is still producing.
38
+ if (writeError) {
39
+ if (writeError.code !== "EPIPE" && writeError.code !== "ECONNRESET")
40
+ throw writeError;
41
+ }
42
+ else if (!closed)
43
+ throw error;
44
+ }
45
+ finally {
46
+ stdout.off("error", onError);
47
+ stdout.off("close", onClose);
48
+ }
49
+ };
50
+ export { parseConfig } from "./config.js";
51
+ /** Invoke a configured tool from a script using the same argv and policy as the CLI. */
52
+ export async function callConfiguredTool(cfg, name, tokens, opts = {}) {
53
+ let spec = cfg.tools.find(tool => prefixedName(cfg, tool) === name);
54
+ const connections = await prepareConnections(cfg, opts);
55
+ const directAlias = pipelineModuleAlias(name, cfg);
56
+ const planners = await preparePlanners(cfg, opts, connections, !spec && !directAlias);
57
+ const owned = planners.nativeCommands.has(name);
58
+ const native = !spec && (owned || !directAlias && cfg["bash-policy"]?.["external-commands"]?.includes(name));
59
+ if (native) {
60
+ const bash = cfg["bash-policy"];
61
+ if (bash) {
62
+ const verdict = stageDecision(bash, owned, name, tokens);
63
+ if (verdict.action === "deny")
64
+ throw new Error(`Command denied: ${verdict.reason}`);
65
+ if (verdict.action === "confirm" && !opts.dryRun)
66
+ throw new Error("Command requires user confirmation.");
67
+ }
68
+ spec = commandToolSchema.parse({ name: "cli_command", description: name, command: name, args: tokens });
69
+ tokens = [];
70
+ }
71
+ if (!spec && !name.includes("."))
72
+ throw new Error(`Unknown tool "${name}". Run "toolring inspect <config.yaml>" to list the published names.`);
73
+ if (spec && opts.connection !== undefined)
74
+ throw new Error("--connection applies only to direct module calls.");
75
+ const target = spec ?? moduleCallSchema.parse({ call: name, connection: opts.connection });
76
+ const schema = spec ? z.object(buildZodShape(spec)).strict() : moduleArgsSchema;
77
+ const normalized = spec ? parseToolTokens(spec, tokens, [], "cli").argv.map(token => token.replace(/^--/, "")) : tokens;
78
+ const input = schema.safeParse(parseInput(spec, normalized));
79
+ if (!input.success) {
80
+ const issues = input.error.issues.map(issue => [issue.path.join("."), issue.message].filter(Boolean).join(": "));
81
+ throw new Error(`Invalid arguments for "${name}": ${issues.join("; ")}`);
82
+ }
83
+ const preparedCommand = native && spec?.command ? planExternalCommand(cfg, planners.planCommand, name, spec.args) : undefined;
84
+ const invoke = createToolHandler(cfg, target, {
85
+ registry: opts.registry, configPath: opts.configPath, dryRun: opts.dryRun, stream: opts.stream,
86
+ env: opts.env ?? cfg.env, ...planners, preparedCommand,
87
+ }, connections);
88
+ return invoke(input.data);
89
+ }
90
+ //# sourceMappingURL=call.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"call.js","sourceRoot":"","sources":["../src/call.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,iBAAiB,EAAiB,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,YAAY,EAAuB,MAAM,aAAa,CAAC;AAC3J,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAA4B,MAAM,aAAa,CAAC;AAG1E,+EAA+E;AAC/E,MAAM,CAAC,MAAM,cAAc,GAAmB,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE;IACzE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAC9B,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,UAA6C,CAAC;IAClD,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,MAAM,GAAG,IAAI,CAAC;QACd,UAAU,EAAE,CAAC;IACf,CAAC,CAAC;IACF,MAAM,OAAO,GAAG,CAAC,KAA4B,EAAE,EAAE;QAC/C,UAAU,GAAG,KAAK,CAAC;QACnB,UAAU,EAAE,CAAC;IACf,CAAC,CAAC;IACF,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5B,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC5B,IAAI,CAAC;QAC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AI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC9H,MAAM,MAAM,GAAG,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE;QAC5C,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM;QAC9F,GAAG,EAAE,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,GAAG,EAAE,GAAG,QAAQ,EAAE,eAAe;KACvD,EAAE,WAAW,CAAC,CAAC;IAChB,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC5B,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { type ToolringConfig } from "./config.js";
2
+ import { type ModuleRegistry } from "./modules.js";
3
+ import type { PreparedConnection } from "./connections.js";
4
+ /** Inspect registered exports without invoking an operation or opening a connection. */
5
+ export declare function inspectCatalog(alias: string | undefined, cfg: ToolringConfig, registry: ModuleRegistry, configPath: string | undefined, connections: ReadonlyMap<string, PreparedConnection>): Promise<{
6
+ modules: string[];
7
+ module?: undefined;
8
+ connections?: undefined;
9
+ operations?: undefined;
10
+ } | {
11
+ module: string;
12
+ connections: string[];
13
+ operations: {
14
+ publishedAs: string[];
15
+ usedInSteps: string[];
16
+ description?: string | undefined;
17
+ params?: {
18
+ type: "string" | "number" | "boolean" | "string[]";
19
+ required: boolean;
20
+ name: string;
21
+ description?: string | undefined;
22
+ default?: string | number | boolean | string[] | undefined;
23
+ aliases?: string[] | undefined;
24
+ enum?: string[] | undefined;
25
+ }[] | undefined;
26
+ example?: Record<string, string | number | boolean | string[]> | undefined;
27
+ call: string;
28
+ }[];
29
+ modules?: undefined;
30
+ }>;
@@ -0,0 +1,34 @@
1
+ import { operationMetadataSchema, prefixedName } from "./config.js";
2
+ import { configDirectory, resolveModuleLoader } from "./modules.js";
3
+ /** Inspect registered exports without invoking an operation or opening a connection. */
4
+ export async function inspectCatalog(alias, cfg, registry, configPath, connections) {
5
+ if (alias === undefined) {
6
+ return { modules: [...new Set(cfg["enabled-modules"] ?? [...registry.keys(), ...Object.keys(cfg.modules ?? {})])].sort() };
7
+ }
8
+ const load = resolveModuleLoader(alias, configDirectory(configPath), cfg, registry);
9
+ const bindings = Object.keys(cfg.connections ?? {}).filter(name => cfg.connections?.[name].module === alias).sort();
10
+ const exports = connections.get(bindings[0])?.exports ?? await load();
11
+ if (typeof exports !== "object" || exports === null)
12
+ throw new Error(`Expected exports from module "${alias}".`);
13
+ const metadata = operationMetadataSchema.safeParse(typeof exports.operationMetadata === "function" ? {} : exports.operationMetadata ?? {});
14
+ if (!metadata.success)
15
+ throw new Error(`Invalid operationMetadata for module "${alias}": ${metadata.error.message}`);
16
+ const operations = Object.keys(exports).sort()
17
+ .filter(name => name !== "default" && /^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(name) && typeof exports[name] === "function")
18
+ .map(name => {
19
+ const call = `${alias}.${name}`;
20
+ const publishedAs = [];
21
+ const usedInSteps = [];
22
+ for (const tool of cfg.tools) {
23
+ const publicName = prefixedName(cfg, tool);
24
+ if (tool.call === call)
25
+ publishedAs.push(publicName);
26
+ else if (tool.steps?.some(step => step.call === call))
27
+ usedInSteps.push(publicName);
28
+ }
29
+ const details = Object.hasOwn(metadata.data, name) ? metadata.data[name] : undefined;
30
+ return { call, ...details, publishedAs, usedInSteps };
31
+ });
32
+ return { module: alias, connections: bindings, operations };
33
+ }
34
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../src/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,YAAY,EAAuB,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAuB,MAAM,cAAc,CAAC;AAGzF,wFAAwF;AACxF,MAAM,CAAC,KAAK,UAAU,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 import type { PreparedConnection } from "./connections.js";
2
+ import { type ModuleCall, type ToolSpec, type ToolringConfig } from "./config.js";
3
+ import { type ModuleRegistry } from "./modules.js";
4
+ type Destination = {
5
+ kind: "process";
6
+ argv: string[];
7
+ } | {
8
+ kind: "module";
9
+ tool: ToolSpec;
10
+ args: Record<string, unknown>;
11
+ };
12
+ export interface CommandPlan {
13
+ parsed: unknown;
14
+ connection?: string;
15
+ action: "allow" | "confirm";
16
+ reasons: string[];
17
+ target: Destination;
18
+ }
19
+ export type CommandPlanner = (command: string, argv: string[]) => CommandPlan;
20
+ export type ReviewOperations = (calls: readonly ModuleCall[], args: Record<string, unknown>, toolValidators?: readonly string[]) => Promise<string[]>;
21
+ export declare function reviewTarget(review: ReviewOperations, target: ToolSpec | ModuleCall | undefined, args: Record<string, unknown>, command?: CommandPlan): never[] | Promise<string[]>;
22
+ /** Bind trusted extensions at profile load. Planning never starts a process or opens a service connection. */
23
+ export declare function preparePlanners(cfg: ToolringConfig, opts: {
24
+ registry?: ModuleRegistry;
25
+ configPath?: string;
26
+ }, connections: ReadonlyMap<string, PreparedConnection>, discoverNativeCommand?: boolean): Promise<{
27
+ planCommand: CommandPlanner;
28
+ reviewOperations: ReviewOperations;
29
+ nativeCommands: Map<string, {
30
+ module?: string;
31
+ connection?: string;
32
+ }>;
33
+ }>;
34
+ export {};
@@ -0,0 +1,229 @@
1
+ import path from "node:path";
2
+ import { z } from "zod";
3
+ import { matchingRules, moduleAction, selectAction } from "./call-policy.js";
4
+ import { bashToolName, commandNamePattern, effectiveCallPolicy, managementToolNames, moduleCalls, operationPolicies, prefixedName, } from "./config.js";
5
+ import { builtinModules, configDirectory, fileModuleLoader, resolveModuleLoader, splitModuleCall } from "./modules.js";
6
+ import { buildZodShape } from "./schema.js";
7
+ export function reviewTarget(review, target, args, command) {
8
+ if (command?.target.kind === "module") {
9
+ target = command.target.tool;
10
+ args = command.target.args;
11
+ }
12
+ if (!target)
13
+ return [];
14
+ return review("name" in target ? moduleCalls(target) : [target], args, "validators" in target ? target.validators : undefined);
15
+ }
16
+ function member(exports, group, key) {
17
+ const table = exports[group];
18
+ if (table && typeof table === "object" && Object.hasOwn(table, key))
19
+ return Reflect.get(table, key);
20
+ }
21
+ function reviewValidators(validators, input, subject) {
22
+ const reasons = [];
23
+ for (const { ref, validate } of validators) {
24
+ const verdict = validate(structuredClone(input));
25
+ collectVerdict(reasons, ref, subject, verdict);
26
+ }
27
+ return reasons;
28
+ }
29
+ function collectVerdict(reasons, ref, subject, verdict) {
30
+ if (!verdict || !["allow", "confirm", "deny"].includes(verdict.action))
31
+ throw new Error(`Invalid verdict from ${ref}.`);
32
+ if (verdict.action === "deny")
33
+ throw new Error(`Validator ${ref} denied ${subject}: ${verdict.reason ?? "denied"}`);
34
+ if (verdict.action === "confirm")
35
+ reasons.push(verdict.reason ?? `Confirmation required by ${ref} for ${subject}`);
36
+ }
37
+ function publishedTarget(cfg, call, connection, supplied, reasons) {
38
+ const matches = cfg.tools.filter(tool => tool.call === call && tool.connection === connection);
39
+ if (matches.length !== 1)
40
+ throw new Error(`Expected one published tool for ${call} on this connection.`);
41
+ const tool = matches[0];
42
+ const args = z.object(buildZodShape(tool)).strict().parse(supplied);
43
+ const policy = effectiveCallPolicy(cfg);
44
+ if (policy?.scope === "all") {
45
+ const action = moduleAction(policy, { call, connection }, args);
46
+ if (action === "deny")
47
+ throw new Error(`Call policy denied ${call}.`);
48
+ if (action === "confirm")
49
+ reasons.push(`Call policy requires confirmation for ${call}`);
50
+ }
51
+ return { kind: "module", tool, args };
52
+ }
53
+ function isCommandAdapter(value) {
54
+ if (!value || typeof value !== "object")
55
+ return false;
56
+ return "parse" in value && typeof value.parse === "function" && "bind" in value && typeof value.bind === "function"
57
+ && (("operation" in value && typeof value.operation === "function") || ("transform" in value && typeof value.transform === "function"));
58
+ }
59
+ function moduleCommandPlanner(cfg, alias, name, adapter, connection, settings, ambiguous) {
60
+ return (command, argv) => {
61
+ if (!connection && (adapter.requiresConnection || ambiguous)) {
62
+ throw new Error(`Select a ${alias} connection for "${name}" with command-connections.${name}.`);
63
+ }
64
+ const parsed = adapter.bind(adapter.parse({ command, argv: [...argv] }), settings?.getSettings());
65
+ const dest = "operation" in adapter ? { ...adapter.operation(parsed), kind: "module" } : adapter.transform(parsed, "module");
66
+ if (dest.kind !== "module" || typeof dest.call !== "string" || !/^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(dest.call)) {
67
+ throw new Error(`Command "${name}" must resolve to an operation of "${alias}".`);
68
+ }
69
+ const reasons = [];
70
+ const target = publishedTarget(cfg, `${alias}.${dest.call}`, connection, dest.args, reasons);
71
+ return { parsed, connection, reasons, action: reasons.length ? "confirm" : "allow", target };
72
+ };
73
+ }
74
+ /** Bind trusted extensions at profile load. Planning never starts a process or opens a service connection. */
75
+ export async function preparePlanners(cfg, opts, connections, discoverNativeCommand = false) {
76
+ const policies = new Map();
77
+ const loaded = new Map([...connections.values()].map(connection => [connection.module, connection.exports]));
78
+ async function load(alias) {
79
+ let exports = loaded.get(alias);
80
+ if (!exports) {
81
+ exports = await resolveModuleLoader(alias, configDirectory(opts.configPath), cfg, opts.registry ?? builtinModules)();
82
+ loaded.set(alias, exports);
83
+ }
84
+ return exports;
85
+ }
86
+ async function loadValidators(group, refs) {
87
+ const validators = [];
88
+ for (const ref of refs) {
89
+ const [alias, key] = splitModuleCall(ref);
90
+ const validate = member(await load(alias), group, key);
91
+ if (typeof validate !== "function")
92
+ throw new Error(`Unknown validator "${ref}" in ${group}.`);
93
+ validators.push({ ref, validate: validate });
94
+ }
95
+ return validators;
96
+ }
97
+ const toolPolicy = cfg["tool-policy"];
98
+ const operations = operationPolicies(cfg);
99
+ for (const call of Object.keys(operations)) {
100
+ const [module, operation] = splitModuleCall(call);
101
+ const exports = await load(module);
102
+ if (!Object.hasOwn(exports, operation) || typeof exports[operation] !== "function") {
103
+ throw new Error(`Unknown operation "${call}" in the configured operation validators.`);
104
+ }
105
+ }
106
+ const validators = new Map();
107
+ const refs = [
108
+ ...(toolPolicy?.validators ?? []),
109
+ ...(toolPolicy?.rules.flatMap(rule => rule.validators ?? []) ?? []),
110
+ ...Object.values(operations).flatMap(policy => policy.validators),
111
+ ...cfg.tools.flatMap(tool => "validators" in tool ? tool.validators ?? [] : []),
112
+ ];
113
+ for (const ref of new Set(refs)) {
114
+ const [file, key] = ref.split("#");
115
+ const filename = path.resolve(configDirectory(opts.configPath), file);
116
+ const exports = await fileModuleLoader(filename)();
117
+ if (typeof exports[key] !== "function")
118
+ throw new Error(`Policy file "${filename}" must export function "${key}".`);
119
+ validators.set(ref, exports[key]);
120
+ }
121
+ const reviewOperations = async (calls, args, toolValidators = []) => {
122
+ const reasons = [];
123
+ const checks = calls.map(target => {
124
+ const rules = toolPolicy ? matchingRules(toolPolicy, target, args) : [];
125
+ if (toolPolicy && selectAction(rules, toolPolicy.default) === "deny") {
126
+ throw new Error(`Call policy denied ${target.call} with these arguments and connection.`);
127
+ }
128
+ const refs = new Set([
129
+ ...(toolPolicy?.validators ?? []),
130
+ ...rules.flatMap(rule => rule.validators ?? []),
131
+ ...(operations[target.call]?.validators ?? []),
132
+ ...toolValidators,
133
+ ]);
134
+ return { target, refs };
135
+ });
136
+ for (const { target: { call, connection }, refs } of checks) {
137
+ for (const ref of refs) {
138
+ const validate = validators.get(ref);
139
+ const verdict = await validate(structuredClone({ call, connection, args }), {
140
+ async getClient() {
141
+ const bound = connection && connections.get(connection);
142
+ if (!bound)
143
+ throw new Error(`Validator ${ref} requires a bound connection for ${call}.`);
144
+ return bound.getClient();
145
+ },
146
+ });
147
+ collectVerdict(reasons, ref, call, verdict);
148
+ }
149
+ }
150
+ return reasons;
151
+ };
152
+ const nativeCommands = new Map();
153
+ const registry = opts.registry ?? builtinModules;
154
+ // Profiles exposing only named tools can keep their unbound module imports lazy.
155
+ const discoverAll = discoverNativeCommand || cfg["bash-policy"] || cfg["tool-policy"] || cfg["command-connections"]
156
+ || cfg.tools.some(tool => tool.command && commandNamePattern.test(tool.command));
157
+ const aliases = cfg["enabled-modules"] ?? (discoverAll
158
+ ? new Set([...registry.keys(), ...Object.keys(cfg.modules ?? {})]) : [...loaded.keys()]);
159
+ const published = new Set(cfg.tools.map(tool => prefixedName(cfg, tool)));
160
+ const bindings = new Map(Object.entries(cfg["command-connections"] ?? {}));
161
+ const legacyPolicies = new Map(Object.entries(cfg["command-policies"] ?? {}));
162
+ for (const alias of aliases) {
163
+ const adapters = (await load(alias)).commandAdapters;
164
+ if (adapters === undefined)
165
+ continue;
166
+ if (!adapters || typeof adapters !== "object" || Array.isArray(adapters))
167
+ throw new Error(`Invalid commandAdapters in "${alias}".`);
168
+ const candidates = [...connections].filter(([, conn]) => conn.module === alias).map(([name]) => name);
169
+ for (const [name, adapter] of Object.entries(adapters)) {
170
+ if (!commandNamePattern.test(name) || managementToolNames.has(name) || [bashToolName, "toolring_help"].includes(name)
171
+ || published.has(name) || nativeCommands.has(name))
172
+ throw new Error(`Ambiguous or reserved command "${name}" in module "${alias}".`);
173
+ const legacy = legacyPolicies.get(name);
174
+ if (legacy && legacy.parser !== alias)
175
+ throw new Error(`Command "${name}" belongs to module "${alias}".`);
176
+ if (!isCommandAdapter(adapter))
177
+ throw new Error(`Invalid adapter for "${name}" in module "${alias}".`);
178
+ const explicit = bindings.get(name);
179
+ if (explicit && !candidates.includes(explicit))
180
+ throw new Error(`command-connections.${name} must name a connection for "${alias}".`);
181
+ const connection = explicit ?? (candidates.length === 1 ? candidates[0] : undefined);
182
+ nativeCommands.set(name, { module: alias, connection });
183
+ if (legacy)
184
+ continue;
185
+ const settings = connection ? connections.get(connection) : undefined;
186
+ policies.set(name, moduleCommandPlanner(cfg, alias, name, adapter, connection, settings, candidates.length > 1));
187
+ }
188
+ }
189
+ for (const name of bindings.keys()) {
190
+ if (!nativeCommands.has(name))
191
+ throw new Error(`command-connections.${name}: no enabled module owns this command.`);
192
+ }
193
+ for (const [name, policy] of legacyPolicies) {
194
+ nativeCommands.set(name, { module: policy.parser, connection: policy.connection });
195
+ let adapter;
196
+ if (policy.parser) {
197
+ adapter = member(await load(policy.parser), "commandAdapters", name);
198
+ if (!adapter || [adapter.parse, adapter.bind, adapter.transform].some(fn => typeof fn !== "function")) {
199
+ throw new Error(`Missing command adapter "${name}" in module "${policy.parser}".`);
200
+ }
201
+ if (adapter.requiresConnection && !policy.connection)
202
+ throw new Error(`Command "${name}" requires a connection.`);
203
+ }
204
+ const validators = await loadValidators("commandValidators", policy.validators);
205
+ const connection = policy.connection ? connections.get(policy.connection) : undefined;
206
+ policies.set(name, (command, argv) => {
207
+ const input = { command, argv: [...argv] };
208
+ const parsed = adapter ? adapter.bind(adapter.parse(input), connection?.getSettings()) : input;
209
+ const reasons = reviewValidators(validators, { ...input, connection: policy.connection, parsed }, name);
210
+ const destination = adapter ? adapter.transform(parsed, policy.backend) : { kind: "process", argv };
211
+ if (destination.kind !== policy.backend)
212
+ throw new Error(`Unexpected backend for ${name}.`);
213
+ let target;
214
+ if (destination.kind === "process") {
215
+ target = { kind: "process", argv: z.array(z.string().refine(v => !v.includes("\0"))).parse(destination.argv) };
216
+ }
217
+ else {
218
+ // Resolve one published schema. Never give an adapter access to an unpublished export.
219
+ const call = destination.call.includes(".") ? destination.call : `${policy.parser}.${destination.call}`;
220
+ target = publishedTarget(cfg, call, policy.connection, destination.args, reasons);
221
+ }
222
+ return { parsed, connection: policy.connection, action: reasons.length ? "confirm" : "allow", reasons, target };
223
+ });
224
+ }
225
+ const planCommand = (command, argv) => policies.get(path.basename(command))?.(command, argv)
226
+ ?? { parsed: { command, argv }, action: "allow", reasons: [], target: { kind: "process", argv } };
227
+ return { planCommand, reviewOperations, nativeCommands };
228
+ }
229
+ //# sourceMappingURL=command-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command-plan.js","sourceRoot":"","sources":["../src/command-plan.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC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