qlogicagent 0.3.0 → 0.5.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.
Files changed (119) hide show
  1. package/README.md +402 -45
  2. package/package.json +2 -2
  3. package/dist/agent.js +0 -1
  4. package/dist/cli.js +0 -9
  5. package/dist/contracts.js +0 -1
  6. package/dist/index.js +0 -5
  7. package/dist/orchestration.js +0 -118
  8. package/dist/types/agent/agent.d.ts +0 -43
  9. package/dist/types/agent/tool-loop.d.ts +0 -64
  10. package/dist/types/agent/types.d.ts +0 -175
  11. package/dist/types/cli/main.d.ts +0 -11
  12. package/dist/types/cli/stdio-server.d.ts +0 -45
  13. package/dist/types/config/config.d.ts +0 -17
  14. package/dist/types/contracts/hooks.d.ts +0 -120
  15. package/dist/types/contracts/index.d.ts +0 -10
  16. package/dist/types/contracts/planner.d.ts +0 -35
  17. package/dist/types/contracts/skill-candidate.d.ts +0 -63
  18. package/dist/types/contracts/todo.d.ts +0 -14
  19. package/dist/types/index.d.ts +0 -13
  20. package/dist/types/llm/builtin-providers.d.ts +0 -10
  21. package/dist/types/llm/index.d.ts +0 -15
  22. package/dist/types/llm/llm-client.d.ts +0 -43
  23. package/dist/types/llm/model-catalog.d.ts +0 -53
  24. package/dist/types/llm/provider-def.d.ts +0 -59
  25. package/dist/types/llm/provider-registry.d.ts +0 -54
  26. package/dist/types/llm/transport.d.ts +0 -62
  27. package/dist/types/llm/transports/anthropic-messages.d.ts +0 -31
  28. package/dist/types/llm/transports/openai-chat.d.ts +0 -36
  29. package/dist/types/orchestration/agent-registry.d.ts +0 -41
  30. package/dist/types/orchestration/approval-aware-tool-plan.d.ts +0 -32
  31. package/dist/types/orchestration/context-compression.d.ts +0 -220
  32. package/dist/types/orchestration/conversation-repair.d.ts +0 -61
  33. package/dist/types/orchestration/curator-scheduler.d.ts +0 -119
  34. package/dist/types/orchestration/embedded-failover-policy.d.ts +0 -110
  35. package/dist/types/orchestration/error-classification.d.ts +0 -12
  36. package/dist/types/orchestration/failover-classification.d.ts +0 -8
  37. package/dist/types/orchestration/failover-error.d.ts +0 -33
  38. package/dist/types/orchestration/fork-subagent.d.ts +0 -100
  39. package/dist/types/orchestration/index.d.ts +0 -120
  40. package/dist/types/orchestration/memory-flush-policy.d.ts +0 -57
  41. package/dist/types/orchestration/memory-provider.d.ts +0 -14
  42. package/dist/types/orchestration/parallel-tool-calls.d.ts +0 -41
  43. package/dist/types/orchestration/prompt-cache-strategy.d.ts +0 -126
  44. package/dist/types/orchestration/reactive-compact.d.ts +0 -73
  45. package/dist/types/orchestration/retry-loop.d.ts +0 -22
  46. package/dist/types/orchestration/skill-candidate.d.ts +0 -52
  47. package/dist/types/orchestration/skill-consolidation.d.ts +0 -123
  48. package/dist/types/orchestration/skill-improvement.d.ts +0 -59
  49. package/dist/types/orchestration/skill-similarity.d.ts +0 -98
  50. package/dist/types/orchestration/streaming-tool-executor.d.ts +0 -73
  51. package/dist/types/orchestration/team-orchestration.d.ts +0 -195
  52. package/dist/types/orchestration/team-tool-loop-wiring.d.ts +0 -92
  53. package/dist/types/orchestration/tool-choice-policy.d.ts +0 -54
  54. package/dist/types/orchestration/tool-loop-state.d.ts +0 -50
  55. package/dist/types/orchestration/tool-schema.d.ts +0 -39
  56. package/dist/types/orchestration/transcript-repair.d.ts +0 -42
  57. package/dist/types/orchestration/turn-loop-guard.d.ts +0 -86
  58. package/dist/types/orchestration/web-browser-policy.d.ts +0 -17
  59. package/dist/types/runtime/context-compression.d.ts +0 -61
  60. package/dist/types/runtime/hook-registry.d.ts +0 -12
  61. package/dist/types/runtime/memory-hooks.d.ts +0 -23
  62. package/dist/types/runtime/tool-eligibility.d.ts +0 -59
  63. package/dist/types/skills/index.d.ts +0 -108
  64. package/dist/types/skills/memory-extractor.d.ts +0 -64
  65. package/dist/types/skills/memory-query-tool.d.ts +0 -43
  66. package/dist/types/skills/memory-store.d.ts +0 -66
  67. package/dist/types/skills/memory-tool.d.ts +0 -67
  68. package/dist/types/skills/portable-tool.d.ts +0 -71
  69. package/dist/types/skills/qmemory-adapter.d.ts +0 -52
  70. package/dist/types/skills/skill-frontmatter.d.ts +0 -19
  71. package/dist/types/skills/skill-guard.d.ts +0 -23
  72. package/dist/types/skills/skill-loader.d.ts +0 -16
  73. package/dist/types/skills/skill-source.d.ts +0 -119
  74. package/dist/types/skills/skill-types.d.ts +0 -199
  75. package/dist/types/skills/think-tool.d.ts +0 -16
  76. package/dist/types/skills/todo-tool.d.ts +0 -63
  77. package/dist/types/skills/tools/agent-tool.d.ts +0 -91
  78. package/dist/types/skills/tools/apply-patch-tool.d.ts +0 -29
  79. package/dist/types/skills/tools/ask-user-tool.d.ts +0 -80
  80. package/dist/types/skills/tools/brief-tool.d.ts +0 -74
  81. package/dist/types/skills/tools/browser-tool.d.ts +0 -114
  82. package/dist/types/skills/tools/checkpoint-tool.d.ts +0 -66
  83. package/dist/types/skills/tools/config-tool.d.ts +0 -63
  84. package/dist/types/skills/tools/cron-tool.d.ts +0 -116
  85. package/dist/types/skills/tools/edit-tool.d.ts +0 -43
  86. package/dist/types/skills/tools/exec-tool.d.ts +0 -102
  87. package/dist/types/skills/tools/image-generate-tool.d.ts +0 -62
  88. package/dist/types/skills/tools/instructions-tool.d.ts +0 -103
  89. package/dist/types/skills/tools/lsp-tool.d.ts +0 -153
  90. package/dist/types/skills/tools/mcp-client-types.d.ts +0 -269
  91. package/dist/types/skills/tools/mcp-tool.d.ts +0 -249
  92. package/dist/types/skills/tools/memory-tool.d.ts +0 -74
  93. package/dist/types/skills/tools/monitor-tool.d.ts +0 -113
  94. package/dist/types/skills/tools/music-generate-tool.d.ts +0 -55
  95. package/dist/types/skills/tools/notify-tool.d.ts +0 -53
  96. package/dist/types/skills/tools/patch-tool.d.ts +0 -45
  97. package/dist/types/skills/tools/pdf-tool.d.ts +0 -66
  98. package/dist/types/skills/tools/plan-mode-tool.d.ts +0 -59
  99. package/dist/types/skills/tools/read-tool.d.ts +0 -51
  100. package/dist/types/skills/tools/repl-tool.d.ts +0 -70
  101. package/dist/types/skills/tools/search-tool.d.ts +0 -112
  102. package/dist/types/skills/tools/send-message-tool.d.ts +0 -51
  103. package/dist/types/skills/tools/skill-list-tool.d.ts +0 -33
  104. package/dist/types/skills/tools/skill-manage-tool.d.ts +0 -73
  105. package/dist/types/skills/tools/skill-view-tool.d.ts +0 -37
  106. package/dist/types/skills/tools/sleep-tool.d.ts +0 -49
  107. package/dist/types/skills/tools/structured-output-tool.d.ts +0 -116
  108. package/dist/types/skills/tools/task-tool.d.ts +0 -104
  109. package/dist/types/skills/tools/team-tool.d.ts +0 -89
  110. package/dist/types/skills/tools/tool-search-tool.d.ts +0 -51
  111. package/dist/types/skills/tools/tts-tool.d.ts +0 -38
  112. package/dist/types/skills/tools/video-edit-tool.d.ts +0 -69
  113. package/dist/types/skills/tools/video-generate-tool.d.ts +0 -62
  114. package/dist/types/skills/tools/video-merge-tool.d.ts +0 -105
  115. package/dist/types/skills/tools/video-upscale-tool.d.ts +0 -45
  116. package/dist/types/skills/tools/web-fetch-tool.d.ts +0 -78
  117. package/dist/types/skills/tools/web-search-tool.d.ts +0 -57
  118. package/dist/types/skills/tools/worktree-tool.d.ts +0 -69
  119. package/dist/types/skills/tools/write-tool.d.ts +0 -45
