@inerrata-corporation/errata 2.0.6-dev.2561 → 2.0.6-dev.2563

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.
Files changed (2) hide show
  1. package/errata.mjs +103 -18
  2. package/package.json +1 -1
package/errata.mjs CHANGED
@@ -78332,7 +78332,7 @@ function createWatchBreaker(deps) {
78332
78332
  }
78333
78333
 
78334
78334
  // src/engine.ts
78335
- var DAEMON_VERSION = true ? "2.0.6-dev.2561" : "2.0.0-alpha.0";
78335
+ var DAEMON_VERSION = true ? "2.0.6-dev.2563" : "2.0.0-alpha.0";
78336
78336
  var IGNORED_PATH = /[\\/](?:\.git|node_modules|\.errata|\.claude|\.codex|\.cursor|\.turbo|\.next|dist|coverage|test-results|playwright-report|__pycache__)(?:[\\/]|$)/;
78337
78337
  var IGNORED_NOISE = /castalia\.db|eventlog\.sqlite|turn-cursors/;
78338
78338
  var GIT_OP_MUTE_MS = 4e3;
@@ -81713,6 +81713,41 @@ var ConsolidateWorker = class {
81713
81713
  // src/multi.ts
81714
81714
  init_paths();
81715
81715
 
81716
+ // src/cloud-target.ts
81717
+ init_cloud_endpoint_policy();
81718
+ function describeCloudTarget(cfg, opts, env2, configPath) {
81719
+ const pinnedBy = [];
81720
+ if (opts.cloudUrl) pinnedBy.push("--cloud-url");
81721
+ if (opts.apiKey) pinnedBy.push("--api-key");
81722
+ if (env2["ERRATA_CLOUD_URL"]) pinnedBy.push("ERRATA_CLOUD_URL");
81723
+ if (env2["ERRATA_CONFIG_PATH"]) pinnedBy.push("ERRATA_CONFIG_PATH");
81724
+ return {
81725
+ url: normalizeCloudUrl(opts.cloudUrl ?? cfg.cloudUrl),
81726
+ profile: opts.apiKey ? null : cfg.activeInstallationProfile ?? null,
81727
+ credential: opts.apiKey ? "process-key" : cfg.accessToken ? "oauth" : cfg.apiKey ? "key" : "none",
81728
+ configPath,
81729
+ pinnedBy
81730
+ };
81731
+ }
81732
+ function cloudTargetDrift(daemon, shell2) {
81733
+ const out2 = [];
81734
+ if (daemon.url !== shell2.url) {
81735
+ out2.push(`the running daemon talks to ${daemon.url} \u2014 this shell resolves ${shell2.url}`);
81736
+ }
81737
+ if (daemon.profile !== shell2.profile) {
81738
+ out2.push(`daemon profile ${daemon.profile ?? "(none)"} \u2260 this shell's ${shell2.profile ?? "(none)"}`);
81739
+ }
81740
+ if (daemon.configPath !== shell2.configPath) {
81741
+ out2.push(`daemon reads ${daemon.configPath} \u2014 this shell reads ${shell2.configPath}`);
81742
+ }
81743
+ if (out2.length > 0) {
81744
+ out2.push(
81745
+ daemon.pinnedBy.length > 0 ? `the daemon is pinned by ${daemon.pinnedBy.join(", ")} \u2014 restart it from a shell without that override (errata stop; errata start)` : `restart the daemon to adopt this shell's config (errata stop; errata start)`
81746
+ );
81747
+ }
81748
+ return out2;
81749
+ }
81750
+
81716
81751
  // src/lock.ts
81717
81752
  import { existsSync as existsSync29, readFileSync as readFileSync28 } from "node:fs";
81718
81753
  function daemonLockPayload(lock) {
@@ -81895,6 +81930,42 @@ function runNpmInstall(channel) {
81895
81930
  // src/multi.ts
81896
81931
  init_cloud_endpoint_policy();
81897
81932
  init_cloud_auth();
81933
+
81934
+ // src/live-cloud-client.ts
81935
+ function liveCloudClient(src) {
81936
+ const recheckMs = src.recheckMs ?? 5e3;
81937
+ const now = src.now ?? Date.now;
81938
+ let current = null;
81939
+ let currentKey = "";
81940
+ let checkedAt = -Infinity;
81941
+ const resolve7 = () => {
81942
+ const t = now();
81943
+ if (current && t - checkedAt < recheckMs) return current;
81944
+ checkedAt = t;
81945
+ let cfg;
81946
+ try {
81947
+ cfg = src.read();
81948
+ } catch (err2) {
81949
+ if (current) return current;
81950
+ throw err2;
81951
+ }
81952
+ const key = src.fingerprint(cfg);
81953
+ if (!current || key !== currentKey) {
81954
+ current = src.build(cfg);
81955
+ currentKey = key;
81956
+ }
81957
+ return current;
81958
+ };
81959
+ return new Proxy({}, {
81960
+ get(_target, prop) {
81961
+ const client = resolve7();
81962
+ const value = Reflect.get(client, prop, client);
81963
+ return typeof value === "function" ? value.bind(client) : value;
81964
+ }
81965
+ });
81966
+ }
81967
+
81968
+ // src/multi.ts
81898
81969
  init_identity2();
81899
81970
 
81900
81971
  // src/project-link.ts
@@ -84759,20 +84830,9 @@ async function startMultiDaemon(opts = {}) {
84759
84830
  }
84760
84831
  const cfg = loadConfig();
84761
84832
  const CLOUD_TIMEOUT_MS = 12e4;
84762
- const initialCloudUrl = normalizeCloudUrl(opts.cloudUrl ?? cfg.cloudUrl);
84763
- const initialCfg = { ...cfg, cloudUrl: initialCloudUrl };
84764
- if (opts.apiKey) {
84765
- initialCfg.apiKey = opts.apiKey;
84766
- initialCfg.accessToken = null;
84767
- initialCfg.refreshToken = null;
84768
- initialCfg.tokenEndpoint = null;
84769
- initialCfg.oauthClientId = null;
84770
- }
84771
- const cloud = authedCloudClient(initialCfg, { timeoutMs: CLOUD_TIMEOUT_MS, daemonVersion: DAEMON_VERSION });
84772
- const cloudNow = () => {
84833
+ const currentCfg = () => {
84773
84834
  const c = loadConfig();
84774
- const baseUrl2 = normalizeCloudUrl(opts.cloudUrl ?? c.cloudUrl);
84775
- const current = { ...c, cloudUrl: baseUrl2 };
84835
+ const current = { ...c, cloudUrl: normalizeCloudUrl(opts.cloudUrl ?? c.cloudUrl) };
84776
84836
  if (opts.apiKey) {
84777
84837
  current.apiKey = opts.apiKey;
84778
84838
  current.accessToken = null;
@@ -84780,8 +84840,14 @@ async function startMultiDaemon(opts = {}) {
84780
84840
  current.tokenEndpoint = null;
84781
84841
  current.oauthClientId = null;
84782
84842
  }
84783
- return authedCloudClient(current, { timeoutMs: CLOUD_TIMEOUT_MS, daemonVersion: DAEMON_VERSION });
84843
+ return current;
84784
84844
  };
84845
+ const cloudNow = () => authedCloudClient(currentCfg(), { timeoutMs: CLOUD_TIMEOUT_MS, daemonVersion: DAEMON_VERSION });
84846
+ const cloud = liveCloudClient({
84847
+ read: currentCfg,
84848
+ fingerprint: (c) => JSON.stringify([c.cloudUrl, c.apiKey, c.accessToken, c.refreshToken, c.tokenEndpoint, c.activeInstallationProfile, c.updateChannel]),
84849
+ build: (c) => authedCloudClient(c, { timeoutMs: CLOUD_TIMEOUT_MS, daemonVersion: DAEMON_VERSION })
84850
+ });
84785
84851
  const identityFor = (entry) => {
84786
84852
  if (opts.apiKey) {
84787
84853
  return {
@@ -84956,9 +85022,14 @@ async function startMultiDaemon(opts = {}) {
84956
85022
  noteIdentityBlock(entry.id, entry.name, wsIdentity);
84957
85023
  wsCloud = blockedCloudClient(wsIdentity.reason);
84958
85024
  } else {
84959
- wsCloud = authedCloudClientForProfile(loadConfig(), wsIdentity.profileName, {
84960
- timeoutMs: CLOUD_TIMEOUT_MS,
84961
- daemonVersion: DAEMON_VERSION
85025
+ const profileName = wsIdentity.profileName;
85026
+ wsCloud = liveCloudClient({
85027
+ read: loadConfig,
85028
+ fingerprint: (c) => {
85029
+ const p = c.installationProfiles[profileName];
85030
+ return JSON.stringify([p?.cloudUrl, c.cloudUrl, p?.accessToken, p?.refreshToken, p?.tokenEndpoint, c.updateChannel]);
85031
+ },
85032
+ build: (c) => authedCloudClientForProfile(c, profileName, { timeoutMs: CLOUD_TIMEOUT_MS, daemonVersion: DAEMON_VERSION })
84962
85033
  });
84963
85034
  console.log(`[identity] workspace "${entry.name}" bound \u2192 profile "${wsIdentity.profileName}"`);
84964
85035
  }
@@ -85146,11 +85217,19 @@ async function startMultiDaemon(opts = {}) {
85146
85217
  return hit?.count ?? -1;
85147
85218
  };
85148
85219
  let lastHook = null;
85220
+ const cloudTarget = () => {
85221
+ try {
85222
+ return describeCloudTarget(loadConfig(), { cloudUrl: opts.cloudUrl, apiKey: opts.apiKey }, process.env, globalConfigPath());
85223
+ } catch {
85224
+ return null;
85225
+ }
85226
+ };
85149
85227
  app.get(
85150
85228
  "/health",
85151
85229
  (c) => c.json({
85152
85230
  ok: true,
85153
85231
  daemonVersion: DAEMON_VERSION,
85232
+ cloud: cloudTarget(),
85154
85233
  lastHook,
85155
85234
  // What the daemon is DOING, not just what it holds. Without these a
85156
85235
  // pegged daemon is only diagnosable by attaching a CPU profiler to the
@@ -87585,6 +87664,7 @@ async function cmdStatus() {
87585
87664
  const note = foreignDaemonNote(running, pathResolve2(process.argv[1]));
87586
87665
  if (note) for (const l of note) console.log(` \u26A0 ${l}`);
87587
87666
  }
87667
+ let daemonCloud = null;
87588
87668
  if (running?.webUiUrl) {
87589
87669
  try {
87590
87670
  const res = await fetch(`${running.webUiUrl}/health`, {
@@ -87592,6 +87672,7 @@ async function cmdStatus() {
87592
87672
  });
87593
87673
  if (res.ok) {
87594
87674
  const h = await res.json();
87675
+ daemonCloud = h.cloud ?? null;
87595
87676
  if (h.pass) {
87596
87677
  const held = h.pass.runningMs !== null && h.pass.current !== "idle" ? ` (${(h.pass.runningMs / 1e3).toFixed(1)}s)` : "";
87597
87678
  const alsoCount = Math.max(0, (h.pass.active?.length ?? 0) - 1);
@@ -87627,6 +87708,10 @@ async function cmdStatus() {
87627
87708
  );
87628
87709
  console.log(` cloud:`);
87629
87710
  console.log(` url: ${cfg.cloudUrl}`);
87711
+ if (daemonCloud) {
87712
+ const shellCloud = describeCloudTarget(cfg, {}, process.env, globalConfigPath());
87713
+ for (const line of cloudTargetDrift(daemonCloud, shellCloud)) console.log(` \u26A0 ${line}`);
87714
+ }
87630
87715
  console.log(` profile: ${cfg.activeInstallationProfile ?? "(unbound legacy credential)"}`);
87631
87716
  if (!hasCloudCredential(cfg)) {
87632
87717
  console.log(` logged in: no`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inerrata-corporation/errata",
3
- "version": "2.0.6-dev.2561",
3
+ "version": "2.0.6-dev.2563",
4
4
  "description": "errata - local-first observation engine for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {