@agent-api/sdk 1.0.1 → 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,30 @@
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
+
15
+ ## 1.0.2
16
+
17
+ ### Added
18
+
19
+ - `user` on create-run params; `input_document` content parts in TypeScript types.
20
+ - `response.requires_action` in streaming event types.
21
+ - `readFile(..., { format: "raw" })` for binary volume files (`VolumeFileRaw` with `ArrayBuffer` content).
22
+ - Route manifest coverage for volume rename, usage reconcile, and directory create/delete.
23
+
24
+ ### Fixed
25
+
26
+ - README and route manifest now list all volume resource methods implemented since 1.0.1.
27
+
3
28
  ## 1.0.1
4
29
 
5
30
  ### Added
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Production JavaScript/TypeScript SDK for the Managed Agent API.
4
4
 
5
- **Published on npm:** [`@agent-api/sdk`](https://www.npmjs.com/package/@agent-api/sdk) (v1.0.1)
5
+ **Published on npm:** [`@agent-api/sdk`](https://www.npmjs.com/package/@agent-api/sdk) (v1.0.2)
6
6
 
7
7
  ## Install
8
8
 
@@ -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`, `delete`, `listEntries`, `searchEntries`, `readFile`, `writeFile`, `deleteFile` |
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
 
@@ -68,6 +68,7 @@ const volume = await client.volumes.create({ name: "research-notes" });
68
68
 
69
69
  await client.volumes.writeFile(volume.volume_id, "notes/summary.md", "# Summary\n");
70
70
  const file = await client.volumes.readFile(volume.volume_id, "notes/summary.md");
71
+ const binary = await client.volumes.readFile(volume.volume_id, "assets/logo.png", { format: "raw" });
71
72
 
72
73
  const response = await client.agent.create({
73
74
  preset: "pro-search",
@@ -14,6 +14,10 @@ export declare class HTTPClient {
14
14
  request<T>(method: string, path: string, body?: unknown, options?: RequestOptions): Promise<T>;
15
15
  requestRaw<T>(method: string, path: string, body: BodyInit, options?: RequestOptions): Promise<T>;
16
16
  requestVoid(method: string, path: string, options?: RequestOptions): Promise<void>;
17
+ requestBinary(method: string, path: string, options?: RequestOptions): Promise<{
18
+ body: ArrayBuffer;
19
+ headers: Headers;
20
+ }>;
17
21
  stream<T>(path: string, body: unknown, options?: RequestOptions): Promise<AsyncIterable<T>>;
18
22
  private fetchWithRetry;
19
23
  private fetchOnce;
@@ -17,6 +17,10 @@ export class HTTPClient {
17
17
  async requestVoid(method, path, options = {}) {
18
18
  await this.fetchWithRetry(method, path, undefined, options, false, false);
19
19
  }
20
+ async requestBinary(method, path, options = {}) {
21
+ const response = await this.fetchWithRetry(method, path, undefined, options, false, false);
22
+ return { body: await response.arrayBuffer(), headers: response.headers };
23
+ }
20
24
  async stream(path, body, options = {}) {
21
25
  const response = await this.fetchWithRetry("POST", path, body, options, true, false);
22
26
  return parseSSE(response);
@@ -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,16 +1,29 @@
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, SearchVolumeEntriesParams, VolumeFileRead, 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);
7
7
  list(params?: ListVolumesParams, options?: RequestOptions): Promise<ListVolumesResponse>;
8
8
  create(params?: CreateVolumeParams, options?: RequestOptions): Promise<VolumeInfo>;
9
9
  retrieve(volumeID: string, options?: RequestOptions): Promise<VolumeInfo>;
10
+ update(volumeID: string, params: {
11
+ name: string;
12
+ }, options?: RequestOptions): Promise<VolumeInfo>;
10
13
  delete(volumeID: string, options?: RequestOptions): Promise<void>;
11
14
  listEntries(volumeID: string, params?: ListVolumeEntriesParams, options?: RequestOptions): Promise<ListVolumeEntriesResponse>;
12
15
  searchEntries(volumeID: string, params: SearchVolumeEntriesParams, options?: RequestOptions): Promise<ListVolumeEntriesResponse>;
13
- readFile(volumeID: string, path: string, params?: ReadVolumeFileParams, options?: RequestOptions): Promise<VolumeFileRead>;
16
+ readFile(volumeID: string, path: string, params: ReadVolumeFileRawParams, options?: RequestOptions): Promise<VolumeFileRaw>;
17
+ readFile(volumeID: string, path: string, params?: ReadVolumeFileParams, options?: RequestOptions): Promise<VolumeFileDeliver>;
14
18
  writeFile(volumeID: string, path: string, content: string | ArrayBuffer | Blob, options?: RequestOptions): Promise<VolumeFileWrite>;
15
- deleteFile(volumeID: string, path: string, options?: RequestOptions): Promise<void>;
19
+ deletePath(volumeID: string, path: string, options?: RequestOptions): Promise<VolumePathDelete>;
20
+ reconcileUsage(volumeID: string, options?: RequestOptions): Promise<VolumeInfo>;
21
+ createDirectory(volumeID: string, path: string, options?: RequestOptions): Promise<{
22
+ path: string;
23
+ }>;
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>;
16
29
  }
@@ -13,6 +13,9 @@ export class VolumesResource {
13
13
  retrieve(volumeID, options) {
14
14
  return this.http.request("GET", `/v1/volumes/${encodeURIComponent(volumeID)}`, undefined, options);
15
15
  }
16
+ update(volumeID, params, options) {
17
+ return this.http.request("PATCH", `/v1/volumes/${encodeURIComponent(volumeID)}`, params, options);
18
+ }
16
19
  delete(volumeID, options) {
17
20
  return this.http.requestVoid("DELETE", `/v1/volumes/${encodeURIComponent(volumeID)}`, options);
18
21
  }
@@ -32,15 +35,64 @@ export class VolumesResource {
32
35
  })}`, undefined, options);
33
36
  }
