@karmaniverous/jeeves 0.1.3 → 0.1.5

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/dist/index.d.ts CHANGED
@@ -183,6 +183,53 @@ interface CreateComponentWriterOptions {
183
183
  */
184
184
  declare function createComponentWriter(component: JeevesComponent, options?: CreateComponentWriterOptions): ComponentWriter;
185
185
 
186
+ /**
187
+ * Resolve the OpenClaw workspace root from the plugin API.
188
+ *
189
+ * @remarks
190
+ * Tries three sources in order:
191
+ * 1. `api.config.agents.defaults.workspace` — explicit config (most authoritative)
192
+ * 2. `api.resolvePath('.')` — gateway-provided path resolver
193
+ * 3. `process.cwd()` — last resort (unsafe when gateway runs from system32)
194
+ *
195
+ * The config value is checked first because `api.resolvePath('.')` delegates
196
+ * to `path.resolve('.')`, which returns `process.cwd()` — not the workspace.
197
+ * When the gateway runs as a Windows service from `C:\Windows\system32`,
198
+ * `resolvePath('.')` returns system32, not the configured workspace.
199
+ *
200
+ * Plugins should call this once at registration time and pass the result
201
+ * to `init({ workspacePath })`.
202
+ */
203
+ /**
204
+ * Minimal shape of the OpenClaw plugin API needed for workspace resolution.
205
+ *
206
+ * @remarks
207
+ * Intentionally loose — plugins define their own full `PluginApi` type.
208
+ * This captures only the fields `resolveWorkspacePath` inspects.
209
+ */
210
+ interface PluginApiLike {
211
+ /** Gateway-provided path resolver. May not exist in all gateway versions. */
212
+ resolvePath?: (input: string) => string;
213
+ /** OpenClaw configuration object. */
214
+ config?: {
215
+ /** Agent configuration block. */
216
+ agents?: {
217
+ /** Default agent settings. */
218
+ defaults?: {
219
+ /** Absolute path to the workspace root directory. */
220
+ workspace?: string;
221
+ };
222
+ };
223
+ };
224
+ }
225
+ /**
226
+ * Resolve the workspace root from the OpenClaw plugin API.
227
+ *
228
+ * @param api - The plugin API object provided by the gateway at registration.
229
+ * @returns Absolute path to the workspace root.
230
+ */
231
+ declare function resolveWorkspacePath(api: PluginApiLike): string;
232
+
186
233
  /**
187
234
  * Comment markers for managed content blocks.
188
235
  *
@@ -726,5 +773,5 @@ interface SeedContentOptions {
726
773
  */
727
774
  declare function seedContent(options: SeedContentOptions): Promise<void>;
728
775
 
729
- export { AGENTS_MARKERS, CLEANUP_FLAG, COMPONENT_CONFIG_PREFIX, CONFIG_FILE, CORE_CONFIG_DIR, CORE_VERSION, ComponentWriter, DEFAULT_PORTS, META_PORT, REGISTRY_CACHE_FILE, RUNNER_PORT, SECTION_IDS, SECTION_ORDER, SERVER_PORT, SOUL_MARKERS, STALENESS_THRESHOLD_MS, TEMPLATES_DIR, TOOLS_MARKERS, VERSION_STAMP_PATTERN, WATCHER_PORT, WORKSPACE_FILES, checkRegistryVersion, coreConfigSchema, createAsyncContentCache, createComponentWriter, formatBeginMarker, formatEndMarker, generateJsonSchema, getComponentConfigDir, getConfigRoot, getCoreConfigDir, getCoreConfigFile, getServiceUrl, getWorkspacePath, init, jaccard, needsCleanup, parseManaged, probeAllServices, probeService, refreshPlatformContent, resetInit, seedContent, shingles, shouldWrite, updateManagedSection };
730
- export type { AsyncContentCacheOptions, CoreConfig, CreateComponentWriterOptions, InitOptions, JeevesComponent, ManagedSection, ParseManagedResult, PluginCommands, ProbeResult, RefreshPlatformContentOptions, SectionId, SeedContentOptions, ServiceCommands, ServiceStatus, UpdateManagedSectionOptions, VersionStamp };
776
+ export { AGENTS_MARKERS, CLEANUP_FLAG, COMPONENT_CONFIG_PREFIX, CONFIG_FILE, CORE_CONFIG_DIR, CORE_VERSION, ComponentWriter, DEFAULT_PORTS, META_PORT, REGISTRY_CACHE_FILE, RUNNER_PORT, SECTION_IDS, SECTION_ORDER, SERVER_PORT, SOUL_MARKERS, STALENESS_THRESHOLD_MS, TEMPLATES_DIR, TOOLS_MARKERS, VERSION_STAMP_PATTERN, WATCHER_PORT, WORKSPACE_FILES, checkRegistryVersion, coreConfigSchema, createAsyncContentCache, createComponentWriter, formatBeginMarker, formatEndMarker, generateJsonSchema, getComponentConfigDir, getConfigRoot, getCoreConfigDir, getCoreConfigFile, getServiceUrl, getWorkspacePath, init, jaccard, needsCleanup, parseManaged, probeAllServices, probeService, refreshPlatformContent, resetInit, resolveWorkspacePath, seedContent, shingles, shouldWrite, updateManagedSection };
777
+ export type { AsyncContentCacheOptions, CoreConfig, CreateComponentWriterOptions, InitOptions, JeevesComponent, ManagedSection, ParseManagedResult, PluginApiLike, PluginCommands, ProbeResult, RefreshPlatformContentOptions, SectionId, SeedContentOptions, ServiceCommands, ServiceStatus, UpdateManagedSectionOptions, VersionStamp };
package/dist/index.js CHANGED
@@ -1606,6 +1606,43 @@ function createComponentWriter(component, options) {
1606
1606
  return new ComponentWriter(component, options?.probeTimeoutMs);
1607
1607
  }
1608
1608
 
1609
+ /**
1610
+ * Resolve the OpenClaw workspace root from the plugin API.
1611
+ *
1612
+ * @remarks
1613
+ * Tries three sources in order:
1614
+ * 1. `api.config.agents.defaults.workspace` — explicit config (most authoritative)
1615
+ * 2. `api.resolvePath('.')` — gateway-provided path resolver
1616
+ * 3. `process.cwd()` — last resort (unsafe when gateway runs from system32)
1617
+ *
1618
+ * The config value is checked first because `api.resolvePath('.')` delegates
1619
+ * to `path.resolve('.')`, which returns `process.cwd()` — not the workspace.
1620
+ * When the gateway runs as a Windows service from `C:\Windows\system32`,
1621
+ * `resolvePath('.')` returns system32, not the configured workspace.
1622
+ *
1623
+ * Plugins should call this once at registration time and pass the result
1624
+ * to `init({ workspacePath })`.
1625
+ */
1626
+ /**
1627
+ * Resolve the workspace root from the OpenClaw plugin API.
1628
+ *
1629
+ * @param api - The plugin API object provided by the gateway at registration.
1630
+ * @returns Absolute path to the workspace root.
1631
+ */
1632
+ function resolveWorkspacePath(api) {
1633
+ // 1. Explicit config value (most authoritative)
1634
+ const configured = api.config?.agents?.defaults?.workspace;
1635
+ if (typeof configured === 'string' && configured.trim()) {
1636
+ return configured;
1637
+ }
1638
+ // 2. Gateway-provided path resolver
1639
+ if (typeof api.resolvePath === 'function') {
1640
+ return api.resolvePath('.');
1641
+ }
1642
+ // 3. Last resort — unsafe when gateway runs from system32
1643
+ return process.cwd();
1644
+ }
1645
+
1609
1646
  /**
1610
1647
  * One-shot content seeding used by the CLI install command.
1611
1648
  *
@@ -1659,4 +1696,4 @@ async function seedContent(options) {
1659
1696
  });
1660
1697
  }
1661
1698
 
1662
- export { AGENTS_MARKERS, CLEANUP_FLAG, COMPONENT_CONFIG_PREFIX, CONFIG_FILE, CORE_CONFIG_DIR, CORE_VERSION, ComponentWriter, DEFAULT_PORTS, META_PORT, REGISTRY_CACHE_FILE, RUNNER_PORT, SECTION_IDS, SECTION_ORDER, SERVER_PORT, SOUL_MARKERS, STALENESS_THRESHOLD_MS, TEMPLATES_DIR, TOOLS_MARKERS, VERSION_STAMP_PATTERN, WATCHER_PORT, WORKSPACE_FILES, checkRegistryVersion, coreConfigSchema, createAsyncContentCache, createComponentWriter, formatBeginMarker, formatEndMarker, generateJsonSchema, getComponentConfigDir, getConfigRoot, getCoreConfigDir, getCoreConfigFile, getServiceUrl, getWorkspacePath, init, jaccard, needsCleanup, parseManaged, probeAllServices, probeService, refreshPlatformContent, resetInit, seedContent, shingles, shouldWrite, updateManagedSection };
1699
+ export { AGENTS_MARKERS, CLEANUP_FLAG, COMPONENT_CONFIG_PREFIX, CONFIG_FILE, CORE_CONFIG_DIR, CORE_VERSION, ComponentWriter, DEFAULT_PORTS, META_PORT, REGISTRY_CACHE_FILE, RUNNER_PORT, SECTION_IDS, SECTION_ORDER, SERVER_PORT, SOUL_MARKERS, STALENESS_THRESHOLD_MS, TEMPLATES_DIR, TOOLS_MARKERS, VERSION_STAMP_PATTERN, WATCHER_PORT, WORKSPACE_FILES, checkRegistryVersion, coreConfigSchema, createAsyncContentCache, createComponentWriter, formatBeginMarker, formatEndMarker, generateJsonSchema, getComponentConfigDir, getConfigRoot, getCoreConfigDir, getCoreConfigFile, getServiceUrl, getWorkspacePath, init, jaccard, needsCleanup, parseManaged, probeAllServices, probeService, refreshPlatformContent, resetInit, resolveWorkspacePath, seedContent, shingles, shouldWrite, updateManagedSection };
package/package.json CHANGED
@@ -138,5 +138,5 @@
138
138
  },
139
139
  "type": "module",
140
140
  "types": "dist/index.d.ts",
141
- "version": "0.1.3"
141
+ "version": "0.1.5"
142
142
  }