@finalai/agent-provider 0.9.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (206) hide show
  1. package/HOSTING.md +334 -245
  2. package/README.md +106 -20
  3. package/dist/modules/canonical-json.d.mts +4 -0
  4. package/dist/modules/canonical-json.mjs +33 -0
  5. package/dist/modules/canonical-json.mjs.map +7 -0
  6. package/dist/modules/channel.d.mts +51 -15
  7. package/dist/modules/channel.mjs +1 -0
  8. package/dist/modules/channel.mjs.map +2 -2
  9. package/dist/modules/code-host/host.d.mts +10 -0
  10. package/dist/modules/code-host/host.mjs +88 -0
  11. package/dist/modules/code-host/host.mjs.map +7 -0
  12. package/dist/modules/code-host/in-process.d.mts +24 -0
  13. package/dist/modules/code-host/in-process.mjs +89 -0
  14. package/dist/modules/code-host/in-process.mjs.map +7 -0
  15. package/dist/modules/code-host/index.d.mts +4 -0
  16. package/dist/modules/code-host/index.mjs +5 -0
  17. package/dist/modules/code-host/index.mjs.map +7 -0
  18. package/dist/modules/code-host/serverless.d.mts +63 -0
  19. package/dist/modules/code-host/serverless.mjs +27 -0
  20. package/dist/modules/code-host/serverless.mjs.map +7 -0
  21. package/dist/modules/code-host/types.d.mts +152 -0
  22. package/dist/modules/code-host/types.mjs +85 -0
  23. package/dist/modules/code-host/types.mjs.map +7 -0
  24. package/dist/modules/conformance/agent.mjs +72 -6
  25. package/dist/modules/conformance/agent.mjs.map +2 -2
  26. package/dist/modules/conformance/harness-kit.d.mts +9 -2
  27. package/dist/modules/conformance/harness-kit.mjs +224 -63
  28. package/dist/modules/conformance/harness-kit.mjs.map +3 -3
  29. package/dist/modules/conformance/local-harness.d.mts +1 -4
  30. package/dist/modules/conformance/local-harness.mjs +21 -22
  31. package/dist/modules/conformance/local-harness.mjs.map +2 -2
  32. package/dist/modules/conformance/protocol.d.mts +1 -0
  33. package/dist/modules/conformance/protocol.mjs +2 -0
  34. package/dist/modules/conformance/protocol.mjs.map +2 -2
  35. package/dist/modules/conformance/sandbox-kit.d.mts +12 -4
  36. package/dist/modules/conformance/sandbox-kit.mjs +189 -103
  37. package/dist/modules/conformance/sandbox-kit.mjs.map +2 -2
  38. package/dist/modules/conformance/scripted-model/chat-completions.mjs +1 -0
  39. package/dist/modules/conformance/scripted-model/chat-completions.mjs.map +2 -2
  40. package/dist/modules/conformance/scripted-model/directives.d.mts +3 -0
  41. package/dist/modules/conformance/scripted-model/directives.mjs +26 -10
  42. package/dist/modules/conformance/scripted-model/directives.mjs.map +2 -2
  43. package/dist/modules/conformance/scripted-model/messages.mjs +1 -0
  44. package/dist/modules/conformance/scripted-model/messages.mjs.map +2 -2
  45. package/dist/modules/conformance/scripted-model/responses.mjs +2 -0
  46. package/dist/modules/conformance/scripted-model/responses.mjs.map +2 -2
  47. package/dist/modules/conformance/stdio.d.mts +21 -0
  48. package/dist/modules/conformance/stdio.mjs +158 -0
  49. package/dist/modules/conformance/stdio.mjs.map +7 -0
  50. package/dist/modules/credential-routes.d.mts +3 -3
  51. package/dist/modules/credential-routes.mjs +2 -2
  52. package/dist/modules/credential-routes.mjs.map +2 -2
  53. package/dist/modules/document.d.mts +358 -0
  54. package/dist/modules/document.mjs +193 -0
  55. package/dist/modules/document.mjs.map +7 -0
  56. package/dist/modules/harness-configuration.d.mts +16 -0
  57. package/dist/modules/harness-configuration.mjs +83 -0
  58. package/dist/modules/harness-configuration.mjs.map +7 -0
  59. package/dist/modules/harness-definition.d.mts +280 -0
  60. package/dist/modules/harness-definition.mjs +430 -0
  61. package/dist/modules/harness-definition.mjs.map +7 -0
  62. package/dist/modules/harness-provider.d.mts +197 -0
  63. package/dist/modules/harness-provider.mjs +108 -0
  64. package/dist/modules/harness-provider.mjs.map +7 -0
  65. package/dist/modules/harness-requirements.d.mts +19 -0
  66. package/dist/modules/harness-requirements.mjs +40 -0
  67. package/dist/modules/harness-requirements.mjs.map +7 -0
  68. package/dist/modules/harness-start.d.mts +33 -0
  69. package/dist/modules/harness-start.mjs +107 -0
  70. package/dist/modules/harness-start.mjs.map +7 -0
  71. package/dist/modules/harness.d.mts +84 -109
  72. package/dist/modules/harness.mjs +56 -111
  73. package/dist/modules/harness.mjs.map +3 -3
  74. package/dist/modules/identity.d.mts +1 -0
  75. package/dist/modules/identity.mjs +2 -0
  76. package/dist/modules/identity.mjs.map +7 -0
  77. package/dist/modules/index.d.mts +12 -7
  78. package/dist/modules/index.mjs +12 -7
  79. package/dist/modules/index.mjs.map +2 -2
  80. package/dist/modules/inference.d.mts +35 -0
  81. package/dist/modules/inference.mjs +74 -0
  82. package/dist/modules/inference.mjs.map +7 -0
  83. package/dist/modules/local-channel-context.d.mts +1 -1
  84. package/dist/modules/local-channel-context.mjs +1 -1
  85. package/dist/modules/local-channel-context.mjs.map +2 -2
  86. package/dist/modules/requirements-check.d.mts +30 -0
  87. package/dist/modules/requirements-check.mjs +164 -0
  88. package/dist/modules/requirements-check.mjs.map +7 -0
  89. package/dist/modules/sandbox/client.d.mts +3 -0
  90. package/dist/modules/sandbox/client.mjs +101 -18
  91. package/dist/modules/sandbox/client.mjs.map +2 -2
  92. package/dist/modules/sandbox/grant.d.mts +78 -0
  93. package/dist/modules/sandbox/grant.mjs +134 -0
  94. package/dist/modules/sandbox/grant.mjs.map +7 -0
  95. package/dist/modules/sandbox/index.d.mts +3 -3
  96. package/dist/modules/sandbox/index.mjs +4 -5
  97. package/dist/modules/sandbox/index.mjs.map +2 -2
  98. package/dist/modules/sandbox/mcp-hosted.d.mts +1 -1
  99. package/dist/modules/sandbox/mcp-hosted.mjs +4 -7
  100. package/dist/modules/sandbox/mcp-hosted.mjs.map +2 -2
  101. package/dist/modules/sandbox/mcp.d.mts +4 -2
  102. package/dist/modules/sandbox/mcp.mjs +14 -7
  103. package/dist/modules/sandbox/mcp.mjs.map +2 -2
  104. package/dist/modules/sandbox/memory-sandbox.d.mts +2 -1
  105. package/dist/modules/sandbox/memory-sandbox.mjs +71 -41
  106. package/dist/modules/sandbox/memory-sandbox.mjs.map +2 -2
  107. package/dist/modules/sandbox/networking.d.mts +7 -7
  108. package/dist/modules/sandbox/networking.mjs +16 -9
  109. package/dist/modules/sandbox/networking.mjs.map +2 -2
  110. package/dist/modules/sandbox/remote/adapter.d.mts +30 -0
  111. package/dist/modules/sandbox/remote/adapter.mjs +381 -0
  112. package/dist/modules/sandbox/remote/adapter.mjs.map +7 -0
  113. package/dist/modules/sandbox/remote/body.d.mts +1 -0
  114. package/dist/modules/sandbox/remote/body.mjs +27 -0
  115. package/dist/modules/sandbox/remote/body.mjs.map +7 -0
  116. package/dist/modules/sandbox/remote/errors.d.mts +10 -0
  117. package/dist/modules/sandbox/remote/errors.mjs +62 -0
  118. package/dist/modules/sandbox/remote/errors.mjs.map +7 -0
  119. package/dist/modules/sandbox/remote/index.d.mts +5 -0
  120. package/dist/modules/sandbox/remote/index.mjs +6 -0
  121. package/dist/modules/sandbox/remote/index.mjs.map +7 -0
  122. package/dist/modules/sandbox/remote/ndjson.d.mts +6 -0
  123. package/dist/modules/sandbox/remote/ndjson.mjs +80 -0
  124. package/dist/modules/sandbox/remote/ndjson.mjs.map +7 -0
  125. package/dist/modules/sandbox/remote/platform-api.d.mts +8 -0
  126. package/dist/modules/sandbox/remote/platform-api.mjs +15 -0
  127. package/dist/modules/sandbox/remote/platform-api.mjs.map +7 -0
  128. package/dist/modules/sandbox/remote/preamble.d.mts +7 -0
  129. package/dist/modules/sandbox/remote/preamble.mjs +51 -0
  130. package/dist/modules/sandbox/remote/preamble.mjs.map +7 -0
  131. package/dist/modules/sandbox/remote/serve.d.mts +34 -0
  132. package/dist/modules/sandbox/remote/serve.mjs +520 -0
  133. package/dist/modules/sandbox/remote/serve.mjs.map +7 -0
  134. package/dist/modules/sandbox/remote/testing.d.mts +34 -0
  135. package/dist/modules/sandbox/remote/testing.mjs +275 -0
  136. package/dist/modules/sandbox/remote/testing.mjs.map +7 -0
  137. package/dist/modules/sandbox/seeds.d.mts +2 -2
  138. package/dist/modules/sandbox/seeds.mjs +2 -2
  139. package/dist/modules/sandbox/seeds.mjs.map +2 -2
  140. package/dist/modules/sandbox/server.d.mts +4 -6
  141. package/dist/modules/sandbox/server.mjs +93 -49
  142. package/dist/modules/sandbox/server.mjs.map +2 -2
  143. package/dist/modules/sandbox/setup/apply.d.mts +40 -0
  144. package/dist/modules/sandbox/setup/apply.mjs +190 -0
  145. package/dist/modules/sandbox/setup/apply.mjs.map +7 -0
  146. package/dist/modules/sandbox/setup/describe.d.mts +10 -0
  147. package/dist/modules/sandbox/setup/describe.mjs +62 -0
  148. package/dist/modules/sandbox/setup/describe.mjs.map +7 -0
  149. package/dist/modules/sandbox/setup/index.d.mts +6 -0
  150. package/dist/modules/sandbox/setup/index.mjs +17 -0
  151. package/dist/modules/sandbox/setup/index.mjs.map +7 -0
  152. package/dist/modules/sandbox/setup/paths.d.mts +8 -0
  153. package/dist/modules/sandbox/setup/paths.mjs +18 -0
  154. package/dist/modules/sandbox/setup/paths.mjs.map +7 -0
  155. package/dist/modules/sandbox/setup/schema.d.mts +43 -0
  156. package/dist/modules/sandbox/setup/schema.mjs +58 -0
  157. package/dist/modules/sandbox/setup/schema.mjs.map +7 -0
  158. package/dist/modules/sandbox/tool-policy.d.mts +1 -1
  159. package/dist/modules/sandbox/tool-policy.mjs +1 -1
  160. package/dist/modules/sandbox/tool-policy.mjs.map +2 -2
  161. package/dist/modules/sandbox/types.d.mts +117 -142
  162. package/dist/modules/sandbox/types.mjs +47 -57
  163. package/dist/modules/sandbox/types.mjs.map +3 -3
  164. package/dist/modules/sandbox/wire.d.mts +93 -6
  165. package/dist/modules/sandbox/wire.mjs +61 -38
  166. package/dist/modules/sandbox/wire.mjs.map +2 -2
  167. package/dist/modules/schemas.d.mts +5 -76
  168. package/dist/modules/schemas.mjs +18 -85
  169. package/dist/modules/schemas.mjs.map +2 -2
  170. package/dist/modules/tool-annotations.d.mts +15 -6
  171. package/dist/modules/tool-annotations.mjs +9 -3
  172. package/dist/modules/tool-annotations.mjs.map +2 -2
  173. package/dist/modules/tool-descriptor.d.mts +16 -0
  174. package/dist/modules/tool-descriptor.mjs +19 -0
  175. package/dist/modules/tool-descriptor.mjs.map +7 -0
  176. package/dist/modules/tool-patterns.d.mts +7 -7
  177. package/dist/modules/tool-patterns.mjs +10 -9
  178. package/dist/modules/tool-patterns.mjs.map +2 -2
  179. package/package.json +86 -41
  180. package/dist/modules/credentials.d.mts +0 -206
  181. package/dist/modules/credentials.mjs +0 -207
  182. package/dist/modules/credentials.mjs.map +0 -7
  183. package/dist/modules/dynamic.d.mts +0 -40
  184. package/dist/modules/dynamic.mjs +0 -79
  185. package/dist/modules/dynamic.mjs.map +0 -7
  186. package/dist/modules/hosted-bindings.d.mts +0 -15
  187. package/dist/modules/hosted-bindings.mjs +0 -21
  188. package/dist/modules/hosted-bindings.mjs.map +0 -7
  189. package/dist/modules/manifest.d.mts +0 -791
  190. package/dist/modules/manifest.mjs +0 -322
  191. package/dist/modules/manifest.mjs.map +0 -7
  192. package/dist/modules/provider-ref.d.mts +0 -29
  193. package/dist/modules/provider-ref.mjs +0 -55
  194. package/dist/modules/provider-ref.mjs.map +0 -7
  195. package/dist/modules/room-surface.d.mts +0 -355
  196. package/dist/modules/room-surface.mjs +0 -156
  197. package/dist/modules/room-surface.mjs.map +0 -7
  198. package/dist/modules/sandbox/open-scope-node.d.mts +0 -4
  199. package/dist/modules/sandbox/open-scope-node.mjs +0 -19
  200. package/dist/modules/sandbox/open-scope-node.mjs.map +0 -7
  201. package/dist/modules/sandbox/open-scope.d.mts +0 -16
  202. package/dist/modules/sandbox/open-scope.mjs +0 -66
  203. package/dist/modules/sandbox/open-scope.mjs.map +0 -7
  204. package/dist/modules/sandbox/workspace-identity.d.mts +0 -5
  205. package/dist/modules/sandbox/workspace-identity.mjs +0 -14
  206. package/dist/modules/sandbox/workspace-identity.mjs.map +0 -7
