appduct 0.10.0 → 0.11.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 +122 -52
- package/dist/artifact-inspect.d.ts +0 -1
- package/dist/bin.d.ts +0 -1
- package/dist/bin.js +1250 -2
- package/dist/cli/command-options.d.ts +8 -1
- package/dist/cli/create-cli.d.ts +0 -1
- package/dist/cli/dispatch.d.ts +10 -1
- package/dist/cli/envelope.d.ts +19 -0
- package/dist/cli/global-flags.d.ts +30 -0
- package/dist/cli/open-target.d.ts +25 -8
- package/dist/cli/result-types.d.ts +31 -5
- package/dist/cli/router.d.ts +78 -0
- package/dist/cli/routes/daemon/index.d.ts +9 -0
- package/dist/cli/routes/daemon/index.js +848 -0
- package/dist/cli/routes/daemon/run.d.ts +3 -0
- package/dist/cli/routes/daemon/run.js +3246 -0
- package/dist/cli/routes/daemon/start.d.ts +3 -0
- package/dist/cli/routes/daemon/start.js +1677 -0
- package/dist/cli/routes/daemon/status.d.ts +4 -0
- package/dist/cli/routes/daemon/status.js +1685 -0
- package/dist/cli/routes/daemon/stop.d.ts +4 -0
- package/dist/cli/routes/daemon/stop.js +1655 -0
- package/dist/cli/routes/doctor.d.ts +3 -0
- package/dist/cli/routes/doctor.js +1075 -0
- package/dist/cli/routes/events.d.ts +3 -0
- package/dist/cli/routes/events.js +1915 -0
- package/dist/cli/routes/init.d.ts +3 -0
- package/dist/cli/routes/init.js +1486 -0
- package/dist/cli/routes/invoke.d.ts +3 -0
- package/dist/cli/routes/invoke.js +1893 -0
- package/dist/cli/routes/keygen.d.ts +3 -0
- package/dist/cli/routes/keygen.js +928 -0
- package/dist/cli/routes/link.d.ts +3 -0
- package/dist/cli/routes/link.js +2714 -0
- package/dist/cli/routes/ls.d.ts +3 -0
- package/dist/cli/routes/ls.js +1668 -0
- package/dist/cli/routes/mcp.d.ts +5 -0
- package/dist/cli/routes/mcp.js +3929 -0
- package/dist/cli/routes/revoke.d.ts +3 -0
- package/dist/cli/routes/revoke.js +1684 -0
- package/dist/cli/routes/tools.d.ts +3 -0
- package/dist/cli/routes/tools.js +1860 -0
- package/dist/cli/runner.d.ts +3 -11
- package/dist/cli/types.d.ts +9 -6
- package/dist/cli/version-guard.d.ts +20 -0
- package/dist/cli.d.ts +0 -1
- package/dist/client/app-client.d.ts +4 -4
- package/dist/client/bootstrap.d.ts +4 -4
- package/dist/client/connect.d.ts +0 -1
- package/dist/client/errors.d.ts +0 -1
- package/dist/client/index.d.ts +1 -2
- package/dist/client/index.js +2389 -16
- package/dist/commands/daemon/context.d.ts +14 -0
- package/dist/commands/daemon/run.d.ts +11 -0
- package/dist/commands/daemon/start.d.ts +5 -0
- package/dist/commands/daemon/status.d.ts +5 -0
- package/dist/commands/daemon/stop.d.ts +5 -0
- package/dist/commands/doctor.d.ts +0 -1
- package/dist/commands/events.d.ts +0 -1
- package/dist/commands/init.d.ts +17 -4
- package/dist/commands/invoke.d.ts +0 -1
- package/dist/commands/keygen.d.ts +0 -1
- package/dist/commands/link.d.ts +1 -2
- package/dist/commands/ls.d.ts +0 -1
- package/dist/commands/mcp.d.ts +2 -4
- package/dist/commands/revoke.d.ts +0 -1
- package/dist/commands/tools.d.ts +19 -3
- package/dist/daemon/address.d.ts +0 -1
- package/dist/daemon/audit.d.ts +6 -11
- package/dist/daemon/calls.d.ts +0 -1
- package/dist/daemon/config.d.ts +13 -16
- package/dist/daemon/daemon.d.ts +0 -1
- package/dist/daemon/event-bus.d.ts +0 -1
- package/dist/daemon/links.d.ts +0 -1
- package/dist/daemon/listener.d.ts +0 -1
- package/dist/daemon/log-rotation.d.ts +0 -1
- package/dist/daemon/pidfile.d.ts +14 -8
- package/dist/daemon/policy.d.ts +0 -1
- package/dist/daemon/registry.d.ts +0 -1
- package/dist/daemon/rpc-errors.d.ts +16 -0
- package/dist/daemon/rpc-server.d.ts +0 -11
- package/dist/daemon/sessions.d.ts +0 -1
- package/dist/daemon/socket-probe.d.ts +0 -1
- package/dist/daemon/state-dir.d.ts +0 -1
- package/dist/daemon/timers.d.ts +0 -1
- package/dist/daemon/tls.d.ts +0 -1
- package/dist/errors.d.ts +0 -1
- package/dist/host-certificate.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1307 -3
- package/dist/key-material.d.ts +0 -1
- package/dist/link.d.ts +8 -7
- package/dist/mcp/app-tools.d.ts +153 -0
- package/dist/mcp/connect-tool.d.ts +14 -8
- package/dist/mcp/daemon-tools.d.ts +2 -11
- package/dist/mcp/events-tool.d.ts +0 -1
- package/dist/mcp/server.d.ts +33 -14
- package/dist/native-scheme.d.ts +0 -1
- package/dist/output.d.ts +8 -11
- package/dist/package-root.d.ts +11 -0
- package/dist/package-version.d.ts +0 -1
- package/dist/qr-terminal.d.ts +0 -1
- package/dist/rpc/client.d.ts +3 -3
- package/dist/scheme.d.ts +60 -2
- package/dist/spki-pin.d.ts +0 -1
- package/package.json +6 -3
- package/dist/artifact-inspect.d.ts.map +0 -1
- package/dist/artifact-inspect.js +0 -334
- package/dist/bin.d.ts.map +0 -1
- package/dist/cli/command-options.d.ts.map +0 -1
- package/dist/cli/command-options.js +0 -95
- package/dist/cli/create-cli.d.ts.map +0 -1
- package/dist/cli/create-cli.js +0 -56
- package/dist/cli/dispatch.d.ts.map +0 -1
- package/dist/cli/dispatch.js +0 -275
- package/dist/cli/open-target.d.ts.map +0 -1
- package/dist/cli/open-target.js +0 -438
- package/dist/cli/result-types.d.ts.map +0 -1
- package/dist/cli/result-types.js +0 -6
- package/dist/cli/runner.d.ts.map +0 -1
- package/dist/cli/runner.js +0 -111
- package/dist/cli/types.d.ts.map +0 -1
- package/dist/cli/types.js +0 -10
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -2
- package/dist/client/app-client.d.ts.map +0 -1
- package/dist/client/app-client.js +0 -223
- package/dist/client/bootstrap.d.ts.map +0 -1
- package/dist/client/bootstrap.js +0 -108
- package/dist/client/connect.d.ts.map +0 -1
- package/dist/client/connect.js +0 -38
- package/dist/client/errors.d.ts.map +0 -1
- package/dist/client/errors.js +0 -40
- package/dist/client/index.d.ts.map +0 -1
- package/dist/commands/daemon.d.ts +0 -22
- package/dist/commands/daemon.d.ts.map +0 -1
- package/dist/commands/daemon.js +0 -128
- package/dist/commands/doctor.d.ts.map +0 -1
- package/dist/commands/doctor.js +0 -42
- package/dist/commands/events.d.ts.map +0 -1
- package/dist/commands/events.js +0 -76
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -231
- package/dist/commands/invoke.d.ts.map +0 -1
- package/dist/commands/invoke.js +0 -54
- package/dist/commands/keygen.d.ts.map +0 -1
- package/dist/commands/keygen.js +0 -46
- package/dist/commands/link.d.ts.map +0 -1
- package/dist/commands/link.js +0 -43
- package/dist/commands/ls.d.ts.map +0 -1
- package/dist/commands/ls.js +0 -7
- package/dist/commands/mcp.d.ts.map +0 -1
- package/dist/commands/mcp.js +0 -98
- package/dist/commands/revoke.d.ts.map +0 -1
- package/dist/commands/revoke.js +0 -7
- package/dist/commands/tools.d.ts.map +0 -1
- package/dist/commands/tools.js +0 -52
- package/dist/daemon/address.d.ts.map +0 -1
- package/dist/daemon/address.js +0 -71
- package/dist/daemon/audit.d.ts.map +0 -1
- package/dist/daemon/audit.js +0 -237
- package/dist/daemon/calls.d.ts.map +0 -1
- package/dist/daemon/calls.js +0 -158
- package/dist/daemon/config.d.ts.map +0 -1
- package/dist/daemon/config.js +0 -170
- package/dist/daemon/daemon.d.ts.map +0 -1
- package/dist/daemon/daemon.js +0 -560
- package/dist/daemon/event-bus.d.ts.map +0 -1
- package/dist/daemon/event-bus.js +0 -111
- package/dist/daemon/links.d.ts.map +0 -1
- package/dist/daemon/links.js +0 -118
- package/dist/daemon/listener.d.ts.map +0 -1
- package/dist/daemon/listener.js +0 -132
- package/dist/daemon/log-rotation.d.ts.map +0 -1
- package/dist/daemon/log-rotation.js +0 -136
- package/dist/daemon/pidfile.d.ts.map +0 -1
- package/dist/daemon/pidfile.js +0 -90
- package/dist/daemon/policy.d.ts.map +0 -1
- package/dist/daemon/policy.js +0 -24
- package/dist/daemon/registry.d.ts.map +0 -1
- package/dist/daemon/registry.js +0 -31
- package/dist/daemon/rpc-server.d.ts.map +0 -1
- package/dist/daemon/rpc-server.js +0 -203
- package/dist/daemon/sessions.d.ts.map +0 -1
- package/dist/daemon/sessions.js +0 -429
- package/dist/daemon/socket-probe.d.ts.map +0 -1
- package/dist/daemon/socket-probe.js +0 -28
- package/dist/daemon/state-dir.d.ts.map +0 -1
- package/dist/daemon/state-dir.js +0 -43
- package/dist/daemon/timers.d.ts.map +0 -1
- package/dist/daemon/timers.js +0 -12
- package/dist/daemon/tls.d.ts.map +0 -1
- package/dist/daemon/tls.js +0 -79
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -162
- package/dist/host-certificate.d.ts.map +0 -1
- package/dist/host-certificate.js +0 -111
- package/dist/index.d.ts.map +0 -1
- package/dist/key-material.d.ts.map +0 -1
- package/dist/key-material.js +0 -42
- package/dist/link.d.ts.map +0 -1
- package/dist/link.js +0 -117
- package/dist/mcp/connect-tool.d.ts.map +0 -1
- package/dist/mcp/connect-tool.js +0 -396
- package/dist/mcp/daemon-tools.d.ts.map +0 -1
- package/dist/mcp/daemon-tools.js +0 -29
- package/dist/mcp/events-tool.d.ts.map +0 -1
- package/dist/mcp/events-tool.js +0 -322
- package/dist/mcp/server.d.ts.map +0 -1
- package/dist/mcp/server.js +0 -538
- package/dist/mcp/tool-mapping.d.ts +0 -58
- package/dist/mcp/tool-mapping.d.ts.map +0 -1
- package/dist/mcp/tool-mapping.js +0 -143
- package/dist/mcp/tool-namespace.d.ts +0 -40
- package/dist/mcp/tool-namespace.d.ts.map +0 -1
- package/dist/mcp/tool-namespace.js +0 -65
- package/dist/native-scheme.d.ts.map +0 -1
- package/dist/native-scheme.js +0 -465
- package/dist/output.d.ts.map +0 -1
- package/dist/output.js +0 -342
- package/dist/package-version.d.ts.map +0 -1
- package/dist/package-version.js +0 -47
- package/dist/qr-terminal.d.ts.map +0 -1
- package/dist/qr-terminal.js +0 -45
- package/dist/rpc/client.d.ts.map +0 -1
- package/dist/rpc/client.js +0 -819
- package/dist/scheme.d.ts.map +0 -1
- package/dist/scheme.js +0 -321
- package/dist/spki-pin.d.ts.map +0 -1
- package/dist/spki-pin.js +0 -14
package/dist/cli/dispatch.js
DELETED
|
@@ -1,275 +0,0 @@
|
|
|
1
|
-
import { handleDaemonRunCommand, handleDaemonStartCommand, handleDaemonStatusCommand, handleDaemonStopCommand, } from "../commands/daemon.js";
|
|
2
|
-
import { handleDoctorCommand } from "../commands/doctor.js";
|
|
3
|
-
import { handleEventsCommand } from "../commands/events.js";
|
|
4
|
-
import { handleInitCommand } from "../commands/init.js";
|
|
5
|
-
import { handleInvokeCommand } from "../commands/invoke.js";
|
|
6
|
-
import { handleKeygenCommand } from "../commands/keygen.js";
|
|
7
|
-
import { handleLinkCommand } from "../commands/link.js";
|
|
8
|
-
import { handleLsCommand } from "../commands/ls.js";
|
|
9
|
-
import { handleMcpCommand } from "../commands/mcp.js";
|
|
10
|
-
import { handleRevokeCommand } from "../commands/revoke.js";
|
|
11
|
-
import { handleToolsCommand } from "../commands/tools.js";
|
|
12
|
-
import { loadConfig } from "../daemon/config.js";
|
|
13
|
-
import { getStateDirPaths, resolveStateDir } from "../daemon/state-dir.js";
|
|
14
|
-
import { usageError } from "../errors.js";
|
|
15
|
-
import { renderEventLine, renderEventsCursorLine } from "../output.js";
|
|
16
|
-
import { getPackageVersion } from "../package-version.js";
|
|
17
|
-
import { ensureDaemonVersionMatches } from "../rpc/client.js";
|
|
18
|
-
import { parseJsonInputOption, parseNonNegativeIntegerOption, parsePositiveIntegerOption, splitOptionalSelector, splitOptionalSelectorAndTarget, splitSelectorAndRequiredTarget, } from "./command-options.js";
|
|
19
|
-
import { createCli } from "./create-cli.js";
|
|
20
|
-
import { executeCommand, executeHostedCommand } from "./runner.js";
|
|
21
|
-
import { systemClock } from "./types.js";
|
|
22
|
-
/** `APPDUCT_DAEMON_RESTART=1` forces a version-mismatch restart for one run — the env-var form
|
|
23
|
-
* of `--daemon-restart`, so an MCP launch config (which passes no CLI flags) can opt in. */
|
|
24
|
-
const DAEMON_RESTART_ENV = "APPDUCT_DAEMON_RESTART";
|
|
25
|
-
const isEnvTruthy = (value) => {
|
|
26
|
-
return value === "1" || value?.toLowerCase() === "true";
|
|
27
|
-
};
|
|
28
|
-
export const runCli = async (argv, options = {}) => {
|
|
29
|
-
const writers = {
|
|
30
|
-
stdout: options.stdout ?? process.stdout,
|
|
31
|
-
stderr: options.stderr ?? process.stderr,
|
|
32
|
-
};
|
|
33
|
-
const clock = options.clock ?? systemClock;
|
|
34
|
-
const cli = createCli();
|
|
35
|
-
try {
|
|
36
|
-
cli.parse(["node", "appduct", ...argv], {
|
|
37
|
-
run: false,
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
return executeCommand("cli", () => {
|
|
42
|
-
throw error;
|
|
43
|
-
}, {
|
|
44
|
-
json: argv.includes("--json"),
|
|
45
|
-
color: !argv.includes("--no-color"),
|
|
46
|
-
stdout: writers.stdout,
|
|
47
|
-
stderr: writers.stderr,
|
|
48
|
-
clock,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
const matchedCommand = cli.matchedCommandName;
|
|
52
|
-
const parsedOptions = cli.options;
|
|
53
|
-
const parsedArgs = cli.args;
|
|
54
|
-
if (parsedOptions.help || parsedOptions.version) {
|
|
55
|
-
return 0;
|
|
56
|
-
}
|
|
57
|
-
if (!matchedCommand) {
|
|
58
|
-
if (parsedArgs[0]) {
|
|
59
|
-
return executeCommand("cli", () => {
|
|
60
|
-
throw usageError(`Unknown command "${parsedArgs[0]}".`);
|
|
61
|
-
}, {
|
|
62
|
-
json: Boolean(parsedOptions.json),
|
|
63
|
-
color: parsedOptions.color !== false,
|
|
64
|
-
stdout: writers.stdout,
|
|
65
|
-
stderr: writers.stderr,
|
|
66
|
-
clock,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
cli.outputHelp();
|
|
70
|
-
return 0;
|
|
71
|
-
}
|
|
72
|
-
const json = Boolean(parsedOptions.json);
|
|
73
|
-
const color = parsedOptions.color !== false;
|
|
74
|
-
const io = { json, color, stdout: writers.stdout, stderr: writers.stderr, clock };
|
|
75
|
-
const stateDir = resolveStateDir(typeof parsedOptions.stateDir === "string" ? parsedOptions.stateDir : undefined);
|
|
76
|
-
// --- daemon/CLI version drift (issue #30, ARCHITECTURE.md §4 "Version drift") ------------------
|
|
77
|
-
let forceRestart;
|
|
78
|
-
/** Memoized so the config read behind `restartDaemonOnVersionMismatch` happens at most once. */
|
|
79
|
-
const resolveForceRestart = () => {
|
|
80
|
-
forceRestart ??= (async () => {
|
|
81
|
-
let configuredForce = false;
|
|
82
|
-
try {
|
|
83
|
-
configuredForce = (await loadConfig(getStateDirPaths(stateDir))).restartDaemonOnVersionMismatch;
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
// An unreadable/invalid `config.json` must not turn every command into a config error just
|
|
87
|
-
// because one optional knob lives there; the daemon reports the real problem when it starts.
|
|
88
|
-
}
|
|
89
|
-
// An explicit flag wins outright, in both directions: `--no-daemon-restart` is how an
|
|
90
|
-
// operator overrules a `restartDaemonOnVersionMismatch: true` in their config (or a
|
|
91
|
-
// `APPDUCT_DAEMON_RESTART` exported by a wrapper script) for one command, and silently
|
|
92
|
-
// ignoring it would be the worst kind of surprise for a knob that decides whether their
|
|
93
|
-
// connected devices survive.
|
|
94
|
-
const flag = typeof parsedOptions.daemonRestart === "boolean" ? parsedOptions.daemonRestart : undefined;
|
|
95
|
-
return flag ?? (isEnvTruthy(process.env[DAEMON_RESTART_ENV]) || configuredForce);
|
|
96
|
-
})();
|
|
97
|
-
return forceRestart;
|
|
98
|
-
};
|
|
99
|
-
/**
|
|
100
|
-
* Where the "the running daemon is newer than this client" notice goes. `--json` promises one
|
|
101
|
-
* machine-readable object and nothing else, so in that mode the notice is dropped rather than
|
|
102
|
-
* dribbled onto stderr where it would corrupt a script that captures both streams — the check
|
|
103
|
-
* still behaves identically, it just says nothing. (A structured warning channel would be the
|
|
104
|
-
* better answer; the runner has none today.)
|
|
105
|
-
*/
|
|
106
|
-
const cliWarning = json ? () => { } : (message) => void writers.stderr.write(message);
|
|
107
|
-
const versionCheckFor = async (onWarning) => {
|
|
108
|
-
return {
|
|
109
|
-
clientVersion: getPackageVersion(),
|
|
110
|
-
forceRestart: await resolveForceRestart(),
|
|
111
|
-
onWarning,
|
|
112
|
-
};
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* Wraps a command handler so the daemon's version is verified once, before the command's first
|
|
116
|
-
* RPC. `autoSpawn: false`: with nothing listening there is no drift to find, and any daemon this
|
|
117
|
-
* process spawns afterwards is its own build. Applied to every command that talks to the daemon
|
|
118
|
-
* except `daemon run` (it *is* the daemon), `daemon status` (warns instead — see
|
|
119
|
-
* `commands/daemon.ts`) and `daemon stop` (already the remedy); `keygen`/`doctor` never open a
|
|
120
|
-
* daemon connection at all.
|
|
121
|
-
*/
|
|
122
|
-
const guarded = (handler) => {
|
|
123
|
-
return async () => {
|
|
124
|
-
await ensureDaemonVersionMatches({
|
|
125
|
-
stateDir,
|
|
126
|
-
autoSpawn: false,
|
|
127
|
-
checkVersion: await versionCheckFor(cliWarning),
|
|
128
|
-
});
|
|
129
|
-
return handler();
|
|
130
|
-
};
|
|
131
|
-
};
|
|
132
|
-
switch (matchedCommand) {
|
|
133
|
-
case "init":
|
|
134
|
-
return executeCommand("init", () => handleInitCommand({
|
|
135
|
-
scheme: typeof parsedOptions.scheme === "string" ? parsedOptions.scheme : undefined,
|
|
136
|
-
force: Boolean(parsedOptions.force),
|
|
137
|
-
},
|
|
138
|
-
// `init` never reads the state dir, but it must know which directory it is so it can
|
|
139
|
-
// refuse to write a "safe to commit" project config into the daemon's own state.
|
|
140
|
-
{ stateDir }), io);
|
|
141
|
-
case "keygen":
|
|
142
|
-
return executeCommand("keygen", () => handleKeygenCommand({
|
|
143
|
-
out: typeof parsedOptions.out === "string" ? parsedOptions.out : undefined,
|
|
144
|
-
force: Boolean(parsedOptions.force),
|
|
145
|
-
}, { stateDir }), io);
|
|
146
|
-
case "link": {
|
|
147
|
-
return executeCommand("link", guarded(() => handleLinkCommand({
|
|
148
|
-
ttlSeconds: parsePositiveIntegerOption(parsedOptions.ttl, "--ttl"),
|
|
149
|
-
scheme: typeof parsedOptions.scheme === "string" ? parsedOptions.scheme : undefined,
|
|
150
|
-
open: typeof parsedOptions.open === "string" ? parsedOptions.open : undefined,
|
|
151
|
-
device: typeof parsedOptions.device === "string" ? parsedOptions.device : undefined,
|
|
152
|
-
// cac camelCases `--bundle-id`; the dashed spelling is kept as a fallback so a
|
|
153
|
-
// parser change can't silently drop the flag.
|
|
154
|
-
bundleId: typeof parsedOptions.bundleId === "string"
|
|
155
|
-
? parsedOptions.bundleId
|
|
156
|
-
: typeof parsedOptions["bundle-id"] === "string"
|
|
157
|
-
? parsedOptions["bundle-id"]
|
|
158
|
-
: undefined,
|
|
159
|
-
// Left `undefined` when absent rather than coerced to `false`, so that
|
|
160
|
-
// "--relaunch only applies with --open ios-device" fires on the flag actually being
|
|
161
|
-
// passed and not on every `link` invocation.
|
|
162
|
-
relaunch: parsedOptions.relaunch === true ? true : undefined,
|
|
163
|
-
}, { stateDir })), {
|
|
164
|
-
...io,
|
|
165
|
-
qr: Boolean(parsedOptions.qr),
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
case "ls":
|
|
169
|
-
return executeCommand("ls", guarded(() => handleLsCommand({ stateDir })), io);
|
|
170
|
-
case "tools": {
|
|
171
|
-
const { selector, target, selectorOrTarget } = splitOptionalSelectorAndTarget(parsedArgs, "tools [selector] [name]");
|
|
172
|
-
return executeCommand("tools", guarded(() => handleToolsCommand({ selector: selector ?? selectorOrTarget, name: target }, { stateDir })), { ...io, full: Boolean(parsedOptions.full) });
|
|
173
|
-
}
|
|
174
|
-
case "invoke": {
|
|
175
|
-
const { selector, target: tool } = splitSelectorAndRequiredTarget(parsedArgs, "invoke [selector] <tool> --input '<json>'");
|
|
176
|
-
// SIGINT cancels the in-flight tools.call rather than leaving it running unowned in the app
|
|
177
|
-
// (issue #9) — the listener is torn down once the command settles either way.
|
|
178
|
-
const cancelController = new AbortController();
|
|
179
|
-
const onSigint = () => cancelController.abort();
|
|
180
|
-
process.once("SIGINT", onSigint);
|
|
181
|
-
try {
|
|
182
|
-
return await executeCommand("invoke", guarded(() => handleInvokeCommand({
|
|
183
|
-
selector,
|
|
184
|
-
tool,
|
|
185
|
-
args: parseJsonInputOption(typeof parsedOptions.input === "string" ? parsedOptions.input : undefined),
|
|
186
|
-
timeoutMs: parsePositiveIntegerOption(parsedOptions.timeout, "--timeout"),
|
|
187
|
-
}, { stateDir }, cancelController.signal)), io);
|
|
188
|
-
}
|
|
189
|
-
finally {
|
|
190
|
-
process.off("SIGINT", onSigint);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
case "revoke": {
|
|
194
|
-
const { selector } = splitOptionalSelector(parsedArgs, "revoke [selector]");
|
|
195
|
-
return executeCommand("revoke", guarded(() => handleRevokeCommand({ selector }, { stateDir })), io);
|
|
196
|
-
}
|
|
197
|
-
case "events": {
|
|
198
|
-
const { selector } = splitOptionalSelector(parsedArgs, "events [selector]");
|
|
199
|
-
const since = parseNonNegativeIntegerOption(parsedOptions.since, "--since");
|
|
200
|
-
const follow = Boolean(parsedOptions.follow);
|
|
201
|
-
return executeHostedCommand("events", guarded(() => {
|
|
202
|
-
// Deferred into the wrapped handler (rather than thrown directly in this case body,
|
|
203
|
-
// matching the codebase's existing lax convention for that) so `executeHostedCommand`'s
|
|
204
|
-
// own try/catch renders it as a normal usage_error instead of an uncaught rejection.
|
|
205
|
-
if (since !== undefined && follow) {
|
|
206
|
-
throw usageError('"--since" is a one-shot pull and cannot be combined with "--follow".');
|
|
207
|
-
}
|
|
208
|
-
return handleEventsCommand({ selector, since }, {
|
|
209
|
-
stateDir,
|
|
210
|
-
onEvent: (event) => {
|
|
211
|
-
writers.stdout.write(`${renderEventLine(event, { json, color })}\n`);
|
|
212
|
-
},
|
|
213
|
-
onCursor: (cursor) => {
|
|
214
|
-
writers.stdout.write(`${renderEventsCursorLine(cursor, { json, color })}\n`);
|
|
215
|
-
},
|
|
216
|
-
});
|
|
217
|
-
}), {
|
|
218
|
-
...io,
|
|
219
|
-
reporter: {
|
|
220
|
-
kind: "interactive",
|
|
221
|
-
onEvent: () => { },
|
|
222
|
-
dispose: () => { },
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
case "mcp": {
|
|
227
|
-
return executeHostedCommand("mcp",
|
|
228
|
-
// Unlike every other command the check is threaded into the server itself, not run ahead
|
|
229
|
-
// of it: the MCP server is long-lived and auto-spawns its own daemon, so the check belongs
|
|
230
|
-
// on the startup stream that establishes the connection it keeps (ARCHITECTURE.md §9).
|
|
231
|
-
// The notice always goes to stderr here, `--json` or not: stdout carries MCP protocol
|
|
232
|
-
// frames, and stderr is this server's only log channel (ARCHITECTURE.md §9).
|
|
233
|
-
async () => handleMcpCommand({
|
|
234
|
-
stateDir,
|
|
235
|
-
scheme: typeof parsedOptions.scheme === "string" ? parsedOptions.scheme : undefined,
|
|
236
|
-
checkVersion: await versionCheckFor((message) => void writers.stderr.write(message)),
|
|
237
|
-
}), {
|
|
238
|
-
...io,
|
|
239
|
-
reporter: {
|
|
240
|
-
kind: "interactive",
|
|
241
|
-
onEvent: () => { },
|
|
242
|
-
dispose: () => { },
|
|
243
|
-
},
|
|
244
|
-
});
|
|
245
|
-
}
|
|
246
|
-
case "doctor": {
|
|
247
|
-
return executeCommand("doctor", () => handleDoctorCommand({
|
|
248
|
-
artifactPath: parsedArgs[0],
|
|
249
|
-
assertPresent: Boolean(parsedOptions.assertPresent),
|
|
250
|
-
assertAbsent: Boolean(parsedOptions.assertAbsent),
|
|
251
|
-
}), io);
|
|
252
|
-
}
|
|
253
|
-
case "daemon": {
|
|
254
|
-
const action = parsedArgs[0];
|
|
255
|
-
switch (action) {
|
|
256
|
-
case "run":
|
|
257
|
-
return executeHostedCommand("daemon run", () => handleDaemonRunCommand({ stateDir, clock }), io);
|
|
258
|
-
case "start":
|
|
259
|
-
return executeCommand("daemon start", guarded(() => handleDaemonStartCommand({ stateDir, clock })), io);
|
|
260
|
-
case "stop":
|
|
261
|
-
return executeCommand("daemon stop", () => handleDaemonStopCommand({ stateDir, clock }), io);
|
|
262
|
-
case "status":
|
|
263
|
-
return executeCommand("daemon status", () => handleDaemonStatusCommand({ stateDir, clock }), io);
|
|
264
|
-
default:
|
|
265
|
-
return executeCommand("daemon", () => {
|
|
266
|
-
throw usageError(`The daemon command requires an action: run, start, stop, or status (got ${action === undefined ? "none" : `"${action}"`}).`);
|
|
267
|
-
}, io);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
default:
|
|
271
|
-
return executeCommand(matchedCommand, () => {
|
|
272
|
-
throw usageError(`Unknown command "${matchedCommand}".`);
|
|
273
|
-
}, io);
|
|
274
|
-
}
|
|
275
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"open-target.d.ts","sourceRoot":"","sources":["../../src/cli/open-target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AASH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,SAAS,GAAG,YAAY,CAAC;AAE9D,eAAO,MAAM,YAAY,GAAI,OAAO,MAAM,KAAG,KAAK,IAAI,UAErD,CAAC;AAEF;6FAC6F;AAC7F,eAAO,MAAM,YAAY,EAAE,SAAS,UAAU,EAAyC,CAAC;AAExF;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAAI,QAAQ,UAAU,KAAG,OAExD,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,SAAS,MAAM,KAAG,OAUnD,CAAC;AAEF,yEAAyE;AACzE,eAAO,MA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