@dot-ai/adapter-openclaw 0.5.2 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,205 @@
1
+ # @dot-ai/adapter-openclaw
2
+
3
+ OpenClaw adapter for dot-ai — universal context enrichment across AI agents.
4
+
5
+ ## Why dot-ai exists
6
+
7
+ AI agents (OpenClaw, Claude Code, Cursor, etc.) each implement their own memory, skills, and context systems. They're all solving the same problem differently, with hardcoded backends and no portability.
8
+
9
+ **dot-ai generalizes this.** One configuration (`dot-ai.yml`), pluggable providers, multiple adapters. Switch your memory backend without touching agent config. Use the same memory across OpenClaw and Claude Code.
10
+
11
+ ## Comparison: How agents handle memory
12
+
13
+ ### OpenClaw (built-in `memory-core`)
14
+
15
+ ```
16
+ memory-core plugin
17
+ ├── Tools: memory_search, memory_get (hardcoded)
18
+ ├── Backend: markdown files (MEMORY.md + memory/*.md)
19
+ ├── System prompt: buildMemorySection() — hardcoded text
20
+ │ "run memory_search on MEMORY.md + memory/*.md"
21
+ └── Search: line-by-line keyword matching
22
+ ```
23
+
24
+ - Storage and search logic baked into the plugin
25
+ - System prompt describes file-based memory regardless of actual backend
26
+ - No way to swap to SQLite, vector DB, or API without replacing the entire plugin
27
+ - `kind: "memory"` slot system allows replacement (one plugin per kind)
28
+
29
+ ### Claude Code (native auto-memory)
30
+
31
+ ```
32
+ Auto-memory system
33
+ ├── Storage: ~/.claude/projects/<project>/memory/MEMORY.md
34
+ ├── Write: Claude uses Write/Edit tools on markdown files
35
+ ├── Read: First 200 lines of MEMORY.md injected at session start
36
+ ├── Search: Claude reads files with Read tool (no semantic search)
37
+ └── Control: autoMemoryEnabled: true/false (global toggle)
38
+ ```
39
+
40
+ - Plain markdown files, no indexing or search
41
+ - Hardcoded directory structure per project
42
+ - No plugin API to redirect memory writes
43
+ - Hooks available: UserPromptSubmit (inject), PreCompact (save before compaction), Stop (extract learnings)
44
+ - Can disable native memory and replace via hooks + MCP tools
45
+
46
+ ### dot-ai (provider-based)
47
+
48
+ ```
49
+ dot-ai.yml (user config)
50
+
51
+ ├── MemoryProvider interface
52
+ │ ├── search(query, labels) → MemoryEntry[]
53
+ │ ├── store(entry) → void
54
+ │ └── describe() → string ← tells the LLM what system is active
55
+
56
+ ├── Providers (interchangeable)
57
+ │ ├── @dot-ai/provider-file-memory → markdown files
58
+ │ ├── @dot-ai/provider-sqlite-memory → SQLite + FTS5
59
+ │ └── (future: vector DB, API, etc.)
60
+
61
+ └── Adapters (multi-agent)
62
+ ├── @dot-ai/adapter-openclaw → before_agent_start + memory slot
63
+ └── @dot-ai/adapter-claude → UserPromptSubmit hook
64
+ ```
65
+
66
+ - **One config** (`dot-ai.yml`) controls the backend for all agents
67
+ - **Provider swap** = one line change, no code modification
68
+ - **Self-describing** = `describe()` tells the LLM exactly what system is active
69
+ - **Same memory** shared across OpenClaw and Claude Code sessions
70
+
71
+ ## Key difference: describe()
72
+
73
+ The core innovation is that each provider **tells the LLM how memory works**:
74
+
75
+ | Provider | describe() output |
76
+ |----------|------------------|
77
+ | `file-memory` | "File-based memory (markdown files). Directories: root:memory/." |
78
+ | `sqlite-memory` | "SQLite memory with FTS5 full-text search. 1626 entries indexed." |
79
+
80
+ This is injected as a blockquote in the memory section:
81
+
82
+ ```markdown
83
+ ## Relevant Memory
84
+
85
+ > SQLite memory with FTS5 full-text search. 1626 entries indexed. Memories are stored and searched automatically.
86
+
87
+ - Previous decision about API design (2026-03-04)
88
+ - User prefers TypeScript over JavaScript (2026-03-01)
89
+ ```
90
+
91
+ No more "run memory_search on MEMORY.md" when the backend is SQLite.
92
+
93
+ ## OpenClaw integration
94
+
95
+ ### Memory slot replacement
96
+
97
+ This plugin declares `kind: "memory"` to replace OpenClaw's built-in `memory-core` via the exclusive slot system.
98
+
99
+ **What gets replaced:**
100
+
101
+ | Component | memory-core | dot-ai |
102
+ |-----------|-------------|--------|
103
+ | Tools | `memory_search`, `memory_get` | `memory_recall`, `memory_store` |
104
+ | System prompt | Hardcoded `buildMemorySection()` | Dynamic via `describe()` + `prependContext` |
105
+ | Backend | Markdown files only | Any provider (SQLite, files, API...) |
106
+ | Search | Line-by-line keyword | Provider-dependent (FTS5, keyword, vector...) |
107
+
108
+ **How it works:**
109
+
110
+ 1. `openclaw.plugin.json` declares `kind: "memory"` → enters slot competition
111
+ 2. User sets `plugins.slots.memory: "dot-ai"` → OpenClaw disables `memory-core`
112
+ 3. `buildMemorySection()` returns `[]` (our tools aren't named `memory_search`/`memory_get`)
113
+ 4. dot-ai injects its own context via `before_agent_start` → `prependContext`
114
+
115
+ **User configuration:**
116
+
117
+ ```yaml
118
+ # ~/.openclaw/openclaw.yaml (or .json)
119
+ plugins:
120
+ slots:
121
+ memory: "dot-ai"
122
+ ```
123
+
124
+ ### Context enrichment (beyond memory)
125
+
126
+ Independent of the slot system, the plugin hooks `before_agent_start` to run the full dot-ai pipeline:
127
+
128
+ ```
129
+ loadConfig → createProviders → boot → enrich → formatContext → prependContext
130
+ ```
131
+
132
+ This injects **all** dot-ai context: identities, skills, tools, routing, and memory. The slot only controls which memory tools are active — the rest flows through `prependContext` regardless.
133
+
134
+ ## Claude Code integration
135
+
136
+ See `@dot-ai/adapter-claude` for the Claude Code adapter.
137
+
138
+ **Current capabilities:**
139
+
140
+ | Hook | Purpose | Status |
141
+ |------|---------|--------|
142
+ | `UserPromptSubmit` | Inject enriched context | Implemented |
143
+ | `PreCompact` | Save to memory before compaction | Planned |
144
+ | `Stop` | Extract learnings after response | Planned |
145
+ | MCP server | `memory_recall`/`memory_store` tools | Planned |
146
+ | `autoMemoryEnabled: false` | Disable native MEMORY.md | Planned |
147
+ | `PreToolUse` (Write/Edit) | Intercept native memory writes | Planned |
148
+
149
+ **Target architecture:**
150
+
151
+ ```
152
+ Claude Code session
153
+ ├── SessionStart: boot dot-ai providers
154
+ ├── UserPromptSubmit: enrich() → inject context (done)
155
+ ├── PreCompact: parse transcript → provider.store() (planned)
156
+ ├── Stop: extract learnings → provider.store() (planned)
157
+ ├── MCP tools: memory_recall, memory_store (planned)
158
+ └── PreToolUse: intercept writes to ~/.claude/*/memory/ (planned)
159
+ ```
160
+
161
+ ## OpenClaw slot system — future tracking
162
+
163
+ As of March 2026, OpenClaw only supports one slot kind: `"memory"`. The architecture is extensible:
164
+
165
+ ```typescript
166
+ // openclaw/src/plugins/types.ts
167
+ export type PluginKind = "memory"; // only value today
168
+
169
+ // openclaw/src/plugins/slots.ts
170
+ const SLOT_BY_KIND = { memory: "memory" }; // extensible map
171
+ ```
172
+
173
+ dot-ai already has providers for capabilities that could become future slot kinds:
174
+
175
+ | Potential Kind | dot-ai Provider | OpenClaw Status |
176
+ |---------------|-----------------|-----------------|
177
+ | `memory` | MemoryProvider | **Supported** (slot exists) |
178
+ | `skills` | SkillProvider | Not yet — dot-ai uses `prependContext` |
179
+ | `routing` | RoutingProvider | Not yet — dot-ai uses `prependContext` |
180
+ | `identity` | IdentityProvider | Not yet — dot-ai uses `prependContext` |
181
+ | `tools` | ToolProvider | Not yet — dot-ai uses `prependContext` |
182
+
183
+ When OpenClaw adds new kinds, this adapter can declare them for native slot integration.
184
+
185
+ ## Architecture
186
+
187
+ ```
188
+ dot-ai.yml
189
+
190
+
191
+ @dot-ai/core ─── contracts (6 interfaces) + engine (boot/enrich/learn)
192
+
193
+ ├── Providers (pluggable backends)
194
+ │ ├── file-memory, sqlite-memory
195
+ │ ├── file-skills, file-identity, file-tools
196
+ │ ├── rules-routing
197
+ │ └── cockpit-tasks (kiwi-specific)
198
+
199
+ └── Adapters (agent integration)
200
+ ├── adapter-openclaw (this) ── slot + before_agent_start
201
+ ├── adapter-claude ────────── UserPromptSubmit hook
202
+ └── adapter-sync ──────────── file markers for Cursor/Copilot
203
+ ```
204
+
205
+ The key insight: **agents are just adapters**. The intelligence lives in the providers and engine. Adding support for a new agent means writing one adapter file, not reimplementing memory/skills/routing.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=plugin-integration.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-integration.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/plugin-integration.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,164 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { DotAiRuntime, EventBus, ADAPTER_CAPABILITIES } from '@dot-ai/core';
3
+ function createMockOpenClawApi() {
4
+ const logs = [];
5
+ const hooks = [];
6
+ const services = [];
7
+ const tools = [];
8
+ const api = {
9
+ logger: {
10
+ info: (msg) => logs.push(msg),
11
+ debug: (msg) => logs.push(`[debug] ${msg}`),
12
+ },
13
+ pluginConfig: undefined,
14
+ on(event, handler, options) {
15
+ hooks.push({ event, handler, options });
16
+ },
17
+ registerService(service) {
18
+ services.push(service);
19
+ },
20
+ registerTool(factory, opts) {
21
+ tools.push({ factory, opts });
22
+ },
23
+ };
24
+ return { api, logs, hooks, services, tools };
25
+ }
26
+ // ── Tests ──
27
+ describe('OpenClaw Plugin Integration', () => {
28
+ describe('plugin.register() structure', () => {
29
+ it('registers before_agent_start hook with priority 10', async () => {
30
+ const { api, hooks } = createMockOpenClawApi();
31
+ const { default: plugin } = await import('../index.js');
32
+ plugin.register(api);
33
+ const beforeStart = hooks.find(h => h.event === 'before_agent_start');
34
+ expect(beforeStart).toBeDefined();
35
+ expect(beforeStart.options?.priority).toBe(10);
36
+ });
37
+ it('registers after_agent_end hook', async () => {
38
+ const { api, hooks } = createMockOpenClawApi();
39
+ const { default: plugin } = await import('../index.js');
40
+ plugin.register(api);
41
+ const afterEnd = hooks.find(h => h.event === 'after_agent_end');
42
+ expect(afterEnd).toBeDefined();
43
+ });
44
+ it('registers dot-ai service', async () => {
45
+ const { api, services } = createMockOpenClawApi();
46
+ const { default: plugin } = await import('../index.js');
47
+ plugin.register(api);
48
+ const svc = services.find(s => s.id === 'dot-ai');
49
+ expect(svc).toBeDefined();
50
+ });
51
+ it('registers tool factory for capabilities', async () => {
52
+ const { api, tools } = createMockOpenClawApi();
53
+ const { default: plugin } = await import('../index.js');
54
+ plugin.register(api);
55
+ expect(tools.length).toBe(1);
56
+ expect(tools[0].opts?.names).toContain('memory_recall');
57
+ expect(tools[0].opts?.names).toContain('memory_store');
58
+ expect(tools[0].opts?.names).toContain('task_list');
59
+ });
60
+ it('logs plugin version v6', async () => {
61
+ const { api, logs } = createMockOpenClawApi();
62
+ const { default: plugin } = await import('../index.js');
63
+ plugin.register(api);
64
+ expect(logs.some(l => l.includes('v6'))).toBe(true);
65
+ });
66
+ it('has correct plugin metadata', async () => {
67
+ const { default: plugin } = await import('../index.js');
68
+ expect(plugin.id).toBe('dot-ai');
69
+ expect(plugin.version).toBe('6.0.0');
70
+ expect(plugin.kind).toBe('memory');
71
+ });
72
+ });
73
+ describe('before_agent_start → boot → processPrompt', () => {
74
+ it('skips sub-agent sessions', async () => {
75
+ const { api, hooks, logs } = createMockOpenClawApi();
76
+ const { default: plugin } = await import('../index.js');
77
+ plugin.register(api);
78
+ const beforeStart = hooks.find(h => h.event === 'before_agent_start');
79
+ const result = await beforeStart.handler({}, { workspaceDir: '/tmp/test', sessionKey: 'session:subagent:1', prompt: 'hello' });
80
+ expect(result).toBeUndefined();
81
+ expect(logs.some(l => l.includes('Sub-agent'))).toBe(true);
82
+ });
83
+ it('skips cron sessions', async () => {
84
+ const { api, hooks, logs } = createMockOpenClawApi();
85
+ const { default: plugin } = await import('../index.js');
86
+ plugin.register(api);
87
+ const beforeStart = hooks.find(h => h.event === 'before_agent_start');
88
+ const result = await beforeStart.handler({}, { workspaceDir: '/tmp/test', sessionKey: 'session:cron:cleanup', prompt: 'cleanup' });
89
+ expect(result).toBeUndefined();
90
+ expect(logs.some(l => l.includes('Sub-agent') || l.includes('cron'))).toBe(true);
91
+ });
92
+ it('skips when no workspaceDir', async () => {
93
+ const { api, hooks, logs } = createMockOpenClawApi();
94
+ const { default: plugin } = await import('../index.js');
95
+ plugin.register(api);
96
+ const beforeStart = hooks.find(h => h.event === 'before_agent_start');
97
+ const result = await beforeStart.handler({}, { prompt: 'hello' });
98
+ expect(result).toBeUndefined();
99
+ expect(logs.some(l => l.includes('No workspaceDir'))).toBe(true);
100
+ });
101
+ });
102
+ describe('DotAiRuntime lifecycle (v6 extension-only)', () => {
103
+ it('boots and processes prompt', async () => {
104
+ const runtime = new DotAiRuntime({
105
+ workspaceRoot: '/tmp/nonexistent',
106
+ skipIdentities: true,
107
+ });
108
+ await runtime.boot();
109
+ expect(runtime.isBooted).toBe(true);
110
+ const { formatted } = await runtime.processPrompt('hello world');
111
+ expect(formatted).toBeDefined();
112
+ });
113
+ it('diagnostics show extension info', async () => {
114
+ const runtime = new DotAiRuntime({
115
+ workspaceRoot: '/tmp/nonexistent',
116
+ });
117
+ await runtime.boot();
118
+ const diag = runtime.diagnostics;
119
+ expect(diag.extensions).toEqual([]);
120
+ expect(diag.capabilityCount).toBe(0);
121
+ });
122
+ it('learn fires agent_end without throwing', async () => {
123
+ const runtime = new DotAiRuntime({
124
+ workspaceRoot: '/tmp/nonexistent',
125
+ });
126
+ await runtime.boot();
127
+ await runtime.learn('test response');
128
+ });
129
+ });
130
+ describe('OpenClaw adapter capability matrix', () => {
131
+ it('OpenClaw supports context_inject, agent_end, session_start', () => {
132
+ const supported = ADAPTER_CAPABILITIES['openclaw'];
133
+ expect(supported.has('context_inject')).toBe(true);
134
+ expect(supported.has('agent_end')).toBe(true);
135
+ expect(supported.has('session_start')).toBe(true);
136
+ });
137
+ it('OpenClaw does NOT support tool_call, tool_result, context_modify', () => {
138
+ const supported = ADAPTER_CAPABILITIES['openclaw'];
139
+ expect(supported.has('tool_call')).toBe(false);
140
+ expect(supported.has('tool_result')).toBe(false);
141
+ expect(supported.has('context_modify')).toBe(false);
142
+ expect(supported.has('turn_start')).toBe(false);
143
+ expect(supported.has('turn_end')).toBe(false);
144
+ });
145
+ });
146
+ describe('EventBus inter-extension communication', () => {
147
+ it('extensions can communicate via EventBus', async () => {
148
+ const eventBus = new EventBus();
149
+ const received = [];
150
+ eventBus.on('custom:auth-fix', (data) => {
151
+ received.push(data);
152
+ });
153
+ eventBus.emit('custom:auth-fix', { file: 'auth.ts', action: 'refactored' });
154
+ expect(received).toHaveLength(1);
155
+ expect(received[0]).toEqual({ file: 'auth.ts', action: 'refactored' });
156
+ });
157
+ it('EventBus errors dont propagate', () => {
158
+ const eventBus = new EventBus();
159
+ eventBus.on('test', () => { throw new Error('boom'); });
160
+ expect(() => eventBus.emit('test')).not.toThrow();
161
+ });
162
+ });
163
+ });
164
+ //# sourceMappingURL=plugin-integration.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-integration.test.js","sourceRoot":"","sources":["../../src/__tests__/plugin-integration.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAqB5E,SAAS,qBAAqB;IAC5B,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,MAAM,KAAK,GAAmB,EAAE,CAAC;IACjC,MAAM,QAAQ,GAAsB,EAAE,CAAC;IACvC,MAAM,KAAK,GAAmB,EAAE,CAAC;IAEjC,MAAM,GAAG,GAAG;QACV,MAAM,EAAE;YACN,IAAI,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;YACrC,KAAK,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;SACpD;QACD,YAAY,EAAE,SAAgD;QAC9D,EAAE,CACA,KAAa,EACb,OAAwC,EACxC,OAA+B;YAE/B,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QAC1C,CAAC;QACD,eAAe,CAAC,OAAwB;YACtC,QAAQ,CAAC,IAAI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AE,MAAM,EAAE,YAAY,EAAE,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,gCAAgC,EAAE,GAAG,EAAE;YACxC,MAAM,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;YAChC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YAExD,MAAM,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;QACpD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -23,12 +23,32 @@ interface OpenClawPluginApi {
23
23
  logger: OpenClawLogger;
24
24
  }): void;
