@indigoai-us/hq-cli 5.123.0 → 5.123.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.
@@ -112,10 +112,12 @@ export declare function writeSessionState(state: SessionStateFile, root: string)
112
112
  /** Strip any non-allowlisted fields before durable write. */
113
113
  export declare function projectSessionState(state: SessionStateFile): SessionStateFile;
114
114
  /**
115
- * Merge prior local-only counters into a new state write so PostToolUse bumps
116
- * and reconcile updates do not clobber each other.
115
+ * Merge prior local fields into a new state write so PostToolUse bumps and
116
+ * reconcile updates do not clobber an acknowledged company binding.
117
117
  */
118
- export declare function mergeLocalSessionFields(next: SessionStateFile, prior: SessionStateFile | null): SessionStateFile;
118
+ export declare function mergeLocalSessionFields(next: SessionStateFile, prior: SessionStateFile | null, options?: {
119
+ preserveBindingEpisode?: boolean;
120
+ }): SessionStateFile;
119
121
  /**
120
122
  * Upgrade the local projection after the server acknowledges a register.
121
123
  *
@@ -103,13 +103,30 @@ export function projectSessionState(state) {
103
103
  return out;
104
104
  }
105
105
  /**
106
- * Merge prior local-only counters into a new state write so PostToolUse bumps
107
- * and reconcile updates do not clobber each other.
106
+ * Merge prior local fields into a new state write so PostToolUse bumps and
107
+ * reconcile updates do not clobber an acknowledged company binding.
108
108
  */
109
- export function mergeLocalSessionFields(next, prior) {
109
+ export function mergeLocalSessionFields(next, prior, options = {}) {
110
110
  if (!prior)
111
111
  return next;
112
112
  const out = { ...next };
113
+ // Hook observations commonly carry only tool-write/session metadata. Those
114
+ // writes must not erase a company that an acknowledged register already
115
+ // projected locally; losing it causes held events and repeat registrations.
116
+ // A caller that carries either company field is intentionally changing the
117
+ // binding and remains authoritative.
118
+ if (!out.companyUid && !out.companySlug && (prior.companyUid || prior.companySlug)) {
119
+ out.companyUid = prior.companyUid;
120
+ out.companySlug = prior.companySlug;
121
+ out.contextStatus = prior.contextStatus;
122
+ if (!out.projectId && prior.projectId)
123
+ out.projectId = prior.projectId;
124
+ if (!out.taskId && prior.taskId)
125
+ out.taskId = prior.taskId;
126
+ if (out.version === undefined && prior.version !== undefined) {
127
+ out.version = prior.version;
128
+ }
129
+ }
113
130
  if (out.toolWrites === undefined && typeof prior.toolWrites === "number") {
114
131
  out.toolWrites = prior.toolWrites;
115
132
  }
@@ -131,7 +148,14 @@ export function mergeLocalSessionFields(next, prior) {
131
148
  if (!out.transcriptMarker && prior.transcriptMarker) {
132
149
  out.transcriptMarker = prior.transcriptMarker;
133
150
  }
134
- if (!out.bindingEpisodeId && prior.bindingEpisodeId) {
151
+ const sameBinding = prior.companyUid === out.companyUid &&
152
+ prior.companySlug === out.companySlug &&
153
+ prior.projectId === out.projectId &&
154
+ prior.taskId === out.taskId;
155
+ if (options.preserveBindingEpisode !== false &&
156
+ !out.bindingEpisodeId &&
157
+ prior.bindingEpisodeId &&
158
+ sameBinding) {
135
159
  out.bindingEpisodeId = prior.bindingEpisodeId;
136
160
  }
137
161
  return out;
@@ -57,6 +57,7 @@
57
57
  * version-check), `hq rescue --no-self-update`, and the re-exec guard env.
58
58
  */
59
59
  import { type RunningInstall, type UpdateResult } from "./version-gate.js";
60
+ import { type RestartDaemonResult } from "../lib/mesh/live/daemon/install.js";
60
61
  /**
61
62
  * Set on the re-exec'd child so it can never self-update (and re-exec) again.
62
63
  * One update + one re-exec per user invocation, ever.
@@ -153,6 +154,8 @@ export interface SelfUpdateDeps {
153
154
  * underneath themselves: hooks, scripts, agents, cron, CI.
154
155
  */
155
156
  interactive?: boolean;
157
+ /** Best-effort daemon kick after the CLI install converges (tests). */
158
+ restartDaemon?: () => RestartDaemonResult | void;
156
159
  }
157
160
  /**
158
161
  * Startup path: the running CLI is behind npm `latest`, so update in place and
@@ -63,6 +63,7 @@ import { CLI_NAME, CLI_VERSION } from "../cli-version.js";
63
63
  import { buildBunInstallArgv, buildPnpmInstallArgv, buildPrefixedInstallArgv, buildSpawnPlan, checkUpdateConvergence, isLocalDependencyInstall, isPrefixWritable, nonWritablePrefixNote, openInstallOutput, pnpmUpdateEnv, resolveRunningInstall, runUpdateCommand, runSupervisedUpdateCommand, } from "./version-gate.js";
64
64
  import { acquireUpdateLock as acquireSharedUpdateLock } from "./update-lock.js";
65
65
  import { markLatestIneffective } from "./version-check.js";
66
+ import { restartDaemonServiceIfInstalled } from "../lib/mesh/live/daemon/install.js";
66
67
  /**
67
68
  * Set on the re-exec'd child so it can never self-update (and re-exec) again.
68
69
  * One update + one re-exec per user invocation, ever.
@@ -278,6 +279,16 @@ async function updateAndReexec(argv, flavor, known, deps) {
278
279
  console.error(chalk.dim(` Continuing the ${flavor.noun} on ${current}.`));
279
280
  return { action: "update-ineffective", latest };
280
281
  }
282
+ // A resident mesh daemon keeps the old JS loaded after a global install.
283
+ // Service restart is best-effort and cannot turn a successful update red.
284
+ try {
285
+ const restart = (deps.restartDaemon ?? restartDaemonServiceIfInstalled)();
286
+ if (restart?.message)
287
+ console.error(chalk.yellow(` ${restart.message}`));
288
+ }
289
+ catch {
290
+ // Defensive only; the default helper already absorbs manager failures.
291
+ }
281
292
  const childEnv = { ...env, [REEXEC_GUARD_ENV]: "1" };
282
293
  const status = (deps.reexec ?? reexecHq)([...argv.slice(2)], childEnv);
283
294
  if (status === null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigoai-us/hq-cli",
3
- "version": "5.123.0",
3
+ "version": "5.123.1",
4
4
  "description": "HQ by Indigo management CLI \u2014 modules and cloud sync",
5
5
  "main": "dist/index.js",
6
6
  "bin": {