@skrr-ai/cli 0.1.141 → 0.1.143

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.
Files changed (85) hide show
  1. package/dist/base-command.d.ts +4 -2
  2. package/dist/base-command.js +46 -13
  3. package/dist/commands/agents/always-on/disable.js +9 -1
  4. package/dist/commands/agents/always-on/enable.js +9 -1
  5. package/dist/commands/agents/always-on/status.js +14 -1
  6. package/dist/commands/agents/create.js +10 -1
  7. package/dist/commands/agents/delete.d.ts +6 -0
  8. package/dist/commands/agents/delete.js +24 -0
  9. package/dist/commands/agents/intuitions/list.js +1 -1
  10. package/dist/commands/agents/spawn.d.ts +9 -0
  11. package/dist/commands/agents/spawn.js +127 -7
  12. package/dist/commands/agents/todos/cancel.js +3 -0
  13. package/dist/commands/agents/todos/edit.js +1 -1
  14. package/dist/commands/agents/triggers/policy.js +7 -0
  15. package/dist/commands/commitments/preflight.js +17 -2
  16. package/dist/commands/daemon/index.js +1 -0
  17. package/dist/commands/daemon/logs.d.ts +8 -1
  18. package/dist/commands/daemon/logs.js +32 -22
  19. package/dist/commands/daemon/profile.d.ts +15 -0
  20. package/dist/commands/daemon/profile.js +51 -0
  21. package/dist/commands/goals/briefing/status.js +1 -1
  22. package/dist/commands/machines/profiles/disconnect.d.ts +23 -0
  23. package/dist/commands/machines/profiles/disconnect.js +102 -0
  24. package/dist/commands/machines/profiles/index.d.ts +15 -0
  25. package/dist/commands/machines/profiles/index.js +33 -0
  26. package/dist/commands/machines/profiles/label.d.ts +24 -0
  27. package/dist/commands/machines/profiles/label.js +85 -0
  28. package/dist/commands/machines/profiles/list.d.ts +16 -0
  29. package/dist/commands/machines/profiles/list.js +87 -0
  30. package/dist/commands/profiles/list.js +17 -2
  31. package/dist/commands/spaces/heartbeats/create.js +1 -1
  32. package/dist/commands/spaces/heartbeats/update.js +1 -1
  33. package/dist/commands/triggers/authorization.js +1 -1
  34. package/dist/lib/agent-guides.js +1 -1
  35. package/dist/lib/agent-proactive-baseline.d.ts +6 -0
  36. package/dist/lib/agent-proactive-baseline.js +25 -2
  37. package/dist/lib/always-on-command-result.d.ts +18 -0
  38. package/dist/lib/always-on-command-result.js +52 -0
  39. package/dist/lib/always-on-runtime.d.ts +31 -0
  40. package/dist/lib/always-on-runtime.js +39 -0
  41. package/dist/lib/auth-diagnostics.d.ts +10 -1
  42. package/dist/lib/auth-diagnostics.js +16 -8
  43. package/dist/lib/compasses.js +5 -0
  44. package/dist/lib/daemon-binding.js +6 -3
  45. package/dist/lib/daemon-command-hint.d.ts +10 -5
  46. package/dist/lib/daemon-command-hint.js +11 -6
  47. package/dist/lib/daemonHandoff.js +6 -2
  48. package/dist/lib/drain-stdio.d.ts +22 -0
  49. package/dist/lib/drain-stdio.js +46 -0
  50. package/dist/lib/keychain.d.ts +22 -1
  51. package/dist/lib/keychain.js +40 -1
  52. package/dist/lib/local-daemon-readiness.js +4 -6
  53. package/dist/lib/local-skills.js +4 -1
  54. package/dist/lib/machines.d.ts +68 -0
  55. package/dist/lib/machines.js +67 -0
  56. package/dist/lib/proactiveApi.d.ts +15 -1
  57. package/dist/lib/runtime-start-verification.js +3 -6
  58. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.d.ts +12 -0
  59. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.js +10 -2
  60. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.d.ts +8 -0
  61. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/deviceIdentityBridge.js +22 -0
  62. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/executorStopReceiptV2.d.ts +133 -0
  63. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/executorStopReceiptV2.js +180 -0
  64. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.d.ts +4 -2
  65. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.js +48 -0
  66. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profilePorts.d.ts +137 -0
  67. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profilePorts.js +328 -0
  68. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileSelection.d.ts +63 -0
  69. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/profileSelection.js +174 -0
  70. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.d.ts +12 -0
  71. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.js +14 -0
  72. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.d.ts +8 -0
  73. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/deviceIdentityBridge.js +27 -0
  74. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/executorStopReceiptV2.d.ts +133 -0
  75. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/executorStopReceiptV2.js +183 -0
  76. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.d.ts +4 -2
  77. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.js +10 -2
  78. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profilePorts.d.ts +137 -0
  79. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profilePorts.js +333 -0
  80. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileSelection.d.ts +63 -0
  81. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/profileSelection.js +212 -0
  82. package/dist/node_modules/@skrr-ai/auth-core/package.json +11 -1
  83. package/dist/node_modules/@skrr-ai/data-provider/index.js +7295 -7265
  84. package/oclif.manifest.json +332 -3
  85. package/package.json +1 -1
