@skrr-ai/cli 0.1.179 → 0.1.181

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 (66) hide show
  1. package/dist/commands/code/index.js +5 -0
  2. package/dist/commands/diagnostics/inference-smoke.d.ts +13 -0
  3. package/dist/commands/diagnostics/inference-smoke.js +50 -0
  4. package/dist/commands/harnesses/evaluations/evidence.d.ts +2 -0
  5. package/dist/commands/harnesses/evaluations/evidence.js +20 -0
  6. package/dist/commands/harnesses/evaluations/fixed-tool.d.ts +10 -0
  7. package/dist/commands/harnesses/evaluations/fixed-tool.js +189 -0
  8. package/dist/commands/harnesses/evaluations/platform-h9-turn.d.ts +13 -0
  9. package/dist/commands/harnesses/evaluations/platform-h9-turn.js +322 -0
  10. package/dist/commands/machines/hosted/identity-evaluations/issue.d.ts +12 -0
  11. package/dist/commands/machines/hosted/identity-evaluations/issue.js +40 -0
  12. package/dist/commands/machines/hosted/identity-evaluations/revoke.d.ts +11 -0
  13. package/dist/commands/machines/hosted/identity-evaluations/revoke.js +21 -0
  14. package/dist/commands/machines/hosted/identity-evaluations/show.d.ts +8 -0
  15. package/dist/commands/machines/hosted/identity-evaluations/show.js +20 -0
  16. package/dist/commands/machines/hosted/start.d.ts +1 -0
  17. package/dist/commands/machines/hosted/start.js +6 -0
  18. package/dist/lib/agent-model-check.d.ts +19 -0
  19. package/dist/lib/agent-model-check.js +10 -20
  20. package/dist/lib/agentic-stream.d.ts +3 -0
  21. package/dist/lib/agentic-stream.js +63 -1
  22. package/dist/lib/copilot-fixed-probe-runner.d.ts +72 -0
  23. package/dist/lib/copilot-fixed-probe-runner.js +213 -0
  24. package/dist/lib/copilot-fixed-probe.d.ts +61 -0
  25. package/dist/lib/copilot-fixed-probe.js +223 -0
  26. package/dist/lib/credential-resolver.d.ts +1 -0
  27. package/dist/lib/credential-resolver.js +5 -1
  28. package/dist/lib/first-party-harness-broker.d.ts +5 -10
  29. package/dist/lib/first-party-harness-broker.js +121 -50
  30. package/dist/lib/h9-platform-stream.d.ts +63 -0
  31. package/dist/lib/h9-platform-stream.js +317 -0
  32. package/dist/lib/h9-prior-stream.d.ts +44 -0
  33. package/dist/lib/h9-prior-stream.js +217 -0
  34. package/dist/lib/harness-evaluations.d.ts +85 -0
  35. package/dist/lib/harness-evaluations.js +8 -0
  36. package/dist/lib/hosted-identity-evaluations.d.ts +26 -0
  37. package/dist/lib/hosted-identity-evaluations.js +18 -0
  38. package/dist/lib/hosted-machines.d.ts +1 -0
  39. package/dist/lib/inference-overload-smoke-contract.d.ts +53 -0
  40. package/dist/lib/inference-overload-smoke-contract.js +192 -0
  41. package/dist/lib/inference-overload-smoke.d.ts +78 -0
  42. package/dist/lib/inference-overload-smoke.js +350 -0
  43. package/dist/lib/operator-probe-files.d.ts +6 -0
  44. package/dist/lib/operator-probe-files.js +68 -0
  45. package/dist/lib/platform-h9-plan.d.ts +47 -0
  46. package/dist/lib/platform-h9-plan.js +78 -0
  47. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/codex-model-catalog.json +150 -0
  48. package/dist/node_modules/@skrr-ai/data-provider/index.js +6 -6
  49. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.d.ts +3 -1
  50. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.js +23 -1
  51. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.d.ts +8 -0
  52. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-haiku-none.js +40 -0
  53. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.d.ts +2 -11
  54. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +31 -5
  55. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.d.ts +56 -0
  56. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/overload-smoke.js +277 -0
  57. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.d.ts +3 -1
  58. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.js +3 -1
  59. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.d.ts +8 -0
  60. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-haiku-none.js +20 -0
  61. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.d.ts +2 -11
  62. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +28 -4
  63. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.d.ts +56 -0
  64. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/overload-smoke.js +261 -0
  65. package/oclif.manifest.json +473 -1
  66. package/package.json +2 -2
