qlogicagent 0.5.2 → 0.6.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/README.md +403 -402
- package/dist/agent.js +18 -0
- package/dist/cli.js +384 -0
- package/dist/contracts.js +1 -0
- package/dist/index.js +383 -0
- package/dist/orchestration.js +34 -0
- package/dist/types/agent/agent.d.ts +43 -0
- package/dist/types/agent/constants.d.ts +47 -0
- package/dist/types/agent/tool-access.d.ts +30 -0
- package/dist/types/agent/tool-loop.d.ts +94 -0
- package/dist/types/agent/types.d.ts +238 -0
- package/dist/types/cli/main.d.ts +11 -0
- package/dist/types/cli/stdio-server.d.ts +78 -0
- package/dist/types/cli/tool-bootstrap.d.ts +40 -0
- package/dist/types/cli/transport.d.ts +40 -0
- package/dist/types/config/config.d.ts +17 -0
- package/dist/types/contracts/hooks.d.ts +175 -0
- package/dist/types/contracts/index.d.ts +9 -0
- package/dist/types/contracts/planner.d.ts +35 -0
- package/dist/types/contracts/todo.d.ts +23 -0
- package/dist/types/index.d.ts +16 -0
- package/dist/types/llm/builtin-providers.d.ts +10 -0
- package/dist/types/llm/debug-transport.d.ts +12 -0
- package/dist/types/llm/index.d.ts +16 -0
- package/dist/types/llm/llm-client.d.ts +43 -0
- package/dist/types/llm/model-catalog.d.ts +53 -0
- package/dist/types/llm/provider-def.d.ts +59 -0
- package/dist/types/llm/provider-registry.d.ts +54 -0
- package/dist/types/llm/transport.d.ts +62 -0
- package/dist/types/llm/transports/anthropic-messages.d.ts +31 -0
- package/dist/types/llm/transports/openai-chat.d.ts +36 -0
- package/dist/types/orchestration/context/context-collapse.d.ts +58 -0
- package/dist/types/orchestration/context/context-compression.d.ts +301 -0
- package/dist/types/orchestration/context/reactive-compact.d.ts +73 -0
- package/dist/types/orchestration/context/turn-loop-guard.d.ts +86 -0
- package/dist/types/orchestration/error-handling/error-classification.d.ts +12 -0
- package/dist/types/orchestration/error-handling/failover-classification.d.ts +8 -0
- package/dist/types/orchestration/error-handling/failover-error.d.ts +33 -0
- package/dist/types/orchestration/error-handling/retry-loop.d.ts +69 -0
- package/dist/types/orchestration/index.d.ts +15 -0
- package/dist/types/orchestration/skill-improvement.d.ts +59 -0
- package/dist/types/orchestration/subagent/agent-registry.d.ts +46 -0
- package/dist/types/orchestration/subagent/fork-subagent.d.ts +98 -0
- package/dist/types/orchestration/subagent/task-types.d.ts +142 -0
- package/dist/types/orchestration/tool-loop/conversation-repair.d.ts +61 -0
- package/dist/types/orchestration/tool-loop/tool-choice-policy.d.ts +54 -0
- package/dist/types/orchestration/tool-loop/tool-loop-state.d.ts +50 -0
- package/dist/types/orchestration/tool-loop/tool-schema.d.ts +39 -0
- package/dist/types/runtime/execution/dream-agent.d.ts +199 -0
- package/dist/types/runtime/execution/forked-agent.d.ts +109 -0
- package/dist/types/runtime/execution/index.d.ts +6 -0
- package/dist/types/runtime/execution/progress-tracker.d.ts +78 -0
- package/dist/types/runtime/execution/remote-agent.d.ts +63 -0
- package/dist/types/runtime/execution/streaming-tool-executor.d.ts +100 -0
- package/dist/types/runtime/execution/tool-eligibility.d.ts +59 -0
- package/dist/types/runtime/execution/tool-result-storage.d.ts +87 -0
- package/dist/types/runtime/hooks/context-compression.d.ts +61 -0
- package/dist/types/runtime/hooks/hook-registry.d.ts +12 -0
- package/dist/types/runtime/hooks/index.d.ts +3 -0
- package/dist/types/runtime/hooks/memory-hooks.d.ts +49 -0
- package/dist/types/runtime/index.d.ts +5 -0
- package/dist/types/runtime/infra/agent-paths.d.ts +57 -0
- package/dist/types/runtime/infra/checkpoint-backend.d.ts +8 -0
- package/dist/types/runtime/infra/cleanup-registry.d.ts +23 -0
- package/dist/types/runtime/infra/disk-storage.d.ts +36 -0
- package/dist/types/runtime/infra/file-watcher.d.ts +72 -0
- package/dist/types/runtime/infra/index.d.ts +8 -0
- package/dist/types/runtime/infra/secure-storage.d.ts +81 -0
- package/dist/types/runtime/infra/task-runtime.d.ts +108 -0
- package/dist/types/runtime/infra/token-budget.d.ts +92 -0
- package/dist/types/runtime/infra/worktree-backend.d.ts +85 -0
- package/dist/types/runtime/prompt/environment-context.d.ts +23 -0
- package/dist/types/runtime/prompt/index.d.ts +3 -0
- package/dist/types/runtime/prompt/instruction-loader.d.ts +64 -0
- package/dist/types/runtime/prompt/system-prompt-sections.d.ts +63 -0
- package/dist/types/runtime/session/index.d.ts +2 -0
- package/dist/types/runtime/session/session-memory.d.ts +90 -0
- package/dist/types/runtime/session/session-persistence.d.ts +94 -0
- package/dist/types/runtime/session/session-state.d.ts +117 -0
- package/dist/types/skills/index.d.ts +119 -0
- package/dist/types/skills/mcp/index.d.ts +3 -0
- package/dist/types/skills/mcp/mcp-http-client.d.ts +66 -0
- package/dist/types/skills/mcp/mcp-manager.d.ts +83 -0
- package/dist/types/skills/mcp/mcp-stdio-client.d.ts +84 -0
- package/dist/types/skills/memory/memory-extractor.d.ts +64 -0
- package/dist/types/skills/memory/memory-store.d.ts +86 -0
- package/dist/types/skills/memory/memory-tool.d.ts +87 -0
- package/dist/types/skills/memory/qmemory-adapter.d.ts +42 -0
- package/dist/types/skills/permissions/bash-classifier.d.ts +30 -0
- package/dist/types/skills/permissions/classifier-cache.d.ts +51 -0
- package/dist/types/skills/permissions/denial-tracking.d.ts +42 -0
- package/dist/types/skills/permissions/hook-runner.d.ts +85 -0
- package/dist/types/skills/permissions/index.d.ts +12 -0
- package/dist/types/skills/permissions/permission-classifier.d.ts +41 -0
- package/dist/types/skills/permissions/rule-engine.d.ts +41 -0
- package/dist/types/skills/permissions/settings-watcher.d.ts +46 -0
- package/dist/types/skills/permissions/types.d.ts +113 -0
- package/dist/types/skills/plugins/index.d.ts +2 -0
- package/dist/types/skills/plugins/plugin-api.d.ts +38 -0
- package/dist/types/skills/plugins/plugin-loader.d.ts +42 -0
- package/dist/types/skills/plugins/plugin-marketplace.d.ts +61 -0
- package/dist/types/skills/portable-tool.d.ts +104 -0
- package/dist/types/skills/skill-system/skill-frontmatter.d.ts +19 -0
- package/dist/types/skills/skill-system/skill-guard.d.ts +23 -0
- package/dist/types/skills/skill-system/skill-loader.d.ts +16 -0
- package/dist/types/skills/skill-system/skill-source.d.ts +119 -0
- package/dist/types/skills/skill-system/skill-types.d.ts +199 -0
- package/dist/types/skills/think-tool.d.ts +16 -0
- package/dist/types/skills/todo-tool.d.ts +72 -0
- package/dist/types/skills/tools/agent-tool.d.ts +91 -0
- package/dist/types/skills/tools/apply-patch-tool.d.ts +29 -0
- package/dist/types/skills/tools/ask-user-tool.d.ts +80 -0
- package/dist/types/skills/tools/brief-tool.d.ts +74 -0
- package/dist/types/skills/tools/browser-tool.d.ts +114 -0
- package/dist/types/skills/tools/checkpoint-tool.d.ts +66 -0
- package/dist/types/skills/tools/config-tool.d.ts +63 -0
- package/dist/types/skills/tools/cron-tool.d.ts +116 -0
- package/dist/types/skills/tools/edit-tool.d.ts +43 -0
- package/dist/types/skills/tools/exec-tool.d.ts +97 -0
- package/dist/types/skills/tools/image-generate-tool.d.ts +62 -0
- package/dist/types/skills/tools/instructions-tool.d.ts +65 -0
- package/dist/types/skills/tools/lsp-tool.d.ts +153 -0
- package/dist/types/skills/tools/mcp-client-types.d.ts +269 -0
- package/dist/types/skills/tools/mcp-resource-tools.d.ts +14 -0
- package/dist/types/skills/tools/mcp-tool.d.ts +249 -0
- package/dist/types/skills/tools/monitor-tool.d.ts +113 -0
- package/dist/types/skills/tools/music-generate-tool.d.ts +55 -0
- package/dist/types/skills/tools/notebook-edit-tool.d.ts +15 -0
- package/dist/types/skills/tools/notify-tool.d.ts +53 -0
- package/dist/types/skills/tools/patch-tool.d.ts +45 -0
- package/dist/types/skills/tools/plan-mode-tool.d.ts +98 -0
- package/dist/types/skills/tools/read-tool.d.ts +51 -0
- package/dist/types/skills/tools/repl-tool.d.ts +70 -0
- package/dist/types/skills/tools/search-tool.d.ts +112 -0
- package/dist/types/skills/tools/send-message-tool.d.ts +51 -0
- package/dist/types/skills/tools/shell/bash-provider.d.ts +26 -0
- package/dist/types/skills/tools/shell/command-classification.d.ts +44 -0
- package/dist/types/skills/tools/shell/command-semantics.d.ts +14 -0
- package/dist/types/skills/tools/shell/destructive-command-warning.d.ts +10 -0
- package/dist/types/skills/tools/shell/exec-permissions.d.ts +52 -0
- package/dist/types/skills/tools/shell/index.d.ts +17 -0
- package/dist/types/skills/tools/shell/powershell-provider.d.ts +15 -0
- package/dist/types/skills/tools/shell/shell-command.d.ts +54 -0
- package/dist/types/skills/tools/shell/shell-exec.d.ts +33 -0
- package/dist/types/skills/tools/shell/shell-provider.d.ts +85 -0
- package/dist/types/skills/tools/shell/task-output.d.ts +45 -0
- package/dist/types/skills/tools/skill-invoke-tool.d.ts +46 -0
- package/dist/types/skills/tools/skill-list-tool.d.ts +33 -0
- package/dist/types/skills/tools/skill-manage-tool.d.ts +73 -0
- package/dist/types/skills/tools/skill-view-tool.d.ts +37 -0
- package/dist/types/skills/tools/sleep-tool.d.ts +49 -0
- package/dist/types/skills/tools/structured-output-tool.d.ts +116 -0
- package/dist/types/skills/tools/task-tool.d.ts +104 -0
- package/dist/types/skills/tools/team-tool.d.ts +89 -0
- package/dist/types/skills/tools/tool-search-tool.d.ts +51 -0
- package/dist/types/skills/tools/tts-tool.d.ts +38 -0
- package/dist/types/skills/tools/video-edit-tool.d.ts +69 -0
- package/dist/types/skills/tools/video-generate-tool.d.ts +62 -0
- package/dist/types/skills/tools/video-merge-tool.d.ts +105 -0
- package/dist/types/skills/tools/video-upscale-tool.d.ts +45 -0
- package/dist/types/skills/tools/web-fetch-tool.d.ts +78 -0
- package/dist/types/skills/tools/web-search-tool.d.ts +57 -0
- package/dist/types/skills/tools/workflow-tool.d.ts +44 -0
- package/dist/types/skills/tools/worktree-tool.d.ts +69 -0
- package/dist/types/skills/tools/write-tool.d.ts +45 -0
- package/dist/types/skills/tools.d.ts +65 -0
- package/package.json +4 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
import type { HookPoint, HookHandler } from "../../contracts/hooks.js";
|
|
3
|
+
import type { WorkspaceSkill } from "../skill-system/skill-types.js";
|
|
4
|
+
export type PluginHookPhase = "preToolUse" | "postToolUse" | "onTurnStart" | "onTurnEnd" | "onSessionEnd";
|
|
5
|
+
/** Map plugin hook phases to internal HookPoint names */
|
|
6
|
+
export declare const PLUGIN_HOOK_MAP: Record<PluginHookPhase, HookPoint>;
|
|
7
|
+
export interface PluginApi {
|
|
8
|
+
/** Register a tool that will be available to the LLM. */
|
|
9
|
+
registerTool(tool: PortableTool): void;
|
|
10
|
+
/** Register a hook at a specific lifecycle phase. */
|
|
11
|
+
registerHook(phase: PluginHookPhase, handler: HookHandler<any>): void;
|
|
12
|
+
/** Register a skill (Markdown instructions + metadata). */
|
|
13
|
+
registerSkill(skill: WorkspaceSkill): void;
|
|
14
|
+
/** Get plugin-scoped configuration (from openclaw/plugins/name/config.json). */
|
|
15
|
+
getConfig(): Record<string, unknown>;
|
|
16
|
+
/**
|
|
17
|
+
* Set an activation check function. When it returns false, the plugin's
|
|
18
|
+
* tools and hooks are temporarily deactivated. Results are cached for
|
|
19
|
+
* `ttlMs` (default: 60 000) to avoid expensive re-checks.
|
|
20
|
+
*/
|
|
21
|
+
setActivationCheck(checkFn: () => boolean | Promise<boolean>, ttlMs?: number): void;
|
|
22
|
+
/** Plugin's own name (directory name). */
|
|
23
|
+
readonly pluginName: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Every plugin must export a `register` function.
|
|
27
|
+
* Called once during plugin loading.
|
|
28
|
+
*/
|
|
29
|
+
export interface PluginModule {
|
|
30
|
+
register(api: PluginApi): void | Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
export interface LoadedPlugin {
|
|
33
|
+
name: string;
|
|
34
|
+
directory: string;
|
|
35
|
+
toolCount: number;
|
|
36
|
+
hookCount: number;
|
|
37
|
+
skillCount: number;
|
|
38
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { HookRegistry } from "../../contracts/hooks.js";
|
|
2
|
+
import type { WorkspaceSkill } from "../skill-system/skill-types.js";
|
|
3
|
+
import { type LoadedPlugin } from "./plugin-api.js";
|
|
4
|
+
export interface PluginLoaderConfig {
|
|
5
|
+
/** Directories to scan for plugins (order = priority) */
|
|
6
|
+
pluginDirs: string[];
|
|
7
|
+
/** HookRegistry to wire plugin hooks into */
|
|
8
|
+
hookRegistry: HookRegistry;
|
|
9
|
+
/** Logger */
|
|
10
|
+
log?: {
|
|
11
|
+
info(msg: string): void;
|
|
12
|
+
warn(msg: string): void;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare class PluginLoader {
|
|
16
|
+
private config;
|
|
17
|
+
private loaded;
|
|
18
|
+
private pluginSkills;
|
|
19
|
+
private activations;
|
|
20
|
+
private log;
|
|
21
|
+
constructor(config: PluginLoaderConfig);
|
|
22
|
+
/**
|
|
23
|
+
* Discover and load all plugins from configured directories.
|
|
24
|
+
* Returns the list of successfully loaded plugins.
|
|
25
|
+
*/
|
|
26
|
+
loadAll(): Promise<LoadedPlugin[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Get all skills registered by plugins.
|
|
29
|
+
*/
|
|
30
|
+
getPluginSkills(): WorkspaceSkill[];
|
|
31
|
+
/**
|
|
32
|
+
* Get list of all loaded plugins.
|
|
33
|
+
*/
|
|
34
|
+
getLoaded(): LoadedPlugin[];
|
|
35
|
+
/**
|
|
36
|
+
* Re-check activation for plugins whose TTL has expired.
|
|
37
|
+
* Call this before tool resolution or periodically in the agent loop.
|
|
38
|
+
* Only re-runs check functions when the cache has expired.
|
|
39
|
+
*/
|
|
40
|
+
refreshActivations(): Promise<void>;
|
|
41
|
+
private loadPlugin;
|
|
42
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export interface MarketplaceSource {
|
|
2
|
+
/** Source type */
|
|
3
|
+
type: "npm" | "git" | "url";
|
|
4
|
+
/** Package name (npm), git URL, or zip URL */
|
|
5
|
+
specifier: string;
|
|
6
|
+
/** Optional version constraint (npm only) */
|
|
7
|
+
version?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface MarketplaceConfig {
|
|
10
|
+
/** Enabled plugins from marketplace */
|
|
11
|
+
enabledPlugins: MarketplaceSource[];
|
|
12
|
+
/**
|
|
13
|
+
* Enterprise policy: only allow plugins matching these names.
|
|
14
|
+
* If set, any plugin not in the allowlist is blocked.
|
|
15
|
+
*/
|
|
16
|
+
allowlist?: string[];
|
|
17
|
+
/**
|
|
18
|
+
* Enterprise policy: block these plugin names.
|
|
19
|
+
*/
|
|
20
|
+
blocklist?: string[];
|
|
21
|
+
}
|
|
22
|
+
export interface MarketplaceCatalogEntry {
|
|
23
|
+
/** Plugin name */
|
|
24
|
+
name: string;
|
|
25
|
+
/** Installed version */
|
|
26
|
+
version: string;
|
|
27
|
+
/** Source that provided this plugin */
|
|
28
|
+
source: MarketplaceSource;
|
|
29
|
+
/** Local install path */
|
|
30
|
+
installPath: string;
|
|
31
|
+
/** Install timestamp */
|
|
32
|
+
installedAt: string;
|
|
33
|
+
}
|
|
34
|
+
export interface InstalledPluginsManifest {
|
|
35
|
+
version: 1;
|
|
36
|
+
plugins: MarketplaceCatalogEntry[];
|
|
37
|
+
}
|
|
38
|
+
export interface MarketplaceLogger {
|
|
39
|
+
info(msg: string): void;
|
|
40
|
+
warn(msg: string): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Load plugins from cache only (no network). Fast startup path.
|
|
44
|
+
* CC parity: loadAllPluginsCacheOnly()
|
|
45
|
+
*/
|
|
46
|
+
export declare function loadCachedPlugins(): string[];
|
|
47
|
+
/**
|
|
48
|
+
* Install/update marketplace plugins and return their local paths.
|
|
49
|
+
* CC parity: loadAllPluginsWithDynamic()
|
|
50
|
+
*/
|
|
51
|
+
export declare function installMarketplacePlugins(config: MarketplaceConfig, log: MarketplaceLogger): Promise<string[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Get the marketplace config from user settings.
|
|
54
|
+
* Reads ~/.qlogicagent/marketplace.json
|
|
55
|
+
*/
|
|
56
|
+
export declare function loadMarketplaceConfig(): MarketplaceConfig | null;
|
|
57
|
+
/**
|
|
58
|
+
* Combine local plugin dirs + marketplace plugin dirs for PluginLoader.
|
|
59
|
+
* CC parity: loadAllPlugins() merges session + marketplace + builtin.
|
|
60
|
+
*/
|
|
61
|
+
export declare function resolveAllPluginDirs(localDirs: string[], log: MarketplaceLogger): Promise<string[]>;
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content block returned by tool execution.
|
|
3
|
+
* Compatible with OpenAI / Anthropic content array format.
|
|
4
|
+
*/
|
|
5
|
+
export interface ToolContentBlock {
|
|
6
|
+
type: "text" | "image";
|
|
7
|
+
text?: string;
|
|
8
|
+
/** base64-encoded image data (only when type === "image") */
|
|
9
|
+
data?: string;
|
|
10
|
+
mimeType?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Result of executing a portable tool.
|
|
14
|
+
*/
|
|
15
|
+
export interface PortableToolResult {
|
|
16
|
+
content: ToolContentBlock[];
|
|
17
|
+
/** Arbitrary structured metadata for the calling runtime. */
|
|
18
|
+
details?: Record<string, unknown>;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A runtime-agnostic tool definition.
|
|
22
|
+
*
|
|
23
|
+
* @typeParam TParams The expected parameter shape (for TypeScript consumers).
|
|
24
|
+
*/
|
|
25
|
+
export interface PortableTool<TParams = Record<string, unknown>> {
|
|
26
|
+
/** Unique tool name (e.g. "think", "todo", "memory"). */
|
|
27
|
+
name: string;
|
|
28
|
+
/** Human-readable label. */
|
|
29
|
+
label: string;
|
|
30
|
+
/** Tool description shown to the LLM. */
|
|
31
|
+
description: string;
|
|
32
|
+
/** JSON Schema object describing the tool's parameters. */
|
|
33
|
+
parameters: Record<string, unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* When true, the tool should NOT appear in the default tool list.
|
|
36
|
+
* The host injects it only for complex tasks (e.g. multi-step reasoning)
|
|
37
|
+
* or when explicitly activated via tool_search.
|
|
38
|
+
* This saves context tokens in simple conversations.
|
|
39
|
+
*/
|
|
40
|
+
shouldDefer?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the tool can safely run concurrently with other tools.
|
|
43
|
+
* When true, the runtime may execute this tool in parallel with others.
|
|
44
|
+
* Default: false (sequential execution assumed).
|
|
45
|
+
*/
|
|
46
|
+
isConcurrencySafe?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Whether the tool only reads state and never mutates anything.
|
|
49
|
+
* Read-only tools can skip confirmation prompts in strict permission modes.
|
|
50
|
+
*/
|
|
51
|
+
isReadOnly?: boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the tool is currently available.
|
|
54
|
+
* CC parity: tools that return false are excluded from getTools().
|
|
55
|
+
* Default: true (always enabled).
|
|
56
|
+
*/
|
|
57
|
+
isEnabled?: () => boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Whether the tool performs destructive operations (delete, overwrite, etc.).
|
|
60
|
+
* CC parity: Tool.isDestructive field.
|
|
61
|
+
* Used by permission system to require confirmation.
|
|
62
|
+
*/
|
|
63
|
+
isDestructive?: boolean;
|
|
64
|
+
/**
|
|
65
|
+
* Tool-specific permission check before execution.
|
|
66
|
+
* CC parity: Tool.checkPermissions — returns allow/deny with reason.
|
|
67
|
+
* Default (via buildTool): always allow, deferring to general permission system.
|
|
68
|
+
*/
|
|
69
|
+
checkPermissions?: (params: TParams) => {
|
|
70
|
+
behavior: "allow" | "deny";
|
|
71
|
+
reason?: string;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Brief keyword hint for tool_search to match against
|
|
75
|
+
* (e.g. "return the final response as structured JSON").
|
|
76
|
+
*/
|
|
77
|
+
searchHint?: string;
|
|
78
|
+
/**
|
|
79
|
+
* Maximum allowed content size in characters for the tool result.
|
|
80
|
+
* The runtime should truncate/reject results exceeding this.
|
|
81
|
+
*/
|
|
82
|
+
maxResultSizeChars?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Execute the tool.
|
|
85
|
+
*
|
|
86
|
+
* @param toolCallId - Unique ID for this tool invocation (for tracing).
|
|
87
|
+
* @param params - Parsed parameters matching the JSON Schema.
|
|
88
|
+
* @param signal - Optional abort signal.
|
|
89
|
+
* @returns Tool result with content blocks + optional details.
|
|
90
|
+
*/
|
|
91
|
+
execute(toolCallId: string, params: TParams, signal?: AbortSignal): Promise<PortableToolResult>;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Build a complete PortableTool from a partial definition, filling safe defaults.
|
|
95
|
+
* CC parity: buildTool() factory in Tool.ts.
|
|
96
|
+
*
|
|
97
|
+
* Defaults (fail-closed where it matters):
|
|
98
|
+
* - isEnabled → true
|
|
99
|
+
* - isConcurrencySafe → false
|
|
100
|
+
* - isReadOnly → false
|
|
101
|
+
* - isDestructive → false
|
|
102
|
+
* - checkPermissions → { behavior: "allow" } (defer to general permission system)
|
|
103
|
+
*/
|
|
104
|
+
export declare function buildTool<TParams = Record<string, unknown>>(partial: PortableTool<TParams>): PortableTool<TParams>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ParsedSkillFrontmatter, SkillInvocationPolicy, SkillMetadata } from "./skill-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Parse a YAML-like frontmatter block into a flat key→value record.
|
|
4
|
+
* Uses a lightweight line parser to avoid a YAML library dependency.
|
|
5
|
+
*/
|
|
6
|
+
export declare function parseFrontmatter(content: string): ParsedSkillFrontmatter;
|
|
7
|
+
/**
|
|
8
|
+
* Resolve structured metadata from the `metadata:` frontmatter field.
|
|
9
|
+
* Expects `metadata: {"openclaw": {...}}` (JSON format).
|
|
10
|
+
*/
|
|
11
|
+
export declare function resolveSkillMetadata(frontmatter: ParsedSkillFrontmatter): SkillMetadata | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Resolve invocation policy from frontmatter fields.
|
|
14
|
+
*/
|
|
15
|
+
export declare function resolveSkillInvocationPolicy(frontmatter: ParsedSkillFrontmatter): SkillInvocationPolicy;
|
|
16
|
+
/**
|
|
17
|
+
* Get the canonical key for a skill (metadata.skillKey or skill.name).
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveSkillKey(skillName: string, metadata?: SkillMetadata): string;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { SkillFsDeps, SkillPathDeps, SkillScanFinding, SkillScanOptions, SkillScanSummary } from "./skill-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Scan a source string for security findings.
|
|
4
|
+
* This is a pure function — no file I/O.
|
|
5
|
+
*/
|
|
6
|
+
export declare function scanSource(source: string, filePath: string): SkillScanFinding[];
|
|
7
|
+
export interface SkillGuardDeps {
|
|
8
|
+
fs: SkillFsDeps;
|
|
9
|
+
path: SkillPathDeps;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Scan an entire skill directory for security issues.
|
|
13
|
+
* Returns a summary with per-file findings.
|
|
14
|
+
*/
|
|
15
|
+
export declare function scanSkillDirectory(deps: SkillGuardDeps, skillDir: string, opts?: SkillScanOptions): Promise<SkillScanSummary>;
|
|
16
|
+
/**
|
|
17
|
+
* Quick check: does this source have any critical findings?
|
|
18
|
+
*/
|
|
19
|
+
export declare function hasCriticalFindings(source: string, filePath: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Check if a file extension is scannable by the guard.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isScannable(filePath: string, pathDeps: SkillPathDeps): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SkillEntry, SkillLoadLimits, SkillLoaderDeps, SkillSnapshot } from "./skill-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Discover all skills from configured search paths, applying precedence merge
|
|
4
|
+
* and size/count limits. Returns fully parsed `SkillEntry` objects.
|
|
5
|
+
*/
|
|
6
|
+
export declare function loadSkillEntries(deps: SkillLoaderDeps): SkillEntry[];
|
|
7
|
+
/**
|
|
8
|
+
* Filter skill entries by a name-based filter list.
|
|
9
|
+
* If filter is undefined or empty, returns all entries.
|
|
10
|
+
*/
|
|
11
|
+
export declare function filterSkillEntries(entries: SkillEntry[], skillFilter?: string[]): SkillEntry[];
|
|
12
|
+
/**
|
|
13
|
+
* Build a system-prompt-embeddable skill snapshot.
|
|
14
|
+
* Applies count and character limits from the provided config.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildSkillSnapshot(entries: SkillEntry[], limits?: SkillLoadLimits, skillFilter?: string[]): SkillSnapshot;
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { SkillScanSummary } from "./skill-types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Trust level for a skill based on its origin.
|
|
4
|
+
* Higher trust = fewer restrictions.
|
|
5
|
+
*/
|
|
6
|
+
export type TrustLevel = "builtin" | "verified" | "community" | "unknown";
|
|
7
|
+
/**
|
|
8
|
+
* Result of a skill security scan decision.
|
|
9
|
+
*/
|
|
10
|
+
export type ScanVerdict = "pass" | "quarantine" | "reject";
|
|
11
|
+
/**
|
|
12
|
+
* A resolved skill source descriptor.
|
|
13
|
+
*/
|
|
14
|
+
export interface SkillSourceDescriptor {
|
|
15
|
+
/** Source type. */
|
|
16
|
+
kind: "bundled" | "github" | "npm" | "local" | "tap";
|
|
17
|
+
/** Human-readable identifier, e.g. "github:user/repo" or "npm:@scope/pkg". */
|
|
18
|
+
identifier: string;
|
|
19
|
+
/** Trust level derived from source type + verification status. */
|
|
20
|
+
trust: TrustLevel;
|
|
21
|
+
/** Version constraint (semver or tag). */
|
|
22
|
+
version?: string;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Result of fetching a skill from a remote source.
|
|
26
|
+
*/
|
|
27
|
+
export interface SkillFetchResult {
|
|
28
|
+
/** Local directory where fetched content was placed. */
|
|
29
|
+
quarantineDir: string;
|
|
30
|
+
/** Manifest metadata if found. */
|
|
31
|
+
name?: string;
|
|
32
|
+
version?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Dependencies for the skill fetch step.
|
|
36
|
+
* Consumers inject actual HTTP/git/npm implementations.
|
|
37
|
+
*/
|
|
38
|
+
export interface SkillFetchDeps {
|
|
39
|
+
/**
|
|
40
|
+
* Download / clone / extract a skill from its source into a quarantine dir.
|
|
41
|
+
* Must NOT place content in the final install location.
|
|
42
|
+
*/
|
|
43
|
+
fetch(source: SkillSourceDescriptor, quarantineDir: string): Promise<SkillFetchResult>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Dependencies for the skill storage step.
|
|
47
|
+
* Manages the local skill directory and registry.
|
|
48
|
+
*/
|
|
49
|
+
export interface SkillStorageDeps {
|
|
50
|
+
/** Root directory for installed skills (e.g. ~/.xiaozhiclaw/skills/). */
|
|
51
|
+
skillsDir: string;
|
|
52
|
+
/** Registry subdirectory (e.g. ~/.xiaozhiclaw/skills/.registry/). */
|
|
53
|
+
registryDir: string;
|
|
54
|
+
/** Move content from quarantine to final location. */
|
|
55
|
+
moveToInstallDir(quarantineDir: string, skillName: string): Promise<string>;
|
|
56
|
+
/** Remove an installed skill directory. */
|
|
57
|
+
removeSkill(skillName: string): Promise<void>;
|
|
58
|
+
/** Read the registry lock file. */
|
|
59
|
+
readLockfile(): Promise<SkillLockfile>;
|
|
60
|
+
/** Write the registry lock file. */
|
|
61
|
+
writeLockfile(lockfile: SkillLockfile): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Single entry in the skill lockfile.
|
|
65
|
+
*/
|
|
66
|
+
export interface SkillLockEntry {
|
|
67
|
+
name: string;
|
|
68
|
+
source: SkillSourceDescriptor;
|
|
69
|
+
installedAt: string;
|
|
70
|
+
scanVerdict: ScanVerdict;
|
|
71
|
+
scanSummary?: SkillScanSummary;
|
|
72
|
+
/** Integrity hash of the SKILL.md content (sha256). */
|
|
73
|
+
integrity?: string;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Complete lockfile for all installed skills.
|
|
77
|
+
*/
|
|
78
|
+
export interface SkillLockfile {
|
|
79
|
+
version: 1;
|
|
80
|
+
entries: Record<string, SkillLockEntry>;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Result of a skill install operation.
|
|
84
|
+
*/
|
|
85
|
+
export interface SkillInstallResult {
|
|
86
|
+
success: boolean;
|
|
87
|
+
name: string;
|
|
88
|
+
installDir?: string;
|
|
89
|
+
verdict: ScanVerdict;
|
|
90
|
+
scanSummary?: SkillScanSummary;
|
|
91
|
+
error?: string;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Orchestrate the full install pipeline:
|
|
95
|
+
* Fetch → Quarantine → Scan → Validate → Move → Lock
|
|
96
|
+
*
|
|
97
|
+
* This function is pure orchestration — actual I/O is delegated to deps.
|
|
98
|
+
*/
|
|
99
|
+
export declare function installSkill(params: {
|
|
100
|
+
source: SkillSourceDescriptor;
|
|
101
|
+
fetchDeps: SkillFetchDeps;
|
|
102
|
+
storageDeps: SkillStorageDeps;
|
|
103
|
+
scanSkillDir: (dir: string) => Promise<SkillScanSummary>;
|
|
104
|
+
quarantineDir: string;
|
|
105
|
+
}): Promise<SkillInstallResult>;
|
|
106
|
+
/**
|
|
107
|
+
* Uninstall a skill: remove from disk + update lockfile.
|
|
108
|
+
*/
|
|
109
|
+
export declare function uninstallSkill(params: {
|
|
110
|
+
skillName: string;
|
|
111
|
+
storageDeps: SkillStorageDeps;
|
|
112
|
+
}): Promise<{
|
|
113
|
+
success: boolean;
|
|
114
|
+
error?: string;
|
|
115
|
+
}>;
|
|
116
|
+
/**
|
|
117
|
+
* Create an empty lockfile.
|
|
118
|
+
*/
|
|
119
|
+
export declare function createEmptyLockfile(): SkillLockfile;
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parsed YAML frontmatter from a SKILL.md file.
|
|
3
|
+
* Keys are lowercased header names; values are always coerced to strings.
|
|
4
|
+
*/
|
|
5
|
+
export type ParsedSkillFrontmatter = Record<string, string>;
|
|
6
|
+
/**
|
|
7
|
+
* A discovered skill on the filesystem.
|
|
8
|
+
*/
|
|
9
|
+
export interface WorkspaceSkill {
|
|
10
|
+
/** Display name (directory name by default). */
|
|
11
|
+
name: string;
|
|
12
|
+
/** One-line description extracted from frontmatter. */
|
|
13
|
+
description?: string;
|
|
14
|
+
/** Source tag for precedence/debugging, e.g. "bundled", "user", "project". */
|
|
15
|
+
source: string;
|
|
16
|
+
/** Absolute path to the SKILL.md file. */
|
|
17
|
+
filePath: string;
|
|
18
|
+
/** Absolute path to the skill directory (parent of SKILL.md). */
|
|
19
|
+
baseDir: string;
|
|
20
|
+
/** Primary runtime environment hint, e.g. "node", "python". */
|
|
21
|
+
primaryEnv?: string;
|
|
22
|
+
/** Environment variables the skill requires. */
|
|
23
|
+
requiredEnv?: string[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Package-manager install specification for a skill dependency.
|
|
27
|
+
*/
|
|
28
|
+
export interface SkillInstallSpec {
|
|
29
|
+
id?: string;
|
|
30
|
+
kind: "brew" | "node" | "go" | "uv" | "download";
|
|
31
|
+
label?: string;
|
|
32
|
+
bins?: string[];
|
|
33
|
+
os?: string[];
|
|
34
|
+
formula?: string;
|
|
35
|
+
package?: string;
|
|
36
|
+
module?: string;
|
|
37
|
+
url?: string;
|
|
38
|
+
archive?: string;
|
|
39
|
+
extract?: boolean;
|
|
40
|
+
stripComponents?: number;
|
|
41
|
+
targetDir?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Structured metadata from the `openclaw:` block inside SKILL.md frontmatter.
|
|
45
|
+
*/
|
|
46
|
+
export interface SkillMetadata {
|
|
47
|
+
/** If true, always include in prompt regardless of filter. */
|
|
48
|
+
always?: boolean;
|
|
49
|
+
/** Override key for deduplication / user-facing identification. */
|
|
50
|
+
skillKey?: string;
|
|
51
|
+
primaryEnv?: string;
|
|
52
|
+
emoji?: string;
|
|
53
|
+
homepage?: string;
|
|
54
|
+
/** Platform restriction: "win32", "darwin", "linux". */
|
|
55
|
+
os?: string[];
|
|
56
|
+
/** Use-case category for UI grouping. */
|
|
57
|
+
category?: string;
|
|
58
|
+
requires?: {
|
|
59
|
+
bins?: string[];
|
|
60
|
+
anyBins?: string[];
|
|
61
|
+
env?: string[];
|
|
62
|
+
config?: string[];
|
|
63
|
+
};
|
|
64
|
+
install?: SkillInstallSpec[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Controls how a skill may be activated by user commands or model tool calls.
|
|
68
|
+
*/
|
|
69
|
+
export interface SkillInvocationPolicy {
|
|
70
|
+
/** Whether users can directly invoke this skill via slash-command. */
|
|
71
|
+
userInvocable: boolean;
|
|
72
|
+
/** If true, the model cannot trigger this skill autonomously. */
|
|
73
|
+
disableModelInvocation: boolean;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* A fully resolved skill entry with parsed metadata.
|
|
77
|
+
*/
|
|
78
|
+
export interface SkillEntry {
|
|
79
|
+
skill: WorkspaceSkill;
|
|
80
|
+
frontmatter: ParsedSkillFrontmatter;
|
|
81
|
+
metadata?: SkillMetadata;
|
|
82
|
+
invocation?: SkillInvocationPolicy;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Slash-command dispatch specification for a skill.
|
|
86
|
+
*/
|
|
87
|
+
export interface SkillCommandDispatchSpec {
|
|
88
|
+
kind: "tool";
|
|
89
|
+
toolName: string;
|
|
90
|
+
argMode?: "raw";
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A skill-derived slash-command for IM platforms.
|
|
94
|
+
*/
|
|
95
|
+
export interface SkillCommandSpec {
|
|
96
|
+
name: string;
|
|
97
|
+
skillName: string;
|
|
98
|
+
description: string;
|
|
99
|
+
dispatch?: SkillCommandDispatchSpec;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Serialized skill snapshot for system-prompt embedding.
|
|
103
|
+
*/
|
|
104
|
+
export interface SkillSnapshot {
|
|
105
|
+
prompt: string;
|
|
106
|
+
skills: Array<{
|
|
107
|
+
name: string;
|
|
108
|
+
primaryEnv?: string;
|
|
109
|
+
requiredEnv?: string[];
|
|
110
|
+
}>;
|
|
111
|
+
skillFilter?: string[];
|
|
112
|
+
version?: number;
|
|
113
|
+
}
|
|
114
|
+
export type SkillScanSeverity = "info" | "warn" | "critical";
|
|
115
|
+
export interface SkillScanFinding {
|
|
116
|
+
ruleId: string;
|
|
117
|
+
severity: SkillScanSeverity;
|
|
118
|
+
file: string;
|
|
119
|
+
line: number;
|
|
120
|
+
message: string;
|
|
121
|
+
evidence: string;
|
|
122
|
+
}
|
|
123
|
+
export interface SkillScanSummary {
|
|
124
|
+
scannedFiles: number;
|
|
125
|
+
critical: number;
|
|
126
|
+
warn: number;
|
|
127
|
+
info: number;
|
|
128
|
+
findings: SkillScanFinding[];
|
|
129
|
+
}
|
|
130
|
+
export interface SkillScanOptions {
|
|
131
|
+
includeFiles?: string[];
|
|
132
|
+
maxFiles?: number;
|
|
133
|
+
maxFileBytes?: number;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Filesystem dependencies injected by the host runtime.
|
|
137
|
+
* Keeps the skill system decoupled from Node.js `fs` / `path`.
|
|
138
|
+
*/
|
|
139
|
+
export interface SkillFsDeps {
|
|
140
|
+
readFileSync(path: string, encoding: "utf-8"): string;
|
|
141
|
+
readFile(path: string, encoding: "utf-8"): Promise<string>;
|
|
142
|
+
existsSync(path: string): boolean;
|
|
143
|
+
statSync(path: string): {
|
|
144
|
+
size: number;
|
|
145
|
+
mtimeMs: number;
|
|
146
|
+
isDirectory(): boolean;
|
|
147
|
+
};
|
|
148
|
+
readdirSync(path: string, opts: {
|
|
149
|
+
withFileTypes: true;
|
|
150
|
+
}): Array<{
|
|
151
|
+
name: string;
|
|
152
|
+
isDirectory(): boolean;
|
|
153
|
+
isSymbolicLink(): boolean;
|
|
154
|
+
}>;
|
|
155
|
+
realpathSync(path: string): string;
|
|
156
|
+
}
|
|
157
|
+
export interface SkillPathDeps {
|
|
158
|
+
join(...segments: string[]): string;
|
|
159
|
+
resolve(...segments: string[]): string;
|
|
160
|
+
extname(p: string): string;
|
|
161
|
+
sep: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Configurable limits for skill discovery to prevent abuse.
|
|
165
|
+
*/
|
|
166
|
+
export interface SkillLoadLimits {
|
|
167
|
+
maxCandidatesPerRoot?: number;
|
|
168
|
+
maxSkillsLoadedPerSource?: number;
|
|
169
|
+
maxSkillsInPrompt?: number;
|
|
170
|
+
maxSkillsPromptChars?: number;
|
|
171
|
+
maxSkillFileBytes?: number;
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Search paths for skill discovery, ordered by precedence (low → high).
|
|
175
|
+
*/
|
|
176
|
+
export interface SkillSearchPaths {
|
|
177
|
+
/** Bundled with npm package or app install. */
|
|
178
|
+
bundled?: string;
|
|
179
|
+
/** Extra directories from config. */
|
|
180
|
+
extra?: string[];
|
|
181
|
+
/** Managed skills (installed via CLI). */
|
|
182
|
+
managed?: string;
|
|
183
|
+
/** Personal agent skills: ~/.agents/skills/ */
|
|
184
|
+
personalAgents?: string;
|
|
185
|
+
/** Project agent skills: <workspace>/.agents/skills/ */
|
|
186
|
+
projectAgents?: string;
|
|
187
|
+
/** Workspace-level: <workspace>/skills/ */
|
|
188
|
+
workspace?: string;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Aggregate deps for the skill loader.
|
|
192
|
+
*/
|
|
193
|
+
export interface SkillLoaderDeps {
|
|
194
|
+
fs: SkillFsDeps;
|
|
195
|
+
path: SkillPathDeps;
|
|
196
|
+
homeDir: string;
|
|
197
|
+
searchPaths: SkillSearchPaths;
|
|
198
|
+
limits?: SkillLoadLimits;
|
|
199
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PortableTool } from "./portable-tool.js";
|
|
2
|
+
export declare const THINK_TOOL_NAME: "think";
|
|
3
|
+
export interface ThinkToolParams {
|
|
4
|
+
thought: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const THINK_TOOL_SCHEMA: {
|
|
7
|
+
readonly type: "object";
|
|
8
|
+
readonly properties: {
|
|
9
|
+
readonly thought: {
|
|
10
|
+
readonly type: "string";
|
|
11
|
+
readonly description: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
readonly required: readonly ["thought"];
|
|
15
|
+
};
|
|
16
|
+
export declare function createThinkTool(): PortableTool<ThinkToolParams>;
|