@autohq/cli 0.1.88 → 0.1.90

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.
@@ -4842,6 +4842,76 @@ var require_websocket_server = __commonJS({
4842
4842
  }
4843
4843
  });
4844
4844
 
4845
+ // src/commands/agent-bridge/git-credentials.ts
4846
+ import { once } from "events";
4847
+ import { chmod, mkdir, readFile, writeFile } from "fs/promises";
4848
+ import { createServer } from "http";
4849
+ import { homedir } from "os";
4850
+ import path from "path";
4851
+ var RELAY_PATH = "/git-credential";
4852
+ function defaultGitCredentialPortFilePath() {
4853
+ return path.join(homedir(), ".auto", "agent-bridge", "git-credential.json");
4854
+ }
4855
+ async function startGitCredentialRelay(input) {
4856
+ const fetchImpl = input.fetchImpl ?? fetch;
4857
+ let target = { url: input.url, accessToken: input.accessToken };
4858
+ const server = createServer((request, response) => {
4859
+ if (request.method !== "POST" || request.url !== RELAY_PATH) {
4860
+ response.writeHead(404).end();
4861
+ return;
4862
+ }
4863
+ const chunks = [];
4864
+ request.on("data", (chunk) => chunks.push(chunk));
4865
+ request.on("end", () => {
4866
+ void (async () => {
4867
+ try {
4868
+ const upstream = await fetchImpl(target.url, {
4869
+ method: "POST",
4870
+ headers: {
4871
+ authorization: `Bearer ${target.accessToken}`,
4872
+ "content-type": "application/json"
4873
+ },
4874
+ body: Buffer.concat(chunks).toString("utf8") || "{}"
4875
+ });
4876
+ const body = await upstream.text();
4877
+ response.writeHead(upstream.status, {
4878
+ "content-type": upstream.headers.get("content-type") ?? "application/json"
4879
+ }).end(body);
4880
+ } catch (error51) {
4881
+ response.writeHead(502, { "content-type": "application/json" }).end(
4882
+ JSON.stringify({
4883
+ error: error51 instanceof Error ? error51.message : String(error51)
4884
+ })
4885
+ );
4886
+ }
4887
+ })();
4888
+ });
4889
+ });
4890
+ server.listen(0, "127.0.0.1");
4891
+ await once(server, "listening");
4892
+ server.unref();
4893
+ const address = server.address();
4894
+ if (!address || typeof address !== "object") {
4895
+ server.close();
4896
+ throw new Error("git credential relay failed to bind a loopback port");
4897
+ }
4898
+ const portFilePath = input.portFilePath ?? defaultGitCredentialPortFilePath();
4899
+ await mkdir(path.dirname(portFilePath), { recursive: true });
4900
+ await writeFile(portFilePath, JSON.stringify({ port: address.port }), {
4901
+ mode: 384
4902
+ });
4903
+ await chmod(portFilePath, 384);
4904
+ return {
4905
+ port: address.port,
4906
+ update: (next) => {
4907
+ target = { url: next.url, accessToken: next.accessToken };
4908
+ },
4909
+ close: () => new Promise((resolve) => {
4910
+ server.close(() => resolve());
4911
+ })
4912
+ };
4913
+ }
4914
+
4845
4915
  // ../../node_modules/zod/v4/classic/external.js
4846
4916
  var external_exports = {};
