rovloom 0.6.0 → 0.6.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.
Files changed (62) hide show
  1. package/README.md +2 -2
  2. package/dist/src/admin/index.js +1 -1
  3. package/dist/src/{chunk-g27b2gmx.js → chunk-0e9gg4sg.js} +2 -2
  4. package/dist/src/chunk-1xer1ent.js +102 -0
  5. package/dist/src/{chunk-863tk45b.js → chunk-41fny9qm.js} +5 -5
  6. package/dist/src/{chunk-zjzrcc59.js → chunk-59h200cr.js} +139 -7
  7. package/dist/src/chunk-5w5srj3b.js +93 -0
  8. package/dist/src/{chunk-d4ejrtjq.js → chunk-6n6b1xpy.js} +1 -1
  9. package/dist/src/{chunk-ez7d5dac.js → chunk-6w4g9fw8.js} +4 -1
  10. package/dist/src/{chunk-0dqx2mmz.js → chunk-73aq2qkz.js} +1 -1
  11. package/dist/src/{chunk-n6wtjyfb.js → chunk-8c9yc0ge.js} +5 -5
  12. package/dist/src/{chunk-57ayxqnb.js → chunk-8fy8w7ds.js} +2 -23
  13. package/dist/src/{chunk-2tn0r64b.js → chunk-9h9x79bx.js} +5 -5
  14. package/dist/src/{chunk-qjh9x872.js → chunk-av31bx1e.js} +1 -1
  15. package/dist/src/{chunk-0xgpxdgc.js → chunk-bbdtsg4b.js} +7 -5
  16. package/dist/src/{chunk-q5pgbwb3.js → chunk-e7jgpxkf.js} +2 -2
  17. package/dist/src/{chunk-zj48jvfe.js → chunk-efty77sb.js} +3 -40
  18. package/dist/src/{chunk-gyvqqnjb.js → chunk-enj7s8cv.js} +49 -29
  19. package/dist/src/{chunk-jka7v3wb.js → chunk-ftpy8xx3.js} +311 -23
  20. package/dist/src/{chunk-zdxww7ms.js → chunk-h3xyq7zk.js} +1 -1
  21. package/dist/src/{chunk-ttsrctxg.js → chunk-hxmq28pg.js} +9 -7
  22. package/dist/src/{chunk-s3ydr65k.js → chunk-j59ac0xs.js} +2 -2
  23. package/dist/src/{chunk-5s2emvww.js → chunk-j6svdqr8.js} +10 -302
  24. package/dist/src/{chunk-9zkq0kc8.js → chunk-jkzfck98.js} +3 -3
  25. package/dist/src/{chunk-ssp57p43.js → chunk-m76cmkfy.js} +7 -5
  26. package/dist/src/{chunk-d2kz25f2.js → chunk-m96mbzcw.js} +674 -308
  27. package/dist/src/{chunk-yv9px0f5.js → chunk-n3z3jaxy.js} +20 -14
  28. package/dist/src/{chunk-jf4r0r44.js → chunk-ndj0ay2p.js} +19 -18
  29. package/dist/src/{chunk-5b8g62kw.js → chunk-pgs9jp6t.js} +61 -179
  30. package/dist/src/chunk-pksaqt9a.js +25 -0
  31. package/dist/src/{chunk-wxqhscsw.js → chunk-pnep7yhj.js} +7 -99
  32. package/dist/src/chunk-qn5xae7g.js +66 -0
  33. package/dist/src/{chunk-0pewfj89.js → chunk-qp8tgms2.js} +1 -1
  34. package/dist/src/{chunk-mg0fd6ph.js → chunk-rmgw8h27.js} +10 -8
  35. package/dist/src/{chunk-gbsbwssz.js → chunk-sf4ztxba.js} +3 -3
  36. package/dist/src/{chunk-x0td5wn4.js → chunk-shez7hkc.js} +1 -1
  37. package/dist/src/chunk-sqz614bh.js +30 -0
  38. package/dist/src/{chunk-09f9q26d.js → chunk-vdwzb63d.js} +2 -2
  39. package/dist/src/chunk-xtvgm6kf.js +48 -0
  40. package/dist/src/chunk-y8zm75jt.js +157 -0
  41. package/dist/src/chunk-yasqw2vj.js +756 -0
  42. package/dist/src/{chunk-srfbjwtk.js → chunk-z0qmfqvd.js} +3 -3
  43. package/dist/src/chunk-zm705snh.js +53 -0
  44. package/dist/src/cli/index.js +29 -28
  45. package/dist/src/cli/main.js +5 -5
  46. package/dist/src/connector/herdr/installation.js +4 -4
  47. package/dist/src/connector/herdr/provider.js +9 -9
  48. package/dist/src/connector/herdr/runtime.js +7 -7
  49. package/dist/src/connector/luvus/index.js +7 -6
  50. package/dist/src/mcp/index.js +16 -15
  51. package/dist/src/runtime/index.js +16 -15
  52. package/dist/src/service/index.js +2 -2
  53. package/dist/src/store.js +4 -4
  54. package/dist/src/transport/index.js +9 -9
  55. package/dist/src/webui/index.js +141 -939
  56. package/package.json +1 -1
  57. package/dist/src/chunk-0qgk7mhz.js +0 -52
  58. package/dist/src/chunk-3dvn33c4.js +0 -1299
  59. package/dist/src/chunk-5j0gj6w2.js +0 -7
  60. package/dist/src/chunk-vwcntax3.js +0 -228
  61. package/dist/src/chunk-ytpfmcp1.js +0 -25
  62. package/dist/src/chunk-zjkjjm81.js +0 -1114