25
25
  }): void;
26
+ registerTool(tool: OpenClawTool | OpenClawToolFactory, opts?: {
27
+ name?: string;
28
+ names?: string[];
29
+ }): void;
30
+ }
31
+ interface OpenClawToolResult {
32
+ content: Array<{
33
+ type: string;
34
+ text: string;
35
+ }>;
36
+ details?: Record<string, unknown>;
37
+ }
38
+ interface OpenClawTool {
39
+ name: string;
40
+ label: string;
41
+ description: string;
42
+ parameters: Record<string, unknown>;
43
+ execute(toolCallId: string, params: Record<string, unknown>): Promise<OpenClawToolResult>;
26
44
  }
45
+ type OpenClawToolFactory = (ctx: Record<string, unknown>) => OpenClawTool | OpenClawTool[] | null;
27
46
  declare const plugin: {
28
47
  id: string;
29
48
  name: string;
30
49
  version: string;
31
50
  description: string;
51
+ kind: "memory";
32
52
  register(api: OpenClawPluginApi): void;
33
53
  };
34
54
  export default plugin;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAsBA,UAAU,cAAc;IACtB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,C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AM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;CAC3F;AAED,KAAK,mBAAmB,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,YAAY,GAAG,YAAY,EAAE,GAAG,IAAI,CAAC;AAMlG,QAAA,MAAM,MAAM;;;;;;kBAOI,iBAAiB;CA0FhC,CAAC;AAEF,eAAe,MAAM,CAAC"}
