@skrr-ai/cli 0.1.170 → 0.1.172

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 (46) hide show
  1. package/dist/commands/agents/always-on/recovery-close.d.ts +4 -0
  2. package/dist/commands/agents/always-on/recovery-close.js +5 -1
  3. package/dist/commands/agents/always-on/recovery-review.js +29 -2
  4. package/dist/commands/harnesses/models.d.ts +12 -0
  5. package/dist/commands/harnesses/models.js +14 -2
  6. package/dist/commands/harnesses/rollouts/grant.d.ts +21 -0
  7. package/dist/commands/harnesses/rollouts/grant.js +56 -0
  8. package/dist/commands/harnesses/rollouts/list.d.ts +24 -0
  9. package/dist/commands/harnesses/rollouts/list.js +87 -0
  10. package/dist/commands/harnesses/rollouts/revoke.d.ts +22 -0
  11. package/dist/commands/harnesses/rollouts/revoke.js +56 -0
  12. package/dist/commands/machines/hosted/exec.d.ts +19 -0
  13. package/dist/commands/machines/hosted/exec.js +59 -5
  14. package/dist/commands/machines/hosted/list.js +8 -1
  15. package/dist/commands/machines/hosted/start.js +10 -1
  16. package/dist/lib/first-party-harness-broker.js +6 -0
  17. package/dist/lib/harness-tiers.d.ts +6 -4
  18. package/dist/lib/harness-tiers.js +12 -10
  19. package/dist/lib/hosted-machines.d.ts +13 -0
  20. package/dist/lib/hosted-machines.js +34 -1
  21. package/dist/lib/provider-rollouts.d.ts +58 -0
  22. package/dist/lib/provider-rollouts.js +23 -0
  23. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/codex-model-catalog.cjs +8 -0
  24. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/codex-model-catalog.d.cts +23 -0
  25. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/codex-model-catalog.json +2381 -0
  26. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessTrust.d.ts +11 -2
  27. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessTrust.js +1 -5
  28. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/inferenceBrokerHarnesses.d.ts +165 -0
  29. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/inferenceBrokerHarnesses.js +132 -0
  30. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessTrust.d.ts +11 -2
  31. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessTrust.js +1 -5
  32. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.d.ts +165 -0
  33. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/inferenceBrokerHarnesses.js +203 -0
  34. package/dist/node_modules/@skrr-ai/auth-core/package.json +14 -0
  35. package/dist/node_modules/@skrr-ai/data-provider/index.js +11600 -11591
  36. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.d.ts +1 -1
  37. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.js +4 -0
  38. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.d.ts +58 -1
  39. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +171 -61
  40. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.d.ts +1 -1
  41. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.js +1 -1
  42. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.d.ts +58 -1
  43. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +217 -88
  44. package/dist/node_modules/@skrr-ai/inference-broker/package.json +1 -1
  45. package/oclif.manifest.json +298 -5
  46. package/package.json +5 -2
@@ -8,6 +8,10 @@ import { BaseCommand } from '../../../base-command';
8
8
  * Duty re-decides at its next Check, from what it finds then. Closing says nothing about effects: anything the turn
9
9
  * already did stays done.
10
10
  *
11
+ * A Run that was applying its result under an effect boundary (OSK-24399 F4) is closed the same way, once the worker
12
+ * applying it has let its lease lapse: what it applied with a receipt stays applied and nothing more is applied. The
13
+ * ref then names the boundary, and the close records which effect classes its receipts had settled.
14
+ *
11
15
  * `--hold` is the ref `recovery-review <agent-id> <run-id>` prints. It binds the close to the hold you read: if the Run
12
16
  * was held again since, the server refuses. The server also requires you to be the Agent's owner signed in as a person
13
17
  * (`skrr login`; a personal access token never reaches the route), that you can see the review, and that the machine
@@ -12,13 +12,17 @@ const base_command_1 = require("../../../base-command");
12
12
  * Duty re-decides at its next Check, from what it finds then. Closing says nothing about effects: anything the turn
13
13
  * already did stays done.
14
14
  *
15
+ * A Run that was applying its result under an effect boundary (OSK-24399 F4) is closed the same way, once the worker
16
+ * applying it has let its lease lapse: what it applied with a receipt stays applied and nothing more is applied. The
17
+ * ref then names the boundary, and the close records which effect classes its receipts had settled.
18
+ *
15
19
  * `--hold` is the ref `recovery-review <agent-id> <run-id>` prints. It binds the close to the hold you read: if the Run
16
20
  * was held again since, the server refuses. The server also requires you to be the Agent's owner signed in as a person