@@ -3,109 +3,14 @@ import {
3
3
  object2,
4
4
  fields2,
5
5
  id2,
6
- boundedJson2,
7
6
  validatePolicies2
8
7
  } from "./chunk-qt9m2kg2.js";
9
- import {
10
- DEFAULT_PAIRING_POLICY_REF
11
- } from "./chunk-5j0gj6w2.js";
12
- import {
13
- readRuntimeJson
14
- } from "./chunk-z7kkfrgz.js";
15
8
  import {
16
9
  CliError2
17
10
  } from "./chunk-hpzr94hm.js";
18
- import {
19
- privatePath,
20
- readPrivateBytes
21
- } from "./chunk-0y5542k8.js";
22
-
23
- // src/cli/setup-files.ts
24
- import {
25
- closeSync,
26
- fsyncSync,
27
- fchmodSync,
28
- linkSync,
29
- statSync,
30
- openSync,
31
- renameSync,
32
- unlinkSync,
33
- writeFileSync
34
- } from "fs";
35
- import { createHash, randomUUID } from "crypto";
36
- import { dirname, join } from "path";
37
- function setupFileStamp(path) {
38
- const bytes = readPrivateBytes(path, 16777216);
39
- try {
40
- return createHash("sha256").update(bytes).digest("hex");
41
- } finally {
42
- bytes.fill(0);
43
- }
44
- }
45
- function writeSetupFile(path, bytes, replace = false, expectedStamp) {
46
- privatePath(path);
47
- const previous = replace ? expectedStamp ?? setupFileStamp(path) : undefined;
48
- if (replace && setupFileStamp(path) !== previous) {
49
- throw new CliError2("config_changed");
50
- }
51
- const temporary = join(dirname(path), ".rovloom-setup-" + randomUUID() + ".tmp");
52
- let fd;
53
- let created = false;
54
- try {
55
- const mode = replace ? statSync(path).mode & 511 : 384;
56
- fd = openSync(temporary, "wx", mode);
57
- created = true;
58
- if (replace && process.platform !== "win32") {
59
- fchmodSync(fd, mode);
60
- }
61
- writeFileSync(fd, bytes);
62
- fsyncSync(fd);
63
- const complete = fd;
64
- fd = undefined;
65
- closeSync(complete);
66
- if (replace) {
67
- if (setupFileStamp(path) !== previous) {
68
- throw new CliError2("config_changed");
69
- }
70
- renameSync(temporary, path);
71
- } else {
72
- linkSync(temporary, path);
73
- unlinkSync(temporary);
74
- }
75
- created = false;
76
- } catch (error) {
77
- if (error instanceof CliError2) {
78
- throw error;
79
- }
80
- throw new CliError2("config_unreadable");
81
- } finally {
82
- try {
83
- if (fd !== undefined) {
84
- closeSync(fd);
85
- }
86
- } finally {
87
- if (created) {
88
- unlinkSync(temporary);
89
- }
90
- }
91
- }
92
- }
93
- function readSetupJson(path, maximum = 16384) {
94
- try {
95
- return readRuntimeJson(path, maximum);
96
- } catch (error) {
97
- if (error instanceof CliError2 && error.code === "backend_unavailable") {
98
- return;
99
- }
100
- throw error;
101
- }
102
- }
103
- function writeSetupJson(path, value, replace = false, maximum = 16384) {
104
- writeSetupFile(path, boundedJson2(value, maximum), replace);
105
- }
106
11
 
