@skrr-ai/cli 0.1.31 → 0.1.33

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 (112) hide show
  1. package/bin/run.js +2 -2
  2. package/dist/commands/agents/list.d.ts +2 -1
  3. package/dist/commands/agents/list.js +2 -1
  4. package/dist/commands/agents/show.js +2 -1
  5. package/dist/commands/balance/statement.js +8 -4
  6. package/dist/commands/browser/install.js +6 -2
  7. package/dist/commands/browser/uninstall.js +6 -2
  8. package/dist/commands/code/acp.js +2 -1
  9. package/dist/commands/code/doctor.d.ts +1 -1
  10. package/dist/commands/code/doctor.js +6 -5
  11. package/dist/commands/code/handover.d.ts +2 -2
  12. package/dist/commands/code/handover.js +2 -2
  13. package/dist/commands/code/index.d.ts +2 -2
  14. package/dist/commands/code/index.js +18 -17
  15. package/dist/commands/code/install.d.ts +3 -3
  16. package/dist/commands/code/install.js +18 -11
  17. package/dist/commands/code/migrate.js +3 -2
  18. package/dist/commands/code/oversky-agent.d.ts +5 -4
  19. package/dist/commands/code/oversky-agent.js +24 -22
  20. package/dist/commands/code/run.js +2 -1
  21. package/dist/commands/harnesses/list.d.ts +9 -1
  22. package/dist/commands/harnesses/list.js +28 -7
  23. package/dist/commands/harnesses/show.js +7 -2
  24. package/dist/commands/instructions/install.js +16 -6
  25. package/dist/commands/learning/delete.d.ts +9 -0
  26. package/dist/commands/learning/delete.js +39 -0
  27. package/dist/commands/learning/export.d.ts +5 -0
  28. package/dist/commands/learning/export.js +22 -0
  29. package/dist/commands/learning/reset.d.ts +9 -0
  30. package/dist/commands/learning/reset.js +34 -0
  31. package/dist/commands/learning/set.d.ts +10 -0
  32. package/dist/commands/learning/set.js +52 -0
  33. package/dist/commands/learning/status.d.ts +8 -0
  34. package/dist/commands/learning/status.js +35 -0
  35. package/dist/commands/logout.js +10 -5
  36. package/dist/commands/machines/dedicated/attach.js +2 -1
  37. package/dist/commands/tasks/runs.js +3 -1
  38. package/dist/commands/workspaces/use.js +2 -1
  39. package/dist/lib/adaptive-learning.d.ts +37 -0
  40. package/dist/lib/adaptive-learning.js +39 -0
  41. package/dist/lib/code-handover.d.ts +1 -1
  42. package/dist/lib/code-handover.js +3 -2
  43. package/dist/lib/config.d.ts +30 -4
  44. package/dist/lib/config.js +2 -1
  45. package/dist/lib/daemon-installer.d.ts +1 -1
  46. package/dist/lib/daemon-target.js +2 -2
  47. package/dist/lib/dedicated-lease-command.js +2 -1
  48. package/dist/lib/dedicated-machines.d.ts +2 -2
  49. package/dist/lib/dedicated-machines.js +6 -3
  50. package/dist/lib/exec-runtime-binary.d.ts +2 -2
  51. package/dist/lib/exec-runtime-binary.js +2 -2
  52. package/dist/lib/{sky-code-agent.d.ts → first-party-harness-agent.d.ts} +20 -19
  53. package/dist/lib/{sky-code-agent.js → first-party-harness-agent.js} +85 -47
  54. package/dist/lib/{sky-code-broker.d.ts → first-party-harness-broker.d.ts} +6 -6
  55. package/dist/lib/{sky-code-broker.js → first-party-harness-broker.js} +23 -23
  56. package/dist/lib/{sky-code-doctor.d.ts → first-party-harness-doctor.d.ts} +12 -2
  57. package/dist/lib/{sky-code-doctor.js → first-party-harness-doctor.js} +181 -94
  58. package/dist/lib/{sky-code-managed.d.ts → first-party-harness-managed.d.ts} +55 -30
  59. package/dist/lib/{sky-code-managed.js → first-party-harness-managed.js} +92 -35
  60. package/dist/lib/{sky-code.d.ts → first-party-harness.d.ts} +107 -36
  61. package/dist/lib/{sky-code.js → first-party-harness.js} +172 -73
  62. package/dist/lib/harness-provider-input.d.ts +35 -0
  63. package/dist/lib/harness-provider-input.js +57 -0
  64. package/dist/lib/harness-tiers.d.ts +8 -2
  65. package/dist/lib/harness-tiers.js +11 -6
  66. package/dist/lib/task-instruction-offer.js +10 -4
  67. package/dist/lib/worklogs.js +2 -2
  68. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.d.ts +2 -2
  69. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/configRoot.js +2 -2
  70. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.d.ts +248 -0
  71. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarness.js +361 -0
  72. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessChannels.d.ts +147 -0
  73. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessChannels.js +180 -0
  74. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessHome.d.ts +111 -0
  75. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/firstPartyHarnessHome.js +314 -0
  76. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessTrust.d.ts +11 -5
  77. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/harnessTrust.js +14 -7
  78. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.d.ts +3 -1
  79. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/index.js +51 -14
  80. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/releaseManifest.js +1 -1
  81. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/spawnEnv.d.ts +4 -4
  82. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/spawnEnv.js +4 -4
  83. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.d.ts +2 -2
  84. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/configRoot.js +2 -2
  85. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.d.ts +248 -0
  86. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarness.js +332 -0
  87. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessChannels.d.ts +147 -0
  88. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessChannels.js +170 -0
  89. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessHome.d.ts +111 -0
  90. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/firstPartyHarnessHome.js +303 -0
  91. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessTrust.d.ts +11 -5
  92. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/harnessTrust.js +14 -7
  93. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.d.ts +3 -1
  94. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/index.js +12 -2
  95. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/releaseManifest.js +1 -1
  96. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/spawnEnv.d.ts +4 -4
  97. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/spawnEnv.js +4 -4
  98. package/dist/node_modules/@skrr-ai/auth-core/package.json +11 -1
  99. package/dist/node_modules/@skrr-ai/data-provider/index.js +4816 -4782
  100. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.d.ts +1 -1
  101. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/index.js +1 -1
  102. package/dist/node_modules/@skrr-ai/inference-broker/dist/cjs/managed-inference-broker.js +1 -1
  103. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.d.ts +1 -1
  104. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/index.js +1 -1
  105. package/dist/node_modules/@skrr-ai/inference-broker/dist/esm/managed-inference-broker.js +1 -1
  106. package/dist/node_modules/@skrr-ai/inference-broker/package.json +1 -1
  107. package/oclif.manifest.json +27119 -26808
  108. package/package.json +5 -2
  109. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/skyCodeChannels.d.ts +0 -96
  110. package/dist/node_modules/@skrr-ai/auth-core/dist/cjs/skyCodeChannels.js +0 -115
  111. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/skyCodeChannels.d.ts +0 -96
  112. package/dist/node_modules/@skrr-ai/auth-core/dist/esm/skyCodeChannels.js +0 -107
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  /**
3
- * OSK-3892 — which AGENT a locally-hosted skrr Code session belongs to.
3
+ * OSK-3892 — which AGENT a locally-hosted first-party harness session belongs to.
4
4
  *
5
5
  * ── Why a session needs an agent at all ────────────────────────────────────
6
6
  *
7
7
  * `skrr code` is the local arm of an agent's harness. The cloud dispatches to
8
- * sky-code AS an agent, and a human running it here runs the same harness against
8
+ * the first-party harness AS an agent, and a human running it here runs the same harness against
9
9
  * the same server contract — so the session is attributed to an agent the user
10
10
  * names.
11
11
  *
@@ -16,8 +16,8 @@
16
16
  *
17
17
  * ── Resolution order, and why it ends in a refusal ─────────────────────────
18
18
  *
19
- * 1. `--oversky-agent <id-or-name>`
20
- * 2. `skyCodeAgentId` in `~/.skrr/cli-config.json`
19
+ * 1. `--skrr-agent <id-or-name>` (or its older spelling, `--oversky-agent`)
20
+ * 2. `AGENT_CONFIG_KEY` in `~/.skrr/cli-config.json` (or the key earlier CLIs wrote)
21
21
  * 3. the user's single agent, when they have exactly one AND AUTHORED IT
22
22
  * 4. the user's own DEFAULT agent for this harness, created on first use
23
23
  *
@@ -50,15 +50,16 @@
50
50
  * its habit of listing what it found are worth copying; its precedence is not.
51
51
  */