package/dist/index.js CHANGED
@@ -1,103 +1,70 @@
1
1
  /**
2
- * dot-ai OpenClaw plugin v4
3
- *
4
- * Hooks into before_agent_start to run the full dot-ai pipeline:
5
- * loadConfig → registerDefaults → createProviders → boot → enrich → formatContext
2
+ * dot-ai OpenClaw plugin v6
6
3
  *
4
+ * Hooks into before_agent_start to run the full dot-ai pipeline via DotAiRuntime.
5
+ * Uses the v6 extension-based pipeline — no providers required.
7
6
  * Returns enriched context as prependContext for the agent.
8
7
  */
9
- import { loadConfig, registerDefaults, registerProvider, createProviders, boot, enrich, injectRoot, formatContext, } from '@dot-ai/core';
10
- /**
11
- * Load custom providers declared in pluginConfig.
12
- * Workspaces declare custom providers via openclaw.json:
13
- * plugins.entries.dot-ai.config.customProviders: [
14
- * { type: "cockpit", module: "/abs/path/to/provider.ts" }
15
- * ]
16
- */
17
- async function loadCustomProviders(config, logger) {
18
- const providers = config.customProviders;
19
- if (!Array.isArray(providers))
20
- return;
21
- for (const entry of providers) {
22
- if (!entry || typeof entry !== 'object' || !('type' in entry) || !('module' in entry))
23
- continue;
24
- const { type, module: modulePath } = entry;
25
- try {
26
- const mod = await import(modulePath);
27
- // Find the exported provider class or factory
28
- for (const [name, exported] of Object.entries(mod)) {
29
- if (typeof exported === 'function') {
30
- if (name.endsWith('Provider')) {
31
- const ProviderClass = exported;
32
- registerProvider(`@custom/${type}`, (opts) => new ProviderClass(opts));
33
- logger.info(`[dot-ai] Registered custom provider: ${type} (${name})`);
34
- break;
35
- }
36
- }
37
- }
38
- }
39
- catch (err) {
40
- logger.info(`[dot-ai] Failed to load custom provider "${type}" from ${modulePath}: ${err}`);
41
- }
42
- }
43
- }
8
+ import { DotAiRuntime } from '@dot-ai/core';
44
9
  // Session-level cache
