@agent-api/sdk 1.0.2 → 1.0.3

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog — @agent-api/sdk
2
2
 
3
+ ## 1.0.3
4
+
5
+ ### Added
6
+
7
+ - Workbench volume APIs: `summarize`, `grep`, `readLines`, `patchLines`, `downloadArchive`.
8
+ - `responses.retrieveVolume` for `GET /v1/responses/{response_id}/volume`.
9
+
10
+ ### Changed
11
+
12
+ - **Breaking:** `readFile` returns smart delivery metadata (`encoding`, `mime_type`, `content`, `image_url`, etc.); use `{ format: "raw" }` for binary bytes.
13
+ - **Breaking:** `deleteFile` and `deleteDirectory` replaced by unified `deletePath`, returning `{ path, recursive }`.
14
+
3
15
  ## 1.0.2
4
16
 
5
17
  ### Added
package/README.md CHANGED
@@ -59,7 +59,7 @@ src/
59
59
  | `client.models` | `list` |
60
60
  | `client.presets` | `list` |
61
61
  | `client.tools` | `list` |
62
- | `client.volumes` | `list`, `create`, `retrieve`, `update`, `delete`, `listEntries`, `searchEntries`, `readFile`, `writeFile`, `deleteFile`, `reconcileUsage`, `createDirectory`, `deleteDirectory` |
62
+ | `client.volumes` | `list`, `create`, `retrieve`, `update`, `delete`, `listEntries`, `searchEntries`, `readFile`, `writeFile`, `deletePath`, `reconcileUsage`, `createDirectory`, `downloadArchive`, `summarize`, `readLines`, `patchLines`, `grep` |
63
63
 
64
64
  ## Durable Volumes
65
65
 
@@ -3,6 +3,7 @@ import { Page } from "../pagination.js";
3
3
  import type { RequestOptions } from "../types/common.js";
4
4
  import type { AgentResponse, CancelResponse, ListChildrenResponse, ListEventsParams, ListEventsResponse, ListResponsesParams, ListResponsesResponse, ResponseCreateParamsNonStreaming, ResponseCreateParamsStreaming, ResponseListItem } from "../types/responses.js";
5
5
  import type { ResponseStreamEvent } from "../types/streaming.js";
6
+ import type { VolumeInfo } from "../types/volumes.js";
6
7
  export declare class ResponsesResource {
7
8
  private readonly http;
8
9
  private readonly path;
@@ -16,4 +17,5 @@ export declare class ResponsesResource {
16
17
  cancel(responseID: string, options?: RequestOptions): Promise<CancelResponse>;
17
18
  listChildren(responseID: string, options?: RequestOptions): Promise<ListChildrenResponse>;
18
19
  listEvents(responseID: string, params?: ListEventsParams, options?: RequestOptions): Promise<ListEventsResponse>;
20
+ retrieveVolume(responseID: string, options?: RequestOptions): Promise<VolumeInfo>;
19
21
  }
@@ -46,4 +46,7 @@ export class ResponsesResource {
46
46
  view: params.view,
47
47
  })}`, undefined, options);
48
48
  }
49
+ retrieveVolume(responseID, options) {
50
+ return this.http.request("GET", `${this.path}/${encodeURIComponent(responseID)}/volume`, undefined, options);
51
+ }
49
52
  }
@@ -1,6 +1,6 @@
1
1
  import type { HTTPClient } from "../internal/http.js";
2
2
  import type { RequestOptions } from "../types/common.js";
3
- import type { CreateVolumeParams, ListVolumeEntriesParams, ListVolumeEntriesResponse, ListVolumesParams, ListVolumesResponse, ReadVolumeFileParams, ReadVolumeFileRawParams, SearchVolumeEntriesParams, VolumeFileRead, VolumeFileRaw, VolumeFileWrite, VolumeInfo } from "../types/volumes.js";
3
+ import type { CreateVolumeParams, DownloadVolumeArchiveParams, GrepVolumeParams, ListVolumeEntriesParams, ListVolumeEntriesResponse, ListVolumesParams, ListVolumesResponse, PatchVolumeFileLinesParams, ReadVolumeFileLinesParams, ReadVolumeFileParams, ReadVolumeFileRawParams, SearchVolumeEntriesParams, SummarizeVolumeParams, VolumeArchive, VolumeFileDeliver, VolumeFileLines, VolumeFileLinesPatch, VolumeFileRaw, VolumeFileWrite, VolumeGrepResponse, VolumeInfo, VolumePathDelete, VolumeSummary } from "../types/volumes.js";
4
4
  export declare class VolumesResource {
5
5
  private readonly http;
6
6
  constructor(http: HTTPClient);
@@ -14,12 +14,16 @@ export declare class VolumesResource {
14
14
  listEntries(volumeID: string, params?: ListVolumeEntriesParams, options?: RequestOptions): Promise<ListVolumeEntriesResponse>;
15
15
  searchEntries(volumeID: string, params: SearchVolumeEntriesParams, options?: RequestOptions): Promise<ListVolumeEntriesResponse>;
16
16
  readFile(volumeID: string, path: string, params: ReadVolumeFileRawParams, options?: RequestOptions): Promise<VolumeFileRaw>;
17
- readFile(volumeID: string, path: string, params?: ReadVolumeFileParams, options?: RequestOptions): Promise<VolumeFileRead>;
17
+ readFile(volumeID: string, path: string, params?: ReadVolumeFileParams, options?: RequestOptions): Promise<VolumeFileDeliver>;
18
18
  writeFile(volumeID: string, path: string, content: string | ArrayBuffer | Blob, options?: RequestOptions): Promise<VolumeFileWrite>;
19
- deleteFile(volumeID: string, path: string, options?: RequestOptions): Promise<void>;
19
+ deletePath(volumeID: string, path: string, options?: RequestOptions): Promise<VolumePathDelete>;
20
20
  reconcileUsage(volumeID: string, options?: RequestOptions): Promise<VolumeInfo>;
21
21
  createDirectory(volumeID: string, path: string, options?: RequestOptions): Promise<{
22
22
  path: string;
23
23
  }>;
24
- deleteDirectory(volumeID: string, path: string, options?: RequestOptions): Promise<void>;
24
+ downloadArchive(volumeID: string, params?: DownloadVolumeArchiveParams, options?: RequestOptions): Promise<VolumeArchive>;
25
+ summarize(volumeID: string, params?: SummarizeVolumeParams, options?: RequestOptions): Promise<VolumeSummary>;
26
+ readLines(volumeID: string, path: string, params: ReadVolumeFileLinesParams, options?: RequestOptions): Promise<VolumeFileLines>;
27
+ patchLines(volumeID: string, path: string, params: PatchVolumeFileLinesParams, options?: RequestOptions): Promise<VolumeFileLinesPatch>;
28
+ grep(volumeID: string, params: GrepVolumeParams, options?: RequestOptions): Promise<VolumeGrepResponse>;
25
29
  }
@@ -35,11 +35,12 @@ export class VolumesResource {
35
35
  })}`, undefined, options);
