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
@@ -1,11 +1,11 @@
1
1
  import { type HelpersMode } from "./config.ts";
2
2
  import { type HelpersStatus } from "./deputy/install.ts";
3
3
  import { type HelpersRouting } from "./deputy/routing.ts";
4
- import { type ReadCapability, type UiCapability, type WriteCapability } from "./capability.ts";
4
+ import { type CapabilityDeps, type ReadCapability, type UiCapability, type UrlSchemeCapability, type WriteCapability } from "./capability.ts";
5
5
  import { type AutomationProbeDeps, type AutomationProbeStatus } from "./write/automation-probe.ts";
6
6
  import { type AccessibilityProbeDeps, type AccessibilityProbeStatus } from "./write/accessibility-probe.ts";
7
7
  import { type CertificationStatus } from "./write/vectors/ui-certification.ts";
8
- import { type AvailabilityDeps, type ShortcutsState, type UrlSchemeState } from "./write/availability.ts";
8
+ import { type AvailabilityDeps, type ShortcutsState } from "./write/availability.ts";
9
9
  import { type EnvironmentChange, type EnvironmentTracker, type EnvironmentTuple } from "./write/environment.ts";
10
10
  import { type SyncHealth, type SyncHealthDeps } from "./sync-health.ts";
11
11
  import { ExitCode, type EnvelopeMeta, type ErrorCode } from "./contracts.ts";
@@ -142,8 +142,8 @@ export interface DiagnoseReport {
142
142
  reason: string;
143
143
  };
144
144
  availability: {
145
- /** On-disk 'Enable Things URLs' state (group-container plist; Phase 21b). */
146
- urlScheme: UrlSchemeState;
145
+ /** Things' own 'Enable Things URLs' authorization (capability.ts; URLEN1). */
146
+ urlScheme: UrlSchemeCapability;
147
147
  /** Which proxy shortcuts are installed (the Shortcuts surface's prerequisites). */
148
148
  shortcuts: ShortcutsState;
149
149
  };
