@autohq/cli 0.1.100 → 0.1.102

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.
@@ -21815,13 +21815,14 @@ var ProjectApplyResourceSchema = external_exports.discriminatedUnion("kind", [
21815
21815
  ToolApplyDocumentSchema,
21816
21816
  SessionApplyDocumentSchema
21817
21817
  ]);
21818
+ var PROJECT_RESOURCE_KINDS = [
21819
+ RESOURCE_KIND_ENVIRONMENT,
21820
+ RESOURCE_KIND_PROFILE,
21821
+ RESOURCE_KIND_TOOL,
21822
+ RESOURCE_KIND_SESSION
21823
+ ];
21818
21824
  var ProjectDeleteResourceSchema = external_exports.object({
21819
- kind: external_exports.enum([
21820
- RESOURCE_KIND_ENVIRONMENT,
21821
- RESOURCE_KIND_PROFILE,
21822
- RESOURCE_KIND_TOOL,
21823
- RESOURCE_KIND_SESSION
21824
- ]),
21825
+ kind: external_exports.enum(PROJECT_RESOURCE_KINDS),
21825
21826
  name: external_exports.string().trim().min(1)
21826
21827
  });
21827
21828
  var AVATAR_ASSET_CONTENT_TYPES = ["image/png", "image/jpeg"];
package/dist/index.js CHANGED
@@ -17628,7 +17628,7 @@ var init_sessions = __esm({
17628
17628
  });
17629
17629
 
17630
17630
  // ../../packages/schemas/src/project-resources.ts
