@moxt-ai/mobius 0.0.313 → 0.0.315

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.
@@ -0,0 +1,12 @@
1
+ /** The configured state directory holds another root's installation data, so Mobius must not create a root there. */
2
+ export declare class StateRootError extends Error {
3
+ readonly code = "state_root_is_installation_data";
4
+ readonly owningRoot: string;
5
+ constructor(stateDirectory: string, owningRoot: string);
6
+ }
7
+ /**
8
+ * Refuses a state directory that is another root's installation data, as an Agent launched by an earlier daemon
9
+ * inherits. A directory a daemon already ran as its root keeps working: it records its version data there.
10
+ */
11
+ export declare function validateStateRoot(environment: Readonly<NodeJS.ProcessEnv>): Promise<void>;
12
+ //# sourceMappingURL=state-root.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-root.d.ts","sourceRoot":"","sources":["../../src/storage/state-root.ts"],"names":[],"mappings":"AAKA,qHAAqH;AACrH,qBAAa,cAAe,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,qCAAqC;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,YAAY,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAOrD;CACJ;AAqCD;;;GAGG;AACH,wBAAsB,iBAAiB,CAAC,WAAW,EAAE,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAS/F"}
@@ -0,0 +1,59 @@
1
+ import { readFile, stat } from "node:fs/promises";
2
+ import { basename, dirname, join } from "node:path";
3
+ import { installationPointerPath } from "./installation/installation-files.js";
4
+ import { readStateDirectory } from "./state-directory.js";
5
+ /** The configured state directory holds another root's installation data, so Mobius must not create a root there. */
6
+ export class StateRootError extends Error {
7
+ code = "state_root_is_installation_data";
8
+ owningRoot;
9
+ constructor(stateDirectory, owningRoot) {
10
+ super(`MOBIUS_STATE_DIRECTORY (${stateDirectory}) is Mobius installation data, not a state root. ` +
11
+ `Use the state root that owns it: MOBIUS_STATE_DIRECTORY=${owningRoot}`);
12
+ this.name = "StateRootError";
13
+ this.owningRoot = owningRoot;
14
+ }
15
+ }
16
+ async function exists(path) {
17
+ return await stat(path).then(() => true, () => false);
18
+ }
19
+ /**
20
+ * An installation directory sits at `<root>/installations/<application>/<id>` or, for CLI data,
21
+ * `<root>/versions/<version>/installations/<application>/<id>`, and its application's `current.json` names it.
22
+ */
23
+ async function owningRoot(directory) {
24
+ const application = dirname(directory);
25
+ const installations = dirname(application);
26
+ if (basename(installations) !== "installations") {
27
+ return null;
28
+ }
29
+ let pointer;
30
+ try {
31
+ pointer = JSON.parse(await readFile(installationPointerPath(application), "utf8"));
32
+ }
33
+ catch {
34
+ return null;
35
+ }
36
+ if (typeof pointer !== "object" ||
37
+ pointer === null ||
38
+ !("installationId" in pointer) ||
39
+ pointer.installationId !== basename(directory)) {
40
+ return null;
41
+ }
42
+ const container = dirname(installations);
43
+ return basename(dirname(container)) === "versions" ? dirname(dirname(container)) : container;
44
+ }
45
+ /**
46
+ * Refuses a state directory that is another root's installation data, as an Agent launched by an earlier daemon
47
+ * inherits. A directory a daemon already ran as its root keeps working: it records its version data there.
48
+ */
49
+ export async function validateStateRoot(environment) {
50
+ const directory = readStateDirectory(environment);
51
+ if ((await exists(join(directory, "current-data.txt"))) || (await exists(join(directory, "versions")))) {
52
+ return;
53
+ }
54
+ const root = await owningRoot(directory);
55
+ if (root !== null) {
56
+ throw new StateRootError(directory, root);
57
+ }
58
+ }
59
+ //# sourceMappingURL=state-root.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-root.js","sourceRoot":"","sources":["../../src/storage/state-root.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC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;IACD,MAAM,SAAS,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;IACzC,OAAO,QAAQ,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACjG,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,WAAwC;IAC5E,MAAM,SAAS,GAAG,kBAAkB,CAAC,WAAW,CAAC,CAAC;IAClD,IAAI,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC;QACrG,OAAO;IACX,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,UAAU,CAAC,SAAS,CAAC,CAAC;IACzC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,cAAc,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAC9C,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moxt-ai/mobius",
3
- "version": "0.0.313",
3
+ "version": "0.0.315",
4
4
  "description": "Mobius CLI for pairing and running local AI agent services.",
5
5
  "type": "module",
6
6
  "bin": {