package/README.md CHANGED
@@ -1,7 +1,68 @@
1
1
  # @finalai/agent-provider
2
2
 
3
- Contracts for custom harnesses, sandboxes, channels, and credential policies, plus
4
- RPC/MCP projections and conformance tools for integration authors.
3
+ Contracts for the agent stack: the agent document and its requirements, harnesses,
4
+ sandboxes, the code host and channels, plus RPC/MCP projections and conformance
5
+ tools for integration authors.
6
+
7
+ ## Agents declare requirements; callers provide them
8
+
9
+ An agent is one JSON document (`agentDocumentSchema`, exported as `./document`):
10
+ identity, instructions, skills, the tools and hooks it defines, and what it
11
+ `require`s: a harness (a permission ceiling, the features it can live without and
12
+ an optional recommendation), compute keyed by capability (`files`, `shell`,
13
+ `computerUse`, `browserUse`, each with an access ceiling) and named integration
14
+ slots. It never names what provides them. `agentDocumentHash` is its identity: the
15
+ content hash of the canonical document, defaults applied.
16
+
17
+ Whoever starts work provides the rest as plain data: harness settings
18
+ (`{ harness, adapter?, configuration, environment? }`), a sandbox per capability and an
19
+ integration per slot. `unmetRequirements` is the single check every caller runs
20
+ before anything starts; `files` and `shell` must name the same sandbox. Inference
21
+ sources (`subscription()`, `apiKey(name)`, `finalCredits()`, `harnessLogin()`) are
22
+ an ordered list in the harness settings: the first available one wins.
23
+
24
+ Each tool and hook says where its code runs. In-process code runs in the process
25
+ that created the session; serverless code carries its own self-contained source in
26
+ the document. `createCodeHost` (`./code-host`) routes a tool call, hook or approval
27
+ predicate by that placement, and `serveInProcessCode` answers in-process calls on
28
+ the creating client's side; both speak the same invocation and line schemas.
29
+
30
+ Harnesses, ACP adapters and environments are independent pieces
31
+ (`./harness-definition`): a harness definition and an ACP adapter definition are
32
+ data with run entries per runtime kind (`process`, `worker`), an environment is a
33
+ sandbox whose provider declares the runtime kinds it runs, or an ACP endpoint at a
34
+ URL. `composeHarness` picks a runtime all three share for the requirements check,
35
+ and a harness provider (`./harness-provider`) starts adapter(harness) there and
36
+ returns the ACP endpoint.
37
+
38
+ ## Harnesses
39
+
40
+ A harness definition says what it accepts: the document features it supports,
41
+ the lowest permission it can be held to, the inference sources it can use, what it
42
+ uses natively where it runs (`files`, `shell`) and the JSON Schema of its
43
+ configuration. `validateHarnessConfiguration` (`./harness-configuration`) checks a
44
+ configuration against that schema (its `final://schemas/*` references resolve to
45
+ the shared fragments) and the definition's limits; `acceptsHarnessSettings` also
46
+ checks that the settings name the harness. `harnessCheckInputOf` turns a composed
47
+ harness into the requirements check's input. A harness is opened with the agent
48
+ document, the resolved settings and one sandbox endpoint per capability it drives.
49
+
50
+ ## Sandboxes
51
+
52
+ A sandbox is a resource. A provider implements `create`, `attach` (reporting
53
+ whether the disk is `fresh` and the machine `booted`), `detach`, `park` and
54
+ `delete`, plus `capabilities` (each capability it serves with the most access it
55
+ grants) and the cached `artifactKey`/`prepare` preparation. Every handle RPC method
56
+ is gated by the connection's per-capability grant (`./sandbox/grant`): `{ files:
57
+ 'write' }` writes files and runs nothing.
58
+
59
+ A sandbox setup (`defineSandboxSetup`, `./sandbox/setup`) is provider-neutral:
60
+ repositories, variables (values or project secrets by name), steps run once per
61
+ sandbox, services started after each boot, named commands and notes.
62
+ `applySandboxSetup` applies it through the standard handle in idempotent phases,
63
+ so a resumed sandbox redoes only what its attach lost, and passes secrets to
64
+ process environments only. `describeSandbox` reports the real checkout paths,
65
+ service URLs and commands.
5
66
 
6
67
  Sandbox networking is a composable extension. `SandboxNetworkingExtensionIface`
7
68
  owns policy persistence, controller setup, readiness and suspension; the sandbox
@@ -22,21 +83,42 @@ equivalent admission, deferred setup and failure cleanup. Namespace-only adapter
22
83
  must disclose the startup traffic window when their provider cannot fence boot.
23
84
 
24
85
  Hosts pass `credentials` (`SandboxCredentialsIface`) on sandbox contexts:
25
- `computersAccess()`, `deviceAccess({ actingUserId })` and `secret({ secretRef })`.
26
- Providers that need a third-party key take `credential: { secretRef }`
27
- (`sandboxCredentialRefSchema`) in their environment options.
86
+ `secret({ secretRef })`, resolved in the sandbox's project. Providers that need a
87
+ third-party key take `credential: { secretRef }` (`sandboxCredentialRefSchema`) in
88
+ their environment options. A backend the provider's registration was granted is
89
+ reached with `identity({ audience })`: a platform-identity assertion for that
90
+ backend, naming the sandbox and the acting user, which the backend verifies with
91
+ `/identity`. `lifecycle.parkAfterIdleMs` says when the platform parks an idle
92
+ sandbox, so a backend idle timeout can outlast it.
93
+
94
+ `/sandbox/remote` is the sandbox-provider wire. `serveSandboxProvider` serves
95
+ providers at the URLs a project registers: lifecycle calls over HTTP (long ones
96
+ answer NDJSON with heartbeats), and `/v1/attach`, a WebSocket that carries the
97
+ handle RPC once attached. Each call is authenticated by a sandbox-provider
98
+ assertion; on the attach socket `identity/refresh` replaces it when the acting
99
+ user changes. `remoteSandboxProvider` is the platform's side: an ordinary
100
+ provider over the wire that reports the applied network policy, writes the
101
+ platform's files and sets the platform's environment on every process itself.
102
+ `connectSandboxProviderInMemory` joins the two in memory, and the sandbox
103
+ conformance kit's `remote` mode runs every provider case through it.
28
104
 
29
105
  Implement the public provider interfaces and use `/conformance` to exercise them.
30
106
  Use leaf entrypoints for sandbox wire clients, servers, MCP adapters, and local
31
107
  channel sockets. These helpers adapt your integration to the provider contracts.
32
108
 
33
109
  `/conformance` provides harness and sandbox checks, profiles, and a reference harness.
110
+ The harness profiles are `plain-acp-v2` (standard ACP only), `final` (checks the
111
+ Final extensions an agent advertises) and `final-required`, which every ACP adapter
112
+ must pass: it runs each extension check (the `initialize` advertisement,
113
+ `_final/session/observe`, `_final/live_text`, `emittedAtMs`, author meta, replay
114
+ after a sequence number, provider errors) and fails those the agent does not
115
+ advertise. Fork is checked where advertised.
34
116
  `/conformance/scripted-model` provides deterministic model handlers for exercising
35
117
  your integration. The `final-agents conformance` CLI runs the harness checks.
36
118
 
37
119
  Declare `executionPolicy: { beforeExecution }` on a provider handle, or supply it
38
- in `SandboxStartContextIface` from the host. `defineSandboxProvider` automatically
39
- applies both policies to handles returned by start, resume and passive recovery;
120
+ in `SandboxResourceContextIface` from the host. `defineSandboxProvider` automatically
121
+ applies both policies to handles returned by attach and passive attach;
40
122
  the host policy runs first. Construction consumes the policy declaration so later
41
123
  composition does not reinstall it. Providers do not need to wrap execution methods.
42
124
  An ordinary provider without either policy retains its existing behavior.
@@ -64,7 +146,7 @@ retains ownership of its endpoints, with the host transport as a fallback. Pass
64
146
  Pass the complete keys from `sandboxMcpToolPolicyKeys` to `resolveSandboxToolPolicy`.
65
147
  Egress consent requires its canonical capability/action keys; arbitrary hosted
66
148
  tools can use the same display name and must retain their ordinary tool policy.
67
- When the builtin egress capability is exposed, conflicting hosted names are prefixed rather than hidden. Configure/Disable preauthorization requires its exact action key; a legacy hosted-tool `egress: Allow` cannot waive consent. Read bindings cannot change network policy, including with lifecycle authority. Handle RPC
149
+ When the builtin egress capability is exposed, conflicting hosted names are prefixed rather than hidden. Configure/Disable preauthorization requires its exact action key; a legacy hosted-tool `egress: Allow` cannot waive consent. A grant without `shell` cannot change network policy, including with lifecycle authority. Handle RPC
68
150
  hosts must supply `authorizeOperation` for Configure/Disable; without it mutations
69
151
  are refused. The host owns approval policy, including any explicit preauthorization.
70
152
 
@@ -80,15 +162,20 @@ Acquiring a hosted MCP endpoint or channel is foreground work: it may start a se
80
162
  ## Channels
81
163
 
82
164
  `ChannelDefinitionIface<Config, Inbound, State>` describes a provider namespace,
83
- its application credentials, identity proof, place kinds, routes/listeners,
84
- receive function, and typed semantic event handlers. Channels resolve people and
165
+ the provider application credentials it requires, identity proof, place kinds,
166
+ routes/listeners, receive function, and typed semantic event handlers. Channels resolve people and
85
167
  places through `ChannelReceiveContextIface`; they do not supply Final user,
86
168
  conversation or agent IDs. A host validates every opaque person/conversation
87
169
  handle against its binding and invocation.
88
170
 
89
171
  `post` records a linked person's message. `input` without `principal` is a
90
172
  nonhuman event; `input` with a principal represents an unlinked person and requires
91
- an explicitly configured `anyone` audience. A shared place cannot target Home.
173
+ an explicitly configured `anyone` audience. `input`'s `actingAs` names the linked
174
+ person the agent's turn acts for; an input acting for nobody waits for the running
175
+ turn. `replyExpected: false` lets the agent stay silent when it has nothing to say.
176
+ An unlinked person resolves with the install's `linkUrl` and an unconnected place
177
+ with its `connectUrl` only when the installer provided those pages; otherwise the
178
+ channel explains linking in its own words. A shared place cannot target Home.
92
179
  `attach` records content without dispatching a turn. It supports recordings and
93
180
  other channel-produced attachments. Explicit `anyone`/`group` defaults let `places.resolve`
94
181
  create a Shared chat for a new anonymous call. Input idempotency keys are scoped to
@@ -103,12 +190,15 @@ Semantic events cover messages, tools, plans, decisions and turn completion, plu
103
190
  origin-bearing edits/removals/reactions. Completion events include the reply and
104
191
  are delivered at least once; channels persist provider reply IDs in `store` for
105
192
  deduplication. `replies: all` enables `message.posted` mirroring. Raw ACP updates
106
- belong to harnesses and the separately typed Final room surface.
193
+ belong to harnesses.
107
194
 
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.
195
+ `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. Speech providers and audio processing belong to application code, using its declared credentials and ordinary HTTP/socket requests.
110
196
 
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.
197
+ A channel declares the provider application it needs in `require.app`: an OAuth client and named secret slots (a signing secret, an app-level token). A channel app satisfies it, either the installer's own or one the channel's publisher attached to the publication; an install whose app cannot meet the declaration is refused. App credentials stay with the host in every execution mode. `credentials.client()` exposes only the public client ID; `verify({ secret })` checks a signed payload with a slot's key without returning it. `exchange()` returns an opaque, short-lived OAuth credential handle. Select that handle, a provider tenant's installed token (`{ kind: 'app', tenant }`) or a secret slot (`{ kind: 'secret', slot }`) 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. `secret(slot)` reads only slots the channel declares. Sockets accept bounded caller-owned headers for provider handshakes. 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.
198
+
199
+ A provider tenant (a workspace, a server) installs the app through the channel's own code. `tenants.installPath` names a GET route that receives a single-use `ticket`; it calls `credentials.redirect({ path, ticket })`, and the redirect route calls `credentials.exchange({ ..., store: { tenant } })`, which stores the token as that tenant's install. A tenant belongs to one install of an app at a time: a later install takes it over. Routes marked `shared: true` are also served at the app's shared ingress URL, one URL per app registered with the provider once. The publication the app routes its ingress through declares `ingress.tenantOf`, which verifies each request with app-only credentials and returns the tenant, a direct `respond` for app-level handshakes, or null to reject it; the host then runs the shared route of the binding that holds that tenant.
200
+
201
+ `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. A channel is published as one self-contained module; 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
202
 
113
203
  A host must fail ambiguous tenant selection rather than choosing an arbitrary
114
204
  credential. Tenant-wide `people.revoke` with reason `uninstalled` or
@@ -117,11 +207,7 @@ the tenant applies this lifecycle change to the binding's namespace. A socket ha
117
207
  cleanup grace after disconnect; every other operation is revoked immediately, and all
118
208
  capabilities end when the handler returns. Attachment authorization still applies.
119
209
 
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.
210
+ A channel's handlers always run on Final's serverless runtime.
125
211
 
126
212
  ## Durable processes
127
213
 
@@ -0,0 +1,4 @@
1
+ import type { JsonValue } from "./json.mjs";
2
+ export declare const canonicalJson: (value: JsonValue) => string;
3
+ export declare const contentHash: (value: JsonValue) => Promise<string>;
4
+ export declare const isContentHash: (text: string) => boolean;
@@ -0,0 +1,33 @@
1
+ const canonicalJson = (value) => {
2
+ if (value === null || typeof value === "boolean") return JSON.stringify(value);
3
+ if (typeof value === "number") {
4
+ if (!Number.isFinite(value)) throw new Error("canonical JSON has no non-finite numbers");
5
+ return JSON.stringify(value);
6
+ }
7
+ if (typeof value === "string") return JSON.stringify(value);
8
+ if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
9
+ const keys = Object.keys(value).sort();
10
+ const members = [];
11
+ for (const key of keys) {
12
+ const member = value[key];
13
+ if (member === void 0) continue;
14
+ members.push(`${JSON.stringify(key)}:${canonicalJson(member)}`);
15
+ }
16
+ return `{${members.join(",")}}`;
17
+ };
18
+ const HASH_PREFIX = "sha256:";
19
+ const hex = (bytes) => Array.from(new Uint8Array(bytes), (byte) => byte.toString(16).padStart(2, "0")).join("");
20
+ const contentHash = async (value) => {
21
+ const digest = await crypto.subtle.digest(
22
+ "SHA-256",
23
+ new TextEncoder().encode(canonicalJson(value))
24
+ );
25
+ return `${HASH_PREFIX}${hex(digest)}`;
26
+ };
27
+ const isContentHash = (text) => /^sha256:[0-9a-f]{64}$/.test(text);
28
+ export {
29
+ canonicalJson,
30
+ contentHash,
31
+ isContentHash
32
+ };
33
+ //# sourceMappingURL=canonical-json.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/canonical-json.ts"],
4
+ "sourcesContent": ["import type { JsonValue } from \"./json.mjs\";\n\n// RFC 8785-style canonical JSON: object keys sorted by UTF-16 code units, no\n// whitespace, numbers in their shortest round-trip form. Two documents with the\n// same data produce the same text, so the same hash.\nexport const canonicalJson = (value: JsonValue): string => {\n if (value === null || typeof value === 'boolean') return JSON.stringify(value);\n if (typeof value === 'number') {\n if (!Number.isFinite(value)) throw new Error('canonical JSON has no non-finite numbers');\n return JSON.stringify(value);\n }\n if (typeof value === 'string') return JSON.stringify(value);\n if (Array.isArray(value)) return `[${value.map(canonicalJson).join(',')}]`;\n const keys = Object.keys(value).sort();\n const members: string[] = [];\n for (const key of keys) {\n const member = value[key];\n if (member === undefined) continue;\n members.push(`${JSON.stringify(key)}:${canonicalJson(member)}`);\n }\n return `{${members.join(',')}}`;\n};\n\nconst HASH_PREFIX = 'sha256:';\n\nconst hex = (bytes: ArrayBuffer): string =>\n Array.from(new Uint8Array(bytes), (byte) => byte.toString(16).padStart(2, '0')).join('');\n\n// `sha256:<hex>` of the canonical text. Web Crypto, so it runs in Node,\n// browsers and Workers alike.\nexport const contentHash = async (value: JsonValue): Promise<string> => {\n const digest = await crypto.subtle.digest(\n 'SHA-256',\n new TextEncoder().encode(canonicalJson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
+ }
@@ -34,10 +34,10 @@ export type PersonResolution = {
34
34
  displayName: string;
35
35
  } | {
36
36
  kind: 'unlinked';
37
- linkUrl: string;
37
+ linkUrl?: string;
38
38
  } | {
39
39
  kind: 'blocked';
40
- reason: 'not-in-organization' | 'suspended';
40
+ reason: 'not-a-member' | 'suspended';
41
41
  };
42
42
  export declare enum ChannelReplies {
43
43
  Origin = "origin",
@@ -68,7 +68,7 @@ export type PlaceResolution = {
68
68
  policy: PlacePolicy;
69
69
  } | {
70
70
  kind: 'unconnected';
71
- connectUrl: string;
71
+ connectUrl?: string;
72
72
  defaults: PlaceDefaultsIface | null;
73
73
  };
74
74
  export interface Refusal {
@@ -108,6 +108,7 @@ export declare const channelReceiveResultSchema: z.ZodUnion<readonly [z.ZodObjec
108
108
  }, z.core.$strip>]>;
109
109
  export declare enum ChannelCredentialKind {
110
110
  App = "app",
111
+ Secret = "secret",
111
112
  OAuth = "oauth",
112
113
  None = "none"
113
114
  }
@@ -115,7 +116,11 @@ export declare const channelCredentialHandleSchema: z.core.$ZodBranded<z.ZodStri
115
116
  export type ChannelCredentialHandle = z.infer<typeof channelCredentialHandleSchema>;
116
117
  export type ChannelCredentialRef = {
117
118
  kind: ChannelCredentialKind.App;
118
- tenant?: string;
119
+ tenant: string;
120
+ } | {
121
+ kind: ChannelCredentialKind.Secret;
122
+ slot: string;
123
+ scheme?: string;
119
124
  } | {
120
125
  kind: ChannelCredentialKind.OAuth;
121
126
  handle: ChannelCredentialHandle;
@@ -140,6 +145,7 @@ export interface ChannelCredentialRequestInitIface extends RequestInit {
140
145
  credential?: ChannelCredentialRef;
141
146
  }
142
147
  export interface ChannelVerifyOptionsIface {
148
+ secret: string;
143
149
  algorithm: ChannelSigningAlgorithm;
144
150
  encoding: ChannelSignatureEncoding;
145
151
  data: string;
@@ -151,9 +157,13 @@ export interface ChannelOAuthExchangeOptionsIface {
151
157
  authentication: ChannelOAuthClientAuthentication;
152
158
  clientId?: string;
153
159
  signal?: AbortSignal;
160
+ store?: {
161
+ tenant: string;
162
+ };
154
163
  }
155
164
  export interface ChannelRedirectOptionsIface {
156
165
  path: string;
166
+ ticket?: string;
157
167
  }
158
168
  export interface ChannelRedirectIface {
159
169
  url: string;
@@ -184,7 +194,7 @@ export interface ChannelCredentialsIface {
184
194
  redirect(args: ChannelRedirectOptionsIface): Promise<ChannelRedirectIface>;
185
195
  fetch(input: RequestInfo | URL, init?: ChannelCredentialRequestInitIface): Promise<Response>;
186
196
  connect(args: ChannelCredentialConnectOptionsIface): Promise<ChannelCredentialSocketIface>;
187
- secret(name: string): Promise<string | null>;
197
+ secret(slot: string): Promise<string | null>;
188
198
  }
189
199
  export interface ChannelPostArgsIface {
190
200
  from: PersonHandle;
@@ -202,6 +212,8 @@ export interface ChannelConversationIface {
202
212
  input(args: {
203
213
  label: string;
204
214
  principal?: PrincipalRef;
215
+ actingAs?: PersonHandle;
216
+ replyExpected?: boolean;
205
217
  content: ContentBlock[];
206
218
  context?: string[];
207
219
  origin: OriginIface;
@@ -260,13 +272,7 @@ export interface ChannelReceiveContextIface<Config = JsonObject> {
260
272
  binding: {
261
273
  id: string;
262
274
  url: string;
263
- owner: {
264
- kind: 'agent';
265
- definitionId: string;
266
- } | {
267
- kind: 'install';
268
- installId: string;
269
- };
275
+ projectId: string;
270
276
  };
271
277
  config: Config;
272
278
  credentials: ChannelCredentialsIface;
@@ -367,6 +373,7 @@ export interface HttpChannelRouteDefinitionIface<Config = JsonObject> {
367
373
  method: 'GET' | 'POST' | 'PUT' | 'DELETE';
368
374
  path: string;
369
375
  redirect?: boolean;
376
+ shared?: boolean;
370
377
  handler(args: ChannelRouteContextIface<Config>): Promise<Response>;
371
378
  }
372
379
  export interface WebSocketChannelRouteDefinitionIface<Config = JsonObject> {
@@ -381,14 +388,43 @@ export type ChannelEventHandlersIface<Config, State> = {
381
388
  [Kind in keyof ChannelSemanticDataByKindIface]?: (data: ChannelSemanticDataByKindIface[Kind], ctx: ChannelEventContextIface<Config, State>) => Promise<void>;
382
389
  };
383
390
  export type ChannelEventKind = keyof ChannelSemanticDataByKindIface;
391
+ export interface ChannelAppRequirementIface {
392
+ description: string;
393
+ oauthClient?: {
394
+ description: string;
395
+ optional?: boolean;
396
+ };
397
+ secrets?: Record<string, {
398
+ description: string;
399
+ optional?: boolean;
400
+ }>;
401
+ }
402
+ export interface ChannelRequireIface {
403
+ app?: ChannelAppRequirementIface;
404
+ }
405
+ export interface ChannelIngressContextIface {
406
+ app: {
407
+ id: string;
408
+ };
409
+ credentials: Pick<ChannelCredentialsIface, 'verify' | 'secret' | 'client'>;
410
+ log(message: string, details?: JsonObject): void;
411
+ }
412
+ export interface ChannelIngressIface {
413
+ tenantOf(request: Request, ctx: ChannelIngressContextIface): Promise<{
414
+ tenant: string;
415
+ } | {
416
+ respond: Response;
417
+ } | null>;
418
+ }
384
419
  export interface ChannelDefinitionIface<Config = JsonObject, Inbound = JsonValue, State = JsonValue> {
385
420
  name: string;
386
421
  config?: Config;
387
422
  configure?(config: Config): ChannelDefinitionIface<Config, Inbound, State>;
388
- credentials: {
389
- app: string | null;
390
- secrets?: string[];
423
+ require?: ChannelRequireIface;
424
+ tenants?: {
425
+ installPath: string;
391
426
  };
427
+ ingress?: ChannelIngressIface;
392
428
  identity: {
393
429
  kind: 'redirect';
394
430
  start(args: {
@@ -54,6 +54,7 @@ const channelReceiveResultSchema = z.union([
54
54
  ]);
55
55
  var ChannelCredentialKind = /* @__PURE__ */ ((ChannelCredentialKind2) => {
56
56
  ChannelCredentialKind2["App"] = "app";
57
+ ChannelCredentialKind2["Secret"] = "secret";
57
58
  ChannelCredentialKind2["OAuth"] = "oauth";
58
59
  ChannelCredentialKind2["None"] = "none";
59
60
  return ChannelCredentialKind2;
@@ -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 { 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;AA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2';\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 // `linkUrl` is the installer's link page for this person, when the install has one; without\n // it, the channel tells the person how to link in its own words.\n | { kind: 'unlinked'; linkUrl?: string }\n | { kind: 'blocked'; reason: 'not-a-member' | '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 // `connectUrl` is the installer's connect page for this place, when the install has one.\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 // A provider tenant's token, stored when the tenant installed the channel's app.\n App = 'app',\n // A secret slot of the channel's app, injected without the channel reading it.\n Secret = 'secret',\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 // `scheme` is the Authorization scheme the secret is sent with (`Bearer` when omitted). Frame\n // injection writes the bare value.\n | { kind: ChannelCredentialKind.Secret; slot: string; scheme?: 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 // The app secret slot holding the signing secret or public key; its value is never read.\n secret: string;\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 // Stores the token as this provider tenant's install of the channel's app. Honoured only in a\n // redirect route whose state carries an unused tenant-install ticket for this binding.\n store?: { tenant: string };\n}\nexport interface ChannelRedirectOptionsIface {\n // A GET route of this channel declared with `redirect: true`.\n path: string;\n // A tenant-install ticket the install route received; it is bound into the signed state.\n ticket?: 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 // The channel app's 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 // The value of an app secret slot the channel declares in `require.app.secrets`; null for any\n // other slot.\n secret(slot: 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 // The linked person the agent's turn acts for; with nobody, the input waits for the\n // running turn.\n actingAs?: PersonHandle;\n // False when the agent should reply only if it has something to say. Default true.\n replyExpected?: boolean;\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 // The project the install belongs to.\n projectId: 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 // Also served at the app's shared ingress URL, for the binding `ingress.tenantOf` picks.\n shared?: 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;\n\n// Provider application credentials the channel needs, satisfied by a channel app: the install's\n// own, or the one the channel's publisher attached.\nexport interface ChannelAppRequirementIface {\n description: string;\n oauthClient?: { description: string; optional?: boolean };\n // Secret slots, by name (a signing secret, an app-level token).\n secrets?: Record<string, { description: string; optional?: boolean }>;\n}\nexport interface ChannelRequireIface {\n app?: ChannelAppRequirementIface;\n}\nexport interface ChannelIngressContextIface {\n app: { id: string };\n credentials: Pick<ChannelCredentialsIface, 'verify' | 'secret' | 'client'>;\n log(message: string, details?: JsonObject): void;\n}\nexport interface ChannelIngressIface {\n // Reads which provider tenant a request to the app's shared ingress URL is for, after verifying\n // it. `respond` answers an app-level request (a URL handshake) with no binding; null rejects it.\n tenantOf(\n request: Request,\n ctx: ChannelIngressContextIface,\n ): Promise<{ tenant: string } | { respond: Response } | null>;\n}\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 require?: ChannelRequireIface;\n // A GET route that starts the provider's app install for a tenant; it receives `ticket`.\n tenants?: { installPath: string };\n // Present on the publication an app routes its shared ingress through.\n ingress?: ChannelIngressIface;\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,wBAA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ChannelAudience", "ChannelCreate", "ChannelCredentialKind", "ChannelSigningAlgorithm", "ChannelSignatureEncoding", "ChannelOAuthClientAuthentication"]
7
7
  }
@@ -0,0 +1,10 @@
1
+ import { type AgentDocumentIface } from "../document.mjs";
2
+ import type { ServerlessRuntimeIface } from "./serverless.mjs";
3
+ import { type CodeHostIface, type CodeRunIface } from "./types.mjs";
4
+ export interface CreateCodeHostArgsIface {
5
+ document: AgentDocumentIface;
6
+ agent: string;
7
+ serverless: ServerlessRuntimeIface;
8
+ inProcess: () => CodeRunIface | null;
9
+ }
10
+ export declare const createCodeHost: (args: CreateCodeHostArgsIface) => CodeHostIface;
@@ -0,0 +1,88 @@
1
+ import {
2
+ CodePlacement,
3
+ ToolApprovalMode
4
+ } from "../document.mjs";
5
+ import {
6
+ CodeErrorCode,
7
+ CodeKind,
8
+ CodeLineType
9
+ } from "./types.mjs";
10
+ const failure = (code, message) => ({ ok: false, code, message });
11
+ const createCodeHost = (args) => {
12
+ const runner = (code) => {
13
+ if (code.placement === CodePlacement.InProcess) return args.inProcess();
14
+ return (invocation, options) => args.serverless.run(
15
+ { agent: args.agent, source: code.source, export: code.export, invocation },
16
+ options
17
+ );
18
+ };
19
+ const run = async (code, invocation, call) => {
20
+ const execute = runner(code);
21
+ if (execute == null)
22
+ return failure(
23
+ CodeErrorCode.Unavailable,
24
+ `${invocation.name} runs in the process that created the session, which is not connected`
25
+ );
26
+ try {
27
+ for await (const line of execute(invocation, { signal: call.signal })) {
28
+ if (line.type === CodeLineType.Progress) {
29
+ call.onProgress?.(line.label == null ? { data: line.data } : line);
30
+ continue;
31
+ }
32
+ if (line.type === CodeLineType.Error) return failure(CodeErrorCode.Failed, line.message);
33
+ return line.modelOutput === void 0 ? { ok: true, output: line.output } : { ok: true, output: line.output, modelOutput: line.modelOutput };
34
+ }
35
+ return failure(CodeErrorCode.Failed, `${invocation.name} ended without a result`);
36
+ } catch (cause) {
37
+ return failure(CodeErrorCode.Failed, cause instanceof Error ? cause.message : String(cause));
38
+ }
39
+ };
40
+ return {
41
+ invokeTool: async (call) => {
42
+ const tool = args.document.tools[call.name];
43
+ if (tool == null) return failure(CodeErrorCode.NotFound, `no tool ${call.name}`);
44
+ return run(
45
+ tool.code,
46
+ { kind: CodeKind.Tool, name: call.name, input: call.input, context: call.context },
47
+ call
48
+ );
49
+ },
50
+ dispatchHook: async (call) => {
51
+ const hook = args.document.hooks.find((candidate) => candidate.name === call.name);
52
+ if (hook == null) return failure(CodeErrorCode.NotFound, `no hook ${call.name}`);
53
+ return run(
54
+ hook.code,
55
+ {
56
+ kind: CodeKind.Hook,
57
+ name: call.name,
58
+ event: call.event,
59
+ payload: call.payload,
60
+ context: call.context
61
+ },
62
+ call
63
+ );
64
+ },
65
+ evaluateApproval: async (call) => {
66
+ const tool = args.document.tools[call.name];
67
+ if (tool == null) return failure(CodeErrorCode.NotFound, `no tool ${call.name}`);
68
+ const approval = tool.approval ?? ToolApprovalMode.Allow;
69
+ if (typeof approval === "string") return { ok: true, ask: approval === ToolApprovalMode.Ask };
70
+ const result = await run(
71
+ approval.whenInput,
72
+ { kind: CodeKind.Approval, name: call.name, input: call.input, context: call.context },
73
+ call
74
+ );
75
+ if (!result.ok) return result;
76
+ if (typeof result.output !== "boolean")
77
+ return failure(
78
+ CodeErrorCode.Invalid,
79
+ `the approval of ${call.name} must answer true (ask) or false (allow)`
80
+ );
81
+ return { ok: true, ask: result.output };
82
+ }
83
+ };
84
+ };
85
+ export {
86
+ createCodeHost
87
+ };
88
+ //# sourceMappingURL=host.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../../src/code-host/host.ts"],
4
+ "sourcesContent": ["import {\n CodePlacement,\n ToolApprovalMode,\n type AgentDocumentIface,\n type CodeIface,\n} from \"../document.mjs\";\nimport type { ServerlessRuntimeIface } from \"./serverless.mjs\";\nimport {\n CodeErrorCode,\n CodeKind,\n CodeLineType,\n type ApprovalResultIface,\n type CodeCallIface,\n type CodeHostIface,\n type CodeInvocationIface,\n type CodeResultIface,\n type CodeRunIface,\n} from \"./types.mjs\";\n\nexport interface CreateCodeHostArgsIface {\n document: AgentDocumentIface;\n // The document's content hash.\n agent: string;\n // Final's serverless runtime.\n serverless: ServerlessRuntimeIface;\n // The creating client's connection, when one that holds the code is\n // connected; read on every call, since it comes and goes.\n inProcess: () => CodeRunIface | null;\n}\n\nconst failure = (code: CodeErrorCode, message: string) => ({ ok: false as const, code, message });\n\n// Routes each call by the placement its document gives it: serverless code to\n// the runtime with its source, in-process code to the creating client.\nexport const createCodeHost = (args: CreateCodeHostArgsIface): CodeHostIface => {\n const runner = (code: CodeIface): CodeRunIface | null => {\n if (code.placement === CodePlacement.InProcess) return args.inProcess();\n return (invocation, options) =>\n args.serverless.run(\n { agent: args.agent, source: code.source, export: code.export, invocation },\n options,\n );\n };\n\n const run = async (\n code: CodeIface,\n invocation: CodeInvocationIface,\n call: Pick<CodeCallIface, 'signal' | 'onProgress'>,\n ): Promise<CodeResultIface> => {\n const execute = runner(code);\n if (execute == null)\n return failure(\n CodeErrorCode.Unavailable,\n `${invocation.name} runs in the process that created the session, which is not connected`,\n );\n try {\n for await (const line of execute(invocation, { signal: call.signal })) {\n if (line.type === CodeLineType.Progress) {\n call.onProgress?.(line.label == null ? { data: line.data } : line);\n continue;\n }\n if (line.type === CodeLineType.Error) return failure(CodeErrorCode.Failed, line.message);\n return line.modelOutput === undefined\n ? { ok: true, output: line.output }\n : { ok: true, output: line.output, modelOutput: line.modelOutput };\n }\n return failure(CodeErrorCode.Failed, `${invocation.name} ended without a result`);\n } catch (cause) {\n return failure(CodeErrorCode.Failed, cause instanceof Error ? cause.message : String(cause));\n }\n };\n\n return {\n invokeTool: async (call) => {\n const tool = args.document.tools[call.name];\n if (tool == null) return failure(CodeErrorCode.NotFound, `no tool ${call.name}`);\n return run(\n tool.code,\n { kind: CodeKind.Tool, name: call.name, input: call.input, context: call.context },\n call,\n );\n },\n dispatchHook: async (call) => {\n const hook = args.document.hooks.find((candidate) => candidate.name === call.name);\n if (hook == null) return failure(CodeErrorCode.NotFound, `no hook ${call.name}`);\n return run(\n hook.code,\n {\n kind: CodeKind.Hook,\n name: call.name,\n event: call.event,\n payload: call.payload,\n context: call.context,\n },\n call,\n );\n },\n evaluateApproval: async (call): Promise<ApprovalResultIface> => {\n const tool = args.document.tools[call.name];\n if (tool == null) return failure(CodeErrorCode.NotFound, `no tool ${call.name}`);\n const approval = tool.approval ?? ToolApprovalMode.Allow;\n if (typeof approval === 'string') return { ok: true, ask: approval === ToolApprovalMode.Ask };\n const result = await run(\n approval.whenInput,\n { kind: CodeKind.Approval, name: call.name, input: call.input, context: call.context },\n call,\n );\n if (!result.ok) return result;\n if (typeof result.output !== 'boolean')\n return failure(\n CodeErrorCode.Invalid,\n `the approval of ${call.name} must answer true (ask) or false (allow)`,\n );\n return { ok: true, ask: result.output };\n },\n };\n};\n"],
5
+ "mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAEP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAOK;AAaP,MAAM,UAAU,CAAC,MAAqB,aAAqB,EAAE,IAAI,OAAgB,MAAM,QAAQ;AAIxF,MAAM,iBAAiB,CAAC,SAAiD;AAC9E,QAAM,SAAS,CAAC,SAAyC;AACvD,QAAI,KAAK,cAAc,cAAc,UAAW,QAAO,KAAK,UAAU;AACtE,WAAO,CAAC,YAAY,YAClB,KAAK,WAAW;AAAA,MACd,EAAE,OAAO,KAAK,OAAO,QAAQ,KAAK,QAAQ,QAAQ,KAAK,QAAQ,WAAW;AAAA,MAC1E;AAAA,IACF;AAAA,EACJ;AAEA,QAAM,MAAM,OACV,MACA,YACA,SAC6B;AAC7B,UAAM,UAAU,OAAO,IAAI;AAC3B,QAAI,WAAW;AACb,aAAO;AAAA,QACL,cAAc;AAAA,QACd,GAAG,WAAW,IAAI;AAAA,MACpB;AACF,QAAI;AACF,uBAAiB,QAAQ,QAAQ,YAAY,EAAE,QAA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