@jiggai/recipes 0.4.69 → 0.4.70
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/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/lib/recipes-config.ts +26 -11
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
|
@@ -2,34 +2,49 @@ import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
|
2
2
|
import { upsertAgentInConfig, type AgentConfigSnippet } from "./agent-config";
|
|
3
3
|
import { stableStringify } from "./stable-stringify";
|
|
4
4
|
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Runtime API shape for config access. Mirrors the modern surface
|
|
7
|
+
* (`current` + `replaceConfigFile`) so we don't trigger the
|
|
8
|
+
* `runtime-config-load-write` deprecation warning that the legacy
|
|
9
|
+
* `loadConfig` / `writeConfigFile` helpers emit.
|
|
10
|
+
*/
|
|
6
11
|
interface OpenClawRuntimeConfig {
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
current?: () => unknown;
|
|
13
|
+
replaceConfigFile?: (params: {
|
|
14
|
+
nextConfig: unknown;
|
|
15
|
+
afterWrite: { mode: "auto" } | { mode: "restart"; reason: string } | { mode: "none"; reason: string };
|
|
16
|
+
}) => Promise<unknown>;
|
|
9
17
|
}
|
|
10
18
|
|
|
11
19
|
/**
|
|
12
20
|
* Load OpenClaw config via runtime API.
|
|
21
|
+
* Returns a deep clone of the runtime snapshot so callers may mutate it
|
|
22
|
+
* before persisting via {@link writeOpenClawConfig}; the runtime's own
|
|
23
|
+
* snapshot from `current()` is `DeepReadonly` and must not be mutated.
|
|
13
24
|
* @param api - OpenClaw plugin API
|
|
14
|
-
* @returns Config object (mutable)
|
|
15
|
-
* @throws If
|
|
25
|
+
* @returns Config object (mutable copy)
|
|
26
|
+
* @throws If the runtime config API is unavailable
|
|
16
27
|
*/
|
|
17
28
|
export async function loadOpenClawConfig(api: OpenClawPluginApi): Promise<Record<string, unknown>> {
|
|
18
29
|
const runtime = api.runtime as { config?: OpenClawRuntimeConfig };
|
|
19
|
-
const
|
|
20
|
-
if (!
|
|
21
|
-
|
|
22
|
-
return cfgObj as Record<string, unknown>;
|
|
30
|
+
const snapshot = runtime.config?.current?.();
|
|
31
|
+
if (!snapshot) throw new Error("Failed to load config via api.runtime.config.current()");
|
|
32
|
+
return JSON.parse(JSON.stringify(snapshot)) as Record<string, unknown>;
|
|
23
33
|
}
|
|
24
34
|
|
|
25
35
|
/**
|
|
26
|
-
*
|
|
36
|
+
* Persist a full OpenClaw config replacement via the runtime API.
|
|
37
|
+
* Uses `afterWrite: { mode: "auto" }` to let the gateway choose between
|
|
38
|
+
* hot-reload and restart, matching the legacy `writeConfigFile` default.
|
|
27
39
|
* @param api - OpenClaw plugin API
|
|
28
40
|
* @param cfgObj - Config object to write
|
|
29
41
|
*/
|
|
30
42
|
export async function writeOpenClawConfig(api: OpenClawPluginApi, cfgObj: Record<string, unknown>): Promise<void> {
|
|
31
43
|
const runtime = api.runtime as { config?: OpenClawRuntimeConfig };
|
|
32
|
-
await runtime.config?.
|
|
44
|
+
await runtime.config?.replaceConfigFile?.({
|
|
45
|
+
nextConfig: cfgObj,
|
|
46
|
+
afterWrite: { mode: "auto" },
|
|
47
|
+
});
|
|
33
48
|
}
|
|
34
49
|
|
|
35
50
|
export type BindingMatch = {
|