@autohq/cli 0.1.122 → 0.1.123

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.
@@ -20618,6 +20618,11 @@ function resourceApplySchema(spec) {
20618
20618
  spec
20619
20619
  });
20620
20620
  }
20621
+ function resourceApplyDocumentSchema(kind, spec) {
20622
+ return resourceApplySchema(spec).extend({
20623
+ kind: external_exports.literal(kind)
20624
+ });
20625
+ }
20621
20626
 
20622
20627
  // ../../packages/schemas/src/connections.ts
20623
20628
  var ConnectionNameSchema = ResourceNameSchema;
@@ -21875,30 +21880,35 @@ function hasFilterValue(trigger, path2, expected) {
21875
21880
  }
21876
21881
 
21877
21882
  // ../../packages/schemas/src/project-resources.ts
21878
- var EnvironmentApplyDocumentSchema = EnvironmentApplyRequestSchema.extend({
21879
- kind: external_exports.literal(RESOURCE_KIND_ENVIRONMENT)
21880
- });
21881
- var ProfileApplyDocumentSchema = ProfileApplyRequestSchema.extend({
21882
- kind: external_exports.literal(RESOURCE_KIND_PROFILE)
21883
- });
21884
- var ToolApplyDocumentSchema = ToolApplyRequestSchema.extend({
21885
- kind: external_exports.literal(RESOURCE_KIND_TOOL)
21886
- });
21887
- var SessionApplyDocumentSchema = SessionApplyRequestSchema.extend({
21888
- kind: external_exports.literal(RESOURCE_KIND_SESSION)
21889
- });
21883
+ var EnvironmentApplyDocumentSchema = resourceApplyDocumentSchema(
21884
+ RESOURCE_KIND_ENVIRONMENT,
21885
+ EnvironmentApplyRequestSchema.shape.spec
21886
+ );
21887
+ var ProfileApplyDocumentSchema = resourceApplyDocumentSchema(
21888
+ RESOURCE_KIND_PROFILE,
21889
+ ProfileApplyRequestSchema.shape.spec
21890
+ );
21891
+ var ToolApplyDocumentSchema = resourceApplyDocumentSchema(
21892
+ RESOURCE_KIND_TOOL,
21893
+ ToolApplyRequestSchema.shape.spec
21894
+ );
21895
+ var SessionApplyDocumentSchema = resourceApplyDocumentSchema(
21896
+ RESOURCE_KIND_SESSION,
21897
+ SessionApplyRequestSchema.shape.spec
21898
+ );
21890
21899
  var ProjectApplyResourceSchema = external_exports.discriminatedUnion("kind", [
21891
21900
  EnvironmentApplyDocumentSchema,
21892
21901
  ProfileApplyDocumentSchema,
21893
21902
  ToolApplyDocumentSchema,
21894
21903
  SessionApplyDocumentSchema
21895
21904
  ]);