4847
4917
  __export(external_exports, {
@@ -5608,10 +5678,10 @@ function mergeDefs(...defs) {
5608
5678
  function cloneDef(schema) {
5609
5679
  return mergeDefs(schema._zod.def);
5610
5680
  }
5611
- function getElementAtPath(obj, path) {
5612
- if (!path)
5681
+ function getElementAtPath(obj, path2) {
5682
+ if (!path2)
5613
5683
  return obj;
5614
- return path.reduce((acc, key) => acc?.[key], obj);
5684
+ return path2.reduce((acc, key) => acc?.[key], obj);
5615
5685
  }
5616
5686
  function promiseAllObject(promisesObj) {
5617
5687
  const keys = Object.keys(promisesObj);
@@ -6020,11 +6090,11 @@ function explicitlyAborted(x2, startIndex = 0) {
6020
6090
  }
6021
6091
  return false;
6022
6092
  }
6023
- function prefixIssues(path, issues) {
6093
+ function prefixIssues(path2, issues) {
6024
6094
  return issues.map((iss) => {
6025
6095
  var _a3;
6026
6096
  (_a3 = iss).path ?? (_a3.path = []);
6027
- iss.path.unshift(path);
6097
+ iss.path.unshift(path2);
6028
6098
  return iss;
6029
6099
  });
6030
6100
  }
@@ -6171,16 +6241,16 @@ function flattenError(error51, mapper = (issue2) => issue2.message) {
6171
6241
  }
6172
6242
  function formatError(error51, mapper = (issue2) => issue2.message) {
6173
6243
  const fieldErrors = { _errors: [] };
6174
- const processError = (error52, path = []) => {
6244
+ const processError = (error52, path2 = []) => {
6175
6245
  for (const issue2 of error52.issues) {
6176
6246
  if (issue2.code === "invalid_union" && issue2.errors.length) {
6177
- issue2.errors.map((issues) => processError({ issues }, [...path, ...issue2.path]));
6247
+ issue2.errors.map((issues) => processError({ issues }, [...path2, ...issue2.path]));
6178
6248
  } else if (issue2.code === "invalid_key") {
6179
- processError({ issues: issue2.issues }, [...path, ...issue2.path]);
6249
+ processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
6180
6250
  } else if (issue2.code === "invalid_element") {
6181
- processError({ issues: issue2.issues }, [...path, ...issue2.path]);
6251
+ processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
6182
6252
  } else {
6183
- const fullpath = [...path, ...issue2.path];
6253
+ const fullpath = [...path2, ...issue2.path];
6184
6254
  if (fullpath.length === 0) {
6185
6255
  fieldErrors._errors.push(mapper(issue2));
6186
6256
  } else {
@@ -6207,17 +6277,17 @@ function formatError(error51, mapper = (issue2) => issue2.message) {
6207
6277
  }
6208
6278
  function treeifyError(error51, mapper = (issue2) => issue2.message) {
6209
6279
  const result = { errors: [] };
6210
- const processError = (error52, path = []) => {
6280
+ const processError = (error52, path2 = []) => {
6211
6281
  var _a3, _b2;
6212
6282
  for (const issue2 of error52.issues) {
6213
6283
  if (issue2.code === "invalid_union" && issue2.errors.length) {
6214
- issue2.errors.map((issues) => processError({ issues }, [...path, ...issue2.path]));
6284
+ issue2.errors.map((issues) => processError({ issues }, [...path2, ...issue2.path]));
6215
6285
  } else if (issue2.code === "invalid_key") {
6216
- processError({ issues: issue2.issues }, [...path, ...issue2.path]);
6286
+ processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
6217
6287
  } else if (issue2.code === "invalid_element") {
6218
- processError({ issues: issue2.issues }, [...path, ...issue2.path]);
6288
+ processError({ issues: issue2.issues }, [...path2, ...issue2.path]);
6219
6289
  } else {
6220
- const fullpath = [...path, ...issue2.path];
6290
+ const fullpath = [...path2, ...issue2.path];
6221
6291
  if (fullpath.length === 0) {
6222
6292
  result.errors.push(mapper(issue2));
6223
6293
  continue;
@@ -6249,8 +6319,8 @@ function treeifyError(error51, mapper = (issue2) => issue2.message) {
6249
6319
  }
6250
6320
  function toDotPath(_path) {
6251
6321
  const segs = [];
6252
- const path = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
6253
- for (const seg of path) {
6322
+ const path2 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
6323
+ for (const seg of path2) {
6254
6324
  if (typeof seg === "number")
6255
6325
  segs.push(`[${seg}]`);
6256
6326
  else if (typeof seg === "symbol")
@@ -18942,13 +19012,13 @@ function resolveRef(ref, ctx) {
18942
19012
  if (!ref.startsWith("#")) {
18943
19013
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
18944
19014
  }
18945
- const path = ref.slice(1).split("/").filter(Boolean);
18946
- if (path.length === 0) {
19015
+ const path2 = ref.slice(1).split("/").filter(Boolean);
19016
+ if (path2.length === 0) {
18947
19017
  return ctx.rootSchema;
18948
19018
  }
18949
19019
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
18950
- if (path[0] === defsKey) {
18951
- const key = path[1];
19020
+ if (path2[0] === defsKey) {
19021
+ const key = path2[1];
18952
19022
  if (!key || !ctx.defs[key]) {
18953
19023
  throw new Error(`Reference not found: ${ref}`);
18954
19024
  }
@@ -19463,7 +19533,14 @@ var AgentBridgeClaudeConfigSchema = external_exports.object({
19463
19533
  var RuntimeBridgeBootstrapPlaintextSchema = external_exports.object({
19464
19534
  version: external_exports.literal(1),
19465
19535
  outputSeqStart: external_exports.number().int().nonnegative(),
19466
- claude: AgentBridgeClaudeConfigSchema
19536
+ claude: AgentBridgeClaudeConfigSchema,
19537
+ // Endpoint + run token for the git credential broker. Present only when
19538
+ // the run has GitHub App git mounts; rides the encrypted bootstrap so the
19539
+ // token lives in agent-bridge memory, never on disk.
19540
+ gitCredentials: external_exports.object({
19541
+ url: external_exports.string().trim().min(1),
19542
+ accessToken: external_exports.string().trim().min(1)
19543
+ }).strict().optional()
19467
19544
  }).strict();
19468
19545
  var RuntimeBridgeEncryptedBootstrapSchema = external_exports.object({
19469
19546
  version: external_exports.literal(1),
@@ -19615,6 +19692,8 @@ var AuthScopeSchema = external_exports.enum([
19615
19692
  "secrets:read",
19616
19693
  "secrets:write",
19617
19694
  "secrets:use",
19695
+ "github:mcp",
19696
+ "github:credentials",
19618
19697
  "projects:admin",
19619
19698
  "org:admin"
19620
19699
  ]);
@@ -20657,6 +20736,87 @@ var ConnectionRemoveResponseSchema = external_exports.object({
20657
20736
  message: external_exports.string().trim().min(1)
20658
20737
  });
20659
20738
 
20739
+ // ../../packages/schemas/src/github-credentials.ts
20740
+ var CreateRunGithubCredentialRequestSchema = external_exports.object({
20741
+ host: external_exports.literal("github.com"),
20742
+ path: external_exports.string().trim().min(1).optional()
20743
+ });
20744
+ var RunGithubCredentialResponseSchema = external_exports.object({
20745
+ username: external_exports.literal("x-access-token"),
20746
+ password: external_exports.string().min(1),
20747
+ expiresAt: external_exports.string().datetime()
20748
+ });
20749
+
20750
+ // ../../packages/schemas/src/github-mcp-catalog.ts
20751
+ var GITHUB_MCP_TOOL_NAMES = [
20752
+ "actions_get",
20753
+ "actions_list",
20754
+ "actions_run_trigger",
20755
+ "add_comment_to_pending_review",
20756
+ "add_issue_comment",
20757
+ "add_reply_to_pull_request_comment",
20758
+ "create_branch",
20759
+ "create_or_update_file",
20760
+ "create_pull_request",
20761
+ "create_repository",
20762
+ "delete_file",
20763
+ "fork_repository",
20764
+ "get_commit",
20765
+ "get_file_contents",
20766
+ "get_job_logs",
20767
+ "get_label",
20768
+ "get_latest_release",
20769
+ "get_release_by_tag",
20770
+ "get_tag",
20771
+ "issue_read",
20772
+ "issue_write",
20773
+ "list_branches",
20774
+ "list_commits",
20775
+ "list_issue_types",
20776
+ "list_issues",
20777
+ "list_pull_requests",
20778
+ "list_releases",
20779
+ "list_repository_collaborators",
20780
+ "list_tags",
20781
+ "merge_pull_request",
20782
+ "pull_request_read",
20783
+ "pull_request_review_write",
20784
+ "push_files",
20785
+ "search_code",
20786
+ "search_commits",
20787
+ "search_issues",
20788
+ "search_pull_requests",
20789
+ "search_repositories",
20790
+ "sub_issue_write",
20791
+ "update_pull_request",
20792
+ "update_pull_request_branch"
20793
+ ];
20794
+ var GITHUB_MCP_WRITE_TOOLS = [
20795
+ "actions_run_trigger",
20796
+ "add_comment_to_pending_review",
20797
+ "add_issue_comment",
20798
+ "add_reply_to_pull_request_comment",
20799
+ "create_branch",
20800
+ "create_or_update_file",
20801
+ "create_pull_request",
20802
+ "create_repository",
20803
+ "delete_file",
20804
+ "fork_repository",
20805
+ "issue_write",
20806
+ "merge_pull_request",
20807
+ "pull_request_review_write",
20808
+ "push_files",
20809
+ "sub_issue_write",
20810
+ "update_pull_request",
20811
+ "update_pull_request_branch"
20812
+ ];
20813
+ var githubMcpToolNameSet = new Set(
20814
+ GITHUB_MCP_TOOL_NAMES
20815
+ );
20816
+ var githubMcpWriteToolSet = new Set(
20817
+ GITHUB_MCP_WRITE_TOOLS
20818
+ );
20819
+
20660
20820
  // ../../packages/schemas/src/secrets.ts
20661
20821
  var SECRET_ENCRYPTION_ALGORITHM = "AES-256-GCM";
20662
20822
  var SecretEnvNameSchema = external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/);
@@ -20831,6 +20991,14 @@ var GITHUB_MOUNT_CAPABILITY_LEVELS = [
20831
20991
  var GithubMountCapabilityLevelSchema = external_exports.enum(
20832
20992
  GITHUB_MOUNT_CAPABILITY_LEVELS
20833
20993
  );
20994
+ var DEFAULT_GITHUB_MOUNT_CAPABILITIES = {
20995
+ contents: "write",
20996
+ pullRequests: "write",
20997
+ issues: "write",
20998
+ checks: "read",
20999
+ actions: "read",
21000
+ workflows: "none"
21001
+ };
20834
21002
  var GitMountAuthSchema = external_exports.discriminatedUnion("kind", [
20835
21003
  external_exports.object({
20836
21004
  kind: external_exports.literal("none")
@@ -20851,14 +21019,7 @@ var GitMountAuthSchema = external_exports.discriminatedUnion("kind", [
20851
21019
  checks: GithubMountCapabilityLevelSchema.default("read"),
20852
21020
  actions: GithubMountCapabilityLevelSchema.default("read"),
20853
21021
  workflows: GithubMountCapabilityLevelSchema.default("none")
20854
- }).default({
20855
- contents: "write",
20856
- pullRequests: "write",
20857
- issues: "write",
20858
- checks: "read",
20859
- actions: "read",
20860
- workflows: "none"
20861
- })
21022
+ }).default({ ...DEFAULT_GITHUB_MOUNT_CAPABILITIES })
20862
21023
  })
20863
21024
  ]);
20864
21025
  var GitMountSchema = external_exports.object({
@@ -21009,6 +21170,11 @@ var LocalToolSchema = external_exports.discriminatedUnion(
21009
21170
  error: `Unsupported local tool implementation. Supported implementations: ${LOCAL_TOOL_IMPLEMENTATIONS.join(", ")}`
21010
21171
  }
21011
21172
  );
21173
+ var GithubToolSchema = external_exports.object({
21174
+ kind: external_exports.literal("github"),
21175
+ description: external_exports.string().trim().min(1).optional(),
21176
+ tools: external_exports.array(external_exports.enum(GITHUB_MCP_TOOL_NAMES)).min(1).optional()
21177
+ });
21012
21178
  var ToolSpecSchema = external_exports.discriminatedUnion("kind", [
21013
21179
  RemoteMcpToolSchema,
21014
21180
  LocalToolSchema
@@ -21058,6 +21224,10 @@ var InlineSessionToolSchema = RemoteMcpToolSchema.extend({
21058
21224
  disabled: external_exports.boolean().optional()
21059
21225
  })
21060
21226
  )
21227
+ ).or(
21228
+ GithubToolSchema.extend({
21229
+ disabled: external_exports.boolean().optional()
21230
+ })
21061
21231
  );
21062
21232
  var SessionToolRefSchema = InlineSessionToolSchema.or(
21063
21233
  ReferencedSessionToolRefSchema
@@ -21173,17 +21343,17 @@ var TriggerFilterScalarSchema = external_exports.union([
21173
21343
  external_exports.boolean()
21174
21344
  ]);
21175
21345
  var TriggerFilterPathSchema = external_exports.string().refine(
21176
- (path) => {
21177
- if (path.length === 0 || path.trim() !== path) {
21346
+ (path2) => {
21347
+ if (path2.length === 0 || path2.trim() !== path2) {
21178
21348
  return false;
21179
21349
  }
21180
- if (path.startsWith("$.")) {
21181
- const segments = path.slice(2).split(".");
21350
+ if (path2.startsWith("$.")) {
21351
+ const segments = path2.slice(2).split(".");
21182
21352
  return segments.length > 0 && segments.every(
21183
21353
  (segment) => segment.length > 0 && segment.trim() === segment
21184
21354
  );
21185
21355
  }
21186
- return !path.includes(".");
21356
+ return !path2.includes(".");
21187
21357
  },
21188
21358
  {
21189
21359
  message: "Trigger filter paths must be a single bare key or use $.path.segments"
@@ -21622,8 +21792,8 @@ function hasAutoAttributionsExists(trigger, expected) {
21622
21792
  function isChatMessageEvent(trigger) {
21623
21793
  return trigger.event.startsWith("chat.message.");
21624
21794
  }
21625
- function hasFilterValue(trigger, path, expected) {
21626
- return trigger.where?.[path] === expected;
21795
+ function hasFilterValue(trigger, path2, expected) {
21796
+ return trigger.where?.[path2] === expected;
21627
21797
  }
21628
21798
 
21629
21799
  // ../../packages/schemas/src/project-resources.ts
@@ -21786,6 +21956,281 @@ var RunDiagnosticEventSchema = external_exports.object({
21786
21956
  createdAt: external_exports.string().datetime()
21787
21957
  });
21788
21958
 
21959
+ // ../../packages/schemas/src/session-runs.ts
21960
+ var SESSION_RUN_STATUSES = [
21961
+ "queued",
21962
+ "running",
21963
+ "awaiting",
21964
+ "failed",
21965
+ "stopped"
21966
+ ];
21967
+ var SESSION_RUN_DISPLAY_TITLE_MAX_LENGTH = 64;
21968
+ var SessionRunStatusSchema = external_exports.enum(SESSION_RUN_STATUSES);
21969
+ var SessionRunDisplayTitleSchema = external_exports.string().trim().max(SESSION_RUN_DISPLAY_TITLE_MAX_LENGTH);
21970
+ var SESSION_RUN_CHECK_STATUSES = [
21971
+ "queued",
21972
+ "in_progress",
21973
+ "completed"
21974
+ ];
21975
+ var SESSION_RUN_CHECK_CONCLUSIONS = ["success", "failure"];
21976
+ var SESSION_RUN_CHECK_TIMEOUT_PHASES = ["begin", "complete"];
21977
+ var SessionRunCheckStatusSchema = external_exports.enum(SESSION_RUN_CHECK_STATUSES);
21978
+ var SessionRunCheckConclusionSchema = external_exports.enum(
21979
+ SESSION_RUN_CHECK_CONCLUSIONS
21980
+ );
21981
+ var SessionRunCheckTimeoutPhaseSchema = external_exports.enum(
21982
+ SESSION_RUN_CHECK_TIMEOUT_PHASES
21983
+ );
21984
+ var ManualSessionRunRequestSchema = external_exports.object({
21985
+ message: external_exports.string().trim().min(1).max(2e4).optional(),
21986
+ interactive: external_exports.boolean().optional()
21987
+ });
21988
+ var SessionRunArchiveRequestSchema = external_exports.object({
21989
+ archived: external_exports.boolean()
21990
+ });
21991
+ var SessionRunsArchiveRequestSchema = external_exports.object({
21992
+ run_ids: external_exports.array(SessionRunIdSchema2).min(1).max(100),
21993
+ archived: external_exports.boolean()
21994
+ });
21995
+ var SessionRunRecordSchema = external_exports.object({
21996
+ id: SessionRunIdSchema2,
21997
+ organizationId: external_exports.string().trim().min(1),
21998
+ projectId: external_exports.string().trim().min(1).nullable(),
21999
+ sessionId: SessionIdSchema,
22000
+ runtimeId: RuntimeIdSchema2.nullable(),
22001
+ status: SessionRunStatusSchema,
22002
+ idempotencyKey: external_exports.string().min(1).nullable(),
22003
+ correlationKey: external_exports.string().nullable(),
22004
+ workflowId: external_exports.string().min(1),
22005
+ displayTitle: SessionRunDisplayTitleSchema,
22006
+ starterActor: AuthActorSchema.nullable(),
22007
+ sessionSnapshot: SessionResourceSchema,
22008
+ profileSnapshot: ProfileResourceSchema,
22009
+ environmentSnapshot: EnvironmentResourceSchema,
22010
+ toolSnapshots: external_exports.array(
22011
+ external_exports.discriminatedUnion("source", [
22012
+ external_exports.object({
22013
+ source: external_exports.literal("inline"),
22014
+ alias: ToolAliasSchema,
22015
+ spec: RemoteMcpToolSchema.or(LocalToolSchema).or(GithubToolSchema)
22016
+ }),
22017
+ external_exports.object({
22018
+ source: external_exports.literal("resource"),
22019
+ alias: ToolAliasSchema,
22020
+ resource: ToolResourceSchema
22021
+ })
22022
+ ])
22023
+ ),
22024
+ input: JsonValueSchema2,
22025
+ createdAt: external_exports.string().datetime(),
22026
+ updatedAt: external_exports.string().datetime(),
22027
+ startedAt: external_exports.string().datetime().nullable(),
22028
+ finishedAt: external_exports.string().datetime().nullable(),
22029
+ archivedAt: external_exports.string().datetime().nullable(),
22030
+ error: JsonValueSchema2.nullable()
22031
+ });
22032
+ var SessionRunsArchiveResponseSchema = external_exports.object({
22033
+ archived: external_exports.boolean(),
22034
+ runs: external_exports.array(SessionRunRecordSchema)
22035
+ });
22036
+
22037
+ // ../../packages/schemas/src/run-introspection.ts
22038
+ var TruncatedValueSchema = external_exports.object({
22039
+ truncated: external_exports.literal(true),
22040
+ truncatedPreview: external_exports.string(),
22041
+ originalBytes: external_exports.number().int().nonnegative()
22042
+ });
22043
+ var RunConversationSearchSnippetSchema = external_exports.object({
22044
+ partIndex: external_exports.number().int().nonnegative(),
22045
+ partType: external_exports.string(),
22046
+ /** The search term this snippet was produced for. */
22047
+ query: external_exports.string(),
22048
+ text: external_exports.string()
22049
+ });
22050
+ var RunConversationSearchMatchSchema = external_exports.object({
22051
+ sequence: external_exports.number().int().nonnegative(),
22052
+ role: ConversationRoleSchema2,
22053
+ kind: ConversationEntryKindSchema2,
22054
+ status: ConversationEntryStatusSchema2,
22055
+ createdAt: external_exports.string().datetime(),
22056
+ /** Which of the requested terms matched this entry. */
22057
+ matchedQueries: external_exports.array(external_exports.string()),
22058
+ /** Total match occurrences across terms in this entry. */
22059
+ matchCount: external_exports.number().int().positive(),
22060
+ snippets: external_exports.array(RunConversationSearchSnippetSchema)
22061
+ });
22062
+ var RunConversationSearchResponseSchema = external_exports.object({
22063
+ matches: external_exports.array(RunConversationSearchMatchSchema),
22064
+ hasMore: external_exports.boolean(),
22065
+ /**
22066
+ * Sequence of the last candidate entry scanned (not just the last confirmed
22067
+ * match) — pass as `afterSequence` to continue without re-scanning
22068
+ * candidates the match confirmation dropped. Null when nothing was scanned.
22069
+ */
22070
+ nextAfterSequence: external_exports.number().int().nullable()
22071
+ });
22072
+ var RunToolExchangeSchema = external_exports.object({
22073
+ name: external_exports.string(),
22074
+ callSequence: external_exports.number().int().nonnegative(),
22075
+ resultSequence: external_exports.number().int().nonnegative().nullable(),
22076
+ input: JsonValueSchema2,
22077
+ output: JsonValueSchema2.nullable(),
22078
+ /** Null while the call has no recorded result. */
22079
+ isError: external_exports.boolean().nullable(),
22080
+ /** Result `completedAt` minus call `createdAt`; null without a result. */
22081
+ durationMs: external_exports.number().int().nonnegative().nullable(),
22082
+ startedAt: external_exports.string().datetime(),
22083
+ completedAt: external_exports.string().datetime().nullable()
22084
+ });
22085
+ var RunToolExchangesResponseSchema = external_exports.object({
22086
+ exchanges: external_exports.array(RunToolExchangeSchema),
22087
+ hasMore: external_exports.boolean(),
22088
+ /**
22089
+ * Sequence bounds of the entries window this page consumed (not just the
22090
+ * returned exchanges) — continue paging with `after`/`before` from these so
22091
+ * filtered-out entries are not re-scanned. Null when nothing was scanned.
22092
+ */
22093
+ nextAfterSequence: external_exports.number().int().nullable(),
22094
+ nextBeforeSequence: external_exports.number().int().nullable()
22095
+ });
22096
+ var RUN_TRIGGER_DELIVERY_ACTIONS = [
22097
+ "started",
22098
+ "signaled",
22099
+ "dropped",
22100
+ "warned",
22101
+ "errored"
22102
+ ];
22103
+ var RunTriggerDeliveryActionSchema = external_exports.enum(
22104
+ RUN_TRIGGER_DELIVERY_ACTIONS
22105
+ );
22106
+ var RUN_EVENT_ORIGIN_KINDS = [
22107
+ "internal",
22108
+ "provider_grant",
22109
+ "webhook"
22110
+ ];
22111
+ var RunEventOriginKindSchema = external_exports.enum(RUN_EVENT_ORIGIN_KINDS);
22112
+ var RunTriggerDeliveryRecordSchema = external_exports.object({
22113
+ action: RunTriggerDeliveryActionSchema,
22114
+ triggerId: external_exports.string(),
22115
+ eventKey: external_exports.string(),
22116
+ originKind: RunEventOriginKindSchema,
22117
+ occurredAt: external_exports.string().datetime(),
22118
+ receivedAt: external_exports.string().datetime(),
22119
+ deliveredAt: external_exports.string().datetime(),
22120
+ reason: external_exports.string().nullable(),
22121
+ /** Event payload; may be a {@link TruncatedValueSchema} marker. */
22122
+ payload: JsonValueSchema2.optional()
22123
+ });
22124
+ var RunTriggersResponseSchema = external_exports.object({
22125
+ /** The `started` delivery that spawned the run; null for manual/agent spawns. */
22126
+ spawn: RunTriggerDeliveryRecordSchema.nullable(),
22127
+ /** Who started the run, for manual/CLI/agent spawns. */
22128
+ starter: AuthActorSchema.nullable(),
22129
+ /** Subsequent deliveries against the run, chronological. */
22130
+ deliveries: external_exports.array(RunTriggerDeliveryRecordSchema)
22131
+ });
22132
+ var RunArtifactRecordSchema = external_exports.object({
22133
+ artifactType: external_exports.string(),
22134
+ externalId: external_exports.string(),
22135
+ payload: JsonValueSchema2,
22136
+ recordedAt: external_exports.string().datetime()
22137
+ });
22138
+ var RunArtifactsResponseSchema = external_exports.object({
22139
+ artifacts: external_exports.array(RunArtifactRecordSchema)
22140
+ });
22141
+ var RunTurnSchema = external_exports.object({
22142
+ startSequence: external_exports.number().int().nonnegative(),
22143
+ endSequence: external_exports.number().int().nonnegative(),
22144
+ startedAt: external_exports.string().datetime(),
22145
+ completedAt: external_exports.string().datetime().nullable(),
22146
+ toolCallCount: external_exports.number().int().nonnegative()
22147
+ });
22148
+ var RunToolStatSchema = external_exports.object({
22149
+ name: external_exports.string(),
22150
+ /** Run-wide call count from the SQL aggregate. */
22151
+ calls: external_exports.number().int().nonnegative(),
22152
+ /**
22153
+ * Derived from the summary's recent-entries window (most recent ~1000
22154
+ * entries), so on very long runs `errors` and `durationMs` can understate
22155
+ * relative to the run-wide `calls`.
22156
+ */
22157
+ errors: external_exports.number().int().nonnegative(),
22158
+ durationMs: external_exports.object({
22159
+ p50: external_exports.number().nonnegative().nullable(),
22160
+ max: external_exports.number().nonnegative().nullable()
22161
+ })
22162
+ });
22163
+ var RunSummarySchema = external_exports.object({
22164
+ run: external_exports.object({
22165
+ id: SessionRunIdSchema2,
22166
+ sessionName: external_exports.string(),
22167
+ profileName: external_exports.string(),
22168
+ displayTitle: external_exports.string(),
22169
+ status: SessionRunStatusSchema,
22170
+ error: JsonValueSchema2.nullable(),
22171
+ workflowId: external_exports.string(),
22172
+ createdAt: external_exports.string().datetime(),
22173
+ startedAt: external_exports.string().datetime().nullable(),
22174
+ finishedAt: external_exports.string().datetime().nullable(),
22175
+ archivedAt: external_exports.string().datetime().nullable()
22176
+ }),
22177
+ timing: external_exports.object({
22178
+ /** `startedAt - createdAt`; null until the run starts. */
22179
+ queuedMs: external_exports.number().int().nonnegative().nullable(),
22180
+ /** `(finishedAt ?? now) - startedAt`; null until the run starts. */
22181
+ activeMs: external_exports.number().int().nonnegative().nullable(),
22182
+ /** `(finishedAt ?? now) - createdAt`. */
22183
+ totalMs: external_exports.number().int().nonnegative()
22184
+ }),
22185
+ conversation: external_exports.object({
22186
+ entryCount: external_exports.number().int().nonnegative(),
22187
+ firstEntryAt: external_exports.string().datetime().nullable(),
22188
+ lastEntryAt: external_exports.string().datetime().nullable(),
22189
+ countsByKind: external_exports.object({
22190
+ status: external_exports.number().int().nonnegative(),
22191
+ message: external_exports.number().int().nonnegative(),
22192
+ tool_call: external_exports.number().int().nonnegative(),
22193
+ tool_result: external_exports.number().int().nonnegative(),
22194
+ question: external_exports.number().int().nonnegative()
22195
+ }),
22196
+ failedEntryCount: external_exports.number().int().nonnegative(),
22197
+ lastSequence: external_exports.number().int().nonnegative()
22198
+ }),
22199
+ tools: external_exports.array(RunToolStatSchema),
22200
+ /**
22201
+ * True when the run has more conversation entries than the summary's
22202
+ * recent-entries window, meaning per-tool `errors`/`durationMs` (and
22203
+ * `turns`) describe only the most recent slice of the run.
22204
+ */
22205
+ toolStatsWindowed: external_exports.boolean(),
22206
+ trigger: external_exports.object({
22207
+ /** Spawning event key, or "manual" / "agent" for actor-started runs. */
22208
+ spawn: external_exports.string(),
22209
+ signaledCount: external_exports.number().int().nonnegative(),
22210
+ droppedCount: external_exports.number().int().nonnegative()
22211
+ }),
22212
+ artifacts: external_exports.object({
22213
+ count: external_exports.number().int().nonnegative(),
22214
+ types: external_exports.array(external_exports.string())
22215
+ }),
22216
+ /** Derived per-user-message turns, capped to the most recent. */
22217
+ turns: external_exports.array(RunTurnSchema),
22218
+ commands: external_exports.object({
22219
+ total: external_exports.number().int().nonnegative(),
22220
+ byKind: external_exports.record(external_exports.string(), external_exports.number().int().nonnegative()),
22221
+ failed: external_exports.number().int().nonnegative()
22222
+ }),
22223
+ checks: external_exports.array(
22224
+ external_exports.object({
22225
+ name: external_exports.string(),
22226
+ displayName: external_exports.string(),
22227
+ status: SessionRunCheckStatusSchema,
22228
+ conclusion: SessionRunCheckConclusionSchema.nullable(),
22229
+ completedAt: external_exports.string().datetime().nullable()
22230
+ })
22231
+ )
22232
+ });
22233
+
21789
22234
  // ../../packages/schemas/src/session-run-commands.ts
21790
22235
  var SESSION_RUN_COMMAND_KINDS = [
21791
22236
  "message",
@@ -22084,84 +22529,6 @@ var RunCommandDispatchSignalPayloadSchema = external_exports.object({
22084
22529
  }).strict();
22085
22530
  var RealtimeRunCursorSchema = external_exports.string().regex(/^rt:(0|[1-9]\d*)$/);
22086
22531
 
22087
- // ../../packages/schemas/src/session-runs.ts
22088
- var SESSION_RUN_STATUSES = [
22089
- "queued",
22090
- "running",
22091
- "awaiting",
22092
- "failed",
22093
- "stopped"
22094
- ];
22095
- var SESSION_RUN_DISPLAY_TITLE_MAX_LENGTH = 64;
22096
- var SessionRunStatusSchema = external_exports.enum(SESSION_RUN_STATUSES);
22097
- var SessionRunDisplayTitleSchema = external_exports.string().trim().max(SESSION_RUN_DISPLAY_TITLE_MAX_LENGTH);
22098
- var SESSION_RUN_CHECK_STATUSES = [
22099
- "queued",
22100
- "in_progress",
22101
- "completed"
22102
- ];
22103
- var SESSION_RUN_CHECK_CONCLUSIONS = ["success", "failure"];
22104
- var SESSION_RUN_CHECK_TIMEOUT_PHASES = ["begin", "complete"];
22105
- var SessionRunCheckStatusSchema = external_exports.enum(SESSION_RUN_CHECK_STATUSES);
22106
- var SessionRunCheckConclusionSchema = external_exports.enum(
22107
- SESSION_RUN_CHECK_CONCLUSIONS
22108
- );
22109
- var SessionRunCheckTimeoutPhaseSchema = external_exports.enum(
22110
- SESSION_RUN_CHECK_TIMEOUT_PHASES
22111
- );
22112
- var ManualSessionRunRequestSchema = external_exports.object({
22113
- message: external_exports.string().trim().min(1).max(2e4).optional(),
22114
- interactive: external_exports.boolean().optional()
22115
- });
22116
- var SessionRunArchiveRequestSchema = external_exports.object({
22117
- archived: external_exports.boolean()
22118
- });
22119
- var SessionRunsArchiveRequestSchema = external_exports.object({
22120
- run_ids: external_exports.array(SessionRunIdSchema2).min(1).max(100),
22121
- archived: external_exports.boolean()
22122
- });
22123
- var SessionRunRecordSchema = external_exports.object({
22124
- id: SessionRunIdSchema2,
22125
- organizationId: external_exports.string().trim().min(1),
22126
- projectId: external_exports.string().trim().min(1).nullable(),
22127
- sessionId: SessionIdSchema,
22128
- runtimeId: RuntimeIdSchema2.nullable(),
22129
- status: SessionRunStatusSchema,
22130
- idempotencyKey: external_exports.string().min(1).nullable(),
22131
- correlationKey: external_exports.string().nullable(),
22132
- workflowId: external_exports.string().min(1),
22133
- displayTitle: SessionRunDisplayTitleSchema,
22134
- starterActor: AuthActorSchema.nullable(),
22135
- sessionSnapshot: SessionResourceSchema,
22136
- profileSnapshot: ProfileResourceSchema,
22137
- environmentSnapshot: EnvironmentResourceSchema,
22138
- toolSnapshots: external_exports.array(
22139
- external_exports.discriminatedUnion("source", [
22140
- external_exports.object({
22141
- source: external_exports.literal("inline"),
22142
- alias: ToolAliasSchema,
22143
- spec: RemoteMcpToolSchema.or(LocalToolSchema)
22144
- }),
22145
- external_exports.object({
22146
- source: external_exports.literal("resource"),
22147
- alias: ToolAliasSchema,
22148
- resource: ToolResourceSchema
22149
- })
22150
- ])
22151
- ),
22152
- input: JsonValueSchema2,
22153
- createdAt: external_exports.string().datetime(),
22154
- updatedAt: external_exports.string().datetime(),
22155
- startedAt: external_exports.string().datetime().nullable(),
22156
- finishedAt: external_exports.string().datetime().nullable(),
22157
- archivedAt: external_exports.string().datetime().nullable(),
22158
- error: JsonValueSchema2.nullable()
22159
- });
22160
- var SessionRunsArchiveResponseSchema = external_exports.object({
22161
- archived: external_exports.boolean(),
22162
- runs: external_exports.array(SessionRunRecordSchema)
22163
- });
22164
-
22165
22532
  // ../../packages/schemas/src/temporal.ts
22166
22533
  var ResourceReconciliationScopeSchema = external_exports.object({
22167
22534
  organizationId: external_exports.string().trim().min(1),
@@ -23481,12 +23848,12 @@ function parse4(str) {
23481
23848
  uri.queryKey = queryKey(uri, uri["query"]);
23482
23849
  return uri;
23483
23850
  }
23484
- function pathNames(obj, path) {
23485
- const regx = /\/{2,9}/g, names = path.replace(regx, "/").split("/");
23486
- if (path.slice(0, 1) == "/" || path.length === 0) {
23851
+ function pathNames(obj, path2) {
23852
+ const regx = /\/{2,9}/g, names = path2.replace(regx, "/").split("/");
23853
+ if (path2.slice(0, 1) == "/" || path2.length === 0) {
23487
23854
  names.splice(0, 1);
23488
23855
  }
23489
- if (path.slice(-1) == "/") {
23856
+ if (path2.slice(-1) == "/") {
23490
23857
  names.splice(names.length - 1, 1);
23491
23858
  }
23492
23859
  return names;
@@ -24103,7 +24470,7 @@ var protocol2 = Socket.protocol;
24103
24470
  // ../../node_modules/socket.io-client/build/esm-debug/url.js
24104
24471
  var import_debug7 = __toESM(require_src(), 1);
24105
24472
  var debug7 = (0, import_debug7.default)("socket.io-client:url");
24106
- function url2(uri, path = "", loc) {
24473
+ function url2(uri, path2 = "", loc) {
24107
24474
  let obj = uri;
24108
24475
  loc = loc || typeof location !== "undefined" && location;
24109
24476
  if (null == uri)
@@ -24137,7 +24504,7 @@ function url2(uri, path = "", loc) {
24137
24504
  obj.path = obj.path || "/";
24138
24505
  const ipv63 = obj.host.indexOf(":") !== -1;
24139
24506
  const host = ipv63 ? "[" + obj.host + "]" : obj.host;
24140
- obj.id = obj.protocol + "://" + host + ":" + obj.port + path;
24507
+ obj.id = obj.protocol + "://" + host + ":" + obj.port + path2;
24141
24508
  obj.href = obj.protocol + "://" + host + (loc && loc.port === obj.port ? "" : ":" + obj.port);
24142
24509
  return obj;
24143
24510
  }
@@ -25768,8 +26135,8 @@ function lookup(uri, opts) {
25768
26135
  const parsed = url2(uri, opts.path || "/socket.io");
25769
26136
  const source = parsed.source;
25770
26137
  const id = parsed.id;
25771
- const path = parsed.path;
25772
- const sameNamespace = cache[id] && path in cache[id]["nsps"];
26138
+ const path2 = parsed.path;
26139
+ const sameNamespace = cache[id] && path2 in cache[id]["nsps"];
25773
26140
  const newConnection = opts.forceNew || opts["force new connection"] || false === opts.multiplex || sameNamespace;
25774
26141
  let io;
25775
26142
  if (newConnection) {
@@ -25837,6 +26204,7 @@ async function runAgentBridgeSocket(options) {
25837
26204
  RUNTIME_BRIDGE_BOOTSTRAP_EVENT,
25838
26205
  createRuntimeBridgeBootstrapListener({
25839
26206
  token: options.token,
26207
+ onBootstrap: options.onBootstrap,
25840
26208
  createHandler: (bootstrap) => options.createHandler({
25841
26209
  emitOutput: (output) => emitOutputWithAck(socket, output),
25842
26210
  claude: bootstrap.claude,
@@ -25935,6 +26303,7 @@ function createRuntimeBridgeBootstrapListener(input) {
25935
26303
  input.writeOutput?.(
25936
26304
  `agent_bridge_bootstrap_decrypted duration_ms=${Date.now() - decryptStartedAt}`
25937
26305
  );
26306
+ await input.onBootstrap?.(bootstrap);
25938
26307
  let handler = input.getHandler();
25939
26308
  if (!handler) {
25940
26309
  handler = input.createHandler(bootstrap);
@@ -46342,21 +46711,21 @@ import { existsSync as existsSync2, mkdirSync as mkdirSync2, readFileSync as rea
46342
46711
  import { dirname } from "path";
46343
46712
  var AGENT_BRIDGE_RUNTIME_DIR = "/tmp/auto-bridge-runtime";
46344
46713
  var CLAUDE_SESSION_RESUME_PATH = `${AGENT_BRIDGE_RUNTIME_DIR}/claude-session-id`;
46345
- function fileClaudeSessionResumeStore(path = CLAUDE_SESSION_RESUME_PATH) {
46714
+ function fileClaudeSessionResumeStore(path2 = CLAUDE_SESSION_RESUME_PATH) {
46346
46715
  return {
46347
46716
  read(runId) {
46348
- if (!existsSync2(path)) {
46717
+ if (!existsSync2(path2)) {
46349
46718
  return null;
46350
46719
  }
46351
- const record2 = parseResumeRecord(readFileSync2(path, "utf8"));
46720
+ const record2 = parseResumeRecord(readFileSync2(path2, "utf8"));
46352
46721
  if (!record2 || record2.runId !== runId) {
46353
46722
  return null;
46354
46723
  }
46355
46724
  return record2.sessionId;
46356
46725
  },
46357
46726
  write(record2) {
46358
- mkdirSync2(dirname(path), { recursive: true });
46359
- writeFileSync(path, `${JSON.stringify(record2)}
46727
+ mkdirSync2(dirname(path2), { recursive: true });
46728
+ writeFileSync(path2, `${JSON.stringify(record2)}
46360
46729
  `, "utf8");
46361
46730
  }
46362
46731
  };
@@ -46725,7 +47094,10 @@ function deliveryMessage(delivery) {
46725
47094
  // src/commands/agent-bridge/entrypoint.ts
46726
47095
  async function runAgentBridgeProcess(input) {
46727
47096
  const runAgentBridge = input.runAgentBridge ?? runAgentBridgeClaudeCode;
46728
- await runAgentBridge(agentBridgeOptionsFromEnv(input));
47097
+ await runAgentBridge({
47098
+ ...agentBridgeOptionsFromEnv(input),
47099
+ onBootstrap: createGitCredentialRelayStarter(input.writeOutput)
47100
+ });
46729
47101
  }
46730
47102
  function agentBridgeOptionsFromEnv(input) {
46731
47103
  return {
@@ -46734,6 +47106,37 @@ function agentBridgeOptionsFromEnv(input) {
46734
47106
  writeOutput: input.writeOutput
46735
47107
  };
46736
47108
  }
47109
+ function createGitCredentialRelayStarter(writeOutput) {
47110
+ let relay;
47111
+ let startup;
47112
+ return async (bootstrap) => {
47113
+ const gitCredentials = bootstrap.gitCredentials;
47114
+ if (!gitCredentials) {
47115
+ return;
47116
+ }
47117
+ if (relay) {
47118
+ relay.update(gitCredentials);
47119
+ return;
47120
+ }
47121
+ if (startup) {
47122
+ const started = await startup;
47123
+ started?.update(gitCredentials);
47124
+ return;
47125
+ }
47126
+ startup = startGitCredentialRelay(gitCredentials).then((started) => {
47127
+ relay = started;
47128
+ writeOutput?.(`agent_bridge_git_credential_relay port=${started.port}`);
47129
+ return started;
47130
+ }).catch((error51) => {
47131
+ startup = void 0;
47132
+ writeOutput?.(
47133
+ `agent_bridge_git_credential_relay_failed error=${error51 instanceof Error ? error51.message : String(error51)}`
47134
+ );
47135
+ return void 0;
47136
+ });
47137
+ await startup;
47138
+ };
47139
+ }
46737
47140
  function requiredEnv(env, key) {
46738
47141
  const value2 = env[key]?.trim();
46739
47142
  if (!value2) {