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,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment variables that can safely appear as prefixes.
|
|
3
|
+
* Ported from cc's SAFE_ENV_VARS.
|
|
4
|
+
*
|
|
5
|
+
* NEVER add:
|
|
6
|
+
* PATH, LD_PRELOAD, LD_LIBRARY_PATH, DYLD_* (execution/library loading)
|
|
7
|
+
* PYTHONPATH, NODE_PATH, CLASSPATH, RUBYLIB (module loading)
|
|
8
|
+
* GOFLAGS, RUSTFLAGS, NODE_OPTIONS (code execution flags)
|
|
9
|
+
* HOME, TMPDIR, SHELL, BASH_ENV (system behavior)
|
|
10
|
+
*/
|
|
11
|
+
export declare const SAFE_ENV_VARS: Set<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Commands that execute their arguments — should not be treated
|
|
14
|
+
* as "first word" for permission prefix matching.
|
|
15
|
+
* Ported from cc's BARE_SHELL_PREFIXES.
|
|
16
|
+
*/
|
|
17
|
+
export declare const BARE_SHELL_PREFIXES: Set<string>;
|
|
18
|
+
/**
|
|
19
|
+
* Strip safe env var prefixes and wrapper commands.
|
|
20
|
+
* Ported from cc's `stripSafeWrappers()`.
|
|
21
|
+
*
|
|
22
|
+
* `NODE_ENV=test timeout 30 grep -r foo .` → `grep -r foo .`
|
|
23
|
+
*/
|
|
24
|
+
export declare function stripSafeWrappers(command: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* Aggressively strip ALL leading env vars (not just safe ones).
|
|
27
|
+
* Used for deny-rule matching where the env prefix doesn't change
|
|
28
|
+
* the dangerousness of the underlying command.
|
|
29
|
+
* Ported from cc's `stripAllLeadingEnvVars()`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function stripAllLeadingEnvVars(command: string, blocklist?: RegExp): string;
|
|
32
|
+
/**
|
|
33
|
+
* Extract `<cmd> <subcommand>` prefix for rule matching.
|
|
34
|
+
* E.g. `git commit -m "foo"` → `git commit`
|
|
35
|
+
* Ported from cc's `getSimpleCommandPrefix()`.
|
|
36
|
+
*/
|
|
37
|
+
export declare function getSimpleCommandPrefix(command: string): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Extract the first command word for prefix-based rule matching.
|
|
40
|
+
* Ported from cc's `getFirstWordPrefix()`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function getFirstWordPrefix(command: string): string | null;
|
|
43
|
+
/**
|
|
44
|
+
* Strip argv-level wrapper commands.
|
|
45
|
+
* Ported from cc's `stripWrappersFromArgv()`.
|
|
46
|
+
*/
|
|
47
|
+
export declare function stripWrappersFromArgv(argv: string[]): string[];
|
|
48
|
+
/**
|
|
49
|
+
* Detect blocking sleep/wait patterns in commands.
|
|
50
|
+
* Ported from cc's `detectBlockedSleepPattern()`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function detectBlockedSleepPattern(command: string): string | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type { ShellType, BuildCommandOpts, BuiltCommand, ShellProvider, } from "./shell-provider.js";
|
|
2
|
+
export { isPowerShellToolEnabled, getDefaultShellType, generateCommandId, } from "./shell-provider.js";
|
|
3
|
+
export { createBashProvider } from "./bash-provider.js";
|
|
4
|
+
export type { BashProviderOptions } from "./bash-provider.js";
|
|
5
|
+
export { createPowerShellProvider, encodePowerShellCommand, } from "./powershell-provider.js";
|
|
6
|
+
export type { CommandClassification } from "./command-classification.js";
|
|
7
|
+
export { SEARCH_COMMANDS, READ_COMMANDS, LIST_COMMANDS, SEMANTIC_NEUTRAL_COMMANDS, SILENT_COMMANDS, classifyCommand, commandHasAnyCd, } from "./command-classification.js";
|
|
8
|
+
export { SAFE_ENV_VARS, BARE_SHELL_PREFIXES, stripSafeWrappers, stripAllLeadingEnvVars, getSimpleCommandPrefix, getFirstWordPrefix, stripWrappersFromArgv, detectBlockedSleepPattern, } from "./exec-permissions.js";
|
|
9
|
+
export { getDestructiveCommandWarning, getPowerShellDestructiveCommandWarning, } from "./destructive-command-warning.js";
|
|
10
|
+
export type { CommandSemanticResult } from "./command-semantics.js";
|
|
11
|
+
export { interpretCommandResult } from "./command-semantics.js";
|
|
12
|
+
export { TaskOutput, generateTaskId, getTaskOutputDir, setTaskOutputDir, getTaskOutputPath, MAX_TASK_OUTPUT_BYTES, } from "./task-output.js";
|
|
13
|
+
export type { ProgressCallback } from "./task-output.js";
|
|
14
|
+
export type { ExecResult, ShellCommand } from "./shell-command.js";
|
|
15
|
+
export { wrapSpawn, createAbortedCommand, createFailedCommand, } from "./shell-command.js";
|
|
16
|
+
export { exec, getCwd, setCwd, initCwd, getOriginalCwd, setShellProvider, getShellProvider, } from "./shell-exec.js";
|
|
17
|
+
export type { ExecOptions } from "./shell-exec.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ShellProvider } from "./shell-provider.js";
|
|
2
|
+
/**
|
|
3
|
+
* Encode a PowerShell command as UTF-16LE Base64 for -EncodedCommand.
|
|
4
|
+
* This avoids all quoting/escaping issues when passing complex commands
|
|
5
|
+
* through cmd.exe or other shell wrappers.
|
|
6
|
+
*
|
|
7
|
+
* Ported directly from cc's `encodePowerShellCommand()`.
|
|
8
|
+
*/
|
|
9
|
+
export declare function encodePowerShellCommand(psCommand: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Create a PowerShell ShellProvider.
|
|
12
|
+
*
|
|
13
|
+
* @param shellPath Absolute path to pwsh.exe or powershell.exe
|
|
14
|
+
*/
|
|
15
|
+
export declare function createPowerShellProvider(shellPath: string): ShellProvider;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ChildProcess } from "node:child_process";
|
|
2
|
+
import { TaskOutput } from "./task-output.js";
|
|
3
|
+
export interface ExecResult {
|
|
4
|
+
stdout: string;
|
|
5
|
+
stderr: string;
|
|
6
|
+
/** Exit code. 137 = SIGKILL, 143 = SIGTERM, 145 = aborted. */
|
|
7
|
+
code: number;
|
|
8
|
+
/** Whether the process was interrupted (killed or timed out). */
|
|
9
|
+
interrupted: boolean;
|
|
10
|
+
/** Set when backgrounded. */
|
|
11
|
+
backgroundTaskId?: string;
|
|
12
|
+
/** Set when the user explicitly backgrounded. */
|
|
13
|
+
backgroundedByUser?: boolean;
|
|
14
|
+
/** Set when assistant mode auto-backgrounded. */
|
|
15
|
+
assistantAutoBackgrounded?: boolean;
|
|
16
|
+
/** Path to raw output file for large outputs. */
|
|
17
|
+
outputFilePath?: string;
|
|
18
|
+
/** Total output file size in bytes. */
|
|
19
|
+
outputFileSize?: number;
|
|
20
|
+
/** Error message when command failed before spawning. */
|
|
21
|
+
preSpawnError?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ShellCommand {
|
|
24
|
+
/** Move the process to background. Returns true if successful. */
|
|
25
|
+
background(taskId: string): boolean;
|
|
26
|
+
/** Promise resolving when the process exits. */
|
|
27
|
+
result: Promise<ExecResult>;
|
|
28
|
+
/** Kill the process immediately. */
|
|
29
|
+
kill(): void;
|
|
30
|
+
/** Current lifecycle status. */
|
|
31
|
+
status: "running" | "backgrounded" | "completed" | "killed";
|
|
32
|
+
/** Clean up stream resources and listeners. */
|
|
33
|
+
cleanup(): void;
|
|
34
|
+
/** Register timeout callback (for auto-backgrounding). */
|
|
35
|
+
onTimeout?: (callback: (backgroundFn: (taskId: string) => boolean) => void) => void;
|
|
36
|
+
/** Output container. */
|
|
37
|
+
taskOutput: TaskOutput;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Wrap a child process with lifecycle management.
|
|
41
|
+
* Ported from cc's wrapSpawn().
|
|
42
|
+
*/
|
|
43
|
+
export declare function wrapSpawn(childProcess: ChildProcess, abortSignal: AbortSignal, timeout: number, taskOutput: TaskOutput, shouldAutoBackground?: boolean, maxOutputBytes?: number): ShellCommand;
|
|
44
|
+
/**
|
|
45
|
+
* Create a ShellCommand for commands that were aborted before execution.
|
|
46
|
+
*/
|
|
47
|
+
export declare function createAbortedCommand(backgroundTaskId?: string, opts?: {
|
|
48
|
+
stderr?: string;
|
|
49
|
+
code?: number;
|
|
50
|
+
}): ShellCommand;
|
|
51
|
+
/**
|
|
52
|
+
* Create a ShellCommand for commands that failed before spawn.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createFailedCommand(preSpawnError: string): ShellCommand;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ShellProvider, ShellType } from "./shell-provider.js";
|
|
2
|
+
import { type ShellCommand } from "./shell-command.js";
|
|
3
|
+
import { type ProgressCallback } from "./task-output.js";
|
|
4
|
+
export type { ExecResult } from "./shell-command.js";
|
|
5
|
+
export declare function getCwd(): string;
|
|
6
|
+
export declare function setCwd(path: string, relativeTo?: string): void;
|
|
7
|
+
export declare function getOriginalCwd(): string;
|
|
8
|
+
export declare function initCwd(cwd: string): void;
|
|
9
|
+
export interface ExecOptions {
|
|
10
|
+
timeout?: number;
|
|
11
|
+
onProgress?: ProgressCallback;
|
|
12
|
+
/** When true, `cd` in the command does NOT update the session CWD. */
|
|
13
|
+
preventCwdChanges?: boolean;
|
|
14
|
+
shouldAutoBackground?: boolean;
|
|
15
|
+
/** When provided, stdout is piped and this callback fires per chunk. */
|
|
16
|
+
onStdout?: (data: string) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Set the shell provider for this session.
|
|
20
|
+
* Must be called once at startup by the host.
|
|
21
|
+
*/
|
|
22
|
+
export declare function setShellProvider(provider: ShellProvider): void;
|
|
23
|
+
/**
|
|
24
|
+
* Get the current shell provider, or throw if not configured.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getShellProvider(): ShellProvider;
|
|
27
|
+
/**
|
|
28
|
+
* Execute a shell command using the configured provider.
|
|
29
|
+
* Creates a new child process for each invocation.
|
|
30
|
+
*
|
|
31
|
+
* Ported from cc's Shell.ts — the tool owns process lifecycle.
|
|
32
|
+
*/
|
|
33
|
+
export declare function exec(command: string, abortSignal: AbortSignal, shellType?: ShellType, options?: ExecOptions): Promise<ShellCommand>;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Discriminated shell type identifier.
|
|
3
|
+
*/
|
|
4
|
+
export type ShellType = "bash" | "powershell";
|
|
5
|
+
/**
|
|
6
|
+
* Options passed to `buildExecCommand`.
|
|
7
|
+
*/
|
|
8
|
+
export interface BuildCommandOpts {
|
|
9
|
+
/** Unique command invocation ID (for CWD temp-file naming). */
|
|
10
|
+
id: string;
|
|
11
|
+
/** If set, sandbox TMPDIR root. */
|
|
12
|
+
sandboxTmpDir?: string;
|
|
13
|
+
/** Whether sandbox mode is active. */
|
|
14
|
+
useSandbox: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Result of `buildExecCommand` — the final command string
|
|
18
|
+
* and the path where the shell will write its post-command CWD.
|
|
19
|
+
*/
|
|
20
|
+
export interface BuiltCommand {
|
|
21
|
+
/** Fully-wrapped command string ready for spawn. */
|
|
22
|
+
commandString: string;
|
|
23
|
+
/**
|
|
24
|
+
* Temp file path where the shell writes its post-command CWD.
|
|
25
|
+
* Used by the host to track `cd` across invocations.
|
|
26
|
+
* undefined if CWD tracking is not supported / not needed.
|
|
27
|
+
*/
|
|
28
|
+
cwdFilePath?: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Runtime-agnostic shell provider.
|
|
32
|
+
*
|
|
33
|
+
* Hosts (Gateway / Desktop / Hub) create a provider once, then
|
|
34
|
+
* use it for every `exec()` call. The tool itself never
|
|
35
|
+
* `spawn()`s — the host does, using args from this provider.
|
|
36
|
+
*/
|
|
37
|
+
export interface ShellProvider {
|
|
38
|
+
/** Shell type discriminator. */
|
|
39
|
+
readonly type: ShellType;
|
|
40
|
+
/** Absolute path to the shell binary. */
|
|
41
|
+
readonly shellPath: string;
|
|
42
|
+
/**
|
|
43
|
+
* Whether `spawn()` should use `detached: true`.
|
|
44
|
+
* Bash: true (allows job control / cleanup).
|
|
45
|
+
* PowerShell: false (no POSIX process groups on Windows).
|
|
46
|
+
*/
|
|
47
|
+
readonly detached: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Wrap a raw user command into a full shell command string.
|
|
50
|
+
* Handles:
|
|
51
|
+
* - Environment snapshots / session env sourcing (bash)
|
|
52
|
+
* - UTF-16LE EncodedCommand wrapping (PowerShell)
|
|
53
|
+
* - CWD tracking (`pwd -P > file` / `Get-Location | Out-File`)
|
|
54
|
+
* - stdin redirect for interactive commands (bash)
|
|
55
|
+
*/
|
|
56
|
+
buildExecCommand(command: string, opts: BuildCommandOpts): Promise<BuiltCommand>;
|
|
57
|
+
/**
|
|
58
|
+
* Return the argv array for `child_process.spawn()`.
|
|
59
|
+
* E.g. bash → `['-c', commandString]`
|
|
60
|
+
* PS → `['-NoProfile', '-NonInteractive', '-Command', cmd]`
|
|
61
|
+
*/
|
|
62
|
+
getSpawnArgs(commandString: string): string[];
|
|
63
|
+
/**
|
|
64
|
+
* Return extra environment variables to merge into spawn env.
|
|
65
|
+
* E.g. `{ SHELL: '/bin/bash', GIT_EDITOR: 'true', CLAUDECODE: '1' }`
|
|
66
|
+
*/
|
|
67
|
+
getEnvironmentOverrides(command: string): Promise<Record<string, string>>;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Check if PowerShell tool mode should be enabled.
|
|
71
|
+
* Mirrors cc's `isPowerShellToolEnabled()`.
|
|
72
|
+
*
|
|
73
|
+
* On Windows: enabled when `QLOGICAGENT_USE_POWERSHELL` is truthy.
|
|
74
|
+
* On non-Windows: always false.
|
|
75
|
+
*/
|
|
76
|
+
export declare function isPowerShellToolEnabled(): boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Default shell type for the current platform.
|
|
79
|
+
*/
|
|
80
|
+
export declare function getDefaultShellType(): ShellType;
|
|
81
|
+
/**
|
|
82
|
+
* Generate a short random hex ID for CWD temp file naming.
|
|
83
|
+
* Matches cc's `Math.floor(Math.random() * 0x10000).toString(16)`.
|
|
84
|
+
*/
|
|
85
|
+
export declare function generateCommandId(): string;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Progress callback — matches cc's signature. */
|
|
2
|
+
export type ProgressCallback = (lastLines: string, allLines: string, totalLines: number, totalBytes: number, isIncomplete: boolean) => void;
|
|
3
|
+
/** Max output file on disk (background tasks). */
|
|
4
|
+
export declare const MAX_TASK_OUTPUT_BYTES: number;
|
|
5
|
+
export declare const MAX_TASK_OUTPUT_BYTES_DISPLAY = "5GB";
|
|
6
|
+
/** Lazily generate session-scoped task output directory. */
|
|
7
|
+
export declare function getTaskOutputDir(): string;
|
|
8
|
+
/** Set the task output directory (for embedding hosts to override). */
|
|
9
|
+
export declare function setTaskOutputDir(dir: string): void;
|
|
10
|
+
export declare function getTaskOutputPath(taskId: string): string;
|
|
11
|
+
export declare function generateTaskId(prefix?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Single source of truth for a shell command's output.
|
|
14
|
+
* Ported from cc's TaskOutput.
|
|
15
|
+
*
|
|
16
|
+
* For bash commands (file mode): both stdout/stderr go to file fd.
|
|
17
|
+
* For hooks (pipe mode): data flows through writeStdout/writeStderr.
|
|
18
|
+
*/
|
|
19
|
+
export declare class TaskOutput {
|
|
20
|
+
#private;
|
|
21
|
+
readonly taskId: string;
|
|
22
|
+
readonly path: string;
|
|
23
|
+
readonly stdoutToFile: boolean;
|
|
24
|
+
constructor(taskId: string, onProgress: ProgressCallback | null, stdoutToFile?: boolean, maxMemory?: number);
|
|
25
|
+
/** Write stdout data (pipe mode). */
|
|
26
|
+
writeStdout(data: string): void;
|
|
27
|
+
/** Write stderr data (pipe mode). */
|
|
28
|
+
writeStderr(data: string): void;
|
|
29
|
+
/** Get captured stdout. For file mode, reads from disk. */
|
|
30
|
+
getStdout(): Promise<string>;
|
|
31
|
+
/** Get captured stderr. In file mode stderr is interleaved with stdout. */
|
|
32
|
+
getStderr(): string;
|
|
33
|
+
get outputFileSize(): number;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the output file content is fully contained in getStdout().
|
|
36
|
+
* If true, the file can be deleted.
|
|
37
|
+
*/
|
|
38
|
+
get outputFileRedundant(): boolean;
|
|
39
|
+
/** Write in-memory buffer to disk file. */
|
|
40
|
+
spillToDisk(): void;
|
|
41
|
+
/** Delete the output file on disk. */
|
|
42
|
+
deleteOutputFile(): Promise<void>;
|
|
43
|
+
/** Clean up all resources. */
|
|
44
|
+
clear(): void;
|
|
45
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
import type { WorkspaceSkill } from "../skill-system/skill-types.js";
|
|
3
|
+
export declare const SKILL_TOOL_NAME: "skill_invoke";
|
|
4
|
+
export interface SkillInvokeParams {
|
|
5
|
+
skill: string;
|
|
6
|
+
args?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const SKILL_INVOKE_SCHEMA: {
|
|
9
|
+
readonly type: "object";
|
|
10
|
+
readonly properties: {
|
|
11
|
+
readonly skill: {
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
readonly description: "Name of the skill to invoke. Use skill_list to see available skills.";
|
|
14
|
+
};
|
|
15
|
+
readonly args: {
|
|
16
|
+
readonly type: "string";
|
|
17
|
+
readonly description: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
readonly required: readonly ["skill"];
|
|
21
|
+
};
|
|
22
|
+
export interface SkillToolDeps {
|
|
23
|
+
/**
|
|
24
|
+
* Get all available skills (Layer 0 metadata).
|
|
25
|
+
* Returns name + description pairs for tool manifest enrichment.
|
|
26
|
+
*/
|
|
27
|
+
listSkills(): WorkspaceSkill[];
|
|
28
|
+
/**
|
|
29
|
+
* Read skill content (Layer 1 instructions).
|
|
30
|
+
* Returns the full SKILL.md content for the named skill.
|
|
31
|
+
* Returns null if skill not found.
|
|
32
|
+
*/
|
|
33
|
+
readSkillContent(name: string): Promise<string | null>;
|
|
34
|
+
/**
|
|
35
|
+
* Execute the skill instructions as a sub-turn.
|
|
36
|
+
* The implementation should:
|
|
37
|
+
* 1. Build system prompt from SKILL.md content
|
|
38
|
+
* 2. Run a sub-turn (fork) with skill instructions
|
|
39
|
+
* 3. Return the sub-turn's final response
|
|
40
|
+
*
|
|
41
|
+
* If not provided, the skill content is returned directly
|
|
42
|
+
* (the LLM can then follow the instructions in context).
|
|
43
|
+
*/
|
|
44
|
+
executeSkillSubturn?(skillName: string, skillContent: string, userArgs: string | undefined, signal?: AbortSignal): Promise<string>;
|
|
45
|
+
}
|
|
46
|
+
export declare function createSkillTool(deps: SkillToolDeps): PortableTool<SkillInvokeParams>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const SKILL_LIST_TOOL_NAME: "skill_list";
|
|
3
|
+
export interface SkillListToolParams {
|
|
4
|
+
category?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare const SKILL_LIST_TOOL_SCHEMA: {
|
|
7
|
+
readonly type: "object";
|
|
8
|
+
readonly properties: {
|
|
9
|
+
readonly category: {
|
|
10
|
+
readonly type: "string";
|
|
11
|
+
readonly description: "Filter skills by category (e.g. 'devops', 'mlops'). Omit to list all.";
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
readonly required: readonly [];
|
|
15
|
+
};
|
|
16
|
+
export interface SkillListItem {
|
|
17
|
+
name: string;
|
|
18
|
+
description: string;
|
|
19
|
+
version?: string;
|
|
20
|
+
category?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface SkillListOutput {
|
|
23
|
+
skills: SkillListItem[];
|
|
24
|
+
categories: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Host-provided skill registry for listing.
|
|
28
|
+
*/
|
|
29
|
+
export interface SkillListToolDeps {
|
|
30
|
+
/** List all available skills, optionally filtered by category. */
|
|
31
|
+
listSkills(category?: string): Promise<SkillListOutput>;
|
|
32
|
+
}
|
|
33
|
+
export declare function createSkillListTool(deps: SkillListToolDeps): PortableTool<SkillListToolParams>;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const SKILL_MANAGE_TOOL_NAME: "skill_manage";
|
|
3
|
+
export type SkillManageAction = "create" | "edit" | "patch" | "delete" | "write_file" | "remove_file";
|
|
4
|
+
export interface SkillManageToolParams {
|
|
5
|
+
action: SkillManageAction;
|
|
6
|
+
name: string;
|
|
7
|
+
content?: string;
|
|
8
|
+
category?: string;
|
|
9
|
+
filePath?: string;
|
|
10
|
+
fileContent?: string;
|
|
11
|
+
oldString?: string;
|
|
12
|
+
newString?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare const SKILL_MANAGE_TOOL_SCHEMA: {
|
|
15
|
+
readonly type: "object";
|
|
16
|
+
readonly properties: {
|
|
17
|
+
readonly action: {
|
|
18
|
+
readonly type: "string";
|
|
19
|
+
readonly enum: readonly ["create", "edit", "patch", "delete", "write_file", "remove_file"];
|
|
20
|
+
readonly description: string;
|
|
21
|
+
};
|
|
22
|
+
readonly name: {
|
|
23
|
+
readonly type: "string";
|
|
24
|
+
readonly description: "Skill name (lowercase, max 64 chars, kebab-case: letters, digits, hyphens).";
|
|
25
|
+
};
|
|
26
|
+
readonly content: {
|
|
27
|
+
readonly type: "string";
|
|
28
|
+
readonly description: string;
|
|
29
|
+
};
|
|
30
|
+
readonly category: {
|
|
31
|
+
readonly type: "string";
|
|
32
|
+
readonly description: "Category/domain (e.g. 'devops', 'mlops'). Used by create to organize skills.";
|
|
33
|
+
};
|
|
34
|
+
readonly filePath: {
|
|
35
|
+
readonly type: "string";
|
|
36
|
+
readonly description: string;
|
|
37
|
+
};
|
|
38
|
+
readonly fileContent: {
|
|
39
|
+
readonly type: "string";
|
|
40
|
+
readonly description: "Content for write_file action. Max 1 MiB.";
|
|
41
|
+
};
|
|
42
|
+
readonly oldString: {
|
|
43
|
+
readonly type: "string";
|
|
44
|
+
readonly description: "Text to find for patch action (must match uniquely in SKILL.md).";
|
|
45
|
+
};
|
|
46
|
+
readonly newString: {
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
readonly description: "Replacement text for patch action (can be empty to delete).";
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
readonly required: readonly ["action", "name"];
|
|
52
|
+
};
|
|
53
|
+
export interface SkillManageResult {
|
|
54
|
+
success: boolean;
|
|
55
|
+
message: string;
|
|
56
|
+
path?: string;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Host-provided skill management backend.
|
|
60
|
+
*/
|
|
61
|
+
export interface SkillManageToolDeps {
|
|
62
|
+
/**
|
|
63
|
+
* Execute a skill management action.
|
|
64
|
+
* The host handles file system operations, validation, and security scanning.
|
|
65
|
+
*/
|
|
66
|
+
manageSkill(params: SkillManageToolParams): Promise<SkillManageResult>;
|
|
67
|
+
/**
|
|
68
|
+
* Validate skill name format.
|
|
69
|
+
* If not provided, tool uses built-in validation.
|
|
70
|
+
*/
|
|
71
|
+
validateName?(name: string): string | null;
|
|
72
|
+
}
|
|
73
|
+
export declare function createSkillManageTool(deps: SkillManageToolDeps): PortableTool<SkillManageToolParams>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const SKILL_VIEW_TOOL_NAME: "skill_view";
|
|
3
|
+
export interface SkillViewToolParams {
|
|
4
|
+
name: string;
|
|
5
|
+
filePath?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const SKILL_VIEW_TOOL_SCHEMA: {
|
|
8
|
+
readonly type: "object";
|
|
9
|
+
readonly properties: {
|
|
10
|
+
readonly name: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly description: "Skill name to view (e.g. 'code-review', 'deploy-ecs').";
|
|
13
|
+
};
|
|
14
|
+
readonly filePath: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly description: string;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
readonly required: readonly ["name"];
|
|
20
|
+
};
|
|
21
|
+
export interface SkillViewOutput {
|
|
22
|
+
name: string;
|
|
23
|
+
content: string;
|
|
24
|
+
referenceFiles?: string[];
|
|
25
|
+
tags?: string[];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Host-provided skill viewer.
|
|
29
|
+
*/
|
|
30
|
+
export interface SkillViewToolDeps {
|
|
31
|
+
/**
|
|
32
|
+
* Read skill content. Returns the main SKILL.md or a specific file.
|
|
33
|
+
* Returns null if skill not found.
|
|
34
|
+
*/
|
|
35
|
+
viewSkill(name: string, filePath?: string): Promise<SkillViewOutput | null>;
|
|
36
|
+
}
|
|
37
|
+
export declare function createSkillViewTool(deps: SkillViewToolDeps): PortableTool<SkillViewToolParams>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const SLEEP_TOOL_NAME: "sleep";
|
|
3
|
+
export interface SleepToolParams {
|
|
4
|
+
/** Duration to sleep in seconds (1–3600). */
|
|
5
|
+
duration: number;
|
|
6
|
+
/** Reason for sleeping — helps the runtime decide whether to interrupt. */
|
|
7
|
+
reason?: string;
|
|
8
|
+
}
|
|
9
|
+
export declare const SLEEP_TOOL_SCHEMA: {
|
|
10
|
+
readonly type: "object";
|
|
11
|
+
readonly properties: {
|
|
12
|
+
readonly duration: {
|
|
13
|
+
readonly type: "number";
|
|
14
|
+
readonly description: "Duration to sleep in seconds (1–3600). Prefer short sleeps (10–60s) to stay responsive.";
|
|
15
|
+
readonly minimum: 1;
|
|
16
|
+
readonly maximum: 3600;
|
|
17
|
+
};
|
|
18
|
+
readonly reason: {
|
|
19
|
+
readonly type: "string";
|
|
20
|
+
readonly description: string;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly required: readonly ["duration"];
|
|
24
|
+
};
|
|
25
|
+
/** The result returned after a sleep completes or is interrupted. */
|
|
26
|
+
export interface SleepResult {
|
|
27
|
+
/** Actual time slept in seconds (may be less if interrupted). */
|
|
28
|
+
sleptSeconds: number;
|
|
29
|
+
/** Whether the sleep was interrupted before completing. */
|
|
30
|
+
interrupted: boolean;
|
|
31
|
+
/** The event that caused the interruption (undefined if not interrupted). */
|
|
32
|
+
interruptReason?: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Runtime dependencies injected by the host.
|
|
36
|
+
*
|
|
37
|
+
* The sleep mechanism is host-provided — the tool itself does NOT call
|
|
38
|
+
* setTimeout. The host decides how to implement the wait (timer, event loop
|
|
39
|
+
* integration, tick prompt scheduling, etc.).
|
|
40
|
+
*/
|
|
41
|
+
export interface SleepToolDeps {
|
|
42
|
+
/**
|
|
43
|
+
* Perform the actual sleep. Must resolve after `durationMs` or when
|
|
44
|
+
* interrupted (whichever is first). The AbortSignal fires if the user
|
|
45
|
+
* or the system requests an interrupt.
|
|
46
|
+
*/
|
|
47
|
+
sleep(durationMs: number, signal: AbortSignal): Promise<SleepResult>;
|
|
48
|
+
}
|
|
49
|
+
export declare function createSleepTool(deps: SleepToolDeps): PortableTool<SleepToolParams>;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import type { PortableTool } from "../portable-tool.js";
|
|
2
|
+
export declare const STRUCTURED_OUTPUT_TOOL_NAME: "structured_output";
|
|
3
|
+
/** Maximum content size for structured output results. */
|
|
4
|
+
export declare const STRUCTURED_OUTPUT_MAX_CHARS = 100000;
|
|
5
|
+
export interface StructuredOutputToolParams {
|
|
6
|
+
/** The structured data to return. Must conform to the session's output schema. */
|
|
7
|
+
data: Record<string, unknown>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Base schema — accepts any object.
|
|
11
|
+
* When used with createConfiguredStructuredOutputTool, the host overrides
|
|
12
|
+
* this with the actual JSON Schema from `response_format.json_schema`.
|
|
13
|
+
*/
|
|
14
|
+
export declare const STRUCTURED_OUTPUT_TOOL_SCHEMA: {
|
|
15
|
+
readonly type: "object";
|
|
16
|
+
readonly properties: {
|
|
17
|
+
readonly data: {
|
|
18
|
+
readonly type: "object";
|
|
19
|
+
readonly description: string;
|
|
20
|
+
readonly additionalProperties: true;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly required: readonly ["data"];
|
|
24
|
+
};
|
|
25
|
+
/** Schema validation error detail. */
|
|
26
|
+
export interface SchemaValidationError {
|
|
27
|
+
path: string;
|
|
28
|
+
message: string;
|
|
29
|
+
keyword?: string;
|
|
30
|
+
}
|
|
31
|
+
/** Result of structured output validation. */
|
|
32
|
+
export interface StructuredOutputResult {
|
|
33
|
+
valid: boolean;
|
|
34
|
+
errors?: SchemaValidationError[];
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Whether the structured output tool should be enabled for this session.
|
|
38
|
+
* CC equivalent: `isSyntheticOutputToolEnabled`.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isStructuredOutputEnabled(opts: {
|
|
41
|
+
isNonInteractiveSession: boolean;
|
|
42
|
+
}): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Runtime dependencies injected by the host.
|
|
45
|
+
*
|
|
46
|
+
* The host provides:
|
|
47
|
+
* 1. The JSON Schema to validate against (from session config)
|
|
48
|
+
* 2. A validator function (host may use Ajv, Zod, or any validator)
|
|
49
|
+
* 3. An output sink to deliver the validated data
|
|
50
|
+
*
|
|
51
|
+
* The tool is only available in non-interactive (SDK/API) sessions
|
|
52
|
+
* where a `response_format.json_schema` has been specified.
|
|
53
|
+
*/
|
|
54
|
+
export interface StructuredOutputToolDeps {
|
|
55
|
+
/**
|
|
56
|
+
* Get the JSON Schema that the output must conform to.
|
|
57
|
+
* Returns undefined if no schema is configured (tool should not be registered).
|
|
58
|
+
*/
|
|
59
|
+
getOutputSchema(): Record<string, unknown> | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Validate data against the output schema.
|
|
62
|
+
* Returns { valid: true } or { valid: false, errors: [...] }.
|
|
63
|
+
*/
|
|
64
|
+
validateOutput(data: Record<string, unknown>): StructuredOutputResult;
|
|
65
|
+
/**
|
|
66
|
+
* Deliver the validated output to the caller.
|
|
67
|
+
* Called only after successful validation.
|
|
68
|
+
*/
|
|
69
|
+
deliverOutput(data: Record<string, unknown>): Promise<void>;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create the base structured output tool with DI-based validation.
|
|
73
|
+
* This is the standard factory for runtime integration.
|
|
74
|
+
*/
|
|
75
|
+
export declare function createStructuredOutputTool(deps: StructuredOutputToolDeps): PortableTool<StructuredOutputToolParams>;
|
|
76
|
+
/**
|
|
77
|
+
* Result of creating a configured structured output tool.
|
|
78
|
+
* Success: { tool } — ready-to-use tool with compiled schema.
|
|
79
|
+
* Failure: { error } — schema was invalid.
|
|
80
|
+
*/
|
|
81
|
+
export type ConfiguredToolResult = {
|
|
82
|
+
tool: PortableTool<StructuredOutputToolParams>;
|
|
83
|
+
} | {
|
|
84
|
+
error: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Host-provided schema compilation interface.
|
|
88
|
+
* Allows the host to use any validator (Ajv, Zod, custom).
|
|
89
|
+
*/
|
|
90
|
+
export interface SchemaCompiler {
|
|
91
|
+
/**
|
|
92
|
+
* Validate that the schema itself is a valid JSON Schema.
|
|
93
|
+
* Returns null if valid, or an error message string if invalid.
|
|
94
|
+
*/
|
|
95
|
+
validateSchema(schema: Record<string, unknown>): string | null;
|
|
96
|
+
/**
|
|
97
|
+
* Compile the schema into a reusable validator function.
|
|
98
|
+
* Returns a function that validates data and returns StructuredOutputResult.
|
|
99
|
+
*/
|
|
100
|
+
compile(schema: Record<string, unknown>): (data: Record<string, unknown>) => StructuredOutputResult;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Create a StructuredOutputTool configured with a specific JSON Schema.
|
|
104
|
+
* Mirrors CC's `createSyntheticOutputTool(jsonSchema)`.
|
|
105
|
+
*
|
|
106
|
+
* Features:
|
|
107
|
+
* - Validates the schema itself at creation time
|
|
108
|
+
* - Compiles the validator for reuse (cached via WeakMap)
|
|
109
|
+
* - Overrides the tool's `parameters` with the provided schema (dynamic input)
|
|
110
|
+
* - Returns { tool } on success or { error } if schema is invalid
|
|
111
|
+
*
|
|
112
|
+
* @param jsonSchema The JSON Schema to validate output against.
|
|
113
|
+
* @param compiler Schema compiler/validator provided by the host.
|
|
114
|
+
* @param deliver Output delivery function (called after successful validation).
|
|
115
|
+
*/
|
|
116
|
+
export declare function createConfiguredStructuredOutputTool(jsonSchema: Record<string, unknown>, compiler: SchemaCompiler, deliver: (data: Record<string, unknown>) => Promise<void>): ConfiguredToolResult;
|