@finalai/agent-provider 0.7.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/HOSTING.md CHANGED
@@ -269,6 +269,6 @@ Optional readers preserve source compatibility with existing hosts. Definitions
269
269
  requesting bindings fail clearly if hosting does not provide them. Installing these
270
270
  packages alone does not change Final's deployed service wiring or provision secrets.
271
271
 
272
- New compiles emit manifest version 4. Hosts and stored revisions must use v4;
273
- recompile older definitions before loading them. Upgrade hosting before
274
- publishing newly compiled agents.
272
+ New compiles emit manifest version 4. Hosts read versions 2 through 4; older
273
+ channel entries default to no credentials and an empty surface. Upgrade hosting
274
+ before publishing newly compiled agents.
package/README.md CHANGED
@@ -77,7 +77,7 @@ Confined reads require a trusted system `python3` in `/usr/bin` or `/usr/local/b
77
77
 
78
78
  Acquiring a hosted MCP endpoint or channel is foreground work: it may start a server and perform deferred workspace setup. Catalog polling on an acquired channel is background maintenance and does not start setup. Abortable operations pass their signal to admission; cancellation rejects pending admission and prevents dispatch even if a host policy settles later.
79
79
 
80
- ## Channels v2
80
+ ## Channels
81
81
 
82
82
  `ChannelDefinitionIface<Config, Inbound, State>` describes a provider namespace,
83
83
  its application credentials, identity proof, place kinds, routes/listeners,
@@ -105,15 +105,11 @@ are delivered at least once; channels persist provider reply IDs in `store` for
105
105
  deduplication. `replies: all` enables `message.posted` mirroring. Raw ACP updates
106
106
  belong to harnesses and the separately typed Final room surface.
107
107
 
108
- `observe` streams deltas directly and accepts a cancellation signal. Media
109
- operations stream transcription and synthesis and accept an optional `signal` to
110
- abort pending provider work on hangup or interruption. HTTP and binary WebSocket routes
111
- receive the same capabilities; listeners additionally receive an abort signal.
112
- Package execution obtains shared OAuth/signing metadata with `appInfo()` and
113
- selects a tenant API credential with `app({tenant})`. `appInfo()` never returns an access token.
114
- `app()` and `appInfo()` are available only in package execution. Isolated code
115
- uses the host's credential-injecting fetch and explicitly declared project secrets
116
- through `secret(name)`.
108
+ `observe` streams one turn's events, from its start, and accepts a cancellation signal. Use `events` to hear a conversation over time. HTTP and binary WebSocket routes receive the same capabilities; listeners additionally receive an abort signal. Events a host receives for an installed app arrive unchanged at the channel's `POST /webhook` route, signature headers included, so a channel verifies them like any other request. Speech providers and audio processing belong to application code, using its declared credentials and ordinary HTTP/socket requests.
109
+ Installed app credentials stay with the host in every execution mode. `credentials.client()` exposes only the public client ID; `verify()` checks signed payloads without returning the signing key. `exchange()` returns an opaque, short-lived OAuth credential handle. Select that handle or the installed app with `credentials.fetch`'s `credential` option; requests default to no credential. `credentials.connect()` supports host-injected credentials in outgoing JSON socket frames. Hosts enforce the same destination and grant checks for all these operations. Only explicitly declared project secrets can be read through `secret(name)`. Sockets accept bounded caller-owned headers for provider handshakes. Installed app credentials remain opaque and can be injected into JSON frames. Exchange handles are invocation-scoped and expire; they do not provide durable person-token storage or automatic refresh. An application's authorization callback must use provider APIs that can establish the current person's access.
110
+
111
+ `binding.url` is the host's canonical binding base URL for routes. Provider settings must not hold it when an application serves more than one binding. For OAuth, declare the callback route with `redirect: true` and call `credentials.redirect({ path })`: the returned `url` is the same for every binding, so an application registers it once, and `state` returns the person to this binding. Send both unchanged, and use the same `url` in the token exchange. A `redirect` route must be a GET and is reachable only through that URL. Channels compile into their authored bundle; naming an installed implementation does not grant additional authority. `resources.resolve` maps an application URL to a canonical provider place; the required companion `resources.authorize` checks the linked person's current provider access. Hosts repeat that authorization for later observation access. `places.follow` and `unfollow` manage observation under a linked person's authority, while `places.observers` enumerates authorized deliveries.
112
+
117
113
  A host must fail ambiguous tenant selection rather than choosing an arbitrary
118
114
  credential. Tenant-wide `people.revoke` with reason `uninstalled` or
119
115
  `provider-revoked` and no principal also disconnects that tenant's places. Omitting
@@ -121,10 +117,11 @@ the tenant applies this lifecycle change to the binding's namespace. A socket ha
121
117
  cleanup grace after disconnect; every other operation is revoked immediately, and all
122
118
  capabilities end when the handler returns. Attachment authorization still applies.
123
119
 
124
- Manifest v4 records channel credentials and `surface` routes/listeners/place kinds.
125
- The `roomSurface` field describes `channels/final.ts` separately. The old address,
126
- attached-session, handoff and bound-conversation channel API is removed. Existing
127
- channel authors must migrate and republish their definitions.
120
+ Manifests record channel credentials and `surface` routes/listeners/place kinds.
121
+ The `roomSurface` field describes `channels/final.ts`, the customization of the Final
122
+ chat itself, which is typed separately in `@finalai/agent-provider/room-surface`.
123
+ The address, attached-session and handoff channel API is removed. Existing channel
124
+ authors must migrate and republish their definitions.
128
125
 
129
126
  ## Durable processes
130
127
 
@@ -1,10 +1,7 @@
1
1
  import type { ContentBlock } from '@agentclientprotocol/sdk/experimental/v2';
2
2
  import * as z from 'zod';
3
3
  import { type JsonObject, type JsonValue } from "./json.mjs";
4
- import type { ProviderRef } from "./provider-ref.mjs";
5
- import type { ChannelSocketIface, ChannelTurnStateIface } from "./room-surface.mjs";
6
4
  import type { ChannelSemanticDataByKindIface } from "./semantic-events.mjs";
7
- export * from "./room-surface.mjs";
8
5
  export declare const personHandleSchema: z.core.$ZodBranded<z.ZodString, "ChannelPerson", "out">;
9
6
  export declare const conversationHandleSchema: z.core.$ZodBranded<z.ZodString, "ChannelConversation", "out">;
10
7
  export type PersonHandle = z.infer<typeof personHandleSchema>;
@@ -109,25 +106,85 @@ export declare const channelReceiveResultSchema: z.ZodUnion<readonly [z.ZodObjec
109
106
  ignored: z.ZodLiteral<true>;
110
107
  reason: z.ZodString;
111
108
  }, z.core.$strip>]>;
112
- export interface InstalledAppInfoIface {
113
- clientId: string;
114
- clientSecret: string;
115
- signingSecret?: string;
109
+ export declare enum ChannelCredentialKind {
110
+ App = "app",
111
+ OAuth = "oauth",
112
+ None = "none"
116
113
  }
117
- export interface InstalledAppCredential extends InstalledAppInfoIface {
118
- accessToken: string;
119
- tenantId?: string;
120
- externalId?: string;
121
- expiresAt?: string | null;
122
- customHeaders?: Record<string, string>;
114
+ export declare const channelCredentialHandleSchema: z.core.$ZodBranded<z.ZodString, "ChannelCredential", "out">;
115
+ export type ChannelCredentialHandle = z.infer<typeof channelCredentialHandleSchema>;
116
+ export type ChannelCredentialRef = {
117
+ kind: ChannelCredentialKind.App;
118
+ tenant?: string;
119
+ } | {
120
+ kind: ChannelCredentialKind.OAuth;
121
+ handle: ChannelCredentialHandle;
122
+ } | {
123
+ kind: ChannelCredentialKind.None;
124
+ };
125
+ export declare enum ChannelSigningAlgorithm {
126
+ HmacSha256 = "hmac-sha256",
127
+ HmacSha1 = "hmac-sha1",
128
+ Ed25519 = "ed25519"
129
+ }
130
+ export declare enum ChannelSignatureEncoding {
131
+ Hex = "hex",
132
+ Base64 = "base64"
133
+ }
134
+ export declare enum ChannelOAuthClientAuthentication {
135
+ Body = "body",
136
+ Basic = "basic",
137
+ None = "none"
138
+ }
139
+ export interface ChannelCredentialRequestInitIface extends RequestInit {
140
+ credential?: ChannelCredentialRef;
141
+ }
142
+ export interface ChannelVerifyOptionsIface {
143
+ algorithm: ChannelSigningAlgorithm;
144
+ encoding: ChannelSignatureEncoding;
145
+ data: string;
146
+ signature: string;
147
+ }
148
+ export interface ChannelOAuthExchangeOptionsIface {
149
+ url: string;
150
+ parameters: Record<string, string>;
151
+ authentication: ChannelOAuthClientAuthentication;
152
+ clientId?: string;
153
+ signal?: AbortSignal;
154
+ }
155
+ export interface ChannelRedirectOptionsIface {
156
+ path: string;
157
+ }
158
+ export interface ChannelRedirectIface {
159
+ url: string;
160
+ state: string;
161
+ }
162
+ export interface ChannelCredentialConnectOptionsIface {
163
+ url: string;
164
+ signal?: AbortSignal;
165
+ }
166
+ export interface ChannelCredentialInjectionIface {
167
+ path: string[];
168
+ credential: ChannelCredentialRef;
169
+ }
170
+ export interface ChannelCredentialSocketIface {
171
+ messages: AsyncIterable<string | Uint8Array>;
172
+ send(data: string | Uint8Array, options?: {
173
+ inject?: ChannelCredentialInjectionIface[];
174
+ }): Promise<void>;
175
+ close(code?: number, reason?: string): Promise<void>;
176
+ closeCode(): number | null;
123
177
  }
124
178
  export interface ChannelCredentialsIface {
125
- appInfo(): Promise<InstalledAppInfoIface>;
126
- app(options?: {
127
- tenant?: string;
128
- }): Promise<InstalledAppCredential>;
179
+ client(): Promise<{
180
+ clientId: string;
181
+ }>;
182
+ verify(args: ChannelVerifyOptionsIface): Promise<boolean>;
183
+ exchange(args: ChannelOAuthExchangeOptionsIface): Promise<ChannelCredentialHandle>;
184
+ redirect(args: ChannelRedirectOptionsIface): Promise<ChannelRedirectIface>;
185
+ fetch(input: RequestInfo | URL, init?: ChannelCredentialRequestInitIface): Promise<Response>;
186
+ connect(args: ChannelCredentialConnectOptionsIface): Promise<ChannelCredentialSocketIface>;
129
187
  secret(name: string): Promise<string | null>;
130
- fetch: typeof fetch;
131
188
  }
132
189
  export interface ChannelPostArgsIface {
133
190
  from: PersonHandle;
@@ -202,6 +259,7 @@ export type SemanticEvent = {
202
259
  export interface ChannelReceiveContextIface<Config = JsonObject> {
203
260
  binding: {
204
261
  id: string;
262
+ url: string;
205
263
  owner: {
206
264
  kind: 'agent';
207
265
  definitionId: string;
@@ -236,30 +294,21 @@ export interface ChannelReceiveContextIface<Config = JsonObject> {
236
294
  create?: ChannelCreate | `${ChannelCreate}`;
237
295
  }): Promise<ConversationHandle>;
238
296
  disconnect(place: PlaceRef, by: PersonHandle): Promise<void>;
297
+ follow(place: PlaceRef, args: {
298
+ by: PersonHandle;
299
+ conversation: ConversationHandle;
300
+ ttlSeconds?: number;
301
+ }): Promise<void>;
302
+ unfollow(place: PlaceRef, args: {
303
+ by: PersonHandle;
304
+ conversation: ConversationHandle;
305
+ }): Promise<void>;
239
306
  };
240
307
  conversation(handle: ConversationHandle): ChannelConversationIface;
241
- observe(handle: ConversationHandle, args?: {
242
- turnId?: string;
308
+ observe(handle: ConversationHandle, args: {
309
+ turnId: string;
243
310
  signal?: AbortSignal;
244
311
  }): AsyncIterable<SemanticEvent>;
245
- media: {
246
- transcribe(audio: AsyncIterable<Uint8Array>, options: {
247
- encoding: string;
248
- sampleRate: number;
249
- language?: string;
250
- endpointing?: boolean;
251
- signal?: AbortSignal;
252
- }): AsyncIterable<{
253
- text: string;
254
- final: boolean;
255
- }>;
256
- synthesize(text: AsyncIterable<string>, options: {
257
- voice?: string;
258
- encoding: string;
259
- sampleRate: number;
260
- signal?: AbortSignal;
261
- }): AsyncIterable<Uint8Array>;
262
- };
263
312
  decisions: {
264
313
  resolve(args: {
265
314
  decisionId: string;
@@ -286,6 +335,19 @@ export interface ChannelReceiveContextIface<Config = JsonObject> {
286
335
  };
287
336
  log(message: string, details?: JsonObject): void;
288
337
  }
338
+ export interface ChannelSocketIface {
339
+ readonly signal: AbortSignal;
340
+ readonly messages: AsyncIterable<string | Uint8Array>;
341
+ accept(options?: {
342
+ protocol?: string;
343
+ }): void;
344
+ send(data: string | Uint8Array): void;
345
+ close(code?: number, reason?: string): void;
346
+ }
347
+ export interface ChannelTurnStateIface<State> {
348
+ get(): State | null;
349
+ set(state: State | null): void;
350
+ }
289
351
  export interface ChannelEventContextIface<Config = JsonObject, State = JsonValue> extends Pick<ChannelReceiveContextIface<Config>, 'binding' | 'config' | 'credentials' | 'store' | 'log'> {
290
352
  origin: OriginIface;
291
353
  conversation: ConversationHandle;
@@ -299,12 +361,12 @@ export interface ChannelEventContextIface<Config = JsonObject, State = JsonValue
299
361
  }
300
362
  export interface ChannelRouteContextIface<Config = JsonObject> extends ChannelReceiveContextIface<Config> {
301
363
  request: Request;
302
- authenticatedPrincipal?: PrincipalRef;
303
364
  receive(input: JsonValue): Promise<ChannelReceiveResult>;
304
365
  }
305
366
  export interface HttpChannelRouteDefinitionIface<Config = JsonObject> {
306
367
  method: 'GET' | 'POST' | 'PUT' | 'DELETE';
307
368
  path: string;
369
+ redirect?: boolean;
308
370
  handler(args: ChannelRouteContextIface<Config>): Promise<Response>;
309
371
  }
310
372
  export interface WebSocketChannelRouteDefinitionIface<Config = JsonObject> {
@@ -322,7 +384,6 @@ export type ChannelEventKind = keyof ChannelSemanticDataByKindIface;
322
384
  export interface ChannelDefinitionIface<Config = JsonObject, Inbound = JsonValue, State = JsonValue> {
323
385
  name: string;
324
386
  config?: Config;
325
- installed?: ProviderRef;
326
387
  configure?(config: Config): ChannelDefinitionIface<Config, Inbound, State>;
327
388
  credentials: {
328
389
  app: string | null;
@@ -347,6 +408,16 @@ export interface ChannelDefinitionIface<Config = JsonObject, Inbound = JsonValue
347
408
  kinds: readonly string[];
348
409
  defaults?(place: PlaceRef): PlaceDefaultsIface | null;
349
410
  };
411
+ resources?: {
412
+ authorize(args: {
413
+ place: PlaceRef;
414
+ principal: PrincipalRef;
415
+ }, ctx: ChannelReceiveContextIface<Config>): Promise<boolean>;
416
+ resolve(args: {
417
+ url: string;
418
+ principal: PrincipalRef;
419
+ }, ctx: ChannelReceiveContextIface<Config>): Promise<PlaceRef | null>;
420
+ };
350
421
  routes?: RouteDefinitionIface<Config>[];
351
422
  listeners?: {
352
423
  key: string;
@@ -1,6 +1,5 @@
1
1
  import * as z from "zod";
2
2
  import { jsonObjectSchema } from "./json.mjs";
3
- export * from "./room-surface.mjs";
4
3
  const personHandleSchema = z.string().min(1).brand();
5
4
  const conversationHandleSchema = z.string().min(1).brand();
6
5
  const principalRefSchema = z.object({
@@ -53,11 +52,40 @@ const channelReceiveResultSchema = z.union([
53
52
  z.object({ accepted: z.literal(false), refusal: refusalSchema }),
54
53
  z.object({ ignored: z.literal(true), reason: z.string() })
55
54
  ]);
55
+ var ChannelCredentialKind = /* @__PURE__ */ ((ChannelCredentialKind2) => {
56
+ ChannelCredentialKind2["App"] = "app";
57
+ ChannelCredentialKind2["OAuth"] = "oauth";
58
+ ChannelCredentialKind2["None"] = "none";
59
+ return ChannelCredentialKind2;
60
+ })(ChannelCredentialKind || {});
61
+ const channelCredentialHandleSchema = z.string().min(1).brand();
62
+ var ChannelSigningAlgorithm = /* @__PURE__ */ ((ChannelSigningAlgorithm2) => {
63
+ ChannelSigningAlgorithm2["HmacSha256"] = "hmac-sha256";
64
+ ChannelSigningAlgorithm2["HmacSha1"] = "hmac-sha1";
65
+ ChannelSigningAlgorithm2["Ed25519"] = "ed25519";
66
+ return ChannelSigningAlgorithm2;
67
+ })(ChannelSigningAlgorithm || {});
68
+ var ChannelSignatureEncoding = /* @__PURE__ */ ((ChannelSignatureEncoding2) => {
69
+ ChannelSignatureEncoding2["Hex"] = "hex";
70
+ ChannelSignatureEncoding2["Base64"] = "base64";
71
+ return ChannelSignatureEncoding2;
72
+ })(ChannelSignatureEncoding || {});
73
+ var ChannelOAuthClientAuthentication = /* @__PURE__ */ ((ChannelOAuthClientAuthentication2) => {
74
+ ChannelOAuthClientAuthentication2["Body"] = "body";
75
+ ChannelOAuthClientAuthentication2["Basic"] = "basic";
76
+ ChannelOAuthClientAuthentication2["None"] = "none";
77
+ return ChannelOAuthClientAuthentication2;
78
+ })(ChannelOAuthClientAuthentication || {});
56
79
  const defineChannel = (definition) => definition;
57
80
  export {
58
81
  ChannelAudience,
59
82
  ChannelCreate,
83
+ ChannelCredentialKind,
84
+ ChannelOAuthClientAuthentication,
60
85
  ChannelReplies,
86
+ ChannelSignatureEncoding,
87
+ ChannelSigningAlgorithm,
88
+ channelCredentialHandleSchema,
61
89
  channelReceiveResultSchema,
62
90
  conversationHandleSchema,
63
91
  defineChannel,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/channel.ts"],
4
- "sourcesContent": ["import type { ContentBlock } from '@agentclientprotocol/sdk/experimental/v2';\nimport * as z from 'zod';\nimport { jsonObjectSchema, type JsonObject, type JsonValue } from \"./json.mjs\";\nimport type { ProviderRef } from \"./provider-ref.mjs\";\nimport type { ChannelSocketIface, ChannelTurnStateIface } from \"./room-surface.mjs\";\nimport type { ChannelSemanticDataByKindIface } from \"./semantic-events.mjs\";\n\nexport * from \"./room-surface.mjs\";\n\n// Handles carry no authority until the platform validates their binding and invocation signature.\nexport const personHandleSchema = z.string().min(1).brand<'ChannelPerson'>();\nexport const conversationHandleSchema = z.string().min(1).brand<'ChannelConversation'>();\nexport type PersonHandle = z.infer<typeof personHandleSchema>;\nexport type ConversationHandle = z.infer<typeof conversationHandleSchema>;\n\nexport const principalRefSchema = z.object({\n id: z.string().min(1),\n tenant: z.string().min(1).optional(),\n displayName: z.string().optional(),\n});\nexport type PrincipalRef = z.infer<typeof principalRefSchema>;\nexport interface PlaceRef {\n kind: string;\n id: string;\n tenant?: string;\n parent?: PlaceRef;\n title?: string;\n}\nexport const placeRefSchema: z.ZodType<PlaceRef> = z.lazy(() =>\n z.object({\n kind: z.string().min(1),\n id: z.string().min(1),\n tenant: z.string().min(1).optional(),\n parent: placeRefSchema.optional(),\n title: z.string().optional(),\n }),\n);\nexport interface OriginIface {\n place: PlaceRef;\n ref?: JsonObject;\n}\nexport const originSchema = z.object({ place: placeRefSchema, ref: jsonObjectSchema.optional() });\n\nexport type PersonResolution =\n | { kind: 'member'; person: PersonHandle; displayName: string }\n | { kind: 'unlinked'; linkUrl: string }\n | { kind: 'blocked'; reason: 'not-in-organization' | 'suspended' };\nexport enum ChannelReplies {\n Origin = 'origin',\n All = 'all',\n}\nexport enum ChannelAudience {\n Members = 'members',\n Anyone = 'anyone',\n}\nexport enum ChannelCreate {\n DirectWithAgent = 'direct-with-agent',\n Group = 'group',\n}\nexport const placePolicySchema = z.object({\n replies: z.nativeEnum(ChannelReplies),\n audience: z.nativeEnum(ChannelAudience),\n});\nexport interface PlacePolicy {\n replies: ChannelReplies | `${ChannelReplies}`;\n audience: ChannelAudience | `${ChannelAudience}`;\n}\nexport interface PlaceDefaultsIface extends PlacePolicy {\n create: ChannelCreate | `${ChannelCreate}`;\n}\nexport type PlaceResolution =\n | { kind: 'connected'; conversation: ConversationHandle; policy: PlacePolicy }\n | { kind: 'unconnected'; connectUrl: string; defaults: PlaceDefaultsIface | null };\nexport interface Refusal {\n refused: 'unlinked' | 'no-access' | 'unconnected' | 'not-audience';\n linkUrl?: string;\n connectUrl?: string;\n message: string;\n}\nexport type ChannelReceiveResult =\n | { accepted: true }\n | { accepted: false; refusal: Refusal }\n | { ignored: true; reason: string };\nexport const refusalSchema = z.object({\n refused: z.union([\n z.literal('unlinked'),\n z.literal('no-access'),\n z.literal('unconnected'),\n z.literal('not-audience'),\n ]),\n linkUrl: z.string().optional(),\n connectUrl: z.string().optional(),\n message: z.string(),\n});\nexport const channelReceiveResultSchema = z.union([\n z.object({ accepted: z.literal(true) }),\n z.object({ accepted: z.literal(false), refusal: refusalSchema }),\n z.object({ ignored: z.literal(true), reason: z.string() }),\n]);\nexport interface InstalledAppInfoIface {\n clientId: string;\n clientSecret: string;\n signingSecret?: string;\n}\nexport interface InstalledAppCredential extends InstalledAppInfoIface {\n accessToken: string;\n tenantId?: string;\n externalId?: string;\n expiresAt?: string | null;\n customHeaders?: Record<string, string>;\n}\nexport interface ChannelCredentialsIface {\n // Installed app credentials and metadata are package-only; isolates use token-injecting fetch.\n appInfo(): Promise<InstalledAppInfoIface>;\n app(options?: { tenant?: string }): Promise<InstalledAppCredential>;\n // Explicitly declared project secrets are available in both execution modes.\n secret(name: string): Promise<string | null>;\n fetch: typeof fetch;\n}\nexport interface ChannelPostArgsIface {\n from: PersonHandle;\n content: ContentBlock[];\n context?: string[];\n origin: OriginIface;\n idempotencyKey: string;\n waitForAcceptance?: boolean;\n}\nexport interface ChannelConversationIface {\n post(args: ChannelPostArgsIface): Promise<{ messageId: string; turnId?: string } | Refusal>;\n input(args: {\n label: string;\n principal?: PrincipalRef;\n content: ContentBlock[];\n context?: string[];\n origin: OriginIface;\n idempotencyKey: string;\n waitForAcceptance?: boolean;\n }): Promise<{ inputId: string; turnId?: string } | Refusal>;\n attach(args: {\n origin: OriginIface;\n content: ContentBlock[];\n label: string;\n idempotencyKey: string;\n from?: PersonHandle;\n }): Promise<{ messageId: string } | Refusal>;\n edit(args: {\n externalKey: string;\n by: PersonHandle;\n content: ContentBlock[];\n }): Promise<{ messageId: string } | Refusal>;\n remove(args: { externalKey: string; by: PersonHandle }): Promise<{ removed: boolean } | Refusal>;\n react(args: {\n target: { externalKey: string } | { replyOf: { externalKey: string; turnId: string } };\n emoji: string;\n by: PersonHandle;\n op: 'add' | 'remove';\n }): Promise<{ ok: true } | Refusal>;\n}\nexport type SemanticEvent = {\n [Kind in keyof ChannelSemanticDataByKindIface]: {\n type: Kind;\n data: ChannelSemanticDataByKindIface[Kind];\n seq: number;\n };\n}[keyof ChannelSemanticDataByKindIface];\nexport interface ChannelReceiveContextIface<Config = JsonObject> {\n binding: {\n id: string;\n owner: { kind: 'agent'; definitionId: string } | { kind: 'install'; installId: string };\n };\n config: Config;\n credentials: ChannelCredentialsIface;\n people: {\n resolve(principal: PrincipalRef): Promise<PersonResolution>;\n identify(person: PersonHandle): Promise<PrincipalRef | null>;\n // Tenant-wide uninstall/revocation also disconnects that tenant's places.\n revoke(args: {\n principal?: PrincipalRef;\n tenant?: string;\n reason: 'deactivated' | 'uninstalled' | 'provider-revoked';\n }): Promise<void>;\n confirm(args: { ticket: string; principal: PrincipalRef }): Promise<{ linked: true } | Refusal>;\n };\n places: {\n // Explicit anyone/group defaults may create a Shared chat while resolving a new place.\n resolve(place: PlaceRef): Promise<PlaceResolution>;\n observers(place: PlaceRef): Promise<ConversationHandle[]>;\n connect(\n place: PlaceRef,\n to: {\n by: PersonHandle;\n conversation?: ConversationHandle;\n create?: ChannelCreate | `${ChannelCreate}`;\n },\n ): Promise<ConversationHandle>;\n disconnect(place: PlaceRef, by: PersonHandle): Promise<void>;\n };\n conversation(handle: ConversationHandle): ChannelConversationIface;\n observe(\n handle: ConversationHandle,\n args?: { turnId?: string; signal?: AbortSignal },\n ): AsyncIterable<SemanticEvent>;\n media: {\n transcribe(\n audio: AsyncIterable<Uint8Array>,\n options: {\n encoding: string;\n sampleRate: number;\n language?: string;\n endpointing?: boolean;\n signal?: AbortSignal;\n },\n ): AsyncIterable<{ text: string; final: boolean }>;\n synthesize(\n text: AsyncIterable<string>,\n options: { voice?: string; encoding: string; sampleRate: number; signal?: AbortSignal },\n ): AsyncIterable<Uint8Array>;\n };\n decisions: {\n resolve(args: {\n decisionId: string;\n outcome: JsonValue;\n by: PersonHandle;\n }): Promise<{ resolved: boolean } | Refusal>;\n };\n turns: {\n cancel(args: {\n conversation: ConversationHandle;\n by?: PersonHandle;\n turnId?: string;\n }): Promise<{ accepted: boolean } | Refusal>;\n };\n store: {\n get(key: string): Promise<JsonValue | null>;\n set(key: string, value: JsonValue | null, options?: { ttlSeconds?: number }): Promise<void>;\n };\n log(message: string, details?: JsonObject): void;\n}\nexport interface ChannelEventContextIface<Config = JsonObject, State = JsonValue> extends Pick<\n ChannelReceiveContextIface<Config>,\n 'binding' | 'config' | 'credentials' | 'store' | 'log'\n> {\n origin: OriginIface;\n conversation: ConversationHandle;\n turn: { id: string; agent: { displayName: string } };\n state: ChannelTurnStateIface<State>;\n}\nexport interface ChannelRouteContextIface<\n Config = JsonObject,\n> extends ChannelReceiveContextIface<Config> {\n request: Request;\n authenticatedPrincipal?: PrincipalRef;\n receive(input: JsonValue): Promise<ChannelReceiveResult>;\n}\nexport interface HttpChannelRouteDefinitionIface<Config = JsonObject> {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE';\n path: string;\n handler(args: ChannelRouteContextIface<Config>): Promise<Response>;\n}\nexport interface WebSocketChannelRouteDefinitionIface<Config = JsonObject> {\n method: 'WS';\n path: string;\n handler(\n args: ChannelRouteContextIface<Config> & { socket: ChannelSocketIface },\n ): Promise<Response | void>;\n}\nexport type RouteDefinitionIface<Config = JsonObject> =\n | HttpChannelRouteDefinitionIface<Config>\n | WebSocketChannelRouteDefinitionIface<Config>;\nexport type ChannelEventHandlersIface<Config, State> = {\n [Kind in keyof ChannelSemanticDataByKindIface]?: (\n data: ChannelSemanticDataByKindIface[Kind],\n ctx: ChannelEventContextIface<Config, State>,\n ) => Promise<void>;\n};\nexport type ChannelEventKind = keyof ChannelSemanticDataByKindIface;\nexport interface ChannelDefinitionIface<\n Config = JsonObject,\n Inbound = JsonValue,\n State = JsonValue,\n> {\n name: string;\n config?: Config;\n installed?: ProviderRef;\n configure?(config: Config): ChannelDefinitionIface<Config, Inbound, State>;\n credentials: { app: string | null; secrets?: string[] };\n identity:\n | {\n kind: 'redirect';\n start(\n args: { ticket: string; principal: PrincipalRef },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<URL>;\n }\n | {\n kind: 'challenge';\n deliver(\n args: { principal: PrincipalRef; code: string },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<void>;\n }\n | { kind: 'none' };\n places: { kinds: readonly string[]; defaults?(place: PlaceRef): PlaceDefaultsIface | null };\n routes?: RouteDefinitionIface<Config>[];\n listeners?: {\n key: string;\n run(ctx: ChannelReceiveContextIface<Config> & { signal: AbortSignal }): Promise<void>;\n }[];\n receive(input: Inbound, ctx: ChannelReceiveContextIface<Config>): Promise<ChannelReceiveResult>;\n events?: ChannelEventHandlersIface<Config, State>;\n}\nexport const defineChannel = <Config = JsonObject, Inbound = JsonValue, State = JsonValue>(\n definition: ChannelDefinitionIface<Config, Inbound, State>,\n): ChannelDefinitionIface<Config, Inbound, State> => definition;\n"],
5
- "mappings": "AACA,YAAY,OAAO;AACnB,SAAS,wBAAyD;AAKlE,cAAc;AAGP,MAAM,qBAAqB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAuB;AACpE,MAAM,2BAA2B,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAA6B;AAIhF,MAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACpB,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACnC,aAAa,EAAE,OAAO,EAAE,SAAS;AACnC,CAAC;AASM,MAAM,iBAAsC,EAAE;AAAA,EAAK,MACxD,EAAE,OAAO;AAAA,IACP,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,IACtB,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,IACpB,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,EAA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O,EAAE,CAAC;AAC3D,CAAC;AAqNM,MAAM,gBAAgB,CAC3B,eACmD;",
6
- "names": ["ChannelReplies", "ChannelAudience", "ChannelCreate"]
4
+ "sourcesContent": ["import type { ContentBlock } from '@agentclientprotocol/sdk/experimental/v2';\nimport * as z from 'zod';\nimport { jsonObjectSchema, type JsonObject, type JsonValue } from \"./json.mjs\";\nimport type { ChannelSemanticDataByKindIface } from \"./semantic-events.mjs\";\n\n// Handles carry no authority until the platform validates their binding and invocation signature.\nexport const personHandleSchema = z.string().min(1).brand<'ChannelPerson'>();\nexport const conversationHandleSchema = z.string().min(1).brand<'ChannelConversation'>();\nexport type PersonHandle = z.infer<typeof personHandleSchema>;\nexport type ConversationHandle = z.infer<typeof conversationHandleSchema>;\n\nexport const principalRefSchema = z.object({\n id: z.string().min(1),\n tenant: z.string().min(1).optional(),\n displayName: z.string().optional(),\n});\nexport type PrincipalRef = z.infer<typeof principalRefSchema>;\nexport interface PlaceRef {\n kind: string;\n id: string;\n tenant?: string;\n parent?: PlaceRef;\n title?: string;\n}\nexport const placeRefSchema: z.ZodType<PlaceRef> = z.lazy(() =>\n z.object({\n kind: z.string().min(1),\n id: z.string().min(1),\n tenant: z.string().min(1).optional(),\n parent: placeRefSchema.optional(),\n title: z.string().optional(),\n }),\n);\nexport interface OriginIface {\n place: PlaceRef;\n ref?: JsonObject;\n}\nexport const originSchema = z.object({ place: placeRefSchema, ref: jsonObjectSchema.optional() });\n\nexport type PersonResolution =\n | { kind: 'member'; person: PersonHandle; displayName: string }\n | { kind: 'unlinked'; linkUrl: string }\n | { kind: 'blocked'; reason: 'not-in-organization' | 'suspended' };\nexport enum ChannelReplies {\n Origin = 'origin',\n All = 'all',\n}\nexport enum ChannelAudience {\n Members = 'members',\n Anyone = 'anyone',\n}\nexport enum ChannelCreate {\n DirectWithAgent = 'direct-with-agent',\n Group = 'group',\n}\nexport const placePolicySchema = z.object({\n replies: z.nativeEnum(ChannelReplies),\n audience: z.nativeEnum(ChannelAudience),\n});\nexport interface PlacePolicy {\n replies: ChannelReplies | `${ChannelReplies}`;\n audience: ChannelAudience | `${ChannelAudience}`;\n}\nexport interface PlaceDefaultsIface extends PlacePolicy {\n create: ChannelCreate | `${ChannelCreate}`;\n}\nexport type PlaceResolution =\n | { kind: 'connected'; conversation: ConversationHandle; policy: PlacePolicy }\n | { kind: 'unconnected'; connectUrl: string; defaults: PlaceDefaultsIface | null };\nexport interface Refusal {\n refused: 'unlinked' | 'no-access' | 'unconnected' | 'not-audience';\n linkUrl?: string;\n connectUrl?: string;\n message: string;\n}\nexport type ChannelReceiveResult =\n | { accepted: true }\n | { accepted: false; refusal: Refusal }\n | { ignored: true; reason: string };\nexport const refusalSchema = z.object({\n refused: z.union([\n z.literal('unlinked'),\n z.literal('no-access'),\n z.literal('unconnected'),\n z.literal('not-audience'),\n ]),\n linkUrl: z.string().optional(),\n connectUrl: z.string().optional(),\n message: z.string(),\n});\nexport const channelReceiveResultSchema = z.union([\n z.object({ accepted: z.literal(true) }),\n z.object({ accepted: z.literal(false), refusal: refusalSchema }),\n z.object({ ignored: z.literal(true), reason: z.string() }),\n]);\nexport enum ChannelCredentialKind {\n App = 'app',\n OAuth = 'oauth',\n None = 'none',\n}\nexport const channelCredentialHandleSchema = z.string().min(1).brand<'ChannelCredential'>();\nexport type ChannelCredentialHandle = z.infer<typeof channelCredentialHandleSchema>;\nexport type ChannelCredentialRef =\n | { kind: ChannelCredentialKind.App; tenant?: string }\n | { kind: ChannelCredentialKind.OAuth; handle: ChannelCredentialHandle }\n | { kind: ChannelCredentialKind.None };\nexport enum ChannelSigningAlgorithm {\n HmacSha256 = 'hmac-sha256',\n HmacSha1 = 'hmac-sha1',\n Ed25519 = 'ed25519',\n}\nexport enum ChannelSignatureEncoding {\n Hex = 'hex',\n Base64 = 'base64',\n}\nexport enum ChannelOAuthClientAuthentication {\n Body = 'body',\n Basic = 'basic',\n None = 'none',\n}\nexport interface ChannelCredentialRequestInitIface extends RequestInit {\n credential?: ChannelCredentialRef;\n}\nexport interface ChannelVerifyOptionsIface {\n algorithm: ChannelSigningAlgorithm;\n encoding: ChannelSignatureEncoding;\n data: string;\n signature: string;\n}\nexport interface ChannelOAuthExchangeOptionsIface {\n url: string;\n parameters: Record<string, string>;\n authentication: ChannelOAuthClientAuthentication;\n clientId?: string;\n signal?: AbortSignal;\n}\nexport interface ChannelRedirectOptionsIface {\n // A GET route of this channel declared with `redirect: true`.\n path: string;\n}\nexport interface ChannelRedirectIface {\n url: string;\n state: string;\n}\nexport interface ChannelCredentialConnectOptionsIface {\n url: string;\n signal?: AbortSignal;\n}\nexport interface ChannelCredentialInjectionIface {\n path: string[];\n credential: ChannelCredentialRef;\n}\nexport interface ChannelCredentialSocketIface {\n messages: AsyncIterable<string | Uint8Array>;\n send(\n data: string | Uint8Array,\n options?: { inject?: ChannelCredentialInjectionIface[] },\n ): Promise<void>;\n close(code?: number, reason?: string): Promise<void>;\n closeCode(): number | null;\n}\nexport interface ChannelCredentialsIface {\n // Installed credentials stay with the host in every execution mode.\n client(): Promise<{ clientId: string }>;\n verify(args: ChannelVerifyOptionsIface): Promise<boolean>;\n exchange(args: ChannelOAuthExchangeOptionsIface): Promise<ChannelCredentialHandle>;\n // Send `url` as the OAuth redirect URI and `state` unchanged. `url` is the same for every\n // binding, so a provider application registers it once; `state` returns to this binding.\n redirect(args: ChannelRedirectOptionsIface): Promise<ChannelRedirectIface>;\n // Requests without an explicit credential are unauthenticated.\n fetch(input: RequestInfo | URL, init?: ChannelCredentialRequestInitIface): Promise<Response>;\n connect(args: ChannelCredentialConnectOptionsIface): Promise<ChannelCredentialSocketIface>;\n // Only explicitly declared project secrets can be read by authored code.\n secret(name: string): Promise<string | null>;\n}\nexport interface ChannelPostArgsIface {\n from: PersonHandle;\n content: ContentBlock[];\n context?: string[];\n origin: OriginIface;\n idempotencyKey: string;\n waitForAcceptance?: boolean;\n}\nexport interface ChannelConversationIface {\n post(args: ChannelPostArgsIface): Promise<{ messageId: string; turnId?: string } | Refusal>;\n input(args: {\n label: string;\n principal?: PrincipalRef;\n content: ContentBlock[];\n context?: string[];\n origin: OriginIface;\n idempotencyKey: string;\n waitForAcceptance?: boolean;\n }): Promise<{ inputId: string; turnId?: string } | Refusal>;\n attach(args: {\n origin: OriginIface;\n content: ContentBlock[];\n label: string;\n idempotencyKey: string;\n from?: PersonHandle;\n }): Promise<{ messageId: string } | Refusal>;\n edit(args: {\n externalKey: string;\n by: PersonHandle;\n content: ContentBlock[];\n }): Promise<{ messageId: string } | Refusal>;\n remove(args: { externalKey: string; by: PersonHandle }): Promise<{ removed: boolean } | Refusal>;\n react(args: {\n target: { externalKey: string } | { replyOf: { externalKey: string; turnId: string } };\n emoji: string;\n by: PersonHandle;\n op: 'add' | 'remove';\n }): Promise<{ ok: true } | Refusal>;\n}\nexport type SemanticEvent = {\n [Kind in keyof ChannelSemanticDataByKindIface]: {\n type: Kind;\n data: ChannelSemanticDataByKindIface[Kind];\n seq: number;\n };\n}[keyof ChannelSemanticDataByKindIface];\nexport interface ChannelReceiveContextIface<Config = JsonObject> {\n binding: {\n id: string;\n url: string;\n owner: { kind: 'agent'; definitionId: string } | { kind: 'install'; installId: string };\n };\n config: Config;\n credentials: ChannelCredentialsIface;\n people: {\n resolve(principal: PrincipalRef): Promise<PersonResolution>;\n identify(person: PersonHandle): Promise<PrincipalRef | null>;\n // Tenant-wide uninstall/revocation also disconnects that tenant's places.\n revoke(args: {\n principal?: PrincipalRef;\n tenant?: string;\n reason: 'deactivated' | 'uninstalled' | 'provider-revoked';\n }): Promise<void>;\n confirm(args: { ticket: string; principal: PrincipalRef }): Promise<{ linked: true } | Refusal>;\n };\n places: {\n // Explicit anyone/group defaults may create a Shared chat while resolving a new place.\n resolve(place: PlaceRef): Promise<PlaceResolution>;\n observers(place: PlaceRef): Promise<ConversationHandle[]>;\n connect(\n place: PlaceRef,\n to: {\n by: PersonHandle;\n conversation?: ConversationHandle;\n create?: ChannelCreate | `${ChannelCreate}`;\n },\n ): Promise<ConversationHandle>;\n disconnect(place: PlaceRef, by: PersonHandle): Promise<void>;\n follow(\n place: PlaceRef,\n args: { by: PersonHandle; conversation: ConversationHandle; ttlSeconds?: number },\n ): Promise<void>;\n unfollow(\n place: PlaceRef,\n args: { by: PersonHandle; conversation: ConversationHandle },\n ): Promise<void>;\n };\n conversation(handle: ConversationHandle): ChannelConversationIface;\n observe(\n handle: ConversationHandle,\n args: { turnId: string; signal?: AbortSignal },\n ): AsyncIterable<SemanticEvent>;\n decisions: {\n resolve(args: {\n decisionId: string;\n outcome: JsonValue;\n by: PersonHandle;\n }): Promise<{ resolved: boolean } | Refusal>;\n };\n turns: {\n cancel(args: {\n conversation: ConversationHandle;\n by?: PersonHandle;\n turnId?: string;\n }): Promise<{ accepted: boolean } | Refusal>;\n };\n store: {\n get(key: string): Promise<JsonValue | null>;\n set(key: string, value: JsonValue | null, options?: { ttlSeconds?: number }): Promise<void>;\n };\n log(message: string, details?: JsonObject): void;\n}\nexport interface ChannelSocketIface {\n readonly signal: AbortSignal;\n readonly messages: AsyncIterable<string | Uint8Array>;\n // Authenticate the request before accepting. The selected protocol must have been offered.\n accept(options?: { protocol?: string }): void;\n send(data: string | Uint8Array): void;\n close(code?: number, reason?: string): void;\n}\n// State starts null and persists for the callbacks of one turn.\nexport interface ChannelTurnStateIface<State> {\n get(): State | null;\n set(state: State | null): void;\n}\nexport interface ChannelEventContextIface<Config = JsonObject, State = JsonValue> extends Pick<\n ChannelReceiveContextIface<Config>,\n 'binding' | 'config' | 'credentials' | 'store' | 'log'\n> {\n origin: OriginIface;\n conversation: ConversationHandle;\n turn: { id: string; agent: { displayName: string } };\n state: ChannelTurnStateIface<State>;\n}\nexport interface ChannelRouteContextIface<\n Config = JsonObject,\n> extends ChannelReceiveContextIface<Config> {\n request: Request;\n receive(input: JsonValue): Promise<ChannelReceiveResult>;\n}\nexport interface HttpChannelRouteDefinitionIface<Config = JsonObject> {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE';\n path: string;\n // Served only for a provider returning with `credentials.redirect` state.\n redirect?: boolean;\n handler(args: ChannelRouteContextIface<Config>): Promise<Response>;\n}\nexport interface WebSocketChannelRouteDefinitionIface<Config = JsonObject> {\n method: 'WS';\n path: string;\n handler(\n args: ChannelRouteContextIface<Config> & { socket: ChannelSocketIface },\n ): Promise<Response | void>;\n}\nexport type RouteDefinitionIface<Config = JsonObject> =\n | HttpChannelRouteDefinitionIface<Config>\n | WebSocketChannelRouteDefinitionIface<Config>;\nexport type ChannelEventHandlersIface<Config, State> = {\n [Kind in keyof ChannelSemanticDataByKindIface]?: (\n data: ChannelSemanticDataByKindIface[Kind],\n ctx: ChannelEventContextIface<Config, State>,\n ) => Promise<void>;\n};\nexport type ChannelEventKind = keyof ChannelSemanticDataByKindIface;\nexport interface ChannelDefinitionIface<\n Config = JsonObject,\n Inbound = JsonValue,\n State = JsonValue,\n> {\n name: string;\n config?: Config;\n configure?(config: Config): ChannelDefinitionIface<Config, Inbound, State>;\n credentials: { app: string | null; secrets?: string[] };\n identity:\n | {\n kind: 'redirect';\n start(\n args: { ticket: string; principal: PrincipalRef },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<URL>;\n }\n | {\n kind: 'challenge';\n deliver(\n args: { principal: PrincipalRef; code: string },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<void>;\n }\n | { kind: 'none' };\n places: { kinds: readonly string[]; defaults?(place: PlaceRef): PlaceDefaultsIface | null };\n resources?: {\n authorize(\n args: { place: PlaceRef; principal: PrincipalRef },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<boolean>;\n resolve(\n args: { url: string; principal: PrincipalRef },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<PlaceRef | null>;\n };\n routes?: RouteDefinitionIface<Config>[];\n listeners?: {\n key: string;\n run(ctx: ChannelReceiveContextIface<Config> & { signal: AbortSignal }): Promise<void>;\n }[];\n receive(input: Inbound, ctx: ChannelReceiveContextIface<Config>): Promise<ChannelReceiveResult>;\n events?: ChannelEventHandlersIface<Config, State>;\n}\nexport const defineChannel = <Config = JsonObject, Inbound = JsonValue, State = JsonValue>(\n definition: ChannelDefinitionIface<Config, Inbound, State>,\n): ChannelDefinitionIface<Config, Inbound, State> => definition;\n"],
5
+ "mappings": "AACA,YAAY,OAAO;AACnB,SAAS,wBAAyD;AAI3D,MAAM,qBAAqB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAuB;AACpE,MAAM,2BAA2B,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAA6B;AAIhF,MAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACpB,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACnC,aAAa,EAAE,OAAO,EAAE,SAAS;AACnC,CAAC;AASM,MAAM,iBAAsC,EAAE;AAAA,EAAK,MACxD,EAAE,OAAO;AAAA,IACP,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,IACtB,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,IACpB,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,IACnC,QAAQ,eAAe,SAAS;AAAA,IAChC,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,CAAC;AACH;AAKO,MAAM,eAAe,EAAE,OAAO,EAAE,OAAO,gBAAgB,KAAK,iBAAiB,SAAS,EAAE,CAAC;AAMzF,IAAK,iBAAL,kBAAKA,oBAAL;AACL,EAAAA,gBAAA,YAAS;AACT,EAAAA,gBAAA,SAAM;AAFI,SAAAA;AAAA,GAAA;AAIL,IAAK,kBAAL,kBAAKC,qBAAL;AACL,EAAAA,iBAAA,aAAU;AACV,EAAAA,iBAAA,YAAS;AAFC,SAAAA;AAAA,GAAA;AAIL,IAAK,gBAAL,kBAAKC,mBAAL;AACL,EAAAA,eAAA,qBAAkB;AAClB,EAAAA,eAAA,WAAQ;AAF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,sCAAL;AACL,EAAAA,kCAAA,UAAO;AACP,EAAAA,kCAAA,WAAQ;AACR,EAAAA,kCAAA,UAAO;AAHG,SAAAA;AAAA,GAAA;AA4QL,MAAM,gBAAgB,CAC3B,eACmD;",
6
+ "names": ["ChannelReplies", "ChannelAudience", "ChannelCreate", "ChannelCredentialKind", "ChannelSigningAlgorithm", "ChannelSignatureEncoding", "ChannelOAuthClientAuthentication"]
7
7
  }
@@ -7,6 +7,7 @@ export * from "./hosted-bindings.mjs";
7
7
  export * from "./json.mjs";
8
8
  export * from "./manifest.mjs";
9
9
  export * from "./provider-ref.mjs";
10
+ export * from "./room-surface.mjs";
10
11
  export * from "./sandbox/open-scope.mjs";
11
12
  export * from "./sandbox/types.mjs";
12
13
  export * from "./schemas.mjs";
@@ -14,6 +14,7 @@ export * from "./hosted-bindings.mjs";
14
14
  export * from "./json.mjs";
15
15
  export * from "./manifest.mjs";
16
16
  export * from "./provider-ref.mjs";
17
+ export * from "./room-surface.mjs";
17
18
  export * from "./sandbox/open-scope.mjs";
18
19
  export * from "./sandbox/types.mjs";
19
20
  export * from "./schemas.mjs";
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/index.ts"],
4
- "sourcesContent": ["export {\n ProcessInspectionOperation,\n inspectedProcessSchema,\n processInspectionDetailSchema,\n processInspectionPageSchema,\n processInspectionRequestSchema,\n processInspectionResultSchema,\n type InspectedProcessIface,\n type ProcessInspectionDetailIface,\n type ProcessInspectionPageIface,\n type ProcessInspectionRequestIface,\n type ProcessInspectionResultIface,\n} from '@finalai/agent-protocol/process-inspection';\nexport * from \"./channel.mjs\";\nexport * from \"./credentials.mjs\";\nexport * from \"./dynamic.mjs\";\nexport * from \"./harness.mjs\";\nexport * from \"./hosted-bindings.mjs\";\nexport * from \"./json.mjs\";\nexport * from \"./manifest.mjs\";\nexport * from \"./provider-ref.mjs\";\nexport * from \"./sandbox/open-scope.mjs\";\nexport * from \"./sandbox/types.mjs\";\nexport * from \"./schemas.mjs\";\nexport * from \"./tool-annotations.mjs\";\nexport * from \"./tool-patterns.mjs\";\n\nexport * from \"./semantic-events.mjs\";\n\nexport * from \"./sandbox/snapshots.mjs\";\n\nexport {\n SandboxEditorOperation,\n sandboxEditorRequestSchema,\n sandboxEditorResultSchema,\n sandboxEditorSessionSchema,\n type SandboxEditorRequestIface,\n type SandboxEditorResultIface,\n type SandboxEditorSessionIface,\n} from \"./sandbox/editor.mjs\";\n"],
5
- "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;",
4
+ "sourcesContent": ["export {\n ProcessInspectionOperation,\n inspectedProcessSchema,\n processInspectionDetailSchema,\n processInspectionPageSchema,\n processInspectionRequestSchema,\n processInspectionResultSchema,\n type InspectedProcessIface,\n type ProcessInspectionDetailIface,\n type ProcessInspectionPageIface,\n type ProcessInspectionRequestIface,\n type ProcessInspectionResultIface,\n} from '@finalai/agent-protocol/process-inspection';\nexport * from \"./channel.mjs\";\nexport * from \"./credentials.mjs\";\nexport * from \"./dynamic.mjs\";\nexport * from \"./harness.mjs\";\nexport * from \"./hosted-bindings.mjs\";\nexport * from \"./json.mjs\";\nexport * from \"./manifest.mjs\";\nexport * from \"./provider-ref.mjs\";\nexport * from \"./room-surface.mjs\";\nexport * from \"./sandbox/open-scope.mjs\";\nexport * from \"./sandbox/types.mjs\";\nexport * from \"./schemas.mjs\";\nexport * from \"./tool-annotations.mjs\";\nexport * from \"./tool-patterns.mjs\";\n\nexport * from \"./semantic-events.mjs\";\n\nexport * from \"./sandbox/snapshots.mjs\";\n\nexport {\n SandboxEditorOperation,\n sandboxEditorRequestSchema,\n sandboxEditorResultSchema,\n sandboxEditorSessionSchema,\n type SandboxEditorRequestIface,\n type SandboxEditorResultIface,\n type SandboxEditorSessionIface,\n} from \"./sandbox/editor.mjs\";\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;",
6
6
  "names": []
7
7
  }
@@ -1,10 +1,10 @@
1
- import type { ChannelReceiveContextIface, InstalledAppCredential, InstalledAppInfoIface } from "./channel.mjs";
1
+ import type { ChannelReceiveContextIface, ChannelCredentialsIface } from "./channel.mjs";
2
2
  import type { JsonObject } from "./json.mjs";
3
3
  export interface LocalChannelContextOptionsIface {
4
4
  config?: JsonObject;
5
5
  secret(name: string): Promise<string | null>;
6
- app?: InstalledAppCredential;
7
- appInfo?: InstalledAppInfoIface;
6
+ credentials?: ChannelCredentialsIface;
7
+ url?: string;
8
8
  fetch?: typeof fetch;
9
9
  }
10
10
  export declare const createLocalChannelContext: (options: LocalChannelContextOptionsIface) => ChannelReceiveContextIface;
@@ -5,21 +5,33 @@ const createLocalChannelContext = (options) => {
5
5
  const noStream = () => ({
6
6
  [Symbol.asyncIterator]: () => ({ next: async () => unavailable() })
7
7
  });
8
+ const credentials = options.credentials ?? {
9
+ client: async () => unavailable(),
10
+ verify: async () => unavailable(),
11
+ exchange: async () => unavailable(),
12
+ redirect: async () => unavailable(),
13
+ connect: async () => unavailable(),
14
+ secret: options.secret,
15
+ fetch: async (input, init) => {
16
+ if (init?.credential != null && init.credential.kind !== "none") return unavailable();
17
+ return (options.fetch ?? globalThis.fetch)(input, { ...init, redirect: "manual" });
18
+ }
19
+ };
8
20
  return {
9
- binding: { id: "local", owner: { kind: "agent", definitionId: "local" } },
21
+ binding: {
22
+ id: "local",
23
+ url: options.url ?? "http://localhost",
24
+ owner: { kind: "agent", definitionId: "local" }
25
+ },
10
26
  config: options.config ?? {},
11
27
  credentials: {
12
- appInfo: async () => {
13
- const app = options.appInfo ?? options.app ?? unavailable();
14
- return {
15
- clientId: app.clientId,
16
- clientSecret: app.clientSecret,
17
- ...app.signingSecret == null ? {} : { signingSecret: app.signingSecret }
18
- };
19
- },
20
- app: async () => options.app ?? unavailable(),
21
- secret: options.secret,
22
- fetch: options.fetch ?? globalThis.fetch
28
+ client: () => credentials.client(),
29
+ verify: (value) => credentials.verify(value),
30
+ exchange: (value) => credentials.exchange(value),
31
+ redirect: (value) => credentials.redirect(value),
32
+ connect: (value) => credentials.connect(value),
33
+ fetch: (input, init) => credentials.fetch(input, init),
34
+ secret: options.secret
23
35
  },
24
36
  people: {
25
37
  resolve: async () => unavailable(),
@@ -31,7 +43,9 @@ const createLocalChannelContext = (options) => {
31
43
  resolve: async () => unavailable(),
32
44
  observers: async () => unavailable(),
33
45
  connect: async () => unavailable(),
34
- disconnect: async () => unavailable()
46
+ disconnect: async () => unavailable(),
47
+ follow: async () => unavailable(),
48
+ unfollow: async () => unavailable()
35
49
  },
36
50
  conversation: () => ({
37
51
  post: async () => unavailable(),
@@ -42,7 +56,6 @@ const createLocalChannelContext = (options) => {
42
56
  react: async () => unavailable()
43
57
  }),
44
58
  observe: noStream,
45
- media: { transcribe: noStream, synthesize: noStream },
46
59
  decisions: { resolve: async () => unavailable() },
47
60
  turns: { cancel: async () => unavailable() },
48
61
  store: { get: async () => unavailable(), set: async () => unavailable() },
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/local-channel-context.ts"],
4
- "sourcesContent": ["import type {\n ChannelReceiveContextIface,\n InstalledAppCredential,\n InstalledAppInfoIface,\n} from \"./channel.mjs\";\nimport type { JsonObject } from \"./json.mjs\";\nexport interface LocalChannelContextOptionsIface {\n config?: JsonObject;\n secret(name: string): Promise<string | null>;\n app?: InstalledAppCredential;\n appInfo?: InstalledAppInfoIface;\n fetch?: typeof fetch;\n}\n// Local route previews can validate and log ingress; authenticated platform operations require a host.\nexport const createLocalChannelContext = (\n options: LocalChannelContextOptionsIface,\n): ChannelReceiveContextIface => {\n const unavailable = (): never => {\n throw new Error('This channel operation needs an authenticated Final host.');\n };\n const noStream = (): AsyncIterable<never> => ({\n [Symbol.asyncIterator]: () => ({ next: async () => unavailable() }),\n });\n return {\n binding: { id: 'local', owner: { kind: 'agent', definitionId: 'local' } },\n config: options.config ?? {},\n credentials: {\n appInfo: async () => {\n const app = options.appInfo ?? options.app ?? unavailable();\n return {\n clientId: app.clientId,\n clientSecret: app.clientSecret,\n ...(app.signingSecret == null ? {} : { signingSecret: app.signingSecret }),\n };\n },\n app: async () => options.app ?? unavailable(),\n secret: options.secret,\n fetch: options.fetch ?? globalThis.fetch,\n },\n people: {\n resolve: async () => unavailable(),\n identify: async () => unavailable(),\n confirm: async () => unavailable(),\n revoke: async () => unavailable(),\n },\n places: {\n resolve: async () => unavailable(),\n observers: async () => unavailable(),\n connect: async () => unavailable(),\n disconnect: async () => unavailable(),\n },\n conversation: () => ({\n post: async () => unavailable(),\n input: async () => unavailable(),\n attach: async () => unavailable(),\n edit: async () => unavailable(),\n remove: async () => unavailable(),\n react: async () => unavailable(),\n }),\n observe: noStream,\n media: { transcribe: noStream, synthesize: noStream },\n decisions: { resolve: async () => unavailable() },\n turns: { cancel: async () => unavailable() },\n store: { get: async () => unavailable(), set: async () => unavailable() },\n log: () => undefined,\n };\n};\n"],
5
- "mappings": "AAcO,MAAM,4BAA4B,CACvC,YAC+B;AAC/B,QAAM,cAAc,MAAa;AAC/B,UAAM,IAAI,MAAM,2DAA2D;AAAA,EA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YAAY,EAAE;AAAA,IAChD,OAAO,EAAE,QAAQ,YAAY,YAAY,EAAE;AAAA,IAC3C,OAAO,EAAE,KAAK,YAAY,YAAY,GAAG,KAAK,YAAY,YAAY,EAAE;AAAA,IACxE,KAAK,MAAM;AAAA,EACb;AACF;",
4
+ "sourcesContent": ["import type { ChannelReceiveContextIface, ChannelCredentialsIface } from \"./channel.mjs\";\nimport type { JsonObject } from \"./json.mjs\";\nexport interface LocalChannelContextOptionsIface {\n config?: JsonObject;\n secret(name: string): Promise<string | null>;\n credentials?: ChannelCredentialsIface;\n url?: string;\n fetch?: typeof fetch;\n}\n// Local route previews can validate and log ingress; authenticated platform operations require a host.\nexport const createLocalChannelContext = (\n options: LocalChannelContextOptionsIface,\n): ChannelReceiveContextIface => {\n const unavailable = (): never => {\n throw new Error('This channel operation needs an authenticated Final host.');\n };\n const noStream = (): AsyncIterable<never> => ({\n [Symbol.asyncIterator]: () => ({ next: async () => unavailable() }),\n });\n const credentials: ChannelCredentialsIface = options.credentials ?? {\n client: async () => unavailable(),\n verify: async () => unavailable(),\n exchange: async () => unavailable(),\n redirect: async () => unavailable(),\n connect: async () => unavailable(),\n secret: options.secret,\n fetch: async (input, init) => {\n if (init?.credential != null && init.credential.kind !== 'none') return unavailable();\n return (options.fetch ?? globalThis.fetch)(input, { ...init, redirect: 'manual' });\n },\n };\n return {\n binding: {\n id: 'local',\n url: options.url ?? 'http://localhost',\n owner: { kind: 'agent', definitionId: 'local' },\n },\n config: options.config ?? {},\n credentials: {\n client: () => credentials.client(),\n verify: (value) => credentials.verify(value),\n exchange: (value) => credentials.exchange(value),\n redirect: (value) => credentials.redirect(value),\n connect: (value) => credentials.connect(value),\n fetch: (input, init) => credentials.fetch(input, init),\n secret: options.secret,\n },\n people: {\n resolve: async () => unavailable(),\n identify: async () => unavailable(),\n confirm: async () => unavailable(),\n revoke: async () => unavailable(),\n },\n places: {\n resolve: async () => unavailable(),\n observers: async () => unavailable(),\n connect: async () => unavailable(),\n disconnect: async () => unavailable(),\n follow: async () => unavailable(),\n unfollow: async () => unavailable(),\n },\n conversation: () => ({\n post: async () => unavailable(),\n input: async () => unavailable(),\n attach: async () => unavailable(),\n edit: async () => unavailable(),\n remove: async () => unavailable(),\n react: async () => unavailable(),\n }),\n observe: noStream,\n decisions: { resolve: async () => unavailable() },\n turns: { cancel: async () => unavailable() },\n store: { get: async () => unavailable(), set: async () => unavailable() },\n log: () => undefined,\n };\n};\n"],
5
+ "mappings": "AAUO,MAAM,4BAA4B,CACvC,YAC+B;AAC/B,QAAM,cAAc,MAAa;AAC/B,UAAM,IAAI,MAAM,2DAA2D;AAAA,EAC7E;AACA,QAAM,WAAW,OAA6B;AAAA,IAC5C,CAAC,OAAO,aAAa,GAAG,OAAO,EAAE,MAAM,YAAY,YAAY,EAAE;AAAA,EACnE;AACA,QAAM,cAAuC,QAAQ,eAAe;AAAA,IAClE,QAAQ,YAAY,YAAY;AAAA,IAChC,QAAQ,YAAY,YAAY;AAAA,IAChC,UAAU,YAAY,YAAY;AAAA,IAClC,UAAU,YAAY,YAAY;AAAA,IAClC,SAAS,YAAY,YAAY;AAAA,IACjC,QAAQ,QAAQ;AAAA,IAChB,OAAO,OAAO,OAAO,SAAS;AAC5B,UAAI,MAAM,cAAc,QAAQ,KAAK,WAAW,SAAS,OAAQ,QAAO,YAAY;AACpF,cAAQ,QAAQ,SAAS,WAAW,OAAO,OAAO,EAAE,GAAG,MAAM,UAAU,SAAS,CAAC;AAAA,IACnF;AAAA,EACF;AACA,SAAO;AAAA,IACL,SAAS;AAAA,MACP,IAAI;AAAA,MACJ,KAAK,QAAQ,OAAO;AAAA,MACpB,OAAO,EAAE,MAAM,SAAS,cAAc,QAAQ;AAAA,IAChD;AAAA,IACA,QAAQ,QAAQ,UAAU,CAAC;AAAA,IAC3B,aAAa;AAAA,MACX,QAAQ,MAAM,YAAY,OAAO;AAAA,MACjC,QAAQ,CAAC,UAAU,YAAY,OAAO,KAAK;AAAA,MAC3C,UAAU,CAAC,UAAU,YAAY,SAAS,KAAK;AAAA,MAC/C,UAAU,CAAC,UAAU,YAAY,SAAS,KAAK;AAAA,MAC/C,SAAS,CAAC,UAAU,YAAY,QAAQ,KAAK;AAAA,MAC7C,OAAO,CAAC,OAAO,SAAS,YAAY,MAAM,OAAO,IAAI;AAAA,MACrD,QAAQ,QAAQ;AAAA,IAClB;AAAA,IACA,QAAQ;AAAA,MACN,SAAS,YAAY,YAAY;AAAA,MACjC,UAAU,YAAY,YAAY;AAAA,MAClC,SAAS,YAAY,YAAY;AAAA,MACjC,QAAQ,YAAY,YAAY;AAAA,IAClC;AAAA,IACA,QAAQ;AAAA,MACN,SAAS,YAAY,YAAY;AAAA,MACjC,WAAW,YAAY,YAAY;AAAA,MACnC,SAAS,YAAY,YAAY;AAAA,MACjC,YAAY,YAAY,YAAY;AAAA,MACpC,QAAQ,YAAY,YAAY;AAAA,MAChC,UAAU,YAAY,YAAY;AAAA,IACpC;AAAA,IACA,cAAc,OAAO;AAAA,MACnB,MAAM,YAAY,YAAY;AAAA,MAC9B,OAAO,YAAY,YAAY;AAAA,MAC/B,QAAQ,YAAY,YAAY;AAAA,MAChC,MAAM,YAAY,YAAY;AAAA,MAC9B,QAAQ,YAAY,YAAY;AAAA,MAChC,OAAO,YAAY,YAAY;AAAA,IACjC;AAAA,IACA,SAAS;AAAA,IACT,WAAW,EAAE,SAAS,YAAY,YAAY,EAAE;AAAA,IAChD,OAAO,EAAE,QAAQ,YAAY,YAAY,EAAE;AAAA,IAC3C,OAAO,EAAE,KAAK,YAAY,YAAY,GAAG,KAAK,YAAY,YAAY,EAAE;AAAA,IACxE,KAAK,MAAM;AAAA,EACb;AACF;",
6
6
  "names": []
7
7
  }
@@ -280,9 +280,11 @@ export declare const channelSurfaceSchema: z.ZodObject<{
280
280
  routes: z.ZodArray<z.ZodObject<{
281
281
  method: z.ZodString;
282
282
  path: z.ZodString;
283
+ redirect: z.ZodOptional<z.ZodBoolean>;
283
284
  }, z.core.$strip>>;
284
285
  listeners: z.ZodArray<z.ZodString>;
285
286
  placeKinds: z.ZodArray<z.ZodString>;
287
+ resourceResolver: z.ZodDefault<z.ZodBoolean>;
286
288
  }, z.core.$strip>;
287
289
  export declare const roomSurfaceBindingSchema: z.ZodObject<{
288
290
  channel: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -306,18 +308,20 @@ export declare const channelBindingSchema: z.ZodObject<{
306
308
  config: z.ZodDefault<z.ZodType<import("./json.mjs").JsonObject, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonObject, unknown>>>;
307
309
  source: z.ZodOptional<z.ZodString>;
308
310
  key: z.ZodString;
309
- credentials: z.ZodObject<{
311
+ credentials: z.ZodDefault<z.ZodObject<{
310
312
  app: z.ZodNullable<z.ZodString>;
311
313
  secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
312
- }, z.core.$strip>;
313
- surface: z.ZodObject<{
314
+ }, z.core.$strip>>;
315
+ surface: z.ZodDefault<z.ZodObject<{
314
316
  routes: z.ZodArray<z.ZodObject<{
315
317
  method: z.ZodString;
316
318
  path: z.ZodString;
319
+ redirect: z.ZodOptional<z.ZodBoolean>;
317
320
  }, z.core.$strip>>;
318
321
  listeners: z.ZodArray<z.ZodString>;
319
322
  placeKinds: z.ZodArray<z.ZodString>;
320
- }, z.core.$strip>;
323
+ resourceResolver: z.ZodDefault<z.ZodBoolean>;
324
+ }, z.core.$strip>>;
321
325
  install: z.ZodOptional<z.ZodString>;
322
326
  }, z.core.$strip>;
323
327
  export declare const hookBindingSchema: z.ZodObject<{
@@ -362,7 +366,7 @@ export declare const harnessBindingSchema: z.ZodObject<{
362
366
  }, z.core.$strip>, z.ZodType<import("./json.mjs").JsonValue, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonValue, unknown>>]>;
363
367
  }, z.core.$strip>;
364
368
  export declare const agentManifestSchema: z.ZodObject<{
365
- version: z.ZodLiteral<4>;
369
+ version: z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
366
370
  identity: z.ZodObject<{
367
371
  name: z.ZodString;
368
372
  description: z.ZodNullable<z.ZodString>;
@@ -521,18 +525,20 @@ export declare const agentManifestSchema: z.ZodObject<{
521
525
  config: z.ZodDefault<z.ZodType<import("./json.mjs").JsonObject, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonObject, unknown>>>;
522
526
  source: z.ZodOptional<z.ZodString>;
523
527
  key: z.ZodString;
524
- credentials: z.ZodObject<{
528
+ credentials: z.ZodDefault<z.ZodObject<{
525
529
  app: z.ZodNullable<z.ZodString>;
526
530
  secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
527
- }, z.core.$strip>;
528
- surface: z.ZodObject<{
531
+ }, z.core.$strip>>;
532
+ surface: z.ZodDefault<z.ZodObject<{
529
533
  routes: z.ZodArray<z.ZodObject<{
530
534
  method: z.ZodString;
531
535
  path: z.ZodString;
536
+ redirect: z.ZodOptional<z.ZodBoolean>;
532
537
  }, z.core.$strip>>;
533
538
  listeners: z.ZodArray<z.ZodString>;
534
539
  placeKinds: z.ZodArray<z.ZodString>;
535
- }, z.core.$strip>;
540
+ resourceResolver: z.ZodDefault<z.ZodBoolean>;
541
+ }, z.core.$strip>>;
536
542
  install: z.ZodOptional<z.ZodString>;
537
543
  }, z.core.$strip>>;
538
544
  roomSurface: z.ZodOptional<z.ZodObject<{
@@ -573,7 +579,7 @@ export declare const agentManifestSchema: z.ZodObject<{
573
579
  }, z.core.$strip>>;
574
580
  }, z.core.$strip>;
575
581
  export declare const resolvedAgentManifestSchema: z.ZodObject<{
576
- version: z.ZodLiteral<4>;
582
+ version: z.ZodUnion<readonly [z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
577
583
  identity: z.ZodObject<{
578
584
  name: z.ZodString;
579
585
  description: z.ZodNullable<z.ZodString>;
@@ -598,18 +604,20 @@ export declare const resolvedAgentManifestSchema: z.ZodObject<{
598
604
  config: z.ZodDefault<z.ZodType<import("./json.mjs").JsonObject, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonObject, unknown>>>;
599
605
  source: z.ZodOptional<z.ZodString>;
600
606
  key: z.ZodString;
601
- credentials: z.ZodObject<{
607
+ credentials: z.ZodDefault<z.ZodObject<{
602
608
  app: z.ZodNullable<z.ZodString>;
603
609
  secrets: z.ZodOptional<z.ZodArray<z.ZodString>>;
604
- }, z.core.$strip>;
605
- surface: z.ZodObject<{
610
+ }, z.core.$strip>>;
611
+ surface: z.ZodDefault<z.ZodObject<{
606
612
  routes: z.ZodArray<z.ZodObject<{
607
613
  method: z.ZodString;
608
614
  path: z.ZodString;
615
+ redirect: z.ZodOptional<z.ZodBoolean>;
609
616
  }, z.core.$strip>>;
610
617
  listeners: z.ZodArray<z.ZodString>;
611
618
  placeKinds: z.ZodArray<z.ZodString>;
612
- }, z.core.$strip>;
619
+ resourceResolver: z.ZodDefault<z.ZodBoolean>;
620
+ }, z.core.$strip>>;
613
621
  install: z.ZodOptional<z.ZodString>;
614
622
  }, z.core.$strip>>;
615
623
  roomSurface: z.ZodOptional<z.ZodObject<{
@@ -161,9 +161,12 @@ const channelCredentialsSchema = z.object({
161
161
  secrets: z.array(z.string()).optional()
162
162
  });
163
163
  const channelSurfaceSchema = z.object({
164
- routes: z.array(z.object({ method: z.string(), path: z.string() })),
164
+ routes: z.array(
165
+ z.object({ method: z.string(), path: z.string(), redirect: z.boolean().optional() })
166
+ ),
165
167
  listeners: z.array(z.string()),
166
- placeKinds: z.array(z.string())
168
+ placeKinds: z.array(z.string()),
169
+ resourceResolver: z.boolean().default(false)
167
170
  });
168
171
  const roomSurfaceBindingSchema = z.object({
169
172
  channel: providerRefSchema,
@@ -172,8 +175,13 @@ const roomSurfaceBindingSchema = z.object({
172
175
  });
173
176
  const channelBindingSchema = roomSurfaceBindingSchema.extend({
174
177
  key: z.string().min(1),
175
- credentials: channelCredentialsSchema,
176
- surface: channelSurfaceSchema,
178
+ credentials: channelCredentialsSchema.default({ app: null }),
179
+ surface: channelSurfaceSchema.default({
180
+ routes: [],
181
+ listeners: [],
182
+ placeKinds: [],
183
+ resourceResolver: false
184
+ }),
177
185
  install: z.string().optional()
178
186
  });
179
187
  const hookBindingSchema = z.object({
@@ -205,8 +213,8 @@ const harnessBindingSchema = z.object({
205
213
  config: maybeDynamic(jsonValueSchema)
206
214
  });
207
215
  const agentManifestSchema = z.object({
208
- // v4 external-channel writers require a host supporting scoped people and places.
209
- version: z.literal(MANIFEST_VERSION),
216
+ // Earlier versions stay readable: their channel entries take the defaults below.
217
+ version: z.union([z.literal(2), z.literal(3), z.literal(MANIFEST_VERSION)]),
210
218
  identity: identitySchema,
211
219
  harness: harnessBindingSchema,
212
220
  mcpServers: maybeDynamic(z.array(mcpServerBindingSchema)),
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/manifest.ts"],
4
- "sourcesContent": ["import * as z from 'zod';\nimport { agentAvatarSchema } from '@finalai/agent-protocol';\nimport { containsDynamicSlot, DynamicEvent, maybeDynamic } from \"./dynamic.mjs\";\nimport { jsonObjectSchema, jsonSchemaSchema, jsonValueSchema } from \"./json.mjs\";\nimport { packageRef, providerRefSchema } from \"./provider-ref.mjs\";\n\nexport { agentAvatarSchema, avatarMediaSchema } from '@finalai/agent-protocol';\nexport type { AgentAvatarIface, AvatarMedia, AvatarState } from '@finalai/agent-protocol';\n\n// The Agent Manifest. It lives in the provider contract\n// package because it is what harnesses, sandboxes and channels receive;\n// @finalai/agent-definition compiles directories into it and re-exports it.\n//\n// A harness owns its loop, native tools, prompt assembly, models, permission\n// modes, memory and compaction: all of that is `harness.config`, typed by the\n// harness's own configSchema. What ACP standardizes (MCP servers, prompts,\n// permissions, cancellation) is session input, identical for every harness.\n\nexport const MANIFEST_VERSION = 4;\n\n// Base tool capability classes, one to one with sandbox handle capabilities.\nexport enum BaseCapability {\n Shell = 'shell',\n Files = 'files',\n Process = 'process',\n Ports = 'ports',\n Browser = 'browser',\n ComputerUse = 'computerUse',\n}\n\nexport enum ToolApproval {\n Allow = 'allow',\n Ask = 'ask',\n}\n\n// What a session may do on a sandbox target: read files; also run\n// processes (execute, without file writes); or everything (write).\nexport enum SandboxAccess {\n Read = 'read',\n Execute = 'execute',\n Write = 'write',\n}\n\nconst SANDBOX_ACCESS_RANK = {\n [SandboxAccess.Read]: 0,\n [SandboxAccess.Execute]: 1,\n [SandboxAccess.Write]: 2,\n} satisfies Record<SandboxAccess, number>;\n\n// Each access includes the ones before it: read < execute < write.\nexport const sandboxAccessAtLeast = (access: SandboxAccess, floor: SandboxAccess): boolean =>\n SANDBOX_ACCESS_RANK[access] >= SANDBOX_ACCESS_RANK[floor];\n\nexport const narrowerSandboxAccess = (a: SandboxAccess, b: SandboxAccess): SandboxAccess =>\n SANDBOX_ACCESS_RANK[a] <= SANDBOX_ACCESS_RANK[b] ? a : b;\n\nexport enum SandboxAttach {\n Lazy = 'lazy',\n OnPrompt = 'on-prompt',\n}\n\nexport enum McpServerBindingKind {\n // Authored tools, served from the agent's Worker isolate behind the MCP host.\n Worker = 'worker',\n Http = 'http',\n}\n\nexport enum ScheduleTarget {\n OwnerDirect = 'owner-direct',\n BoundConversation = 'bound-conversation',\n}\n\n// Whether a schedule's firing must get a visible reply. Values match the schedules API.\nexport enum ScheduleDelivery {\n Always = 'always',\n // The agent replies only when there is something to say; an empty turn posts nothing.\n IfNeeded = 'if_needed',\n}\n\nexport const identitySchema = z.object({\n name: z.string().min(1).max(120),\n description: z.string().max(2000).nullable(),\n avatar: agentAvatarSchema.optional(),\n});\n\nexport enum InputApprovalKind {\n Tool = 'tool',\n Connection = 'connection',\n}\n\nexport const inputApprovalSchema = z.object({\n kind: z.nativeEnum(InputApprovalKind),\n export: z.string().min(1),\n // Connection default when absent; otherwise tools.approval[policyKey].\n policyKey: z.string().min(1).optional(),\n dynamic: jsonObjectSchema.optional(),\n});\nexport type InputApprovalIface = z.infer<typeof inputApprovalSchema>;\n\n// Tool descriptors are stored statically so `tools/list` never needs the isolate.\nexport const toolDescriptorSchema = z.object({\n name: z.string().min(1),\n description: z.string(),\n inputSchema: jsonSchemaSchema,\n outputSchema: jsonSchemaSchema.optional(),\n annotations: z\n .object({\n title: z.string().optional(),\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n })\n .optional(),\n // Bundle export implementing it ('tools/lookup_release_notes').\n export: z.string().min(1).optional(),\n // Boundary snapshot used to reconstruct dynamic tools after isolate eviction.\n dynamic: jsonObjectSchema.optional(),\n inputApproval: inputApprovalSchema.optional(),\n});\n\nexport const mcpAuthSchema = z.union([\n z.object({ secretKey: z.string().min(1), headerName: z.string().min(1).nullable() }),\n // Resolved by the broker to a session-scoped grant (Final's own MCP server).\n z.object({ kind: z.literal('final-session') }),\n]);\n\nconst toolApprovalsSchema = z.record(z.string(), z.nativeEnum(ToolApproval)).nullable();\n\n// MCP tool annotation hints a connection policy selects on (./tool-annotations.ts).\nexport const toolAnnotationSelectorSchema = z\n .strictObject({\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n })\n .refine((selector) => Object.keys(selector).length > 0, 'Select at least one annotation');\n\n// Tools exposed because their annotations match, with the approval (and the\n// connection default's input predicate) they run under.\nexport const toolAnnotationRuleSchema = z.object({\n match: toolAnnotationSelectorSchema,\n approval: z.nativeEnum(ToolApproval),\n inputApproval: inputApprovalSchema.optional(),\n});\n\nexport const workerMcpServerBindingSchema = z.object({\n key: z.string().min(1),\n kind: z.literal(McpServerBindingKind.Worker),\n tools: z.array(toolDescriptorSchema),\n approvals: toolApprovalsSchema,\n});\n\nexport const httpMcpServerBindingSchema = z.object({\n key: z.string().min(1),\n kind: z.literal(McpServerBindingKind.Http),\n url: z.string().url(),\n auth: mcpAuthSchema.nullable(),\n headers: z.record(z.string(), z.string()).default({}),\n // Null allows every tool the server lists, each with the default approval.\n // Keys are tool names or `*` patterns (./tool-patterns.ts); the most\n // specific matching key governs a tool.\n approvals: toolApprovalsSchema,\n // Tool names or `*` patterns hidden even when `approvals` would expose them.\n deny: z.array(z.string().min(1)).optional(),\n // Exposed tools (names or `*` patterns) the harness lists up front. Absent\n // lists every exposed tool; otherwise the host keeps the rest reachable\n // through search (HOSTING.md).\n load: z.array(z.string().min(1)).optional(),\n // Tools also exposed by their MCP annotations; named tools keep `approvals`.\n allowAnnotations: z.array(toolAnnotationRuleSchema).optional(),\n // Tools hidden by their MCP annotations, whatever else exposes them.\n denyAnnotations: z.array(toolAnnotationSelectorSchema).optional(),\n // The authored resolver that produced this connection, for retained boundary values.\n dynamicResolver: z.string().min(1).optional(),\n inputApprovals: z.record(z.string(), inputApprovalSchema).optional(),\n});\n\nexport const mcpServerBindingSchema = z.discriminatedUnion('kind', [\n workerMcpServerBindingSchema,\n httpMcpServerBindingSchema,\n]);\n\n// A sandbox provider's credential by reference: `secretRef` is the name of a secret,\n// never its value. Providers take it as `credential` in their environment options.\nexport const sandboxCredentialRefSchema = z.strictObject({\n secretRef: z.string().min(1).max(256),\n});\n\nexport type SandboxCredentialRefIface = z.infer<typeof sandboxCredentialRefSchema>;\n\nexport const sandboxBindingSchema = z.object({\n provider: providerRefSchema,\n // Provider-defined environment options (`computer`: a setup guide reference or\n // inline guide plus start-time parameters). Validated by the provider.\n environment: maybeDynamic(jsonValueSchema),\n access: z.nativeEnum(SandboxAccess).default(SandboxAccess.Write),\n attach: z.nativeEnum(SandboxAttach).default(SandboxAttach.Lazy),\n});\n\nexport const baseToolsSchema = z.object({\n base: z.partialRecord(z.nativeEnum(BaseCapability), z.object({ target: z.string().min(1) })),\n // Capabilities declared on the harness's own host with no sandbox target\n // (`baseTools({ shell: harnessHost })`): only a harness that\n // provides them natively (host-disableable, host-fixed) can serve them.\n host: z.array(z.nativeEnum(BaseCapability)).optional(),\n});\n\nexport const channelCredentialsSchema = z.object({\n app: z.string().nullable(),\n secrets: z.array(z.string()).optional(),\n});\nexport const channelSurfaceSchema = z.object({\n routes: z.array(z.object({ method: z.string(), path: z.string() })),\n listeners: z.array(z.string()),\n placeKinds: z.array(z.string()),\n});\nexport const roomSurfaceBindingSchema = z.object({\n channel: providerRefSchema,\n config: jsonObjectSchema.default({}),\n source: z.string().optional(),\n});\nexport const channelBindingSchema = roomSurfaceBindingSchema.extend({\n key: z.string().min(1),\n credentials: channelCredentialsSchema,\n surface: channelSurfaceSchema,\n install: z.string().optional(),\n});\n\nexport const hookBindingSchema = z.object({\n slug: z.string().min(1),\n export: z.string().min(1),\n events: z.array(z.string().min(1)).min(1),\n});\n\nexport const scheduleDefinitionSchema = z.object({\n key: z.string().min(1),\n cron: z.string().min(1),\n timezone: z.string().min(1),\n prompt: z.string().min(1),\n target: z.nativeEnum(ScheduleTarget),\n});\n\nexport const bundleSchema = z.object({\n // Absent on historical revisions: the host must inspect their resources.\n hasPreparationFiles: z.boolean().optional(),\n hash: z.string().min(1),\n // Dynamic slot path \u2192 resolver export and events.\n resolvers: z.record(\n z.string(),\n z.object({ export: z.string().min(1), events: z.array(z.nativeEnum(DynamicEvent)).min(1) }),\n ),\n});\n\nexport const harnessBindingSchema = z.object({\n harness: providerRefSchema,\n // Validated against the harness's configSchema; may contain dynamic slots at\n // any depth (an instruction fragment, the model).\n config: maybeDynamic(jsonValueSchema),\n});\n\nexport const agentManifestSchema = z.object({\n // v4 external-channel writers require a host supporting scoped people and places.\n version: z.literal(MANIFEST_VERSION),\n identity: identitySchema,\n harness: harnessBindingSchema,\n mcpServers: maybeDynamic(z.array(mcpServerBindingSchema)),\n sandboxes: maybeDynamic(z.record(z.string(), sandboxBindingSchema)),\n tools: baseToolsSchema,\n toolPolicy: z.record(z.string(), z.nativeEnum(ToolApproval)),\n // Secrets this agent may read, by name (`secrets.get`, MCP `secretKey`,\n // `apiKey({ secret })`). Nothing else is readable.\n secrets: z.array(z.string().min(1)).default([]),\n channels: z.array(channelBindingSchema),\n roomSurface: roomSurfaceBindingSchema.optional(),\n channelSources: z\n .record(z.string(), z.object({ path: z.string(), source: z.string(), disabled: z.boolean() }))\n .optional(),\n hooks: z.array(hookBindingSchema),\n schedules: z.array(scheduleDefinitionSchema),\n bundle: bundleSchema.nullable(),\n});\n\n// What one session actually got: every dynamic slot replaced by its resolved\n// value (stored in agent.session_manifests).\nexport const resolvedAgentManifestSchema = agentManifestSchema\n .extend({\n harness: z.object({ harness: providerRefSchema, config: jsonValueSchema }),\n mcpServers: z.array(mcpServerBindingSchema),\n sandboxes: z.record(z.string(), sandboxBindingSchema.extend({ environment: jsonValueSchema })),\n })\n .superRefine((manifest, ctx) => {\n if (containsDynamicSlot(manifest)) {\n ctx.addIssue({\n code: 'custom',\n message: 'a resolved manifest must not contain dynamic slots',\n });\n }\n });\n\nexport type IdentityIface = z.infer<typeof identitySchema>;\nexport type ToolDescriptorIface = z.infer<typeof toolDescriptorSchema>;\nexport type McpAuth = z.infer<typeof mcpAuthSchema>;\nexport type WorkerMcpServerBindingIface = z.infer<typeof workerMcpServerBindingSchema>;\nexport type HttpMcpServerBindingIface = z.infer<typeof httpMcpServerBindingSchema>;\nexport type ToolAnnotationSelectorIface = z.infer<typeof toolAnnotationSelectorSchema>;\nexport type ToolAnnotationRuleIface = z.infer<typeof toolAnnotationRuleSchema>;\nexport type McpServerBinding = z.infer<typeof mcpServerBindingSchema>;\nexport type SandboxBindingIface = z.infer<typeof sandboxBindingSchema>;\nexport type BaseToolsIface = z.infer<typeof baseToolsSchema>;\nexport type ChannelBindingIface = z.infer<typeof channelBindingSchema>;\nexport type HookBindingIface = z.infer<typeof hookBindingSchema>;\nexport type ScheduleDefinitionIface = z.infer<typeof scheduleDefinitionSchema>;\nexport type BundleIface = z.infer<typeof bundleSchema>;\nexport type HarnessBindingIface = z.infer<typeof harnessBindingSchema>;\nexport type AgentManifestIface = z.infer<typeof agentManifestSchema>;\nexport type ResolvedAgentManifestIface = z.infer<typeof resolvedAgentManifestSchema>;\nexport type ResolvedSandboxBindingIface = ResolvedAgentManifestIface['sandboxes'][string];\n\n// The fields of a harness config the platform itself reads through the shared\n// schema fragments; everything else is opaque to the platform.\nexport enum InstructionRole {\n System = 'system',\n User = 'user',\n}\n\nexport const instructionFragmentSchema = z.object({\n role: z.nativeEnum(InstructionRole),\n content: z.string(),\n // Source file, for the compatibility report and Build.\n source: z.string().optional(),\n});\n\nexport const skillFileSchema = z.object({ path: z.string().min(1), content: z.string() });\nexport const skillBundleSchema = z.object({\n key: z.string().min(1),\n description: z.string().optional(),\n files: z.array(skillFileSchema),\n});\n\nexport type InstructionFragmentIface = z.infer<typeof instructionFragmentSchema>;\nexport type SkillBundleIface = z.infer<typeof skillBundleSchema>;\n\nexport const emptyManifest = (name: string): AgentManifestIface => ({\n version: MANIFEST_VERSION,\n identity: { name, description: null },\n harness: {\n harness: packageRef('@finalai/final-agent-provider/harnesses/serverless-final'),\n config: {},\n },\n mcpServers: [],\n sandboxes: {},\n tools: { base: {} },\n toolPolicy: {},\n secrets: [],\n channels: [],\n hooks: [],\n schedules: [],\n bundle: null,\n});\n"],
5
- "mappings": "AAAA,YAAY,OAAO;AACnB,SAAS,yBAAyB;AAClC,SAAS,qBAAqB,cAAc,oBAAoB;AAChE,SAAS,kBAAkB,kBAAkB,uBAAuB;AACpE,SAAS,YAAY,yBAAyB;AAE9C,SAAS,qBAAAA,oBAAmB,yBAAyB;AAY9C,MAAM,mBAAmB;AAGzB,IAAK,iBAAL,kBAAKC,oBAAL;AACL,EAAAA,gBAAA,WAAQ;AACR,EAAAA,gBAAA,WAAQ;AACR,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,WAAQ;AACR,EAAAA,gBAAA,aAAU;AACV,EAAAA,gBAAA,iBAAc;AANJ,SAAAA;AAAA,GAAA;AASL,IAAK,eAAL,kBAAKC,kBAAL;AACL,EAAAA,cAAA,WAAQ;AACR,EAAAA,cAAA,SAAM;AAFI,SAAAA;AAAA,GAAA;AAOL,IAAK,gBAAL,k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KL,MAAM,4BAA4B,EAAE,OAAO;AAAA,EAChD,MAAM,EAAE,WAAW,eAAe;AAAA,EAClC,SAAS,EAAE,OAAO;AAAA;AAAA,EAElB,QAAQ,EAAE,OAAO,EAAE,SAAS;AAC9B,CAAC;AAEM,MAAM,kBAAkB,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,SAAS,EAAE,OAAO,EAAE,CAAC;AACjF,MAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACrB,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,EACjC,OAAO,EAAE,MAAM,eAAe;AAChC,CAAC;AAKM,MAAM,gBAAgB,CAAC,UAAsC;AAAA,EAClE,SAAS;AAAA,EACT,UAAU,EAAE,MAAM,aAAa,KAAK;AAAA,EACpC,SAAS;AAAA,IACP,SAAS,WAAW,0DAA0D;AAAA,IAC9E,QAAQ,CAAC;AAAA,EACX;AAAA,EACA,YAAY,CAAC;AAAA,EACb,WAAW,CAAC;AAAA,EACZ,OAAO,EAAE,MAAM,CAAC,EAAE;AAAA,EAClB,YAAY,CAAC;AAAA,EACb,SAAS,CAAC;AAAA,EACV,UAAU,CAAC;AAAA,EACX,OAAO,CAAC;AAAA,EACR,WAAW,CAAC;AAAA,EACZ,QAAQ;AACV;",
4
+ "sourcesContent": ["import * as z from 'zod';\nimport { agentAvatarSchema } from '@finalai/agent-protocol';\nimport { containsDynamicSlot, DynamicEvent, maybeDynamic } from \"./dynamic.mjs\";\nimport { jsonObjectSchema, jsonSchemaSchema, jsonValueSchema } from \"./json.mjs\";\nimport { packageRef, providerRefSchema } from \"./provider-ref.mjs\";\n\nexport { agentAvatarSchema, avatarMediaSchema } from '@finalai/agent-protocol';\nexport type { AgentAvatarIface, AvatarMedia, AvatarState } from '@finalai/agent-protocol';\n\n// The Agent Manifest. It lives in the provider contract\n// package because it is what harnesses, sandboxes and channels receive;\n// @finalai/agent-definition compiles directories into it and re-exports it.\n//\n// A harness owns its loop, native tools, prompt assembly, models, permission\n// modes, memory and compaction: all of that is `harness.config`, typed by the\n// harness's own configSchema. What ACP standardizes (MCP servers, prompts,\n// permissions, cancellation) is session input, identical for every harness.\n\nexport const MANIFEST_VERSION = 4;\n\n// Base tool capability classes, one to one with sandbox handle capabilities.\nexport enum BaseCapability {\n Shell = 'shell',\n Files = 'files',\n Process = 'process',\n Ports = 'ports',\n Browser = 'browser',\n ComputerUse = 'computerUse',\n}\n\nexport enum ToolApproval {\n Allow = 'allow',\n Ask = 'ask',\n}\n\n// What a session may do on a sandbox target: read files; also run\n// processes (execute, without file writes); or everything (write).\nexport enum SandboxAccess {\n Read = 'read',\n Execute = 'execute',\n Write = 'write',\n}\n\nconst SANDBOX_ACCESS_RANK = {\n [SandboxAccess.Read]: 0,\n [SandboxAccess.Execute]: 1,\n [SandboxAccess.Write]: 2,\n} satisfies Record<SandboxAccess, number>;\n\n// Each access includes the ones before it: read < execute < write.\nexport const sandboxAccessAtLeast = (access: SandboxAccess, floor: SandboxAccess): boolean =>\n SANDBOX_ACCESS_RANK[access] >= SANDBOX_ACCESS_RANK[floor];\n\nexport const narrowerSandboxAccess = (a: SandboxAccess, b: SandboxAccess): SandboxAccess =>\n SANDBOX_ACCESS_RANK[a] <= SANDBOX_ACCESS_RANK[b] ? a : b;\n\nexport enum SandboxAttach {\n Lazy = 'lazy',\n OnPrompt = 'on-prompt',\n}\n\nexport enum McpServerBindingKind {\n // Authored tools, served from the agent's Worker isolate behind the MCP host.\n Worker = 'worker',\n Http = 'http',\n}\n\nexport enum ScheduleTarget {\n OwnerDirect = 'owner-direct',\n BoundConversation = 'bound-conversation',\n}\n\n// Whether a schedule's firing must get a visible reply. Values match the schedules API.\nexport enum ScheduleDelivery {\n Always = 'always',\n // The agent replies only when there is something to say; an empty turn posts nothing.\n IfNeeded = 'if_needed',\n}\n\nexport const identitySchema = z.object({\n name: z.string().min(1).max(120),\n description: z.string().max(2000).nullable(),\n avatar: agentAvatarSchema.optional(),\n});\n\nexport enum InputApprovalKind {\n Tool = 'tool',\n Connection = 'connection',\n}\n\nexport const inputApprovalSchema = z.object({\n kind: z.nativeEnum(InputApprovalKind),\n export: z.string().min(1),\n // Connection default when absent; otherwise tools.approval[policyKey].\n policyKey: z.string().min(1).optional(),\n dynamic: jsonObjectSchema.optional(),\n});\nexport type InputApprovalIface = z.infer<typeof inputApprovalSchema>;\n\n// Tool descriptors are stored statically so `tools/list` never needs the isolate.\nexport const toolDescriptorSchema = z.object({\n name: z.string().min(1),\n description: z.string(),\n inputSchema: jsonSchemaSchema,\n outputSchema: jsonSchemaSchema.optional(),\n annotations: z\n .object({\n title: z.string().optional(),\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n })\n .optional(),\n // Bundle export implementing it ('tools/lookup_release_notes').\n export: z.string().min(1).optional(),\n // Boundary snapshot used to reconstruct dynamic tools after isolate eviction.\n dynamic: jsonObjectSchema.optional(),\n inputApproval: inputApprovalSchema.optional(),\n});\n\nexport const mcpAuthSchema = z.union([\n z.object({ secretKey: z.string().min(1), headerName: z.string().min(1).nullable() }),\n // Resolved by the broker to a session-scoped grant (Final's own MCP server).\n z.object({ kind: z.literal('final-session') }),\n]);\n\nconst toolApprovalsSchema = z.record(z.string(), z.nativeEnum(ToolApproval)).nullable();\n\n// MCP tool annotation hints a connection policy selects on (./tool-annotations.ts).\nexport const toolAnnotationSelectorSchema = z\n .strictObject({\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n })\n .refine((selector) => Object.keys(selector).length > 0, 'Select at least one annotation');\n\n// Tools exposed because their annotations match, with the approval (and the\n// connection default's input predicate) they run under.\nexport const toolAnnotationRuleSchema = z.object({\n match: toolAnnotationSelectorSchema,\n approval: z.nativeEnum(ToolApproval),\n inputApproval: inputApprovalSchema.optional(),\n});\n\nexport const workerMcpServerBindingSchema = z.object({\n key: z.string().min(1),\n kind: z.literal(McpServerBindingKind.Worker),\n tools: z.array(toolDescriptorSchema),\n approvals: toolApprovalsSchema,\n});\n\nexport const httpMcpServerBindingSchema = z.object({\n key: z.string().min(1),\n kind: z.literal(McpServerBindingKind.Http),\n url: z.string().url(),\n auth: mcpAuthSchema.nullable(),\n headers: z.record(z.string(), z.string()).default({}),\n // Null allows every tool the server lists, each with the default approval.\n // Keys are tool names or `*` patterns (./tool-patterns.ts); the most\n // specific matching key governs a tool.\n approvals: toolApprovalsSchema,\n // Tool names or `*` patterns hidden even when `approvals` would expose them.\n deny: z.array(z.string().min(1)).optional(),\n // Exposed tools (names or `*` patterns) the harness lists up front. Absent\n // lists every exposed tool; otherwise the host keeps the rest reachable\n // through search (HOSTING.md).\n load: z.array(z.string().min(1)).optional(),\n // Tools also exposed by their MCP annotations; named tools keep `approvals`.\n allowAnnotations: z.array(toolAnnotationRuleSchema).optional(),\n // Tools hidden by their MCP annotations, whatever else exposes them.\n denyAnnotations: z.array(toolAnnotationSelectorSchema).optional(),\n // The authored resolver that produced this connection, for retained boundary values.\n dynamicResolver: z.string().min(1).optional(),\n inputApprovals: z.record(z.string(), inputApprovalSchema).optional(),\n});\n\nexport const mcpServerBindingSchema = z.discriminatedUnion('kind', [\n workerMcpServerBindingSchema,\n httpMcpServerBindingSchema,\n]);\n\n// A sandbox provider's credential by reference: `secretRef` is the name of a secret,\n// never its value. Providers take it as `credential` in their environment options.\nexport const sandboxCredentialRefSchema = z.strictObject({\n secretRef: z.string().min(1).max(256),\n});\n\nexport type SandboxCredentialRefIface = z.infer<typeof sandboxCredentialRefSchema>;\n\nexport const sandboxBindingSchema = z.object({\n provider: providerRefSchema,\n // Provider-defined environment options (`computer`: a setup guide reference or\n // inline guide plus start-time parameters). Validated by the provider.\n environment: maybeDynamic(jsonValueSchema),\n access: z.nativeEnum(SandboxAccess).default(SandboxAccess.Write),\n attach: z.nativeEnum(SandboxAttach).default(SandboxAttach.Lazy),\n});\n\nexport const baseToolsSchema = z.object({\n base: z.partialRecord(z.nativeEnum(BaseCapability), z.object({ target: z.string().min(1) })),\n // Capabilities declared on the harness's own host with no sandbox target\n // (`baseTools({ shell: harnessHost })`): only a harness that\n // provides them natively (host-disableable, host-fixed) can serve them.\n host: z.array(z.nativeEnum(BaseCapability)).optional(),\n});\n\nexport const channelCredentialsSchema = z.object({\n app: z.string().nullable(),\n secrets: z.array(z.string()).optional(),\n});\nexport const channelSurfaceSchema = z.object({\n routes: z.array(\n z.object({ method: z.string(), path: z.string(), redirect: z.boolean().optional() }),\n ),\n listeners: z.array(z.string()),\n placeKinds: z.array(z.string()),\n resourceResolver: z.boolean().default(false),\n});\nexport const roomSurfaceBindingSchema = z.object({\n channel: providerRefSchema,\n config: jsonObjectSchema.default({}),\n source: z.string().optional(),\n});\nexport const channelBindingSchema = roomSurfaceBindingSchema.extend({\n key: z.string().min(1),\n credentials: channelCredentialsSchema.default({ app: null }),\n surface: channelSurfaceSchema.default({\n routes: [],\n listeners: [],\n placeKinds: [],\n resourceResolver: false,\n }),\n install: z.string().optional(),\n});\n\nexport const hookBindingSchema = z.object({\n slug: z.string().min(1),\n export: z.string().min(1),\n events: z.array(z.string().min(1)).min(1),\n});\n\nexport const scheduleDefinitionSchema = z.object({\n key: z.string().min(1),\n cron: z.string().min(1),\n timezone: z.string().min(1),\n prompt: z.string().min(1),\n target: z.nativeEnum(ScheduleTarget),\n});\n\nexport const bundleSchema = z.object({\n // Absent on historical revisions: the host must inspect their resources.\n hasPreparationFiles: z.boolean().optional(),\n hash: z.string().min(1),\n // Dynamic slot path \u2192 resolver export and events.\n resolvers: z.record(\n z.string(),\n z.object({ export: z.string().min(1), events: z.array(z.nativeEnum(DynamicEvent)).min(1) }),\n ),\n});\n\nexport const harnessBindingSchema = z.object({\n harness: providerRefSchema,\n // Validated against the harness's configSchema; may contain dynamic slots at\n // any depth (an instruction fragment, the model).\n config: maybeDynamic(jsonValueSchema),\n});\n\nexport const agentManifestSchema = z.object({\n // Earlier versions stay readable: their channel entries take the defaults below.\n version: z.union([z.literal(2), z.literal(3), z.literal(MANIFEST_VERSION)]),\n identity: identitySchema,\n harness: harnessBindingSchema,\n mcpServers: maybeDynamic(z.array(mcpServerBindingSchema)),\n sandboxes: maybeDynamic(z.record(z.string(), sandboxBindingSchema)),\n tools: baseToolsSchema,\n toolPolicy: z.record(z.string(), z.nativeEnum(ToolApproval)),\n // Secrets this agent may read, by name (`secrets.get`, MCP `secretKey`,\n // `apiKey({ secret })`). Nothing else is readable.\n secrets: z.array(z.string().min(1)).default([]),\n channels: z.array(channelBindingSchema),\n roomSurface: roomSurfaceBindingSchema.optional(),\n channelSources: z\n .record(z.string(), z.object({ path: z.string(), source: z.string(), disabled: z.boolean() }))\n .optional(),\n hooks: z.array(hookBindingSchema),\n schedules: z.array(scheduleDefinitionSchema),\n bundle: bundleSchema.nullable(),\n});\n\n// What one session actually got: every dynamic slot replaced by its resolved\n// value (stored in agent.session_manifests).\nexport const resolvedAgentManifestSchema = agentManifestSchema\n .extend({\n harness: z.object({ harness: providerRefSchema, config: jsonValueSchema }),\n mcpServers: z.array(mcpServerBindingSchema),\n sandboxes: z.record(z.string(), sandboxBindingSchema.extend({ environment: jsonValueSchema })),\n })\n .superRefine((manifest, ctx) => {\n if (containsDynamicSlot(manifest)) {\n ctx.addIssue({\n code: 'custom',\n message: 'a resolved manifest must not contain dynamic slots',\n });\n }\n });\n\nexport type IdentityIface = z.infer<typeof identitySchema>;\nexport type ToolDescriptorIface = z.infer<typeof toolDescriptorSchema>;\nexport type McpAuth = z.infer<typeof mcpAuthSchema>;\nexport type WorkerMcpServerBindingIface = z.infer<typeof workerMcpServerBindingSchema>;\nexport type HttpMcpServerBindingIface = z.infer<typeof httpMcpServerBindingSchema>;\nexport type ToolAnnotationSelectorIface = z.infer<typeof toolAnnotationSelectorSchema>;\nexport type ToolAnnotationRuleIface = z.infer<typeof toolAnnotationRuleSchema>;\nexport type McpServerBinding = z.infer<typeof mcpServerBindingSchema>;\nexport type SandboxBindingIface = z.infer<typeof sandboxBindingSchema>;\nexport type BaseToolsIface = z.infer<typeof baseToolsSchema>;\nexport type ChannelBindingIface = z.infer<typeof channelBindingSchema>;\nexport type HookBindingIface = z.infer<typeof hookBindingSchema>;\nexport type ScheduleDefinitionIface = z.infer<typeof scheduleDefinitionSchema>;\nexport type BundleIface = z.infer<typeof bundleSchema>;\nexport type HarnessBindingIface = z.infer<typeof harnessBindingSchema>;\nexport type AgentManifestIface = z.infer<typeof agentManifestSchema>;\nexport type ResolvedAgentManifestIface = z.infer<typeof resolvedAgentManifestSchema>;\nexport type ResolvedSandboxBindingIface = ResolvedAgentManifestIface['sandboxes'][string];\n\n// The fields of a harness config the platform itself reads through the shared\n// schema fragments; everything else is opaque to the platform.\nexport enum InstructionRole {\n System = 'system',\n User = 'user',\n}\n\nexport const instructionFragmentSchema = z.object({\n role: z.nativeEnum(InstructionRole),\n content: z.string(),\n // Source file, for the compatibility report and Build.\n source: z.string().optional(),\n});\n\nexport const skillFileSchema = z.object({ path: z.string().min(1), content: z.string() });\nexport const skillBundleSchema = z.object({\n key: z.string().min(1),\n description: z.string().optional(),\n files: z.array(skillFileSchema),\n});\n\nexport type InstructionFragmentIface = z.infer<typeof instructionFragmentSchema>;\nexport type SkillBundleIface = z.infer<typeof skillBundleSchema>;\n\nexport const emptyManifest = (name: string): AgentManifestIface => ({\n version: MANIFEST_VERSION,\n identity: { name, description: null },\n harness: {\n harness: packageRef('@finalai/final-agent-provider/harnesses/serverless-final'),\n config: {},\n },\n mcpServers: [],\n sandboxes: {},\n tools: { base: {} },\n toolPolicy: {},\n secrets: [],\n channels: [],\n hooks: [],\n schedules: [],\n bundle: null,\n});\n"],
5
+ "mappings": "AAAA,YAAY,OAAO;AACnB,SAAS,yBAAyB;AAClC,SAAS,qBAAqB,cAAc,oBAAoB;AAChE,SAAS,kBAAkB,kBAAkB,uBAAuB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AAM,gBAAgB,CAAC,UAAsC;AAAA,EAClE,SAAS;AAAA,EACT,UAAU,EAAE,MAAM,aAAa,KAAK;AAAA,EACpC,SAAS;AAAA,IACP,SAAS,WAAW,0DAA0D;AAAA,IAC9E,QAAQ,CAAC;AAAA,EACX;AAAA,EACA,YAAY,CAAC;AAAA,EACb,WAAW,CAAC;AAAA,EACZ,OAAO,EAAE,MAAM,CAAC,EAAE;AAAA,EAClB,YAAY,CAAC;AAAA,EACb,SAAS,CAAC;AAAA,EACV,UAAU,CAAC;AAAA,EACX,OAAO,CAAC;AAAA,EACR,WAAW,CAAC;AAAA,EACZ,QAAQ;AACV;",
6
6
  "names": ["agentAvatarSchema", "BaseCapability", "ToolApproval", "SandboxAccess", "SandboxAttach", "McpServerBindingKind", "ScheduleTarget", "ScheduleDelivery", "InputApprovalKind", "InstructionRole"]
7
7
  }
@@ -2,27 +2,27 @@ import type { HostedBindingsIface } from "./hosted-bindings.mjs";
2
2
  import type { ContentBlock, SessionUpdate } from '@agentclientprotocol/sdk/experimental/v2';
3
3
  import type { SessionUpdateKind } from '@finalai/acp-session';
4
4
  import * as z from 'zod';
5
+ import type { ChannelTurnStateIface } from "./channel.mjs";
5
6
  import { type JsonObject, type JsonValue } from "./json.mjs";
6
- import type { ProviderRef } from "./provider-ref.mjs";
7
7
  import type { SemanticChannelEventKind } from "./semantic-events.mjs";
8
- export declare enum ChannelPrincipalType {
8
+ export declare enum RoomPrincipalType {
9
9
  User = "user",
10
10
  Service = "service"
11
11
  }
12
- export interface ChannelAuthIface extends JsonObject {
12
+ export interface RoomAuthIface extends JsonObject {
13
13
  principalId: string;
14
- principalType: ChannelPrincipalType | `${ChannelPrincipalType}`;
14
+ principalType: RoomPrincipalType | `${RoomPrincipalType}`;
15
15
  authenticator: string;
16
16
  attributes: JsonObject;
17
17
  }
18
- export declare const channelAuthSchema: z.ZodObject<{
18
+ export declare const roomAuthSchema: z.ZodObject<{
19
19
  principalId: z.ZodString;
20
- principalType: z.ZodEnum<typeof ChannelPrincipalType>;
20
+ principalType: z.ZodEnum<typeof RoomPrincipalType>;
21
21
  authenticator: z.ZodString;
22
22
  displayName: z.ZodOptional<z.ZodString>;
23
23
  attributes: z.ZodDefault<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
24
24
  }, z.core.$strip>;
25
- export declare const principalDisplayName: (auth: ChannelAuthIface) => string;
25
+ export declare const principalDisplayName: (auth: RoomAuthIface) => string;
26
26
  export declare enum ConversationKind {
27
27
  Direct = "direct",
28
28
  Group = "group"
@@ -128,7 +128,7 @@ export interface PostMessageArgsIface {
128
128
  toSeq: number;
129
129
  } | null;
130
130
  }
131
- export declare const channelMessageInputSchema: z.ZodObject<{
131
+ export declare const roomMessageInputSchema: z.ZodObject<{
132
132
  conversationId: z.ZodString;
133
133
  authorParticipantId: z.ZodString;
134
134
  kind: z.ZodDefault<z.ZodEnum<typeof MessageKind>>;
@@ -160,7 +160,7 @@ export interface PromptArgsIface {
160
160
  id: string;
161
161
  revisionId: string;
162
162
  };
163
- auth?: ChannelAuthIface | null;
163
+ auth?: RoomAuthIface | null;
164
164
  title?: string;
165
165
  participantId: string;
166
166
  content: ContentBlock[];
@@ -168,7 +168,6 @@ export interface PromptArgsIface {
168
168
  replyExpected: boolean;
169
169
  idempotencyKey: string;
170
170
  authorParticipantId: string;
171
- actingUserId?: string | null;
172
171
  audienceParticipantIds: string[];
173
172
  sourceMessageId: string;
174
173
  }
@@ -241,18 +240,18 @@ export interface RoomPlatformIface {
241
240
  reason?: string;
242
241
  throughMessageSeq?: number;
243
242
  }): Promise<void>;
244
- respond?(args: ChannelInputResponseIface): Promise<{
243
+ respond?(args: RoomInputResponseIface): Promise<{
245
244
  resolved: boolean;
246
245
  }>;
247
246
  };
248
247
  log(message: string, details?: Record<string, JsonValue>): void;
249
248
  }
250
- export interface ChannelInputResponseIface {
249
+ export interface RoomInputResponseIface {
251
250
  channelBinding?: {
252
251
  id: string;
253
252
  revisionId: string;
254
253
  };
255
- auth?: ChannelAuthIface | null;
254
+ auth?: RoomAuthIface | null;
256
255
  participantId: string;
257
256
  decisionId: string;
258
257
  outcome: JsonValue;
@@ -273,25 +272,12 @@ export interface RoomReceiveContextIface {
273
272
  message?: ConversationMessageIface;
274
273
  conversation?: ConversationIface;
275
274
  participants?: readonly ParticipantIface[];
276
- response?: ChannelInputResponseIface;
275
+ response?: RoomInputResponseIface;
277
276
  conversationId?: string;
278
277
  cancelReason?: string;
279
278
  cancelThroughMessageSeq?: number;
280
279
  requestedDelivery?: Delivery;
281
280
  }
282
- export interface ChannelSocketIface {
283
- readonly signal: AbortSignal;
284
- readonly messages: AsyncIterable<string | Uint8Array>;
285
- accept(options?: {
286
- protocol?: string;
287
- }): void;
288
- send(data: string | Uint8Array): void;
289
- close(code?: number, reason?: string): void;
290
- }
291
- export interface ChannelTurnStateIface<State> {
292
- get(): State | null;
293
- set(state: State | null): void;
294
- }
295
281
  export interface ProjectionContextIface<State = JsonValue> {
296
282
  bindings?: HostedBindingsIface;
297
283
  sessionId?: string;
@@ -317,12 +303,12 @@ export declare enum DecisionEventKind {
317
303
  export type AcpUpdateKind = SessionUpdate['sessionUpdate'];
318
304
  export type KnownAcpUpdateKind = `${SessionUpdateKind}`;
319
305
  export type RoomEventKind = AcpUpdateKind | `${DecisionEventKind}` | `${SemanticChannelEventKind}`;
320
- export interface ChannelEventIface {
306
+ export interface RoomEventIface {
321
307
  type: string;
322
308
  data: JsonValue;
323
309
  seq: number;
324
310
  }
325
- export type RoomEventHandler<State = JsonValue> = (event: ChannelEventIface, ctx: ProjectionContextIface<State>) => Promise<void>;
311
+ export type RoomEventHandler<State = JsonValue> = (event: RoomEventIface, ctx: ProjectionContextIface<State>) => Promise<void>;
326
312
  export declare enum DecisionKind {
327
313
  Permission = "permission",
328
314
  Elicitation = "elicitation"
@@ -339,7 +325,7 @@ export declare const decisionResolvedDataSchema: z.ZodObject<{
339
325
  outcome: z.ZodType<JsonValue, unknown, z.core.$ZodTypeInternals<JsonValue, unknown>>;
340
326
  respondedBy: z.ZodDefault<z.ZodNullable<z.ZodObject<{
341
327
  principalId: z.ZodString;
342
- principalType: z.ZodEnum<typeof ChannelPrincipalType>;
328
+ principalType: z.ZodEnum<typeof RoomPrincipalType>;
343
329
  authenticator: z.ZodString;
344
330
  displayName: z.ZodOptional<z.ZodString>;
345
331
  attributes: z.ZodDefault<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
@@ -353,9 +339,8 @@ export declare const turnEndOf: (update: SessionUpdate) => {
353
339
  export declare const turnEndUpdate: (stopReason: string | null) => SessionUpdate;
354
340
  export interface RoomSurfaceDefinitionIface<Inbound, State = undefined> {
355
341
  config?: JsonObject;
356
- installed?: ProviderRef;
357
342
  configure?: (config: JsonObject) => RoomSurfaceDefinitionIface<Inbound, State>;
358
- respond?(input: ChannelInputResponseIface, ctx: RoomReceiveContextIface): Promise<{
343
+ respond?(input: RoomInputResponseIface, ctx: RoomReceiveContextIface): Promise<{
359
344
  resolved: boolean;
360
345
  }>;
361
346
  cancel?(ctx: RoomReceiveContextIface): Promise<{
@@ -1,13 +1,13 @@
1
1
  import * as z from "zod";
2
2
  import { jsonObjectSchema, jsonValueSchema } from "./json.mjs";
3
- var ChannelPrincipalType = /* @__PURE__ */ ((ChannelPrincipalType2) => {
4
- ChannelPrincipalType2["User"] = "user";
5
- ChannelPrincipalType2["Service"] = "service";
6
- return ChannelPrincipalType2;
7
- })(ChannelPrincipalType || {});
8
- const channelAuthSchema = z.object({
3
+ var RoomPrincipalType = /* @__PURE__ */ ((RoomPrincipalType2) => {
4
+ RoomPrincipalType2["User"] = "user";
5
+ RoomPrincipalType2["Service"] = "service";
6
+ return RoomPrincipalType2;
7
+ })(RoomPrincipalType || {});
8
+ const roomAuthSchema = z.object({
9
9
  principalId: z.string().min(1),
10
- principalType: z.nativeEnum(ChannelPrincipalType),
10
+ principalType: z.nativeEnum(RoomPrincipalType),
11
11
  authenticator: z.string().min(1),
12
12
  // How the agent and the people reading its reply name the principal.
13
13
  displayName: z.string().min(1).max(200).optional(),
@@ -59,7 +59,7 @@ const roomReceiveResultSchema = z.union([
59
59
  z.object({ sessionId: z.string().min(1) }),
60
60
  z.null()
61
61
  ]);
62
- const channelMessageInputSchema = z.object({
62
+ const roomMessageInputSchema = z.object({
63
63
  conversationId: z.string().min(1),
64
64
  authorParticipantId: z.string().min(1),
65
65
  kind: z.nativeEnum(MessageKind).default("message" /* Message */),
@@ -89,7 +89,7 @@ const decisionCreatedDataSchema = z.object({
89
89
  const decisionResolvedDataSchema = z.object({
90
90
  decisionId: z.string().min(1),
91
91
  outcome: jsonValueSchema,
92
- respondedBy: channelAuthSchema.nullable().default(null)
92
+ respondedBy: roomAuthSchema.nullable().default(null)
93
93
  });
94
94
  const PROJECTED_UPDATE_KINDS = /* @__PURE__ */ new Set([
95
95
  "agent_message_chunk",
@@ -133,7 +133,6 @@ const turnEndUpdate = (stopReason) => {
133
133
  const defineRoomSurface = (definition) => definition;
134
134
  export {
135
135
  CardKind,
136
- ChannelPrincipalType,
137
136
  ConversationKind,
138
137
  DecisionEventKind,
139
138
  DecisionKind,
@@ -141,14 +140,15 @@ export {
141
140
  MessageKind,
142
141
  PROJECTED_UPDATE_KINDS,
143
142
  ParticipantKind,
143
+ RoomPrincipalType,
144
144
  RoutingMode,
145
145
  TurnPolicy,
146
- channelAuthSchema,
147
- channelMessageInputSchema,
148
146
  decisionCreatedDataSchema,
149
147
  decisionResolvedDataSchema,
150
148
  defineRoomSurface,
151
149
  principalDisplayName,
150
+ roomAuthSchema,
151
+ roomMessageInputSchema,
152
152
  roomReceiveResultSchema,
153
153
  turnEndOf,
154
154
  turnEndUpdate
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/room-surface.ts"],
4
- "sourcesContent": ["import type { HostedBindingsIface } from \"./hosted-bindings.mjs\";\nimport type { ContentBlock, SessionUpdate } from '@agentclientprotocol/sdk/experimental/v2';\nimport type { SessionUpdateKind } from '@finalai/acp-session';\nimport * as z from 'zod';\nimport { jsonObjectSchema, jsonValueSchema, type JsonObject, type JsonValue } from \"./json.mjs\";\nimport type { ProviderRef } from \"./provider-ref.mjs\";\nimport type { SemanticChannelEventKind } from \"./semantic-events.mjs\";\n\n// Contracts for customizing Final chats. Admission callbacks receive the\n// current message and members; renderers and events can post room output.\n// External transports use the separate scoped channel contract.\n\nexport enum ChannelPrincipalType {\n User = 'user',\n Service = 'service',\n}\n\n// Who a channel authenticated for an input or a response. Channels vouch for\n// their principals; one principal per authenticator (`slack:<user>`), so\n// the same person on two surfaces is two principals.\nexport interface ChannelAuthIface extends JsonObject {\n principalId: string;\n principalType: ChannelPrincipalType | `${ChannelPrincipalType}`;\n authenticator: string;\n // `displayName` (a string) when the channel names the principal; see principalDisplayName.\n attributes: JsonObject;\n}\n\nexport const channelAuthSchema = z.object({\n principalId: z.string().min(1),\n principalType: z.nativeEnum(ChannelPrincipalType),\n authenticator: z.string().min(1),\n // How the agent and the people reading its reply name the principal.\n displayName: z.string().min(1).max(200).optional(),\n attributes: jsonObjectSchema.default({}),\n});\n\n// How a principal is named to the agent and in captions: its `displayName`, else its id.\nexport const principalDisplayName = (auth: ChannelAuthIface): string => {\n const name = auth['displayName'];\n return typeof name === 'string' && name.length > 0 ? name : auth.principalId;\n};\n\nexport enum ConversationKind {\n Direct = 'direct',\n Group = 'group',\n}\n\nexport enum ParticipantKind {\n User = 'user',\n Agent = 'agent',\n}\n\nexport enum RoutingMode {\n Mention = 'mention',\n All = 'all',\n Default = 'default',\n}\n\nexport enum TurnPolicy {\n Steer = 'steer',\n Queue = 'queue',\n}\n\nexport enum Delivery {\n Prompt = 'prompt',\n Observe = 'observe',\n}\n\nexport enum MessageKind {\n Message = 'message',\n Card = 'card',\n}\n\nexport enum CardKind {\n Elicitation = 'elicitation',\n Permission = 'permission',\n Notice = 'notice',\n}\n\nexport interface ParticipantIface {\n id: string;\n kind: ParticipantKind;\n displayName: string;\n userId: string | null;\n definitionId: string | null;\n routingMode: RoutingMode | null;\n sessionId: string | null;\n // Whether the agent's harness supports _final/session/observe and renders\n // _meta[\"final.ai\"].author; null for non-agents.\n supportsObserve: boolean | null;\n rendersAuthorMeta: boolean | null;\n left: boolean;\n}\n\nexport const roomReceiveResultSchema = z.union([\n z.object({ conversationId: z.string().min(1) }),\n z.object({ sessionId: z.string().min(1) }),\n z.null(),\n]);\nexport type RoomReceiveResult = z.infer<typeof roomReceiveResultSchema>;\n\nexport interface ConversationRefIface {\n conversationId: string;\n}\n\nexport interface ConversationIface extends ConversationRefIface {\n organizationId: string;\n kind: ConversationKind;\n title: string | null;\n isHome: boolean;\n turnPolicy: TurnPolicy;\n}\n\nexport interface MessageRefIface {\n messageId: string;\n seq: number;\n}\n\nexport interface ConversationMessageIface extends MessageRefIface {\n conversationId: string;\n authorParticipantId: string;\n kind: MessageKind;\n body: string;\n content: ContentBlock[];\n replyToMessageId: string | null;\n threadRootId: string | null;\n // Earlier messages of the conversation the author quoted, in order.\n quotedMessageIds: string[];\n // Agent participant ids explicitly mentioned in the message.\n mentionedParticipantIds: string[];\n // Number of agent-authored hops that led to this message (0 for humans).\n hopDepth: number;\n // The originating agent for a tool-posted message, including linked conversations.\n agentAuthorDefinitionId?: string | null;\n createdAt: string;\n}\n\nexport interface RouteArgsIface {\n conversation: ConversationIface;\n message: ConversationMessageIface;\n participants: ParticipantIface[];\n agentParticipantId?: string;\n}\n\nexport interface RouteDecisionIface {\n participantId: string;\n delivery: Delivery;\n}\n\nexport interface PostMessageArgsIface {\n conversationId: string;\n authorParticipantId: string;\n kind?: MessageKind;\n content: ContentBlock[];\n replyToMessageId?: string | null;\n threadRootId?: string | null;\n quotedMessageIds?: string[];\n clientMessageId?: string | null;\n mentionedParticipantIds?: string[];\n attachmentIds?: string[];\n hopDepth?: number;\n // A tool or linked-conversation event carries the turn that produced it.\n originTurnId?: string | null;\n // Projection provenance for agent replies.\n source?: { turnId: string; fromSeq: number; toSeq: number } | null;\n}\n\nexport const channelMessageInputSchema = z.object({\n conversationId: z.string().min(1),\n authorParticipantId: z.string().min(1),\n kind: z.nativeEnum(MessageKind).default(MessageKind.Message),\n content: z.array(jsonObjectSchema).min(1),\n clientMessageId: z.string().min(1).nullish(),\n replyToMessageId: z.string().min(1).nullish(),\n threadRootId: z.string().min(1).nullish(),\n quotedMessageIds: z.array(z.string().min(1)).default([]),\n mentionedParticipantIds: z.array(z.string().min(1)).default([]),\n});\n\nexport interface CardArgsIface {\n conversationId: string;\n authorParticipantId: string;\n kind: CardKind;\n decisionId: string | null;\n // Generic cards only: a title, body, options, and entity links (a Goal is an\n // entity link, not a card kind).\n state: JsonObject;\n entityLinks: {\n kind: string;\n id: string;\n title?: string;\n url?: string;\n description?: string;\n imageUrl?: string;\n }[];\n}\n\nexport interface PromptArgsIface {\n waitForAcceptance?: boolean;\n channelBinding?: { id: string; revisionId: string };\n auth?: ChannelAuthIface | null;\n title?: string;\n participantId: string;\n content: ContentBlock[];\n turnPolicy: TurnPolicy;\n replyExpected: boolean;\n idempotencyKey: string;\n // Who prompted (for payer resolution and decision audience).\n authorParticipantId: string;\n // The person a prompt from no person acts for (payer and audience).\n actingUserId?: string | null;\n audienceParticipantIds: string[];\n sourceMessageId: string;\n}\n\nexport interface ObserveArgsIface {\n participantId: string;\n content: ContentBlock[];\n idempotencyKey: string;\n}\n\n// Operations available while customizing a Final chat.\nexport interface RoomPlatformIface {\n conversations: {\n get(conversationId: string): Promise<ConversationIface | null>;\n createAttachmentUpload?(args: {\n conversationId: string;\n name: string;\n contentType: string;\n sizeBytes: number;\n }): Promise<{\n attachmentId: string;\n uploadUrl: string;\n method: string;\n headers: Record<string, string>;\n expiresAt: string;\n }>;\n getAttachmentUrl?(args: {\n conversationId: string;\n attachmentId: string;\n }): Promise<{ attachmentId: string; url: string; expiresAt: string }>;\n // Dispatch a stored reply to each recipient's binding; each channel owns routing.\n dispatchMessage?(args: {\n conversationId: string;\n messageId: string;\n participantId?: string;\n requestedDelivery?: Delivery;\n }): Promise<void>;\n participants(conversationId: string): Promise<ParticipantIface[]>;\n postMessage(args: PostMessageArgsIface): Promise<ConversationMessageIface>;\n updateMessage(args: {\n messageId: string;\n content: ContentBlock[];\n final: boolean;\n }): Promise<void>;\n postCard(args: CardArgsIface): Promise<ConversationMessageIface>;\n updateCard(args: { messageId: string; state: JsonObject }): Promise<void>;\n recentMessages(args: {\n conversationId: string;\n limit: number;\n beforeSeq?: number;\n afterSeq?: number;\n }): Promise<ConversationMessageIface[]>;\n // Messages of the conversation by id, however old (reply, thread and quote\n // context outside the recent window); unknown and deleted ones are absent.\n getMessages(args: {\n conversationId: string;\n messageIds: string[];\n }): Promise<ConversationMessageIface[]>;\n };\n sessions: {\n prompt(\n args: PromptArgsIface,\n ): Promise<{ messageId: string; sessionId?: string; turnId?: string }>;\n observe(args: ObserveArgsIface): Promise<void>;\n cancel(args: {\n participantId: string;\n reason?: string;\n throughMessageSeq?: number;\n }): Promise<void>;\n respond?(args: ChannelInputResponseIface): Promise<{ resolved: boolean }>;\n };\n log(message: string, details?: Record<string, JsonValue>): void;\n}\n\nexport interface ChannelInputResponseIface {\n channelBinding?: { id: string; revisionId: string };\n auth?: ChannelAuthIface | null;\n participantId: string;\n decisionId: string;\n outcome: JsonValue;\n actorParticipantId: string;\n userId: string | null;\n}\n\nexport interface RoomReceiveContextIface {\n bindings?: HostedBindingsIface;\n platform: RoomPlatformIface;\n organizationId: string;\n definitionId: string | null;\n bindingId: string | null;\n config: JsonObject;\n secrets: { get(name: string): Promise<string | null> };\n // A stored, authenticated delivery to one agent in a shared conversation.\n agentParticipantId?: string;\n message?: ConversationMessageIface;\n conversation?: ConversationIface;\n participants?: readonly ParticipantIface[];\n response?: ChannelInputResponseIface;\n conversationId?: string;\n cancelReason?: string;\n // Preserve this boundary when forwarding a retryable conversation Stop.\n cancelThroughMessageSeq?: number;\n requestedDelivery?: Delivery;\n}\n\nexport interface ChannelSocketIface {\n readonly signal: AbortSignal;\n readonly messages: AsyncIterable<string | Uint8Array>;\n // Authenticate the request before accepting. The selected protocol must have been offered.\n accept(options?: { protocol?: string }): void;\n send(data: string | Uint8Array): void;\n close(code?: number, reason?: string): void;\n}\n\n// State starts null and persists for the callbacks of one turn.\nexport interface ChannelTurnStateIface<State> {\n get(): State | null;\n set(state: State | null): void;\n}\n\nexport interface ProjectionContextIface<State = JsonValue> {\n bindings?: HostedBindingsIface;\n sessionId?: string;\n platform: RoomPlatformIface;\n // The binding's config and the agent's secrets (manifest.secrets), as receive gets them:\n // a channel posts its replies back to its own service with them.\n config: JsonObject;\n secrets: { get(name: string): Promise<string | null> };\n conversation: ConversationIface | null;\n agentParticipant: ParticipantIface | null;\n turn: { id: string; promptMessageId: string | null; authorParticipantId: string | null };\n seq: number;\n state: ChannelTurnStateIface<State>;\n}\n\nexport enum DecisionEventKind {\n Created = 'decision.created',\n Resolved = 'decision.resolved',\n}\n\nexport type AcpUpdateKind = SessionUpdate['sessionUpdate'];\n// The update kinds ACP v2 names; AcpUpdateKind also admits any other string.\nexport type KnownAcpUpdateKind = `${SessionUpdateKind}`;\n\nexport type RoomEventKind = AcpUpdateKind | `${DecisionEventKind}` | `${SemanticChannelEventKind}`;\n\nexport interface ChannelEventIface {\n type: string;\n data: JsonValue;\n seq: number;\n}\n\nexport type RoomEventHandler<State = JsonValue> = (\n event: ChannelEventIface,\n ctx: ProjectionContextIface<State>,\n) => Promise<void>;\n\nexport enum DecisionKind {\n Permission = 'permission',\n Elicitation = 'elicitation',\n}\n\n// `data` of a decision.created event: an ACP session/request_permission or\n// elicitation/create request awaiting its audience.\nexport const decisionCreatedDataSchema = z.object({\n decisionId: z.string().min(1),\n kind: z.nativeEnum(DecisionKind),\n audienceParticipantIds: z.array(z.string()),\n request: jsonValueSchema,\n});\n\nexport type DecisionCreatedDataIface = z.infer<typeof decisionCreatedDataSchema>;\n\n// `data` of a decision.resolved event: the answer (or cancellation) as recorded,\n// and the principal a channel answered as (null for Final rooms and expiries).\nexport const decisionResolvedDataSchema = z.object({\n decisionId: z.string().min(1),\n outcome: jsonValueSchema,\n respondedBy: channelAuthSchema.nullable().default(null),\n});\n\nexport type DecisionResolvedDataIface = z.infer<typeof decisionResolvedDataSchema>;\n\n// The visible-output updates `project` receives. After them, the\n// turn's projection ends with one ACP v2 idle `state_update` (turnEndUpdate).\n// Thought, tool, plan and every other update, other state updates included,\n// reach a channel only through an `events` handler for its kind.\nexport const PROJECTED_UPDATE_KINDS: ReadonlySet<AcpUpdateKind> = new Set<AcpUpdateKind>([\n 'agent_message_chunk',\n 'agent_message',\n]);\n\nconst turnEndSchema = z.looseObject({\n sessionUpdate: z.literal('state_update'),\n state: z.literal('idle'),\n stopReason: z.string().nullish(),\n _meta: z\n .looseObject({ 'final.ai': z.looseObject({ stopReason: z.string().nullish() }).nullish() })\n .nullish(),\n});\n\n// The stop reason when the update ends the turn (an idle state_update); null otherwise.\nexport const turnEndOf = (update: SessionUpdate): { stopReason: string | null } | null => {\n const parsed = turnEndSchema.safeParse(update);\n if (!parsed.success) return null;\n return {\n stopReason: parsed.data.stopReason ?? parsed.data._meta?.['final.ai']?.stopReason ?? null,\n };\n};\n\n// The idle state_update that ends a turn, as `project` receives it. A stop\n// reason outside ACP's known set rides in `_meta[\"final.ai\"]` (the SDK types\n// only received values as unknown variants).\nexport const turnEndUpdate = (stopReason: string | null): SessionUpdate => {\n switch (stopReason) {\n case null:\n return { sessionUpdate: 'state_update', state: 'idle' };\n case 'end_turn':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'end_turn' };\n case 'max_tokens':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'max_tokens' };\n case 'max_turn_requests':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'max_turn_requests' };\n case 'refusal':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'refusal' };\n case 'cancelled':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'cancelled' };\n default:\n return {\n sessionUpdate: 'state_update',\n state: 'idle',\n _meta: { 'final.ai': { stopReason } },\n };\n }\n};\n\n// The Final chat admission, routing and rendering extension.\nexport interface RoomSurfaceDefinitionIface<Inbound, State = undefined> {\n config?: JsonObject;\n // Installed execution is an optimization for an uncustomized definition.\n installed?: ProviderRef;\n configure?: (config: JsonObject) => RoomSurfaceDefinitionIface<Inbound, State>;\n respond?(\n input: ChannelInputResponseIface,\n ctx: RoomReceiveContextIface,\n ): Promise<{ resolved: boolean }>;\n cancel?(ctx: RoomReceiveContextIface): Promise<{ accepted: boolean }>;\n // Inserts the input into its conversation and routes it. Returns where it went.\n receive(input: Inbound, ctx: RoomReceiveContextIface): Promise<RoomReceiveResult>;\n // Pure: who gets this message, and how. The channel applies it\n // to what it posts, from receive and project.\n route(args: RouteArgsIface): RouteDecisionIface[] | Promise<RouteDecisionIface[]>;\n turnPolicy: TurnPolicy;\n // ACP update \u2192 visible message / card. Called with a turn's\n // PROJECTED_UPDATE_KINDS updates in seq order, then its idle state_update.\n project(update: SessionUpdate, ctx: ProjectionContextIface<State>): Promise<void>;\n events?: Partial<Record<RoomEventKind, RoomEventHandler<State>>>;\n}\n\nexport const defineRoomSurface = <Inbound, State = undefined>(\n definition: RoomSurfaceDefinitionIface<Inbound, State>,\n): RoomSurfaceDefinitionIface<Inbound, State> => definition;\n"],
5
- "mappings": "AAGA,YAAY,OAAO;AACnB,SAAS,kBAAkB,uBAAwD;AAQ5E,IAAK,uBAAL,kBAAKA,0BAAL;AACL,EAAAA,sBAAA,UAAO;AACP,EAAAA,sBAAA,aAAU;AAFA,SAAAA;AAAA,GAAA;AAgBL,MAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC7B,eAAe,EAAE,WAAW,oBAAoB;AAAA,EAChD,eAAe,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA;AAAA,EAE/B,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE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+C;",
6
- "names": ["ChannelPrincipalType", "ConversationKind", "ParticipantKind", "RoutingMode", "TurnPolicy", "Delivery", "MessageKind", "CardKind", "DecisionEventKind", "DecisionKind"]
4
+ "sourcesContent": ["import type { HostedBindingsIface } from \"./hosted-bindings.mjs\";\nimport type { ContentBlock, SessionUpdate } from '@agentclientprotocol/sdk/experimental/v2';\nimport type { SessionUpdateKind } from '@finalai/acp-session';\nimport * as z from 'zod';\nimport type { ChannelTurnStateIface } from \"./channel.mjs\";\nimport { jsonObjectSchema, jsonValueSchema, type JsonObject, type JsonValue } from \"./json.mjs\";\nimport type { SemanticChannelEventKind } from \"./semantic-events.mjs\";\n\n// Contracts for customizing Final chats. Admission callbacks receive the\n// current message and members; renderers and events can post room output.\n// External transports use the separate scoped channel contract.\n\nexport enum RoomPrincipalType {\n User = 'user',\n Service = 'service',\n}\n\n// Who a room input or response came from, as vouched for by its authenticator.\nexport interface RoomAuthIface extends JsonObject {\n principalId: string;\n principalType: RoomPrincipalType | `${RoomPrincipalType}`;\n authenticator: string;\n // `displayName` (a string) when the principal is named; see principalDisplayName.\n attributes: JsonObject;\n}\n\nexport const roomAuthSchema = z.object({\n principalId: z.string().min(1),\n principalType: z.nativeEnum(RoomPrincipalType),\n authenticator: z.string().min(1),\n // How the agent and the people reading its reply name the principal.\n displayName: z.string().min(1).max(200).optional(),\n attributes: jsonObjectSchema.default({}),\n});\n\n// How a principal is named to the agent and in captions: its `displayName`, else its id.\nexport const principalDisplayName = (auth: RoomAuthIface): string => {\n const name = auth['displayName'];\n return typeof name === 'string' && name.length > 0 ? name : auth.principalId;\n};\n\nexport enum ConversationKind {\n Direct = 'direct',\n Group = 'group',\n}\n\nexport enum ParticipantKind {\n User = 'user',\n Agent = 'agent',\n}\n\nexport enum RoutingMode {\n Mention = 'mention',\n All = 'all',\n Default = 'default',\n}\n\nexport enum TurnPolicy {\n Steer = 'steer',\n Queue = 'queue',\n}\n\nexport enum Delivery {\n Prompt = 'prompt',\n Observe = 'observe',\n}\n\nexport enum MessageKind {\n Message = 'message',\n Card = 'card',\n}\n\nexport enum CardKind {\n Elicitation = 'elicitation',\n Permission = 'permission',\n Notice = 'notice',\n}\n\nexport interface ParticipantIface {\n id: string;\n kind: ParticipantKind;\n displayName: string;\n userId: string | null;\n definitionId: string | null;\n routingMode: RoutingMode | null;\n sessionId: string | null;\n // Whether the agent's harness supports _final/session/observe and renders\n // _meta[\"final.ai\"].author; null for non-agents.\n supportsObserve: boolean | null;\n rendersAuthorMeta: boolean | null;\n left: boolean;\n}\n\nexport const roomReceiveResultSchema = z.union([\n z.object({ conversationId: z.string().min(1) }),\n z.object({ sessionId: z.string().min(1) }),\n z.null(),\n]);\nexport type RoomReceiveResult = z.infer<typeof roomReceiveResultSchema>;\n\nexport interface ConversationRefIface {\n conversationId: string;\n}\n\nexport interface ConversationIface extends ConversationRefIface {\n organizationId: string;\n kind: ConversationKind;\n title: string | null;\n isHome: boolean;\n turnPolicy: TurnPolicy;\n}\n\nexport interface MessageRefIface {\n messageId: string;\n seq: number;\n}\n\nexport interface ConversationMessageIface extends MessageRefIface {\n conversationId: string;\n authorParticipantId: string;\n kind: MessageKind;\n body: string;\n content: ContentBlock[];\n replyToMessageId: string | null;\n threadRootId: string | null;\n // Earlier messages of the conversation the author quoted, in order.\n quotedMessageIds: string[];\n // Agent participant ids explicitly mentioned in the message.\n mentionedParticipantIds: string[];\n // Number of agent-authored hops that led to this message (0 for humans).\n hopDepth: number;\n // The originating agent for a tool-posted message, including linked conversations.\n agentAuthorDefinitionId?: string | null;\n createdAt: string;\n}\n\nexport interface RouteArgsIface {\n conversation: ConversationIface;\n message: ConversationMessageIface;\n participants: ParticipantIface[];\n agentParticipantId?: string;\n}\n\nexport interface RouteDecisionIface {\n participantId: string;\n delivery: Delivery;\n}\n\nexport interface PostMessageArgsIface {\n conversationId: string;\n authorParticipantId: string;\n kind?: MessageKind;\n content: ContentBlock[];\n replyToMessageId?: string | null;\n threadRootId?: string | null;\n quotedMessageIds?: string[];\n clientMessageId?: string | null;\n mentionedParticipantIds?: string[];\n attachmentIds?: string[];\n hopDepth?: number;\n // A tool or linked-conversation event carries the turn that produced it.\n originTurnId?: string | null;\n // Projection provenance for agent replies.\n source?: { turnId: string; fromSeq: number; toSeq: number } | null;\n}\n\nexport const roomMessageInputSchema = z.object({\n conversationId: z.string().min(1),\n authorParticipantId: z.string().min(1),\n kind: z.nativeEnum(MessageKind).default(MessageKind.Message),\n content: z.array(jsonObjectSchema).min(1),\n clientMessageId: z.string().min(1).nullish(),\n replyToMessageId: z.string().min(1).nullish(),\n threadRootId: z.string().min(1).nullish(),\n quotedMessageIds: z.array(z.string().min(1)).default([]),\n mentionedParticipantIds: z.array(z.string().min(1)).default([]),\n});\n\nexport interface CardArgsIface {\n conversationId: string;\n authorParticipantId: string;\n kind: CardKind;\n decisionId: string | null;\n // Generic cards only: a title, body, options, and entity links (a Goal is an\n // entity link, not a card kind).\n state: JsonObject;\n entityLinks: {\n kind: string;\n id: string;\n title?: string;\n url?: string;\n description?: string;\n imageUrl?: string;\n }[];\n}\n\nexport interface PromptArgsIface {\n waitForAcceptance?: boolean;\n channelBinding?: { id: string; revisionId: string };\n auth?: RoomAuthIface | null;\n title?: string;\n participantId: string;\n content: ContentBlock[];\n turnPolicy: TurnPolicy;\n replyExpected: boolean;\n idempotencyKey: string;\n // Who prompted (for payer resolution and decision audience).\n authorParticipantId: string;\n audienceParticipantIds: string[];\n sourceMessageId: string;\n}\n\nexport interface ObserveArgsIface {\n participantId: string;\n content: ContentBlock[];\n idempotencyKey: string;\n}\n\n// Operations available while customizing a Final chat.\nexport interface RoomPlatformIface {\n conversations: {\n get(conversationId: string): Promise<ConversationIface | null>;\n createAttachmentUpload?(args: {\n conversationId: string;\n name: string;\n contentType: string;\n sizeBytes: number;\n }): Promise<{\n attachmentId: string;\n uploadUrl: string;\n method: string;\n headers: Record<string, string>;\n expiresAt: string;\n }>;\n getAttachmentUrl?(args: {\n conversationId: string;\n attachmentId: string;\n }): Promise<{ attachmentId: string; url: string; expiresAt: string }>;\n // Dispatch a stored reply to each recipient's binding; each channel owns routing.\n dispatchMessage?(args: {\n conversationId: string;\n messageId: string;\n participantId?: string;\n requestedDelivery?: Delivery;\n }): Promise<void>;\n participants(conversationId: string): Promise<ParticipantIface[]>;\n postMessage(args: PostMessageArgsIface): Promise<ConversationMessageIface>;\n updateMessage(args: {\n messageId: string;\n content: ContentBlock[];\n final: boolean;\n }): Promise<void>;\n postCard(args: CardArgsIface): Promise<ConversationMessageIface>;\n updateCard(args: { messageId: string; state: JsonObject }): Promise<void>;\n recentMessages(args: {\n conversationId: string;\n limit: number;\n beforeSeq?: number;\n afterSeq?: number;\n }): Promise<ConversationMessageIface[]>;\n // Messages of the conversation by id, however old (reply, thread and quote\n // context outside the recent window); unknown and deleted ones are absent.\n getMessages(args: {\n conversationId: string;\n messageIds: string[];\n }): Promise<ConversationMessageIface[]>;\n };\n sessions: {\n prompt(\n args: PromptArgsIface,\n ): Promise<{ messageId: string; sessionId?: string; turnId?: string }>;\n observe(args: ObserveArgsIface): Promise<void>;\n cancel(args: {\n participantId: string;\n reason?: string;\n throughMessageSeq?: number;\n }): Promise<void>;\n respond?(args: RoomInputResponseIface): Promise<{ resolved: boolean }>;\n };\n log(message: string, details?: Record<string, JsonValue>): void;\n}\n\nexport interface RoomInputResponseIface {\n channelBinding?: { id: string; revisionId: string };\n auth?: RoomAuthIface | null;\n participantId: string;\n decisionId: string;\n outcome: JsonValue;\n actorParticipantId: string;\n userId: string | null;\n}\n\nexport interface RoomReceiveContextIface {\n bindings?: HostedBindingsIface;\n platform: RoomPlatformIface;\n organizationId: string;\n definitionId: string | null;\n bindingId: string | null;\n config: JsonObject;\n secrets: { get(name: string): Promise<string | null> };\n // A stored, authenticated delivery to one agent in a shared conversation.\n agentParticipantId?: string;\n message?: ConversationMessageIface;\n conversation?: ConversationIface;\n participants?: readonly ParticipantIface[];\n response?: RoomInputResponseIface;\n conversationId?: string;\n cancelReason?: string;\n // Preserve this boundary when forwarding a retryable conversation Stop.\n cancelThroughMessageSeq?: number;\n requestedDelivery?: Delivery;\n}\n\nexport interface ProjectionContextIface<State = JsonValue> {\n bindings?: HostedBindingsIface;\n sessionId?: string;\n platform: RoomPlatformIface;\n // The binding's config and the agent's secrets (manifest.secrets), as receive gets them:\n // a channel posts its replies back to its own service with them.\n config: JsonObject;\n secrets: { get(name: string): Promise<string | null> };\n conversation: ConversationIface | null;\n agentParticipant: ParticipantIface | null;\n turn: { id: string; promptMessageId: string | null; authorParticipantId: string | null };\n seq: number;\n state: ChannelTurnStateIface<State>;\n}\n\nexport enum DecisionEventKind {\n Created = 'decision.created',\n Resolved = 'decision.resolved',\n}\n\nexport type AcpUpdateKind = SessionUpdate['sessionUpdate'];\n// The update kinds ACP v2 names; AcpUpdateKind also admits any other string.\nexport type KnownAcpUpdateKind = `${SessionUpdateKind}`;\n\nexport type RoomEventKind = AcpUpdateKind | `${DecisionEventKind}` | `${SemanticChannelEventKind}`;\n\nexport interface RoomEventIface {\n type: string;\n data: JsonValue;\n seq: number;\n}\n\nexport type RoomEventHandler<State = JsonValue> = (\n event: RoomEventIface,\n ctx: ProjectionContextIface<State>,\n) => Promise<void>;\n\nexport enum DecisionKind {\n Permission = 'permission',\n Elicitation = 'elicitation',\n}\n\n// `data` of a decision.created event: an ACP session/request_permission or\n// elicitation/create request awaiting its audience.\nexport const decisionCreatedDataSchema = z.object({\n decisionId: z.string().min(1),\n kind: z.nativeEnum(DecisionKind),\n audienceParticipantIds: z.array(z.string()),\n request: jsonValueSchema,\n});\n\nexport type DecisionCreatedDataIface = z.infer<typeof decisionCreatedDataSchema>;\n\n// `data` of a decision.resolved event: the answer (or cancellation) as recorded,\n// and the principal a channel answered as (null for Final rooms and expiries).\nexport const decisionResolvedDataSchema = z.object({\n decisionId: z.string().min(1),\n outcome: jsonValueSchema,\n respondedBy: roomAuthSchema.nullable().default(null),\n});\n\nexport type DecisionResolvedDataIface = z.infer<typeof decisionResolvedDataSchema>;\n\n// The visible-output updates `project` receives. After them, the\n// turn's projection ends with one ACP v2 idle `state_update` (turnEndUpdate).\n// Thought, tool, plan and every other update, other state updates included,\n// reach a channel only through an `events` handler for its kind.\nexport const PROJECTED_UPDATE_KINDS: ReadonlySet<AcpUpdateKind> = new Set<AcpUpdateKind>([\n 'agent_message_chunk',\n 'agent_message',\n]);\n\nconst turnEndSchema = z.looseObject({\n sessionUpdate: z.literal('state_update'),\n state: z.literal('idle'),\n stopReason: z.string().nullish(),\n _meta: z\n .looseObject({ 'final.ai': z.looseObject({ stopReason: z.string().nullish() }).nullish() })\n .nullish(),\n});\n\n// The stop reason when the update ends the turn (an idle state_update); null otherwise.\nexport const turnEndOf = (update: SessionUpdate): { stopReason: string | null } | null => {\n const parsed = turnEndSchema.safeParse(update);\n if (!parsed.success) return null;\n return {\n stopReason: parsed.data.stopReason ?? parsed.data._meta?.['final.ai']?.stopReason ?? null,\n };\n};\n\n// The idle state_update that ends a turn, as `project` receives it. A stop\n// reason outside ACP's known set rides in `_meta[\"final.ai\"]` (the SDK types\n// only received values as unknown variants).\nexport const turnEndUpdate = (stopReason: string | null): SessionUpdate => {\n switch (stopReason) {\n case null:\n return { sessionUpdate: 'state_update', state: 'idle' };\n case 'end_turn':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'end_turn' };\n case 'max_tokens':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'max_tokens' };\n case 'max_turn_requests':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'max_turn_requests' };\n case 'refusal':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'refusal' };\n case 'cancelled':\n return { sessionUpdate: 'state_update', state: 'idle', stopReason: 'cancelled' };\n default:\n return {\n sessionUpdate: 'state_update',\n state: 'idle',\n _meta: { 'final.ai': { stopReason } },\n };\n }\n};\n\n// The Final chat admission, routing and rendering extension.\nexport interface RoomSurfaceDefinitionIface<Inbound, State = undefined> {\n config?: JsonObject;\n configure?: (config: JsonObject) => RoomSurfaceDefinitionIface<Inbound, State>;\n respond?(\n input: RoomInputResponseIface,\n ctx: RoomReceiveContextIface,\n ): Promise<{ resolved: boolean }>;\n cancel?(ctx: RoomReceiveContextIface): Promise<{ accepted: boolean }>;\n // Inserts the input into its conversation and routes it. Returns where it went.\n receive(input: Inbound, ctx: RoomReceiveContextIface): Promise<RoomReceiveResult>;\n // Pure: who gets this message, and how. The channel applies it\n // to what it posts, from receive and project.\n route(args: RouteArgsIface): RouteDecisionIface[] | Promise<RouteDecisionIface[]>;\n turnPolicy: TurnPolicy;\n // ACP update \u2192 visible message / card. Called with a turn's\n // PROJECTED_UPDATE_KINDS updates in seq order, then its idle state_update.\n project(update: SessionUpdate, ctx: ProjectionContextIface<State>): Promise<void>;\n events?: Partial<Record<RoomEventKind, RoomEventHandler<State>>>;\n}\n\nexport const defineRoomSurface = <Inbound, State = undefined>(\n definition: RoomSurfaceDefinitionIface<Inbound, State>,\n): RoomSurfaceDefinitionIface<Inbound, State> => definition;\n"],
5
+ "mappings": "AAGA,YAAY,OAAO;AAEnB,SAAS,kBAAkB,uBAAwD;AAO5E,IAAK,oBAAL,kBAAKA,uBAAL;AACL,EAAAA,mBAAA,UAAO;AACP,EAAAA,mBAAA,aAAU;AAFA,SAAAA;AAAA,GAAA;AAcL,MAAM,iBAAiB,EAAE,OAAO;AAAA,EACrC,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EAC7B,eAAe,EAAE,WAAW,iBAAiB;AAAA,EAC7C,eAAe,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA;AAAA,EAE/B,aAAa,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,EAAE,SAAS;AAAA,EACjD,YAAY,iBAAiB,QAAQ,CAAC,CAAC;AACzC,CAAC;AAGM,MAAM,uBAAuB,CAAC,SAAgC;AACnE,QAAM,OAAO,KAAK,aAAa;AAC/B,SAAO,OAAO,SAAS,YAAY,KAAK,SAAS,IAAI,OAAO,KAAK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EAAE,OAAO,EAAE,QAAQ;AAAA,EAC/B,OAAO,EACJ,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,CAAC,EACzF,QAAQ;AACb,CAAC;AAGM,MAAM,YAAY,CAAC,WAAgE;AACxF,QAAM,SAAS,cAAc,UAAU,MAAM;AAC7C,MAAI,CAAC,OAAO,QAAS,QAAO;AAC5B,SAAO;AAAA,IACL,YAAY,OAAO,KAAK,cAAc,OAAO,KAAK,QAAQ,UAAU,GAAG,cAAc;AAAA,EACvF;AACF;AAKO,MAAM,gBAAgB,CAAC,eAA6C;AACzE,UAAQ,YAAY;AAAA,IAClB,KAAK;AACH,aAAO,EAAE,eAAe,gBAAgB,OAAO,OAAO;AAAA,IACxD,KAAK;AACH,aAAO,EAAE,eAAe,gBAAgB,OAAO,QAAQ,YAAY,WAAW;AAAA,IAChF,KAAK;AACH,aAAO,EAAE,eAAe,gBAAgB,OAAO,QAAQ,YAAY,aAAa;AAAA,IAClF,KAAK;AACH,aAAO,EAAE,eAAe,gBAAgB,OAAO,QAAQ,YAAY,oBAAoB;AAAA,IACzF,KAAK;AACH,aAAO,EAAE,eAAe,gBAAgB,OAAO,QAAQ,YAAY,UAAU;AAAA,IAC/E,KAAK;AACH,aAAO,EAAE,eAAe,gBAAgB,OAAO,QAAQ,YAAY,YAAY;AAAA,IACjF;AACE,aAAO;AAAA,QACL,eAAe;AAAA,QACf,OAAO;AAAA,QACP,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE;AAAA,MACtC;AAAA,EACJ;AACF;AAuBO,MAAM,oBAAoB,CAC/B,eAC+C;",
6
+ "names": ["RoomPrincipalType", "ConversationKind", "ParticipantKind", "RoutingMode", "TurnPolicy", "Delivery", "MessageKind", "CardKind", "DecisionEventKind", "DecisionKind"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@finalai/agent-provider",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "private": false,
5
5
  "description": "Provider contracts for the agent stack: harnesses, sandboxes (handle, wire, MCP projection), channels, credential policies, and the conformance kit.",
6
6
  "license": "Apache-2.0",
@@ -189,7 +189,7 @@
189
189
  "dependencies": {
190
190
  "@agentclientprotocol/sdk": "1.8.0",
191
191
  "@finalai/acp-session": "0.1.11",
192
- "@finalai/agent-protocol": "0.7.0",
192
+ "@finalai/agent-protocol": "0.8.0",
193
193
  "@modelcontextprotocol/client": "^2.1.0",
194
194
  "@modelcontextprotocol/core": "^2.1.0",
195
195
  "@modelcontextprotocol/server": "^2.1.0",