agent-transport-system 0.7.6 → 0.7.7

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.6";
30
+ var version = "0.7.7";
31
31
  var package_default = {
32
32
  $schema: "https://www.schemastore.org/package.json",
33
33
  name: "agent-transport-system",
@@ -3469,13 +3469,13 @@ const COMMAND_CHECK_REQUIREMENTS = Object.freeze({
3469
3469
  "service.reinstall": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE),
3470
3470
  "service.stop": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE),
3471
3471
  "space.menu": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE, AUTO_FIX_LOCAL_RUNTIME, REQUIRED_SIGN_IN, CONFIRM_SELECTED_PROFILE),
3472
- "space.create": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE, AUTO_FIX_LOCAL_RUNTIME, REQUIRED_SIGN_IN, CONFIRM_SELECTED_PROFILE),
3472
+ "space.create": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE, REQUIRED_SIGN_IN, CONFIRM_SELECTED_PROFILE),
3473
3473
  "space.delete": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE, AUTO_FIX_LOCAL_RUNTIME, REQUIRED_SIGN_IN, CONFIRM_SELECTED_PROFILE),
3474
3474
  "space.conversation.bind": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE, AUTO_FIX_LOCAL_RUNTIME, REQUIRED_SIGN_IN, CONFIRM_SELECTED_PROFILE),
3475
3475
  "space.conversation.clear": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE, AUTO_FIX_LOCAL_RUNTIME, REQUIRED_SIGN_IN, CONFIRM_SELECTED_PROFILE),
3476
3476
  "space.conversation.status": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE, AUTO_FIX_LOCAL_RUNTIME, REQUIRED_SIGN_IN, CONFIRM_SELECTED_PROFILE),
3477
3477
  "space.join": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE, AUTO_FIX_LOCAL_RUNTIME, REQUIRED_SIGN_IN, CONFIRM_SELECTED_PROFILE),
3478
- "space.add-members": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE, AUTO_FIX_LOCAL_RUNTIME, REQUIRED_SIGN_IN, CONFIRM_SELECTED_PROFILE),
3478
+ "space.add-members": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE, REQUIRED_SIGN_IN, CONFIRM_SELECTED_PROFILE),
3479
3479
  "space.remove-members": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE, AUTO_FIX_LOCAL_RUNTIME, REQUIRED_SIGN_IN, CONFIRM_SELECTED_PROFILE),
3480
3480
  "space.leave": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE, AUTO_FIX_LOCAL_RUNTIME, REQUIRED_SIGN_IN, CONFIRM_SELECTED_PROFILE),
3481
3481
  "space.watch": buildCommandChecks(REQUIRED_DISCLAIMER, OPTIONAL_CLI_UPDATE, AUTO_FIX_LOCAL_RUNTIME, REQUIRED_SIGN_IN, CONFIRM_SELECTED_PROFILE),
@@ -28450,13 +28450,21 @@ function showHumanCheckCard(input) {
28450
28450
  //#region src/command-entry-checks/check-cli-update.ts
28451
28451
  const SKIP_CLI_UPDATE_ENV = "ATS_INTERNAL_SKIP_STARTUP_UPGRADE";
28452
28452
  const ATS_PACKAGE_NAME = "agent-transport-system";
28453
+ const OPTIONAL_CLI_UPDATE_CACHE_TTL_MS = 1440 * 60 * 1e3;
28453
28454
  async function runCliUpdateCheck(input) {
28454
28455
  if (input.requirement.mode === "skip") return { status: "continue" };
28455
28456
  if (String(process.env[SKIP_CLI_UPDATE_ENV] ?? "").trim() === "1") return { status: "continue" };
28456
28457
  if (!shouldCheckNpmCliUpdate(input.context)) return { status: "continue" };
28457
28458
  const currentVersion = version;
28458
- const latestVersion = await fetchLatestPackageVersion(ATS_PACKAGE_NAME).catch(() => null);
28459
- if (!(latestVersion && compareSemver(currentVersion, latestVersion) < 0)) return { status: "continue" };
28459
+ const latestVersion = await resolveLatestPackageVersionForUpdateCheck({
28460
+ currentVersion,
28461
+ useLocalCache: input.requirement.mode !== "required"
28462
+ }).catch(() => null);
28463
+ const noUpdateResult = await resolveNoCliUpdateResult({
28464
+ currentVersion,
28465
+ latestVersion
28466
+ });
28467
+ if (noUpdateResult) return noUpdateResult;
28460
28468
  const copy = getCommandEntryCopy(input.context.entryName);
28461
28469
  if (input.context.runtime.resolvedView !== "human" || !input.context.allowPrompt) {
28462
28470
  const isRequired = input.requirement.mode === "required";
@@ -28515,6 +28523,38 @@ async function runCliUpdateCheck(input) {
28515
28523
  })
28516
28524
  };
28517
28525
  }
