things-api 0.18.0 → 0.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -9
- package/deputy/AppIcon.icns +0 -0
- package/deputy/VERSION +1 -1
- package/deputy/helpers-Info.plist +4 -0
- package/deputy/prebuilt/Things API Helper.app/Contents/CodeResources +0 -0
- package/deputy/prebuilt/Things API Helper.app/Contents/Helpers/things-reader.app/Contents/Info.plist +3 -1
- package/deputy/prebuilt/Things API Helper.app/Contents/Helpers/things-reader.app/Contents/MacOS/things-reader +0 -0
- package/deputy/prebuilt/Things API Helper.app/Contents/Helpers/things-reader.app/Contents/Resources/AppIcon.icns +0 -0
- package/deputy/prebuilt/Things API Helper.app/Contents/Helpers/things-reader.app/Contents/_CodeSignature/CodeResources +15 -2
- package/deputy/prebuilt/Things API Helper.app/Contents/Info.plist +5 -1
- package/deputy/prebuilt/Things API Helper.app/Contents/MacOS/things-deputy +0 -0
- package/deputy/prebuilt/Things API Helper.app/Contents/Resources/AppIcon.icns +0 -0
- package/deputy/prebuilt/Things API Helper.app/Contents/_CodeSignature/CodeResources +14 -2
- package/deputy/reader/Info.plist +2 -0
- package/deputy/reader/entitlements.plist +30 -0
- package/deputy/reader/main.swift +129 -40
- package/deputy/src/server.swift +25 -2
- package/deputy/src/tcc.swift +58 -0
- package/dist/audit/schema.d.ts +30 -1
- package/dist/audit/schema.js.map +1 -1
- package/dist/capability.d.ts +322 -0
- package/dist/capability.js +706 -0
- package/dist/capability.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +13 -1
- package/dist/cli/commands/doctor.js +141 -5
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/commands/helpers.js +189 -51
- package/dist/cli/commands/helpers.js.map +1 -1
- package/dist/cli/commands/mcp.js +8 -0
- package/dist/cli/commands/mcp.js.map +1 -1
- package/dist/cli/commands/op-result.js +6 -0
- package/dist/cli/commands/op-result.js.map +1 -1
- package/dist/cli/commands/reads.js +47 -1
- package/dist/cli/commands/reads.js.map +1 -1
- package/dist/cli/commands/repeat-flags.js +34 -2
- package/dist/cli/commands/repeat-flags.js.map +1 -1
- package/dist/cli/commands/setup.d.ts +9 -0
- package/dist/cli/commands/setup.js +76 -83
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/commands/writes.d.ts +1 -1
- package/dist/cli/commands/writes.js +311 -142
- package/dist/cli/commands/writes.js.map +1 -1
- package/dist/cli/dry-run.d.ts +1 -1
- package/dist/cli/dry-run.js +1 -1
- package/dist/cli/glyphs.d.ts +23 -4
- package/dist/cli/glyphs.js +46 -19
- package/dist/cli/glyphs.js.map +1 -1
- package/dist/cli/help.d.ts +1 -1
- package/dist/cli/help.js +49 -27
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/interrupt.d.ts +54 -6
- package/dist/cli/interrupt.js +78 -12
- package/dist/cli/interrupt.js.map +1 -1
- package/dist/cli/main.js +8 -5
- package/dist/cli/main.js.map +1 -1
- package/dist/cli/period.d.ts +3 -1
- package/dist/cli/period.js +1 -1
- package/dist/cli/period.js.map +1 -1
- package/dist/cli/read-driver.js +26 -1
- package/dist/cli/read-driver.js.map +1 -1
- package/dist/cli/render.d.ts +31 -4
- package/dist/cli/render.js +127 -15
- package/dist/cli/render.js.map +1 -1
- package/dist/client.d.ts +23 -3
- package/dist/client.js +36 -13
- package/dist/client.js.map +1 -1
- package/dist/contracts.d.ts +8 -4
- package/dist/contracts.js +1 -1
- package/dist/contracts.js.map +1 -1
- package/dist/deputy/install.d.ts +234 -6
- package/dist/deputy/install.js +843 -31
- package/dist/deputy/install.js.map +1 -1
- package/dist/deputy/notices.js +2 -2
- package/dist/deputy/notices.js.map +1 -1
- package/dist/deputy/protocol.d.ts +59 -5
- package/dist/deputy/protocol.js +48 -11
- package/dist/deputy/protocol.js.map +1 -1
- package/dist/deputy/routing.d.ts +37 -0
- package/dist/deputy/routing.js +181 -27
- package/dist/deputy/routing.js.map +1 -1
- package/dist/deputy/wake.d.ts +61 -0
- package/dist/deputy/wake.js +149 -0
- package/dist/deputy/wake.js.map +1 -0
- package/dist/diagnose.d.ts +19 -4
- package/dist/diagnose.js +64 -8
- package/dist/diagnose.js.map +1 -1
- package/dist/direct-setup.d.ts +104 -0
- package/dist/direct-setup.js +658 -0
- package/dist/direct-setup.js.map +1 -0
- package/dist/host-access.d.ts +75 -0
- package/dist/host-access.js +177 -0
- package/dist/host-access.js.map +1 -0
- package/dist/index.d.ts +20 -5
- package/dist/index.js +14 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/server.d.ts +27 -1
- package/dist/mcp/server.js +308 -109
- package/dist/mcp/server.js.map +1 -1
- package/dist/op-result.d.ts +9 -0
- package/dist/op-result.js +13 -1
- package/dist/op-result.js.map +1 -1
- package/dist/read/filter-contract.d.ts +1 -1
- package/dist/read/filter-contract.js +4 -0
- package/dist/read/filter-contract.js.map +1 -1
- package/dist/read/shape.js +4 -0
- package/dist/read/shape.js.map +1 -1
- package/dist/read/views.d.ts +29 -0
- package/dist/read/views.js +60 -0
- package/dist/read/views.js.map +1 -1
- package/dist/session-grant.d.ts +48 -0
- package/dist/session-grant.js +185 -0
- package/dist/session-grant.js.map +1 -0
- package/dist/surface-copy.d.ts +19 -3
- package/dist/surface-copy.js +19 -3
- package/dist/surface-copy.js.map +1 -1
- package/dist/wizard.d.ts +58 -0
- package/dist/wizard.js +174 -0
- package/dist/wizard.js.map +1 -0
- package/dist/write/availability.d.ts +1 -16
- package/dist/write/availability.js +10 -65
- package/dist/write/availability.js.map +1 -1
- package/dist/write/batch.d.ts +20 -0
- package/dist/write/batch.js +111 -21
- package/dist/write/batch.js.map +1 -1
- package/dist/write/capabilities.d.ts +9 -0
- package/dist/write/capabilities.js +2 -0
- package/dist/write/capabilities.js.map +1 -1
- package/dist/write/clear-reminder.js +1 -1
- package/dist/write/clear-reminder.js.map +1 -1
- package/dist/write/commands.d.ts +22 -7
- package/dist/write/commands.js +231 -254
- package/dist/write/commands.js.map +1 -1
- package/dist/write/failure-hints.d.ts +32 -7
- package/dist/write/failure-hints.js +9 -14
- package/dist/write/failure-hints.js.map +1 -1
- package/dist/write/guards.js +22 -4
- package/dist/write/guards.js.map +1 -1
- package/dist/write/lock.d.ts +16 -13
- package/dist/write/lock.js +55 -0
- package/dist/write/lock.js.map +1 -1
- package/dist/write/make-repeating-project.js +9 -13
- package/dist/write/make-repeating-project.js.map +1 -1
- package/dist/write/move.js +9 -12
- package/dist/write/move.js.map +1 -1
- package/dist/write/operations.d.ts +51 -29
- package/dist/write/operations.js +16 -0
- package/dist/write/operations.js.map +1 -1
- package/dist/write/opid.d.ts +72 -14
- package/dist/write/opid.js +152 -8
- package/dist/write/opid.js.map +1 -1
- package/dist/write/param-schema.d.ts +80 -0
- package/dist/write/param-schema.js +754 -0
- package/dist/write/param-schema.js.map +1 -0
- package/dist/write/pipeline.d.ts +110 -5
- package/dist/write/pipeline.js +288 -14
- package/dist/write/pipeline.js.map +1 -1
- package/dist/write/pre-state.d.ts +38 -16
- package/dist/write/pre-state.js +117 -22
- package/dist/write/pre-state.js.map +1 -1
- package/dist/write/promote-clone.js +658 -444
- package/dist/write/promote-clone.js.map +1 -1
- package/dist/write/reorder.js +25 -8
- package/dist/write/reorder.js.map +1 -1
- package/dist/write/repeat-collateral.d.ts +31 -0
- package/dist/write/repeat-collateral.js +153 -0
- package/dist/write/repeat-collateral.js.map +1 -0
- package/dist/write/repeat-rule.d.ts +28 -1
- package/dist/write/repeat-rule.js +54 -4
- package/dist/write/repeat-rule.js.map +1 -1
- package/dist/write/resolution-timestamps.d.ts +11 -0
- package/dist/write/resolution-timestamps.js +108 -40
- package/dist/write/resolution-timestamps.js.map +1 -1
- package/dist/write/reversibility.js +4 -0
- package/dist/write/reversibility.js.map +1 -1
- package/dist/write/template-mutation.d.ts +137 -0
- package/dist/write/template-mutation.js +598 -0
- package/dist/write/template-mutation.js.map +1 -0
- package/dist/write/undo.js +10 -20
- package/dist/write/undo.js.map +1 -1
- package/dist/write/update-fields.d.ts +151 -0
- package/dist/write/update-fields.js +427 -0
- package/dist/write/update-fields.js.map +1 -0
- package/dist/write/vectors/applescript.js +6 -10
- package/dist/write/vectors/applescript.js.map +1 -1
- package/dist/write/vectors/registry.d.ts +1 -1
- package/dist/write/vectors/registry.js +10 -2
- package/dist/write/vectors/registry.js.map +1 -1
- package/dist/write/vectors/shortcuts.js +2 -2
- package/dist/write/vectors/shortcuts.js.map +1 -1
- package/dist/write/vectors/simulator.js +15 -4
- package/dist/write/vectors/simulator.js.map +1 -1
- package/dist/write/vectors/types.d.ts +268 -1
- package/dist/write/vectors/ui-certification.js +63 -13
- package/dist/write/vectors/ui-certification.js.map +1 -1
- package/dist/write/vectors/ui-chord.d.ts +144 -0
- package/dist/write/vectors/ui-chord.js +428 -0
- package/dist/write/vectors/ui-chord.js.map +1 -0
- package/dist/write/vectors/ui-drag.d.ts +8 -4
- package/dist/write/vectors/ui-drag.js +2 -0
- package/dist/write/vectors/ui-drag.js.map +1 -1
- package/dist/write/vectors/ui-recipes.d.ts +70 -3
- package/dist/write/vectors/ui-recipes.js +482 -44
- package/dist/write/vectors/ui-recipes.js.map +1 -1
- package/dist/write/vectors/ui.d.ts +280 -10
- package/dist/write/vectors/ui.js +1068 -77
- package/dist/write/vectors/ui.js.map +1 -1
- package/dist/write/vectors/url-scheme.js +3 -0
- package/dist/write/vectors/url-scheme.js.map +1 -1
- package/dist/write/verify/delta.d.ts +62 -0
- package/dist/write/verify/delta.js +36 -2
- package/dist/write/verify/delta.js.map +1 -1
- package/dist/write/verify/poller.d.ts +4 -1
- package/dist/write/verify/poller.js +14 -0
- package/dist/write/verify/poller.js.map +1 -1
- package/package.json +2 -1
- package/schema/envelope.schema.json +6 -4
- package/scripts/build-helpers.sh +5 -0
- package/skills/things-cli/SKILL.md +5 -3
- package/skills/things-cli/references/contracts.md +1 -0
- package/skills/things-cli/references/data-model.md +3 -0
- package/skills/things-cli/references/errors.md +1 -1
- package/skills/things-cli/references/gui.md +1 -0
- package/skills/things-cli/references/repeating.md +6 -0
- package/skills/things-cli/references/tag-cleanup.md +64 -0
package/dist/deputy/routing.js
CHANGED
|
@@ -11,17 +11,33 @@
|
|
|
11
11
|
*
|
|
12
12
|
* The tri-state (docs/design/agent-daemon.md §3c):
|
|
13
13
|
*
|
|
14
|
-
* | mode | helper absent
|
|
15
|
-
*
|
|
16
|
-
* | `auto` | direct, SILENT
|
|
17
|
-
* | `true` | direct, LOUD
|
|
18
|
-
* | `false` | direct, silent
|
|
14
|
+
* | mode | helper absent | installed, unhealthy | healthy, NOT onboarded | healthy + onboarded |
|
|
15
|
+
* |---------|----------------|----------------------|------------------------|---------------------|
|
|
16
|
+
* | `auto` | direct, SILENT | direct, LOUD | direct, LOUD | routed |
|
|
17
|
+
* | `true` | direct, LOUD | direct, LOUD | routed | routed |
|
|
18
|
+
* | `false` | direct, silent | direct, silent | direct, silent | direct, silent |
|
|
19
19
|
*
|
|
20
20
|
* Under `auto` installation IS the intent signal, so absence is not a
|
|
21
21
|
* degradation to report (a fresh machine must not nag) while an installed
|
|
22
22
|
* helper that cannot serve is — silence there would hide the very consent churn
|
|
23
23
|
* the helpers exist to end.
|
|
24
24
|
*
|
|
25
|
+
* There is no "installed but unpermissioned" routing state under `auto`: a
|
|
26
|
+
* deputy without an app-control grant for Things would move the consent dialog
|
|
27
|
+
* onto the helper, where nobody is watching for it, so it stays DORMANT until
|
|
28
|
+
* `things helpers setup` proves the grant. Each half is gated on its OWN
|
|
29
|
+
* requisite — writes on the deputy's `automation.things`, reads on the
|
|
30
|
+
* reader's bookmark grant — so a machine that finished half the ceremony gets
|
|
31
|
+
* the half it earned. Accessibility and System Events are NOT requisite: the
|
|
32
|
+
* UI vector is separately double-gated and refuses on its own.
|
|
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
|
+
*
|
|
25
41
|
* Fallback is decided at ACTIVATION, never mid-operation: if a helper is
|
|
26
42
|
* expected but unreachable (or speaks a different protocol), the whole process
|
|
27
43
|
* runs direct with one stderr notice — a half-routed operation is worse than
|
|
@@ -31,6 +47,7 @@
|
|
|
31
47
|
import { execFileSync } from "node:child_process";
|
|
32
48
|
import { existsSync, readFileSync } from "node:fs";
|
|
33
49
|
import { loadConfig } from "../config.js";
|
|
50
|
+
import { readRendezvousToken, rendezvousExists } from "../host-access.js";
|
|
34
51
|
import { DeputySyncBridge } from "./bridge.js";
|
|
35
52
|
import { DeputyAsyncClient } from "./client.js";
|
|
36
53
|
import { emitHelpersNotice, resetHelpersNoticeForTests } from "./notice.js";
|
|
@@ -90,7 +107,7 @@ function reconcileVersions(bridge, token, first) {
|
|
|
90
107
|
}
|
|
91
108
|
catch {
|
|
92
109
|
// Not installed under launchd (foreground/test deputy) — nothing to restart.
|
|
93
|
-
notice(true, `installed helpers are v${first.deputyVersion}, this package expects v${EXPECTED_HELPERS_VERSION} (same protocol) — proceeding; rebuild with \`bash scripts/build-helpers.sh\` + \`things helpers
|
|
110
|
+
notice(true, `installed helpers are v${first.deputyVersion}, this package expects v${EXPECTED_HELPERS_VERSION} (same protocol) — proceeding; rebuild with \`bash scripts/build-helpers.sh\` + \`things helpers setup\` to align`);
|
|
94
111
|
return first;
|
|
95
112
|
}
|
|
96
113
|
for (let attempt = 0; attempt < 8; attempt++) {
|
|
@@ -105,7 +122,7 @@ function reconcileVersions(bridge, token, first) {
|
|
|
105
122
|
}
|
|
106
123
|
}
|
|
107
124
|
const current = hello(bridge, token);
|
|
108
|
-
notice(true, `installed helpers are v${current.deputyVersion}, this package expects v${EXPECTED_HELPERS_VERSION} (same protocol) — proceeding; rebuild with \`bash scripts/build-helpers.sh\` + \`things helpers
|
|
125
|
+
notice(true, `installed helpers are v${current.deputyVersion}, this package expects v${EXPECTED_HELPERS_VERSION} (same protocol) — proceeding; rebuild with \`bash scripts/build-helpers.sh\` + \`things helpers setup\` to align`);
|
|
109
126
|
return current;
|
|
110
127
|
}
|
|
111
128
|
/**
|
|
@@ -130,7 +147,7 @@ function activate(env) {
|
|
|
130
147
|
if (!existsSync(socketPath) || !existsSync(tokenPath)) {
|
|
131
148
|
notice(loud, `${installed
|
|
132
149
|
? `installed but not running (no socket at ${socketPath})`
|
|
133
|
-
: "not installed on this machine"} — running DIRECT, so TCC prompts attach to this process. \`things helpers ${installed ? "status` to inspect" : "
|
|
150
|
+
: "not installed on this machine"} — running DIRECT, so TCC prompts attach to this process. \`things helpers ${installed ? "status` to inspect" : "setup` to change that"}.`);
|
|
134
151
|
return {
|
|
135
152
|
active: false,
|
|
136
153
|
reason: installed
|
|
@@ -155,13 +172,54 @@ function activate(env) {
|
|
|
155
172
|
}
|
|
156
173
|
if (helloResult.protocol !== DEPUTY_PROTOCOL_VERSION) {
|
|
157
174
|
bridge.close();
|
|
158
|
-
notice(true, `the deputy speaks protocol ${helloResult.protocol}, this package speaks ${DEPUTY_PROTOCOL_VERSION} — running DIRECT. Rebuild with \`bash scripts/build-helpers.sh\` + \`things helpers
|
|
175
|
+
notice(true, `the deputy speaks protocol ${helloResult.protocol}, this package speaks ${DEPUTY_PROTOCOL_VERSION} — running DIRECT. Rebuild with \`bash scripts/build-helpers.sh\` + \`things helpers setup\`.`);
|
|
159
176
|
return {
|
|
160
177
|
active: false,
|
|
161
178
|
reason: `protocol skew (deputy ${helloResult.protocol}, library ${DEPUTY_PROTOCOL_VERSION})`,
|
|
162
179
|
hello: null,
|
|
163
180
|
};
|
|
164
181
|
}
|
|
182
|
+
// The onboarding gate. Routing writes through a deputy that has no
|
|
183
|
+
// app-control grant for Things does not move the consent surface anywhere —
|
|
184
|
+
// it just relocates the dialog to the helper, where nobody is looking. Under
|
|
185
|
+
// `auto` (installation is the intent signal, not a promise) the deputy must
|
|
186
|
+
// PROVE the grant before it carries traffic; `true` is an explicit
|
|
187
|
+
// instruction to route regardless and stays loud on failure.
|
|
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
|
+
}
|
|
211
|
+
if (mode === "auto" && automationThings !== "granted") {
|
|
212
|
+
bridge.close();
|
|
213
|
+
// Absent fields = helpers predating the TCC handshake. Not provably
|
|
214
|
+
// onboarded is not onboarded: fail closed rather than guess.
|
|
215
|
+
const reason = automationThings === undefined
|
|
216
|
+
? `onboarding not provable (helpers v${helloResult.deputyVersion} predate the permission handshake)`
|
|
217
|
+
: `onboarding incomplete (automation → Things: ${automationThings})`;
|
|
218
|
+
notice(true, automationThings === undefined
|
|
219
|
+
? `the installed helpers (v${helloResult.deputyVersion}) cannot report their macOS permission standing, so app automation runs DIRECT — rebuild with \`bash scripts/build-helpers.sh\`, then \`things helpers setup\`.`
|
|
220
|
+
: `the helpers have no app-control permission for Things (${automationThings}), so app automation runs DIRECT — \`things helpers setup\` settles it in one sitting.`);
|
|
221
|
+
return { active: false, reason, hello: null };
|
|
222
|
+
}
|
|
165
223
|
return {
|
|
166
224
|
active: true,
|
|
167
225
|
reason: null,
|
|
@@ -176,30 +234,88 @@ export function deputyRouting(env = process.env) {
|
|
|
176
234
|
state ??= activate(env);
|
|
177
235
|
return state;
|
|
178
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
|
+
}
|
|
179
278
|
function activeState(env) {
|
|
180
279
|
const routing = deputyRouting(env);
|
|
181
280
|
return routing.active ? state : null;
|
|
182
281
|
}
|
|
183
282
|
function readerInactive(reason) {
|
|
184
|
-
return {
|
|
283
|
+
return {
|
|
284
|
+
active: false,
|
|
285
|
+
granted: false,
|
|
286
|
+
hello: null,
|
|
287
|
+
token: "",
|
|
288
|
+
bridge: null,
|
|
289
|
+
reason,
|
|
290
|
+
};
|
|
185
291
|
}
|
|
186
292
|
function activateReader(env) {
|
|
187
293
|
const mode = loadConfig(env).helpersMode;
|
|
188
294
|
if (mode === "false")
|
|
189
295
|
return readerInactive("disabled");
|
|
296
|
+
// The rendezvous is `<state>/reader` — our own directory, outside every App
|
|
297
|
+
// Sandbox container — so these are ordinary file touches from any host app.
|
|
298
|
+
// No guard, no consent class, nothing to prove before looking.
|
|
190
299
|
const socketPath = readerSocketPath(env);
|
|
191
300
|
const tokenPath = readerTokenPath(env);
|
|
192
301
|
const installed = halfInstalled(readerInstalledAppPath(env), socketPath, tokenPath);
|
|
193
|
-
if (!
|
|
302
|
+
if (!rendezvousExists(socketPath) || !rendezvousExists(tokenPath)) {
|
|
303
|
+
// launchd creates the socket when the reader's LaunchAgent is loaded, and
|
|
304
|
+
// install mints the token beside it — so an absent rendezvous means the
|
|
305
|
+
// pair was never installed here, or its LaunchAgent is not loaded.
|
|
194
306
|
// Absence is silent under `auto`; under `true` the caller asserted routing.
|
|
195
307
|
// An UNGRANTED reader is deliberately NOT noticed here — that is the
|
|
196
308
|
// ceremony's own state, reported by `things helpers status` and doctor.
|
|
197
309
|
notice(mode === "true" || installed, installed
|
|
198
|
-
? `the reader is installed but not
|
|
199
|
-
: "the reader is not installed on this machine — database reads run DIRECT. `things helpers
|
|
200
|
-
return readerInactive(installed ? `reader not
|
|
310
|
+
? `the reader is installed but not registered with launchd (no rendezvous at ${socketPath}) — database reads run DIRECT. \`things helpers setup\` to re-register it.`
|
|
311
|
+
: "the reader is not installed on this machine — database reads run DIRECT. `things helpers setup` to change that.");
|
|
312
|
+
return readerInactive(installed ? `reader not registered with launchd (no ${socketPath})` : "reader not installed");
|
|
313
|
+
}
|
|
314
|
+
const token = readRendezvousToken(tokenPath);
|
|
315
|
+
if (token === null) {
|
|
316
|
+
notice(true, `the reader's access token could not be read (${tokenPath}) — database reads run DIRECT. \`things helpers setup\` to mint a fresh one.`);
|
|
317
|
+
return readerInactive(`the reader's access token could not be read (${tokenPath})`);
|
|
201
318
|
}
|
|
202
|
-
const token = readFileSync(tokenPath, "utf8").trim();
|
|
203
319
|
const bridge = new DeputySyncBridge(socketPath);
|
|
204
320
|
try {
|
|
205
321
|
const res = bridge.request({ v: DEPUTY_PROTOCOL_VERSION, token, verb: "hello" }, 2000);
|
|
@@ -208,7 +324,7 @@ function activateReader(env) {
|
|
|
208
324
|
const readerHello = res;
|
|
209
325
|
if (readerHello.protocol !== DEPUTY_PROTOCOL_VERSION) {
|
|
210
326
|
bridge.close();
|
|
211
|
-
notice(true, `the reader speaks protocol ${readerHello.protocol}, this package speaks ${DEPUTY_PROTOCOL_VERSION} — database reads run DIRECT. Rebuild with \`bash scripts/build-helpers.sh\` + \`things helpers
|
|
327
|
+
notice(true, `the reader speaks protocol ${readerHello.protocol}, this package speaks ${DEPUTY_PROTOCOL_VERSION} — database reads run DIRECT. Rebuild with \`bash scripts/build-helpers.sh\` + \`things helpers setup\`.`);
|
|
212
328
|
return readerInactive(`protocol skew (reader ${readerHello.protocol})`);
|
|
213
329
|
}
|
|
214
330
|
return {
|
|
@@ -261,7 +377,7 @@ export function helpersRouting(env = process.env) {
|
|
|
261
377
|
readerReason: files
|
|
262
378
|
? null
|
|
263
379
|
: reader.active && !reader.granted
|
|
264
|
-
? "reader running but NOT granted (things helpers
|
|
380
|
+
? "reader running but NOT granted (things helpers setup)"
|
|
265
381
|
: reader.reason,
|
|
266
382
|
};
|
|
267
383
|
}
|
|
@@ -269,6 +385,40 @@ export function helpersRouting(env = process.env) {
|
|
|
269
385
|
export function deputyFilesActive(env = process.env) {
|
|
270
386
|
return fileTransport(env) !== null;
|
|
271
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* Does this machine EXPECT the helpers to carry its reads?
|
|
390
|
+
*
|
|
391
|
+
* `true` is an explicit instruction, and under `auto` an installed bundle is
|
|
392
|
+
* the intent signal (src/deputy/agent-daemon.md §3c). The permissions doctrine
|
|
393
|
+
* hangs its no-fallback rule on this: when the helpers are expected but cannot
|
|
394
|
+
* serve, a read refuses loudly instead of quietly re-attaching consent to the
|
|
395
|
+
* terminal — the exact churn the helpers exist to end. A machine with nothing
|
|
396
|
+
* installed under `auto` is an ordinary direct machine and is NOT expecting
|
|
397
|
+
* them, so it falls through to the direct grants as it always has.
|
|
398
|
+
*/
|
|
399
|
+
export function helpersExpected(env = process.env) {
|
|
400
|
+
const mode = loadConfig(env).helpersMode;
|
|
401
|
+
if (mode === "false")
|
|
402
|
+
return false;
|
|
403
|
+
if (mode === "true")
|
|
404
|
+
return true;
|
|
405
|
+
// Both halves of the question live in our own state directory now — the
|
|
406
|
+
// installed bundle and the rendezvous alike — so this is always answerable
|
|
407
|
+
// from any host, with no probe that could prompt.
|
|
408
|
+
if (existsSync(readerInstalledAppPath(env)))
|
|
409
|
+
return true;
|
|
410
|
+
return rendezvousExists(readerSocketPath(env)) && rendezvousExists(readerTokenPath(env));
|
|
411
|
+
}
|
|
412
|
+
/** Why the reader is not carrying reads (null when it is). */
|
|
413
|
+
export function readerUnavailableReason(env = process.env) {
|
|
414
|
+
if (deputyFilesActive(env))
|
|
415
|
+
return null;
|
|
416
|
+
const reader = readerRouting(env);
|
|
417
|
+
if (reader.active && !reader.granted) {
|
|
418
|
+
return "the reader is running but holds no read grant for the Things data folder";
|
|
419
|
+
}
|
|
420
|
+
return reader.reason;
|
|
421
|
+
}
|
|
272
422
|
/** Blocking FILE-verb round-trip via the granted reader. */
|
|
273
423
|
export function fileSyncRequest(fields, timeoutMs, env = process.env) {
|
|
274
424
|
const transport = fileTransport(env);
|
|
@@ -303,6 +453,13 @@ export async function deputyAsyncRequest(fields, timeoutMs, env = process.env) {
|
|
|
303
453
|
* is active (the caller then locates locally, exactly as before the helpers
|
|
304
454
|
* existed). The reader's scope is grant-checked, never prompted — a locate
|
|
305
455
|
* through it can refuse but can never stall on a consent dialog.
|
|
456
|
+
*
|
|
457
|
+
* A reader that IS serving and then fails to locate THROWS rather than
|
|
458
|
+
* returning null. Falling back to a direct locate there would silently move
|
|
459
|
+
* the read — and its consent — back onto the host app, which the permissions
|
|
460
|
+
* doctrine forbids (Article I; no-fallback rule). The reader's typed
|
|
461
|
+
* `not-granted` / `not-found` codes travel out on the error so the CLI can
|
|
462
|
+
* name the remedy.
|
|
306
463
|
*/
|
|
307
464
|
export function deputyDbPath(env = process.env) {
|
|
308
465
|
const reader = readerRouting(env);
|
|
@@ -311,18 +468,15 @@ export function deputyDbPath(env = process.env) {
|
|
|
311
468
|
if (reader.hello?.dbPath != null)
|
|
312
469
|
return reader.hello.dbPath;
|
|
313
470
|
const rs = readerState;
|
|
314
|
-
if (rs.dbPathMemo !== undefined)
|
|
471
|
+
if (rs.dbPathMemo !== undefined && rs.dbPathMemo !== null)
|
|
315
472
|
return rs.dbPathMemo;
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
catch (err) {
|
|
321
|
-
rs.dbPathMemo = null;
|
|
322
|
-
const why = err instanceof Error ? err.message : String(err);
|
|
323
|
-
emitHelpersNotice(`the reader could not resolve the database (${why}) — this read runs DIRECT`);
|
|
473
|
+
const res = fileSyncRequest({ verb: "locate" }, 10_000, env);
|
|
474
|
+
const path = typeof res["path"] === "string" ? res["path"] : null;
|
|
475
|
+
if (path === null) {
|
|
476
|
+
throw new DeputyRequestError("not-found", "the reader answered the locate but named no database");
|
|
324
477
|
}
|
|
325
|
-
|
|
478
|
+
rs.dbPathMemo = path;
|
|
479
|
+
return path;
|
|
326
480
|
}
|
|
327
481
|
/**
|
|
328
482
|
* Should DATABASE access route through the deputy? Only for the default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing.js","sourceRoot":"","sources":["../../src/deputy/routing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEnD,OAAO,EAAoB,UAAU,EAAE,MAAM,cAAc,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EAEvB,kBAAkB,EAClB,yBAAyB,EACzB,gBAAgB,EAChB,eAAe,EACf,wBAAwB,EAExB,sBAAsB,EACtB,gBAAgB,EAChB,eAAe,GAChB,MAAM,eAAe,CAAC;AA8CvB,IAAI,KAAK,GAAwB,IAAI,CAAC;AACtC,IAAI,WAAW,GAAuB,IAAI,CAAC;AAE3C,gFAAgF;AAChF,MAAM,UAAU,0BAA0B;IACxC,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,EAAE,CAAC;QAC3B,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,KAAK,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IACD,WAAW,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAC7B,KAAK,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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 wakeTarget(THINGS_TARGET, env, deps);
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=wake.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wake.js","sourceRoot":"","sources":["../../src/deputy/wake.ts"],"names":[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