@signetai/connector-openclaw 0.140.1

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,71 @@
1
+ # @signetai/connector-openclaw
2
+
3
+ Signet connector for OpenClaw (and its earlier names: clawdbot, moltbot).
4
+
5
+ ## Overview
6
+
7
+ Unlike other harnesses, OpenClaw reads `~/.agents/AGENTS.md` directly, so no
8
+ generated output file is needed. Instead, this connector patches the JSON
9
+ config to point OpenClaw at the Signet workspace and enables memory hooks.
10
+
11
+ ## Installation
12
+
13
+ ```bash
14
+ npm install @signetai/connector-openclaw
15
+ # or
16
+ bun add @signetai/connector-openclaw
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ```typescript
22
+ import { OpenClawConnector } from '@signetai/connector-openclaw';
23
+
24
+ const connector = new OpenClawConnector();
25
+ await connector.install('~/.agents');
26
+ ```
27
+
28
+ ## What It Does
29
+
30
+ - Patches JSON config files: `~/.openclaw/openclaw.json`,
31
+ `~/.clawdbot/clawdbot.json`, `~/.moldbot/moldbot.json`,
32
+ `~/.moltbot/moltbot.json`
33
+ - Also discovers config via modern env vars used by OpenClaw:
34
+ `OPENCLAW_CONFIG_PATH`, `CLAWDBOT_CONFIG_PATH`,
35
+ `OPENCLAW_STATE_DIR`, `CLAWDBOT_STATE_DIR`
36
+ - State-dir discovery follows OpenClaw compatibility behavior and may
37
+ detect legacy config filenames in that directory (`clawdbot.json`,
38
+ `moldbot.json`, `moltbot.json`) in addition to `openclaw.json`
39
+ - Preserves legacy env compatibility used by older installs:
40
+ `OPENCLAW_HOME`, `CLAWDBOT_HOME`, `MOLDBOT_HOME`, `MOLTBOT_HOME`,
41
+ `OPENCLAW_STATE_HOME`
42
+ - Sets `agents.defaults.workspace` to point at `~/.agents`
43
+ - Enables the `signet-memory` internal hook entry
44
+ - Creates hook handler files in `~/.agents/hooks/agent-memory/` for
45
+ `/remember`, `/recall`, and `/context` commands
46
+
47
+ ## API
48
+
49
+ ### `install(basePath: string): Promise<InstallResult>`
50
+
51
+ Install the connector. Patches all found OpenClaw config files and installs
52
+ hook handler files.
53
+
54
+ ### `uninstall(basePath?: string): Promise<UninstallResult>`
55
+
56
+ Uninstall the connector. Disables the `signet-memory` hook in all configs
57
+ and removes hook handler files.
58
+
59
+ ### `isInstalled(): boolean`
60
+
61
+ Check whether any OpenClaw config has signet-memory enabled.
62
+
63
+ ## Idempotent
64
+
65
+ Safe to run multiple times. Re-running `install()` will update configs and
66
+ hook files to the current expected state without duplicating or corrupting
67
+ existing configuration.
68
+
69
+ ## License
70
+
71
+ Apache-2.0
package/bin/install.js ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env node
2
+ import { runConnectorInstaller } from "@signetai/connector-base";
3
+ import { OpenClawConnector } from "../dist/index.js";
4
+
5
+ runConnectorInstaller("openclaw", OpenClawConnector);
@@ -0,0 +1,146 @@
1
+ /**
2
+ * @signetai/connector-openclaw
3
+ *
4
+ * Signet connector for OpenClaw (and its earlier names: clawdbot, moltbot).
5
+ *
6
+ * Unlike Claude Code and OpenCode, OpenClaw reads ~/.agents/AGENTS.md
7
+ * directly — so no generated output file is needed. Instead, this
8
+ * connector can patch OpenClaw config to:
9
+ * 1. Point `agents.defaults.workspace` at ~/.agents
10
+ * 2. Enable the `signet-memory` internal hook entry
11
+ *
12
+ * It also installs hook handler files that OpenClaw loads for
13
+ * /remember, /recall, and /context commands.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { OpenClawConnector } from '@signetai/connector-openclaw';
18
+ *
19
+ * const connector = new OpenClawConnector();
20
+ * await connector.install('~/.agents');
21
+ * ```
22
+ */
23
+ import { BaseConnector, type InstallResult, type UninstallResult } from "@signetai/connector-base";
24
+ export interface OpenClawInstallOptions {
25
+ configureWorkspace?: boolean;
26
+ configureHooks?: boolean;
27
+ runtimePath?: "plugin" | "legacy";
28
+ }
29
+ export type OpenClawRuntimeState = "plugin" | "legacy" | "dual" | null;
30
+ /**
31
+ * Connector for OpenClaw (and its historical names: clawdbot, moltbot).
32
+ *
33
+ * Idempotent — safe to run multiple times.
34
+ */
35
+ export declare class OpenClawConnector extends BaseConnector {
36
+ readonly name = "OpenClaw";
37
+ readonly harnessId = "openclaw";
38
+ /**
39
+ * Install the connector.
40
+ *
41
+ * - Patches OpenClaw hook entries by default
42
+ * - Patches OpenClaw workspace only when explicitly requested
43
+ * - Installs hook handler files under `<basePath>/hooks/agent-memory/`
44
+ *
45
+ * **`runtimePath` default changed in 0.53:** The default is now `"plugin"`
46
+ * (automatic per-prompt memory injection via the OpenClaw plugin system)
47
+ * instead of the old `"legacy"` (manual `/remember`/`/recall` commands
48
+ * only). SDK callers that relied on the legacy path must now pass
49
+ * `{ runtimePath: "legacy" }` explicitly.
50
+ */
51
+ install(basePath: string, options?: OpenClawInstallOptions): Promise<InstallResult>;
52
+ /**
53
+ * Patch OpenClaw configs to set workspace only.
54
+ */
55
+ configureWorkspace(basePath: string): Promise<string[]>;
56
+ /**
57
+ * Sync a multi-agent roster into the `agents.list` section of all
58
+ * discovered OpenClaw configs. Only agents that include `"openclaw"` in
59
+ * their `harnesses` array (or have no harnesses specified) are written.
60
+ */
61
+ syncMultipleAgents(roster: ReadonlyArray<{
62
+ name: string;
63
+ harnesses?: ReadonlyArray<string>;
64
+ skills?: ReadonlyArray<string>;
65
+ }>, basePath: string): Promise<void>;
66
+ /**
67
+ * Return all existing OpenClaw config paths discovered on this machine.
68
+ */
69
+ getDiscoveredConfigPaths(): string[];
70
+ /**
71
+ * Return normalized workspace paths declared in discovered OpenClaw configs.
72
+ *
73
+ * Paths are expanded (`~` -> home) and de-duplicated.
74
+ */
75
+ getDiscoveredWorkspacePaths(): string[];
76
+ /**
77
+ * Uninstall the connector.
78
+ *
79
+ * Disables both legacy hooks and plugin entries, removes hook handler files.
80
+ */
81
+ uninstall(): Promise<UninstallResult>;
82
+ private removePluginFromAllow;
83
+ /**
84
+ * Check whether any OpenClaw config has signet enabled
85
+ * (via legacy hooks or plugin entry).
86
+ */
87
+ isInstalled(): boolean;
88
+ getRuntimeState(): OpenClawRuntimeState;
89
+ getConfiguredRuntimePath(): "plugin" | "legacy" | null;
90
+ /**
91
+ * Get the primary config path (first existing config, or default).
92
+ */
93
+ getConfigPath(): string;
94
+ /**
95
+ * Reject workspace paths that point into temp directories.
96
+ * Prevents accidental persistence of test/ephemeral paths
97
+ * in production OpenClaw configs.
98
+ */
99
+ private validateWorkspacePath;
100
+ /**
101
+ * Check that a resolved workspace path exists and belongs to
102
+ * the current user's home directory. Returns warnings (non-fatal)
103
+ * so callers can surface them without blocking the install.
104
+ */
105
+ private checkWorkspaceOwnership;
106
+ private getConfigCandidates;
107
+ /**
108
+ * Patch configs with plugin entry using the object format:
109
+ * plugins.entries["signet-memory-openclaw"] = { enabled, config }
110
+ *
111
+ * Migrates:
112
+ * - Legacy array-style plugins (["signet-memory"] -> { entries: {...} })
113
+ * - Top-level `signet: { daemonUrl }` key
114
+ * - Old plugin name "signet-memory" -> "signet-memory-openclaw"
115
+ */
116
+ private patchAllConfigsWithPlugin;
117
+ private patchAllConfigs;
118
+ private patchConfig;
119
+ /**
120
+ * Narrow config-only update: add `searchPath` to `plugins.load.paths` and
121
+ * ensure `plugins.allow` trusts `signet-memory-openclaw` in all discovered
122
+ * configs without re-running the full install flow.
123
+ *
124
+ * `searchPath` should be the **parent** directory of the plugin package
125
+ * (e.g. `…/@signetai/`) so OpenClaw can find `signet-memory-openclaw`
126
+ * as a subdirectory.
127
+ */
128
+ patchLoadPaths(searchPath: string): {
129
+ patched: string[];
130
+ warnings: string[];
131
+ };
132
+ /**
133
+ * Create the hook handler files that OpenClaw loads for
134
+ * /remember, /recall, and /context commands.
135
+ *
136
+ * This is the canonical implementation; cli.ts delegates here.
137
+ */
138
+ installHookFiles(basePath: string): string[];
139
+ /** Detect the indentation style used in a JSON string. */
140
+ private detectIndent;
141
+ private getHomeDir;
142
+ }
143
+ /** Create an OpenClaw connector instance. */
144
+ export declare function createConnector(): OpenClawConnector;
145
+ export default OpenClawConnector;
146
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAKH,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAmB,MAAM,wBAAwB,CAAC;AAyClH,MAAM,WAAW,sBAAsB;IACtC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,WAAW,CAAC,EAAE,QAAQ,GAAG,QAAQ,CAAC;CAClC;AAED,MAAM,MAAM,oBAAoB,GAAG,QAAQ,GAAG,QAAQ,GAAG,MAAM,GAAG,IAAI,CAAC;AA+OvE;;;;GAIG;AACH,qBAAa,iBAAkB,SAAQ,aAAa;IACnD,QAAQ,CAAC,IAAI,cAAc;IAC3B,QAAQ,CAAC,SAAS,cAAc;IAEhC;;;;;;;;;;;;OAYG;IACG,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,sBAA2B,GAAG,OAAO,CAAC,aAAa,CAAC;IAyF7F;;OAEG;IACG,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAiB7D;;;;OAIG;IACG,kBAAkB,CACvB,MAAM,EAAE,aAAa,CAAC;QACrB,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAClC,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;KAC/B,CAAC,EACF,QAAQ,EAAE,MAAM,GACd,OAAO,CAAC,IAAI,CAAC;IAsDhB;;OAEG;IACH,wBAAwB,IAAI,MAAM,EAAE;IAIpC;;;;OAIG;IACH,2BAA2B,IAAI,MAAM,EAAE;IAgCvC;;;;OAIG;IACG,SAAS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