52
52
  Object.defineProperty(exports, "__esModule", { value: true });
53
- exports.SkyCodeAgentError = void 0;
54
- exports.resolveSkyCodeAgent = resolveSkyCodeAgent;
53
+ exports.FirstPartyHarnessAgentError = void 0;
54
+ exports.resolveFirstPartyHarnessAgent = resolveFirstPartyHarnessAgent;
55
55
  exports.readConfiguredAgentId = readConfiguredAgentId;
56
56
  exports.setConfiguredAgentId = setConfiguredAgentId;
57
57
  exports.clearConfiguredAgentId = clearConfiguredAgentId;
58
+ const auth_core_1 = require("@skrr-ai/auth-core");
58
59
  const data_provider_1 = require("@skrr-ai/data-provider");
59
60
  const api_fetch_1 = require("./api-fetch");
60
61
  const config_1 = require("./config");
61
- const sky_code_managed_1 = require("./sky-code-managed");
62
+ const first_party_harness_managed_1 = require("./first-party-harness-managed");
62
63
  /**
63
64
  * How many agents the refusal is allowed to look at.
64
65
  *
@@ -68,15 +69,15 @@ const sky_code_managed_1 = require("./sky-code-managed");
68
69
  const ROSTER_LIMIT = 100;
69
70
  /** How many candidates a refusal prints before it summarizes the rest. */
70
71
  const CANDIDATES_SHOWN = 12;
