sigild 0.0.8 → 0.0.9

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 (118) hide show
  1. package/README.md +74 -22
  2. package/THREAT_MODEL.md +6 -4
  3. package/dist/src/bin/sigil-mcp.js +59 -16
  4. package/dist/src/bin/sigil-mcp.js.map +1 -1
  5. package/dist/src/cli/index.d.ts +2 -2
  6. package/dist/src/cli/index.d.ts.map +1 -1
  7. package/dist/src/cli/index.js.map +1 -1
  8. package/dist/src/cli/main.d.ts.map +1 -1
  9. package/dist/src/cli/main.js +10 -8
  10. package/dist/src/cli/main.js.map +1 -1
  11. package/dist/src/cli/paths.d.ts +15 -5
  12. package/dist/src/cli/paths.d.ts.map +1 -1
  13. package/dist/src/cli/paths.js +11 -1
  14. package/dist/src/cli/paths.js.map +1 -1
  15. package/dist/src/cli/portal.d.ts +3 -0
  16. package/dist/src/cli/portal.d.ts.map +1 -1
  17. package/dist/src/cli/portal.js +7 -1
  18. package/dist/src/cli/portal.js.map +1 -1
  19. package/dist/src/cli/status.d.ts +15 -12
  20. package/dist/src/cli/status.d.ts.map +1 -1
  21. package/dist/src/cli/status.js +17 -30
  22. package/dist/src/cli/status.js.map +1 -1
  23. package/dist/src/cli/unlock.d.ts +15 -15
  24. package/dist/src/cli/unlock.d.ts.map +1 -1
  25. package/dist/src/cli/unlock.js +83 -60
  26. package/dist/src/cli/unlock.js.map +1 -1
  27. package/dist/src/confirm/ack-server.d.ts +53 -0
  28. package/dist/src/confirm/ack-server.d.ts.map +1 -0
  29. package/dist/src/confirm/ack-server.js +87 -0
  30. package/dist/src/confirm/ack-server.js.map +1 -0
  31. package/dist/src/confirm/config.d.ts +54 -0
  32. package/dist/src/confirm/config.d.ts.map +1 -0
  33. package/dist/src/confirm/config.js +139 -0
  34. package/dist/src/confirm/config.js.map +1 -0
  35. package/dist/src/confirm/gate.d.ts +38 -0
  36. package/dist/src/confirm/gate.d.ts.map +1 -0
  37. package/dist/src/confirm/gate.js +66 -0
  38. package/dist/src/confirm/gate.js.map +1 -0
  39. package/dist/src/confirm/index.d.ts +6 -0
  40. package/dist/src/confirm/index.d.ts.map +1 -0
  41. package/dist/src/confirm/index.js +5 -0
  42. package/dist/src/confirm/index.js.map +1 -0
  43. package/dist/src/confirm/ntfy.d.ts +38 -0
  44. package/dist/src/confirm/ntfy.d.ts.map +1 -0
  45. package/dist/src/confirm/ntfy.js +47 -0
  46. package/dist/src/confirm/ntfy.js.map +1 -0
  47. package/dist/src/confirm/types.d.ts +66 -0
  48. package/dist/src/confirm/types.d.ts.map +1 -0
  49. package/dist/src/confirm/types.js +12 -0
  50. package/dist/src/confirm/types.js.map +1 -0
  51. package/dist/src/control/broadcast.d.ts +29 -0
  52. package/dist/src/control/broadcast.d.ts.map +1 -0
  53. package/dist/src/control/broadcast.js +88 -0
  54. package/dist/src/control/broadcast.js.map +1 -0
  55. package/dist/src/control/client.d.ts.map +1 -1
  56. package/dist/src/control/client.js +4 -1
  57. package/dist/src/control/client.js.map +1 -1
  58. package/dist/src/control/index.d.ts +1 -0
  59. package/dist/src/control/index.d.ts.map +1 -1
  60. package/dist/src/control/index.js +1 -0
  61. package/dist/src/control/index.js.map +1 -1
  62. package/dist/src/control/protocol.d.ts +5 -1
  63. package/dist/src/control/protocol.d.ts.map +1 -1
  64. package/dist/src/control/protocol.js +2 -1
  65. package/dist/src/control/protocol.js.map +1 -1
  66. package/dist/src/control/server.js +6 -6
  67. package/dist/src/control/server.js.map +1 -1
  68. package/dist/src/daemon/handles.d.ts +3 -0
  69. package/dist/src/daemon/handles.d.ts.map +1 -1
  70. package/dist/src/daemon/handles.js +3 -1
  71. package/dist/src/daemon/handles.js.map +1 -1
  72. package/dist/src/daemon/methods.d.ts +13 -3
  73. package/dist/src/daemon/methods.d.ts.map +1 -1
  74. package/dist/src/daemon/methods.js +121 -16
  75. package/dist/src/daemon/methods.js.map +1 -1
  76. package/dist/src/mcp/server.d.ts +14 -2
  77. package/dist/src/mcp/server.d.ts.map +1 -1
  78. package/dist/src/mcp/server.js +28 -14
  79. package/dist/src/mcp/server.js.map +1 -1
  80. package/dist/src/mcp/tools.d.ts +1 -1
  81. package/dist/src/mcp/tools.d.ts.map +1 -1
  82. package/dist/src/mcp/tools.js +37 -3
  83. package/dist/src/mcp/tools.js.map +1 -1
  84. package/dist/src/policy/evaluate.d.ts +10 -4
  85. package/dist/src/policy/evaluate.d.ts.map +1 -1
  86. package/dist/src/policy/evaluate.js +161 -20
  87. package/dist/src/policy/evaluate.js.map +1 -1
  88. package/dist/src/policy/loader.d.ts.map +1 -1
  89. package/dist/src/policy/loader.js +70 -0
  90. package/dist/src/policy/loader.js.map +1 -1
  91. package/dist/src/policy/template.d.ts +1 -1
  92. package/dist/src/policy/template.d.ts.map +1 -1
  93. package/dist/src/policy/template.js +30 -0
  94. package/dist/src/policy/template.js.map +1 -1
  95. package/dist/src/policy/types.d.ts +53 -3
  96. package/dist/src/policy/types.d.ts.map +1 -1
  97. package/dist/src/policy/types.js.map +1 -1
  98. package/dist/src/svm/address.d.ts +14 -0
  99. package/dist/src/svm/address.d.ts.map +1 -0
  100. package/dist/src/svm/address.js +18 -0
  101. package/dist/src/svm/address.js.map +1 -0
  102. package/dist/src/svm/base58.d.ts +15 -0
  103. package/dist/src/svm/base58.d.ts.map +1 -0
  104. package/dist/src/svm/base58.js +60 -0
  105. package/dist/src/svm/base58.js.map +1 -0
  106. package/dist/src/svm/ed25519.d.ts +19 -0
  107. package/dist/src/svm/ed25519.d.ts.map +1 -0
  108. package/dist/src/svm/ed25519.js +32 -0
  109. package/dist/src/svm/ed25519.js.map +1 -0
  110. package/dist/src/svm/index.d.ts +5 -0
  111. package/dist/src/svm/index.d.ts.map +1 -0
  112. package/dist/src/svm/index.js +5 -0
  113. package/dist/src/svm/index.js.map +1 -0
  114. package/dist/src/svm/transaction.d.ts +56 -0
  115. package/dist/src/svm/transaction.d.ts.map +1 -0
  116. package/dist/src/svm/transaction.js +182 -0
  117. package/dist/src/svm/transaction.js.map +1 -0
  118. package/package.json +2 -1
