@harness-gw/sdk 0.10.4 → 0.12.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 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.10.4 \
66
+ ghcr.io/almogbaku/harness-gw:0.12.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.10.4 \
76
+ ghcr.io/almogbaku/harness-gw:0.12.0 \
77
77
  serve --config /run/harness-gw/config.yaml
78
78
  ```
79
79
 
@@ -9,6 +9,7 @@ var IdentifierSchema = z.string().min(1).max(256).refine((value) => [...value].e
9
9
  return code >= 32 && code !== 127;
10
10
  }));
11
11
  var Utf8MiBTextSchema = z.string().min(1).refine((value) => new TextEncoder().encode(value).byteLength <= 1048576);
12
+ var JsonRecordSchema = z.record(z.string(), z.json());
12
13
  var RuntimeAuthStateSchema2 = z.discriminatedUnion("status", [
13
14
  z.strictObject({ status: z.literal("authenticated") }),
14
15
  z.strictObject({ status: z.literal("authentication-required") }),
@@ -83,9 +84,9 @@ var AgentSummarySchema = z.strictObject({
83
84
  status: z.enum(["idle", "active", "running", "attention", "unknown"]).optional(),
84
85
  activity: z.enum(["active", "idle", "unknown"]).optional(),
85
86
  visibility: z.enum(["visible", "hidden"]).optional(),
86
- role: z.literal("creator").optional(),
87
87
  avatar: AgentAvatarSchema2.optional(),
88
- muted: z.literal(true).optional()
88
+ muted: z.literal(true).optional(),
89
+ _meta: JsonRecordSchema.optional()
89
90
  });
90
91
  var AgentCatalogEntrySchema2 = z.strictObject({
91
92
  summary: AgentSummarySchema,
@@ -199,7 +200,6 @@ var ToolDiffSchema2 = z.strictObject({
199
200
  changes: z.array(DiffChangeSchema2).min(1),
200
201
  patch: z.string().optional()
201
202
  });
202
- var JsonRecordSchema = z.record(z.string(), z.json());
203
203
  var SessionMessagePartSchema = z.discriminatedUnion("type", [
204
204
  z.strictObject({ type: z.literal("text"), text: z.string().max(1e6) }),
205
205
  z.strictObject({
@@ -735,7 +735,7 @@ function hgwAcpAgentPath2(agentId) {
735
735
  return `${HGW_ACP_AGENTS_PATH2}/${encodeURIComponent(agentId)}`;
736
736
  }
737
737
  var HGW_META_KEY2 = "hgw";
738
- var HGW_EXTENSION_VERSION2 = 2;
738
+ var HGW_EXTENSION_VERSION2 = 3;
739
739
  var HGW_AUTH_METHOD_INVITE2 = "hgw-invite";
740
740
  var HGW_ATTACHMENT_URI_SCHEME2 = "hgw-attachment:";
741
741
  var HGW_ARTIFACT_URI_SCHEME2 = "artifact:";
@@ -1053,10 +1053,8 @@ function categoryOf2(type) {
1053
1053
  case "attention-requested":
1054
1054
  return "input";
1055
1055
  case "turn-failed":
1056
- case "agent-activation-failed":
1057
1056
  return "failure";
1058
1057
  case "turn-finished":
1059
- case "agent-ready":
1060
1058
  return "completion";
1061
1059
  default:
1062
1060
  return;
@@ -1188,25 +1186,81 @@ var McpAppResourceReadRequestSchema2 = z4.strictObject({
1188
1186
  uri: z4.string().min(1).max(2048)
1189
1187
  });
1190
1188
  var MCP_APP_SANDBOX_PATH2 = "/mcp-app-sandbox.html";
1191
- var LOOPBACK_SOURCES = (scheme) => ["127.0.0.1", "localhost", "*.localhost"].map((host) => `${scheme}://${host}:*`);
1192
- var MCP_APP_SANDBOX_CSP2 = [
1193
- "default-src 'none'",
1194
- "script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval' https:",
1195
- "style-src 'self' 'unsafe-inline' https:",
1196
- "img-src 'self' data: https:",
1197
- "font-src 'self' data: https:",
1198
- ["media-src 'self' data: https:", ...LOOPBACK_SOURCES("http")].join(" "),
1199
- [
1200
- "connect-src https: wss:",
1201
- ...LOOPBACK_SOURCES("http"),
1202
- ...LOOPBACK_SOURCES("ws")
1203
- ].join(" "),
1204
- "worker-src 'self' blob: data:",
1205
- "frame-src https:",
1206
- "base-uri https:",
1207
- "object-src 'none'",
1208
- "form-action 'none'",
1209
- "frame-ancestors 'self'"
1210
- ].join("; ");
1189
+ var POLICY_ORIGIN = new RegExp(`^https?://${HOST}${PORT}$`, "u");
1190
+ function isMcpAppPolicyOrigin2(value) {
1191
+ try {
1192
+ return POLICY_ORIGIN.test(value) && new URL(value).origin === value;
1193
+ } catch {
1194
+ return false;
1195
+ }
1196
+ }
1197
+ function ownHosts({
1198
+ frameAncestors,
1199
+ sandboxOrigin
1200
+ }) {
1201
+ const origins = [...frameAncestors, sandboxOrigin];
1202
+ const invalid = origins.find((origin) => !isMcpAppPolicyOrigin2(origin));
1203
+ if (invalid !== undefined)
1204
+ throw new Error(`Not an exact origin a sandbox policy can name: ${invalid}`);
1205
+ if (frameAncestors.includes(sandboxOrigin))
1206
+ throw new Error(`The sandbox origin is one of the host's: ${sandboxOrigin}`);
1207
+ return new Set(origins.map((origin) => new URL(origin).host));
1208
+ }
1209
+ function namesHost(domain, hosts) {
1210
+ try {
1211
+ return hosts.has(new URL(domain).host);
1212
+ } catch {
1213
+ return false;
1214
+ }
1215
+ }
1216
+ var CSP_LISTS = McpUiCspSchema2.keyof().options;
1217
+ function appliedMcpAppCsp2({
1218
+ csp,
1219
+ ...origins
1220
+ }) {
1221
+ const own = ownHosts(origins);
1222
+ const applied = {};
1223
+ for (const list of CSP_LISTS) {
1224
+ const domains = new Set((csp?.[list] ?? []).filter((domain) => isMcpAppCspDomain2(list, domain)).map((domain) => domain.toLowerCase()).filter((domain) => !namesHost(domain, own)));
1225
+ if (domains.size > 0)
1226
+ applied[list] = [...domains];
1227
+ }
1228
+ return Object.keys(applied).length > 0 ? applied : undefined;
1229
+ }
1230
+ function policyFileLocation(value, origins) {
1231
+ try {
1232
+ const url = new URL(value);
1233
+ if (!["http:", "https:"].includes(url.protocol) || !origins.includes(url.origin) || url.pathname.endsWith("/"))
1234
+ return;
1235
+ const path = url.pathname.split("/").map((segment) => encodeURIComponent(decodeURIComponent(segment)).replaceAll("'", "%27")).join("/");
1236
+ return `${url.origin}${path}`;
1237
+ } catch {
1238
+ return;
1239
+ }
1240
+ }
1241
+ var sources = (base, domains = []) => [...base, ...domains].join(" ") || "'none'";
1242
+ function mcpAppSandboxPolicy2({
1243
+ fileLocations = [],
1244
+ ...view
1245
+ }) {
1246
+ const applied = appliedMcpAppCsp2(view) ?? {};
1247
+ const files = fileLocations.flatMap((location) => policyFileLocation(location, view.frameAncestors) ?? []);
1248
+ const resource = applied.resourceDomains ?? [];
1249
+ return [
1250
+ "default-src 'none'",
1251
+ `script-src ${sources(["'self'", "'unsafe-inline'", "'wasm-unsafe-eval'"], resource)}`,
1252
+ `style-src ${sources(["'self'", "'unsafe-inline'"], resource)}`,
1253
+ `img-src ${sources(["'self'", "data:"], resource)}`,
1254
+ `font-src ${sources(["'self'", "data:"], resource)}`,
1255
+ `media-src ${sources(["'self'", "data:"], [...resource, ...files])}`,
1256
+ `connect-src ${sources(applied.connectDomains ?? [], files)}`,
1257
+ "worker-src 'self' blob: data:",
1258
+ `frame-src ${sources([], applied.frameDomains)}`,
1259
+ `base-uri ${sources([], applied.baseUriDomains)}`,
1260
+ "object-src 'none'",
1261
+ "form-action 'none'",
1262
+ `frame-ancestors ${sources([], view.frameAncestors)}`
1263
+ ].join("; ");
1264
+ }
1211
1265
 
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 };
1266
+ 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, isMcpAppPolicyOrigin2, appliedMcpAppCsp2, mcpAppSandboxPolicy2 };
@@ -12,12 +12,10 @@ type MetadataListener = (metadata: SessionMetadata[]) => void;
12
12
  export type AcpSessionStoreOptions = {
13
13
  connection: AcpConnection;
14
14
  now?: () => number;
15
- /** A live turn of a subscribed Session just stopped, however it ended. */
16
- onTurnFinished?: (sessionId: string) => void;
17
15
  /** Where a listener that throws is told; the others still hear. */
18
16
  logger?: Logger;
19
17
  };
