things-api 0.19.0 → 0.19.2

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 (154) hide show
  1. package/README.md +3 -1
  2. package/deputy/prebuilt/Things API Helper.app/Contents/CodeResources +0 -0
  3. package/deputy/prebuilt/Things API Helper.app/Contents/Helpers/things-reader.app/Contents/MacOS/things-reader +0 -0
  4. package/deputy/prebuilt/Things API Helper.app/Contents/MacOS/things-deputy +0 -0
  5. package/dist/audit/schema.d.ts +19 -2
  6. package/dist/audit/schema.js.map +1 -1
  7. package/dist/capability.d.ts +166 -4
  8. package/dist/capability.js +303 -13
  9. package/dist/capability.js.map +1 -1
  10. package/dist/cli/commands/doctor.d.ts +13 -1
  11. package/dist/cli/commands/doctor.js +52 -22
  12. package/dist/cli/commands/doctor.js.map +1 -1
  13. package/dist/cli/commands/helpers.js +14 -3
  14. package/dist/cli/commands/helpers.js.map +1 -1
  15. package/dist/cli/commands/mcp.js +8 -0
  16. package/dist/cli/commands/mcp.js.map +1 -1
  17. package/dist/cli/commands/repeat-flags.js +34 -2
  18. package/dist/cli/commands/repeat-flags.js.map +1 -1
  19. package/dist/cli/commands/setup.js +16 -3
  20. package/dist/cli/commands/setup.js.map +1 -1
  21. package/dist/cli/commands/ui-state.d.ts +11 -0
  22. package/dist/cli/commands/ui-state.js +27 -0
  23. package/dist/cli/commands/ui-state.js.map +1 -0
  24. package/dist/cli/commands/writes.js +102 -67
  25. package/dist/cli/commands/writes.js.map +1 -1
  26. package/dist/cli/help.js +2 -0
  27. package/dist/cli/help.js.map +1 -1
  28. package/dist/cli/interrupt.d.ts +54 -6
  29. package/dist/cli/interrupt.js +78 -12
  30. package/dist/cli/interrupt.js.map +1 -1
  31. package/dist/cli/main.js +10 -5
  32. package/dist/cli/main.js.map +1 -1
  33. package/dist/client.d.ts +1 -1
  34. package/dist/contracts.d.ts +4 -4
  35. package/dist/contracts.js +1 -1
  36. package/dist/contracts.js.map +1 -1
  37. package/dist/deputy/install.d.ts +15 -1
  38. package/dist/deputy/install.js +46 -6
  39. package/dist/deputy/install.js.map +1 -1
  40. package/dist/deputy/osa.d.ts +42 -2
  41. package/dist/deputy/osa.js +79 -5
  42. package/dist/deputy/osa.js.map +1 -1
  43. package/dist/deputy/routing.d.ts +34 -0
  44. package/dist/deputy/routing.js +95 -0
  45. package/dist/deputy/routing.js.map +1 -1
  46. package/dist/deputy/wake.d.ts +61 -0
  47. package/dist/deputy/wake.js +149 -0
  48. package/dist/deputy/wake.js.map +1 -0
  49. package/dist/diagnose.d.ts +6 -4
  50. package/dist/diagnose.js +20 -4
  51. package/dist/diagnose.js.map +1 -1
  52. package/dist/direct-setup.d.ts +31 -5
  53. package/dist/direct-setup.js +200 -26
  54. package/dist/direct-setup.js.map +1 -1
  55. package/dist/host-access.d.ts +12 -0
  56. package/dist/host-access.js +12 -0
  57. package/dist/host-access.js.map +1 -1
  58. package/dist/index.d.ts +5 -3
  59. package/dist/index.js +3 -2
  60. package/dist/index.js.map +1 -1
  61. package/dist/mcp/server.js +23 -9
  62. package/dist/mcp/server.js.map +1 -1
  63. package/dist/op-result.js +8 -1
  64. package/dist/op-result.js.map +1 -1
  65. package/dist/session-grant.js +16 -1
  66. package/dist/session-grant.js.map +1 -1
  67. package/dist/surface-copy.d.ts +11 -3
  68. package/dist/surface-copy.js +11 -3
  69. package/dist/surface-copy.js.map +1 -1
  70. package/dist/ui-state.d.ts +46 -0
  71. package/dist/ui-state.js +82 -0
  72. package/dist/ui-state.js.map +1 -0
  73. package/dist/wizard.js +8 -1
  74. package/dist/wizard.js.map +1 -1
  75. package/dist/write/accessibility-probe.js +4 -1
  76. package/dist/write/accessibility-probe.js.map +1 -1
  77. package/dist/write/automation-probe.js +7 -1
  78. package/dist/write/automation-probe.js.map +1 -1
  79. package/dist/write/availability.d.ts +0 -15
  80. package/dist/write/availability.js +7 -62
  81. package/dist/write/availability.js.map +1 -1
  82. package/dist/write/batch.js +17 -6
  83. package/dist/write/batch.js.map +1 -1
  84. package/dist/write/commands.d.ts +10 -6
  85. package/dist/write/commands.js +120 -31
  86. package/dist/write/commands.js.map +1 -1
  87. package/dist/write/failure-hints.d.ts +36 -7
  88. package/dist/write/failure-hints.js +33 -14
  89. package/dist/write/failure-hints.js.map +1 -1
  90. package/dist/write/field-limits.d.ts +100 -0
  91. package/dist/write/field-limits.js +144 -0
  92. package/dist/write/field-limits.js.map +1 -0
  93. package/dist/write/guards.js +3 -2
  94. package/dist/write/guards.js.map +1 -1
  95. package/dist/write/move.js +9 -12
  96. package/dist/write/move.js.map +1 -1
  97. package/dist/write/operations.d.ts +15 -8
  98. package/dist/write/operations.js +9 -0
  99. package/dist/write/operations.js.map +1 -1
  100. package/dist/write/opid.d.ts +67 -23
  101. package/dist/write/opid.js +141 -19
  102. package/dist/write/opid.js.map +1 -1
  103. package/dist/write/param-schema.d.ts +17 -44
  104. package/dist/write/param-schema.js +74 -7
  105. package/dist/write/param-schema.js.map +1 -1
  106. package/dist/write/pipeline.d.ts +38 -7
  107. package/dist/write/pipeline.js +134 -18
  108. package/dist/write/pipeline.js.map +1 -1
  109. package/dist/write/pre-state.d.ts +30 -16
  110. package/dist/write/pre-state.js +88 -20
  111. package/dist/write/pre-state.js.map +1 -1
  112. package/dist/write/promote-clone.d.ts +26 -0
  113. package/dist/write/promote-clone.js +333 -41
  114. package/dist/write/promote-clone.js.map +1 -1
  115. package/dist/write/repeat-collateral.d.ts +31 -0
  116. package/dist/write/repeat-collateral.js +153 -0
  117. package/dist/write/repeat-collateral.js.map +1 -0
  118. package/dist/write/resolution-timestamps.js +25 -2
  119. package/dist/write/resolution-timestamps.js.map +1 -1
  120. package/dist/write/template-mutation.js +163 -16
  121. package/dist/write/template-mutation.js.map +1 -1
  122. package/dist/write/vectors/applescript.js +3 -10
  123. package/dist/write/vectors/applescript.js.map +1 -1
  124. package/dist/write/vectors/simulator.js +8 -2
  125. package/dist/write/vectors/simulator.js.map +1 -1
  126. package/dist/write/vectors/types.d.ts +236 -4
  127. package/dist/write/vectors/ui-certification.js +63 -13
  128. package/dist/write/vectors/ui-certification.js.map +1 -1
  129. package/dist/write/vectors/ui-chord.d.ts +144 -0
  130. package/dist/write/vectors/ui-chord.js +428 -0
  131. package/dist/write/vectors/ui-chord.js.map +1 -0
  132. package/dist/write/vectors/ui-drag.d.ts +8 -4
  133. package/dist/write/vectors/ui-drag.js +2 -0
  134. package/dist/write/vectors/ui-drag.js.map +1 -1
  135. package/dist/write/vectors/ui-recipes.d.ts +51 -3
  136. package/dist/write/vectors/ui-recipes.js +452 -44
  137. package/dist/write/vectors/ui-recipes.js.map +1 -1
  138. package/dist/write/vectors/ui-state.d.ts +157 -0
  139. package/dist/write/vectors/ui-state.js +237 -0
  140. package/dist/write/vectors/ui-state.js.map +1 -0
  141. package/dist/write/vectors/ui.d.ts +386 -13
  142. package/dist/write/vectors/ui.js +1543 -124
  143. package/dist/write/vectors/ui.js.map +1 -1
  144. package/dist/write/vectors/url-scheme.js +3 -0
  145. package/dist/write/vectors/url-scheme.js.map +1 -1
  146. package/dist/write/verify/delta.d.ts +41 -0
  147. package/dist/write/verify/delta.js +36 -2
  148. package/dist/write/verify/delta.js.map +1 -1
  149. package/dist/write/verify/poller.d.ts +4 -1
  150. package/dist/write/verify/poller.js +14 -0
  151. package/dist/write/verify/poller.js.map +1 -1
  152. package/package.json +1 -1
  153. package/schema/envelope.schema.json +2 -1
  154. package/skills/things-cli/SKILL.md +2 -2