28526
+ async function resolveNoCliUpdateResult(input) {
28527
+ if (input.latestVersion && compareSemver(input.currentVersion, input.latestVersion) < 0) return null;
28528
+ if (input.latestVersion) await persistLatestVersionCheck({
28529
+ currentVersion: input.currentVersion,
28530
+ latestVersion: input.latestVersion
28531
+ });
28532
+ return { status: "continue" };
28533
+ }
28534
+ async function resolveLatestPackageVersionForUpdateCheck(input) {
28535
+ if (!input.useLocalCache) return await fetchLatestPackageVersion(ATS_PACKAGE_NAME);
28536
+ const previousVersionState = await readVersionState().catch(() => null);
28537
+ const cachedLatestVersion = resolveFreshCachedLatestVersion({
28538
+ currentVersion: input.currentVersion,
28539
+ previousVersionState
28540
+ });
28541
+ if (cachedLatestVersion) return cachedLatestVersion;
28542
+ return await fetchLatestPackageVersion(ATS_PACKAGE_NAME);
28543
+ }
28544
+ async function persistLatestVersionCheck(input) {
28545
+ await writeVersionState(buildNextVersionState({
28546
+ previous: await readVersionState().catch(() => null),
28547
+ currentVersion: input.currentVersion,
28548
+ latestVersion: input.latestVersion
28549
+ })).catch(() => void 0);
28550
+ }
28551
+ function resolveFreshCachedLatestVersion(input) {
28552
+ const state = input.previousVersionState;
28553
+ if (state?.last_version !== input.currentVersion || !state.latest_version || !state.last_checked_at) return null;
28554
+ const checkedAt = Date.parse(state.last_checked_at);
28555
+ if (Number.isNaN(checkedAt) || Date.now() - checkedAt >= OPTIONAL_CLI_UPDATE_CACHE_TTL_MS) return null;
28556
+ return state.latest_version;
28557
+ }
28518
28558
  function shouldCheckNpmCliUpdate(context) {
28519
28559
  return context.environmentTarget.preset === "prod" && context.environmentTarget.userFacingCommand === "ats";
28520
28560
  }
@@ -76041,13 +76081,32 @@ async function resolveSpaceSessionDiagnostics(input) {
76041
76081
  };
76042
76082
  }