21896
- var PROJECT_RESOURCE_KINDS = [
21905
+ var PROJECT_RESOURCE_APPLY_ORDER = [
21897
21906
  RESOURCE_KIND_ENVIRONMENT,
21898
21907
  RESOURCE_KIND_PROFILE,
21899
21908
  RESOURCE_KIND_TOOL,
21900
21909
  RESOURCE_KIND_SESSION
21901
21910
  ];
21911
+ var PROJECT_RESOURCE_KINDS = PROJECT_RESOURCE_APPLY_ORDER;
21902
21912
  var ProjectDeleteResourceSchema = external_exports.object({
21903
21913
  kind: external_exports.enum(PROJECT_RESOURCE_KINDS),
21904
21914
  name: external_exports.string().trim().min(1)
@@ -26259,7 +26269,7 @@ Object.assign(lookup, {
26259
26269
  // package.json
26260
26270
  var package_default = {
26261
26271
  name: "@autohq/cli",
26262
- version: "0.1.122",
26272
+ version: "0.1.123",
26263
26273
  license: "SEE LICENSE IN README.md",
26264
26274
  publishConfig: {
26265
26275
  access: "public"
package/dist/index.js CHANGED
@@ -17132,6 +17132,11 @@ function resourceApplySchema(spec) {
17132
17132
  spec
17133
17133
  });
17134
17134
  }
17135
+ function resourceApplyDocumentSchema(kind, spec) {
17136
+ return resourceApplySchema(spec).extend({
17137
+ kind: external_exports.literal(kind)
17138
+ });
17139
+ }
17135
17140
  var ResourceNameSchema, StringMapSchema, MetadataInputSchema, MetadataSchema;
17136
17141
  var init_resources = __esm({
17137
17142
  "../../packages/schemas/src/resources.ts"() {
@@ -18573,39 +18578,45 @@ var init_sessions = __esm({
18573
18578
  });
18574
18579
 
18575
18580
  // ../../packages/schemas/src/project-resources.ts
18576
- var EnvironmentApplyDocumentSchema, ProfileApplyDocumentSchema, ToolApplyDocumentSchema, SessionApplyDocumentSchema, ProjectApplyResourceSchema, PROJECT_RESOURCE_KINDS, ProjectDeleteResourceSchema, AVATAR_ASSET_CONTENT_TYPES, MAX_AVATAR_ASSET_BASE64_LENGTH, ProjectApplyAssetSchema, ProjectApplyAssetsSchema, AvatarAssetUploadRequestSchema, AvatarAssetUploadResponseSchema, ProjectApplyRequestSchema, ProjectApplySystemConfigSchema, ProjectAppliedResourceSchema, ProjectApplyDiagnosticSchema, ProjectApplyResponseSchema;
18581
+ var EnvironmentApplyDocumentSchema, ProfileApplyDocumentSchema, ToolApplyDocumentSchema, SessionApplyDocumentSchema, ProjectApplyResourceSchema, PROJECT_RESOURCE_APPLY_ORDER, PROJECT_RESOURCE_KINDS, ProjectDeleteResourceSchema, AVATAR_ASSET_CONTENT_TYPES, MAX_AVATAR_ASSET_BASE64_LENGTH, ProjectApplyAssetSchema, ProjectApplyAssetsSchema, AvatarAssetUploadRequestSchema, AvatarAssetUploadResponseSchema, ProjectApplyRequestSchema, ProjectApplySystemConfigSchema, ProjectAppliedResourceSchema, ProjectApplyDiagnosticSchema, ProjectApplyResponseSchema;
18577
18582
  var init_project_resources = __esm({
18578
18583
  "../../packages/schemas/src/project-resources.ts"() {
18579
18584
  "use strict";
18580
18585
  init_zod();
18581
18586
  init_environments();
18582
18587
  init_profiles2();
18588
+ init_resources();
18583
18589
  init_sessions();
18584
18590
  init_tools();
18585
- EnvironmentApplyDocumentSchema = EnvironmentApplyRequestSchema.extend({
18586
- kind: external_exports.literal(RESOURCE_KIND_ENVIRONMENT)
18587
- });
18588
- ProfileApplyDocumentSchema = ProfileApplyRequestSchema.extend({
18589
- kind: external_exports.literal(RESOURCE_KIND_PROFILE)
18590
- });
18591
- ToolApplyDocumentSchema = ToolApplyRequestSchema.extend({
18592
- kind: external_exports.literal(RESOURCE_KIND_TOOL)
18593
- });
18594
- SessionApplyDocumentSchema = SessionApplyRequestSchema.extend({
18595
- kind: external_exports.literal(RESOURCE_KIND_SESSION)
18596
- });
18591
+ EnvironmentApplyDocumentSchema = resourceApplyDocumentSchema(
18592
+ RESOURCE_KIND_ENVIRONMENT,
18593
+ EnvironmentApplyRequestSchema.shape.spec
18594
+ );
18595
+ ProfileApplyDocumentSchema = resourceApplyDocumentSchema(
18596
+ RESOURCE_KIND_PROFILE,
18597
+ ProfileApplyRequestSchema.shape.spec
18598
+ );
18599
+ ToolApplyDocumentSchema = resourceApplyDocumentSchema(
18600
+ RESOURCE_KIND_TOOL,
18601
+ ToolApplyRequestSchema.shape.spec
18602
+ );
18603
+ SessionApplyDocumentSchema = resourceApplyDocumentSchema(
18604
+ RESOURCE_KIND_SESSION,
18605
+ SessionApplyRequestSchema.shape.spec
18606
+ );
18597
18607
  ProjectApplyResourceSchema = external_exports.discriminatedUnion("kind", [
18598
18608
  EnvironmentApplyDocumentSchema,
18599
18609
  ProfileApplyDocumentSchema,
18600
18610
  ToolApplyDocumentSchema,
18601
18611
  SessionApplyDocumentSchema
18602
18612
  ]);
18603
- PROJECT_RESOURCE_KINDS = [
18613
+ PROJECT_RESOURCE_APPLY_ORDER = [
18604
18614
  RESOURCE_KIND_ENVIRONMENT,
18605
18615
  RESOURCE_KIND_PROFILE,
18606
18616
  RESOURCE_KIND_TOOL,
18607
18617
  RESOURCE_KIND_SESSION
18608
18618
  ];
18619
+ PROJECT_RESOURCE_KINDS = PROJECT_RESOURCE_APPLY_ORDER;
18609
18620
  ProjectDeleteResourceSchema = external_exports.object({
18610
18621
  kind: external_exports.enum(PROJECT_RESOURCE_KINDS),
18611
18622
  name: external_exports.string().trim().min(1)
@@ -21220,7 +21231,7 @@ var init_package = __esm({
21220
21231
  "package.json"() {
21221
21232
  package_default = {
21222
21233
  name: "@autohq/cli",
21223
- version: "0.1.122",
21234
+ version: "0.1.123",
21224
21235
  license: "SEE LICENSE IN README.md",
21225
21236
  publishConfig: {
21226
21237
  access: "public"
@@ -21564,7 +21575,7 @@ function appliedResourceKind(request, response, index) {
21564
21575
  return kind;
21565
21576
  }
21566
21577
  function mcpOAuthToolConnectionsFromApplyRequest(request) {
21567
- return request.resources.filter((resource) => resource.kind === "tool" /* Tool */).flatMap((resource) => {
21578
+ return request.resources.filter((resource) => resource.kind === RESOURCE_KIND_TOOL).flatMap((resource) => {
21568
21579
  if (resource.spec.kind !== "mcp_remote" || resource.spec.auth.kind !== "mcp_oauth") {
21569
21580
  return [];
21570
21581
  }
@@ -21577,7 +21588,7 @@ function mcpOAuthToolConnectionsFromApplyRequest(request) {
21577
21588
  });
21578
21589
  }
21579
21590
  function mcpOAuthToolConnectionsFromAppliedResources(resources) {
21580
- return resources.filter((item) => item.kind === "tool" /* Tool */).flatMap((item) => {
21591
+ return resources.filter((item) => item.kind === RESOURCE_KIND_TOOL).flatMap((item) => {
21581
21592
  const resource = item.resource;
21582
21593
  if (resource.spec.kind !== "mcp_remote" || resource.spec.auth.kind !== "mcp_oauth") {
21583
21594
  return [];
@@ -21592,7 +21603,7 @@ function mcpOAuthToolConnectionsFromAppliedResources(resources) {
21592
21603
  }
21593
21604
  function applyFiles(root) {
21594
21605
  const files = [];
21595
- for (const kind of APPLY_RESOURCE_ORDER) {
21606
+ for (const kind of PROJECT_RESOURCE_APPLY_ORDER) {
21596
21607
  const directory = APPLY_DIRECTORIES[kind];
21597
21608
  const path2 = join3(root, directory);
21598
21609
  let entries;
@@ -21654,7 +21665,7 @@ function readApplyDocument(document) {
21654
21665
  function readApplyAssets(resources, projectRoot) {
21655
21666
  const assets = {};
21656
21667
  for (const resource of resources) {
21657
- if (resource.kind !== "session" /* Session */) {
21668
+ if (resource.kind !== RESOURCE_KIND_SESSION) {
21658
21669
  continue;
21659
21670
  }
21660
21671
  const avatarAsset = resource.spec.identity?.avatar?.asset;
@@ -21758,11 +21769,11 @@ function isInside(path2, parent) {
21758
21769
  }
21759
21770
  function applyCandidate(document) {
21760
21771
  if (!isRecord(document) || !("kind" in document)) {
21761
- return { kind: "session" /* Session */, value: document };
21772
+ return { kind: RESOURCE_KIND_SESSION, value: document };
21762
21773
  }
21763
- if (!Object.values(ResourceKind).includes(document.kind)) {
21774
+ if (!PROJECT_RESOURCE_APPLY_ORDER.includes(document.kind)) {
21764
21775
  throw new Error(
21765
- `Unsupported apply resource kind "${String(document.kind)}"; supported kinds are ${APPLY_RESOURCE_ORDER.map((kind2) => `"${kind2}"`).join(", ")}`
21776
+ `Unsupported apply resource kind "${String(document.kind)}"; supported kinds are ${PROJECT_RESOURCE_APPLY_ORDER.map((kind2) => `"${kind2}"`).join(", ")}`
21766
21777
  );
21767
21778
  }
21768
21779
  const kind = document.kind;
@@ -21793,35 +21804,22 @@ function resourceApplyFiles(directory, entries) {
21793
21804
  }
21794
21805
  return files.sort((left, right) => left.localeCompare(right));
21795
21806
  }
21796
- var ResourceKind, APPLY_RESOURCE_ORDER, APPLY_DIRECTORIES, APPLY_SCHEMAS, ALLOWED_AVATAR_EXTENSIONS;
21807
+ var APPLY_DIRECTORIES, APPLY_SCHEMAS, ALLOWED_AVATAR_EXTENSIONS;
21797
21808
  var init_files = __esm({
21798
21809
  "src/commands/apply/files.ts"() {
21799
21810
  "use strict";
21800
21811
  init_src();
21801
- ResourceKind = /* @__PURE__ */ ((ResourceKind2) => {
21802
- ResourceKind2["Environment"] = "environment";
21803
- ResourceKind2["Profile"] = "profile";
21804
- ResourceKind2["Tool"] = "tool";
21805
- ResourceKind2["Session"] = "session";
21806
- return ResourceKind2;
21807
- })(ResourceKind || {});
21808
- APPLY_RESOURCE_ORDER = [
21809
- "environment" /* Environment */,
21810
- "profile" /* Profile */,
21811
- "tool" /* Tool */,
21812
- "session" /* Session */
21813
- ];
21814
21812
  APPLY_DIRECTORIES = {
21815
- ["environment" /* Environment */]: "environments",
21816
- ["profile" /* Profile */]: "profiles",
21817
- ["tool" /* Tool */]: "tools",
21818
- ["session" /* Session */]: "sessions"
21813
+ environment: "environments",
21814
+ profile: "profiles",
21815
+ tool: "tools",
21816
+ session: "sessions"
21819
21817
  };
21820
21818
  APPLY_SCHEMAS = {
21821
- ["environment" /* Environment */]: EnvironmentApplyRequestSchema,
21822
- ["profile" /* Profile */]: ProfileApplyRequestSchema,
21823
- ["tool" /* Tool */]: ToolApplyRequestSchema,
21824
- ["session" /* Session */]: SessionApplyRequestSchema
21819
+ environment: EnvironmentApplyRequestSchema,
21820
+ profile: ProfileApplyRequestSchema,
21821
+ tool: ToolApplyRequestSchema,
21822
+ session: SessionApplyRequestSchema
21825
21823
  };
21826
21824
  ALLOWED_AVATAR_EXTENSIONS = /* @__PURE__ */ new Set([".jpg", ".jpeg", ".png"]);
21827
21825
  }
@@ -22009,10 +22007,58 @@ async function requireProjectResource(client, reference, options) {
22009
22007
  }
22010
22008
  return resource;
22011
22009
  }
22010
+ var PROJECT_RESOURCE_TUI_DEFINITION_BY_KIND, PROJECT_RESOURCE_TUI_ORDER, PROJECT_RESOURCE_TUI_DEFINITIONS, PROJECT_RESOURCE_TUI_DEFINITIONS_BY_SECTION, PROJECT_RESOURCE_TUI_DEFINITIONS_BY_KIND;
22012
22011
  var init_resources3 = __esm({
22013
22012
  "src/lib/resources.ts"() {
22014
22013
  "use strict";
22015
22014
  init_src();
22015
+ PROJECT_RESOURCE_TUI_DEFINITION_BY_KIND = {
22016
+ [RESOURCE_KIND_ENVIRONMENT]: {
22017
+ kind: RESOURCE_KIND_ENVIRONMENT,
22018
+ section: "environments",
22019
+ label: "Environment",
22020
+ pluralLabel: "Environments"
22021
+ },
22022
+ [RESOURCE_KIND_PROFILE]: {
22023
+ kind: RESOURCE_KIND_PROFILE,
22024
+ section: "profiles",
22025
+ label: "Profile",
22026
+ pluralLabel: "Profiles"
22027
+ },
22028
+ [RESOURCE_KIND_TOOL]: {
22029
+ kind: RESOURCE_KIND_TOOL,
22030
+ section: "tools",
22031
+ label: "Tool",
22032
+ pluralLabel: "Tools"
22033
+ },
22034
+ [RESOURCE_KIND_SESSION]: {
22035
+ kind: RESOURCE_KIND_SESSION,
22036
+ section: "sessions",
22037
+ label: "Session",
22038
+ pluralLabel: "Sessions"
22039
+ }
22040
+ };
22041
+ PROJECT_RESOURCE_TUI_ORDER = [
22042
+ RESOURCE_KIND_SESSION,
22043
+ RESOURCE_KIND_PROFILE,
22044
+ RESOURCE_KIND_ENVIRONMENT,
22045
+ RESOURCE_KIND_TOOL
22046
+ ];
22047
+ PROJECT_RESOURCE_TUI_DEFINITIONS = PROJECT_RESOURCE_TUI_ORDER.map(
22048
+ (kind) => PROJECT_RESOURCE_TUI_DEFINITION_BY_KIND[kind]
22049
+ );
22050
+ PROJECT_RESOURCE_TUI_DEFINITIONS_BY_SECTION = new Map(
22051
+ PROJECT_RESOURCE_TUI_DEFINITIONS.map((definition) => [
22052
+ definition.section,
22053
+ definition
22054
+ ])
22055
+ );
22056
+ PROJECT_RESOURCE_TUI_DEFINITIONS_BY_KIND = new Map(
22057
+ PROJECT_RESOURCE_TUI_DEFINITIONS.map((definition) => [
22058
+ definition.kind,
22059
+ definition
22060
+ ])
22061
+ );
22016
22062
  }
22017
22063
  });
22018
22064
 
@@ -25442,41 +25488,59 @@ import { Box as Box13, Text as Text14, useApp as useApp2, useInput as useInput4,
25442
25488
  import TextInput3 from "ink-text-input";
25443
25489
  import { useCallback as useCallback2, useEffect as useEffect3, useMemo as useMemo3, useRef as useRef2, useState as useState3 } from "react";
25444
25490
  import { Fragment as Fragment3, jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
25491
+ function resourceNavItem(input) {
25492
+ const definition = PROJECT_RESOURCE_TUI_DEFINITIONS_BY_SECTION.get(
25493
+ input.section
25494
+ );
25495
+ if (!definition) {
25496
+ throw new Error(`Missing TUI resource definition for ${input.section}`);
25497
+ }
25498
+ return {
25499
+ k: input.k,
25500
+ label: definition.pluralLabel,
25501
+ activeSection: definition.section
25502
+ };
25503
+ }
25445
25504
  function clampListIndex(index, length) {
25446
25505
  return Math.min(Math.max(0, index), Math.max(0, length - 1));
25447
25506
  }
25448
25507
  function sectionForResourceShortcut(input) {
25449
- return RESOURCES.find((resource) => resource.k === input)?.activeSection ?? null;
25508
+ return DASHBOARD_NAV_ITEMS.find((resource) => resource.k === input)?.activeSection ?? null;
25450
25509
  }
25451
25510
  function inspectParentLabel(kind) {
25452
- switch (kind) {
25453
- case "session":
25454
- return "sessions";
25455
- case "profile":
25456
- return "profiles";
25457
- case "environment":
25458
- return "environments";
25459
- case "tool":
25460
- return "tools";
25461
- }
25511
+ return PROJECT_RESOURCE_TUI_DEFINITIONS.find(
25512
+ (definition) => definition.kind === kind
25513
+ )?.section ?? kind;
25462
25514
  }
25463
- function editableResourceForSelection(input) {
25515
+ function isApplyResourceSection(section) {
25516
+ return PROJECT_RESOURCE_TUI_DEFINITIONS_BY_SECTION.has(
25517
+ section
25518
+ );
25519
+ }
25520
+ function selectedNamedResourceForSection(input) {
25464
25521
  switch (input.activeSection) {
25465
- case "sessions":
25466
- return input.selectedSession ? { kind: "session", name: input.selectedSession.metadata.name } : null;
25467
- case "profiles":
25468
- return input.selectedProfile ? { kind: "profile", name: input.selectedProfile.metadata.name } : null;
25469
25522
  case "environments":
25470
- return input.selectedEnvironment ? {
25471
- kind: "environment",
25472
- name: input.selectedEnvironment.metadata.name
25473
- } : null;
25523
+ return input.selectedEnvironment ?? null;
25524
+ case "profiles":
25525
+ return input.selectedProfile ?? null;
25526
+ case "sessions":
25527
+ return input.selectedSession ?? null;
25474
25528
  case "tools":
25475
- return input.selectedTool ? { kind: "tool", name: input.selectedTool.metadata.name } : null;
25529
+ return input.selectedTool ?? null;
25476
25530
  default:
25477
25531
  return null;
25478
25532
  }
25479
25533
  }
25534
+ function editableResourceForSelection(input) {
25535
+ if (!isApplyResourceSection(input.activeSection)) {
25536
+ return null;
25537
+ }
25538
+ const definition = PROJECT_RESOURCE_TUI_DEFINITIONS_BY_SECTION.get(
25539
+ input.activeSection
25540
+ );
25541
+ const selected = selectedNamedResourceForSection(input);
25542
+ return definition && selected ? { kind: definition.kind, name: selected.metadata.name } : null;
25543
+ }
25480
25544
  function HomeView({ apiUrl, notice, returnToSession }) {
25481
25545
  const client = useApiClient();
25482
25546
  const queryClient = useQueryClient2();
@@ -25633,29 +25697,39 @@ function HomeView({ apiUrl, notice, returnToSession }) {
25633
25697
  const selectedEnvironment = environments[environmentIndex];
25634
25698
  const selectedTool = tools[toolIndex];
25635
25699
  const selectedInspectableResource = useMemo3(() => {
25700
+ const selectedEditable = editableResourceForSelection({
25701
+ activeSection,
25702
+ selectedEnvironment,
25703
+ selectedProfile,
25704
+ selectedSession,
25705
+ selectedTool
25706
+ });
25707
+ if (!selectedEditable) {
25708
+ return null;
25709
+ }
25636
25710
  switch (activeSection) {
25637
25711
  case "sessions":
25638
25712
  return selectedSession ? {
25639
- kind: "session",
25640
- name: selectedSession.metadata.name,
25713
+ kind: selectedEditable.kind,
25714
+ name: selectedEditable.name,
25641
25715
  spec: selectedSession.spec
25642
25716
  } : null;
25643
25717
  case "profiles":
25644
25718
  return selectedProfile ? {
25645
- kind: "profile",
25646
- name: selectedProfile.metadata.name,
25719
+ kind: selectedEditable.kind,
25720
+ name: selectedEditable.name,
25647
25721
  spec: selectedProfile.spec
25648
25722
  } : null;
25649
25723
  case "environments":
25650
25724
  return selectedEnvironment ? {
25651
- kind: "environment",
25652
- name: selectedEnvironment.metadata.name,
25725
+ kind: selectedEditable.kind,
25726
+ name: selectedEditable.name,
25653
25727
  spec: selectedEnvironment.spec
25654
25728
  } : null;
25655
25729
  case "tools":
25656
25730
  return selectedTool ? {
25657
- kind: "tool",
25658
- name: selectedTool.metadata.name,
25731
+ kind: selectedEditable.kind,
25732
+ name: selectedEditable.name,
25659
25733
  spec: selectedTool.spec
25660
25734
  } : null;
25661
25735
  default:
@@ -26195,7 +26269,7 @@ function HomeView({ apiUrl, notice, returnToSession }) {
26195
26269
  return;
26196
26270
  }
26197
26271
  }
26198
- if (activeSection === "profiles" || activeSection === "environments" || activeSection === "tools" || activeSection === "serviceAccounts" || activeSection === "connections") {
26272
+ if (isApplyResourceSection(activeSection) && activeSection !== "sessions" || activeSection === "serviceAccounts" || activeSection === "connections") {
26199
26273
  if (key.escape) {
26200
26274
  if (activeSection === "connections" && connectionMode === "providers") {
26201
26275
  setConnectionMode("connections");
@@ -26502,8 +26576,10 @@ function HomeView({ apiUrl, notice, returnToSession }) {
26502
26576
  );
26503
26577
  }
26504
26578
  const resourceColumns = [];
26505
- for (let i = 0; i < RESOURCES.length; i += RESOURCES_PER_COLUMN) {
26506
- resourceColumns.push(RESOURCES.slice(i, i + RESOURCES_PER_COLUMN));
26579
+ for (let i = 0; i < DASHBOARD_NAV_ITEMS.length; i += RESOURCES_PER_COLUMN) {
26580
+ resourceColumns.push(
26581
+ DASHBOARD_NAV_ITEMS.slice(i, i + RESOURCES_PER_COLUMN)
26582
+ );
26507
26583
  }
26508
26584
  let sectionTitle;
26509
26585
  switch (activeSection) {
@@ -26517,14 +26593,13 @@ function HomeView({ apiUrl, notice, returnToSession }) {
26517
26593
  sectionTitle = `Service Accounts[${serviceAccounts.length}]`;
26518
26594
  break;
26519
26595
  case "profiles":
26520
- sectionTitle = `Profiles[${profiles.length}]`;
26521
- break;
26522
26596
  case "environments":
26523
- sectionTitle = `Environments[${environments.length}]`;
26524
- break;
26525
- case "tools":
26526
- sectionTitle = `Tools[${tools.length}]`;
26597
+ case "tools": {
26598
+ const definition = PROJECT_RESOURCE_TUI_DEFINITIONS_BY_SECTION.get(activeSection);
26599
+ const count = activeSection === "profiles" ? profiles.length : activeSection === "environments" ? environments.length : tools.length;
26600
+ sectionTitle = `${definition?.pluralLabel ?? activeSection}[${count}]`;
26527
26601
  break;
26602
+ }
26528
26603
  case "connections":
26529
26604
  sectionTitle = connectionMode === "providers" ? `Providers[${connectionProviderRowCount}]` : `Connections[${connectionRowCount}]`;
26530
26605
  break;
@@ -26601,13 +26676,13 @@ function HomeView({ apiUrl, notice, returnToSession }) {
26601
26676
  { k: "q", label: "Quit" }
26602
26677
  ]
26603
26678
  }
26604
- ) : activeSection === "profiles" || activeSection === "environments" || activeSection === "tools" || activeSection === "serviceAccounts" || activeSection === "connections" ? /* @__PURE__ */ jsx14(
26679
+ ) : isApplyResourceSection(activeSection) || activeSection === "serviceAccounts" || activeSection === "connections" ? /* @__PURE__ */ jsx14(
26605
26680
  ActionKeyColumns,
26606
26681
  {
26607
26682
  keys: [
26608
- ...activeSection === "profiles" || activeSection === "environments" || activeSection === "tools" || activeSection === "serviceAccounts" ? [{ k: "\u2191\u2193", label: "Navigate" }] : [],
26683
+ ...isApplyResourceSection(activeSection) || activeSection === "serviceAccounts" ? [{ k: "\u2191\u2193", label: "Navigate" }] : [],
26609
26684
  ...activeSection === "profiles" ? [{ k: "enter", label: "Environment" }] : [],
26610
- ...activeSection === "profiles" || activeSection === "environments" || activeSection === "tools" ? [
26685
+ ...isApplyResourceSection(activeSection) ? [
26611
26686
  { k: "i", label: "Inspect" },
26612
26687
  { k: "e", label: "Edit" }
26613
26688
  ] : [],
@@ -26995,13 +27070,14 @@ function ContentTopBorder({ title, width }) {
26995
27070
  /* @__PURE__ */ jsx14(Text14, { color: "gray", children: `${"\u2500".repeat(right)}\u2510` })
26996
27071
  ] });
26997
27072
  }
26998
- var CONNECTION_REFRESH_INTERVAL_MS, CONNECTION_REFRESH_TIMEOUT_MS, RESOURCES, RESOURCES_PER_COLUMN;
27073
+ var CONNECTION_REFRESH_INTERVAL_MS, CONNECTION_REFRESH_TIMEOUT_MS, DASHBOARD_NAV_ITEMS, RESOURCES_PER_COLUMN;
26999
27074
  var init_HomeView = __esm({
27000
27075
  "src/tui/HomeView.tsx"() {
27001
27076
  "use strict";
27002
27077
  init_login();
27003
27078
  init_base_url();
27004
27079
  init_browser();
27080
+ init_resources3();
27005
27081
  init_ApiClientContext();
27006
27082
  init_ConnectionProvidersView();
27007
27083
  init_ConnectionsView();
@@ -27014,12 +27090,12 @@ var init_HomeView = __esm({
27014
27090
  init_string();
27015
27091
  CONNECTION_REFRESH_INTERVAL_MS = 1500;
27016
27092
  CONNECTION_REFRESH_TIMEOUT_MS = 9e4;
27017
- RESOURCES = [
27018
- { k: "1", label: "Sessions", activeSection: "sessions" },
27093
+ DASHBOARD_NAV_ITEMS = [
27094
+ resourceNavItem({ k: "1", section: "sessions" }),
27019
27095
  { k: "2", label: "Runs", activeSection: "runs" },
27020
- { k: "3", label: "Profiles", activeSection: "profiles" },
27021
- { k: "4", label: "Environments", activeSection: "environments" },
27022
- { k: "5", label: "Tools", activeSection: "tools" },
27096
+ resourceNavItem({ k: "3", section: "profiles" }),
27097
+ resourceNavItem({ k: "4", section: "environments" }),
27098
+ resourceNavItem({ k: "5", section: "tools" }),
27023
27099
  { k: "6", label: "Projects", activeSection: "projects" },
27024
27100
  { k: "7", label: "Service Accounts", activeSection: "serviceAccounts" },
27025
27101
  { k: "8", label: "Connections", activeSection: "connections" }
@@ -27243,48 +27319,11 @@ async function launch(opts) {
27243
27319
  }
27244
27320
  }
27245
27321
  async function refreshEditedResource(input) {
27246
- switch (input.kind) {
27247
- case "session": {
27248
- const response = await input.apiClient.listSessions({
27249
- apiBaseUrl: input.apiUrl
27250
- });
27251
- input.queryClient.setQueryData(
27252
- queryKeys.sessions(input.apiUrl),
27253
- sortSessions(response.sessions)
27254
- );
27255
- return;
27256
- }
27257
- case "profile": {
27258
- const response = await input.apiClient.listProfiles({
27259
- apiBaseUrl: input.apiUrl
27260
- });
27261
- input.queryClient.setQueryData(
27262
- queryKeys.profiles(input.apiUrl),
27263
- sortByResourceName(response.profiles)
27264
- );
27265
- return;
27266
- }
27267
- case "environment": {
27268
- const response = await input.apiClient.listEnvironments({
27269
- apiBaseUrl: input.apiUrl
27270
- });
27271
- input.queryClient.setQueryData(
27272
- queryKeys.environments(input.apiUrl),
27273
- sortByResourceName(response.environments)
27274
- );
27275
- return;
27276
- }
27277
- case "tool": {
27278
- const response = await input.apiClient.listTools({
27279
- apiBaseUrl: input.apiUrl
27280
- });
27281
- input.queryClient.setQueryData(
27282
- queryKeys.tools(input.apiUrl),
27283
- sortByResourceName(response.tools)
27284
- );
27285
- return;
27286
- }
27287
- }
27322
+ const definition = RESOURCE_REFRESH_DEFINITIONS[input.kind];
27323
+ input.queryClient.setQueryData(
27324
+ definition.queryKey(input.apiUrl),
27325
+ definition.sort(await definition.list(input))
27326
+ );
27288
27327
  }
27289
27328
  function sortByResourceName(resources) {
27290
27329
  return resources.slice().sort(
@@ -27294,9 +27333,11 @@ function sortByResourceName(resources) {
27294
27333
  function isEditSelection(selection) {
27295
27334
  return "action" in selection && selection.action === "editResource";
27296
27335
  }
27336
+ var RESOURCE_REFRESH_DEFINITIONS;
27297
27337
  var init_launcher = __esm({
27298
27338
  "src/tui/launcher.ts"() {
27299
27339
  "use strict";
27340
+ init_src();
27300
27341
  init_actions2();
27301
27342
  init_base_url();
27302
27343
  init_client();
@@ -27305,6 +27346,36 @@ var init_launcher = __esm({
27305
27346
  init_HomeView();
27306
27347
  init_SplashView();
27307
27348
  init_queries();
27349
+ RESOURCE_REFRESH_DEFINITIONS = {
27350
+ [RESOURCE_KIND_ENVIRONMENT]: {
27351
+ async list({ apiClient, apiUrl }) {
27352
+ return (await apiClient.listEnvironments({ apiBaseUrl: apiUrl })).environments;
27353
+ },
27354
+ queryKey: queryKeys.environments,
27355
+ sort: sortByResourceName
27356
+ },
27357
+ [RESOURCE_KIND_PROFILE]: {
27358
+ async list({ apiClient, apiUrl }) {
27359
+ return (await apiClient.listProfiles({ apiBaseUrl: apiUrl })).profiles;
27360
+ },
27361
+ queryKey: queryKeys.profiles,
27362
+ sort: sortByResourceName
27363
+ },
27364
+ [RESOURCE_KIND_TOOL]: {
27365
+ async list({ apiClient, apiUrl }) {
27366
+ return (await apiClient.listTools({ apiBaseUrl: apiUrl })).tools;
27367
+ },
27368
+ queryKey: queryKeys.tools,
27369
+ sort: sortByResourceName
27370
+ },
27371
+ [RESOURCE_KIND_SESSION]: {
27372
+ async list({ apiClient, apiUrl }) {
27373
+ return (await apiClient.listSessions({ apiBaseUrl: apiUrl })).sessions;
27374
+ },
27375
+ queryKey: queryKeys.sessions,
27376
+ sort: (resources) => sortSessions(resources)
27377
+ }
27378
+ };
27308
27379
  }
27309
27380
  });
27310
27381
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.122",
3
+ "version": "0.1.123",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"