36
36
  }
37
37
  readFile(volumeID, path, params = {}, options) {
38
+ const format = "format" in params ? params.format : undefined;
38
39
  const url = `/v1/volumes/${encodeURIComponent(volumeID)}/files/${volumePath(path)}${buildQuery({
39
40
  max_bytes: params.max_bytes,
40
- format: params.format,
41
+ format,
41
42
  })}`;
42
- if (params.format === "raw") {
43
+ if (format === "raw") {
43
44
  return this.http.requestBinary("GET", url, options).then(({ body, headers }) => ({
44
45
  path,
45
46
  size: Number(headers.get("X-Volume-Size") ?? body.byteLength),
@@ -53,8 +54,8 @@ export class VolumesResource {
53
54
  writeFile(volumeID, path, content, options) {
54
55
  return this.http.requestRaw("PUT", `/v1/volumes/${encodeURIComponent(volumeID)}/files/${volumePath(path)}`, content, options);
55
56
  }
56
- deleteFile(volumeID, path, options) {
57
- return this.http.requestVoid("DELETE", `/v1/volumes/${encodeURIComponent(volumeID)}/files/${volumePath(path)}`, options);
57
+ deletePath(volumeID, path, options) {
58
+ return this.http.request("DELETE", `/v1/volumes/${encodeURIComponent(volumeID)}/paths/${volumePath(path)}`, undefined, options);
58
59
  }
59
60
  reconcileUsage(volumeID, options) {
60
61
  return this.http.request("POST", `/v1/volumes/${encodeURIComponent(volumeID)}/usage/reconcile`, undefined, options);
@@ -62,8 +63,36 @@ export class VolumesResource {
62
63
  createDirectory(volumeID, path, options) {
63
64
  return this.http.request("POST", `/v1/volumes/${encodeURIComponent(volumeID)}/directories`, { path }, options);
64
65
  }
65
- deleteDirectory(volumeID, path, options) {
66
- return this.http.requestVoid("DELETE", `/v1/volumes/${encodeURIComponent(volumeID)}/directories/${volumePath(path)}`, options);
66
+ downloadArchive(volumeID, params = {}, options) {
67
+ const archivePath = normalizeArchivePath(params.path);
68
+ return this.http
69
+ .requestBinary("GET", `/v1/volumes/${encodeURIComponent(volumeID)}/archive${buildQuery({ path: archivePath || undefined })}`, options)
70
+ .then(({ body, headers }) => ({
71
+ path: archivePath,
72
+ content: body,
73
+ content_type: headers.get("Content-Type") ?? undefined,
74
+ }));
75
+ }
76
+ summarize(volumeID, params = {}, options) {
77
+ return this.http.request("POST", `/v1/volumes/${encodeURIComponent(volumeID)}/summarize`, params, options);
78
+ }
79
+ readLines(volumeID, path, params, options) {
80
+ return this.http.request("GET", `/v1/volumes/${encodeURIComponent(volumeID)}/file_lines/${volumePath(path)}${buildQuery({
81
+ start_line: params.start_line,
82
+ end_line: params.end_line,
83
+ max_bytes: params.max_bytes,
84
+ })}`, undefined, options);
85
+ }
86
+ patchLines(volumeID, path, params, options) {
87
+ return this.http.request("PATCH", `/v1/volumes/${encodeURIComponent(volumeID)}/file_lines/${volumePath(path)}`, params, options);
88
+ }
89
+ grep(volumeID, params, options) {
90
+ return this.http.request("GET", `/v1/volumes/${encodeURIComponent(volumeID)}/grep${buildQuery({
91
+ pattern: params.pattern,
92
+ path: params.path,
93
+ limit: params.limit,
94
+ page_token: params.page_token,
95
+ })}`, undefined, options);
67
96
  }
68
97
  }
69
98
  function volumePath(path) {
@@ -73,3 +102,9 @@ function volumePath(path) {
73
102
  .map((part) => encodeURIComponent(part))
74
103
  .join("/");
75
104
  }
105
+ function normalizeArchivePath(path) {
106
+ if (!path) {
107
+ return "";
108
+ }
109
+ return path.trim().replace(/^\/+/, "").replace(/\/+/g, "/").replace(/\/$/, "");
110
+ }
@@ -42,17 +42,23 @@ export interface ListVolumeEntriesResponse {
42
42
  }
43
43
  export interface ReadVolumeFileParams {
44
44
  max_bytes?: number;
45
- format?: "json";
46
45
  }
47
46
  export interface ReadVolumeFileRawParams {
48
47
  max_bytes?: number;
49
48
  format: "raw";
50
49
  }
51
- export interface VolumeFileRead {
50
+ export type VolumeFileEncoding = "text" | "extracted_text" | "url" | "base64";
51
+ export interface VolumeFileDeliver {
52
52
  path: string;
53
+ encoding: VolumeFileEncoding;
54
+ mime_type: string;
53
55
  size: number;
54
56
  truncated: boolean;
55
- content: string;
57
+ content?: string;
58
+ content_base64?: string;
59
+ image_url?: string;
60
+ expires_at_unix?: number;
61
+ extraction_warnings?: string[];
56
62
  }
57
63
  export interface VolumeFileRaw {
58
64
  path: string;
@@ -65,3 +71,76 @@ export interface VolumeFileWrite {
65
71
  path: string;
66
72
  size: number;
67
73
  }
74
+ export interface VolumePathDelete {
75
+ path: string;
76
+ recursive: boolean;
77
+ }
78
+ export interface DownloadVolumeArchiveParams {
79
+ path?: string;
80
+ }
81
+ export interface VolumeArchive {
82
+ path: string;
83
+ content: ArrayBuffer;
84
+ content_type?: string;
85
+ }
86
+ export interface SummarizeVolumeParams {
87
+ path?: string;
88
+ }
89
+ export interface VolumeSummaryPreview {
90
+ path: string;
91
+ size: number;
92
+ preview: string;
93
+ preview_truncated?: boolean;
94
+ }
95
+ export interface VolumeSummary {
96
+ summary_path: string;
97
+ file_count: number;
98
+ total_bytes: number;
99
+ top_paths_by_size: string[];
100
+ text_previews: VolumeSummaryPreview[];
101
+ generated_at_unix: number;
102
+ }
103
+ export interface ReadVolumeFileLinesParams {
104
+ start_line: number;
105
+ end_line?: number;
106
+ max_bytes?: number;
107
+ }
108
+ export interface VolumeFileLines {
109
+ path: string;
110
+ start_line: number;
111
+ end_line: number;
112
+ total_lines: number;
113
+ lines: string[];
114
+ file_truncated: boolean;
115
+ size: number;
116
+ }
117
+ export interface PatchVolumeFileLinesParams {
118
+ start_line: number;
119
+ end_line?: number;
120
+ replacement?: string;
121
+ }
122
+ export interface VolumeFileLinesPatch {
123
+ path: string;
124
+ start_line: number;
125
+ end_line: number;
126
+ total_lines: number;
127
+ size: number;
128
+ }
129
+ export interface GrepVolumeParams {
130
+ pattern: string;
131
+ path?: string;
132
+ limit?: number;
133
+ page_token?: string;
134
+ }
135
+ export interface VolumeGrepMatch {
136
+ path: string;
137
+ line_number: number;
138
+ line: string;
139
+ }
140
+ export interface VolumeGrepResponse {
141
+ object: "list";
142
+ matches: VolumeGrepMatch[];
143
+ next_page_token?: string;
144
+ files_scanned: number;
145
+ scan_truncated: boolean;
146
+ }
package/dist/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.0.2";
2
- export declare const USER_AGENT = "@agent-api/sdk/1.0.2";
1
+ export declare const VERSION = "1.0.3";
2
+ export declare const USER_AGENT = "@agent-api/sdk/1.0.3";
package/dist/version.js CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = "1.0.2";
1
+ export const VERSION = "1.0.3";
2
2
  export const USER_AGENT = `@agent-api/sdk/${VERSION}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent-api/sdk",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Production JavaScript SDK for the Managed Agent API",
5
5
  "license": "MIT",
6
6
  "repository": {