@@ -0,0 +1,223 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FixedCopilotPermission = void 0;
4
+ exports.interactiveAdmission = interactiveAdmission;
5
+ exports.fixedCopilotCommand = fixedCopilotCommand;
6
+ exports.copilotPlatformScratchDirectory = copilotPlatformScratchDirectory;
7
+ exports.copilotPlatformScratchCommand = copilotPlatformScratchCommand;
8
+ const object = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
9
+ const exact = (value, keys) => JSON.stringify(Object.keys(value).sort()) === JSON.stringify([...keys].sort());
10
+ const text = (value) => typeof value === 'string' && /^[A-Za-z0-9][A-Za-z0-9_.:@-]{0,239}$/.test(value);
11
+ function interactiveAdmission(value) {
12
+ if (!object(value) ||
13
+ !exact(value, ['version', 'kind', 'sessionId', 'responseMessageId', 'generation']) ||
14
+ value.version !== 1 ||
15
+ value.kind !== 'interactive' ||
16
+ !text(value.sessionId) ||
17
+ !text(value.responseMessageId) ||
18
+ typeof value.generation !== 'string' ||
19
+ !/^[a-f0-9]{64}$/.test(value.generation))
20
+ throw new Error('PROBE_INTERACTIVE_ADMISSION_REQUIRED');
21
+ return { ...value };
22
+ }
23
+ function requireProbeNonce(nonce) {
24
+ if (!/^[a-f0-9]{32}$/.test(nonce))
25
+ throw new Error('PROBE_NONCE_INVALID');
26
+ }
27
+ function fixedCopilotCommand(nonce) {
28
+ requireProbeNonce(nonce);
29
+ return `printf '%s\\n' 'COPILOT-PROBE-${nonce}'`;
30
+ }
31
+ function copilotPlatformScratchDirectory(nonce) {
32
+ requireProbeNonce(nonce);
33
+ return `/tmp/osk-copilot-h9-${nonce}`;
34
+ }
35
+ /** Create a private, non-existing directory and remove it before reporting successful exit. */
36
+ function copilotPlatformScratchCommand(nonce) {
37
+ const scratch = copilotPlatformScratchDirectory(nonce);
38
+ const marker = `${scratch}/marker`;
39
+ return `(umask 077; mkdir -- '${scratch}' || exit; trap 'rm -f -- "${marker}"; rmdir -- "${scratch}"' EXIT; output=$(${fixedCopilotCommand(nonce)} | tee -- '${marker}') || exit; rm -- '${marker}' && rmdir -- '${scratch}' || exit; trap - EXIT; printf '%s\\n' "$output")`;
40
+ }
41
+ /** Constructed only after normal authenticated owner/grant/image/sole-Harness checks. */
42
+ class FixedCopilotPermission {
43
+ deadline;
44
+ now;
45
+ matchesOutput;
46
+ platformCopilotScratch;
47
+ admission;
48
+ command;
49
+ output;
50
+ claimed = null;
51
+ announced = null;
52
+ recorded = false;
53
+ completed = false;
54
+ failure = null;
55
+ stopped = false;
56
+ constructor(admission, nonce, deadline, now = Date.now, matchesOutput = (actual, expected) => actual === expected, platformCopilotScratch = false) {
57
+ this.deadline = deadline;
58
+ this.now = now;
59
+ this.matchesOutput = matchesOutput;
60
+ this.platformCopilotScratch = platformCopilotScratch;
61
+ this.admission = interactiveAdmission(admission);
62
+ this.command = platformCopilotScratch
63
+ ? copilotPlatformScratchCommand(nonce)
64
+ : fixedCopilotCommand(nonce);
65
+ this.output = `COPILOT-PROBE-${nonce}\n`;
66
+ if (!Number.isFinite(deadline) || deadline <= now() || deadline > now() + 120_000)
67
+ throw new Error('PROBE_DEADLINE_INVALID');
68
+ }
69
+ stop(reason = 'PROBE_CANCELLED') {
70
+ this.stopped = true;
71
+ this.failure ??= reason;
72
+ }
73
+ close() {
74
+ this.stopped = true;
75
+ }
76
+ get refused() {
77
+ return this.failure !== null;
78
+ }
79
+ /** The exact answered/admitted notice dismisses the prompt without proving execution. */
80
+ answerNotice(frame) {
81
+ const binding = frame.permissionBinding;
82
+ return (this.active() &&
83
+ !!this.claimed &&
84
+ (frame.reason === 'answered' ||
85
+ (frame.reason === 'response_admitted' && frame.executionConfirmed === false)) &&
86
+ frame.sessionId === this.admission.sessionId &&
87
+ frame.toolUseId === this.claimed.toolUseId &&
88
+ object(binding) &&
89
+ binding.epoch === this.admission.generation &&
90
+ binding.requestId === this.claimed.requestId);
91
+ }
92
+ refuse(reason) {
93
+ this.failure ??= reason;
94
+ return false;
95
+ }
96
+ active() {
97
+ return !this.stopped && !this.failure && this.now() < this.deadline;
98
+ }
99
+ tool(frame, observedStart = false) {
100
+ const input = frame.toolInput;
101
+ return (typeof frame.toolName === 'string' &&
102
+ /^(bash|Bash)$/.test(frame.toolName) &&
103
+ text(frame.toolUseId) &&
104
+ object(input) &&
105
+ input.command === this.command &&
106
+ (exact(input, ['command']) ||
107
+ (observedStart &&
108
+ this.platformCopilotScratch &&
109
+ exact(input, ['command', 'description']) &&
110
+ typeof input.description === 'string' &&
111
+ Buffer.byteLength(input.description) <= 256)));
112
+ }
113
+ /** Synchronous consumption happens BEFORE any asynchronous decision transport. */
114
+ decide(frame) {
115
+ if (!this.active())
116
+ return this.refuse('PROBE_CLOSED_OR_EXPIRED');
117
+ const context = frame.interactiveAdmission;
118
+ const binding = frame.permissionBinding;
119
+ if (frame.sessionId !== this.admission.sessionId ||
120
+ frame.purpose !== undefined ||
121
+ frame.runtimeElicitation !== undefined ||
122
+ frame.decisionStatus !== undefined ||
123
+ !this.tool(frame) ||
124
+ !object(context) ||
125
+ !exact(context, [
126
+ 'version',
127
+ 'kind',
128
+ 'sessionId',
129
+ 'responseMessageId',
130
+ 'generation',
131
+ 'requestId',
132
+ ]) ||
133
+ !object(binding) ||
134
+ !exact(binding, ['epoch', 'requestId']) ||
135
+ !text(binding.requestId) ||
136
+ context.version !== 1 ||
137
+ context.kind !== 'interactive' ||
138
+ context.sessionId !== this.admission.sessionId ||
139
+ context.responseMessageId !== this.admission.responseMessageId ||
140
+ context.generation !== this.admission.generation ||
141
+ binding.epoch !== this.admission.generation ||
142
+ context.requestId !== binding.requestId ||
143
+ typeof frame.timeoutAt !== 'number' ||
144
+ !Number.isFinite(frame.timeoutAt) ||
145
+ frame.timeoutAt <= this.now())
146
+ return this.refuse('PROBE_PERMISSION_MISMATCH');
147
+ if (this.claimed || (this.announced && this.announced !== frame.toolUseId))
148
+ return this.refuse('PROBE_ADDITIONAL_REQUEST');
149
+ this.claimed = { toolUseId: frame.toolUseId, requestId: binding.requestId };
150
+ return true;
151
+ }
152
+ decisionReceipt(frame, approved, receipt) {
153
+ if (!approved ||
154
+ !this.active() ||
155
+ !this.claimed ||
156
+ frame.toolUseId !== this.claimed.toolUseId ||
157
+ receipt.type !== 'permission.response_recorded' ||
158
+ receipt.duplicate === true ||
159
+ typeof receipt.status !== 'string' ||
160
+ !['recorded', 'admitted'].includes(receipt.status)) {
161
+ this.refuse('PROBE_DECISION_UNCONFIRMED');
162
+ return;
163
+ }
164
+ this.recorded = true; // A response receipt alone never sets completed.
165
+ }
166
+ observe(frame) {
167
+ if (typeof frame.type !== 'string') {
168
+ this.stop('PROBE_MALFORMED_EVENT');
169
+ return;
170
+ }
171
+ if (['stream.gap', 'transport.error', 'run.handed_over', 'text.reset'].includes(String(frame.type))) {
172
+ this.stop('PROBE_TRANSPORT_CONTEXT_LOST');
173
+ return;
174
+ }
175
+ if (!['tool.started', 'tool.completed', 'run.cancel_requested', 'permission.cancelled'].includes(String(frame.type)))
176
+ return;
177
+ if (frame.type === 'run.cancel_requested' || frame.type === 'permission.cancelled') {
178
+ this.stop();
179
+ return;
180
+ }
181
+ if (!this.active() || frame.sessionId !== this.admission.sessionId) {
182
+ this.refuse('PROBE_TOOL_CONTEXT_MISMATCH');
183
+ return;
184
+ }
185
+ if (frame.type === 'tool.started') {
186
+ if (!this.tool(frame, true) ||
187
+ this.announced ||
188
+ (this.claimed && this.claimed.toolUseId !== frame.toolUseId)) {
189
+ this.refuse('PROBE_UNEXPECTED_TOOL');
190
+ return;
191
+ }
192
+ this.announced = frame.toolUseId;
193
+ }
194
+ else {
195
+ if (this.completed ||
196
+ !this.claimed ||
197
+ this.announced !== this.claimed.toolUseId ||
198
+ frame.toolUseId !== this.claimed.toolUseId ||
199
+ typeof frame.toolName !== 'string' ||
200
+ !/^(bash|Bash)$/.test(frame.toolName) ||
201
+ frame.status !== 'completed' ||
202
+ !this.matchesOutput(frame.toolResponse, this.output)) {
203
+ this.refuse('PROBE_TOOL_RESULT_MISMATCH');
204
+ return;
205
+ }
206
+ this.completed = true;
207
+ }
208
+ }
209
+ result() {
210
+ return {
211
+ permissionRecorded: this.recorded,
212
+ toolVerified: this.completed && this.recorded && !this.failure,
213
+ failure: this.failure,
214
+ toolUseId: this.claimed?.toolUseId ?? null,
215
+ requestId: this.claimed?.requestId ?? null,
216
+ interactiveAdmission: this.admission,
217
+ autonomousRunClaimed: false,
218
+ autonomousAttemptClaimed: false,
219
+ approvalSource: 'exact-local-operator-rule',
220
+ };
221
+ }
222
+ }
223
+ exports.FixedCopilotPermission = FixedCopilotPermission;
@@ -52,6 +52,7 @@ export interface ResolveOptions {
52
52
  * chain should run.
53
53
  */
54
54
  export declare function resolveTrustedAutonomousCredential(env?: Record<string, string | undefined>): ResolvedCredential | null;
55
+ export declare function isBareCliEnvironment(env?: NodeJS.ProcessEnv): boolean;
55
56
  /**
56
57
  * Resolve the active credential. Returns the token, the source that
57
58
  * produced it, and (Phase I) a `kind` discriminator so callers can
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveTrustedAutonomousCredential = resolveTrustedAutonomousCredential;
4
+ exports.isBareCliEnvironment = isBareCliEnvironment;
4
5
  exports.resolveCredential = resolveCredential;
5
6
  exports.kindOf = kindOf;
6
7
  exports.describeCredentialSource = describeCredentialSource;
@@ -55,6 +56,9 @@ function resolveTrustedAutonomousCredential(env = process.env) {
55
56
  kind: (0, auth_core_1.classifyTokenKind)(token),
56
57
  };
57
58
  }
59
+ function isBareCliEnvironment(env = process.env) {
60
+ return ['1', 'true', 'TRUE', 'yes'].includes(env.OVERSKY_BARE_MODE ?? '');
61
+ }
58
62
  /**
59
63
  * Resolve the active credential. Returns the token, the source that
60
64
  * produced it, and (Phase I) a `kind` discriminator so callers can
@@ -75,7 +79,7 @@ async function resolveCredential(opts = {}) {
75
79
  const storeMode = (0, harness_context_1.isHarnessCliContext)()
76
80
  ? 'env-only'
77
81
  : (opts.storeModeOverride ?? cfg?.credentials?.store ?? 'auto');
78
- const bareMode = opts.bareMode || ['1', 'true', 'TRUE', 'yes'].includes(process.env.OVERSKY_BARE_MODE ?? '');
82
+ const bareMode = opts.bareMode || isBareCliEnvironment();
79
83
  // Clear an observation left by a prior, unrelated direct backend probe in
80
84
  // this process. Only a blocked read made by THIS resolver should trigger the
81
85
  // bounded wait/retry below.
@@ -61,6 +61,7 @@ import { buildManagedInferenceRelayCredential, startManagedInferenceBroker, type
61
61
  import { type ApiFetchOptions } from './api-fetch';
62
62
  import { type EngineExitOutcome } from './first-party-harness';
63
63
  import { type FirstPartyHarnessAgent } from './first-party-harness-agent';
64
+ import { type ManagedSmokeOperations } from './inference-overload-smoke-contract';
64
65
  /**
65
66
  * Reasons the server accepts for a release. An ALLOW-LIST on its side, mirrored
66
67
  * here as a type so a typo becomes a compile error rather than a silent
@@ -122,6 +123,8 @@ export interface ManagedSessionHandle {
122
123
  * process until the reaper notices. `reason` is what an operator greps.
123
124
  */
124
125
  stop(reason?: ManagedReleaseReason): Promise<void>;
126
+ /** Fixed diagnostic operations; the current session capability stays inside this factory. */
127
+ overloadSmoke?: ManagedSmokeOperations;
125
128
  }