17631
- var EnvironmentApplyDocumentSchema, ProfileApplyDocumentSchema, ToolApplyDocumentSchema, SessionApplyDocumentSchema, ProjectApplyResourceSchema, ProjectDeleteResourceSchema, AVATAR_ASSET_CONTENT_TYPES, MAX_AVATAR_ASSET_BASE64_LENGTH, ProjectApplyAssetSchema, ProjectApplyAssetsSchema, ProjectApplyRequestSchema, ProjectApplySystemConfigSchema, ProjectAppliedResourceSchema, ProjectApplyDiagnosticSchema, ProjectApplyResponseSchema;
17631
+ var EnvironmentApplyDocumentSchema, ProfileApplyDocumentSchema, ToolApplyDocumentSchema, SessionApplyDocumentSchema, ProjectApplyResourceSchema, PROJECT_RESOURCE_KINDS, ProjectDeleteResourceSchema, AVATAR_ASSET_CONTENT_TYPES, MAX_AVATAR_ASSET_BASE64_LENGTH, ProjectApplyAssetSchema, ProjectApplyAssetsSchema, ProjectApplyRequestSchema, ProjectApplySystemConfigSchema, ProjectAppliedResourceSchema, ProjectApplyDiagnosticSchema, ProjectApplyResponseSchema;
17632
17632
  var init_project_resources = __esm({
17633
17633
  "../../packages/schemas/src/project-resources.ts"() {
17634
17634
  "use strict";
@@ -17655,13 +17655,14 @@ var init_project_resources = __esm({
17655
17655
  ToolApplyDocumentSchema,
17656
17656
  SessionApplyDocumentSchema
17657
17657
  ]);
17658
+ PROJECT_RESOURCE_KINDS = [
17659
+ RESOURCE_KIND_ENVIRONMENT,
17660
+ RESOURCE_KIND_PROFILE,
17661
+ RESOURCE_KIND_TOOL,
17662
+ RESOURCE_KIND_SESSION
17663
+ ];
17658
17664
  ProjectDeleteResourceSchema = external_exports.object({
17659
- kind: external_exports.enum([
17660
- RESOURCE_KIND_ENVIRONMENT,
17661
- RESOURCE_KIND_PROFILE,
17662
- RESOURCE_KIND_TOOL,
17663
- RESOURCE_KIND_SESSION
17664
- ]),
17665
+ kind: external_exports.enum(PROJECT_RESOURCE_KINDS),
17665
17666
  name: external_exports.string().trim().min(1)
17666
17667
  });
17667
17668
  AVATAR_ASSET_CONTENT_TYPES = ["image/png", "image/jpeg"];
@@ -20373,14 +20374,25 @@ var init_client = __esm({
20373
20374
  // src/lib/browser.ts
20374
20375
  import { spawn } from "child_process";
20375
20376
  function openBrowser(url2) {
20376
- const command = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
20377
- const args = process.platform === "win32" ? ["/c", "start", "", url2] : [url2];
20378
- const child = spawn(command, args, {
20377
+ const child = spawn(openCommand(), openArgs(url2), {
20379
20378
  detached: true,
20380
20379
  stdio: "ignore"
20381
20380
  });
20382
20381
  child.unref();
20383
20382
  }
20383
+ function openCommand() {
20384
+ switch (process.platform) {
20385
+ case "darwin":
20386
+ return "open";
20387
+ case "win32":
20388
+ return "cmd";
20389
+ default:
20390
+ return "xdg-open";
20391
+ }
20392
+ }
20393
+ function openArgs(url2) {
20394
+ return process.platform === "win32" ? ["/c", "start", "", url2] : [url2];
20395
+ }
20384
20396
  var init_browser = __esm({
20385
20397
  "src/lib/browser.ts"() {
20386
20398
  "use strict";
@@ -21482,6 +21494,48 @@ var init_login = __esm({
21482
21494
  }
21483
21495
  });
21484
21496
 
21497
+ // src/lib/resources.ts
21498
+ function parseProjectResourceReference(resource) {
21499
+ const [kind, name, extra] = resource.split("/");
21500
+ if (!kind || !name || extra) {
21501
+ throw new Error('Resource must be formatted as "kind/name"');
21502
+ }
21503
+ if (!PROJECT_RESOURCE_KINDS.includes(kind)) {
21504
+ throw new Error(
21505
+ `Unsupported resource kind "${kind}"; supported kinds are ${PROJECT_RESOURCE_KINDS.map((value) => `"${value}"`).join(", ")}`
21506
+ );
21507
+ }
21508
+ return { kind, name };
21509
+ }
21510
+ async function listProjectResources2(client, kind, options) {
21511
+ switch (kind) {
21512
+ case RESOURCE_KIND_ENVIRONMENT:
21513
+ return (await client.listEnvironments(options)).environments;
21514
+ case RESOURCE_KIND_PROFILE:
21515
+ return (await client.listProfiles(options)).profiles;
21516
+ case RESOURCE_KIND_TOOL:
21517
+ return (await client.listTools(options)).tools;
21518
+ case RESOURCE_KIND_SESSION:
21519
+ return (await client.listSessions(options)).sessions;
21520
+ }
21521
+ }
21522
+ async function requireProjectResource(client, reference, options) {
21523
+ const resources = await listProjectResources2(client, reference.kind, options);
21524
+ const resource = resources.find(
21525
+ (item) => item.metadata.name === reference.name
21526
+ );
21527
+ if (!resource) {
21528
+ throw new Error(`Resource not found: ${reference.kind}/${reference.name}`);
21529
+ }
21530
+ return resource;
21531
+ }
21532
+ var init_resources3 = __esm({
21533
+ "src/lib/resources.ts"() {
21534
+ "use strict";
21535
+ init_src();
21536
+ }
21537
+ });
21538
+
21485
21539
  // src/commands/edit/actions.ts
21486
21540
  import { spawn as spawn2 } from "child_process";
21487
21541
  import { mkdtempSync, readFileSync as readFileSync4, rmSync, writeFileSync as writeFileSync3 } from "fs";
@@ -21489,13 +21543,13 @@ import { tmpdir } from "os";
21489
21543
  import { join as join5 } from "path";
21490
21544
  import { parseAllDocuments as parseYamlDocuments2, stringify as stringify2 } from "yaml";
21491
21545
  async function editResource(input) {
21492
- const reference = parseEditableResource(input.resource);
21546
+ const reference = parseProjectResourceReference(input.resource);
21493
21547
  const editor = resolveEditor({
21494
21548
  canFallbackToVi: input.canFallbackToVi,
21495
21549
  env: input.env,
21496
21550
  explicit: input.commandOptions.editor
21497
21551
  });
21498
- const current = await getEditableResource(input.client, reference, {
21552
+ const current = await requireProjectResource(input.client, reference, {
21499
21553
  apiBaseUrl: input.commandOptions.apiBaseUrl
21500
21554
  });
21501
21555
  const document = editableResourceDocument(reference.kind, current);
@@ -21543,18 +21597,6 @@ Edited file retained at ${filePath}`);
21543
21597
  }
21544
21598
  }
21545
21599
  }
21546
- function parseEditableResource(resource) {
21547
- const [kind, name, extra] = resource.split("/");
21548
- if (!kind || !name || extra) {
21549
- throw new Error('Resource must be formatted as "kind/name"');
21550
- }
21551
- if (!RESOURCE_KINDS3.includes(kind)) {
21552
- throw new Error(
21553
- `Unsupported resource kind "${kind}"; supported kinds are ${RESOURCE_KINDS3.map((value) => `"${value}"`).join(", ")}`
21554
- );
21555
- }
21556
- return { kind, name };
21557
- }
21558
21600
  function resolveEditor(input) {
21559
21601
  const explicit = input.explicit?.trim();
21560
21602
  if (explicit) {
@@ -21629,44 +21671,12 @@ function editableResourceDocument(kind, resource) {
21629
21671
  spec: resource.spec
21630
21672
  };
21631
21673
  }
21632
- async function getEditableResource(client, reference, options) {
21633
- const resources = await listEditableResources(
21634
- client,
21635
- reference.kind,
21636
- options
21637
- );
21638
- const resource = resources.find(
21639
- (item) => item.metadata.name === reference.name
21640
- );
21641
- if (!resource) {
21642
- throw new Error(`Resource not found: ${reference.kind}/${reference.name}`);
21643
- }
21644
- return resource;
21645
- }
21646
- async function listEditableResources(client, kind, options) {
21647
- switch (kind) {
21648
- case RESOURCE_KIND_ENVIRONMENT:
21649
- return (await client.listEnvironments(options)).environments;
21650
- case RESOURCE_KIND_PROFILE:
21651
- return (await client.listProfiles(options)).profiles;
21652
- case RESOURCE_KIND_TOOL:
21653
- return (await client.listTools(options)).tools;
21654
- case RESOURCE_KIND_SESSION:
21655
- return (await client.listSessions(options)).sessions;
21656
- }
21657
- }
21658
- var RESOURCE_KINDS3;
21659
21674
  var init_actions2 = __esm({
21660
21675
  "src/commands/edit/actions.ts"() {
21661
21676
  "use strict";
21662
21677
  init_src();
21678
+ init_resources3();
21663
21679
  init_actions();
21664
- RESOURCE_KINDS3 = [
21665
- RESOURCE_KIND_ENVIRONMENT,
21666
- RESOURCE_KIND_PROFILE,
21667
- RESOURCE_KIND_TOOL,
21668
- RESOURCE_KIND_SESSION
21669
- ];
21670
21680
  }
21671
21681
  });
21672
21682
 
@@ -21761,7 +21771,7 @@ var init_package = __esm({
21761
21771
  "package.json"() {
21762
21772
  package_default = {
21763
21773
  name: "@autohq/cli",
21764
- version: "0.1.100",
21774
+ version: "0.1.102",
21765
21775
  license: "SEE LICENSE IN README.md",
21766
21776
  publishConfig: {
21767
21777
  access: "public"
@@ -29221,6 +29231,66 @@ function createGithubConnectionApi(context) {
29221
29231
  };
29222
29232
  }
29223
29233
 
29234
+ // src/commands/connections/wait.ts
29235
+ init_browser();
29236
+ var ConnectionWaitTimeoutError = class extends Error {
29237
+ };
29238
+ async function finishConnectionAuthorization(input) {
29239
+ const knownGrantIds = input.wait ? await activeGrantIds(input) : void 0;
29240
+ if (input.openInBrowser) {
29241
+ (input.openBrowser ?? openBrowser)(input.authorizationUrl);
29242
+ }
29243
+ if (!knownGrantIds) {
29244
+ return void 0;
29245
+ }
29246
+ input.writeOutput(
29247
+ `Waiting for the ${input.provider} authorization to complete in the browser...`
29248
+ );
29249
+ return waitForNewGrant(input, knownGrantIds);
29250
+ }
29251
+ var POLL_INTERVAL_MS = 2e3;
29252
+ var POLL_TIMEOUT_MS = 5 * 6e4;
29253
+ async function activeGrantIds(input) {
29254
+ const result = await input.client.listConnections({
29255
+ provider: input.provider,
29256
+ apiBaseUrl: input.apiBaseUrl
29257
+ });
29258
+ return new Set(
29259
+ result.connections.flatMap(
29260
+ (connection) => connection.grants.map((grant) => grant.id)
29261
+ )
29262
+ );
29263
+ }
29264
+ async function waitForNewGrant(input, knownGrantIds) {
29265
+ const sleep3 = input.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
29266
+ const now3 = input.now ?? Date.now;
29267
+ const deadline = now3() + (input.pollTimeoutMs ?? POLL_TIMEOUT_MS);
29268
+ while (now3() < deadline) {
29269
+ await sleep3(input.pollIntervalMs ?? POLL_INTERVAL_MS);
29270
+ const result = await input.client.listConnections({
29271
+ provider: input.provider,
29272
+ apiBaseUrl: input.apiBaseUrl
29273
+ });
29274
+ for (const connection of result.connections) {
29275
+ for (const grant of connection.grants) {
29276
+ if (knownGrantIds.has(grant.id)) {
29277
+ continue;
29278
+ }
29279
+ input.writeOutput(
29280
+ `connected ${input.provider} connection/${grant.name} account/${connection.externalAccount.loginOrName}`
29281
+ );
29282
+ return {
29283
+ connection: grant.name,
29284
+ account: connection.externalAccount.loginOrName
29285
+ };
29286
+ }
29287
+ }
29288
+ }
29289
+ throw new ConnectionWaitTimeoutError(
29290
+ `Timed out waiting for the ${input.provider} connection to complete. The authorization may still land (or may have re-authorized an existing connection); check \`auto connections list --provider ${input.provider}\`, or re-run with --no-wait to skip waiting.`
29291
+ );
29292
+ }
29293
+
29224
29294
  // src/commands/connections/github.ts
29225
29295
  async function connectGithub(context, commandOptions) {
29226
29296
  const githubApi = createGithubConnectionApi(context);
@@ -29265,17 +29335,25 @@ async function connectGithub(context, commandOptions) {
29265
29335
  await startGithubInstallFlow(context, commandOptions);
29266
29336
  }
29267
29337
  async function startGithubInstallFlow(context, commandOptions) {
29268
- const result = await createConnectionServiceClient(context).startConnection(
29269
- "github",
29270
- {
29271
- allowProjectId: commandOptions.allow,
29272
- apiBaseUrl: commandOptions.apiBaseUrl
29273
- }
29274
- );
29338
+ const client = createConnectionServiceClient(context);
29339
+ const result = await client.startConnection("github", {
29340
+ allowProjectId: commandOptions.allow,
29341
+ apiBaseUrl: commandOptions.apiBaseUrl
29342
+ });
29275
29343
  context.writeOutput(result.message);
29276
- if (result.authorizationUrl) {
29277
- context.writeOutput(`authorization_url ${result.authorizationUrl}`);
29344
+ if (!result.authorizationUrl) {
29345
+ return;
29278
29346
  }
29347
+ context.writeOutput(`authorization_url ${result.authorizationUrl}`);
29348
+ await finishConnectionAuthorization({
29349
+ apiBaseUrl: commandOptions.apiBaseUrl,
29350
+ authorizationUrl: result.authorizationUrl,
29351
+ client,
29352
+ provider: "github",
29353
+ openInBrowser: commandOptions.browser !== false && context.io.isTTY,
29354
+ wait: commandOptions.wait !== false,
29355
+ writeOutput: context.writeOutput
29356
+ });
29279
29357
  }
29280
29358
  async function selectGithubInstallation(input) {
29281
29359
  if (input.selector) {
@@ -29559,27 +29637,40 @@ async function connectProviderAction(context, provider, commandOptions) {
29559
29637
  });
29560
29638
  return;
29561
29639
  }
29640
+ if (commandOptions.configRefreshToken && commandOptions.wait === false) {
29641
+ throw new Error(
29642
+ "--config-refresh-token registers the token once the connection completes; it cannot be combined with --no-wait."
29643
+ );
29644
+ }
29562
29645
  const client = createConnectionServiceClient(context);
29563
- const knownGrants = commandOptions.configRefreshToken ? await slackGrantNames(client, apiBaseUrl) : void 0;
29564
29646
  const result = await client.startConnection(provider, {
29565
29647
  allowProjectId: commandOptions.allow,
29566
29648
  apiBaseUrl
29567
29649
  });
29568
29650
  context.writeOutput(result.message);
29569
- if (result.authorizationUrl) {
29570
- context.writeOutput(`authorization_url ${result.authorizationUrl}`);
29651
+ if (!result.authorizationUrl) {
29652
+ return;
29571
29653
  }
29572
- if (commandOptions.configRefreshToken && knownGrants) {
29573
- context.writeOutput(
29574
- "Waiting for the Slack connection to complete before registering the config token..."
29575
- );
29576
- const connection = await waitForNewSlackGrant(
29577
- client,
29578
- apiBaseUrl,
29579
- knownGrants
29580
- );
29654
+ context.writeOutput(`authorization_url ${result.authorizationUrl}`);
29655
+ const connected = await finishConnectionAuthorization({
29656
+ apiBaseUrl,
29657
+ authorizationUrl: result.authorizationUrl,
29658
+ client,
29659
+ provider,
29660
+ openInBrowser: commandOptions.browser !== false && context.io.isTTY,
29661
+ wait: commandOptions.wait !== false,
29662
+ writeOutput: context.writeOutput
29663
+ }).catch((error51) => {
29664
+ if (error51 instanceof ConnectionWaitTimeoutError && commandOptions.configRefreshToken) {
29665
+ throw new Error(
29666
+ `${error51.message} Register the config token afterwards with \`auto connections config-token slack\`.`
29667
+ );
29668
+ }
29669
+ throw error51;
29670
+ });
29671
+ if (commandOptions.configRefreshToken && connected) {
29581
29672
  const registered = await client.registerSlackConfigToken({
29582
- connection,
29673
+ connection: connected.connection,
29583
29674
  refreshToken: commandOptions.configRefreshToken,
29584
29675
  apiBaseUrl
29585
29676
  });
@@ -29588,36 +29679,6 @@ async function connectProviderAction(context, provider, commandOptions) {
29588
29679
  );
29589
29680
  }
29590
29681
  }
29591
- var NEW_GRANT_POLL_INTERVAL_MS = 2e3;
29592
- var NEW_GRANT_POLL_TIMEOUT_MS = 5 * 6e4;
29593
- async function slackGrantNames(client, apiBaseUrl) {
29594
- const result = await client.listConnections({
29595
- provider: "slack",
29596
- apiBaseUrl
29597
- });
29598
- return new Set(
29599
- result.connections.flatMap(
29600
- (connection) => connection.grants.map((grant) => grant.name)
29601
- )
29602
- );
29603
- }
29604
- async function waitForNewSlackGrant(client, apiBaseUrl, knownGrants) {
29605
- const deadline = Date.now() + NEW_GRANT_POLL_TIMEOUT_MS;
29606
- while (Date.now() < deadline) {
29607
- await new Promise(
29608
- (resolve2) => setTimeout(resolve2, NEW_GRANT_POLL_INTERVAL_MS)
29609
- );
29610
- const current = await slackGrantNames(client, apiBaseUrl);
29611
- for (const name of current) {
29612
- if (!knownGrants.has(name)) {
29613
- return name;
29614
- }
29615
- }
29616
- }
29617
- throw new Error(
29618
- "Timed out waiting for the Slack connection to complete. Register the config token afterwards with `auto connections config-token slack`."
29619
- );
29620
- }
29621
29682
  async function registerConfigTokenAction(context, provider, commandOptions) {
29622
29683
  if (provider !== "slack") {
29623
29684
  throw new Error(
@@ -29684,21 +29745,30 @@ async function replaceConnectionAction(context, provider, commandOptions) {
29684
29745
  yes: commandOptions.yes
29685
29746
  });
29686
29747
  }
29687
- const result = await createConnectionServiceClient(context).startConnection(
29688
- provider,
29689
- {
29690
- allowProjectId: commandOptions.allow,
29691
- apiBaseUrl: apiUrlFromOptions(context, commandOptions),
29692
- replace: {
29693
- connection: commandOptions.connection,
29694
- removeFirst: commandOptions.removeFirst === true
29695
- }
29748
+ const apiBaseUrl = apiUrlFromOptions(context, commandOptions);
29749
+ const client = createConnectionServiceClient(context);
29750
+ const result = await client.startConnection(provider, {
29751
+ allowProjectId: commandOptions.allow,
29752
+ apiBaseUrl,
29753
+ replace: {
29754
+ connection: commandOptions.connection,
29755
+ removeFirst: commandOptions.removeFirst === true
29696
29756
  }
29697
- );
29757
+ });
29698
29758
  context.writeOutput(result.message);
29699
- if (result.authorizationUrl) {
29700
- context.writeOutput(`authorization_url ${result.authorizationUrl}`);
29759
+ if (!result.authorizationUrl) {
29760
+ return;
29701
29761
  }
29762
+ context.writeOutput(`authorization_url ${result.authorizationUrl}`);
29763
+ await finishConnectionAuthorization({
29764
+ apiBaseUrl,
29765
+ authorizationUrl: result.authorizationUrl,
29766
+ client,
29767
+ provider,
29768
+ openInBrowser: commandOptions.browser !== false && context.io.isTTY,
29769
+ wait: commandOptions.wait !== false,
29770
+ writeOutput: context.writeOutput
29771
+ });
29702
29772
  }
29703
29773
 
29704
29774
  // src/commands/connections/commands.ts
@@ -29725,7 +29795,10 @@ function registerConnectionCommands(program, context) {
29725
29795
  ).option(
29726
29796
  "--remove-first",
29727
29797
  "remove the old connection before the replacement authorization completes"
29728
- ).option("-y, --yes", "skip confirmation prompt when using --remove-first").option("--allow <project>", "project id to allow after connecting").option("--api-url <url>", "Auto API base URL").option("--api-base-url <url>", "Auto API base URL").action(async (provider, commandOptions) => {
29798
+ ).option("-y, --yes", "skip confirmation prompt when using --remove-first").option("--allow <project>", "project id to allow after connecting").option(
29799
+ "--no-wait",
29800
+ "print the authorization URL and exit without waiting for the replacement to complete"
29801
+ ).option("--no-browser", "do not open the authorization URL in a browser").option("--api-url <url>", "Auto API base URL").option("--api-base-url <url>", "Auto API base URL").action(async (provider, commandOptions) => {
29729
29802
  await replaceConnectionAction(context, provider, commandOptions);
29730
29803
  });
29731
29804
  program.command("connect").description("Start a provider connection flow.").argument("<provider>", "provider name").option("--allow <project>", "project id to allow after connecting").option(
@@ -29746,7 +29819,10 @@ function registerConnectionCommands(program, context) {
29746
29819
  ).option(
29747
29820
  "--manual",
29748
29821
  "print the setup steps instead of the interactive wizard (telegram only)"
29749
- ).option("--api-url <url>", "Auto API base URL").option("--api-base-url <url>", "Auto API base URL").action(async (provider, commandOptions) => {
29822
+ ).option(
29823
+ "--no-wait",
29824
+ "print the authorization URL and exit without waiting for the connection to complete"
29825
+ ).option("--no-browser", "do not open the authorization URL in a browser").option("--api-url <url>", "Auto API base URL").option("--api-base-url <url>", "Auto API base URL").action(async (provider, commandOptions) => {
29750
29826
  await connectProviderAction(context, provider, commandOptions);
29751
29827
  });
29752
29828
  program.command("allow").description("Allow a project to use an existing provider connection.").argument("<provider>", "provider name").argument("<project>", "project id").option("--connection <name>", "specific connection or grant name").option("--api-url <url>", "Auto API base URL").option("--api-base-url <url>", "Auto API base URL").action(
@@ -29762,15 +29838,9 @@ function registerConnectionCommands(program, context) {
29762
29838
  }
29763
29839
 
29764
29840
  // src/commands/delete/actions.ts
29765
- init_src();
29766
- var RESOURCE_KINDS = [
29767
- RESOURCE_KIND_ENVIRONMENT,
29768
- RESOURCE_KIND_PROFILE,
29769
- RESOURCE_KIND_TOOL,
29770
- RESOURCE_KIND_SESSION
29771
- ];
29841
+ init_resources3();
29772
29842
  async function deleteResource(input) {
29773
- const request = parseDeleteResource(input.resource);
29843
+ const request = parseProjectResourceReference(input.resource);
29774
29844
  const response = await input.client.deleteProjectResource(request, {
29775
29845
  apiBaseUrl: input.commandOptions.apiBaseUrl
29776
29846
  });
@@ -29782,18 +29852,6 @@ async function deleteResource(input) {
29782
29852
  `deleted ${response.deleted.kind}/${response.deleted.name}`
29783
29853
  );
29784
29854
  }
29785
- function parseDeleteResource(resource) {
29786
- const [kind, name, extra] = resource.split("/");
29787
- if (!kind || !name || extra) {
29788
- throw new Error('Resource must be formatted as "kind/name"');
29789
- }
29790
- if (!RESOURCE_KINDS.includes(kind)) {
29791
- throw new Error(
29792
- `Unsupported resource kind "${kind}"; supported kinds are ${RESOURCE_KINDS.map((value) => `"${value}"`).join(", ")}`
29793
- );
29794
- }
29795
- return { kind, name };
29796
- }
29797
29855
 
29798
29856
  // src/commands/delete/commands.ts
29799
29857
  function registerDeleteCommands(program, context) {
@@ -29815,55 +29873,15 @@ function registerDeleteCommands(program, context) {
29815
29873
  }
29816
29874
 
29817
29875
  // src/commands/describe/actions.ts
29818
- init_src();
29876
+ init_resources3();
29819
29877
  import { stringify } from "yaml";
29820
- var RESOURCE_KINDS2 = [
29821
- RESOURCE_KIND_ENVIRONMENT,
29822
- RESOURCE_KIND_PROFILE,
29823
- RESOURCE_KIND_TOOL,
29824
- RESOURCE_KIND_SESSION
29825
- ];
29826
29878
  async function inspectResource(input) {
29827
- const request = parseInspectResource(input.resource);
29828
- const resource = await getResource(input.client, request, {
29879
+ const request = parseProjectResourceReference(input.resource);
29880
+ const resource = await requireProjectResource(input.client, request, {
29829
29881
  apiBaseUrl: input.commandOptions.apiBaseUrl
29830
29882
  });
29831
29883
  input.writeOutput(stringify(resource.spec).trimEnd());
29832
29884
  }
29833
- function parseInspectResource(resource) {
29834
- const [kind, name, extra] = resource.split("/");
29835
- if (!kind || !name || extra) {
29836
- throw new Error('Resource must be formatted as "kind/name"');
29837
- }
29838
- if (!RESOURCE_KINDS2.includes(kind)) {
29839
- throw new Error(
29840
- `Unsupported resource kind "${kind}"; supported kinds are ${RESOURCE_KINDS2.map((value) => `"${value}"`).join(", ")}`
29841
- );
29842
- }
29843
- return { kind, name };
29844
- }
29845
- async function getResource(client, request, options) {
29846
- const resources = await listResources(client, request.kind, options);
29847
- const resource = resources.find(
29848
- (item) => item.metadata.name === request.name
29849
- );
29850
- if (!resource) {
29851
- throw new Error(`Resource not found: ${request.kind}/${request.name}`);
29852
- }
29853
- return resource;
29854
- }
29855
- async function listResources(client, kind, options) {
29856
- switch (kind) {
29857
- case RESOURCE_KIND_ENVIRONMENT:
29858
- return (await client.listEnvironments(options)).environments;
29859
- case RESOURCE_KIND_PROFILE:
29860
- return (await client.listProfiles(options)).profiles;
29861
- case RESOURCE_KIND_TOOL:
29862
- return (await client.listTools(options)).tools;
29863
- case RESOURCE_KIND_SESSION:
29864
- return (await client.listSessions(options)).sessions;
29865
- }
29866
- }
29867
29885
 
29868
29886
  // src/commands/describe/commands.ts
29869
29887
  function registerDescribeCommands(program, context) {
@@ -31070,7 +31088,7 @@ function formatToolsText(result, writeLine) {
31070
31088
  }
31071
31089
  for (const exchange of result.exchanges) {
31072
31090
  const duration4 = exchange.durationMs === null ? "-" : `${exchange.durationMs}ms`;
31073
- const outcome = exchange.isError === null ? "pending" : exchange.isError ? "ERR" : "ok";
31091
+ const outcome = exchangeOutcome(exchange.isError);
31074
31092
  writeLine(
31075
31093
  `${exchange.callSequence} ${exchange.name} ${duration4} ${outcome}: ${preview(exchange.input)}`
31076
31094
  );
@@ -31081,6 +31099,12 @@ function formatToolsText(result, writeLine) {
31081
31099
  );
31082
31100
  }
31083
31101
  }
31102
+ function exchangeOutcome(isError) {
31103
+ if (isError === null) {
31104
+ return "pending";
31105
+ }
31106
+ return isError ? "ERR" : "ok";
31107
+ }
31084
31108
  async function handleRunsTriggers(context, runId, options = {}) {
31085
31109
  const client = createContextApiClient(context);
31086
31110
  const response = await client.listRunTriggers(runId, {
@@ -31644,8 +31668,8 @@ init_browser();
31644
31668
  import { existsSync as existsSync2, mkdtempSync as mkdtempSync2, writeFileSync as writeFileSync4 } from "fs";
31645
31669
  import { homedir as homedir3, tmpdir as tmpdir2 } from "os";
31646
31670
  import { join as join6 } from "path";
31647
- var POLL_INTERVAL_MS = 2e3;
31648
- var POLL_TIMEOUT_MS = 5 * 6e4;
31671
+ var POLL_INTERVAL_MS2 = 2e3;
31672
+ var POLL_TIMEOUT_MS2 = 5 * 6e4;
31649
31673
  var SLACK_APPS_URL = "https://api.slack.com/apps";
31650
31674
  async function connectSessionPresence2(input) {
31651
31675
  const options = { apiBaseUrl: input.apiBaseUrl };
@@ -31694,8 +31718,8 @@ async function connectSessionPresence2(input) {
31694
31718
  const sleep3 = input.sleep ?? ((ms) => new Promise((resolve2) => setTimeout(resolve2, ms)));
31695
31719
  const openBrowser2 = input.openBrowser ?? openBrowser;
31696
31720
  const now3 = input.now ?? Date.now;
31697
- const pollIntervalMs = input.pollIntervalMs ?? POLL_INTERVAL_MS;
31698
- const pollTimeoutMs = input.pollTimeoutMs ?? POLL_TIMEOUT_MS;
31721
+ const pollIntervalMs = input.pollIntervalMs ?? POLL_INTERVAL_MS2;
31722
+ const pollTimeoutMs = input.pollTimeoutMs ?? POLL_TIMEOUT_MS2;
31699
31723
  for (const pending of result.pending) {
31700
31724
  const telegram = Boolean(pending.suggestedUsername);
31701
31725
  input.writeOutput(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.100",
3
+ "version": "0.1.102",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"