qlogicagent 0.5.2 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/README.md +402 -402
  2. package/dist/agent.js +18 -0
  3. package/dist/cli.js +360 -0
  4. package/dist/contracts.js +1 -0
  5. package/dist/index.js +22 -0
  6. package/dist/orchestration.js +125 -0
  7. package/dist/types/agent/agent.d.ts +43 -0
  8. package/dist/types/agent/constants.d.ts +47 -0
  9. package/dist/types/agent/tool-loop.d.ts +96 -0
  10. package/dist/types/agent/types.d.ts +250 -0
  11. package/dist/types/cli/main.d.ts +11 -0
  12. package/dist/types/cli/stdio-server.d.ts +56 -0
  13. package/dist/types/cli/tool-bootstrap.d.ts +21 -0
  14. package/dist/types/config/config.d.ts +17 -0
  15. package/dist/types/contracts/hooks.d.ts +175 -0
  16. package/dist/types/contracts/index.d.ts +10 -0
  17. package/dist/types/contracts/planner.d.ts +35 -0
  18. package/dist/types/contracts/skill-candidate.d.ts +63 -0
  19. package/dist/types/contracts/todo.d.ts +14 -0
  20. package/dist/types/index.d.ts +13 -0
  21. package/dist/types/llm/builtin-providers.d.ts +10 -0
  22. package/dist/types/llm/debug-transport.d.ts +12 -0
  23. package/dist/types/llm/index.d.ts +16 -0
  24. package/dist/types/llm/llm-client.d.ts +43 -0
  25. package/dist/types/llm/model-catalog.d.ts +53 -0
  26. package/dist/types/llm/provider-def.d.ts +59 -0
  27. package/dist/types/llm/provider-registry.d.ts +54 -0
  28. package/dist/types/llm/transport.d.ts +62 -0
  29. package/dist/types/llm/transports/anthropic-messages.d.ts +31 -0
  30. package/dist/types/llm/transports/openai-chat.d.ts +36 -0
  31. package/dist/types/orchestration/agent-registry.d.ts +46 -0
  32. package/dist/types/orchestration/context-collapse.d.ts +58 -0
  33. package/dist/types/orchestration/context-compression.d.ts +301 -0
  34. package/dist/types/orchestration/conversation-repair.d.ts +61 -0
  35. package/dist/types/orchestration/curator-scheduler.d.ts +119 -0
  36. package/dist/types/orchestration/error-classification.d.ts +12 -0
  37. package/dist/types/orchestration/failover-classification.d.ts +8 -0
  38. package/dist/types/orchestration/failover-error.d.ts +33 -0
  39. package/dist/types/orchestration/fork-subagent.d.ts +100 -0
  40. package/dist/types/orchestration/index.d.ts +113 -0
  41. package/dist/types/orchestration/memory-provider.d.ts +14 -0
  42. package/dist/types/orchestration/reactive-compact.d.ts +73 -0
  43. package/dist/types/orchestration/retry-loop.d.ts +69 -0
  44. package/dist/types/orchestration/skill-candidate.d.ts +52 -0
  45. package/dist/types/orchestration/skill-consolidation.d.ts +123 -0
  46. package/dist/types/orchestration/skill-improvement.d.ts +59 -0
  47. package/dist/types/orchestration/skill-similarity.d.ts +98 -0
  48. package/dist/types/orchestration/task-types.d.ts +142 -0
  49. package/dist/types/orchestration/team-orchestration.d.ts +195 -0
  50. package/dist/types/orchestration/team-tool-loop-wiring.d.ts +92 -0
  51. package/dist/types/orchestration/tool-choice-policy.d.ts +54 -0
  52. package/dist/types/orchestration/tool-loop-state.d.ts +50 -0
  53. package/dist/types/orchestration/tool-schema.d.ts +39 -0
  54. package/dist/types/orchestration/turn-loop-guard.d.ts +86 -0
  55. package/dist/types/runtime/execution/dream-agent.d.ts +199 -0
  56. package/dist/types/runtime/execution/forked-agent.d.ts +111 -0
  57. package/dist/types/runtime/execution/index.d.ts +6 -0
  58. package/dist/types/runtime/execution/progress-tracker.d.ts +78 -0
  59. package/dist/types/runtime/execution/remote-agent.d.ts +63 -0
  60. package/dist/types/runtime/execution/streaming-tool-executor.d.ts +100 -0
  61. package/dist/types/runtime/execution/tool-eligibility.d.ts +59 -0
  62. package/dist/types/runtime/execution/tool-result-storage.d.ts +87 -0
  63. package/dist/types/runtime/hooks/context-compression.d.ts +61 -0
  64. package/dist/types/runtime/hooks/hook-registry.d.ts +12 -0
  65. package/dist/types/runtime/hooks/index.d.ts +3 -0
  66. package/dist/types/runtime/hooks/memory-hooks.d.ts +49 -0
  67. package/dist/types/runtime/index.d.ts +5 -0
  68. package/dist/types/runtime/infra/cleanup-registry.d.ts +23 -0
  69. package/dist/types/runtime/infra/file-watcher.d.ts +72 -0
  70. package/dist/types/runtime/infra/index.d.ts +6 -0
  71. package/dist/types/runtime/infra/secure-storage.d.ts +81 -0
  72. package/dist/types/runtime/infra/task-runtime.d.ts +108 -0
  73. package/dist/types/runtime/infra/token-budget.d.ts +92 -0
  74. package/dist/types/runtime/infra/worktree-backend.d.ts +85 -0
  75. package/dist/types/runtime/prompt/environment-context.d.ts +23 -0
  76. package/dist/types/runtime/prompt/index.d.ts +3 -0
  77. package/dist/types/runtime/prompt/instruction-loader.d.ts +64 -0
  78. package/dist/types/runtime/prompt/system-prompt-sections.d.ts +63 -0
  79. package/dist/types/runtime/session/index.d.ts +2 -0
  80. package/dist/types/runtime/session/session-memory.d.ts +91 -0
  81. package/dist/types/runtime/session/session-persistence.d.ts +94 -0
  82. package/dist/types/runtime/session/session-state.d.ts +117 -0
  83. package/dist/types/skills/index.d.ts +125 -0
  84. package/dist/types/skills/mcp/index.d.ts +3 -0
  85. package/dist/types/skills/mcp/mcp-http-client.d.ts +66 -0
  86. package/dist/types/skills/mcp/mcp-manager.d.ts +84 -0
  87. package/dist/types/skills/mcp/mcp-stdio-client.d.ts +84 -0
  88. package/dist/types/skills/memory-extractor.d.ts +64 -0
  89. package/dist/types/skills/memory-query-tool.d.ts +43 -0
  90. package/dist/types/skills/memory-store.d.ts +66 -0
  91. package/dist/types/skills/memory-tool.d.ts +67 -0
  92. package/dist/types/skills/permissions/bash-classifier.d.ts +30 -0
  93. package/dist/types/skills/permissions/classifier-cache.d.ts +51 -0
  94. package/dist/types/skills/permissions/denial-tracking.d.ts +42 -0
  95. package/dist/types/skills/permissions/hook-runner.d.ts +85 -0
  96. package/dist/types/skills/permissions/index.d.ts +12 -0
  97. package/dist/types/skills/permissions/permission-classifier.d.ts +41 -0
  98. package/dist/types/skills/permissions/rule-engine.d.ts +41 -0
  99. package/dist/types/skills/permissions/settings-watcher.d.ts +46 -0
  100. package/dist/types/skills/permissions/types.d.ts +113 -0
  101. package/dist/types/skills/plugins/index.d.ts +2 -0
  102. package/dist/types/skills/plugins/plugin-api.d.ts +38 -0
  103. package/dist/types/skills/plugins/plugin-loader.d.ts +45 -0
  104. package/dist/types/skills/plugins/plugin-marketplace.d.ts +61 -0
  105. package/dist/types/skills/portable-tool.d.ts +71 -0
  106. package/dist/types/skills/qmemory-adapter.d.ts +42 -0
  107. package/dist/types/skills/skill-frontmatter.d.ts +19 -0
  108. package/dist/types/skills/skill-guard.d.ts +23 -0
  109. package/dist/types/skills/skill-loader.d.ts +16 -0
  110. package/dist/types/skills/skill-source.d.ts +119 -0
  111. package/dist/types/skills/skill-types.d.ts +199 -0
  112. package/dist/types/skills/think-tool.d.ts +16 -0
  113. package/dist/types/skills/todo-tool.d.ts +63 -0
  114. package/dist/types/skills/tool-registry.d.ts +29 -0
  115. package/dist/types/skills/tools/agent-tool.d.ts +91 -0
  116. package/dist/types/skills/tools/apply-patch-tool.d.ts +29 -0
  117. package/dist/types/skills/tools/ask-user-tool.d.ts +80 -0
  118. package/dist/types/skills/tools/brief-tool.d.ts +74 -0
  119. package/dist/types/skills/tools/browser-tool.d.ts +114 -0
  120. package/dist/types/skills/tools/checkpoint-tool.d.ts +66 -0
  121. package/dist/types/skills/tools/config-tool.d.ts +63 -0
  122. package/dist/types/skills/tools/cron-tool.d.ts +116 -0
  123. package/dist/types/skills/tools/edit-tool.d.ts +43 -0
  124. package/dist/types/skills/tools/exec-tool.d.ts +97 -0
  125. package/dist/types/skills/tools/image-generate-tool.d.ts +62 -0
  126. package/dist/types/skills/tools/instructions-tool.d.ts +103 -0
  127. package/dist/types/skills/tools/lsp-tool.d.ts +153 -0
  128. package/dist/types/skills/tools/mcp-client-types.d.ts +269 -0
  129. package/dist/types/skills/tools/mcp-resource-tools.d.ts +14 -0
  130. package/dist/types/skills/tools/mcp-tool.d.ts +249 -0
  131. package/dist/types/skills/tools/memory-tool.d.ts +74 -0
  132. package/dist/types/skills/tools/monitor-tool.d.ts +113 -0
  133. package/dist/types/skills/tools/music-generate-tool.d.ts +55 -0
  134. package/dist/types/skills/tools/notebook-edit-tool.d.ts +15 -0
  135. package/dist/types/skills/tools/notify-tool.d.ts +53 -0
  136. package/dist/types/skills/tools/patch-tool.d.ts +45 -0
  137. package/dist/types/skills/tools/pdf-tool.d.ts +66 -0
  138. package/dist/types/skills/tools/plan-mode-tool.d.ts +98 -0
  139. package/dist/types/skills/tools/read-tool.d.ts +51 -0
  140. package/dist/types/skills/tools/repl-tool.d.ts +70 -0
  141. package/dist/types/skills/tools/search-tool.d.ts +112 -0
  142. package/dist/types/skills/tools/send-message-tool.d.ts +51 -0
  143. package/dist/types/skills/tools/shell/bash-provider.d.ts +26 -0
  144. package/dist/types/skills/tools/shell/command-classification.d.ts +44 -0
  145. package/dist/types/skills/tools/shell/command-semantics.d.ts +14 -0
  146. package/dist/types/skills/tools/shell/destructive-command-warning.d.ts +10 -0
  147. package/dist/types/skills/tools/shell/exec-permissions.d.ts +52 -0
  148. package/dist/types/skills/tools/shell/index.d.ts +17 -0
  149. package/dist/types/skills/tools/shell/powershell-provider.d.ts +15 -0
  150. package/dist/types/skills/tools/shell/shell-command.d.ts +54 -0
  151. package/dist/types/skills/tools/shell/shell-exec.d.ts +33 -0
  152. package/dist/types/skills/tools/shell/shell-provider.d.ts +85 -0
  153. package/dist/types/skills/tools/shell/task-output.d.ts +45 -0
  154. package/dist/types/skills/tools/skill-invoke-tool.d.ts +46 -0
  155. package/dist/types/skills/tools/skill-list-tool.d.ts +33 -0
  156. package/dist/types/skills/tools/skill-manage-tool.d.ts +73 -0
  157. package/dist/types/skills/tools/skill-view-tool.d.ts +37 -0
  158. package/dist/types/skills/tools/sleep-tool.d.ts +49 -0
  159. package/dist/types/skills/tools/structured-output-tool.d.ts +116 -0
  160. package/dist/types/skills/tools/task-tool.d.ts +104 -0
  161. package/dist/types/skills/tools/team-tool.d.ts +89 -0
  162. package/dist/types/skills/tools/tool-search-tool.d.ts +51 -0
  163. package/dist/types/skills/tools/tts-tool.d.ts +38 -0
  164. package/dist/types/skills/tools/video-edit-tool.d.ts +69 -0
  165. package/dist/types/skills/tools/video-generate-tool.d.ts +62 -0
  166. package/dist/types/skills/tools/video-merge-tool.d.ts +105 -0
  167. package/dist/types/skills/tools/video-upscale-tool.d.ts +45 -0
  168. package/dist/types/skills/tools/web-fetch-tool.d.ts +78 -0
  169. package/dist/types/skills/tools/web-search-tool.d.ts +57 -0
  170. package/dist/types/skills/tools/workflow-tool.d.ts +44 -0
  171. package/dist/types/skills/tools/worktree-tool.d.ts +69 -0
  172. package/dist/types/skills/tools/write-tool.d.ts +45 -0
  173. package/package.json +3 -2
