toolcraft 0.0.85 → 0.0.87
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/LICENSE +21 -0
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +19 -7
- package/dist/error-report.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +11 -0
- package/dist/mcp-proxy.d.ts +1 -1
- package/dist/mcp-proxy.js +2 -17
- package/dist/node-require-shim.d.ts +1 -0
- package/dist/node-require-shim.js +4 -0
- package/dist/project-root.d.ts +1 -0
- package/dist/project-root.js +15 -0
- package/package.json +4 -2
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Poe Platform
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import "./node-require-shim.js";
|
|
1
2
|
import { configureTheme } from "toolcraft-design";
|
|
2
3
|
import type { Group, LogLevel, RuntimeLoggerInput } from "./index.js";
|
|
3
4
|
import { type ErrorReportsOption } from "./error-report.js";
|
|
4
|
-
import type { HumanInLoopRuntimeOptions } from "./human-in-loop/
|
|
5
|
+
import type { HumanInLoopRuntimeOptions } from "./human-in-loop/types.js";
|
|
5
6
|
export { configureTheme };
|
|
6
7
|
type Casing = "kebab" | "snake";
|
|
7
8
|
export interface CLIControls {
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
+
import "./node-require-shim.js";
|
|
1
2
|
import { access, lstat, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import { Command as CommanderCommand, CommanderError, InvalidArgumentError, Option } from "commander";
|
|
4
5
|
import { cancel, configureTheme, confirm, createLogger, formatCommandList, formatOptionList, getTheme, helpFormatterPlain, isCancel, note, promptText, renderTable, resetOutputFormatCache, select, text } from "toolcraft-design";
|
|
5
|
-
import { ApprovalDeclinedError, UserError, assertCommandRequirements, getCommandSourcePath, resolveCommandSecrets } from "./index.js";
|
|
6
|
+
import { ApprovalDeclinedError, UserError, assertCommandRequirements, getCommandSourcePath, hasMcpProxyConfig, resolveCommandSecrets } from "./index.js";
|
|
6
7
|
import { hasOwnErrorCode } from "./error-codes.js";
|
|
7
|
-
import { mergeApprovalsGroup } from "./human-in-loop/approvals-commands.js";
|
|
8
8
|
import { writeErrorReport } from "./error-report.js";
|
|
9
|
-
import { invokeWithHumanInLoop } from "./human-in-loop/index.js";
|
|
10
|
-
import { resolveMcpProxies } from "./mcp-proxy.js";
|
|
11
9
|
import { getExpectedNumberDescription, isValidNumberSchemaValue } from "./number-schema.js";
|
|
12
10
|
import { findEntrypointPackageMetadata } from "./package-metadata.js";
|
|
13
11
|
import { redactHttpBody, redactHttpHeaderValue } from "./redaction.js";
|
|
@@ -33,6 +31,14 @@ const RESERVED_SERVICE_NAMES = new Set([
|
|
|
33
31
|
]);
|
|
34
32
|
const RESERVED_SERVICE_NAMES_MESSAGE = "Available reserved names: params, secrets, fetch, fs, env, diagnostics, progress, runtimeOptions, root.";
|
|
35
33
|
const NULL_OPTION_VALUE = Symbol("toolcraft.cli.null");
|
|
34
|
+
const optionalModulePaths = {
|
|
35
|
+
approvals: "./human-in-loop/approvals-commands.js",
|
|
36
|
+
humanInLoop: "./human-in-loop/gate.js",
|
|
37
|
+
mcpProxy: "./mcp-proxy.js"
|
|
38
|
+
};
|
|
39
|
+
function importOptionalModule(specifier) {
|
|
40
|
+
return import(specifier);
|
|
41
|
+
}
|
|
36
42
|
function inferProgramName(argv) {
|
|
37
43
|
const entrypoint = argv[1];
|
|
38
44
|
if (typeof entrypoint !== "string" || entrypoint.length === 0) {
|
|
@@ -2875,7 +2881,9 @@ async function executeCommand(state, services, requirementOptions, runtimeFetch,
|
|
|
2875
2881
|
throw new UserError("Operation cancelled.");
|
|
2876
2882
|
}
|
|
2877
2883
|
}
|
|
2878
|
-
const result =
|
|
2884
|
+
const result = state.command.humanInLoop
|
|
2885
|
+
? await (await importOptionalModule(optionalModulePaths.humanInLoop)).invokeWithHumanInLoop(state.command, context, runtimeOptions, state.commandPath)
|
|
2886
|
+
: await state.command.handler(context);
|
|
2879
2887
|
if (output === "rich" && runtime.isFixture) {
|
|
2880
2888
|
writeRichHeader(`${state.command.name} (fixture)`);
|
|
2881
2889
|
}
|
|
@@ -3419,8 +3427,12 @@ export async function runCLI(roots, options = {}) {
|
|
|
3419
3427
|
let errorReportContext;
|
|
3420
3428
|
try {
|
|
3421
3429
|
const normalizedRoot = normalizeRoots(roots, argv);
|
|
3422
|
-
const root = options.approvals === true
|
|
3423
|
-
|
|
3430
|
+
const root = options.approvals === true
|
|
3431
|
+
? (await importOptionalModule(optionalModulePaths.approvals)).mergeApprovalsGroup(normalizedRoot)
|
|
3432
|
+
: normalizedRoot;
|
|
3433
|
+
if (hasMcpProxyConfig(root)) {
|
|
3434
|
+
await (await importOptionalModule(optionalModulePaths.mcpProxy)).resolveMcpProxies(root, { projectRoot: options.projectRoot });
|
|
3435
|
+
}
|
|
3424
3436
|
const casing = options.casing ?? "kebab";
|
|
3425
3437
|
const services = (options.services ?? {});
|
|
3426
3438
|
const runtimeOptions = options.humanInLoop ?? {};
|
package/dist/error-report.js
CHANGED
|
@@ -4,8 +4,8 @@ import os from "node:os";
|
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { CommanderError } from "commander";
|
|
6
6
|
import { ApprovalDeclinedError } from "./human-in-loop/types.js";
|
|
7
|
-
import { findProjectRoot } from "./mcp-proxy.js";
|
|
8
7
|
import { findPackageMetadata } from "./package-metadata.js";
|
|
8
|
+
import { findProjectRoot } from "./project-root.js";
|
|
9
9
|
import { isSensitiveName, redactHttpBody, redactHttpHeaderValue } from "./redaction.js";
|
|
10
10
|
import { UserError } from "./user-error.js";
|
|
11
11
|
const ERROR_REPORTS_ENV = "TOOLCRAFT_ERROR_REPORTS";
|
package/dist/index.d.ts
CHANGED
|
@@ -200,6 +200,7 @@ export declare function defineGroup<TServices extends object = EmptyServices, TN
|
|
|
200
200
|
humanInLoop?: TOwnHumanInLoop;
|
|
201
201
|
}): Group<TServices> & TypedGroupMetadata<TServices, TName, TChildren, TOwnScope, ResolveOwnHumanInLoopMode<TOwnHumanInLoop>>;
|
|
202
202
|
export declare function getCommandSourcePath(command: Command<any, any, any, any>): string | undefined;
|
|
203
|
+
export declare function hasMcpProxyConfig(group: Group<any>): boolean;
|
|
203
204
|
export { S, toJsonSchema } from "toolcraft-schema";
|
|
204
205
|
export { AuthenticationError, BadRequestError, ClientError, ConflictError, HttpError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, ServerError, ServiceUnavailableError, UnprocessableEntityError, createHttpError } from "./http-errors.js";
|
|
205
206
|
export type { HttpErrorRequest, HttpErrorResponse } from "./http-errors.js";
|
package/dist/index.js
CHANGED
|
@@ -469,6 +469,17 @@ export function defineGroup(config) {
|
|
|
469
469
|
export function getCommandSourcePath(command) {
|
|
470
470
|
return command[commandSourcePathSymbol];
|
|
471
471
|
}
|
|
472
|
+
export function hasMcpProxyConfig(group) {
|
|
473
|
+
const configSymbol = Object.getOwnPropertySymbols(group).find((candidate) => candidate.description === groupConfigSymbol.description);
|
|
474
|
+
const config = configSymbol === undefined
|
|
475
|
+
? undefined
|
|
476
|
+
: group[configSymbol];
|
|
477
|
+
if (config?.mcp !== undefined) {
|
|
478
|
+
return true;
|
|
479
|
+
}
|
|
480
|
+
const children = config?.children ?? group.children;
|
|
481
|
+
return children.some((child) => child.kind === "group" && hasMcpProxyConfig(child));
|
|
482
|
+
}
|
|
472
483
|
export { S, toJsonSchema } from "toolcraft-schema";
|
|
473
484
|
export { AuthenticationError, BadRequestError, ClientError, ConflictError, HttpError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, ServerError, ServiceUnavailableError, UnprocessableEntityError, createHttpError } from "./http-errors.js";
|
|
474
485
|
export { ApprovalDeclinedError, ToolcraftBugError, UserError };
|
package/dist/mcp-proxy.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { McpServerConfig } from "@poe-code/agent-mcp-config";
|
|
2
2
|
import { McpClient } from "tiny-mcp-client";
|
|
3
3
|
import type { Group } from "./index.js";
|
|
4
|
+
export { findProjectRoot } from "./project-root.js";
|
|
4
5
|
export interface ResolveMcpProxyOptions {
|
|
5
6
|
projectRoot?: string;
|
|
6
7
|
}
|
|
7
8
|
export declare function hasMcpProxyGroups(root: Group<any>): boolean;
|
|
8
|
-
export declare function findProjectRoot(from?: string): string | undefined;
|
|
9
9
|
export declare function resolveCachePath(name: string, projectRoot?: string): string;
|
|
10
10
|
export declare function parseRefreshEnv(value: string | undefined): "all" | Set<string> | undefined;
|
|
11
11
|
export declare function dialUpstream(name: string, config: McpServerConfig): Promise<McpClient>;
|
package/dist/mcp-proxy.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { existsSync } from "node:fs";
|
|
2
1
|
import { lstat, mkdir, readFile, rename, unlink, writeFile } from "node:fs/promises";
|
|
3
2
|
import path from "node:path";
|
|
4
3
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -6,6 +5,8 @@ import { createLogger } from "toolcraft-design";
|
|
|
6
5
|
import { HttpTransport, McpClient, StdioTransport } from "tiny-mcp-client";
|
|
7
6
|
import { hasOwnErrorCode } from "./error-codes.js";
|
|
8
7
|
import { convertJsonSchema } from "./json-schema-converter.js";
|
|
8
|
+
import { findProjectRoot } from "./project-root.js";
|
|
9
|
+
export { findProjectRoot } from "./project-root.js";
|
|
9
10
|
const GROUP_CONFIG_SYMBOL_DESCRIPTION = "toolcraft.group.config";
|
|
10
11
|
const MCP_PROXY_SCHEMA_URL = "https://poe-platform.github.io/poe-code/schemas/toolcraft/mcp-proxy.schema.json";
|
|
11
12
|
const DEFAULT_CLIENT_INFO = {
|
|
@@ -400,22 +401,6 @@ function collectProxyGroups(root) {
|
|
|
400
401
|
export function hasMcpProxyGroups(root) {
|
|
401
402
|
return collectProxyGroups(root).length > 0;
|
|
402
403
|
}
|
|
403
|
-
export function findProjectRoot(from = process.cwd()) {
|
|
404
|
-
let current = process.cwd();
|
|
405
|
-
if (from !== current) {
|
|
406
|
-
current = path.resolve(from);
|
|
407
|
-
}
|
|
408
|
-
while (true) {
|
|
409
|
-
if (existsSync(path.join(current, "package.json"))) {
|
|
410
|
-
return current;
|
|
411
|
-
}
|
|
412
|
-
const parent = path.dirname(current);
|
|
413
|
-
if (parent === current) {
|
|
414
|
-
return undefined;
|
|
415
|
-
}
|
|
416
|
-
current = parent;
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
404
|
export function resolveCachePath(name, projectRoot) {
|
|
420
405
|
const resolvedProjectRoot = projectRoot ?? findProjectRoot();
|
|
421
406
|
if (resolvedProjectRoot === undefined) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function findProjectRoot(from?: string): string | undefined;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
export function findProjectRoot(from = process.cwd()) {
|
|
4
|
+
let current = from === process.cwd() ? process.cwd() : path.resolve(from);
|
|
5
|
+
while (true) {
|
|
6
|
+
if (existsSync(path.join(current, "package.json"))) {
|
|
7
|
+
return current;
|
|
8
|
+
}
|
|
9
|
+
const parent = path.dirname(current);
|
|
10
|
+
if (parent === current) {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
current = parent;
|
|
14
|
+
}
|
|
15
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolcraft",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.87",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"type": "module",
|
|
5
6
|
"main": "dist/index.js",
|
|
6
7
|
"types": "dist/index.d.ts",
|
|
@@ -55,7 +56,7 @@
|
|
|
55
56
|
"postpack": "node ../../scripts/manage-bundled-workspace-deps.mjs cleanup . toolcraft-design @poe-code/frontmatter @poe-code/agent-mcp-config @poe-code/agent-human-in-loop @poe-code/task-list @poe-code/agent-defs @poe-code/config-mutations @poe-code/process-runner tiny-mcp-client mcp-oauth auth-store"
|
|
56
57
|
},
|
|
57
58
|
"dependencies": {
|
|
58
|
-
"toolcraft-schema": "0.0.
|
|
59
|
+
"toolcraft-schema": "0.0.87",
|
|
59
60
|
"commander": "^13.1.0",
|
|
60
61
|
"fast-string-width": "^3.0.2",
|
|
61
62
|
"fast-wrap-ansi": "^0.2.0",
|
|
@@ -68,6 +69,7 @@
|
|
|
68
69
|
"yaml": "^2.8.2"
|
|
69
70
|
},
|
|
70
71
|
"files": [
|
|
72
|
+
"LICENSE",
|
|
71
73
|
"dist"
|
|
72
74
|
],
|
|
73
75
|
"engines": {
|