@@ -4,12 +4,46 @@ export interface OsaExecResult {
4
4
  stdout: string;
5
5
  stderr: string;
6
6
  timedOut?: boolean;
7
+ /** True when the seam refused rather than running anything (see REFUSAL). */
8
+ refused?: boolean;
9
+ }
10
+ /**
11
+ * Whether this call may fall back to running osascript under the HOST process
12
+ * when the deputy is expected but not carrying traffic:
13
+ *
14
+ * - `"refuse"` (default) — every operational call. A different identity
15
+ * mid-operation is never an acceptable substitute for the one the machine
16
+ * was set up to use.
17
+ * - `"permitted"` — the setup ceremony's consent probes ONLY. Their question
18
+ * is what the calling identity itself holds, so answering it from the host
19
+ * is the correct behavior, and refusing would blind the very diagnostic
20
+ * someone runs when the deputy is down.
21
+ */
22
+ export type HostDirectPolicy = "refuse" | "permitted";
23
+ /** The exit code a refusal reports — distinct from any osascript status. */
24
+ export declare const OSA_REFUSED_EXIT_CODE = 126;
25
+ /**
26
+ * The refusal copy: what is wrong (the deputy is not live/healthy), what will
27
+ * NOT happen instead (a silent identity switch), and the one command that
28
+ * inspects it.
29
+ */
30
+ export declare function osaRoutingRefusalMessage(reason: string | null): string;
31
+ /** The error an osaExecSync refusal throws — shaped so stderr-classifying callers still read the message. */
32
+ export declare class OsaRoutingRefusal extends Error {
33
+ readonly status = 126;
34
+ readonly stdout = "";
35
+ readonly stderr: string;
36
+ readonly killed = false;
37
+ readonly signal: null;
38
+ readonly refused = true;
39
+ constructor(message: string);
7
40
  }