107
12
  // src/cli/token-registry.ts
108
- import { createHash as createHash2, randomBytes } from "crypto";
13
+ import { createHash, randomBytes } from "crypto";
109
14
  var REGISTRY_MAX_BYTES = 262144;
110
15
  var MAX_CALLERS = 64;
111
16
  var DEFAULT_TTL_DAYS = 30;
@@ -113,7 +18,7 @@ var DAY = 86400000;
113
18
  var HEX = /^[a-f0-9]{64}$/;
114
19
  var PRINCIPAL = /^[a-zA-Z0-9_-]{1,128}$/;
115
20
  function digestToken(token) {
116
- return createHash2("sha256").update(token).digest("hex");
21
+ return createHash("sha256").update(token).digest("hex");
117
22
  }
118
23
  function newToken() {
119
24
  return randomBytes(32).toString("base64url");
@@ -274,6 +179,9 @@ function createGatewayCaller(registry, principal, now, days = 365) {
274
179
  return { registry: { ...registry, callers: [...registry.callers, entry] }, token, expires_at };
275
180
  }
276
181
 
182
+ // src/pairing-policy.ts
183
+ var DEFAULT_PAIRING_POLICY_REF = "rovloom_setup_v1";
184
+
277
185
  // src/cli/admin-registry.ts
278
186
  var ADMIN_POLICY_REVISION = "rovloom_admin_v1";
279
187
  var MAX_ADMINS = 16;
@@ -374,6 +282,6 @@ function summarizeAdmins(management, now) {
374
282
  }));
375
283
  }
376
284
 
377
- export { setupFileStamp, writeSetupFile, readSetupJson, writeSetupJson, REGISTRY_MAX_BYTES, digestToken, parseRegistry, createCaller, setDiscardPermission, renewCaller, rotateCaller, revokeCaller, summarize, createGatewayCaller, DEFAULT_ADMIN_TTL_DAYS, emptyManagement, isAdminPlaceholder, issueAdmin, revokeAdmin, summarizeAdmins };
285
+ export { REGISTRY_MAX_BYTES, digestToken, parseRegistry, createCaller, setDiscardPermission, renewCaller, rotateCaller, revokeCaller, summarize, createGatewayCaller, DEFAULT_ADMIN_TTL_DAYS, emptyManagement, isAdminPlaceholder, issueAdmin, revokeAdmin, summarizeAdmins };
378
286
 
