@gitterm/sdk 0.9.0 → 0.11.0

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/client.d.ts CHANGED
@@ -70,9 +70,13 @@ export type GittermClient = {
70
70
  listProviders(): Promise<ModelProviderInfo[]>;
71
71
  };
72
72
  bots: {
73
- /** Claims (or renews) the right to run this saved bot; one process at a time. */
73
+ /**
74
+ * Claims (or renews) the right to run this saved bot; one process at a time. `updatedAt` is
75
+ * when its saved settings last changed (absent from older servers).
76
+ */
74
77
  acquireLease(leaseId: string): Promise<{
75
78
  success: true;
79
+ updatedAt?: string;
76
80
  }>;
77
81
  releaseLease(leaseId: string): Promise<{
78
82
  success: true;
@@ -2177,12 +2177,12 @@ var WORKSPACE_LIFECYCLE_ERROR_CODES = [
2177
2177
 
2178
2178
  class GittermError extends Error {
2179
2179
  code;
2180
- cause;
2180
+ status;
2181
2181
  constructor(code, message, options = {}) {
2182
- super(message);
2182
+ super(message, "cause" in options ? { cause: options.cause } : undefined);
2183
2183
  this.name = "GittermError";
2184
2184
  this.code = code;
2185
- this.cause = options.cause;
2185
+ this.status = options.status;
2186
2186
  }
2187
2187
  }
2188
2188
 
package/dist/errors.d.ts CHANGED
@@ -5,15 +5,18 @@ export type WorkspaceLifecycleErrorCode = "WORKSPACE_NOT_RUNNING" | "WORKSPACE_T
5
5
  export declare const WORKSPACE_LIFECYCLE_ERROR_CODES: readonly WorkspaceLifecycleErrorCode[];
6
6
  export declare class GittermError extends Error {
7
7
  readonly code: GittermErrorCode;
8
- readonly cause?: unknown;
8
+ /** HTTP status of the API response; undefined when the server never answered. */
9
+ readonly status: number | undefined;
9
10
  constructor(code: GittermErrorCode, message: string, options?: {
10
11
  cause?: unknown;
12
+ status?: number;
11
13
  });
12
14
  }
13
15
  export declare class WorkspaceLifecycleError extends GittermError {
14
16
  readonly code: WorkspaceLifecycleErrorCode;
15
17
  constructor(code: WorkspaceLifecycleErrorCode, message: string, options?: {
16
18
  cause?: unknown;
19
+ status?: number;
17
20
  });
18
21
  }
19
22
  /** result() could not produce a successful result. The run remains inspectable. */
package/dist/index.js CHANGED
@@ -68,12 +68,12 @@ var WORKSPACE_LIFECYCLE_ERROR_CODES = [
68
68
 
69
69
  class GittermError extends Error {
70
70
  code;
71
- cause;
71
+ status;
72
72
  constructor(code, message, options = {}) {
73
- super(message);
73
+ super(message, "cause" in options ? { cause: options.cause } : undefined);
74
74
  this.name = "GittermError";
75
75
  this.code = code;
76
- this.cause = options.cause;
76
+ this.status = options.status;
77
77
  }
78
78
  }
79
79
 
@@ -426,27 +426,26 @@ function toGittermError(serverUrl, error) {
426
426
  return error;
427
427
  if (error instanceof TRPCClientError) {
428
428
  const data = error.data;
429
- const trpcCode = data?.code;
430
- if (!error.data) {
429
+ if (!data) {
431
430
  return new GittermError("NETWORK", `Could not reach the GitTerm server at ${serverUrl}`, {
432
- cause: error
431
+ cause: error.cause ?? error
433
432
  });
434
433
  }
435
- const code = mapTrpcCode(trpcCode);
436
- const structuredLifecycleCode = WORKSPACE_LIFECYCLE_ERROR_CODES.find((candidate) => candidate === data?.workspaceLifecycleCode);
434
+ const status = { status: data.httpStatus };
435
+ const structuredLifecycleCode = WORKSPACE_LIFECYCLE_ERROR_CODES.find((candidate) => candidate === data.workspaceLifecycleCode);
437
436
  if (structuredLifecycleCode) {
438
- return new WorkspaceLifecycleError(structuredLifecycleCode, error.message, { cause: error });
437
+ return new WorkspaceLifecycleError(structuredLifecycleCode, error.message, status);
439
438
  }
440
439
  if (error.message.startsWith("INPUT_NOT_PENDING:"))
441
- return new GittermError("INPUT_NOT_PENDING", error.message, { cause: error });
440
+ return new GittermError("INPUT_NOT_PENDING", error.message, status);
442
441
  const credentialCode = credentialErrorCode(error.message);
443
442
  if (credentialCode)
444
- return new GittermError(credentialCode, error.message, { cause: error });
443
+ return new GittermError(credentialCode, error.message, status);
445
444
  const lifecycleCode = WORKSPACE_LIFECYCLE_ERROR_CODES.find((candidate) => error.message.startsWith(`${candidate}:`));
446
- if (lifecycleCode) {
447
- return new WorkspaceLifecycleError(lifecycleCode, error.message, { cause: error });
448
- }
449
- return new GittermError(code, code === "UNAUTHORIZED" ? `Authentication failed: ${error.message}. Check that the API token is valid and has not expired.` : error.message, { cause: error });
445
+ if (lifecycleCode)
446
+ return new WorkspaceLifecycleError(lifecycleCode, error.message, status);
447
+ const code = mapTrpcCode(data.code);
448
+ return new GittermError(code, code === "UNAUTHORIZED" ? `${error.message}. Check your GitTerm API token, or create a new one in the dashboard.` : error.message, status);
450
449
  }
451
450
  return new GittermError("NETWORK", error instanceof Error ? error.message : "Network request failed", { cause: error });
452
451
  }
package/dist/types.d.ts CHANGED
@@ -62,6 +62,7 @@ export type RunRef = {
62
62
  id: string;
63
63
  };
64
64
  export type WaitOptions = {
65
+ /** For `ensureRunning` the server maximum is 240000 (4 minutes). */
65
66
  timeoutMs?: number;
66
67
  pollIntervalMs?: number;
67
68
  /** Abort the wait early; the promise rejects with code `ABORTED`. */
@@ -262,7 +263,7 @@ export type McpConnectionDetails = {
262
263
  revision?: number;
263
264
  integration: "mcp" | "executor";
264
265
  url: string;
265
- authType: "none" | "headers";
266
+ authType: "none" | "bearer" | "headers";
266
267
  codemode: boolean;
267
268
  toolCount: number | null;
268
269
  serverInfo: {
@@ -773,5 +774,7 @@ export type SavedBot = {
773
774
  instructions: string | null;
774
775
  /** A command run in the checkout before the agent starts in a new sandbox. */
775
776
  setup: string | null;
777
+ /** When the settings last changed (ISO 8601); absent from older servers. */
778
+ updatedAt?: string;
776
779
  };
777
780
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gitterm/sdk",
3
- "version": "0.9.0",
3
+ "version": "0.11.0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],