@signetai/connector-hermes-agent 0.208.2 → 0.209.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/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import { BaseConnector, type InstallResult, type UninstallResult } from "@signetai/connector-base";
2
- import { type HermesTarget } from "@signetai/core";
3
2
  export interface HermesDiagnosticCheck {
4
3
  readonly id: string;
5
4
  readonly label: string;
@@ -7,6 +6,12 @@ export interface HermesDiagnosticCheck {
7
6
  readonly detail: string;
8
7
  readonly fix?: string;
9
8
  }
9
+ export interface HermesConnectorOptions {
10
+ readonly profile?: string;
11
+ readonly agentId?: string;
12
+ readonly memoryPolicy?: "isolated" | "shared" | "group";
13
+ readonly policyGroup?: string;
14
+ }
10
15
  export interface HermesDoctorReport {
11
16
  readonly ok: boolean;
12
17
  readonly hermesHome: string;
@@ -18,41 +23,15 @@ export interface HermesDoctorReport {
18
23
  readonly checks: readonly HermesDiagnosticCheck[];
19
24
  readonly warnings: readonly string[];
20
25
  }
21
- type AgentReadPolicy = "isolated" | "shared" | "group";
22
- export interface AgentRegistrationOptions {
23
- readonly agentId: string;
24
- readonly readPolicy?: AgentReadPolicy;
25
- readonly policyGroup?: string | null;
26
- /** Requested profile provisioning must fail closed instead of warning. */
27
- readonly strict?: boolean;
28
- }
29
- export type AgentRegistrationResult = {
30
- readonly ok: true;
31
- readonly created: boolean;
32
- readonly agentId: string;
33
- } | {
34
- readonly ok: false;
35
- readonly agentId: string;
36
- readonly error: string;
37
- };
38
- export declare function ensureNamedAgentRegistered(daemonUrl: string, agentIdOrOptions: string | AgentRegistrationOptions, warnings: string[]): Promise<AgentRegistrationResult>;
39
- export interface HermesConnectorOptions {
40
- readonly target?: HermesTarget;
41
- readonly agentId?: string;
42
- readonly readPolicy?: AgentReadPolicy;
43
- readonly policyGroup?: string | null;
44
- }
45
26
  export declare class HermesAgentConnector extends BaseConnector {
46
27
  readonly name = "Hermes Agent";
47
28
  readonly harnessId = "hermes-agent";
48
- private readonly target?;
49
- private readonly registration?;
50
- constructor(options?: HermesTarget | HermesConnectorOptions);
29
+ private targetOptions;
51
30
  private getHermesHome;
52
31
  private getHermesRepo;
53
32
  getConfigPath(): string;
54
- install(basePath: string): Promise<InstallResult>;
55
- uninstall(): Promise<UninstallResult>;
33
+ install(basePath: string, options?: HermesConnectorOptions): Promise<InstallResult>;
34
+ uninstall(options?: HermesConnectorOptions): Promise<UninstallResult>;
56
35
  isInstalled(): boolean;
57
36
  diagnose(): Promise<HermesDoctorReport>;
58
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAuB,MAAM,wBAAwB,CAAC;AACtH,OAAO,EAA4D,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAmD3G,MAAM,WAAW,qBAAqB;IACrC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,EAAE,EAAE,OAAO,CAAC;IACrB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,QAAQ,CAAC,SAAS,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAA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AC;IAC7B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC5B,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAuG9B;AAED,wBAAgB,eAAe,IAAI,oBAAoB,CAEtD;AAED,eAAe,oBAAoB,CAAC"}
package/dist/index.js CHANGED
@@ -34505,13 +34505,6 @@ function resolveContainedWritePath(targetPath, targetRoot) {
34505
34505
  if (realpathSync3(rootPath) !== rootPath) {
34506
34506
  throw new Error(`Hermes target root is symlinked and cannot be used for writes: ${targetRoot}`);
34507
34507
  }
34508
- rootPath = targetRoot;
34509
- while (!existsSync2(rootPath)) {
34510
- const parent = dirname6(rootPath);
34511
- if (parent === rootPath)
34512
- throw new Error(`Hermes target root does not exist: ${targetRoot}`);
34513
- rootPath = parent;
34514
- }
34515
34508
  const root = realpathSync3(rootPath);
34516
34509
  let existing = targetPath;
34517
34510
  const missing = [];
@@ -34529,9 +34522,6 @@ function resolveContainedWritePath(targetPath, targetRoot) {
34529
34522
  }
34530
34523
  return candidate;
34531
34524
  }
34532
- function assertContainedTargetPath(targetPath, targetRoot) {
34533
- resolveContainedWritePath(targetPath, targetRoot);
34534
- }
34535
34525
  function getRepoPluginTargetDir(hermesRepo) {
34536
34526
  return join4(hermesRepo, "plugins", "memory", "signet");
34537
34527
  }
@@ -34548,7 +34538,7 @@ function installPlugin(targetDir, targetKind, targetRoot) {
34548
34538
  const written = [];
34549
34539
  for (const file of PLUGIN_FILES) {
34550
34540
  const src = join4(sourceDir, file);
34551
- const dst = join4(writeDir, file);
34541
+ const dst = targetRoot ? resolveContainedWritePath(join4(writeDir, file), targetRoot) : join4(writeDir, file);
34552
34542
  if (existsSync2(src)) {
34553
34543
  writeFileSync2(dst, readFileSync2(src));
34554
34544
  written.push(dst);
@@ -34567,18 +34557,20 @@ function uninstallPlugin(targetDir, targetRoot) {
34567
34557
  rmSync(safeTargetDir, { recursive: true, force: true });
34568
34558
  return [targetDir];
34569
34559
  }
34570
- function getConfigCandidates(hermesHome) {
34571
- return [join4(hermesHome, "config.yaml"), join4(hermesHome, "cli-config.yaml")];
34560
+ function getConfigCandidates(hermesHome, targetRoot) {
34561
+ const candidates = [join4(hermesHome, "config.yaml"), join4(hermesHome, "cli-config.yaml")];
34562
+ return targetRoot ? candidates.map((candidate) => resolveContainedWritePath(candidate, targetRoot)) : candidates;
34572
34563
  }
34573
- function resolveConfigPath(hermesHome) {
34574
- for (const candidate of getConfigCandidates(hermesHome)) {
34564
+ function resolveConfigPath(hermesHome, targetRoot) {
34565
+ for (const candidate of getConfigCandidates(hermesHome, targetRoot)) {
34575
34566
  if (existsSync2(candidate))
34576
34567
  return candidate;
34577
34568
  }
34578
- return join4(hermesHome, "config.yaml");
34569
+ const fallback = join4(hermesHome, "config.yaml");
34570
+ return targetRoot ? resolveContainedWritePath(fallback, targetRoot) : fallback;
34579
34571
  }
34580
- function readConfigYaml(hermesHome) {
34581
- const configPath = resolveConfigPath(hermesHome);
34572
+ function readConfigYaml(hermesHome, targetRoot) {
34573
+ const configPath = resolveConfigPath(hermesHome, targetRoot);
34582
34574
  if (!existsSync2(configPath))
34583
34575
  return null;
34584
34576
  try {
@@ -34684,10 +34676,10 @@ function parseDottedProviderLine(line) {
34684
34676
  function setDottedProviderLine(lines, line, value) {
34685
34677
  lines[line] = `memory.provider: ${value}`;
34686
34678
  }
34687
- function writeProviderBackup(hermesHome, targetRoot, configPath, providerKind, previousProvider) {
34679
+ function writeProviderBackup(hermesHome, configPath, providerKind, previousProvider) {
34688
34680
  if (previousProvider === "signet")
34689
34681
  return null;
34690
- const backupPath = resolveContainedWritePath(getProviderBackupPath(hermesHome), targetRoot);
34682
+ const backupPath = getProviderBackupPath(hermesHome);
34691
34683
  if (existsSync2(backupPath))
34692
34684
  return null;
34693
34685
  const backup = {
@@ -34744,8 +34736,8 @@ function isProviderConfigured(hermesHome) {
34744
34736
  }
34745
34737
  return false;
34746
34738
  }
34747
- function configureProvider(hermesHome, warnings, targetRoot = hermesHome) {
34748
- const configPath = resolveContainedWritePath(resolveConfigPath(hermesHome), targetRoot);
34739
+ function configureProvider(hermesHome, warnings, targetRoot) {
34740
+ const configPath = resolveConfigPath(hermesHome, targetRoot);
34749
34741
  let content = "";
34750
34742
  if (existsSync2(configPath)) {
34751
34743
  try {
@@ -34766,13 +34758,13 @@ function configureProvider(hermesHome, warnings, targetRoot = hermesHome) {
34766
34758
  let changed = false;
34767
34759
  const dottedWasSignet = dottedProviderLineIsSignet(lines[dottedProvider] ?? "");
34768
34760
  if (!dottedWasSignet) {
34769
- backupPath = writeProviderBackup(hermesHome, targetRoot, configPath, "dotted", parseDottedProviderLine(lines[dottedProvider] ?? "") ?? "");
34761
+ backupPath = writeProviderBackup(hermesHome, configPath, "dotted", parseDottedProviderLine(lines[dottedProvider] ?? "") ?? "");
34770
34762
  setDottedProviderLine(lines, dottedProvider, "signet");
34771
34763
  changed = true;
34772
34764
  }
34773
34765
  if (block !== null && typeof block === "object" && block.provider !== null && block.provider !== undefined) {
34774
34766
  if (dottedWasSignet) {
34775
- const nestedBackupPath = writeProviderBackup(hermesHome, targetRoot, configPath, "nested", parseProviderLine(lines[block.provider] ?? "") ?? "");
34767
+ const nestedBackupPath = writeProviderBackup(hermesHome, configPath, "nested", parseProviderLine(lines[block.provider] ?? "") ?? "");
34776
34768
  backupPath = nestedBackupPath ?? backupPath;
34777
34769
  }
34778
34770
  lines.splice(block.provider, 1);
@@ -34793,7 +34785,7 @@ function configureProvider(hermesHome, warnings, targetRoot = hermesHome) {
34793
34785
  if (block !== null && typeof block === "object" && block.provider !== null && block.provider !== undefined) {
34794
34786
  if (providerLineIsSignet(lines[block.provider] ?? ""))
34795
34787
  return { configPath: null, backupPath: null };
34796
- backupPath = writeProviderBackup(hermesHome, targetRoot, configPath, "nested", parseProviderLine(lines[block.provider] ?? "") ?? "");
34788
+ backupPath = writeProviderBackup(hermesHome, configPath, "nested", parseProviderLine(lines[block.provider] ?? "") ?? "");
34797
34789
  lines[block.provider] = `${(lines[block.provider] ?? "").match(/^\s*/)?.[0] ?? " "}provider: signet`;
34798
34790
  } else if (block !== null && typeof block === "object") {
34799
34791
  lines.splice(block.start + 1, 0, `${" ".repeat(block.indent)}provider: signet`);
@@ -34813,7 +34805,8 @@ function restoreOrClearProvider(hermesHome, targetRoot) {
34813
34805
  const config = readConfigYaml(hermesHome);
34814
34806
  if (!config)
34815
34807
  return { configPath: null, backupPath: removeProviderBackup(hermesHome, targetRoot) };
34816
- resolveContainedWritePath(config.path, targetRoot ?? hermesHome);
34808
+ if (targetRoot)
34809
+ resolveContainedWritePath(config.path, targetRoot);
34817
34810
  const lines = config.content.replace(/\r\n/g, `
34818
34811
  `).split(`
34819
34812
  `);
@@ -35007,16 +35000,15 @@ function trustedOriginForDaemonUrl(daemonUrl) {
35007
35000
  return null;
35008
35001
  }
35009
35002
  }
35010
- function configuredAgentReadPolicy(warnings, strict = false) {
35003
+ function configuredAgentReadPolicy(warnings, options = {}) {
35004
+ if (options.memoryPolicy)
35005
+ return options.memoryPolicy;
35011
35006
  const raw = sanitizedEnv("SIGNET_AGENT_READ_POLICY") || sanitizedEnv("SIGNET_AGENT_MEMORY_POLICY");
35012
35007
  if (!raw)
35013
35008
  return "shared";
35014
35009
  if (raw === "isolated" || raw === "shared" || raw === "group")
35015
35010
  return raw;
35016
- const error = `Unsupported SIGNET_AGENT_READ_POLICY '${raw}'. Expected one of: isolated, shared, group.`;
35017
- if (strict)
35018
- return null;
35019
- warnings.push(`Ignoring ${error}`);
35011
+ warnings.push(`Ignoring unsupported SIGNET_AGENT_READ_POLICY '${raw}'. Expected one of: isolated, shared, group.`);
35020
35012
  return "shared";
35021
35013
  }
35022
35014
  async function resolveDaemonAgentId(daemonUrl) {
@@ -35040,20 +35032,11 @@ async function resolveDaemonAgentId(daemonUrl) {
35040
35032
  return null;
35041
35033
  }
35042
35034
  }
35043
- async function ensureNamedAgentRegistered(daemonUrl, agentIdOrOptions, warnings) {
35044
- const options = typeof agentIdOrOptions === "string" ? { agentId: agentIdOrOptions } : agentIdOrOptions;
35045
- const { agentId } = options;
35046
- const strict = options.strict === true;
35047
- const fail = (error) => {
35048
- if (!strict)
35049
- warnings.push(error);
35050
- return { ok: false, agentId, error };
35051
- };
35052
- if (!agentId || agentId === "default" || agentId === "hermes-agent") {
35053
- return { ok: true, created: false, agentId };
35054
- }
35035
+ async function ensureNamedAgentRegistered(daemonUrl, agentId, warnings, options = {}) {
35036
+ if (!agentId || agentId === "default" || agentId === "hermes-agent")
35037
+ return null;
35055
35038
  if (process.env.SIGNET_SKIP_AGENT_REGISTER === "1")
35056
- return { ok: true, created: false, agentId };
35039
+ return null;
35057
35040
  const baseUrl = trimTrailingSlashes(daemonUrl);
35058
35041
  const token = sanitizedAuthTokenEnv();
35059
35042
  const headers = {};
@@ -35066,27 +35049,19 @@ async function ensureNamedAgentRegistered(daemonUrl, agentIdOrOptions, warnings)
35066
35049
  signal: AbortSignal.timeout(1000)
35067
35050
  });
35068
35051
  if (getResp.ok)
35069
- return { ok: true, created: false, agentId };
35052
+ return null;
35070
35053
  if (getResp.status !== 404) {
35071
35054
  const body = await getResp.text();
35072
- return fail(`Could not check Signet agent '${agentId}' before registration: HTTP ${getResp.status} ${body.slice(0, 200)}`);
35073
- }
35074
- } catch (e) {
35075
- if (strict) {
35076
- const msg = e instanceof Error ? e.message : String(e);
35077
- return fail(`Could not check Signet agent '${agentId}' because the daemon was unreachable. (${msg})`);
35055
+ warnings.push(`Could not check Signet agent '${agentId}' before registration: HTTP ${getResp.status} ${body.slice(0, 200)}`);
35056
+ return null;
35078
35057
  }
35079
- }
35080
- const readPolicy = options.readPolicy ?? configuredAgentReadPolicy(warnings, strict);
35081
- if (readPolicy === null)
35082
- return fail(`Could not register Signet agent '${agentId}' because its read policy is invalid.`);
35083
- const policyGroup = options.policyGroup !== undefined ? options.policyGroup : readPolicy === "group" ? sanitizedEnv("SIGNET_AGENT_POLICY_GROUP") || null : null;
35058
+ } catch {}
35059
+ const readPolicy = configuredAgentReadPolicy(warnings, options);
35060
+ const policyGroup = readPolicy === "group" ? options.policyGroup?.trim() || sanitizedEnv("SIGNET_AGENT_POLICY_GROUP") || null : null;
35084
35061
  if (readPolicy === "group" && !policyGroup) {
35085
- if (strict)
35086
- return fail(`Agent '${agentId}' requested group policy but no policy group was provided.`);
35087
- warnings.push(`SIGNET_AGENT_READ_POLICY=group requires SIGNET_AGENT_POLICY_GROUP. Registering '${agentId}' with isolated memory instead.`);
35062
+ return `Group memory policy for '${agentId}' requires --group or SIGNET_AGENT_POLICY_GROUP.`;
35088
35063
  }
35089
- const effectiveReadPolicy = readPolicy === "group" && !policyGroup ? "isolated" : readPolicy;
35064
+ const effectiveReadPolicy = readPolicy;
35090
35065
  const policyHint = effectiveReadPolicy === "shared" ? `Run: signet agent create ${agentId} --memory shared, or use --memory isolated for private memory.` : `Run: signet agent create ${agentId} --memory ${effectiveReadPolicy}.`;
35091
35066
  try {
35092
35067
  const resp = await fetch(`${baseUrl}/api/agents`, {
@@ -35101,64 +35076,54 @@ async function ensureNamedAgentRegistered(daemonUrl, agentIdOrOptions, warnings)
35101
35076
  });
35102
35077
  if (!resp.ok) {
35103
35078
  const body = await resp.text();
35104
- return fail(`Could not register Signet agent '${agentId}' with ${effectiveReadPolicy} memory policy: ${body.slice(0, 200)}. ${policyHint}`);
35079
+ return `Could not register Signet agent '${agentId}' with ${effectiveReadPolicy} memory policy: ${body.slice(0, 200)}. ${policyHint}`;
35105
35080
  }
35106
- return { ok: true, created: true, agentId };
35107
35081
  } catch (e) {
35108
35082
  const msg = e instanceof Error ? e.message : String(e);
35109
- return fail(`Could not register Signet agent '${agentId}' because the daemon was unreachable. ${policyHint} (${msg})`);
35083
+ return `Could not register Signet agent '${agentId}' because the daemon was unreachable. ${policyHint} (${msg})`;
35110
35084
  }
35085
+ return null;
35111
35086
  }
35112
35087
 
35113
35088
  class HermesAgentConnector extends BaseConnector {
35114
35089
  name = "Hermes Agent";
35115
35090
  harnessId = "hermes-agent";
35116
- target;
35117
- registration;
35118
- constructor(options) {
35119
- super();
35120
- if (options && "home" in options) {
35121
- this.target = options;
35122
- this.registration = { agentId: "", strict: options.kind === "profile" };
35123
- } else {
35124
- this.target = options?.target;
35125
- this.registration = options ? {
35126
- agentId: options.agentId ?? "",
35127
- readPolicy: options.readPolicy,
35128
- policyGroup: options.policyGroup,
35129
- strict: options.target?.kind === "profile"
35130
- } : undefined;
35131
- }
35132
- }
35091
+ targetOptions = {};
35133
35092
  getHermesHome() {
35134
- return this.target?.home ?? resolveHermesHomePath();
35093
+ if (this.targetOptions.profile) {
35094
+ if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/.test(this.targetOptions.profile)) {
35095
+ throw new Error("Invalid Hermes profile name; use 1-64 letters, numbers, '.', '_' or '-'.");
35096
+ }
35097
+ const userHome2 = process.env.HOME?.trim() || homedir();
35098
+ const profileHome = join4(userHome2, ".hermes", "profiles", this.targetOptions.profile);
35099
+ return resolveContainedWritePath(profileHome, join4(userHome2, ".hermes", "profiles"));
35100
+ }
35101
+ return resolveHermesHomePath();
35135
35102
  }
35136
35103
  getHermesRepo() {
35137
- if (this.target?.kind === "profile")
35104
+ if (this.targetOptions.profile)
35138
35105
  return null;
35139
35106
  return resolveHermesRepoPath();
35140
35107
  }
35141
35108
  getConfigPath() {
35142
35109
  return resolveConfigPath(this.getHermesHome());
35143
35110
  }
35144
- async install(basePath) {
35111
+ async install(basePath, options = {}) {
35112
+ this.targetOptions = options;
35145
35113
  const filesWritten = [];
35146
35114
  const configsPatched = [];
35147
35115
  const warnings = [];
35148
35116
  const expandedBasePath = expandHome(basePath || join4(homedir(), ".agents"));
35149
- const hermesHome = this.getHermesHome();
35150
- const legacyAgentsBasePath = this.target?.kind === "profile" ? hermesHome : expandedBasePath;
35151
- const strippedAgentsPath = this.stripLegacySignetBlock(legacyAgentsBasePath);
35117
+ const strippedAgentsPath = options.profile ? null : this.stripLegacySignetBlock(expandedBasePath);
35152
35118
  if (strippedAgentsPath !== null) {
35153
35119
  filesWritten.push(strippedAgentsPath);
35154
35120
  }
35155
- if (this.target?.kind === "profile")
35156
- assertContainedTargetPath(hermesHome, this.target.home);
35121
+ const hermesHome = this.getHermesHome();
35157
35122
  const hermesRepo = this.getHermesRepo();
35158
35123
  let userPluginInstalled = false;
35159
35124
  let repoPluginInstalled = false;
35160
35125
  try {
35161
- const pluginFiles = installPlugin(getUserPluginTargetDir(hermesHome), "user", hermesHome);
35126
+ const pluginFiles = installPlugin(getUserPluginTargetDir(hermesHome), "user", options.profile ? hermesHome : undefined);
35162
35127
  filesWritten.push(...pluginFiles);
35163
35128
  userPluginInstalled = true;
35164
35129
  } catch (e) {
@@ -35167,7 +35132,7 @@ class HermesAgentConnector extends BaseConnector {
35167
35132
  }
35168
35133
  if (hermesRepo) {
35169
35134
  try {
35170
- const pluginFiles = installPlugin(getRepoPluginTargetDir(hermesRepo), "repo", hermesRepo);
35135
+ const pluginFiles = installPlugin(getRepoPluginTargetDir(hermesRepo), "repo");
35171
35136
  filesWritten.push(...pluginFiles);
35172
35137
  repoPluginInstalled = true;
35173
35138
  } catch (e) {
@@ -35185,7 +35150,7 @@ class HermesAgentConnector extends BaseConnector {
35185
35150
  warnings
35186
35151
  };
35187
35152
  }
35188
- const envPath = this.target?.kind === "profile" ? resolveContainedWritePath(join4(hermesHome, ".env"), this.target.home) : join4(hermesHome, ".env");
35153
+ const envPath = options.profile ? resolveContainedWritePath(join4(hermesHome, ".env"), hermesHome) : join4(hermesHome, ".env");
35189
35154
  let configuredSignetAgentId = "default";
35190
35155
  const configuredDaemonUrl = (process.env.SIGNET_DAEMON_URL?.trim() || "http://127.0.0.1:3850").replace(/[\r\n]+/g, "");
35191
35156
  try {
@@ -35200,7 +35165,7 @@ class HermesAgentConnector extends BaseConnector {
35200
35165
  if (process.env.SIGNET_TRUSTED_DAEMON_ORIGINS) {
35201
35166
  signetVars.SIGNET_TRUSTED_DAEMON_ORIGINS = sanitizedEnv("SIGNET_TRUSTED_DAEMON_ORIGINS");
35202
35167
  }
35203
- let signetAgentId = this.registration?.agentId || sanitizedEnv("SIGNET_AGENT_ID");
35168
+ let signetAgentId = sanitizedEnv("SIGNET_AGENT_ID");
35204
35169
  if (signetAgentId === "hermes-agent") {
35205
35170
  warnings.push("SIGNET_AGENT_ID='hermes-agent' is the harness name, not an agent scope. Re-resolving from the daemon.");
35206
35171
  signetAgentId = "";
@@ -35255,18 +35220,11 @@ ${key}=${value}
35255
35220
  const msg = e instanceof Error ? e.message : String(e);
35256
35221
  warnings.push(`Failed to update .env: ${msg}`);
35257
35222
  }
35258
- const registration = this.registration ? { ...this.registration, agentId: this.registration.agentId || configuredSignetAgentId } : configuredSignetAgentId;
35259
- const registrationResult = await ensureNamedAgentRegistered(configuredDaemonUrl, registration, warnings);
35260
- if (!registrationResult.ok && this.target?.kind === "profile") {
35261
- return {
35262
- success: false,
35263
- message: registrationResult.error,
35264
- filesWritten,
35265
- configsPatched,
35266
- warnings
35267
- };
35223
+ const registrationError = await ensureNamedAgentRegistered(configuredDaemonUrl, configuredSignetAgentId, warnings, options);
35224
+ if (registrationError) {
35225
+ return { success: false, message: registrationError, filesWritten, configsPatched, warnings };
35268
35226
  }
35269
- const providerConfig = configureProvider(hermesHome, warnings, this.target?.kind === "profile" ? this.target.home : hermesHome);
35227
+ const providerConfig = configureProvider(hermesHome, warnings, options.profile ? hermesHome : undefined);
35270
35228
  if (providerConfig.configPath) {
35271
35229
  configsPatched.push(providerConfig.configPath);
35272
35230
  }
@@ -35299,28 +35257,30 @@ ${key}=${value}
35299
35257
  warnings
35300
35258
  };
35301
35259
  }
35302
- async uninstall() {
35260
+ async uninstall(options = {}) {
35261
+ this.targetOptions = options;
35303
35262
  const filesRemoved = [];
35304
35263
  const configsPatched = [];
35305
35264
  const hermesRepo = this.getHermesRepo();
35306
35265
  if (hermesRepo) {
35307
- const removed = uninstallPlugin(getRepoPluginTargetDir(hermesRepo), hermesRepo);
35266
+ const removed = uninstallPlugin(getRepoPluginTargetDir(hermesRepo));
35308
35267
  filesRemoved.push(...removed);
35309
35268
  }
35310
35269
  const hermesHome = this.getHermesHome();
35311
- const targetRoot = this.target?.kind === "profile" ? this.target.home : undefined;
35312
- if (targetRoot)
35313
- assertContainedTargetPath(hermesHome, targetRoot);
35314
- const userPluginRemoved = uninstallPlugin(getUserPluginTargetDir(hermesHome), targetRoot);
35270
+ const userPluginTarget = getUserPluginTargetDir(hermesHome);
35271
+ if (options.profile && (!existsSync2(userPluginTarget) || readInstallMarker(userPluginTarget) === null)) {
35272
+ return { filesRemoved, configsPatched };
35273
+ }
35274
+ const userPluginRemoved = uninstallPlugin(userPluginTarget, options.profile ? hermesHome : undefined);
35315
35275
  filesRemoved.push(...userPluginRemoved);
35316
- const providerConfig = restoreOrClearProvider(hermesHome, targetRoot);
35276
+ const providerConfig = restoreOrClearProvider(hermesHome, options.profile ? hermesHome : undefined);
35317
35277
  if (providerConfig.configPath) {
35318
35278
  configsPatched.push(providerConfig.configPath);
35319
35279
  }
35320
35280
  if (providerConfig.backupPath) {
35321
35281
  filesRemoved.push(providerConfig.backupPath);
35322
35282
  }
35323
- const envPath = targetRoot ? resolveContainedWritePath(join4(hermesHome, ".env"), targetRoot) : join4(hermesHome, ".env");
35283
+ const envPath = options.profile ? resolveContainedWritePath(join4(hermesHome, ".env"), hermesHome) : join4(hermesHome, ".env");
35324
35284
  if (existsSync2(envPath)) {
35325
35285
  try {
35326
35286
  let envContent = readFileSync2(envPath, "utf-8");
@@ -35454,7 +35414,6 @@ function createConnector() {
35454
35414
  }
35455
35415
  var src_default = HermesAgentConnector;
35456
35416
  export {
35457
- ensureNamedAgentRegistered,
35458
35417
  diagnoseHermesIntegration,
35459
35418
  src_default as default,
35460
35419
  createConnector,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@signetai/connector-hermes-agent",
3
- "version": "0.208.2",
3
+ "version": "0.209.1",
4
4
  "description": "Signet connector for Hermes Agent — installs Signet as a pluggable memory provider",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -25,8 +25,8 @@
25
25
  "typecheck": "tsc --noEmit"
26
26
  },
27
27
  "dependencies": {
28
- "@signetai/connector-base": "0.208.2",
29
- "@signetai/core": "0.208.2"
28
+ "@signetai/connector-base": "0.209.1",
29
+ "@signetai/core": "0.209.1"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/node": "^22.0.0",