@harness-gw/sdk 0.7.0 → 0.9.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 +64 -37
- package/dist/client/acp-approvals.d.ts +1 -1
- package/dist/client/acp-workspace-client-composer.d.ts +7 -0
- package/dist/client/acp-workspace-client-sessions.d.ts +5 -2
- package/dist/client/acp-workspace-client.d.ts +9 -0
- package/dist/client/connection.d.ts +1 -1
- package/dist/client/hgw-client.d.ts +5 -5
- package/dist/client/hgw-notification.d.ts +1 -1
- package/dist/client/index.js +104 -42
- package/dist/client/limits.d.ts +1 -1
- package/dist/client/types.d.ts +25 -2
- package/dist/client/workspace.d.ts +1 -0
- package/dist/protocol/acp.d.ts +36 -48
- package/dist/protocol/index.d.ts +143 -2
- package/dist/protocol/mcp-apps.d.ts +1 -1
- package/dist/protocol/sdk.js +12 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -63,7 +63,7 @@ You need a running harness. Hermes is the primary one; see
|
|
|
63
63
|
docker run --rm \
|
|
64
64
|
-v "$PWD/config.yaml:/run/harness-gw/config.yaml:ro" \
|
|
65
65
|
-v "$PWD/hermes-token:/run/secrets/hermes-token:ro" \
|
|
66
|
-
ghcr.io/almogbaku/harness-gw:0.
|
|
66
|
+
ghcr.io/almogbaku/harness-gw:0.9.0 \
|
|
67
67
|
config check --config /run/harness-gw/config.yaml
|
|
68
68
|
```
|
|
69
69
|
|
|
@@ -73,7 +73,7 @@ You need a running harness. Hermes is the primary one; see
|
|
|
73
73
|
docker run --rm -p 127.0.0.1:4100:4100 \
|
|
74
74
|
-v "$PWD/config.yaml:/run/harness-gw/config.yaml:ro" \
|
|
75
75
|
-v "$PWD/hermes-token:/run/secrets/hermes-token:ro" \
|
|
76
|
-
ghcr.io/almogbaku/harness-gw:0.
|
|
76
|
+
ghcr.io/almogbaku/harness-gw:0.9.0 \
|
|
77
77
|
serve --config /run/harness-gw/config.yaml
|
|
78
78
|
```
|
|
79
79
|
|
package/dist/chunks/index.js
CHANGED
|
@@ -282,11 +282,49 @@ var SessionPlanActivityMessageSchema2 = z.strictObject({
|
|
|
282
282
|
todos: z.array(TodoSchema).max(1e4)
|
|
283
283
|
})
|
|
284
284
|
});
|
|
285
|
+
var SessionCompactionActivityMessageSchema2 = z.strictObject({
|
|
286
|
+
id: IdentifierSchema,
|
|
287
|
+
role: z.literal("activity"),
|
|
288
|
+
activityType: z.literal("COMPACTION"),
|
|
289
|
+
content: z.strictObject({
|
|
290
|
+
compactionId: IdentifierSchema,
|
|
291
|
+
summary: z.string().max(1e6).optional()
|
|
292
|
+
})
|
|
293
|
+
});
|
|
294
|
+
var SessionChildActivityMessageSchema2 = z.strictObject({
|
|
295
|
+
id: IdentifierSchema,
|
|
296
|
+
role: z.literal("activity"),
|
|
297
|
+
activityType: z.literal("CHILD_SESSION"),
|
|
298
|
+
content: z.strictObject({
|
|
299
|
+
childSessionId: IdentifierSchema,
|
|
300
|
+
toolCallId: IdentifierSchema.optional(),
|
|
301
|
+
title: z.string().max(65536).optional(),
|
|
302
|
+
description: z.string().max(65536).optional(),
|
|
303
|
+
status: z.enum([
|
|
304
|
+
"running",
|
|
305
|
+
"waiting-for-input",
|
|
306
|
+
"idle",
|
|
307
|
+
"failed",
|
|
308
|
+
"cancelled",
|
|
309
|
+
"unknown"
|
|
310
|
+
]).optional(),
|
|
311
|
+
model: z.string().min(1).max(256).optional(),
|
|
312
|
+
filesRead: z.array(z.string().max(4096)).max(1000).optional(),
|
|
313
|
+
filesWritten: z.array(z.string().max(4096)).max(1000).optional(),
|
|
314
|
+
durationMs: z.number().int().nonnegative().optional(),
|
|
315
|
+
summary: z.string().max(65536).optional()
|
|
316
|
+
})
|
|
317
|
+
});
|
|
318
|
+
var SessionActivityMessageSchema2 = z.discriminatedUnion("activityType", [
|
|
319
|
+
SessionPlanActivityMessageSchema2,
|
|
320
|
+
SessionCompactionActivityMessageSchema2,
|
|
321
|
+
SessionChildActivityMessageSchema2
|
|
322
|
+
]);
|
|
285
323
|
var SessionHistoryResponseSchema2 = z.strictObject({
|
|
286
324
|
sessionId: IdentifierSchema,
|
|
287
325
|
messages: z.array(z.discriminatedUnion("role", [
|
|
288
326
|
SessionMessageSchema2,
|
|
289
|
-
|
|
327
|
+
SessionActivityMessageSchema2
|
|
290
328
|
])).max(501),
|
|
291
329
|
total: z.number().int().min(0),
|
|
292
330
|
limit: z.number().int().min(1).max(500),
|
|
@@ -392,6 +430,13 @@ var SessionWorkspaceCapabilitiesResponseSchema2 = z.strictObject({
|
|
|
392
430
|
}),
|
|
393
431
|
CapabilityUnavailableSchema
|
|
394
432
|
]),
|
|
433
|
+
rewind: z.union([
|
|
434
|
+
z.strictObject({
|
|
435
|
+
status: z.literal("available"),
|
|
436
|
+
scope: z.literal("user-turn")
|
|
437
|
+
}),
|
|
438
|
+
CapabilityUnavailableSchema
|
|
439
|
+
]),
|
|
395
440
|
approvals: z.strictObject({
|
|
396
441
|
status: z.literal("available"),
|
|
397
442
|
protocol: z.literal(INTERACTION_PROTOCOL2),
|
|
@@ -690,7 +735,7 @@ function hgwAcpAgentPath2(agentId) {
|
|
|
690
735
|
return `${HGW_ACP_AGENTS_PATH2}/${encodeURIComponent(agentId)}`;
|
|
691
736
|
}
|
|
692
737
|
var HGW_META_KEY2 = "hgw";
|
|
693
|
-
var HGW_EXTENSION_VERSION2 =
|
|
738
|
+
var HGW_EXTENSION_VERSION2 = 2;
|
|
694
739
|
var HGW_AUTH_METHOD_INVITE2 = "hgw-invite";
|
|
695
740
|
var HGW_ATTACHMENT_URI_SCHEME2 = "hgw-attachment:";
|
|
696
741
|
var HGW_ARTIFACT_URI_SCHEME2 = "artifact:";
|
|
@@ -715,10 +760,6 @@ var HGW_METHODS2 = {
|
|
|
715
760
|
error: "_hgw/error"
|
|
716
761
|
}
|
|
717
762
|
};
|
|
718
|
-
var HGW_STOP_REASONS2 = {
|
|
719
|
-
error: "_hgw_error",
|
|
720
|
-
uncertain: "_hgw_uncertain"
|
|
721
|
-
};
|
|
722
763
|
var HGW_PERMISSION_KIND_SESSION2 = "_allow_session";
|
|
723
764
|
var HGW_PLAN_ID2 = "todos";
|
|
724
765
|
var HGW_JSONRPC_ERRORS2 = {
|
|
@@ -727,7 +768,6 @@ var HGW_JSONRPC_ERRORS2 = {
|
|
|
727
768
|
revisionConflict: -31012,
|
|
728
769
|
temporarilyUnavailable: -31013,
|
|
729
770
|
uncertainMutation: -31014,
|
|
730
|
-
unsupported: -31015,
|
|
731
771
|
requestTooLarge: -31016
|
|
732
772
|
};
|
|
733
773
|
var HGW_MAX_FRAME_BYTES2 = 1100000;
|
|
@@ -793,9 +833,14 @@ var HgwSessionInfoMetaSchema2 = readObject({
|
|
|
793
833
|
platform: SessionPlatformSchema2.optional()
|
|
794
834
|
});
|
|
795
835
|
var HgwSessionResumeMetaSchema2 = z2.strictObject({
|
|
796
|
-
agentId: IdentifierSchema2.optional()
|
|
797
|
-
|
|
798
|
-
|
|
836
|
+
agentId: IdentifierSchema2.optional()
|
|
837
|
+
});
|
|
838
|
+
var HGW_REPLAY_POSITION2 = "_hgw/position";
|
|
839
|
+
var HgwReplayPositionSchema2 = z2.strictObject({
|
|
840
|
+
type: z2.literal(HGW_REPLAY_POSITION2),
|
|
841
|
+
turnId: IdentifierSchema2.optional(),
|
|
842
|
+
from: z2.number().int().min(1).optional(),
|
|
843
|
+
_meta: z2.record(z2.string(), z2.unknown()).nullish()
|
|
799
844
|
});
|
|
800
845
|
var HGW_REPLAY_BEFORE2 = "_hgw/before";
|
|
801
846
|
var HgwReplayBeforeSchema2 = z2.strictObject({
|
|
@@ -851,7 +896,8 @@ var HgwAgentUpdateRequestSchema2 = z2.strictObject({ agentId: IdentifierSchema2,
|
|
|
851
896
|
var HgwAgentUpdateResponseSchema2 = AgentUpdateResponseSchema2;
|
|
852
897
|
var TurnMetaBase = {
|
|
853
898
|
sequence: SequenceSchema,
|
|
854
|
-
turnId: IdentifierSchema2
|
|
899
|
+
turnId: IdentifierSchema2,
|
|
900
|
+
background: z2.literal(true).optional()
|
|
855
901
|
};
|
|
856
902
|
var HgwTurnMetaSchema2 = readObject(TurnMetaBase);
|
|
857
903
|
var NoticeKindSchema = z2.string().min(1).max(64);
|
|
@@ -871,29 +917,15 @@ var HgwCostSchema2 = readObject({
|
|
|
871
917
|
amount: z2.number().nonnegative(),
|
|
872
918
|
currency: z2.string().min(1).max(16)
|
|
873
919
|
});
|
|
874
|
-
var
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
"failed",
|
|
878
|
-
"cancelled"
|
|
879
|
-
];
|
|
880
|
-
var HgwSubagentSchema2 = readObject({
|
|
881
|
-
id: IdentifierSchema2,
|
|
882
|
-
goal: z2.string().max(65536).optional(),
|
|
920
|
+
var HgwChildSessionMetaSchema2 = readObject({
|
|
921
|
+
...TurnMetaBase,
|
|
922
|
+
toolCallId: IdentifierSchema2.optional(),
|
|
883
923
|
model: z2.string().min(1).max(256).optional(),
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
tokens: CountSchema.optional(),
|
|
887
|
-
filesRead: z2.array(z2.string()).optional(),
|
|
888
|
-
filesWritten: z2.array(z2.string()).optional(),
|
|
924
|
+
filesRead: z2.array(z2.string().max(4096)).max(1000).optional(),
|
|
925
|
+
filesWritten: z2.array(z2.string().max(4096)).max(1000).optional(),
|
|
889
926
|
durationMs: CountSchema.optional(),
|
|
890
|
-
childSessionId: IdentifierSchema2.optional(),
|
|
891
927
|
summary: z2.string().max(65536).optional()
|
|
892
928
|
});
|
|
893
|
-
var SubagentAttribution = {
|
|
894
|
-
subagentId: IdentifierSchema2.optional(),
|
|
895
|
-
parentToolCallId: IdentifierSchema2.optional()
|
|
896
|
-
};
|
|
897
929
|
var HgwStateMetaSchema2 = readObject({
|
|
898
930
|
...TurnMetaBase,
|
|
899
931
|
at: z2.iso.datetime().optional(),
|
|
@@ -904,20 +936,15 @@ var HgwStateMetaSchema2 = readObject({
|
|
|
904
936
|
model: z2.string().min(1).max(256).optional(),
|
|
905
937
|
cost: HgwCostSchema2.optional()
|
|
906
938
|
});
|
|
907
|
-
var HgwChunkMetaSchema2 = readObject({
|
|
908
|
-
...TurnMetaBase,
|
|
909
|
-
...SubagentAttribution
|
|
910
|
-
});
|
|
939
|
+
var HgwChunkMetaSchema2 = readObject({ ...TurnMetaBase });
|
|
911
940
|
var HgwToolCallMetaSchema2 = readObject({
|
|
912
941
|
...TurnMetaBase,
|
|
913
|
-
...SubagentAttribution,
|
|
914
942
|
messageId: IdentifierSchema2,
|
|
915
943
|
argsTextDelta: z2.string().optional(),
|
|
916
944
|
argsText: z2.string().optional(),
|
|
917
945
|
startedAt: z2.iso.datetime().optional(),
|
|
918
946
|
completedAt: z2.iso.datetime().optional(),
|
|
919
947
|
durationMs: CountSchema.optional(),
|
|
920
|
-
subagent: HgwSubagentSchema2.optional(),
|
|
921
948
|
app: z2.strictObject({}).optional()
|
|
922
949
|
});
|
|
923
950
|
var HgwPlanMetaSchema2 = readObject({
|
|
@@ -1182,4 +1209,4 @@ var MCP_APP_SANDBOX_CSP2 = [
|
|
|
1182
1209
|
"frame-ancestors 'self'"
|
|
1183
1210
|
].join("; ");
|
|
1184
1211
|
|
|
1185
|
-
export { SESSION_CATALOG_MAX_WINDOW2, RuntimeAuthStateSchema2, OperationCapabilitySchema2, RuntimeInfoSchema2, AgentAvatarSchema2, AgentCatalogEntrySchema2, AgentCatalogResponseSchema2, AgentUpdateFields2, writesAgentField2, AgentUpdateRequestSchema2, AgentUpdateResponseSchema2, SessionStatusSchema2, SessionPlatformSchema2, SessionSchema2, newestSessionFirst2, SessionCatalogResponseSchema2, StopReason2, ToolKind2, ToolLocationSchema2, DiffOperation2, DiffChangeSchema2, ToolDiffSchema2, SessionMessageErrorStatusSchema2, SessionMessageSchema2, SessionPlanActivityMessageSchema2, SessionHistoryResponseSchema2, SessionCreateRequestSchema2, SessionCreateResponseSchema2, SessionPatchRequestSchema2, TurnStopResponseSchema2, TurnSteerRequestSchema2, TurnSteerResponseSchema2, SlashCommandSchema2, MAX_SLASH_COMMANDS2, INTERACTION_PROTOCOL2, SessionWorkspaceCapabilitiesResponseSchema2, GuestRuntimeCapabilitiesResponseSchema2, SessionModelsResponseSchema2, SessionModelUpdateRequestSchema2, SessionModelUpdateResponseSchema2, SessionContextResponseSchema2, ArtifactDescriptorSchema2, SessionTodosResponseSchema2, SessionActivityResponseSchema2, SessionAttachmentStageRequestSchema2, SessionAttachmentStageResponseSchema2, SessionAudioResponseSchema2, SessionTranscriptionRequestSchema2, SessionTranscriptionResponseSchema2, SessionSpeechRequestSchema2, ErrorResponseSchema2, ACP_PROTOCOL_VERSION2, HGW_API_PREFIX2, HGW_ACP_PATH2, HGW_ACP_AGENTS_PATH2, hgwAcpAgentPath2, HGW_META_KEY2, HGW_EXTENSION_VERSION2, HGW_AUTH_METHOD_INVITE2, HGW_ATTACHMENT_URI_SCHEME2, HGW_ARTIFACT_URI_SCHEME2, HGW_METHODS2,
|
|
1212
|
+
export { SESSION_CATALOG_MAX_WINDOW2, RuntimeAuthStateSchema2, OperationCapabilitySchema2, RuntimeInfoSchema2, AgentAvatarSchema2, AgentCatalogEntrySchema2, AgentCatalogResponseSchema2, AgentUpdateFields2, writesAgentField2, AgentUpdateRequestSchema2, AgentUpdateResponseSchema2, SessionStatusSchema2, SessionPlatformSchema2, SessionSchema2, newestSessionFirst2, SessionCatalogResponseSchema2, StopReason2, ToolKind2, ToolLocationSchema2, DiffOperation2, DiffChangeSchema2, ToolDiffSchema2, SessionMessageErrorStatusSchema2, SessionMessageSchema2, SessionPlanActivityMessageSchema2, SessionCompactionActivityMessageSchema2, SessionChildActivityMessageSchema2, SessionActivityMessageSchema2, SessionHistoryResponseSchema2, SessionCreateRequestSchema2, SessionCreateResponseSchema2, SessionPatchRequestSchema2, TurnStopResponseSchema2, TurnSteerRequestSchema2, TurnSteerResponseSchema2, SlashCommandSchema2, MAX_SLASH_COMMANDS2, INTERACTION_PROTOCOL2, SessionWorkspaceCapabilitiesResponseSchema2, GuestRuntimeCapabilitiesResponseSchema2, SessionModelsResponseSchema2, SessionModelUpdateRequestSchema2, SessionModelUpdateResponseSchema2, SessionContextResponseSchema2, ArtifactDescriptorSchema2, SessionTodosResponseSchema2, SessionActivityResponseSchema2, SessionAttachmentStageRequestSchema2, SessionAttachmentStageResponseSchema2, SessionAudioResponseSchema2, SessionTranscriptionRequestSchema2, SessionTranscriptionResponseSchema2, SessionSpeechRequestSchema2, ErrorResponseSchema2, ACP_PROTOCOL_VERSION2, HGW_API_PREFIX2, HGW_ACP_PATH2, HGW_ACP_AGENTS_PATH2, hgwAcpAgentPath2, HGW_META_KEY2, HGW_EXTENSION_VERSION2, HGW_AUTH_METHOD_INVITE2, HGW_ATTACHMENT_URI_SCHEME2, HGW_ARTIFACT_URI_SCHEME2, HGW_METHODS2, HGW_PERMISSION_KIND_SESSION2, HGW_PLAN_ID2, HGW_JSONRPC_ERRORS2, HGW_MAX_FRAME_BYTES2, IdentifierSchema2, HgwExtensionsSchema2, HgwClientCapabilitiesMetaSchema2, HgwInitializeMetaSchema2, HgwLoginMetaSchema2, HgwSessionNewMetaSchema2, HgwSessionListMetaSchema2, HgwSessionSearchMetaSchema2, HgwSessionSearchResponseSchema2, HgwSessionInfoMetaSchema2, HgwSessionResumeMetaSchema2, HGW_REPLAY_POSITION2, HgwReplayPositionSchema2, HGW_REPLAY_BEFORE2, HgwReplayBeforeSchema2, HgwHistoryCursorSchema2, HgwHistoryPageResponseMetaSchema2, HgwHistoryPageTagSchema2, HgwSessionResumeResponseMetaSchema2, HgwPromptMetaSchema2, HgwSessionUpdateRequestSchema2, HgwSessionPartRequestSchema2, HgwSteerRequestSchema2, HgwSteerResponseSchema2, HgwFocusRequestSchema2, HgwAgentsListResponseSchema2, HgwAgentUpdateRequestSchema2, HgwAgentUpdateResponseSchema2, HgwTurnMetaSchema2, HgwNoticeMetaSchema2, HgwMessageMetaSchema2, HgwCostSchema2, HgwChildSessionMetaSchema2, HgwStateMetaSchema2, HgwChunkMetaSchema2, HgwToolCallMetaSchema2, HgwPlanMetaSchema2, HgwUsageMetaSchema2, HgwAvailableCommandsMetaSchema2, HgwPermissionMetaSchema2, HgwQuestionOptionSchema2, HgwQuestionSchema2, HgwElicitationMetaSchema2, HgwArtifactDescriptorSchema2, formatArtifactUri2, parseArtifactUri2, HgwComposerPrefillNotificationSchema2, HgwErrorNotificationSchema2, HGW_REQUEST_TEXT_MAX2, HgwActivityNotificationSchema2, PushCategorySchema2, categoryOf2, PushLocaleSchema2, PRESENCE_IDLE_MS2, PRESENCE_HEARTBEAT_MS2, PRESENCE_GRACE_MS2, PRESENCE_CLOSED_GRACE_MS2, COALESCE_WINDOW_MS2, PUSH_TEXT_LIMITS2, PushMessageSchema2, PushCategoriesSchema2, PushSubscriptionJsonSchema2, PushInfoSchema2, PushRegistrationSchema2, PushUnregistrationSchema2, CallToolResultSchema2, ReadResourceResultSchema2, McpUiCspSchema2, isMcpAppCspDomain2, McpUiPermissionsSchema2, McpAppFilesSchema2, McpAppViewSchema2, viewerFileResult2, McpAppToolCallRequestSchema2, McpAppResourceReadRequestSchema2, MCP_APP_SANDBOX_PATH2, MCP_APP_SANDBOX_CSP2 };
|
|
@@ -21,7 +21,7 @@ export type AcpApprovalOption = {
|
|
|
21
21
|
};
|
|
22
22
|
export type AcpApproval = {
|
|
23
23
|
readonly id: string;
|
|
24
|
-
/** The tool call the request guards, when the
|
|
24
|
+
/** The tool call the request guards, when the gateway knows it. */
|
|
25
25
|
readonly toolCallId?: string;
|
|
26
26
|
/** The operation asked for, which is the request's title. */
|
|
27
27
|
readonly action: string;
|
|
@@ -90,6 +90,13 @@ export declare function createAcpComposerStore(connection: AcpConnection): {
|
|
|
90
90
|
input: "text";
|
|
91
91
|
fallback: "provider-queue";
|
|
92
92
|
};
|
|
93
|
+
rewind: {
|
|
94
|
+
status: "unavailable";
|
|
95
|
+
reason: string;
|
|
96
|
+
} | {
|
|
97
|
+
status: "available";
|
|
98
|
+
scope: "user-turn";
|
|
99
|
+
};
|
|
93
100
|
approvals: {
|
|
94
101
|
status: "available";
|
|
95
102
|
protocol: "acp-request";
|
|
@@ -43,8 +43,11 @@ export declare function createAcpSessionStore({ connection, now, onTurnFinished,
|
|
|
43
43
|
answer(sessionIds: readonly string[]): void;
|
|
44
44
|
/** The provider's title, as a list page or a subscribed Session reports it. */
|
|
45
45
|
setTitle: (sessionId: string, title: string) => Map<string, string>;
|
|
46
|
-
/**
|
|
47
|
-
|
|
46
|
+
/**
|
|
47
|
+
* The gateway's read state, or the operator's own optimistic write;
|
|
48
|
+
* `undefined` restores a refused one.
|
|
49
|
+
*/
|
|
50
|
+
setUnread: (sessionId: string, unread: boolean | undefined) => void;
|
|
48
51
|
/** The operator's own optimistic pin; `undefined` restores a refused one. */
|
|
49
52
|
setPinned: (sessionId: string, pinned: boolean | undefined) => void;
|
|
50
53
|
setStatus: (sessionId: string, status: SessionStatus) => void;
|
|
@@ -109,6 +109,8 @@ export declare function createAcpWorkspaceClient({ connection, rest, agentIdFor,
|
|
|
109
109
|
markSessionRead(sessionId: string): Promise<void>;
|
|
110
110
|
/** The row leads the write, so a refused pin has to be taken back. */
|
|
111
111
|
setSessionPinned(sessionId: string, pinned: boolean): Promise<void>;
|
|
112
|
+
/** As a pin does, the row leads the write and a refusal takes it back. */
|
|
113
|
+
markSessionUnread(sessionId: string): Promise<void>;
|
|
112
114
|
/**
|
|
113
115
|
* The runtime's own report, read once. A failed read is not an answer, so
|
|
114
116
|
* it is not remembered.
|
|
@@ -184,6 +186,13 @@ export declare function createAcpWorkspaceClient({ connection, rest, agentIdFor,
|
|
|
184
186
|
input: "text";
|
|
185
187
|
fallback: "provider-queue";
|
|
186
188
|
};
|
|
189
|
+
rewind: {
|
|
190
|
+
status: "unavailable";
|
|
191
|
+
reason: string;
|
|
192
|
+
} | {
|
|
193
|
+
status: "available";
|
|
194
|
+
scope: "user-turn";
|
|
195
|
+
};
|
|
187
196
|
approvals: {
|
|
188
197
|
status: "available";
|
|
189
198
|
protocol: "acp-request";
|
|
@@ -48,7 +48,7 @@ export type AcpConnectionOptions = {
|
|
|
48
48
|
url?: never;
|
|
49
49
|
socketConstructor?: never;
|
|
50
50
|
});
|
|
51
|
-
/** Whether the
|
|
51
|
+
/** Whether the gateway refused an invitation it cannot redeem. */
|
|
52
52
|
export declare function isAuthenticationRequired(error: unknown): boolean;
|
|
53
53
|
/** One of the gateway's ACP listener paths as a WebSocket URL from `base`. */
|
|
54
54
|
export declare function acpSocketUrl(path: string, base: string): string;
|
|
@@ -6,7 +6,7 @@ import type { StagedAttachment } from "./workspace.js";
|
|
|
6
6
|
export type HgwWorkspaceCapabilities = z.infer<typeof SessionWorkspaceCapabilitiesResponseSchema>;
|
|
7
7
|
export type HgwModelChoices = z.infer<typeof SessionModelsResponseSchema>;
|
|
8
8
|
export type HgwContext = z.infer<typeof SessionContextResponseSchema>;
|
|
9
|
-
export type HgwClientFailure = "connection-interrupted" | "provider-unavailable" | "
|
|
9
|
+
export type HgwClientFailure = "connection-interrupted" | "provider-unavailable" | "gateway-failure"
|
|
10
10
|
/** The provider no longer holds the bytes a published receipt points at. */
|
|
11
11
|
| "artifact-missing";
|
|
12
12
|
/** What an MCP App view is opened for: a tool call, or a published Artifact. */
|
|
@@ -18,10 +18,10 @@ export type McpAppSubject = {
|
|
|
18
18
|
export declare class HgwClientError extends Error {
|
|
19
19
|
readonly kind: HgwClientFailure;
|
|
20
20
|
readonly code?: string | undefined;
|
|
21
|
-
/** The
|
|
21
|
+
/** The gateway's HTTP status, when it answered. */
|
|
22
22
|
readonly status?: number | undefined;
|
|
23
23
|
constructor(kind: HgwClientFailure, message?: string, code?: string | undefined,
|
|
24
|
-
/** The
|
|
24
|
+
/** The gateway's HTTP status, when it answered. */
|
|
25
25
|
status?: number | undefined);
|
|
26
26
|
}
|
|
27
27
|
/** The `fetch` the client sends every request with. */
|
|
@@ -302,7 +302,7 @@ export declare class HgwRemoteClient {
|
|
|
302
302
|
addresses: Record<string, string>;
|
|
303
303
|
expiresAt?: string | undefined;
|
|
304
304
|
}>;
|
|
305
|
-
/** A tool call the App view makes, answered by the
|
|
305
|
+
/** A tool call the App view makes, answered by the gateway's MCP server. */
|
|
306
306
|
callMcpAppTool(sessionId: string, toolCallId: string, request: McpAppToolCallRequest): Promise<{
|
|
307
307
|
[x: string]: unknown;
|
|
308
308
|
_meta?: {
|
|
@@ -395,7 +395,7 @@ export declare class HgwRemoteClient {
|
|
|
395
395
|
structuredContent?: unknown;
|
|
396
396
|
isError?: boolean | undefined;
|
|
397
397
|
}>;
|
|
398
|
-
/** A resource read the App view makes, answered by the
|
|
398
|
+
/** A resource read the App view makes, answered by the gateway's MCP server. */
|
|
399
399
|
readMcpAppResource(sessionId: string, subject: McpAppSubject, request: McpAppResourceReadRequest): Promise<{
|
|
400
400
|
[x: string]: unknown;
|
|
401
401
|
_meta?: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { z } from "zod";
|
|
2
2
|
import type { AcpConnection } from "./types.js";
|
|
3
|
-
/** Runs `handler` for every notification of `method` the
|
|
3
|
+
/** Runs `handler` for every notification of `method` the gateway sends. */
|
|
4
4
|
export declare function subscribeHgwNotification<Value>(connection: Pick<AcpConnection, "subscribeNotification">, method: string, schema: Pick<z.ZodType<Value>, "safeParse">, handler: (value: Value) => void): () => void;
|
package/dist/client/index.js
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
HGW_EXTENSION_VERSION2,
|
|
12
12
|
HGW_AUTH_METHOD_INVITE2,
|
|
13
13
|
HGW_METHODS2,
|
|
14
|
-
HGW_STOP_REASONS2,
|
|
15
14
|
HGW_PERMISSION_KIND_SESSION2,
|
|
16
15
|
HGW_JSONRPC_ERRORS2,
|
|
17
16
|
HGW_MAX_FRAME_BYTES2,
|
|
@@ -19,6 +18,7 @@ import {
|
|
|
19
18
|
HgwSessionSearchMetaSchema2,
|
|
20
19
|
HgwSessionSearchResponseSchema2,
|
|
21
20
|
HgwSessionInfoMetaSchema2,
|
|
21
|
+
HGW_REPLAY_POSITION2,
|
|
22
22
|
HGW_REPLAY_BEFORE2,
|
|
23
23
|
HgwHistoryPageResponseMetaSchema2,
|
|
24
24
|
HgwHistoryPageTagSchema2,
|
|
@@ -50,7 +50,8 @@ import {
|
|
|
50
50
|
import {
|
|
51
51
|
client,
|
|
52
52
|
methods as methods2,
|
|
53
|
-
RequestError
|
|
53
|
+
RequestError,
|
|
54
|
+
SessionUpdate
|
|
54
55
|
} from "@agentclientprotocol/sdk/experimental/v2";
|
|
55
56
|
import {
|
|
56
57
|
createWebSocketStream
|
|
@@ -444,7 +445,7 @@ var SESSION_STATES = new Map([
|
|
|
444
445
|
["gone", "gone"]
|
|
445
446
|
]);
|
|
446
447
|
function agentUpdateError(error) {
|
|
447
|
-
if (codeOf(error) ===
|
|
448
|
+
if (codeOf(error) === RequestError.invalidParams().code)
|
|
448
449
|
return new AgentUpdateError("unsupported", "This runtime cannot store that Agent field");
|
|
449
450
|
if (codeOf(error) === HGW_JSONRPC_ERRORS2.revisionConflict)
|
|
450
451
|
return new AgentUpdateError("conflict", "The Agent changed; reload it");
|
|
@@ -459,6 +460,12 @@ function acpSocketUrl(path, base) {
|
|
|
459
460
|
url.protocol = url.protocol === "https:" ? "wss:" : "ws:";
|
|
460
461
|
return url.toString();
|
|
461
462
|
}
|
|
463
|
+
function rejoinCursor(position) {
|
|
464
|
+
return {
|
|
465
|
+
type: HGW_REPLAY_POSITION2,
|
|
466
|
+
...position === undefined ? {} : { turnId: position.turnId, from: position.after + 1 }
|
|
467
|
+
};
|
|
468
|
+
}
|
|
462
469
|
function subscribeTo(listeners, listener) {
|
|
463
470
|
listeners.add(listener);
|
|
464
471
|
return () => {
|
|
@@ -703,6 +710,8 @@ function createAcpConnection(options) {
|
|
|
703
710
|
const outageListeners = new Set;
|
|
704
711
|
const sessions = new Map;
|
|
705
712
|
const owners = new Map;
|
|
713
|
+
const children = new Map;
|
|
714
|
+
let agentCapabilities;
|
|
706
715
|
let status = "connecting";
|
|
707
716
|
let outage;
|
|
708
717
|
let started = false;
|
|
@@ -735,7 +744,19 @@ function createAcpConnection(options) {
|
|
|
735
744
|
outage = next;
|
|
736
745
|
callEach(outageListeners, logger, "acp.listener.failed", next);
|
|
737
746
|
}
|
|
747
|
+
function ownerOf(sessionId) {
|
|
748
|
+
let owner = children.get(sessionId);
|
|
749
|
+
for (let depth = 0;owner !== undefined && depth < 8; depth += 1) {
|
|
750
|
+
if (sessions.has(owner))
|
|
751
|
+
return owner;
|
|
752
|
+
owner = children.get(owner);
|
|
753
|
+
}
|
|
754
|
+
return;
|
|
755
|
+
}
|
|
738
756
|
function emitPending(request) {
|
|
757
|
+
const parentSessionId = request.sessionId === undefined ? undefined : ownerOf(request.sessionId);
|
|
758
|
+
if (parentSessionId !== undefined)
|
|
759
|
+
request = { ...request, parentSessionId };
|
|
739
760
|
for (const listener of pendingListeners)
|
|
740
761
|
try {
|
|
741
762
|
listener(request);
|
|
@@ -793,23 +814,37 @@ function createAcpConnection(options) {
|
|
|
793
814
|
});
|
|
794
815
|
});
|
|
795
816
|
}
|
|
817
|
+
function deliverChild(open, childSessionId, update, meta) {
|
|
818
|
+
for (const { listener } of open.listeners)
|
|
819
|
+
callEach(listener.child ? [listener.child] : [], logger, "acp.listener.failed", childSessionId, update, meta);
|
|
820
|
+
}
|
|
796
821
|
const app = client({ name: clientInfo.name }).onNotification(methods2.client.session.update, ({ params }) => {
|
|
797
822
|
const meta = hgwMetaOf(params.update._meta);
|
|
798
|
-
|
|
823
|
+
if (SessionUpdate.isSubagentUpdate(params.update))
|
|
824
|
+
children.set(params.update.sessionId, params.sessionId);
|
|
825
|
+
const owner = sessions.has(params.sessionId) ? undefined : ownerOf(params.sessionId);
|
|
826
|
+
const open = sessions.get(owner ?? params.sessionId);
|
|
799
827
|
if (!open)
|
|
800
828
|
return;
|
|
801
829
|
if (HgwHistoryPageTagSchema2.safeParse(meta).data?.historyPage) {
|
|
802
|
-
|
|
830
|
+
if (owner !== undefined)
|
|
831
|
+
deliverChild(open, params.sessionId, params.update, meta);
|
|
832
|
+
else
|
|
833
|
+
open.page?.push({ update: params.update, meta });
|
|
803
834
|
return;
|
|
804
835
|
}
|
|
805
836
|
const position = HgwChunkMetaSchema2.safeParse(meta);
|
|
806
|
-
if (position.success)
|
|
837
|
+
if (position.success && !position.data.background)
|
|
807
838
|
open.position = {
|
|
808
839
|
turnId: position.data.turnId,
|
|
809
840
|
after: position.data.sequence
|
|
810
841
|
};
|
|
811
842
|
if (open.replaying)
|
|
812
843
|
open.replaying.delivered = true;
|
|
844
|
+
if (owner !== undefined) {
|
|
845
|
+
deliverChild(open, params.sessionId, params.update, meta);
|
|
846
|
+
return;
|
|
847
|
+
}
|
|
813
848
|
for (const { listener } of open.listeners)
|
|
814
849
|
callEach(listener.update ? [listener.update] : [], logger, "acp.listener.failed", params.update, meta);
|
|
815
850
|
}).onRequest(methods2.client.session.requestPermission, ({ params, signal }) => permissionRequest(params, signal)).onRequest(methods2.client.elicitation.create, ({ params, signal }) => elicitationRequest(params, signal));
|
|
@@ -903,6 +938,7 @@ function createAcpConnection(options) {
|
|
|
903
938
|
}
|
|
904
939
|
});
|
|
905
940
|
const announced = hgwMetaOf(response._meta);
|
|
941
|
+
agentCapabilities = response.capabilities ?? undefined;
|
|
906
942
|
if (announced?.version !== HGW_EXTENSION_VERSION2) {
|
|
907
943
|
const error = new Error(`The gateway speaks hgw extension version ${String(announced?.version)}; this client speaks version ${HGW_EXTENSION_VERSION2}`);
|
|
908
944
|
failInitialized?.(error);
|
|
@@ -952,12 +988,9 @@ function createAcpConnection(options) {
|
|
|
952
988
|
const response = await requestOn(transport, fromStart ? "long" : "medium", (agent, options) => agent.request(methods2.agent.session.resume, {
|
|
953
989
|
sessionId,
|
|
954
990
|
cwd: AGENT_CWD,
|
|
955
|
-
|
|
991
|
+
replayFrom: fromStart ? { type: "start" } : rejoinCursor(open.position),
|
|
956
992
|
_meta: {
|
|
957
|
-
[HGW_META_KEY2]: {
|
|
958
|
-
...agentId === undefined ? {} : { agentId },
|
|
959
|
-
...fromStart ? {} : open.position
|
|
960
|
-
}
|
|
993
|
+
[HGW_META_KEY2]: agentId === undefined ? {} : { agentId }
|
|
961
994
|
}
|
|
962
995
|
}, options), signal);
|
|
963
996
|
const meta = HgwSessionResumeResponseMetaSchema2.parse(hgwMetaOf(response._meta));
|
|
@@ -1088,6 +1121,9 @@ function createAcpConnection(options) {
|
|
|
1088
1121
|
function part(sessionId, open) {
|
|
1089
1122
|
sessions.delete(sessionId);
|
|
1090
1123
|
owners.delete(sessionId);
|
|
1124
|
+
for (const [child, parent] of children)
|
|
1125
|
+
if (parent === sessionId)
|
|
1126
|
+
children.delete(child);
|
|
1091
1127
|
open.owner?.dispose();
|
|
1092
1128
|
open.waiters?.reject(notOpen());
|
|
1093
1129
|
open.waiters = undefined;
|
|
@@ -1255,6 +1291,9 @@ function createAcpConnection(options) {
|
|
|
1255
1291
|
get status() {
|
|
1256
1292
|
return status;
|
|
1257
1293
|
},
|
|
1294
|
+
get capabilities() {
|
|
1295
|
+
return agentCapabilities;
|
|
1296
|
+
},
|
|
1258
1297
|
start,
|
|
1259
1298
|
initialized,
|
|
1260
1299
|
subscribeStatus: (listener) => subscribeTo(statusListeners, listener),
|
|
@@ -1272,6 +1311,17 @@ function createAcpConnection(options) {
|
|
|
1272
1311
|
}
|
|
1273
1312
|
return { sessionId };
|
|
1274
1313
|
},
|
|
1314
|
+
async forkSession(sessionId) {
|
|
1315
|
+
const forked = await request("short", (agent, options) => agent.request(methods2.agent.session.fork, { sessionId, cwd: AGENT_CWD }, options));
|
|
1316
|
+
const agentId = owners.get(sessionId);
|
|
1317
|
+
if (agentId !== undefined)
|
|
1318
|
+
owners.set(forked.sessionId, agentId);
|
|
1319
|
+
if (!sessions.has(forked.sessionId)) {
|
|
1320
|
+
const open = openSession(forked.sessionId, [], true);
|
|
1321
|
+
open.grace = clock.setTimeout(() => part(forked.sessionId, open), PART_GRACE_MS);
|
|
1322
|
+
}
|
|
1323
|
+
return { sessionId: forked.sessionId };
|
|
1324
|
+
},
|
|
1275
1325
|
async listSessions(meta, cursor) {
|
|
1276
1326
|
const response = await request("short", (agent, options) => agent.request(methods2.agent.session.list, {
|
|
1277
1327
|
...cursor === undefined ? {} : { cursor },
|
|
@@ -1352,7 +1402,7 @@ function createAcpConnection(options) {
|
|
|
1352
1402
|
// client/acp-workspace-client-composer.ts
|
|
1353
1403
|
import {
|
|
1354
1404
|
SessionConfigOption,
|
|
1355
|
-
SessionUpdate
|
|
1405
|
+
SessionUpdate as SessionUpdate2
|
|
1356
1406
|
} from "@agentclientprotocol/sdk/experimental/v2";
|
|
1357
1407
|
var MODEL_CATEGORY = "model";
|
|
1358
1408
|
var EFFORT_CATEGORY = "thought_level";
|
|
@@ -1493,9 +1543,9 @@ function createAcpComposerStore(connection) {
|
|
|
1493
1543
|
function accept(sessionId, update, meta) {
|
|
1494
1544
|
const known = sessions.get(sessionId) ?? { projection: {}, writes: 0 };
|
|
1495
1545
|
sessions.set(sessionId, known);
|
|
1496
|
-
if (
|
|
1546
|
+
if (SessionUpdate2.isConfigOptionUpdate(update)) {
|
|
1497
1547
|
project(known, sessionId, projectModels(update.configOptions));
|
|
1498
|
-
} else if (
|
|
1548
|
+
} else if (SessionUpdate2.isAvailableCommandsUpdate(update)) {
|
|
1499
1549
|
known.commands = update.availableCommands.map(({ name, description }) => ({ name, description }));
|
|
1500
1550
|
const aos = HgwAvailableCommandsMetaSchema2.safeParse(meta);
|
|
1501
1551
|
if (aos.success)
|
|
@@ -1503,13 +1553,13 @@ function createAcpComposerStore(connection) {
|
|
|
1503
1553
|
if (known.reported)
|
|
1504
1554
|
known.capabilities = capabilitiesOf(known.reported, known.commands);
|
|
1505
1555
|
notify(listeners, sessionId);
|
|
1506
|
-
} else if (
|
|
1556
|
+
} else if (SessionUpdate2.isUsageUpdate(update)) {
|
|
1507
1557
|
const context = projectContext(update, meta);
|
|
1508
1558
|
if (!context)
|
|
1509
1559
|
return;
|
|
1510
1560
|
known.context = context;
|
|
1511
1561
|
notify(listeners, sessionId);
|
|
1512
|
-
} else if (
|
|
1562
|
+
} else if (SessionUpdate2.isStateUpdate(update) && update.state === "idle") {
|
|
1513
1563
|
const aos = HgwStateMetaSchema2.safeParse(meta);
|
|
1514
1564
|
const turns = foldTurnUsage(known.turns, isUsage(update.usage) ? update.usage : undefined, aos.success ? aos.data.cost : undefined);
|
|
1515
1565
|
if (turns === known.turns)
|
|
@@ -1575,7 +1625,7 @@ function createAcpComposerStore(connection) {
|
|
|
1575
1625
|
|
|
1576
1626
|
// client/acp-workspace-client-sessions.ts
|
|
1577
1627
|
import {
|
|
1578
|
-
SessionUpdate as
|
|
1628
|
+
SessionUpdate as SessionUpdate3,
|
|
1579
1629
|
StateUpdate
|
|
1580
1630
|
} from "@agentclientprotocol/sdk/experimental/v2";
|
|
1581
1631
|
|
|
@@ -1594,10 +1644,11 @@ function statusFromState(update) {
|
|
|
1594
1644
|
return "running";
|
|
1595
1645
|
if (StateUpdate.isRequiresAction(update))
|
|
1596
1646
|
return "waiting-for-input";
|
|
1647
|
+
if (StateUpdate.isUnknown(update))
|
|
1648
|
+
return "failed";
|
|
1597
1649
|
if (!StateUpdate.isIdle(update))
|
|
1598
1650
|
return "unknown";
|
|
1599
|
-
|
|
1600
|
-
return stopReason === HGW_STOP_REASONS2.error || stopReason === HGW_STOP_REASONS2.uncertain ? "failed" : "idle";
|
|
1651
|
+
return update.stopReason === "error" ? "failed" : "idle";
|
|
1601
1652
|
}
|
|
1602
1653
|
var FEED_STATUS = {
|
|
1603
1654
|
"turn-started": "running",
|
|
@@ -1715,7 +1766,7 @@ function createAcpSessionStore({
|
|
|
1715
1766
|
callEach(invalidationListeners.get(sessionId) ?? [], logger, "sessions.listener.failed");
|
|
1716
1767
|
}
|
|
1717
1768
|
function acceptUpdate(sessionId, update, meta) {
|
|
1718
|
-
if (
|
|
1769
|
+
if (SessionUpdate3.isStateUpdate(update)) {
|
|
1719
1770
|
const status = statusFromState(update);
|
|
1720
1771
|
if (replaying.has(sessionId))
|
|
1721
1772
|
return void replaying.set(sessionId, status);
|
|
@@ -1725,7 +1776,7 @@ function createAcpSessionStore({
|
|
|
1725
1776
|
onTurnFinished?.(sessionId);
|
|
1726
1777
|
return;
|
|
1727
1778
|
}
|
|
1728
|
-
if (
|
|
1779
|
+
if (SessionUpdate3.isSessionInfoUpdate(update)) {
|
|
1729
1780
|
if (update.title && update.title !== titles.get(sessionId)) {
|
|
1730
1781
|
titles.set(sessionId, update.title);
|
|
1731
1782
|
invalidate(sessionId);
|
|
@@ -1735,7 +1786,7 @@ function createAcpSessionStore({
|
|
|
1735
1786
|
put(sessionId, info.data, update.updatedAt);
|
|
1736
1787
|
return;
|
|
1737
1788
|
}
|
|
1738
|
-
if (!
|
|
1789
|
+
if (!SessionUpdate3.isPlanUpdate(update))
|
|
1739
1790
|
return;
|
|
1740
1791
|
const plan = HgwPlanMetaSchema2.safeParse(meta);
|
|
1741
1792
|
if (plan.success)
|
|
@@ -2191,12 +2242,23 @@ function createAcpWorkspaceClient({
|
|
|
2191
2242
|
throw reason;
|
|
2192
2243
|
}
|
|
2193
2244
|
},
|
|
2245
|
+
async markSessionUnread(sessionId) {
|
|
2246
|
+
const [previous] = store.rowsFor([sessionId]);
|
|
2247
|
+
store.setUnread(sessionId, true);
|
|
2248
|
+
try {
|
|
2249
|
+
await connection.updateSession({ sessionId, unread: true });
|
|
2250
|
+
} catch (reason) {
|
|
2251
|
+
store.setUnread(sessionId, previous?.unread);
|
|
2252
|
+
throw reason;
|
|
2253
|
+
}
|
|
2254
|
+
},
|
|
2194
2255
|
sessionActionCapabilities() {
|
|
2195
2256
|
sessionActions ??= rest.runtimeInfo().then(({ capabilities }) => ({
|
|
2196
2257
|
rename: offers(capabilities.sessionTitle),
|
|
2197
2258
|
archive: offers(capabilities.sessionArchival),
|
|
2198
2259
|
delete: offers(capabilities.sessionDeletion),
|
|
2199
|
-
pin: offers(capabilities.sessionPin)
|
|
2260
|
+
pin: offers(capabilities.sessionPin),
|
|
2261
|
+
unread: offers(capabilities.sessionReadState)
|
|
2200
2262
|
})).catch((reason) => {
|
|
2201
2263
|
sessionActions = undefined;
|
|
2202
2264
|
throw reason;
|
|
@@ -2470,7 +2532,7 @@ class HgwClientError extends Error {
|
|
|
2470
2532
|
kind;
|
|
2471
2533
|
code;
|
|
2472
2534
|
status;
|
|
2473
|
-
constructor(kind, message = "
|
|
2535
|
+
constructor(kind, message = "Gateway request failed", code, status) {
|
|
2474
2536
|
super(message);
|
|
2475
2537
|
this.kind = kind;
|
|
2476
2538
|
this.code = code;
|
|
@@ -2504,7 +2566,7 @@ class HgwRemoteClient {
|
|
|
2504
2566
|
this.#authorization = options.authorization;
|
|
2505
2567
|
this.#origin = options.origin;
|
|
2506
2568
|
}
|
|
2507
|
-
async#read(path, schema, init, notFound = "
|
|
2569
|
+
async#read(path, schema, init, notFound = "gateway-failure") {
|
|
2508
2570
|
let response;
|
|
2509
2571
|
try {
|
|
2510
2572
|
const headers = new Headers(init?.headers);
|
|
@@ -2521,17 +2583,17 @@ class HgwRemoteClient {
|
|
|
2521
2583
|
}
|
|
2522
2584
|
if (!response.ok) {
|
|
2523
2585
|
const error = await normalizedError(response);
|
|
2524
|
-
throw new HgwClientError(response.status === 503 ? "provider-unavailable" : response.status === 404 ? notFound : "
|
|
2586
|
+
throw new HgwClientError(response.status === 503 ? "provider-unavailable" : response.status === 404 ? notFound : "gateway-failure", error?.description, error?.code, response.status);
|
|
2525
2587
|
}
|
|
2526
2588
|
let payload;
|
|
2527
2589
|
try {
|
|
2528
2590
|
payload = await response.json();
|
|
2529
2591
|
} catch {
|
|
2530
|
-
throw new HgwClientError("
|
|
2592
|
+
throw new HgwClientError("gateway-failure", "Invalid gateway response");
|
|
2531
2593
|
}
|
|
2532
2594
|
const parsed = schema.safeParse(payload);
|
|
2533
2595
|
if (!parsed.success)
|
|
2534
|
-
throw new HgwClientError("
|
|
2596
|
+
throw new HgwClientError("gateway-failure", "Invalid gateway response");
|
|
2535
2597
|
return parsed.data;
|
|
2536
2598
|
}
|
|
2537
2599
|
runtimeInfo(signal) {
|
|
@@ -2546,7 +2608,7 @@ class HgwRemoteClient {
|
|
|
2546
2608
|
async deletePushSubscription(endpoint) {
|
|
2547
2609
|
const request = PushUnregistrationSchema2.safeParse({ endpoint });
|
|
2548
2610
|
if (!request.success || !endpoint.trim())
|
|
2549
|
-
throw new HgwClientError("
|
|
2611
|
+
throw new HgwClientError("gateway-failure", "Invalid push subscription");
|
|
2550
2612
|
await this.#write("/push/subscriptions", "DELETE", request.data);
|
|
2551
2613
|
}
|
|
2552
2614
|
adoptSessionOwnership(sessionId, agentId) {
|
|
@@ -2567,7 +2629,7 @@ class HgwRemoteClient {
|
|
|
2567
2629
|
})
|
|
2568
2630
|
});
|
|
2569
2631
|
if (!request.success)
|
|
2570
|
-
throw new HgwClientError("
|
|
2632
|
+
throw new HgwClientError("gateway-failure", "Invalid attachment staging request");
|
|
2571
2633
|
return this.#read(this.#sessionPath(sessionId, "/attachments/stage"), SessionAttachmentStageResponseSchema2, {
|
|
2572
2634
|
method: "POST",
|
|
2573
2635
|
headers: { "content-type": "application/json" },
|
|
@@ -2576,11 +2638,11 @@ class HgwRemoteClient {
|
|
|
2576
2638
|
}
|
|
2577
2639
|
async readArtifact(sessionId, artifactId, signal) {
|
|
2578
2640
|
if (!artifactId.trim() || artifactId.length > 512)
|
|
2579
|
-
throw new HgwClientError("
|
|
2641
|
+
throw new HgwClientError("gateway-failure", "Invalid artifact reference");
|
|
2580
2642
|
return this.#readBlob(this.#sessionPath(sessionId, `/artifacts/${encodeURIComponent(artifactId)}`), { signal }, "artifact-missing");
|
|
2581
2643
|
}
|
|
2582
2644
|
async openMcpApp(sessionId, subject, signal) {
|
|
2583
|
-
const view = await this.#read(this.#mcpAppPath(sessionId, subject), McpAppViewSchema2, { signal }, "artifactId" in subject ? "artifact-missing" : "
|
|
2645
|
+
const view = await this.#read(this.#mcpAppPath(sessionId, subject), McpAppViewSchema2, { signal }, "artifactId" in subject ? "artifact-missing" : "gateway-failure");
|
|
2584
2646
|
return view.files ? { ...view, files: this.#absoluteFiles(view.files) } : view;
|
|
2585
2647
|
}
|
|
2586
2648
|
async renewMcpAppFiles(sessionId, subject) {
|
|
@@ -2607,13 +2669,13 @@ class HgwRemoteClient {
|
|
|
2607
2669
|
}
|
|
2608
2670
|
async transcribeForAgent(agentId, audio, signal) {
|
|
2609
2671
|
if (!audio.size || !audio.type)
|
|
2610
|
-
throw new HgwClientError("
|
|
2672
|
+
throw new HgwClientError("gateway-failure", "Invalid audio recording");
|
|
2611
2673
|
const request = SessionTranscriptionRequestSchema2.safeParse({
|
|
2612
2674
|
dataUrl: await dataUrl(audio),
|
|
2613
2675
|
mimeType: audio.type
|
|
2614
2676
|
});
|
|
2615
2677
|
if (!request.success)
|
|
2616
|
-
throw new HgwClientError("
|
|
2678
|
+
throw new HgwClientError("gateway-failure", "Invalid audio recording");
|
|
2617
2679
|
const path = `/agents/${encodeURIComponent(agentId)}/audio/transcribe`;
|
|
2618
2680
|
const response = await this.#read(path, SessionTranscriptionResponseSchema2, {
|
|
2619
2681
|
method: "POST",
|
|
@@ -2629,7 +2691,7 @@ class HgwRemoteClient {
|
|
|
2629
2691
|
async speakForAgent(agentId, text, signal) {
|
|
2630
2692
|
const request = SessionSpeechRequestSchema2.safeParse({ text });
|
|
2631
2693
|
if (!request.success)
|
|
2632
|
-
throw new HgwClientError("
|
|
2694
|
+
throw new HgwClientError("gateway-failure", "Invalid speech input");
|
|
2633
2695
|
const path = `/agents/${encodeURIComponent(agentId)}/audio/speak`;
|
|
2634
2696
|
return this.#readBlob(path, {
|
|
2635
2697
|
method: "POST",
|
|
@@ -2655,18 +2717,18 @@ class HgwRemoteClient {
|
|
|
2655
2717
|
}
|
|
2656
2718
|
if (!response.ok) {
|
|
2657
2719
|
const error = await normalizedError(response);
|
|
2658
|
-
throw new HgwClientError(response.status === 503 ? "provider-unavailable" : "
|
|
2720
|
+
throw new HgwClientError(response.status === 503 ? "provider-unavailable" : "gateway-failure", error?.description, error?.code, response.status);
|
|
2659
2721
|
}
|
|
2660
2722
|
}
|
|
2661
2723
|
#mcpAppPath(sessionId, subject, suffix = "") {
|
|
2662
2724
|
const [collection, id] = "toolCallId" in subject ? ["tool-calls", subject.toolCallId] : ["artifacts", subject.artifactId];
|
|
2663
2725
|
if (!id.trim() || id.length > 512)
|
|
2664
|
-
throw new HgwClientError("
|
|
2726
|
+
throw new HgwClientError("gateway-failure", "Invalid MCP App reference");
|
|
2665
2727
|
return this.#sessionPath(sessionId, `/${collection}/${encodeURIComponent(id)}/app${suffix}`);
|
|
2666
2728
|
}
|
|
2667
2729
|
async#postMcpApp(sessionId, subject, suffix, request, schema) {
|
|
2668
2730
|
if (!request.success)
|
|
2669
|
-
throw new HgwClientError("
|
|
2731
|
+
throw new HgwClientError("gateway-failure", "Invalid MCP App request");
|
|
2670
2732
|
return this.#read(this.#mcpAppPath(sessionId, subject, suffix), schema, {
|
|
2671
2733
|
method: "POST",
|
|
2672
2734
|
headers: { "content-type": "application/json" },
|
|
@@ -2677,7 +2739,7 @@ class HgwRemoteClient {
|
|
|
2677
2739
|
const agentId = this.#owner(sessionId);
|
|
2678
2740
|
return `/agents/${encodeURIComponent(agentId)}/sessions/${encodeURIComponent(sessionId)}${suffix}`;
|
|
2679
2741
|
}
|
|
2680
|
-
async#readBlob(path, init, notFound = "
|
|
2742
|
+
async#readBlob(path, init, notFound = "gateway-failure") {
|
|
2681
2743
|
let response;
|
|
2682
2744
|
try {
|
|
2683
2745
|
const headers = new Headers(init?.headers);
|
|
@@ -2694,15 +2756,15 @@ class HgwRemoteClient {
|
|
|
2694
2756
|
}
|
|
2695
2757
|
if (!response.ok) {
|
|
2696
2758
|
const error = await normalizedError(response);
|
|
2697
|
-
throw new HgwClientError(response.status === 503 ? "provider-unavailable" : response.status === 404 ? notFound : "
|
|
2759
|
+
throw new HgwClientError(response.status === 503 ? "provider-unavailable" : response.status === 404 ? notFound : "gateway-failure", error?.description, error?.code, response.status);
|
|
2698
2760
|
}
|
|
2699
2761
|
const contentType = response.headers.get("content-type");
|
|
2700
2762
|
if (!contentType || /[\r\n]/u.test(contentType))
|
|
2701
|
-
throw new HgwClientError("
|
|
2763
|
+
throw new HgwClientError("gateway-failure", "Invalid gateway response");
|
|
2702
2764
|
try {
|
|
2703
2765
|
return await response.blob();
|
|
2704
2766
|
} catch {
|
|
2705
|
-
throw new HgwClientError("
|
|
2767
|
+
throw new HgwClientError("gateway-failure", "Invalid gateway response");
|
|
2706
2768
|
}
|
|
2707
2769
|
}
|
|
2708
2770
|
#owner(sessionId) {
|
package/dist/client/limits.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare const STABLE_AFTER_MS = 60000;
|
|
|
33
33
|
* neither a close nor a resume.
|
|
34
34
|
*/
|
|
35
35
|
export declare const PART_GRACE_MS = 2000;
|
|
36
|
-
/** The window a reopen waits in after the
|
|
36
|
+
/** The window a reopen waits in after the gateway closes at capacity. */
|
|
37
37
|
export declare const CAPACITY_BACKOFF: {
|
|
38
38
|
minMs: number;
|
|
39
39
|
maxMs: number;
|
package/dist/client/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ContentBlock, CreateElicitationRequest, CreateElicitationResponse, RequestPermissionRequest, RequestPermissionResponse, SessionConfigOption, SessionInfo, SessionUpdate } from "@agentclientprotocol/sdk/experimental/v2";
|
|
1
|
+
import type { AgentCapabilities, ContentBlock, CreateElicitationRequest, CreateElicitationResponse, RequestPermissionRequest, RequestPermissionResponse, SessionConfigOption, SessionInfo, SessionUpdate } from "@agentclientprotocol/sdk/experimental/v2";
|
|
2
2
|
import type { z } from "zod";
|
|
3
3
|
import type { AgentCatalogResponseSchema } from "../protocol/index.js";
|
|
4
4
|
import type { HgwAgentUpdateRequest, HgwAgentUpdateResponseSchema, HgwHistoryCursor, HgwInitializeMetaSchema, HgwPromptMetaSchema, HgwSessionListMetaSchema, HgwSessionNewMetaSchema, HgwSessionSearchMeta, HgwSessionUpdateRequestSchema, HgwSteerRequestSchema, HgwSteerResponseSchema } from "../protocol/acp.js";
|
|
@@ -15,13 +15,17 @@ export type AcpConnectionOutage = "reconnecting" | "capacity";
|
|
|
15
15
|
export type AcpPendingRequest = {
|
|
16
16
|
kind: "permission";
|
|
17
17
|
sessionId: string;
|
|
18
|
+
/** The Session that owns the child Session `sessionId` names, if it is one. */
|
|
19
|
+
parentSessionId?: string;
|
|
18
20
|
request: RequestPermissionRequest;
|
|
19
21
|
respond(response: RequestPermissionResponse): void;
|
|
20
|
-
/** Aborts when the
|
|
22
|
+
/** Aborts when the gateway withdraws the request, which needs no answer. */
|
|
21
23
|
signal: AbortSignal;
|
|
22
24
|
} | {
|
|
23
25
|
kind: "elicitation";
|
|
24
26
|
sessionId: string | undefined;
|
|
27
|
+
/** The Session that owns the child Session `sessionId` names, if it is one. */
|
|
28
|
+
parentSessionId?: string;
|
|
25
29
|
request: CreateElicitationRequest;
|
|
26
30
|
respond(response: CreateElicitationResponse): void;
|
|
27
31
|
signal: AbortSignal;
|
|
@@ -55,6 +59,12 @@ export type AcpSessionListener = {
|
|
|
55
59
|
agentId?: string;
|
|
56
60
|
/** `session/update` notifications for the Session, with `_meta.hgw`. */
|
|
57
61
|
update?: AcpSessionUpdateListener;
|
|
62
|
+
/**
|
|
63
|
+
* The updates of a child Session this one owns, announced by a
|
|
64
|
+
* `subagent_update` this listener's `update` saw: ACP sends them under the
|
|
65
|
+
* child's own id, on this connection.
|
|
66
|
+
*/
|
|
67
|
+
child?: (childSessionId: string, update: SessionUpdate, meta: Record<string, unknown> | undefined) => void;
|
|
58
68
|
/**
|
|
59
69
|
* Fires just before a from-start replay is requested, so whoever projects
|
|
60
70
|
* the Session can drop the transcript that replay is about to resend. It
|
|
@@ -81,6 +91,11 @@ export interface AcpConnection {
|
|
|
81
91
|
start(): void;
|
|
82
92
|
/** Resolves with `InitializeResponse._meta.hgw` once the handshake settles. */
|
|
83
93
|
readonly initialized: Promise<z.infer<typeof HgwInitializeMetaSchema>>;
|
|
94
|
+
/**
|
|
95
|
+
* ACP's `InitializeResponse.capabilities` from the latest handshake:
|
|
96
|
+
* `session.fork` says the gateway forks. Undefined before one settles.
|
|
97
|
+
*/
|
|
98
|
+
readonly capabilities: AgentCapabilities | undefined;
|
|
84
99
|
subscribeStatus(listener: (status: AcpConnectionStatus) => void): () => void;
|
|
85
100
|
/**
|
|
86
101
|
* Set from a close until the transport is ready again. Each Session's
|
|
@@ -102,6 +117,14 @@ export interface AcpConnection {
|
|
|
102
117
|
}): Promise<{
|
|
103
118
|
sessionId: string;
|
|
104
119
|
}>;
|
|
120
|
+
/**
|
|
121
|
+
* Forks a Session into a new one holding its conversation so far, where
|
|
122
|
+
* `capabilities.session.fork` says the gateway forks; the gateway joins
|
|
123
|
+
* this connection to it, as `newSession` does.
|
|
124
|
+
*/
|
|
125
|
+
forkSession(sessionId: string): Promise<{
|
|
126
|
+
sessionId: string;
|
|
127
|
+
}>;
|
|
105
128
|
listSessions(meta: z.infer<typeof HgwSessionListMetaSchema>, cursor?: string): Promise<{
|
|
106
129
|
sessions: SessionInfo[];
|
|
107
130
|
nextCursor?: string;
|
package/dist/protocol/acp.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export declare const HGW_ACP_AGENTS_PATH: "/api/v1/acp/agents";
|
|
|
44
44
|
/** One Agent's own ACP address, its id one path segment. */
|
|
45
45
|
export declare function hgwAcpAgentPath(agentId: string): string;
|
|
46
46
|
export declare const HGW_META_KEY: "hgw";
|
|
47
|
-
export declare const HGW_EXTENSION_VERSION:
|
|
47
|
+
export declare const HGW_EXTENSION_VERSION: 2;
|
|
48
48
|
export declare const HGW_AUTH_METHOD_INVITE: "hgw-invite";
|
|
49
49
|
export declare const HGW_ATTACHMENT_URI_SCHEME: "hgw-attachment:";
|
|
50
50
|
export declare const HGW_ARTIFACT_URI_SCHEME: "artifact:";
|
|
@@ -69,11 +69,6 @@ export declare const HGW_METHODS: {
|
|
|
69
69
|
readonly error: "_hgw/error";
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
-
/** Vendor stop reasons used on `state_update { state: "idle" }`. */
|
|
73
|
-
export declare const HGW_STOP_REASONS: {
|
|
74
|
-
readonly error: "_hgw_error";
|
|
75
|
-
readonly uncertain: "_hgw_uncertain";
|
|
76
|
-
};
|
|
77
72
|
/** Vendor permission option kind for Hermes' "allow for this session" scope. */
|
|
78
73
|
export declare const HGW_PERMISSION_KIND_SESSION: "_allow_session";
|
|
79
74
|
/** The single plan a Session carries: its Todos. */
|
|
@@ -89,7 +84,6 @@ export declare const HGW_JSONRPC_ERRORS: {
|
|
|
89
84
|
readonly revisionConflict: -31012;
|
|
90
85
|
readonly temporarilyUnavailable: -31013;
|
|
91
86
|
readonly uncertainMutation: -31014;
|
|
92
|
-
readonly unsupported: -31015;
|
|
93
87
|
/**
|
|
94
88
|
* Params too large for one frame. The client raises it before sending and
|
|
95
89
|
* the gateway never sends it, so it has no machine name on the wire.
|
|
@@ -126,7 +120,7 @@ export declare const HgwClientCapabilitiesMetaSchema: z.ZodObject<{
|
|
|
126
120
|
}, z.core.$strip>;
|
|
127
121
|
/** `InitializeResponse._meta.hgw` */
|
|
128
122
|
export declare const HgwInitializeMetaSchema: z.ZodObject<{
|
|
129
|
-
version: z.ZodLiteral<
|
|
123
|
+
version: z.ZodLiteral<2>;
|
|
130
124
|
role: z.ZodEnum<{
|
|
131
125
|
guest: "guest";
|
|
132
126
|
operator: "operator";
|
|
@@ -210,8 +204,20 @@ export type HgwSessionInfoMeta = z.infer<typeof HgwSessionInfoMetaSchema>;
|
|
|
210
204
|
/** `ResumeSessionRequest._meta.hgw` */
|
|
211
205
|
export declare const HgwSessionResumeMetaSchema: z.ZodObject<{
|
|
212
206
|
agentId: z.ZodOptional<z.ZodString>;
|
|
213
|
-
|
|
207
|
+
}, z.core.$strict>;
|
|
208
|
+
/**
|
|
209
|
+
* The reserved `replayFrom` variant that resumes a view from where it already
|
|
210
|
+
* reaches in the live turn: `from` is the first `_meta.hgw.sequence` of
|
|
211
|
+
* `turnId` the client still needs, inclusive as every ACP cursor is. One that
|
|
212
|
+
* names neither replays the live turn from its first event, or rebuilds the
|
|
213
|
+
* view from history once the journal no longer holds that.
|
|
214
|
+
*/
|
|
215
|
+
export declare const HGW_REPLAY_POSITION: "_hgw/position";
|
|
216
|
+
export declare const HgwReplayPositionSchema: z.ZodObject<{
|
|
217
|
+
type: z.ZodLiteral<"_hgw/position">;
|
|
214
218
|
turnId: z.ZodOptional<z.ZodString>;
|
|
219
|
+
from: z.ZodOptional<z.ZodNumber>;
|
|
220
|
+
_meta: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
|
|
215
221
|
}, z.core.$strict>;
|
|
216
222
|
/**
|
|
217
223
|
* The reserved `replayFrom` extension variant that reads one older page of a
|
|
@@ -417,6 +423,7 @@ export declare const HgwAgentUpdateResponseSchema: z.ZodObject<{
|
|
|
417
423
|
export declare const HgwTurnMetaSchema: z.ZodObject<{
|
|
418
424
|
sequence: z.ZodNumber;
|
|
419
425
|
turnId: z.ZodString;
|
|
426
|
+
background: z.ZodOptional<z.ZodLiteral<true>>;
|
|
420
427
|
}, z.core.$strip>;
|
|
421
428
|
/**
|
|
422
429
|
* `_meta.hgw` of a Session-scoped `notice`: the provider's own status kind,
|
|
@@ -452,35 +459,29 @@ export declare const HgwCostSchema: z.ZodObject<{
|
|
|
452
459
|
currency: z.ZodString;
|
|
453
460
|
}, z.core.$strip>;
|
|
454
461
|
export type HgwCost = z.infer<typeof HgwCostSchema>;
|
|
455
|
-
/** How far a delegated subagent has got. */
|
|
456
|
-
export declare const HGW_SUBAGENT_STATUSES: readonly ["running", "completed", "failed", "cancelled"];
|
|
457
462
|
/**
|
|
458
|
-
*
|
|
459
|
-
*
|
|
463
|
+
* `subagent_update._meta.hgw`: what ACP's child Session announcement has no
|
|
464
|
+
* field for. `toolCallId` names the parent's call that spawned the child; the
|
|
465
|
+
* rest are the facts its runtime reports. A child's tokens arrive in its own
|
|
466
|
+
* idle usage, apart from its parent's.
|
|
460
467
|
*/
|
|
461
|
-
export declare const
|
|
462
|
-
|
|
463
|
-
|
|
468
|
+
export declare const HgwChildSessionMetaSchema: z.ZodObject<{
|
|
469
|
+
sequence: z.ZodNumber;
|
|
470
|
+
turnId: z.ZodString;
|
|
471
|
+
background: z.ZodOptional<z.ZodLiteral<true>>;
|
|
472
|
+
toolCallId: z.ZodOptional<z.ZodString>;
|
|
464
473
|
model: z.ZodOptional<z.ZodString>;
|
|
465
|
-
depth: z.ZodOptional<z.ZodNumber>;
|
|
466
|
-
status: z.ZodOptional<z.ZodEnum<{
|
|
467
|
-
cancelled: "cancelled";
|
|
468
|
-
completed: "completed";
|
|
469
|
-
failed: "failed";
|
|
470
|
-
running: "running";
|
|
471
|
-
}>>;
|
|
472
|
-
tokens: z.ZodOptional<z.ZodNumber>;
|
|
473
474
|
filesRead: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
474
475
|
filesWritten: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
475
476
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
476
|
-
childSessionId: z.ZodOptional<z.ZodString>;
|
|
477
477
|
summary: z.ZodOptional<z.ZodString>;
|
|
478
478
|
}, z.core.$strip>;
|
|
479
|
-
export type
|
|
479
|
+
export type HgwChildSessionMeta = z.infer<typeof HgwChildSessionMetaSchema>;
|
|
480
480
|
/** `state_update._meta.hgw` */
|
|
481
481
|
export declare const HgwStateMetaSchema: z.ZodObject<{
|
|
482
482
|
sequence: z.ZodNumber;
|
|
483
483
|
turnId: z.ZodString;
|
|
484
|
+
background: z.ZodOptional<z.ZodLiteral<true>>;
|
|
484
485
|
at: z.ZodOptional<z.ZodISODateTime>;
|
|
485
486
|
execution: z.ZodOptional<z.ZodLiteral<"stopping">>;
|
|
486
487
|
code: z.ZodOptional<z.ZodString>;
|
|
@@ -496,39 +497,19 @@ export declare const HgwStateMetaSchema: z.ZodObject<{
|
|
|
496
497
|
export declare const HgwChunkMetaSchema: z.ZodObject<{
|
|
497
498
|
sequence: z.ZodNumber;
|
|
498
499
|
turnId: z.ZodString;
|
|
499
|
-
|
|
500
|
-
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
500
|
+
background: z.ZodOptional<z.ZodLiteral<true>>;
|
|
501
501
|
}, z.core.$strip>;
|
|
502
502
|
/** `tool_call_update` / `tool_call_content_chunk` `_meta.hgw` */
|
|
503
503
|
export declare const HgwToolCallMetaSchema: z.ZodObject<{
|
|
504
504
|
sequence: z.ZodNumber;
|
|
505
505
|
turnId: z.ZodString;
|
|
506
|
-
|
|
507
|
-
parentToolCallId: z.ZodOptional<z.ZodString>;
|
|
506
|
+
background: z.ZodOptional<z.ZodLiteral<true>>;
|
|
508
507
|
messageId: z.ZodString;
|
|
509
508
|
argsTextDelta: z.ZodOptional<z.ZodString>;
|
|
510
509
|
argsText: z.ZodOptional<z.ZodString>;
|
|
511
510
|
startedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
512
511
|
completedAt: z.ZodOptional<z.ZodISODateTime>;
|
|
513
512
|
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
514
|
-
subagent: z.ZodOptional<z.ZodObject<{
|
|
515
|
-
id: z.ZodString;
|
|
516
|
-
goal: z.ZodOptional<z.ZodString>;
|
|
517
|
-
model: z.ZodOptional<z.ZodString>;
|
|
518
|
-
depth: z.ZodOptional<z.ZodNumber>;
|
|
519
|
-
status: z.ZodOptional<z.ZodEnum<{
|
|
520
|
-
cancelled: "cancelled";
|
|
521
|
-
completed: "completed";
|
|
522
|
-
failed: "failed";
|
|
523
|
-
running: "running";
|
|
524
|
-
}>>;
|
|
525
|
-
tokens: z.ZodOptional<z.ZodNumber>;
|
|
526
|
-
filesRead: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
527
|
-
filesWritten: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
528
|
-
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
529
|
-
childSessionId: z.ZodOptional<z.ZodString>;
|
|
530
|
-
summary: z.ZodOptional<z.ZodString>;
|
|
531
|
-
}, z.core.$strip>>;
|
|
532
513
|
app: z.ZodOptional<z.ZodObject<{}, z.core.$strict>>;
|
|
533
514
|
}, z.core.$strip>;
|
|
534
515
|
/** `plan_update._meta.hgw`: the lossless Session Todos. */
|
|
@@ -632,6 +613,13 @@ export declare const HgwAvailableCommandsMetaSchema: z.ZodObject<{
|
|
|
632
613
|
status: z.ZodLiteral<"unavailable">;
|
|
633
614
|
reason: z.ZodString;
|
|
634
615
|
}, z.core.$strict>]>;
|
|
616
|
+
rewind: z.ZodUnion<readonly [z.ZodObject<{
|
|
617
|
+
status: z.ZodLiteral<"available">;
|
|
618
|
+
scope: z.ZodLiteral<"user-turn">;
|
|
619
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
620
|
+
status: z.ZodLiteral<"unavailable">;
|
|
621
|
+
reason: z.ZodString;
|
|
622
|
+
}, z.core.$strict>]>;
|
|
635
623
|
approvals: z.ZodObject<{
|
|
636
624
|
status: z.ZodLiteral<"available">;
|
|
637
625
|
protocol: z.ZodLiteral<"acp-request">;
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -568,6 +568,102 @@ export declare const SessionPlanActivityMessageSchema: z.ZodObject<{
|
|
|
568
568
|
}, z.core.$strict>;
|
|
569
569
|
}, z.core.$strict>;
|
|
570
570
|
export type SessionPlanActivityMessage = z.infer<typeof SessionPlanActivityMessageSchema>;
|
|
571
|
+
/**
|
|
572
|
+
* A compaction the provider stored: where it summarized the conversation's
|
|
573
|
+
* context, under the id its live `compaction_update` carried, and the summary
|
|
574
|
+
* where it keeps one. It replays as that compaction, completed.
|
|
575
|
+
*/
|
|
576
|
+
export declare const SessionCompactionActivityMessageSchema: z.ZodObject<{
|
|
577
|
+
id: z.ZodString;
|
|
578
|
+
role: z.ZodLiteral<"activity">;
|
|
579
|
+
activityType: z.ZodLiteral<"COMPACTION">;
|
|
580
|
+
content: z.ZodObject<{
|
|
581
|
+
compactionId: z.ZodString;
|
|
582
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
583
|
+
}, z.core.$strict>;
|
|
584
|
+
}, z.core.$strict>;
|
|
585
|
+
export type SessionCompactionActivityMessage = z.infer<typeof SessionCompactionActivityMessageSchema>;
|
|
586
|
+
/**
|
|
587
|
+
* A child Session a turn of this one spawned, as its runtime stored it: its
|
|
588
|
+
* id, the call that spawned it, its display text, and its final state and
|
|
589
|
+
* facts. It replays as the child's announcement, ahead of the child's own
|
|
590
|
+
* transcript.
|
|
591
|
+
*/
|
|
592
|
+
export declare const SessionChildActivityMessageSchema: z.ZodObject<{
|
|
593
|
+
id: z.ZodString;
|
|
594
|
+
role: z.ZodLiteral<"activity">;
|
|
595
|
+
activityType: z.ZodLiteral<"CHILD_SESSION">;
|
|
596
|
+
content: z.ZodObject<{
|
|
597
|
+
childSessionId: z.ZodString;
|
|
598
|
+
toolCallId: z.ZodOptional<z.ZodString>;
|
|
599
|
+
title: z.ZodOptional<z.ZodString>;
|
|
600
|
+
description: z.ZodOptional<z.ZodString>;
|
|
601
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
602
|
+
cancelled: "cancelled";
|
|
603
|
+
failed: "failed";
|
|
604
|
+
idle: "idle";
|
|
605
|
+
running: "running";
|
|
606
|
+
unknown: "unknown";
|
|
607
|
+
"waiting-for-input": "waiting-for-input";
|
|
608
|
+
}>>;
|
|
609
|
+
model: z.ZodOptional<z.ZodString>;
|
|
610
|
+
filesRead: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
611
|
+
filesWritten: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
612
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
613
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
614
|
+
}, z.core.$strict>;
|
|
615
|
+
}, z.core.$strict>;
|
|
616
|
+
export type SessionChildActivityMessage = z.infer<typeof SessionChildActivityMessageSchema>;
|
|
617
|
+
/** A stored row of the Session's activity, not of its conversation. */
|
|
618
|
+
export declare const SessionActivityMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
619
|
+
id: z.ZodString;
|
|
620
|
+
role: z.ZodLiteral<"activity">;
|
|
621
|
+
activityType: z.ZodLiteral<"PLAN">;
|
|
622
|
+
content: z.ZodObject<{
|
|
623
|
+
todos: z.ZodArray<z.ZodObject<{
|
|
624
|
+
id: z.ZodString;
|
|
625
|
+
label: z.ZodString;
|
|
626
|
+
status: z.ZodEnum<{
|
|
627
|
+
active: "active";
|
|
628
|
+
completed: "completed";
|
|
629
|
+
failed: "failed";
|
|
630
|
+
pending: "pending";
|
|
631
|
+
}>;
|
|
632
|
+
}, z.core.$strict>>;
|
|
633
|
+
}, z.core.$strict>;
|
|
634
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
635
|
+
id: z.ZodString;
|
|
636
|
+
role: z.ZodLiteral<"activity">;
|
|
637
|
+
activityType: z.ZodLiteral<"COMPACTION">;
|
|
638
|
+
content: z.ZodObject<{
|
|
639
|
+
compactionId: z.ZodString;
|
|
640
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
641
|
+
}, z.core.$strict>;
|
|
642
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
643
|
+
id: z.ZodString;
|
|
644
|
+
role: z.ZodLiteral<"activity">;
|
|
645
|
+
activityType: z.ZodLiteral<"CHILD_SESSION">;
|
|
646
|
+
content: z.ZodObject<{
|
|
647
|
+
childSessionId: z.ZodString;
|
|
648
|
+
toolCallId: z.ZodOptional<z.ZodString>;
|
|
649
|
+
title: z.ZodOptional<z.ZodString>;
|
|
650
|
+
description: z.ZodOptional<z.ZodString>;
|
|
651
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
652
|
+
cancelled: "cancelled";
|
|
653
|
+
failed: "failed";
|
|
654
|
+
idle: "idle";
|
|
655
|
+
running: "running";
|
|
656
|
+
unknown: "unknown";
|
|
657
|
+
"waiting-for-input": "waiting-for-input";
|
|
658
|
+
}>>;
|
|
659
|
+
model: z.ZodOptional<z.ZodString>;
|
|
660
|
+
filesRead: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
661
|
+
filesWritten: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
662
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
663
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
664
|
+
}, z.core.$strict>;
|
|
665
|
+
}, z.core.$strict>], "activityType">;
|
|
666
|
+
export type SessionActivityMessage = z.infer<typeof SessionActivityMessageSchema>;
|
|
571
667
|
export declare const SessionHistoryResponseSchema: z.ZodObject<{
|
|
572
668
|
sessionId: z.ZodString;
|
|
573
669
|
messages: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -670,7 +766,7 @@ export declare const SessionHistoryResponseSchema: z.ZodObject<{
|
|
|
670
766
|
correction: z.ZodOptional<z.ZodLiteral<true>>;
|
|
671
767
|
opensTurn: z.ZodOptional<z.ZodLiteral<true>>;
|
|
672
768
|
turnErrorCode: z.ZodOptional<z.ZodString>;
|
|
673
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
769
|
+
}, z.core.$strict>, z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
674
770
|
id: z.ZodString;
|
|
675
771
|
role: z.ZodLiteral<"activity">;
|
|
676
772
|
activityType: z.ZodLiteral<"PLAN">;
|
|
@@ -686,7 +782,38 @@ export declare const SessionHistoryResponseSchema: z.ZodObject<{
|
|
|
686
782
|
}>;
|
|
687
783
|
}, z.core.$strict>>;
|
|
688
784
|
}, z.core.$strict>;
|
|
689
|
-
}, z.core.$strict
|
|
785
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
786
|
+
id: z.ZodString;
|
|
787
|
+
role: z.ZodLiteral<"activity">;
|
|
788
|
+
activityType: z.ZodLiteral<"COMPACTION">;
|
|
789
|
+
content: z.ZodObject<{
|
|
790
|
+
compactionId: z.ZodString;
|
|
791
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
792
|
+
}, z.core.$strict>;
|
|
793
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
794
|
+
id: z.ZodString;
|
|
795
|
+
role: z.ZodLiteral<"activity">;
|
|
796
|
+
activityType: z.ZodLiteral<"CHILD_SESSION">;
|
|
797
|
+
content: z.ZodObject<{
|
|
798
|
+
childSessionId: z.ZodString;
|
|
799
|
+
toolCallId: z.ZodOptional<z.ZodString>;
|
|
800
|
+
title: z.ZodOptional<z.ZodString>;
|
|
801
|
+
description: z.ZodOptional<z.ZodString>;
|
|
802
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
803
|
+
cancelled: "cancelled";
|
|
804
|
+
failed: "failed";
|
|
805
|
+
idle: "idle";
|
|
806
|
+
running: "running";
|
|
807
|
+
unknown: "unknown";
|
|
808
|
+
"waiting-for-input": "waiting-for-input";
|
|
809
|
+
}>>;
|
|
810
|
+
model: z.ZodOptional<z.ZodString>;
|
|
811
|
+
filesRead: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
812
|
+
filesWritten: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
813
|
+
durationMs: z.ZodOptional<z.ZodNumber>;
|
|
814
|
+
summary: z.ZodOptional<z.ZodString>;
|
|
815
|
+
}, z.core.$strict>;
|
|
816
|
+
}, z.core.$strict>], "activityType">], "role">>;
|
|
690
817
|
total: z.ZodNumber;
|
|
691
818
|
limit: z.ZodNumber;
|
|
692
819
|
offset: z.ZodNumber;
|
|
@@ -811,6 +938,13 @@ export declare const SessionWorkspaceCapabilitiesResponseSchema: z.ZodObject<{
|
|
|
811
938
|
status: z.ZodLiteral<"unavailable">;
|
|
812
939
|
reason: z.ZodString;
|
|
813
940
|
}, z.core.$strict>]>;
|
|
941
|
+
rewind: z.ZodUnion<readonly [z.ZodObject<{
|
|
942
|
+
status: z.ZodLiteral<"available">;
|
|
943
|
+
scope: z.ZodLiteral<"user-turn">;
|
|
944
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
945
|
+
status: z.ZodLiteral<"unavailable">;
|
|
946
|
+
reason: z.ZodString;
|
|
947
|
+
}, z.core.$strict>]>;
|
|
814
948
|
approvals: z.ZodObject<{
|
|
815
949
|
status: z.ZodLiteral<"available">;
|
|
816
950
|
protocol: z.ZodLiteral<"acp-request">;
|
|
@@ -988,6 +1122,13 @@ export declare const GuestRuntimeCapabilitiesResponseSchema: z.ZodObject<{
|
|
|
988
1122
|
}, z.core.$strict>]>>>;
|
|
989
1123
|
}, z.core.$strict>>>;
|
|
990
1124
|
interactions: z.ZodObject<{
|
|
1125
|
+
rewind: z.ZodUnion<readonly [z.ZodObject<{
|
|
1126
|
+
status: z.ZodLiteral<"available">;
|
|
1127
|
+
scope: z.ZodLiteral<"user-turn">;
|
|
1128
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1129
|
+
status: z.ZodLiteral<"unavailable">;
|
|
1130
|
+
reason: z.ZodString;
|
|
1131
|
+
}, z.core.$strict>]>;
|
|
991
1132
|
questions: z.ZodObject<{
|
|
992
1133
|
status: z.ZodLiteral<"available">;
|
|
993
1134
|
protocol: z.ZodLiteral<"acp-request">;
|
|
@@ -199,7 +199,7 @@ export declare const McpAppResourceReadRequestSchema: z.ZodObject<{
|
|
|
199
199
|
}, z.core.$strict>;
|
|
200
200
|
export type McpAppResourceReadRequest = z.infer<typeof McpAppResourceReadRequestSchema>;
|
|
201
201
|
/**
|
|
202
|
-
* The MCP App sandbox
|
|
202
|
+
* The MCP App sandbox gateway: a static page, served beside the workspace on
|
|
203
203
|
* every listener, that holds only the relay creating the App's own frame. It
|
|
204
204
|
* is a real document rather than `srcdoc` so it carries this policy instead of
|
|
205
205
|
* inheriting the embedding page's, which on the guest surface forbids inline
|
package/dist/protocol/sdk.js
CHANGED
|
@@ -24,6 +24,9 @@ import {
|
|
|
24
24
|
SessionMessageErrorStatusSchema2,
|
|
25
25
|
SessionMessageSchema2,
|
|
26
26
|
SessionPlanActivityMessageSchema2,
|
|
27
|
+
SessionCompactionActivityMessageSchema2,
|
|
28
|
+
SessionChildActivityMessageSchema2,
|
|
29
|
+
SessionActivityMessageSchema2,
|
|
27
30
|
SessionHistoryResponseSchema2,
|
|
28
31
|
SessionCreateRequestSchema2,
|
|
29
32
|
SessionCreateResponseSchema2,
|
|
@@ -61,7 +64,6 @@ import {
|
|
|
61
64
|
HGW_ATTACHMENT_URI_SCHEME2,
|
|
62
65
|
HGW_ARTIFACT_URI_SCHEME2,
|
|
63
66
|
HGW_METHODS2,
|
|
64
|
-
HGW_STOP_REASONS2,
|
|
65
67
|
HGW_PERMISSION_KIND_SESSION2,
|
|
66
68
|
HGW_PLAN_ID2,
|
|
67
69
|
HGW_JSONRPC_ERRORS2,
|
|
@@ -77,6 +79,8 @@ import {
|
|
|
77
79
|
HgwSessionSearchResponseSchema2,
|
|
78
80
|
HgwSessionInfoMetaSchema2,
|
|
79
81
|
HgwSessionResumeMetaSchema2,
|
|
82
|
+
HGW_REPLAY_POSITION2,
|
|
83
|
+
HgwReplayPositionSchema2,
|
|
80
84
|
HGW_REPLAY_BEFORE2,
|
|
81
85
|
HgwReplayBeforeSchema2,
|
|
82
86
|
HgwHistoryCursorSchema2,
|
|
@@ -96,8 +100,7 @@ import {
|
|
|
96
100
|
HgwNoticeMetaSchema2,
|
|
97
101
|
HgwMessageMetaSchema2,
|
|
98
102
|
HgwCostSchema2,
|
|
99
|
-
|
|
100
|
-
HgwSubagentSchema2,
|
|
103
|
+
HgwChildSessionMetaSchema2,
|
|
101
104
|
HgwStateMetaSchema2,
|
|
102
105
|
HgwChunkMetaSchema2,
|
|
103
106
|
HgwToolCallMetaSchema2,
|
|
@@ -222,15 +225,15 @@ export {
|
|
|
222
225
|
HGW_PERMISSION_KIND_SESSION2 as HGW_PERMISSION_KIND_SESSION,
|
|
223
226
|
HGW_PLAN_ID2 as HGW_PLAN_ID,
|
|
224
227
|
HGW_REPLAY_BEFORE2 as HGW_REPLAY_BEFORE,
|
|
228
|
+
HGW_REPLAY_POSITION2 as HGW_REPLAY_POSITION,
|
|
225
229
|
HGW_REQUEST_TEXT_MAX2 as HGW_REQUEST_TEXT_MAX,
|
|
226
|
-
HGW_STOP_REASONS2 as HGW_STOP_REASONS,
|
|
227
|
-
HGW_SUBAGENT_STATUSES2 as HGW_SUBAGENT_STATUSES,
|
|
228
230
|
HgwActivityNotificationSchema2 as HgwActivityNotificationSchema,
|
|
229
231
|
HgwAgentUpdateRequestSchema2 as HgwAgentUpdateRequestSchema,
|
|
230
232
|
HgwAgentUpdateResponseSchema2 as HgwAgentUpdateResponseSchema,
|
|
231
233
|
HgwAgentsListResponseSchema2 as HgwAgentsListResponseSchema,
|
|
232
234
|
HgwArtifactDescriptorSchema2 as HgwArtifactDescriptorSchema,
|
|
233
235
|
HgwAvailableCommandsMetaSchema2 as HgwAvailableCommandsMetaSchema,
|
|
236
|
+
HgwChildSessionMetaSchema2 as HgwChildSessionMetaSchema,
|
|
234
237
|
HgwChunkMetaSchema2 as HgwChunkMetaSchema,
|
|
235
238
|
HgwClientCapabilitiesMetaSchema2 as HgwClientCapabilitiesMetaSchema,
|
|
236
239
|
HgwComposerPrefillNotificationSchema2 as HgwComposerPrefillNotificationSchema,
|
|
@@ -252,6 +255,7 @@ export {
|
|
|
252
255
|
HgwQuestionOptionSchema2 as HgwQuestionOptionSchema,
|
|
253
256
|
HgwQuestionSchema2 as HgwQuestionSchema,
|
|
254
257
|
HgwReplayBeforeSchema2 as HgwReplayBeforeSchema,
|
|
258
|
+
HgwReplayPositionSchema2 as HgwReplayPositionSchema,
|
|
255
259
|
HgwSessionInfoMetaSchema2 as HgwSessionInfoMetaSchema,
|
|
256
260
|
HgwSessionListMetaSchema2 as HgwSessionListMetaSchema,
|
|
257
261
|
HgwSessionNewMetaSchema2 as HgwSessionNewMetaSchema,
|
|
@@ -264,7 +268,6 @@ export {
|
|
|
264
268
|
HgwStateMetaSchema2 as HgwStateMetaSchema,
|
|
265
269
|
HgwSteerRequestSchema2 as HgwSteerRequestSchema,
|
|
266
270
|
HgwSteerResponseSchema2 as HgwSteerResponseSchema,
|
|
267
|
-
HgwSubagentSchema2 as HgwSubagentSchema,
|
|
268
271
|
HgwToolCallMetaSchema2 as HgwToolCallMetaSchema,
|
|
269
272
|
HgwTurnMetaSchema2 as HgwTurnMetaSchema,
|
|
270
273
|
HgwUsageMetaSchema2 as HgwUsageMetaSchema,
|
|
@@ -304,11 +307,14 @@ export {
|
|
|
304
307
|
RuntimeInfoSchema2 as RuntimeInfoSchema,
|
|
305
308
|
SESSION_CATALOG_MAX_WINDOW2 as SESSION_CATALOG_MAX_WINDOW,
|
|
306
309
|
SPEECH_MIME_TYPES,
|
|
310
|
+
SessionActivityMessageSchema2 as SessionActivityMessageSchema,
|
|
307
311
|
SessionActivityResponseSchema2 as SessionActivityResponseSchema,
|
|
308
312
|
SessionAttachmentStageRequestSchema2 as SessionAttachmentStageRequestSchema,
|
|
309
313
|
SessionAttachmentStageResponseSchema2 as SessionAttachmentStageResponseSchema,
|
|
310
314
|
SessionAudioResponseSchema2 as SessionAudioResponseSchema,
|
|
311
315
|
SessionCatalogResponseSchema2 as SessionCatalogResponseSchema,
|
|
316
|
+
SessionChildActivityMessageSchema2 as SessionChildActivityMessageSchema,
|
|
317
|
+
SessionCompactionActivityMessageSchema2 as SessionCompactionActivityMessageSchema,
|
|
312
318
|
SessionContextResponseSchema2 as SessionContextResponseSchema,
|
|
313
319
|
SessionCreateRequestSchema2 as SessionCreateRequestSchema,
|
|
314
320
|
SessionCreateResponseSchema2 as SessionCreateResponseSchema,
|
package/package.json
CHANGED