@harness-gw/sdk 0.13.0 → 0.15.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.
@@ -128,15 +128,15 @@ export declare function createAcpWorkspaceClient({ connection, rest, agentIdFor,
128
128
  workspaceCapabilities: (sessionId: string) => {
129
129
  workspace: {
130
130
  slashCommands: {
131
+ status: "unavailable";
132
+ reason: string;
133
+ } | {
131
134
  status: "available";
132
135
  scope: "session";
133
136
  commands: {
134
137
  name: string;
135
138
  description?: string | undefined;
136
139
  }[];
137
- } | {
138
- status: "unavailable";
139
- reason: string;
140
140
  };
141
141
  models: {
142
142
  status: "unavailable";
@@ -1,7 +1,7 @@
1
1
  import type { z } from "zod";
2
2
  import { SessionContextResponseSchema, SessionModelsResponseSchema, SessionWorkspaceCapabilitiesResponseSchema } from "../protocol/index.js";
3
3
  import { type PushRegistration } from "../protocol/push.js";
4
- import { type McpAppResourceReadRequest, type McpAppToolCallRequest } from "../protocol/mcp-apps.js";
4
+ import { type McpAppFileReadFailure, type McpAppModelContextRequest, type McpAppResourceReadRequest, type McpAppToolCallRequest } from "../protocol/mcp-apps.js";
5
5
  import type { StagedAttachment } from "./workspace.js";
6
6
  export type HgwWorkspaceCapabilities = z.infer<typeof SessionWorkspaceCapabilitiesResponseSchema>;
7
7
  export type HgwModelChoices = z.infer<typeof SessionModelsResponseSchema>;
@@ -24,6 +24,14 @@ export declare class HgwClientError extends Error {
24
24
  /** The gateway's HTTP status, when it answered. */
25
25
  status?: number | undefined);
26
26
  }
27
+ /**
28
+ * A view's read of its own file address failed: `reason` says why, as the
29
+ * gateway answered it.
30
+ */
31
+ export declare class McpAppFileReadError extends HgwClientError {
32
+ readonly reason: McpAppFileReadFailure;
33
+ constructor(reason: McpAppFileReadFailure, ...failure: ConstructorParameters<typeof HgwClientError>);
34
+ }
27
35
  /** The `fetch` the client sends every request with. */
28
36
  export type Fetcher = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
29
37
  export type HgwRemoteClientOptions = {
@@ -396,7 +404,11 @@ export declare class HgwRemoteClient {
396
404
  structuredContent?: unknown;
397
405
  isError?: boolean | undefined;
398
406
  }>;
399
- /** A resource read the App view makes, answered by the gateway's MCP server. */
407
+ /**
408
+ * A resource read the App view makes, answered by the gateway's MCP server:
409
+ * one of its `ui://` resources, or one of the view's own file addresses,
410
+ * whose failure rejects as `McpAppFileReadError`.
411
+ */
400
412
  readMcpAppResource(sessionId: string, subject: McpAppSubject, request: McpAppResourceReadRequest): Promise<{
401
413
  [x: string]: unknown;
402
414
  _meta?: {
@@ -427,6 +439,30 @@ export declare class HgwRemoteClient {
427
439
  blob: string;
428
440
  })[];
429
441
  }>;
442
+ /**
443
+ * A view's `ui/update-model-context`, answered with its empty result: the
444
+ * model reads it once, in the Session's next turn, in place of what the view
445
+ * sent before. A runtime with nowhere to put it out of the transcript
446
+ * rejects it with code `unsupported`, a refusal no retry changes.
447
+ */
448
+ updateMcpAppModelContext(sessionId: string, toolCallId: string, request: McpAppModelContextRequest): Promise<{
449
+ _meta?: {
450
+ [x: string]: unknown;
451
+ "io.modelcontextprotocol/serverInfo"?: {
452
+ version: string;
453
+ websiteUrl?: string | undefined;
454
+ description?: string | undefined;
455
+ icons?: {
456
+ src: string;
457
+ mimeType?: string | undefined;
458
+ sizes?: string[] | undefined;
459
+ theme?: "dark" | "light" | undefined;
460
+ }[] | undefined;
461
+ name: string;
462
+ title?: string | undefined;
463
+ } | undefined;
464
+ } | undefined;
465
+ }>;
430
466
  transcribe(sessionId: string, audio: Blob, signal?: AbortSignal): Promise<string>;
431
467
  transcribeForAgent(agentId: string, audio: Blob, signal?: AbortSignal): Promise<string>;
432
468
  speak(sessionId: string, text: string, signal?: AbortSignal): Promise<Blob>;
@@ -1,4 +1,12 @@
1
1
  import {
2
+ CallToolResultSchema2,
3
+ EmptyResultSchema2,
4
+ ReadResourceResultSchema2,
5
+ McpAppFilesSchema2,
6
+ McpAppViewSchema2,
7
+ McpAppToolCallRequestSchema2,
8
+ McpAppResourceReadRequestSchema2,
9
+ McpAppModelContextRequestSchema2,
2
10
  RuntimeInfoSchema2,
3
11
  SessionAttachmentStageRequestSchema2,
4
12
  SessionAttachmentStageResponseSchema2,
@@ -37,13 +45,7 @@ import {
37
45
  HgwErrorNotificationSchema2,
38
46
  HgwActivityNotificationSchema2,
39
47
  PushInfoSchema2,
40
- PushUnregistrationSchema2,
41
- CallToolResultSchema2,
42
- ReadResourceResultSchema2,
43
- McpAppFilesSchema2,
44
- McpAppViewSchema2,
45
- McpAppToolCallRequestSchema2,
46
- McpAppResourceReadRequestSchema2
48
+ PushUnregistrationSchema2
47
49
  } from "../chunks/index.js";
48
50
 
49
51
  // client/connection.ts
@@ -2497,6 +2499,15 @@ class HgwClientError extends Error {
2497
2499
  this.name = "HgwClientError";
2498
2500
  }
2499
2501
  }
2502
+
2503
+ class McpAppFileReadError extends HgwClientError {
2504
+ reason;
2505
+ constructor(reason, ...failure) {
2506
+ super(...failure);
2507
+ this.reason = reason;
2508
+ this.name = "McpAppFileReadError";
2509
+ }
2510
+ }
2500
2511
  async function normalizedError(response) {
2501
2512
  const parsed = ErrorResponseSchema2.safeParse(await response.json().catch(() => {
2502
2513
  return;
@@ -2540,7 +2551,13 @@ class HgwRemoteClient {
2540
2551
  }
2541
2552
  if (!response.ok) {
2542
2553
  const error = await normalizedError(response);
2543
- throw new HgwClientError(response.status === 503 ? "provider-unavailable" : response.status === 404 ? notFound : "gateway-failure", error?.description, error?.code, response.status);
2554
+ const failure = [
2555
+ response.status === 503 ? "provider-unavailable" : response.status === 404 ? notFound : "gateway-failure",
2556
+ error?.description,
2557
+ error?.code,
2558
+ response.status
2559
+ ];
2560
+ throw error?.reason ? new McpAppFileReadError(error.reason, ...failure) : new HgwClientError(...failure);
2544
2561
  }
2545
2562
  let payload;
2546
2563
  try {
@@ -2621,6 +2638,9 @@ class HgwRemoteClient {
2621
2638
  async readMcpAppResource(sessionId, subject, request) {
2622
2639
  return this.#postMcpApp(sessionId, subject, "/resources/read", McpAppResourceReadRequestSchema2.safeParse(request), ReadResourceResultSchema2);
2623
2640
  }
2641
+ async updateMcpAppModelContext(sessionId, toolCallId, request) {
2642
+ return this.#postMcpApp(sessionId, { toolCallId }, "/ui/update-model-context", McpAppModelContextRequestSchema2.safeParse(request), EmptyResultSchema2);
2643
+ }
2624
2644
  async transcribe(sessionId, audio, signal) {
2625
2645
  return this.transcribeForAgent(this.#owner(sessionId), audio, signal);
2626
2646
  }
@@ -2736,6 +2756,7 @@ export {
2736
2756
  AgentUpdateError,
2737
2757
  HgwClientError,
2738
2758
  HgwRemoteClient,
2759
+ McpAppFileReadError,
2739
2760
  PART_GRACE_MS,
2740
2761
  SILENT_LOGGER,
2741
2762
  acpDebugEnabled,
@@ -1357,6 +1357,12 @@ export declare const ErrorResponseSchema: z.ZodObject<{
1357
1357
  unsupported: "unsupported";
1358
1358
  }>;
1359
1359
  description: z.ZodString;
1360
+ reason: z.ZodOptional<z.ZodEnum<{
1361
+ denied: "denied";
1362
+ tooLarge: "tooLarge";
1363
+ unavailable: "unavailable";
1364
+ unreachable: "unreachable";
1365
+ }>>;
1360
1366
  }, z.core.$strict>;
1361
1367
  }, z.core.$strict>;
1362
1368
  export type ErrorResponse = z.infer<typeof ErrorResponseSchema>;
@@ -1,4 +1,4 @@
1
- import { CallToolResultSchema, ReadResourceResultSchema } from "@modelcontextprotocol/core";
1
+ import { CallToolResultSchema, EmptyResultSchema, ReadResourceResultSchema } from "@modelcontextprotocol/core";
2
2
  import { z } from "zod";
3
3
  /**
4
4
  * MCP Apps (spec 2026-01-26) as the gateway hands them to the browser. A tool
@@ -6,7 +6,7 @@ import { z } from "zod";
6
6
  * resource server-side and the browser only ever sees the view below, keyed
7
7
  * by the tool call that opened it, never the resource URI.
8
8
  */
9
- export { CallToolResultSchema, ReadResourceResultSchema };
9
+ export { CallToolResultSchema, EmptyResultSchema, ReadResourceResultSchema };
10
10
  export type CallToolResult = z.infer<typeof CallToolResultSchema>;
11
11
  export type ReadResourceResult = z.infer<typeof ReadResourceResultSchema>;
12
12
  /** A UI resource's `_meta.ui.csp`: the origins its view may reach. */
@@ -203,11 +203,144 @@ export declare const McpAppToolCallRequestSchema: z.ZodObject<{
203
203
  arguments: z.ZodRecord<z.ZodString, z.ZodUnknown>;
204
204
  }, z.core.$strict>;
205
205
  export type McpAppToolCallRequest = z.infer<typeof McpAppToolCallRequestSchema>;
206
- /** A view's `resources/read`, answered with a `ReadResourceResult`. */
206
+ /**
207
+ * A view's `resources/read`, answered with a `ReadResourceResult`: one of its
208
+ * server's `ui://` resources, or one of the view's own file addresses, which
209
+ * the gateway forwards to that server to read.
210
+ */
207
211
  export declare const McpAppResourceReadRequestSchema: z.ZodObject<{
208
212
  uri: z.ZodString;
209
213
  }, z.core.$strict>;
210
214
  export type McpAppResourceReadRequest = z.infer<typeof McpAppResourceReadRequestSchema>;
215
+ /**
216
+ * A view's `ui/update-model-context`, answered with an empty result: what the
217
+ * model reads of the view once, in the Session's next turn, in place of
218
+ * whatever the view sent before. An update carrying neither field clears it.
219
+ */
220
+ export declare const McpAppModelContextRequestSchema: z.ZodObject<{
221
+ content: z.ZodOptional<z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
222
+ type: z.ZodLiteral<"text">;
223
+ text: z.ZodString;
224
+ annotations: z.ZodOptional<z.ZodObject<{
225
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
226
+ user: "user";
227
+ assistant: "assistant";
228
+ }>>>;
229
+ priority: z.ZodOptional<z.ZodNumber>;
230
+ lastModified: z.ZodOptional<z.ZodISODateTime>;
231
+ }, z.core.$strip>>;
232
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
233
+ }, z.core.$strip>, z.ZodObject<{
234
+ type: z.ZodLiteral<"image">;
235
+ data: z.ZodString;
236
+ mimeType: z.ZodString;
237
+ annotations: z.ZodOptional<z.ZodObject<{
238
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
239
+ user: "user";
240
+ assistant: "assistant";
241
+ }>>>;
242
+ priority: z.ZodOptional<z.ZodNumber>;
243
+ lastModified: z.ZodOptional<z.ZodISODateTime>;
244
+ }, z.core.$strip>>;
245
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
246
+ }, z.core.$strip>, z.ZodObject<{
247
+ type: z.ZodLiteral<"audio">;
248
+ data: z.ZodString;
249
+ mimeType: z.ZodString;
250
+ annotations: z.ZodOptional<z.ZodObject<{
251
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
252
+ user: "user";
253
+ assistant: "assistant";
254
+ }>>>;
255
+ priority: z.ZodOptional<z.ZodNumber>;
256
+ lastModified: z.ZodOptional<z.ZodISODateTime>;
257
+ }, z.core.$strip>>;
258
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
259
+ }, z.core.$strip>, z.ZodObject<{
260
+ uri: z.ZodString;
261
+ description: z.ZodOptional<z.ZodString>;
262
+ mimeType: z.ZodOptional<z.ZodString>;
263
+ size: z.ZodOptional<z.ZodNumber>;
264
+ annotations: z.ZodOptional<z.ZodObject<{
265
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
266
+ user: "user";
267
+ assistant: "assistant";
268
+ }>>>;
269
+ priority: z.ZodOptional<z.ZodNumber>;
270
+ lastModified: z.ZodOptional<z.ZodISODateTime>;
271
+ }, z.core.$strip>>;
272
+ _meta: z.ZodOptional<z.ZodObject<{}, z.core.$loose>>;
273
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
274
+ src: z.ZodString;
275
+ mimeType: z.ZodOptional<z.ZodString>;
276
+ sizes: z.ZodOptional<z.ZodArray<z.ZodString>>;
277
+ theme: z.ZodOptional<z.ZodEnum<{
278
+ light: "light";
279
+ dark: "dark";
280
+ }>>;
281
+ }, z.core.$strip>>>;
282
+ name: z.ZodString;
283
+ title: z.ZodOptional<z.ZodString>;
284
+ type: z.ZodLiteral<"resource_link">;
285
+ }, z.core.$strip>, z.ZodObject<{
286
+ type: z.ZodLiteral<"resource">;
287
+ resource: z.ZodUnion<readonly [z.ZodObject<{
288
+ uri: z.ZodString;
289
+ mimeType: z.ZodOptional<z.ZodString>;
290
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
291
+ text: z.ZodString;
292
+ }, z.core.$strip>, z.ZodObject<{
293
+ uri: z.ZodString;
294
+ mimeType: z.ZodOptional<z.ZodString>;
295
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
296
+ blob: z.ZodString;
297
+ }, z.core.$strip>]>;
298
+ annotations: z.ZodOptional<z.ZodObject<{
299
+ audience: z.ZodOptional<z.ZodArray<z.ZodEnum<{
300
+ user: "user";
301
+ assistant: "assistant";
302
+ }>>>;
303
+ priority: z.ZodOptional<z.ZodNumber>;
304
+ lastModified: z.ZodOptional<z.ZodISODateTime>;
305
+ }, z.core.$strip>>;
306
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
307
+ }, z.core.$strip>]>>>;
308
+ structuredContent: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
309
+ }, z.core.$strict>;
310
+ export type McpAppModelContextRequest = z.infer<typeof McpAppModelContextRequestSchema>;
311
+ /**
312
+ * The most file content a view's read of its own file address answers: 64
313
+ * MiB, so a base64 `blob` of at most 4·⌈64 MiB / 3⌉ characters.
314
+ */
315
+ export declare const MAX_MCP_APP_FILE_BYTES: number;
316
+ /**
317
+ * Why a view's read of its own file address failed, as the gateway answers
318
+ * it: the file route refused the pass (`denied`), the file is past
319
+ * `MAX_MCP_APP_FILE_BYTES` (`tooLarge`), the view's server could not reach
320
+ * the file route, or the read found no turn on the listener or outlasted
321
+ * it (`unreachable`), or the gateway could not forward the read
322
+ * (`unavailable`).
323
+ */
324
+ export declare const McpAppFileReadFailureSchema: z.ZodEnum<{
325
+ denied: "denied";
326
+ tooLarge: "tooLarge";
327
+ unavailable: "unavailable";
328
+ unreachable: "unreachable";
329
+ }>;
330
+ export type McpAppFileReadFailure = z.infer<typeof McpAppFileReadFailureSchema>;
331
+ /**
332
+ * The `data` of the JSON-RPC error a view's server answers a failed file read
333
+ * with, so the gateway passes its reason on.
334
+ */
335
+ export declare const McpAppFileReadErrorDataSchema: z.ZodObject<{
336
+ reason: z.ZodEnum<{
337
+ denied: "denied";
338
+ tooLarge: "tooLarge";
339
+ unavailable: "unavailable";
340
+ unreachable: "unreachable";
341
+ }>;
342
+ }, z.core.$strip>;
343
+ export type McpAppFileReadErrorData = z.infer<typeof McpAppFileReadErrorDataSchema>;
211
344
  /**
212
345
  * The MCP App sandbox page: a static page that holds only the relay creating
213
346
  * the App's own frame. A host serves it from a sandbox origin of its own,
@@ -1,4 +1,24 @@
1
1
  import {
2
+ CallToolResultSchema2,
3
+ EmptyResultSchema2,
4
+ ReadResourceResultSchema2,
5
+ McpUiCspSchema2,
6
+ isMcpAppCspDomain2,
7
+ McpUiPermissionsSchema2,
8
+ McpAppFilesSchema2,
9
+ McpUiDomainSchema2,
10
+ McpAppViewSchema2,
11
+ viewerFileResult2,
12
+ McpAppToolCallRequestSchema2,
13
+ McpAppResourceReadRequestSchema2,
14
+ McpAppModelContextRequestSchema2,
15
+ MAX_MCP_APP_FILE_BYTES2,
16
+ McpAppFileReadFailureSchema2,
17
+ McpAppFileReadErrorDataSchema2,
18
+ MCP_APP_SANDBOX_PATH2,
19
+ isMcpAppPolicyOrigin2,
20
+ appliedMcpAppCsp2,
21
+ mcpAppSandboxPolicy2,
2
22
  SESSION_CATALOG_MAX_WINDOW2,
3
23
  RuntimeAuthStateSchema2,
4
24
  OperationCapabilitySchema2,
@@ -132,22 +152,7 @@ import {
132
152
  PushSubscriptionJsonSchema2,
133
153
  PushInfoSchema2,
134
154
  PushRegistrationSchema2,
135
- PushUnregistrationSchema2,
136
- CallToolResultSchema2,
137
- ReadResourceResultSchema2,
138
- McpUiCspSchema2,
139
- isMcpAppCspDomain2,
140
- McpUiPermissionsSchema2,
141
- McpAppFilesSchema2,
142
- McpUiDomainSchema2,
143
- McpAppViewSchema2,
144
- viewerFileResult2,
145
- McpAppToolCallRequestSchema2,
146
- McpAppResourceReadRequestSchema2,
147
- MCP_APP_SANDBOX_PATH2,
148
- isMcpAppPolicyOrigin2,
149
- appliedMcpAppCsp2,
150
- mcpAppSandboxPolicy2
155
+ PushUnregistrationSchema2
151
156
  } from "../chunks/index.js";
152
157
  // protocol/audio.ts
153
158
  var RECORDING_MIME_TYPES = [
@@ -212,6 +217,7 @@ export {
212
217
  CallToolResultSchema2 as CallToolResultSchema,
213
218
  DiffChangeSchema2 as DiffChangeSchema,
214
219
  DiffOperation2 as DiffOperation,
220
+ EmptyResultSchema2 as EmptyResultSchema,
215
221
  ErrorResponseSchema2 as ErrorResponseSchema,
216
222
  GuestRuntimeCapabilitiesResponseSchema2 as GuestRuntimeCapabilitiesResponseSchema,
217
223
  HGW_ACP_AGENTS_PATH2 as HGW_ACP_AGENTS_PATH,
@@ -276,13 +282,17 @@ export {
276
282
  HgwUsageMetaSchema2 as HgwUsageMetaSchema,
277
283
  INTERACTION_PROTOCOL2 as INTERACTION_PROTOCOL,
278
284
  IdentifierSchema2 as IdentifierSchema,
285
+ MAX_MCP_APP_FILE_BYTES2 as MAX_MCP_APP_FILE_BYTES,
279
286
  MAX_RECORDING_BYTES,
280
287
  MAX_SLASH_COMMANDS2 as MAX_SLASH_COMMANDS,
281
288
  MAX_SPEECH_BYTES,
282
289
  MAX_SPEECH_TEXT_BYTES,
283
290
  MAX_TRANSCRIPT_BYTES,
284
291
  MCP_APP_SANDBOX_PATH2 as MCP_APP_SANDBOX_PATH,
292
+ McpAppFileReadErrorDataSchema2 as McpAppFileReadErrorDataSchema,
293
+ McpAppFileReadFailureSchema2 as McpAppFileReadFailureSchema,
285
294
  McpAppFilesSchema2 as McpAppFilesSchema,
295
+ McpAppModelContextRequestSchema2 as McpAppModelContextRequestSchema,
286
296
  McpAppResourceReadRequestSchema2 as McpAppResourceReadRequestSchema,
287
297
  McpAppToolCallRequestSchema2 as McpAppToolCallRequestSchema,
288
298
  McpAppViewSchema2 as McpAppViewSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harness-gw/sdk",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "description": "A gateway that puts Hermes, OpenClaw, and OpenCode behind one ACP WebSocket, and the browser client and protocol SDK for it.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",