34
37
  readFile(volumeID, path, params = {}, options) {
35
- return this.http.request("GET", `/v1/volumes/${encodeURIComponent(volumeID)}/files/${volumePath(path)}${buildQuery({
38
+ const format = "format" in params ? params.format : undefined;
39
+ const url = `/v1/volumes/${encodeURIComponent(volumeID)}/files/${volumePath(path)}${buildQuery({
36
40
  max_bytes: params.max_bytes,
37
- })}`, undefined, options);
41
+ format,
42
+ })}`;
43
+ if (format === "raw") {
44
+ return this.http.requestBinary("GET", url, options).then(({ body, headers }) => ({
45
+ path,
46
+ size: Number(headers.get("X-Volume-Size") ?? body.byteLength),
47
+ truncated: headers.get("X-Volume-Truncated") === "true",
48
+ content: body,
49
+ content_type: headers.get("Content-Type") ?? undefined,
50
+ }));
51
+ }
52
+ return this.http.request("GET", url, undefined, options);
38
53
  }
39
54
  writeFile(volumeID, path, content, options) {
40
55
  return this.http.requestRaw("PUT", `/v1/volumes/${encodeURIComponent(volumeID)}/files/${volumePath(path)}`, content, options);
41
56
  }
42
- deleteFile(volumeID, path, options) {
43
- 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);
59
+ }
60
+ reconcileUsage(volumeID, options) {
61
+ return this.http.request("POST", `/v1/volumes/${encodeURIComponent(volumeID)}/usage/reconcile`, undefined, options);
62
+ }
63
+ createDirectory(volumeID, path, options) {
64
+ return this.http.request("POST", `/v1/volumes/${encodeURIComponent(volumeID)}/directories`, { path }, options);
65
+ }
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);
44
96
  }
45
97
  }