@@ -0,0 +1,139 @@
1
+ import { readdirSync, readFileSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import toml from '@iarna/toml';
4
+ import { parsePolicy, PolicyLoadError } from '../policy/index.js';
5
+ export class SigilConfigError extends Error {
6
+ constructor(message) {
7
+ super(message);
8
+ this.name = 'SigilConfigError';
9
+ }
10
+ }
11
+ /**
12
+ * Parse the file contents (an empty string is treated as "no file").
13
+ * Exported for tests; production loaders should use `loadConfig` so the
14
+ * file-not-found case is handled uniformly.
15
+ */
16
+ export function parseConfig(source) {
17
+ if (source.trim() === '')
18
+ return {};
19
+ let raw;
20
+ try {
21
+ raw = toml.parse(source);
22
+ }
23
+ catch (err) {
24
+ throw new SigilConfigError(`config: invalid TOML — ${err.message}`);
25
+ }
26
+ const out = {};
27
+ const confirmRaw = raw['confirm'];
28
+ if (confirmRaw === undefined)
29
+ return out;
30
+ if (!isObject(confirmRaw)) {
31
+ throw new SigilConfigError(`config.confirm must be a table`);
32
+ }
33
+ const confirm = {};
34
+ const timeoutMs = confirmRaw['timeout_ms'];
35
+ if (timeoutMs !== undefined) {
36
+ if (typeof timeoutMs !== 'number' || !Number.isInteger(timeoutMs) || timeoutMs <= 0) {
37
+ throw new SigilConfigError(`config.confirm.timeout_ms must be a positive integer (got ${JSON.stringify(timeoutMs)})`);
38
+ }
39
+ confirm.timeoutMs = timeoutMs;
40
+ }
41
+ const ntfyRaw = confirmRaw['ntfy'];
42
+ if (ntfyRaw !== undefined) {
43
+ if (!isObject(ntfyRaw)) {
44
+ throw new SigilConfigError(`config.confirm.ntfy must be a table`);
45
+ }
46
+ const topic = ntfyRaw['topic'];
47
+ if (typeof topic !== 'string' || topic.length === 0) {
48
+ throw new SigilConfigError(`config.confirm.ntfy.topic is required and must be a string`);
49
+ }
50
+ const server = ntfyRaw['server'];
51
+ if (server !== undefined && typeof server !== 'string') {
52
+ throw new SigilConfigError(`config.confirm.ntfy.server must be a string if set`);
53
+ }
54
+ confirm.ntfy = server !== undefined ? { topic, server } : { topic };
55
+ }
56
+ if (confirm.timeoutMs !== undefined || confirm.ntfy !== undefined) {
57
+ out.confirm = confirm;
58
+ }
59
+ return out;
60
+ }
61
+ /**
62
+ * Load + parse the file at ~/.sigil/config.toml. Returns an empty config if
63
+ * the file is absent. Throws SigilConfigError on parse/schema errors.
64
+ */
65
+ export function loadConfig(path) {
66
+ let source;
67
+ try {
68
+ source = readFileSync(path, 'utf8');
69
+ }
70
+ catch (err) {
71
+ if (err.code === 'ENOENT')
72
+ return {};
73
+ throw new SigilConfigError(`config: failed to read ${path}: ${err.message}`);
74
+ }
75
+ return parseConfig(source);
76
+ }
77
+ /**
78
+ * Walk every *.toml under the policy dir, parse each, and return true if
79
+ * any of them sets require_confirm_above_wei. A malformed policy file is
80
+ * skipped (it'll surface its own error at sign time); we only need to know
81
+ * whether some portal is *trying* to gate on confirm.
82
+ */
83
+ export function anyPolicyRequiresConfirm(policyDir) {
84
+ let entries;
85
+ try {
86
+ entries = readdirSync(policyDir);
87
+ }
88
+ catch (err) {
89
+ if (err.code === 'ENOENT')
90
+ return false;
91
+ throw err;
92
+ }
93
+ for (const f of entries) {
94
+ if (!f.endsWith('.toml'))
95
+ continue;
96
+ let source;
97
+ try {
98
+ source = readFileSync(join(policyDir, f), 'utf8');
99
+ }
100
+ catch {
101
+ continue;
102
+ }
103
+ try {
104
+ const p = parsePolicy(source);
105
+ if (p.requireConfirmAboveWei !== undefined)
106
+ return true;
107
+ }
108
+ catch (err) {
109
+ // Malformed policy file — not our problem here; the sign path will
110
+ // raise PolicyLoadError when this portal is used. Skip.
111
+ if (err instanceof PolicyLoadError)
112
+ continue;
113
+ throw err;
114
+ }
115
+ }
116
+ return false;
117
+ }
118
+ /**
119
+ * Fail-closed check called at sigil-mcp boot: if any policy on disk uses
120
+ * require_confirm_above_wei but the config has no transport, the process
121
+ * cannot honour that policy — bail with a clear message instead of running
122
+ * with a half-built safety net.
123
+ */
124
+ export function enforceConfirmTransportPresence(config, policyDir) {
125
+ const needsTransport = anyPolicyRequiresConfirm(policyDir);
126
+ if (!needsTransport)
127
+ return;
128
+ const haveTransport = config.confirm?.ntfy !== undefined;
129
+ if (haveTransport)
130
+ return;
131
+ throw new SigilConfigError(`at least one portal policy in ${policyDir} sets require_confirm_above_wei, ` +
132
+ `but no OOB confirm transport is configured. ` +
133
+ `Add a [confirm.ntfy] block to ~/.sigil/config.toml with a topic, ` +
134
+ `or remove require_confirm_above_wei from the affected policy files.`);
135
+ }
136
+ function isObject(v) {
137
+ return typeof v === 'object' && v !== null && !Array.isArray(v);
138
+ }
139
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/confirm/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,IAAI,MAAM,aAAa,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AA8BlE,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACxC,IAAI,MAAM,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,EAAE,CAAC;IACpC,IAAI,GAAiB,CAAC;IACtB,IAAI,CAAC;QACH,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC3B,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,IAAI,gBAAgB,CAAC,0BAA2B,GAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IACjF,CA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Ac,CAAC;QACnB,IAAI,CAAC;YACH,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QACpD,CAAC;QAAC,MAAM,CAAC;YACP,SAAS;QACX,CAAC;QACD,IAAI,CAAC;YACH,MAAM,CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC;YAC9B,IAAI,CAAC,CAAC,sBAAsB,KAAK,SAAS;gBAAE,OAAO,IAAI,CAAC;QAC1D,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,mEAAmE;YACnE,wDAAwD;YACxD,IAAI,GAAG,YAAY,eAAe;gBAAE,SAAS;YAC7C,MAAM,GAAG,CAAC;QACZ,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,+BAA+B,CAC7C,MAAmB,EACnB,SAAiB;IAEjB,MAAM,cAAc,GAAG,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAC3D,IAAI,CAAC,cAAc;QAAE,OAAO;IAC5B,MAAM,aAAa,GAAG,MAAM,CAAC,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC;IACzD,IAAI,aAAa;QAAE,OAAO;IAC1B,MAAM,IAAI,gBAAgB,CACxB,iCAAiC,SAAS,mCAAmC;QAC7E,8CAA8C;QAC9C,mEAAmE;QACnE,qEAAqE,CACtE,CAAC;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,CAAU;IAC1B,OAAO,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { AckServer } from './ack-server.js';
2
+ import type { ConfirmDecision, ConfirmTransport } from './types.js';
3
+ export interface ConfirmGateOpts {
4
+ /** Pluggable transport — ntfy in production; mock in tests. */
5
+ transport: ConfirmTransport;
6
+ /** Shared local ack server (one per process). */
7
+ ackServer: AckServer;
8
+ /** Per-portal override comes from policy; this is the cross-portal default.
9
+ * Configurable so tests can use ms-scale timeouts without slowing the suite. */
10
+ timeoutMs?: number;
11
+ }
12
+ /**
13
+ * The OOB confirm gate. Mints a token, pushes the prompt over the transport,
14
+ * races the human's click against a timeout, returns the decision.
15
+ *
16
+ * Failure modes (all map to a final ConfirmDecision):
17
+ * - transport.send() throws → `transport_error` (gate doesn't fall
18
+ * back to silently allowing the sign;
19
+ * the caller maps this to RPC_POLICY_DENIED)
20
+ * - human clicks Approve / Deny → `approved` / `denied`
21
+ * - clock runs out → `timeout` (cancels the token so a late
22
+ * click returns 410 Gone instead of being
23
+ * silently absorbed)
24
+ *
25
+ * Concurrent requests are isolated: each call mints its own token, the ack
26
+ * server matches by token, so two pending confirms cannot cross-resolve.
27
+ */
28
+ export declare class ConfirmGate {
29
+ #private;
30
+ constructor(opts: ConfirmGateOpts);
31
+ /** Transport name — used for audit log + startup banner. */
32
+ get transportName(): string;
33
+ request(input: {
34
+ portal: string;
35
+ summary: string;
36
+ }): Promise<ConfirmDecision>;
37
+ }
38
+ //# sourceMappingURL=gate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gate.d.ts","sourceRoot":"","sources":["../../../src/confirm/gate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEpE,MAAM,WAAW,eAAe;IAC9B,+DAA+D;IAC/D,SAAS,EAAE,gBAAgB,CAAC;IAC5B,iDAAiD;IACjD,SAAS,EAAE,SAAS,CAAC;IACrB;qFACiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,WAAW;;gBAKV,IAAI,EAAE,eAAe;IAMjC,4DAA4D;IAC5D,IAAI,aAAa,IAAI,MAAM,CAE1B;IAEK,OAAO,CAAC,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,CAAC;CAmCpF"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * The OOB confirm gate. Mints a token, pushes the prompt over the transport,
3
+ * races the human's click against a timeout, returns the decision.
4
+ *
5
+ * Failure modes (all map to a final ConfirmDecision):
6
+ * - transport.send() throws → `transport_error` (gate doesn't fall
7
+ * back to silently allowing the sign;
8
+ * the caller maps this to RPC_POLICY_DENIED)
9
+ * - human clicks Approve / Deny → `approved` / `denied`
10
+ * - clock runs out → `timeout` (cancels the token so a late
11
+ * click returns 410 Gone instead of being
12
+ * silently absorbed)
13
+ *
14
+ * Concurrent requests are isolated: each call mints its own token, the ack
15
+ * server matches by token, so two pending confirms cannot cross-resolve.
16
+ */
17
+ export class ConfirmGate {
18
+ #transport;
19
+ #ackServer;
20
+ #timeoutMs;
21
+ constructor(opts) {
22
+ this.#transport = opts.transport;
23
+ this.#ackServer = opts.ackServer;
24
+ this.#timeoutMs = opts.timeoutMs ?? 60_000;
25
+ }
26
+ /** Transport name — used for audit log + startup banner. */
27
+ get transportName() {
28
+ return this.#transport.name;
29
+ }
30
+ async request(input) {
31
+ const { token, approveUrl, denyUrl, settled } = this.#ackServer.pending();
32
+ try {
33
+ await this.#transport.send({
34
+ portal: input.portal,
35
+ summary: input.summary,
36
+ approveUrl,
37
+ denyUrl,
38
+ token,
39
+ });
40
+ }
41
+ catch (err) {
42
+ this.#ackServer.cancel(token);
43
+ return { kind: 'transport_error', message: err.message };
44
+ }
45
+ // Race the click against the timeout. We use a unique sentinel rather
46
+ // than null so that an Outcome of falsy value (no such thing today, but
47
+ // future-proofing) doesn't get misread as a timeout.
48
+ const TIMEOUT = Symbol('confirm-timeout');
49
+ let timer;
50
+ const timeoutP = new Promise((resolve) => {
51
+ timer = setTimeout(() => resolve(TIMEOUT), this.#timeoutMs);
52
+ // Don't keep the event loop alive just for the timeout — sigil-mcp
53
+ // exits when stdin closes, and a hanging timeout would prevent that.
54
+ timer.unref?.();
55
+ });
56
+ const winner = await Promise.race([settled, timeoutP]);
57
+ if (timer)
58
+ clearTimeout(timer);
59
+ if (winner === TIMEOUT) {
60
+ this.#ackServer.cancel(token);
61
+ return { kind: 'timeout' };
62
+ }
63
+ return winner === 'approve' ? { kind: 'approved' } : { kind: 'denied' };
64
+ }
65
+ }
66
+ //# sourceMappingURL=gate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gate.js","sourceRoot":"","sources":["../../../src/confirm/gate.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,OAAO,WAAW;IACb,UAAU,CAAmB;IAC7B,UAAU,CAAY;IACtB,UAAU,CAAS;IAE5B,YAAY,IAAqB;QAC/B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,SAAS,IAAI,MAAM,CAAC;IAC7C,CAAC;IAED,4DAA4D;IAC5D,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAA0C;QACtD,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;QAC1E,IAAI,CAAC;YACH,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;gBACzB,MAAM,EAAE,KAAK,CAAC,MAAM;gBACpB,OAAO,EAAE,KAAK,CAAC,OAAO;gBACtB,UAAU;gBACV,OAAO;gBACP,KAAK;aACN,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC9B,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,EAAG,GAAa,CAAC,OAAO,EAAE,CAAC;QACtE,CAAC;QAED,sEAAsE;QACtE,wEAAwE;QACxE,qDAAqD;QACrD,MAAM,OAAO,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;QAC1C,IAAI,KAAiC,CAAC;QACtC,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAiB,CAAC,OAAO,EAAE,EAAE;YACvD,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;YAC5D,mEAAmE;YACnE,qEAAqE;YACrE,KAAK,CAAC,KAAK,EAAE,EAAE,CAAC;QAClB,CAAC,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,CAAC;QACvD,IAAI,KAAK;YAAE,YAAY,CAAC,KAAK,CAAC,CAAC;QAE/B,IAAI,MAAM,KAAK,OAAO,EAAE,CAAC;YACvB,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC9B,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC7B,CAAC;QACD,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAC1E,CAAC;CACF"}
@@ -0,0 +1,6 @@
1
+ export { type ConfirmRequest, type ConfirmDecision, type ConfirmTransport, } from './types.js';
2
+ export { NtfyTransport, type NtfyConfig, type FetchLike } from './ntfy.js';
3
+ export { startAckServer, type AckServer, type AckOutcome, } from './ack-server.js';
4
+ export { ConfirmGate, type ConfirmGateOpts } from './gate.js';
5
+ export { type SigilConfig, type ConfirmConfig, type NtfyConfigToml, SigilConfigError, parseConfig, loadConfig, anyPolicyRequiresConfirm, enforceConfirmTransportPresence, } from './config.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/confirm/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,GACtB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,KAAK,UAAU,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAC3E,OAAO,EACL,cAAc,EACd,KAAK,SAAS,EACd,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,wBAAwB,EACxB,+BAA+B,GAChC,MAAM,aAAa,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { NtfyTransport } from './ntfy.js';
2
+ export { startAckServer, } from './ack-server.js';
3
+ export { ConfirmGate } from './gate.js';
4
+ export { SigilConfigError, parseConfig, loadConfig, anyPolicyRequiresConfirm, enforceConfirmTransportPresence, } from './config.js';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/confirm/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAmC,MAAM,WAAW,CAAC;AAC3E,OAAO,EACL,cAAc,GAGf,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,WAAW,EAAwB,MAAM,WAAW,CAAC;AAC9D,OAAO,EAIL,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,wBAAwB,EACxB,+BAA+B,GAChC,MAAM,aAAa,CAAC"}
@@ -0,0 +1,38 @@
1
+ import type { ConfirmRequest, ConfirmTransport } from './types.js';
2
+ export interface NtfyConfig {
3
+ /** Topic name — appears as the last path segment of the ntfy URL. The
4
+ * topic name IS the credential on ntfy.sh; pick something unguessable. */
5
+ topic: string;
6
+ /** Base URL, default https://ntfy.sh. Override to point at a self-hosted
7
+ * ntfy instance (e.g. https://ntfy.example.com). No trailing slash. */
8
+ server?: string;
9
+ }
10
+ /** Minimal subset of the fetch API surface we use. Lets tests inject a stub
11
+ * without dragging in undici/MSW. */
12
+ export type FetchLike = (url: string, init: {
13
+ method: 'POST';
14
+ headers: Record<string, string>;
15
+ body?: string;
16
+ }) => Promise<{
17
+ ok: boolean;
18
+ status: number;
19
+ statusText: string;
20
+ }>;
21
+ /**
22
+ * ntfy.sh transport. Publish-only — the user's phone subscribes through the
23
+ * ntfy app, taps an action button, and the click round-trips to sigil's
24
+ * local ack server. We never read from ntfy.
25
+ *
26
+ * Headers we use (all per ntfy docs):
27
+ * Title: portal handle
28
+ * Priority: high (default 4) — bypasses Android Doze + iOS quiet hours
29
+ * Click: approveUrl — tapping the body of the notification approves
30
+ * Actions: http,Approve,<approveUrl>; http,Deny,<denyUrl>
31
+ */
32
+ export declare class NtfyTransport implements ConfirmTransport {
33
+ #private;
34
+ readonly name = "ntfy";
35
+ constructor(config: NtfyConfig, fetchImpl?: FetchLike);
36
+ send(req: ConfirmRequest): Promise<void>;
37
+ }
38
+ //# sourceMappingURL=ntfy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ntfy.d.ts","sourceRoot":"","sources":["../../../src/confirm/ntfy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnE,MAAM,WAAW,UAAU;IACzB;+EAC2E;IAC3E,KAAK,EAAE,MAAM,CAAC;IACd;4EACwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;sCACsC;AACtC,MAAM,MAAM,SAAS,GAAG,CACtB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,KACrE,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAElE;;;;;;;;;;GAUG;AACH,qBAAa,aAAc,YAAW,gBAAgB;;IACpD,QAAQ,CAAC,IAAI,UAAU;gBAIX,MAAM,EAAE,UAAU,EAAE,SAAS,GAAE,SAAoD;IAazF,IAAI,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAoB/C"}
@@ -0,0 +1,47 @@
1
+ /**
2
+ * ntfy.sh transport. Publish-only — the user's phone subscribes through the
3
+ * ntfy app, taps an action button, and the click round-trips to sigil's
4
+ * local ack server. We never read from ntfy.
5
+ *
6
+ * Headers we use (all per ntfy docs):
7
+ * Title: portal handle
8
+ * Priority: high (default 4) — bypasses Android Doze + iOS quiet hours
9
+ * Click: approveUrl — tapping the body of the notification approves
10
+ * Actions: http,Approve,<approveUrl>; http,Deny,<denyUrl>
11
+ */
12
+ export class NtfyTransport {
13
+ name = 'ntfy';
14
+ #url;
15
+ #fetch;
16
+ constructor(config, fetchImpl = globalThis.fetch) {
17
+ const server = (config.server ?? 'https://ntfy.sh').replace(/\/+$/, '');
18
+ if (!/^[A-Za-z0-9_\-]+$/.test(config.topic)) {
19
+ // ntfy permits more, but a stricter pattern catches "user pasted the full
20
+ // URL into the topic field" right at construction time.
21
+ throw new Error(`ntfy topic must match [A-Za-z0-9_-]+ (got ${JSON.stringify(config.topic)})`);
22
+ }
23
+ this.#url = `${server}/${config.topic}`;
24
+ this.#fetch = fetchImpl;
25
+ }
26
+ async send(req) {
27
+ const actions = [
28
+ `http, Approve, ${req.approveUrl}, method=POST, clear=true`,
29
+ `http, Deny, ${req.denyUrl}, method=POST, clear=true`,
30
+ ].join('; ');
31
+ const resp = await this.#fetch(this.#url, {
32
+ method: 'POST',
33
+ headers: {
34
+ 'Title': `sigil — ${req.portal}`,
35
+ 'Priority': 'high',
36
+ 'Click': req.approveUrl,
37
+ 'Actions': actions,
38
+ 'Content-Type': 'text/plain; charset=utf-8',
39
+ },
40
+ body: req.summary,
41
+ });
42
+ if (!resp.ok) {
43
+ throw new Error(`ntfy push failed: HTTP ${resp.status} ${resp.statusText}`);
44
+ }
45
+ }
46
+ }
47
+ //# sourceMappingURL=ntfy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ntfy.js","sourceRoot":"","sources":["../../../src/confirm/ntfy.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;GAUG;AACH,MAAM,OAAO,aAAa;IACf,IAAI,GAAG,MAAM,CAAC;IACd,IAAI,CAAS;IACb,MAAM,CAAY;IAE3B,YAAY,MAAkB,EAAE,YAAuB,UAAU,CAAC,KAA6B;QAC7F,MAAM,MAAM,GAAG,CAAC,MAAM,CAAC,MAAM,IAAI,iBAAiB,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACxE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5C,0EAA0E;YAC1E,wDAAwD;YACxD,MAAM,IAAI,KAAK,CACb,6CAA6C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAC7E,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,GAAG,MAAM,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;QACxC,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,GAAmB;QAC5B,MAAM,OAAO,GAAG;YACd,kBAAkB,GAAG,CAAC,UAAU,2BAA2B;YAC3D,eAAe,GAAG,CAAC,OAAO,2BAA2B;SACtD,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACb,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE;YACxC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,OAAO,EAAE,WAAW,GAAG,CAAC,MAAM,EAAE;gBAChC,UAAU,EAAE,MAAM;gBAClB,OAAO,EAAE,GAAG,CAAC,UAAU;gBACvB,SAAS,EAAE,OAAO;gBAClB,cAAc,EAAE,2BAA2B;aAC5C;YACD,IAAI,EAAE,GAAG,CAAC,OAAO;SAClB,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACb,MAAM,IAAI,KAAK,CAAC,0BAA0B,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Out-of-band confirmation: when a sign request crosses the policy's confirm
3
+ * threshold, sigil pushes a notification to a channel the human controls
4
+ * (not the agent) and waits for an explicit human ack before signing.
5
+ *
6
+ * The transport interface is intentionally tiny. The shared ack mechanism
7
+ * (a localhost HTTP listener that resolves clicks) lives in ack-server.ts
8
+ * and isn't a per-transport concern — every transport just emits a
9
+ * notification carrying the two URLs.
10
+ */
11
+ /**
12
+ * A pending sign request that needs an out-of-band human ack. The transport
13
+ * is told about it via `send`; the human resolves it by hitting one of the
14
+ * two URLs from a device the agent process can't reach.
15
+ *
16
+ * `token` is opaque to the transport — it's already baked into approveUrl
17
+ * and denyUrl. The transport may surface it (e.g. for logging) but should
18
+ * not transmit it separately, since the URLs are the only thing the ack
19
+ * server matches against.
20
+ */
21
+ export interface ConfirmRequest {
22
+ /** Portal handle, e.g. "evm:executor". Used as the notification title. */
23
+ portal: string;
24
+ /** One-line description of what's about to be signed. Comes from the policy
25
+ * evaluator. Safe to put in the push body — does not include key material. */
26
+ summary: string;
27
+ /** Full URL the human clicks (or taps) to approve. Hits the ack server on
28
+ * 127.0.0.1; the token in the query string is single-use + request-bound. */
29
+ approveUrl: string;
30
+ /** Same shape, deny path. */
31
+ denyUrl: string;
32
+ /** Token (also embedded in the URLs above). Exposed for transports that
33
+ * want to log/correlate without parsing URLs. */
34
+ token: string;
35
+ }
36
+ /**
37
+ * Implementation contract. Transports just push the prompt — the ack
38
+ * round-trips back through the local HTTP server, not through the transport.
39
+ *
40
+ * Implementations should reject with a thrown Error on transport failure
41
+ * (network down, push provider 5xx, etc). The gate treats any throw as a
42
+ * push failure and surfaces it as a deny (fail-closed): we'd rather decline
43
+ * the sign than silently let it through because the notification didn't
44
+ * reach the human's phone.
45
+ */
46
+ export interface ConfirmTransport {
47
+ /** Short identifier — used in audit log + startup banner. */
48
+ readonly name: string;
49
+ send(req: ConfirmRequest): Promise<void>;
50
+ }
51
+ /**
52
+ * Outcome of a confirm round-trip. The gate returns one of these; the sign
53
+ * method then either proceeds (approved) or throws RPC_POLICY_DENIED with
54
+ * the appropriate reason (denied | timeout | transport_error).
55
+ */
56
+ export type ConfirmDecision = {
57
+ kind: 'approved';
58
+ } | {
59
+ kind: 'denied';
60
+ } | {
61
+ kind: 'timeout';
62
+ } | {
63
+ kind: 'transport_error';
64
+ message: string;
65
+ };
66
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/confirm/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf;mFAC+E;IAC/E,OAAO,EAAE,MAAM,CAAC;IAChB;kFAC8E;IAC9E,UAAU,EAAE,MAAM,CAAC;IACnB,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB;sDACkD;IAClD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,GACpB;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,GAClB;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,iBAAiB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Out-of-band confirmation: when a sign request crosses the policy's confirm
3
+ * threshold, sigil pushes a notification to a channel the human controls
4
+ * (not the agent) and waits for an explicit human ack before signing.
5
+ *
6
+ * The transport interface is intentionally tiny. The shared ack mechanism
7
+ * (a localhost HTTP listener that resolves clicks) lives in ack-server.ts
8
+ * and isn't a per-transport concern — every transport just emits a
9
+ * notification carrying the two URLs.
10
+ */
11
+ export {};
12
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/confirm/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG"}
@@ -0,0 +1,29 @@
1
+ import { ControlClientError } from './client.js';
2
+ import type { ControlRequest, ControlResponse } from './protocol.js';
3
+ export interface SessionSocket {
4
+ /** PID parsed from the socket filename. */
5
+ pid: number;
6
+ socketPath: string;
7
+ }
8
+ export interface SessionResult extends SessionSocket {
9
+ /** Server response, or null if the socket was unreachable. */
10
+ response: ControlResponse | null;
11
+ /** Set when the socket couldn't be reached. */
12
+ clientError?: ControlClientError;
13
+ /** True when the socket was stale (refused / missing) and got unlinked. */
14
+ reaped: boolean;
15
+ }
16
+ /**
17
+ * List the `<pid>.sock` entries in `controlDir`, sorted by PID for stable
18
+ * output. Returns `[]` if the directory is missing. Ignores anything that
19
+ * isn't a `<digits>.sock` name.
20
+ */
21
+ export declare function listSessionSockets(controlDir: string): SessionSocket[];
22
+ /**
23
+ * Send `request` to every live session socket in parallel and collect the
24
+ * per-session outcomes. Sockets that refuse the connection or have vanished
25
+ * are treated as stale: they're unlinked and reported with `reaped: true`.
26
+ * Never throws — transport failures land in each result's `clientError`.
27
+ */
28
+ export declare function broadcast(controlDir: string, request: ControlRequest, timeoutMs?: number): Promise<SessionResult[]>;
29
+ //# sourceMappingURL=broadcast.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../../src/control/broadcast.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAkB,MAAM,aAAa,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAcrE,MAAM,WAAW,aAAa;IAC5B,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAc,SAAQ,aAAa;IAClD,8DAA8D;IAC9D,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;IACjC,+CAA+C;IAC/C,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC,2EAA2E;IAC3E,MAAM,EAAE,OAAO,CAAC;CACjB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,aAAa,EAAE,CAetE;AAED;;;;;GAKG;AACH,wBAAsB,SAAS,CAC7B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,cAAc,EACvB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,EAAE,CAAC,CAK1B"}
@@ -0,0 +1,88 @@
1
+ import { existsSync, readdirSync, statSync, unlinkSync } from 'node:fs';
2
+ import { join } from 'node:path';
3
+ import { ControlClientError, controlRequest } from './client.js';
4
+ /**
5
+ * Fan-out client for the per-session control sockets.
6
+ *
7
+ * Each running sigil-mcp binds `<controlDir>/<pid>.sock`. The CLI broadcasts a
8
+ * single control request to every one of them so `sigil unlock` (etc.) reaches
9
+ * all live Claude Code sessions at once, not just whichever process happened to
10
+ * start first. Sockets left behind by hard-killed processes are detected on
11
+ * connect (refused / missing) and unlinked, so the directory self-heals.
12
+ */
13
+ const SOCK_RE = /^(\d+)\.sock$/;
14
+ /**
15
+ * List the `<pid>.sock` entries in `controlDir`, sorted by PID for stable
16
+ * output. Returns `[]` if the directory is missing. Ignores anything that
17
+ * isn't a `<digits>.sock` name.
18
+ */
19
+ export function listSessionSockets(controlDir) {
20
+ if (!existsSync(controlDir))
21
+ return [];
22
+ try {
23
+ if (!statSync(controlDir).isDirectory())
24
+ return [];
25
+ }
26
+ catch {
27
+ return [];
28
+ }
29
+ const out = [];
30
+ for (const name of readdirSync(controlDir)) {
31
+ const m = SOCK_RE.exec(name);
32
+ if (!m)
33
+ continue;
34
+ out.push({ pid: Number(m[1]), socketPath: join(controlDir, name) });
35
+ }
36
+ out.sort((a, b) => a.pid - b.pid);
37
+ return out;
38
+ }
39
+ /**
40
+ * Send `request` to every live session socket in parallel and collect the
41
+ * per-session outcomes. Sockets that refuse the connection or have vanished
42
+ * are treated as stale: they're unlinked and reported with `reaped: true`.
43
+ * Never throws — transport failures land in each result's `clientError`.
44
+ */
45
+ export async function broadcast(controlDir, request, timeoutMs) {
46
+ const sockets = listSessionSockets(controlDir);
47
+ return Promise.all(sockets.map((s) => sendOne(s, request, timeoutMs)));
48
+ }
49
+ async function sendOne(s, request, timeoutMs) {
50
+ let err;
51
+ try {
52
+ const response = await controlRequest({
53
+ socketPath: s.socketPath,
54
+ request,
55
+ ...(timeoutMs !== undefined ? { timeoutMs } : {}),
56
+ });
57
+ return { ...s, response, reaped: false };
58
+ }
59
+ catch (e) {
60
+ // controlRequest rejects with ControlClientError for all transport
61
+ // failures, but guard against anything unexpected (e.g. a synchronous
62
+ // throw from createConnection on a pathological path) so a single bad
63
+ // socket can never reject the whole fan-out and sink the other sessions.
64
+ err = e instanceof ControlClientError
65
+ ? e
66
+ : new ControlClientError(`control socket: ${e.message}`, 'CONNECT_FAILED');
67
+ }
68
+ // SERVER_DOWN means the file is gone (ENOENT), nothing is listening
69
+ // (ECONNREFUSED), or the path isn't a socket (ENOTSOCK) — no live server, so
70
+ // reap it. TIMEOUT / BAD_RESPONSE / NO_RESPONSE / CONNECT_FAILED could be a
71
+ // live-but-busy server, so leave those sockets in place.
72
+ //
73
+ // Narrow race not handled: if a process died and its PID was immediately
74
+ // reused by a new sigil-mcp that is mid-bind, a connect during the brief
75
+ // ENOENT window could unlink the new server's just-bound socket. Requires
76
+ // PID reuse + simultaneous bind + simultaneous broadcast; the new session
77
+ // self-heals on its next restart. Acceptable given how narrow it is.
78
+ let reaped = false;
79
+ if (err.code === 'SERVER_DOWN') {
80
+ try {
81
+ unlinkSync(s.socketPath);
82
+ reaped = true;
83
+ }
84
+ catch { /* raced another reaper */ }
85
+ }
86
+ return { ...s, response: null, clientError: err, reaped };
87
+ }
88
+ //# sourceMappingURL=broadcast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../../../src/control/broadcast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGjE;;;;;;;;GAQG;AAEH,MAAM,OAAO,GAAG,eAAe,CAAC;AAiBhC;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAkB;IACnD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC;QAAE,OAAO,EAAE,CAAC;IACvC,IAAI,CA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ACxB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,CA8DvF;AAED,MAAM,MAAM,sBAAsB,GAC9B,aAAa,GACb,gBAAgB,GAChB,SAAS,GACT,cAAc,GACd,aAAa,CAAC;AAElB,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;gBAC1B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB;CAK1D"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/control/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAIrE,MAAM,WAAW,kBAAkB;IACjC,iEAAiE;IACjE,UAAU,EAAE,MAAM,CAAC;IACnB,2BAA2B;IAC3B,OAAO,EAAE,cAAc,CAAC;IACxB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,eAAe,CAAC,CAiEvF;AAED,MAAM,MAAM,sBAAsB,GAC9B,aAAa,GACb,gBAAgB,GAChB,SAAS,GACT,cAAc,GACd,aAAa,CAAC;AAElB,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,IAAI,EAAE,sBAAsB,CAAC;gBAC1B,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,sBAAsB;CAK1D"}
@@ -59,7 +59,10 @@ export async function controlRequest(opts) {
59
59
  sock.on('error', (err) => {
60
60
  const code = err.code;
61
61
  let mapped = 'CONNECT_FAILED';
62
- if (code === 'ENOENT' || code === 'ECONNREFUSED')
62
+ // ENOENT: socket file gone. ECONNREFUSED: socket exists but no listener
63
+ // (process died). ENOTSOCK: the path is a non-socket file (junk). All
64
+ // three mean "no live server here" — the caller treats them as reapable.
65
+ if (code === 'ENOENT' || code === 'ECONNREFUSED' || code === 'ENOTSOCK')
63
66
  mapped = 'SERVER_DOWN';
64
67
  finish(() => reject(new ControlClientError(`control socket: ${err.message}`, mapped)));
65
68
  });
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/control/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAG5C,MAAM,kBAAkB,GAAG,KAAK,CAAC;AAWjC;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,IAAwB;IAC3D,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,kBAAkB,CAAC;IACvD,MAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAEzB,IAAI,KAAK,GAA0B,IAAI,CAAC;IACxC,MAAM,YAAY,GAAG,GAAS,EAAE,GAAG,IAAI,KAAK;QAAE,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IAEnF,OAAO,IAAI,OAAO,CAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACtD,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YACtB,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,kBAAkB,CAAC,gCAAgC,SAAS,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC;QAC3F,CAAC,EAAE,SAAS,CAAC,CAAC;QAEd,IAAI,GAAG,GAAG,EAAE,CAAC;QACb,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,MAAM,MAAM,GAAG,CAAC,EAAc,EAAQ,EAAE;YACtC,IAAI,QAAQ;gBAAE,OAAO;YACr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, type ControlRequest, type ControlResponse, type ControlSuccess, type ControlError, type ControlErrorCode, type PortalSummary, isControlError, parseControlRequest, } from './protocol.js';
2
2
  export { type ControlServerOpts, type ControlServerHandle, type ControlLogEvent, startControlServer, } from './server.js';
3
3
  export { type ControlRequestOpts, type ControlClientErrorCode, ControlClientError, controlRequest, } from './client.js';
4
+ export { type SessionSocket, type SessionResult, broadcast, listSessionSockets, } from './broadcast.js';
4
5
  //# sourceMappingURL=index.d.ts.map