@@ -88,7 +88,7 @@ async function readAgentGuide(request, flags) {
88
88
  let source = 'bundled';
89
89
  let reason = flags.offline ? 'offline-requested' : 'no-session';
90
90
  if (!flags.offline) {
91
- (0, keychain_1.setActiveProfile)(flags.profile ?? process.env.OVERSKY_PROFILE ?? '');
91
+ (0, keychain_1.selectActiveProfile)(flags.profile);
92
92
  let credential;
93
93
  let autonomous = false;
94
94
  try {
@@ -6,4 +6,10 @@ import type { AgentCreationDisposition, AgentProactiveBaseline } from '@skrr-ai/
6
6
  * unreadable fact prints as `unknown`, never as missing.
7
7
  */
8
8
  export declare function proactiveBaselineLines(b?: AgentProactiveBaseline | null): string[];
9
+ /**
10
+ * The ceiling is the sum of what the EXPECTED system loops declare, not of the loops
11
+ * that exist. A standby duplicate with 0 of its 5 loops printed "23/day (declared by
12
+ * the system loops)", which read as a budget it was spending (OSK-22353).
13
+ */
14
+ export declare function modelRunCeilingText(b: AgentProactiveBaseline): string;
9
15
  export declare function creationDispositionLines(p?: AgentCreationDisposition | null): string[];
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.proactiveBaselineLines = proactiveBaselineLines;
4
+ exports.modelRunCeilingText = modelRunCeilingText;
4
5
  exports.creationDispositionLines = creationDispositionLines;
5
6
  /**
6
7
  * Human lines for the read-only proactive baseline an Always-On status carries
@@ -17,7 +18,10 @@ function proactiveBaselineLines(b) {
17
18
  ? 'unknown'
18
19
  : `${b.systemLoops.present.length}/${b.systemLoops.expected.length}` +
19
20
  (b.systemLoops.paused.length ? ` (paused: ${b.systemLoops.paused.join(', ')})` : '') +
20
- (b.systemLoops.missing.length ? ` (missing: ${b.systemLoops.missing.join(', ')})` : '');
21
+ (b.systemLoops.missing.length ? ` (missing: ${b.systemLoops.missing.join(', ')})` : '') +
22
+ (b.systemLoops.blocked?.length
23
+ ? ` (cannot run: ${b.systemLoops.blocked.map((loop) => `${loop.role} - ${loop.reason}`).join(', ')})`
24
+ : '');
21
25
  const watchers = b.watchers.status === 'unknown'
22
26
  ? 'unknown'
23
27
  : `${b.watchers.total} (${b.watchers.enabled} enabled; separate from Always-On)`;
@@ -37,11 +41,30 @@ function proactiveBaselineLines(b) {
37
41
  }
38
42
  lines.push(`System loops: ${loops}`);
39
43
  lines.push(`Watchers: ${watchers}`);
40
- lines.push(`Model-run ceiling: ${b.dailyModelRunCeiling}/day (declared by the system loops)`);
44
+ lines.push(`Model-run ceiling: ${modelRunCeilingText(b)}`);
41
45
  for (const gap of b.gaps)
42
46
  lines.push(` ${gap.code}: ${gap.fix}`);
43
47
  return lines;
44
48
  }
49
+ /**
50
+ * The ceiling is the sum of what the EXPECTED system loops declare, not of the loops
51
+ * that exist. A standby duplicate with 0 of its 5 loops printed "23/day (declared by
52
+ * the system loops)", which read as a budget it was spending (OSK-22353).
53
+ */
54
+ function modelRunCeilingText(b) {
55
+ const ceiling = b.dailyModelRunCeiling;
56
+ if (b.systemLoops.status === 'unknown')
57
+ return `${ceiling}/day if its system loops are installed (their state is unknown)`;
58
+ const expected = b.systemLoops.expected.length;
59
+ const present = b.systemLoops.present.length;
60
+ if (expected === 0 || ceiling === 0)
61
+ return `${ceiling}/day (no system loop declares a budget)`;
62
+ if (present >= expected)
63
+ return `${ceiling}/day (declared by its ${expected} system loops)`;
64
+ if (present === 0)
65
+ return `none now; ${ceiling}/day once its ${expected} system loops are installed`;
66
+ return `${ceiling}/day once all ${expected} system loops are installed (${present} are now)`;
67
+ }
45
68
  function creationDispositionLines(p) {
46
69
  if (!p)
47
70
  return [];
@@ -0,0 +1,18 @@
1
+ import type { AlwaysOnStatus } from '@skrr-ai/data-provider';
2
+ /**
3
+ * What `skrr agents always-on enable|disable` should say about the response to
4
+ * its control write (OSK-21992).
5
+ *
6
+ * The response is the composed status read at the END of the request. Two
7
+ * concurrent opposite commands are both valid when one of them is a no-op, so
8
+ * "disable" can come back from a server whose Agent is now ON. Printing
9
+ * "Always-On disabled" there is a claim the same response contradicts.
10
+ *
11
+ * `matched` is whether the Agent ended in the state the caller asked for. It is
12
+ * the command's exit code: a script chaining `disable && …` must not carry on
13
+ * with an Agent that is still on.
14
+ */
15
+ export declare function alwaysOnCommandResult(requested: boolean, status: Pick<AlwaysOnStatus, 'desiredEnabled' | 'generation' | 'operationalState' | 'controlCommand'>): {
16
+ matched: boolean;
17
+ line: string;
18
+ };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.alwaysOnCommandResult = alwaysOnCommandResult;
4
+ /**
5
+ * What `skrr agents always-on enable|disable` should say about the response to
6
+ * its control write (OSK-21992).
7
+ *
8
+ * The response is the composed status read at the END of the request. Two
9
+ * concurrent opposite commands are both valid when one of them is a no-op, so
10
+ * "disable" can come back from a server whose Agent is now ON. Printing
11
+ * "Always-On disabled" there is a claim the same response contradicts.
12
+ *
13
+ * `matched` is whether the Agent ended in the state the caller asked for. It is
14
+ * the command's exit code: a script chaining `disable && …` must not carry on
15
+ * with an Agent that is still on.
16
+ */
17
+ function alwaysOnCommandResult(requested, status) {
18
+ const word = (on) => (on ? 'on' : 'off');
19
+ const matched = status.desiredEnabled === requested;
20
+ const now = `generation=${status.generation} operational=${status.operationalState}`;
21
+ const command = status.controlCommand;
22
+ if (matched) {
23
+ // Only an explicit `unchanged` is a no-op; an older server sends no receipt,
24
+ // and then the long-standing wording is all that can honestly be said.
25
+ return {
26
+ matched,
27
+ line: command?.outcome === 'unchanged'
28
+ ? `Always-On was already ${word(requested)} — nothing to change (${now})`
29
+ : `Always-On ${requested ? 'enabled' : 'disabled'} — ${now}`,
30
+ };
31
+ }
32
+ const actual = word(status.desiredEnabled);
33
+ const tail = `(${now}). Run \`skrr agents always-on status\` before relying on it.`;
34
+ if (command?.outcome === 'unchanged') {
35
+ return {
36
+ matched,
37
+ line: `Always-On was already ${word(requested)} at generation ${command.generation}, so this ` +
38
+ `command changed nothing; a newer command has since turned it ${actual} ${tail}`,
39
+ };
40
+ }
41
+ if (command?.outcome === 'applied') {
42
+ return {
43
+ matched,
44
+ line: `Always-On was turned ${word(requested)} at generation ${command.generation}, but a ` +
45
+ `newer command has since turned it ${actual} ${tail}`,
46
+ };
47
+ }
48
+ return {
49
+ matched,
50
+ line: `Always-On was not left ${word(requested)}: a concurrent change landed first and it is now ${actual} ${tail}`,
51
+ };
52
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Where an Always-On Agent's work has to run, as `skrr agents always-on status`
3
+ * prints it (OSK-22347).
4
+ *
5
+ * The status envelope says what the platform INTENDS to fire (`operationalState`,
6
+ * `nextFire`) and nothing about whether the machine that work runs on is
7
+ * reachable, so a laptop that was closed, or a stopped Dedicated Runtime, read as
8
+ * a healthy `idle` with a next fire hours away. The web already downgrades that
9
+ * to "Runtime offline" from the Agent's `harnessStatus`; this is the same fact for
10
+ * the CLI. A failed read is `unknown`, never absent: a missing line would read as
11
+ * "nothing wrong".
12
+ */
13
+ export type AlwaysOnRuntimeStatus = 'online' | 'offline' | 'unknown' | 'none';
14
+ export interface AlwaysOnRuntimeRead {
15
+ status: AlwaysOnRuntimeStatus;
16
+ name?: string;
17
+ lastSeenAt?: string;
18
+ /** The Agent read itself failed, so the runtime could not be established. */
19
+ readFailed?: true;
20
+ }
21
+ interface AgentRuntimeFields {
22
+ harnessId?: string | null;
23
+ harnessStatus?: string | null;
24
+ harnessName?: string | null;
25
+ harnessLastSeenAt?: string | Date | null;
26
+ }
27
+ export declare function runtimeFromAgent(agent: AgentRuntimeFields | null | undefined): AlwaysOnRuntimeRead;
28
+ export declare const RUNTIME_READ_FAILED: AlwaysOnRuntimeRead;
29
+ /** Lines to print under `Operational:`; empty when there is no machine involved. */
30
+ export declare function runtimeLines(runtime: AlwaysOnRuntimeRead, desiredEnabled: boolean): string[];
31
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RUNTIME_READ_FAILED = void 0;
4
+ exports.runtimeFromAgent = runtimeFromAgent;
5
+ exports.runtimeLines = runtimeLines;
6
+ function runtimeFromAgent(agent) {
7
+ // An Agent with no harness runs in the cloud: there is no machine to be off.
8
+ if (!agent || !agent.harnessId)
9
+ return { status: 'none' };
10
+ const status = agent.harnessStatus === 'online' || agent.harnessStatus === 'offline'
11
+ ? agent.harnessStatus
12
+ : 'unknown';
13
+ return {
14
+ status,
15
+ ...(agent.harnessName ? { name: agent.harnessName } : {}),
16
+ ...(agent.harnessLastSeenAt
17
+ ? { lastSeenAt: new Date(agent.harnessLastSeenAt).toISOString() }
18
+ : {}),
19
+ };
20
+ }
21
+ exports.RUNTIME_READ_FAILED = { status: 'unknown', readFailed: true };
22
+ /** Lines to print under `Operational:`; empty when there is no machine involved. */
23
+ function runtimeLines(runtime, desiredEnabled) {
24
+ if (runtime.status === 'none')
25
+ return [];
26
+ const label = runtime.name ? ` — ${runtime.name}` : '';
27
+ if (runtime.status === 'offline') {
28
+ const lines = [
29
+ `Runtime: offline${label}${runtime.lastSeenAt ? ` (last seen ${runtime.lastSeenAt})` : ''}`,
30
+ ];
31
+ if (desiredEnabled) {
32
+ lines.push('Warning: Always-On cannot run work while this runtime is offline; scheduled fires wait for it.');
33
+ }
34
+ return lines;
35
+ }
36
+ if (runtime.status === 'online')
37
+ return [`Runtime: online${label}`];
38
+ return [`Runtime: unknown${runtime.readFailed ? ' (could not read the Agent)' : label}`];
39
+ }
@@ -4,6 +4,7 @@
4
4
  * Only metadata crosses this boundary: callers must never pass a token, an
5
5
  * auth-helper result, or a raw configured URL into an error document.
6
6
  */
7
+ import { type ProfileSelection } from '@skrr-ai/auth-core';
7
8
  export type ServerConfigurationSource = 'OVERSKY_BASE_URL' | 'SKRR_BASE_URL' | 'OVERSKY_SERVER_URL' | 'SKRR_SERVER_URL' | 'configuration';
8
9
  /** Matches config.ts precedence while exposing only the selected variable name. */
9
10
  export declare function serverConfigurationSource(env?: Record<string, string | undefined>): ServerConfigurationSource;
@@ -25,15 +26,23 @@ export type AuthResolutionDiagnostic = {
25
26
  origin: string | null;
26
27
  source: ServerConfigurationSource;
27
28
  };
29
+ /**
30
+ * The profile whose credential store was read, and why it was chosen
31
+ * (OSK-22299). "Not signed in" while another profile holds a session is
32
+ * the common case after `skrrd profile use`, and without this it read as a
33
+ * lost login.
34
+ */
35
+ profile: ProfileSelection | null;
28
36
  suggestion: string | null;
29
37
  };
30
- export declare function authResolutionDiagnostic({ credential, bareMode, managedRuntime, baseURL, bin, env, }: {
38
+ export declare function authResolutionDiagnostic({ credential, bareMode, managedRuntime, baseURL, bin, env, profile, }: {
31
39
  credential: CredentialResolutionMetadata;
32
40
  bareMode: boolean;
33
41
  managedRuntime?: boolean;
34
42
  baseURL: string | null | undefined;
35
43
  bin: string;
36
44
  env?: Record<string, string | undefined>;
45
+ profile?: ProfileSelection | null;
37
46
  }): AuthResolutionDiagnostic;
38
47
  /** Human form of a missing-credential diagnostic. Never echoes a raw URL. */
39
48
  export declare function describeMissingCredential(diagnostic: AuthResolutionDiagnostic, bin: string): string;
@@ -1,15 +1,16 @@
1
1
  "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.serverConfigurationSource = serverConfigurationSource;
4
+ exports.safeServerOrigin = safeServerOrigin;
5
+ exports.authResolutionDiagnostic = authResolutionDiagnostic;
6
+ exports.describeMissingCredential = describeMissingCredential;
2
7
  /**
3
8
  * Stable, secret-safe auth diagnostics.
4
9
  *
5
10
  * Only metadata crosses this boundary: callers must never pass a token, an
6
11
  * auth-helper result, or a raw configured URL into an error document.
7
12
  */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.serverConfigurationSource = serverConfigurationSource;
10
- exports.safeServerOrigin = safeServerOrigin;
11
- exports.authResolutionDiagnostic = authResolutionDiagnostic;
12
- exports.describeMissingCredential = describeMissingCredential;
13
+ const auth_core_1 = require("@skrr-ai/auth-core");
13
14
  const SERVER_ENV_PRECEDENCE = [
14
15
  'OVERSKY_BASE_URL',
15
16
  'SKRR_BASE_URL',
@@ -32,15 +33,20 @@ function safeServerOrigin(value) {
32
33
  return null;
33
34
  }
34
35
  }
35
- function authResolutionDiagnostic({ credential, bareMode, managedRuntime = false, baseURL, bin, env = process.env, }) {
36
+ function authResolutionDiagnostic({ credential, bareMode, managedRuntime = false, baseURL, bin, env = process.env, profile = null, }) {
36
37
  const resolved = Boolean(credential.token);
38
+ // Name the profile in the command only when a bare `login` would land
39
+ // somewhere else: an environment override or a lock pointing elsewhere.
40
+ const loginProfile = profile && !(0, auth_core_1.profileIsImplicit)(profile.profile, env)
41
+ ? ` --profile ${profile.profile}`
42
+ : '';
37
43
  const suggestion = resolved
38
44
  ? null
39
45
  : bareMode
40
46
  ? 'Set OVERSKY_TOKEN or SKRR_TOKEN, pass --token, or omit --bare to use a saved session.'
41
47
  : managedRuntime
42
48
  ? 'This managed runtime accepts only its session credential. Start a new managed session or run the command in your own terminal.'
43
- : `Run \`${bin} login\` to create a local session.`;
49
+ : `Run \`${bin} login${loginProfile}\` to create a local session.`;
44
50
  return {
45
51
  state: resolved ? 'resolved' : 'missing',
46
52
  source: resolved ? credential.source ?? null : null,
@@ -53,6 +59,7 @@ function authResolutionDiagnostic({ credential, bareMode, managedRuntime = false
53
59
  : 'checked',
54
60
  authHelper: env.OVERSKY_AUTH_HELPER?.trim() ? 'configured' : 'not-configured',
55
61
  server: { origin: safeServerOrigin(baseURL), source: serverConfigurationSource(env) },
62
+ profile: profile ? { profile: profile.profile, source: profile.source } : null,
56
63
  suggestion,
57
64
  };
58
65
  }
@@ -67,5 +74,6 @@ function describeMissingCredential(diagnostic, bin) {
67
74
  : diagnostic.localCredentialStore === 'unavailable-in-managed-runtime'
68
75
  ? ' This managed runtime cannot use the local credential store.'
69
76
  : '';
70
- return `No usable credential for ${server} (selected by ${source}).${localStore} ${diagnostic.suggestion ?? `Run \`${bin} login\` to sign in.`}`;
77
+ const profile = diagnostic.profile ? ` in ${(0, auth_core_1.describeProfileSelection)(diagnostic.profile)}` : '';
78
+ return `No usable credential for ${server} (selected by ${source})${profile}.${localStore} ${diagnostic.suggestion ?? `Run \`${bin} login\` to sign in.`}`;
71
79
  }
@@ -276,6 +276,11 @@ const record = (value) => value && typeof value === 'object' && !Array.isArray(v
276
276
  function renderEffectivePolicy(policy, log) {
277
277
  log(`Compass ${scalar(policy.compassId)}, revision ${scalar(policy.compassVersion)}: ${scalar(policy.status)}`);
278
278
  log(`Applies to runtime: ${policy.appliesToRuntime === true ? 'yes' : 'no'}`);
279
+ // The Gateway reads one Compass per agent for the agent's own messages; this one may not be it.
280
+ const gateway = record(policy.messageGateway);
281
+ if (gateway.readsThisCompass === false && typeof gateway.canonicalCompassId === 'string') {
282
+ log(`Agent messages: the Gateway reads ${gateway.canonicalCompassId} for this agent, not this Compass, so its communication defaults do not change those messages. They apply to Commitments bound to it.`);
283
+ }
279
284
  const autonomy = record(policy.autonomy);
280
285
  log('Autonomy');
281
286
  const source = typeof autonomy.modeSource === 'string' ? autonomy.modeSource : undefined;
@@ -4,6 +4,7 @@ exports.hasFlag = hasFlag;
4
4
  exports.bindToCliSession = bindToCliSession;
5
5
  const config_1 = require("./config");
6
6
  const exec_runtime_binary_1 = require("./exec-runtime-binary");
7
+ const auth_core_1 = require("@skrr-ai/auth-core");
7
8
  const keychain_1 = require("./keychain");
8
9
  /**
9
10
  * Defaults for the flags that decide WHICH deployment and WHICH profile a
@@ -56,9 +57,11 @@ function bindToCliSession(argv) {
56
57
  // is already inside a BaseCommand; fall back to that process's resolved
57
58
  // active profile so it cannot silently install the default service after
58
59
  // `skrr login --profile <name>`.
59
- const profile = (0, keychain_1.resolveProfileFromArgv)(argv) ?? process.env.OVERSKY_PROFILE ?? (0, keychain_1.getActiveProfile)() ?? null;
60
- if (profile && profile !== keychain_1.DEFAULT_PROFILE)
61
- extra.push('--profile', profile);
60
+ //
61
+ // Always explicit, `default` included (OSK-22298): omitting it for the
62
+ // default left `skrrd` to resolve on its own, and its own rule reads
63
+ // `profile.lock`, so a default-profile command could act on the pinned one.
64
+ extra.push(...(0, auth_core_1.explicitProfileArgs)((0, keychain_1.profileForChildProcess)(argv)));
62
65
  }
63
66
  return (0, exec_runtime_binary_1.normalizeRuntimeGlobalArgs)([...argv, ...extra]);
64
67
  }
@@ -2,14 +2,19 @@
2
2
  * `skrr daemon <verb> [args]` as a person can paste it for THIS profile.
3
3
  *
4
4
  * `skrr daemon login` with no `--profile` acts on whichever profile the shell it
5
- * is typed in resolves, which is the default one unless something says
6
- * otherwise. So a hint printed after `skrr login --profile expd` that said only
7
- * `skrr daemon login` sent people to sign a different daemon in and leave the
8
- * one they had just set up exactly as it was (OSK-16435). The profile is named
9
- * only when it is not the default, the way every other hint here spells it.
5
+ * is typed in resolves. So a hint printed after `skrr login --profile expd` that
6
+ * said only `skrr daemon login` sent people to sign a different daemon in and
7
+ * leave the one they had just set up exactly as it was (OSK-16435).
8
+ *
9
+ * The flag is left out only when the command typed without it would resolve to
10
+ * the same profile (`profileIsImplicit`: no environment override and no
11
+ * `profile.lock` pointing elsewhere). Comparing with the literal `default` was
12
+ * not enough: with a lock naming `work`, a hint for `default` read as
13
+ * `skrr daemon login` and signed `work` in instead (OSK-22299).
10
14
  */
11
15
  export declare function daemonCommandHint(verb: string, options?: {
12
16
  bin?: string;
13
17
  extraArgs?: string;
14
18
  profile?: string;
19
+ env?: NodeJS.ProcessEnv;
15
20
  }): string;
@@ -1,21 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.daemonCommandHint = daemonCommandHint;
4
+ const auth_core_1 = require("@skrr-ai/auth-core");
4
5
  const keychain_1 = require("./keychain");
5
6
  /**
6
7
  * `skrr daemon <verb> [args]` as a person can paste it for THIS profile.
7
8
  *
8
9
  * `skrr daemon login` with no `--profile` acts on whichever profile the shell it
9
- * is typed in resolves, which is the default one unless something says
10
- * otherwise. So a hint printed after `skrr login --profile expd` that said only
11
- * `skrr daemon login` sent people to sign a different daemon in and leave the
12
- * one they had just set up exactly as it was (OSK-16435). The profile is named
13
- * only when it is not the default, the way every other hint here spells it.
10
+ * is typed in resolves. So a hint printed after `skrr login --profile expd` that
11
+ * said only `skrr daemon login` sent people to sign a different daemon in and
12
+ * leave the one they had just set up exactly as it was (OSK-16435).
13
+ *
14
+ * The flag is left out only when the command typed without it would resolve to
15
+ * the same profile (`profileIsImplicit`: no environment override and no
16
+ * `profile.lock` pointing elsewhere). Comparing with the literal `default` was
17
+ * not enough: with a lock naming `work`, a hint for `default` read as
18
+ * `skrr daemon login` and signed `work` in instead (OSK-22299).
14
19
  */
15
20
  function daemonCommandHint(verb, options = {}) {
16
21
  const bin = options.bin ?? 'skrr';
17
22
  const profile = options.profile ?? (0, keychain_1.getActiveProfile)();
18
- const scoped = profile && profile !== keychain_1.DEFAULT_PROFILE ? ` --profile ${profile}` : '';
23
+ const scoped = profile && !(0, auth_core_1.profileIsImplicit)(profile, options.env) ? ` --profile ${profile}` : '';
19
24
  const extra = options.extraArgs ? ` ${options.extraArgs}` : '';
20
25
  return `${bin} daemon ${verb}${scoped}${extra}`;
21
26
  }
@@ -9,6 +9,7 @@ const daemon_handoff_opt_out_1 = require("./daemon-handoff-opt-out");
9
9
  const daemon_machine_identity_1 = require("./daemon-machine-identity");
10
10
  const dedicated_service_1 = require("./dedicated-service");
11
11
  const exec_runtime_binary_1 = require("./exec-runtime-binary");
12
+ const auth_core_1 = require("@skrr-ai/auth-core");
12
13
  const keychain_1 = require("./keychain");
13
14
  /**
14
15
  * Ceilings, not expectations. Both calls finish in milliseconds when anything is
@@ -100,8 +101,11 @@ function runOversky(binary, args, opts) {
100
101
  * this is the same rule for the path that runs without being asked.
101
102
  */
102
103
  function profileArgs() {
103
- const profile = (0, keychain_1.getActiveProfile)();
104
- return profile && profile !== keychain_1.DEFAULT_PROFILE ? ['--profile', profile] : [];
104
+ // Explicit for `default` too (OSK-22298). Leaving it out for the default
105
+ // profile kept exactly the gap described above: `skrrd` then resolved from
106
+ // its lock, so a lock naming `work` sent a default-profile `skrr login`'s
107
+ // daemon credential to `work`.
108
+ return (0, auth_core_1.explicitProfileArgs)((0, keychain_1.profileForChildProcess)());
105
109
  }
106
110
  /**
107
111
  * Parse the machine-readable line `accept-handoff --print-id` writes to stderr.
@@ -0,0 +1,22 @@
1
+ import type { Writable } from 'node:stream';
2
+ /**
3
+ * Resolve once everything this process has already written to stdout and
4
+ * stderr has been handed to the operating system (OSK-22165).
5
+ *
6
+ * Node writes a pipe asynchronously on macOS: a write larger than the pipe's
7
+ * free kernel buffer is only partly accepted, and Node queues the rest to send
8
+ * as the reader drains. `process.exit()` throws that queue away. oclif turns
9
+ * every `this.exit(n)` into exactly that call (`handle` -> `Exit.exit`), so a
10
+ * command that printed its `--json` document and then chose a nonzero status
11
+ * sent a piped reader the first 64 KiB and nothing else: a document cut
12
+ * mid-string under an exit status that looked like an ordinary refusal. A
13
+ * terminal is written synchronously, which is why the same command looked
14
+ * complete when run by hand.
15
+ *
16
+ * A zero-length write is queued behind every earlier one, so its callback runs
17
+ * only after they have all completed. A reader that has gone away (`| head -1`)
18
+ * makes the write fail, which resolves too: there is nobody left to lose
19
+ * output for.
20
+ */
21
+ export declare function drainStdio(streams?: ReadonlyArray<Writable | undefined>): Promise<void>;
22
+ export declare function drainWritable(stream: Writable | undefined): Promise<void>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.drainStdio = drainStdio;
4
+ exports.drainWritable = drainWritable;
5
+ /**
6
+ * Resolve once everything this process has already written to stdout and
7
+ * stderr has been handed to the operating system (OSK-22165).
8
+ *
9
+ * Node writes a pipe asynchronously on macOS: a write larger than the pipe's
10
+ * free kernel buffer is only partly accepted, and Node queues the rest to send
11
+ * as the reader drains. `process.exit()` throws that queue away. oclif turns
12
+ * every `this.exit(n)` into exactly that call (`handle` -> `Exit.exit`), so a
13
+ * command that printed its `--json` document and then chose a nonzero status
14
+ * sent a piped reader the first 64 KiB and nothing else: a document cut
15
+ * mid-string under an exit status that looked like an ordinary refusal. A
16
+ * terminal is written synchronously, which is why the same command looked
17
+ * complete when run by hand.
18
+ *
19
+ * A zero-length write is queued behind every earlier one, so its callback runs
20
+ * only after they have all completed. A reader that has gone away (`| head -1`)
21
+ * makes the write fail, which resolves too: there is nobody left to lose
22
+ * output for.
23
+ */
24
+ async function drainStdio(streams = [process.stdout, process.stderr]) {
25
+ await Promise.all(streams.map(drainWritable));
26
+ }
27
+ function drainWritable(stream) {
28
+ if (!stream || stream.destroyed || !stream.writable || stream.writableLength === 0) {
29
+ return Promise.resolve();
30
+ }
31
+ return new Promise((resolve) => {
32
+ const done = () => {
33
+ stream.off('close', done);
34
+ stream.off('error', done);
35
+ resolve();
36
+ };
37
+ stream.once('close', done);
38
+ stream.once('error', done);
39
+ try {
40
+ stream.write('', () => done());
41
+ }
42
+ catch {
43
+ done();
44
+ }
45
+ });
46
+ }
@@ -1,6 +1,27 @@
1
+ import { type ProfileSelection, type ProfileSelectionSource } from '@skrr-ai/auth-core';
1
2
  /** Default profile when no profile flag or environment override is present. */
2
3
  export declare const DEFAULT_PROFILE = "default";
3
- export declare function setActiveProfile(profile: string): void;
4
+ /**
5
+ * Wire the profile from the ONE selection rule both binaries share
6
+ * (`resolveProfileSelection` in auth-core: `--profile` > `OVERSKY_PROFILE` >
7
+ * `<root>/profile.lock` > `default`, OSK-22299). Throws the grammar's message
8
+ * for an invalid flag or environment value.
9
+ */
10
+ export declare function selectActiveProfile(flag: string | null | undefined): ProfileSelection;
11
+ /** How the active profile was chosen, for diagnostics that name it. */
12
+ export declare function getActiveProfileSelection(): ProfileSelection;
13
+ /**
14
+ * The profile a `skrrd` child must be told to act on, always passed explicitly
15
+ * (`explicitProfileArgs`, `default` included).
16
+ *
17
+ * A `--profile` in the forwarded argv wins. Otherwise a process that already
18
+ * chose (every `BaseCommand`) passes what it chose, and a thin wrapper that
19
+ * extends oclif's `Command` and never ran `init()` resolves by the shared rule
20
+ * now, so it lands where `skrrd` would have — but says so instead of leaving
21
+ * the child to re-derive it (OSK-22298).
22
+ */
23
+ export declare function profileForChildProcess(argv?: readonly string[]): string;
24
+ export declare function setActiveProfile(profile: string, source?: ProfileSelectionSource): void;
4
25
  /**
5
26
  * Whether the profile has been chosen for this process.
6
27
  *
@@ -34,6 +34,9 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.DEFAULT_PROFILE = void 0;
37
+ exports.selectActiveProfile = selectActiveProfile;
38
+ exports.getActiveProfileSelection = getActiveProfileSelection;
39
+ exports.profileForChildProcess = profileForChildProcess;
37
40
  exports.setActiveProfile = setActiveProfile;
38
41
  exports.isProfileResolved = isProfileResolved;
39
42
  exports.getActiveProfile = getActiveProfile;
@@ -146,8 +149,44 @@ let _availability = null;
146
149
  let _activeProfile = exports.DEFAULT_PROFILE;
147
150
  /** True once a caller has chosen, so a writer can tell "default" from "unset". */
148
151
  let _profileResolved = false;
149
- function setActiveProfile(profile) {
152
+ /** How `_activeProfile` was chosen; `default` until a caller says otherwise. */
153
+ let _activeProfileSource = 'default';
154
+ /**
155
+ * Wire the profile from the ONE selection rule both binaries share
156
+ * (`resolveProfileSelection` in auth-core: `--profile` > `OVERSKY_PROFILE` >
157
+ * `<root>/profile.lock` > `default`, OSK-22299). Throws the grammar's message
158
+ * for an invalid flag or environment value.
159
+ */
160
+ function selectActiveProfile(flag) {
161
+ const selection = (0, auth_core_1.resolveProfileSelection)({ flag });
162
+ setActiveProfile(selection.profile, selection.source);
163
+ return selection;
164
+ }
165
+ /** How the active profile was chosen, for diagnostics that name it. */
166
+ function getActiveProfileSelection() {
167
+ return { profile: _activeProfile, source: _activeProfileSource };
168
+ }
169
+ /**
170
+ * The profile a `skrrd` child must be told to act on, always passed explicitly
171
+ * (`explicitProfileArgs`, `default` included).
172
+ *
173
+ * A `--profile` in the forwarded argv wins. Otherwise a process that already
174
+ * chose (every `BaseCommand`) passes what it chose, and a thin wrapper that
175
+ * extends oclif's `Command` and never ran `init()` resolves by the shared rule
176
+ * now, so it lands where `skrrd` would have — but says so instead of leaving
177
+ * the child to re-derive it (OSK-22298).
178
+ */
179
+ function profileForChildProcess(argv) {
180
+ const fromArgv = argv ? resolveProfileFromArgv(argv) : null;
181
+ if (fromArgv)
182
+ return (0, auth_core_1.resolveProfileSelection)({ flag: fromArgv }).profile;
183
+ if (_profileResolved)
184
+ return _activeProfile;
185
+ return (0, auth_core_1.resolveProfileSelection)().profile;
186
+ }
187
+ function setActiveProfile(profile, source = profile && profile !== exports.DEFAULT_PROFILE ? 'flag' : 'default') {
150
188
  _profileResolved = true;
189
+ _activeProfileSource = source;
151
190
  if (profile && profile.length > 0)
152
191
  _activeProfile = profile;
153
192
  // The machineUuid the CLI sends (first-party harness broker) is per profile,
@@ -5,6 +5,7 @@ exports.describeUnreadyLocalDaemon = describeUnreadyLocalDaemon;
5
5
  exports.reportLocalDaemonAfterHandoff = reportLocalDaemonAfterHandoff;
6
6
  const exec_runtime_binary_1 = require("./exec-runtime-binary");
7
7
  const managed_instruction_local_1 = require("./managed-instruction-local");
8
+ const auth_core_1 = require("@skrr-ai/auth-core");
8
9
  const keychain_1 = require("./keychain");
9
10
  const config_1 = require("./config");
10
11
  const runtime_start_verification_1 = require("./runtime-start-verification");
@@ -14,12 +15,9 @@ function defaultDeps() {
14
15
  return {
15
16
  inspect: () => (0, managed_instruction_local_1.inspectLocalInstructionDaemon)((0, keychain_1.getActiveProfile)(), (0, config_1.loadConfig)().baseURL),
16
17
  status: async () => {
17
- const profile = (0, keychain_1.getActiveProfile)();
18
- const args = [
19
- 'status',
20
- '--json',
21
- ...(profile !== keychain_1.DEFAULT_PROFILE ? ['--profile', profile] : []),
22
- ];
18
+ // Explicit for `default` too, so the probe reads the profile this
19
+ // process signed in to rather than whichever one a lock names (OSK-22298).
20
+ const args = ['status', '--json', ...(0, auth_core_1.explicitProfileArgs)((0, keychain_1.profileForChildProcess)())];
23
21
  try {
24
22
  const out = await (0, exec_runtime_binary_1.execRuntimeBinaryCapture)(args, { timeoutMs: 15_000 });
25
23
  return { stdout: out.stdout, code: out.code };
@@ -12,6 +12,7 @@ exports.describeStoreSkillMiss = describeStoreSkillMiss;
12
12
  exports.daemonPredates = daemonPredates;
13
13
  exports.summarizeSkillActionImport = summarizeSkillActionImport;
14
14
  const data_provider_1 = require("@skrr-ai/data-provider");
15
+ const auth_core_1 = require("@skrr-ai/auth-core");
15
16
  const instruction_input_1 = require("./instruction-input");
16
17
  /**
17
18
  * Which machine to ask, or why there is no single answer.
@@ -55,7 +56,9 @@ function isUserInvocable(skill) {
55
56
  */
56
57
  function daemonRestartCommand(daemonId) {
57
58
  const profile = daemonId ? (0, instruction_input_1.parseDaemonId)(daemonId)?.profile : undefined;
58
- return profile && profile !== 'default'
59
+ // Named whenever a bare command would resolve elsewhere, which includes a
60
+ // `profile.lock` naming another profile (OSK-22299), not only non-default.
61
+ return profile && !(0, auth_core_1.profileIsImplicit)(profile)
59
62
  ? `skrr daemon restart --profile ${profile}`
60
63
  : 'skrr daemon restart';
61
64
  }