71
- class SkyCodeAgentError extends Error {
72
+ class FirstPartyHarnessAgentError extends Error {
72
73
  code;
73
74
  constructor(code, message) {
74
75
  super(message);
75
- this.name = 'SkyCodeAgentError';
76
+ this.name = 'FirstPartyHarnessAgentError';
76
77
  this.code = code;
77
78
  }
78
79
  }
79
- exports.SkyCodeAgentError = SkyCodeAgentError;
80
+ exports.FirstPartyHarnessAgentError = FirstPartyHarnessAgentError;
80
81
  /**
81
82
  * Resolve the agent for this session, or refuse with something actionable.
82
83
  *
@@ -94,9 +95,20 @@ exports.SkyCodeAgentError = SkyCodeAgentError;
94
95
  * a refusal listable. That is worth just as much care — a wrong pick is not a
95
96
  * breach, it is a bill someone else reads weeks later — but it is a different job.
96
97
  */
97
- async function resolveSkyCodeAgent(explicit, deps = {}, options = {}) {
98
- const configured = deps.configuredAgentId ?? (() => (0, config_1.loadConfig)().skyCodeAgentId);
99
- const explicitLabel = options.explicitLabel ?? sky_code_managed_1.SKRR_AGENT_FLAG;
98
+ async function resolveFirstPartyHarnessAgent(explicit, deps = {}, options = {}) {
99
+ // Lazy, as before: a session with an explicit flag must not fail on an
100
+ // unreadable config it never needed. The KEY travels with the value so a refusal
101
+ // names the key actually in the file, which is not always the one written today.
102
+ const configured = () => {
103
+ if (deps.configuredAgentId)
104
+ return { value: deps.configuredAgentId(), key: first_party_harness_managed_1.AGENT_CONFIG_KEY };
105
+ const setting = (0, first_party_harness_managed_1.readConfiguredAgentSetting)();
106
+ if (setting.legacy && migrateLegacyAgentSettingKey()) {
107
+ return { value: setting.value, key: first_party_harness_managed_1.AGENT_CONFIG_KEY };
108
+ }
109
+ return { value: setting.value, key: setting.key ?? first_party_harness_managed_1.AGENT_CONFIG_KEY };
110
+ };
111
+ const explicitLabel = options.explicitLabel ?? first_party_harness_managed_1.SKRR_AGENT_FLAG;
100
112
  let cached = null;
101
113
  const roster = async () => {
102
114
  if (cached)
@@ -105,11 +117,11 @@ async function resolveSkyCodeAgent(explicit, deps = {}, options = {}) {
105
117
  cached = (await (deps.listAgents ?? listAgents)(options.signal)).filter((row) => Boolean(row?.id));
106
118
  }
107
119
  catch (err) {
108
- throw new SkyCodeAgentError('agent-lookup-failed', `could not read your agents — ${message(err)}`);
120
+ throw new FirstPartyHarnessAgentError('agent-lookup-failed', `could not read your agents — ${message(err)}`);
109
121
  }
110
122
  return cached;
111
123
  };
112
- const named = async (ref, source) => {
124
+ const named = async (ref, source, configKey = first_party_harness_managed_1.AGENT_CONFIG_KEY) => {
113
125
  const rows = await roster();
114
126
  const byId = rows.find((row) => row.id === ref);
115
127
  if (byId)
@@ -122,8 +134,8 @@ async function resolveSkyCodeAgent(explicit, deps = {}, options = {}) {
122
134
  return { id: byName[0].id, ...(byName[0].name ? { name: byName[0].name } : {}), source };
123
135
  }
124
136
  if (byName.length > 1) {
125
- throw new SkyCodeAgentError('agent-ambiguous', `${describeSource(source, ref, explicitLabel)} matches ${byName.length} agents. ` +
126
- `Pass ${sky_code_managed_1.SKRR_AGENT_FLAG} with an id instead: ${candidates(byName)}`);
137
+ throw new FirstPartyHarnessAgentError('agent-ambiguous', `${describeSource(source, ref, explicitLabel, configKey)} matches ${byName.length} agents. ` +
138
+ `Pass ${first_party_harness_managed_1.SKRR_AGENT_FLAG} with an id instead: ${candidates(byName)}`);
127
139
  }
128
140
  // Not in the bounded roster. It may still be a real id belonging to a user with
129
141
  // more agents than the roster shows, so ask directly before refusing.
@@ -131,7 +143,7 @@ async function resolveSkyCodeAgent(explicit, deps = {}, options = {}) {
131
143
  if (direct?.id) {
132
144
  return { id: direct.id, ...(direct.name ? { name: direct.name } : {}), source };
133
145
  }
134
- throw new SkyCodeAgentError('agent-unknown', `${describeSource(source, ref, explicitLabel)} is not an agent you can run. ` +
146
+ throw new FirstPartyHarnessAgentError('agent-unknown', `${describeSource(source, ref, explicitLabel, configKey)} is not an agent you can run. ` +
135
147
  (rows.length ? `Yours: ${candidates(rows)}` : 'You have no agents yet.'));
136
148
  };
137
149
  /**
@@ -153,9 +165,10 @@ async function resolveSkyCodeAgent(explicit, deps = {}, options = {}) {
153
165
  const flag = explicit?.trim();
154
166
  if (flag)
155
167
  return named(flag, 'flag');
156
- const fromConfig = configured()?.trim();
157
- if (fromConfig)
158
- return named(fromConfig, 'config');
168
+ const fromConfig = configured();
169
+ const configuredRef = fromConfig.value?.trim();
170
+ if (configuredRef)
171
+ return named(configuredRef, 'config', fromConfig.key);
159
172
  const rows = await roster();
160
173
  if (rows.length === 1) {
161
174
  // AUTHORSHIP, not visibility. The roster is read at EDIT and `AGENT_EDITOR`
@@ -194,7 +207,7 @@ async function resolveSkyCodeAgent(explicit, deps = {}, options = {}) {
194
207
  // hardest to notice: "do not create" is not "do not look", and `--show`
195
208
  // would report "no default agent yet" while staring at the row.
196
209
  if (options.createDefault === false) {
197
- const existing = rows.find((row) => row.defaultForHarness === sky_code_managed_1.SKY_CODE_HARNESS);
210
+ const existing = rows.find((row) => (0, auth_core_1.isFirstPartyHarnessProvider)(row.defaultForHarness));
198
211
  if (existing?.id) {
199
212
  return {
200
213
  id: existing.id,
@@ -206,7 +219,9 @@ async function resolveSkyCodeAgent(explicit, deps = {}, options = {}) {
206
219
  try {
207
220
  const created = options.createDefault === false
208
221
  ? null
209
- : await (deps.ensureDefaultAgent ?? ensureDefaultAgent)(sky_code_managed_1.SKY_CODE_HARNESS, options.signal);
222
+ : await (deps.ensureDefaultAgent ?? ensureDefaultAgent)(
223
+ // Canonical: what the server stores. It accepts every spelling.
224
+ auth_core_1.FIRST_PARTY_HARNESS.provider, options.signal);
210
225
  if (created?.id) {
211
226
  return {
212
227
  id: created.id,
@@ -219,30 +234,30 @@ async function resolveSkyCodeAgent(explicit, deps = {}, options = {}) {
219
234
  catch (err) {
220
235
  if (isAbortError(err))
221
236
  throw err;
222
- throw new SkyCodeAgentError('agent-unset', `could not establish your default skrr Code agent — ${message(err)}. ` +
223
- `Pass ${sky_code_managed_1.SKRR_AGENT_FLAG} <id-or-name>, or set one with ` +
224
- '`skrr code skrr-agent --set <id>`' +
237
+ throw new FirstPartyHarnessAgentError('agent-unset', `could not establish your default ${auth_core_1.FIRST_PARTY_HARNESS.displayName} agent — ${message(err)}. ` +
238
+ `Pass ${first_party_harness_managed_1.SKRR_AGENT_FLAG} <id-or-name>, or set one with ` +
239
+ `\`${auth_core_1.FIRST_PARTY_HARNESS.command} skrr-agent --set <id>\`` +
225
240
  (rows.length ? `. Yours: ${candidates(rows)}` : ''));
226
241
  }
227
242
  // Asked, not told: the caller opted out of creation, so "no default" is a fact
228
243
  // about this machine rather than a failure, and the remedy is a real command.
229
244
  if (options.createDefault === false) {
230
- throw new SkyCodeAgentError('agent-unset', 'nothing is configured and you have no skrr Code default agent yet. ' +
245
+ throw new FirstPartyHarnessAgentError('agent-unset', `nothing is configured and you have no ${auth_core_1.FIRST_PARTY_HARNESS.displayName} default agent yet. ` +
231
246
  'One is created automatically the first time you run a managed session — ' +
232
- 'or make it now with `skrr code skrr-agent --create`' +
247
+ `or make it now with \`${auth_core_1.FIRST_PARTY_HARNESS.command} skrr-agent --create\`` +
233
248
  (rows.length ? `. Yours: ${candidates(rows)}` : ''));
234
249
  }
235
250
  // The endpoint answered without an agent. Nothing here can repair that, but
236
251
  // the user still has every ordinary way to name one.
237
- throw new SkyCodeAgentError('agent-unset', rows.length
238
- ? `skrr Code has no default agent for you and will not pick one of your ${rows.length}. ` +
239
- `Pass ${sky_code_managed_1.SKRR_AGENT_FLAG} <id-or-name>, or set "${sky_code_managed_1.AGENT_CONFIG_KEY}" in ` +
252
+ throw new FirstPartyHarnessAgentError('agent-unset', rows.length
253
+ ? `${auth_core_1.FIRST_PARTY_HARNESS.displayName} has no default agent for you and will not pick one of your ${rows.length}. ` +
254
+ `Pass ${first_party_harness_managed_1.SKRR_AGENT_FLAG} <id-or-name>, or set "${first_party_harness_managed_1.AGENT_CONFIG_KEY}" in ` +
240
255
  `${configPathHint()}. Yours: ${candidates(rows)}`
241
- : 'you have no agents and no default could be created, yet a managed skrr Code session ' +
256
+ : `you have no agents and no default could be created, yet a managed ${auth_core_1.FIRST_PARTY_HARNESS.displayName} session ` +
242
257
  'runs as one. Create an agent in the skrr app first');
243
258
  }
244
- function describeSource(source, ref, explicitLabel) {
245
- return source === 'config' ? `"${sky_code_managed_1.AGENT_CONFIG_KEY}": "${ref}"` : `${explicitLabel} "${ref}"`;
259
+ function describeSource(source, ref, explicitLabel, configKey) {
260
+ return source === 'config' ? `"${configKey}": "${ref}"` : `${explicitLabel} "${ref}"`;
246
261
  }
247
262
  function candidates(rows) {
248
263
  const shown = rows
@@ -263,22 +278,22 @@ function configPathHint() {
263
278
  }
264
279
  /** The stored value, unresolved — for a `--show` that must report "unset" honestly. */
265
280
  function readConfiguredAgentId() {
266
- return (0, config_1.loadConfig)().skyCodeAgentId?.trim() || undefined;
281
+ return (0, first_party_harness_managed_1.readConfiguredAgentSetting)().value;
267
282
  }
268
283
  /**
269
284
  * Persist the agent `skrr code` runs as when no flag is passed.
270
285
  *
271
- * Resolves through the SAME roster `resolveSkyCodeAgent` uses, for two reasons: a
286
+ * Resolves through the SAME roster `resolveFirstPartyHarnessAgent` uses, for two reasons: a
272
287
  * typo is refused while the user is still looking at it rather than at the start
273
288
  * of some later session, and what lands on disk is always a canonical id. Storing
274
289
  * the display name a user typed would silently break on the next rename.
275
290
  */
276
291
  async function setConfiguredAgentId(ref, deps = {}, options = {}) {
277
- const resolved = await resolveSkyCodeAgent(ref, deps, {
292
+ const resolved = await resolveFirstPartyHarnessAgent(ref, deps, {
278
293
  // Name the thing the user actually typed. Without this a bad `--set` value
279
- // is refused with "--oversky-agent \"typo\" is not an agent you can run",
294
+ // is refused with "--skrr-agent \"typo\" is not an agent you can run",
280
295
  // pointing at a flag that was never on the command line.
281
- explicitLabel: 'skrr code skrr-agent --set',
296
+ explicitLabel: `${auth_core_1.FIRST_PARTY_HARNESS.command} skrr-agent --set`,
282
297
  ...options,
283
298
  });
284
299
  writeConfigKey(resolved.id);
@@ -291,8 +306,7 @@ function clearConfiguredAgentId() {
291
306
  return previous;
292
307
  }
293
308
  function readRawConfigKey() {
294
- const value = (0, config_1.loadRawConfig)()[sky_code_managed_1.AGENT_CONFIG_KEY];
295
- return typeof value === 'string' && value.trim() ? value : undefined;
309
+ return (0, first_party_harness_managed_1.readAgentSetting)((0, config_1.loadRawConfig)()).value;
296
310
  }
297
311
  /**
298
312
  * Read-modify-write through the RAW accessors, never `loadConfig`/`saveConfig`.
@@ -304,13 +318,37 @@ function readRawConfigKey() {
304
318
  * that moved credentials to the keychain, on a command about an agent id. The raw
305
319
  * pair also preserves operator-added keys the typed shape does not enumerate.
306
320
  */
321
+ /**
322
+ * Move an agent setting stored under an older key onto the neutral one, on the
323
+ * first real session read. Returns whether the file now holds it under the
324
+ * neutral key.
325
+ *
326
+ * Reading alone used to leave it where it was, which is safe only while that key
327
+ * is still an accepted spelling. The contract phase empties the identity's
328
+ * aliases, `legacyAgentConfigKeys()` then stops naming the old key, and a user
329
+ * who never ran `--set`, `--clear` or logout would silently lose their setting.
330
+ * Moving it here retires the old key long before that date.
331
+ *
332
+ * Only the session path calls this — `skrr code doctor` reports and never
333
+ * writes. Best-effort: an unwritable config is left alone and still read.
334
+ */
335
+ function migrateLegacyAgentSettingKey() {
336
+ try {
337
+ const raw = (0, config_1.loadRawConfig)();
338
+ const stored = (0, first_party_harness_managed_1.readAgentSetting)(raw);
339
+ if (!stored.legacy || !stored.value)
340
+ return false;
341
+ (0, config_1.saveRawConfig)((0, first_party_harness_managed_1.withAgentSetting)(raw, stored.value));
342
+ return true;
343
+ }
344
+ catch {
345
+ return false;
346
+ }
347
+ }
307
348
  function writeConfigKey(id) {
308
- const raw = (0, config_1.loadRawConfig)();
309
- if (id)
310
- raw[sky_code_managed_1.AGENT_CONFIG_KEY] = id;
311
- else
312
- delete raw[sky_code_managed_1.AGENT_CONFIG_KEY];
313
- (0, config_1.saveRawConfig)(raw);
349
+ // Every older key goes too, so the file ends holding the setting under one
350
+ // name — a clear that left an older key behind would un-clear on the next read.
351
+ (0, config_1.saveRawConfig)((0, first_party_harness_managed_1.withAgentSetting)((0, config_1.loadRawConfig)(), id));
314
352
  }
315
353
  /**
316
354
  * The roster, at EDIT.
@@ -59,8 +59,8 @@
59
59
  */
60
60
  import { buildManagedInferenceRelayCredential, startManagedInferenceBroker, type RenewalStopReason } from '@skrr-ai/inference-broker';
61
61
  import { type ApiFetchOptions } from './api-fetch';
62
- import { type EngineExitOutcome } from './sky-code';
63
- import { type SkyCodeAgent } from './sky-code-agent';
62
+ import { type EngineExitOutcome } from './first-party-harness';
63
+ import { type FirstPartyHarnessAgent } from './first-party-harness-agent';
64
64
  /**
65
65
  * Reasons the server accepts for a release. An ALLOW-LIST on its side, mirrored
66
66
  * here as a type so a typo becomes a compile error rather than a silent
@@ -88,7 +88,7 @@ export interface ManagedSessionHandle {
88
88
  env: Record<string, string>;
89
89
  socketPath: string;
90
90
  sessionId: string;
91
- agent: SkyCodeAgent;
91
+ agent: FirstPartyHarnessAgent;
92
92
  reservationId: string;
93
93
  /** The ADMITTED model. After admission the reservation is the model authority. */
94
94
  model: string;
@@ -125,7 +125,7 @@ export interface ManagedSessionHandle {
125
125
  }
126
126
  type FetchLike = (url: string, init: RequestInit) => Promise<Response>;
127
127
  export interface AcquireManagedSessionInput {
128
- /** `--oversky-agent` value, if the user passed one. */
128
+ /** `--skrr-agent` (or `--oversky-agent`) value, if the user passed one. */
129
129
  agentRef?: string;
130
130
  /** The model the user named to the engine, if any. */
131
131
  model?: string;
@@ -147,7 +147,7 @@ export interface AcquireManagedSessionDeps {
147
147
  prefetchAuth?: () => Promise<void>;
148
148
  hasCredential?: () => boolean;
149
149
  /** `signal` is the acquisition-wide deadline; an override that ignores it is unbounded. */
150
- resolveAgent?: (ref?: string, signal?: AbortSignal) => Promise<SkyCodeAgent>;
150
+ resolveAgent?: (ref?: string, signal?: AbortSignal) => Promise<FirstPartyHarnessAgent>;
151
151
  /** The user-JWT call. Defaults to `apiFetch`. */
152
152
  api?: <T>(path: string, opts?: ApiFetchOptions) => Promise<T>;
153
153
  /** The session-token calls. Defaults to global `fetch`. */
@@ -226,7 +226,7 @@ export interface ManagedEngineHooks {
226
226
  }
227
227
  export interface ManagedEngineHooksInput {
228
228
  subcommand: string | null;
229
- /** Argv bound for the engine, with `--oversky-agent` already removed. */
229
+ /** Argv bound for the engine, with `--skrr-agent` / `--oversky-agent` already removed. */
230
230
  passthrough: readonly string[];
231
231
  agentRef?: string;
232
232
  env?: NodeJS.ProcessEnv;
@@ -75,9 +75,9 @@ const auth_core_init_1 = require("./auth-core-init");
75
75
  const config_1 = require("./config");
76
76
  const cred_envelope_1 = require("./cred-envelope");
77
77
  const device_id_1 = require("./device-id");
78
- const sky_code_1 = require("./sky-code");
79
- const sky_code_agent_1 = require("./sky-code-agent");
80
- const sky_code_managed_1 = require("./sky-code-managed");
78
+ const first_party_harness_1 = require("./first-party-harness");
79
+ const first_party_harness_agent_1 = require("./first-party-harness-agent");
80
+ const first_party_harness_managed_1 = require("./first-party-harness-managed");
81
81
  const task_execution_1 = require("./task-execution");
82
82
  /**
83
83
  * Harness selections the POLICY resolves, mirroring the server's own set.
@@ -173,7 +173,7 @@ async function acquireManagedSession(input = {}, deps = {}) {
173
173
  const newId = deps.newId ?? (() => (0, node_crypto_1.randomUUID)());
174
174
  const fetchImpl = deps.fetchImpl ?? ((url, init) => fetch(url, init));
175
175
  const api = deps.api ?? ((path, opts) => (0, api_fetch_1.apiFetch)(path, opts));
176
- const serverUrl = (deps.serverUrl ?? (() => (0, sky_code_managed_1.skyCodeServerUrl)(input.env ?? process.env)))();
176
+ const serverUrl = (deps.serverUrl ?? (() => (0, first_party_harness_managed_1.configuredServerUrl)(input.env ?? process.env)))();
177
177
  // Envelope-wrapped credentials are unreadable until this has run: without it
178
178
  // `readFromBackend` returns a null plaintext and the whole bundle is dropped, so
179
179
  // a signed-in user looks signed out. `BaseCommand` awaits it for the same reason
@@ -236,7 +236,7 @@ async function acquireManagedSession(input = {}, deps = {}) {
236
236
  let lease;
237
237
  try {
238
238
  agent = await (deps.resolveAgent ??
239
- ((ref, signal) => (0, sky_code_agent_1.resolveSkyCodeAgent)(ref, {}, signal ? { signal } : {})))(input.agentRef, acquisition.signal);
239
+ ((ref, signal) => (0, first_party_harness_agent_1.resolveFirstPartyHarnessAgent)(ref, {}, signal ? { signal } : {})))(input.agentRef, acquisition.signal);
240
240
  // Say it exactly once, on the run that actually minted it.
241
241
  //
242
242
  // A user who never chose an agent is about to have a new one appear in their
@@ -245,9 +245,9 @@ async function acquireManagedSession(input = {}, deps = {}) {
245
245
  // on every subsequent session, which is why the server distinguishes created
246
246
  // from found rather than the CLI guessing from a timestamp.
247
247
  if (agent.createdNow) {
248
- input.log?.(`Created "${agent.name ?? agent.id}" as your default skrr Code agent — ` +
248
+ input.log?.(`Created "${agent.name ?? agent.id}" as your default ${auth_core_1.FIRST_PARTY_HARNESS.displayName} agent — ` +
249
249
  'this session, and future ones, are attributed to it. ' +
250
- 'Change it with `skrr code skrr-agent --set <id-or-name>`.');
250
+ `Change it with \`${auth_core_1.FIRST_PARTY_HARNESS.command} skrr-agent --set <id-or-name>\`.`);
251
251
  }
252
252
  const minted = await mintSessionToken({ sessionId, processStartId, agentId: agent.id, actorId: newId() }, api, acquisition.signal);
253
253
  sessionToken = minted.token;
@@ -942,31 +942,31 @@ function localClock(atMs) {
942
942
  * wrong one of the three is the confusion, not a mitigation of it.
943
943
  *
944
944
  * The predicate is `hasProviderCredential`, the same one that decides what the
945
- * engine actually inherits (`sky-code.ts`), so the sentence and the spawn cannot
945
+ * engine actually inherits (`first-party-harness.ts`), so the sentence and the spawn cannot
946
946
  * disagree. `strippedProviderCredentialNames` covers the third case that
947
947
  * predicate cannot see: the machine HAS a provider credential and this run
948
948
  * removes it, which reads as absence and is not.
949
949
  */
950
950
  function fallbackTail(env) {
951
- if ((0, sky_code_1.hasProviderCredential)(env))
951
+ if ((0, first_party_harness_1.hasProviderCredential)(env))
952
952
  return 'Continuing with your own provider credentials.';
953
953
  // Absence and removal are different problems, and the old sentence said the
954
954
  // first when the second was true: on a machine whose only credential is an AWS
955
955
  // profile the engine runs fine on its own and fails through `skrr code`,
956
956
  // because `AWS_*` is stripped on the way in. Being told "no provider
957
957
  // credential is set here" sends that user to buy a key they do not need.
958
- const stripped = (0, sky_code_1.strippedProviderCredentialNames)(env);
958
+ const stripped = (0, first_party_harness_1.strippedProviderCredentialNames)(env);
959
959
  if (stripped.length > 0) {
960
960
  return (`${stripped.join(', ')} is set here, but this run does not pass it to the engine — ` +
961
961
  'it is stripped so a model-driven process opening other people\u2019s repositories cannot ' +
962
962
  'reuse a cloud credential. So the engine starts without one and its first request will ' +
963
963
  'fail. Export a provider key the engine may inherit (any `*_API_KEY`, e.g. ' +
964
964
  'OPENROUTER_API_KEY), resolve the reason above, or run the engine directly if you ' +
965
- 'intend to spend that credential (`skrr code doctor` shows where it is).');
965
+ `intend to spend that credential (\`${auth_core_1.FIRST_PARTY_HARNESS.command} doctor\` shows where it is).`);
966
966
  }
967
967
  return ('No provider credential is set here either, so the engine will start without one and ' +
968
968
  'its first request will fail — set OPENROUTER_API_KEY, or resolve the reason above ' +
969
- '(`skrr code doctor`).');
969
+ `(\`${auth_core_1.FIRST_PARTY_HARNESS.command} doctor\`).`);
970
970
  }
971
971
  /**
972
972
  * Build the three `execEngine` hooks for one `skrr code` invocation.
@@ -992,7 +992,7 @@ function createManagedEngineHooks(input) {
992
992
  const env = input.env ?? process.env;
993
993
  const log = input.log ?? ((line) => process.stderr.write(`${line}\n`));
994
994
  const acquire = input.acquire ?? acquireManagedSession;
995
- const requestedModel = (0, sky_code_managed_1.namedEngineModel)(input.passthrough);
995
+ const requestedModel = (0, first_party_harness_managed_1.namedEngineModel)(input.passthrough);
996
996
  let handle = null;
997
997
  /**
998
998
  * Set the instant teardown begins, so a renewal refusal our OWN release caused
@@ -1008,7 +1008,7 @@ function createManagedEngineHooks(input) {
1008
1008
  // user was told so.
1009
1009
  credentialMode: () => (handle ? 'managed' : 'byok'),
1010
1010
  prepare: async () => {
1011
- const skip = (0, sky_code_managed_1.managedSkipReason)(env);
1011
+ const skip = (0, first_party_harness_managed_1.managedSkipReason)(env);
1012
1012
  if (skip) {
1013
1013
  if (skip.announce)
1014
1014
  log(`Managed inference not used: ${skip.detail}. ${fallbackTail(env)}`);
@@ -1061,14 +1061,14 @@ function createManagedEngineHooks(input) {
1061
1061
  const failure = managedAcquisitionFailure(err, env);
1062
1062
  log(failure.line);
1063
1063
  if (failure.action === 'refuse') {
1064
- throw new sky_code_1.EngineStartRefusedError(failure.code, failure.line);
1064
+ throw new first_party_harness_1.EngineStartRefusedError(failure.code, failure.line);
1065
1065
  }
1066
1066
  return {};
1067
1067
  }
1068
1068
  },
1069
1069
  finalizeArgs: (args) =>
1070
1070
  // Only when WE resolved the model. A user-named model is already in the argv.
1071
- (0, sky_code_managed_1.withManagedModel)(input.subcommand, args, handle && !requestedModel ? (handle.clientModelId ?? handle.model) : undefined),
1071
+ (0, first_party_harness_managed_1.withManagedModel)(input.subcommand, args, handle && !requestedModel ? (handle.clientModelId ?? handle.model) : undefined),
1072
1072
  cleanup: async (outcome) => {
1073
1073
  const live = handle;
1074
1074
  handle = null;
@@ -1126,7 +1126,7 @@ function managedRenewalStoppedLine(reason, detail) {
1126
1126
  // the useful detail here is WHEN the window ended, not which rule fired.
1127
1127
  return ('Managed inference reached the limit this session was authorized for' +
1128
1128
  `${detail ? ` (${detail})` : ''}. ` +
1129
- 'It cannot be extended further — start a new `skrr code` session to continue.');
1129
+ `It cannot be extended further — start a new \`${auth_core_1.FIRST_PARTY_HARNESS.command}\` session to continue.`);
1130
1130
  case 'expired':
1131
1131
  // Deliberately names the cause rather than only the fact. A user who was
1132
1132
  // told "renewal was refused" goes looking for a policy or budget problem;
@@ -1134,7 +1134,7 @@ function managedRenewalStoppedLine(reason, detail) {
1134
1134
  // and the fix is the same one-liner as the ceiling's.
1135
1135
  return ('Managed inference lost its session credential before it could be refreshed' +
1136
1136
  `${detail ? ` (${detail})` : ''} — this usually means the machine slept. ` +
1137
- 'Start a new `skrr code` session to continue.');
1137
+ `Start a new \`${auth_core_1.FIRST_PARTY_HARNESS.command}\` session to continue.`);
1138
1138
  case 'exhausted': {
1139
1139
  // OSK-3932 — the money, which until now could only reach the user as
1140
1140
  // `denied` ("something is wrong with your access") or, worse, as nothing at
@@ -1155,7 +1155,7 @@ function managedRenewalStoppedLine(reason, detail) {
1155
1155
  'or export OPENROUTER_API_KEY to continue on your own key.');
1156
1156
  }
1157
1157
  return ('Managed inference stopped: this session spent the budget it was authorized. ' +
1158
- 'Waiting will not restore it — start a new `skrr code` session to continue, ' +
1158
+ `Waiting will not restore it — start a new \`${auth_core_1.FIRST_PARTY_HARNESS.command}\` session to continue, ` +
1159
1159
  'or export OPENROUTER_API_KEY to continue on your own key.');
1160
1160
  }
1161
1161
  case 'denied':
@@ -1175,7 +1175,7 @@ function managedRenewalStoppedLine(reason, detail) {
1175
1175
  return (`Managed inference renewal was refused (${reason}${because}). ` +
1176
1176
  'This session will lose access to the model shortly. This is an answer about ' +
1177
1177
  'your account rather than the clock, so a new session may get it again — run ' +
1178
- '`skrr code doctor`, or export OPENROUTER_API_KEY to continue on your own key.');
1178
+ `\`${auth_core_1.FIRST_PARTY_HARNESS.command} doctor\`, or export OPENROUTER_API_KEY to continue on your own key.`);
1179
1179
  default:
1180
1180
  // `unavailable`, and any reason a future package version adds: the cautious
1181
1181
  // sentence is the right default for something this CLI does not recognise.
@@ -1185,7 +1185,7 @@ function managedRenewalStoppedLine(reason, detail) {
1185
1185
  // than the fix.
1186
1186
  return (`Managed inference could not renew its lease (${reason}${because}). ` +
1187
1187
  'This session will lose access to the model shortly. If it does not recover, ' +
1188
- 'start a new `skrr code` session, or export OPENROUTER_API_KEY to continue on ' +
1188
+ `start a new \`${auth_core_1.FIRST_PARTY_HARNESS.command}\` session, or export OPENROUTER_API_KEY to continue on ` +
1189
1189
  'your own key.');
1190
1190
  }
1191
1191
  }
@@ -1276,9 +1276,9 @@ function managedAcquisitionFailure(err, env = process.env) {
1276
1276
  * offered where there is no key to spend.
1277
1277
  */
1278
1278
  function refusalTail(env) {
1279
- if ((0, sky_code_1.hasProviderCredential)(env)) {
1279
+ if ((0, first_party_harness_1.hasProviderCredential)(env)) {
1280
1280
  return ('`skrr code` did not start the engine; to run on your own provider key instead, ' +
1281
- `set ${sky_code_managed_1.MANAGED_ENV_FLAG}=0.`);
1281
+ `set ${first_party_harness_managed_1.MANAGED_ENV_FLAG}=0.`);
1282
1282
  }
1283
1283
  return '`skrr code` did not start the engine.';
1284
1284
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * WL-6.9 — skrr Code diagnostics.
2
+ * WL-6.9 — first-party harness diagnostics (`skrr code doctor`).
3
3
  *
4
4
  * The plan makes this a launch gate, phrased as: support must be able to
5
5
  * identify the product version, upstream base, config source, and runtime mode
@@ -20,6 +20,12 @@
20
20
  * actions, and collapsing them into one red line is how a user spends an
21
21
  * hour reinstalling something that was merely absent. Hence three statuses,
22
22
  * not two.
23
+ *
24
+ * Every product-named value — display name, binary name, project directory, env
25
+ * var names — comes from the identity module in `@skrr-ai/auth-core`. A variable
26
+ * that was read under an OLDER name is reported by that name, with the neutral
27
+ * one to move to: the older names are still honoured, and a diagnostic that
28
+ * hid which one was in effect would send an operator to edit the wrong line.
23
29
  */
24
30
  export type CheckStatus = 'ok' | 'warn' | 'fail';
25
31
  export interface DoctorCheck {
@@ -35,7 +41,11 @@ export interface DoctorReport {
35
41
  /** `fail` if any check failed, else `warn` if any warned, else `ok`. */
36
42
  status: CheckStatus;
37
43
  }
38
- /** Project-level state dir. Basename deliberately differs from `~/.skrr`. */
44
+ /**
45
+ * Project-level state dir — the ENGINE's own project marker
46
+ * (`FIRST_PARTY_HARNESS_ENGINE.projectDirectory`). Basename deliberately differs
47
+ * from `~/.skrr`.
48
+ */
39
49
  export declare function projectStateDir(cwd: string): string;
40
50
  export declare function runDoctor(cwd?: string, env?: NodeJS.ProcessEnv): DoctorReport;
41
51
  /** Render a report for a terminal. */