@getmateo/cli 0.0.0-stage → 0.19.7
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/LICENSE +211 -0
- package/bin/mateo +3 -0
- package/dist/classify.d.ts +19 -0
- package/dist/classify.js +49 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +143 -0
- package/dist/commands/agent/archive.d.ts +27 -0
- package/dist/commands/agent/archive.js +88 -0
- package/dist/commands/agent/attach.d.ts +8 -0
- package/dist/commands/agent/attach.js +160 -0
- package/dist/commands/agent/delete.d.ts +15 -0
- package/dist/commands/agent/delete.js +104 -0
- package/dist/commands/agent/detach.d.ts +16 -0
- package/dist/commands/agent/detach.js +44 -0
- package/dist/commands/agent/import.d.ts +14 -0
- package/dist/commands/agent/import.js +108 -0
- package/dist/commands/agent/index.d.ts +3 -0
- package/dist/commands/agent/index.js +56 -0
- package/dist/commands/agent/inspect.d.ts +15 -0
- package/dist/commands/agent/inspect.js +196 -0
- package/dist/commands/agent/logs.d.ts +39 -0
- package/dist/commands/agent/logs.js +369 -0
- package/dist/commands/agent/ls.d.ts +61 -0
- package/dist/commands/agent/ls.js +201 -0
- package/dist/commands/agent/mode.d.ts +18 -0
- package/dist/commands/agent/mode.js +100 -0
- package/dist/commands/agent/open.d.ts +11 -0
- package/dist/commands/agent/open.js +74 -0
- package/dist/commands/agent/reload.d.ts +25 -0
- package/dist/commands/agent/reload.js +64 -0
- package/dist/commands/agent/run.d.ts +77 -0
- package/dist/commands/agent/run.js +556 -0
- package/dist/commands/agent/send.d.ts +21 -0
- package/dist/commands/agent/send.js +187 -0
- package/dist/commands/agent/stop.d.ts +17 -0
- package/dist/commands/agent/stop.js +102 -0
- package/dist/commands/agent/update.d.ts +51 -0
- package/dist/commands/agent/update.js +173 -0
- package/dist/commands/agent/wait.d.ts +31 -0
- package/dist/commands/agent/wait.js +161 -0
- package/dist/commands/clone.d.ts +17 -0
- package/dist/commands/clone.js +59 -0
- package/dist/commands/daemon/config.d.ts +3 -0
- package/dist/commands/daemon/config.js +103 -0
- package/dist/commands/daemon/index.d.ts +3 -0
- package/dist/commands/daemon/index.js +28 -0
- package/dist/commands/daemon/local-daemon.d.ts +13 -0
- package/dist/commands/daemon/local-daemon.js +105 -0
- package/dist/commands/daemon/pair.d.ts +30 -0
- package/dist/commands/daemon/pair.js +145 -0
- package/dist/commands/daemon/reload.d.ts +12 -0
- package/dist/commands/daemon/reload.js +44 -0
- package/dist/commands/daemon/restart.d.ts +29 -0
- package/dist/commands/daemon/restart.js +169 -0
- package/dist/commands/daemon/runtime-toolchain.d.ts +6 -0
- package/dist/commands/daemon/runtime-toolchain.js +87 -0
- package/dist/commands/daemon/set-password.d.ts +17 -0
- package/dist/commands/daemon/set-password.js +89 -0
- package/dist/commands/daemon/start.d.ts +20 -0
- package/dist/commands/daemon/start.js +52 -0
- package/dist/commands/daemon/status.d.ts +13 -0
- package/dist/commands/daemon/status.js +119 -0
- package/dist/commands/daemon/stop.d.ts +20 -0
- package/dist/commands/daemon/stop.js +58 -0
- package/dist/commands/fleet/index.d.ts +4 -0
- package/dist/commands/fleet/index.js +57 -0
- package/dist/commands/heartbeat/index.d.ts +3 -0
- package/dist/commands/heartbeat/index.js +139 -0
- package/dist/commands/hooks.d.ts +19 -0
- package/dist/commands/hooks.js +89 -0
- package/dist/commands/hub/authority.d.ts +17 -0
- package/dist/commands/hub/authority.js +18 -0
- package/dist/commands/hub/connect.d.ts +24 -0
- package/dist/commands/hub/connect.js +44 -0
- package/dist/commands/hub/credentials.d.ts +21 -0
- package/dist/commands/hub/credentials.js +143 -0
- package/dist/commands/hub/daemon-client.d.ts +41 -0
- package/dist/commands/hub/daemon-client.js +14 -0
- package/dist/commands/hub/deploy-bundle.d.ts +16 -0
- package/dist/commands/hub/deploy-bundle.js +248 -0
- package/dist/commands/hub/deploy-triggers.d.ts +6 -0
- package/dist/commands/hub/deploy-triggers.js +116 -0
- package/dist/commands/hub/deploy.d.ts +50 -0
- package/dist/commands/hub/deploy.js +159 -0
- package/dist/commands/hub/disconnect.d.ts +17 -0
- package/dist/commands/hub/disconnect.js +24 -0
- package/dist/commands/hub/error.d.ts +6 -0
- package/dist/commands/hub/error.js +9 -0
- package/dist/commands/hub/export.d.ts +28 -0
- package/dist/commands/hub/export.js +80 -0
- package/dist/commands/hub/help.d.ts +3 -0
- package/dist/commands/hub/help.js +5 -0
- package/dist/commands/hub/hub-client/index.d.ts +22 -0
- package/dist/commands/hub/hub-client/index.js +135 -0
- package/dist/commands/hub/hub-client/internal/contracts.d.ts +126 -0
- package/dist/commands/hub/hub-client/internal/contracts.js +85 -0
- package/dist/commands/hub/hub-client/internal/problem.d.ts +3 -0
- package/dist/commands/hub/hub-client/internal/problem.js +85 -0
- package/dist/commands/hub/hub-client/internal/transport.d.ts +15 -0
- package/dist/commands/hub/hub-client/internal/transport.js +30 -0
- package/dist/commands/hub/index.d.ts +20 -0
- package/dist/commands/hub/index.js +94 -0
- package/dist/commands/hub/init-plan.d.ts +33 -0
- package/dist/commands/hub/init-plan.js +94 -0
- package/dist/commands/hub/init.d.ts +37 -0
- package/dist/commands/hub/init.js +525 -0
- package/dist/commands/hub/login-flow.d.ts +34 -0
- package/dist/commands/hub/login-flow.js +78 -0
- package/dist/commands/hub/login.d.ts +23 -0
- package/dist/commands/hub/login.js +40 -0
- package/dist/commands/hub/logout.d.ts +33 -0
- package/dist/commands/hub/logout.js +71 -0
- package/dist/commands/hub/origin.d.ts +2 -0
- package/dist/commands/hub/origin.js +27 -0
- package/dist/commands/hub/permissions.d.ts +22 -0
- package/dist/commands/hub/permissions.js +61 -0
- package/dist/commands/hub/projects.d.ts +24 -0
- package/dist/commands/hub/projects.js +49 -0
- package/dist/commands/hub/reporter.d.ts +10 -0
- package/dist/commands/hub/reporter.js +11 -0
- package/dist/commands/hub/starter-agent-runtime.d.ts +37 -0
- package/dist/commands/hub/starter-agent-runtime.js +49 -0
- package/dist/commands/hub/starter-trigger.d.ts +10 -0
- package/dist/commands/hub/starter-trigger.js +30 -0
- package/dist/commands/hub/status-output.d.ts +13 -0
- package/dist/commands/hub/status-output.js +30 -0
- package/dist/commands/onboard.d.ts +14 -0
- package/dist/commands/onboard.js +169 -0
- package/dist/commands/open.d.ts +4 -0
- package/dist/commands/open.js +91 -0
- package/dist/commands/permit/allow.d.ts +38 -0
- package/dist/commands/permit/allow.js +138 -0
- package/dist/commands/permit/deny.d.ts +13 -0
- package/dist/commands/permit/deny.js +100 -0
- package/dist/commands/permit/index.d.ts +3 -0
- package/dist/commands/permit/index.js +27 -0
- package/dist/commands/permit/ls.d.ts +21 -0
- package/dist/commands/permit/ls.js +54 -0
- package/dist/commands/plugin/index.d.ts +23 -0
- package/dist/commands/plugin/index.js +174 -0
- package/dist/commands/plugin/scaffold.d.ts +6 -0
- package/dist/commands/plugin/scaffold.js +212 -0
- package/dist/commands/plugin/shared.d.ts +7 -0
- package/dist/commands/plugin/shared.js +34 -0
- package/dist/commands/plugin/update.d.ts +37 -0
- package/dist/commands/plugin/update.js +58 -0
- package/dist/commands/project/create.d.ts +10 -0
- package/dist/commands/project/create.js +43 -0
- package/dist/commands/project/delete.d.ts +9 -0
- package/dist/commands/project/delete.js +35 -0
- package/dist/commands/project/index.d.ts +3 -0
- package/dist/commands/project/index.js +28 -0
- package/dist/commands/project/ls.d.ts +5 -0
- package/dist/commands/project/ls.js +19 -0
- package/dist/commands/project/rename.d.ts +15 -0
- package/dist/commands/project/rename.js +52 -0
- package/dist/commands/project/shared.d.ts +11 -0
- package/dist/commands/project/shared.js +18 -0
- package/dist/commands/provider/diagnostic.d.ts +12 -0
- package/dist/commands/provider/diagnostic.js +31 -0
- package/dist/commands/provider/index.d.ts +3 -0
- package/dist/commands/provider/index.js +21 -0
- package/dist/commands/provider/ls.d.ts +19 -0
- package/dist/commands/provider/ls.js +46 -0
- package/dist/commands/provider/models.d.ts +20 -0
- package/dist/commands/provider/models.js +53 -0
- package/dist/commands/schedule/create.d.ts +19 -0
- package/dist/commands/schedule/create.js +41 -0
- package/dist/commands/schedule/delete.d.ts +10 -0
- package/dist/commands/schedule/delete.js +32 -0
- package/dist/commands/schedule/index.d.ts +3 -0
- package/dist/commands/schedule/index.js +66 -0
- package/dist/commands/schedule/inspect.d.ts +6 -0
- package/dist/commands/schedule/inspect.js +27 -0
- package/dist/commands/schedule/logs.d.ts +6 -0
- package/dist/commands/schedule/logs.js +24 -0
- package/dist/commands/schedule/ls.d.ts +5 -0
- package/dist/commands/schedule/ls.js +25 -0
- package/dist/commands/schedule/pause.d.ts +5 -0
- package/dist/commands/schedule/pause.js +24 -0
- package/dist/commands/schedule/resume.d.ts +5 -0
- package/dist/commands/schedule/resume.js +24 -0
- package/dist/commands/schedule/run-once.d.ts +5 -0
- package/dist/commands/schedule/run-once.js +24 -0
- package/dist/commands/schedule/schema.d.ts +21 -0
- package/dist/commands/schedule/schema.js +67 -0
- package/dist/commands/schedule/shared.d.ts +61 -0
- package/dist/commands/schedule/shared.js +360 -0
- package/dist/commands/schedule/types.d.ts +165 -0
- package/dist/commands/schedule/types.js +2 -0
- package/dist/commands/schedule/update.d.ts +19 -0
- package/dist/commands/schedule/update.js +40 -0
- package/dist/commands/script/index.d.ts +3 -0
- package/dist/commands/script/index.js +19 -0
- package/dist/commands/script/ls.d.ts +6 -0
- package/dist/commands/script/ls.js +20 -0
- package/dist/commands/script/schema.d.ts +5 -0
- package/dist/commands/script/schema.js +13 -0
- package/dist/commands/script/shared.d.ts +12 -0
- package/dist/commands/script/shared.js +59 -0
- package/dist/commands/script/start.d.ts +6 -0
- package/dist/commands/script/start.js +23 -0
- package/dist/commands/script/stop.d.ts +6 -0
- package/dist/commands/script/stop.js +23 -0
- package/dist/commands/terminal/capture.d.ts +10 -0
- package/dist/commands/terminal/capture.js +67 -0
- package/dist/commands/terminal/create.d.ts +11 -0
- package/dist/commands/terminal/create.js +29 -0
- package/dist/commands/terminal/index.d.ts +3 -0
- package/dist/commands/terminal/index.js +51 -0
- package/dist/commands/terminal/kill.d.ts +6 -0
- package/dist/commands/terminal/kill.js +36 -0
- package/dist/commands/terminal/ls.d.ts +11 -0
- package/dist/commands/terminal/ls.js +21 -0
- package/dist/commands/terminal/schema.d.ts +10 -0
- package/dist/commands/terminal/schema.js +17 -0
- package/dist/commands/terminal/send-keys.d.ts +7 -0
- package/dist/commands/terminal/send-keys.js +44 -0
- package/dist/commands/terminal/shared.d.ts +13 -0
- package/dist/commands/terminal/shared.js +64 -0
- package/dist/commands/terminal/upgrade-hosts.d.ts +11 -0
- package/dist/commands/terminal/upgrade-hosts.js +46 -0
- package/dist/commands/usage/index.d.ts +29 -0
- package/dist/commands/usage/index.js +62 -0
- package/dist/commands/usage/presentation.d.ts +4 -0
- package/dist/commands/usage/presentation.js +146 -0
- package/dist/commands/workspace/archive.d.ts +13 -0
- package/dist/commands/workspace/archive.js +43 -0
- package/dist/commands/workspace/create.d.ts +50 -0
- package/dist/commands/workspace/create.js +132 -0
- package/dist/commands/workspace/index.d.ts +3 -0
- package/dist/commands/workspace/index.js +50 -0
- package/dist/commands/workspace/ls.d.ts +11 -0
- package/dist/commands/workspace/ls.js +33 -0
- package/dist/commands/workspace/rename.d.ts +23 -0
- package/dist/commands/workspace/rename.js +63 -0
- package/dist/commands/workspace/setup.d.ts +12 -0
- package/dist/commands/workspace/setup.js +41 -0
- package/dist/commands/workspace/shared.d.ts +15 -0
- package/dist/commands/workspace/shared.js +29 -0
- package/dist/commands/worktree/archive.d.ts +21 -0
- package/dist/commands/worktree/archive.js +108 -0
- package/dist/commands/worktree/create-input.d.ts +15 -0
- package/dist/commands/worktree/create-input.js +56 -0
- package/dist/commands/worktree/create.d.ts +11 -0
- package/dist/commands/worktree/create.js +50 -0
- package/dist/commands/worktree/index.d.ts +3 -0
- package/dist/commands/worktree/index.js +29 -0
- package/dist/commands/worktree/ls.d.ts +18 -0
- package/dist/commands/worktree/ls.js +73 -0
- package/dist/commands/worktree/repository-directory.d.ts +6 -0
- package/dist/commands/worktree/repository-directory.js +9 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/output/index.d.ts +45 -0
- package/dist/output/index.js +47 -0
- package/dist/output/json.d.ts +11 -0
- package/dist/output/json.js +37 -0
- package/dist/output/pairing.d.ts +9 -0
- package/dist/output/pairing.js +36 -0
- package/dist/output/quiet.d.ts +9 -0
- package/dist/output/quiet.js +22 -0
- package/dist/output/render.d.ts +15 -0
- package/dist/output/render.js +84 -0
- package/dist/output/table.d.ts +13 -0
- package/dist/output/table.js +135 -0
- package/dist/output/types.d.ts +73 -0
- package/dist/output/types.js +8 -0
- package/dist/output/with-output.d.ts +43 -0
- package/dist/output/with-output.js +85 -0
- package/dist/output/yaml.d.ts +11 -0
- package/dist/output/yaml.js +38 -0
- package/dist/run.d.ts +14 -0
- package/dist/run.js +62 -0
- package/dist/ssh/ssh-tunnel.d.ts +2 -0
- package/dist/ssh/ssh-tunnel.js +3 -0
- package/dist/utils/agent-directory.d.ts +31 -0
- package/dist/utils/agent-directory.js +48 -0
- package/dist/utils/caller-agent.d.ts +14 -0
- package/dist/utils/caller-agent.js +16 -0
- package/dist/utils/client-id.d.ts +2 -0
- package/dist/utils/client-id.js +31 -0
- package/dist/utils/client.d.ts +57 -0
- package/dist/utils/client.js +360 -0
- package/dist/utils/command-options.d.ts +8 -0
- package/dist/utils/command-options.js +49 -0
- package/dist/utils/daemon-target.d.ts +13 -0
- package/dist/utils/daemon-target.js +51 -0
- package/dist/utils/duration.d.ts +7 -0
- package/dist/utils/duration.js +39 -0
- package/dist/utils/errors.d.ts +5 -0
- package/dist/utils/errors.js +10 -0
- package/dist/utils/paths.d.ts +12 -0
- package/dist/utils/paths.js +22 -0
- package/dist/utils/provider-model.d.ts +11 -0
- package/dist/utils/provider-model.js +49 -0
- package/dist/utils/timeline.d.ts +12 -0
- package/dist/utils/timeline.js +16 -0
- package/dist/utils/wait-for-stop.d.ts +2 -0
- package/dist/utils/wait-for-stop.js +28 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.js +24 -0
- package/package.json +58 -4
- package/README.md +0 -3
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { DEFAULT_APP_BASE_URL } from "@getmateo/protocol/service-defaults";
|
|
2
|
+
import { addLocalDaemonOptions } from "../utils/command-options.js";
|
|
3
|
+
import { cancel, intro, log, note, outro } from "@clack/prompts";
|
|
4
|
+
import { Command, Option } from "commander";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { readPersistedConfig as loadPersistedConfig, savePersistedConfig, } from "@getmateo/server/configuration";
|
|
7
|
+
import { readDaemonInstance, waitForDaemonReady } from "@getmateo/server/daemon-control";
|
|
8
|
+
import { withGlobalOptions } from "../utils/command-options.js";
|
|
9
|
+
import { launchLocalDaemon, parseTimeoutMs } from "./daemon/local-daemon.js";
|
|
10
|
+
import { connectToDaemon } from "../utils/client.js";
|
|
11
|
+
import { formatPairingInstructions } from "../output/pairing.js";
|
|
12
|
+
import { confirmRelayPairing, printDirectConnectionGuidance, resolveLocalPairingOffer, } from "./daemon/pair.js";
|
|
13
|
+
const plainNoteFormat = (line) => line;
|
|
14
|
+
function renderNote(message, title) {
|
|
15
|
+
note(message, title, { format: plainNoteFormat });
|
|
16
|
+
}
|
|
17
|
+
function printNextSteps(pairingUrl, mateoHome, richUi) {
|
|
18
|
+
const daemonLogPath = path.join(mateoHome, "daemon.log");
|
|
19
|
+
const nextStepsLines = [
|
|
20
|
+
pairingUrl
|
|
21
|
+
? "1. Open Mateo and scan the QR code above, or paste the pairing link."
|
|
22
|
+
: "1. Open Mateo and connect to your daemon.",
|
|
23
|
+
`2. Web app: ${loadPersistedConfig(mateoHome)?.app?.baseUrl ?? DEFAULT_APP_BASE_URL}`,
|
|
24
|
+
"3. Desktop app: https://github.com/getpaseo/paseo/releases/latest",
|
|
25
|
+
"4. Docs: https://paseo.sh/docs",
|
|
26
|
+
`5. Example: mateo run --home ${JSON.stringify(mateoHome)} --output-schema schema.json "extract fields"`,
|
|
27
|
+
];
|
|
28
|
+
const quickReferenceLines = [
|
|
29
|
+
"1. mateo --help",
|
|
30
|
+
`2. mateo ls --home ${JSON.stringify(mateoHome)}`,
|
|
31
|
+
`3. mateo run --home ${JSON.stringify(mateoHome)} "your prompt"`,
|
|
32
|
+
`4. mateo status --home ${JSON.stringify(mateoHome)}`,
|
|
33
|
+
`5. Daemon logs: ${daemonLogPath}`,
|
|
34
|
+
];
|
|
35
|
+
if (!richUi) {
|
|
36
|
+
console.log("");
|
|
37
|
+
console.log("Next steps:");
|
|
38
|
+
for (const line of nextStepsLines) {
|
|
39
|
+
console.log(line);
|
|
40
|
+
}
|
|
41
|
+
console.log("");
|
|
42
|
+
console.log("CLI quick reference:");
|
|
43
|
+
for (const line of quickReferenceLines) {
|
|
44
|
+
console.log(line);
|
|
45
|
+
}
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
renderNote(nextStepsLines.join("\n"), "Next steps");
|
|
49
|
+
renderNote(quickReferenceLines.join("\n"), "CLI quick reference");
|
|
50
|
+
}
|
|
51
|
+
export function onboardCommand() {
|
|
52
|
+
return addLocalDaemonOptions(new Command("onboard"))
|
|
53
|
+
.description("Run first-time setup, start daemon, and print pairing instructions")
|
|
54
|
+
.option("--listen <listen>", "Listen target (host:port, port, or unix socket path)")
|
|
55
|
+
.option("--port <port>", "Port to listen on (default: 8686)")
|
|
56
|
+
.option("--relay", "Enable relay connection without prompting")
|
|
57
|
+
.option("--no-relay", "Disable relay connection")
|
|
58
|
+
.option("--no-mcp", "Disable the Agent MCP HTTP endpoint")
|
|
59
|
+
.option("--hostnames <hosts>", 'Daemon hostnames (comma-separated, e.g. "myhost,.example.com" or "true" for any)')
|
|
60
|
+
.addOption(new Option("--allowed-hosts <hosts>").hideHelp())
|
|
61
|
+
.option("--timeout <seconds>", "Max time to wait for daemon readiness (default: 600)")
|
|
62
|
+
.action(withGlobalOptions(async (options, command) => {
|
|
63
|
+
await runOnboard({
|
|
64
|
+
...options,
|
|
65
|
+
mcp: command.getOptionValueSource("mcp") === "cli" ? options.mcp : undefined,
|
|
66
|
+
hostnames: options.hostnames ?? options.allowedHosts,
|
|
67
|
+
});
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
function persistSetupChoices(mateoHome, options) {
|
|
71
|
+
const persisted = loadPersistedConfig(mateoHome, { defaultsIfMissing: true });
|
|
72
|
+
if (options.listen || options.port) {
|
|
73
|
+
persisted.daemon = {
|
|
74
|
+
...persisted.daemon,
|
|
75
|
+
listen: options.listen ?? `127.0.0.1:${options.port}`,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (options.relay !== undefined)
|
|
79
|
+
persisted.daemon = {
|
|
80
|
+
...persisted.daemon,
|
|
81
|
+
relay: { ...persisted.daemon?.relay, enabled: options.relay },
|
|
82
|
+
};
|
|
83
|
+
if (options.mcp !== undefined)
|
|
84
|
+
persisted.daemon = {
|
|
85
|
+
...persisted.daemon,
|
|
86
|
+
mcp: { ...persisted.daemon?.mcp, enabled: options.mcp },
|
|
87
|
+
};
|
|
88
|
+
if (options.hostnames)
|
|
89
|
+
persisted.daemon = {
|
|
90
|
+
...persisted.daemon,
|
|
91
|
+
hostnames: options.hostnames === "true" ? true : options.hostnames.split(","),
|
|
92
|
+
};
|
|
93
|
+
savePersistedConfig(mateoHome, persisted);
|
|
94
|
+
}
|
|
95
|
+
export async function runOnboard(options) {
|
|
96
|
+
const richUi = process.stdin.isTTY && process.stdout.isTTY;
|
|
97
|
+
if (richUi) {
|
|
98
|
+
intro("Welcome to Mateo");
|
|
99
|
+
}
|
|
100
|
+
if (options.listen && options.port) {
|
|
101
|
+
cancel("Cannot use --listen and --port together");
|
|
102
|
+
process.exit(1);
|
|
103
|
+
}
|
|
104
|
+
const timeoutMs = parseTimeoutMs(options.timeout);
|
|
105
|
+
if (options.daemonTarget.kind !== "instance")
|
|
106
|
+
throw new Error("Onboarding requires a local home");
|
|
107
|
+
const mateoHome = options.daemonTarget.home;
|
|
108
|
+
const alreadyRunning = await readDaemonInstance(mateoHome);
|
|
109
|
+
persistSetupChoices(mateoHome, options);
|
|
110
|
+
if (richUi) {
|
|
111
|
+
renderNote(mateoHome, "Mateo home");
|
|
112
|
+
}
|
|
113
|
+
if (alreadyRunning) {
|
|
114
|
+
log.message(`Daemon already running (PID ${alreadyRunning.pid}); retaining its supervisor.`);
|
|
115
|
+
const client = await connectToDaemon({ target: options.daemonTarget, timeout: timeoutMs });
|
|
116
|
+
try {
|
|
117
|
+
log.message(JSON.stringify(await client.reloadDaemonConfig()));
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
await client.close();
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
await launchLocalDaemon({ home: mateoHome, timeoutMs });
|
|
125
|
+
}
|
|
126
|
+
const ready = await waitForDaemonReady(mateoHome, { timeoutMs });
|
|
127
|
+
log.message(`Daemon ready on ${ready.listen}`);
|
|
128
|
+
if (options.relay === false) {
|
|
129
|
+
log.message("Relay pairing skipped because --no-relay was provided.");
|
|
130
|
+
printNextSteps(null, mateoHome, richUi);
|
|
131
|
+
if (richUi)
|
|
132
|
+
outro("Mateo daemon is running.");
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
let pairing = await resolveLocalPairingOffer({
|
|
136
|
+
mateoHome,
|
|
137
|
+
enableRelay: options.relay === true,
|
|
138
|
+
});
|
|
139
|
+
if (!pairing.relayEnabled) {
|
|
140
|
+
const shouldEnable = richUi ? await confirmRelayPairing() : false;
|
|
141
|
+
if (!shouldEnable) {
|
|
142
|
+
printDirectConnectionGuidance();
|
|
143
|
+
printNextSteps(null, mateoHome, richUi);
|
|
144
|
+
if (richUi)
|
|
145
|
+
outro("Mateo daemon is running.");
|
|
146
|
+
return;
|
|
147
|
+
}
|
|
148
|
+
pairing = await resolveLocalPairingOffer({ mateoHome, enableRelay: true });
|
|
149
|
+
log.success("Relay enabled");
|
|
150
|
+
}
|
|
151
|
+
if (!pairing.url) {
|
|
152
|
+
log.warn("Relay pairing URL is unavailable for this daemon configuration.");
|
|
153
|
+
printNextSteps(null, mateoHome, richUi);
|
|
154
|
+
if (richUi) {
|
|
155
|
+
outro("Mateo daemon is running.");
|
|
156
|
+
}
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
process.stdout.write(formatPairingInstructions({
|
|
160
|
+
url: pairing.url,
|
|
161
|
+
qr: pairing.qr,
|
|
162
|
+
columns: process.stdout.columns,
|
|
163
|
+
}));
|
|
164
|
+
printNextSteps(pairing.url, mateoHome, richUi);
|
|
165
|
+
if (richUi) {
|
|
166
|
+
outro("Mateo is ready!");
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=onboard.js.map
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type AgentDeepLinkTarget } from "@getmateo/protocol/agent-deep-link";
|
|
2
|
+
export declare function openDesktopWithProject(projectPath: string): Promise<void>;
|
|
3
|
+
export declare function openDesktopWithAgent(target: AgentDeepLinkTarget): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=open.d.ts.map
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { spawnProcess } from "@getmateo/server/process";
|
|
5
|
+
import { buildAgentDeepLink } from "@getmateo/protocol/agent-deep-link";
|
|
6
|
+
function findDesktopApp() {
|
|
7
|
+
if (process.platform === "darwin") {
|
|
8
|
+
const candidates = [
|
|
9
|
+
"/Applications/Mateo.app",
|
|
10
|
+
path.join(homedir(), "Applications", "Mateo.app"),
|
|
11
|
+
];
|
|
12
|
+
for (const candidate of candidates) {
|
|
13
|
+
if (existsSync(candidate)) {
|
|
14
|
+
return candidate;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
if (process.platform === "linux") {
|
|
20
|
+
const candidates = [
|
|
21
|
+
"/usr/bin/Mateo",
|
|
22
|
+
"/opt/Mateo/Mateo",
|
|
23
|
+
path.join(homedir(), "Applications", "Mateo.AppImage"),
|
|
24
|
+
];
|
|
25
|
+
for (const candidate of candidates) {
|
|
26
|
+
if (existsSync(candidate)) {
|
|
27
|
+
return candidate;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
if (process.platform === "win32") {
|
|
33
|
+
const localAppData = process.env.LOCALAPPDATA;
|
|
34
|
+
if (!localAppData) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const candidate = path.join(localAppData, "Programs", "Mateo", "Mateo.exe");
|
|
38
|
+
return existsSync(candidate) ? candidate : null;
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
function cleanEnvForDesktopLaunch() {
|
|
43
|
+
const env = { ...process.env };
|
|
44
|
+
// The CLI runs via ELECTRON_RUN_AS_NODE=1. On Linux/Windows the spawned
|
|
45
|
+
// desktop process inherits the env directly, so we must strip it or the
|
|
46
|
+
// desktop app would start as a bare Node process instead of Electron.
|
|
47
|
+
delete env.ELECTRON_RUN_AS_NODE;
|
|
48
|
+
delete env.ELECTRON_NO_ATTACH_CONSOLE;
|
|
49
|
+
delete env.MATEO_NODE_ENV;
|
|
50
|
+
return env;
|
|
51
|
+
}
|
|
52
|
+
function spawnDetached(command, args) {
|
|
53
|
+
spawnProcess(command, args, {
|
|
54
|
+
detached: true,
|
|
55
|
+
stdio: "ignore",
|
|
56
|
+
env: cleanEnvForDesktopLaunch(),
|
|
57
|
+
}).unref();
|
|
58
|
+
}
|
|
59
|
+
function launchDesktop(args) {
|
|
60
|
+
if (process.env.MATEO_DESKTOP_CLI === "1") {
|
|
61
|
+
throw new Error("Cannot open Mateo Desktop while running in desktop CLI passthrough mode.");
|
|
62
|
+
}
|
|
63
|
+
const desktopApp = findDesktopApp();
|
|
64
|
+
if (!desktopApp) {
|
|
65
|
+
throw new Error("Mateo desktop app not found. Install it from https://github.com/getpaseo/paseo/releases");
|
|
66
|
+
}
|
|
67
|
+
if (process.platform === "darwin") {
|
|
68
|
+
// -n forces a new instance even if the app is already running. The new
|
|
69
|
+
// instance relays its argv to the existing one through Electron's
|
|
70
|
+
// single-instance lock. -g keeps the terminal in the foreground.
|
|
71
|
+
spawnDetached("open", ["-n", "-g", "-a", desktopApp, "--args", ...args]);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
spawnDetached(desktopApp, args);
|
|
75
|
+
}
|
|
76
|
+
export async function openDesktopWithProject(projectPath) {
|
|
77
|
+
try {
|
|
78
|
+
launchDesktop([projectPath]);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error && typeof error === "object" && "code" in error)
|
|
82
|
+
throw error;
|
|
83
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
84
|
+
process.stderr.write(`${message}\n`);
|
|
85
|
+
process.exitCode = 1;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export async function openDesktopWithAgent(target) {
|
|
89
|
+
launchDesktop([buildAgentDeepLink(target)]);
|
|
90
|
+
}
|
|
91
|
+
//# sourceMappingURL=open.js.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { AgentPermissionRequest, AgentPermissionResponse } from "@getmateo/protocol/agent-types";
|
|
3
|
+
import { connectToDaemon } from "../../utils/client.js";
|
|
4
|
+
import type { CommandOptions, ListResult, OutputSchema } from "../../output/index.js";
|
|
5
|
+
/** Permission response item for display */
|
|
6
|
+
export interface PermissionResponseItem {
|
|
7
|
+
requestId: string;
|
|
8
|
+
agentId: string;
|
|
9
|
+
agentShortId: string;
|
|
10
|
+
name: string;
|
|
11
|
+
result: string;
|
|
12
|
+
}
|
|
13
|
+
/** Schema for permit allow/deny output */
|
|
14
|
+
export declare const permitResponseSchema: OutputSchema<PermissionResponseItem>;
|
|
15
|
+
/** Transform a permission the agent answered to a response item */
|
|
16
|
+
export declare function toPermissionResponseItem(agentId: string, permission: AgentPermissionRequest, result: "allowed" | "denied"): PermissionResponseItem;
|
|
17
|
+
export type PermitAllowResult = ListResult<PermissionResponseItem>;
|
|
18
|
+
export interface PermitAllowOptions extends CommandOptions {
|
|
19
|
+
all?: boolean;
|
|
20
|
+
input?: string;
|
|
21
|
+
host?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface PermitClient {
|
|
24
|
+
fetchAgent(options: {
|
|
25
|
+
agentId: string;
|
|
26
|
+
}): Promise<{
|
|
27
|
+
agent: {
|
|
28
|
+
id: string;
|
|
29
|
+
pendingPermissions?: AgentPermissionRequest[];
|
|
30
|
+
};
|
|
31
|
+
} | null>;
|
|
32
|
+
respondToPermissionAndWait(agentId: string, requestId: string, response: AgentPermissionResponse): Promise<unknown>;
|
|
33
|
+
close(): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export type PermitClientConnector = (options: Parameters<typeof connectToDaemon>[0]) => Promise<PermitClient>;
|
|
36
|
+
export declare function createAllowCommand(connect?: PermitClientConnector): (agentIdOrPrefix: string, reqId: string | undefined, options: PermitAllowOptions, _command: Command) => Promise<PermitAllowResult>;
|
|
37
|
+
export declare const runAllowCommand: (agentIdOrPrefix: string, reqId: string | undefined, options: PermitAllowOptions, _command: Command) => Promise<PermitAllowResult>;
|
|
38
|
+
//# sourceMappingURL=allow.d.ts.map
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { connectToDaemon } from "../../utils/client.js";
|
|
2
|
+
/** Schema for permit allow/deny output */
|
|
3
|
+
export const permitResponseSchema = {
|
|
4
|
+
idField: "requestId",
|
|
5
|
+
columns: [
|
|
6
|
+
{ header: "REQUEST ID", field: (item) => item.requestId.slice(0, 8), width: 12 },
|
|
7
|
+
{ header: "AGENT", field: "agentShortId", width: 10 },
|
|
8
|
+
{ header: "TOOL", field: "name", width: 20 },
|
|
9
|
+
{
|
|
10
|
+
header: "RESULT",
|
|
11
|
+
field: "result",
|
|
12
|
+
width: 10,
|
|
13
|
+
color: (value) => {
|
|
14
|
+
if (value === "allowed")
|
|
15
|
+
return "green";
|
|
16
|
+
if (value === "denied")
|
|
17
|
+
return "red";
|
|
18
|
+
return undefined;
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
};
|
|
23
|
+
/** Transform a permission the agent answered to a response item */
|
|
24
|
+
export function toPermissionResponseItem(agentId, permission, result) {
|
|
25
|
+
return {
|
|
26
|
+
requestId: permission.id,
|
|
27
|
+
agentId,
|
|
28
|
+
agentShortId: agentId.slice(0, 7),
|
|
29
|
+
name: permission.name,
|
|
30
|
+
result,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
export function createAllowCommand(connect = connectToDaemon) {
|
|
34
|
+
return async function runAllowCommand(agentIdOrPrefix, reqId, options, _command) {
|
|
35
|
+
// No validation needed - if no reqId provided, allow all by default
|
|
36
|
+
// Parse input JSON if provided
|
|
37
|
+
let updatedInput;
|
|
38
|
+
if (options.input) {
|
|
39
|
+
try {
|
|
40
|
+
updatedInput = JSON.parse(options.input);
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
const error = {
|
|
44
|
+
code: "INVALID_JSON",
|
|
45
|
+
message: `Invalid JSON for --input: ${err instanceof Error ? err.message : String(err)}`,
|
|
46
|
+
details: 'Provide valid JSON, e.g., --input \'{"key": "value"}\'',
|
|
47
|
+
};
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const client = await connect({ target: options.daemonTarget });
|
|
52
|
+
try {
|
|
53
|
+
const fetchResult = await client.fetchAgent({ agentId: agentIdOrPrefix });
|
|
54
|
+
if (!fetchResult) {
|
|
55
|
+
await client.close();
|
|
56
|
+
const error = {
|
|
57
|
+
code: "AGENT_NOT_FOUND",
|
|
58
|
+
message: `Agent not found: ${agentIdOrPrefix}`,
|
|
59
|
+
details: 'Use "mateo ls" to list available agents',
|
|
60
|
+
};
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
const agent = fetchResult.agent;
|
|
64
|
+
const resolvedAgentId = agent.id;
|
|
65
|
+
// Get pending permissions for this agent
|
|
66
|
+
const pendingPermissions = agent.pendingPermissions || [];
|
|
67
|
+
if (pendingPermissions.length === 0) {
|
|
68
|
+
await client.close();
|
|
69
|
+
const error = {
|
|
70
|
+
code: "NO_PENDING_PERMISSIONS",
|
|
71
|
+
message: `No pending permissions for agent ${agent.id.slice(0, 7)}`,
|
|
72
|
+
};
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
// Determine which permissions to allow
|
|
76
|
+
let permissionsToAllow;
|
|
77
|
+
if (!reqId || options.all) {
|
|
78
|
+
// Default: allow all pending permissions if no req_id specified
|
|
79
|
+
// --all flag is kept as an explicit alias for clarity
|
|
80
|
+
permissionsToAllow = pendingPermissions;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
// Find permission by ID prefix
|
|
84
|
+
const permission = pendingPermissions.find((p) => p.id === reqId || p.id.startsWith(reqId));
|
|
85
|
+
if (!permission) {
|
|
86
|
+
await client.close();
|
|
87
|
+
const error = {
|
|
88
|
+
code: "PERMISSION_NOT_FOUND",
|
|
89
|
+
message: `Permission request not found: ${reqId}`,
|
|
90
|
+
details: `Available requests: ${pendingPermissions.map((p) => p.id.slice(0, 8)).join(", ")}`,
|
|
91
|
+
};
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
permissionsToAllow = [permission];
|
|
95
|
+
}
|
|
96
|
+
// Allow permissions
|
|
97
|
+
const results = await Promise.all(permissionsToAllow.map(async (permission) => {
|
|
98
|
+
try {
|
|
99
|
+
await client.respondToPermissionAndWait(resolvedAgentId, permission.id, {
|
|
100
|
+
behavior: "allow",
|
|
101
|
+
...(updatedInput ? { updatedInput } : {}),
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
catch (err) {
|
|
105
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
106
|
+
const error = {
|
|
107
|
+
code: "PERMISSION_RESPONSE_UNCONFIRMED",
|
|
108
|
+
message: `Permission response unconfirmed for request ${permission.id}: ${message}`,
|
|
109
|
+
details: 'Use "mateo permit ls" to check whether the request is still pending',
|
|
110
|
+
};
|
|
111
|
+
throw error;
|
|
112
|
+
}
|
|
113
|
+
return toPermissionResponseItem(resolvedAgentId, permission, "allowed");
|
|
114
|
+
}));
|
|
115
|
+
await client.close();
|
|
116
|
+
return {
|
|
117
|
+
type: "list",
|
|
118
|
+
data: results,
|
|
119
|
+
schema: permitResponseSchema,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
await client.close().catch(() => { });
|
|
124
|
+
// Re-throw CommandErrors
|
|
125
|
+
if (err && typeof err === "object" && "code" in err) {
|
|
126
|
+
throw err;
|
|
127
|
+
}
|
|
128
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
129
|
+
const error = {
|
|
130
|
+
code: "ALLOW_PERMISSION_FAILED",
|
|
131
|
+
message: `Failed to allow permission: ${message}`,
|
|
132
|
+
};
|
|
133
|
+
throw error;
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export const runAllowCommand = createAllowCommand();
|
|
138
|
+
//# sourceMappingURL=allow.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { CommandOptions, ListResult } from "../../output/index.js";
|
|
3
|
+
import { type PermissionResponseItem, type PermitClientConnector } from "./allow.js";
|
|
4
|
+
export type PermitDenyResult = ListResult<PermissionResponseItem>;
|
|
5
|
+
export interface PermitDenyOptions extends CommandOptions {
|
|
6
|
+
all?: boolean;
|
|
7
|
+
message?: string;
|
|
8
|
+
interrupt?: boolean;
|
|
9
|
+
host?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare function createDenyCommand(connect?: PermitClientConnector): (agentIdOrPrefix: string, reqId: string | undefined, options: PermitDenyOptions, _command: Command) => Promise<PermitDenyResult>;
|
|
12
|
+
export declare const runDenyCommand: (agentIdOrPrefix: string, reqId: string | undefined, options: PermitDenyOptions, _command: Command) => Promise<PermitDenyResult>;
|
|
13
|
+
//# sourceMappingURL=deny.d.ts.map
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { connectToDaemon } from "../../utils/client.js";
|
|
2
|
+
import { permitResponseSchema, toPermissionResponseItem, } from "./allow.js";
|
|
3
|
+
export function createDenyCommand(connect = connectToDaemon) {
|
|
4
|
+
return async function runDenyCommand(agentIdOrPrefix, reqId, options, _command) {
|
|
5
|
+
// Validate arguments
|
|
6
|
+
if (!options.all && !reqId) {
|
|
7
|
+
const error = {
|
|
8
|
+
code: "MISSING_ARGUMENT",
|
|
9
|
+
message: "Request ID is required unless --all is specified",
|
|
10
|
+
details: "Usage: mateo permit deny <agent> <req_id> or mateo permit deny <agent> --all",
|
|
11
|
+
};
|
|
12
|
+
throw error;
|
|
13
|
+
}
|
|
14
|
+
const client = await connect({ target: options.daemonTarget });
|
|
15
|
+
try {
|
|
16
|
+
const fetchResult = await client.fetchAgent({ agentId: agentIdOrPrefix });
|
|
17
|
+
if (!fetchResult) {
|
|
18
|
+
await client.close();
|
|
19
|
+
const error = {
|
|
20
|
+
code: "AGENT_NOT_FOUND",
|
|
21
|
+
message: `Agent not found: ${agentIdOrPrefix}`,
|
|
22
|
+
details: 'Use "mateo ls" to list available agents',
|
|
23
|
+
};
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
const agent = fetchResult.agent;
|
|
27
|
+
const resolvedAgentId = agent.id;
|
|
28
|
+
// Get pending permissions for this agent
|
|
29
|
+
const pendingPermissions = agent.pendingPermissions || [];
|
|
30
|
+
if (pendingPermissions.length === 0) {
|
|
31
|
+
await client.close();
|
|
32
|
+
const error = {
|
|
33
|
+
code: "NO_PENDING_PERMISSIONS",
|
|
34
|
+
message: `No pending permissions for agent ${agent.id.slice(0, 7)}`,
|
|
35
|
+
};
|
|
36
|
+
throw error;
|
|
37
|
+
}
|
|
38
|
+
// Determine which permissions to deny
|
|
39
|
+
let permissionsToDeny;
|
|
40
|
+
if (options.all) {
|
|
41
|
+
permissionsToDeny = pendingPermissions;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
// Find permission by ID prefix
|
|
45
|
+
const permission = pendingPermissions.find((p) => p.id === reqId || p.id.startsWith(reqId));
|
|
46
|
+
if (!permission) {
|
|
47
|
+
await client.close();
|
|
48
|
+
const error = {
|
|
49
|
+
code: "PERMISSION_NOT_FOUND",
|
|
50
|
+
message: `Permission request not found: ${reqId}`,
|
|
51
|
+
details: `Available requests: ${pendingPermissions.map((p) => p.id.slice(0, 8)).join(", ")}`,
|
|
52
|
+
};
|
|
53
|
+
throw error;
|
|
54
|
+
}
|
|
55
|
+
permissionsToDeny = [permission];
|
|
56
|
+
}
|
|
57
|
+
// Deny permissions
|
|
58
|
+
const results = await Promise.all(permissionsToDeny.map(async (permission) => {
|
|
59
|
+
try {
|
|
60
|
+
await client.respondToPermissionAndWait(resolvedAgentId, permission.id, {
|
|
61
|
+
behavior: "deny",
|
|
62
|
+
...(options.message ? { message: options.message } : {}),
|
|
63
|
+
...(options.interrupt ? { interrupt: true } : {}),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (err) {
|
|
67
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
68
|
+
const error = {
|
|
69
|
+
code: "PERMISSION_RESPONSE_UNCONFIRMED",
|
|
70
|
+
message: `Permission response unconfirmed for request ${permission.id}: ${message}`,
|
|
71
|
+
details: 'Use "mateo permit ls" to check whether the request is still pending',
|
|
72
|
+
};
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
return toPermissionResponseItem(resolvedAgentId, permission, "denied");
|
|
76
|
+
}));
|
|
77
|
+
await client.close();
|
|
78
|
+
return {
|
|
79
|
+
type: "list",
|
|
80
|
+
data: results,
|
|
81
|
+
schema: permitResponseSchema,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
await client.close().catch(() => { });
|
|
86
|
+
// Re-throw CommandErrors
|
|
87
|
+
if (err && typeof err === "object" && "code" in err) {
|
|
88
|
+
throw err;
|
|
89
|
+
}
|
|
90
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
91
|
+
const error = {
|
|
92
|
+
code: "DENY_PERMISSION_FAILED",
|
|
93
|
+
message: `Failed to deny permission: ${message}`,
|
|
94
|
+
};
|
|
95
|
+
throw error;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export const runDenyCommand = createDenyCommand();
|
|
100
|
+
//# sourceMappingURL=deny.js.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { runLsCommand } from "./ls.js";
|
|
3
|
+
import { runAllowCommand } from "./allow.js";
|
|
4
|
+
import { runDenyCommand } from "./deny.js";
|
|
5
|
+
import { withOutput } from "../../output/index.js";
|
|
6
|
+
import { addJsonAndDaemonHostOptions } from "../../utils/command-options.js";
|
|
7
|
+
export function createPermitCommand() {
|
|
8
|
+
const permit = new Command("permit").description("Manage permission requests");
|
|
9
|
+
addJsonAndDaemonHostOptions(permit.command("ls").description("List all pending permissions")).action(withOutput(runLsCommand));
|
|
10
|
+
addJsonAndDaemonHostOptions(permit
|
|
11
|
+
.command("allow")
|
|
12
|
+
.description("Allow a permission request")
|
|
13
|
+
.argument("<agent>", "Agent ID (or prefix)")
|
|
14
|
+
.argument("[req_id]", "Permission request ID (optional if --all)")
|
|
15
|
+
.option("--all", "Allow all pending permissions for this agent")
|
|
16
|
+
.option("--input <json>", "Modified input parameters (JSON)")).action(withOutput(runAllowCommand));
|
|
17
|
+
addJsonAndDaemonHostOptions(permit
|
|
18
|
+
.command("deny")
|
|
19
|
+
.description("Deny a permission request")
|
|
20
|
+
.argument("<agent>", "Agent ID (or prefix)")
|
|
21
|
+
.argument("[req_id]", "Permission request ID (optional if --all)")
|
|
22
|
+
.option("--all", "Deny all pending permissions for this agent")
|
|
23
|
+
.option("--message <msg>", "Denial reason message")
|
|
24
|
+
.option("--interrupt", "Stop agent after denial")).action(withOutput(runDenyCommand));
|
|
25
|
+
return permit;
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import type { AgentSnapshotPayload } from "@getmateo/protocol/messages";
|
|
3
|
+
import type { CommandOptions, ListResult, OutputSchema } from "../../output/index.js";
|
|
4
|
+
/** Permission list item for display */
|
|
5
|
+
export interface PermissionListItem {
|
|
6
|
+
id: string;
|
|
7
|
+
agentId: string;
|
|
8
|
+
agentShortId: string;
|
|
9
|
+
name: string;
|
|
10
|
+
description: string;
|
|
11
|
+
}
|
|
12
|
+
/** Schema for permit ls output */
|
|
13
|
+
export declare const permitLsSchema: OutputSchema<PermissionListItem>;
|
|
14
|
+
export type PermitLsResult = ListResult<PermissionListItem>;
|
|
15
|
+
/** Collect the pending permissions of every agent */
|
|
16
|
+
export declare function listPendingPermissions(agents: AgentSnapshotPayload[]): PermitLsResult;
|
|
17
|
+
export interface PermitLsOptions extends CommandOptions {
|
|
18
|
+
host?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare function runLsCommand(options: PermitLsOptions, _command: Command): Promise<PermitLsResult>;
|
|
21
|
+
//# sourceMappingURL=ls.d.ts.map
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { connectToDaemon } from "../../utils/client.js";
|
|
2
|
+
/** Schema for permit ls output */
|
|
3
|
+
export const permitLsSchema = {
|
|
4
|
+
idField: "id",
|
|
5
|
+
columns: [
|
|
6
|
+
{ header: "AGENT", field: "agentShortId", width: 12 },
|
|
7
|
+
{ header: "REQ_ID", field: (item) => item.id.slice(0, 8), width: 12 },
|
|
8
|
+
{ header: "TOOL", field: "name", width: 20 },
|
|
9
|
+
{ header: "DESCRIPTION", field: "description", width: 50 },
|
|
10
|
+
],
|
|
11
|
+
};
|
|
12
|
+
/** Transform agent snapshot + permission to list item */
|
|
13
|
+
function toListItem(agent, permission) {
|
|
14
|
+
return {
|
|
15
|
+
id: permission.id,
|
|
16
|
+
agentId: agent.id,
|
|
17
|
+
agentShortId: agent.id.slice(0, 7),
|
|
18
|
+
name: permission.name,
|
|
19
|
+
description: permission.description ?? "-",
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/** Collect the pending permissions of every agent */
|
|
23
|
+
export function listPendingPermissions(agents) {
|
|
24
|
+
const items = [];
|
|
25
|
+
for (const agent of agents) {
|
|
26
|
+
for (const permission of agent.pendingPermissions ?? []) {
|
|
27
|
+
items.push(toListItem(agent, permission));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
type: "list",
|
|
32
|
+
data: items,
|
|
33
|
+
schema: permitLsSchema,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export async function runLsCommand(options, _command) {
|
|
37
|
+
const client = await connectToDaemon({ target: options.daemonTarget });
|
|
38
|
+
try {
|
|
39
|
+
const agentsPayload = await client.fetchAgents({ filter: { includeArchived: true } });
|
|
40
|
+
const agents = agentsPayload.entries.map((entry) => entry.agent);
|
|
41
|
+
await client.close();
|
|
42
|
+
return listPendingPermissions(agents);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
await client.close().catch(() => { });
|
|
46
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
47
|
+
const error = {
|
|
48
|
+
code: "LIST_PERMISSIONS_FAILED",
|
|
49
|
+
message: `Failed to list permissions: ${message}`,
|
|
50
|
+
};
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=ls.js.map
|