126
129
  type FetchLike = (url: string, init: RequestInit) => Promise<Response>;
127
130
  export interface AcquireManagedSessionInput {
@@ -129,6 +132,8 @@ export interface AcquireManagedSessionInput {
129
132
  agentRef?: string;
130
133
  /** The model the user named to the engine, if any. */
131
134
  model?: string;
135
+ /** Optional normal admission selection; absence preserves the policy default. */
136
+ reasoningEffort?: string;
132
137
  env?: NodeJS.ProcessEnv;
133
138
  onLeaseRenewalStopped?: (reason: RenewalStopReason, detail?: string) => void;
134
139
  /**
@@ -169,16 +174,6 @@ export interface AcquireManagedSessionDeps {
169
174
  * things is a null whose message has to be reconstructed by the caller.
170
175
  */
171
176
  export declare function acquireManagedSession(input?: AcquireManagedSessionInput, deps?: AcquireManagedSessionDeps): Promise<ManagedSessionHandle>;
172
- /**
173
- * Whether a credential exists on this machine, without a network call.
174
- *
175
- * Reads the same two slots the resolver's non-interactive path reads: the auth
176
- * backend (keychain or `cli-auth.json`, origin-checked) and the env overlay that
177
- * `OVERSKY_TOKEN` lands in. Deliberately NOT `resolveCredential()`, which may
178
- * spawn an auth helper or prompt — a precondition check must not have side
179
- * effects.
180
- */
181
- export declare function hasLocalCredential(): boolean;
182
177
  /**
183
178
  * The three clocks a supervised session runs on, said once, before the first turn.
184
179
  *
@@ -61,7 +61,6 @@
61
61
  Object.defineProperty(exports, "__esModule", { value: true });
62
62
  exports.ManagedAcquisitionError = void 0;
63
63
  exports.acquireManagedSession = acquireManagedSession;
64
- exports.hasLocalCredential = hasLocalCredential;
65
64
  exports.managedLeaseClockLine = managedLeaseClockLine;
66
65
  exports.createManagedEngineHooks = createManagedEngineHooks;
67
66
  exports.managedRenewalStoppedLine = managedRenewalStoppedLine;
@@ -71,11 +70,9 @@ const auth_core_1 = require("@skrr-ai/auth-core");
71
70
  const inference_broker_harnesses_1 = require("@skrr-ai/auth-core/inference-broker-harnesses");
72
71
  const inference_broker_1 = require("@skrr-ai/inference-broker");
73
72
  const api_fetch_1 = require("./api-fetch");
74
- const auth_storage_1 = require("./auth-storage");
75
73
  const auth_core_init_1 = require("./auth-core-init");
76
74
  const config_1 = require("./config");
77
75
  const cli_id_1 = require("./cli-id");
78
- const cred_envelope_1 = require("./cred-envelope");
79
76
  const dedicated_guest_1 = require("./dedicated-guest");
80
77
  const daemonBroker_1 = require("./daemonBroker");
81
78
  const daemonBrokerRefusal_1 = require("./daemonBrokerRefusal");
@@ -87,6 +84,7 @@ const first_party_harness_1 = require("./first-party-harness");
87
84
  const first_party_harness_agent_1 = require("./first-party-harness-agent");
88
85
  const first_party_harness_managed_1 = require("./first-party-harness-managed");
89
86
  const task_execution_1 = require("./task-execution");
87
+ const inference_overload_smoke_contract_1 = require("./inference-overload-smoke-contract");
90
88
  const RELEASE_LEASE_RE = /\/+$/;
91
89
  /**
92
90
  * Harness selections the POLICY resolves, mirroring the server's own set.
@@ -173,14 +171,17 @@ class ManagedAcquisitionError extends Error {
173
171
  exports.ManagedAcquisitionError = ManagedAcquisitionError;
174
172
  async function borrowDedicatedGuestCredential() {
175
173
  if (!(0, dedicated_guest_1.runningOnDedicatedRuntimeGuest)() ||
176
- (0, harness_context_1.isHarnessCliContext)() ||
177
- (0, credential_resolver_1.resolveTrustedAutonomousCredential)()) {
174
+ (0, credential_resolver_1.resolveTrustedAutonomousCredential)() ||
175
+ (0, config_1.isEnvAuthOverride)() ||
176
+ (0, credential_resolver_1.isBareCliEnvironment)() ||
177
+ process.env.OVERSKY_SKIP_DAEMON_BROKER === '1') {
178
178
  return null;
179
179
  }
180
180
  // `skrr code run` does not extend BaseCommand, so its local credential check
181
181
  // used to stop before the guest's daemon hand-off could be redeemed. Borrow
182
- // only the fixed root-owned guest descriptor. No refresh family or credential
183
- // is persisted, and apiFetch can re-redeem this DPoP-bound token on a 401.
182
+ // only from the fixed guest descriptor. Owner-requested exec runs as a
183
+ // daemon child, where borrowing is allowed and persisting a login is forbidden.
184
+ // apiFetch can re-redeem this DPoP-bound token on a 401.
184
185
  try {
185
186
  const cfg = (0, config_1.loadConfig)();
186
187
  const outcome = await (0, daemonBroker_1.attemptDaemonBrokerLogin)({
@@ -230,46 +231,38 @@ async function acquireManagedSession(input = {}, deps = {}) {
230
231
  // before resolving a credential; `skrr code` does not extend `BaseCommand`, so it
231
232
  // is awaited here.
232
233
  await (deps.prefetchAuth ?? auth_core_init_1.prefetchCliAuth)();
233
- // Checked locally, BEFORE any network. A fresh machine that has never run
234
- // `skrr login` must fall back to BYOK without a round trip and without a 401 that
235
- // would drag `apiFetch`'s refresh machinery in behind it.
234
+ // No mint or admission request until the CLI has resolved its authority.
235
+ // Only human guest commands can prefer the live descriptor over a legacy
236
+ // stored family. The standard resolver keeps daemon children off that store.
236
237
  let localCredentialAvailable = false;
237
- // Match BaseCommand's narrowly scoped retirement path: a stale guest refresh
238
- // family must not prevent the live machine descriptor from lending a token.
238
+ let guestHandoff;
239
+ const borrow = () => (guestHandoff ??= (deps.borrowGuestCredential ?? borrowDedicatedGuestCredential)());
239
240
  const brokerBeforeStored = !deps.hasCredential &&
240
241
  !(0, config_1.isEnvAuthOverride)() &&
242
+ !(0, credential_resolver_1.isBareCliEnvironment)() &&
243
+ process.env.OVERSKY_SKIP_DAEMON_BROKER !== '1' &&
241
244
  !(0, harness_context_1.isHarnessCliContext)() &&
242
245
  !(0, credential_resolver_1.resolveTrustedAutonomousCredential)() &&
243
246
  (0, daemonBroker_1.shouldBrokerBeforeStoredCredential)();
244
247
  if (brokerBeforeStored) {
245
248
  try {
246
- const guestHandoff = await (deps.borrowGuestCredential ?? borrowDedicatedGuestCredential)();
247
- if (guestHandoff === true)
248
- localCredentialAvailable = true;
249
+ localCredentialAvailable = (await borrow()) === true;
249
250
  }
250
251
  catch {
251
252
  // A usable stored credential remains the fallback during a hand-off outage.
252
253
  }
253
254
  }
254
- if (!localCredentialAvailable && deps.hasCredential) {
255
- localCredentialAvailable = deps.hasCredential();
256
- }
257
- else if (!localCredentialAvailable) {
258
- (0, cred_envelope_1.consumeEncryptedCredentialReadWhileInactive)();
259
- localCredentialAvailable = hasLocalCredential();
260
- if (!localCredentialAvailable && (0, cred_envelope_1.consumeEncryptedCredentialReadWhileInactive)()) {
261
- await (0, auth_core_init_1.waitForCliCredentialEnvelope)();
262
- localCredentialAvailable = hasLocalCredential();
263
- }
255
+ if (!localCredentialAvailable) {
256
+ localCredentialAvailable = deps.hasCredential
257
+ ? deps.hasCredential()
258
+ : Boolean(((0, credential_resolver_1.resolveTrustedAutonomousCredential)() ?? (await (0, credential_resolver_1.resolveCredential)())).token);
264
259
  }
265
260
  if (!localCredentialAvailable) {
266
- const guestHandoff = await (deps.borrowGuestCredential ?? borrowDedicatedGuestCredential)();
267
- if (guestHandoff === true) {
268
- localCredentialAvailable = true;
269
- }
270
- else if (guestHandoff === false) {
261
+ const borrowed = await borrow();
262
+ if (borrowed === false) {
271
263
  throw new ManagedAcquisitionError('guest-handoff-unavailable', 'the Dedicated Runtime could not provide its managed skrr session');
272
264
  }
265
+ localCredentialAvailable = borrowed === true;
273
266
  }
274
267
  if (!localCredentialAvailable) {
275
268
  throw new ManagedAcquisitionError('not-signed-in', 'no skrr session on this machine — run `skrr login`');
@@ -334,6 +327,9 @@ async function acquireManagedSession(input = {}, deps = {}) {
334
327
  sessionId,
335
328
  sessionToken,
336
329
  model: input.model?.trim() || AUTOMATIC_MODEL,
330
+ ...(input.reasoningEffort !== undefined
331
+ ? { reasoningEffort: input.reasoningEffort }
332
+ : {}),
337
333
  localRuntimeId: (deps.localRuntimeId ?? localRuntimeId)(),
338
334
  // The hardware id every Daemon row is keyed on — the same function
339
335
  // the daemon calls — not the minted `~/.skrr/daemon.id` UUIDv7,
@@ -507,6 +503,55 @@ async function acquireManagedSession(input = {}, deps = {}) {
507
503
  await compensate(releaseModel, sessionToken);
508
504
  throw err;
509
505
  }
506
+ let stopping = false;
507
+ let smokeBeginClaimed = false, smokeFailed = false, smokeBatchPending = false, nextSmokeBatch = 0;
508
+ let smokeOperationId = null;
509
+ const smokePath = `${serverUrl.replace(RELEASE_LEASE_RE, '')}/api/agentic/sessions/${encodeURIComponent(sessionId)}/inference/diagnostics/overload-smoke`;
510
+ const smokeRequest = async (body, signal) => {
511
+ if (stopping && body.action !== 'receipt')
512
+ throw new inference_overload_smoke_contract_1.InferenceSmokeError('SMOKE_SESSION_STOPPED');
513
+ const controller = new AbortController();
514
+ const timeout = setTimeout(() => controller.abort(), body.action === 'receipt' ? RELEASE_TIMEOUT_MS : 180000);
515
+ const abort = () => controller.abort();
516
+ signal?.addEventListener('abort', abort, { once: true });
517
+ if (signal?.aborted)
518
+ abort();
519
+ try {
520
+ const raw = await fetchImpl(smokePath, {
521
+ method: 'POST',
522
+ headers: {
523
+ Accept: 'application/json',
524
+ 'Content-Type': 'application/json',
525
+ Authorization: `Bearer ${sessionToken}`,
526
+ },
527
+ body: JSON.stringify(body),
528
+ signal: controller.signal,
529
+ redirect: 'error',
530
+ });
531
+ const response = await (0, inference_broker_1.boundedOverloadSmokeResponse)(raw, controller.signal);
532
+ if (!response.ok) {
533
+ // Read a fixed code only. Server/transport bodies can carry requests and credentials.
534
+ const data = (await response.json().catch(() => null));
535
+ const code = data?.code ?? data?.error?.code;
536
+ throw new inference_overload_smoke_contract_1.InferenceSmokeError(typeof code === 'string' && /^[A-Za-z0-9_.:-]{1,96}$/.test(code)
537
+ ? code
538
+ : `SMOKE_HTTP_${response.status}`);
539
+ }
540
+ return await response.json();
541
+ }
542
+ catch (error) {
543
+ if (error instanceof inference_overload_smoke_contract_1.InferenceSmokeError)
544
+ throw error;
545
+ const code = error?.code;
546
+ if (typeof code === 'string' && /^SMOKE_[A-Z0-9_]{1,90}$/.test(code))
547
+ throw new inference_overload_smoke_contract_1.InferenceSmokeError(code);
548
+ throw new inference_overload_smoke_contract_1.InferenceSmokeError(controller.signal.aborted ? 'SMOKE_ABORTED' : 'SMOKE_OPERATION_UNKNOWN');
549
+ }
550
+ finally {
551
+ clearTimeout(timeout);
552
+ signal?.removeEventListener('abort', abort);
553
+ }
554
+ };
510
555
  return {
511
556
  env: session.env,
512
557
  socketPath: session.socketPath,
@@ -519,7 +564,52 @@ async function acquireManagedSession(input = {}, deps = {}) {
519
564
  leaseExpiresInMs: lease.leaseExpiresInMs,
520
565
  ...(lease.renewalWindowMs !== undefined ? { renewalWindowMs: lease.renewalWindowMs } : {}),
521
566
  ...(lease.ceilingAtMs !== undefined ? { ceilingAtMs: lease.ceilingAtMs } : {}),
567
+ overloadSmoke: {
568
+ begin: async (signal) => {
569
+ if (smokeBeginClaimed || stopping)
570
+ throw new inference_overload_smoke_contract_1.InferenceSmokeError('SMOKE_BEGIN_ALREADY_CLAIMED');
571
+ smokeBeginClaimed = true;
572
+ try {
573
+ const begun = (0, inference_overload_smoke_contract_1.projectSmokeBegin)(await smokeRequest({ action: 'begin' }, signal));
574
+ smokeOperationId = begun.operationId;
575
+ return begun;
576
+ }
577
+ catch (error) {
578
+ smokeFailed = true;
579
+ throw error;
580
+ }
581
+ },
582
+ batch: async (operationId, index, signal) => {
583
+ if (!Number.isSafeInteger(index) ||
584
+ index < 0 ||
585
+ index >= 64 ||
586
+ operationId !== smokeOperationId ||
587
+ index !== nextSmokeBatch ||
588
+ smokeBatchPending ||
589
+ smokeFailed ||
590
+ stopping)
591
+ throw new inference_overload_smoke_contract_1.InferenceSmokeError('SMOKE_BATCH_INDEX_INVALID');
592
+ smokeBatchPending = true;
593
+ nextSmokeBatch += 1;
594
+ try {
595
+ return (0, inference_overload_smoke_contract_1.projectSmokeBatch)(await smokeRequest({ action: 'batch', operationId, index }, signal), index);
596
+ }
597
+ catch (error) {
598
+ smokeFailed = true;
599
+ throw error;
600
+ }
601
+ finally {
602
+ smokeBatchPending = false;
603
+ }
604
+ },
605
+ receipt: async (operationId, signal) => {
606
+ if (operationId !== smokeOperationId)
607
+ throw new inference_overload_smoke_contract_1.InferenceSmokeError('SMOKE_OPERATION_MISMATCH');
608
+ return (0, inference_overload_smoke_contract_1.projectSmokeReceipt)(await smokeRequest({ action: 'receipt', operationId }, signal), operationId);
609
+ },
610
+ },
522
611
  stop: async (reason = 'cli_session_ended') => {
612
+ stopping = true;
523
613
  try {
524
614
  // The broker FIRST, because `stop()` stops the renewal loop: releasing
525
615
  // while a heartbeat is in flight risks the renewal re-extending the lease
@@ -822,6 +912,7 @@ signal) {
822
912
  },
823
913
  body: JSON.stringify({
824
914
  model: input.model,
915
+ ...(input.reasoningEffort !== undefined ? { reasoningEffort: input.reasoningEffort } : {}),
825
916
  localRuntimeId: input.localRuntimeId,
826
917
  machineUuid: input.machineUuid,
827
918
  }),
@@ -917,26 +1008,6 @@ async function readRefusal(response) {
917
1008
  return {};
918
1009
  }
919
1010
  }
920
- /**
921
- * Whether a credential exists on this machine, without a network call.
922
- *
923
- * Reads the same two slots the resolver's non-interactive path reads: the auth
924
- * backend (keychain or `cli-auth.json`, origin-checked) and the env overlay that
925
- * `OVERSKY_TOKEN` lands in. Deliberately NOT `resolveCredential()`, which may
926
- * spawn an auth helper or prompt — a precondition check must not have side
927
- * effects.
928
- */
929
- function hasLocalCredential() {
930
- try {
931
- const cfg = (0, config_1.loadConfig)();
932
- if (cfg.token)
933
- return true;
934
- return Boolean((0, auth_storage_1.readFromBackend)(cfg.baseURL).bundle?.token);
935
- }
936
- catch {
937
- return false;
938
- }
939
- }
940
1011
  /**
941
1012
  * This installation's runtime id.
942
1013
  *
@@ -0,0 +1,63 @@
1
+ import { type AgenticStreamEvent, type EnvelopeReplayPage } from './agentic-stream';
2
+ export declare const H9_TURN_LABELS: readonly ["streaming", "toolCalls", "remember", "interrupt", "recall", "cancel"];
3
+ export type H9TurnLabel = (typeof H9_TURN_LABELS)[number];
4
+ export type H9Harness = 'pi' | 'copilot-sdk';
5
+ type Row = Record<string, any>;
6
+ /** Fixed prompts for the two reviewed platform qualification pairs. */
7
+ export declare function h9FixedPrompt(label: H9TurnLabel, nonce: string, harness?: H9Harness): string;
8
+ export type H9AcceptedScope = {
9
+ agentId: string;
10
+ harnessId: string;
11
+ harness: H9Harness;
12
+ workspaceId?: string;
13
+ daemonId: string;
14
+ conversationId?: string;
15
+ };
16
+ /** Actual normal HTTP acceptance, not a caller-provided session or permission context. */
17
+ export declare function validateH9Acceptance(accepted: Row, scope: H9AcceptedScope): import("./copilot-fixed-probe").InteractiveAdmission;
18
+ export interface H9StreamInput {
19
+ label: H9TurnLabel;
20
+ nonce: string;
21
+ accepted: Row;
22
+ scope: H9AcceptedScope;
23
+ deadline: number;
24
+ baseURL: string;
25
+ token: string;
26
+ replayEnvelopes: (from: number) => Promise<EnvelopeReplayPage>;
27
+ readResponseMessage?: () => Promise<unknown>;
28
+ onEvent: (event: AgenticStreamEvent) => void;
29
+ signal?: AbortSignal;
30
+ }
31
+ /**
32
+ * Internal transport seam only. The closed operator runner must establish owner, unused
33
+ * grant, exact image/runtime/model and per-turn financial barriers before calling this.
34
+ * The shared client is the ONLY permission responder. No generic approval/input option.
35
+ */
36
+ export declare function streamH9PlatformTurn(input: H9StreamInput): Promise<{
37
+ result: {
38
+ responseMessageId: string | undefined;
39
+ sessionId: string;
40
+ text: string;
41
+ status: "completed" | "aborted" | "failed";
42
+ repaired?: true;
43
+ permissionDenials?: string[];
44
+ lastEvent?: AgenticStreamEvent;
45
+ };
46
+ permission: {
47
+ permissionRecorded: boolean;
48
+ toolVerified: boolean;
49
+ failure: string | null;
50
+ toolUseId: string | null;
51
+ requestId: string | null;
52
+ interactiveAdmission: import("./copilot-fixed-probe").InteractiveAdmission;
53
+ autonomousRunClaimed: boolean;
54
+ autonomousAttemptClaimed: boolean;
55
+ approvalSource: string;
56
+ } | null;
57
+ cancelRequestedAtMs: null;
58
+ successful: boolean;
59
+ refusal: null;
60
+ providerAbsenceClaimed: boolean;
61
+ financialSettlementClaimed: boolean;
62
+ }>;
63
+ export {};