@kilocode/sdk 7.3.28 → 7.3.29

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.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./gen/types.gen.js";
2
2
  import { createClient } from "./gen/client/client.gen.js";
3
3
  import { KiloClient } from "./gen/sdk.gen.js";
4
+ import { wrapClientError } from "./error-interceptor.js";
4
5
  export { KiloClient };
5
6
  function pick(value, fallback) {
6
7
  if (!value)
@@ -56,5 +57,6 @@ export function createKiloClient(config) {
56
57
  config.duplex = "half";
57
58
  const client = createClient(config);
58
59
  client.interceptors.request.use((request) => rewrite(request, config?.directory));
60
+ client.interceptors.error.use(wrapClientError);
59
61
  return new KiloClient({ client });
60
62
  }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Wrap whatever the generated client decoded from a non-2xx error body
3
+ * into a real `Error` so downstream formatters (TUI, plugins) get a
4
+ * useful `.message` instead of `[object Object]` or blank. The original
5
+ * parsed body and status live under `.cause` for callers that need
6
+ * structured fields.
7
+ *
8
+ * Only fires when the caller used `{ throwOnError: true }`. Callers that
9
+ * read `result.error` directly (the result-tuple path) get the parsed
10
+ * body unchanged so existing field-level reads (`.error.name`,
11
+ * `JSON.stringify(error)`, etc.) are byte-for-byte identical to before.
12
+ */
13
+ export declare function wrapClientError(error: unknown, response: Response | undefined, request: Request | undefined, opts: {
14
+ throwOnError?: boolean;
15
+ } | undefined): unknown;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Wrap whatever the generated client decoded from a non-2xx error body
3
+ * into a real `Error` so downstream formatters (TUI, plugins) get a
4
+ * useful `.message` instead of `[object Object]` or blank. The original
5
+ * parsed body and status live under `.cause` for callers that need
6
+ * structured fields.
7
+ *
8
+ * Only fires when the caller used `{ throwOnError: true }`. Callers that
9
+ * read `result.error` directly (the result-tuple path) get the parsed
10
+ * body unchanged so existing field-level reads (`.error.name`,
11
+ * `JSON.stringify(error)`, etc.) are byte-for-byte identical to before.
12
+ */
13
+ export function wrapClientError(error, response, request, opts) {
14
+ if (!opts?.throwOnError)
15
+ return error;
16
+ if (error instanceof Error)
17
+ return error;
18
+ // NamedError-shaped responses (the common case for opencode 4xx) come
19
+ // through as POJOs — extract a useful message first, then wrap.
20
+ if (typeof error === "object" && error !== null && Object.keys(error).length > 0) {
21
+ const obj = error;
22
+ const message = (typeof obj.data?.message === "string" && obj.data.message) ||
23
+ (typeof obj.message === "string" && obj.message) ||
24
+ (typeof obj.name === "string" && obj.name) ||
25
+ describe(request, response);
26
+ return new Error(message, { cause: { body: error, status: response?.status } });
27
+ }
28
+ if (typeof error === "string" && error.length > 0) {
29
+ return new Error(error, { cause: { body: error, status: response?.status } });
30
+ }
31
+ // Empty body / network failure / undefined / null / empty object.
32
+ const reason = response ? "(empty response body)" : "network error (no response)";
33
+ // kilocode_change
34
+ return new Error(`kilo server ${describe(request, response)}: ${reason}`, {
35
+ cause: { body: error, status: response?.status },
36
+ });
37
+ }
38
+ function describe(request, response) {
39
+ const method = request?.method ?? "?";
40
+ const url = request?.url ?? "?";
41
+ const status = response?.status;
42
+ const statusText = response?.statusText;
43
+ return `${method} ${url}${status ? " → " + status : ""}${statusText ? " " + statusText : ""}`;
44
+ }
@@ -911,7 +911,7 @@ export type ProviderConfig = {
911
911
  output: Array<"text" | "audio" | "image" | "video" | "pdf">;
912
912
  };
913
913
  experimental?: boolean;
914
- status?: "alpha" | "beta" | "deprecated";
914
+ status?: "alpha" | "beta" | "deprecated" | "active";
915
915
  options?: {
916
916
  [key: string]: unknown;
917
917
  };
@@ -2619,7 +2619,7 @@ export type ProviderListResponses = {
2619
2619
  output: Array<"text" | "audio" | "image" | "video" | "pdf">;
2620
2620
  };
2621
2621
  experimental?: boolean;
2622
- status?: "alpha" | "beta" | "deprecated";
2622
+ status?: "alpha" | "beta" | "deprecated" | "active";
2623
2623
  options: {
2624
2624
  [key: string]: unknown;
2625
2625
  };
package/dist/v2/client.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export * from "./gen/types.gen.js";
2
2
  import { createClient } from "./gen/client/client.gen.js";
3
3
  import { KiloClient } from "./gen/sdk.gen.js";
4
+ import { wrapClientError } from "../error-interceptor.js";
4
5
  export { KiloClient };
5
6
  function pick(value, fallback, encode) {
6
7
  if (!value)
@@ -81,25 +82,6 @@ export function createKiloClient(config) {
81
82
  throw new Error("Request is not supported by this version of OpenCode Server (Server responded with text/html)");
82
83
  return response;
83
84
  });
84
- // The generated client falls back to throwing a literal `{}` when the server
85
- // responds with an empty / unparseable error body, which surfaces as a bare
86
- // `{}` in TUI / CLI error output. Wrap ONLY that case in a real Error so
87
- // downstream formatters get a useful message — but pass through any parsed
88
- // JSON error body unchanged so existing consumers can still inspect fields.
89
- client.interceptors.error.use((error, response, request) => {
90
- const isEmpty = error === undefined ||
91
- error === null ||
92
- error === "" ||
93
- (typeof error === "object" && !(error instanceof Error) && Object.keys(error).length === 0);
94
- if (!isEmpty)
95
- return error;
96
- const method = request?.method ?? "?";
97
- const url = request?.url ?? "?";
98
- if (!response)
99
- return new Error(`kilo server ${method} ${url}: network error (no response)`);
100
- const status = response.status;
101
- const statusText = response.statusText ? " " + response.statusText : "";
102
- return new Error(`kilo server ${method} ${url} → ${status}${statusText}: (empty response body)`);
103
- });
85
+ client.interceptors.error.use(wrapClientError);
104
86
  return new KiloClient({ client });
105
87
  }
