@finalai/agents 0.12.0 → 0.13.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 (30) hide show
  1. package/dist/modules/agent-client/channels.d.mts +91 -28
  2. package/dist/modules/agent-client/channels.mjs +168 -46
  3. package/dist/modules/agent-client/channels.mjs.map +2 -2
  4. package/dist/modules/agent-client/client.d.mts +8 -3
  5. package/dist/modules/agent-client/client.mjs +7 -5
  6. package/dist/modules/agent-client/client.mjs.map +2 -2
  7. package/dist/modules/agent-client/conversation-resources.d.mts +18 -1
  8. package/dist/modules/agent-client/conversation-resources.mjs +28 -0
  9. package/dist/modules/agent-client/conversation-resources.mjs.map +2 -2
  10. package/dist/modules/agent-client/conversations.d.mts +5 -1
  11. package/dist/modules/agent-client/conversations.mjs +7 -0
  12. package/dist/modules/agent-client/conversations.mjs.map +2 -2
  13. package/dist/modules/agent-client/index.d.mts +3 -3
  14. package/dist/modules/agent-client/index.mjs.map +2 -2
  15. package/dist/modules/agent-client/project.d.mts +7 -2
  16. package/dist/modules/agent-client/project.mjs +5 -5
  17. package/dist/modules/agent-client/project.mjs.map +2 -2
  18. package/dist/modules/agent-client/sandboxes.d.mts +7 -0
  19. package/dist/modules/agent-client/sandboxes.mjs +9 -1
  20. package/dist/modules/agent-client/sandboxes.mjs.map +2 -2
  21. package/dist/modules/agent-client/schedules.d.mts +7 -22
  22. package/dist/modules/agent-client/schedules.mjs +8 -47
  23. package/dist/modules/agent-client/schedules.mjs.map +2 -2
  24. package/dist/modules/public.d.mts +1 -1
  25. package/dist/modules/public.mjs.map +2 -2
  26. package/examples/release-scout/run-on-a-computer.ts +1 -1
  27. package/package.json +5 -10
  28. package/dist/modules/authoring/final-channel.d.mts +0 -1
  29. package/dist/modules/authoring/final-channel.mjs +0 -2
  30. package/dist/modules/authoring/final-channel.mjs.map +0 -7
@@ -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,OAUK;AACP,SAAS,oBAAsC;AAE/C;AAAA,EACE;AAAA,OAGK;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,EACA;AAAA,OAGK;AACP,SAAS,2BAAmD;AAC5D;AAAA,EACE;AAAA,EACA;AAAA,OAIK;AACP;AAAA,EACE;AAAA,OAIK;AAEP,SAAS,2BAAoD;AAC7D,SAAS,yBAAgD;AACzD,SAAS,2BAAoD;AAC7D,SAAS,0BAAkD;AAC3D,SAAS,yBAAgD;AAIlD,MAAM,sBAAsB;AAyJ5B,MAAM,eAAe,CAAC,YAAwD;AACnF,QAAM,OAAO,WAAW;AAAA,IACtB,MAAM,QAAQ,QAAQ;AAAA,IACtB,MAAM,QAAQ;AAAA,IACd,SAAS,QAAQ;AAAA,IACjB,OAAO,QAAQ;AAAA,EACjB,CAAC;AACD,MAAI,WAAW,QAAQ,YAAY;AACnC,MAAI,eAAqD;AACzD,QAAM,UAAU,IAAI,gBAAgB;AACpC,QAAM,wBAA2D,CAAC,mBAChE,KAAK,QAAQ;AAAA,IACX,QAAQ,WAAW;AAAA,IACnB,MAAM;AAAA,IACN,UAAU;AAAA,IACV,QAAQ,gBAAgB;AAAA,EAC1B,CAAC;AACH,MAAI,gBAA8D;AAClE,QAAM,uBAAuB,MAA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AA,IACL;AAAA,IACA,WAAW;AAAA,MACT,KAAK,OAAO,EAAE,IAAI,OAAO,OAErB,MAAM,KAAK,QAAQ;AAAA,QACjB,QAAQ,WAAW;AAAA,QACnB,MAAM,iBAAiB,WAAW,EAAE,CAAC;AAAA,QACrC,UAAU;AAAA,QACV;AAAA,QACA,SAAS,EAAE,YAAY,GAAG;AAAA,MAC5B,CAAC,GACD;AAAA,IACN;AAAA,IACA,UAAU,kBAAkB,OAAO;AAAA,IACnC,eAAe,uBAAuB,SAAS,WAAW;AAAA,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 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 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 { 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\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 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 },\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 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,OAUK;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,EACA;AAAA,OAGK;AACP,SAAS,2BAAmD;AAC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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: endResourceSubscriptionResponseSchema,\n signal,\n })\n ).ended,\n },\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,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAWK;AACP,YAAY,OA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AA,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: okResponseSchema,\n signal,\n });\n },\n },\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,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,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AA,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,5 @@
1
1
  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';
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 ScheduleRunResultIface, type UpdateParticipantRequestIface, type WireFallback } from '@finalai/agent-protocol/agent-platform';
3
3
  import type { AgentInput } from "./agent-input.mjs";
4
4
  import { type ConversationResourcesIface } from "./conversation-resources.mjs";
5
5
  import { type CollectionEvent, type CollectionEventsOptionsIface } from "./collection-events.mjs";
@@ -307,6 +307,10 @@ export interface ConversationHandleIface extends ConversationResourcesIface {
307
307
  deleteSchedule: (args: {
308
308
  scheduleId: string;
309
309
  }, options?: SignalOptionsIface) => Promise<void>;
310
+ /** Fires a schedule now (`POST …/schedules/:id/run-now`, needs `agents:execute`). */
311
+ runSchedule: (args: {
312
+ scheduleId: string;
313
+ }, options?: SignalOptionsIface) => Promise<ScheduleRunResultIface>;
310
314
  /**
311
315
  * The conversations this one handed work to, with what their agents are
312
316
  * doing (`GET …/links`). Their replies and waits arrive here as messages.
@@ -31,6 +31,7 @@ import {
31
31
  createConversationRequestSchema,
32
32
  createConversationScheduleRequestSchema,
33
33
  createDirectConversationRequestSchema,
34
+ scheduleRunResultSchema,
34
35
  DecisionEventState,
35
36
  decisionRecordListSchema,
36
37
  homeConversationRequestSchema,
@@ -1126,6 +1127,12 @@ const createConversationHandle = (context, conversationId, starter) => {
1126
1127
  signal: options?.signal
1127
1128
  });
1128
1129
  },
1130
+ runSchedule: (args, options) => http.request({
1131
+ method: HttpMethod.Post,
1132
+ path: conversationPath(conversationId, `/schedules/${encodePath(args.scheduleId)}/run-now`),
1133
+ response: scheduleRunResultSchema,
1134
+ signal: options?.signal
1135
+ }),
1129
1136
  uploadAttachment: async (args) => {
1130
1137
  const sizeBytes = "byteLength" in args.data ? args.data.byteLength : args.data.size;
1131
1138
  const upload = await http.request({