@@ -1,43 +0,0 @@
1
- import type { PortableTool } from "./portable-tool.js";
2
- export declare const MEMORY_QUERY_TOOL_NAME: "memory_query";
3
- export declare const MEMORY_QUERY_TOOL_SCHEMA: {
4
- readonly type: "object";
5
- readonly properties: {
6
- readonly query: {
7
- readonly type: "string";
8
- readonly description: string;
9
- };
10
- readonly category: {
11
- readonly type: "string";
12
- readonly description: string;
13
- };
14
- };
15
- readonly required: readonly ["query"];
16
- };
17
- export interface MediaPreferencesSummary {
18
- imageStyle?: string;
19
- videoStyle?: string;
20
- musicGenre?: string;
21
- musicMood?: string;
22
- primaryPurpose?: string;
23
- colorPreference?: string;
24
- }
25
- /**
26
- * Dependency-injected callbacks for memory query.
27
- * Consumers provide these from their own memory system.
28
- */
29
- export interface MemoryQueryToolDeps {
30
- /** Query recalled facts/memories by natural language. */
31
- queryGraph?: (query: string, userId: string) => string[];
32
- /** Retrieve user profile summary. */
33
- getProfileSummary?: (userId: string) => string | null;
34
- /** Retrieve media preferences. */
35
- getMediaPreferences?: (userId: string) => MediaPreferencesSummary | null;
36
- /** User ID for this session. */
37
- userId?: string;
38
- }
39
- export interface MemoryQueryToolParams {
40
- query: string;
41
- category?: string;
42
- }
43
- export declare function createMemoryQueryTool(deps?: MemoryQueryToolDeps): PortableTool<MemoryQueryToolParams>;
@@ -1,66 +0,0 @@
1
- export declare const MEMORY_ENTRY_DELIMITER = "\n\u00A7\n";
2
- export declare const DEFAULT_MEMORY_CHAR_LIMIT = 2200;
3
- export declare const DEFAULT_USER_CHAR_LIMIT = 1375;
4
- export type MemoryStoreTarget = "memory" | "user";
5
- export interface MemoryStoreResult {
6
- ok: boolean;
7
- message: string;
8
- target: MemoryStoreTarget;
9
- entries: readonly string[];
10
- entryCount: number;
11
- usage: string;
12
- errorCode?: string;
13
- }
14
- export interface MemoryStoreOptions {
15
- memoryCharLimit?: number;
16
- userCharLimit?: number;
17
- }
18
- export interface MemoryStoreSerialized {
19
- memory: string;
20
- user: string;
21
- }
22
- export declare class MemoryStore {
23
- private memoryEntries;
24
- private userEntries;
25
- private frozenSnapshot;
26
- private snapshotFrozen;
27
- private readonly memoryCharLimit;
28
- private readonly userCharLimit;
29
- constructor(options?: MemoryStoreOptions);
30
- /**
31
- * Load from serialized form (e.g. from PG or filesystem).
32
- * Deduplicates entries on load.
33
- */
34
- loadFromSerialized(data: Partial<MemoryStoreSerialized>): void;
35
- /**
36
- * Serialize current live state for persistence.
37
- */
38
- serialize(): MemoryStoreSerialized;
39
- /**
40
- * Freeze current entries for system prompt injection.
41
- * Call once at session start. After freezing, mutations update
42
- * live state but NOT the system prompt block.
43
- */
44
- freezeSnapshot(): void;
45
- /**
46
- * Get frozen system prompt block for the given target.
47
- * Returns empty string if no entries or not yet frozen.
48
- */
49
- getSystemPromptBlock(target: MemoryStoreTarget): string;
50
- add(target: MemoryStoreTarget, content: string): MemoryStoreResult;
51
- replace(target: MemoryStoreTarget, oldText: string, newContent: string): MemoryStoreResult;
52
- remove(target: MemoryStoreTarget, oldText: string): MemoryStoreResult;
53
- getEntries(target: MemoryStoreTarget): readonly string[];
54
- getUsage(target: MemoryStoreTarget): {
55
- used: number;
56
- limit: number;
57
- percent: number;
58
- };
59
- isEmpty(): boolean;
60
- private entriesFor;
61
- private charLimitFor;
62
- private formatUsage;
63
- private renderBlock;
64
- private successResult;
65
- private errorResult;
66
- }
@@ -1,67 +0,0 @@
1
- import type { MemoryProvider, MemorySearchResult } from "qlogicagent-runtime-contracts";
2
- import type { MemoryStore, MemoryStoreTarget } from "./memory-store.js";
3
- export declare const MEMORY_TOOL_NAME: "memory";
4
- export declare const MEMORY_TOOL_MAX_CONTENT_LENGTH = 2000;
5
- export declare const MEMORY_TOOL_ACTIONS: readonly ["add", "replace", "remove", "search"];
6
- export type MemoryToolAction = (typeof MEMORY_TOOL_ACTIONS)[number];
7
- export declare const MEMORY_TOOL_SCHEMA: {
8
- readonly type: "object";
9
- readonly properties: {
10
- readonly action: {
11
- readonly type: "string";
12
- readonly enum: string[];
13
- readonly description: string;
14
- };
15
- readonly target: {
16
- readonly type: "string";
17
- readonly enum: readonly ["memory", "user"];
18
- readonly description: string;
19
- };
20
- readonly content: {
21
- readonly type: "string";
22
- readonly description: string;
23
- };
24
- readonly old_text: {
25
- readonly type: "string";
26
- readonly description: "Required for 'replace' and 'remove'. A substring that uniquely identifies the note entry to modify.";
27
- };
28
- readonly query: {
29
- readonly type: "string";
30
- readonly description: "Required for 'search'. Natural language query to find relevant memories.";
31
- };
32
- };
33
- readonly required: readonly ["action"];
34
- };
35
- export declare const MEMORY_TOOL_DESCRIPTION: string;
36
- export declare const MEMORY_TOOL_LABEL = "Memory";
37
- export declare function isMemoryContentSafe(text: string): boolean;
38
- export interface MemoryToolParams {
39
- action: MemoryToolAction;
40
- target?: MemoryStoreTarget;
41
- content?: string;
42
- old_text?: string;
43
- query?: string;
44
- }
45
- export interface MemoryToolResult {
46
- ok: boolean;
47
- message: string;
48
- action: string;
49
- /** For MD store operations: live entry count */
50
- entryCount?: number;
51
- /** For MD store operations: usage string */
52
- usage?: string;
53
- /** For search: qmemory results */
54
- results?: MemorySearchResult[];
55
- /** Indicates MD store was mutated (consumer should persist) */
56
- storeModified?: boolean;
57
- errorCode?: string;
58
- }
59
- export interface MemoryToolExecutorDeps {
60
- /** QMemory provider for semantic search. */
61
- provider: MemoryProvider;
62
- /** Local MD memory store for notes. */
63
- store?: MemoryStore;
64
- userId: string;
65
- sessionId?: string;
66
- }
67
- export declare function executeMemoryTool(params: MemoryToolParams, deps: MemoryToolExecutorDeps): Promise<MemoryToolResult>;
@@ -1,71 +0,0 @@
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_query"). */
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
- * Brief keyword hint for tool_search to match against
54
- * (e.g. "return the final response as structured JSON").
55
- */
56
- searchHint?: string;
57
- /**
58
- * Maximum allowed content size in characters for the tool result.
59
- * The runtime should truncate/reject results exceeding this.
60
- */
61
- maxResultSizeChars?: number;
62
- /**
63
- * Execute the tool.
64
- *
65
- * @param toolCallId - Unique ID for this tool invocation (for tracing).
66
- * @param params - Parsed parameters matching the JSON Schema.
67
- * @param signal - Optional abort signal.
68
- * @returns Tool result with content blocks + optional details.
69
- */
70
- execute(toolCallId: string, params: TParams, signal?: AbortSignal): Promise<PortableToolResult>;
71
- }
@@ -1,52 +0,0 @@
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
- * @example
35
- * ```ts
36
- * const provider = createQMemoryAdapter({
37
- * baseUrl: "http://localhost:18800",
38
- * apiKey: "sk-...",
39
- * });
40
- *
41
- * const results = await provider.search("last meeting notes", "alice");
42
- * await provider.ingest([{ role: "user", content: "..." }], "alice");
43
- * ```
44
- */
45
- export declare function createQMemoryAdapter(config: QMemoryAdapterConfig): MemoryProvider & {
46
- /** Check qmemory server health. */
47
- health(): Promise<QMemoryHealthStatus>;
48
- /** Write pre-extracted memories (no LLM extraction on qmemory side). */
49
- ingestExtracted(items: ExtractedMemoryItem[], userId: string, options?: MemoryIngestOptions): Promise<{
50
- memoriesAdded: number;
51
- }>;
52
- };
@@ -1,19 +0,0 @@
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;
@@ -1,23 +0,0 @@
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;
@@ -1,16 +0,0 @@
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;
@@ -1,119 +0,0 @@
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;
@@ -1,199 +0,0 @@
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
- }