46
98
  function volumePath(path) {
@@ -50,3 +102,9 @@ function volumePath(path) {
50
102
  .map((part) => encodeURIComponent(part))
51
103
  .join("/");
52
104
  }
105
+ function normalizeArchivePath(path) {
106
+ if (!path) {
107
+ return "";
108
+ }
109
+ return path.trim().replace(/^\/+/, "").replace(/\/+/g, "/").replace(/\/$/, "");
110
+ }
@@ -6,9 +6,12 @@ export interface Annotation {
6
6
  end_index?: number;
7
7
  }
8
8
  export interface ContentPart {
9
- type: "input_text" | "output_text" | "input_image";
9
+ type: "input_text" | "output_text" | "input_image" | "input_document";
10
10
  text?: string;
11
11
  image_url?: string;
12
+ mime_type?: string;
13
+ filename?: string;
14
+ document_url?: string;
12
15
  annotations?: Annotation[];
13
16
  logprobs?: unknown[];
14
17
  }
@@ -23,6 +23,7 @@ export interface ResponseCreateParamsBase {
23
23
  memory?: MemoryOptions;
24
24
  plan_mode_preference?: AgentCapabilityPreference;
25
25
  sub_agent_preference?: AgentCapabilityPreference;
26
+ user?: string;
26
27
  stream?: boolean;
27
28
  }
28
29
  export interface ResponseCreateParamsNonStreaming extends ResponseCreateParamsBase {
@@ -17,7 +17,7 @@ export interface ResponseModelCallEvent {
17
17
  model_chain?: string[];
18
18
  attempt_count?: number;
19
19
  }
20
- export type ResponseStreamEventType = "response.created" | "response.in_progress" | "response.completed" | "response.failed" | "response.plan.updated" | "response.output_item.added" | "response.output_item.done" | "response.output_text.delta" | "response.output_text.done" | "response.reasoning.started" | "response.reasoning.search_queries" | "response.reasoning.search_results" | "response.reasoning.fetch_url_queries" | "response.reasoning.fetch_url_results" | "response.reasoning.stopped" | "response.tool.invocation.completed" | "response.step.completed" | "response.step.failed" | "response.step.skipped" | "response.model.requested" | "response.model.completed" | "response.model.failed";
20
+ export type ResponseStreamEventType = "response.created" | "response.in_progress" | "response.completed" | "response.failed" | "response.requires_action" | "response.plan.updated" | "response.output_item.added" | "response.output_item.done" | "response.output_text.delta" | "response.output_text.done" | "response.reasoning.started" | "response.reasoning.search_queries" | "response.reasoning.search_results" | "response.reasoning.fetch_url_queries" | "response.reasoning.fetch_url_results" | "response.reasoning.stopped" | "response.tool.invocation.completed" | "response.step.completed" | "response.step.failed" | "response.step.skipped" | "response.model.requested" | "response.model.completed" | "response.model.failed";
21
21
  export interface ResponseStreamEvent {
22
22
  type: ResponseStreamEventType;
23
23
  sequence_number: number;
@@ -3,6 +3,9 @@ export interface VolumeInfo {
3
3
  tenant_id?: string;
4
4
  name?: string;
5
5
  oss_prefix?: string;
6
+ bytes_used?: number;
7
+ object_count?: number;
8
+ usage_reconciled_at_unix?: number;
6
9
  created_at_unix?: number;
7
10
  updated_at_unix?: number;
8
11
  }
@@ -40,13 +43,104 @@ export interface ListVolumeEntriesResponse {
40
43
  export interface ReadVolumeFileParams {
41
44
  max_bytes?: number;
42
45
  }
43
- export interface VolumeFileRead {
46
+ export interface ReadVolumeFileRawParams {
47
+ max_bytes?: number;
48
+ format: "raw";
49
+ }
50
+ export type VolumeFileEncoding = "text" | "extracted_text" | "url" | "base64";
51
+ export interface VolumeFileDeliver {
44
52
  path: string;
53
+ encoding: VolumeFileEncoding;
54
+ mime_type: string;
45
55
  size: number;
46
56
  truncated: boolean;
47
- content: string;
57
+ content?: string;
58
+ content_base64?: string;
59
+ image_url?: string;
60
+ expires_at_unix?: number;
61
+ extraction_warnings?: string[];
62
+ }
63
+ export interface VolumeFileRaw {
64
+ path: string;
65
+ size: number;
66
+ truncated: boolean;
67
+ content: ArrayBuffer;
68
+ content_type?: string;
48
69
  }
49
70
  export interface VolumeFileWrite {
50
71
  path: string;
51
72
  size: number;
52
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.1";
2
- export declare const USER_AGENT = "@agent-api/sdk/1.0.1";
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.1";
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.1",
3
+ "version": "1.0.3",
4
4
  "description": "Production JavaScript SDK for the Managed Agent API",
5
5
  "license": "MIT",
6
6
  "repository": {