@@ -1483,6 +1483,13 @@ export declare class Session3 extends HeyApiClient {
1483
1483
  list<ThrowOnError extends boolean = false>(parameters?: {
1484
1484
  directory?: string;
1485
1485
  workspace?: string;
1486
+ limit?: number;
1487
+ order?: "asc" | "desc";
1488
+ path?: string;
1489
+ roots?: boolean | "true" | "false";
1490
+ start?: number;
1491
+ search?: string;
1492
+ cursor?: string;
1486
1493
  }, options?: Options<never, ThrowOnError>): import("./client/types.gen.js").RequestResult<V2SessionListResponses, V2SessionListErrors, ThrowOnError, "fields">;
1487
1494
  /**
1488
1495
  * Send v2 message
@@ -1535,6 +1542,9 @@ export declare class Session3 extends HeyApiClient {
1535
1542
  sessionID: string;
1536
1543
  directory?: string;
1537
1544
  workspace?: string;
1545
+ limit?: number;
1546
+ order?: "asc" | "desc";
1547
+ cursor?: string;
1538
1548
  }, options?: Options<never, ThrowOnError>): import("./client/types.gen.js").RequestResult<V2SessionMessagesResponses, V2SessionMessagesErrors, ThrowOnError, "fields">;
1539
1549
  }
1540
1550
  export declare class V2 extends HeyApiClient {
@@ -2973,6 +2973,13 @@ export class Session3 extends HeyApiClient {
2973
2973
  args: [
2974
2974
  { in: "query", key: "directory" },
2975
2975
  { in: "query", key: "workspace" },
2976
+ { in: "query", key: "limit" },
2977
+ { in: "query", key: "order" },
2978
+ { in: "query", key: "path" },
2979
+ { in: "query", key: "roots" },
2980
+ { in: "query", key: "start" },
2981
+ { in: "query", key: "search" },
2982
+ { in: "query", key: "cursor" },
2976
2983
  ],
2977
2984
  },
2978
2985
  ]);
@@ -3085,6 +3092,9 @@ export class Session3 extends HeyApiClient {
3085
3092
  { in: "path", key: "sessionID" },
3086
3093
  { in: "query", key: "directory" },
3087
3094
  { in: "query", key: "workspace" },
3095
+ { in: "query", key: "limit" },
3096
+ { in: "query", key: "order" },
3097
+ { in: "query", key: "cursor" },
3088
3098
  ],
3089
3099
  },
3090
3100
  ]);
@@ -164,8 +164,8 @@ export type BackgroundProcessInfo = {
164
164
  };
165
165
  };
166
166
  export type SnapshotFileDiff = {
167
- file: string;
168
- patch: string;
167
+ file?: string;
168
+ patch?: string;
169
169
  additions: number;
170
170
  deletions: number;
171
171
  status?: "added" | "deleted" | "modified";
@@ -619,7 +619,7 @@ export type CompactionPart = {
619
619
  };
620
620
  export type Part = TextPart | SubtaskPart | ReasoningPart | FilePart | ToolPart | StepStartPart | StepFinishPart | SnapshotPart | PatchPart | AgentPart | RetryPart | CompactionPart;
621
621
  export type SnapshotSummaryFileDiff = {
622
- file: string;
622
+ file?: string;
623
623
  additions: number;
624
624
  deletions: number;
625
625
  status?: "added" | "deleted" | "modified";
@@ -877,7 +877,7 @@ export type ProviderConfig = {
877
877
  output: Array<"text" | "audio" | "image" | "video" | "pdf">;
878
878
  };
879
879
  experimental?: boolean;
880
- status?: "alpha" | "beta" | "deprecated";
880
+ status?: "alpha" | "beta" | "deprecated" | "active";
881
881
  provider?: {
882
882
  npm?: string;
883
883
  api?: string;
@@ -1203,8 +1203,8 @@ export type WorktreeResetInput = {
1203
1203
  directory: string;
1204
1204
  };
1205
1205
  export type WorktreeDiffItem = {
1206
- file: string;
1207
- patch: string;
1206
+ file?: string;
1207
+ patch?: string;
1208
1208
  additions: number;
1209
1209
  deletions: number;
1210
1210
  status?: "added" | "deleted" | "modified";
@@ -1329,7 +1329,7 @@ export type VcsFileStatus = {
1329
1329
  };
1330
1330
  export type VcsFileDiff = {
1331
1331
  file: string;
1332
- patch: string;
1332
+ patch?: string;
1333
1333
  additions: number;
1334
1334
  deletions: number;
1335
1335
  status?: "added" | "deleted" | "modified";
@@ -5894,6 +5894,16 @@ export type V2SessionListData = {
5894
5894
  query?: {
5895
5895
  directory?: string;
5896
5896
  workspace?: string;
5897
+ limit?: number;
5898
+ order?: "asc" | "desc";
5899
+ path?: string;
5900
+ roots?: boolean | "true" | "false";
5901
+ start?: number;
5902
+ search?: string;
5903
+ /**
5904
+ * Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response. Do not combine with order or filters.
5905
+ */
5906
+ cursor?: string;
5897
5907
  };
5898
5908
  url: "/api/session";
5899
5909
  };
@@ -5994,6 +6004,12 @@ export type V2SessionMessagesData = {
5994
6004
  query?: {
5995
6005
  directory?: string;
5996
6006
  workspace?: string;
6007
+ limit?: number;
6008
+ order?: "asc" | "desc";
6009
+ /**
6010
+ * Opaque pagination cursor returned as cursor.previous or cursor.next in the previous response. Do not combine with order.
6011
+ */
6012
+ cursor?: string;
5997
6013
  };
5998
6014
  url: "/api/session/{sessionID}/message";
5999
6015
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@kilocode/sdk",
4
- "version": "7.3.28",
4
+ "version": "7.3.29",
5
5
  "type": "module",
6
6
  "license": "MIT",
7
7
  "scripts": {