agent-transport-system 0.2.2 → 0.2.3

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
@@ -20,7 +20,66 @@ import { setTimeout as setTimeout$1 } from "node:timers/promises";
20
20
  import WebSocket from "ws";
21
21
 
22
22
  //#region package.json
23
- var version$1 = "0.2.2";
23
+ var version$1 = "0.2.3";
24
+ var package_default = {
25
+ name: "agent-transport-system",
26
+ version: version$1,
27
+ atsReleaseDate: "2026-03-12",
28
+ description: "Agent Transport System CLI - https://ats.sh",
29
+ license: "MIT",
30
+ type: "module",
31
+ bin: {
32
+ "agent-transport-system": "dist/ats.js",
33
+ "ats": "dist/ats.js"
34
+ },
35
+ "private": false,
36
+ engines: { "node": ">=20" },
37
+ files: [
38
+ "README.md",
39
+ "dist",
40
+ "skills"
41
+ ],
42
+ scripts: {
43
+ "build:deps": "pnpm --filter @agent-transport-system/agent-runtime build && pnpm --filter @agent-transport-system/protocol build && pnpm --filter @agent-transport-system/gateway-contract build && pnpm --filter @agent-transport-system/schemas build && pnpm --filter @agent-transport-system/adapter-core build && pnpm --filter @agent-transport-system/adapter-claude-code build && pnpm --filter @agent-transport-system/adapter-codex build && pnpm --filter @agent-transport-system/adapter-openclaw build && pnpm --filter @agent-transport-system/atsd build",
44
+ "prebuild": "pnpm run build:deps",
45
+ "build": "tsdown",
46
+ "prepack": "pnpm run build && pnpm run verify:pack-readme",
47
+ "prepublishOnly": "pnpm run verify:pack-readme",
48
+ "verify:pack-readme": "node scripts/verify-npm-pack-readme.mjs",
49
+ "pretypecheck": "pnpm run build:deps",
50
+ "typecheck": "tsc -p tsconfig.json --noEmit",
51
+ "precheck": "pnpm run build:deps",
52
+ "check": "ultracite check && tsc -p tsconfig.json --noEmit",
53
+ "pretest": "pnpm run build:deps",
54
+ "test": "vitest run",
55
+ "test:daemon": "vitest run tests/daemon-state.test.ts tests/daemon-command.test.ts tests/daemon-menu.test.ts tests/daemon-run.test.ts tests/daemon-bootstrap-recommendation.test.ts",
56
+ "test:watch": "vitest"
57
+ },
58
+ dependencies: {
59
+ "@clack/prompts": "^1.0.1",
60
+ "commander": "^14.0.0",
61
+ "picocolors": "^1.1.1",
62
+ "string-width": "^8.1.0",
63
+ "ws": "^8.18.3"
64
+ },
65
+ devDependencies: {
66
+ "@agent-transport-system/adapter-claude-code": "workspace:*",
67
+ "@agent-transport-system/adapter-codex": "workspace:*",
68
+ "@agent-transport-system/adapter-core": "workspace:*",
69
+ "@agent-transport-system/adapter-openclaw": "workspace:*",
70
+ "@agent-transport-system/atsd": "workspace:*",
71
+ "@agent-transport-system/gateway-contract": "workspace:*",
72
+ "@agent-transport-system/protocol": "workspace:*",
73
+ "@agent-transport-system/schemas": "workspace:*",
74
+ "@types/node": "^24.3.0",
75
+ "@types/ws": "^8.18.1",
76
+ "oxc-resolver": "^11.0.0",
77
+ "tsdown": "^0.20.3",
78
+ "typescript": "^5.9.3",
79
+ "unplugin-lightningcss": "^0.4.0",
80
+ "vitest": "~3.2.0"
81
+ }
82
+ };
24
83
 
25
84
  //#endregion
26
85
  //#region ../../config/agents/registry.json
@@ -1597,6 +1656,7 @@ function buildCommandChecks(...parts) {
1597
1656
  return Object.freeze(Object.assign({}, SKIP_ALL_CHECKS, ...parts));
1598
1657
  }