8
41
  /** Async osascript for vector dispatch and ui steps (never blocks the event loop). */
9
42
  export declare function osaExec(script: string, options: {
10
43
  lang?: OsaLang;
11
44
  timeoutMs: number;
12
- }): Promise<OsaExecResult>;
45
+ hostDirect?: HostDirectPolicy;
46
+ }, env?: NodeJS.ProcessEnv): Promise<OsaExecResult>;
13
47
  /**
14
48
  * Sync osascript for the consent probes. Returns stdout on success; throws an
15
49
  * execFileSync-SHAPED error otherwise (status/stderr/killed/signal), so the
@@ -17,5 +51,11 @@ export declare function osaExec(script: string, options: {
17
51
  * identically on both paths. In deputy mode the classification is answered
18
52
  * about the DEPUTY's grants — exactly the right question, since it is the
19
53
  * deputy that will send every AppleEvent.
54
+ *
55
+ * Its two callers are ceremony probes and pass `hostDirect: "permitted"`; any
56
+ * future caller inherits the safe default and refuses instead of switching
57
+ * identity mid-flight.
20
58
  */
21
- export declare function osaExecSync(script: string, timeoutMs: number): string;
59
+ export declare function osaExecSync(script: string, timeoutMs: number, options?: {
60
+ hostDirect?: HostDirectPolicy;
61
+ }, env?: NodeJS.ProcessEnv): string;
@@ -5,12 +5,62 @@
5
5
  * (execFile/execFileSync, byte-identical to the pre-deputy behavior)
6
6
  * otherwise. `open`-based primitives (URL scheme, reveal) are consent-free by
7
7
  * design and never route.
