@skrr-ai/cli 0.1.47 → 0.1.49
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 +1 -1
- package/dist/base-command.d.ts +18 -0
- package/dist/base-command.js +61 -1
- package/dist/commands/agent-worker.d.ts +12 -0
- package/dist/commands/agent-worker.js +140 -0
- package/dist/commands/agents/chat.d.ts +21 -0
- package/dist/commands/agents/chat.js +26 -9
- package/dist/commands/balance/usage/breakdown.d.ts +14 -0
- package/dist/commands/balance/usage/breakdown.js +68 -0
- package/dist/commands/balance/usage.js +24 -0
- package/dist/commands/commerce/entitlements/explain.d.ts +22 -0
- package/dist/commands/commerce/entitlements/explain.js +40 -0
- package/dist/commands/commerce/incidents/audit.d.ts +20 -0
- package/dist/commands/commerce/incidents/audit.js +37 -0
- package/dist/commands/commerce/incidents/list.d.ts +22 -0
- package/dist/commands/commerce/incidents/list.js +49 -0
- package/dist/commands/commerce/incidents/resolve.d.ts +23 -0
- package/dist/commands/commerce/incidents/resolve.js +45 -0
- package/dist/commands/commerce/incidents/retry.d.ts +22 -0
- package/dist/commands/commerce/incidents/retry.js +45 -0
- package/dist/commands/commerce/incidents/show.d.ts +13 -0
- package/dist/commands/commerce/incidents/show.js +30 -0
- package/dist/commands/commerce/offers/approve.d.ts +17 -0
- package/dist/commands/commerce/offers/approve.js +33 -0
- package/dist/commands/commerce/offers/create.d.ts +18 -0
- package/dist/commands/commerce/offers/create.js +34 -0
- package/dist/commands/commerce/offers/publish.d.ts +13 -0
- package/dist/commands/commerce/offers/publish.js +28 -0
- package/dist/commands/commerce/offers/retire.d.ts +17 -0
- package/dist/commands/commerce/offers/retire.js +32 -0
- package/dist/commands/commerce/offers/validate.d.ts +18 -0
- package/dist/commands/commerce/offers/validate.js +33 -0
- package/dist/commands/commerce/products/create.d.ts +10 -0
- package/dist/commands/commerce/products/create.js +25 -0
- package/dist/commands/commerce/promotions/redeem.d.ts +13 -0
- package/dist/commands/commerce/promotions/redeem.js +32 -0
- package/dist/commands/commerce/terms/accept.d.ts +18 -0
- package/dist/commands/commerce/terms/accept.js +39 -0
- package/dist/commands/commerce/terms/show.d.ts +10 -0
- package/dist/commands/commerce/terms/show.js +34 -0
- package/dist/commands/commerce/trials/conversion-preview.d.ts +18 -0
- package/dist/commands/commerce/trials/conversion-preview.js +39 -0
- package/dist/commands/commerce/trials/start.d.ts +23 -0
- package/dist/commands/commerce/trials/start.js +58 -0
- package/dist/commands/commitments/accounting.d.ts +39 -0
- package/dist/commands/commitments/accounting.js +116 -0
- package/dist/commands/commitments/action-history.d.ts +1 -0
- package/dist/commands/commitments/action-history.js +8 -1
- package/dist/commands/commitments/case.d.ts +1 -0
- package/dist/commands/commitments/case.js +19 -3
- package/dist/commands/commitments/cases.d.ts +1 -0
- package/dist/commands/commitments/cases.js +11 -1
- package/dist/commands/commitments/checks.d.ts +1 -0
- package/dist/commands/commitments/checks.js +5 -1
- package/dist/commands/commitments/cost.d.ts +62 -0
- package/dist/commands/commitments/cost.js +130 -0
- package/dist/commands/commitments/create.js +1 -1
- package/dist/commands/commitments/delete.d.ts +1 -0
- package/dist/commands/commitments/delete.js +56 -6
- package/dist/commands/commitments/feedback.js +9 -1
- package/dist/commands/commitments/handover.js +16 -0
- package/dist/commands/commitments/hypotheses.d.ts +1 -0
- package/dist/commands/commitments/hypotheses.js +17 -2
- package/dist/commands/commitments/links/list.js +4 -1
- package/dist/commands/commitments/liveness.d.ts +18 -0
- package/dist/commands/commitments/liveness.js +80 -0
- package/dist/commands/commitments/metrics.d.ts +1 -0
- package/dist/commands/commitments/metrics.js +8 -1
- package/dist/commands/commitments/next-tick.d.ts +39 -0
- package/dist/commands/commitments/next-tick.js +122 -0
- package/dist/commands/commitments/observations.d.ts +1 -0
- package/dist/commands/commitments/observations.js +19 -2
- package/dist/commands/commitments/pause.js +12 -0
- package/dist/commands/commitments/receipt.d.ts +2 -0
- package/dist/commands/commitments/receipt.js +16 -2
- package/dist/commands/commitments/remediation-proposal.js +6 -2
- package/dist/commands/commitments/remediation-proposals.js +5 -1
- package/dist/commands/commitments/restore.d.ts +25 -0
- package/dist/commands/commitments/restore.js +46 -0
- package/dist/commands/commitments/show.js +32 -0
- package/dist/commands/commitments/trigger-status.js +33 -0
- package/dist/commands/commitments/update.d.ts +1 -0
- package/dist/commands/commitments/update.js +31 -5
- package/dist/commands/commitments/wake-capabilities.d.ts +0 -1
- package/dist/commands/commitments/wake-capabilities.js +8 -4
- package/dist/commands/enterprise/budgets/create.d.ts +11 -0
- package/dist/commands/enterprise/budgets/create.js +27 -0
- package/dist/commands/enterprise/budgets/evaluate.d.ts +17 -0
- package/dist/commands/enterprise/budgets/evaluate.js +32 -0
- package/dist/commands/enterprise/budgets/publish.d.ts +14 -0
- package/dist/commands/enterprise/budgets/publish.js +30 -0
- package/dist/commands/enterprise/contracts/activate.d.ts +14 -0
- package/dist/commands/enterprise/contracts/activate.js +30 -0
- package/dist/commands/enterprise/contracts/create.d.ts +14 -0
- package/dist/commands/enterprise/contracts/create.js +32 -0
- package/dist/commands/enterprise/contracts/issue.d.ts +18 -0
- package/dist/commands/enterprise/contracts/issue.js +34 -0
- package/dist/commands/enterprise/domains/begin.d.ts +20 -0
- package/dist/commands/enterprise/domains/begin.js +39 -0
- package/dist/commands/enterprise/domains/verify.d.ts +14 -0
- package/dist/commands/enterprise/domains/verify.js +32 -0
- package/dist/commands/enterprise/external-config/activate.d.ts +22 -0
- package/dist/commands/enterprise/external-config/activate.js +49 -0
- package/dist/commands/enterprise/external-config/set.d.ts +25 -0
- package/dist/commands/enterprise/external-config/set.js +123 -0
- package/dist/commands/enterprise/external-config/show.d.ts +12 -0
- package/dist/commands/enterprise/external-config/show.js +39 -0
- package/dist/commands/enterprise/external-config/suspend.d.ts +13 -0
- package/dist/commands/enterprise/external-config/suspend.js +41 -0
- package/dist/commands/enterprise/finance/close-snapshot.d.ts +11 -0
- package/dist/commands/enterprise/finance/close-snapshot.js +28 -0
- package/dist/commands/enterprise/finance/record-document.d.ts +18 -0
- package/dist/commands/enterprise/finance/record-document.js +35 -0
- package/dist/commands/enterprise/profile.d.ts +20 -0
- package/dist/commands/enterprise/profile.js +38 -0
- package/dist/commands/login.d.ts +13 -0
- package/dist/commands/login.js +77 -0
- package/dist/commands/machines/dedicated/index.js +3 -0
- package/dist/commands/machines/dedicated/service/apply.d.ts +23 -0
- package/dist/commands/machines/dedicated/service/apply.js +99 -0
- package/dist/commands/machines/dedicated/service/approve.d.ts +23 -0
- package/dist/commands/machines/dedicated/service/approve.js +52 -0
- package/dist/commands/machines/dedicated/service/create.d.ts +55 -0
- package/dist/commands/machines/dedicated/service/create.js +222 -0
- package/dist/commands/machines/dedicated/service/edit.d.ts +30 -0
- package/dist/commands/machines/dedicated/service/edit.js +146 -0
- package/dist/commands/machines/dedicated/service/exec.d.ts +26 -0
- package/dist/commands/machines/dedicated/service/exec.js +92 -0
- package/dist/commands/machines/dedicated/service/export.d.ts +29 -0
- package/dist/commands/machines/dedicated/service/export.js +106 -0
- package/dist/commands/machines/dedicated/service/index.d.ts +14 -0
- package/dist/commands/machines/dedicated/service/index.js +49 -0
- package/dist/commands/machines/dedicated/service/logs.d.ts +33 -0
- package/dist/commands/machines/dedicated/service/logs.js +148 -0
- package/dist/commands/machines/dedicated/service/ls.d.ts +20 -0
- package/dist/commands/machines/dedicated/service/ls.js +80 -0
- package/dist/commands/machines/dedicated/service/restart.d.ts +14 -0
- package/dist/commands/machines/dedicated/service/restart.js +29 -0
- package/dist/commands/machines/dedicated/service/rm.d.ts +20 -0
- package/dist/commands/machines/dedicated/service/rm.js +33 -0
- package/dist/commands/machines/dedicated/service/secret/index.d.ts +14 -0
- package/dist/commands/machines/dedicated/service/secret/index.js +25 -0
- package/dist/commands/machines/dedicated/service/secret/rm.d.ts +22 -0
- package/dist/commands/machines/dedicated/service/secret/rm.js +54 -0
- package/dist/commands/machines/dedicated/service/secret/set.d.ts +22 -0
- package/dist/commands/machines/dedicated/service/secret/set.js +93 -0
- package/dist/commands/machines/dedicated/service/start.d.ts +14 -0
- package/dist/commands/machines/dedicated/service/start.js +29 -0
- package/dist/commands/machines/dedicated/service/status.d.ts +21 -0
- package/dist/commands/machines/dedicated/service/status.js +85 -0
- package/dist/commands/machines/dedicated/service/stop.d.ts +20 -0
- package/dist/commands/machines/dedicated/service/stop.js +35 -0
- package/dist/commands/machines/dedicated/service/top.d.ts +22 -0
- package/dist/commands/machines/dedicated/service/top.js +120 -0
- package/dist/commands/machines/dedicated/sign-in-status.d.ts +22 -0
- package/dist/commands/machines/dedicated/sign-in-status.js +79 -0
- package/dist/commands/machines/dedicated/ssh-config.d.ts +28 -0
- package/dist/commands/machines/dedicated/ssh-config.js +66 -0
- package/dist/commands/machines/dedicated/ssh-proxy.d.ts +22 -0
- package/dist/commands/machines/dedicated/ssh-proxy.js +62 -0
- package/dist/commands/machines/dedicated/ssh.d.ts +29 -0
- package/dist/commands/machines/dedicated/ssh.js +121 -0
- package/dist/commands/native/allow-all.d.ts +14 -0
- package/dist/commands/native/allow-all.js +25 -0
- package/dist/commands/native/allow.d.ts +24 -0
- package/dist/commands/native/allow.js +45 -0
- package/dist/commands/native/deny.d.ts +24 -0
- package/dist/commands/native/deny.js +43 -0
- package/dist/commands/native/disable.d.ts +17 -0
- package/dist/commands/native/disable.js +28 -0
- package/dist/commands/native/enable.d.ts +12 -0
- package/dist/commands/native/enable.js +29 -0
- package/dist/commands/native/list-apps.d.ts +19 -0
- package/dist/commands/native/list-apps.js +30 -0
- package/dist/commands/native/restrict-to.d.ts +22 -0
- package/dist/commands/native/restrict-to.js +41 -0
- package/dist/commands/native/status.d.ts +19 -0
- package/dist/commands/native/status.js +33 -0
- package/dist/commands/native.d.ts +39 -0
- package/dist/commands/native.js +76 -0
- package/dist/commands/service/index.d.ts +14 -0
- package/dist/commands/service/index.js +31 -0
- package/dist/commands/service/logs.d.ts +18 -0
- package/dist/commands/service/logs.js +53 -0
- package/dist/commands/service/ls.d.ts +13 -0
- package/dist/commands/service/ls.js +48 -0
- package/dist/commands/service/propose.d.ts +34 -0
- package/dist/commands/service/propose.js +113 -0
- package/dist/commands/service/status.d.ts +17 -0
- package/dist/commands/service/status.js +56 -0
- package/dist/commands/spaces/auto-executor/runs.d.ts +13 -0
- package/dist/commands/spaces/auto-executor/runs.js +56 -0
- package/dist/commands/store/governance/artifacts.d.ts +25 -0
- package/dist/commands/store/governance/artifacts.js +55 -0
- package/dist/commands/store/governance/assign.d.ts +16 -0
- package/dist/commands/store/governance/assign.js +54 -0
- package/dist/commands/store/governance/create-license.d.ts +18 -0
- package/dist/commands/store/governance/create-license.js +35 -0
- package/dist/commands/store/governance/install-plan.d.ts +25 -0
- package/dist/commands/store/governance/install-plan.js +56 -0
- package/dist/commands/store/governance/license-policy.d.ts +30 -0
- package/dist/commands/store/governance/license-policy.js +69 -0
- package/dist/commands/store/governance/policy.d.ts +25 -0
- package/dist/commands/store/governance/policy.js +65 -0
- package/dist/commands/store/governance/publish-release.d.ts +17 -0
- package/dist/commands/store/governance/publish-release.js +34 -0
- package/dist/commands/tasks/deliverable/add.d.ts +15 -0
- package/dist/commands/tasks/deliverable/add.js +174 -0
- package/dist/commands/tasks/deliverable/archive.d.ts +35 -0
- package/dist/commands/tasks/deliverable/archive.js +205 -0
- package/dist/commands/tasks/labels/detach.js +3 -0
- package/dist/commands/tasks/labels/suggest.d.ts +24 -0
- package/dist/commands/tasks/labels/suggest.js +69 -0
- package/dist/commands/tasks/list.d.ts +16 -2
- package/dist/commands/tasks/list.js +100 -24
- package/dist/commands/tasks/show.d.ts +23 -0
- package/dist/commands/tasks/show.js +51 -1
- package/dist/commands/wiki/rm.d.ts +22 -1
- package/dist/commands/wiki/rm.js +52 -3
- package/dist/lib/agentic-stream.js +10 -2
- package/dist/lib/balance.d.ts +6 -1
- package/dist/lib/balance.js +15 -0
- package/dist/lib/commerce-command.d.ts +48 -0
- package/dist/lib/commerce-command.js +70 -0
- package/dist/lib/commerce.d.ts +93 -0
- package/dist/lib/commerce.js +129 -0
- package/dist/lib/commitment-product.js +1 -1
- package/dist/lib/commitments.d.ts +202 -29
- package/dist/lib/commitments.js +300 -33
- package/dist/lib/daemon-installer.d.ts +6 -5
- package/dist/lib/daemon-installer.js +4 -17
- package/dist/lib/dedicated-lease-command.js +10 -0
- package/dist/lib/dedicated-machines.d.ts +37 -0
- package/dist/lib/dedicated-machines.js +47 -0
- package/dist/lib/dedicated-service-command.d.ts +60 -0
- package/dist/lib/dedicated-service-command.js +182 -0
- package/dist/lib/dedicated-service.d.ts +342 -0
- package/dist/lib/dedicated-service.js +741 -0
- package/dist/lib/dedicated-ssh.d.ts +136 -0
- package/dist/lib/dedicated-ssh.js +387 -0
- package/dist/lib/delegated-cli.js +51 -13
- package/dist/lib/enterprise-commerce.d.ts +67 -0
- package/dist/lib/enterprise-commerce.js +112 -0
- package/dist/lib/enterprise-external-configuration.d.ts +60 -0
- package/dist/lib/enterprise-external-configuration.js +58 -0
- package/dist/lib/first-party-harness.js +17 -3
- package/dist/lib/governed-store.d.ts +110 -0
- package/dist/lib/governed-store.js +79 -0
- package/dist/lib/guest-service-command.d.ts +16 -0
- package/dist/lib/guest-service-command.js +32 -0
- package/dist/lib/guest-service.d.ts +67 -0
- package/dist/lib/guest-service.js +112 -0
- package/dist/lib/prompt.d.ts +1 -0
- package/dist/lib/prompt.js +1 -0
- package/dist/lib/task-asset-upload.d.ts +20 -0
- package/dist/lib/task-asset-upload.js +30 -8
- package/dist/lib/task-extras.d.ts +23 -0
- package/dist/lib/task-extras.js +6 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonScopes.d.ts +9 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/daemonScopes.js +10 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.d.ts +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.js +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.d.ts +2 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.js +8 -5
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/messages.d.ts +16 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/messages.js +21 -4
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releaseManifest.d.ts +38 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releaseManifest.js +66 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/spawnEnv.d.ts +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/spawnEnv.js +24 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonScopes.d.ts +9 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/daemonScopes.js +10 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.d.ts +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.js +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.d.ts +2 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.js +2 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/messages.d.ts +16 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/messages.js +20 -4
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releaseManifest.d.ts +38 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releaseManifest.js +64 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/spawnEnv.d.ts +1 -1
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/spawnEnv.js +24 -2
- package/dist/node_modules/@skrr-ai/auth-core/package.json +1 -1
- package/dist/node_modules/@skrr-ai/data-provider/index.js +5060 -4827
- package/oclif.manifest.json +35194 -29157
- package/package.json +43 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const dedicated_service_command_1 = require("../../../../lib/dedicated-service-command");
|
|
5
|
+
const dedicated_service_1 = require("../../../../lib/dedicated-service");
|
|
6
|
+
/**
|
|
7
|
+
* `skrr machines dedicated service logs` — tail the service's log, or follow it.
|
|
8
|
+
*
|
|
9
|
+
* The daemon rotates a bounded `current` log per service; `logs` replays a
|
|
10
|
+
* byte tail of it and `-f` keeps the stream open on live
|
|
11
|
+
* `dedicated:service:log` frames. Ctrl-C ends the follow cleanly — the
|
|
12
|
+
* stream is closed with `logs:stop`, the service keeps running.
|
|
13
|
+
*
|
|
14
|
+
* While a follow is open, an agent proposal arriving on the same channel is
|
|
15
|
+
* surfaced on stderr: the owner watching logs is exactly the owner who can
|
|
16
|
+
* approve it.
|
|
17
|
+
*/
|
|
18
|
+
class DedicatedServiceLogs extends dedicated_service_command_1.DedicatedServiceCommand {
|
|
19
|
+
static summary = 'Print a service’s log; -f follows live output';
|
|
20
|
+
static examples = [
|
|
21
|
+
'<%= config.bin %> machines dedicated service logs <lease-id> <name>',
|
|
22
|
+
'<%= config.bin %> machines dedicated service logs <lease-id> <name> -f',
|
|
23
|
+
'<%= config.bin %> machines dedicated service logs <lease-id> <name> --tail 65536',
|
|
24
|
+
];
|
|
25
|
+
static args = {
|
|
26
|
+
lease: core_1.Args.string({
|
|
27
|
+
description: dedicated_service_command_1.SERVICE_LEASE_ARG_DESCRIPTION,
|
|
28
|
+
required: true,
|
|
29
|
+
ignoreStdin: true,
|
|
30
|
+
}),
|
|
31
|
+
name: core_1.Args.string({ description: 'Service name', required: true, ignoreStdin: true }),
|
|
32
|
+
};
|
|
33
|
+
static flags = {
|
|
34
|
+
follow: core_1.Flags.boolean({
|
|
35
|
+
description: 'Keep the stream open on live log frames (Ctrl-C ends the follow, not the service)',
|
|
36
|
+
char: 'f',
|
|
37
|
+
}),
|
|
38
|
+
tail: core_1.Flags.integer({
|
|
39
|
+
description: 'Bytes from the end of the stored log to print first (daemon rotates at 8 MiB)',
|
|
40
|
+
min: 0,
|
|
41
|
+
}),
|
|
42
|
+
json: core_1.Flags.boolean({ description: 'Emit log frames as JSON objects' }),
|
|
43
|
+
};
|
|
44
|
+
async run() {
|
|
45
|
+
this.requireAuth();
|
|
46
|
+
const { args, flags } = await this.parse(DedicatedServiceLogs);
|
|
47
|
+
const leaseId = await this.resolveLeaseArg(args.lease);
|
|
48
|
+
if (flags.json) {
|
|
49
|
+
// --json emits one frame per line — a follow a program can consume.
|
|
50
|
+
// Proposals surface as frames too rather than stderr prose.
|
|
51
|
+
const code = await this.followJson(leaseId, args.name, flags);
|
|
52
|
+
if (code !== 0)
|
|
53
|
+
this.exit(code);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
let code;
|
|
57
|
+
try {
|
|
58
|
+
code = await (0, dedicated_service_1.streamServiceLogs)({
|
|
59
|
+
baseURL: this.cliConfig.baseURL,
|
|
60
|
+
token: this.resolvedCredential.token,
|
|
61
|
+
leaseId,
|
|
62
|
+
name: args.name,
|
|
63
|
+
follow: flags.follow,
|
|
64
|
+
tailBytes: flags.tail,
|
|
65
|
+
output: process.stdout,
|
|
66
|
+
errorOutput: process.stderr,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (err) {
|
|
70
|
+
this.reportServiceError(err);
|
|
71
|
+
}
|
|
72
|
+
if (code !== 0)
|
|
73
|
+
this.exit(code);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The machine-readable follow: each log frame is one JSON line. An ack's
|
|
77
|
+
* refusal surfaces through the same channel.call error path as every other
|
|
78
|
+
* verb (a `--json` caller reads the CLI error envelope).
|
|
79
|
+
*/
|
|
80
|
+
async followJson(leaseId, name, flags) {
|
|
81
|
+
const channel = new dedicated_service_1.DedicatedServiceChannel({
|
|
82
|
+
baseURL: this.cliConfig.baseURL,
|
|
83
|
+
token: this.resolvedCredential.token,
|
|
84
|
+
});
|
|
85
|
+
return new Promise((resolve, reject) => {
|
|
86
|
+
let streamId = null;
|
|
87
|
+
let finished = false;
|
|
88
|
+
let closedByServer = false;
|
|
89
|
+
const onSigint = () => finish(0);
|
|
90
|
+
const finish = (code) => {
|
|
91
|
+
if (finished)
|
|
92
|
+
return;
|
|
93
|
+
finished = true;
|
|
94
|
+
process.off('SIGINT', onSigint);
|
|
95
|
+
if (streamId && flags.follow && !closedByServer) {
|
|
96
|
+
channel.send(dedicated_service_1.DEDICATED_SERVICE_EVENTS.logsStop, { leaseId, name, streamId });
|
|
97
|
+
}
|
|
98
|
+
channel.close();
|
|
99
|
+
resolve(code);
|
|
100
|
+
};
|
|
101
|
+
channel.setOnDead(() => finish(1));
|
|
102
|
+
channel
|
|
103
|
+
.open()
|
|
104
|
+
.then(async () => {
|
|
105
|
+
process.on('SIGINT', onSigint);
|
|
106
|
+
channel.on(dedicated_service_1.DEDICATED_SERVICE_EVENTS.log, (frame) => {
|
|
107
|
+
if (streamId && frame.streamId && frame.streamId !== streamId)
|
|
108
|
+
return;
|
|
109
|
+
if (frame.name && frame.name !== name)
|
|
110
|
+
return;
|
|
111
|
+
this.log(JSON.stringify({ type: 'log', ...frame }));
|
|
112
|
+
});
|
|
113
|
+
channel.on(dedicated_service_1.DEDICATED_SERVICE_EVENTS.logClosed, (frame) => {
|
|
114
|
+
if (streamId && frame.streamId && frame.streamId !== streamId)
|
|
115
|
+
return;
|
|
116
|
+
closedByServer = true;
|
|
117
|
+
this.log(JSON.stringify({ type: 'closed', ...frame }));
|
|
118
|
+
finish(0);
|
|
119
|
+
});
|
|
120
|
+
channel.on(dedicated_service_1.DEDICATED_SERVICE_EVENTS.proposed, (frame) => {
|
|
121
|
+
this.log(JSON.stringify({ type: 'proposed', ...frame }));
|
|
122
|
+
});
|
|
123
|
+
const { result } = await channel.call('logs', {
|
|
124
|
+
leaseId,
|
|
125
|
+
name,
|
|
126
|
+
follow: flags.follow,
|
|
127
|
+
...(flags.tail !== undefined ? { tailBytes: flags.tail } : {}),
|
|
128
|
+
...this.scopeFrom(flags),
|
|
129
|
+
});
|
|
130
|
+
streamId = typeof result?.streamId === 'string' ? result.streamId : null;
|
|
131
|
+
if (typeof result?.data === 'string' && result.data.length > 0) {
|
|
132
|
+
this.log(JSON.stringify({ type: 'tail', name, data: result.data }));
|
|
133
|
+
}
|
|
134
|
+
if (!flags.follow)
|
|
135
|
+
finish(0);
|
|
136
|
+
})
|
|
137
|
+
.catch((err) => {
|
|
138
|
+
// Reject BEFORE closing — disconnect() fires onDead → finish(1),
|
|
139
|
+
// which would otherwise win the settlement race and mask the refusal.
|
|
140
|
+
finished = true;
|
|
141
|
+
process.off('SIGINT', onSigint);
|
|
142
|
+
reject(err);
|
|
143
|
+
channel.close();
|
|
144
|
+
});
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
exports.default = DedicatedServiceLogs;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DedicatedServiceCommand } from '../../../../lib/dedicated-service-command';
|
|
2
|
+
/**
|
|
3
|
+
* `skrr machines dedicated service ls` — what the machine is keeping alive,
|
|
4
|
+
* and what agents have asked it to keep alive.
|
|
5
|
+
*
|
|
6
|
+
* Agent proposals are printed as their own section rather than as ordinary
|
|
7
|
+
* rows: a proposed service runs nothing until the owner approves it, and a
|
|
8
|
+
* table that listed it beside running work would lie by adjacency.
|
|
9
|
+
*/
|
|
10
|
+
export default class DedicatedServiceLs extends DedicatedServiceCommand {
|
|
11
|
+
static summary: string;
|
|
12
|
+
static examples: string[];
|
|
13
|
+
static args: {
|
|
14
|
+
lease: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
15
|
+
};
|
|
16
|
+
static flags: {
|
|
17
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
};
|
|
19
|
+
run(): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const dedicated_service_command_1 = require("../../../../lib/dedicated-service-command");
|
|
5
|
+
const format_1 = require("../../../../lib/format");
|
|
6
|
+
/**
|
|
7
|
+
* `skrr machines dedicated service ls` — what the machine is keeping alive,
|
|
8
|
+
* and what agents have asked it to keep alive.
|
|
9
|
+
*
|
|
10
|
+
* Agent proposals are printed as their own section rather than as ordinary
|
|
11
|
+
* rows: a proposed service runs nothing until the owner approves it, and a
|
|
12
|
+
* table that listed it beside running work would lie by adjacency.
|
|
13
|
+
*/
|
|
14
|
+
class DedicatedServiceLs extends dedicated_service_command_1.DedicatedServiceCommand {
|
|
15
|
+
static summary = 'List declared services and pending agent proposals';
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> machines dedicated service ls <lease-id>',
|
|
18
|
+
'<%= config.bin %> machines dedicated service ls <lease-id> --json',
|
|
19
|
+
];
|
|
20
|
+
static args = {
|
|
21
|
+
lease: core_1.Args.string({
|
|
22
|
+
description: dedicated_service_command_1.SERVICE_LEASE_ARG_DESCRIPTION,
|
|
23
|
+
required: true,
|
|
24
|
+
ignoreStdin: true,
|
|
25
|
+
}),
|
|
26
|
+
};
|
|
27
|
+
static flags = {
|
|
28
|
+
json: core_1.Flags.boolean({ description: 'Output as JSON' }),
|
|
29
|
+
};
|
|
30
|
+
async run() {
|
|
31
|
+
this.requireAuth();
|
|
32
|
+
const { args, flags } = await this.parse(DedicatedServiceLs);
|
|
33
|
+
const leaseId = await this.resolveLeaseArg(args.lease);
|
|
34
|
+
const result = await this.callService('list', {
|
|
35
|
+
leaseId,
|
|
36
|
+
...this.scopeFrom(flags),
|
|
37
|
+
});
|
|
38
|
+
this.closeServiceChannel();
|
|
39
|
+
if (flags.json) {
|
|
40
|
+
this.log(JSON.stringify(result ?? { services: [] }, null, 2));
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const services = result?.services ?? [];
|
|
44
|
+
const proposals = result?.proposals ?? [];
|
|
45
|
+
if (services.length === 0 && proposals.length === 0) {
|
|
46
|
+
this.log(`No declared services on ${leaseId}.`);
|
|
47
|
+
this.log(`Declare one with \`${this.config.bin} machines dedicated service create ${leaseId} --name <name> -- <command>\`.`);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (services.length > 0) {
|
|
51
|
+
(0, format_1.renderTable)(services.map((svc) => ({
|
|
52
|
+
name: (0, format_1.formatCell)(svc.name ?? svc.spec?.name),
|
|
53
|
+
status: (0, format_1.formatCell)(svc.status ?? 'unknown'),
|
|
54
|
+
restart: (0, format_1.formatCell)(svc.restart ?? svc.spec?.restart),
|
|
55
|
+
createdBy: (0, format_1.formatCell)(svc.createdBy ?? svc.spec?.createdBy),
|
|
56
|
+
})), [
|
|
57
|
+
{ key: 'name', header: 'NAME', verbatim: true },
|
|
58
|
+
{ key: 'status', header: 'STATUS' },
|
|
59
|
+
{ key: 'restart', header: 'RESTART' },
|
|
60
|
+
{ key: 'createdBy', header: 'CREATED BY' },
|
|
61
|
+
], (line) => this.log(line));
|
|
62
|
+
}
|
|
63
|
+
if (proposals.length > 0) {
|
|
64
|
+
if (services.length > 0)
|
|
65
|
+
this.log('');
|
|
66
|
+
this.log('Pending proposals — nothing runs until you approve:');
|
|
67
|
+
(0, format_1.renderTable)(proposals.map((p) => ({
|
|
68
|
+
name: (0, format_1.formatCell)(p.name ?? p.spec?.name),
|
|
69
|
+
proposedBy: (0, format_1.formatCell)(p.createdBy),
|
|
70
|
+
command: (0, format_1.formatCell)(Array.isArray(p.spec?.command) ? p.spec.command.join(' ') : (p.spec?.shell ?? ''), '-'),
|
|
71
|
+
})), [
|
|
72
|
+
{ key: 'name', header: 'NAME', verbatim: true },
|
|
73
|
+
{ key: 'proposedBy', header: 'PROPOSED BY' },
|
|
74
|
+
{ key: 'command', header: 'COMMAND', maxWidth: 60 },
|
|
75
|
+
], (line) => this.log(line));
|
|
76
|
+
this.log(`Approve with \`${this.config.bin} machines dedicated service approve ${leaseId} <name>\` (add --reject to refuse).`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.default = DedicatedServiceLs;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DedicatedServiceCommand } from '../../../../lib/dedicated-service-command';
|
|
2
|
+
/** `skrr machines dedicated service restart` — bounce it now; also re-arms a `failed` service. */
|
|
3
|
+
export default class DedicatedServiceRestart extends DedicatedServiceCommand {
|
|
4
|
+
static summary: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static args: {
|
|
7
|
+
lease: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
8
|
+
name: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
9
|
+
};
|
|
10
|
+
static flags: {
|
|
11
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const dedicated_service_command_1 = require("../../../../lib/dedicated-service-command");
|
|
5
|
+
/** `skrr machines dedicated service restart` — bounce it now; also re-arms a `failed` service. */
|
|
6
|
+
class DedicatedServiceRestart extends dedicated_service_command_1.DedicatedServiceCommand {
|
|
7
|
+
static summary = 'Restart a service now (re-arms a failed one)';
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> machines dedicated service restart <lease-id> <name>',
|
|
10
|
+
];
|
|
11
|
+
static args = {
|
|
12
|
+
lease: core_1.Args.string({
|
|
13
|
+
description: dedicated_service_command_1.SERVICE_LEASE_ARG_DESCRIPTION,
|
|
14
|
+
required: true,
|
|
15
|
+
ignoreStdin: true,
|
|
16
|
+
}),
|
|
17
|
+
name: core_1.Args.string({ description: 'Service name', required: true, ignoreStdin: true }),
|
|
18
|
+
};
|
|
19
|
+
static flags = {
|
|
20
|
+
json: core_1.Flags.boolean({ description: 'Output the result as JSON' }),
|
|
21
|
+
};
|
|
22
|
+
async run() {
|
|
23
|
+
this.requireAuth();
|
|
24
|
+
const { args, flags } = await this.parse(DedicatedServiceRestart);
|
|
25
|
+
const leaseId = await this.resolveLeaseArg(args.lease);
|
|
26
|
+
await this.runServiceAction(leaseId, args.name, 'restart', flags);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = DedicatedServiceRestart;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DedicatedServiceCommand } from '../../../../lib/dedicated-service-command';
|
|
2
|
+
/**
|
|
3
|
+
* `skrr machines dedicated service rm` — delete the declaration.
|
|
4
|
+
*
|
|
5
|
+
* The only way a declared service does not come back short of destroying the
|
|
6
|
+
* lease: the spec file is dropped, the scope is killed, and the reconciler
|
|
7
|
+
* forgets it.
|
|
8
|
+
*/
|
|
9
|
+
export default class DedicatedServiceRm extends DedicatedServiceCommand {
|
|
10
|
+
static summary: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
static args: {
|
|
13
|
+
lease: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
14
|
+
name: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
15
|
+
};
|
|
16
|
+
static flags: {
|
|
17
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
};
|
|
19
|
+
run(): Promise<void>;
|
|
20
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const dedicated_service_command_1 = require("../../../../lib/dedicated-service-command");
|
|
5
|
+
/**
|
|
6
|
+
* `skrr machines dedicated service rm` — delete the declaration.
|
|
7
|
+
*
|
|
8
|
+
* The only way a declared service does not come back short of destroying the
|
|
9
|
+
* lease: the spec file is dropped, the scope is killed, and the reconciler
|
|
10
|
+
* forgets it.
|
|
11
|
+
*/
|
|
12
|
+
class DedicatedServiceRm extends dedicated_service_command_1.DedicatedServiceCommand {
|
|
13
|
+
static summary = 'Remove a service declaration';
|
|
14
|
+
static examples = ['<%= config.bin %> machines dedicated service rm <lease-id> <name>'];
|
|
15
|
+
static args = {
|
|
16
|
+
lease: core_1.Args.string({
|
|
17
|
+
description: dedicated_service_command_1.SERVICE_LEASE_ARG_DESCRIPTION,
|
|
18
|
+
required: true,
|
|
19
|
+
ignoreStdin: true,
|
|
20
|
+
}),
|
|
21
|
+
name: core_1.Args.string({ description: 'Service name', required: true, ignoreStdin: true }),
|
|
22
|
+
};
|
|
23
|
+
static flags = {
|
|
24
|
+
json: core_1.Flags.boolean({ description: 'Output the result as JSON' }),
|
|
25
|
+
};
|
|
26
|
+
async run() {
|
|
27
|
+
this.requireAuth();
|
|
28
|
+
const { args, flags } = await this.parse(DedicatedServiceRm);
|
|
29
|
+
const leaseId = await this.resolveLeaseArg(args.lease);
|
|
30
|
+
await this.runServiceAction(leaseId, args.name, 'remove', flags);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.default = DedicatedServiceRm;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Command } from '@oclif/core';
|
|
2
|
+
/**
|
|
3
|
+
* `skrr machines dedicated service secret` — values a spec references as
|
|
4
|
+
* `secret://<name>` (phase 2).
|
|
5
|
+
*
|
|
6
|
+
* The daemon resolves the reference at spawn; the spec and every status
|
|
7
|
+
* surface carry only the name. Mutation is owner-channel only and names —
|
|
8
|
+
* never values — reach the audit log.
|
|
9
|
+
*/
|
|
10
|
+
export default class DedicatedServiceSecret extends Command {
|
|
11
|
+
static description: string;
|
|
12
|
+
static examples: string[];
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
/**
|
|
5
|
+
* `skrr machines dedicated service secret` — values a spec references as
|
|
6
|
+
* `secret://<name>` (phase 2).
|
|
7
|
+
*
|
|
8
|
+
* The daemon resolves the reference at spawn; the spec and every status
|
|
9
|
+
* surface carry only the name. Mutation is owner-channel only and names —
|
|
10
|
+
* never values — reach the audit log.
|
|
11
|
+
*/
|
|
12
|
+
class DedicatedServiceSecret extends core_1.Command {
|
|
13
|
+
static description = 'Secrets a service spec can reference as secret://<name> — daemon-held, never in the spec (phase 2)';
|
|
14
|
+
static examples = [
|
|
15
|
+
'<%= config.bin %> machines dedicated service secret set <lease-id> <name> < secret.txt',
|
|
16
|
+
'<%= config.bin %> machines dedicated service secret set <lease-id> <name> --from-file .env.production',
|
|
17
|
+
'<%= config.bin %> machines dedicated service secret rm <lease-id> <name>',
|
|
18
|
+
];
|
|
19
|
+
async run() {
|
|
20
|
+
this.log('skrr machines dedicated service secret commands:');
|
|
21
|
+
this.log(' skrr machines dedicated service secret set store a secret a spec can reference');
|
|
22
|
+
this.log(' skrr machines dedicated service secret rm remove one (--force if referenced)');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.default = DedicatedServiceSecret;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DedicatedServiceCommand } from '../../../../../lib/dedicated-service-command';
|
|
2
|
+
/**
|
|
3
|
+
* `skrr machines dedicated service secret rm` — drop a stored secret.
|
|
4
|
+
*
|
|
5
|
+
* Removing a name a spec still references is refused unless forced — the
|
|
6
|
+
* daemon answers with the referencing services, and `--force` is the caller
|
|
7
|
+
* saying they know. Rotation stays manual on purpose: `secret set` +
|
|
8
|
+
* `service restart`, never a silent restart channel.
|
|
9
|
+
*/
|
|
10
|
+
export default class DedicatedServiceSecretRm extends DedicatedServiceCommand {
|
|
11
|
+
static summary: string;
|
|
12
|
+
static examples: string[];
|
|
13
|
+
static args: {
|
|
14
|
+
lease: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
15
|
+
name: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
16
|
+
};
|
|
17
|
+
static flags: {
|
|
18
|
+
force: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
};
|
|
21
|
+
run(): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const dedicated_service_command_1 = require("../../../../../lib/dedicated-service-command");
|
|
5
|
+
const dedicated_service_1 = require("../../../../../lib/dedicated-service");
|
|
6
|
+
/**
|
|
7
|
+
* `skrr machines dedicated service secret rm` — drop a stored secret.
|
|
8
|
+
*
|
|
9
|
+
* Removing a name a spec still references is refused unless forced — the
|
|
10
|
+
* daemon answers with the referencing services, and `--force` is the caller
|
|
11
|
+
* saying they know. Rotation stays manual on purpose: `secret set` +
|
|
12
|
+
* `service restart`, never a silent restart channel.
|
|
13
|
+
*/
|
|
14
|
+
class DedicatedServiceSecretRm extends dedicated_service_command_1.DedicatedServiceCommand {
|
|
15
|
+
static summary = 'Remove a stored secret (--force when services still reference it)';
|
|
16
|
+
static examples = [
|
|
17
|
+
'<%= config.bin %> machines dedicated service secret rm <lease-id> <name>',
|
|
18
|
+
'<%= config.bin %> machines dedicated service secret rm <lease-id> <name> --force',
|
|
19
|
+
];
|
|
20
|
+
static args = {
|
|
21
|
+
lease: core_1.Args.string({
|
|
22
|
+
description: dedicated_service_command_1.SERVICE_LEASE_ARG_DESCRIPTION,
|
|
23
|
+
required: true,
|
|
24
|
+
ignoreStdin: true,
|
|
25
|
+
}),
|
|
26
|
+
name: core_1.Args.string({ description: 'Secret name', required: true, ignoreStdin: true }),
|
|
27
|
+
};
|
|
28
|
+
static flags = {
|
|
29
|
+
force: core_1.Flags.boolean({ description: 'Remove even when services still reference the name' }),
|
|
30
|
+
json: core_1.Flags.boolean({ description: 'Output the result as JSON' }),
|
|
31
|
+
};
|
|
32
|
+
async run() {
|
|
33
|
+
this.requireAuth();
|
|
34
|
+
const { args, flags } = await this.parse(DedicatedServiceSecretRm);
|
|
35
|
+
const leaseId = await this.resolveLeaseArg(args.lease);
|
|
36
|
+
if (!dedicated_service_1.SERVICE_SECRET_NAME_PATTERN.test(args.name)) {
|
|
37
|
+
this.error(`Invalid secret name ${args.name} — must start with a letter or _ and use only letters, digits, _, ., - (max 128).`, { exit: 2 });
|
|
38
|
+
}
|
|
39
|
+
const result = await this.callService('secret', {
|
|
40
|
+
leaseId,
|
|
41
|
+
op: 'rm',
|
|
42
|
+
name: args.name,
|
|
43
|
+
...(flags.force ? { force: true } : {}),
|
|
44
|
+
...this.scopeFrom(flags),
|
|
45
|
+
});
|
|
46
|
+
this.closeServiceChannel();
|
|
47
|
+
if (flags.json) {
|
|
48
|
+
this.log(JSON.stringify(result ?? { name: args.name, op: 'rm' }, null, 2));
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
this.log(`Secret ${args.name} removed.`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.default = DedicatedServiceSecretRm;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { DedicatedServiceCommand } from '../../../../../lib/dedicated-service-command';
|
|
2
|
+
/**
|
|
3
|
+
* `skrr machines dedicated service secret set` — store a value the daemon
|
|
4
|
+
* resolves at spawn when a spec's env carries `secret://<name>` (phase 2).
|
|
5
|
+
*
|
|
6
|
+
* The value travels the admitted channel once; after that only the name is
|
|
7
|
+
* ever spoken — in the spec, in status output, in the audit entry.
|
|
8
|
+
*/
|
|
9
|
+
export default class DedicatedServiceSecretSet extends DedicatedServiceCommand {
|
|
10
|
+
static summary: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
static args: {
|
|
13
|
+
lease: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
14
|
+
name: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
15
|
+
};
|
|
16
|
+
static flags: {
|
|
17
|
+
value: import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
18
|
+
'from-file': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces").CustomOptions>;
|
|
19
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
20
|
+
};
|
|
21
|
+
run(): Promise<void>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_fs_1 = require("node:fs");
|
|
4
|
+
const core_1 = require("@oclif/core");
|
|
5
|
+
const dedicated_service_command_1 = require("../../../../../lib/dedicated-service-command");
|
|
6
|
+
const dedicated_service_1 = require("../../../../../lib/dedicated-service");
|
|
7
|
+
/** Read the secret's bytes: --value, --from-file, or piped stdin. */
|
|
8
|
+
async function readSecretValue(command, flags) {
|
|
9
|
+
if (flags.value !== undefined && flags['from-file']) {
|
|
10
|
+
command.error('Give the secret once: --value or --from-file, not both.', { exit: 2 });
|
|
11
|
+
}
|
|
12
|
+
if (flags['from-file']) {
|
|
13
|
+
try {
|
|
14
|
+
return (0, node_fs_1.readFileSync)(flags['from-file'], 'utf8');
|
|
15
|
+
}
|
|
16
|
+
catch (err) {
|
|
17
|
+
command.error(`Cannot read ${flags['from-file']}: ${err instanceof Error ? err.message : err}`, { exit: 2 });
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (flags.value !== undefined)
|
|
21
|
+
return flags.value;
|
|
22
|
+
if (process.stdin.isTTY) {
|
|
23
|
+
command.error('No secret value given. Pipe it on stdin, or pass --value / --from-file.', {
|
|
24
|
+
exit: 2,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const chunks = [];
|
|
28
|
+
for await (const chunk of process.stdin) {
|
|
29
|
+
chunks.push(typeof chunk === 'string' ? Buffer.from(chunk) : chunk);
|
|
30
|
+
}
|
|
31
|
+
const value = Buffer.concat(chunks).toString('utf8');
|
|
32
|
+
if (!value) {
|
|
33
|
+
command.error('The secret value on stdin was empty.', { exit: 2 });
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* `skrr machines dedicated service secret set` — store a value the daemon
|
|
39
|
+
* resolves at spawn when a spec's env carries `secret://<name>` (phase 2).
|
|
40
|
+
*
|
|
41
|
+
* The value travels the admitted channel once; after that only the name is
|
|
42
|
+
* ever spoken — in the spec, in status output, in the audit entry.
|
|
43
|
+
*/
|
|
44
|
+
class DedicatedServiceSecretSet extends dedicated_service_command_1.DedicatedServiceCommand {
|
|
45
|
+
static summary = 'Store a secret a service spec can reference as secret://<name>';
|
|
46
|
+
static examples = [
|
|
47
|
+
'echo "$TOKEN" | <%= config.bin %> machines dedicated service secret set <lease-id> registry-token',
|
|
48
|
+
'<%= config.bin %> machines dedicated service secret set <lease-id> app-env --from-file .env.production',
|
|
49
|
+
];
|
|
50
|
+
static args = {
|
|
51
|
+
lease: core_1.Args.string({
|
|
52
|
+
description: dedicated_service_command_1.SERVICE_LEASE_ARG_DESCRIPTION,
|
|
53
|
+
required: true,
|
|
54
|
+
ignoreStdin: true,
|
|
55
|
+
}),
|
|
56
|
+
name: core_1.Args.string({
|
|
57
|
+
description: 'Secret name the spec references',
|
|
58
|
+
required: true,
|
|
59
|
+
ignoreStdin: true,
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
static flags = {
|
|
63
|
+
value: core_1.Flags.string({
|
|
64
|
+
description: 'The secret value (prefer stdin — flags show in shell history)',
|
|
65
|
+
}),
|
|
66
|
+
'from-file': core_1.Flags.string({ description: 'Read the secret value from a file' }),
|
|
67
|
+
json: core_1.Flags.boolean({ description: 'Output the result as JSON' }),
|
|
68
|
+
};
|
|
69
|
+
async run() {
|
|
70
|
+
this.requireAuth();
|
|
71
|
+
const { args, flags } = await this.parse(DedicatedServiceSecretSet);
|
|
72
|
+
const leaseId = await this.resolveLeaseArg(args.lease);
|
|
73
|
+
if (!dedicated_service_1.SERVICE_SECRET_NAME_PATTERN.test(args.name)) {
|
|
74
|
+
this.error(`Invalid secret name ${args.name} — must start with a letter or _ and use only letters, digits, _, ., - (max 128).`, { exit: 2 });
|
|
75
|
+
}
|
|
76
|
+
const value = await readSecretValue(this, flags);
|
|
77
|
+
const result = await this.callService('secret', {
|
|
78
|
+
leaseId,
|
|
79
|
+
op: 'set',
|
|
80
|
+
name: args.name,
|
|
81
|
+
value,
|
|
82
|
+
...this.scopeFrom(flags),
|
|
83
|
+
});
|
|
84
|
+
this.closeServiceChannel();
|
|
85
|
+
if (flags.json) {
|
|
86
|
+
this.log(JSON.stringify(result ?? { name: args.name, op: 'set' }, null, 2));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
this.log(`Secret ${args.name} stored. Reference it in a spec as "secret://${args.name}" in an env value, ` +
|
|
90
|
+
'then `service restart` the referencing services.');
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.default = DedicatedServiceSecretSet;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DedicatedServiceCommand } from '../../../../lib/dedicated-service-command';
|
|
2
|
+
/** `skrr machines dedicated service start` — desired state back to running. */
|
|
3
|
+
export default class DedicatedServiceStart extends DedicatedServiceCommand {
|
|
4
|
+
static summary: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static args: {
|
|
7
|
+
lease: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
8
|
+
name: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
9
|
+
};
|
|
10
|
+
static flags: {
|
|
11
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
12
|
+
};
|
|
13
|
+
run(): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const core_1 = require("@oclif/core");
|
|
4
|
+
const dedicated_service_command_1 = require("../../../../lib/dedicated-service-command");
|
|
5
|
+
/** `skrr machines dedicated service start` — desired state back to running. */
|
|
6
|
+
class DedicatedServiceStart extends dedicated_service_command_1.DedicatedServiceCommand {
|
|
7
|
+
static summary = 'Set a service’s desired state to running';
|
|
8
|
+
static examples = [
|
|
9
|
+
'<%= config.bin %> machines dedicated service start <lease-id> <name>',
|
|
10
|
+
];
|
|
11
|
+
static args = {
|
|
12
|
+
lease: core_1.Args.string({
|
|
13
|
+
description: dedicated_service_command_1.SERVICE_LEASE_ARG_DESCRIPTION,
|
|
14
|
+
required: true,
|
|
15
|
+
ignoreStdin: true,
|
|
16
|
+
}),
|
|
17
|
+
name: core_1.Args.string({ description: 'Service name', required: true, ignoreStdin: true }),
|
|
18
|
+
};
|
|
19
|
+
static flags = {
|
|
20
|
+
json: core_1.Flags.boolean({ description: 'Output the result as JSON' }),
|
|
21
|
+
};
|
|
22
|
+
async run() {
|
|
23
|
+
this.requireAuth();
|
|
24
|
+
const { args, flags } = await this.parse(DedicatedServiceStart);
|
|
25
|
+
const leaseId = await this.resolveLeaseArg(args.lease);
|
|
26
|
+
await this.runServiceAction(leaseId, args.name, 'start', flags);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.default = DedicatedServiceStart;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DedicatedServiceCommand } from '../../../../lib/dedicated-service-command';
|
|
2
|
+
/**
|
|
3
|
+
* `skrr machines dedicated service status` — one service, as the machine
|
|
4
|
+
* computes it right now: the spec it reconciles, the state it derived, and
|
|
5
|
+
* the exits it has seen.
|
|
6
|
+
*
|
|
7
|
+
* Status is computed from `spec + live children`, never stored — so what
|
|
8
|
+
* prints here is what the reconciler believes, not a record that can drift.
|
|
9
|
+
*/
|
|
10
|
+
export default class DedicatedServiceStatus extends DedicatedServiceCommand {
|
|
11
|
+
static summary: string;
|
|
12
|
+
static examples: string[];
|
|
13
|
+
static args: {
|
|
14
|
+
lease: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
15
|
+
name: import("@oclif/core/lib/interfaces").Arg<string, Record<string, unknown>>;
|
|
16
|
+
};
|
|
17
|
+
static flags: {
|
|
18
|
+
json: import("@oclif/core/lib/interfaces").BooleanFlag<boolean>;
|
|
19
|
+
};
|
|
20
|
+
run(): Promise<void>;
|
|
21
|
+
}
|