@skrr-ai/cli 0.1.180 → 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.
- package/dist/lib/agent-model-check.d.ts +19 -0
- package/dist/lib/agent-model-check.js +10 -20
- package/dist/lib/credential-resolver.d.ts +1 -0
- package/dist/lib/credential-resolver.js +5 -1
- package/dist/lib/first-party-harness-broker.d.ts +0 -10
- package/dist/lib/first-party-harness-broker.js +22 -50
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
|
@@ -1,7 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A model id the agent's harness does not list, said at save time (OSK-12205).
|
|
3
|
+
*
|
|
4
|
+
* `agents create/update --model <id>` stored any well-formed id without a
|
|
5
|
+
* word; the first anyone heard of a typo was a failed turn, whose remedy then
|
|
6
|
+
* sent a local agent to "publish the agent". The server only validates the
|
|
7
|
+
* id's SHAPE on write — asking the daemon for its live list on every PATCH
|
|
8
|
+
* would put a machine round-trip on the write path — so the check lives here,
|
|
9
|
+
* after the write, and never fails the command.
|
|
10
|
+
*
|
|
11
|
+
* Only a list that speaks for the harness can say "not there": `live` (the
|
|
12
|
+
* installed harness enumerated it) or `managed` (the admission policy). A
|
|
13
|
+
* `curated` list is our suggestion, so a miss against it is reported as
|
|
14
|
+
* unverified, with the reason the live list was unavailable.
|
|
15
|
+
*/
|
|
1
16
|
interface ModelsReport {
|
|
2
17
|
provider?: string | null;
|
|
3
18
|
source?: string;
|
|
4
19
|
sourceReason?: string;
|
|
20
|
+
managedRefusal?: {
|
|
21
|
+
code?: string;
|
|
22
|
+
message?: string;
|
|
23
|
+
};
|
|
5
24
|
models?: Array<{
|
|
6
25
|
value?: string;
|
|
7
26
|
}>;
|
|
@@ -3,24 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.primaryHarnessId = primaryHarnessId;
|
|
4
4
|
exports.describeUnlistedModel = describeUnlistedModel;
|
|
5
5
|
exports.warnIfModelNotListed = warnIfModelNotListed;
|
|
6
|
+
const data_provider_1 = require("@skrr-ai/data-provider");
|
|
6
7
|
const harnesses_1 = require("./harnesses");
|
|
7
|
-
/**
|
|
8
|
-
* A model id the agent's harness does not list, said at save time (OSK-12205).
|
|
9
|
-
*
|
|
10
|
-
* `agents create/update --model <id>` stored any well-formed id without a
|
|
11
|
-
* word; the first anyone heard of a typo was a failed turn, whose remedy then
|
|
12
|
-
* sent a local agent to "publish the agent". The server only validates the
|
|
13
|
-
* id's SHAPE on write — asking the daemon for its live list on every PATCH
|
|
14
|
-
* would put a machine round-trip on the write path — so the check lives here,
|
|
15
|
-
* after the write, and never fails the command.
|
|
16
|
-
*
|
|
17
|
-
* Only a list that speaks for the harness can say "not there": `live` (the
|
|
18
|
-
* installed harness enumerated it) or `managed` (the admission policy). A
|
|
19
|
-
* `curated` list is our suggestion, so a miss against it is reported as
|
|
20
|
-
* unverified, with the reason the live list was unavailable.
|
|
21
|
-
*/
|
|
22
|
-
/** Not model names: "no selection", which runs the harness default. */
|
|
23
|
-
const SENTINELS = new Set(['', 'default', 'auto']);
|
|
24
8
|
/** The harness the saved agent runs on first, as the write response names it. */
|
|
25
9
|
function primaryHarnessId(agent) {
|
|
26
10
|
const record = (agent ?? {});
|
|
@@ -32,13 +16,19 @@ function primaryHarnessId(agent) {
|
|
|
32
16
|
}
|
|
33
17
|
function describeUnlistedModel(model, report, harnessId, bin) {
|
|
34
18
|
const id = typeof model === 'string' ? model.trim() : '';
|
|
35
|
-
if (
|
|
19
|
+
if (!id || data_provider_1.RESERVED_LOCAL_CLI_MODEL_SENTINELS.has(id.toLowerCase()))
|
|
36
20
|
return null;
|
|
37
|
-
const
|
|
21
|
+
const normalized = (0, data_provider_1.normalizeLocalCliModelForProvider)(report?.provider, id);
|
|
22
|
+
const listed = (report?.models ?? []).some((entry) => entry?.value === id ||
|
|
23
|
+
(normalized !== null &&
|
|
24
|
+
(0, data_provider_1.normalizeLocalCliModelForProvider)(report?.provider, entry?.value) === normalized));
|
|
38
25
|
if (listed)
|
|
39
26
|
return null;
|
|
40
27
|
const provider = report?.provider || 'this';
|
|
41
28
|
const remedy = `\`${bin} harnesses models ${harnessId}\` lists what it can run.`;
|
|
29
|
+
if (report?.source === 'managed' && report.managedRefusal?.message) {
|
|
30
|
+
return `Model '${id}' was saved. ${report.managedRefusal.message} ${remedy}`;
|
|
31
|
+
}
|
|
42
32
|
if (report?.source === 'live' || report?.source === 'managed') {
|
|
43
33
|
return (`Model '${id}' is not in the ${provider} harness's ${report.source} model list ` +
|
|
44
34
|
`(${harnessId}). It was saved, but a turn fails when the harness refuses it. ${remedy}`);
|
|
@@ -53,7 +43,7 @@ function describeUnlistedModel(model, report, harnessId, bin) {
|
|
|
53
43
|
/** Best effort: a check that cannot run says nothing rather than failing the save. */
|
|
54
44
|
async function warnIfModelNotListed(opts) {
|
|
55
45
|
const id = typeof opts.model === 'string' ? opts.model.trim() : '';
|
|
56
|
-
if (
|
|
46
|
+
if (!id || data_provider_1.RESERVED_LOCAL_CLI_MODEL_SENTINELS.has(id.toLowerCase()))
|
|
57
47
|
return;
|
|
58
48
|
const harnessId = primaryHarnessId(opts.agent);
|
|
59
49
|
if (!harnessId)
|
|
@@ -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 ||
|
|
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.
|
|
@@ -174,16 +174,6 @@ export interface AcquireManagedSessionDeps {
|
|
|
174
174
|
* things is a null whose message has to be reconstructed by the caller.
|
|
175
175
|
*/
|
|
176
176
|
export declare function acquireManagedSession(input?: AcquireManagedSessionInput, deps?: AcquireManagedSessionDeps): Promise<ManagedSessionHandle>;
|
|
177
|
-
/**
|
|
178
|
-
* Whether a credential exists on this machine, without a network call.
|
|
179
|
-
*
|
|
180
|
-
* Reads the same two slots the resolver's non-interactive path reads: the auth
|
|
181
|
-
* backend (keychain or `cli-auth.json`, origin-checked) and the env overlay that
|
|
182
|
-
* `OVERSKY_TOKEN` lands in. Deliberately NOT `resolveCredential()`, which may
|
|
183
|
-
* spawn an auth helper or prompt — a precondition check must not have side
|
|
184
|
-
* effects.
|
|
185
|
-
*/
|
|
186
|
-
export declare function hasLocalCredential(): boolean;
|
|
187
177
|
/**
|
|
188
178
|
* The three clocks a supervised session runs on, said once, before the first turn.
|
|
189
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");
|
|
@@ -174,14 +171,17 @@ class ManagedAcquisitionError extends Error {
|
|
|
174
171
|
exports.ManagedAcquisitionError = ManagedAcquisitionError;
|
|
175
172
|
async function borrowDedicatedGuestCredential() {
|
|
176
173
|
if (!(0, dedicated_guest_1.runningOnDedicatedRuntimeGuest)() ||
|
|
177
|
-
(0,
|
|
178
|
-
(0,
|
|
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') {
|
|
179
178
|
return null;
|
|
180
179
|
}
|
|
181
180
|
// `skrr code run` does not extend BaseCommand, so its local credential check
|
|
182
181
|
// used to stop before the guest's daemon hand-off could be redeemed. Borrow
|
|
183
|
-
// only the fixed
|
|
184
|
-
//
|
|
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.
|
|
185
185
|
try {
|
|
186
186
|
const cfg = (0, config_1.loadConfig)();
|
|
187
187
|
const outcome = await (0, daemonBroker_1.attemptDaemonBrokerLogin)({
|
|
@@ -231,46 +231,38 @@ async function acquireManagedSession(input = {}, deps = {}) {
|
|
|
231
231
|
// before resolving a credential; `skrr code` does not extend `BaseCommand`, so it
|
|
232
232
|
// is awaited here.
|
|
233
233
|
await (deps.prefetchAuth ?? auth_core_init_1.prefetchCliAuth)();
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
//
|
|
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.
|
|
237
237
|
let localCredentialAvailable = false;
|
|
238
|
-
|
|
239
|
-
|
|
238
|
+
let guestHandoff;
|
|
239
|
+
const borrow = () => (guestHandoff ??= (deps.borrowGuestCredential ?? borrowDedicatedGuestCredential)());
|
|
240
240
|
const brokerBeforeStored = !deps.hasCredential &&
|
|
241
241
|
!(0, config_1.isEnvAuthOverride)() &&
|
|
242
|
+
!(0, credential_resolver_1.isBareCliEnvironment)() &&
|
|
243
|
+
process.env.OVERSKY_SKIP_DAEMON_BROKER !== '1' &&
|
|
242
244
|
!(0, harness_context_1.isHarnessCliContext)() &&
|
|
243
245
|
!(0, credential_resolver_1.resolveTrustedAutonomousCredential)() &&
|
|
244
246
|
(0, daemonBroker_1.shouldBrokerBeforeStoredCredential)();
|
|
245
247
|
if (brokerBeforeStored) {
|
|
246
248
|
try {
|
|
247
|
-
|
|
248
|
-
if (guestHandoff === true)
|
|
249
|
-
localCredentialAvailable = true;
|
|
249
|
+
localCredentialAvailable = (await borrow()) === true;
|
|
250
250
|
}
|
|
251
251
|
catch {
|
|
252
252
|
// A usable stored credential remains the fallback during a hand-off outage.
|
|
253
253
|
}
|
|
254
254
|
}
|
|
255
|
-
if (!localCredentialAvailable
|
|
256
|
-
localCredentialAvailable = deps.hasCredential
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
(0, cred_envelope_1.consumeEncryptedCredentialReadWhileInactive)();
|
|
260
|
-
localCredentialAvailable = hasLocalCredential();
|
|
261
|
-
if (!localCredentialAvailable && (0, cred_envelope_1.consumeEncryptedCredentialReadWhileInactive)()) {
|
|
262
|
-
await (0, auth_core_init_1.waitForCliCredentialEnvelope)();
|
|
263
|
-
localCredentialAvailable = hasLocalCredential();
|
|
264
|
-
}
|
|
255
|
+
if (!localCredentialAvailable) {
|
|
256
|
+
localCredentialAvailable = deps.hasCredential
|
|
257
|
+
? deps.hasCredential()
|
|
258
|
+
: Boolean(((0, credential_resolver_1.resolveTrustedAutonomousCredential)() ?? (await (0, credential_resolver_1.resolveCredential)())).token);
|
|
265
259
|
}
|
|
266
260
|
if (!localCredentialAvailable) {
|
|
267
|
-
const
|
|
268
|
-
if (
|
|
269
|
-
localCredentialAvailable = true;
|
|
270
|
-
}
|
|
271
|
-
else if (guestHandoff === false) {
|
|
261
|
+
const borrowed = await borrow();
|
|
262
|
+
if (borrowed === false) {
|
|
272
263
|
throw new ManagedAcquisitionError('guest-handoff-unavailable', 'the Dedicated Runtime could not provide its managed skrr session');
|
|
273
264
|
}
|
|
265
|
+
localCredentialAvailable = borrowed === true;
|
|
274
266
|
}
|
|
275
267
|
if (!localCredentialAvailable) {
|
|
276
268
|
throw new ManagedAcquisitionError('not-signed-in', 'no skrr session on this machine — run `skrr login`');
|
|
@@ -1016,26 +1008,6 @@ async function readRefusal(response) {
|
|
|
1016
1008
|
return {};
|
|
1017
1009
|
}
|
|
1018
1010
|
}
|
|
1019
|
-
/**
|
|
1020
|
-
* Whether a credential exists on this machine, without a network call.
|
|
1021
|
-
*
|
|
1022
|
-
* Reads the same two slots the resolver's non-interactive path reads: the auth
|
|
1023
|
-
* backend (keychain or `cli-auth.json`, origin-checked) and the env overlay that
|
|
1024
|
-
* `OVERSKY_TOKEN` lands in. Deliberately NOT `resolveCredential()`, which may
|
|
1025
|
-
* spawn an auth helper or prompt — a precondition check must not have side
|
|
1026
|
-
* effects.
|
|
1027
|
-
*/
|
|
1028
|
-
function hasLocalCredential() {
|
|
1029
|
-
try {
|
|
1030
|
-
const cfg = (0, config_1.loadConfig)();
|
|
1031
|
-
if (cfg.token)
|
|
1032
|
-
return true;
|
|
1033
|
-
return Boolean((0, auth_storage_1.readFromBackend)(cfg.baseURL).bundle?.token);
|
|
1034
|
-
}
|
|
1035
|
-
catch {
|
|
1036
|
-
return false;
|
|
1037
|
-
}
|
|
1038
|
-
}
|
|
1039
1011
|
/**
|
|
1040
1012
|
* This installation's runtime id.
|
|
1041
1013
|
*
|
package/oclif.manifest.json
CHANGED
|
@@ -151482,5 +151482,5 @@
|
|
|
151482
151482
|
]
|
|
151483
151483
|
}
|
|
151484
151484
|
},
|
|
151485
|
-
"version": "0.1.
|
|
151485
|
+
"version": "0.1.181"
|
|
151486
151486
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@skrr-ai/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.181",
|
|
4
4
|
"description": "Command-line interface for skrr",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "skrr",
|
|
@@ -707,5 +707,5 @@
|
|
|
707
707
|
"engines": {
|
|
708
708
|
"node": ">=20.0.0"
|
|
709
709
|
},
|
|
710
|
-
"gitHead": "
|
|
710
|
+
"gitHead": "5f80e25143ca8620a9c8fff2256862de895dfbae"
|
|
711
711
|
}
|