@namzu/cli 0.6.0 → 0.7.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/dist/__tests__/permission-rules-reach-the-turn.test.d.ts +31 -0
- package/dist/__tests__/permission-rules-reach-the-turn.test.d.ts.map +1 -0
- package/dist/__tests__/permission-rules-reach-the-turn.test.js +132 -0
- package/dist/__tests__/permission-rules-reach-the-turn.test.js.map +1 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +16 -3
- package/dist/cli.js.map +1 -1
- package/dist/cli.test.js +7 -1
- package/dist/cli.test.js.map +1 -1
- package/dist/commands/__tests__/run-flags.test.js +0 -1
- package/dist/commands/__tests__/run-flags.test.js.map +1 -1
- package/dist/commands/__tests__/run-stream-flags.test.js +0 -1
- package/dist/commands/__tests__/run-stream-flags.test.js.map +1 -1
- package/dist/commands/run-stream.d.ts +3 -3
- package/dist/commands/run-stream.js +3 -3
- package/dist/commands/run.d.ts.map +1 -1
- package/dist/commands/run.js +4 -0
- package/dist/commands/run.js.map +1 -1
- package/dist/commands/stubs.d.ts +10 -0
- package/dist/commands/stubs.d.ts.map +1 -1
- package/dist/commands/stubs.js +12 -2
- package/dist/commands/stubs.js.map +1 -1
- package/dist/config/load.d.ts.map +1 -1
- package/dist/config/load.js +20 -4
- package/dist/config/load.js.map +1 -1
- package/dist/config/schema.d.ts +0 -12
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js.map +1 -1
- package/dist/doctor/checks/credentials.d.ts +20 -0
- package/dist/doctor/checks/credentials.d.ts.map +1 -0
- package/dist/doctor/checks/credentials.js +58 -0
- package/dist/doctor/checks/credentials.js.map +1 -0
- package/dist/doctor/checks/credentials.test.d.ts +10 -0
- package/dist/doctor/checks/credentials.test.d.ts.map +1 -0
- package/dist/doctor/checks/credentials.test.js +47 -0
- package/dist/doctor/checks/credentials.test.js.map +1 -0
- package/dist/doctor/checks/index.d.ts +2 -1
- package/dist/doctor/checks/index.d.ts.map +1 -1
- package/dist/doctor/checks/index.js +3 -1
- package/dist/doctor/checks/index.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/providers/discover.d.ts +3 -8
- package/dist/integrations/providers/discover.d.ts.map +1 -1
- package/dist/integrations/providers/discover.js +2 -12
- package/dist/integrations/providers/discover.js.map +1 -1
- package/dist/integrations/providers/discover.test.js +1 -28
- package/dist/integrations/providers/discover.test.js.map +1 -1
- package/dist/integrations/providers/index.d.ts +0 -1
- package/dist/integrations/providers/index.d.ts.map +1 -1
- package/dist/integrations/providers/index.js +0 -1
- package/dist/integrations/providers/index.js.map +1 -1
- package/dist/integrations/providers/oauth.d.ts +1 -1
- package/dist/integrations/providers/oauth.js +1 -1
- package/dist/integrations/providers/preferences.d.ts +2 -2
- package/dist/integrations/providers/preferences.js +2 -2
- package/dist/integrations/sessions/store.js +1 -1
- package/dist/integrations/sessions/store.js.map +1 -1
- package/dist/integrations/updates.d.ts +4 -12
- package/dist/integrations/updates.d.ts.map +1 -1
- package/dist/integrations/updates.js +6 -53
- package/dist/integrations/updates.js.map +1 -1
- package/dist/tui/App.d.ts.map +1 -1
- package/dist/tui/App.js +23 -131
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/Picker.d.ts +4 -4
- package/dist/tui/Picker.d.ts.map +1 -1
- package/dist/tui/Picker.js +6 -8
- package/dist/tui/Picker.js.map +1 -1
- package/dist/tui/__tests__/deferred-tool-discovery.test.d.ts +24 -0
- package/dist/tui/__tests__/deferred-tool-discovery.test.d.ts.map +1 -0
- package/dist/tui/__tests__/deferred-tool-discovery.test.js +111 -0
- package/dist/tui/__tests__/deferred-tool-discovery.test.js.map +1 -0
- package/dist/tui/__tests__/to-agent-event.test.js +88 -0
- package/dist/tui/__tests__/to-agent-event.test.js.map +1 -1
- package/dist/tui/__tests__/working-directory.test.js +0 -6
- package/dist/tui/__tests__/working-directory.test.js.map +1 -1
- package/dist/tui/agent.d.ts +16 -2
- package/dist/tui/agent.d.ts.map +1 -1
- package/dist/tui/agent.js +83 -30
- package/dist/tui/agent.js.map +1 -1
- package/dist/tui/slashCommands.d.ts +0 -6
- package/dist/tui/slashCommands.d.ts.map +1 -1
- package/dist/tui/slashCommands.js +1 -21
- package/dist/tui/slashCommands.js.map +1 -1
- package/dist/tui/types.d.ts +12 -0
- package/dist/tui/types.d.ts.map +1 -1
- package/package.json +4 -5
- package/dist/commands/tools.d.ts +0 -16
- package/dist/commands/tools.d.ts.map +0 -1
- package/dist/commands/tools.js +0 -161
- package/dist/commands/tools.js.map +0 -1
- package/dist/integrations/clawtool/agents.d.ts +0 -31
- package/dist/integrations/clawtool/agents.d.ts.map +0 -1
- package/dist/integrations/clawtool/agents.js +0 -30
- package/dist/integrations/clawtool/agents.js.map +0 -1
- package/dist/integrations/clawtool/agents.test.d.ts +0 -2
- package/dist/integrations/clawtool/agents.test.d.ts.map +0 -1
- package/dist/integrations/clawtool/agents.test.js +0 -79
- package/dist/integrations/clawtool/agents.test.js.map +0 -1
- package/dist/integrations/clawtool/auth.d.ts +0 -26
- package/dist/integrations/clawtool/auth.d.ts.map +0 -1
- package/dist/integrations/clawtool/auth.js +0 -56
- package/dist/integrations/clawtool/auth.js.map +0 -1
- package/dist/integrations/clawtool/auth.test.d.ts +0 -2
- package/dist/integrations/clawtool/auth.test.d.ts.map +0 -1
- package/dist/integrations/clawtool/auth.test.js +0 -40
- package/dist/integrations/clawtool/auth.test.js.map +0 -1
- package/dist/integrations/clawtool/binary.d.ts +0 -25
- package/dist/integrations/clawtool/binary.d.ts.map +0 -1
- package/dist/integrations/clawtool/binary.js +0 -50
- package/dist/integrations/clawtool/binary.js.map +0 -1
- package/dist/integrations/clawtool/binary.test.d.ts +0 -2
- package/dist/integrations/clawtool/binary.test.d.ts.map +0 -1
- package/dist/integrations/clawtool/binary.test.js +0 -50
- package/dist/integrations/clawtool/binary.test.js.map +0 -1
- package/dist/integrations/clawtool/daemon.d.ts +0 -37
- package/dist/integrations/clawtool/daemon.d.ts.map +0 -1
- package/dist/integrations/clawtool/daemon.js +0 -109
- package/dist/integrations/clawtool/daemon.js.map +0 -1
- package/dist/integrations/clawtool/daemon.test.d.ts +0 -11
- package/dist/integrations/clawtool/daemon.test.d.ts.map +0 -1
- package/dist/integrations/clawtool/daemon.test.js +0 -118
- package/dist/integrations/clawtool/daemon.test.js.map +0 -1
- package/dist/integrations/clawtool/dispatch.d.ts +0 -33
- package/dist/integrations/clawtool/dispatch.d.ts.map +0 -1
- package/dist/integrations/clawtool/dispatch.js +0 -155
- package/dist/integrations/clawtool/dispatch.js.map +0 -1
- package/dist/integrations/clawtool/dispatch.test.d.ts +0 -2
- package/dist/integrations/clawtool/dispatch.test.d.ts.map +0 -1
- package/dist/integrations/clawtool/dispatch.test.js +0 -138
- package/dist/integrations/clawtool/dispatch.test.js.map +0 -1
- package/dist/integrations/clawtool/index.d.ts +0 -11
- package/dist/integrations/clawtool/index.d.ts.map +0 -1
- package/dist/integrations/clawtool/index.js +0 -10
- package/dist/integrations/clawtool/index.js.map +0 -1
- package/dist/integrations/clawtool/mcp.d.ts +0 -51
- package/dist/integrations/clawtool/mcp.d.ts.map +0 -1
- package/dist/integrations/clawtool/mcp.js +0 -174
- package/dist/integrations/clawtool/mcp.js.map +0 -1
- package/dist/integrations/clawtool/mcp.test.d.ts +0 -2
- package/dist/integrations/clawtool/mcp.test.d.ts.map +0 -1
- package/dist/integrations/clawtool/mcp.test.js +0 -126
- package/dist/integrations/clawtool/mcp.test.js.map +0 -1
- package/dist/integrations/clawtool/paths.d.ts +0 -8
- package/dist/integrations/clawtool/paths.d.ts.map +0 -1
- package/dist/integrations/clawtool/paths.js +0 -19
- package/dist/integrations/clawtool/paths.js.map +0 -1
- package/dist/integrations/clawtool/peers.d.ts +0 -67
- package/dist/integrations/clawtool/peers.d.ts.map +0 -1
- package/dist/integrations/clawtool/peers.js +0 -150
- package/dist/integrations/clawtool/peers.js.map +0 -1
- package/dist/integrations/clawtool/plugin.d.ts +0 -42
- package/dist/integrations/clawtool/plugin.d.ts.map +0 -1
- package/dist/integrations/clawtool/plugin.js +0 -38
- package/dist/integrations/clawtool/plugin.js.map +0 -1
- package/dist/integrations/clawtool/state.d.ts +0 -11
- package/dist/integrations/clawtool/state.d.ts.map +0 -1
- package/dist/integrations/clawtool/state.js +0 -41
- package/dist/integrations/clawtool/state.js.map +0 -1
- package/dist/integrations/clawtool/state.test.d.ts +0 -2
- package/dist/integrations/clawtool/state.test.d.ts.map +0 -1
- package/dist/integrations/clawtool/state.test.js +0 -38
- package/dist/integrations/clawtool/state.test.js.map +0 -1
- package/dist/integrations/clawtool/tooling.d.ts +0 -52
- package/dist/integrations/clawtool/tooling.d.ts.map +0 -1
- package/dist/integrations/clawtool/tooling.js +0 -91
- package/dist/integrations/clawtool/tooling.js.map +0 -1
- package/dist/integrations/clawtool/tooling.test.d.ts +0 -2
- package/dist/integrations/clawtool/tooling.test.d.ts.map +0 -1
- package/dist/integrations/clawtool/tooling.test.js +0 -58
- package/dist/integrations/clawtool/tooling.test.js.map +0 -1
- package/dist/integrations/clawtool/types.d.ts +0 -41
- package/dist/integrations/clawtool/types.d.ts.map +0 -1
- package/dist/integrations/clawtool/types.js +0 -9
- package/dist/integrations/clawtool/types.js.map +0 -1
- package/dist/integrations/providers/secrets.d.ts +0 -37
- package/dist/integrations/providers/secrets.d.ts.map +0 -1
- package/dist/integrations/providers/secrets.js +0 -69
- package/dist/integrations/providers/secrets.js.map +0 -1
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adapt clawtool's MCP tool catalog into SDK `ToolDefinition`s so the
|
|
3
|
-
* agent loop can call clawtool's tools alongside the SDK builtins.
|
|
4
|
-
*
|
|
5
|
-
* The cli's `ClawtoolMcpClient` is not the SDK's `MCPClient`, so the SDK's
|
|
6
|
-
* `mcpToolToToolDefinition` can't be used directly — but its building
|
|
7
|
-
* blocks (`mcpJsonSchemaToZod`, `mcpToolResultToToolResult`) are public and
|
|
8
|
-
* the MCP wire shapes already match, so the adapter is a thin wrapper.
|
|
9
|
-
*
|
|
10
|
-
* Loading is best-effort: clawtool may be absent, down, or slow to spawn.
|
|
11
|
-
* `loadClawtoolToolDefinitions` never throws and never blocks longer than
|
|
12
|
-
* its timeout — on any failure it yields zero tools and the session runs on
|
|
13
|
-
* builtins alone.
|
|
14
|
-
*/
|
|
15
|
-
import { type ToolDefinition } from '@namzu/sdk';
|
|
16
|
-
import { type CreateClawtoolPluginOptions } from './plugin.js';
|
|
17
|
-
import type { ClawtoolProxyTool } from './plugin.js';
|
|
18
|
-
/** Bridged clawtool tools are namespaced under this prefix. */
|
|
19
|
-
export declare const CLAWTOOL_TOOL_PREFIX = "clawtool_";
|
|
20
|
-
/**
|
|
21
|
-
* clawtool tools namzu never bridges (bare lowercased names).
|
|
22
|
-
*
|
|
23
|
-
* The `Agent*` family is clawtool's on-disk persona manager. It writes
|
|
24
|
-
* agent definitions into a third-party tool's configuration directory —
|
|
25
|
-
* a mechanism namzu neither owns nor reads, and one that is redundant with
|
|
26
|
-
* (and confusing alongside) namzu's own in-memory dynamic sub-agents.
|
|
27
|
-
* namzu defines and dispatches sub-agents natively, so these are dropped
|
|
28
|
-
* before they reach the model.
|
|
29
|
-
*/
|
|
30
|
-
export declare const EXCLUDED_CLAWTOOL_TOOLS: Set<string>;
|
|
31
|
-
/** Whether a bridged clawtool tool (by its bare name) is excluded from namzu. */
|
|
32
|
-
export declare function isExcludedClawtoolTool(bareName: string): boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Convert one clawtool proxy tool into an SDK `ToolDefinition`. Pure.
|
|
35
|
-
* Bridged tools are flagged destructive (clawtool's MCP descriptors carry
|
|
36
|
-
* no read-only hint, so they're treated as needing consent) and run by
|
|
37
|
-
* forwarding to clawtool's `tools/call`.
|
|
38
|
-
*/
|
|
39
|
-
export declare function clawtoolToolToDefinition(proxy: ClawtoolProxyTool): ToolDefinition;
|
|
40
|
-
export interface LoadClawtoolToolsOptions extends CreateClawtoolPluginOptions {
|
|
41
|
-
/** Tool names already provided by builtins; clawtool dupes of these are skipped. */
|
|
42
|
-
readonly skipNames?: readonly string[];
|
|
43
|
-
/** Hard cap on how long to wait for the daemon before giving up. */
|
|
44
|
-
readonly timeoutMs?: number;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Connect to clawtool (spawning the daemon if needed) and adapt its tool
|
|
48
|
-
* catalog, skipping any tool whose bare lowercased name duplicates a
|
|
49
|
-
* builtin. Best-effort: returns `[]` on timeout or any error.
|
|
50
|
-
*/
|
|
51
|
-
export declare function loadClawtoolToolDefinitions(opts?: LoadClawtoolToolsOptions): Promise<ToolDefinition[]>;
|
|
52
|
-
//# sourceMappingURL=tooling.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tooling.d.ts","sourceRoot":"","sources":["../../../src/integrations/clawtool/tooling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACN,KAAK,cAAc,EAInB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,KAAK,2BAA2B,EAAwB,MAAM,aAAa,CAAA;AACpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAIpD,+DAA+D;AAC/D,eAAO,MAAM,oBAAoB,cAAc,CAAA;AAE/C;;;;;;;;;GASG;AACH,eAAO,MAAM,uBAAuB,aAAoD,CAAA;AAExF,iFAAiF;AACjF,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,iBAAiB,GAAG,cAAc,CAkBjF;AAED,MAAM,WAAW,wBAAyB,SAAQ,2BAA2B;IAC5E,oFAAoF;IACpF,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;IACtC,oEAAoE;IACpE,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED;;;;GAIG;AACH,wBAAsB,2BAA2B,CAChD,IAAI,GAAE,wBAA6B,GACjC,OAAO,CAAC,cAAc,EAAE,CAAC,CAc3B"}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adapt clawtool's MCP tool catalog into SDK `ToolDefinition`s so the
|
|
3
|
-
* agent loop can call clawtool's tools alongside the SDK builtins.
|
|
4
|
-
*
|
|
5
|
-
* The cli's `ClawtoolMcpClient` is not the SDK's `MCPClient`, so the SDK's
|
|
6
|
-
* `mcpToolToToolDefinition` can't be used directly — but its building
|
|
7
|
-
* blocks (`mcpJsonSchemaToZod`, `mcpToolResultToToolResult`) are public and
|
|
8
|
-
* the MCP wire shapes already match, so the adapter is a thin wrapper.
|
|
9
|
-
*
|
|
10
|
-
* Loading is best-effort: clawtool may be absent, down, or slow to spawn.
|
|
11
|
-
* `loadClawtoolToolDefinitions` never throws and never blocks longer than
|
|
12
|
-
* its timeout — on any failure it yields zero tools and the session runs on
|
|
13
|
-
* builtins alone.
|
|
14
|
-
*/
|
|
15
|
-
import { defineTool, mcpJsonSchemaToZod, mcpToolResultToToolResult, } from '@namzu/sdk';
|
|
16
|
-
import { createClawtoolPlugin } from './plugin.js';
|
|
17
|
-
const DEFAULT_LOAD_TIMEOUT_MS = 5_000;
|
|
18
|
-
/** Bridged clawtool tools are namespaced under this prefix. */
|
|
19
|
-
export const CLAWTOOL_TOOL_PREFIX = 'clawtool_';
|
|
20
|
-
/**
|
|
21
|
-
* clawtool tools namzu never bridges (bare lowercased names).
|
|
22
|
-
*
|
|
23
|
-
* The `Agent*` family is clawtool's on-disk persona manager. It writes
|
|
24
|
-
* agent definitions into a third-party tool's configuration directory —
|
|
25
|
-
* a mechanism namzu neither owns nor reads, and one that is redundant with
|
|
26
|
-
* (and confusing alongside) namzu's own in-memory dynamic sub-agents.
|
|
27
|
-
* namzu defines and dispatches sub-agents natively, so these are dropped
|
|
28
|
-
* before they reach the model.
|
|
29
|
-
*/
|
|
30
|
-
export const EXCLUDED_CLAWTOOL_TOOLS = new Set(['agentnew', 'agentlist', 'agentdetect']);
|
|
31
|
-
/** Whether a bridged clawtool tool (by its bare name) is excluded from namzu. */
|
|
32
|
-
export function isExcludedClawtoolTool(bareName) {
|
|
33
|
-
return EXCLUDED_CLAWTOOL_TOOLS.has(bareName.toLowerCase());
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Convert one clawtool proxy tool into an SDK `ToolDefinition`. Pure.
|
|
37
|
-
* Bridged tools are flagged destructive (clawtool's MCP descriptors carry
|
|
38
|
-
* no read-only hint, so they're treated as needing consent) and run by
|
|
39
|
-
* forwarding to clawtool's `tools/call`.
|
|
40
|
-
*/
|
|
41
|
-
export function clawtoolToolToDefinition(proxy) {
|
|
42
|
-
const inputSchema = mcpJsonSchemaToZod(proxy.inputSchema);
|
|
43
|
-
return defineTool({
|
|
44
|
-
name: `${CLAWTOOL_TOOL_PREFIX}${proxy.name}`,
|
|
45
|
-
description: proxy.description ? `[clawtool] ${proxy.description}` : `[clawtool] ${proxy.name}`,
|
|
46
|
-
inputSchema,
|
|
47
|
-
category: 'custom',
|
|
48
|
-
permissions: [],
|
|
49
|
-
readOnly: false,
|
|
50
|
-
destructive: true,
|
|
51
|
-
concurrencySafe: false,
|
|
52
|
-
execute: async (input) => {
|
|
53
|
-
const result = await proxy.call((input ?? {}));
|
|
54
|
-
return mcpToolResultToToolResult(result);
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Connect to clawtool (spawning the daemon if needed) and adapt its tool
|
|
60
|
-
* catalog, skipping any tool whose bare lowercased name duplicates a
|
|
61
|
-
* builtin. Best-effort: returns `[]` on timeout or any error.
|
|
62
|
-
*/
|
|
63
|
-
export async function loadClawtoolToolDefinitions(opts = {}) {
|
|
64
|
-
const { skipNames = [], timeoutMs = DEFAULT_LOAD_TIMEOUT_MS, ...pluginOpts } = opts;
|
|
65
|
-
const skip = new Set(skipNames.map((n) => n.toLowerCase()));
|
|
66
|
-
try {
|
|
67
|
-
const plugin = await withTimeout(createClawtoolPlugin(pluginOpts), timeoutMs);
|
|
68
|
-
return plugin.tools
|
|
69
|
-
.filter((t) => {
|
|
70
|
-
const bare = t.name.toLowerCase();
|
|
71
|
-
return !skip.has(bare) && !EXCLUDED_CLAWTOOL_TOOLS.has(bare);
|
|
72
|
-
})
|
|
73
|
-
.map(clawtoolToolToDefinition);
|
|
74
|
-
}
|
|
75
|
-
catch {
|
|
76
|
-
return [];
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
function withTimeout(promise, ms) {
|
|
80
|
-
return new Promise((resolve, reject) => {
|
|
81
|
-
const timer = setTimeout(() => reject(new Error('clawtool connect timed out')), ms);
|
|
82
|
-
promise.then((value) => {
|
|
83
|
-
clearTimeout(timer);
|
|
84
|
-
resolve(value);
|
|
85
|
-
}, (err) => {
|
|
86
|
-
clearTimeout(timer);
|
|
87
|
-
reject(err);
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=tooling.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tooling.js","sourceRoot":"","sources":["../../../src/integrations/clawtool/tooling.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAEN,UAAU,EACV,kBAAkB,EAClB,yBAAyB,GACzB,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAoC,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAGpF,MAAM,uBAAuB,GAAG,KAAK,CAAA;AAErC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,oBAAoB,GAAG,WAAW,CAAA;AAE/C;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,WA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,MAAM,GAAG,MAAM,WAAW,CAAC,oBAAoB,CAAC,UAAU,CAAC,EAAE,SAAS,CAAC,CAAA;QAC7E,OAAO,MAAM,CAAC,KAAK;aACjB,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;YACb,MAAM,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAA;YACjC,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC7D,CAAC,CAAC;aACD,GAAG,CAAC,wBAAwB,CAAC,CAAA;IAChC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,CAAA;IACV,CAAC;AACF,CAAC;AAED,SAAS,WAAW,CAAI,OAAmB,EAAE,EAAU;IACtD,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACzC,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QACnF,OAAO,CAAC,IAAI,CACX,CAAC,KAAK,EAAE,EAAE;YACT,YAAY,CAAC,KAAK,CAAC,CAAA;YACnB,OAAO,CAAC,KAAK,CAAC,CAAA;QACf,CAAC,EACD,CAAC,GAAG,EAAE,EAAE;YACP,YAAY,CAAC,KAAK,CAAC,CAAA;YACnB,MAAM,CAAC,GAAG,CAAC,CAAA;QACZ,CAAC,CACD,CAAA;IACF,CAAC,CAAC,CAAA;AACH,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tooling.test.d.ts","sourceRoot":"","sources":["../../../src/integrations/clawtool/tooling.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { CLAWTOOL_TOOL_PREFIX, clawtoolToolToDefinition } from './tooling.js';
|
|
3
|
-
function proxy(over = {}) {
|
|
4
|
-
return {
|
|
5
|
-
name: 'WebSearch',
|
|
6
|
-
description: 'Search the web',
|
|
7
|
-
inputSchema: {
|
|
8
|
-
type: 'object',
|
|
9
|
-
properties: { query: { type: 'string' } },
|
|
10
|
-
required: ['query'],
|
|
11
|
-
},
|
|
12
|
-
source: 'clawtool',
|
|
13
|
-
call: vi.fn(async () => ({ content: [{ type: 'text', text: 'ok' }], isError: false })),
|
|
14
|
-
...over,
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
describe('clawtoolToolToDefinition', () => {
|
|
18
|
-
it('namespaces the name and tags the description', () => {
|
|
19
|
-
const def = clawtoolToolToDefinition(proxy());
|
|
20
|
-
expect(def.name).toBe(`${CLAWTOOL_TOOL_PREFIX}WebSearch`);
|
|
21
|
-
expect(def.description).toBe('[clawtool] Search the web');
|
|
22
|
-
});
|
|
23
|
-
it('builds a zod schema that accepts the declared input', () => {
|
|
24
|
-
const def = clawtoolToolToDefinition(proxy());
|
|
25
|
-
expect(def.inputSchema.safeParse({ query: 'hi' }).success).toBe(true);
|
|
26
|
-
});
|
|
27
|
-
it('flags bridged tools destructive (always prompt)', () => {
|
|
28
|
-
const def = clawtoolToolToDefinition(proxy());
|
|
29
|
-
expect(def.isDestructive?.({})).toBe(true);
|
|
30
|
-
expect(def.isReadOnly?.({})).toBe(false);
|
|
31
|
-
});
|
|
32
|
-
it('forwards execution to clawtool and maps the text result', async () => {
|
|
33
|
-
const call = vi.fn(async () => ({
|
|
34
|
-
content: [{ type: 'text', text: 'search results' }],
|
|
35
|
-
isError: false,
|
|
36
|
-
}));
|
|
37
|
-
const def = clawtoolToolToDefinition(proxy({ call }));
|
|
38
|
-
const result = await def.execute({ query: 'hi' }, {});
|
|
39
|
-
expect(call).toHaveBeenCalledWith({ query: 'hi' });
|
|
40
|
-
expect(result.success).toBe(true);
|
|
41
|
-
expect(result.output).toBe('search results');
|
|
42
|
-
});
|
|
43
|
-
it('maps an MCP error result to an unsuccessful ToolResult', async () => {
|
|
44
|
-
const call = vi.fn(async () => ({
|
|
45
|
-
content: [{ type: 'text', text: 'boom' }],
|
|
46
|
-
isError: true,
|
|
47
|
-
}));
|
|
48
|
-
const def = clawtoolToolToDefinition(proxy({ call }));
|
|
49
|
-
const result = await def.execute({ query: 'hi' }, {});
|
|
50
|
-
expect(result.success).toBe(false);
|
|
51
|
-
expect(result.error).toBe('boom');
|
|
52
|
-
});
|
|
53
|
-
it('falls back to the tool name when no description', () => {
|
|
54
|
-
const def = clawtoolToolToDefinition(proxy({ description: '' }));
|
|
55
|
-
expect(def.description).toBe('[clawtool] WebSearch');
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
//# sourceMappingURL=tooling.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tooling.test.js","sourceRoot":"","sources":["../../../src/integrations/clawtool/tooling.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAGjD,OAAO,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAE7E,SAAS,KAAK,CAAC,OAAmC,EAAE;IACnD,OAAO;QACN,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,gBAAgB;QAC7B,WAAW,EAAE;YACZ,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE;YACzC,QAAQ,EAAE,CAAC,OAAO,CAAC;SACnB;QACD,MAAM,EAAE,UAAU;QAClB,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAC;QA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KAAK,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;QAChE,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;IACrD,CAAC,CAAC,CAAA;AACH,CAAC,CAAC,CAAA"}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared types for the clawtool integration.
|
|
3
|
-
*
|
|
4
|
-
* Wire shapes mirror clawtool's Go source (cogitave/clawtool) verbatim so
|
|
5
|
-
* upgrades on the clawtool side stay backwards-compatible without TS
|
|
6
|
-
* changes. The source of truth for each shape is cited inline.
|
|
7
|
-
*/
|
|
8
|
-
/**
|
|
9
|
-
* `~/.config/clawtool/daemon.json` schema. Matches the Go struct at
|
|
10
|
-
* `internal/daemon/daemon.go:41-48`. Written atomically by `daemon.Ensure`.
|
|
11
|
-
*/
|
|
12
|
-
export interface DaemonState {
|
|
13
|
-
readonly version: number;
|
|
14
|
-
readonly pid: number;
|
|
15
|
-
readonly port: number;
|
|
16
|
-
readonly started_at: string;
|
|
17
|
-
readonly token_file: string;
|
|
18
|
-
readonly log_file: string;
|
|
19
|
-
}
|
|
20
|
-
/** Per-tool descriptor returned by MCP `tools/list`. */
|
|
21
|
-
export interface McpToolDescriptor {
|
|
22
|
-
readonly name: string;
|
|
23
|
-
readonly description: string;
|
|
24
|
-
readonly inputSchema: Record<string, unknown>;
|
|
25
|
-
}
|
|
26
|
-
/** Single text-content element returned in a `tools/call` result. */
|
|
27
|
-
export interface McpTextContent {
|
|
28
|
-
readonly type: 'text';
|
|
29
|
-
readonly text: string;
|
|
30
|
-
}
|
|
31
|
-
/** Result envelope of a `tools/call` request. */
|
|
32
|
-
export interface McpCallResult {
|
|
33
|
-
readonly content: readonly McpTextContent[];
|
|
34
|
-
readonly isError?: boolean;
|
|
35
|
-
}
|
|
36
|
-
/** Discovered + connected clawtool endpoint, returned by `ensureDaemon`. */
|
|
37
|
-
export interface DaemonEndpoint {
|
|
38
|
-
readonly baseUrl: string;
|
|
39
|
-
readonly token: string;
|
|
40
|
-
}
|
|
41
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/integrations/clawtool/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CACzB;AAED,wDAAwD;AACxD,MAAM,WAAW,iBAAiB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAA;IAC5B,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC7C;AAED,qEAAqE;AACrE,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CACrB;AAED,iDAAiD;AACjD,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAA;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAA;CAC1B;AAED,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC9B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACtB"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared types for the clawtool integration.
|
|
3
|
-
*
|
|
4
|
-
* Wire shapes mirror clawtool's Go source (cogitave/clawtool) verbatim so
|
|
5
|
-
* upgrades on the clawtool side stay backwards-compatible without TS
|
|
6
|
-
* changes. The source of truth for each shape is cited inline.
|
|
7
|
-
*/
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/integrations/clawtool/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reader for clawtool's `~/.config/clawtool/secrets.toml`.
|
|
3
|
-
*
|
|
4
|
-
* Schema (per clawtool's `internal/config/portals_io.go`):
|
|
5
|
-
*
|
|
6
|
-
* [secrets.work]
|
|
7
|
-
* ANTHROPIC_API_KEY = "sk-ant-..."
|
|
8
|
-
* OPENAI_API_KEY = "sk-..."
|
|
9
|
-
*
|
|
10
|
-
* [secrets.personal]
|
|
11
|
-
* OPENROUTER_API_KEY = "..."
|
|
12
|
-
*
|
|
13
|
-
* Namzu treats each `[secrets.X]` section as a candidate credential
|
|
14
|
-
* bundle — the env-var keys inside are the same names as native env
|
|
15
|
-
* vars (e.g. `ANTHROPIC_API_KEY`). We flatten every section into a
|
|
16
|
-
* single `Map<envVarName, value[]>` so the discoverer can ask "does any
|
|
17
|
-
* source have ANTHROPIC_API_KEY?" without caring which scope it came
|
|
18
|
-
* from. Multiple sections can carry the same key; we keep all values
|
|
19
|
-
* so the picker can present them as distinct candidates if the user
|
|
20
|
-
* has multiple Anthropic accounts.
|
|
21
|
-
*/
|
|
22
|
-
export interface SecretCandidate {
|
|
23
|
-
/** Env-var name as it would appear at runtime (e.g. `ANTHROPIC_API_KEY`). */
|
|
24
|
-
readonly envName: string;
|
|
25
|
-
readonly value: string;
|
|
26
|
-
/** Which `[secrets.X]` section it came from (e.g. `work`, `personal`). */
|
|
27
|
-
readonly scope: string;
|
|
28
|
-
}
|
|
29
|
-
export declare function clawtoolSecretsPath(home?: string): string;
|
|
30
|
-
/**
|
|
31
|
-
* Read clawtool's secrets.toml and return a flat array of every
|
|
32
|
-
* env-var-style credential it carries, tagged by scope. Returns `[]`
|
|
33
|
-
* when the file is missing or unparseable — never throws (this is an
|
|
34
|
-
* optional discovery source).
|
|
35
|
-
*/
|
|
36
|
-
export declare function readClawtoolSecrets(home?: string): readonly SecretCandidate[];
|
|
37
|
-
//# sourceMappingURL=secrets.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.d.ts","sourceRoot":"","sources":["../../../src/integrations/providers/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAQH,MAAM,WAAW,eAAe;IAC/B,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;CACtB;AAED,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,CAEpE;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,MAAkB,GAAG,SAAS,eAAe,EAAE,CA4BxF"}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Reader for clawtool's `~/.config/clawtool/secrets.toml`.
|
|
3
|
-
*
|
|
4
|
-
* Schema (per clawtool's `internal/config/portals_io.go`):
|
|
5
|
-
*
|
|
6
|
-
* [secrets.work]
|
|
7
|
-
* ANTHROPIC_API_KEY = "sk-ant-..."
|
|
8
|
-
* OPENAI_API_KEY = "sk-..."
|
|
9
|
-
*
|
|
10
|
-
* [secrets.personal]
|
|
11
|
-
* OPENROUTER_API_KEY = "..."
|
|
12
|
-
*
|
|
13
|
-
* Namzu treats each `[secrets.X]` section as a candidate credential
|
|
14
|
-
* bundle — the env-var keys inside are the same names as native env
|
|
15
|
-
* vars (e.g. `ANTHROPIC_API_KEY`). We flatten every section into a
|
|
16
|
-
* single `Map<envVarName, value[]>` so the discoverer can ask "does any
|
|
17
|
-
* source have ANTHROPIC_API_KEY?" without caring which scope it came
|
|
18
|
-
* from. Multiple sections can carry the same key; we keep all values
|
|
19
|
-
* so the picker can present them as distinct candidates if the user
|
|
20
|
-
* has multiple Anthropic accounts.
|
|
21
|
-
*/
|
|
22
|
-
import { readFileSync } from 'node:fs';
|
|
23
|
-
import { homedir } from 'node:os';
|
|
24
|
-
import { join } from 'node:path';
|
|
25
|
-
import { parse as tomlParse } from 'smol-toml';
|
|
26
|
-
export function clawtoolSecretsPath(home = homedir()) {
|
|
27
|
-
return join(home, '.config', 'clawtool', 'secrets.toml');
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Read clawtool's secrets.toml and return a flat array of every
|
|
31
|
-
* env-var-style credential it carries, tagged by scope. Returns `[]`
|
|
32
|
-
* when the file is missing or unparseable — never throws (this is an
|
|
33
|
-
* optional discovery source).
|
|
34
|
-
*/
|
|
35
|
-
export function readClawtoolSecrets(home = homedir()) {
|
|
36
|
-
const path = clawtoolSecretsPath(home);
|
|
37
|
-
let raw;
|
|
38
|
-
try {
|
|
39
|
-
raw = readFileSync(path, 'utf8');
|
|
40
|
-
}
|
|
41
|
-
catch {
|
|
42
|
-
return [];
|
|
43
|
-
}
|
|
44
|
-
let parsed;
|
|
45
|
-
try {
|
|
46
|
-
parsed = tomlParse(raw);
|
|
47
|
-
}
|
|
48
|
-
catch {
|
|
49
|
-
return [];
|
|
50
|
-
}
|
|
51
|
-
if (typeof parsed !== 'object' || parsed === null)
|
|
52
|
-
return [];
|
|
53
|
-
const root = parsed;
|
|
54
|
-
const secrets = root.secrets;
|
|
55
|
-
if (typeof secrets !== 'object' || secrets === null)
|
|
56
|
-
return [];
|
|
57
|
-
const out = [];
|
|
58
|
-
for (const [scope, section] of Object.entries(secrets)) {
|
|
59
|
-
if (typeof section !== 'object' || section === null)
|
|
60
|
-
continue;
|
|
61
|
-
for (const [envName, value] of Object.entries(section)) {
|
|
62
|
-
if (typeof value === 'string' && value.length > 0) {
|
|
63
|
-
out.push({ envName, value, scope });
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return out;
|
|
68
|
-
}
|
|
69
|
-
//# sourceMappingURL=secrets.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secrets.js","sourceRoot":"","sources":["../../../src/integrations/providers/secrets.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,WAAW,CAAA;AAU9C,MAAM,UAAU,mBAAmB,CAAC,OAAe,OAAO,EAAE;IAC3D,OAAO,IAAI,CAAC,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,cAAc,CAAC,CAAA;AACzD,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe,OAAO,EAAE;IAC3D,MAAM,IAAI,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAA;IACtC,IAAI,GAAW,CAAA;IACf,IAAI,CAAC;QACJ,GAAG,GAAG,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;IACjC,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,CAAA;IACV,CAAC;IACD,IAAI,MAAe,CAAA;IACnB,IAAI,CAAC;QACJ,MAAM,GAAG,SAAS,CAAC,GAAG,CAAC,CAAA;IACxB,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,EAAE,CAAA;IACV,CAAC;IACD,IAAI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