@finalai/agents 0.12.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +1 -1
  2. package/dist/modules/agent-client/channels.d.mts +91 -28
  3. package/dist/modules/agent-client/channels.mjs +176 -46
  4. package/dist/modules/agent-client/channels.mjs.map +2 -2
  5. package/dist/modules/agent-client/client.d.mts +19 -4
  6. package/dist/modules/agent-client/client.mjs +16 -5
  7. package/dist/modules/agent-client/client.mjs.map +2 -2
  8. package/dist/modules/agent-client/conversation-resources.d.mts +18 -1
  9. package/dist/modules/agent-client/conversation-resources.mjs +28 -0
  10. package/dist/modules/agent-client/conversation-resources.mjs.map +2 -2
  11. package/dist/modules/agent-client/conversations.d.mts +21 -25
  12. package/dist/modules/agent-client/conversations.mjs +17 -62
  13. package/dist/modules/agent-client/conversations.mjs.map +2 -2
  14. package/dist/modules/agent-client/index.d.mts +5 -3
  15. package/dist/modules/agent-client/index.mjs.map +2 -2
  16. package/dist/modules/agent-client/integrations.d.mts +5 -1
  17. package/dist/modules/agent-client/integrations.mjs +9 -1
  18. package/dist/modules/agent-client/integrations.mjs.map +2 -2
  19. package/dist/modules/agent-client/organization.d.mts +83 -0
  20. package/dist/modules/agent-client/organization.mjs +209 -0
  21. package/dist/modules/agent-client/organization.mjs.map +7 -0
  22. package/dist/modules/agent-client/participant-configuration.d.mts +21 -0
  23. package/dist/modules/agent-client/participant-configuration.mjs +38 -0
  24. package/dist/modules/agent-client/participant-configuration.mjs.map +7 -0
  25. package/dist/modules/agent-client/project.d.mts +10 -2
  26. package/dist/modules/agent-client/project.mjs +8 -6
  27. package/dist/modules/agent-client/project.mjs.map +2 -2
  28. package/dist/modules/agent-client/provide.d.mts +0 -1
  29. package/dist/modules/agent-client/provide.mjs +0 -1
  30. package/dist/modules/agent-client/provide.mjs.map +2 -2
  31. package/dist/modules/agent-client/sandboxes.d.mts +7 -0
  32. package/dist/modules/agent-client/sandboxes.mjs +9 -1
  33. package/dist/modules/agent-client/sandboxes.mjs.map +2 -2
  34. package/dist/modules/agent-client/schedules.d.mts +7 -22
  35. package/dist/modules/agent-client/schedules.mjs +8 -47
  36. package/dist/modules/agent-client/schedules.mjs.map +2 -2
  37. package/dist/modules/agent-client/sessions.d.mts +8 -1
  38. package/dist/modules/agent-client/sessions.mjs +24 -5
  39. package/dist/modules/agent-client/sessions.mjs.map +2 -2
  40. package/dist/modules/public.d.mts +1 -1
  41. package/dist/modules/public.mjs.map +2 -2
  42. package/examples/release-scout/run-on-a-computer.ts +1 -1
  43. package/package.json +5 -10
  44. package/dist/modules/authoring/final-channel.d.mts +0 -1
  45. package/dist/modules/authoring/final-channel.mjs +0 -2
  46. package/dist/modules/authoring/final-channel.mjs.map +0 -7
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  agentListSchema,
3
3
  agentRealtimeTopics,
4
+ agentSummarySchema,
4
5
  decisionResponseSchema,
5
6
  healthResponseSchema,
6
7
  inferenceOfferingSchema,
@@ -11,7 +12,9 @@ import {
11
12
  } from "@finalai/agent-protocol/agent-platform";
12
13
  import { createAcpApi } from "./acp.mjs";
13
14
  import {
14
- createChannelBindingsApi
15
+ createChannelBindingsApi,
16
+ createChannelTicketsApi,
17
+ createIdentityLinksApi
15
18
  } from "./channels.mjs";
16
19
  import { encodePath } from "./context.mjs";
17
20
  import { createConversationsApi } from "./conversations.mjs";
@@ -36,8 +39,8 @@ import {
36
39
  } from "./realtime.mjs";
37
40
  import { createProjectClient } from "./project.mjs";
38
41
  import { createProjectsApi } from "./projects.mjs";
42
+ import { createOrganizationApi } from "./organization.mjs";
39
43
  import { createPublishersApi } from "./publishers.mjs";
40
- import { createSchedulesApi } from "./schedules.mjs";
41
44
  import { createSessionsApi } from "./sessions.mjs";
42
45
  const DEFAULT_AGENTS_HOST = "https://agent-session.final.ai";
43
46
  const createClient = (options) => {
@@ -147,9 +150,15 @@ const createClient = (options) => {
147
150
  },
148
151
  response: agentListSchema,
149
152
  signal: listOptions?.signal
153
+ }),
154
+ get: ({ id, signal }) => http.request({
155
+ method: HttpMethod.Get,
156
+ path: `/v1/agents/${encodePath(id)}`,
157
+ response: agentSummarySchema,
158
+ signal
150
159
  })
151
160
  },