379
- //# debugId=69610EBBA61A8B4564756E2164756E21
287
+ //# debugId=96015426A0C339E864756E2164756E21
@@ -0,0 +1,66 @@
1
+ // @bun
2
+ import {
3
+ HERDR_WORKFLOW_METHODS
4
+ } from "./chunk-9tt13dm0.js";
5
+ import {
6
+ LUVUS_OPERATION_METHODS2
7
+ } from "./chunk-efty77sb.js";
8
+ import {
9
+ luvusMode,
10
+ CliError2
11
+ } from "./chunk-hpzr94hm.js";
12
+
13
+ // src/cli/setup-policy.ts
14
+ var SIMPLE_SETUP_ACTOR = "operator_simple_pairing";
15
+ var SIMPLE_SETUP_LINEAGE = "simple";
16
+ function setupSessions(input) {
17
+ if (input === undefined) {
18
+ return Object.freeze({});
19
+ }
20
+ const row = input;
21
+ if (row === null || typeof row !== "object" || Array.isArray(row) || Object.keys(row).some((key) => key !== "luvus") || row.luvus !== undefined && row.luvus !== "default" && row.luvus !== "rovloom") {
22
+ throw new CliError2("configuration_required");
23
+ }
24
+ return Object.freeze(row.luvus === undefined ? {} : { luvus: row.luvus });
25
+ }
26
+ function setupTarget(machine, kind = "luvus", sessions = {}) {
27
+ return {
28
+ machine_id: machine,
29
+ provider_id: kind,
30
+ profile: "session",
31
+ session: kind === "luvus" ? sessions.luvus ?? "rovloom" : "default"
32
+ };
33
+ }
34
+ function setupProviderKinds(input) {
35
+ if (!Array.isArray(input) || input.some((kind) => kind !== "luvus" && kind !== "herdr") || !["luvus", "herdr", "luvus,herdr"].includes(input.join(","))) {
36
+ throw new CliError2("configuration_required");
37
+ }
38
+ return Object.freeze([...input]);
39
+ }
40
+ function selectedSetupPolicies(plan, machine, kinds, sessions = {}) {
41
+ const grants = setupProviderKinds(kinds).map((kind) => ({
42
+ target: setupTarget(machine, kind, sessions),
43
+ methods: [...kind === "luvus" ? LUVUS_OPERATION_METHODS2 : HERDR_WORKFLOW_METHODS],
44
+ actions: ["dispatch", "read", "cancel"]
45
+ }));
46
+ return {
47
+ principal_id: plan.actor,
48
+ policies: {
49
+ caller: { revision: "setup_caller_" + (plan.lineage ?? plan.attempt_id), grants },
50
+ local: { revision: "setup_local_" + (plan.lineage ?? plan.attempt_id), grants: structuredClone(grants) }
51
+ }
52
+ };
53
+ }
54
+ function setupReference(attempt, kind = "luvus") {
55
+ return kind + "_" + attempt;
56
+ }
57
+ function setupSessionsFor(config) {
58
+ return Object.freeze({ luvus: luvusMode(config) === "attach" ? "default" : "rovloom" });
59
+ }
60
+ function simpleSetupAuthorization(machine, kinds, sessions = {}) {
61
+ return selectedSetupPolicies({ attempt_id: SIMPLE_SETUP_LINEAGE, actor: SIMPLE_SETUP_ACTOR, lineage: SIMPLE_SETUP_LINEAGE }, machine, kinds, sessions);
62
+ }
63
+
64
+ export { SIMPLE_SETUP_ACTOR, SIMPLE_SETUP_LINEAGE, setupSessions, setupTarget, setupProviderKinds, selectedSetupPolicies, setupReference, setupSessionsFor, simpleSetupAuthorization };
65
+
66
+ //# debugId=E4B9A88833E96D5764756E2164756E21
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  macosProcessState,
4
4
  windowsProcessState
5
- } from "./chunk-09f9q26d.js";
5
+ } from "./chunk-vdwzb63d.js";
6
6
 
7
7
  // src/storage/process-identity.ts
8
8
  import { connect } from "net";
@@ -22,21 +22,23 @@ import {
22
22
  SERVICE_ERROR_CODES,
23
23
  FacadeServiceError2,
24
24
  NativeRequestNotDispatchedError
25
- } from "./chunk-0dqx2mmz.js";
25
+ } from "./chunk-73aq2qkz.js";
26
26
  import {
27
- LuvusAdapterError2,
28
27
  terminalExecutionCatalog
29
- } from "./chunk-57ayxqnb.js";
28
+ } from "./chunk-8fy8w7ds.js";
30
29
  import {
31
30
  createLuvusCatalog2
32
- } from "./chunk-0xgpxdgc.js";
33
- import {
34
- NativeRequestPreflightError
35
- } from "./chunk-zj48jvfe.js";
31
+ } from "./chunk-bbdtsg4b.js";
36
32
  import {
37
33
  sampleManagementTransport2,
38
34
  createManagementTransportProjection2
39
35
  } from "./chunk-2tansfxf.js";