20
- export declare function createAcpSessionStore({ connection, now, onTurnFinished, logger, }: AcpSessionStoreOptions): {
18
+ export declare function createAcpSessionStore({ connection, now, logger, }: AcpSessionStoreOptions): {
21
19
  subscribe: (sessionId: string, agentId?: string) => () => void;
22
20
  dispose(): void;
23
21
  /**
@@ -59,7 +57,6 @@ export declare function createAcpSessionStore({ connection, now, onTurnFinished,
59
57
  subscribeMetadata(sessionIds: readonly string[], listener: MetadataListener): () => boolean;
60
58
  subscribeStatus(sessionId: string, listener: () => void): () => boolean;
61
59
  subscribeTodos(sessionId: string, listener: (todos: TodoItem[]) => void): () => void;
62
- emitActivity: (event: WorkspaceActivityEvent) => void;
63
60
  subscribeActivity(listener: (event: WorkspaceActivityEvent) => void): () => boolean;
64
61
  subscribeInvalidation(sessionId: string, listener: () => void): () => void;
65
62
  };
@@ -26,9 +26,9 @@ export declare function createAcpWorkspaceClient({ connection, rest, agentIdFor,
26
26
  status?: "active" | "attention" | "idle" | "running" | "unknown" | undefined;
27
27
  activity?: "active" | "idle" | "unknown" | undefined;
28
28
  visibility?: "hidden" | "visible" | undefined;
29
- role?: "creator" | undefined;
30
29
  avatar?: string | undefined;
31
30
  muted?: true | undefined;
31
+ _meta?: Record<string, import("zod").JSONType> | undefined;
32
32
  }[]>;
33
33
  refreshAgents(): Promise<{
34
34
  kind: "ready";
@@ -38,9 +38,9 @@ export declare function createAcpWorkspaceClient({ connection, rest, agentIdFor,
38
38
  status?: "active" | "attention" | "idle" | "running" | "unknown" | undefined;
39
39
  activity?: "active" | "idle" | "unknown" | undefined;
40
40
  visibility?: "hidden" | "visible" | undefined;
41
- role?: "creator" | undefined;
42
41
  avatar?: string | undefined;
43
42
  muted?: true | undefined;
43
+ _meta?: Record<string, import("zod").JSONType> | undefined;
44
44
  }[]>;
45
45
  listAgentCatalog(): Promise<{
46
46
  summary: {
@@ -51,9 +51,9 @@ export declare function createAcpWorkspaceClient({ connection, rest, agentIdFor,
51
51
  status?: "active" | "attention" | "idle" | "running" | "unknown" | undefined;
52
52
  activity?: "active" | "idle" | "unknown" | undefined;
53
53
  visibility?: "hidden" | "visible" | undefined;
54
- role?: "creator" | undefined;
55
54
  avatar?: string | undefined;
56
55
  muted?: true | undefined;
56
+ _meta?: Record<string, import("zod").JSONType> | undefined;
57
57
  };
58
58
  visibility: "hidden" | "visible";
59
59
  selectable: boolean;
@@ -1690,7 +1690,6 @@ function sameRow(left, right) {
1690
1690
  function createAcpSessionStore({
1691
1691
  connection,
1692
1692
  now = Date.now,
1693
- onTurnFinished,
1694
1693
  logger = SILENT_LOGGER
1695
1694
  }) {
1696
1695
  const rows = new Map;
@@ -1770,10 +1769,7 @@ function createAcpSessionStore({
1770
1769
  const status = statusFromState(update);
1771
1770
  if (replaying.has(sessionId))
1772
1771
  return void replaying.set(sessionId, status);
1773
- const previous = rows.get(sessionId)?.status;
1774
1772
  patch(sessionId, { status });
1775
- if ((previous === "running" || previous === "waiting-for-input") && (status === "idle" || status === "failed"))
1776
- onTurnFinished?.(sessionId);
1777
1773
  return;
1778
1774
  }
1779
1775
  if (SessionUpdate3.isSessionInfoUpdate(update)) {
@@ -1904,7 +1900,6 @@ function createAcpSessionStore({
1904
1900
  todoListeners.delete(sessionId);
1905
1901
  };
1906
1902
  },
1907
- emitActivity,
1908
1903
  subscribeActivity(listener) {
1909
1904
  activityListeners.add(listener);
1910
1905
  return () => activityListeners.delete(listener);
@@ -1947,10 +1942,7 @@ function createAcpWorkspaceClient({
1947
1942
  const store = createAcpSessionStore({
1948
1943
  connection,
1949
1944
  logger: clientLog,
1950
- ...now ? { now } : {},
1951
- onTurnFinished: (sessionId) => {
1952
- reportCreatedAgents(sessionId).catch((err) => clientLog.warn({ err }, "agent.report_created_failed"));
1953
- }
1945
+ ...now ? { now } : {}
1954
1946
  });
1955
1947
  const composer = createAcpComposerStore(connection);
1956
1948
  const revisions = new Map;
@@ -1961,9 +1953,6 @@ function createAcpWorkspaceClient({
1961
1953
  const result = await connection.updateAgent({ agentId, ...patch, revision });
1962
1954
  revisions.set(agentId, result.agent.revision);
1963
1955
  }
1964
- let creatorId;
1965
- let listedAgentIds = new Set;
1966
- const creatorBaselines = new Map;
1967
1956
  let sessionActions;
1968
1957
  function adopt(sessionId, agentId) {
1969
1958
  try {
@@ -1988,8 +1977,6 @@ function createAcpWorkspaceClient({
1988
1977
  revisions.clear();
1989
1978
  for (const entry of response.agents)
1990
1979
  revisions.set(entry.summary.id, entry.revision);
1991
- creatorId = response.agents.find(({ summary }) => summary.role === "creator")?.summary.id;
1992
- listedAgentIds = new Set(response.agents.map(({ summary }) => summary.id));
1993
1980
  return response;
1994
1981
  }
1995
1982
  function rememberRows(sessions) {
@@ -2024,33 +2011,6 @@ function createAcpWorkspaceClient({
2024
2011
  pageReads.set(key, read);
2025
2012
  return read;
2026
2013
  }
2027
- function watchCreator(sessionId, agentId) {
2028
- if (agentId === creatorId && !creatorBaselines.has(sessionId))
2029
- creatorBaselines.set(sessionId, new Set(listedAgentIds));
2030
- }
2031
- async function reportCreatedAgents(sessionId) {
2032
- const baseline = creatorBaselines.get(sessionId);
2033
- if (!baseline)
2034
- return;
2035
- let agents;
2036
- try {
2037
- agents = (await catalog()).agents;
2038
- } catch {
2039
- return;
2040
- }
2041
- for (const { summary, visibility } of agents) {
2042
- if (baseline.has(summary.id))
2043
- continue;
2044
- baseline.add(summary.id);
2045
- store.emitActivity({
2046
- id: `${sessionId}:${summary.id}`,
2047
- type: visibility === "hidden" ? "agent-activation-failed" : "agent-ready",
2048
- agentId: summary.id,
2049
- sessionId,
2050
- occurredAt: new Date((now ?? Date.now)()).toISOString()
2051
- });
2052
- }
2053
- }
2054
2014
  async function listSessions(agentId, cursor) {
2055
2015
  const page = await readSessionPage(agentId === undefined ? {} : { agentId }, cursor);
2056
2016
  return {
@@ -2144,10 +2104,8 @@ function createAcpWorkspaceClient({
2144
2104
  leaveComposer();
2145
2105
  }
2146
2106
  });
2147
- if (agentId) {
2107
+ if (agentId)
2148
2108
  adopt(sessionId, agentId);
2149
- watchCreator(sessionId, agentId);
2150
- }
2151
2109
  }
2152
2110
  let released = false;
2153
2111
  return () => {
@@ -2224,7 +2182,6 @@ function createAcpWorkspaceClient({
2224
2182
  ...options?.title ? { title: options.title } : {}
2225
2183
  });
2226
2184
  adopt(created.sessionId, agentId);
2227
- watchCreator(created.sessionId, agentId);
2228
2185
  return { sessionId: created.sessionId };
2229
2186
  },
2230
2187
  subscribeSession,
@@ -52,8 +52,6 @@ export type WorkspaceActivityEvent = (ActivityBase & {
52
52
  }) | (ActivityBase & {
53
53
  type: "attention-resolved";
54
54
  requestId: string;
55
- }) | (ActivityBase & {
56
- type: "agent-ready" | "agent-activation-failed";
57
55
  });
58
56
  export type SessionMetadata = {
59
57
  sessionId: string;
@@ -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: 2;
47
+ export declare const HGW_EXTENSION_VERSION: 3;
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:";
@@ -120,7 +120,7 @@ export declare const HgwClientCapabilitiesMetaSchema: z.ZodObject<{
120
120
  }, z.core.$strip>;
121
121
  /** `InitializeResponse._meta.hgw` */
122
122
  export declare const HgwInitializeMetaSchema: z.ZodObject<{
123
- version: z.ZodLiteral<2>;
123
+ version: z.ZodLiteral<3>;
124
124
  role: z.ZodEnum<{
125
125
  guest: "guest";
126
126
  operator: "operator";
@@ -349,9 +349,9 @@ export declare const HgwAgentsListResponseSchema: z.ZodObject<{
349
349
  hidden: "hidden";
350
350
  visible: "visible";
351
351
  }>>;
352
- role: z.ZodOptional<z.ZodLiteral<"creator">>;
353
352
  avatar: z.ZodOptional<z.ZodString>;
354
353
  muted: z.ZodOptional<z.ZodLiteral<true>>;
354
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
355
355
  }, z.core.$strict>;
356
356
  visibility: z.ZodEnum<{
357
357
  hidden: "hidden";
@@ -400,9 +400,9 @@ export declare const HgwAgentUpdateResponseSchema: z.ZodObject<{
400
400
  hidden: "hidden";
401
401
  visible: "visible";
402
402
  }>>;
403
- role: z.ZodOptional<z.ZodLiteral<"creator">>;
404
403
  avatar: z.ZodOptional<z.ZodString>;
405
404
  muted: z.ZodOptional<z.ZodLiteral<true>>;
405
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
406
406
  }, z.core.$strict>;
407
407
  visibility: z.ZodEnum<{
408
408
  hidden: "hidden";
@@ -164,9 +164,9 @@ export declare const AgentCatalogEntrySchema: z.ZodObject<{
164
164
  hidden: "hidden";
165
165
  visible: "visible";
166
166
  }>>;
167
- role: z.ZodOptional<z.ZodLiteral<"creator">>;
168
167
  avatar: z.ZodOptional<z.ZodString>;
169
168
  muted: z.ZodOptional<z.ZodLiteral<true>>;
169
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
170
170
  }, z.core.$strict>;
171
171
  visibility: z.ZodEnum<{
172
172
  hidden: "hidden";
@@ -203,9 +203,9 @@ export declare const AgentCatalogResponseSchema: z.ZodObject<{
203
203
  hidden: "hidden";
204
204
  visible: "visible";
205
205
  }>>;
206
- role: z.ZodOptional<z.ZodLiteral<"creator">>;
207
206
  avatar: z.ZodOptional<z.ZodString>;
208
207
  muted: z.ZodOptional<z.ZodLiteral<true>>;
208
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
209
209
  }, z.core.$strict>;
210
210
  visibility: z.ZodEnum<{
211
211
  hidden: "hidden";
@@ -272,9 +272,9 @@ export declare const AgentUpdateResponseSchema: z.ZodObject<{
272
272
  hidden: "hidden";
273
273
  visible: "visible";
274
274
  }>>;
275
- role: z.ZodOptional<z.ZodLiteral<"creator">>;
276
275
  avatar: z.ZodOptional<z.ZodString>;
277
276
  muted: z.ZodOptional<z.ZodLiteral<true>>;
277
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodJSONSchema>>;
278
278
  }, z.core.$strict>;
279
279
  visibility: z.ZodEnum<{
280
280
  hidden: "hidden";
@@ -199,13 +199,57 @@ 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 gateway: a static page, served beside the workspace on
203
- * every listener, that holds only the relay creating the App's own frame. It
204
- * is a real document rather than `srcdoc` so it carries this policy instead of
205
- * inheriting the embedding page's, which on the guest surface forbids inline
206
- * scripts. The App frame inherits it too, so it is the widest any view may
207
- * reach — every source `buildMcpAppCsp` can grant — and the view's own policy,
208
- * injected into its document, narrows it to what it declared.
202
+ * The MCP App sandbox page: a static page that holds only the relay creating
203
+ * the App's own frame. A host serves it from a sandbox origin of its own,
204
+ * apart from its pages' origins as the spec requires, and frames it with
205
+ * `allow-scripts allow-same-origin`, so the view runs on that origin with
206
+ * storage of its own. The page is a real document rather than `srcdoc` so it
207
+ * carries the view's own policy, `mcpAppSandboxPolicy`, as its header; the
208
+ * view's `srcdoc` frame inherits it.
209
209
  */
210
210
  export declare const MCP_APP_SANDBOX_PATH = "/mcp-app-sandbox.html";
211
- export declare const MCP_APP_SANDBOX_CSP: string;
211
+ /** What one view's sandbox policy is built from. */
212
+ export type McpAppSandboxPolicyInput = {
213
+ /**
214
+ * The exact origins of the host's own pages, the only ones that may frame
215
+ * the sandbox page.
216
+ */
217
+ frameAncestors: readonly string[];
218
+ /** The exact origin the sandbox page is served from. */
219
+ sandboxOrigin: string;
220
+ /** The view's declared `_meta.ui.csp`. */
221
+ csp?: McpUiCsp | undefined;
222
+ /** The call's absolute file addresses; no pass is written. */
223
+ fileLocations?: readonly string[] | undefined;
224
+ };
225
+ /**
226
+ * Whether a sandbox policy can name `value` as a framing page or as the
227
+ * sandbox: an `http(s)` origin exactly as `URL` writes it, whose host is a name
228
+ * or an IPv4 address. `mcpAppSandboxPolicy` throws for any other, so a host
229
+ * checks its settings with this once, before it serves a view.
230
+ */
231
+ export declare function isMcpAppPolicyOrigin(value: string): boolean;
232
+ /**
233
+ * The domains a view's sandbox policy applies, per `_meta.ui.csp` list, as a
234
+ * host reports them in `hostCapabilities.sandbox.csp`: those
235
+ * `isMcpAppCspDomain` admits, lowercased and once each, without any that names
236
+ * the host and port of a framing page or of the sandbox itself, whatever its
237
+ * scheme. `undefined` when it applies none. Throws as `mcpAppSandboxPolicy`
238
+ * does for the origins.
239
+ */
240
+ export declare function appliedMcpAppCsp({ csp, ...origins }: Omit<McpAppSandboxPolicyInput, "fileLocations">): McpUiCsp | undefined;
241
+ /**
242
+ * One view's sandbox policy, sent as the sandbox page's header: the MCP Apps
243
+ * default policy (spec 2026-01-26), widened only by the domains
244
+ * `appliedMcpAppCsp` keeps and by the call's own file locations, each by its
245
+ * exact path, to read and to play; never allowing plugins or form posts, and
246
+ * framed only by `frameAncestors`. Views may compile WebAssembly, as a
247
+ * document renderer's decoders do.
248
+ *
249
+ * Anyone can ask for a sandbox page with any query, so every value is checked
250
+ * before it is written: an ancestor or a sandbox origin that is no exact
251
+ * origin (`isMcpAppPolicyOrigin`) throws, as does a sandbox origin among the
252
+ * ancestors, and a domain or a file location its rule refuses is dropped. A
253
+ * file location is kept only on a framing page's origin.
254
+ */
255
+ export declare function mcpAppSandboxPolicy({ fileLocations, ...view }: McpAppSandboxPolicyInput): string;
@@ -14,7 +14,7 @@ export declare const PushCategorySchema: z.ZodEnum<{
14
14
  input: "input";
15
15
  }>;
16
16
  export type PushCategory = z.infer<typeof PushCategorySchema>;
17
- /** Which category, if any, an execution or Agent lifecycle event notifies as. */
17
+ /** Which category, if any, an execution event notifies as. */
18
18
  export declare function categoryOf(type: string): PushCategory | undefined;
19
19
  export declare const PushLocaleSchema: z.ZodEnum<{
20
20
  en: "en";
@@ -144,7 +144,9 @@ import {
144
144
  McpAppToolCallRequestSchema2,
145
145
  McpAppResourceReadRequestSchema2,
146
146
  MCP_APP_SANDBOX_PATH2,
147
- MCP_APP_SANDBOX_CSP2
147
+ isMcpAppPolicyOrigin2,
148
+ appliedMcpAppCsp2,
149
+ mcpAppSandboxPolicy2
148
150
  } from "../chunks/index.js";
149
151
  // protocol/audio.ts
150
152
  var RECORDING_MIME_TYPES = [
@@ -278,7 +280,6 @@ export {
278
280
  MAX_SPEECH_BYTES,
279
281
  MAX_SPEECH_TEXT_BYTES,
280
282
  MAX_TRANSCRIPT_BYTES,
281
- MCP_APP_SANDBOX_CSP2 as MCP_APP_SANDBOX_CSP,
282
283
  MCP_APP_SANDBOX_PATH2 as MCP_APP_SANDBOX_PATH,
283
284
  McpAppFilesSchema2 as McpAppFilesSchema,
284
285
  McpAppResourceReadRequestSchema2 as McpAppResourceReadRequestSchema,
@@ -342,10 +343,13 @@ export {
342
343
  TurnSteerRequestSchema2 as TurnSteerRequestSchema,
343
344
  TurnSteerResponseSchema2 as TurnSteerResponseSchema,
344
345
  TurnStopResponseSchema2 as TurnStopResponseSchema,
346
+ appliedMcpAppCsp2 as appliedMcpAppCsp,
345
347
  categoryOf2 as categoryOf,
346
348
  formatArtifactUri2 as formatArtifactUri,
347
349
  hgwAcpAgentPath2 as hgwAcpAgentPath,
348
350
  isMcpAppCspDomain2 as isMcpAppCspDomain,
351
+ isMcpAppPolicyOrigin2 as isMcpAppPolicyOrigin,
352
+ mcpAppSandboxPolicy2 as mcpAppSandboxPolicy,
349
353
  newestSessionFirst2 as newestSessionFirst,
350
354
  parseArtifactUri2 as parseArtifactUri,
351
355
  parseRecordingMime,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harness-gw/sdk",
3
- "version": "0.10.4",
3
+ "version": "0.12.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",