45
- let cachedProviders = null;
46
- let cachedBoot = null;
10
+ let cachedRuntime = null;
47
11
  let cachedWorkspace = null;
48
12
  const plugin = {
49
13
  id: 'dot-ai',
50
14
  name: 'dot-ai — Universal AI Workspace Convention',
51
- version: '0.4.0',
15
+ version: '6.0.0',
52
16
  description: 'Deterministic context enrichment for OpenClaw agents',
17
+ kind: 'memory',
53
18
  register(api) {
54
- api.logger.info('[dot-ai] Plugin loaded (v4)');
55
- // Load custom providers if configured capture the promise so before_agent_start can await it
56
- let providerPromise = Promise.resolve();
57
- if (api.pluginConfig) {
58
- providerPromise = loadCustomProviders(api.pluginConfig, api.logger);
59
- }
60
- // Register default file-based providers
61
- registerDefaults();
19
+ api.logger.info('[dot-ai] Plugin loaded (v6)');
20
+ // Register tools from core capabilities (delegates to extensions)
21
+ api.registerTool((_ctx) => {
22
+ if (!cachedRuntime?.isBooted)
23
+ return null;
24
+ const capabilities = cachedRuntime.capabilities;
25
+ return capabilities.map((cap) => ({
26
+ name: cap.name,
27
+ label: cap.name.replace(/_/g, ' ').replace(/\b\w/g, c => c.toUpperCase()),
28
+ description: cap.description,
29
+ parameters: cap.parameters,
30
+ async execute(_toolCallId, params) {
31
+ const result = await cap.execute(params);
32
+ return {
33
+ content: [{ type: 'text', text: result.text }],
34
+ ...(result.details && { details: result.details }),
35
+ };
36
+ },
37
+ }));
38
+ }, { names: ['memory_recall', 'memory_store', 'task_list', 'task_create', 'task_update'] });
62
39
  // Hook: before_agent_start — run the full pipeline
63
40
  api.on('before_agent_start', async (_event, ctx) => {
64
- // Ensure custom providers are registered before proceeding
65
- await providerPromise;
66
41
  const workspaceDir = ctx.workspaceDir;
67
42
  if (!workspaceDir) {
68
43
  api.logger.info('[dot-ai] No workspaceDir, skipping');
69
44
  return;
70
45
  }
71
- // Skip sub-agent/cron sessions
72
46
  const isSubagent = ctx.sessionKey?.includes(':subagent:') || ctx.sessionKey?.includes(':cron:');
73
47
  if (isSubagent) {
74
48
  api.logger.debug?.('[dot-ai] Sub-agent/cron session, skipping');
75
49
  return;
76
50
  }
77
51
  try {
78
- // Boot once per workspace (cache across prompts in same session)
79
- if (!cachedProviders || cachedWorkspace !== workspaceDir) {
80
- const rawConfig = await loadConfig(workspaceDir);
81
- // Inject workspaceDir into all provider options
82
- const config = injectRoot(rawConfig, workspaceDir);
83
- cachedProviders = await createProviders(config);
84
- cachedBoot = await boot(cachedProviders);
52
+ if (!cachedRuntime || cachedWorkspace !== workspaceDir) {
53
+ cachedRuntime = new DotAiRuntime({ workspaceRoot: workspaceDir });
54
+ await cachedRuntime.boot();
85
55
  cachedWorkspace = workspaceDir;
86
- api.logger.info(`[dot-ai] Booted: ${cachedBoot.identities.length} identities, ${cachedBoot.vocabulary.length} vocabulary, ${cachedBoot.skills.length} skills`);
87
- }
88
- // Enrich the prompt
89
- const prompt = ctx.prompt ?? '';
90
- const enriched = await enrich(prompt, cachedProviders, cachedBoot);
91
- // Load skill content for matched skills
92
- for (const skill of enriched.skills) {
93
- if (!skill.content && skill.name) {
94
- skill.content = await cachedProviders.skills.load(skill.name) ?? undefined;
56
+ api.logger.info('[dot-ai] Runtime booted (v6)');
57
+ // Log extension diagnostics
58
+ const diag = cachedRuntime.diagnostics;
59
+ api.logger.info(`[dot-ai] extensions=${diag.extensions.length}, capabilities=${diag.capabilityCount}`);
60
+ if (diag.vocabularySize !== undefined) {
61
+ api.logger.info(`[dot-ai] Vocabulary size: ${diag.vocabularySize}`);
95
62
  }
96
63
  }
97
- // Format and inject
98
- const formatted = formatContext(enriched);
64
+ const prompt = ctx.prompt ?? '';
65
+ const { formatted, enriched } = await cachedRuntime.processPrompt(prompt);
99
66
  if (formatted) {
100
- api.logger.info(`[dot-ai] Injected: ${enriched.identities.length} identities, ${enriched.memories.length} memories, ${enriched.skills.length} skills`);
67
+ api.logger.info(`[dot-ai] Injected: ${enriched.identities.length} ids, ${enriched.memories.length} mems, ${enriched.skills.length} skills`);
101
68
  return { prependContext: formatted };
102
69
  }
103
70
  }
@@ -106,6 +73,15 @@ const plugin = {
106
73
  }
107
74
  return;
108
75
  }, { priority: 10 });
76
+ // Hook: after_agent_end — feed response back to runtime for learning + extension events
77
+ api.on('after_agent_end', async (_event, ctx) => {
78
+ if (!cachedRuntime)
79
+ return;
80
+ const response = ctx.response ?? '';
81
+ if (response) {
82
+ await cachedRuntime.learn(response);
83
+ }
84
+ });
109
85
  // Service registration
110
86
  api.registerService({
111
87
  id: 'dot-ai',
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,gBAAgB,EAChB,eAAe,EACf,IAAI,EACJ,MAAM,EACN,UAAU,EACV,aAAa,GAGd,MAAM,cAAc,CAAC;AA0BtB;;;;;;GAMG;AACH,KAAK,UAAU,mBAAmB,CAChC,MAA+B,EAC/B,MAAsB;IAEtB,MAAM,SAAS,GAAG,MAAM,CAAC,eAAe,CAAC;IACzC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC;QAAE,OAAO;IAEtC,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;QAC9B,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC;YAAE,SAAS;QAEhG,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,KAAyC,CAAC;QAC/E,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,CAAC;YACrC,8CAA8C;YAC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ACvB,GAAG,CAAC,eAAe,CAAC;YAClB,EAAE,EAAE,QAAQ;YACZ,KAAK,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC;YAClD,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC;SACnD,CAAC,CAAC;IACL,CAAC;CACF,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -0,0 +1,9 @@
1
+ {
2
+ "id": "dot-ai",
3
+ "kind": "memory",
4
+ "configSchema": {
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "properties": {}
8
+ }
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dot-ai/adapter-openclaw",
3
- "version": "0.5.2",
3
+ "version": "0.7.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/jogelin/dot-ai",
@@ -18,7 +18,7 @@
18
18
  "openclaw": "^2026.2.0"
19
19
  },
20
20
  "dependencies": {
21
- "@dot-ai/core": "0.5.2"
21
+ "@dot-ai/core": "0.7.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/node": "^22.0.0",