@autohq/cli 0.1.129 → 0.1.131

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/index.js CHANGED
@@ -16052,7 +16052,7 @@ var init_zod = __esm({
16052
16052
  });
16053
16053
 
16054
16054
  // ../../packages/schemas/src/ids.ts
16055
- var OpaqueIdSchema, ProfileIdSchema, EnvironmentIdSchema, ConnectionIdSchema, ExternalAccountIdSchema, OrganizationIdSchema, ProjectIdSchema, ProviderGrantIdSchema, ServiceAccountIdSchema, SessionIdSchema, SessionRunIdSchema, SessionRunCommandIdSchema, RuntimeIdSchema, RuntimeBridgeLeaseIdSchema, EnvironmentSetupSnapshotIdSchema, ToolIdSchema, UserIdSchema;
16055
+ var OpaqueIdSchema, ProfileIdSchema, EnvironmentIdSchema, IdentityIdSchema, ConnectionIdSchema, ExternalAccountIdSchema, OrganizationIdSchema, ProjectIdSchema, ProviderGrantIdSchema, ServiceAccountIdSchema, SessionIdSchema, SessionRunIdSchema, SessionRunCommandIdSchema, RuntimeIdSchema, RuntimeBridgeLeaseIdSchema, EnvironmentSetupSnapshotIdSchema, ToolIdSchema, UserIdSchema;
16056
16056
  var init_ids = __esm({
16057
16057
  "../../packages/schemas/src/ids.ts"() {
16058
16058
  "use strict";
@@ -16060,6 +16060,7 @@ var init_ids = __esm({
16060
16060
  OpaqueIdSchema = external_exports.string().trim().min(1);
16061
16061
  ProfileIdSchema = OpaqueIdSchema.brand();
16062
16062
  EnvironmentIdSchema = OpaqueIdSchema.brand();
16063
+ IdentityIdSchema = OpaqueIdSchema.brand();
16063
16064
  ConnectionIdSchema = OpaqueIdSchema.brand();
16064
16065
  ExternalAccountIdSchema = OpaqueIdSchema.brand();
16065
16066
  OrganizationIdSchema = OpaqueIdSchema.brand();
@@ -17431,193 +17432,6 @@ var init_github_mcp_catalog = __esm({
17431
17432
  }
17432
17433
  });
17433
17434
 
17434
- // ../../packages/schemas/src/secrets.ts
17435
- var SECRET_ENCRYPTION_ALGORITHM, SecretEnvNameSchema, SecretCiphertextFieldSchema, SecretAesGcmIvSchema, SecretAesGcmAuthTagSchema, SecretEnvValueSchema, SecretEnvSchema, EncryptedSecretValueSchema, SecretSetRequestSchema, SecretMetadataSchema, SecretSetResponseSchema, SecretListResponseSchema, SecretDeleteResponseSchema;
17436
- var init_secrets = __esm({
17437
- "../../packages/schemas/src/secrets.ts"() {
17438
- "use strict";
17439
- init_zod();
17440
- init_resources();
17441
- SECRET_ENCRYPTION_ALGORITHM = "AES-256-GCM";
17442
- SecretEnvNameSchema = external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/);
17443
- SecretCiphertextFieldSchema = external_exports.string().trim().min(1).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/);
17444
- SecretAesGcmIvSchema = external_exports.string().trim().regex(/^[A-Za-z0-9+/]{16}$/);
17445
- SecretAesGcmAuthTagSchema = external_exports.string().trim().regex(/^[A-Za-z0-9+/]{22}==$/);
17446
- SecretEnvValueSchema = external_exports.union([
17447
- external_exports.string(),
17448
- external_exports.object({
17449
- $secret: ResourceNameSchema,
17450
- optional: external_exports.boolean().optional()
17451
- })
17452
- ]);
17453
- SecretEnvSchema = external_exports.record(
17454
- SecretEnvNameSchema,
17455
- SecretEnvValueSchema
17456
- );
17457
- EncryptedSecretValueSchema = external_exports.object({
17458
- keyVersion: external_exports.string().trim().min(1),
17459
- algorithm: external_exports.literal(SECRET_ENCRYPTION_ALGORITHM),
17460
- ciphertext: SecretCiphertextFieldSchema,
17461
- valueIv: SecretAesGcmIvSchema,
17462
- valueAuthTag: SecretAesGcmAuthTagSchema,
17463
- encryptedDek: SecretCiphertextFieldSchema,
17464
- dekIv: SecretAesGcmIvSchema,
17465
- dekAuthTag: SecretAesGcmAuthTagSchema
17466
- });
17467
- SecretSetRequestSchema = external_exports.object({
17468
- value: external_exports.string()
17469
- });
17470
- SecretMetadataSchema = external_exports.object({
17471
- id: external_exports.string().trim().min(1),
17472
- organizationId: external_exports.string().trim().min(1),
17473
- projectId: external_exports.string().trim().min(1).nullable(),
17474
- name: ResourceNameSchema,
17475
- createdAt: external_exports.string().datetime(),
17476
- updatedAt: external_exports.string().datetime()
17477
- });
17478
- SecretSetResponseSchema = external_exports.object({
17479
- secret: SecretMetadataSchema
17480
- });
17481
- SecretListResponseSchema = external_exports.object({
17482
- secrets: external_exports.array(SecretMetadataSchema)
17483
- });
17484
- SecretDeleteResponseSchema = external_exports.object({
17485
- secret: SecretMetadataSchema
17486
- });
17487
- }
17488
- });
17489
-
17490
- // ../../packages/schemas/src/environments.ts
17491
- function environmentSetupSchema(cachePathSchema) {
17492
- return external_exports.object({
17493
- name: ResourceNameSchema,
17494
- commands: external_exports.array(external_exports.string().trim().min(1)).min(1),
17495
- cache: external_exports.object({
17496
- key: ResourceNameSchema.optional(),
17497
- files: external_exports.array(
17498
- external_exports.string().trim().refine(isSafeRelativePath, {
17499
- message: "Expected a relative path without traversal"
17500
- })
17501
- ).default([]),
17502
- paths: external_exports.array(cachePathSchema).default([])
17503
- }).strict().default({ files: [], paths: [] })
17504
- }).strict();
17505
- }
17506
- function environmentSpecSchema(setupSchema) {
17507
- return external_exports.object({
17508
- image: EnvironmentImageSchema,
17509
- env: SecretEnvSchema.default({}),
17510
- resources: EnvironmentResourcesSchema.optional(),
17511
- steps: external_exports.array(external_exports.string()).default([]),
17512
- setup: external_exports.array(setupSchema).default([]),
17513
- setupCache: EnvironmentSetupCacheSchema.optional()
17514
- }).strict();
17515
- }
17516
- function isSafeSandboxUserHomePath(value, options = {}) {
17517
- return (options.allowedHomes ?? [CURRENT_SANDBOX_USER_HOME]).some(
17518
- (home) => isSafePathUnderHome(value, home)
17519
- );
17520
- }
17521
- function isSafePathUnderHome(value, home) {
17522
- const prefix = `${home}/`;
17523
- if (!value.startsWith(prefix)) {
17524
- return false;
17525
- }
17526
- const relative = value.slice(prefix.length);
17527
- return relative.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
17528
- }
17529
- function isSafeRelativePath(value) {
17530
- if (!value || value.startsWith("/")) {
17531
- return false;
17532
- }
17533
- return value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
17534
- }
17535
- function isSetupCacheTtl(value) {
17536
- return /^[1-9][0-9]*(s|m|h|d)$/.test(value);
17537
- }
17538
- var RESOURCE_KIND_ENVIRONMENT, CURRENT_SANDBOX_USER_HOME, LEGACY_SANDBOX_USER_HOMES, STORED_SANDBOX_USER_HOMES, EnvironmentSetupCachePathSchema, StoredEnvironmentSetupCachePathSchema, EnvironmentImageSchema, EnvironmentSetupSchema, EnvironmentApplySetupSchema, EnvironmentSetupCacheSchema, EnvironmentResourcesSchema, EnvironmentSpecSchema, EnvironmentApplySpecSchema, EnvironmentResourceSchema, EnvironmentApplyRequestSchema;
17539
- var init_environments = __esm({
17540
- "../../packages/schemas/src/environments.ts"() {
17541
- "use strict";
17542
- init_zod();
17543
- init_resources();
17544
- init_secrets();
17545
- RESOURCE_KIND_ENVIRONMENT = "environment";
17546
- CURRENT_SANDBOX_USER_HOME = "/home/user";
17547
- LEGACY_SANDBOX_USER_HOMES = ["/home/auto", "/home/node"];
17548
- STORED_SANDBOX_USER_HOMES = [
17549
- CURRENT_SANDBOX_USER_HOME,
17550
- ...LEGACY_SANDBOX_USER_HOMES
17551
- ];
17552
- EnvironmentSetupCachePathSchema = external_exports.string().trim().refine((value) => isSafeSandboxUserHomePath(value), {
17553
- message: `Expected an absolute path under ${CURRENT_SANDBOX_USER_HOME}`
17554
- });
17555
- StoredEnvironmentSetupCachePathSchema = external_exports.string().trim().refine(
17556
- (value) => isSafeSandboxUserHomePath(value, {
17557
- allowedHomes: STORED_SANDBOX_USER_HOMES
17558
- }),
17559
- {
17560
- message: `Expected an absolute path under ${CURRENT_SANDBOX_USER_HOME}`
17561
- }
17562
- );
17563
- EnvironmentImageSchema = external_exports.object({
17564
- kind: external_exports.literal("preset"),
17565
- name: ResourceNameSchema
17566
- }).strict();
17567
- EnvironmentSetupSchema = environmentSetupSchema(
17568
- StoredEnvironmentSetupCachePathSchema
17569
- );
17570
- EnvironmentApplySetupSchema = environmentSetupSchema(
17571
- EnvironmentSetupCachePathSchema
17572
- );
17573
- EnvironmentSetupCacheSchema = external_exports.object({
17574
- ttl: external_exports.string().trim().refine(isSetupCacheTtl, {
17575
- message: "Expected a positive setup cache TTL such as 30m, 24h, or 7d"
17576
- })
17577
- }).strict();
17578
- EnvironmentResourcesSchema = external_exports.object({
17579
- cpuCount: external_exports.number().int().min(1).optional(),
17580
- memoryMB: external_exports.number().int().min(128).optional()
17581
- }).strict().refine(
17582
- (resources) => resources.cpuCount !== void 0 || resources.memoryMB !== void 0,
17583
- {
17584
- message: "Expected at least one runtime resource setting"
17585
- }
17586
- );
17587
- EnvironmentSpecSchema = environmentSpecSchema(
17588
- EnvironmentSetupSchema
17589
- );
17590
- EnvironmentApplySpecSchema = environmentSpecSchema(
17591
- EnvironmentApplySetupSchema
17592
- );
17593
- EnvironmentResourceSchema = resourceEnvelopeSchema(
17594
- EnvironmentSpecSchema
17595
- );
17596
- EnvironmentApplyRequestSchema = resourceApplySchema(
17597
- EnvironmentApplySpecSchema
17598
- );
17599
- }
17600
- });
17601
-
17602
- // ../../packages/schemas/src/mcp.ts
17603
- var McpToolCallMessageSchema, McpJsonRpcMessageSchema, McpPostBodySchema;
17604
- var init_mcp = __esm({
17605
- "../../packages/schemas/src/mcp.ts"() {
17606
- "use strict";
17607
- init_zod();
17608
- McpToolCallMessageSchema = external_exports.object({
17609
- method: external_exports.literal("tools/call"),
17610
- params: external_exports.object({
17611
- name: external_exports.string().trim().min(1)
17612
- })
17613
- });
17614
- McpJsonRpcMessageSchema = external_exports.object({
17615
- method: external_exports.string().optional()
17616
- }).passthrough();
17617
- McpPostBodySchema = external_exports.union([McpJsonRpcMessageSchema, external_exports.array(McpJsonRpcMessageSchema)]).transform((body) => Array.isArray(body) ? body : [body]);
17618
- }
17619
- });
17620
-
17621
17435
  // ../../packages/schemas/src/mounts.ts
17622
17436
  var AbsoluteMountPathSchema, GITHUB_MOUNT_CAPABILITY_LEVELS, GithubMountCapabilityLevelSchema, GITHUB_MOUNT_MERGE_CAPABILITY_LEVELS, GithubMountMergeCapabilityLevelSchema, DEFAULT_GITHUB_MOUNT_CAPABILITIES, GitMountAuthSchema, GitMountSchema, SessionMountSchema;
17623
17437
  var init_mounts = __esm({
@@ -17696,43 +17510,58 @@ var init_mounts = __esm({
17696
17510
  }
17697
17511
  });
17698
17512
 
17699
- // ../../packages/schemas/src/project-service-accounts.ts
17700
- var ProjectServiceAccountSchema, ProjectServiceAccountCreateRequestSchema, ProjectServiceAccountUpdateRequestSchema, ProjectServiceAccountTokenResponseSchema, ProjectServiceAccountUpdateResponseSchema, ProjectServiceAccountRemoveResponseSchema, ProjectServiceAccountListResponseSchema;
17701
- var init_project_service_accounts = __esm({
17702
- "../../packages/schemas/src/project-service-accounts.ts"() {
17513
+ // ../../packages/schemas/src/secrets.ts
17514
+ var SECRET_ENCRYPTION_ALGORITHM, SecretEnvNameSchema, SecretCiphertextFieldSchema, SecretAesGcmIvSchema, SecretAesGcmAuthTagSchema, SecretEnvValueSchema, SecretEnvSchema, EncryptedSecretValueSchema, SecretSetRequestSchema, SecretMetadataSchema, SecretSetResponseSchema, SecretListResponseSchema, SecretDeleteResponseSchema;
17515
+ var init_secrets = __esm({
17516
+ "../../packages/schemas/src/secrets.ts"() {
17703
17517
  "use strict";
17704
17518
  init_zod();
17705
- init_auth();
17706
- init_ids();
17707
17519
  init_resources();
17708
- ProjectServiceAccountSchema = external_exports.object({
17709
- id: ServiceAccountIdSchema,
17710
- organizationId: OrganizationIdSchema,
17711
- projectId: ProjectIdSchema,
17712
- name: ResourceNameSchema,
17713
- scopes: external_exports.array(AuthScopeSchema),
17714
- createdAt: external_exports.string().datetime()
17715
- });
17716
- ProjectServiceAccountCreateRequestSchema = external_exports.object({
17717
- name: ResourceNameSchema,
17718
- scopes: external_exports.array(AuthScopeSchema).min(1)
17520
+ SECRET_ENCRYPTION_ALGORITHM = "AES-256-GCM";
17521
+ SecretEnvNameSchema = external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/);
17522
+ SecretCiphertextFieldSchema = external_exports.string().trim().min(1).regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/);
17523
+ SecretAesGcmIvSchema = external_exports.string().trim().regex(/^[A-Za-z0-9+/]{16}$/);
17524
+ SecretAesGcmAuthTagSchema = external_exports.string().trim().regex(/^[A-Za-z0-9+/]{22}==$/);
17525
+ SecretEnvValueSchema = external_exports.union([
17526
+ external_exports.string(),
17527
+ external_exports.object({
17528
+ $secret: ResourceNameSchema,
17529
+ optional: external_exports.boolean().optional()
17530
+ })
17531
+ ]);
17532
+ SecretEnvSchema = external_exports.record(
17533
+ SecretEnvNameSchema,
17534
+ SecretEnvValueSchema
17535
+ );
17536
+ EncryptedSecretValueSchema = external_exports.object({
17537
+ keyVersion: external_exports.string().trim().min(1),
17538
+ algorithm: external_exports.literal(SECRET_ENCRYPTION_ALGORITHM),
17539
+ ciphertext: SecretCiphertextFieldSchema,
17540
+ valueIv: SecretAesGcmIvSchema,
17541
+ valueAuthTag: SecretAesGcmAuthTagSchema,
17542
+ encryptedDek: SecretCiphertextFieldSchema,
17543
+ dekIv: SecretAesGcmIvSchema,
17544
+ dekAuthTag: SecretAesGcmAuthTagSchema
17719
17545
  });
17720
- ProjectServiceAccountUpdateRequestSchema = external_exports.object({
17721
- scopes: external_exports.array(AuthScopeSchema).min(1)
17546
+ SecretSetRequestSchema = external_exports.object({
17547
+ value: external_exports.string()
17722
17548
  });
17723
- ProjectServiceAccountTokenResponseSchema = external_exports.object({
17724
- serviceAccount: ProjectServiceAccountSchema,
17725
- token: external_exports.string().min(1)
17549
+ SecretMetadataSchema = external_exports.object({
17550
+ id: external_exports.string().trim().min(1),
17551
+ organizationId: external_exports.string().trim().min(1),
17552
+ projectId: external_exports.string().trim().min(1).nullable(),
17553
+ name: ResourceNameSchema,
17554
+ createdAt: external_exports.string().datetime(),
17555
+ updatedAt: external_exports.string().datetime()
17726
17556
  });
17727
- ProjectServiceAccountUpdateResponseSchema = external_exports.object({
17728
- serviceAccount: ProjectServiceAccountSchema
17557
+ SecretSetResponseSchema = external_exports.object({
17558
+ secret: SecretMetadataSchema
17729
17559
  });
17730
- ProjectServiceAccountRemoveResponseSchema = external_exports.object({
17731
- serviceAccount: ProjectServiceAccountSchema,
17732
- removed: external_exports.literal(true)
17560
+ SecretListResponseSchema = external_exports.object({
17561
+ secrets: external_exports.array(SecretMetadataSchema)
17733
17562
  });
17734
- ProjectServiceAccountListResponseSchema = external_exports.object({
17735
- serviceAccounts: external_exports.array(ProjectServiceAccountSchema)
17563
+ SecretDeleteResponseSchema = external_exports.object({
17564
+ secret: SecretMetadataSchema
17736
17565
  });
17737
17566
  }
17738
17567
  });
@@ -17774,7 +17603,7 @@ function remoteMcpToolSchema(input) {
17774
17603
  ]).default({ kind: "none" })
17775
17604
  });
17776
17605
  }
17777
- var RESOURCE_KIND_TOOL, REMOTE_MCP_TRANSPORTS, LOCAL_TOOL_IMPLEMENTATIONS, SecretReferenceSchema, NoToolAuthSchema, McpOAuthToolAuthSchema, ConnectionToolAuthSchema, ConnectionsToolAuthSchema, ToolAliasSchema, RemoteMcpToolSchema, LocalAutoToolSchema, LocalPingToolSchema, LocalChatToolSchema, LocalToolSchema, GithubToolSchema, ToolSpecSchema, ToolResourceSchema, ToolApplyRequestSchema, ToolConnectRequestSchema, ToolConnectResponseSchema, ToolConnectCompleteResponseSchema, ReferencedSessionToolRefSchema, ReferencedSessionToolRefsSchema, InlineSessionToolSchema, SessionToolRefSchema, SessionToolsSchema;
17606
+ var REMOTE_MCP_TRANSPORTS, LOCAL_TOOL_IMPLEMENTATIONS, SecretReferenceSchema, NoToolAuthSchema, McpOAuthToolAuthSchema, ConnectionToolAuthSchema, ConnectionsToolAuthSchema, ToolAliasSchema, RemoteMcpToolSchema, LocalAutoToolSchema, LocalPingToolSchema, LocalChatToolSchema, LocalToolSchema, GithubToolSchema, ToolSpecSchema, ToolResourceSchema, ToolApplyRequestSchema, ToolConnectRequestSchema, ToolConnectResponseSchema, ToolConnectCompleteResponseSchema, InlineSessionToolSchema, SessionToolRefSchema, SessionToolsSchema;
17778
17607
  var init_tools = __esm({
17779
17608
  "../../packages/schemas/src/tools.ts"() {
17780
17609
  "use strict";
@@ -17783,7 +17612,6 @@ var init_tools = __esm({
17783
17612
  init_github_mcp_catalog();
17784
17613
  init_ids();
17785
17614
  init_resources();
17786
- RESOURCE_KIND_TOOL = "tool";
17787
17615
  REMOTE_MCP_TRANSPORTS = ["streamable_http"];
17788
17616
  LOCAL_TOOL_IMPLEMENTATIONS = ["auto", "chat", "ping"];
17789
17617
  SecretReferenceSchema = external_exports.object({
@@ -17878,12 +17706,6 @@ var init_tools = __esm({
17878
17706
  connection: ResourceNameSchema,
17879
17707
  projectId: ProjectIdSchema
17880
17708
  });
17881
- ReferencedSessionToolRefSchema = external_exports.object({
17882
- ref: ResourceNameSchema
17883
- }).strict();
17884
- ReferencedSessionToolRefsSchema = external_exports.object({
17885
- refs: external_exports.array(ResourceNameSchema).min(1)
17886
- }).strict();
17887
17709
  InlineSessionToolSchema = RemoteMcpToolSchema.extend({
17888
17710
  disabled: external_exports.boolean().optional()
17889
17711
  }).or(
@@ -17897,9 +17719,7 @@ var init_tools = __esm({
17897
17719
  disabled: external_exports.boolean().optional()
17898
17720
  })
17899
17721
  );
17900
- SessionToolRefSchema = InlineSessionToolSchema.or(
17901
- ReferencedSessionToolRefSchema
17902
- ).or(ReferencedSessionToolRefsSchema);
17722
+ SessionToolRefSchema = InlineSessionToolSchema;
17903
17723
  SessionToolsSchema = external_exports.record(
17904
17724
  ToolAliasSchema,
17905
17725
  SessionToolRefSchema
@@ -18436,13 +18256,13 @@ var init_sessions = __esm({
18436
18256
  }
18437
18257
  ).optional()
18438
18258
  }).strict().refine((identity2) => Object.keys(identity2).length > 0, {
18439
- message: "Session identity requires at least one field"
18259
+ message: "Identity requires at least one field"
18440
18260
  });
18441
18261
  SessionSpecFieldsSchema = external_exports.object({
18442
18262
  harness: external_exports.enum(SESSION_HARNESSES).optional(),
18443
18263
  systemPrompt: external_exports.string().trim().min(1).max(1e5).optional(),
18444
18264
  environment: ResourceNameSchema.optional(),
18445
- identity: SessionIdentitySchema.optional(),
18265
+ identity: external_exports.union([ResourceNameSchema, SessionIdentitySchema]).optional(),
18446
18266
  initialPrompt: external_exports.string().trim().min(1).max(2e4).optional(),
18447
18267
  env: SecretEnvSchema.default({}),
18448
18268
  mounts: external_exports.array(SessionMountSchema).default([]),
@@ -18578,23 +18398,209 @@ var init_sessions = __esm({
18578
18398
  }
18579
18399
  });
18580
18400
 
18401
+ // ../../packages/schemas/src/identities.ts
18402
+ var RESOURCE_KIND_IDENTITY, IdentitySpecSchema, IdentityResourceSchema, IdentityApplyRequestSchema;
18403
+ var init_identities = __esm({
18404
+ "../../packages/schemas/src/identities.ts"() {
18405
+ "use strict";
18406
+ init_resources();
18407
+ init_sessions();
18408
+ RESOURCE_KIND_IDENTITY = "identity";
18409
+ IdentitySpecSchema = SessionIdentitySchema;
18410
+ IdentityResourceSchema = resourceEnvelopeSchema(IdentitySpecSchema);
18411
+ IdentityApplyRequestSchema = resourceApplySchema(IdentitySpecSchema);
18412
+ }
18413
+ });
18414
+
18415
+ // ../../packages/schemas/src/environments.ts
18416
+ function environmentSetupSchema(cachePathSchema) {
18417
+ return external_exports.object({
18418
+ name: ResourceNameSchema,
18419
+ commands: external_exports.array(external_exports.string().trim().min(1)).min(1),
18420
+ cache: external_exports.object({
18421
+ key: ResourceNameSchema.optional(),
18422
+ files: external_exports.array(
18423
+ external_exports.string().trim().refine(isSafeRelativePath, {
18424
+ message: "Expected a relative path without traversal"
18425
+ })
18426
+ ).default([]),
18427
+ paths: external_exports.array(cachePathSchema).default([])
18428
+ }).strict().default({ files: [], paths: [] })
18429
+ }).strict();
18430
+ }
18431
+ function environmentSpecSchema(setupSchema) {
18432
+ return external_exports.object({
18433
+ image: EnvironmentImageSchema,
18434
+ env: SecretEnvSchema.default({}),
18435
+ resources: EnvironmentResourcesSchema.optional(),
18436
+ steps: external_exports.array(external_exports.string()).default([]),
18437
+ setup: external_exports.array(setupSchema).default([]),
18438
+ setupCache: EnvironmentSetupCacheSchema.optional()
18439
+ }).strict();
18440
+ }
18441
+ function isSafeSandboxUserHomePath(value, options = {}) {
18442
+ return (options.allowedHomes ?? [CURRENT_SANDBOX_USER_HOME]).some(
18443
+ (home) => isSafePathUnderHome(value, home)
18444
+ );
18445
+ }
18446
+ function isSafePathUnderHome(value, home) {
18447
+ const prefix = `${home}/`;
18448
+ if (!value.startsWith(prefix)) {
18449
+ return false;
18450
+ }
18451
+ const relative = value.slice(prefix.length);
18452
+ return relative.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
18453
+ }
18454
+ function isSafeRelativePath(value) {
18455
+ if (!value || value.startsWith("/")) {
18456
+ return false;
18457
+ }
18458
+ return value.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
18459
+ }
18460
+ function isSetupCacheTtl(value) {
18461
+ return /^[1-9][0-9]*(s|m|h|d)$/.test(value);
18462
+ }
18463
+ var RESOURCE_KIND_ENVIRONMENT, CURRENT_SANDBOX_USER_HOME, LEGACY_SANDBOX_USER_HOMES, STORED_SANDBOX_USER_HOMES, EnvironmentSetupCachePathSchema, StoredEnvironmentSetupCachePathSchema, EnvironmentImageSchema, EnvironmentSetupSchema, EnvironmentApplySetupSchema, EnvironmentSetupCacheSchema, EnvironmentResourcesSchema, EnvironmentSpecSchema, EnvironmentApplySpecSchema, EnvironmentResourceSchema, EnvironmentApplyRequestSchema;
18464
+ var init_environments = __esm({
18465
+ "../../packages/schemas/src/environments.ts"() {
18466
+ "use strict";
18467
+ init_zod();
18468
+ init_resources();
18469
+ init_secrets();
18470
+ RESOURCE_KIND_ENVIRONMENT = "environment";
18471
+ CURRENT_SANDBOX_USER_HOME = "/home/user";
18472
+ LEGACY_SANDBOX_USER_HOMES = ["/home/auto", "/home/node"];
18473
+ STORED_SANDBOX_USER_HOMES = [
18474
+ CURRENT_SANDBOX_USER_HOME,
18475
+ ...LEGACY_SANDBOX_USER_HOMES
18476
+ ];
18477
+ EnvironmentSetupCachePathSchema = external_exports.string().trim().refine((value) => isSafeSandboxUserHomePath(value), {
18478
+ message: `Expected an absolute path under ${CURRENT_SANDBOX_USER_HOME}`
18479
+ });
18480
+ StoredEnvironmentSetupCachePathSchema = external_exports.string().trim().refine(
18481
+ (value) => isSafeSandboxUserHomePath(value, {
18482
+ allowedHomes: STORED_SANDBOX_USER_HOMES
18483
+ }),
18484
+ {
18485
+ message: `Expected an absolute path under ${CURRENT_SANDBOX_USER_HOME}`
18486
+ }
18487
+ );
18488
+ EnvironmentImageSchema = external_exports.object({
18489
+ kind: external_exports.literal("preset"),
18490
+ name: ResourceNameSchema
18491
+ }).strict();
18492
+ EnvironmentSetupSchema = environmentSetupSchema(
18493
+ StoredEnvironmentSetupCachePathSchema
18494
+ );
18495
+ EnvironmentApplySetupSchema = environmentSetupSchema(
18496
+ EnvironmentSetupCachePathSchema
18497
+ );
18498
+ EnvironmentSetupCacheSchema = external_exports.object({
18499
+ ttl: external_exports.string().trim().refine(isSetupCacheTtl, {
18500
+ message: "Expected a positive setup cache TTL such as 30m, 24h, or 7d"
18501
+ })
18502
+ }).strict();
18503
+ EnvironmentResourcesSchema = external_exports.object({
18504
+ cpuCount: external_exports.number().int().min(1).optional(),
18505
+ memoryMB: external_exports.number().int().min(128).optional()
18506
+ }).strict().refine(
18507
+ (resources) => resources.cpuCount !== void 0 || resources.memoryMB !== void 0,
18508
+ {
18509
+ message: "Expected at least one runtime resource setting"
18510
+ }
18511
+ );
18512
+ EnvironmentSpecSchema = environmentSpecSchema(
18513
+ EnvironmentSetupSchema
18514
+ );
18515
+ EnvironmentApplySpecSchema = environmentSpecSchema(
18516
+ EnvironmentApplySetupSchema
18517
+ );
18518
+ EnvironmentResourceSchema = resourceEnvelopeSchema(
18519
+ EnvironmentSpecSchema
18520
+ );
18521
+ EnvironmentApplyRequestSchema = resourceApplySchema(
18522
+ EnvironmentApplySpecSchema
18523
+ );
18524
+ }
18525
+ });
18526
+
18527
+ // ../../packages/schemas/src/mcp.ts
18528
+ var McpToolCallMessageSchema, McpJsonRpcMessageSchema, McpPostBodySchema;
18529
+ var init_mcp = __esm({
18530
+ "../../packages/schemas/src/mcp.ts"() {
18531
+ "use strict";
18532
+ init_zod();
18533
+ McpToolCallMessageSchema = external_exports.object({
18534
+ method: external_exports.literal("tools/call"),
18535
+ params: external_exports.object({
18536
+ name: external_exports.string().trim().min(1)
18537
+ })
18538
+ });
18539
+ McpJsonRpcMessageSchema = external_exports.object({
18540
+ method: external_exports.string().optional()
18541
+ }).passthrough();
18542
+ McpPostBodySchema = external_exports.union([McpJsonRpcMessageSchema, external_exports.array(McpJsonRpcMessageSchema)]).transform((body) => Array.isArray(body) ? body : [body]);
18543
+ }
18544
+ });
18545
+
18546
+ // ../../packages/schemas/src/project-service-accounts.ts
18547
+ var ProjectServiceAccountSchema, ProjectServiceAccountCreateRequestSchema, ProjectServiceAccountUpdateRequestSchema, ProjectServiceAccountTokenResponseSchema, ProjectServiceAccountUpdateResponseSchema, ProjectServiceAccountRemoveResponseSchema, ProjectServiceAccountListResponseSchema;
18548
+ var init_project_service_accounts = __esm({
18549
+ "../../packages/schemas/src/project-service-accounts.ts"() {
18550
+ "use strict";
18551
+ init_zod();
18552
+ init_auth();
18553
+ init_ids();
18554
+ init_resources();
18555
+ ProjectServiceAccountSchema = external_exports.object({
18556
+ id: ServiceAccountIdSchema,
18557
+ organizationId: OrganizationIdSchema,
18558
+ projectId: ProjectIdSchema,
18559
+ name: ResourceNameSchema,
18560
+ scopes: external_exports.array(AuthScopeSchema),
18561
+ createdAt: external_exports.string().datetime()
18562
+ });
18563
+ ProjectServiceAccountCreateRequestSchema = external_exports.object({
18564
+ name: ResourceNameSchema,
18565
+ scopes: external_exports.array(AuthScopeSchema).min(1)
18566
+ });
18567
+ ProjectServiceAccountUpdateRequestSchema = external_exports.object({
18568
+ scopes: external_exports.array(AuthScopeSchema).min(1)
18569
+ });
18570
+ ProjectServiceAccountTokenResponseSchema = external_exports.object({
18571
+ serviceAccount: ProjectServiceAccountSchema,
18572
+ token: external_exports.string().min(1)
18573
+ });
18574
+ ProjectServiceAccountUpdateResponseSchema = external_exports.object({
18575
+ serviceAccount: ProjectServiceAccountSchema
18576
+ });
18577
+ ProjectServiceAccountRemoveResponseSchema = external_exports.object({
18578
+ serviceAccount: ProjectServiceAccountSchema,
18579
+ removed: external_exports.literal(true)
18580
+ });
18581
+ ProjectServiceAccountListResponseSchema = external_exports.object({
18582
+ serviceAccounts: external_exports.array(ProjectServiceAccountSchema)
18583
+ });
18584
+ }
18585
+ });
18586
+
18581
18587
  // ../../packages/schemas/src/project-resources.ts
18582
- var EnvironmentApplyDocumentSchema, 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;
18588
+ var EnvironmentApplyDocumentSchema, IdentityApplyDocumentSchema, 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;
18583
18589
  var init_project_resources = __esm({
18584
18590
  "../../packages/schemas/src/project-resources.ts"() {
18585
18591
  "use strict";
18586
18592
  init_zod();
18587
18593
  init_environments();
18594
+ init_identities();
18588
18595
  init_resources();
18589
18596
  init_sessions();
18590
- init_tools();
18591
18597
  EnvironmentApplyDocumentSchema = resourceApplyDocumentSchema(
18592
18598
  RESOURCE_KIND_ENVIRONMENT,
18593
18599
  EnvironmentApplyRequestSchema.shape.spec
18594
18600
  );
18595
- ToolApplyDocumentSchema = resourceApplyDocumentSchema(
18596
- RESOURCE_KIND_TOOL,
18597
- ToolApplyRequestSchema.shape.spec
18601
+ IdentityApplyDocumentSchema = resourceApplyDocumentSchema(
18602
+ RESOURCE_KIND_IDENTITY,
18603
+ IdentityApplyRequestSchema.shape.spec
18598
18604
  );
18599
18605
  SessionApplyDocumentSchema = resourceApplyDocumentSchema(
18600
18606
  RESOURCE_KIND_SESSION,
@@ -18602,12 +18608,12 @@ var init_project_resources = __esm({
18602
18608
  );
18603
18609
  ProjectApplyResourceSchema = external_exports.discriminatedUnion("kind", [
18604
18610
  EnvironmentApplyDocumentSchema,
18605
- ToolApplyDocumentSchema,
18611
+ IdentityApplyDocumentSchema,
18606
18612
  SessionApplyDocumentSchema
18607
18613
  ]);
18608
18614
  PROJECT_RESOURCE_APPLY_ORDER = [
18609
18615
  RESOURCE_KIND_ENVIRONMENT,
18610
- RESOURCE_KIND_TOOL,
18616
+ RESOURCE_KIND_IDENTITY,
18611
18617
  RESOURCE_KIND_SESSION
18612
18618
  ];
18613
18619
  PROJECT_RESOURCE_KINDS = PROJECT_RESOURCE_APPLY_ORDER;
@@ -18652,7 +18658,7 @@ var init_project_resources = __esm({
18652
18658
  });
18653
18659
  ProjectAppliedResourceSchema = external_exports.union([
18654
18660
  EnvironmentResourceSchema,
18655
- ToolResourceSchema,
18661
+ IdentityResourceSchema,
18656
18662
  SessionResourceSchema
18657
18663
  ]);
18658
18664
  ProjectApplyDiagnosticSchema = external_exports.object({
@@ -18663,7 +18669,7 @@ var init_project_resources = __esm({
18663
18669
  action: external_exports.enum(["create", "update", "unchanged"]),
18664
18670
  kind: external_exports.enum([
18665
18671
  RESOURCE_KIND_ENVIRONMENT,
18666
- RESOURCE_KIND_TOOL,
18672
+ RESOURCE_KIND_IDENTITY,
18667
18673
  RESOURCE_KIND_SESSION
18668
18674
  ]),
18669
18675
  name: external_exports.string().min(1)
@@ -18678,7 +18684,7 @@ var init_project_resources = __esm({
18678
18684
  action: external_exports.enum(["create", "update", "unchanged", "archive"]),
18679
18685
  kind: external_exports.enum([
18680
18686
  RESOURCE_KIND_ENVIRONMENT,
18681
- RESOURCE_KIND_TOOL,
18687
+ RESOURCE_KIND_IDENTITY,
18682
18688
  RESOURCE_KIND_SESSION
18683
18689
  ]),
18684
18690
  name: external_exports.string().min(1),
@@ -18689,7 +18695,7 @@ var init_project_resources = __esm({
18689
18695
  external_exports.object({
18690
18696
  kind: external_exports.enum([
18691
18697
  RESOURCE_KIND_ENVIRONMENT,
18692
- RESOURCE_KIND_TOOL,
18698
+ RESOURCE_KIND_IDENTITY,
18693
18699
  RESOURCE_KIND_SESSION
18694
18700
  ]),
18695
18701
  name: external_exports.string().min(1),
@@ -19416,6 +19422,7 @@ var init_src = __esm({
19416
19422
  init_connections();
19417
19423
  init_github_credentials();
19418
19424
  init_github_mcp_catalog();
19425
+ init_identities();
19419
19426
  init_ids();
19420
19427
  init_environments();
19421
19428
  init_mcp();
@@ -19631,6 +19638,13 @@ function createResourceApi(context) {
19631
19638
  path: "/tools",
19632
19639
  applyResponseSchema: ToolResourceSchema
19633
19640
  });
19641
+ const identities = projectResource(
19642
+ context,
19643
+ {
19644
+ path: "/identities",
19645
+ applyResponseSchema: IdentityResourceSchema
19646
+ }
19647
+ );
19634
19648
  return {
19635
19649
  applyEnvironmentResource: environments.apply,
19636
19650
  hasAvatarAsset: (request, options) => hasAvatarAsset(context, request, options ?? {}),
@@ -19645,6 +19659,7 @@ function createResourceApi(context) {
19645
19659
  createProjectServiceAccount: (request, options) => createProjectServiceAccount(context, request, options ?? {}),
19646
19660
  deleteProjectResource: (request, options) => deleteProjectResource(context, request, options ?? {}),
19647
19661
  listEnvironments: environments.list,
19662
+ listIdentities: identities.list,
19648
19663
  listProjectServiceAccounts: (options) => listProjectServiceAccounts(context, options ?? {}),
19649
19664
  listSessions: sessions.list,
19650
19665
  listTools: tools.list,
@@ -21190,7 +21205,7 @@ var init_package = __esm({
21190
21205
  "package.json"() {
21191
21206
  package_default = {
21192
21207
  name: "@autohq/cli",
21193
- version: "0.1.129",
21208
+ version: "0.1.131",
21194
21209
  license: "SEE LICENSE IN README.md",
21195
21210
  publishConfig: {
21196
21211
  access: "public"
@@ -21437,28 +21452,39 @@ async function uploadAvatarAsset2(client, asset, apiBaseUrl) {
21437
21452
  }
21438
21453
  }
21439
21454
  function stampAvatarSha256(resource, assets) {
21440
- if (resource.kind !== "session") {
21441
- return resource;
21442
- }
21443
- const identity2 = resource.spec.identity;
21444
- const avatar = identity2?.avatar;
21445
- if (!identity2 || !avatar) {
21446
- return resource;
21447
- }
21448
- const asset = assets[avatar.asset];
21449
- if (!asset) {
21450
- return resource;
21451
- }
21452
- return {
21453
- ...resource,
21454
- spec: {
21455
- ...resource.spec,
21456
- identity: {
21457
- ...identity2,
21455
+ if (resource.kind === "identity") {
21456
+ const avatar = resource.spec.avatar;
21457
+ const asset = avatar ? assets[avatar.asset] : void 0;
21458
+ if (!avatar || !asset) {
21459
+ return resource;
21460
+ }
21461
+ return {
21462
+ ...resource,
21463
+ spec: {
21464
+ ...resource.spec,
21458
21465
  avatar: { asset: avatar.asset, sha256: asset.sha256 }
21459
21466
  }
21467
+ };
21468
+ }
21469
+ if (resource.kind === "session" && typeof resource.spec.identity === "object" && resource.spec.identity !== null && !Array.isArray(resource.spec.identity)) {
21470
+ const identity2 = resource.spec.identity;
21471
+ const avatar = identity2.avatar;
21472
+ const asset = avatar ? assets[avatar.asset] : void 0;
21473
+ if (!avatar || !asset) {
21474
+ return resource;
21460
21475
  }
21461
- };
21476
+ return {
21477
+ ...resource,
21478
+ spec: {
21479
+ ...resource.spec,
21480
+ identity: {
21481
+ ...identity2,
21482
+ avatar: { asset: avatar.asset, sha256: asset.sha256 }
21483
+ }
21484
+ }
21485
+ };
21486
+ }
21487
+ return resource;
21462
21488
  }
21463
21489
  function formatMegabytes(bytes) {
21464
21490
  return (bytes / (1024 * 1024)).toFixed(1);
@@ -21534,30 +21560,14 @@ function appliedResourceKind(request, response, index) {
21534
21560
  return kind;
21535
21561
  }
21536
21562
  function mcpOAuthToolConnectionsFromApplyRequest(request) {
21537
- return request.resources.filter((resource) => resource.kind === RESOURCE_KIND_TOOL).flatMap((resource) => {
21538
- if (resource.spec.kind !== "mcp_remote" || resource.spec.auth.kind !== "mcp_oauth") {
21539
- return [];
21540
- }
21541
- return [
21542
- {
21543
- tool: resource.metadata.name,
21544
- connection: resource.spec.auth.connection
21545
- }
21546
- ];
21563
+ return request.resources.filter((resource) => resource.kind === RESOURCE_KIND_SESSION).flatMap((resource) => {
21564
+ return mcpOAuthToolConnectionsFromSessionTools(resource.spec.tools);
21547
21565
  });
21548
21566
  }
21549
21567
  function mcpOAuthToolConnectionsFromAppliedResources(resources) {
21550
- return resources.filter((item) => item.kind === RESOURCE_KIND_TOOL).flatMap((item) => {
21568
+ return resources.filter((item) => item.kind === RESOURCE_KIND_SESSION).flatMap((item) => {
21551
21569
  const resource = item.resource;
21552
- if (resource.spec.kind !== "mcp_remote" || resource.spec.auth.kind !== "mcp_oauth") {
21553
- return [];
21554
- }
21555
- return [
21556
- {
21557
- tool: resource.metadata.name,
21558
- connection: resource.spec.auth.connection
21559
- }
21560
- ];
21570
+ return mcpOAuthToolConnectionsFromSessionTools(resource.spec.tools);
21561
21571
  });
21562
21572
  }
21563
21573
  function applyFiles(root) {
@@ -21580,6 +21590,14 @@ function applyFiles(root) {
21580
21590
  }
21581
21591
  return files;
21582
21592
  }
21593
+ function mcpOAuthToolConnectionsFromSessionTools(tools) {
21594
+ return Object.entries(tools).flatMap(([alias, tool]) => {
21595
+ if (tool.kind !== "mcp_remote" || tool.disabled || tool.auth.kind !== "mcp_oauth") {
21596
+ return [];
21597
+ }
21598
+ return [{ tool: alias, connection: tool.auth.connection }];
21599
+ });
21600
+ }
21583
21601
  function readApplyDocumentFile(path2) {
21584
21602
  const source = readFileSync3(path2, "utf8");
21585
21603
  let documents;
@@ -21624,26 +21642,23 @@ function readApplyDocument(document) {
21624
21642
  function readApplyAssets(resources, projectRoot) {
21625
21643
  const assets = {};
21626
21644
  for (const resource of resources) {
21627
- if (resource.kind !== RESOURCE_KIND_SESSION) {
21628
- continue;
21629
- }
21630
- const avatarAsset = resource.spec.identity?.avatar?.asset;
21631
- if (!avatarAsset || assets[avatarAsset]) {
21645
+ const target = avatarAssetTarget(resource);
21646
+ if (!target || assets[target.asset]) {
21632
21647
  continue;
21633
21648
  }
21634
21649
  const resolvedPath = validateSessionAvatarAsset({
21635
- asset: avatarAsset,
21636
- resourceName: resource.metadata.name,
21650
+ asset: target.asset,
21651
+ resourceName: target.resourceName,
21637
21652
  projectRoot
21638
21653
  });
21639
21654
  const bytes = readFileSync3(resolvedPath);
21640
21655
  const dimensionsProblem = avatarAssetDimensionsProblem(bytes);
21641
21656
  if (dimensionsProblem) {
21642
21657
  throw new Error(
21643
- `Invalid session identity avatar asset for "${resource.metadata.name}": ${dimensionsProblem}`
21658
+ `Invalid identity avatar asset for "${target.resourceName}": ${dimensionsProblem}`
21644
21659
  );
21645
21660
  }
21646
- assets[avatarAsset] = {
21661
+ assets[target.asset] = {
21647
21662
  sha256: createHash3("sha256").update(bytes).digest("hex"),
21648
21663
  contentType: extname(resolvedPath).toLowerCase() === ".png" ? "image/png" : "image/jpeg",
21649
21664
  dataBase64: bytes.toString("base64")
@@ -21651,16 +21666,27 @@ function readApplyAssets(resources, projectRoot) {
21651
21666
  }
21652
21667
  return assets;
21653
21668
  }
21669
+ function avatarAssetTarget(resource) {
21670
+ if (resource.kind === RESOURCE_KIND_IDENTITY) {
21671
+ const asset = resource.spec.avatar?.asset;
21672
+ return asset ? { asset, resourceName: resource.metadata.name } : void 0;
21673
+ }
21674
+ if (resource.kind === RESOURCE_KIND_SESSION && typeof resource.spec.identity === "object" && resource.spec.identity !== null && !Array.isArray(resource.spec.identity)) {
21675
+ const asset = resource.spec.identity.avatar?.asset;
21676
+ return asset ? { asset, resourceName: resource.metadata.name } : void 0;
21677
+ }
21678
+ return void 0;
21679
+ }
21654
21680
  function validateSessionAvatarAsset(input) {
21655
21681
  if (isAbsolute(input.asset)) {
21656
21682
  throw new Error(
21657
- `Invalid session identity avatar asset for "${input.resourceName}": asset path must be relative`
21683
+ `Invalid identity avatar asset for "${input.resourceName}": asset path must be relative`
21658
21684
  );
21659
21685
  }
21660
21686
  const relativeAssetPath = input.asset.replaceAll("\\", "/");
21661
21687
  if (!relativeAssetPath.startsWith(".auto/assets/") && relativeAssetPath !== ".auto/assets") {
21662
21688
  throw new Error(
21663
- `Invalid session identity avatar asset for "${input.resourceName}": asset path must be under .auto/assets`
21689
+ `Invalid identity avatar asset for "${input.resourceName}": asset path must be under .auto/assets`
21664
21690
  );
21665
21691
  }
21666
21692
  const projectRoot = realpathSync(input.projectRoot);
@@ -21670,7 +21696,7 @@ function validateSessionAvatarAsset(input) {
21670
21696
  assetsRoot = realpathSync(resolve(projectRoot, ".auto", "assets"));
21671
21697
  } catch {
21672
21698
  throw new Error(
21673
- `Invalid session identity avatar asset for "${input.resourceName}": .auto/assets directory does not exist`
21699
+ `Invalid identity avatar asset for "${input.resourceName}": .auto/assets directory does not exist`
21674
21700
  );
21675
21701
  }
21676
21702
  let resolvedAssetPath;
@@ -21680,28 +21706,28 @@ function validateSessionAvatarAsset(input) {
21680
21706
  stat = statSync(resolvedAssetPath);
21681
21707
  } catch {
21682
21708
  throw new Error(
21683
- `Invalid session identity avatar asset for "${input.resourceName}": ${input.asset} does not exist`
21709
+ `Invalid identity avatar asset for "${input.resourceName}": ${input.asset} does not exist`
21684
21710
  );
21685
21711
  }
21686
21712
  if (!(resolvedAssetPath === assetsRoot || isInside(resolvedAssetPath, assetsRoot))) {
21687
21713
  throw new Error(
21688
- `Invalid session identity avatar asset for "${input.resourceName}": asset path must stay inside .auto/assets`
21714
+ `Invalid identity avatar asset for "${input.resourceName}": asset path must stay inside .auto/assets`
21689
21715
  );
21690
21716
  }
21691
21717
  if (!stat.isFile()) {
21692
21718
  throw new Error(
21693
- `Invalid session identity avatar asset for "${input.resourceName}": asset must be a file`
21719
+ `Invalid identity avatar asset for "${input.resourceName}": asset must be a file`
21694
21720
  );
21695
21721
  }
21696
21722
  if (stat.size > MAX_AVATAR_ASSET_BYTES) {
21697
21723
  throw new Error(
21698
- `Invalid session identity avatar asset for "${input.resourceName}": asset must be ${MAX_AVATAR_ASSET_BYTES} bytes or smaller`
21724
+ `Invalid identity avatar asset for "${input.resourceName}": asset must be ${MAX_AVATAR_ASSET_BYTES} bytes or smaller`
21699
21725
  );
21700
21726
  }
21701
21727
  const extension = extname(resolvedAssetPath).toLowerCase();
21702
21728
  if (!ALLOWED_AVATAR_EXTENSIONS.has(extension)) {
21703
21729
  throw new Error(
21704
- `Invalid session identity avatar asset for "${input.resourceName}": asset must be a PNG or JPEG image`
21730
+ `Invalid identity avatar asset for "${input.resourceName}": asset must be a PNG or JPEG image`
21705
21731
  );
21706
21732
  }
21707
21733
  return resolvedAssetPath;
@@ -21770,12 +21796,12 @@ var init_files = __esm({
21770
21796
  init_src();
21771
21797
  APPLY_DIRECTORIES = {
21772
21798
  environment: "environments",
21773
- tool: "tools",
21799
+ identity: "identities",
21774
21800
  session: "sessions"
21775
21801
  };
21776
21802
  APPLY_SCHEMAS = {
21777
21803
  environment: EnvironmentApplyRequestSchema,
21778
- tool: ToolApplyRequestSchema,
21804
+ identity: IdentityApplyRequestSchema,
21779
21805
  session: SessionApplyRequestSchema
21780
21806
  };
21781
21807
  ALLOWED_AVATAR_EXTENSIONS = /* @__PURE__ */ new Set([".jpg", ".jpeg", ".png"]);
@@ -21946,8 +21972,8 @@ async function listProjectResources2(client, kind, options) {
21946
21972
  switch (kind) {
21947
21973
  case RESOURCE_KIND_ENVIRONMENT:
21948
21974
  return (await client.listEnvironments(options)).environments;
21949
- case RESOURCE_KIND_TOOL:
21950
- return (await client.listTools(options)).tools;
21975
+ case RESOURCE_KIND_IDENTITY:
21976
+ return (await client.listIdentities(options)).identities;
21951
21977
  case RESOURCE_KIND_SESSION:
21952
21978
  return (await client.listSessions(options)).sessions;
21953
21979
  }
@@ -21974,11 +22000,11 @@ var init_resources3 = __esm({
21974
22000
  label: "Environment",
21975
22001
  pluralLabel: "Environments"
21976
22002
  },
21977
- [RESOURCE_KIND_TOOL]: {
21978
- kind: RESOURCE_KIND_TOOL,
21979
- section: "tools",
21980
- label: "Tool",
21981
- pluralLabel: "Tools"
22003
+ [RESOURCE_KIND_IDENTITY]: {
22004
+ kind: RESOURCE_KIND_IDENTITY,
22005
+ section: "identities",
22006
+ label: "Identity",
22007
+ pluralLabel: "Identities"
21982
22008
  },
21983
22009
  [RESOURCE_KIND_SESSION]: {
21984
22010
  kind: RESOURCE_KIND_SESSION,
@@ -21989,8 +22015,8 @@ var init_resources3 = __esm({
21989
22015
  };
21990
22016
  PROJECT_RESOURCE_TUI_ORDER = [
21991
22017
  RESOURCE_KIND_SESSION,
21992
- RESOURCE_KIND_ENVIRONMENT,
21993
- RESOURCE_KIND_TOOL
22018
+ RESOURCE_KIND_IDENTITY,
22019
+ RESOURCE_KIND_ENVIRONMENT
21994
22020
  ];
21995
22021
  PROJECT_RESOURCE_TUI_DEFINITIONS = PROJECT_RESOURCE_TUI_ORDER.map(
21996
22022
  (kind) => PROJECT_RESOURCE_TUI_DEFINITION_BY_KIND[kind]
@@ -24411,35 +24437,29 @@ function EnvironmentsView({
24411
24437
  }
24412
24438
  );
24413
24439
  }
24414
- function ToolsView({
24440
+ function IdentitiesView({
24415
24441
  resources,
24416
24442
  selectedIndex,
24417
- selectedSession,
24418
24443
  error: error51
24419
24444
  }) {
24420
24445
  return /* @__PURE__ */ jsx9(
24421
24446
  ResourceTable,
24422
24447
  {
24423
- rows: resources.map((tool) => {
24424
- const aliases = sessionToolAliases(selectedSession, tool.metadata.name);
24425
- return {
24426
- id: tool.metadata.uid,
24427
- name: tool.metadata.name,
24428
- kind: toolKind(tool),
24429
- target: toolTarget(tool),
24430
- detail: [
24431
- toolAuth(tool),
24432
- aliases.length ? `alias:${aliases.join(",")}` : ""
24433
- ].filter(Boolean).join(" "),
24434
- updatedAt: tool.metadata.updatedAt
24435
- };
24436
- }),
24448
+ rows: resources.map((identity2) => ({
24449
+ id: identity2.metadata.uid,
24450
+ name: identity2.metadata.name,
24451
+ kind: identity2.spec.displayName ?? "",
24452
+ target: identity2.spec.username ?? "",
24453
+ detail: identity2.spec.avatar?.asset ?? identity2.spec.description ?? "",
24454
+ updatedAt: identity2.metadata.updatedAt
24455
+ })),
24437
24456
  selectedIndex,
24438
24457
  error: error51,
24439
- empty: "no tools found",
24440
- kindHeader: "KIND",
24441
- targetHeader: "TARGET",
24442
- detailHeader: "AUTH / ALIAS"
24458
+ empty: "no identities found",
24459
+ kindHeader: "DISPLAY",
24460
+ targetHeader: "USERNAME",
24461
+ detailHeader: "AVATAR / DESCRIPTION",
24462
+ flexColumn: "detail"
24443
24463
  }
24444
24464
  );
24445
24465
  }
@@ -24556,26 +24576,6 @@ function envValueKind(value) {
24556
24576
  }
24557
24577
  return "unknown";
24558
24578
  }
24559
- function sessionToolAliases(selectedSession, toolName) {
24560
- if (!selectedSession) return [];
24561
- return Object.entries(selectedSession.spec.tools).filter(([, value]) => "ref" in value && value.ref === toolName).map(([alias]) => alias).sort();
24562
- }
24563
- function toolKind(tool) {
24564
- if (tool.spec.kind === "local") return `local/${tool.spec.implementation}`;
24565
- return tool.spec.kind;
24566
- }
24567
- function toolTarget(tool) {
24568
- if (tool.spec.kind === "local") return tool.spec.implementation;
24569
- return tool.spec.url;
24570
- }
24571
- function toolAuth(tool) {
24572
- const auth = tool.spec.auth;
24573
- if (auth.kind === "none") return "auth:none";
24574
- if (auth.kind === "bearer") return "auth:bearer";
24575
- if (auth.kind === "provider_oauth") return `auth:${auth.provider}`;
24576
- if (auth.kind === "connection") return `auth:${auth.provider}`;
24577
- return "auth:unknown";
24578
- }
24579
24579
  var COL_KIND, COL_DETAIL, COL_TARGET, COL_UPDATED, ROW_GAP_COUNT;
24580
24580
  var init_ResourceViews = __esm({
24581
24581
  "src/tui/ResourceViews.tsx"() {
@@ -24627,9 +24627,9 @@ function useEnvironments(apiUrl) {
24627
24627
  const client = useApiClient();
24628
24628
  return useQuery(environmentsQueryOptions(client, apiUrl));
24629
24629
  }
24630
- function useTools(apiUrl) {
24630
+ function useIdentities(apiUrl) {
24631
24631
  const client = useApiClient();
24632
- return useQuery(toolsQueryOptions(client, apiUrl));
24632
+ return useQuery(identitiesQueryOptions(client, apiUrl));
24633
24633
  }
24634
24634
  function useSessionRuns(sessionName, apiUrl, includeArchived = false) {
24635
24635
  const client = useApiClient();
@@ -24904,22 +24904,20 @@ function environmentsQueryOptions(client, apiUrl) {
24904
24904
  staleTime: Number.POSITIVE_INFINITY
24905
24905
  });
24906
24906
  }
24907
- function sessionsQueryOptions(client, apiUrl) {
24907
+ function identitiesQueryOptions(client, apiUrl) {
24908
24908
  return queryOptions({
24909
- queryKey: queryKeys.sessions(apiUrl),
24910
- queryFn: async () => {
24911
- const res = await client.listSessions({ apiBaseUrl: apiUrl });
24912
- return sortSessions(res.sessions);
24913
- },
24909
+ queryKey: queryKeys.identities(apiUrl),
24910
+ queryFn: async () => (await client.listIdentities({ apiBaseUrl: apiUrl })).identities,
24911
+ select: sortByName,
24914
24912
  staleTime: Number.POSITIVE_INFINITY
24915
24913
  });
24916
24914
  }
24917
- function toolsQueryOptions(client, apiUrl) {
24915
+ function sessionsQueryOptions(client, apiUrl) {
24918
24916
  return queryOptions({
24919
- queryKey: queryKeys.tools(apiUrl),
24917
+ queryKey: queryKeys.sessions(apiUrl),
24920
24918
  queryFn: async () => {
24921
- const res = await client.listTools({ apiBaseUrl: apiUrl });
24922
- return sortByName(res.tools);
24919
+ const res = await client.listSessions({ apiBaseUrl: apiUrl });
24920
+ return sortSessions(res.sessions);
24923
24921
  },
24924
24922
  staleTime: Number.POSITIVE_INFINITY
24925
24923
  });
@@ -24999,6 +24997,7 @@ var init_queries = __esm({
24999
24997
  TUI_RUN_LIST_LIMIT = 200;
25000
24998
  queryKeys = {
25001
24999
  environments: (apiUrl) => ["environments", apiUrl],
25000
+ identities: (apiUrl) => ["identities", apiUrl],
25002
25001
  sessions: (apiUrl) => ["sessions", apiUrl],
25003
25002
  tools: (apiUrl) => ["tools", apiUrl],
25004
25003
  projects: (apiUrl) => ["projects", apiUrl],
@@ -25463,10 +25462,10 @@ function selectedNamedResourceForSection(input) {
25463
25462
  switch (input.activeSection) {
25464
25463
  case "environments":
25465
25464
  return input.selectedEnvironment ?? null;
25465
+ case "identities":
25466
+ return input.selectedIdentity ?? null;
25466
25467
  case "sessions":
25467
25468
  return input.selectedSession ?? null;
25468
- case "tools":
25469
- return input.selectedTool ?? null;
25470
25469
  default:
25471
25470
  return null;
25472
25471
  }
@@ -25505,7 +25504,7 @@ function HomeView({ apiUrl, notice, returnToSession }) {
25505
25504
  );
25506
25505
  const [sessionIndex, setSessionIndex] = useState3(0);
25507
25506
  const [environmentIndex, setEnvironmentIndex] = useState3(0);
25508
- const [toolIndex, setToolIndex] = useState3(0);
25507
+ const [identityIndex, setIdentityIndex] = useState3(0);
25509
25508
  const [projectIndex, setProjectIndex] = useState3(0);
25510
25509
  const [serviceAccountIndex, setServiceAccountIndex] = useState3(0);
25511
25510
  const [runIndex, setRunIndex] = useState3(0);
@@ -25541,10 +25540,10 @@ function HomeView({ apiUrl, notice, returnToSession }) {
25541
25540
  error: environmentsError
25542
25541
  } = useEnvironments(apiUrl);
25543
25542
  const {
25544
- data: tools = [],
25545
- isLoading: isToolsLoading,
25546
- error: toolsError
25547
- } = useTools(apiUrl);
25543
+ data: identities = [],
25544
+ isLoading: isIdentitiesLoading,
25545
+ error: identitiesError
25546
+ } = useIdentities(apiUrl);
25548
25547
  const {
25549
25548
  data: projects = [],
25550
25549
  isLoading: isProjectsLoading,
@@ -25632,13 +25631,13 @@ function HomeView({ apiUrl, notice, returnToSession }) {
25632
25631
  const selectedServiceAccount = serviceAccounts[serviceAccountIndex];
25633
25632
  const selectedSession = sessions[sessionIndex];
25634
25633
  const selectedEnvironment = environments[environmentIndex];
25635
- const selectedTool = tools[toolIndex];
25634
+ const selectedIdentity = identities[identityIndex];
25636
25635
  const selectedInspectableResource = useMemo3(() => {
25637
25636
  const selectedEditable = editableResourceForSelection({
25638
25637
  activeSection,
25639
25638
  selectedEnvironment,
25640
- selectedSession,
25641
- selectedTool
25639
+ selectedIdentity,
25640
+ selectedSession
25642
25641
  });
25643
25642
  if (!selectedEditable) {
25644
25643
  return null;
@@ -25656,24 +25655,24 @@ function HomeView({ apiUrl, notice, returnToSession }) {
25656
25655
  name: selectedEditable.name,
25657
25656
  spec: selectedEnvironment.spec
25658
25657
  } : null;
25659
- case "tools":
25660
- return selectedTool ? {
25658
+ case "identities":
25659
+ return selectedIdentity ? {
25661
25660
  kind: selectedEditable.kind,
25662
25661
  name: selectedEditable.name,
25663
- spec: selectedTool.spec
25662
+ spec: selectedIdentity.spec
25664
25663
  } : null;
25665
25664
  default:
25666
25665
  return null;
25667
25666
  }
25668
- }, [activeSection, selectedEnvironment, selectedSession, selectedTool]);
25667
+ }, [activeSection, selectedEnvironment, selectedIdentity, selectedSession]);
25669
25668
  const selectedEditableResource = useMemo3(
25670
25669
  () => editableResourceForSelection({
25671
25670
  activeSection,
25672
25671
  selectedEnvironment,
25673
- selectedSession,
25674
- selectedTool
25672
+ selectedIdentity,
25673
+ selectedSession
25675
25674
  }),
25676
- [activeSection, selectedEnvironment, selectedSession, selectedTool]
25675
+ [activeSection, selectedEnvironment, selectedIdentity, selectedSession]
25677
25676
  );
25678
25677
  const inspectPanelHeight = Math.max(1, termHeight - 12);
25679
25678
  const scopedSession = runScopeSessionName ? sessions.find((session) => session.metadata.name === runScopeSessionName) : void 0;
@@ -25716,22 +25715,6 @@ function HomeView({ apiUrl, notice, returnToSession }) {
25716
25715
  );
25717
25716
  if (index >= 0) setEnvironmentIndex(index);
25718
25717
  }, [environments, selectedSession]);
25719
- useEffect3(() => {
25720
- const sessionToolRefs = selectedSession ? Object.values(selectedSession.spec.tools).flatMap((tool) => {
25721
- if ("ref" in tool) {
25722
- return [tool.ref];
25723
- }
25724
- if ("refs" in tool) {
25725
- return tool.refs;
25726
- }
25727
- return [];
25728
- }) : [];
25729
- if (sessionToolRefs.length === 0) return;
25730
- const index = tools.findIndex(
25731
- (tool) => sessionToolRefs.includes(tool.metadata.name)
25732
- );
25733
- if (index >= 0) setToolIndex(index);
25734
- }, [tools, selectedSession]);
25735
25718
  const connectionStatus = startConnection.error instanceof Error ? startConnection.error.message : allowConnection.error instanceof Error ? allowConnection.error.message : removeConnection.error instanceof Error ? removeConnection.error.message : connectionNotice;
25736
25719
  const startRun = useCallback2(() => {
25737
25720
  if (!scopedSession || triggerRun.isPending) return;
@@ -26267,13 +26250,13 @@ function HomeView({ apiUrl, notice, returnToSession }) {
26267
26250
  return;
26268
26251
  }
26269
26252
  }
26270
- if (activeSection === "tools") {
26253
+ if (activeSection === "identities") {
26271
26254
  if (key.upArrow) {
26272
- setToolIndex((i) => Math.max(0, i - 1));
26255
+ setIdentityIndex((i) => Math.max(0, i - 1));
26273
26256
  return;
26274
26257
  }
26275
26258
  if (key.downArrow) {
26276
- setToolIndex((i) => clampListIndex(i + 1, tools.length));
26259
+ setIdentityIndex((i) => clampListIndex(i + 1, identities.length));
26277
26260
  return;
26278
26261
  }
26279
26262
  }
@@ -26557,9 +26540,9 @@ function HomeView({ apiUrl, notice, returnToSession }) {
26557
26540
  sectionTitle = `Service Accounts[${serviceAccounts.length}]`;
26558
26541
  break;
26559
26542
  case "environments":
26560
- case "tools": {
26543
+ case "identities": {
26561
26544
  const definition = PROJECT_RESOURCE_TUI_DEFINITIONS_BY_SECTION.get(activeSection);
26562
- const count = activeSection === "environments" ? environments.length : tools.length;
26545
+ const count = activeSection === "environments" ? environments.length : identities.length;
26563
26546
  sectionTitle = `${definition?.pluralLabel ?? activeSection}[${count}]`;
26564
26547
  break;
26565
26548
  }
@@ -26730,13 +26713,12 @@ function HomeView({ apiUrl, notice, returnToSession }) {
26730
26713
  selectedSession,
26731
26714
  error: environmentsError instanceof Error ? environmentsError.message : environmentsError ? String(environmentsError) : null
26732
26715
  }
26733
- ) : activeSection === "tools" ? isToolsLoading ? /* @__PURE__ */ jsx14(Box13, { padding: 2, children: /* @__PURE__ */ jsx14(Spinner, { label: "loading tools\u2026" }) }) : /* @__PURE__ */ jsx14(
26734
- ToolsView,
26716
+ ) : activeSection === "identities" ? isIdentitiesLoading ? /* @__PURE__ */ jsx14(Box13, { padding: 2, children: /* @__PURE__ */ jsx14(Spinner, { label: "loading identities\u2026" }) }) : /* @__PURE__ */ jsx14(
26717
+ IdentitiesView,
26735
26718
  {
26736
- resources: tools,
26737
- selectedIndex: toolIndex,
26738
- selectedSession,
26739
- error: toolsError instanceof Error ? toolsError.message : toolsError ? String(toolsError) : null
26719
+ resources: identities,
26720
+ selectedIndex: identityIndex,
26721
+ error: identitiesError instanceof Error ? identitiesError.message : identitiesError ? String(identitiesError) : null
26740
26722
  }
26741
26723
  ) : activeSection === "sessions" ? /* @__PURE__ */ jsx14(
26742
26724
  SessionsView,
@@ -26842,7 +26824,7 @@ function HomeView({ apiUrl, notice, returnToSession }) {
26842
26824
  /* @__PURE__ */ jsx14(Text14, { dimColor: true, children: ` ${inspectedResource.name} ` }),
26843
26825
  /* @__PURE__ */ jsx14(Text14, { dimColor: true, children: "\u203A" }),
26844
26826
  /* @__PURE__ */ jsx14(Text14, { backgroundColor: "cyan", color: "black", children: " inspect " })
26845
- ] }) : (activeSection === "projects" || activeSection === "environments" || activeSection === "tools" || activeSection === "serviceAccounts" || activeSection === "connections") && /* @__PURE__ */ jsx14(
26827
+ ] }) : (activeSection === "projects" || activeSection === "environments" || activeSection === "identities" || activeSection === "serviceAccounts" || activeSection === "connections") && /* @__PURE__ */ jsx14(
26846
26828
  Text14,
26847
26829
  {
26848
26830
  backgroundColor: "cyan",
@@ -27082,7 +27064,7 @@ var init_HomeView = __esm({
27082
27064
  resourceNavItem({ k: "1", section: "sessions" }),
27083
27065
  { k: "2", label: "Runs", activeSection: "runs" },
27084
27066
  resourceNavItem({ k: "3", section: "environments" }),
27085
- resourceNavItem({ k: "4", section: "tools" }),
27067
+ resourceNavItem({ k: "4", section: "identities" }),
27086
27068
  { k: "5", label: "Projects", activeSection: "projects" },
27087
27069
  { k: "6", label: "Service Accounts", activeSection: "serviceAccounts" },
27088
27070
  { k: "7", label: "Connections", activeSection: "connections" }
@@ -27194,6 +27176,7 @@ async function launch(opts) {
27194
27176
  });
27195
27177
  const prefetchP = Promise.allSettled([
27196
27178
  apiClient.listSessions({ apiBaseUrl: apiUrl }),
27179
+ apiClient.listIdentities({ apiBaseUrl: apiUrl }),
27197
27180
  apiClient.listProjects({ apiBaseUrl: apiUrl }),
27198
27181
  apiClient.listProjectServiceAccounts({ apiBaseUrl: apiUrl }),
27199
27182
  apiClient.listConnections({ apiBaseUrl: apiUrl }),
@@ -27206,6 +27189,7 @@ async function launch(opts) {
27206
27189
  const [, prefetchResult] = await Promise.all([waitSplash(), prefetchP]);
27207
27190
  const [
27208
27191
  sessionsResult,
27192
+ identitiesResult,
27209
27193
  projectsResult,
27210
27194
  serviceAccountsResult,
27211
27195
  connectionsResult,
@@ -27217,6 +27201,12 @@ async function launch(opts) {
27217
27201
  sortSessions(sessionsResult.value.sessions)
27218
27202
  );
27219
27203
  }
27204
+ if (identitiesResult.status === "fulfilled") {
27205
+ queryClient.setQueryData(
27206
+ queryKeys.identities(apiUrl),
27207
+ sortByResourceName(identitiesResult.value.identities)
27208
+ );
27209
+ }
27220
27210
  if (projectsResult.status === "fulfilled") {
27221
27211
  queryClient.setQueryData(
27222
27212
  queryKeys.projects(apiUrl),
@@ -27341,11 +27331,11 @@ var init_launcher = __esm({
27341
27331
  queryKey: queryKeys.environments,
27342
27332
  sort: sortByResourceName
27343
27333
  },
27344
- [RESOURCE_KIND_TOOL]: {
27334
+ [RESOURCE_KIND_IDENTITY]: {
27345
27335
  async list({ apiClient, apiUrl }) {
27346
- return (await apiClient.listTools({ apiBaseUrl: apiUrl })).tools;
27336
+ return (await apiClient.listIdentities({ apiBaseUrl: apiUrl })).identities;
27347
27337
  },
27348
- queryKey: queryKeys.tools,
27338
+ queryKey: queryKeys.identities,
27349
27339
  sort: sortByResourceName
27350
27340
  },
27351
27341
  [RESOURCE_KIND_SESSION]: {