36
+ import {
37
+ NativeRequestPreflightError
38
+ } from "./chunk-xtvgm6kf.js";
39
+ import {
40
+ LuvusAdapterError2
41
+ } from "./chunk-pksaqt9a.js";
40
42
 
41
43
  // src/mcp/store-service.ts
42
44
  import { createHmac, randomBytes, timingSafeEqual } from "crypto";
@@ -989,4 +991,4 @@ class RuntimeGatewayService2 {
989
991
 
990
992
  export { resolveGatewayPrincipal, StoreGatewayService2, RuntimeGatewayService2 };
991
993
 
992
- //# debugId=13A7F49E5E901EE764756E2164756E21
994
+ //# debugId=045A814985626BAA64756E2164756E21
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  windowsInspectPath
4
- } from "./chunk-09f9q26d.js";
4
+ } from "./chunk-vdwzb63d.js";
5
5
  import {
6
6
  id2,
7
7
  boundedJson2,
@@ -10,10 +10,10 @@ import {
10
10
  import {
11
11
  LuvusAdapterError2,
12
12
  ConnectorCapacityError
13
- } from "./chunk-57ayxqnb.js";
13
+ } from "./chunk-pksaqt9a.js";
14
14
  import {
15
15
  currentProcessIdentity
16
- } from "./chunk-0pewfj89.js";
16
+ } from "./chunk-qp8tgms2.js";
17
17
  import {
18
18
  privatePath,
19
19
  privateFile,
@@ -1,7 +1,7 @@
1
1
  // @bun
2
2
  import {
3
3
  cliMessages2
4
- } from "./chunk-5b8g62kw.js";
4
+ } from "./chunk-pgs9jp6t.js";
5
5
  import {
6
6
  isRole,
7
7
  servicePlatform,
@@ -0,0 +1,30 @@
1
+ // @bun
2
+ import {
3
+ hasPairingState2,
4
+ retirePairingState2,
5
+ handleConnectorUnpair2
6
+ } from "./chunk-y8zm75jt.js";
7
+ import"./chunk-1xer1ent.js";
8
+ import"./chunk-8ykrqhxh.js";
9
+ import"./chunk-1bf0wmgk.js";
10
+ import"./chunk-z7kkfrgz.js";
11
+ import"./chunk-hpzr94hm.js";
12
+ import"./chunk-pgs9jp6t.js";
13
+ import"./chunk-sf4ztxba.js";
14
+ import"./chunk-3nnahj0j.js";
15
+ import"./chunk-h3xyq7zk.js";
16
+ import"./chunk-qp8tgms2.js";
17
+ import"./chunk-0y5542k8.js";
18
+ import"./chunk-vdwzb63d.js";
19
+ import"./chunk-g7pnjzkk.js";
20
+ import"./chunk-qt9m2kg2.js";
21
+ import"./chunk-9tt13dm0.js";
22
+ import"./chunk-7crhmqn2.js";
23
+ import"./chunk-d71r315c.js";
24
+ export {
25
+ handleConnectorUnpair2 as handleConnectorUnpair,
26
+ hasPairingState2 as hasPairingState,
27
+ retirePairingState2 as retirePairingState
28
+ };
29
+
30
+ //# debugId=4B1FD15DC6D4072D64756E2164756E21
@@ -414,6 +414,6 @@ function windowsProcessState(pid) {
414
414
  }
415
415
  }
416
416
 
417
- export { macosPeer, macosProcessState, macosProcessUid, macosProcessImage, macosProcessArgv, windowsCurrentUserSid, windowsInspectPath, windowsPipeServerPid, windowsProcessFacts, windowsProcessState };
417
+ export { macosPeer, macosProcessState, macosProcessUid, macosProcessImage, macosProcessArgv, windowsInspectPath, windowsPipeServerPid, windowsProcessFacts, windowsProcessState };
418
418
 