76043
76083
  async function emitSpaceCommandPreflight(input) {
76044
- const [authState, replyReadinessSnapshot] = await Promise.all([getAuthSessionState({ validateRemote: false }), resolveCurrentReplyReadinessSnapshot({
76084
+ const actionRequirements = resolveSpacePreflightActionRequirements(input.command);
76085
+ const authState = await getAuthSessionState({ validateRemote: false });
76086
+ if (actionRequirements.localService === "not_required") {
76087
+ const preflight = buildLocalServiceNotRequiredPreflight({
76088
+ actionRequirements,
76089
+ authState,
76090
+ baseUrl: input.baseUrl,
76091
+ command: input.command,
76092
+ profile: input.profile
76093
+ });
76094
+ if (shouldEmitSpaceCommandPreflightOutput(input.emitOutput)) emitResolvedSpaceCommandPreflight({
76095
+ presenter: input.presenter,
76096
+ command: input.command,
76097
+ resolvedView: input.resolvedView,
76098
+ humanServiceGuidanceMode: input.humanServiceGuidanceMode ?? "show",
76099
+ preflight
76100
+ });
76101
+ return preflight;
76102
+ }
76103
+ const replyReadinessSnapshot = await resolveCurrentReplyReadinessSnapshot({
76045
76104
  baseUrl: input.baseUrl,
76046
- checkGatewayChain: input.command === "create" || input.command === "join" || input.command === "send",
76105
+ checkGatewayChain: input.command === "join",
76047
76106
  ownerUserId: input.profile.ownerUserId,
76048
76107
  profile: input.profile,
76049
76108
  runtimeProjection: input.runtimeProjection
76050
- })]);
76109
+ });
76051
76110
  const serviceParticipationReadiness = resolveServiceParticipationReadiness({
76052
76111
  deviceReplyReadiness: replyReadinessSnapshot.deviceReplyReadiness,
76053
76112
  inventory: replyReadinessSnapshot.inventory,
@@ -76073,7 +76132,7 @@ async function emitSpaceCommandPreflight(input) {
76073
76132
  profileName: input.profile.profileName,
76074
76133
  profileKind: input.profile.profileKind
76075
76134
  },
76076
- actionRequirements: resolveSpacePreflightActionRequirements(input.command),
76135
+ actionRequirements,
76077
76136
  agentReplyReadiness: toSpacePreflightAgentReplyReadiness({
76078
76137
  command: input.command,
76079
76138
  readiness: replyReadinessSnapshot.agentReplyReadiness
@@ -76115,6 +76174,62 @@ async function emitSpaceCommandPreflight(input) {
76115
76174
  serviceParticipationReadiness
76116
76175
  };
76117
76176
  }
76177
+ function buildLocalServiceNotRequiredPreflight(input) {
76178
+ const deviceReplyReadiness = {
76179
+ reasonCodes: [],
76180
+ reasonText: input.actionRequirements.localServiceSummary,
76181
+ replyReadiness: "unknown",
76182
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
76183
+ wakeableRouteCount: 0
76184
+ };
76185
+ const serviceParticipationReadiness = {
76186
+ serviceReadiness: "unknown",
76187
+ serviceReadinessState: "unknown",
76188
+ summaryText: "not required",
76189
+ detailText: input.actionRequirements.localServiceSummary,
76190
+ nextStepSummary: null,
76191
+ nextSteps: [],
76192
+ runtimeHeadline: "unknown"
76193
+ };
76194
+ return {
76195
+ deviceReplyReadiness,
76196
+ payload: {
76197
+ command: input.command,
76198
+ auth: {
76199
+ state: input.authState.state,
76200
+ ready: resolvePreflightAuthReadiness({
76201
+ authState: input.authState,
76202
+ baseUrl: input.baseUrl
76203
+ }),
76204
+ compatibleWithBaseUrl: resolvePreflightAuthCompatibility({
76205
+ authState: input.authState,
76206
+ baseUrl: input.baseUrl
76207
+ }),
76208
+ authBaseUrl: input.authState.state === "valid" && input.authState.session ? input.authState.session.authBaseUrl : null,
76209
+ gatewayUrl: input.baseUrl
76210
+ },
76211
+ profile: {
76212
+ profileId: input.profile.atsProfileId,
76213
+ profileName: input.profile.profileName,
76214
+ profileKind: input.profile.profileKind
76215
+ },
76216
+ actionRequirements: input.actionRequirements,
76217
+ agentReplyReadiness: null,
76218
+ services: { daemon: {
76219
+ installed: false,
76220
+ version: null,
76221
+ runtimeStatus: "unknown",
76222
+ runtimeReason: null
76223
+ } },
76224
+ env: {
76225
+ baseUrl: input.baseUrl,
76226
+ requestTimeoutMs: resolveSpaceRequestTimeoutMsForDiagnostics()
76227
+ },
76228
+ serviceRepairGuidance: null
76229
+ },
76230
+ serviceParticipationReadiness
76231
+ };
76232
+ }
76118
76233
  function emitResolvedSpaceCommandPreflight(input) {
76119
76234
  const { payload, serviceParticipationReadiness } = input.preflight;
76120
76235
  if (input.resolvedView === "human") {
@@ -100145,8 +100260,8 @@ function isSpaceCommandToken(token) {
100145
100260
  }
100146
100261
  async function resolveEffectiveViewForOutput() {
100147
100262
  const explicitView = parseViewFromArgv(process.argv, { allowMissingValue: true });
100148
- const configuredView = await readConfiguredDefaultView({ argv: process.argv });
100149
- const selectedView = explicitView ?? configuredView;
100263
+ if (explicitView === "human" || explicitView === "agent") return explicitView;
100264
+ const selectedView = await readConfiguredDefaultView({ argv: process.argv });
100150
100265
  if (selectedView === "human" || selectedView === "agent") return selectedView;
100151
100266
  return (await resolveRuntimeContext({ view: "auto" })).resolvedView;
100152
100267
  }