om-memory-system 5.7.0-next.218 → 5.9.0

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 (38) hide show
  1. package/dist/adapters/opencode/self-update.d.ts +19 -0
  2. package/dist/adapters/opencode/self-update.js +42 -0
  3. package/dist/adapters/opencode/tui-status.d.ts +12 -2
  4. package/dist/adapters/opencode/tui-status.js +84 -11
  5. package/dist/adapters/pi/extension.js +19 -3
  6. package/dist/adapters/pi/self-update.d.ts +25 -0
  7. package/dist/adapters/pi/self-update.js +146 -0
  8. package/dist/cli/space-command.js +21 -1
  9. package/dist/cli/web-command.js +1 -1
  10. package/dist/config.js +11 -1
  11. package/dist/services/host-copies.d.ts +52 -0
  12. package/dist/services/host-copies.js +150 -0
  13. package/dist/services/host-self-update.d.ts +108 -0
  14. package/dist/services/host-self-update.js +254 -0
  15. package/dist/services/space-routes.d.ts +10 -1
  16. package/dist/services/space-routes.js +63 -20
  17. package/dist/services/spaces/backup.js +3 -0
  18. package/dist/services/spaces/operations.js +3 -1
  19. package/dist/services/spaces/registry-store.d.ts +5 -3
  20. package/dist/services/spaces/registry-store.js +38 -9
  21. package/dist/services/spaces/registry.d.ts +11 -5
  22. package/dist/services/spaces/registry.js +31 -23
  23. package/dist/services/spaces/restore.js +1 -1
  24. package/dist/services/spaces/space-label.d.ts +16 -0
  25. package/dist/services/spaces/space-label.js +69 -0
  26. package/dist/services/web-route-modules.d.ts +3 -1
  27. package/dist/services/web-route-modules.js +3 -1
  28. package/dist/services/web-server.d.ts +1 -1
  29. package/dist/services/web-server.js +2 -1
  30. package/dist/services/web-update-runtime.d.ts +1 -1
  31. package/dist/services/web-update-runtime.js +2 -1
  32. package/dist/services/web-update.d.ts +8 -0
  33. package/dist/services/web-update.js +27 -0
  34. package/dist/v2/plugin.js +60 -1
  35. package/dist/web/assets/index-Bhk1P5Z7.js +170 -0
  36. package/dist/web/index.html +1 -1
  37. package/package.json +1 -1
  38. package/dist/web/assets/index-C6WnDE6h.js +0 -170
@@ -9,6 +9,8 @@ export const UPDATE_CHECK_INTERVAL_MS = 10 * 60 * 1000;
9
9
  export const STATUS_RECHECK_AFTER_MS = 60 * 1000;
10
10
  /** An install that takes longer is stopped, and the web app keeps serving. */
11
11
  export const INSTALL_TIMEOUT_MS = 5 * 60 * 1000;
12
+ /** An automatic start waits this long after a failed automatic install. */
13
+ export const AUTO_RETRY_AFTER_MS = 30 * 60 * 1000;
12
14
  /** Only a plain release reaches the npm arguments; the value comes from the registry. */
13
15
  const PLAIN_VERSION = /^\d+\.\d+\.\d+$/;
14
16
  /** Enough of npm's error stream to find a code; the rest is dropped. */
@@ -29,6 +31,8 @@ export class WebUpdate {
29
31
  started = false;
30
32
  lastCheck = -Infinity;
31
33
  checking = null;
34
+ autoRetryAt = -Infinity;
35
+ autoAttempt = false;
32
36
  constructor(deps) {
33
37
  this.deps = deps;
34
38
  }
@@ -55,6 +59,25 @@ export class WebUpdate {
55
59
  return;
56
60
  }
57
61
  this.available = availableUpdate(this.deps.version, latest);
62
+ this.maybeAutoInstall();
63
+ }
64
+ /** Start the install the Update button starts, once a check found a release. */
65
+ maybeAutoInstall() {
66
+ if (this.state === "installing" || this.state === "restarting")
67
+ return;
68
+ if (!this.available)
69
+ return;
70
+ if (this.deps.now() < this.autoRetryAt)
71
+ return;
72
+ // A check can finish while a Stop or Restart runs; the manual route has the same gate.
73
+ if (this.deps.autoBlocked?.())
74
+ return;
75
+ if (!this.canInstall())
76
+ return;
77
+ if (this.requestInstall() !== "accepted")
78
+ return;
79
+ this.autoAttempt = true;
80
+ this.deps.log("Web app auto-update started", { from: this.deps.version, to: this.available });
58
81
  }
