@harness-gw/sdk 0.1.3 → 0.2.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.1.3 \
66
+ ghcr.io/almogbaku/harness-gw:0.2.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.1.3 \
76
+ ghcr.io/almogbaku/harness-gw:0.2.0 \
77
77
  serve --config /run/harness-gw/config.yaml
78
78
  ```
79
79
 
@@ -696,6 +696,9 @@ var HGW_METHODS2 = {
696
696
  focus: "_hgw/session/focus",
697
697
  part: "_hgw/session/part"
698
698
  },
699
+ sessions: {
700
+ search: "_hgw/sessions/search"
701
+ },
699
702
  agents: {
700
703
  list: "_hgw/agents/list",
701
704
  update: "_hgw/agents/update"
@@ -760,6 +763,19 @@ var HgwSessionNewMetaSchema2 = z2.strictObject({
760
763
  var HgwSessionListMetaSchema2 = z2.strictObject({
761
764
  agentId: IdentifierSchema2.optional()
762
765
  });
766
+ var HgwSessionSearchMetaSchema2 = z2.strictObject({
767
+ agentId: IdentifierSchema2.optional(),
768
+ query: z2.string().min(1).max(512)
769
+ });
770
+ var HgwSessionSearchResponseSchema2 = readObject({
771
+ sessions: z2.array(readObject({
772
+ sessionId: IdentifierSchema2,
773
+ cwd: z2.string(),
774
+ title: z2.string().nullish(),
775
+ updatedAt: z2.string().nullish(),
776
+ _meta: z2.record(z2.string(), z2.unknown()).nullish()
777
+ }))
778
+ });
763
779
  var HgwSessionInfoMetaSchema2 = readObject({
764
780
  agentId: IdentifierSchema2,
765
781
  status: SessionStatusSchema2,
@@ -1146,4 +1162,4 @@ var MCP_APP_SANDBOX_CSP2 = [
1146
1162
  "frame-ancestors 'self'"
1147
1163
  ].join("; ");
1148
1164
 
1149
- 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, HGW_STOP_REASONS2, HGW_PERMISSION_KIND_SESSION2, HGW_PLAN_ID2, HGW_JSONRPC_ERRORS2, IdentifierSchema2, HgwExtensionsSchema2, HgwClientCapabilitiesMetaSchema2, HgwInitializeMetaSchema2, HgwLoginMetaSchema2, HgwSessionNewMetaSchema2, HgwSessionListMetaSchema2, HgwSessionInfoMetaSchema2, HgwSessionResumeMetaSchema2, HGW_REPLAY_BEFORE2, HgwReplayBeforeSchema2, HgwHistoryCursorSchema2, HgwHistoryPageResponseMetaSchema2, HgwHistoryPageTagSchema2, HgwSessionResumeResponseMetaSchema2, HgwPromptMetaSchema2, HgwSessionUpdateRequestSchema2, HgwSessionPartRequestSchema2, HgwSteerRequestSchema2, HgwSteerResponseSchema2, HgwFocusRequestSchema2, HgwAgentsListResponseSchema2, HgwAgentUpdateRequestSchema2, HgwAgentUpdateResponseSchema2, HgwTurnMetaSchema2, HgwNoticeMetaSchema2, HgwMessageMetaSchema2, HgwCostSchema2, HGW_SUBAGENT_STATUSES2, HgwSubagentSchema2, HgwStateMetaSchema2, HgwChunkMetaSchema2, HgwToolCallMetaSchema2, HgwPlanMetaSchema2, HgwUsageMetaSchema2, HgwAvailableCommandsMetaSchema2, HgwPermissionMetaSchema2, HgwQuestionOptionSchema2, HgwQuestionSchema2, HgwElicitationMetaSchema2, HgwArtifactDescriptorSchema2, formatArtifactUri2, parseArtifactUri2, HgwComposerPrefillNotificationSchema2, HgwErrorNotificationSchema2, HgwActivityNotificationSchema2, PushCategorySchema2, categoryOf2, PushLocaleSchema2, PRESENCE_IDLE_MS2, PRESENCE_HEARTBEAT_MS2, PRESENCE_GRACE_MS2, PRESENCE_CLOSED_GRACE_MS2, COALESCE_WINDOW_MS2, PushMessageSchema2, PushCategoriesSchema2, PushSubscriptionJsonSchema2, PushInfoSchema2, PushRegistrationSchema2, PushUnregistrationSchema2, CallToolResultSchema2, ReadResourceResultSchema2, McpUiCspSchema2, isMcpAppCspDomain2, McpUiPermissionsSchema2, McpAppFilesSchema2, McpAppViewSchema2, viewerFileResult2, McpAppToolCallRequestSchema2, McpAppResourceReadRequestSchema2, MCP_APP_SANDBOX_PATH2, MCP_APP_SANDBOX_CSP2 };
1165
+ 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, HGW_STOP_REASONS2, HGW_PERMISSION_KIND_SESSION2, HGW_PLAN_ID2, HGW_JSONRPC_ERRORS2, IdentifierSchema2, HgwExtensionsSchema2, HgwClientCapabilitiesMetaSchema2, HgwInitializeMetaSchema2, HgwLoginMetaSchema2, HgwSessionNewMetaSchema2, HgwSessionListMetaSchema2, HgwSessionSearchMetaSchema2, HgwSessionSearchResponseSchema2, HgwSessionInfoMetaSchema2, HgwSessionResumeMetaSchema2, HGW_REPLAY_BEFORE2, HgwReplayBeforeSchema2, HgwHistoryCursorSchema2, HgwHistoryPageResponseMetaSchema2, HgwHistoryPageTagSchema2, HgwSessionResumeResponseMetaSchema2, HgwPromptMetaSchema2, HgwSessionUpdateRequestSchema2, HgwSessionPartRequestSchema2, HgwSteerRequestSchema2, HgwSteerResponseSchema2, HgwFocusRequestSchema2, HgwAgentsListResponseSchema2, HgwAgentUpdateRequestSchema2, HgwAgentUpdateResponseSchema2, HgwTurnMetaSchema2, HgwNoticeMetaSchema2, HgwMessageMetaSchema2, HgwCostSchema2, HGW_SUBAGENT_STATUSES2, HgwSubagentSchema2, HgwStateMetaSchema2, HgwChunkMetaSchema2, HgwToolCallMetaSchema2, HgwPlanMetaSchema2, HgwUsageMetaSchema2, HgwAvailableCommandsMetaSchema2, HgwPermissionMetaSchema2, HgwQuestionOptionSchema2, HgwQuestionSchema2, HgwElicitationMetaSchema2, HgwArtifactDescriptorSchema2, formatArtifactUri2, parseArtifactUri2, HgwComposerPrefillNotificationSchema2, HgwErrorNotificationSchema2, HgwActivityNotificationSchema2, PushCategorySchema2, categoryOf2, PushLocaleSchema2, PRESENCE_IDLE_MS2, PRESENCE_HEARTBEAT_MS2, PRESENCE_GRACE_MS2, PRESENCE_CLOSED_GRACE_MS2, COALESCE_WINDOW_MS2, PushMessageSchema2, PushCategoriesSchema2, PushSubscriptionJsonSchema2, PushInfoSchema2, PushRegistrationSchema2, PushUnregistrationSchema2, CallToolResultSchema2, ReadResourceResultSchema2, McpUiCspSchema2, isMcpAppCspDomain2, McpUiPermissionsSchema2, McpAppFilesSchema2, McpAppViewSchema2, viewerFileResult2, McpAppToolCallRequestSchema2, McpAppResourceReadRequestSchema2, MCP_APP_SANDBOX_PATH2, MCP_APP_SANDBOX_CSP2 };
@@ -1,6 +1,7 @@
1
+ import type { SessionInfo } from "@agentclientprotocol/sdk/experimental/v2";
1
2
  import { type Clock, type Logger } from "../lifecycle/index.js";
2
3
  import type { SessionModelUpdateRequest, SessionModelUpdateResponse } from "../protocol/index.js";
3
- import type { AgentUpdate, SessionActionCapabilities, SessionCreationOptions } from "./workspace.js";
4
+ import type { AgentUpdate, SessionActionCapabilities, SessionCreationOptions, SessionSearchResult } from "./workspace.js";
4
5
  import type { HgwRemoteClient } from "./hgw-client.js";
5
6
  import type { AcpConnection } from "./types.js";
6
7
  /** What the workspace still reads over REST, delegated to the AOS client. */
@@ -73,12 +74,17 @@ export declare function createAcpWorkspaceClient({ connection, rest, agentIdFor,
73
74
  }[];
74
75
  }>;
75
76
  readSessionPage: (meta: Parameters<AcpConnection["listSessions"]>[0], cursor?: string) => Promise<{
76
- sessions: import("@agentclientprotocol/sdk/experimental/v2").SessionInfo[];
77
+ sessions: SessionInfo[];
77
78
  nextCursor?: string;
78
79
  }>;
79
80
  scopeSessionCatalog(agentId: string): void;
80
81
  /** The Agent the thread list pages History for, once one is selected. */
81
82
  sessionCatalogScope: () => string | undefined;
83
+ /**
84
+ * The Sessions the runtime matches to a query, across every Agent or the
85
+ * one named. Each lands in the row cache as a listed one does.
86
+ */
87
+ searchSessions(query: string, agentId?: string): Promise<SessionSearchResult[]>;
82
88
  subscribeSessionCatalog(listener: (sessionIds: readonly string[]) => void): () => boolean;
83
89
  getSessionMetadata(sessionIds: string[]): Promise<{
84
90
  sessionId: string;
@@ -15,6 +15,8 @@ import {
15
15
  HGW_PERMISSION_KIND_SESSION2,
16
16
  HGW_JSONRPC_ERRORS2,
17
17
  HgwInitializeMetaSchema2,
18
+ HgwSessionSearchMetaSchema2,
19
+ HgwSessionSearchResponseSchema2,
18
20
  HgwSessionInfoMetaSchema2,
19
21
  HGW_REPLAY_BEFORE2,
20
22
  HgwHistoryPageResponseMetaSchema2,
@@ -1212,6 +1214,11 @@ function createAcpConnection(options) {
1212
1214
  ...response.nextCursor ? { nextCursor: response.nextCursor } : {}
1213
1215
  };
1214
1216
  },
1217
+ async searchSessions(meta) {
1218
+ return HgwSessionSearchResponseSchema2.parse(await request("short", (agent, options) => agent.request(HGW_METHODS2.sessions.search, {
1219
+ _meta: { [HGW_META_KEY2]: HgwSessionSearchMetaSchema2.parse(meta) }
1220
+ }, options)));
1221
+ },
1215
1222
  subscribe,
1216
1223
  joined,
1217
1224
  replay,
@@ -1799,6 +1806,14 @@ function createAcpWorkspaceClient({
1799
1806
  listedAgentIds = new Set(response.agents.map(({ summary }) => summary.id));
1800
1807
  return response;
1801
1808
  }
1809
+ function rememberRows(sessions) {
1810
+ for (const session of sessions) {
1811
+ const row = rowOf(session);
1812
+ remember(row.sessionId, row.info, row.updatedAt);
1813
+ if (row.title)
1814
+ store.setTitle(row.sessionId, row.title);
1815
+ }
1816
+ }
1802
1817
  const pageReads = new Map;
1803
1818
  let catalogScope;
1804
1819
  function readSessionPage(meta, cursor) {
@@ -1807,12 +1822,7 @@ function createAcpWorkspaceClient({
1807
1822
  if (inFlight)
1808
1823
  return inFlight;
1809
1824
  const read = connection.listSessions(meta, cursor).then((page) => {
1810
- for (const session of page.sessions) {
1811
- const row = rowOf(session);
1812
- remember(row.sessionId, row.info, row.updatedAt);
1813
- if (row.title)
1814
- store.setTitle(row.sessionId, row.title);
1815
- }
1825
+ rememberRows(page.sessions);
1816
1826
  return page;
1817
1827
  }).finally(() => pageReads.delete(key));
1818
1828
  pageReads.set(key, read);
@@ -1977,6 +1987,20 @@ function createAcpWorkspaceClient({
1977
1987
  catalogScope = agentId;
1978
1988
  },
1979
1989
  sessionCatalogScope: () => catalogScope,
1990
+ async searchSessions(query, agentId) {
1991
+ const { sessions } = await connection.searchSessions({
1992
+ query,
1993
+ ...agentId === undefined ? {} : { agentId }
1994
+ });
1995
+ rememberRows(sessions);
1996
+ const titles = new Map(sessions.map(({ sessionId, title }) => [sessionId, title ?? ""]));
1997
+ return store.rowsFor(sessions.map(({ sessionId }) => sessionId)).map(({ sessionId, agentId, updatedAt }) => ({
1998
+ sessionId,
1999
+ agentId,
2000
+ title: titles.get(sessionId) ?? "",
2001
+ updatedAt
2002
+ }));
2003
+ },
1980
2004
  subscribeSessionCatalog(listener) {
1981
2005
  catalogListeners.add(listener);
1982
2006
  return () => catalogListeners.delete(listener);
@@ -1,7 +1,7 @@
1
1
  import type { 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
- import type { HgwAgentUpdateRequest, HgwAgentUpdateResponseSchema, HgwHistoryCursor, HgwInitializeMetaSchema, HgwPromptMetaSchema, HgwSessionListMetaSchema, HgwSessionNewMetaSchema, HgwSessionUpdateRequestSchema, HgwSteerRequestSchema, HgwSteerResponseSchema } from "../protocol/acp.js";
4
+ import type { HgwAgentUpdateRequest, HgwAgentUpdateResponseSchema, HgwHistoryCursor, HgwInitializeMetaSchema, HgwPromptMetaSchema, HgwSessionListMetaSchema, HgwSessionNewMetaSchema, HgwSessionSearchMeta, HgwSessionUpdateRequestSchema, HgwSteerRequestSchema, HgwSteerResponseSchema } from "../protocol/acp.js";
5
5
  /**
6
6
  * The browser-side seam over one ACP v2 WebSocket connection to the gateway.
7
7
  * `connection.ts` implements it; the runtime, thread list, interactions, and
@@ -96,6 +96,13 @@ export interface AcpConnection {
96
96
  sessions: SessionInfo[];
97
97
  nextCursor?: string;
98
98
  }>;
99
+ /**
100
+ * The Sessions matching a query, at most one window of them, newest first
101
+ * where the runtime orders them. Operators only.
102
+ */
103
+ searchSessions(meta: HgwSessionSearchMeta): Promise<{
104
+ sessions: SessionInfo[];
105
+ }>;
99
106
  /**
100
107
  * Opens the Session while any listener subscribes. The connection joins it,
101
108
  * replaying it from the start the first time, rejoins it from its own
@@ -54,6 +54,11 @@ export type SessionMetadata = {
54
54
  /** External platform the Session came from; absent for AOS-native Sessions. */
55
55
  platform?: SessionPlatform;
56
56
  };
57
+ /** One Session a search matched, as its row cache now holds it. */
58
+ export type SessionSearchResult = Pick<SessionMetadata, "sessionId" | "agentId" | "updatedAt"> & {
59
+ /** The provider's title, or empty when it reports none. */
60
+ title: string;
61
+ };
57
62
  /** Which Session actions the selected runtime declares it performs. */
58
63
  export type SessionActionCapabilities = {
59
64
  rename: boolean;
@@ -40,6 +40,9 @@ export declare const HGW_METHODS: {
40
40
  readonly focus: "_hgw/session/focus";
41
41
  readonly part: "_hgw/session/part";
42
42
  };
43
+ readonly sessions: {
44
+ readonly search: "_hgw/sessions/search";
45
+ };
43
46
  readonly agents: {
44
47
  readonly list: "_hgw/agents/list";
45
48
  readonly update: "_hgw/agents/update";
@@ -131,6 +134,25 @@ export declare const HgwSessionNewMetaSchema: z.ZodObject<{
131
134
  export declare const HgwSessionListMetaSchema: z.ZodObject<{
132
135
  agentId: z.ZodOptional<z.ZodString>;
133
136
  }, z.core.$strict>;
137
+ /** `_hgw/sessions/search` request `_meta.hgw`. */
138
+ export declare const HgwSessionSearchMetaSchema: z.ZodObject<{
139
+ agentId: z.ZodOptional<z.ZodString>;
140
+ query: z.ZodString;
141
+ }, z.core.$strict>;
142
+ export type HgwSessionSearchMeta = z.infer<typeof HgwSessionSearchMetaSchema>;
143
+ /**
144
+ * The `_hgw/sessions/search` response: matching Sessions as `session/list`
145
+ * entries, which ACP's own schema validates for `session/list` alone.
146
+ */
147
+ export declare const HgwSessionSearchResponseSchema: z.ZodObject<{
148
+ sessions: z.ZodArray<z.ZodObject<{
149
+ sessionId: z.ZodString;
150
+ cwd: z.ZodString;
151
+ title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
152
+ updatedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
153
+ _meta: z.ZodOptional<z.ZodNullable<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
154
+ }, z.core.$strip>>;
155
+ }, z.core.$strip>;
134
156
  /**
135
157
  * `SessionInfo._meta.hgw` on `session/list` entries and
136
158
  * `session_info_update._meta.hgw`. `unread`, `pinned`, and `createdAt` are
@@ -72,6 +72,8 @@ import {
72
72
  HgwLoginMetaSchema2,
73
73
  HgwSessionNewMetaSchema2,
74
74
  HgwSessionListMetaSchema2,
75
+ HgwSessionSearchMetaSchema2,
76
+ HgwSessionSearchResponseSchema2,
75
77
  HgwSessionInfoMetaSchema2,
76
78
  HgwSessionResumeMetaSchema2,
77
79
  HGW_REPLAY_BEFORE2,
@@ -251,6 +253,8 @@ export {
251
253
  HgwSessionPartRequestSchema2 as HgwSessionPartRequestSchema,
252
254
  HgwSessionResumeMetaSchema2 as HgwSessionResumeMetaSchema,
253
255
  HgwSessionResumeResponseMetaSchema2 as HgwSessionResumeResponseMetaSchema,
256
+ HgwSessionSearchMetaSchema2 as HgwSessionSearchMetaSchema,
257
+ HgwSessionSearchResponseSchema2 as HgwSessionSearchResponseSchema,
254
258
  HgwSessionUpdateRequestSchema2 as HgwSessionUpdateRequestSchema,
255
259
  HgwStateMetaSchema2 as HgwStateMetaSchema,
256
260
  HgwSteerRequestSchema2 as HgwSteerRequestSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@harness-gw/sdk",
3
- "version": "0.1.3",
3
+ "version": "0.2.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",