@@ -0,0 +1,42 @@
1
+ import type { MemoryIngestOptions, MemoryProvider } from "qlogicagent-runtime-contracts";
2
+ /** A pre-extracted memory item ready to be stored (no LLM needed). */
3
+ export interface ExtractedMemoryItem {
4
+ text: string;
5
+ category?: string;
6
+ importance?: number;
7
+ speaker?: string;
8
+ event_date?: string;
9
+ tags?: string[];
10
+ }
11
+ /** Configuration for the QMemory HTTP adapter. */
12
+ export interface QMemoryAdapterConfig {
13
+ /** Base URL of the qmemory server (e.g. "http://localhost:18800"). */
14
+ baseUrl: string;
15
+ /** Optional API key for authentication. */
16
+ apiKey?: string;
17
+ /** Request timeout in milliseconds (default: 5000). */
18
+ timeoutMs?: number;
19
+ /** Prefix prepended to userId for multi-tenant isolation. */
20
+ userIdPrefix?: string;
21
+ }
22
+ /** Health status returned by qmemory `/v1/health/`. */
23
+ export interface QMemoryHealthStatus {
24
+ status: string;
25
+ version: string;
26
+ memoryCount: number;
27
+ dbSizeBytes: number;
28
+ embeddingModel: string;
29
+ uptimeSeconds: number;
30
+ }
31
+ /**
32
+ * Create a MemoryProvider backed by a QMemory HTTP server.
33
+ *
34
+ * Uses `qlogicagent-adapter-claw` for HTTP transport.
35
+ */
36
+ export declare function createQMemoryAdapter(config: QMemoryAdapterConfig): MemoryProvider & {
37
+ health(): Promise<QMemoryHealthStatus>;
38
+ ingestExtracted(items: ExtractedMemoryItem[], userId: string, options?: MemoryIngestOptions): Promise<{
39
+ memoriesAdded: number;
40
+ }>;
41
+ feedback(memoryIds: string[], signal: string, sessionId?: string): Promise<void>;
42
+ };
@@ -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>;
@@ -0,0 +1,63 @@
1
+ import type { TodoItem } from "../contracts/todo.js";
2
+ import type { PortableTool } from "./portable-tool.js";
3
+ export declare const TODO_TOOL_NAME: "todo";
4
+ export interface TodoToolParams {
5
+ todoList: TodoItem[];
6
+ }
7
+ export declare const TODO_TOOL_SCHEMA: {
8
+ readonly type: "object";
9
+ readonly properties: {
10
+ readonly todoList: {
11
+ readonly type: "array";
12
+ readonly description: string;
13
+ readonly items: {
14
+ readonly type: "object";
15
+ readonly properties: {
16
+ readonly id: {
17
+ readonly type: "number";
18
+ readonly description: "Unique numeric id (sequential from 1).";
19
+ };
20
+ readonly title: {
21
+ readonly type: "string";
22
+ readonly description: "Concise action-oriented label (3-7 words). Displayed in UI.";
23
+ };
24
+ readonly status: {
25
+ readonly type: "string";
26
+ readonly enum: readonly ["not-started", "in-progress", "completed"];
27
+ readonly description: "not-started | in-progress (max 1) | completed";
28
+ };
29
+ };
30
+ readonly required: readonly ["id", "title", "status"];
31
+ };
32
+ };
33
+ };
34
+ readonly required: readonly ["todoList"];
35
+ };
36
+ /**
37
+ * Configuration for todo tool behavior (CC-aligned features).
38
+ */
39
+ export interface TodoToolOptions {
40
+ /**
41
+ * Unique agent/session identifier for per-agent todo isolation.
42
+ * When provided, different agents have independent todo lists.
43
+ */
44
+ agentId?: string;
45
+ /**
46
+ * Whether verification nudge is enabled.
47
+ * When all items are completed (≥3 items, none matching /verif/i),
48
+ * the tool signals that a verification sub-agent should be spawned.
49
+ */
50
+ enableVerificationNudge?: boolean;
51
+ /**
52
+ * Whether to auto-clear the list when all items are completed.
53
+ * Matches CC behavior: allDone → newTodos = [].
54
+ */
55
+ autoClearOnComplete?: boolean;
56
+ }
57
+ /**
58
+ * Create a stateful todo tool instance.
59
+ *
60
+ * Each call returns a tool with its own session-local list.
61
+ * Multiple instances can exist for different sessions/agents.
62
+ */
63
+ export declare function createTodoTool(options?: TodoToolOptions): PortableTool<TodoToolParams>;
@@ -0,0 +1,29 @@
1
+ import type { PortableTool, PortableToolResult } from "./portable-tool.js";
2
+ import type { ToolDefinition } from "../agent/types.js";
3
+ export declare class ToolRegistry {
4
+ private tools;
5
+ /** Register a single tool. Overwrites if name already exists. */
6
+ register(tool: PortableTool<any>): void;
7
+ /** Register multiple tools at once. */
8
+ registerAll(tools: PortableTool<any>[]): void;
9
+ /** Unregister a tool by name. */
10
+ unregister(name: string): boolean;
11
+ /** Find a tool by name. Returns undefined if not registered. */
12
+ findTool(name: string): PortableTool | undefined;
13
+ /** Check if a tool is registered locally. */
14
+ has(name: string): boolean;
15
+ /**
16
+ * Execute a tool by name.
17
+ * @throws Error if the tool is not registered.
18
+ */
19
+ execute(name: string, toolCallId: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<PortableToolResult>;
20
+ /**
21
+ * Generate ToolDefinition[] manifest for LLM tool_use.
22
+ * Excludes deferred tools by default.
23
+ */
24
+ getToolManifest(includeDeferred?: boolean): ToolDefinition[];
25
+ /** Get all registered tool names. */
26
+ getToolNames(): string[];
27
+ /** Number of registered tools. */
28
+ get size(): number;
29
+ }
@@ -0,0 +1,91 @@
1
+ import type { PortableTool } from "../portable-tool.js";
2
+ export declare const AGENT_TOOL_NAME: "agent";
3
+ /**
4
+ * Built-in agent types (CC-aligned registry).
5
+ * The LLM selects which agent to fork based on the task.
6
+ */
7
+ export type BuiltInAgentType = "general" | "explore" | "plan" | "code" | "research" | "verify";
8
+ export declare const BUILT_IN_AGENT_TYPES: BuiltInAgentType[];
9
+ export interface AgentToolParams {
10
+ /** Built-in agent type to invoke. */
11
+ agent: BuiltInAgentType;
12
+ /** Detailed task prompt for the sub-agent. */
13
+ prompt: string;
14
+ /** Short description of the task (3-7 words). Used for status display. */
15
+ description?: string;
16
+ /** Max turns override (default varies by agent type). */
17
+ maxTurns?: number;
18
+ /** Run in background (returns task_id immediately). */
19
+ background?: boolean;
20
+ }
21
+ export declare const AGENT_TOOL_SCHEMA: {
22
+ readonly type: "object";
23
+ readonly properties: {
24
+ readonly agent: {
25
+ readonly type: "string";
26
+ readonly enum: readonly ["general", "explore", "plan", "code", "research", "verify"];
27
+ readonly description: string;
28
+ };
29
+ readonly prompt: {
30
+ readonly type: "string";
31
+ readonly description: string;
32
+ };
33
+ readonly description: {
34
+ readonly type: "string";
35
+ readonly description: "Short description (3-7 words) for status tracking.";
36
+ };
37
+ readonly maxTurns: {
38
+ readonly type: "number";
39
+ readonly description: "Max turns for the sub-agent. Defaults: general=200, explore=50, plan=80, code=200, research=30, verify=40.";
40
+ };
41
+ readonly background: {
42
+ readonly type: "boolean";
43
+ readonly description: "If true, runs in background and returns a task_id. Poll with task tool. Default: false.";
44
+ };
45
+ };
46
+ readonly required: readonly ["agent", "prompt"];
47
+ readonly additionalProperties: false;
48
+ };
49
+ export interface AgentResult {
50
+ agentId: string;
51
+ status: "completed" | "running" | "failed";
52
+ output?: string;
53
+ error?: string;
54
+ maxTurnsReached?: boolean;
55
+ tokensUsed?: number;
56
+ }
57
+ /**
58
+ * Host-provided fork execution backend (CC-aligned).
59
+ *
60
+ * Key properties of the fork mechanism:
61
+ * 1. Child shares parent's message prefix (prompt cache hit)
62
+ * 2. Child uses byte-identical prefix via placeholder results
63
+ * 3. Child has independent tool context (isolation)
64
+ * 4. Results flow back via in-memory streaming (not DB)
65
+ * 5. Fork depth tracked in-memory (max 4 layers)
66
+ */
67
+ export interface AgentToolDeps {
68
+ /**
69
+ * Fork and run a sub-agent.
70
+ * The implementation must:
71
+ * - Share parent's rendered system prompt (byte-identical for cache)
72
+ * - Inherit parent's tool pool (filtered by agent definition)
73
+ * - Track fork depth (reject if > MAX_FORK_DEPTH)
74
+ * - Return output via in-memory streaming backflow
75
+ */
76
+ forkAgent(params: {
77
+ agent: BuiltInAgentType;
78
+ prompt: string;
79
+ description?: string;
80
+ maxTurns?: number;
81
+ background?: boolean;
82
+ abortSignal?: AbortSignal;
83
+ }): Promise<AgentResult>;
84
+ /** Abort signal from the parent turn. */
85
+ abortSignal?: AbortSignal;
86
+ /** Current fork depth (0 = root). Used for depth guard. */
87
+ currentForkDepth?: number;
88
+ }
89
+ /** Maximum fork depth for in-memory agents. */
90
+ export declare const MAX_FORK_DEPTH = 4;
91
+ export declare function createAgentTool(deps: AgentToolDeps): PortableTool<AgentToolParams>;
@@ -0,0 +1,29 @@
1
+ import type { PortableTool } from "../portable-tool.js";
2
+ export declare const APPLY_PATCH_TOOL_NAME: "apply_patch";
3
+ export interface ApplyPatchToolParams {
4
+ input: string;
5
+ }
6
+ export declare const APPLY_PATCH_TOOL_SCHEMA: {
7
+ readonly type: "object";
8
+ readonly properties: {
9
+ readonly input: {
10
+ readonly type: "string";
11
+ readonly description: "Patch content using the *** Begin Patch / *** End Patch format.";
12
+ };
13
+ };
14
+ readonly required: readonly ["input"];
15
+ };
16
+ export interface ApplyPatchSummary {
17
+ added: string[];
18
+ modified: string[];
19
+ deleted: string[];
20
+ }
21
+ /** Deps injected by the host runtime for file patching. */
22
+ export interface ApplyPatchToolDeps {
23
+ readFile(path: string): Promise<string>;
24
+ writeFile(path: string, content: string): Promise<void>;
25
+ deleteFile(path: string): Promise<void>;
26
+ fileExists(path: string): Promise<boolean>;
27
+ resolvePath(input: string): string;
28
+ }
29
+ export declare function createApplyPatchTool(deps: ApplyPatchToolDeps): PortableTool<ApplyPatchToolParams>;