419
- //# debugId=24B541853D8128AB64756E2164756E21
419
+ //# debugId=792167EE7EF656EE64756E2164756E21
@@ -0,0 +1,48 @@
1
+ // @bun
2
+ import {
3
+ GatewayError2
4
+ } from "./chunk-d71r315c.js";
5
+ import {
6
+ createNativeValidator2
7
+ } from "./chunk-mqyq5jh6.js";
8
+ import {
9
+ luvusOperationDescriptor2,
10
+ luvusOperationValidation2
11
+ } from "./chunk-efty77sb.js";
12
+
13
+ // src/runtime/request-preflight.ts
14
+ class NativeRequestPreflightError extends GatewayError2 {
15
+ outcome = "not_dispatched";
16
+ constructor() {
17
+ super("native_request_invalid");
18
+ }
19
+ }
20
+ function createLuvusRequestPreflight(contract) {
21
+ const validator = createNativeValidator2(contract);
22
+ return (request) => {
23
+ const checked = validator.checkRequestShape(request);
24
+ if (!checked.ok) {
25
+ if (checked.error.code === "native_request_invalid") {
26
+ throw new NativeRequestPreflightError;
27
+ }
28
+ throw new GatewayError2(checked.error.code);
29
+ }
30
+ };
31
+ }
32
+ function luvusValidation(kind, request, options) {
33
+ if (kind !== "luvus" || !luvusOperationDescriptor2(request.method)) {
34
+ return options;
35
+ }
36
+ const required = luvusOperationValidation2(request.method);
37
+ if (options.validation === undefined) {
38
+ return { ...options, validation: required };
39
+ }
40
+ if (options.validation !== required) {
41
+ throw new NativeRequestPreflightError;
42
+ }
43
+ return options;
44
+ }
45
+
46
+ export { NativeRequestPreflightError, createLuvusRequestPreflight, luvusValidation };
47
+
48
+ //# debugId=B81CED09F0DF168264756E2164756E21
@@ -0,0 +1,157 @@
1
+ // @bun
2
+ import {
3
+ boundedJson2
4
+ } from "./chunk-qt9m2kg2.js";
5
+ import {
6
+ cliMessages2,
7
+ formatMessage2
8
+ } from "./chunk-pgs9jp6t.js";
9
+ import {
10
+ setupFileStamp,
11
+ writeSetupFile
12
+ } from "./chunk-1xer1ent.js";
13
+ import {
14
+ privateDirectory
15
+ } from "./chunk-8ykrqhxh.js";
16
+ import {
17
+ runtimeReference
18
+ } from "./chunk-z7kkfrgz.js";
19
+ import {
20
+ CliError2,
21
+ configDocument2,
22
+ readConfig2
23
+ } from "./chunk-hpzr94hm.js";
24
+ import {
25
+ LUVUS_CLAIMS_LOCK_FORMAT
26
+ } from "./chunk-sf4ztxba.js";
27
+ import {
28
+ recordedProcess,
29
+ ownedFile
30
+ } from "./chunk-h3xyq7zk.js";
31
+ import {
32
+ ownerIsDead
33
+ } from "./chunk-qp8tgms2.js";
34
+ import {
35
+ syncParentDirectory
36
+ } from "./chunk-0y5542k8.js";
37
+
38
+ // src/cli/unpair.ts
39
+ import { existsSync, lstatSync, readFileSync, renameSync } from "fs";
40
+ import { dirname, join } from "path";
41
+ var PAIRING_FILES = ["device", "pairing", "pairing-claim", "providers", "native-setup", "herdr-setup"];
42
+ var PAIRING_DIRECTORIES = ["control", "n", "h", "w", "hr"];
43
+ var CLAIM_LOCKS = ["control/luvus-claims.db.lock", "hr/control/claims.db.lock"];
44
+ function hasPairingState2(directory) {
45
+ return PAIRING_FILES.some((reference) => existsSync(runtimeReference(directory, reference))) || PAIRING_DIRECTORIES.some((name) => existsSync(join(directory, name)));
46
+ }
47
+ function entry(path) {
48
+ try {
49
+ const info = lstatSync(path);
50
+ if (info.isFile()) {
51
+ return "file";
52
+ }
53
+ return info.isDirectory() ? "directory" : undefined;
54
+ } catch (error) {
55
+ if (error.code === "ENOENT") {
56
+ return;
57
+ }
58
+ throw new CliError2("config_unreadable");
59
+ }
60
+ }
61
+ function assertConnectorIdle(stateDir) {
62
+ for (const name of CLAIM_LOCKS) {
63
+ const path = join(stateDir, name);
64
+ if (ownedFile(path) !== true) {
65
+ continue;
66
+ }
67
+ try {
68
+ const bytes = readFileSync(path);
69
+ if (bytes.length === 0 || bytes.length > 1024) {
70
+ continue;
71
+ }
72
+ const recorded = recordedProcess(JSON.parse(bytes.toString("utf8")), LUVUS_CLAIMS_LOCK_FORMAT);
73
+ if (recorded && !ownerIsDead(recorded)) {
74
+ throw new CliError2("configuration_required");
75
+ }
76
+ } catch (error) {
77
+ if (error instanceof CliError2) {
78
+ throw error;
79
+ }
80
+ }
81
+ }
82
+ }
83
+ function retireStamp(stateDir) {
84
+ const base = new Date().toISOString().replace(/[-:]/gu, "").replace(/\.\d+Z$/u, "Z");
85
+ for (let index = 0;; index++) {
86
+ const name = index === 0 ? base : base + "-" + index;
87
+ if (entry(join(stateDir, "retired", name)) === undefined) {
88
+ return name;
89
+ }
90
+ }
91
+ }
92
+ function retirePairingState2(config, console) {
93
+ console.assertOwner();
94
+ assertConnectorIdle(config.state_dir);
95
+ const moves = [];
96
+ const root = join(config.state_dir, "retired", retireStamp(config.state_dir));
97
+ for (const reference of PAIRING_FILES) {
98
+ const source = runtimeReference(config.state_dir, reference);
99
+ if (entry(source) === "file") {
100
+ moves.push({ source, target: join(root, "managed", reference + ".json") });
101
+ }
102
+ }
103
+ for (const name of PAIRING_DIRECTORIES) {
104
+ const source = join(config.state_dir, name);
105
+ if (entry(source) === "directory") {
106
+ moves.push({ source, target: join(root, name) });
107
+ }
108
+ }
109
+ if (moves.length === 0) {
110
+ return;
111
+ }
112
+ try {
113
+ privateDirectory(join(config.state_dir, "retired"));
114
+ privateDirectory(root);
115
+ for (const move of moves) {
116
+ privateDirectory(dirname(move.target));
117
+ renameSync(move.source, move.target);
118
+ syncParentDirectory(move.target);
119
+ syncParentDirectory(move.source);
120
+ }
121
+ } catch (error) {
122
+ throw error instanceof CliError2 ? error : new CliError2("config_unreadable");
123
+ }
124
+ return root;
125
+ }
126
+ async function handleConnectorUnpair2(path, io) {
127
+ const config = readConfig2(path);
128
+ if (config.role !== "connector") {
129
+ throw new CliError2("config_role_mismatch");
130
+ }
131
+ if (io.signal.aborted) {
132
+ return 0;
133
+ }
134
+ const console = {
135
+ io,
136
+ show: (text) => {
137
+ io.stderr.write(text);
138
+ },
139
+ confirm: async () => true,
140
+ assertOwner: () => {}
141
+ };
142
+ const retired = retirePairingState2(config, console);
143
+ privateDirectory(join(config.state_dir, "managed"));
144
+ if (config.gateway_url !== "" || retired !== undefined) {
145
+ if (boundedJson2(configDocument2(readConfig2(path))) !== boundedJson2(configDocument2(config))) {
146
+ throw new CliError2("config_changed");
147
+ }
148
+ writeSetupFile(path, JSON.stringify({ ...configDocument2(config), gateway: { url: "" } }, null, 2) + `
149
+ `, true, setupFileStamp(path));
150
+ }
151
+ io.stderr.write(retired === undefined ? cliMessages2(io.language)["unpair.empty"] : formatMessage2(cliMessages2(io.language)["unpair.completed"], { retired }));
152
+ return 0;
153
+ }
154
+
155
+ export { hasPairingState2, retirePairingState2, handleConnectorUnpair2 };
156
+
157
+ //# debugId=3C1C123FA665D9EE64756E2164756E21