1599
1658
  const COMMAND_CHECK_REQUIREMENTS = Object.freeze({
1659
+ root: buildCommandChecks(OPTIONAL_CLI_UPDATE),
1600
1660
  view: buildCommandChecks(OPTIONAL_CLI_UPDATE),
1601
1661
  start: buildCommandChecks(OPTIONAL_CLI_UPDATE, AUTO_FIX_LOCAL_RUNTIME),
1602
1662
  "repair.local-state": buildCommandChecks(),
@@ -1662,6 +1722,7 @@ function getCommandCheckRequirements(entryName) {
1662
1722
  //#endregion
1663
1723
  //#region src/command-entry-checks/command-entry-name.ts
1664
1724
  const COMMAND_ENTRY_NAME_BY_ROUTE = {
1725
+ "": "root",
1665
1726
  view: "view",
1666
1727
  start: "start",
1667
1728
  repair: "repair.local-state",
@@ -1772,7 +1833,7 @@ function resolveCommandEntryNameFromRoute(route) {
1772
1833
  }
1773
1834
  function resolveCommandEntryNameFromTokens(tokens) {
1774
1835
  const normalized = tokens.map((token) => token.trim()).filter((token) => token.length > 0).join(" ");
1775
- if (normalized.length === 0) return null;
1836
+ if (normalized.length === 0) return resolveCommandEntryNameFromRoute("");
1776
1837
  return resolveCommandEntryNameFromRoute(normalized);
1777
1838
  }
1778
1839
 
@@ -2026,6 +2087,22 @@ function createInitialVersionState(input) {
2026
2087
  function hasValidLastVersion(state) {
2027
2088
  return Boolean(toNonEmptyString(state?.last_version));
2028
2089
  }
2090
+ async function ensureVersionStateReady(input) {
2091
+ const previousVersionState = await readVersionState();
2092
+ if (!previousVersionState) {
2093
+ const nextState = createInitialVersionState({ currentVersion: input.currentVersion });
2094
+ await writeVersionState(nextState);
2095
+ return nextState;
2096
+ }
2097
+ if (hasValidLastVersion(previousVersionState)) return previousVersionState;
2098
+ const nextState = {
2099
+ ...previousVersionState,
2100
+ last_version: input.currentVersion,
2101
+ latest_version: previousVersionState.latest_version ?? input.currentVersion
2102
+ };
2103
+ await writeVersionState(nextState);
2104
+ return nextState;
2105
+ }
2029
2106
  function buildNextVersionState(input) {
2030
2107
  const checkedAt = input.checkedAt ?? (/* @__PURE__ */ new Date()).toISOString();
2031
2108
  const latestVersion = toNonEmptyString(input.latestVersion) ?? toNonEmptyString(input.previous?.latest_version) ?? input.currentVersion;
@@ -3921,21 +3998,16 @@ async function resolveAtsProfile(input) {
3921
3998
  }
3922
3999
  }), "profile"));
3923
4000
  }
3924
- async function createAtsAgentProfile(input) {
4001
+ function createAtsAgentProfile(input) {
3925
4002
  const profileName = normalizeOptionalString$14(input.profileName);
4003
+ const controllerRef = normalizeOptionalString$14(input.controllerRef) ?? void 0;
3926
4004
  if (!profileName) throw new Error("profile name is required");
3927
- const created = parseAtsProfileItem(readRecordField(await requestAtsProfilesApi({
3928
- method: "POST",
3929
- path: "/v1/profiles/agents",
3930
- body: {
3931
- profileName,
3932
- ...input.controllerKind ? { controllerKind: input.controllerKind } : {},
3933
- ...normalizeOptionalString$14(input.controllerRef) ? { controllerRef: normalizeOptionalString$14(input.controllerRef) } : {},
3934
- ...typeof input.controllerEnabled === "boolean" ? { controllerEnabled: input.controllerEnabled } : {}
3935
- }
3936
- }), "profile"));
3937
- await emitDaemonCatalogSyncSignal$1("profile_created");
3938
- return created;
4005
+ return createAtsAgentProfileRequest({
4006
+ profileName,
4007
+ ...input.controllerKind ? { controllerKind: input.controllerKind } : {},
4008
+ ...controllerRef ? { controllerRef } : {},
4009
+ ...typeof input.controllerEnabled === "boolean" ? { controllerEnabled: input.controllerEnabled } : {}
4010
+ });
3939
4011
  }
3940
4012
  async function createAtsHumanProfile(input) {
3941
4013
  const profileName = normalizeOptionalString$14(input.profileName);
@@ -4032,6 +4104,20 @@ async function requestAtsProfilesApi(input) {
4032
4104
  }
4033
4105
  return record;
4034
4106
  }
4107
+ async function createAtsAgentProfileRequest(input) {
4108
+ const created = parseAtsProfileItem(readRecordField(await requestAtsProfilesApi({
4109
+ method: "POST",
4110
+ path: "/v1/profiles/agents",
4111
+ body: {
4112
+ profileName: input.profileName,
4113
+ ...input.controllerKind ? { controllerKind: input.controllerKind } : {},
4114
+ ...input.controllerRef ? { controllerRef: input.controllerRef } : {},
4115
+ ...typeof input.controllerEnabled === "boolean" ? { controllerEnabled: input.controllerEnabled } : {}
4116
+ }
4117
+ }), "profile"));
4118
+ await emitDaemonCatalogSyncSignal$1("profile_created");
4119
+ return created;
4120
+ }
4035
4121
  async function requireAtsProfilesSession() {
4036
4122
  const now = Date.now();
4037
4123
  if (validatedSessionCache && now - validatedSessionCache.validatedAtMs <= VALIDATED_SESSION_CACHE_TTL_MS) {
@@ -4213,12 +4299,17 @@ function extractApiErrorMessage$1(payload, status) {
4213
4299
  function resolveProfilesApiErrorMessage(input) {
4214
4300
  const message = extractApiErrorMessage$1(input.payload, input.status);
4215
4301
  if (input.status === 500 && input.code === "profile.internal_error" && isLoopbackProfileEndpoint(input.endpoint)) return "internal error from local auth service; if profile schema changed, run `pnpm --filter @agent-transport-system/auth-worker run db:migrate:dev` and retry.";
4302
+ if (input.status === 500 && input.code === "profile.internal_error" && isHostedProfilesEndpoint(input.endpoint)) return "internal error from ATS auth service while handling profile state. If this works in `ats-dev` but fails in `ats`, the hosted auth deployment is likely out of sync with the latest profile flow. Retry after the production auth deploy/migration is updated.";
4216
4303
  return message;
4217
4304
  }
4218
4305
  function isLoopbackProfileEndpoint(endpoint) {
4219
4306
  const url = parseUrlOrNull$2(endpoint);
4220
4307
  return Boolean(url && isLoopbackHostname$2(url.hostname) && url.pathname.startsWith("/v1/profiles"));
4221
4308
  }
4309
+ function isHostedProfilesEndpoint(endpoint) {
4310
+ const url = parseUrlOrNull$2(endpoint);
4311
+ return Boolean(url && !isLoopbackHostname$2(url.hostname) && url.pathname.startsWith("/v1/profiles"));
4312
+ }
4222
4313
  function isRecord$2(value) {
4223
4314
  return Boolean(value && typeof value === "object" && !Array.isArray(value));
4224
4315
  }
@@ -8374,7 +8465,7 @@ var ZodFirstPartyTypeKind;
8374
8465
  (function(ZodFirstPartyTypeKind) {})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
8375
8466
 
8376
8467
  //#endregion
8377
- //#region ../../packages/schemas/dist/envelope-Bj9337Pa.js
8468
+ //#region ../../packages/schemas/dist/envelope-D05cA6vb.js
8378
8469
  const MAX_PROFILE_ID_LENGTH = 64;
8379
8470
  const MAX_PROFILE_NAME_LENGTH = 64;
8380
8471
  const MAX_TEXT_LENGTH$1 = 4e3;
@@ -8842,6 +8933,11 @@ function canonicalizeControllerRefForKind(input) {
8842
8933
  if (input.controllerKind === "builtin") return canonicalizeBuiltinControllerRef(normalized);
8843
8934
  return normalized;
8844
8935
  }
8936
+ function buildControllerRoutingKeyForKind(input) {
8937
+ const canonicalControllerRef = canonicalizeControllerRefForKind(input);
8938
+ if (!canonicalControllerRef) return null;
8939
+ return input.controllerKind === "builtin" ? canonicalControllerRef : `${input.controllerKind}:${canonicalControllerRef}`;
8940
+ }
8845
8941
  function canonicalizeBuiltinControllerRef(controllerRef) {
8846
8942
  const builtinId = normalizeBuiltinControllerId(controllerRef);
8847
8943
  return builtinId ? `${BUILTIN_CONTROLLER_REF_PREFIX}${builtinId}` : null;
@@ -11459,6 +11555,21 @@ function canUseInteractivePrompts(context) {
11459
11555
  return context.resolvedView === "human" && context.interactive;
11460
11556
  }
11461
11557
 
11558
+ //#endregion
11559
+ //#region src/runtime/manual-upgrade.ts
11560
+ const MANUAL_ATS_UPGRADE_COMMAND = "npm install -g agent-transport-system@latest";
11561
+ const ATS_UPGRADE_METADATA_RECOVERY_HINTS = [
11562
+ MANUAL_ATS_UPGRADE_COMMAND,
11563
+ "ats reset --yes",
11564
+ "ats start",
11565
+ "ats upgrade --check"
11566
+ ];
11567
+ const ATS_UPGRADE_FAILURE_HINTS = [
11568
+ MANUAL_ATS_UPGRADE_COMMAND,
11569
+ "ats upgrade --check",
11570
+ "ats upgrade --yes"
11571
+ ];
11572
+
11462
11573
  //#endregion
11463
11574
  //#region src/ui/io.ts
11464
11575
  function outLine(line) {
@@ -14310,6 +14421,98 @@ function resolveAlignmentProgressMessage(step) {
14310
14421
  }
14311
14422
  }
14312
14423
 
14424
+ //#endregion
14425
+ //#region src/runtime/cli-version.ts
14426
+ const PACKAGE_JSON = package_default;
14427
+ const ISO_RELEASE_DATE_RE = /^(\d{4})-(\d{2})-(\d{2})$/u;
14428
+ function getCliVersionInfo() {
14429
+ const version = PACKAGE_JSON.version;
14430
+ const releaseDate = normalizeReleaseDate(PACKAGE_JSON.atsReleaseDate);
14431
+ const releaseDateLabel = releaseDate ? formatCliReleaseDateLabel(releaseDate) : null;
14432
+ return {
14433
+ version,
14434
+ releaseDate,
14435
+ releaseDateLabel,
14436
+ summary: formatCliVersionSummary({
14437
+ version,
14438
+ releaseDateLabel
14439
+ })
14440
+ };
14441
+ }
14442
+ function formatCliVersionSummary(input) {
14443
+ const versionInfo = input ?? getCliVersionInfo();
14444
+ if (!versionInfo.releaseDateLabel) return `Current version: ${versionInfo.version}`;
14445
+ return `Current version: ${versionInfo.version} • ${versionInfo.releaseDateLabel}`;
14446
+ }
14447
+ function normalizeReleaseDate(value) {
14448
+ const normalized = String(value ?? "").trim();
14449
+ if (!ISO_RELEASE_DATE_RE.test(normalized)) return null;
14450
+ return normalized;
14451
+ }
14452
+ function formatCliReleaseDateLabel(releaseDate) {
14453
+ const match = releaseDate.match(ISO_RELEASE_DATE_RE);
14454
+ if (!match) return releaseDate;
14455
+ return `${match[2]}-${match[3]}`;
14456
+ }
14457
+
14458
+ //#endregion
14459
+ //#region src/ui/root-entry-catalog.ts
14460
+ const ROOT_ENTRY_START_COMMAND = "ats start";
14461
+ const ROOT_ENTRY_COMMANDS = [
14462
+ {
14463
+ command: "ats start",
14464
+ description: "Initialize your identity"
14465
+ },
14466
+ {
14467
+ command: "ats auth",
14468
+ description: "Sign in, sign out, and inspect auth state"
14469
+ },
14470
+ {
14471
+ command: "ats profiles",
14472
+ description: "Manage ATS profiles"
14473
+ },
14474
+ {
14475
+ command: "ats agents",
14476
+ description: "Manage ATS agent targets and bindings"
14477
+ },
14478
+ {
14479
+ command: "ats view human|agent",
14480
+ description: "Switch default view mode"
14481
+ },
14482
+ {
14483
+ command: "ats space",
14484
+ description: "Create, join, and configure spaces"
14485
+ },
14486
+ {
14487
+ command: "ats skills",
14488
+ description: "Install or list ATS skills"
14489
+ },
14490
+ {
14491
+ command: "ats service",
14492
+ description: "Manage ATS background service"
14493
+ },
14494
+ {
14495
+ command: "ats whoami",
14496
+ description: "Show your current identity"
14497
+ },
14498
+ {
14499
+ command: "ats doctor",
14500
+ description: "Check local setup and connectivity"
14501
+ },
14502
+ {
14503
+ command: "ats upgrade",
14504
+ description: "Upgrade ATS CLI when a new version is available"
14505
+ },
14506
+ {
14507
+ command: "ats reset",
14508
+ description: "Reset local ATS state and reinitialize baseline files"
14509
+ },
14510
+ {
14511
+ command: "ats help (-h, --help)",
14512
+ description: "Show help for a command"
14513
+ }
14514
+ ];
14515
+
14313
14516
  //#endregion
14314
14517
  //#region src/commands/top-level-agent-overview.ts
14315
14518
  function emitTopLevelAgentOverview(input) {
@@ -14327,6 +14530,23 @@ function emitTopLevelCliAgentOverview(command) {
14327
14530
  }
14328
14531
  function buildTopLevelAgentOverviewPayload(command) {
14329
14532
  switch (command) {
14533
+ case "root": return {
14534
+ summary: "Show the ATS root entry menu, recommend `ats start`, and expose the current CLI release metadata.",
14535
+ requiredArguments: [],
14536
+ optionalArguments: [],
14537
+ commands: ROOT_ENTRY_COMMANDS.map((item) => item.command),
14538
+ stages: [
14539
+ "Recommend the first onboarding command.",
14540
+ "List the top-level ATS commands available from the root entry.",
14541
+ "Return the currently installed CLI version and release date."
14542
+ ],
14543
+ notes: ["Human view renders the branded banner; agent view receives this structured root overview."],
14544
+ cli: getCliVersionInfo(),
14545
+ humanActionRequired: {
14546
+ possible: false,
14547
+ steps: []
14548
+ }
14549
+ };
14330
14550
  case "view": return {
14331
14551
  summary: "Inspect or save the default ATS view mode for the current or explicit ATS profile.",
14332
14552
  requiredArguments: [],
@@ -14585,13 +14805,14 @@ async function runUpgrade(input) {
14585
14805
  });
14586
14806
  }
14587
14807
  function handleMissingVersionMetadata(input) {
14588
- const errorMessage = formatInlineAtsCliCommands("ATS version metadata is missing; run `ats reset --yes` before `ats upgrade`.");
14808
+ const errorMessage = formatAtsCliTextBlock(`ATS version metadata is missing, so automatic upgrade cannot continue.\nManual fallback: \`${MANUAL_ATS_UPGRADE_COMMAND}\`\nIf you want to repair local ATS state first, run \`ats reset --yes\` before \`ats upgrade\`.`);
14589
14809
  if (input.resolvedView === "agent") {
14590
14810
  input.presenter.data({
14591
14811
  code: "upgrade.metadata.missing",
14592
14812
  payload: {
14593
- summary: "Local ATS version metadata is missing, so upgrade cannot verify downgrade safety.",
14813
+ summary: "Local ATS version metadata is missing, so automatic upgrade cannot verify downgrade safety.",
14594
14814
  nextSteps: [
14815
+ MANUAL_ATS_UPGRADE_COMMAND,
14595
14816
  "ats-dev reset --yes --view agent",
14596
14817
  "ats-dev start",
14597
14818
  "ats-dev upgrade --check --view agent"
@@ -14604,13 +14825,17 @@ function handleMissingVersionMetadata(input) {
14604
14825
  throw new Error(errorMessage);
14605
14826
  }
14606
14827
  function handleUpgradeCheckFailure(input) {
14607
- const errorMessage = `Version check failed (${input.upgradeStatus.error}). Upgrade stopped because downgrade protection requires confirming that npm latest is newer than the current CLI.`;
14828
+ const errorMessage = formatAtsCliTextBlock(`Version check failed (${input.upgradeStatus.error}). Upgrade stopped because downgrade protection requires confirming that npm latest is newer than the current CLI.\nManual fallback: \`${MANUAL_ATS_UPGRADE_COMMAND}\``);
14608
14829
  if (input.resolvedView === "agent") {
14609
14830
  input.presenter.data({
14610
14831
  code: "upgrade.check_failed",
14611
14832
  payload: {
14612
14833
  ...input.upgradeStatus,
14613
- nextSteps: ["ats-dev upgrade --check --view agent", "ats-dev upgrade --yes --view agent"],
14834
+ nextSteps: [
14835
+ MANUAL_ATS_UPGRADE_COMMAND,
14836
+ "ats-dev upgrade --check --view agent",
14837
+ "ats-dev upgrade --yes --view agent"
14838
+ ],
14614
14839
  humanActionRequired: false
14615
14840
  }
14616
14841
  });
@@ -14670,7 +14895,7 @@ async function installLatestPackage() {
14670
14895
  const stderr = result.stderr.trim();
14671
14896
  const stdout = result.stdout.trim();
14672
14897
  const details = stderr || stdout;
14673
- throw new Error(`upgrade failed (exit ${result.code})${details ? `: ${details}` : ""}`);
14898
+ throw new Error(formatAtsCliTextBlock(`upgrade failed (exit ${result.code})${details ? `: ${details}` : ""}\nManual fallback: \`${MANUAL_ATS_UPGRADE_COMMAND}\``));
14674
14899
  }
14675
14900
  }
14676
14901
  async function runInternalUpgradeServiceAlignment(input) {
@@ -14919,7 +15144,7 @@ function emitUpgradeInstalling(input) {
14919
15144
  if (input.resolvedView === "agent") {
14920
15145
  input.presenter.data({
14921
15146
  code: "upgrade.installing",
14922
- payload: { command: "npm install -g agent-transport-system@latest" }
15147
+ payload: { command: MANUAL_ATS_UPGRADE_COMMAND }
14923
15148
  });
14924
15149
  return;
14925
15150
  }
@@ -14972,6 +15197,13 @@ const DEFAULT_COPY = {
14972
15197
  serviceAction: null
14973
15198
  };
14974
15199
  const COMMAND_ENTRY_COPY_BY_NAME = Object.freeze({
15200
+ root: {
15201
+ ...DEFAULT_COPY,
15202
+ signInAction: null,
15203
+ profileAction: null,
15204
+ cliUpdateAction: "opening ATS",
15205
+ serviceAction: null
15206
+ },
14975
15207
  view: {
14976
15208
  ...DEFAULT_COPY,
14977
15209
  signInAction: null,
@@ -15544,6 +15776,7 @@ async function runCliUpdateCheck(input) {
15544
15776
  return { status: "cancelled" };
15545
15777
  }
15546
15778
  if (!selected) return { status: "continue" };
15779
+ await ensureVersionStateReady({ currentVersion });
15547
15780
  await runUpgrade({
15548
15781
  yes: true,
15549
15782
  view: input.context.runtime.resolvedView
@@ -26067,7 +26300,17 @@ function resolveDispatchQueueLogMeta(input) {
26067
26300
  function buildDispatchControllerKey(input) {
26068
26301
  const normalizedControllerKind = typeof input.controllerKind === "string" ? input.controllerKind.trim() : "";
26069
26302
  const normalizedControllerRef = typeof input.controllerRef === "string" ? input.controllerRef.trim() : "";
26070
- if (normalizedControllerKind && normalizedControllerRef) return `${normalizedControllerKind}:${normalizedControllerRef}`;
26303
+ if (normalizedControllerKind && normalizedControllerRef) {
26304
+ if (normalizedControllerKind === "builtin" || normalizedControllerKind === "custom") {
26305
+ const controllerKey = buildControllerRoutingKeyForKind({
26306
+ controllerKind: normalizedControllerKind,
26307
+ controllerRef: normalizedControllerRef
26308
+ });
26309
+ if (controllerKey) return controllerKey;
26310
+ return `profile:${input.profileId}`;
26311
+ }
26312
+ return `${normalizedControllerKind}:${normalizedControllerRef}`;
26313
+ }
26071
26314
  return `profile:${input.profileId}`;
26072
26315
  }
26073
26316
  function resolveDispatchContinuityObservation(input) {
@@ -39983,22 +40226,8 @@ async function bootstrapAtsHome(input) {
39983
40226
  ...previousSkillsConfig?.customTargets ? { customTargets: previousSkillsConfig.customTargets } : {},
39984
40227
  installs: previousSkillsConfig?.installs ?? []
39985
40228
  });
39986
- const previousVersionState = await readVersionState();
39987
- let versionState;
39988
- if (!previousVersionState) {
39989
- versionState = createInitialVersionState({ currentVersion: input.currentVersion });
39990
- await writeVersionState(versionState);
39991
- } else if (hasValidLastVersion(previousVersionState)) versionState = previousVersionState;
39992
- else {
39993
- versionState = {
39994
- ...previousVersionState,
39995
- last_version: input.currentVersion,
39996
- latest_version: previousVersionState.latest_version ?? input.currentVersion
39997
- };
39998
- await writeVersionState(versionState);
39999
- }
40000
40229
  return {
40001
- versionState,
40230
+ versionState: await ensureVersionStateReady({ currentVersion: input.currentVersion }),
40002
40231
  skills
40003
40232
  };
40004
40233
  }
@@ -40598,63 +40827,9 @@ const ATS_LOGO_LINES = [
40598
40827
  ];
40599
40828
  const ATS_SUBTITLE_LINES = ["AGENT TRANSPORT SYSTEM CLI • https://ats.sh", "Connect with any AI agents & humans in realtime."];
40600
40829
  const ATS_CLI_NPX_COMMAND = "npx agent-transport-system";
40601
- const START_CALL_TO_ACTION_COMMAND = "ats start";
40602
40830
  const GLOBAL_INSTALL_COMMAND = "npm install -g agent-transport-system";
40603
40831
  const GLOBAL_INSTALL_SHORTCUT_COMMAND = "ats start";
40604
- const BANNER_COMMANDS = [
40605
- {
40606
- command: "ats start",
40607
- description: "Initialize your identity"
40608
- },
40609
- {
40610
- command: "ats auth",
40611
- description: "Sign in, sign out, and inspect auth state"
40612
- },
40613
- {
40614
- command: "ats profiles",
40615
- description: "Manage ATS profiles"
40616
- },
40617
- {
40618
- command: "ats agents",
40619
- description: "Manage ATS agent targets and bindings"
40620
- },
40621
- {
40622
- command: "ats view human|agent",
40623
- description: "Switch default view mode"
40624
- },
40625
- {
40626
- command: "ats space",
40627
- description: "Create, join, and configure spaces"
40628
- },
40629
- {
40630
- command: "ats skills",
40631
- description: "Install or list ATS skills"
40632
- },
40633
- {
40634
- command: "ats service",
40635
- description: "Manage ATS background service"
40636
- },
40637
- {
40638
- command: "ats whoami",
40639
- description: "Show your current identity"
40640
- },
40641
- {
40642
- command: "ats doctor",
40643
- description: "Check local setup and connectivity"
40644
- },
40645
- {
40646
- command: "ats upgrade",
40647
- description: "Upgrade ATS CLI when a new version is available"
40648
- },
40649
- {
40650
- command: "ats reset",
40651
- description: "Reset local ATS state and reinitialize baseline files"
40652
- },
40653
- {
40654
- command: "ats help (-h, --help)",
40655
- description: "Show help for a command"
40656
- }
40657
- ];
40832
+ const CURRENT_VERSION_PREFIX = "Current version:";
40658
40833
  function renderAtsLogo() {
40659
40834
  const useColor = pc.isColorSupported;
40660
40835
  return scaleMonospaceBlock(ATS_LOGO_LINES, LOGO_SCALE).map((line, index) => {
@@ -40666,18 +40841,22 @@ function renderAtsHeader() {
40666
40841
  return `${renderAtsLogo()}\n${renderAtsTagline()}`;
40667
40842
  }
40668
40843
  function printAtsBanner() {
40669
- const startCallToAction = `${pc.dim("Try this first:")} ${pc.bold(pc.cyan(formatAtsCliCommand(START_CALL_TO_ACTION_COMMAND)))}`;
40844
+ const startCallToAction = `${pc.dim("Try this first:")} ${pc.bold(pc.cyan(formatAtsCliCommand(ROOT_ENTRY_START_COMMAND)))}`;
40845
+ const versionSummary = formatCliVersionSummary();
40846
+ const versionCallout = versionSummary.startsWith(CURRENT_VERSION_PREFIX) ? `${pc.dim(CURRENT_VERSION_PREFIX)}${versionSummary.slice(16)}` : versionSummary;
40670
40847
  outLine("");
40671
40848
  outLine(renderAtsLogo());
40672
40849
  outLine(renderAtsTagline());
40673
40850
  outLine("");
40851
+ for (const line of renderThinCalloutBox(versionCallout)) outLine(line);
40852
+ outLine("");
40674
40853
  for (const line of renderThinCalloutBox(startCallToAction)) outLine(line);
40675
40854
  if (shouldRenderGlobalInstallHint()) {
40676
40855
  outLine("");
40677
40856
  for (const line of renderThinCalloutBox(buildGlobalInstallHintLines())) outLine(line);
40678
40857
  }
40679
40858
  outLine("");
40680
- for (const item of BANNER_COMMANDS) outLine(` ${pc.dim("$")} ${pc.cyan(formatAtsCliCommand(item.command))} ${pc.dim(item.description)}`);
40859
+ for (const item of ROOT_ENTRY_COMMANDS) outLine(` ${pc.dim("$")} ${pc.cyan(formatAtsCliCommand(item.command))} ${pc.dim(item.description)}`);
40681
40860
  outLine("");
40682
40861
  }
40683
40862
  function renderAtsTagline() {
@@ -46085,6 +46264,15 @@ async function runSpaceCreate(input) {
46085
46264
  resolvedView: contextRuntime.resolvedView,
46086
46265
  passwordProtected: typeof createInput.value.password === "string"
46087
46266
  });
46267
+ await syncProfileSpaceHistoryForCreate({
46268
+ atsProfile,
46269
+ baseUrl,
46270
+ spaceId: parsed.spaceId,
46271
+ meta: parsed.meta,
46272
+ fallbackSpaceName: createInput.value.name
46273
+ }).catch((error) => {
46274
+ contextPresenter.event("info", "connect.warn.profile_space_history_sync_failed", { error: toErrorMessage$1(error) });
46275
+ });
46088
46276
  if (!(isHumanInteractiveSpaceRuntime(contextRuntime) ? Boolean(createInput.value.joinInput) : await resolveJoinAfterCreate(createInput.value.joinInput, contextInteractive))) return;
46089
46277
  await runSpaceJoin({
46090
46278
  profile: atsProfile.atsProfileId,
@@ -46110,6 +46298,29 @@ async function runSpaceCreate(input) {
46110
46298
  throw error;
46111
46299
  }
46112
46300
  }
46301
+ async function syncProfileSpaceHistoryForCreate(input) {
46302
+ const gatewayHost = resolveGatewayHost(input.baseUrl);
46303
+ if (!gatewayHost) return;
46304
+ const normalizedMeta = input.meta ? normalizeMetaForHistory(input.meta) : null;
46305
+ const fallbackSpaceName = normalizeOptionalString$2(input.fallbackSpaceName);
46306
+ const historySpaceName = normalizedMeta?.spaceName !== void 0 ? normalizedMeta.spaceName : fallbackSpaceName;
46307
+ await upsertProfileSpaceHistory({
46308
+ baseUrl: input.baseUrl,
46309
+ atsProfileId: input.atsProfile.atsProfileId,
46310
+ profileName: input.atsProfile.profileName,
46311
+ spaceId: input.spaceId,
46312
+ body: {
46313
+ gatewayHost,
46314
+ ...historySpaceName ? { spaceName: historySpaceName } : {},
46315
+ ...normalizedMeta?.creatorProfileId !== void 0 ? { creatorProfileId: normalizedMeta.creatorProfileId } : { creatorProfileId: input.atsProfile.atsProfileId },
46316
+ ...normalizedMeta?.creatorKind !== void 0 ? { creatorKind: normalizedMeta.creatorKind } : { creatorKind: input.atsProfile.profileKind },
46317
+ ...normalizedMeta?.spaceCreatedAt !== void 0 ? { spaceCreatedAt: normalizedMeta.spaceCreatedAt } : {},
46318
+ ...normalizedMeta?.spaceUpdatedAt !== void 0 ? { spaceUpdatedAt: normalizedMeta.spaceUpdatedAt } : {},
46319
+ lastJoinedAt: normalizedMeta?.spaceCreatedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
46320
+ status: "active"
46321
+ }
46322
+ });
46323
+ }
46113
46324
  async function resolveSpaceCreateInput(input) {
46114
46325
  if (isHumanInteractiveSpaceRuntime(input.runtime)) {
46115
46326
  const prompted = await promptInteractiveSpaceCreateFlow({
@@ -49853,9 +50064,8 @@ async function resolveOwnerScopedKnownSpacesForSelection(input) {
49853
50064
  });
49854
50065
  if (ownedProfiles.length === 0) return null;
49855
50066
  const ownedProfilesById = buildKnownSpaceProfileMap(ownedProfiles);
49856
- const merged = /* @__PURE__ */ new Map();
49857
- for (const profile of ownedProfiles) {
49858
- const options = await resolveKnownSpacesForSelectionByProfile({
50067
+ const ownerScopedOptions = await Promise.all(ownedProfiles.map(async (profile) => {
50068
+ return await resolveKnownSpacesForSelectionByProfile({
49859
50069
  atsProfile: profile,
49860
50070
  baseUrl: input.baseUrl,
49861
50071
  command: input.command,
@@ -49863,6 +50073,9 @@ async function resolveOwnerScopedKnownSpacesForSelection(input) {
49863
50073
  ownedProfilesById,
49864
50074
  bestEffort: profile.atsProfileId !== input.atsProfile.atsProfileId
49865
50075
  });
50076
+ }));
50077
+ const merged = /* @__PURE__ */ new Map();
50078
+ for (const options of ownerScopedOptions) {
49866
50079
  if (!options) continue;
49867
50080
  for (const item of options) {
49868
50081
  const key = normalizeKnownSpaceMergeKey(item.space);
@@ -55620,7 +55833,7 @@ async function main() {
55620
55833
  return;
55621
55834
  }
55622
55835
  if (argv.length <= 2) {
55623
- printAtsBanner();
55836
+ await runRootCommand();
55624
55837
  return;
55625
55838
  }
55626
55839
  if (isStandaloneViewQueryArgv(argv)) {
@@ -55681,6 +55894,33 @@ async function main() {
55681
55894
  process.exitCode = 1;
55682
55895
  }
55683
55896
  }
55897
+ async function runRootCommand() {
55898
+ const runtime = await resolveRuntimeContext();
55899
+ const presenter = createPresenter(runtime);
55900
+ if (runtime.resolvedView === "agent") emitTopLevelAgentOverview({
55901
+ presenter,
55902
+ command: "root"
55903
+ });
55904
+ startCurrentCommandCheckScope();
55905
+ try {
55906
+ const result = await runCommandEntryFlow({
55907
+ entryName: "root",
55908
+ argv: process.argv,
55909
+ runtime,
55910
+ presenter,
55911
+ allowPrompt: runtime.interactive,
55912
+ gatewayUrl: null,
55913
+ profileArg: null
55914
+ });
55915
+ if (result.status === "continue") {
55916
+ if (runtime.resolvedView !== "agent") printAtsBanner();
55917
+ return;
55918
+ }
55919
+ if (result.status === "blocked") process.exitCode = result.exitCode;
55920
+ } finally {
55921
+ finishCurrentCommandCheckScope();
55922
+ }
55923
+ }
55684
55924
  async function shouldPrintTagline(argv, effectiveView) {
55685
55925
  if ((effectiveView === "auto" ? (await resolveRuntimeContext({ view: "auto" })).resolvedView : effectiveView) === "agent") return false;
55686
55926
  const token = parseFirstCommandTokenFromArgv(argv);
@@ -56056,11 +56296,9 @@ function resolveCommonHintByMessage(message) {
56056
56296
  `ats skills uninstall --agent ${DEFAULT_AGENT_EXAMPLE_PAIR}`,
56057
56297
  "ats skills uninstall --dir /Users/<you>/.your-agent/skills"
56058
56298
  ];
56059
- if (message.includes("ATS version metadata is missing")) return [
56060
- "ats reset --yes",
56061
- "ats start",
56062
- "ats upgrade --check"
56063
- ];
56299
+ if (message.includes("ATS version metadata is missing")) return [...ATS_UPGRADE_METADATA_RECOVERY_HINTS];
56300
+ if (message.includes("Version check failed (")) return [...ATS_UPGRADE_FAILURE_HINTS];
56301
+ if (message.includes("upgrade failed (exit")) return [...ATS_UPGRADE_FAILURE_HINTS];
56064
56302
  if (message.includes("ats reset requires --yes in non-interactive mode")) return ["ats reset --yes"];
56065
56303
  if (message.includes("ats upgrade requires --yes in non-interactive mode")) return ["ats upgrade --yes", "ats upgrade --check"];
56066
56304
  if (message.includes("interactive menu is disabled in agent view")) return [