8
+ *
9
+ * NO SILENT HOST FALLBACK (issue #620, permissions doctrine Article I). The
10
+ * "otherwise" above used to be unconditional, and that is a defect with a
11
+ * measured failure mode: when a machine EXPECTS the deputy (installed under
12
+ * `auto`, or `helpers-enabled true`) and routing is not active — the deputy
13
+ * stopped, its handshake failed, its onboarding could not be proven — the
14
+ * osascript quietly ran under the HOST process's identity instead. The host
15
+ * holds a DIFFERENT set of grants, so a drive could get its Accessibility
16
+ * clicks through and then die on the first keystroke with System Events error
17
+ * 1002 ("osascript is not allowed to send keystrokes"), half-way through a
18
+ * dialog, with the app reporting healthy routing. The read side already
19
+ * forbids exactly this (`helpersExpected` + the reader's no-fallback rule);
20
+ * the automation side now matches: a deputy that is expected but not live
21
+ * makes the call REFUSE, naming the helper's health and its remedy.
22
+ *
23
+ * The one legitimate exception is the CONSENT PROBE inside a setup ceremony,
24
+ * whose entire question is "what does THIS identity hold?" — it passes
25
+ * `hostDirect: "permitted"` explicitly. Machines with no deputy installed
26
+ * (`auto`, nothing there) and machines with the helpers switched off keep the
27
+ * direct path byte-identically, as do the lab escapes, which run in clones
28
+ * where nothing is installed.
8
29
  */
9
30
  import { execFile, execFileSync } from "node:child_process";
10
31
  import {} from "./protocol.js";
11
- import { deputyAsyncRequest, deputyRouting, deputySyncRequest } from "./routing.js";
32
+ import { deputyAsyncRequest, deputyExpected, deputyRouting, deputySyncRequest } from "./routing.js";
12
33
  /** Deputy-side kill fires at timeoutMs; the client deadline adds grace so the deputy's honest answer wins. */
13
34
  const CLIENT_GRACE_MS = 5000;
35
+ /** The exit code a refusal reports — distinct from any osascript status. */
36
+ export const OSA_REFUSED_EXIT_CODE = 126;
37
+ /**
38
+ * The refusal copy: what is wrong (the deputy is not live/healthy), what will
39
+ * NOT happen instead (a silent identity switch), and the one command that
40
+ * inspects it.
41
+ */
42
+ export function osaRoutingRefusalMessage(reason) {
43
+ return ("the helpers are set up on this Mac but the deputy is not carrying app automation right now " +
44
+ `(${reason ?? "routing is not active"}) — automation needs a live, healthy deputy, and this ` +
45
+ "command will not silently run it under this terminal's own identity instead (a different " +
46
+ "identity holds different macOS permissions, which is how a half-finished drive happens). " +
47
+ "Check the helper's health with `things helpers status`, restart it with " +
48
+ "`things helpers restart` if it has stopped, then run the same command again.");
49
+ }
50
+ /** The error an osaExecSync refusal throws — shaped so stderr-classifying callers still read the message. */
51
+ export class OsaRoutingRefusal extends Error {
52
+ status = OSA_REFUSED_EXIT_CODE;
53
+ stdout = "";
54
+ stderr;
55
+ killed = false;
56
+ signal = null;
57
+ refused = true;
58
+ constructor(message) {
59
+ super(message);
60
+ this.name = "OsaRoutingRefusal";
61
+ this.stderr = message;
62
+ }
63
+ }
14
64
  function osaArgs(script, lang) {
15
65
  return lang === "javascript" ? ["-l", "JavaScript", "-e", script] : ["-e", script];
16
66
  }
@@ -27,13 +77,29 @@ function fromDeputy(res) {
27
77
  ...(r.timedOut === true && { timedOut: true }),
28
78
  };
29
79
  }
80
+ /**
81
+ * Is the host path allowed for this call? Only when the machine does not expect
82
+ * a deputy at all, or the caller is a ceremony probe that explicitly opted in.
83
+ */
84
+ function hostPathAllowed(policy, env) {
85
+ return policy === "permitted" || !deputyExpected(env);
86
+ }
30
87
  /** Async osascript for vector dispatch and ui steps (never blocks the event loop). */
31
- export async function osaExec(script, options) {
88
+ export async function osaExec(script, options, env = process.env) {
32
89
  const lang = options.lang ?? "applescript";
33
- if (deputyRouting().active) {
90
+ const routing = deputyRouting(env);
91
+ if (routing.active) {
34
92
  const res = await deputyAsyncRequest({ verb: "osascript", script, lang, timeoutMs: options.timeoutMs }, options.timeoutMs + CLIENT_GRACE_MS);
35
93
  return fromDeputy(res);
36
94
  }
95
+ if (!hostPathAllowed(options.hostDirect ?? "refuse", env)) {
96
+ return {
97
+ exitCode: OSA_REFUSED_EXIT_CODE,
98
+ stdout: "",
99
+ stderr: osaRoutingRefusalMessage(routing.reason),
100
+ refused: true,
101
+ };
102
+ }
37
103
  return new Promise((resolve) => {
38
104
  execFile("osascript", osaArgs(script, lang), { timeout: options.timeoutMs }, (err, stdout, stderr) => {
39
105
  const timedOut = err !== null && err.killed === true;
@@ -53,9 +119,17 @@ export async function osaExec(script, options) {
53
119
  * identically on both paths. In deputy mode the classification is answered
54
120
  * about the DEPUTY's grants — exactly the right question, since it is the
55
121
  * deputy that will send every AppleEvent.
122
+ *
123
+ * Its two callers are ceremony probes and pass `hostDirect: "permitted"`; any
124
+ * future caller inherits the safe default and refuses instead of switching
125
+ * identity mid-flight.
56
126
  */
57
- export function osaExecSync(script, timeoutMs) {
58
- if (!deputyRouting().active) {
127
+ export function osaExecSync(script, timeoutMs, options = {}, env = process.env) {
128
+ const routing = deputyRouting(env);
129
+ if (!routing.active) {
130
+ if (!hostPathAllowed(options.hostDirect ?? "refuse", env)) {
131
+ throw new OsaRoutingRefusal(osaRoutingRefusalMessage(routing.reason));
132
+ }
59
133
  return execFileSync("osascript", ["-e", script], { encoding: "utf8", timeout: timeoutMs });
60
134
  }
61
135
  const res = deputySyncRequest({ verb: "osascript", script, lang: "applescript", timeoutMs }, timeoutMs + CLIENT_GRACE_MS);
@@ -1 +1 @@
1
- {"version":3,"file":"osa.js","sourceRoot":"","sources":["../../src/deputy/osa.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAE5D,OAAO,EAAwB,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAWpF,8GAA8G;AAC9G,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,SAAS,OAAO,CAAC,MAAc,EAAE,IAAa;IAC5C,OAAO,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,Y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C1B,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,QAAQ,KAAK,IAAI,CAAC;IACrC,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,QAAQ,KAAK,IAAI,IAAI,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IACpF,MAAM,KAAK,CAAC;AACd,CAAC"}
@@ -12,6 +12,22 @@ export interface DeputyRouting {
12
12
  export declare function resetDeputyRoutingForTests(): void;
13
13
  /** The per-process routing decision (activated lazily on first ask). */
14
14
  export declare function deputyRouting(env?: NodeJS.ProcessEnv): DeputyRouting;
15
+ /**
16
+ * Finish the onboarding gate that a dormant Things deferred (#617).
17
+ *
18
+ * Called by the write gate with the standing it read AFTER waking the target,
19
+ * which is the first moment the grant is knowable. `granted` proves the deputy
20
+ * and the memoized handshake is corrected in place, so every later verdict in
21
+ * this process reads the truth without waking anything again. Anything else is
22
+ * the state the activation gate would have refused on: the transports are
23
+ * closed, the deferred notice is printed, and the process runs direct — because
24
+ * an event routed to a deputy that lacks the grant just relocates the consent
25
+ * dialog to a helper nobody is watching.
26
+ *
27
+ * A no-op unless a deferral is actually outstanding, so `true` mode (which
28
+ * never defers) and every non-deputy machine are untouched.
29
+ */
30
+ export declare function settleDeputyAutomation(standing: string | undefined): void;
15
31
  /** The reader transport's state (activated lazily; test seam via reset). */
16
32
  export declare function readerRouting(env?: NodeJS.ProcessEnv): {
17
33
  active: boolean;
@@ -51,6 +67,24 @@ export declare function deputyFilesActive(env?: NodeJS.ProcessEnv): boolean;
51
67
  * them, so it falls through to the direct grants as it always has.
52
68
  */
53
69
  export declare function helpersExpected(env?: NodeJS.ProcessEnv): boolean;
70
+ /**
71
+ * Does this machine EXPECT the DEPUTY to carry its app automation?
72
+ *
73
+ * The osascript twin of {@link helpersExpected}, and deliberately a SEPARATE
74
+ * question: each half of the pair is gated on its OWN requisite (reads on the
75
+ * reader's bookmark grant, automation on the deputy's app-control grant), so a
76
+ * machine that installed one half is not told it expects the other. `true` is
77
+ * an explicit instruction; under `auto` the installed deputy bundle (or its
78
+ * live rendezvous) is the intent signal.
79
+ *
80
+ * The no-fallback rule hangs on this (permissions doctrine, Article I; issue
81
+ * #620): when the deputy is expected but is not carrying traffic, an osascript
82
+ * REFUSES rather than quietly re-running under the host process's identity —
83
+ * which is a different identity, with different grants, mid-operation. A
84
+ * machine with no deputy installed under `auto` is an ordinary direct machine
85
+ * and is NOT expecting one, so it runs direct exactly as it always has.
86
+ */
87
+ export declare function deputyExpected(env?: NodeJS.ProcessEnv): boolean;
54
88
  /** Why the reader is not carrying reads (null when it is). */
55
89
  export declare function readerUnavailableReason(env?: NodeJS.ProcessEnv): string | null;
56
90
  /** Blocking FILE-verb round-trip via the granted reader. */
@@ -31,6 +31,13 @@
31
31
  * the half it earned. Accessibility and System Events are NOT requisite: the
32
32
  * UI vector is separately double-gated and refuses on its own.
33
33
  *
34
+ * The one answer that gate cannot judge is `not-running`: with Things closed,
35
+ * macOS has no determination to give, so the value describes the app's PROCESS
36
+ * and not its grant (#617). Deactivating on it would drop a fully onboarded
37
+ * machine onto the direct path every time its owner quit the app. That case is
38
+ * DEFERRED instead — active, `automationUnproven` — and settled by the write
39
+ * gate, which is the one caller allowed to start the target (./wake.ts).
40
+ *
34
41
  * Fallback is decided at ACTIVATION, never mid-operation: if a helper is
35
42
  * expected but unreachable (or speaks a different protocol), the whole process
36
43
  * runs direct with one stderr notice — a half-routed operation is worse than
@@ -179,6 +186,28 @@ function activate(env) {
179
186
  // PROVE the grant before it carries traffic; `true` is an explicit
180
187
  // instruction to route regardless and stays loud on failure.
181
188
  const automationThings = helloResult.automation?.things;
189
+ if (mode === "auto" && automationThings === "not-running") {
190
+ // LIVENESS, NOT AUTHORIZATION (#617). A closed Things is what makes the
191
+ // deputy's ask-false determination answer procNotFound, so `not-running`
192
+ // says nothing about the grant — and a machine whose owner simply quit the
193
+ // app would be deactivated here, printed a notice claiming a missing
194
+ // permission, and dropped onto the direct path the helpers exist to end.
195
+ // The decision is DEFERRED instead: the deputy stays active but UNPROVEN,
196
+ // and the write gate settles it (wake the target, re-read the standing,
197
+ // then {@link settleDeputyAutomation}) before anything is dispatched.
198
+ // Nothing is launched from here — activation happens on every invocation,
199
+ // including pure reads and `doctor`, and none of those may start the user's
200
+ // app as a side effect.
201
+ return {
202
+ active: true,
203
+ reason: null,
204
+ hello: helloResult,
205
+ token,
206
+ bridge,
207
+ client: new DeputyAsyncClient(socketPath),
208
+ automationUnproven: true,
209
+ };
210
+ }
182
211
  if (mode === "auto" && automationThings !== "granted") {
183
212
  bridge.close();
184
213
  // Absent fields = helpers predating the TCC handshake. Not provably
@@ -205,6 +234,47 @@ export function deputyRouting(env = process.env) {
205
234
  state ??= activate(env);
206
235
  return state;
207
236
  }
237
+ /**
238
+ * Finish the onboarding gate that a dormant Things deferred (#617).
239
+ *
240
+ * Called by the write gate with the standing it read AFTER waking the target,
241
+ * which is the first moment the grant is knowable. `granted` proves the deputy
242
+ * and the memoized handshake is corrected in place, so every later verdict in
243
+ * this process reads the truth without waking anything again. Anything else is
244
+ * the state the activation gate would have refused on: the transports are
245
+ * closed, the deferred notice is printed, and the process runs direct — because
246
+ * an event routed to a deputy that lacks the grant just relocates the consent
247
+ * dialog to a helper nobody is watching.
248
+ *
249
+ * A no-op unless a deferral is actually outstanding, so `true` mode (which
250
+ * never defers) and every non-deputy machine are untouched.
251
+ */
252
+ export function settleDeputyAutomation(standing) {
253
+ const current = state;
254
+ if (current === null || !current.active || current.automationUnproven !== true)
255
+ return;
256
+ if (standing === "granted") {
257
+ state = {
258
+ ...current,
259
+ automationUnproven: false,
260
+ hello: {
261
+ ...current.hello,
262
+ ...(current.hello.automation !== undefined && {
263
+ automation: { ...current.hello.automation, things: "granted" },
264
+ }),
265
+ },
266
+ };
267
+ return;
268
+ }
269
+ current.bridge.close();
270
+ current.client.close();
271
+ notice(true, `the helpers have no app-control permission for Things (${standing ?? "unknown"}), so app automation runs DIRECT — \`things helpers setup\` settles it in one sitting.`);
272
+ state = {
273
+ active: false,
274
+ reason: `onboarding incomplete (automation → Things: ${standing ?? "unknown"})`,
275
+ hello: null,
276
+ };
277
+ }
208
278
  function activeState(env) {
209
279
  const routing = deputyRouting(env);
210
280
  return routing.active ? state : null;
@@ -339,6 +409,31 @@ export function helpersExpected(env = process.env) {
339
409
  return true;
340
410
  return rendezvousExists(readerSocketPath(env)) && rendezvousExists(readerTokenPath(env));
341
411
  }
412
+ /**
413
+ * Does this machine EXPECT the DEPUTY to carry its app automation?
414
+ *
415
+ * The osascript twin of {@link helpersExpected}, and deliberately a SEPARATE
416
+ * question: each half of the pair is gated on its OWN requisite (reads on the
417
+ * reader's bookmark grant, automation on the deputy's app-control grant), so a
418
+ * machine that installed one half is not told it expects the other. `true` is
419
+ * an explicit instruction; under `auto` the installed deputy bundle (or its
420
+ * live rendezvous) is the intent signal.
421
+ *
422
+ * The no-fallback rule hangs on this (permissions doctrine, Article I; issue
423
+ * #620): when the deputy is expected but is not carrying traffic, an osascript
424
+ * REFUSES rather than quietly re-running under the host process's identity —
425
+ * which is a different identity, with different grants, mid-operation. A
426
+ * machine with no deputy installed under `auto` is an ordinary direct machine
427
+ * and is NOT expecting one, so it runs direct exactly as it always has.
428
+ */
429
+ export function deputyExpected(env = process.env) {
430
+ const mode = loadConfig(env).helpersMode;
431
+ if (mode === "false")
432
+ return false;
433
+ if (mode === "true")
434
+ return true;
435
+ return halfInstalled(deputyInstalledBinaryPath(env), deputySocketPath(env), deputyTokenPath(env));
436
+ }
342
437
  /** Why the reader is not carrying reads (null when it is). */
343
438
  export function readerUnavailableReason(env = process.env) {
344
439
  if (deputyFilesActive(env))
@@ -1 +1 @@
1
- {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/deputy/routing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,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AAM,CAAC,KAAK,CAAC,MAAM,CAAC;IAC7D,MAAM,EAAE,GAAG,WAA0B,CAAC;IACtC,IAAI,EAAE,CAAC,UAAU,KAAK,SAAS,IAAI,EAAE,CAAC,UAAU,KAAK,IAAI;QAAE,OAAO,EAAE,CAAC,UAAU,CAAC;IAChF,MAAM,GAAG,GAAG,eAAe,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAClE,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,MAAM,IAAI,kBAAkB,CAC1B,WAAW,EACX,sDAAsD,CACvD,CAAC;IACJ,CAAC;IACD,EAAE,CAAC,UAAU,GAAG,IAAI,CAAC;IACrB,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAwC,EACxC,MAAyB,OAAO,CAAC,GAAG;IAEpC,IAAI,OAAO,EAAE,MAAM,KAAK,SAAS,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE;QAAE,OAAO,KAAK,CAAC;IACnF,OAAO,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { AutomationPermission } from "./protocol.ts";
2
+ /** The GUI-driving target: the macOS component that reads and presses controls. */
3
+ export declare const SYSTEM_EVENTS_BUNDLE_ID = "com.apple.systemevents";
4
+ /** The Things application — the AppleScript vector's target. */
5
+ export declare const THINGS_BUNDLE_ID = "com.culturedcode.ThingsMac";
6
+ /**
7
+ * One Automation target, described the two ways this module needs it: the
8
+ * bundle id LaunchServices starts, and the `automation` field of the deputy's
9
+ * hello that carries its determination.
10
+ */
11
+ export interface WakeTarget {
12
+ bundleId: string;
13
+ field: "systemEvents" | "things";
14
+ /** How long the target may take to come up before the wake is a failure. */
15
+ timeoutMs: number;
16
+ }
17
+ /**
18
+ * System Events comes up in milliseconds — it is a headless agent with nothing
19
+ * to restore (SEWAKE1: `granted` on the FIRST ask after the launch, 10 ms).
20
+ */
21
+ export declare const SYSTEM_EVENTS_TARGET: WakeTarget;
22
+ /**
23
+ * Things is a full document app that opens a window and its database, so it is
24
+ * given a longer bound than the agent. This wait only covers becoming
25
+ * ANSWERABLE to the determination; the pipeline separately waits for the app to
26
+ * be ready to land a write (src/write/pipeline.ts, the #486 startup window).
27
+ */
28
+ export declare const THINGS_TARGET: WakeTarget;
29
+ export interface TargetWake {
30
+ /**
31
+ * The target's Automation standing once it is up. `not-running` (or
32
+ * undefined) means the wake did NOT take — a liveness failure, and the only
33
+ * state a caller may refuse on with liveness copy.
34
+ */
35
+ standing: AutomationPermission | undefined;
36
+ /** One clause of provenance, for the refusal when the wake did not take. */
37
+ detail: string;
38
+ }
39
+ export interface WakeDeps {
40
+ /** Start the target in the background. Throws when the launch is refused. */
41
+ launch?: () => void;
42
+ /** Re-read the deputy's ask-false determination for the target. */
43
+ probe?: () => AutomationPermission | undefined;
44
+ sleep?: (ms: number) => void;
45
+ now?: () => number;
46
+ timeoutMs?: number;
47
+ intervalMs?: number;
48
+ }
49
+ /**
50
+ * Start a dormant Automation target, then report where its grant actually
51
+ * stands. Prompt-free by construction — see the module comment for why the
52
+ * launch must precede the determination.
53
+ *
54
+ * Call this only when the deputy has just reported `not-running`: on a live
55
+ * target the determination is already the truth and the launch buys nothing.
56
+ */
57
+ export declare function wakeTarget(target: WakeTarget, env?: NodeJS.ProcessEnv, deps?: WakeDeps): TargetWake;
58
+ /** Wake the GUI-driving target (#610). */
59
+ export declare function wakeSystemEvents(env?: NodeJS.ProcessEnv, deps?: WakeDeps): TargetWake;
60
+ /** Wake the AppleScript vector's target — the user's own Things app (#617). */
61
+ export declare function wakeThings(env?: NodeJS.ProcessEnv, deps?: WakeDeps): TargetWake;
@@ -0,0 +1,149 @@
1
+ /**
2
+ * Waking a dormant Automation target — LIVENESS before authorization.
3
+ *
4
+ * `AEDeterminePermissionToAutomateTarget(askUserIfNeeded: false)` cannot answer
5
+ * for a target that is not running: it returns procNotFound, which the deputy
6
+ * reports as `not-running` (deputy/src/tcc.swift). That value is a fact about
7
+ * the PROCESS, never a verdict on the grant, and reading it as one is what made
8
+ * a fully onboarded machine get steered back through onboarding (#610 for
9
+ * System Events, #617 for Things itself).
10
+ *
11
+ * Two targets, one mechanism:
12
+ *
13
+ * - **System Events** is an on-demand macOS agent the system reaps whenever it
14
+ * has been idle. Its dormancy is the DEFAULT state, not an edge case
15
+ * (SEWAKE1 measured it down on a freshly booted machine that had done
16
+ * nothing).
17
+ * - **Things** is the user's own app, closed whenever they are not using it.
18
+ *
19
+ * The resolution, and why the ORDER is not negotiable:
20
+ *
21
+ * 1. LAUNCH the target first, with a plain background LaunchServices dispatch
22
+ * (`open -g -b`). An app launch is not a TCC-gated act: it raises no consent
23
+ * dialog, on any grant state, ever.
24
+ * 2. Only THEN re-read the ask-false determination. Doing it the other way
25
+ * round — sending the target an Apple event to wake it — auto-launches it
26
+ * AND raises the consent dialog when no grant is on record, which is exactly
27
+ * the surprise the permissions doctrine forbids outside the two ceremonies
28
+ * (docs/design/permissions-doctrine.md, Article I). For Things the order
29
+ * buys a second thing measured independently: an Apple event to a CLOSED
30
+ * Things auto-launches it with FOCUS STEAL (tier 2, A40/A41), while
31
+ * `open -g` keeps the operation at tier 0/1 — so the wake is the pre-launch
32
+ * the AppleScript vector wants anyway.
33
+ *
34
+ * The wait is closed-loop: the determination is re-asked until it stops saying
35
+ * `not-running`, bounded, with no fixed sleep standing in for the answer. When
36
+ * the target never comes up the caller gets a LIVENESS verdict to refuse on —
37
+ * never a permission one.
38
+ *
39
+ * WHO MAY CALL THIS. A launch is a side effect, so it belongs to callers that
40
+ * are about to DRIVE the target (the write gate before a dispatch, the two
41
+ * setup ceremonies). A survey — `doctor`, the MCP startup bake — must never
42
+ * launch the user's app as a diagnostic side effect; it reports the liveness
43
+ * state instead (src/capability.ts).
44
+ */
45
+ import { execFileSync } from "node:child_process";
46
+ import { deputySyncRequest } from "./routing.js";
47
+ /** The GUI-driving target: the macOS component that reads and presses controls. */
48
+ export const SYSTEM_EVENTS_BUNDLE_ID = "com.apple.systemevents";
49
+ /** The Things application — the AppleScript vector's target. */
50
+ export const THINGS_BUNDLE_ID = "com.culturedcode.ThingsMac";
51
+ /** How often the determination is re-asked while waiting. */
52
+ const WAKE_POLL_INTERVAL_MS = 50;
53
+ /** How long the launch itself may take before it counts as refused. */
54
+ const LAUNCH_TIMEOUT_MS = 10_000;
55
+ /**
56
+ * System Events comes up in milliseconds — it is a headless agent with nothing
57
+ * to restore (SEWAKE1: `granted` on the FIRST ask after the launch, 10 ms).
58
+ */
59
+ export const SYSTEM_EVENTS_TARGET = {
60
+ bundleId: SYSTEM_EVENTS_BUNDLE_ID,
61
+ field: "systemEvents",
62
+ timeoutMs: 5_000,
63
+ };
64
+ /**
65
+ * Things is a full document app that opens a window and its database, so it is
66
+ * given a longer bound than the agent. This wait only covers becoming
67
+ * ANSWERABLE to the determination; the pipeline separately waits for the app to
68
+ * be ready to land a write (src/write/pipeline.ts, the #486 startup window).
69
+ */
70
+ export const THINGS_TARGET = {
71
+ bundleId: THINGS_BUNDLE_ID,
72
+ field: "things",
73
+ timeoutMs: 10_000,
74
+ };
75
+ function launchInBackground(bundleId) {
76
+ execFileSync("open", ["-g", "-b", bundleId], {
77
+ stdio: "ignore",
78
+ timeout: LAUNCH_TIMEOUT_MS,
79
+ });
80
+ }
81
+ /**
82
+ * A FRESH determination off the deputy, not the handshake the routing layer
83
+ * memoized at activation — the whole point of the re-probe is that the world
84
+ * changed since then. A deputy that stops answering mid-wake reads as
85
+ * undefined, which keeps the loop waiting rather than manufacturing a verdict.
86
+ */
87
+ function targetStanding(env, field) {
88
+ try {
89
+ const res = deputySyncRequest({ verb: "hello" }, 2000, env);
90
+ const automation = res["automation"];
91
+ return automation?.[field];
92
+ }
93
+ catch {
94
+ return undefined;
95
+ }
96
+ }
97
+ function syncSleep(ms) {
98
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
99
+ }
100
+ /** True while the target is still down (or the determination is still unread). */
101
+ function stillDown(standing) {
102
+ return standing === undefined || standing === "not-running";
103
+ }
104
+ /**
105
+ * Start a dormant Automation target, then report where its grant actually
106
+ * stands. Prompt-free by construction — see the module comment for why the
107
+ * launch must precede the determination.
108
+ *
109
+ * Call this only when the deputy has just reported `not-running`: on a live
110
+ * target the determination is already the truth and the launch buys nothing.
111
+ */
112
+ export function wakeTarget(target, env = process.env, deps = {}) {
113
+ const probe = deps.probe ?? (() => targetStanding(env, target.field));
114
+ const sleep = deps.sleep ?? syncSleep;
115
+ const now = deps.now ?? Date.now;
116
+ const timeoutMs = deps.timeoutMs ?? target.timeoutMs;
117
+ const intervalMs = deps.intervalMs ?? WAKE_POLL_INTERVAL_MS;
118
+ try {
119
+ (deps.launch ?? (() => launchInBackground(target.bundleId)))();
120
+ }
121
+ catch (err) {
122
+ return {
123
+ standing: "not-running",
124
+ detail: `it could not be started (${err instanceof Error ? err.message : String(err)})`,
125
+ };
126
+ }
127
+ const deadline = now() + timeoutMs;
128
+ let standing = probe();
129
+ while (stillDown(standing) && now() < deadline) {
130
+ sleep(intervalMs);
131
+ standing = probe();
132
+ }
133
+ if (stillDown(standing)) {
134
+ return {
135
+ standing,
136
+ detail: `it did not come up within ${Math.round(timeoutMs / 1000)}s of being started`,
137
+ };
138
+ }
139
+ return { standing, detail: "started on demand" };
140
+ }
141
+ /** Wake the GUI-driving target (#610). */
142
+ export function wakeSystemEvents(env = process.env, deps = {}) {
143
+ return wakeTarget(SYSTEM_EVENTS_TARGET, env, deps);
144
+ }
145
+ /** Wake the AppleScript vector's target — the user's own Things app (#617). */
146
+ export function wakeThings(env = process.env, deps = {}) {
147
+ return wak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