agent-transport-system 0.7.25 → 0.7.27

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/ats.js CHANGED
@@ -27,7 +27,7 @@ import wrapAnsi from "wrap-ansi";
27
27
  import { Box, Container, Editor, Key, ProcessTerminal, TUI, Text, getEditorKeybindings, matchesKey } from "@mariozechner/pi-tui";
28
28
 
29
29
  //#region package.json
30
- var version = "0.7.25";
30
+ var version = "0.7.27";
31
31
  var package_default = {
32
32
  $schema: "https://www.schemastore.org/package.json",
33
33
  name: "agent-transport-system",
@@ -8213,7 +8213,7 @@ function normalizeFixtureText(value) {
8213
8213
  }
8214
8214
  function buildContractCandidate(input, pathInput, current) {
8215
8215
  const lane = input.lane ?? resolveAtsEnvPreset(pathInput);
8216
- const connectedComputerId = input.connectedComputerId ?? (current && current.lane === lane && current.gatewayUrl === input.gatewayUrl && current.profileId === input.profileId && current.deviceId === input.deviceId ? current.connectedComputerId : void 0);
8216
+ const connectedComputerId = input.connectedComputerId ?? (current && current.lane === lane && current.gatewayUrl === input.gatewayUrl && current.deviceId === input.deviceId ? current.connectedComputerId : void 0);
8217
8217
  return {
8218
8218
  schema: "ats-daemon-service-contract-v1",
8219
8219
  v: 1,
@@ -45864,6 +45864,7 @@ function renderDaemonReinstallCard(input) {
45864
45864
  }
45865
45865
  function renderDaemonReinstallOutcome(input) {
45866
45866
  emitDaemonReinstallResult(input);
45867
+ if (input.suppressHumanResultCard === true) return;
45867
45868
  renderDaemonReinstallCard(input);
45868
45869
  }
45869
45870
  function createDaemonStartSpinner(input) {
@@ -46180,7 +46181,8 @@ async function runDaemonReinstall(input, options = {}) {
46180
46181
  action: displayAction,
46181
46182
  outcome,
46182
46183
  presenter,
46183
- resolvedView: runtime.resolvedView
46184
+ resolvedView: runtime.resolvedView,
46185
+ suppressHumanResultCard: options.suppressHumanResultCard
46184
46186
  });
46185
46187
  return outcome;
46186
46188
  } catch (error) {
@@ -50171,6 +50173,7 @@ async function runDaemonServiceParticipationInstallAction(input) {
50171
50173
  await runDaemonServiceSafeRefresh({
50172
50174
  atsProfileId: input.input.atsProfileId,
50173
50175
  gatewayUrl: input.input.gatewayUrl,
50176
+ suppressHumanResultCard: input.input.suppressRefreshHumanResultCard,
50174
50177
  view: input.input.view
50175
50178
  });
50176
50179
  return;
@@ -50210,6 +50213,7 @@ async function runDaemonServiceSafeRefresh(input) {
50210
50213
  skipConfirm: true,
50211
50214
  startAfterInstallMode: "always",
50212
50215
  suppressAgentOverview: true,
50216
+ suppressHumanResultCard: input.suppressHumanResultCard,
50213
50217
  suppressInstallOutput: true
50214
50218
  });
50215
50219
  }
@@ -50249,6 +50253,7 @@ async function runDaemonServiceParticipationRefresh(input) {
50249
50253
  const refreshOutcome = await runDaemonServiceSafeRefresh({
50250
50254
  atsProfileId: input.input.atsProfileId,
50251
50255
  gatewayUrl: input.input.gatewayUrl,
50256
+ suppressHumanResultCard: input.input.suppressRefreshHumanResultCard,
50252
50257
  view: input.input.view
50253
50258
  });
50254
50259
  if (refreshOutcome.ok && (refreshOutcome.result === "completed" || refreshOutcome.result === "stopped_safe") && refreshOutcome.serviceState === "stopped") {
@@ -73552,21 +73557,27 @@ function buildSpacePasswordRequirementsText() {
73552
73557
  function resolveSpacePasswordPromptReason(error) {
73553
73558
  const parsed = parseHttpErrorMessage$1(error);
73554
73559
  const rawMessage = toErrorMessage$6(error);
73555
- const requiredByRaw = SPACE_PASSWORD_REQUIRED_HINT_REGEX.test(rawMessage);
73556
- const invalidByRaw = SPACE_PASSWORD_INVALID_HINT_REGEX.test(rawMessage);
73557
73560
  if (!parsed) {
73558
- if (requiredByRaw) return "required";
73559
- if (invalidByRaw) return "invalid";
73561
+ if (isLegacyPlainPasswordError(rawMessage, "required")) return "required";
73562
+ if (isLegacyPlainPasswordError(rawMessage, "invalid")) return "invalid";
73560
73563
  return null;
73561
73564
  }
73562
73565
  const code = parsed.code.toLowerCase();
73563
- const parsedMessage = `${parsed.message}\n${parsed.body}`;
73564
- const requiredByParsed = SPACE_PASSWORD_REQUIRED_HINT_REGEX.test(parsedMessage);
73565
- const invalidByParsed = SPACE_PASSWORD_INVALID_HINT_REGEX.test(parsedMessage);
73566
- if (code === "space.password_required" || requiredByRaw || requiredByParsed) return "required";
73567
- if (code === "space.password_invalid" || invalidByRaw || invalidByParsed) return "invalid";
73566
+ if (code === "space.password_required" || isWrappedHttpPasswordError(parsed, "required")) return "required";
73567
+ if (code === "space.password_invalid" || isWrappedHttpPasswordError(parsed, "invalid")) return "invalid";
73568
73568
  return null;
73569
73569
  }
73570
+ function isLegacyPlainPasswordError(message, reason) {
73571
+ const normalized = message.trim().toLowerCase();
73572
+ if (reason === "required") return normalized === "space password required";
73573
+ return normalized === "space password invalid";
73574
+ }
73575
+ function isWrappedHttpPasswordError(parsed, reason) {
73576
+ const expectedStatus = reason === "required" ? 401 : 403;
73577
+ const hintRegex = reason === "required" ? SPACE_PASSWORD_REQUIRED_HINT_REGEX : SPACE_PASSWORD_INVALID_HINT_REGEX;
73578
+ if (parsed.status === expectedStatus && hintRegex.test(parsed.message)) return true;
73579
+ return new RegExp(`\\bHTTP\\s+${expectedStatus}\\b`, "i").test(parsed.message) && hintRegex.test(parsed.message);
73580
+ }
73570
73581
  async function promptSpacePassword() {
73571
73582
  const password$1 = await password({
73572
73583
  message: "Space password",
@@ -73637,7 +73648,8 @@ function parseHttpErrorMessage$1(error) {
73637
73648
  if (parsedFailure) return {
73638
73649
  body: parsedFailure.body,
73639
73650
  code: parsedFailure.code,
73640
- message: parsedFailure.message
73651
+ message: parsedFailure.message,
73652
+ status: parsedFailure.status
73641
73653
  };
73642
73654
  const message = toErrorMessage$6(error);
73643
73655
  const match = HTTP_ERROR_MESSAGE_REGEX.exec(message.trim());
@@ -73649,7 +73661,8 @@ function parseHttpErrorMessage$1(error) {
73649
73661
  return {
73650
73662
  body,
73651
73663
  code: readHttpErrorField$1(payload, "code"),
73652
- message: readHttpErrorField$1(payload, "message")
73664
+ message: readHttpErrorField$1(payload, "message"),
73665
+ status
73653
73666
  };
73654
73667
  }
73655
73668
  function readHttpErrorField$1(payload, field) {
@@ -76582,6 +76595,11 @@ function buildSpaceListProofPayload() {
76582
76595
  async function runSpaceAddMembers(input) {
76583
76596
  const hasExplicitBaseUrlInput = String(input.baseUrl ?? "").trim().length > 0;
76584
76597
  const explicitMemberIds = (input.members ?? []).map((memberId) => normalizeOptionalString$8(memberId)).filter((memberId) => Boolean(memberId));
76598
+ if (input.all === true || explicitMemberIds.length > 0) validateSpaceMemberSelectionInput({
76599
+ all: input.all === true,
76600
+ command: "add-members",
76601
+ explicitMemberIds
76602
+ });
76585
76603
  const currentProfileId = normalizeOptionalString$8(input.profile) ?? getCurrentCommandCheckState().selectedProfile?.profile?.atsProfileId ?? null;
76586
76604
  if (currentProfileId && explicitMemberIds.includes(currentProfileId)) throw createSpaceAddMembersCurrentProfileGuideError({ profileId: currentProfileId });
76587
76605
  const context = await prepareAuthenticatedSpaceCommandContext({
@@ -87259,6 +87277,67 @@ function normalizeId(value) {
87259
87277
  return value.trim();
87260
87278
  }
87261
87279
 
87280
+ //#endregion
87281
+ //#region src/ui/setup-human-view.ts
87282
+ async function runWithSetupSpinner(input) {
87283
+ const spinner = createDelayedSpinner({
87284
+ enabled: input.enabled,
87285
+ message: input.message
87286
+ });
87287
+ spinner.start();
87288
+ try {
87289
+ const result = await input.run();
87290
+ spinner.complete();
87291
+ return result;
87292
+ } catch (error) {
87293
+ spinner.fail();
87294
+ throw error;
87295
+ }
87296
+ }
87297
+ function emitSetupHumanHeader(input) {
87298
+ if (input.view !== "human") return;
87299
+ input.presenter.line({
87300
+ code: "setup.header.spacing.start",
87301
+ text: ""
87302
+ });
87303
+ for (const line of renderAtsBrandBlockLines()) input.presenter.line({
87304
+ code: "setup.header.brand",
87305
+ text: line
87306
+ });
87307
+ input.presenter.line({
87308
+ code: "setup.header.spacing.end",
87309
+ text: ""
87310
+ });
87311
+ }
87312
+ function renderSetupStepCard(input) {
87313
+ if (input.view !== "human") return;
87314
+ renderInfoCard({
87315
+ presenter: input.presenter,
87316
+ title: input.title,
87317
+ codePrefix: input.codePrefix,
87318
+ rows: input.rows,
87319
+ sanitize: true,
87320
+ minContentWidth: 52
87321
+ });
87322
+ }
87323
+ function renderSetupAgentHandoffCard(input) {
87324
+ if (input.view !== "human") return;
87325
+ renderInfoCard({
87326
+ presenter: input.presenter,
87327
+ title: "For AI Setup Agents",
87328
+ codePrefix: "setup.complete.agent_handoff.card",
87329
+ rows: [{
87330
+ label: "Structured output",
87331
+ value: `Run ${formatAtsCliCommand(`${input.cliCommandPrefix} setup --view agent`)} to print setup.complete.`
87332
+ }, {
87333
+ label: "Use when",
87334
+ value: "An AI setup agent needs the machine-readable setup facts for follow-up ATS commands."
87335
+ }],
87336
+ sanitize: true,
87337
+ minContentWidth: 52
87338
+ });
87339
+ }
87340
+
87262
87341
  //#endregion
87263
87342
  //#region src/start-foundation/profile-id.ts
87264
87343
  function resolveCliStartFoundationProfileId(profile) {
@@ -88738,14 +88817,6 @@ function recordCliStartHandoffFailure(input) {
88738
88817
 
88739
88818
  //#endregion
88740
88819
  //#region src/commands/local-runtime-observed-metadata.ts
88741
- async function syncStandaloneLocalRuntimeObservedMetadata(input) {
88742
- const deviceId = readCliStartDeviceProjection(input.foundation).value?.deviceId ?? null;
88743
- if (!deviceId) return;
88744
- await createCurrentDeviceApi(createCliApiClientFoundation(input.gatewayUrl)).writeObservedMetadata({
88745
- deviceId,
88746
- metadata: await collectObservedDeviceMetadata({ now: input.now })
88747
- });
88748
- }
88749
88820
  async function syncSetupTokenLocalRuntimeObservedMetadata(input) {
88750
88821
  await input.currentDeviceApi.writeSetupTokenObservedMetadata({
88751
88822
  opaqueToken: input.opaqueToken,
@@ -91320,6 +91391,10 @@ async function runSetupUnlocked(input) {
91320
91391
  const presenter = createPresenter(runtime);
91321
91392
  const interactive = canUseInteractivePrompts(runtime);
91322
91393
  const gatewayUrl = await resolveBaseUrl();
91394
+ emitSetupHumanHeader({
91395
+ presenter,
91396
+ view: runtime.resolvedView
91397
+ });
91323
91398
  await maybeLogInWithOneTimeToken({
91324
91399
  ott: input.ott,
91325
91400
  view: input.view
@@ -91330,28 +91405,51 @@ async function runSetupUnlocked(input) {
91330
91405
  promptMessage: "Sign in to ATS before setting up this computer.",
91331
91406
  allowPrompt: interactive
91332
91407
  })) return;
91333
- emitSetupStatus(runtime, "Checking local agents", ["Looking for supported local agents on this computer."]);
91334
- const initialReadiness = await collectStartLocalReadiness({ auth: {
91335
- status: "valid",
91336
- email: null,
91337
- authBaseUrl: null,
91338
- gatewayUrl
91339
- } });
91408
+ const initialReadiness = await runWithSetupSpinner({
91409
+ enabled: runtime.resolvedView === "human",
91410
+ message: "Checking local agents...",
91411
+ run: async () => await collectStartLocalReadiness({ auth: {
91412
+ status: "valid",
91413
+ email: null,
91414
+ authBaseUrl: null,
91415
+ gatewayUrl
91416
+ } })
91417
+ });
91340
91418
  const selectedLocalAgentIds = resolveSetupLocalAgentIds({
91341
91419
  localAgent: input.localAgent,
91342
91420
  localAgents: input.localAgents,
91343
91421
  readiness: initialReadiness
91344
91422
  });
91345
- if (selectedLocalAgentIds.length > 0) {
91346
- emitSetupStatus(runtime, "Connecting local agents", [`Connecting ${selectedLocalAgentIds.length} local agent${selectedLocalAgentIds.length === 1 ? "" : "s"} for ATS.`]);
91347
- assertStartLocalAgentsEnableCompleted(await runStartLocalAgentsEnable({
91423
+ if (selectedLocalAgentIds.length > 0) assertStartLocalAgentsEnableCompleted(await runWithSetupSpinner({
91424
+ enabled: runtime.resolvedView === "human",
91425
+ message: "Connecting local agents...",
91426
+ run: async () => await runStartLocalAgentsEnable({
91348
91427
  agent: selectedLocalAgentIds,
91349
91428
  interactive,
91350
91429
  presentation: "handoff",
91351
91430
  view: input.view
91352
- }));
91353
- }
91354
- emitSetupStatus(runtime, "Starting ATS Service", ["Starting or repairing ATS Service for this computer."]);
91431
+ })
91432
+ }));
91433
+ renderSetupStepCard({
91434
+ presenter,
91435
+ view: runtime.resolvedView,
91436
+ title: "✓ Local Agents",
91437
+ codePrefix: "setup.local_agents.card",
91438
+ rows: [
91439
+ {
91440
+ label: "Status",
91441
+ value: selectedLocalAgentIds.length > 0 ? "Connected" : "No local agents selected"
91442
+ },
91443
+ {
91444
+ label: "Found",
91445
+ value: formatSetupLocalAgentCandidateCount(initialReadiness)
91446
+ },
91447
+ {
91448
+ label: "Selected",
91449
+ value: formatSetupCompleteLocalAgents(selectedLocalAgentIds)
91450
+ }
91451
+ ]
91452
+ });
91355
91453
  const serviceGate = await runDaemonServiceParticipationGate({
91356
91454
  intent: "start",
91357
91455
  presenter,
@@ -91361,11 +91459,36 @@ async function runSetupUnlocked(input) {
91361
91459
  gatewayUrl,
91362
91460
  forcePrompt: true,
91363
91461
  refreshIfAuthSessionChanged: true,
91462
+ suppressRefreshHumanResultCard: true,
91364
91463
  view: input.view
91365
91464
  });
91366
91465
  if (serviceGate.status === "cancelled") return;
91367
91466
  if (serviceGate.status !== "aligned") throw new Error(serviceGate.errorMessage ?? "ATS Service could not be started for setup on this computer.");
91368
91467
  const atsServiceRuntimeIdentity = await syncLocalSetupCurrentDeviceTargetFromServiceContract({ gatewayUrl });
91468
+ renderSetupStepCard({
91469
+ presenter,
91470
+ view: runtime.resolvedView,
91471
+ title: "✓ ATS Service",
91472
+ codePrefix: "setup.service.card",
91473
+ rows: [
91474
+ {
91475
+ label: "Status",
91476
+ value: "Connected"
91477
+ },
91478
+ {
91479
+ label: "What happened",
91480
+ value: "ATS checked the background service and aligned it with this setup."
91481
+ },
91482
+ {
91483
+ label: "Current service",
91484
+ value: formatSetupCompleteService(atsServiceRuntimeIdentity)
91485
+ },
91486
+ {
91487
+ label: "Next",
91488
+ value: "No action is required."
91489
+ }
91490
+ ]
91491
+ });
91369
91492
  const finalReadiness = await collectStartLocalReadiness({ auth: {
91370
91493
  status: "valid",
91371
91494
  email: null,
@@ -91382,8 +91505,31 @@ async function runSetupUnlocked(input) {
91382
91505
  });
91383
91506
  assertSelectedLocalRuntimeReportsAccepted(runtimeReports);
91384
91507
  const routeCatalogSync = selectedLocalAgentIds.length > 0 ? await notifyRouteCatalogAfterSetup({ reason: "setup_local_capabilities_reported" }) : null;
91385
- emitSetupStatus(runtime, "Updating ATS skills", ["Updating ATS skills so local agents use the current ATS instructions."]);
91386
- await ensureSetupManagedSkills({ view: input.view });
91508
+ await runWithSetupSpinner({
91509
+ enabled: runtime.resolvedView === "human",
91510
+ message: "Updating ATS skills...",
91511
+ run: async () => await ensureSetupManagedSkills({ view: input.view })
91512
+ });
91513
+ renderSetupStepCard({
91514
+ presenter,
91515
+ view: runtime.resolvedView,
91516
+ title: "✓ ATS Skills",
91517
+ codePrefix: "setup.skills.card",
91518
+ rows: [
91519
+ {
91520
+ label: "Status",
91521
+ value: "Updated"
91522
+ },
91523
+ {
91524
+ label: "What happened",
91525
+ value: "ATS refreshed the local instructions used by supported agents."
91526
+ },
91527
+ {
91528
+ label: "Next",
91529
+ value: "Local agents can use the current ATS guide."
91530
+ }
91531
+ ]
91532
+ });
91387
91533
  emitSetupComplete({
91388
91534
  gatewayUrl,
91389
91535
  localComponents: await finalizeLocalComponentsSetupSnapshot(),
@@ -91461,10 +91607,6 @@ function assertStartLocalAgentsEnableCompleted(result) {
91461
91607
  async function notifyRouteCatalogAfterSetup(input) {
91462
91608
  return await notifyDaemonRouteCatalogChanged({ reason: input.reason });
91463
91609
  }
91464
- function emitSetupStatus(runtime, title, lines) {
91465
- if (runtime.resolvedView !== "human") return;
91466
- console.log([title, ...lines].join("\n"));
91467
- }
91468
91610
  async function emitSetupCompleteForDelegatedPath(input) {
91469
91611
  const runtime = await resolveRuntimeContext({ view: input.view });
91470
91612
  const presenter = createPresenter(runtime);
@@ -91584,17 +91726,13 @@ function emitSetupComplete(input) {
91584
91726
  if (input.view === "human") {
91585
91727
  renderInfoCard({
91586
91728
  presenter: input.presenter,
91587
- title: "ATS Setup Complete",
91729
+ title: "ATS Setup Complete",
91588
91730
  codePrefix: "setup.complete.card",
91589
91731
  sanitize: true,
91590
91732
  rows: [
91591
91733
  {
91592
- label: "CLI prefix",
91593
- value: cliCommandPrefix
91594
- },
91595
- {
91596
- label: "Lane root",
91597
- value: payload.laneRoot
91734
+ label: "Status",
91735
+ value: "Ready"
91598
91736
  },
91599
91737
  {
91600
91738
  label: "Local agents",
@@ -91608,15 +91746,20 @@ function emitSetupComplete(input) {
91608
91746
  label: "Service",
91609
91747
  value: formatSetupCompleteService(input.atsServiceRuntimeIdentity)
91610
91748
  },
91749
+ {
91750
+ label: "Local components",
91751
+ value: input.localComponents.summaryLabel
91752
+ },
91611
91753
  {
91612
91754
  label: "Next",
91613
91755
  value: nextCommands[1] ?? ""
91614
91756
  }
91615
91757
  ]
91616
91758
  });
91617
- emitHumanSetupCompleteAgentHandoff({
91618
- payload,
91619
- presenter: input.presenter
91759
+ renderSetupAgentHandoffCard({
91760
+ cliCommandPrefix,
91761
+ presenter: input.presenter,
91762
+ view: input.view
91620
91763
  });
91621
91764
  return;
91622
91765
  }
@@ -91673,33 +91816,6 @@ async function finalizeLocalComponentsSetupSnapshot() {
91673
91816
  await writeInstalledLocalComponentsSnapshot({ source: "setup" });
91674
91817
  return await resolveLocalComponentsStatus();
91675
91818
  }
91676
- function emitHumanSetupCompleteAgentHandoff(input) {
91677
- input.presenter.line({
91678
- code: "setup.complete.agent_handoff.heading",
91679
- text: "Agent handoff: setup.complete"
91680
- });
91681
- input.presenter.line({
91682
- code: "setup.complete.agent_handoff.detail",
91683
- text: "Your setup agent can read the structured block below for follow-up commands."
91684
- });
91685
- input.presenter.line({
91686
- code: "setup.complete.agent_handoff.begin",
91687
- text: "-----BEGIN ATS SETUP COMPLETE-----"
91688
- });
91689
- const envelope = {
91690
- type: "result",
91691
- code: "setup.complete",
91692
- payload: input.payload
91693
- };
91694
- for (const line of JSON.stringify(envelope, null, 2).split("\n")) input.presenter.line({
91695
- code: "setup.complete.agent_handoff.json",
91696
- text: line
91697
- });
91698
- input.presenter.line({
91699
- code: "setup.complete.agent_handoff.end",
91700
- text: "-----END ATS SETUP COMPLETE-----"
91701
- });
91702
- }
91703
91819
  function formatSetupCompleteLocalAgents(selectedLocalAgentIds) {
91704
91820
  if (selectedLocalAgentIds.length === 0) return "No local agents selected";
91705
91821
  return `${selectedLocalAgentIds.length} detected: ${selectedLocalAgentIds.join(", ")}`;
@@ -91715,6 +91831,11 @@ function formatSetupCompleteService(atsServiceRuntimeIdentity) {
91715
91831
  if (!atsServiceRuntimeIdentity) return "Not connected";
91716
91832
  return `${atsServiceRuntimeIdentity.runtimeLane} - ${shortenIdentifier(atsServiceRuntimeIdentity.deviceId)}`;
91717
91833
  }
91834
+ function formatSetupLocalAgentCandidateCount(readiness) {
91835
+ const supportedCount = readiness.agents.candidates.filter((candidate) => candidate.selectable).length;
91836
+ if (supportedCount === 0) return "No supported local agents found";
91837
+ return `${supportedCount} supported local agent${supportedCount === 1 ? "" : "s"} found`;
91838
+ }
91718
91839
  function shortenIdentifier(value) {
91719
91840
  if (value.length <= 18) return value;
91720
91841
  return `${value.slice(0, 8)}...${value.slice(-4)}`;
@@ -92361,10 +92482,6 @@ async function runStart(input) {
92361
92482
  foundation,
92362
92483
  gatewayUrl
92363
92484
  });
92364
- await syncStandaloneLocalRuntimeObservedMetadata({
92365
- foundation,
92366
- gatewayUrl
92367
- });
92368
92485
  if (await runStartServiceStep({
92369
92486
  foundation,
92370
92487
  runtime,