@autohq/cli 0.1.472 → 0.1.474

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.
@@ -12176,6 +12176,7 @@ import { createServer } from "http";
12176
12176
  import { homedir } from "os";
12177
12177
  import path from "path";
12178
12178
  var RELAY_PATH = "/git-credential";
12179
+ var GIT_CREDENTIAL_BROKER_TIMEOUT_MS = 24e3;
12179
12180
  function defaultGitCredentialPortFilePath() {
12180
12181
  return path.join(homedir(), ".auto", "agent-bridge", "git-credential.json");
12181
12182
  }
@@ -12192,20 +12193,30 @@ async function startGitCredentialRelay(input) {
12192
12193
  request.on("end", () => {
12193
12194
  void (async () => {
12194
12195
  try {
12195
- const upstream = await fetchImpl(target.url, {
12196
- method: "POST",
12197
- headers: {
12198
- authorization: `Bearer ${target.accessToken}`,
12199
- "content-type": "application/json"
12196
+ const requestTimeoutMs = input.requestTimeoutMs ?? GIT_CREDENTIAL_BROKER_TIMEOUT_MS;
12197
+ const upstream = await fetchWithTimeout({
12198
+ fetchImpl,
12199
+ url: target.url,
12200
+ init: {
12201
+ method: "POST",
12202
+ headers: {
12203
+ authorization: `Bearer ${target.accessToken}`,
12204
+ "content-type": "application/json"
12205
+ },
12206
+ body: Buffer.concat(chunks).toString("utf8") || "{}"
12200
12207
  },
12201
- body: Buffer.concat(chunks).toString("utf8") || "{}"
12208
+ timeoutMs: requestTimeoutMs,
12209
+ message: `git credential broker request timed out after ${requestTimeoutMs}ms`
12202
12210
  });
12203
12211
  const body = await upstream.text();
12204
12212
  response.writeHead(upstream.status, {
12205
12213
  "content-type": upstream.headers.get("content-type") ?? "application/json"
12206
12214
  }).end(body);
12207
12215
  } catch (error51) {
12208
- response.writeHead(502, { "content-type": "application/json" }).end(
12216
+ const timedOut = error51 instanceof GitCredentialRequestTimeoutError;
12217
+ response.writeHead(timedOut ? 504 : 502, {
12218
+ "content-type": "application/json"
12219
+ }).end(
12209
12220
  JSON.stringify({
12210
12221
  error: error51 instanceof Error ? error51.message : String(error51)
12211
12222
  })
@@ -12238,6 +12249,35 @@ async function startGitCredentialRelay(input) {
12238
12249
  })
12239
12250
  };
12240
12251
  }
12252
+ var GitCredentialRequestTimeoutError = class extends Error {
12253
+ constructor(message) {
12254
+ super(message);
12255
+ this.name = "GitCredentialRequestTimeoutError";
12256
+ }
12257
+ };
12258
+ async function fetchWithTimeout(input) {
12259
+ const controller = new AbortController();
12260
+ let timer;
12261
+ const timeout = new Promise((_resolve, reject) => {
12262
+ timer = setTimeout(() => {
12263
+ controller.abort();
12264
+ reject(new GitCredentialRequestTimeoutError(input.message));
12265
+ }, input.timeoutMs);
12266
+ });
12267
+ try {
12268
+ return await Promise.race([
12269
+ input.fetchImpl(input.url, {
12270
+ ...input.init,
12271
+ signal: controller.signal
12272
+ }),
12273
+ timeout
12274
+ ]);
12275
+ } finally {
12276
+ if (timer) {
12277
+ clearTimeout(timer);
12278
+ }
12279
+ }
12280
+ }
12241
12281
 
12242
12282
  // ../../node_modules/zod/v4/classic/external.js
12243
12283
  var external_exports = {};
@@ -30826,7 +30866,7 @@ Object.assign(lookup, {
30826
30866
  // package.json
30827
30867
  var package_default = {
30828
30868
  name: "@autohq/cli",
30829
- version: "0.1.472",
30869
+ version: "0.1.474",
30830
30870
  license: "SEE LICENSE IN README.md",
30831
30871
  publishConfig: {
30832
30872
  access: "public"
package/dist/index.js CHANGED
@@ -22338,6 +22338,13 @@ var init_setup = __esm({
22338
22338
  }
22339
22339
  });
22340
22340
 
22341
+ // ../../packages/schemas/src/requester-accounting.ts
22342
+ var init_requester_accounting = __esm({
22343
+ "../../packages/schemas/src/requester-accounting.ts"() {
22344
+ "use strict";
22345
+ }
22346
+ });
22347
+
22341
22348
  // ../../packages/schemas/src/runtime-log.ts
22342
22349
  function parseRuntimeLogLevel(value) {
22343
22350
  const parsed = RuntimeLogLevelSchema.safeParse(value?.trim());
@@ -53808,6 +53815,7 @@ var init_src = __esm({
53808
53815
  init_pool_replace();
53809
53816
  init_requester();
53810
53817
  init_requester_spend();
53818
+ init_requester_accounting();
53811
53819
  init_runtime_log();
53812
53820
  init_runtime_log_tailer();
53813
53821
  init_runtime_restart_diagnostics();
@@ -56581,7 +56589,7 @@ var init_package = __esm({
56581
56589
  "package.json"() {
56582
56590
  package_default = {
56583
56591
  name: "@autohq/cli",
56584
- version: "0.1.472",
56592
+ version: "0.1.474",
56585
56593
  license: "SEE LICENSE IN README.md",
56586
56594
  publishConfig: {
56587
56595
  access: "public"
@@ -66953,6 +66961,8 @@ import { createServer as createServer2 } from "http";
66953
66961
  import { homedir as homedir2 } from "os";
66954
66962
  import path from "path";
66955
66963
  var RELAY_PATH = "/git-credential";
66964
+ var GIT_CREDENTIAL_BROKER_TIMEOUT_MS = 24e3;
66965
+ var GIT_CREDENTIAL_RELAY_TIMEOUT_MS = 26e3;
66956
66966
  function defaultGitCredentialPortFilePath() {
66957
66967
  return path.join(homedir2(), ".auto", "agent-bridge", "git-credential.json");
66958
66968
  }
@@ -66969,20 +66979,30 @@ async function startGitCredentialRelay(input) {
66969
66979
  request.on("end", () => {
66970
66980
  void (async () => {
66971
66981
  try {
66972
- const upstream = await fetchImpl(target.url, {
66973
- method: "POST",
66974
- headers: {
66975
- authorization: `Bearer ${target.accessToken}`,
66976
- "content-type": "application/json"
66982
+ const requestTimeoutMs = input.requestTimeoutMs ?? GIT_CREDENTIAL_BROKER_TIMEOUT_MS;
66983
+ const upstream = await fetchWithTimeout({
66984
+ fetchImpl,
66985
+ url: target.url,
66986
+ init: {
66987
+ method: "POST",
66988
+ headers: {
66989
+ authorization: `Bearer ${target.accessToken}`,
66990
+ "content-type": "application/json"
66991
+ },
66992
+ body: Buffer.concat(chunks).toString("utf8") || "{}"
66977
66993
  },
66978
- body: Buffer.concat(chunks).toString("utf8") || "{}"
66994
+ timeoutMs: requestTimeoutMs,
66995
+ message: `git credential broker request timed out after ${requestTimeoutMs}ms`
66979
66996
  });
66980
66997
  const body = await upstream.text();
66981
66998
  response.writeHead(upstream.status, {
66982
66999
  "content-type": upstream.headers.get("content-type") ?? "application/json"
66983
67000
  }).end(body);
66984
67001
  } catch (error51) {
66985
- response.writeHead(502, { "content-type": "application/json" }).end(
67002
+ const timedOut = error51 instanceof GitCredentialRequestTimeoutError;
67003
+ response.writeHead(timedOut ? 504 : 502, {
67004
+ "content-type": "application/json"
67005
+ }).end(
66986
67006
  JSON.stringify({
66987
67007
  error: error51 instanceof Error ? error51.message : String(error51)
66988
67008
  })
@@ -67040,17 +67060,21 @@ async function runGitCredentialHelper(input) {
67040
67060
  input.writeError("git credential relay port file is malformed");
67041
67061
  return 1;
67042
67062
  }
67043
- const response = await (input.fetchImpl ?? fetch)(
67044
- `http://127.0.0.1:${portFile.port}${RELAY_PATH}`,
67045
- {
67063
+ const requestTimeoutMs = input.requestTimeoutMs ?? GIT_CREDENTIAL_RELAY_TIMEOUT_MS;
67064
+ const response = await fetchWithTimeout({
67065
+ fetchImpl: input.fetchImpl ?? fetch,
67066
+ url: `http://127.0.0.1:${portFile.port}${RELAY_PATH}`,
67067
+ init: {
67046
67068
  method: "POST",
67047
67069
  headers: { "content-type": "application/json" },
67048
67070
  body: JSON.stringify({
67049
67071
  host: attributes.host,
67050
67072
  ...attributes.path ? { path: attributes.path } : {}
67051
67073
  })
67052
- }
67053
- );
67074
+ },
67075
+ timeoutMs: requestTimeoutMs,
67076
+ message: `git credential relay request timed out after ${requestTimeoutMs}ms`
67077
+ });
67054
67078
  if (!response.ok) {
67055
67079
  input.writeError(
67056
67080
  `git credential broker rejected the request: ${response.status}`
@@ -67074,6 +67098,35 @@ async function runGitCredentialHelper(input) {
67074
67098
  return 1;
67075
67099
  }
67076
67100
  }
67101
+ var GitCredentialRequestTimeoutError = class extends Error {
67102
+ constructor(message) {
67103
+ super(message);
67104
+ this.name = "GitCredentialRequestTimeoutError";
67105
+ }
67106
+ };
67107
+ async function fetchWithTimeout(input) {
67108
+ const controller = new AbortController();
67109
+ let timer;
67110
+ const timeout = new Promise((_resolve, reject) => {
67111
+ timer = setTimeout(() => {
67112
+ controller.abort();
67113
+ reject(new GitCredentialRequestTimeoutError(input.message));
67114
+ }, input.timeoutMs);
67115
+ });
67116
+ try {
67117
+ return await Promise.race([
67118
+ input.fetchImpl(input.url, {
67119
+ ...input.init,
67120
+ signal: controller.signal
67121
+ }),
67122
+ timeout
67123
+ ]);
67124
+ } finally {
67125
+ if (timer) {
67126
+ clearTimeout(timer);
67127
+ }
67128
+ }
67129
+ }
67077
67130
  function parseGitCredentialAttributes(raw) {
67078
67131
  const attributes = {};
67079
67132
  for (const line of raw.split("\n")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autohq/cli",
3
- "version": "0.1.472",
3
+ "version": "0.1.474",
4
4
  "license": "SEE LICENSE IN README.md",
5
5
  "publishConfig": {
6
6
  "access": "public"