@harness-gw/sdk 0.13.0 → 0.14.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/README.md +2 -2
- package/dist/chunks/index.js +702 -689
- package/dist/client/acp-workspace-client.d.ts +3 -3
- package/dist/client/hgw-client.d.ts +14 -2
- package/dist/client/index.js +24 -8
- package/dist/protocol/index.d.ts +6 -0
- package/dist/protocol/mcp-apps.d.ts +38 -1
- package/dist/protocol/sdk.js +22 -16
- package/package.json +1 -1
|
@@ -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 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
|
-
/**
|
|
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?: {
|
package/dist/client/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CallToolResultSchema2,
|
|
3
|
+
ReadResourceResultSchema2,
|
|
4
|
+
McpAppFilesSchema2,
|
|
5
|
+
McpAppViewSchema2,
|
|
6
|
+
McpAppToolCallRequestSchema2,
|
|
7
|
+
McpAppResourceReadRequestSchema2,
|
|
2
8
|
RuntimeInfoSchema2,
|
|
3
9
|
SessionAttachmentStageRequestSchema2,
|
|
4
10
|
SessionAttachmentStageResponseSchema2,
|
|
@@ -37,13 +43,7 @@ import {
|
|
|
37
43
|
HgwErrorNotificationSchema2,
|
|
38
44
|
HgwActivityNotificationSchema2,
|
|
39
45
|
PushInfoSchema2,
|
|
40
|
-
PushUnregistrationSchema2
|
|
41
|
-
CallToolResultSchema2,
|
|
42
|
-
ReadResourceResultSchema2,
|
|
43
|
-
McpAppFilesSchema2,
|
|
44
|
-
McpAppViewSchema2,
|
|
45
|
-
McpAppToolCallRequestSchema2,
|
|
46
|
-
McpAppResourceReadRequestSchema2
|
|
46
|
+
PushUnregistrationSchema2
|
|
47
47
|
} from "../chunks/index.js";
|
|
48
48
|
|
|
49
49
|
// client/connection.ts
|
|
@@ -2497,6 +2497,15 @@ class HgwClientError extends Error {
|
|
|
2497
2497
|
this.name = "HgwClientError";
|
|
2498
2498
|
}
|
|
2499
2499
|
}
|
|
2500
|
+
|
|
2501
|
+
class McpAppFileReadError extends HgwClientError {
|
|
2502
|
+
reason;
|
|
2503
|
+
constructor(reason, ...failure) {
|
|
2504
|
+
super(...failure);
|
|
2505
|
+
this.reason = reason;
|
|
2506
|
+
this.name = "McpAppFileReadError";
|
|
2507
|
+
}
|
|
2508
|
+
}
|
|
2500
2509
|
async function normalizedError(response) {
|
|
2501
2510
|
const parsed = ErrorResponseSchema2.safeParse(await response.json().catch(() => {
|
|
2502
2511
|
return;
|
|
@@ -2540,7 +2549,13 @@ class HgwRemoteClient {
|
|
|
2540
2549
|
}
|
|
2541
2550
|
if (!response.ok) {
|
|
2542
2551
|
const error = await normalizedError(response);
|
|
2543
|
-
|
|
2552
|
+
const failure = [
|
|
2553
|
+
response.status === 503 ? "provider-unavailable" : response.status === 404 ? notFound : "gateway-failure",
|
|
2554
|
+
error?.description,
|
|
2555
|
+
error?.code,
|
|
2556
|
+
response.status
|
|
2557
|
+
];
|
|
2558
|
+
throw error?.reason ? new McpAppFileReadError(error.reason, ...failure) : new HgwClientError(...failure);
|
|
2544
2559
|
}
|
|
2545
2560
|
let payload;
|
|
2546
2561
|
try {
|
|
@@ -2736,6 +2751,7 @@ export {
|
|
|
2736
2751
|
AgentUpdateError,
|
|
2737
2752
|
HgwClientError,
|
|
2738
2753
|
HgwRemoteClient,
|
|
2754
|
+
McpAppFileReadError,
|
|
2739
2755
|
PART_GRACE_MS,
|
|
2740
2756
|
SILENT_LOGGER,
|
|
2741
2757
|
acpDebugEnabled,
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -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>;
|
|
@@ -203,11 +203,48 @@ 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
|
-
/**
|
|
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
|
+
* The most file content a view's read of its own file address answers: 64
|
|
217
|
+
* MiB, so a base64 `blob` of at most 4·⌈64 MiB / 3⌉ characters.
|
|
218
|
+
*/
|
|
219
|
+
export declare const MAX_MCP_APP_FILE_BYTES: number;
|
|
220
|
+
/**
|
|
221
|
+
* Why a view's read of its own file address failed, as the gateway answers
|
|
222
|
+
* it: the file route refused the pass (`denied`), the file is past
|
|
223
|
+
* `MAX_MCP_APP_FILE_BYTES` (`tooLarge`), the view's server could not reach
|
|
224
|
+
* the file route, or the read found no turn on the listener or outlasted
|
|
225
|
+
* it (`unreachable`), or the gateway could not forward the read
|
|
226
|
+
* (`unavailable`).
|
|
227
|
+
*/
|
|
228
|
+
export declare const McpAppFileReadFailureSchema: z.ZodEnum<{
|
|
229
|
+
denied: "denied";
|
|
230
|
+
tooLarge: "tooLarge";
|
|
231
|
+
unavailable: "unavailable";
|
|
232
|
+
unreachable: "unreachable";
|
|
233
|
+
}>;
|
|
234
|
+
export type McpAppFileReadFailure = z.infer<typeof McpAppFileReadFailureSchema>;
|
|
235
|
+
/**
|
|
236
|
+
* The `data` of the JSON-RPC error a view's server answers a failed file read
|
|
237
|
+
* with, so the gateway passes its reason on.
|
|
238
|
+
*/
|
|
239
|
+
export declare const McpAppFileReadErrorDataSchema: z.ZodObject<{
|
|
240
|
+
reason: z.ZodEnum<{
|
|
241
|
+
denied: "denied";
|
|
242
|
+
tooLarge: "tooLarge";
|
|
243
|
+
unavailable: "unavailable";
|
|
244
|
+
unreachable: "unreachable";
|
|
245
|
+
}>;
|
|
246
|
+
}, z.core.$strip>;
|
|
247
|
+
export type McpAppFileReadErrorData = z.infer<typeof McpAppFileReadErrorDataSchema>;
|
|
211
248
|
/**
|
|
212
249
|
* The MCP App sandbox page: a static page that holds only the relay creating
|
|
213
250
|
* the App's own frame. A host serves it from a sandbox origin of its own,
|
package/dist/protocol/sdk.js
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CallToolResultSchema2,
|
|
3
|
+
ReadResourceResultSchema2,
|
|
4
|
+
McpUiCspSchema2,
|
|
5
|
+
isMcpAppCspDomain2,
|
|
6
|
+
McpUiPermissionsSchema2,
|
|
7
|
+
McpAppFilesSchema2,
|
|
8
|
+
McpUiDomainSchema2,
|
|
9
|
+
McpAppViewSchema2,
|
|
10
|
+
viewerFileResult2,
|
|
11
|
+
McpAppToolCallRequestSchema2,
|
|
12
|
+
McpAppResourceReadRequestSchema2,
|
|
13
|
+
MAX_MCP_APP_FILE_BYTES2,
|
|
14
|
+
McpAppFileReadFailureSchema2,
|
|
15
|
+
McpAppFileReadErrorDataSchema2,
|
|
16
|
+
MCP_APP_SANDBOX_PATH2,
|
|
17
|
+
isMcpAppPolicyOrigin2,
|
|
18
|
+
appliedMcpAppCsp2,
|
|
19
|
+
mcpAppSandboxPolicy2,
|
|
2
20
|
SESSION_CATALOG_MAX_WINDOW2,
|
|
3
21
|
RuntimeAuthStateSchema2,
|
|
4
22
|
OperationCapabilitySchema2,
|
|
@@ -132,22 +150,7 @@ import {
|
|
|
132
150
|
PushSubscriptionJsonSchema2,
|
|
133
151
|
PushInfoSchema2,
|
|
134
152
|
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
|
|
153
|
+
PushUnregistrationSchema2
|
|
151
154
|
} from "../chunks/index.js";
|
|
152
155
|
// protocol/audio.ts
|
|
153
156
|
var RECORDING_MIME_TYPES = [
|
|
@@ -276,12 +279,15 @@ export {
|
|
|
276
279
|
HgwUsageMetaSchema2 as HgwUsageMetaSchema,
|
|
277
280
|
INTERACTION_PROTOCOL2 as INTERACTION_PROTOCOL,
|
|
278
281
|
IdentifierSchema2 as IdentifierSchema,
|
|
282
|
+
MAX_MCP_APP_FILE_BYTES2 as MAX_MCP_APP_FILE_BYTES,
|
|
279
283
|
MAX_RECORDING_BYTES,
|
|
280
284
|
MAX_SLASH_COMMANDS2 as MAX_SLASH_COMMANDS,
|
|
281
285
|
MAX_SPEECH_BYTES,
|
|
282
286
|
MAX_SPEECH_TEXT_BYTES,
|
|
283
287
|
MAX_TRANSCRIPT_BYTES,
|
|
284
288
|
MCP_APP_SANDBOX_PATH2 as MCP_APP_SANDBOX_PATH,
|
|
289
|
+
McpAppFileReadErrorDataSchema2 as McpAppFileReadErrorDataSchema,
|
|
290
|
+
McpAppFileReadFailureSchema2 as McpAppFileReadFailureSchema,
|
|
285
291
|
McpAppFilesSchema2 as McpAppFilesSchema,
|
|
286
292
|
McpAppResourceReadRequestSchema2 as McpAppResourceReadRequestSchema,
|
|
287
293
|
McpAppToolCallRequestSchema2 as McpAppToolCallRequestSchema,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@harness-gw/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.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",
|