@skrr-ai/cli 0.1.142 → 0.1.144
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 +8 -0
- package/dist/base-command.d.ts +4 -2
- package/dist/base-command.js +46 -13
- package/dist/commands/agenda/trigger/create.js +4 -2
- package/dist/commands/agenda/trigger/list.js +7 -7
- package/dist/commands/agent/message/approve.d.ts +17 -0
- package/dist/commands/agent/message/approve.js +72 -0
- package/dist/commands/agent/message/decline.d.ts +17 -0
- package/dist/commands/agent/message/decline.js +72 -0
- package/dist/commands/agent/message/pending.d.ts +18 -0
- package/dist/commands/agent/message/pending.js +79 -0
- package/dist/commands/agents/always-on/disable.js +9 -1
- package/dist/commands/agents/always-on/enable.js +9 -1
- package/dist/commands/agents/always-on/status.js +14 -1
- package/dist/commands/agents/create.js +10 -1
- package/dist/commands/agents/delete.d.ts +51 -0
- package/dist/commands/agents/delete.js +163 -2
- package/dist/commands/agents/intuitions/list.js +1 -1
- package/dist/commands/agents/plan-day.d.ts +39 -7
- package/dist/commands/agents/plan-day.js +254 -65
- package/dist/commands/agents/proactive-audit.d.ts +22 -0
- package/dist/commands/agents/proactive-audit.js +86 -0
- package/dist/commands/agents/schedule-overview.d.ts +7 -0
- package/dist/commands/agents/schedule-overview.js +43 -5
- package/dist/commands/agents/schedule-trace.js +30 -19
- package/dist/commands/agents/spawn.d.ts +51 -0
- package/dist/commands/agents/spawn.js +212 -9
- package/dist/commands/agents/todos/cancel.js +3 -0
- package/dist/commands/agents/todos/edit.js +1 -1
- package/dist/commands/agents/todos/list.d.ts +5 -0
- package/dist/commands/agents/todos/list.js +19 -5
- package/dist/commands/agents/triggers/create.js +1 -1
- package/dist/commands/agents/triggers/policy.js +7 -0
- package/dist/commands/agents/triggers/update.js +1 -1
- package/dist/commands/commitments/create.js +13 -3
- package/dist/commands/commitments/preflight.js +31 -5
- package/dist/commands/daemon/index.js +1 -0
- package/dist/commands/daemon/logs.d.ts +8 -1
- package/dist/commands/daemon/logs.js +32 -22
- package/dist/commands/daemon/profile.d.ts +15 -0
- package/dist/commands/daemon/profile.js +51 -0
- package/dist/commands/goals/briefing/status.js +1 -1
- package/dist/commands/initiatives/worker/deactivate.d.ts +23 -0
- package/dist/commands/initiatives/worker/deactivate.js +78 -0
- package/dist/commands/login.js +8 -2
- package/dist/commands/logout.d.ts +20 -0
- package/dist/commands/logout.js +110 -5
- package/dist/commands/machines/profiles/disconnect.d.ts +23 -0
- package/dist/commands/machines/profiles/disconnect.js +102 -0
- package/dist/commands/machines/profiles/index.d.ts +15 -0
- package/dist/commands/machines/profiles/index.js +33 -0
- package/dist/commands/machines/profiles/label.d.ts +24 -0
- package/dist/commands/machines/profiles/label.js +85 -0
- package/dist/commands/machines/profiles/list.d.ts +16 -0
- package/dist/commands/machines/profiles/list.js +87 -0
- package/dist/commands/memory/maintain.js +16 -2
- package/dist/commands/profiles/list.js +17 -2
- package/dist/commands/spaces/delete.js +6 -1
- package/dist/commands/spaces/workflows/archive.js +6 -1
- package/dist/commands/spaces/workflows/publish.js +3 -1
- package/dist/commands/spaces/workflows/run.d.ts +1 -0
- package/dist/commands/spaces/workflows/run.js +17 -1
- package/dist/commands/spaces/workflows/triggers/create.js +3 -1
- package/dist/commands/tasks/workflow-context.js +3 -1
- package/dist/commands/triggers/authorization.js +1 -1
- package/dist/commands/triggers/capabilities.js +17 -1
- package/dist/commands/triggers/create.d.ts +2 -0
- package/dist/commands/triggers/create.js +23 -7
- package/dist/commands/triggers/fire-detail.js +12 -3
- package/dist/commands/triggers/list.d.ts +1 -0
- package/dist/commands/triggers/list.js +13 -1
- package/dist/commands/triggers/preflight.js +18 -0
- package/dist/commands/triggers/prune.js +9 -5
- package/dist/commands/triggers/update.js +13 -4
- package/dist/generated/agent-guides.json +35 -35
- package/dist/lib/agent-guides.js +1 -1
- package/dist/lib/agent-proactive-baseline.d.ts +6 -0
- package/dist/lib/agent-proactive-baseline.js +32 -3
- package/dist/lib/always-on-command-result.d.ts +18 -0
- package/dist/lib/always-on-command-result.js +52 -0
- package/dist/lib/always-on-runtime.d.ts +31 -0
- package/dist/lib/always-on-runtime.js +39 -0
- package/dist/lib/auth-diagnostics.d.ts +10 -1
- package/dist/lib/auth-diagnostics.js +16 -8
- package/dist/lib/commitments.d.ts +16 -9
- package/dist/lib/commitments.js +65 -4
- package/dist/lib/compasses.js +5 -0
- package/dist/lib/daemon-binding.js +6 -3
- package/dist/lib/daemon-command-hint.d.ts +10 -5
- package/dist/lib/daemon-command-hint.js +11 -6
- package/dist/lib/daemon-setup.js +9 -3
- package/dist/lib/daemonBroker.d.ts +7 -0
- package/dist/lib/daemonBroker.js +5 -0
- package/dist/lib/daemonHandoff.d.ts +2 -0
- package/dist/lib/daemonHandoff.js +16 -3
- package/dist/lib/daemonIslandProfile.d.ts +19 -0
- package/dist/lib/daemonIslandProfile.js +41 -0
- package/dist/lib/drain-stdio.d.ts +22 -0
- package/dist/lib/drain-stdio.js +46 -0
- package/dist/lib/format.d.ts +32 -0
- package/dist/lib/format.js +105 -1
- package/dist/lib/initiatives-worker.d.ts +25 -0
- package/dist/lib/initiatives-worker.js +13 -0
- package/dist/lib/keychain.d.ts +22 -1
- package/dist/lib/keychain.js +40 -1
- package/dist/lib/local-daemon-readiness.js +4 -6
- package/dist/lib/local-skills.js +4 -1
- package/dist/lib/login.d.ts +7 -0
- package/dist/lib/login.js +5 -0
- package/dist/lib/machines.d.ts +68 -0
- package/dist/lib/machines.js +67 -0
- package/dist/lib/proactive-audit.d.ts +52 -0
- package/dist/lib/proactive-audit.js +67 -0
- package/dist/lib/proactiveApi.d.ts +23 -0
- package/dist/lib/refresh.d.ts +20 -6
- package/dist/lib/refresh.js +27 -9
- package/dist/lib/roles.d.ts +1 -1
- package/dist/lib/runtime-start-verification.js +3 -6
- package/dist/lib/schedule.d.ts +189 -9
- package/dist/lib/schedule.js +283 -22
- package/dist/lib/triggers.d.ts +134 -3
- package/dist/lib/triggers.js +370 -17
- package/dist/lib/workflow-node-control.js +8 -0
- package/dist/lib/workflow-run-view.js +9 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.d.ts +12 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.js +10 -2
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.d.ts +8 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.js +22 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/executorStopReceiptV2.d.ts +133 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/executorStopReceiptV2.js +180 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.d.ts +5 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.js +50 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profilePorts.d.ts +137 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profilePorts.js +328 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileSelection.d.ts +63 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileSelection.js +174 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.d.ts +22 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/refresh.js +15 -4
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.d.ts +12 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.js +14 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.d.ts +8 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.js +27 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/executorStopReceiptV2.d.ts +133 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/executorStopReceiptV2.js +183 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.d.ts +5 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.js +11 -3
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profilePorts.d.ts +137 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profilePorts.js +333 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileSelection.d.ts +63 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileSelection.js +212 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.d.ts +22 -0
- package/dist/node_modules/@skrr-ai/auth-core/dist/esm/refresh.js +22 -4
- package/dist/node_modules/@skrr-ai/auth-core/package.json +11 -1
- package/dist/node_modules/@skrr-ai/data-provider/index.js +7446 -7378
- package/oclif.manifest.json +844 -47
- package/package.json +1 -1
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var profilePorts_exports = {};
|
|
30
|
+
__export(profilePorts_exports, {
|
|
31
|
+
BROWSER_RELAY_BASE_PORT: () => BROWSER_RELAY_BASE_PORT,
|
|
32
|
+
DEFAULT_PORT_PROFILE: () => DEFAULT_PORT_PROFILE,
|
|
33
|
+
HEALTH_BASE_PORT: () => HEALTH_BASE_PORT,
|
|
34
|
+
PORT_ALLOCATIONS_FILENAME: () => PORT_ALLOCATIONS_FILENAME,
|
|
35
|
+
PORT_ALLOCATIONS_VERSION: () => PORT_ALLOCATIONS_VERSION,
|
|
36
|
+
PROFILE_PORT_KINDS: () => PROFILE_PORT_KINDS,
|
|
37
|
+
PROFILE_PORT_RANGE: () => PROFILE_PORT_RANGE,
|
|
38
|
+
STATIC_DEFAULT_PORTS_ENV: () => STATIC_DEFAULT_PORTS_ENV,
|
|
39
|
+
derivedProfilePort: () => derivedProfilePort,
|
|
40
|
+
describeProfilePort: () => describeProfilePort,
|
|
41
|
+
emptyPortAllocations: () => emptyPortAllocations,
|
|
42
|
+
explicitProfilePort: () => explicitProfilePort,
|
|
43
|
+
fnv1a32: () => fnv1a32,
|
|
44
|
+
isInProfilePortRange: () => isInProfilePortRange,
|
|
45
|
+
listProfileNames: () => listProfileNames,
|
|
46
|
+
otherProfilePortClaims: () => otherProfilePortClaims,
|
|
47
|
+
parsePortAllocations: () => parsePortAllocations,
|
|
48
|
+
portAllocationsPath: () => portAllocationsPath,
|
|
49
|
+
profileDaemonJsonPath: () => profileDaemonJsonPath,
|
|
50
|
+
profileDerivedPort: () => profileDerivedPort,
|
|
51
|
+
profilePortBase: () => profilePortBase,
|
|
52
|
+
readDaemonJsonPortValues: () => readDaemonJsonPortValues,
|
|
53
|
+
readPortAllocations: () => readPortAllocations,
|
|
54
|
+
resolveProfilePort: () => resolveProfilePort,
|
|
55
|
+
resolveProfilePorts: () => resolveProfilePorts,
|
|
56
|
+
staticDefaultPortsEnabled: () => staticDefaultPortsEnabled
|
|
57
|
+
});
|
|
58
|
+
module.exports = __toCommonJS(profilePorts_exports);
|
|
59
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
60
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
61
|
+
const HEALTH_BASE_PORT = 19580;
|
|
62
|
+
const BROWSER_RELAY_BASE_PORT = 18792;
|
|
63
|
+
const PROFILE_PORT_RANGE = 100;
|
|
64
|
+
const PORT_ALLOCATIONS_FILENAME = "port-allocations.json";
|
|
65
|
+
const PORT_ALLOCATIONS_VERSION = 1;
|
|
66
|
+
const STATIC_DEFAULT_PORTS_ENV = "OVERSKY_STATIC_DEFAULT_PORTS";
|
|
67
|
+
const DEFAULT_PORT_PROFILE = "default";
|
|
68
|
+
const PROFILE_PORT_KINDS = ["health", "relay"];
|
|
69
|
+
function profilePortBase(kind) {
|
|
70
|
+
return kind === "health" ? HEALTH_BASE_PORT : BROWSER_RELAY_BASE_PORT;
|
|
71
|
+
}
|
|
72
|
+
function fnv1a32(str) {
|
|
73
|
+
let h = 2166136261;
|
|
74
|
+
for (let i = 0; i < str.length; i++) {
|
|
75
|
+
h ^= str.charCodeAt(i);
|
|
76
|
+
h = Math.imul(h, 16777619) >>> 0;
|
|
77
|
+
}
|
|
78
|
+
return h >>> 0;
|
|
79
|
+
}
|
|
80
|
+
function staticDefaultPortsEnabled(env = process.env) {
|
|
81
|
+
return env[STATIC_DEFAULT_PORTS_ENV] === "1";
|
|
82
|
+
}
|
|
83
|
+
function profileDerivedPort(basePort, profile, env = process.env) {
|
|
84
|
+
if (staticDefaultPortsEnabled(env))
|
|
85
|
+
return basePort;
|
|
86
|
+
return basePort + fnv1a32(profile) % PROFILE_PORT_RANGE;
|
|
87
|
+
}
|
|
88
|
+
function derivedProfilePort(kind, profile, env = process.env) {
|
|
89
|
+
return profileDerivedPort(profilePortBase(kind), profile, env);
|
|
90
|
+
}
|
|
91
|
+
function isInProfilePortRange(kind, port) {
|
|
92
|
+
const base = profilePortBase(kind);
|
|
93
|
+
return typeof port === "number" && Number.isInteger(port) && port >= base && port < base + PROFILE_PORT_RANGE;
|
|
94
|
+
}
|
|
95
|
+
function portAllocationsPath(root) {
|
|
96
|
+
return import_node_path.default.join(root, PORT_ALLOCATIONS_FILENAME);
|
|
97
|
+
}
|
|
98
|
+
function emptyPortAllocations() {
|
|
99
|
+
return { version: PORT_ALLOCATIONS_VERSION, profiles: {} };
|
|
100
|
+
}
|
|
101
|
+
const MOVE_REASONS = /* @__PURE__ */ new Set([
|
|
102
|
+
"default_priority",
|
|
103
|
+
"held_by_profile",
|
|
104
|
+
"in_use",
|
|
105
|
+
"range_exhausted"
|
|
106
|
+
]);
|
|
107
|
+
function parseMove(raw, kind) {
|
|
108
|
+
if (!raw || typeof raw !== "object")
|
|
109
|
+
return void 0;
|
|
110
|
+
const m = raw;
|
|
111
|
+
if (!isInProfilePortRange(kind, m.from) || typeof m.reason !== "string")
|
|
112
|
+
return void 0;
|
|
113
|
+
if (!MOVE_REASONS.has(m.reason))
|
|
114
|
+
return void 0;
|
|
115
|
+
return {
|
|
116
|
+
from: m.from,
|
|
117
|
+
reason: m.reason,
|
|
118
|
+
...typeof m.profile === "string" ? { profile: m.profile } : {},
|
|
119
|
+
...typeof m.at === "string" ? { at: m.at } : {}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function parsePortAllocations(raw) {
|
|
123
|
+
const out = emptyPortAllocations();
|
|
124
|
+
if (!raw || typeof raw !== "object")
|
|
125
|
+
return out;
|
|
126
|
+
const profiles = raw.profiles;
|
|
127
|
+
if (!profiles || typeof profiles !== "object" || Array.isArray(profiles))
|
|
128
|
+
return out;
|
|
129
|
+
for (const [name, value] of Object.entries(profiles)) {
|
|
130
|
+
if (!value || typeof value !== "object")
|
|
131
|
+
continue;
|
|
132
|
+
const v = value;
|
|
133
|
+
const entry = {};
|
|
134
|
+
for (const kind of PROFILE_PORT_KINDS) {
|
|
135
|
+
if (isInProfilePortRange(kind, v[kind]))
|
|
136
|
+
entry[kind] = v[kind];
|
|
137
|
+
const move = parseMove(v.moves?.[kind], kind);
|
|
138
|
+
if (move && entry[kind] !== void 0)
|
|
139
|
+
entry.moves = { ...entry.moves, [kind]: move };
|
|
140
|
+
}
|
|
141
|
+
if (typeof v.updatedAt === "string")
|
|
142
|
+
entry.updatedAt = v.updatedAt;
|
|
143
|
+
if (entry.health !== void 0 || entry.relay !== void 0)
|
|
144
|
+
out.profiles[name] = entry;
|
|
145
|
+
}
|
|
146
|
+
return out;
|
|
147
|
+
}
|
|
148
|
+
function readPortAllocations(root) {
|
|
149
|
+
try {
|
|
150
|
+
return parsePortAllocations(JSON.parse(import_node_fs.default.readFileSync(portAllocationsPath(root), "utf8")));
|
|
151
|
+
} catch {
|
|
152
|
+
return emptyPortAllocations();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function configuredPortNumber(value) {
|
|
156
|
+
let n = null;
|
|
157
|
+
if (typeof value === "number")
|
|
158
|
+
n = value;
|
|
159
|
+
else if (typeof value === "string" && value.trim() !== "")
|
|
160
|
+
n = Number(value);
|
|
161
|
+
if (n === null || !Number.isInteger(n) || n < 0 || n > 65535)
|
|
162
|
+
return null;
|
|
163
|
+
return n;
|
|
164
|
+
}
|
|
165
|
+
function explicitProfilePort(kind, configured, profile, env = process.env) {
|
|
166
|
+
const n = configuredPortNumber(configured);
|
|
167
|
+
if (n === null)
|
|
168
|
+
return null;
|
|
169
|
+
return n === derivedProfilePort(kind, profile, env) ? null : n;
|
|
170
|
+
}
|
|
171
|
+
function profileDaemonJsonPath(root, profile) {
|
|
172
|
+
return import_node_path.default.join(root, "profiles", profile, "daemon.json");
|
|
173
|
+
}
|
|
174
|
+
function readDaemonJsonPortValues(root, profile) {
|
|
175
|
+
try {
|
|
176
|
+
const parsed = JSON.parse(import_node_fs.default.readFileSync(profileDaemonJsonPath(root, profile), "utf8"));
|
|
177
|
+
return { health: parsed?.health?.port, relay: parsed?.browser?.relayPort };
|
|
178
|
+
} catch {
|
|
179
|
+
return { health: void 0, relay: void 0 };
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function resolveProfilePort(input) {
|
|
183
|
+
const env = input.env ?? process.env;
|
|
184
|
+
const derived = derivedProfilePort(input.kind, input.profile, env);
|
|
185
|
+
const explicit = explicitProfilePort(input.kind, input.configured, input.profile, env);
|
|
186
|
+
if (explicit !== null)
|
|
187
|
+
return { kind: input.kind, port: explicit, source: "explicit", derived };
|
|
188
|
+
if (staticDefaultPortsEnabled(env)) {
|
|
189
|
+
return { kind: input.kind, port: derived, source: "static", derived };
|
|
190
|
+
}
|
|
191
|
+
const entry = input.allocations.profiles[input.profile];
|
|
192
|
+
const allocated = entry?.[input.kind];
|
|
193
|
+
if (isInProfilePortRange(input.kind, allocated)) {
|
|
194
|
+
const move = entry?.moves?.[input.kind];
|
|
195
|
+
return {
|
|
196
|
+
kind: input.kind,
|
|
197
|
+
port: allocated,
|
|
198
|
+
source: "allocated",
|
|
199
|
+
derived,
|
|
200
|
+
...move && allocated !== derived ? { move } : {}
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return { kind: input.kind, port: derived, source: "derived", derived };
|
|
204
|
+
}
|
|
205
|
+
function resolveProfilePorts(root, profile, options = {}) {
|
|
206
|
+
const env = options.env ?? process.env;
|
|
207
|
+
const configured = options.configured ?? readDaemonJsonPortValues(root, profile);
|
|
208
|
+
const allocations = options.allocations ?? (staticDefaultPortsEnabled(env) ? emptyPortAllocations() : readPortAllocations(root));
|
|
209
|
+
return {
|
|
210
|
+
profile,
|
|
211
|
+
health: resolveProfilePort({
|
|
212
|
+
kind: "health",
|
|
213
|
+
profile,
|
|
214
|
+
configured: configured.health,
|
|
215
|
+
allocations,
|
|
216
|
+
env
|
|
217
|
+
}),
|
|
218
|
+
relay: resolveProfilePort({
|
|
219
|
+
kind: "relay",
|
|
220
|
+
profile,
|
|
221
|
+
configured: configured.relay,
|
|
222
|
+
allocations,
|
|
223
|
+
env
|
|
224
|
+
})
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
function listProfileNames(root) {
|
|
228
|
+
try {
|
|
229
|
+
return import_node_fs.default.readdirSync(import_node_path.default.join(root, "profiles"), { withFileTypes: true }).filter((d) => d.isDirectory() && !d.name.startsWith(".")).map((d) => d.name).sort();
|
|
230
|
+
} catch {
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
function otherProfilePortClaims(root, kind, profile, options = {}) {
|
|
235
|
+
const env = options.env ?? process.env;
|
|
236
|
+
const allocations = options.allocations ?? readPortAllocations(root);
|
|
237
|
+
const claims = /* @__PURE__ */ new Map();
|
|
238
|
+
const names = /* @__PURE__ */ new Set([...listProfileNames(root), ...Object.keys(allocations.profiles)]);
|
|
239
|
+
names.delete(profile);
|
|
240
|
+
for (const other of [...names].sort()) {
|
|
241
|
+
const explicit = explicitProfilePort(kind, readDaemonJsonPortValues(root, other)[kind], other, env);
|
|
242
|
+
if (explicit !== null) {
|
|
243
|
+
if (explicit > 0 && !claims.has(explicit))
|
|
244
|
+
claims.set(explicit, { profile: other, how: "explicit" });
|
|
245
|
+
continue;
|
|
246
|
+
}
|
|
247
|
+
const recorded = allocations.profiles[other]?.[kind];
|
|
248
|
+
if (isInProfilePortRange(kind, recorded) && !claims.has(recorded)) {
|
|
249
|
+
claims.set(recorded, { profile: other, how: "allocated" });
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (profile !== DEFAULT_PORT_PROFILE) {
|
|
253
|
+
const reserved = derivedProfilePort(kind, DEFAULT_PORT_PROFILE, env);
|
|
254
|
+
if (!claims.has(reserved)) {
|
|
255
|
+
claims.set(reserved, { profile: DEFAULT_PORT_PROFILE, how: "default_priority" });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return claims;
|
|
259
|
+
}
|
|
260
|
+
const KIND_LABEL = { health: "health", relay: "browser relay" };
|
|
261
|
+
const CLAIM_PHRASES = {
|
|
262
|
+
explicit: "sets it explicitly",
|
|
263
|
+
allocated: "is allocated it",
|
|
264
|
+
default_priority: "has priority on it"
|
|
265
|
+
};
|
|
266
|
+
function describeProfilePort(resolved, sharedWith) {
|
|
267
|
+
const label = `${KIND_LABEL[resolved.kind]} port ${resolved.port}`;
|
|
268
|
+
switch (resolved.source) {
|
|
269
|
+
case "explicit":
|
|
270
|
+
return `${label} (explicit: set in this profile's daemon.json)`;
|
|
271
|
+
case "static":
|
|
272
|
+
return `${label} (fixed default: ${STATIC_DEFAULT_PORTS_ENV}=1)`;
|
|
273
|
+
case "allocated": {
|
|
274
|
+
if (resolved.port === resolved.derived) {
|
|
275
|
+
return `${label} (allocated: this profile's derived port)`;
|
|
276
|
+
}
|
|
277
|
+
const move = resolved.move;
|
|
278
|
+
const from = `its derived port ${resolved.derived}`;
|
|
279
|
+
if (!move)
|
|
280
|
+
return `${label} (allocated: moved off ${from})`;
|
|
281
|
+
switch (move.reason) {
|
|
282
|
+
case "default_priority":
|
|
283
|
+
return `${label} (allocated: ${from} is reserved for the default profile)`;
|
|
284
|
+
case "held_by_profile":
|
|
285
|
+
return `${label} (allocated: ${from} is held by profile '${move.profile ?? "unknown"}')`;
|
|
286
|
+
case "in_use":
|
|
287
|
+
return `${label} (allocated: ${from} was in use by another process)`;
|
|
288
|
+
case "range_exhausted":
|
|
289
|
+
return `${label} (allocated: no free port in range; kept ${from})`;
|
|
290
|
+
}
|
|
291
|
+
return `${label} (allocated)`;
|
|
292
|
+
}
|
|
293
|
+
case "derived":
|
|
294
|
+
if (sharedWith) {
|
|
295
|
+
return `${label} (derived from the profile name, not yet allocated, and SHARED: profile '${sharedWith.profile}' ${CLAIM_PHRASES[sharedWith.how]}; restart this profile's daemon to be allocated its own)`;
|
|
296
|
+
}
|
|
297
|
+
return `${label} (derived from the profile name; allocated when this profile's daemon next starts)`;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
301
|
+
0 && (module.exports = {
|
|
302
|
+
BROWSER_RELAY_BASE_PORT,
|
|
303
|
+
DEFAULT_PORT_PROFILE,
|
|
304
|
+
HEALTH_BASE_PORT,
|
|
305
|
+
PORT_ALLOCATIONS_FILENAME,
|
|
306
|
+
PORT_ALLOCATIONS_VERSION,
|
|
307
|
+
PROFILE_PORT_KINDS,
|
|
308
|
+
PROFILE_PORT_RANGE,
|
|
309
|
+
STATIC_DEFAULT_PORTS_ENV,
|
|
310
|
+
derivedProfilePort,
|
|
311
|
+
describeProfilePort,
|
|
312
|
+
emptyPortAllocations,
|
|
313
|
+
explicitProfilePort,
|
|
314
|
+
fnv1a32,
|
|
315
|
+
isInProfilePortRange,
|
|
316
|
+
listProfileNames,
|
|
317
|
+
otherProfilePortClaims,
|
|
318
|
+
parsePortAllocations,
|
|
319
|
+
portAllocationsPath,
|
|
320
|
+
profileDaemonJsonPath,
|
|
321
|
+
profileDerivedPort,
|
|
322
|
+
profilePortBase,
|
|
323
|
+
readDaemonJsonPortValues,
|
|
324
|
+
readPortAllocations,
|
|
325
|
+
resolveProfilePort,
|
|
326
|
+
resolveProfilePorts,
|
|
327
|
+
staticDefaultPortsEnabled
|
|
328
|
+
});
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** Canonical default profile name. Used when no flag / env / lock is set. */
|
|
2
|
+
export declare const DEFAULT_PROFILE = "default";
|
|
3
|
+
/** Basename of the sticky selector at the skrr root (`skrrd profile use`). */
|
|
4
|
+
export declare const PROFILE_LOCK_FILENAME = "profile.lock";
|
|
5
|
+
/** Environment variable that selects a profile for one process tree. */
|
|
6
|
+
export declare const PROFILE_ENV_VAR = "OVERSKY_PROFILE";
|
|
7
|
+
export type ProfileSelectionSource = 'flag' | 'env' | 'lock' | 'default';
|
|
8
|
+
export interface ProfileSelection {
|
|
9
|
+
profile: string;
|
|
10
|
+
source: ProfileSelectionSource;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Validate a profile name. Throws `Error` with a human-readable message on
|
|
14
|
+
* invalid input. Never writes anywhere — pure predicate.
|
|
15
|
+
*/
|
|
16
|
+
export declare function assertValidProfileName(name: string): void;
|
|
17
|
+
/** Non-throwing variant of `assertValidProfileName`. */
|
|
18
|
+
export declare function isValidProfileName(name: unknown): name is string;
|
|
19
|
+
/** Where the sticky selector lives for this environment's skrr root. */
|
|
20
|
+
export declare function profileLockPath(env?: NodeJS.ProcessEnv): string;
|
|
21
|
+
/**
|
|
22
|
+
* Read the sticky selector. Returns `null` when the file is absent, empty,
|
|
23
|
+
* unreadable, or names an invalid profile — a corrupted lock must never pin a
|
|
24
|
+
* command to a profile that cannot exist.
|
|
25
|
+
*/
|
|
26
|
+
export declare function readProfileLock(env?: NodeJS.ProcessEnv): string | null;
|
|
27
|
+
export interface ResolveProfileSelectionInput {
|
|
28
|
+
/** The `--profile` value, or null/undefined/'' when the flag was not given. */
|
|
29
|
+
flag?: string | null;
|
|
30
|
+
/** Environment to read `OVERSKY_PROFILE` and the root from. Default: `process.env`. */
|
|
31
|
+
env?: NodeJS.ProcessEnv;
|
|
32
|
+
/**
|
|
33
|
+
* Whether to consult `OVERSKY_PROFILE` and the lock at all. Tests pass
|
|
34
|
+
* `false` to pin the output to `flag ?? DEFAULT_PROFILE`.
|
|
35
|
+
*/
|
|
36
|
+
readEnv?: boolean;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Resolve the profile for one command invocation:
|
|
40
|
+
* `--profile` > `OVERSKY_PROFILE` > `<root>/profile.lock` > `default`.
|
|
41
|
+
*
|
|
42
|
+
* An invalid flag or environment value THROWS (with the grammar's message): a
|
|
43
|
+
* name the person typed is a request, and silently replacing it with another
|
|
44
|
+
* profile would act on the wrong credentials. An invalid lock is ignored, as a
|
|
45
|
+
* corrupt file should be.
|
|
46
|
+
*
|
|
47
|
+
* Pure apart from reading the lock; mutates no global state.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveProfileSelection(input?: ResolveProfileSelectionInput): ProfileSelection;
|
|
50
|
+
/**
|
|
51
|
+
* The argv a process passes to the OTHER binary so the child acts on exactly
|
|
52
|
+
* `profile`. Always explicit, `default` included — see rule 2 above.
|
|
53
|
+
*/
|
|
54
|
+
export declare function explicitProfileArgs(profile: string): string[];
|
|
55
|
+
/**
|
|
56
|
+
* Does a command typed WITHOUT `--profile` in this environment act on
|
|
57
|
+
* `profile`? A person-facing hint can then omit the flag when it would be
|
|
58
|
+
* noise, and must include it when the environment or the lock would send the
|
|
59
|
+
* typed command somewhere else.
|
|
60
|
+
*/
|
|
61
|
+
export declare function profileIsImplicit(profile: string, env?: NodeJS.ProcessEnv): boolean;
|
|
62
|
+
/** One sentence naming the profile and why it was chosen, for diagnostics. */
|
|
63
|
+
export declare function describeProfileSelection(selection: ProfileSelection, env?: NodeJS.ProcessEnv): string;
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var profileSelection_exports = {};
|
|
30
|
+
__export(profileSelection_exports, {
|
|
31
|
+
DEFAULT_PROFILE: () => DEFAULT_PROFILE,
|
|
32
|
+
PROFILE_ENV_VAR: () => PROFILE_ENV_VAR,
|
|
33
|
+
PROFILE_LOCK_FILENAME: () => PROFILE_LOCK_FILENAME,
|
|
34
|
+
assertValidProfileName: () => assertValidProfileName,
|
|
35
|
+
describeProfileSelection: () => describeProfileSelection,
|
|
36
|
+
explicitProfileArgs: () => explicitProfileArgs,
|
|
37
|
+
isValidProfileName: () => isValidProfileName,
|
|
38
|
+
profileIsImplicit: () => profileIsImplicit,
|
|
39
|
+
profileLockPath: () => profileLockPath,
|
|
40
|
+
readProfileLock: () => readProfileLock,
|
|
41
|
+
resolveProfileSelection: () => resolveProfileSelection
|
|
42
|
+
});
|
|
43
|
+
module.exports = __toCommonJS(profileSelection_exports);
|
|
44
|
+
var import_node_fs = __toESM(require("node:fs"), 1);
|
|
45
|
+
var import_node_path = __toESM(require("node:path"), 1);
|
|
46
|
+
var import_configRoot = require("./configRoot.js");
|
|
47
|
+
const DEFAULT_PROFILE = "default";
|
|
48
|
+
const PROFILE_LOCK_FILENAME = "profile.lock";
|
|
49
|
+
const PROFILE_ENV_VAR = "OVERSKY_PROFILE";
|
|
50
|
+
const VALID_PROFILE_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
51
|
+
const RESERVED_PROFILE_NAMES = /* @__PURE__ */ new Set([
|
|
52
|
+
"profiles",
|
|
53
|
+
"profile",
|
|
54
|
+
".migrated",
|
|
55
|
+
".migrated-2026-Q3-phase-k"
|
|
56
|
+
]);
|
|
57
|
+
const WINDOWS_RESERVED_NAMES = /* @__PURE__ */ new Set([
|
|
58
|
+
"con",
|
|
59
|
+
"prn",
|
|
60
|
+
"aux",
|
|
61
|
+
"nul",
|
|
62
|
+
"com1",
|
|
63
|
+
"com2",
|
|
64
|
+
"com3",
|
|
65
|
+
"com4",
|
|
66
|
+
"com5",
|
|
67
|
+
"com6",
|
|
68
|
+
"com7",
|
|
69
|
+
"com8",
|
|
70
|
+
"com9",
|
|
71
|
+
"lpt1",
|
|
72
|
+
"lpt2",
|
|
73
|
+
"lpt3",
|
|
74
|
+
"lpt4",
|
|
75
|
+
"lpt5",
|
|
76
|
+
"lpt6",
|
|
77
|
+
"lpt7",
|
|
78
|
+
"lpt8",
|
|
79
|
+
"lpt9"
|
|
80
|
+
]);
|
|
81
|
+
function assertValidProfileName(name) {
|
|
82
|
+
if (typeof name !== "string" || name.length === 0) {
|
|
83
|
+
throw new Error("Profile name must be a non-empty string.");
|
|
84
|
+
}
|
|
85
|
+
if (!VALID_PROFILE_RE.test(name)) {
|
|
86
|
+
throw new Error(`Invalid profile name "${name}". Profile names must be 1\u201364 characters and contain only letters, digits, dot, dash, or underscore. The first character must be a letter or digit.`);
|
|
87
|
+
}
|
|
88
|
+
if (RESERVED_PROFILE_NAMES.has(name)) {
|
|
89
|
+
throw new Error(`Profile name "${name}" is reserved. Pick a different name.`);
|
|
90
|
+
}
|
|
91
|
+
if (WINDOWS_RESERVED_NAMES.has(name.toLowerCase())) {
|
|
92
|
+
throw new Error(`Profile name "${name}" is a Windows reserved device name and cannot be used as a directory name on Windows filesystems. Pick a different name (e.g., "${name}-ws").`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function isValidProfileName(name) {
|
|
96
|
+
if (typeof name !== "string")
|
|
97
|
+
return false;
|
|
98
|
+
if (!VALID_PROFILE_RE.test(name))
|
|
99
|
+
return false;
|
|
100
|
+
if (RESERVED_PROFILE_NAMES.has(name))
|
|
101
|
+
return false;
|
|
102
|
+
if (WINDOWS_RESERVED_NAMES.has(name.toLowerCase()))
|
|
103
|
+
return false;
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
function profileLockPath(env = process.env) {
|
|
107
|
+
return import_node_path.default.join((0, import_configRoot.resolveConfigRoot)(env), PROFILE_LOCK_FILENAME);
|
|
108
|
+
}
|
|
109
|
+
function readProfileLock(env = process.env) {
|
|
110
|
+
try {
|
|
111
|
+
const raw = import_node_fs.default.readFileSync(profileLockPath(env), "utf-8").trim();
|
|
112
|
+
if (!raw)
|
|
113
|
+
return null;
|
|
114
|
+
return isValidProfileName(raw) ? raw : null;
|
|
115
|
+
} catch {
|
|
116
|
+
return null;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function resolveProfileSelection(input = {}) {
|
|
120
|
+
const flag = typeof input.flag === "string" ? input.flag.trim() : "";
|
|
121
|
+
if (flag) {
|
|
122
|
+
assertValidProfileName(flag);
|
|
123
|
+
return { profile: flag, source: "flag" };
|
|
124
|
+
}
|
|
125
|
+
if (input.readEnv === false)
|
|
126
|
+
return { profile: DEFAULT_PROFILE, source: "default" };
|
|
127
|
+
const env = input.env ?? process.env;
|
|
128
|
+
const fromEnv = (env[PROFILE_ENV_VAR] ?? "").trim();
|
|
129
|
+
if (fromEnv) {
|
|
130
|
+
assertValidProfileName(fromEnv);
|
|
131
|
+
return { profile: fromEnv, source: "env" };
|
|
132
|
+
}
|
|
133
|
+
const pinned = readProfileLock(env);
|
|
134
|
+
if (pinned)
|
|
135
|
+
return { profile: pinned, source: "lock" };
|
|
136
|
+
return { profile: DEFAULT_PROFILE, source: "default" };
|
|
137
|
+
}
|
|
138
|
+
function explicitProfileArgs(profile) {
|
|
139
|
+
assertValidProfileName(profile);
|
|
140
|
+
return ["--profile", profile];
|
|
141
|
+
}
|
|
142
|
+
function profileIsImplicit(profile, env = process.env) {
|
|
143
|
+
try {
|
|
144
|
+
return resolveProfileSelection({ env }).profile === profile;
|
|
145
|
+
} catch {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function describeProfileSelection(selection, env = process.env) {
|
|
150
|
+
switch (selection.source) {
|
|
151
|
+
case "flag":
|
|
152
|
+
return `profile '${selection.profile}' (from --profile)`;
|
|
153
|
+
case "env":
|
|
154
|
+
return `profile '${selection.profile}' (from ${PROFILE_ENV_VAR})`;
|
|
155
|
+
case "lock":
|
|
156
|
+
return `profile '${selection.profile}' (pinned by ${profileLockPath(env)})`;
|
|
157
|
+
default:
|
|
158
|
+
return `profile '${selection.profile}'`;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
162
|
+
0 && (module.exports = {
|
|
163
|
+
DEFAULT_PROFILE,
|
|
164
|
+
PROFILE_ENV_VAR,
|
|
165
|
+
PROFILE_LOCK_FILENAME,
|
|
166
|
+
assertValidProfileName,
|
|
167
|
+
describeProfileSelection,
|
|
168
|
+
explicitProfileArgs,
|
|
169
|
+
isValidProfileName,
|
|
170
|
+
profileIsImplicit,
|
|
171
|
+
profileLockPath,
|
|
172
|
+
readProfileLock,
|
|
173
|
+
resolveProfileSelection
|
|
174
|
+
});
|
|
@@ -270,6 +270,28 @@ export declare function refreshDaemonToken(serverUrl: string, currentRefreshToke
|
|
|
270
270
|
* replay attempt while keeping back-compat with un-upgraded servers.
|
|
271
271
|
*/
|
|
272
272
|
export declare function revokeDaemonRefreshSession(serverUrl: string, refreshToken: string): Promise<void>;
|
|
273
|
+
/**
|
|
274
|
+
* What became of a revoke request. The server never says whether the presented
|
|
275
|
+
* token existed, so `accepted` is the strongest claim available: the server
|
|
276
|
+
* took the request, and a live session behind that token is now revoked.
|
|
277
|
+
* `refused` and `unreachable` mean the session, if there is one, is still live.
|
|
278
|
+
*/
|
|
279
|
+
export type RefreshRevokeResult = {
|
|
280
|
+
outcome: 'accepted';
|
|
281
|
+
} | {
|
|
282
|
+
outcome: 'refused';
|
|
283
|
+
status: number;
|
|
284
|
+
} | {
|
|
285
|
+
outcome: 'unreachable';
|
|
286
|
+
detail: string;
|
|
287
|
+
};
|
|
288
|
+
/**
|
|
289
|
+
* `revokeDaemonRefreshSession` with its outcome reported instead of swallowed,
|
|
290
|
+
* for a caller that must not tell a person "signed out" when the server never
|
|
291
|
+
* heard (OSK-22307: `skrr logout` did exactly that). Same request, same body,
|
|
292
|
+
* same 5-second bound; it never throws.
|
|
293
|
+
*/
|
|
294
|
+
export declare function revokeDaemonRefreshSessionReported(serverUrl: string, refreshToken: string): Promise<RefreshRevokeResult>;
|
|
273
295
|
export declare function persistReauthState(state: ReauthState): void;
|
|
274
296
|
export declare function needsReauthState(): {
|
|
275
297
|
needed: boolean;
|
|
@@ -40,6 +40,7 @@ __export(refresh_exports, {
|
|
|
40
40
|
persistReauthState: () => persistReauthState,
|
|
41
41
|
refreshDaemonToken: () => refreshDaemonToken,
|
|
42
42
|
revokeDaemonRefreshSession: () => revokeDaemonRefreshSession,
|
|
43
|
+
revokeDaemonRefreshSessionReported: () => revokeDaemonRefreshSessionReported,
|
|
43
44
|
withAuthLock: () => withAuthLock
|
|
44
45
|
});
|
|
45
46
|
module.exports = __toCommonJS(refresh_exports);
|
|
@@ -245,7 +246,17 @@ async function refreshDaemonToken(serverUrl, currentRefreshToken, daemonId, opti
|
|
|
245
246
|
async function revokeDaemonRefreshSession(serverUrl, refreshToken) {
|
|
246
247
|
if (!refreshToken)
|
|
247
248
|
return;
|
|
249
|
+
const result = await revokeDaemonRefreshSessionReported(serverUrl, refreshToken);
|
|
248
250
|
const log = (0, import_runtime.getAuthLogger)();
|
|
251
|
+
if (result.outcome === "refused") {
|
|
252
|
+
log.debug(`[auth/refresh] revoke returned ${result.status}`);
|
|
253
|
+
} else if (result.outcome === "unreachable") {
|
|
254
|
+
log.debug(`[auth/refresh] revoke network error: ${result.detail}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
async function revokeDaemonRefreshSessionReported(serverUrl, refreshToken) {
|
|
258
|
+
if (!refreshToken)
|
|
259
|
+
return { outcome: "unreachable", detail: "no refresh token to present" };
|
|
249
260
|
const url = `${serverUrl.replace(/\/+$/, "")}/api/daemons/token/revoke`;
|
|
250
261
|
const controller = new AbortController();
|
|
251
262
|
const timer = setTimeout(() => controller.abort(), 5e3);
|
|
@@ -258,11 +269,10 @@ async function revokeDaemonRefreshSession(serverUrl, refreshToken) {
|
|
|
258
269
|
signal: controller.signal
|
|
259
270
|
});
|
|
260
271
|
(0, import_runtime.notifyResponseObserver)(res);
|
|
261
|
-
|
|
262
|
-
log.debug(`[auth/refresh] revoke returned ${res.status}`);
|
|
263
|
-
}
|
|
272
|
+
return res.ok ? { outcome: "accepted" } : { outcome: "refused", status: res.status };
|
|
264
273
|
} catch (err) {
|
|
265
|
-
|
|
274
|
+
const detail = controller.signal.aborted ? "no answer within 5 seconds" : err?.message || String(err);
|
|
275
|
+
return { outcome: "unreachable", detail };
|
|
266
276
|
} finally {
|
|
267
277
|
clearTimeout(timer);
|
|
268
278
|
}
|
|
@@ -553,5 +563,6 @@ function clearReauthState() {
|
|
|
553
563
|
persistReauthState,
|
|
554
564
|
refreshDaemonToken,
|
|
555
565
|
revokeDaemonRefreshSession,
|
|
566
|
+
revokeDaemonRefreshSessionReported,
|
|
556
567
|
withAuthLock
|
|
557
568
|
});
|
|
@@ -32,6 +32,18 @@
|
|
|
32
32
|
* child process it is about to spawn, and so tests need no process-wide mutation.
|
|
33
33
|
*/
|
|
34
34
|
export declare function resolveConfigRoot(env?: NodeJS.ProcessEnv): string;
|
|
35
|
+
/**
|
|
36
|
+
* The variables that relocate the root, newest spelling first. For a message
|
|
37
|
+
* that must tell a person which override to drop; nothing reads the
|
|
38
|
+
* environment through this list.
|
|
39
|
+
*/
|
|
40
|
+
export declare const CONFIG_ROOT_ENV_VARS: readonly ["SKRR_CONFIG_DIR", "OVERSKY_CONFIG_DIR"];
|
|
41
|
+
/**
|
|
42
|
+
* `env` with the root pointed at `root`, for a caller that resolves as though the
|
|
43
|
+
* root were elsewhere (a test's temporary home, a child process). Writing the
|
|
44
|
+
* override here keeps the variable's name in its one definition.
|
|
45
|
+
*/
|
|
46
|
+
export declare function withConfigRoot(env: NodeJS.ProcessEnv, root: string): NodeJS.ProcessEnv;
|
|
35
47
|
/** A path under the skrr root, e.g. `configRootPath(env, 'daemon', 'logs')`. */
|
|
36
48
|
export declare function configRootPath(env: NodeJS.ProcessEnv, ...segments: string[]): string;
|
|
37
49
|
/**
|
|
@@ -37,6 +37,20 @@ export function resolveConfigRoot(env = process.env) {
|
|
|
37
37
|
const override = (env.SKRR_CONFIG_DIR || env.OVERSKY_CONFIG_DIR)?.trim();
|
|
38
38
|
return override || path.join(homedir(), '.skrr');
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* The variables that relocate the root, newest spelling first. For a message
|
|
42
|
+
* that must tell a person which override to drop; nothing reads the
|
|
43
|
+
* environment through this list.
|
|
44
|
+
*/
|
|
45
|
+
export const CONFIG_ROOT_ENV_VARS = ['SKRR_CONFIG_DIR', 'OVERSKY_CONFIG_DIR'];
|
|
46
|
+
/**
|
|
47
|
+
* `env` with the root pointed at `root`, for a caller that resolves as though the
|
|
48
|
+
* root were elsewhere (a test's temporary home, a child process). Writing the
|
|
49
|
+
* override here keeps the variable's name in its one definition.
|
|
50
|
+
*/
|
|
51
|
+
export function withConfigRoot(env, root) {
|
|
52
|
+
return { ...env, SKRR_CONFIG_DIR: root };
|
|
53
|
+
}
|
|
40
54
|
/** A path under the skrr root, e.g. `configRootPath(env, 'daemon', 'logs')`. */
|
|
41
55
|
export function configRootPath(env, ...segments) {
|
|
42
56
|
return path.join(resolveConfigRoot(env), ...segments);
|