152
- people: /* @__PURE__ */ (() => {
161
+ people: (() => {
153
162
  const list = (listOptions) => http.request({
154
163
  method: HttpMethod.Get,
155
164
  path: "/v1/people",
@@ -168,13 +177,15 @@ const createClient = (options) => {
168
177
  if (next.nextCursor == null) return all;
169
178
  cursor = next.nextCursor;
170
179
  }
171
- }
180
+ },
181
+ me: { identityLinks: createIdentityLinksApi(context) }
172
182
  };
173
183
  })(),
174
184
  realtime: { createSession: createRealtimeSession },
175
185
  project: ({ id }) => createProjectClient({ context, start, channelSourceOf, projectId: id }),
176
186
  projects: createProjectsApi(context),
177
187
  events: createEventsApi({ context, projectId: null }),
188
+ organization: createOrganizationApi(context),
178
189
  app: {
179
190
  eventSubscriptions: createEventSubscriptionsApi({
180
191
  context,
@@ -211,7 +222,7 @@ const createClient = (options) => {
211
222
  sessions: createSessionsApi(context),
212
223
  conversations: createConversationsApi(context, clientLevel),
213
224
  channelBindings: createChannelBindingsApi(context),
214
- schedules: createSchedulesApi(context),
225
+ channelTickets: createChannelTicketsApi(context),
215
226
  acp: createAcpApi({ http })
216
227
  };
217
228
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/agent-client/client.ts"],
4
- "sourcesContent": ["import {\n agentListSchema,\n agentRealtimeTopics,\n decisionResponseSchema,\n healthResponseSchema,\n inferenceOfferingSchema,\n personListSchema,\n platformIdentityExchangeRequestSchema,\n platformIdentityExchangeResponseSchema,\n realtimeSessionResponseSchema,\n type AgentListIface,\n type DecisionIface,\n type HealthResponseIface,\n type InferenceOfferingIface,\n type PersonIface,\n type PersonListIface,\n type PlatformIdentityExchangeRequestIface,\n type PlatformIdentityExchangeResponseIface,\n type RealtimeSessionResponseIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { createAcpApi, type AcpApiIface } from \"./acp.mjs\";\nimport type { AgentValueCodecIface } from \"./agent-input.mjs\";\nimport {\n createChannelBindingsApi,\n type ChannelBindingsApiIface,\n type ChannelSourceOf,\n} from \"./channels.mjs\";\nimport { encodePath, type ClientContextIface, type SignalOptionsIface } from \"./context.mjs\";\nimport { createConversationsApi, type ConversationsApiIface } from \"./conversations.mjs\";\nimport {\n defaultAgentCodec,\n defaultChannelSourceOf,\n defaultLocalCompute,\n defaultLocalHostDial,\n} from \"./defaults.mjs\";\nimport { clientError, ClientErrorCode } from \"./errors.mjs\";\nimport {\n createEventsApi,\n createEventSubscriptionsApi,\n type EventsApiIface,\n type EventSubscriptionsApiIface,\n} from \"./events.mjs\";\nimport { defaultStreamTiming, type StreamTimingIface } from \"./frame-stream.mjs\";\nimport {\n createHttp,\n HttpMethod,\n type AgentClientAuth,\n type FetchIface,\n type HeadersOption,\n} from \"./http.mjs\";\nimport {\n createGatewayRealtimeTransport,\n type GatewayConnect,\n type GatewayRealtimeTransportIface,\n type RealtimeTransportIface,\n} from \"./realtime.mjs\";\nimport type { LocalComputeIface, LocalHostIface, LocalHostSocketIface } from \"./local-host.mjs\";\nimport { createProjectClient, type ProjectClientIface } from \"./project.mjs\";\nimport { createProjectsApi, type ProjectsApiIface } from \"./projects.mjs\";\nimport { createPublishersApi, type PublishersApiIface } from \"./publishers.mjs\";\nimport { createSchedulesApi, type SchedulesApiIface } from \"./schedules.mjs\";\nimport { createSessionsApi, type SessionsApiIface } from \"./sessions.mjs\";\nimport type { AgentStartDepsIface } from \"./start.mjs\";\n\n/** Final's agents API. */\nexport const DEFAULT_AGENTS_HOST = 'https://agent-session.final.ai';\n\nexport interface CreateClientOptionsIface {\n auth: AgentClientAuth;\n /**\n * Whether this process provides the files and shell an agent requires when\n * the caller leaves them out (default true), so the model's file edits and\n * commands run here, on this machine. A server should provide every\n * capability explicitly and pass false, so an omission fails with\n * `requirements_unmet` instead of giving the model a shell in the server.\n */\n localCompute?: boolean;\n /**\n * The agents API origin (default `https://agent-session.final.ai`; its API is\n * under `/api` and ACP at `/acp/ws`), or a base URL the API routes are mounted under.\n */\n host?: string;\n /** Extra headers per request; console clients send their client identity header here. */\n headers?: HeadersOption;\n /** API requests (the host's routes); carries auth and caller headers. */\n fetch?: FetchIface;\n /**\n * Presigned storage requests (attachment uploads). Gets only the headers the\n * presign requires, never auth, client identity or cookies, so a storage\n * bucket's CORS and third-party hosts see nothing of the caller. Defaults to\n * `globalThis.fetch`; keep it free of header-injecting wrappers.\n */\n storageFetch?: FetchIface;\n /** console-web and console-mobile pass their realtime clients; defaults to a gateway connection. */\n realtime?: RealtimeTransportIface;\n /** Seam for the default transport's gateway connection. */\n gatewayConnect?: GatewayConnect;\n /** Seam for stream retry timing (tests). */\n timing?: Partial<StreamTimingIface>;\n /** Seam for idempotency keys and client message ids; defaults to `crypto.randomUUID`. */\n newKey?: () => string;\n /** Seam for the client clock (conversation recovery windows). */\n now?: () => number;\n /** Seam: how agent values become documents and in-process code. */\n agentCodec?: AgentValueCodecIface;\n /** Seam: how a channel value becomes its source. */\n channelSourceOf?: ChannelSourceOf;\n /** Seams for local hosts: the socket, and the sandbox this process serves. */\n localHosts?: {\n /** Opens the local host socket; abandons it when `signal` aborts. */\n dial?: (path: string, signal?: AbortSignal) => Promise<LocalHostSocketIface>;\n compute?: Partial<LocalComputeIface>;\n };\n}\n\nexport interface AgentsApiIface {\n /**\n * The agents the caller can use; with `projectId`, those usable there (its own and those\n * inherited from its ancestors). Without it, everything the caller can access (an API key: its\n * parent project and every project it is granted; a person: every project they can read).\n * Fetch one as data with `client.project({ id }).agents.get`.\n */\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number; projectId?: string },\n ) => Promise<AgentListIface>;\n}\n\nexport interface PeopleApiIface {\n /** One page of the caller's organization members, by name; pass `nextCursor` as `cursor` for the next. */\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number },\n ) => Promise<PersonListIface>;\n /** Every member of the caller's organization (all pages). */\n all: (options?: SignalOptionsIface) => Promise<PersonIface[]>;\n}\n\nexport interface RealtimeApiIface {\n /**\n * Mints a gateway session (`POST /v1/realtime/session`) for the signed-in user:\n * the gateway URL, a short-lived token, and the user id realtime topics are keyed by.\n * Pass it as `createSession` to `createGatewayRealtimeTransport` when supplying a transport.\n */\n createSession: (options?: SignalOptionsIface) => Promise<RealtimeSessionResponseIface>;\n}\n\nexport interface InferenceApiIface {\n /**\n * The vendors and models the platform's own metered inference serves, with\n * prices (`GET /v1/inference/offering`, public). A harness using the\n * platform's inference can run only models listed here.\n */\n offering: (options?: SignalOptionsIface) => Promise<InferenceOfferingIface>;\n}\n\nexport interface PlatformIdentityApiIface {\n /**\n * Exchanges a sandbox-provider (or downstream) assertion the platform issued\n * for a fresh one: for the provider's own URL (a refresh) or a backend its\n * registration was granted. The subject token is the credential.\n */\n exchange: (\n args: PlatformIdentityExchangeRequestIface & SignalOptionsIface,\n ) => Promise<PlatformIdentityExchangeResponseIface>;\n}\n\nexport interface DecisionsApiIface {\n /** One decision awaiting the caller's answer, as `conversations.decisions` lists it. */\n get: (args: { id: string } & SignalOptionsIface) => Promise<DecisionIface>;\n}\n\nexport interface AppApiIface {\n /**\n * The calling app's event subscriptions, across every organization that\n * installed it. Needs an app-level token.\n */\n eventSubscriptions: EventSubscriptionsApiIface;\n}\n\nexport interface AgentClientIface {\n /** One project: where sessions, conversations, sandboxes and integrations are created. */\n project: (args: { id: string }) => ProjectClientIface;\n /** The project tree: list projects and create them. */\n projects: ProjectsApiIface;\n /** The event feed across everything the caller can see; `project({ id }).events` narrows it. */\n events: EventsApiIface;\n app: AppApiIface;\n /** Publishers' public agents, channels, harnesses and ACP adapters. */\n publishers: PublishersApiIface;\n inference: InferenceApiIface;\n platformIdentity: PlatformIdentityApiIface;\n decisions: DecisionsApiIface;\n health: (options?: SignalOptionsIface) => Promise<HealthResponseIface>;\n agents: AgentsApiIface;\n people: PeopleApiIface;\n realtime: RealtimeApiIface;\n /** Existing sessions by id; create them through `project({ id }).sessions`. */\n sessions: SessionsApiIface;\n /** The caller's conversations; create them through `project({ id }).conversations`. */\n conversations: ConversationsApiIface;\n channelBindings: ChannelBindingsApiIface;\n schedules: SchedulesApiIface;\n /**\n * ACP-native access (`/acp/ws`): an ACP v2 ClientApp connection on which the\n * agents API is the agent. The ACP SDK loads on the first `connect`.\n */\n acp: AcpApiIface;\n /**\n * Ends every stream (they reject with a `client_closed` ClientError) and every\n * local host connection (the platform then reports this process's tools and\n * compute as unavailable; sessions carry on) and, when the client created its\n * own realtime transport, closes the gateway connection and cancels its\n * retries. A transport passed in `realtime` belongs to the caller and is left\n * open. Idempotent.\n */\n close: () => void;\n [Symbol.asyncDispose]: () => Promise<void>;\n}\n\nexport const createClient = (options: CreateClientOptionsIface): AgentClientIface => {\n const http = createHttp({\n host: options.host ?? DEFAULT_AGENTS_HOST,\n auth: options.auth,\n headers: options.headers,\n fetch: options.fetch,\n });\n let realtime = options.realtime ?? null;\n let ownTransport: GatewayRealtimeTransportIface | null = null;\n const closing = new AbortController();\n const createRealtimeSession: RealtimeApiIface['createSession'] = (sessionOptions) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/realtime/session',\n response: realtimeSessionResponseSchema,\n signal: sessionOptions?.signal,\n });\n let realtimeOwner: Promise<RealtimeSessionResponseIface> | null = null;\n const realtimeOwnerSession = () => {\n if (realtimeOwner != null) return realtimeOwner;\n const pending = createRealtimeSession({ signal: closing.signal });\n realtimeOwner = pending;\n void pending.catch(() => {\n if (realtimeOwner === pending) realtimeOwner = null;\n });\n return pending;\n };\n let realtimeUser: Promise<string> | null = null;\n // Shared by every stream, so it is cancelled only with the client, never by one caller.\n const realtimeUserId: ClientContextIface['realtimeUserId'] = () => {\n if (realtimeUser != null) return realtimeUser;\n const pending = realtimeOwnerSession().then((session) => {\n if (session.userId == null)\n throw new Error('This client authenticates as an API-key owner, not a user');\n return session.userId;\n });\n realtimeUser = pending;\n // A failed (or aborted) read is not cached.\n pending.catch(() => {\n if (realtimeUser === pending) realtimeUser = null;\n });\n return pending;\n };\n const context: ClientContextIface = {\n http,\n closeSignal: closing.signal,\n realtimeUserId,\n // Conversations is the only collection.\n realtimeCollectionTopic: async () => {\n const owner = await realtimeOwnerSession();\n // API keys act in their project, not as members: they reach agents through channels.\n if (owner.userId == null)\n throw new Error('Collection streams belong to users; API-key owners use session streams');\n return agentRealtimeTopics.userConversations(owner.userId);\n },\n storageFetch: options.storageFetch ?? ((input, init) => globalThis.fetch(input, init)),\n realtime: () => {\n if (realtime != null) return realtime;\n ownTransport = createGatewayRealtimeTransport({\n createSession: () => createRealtimeSession(),\n connect: options.gatewayConnect,\n });\n if (closing.signal.aborted) ownTransport.close();\n realtime = ownTransport;\n return realtime;\n },\n timing: { ...defaultStreamTiming, ...options.timing },\n newKey: options.newKey ?? (() => globalThis.crypto.randomUUID()),\n now: options.now ?? Date.now,\n };\n\n const hosts = new Set<LocalHostIface>();\n const localCompute = defaultLocalCompute();\n const start: AgentStartDepsIface = {\n context,\n codec: options.agentCodec ?? defaultAgentCodec,\n localCompute: options.localCompute ?? true,\n compute: { ...localCompute, ...options.localHosts?.compute },\n dial: options.localHosts?.dial ?? defaultLocalHostDial(http),\n hosts,\n };\n const channelSourceOf = options.channelSourceOf ?? defaultChannelSourceOf;\n const clientLevel = { deps: start, projectId: null };\n\n const close = (): void => {\n if (closing.signal.aborted) return;\n closing.abort(\n clientError({ message: 'Agent client closed', status: 0, code: ClientErrorCode.Closed }),\n );\n for (const host of hosts) host.close();\n hosts.clear();\n ownTransport?.close();\n };\n\n return {\n close,\n [Symbol.asyncDispose]: async () => close(),\n health: (healthOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/health',\n response: healthResponseSchema,\n signal: healthOptions?.signal,\n }),\n agents: {\n list: (listOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/agents',\n query: {\n cursor: listOptions?.cursor,\n limit: listOptions?.limit,\n projectId: listOptions?.projectId,\n },\n response: agentListSchema,\n signal: listOptions?.signal,\n }),\n },\n people: (() => {\n const list: PeopleApiIface['list'] = (listOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/people',\n query: { cursor: listOptions?.cursor, limit: listOptions?.limit },\n response: personListSchema,\n signal: listOptions?.signal,\n });\n return {\n list,\n all: async (allOptions) => {\n const all: PersonIface[] = [];\n let cursor: string | undefined;\n for (;;) {\n const next = await list({ cursor, signal: allOptions?.signal });\n all.push(...next.people);\n if (next.nextCursor == null) return all;\n cursor = next.nextCursor;\n }\n },\n };\n })(),\n realtime: { createSession: createRealtimeSession },\n project: ({ id }) => createProjectClient({ context, start, channelSourceOf, projectId: id }),\n projects: createProjectsApi(context),\n events: createEventsApi({ context, projectId: null }),\n app: {\n eventSubscriptions: createEventSubscriptionsApi({\n context,\n basePath: '/v1/apps/me/event-subscriptions',\n }),\n },\n publishers: createPublishersApi(context),\n inference: {\n offering: (offeringOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/inference/offering',\n response: inferenceOfferingSchema,\n signal: offeringOptions?.signal,\n }),\n },\n platformIdentity: {\n exchange: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/platform-identity/exchange',\n body: { schema: platformIdentityExchangeRequestSchema, value },\n response: platformIdentityExchangeResponseSchema,\n signal,\n }),\n },\n decisions: {\n get: async ({ id, signal }) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: `/v1/decisions/${encodePath(id)}`,\n response: decisionResponseSchema,\n signal,\n context: { decisionId: id },\n })\n ).decision,\n },\n sessions: createSessionsApi(context),\n conversations: createConversationsApi(context, clientLevel),\n channelBindings: createChannelBindingsApi(context),\n schedules: createSchedulesApi(context),\n acp: createAcpApi({ http }),\n };\n};\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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A,IAC1D,iBAAiB,yBAAyB,OAAO;AAAA,IACjD,WAAW,mBAAmB,OAAO;AAAA,IACrC,KAAK,aAAa,EAAE,KAAK,CAAC;AAAA,EAC5B;AACF;",
4
+ "sourcesContent": ["import {\n agentListSchema,\n agentRealtimeTopics,\n agentSummarySchema,\n decisionResponseSchema,\n healthResponseSchema,\n inferenceOfferingSchema,\n personListSchema,\n platformIdentityExchangeRequestSchema,\n platformIdentityExchangeResponseSchema,\n realtimeSessionResponseSchema,\n type AgentListIface,\n type AgentSummaryIface,\n type DecisionIface,\n type HealthResponseIface,\n type InferenceOfferingIface,\n type PersonIface,\n type PersonListIface,\n type PlatformIdentityExchangeRequestIface,\n type PlatformIdentityExchangeResponseIface,\n type RealtimeSessionResponseIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport { createAcpApi, type AcpApiIface } from \"./acp.mjs\";\nimport type { AgentValueCodecIface } from \"./agent-input.mjs\";\nimport {\n createChannelBindingsApi,\n createChannelTicketsApi,\n createIdentityLinksApi,\n type ChannelBindingsApiIface,\n type ChannelSourceOf,\n type ChannelTicketsApiIface,\n type IdentityLinksApiIface,\n} from \"./channels.mjs\";\nimport { encodePath, type ClientContextIface, type SignalOptionsIface } from \"./context.mjs\";\nimport { createConversationsApi, type ConversationsApiIface } from \"./conversations.mjs\";\nimport {\n defaultAgentCodec,\n defaultChannelSourceOf,\n defaultLocalCompute,\n defaultLocalHostDial,\n} from \"./defaults.mjs\";\nimport { clientError, ClientErrorCode } from \"./errors.mjs\";\nimport {\n createEventsApi,\n createEventSubscriptionsApi,\n type EventsApiIface,\n type EventSubscriptionsApiIface,\n} from \"./events.mjs\";\nimport { defaultStreamTiming, type StreamTimingIface } from \"./frame-stream.mjs\";\nimport {\n createHttp,\n HttpMethod,\n type AgentClientAuth,\n type FetchIface,\n type HeadersOption,\n} from \"./http.mjs\";\nimport {\n createGatewayRealtimeTransport,\n type GatewayConnect,\n type GatewayRealtimeTransportIface,\n type RealtimeTransportIface,\n} from \"./realtime.mjs\";\nimport type { LocalComputeIface, LocalHostIface, LocalHostSocketIface } from \"./local-host.mjs\";\nimport { createProjectClient, type ProjectClientIface } from \"./project.mjs\";\nimport { createProjectsApi, type ProjectsApiIface } from \"./projects.mjs\";\nimport { createOrganizationApi, type OrganizationApiIface } from \"./organization.mjs\";\nimport { createPublishersApi, type PublishersApiIface } from \"./publishers.mjs\";\nimport { createSessionsApi, type SessionsApiIface } from \"./sessions.mjs\";\nimport type { AgentStartDepsIface } from \"./start.mjs\";\n\n/** Final's agents API. */\nexport const DEFAULT_AGENTS_HOST = 'https://agent-session.final.ai';\n\nexport interface CreateClientOptionsIface {\n auth: AgentClientAuth;\n /**\n * Whether this process provides the files and shell an agent requires when\n * the caller leaves them out (default true), so the model's file edits and\n * commands run here, on this machine. A server should provide every\n * capability explicitly and pass false, so an omission fails with\n * `requirements_unmet` instead of giving the model a shell in the server.\n */\n localCompute?: boolean;\n /**\n * The agents API origin (default `https://agent-session.final.ai`; its API is\n * under `/api` and ACP at `/acp/ws`), or a base URL the API routes are mounted under.\n */\n host?: string;\n /** Extra headers per request; console clients send their client identity header here. */\n headers?: HeadersOption;\n /** API requests (the host's routes); carries auth and caller headers. */\n fetch?: FetchIface;\n /**\n * Presigned storage requests (attachment uploads). Gets only the headers the\n * presign requires, never auth, client identity or cookies, so a storage\n * bucket's CORS and third-party hosts see nothing of the caller. Defaults to\n * `globalThis.fetch`; keep it free of header-injecting wrappers.\n */\n storageFetch?: FetchIface;\n /** console-web and console-mobile pass their realtime clients; defaults to a gateway connection. */\n realtime?: RealtimeTransportIface;\n /** Seam for the default transport's gateway connection. */\n gatewayConnect?: GatewayConnect;\n /** Seam for stream retry timing (tests). */\n timing?: Partial<StreamTimingIface>;\n /** Seam for idempotency keys and client message ids; defaults to `crypto.randomUUID`. */\n newKey?: () => string;\n /** Seam for the client clock (conversation recovery windows). */\n now?: () => number;\n /** Seam: how agent values become documents and in-process code. */\n agentCodec?: AgentValueCodecIface;\n /** Seam: how a channel value becomes its source. */\n channelSourceOf?: ChannelSourceOf;\n /** Seams for local hosts: the socket, and the sandbox this process serves. */\n localHosts?: {\n /** Opens the local host socket; abandons it when `signal` aborts. */\n dial?: (path: string, signal?: AbortSignal) => Promise<LocalHostSocketIface>;\n compute?: Partial<LocalComputeIface>;\n };\n}\n\nexport interface AgentsApiIface {\n /**\n * The agents the caller can use; with `projectId`, those usable there (its own and those\n * inherited from its ancestors). Without it, everything the caller can access (an API key: its\n * parent project and every project it is granted; a person: every project they can read).\n * Fetch one as data with `client.project({ id }).agents.get`.\n */\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number; projectId?: string },\n ) => Promise<AgentListIface>;\n /**\n * One agent the caller can use, by id, in whichever project owns it; also one that was never\n * published (`hash` and `revisionId` are null). Archived agents are not found.\n */\n get: (args: { id: string } & SignalOptionsIface) => Promise<AgentSummaryIface>;\n}\n\nexport interface PeopleApiIface {\n /** One page of the caller's organization members, by name; pass `nextCursor` as `cursor` for the next. */\n list: (\n options?: SignalOptionsIface & { cursor?: string; limit?: number },\n ) => Promise<PersonListIface>;\n /** Every member of the caller's organization (all pages). */\n all: (options?: SignalOptionsIface) => Promise<PersonIface[]>;\n /** The caller's own person (or, for an API key or app, the actor it names). */\n me: { identityLinks: IdentityLinksApiIface };\n}\n\nexport interface RealtimeApiIface {\n /**\n * Mints a gateway session (`POST /v1/realtime/session`) for the signed-in user:\n * the gateway URL, a short-lived token, and the user id realtime topics are keyed by.\n * Pass it as `createSession` to `createGatewayRealtimeTransport` when supplying a transport.\n */\n createSession: (options?: SignalOptionsIface) => Promise<RealtimeSessionResponseIface>;\n}\n\nexport interface InferenceApiIface {\n /**\n * The vendors and models the platform's own metered inference serves, with\n * prices (`GET /v1/inference/offering`, public). A harness using the\n * platform's inference can run only models listed here.\n */\n offering: (options?: SignalOptionsIface) => Promise<InferenceOfferingIface>;\n}\n\nexport interface PlatformIdentityApiIface {\n /**\n * Exchanges a sandbox-provider (or downstream) assertion the platform issued\n * for a fresh one: for the provider's own URL (a refresh) or a backend its\n * registration was granted. The subject token is the credential.\n */\n exchange: (\n args: PlatformIdentityExchangeRequestIface & SignalOptionsIface,\n ) => Promise<PlatformIdentityExchangeResponseIface>;\n}\n\nexport interface DecisionsApiIface {\n /** One decision awaiting the caller's answer, as `conversations.decisions` lists it. */\n get: (args: { id: string } & SignalOptionsIface) => Promise<DecisionIface>;\n}\n\nexport interface AppApiIface {\n /**\n * The calling app's event subscriptions, across every organization that\n * installed it. Needs an app-level token.\n */\n eventSubscriptions: EventSubscriptionsApiIface;\n}\n\nexport interface AgentClientIface {\n /** One project: where sessions, conversations, sandboxes and integrations are created. */\n project: (args: { id: string }) => ProjectClientIface;\n /** The project tree: list projects and create them. */\n projects: ProjectsApiIface;\n /** The event feed across everything the caller can see; `project({ id }).events` narrows it. */\n events: EventsApiIface;\n app: AppApiIface;\n /** Publishers' public agents, channels, harnesses and ACP adapters. */\n publishers: PublishersApiIface;\n inference: InferenceApiIface;\n platformIdentity: PlatformIdentityApiIface;\n decisions: DecisionsApiIface;\n health: (options?: SignalOptionsIface) => Promise<HealthResponseIface>;\n /** The caller's organization: model credentials, budgets and policies. */\n organization: OrganizationApiIface;\n agents: AgentsApiIface;\n people: PeopleApiIface;\n realtime: RealtimeApiIface;\n /** Existing sessions by id; create them through `project({ id }).sessions`. */\n sessions: SessionsApiIface;\n /** The caller's conversations; create them through `project({ id }).conversations`. */\n conversations: ConversationsApiIface;\n /** Channel installs by id; install them through `project({ id }).channels`. */\n channelBindings: ChannelBindingsApiIface;\n /** Tickets from an installer's link and connect pages. */\n channelTickets: ChannelTicketsApiIface;\n /**\n * ACP-native access (`/acp/ws`): an ACP v2 ClientApp connection on which the\n * agents API is the agent. The ACP SDK loads on the first `connect`.\n */\n acp: AcpApiIface;\n /**\n * Ends every stream (they reject with a `client_closed` ClientError) and every\n * local host connection (the platform then reports this process's tools and\n * compute as unavailable; sessions carry on) and, when the client created its\n * own realtime transport, closes the gateway connection and cancels its\n * retries. A transport passed in `realtime` belongs to the caller and is left\n * open. Idempotent.\n */\n close: () => void;\n [Symbol.asyncDispose]: () => Promise<void>;\n}\n\nexport const createClient = (options: CreateClientOptionsIface): AgentClientIface => {\n const http = createHttp({\n host: options.host ?? DEFAULT_AGENTS_HOST,\n auth: options.auth,\n headers: options.headers,\n fetch: options.fetch,\n });\n let realtime = options.realtime ?? null;\n let ownTransport: GatewayRealtimeTransportIface | null = null;\n const closing = new AbortController();\n const createRealtimeSession: RealtimeApiIface['createSession'] = (sessionOptions) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/realtime/session',\n response: realtimeSessionResponseSchema,\n signal: sessionOptions?.signal,\n });\n let realtimeOwner: Promise<RealtimeSessionResponseIface> | null = null;\n const realtimeOwnerSession = () => {\n if (realtimeOwner != null) return realtimeOwner;\n const pending = createRealtimeSession({ signal: closing.signal });\n realtimeOwner = pending;\n void pending.catch(() => {\n if (realtimeOwner === pending) realtimeOwner = null;\n });\n return pending;\n };\n let realtimeUser: Promise<string> | null = null;\n // Shared by every stream, so it is cancelled only with the client, never by one caller.\n const realtimeUserId: ClientContextIface['realtimeUserId'] = () => {\n if (realtimeUser != null) return realtimeUser;\n const pending = realtimeOwnerSession().then((session) => {\n if (session.userId == null)\n throw new Error('This client authenticates as an API-key owner, not a user');\n return session.userId;\n });\n realtimeUser = pending;\n // A failed (or aborted) read is not cached.\n pending.catch(() => {\n if (realtimeUser === pending) realtimeUser = null;\n });\n return pending;\n };\n const context: ClientContextIface = {\n http,\n closeSignal: closing.signal,\n realtimeUserId,\n // Conversations is the only collection.\n realtimeCollectionTopic: async () => {\n const owner = await realtimeOwnerSession();\n // API keys act in their project, not as members: they reach agents through channels.\n if (owner.userId == null)\n throw new Error('Collection streams belong to users; API-key owners use session streams');\n return agentRealtimeTopics.userConversations(owner.userId);\n },\n storageFetch: options.storageFetch ?? ((input, init) => globalThis.fetch(input, init)),\n realtime: () => {\n if (realtime != null) return realtime;\n ownTransport = createGatewayRealtimeTransport({\n createSession: () => createRealtimeSession(),\n connect: options.gatewayConnect,\n });\n if (closing.signal.aborted) ownTransport.close();\n realtime = ownTransport;\n return realtime;\n },\n timing: { ...defaultStreamTiming, ...options.timing },\n newKey: options.newKey ?? (() => globalThis.crypto.randomUUID()),\n now: options.now ?? Date.now,\n };\n\n const hosts = new Set<LocalHostIface>();\n const localCompute = defaultLocalCompute();\n const start: AgentStartDepsIface = {\n context,\n codec: options.agentCodec ?? defaultAgentCodec,\n localCompute: options.localCompute ?? true,\n compute: { ...localCompute, ...options.localHosts?.compute },\n dial: options.localHosts?.dial ?? defaultLocalHostDial(http),\n hosts,\n };\n const channelSourceOf = options.channelSourceOf ?? defaultChannelSourceOf;\n const clientLevel = { deps: start, projectId: null };\n\n const close = (): void => {\n if (closing.signal.aborted) return;\n closing.abort(\n clientError({ message: 'Agent client closed', status: 0, code: ClientErrorCode.Closed }),\n );\n for (const host of hosts) host.close();\n hosts.clear();\n ownTransport?.close();\n };\n\n return {\n close,\n [Symbol.asyncDispose]: async () => close(),\n health: (healthOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/health',\n response: healthResponseSchema,\n signal: healthOptions?.signal,\n }),\n agents: {\n list: (listOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/agents',\n query: {\n cursor: listOptions?.cursor,\n limit: listOptions?.limit,\n projectId: listOptions?.projectId,\n },\n response: agentListSchema,\n signal: listOptions?.signal,\n }),\n get: ({ id, signal }) =>\n http.request({\n method: HttpMethod.Get,\n path: `/v1/agents/${encodePath(id)}`,\n response: agentSummarySchema,\n signal,\n }),\n },\n people: (() => {\n const list: PeopleApiIface['list'] = (listOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/people',\n query: { cursor: listOptions?.cursor, limit: listOptions?.limit },\n response: personListSchema,\n signal: listOptions?.signal,\n });\n return {\n list,\n all: async (allOptions) => {\n const all: PersonIface[] = [];\n let cursor: string | undefined;\n for (;;) {\n const next = await list({ cursor, signal: allOptions?.signal });\n all.push(...next.people);\n if (next.nextCursor == null) return all;\n cursor = next.nextCursor;\n }\n },\n me: { identityLinks: createIdentityLinksApi(context) },\n };\n })(),\n realtime: { createSession: createRealtimeSession },\n project: ({ id }) => createProjectClient({ context, start, channelSourceOf, projectId: id }),\n projects: createProjectsApi(context),\n events: createEventsApi({ context, projectId: null }),\n organization: createOrganizationApi(context),\n app: {\n eventSubscriptions: createEventSubscriptionsApi({\n context,\n basePath: '/v1/apps/me/event-subscriptions',\n }),\n },\n publishers: createPublishersApi(context),\n inference: {\n offering: (offeringOptions) =>\n http.request({\n method: HttpMethod.Get,\n path: '/v1/inference/offering',\n response: inferenceOfferingSchema,\n signal: offeringOptions?.signal,\n }),\n },\n platformIdentity: {\n exchange: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: '/v1/platform-identity/exchange',\n body: { schema: platformIdentityExchangeRequestSchema, value },\n response: platformIdentityExchangeResponseSchema,\n signal,\n }),\n },\n decisions: {\n get: async ({ id, signal }) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: `/v1/decisions/${encodePath(id)}`,\n response: decisionResponseSchema,\n signal,\n context: { decisionId: id },\n })\n ).decision,\n },\n sessions: createSessionsApi(context),\n conversations: createConversationsApi(context, clientLevel),\n channelBindings: createChannelBindingsApi(context),\n channelTickets: createChannelTicketsApi(context),\n acp: createAcpApi({ http }),\n };\n};\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAWK;AACP,SAAS,oBAAsC;AAE/C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP,SAAS,kBAAoE;AAC7E,SAAS,8BAA0D;AACnE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,uBAAuB;AAC7C;AAAA,EACE;AAAA,EAC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O;AAAA,IACnC,eAAe,uBAAuB,SAAS,WAAW;AAAA,IAC1D,iBAAiB,yBAAyB,OAAO;AAAA,IACjD,gBAAgB,wBAAwB,OAAO;AAAA,IAC/C,KAAK,aAAa,EAAE,KAAK,CAAC;AAAA,EAC5B;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,4 +1,4 @@
1
- import { type ApiDecisionIface, type ConversationContextEntryIface, type ConversationContextRole, type ConversationReadGrantIface, type CreateConversationReadGrantRequestIface, type CreateResourceSubscriptionRequestIface, type InputReceiptIface, type PostConversationInputRequestIface, type RaiseConversationDecisionRequestIface, type ResourceSubscriptionIface } from '@finalai/agent-protocol/agent-platform';
1
+ import { type ApiDecisionIface, type ChannelRouteIface, type ChannelRoutesResponseIface, type ConnectChannelPlaceRequestIface, type ConversationContextEntryIface, type ConversationContextRole, type ConversationReadGrantIface, type CreateConversationReadGrantRequestIface, type CreateResourceSubscriptionRequestIface, type InputReceiptIface, type PostConversationInputRequestIface, type RaiseConversationDecisionRequestIface, type ResourceSubscriptionIface } from '@finalai/agent-protocol/agent-platform';
2
2
  import { type ClientContextIface, type EnumInput, type SignalOptionsIface } from "./context.mjs";
3
3
  export interface ConversationLabelsApiIface {
4
4
  /**
@@ -74,6 +74,22 @@ export interface ResourceSubscriptionsApiIface {
74
74
  resourceKey: string;
75
75
  } & SignalOptionsIface) => Promise<boolean>;
76
76
  }
77
+ export interface ConversationChannelRoutesApiIface {
78
+ /**
79
+ * The provider places connected to the conversation, whether the caller may
80
+ * change them, and the installs that reach it. An API key or app names the
81
+ * actor participant it acts for by external id.
82
+ */
83
+ list: (options?: SignalOptionsIface & {
84
+ actor?: string;
85
+ }) => Promise<ChannelRoutesResponseIface>;
86
+ /** Connects a place an install has seen; the conversation's managers do this. */
87
+ connect: (args: ConnectChannelPlaceRequestIface & SignalOptionsIface) => Promise<ChannelRouteIface>;
88
+ disconnect: (args: {
89
+ routeId: string;
90
+ actor?: string;
91
+ } & SignalOptionsIface) => Promise<void>;
92
+ }
77
93
  export interface ConversationResourcesIface {
78
94
  labels: ConversationLabelsApiIface;
79
95
  context: ConversationContextApiIface;
@@ -81,5 +97,6 @@ export interface ConversationResourcesIface {
81
97
  inputs: ConversationInputsApiIface;
82
98
  decisions: ConversationDecisionsApiIface;
83
99
  resourceSubscriptions: ResourceSubscriptionsApiIface;
100
+ channelRoutes: ConversationChannelRoutesApiIface;
84
101
  }
85
102
  export declare const createConversationResources: (context: ClientContextIface, conversationId: string) => ConversationResourcesIface;
@@ -1,5 +1,8 @@
1
1
  import {
2
2
  apiDecisionResponseSchema,
3
+ channelRouteSchema,
4
+ channelRoutesResponseSchema,
5
+ connectChannelPlaceRequestSchema,
3
6
  conversationContextEntryResponseSchema,
4
7
  conversationContextListSchema,
5
8
  conversationLabelsResponseSchema,
@@ -141,6 +144,31 @@ const createConversationResources = (context, conversationId) => {
141
144
  response: endResourceSubscriptionResponseSchema,
142
145
  signal
143
146
  })).ended
147
+ },
148
+ channelRoutes: {
149
+ list: (options) => http.request({
150
+ method: HttpMethod.Get,
151
+ path: path("/channel-routes"),
152
+ query: { actor: options?.actor },
153
+ response: channelRoutesResponseSchema,
154
+ signal: options?.signal
155
+ }),
156
+ connect: ({ signal, ...value }) => http.request({
157
+ method: HttpMethod.Post,
158
+ path: path("/channel-routes"),
159
+ body: { schema: connectChannelPlaceRequestSchema, value },
160
+ response: channelRouteSchema,
161
+ signal
162
+ }),
163
+ disconnect: async ({ routeId, actor, signal }) => {
164
+ await http.request({
165
+ method: HttpMethod.Delete,
166
+ path: path(`/channel-routes/${encodePath(routeId)}`),
167
+ query: { actor },
168
+ response: okResponseSchema,
169
+ signal
170
+ });
171
+ }
144
172
  }
145
173
  };
146
174
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/agent-client/conversation-resources.ts"],
4
- "sourcesContent": ["import {\n apiDecisionResponseSchema,\n conversationContextEntryResponseSchema,\n conversationContextListSchema,\n conversationLabelsResponseSchema,\n conversationReadGrantListSchema,\n conversationReadGrantResponseSchema,\n createConversationReadGrantRequestSchema,\n createResourceSubscriptionRequestSchema,\n endResourceSubscriptionResponseSchema,\n okResponseSchema,\n postConversationInputRequestSchema,\n postConversationInputResponseSchema,\n putConversationContextEntryRequestSchema,\n raiseConversationDecisionRequestSchema,\n resourceSubscriptionListSchema,\n resourceSubscriptionResponseSchema,\n setConversationLabelsRequestSchema,\n type ApiDecisionIface,\n type ConversationContextEntryIface,\n type ConversationContextRole,\n type ConversationReadGrantIface,\n type CreateConversationReadGrantRequestIface,\n type CreateResourceSubscriptionRequestIface,\n type InputReceiptIface,\n type PostConversationInputRequestIface,\n type RaiseConversationDecisionRequestIface,\n type ResourceSubscriptionIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport * as z from 'zod';\nimport {\n encodePath,\n type ClientContextIface,\n type EnumInput,\n type SignalOptionsIface,\n} from \"./context.mjs\";\nimport { HttpMethod } from \"./http.mjs\";\n\n// What a caller keeps on a conversation besides its messages: labels,\n// standing context, read grants, inputs, the decisions it raises and the\n// outside resources a person follows from it.\n\nexport interface ConversationLabelsApiIface {\n /**\n * Sets labels in the caller's namespace (`PATCH \u2026/labels`); `null` removes a\n * key and keys not named are kept. Needs `labels:write`. Returns every label\n * the conversation now carries for the caller; `info()` carries them too.\n */\n set: (\n labels: Record<string, string | null>,\n options?: SignalOptionsIface,\n ) => Promise<Record<string, string>>;\n}\n\nexport interface ConversationContextEntryInputIface {\n role: EnumInput<ConversationContextRole>;\n /** Delivered verbatim; the platform adds no headers. */\n text: string;\n /** The one agent participant it is for; omitted or null for every agent in the conversation. */\n participantId?: string | null;\n}\n\nexport interface ConversationContextApiIface {\n /**\n * Creates or replaces the caller's entry `key` (`PUT \u2026/context/:key`). The\n * agent gets the text at its next turn boundary, and again whenever it\n * changes or the agent's context was compacted or restored.\n */\n set: (\n key: string,\n entry: ConversationContextEntryInputIface,\n options?: SignalOptionsIface,\n ) => Promise<ConversationContextEntryIface>;\n /** Stops delivering an entry; the agent is told nothing (write replacement text to tell it). */\n delete: (key: string, options?: SignalOptionsIface & { participantId?: string }) => Promise<void>;\n /** The caller's entries. */\n list: (options?: SignalOptionsIface) => Promise<ConversationContextEntryIface[]>;\n}\n\nexport interface ConversationReadGrantsApiIface {\n /** Lets this conversation's agents read one message of another conversation (`POST \u2026/read-grants`). */\n create: (\n args: CreateConversationReadGrantRequestIface & SignalOptionsIface,\n ) => Promise<ConversationReadGrantIface>;\n list: (options?: SignalOptionsIface) => Promise<ConversationReadGrantIface[]>;\n revoke: (args: { grantId: string } & SignalOptionsIface) => Promise<ConversationReadGrantIface>;\n}\n\nexport type SendInputArgsIface = Omit<PostConversationInputRequestIface, 'idempotencyKey'> & {\n /** Redelivering the same key from the same caller and `from.id` returns the first receipt; defaults to a new key. */\n idempotencyKey?: string;\n} & SignalOptionsIface;\n\nexport interface ConversationInputsApiIface {\n /**\n * Hands the conversation's agent something to act on that is not a message\n * from a member (`POST \u2026/inputs`). The reply arrives later as the agent's\n * message, captioned with `label` (or \"From <from.name>\").\n */\n send: (args: SendInputArgsIface) => Promise<InputReceiptIface>;\n}\n\nexport interface ConversationDecisionsApiIface {\n /**\n * Asks the audience a question card (`POST \u2026/decisions`). The caller owns\n * the decision; raising the same `requestKey` again returns it. Its\n * resolution arrives as a `decision.resolved` event carrying `requestKey`.\n */\n raise: (\n args: RaiseConversationDecisionRequestIface & SignalOptionsIface,\n ) => Promise<ApiDecisionIface>;\n /** A decision the caller raised (404 for anyone else's). */\n get: (args: { decisionId: string } & SignalOptionsIface) => Promise<ApiDecisionIface>;\n cancel: (args: { decisionId: string } & SignalOptionsIface) => Promise<ApiDecisionIface>;\n}\n\nexport interface ResourceSubscriptionsApiIface {\n /** The outside resources the caller's person follows from this conversation. */\n list: (options?: SignalOptionsIface) => Promise<ResourceSubscriptionIface[]>;\n /** Follows a resource; fails with `no_linked_channel` unless a linked channel handles it. */\n create: (\n args: CreateResourceSubscriptionRequestIface & SignalOptionsIface,\n ) => Promise<ResourceSubscriptionIface>;\n /** Stops following; resolves whether a follow ended. */\n delete: (args: { resourceKey: string } & SignalOptionsIface) => Promise<boolean>;\n}\n\nexport interface ConversationResourcesIface {\n labels: ConversationLabelsApiIface;\n context: ConversationContextApiIface;\n readGrants: ConversationReadGrantsApiIface;\n inputs: ConversationInputsApiIface;\n decisions: ConversationDecisionsApiIface;\n resourceSubscriptions: ResourceSubscriptionsApiIface;\n}\n\nconst emptyBodySchema = z.strictObject({});\n\nexport const createConversationResources = (\n context: ClientContextIface,\n conversationId: string,\n): ConversationResourcesIface => {\n const { http } = context;\n const path = (suffix: string): string =>\n `/v1/conversations/${encodePath(conversationId)}${suffix}`;\n const decisionPath = (decisionId: string, suffix = ''): string =>\n path(`/decisions/${encodePath(decisionId)}${suffix}`);\n return {\n labels: {\n set: async (labels, options) =>\n (\n await http.request({\n method: HttpMethod.Patch,\n path: path('/labels'),\n body: { schema: setConversationLabelsRequestSchema, value: { labels } },\n response: conversationLabelsResponseSchema,\n signal: options?.signal,\n })\n ).labels,\n },\n context: {\n set: async (key, entry, options) =>\n (\n await http.request({\n method: HttpMethod.Put,\n path: path(`/context/${encodePath(key)}`),\n body: {\n schema: putConversationContextEntryRequestSchema,\n value: { role: entry.role, text: entry.text, participantId: entry.participantId },\n },\n response: conversationContextEntryResponseSchema,\n signal: options?.signal,\n })\n ).entry,\n delete: async (key, options) => {\n await http.request({\n method: HttpMethod.Delete,\n path: path(`/context/${encodePath(key)}`),\n query: { participantId: options?.participantId },\n response: okResponseSchema,\n signal: options?.signal,\n });\n },\n list: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: path('/context'),\n response: conversationContextListSchema,\n signal: options?.signal,\n })\n ).entries,\n },\n readGrants: {\n create: async ({ signal, ...value }) =>\n (\n await http.request({\n method: HttpMethod.Post,\n path: path('/read-grants'),\n body: { schema: createConversationReadGrantRequestSchema, value },\n response: conversationReadGrantResponseSchema,\n signal,\n })\n ).grant,\n list: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: path('/read-grants'),\n response: conversationReadGrantListSchema,\n signal: options?.signal,\n })\n ).grants,\n revoke: async ({ grantId, signal }) =>\n (\n await http.request({\n method: HttpMethod.Delete,\n path: path(`/read-grants/${encodePath(grantId)}`),\n response: conversationReadGrantResponseSchema,\n signal,\n })\n ).grant,\n },\n inputs: {\n send: async ({ signal, idempotencyKey, ...value }) =>\n (\n await http.request({\n method: HttpMethod.Post,\n path: path('/inputs'),\n body: {\n schema: postConversationInputRequestSchema,\n value: { ...value, idempotencyKey: idempotencyKey ?? context.newKey() },\n },\n response: postConversationInputResponseSchema,\n signal,\n })\n ).input,\n },\n decisions: {\n raise: async ({ signal, ...value }) =>\n (\n await http.request({\n method: HttpMethod.Post,\n path: path('/decisions'),\n body: { schema: raiseConversationDecisionRequestSchema, value },\n response: apiDecisionResponseSchema,\n signal,\n })\n ).decision,\n get: async ({ decisionId, signal }) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: decisionPath(decisionId),\n response: apiDecisionResponseSchema,\n signal,\n context: { decisionId },\n })\n ).decision,\n cancel: async ({ decisionId, signal }) =>\n (\n await http.request({\n method: HttpMethod.Post,\n path: decisionPath(decisionId, '/cancel'),\n body: { schema: emptyBodySchema, value: {} },\n response: apiDecisionResponseSchema,\n signal,\n context: { decisionId },\n })\n ).decision,\n },\n resourceSubscriptions: {\n list: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: path('/resource-subscriptions'),\n response: resourceSubscriptionListSchema,\n signal: options?.signal,\n })\n ).subscriptions,\n create: async ({ signal, ...value }) =>\n (\n await http.request({\n method: HttpMethod.Post,\n path: path('/resource-subscriptions'),\n body: { schema: createResourceSubscriptionRequestSchema, value },\n response: resourceSubscriptionResponseSchema,\n signal,\n })\n ).subscription,\n delete: async ({ resourceKey, signal }) =>\n (\n await http.request({\n method: HttpMethod.Delete,\n path: path(`/resource-subscriptions/${encodePath(resourceKey)}`),\n response: endResourceSubscriptionResponseSch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EAAE,QAAQ,yCAAyC,MAAM;AAAA,QAC/D,UAAU;AAAA,QACV;AAAA,MACF,CAAC,GACD;AAAA,MACJ,QAAQ,OAAO,EAAE,aAAa,OAAO,OAEjC,MAAM,KAAK,QAAQ;AAAA,QACjB,QAAQ,WAAW;AAAA,QACnB,MAAM,KAAK,2BAA2B,WAAW,WAAW,CAAC,EAAE;AAAA,QAC/D,UAAU;AAAA,QACV;AAAA,MACF,CAAC,GACD;AAAA,IACN;AAAA,EACF;AACF;",
4
+ "sourcesContent": ["import {\n apiDecisionResponseSchema,\n channelRouteSchema,\n channelRoutesResponseSchema,\n connectChannelPlaceRequestSchema,\n conversationContextEntryResponseSchema,\n conversationContextListSchema,\n conversationLabelsResponseSchema,\n conversationReadGrantListSchema,\n conversationReadGrantResponseSchema,\n createConversationReadGrantRequestSchema,\n createResourceSubscriptionRequestSchema,\n endResourceSubscriptionResponseSchema,\n okResponseSchema,\n postConversationInputRequestSchema,\n postConversationInputResponseSchema,\n putConversationContextEntryRequestSchema,\n raiseConversationDecisionRequestSchema,\n resourceSubscriptionListSchema,\n resourceSubscriptionResponseSchema,\n setConversationLabelsRequestSchema,\n type ApiDecisionIface,\n type ChannelRouteIface,\n type ChannelRoutesResponseIface,\n type ConnectChannelPlaceRequestIface,\n type ConversationContextEntryIface,\n type ConversationContextRole,\n type ConversationReadGrantIface,\n type CreateConversationReadGrantRequestIface,\n type CreateResourceSubscriptionRequestIface,\n type InputReceiptIface,\n type PostConversationInputRequestIface,\n type RaiseConversationDecisionRequestIface,\n type ResourceSubscriptionIface,\n} from '@finalai/agent-protocol/agent-platform';\nimport * as z from 'zod';\nimport {\n encodePath,\n type ClientContextIface,\n type EnumInput,\n type SignalOptionsIface,\n} from \"./context.mjs\";\nimport { HttpMethod } from \"./http.mjs\";\n\n// What a caller keeps on a conversation besides its messages: labels,\n// standing context, read grants, inputs, the decisions it raises and the\n// outside resources a person follows from it.\n\nexport interface ConversationLabelsApiIface {\n /**\n * Sets labels in the caller's namespace (`PATCH \u2026/labels`); `null` removes a\n * key and keys not named are kept. Needs `labels:write`. Returns every label\n * the conversation now carries for the caller; `info()` carries them too.\n */\n set: (\n labels: Record<string, string | null>,\n options?: SignalOptionsIface,\n ) => Promise<Record<string, string>>;\n}\n\nexport interface ConversationContextEntryInputIface {\n role: EnumInput<ConversationContextRole>;\n /** Delivered verbatim; the platform adds no headers. */\n text: string;\n /** The one agent participant it is for; omitted or null for every agent in the conversation. */\n participantId?: string | null;\n}\n\nexport interface ConversationContextApiIface {\n /**\n * Creates or replaces the caller's entry `key` (`PUT \u2026/context/:key`). The\n * agent gets the text at its next turn boundary, and again whenever it\n * changes or the agent's context was compacted or restored.\n */\n set: (\n key: string,\n entry: ConversationContextEntryInputIface,\n options?: SignalOptionsIface,\n ) => Promise<ConversationContextEntryIface>;\n /** Stops delivering an entry; the agent is told nothing (write replacement text to tell it). */\n delete: (key: string, options?: SignalOptionsIface & { participantId?: string }) => Promise<void>;\n /** The caller's entries. */\n list: (options?: SignalOptionsIface) => Promise<ConversationContextEntryIface[]>;\n}\n\nexport interface ConversationReadGrantsApiIface {\n /** Lets this conversation's agents read one message of another conversation (`POST \u2026/read-grants`). */\n create: (\n args: CreateConversationReadGrantRequestIface & SignalOptionsIface,\n ) => Promise<ConversationReadGrantIface>;\n list: (options?: SignalOptionsIface) => Promise<ConversationReadGrantIface[]>;\n revoke: (args: { grantId: string } & SignalOptionsIface) => Promise<ConversationReadGrantIface>;\n}\n\nexport type SendInputArgsIface = Omit<PostConversationInputRequestIface, 'idempotencyKey'> & {\n /** Redelivering the same key from the same caller and `from.id` returns the first receipt; defaults to a new key. */\n idempotencyKey?: string;\n} & SignalOptionsIface;\n\nexport interface ConversationInputsApiIface {\n /**\n * Hands the conversation's agent something to act on that is not a message\n * from a member (`POST \u2026/inputs`). The reply arrives later as the agent's\n * message, captioned with `label` (or \"From <from.name>\").\n */\n send: (args: SendInputArgsIface) => Promise<InputReceiptIface>;\n}\n\nexport interface ConversationDecisionsApiIface {\n /**\n * Asks the audience a question card (`POST \u2026/decisions`). The caller owns\n * the decision; raising the same `requestKey` again returns it. Its\n * resolution arrives as a `decision.resolved` event carrying `requestKey`.\n */\n raise: (\n args: RaiseConversationDecisionRequestIface & SignalOptionsIface,\n ) => Promise<ApiDecisionIface>;\n /** A decision the caller raised (404 for anyone else's). */\n get: (args: { decisionId: string } & SignalOptionsIface) => Promise<ApiDecisionIface>;\n cancel: (args: { decisionId: string } & SignalOptionsIface) => Promise<ApiDecisionIface>;\n}\n\nexport interface ResourceSubscriptionsApiIface {\n /** The outside resources the caller's person follows from this conversation. */\n list: (options?: SignalOptionsIface) => Promise<ResourceSubscriptionIface[]>;\n /** Follows a resource; fails with `no_linked_channel` unless a linked channel handles it. */\n create: (\n args: CreateResourceSubscriptionRequestIface & SignalOptionsIface,\n ) => Promise<ResourceSubscriptionIface>;\n /** Stops following; resolves whether a follow ended. */\n delete: (args: { resourceKey: string } & SignalOptionsIface) => Promise<boolean>;\n}\n\nexport interface ConversationChannelRoutesApiIface {\n /**\n * The provider places connected to the conversation, whether the caller may\n * change them, and the installs that reach it. An API key or app names the\n * actor participant it acts for by external id.\n */\n list: (options?: SignalOptionsIface & { actor?: string }) => Promise<ChannelRoutesResponseIface>;\n /** Connects a place an install has seen; the conversation's managers do this. */\n connect: (\n args: ConnectChannelPlaceRequestIface & SignalOptionsIface,\n ) => Promise<ChannelRouteIface>;\n disconnect: (args: { routeId: string; actor?: string } & SignalOptionsIface) => Promise<void>;\n}\n\nexport interface ConversationResourcesIface {\n labels: ConversationLabelsApiIface;\n context: ConversationContextApiIface;\n readGrants: ConversationReadGrantsApiIface;\n inputs: ConversationInputsApiIface;\n decisions: ConversationDecisionsApiIface;\n resourceSubscriptions: ResourceSubscriptionsApiIface;\n channelRoutes: ConversationChannelRoutesApiIface;\n}\n\nconst emptyBodySchema = z.strictObject({});\n\nexport const createConversationResources = (\n context: ClientContextIface,\n conversationId: string,\n): ConversationResourcesIface => {\n const { http } = context;\n const path = (suffix: string): string =>\n `/v1/conversations/${encodePath(conversationId)}${suffix}`;\n const decisionPath = (decisionId: string, suffix = ''): string =>\n path(`/decisions/${encodePath(decisionId)}${suffix}`);\n return {\n labels: {\n set: async (labels, options) =>\n (\n await http.request({\n method: HttpMethod.Patch,\n path: path('/labels'),\n body: { schema: setConversationLabelsRequestSchema, value: { labels } },\n response: conversationLabelsResponseSchema,\n signal: options?.signal,\n })\n ).labels,\n },\n context: {\n set: async (key, entry, options) =>\n (\n await http.request({\n method: HttpMethod.Put,\n path: path(`/context/${encodePath(key)}`),\n body: {\n schema: putConversationContextEntryRequestSchema,\n value: { role: entry.role, text: entry.text, participantId: entry.participantId },\n },\n response: conversationContextEntryResponseSchema,\n signal: options?.signal,\n })\n ).entry,\n delete: async (key, options) => {\n await http.request({\n method: HttpMethod.Delete,\n path: path(`/context/${encodePath(key)}`),\n query: { participantId: options?.participantId },\n response: okResponseSchema,\n signal: options?.signal,\n });\n },\n list: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: path('/context'),\n response: conversationContextListSchema,\n signal: options?.signal,\n })\n ).entries,\n },\n readGrants: {\n create: async ({ signal, ...value }) =>\n (\n await http.request({\n method: HttpMethod.Post,\n path: path('/read-grants'),\n body: { schema: createConversationReadGrantRequestSchema, value },\n response: conversationReadGrantResponseSchema,\n signal,\n })\n ).grant,\n list: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: path('/read-grants'),\n response: conversationReadGrantListSchema,\n signal: options?.signal,\n })\n ).grants,\n revoke: async ({ grantId, signal }) =>\n (\n await http.request({\n method: HttpMethod.Delete,\n path: path(`/read-grants/${encodePath(grantId)}`),\n response: conversationReadGrantResponseSchema,\n signal,\n })\n ).grant,\n },\n inputs: {\n send: async ({ signal, idempotencyKey, ...value }) =>\n (\n await http.request({\n method: HttpMethod.Post,\n path: path('/inputs'),\n body: {\n schema: postConversationInputRequestSchema,\n value: { ...value, idempotencyKey: idempotencyKey ?? context.newKey() },\n },\n response: postConversationInputResponseSchema,\n signal,\n })\n ).input,\n },\n decisions: {\n raise: async ({ signal, ...value }) =>\n (\n await http.request({\n method: HttpMethod.Post,\n path: path('/decisions'),\n body: { schema: raiseConversationDecisionRequestSchema, value },\n response: apiDecisionResponseSchema,\n signal,\n })\n ).decision,\n get: async ({ decisionId, signal }) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: decisionPath(decisionId),\n response: apiDecisionResponseSchema,\n signal,\n context: { decisionId },\n })\n ).decision,\n cancel: async ({ decisionId, signal }) =>\n (\n await http.request({\n method: HttpMethod.Post,\n path: decisionPath(decisionId, '/cancel'),\n body: { schema: emptyBodySchema, value: {} },\n response: apiDecisionResponseSchema,\n signal,\n context: { decisionId },\n })\n ).decision,\n },\n resourceSubscriptions: {\n list: async (options) =>\n (\n await http.request({\n method: HttpMethod.Get,\n path: path('/resource-subscriptions'),\n response: resourceSubscriptionListSchema,\n signal: options?.signal,\n })\n ).subscriptions,\n create: async ({ signal, ...value }) =>\n (\n await http.request({\n method: HttpMethod.Post,\n path: path('/resource-subscriptions'),\n body: { schema: createResourceSubscriptionRequestSchema, value },\n response: resourceSubscriptionResponseSchema,\n signal,\n })\n ).subscription,\n delete: async ({ resourceKey, signal }) =>\n (\n await http.request({\n method: HttpMethod.Delete,\n path: path(`/resource-subscriptions/${encodePath(resourceKey)}`),\n response: endResourceSubscriptionResponseSchema,\n signal,\n })\n ).ended,\n },\n channelRoutes: {\n list: (options) =>\n http.request({\n method: HttpMethod.Get,\n path: path('/channel-routes'),\n query: { actor: options?.actor },\n response: channelRoutesResponseSchema,\n signal: options?.signal,\n }),\n connect: ({ signal, ...value }) =>\n http.request({\n method: HttpMethod.Post,\n path: path('/channel-routes'),\n body: { schema: connectChannelPlaceRequestSchema, value },\n response: channelRouteSchema,\n signal,\n }),\n disconnect: async ({ routeId, actor, signal }) => {\n await http.request({\n method: HttpMethod.Delete,\n path: path(`/channel-routes/${encodePath(routeId)}`),\n query: { actor },\n response: okResponseS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AK,yBAAyB;AAAA,QACpC,MAAM,EAAE,QAAQ,yCAAyC,MAAM;AAAA,QAC/D,UAAU;AAAA,QACV;AAAA,MACF,CAAC,GACD;AAAA,MACJ,QAAQ,OAAO,EAAE,aAAa,OAAO,OAEjC,MAAM,KAAK,QAAQ;AAAA,QACjB,QAAQ,WAAW;AAAA,QACnB,MAAM,KAAK,2BAA2B,WAAW,WAAW,CAAC,EAAE;AAAA,QAC/D,UAAU;AAAA,QACV;AAAA,MACF,CAAC,GACD;AAAA,IACN;AAAA,IACA,eAAe;AAAA,MACb,MAAM,CAAC,YACL,KAAK,QAAQ;AAAA,QACX,QAAQ,WAAW;AAAA,QACnB,MAAM,KAAK,iBAAiB;AAAA,QAC5B,OAAO,EAAE,OAAO,SAAS,MAAM;AAAA,QAC/B,UAAU;AAAA,QACV,QAAQ,SAAS;AAAA,MACnB,CAAC;AAAA,MACH,SAAS,CAAC,EAAE,QAAQ,GAAG,MAAM,MAC3B,KAAK,QAAQ;AAAA,QACX,QAAQ,WAAW;AAAA,QACnB,MAAM,KAAK,iBAAiB;AAAA,QAC5B,MAAM,EAAE,QAAQ,kCAAkC,MAAM;AAAA,QACxD,UAAU;AAAA,QACV;AAAA,MACF,CAAC;AAAA,MACH,YAAY,OAAO,EAAE,SAAS,OAAO,OAAO,MAAM;AAChD,cAAM,KAAK,QAAQ;AAAA,UACjB,QAAQ,WAAW;AAAA,UACnB,MAAM,KAAK,mBAAmB,WAAW,OAAO,CAAC,EAAE;AAAA,UACnD,OAAO,EAAE,MAAM;AAAA,UACf,UAAU;AAAA,UACV;AAAA,QACF,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,5 +1,6 @@
1
+ import { type ParticipantConfigurationApiIface } from "./participant-configuration.mjs";
1
2
  import { type ProcessInspectionRequestIface, type ProcessInspectionResultIface } from '@finalai/agent-protocol';
2
- import { AgentSessionState, type PostConversationEventResponseIface, type AgentRealtimeEvent, type AgentTurnPolicy, type AttachmentDownloadIface, type AttachmentUploadIface, type ContentInput, type ConversationIface, type ConversationKind, type ConversationLinkIface, type ConversationListIface, type ConversationMessageIface, type ConversationMessagesPageIface, type ConversationSandboxIface, type ConversationScheduleIface, type CreateConversationScheduleRequestIface, type DecisionsPageIface, type MessageDeliveryIface, type ParticipantIface, type ActorInputIface, type ParticipantInput, type ParticipantProvideResponseIface, type PostConversationEventRequestIface, type ReactionIface, type ReadStateIface, type RespondDecisionResponseIface, type SandboxDirectoryIface, type SandboxEditorSessionIface, type SandboxFileIface, type SandboxPathIface, type SandboxPreviewType, type SandboxSearchIface, type SearchMessagesPageIface, type UpdateConversationRequestIface, type UpdateConversationScheduleRequestIface, type UpdateParticipantRequestIface, type WireFallback } from '@finalai/agent-protocol/agent-platform';
3
+ import { AgentSessionState, type AgentRealtimeEvent, type AgentTurnPolicy, type AttachmentDownloadIface, type AttachmentUploadIface, type ContentInput, type ConversationIface, type ConversationKind, type ConversationLinkIface, type ConversationListIface, type ConversationMessageIface, type ConversationMessagesPageIface, type ConversationSandboxIface, type ConversationScheduleIface, type CreateConversationScheduleRequestIface, type DecisionsPageIface, type MessageDeliveryIface, type ParticipantIface, type ActorInputIface, type ParticipantInput, type ParticipantProvideResponseIface, type ReactionIface, type ReadStateIface, type RespondDecisionResponseIface, type SandboxDirectoryIface, type SandboxEditorSessionIface, type SandboxFileIface, type SandboxPathIface, type SandboxPreviewType, type SandboxSearchIface, type SearchMessagesPageIface, type UpdateConversationRequestIface, type UpdateConversationScheduleRequestIface, type ScheduleRunResultIface, type UpdateParticipantRequestIface, type WireFallback } from '@finalai/agent-protocol/agent-platform';
3
4
  import type { AgentInput } from "./agent-input.mjs";
4
5
  import { type ConversationResourcesIface } from "./conversation-resources.mjs";
5
6
  import { type CollectionEvent, type CollectionEventsOptionsIface } from "./collection-events.mjs";
@@ -104,6 +105,8 @@ export interface ParticipantsApiIface {
104
105
  * `harness_unsuitable` for harness settings it cannot run on.
105
106
  */
106
107
  provide: (participantId: string, patch: ProvidePatchIface, options?: SignalOptionsIface) => Promise<ParticipantProvideResponseIface>;
108
+ /** Changes to an agent participant's settings through proposals a manager decides. */
109
+ configuration: ParticipantConfigurationApiIface;
107
110
  }
108
111
  export interface SentMessageIface {
109
112
  message: ConversationMessageIface;
@@ -138,9 +141,16 @@ export interface ConversationHandleIface extends ConversationResourcesIface {
138
141
  send: (content: ContentInput, options?: SendMessageOptionsIface) => Promise<SentMessageIface>;
139
142
  events: (options?: ConversationEventsOptionsIface) => AsyncIterableIterator<ConversationEvent>;
140
143
  messages: (options?: ListMessagesOptionsIface) => Promise<ConversationMessagesPageIface>;
141
- /** One message by id (`GET /v1/conversations/:id/messages/:messageId`), e.g. a thread root. */
144
+ /**
145
+ * One message: by id (`GET /v1/conversations/:id/messages/:messageId`), e.g. a thread root,
146
+ * or the reply a turn's streamed text became, by the session seq its text started at (a
147
+ * preview's `fromSeq`).
148
+ */
142
149
  message: (args: {
143
150
  messageId: string;
151
+ } | {
152
+ turnId: string;
153
+ fromSeq: number;
144
154
  }, options?: SignalOptionsIface) => Promise<ConversationMessageIface>;
145
155
  react: (args: {
146
156
  messageId: string;
@@ -150,11 +160,6 @@ export interface ConversationHandleIface extends ConversationResourcesIface {
150
160
  messageId: string;
151
161
  emoji: string;
152
162
  }, options?: SignalOptionsIface) => Promise<ReactionIface[]>;
153
- recordPushOpen: (args: {
154
- deliveryId: string;
155
- }, options?: SignalOptionsIface) => Promise<{
156
- recorded: boolean;
157
- }>;
158
163
  markRead: (args: {
159
164
  throughSeq: number;
160
165
  }, options?: SignalOptionsIface) => Promise<ReadStateIface>;
@@ -175,13 +180,6 @@ export interface ConversationHandleIface extends ConversationResourcesIface {
175
180
  typing: (args: {
176
181
  typing: boolean;
177
182
  }, options?: SignalOptionsIface) => Promise<void>;
178
- /**
179
- * Hands something that happened outside the conversation (`POST …/events`)
180
- * to its Default agent as input from you, not as a message: the agent's
181
- * reply carries the source as its caption. The same `eventId` from the same
182
- * source is accepted once; the receipt says whether the agent was prompted.
183
- */
184
- postEvent: (event: PostConversationEventRequestIface, options?: SignalOptionsIface) => Promise<PostConversationEventResponseIface>;
185
183
  respond: (args: RespondArgs, options?: SignalOptionsIface) => Promise<RespondDecisionResponseIface>;
186
184
  /** Stops the agents' running turns in this conversation. */
187
185
  cancel: (options?: SignalOptionsIface & {
@@ -307,6 +305,10 @@ export interface ConversationHandleIface extends ConversationResourcesIface {
307
305
  deleteSchedule: (args: {
308
306
  scheduleId: string;
309
307
  }, options?: SignalOptionsIface) => Promise<void>;
308
+ /** Fires a schedule now (`POST …/schedules/:id/run-now`, needs `agents:execute`). */
309
+ runSchedule: (args: {
310
+ scheduleId: string;
311
+ }, options?: SignalOptionsIface) => Promise<ScheduleRunResultIface>;
310
312
  /**
311
313
  * The conversations this one handed work to, with what their agents are
312
314
  * doing (`GET …/links`). Their replies and waits arrive here as messages.
@@ -367,16 +369,6 @@ export interface ProjectConversationsApiIface extends ConversationsApiIface {
367
369
  * creating nothing, unless each agent's requirements are met.
368
370
  */
369
371
  create: (args: CreateConversationArgsIface) => Promise<OpenedConversationIface>;
370
- /**
371
- * The caller's own Home thread with the project's agent, found or created.
372
- * `provide` is stored only when the agent has no settings there yet.
373
- */
374
- home: (args: {
375
- id?: string;
376
- provide: ProvideIface;
377
- } & SignalOptionsIface) => Promise<OpenedConversationIface>;
378
- /** The caller's Home thread, if there is one. Creates nothing. */
379
- findHome: (options?: SignalOptionsIface) => Promise<ConversationIface | null>;
380
372
  /**
381
373
  * The caller's direct conversation with an agent, found or created.
382
374
  * `provide` is stored only when the agent has no settings there yet.
@@ -416,10 +408,14 @@ export interface ConversationsApiIface {
416
408
  }) => Promise<ConversationListIface>;
417
409
  /** I/O-free handle. */
418
410
  get: (conversationId: string) => ConversationHandleIface;
419
- /** Full-text search over the caller's conversations (or one), newest first. */
411
+ /**
412
+ * Full-text search over the caller's conversations (or one, or those in a project and the
413
+ * projects below it), newest first.
414
+ */
420
415
  search: (args: {
421
416
  q: string;
422
417
  conversationId?: string;
418
+ projectId?: string;
423
419
  cursor?: string;
424
420
  limit?: number;
425
421
  } & SignalOptionsIface) => Promise<SearchMessagesPageIface>;
@@ -1,3 +1,6 @@
1
+ import {
2
+ createParticipantConfigurationApi
3
+ } from "./participant-configuration.mjs";
1
4
  import {
2
5
  PROCESS_CAPABILITIES,
3
6
  ProcessInspectionOperation,
@@ -31,9 +34,9 @@ import {
31
34
  createConversationRequestSchema,
32
35
  createConversationScheduleRequestSchema,
33
36
  createDirectConversationRequestSchema,
37
+ scheduleRunResultSchema,
34
38
  DecisionEventState,
35
39
  decisionRecordListSchema,
36
- homeConversationRequestSchema,
37
40
  decisionsPageSchema,
38
41
  markReadRequestSchema,
39
42
  messageDeliveriesSchema,
@@ -46,10 +49,7 @@ import {
46
49
  participantListSchema,
47
50
  participantProvideResponseSchema,
48
51
  participantSchema,
49
- postConversationEventRequestSchema,
50
52
  provideParticipantRequestSchema,
51
- postConversationEventResponseSchema,
52
- pushDeliveryOpenResponseSchema,
53
53
  reactionRequestSchema,
54
54
  reactionsResponseSchema,
55
55
  readStateSchema,
@@ -721,7 +721,10 @@ const createConversationHandle = (context, conversationId, starter) => {
721
721
  })).deliveries,
722
722
  message: (args, options) => http.request({
723
723
  method: HttpMethod.Get,
724
- path: messagePath(conversationId, args.messageId),
724
+ path: "messageId" in args ? messagePath(conversationId, args.messageId) : conversationPath(
725
+ conversationId,
726
+ `/turns/${encodePath(args.turnId)}/messages/${args.fromSeq}`
727
+ ),
725
728
  response: conversationMessageSchema,
726
729
  signal: options?.signal
727
730
  }),
@@ -736,13 +739,6 @@ const createConversationHandle = (context, conversationId, starter) => {
736
739
  signal: options?.signal
737
740
  });
738
741
  },
739
- postEvent: (event, options) => http.request({
740
- method: HttpMethod.Post,
741
- path: conversationPath(conversationId, "/events"),
742
- body: { schema: postConversationEventRequestSchema, value: event },
743
- response: postConversationEventResponseSchema,
744
- signal: options?.signal
745
- }),
746
742
  typing: async (args, options) => {
747
743
  await http.request({
748
744
  method: HttpMethod.Post,
@@ -752,15 +748,6 @@ const createConversationHandle = (context, conversationId, starter) => {
752
748
  signal: options?.signal
753
749
  });
754
750
  },
755
- recordPushOpen: (args, options) => http.request({
756
- method: HttpMethod.Post,
757
- path: conversationPath(
758
- conversationId,
759
- `/push-deliveries/${encodeURIComponent(args.deliveryId)}/open`
760
- ),
761
- response: pushDeliveryOpenResponseSchema,
762
- signal: options?.signal
763
- }),
764
751
  markRead: (args, options) => http.request({
765
752
  method: HttpMethod.Post,
766
753
  path: conversationPath(conversationId, "/read"),
@@ -818,7 +805,8 @@ const createConversationHandle = (context, conversationId, starter) => {
818
805
  response: participantProvideResponseSchema,
819
806
  signal: options?.signal
820
807
  });
821
- }
808
+ },
809
+ configuration: createParticipantConfigurationApi({ context, conversationId })
822
810
  }
823
811
  ),
824
812
  turns: async (options) => {
@@ -1126,6 +1114,12 @@ const createConversationHandle = (context, conversationId, starter) => {
1126
1114
  signal: options?.signal
1127
1115
  });
1128
1116
  },
1117
+ runSchedule: (args, options) => http.request({
1118
+ method: HttpMethod.Post,
1119
+ path: conversationPath(conversationId, `/schedules/${encodePath(args.scheduleId)}/run-now`),
1120
+ response: scheduleRunResultSchema,
1121
+ signal: options?.signal
1122
+ }),
1129
1123
  uploadAttachment: async (args) => {
1130
1124
  const sizeBytes = "byteLength" in args.data ? args.data.byteLength : args.data.size;
1131
1125
  const upload = await http.request({
@@ -1182,6 +1176,7 @@ const createConversationsApi = (context, starter) => {
1182
1176
  query: {
1183
1177
  q: args.q,
1184
1178
  conversationId: args.conversationId,
1179
+ projectId: args.projectId,
1185
1180
  cursor: args.cursor,
1186
1181
  limit: args.limit
1187
1182
  },
@@ -1342,46 +1337,6 @@ const createProjectConversationsApi = (args) => {
1342
1337
  }
1343
1338
  return opened(conversation);
1344
1339
  },
1345
- home: async ({ id, provide, signal }) => {
1346
- const document = provideDocumentOf(provide);
1347
- const placed = document.harness == null ? null : await withWorkersEnvironment({
1348
- context,
1349
- projectId,
1350
- harness: document.harness,
1351
- owner: { kind: LocalHostOwnerKind.Conversation, id },
1352
- signal
1353
- });
1354
- const homeId = placed?.ownerId ?? id;
1355
- const discard = () => void placed?.created?.discard().catch(() => void 0);
1356
- try {
1357
- const { conversation } = await context.http.request({
1358
- method: HttpMethod.Post,
1359
- path: "/v1/conversations/home",
1360
- body: {
1361
- schema: homeConversationRequestSchema,
1362
- value: {
1363
- projectId,
1364
- id: homeId,
1365
- provide: placed == null ? document : { ...document, harness: placed.harness }
1366
- }
1367
- },
1368
- response: conversationResponseSchema,
1369
- signal
1370
- });
1371
- if (conversation.id !== homeId) discard();
1372
- return opened(conversation);
1373
- } catch (cause) {
1374
- discard();
1375
- throw cause;
1376
- }
1377
- },
1378
- findHome: async (options) => (await context.http.request({
1379
- method: HttpMethod.Get,
1380
- path: "/v1/conversations/home",
1381
- query: { projectId },
1382
- response: conversationLookupSchema,
1383
- signal: options?.signal
1384
- })).conversation,
1385
1340
  direct: async ({ id, agent, provide, actor, signal }) => {
1386
1341
  const started = await startAgent(args.start, {
1387
1342
  projectId,