@alfe.ai/integrations 0.2.1 → 0.2.2
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 +25 -18
- package/dist/index.js +63 -38
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -913,9 +913,11 @@ declare class HermesApplier implements RuntimeApplier {
|
|
|
913
913
|
readonly runtime = "hermes";
|
|
914
914
|
private home;
|
|
915
915
|
private trackingPath;
|
|
916
|
+
/** `~/.hermes/config.yaml` — read-merge-written on removal (no `config unset`). */
|
|
917
|
+
private configYamlPath;
|
|
916
918
|
private configSetRetries;
|
|
917
919
|
private configSetRetryDelayMs;
|
|
918
|
-
/** Serializes all `
|
|
920
|
+
/** Serializes all config mutations (CLI `set` + config.yaml delete) so they never interleave. */
|
|
919
921
|
private configSetQueue;
|
|
920
922
|
constructor(options?: HermesApplierOptions);
|
|
921
923
|
/**
|
|
@@ -929,8 +931,9 @@ declare class HermesApplier implements RuntimeApplier {
|
|
|
929
931
|
/**
|
|
930
932
|
* Remove config previously applied by an integration.
|
|
931
933
|
*
|
|
932
|
-
* Reads the tracking file to find which keys this integration set, then
|
|
933
|
-
*
|
|
934
|
+
* Reads the tracking file to find which dotted keys this integration set, then
|
|
935
|
+
* DELETES each from `~/.hermes/config.yaml` via a read-merge-write (there is no
|
|
936
|
+
* `hermes config unset` verb — see the file header). Clears the tracking entry.
|
|
934
937
|
*/
|
|
935
938
|
removeConfig(integrationId: string): Promise<void>;
|
|
936
939
|
/**
|
|
@@ -967,21 +970,25 @@ declare class HermesApplier implements RuntimeApplier {
|
|
|
967
970
|
/** Convenience: `hermes config set <args>`, serialized + retried. */
|
|
968
971
|
private runConfigSet;
|
|
969
972
|
/**
|
|
970
|
-
*
|
|
971
|
-
*
|
|
972
|
-
*
|
|
973
|
-
*
|
|
974
|
-
*
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
*
|
|
973
|
+
* Delete a set of dotted config keys from `~/.hermes/config.yaml`. There is no
|
|
974
|
+
* `hermes config unset` verb (see file header), so removal is a read-merge-write
|
|
975
|
+
* of the YAML via the Document API — preserving user-authored keys, comments,
|
|
976
|
+
* and formatting. Serialized against every other config mutation on the same
|
|
977
|
+
* queue so a delete can't interleave with an in-flight `hermes config set`.
|
|
978
|
+
*/
|
|
979
|
+
private deleteConfigKeys;
|
|
980
|
+
/**
|
|
981
|
+
* Synchronous config.yaml read-merge-write: parse the doc, delete each dotted
|
|
982
|
+
* key (`model.base_url` → `deleteIn(['model','base_url'])`), and write back only
|
|
983
|
+
* if the text actually changed. No-op if config.yaml doesn't exist yet.
|
|
984
|
+
*/
|
|
985
|
+
private deleteConfigKeysSync;
|
|
986
|
+
/**
|
|
987
|
+
* Run `hermes config <args>` (only `set` is used — removal goes via
|
|
988
|
+
* {@link deleteConfigKeys}), serialized against every other config mutation and
|
|
989
|
+
* retried with backoff. Throws an Error whose (scrubbed) message includes stderr
|
|
990
|
+
* after retries are exhausted, so the real cause propagates to the integration
|
|
991
|
+
* errorMessage without leaking the value.
|
|
985
992
|
*/
|
|
986
993
|
private runConfigCommand;
|
|
987
994
|
private readTracking;
|
package/dist/index.js
CHANGED
|
@@ -2193,11 +2193,17 @@ var OpenClawApplier = class {
|
|
|
2193
2193
|
* HermesApplier — applies integration config (and, later, native plugins) to
|
|
2194
2194
|
* the Hermes runtime (Nous Research's Python agent).
|
|
2195
2195
|
*
|
|
2196
|
-
* Hermes config lives in `~/.hermes/config.yaml` (YAML)
|
|
2197
|
-
* `hermes config set
|
|
2198
|
-
*
|
|
2199
|
-
*
|
|
2200
|
-
*
|
|
2196
|
+
* Hermes config lives in `~/.hermes/config.yaml` (YAML). We APPLY config via the
|
|
2197
|
+
* `hermes config set <dotted.key> <value>` CLI (letting the runtime own its
|
|
2198
|
+
* write path, mirroring the OpenClaw rule). REMOVAL is different: `hermes config
|
|
2199
|
+
* unset` does NOT exist — CONFIRMED against Hermes source, whose `config`
|
|
2200
|
+
* subcommands are only show/set/edit/path/env-path/check/migrate. So teardown is
|
|
2201
|
+
* a config.yaml read-merge-write that deletes the Alfe-applied dotted keys via
|
|
2202
|
+
* the `yaml` Document API (`parseDocument` + `deleteIn`), preserving
|
|
2203
|
+
* user-authored keys, comments, and formatting (the same approach
|
|
2204
|
+
* `hermes-mcp-sync.ts` uses for `mcp_servers`). Per-integration contributions are
|
|
2205
|
+
* tracked in a separate file (`~/.hermes/.alfe-integrations.json`) so we know
|
|
2206
|
+
* exactly which keys to delete.
|
|
2201
2207
|
*
|
|
2202
2208
|
* Scope (Phase 1, MCP-first hybrid):
|
|
2203
2209
|
* - config: SUPPORTED — consumes `installs.runtimes.hermes.config` (the AI-proxy
|
|
@@ -2243,9 +2249,9 @@ function stringifyConfigValue(value) {
|
|
|
2243
2249
|
return typeof value === "string" ? value : JSON.stringify(value);
|
|
2244
2250
|
}
|
|
2245
2251
|
/**
|
|
2246
|
-
* Describe a `config set
|
|
2247
|
-
*
|
|
2248
|
-
*
|
|
2252
|
+
* Describe a `config set` target WITHOUT leaking values. The value argument can
|
|
2253
|
+
* be a secret (`model.api_key`), so it must never reach the integration's
|
|
2254
|
+
* user-facing `errorMessage`. Keep only the program + verb + key.
|
|
2249
2255
|
*/
|
|
2250
2256
|
function redactConfigTarget(args) {
|
|
2251
2257
|
return `hermes config ${args.slice(0, 2).join(" ")}`.trim();
|
|
@@ -2270,13 +2276,16 @@ var HermesApplier = class {
|
|
|
2270
2276
|
runtime = "hermes";
|
|
2271
2277
|
home;
|
|
2272
2278
|
trackingPath;
|
|
2279
|
+
/** `~/.hermes/config.yaml` — read-merge-written on removal (no `config unset`). */
|
|
2280
|
+
configYamlPath;
|
|
2273
2281
|
configSetRetries;
|
|
2274
2282
|
configSetRetryDelayMs;
|
|
2275
|
-
/** Serializes all `
|
|
2283
|
+
/** Serializes all config mutations (CLI `set` + config.yaml delete) so they never interleave. */
|
|
2276
2284
|
configSetQueue = Promise.resolve();
|
|
2277
2285
|
constructor(options = {}) {
|
|
2278
2286
|
this.home = options.home ?? options.workspace ?? DEFAULT_HERMES_HOME$1;
|
|
2279
2287
|
this.trackingPath = options.configPath ?? join(this.home, ".alfe-integrations.json");
|
|
2288
|
+
this.configYamlPath = join(this.home, "config.yaml");
|
|
2280
2289
|
this.configSetRetries = options.configSetRetries ?? CONFIG_SET_RETRIES;
|
|
2281
2290
|
this.configSetRetryDelayMs = options.configSetRetryDelayMs ?? CONFIG_SET_RETRY_DELAY_MS;
|
|
2282
2291
|
}
|
|
@@ -2311,8 +2320,9 @@ var HermesApplier = class {
|
|
|
2311
2320
|
/**
|
|
2312
2321
|
* Remove config previously applied by an integration.
|
|
2313
2322
|
*
|
|
2314
|
-
* Reads the tracking file to find which keys this integration set, then
|
|
2315
|
-
*
|
|
2323
|
+
* Reads the tracking file to find which dotted keys this integration set, then
|
|
2324
|
+
* DELETES each from `~/.hermes/config.yaml` via a read-merge-write (there is no
|
|
2325
|
+
* `hermes config unset` verb — see the file header). Clears the tracking entry.
|
|
2316
2326
|
*/
|
|
2317
2327
|
async removeConfig(integrationId) {
|
|
2318
2328
|
const tracking = this.readTracking();
|
|
@@ -2320,13 +2330,13 @@ var HermesApplier = class {
|
|
|
2320
2330
|
if (!(integrationId in integrations)) return;
|
|
2321
2331
|
const integrationConfig = integrations[integrationId];
|
|
2322
2332
|
const { leaves } = partitionEntries(flattenConfig(integrationConfig));
|
|
2323
|
-
|
|
2324
|
-
await this.
|
|
2333
|
+
try {
|
|
2334
|
+
await this.deleteConfigKeys(leaves.map(({ path }) => path));
|
|
2325
2335
|
} catch (err) {
|
|
2326
2336
|
log$2.warn({
|
|
2327
2337
|
err: err instanceof Error ? err.message : String(err),
|
|
2328
|
-
|
|
2329
|
-
}, "Failed to
|
|
2338
|
+
integrationId
|
|
2339
|
+
}, "Failed to delete Alfe config keys from ~/.hermes/config.yaml");
|
|
2330
2340
|
}
|
|
2331
2341
|
tracking._integrations = Object.fromEntries(Object.entries(integrations).filter(([key]) => key !== integrationId));
|
|
2332
2342
|
this.writeTracking(tracking);
|
|
@@ -2410,23 +2420,40 @@ var HermesApplier = class {
|
|
|
2410
2420
|
return this.runConfigCommand(["set", ...setArgs]);
|
|
2411
2421
|
}
|
|
2412
2422
|
/**
|
|
2413
|
-
*
|
|
2414
|
-
*
|
|
2415
|
-
*
|
|
2416
|
-
*
|
|
2417
|
-
*
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2423
|
+
* Delete a set of dotted config keys from `~/.hermes/config.yaml`. There is no
|
|
2424
|
+
* `hermes config unset` verb (see file header), so removal is a read-merge-write
|
|
2425
|
+
* of the YAML via the Document API — preserving user-authored keys, comments,
|
|
2426
|
+
* and formatting. Serialized against every other config mutation on the same
|
|
2427
|
+
* queue so a delete can't interleave with an in-flight `hermes config set`.
|
|
2428
|
+
*/
|
|
2429
|
+
deleteConfigKeys(paths) {
|
|
2430
|
+
const run = () => {
|
|
2431
|
+
this.deleteConfigKeysSync(paths);
|
|
2432
|
+
return Promise.resolve();
|
|
2433
|
+
};
|
|
2434
|
+
const result = this.configSetQueue.then(run, run);
|
|
2435
|
+
this.configSetQueue = result.catch(() => void 0);
|
|
2436
|
+
return result;
|
|
2437
|
+
}
|
|
2438
|
+
/**
|
|
2439
|
+
* Synchronous config.yaml read-merge-write: parse the doc, delete each dotted
|
|
2440
|
+
* key (`model.base_url` → `deleteIn(['model','base_url'])`), and write back only
|
|
2441
|
+
* if the text actually changed. No-op if config.yaml doesn't exist yet.
|
|
2421
2442
|
*/
|
|
2422
|
-
|
|
2423
|
-
|
|
2443
|
+
deleteConfigKeysSync(paths) {
|
|
2444
|
+
if (paths.length === 0 || !existsSync(this.configYamlPath)) return;
|
|
2445
|
+
const doc = parseDocument(readFileSync(this.configYamlPath, "utf-8"));
|
|
2446
|
+
const before = doc.toString();
|
|
2447
|
+
for (const path of paths) doc.deleteIn(path.split("."));
|
|
2448
|
+
const after = doc.toString();
|
|
2449
|
+
if (before !== after) writeFileSync(this.configYamlPath, after, "utf-8");
|
|
2424
2450
|
}
|
|
2425
2451
|
/**
|
|
2426
|
-
* Run `hermes config <args>` (set
|
|
2427
|
-
*
|
|
2428
|
-
*
|
|
2429
|
-
*
|
|
2452
|
+
* Run `hermes config <args>` (only `set` is used — removal goes via
|
|
2453
|
+
* {@link deleteConfigKeys}), serialized against every other config mutation and
|
|
2454
|
+
* retried with backoff. Throws an Error whose (scrubbed) message includes stderr
|
|
2455
|
+
* after retries are exhausted, so the real cause propagates to the integration
|
|
2456
|
+
* errorMessage without leaking the value.
|
|
2430
2457
|
*/
|
|
2431
2458
|
runConfigCommand(args) {
|
|
2432
2459
|
const run = async () => {
|
|
@@ -2502,15 +2529,13 @@ var HermesApplier = class {
|
|
|
2502
2529
|
const log$1 = createLogger("HermesMcpSync");
|
|
2503
2530
|
const DEFAULT_HERMES_HOME = join(homedir(), ".hermes");
|
|
2504
2531
|
/**
|
|
2505
|
-
*
|
|
2506
|
-
*
|
|
2507
|
-
*
|
|
2508
|
-
*
|
|
2509
|
-
*
|
|
2510
|
-
*
|
|
2511
|
-
*
|
|
2512
|
-
* into each `mcp_servers.<id>.env` and skip the `.env` file entirely — change
|
|
2513
|
-
* `withAlfeApiKey()` + `ensureEnvApiKey()` together in that one case.
|
|
2532
|
+
* SEAM #1 — `${VAR}` interpolation from `~/.hermes/.env`. CONFIRMED (Hermes
|
|
2533
|
+
* source `config.py:5790` `_expand_env_vars`): Hermes loads `~/.hermes/.env` via
|
|
2534
|
+
* dotenv into `os.environ`, then recursively expands `${VAR}` refs across the
|
|
2535
|
+
* ENTIRE merged config — including `mcp_servers.<id>.env.*` (and `model.api_key`
|
|
2536
|
+
* / `model.base_url`). So injecting `ALFE_API_KEY=${ALFE_API_KEY}` into every
|
|
2537
|
+
* Alfe-owned stdio server's env and writing the real value to `~/.hermes/.env`
|
|
2538
|
+
* resolves at spawn time. The inline-literal fallback is therefore not needed.
|
|
2514
2539
|
*/
|
|
2515
2540
|
const ALFE_API_KEY_ENV_REF = "${ALFE_API_KEY}";
|
|
2516
2541
|
const DEFAULT_DEBOUNCE_MS = 250;
|
package/package.json
CHANGED