@@ -205,6 +205,8 @@ export interface DiagnoseOptions {
205
205
  accessibilityProbeDeps?: AccessibilityProbeDeps;
206
206
  environment?: EnvironmentTracker;
207
207
  availability?: AvailabilityDeps;
208
+ /** Test seams for the prompt-free capability verdicts (capability.ts). */
209
+ capability?: CapabilityDeps;
208
210
  /** Test seams for the sync-health section (clock, process check, WAL/plist readers). */
209
211
  syncHealth?: SyncHealthDeps;
210
212
  /**
package/dist/diagnose.js CHANGED
@@ -15,13 +15,13 @@ import { createDeputyDbFacade } from "./deputy/db-facade.js";
15
15
  import { helpersStatus } from "./deputy/install.js";
16
16
  import { EXPECTED_HELPERS_VERSION } from "./deputy/protocol.js";
17
17
  import { deputyDbPath, deputyRoutesDb, helpersRouting, } from "./deputy/routing.js";
18
- import { readAllowed, readCapability, uiCapability, writeCapability, } from "./capability.js";
18
+ import { readAllowed, readCapability, uiCapability, urlSchemeCapability, writeCapability, } from "./capability.js";
19
19
  import { compareToBaseline, observeSchema } from "./db/fingerprint.js";
20
20
  import { locateThingsDb, ThingsDbNotFoundError } from "./db/locate.js";
21
21
  import { isThingsRunning, probeAutomation, } from "./write/automation-probe.js";
22
22
  import { probeAccessibility, } from "./write/accessibility-probe.js";
23
23
  import { allCertifications, UI_CERTIFICATION_PROFILE, } from "./write/vectors/ui-certification.js";
24
- import { readShortcutProxies, readUrlSchemeEnabled, } from "./write/availability.js";
24
+ import { readShortcutProxies, } from "./write/availability.js";
25
25
  import { createEnvironmentTracker, diffEnvironment, } from "./write/environment.js";
26
26
  import { sdefDeclaresPrivateReorder } from "./write/experimental.js";
27
27
  import { computeSyncHealth } from "./sync-health.js";
@@ -75,7 +75,16 @@ function outstandingConsent(hello) {
75
75
  const automation = hello.automation;
76
76
  if (automation === undefined)
77
77
  return false;
78
- return automation.things !== "granted" || automation.systemEvents !== "granted";
78
+ return consentOwed(automation.things) || consentOwed(automation.systemEvents);
79
+ }
80
+ /**
81
+ * `not-running` is the one value that is NOT a standing: with the target down
82
+ * the ask-false determination has no answer to give, so nothing is owed and no
83
+ * sitting would settle anything (#610 for System Events, #617 for Things).
84
+ * Steering a human to a ceremony on it is the false-onboarding loop itself.
85
+ */
86
+ function consentOwed(standing) {
87
+ return standing !== "granted" && standing !== "not-running";
79
88
  }
80
89
  function buildHelpersReport(configMode, deps = {}) {
81
90
  // The routing resolution carries the mode it resolved (helpersRouting reads
@@ -141,6 +150,8 @@ export function diagnose(dbPath, options = {}) {
141
150
  // itself opening the container and raising the dialog it is diagnosing.
142
151
  const capability = {
143
152
  read: readCapability(dbPath !== undefined ? { dbPath } : {}),
153
+ // SURVEY, so a closed Things is REPORTED (`deputy-target-dormant`) and
154
+ // never started: doctor diagnoses the machine, it does not rearrange it.
144
155
  write: writeCapability(),
145
156
  ui: uiCapability(),
146
157
  };
@@ -334,7 +345,12 @@ export function diagnose(dbPath, options = {}) {
334
345
  "intended for a dedicated always-on Mac, see docs/setup.md)",
335
346
  },
336
347
  availability: {
337
- urlScheme: readUrlSchemeEnabled(options.availability),
348
+ // Reuses the read standing already established above rather than
349
+ // re-deriving it, so doctor asks the machine once.
350
+ urlScheme: urlSchemeCapability({
351
+ readStanding: () => capability.read,
352
+ ...options.capability,
353
+ }),
338
354
  shortcuts: readShortcutProxies(options.availability),
339
355
  },
340
356
  recurrence: scanRecurrenceRules(conn.db),
@@ -1 +1 @@
1
- {"version":3,"file":"diagnose.js","sourceRoot":"","sources":["../src/diagnose.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAoB,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAsB,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAoB,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,EACL,YAAY,EACZ,cAAc,EACd,cAAc,GAEf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,eAAe,GAIhB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACvE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AACvE,OAAO,EACL,eAAe,EACf,eAAe,GAGhB,MAAM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e;gBACtC,WAAW,EAAE,iBAAiB,KAAK,iBAAiB,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB;aACrF;SACF,CAAC;IACJ,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -1,7 +1,16 @@
1
- import { writeCapability, type CapabilityDeps, type ReadCapability } from "./capability.ts";
1
+ import { writeCapability, type CapabilityDeps, type ReadCapability, type UrlSchemeCapability, type WriteCapabilityOptions } from "./capability.ts";
2
2
  import { type Wizard } from "./wizard.ts";
3
3
  import { type ShortcutsState } from "./write/availability.ts";
4
- export type SetupLeg = "read-access" | "app-control" | "shortcuts";
4
+ /**
5
+ * The deadline passed with the app-data dialog still unanswered. Distinct from
6
+ * a refusal: nothing was decided, the dialog is still on screen, and answering
7
+ * it later still lands the grant on the host app (APDP1 stage A).
8
+ */
9
+ export declare class ContainerOpenTimedOut extends Error {
10
+ readonly timeoutMs: number;
11
+ constructor(timeoutMs: number);
12
+ }
13
+ export type SetupLeg = "read-access" | "app-control" | "shortcuts" | "url-scheme";
5
14
  /**
6
15
  * Where a leg stands. `pending` is a HUMAN-pace outcome (a toggle not yet
7
16
  * flipped, a sheet not yet clicked) and resumes on a rerun; `denied` means
@@ -41,12 +50,21 @@ export interface DirectSetupDeps extends CapabilityDeps {
41
50
  openUrl?: (url: string) => void;
42
51
  /** Send the real Apple Event that mints an Automation grant. Throws on failure. */
43
52
  sendAutomationProbe?: (timeoutMs: number) => void;
44
- /** Open the container database once, deliberately, to provoke the app-data modal. */
45
- openContainer?: () => void;
53
+ /**
54
+ * Open the container database once, deliberately, to provoke the app-data
55
+ * modal, waiting no longer than `timeoutMs` for it to be answered. Throws
56
+ * {@link ContainerOpenTimedOut} at the deadline and any other error when the
57
+ * open itself failed.
58
+ */
59
+ openContainer?: (timeoutMs: number) => void;
60
+ /** How long the read leg waits for the app-data dialog (default 60s). */
61
+ containerOpenTimeoutMs?: number;
46
62
  /** Open one shortcut's install sheet. */
47
63
  openShortcut?: (file: string) => void;
48
64
  /** The installed proxy-shortcut census (availability.ts). */
49
65
  shortcutProxies?: () => ShortcutsState;
66
+ /** Things' own 'Enable Things URLs' standing, for leg (d) (capability.ts). */
67
+ urlSchemeStanding?: () => UrlSchemeCapability;
50
68
  automationTimeoutMs?: number;
51
69
  }
52
70
  export interface SetupSurvey {
@@ -56,6 +74,7 @@ export interface SetupSurvey {
56
74
  };
57
75
  read: ReadCapability;
58
76
  write: ReturnType<typeof writeCapability>;
77
+ urlScheme: UrlSchemeCapability;
59
78
  shortcutsMissing: string[];
60
79
  /** The legs that WOULD put something on screen. Empty means a rerun asks nothing. */
61
80
  outstanding: SetupLeg[];
@@ -64,8 +83,15 @@ export interface SetupSurvey {
64
83
  * What the ceremony would do, established entirely prompt-free. This is the
65
84
  * idempotence check (Article V): it is what lets a rerun skip settled legs, and
66
85
  * it is what `--dry-run` reports. Raises nothing, ever.
86
+ *
87
+ * `purpose` is the one side effect the survey can be asked for: the ceremony
88
+ * itself passes `dispatch` so a dormant Things is started before the dialogs
89
+ * are COUNTED (#617) — otherwise a machine whose app happens to be closed is
90
+ * told "nothing to raise" and then shown a dialog anyway. `--dry-run` keeps the
91
+ * default and starts nothing at all, at the cost of not knowing where a closed
92
+ * app's grant stands; it says so through the write verdict it reports.
67
93
  */
68
- export declare function surveySetup(deps?: DirectSetupDeps): SetupSurvey;
94
+ export declare function surveySetup(deps?: DirectSetupDeps, options?: WriteCapabilityOptions): SetupSurvey;
69
95
  /**
70
96
  * Run the direct-path ceremony. Strict mode: the banner counts what is about
71
97
  * to appear, waits are bounded, and an unanswered leg leaves the run nonzero.
@@ -19,6 +19,17 @@
19
19
  * instead: durable, but it hands the whole disk to a general-purpose host
20
20
  * app, so it is offered, never assumed.
21
21
  *
22
+ * The provoking open runs in a BOUNDED CHILD process, because macOS parks
23
+ * the requesting syscall in the kernel until someone answers the dialog —
24
+ * an in-process open would park the ceremony itself for as long as the
25
+ * dialog stands. MEASURED (APDP1, docs/lab/apdp1-grant-pinning.md): the
26
+ * app-data grant is keyed to the RESPONSIBLE APP INSTANCE, not to the pid
27
+ * that opened the file, so what a child provokes belongs to the host app
28
+ * and outlives that child — every later process under the same host app
29
+ * reads without a dialog. Killing the child at the deadline takes neither
30
+ * the dialog nor the grant away: a human who answers Allow afterwards still
31
+ * grants the host app, and the next run witnesses it.
32
+ *
22
33
  * MEASURED: FDA does NOT take effect for a running app. macOS says so in
23
34
  * the Settings sheet itself — "…will not have full disk access until it is
24
35
  * quit", with Later / Quit & Reopen — and the responsible process keeps its
@@ -35,6 +46,12 @@
35
46
  * Settings toggle and the `tccutil` re-arm and leaves the choice to the human.
36
47
  * c. SHORTCUTS. The bundled proxies that carry the operations no other surface
37
48
  * can perform. An install sheet per missing shortcut; no macOS consent.
49
+ * d. THINGS URLS. The odd one out: not a macOS grant at all, but Things' own
50
+ * Settings ▸ General ▸ "Enable Things URLs". It raises nothing and cannot be
51
+ * flipped from here, so this leg only DETECTS and instructs — and it earns
52
+ * its place because the off state is otherwise invisible: the app parks
53
+ * every URL command in an alert on its own window rather than running it
54
+ * (URLEN1, #611), which a fresh install hits on its very first write.
38
55
  *
39
56
  * There is deliberately NO Accessibility leg: GUI-driving is helpers-only
40
57
  * (Article IV), so when `ui.enabled` is set this ceremony says so and points at
@@ -53,10 +70,10 @@
53
70
  * inside this ceremony only.
54
71
  */
55
72
  import { execFileSync } from "node:child_process";
56
- import { existsSync, openSync, closeSync } from "node:fs";
73
+ import { existsSync } from "node:fs";
57
74
  import { join } from "node:path";
58
75
  import { fileURLToPath } from "node:url";
59
- import { hostApp, hostDisplayName, readCapability, writeCapability, } from "./capability.js";
76
+ import { hostApp, hostDisplayName, readCapability, urlSchemeCapability, writeCapability, } from "./capability.js";
60
77
  import { loadConfig } from "./config.js";
61
78
  import { locateThingsDb } from "./db/locate.js";
62
79
  import { clearSessionGrant, witnessSessionGrant } from "./session-grant.js";
@@ -69,6 +86,30 @@ const AUTOMATION_SETTINGS_URL = "x-apple.systempreferences:com.apple.preference.
69
86
  /** Package root — one level above src/ AND dist/, so both layouts resolve. */
70
87
  const SHORTCUTS_DIR = fileURLToPath(new URL("../shortcuts", import.meta.url));
71
88
  const AUTOMATION_TIMEOUT_MS = 60_000;
89
+ /** How long the read leg waits for the app-data dialog before giving up. */
90
+ const CONTAINER_OPEN_TIMEOUT_MS = 60_000;
91
+ /**
92
+ * The bounded child's whole job: one `open(2)` against the container, then
93
+ * exit. A dynamic import so the same source runs whether node evaluates `-e`
94
+ * as CommonJS or as an ES module; the failure path writes ONLY the errno
95
+ * message, because an unhandled rejection would dump a stack trace whose first
96
+ * line is a node internal rather than the reason.
97
+ */
98
+ const CONTAINER_OPEN_CHILD = 'import("node:fs").then((fs) => fs.closeSync(fs.openSync(process.argv[1], "r")))' +
99
+ ".catch((e) => { process.stderr.write(String((e && e.message) || e)); process.exit(1); });";
100
+ /**
101
+ * The deadline passed with the app-data dialog still unanswered. Distinct from
102
+ * a refusal: nothing was decided, the dialog is still on screen, and answering
103
+ * it later still lands the grant on the host app (APDP1 stage A).
104
+ */
105
+ export class ContainerOpenTimedOut extends Error {
106
+ timeoutMs;
107
+ constructor(timeoutMs) {
108
+ super(`the app-data dialog was not answered within ${Math.round(timeoutMs / 1000)}s`);
109
+ this.name = "ContainerOpenTimedOut";
110
+ this.timeoutMs = timeoutMs;
111
+ }
112
+ }
72
113
  /** The key that picks Full Disk Access over the session grant at the read leg. */
73
114
  const FDA_CHOICE_KEY = "f";
74
115
  function openUrlBestEffort(url) {
@@ -79,14 +120,47 @@ function openUrlBestEffort(url) {
79
120
  // The deep link is a convenience; the written path works without it.
80
121
  }
81
122
  }
123
+ /** First line of whatever a failed child wrote to stderr. */
124
+ function firstStderrLine(err) {
125
+ const e = err;
126
+ const text = typeof e.stderr === "string"
127
+ ? e.stderr
128
+ : Buffer.isBuffer(e.stderr)
129
+ ? e.stderr.toString("utf8")
130
+ : err instanceof Error
131
+ ? err.message
132
+ : String(err);
133
+ return text.trim().split("\n")[0] ?? "";
134
+ }
82
135
  /**
83
136
  * The container open the ceremony performs on purpose. This is the ONE place
84
137
  * in the package permitted to do it blind — everywhere else the doctrine's
85
138
  * Article I corollary forbids it, because the open is what raises the modal.
139
+ *
140
+ * It runs in a CHILD process so the wait has a deadline (see the read-access
141
+ * note at the top of this file): macOS holds the open in the kernel for as long
142
+ * as the dialog stands, and the grant it lands belongs to the host app rather
143
+ * than to the pid that asked, so nothing is lost by giving up on the child.
86
144
  */
87
- function openContainerDefault() {
88
- const fd = openSync(locateThingsDb().path, "r");
89
- closeSync(fd);
145
+ function openContainerDefault(timeoutMs) {
146
+ const path = locateThingsDb().path;
147
+ try {
148
+ execFileSync(process.execPath, ["-e", CONTAINER_OPEN_CHILD, path], {
149
+ stdio: ["ignore", "ignore", "pipe"],
150
+ timeout: timeoutMs,
151
+ killSignal: "SIGKILL",
152
+ });
153
+ }
154
+ catch (err) {
155
+ const e = err;
156
+ // spawnSync reports a deadline kill as ETIMEDOUT, as `killed`, or as the
157
+ // kill signal itself, depending on where it noticed — all three mean the
158
+ // dialog outlived the wait.
159
+ if (e.code === "ETIMEDOUT" || e.killed === true || e.signal === "SIGKILL") {
160
+ throw new ContainerOpenTimedOut(timeoutMs);
161
+ }
162
+ throw new Error(firstStderrLine(err) || "the container could not be opened", { cause: err });
163
+ }
90
164
  }
91
165
  function sendAutomationProbeDefault(timeoutMs) {
92
166
  // `count of areas` dispatches a REAL Apple event. Properties like `version`
@@ -103,14 +177,28 @@ function sendAutomationProbeDefault(timeoutMs) {
103
177
  * The two ways to read, offered as a choice rather than a ranking. Enter takes
104
178
  * the session grant; `f` takes Full Disk Access, which is the wider grant and
105
179
  * the one that costs the human a relaunch.
180
+ *
181
+ * The Enter line states what the session grant actually buys, as MEASURED
182
+ * (APDP1): one Allow covers every process under this host app — this window,
183
+ * other tabs and windows, and anything they spawn — until the app quits. Under
184
+ * tmux that app is the one that first started the tmux server rather than
185
+ * whatever window you are attached from, because macOS fixes responsibility at
186
+ * spawn and it survives re-parenting; the caveat is printed only when `TMUX`
187
+ * says so, and nothing is detected to produce it.
106
188
  */
107
- function readAccessChoice(hostName) {
108
- return [
189
+ function readAccessChoice(hostName, env) {
190
+ const lines = [
109
191
  "Next: read access to your Things data — two ways:",
110
- ` Enter allow this session only: a dialog asks now; access ends when ${hostName} quits`,
192
+ ` Enter allow while ${hostName} runs: one dialog now, then every command under`,
193
+ ` ${hostName} — any tab, window, or agent it spawns — reads without asking,`,
194
+ ` until ${hostName} quits`,
111
195
  ` f Full Disk Access: durable, but grants ${hostName} broad file access —`,
112
196
  ` flip it in System Settings, then ${hostName} must quit and reopen`,
113
197
  ];
198
+ if ((env["TMUX"] ?? "") !== "") {
199
+ lines.push(` note: inside tmux the grant belongs to the app that started the tmux server, and`, ` lasts until THAT app quits — not the window you are attached from`);
200
+ }
201
+ return lines;
114
202
  }
115
203
  /**
116
204
  * The `f` branch. Nothing here waits: FDA reaches a process only through a
@@ -135,9 +223,10 @@ function fdaBranch(base, hostName, deps) {
135
223
  }
136
224
  /**
137
225
  * The default branch: provoke the app-data modal on purpose and record the
138
- * grant only if the open then actually succeeded. The wait is the modal's own —
139
- * macOS holds the open until someone answers it, which is the premise of a
140
- * ceremony.
226
+ * grant only if the open then actually succeeded. The wait is BOUNDED the
227
+ * open runs in a child process the ceremony can give up on, and giving up
228
+ * costs nothing, because a dialog answered afterwards still grants the host
229
+ * app (APDP1).
141
230
  */
142
231
  function sessionGrantBranch(base, hostName, deps) {
143
232
  const progress = deps.progress ?? (() => { });
@@ -145,18 +234,37 @@ function sessionGrantBranch(base, hostName, deps) {
145
234
  "other apps; click Allow");
146
235
  const host = hostApp(deps);
147
236
  try {
148
- (deps.openContainer ?? openContainerDefault)();
237
+ (deps.openContainer ?? openContainerDefault)(deps.containerOpenTimeoutMs ?? CONTAINER_OPEN_TIMEOUT_MS);
149
238
  }
150
239
  catch (err) {
151
240
  clearSessionGrant(deps.env ?? process.env);
241
+ if (err instanceof ContainerOpenTimedOut) {
242
+ // Nothing was decided and the dialog is still up: say so, because the
243
+ // human's next click still lands the grant on this same host app.
244
+ progress("read access: no answer yet — the dialog is still on screen");
245
+ return {
246
+ ...base,
247
+ state: "pending",
248
+ alreadySatisfied: false,
249
+ detail: `the dialog is still waiting — click Allow and rerun \`things setup\` to confirm it, ` +
250
+ "choose Full Disk Access at the read step instead, or run `things helpers setup` to " +
251
+ "let a helper hold the grant",
252
+ };
253
+ }
152
254
  const why = err instanceof Error ? err.message : String(err);
153
255
  progress(`read access: still no access — ${why}`);
154
256
  return {
155
257
  ...base,
156
258
  state: "pending",
157
259
  alreadySatisfied: false,
158
- detail: "no read access yet rerun and answer the dialog, choose Full Disk Access at the " +
159
- "read step instead, or run `things helpers setup` to let a helper hold the grant",
260
+ // The open failed. Usually that is a Don't Allow which then stands for
261
+ // the whole run of this app, every later open failing instantly with no
262
+ // second dialog (APDP1 stage B) — but the errno could also be something
263
+ // else entirely, so the copy hedges the cause and states the remedy.
264
+ detail: `no read access yet — if the dialog was refused, that answer stands for the rest of ` +
265
+ `this ${hostName} run and macOS will not ask again, so quit and reopen ${hostName} to ` +
266
+ "be asked; or choose Full Disk Access at the read step, or run `things helpers setup` " +
267
+ "to let a helper hold the grant",
160
268
  };
161
269
  }
162
270
  const witnessed = witnessSessionGrant(host.bundleId ?? "", deps);
@@ -169,13 +277,15 @@ function sessionGrantBranch(base, hostName, deps) {
169
277
  "grant could be tied to — choose Full Disk Access instead, or run `things helpers setup`",
170
278
  };
171
279
  }
172
- progress("read access: granted for as long as this app stays open");
280
+ progress(`read access: granted every command under ${hostName}, in any tab or window, reads ` +
281
+ `without asking until ${hostName} quits`);
173
282
  return {
174
283
  ...base,
175
284
  state: "granted",
176
285
  alreadySatisfied: false,
177
- detail: `${hostName} may read the Things data folder until it quits. Full Disk Access makes ` +
178
- "it permanent; `things helpers setup` moves it onto a helper that keeps it across restarts",
286
+ detail: `every command running under ${hostName} any tab, window, or agent it spawns may ` +
287
+ `read the Things data folder until ${hostName} quits. Full Disk Access makes it ` +
288
+ "permanent; `things helpers setup` moves it onto a helper that keeps it across restarts",
179
289
  };
180
290
  }
181
291
  function readAccessLeg(capability, choice, deps) {
@@ -196,7 +306,8 @@ function readAccessLeg(capability, choice, deps) {
196
306
  return { ...base, state: "granted", alreadySatisfied: true, detail: capability.detail };
197
307
  }
198
308
  if (capability.mode === "session-grant") {
199
- progress("read access: already granted for as long as this app stays open");
309
+ progress(`read access: already granted every command under ${hostName} reads without asking ` +
310
+ `until ${hostName} quits`);
200
311
  return { ...base, state: "granted", alreadySatisfied: true, detail: capability.detail };
201
312
  }
202
313
  // Nothing on record: the human's choice decides which grant this leg gathers.
@@ -208,7 +319,11 @@ function readAccessLeg(capability, choice, deps) {
208
319
  function appControlLeg(deps) {
209
320
  const base = { leg: "app-control", label: "app control" };
210
321
  const progress = deps.progress ?? (() => { });
211
- const capability = writeCapability(deps);
322
+ // DISPATCH intent: this leg sends Things a real Apple Event a few lines down,
323
+ // and an Apple Event to a closed Things launches it WITH focus steal
324
+ // (A40/A41). Starting it first is both the honest way to read the standing
325
+ // (#617) and the quieter way to raise the dialog.
326
+ const capability = writeCapability({ purpose: "dispatch" }, deps);
212
327
  const hostName = hostDisplayName(deps);
213
328
  if (capability.mode === "deputy") {
214
329
  progress("app control: already held by the helpers");
@@ -276,7 +391,7 @@ function appControlLeg(deps) {
276
391
  };
277
392
  }
278
393
  // A zero exit is not believed on its own: re-read what macOS actually records.
279
- const after = writeCapability(deps);
394
+ const after = writeCapability({ purpose: "dispatch" }, deps);
280
395
  if (after.mode === "direct-granted" || after.mode === "deputy") {
281
396
  progress("app control: granted");
282
397
  return { ...base, state: "granted", alreadySatisfied: false, detail: "granted" };
@@ -334,6 +449,40 @@ function shortcutsLeg(deps) {
334
449
  : `could not open: ${failures.join(", ")}`,
335
450
  };
336
451
  }
452
+ // ── Leg (d): Things' own URL authorization ───────────────────────────────────
453
+ /**
454
+ * The one leg that raises NOTHING. Things' "Enable Things URLs" is the app's own
455
+ * switch, not a macOS grant: there is no dialog for this ceremony to provoke and
456
+ * nothing it can flip on the human's behalf. What it can do is SAY SO — because
457
+ * the state is silent from every other angle. MEASURED (URLEN1): with the
458
+ * setting off, or never answered, the app puts a "Things URL Scheme" alert on
459
+ * its own window and PARKS the command behind it, so an unattended write reads
460
+ * as a silent no-op minutes later (#611). A fresh install has never answered it,
461
+ * which is precisely when someone is running this ceremony.
462
+ *
463
+ * So the leg reports `pending` and names the toggle; the closing line then
464
+ * carries it as outstanding work and a rerun re-checks it. Settings panes are
465
+ * not deep-linkable the way System Settings panes are — `things:///preferences`
466
+ * is not a route (RESID1) — so the copy names the path instead of opening it.
467
+ */
468
+ function urlSchemeLeg(deps) {
469
+ const base = { leg: "url-scheme", label: "Things URLs" };
470
+ const progress = deps.progress ?? (() => { });
471
+ const standing = (deps.urlSchemeStanding ?? (() => urlSchemeCapability(deps)))();
472
+ if (standing.mode === "enabled") {
473
+ progress("things urls: on");
474
+ return { ...base, state: "granted", alreadySatisfied: true, detail: standing.detail };
475
+ }
476
+ if (standing.mode === "unreadable") {
477
+ // Nothing to report and nothing to ask for: this machine cannot see the
478
+ // setting, so claiming it is unset would be a guess.
479
+ return { ...base, state: "skipped", alreadySatisfied: false, detail: standing.detail };
480
+ }
481
+ progress("things urls: OFF — turn on Things ▸ Settings ▸ General ▸ Enable Things URLs, then rerun. " +
482
+ "Until it is on, Things holds URL commands in an alert on its own window instead of " +
483
+ "running them");
484
+ return { ...base, state: "pending", alreadySatisfied: false, detail: standing.detail };
485
+ }
337
486
  // ── The ceremony ─────────────────────────────────────────────────────────────
338
487
  /**
339
488
  * What each leg puts on screen, for the upfront banner. Named flatly, in the
@@ -347,6 +496,11 @@ function promptLabel(leg, hostName) {
347
496
  return "app control of Things";
348
497
  case "shortcuts":
349
498
  return "one install sheet per missing shortcut";
499
+ case "url-scheme":
500
+ // Unreachable in practice: this leg raises nothing, so it is never put in
501
+ // `outstanding` — the list this function labels. The case exists because
502
+ // the union must be covered, not because anything prints it.
503
+ return "nothing — the Things URLs setting is flipped by hand";
350
504
  }
351
505
  }
352
506
  /** "a", "a and b", "a, b, and c" — the banner reads as a sentence. */
@@ -363,7 +517,8 @@ function listPhrase(items) {
363
517
  * strict mode they are never printed; the upfront banner's count stands alone.
364
518
  * `{host}` is filled with the detected host app's display name. The read leg is
365
519
  * absent because it is a CHOICE rather than an announcement — see
366
- * {@link readAccessChoice}.
520
+ * {@link readAccessChoice}; the url-scheme leg is absent because it raises
521
+ * nothing there is anything to explain in advance of.
367
522
  */
368
523
  const PROMPT_EXPLAINERS = {
369
524
  "app-control": [
@@ -396,12 +551,20 @@ function closingLine(steps, uiEnabled) {
396
551
  * What the ceremony would do, established entirely prompt-free. This is the
397
552
  * idempotence check (Article V): it is what lets a rerun skip settled legs, and
398
553
  * it is what `--dry-run` reports. Raises nothing, ever.
554
+ *
555
+ * `purpose` is the one side effect the survey can be asked for: the ceremony
556
+ * itself passes `dispatch` so a dormant Things is started before the dialogs
557
+ * are COUNTED (#617) — otherwise a machine whose app happens to be closed is
558
+ * told "nothing to raise" and then shown a dialog anyway. `--dry-run` keeps the
559
+ * default and starts nothing at all, at the cost of not knowing where a closed
560
+ * app's grant stands; it says so through the write verdict it reports.
399
561
  */
400
- export function surveySetup(deps = {}) {
562
+ export function surveySetup(deps = {}, options = {}) {
401
563
  const host = hostApp(deps);
402
564
  const read = readCapability({}, deps);
403
- const write = writeCapability(deps);
565
+ const write = writeCapability(options, deps);
404
566
  const shortcuts = (deps.shortcutProxies ?? readShortcutProxies)();
567
+ const urlScheme = (deps.urlSchemeStanding ?? (() => urlSchemeCapability(deps)))();
405
568
  const outstanding = [];
406
569
  if (read.mode !== "direct-fda" && read.mode !== "session-grant" && read.mode !== "helpers") {
407
570
  outstanding.push("read-access");
@@ -411,10 +574,14 @@ export function surveySetup(deps = {}) {
411
574
  outstanding.push("app-control");
412
575
  if (shortcuts.missing.length > 0)
413
576
  outstanding.push("shortcuts");
577
+ // The URL-scheme leg is deliberately NOT added to `outstanding`: that list is
578
+ // "dialogs this ceremony is about to raise", and this leg raises none. It is
579
+ // reported as a step and carried by the closing line instead.
414
580
  return {
415
581
  host: { bundleId: host.bundleId, name: hostDisplayName(deps) },
416
582
  read,
417
583
  write,
584
+ urlScheme,
418
585
  shortcutsMissing: [...shortcuts.missing],
419
586
  outstanding,
420
587
  };
@@ -439,7 +606,7 @@ function runCeremony(deps) {
439
606
  const hostName = hostDisplayName(withProgress);
440
607
  // Survey prompt-free BEFORE raising anything, so whoever started this knows
441
608
  // whether they must stay at the screen (Article V).
442
- const survey = surveySetup(withProgress);
609
+ const survey = surveySetup(withProgress, { purpose: "dispatch" });
443
610
  const readBefore = survey.read;
444
611
  const outstanding = survey.outstanding;
445
612
  progress(`setting up direct access for ${hostName}${host.bundleId !== null ? ` (${host.bundleId})` : ""}`);
@@ -460,13 +627,20 @@ function runCeremony(deps) {
460
627
  // grant, `f` takes Full Disk Access. Strict mode answers "" without asking,
461
628
  // which is the session grant — the only one an absent human can still get.
462
629
  const readChoice = willRaise.has("read-access")
463
- ? wizard.choose(readAccessChoice(hostName), [FDA_CHOICE_KEY])
630
+ ? wizard.choose(readAccessChoice(hostName, env), [FDA_CHOICE_KEY])
464
631
  : "";
465
632
  const readStep = readAccessLeg(readBefore, readChoice, withProgress);
466
633
  brief("app-control");
467
634
  const appControlStep = appControlLeg(withProgress);
468
635
  brief("shortcuts");
469
- const steps = [readStep, appControlStep, shortcutsLeg(withProgress)];
636
+ const steps = [
637
+ readStep,
638
+ appControlStep,
639
+ shortcutsLeg(withProgress),
640
+ // Last, and never briefed: it raises nothing, so there is no dialog to
641
+ // explain one leg ahead (Article V) — it only reports and instructs.
642
+ urlSchemeLeg(withProgress),
643
+ ];
470
644
  const uiEnabled = loadConfig(env).ui.enabled;
471
645
  if (uiEnabled) {
472
646
  progress("note: GUI-driving is enabled in config, and it is granted only to the helpers — " +