17
21
  * (`skrr login`; a personal access token never reaches the route), that you can see the review, and that the machine
18
22
  * that ran the turn confirmed it stopped. Nothing about who you are is taken from the command line.
19
23
  */
20
24
  class AgentsAlwaysOnRecoveryClose extends base_command_1.BaseCommand {
21
- static description = 'Close one held Duty result as the Agent owner: the Run ends cancelled, its held result is not applied, and the Duty re-decides at its next Check. Its effects stay unknown';
25
+ static description = 'Close one held Duty result as the Agent owner: the Run ends cancelled, nothing more of its result is applied, and the Duty re-decides at its next Check. Effects without a receipt stay unknown';
22
26
  static examples = [
23
27
  '<%= config.bin %> agents always-on recovery-close <agent-id> <run-id> --hold <hold-ref>',
24
28
  '<%= config.bin %> agents always-on recovery-close <agent-id> <run-id> --hold <hold-ref> --json',
@@ -65,6 +65,9 @@ class AgentsAlwaysOnRecoveryReview extends base_command_1.BaseCommand {
65
65
  this.log(`Status: ${review.status}; generation: ${review.generation ?? 'unknown'}; attempt: ${review.attempt ?? 'unknown'}`);
66
66
  this.log(`Recovery: ${review.hold}; stored result: ${review.result}`);
67
67
  this.log(`Executor: ${review.executor}; effects: ${review.effects}`);
68
+ const receipts = receiptLine(review);
69
+ if (receipts)
70
+ this.log(receipts);
68
71
  this.log(INTEGRITY_CAVEAT);
69
72
  for (const line of closeLines(args.id, review))
70
73
  this.log(line);
@@ -138,9 +141,13 @@ exports.default = AgentsAlwaysOnRecoveryReview;
138
141
  * server, or a hold this server cannot close: no command is offered that would be refused.
139
142
  */
140
143
  function closeLines(agentId, review) {
144
+ // Only a server that names the receipts can close a Run at its effect boundary (OSK-24399 F4).
145
+ const boundary = review.effectReceipts !== undefined;
141
146
  if (review.close === 'available' && isNonEmptyString(review.holdRef)) {
142
147
  return [
143
- 'Close: available. Closing ends the Run without applying its held result; the Duty re-decides at its next Check.',
148
+ boundary
149
+ ? 'Close: available. Closing ends the Run: what it applied with a receipt stays applied, and nothing more of its result is applied. The Duty re-decides at its next Check.'
150
+ : 'Close: available. Closing ends the Run without applying its held result; the Duty re-decides at its next Check.',
144
151
  `→ skrr agents always-on recovery-close ${agentId} ${review.runId} --hold ${review.holdRef}`,
145
152
  ];
146
153
  }
@@ -151,11 +158,31 @@ function closeLines(agentId, review) {
151
158
  }
152
159
  if (review.close === 'effect_boundary') {
153
160
  return [
154
- 'Close: not available. This Run started applying its result, and closing it would hide which effects happened.',
161
+ boundary
162
+ ? 'Close: not yet. The worker applying this result may still hold the Run; read this again once its lease has lapsed (a few minutes).'
163
+ : 'Close: not available. This Run started applying its result, and closing it would hide which effects happened.',
155
164
  ];
156
165
  }
157
166
  return [];
158
167
  }
168
+ /** What the boundary's receipts settled, by class. Every class not named stays unknown, which the line says. */
169
+ function receiptLine(review) {
170
+ const receipts = review.effectReceipts;
171
+ if (!receipts)
172
+ return undefined;
173
+ const applied = Array.isArray(receipts.applied) ? receipts.applied : [];
174
+ const none = Array.isArray(receipts.none) ? receipts.none : [];
175
+ if (applied.length === 0 && none.length === 0)
176
+ return 'Receipts: none yet. Every effect of this result is unknown.';
177
+ return [
178
+ 'Receipts:',
179
+ applied.length ? `applied ${applied.join(', ')};` : '',
180
+ none.length ? `owed nothing for ${none.join(', ')}.` : '',
181
+ 'Any other effect is unknown.',
182
+ ]
183
+ .filter(Boolean)
184
+ .join(' ');
185
+ }
159
186
  /** One line per held result: what a person needs to choose which one to open. */
160
187
  function reviewLine(review) {
161
188
  const stored = review.resultCapture === 'unsealable'
@@ -7,11 +7,23 @@ import { BaseCommand } from '../../base-command';
7
7
  * does not recognise still prints, verbatim, rather than vanishing.
8
8
  */
9
9
  export type HarnessModelSourceReason = 'no_live_catalog_for_harness' | 'daemon_offline' | 'live_catalog_unsupported' | 'live_probe_failed';
10
+ /**
11
+ * Managed inference refused this harness's PROVIDER outright (OSK-24530), so it
12
+ * admits no model at all. `code` is `provider_not_allowed` (the payer's policy)
13
+ * or `provider_not_in_rollout` (not released to this account yet); `message`
14
+ * is the server's sentence and names the provider.
15
+ */
16
+ export interface HarnessManagedRefusal {
17
+ code?: string;
18
+ provider?: string;
19
+ message?: string;
20
+ }
10
21
  export interface HarnessModelsReport {
11
22
  provider?: string | null;
12
23
  source?: string;
13
24
  sourceReason?: HarnessModelSourceReason | string;
14
25
  sourceDetail?: string;
26
+ managedRefusal?: HarnessManagedRefusal;
15
27
  /** The harness row's own stored default model; empty when unset. */
16
28
  defaultModel?: string | null;
17
29
  /** The harness row's own stored default effort; empty when unset. */
@@ -81,12 +81,24 @@ function describeModelSource(report) {
81
81
  }
82
82
  /** What to print when the answer carries no models at all. */
83
83
  function describeEmptyModels(report) {
84
+ const refusal = report?.managedRefusal;
85
+ if (refusal) {
86
+ // Empty because managed inference refuses the provider itself, which no
87
+ // model choice can fix. Say which gate, by its code, beside the sentence.
88
+ const code = refusal.code ? ` (${refusal.code})` : '';
89
+ const sentence = refusal.message ||
90
+ `Managed inference refuses ${refusal.provider || report?.provider || 'this provider'}.`;
91
+ const next = refusal.code === 'provider_not_in_rollout'
92
+ ? ' A platform admin can release it to you with `skrr harnesses rollouts grant`.'
93
+ : '';
94
+ return `managed — no models${code}: ${sentence}${next}`;
95
+ }
84
96
  const resolved = report?.provider;
85
97
  if (!resolved) {
86
98
  return 'This harness resolved to no provider, so no model list could be built. That is a defect, not a configuration problem — report it with the harness id.';
87
99
  }
88
- // An empty answer is always curated: a live or managed answer with no models
89
- // degrades to curated server-side. So the reason is what explains it — for
100
+ // Past a managed refusal, an empty answer is curated: a live or managed answer
101
+ // with no models degrades to curated server-side. So the reason is what explains it — for
90
102
  // opencode it is usually the live probe, which the old message never named.
91
103
  return `No models are listed for ${resolved}: skrr's curated list has no entries for it, and ${curatedReasonClause(report)}. ${exports.CURATED_ACCEPTS_ANY_ID}`;
92
104
  }
@@ -0,0 +1,21 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ /**
3
+ * Release a managed inference provider to one account (OSK-24530).
4
+ *
5
+ * Takes effect on that account's next turn, with no deploy. Idempotent: an
6
+ * account that already holds an active grant keeps it, unchanged.
7
+ */
8
+ export default class HarnessesRolloutsGrant extends BaseCommand {
9
+ static aliases: string[];
10
+ static description: string;
11
+ static examples: string[];
12
+ static args: {
13
+ provider: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
14
+ };
15
+ static flags: {
16
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
17
+ user: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
18
+ reason: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
19
+ };
20
+ run(): Promise<void>;
21
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const base_command_1 = require("../../../base-command");
5
+ const provider_rollouts_1 = require("../../../lib/provider-rollouts");
6
+ /**
7
+ * Release a managed inference provider to one account (OSK-24530).
8
+ *
9
+ * Takes effect on that account's next turn, with no deploy. Idempotent: an
10
+ * account that already holds an active grant keeps it, unchanged.
11
+ */
12
+ class HarnessesRolloutsGrant extends base_command_1.BaseCommand {
13
+ static aliases = ['harnesses:rollouts:grant'];
14
+ static description = 'Release a managed inference provider to one account (platform admins)';
15
+ static examples = [
16
+ '<%= config.bin %> harnesses rollouts grant copilot-sdk --user me --reason "Owner probe of the Copilot SDK backend"',
17
+ '<%= config.bin %> harnesses rollouts grant copilot-sdk --user <user-id> --reason "Design partner pilot" --json',
18
+ ];
19
+ static args = {
20
+ provider: core_1.Args.string({
21
+ ignoreStdin: true,
22
+ description: 'Provider slug (for example copilot-sdk)',
23
+ required: true,
24
+ }),
25
+ };
26
+ static flags = {
27
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
28
+ user: core_1.Flags.string({ description: 'User id to release it to, or `me`', required: true }),
29
+ reason: core_1.Flags.string({
30
+ description: 'Why (8-512 characters). Recorded on the grant with your account.',
31
+ required: true,
32
+ }),
33
+ };
34
+ async run() {
35
+ this.requireAuth();
36
+ const { args, flags } = await this.parse(HarnessesRolloutsGrant);
37
+ let result;
38
+ try {
39
+ result = await (0, provider_rollouts_1.grantProviderRollout)(args.provider, { type: 'user', id: flags.user }, flags.reason);
40
+ }
41
+ catch (err) {
42
+ this.handleApiError(err);
43
+ return;
44
+ }
45
+ if (flags.json) {
46
+ this.log(JSON.stringify(result, null, 2));
47
+ return;
48
+ }
49
+ const { grant } = result;
50
+ this.log(result.created
51
+ ? `Released ${grant.provider} to user ${grant.subjectId} (grant ${grant.grantId}). Their next turn on it can run on managed inference.`
52
+ : `User ${grant.subjectId} already holds ${grant.provider} (grant ${grant.grantId}); nothing changed.`);
53
+ this.log('The payer’s managed inference policy must still permit the provider; this grant does not widen it.');
54
+ }
55
+ }
56
+ exports.default = HarnessesRolloutsGrant;
@@ -0,0 +1,24 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ import { type ProviderRolloutGrant } from '../../../lib/provider-rollouts';
3
+ /** One table row per grant; `revoked <when>` keeps a withdrawn release readable. */
4
+ export declare function rolloutRows(grants: ProviderRolloutGrant[]): Array<Record<string, string>>;
5
+ /**
6
+ * Who a managed inference provider has been released to (OSK-24530).
7
+ *
8
+ * Platform admins only. A provider the server lists here is closed on managed
9
+ * inference to every account that holds no active grant, whatever the payer's
10
+ * policy permits.
11
+ */
12
+ export default class HarnessesRolloutsList extends BaseCommand {
13
+ static aliases: string[];
14
+ static description: string;
15
+ static examples: string[];
16
+ static flags: {
17
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
+ provider: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
19
+ user: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
20
+ 'include-revoked': import("@oclif/core/interfaces").BooleanFlag<boolean>;
21
+ limit: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
22
+ };
23
+ run(): Promise<void>;
24
+ }
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rolloutRows = rolloutRows;
4
+ const core_1 = require("@oclif/core");
5
+ const base_command_1 = require("../../../base-command");
6
+ const format_1 = require("../../../lib/format");
7
+ const list_output_1 = require("../../../lib/list-output");
8
+ const provider_rollouts_1 = require("../../../lib/provider-rollouts");
9
+ /** One table row per grant; `revoked <when>` keeps a withdrawn release readable. */
10
+ function rolloutRows(grants) {
11
+ return grants.map((grant) => ({
12
+ grant: grant.grantId,
13
+ provider: grant.provider,
14
+ subject: `${grant.subjectType}:${grant.subjectId}`,
15
+ status: grant.active ? 'active' : `revoked ${grant.revokedAt ?? ''}`.trim(),
16
+ by: grant.active ? (grant.grantedByUserId ?? '-') : (grant.revokedByUserId ?? '-'),
17
+ reason: grant.active ? grant.grantReason : (grant.revokeReason ?? '-'),
18
+ }));
19
+ }
20
+ /**
21
+ * Who a managed inference provider has been released to (OSK-24530).
22
+ *
23
+ * Platform admins only. A provider the server lists here is closed on managed
24
+ * inference to every account that holds no active grant, whatever the payer's
25
+ * policy permits.
26
+ */
27
+ class HarnessesRolloutsList extends base_command_1.BaseCommand {
28
+ static aliases = ['harnesses:rollouts:list'];
29
+ static description = 'List who a managed inference provider has been released to (platform admins)';
30
+ static examples = [
31
+ '<%= config.bin %> harnesses rollouts list',
32
+ '<%= config.bin %> harnesses rollouts list --provider copilot-sdk',
33
+ '<%= config.bin %> harnesses rollouts list --user <user-id> --include-revoked --json',
34
+ ];
35
+ static flags = {
36
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
37
+ provider: core_1.Flags.string({ description: 'Only this provider (for example copilot-sdk)' }),
38
+ user: core_1.Flags.string({ description: 'Only grants naming this user id' }),
39
+ 'include-revoked': core_1.Flags.boolean({
40
+ description: 'Include withdrawn grants (kept as the record of who released and withdrew it)',
41
+ }),
42
+ limit: core_1.Flags.integer({ description: 'At most this many grants (default 50, up to 200)' }),
43
+ };
44
+ async run() {
45
+ this.requireAuth();
46
+ const { flags } = await this.parse(HarnessesRolloutsList);
47
+ let result;
48
+ try {
49
+ result = await (0, provider_rollouts_1.listProviderRollouts)({
50
+ provider: flags.provider,
51
+ subjectId: flags.user,
52
+ includeRevoked: flags['include-revoked'],
53
+ limit: flags.limit,
54
+ });
55
+ }
56
+ catch (err) {
57
+ this.handleApiError(err);
58
+ return;
59
+ }
60
+ if (flags.json) {
61
+ this.printJsonResult((0, list_output_1.listResult)(result.grants));
62
+ return;
63
+ }
64
+ const providers = result.providers
65
+ .map((entry) => `${entry.displayName} (${entry.provider})`)
66
+ .join(', ');
67
+ this.log(providers
68
+ ? `Released per account on managed inference: ${providers}. Anyone without an active grant is refused.`
69
+ : 'No provider is in the managed inference rollout; policy alone decides every provider.');
70
+ if (result.grants.length === 0) {
71
+ this.log(flags['include-revoked']
72
+ ? 'No grants match.'
73
+ : 'No active grants match, so these providers are closed to everyone matched.');
74
+ return;
75
+ }
76
+ this.log('');
77
+ (0, format_1.renderTable)(rolloutRows(result.grants), [
78
+ { key: 'grant', header: 'GRANT' },
79
+ { key: 'provider', header: 'PROVIDER' },
80
+ { key: 'subject', header: 'SUBJECT' },
81
+ { key: 'status', header: 'STATUS' },
82
+ { key: 'by', header: 'BY' },
83
+ { key: 'reason', header: 'REASON', maxWidth: 40 },
84
+ ], (line) => this.log(line));
85
+ }
86
+ }
87
+ exports.default = HarnessesRolloutsList;
@@ -0,0 +1,22 @@
1
+ import { BaseCommand } from '../../../base-command';
2
+ /**
3
+ * Withdraw a managed inference provider from one account (OSK-24530).
4
+ *
5
+ * The next turn on it is refused, naming the provider. A turn already running
6
+ * keeps the lease it was admitted with until that lease ends. The grant is kept
7
+ * as the record of who released and withdrew it.
8
+ */
9
+ export default class HarnessesRolloutsRevoke extends BaseCommand {
10
+ static aliases: string[];
11
+ static description: string;
12
+ static examples: string[];
13
+ static args: {
14
+ provider: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
15
+ };
16
+ static flags: {
17
+ json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
18
+ user: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
19
+ reason: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
20
+ };
21
+ run(): Promise<void>;
22
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@oclif/core");
4
+ const base_command_1 = require("../../../base-command");
5
+ const provider_rollouts_1 = require("../../../lib/provider-rollouts");
6
+ /**
7
+ * Withdraw a managed inference provider from one account (OSK-24530).
8
+ *
9
+ * The next turn on it is refused, naming the provider. A turn already running
10
+ * keeps the lease it was admitted with until that lease ends. The grant is kept
11
+ * as the record of who released and withdrew it.
12
+ */
13
+ class HarnessesRolloutsRevoke extends base_command_1.BaseCommand {
14
+ static aliases = ['harnesses:rollouts:revoke'];
15
+ static description = 'Withdraw a managed inference provider from one account (platform admins)';
16
+ static examples = [
17
+ '<%= config.bin %> harnesses rollouts revoke copilot-sdk --user me --reason "Probe finished"',
18
+ '<%= config.bin %> harnesses rollouts revoke copilot-sdk --user <user-id> --reason "Pilot ended" --json',
19
+ ];
20
+ static args = {
21
+ provider: core_1.Args.string({
22
+ ignoreStdin: true,
23
+ description: 'Provider slug (for example copilot-sdk)',
24
+ required: true,
25
+ }),
26
+ };
27
+ static flags = {
28
+ json: core_1.Flags.boolean({ description: 'Output as JSON' }),
29
+ user: core_1.Flags.string({ description: 'User id to withdraw it from, or `me`', required: true }),
30
+ reason: core_1.Flags.string({
31
+ description: 'Why (8-512 characters). Recorded on the grant with your account.',
32
+ required: true,
33
+ }),
34
+ };
35
+ async run() {
36
+ this.requireAuth();
37
+ const { args, flags } = await this.parse(HarnessesRolloutsRevoke);
38
+ let result;
39
+ try {
40
+ result = await (0, provider_rollouts_1.revokeProviderRollout)(args.provider, { type: 'user', id: flags.user }, flags.reason);
41
+ }
42
+ catch (err) {
43
+ this.handleApiError(err);
44
+ return;
45
+ }
46
+ if (flags.json) {
47
+ this.log(JSON.stringify(result, null, 2));
48
+ return;
49
+ }
50
+ for (const grant of result.revoked) {
51
+ this.log(`Withdrew ${grant.provider} from user ${grant.subjectId} (grant ${grant.grantId}). Their next turn on it is refused.`);
52
+ }
53
+ this.log('A turn already running keeps its lease until that lease ends.');
54
+ }
55
+ }
56
+ exports.default = HarnessesRolloutsRevoke;
@@ -1,4 +1,5 @@
1
1
  import { BaseCommand } from '../../../base-command';
2
+ import { type HostedMachineExecInput, type HostedMachineExecResponse } from '../../../lib/hosted-machines';
2
3
  /**
3
4
  * Split a raw argv at the first `--`.
4
5
  *
@@ -12,6 +13,7 @@ export declare function splitExecArgv(rawArgv: readonly string[]): {
12
13
  tail: string[] | null;
13
14
  };
14
15
  export default class HostedMachinesExec extends BaseCommand {
16
+ static summary: string;
15
17
  static description: string;
16
18
  static strict: boolean;
17
19
  static examples: string[];
@@ -23,9 +25,26 @@ export default class HostedMachinesExec extends BaseCommand {
23
25
  cwd: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
24
26
  language: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
25
27
  timeout: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
28
+ 'as-root': import("@oclif/core/interfaces").BooleanFlag<boolean>;
26
29
  'request-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
27
30
  workspace: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
28
31
  json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
29
32
  };
30
33
  run(): Promise<void>;
31
34
  }
35
+ /**
36
+ * The execute request body. `runAs` is sent only for `--as-root`; without it the
37
+ * server runs the command as the machine's workload user (OSK-24531).
38
+ */
39
+ export declare function buildHostedExecBody(input: {
40
+ command: string;
41
+ language?: HostedMachineExecInput['language'];
42
+ cwd?: string;
43
+ timeoutMs?: number;
44
+ asRoot?: boolean;
45
+ }): HostedMachineExecInput;
46
+ /**
47
+ * The line `exec` prints when the machine ran the command as root, or null.
48
+ * Read from what the server reports, not from the flag: it says what happened.
49
+ */
50
+ export declare function describeRootExecution(executedAs: HostedMachineExecResponse['executedAs']): string | null;
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.splitExecArgv = splitExecArgv;
4
+ exports.buildHostedExecBody = buildHostedExecBody;
5
+ exports.describeRootExecution = describeRootExecution;
4
6
  const core_1 = require("@oclif/core");
5
7
  const node_crypto_1 = require("node:crypto");
6
8
  const base_command_1 = require("../../../base-command");
@@ -21,12 +23,29 @@ function splitExecArgv(rawArgv) {
21
23
  return { head: rawArgv.slice(0, separator), tail: rawArgv.slice(separator + 1) };
22
24
  }
23
25
  class HostedMachinesExec extends base_command_1.BaseCommand {
24
- static description = 'Run a command inside a Hosted Machine';
26
+ static summary = 'Run a command inside a Hosted Machine';
27
+ // Who the command runs as, in the help a script author reads (OSK-24531). It
28
+ // used to run as root with HOME=/root, which on a current machine is the
29
+ // daemon's HOME (the launcher hands /root to the daemon's account), so the
30
+ // root-owned files it left there broke the daemon's next harness start.
31
+ static description = [
32
+ "Runs the command as the machine's workload user: the account its daemon runs harnesses as, " +
33
+ "which owns /home/user, with that account's own HOME, starting in /home/user. Files it creates " +
34
+ 'belong to that user, so the daemon and its harnesses can keep using them.',
35
+ '--as-root runs a shell command as root instead, for what needs root, such as installing a system ' +
36
+ 'package. Root gets a HOME that root alone owns: /root where root owns it, otherwise a root-only ' +
37
+ "directory the machine keeps for this. On current machines /root is the daemon's HOME, and a root " +
38
+ 'command writing there would leave files the daemon cannot use. The command starts in that HOME ' +
39
+ '(use --cwd to work elsewhere), and the output says it ran as root and names the HOME. What it ' +
40
+ 'creates is owned by root and the workload user cannot change it, so never start a harness with ' +
41
+ 'it. A machine that isolates its daemon credentials from the workload refuses it.',
42
+ ].join('\n\n');
25
43
  static strict = false;
26
44
  static examples = [
27
45
  '<%= config.bin %> machines hosted exec <machine-id> -- pwd',
28
46
  '<%= config.bin %> machines hosted exec <machine-id> --cwd /home/user -- ls -la',
29
47
  '<%= config.bin %> machines hosted exec <machine-id> --command "npm test" --json',
48
+ '<%= config.bin %> machines hosted exec <machine-id> --as-root -- apt-get install -y jq',
30
49
  ];
31
50
  // Declared so `exec --help` renders the positional ID and an ARGUMENTS
32
51
  // section like every sibling command (OSK-4869). The command still needs
@@ -48,6 +67,10 @@ class HostedMachinesExec extends base_command_1.BaseCommand {
48
67
  default: 'shell',
49
68
  }),
50
69
  timeout: core_1.Flags.string({ description: 'Execution timeout such as 30s, 5m' }),
70
+ 'as-root': core_1.Flags.boolean({
71
+ description: "Run as root instead of the workload user, with a HOME that is root's alone (never the daemon's). " +
72
+ 'Shell only; what it creates is owned by root.',
73
+ }),
51
74
  'request-id': core_1.Flags.string({
52
75
  description: 'Idempotency key. Reuse it after a lost response; the command will not run again.',
53
76
  }),
@@ -81,6 +104,9 @@ class HostedMachinesExec extends base_command_1.BaseCommand {
81
104
  if (!command.trim()) {
82
105
  this.error('Command is required. Use --command or pass it after --.', { exit: 2 });
83
106
  }
107
+ if (flags['as-root'] && flags.language !== 'shell') {
108
+ this.error('--as-root runs shell commands only.', { exit: 2 });
109
+ }
84
110
  let timeoutMs;
85
111
  try {
86
112
  timeoutMs = (0, hosted_machines_1.parseDurationMs)(flags.timeout, '--timeout');
@@ -88,12 +114,13 @@ class HostedMachinesExec extends base_command_1.BaseCommand {
88
114
  catch (err) {
89
115
  this.error(err.message, { exit: 1 });
90
116
  }
91
- const body = {
117
+ const body = buildHostedExecBody({
92
118
  command,
93
119
  language: flags.language,
94
- ...(flags.cwd ? { cwd: flags.cwd } : {}),
95
- ...(timeoutMs ? { timeoutMs } : {}),
96
- };
120
+ cwd: flags.cwd,
121
+ timeoutMs,
122
+ asRoot: flags['as-root'],
123
+ });
97
124
  let response;
98
125
  const requestId = flags['request-id'] || newRequestId();
99
126
  try {
@@ -121,6 +148,11 @@ class HostedMachinesExec extends base_command_1.BaseCommand {
121
148
  if (response.operation?.id) {
122
149
  process.stderr.write(`Operation: ${response.operation.id} (${response.operation.state}).\n`);
123
150
  }
151
+ // The escalation is said, not implied, and on stderr for the same reason
152
+ // as the notes above (OSK-24531).
153
+ const ranAs = describeRootExecution(response.executedAs);
154
+ if (ranAs)
155
+ process.stderr.write(`${ranAs}\n`);
124
156
  if (response.stdout)
125
157
  process.stdout.write(response.stdout);
126
158
  if (response.stderr)
@@ -136,6 +168,28 @@ class HostedMachinesExec extends base_command_1.BaseCommand {
136
168
  }
137
169
  }
138
170
  exports.default = HostedMachinesExec;
171
+ /**
172
+ * The execute request body. `runAs` is sent only for `--as-root`; without it the
173
+ * server runs the command as the machine's workload user (OSK-24531).
174
+ */
175
+ function buildHostedExecBody(input) {
176
+ return {
177
+ command: input.command,
178
+ ...(input.language ? { language: input.language } : {}),
179
+ ...(input.cwd ? { cwd: input.cwd } : {}),
180
+ ...(input.timeoutMs ? { timeoutMs: input.timeoutMs } : {}),
181
+ ...(input.asRoot ? { runAs: 'root' } : {}),
182
+ };
183
+ }
184
+ /**
185
+ * The line `exec` prints when the machine ran the command as root, or null.
186
+ * Read from what the server reports, not from the flag: it says what happened.
187
+ */
188
+ function describeRootExecution(executedAs) {
189
+ if (executedAs?.user !== 'root')
190
+ return null;
191
+ return `Ran as root with HOME=${executedAs.home}.`;
192
+ }
139
193
  function newRequestId() {
140
194
  return `skrr-machine-exec:${Date.now()}:${(0, node_crypto_1.randomBytes)(6).toString('hex')}`;
141
195
  }
@@ -19,7 +19,14 @@ class HostedMachinesList extends base_command_1.BaseCommand {
19
19
  description: 'Include complete session histories in JSON (may be large)',
20
20
  }),
21
21
  workspace: core_1.Flags.string({ description: 'Workspace scope' }),
22
- limit: core_1.Flags.integer({ description: 'Max sessions to return', default: 50 }),
22
+ // The API serves at most 100 per request; refuse more here, in words,
23
+ // instead of sending it and printing "Invalid Hosted Machine request.".
24
+ limit: core_1.Flags.integer({
25
+ description: 'Max sessions to return (1-100)',
26
+ default: 50,
27
+ min: 1,
28
+ max: 100,
29
+ }),
23
30
  };
24
31
  async run() {
25
32
  this.requireAuth();
@@ -80,6 +80,9 @@ class HostedMachinesStart extends base_command_1.BaseCommand {
80
80
  };
81
81
  let session;
82
82
  let operation;
83
+ // Set once the machine is ready and only the repository attach is left.
84
+ // Before that, a failure means the MACHINE failed, not that it is stranded.
85
+ let readyForAttach = false;
83
86
  try {
84
87
  const response = await (0, hosted_machines_1.startHostedMachine)(body);
85
88
  session = response.session;
@@ -87,6 +90,7 @@ class HostedMachinesStart extends base_command_1.BaseCommand {
87
90
  const id = (0, hosted_machines_1.hostedMachineId)(session);
88
91
  if (flags.repo) {
89
92
  session = await this.waitReadyForFollowup(id, flags.workspace, flags.interval, timeoutMs, flags.json);
93
+ readyForAttach = true;
90
94
  const attachResponse = await (0, hosted_machines_1.attachHostedMachineRepo)(id, {
91
95
  installationId: flags['installation-id'],
92
96
  repoFullName: flags.repo,
@@ -128,7 +132,12 @@ class HostedMachinesStart extends base_command_1.BaseCommand {
128
132
  // what exists. No retry line, because there is no CLI command that
129
133
  // attaches a repo to an existing machine — offering one would be worse
130
134
  // than offering none.
131
- const strandedId = (0, hosted_machines_1.hostedMachineId)(session);
135
+ //
136
+ // Only after the machine was READY. A wait that ends because the machine
137
+ // reached `failed` (a daemon that never registered, OSK-24523) used to land
138
+ // here too, and told the reader a failed machine "was created and is
139
+ // running" — hiding the failure reason the wait had just read.
140
+ const strandedId = readyForAttach ? (0, hosted_machines_1.hostedMachineId)(session) : '';
132
141
  if (strandedId) {
133
142
  const cause = (0, hosted_machines_1.formatHostedMachineApiError)(err, { bin: this.config.bin }) ||
134
143
  err?.message ||
@@ -68,6 +68,7 @@ exports.managedRenewalStoppedLine = managedRenewalStoppedLine;
68
68
  exports.managedAcquisitionFailure = managedAcquisitionFailure;
69
69
  const node_crypto_1 = require("node:crypto");
70
70
  const auth_core_1 = require("@skrr-ai/auth-core");
71
+ const inference_broker_harnesses_1 = require("@skrr-ai/auth-core/inference-broker-harnesses");
71
72
  const inference_broker_1 = require("@skrr-ai/inference-broker");
72
73
  const api_fetch_1 = require("./api-fetch");
73
74
  const auth_storage_1 = require("./auth-storage");
@@ -594,6 +595,10 @@ async function releaseLease(input, fetchImpl, log) {
594
595
  * `workspace:<spaceId>` — a tenant that does not exist. The server cannot tell the
595
596
  * two id namespaces apart, so not sending one is the only defence.
596
597
  *
598
+ * `audience: 'inference'` is what lets the relay accept it (OSK-24515): this token
599
+ * stays in the broker, and the relay refuses the session-audience token a harness
600
+ * holds for `skrr`.
601
+ *
597
602
  * The response's `expiresAt` used to be dropped on the floor. It is the only
598
603
  * statement of when this capability dies — the TTL is server env, so the CLI
599
604
  * cannot derive it — and without it there is nothing to schedule a refresh
@@ -609,6 +614,7 @@ async function mintSessionToken(input, api, signal) {
609
614
  actorId: input.actorId,
610
615
  agentId: input.agentId,
611
616
  processStartId: input.processStartId,
617
+ audience: inference_broker_harnesses_1.INFERENCE_RELAY_AUDIENCE,
612
618
  },
613
619
  ...(signal ? { signal } : {}),
614
620
  });