59
82
  status() {
60
83
  // An open page polls the status, so a release shows within about a minute.
@@ -78,6 +101,7 @@ export class WebUpdate {
78
101
  return "no-update";
79
102
  if (!this.canInstall())
80
103
  return "cannot-install";
104
+ this.autoAttempt = false;
81
105
  this.state = "installing";
82
106
  this.code = null;
83
107
  void this.install(this.available);
@@ -96,6 +120,9 @@ export class WebUpdate {
96
120
  const fail = (code, exitCode) => {
97
121
  this.state = "failed";
98
122
  this.code = code;
123
+ // Only an automatic start waits before trying again; the button always works.
124
+ if (this.autoAttempt)
125
+ this.autoRetryAt = this.deps.now() + AUTO_RETRY_AFTER_MS;
99
126
  record("failed", code, exitCode);
100
127
  };
101
128
  const { code, exitCode } = await runGlobalInstall(this.deps, target);
package/dist/v2/plugin.js CHANGED
@@ -1,8 +1,64 @@
1
+ import { fileURLToPath } from "node:url";
1
2
  import { OmmsPlugin } from "../index.js";
2
3
  import { loadOpencodeProvider } from "../adapters/opencode/opencode-provider-loader.js";
3
4
  import { registerV2Adapter } from "./adapter.js";
4
5
  import { createV2MemoryBridge } from "./memory-bridge.js";
5
6
  import { createLegacyClient } from "./legacy-client.js";
7
+ /**
8
+ * Remove old OMMS copies from the OpenCode cache. It runs in the background and
9
+ * is not awaited, so a slow or failing clean-up never delays or breaks setup.
10
+ * `OMMS_DISABLE_UPDATE_CHECK` does not stop it: removing old copies saves disk
11
+ * space and installs nothing. It keeps the copy that `~/.omms/runtime.json` names.
12
+ */
13
+ function startCacheCleanup() {
14
+ void (async () => {
15
+ const modulePath = fileURLToPath(import.meta.url);
16
+ const [{ installedFromNpm }, { pruneOldCacheCopies }, { readRuntimeRecord }, { ommsDir }, { packageVersion }, { log },] = await Promise.all([
17
+ import("../services/host-self-update.js"),
18
+ import("../services/host-copies.js"),
19
+ import("../services/runtime-record.js"),
20
+ import("../services/runtime-handoff.js"),
21
+ import("../services/package-version.js"),
22
+ import("../services/logger.js"),
23
+ ]);
24
+ if (!installedFromNpm(modulePath))
25
+ return;
26
+ const recorded = readRuntimeRecord(ommsDir());
27
+ await pruneOldCacheCopies({
28
+ modulePath,
29
+ runningVersion: packageVersion(),
30
+ keepRoots: recorded ? [recorded.root] : [],
31
+ now: Date.now(),
32
+ log: (message, data) => log(message, data),
33
+ });
34
+ })().catch(() => { });
35
+ }
36
+ let serviceUpdateStarted = false;
37
+ /**
38
+ * Check npm for a newer OMMS from the background service too, so OpenCode
39
+ * without a TUI (OpenChamber, `opencode serve`) also updates. Once per
40
+ * process: setup can run for each project. Not awaited; a failure is ignored.
41
+ */
42
+ function startServiceSelfUpdate() {
43
+ if (serviceUpdateStarted)
44
+ return;
45
+ serviceUpdateStarted = true;
46
+ void (async () => {
47
+ const modulePath = fileURLToPath(import.meta.url);
48
+ const [{ opencodeSelfUpdateDeps, startOpencodeServiceSelfUpdate }, { startHostSelfUpdate }, { packageVersion }, { log },] = await Promise.all([
49
+ import("../adapters/opencode/self-update.js"),
50
+ import("../services/host-self-update.js"),
51
+ import("../services/package-version.js"),
52
+ import("../services/logger.js"),
53
+ ]);
54
+ const deps = opencodeSelfUpdateDeps({
55
+ modulePath,
56
+ currentVersion: packageVersion(),
57
+ log: (message, data) => log(message, data),
58
+ });
59
+ startOpencodeServiceSelfUpdate({ run: () => startHostSelfUpdate(deps) });
60
+ })().catch(() => { });
61
+ }
6
62
  const OmmsPluginV2 = {
7
63
  id: "omms",
8
64
  async setup(ctx) {
@@ -18,7 +74,10 @@ const OmmsPluginV2 = {
18
74
  // context. Route internal structured-output calls through the adapter.
19
75
  const { setV2Client } = await loadOpencodeProvider();
20
76
  setV2Client(legacyClient);
21
- return registerV2Adapter(ctx, legacy, createV2MemoryBridge(ctx.location.directory));
77
+ const adapter = await registerV2Adapter(ctx, legacy, createV2MemoryBridge(ctx.location.directory));
78
+ startCacheCleanup();
79
+ startServiceSelfUpdate();
80
+ return adapter;
22
81
  },
23
82
  };
24
83
  export default OmmsPluginV2;