@finalai/agent-provider 0.1.2 → 0.1.4
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 +234 -0
- package/dist/modules/channel.d.mts +4 -0
- package/dist/modules/channel.mjs.map +2 -2
- package/dist/modules/dynamic.d.mts +8 -0
- package/dist/modules/dynamic.mjs +3 -1
- package/dist/modules/dynamic.mjs.map +2 -2
- package/dist/modules/harness.d.mts +3 -0
- package/dist/modules/harness.mjs +5 -1
- package/dist/modules/harness.mjs.map +2 -2
- package/dist/modules/hosted-bindings.d.mts +15 -0
- package/dist/modules/hosted-bindings.mjs +21 -0
- package/dist/modules/hosted-bindings.mjs.map +7 -0
- package/dist/modules/index.d.mts +3 -0
- package/dist/modules/index.mjs +3 -0
- package/dist/modules/index.mjs.map +2 -2
- package/dist/modules/manifest.d.mts +143 -6
- package/dist/modules/manifest.mjs +33 -5
- package/dist/modules/manifest.mjs.map +3 -3
- package/dist/modules/sandbox/types.d.mts +5 -0
- package/dist/modules/sandbox/types.mjs.map +2 -2
- package/dist/modules/tool-annotations.d.mts +7 -0
- package/dist/modules/tool-annotations.mjs +10 -0
- package/dist/modules/tool-annotations.mjs.map +7 -0
- package/dist/modules/tool-patterns.d.mts +11 -0
- package/dist/modules/tool-patterns.mjs +65 -0
- package/dist/modules/tool-patterns.mjs.map +7 -0
- package/package.json +4 -3
package/HOSTING.md
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
# Portable agent definitions and hosted bindings
|
|
2
|
+
|
|
3
|
+
An agent declares behavior and logical resources. Hosting supplies endpoints,
|
|
4
|
+
resource identifiers, and credential references. The same compiled source can
|
|
5
|
+
resolve against dev and production configuration without source edits.
|
|
6
|
+
|
|
7
|
+
## Selecting a deployment
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
export FINAL_API_HOST=https://agent-session.primary-dev.final.ai/api
|
|
11
|
+
export FINAL_API_KEY=<dev-organization-key>
|
|
12
|
+
pnpm exec final-agents build ./agent
|
|
13
|
+
pnpm exec final-agents publish ./agent --agent my-agent
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Choose production by changing the host and organization key. `--host` overrides
|
|
17
|
+
`FINAL_API_HOST`; without either, the existing production default remains. Build
|
|
18
|
+
compiles locally and optionally checks installed-harness compatibility. Publish
|
|
19
|
+
compiles again and sends source/release requests to the selected deployment.
|
|
20
|
+
Neither rewrites authored URLs. A GitHub-backed definition uses remote source;
|
|
21
|
+
push edits before explicitly publishing a ref. Caller API keys never become agent
|
|
22
|
+
credentials merely because they were used to publish.
|
|
23
|
+
|
|
24
|
+
## Hosted connections
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { defineHostedConnection } from '@finalai/agents';
|
|
28
|
+
|
|
29
|
+
export default defineHostedConnection({
|
|
30
|
+
binding: 'issue-tracker',
|
|
31
|
+
tools: { allow: ['read_issue'], deny: ['delete_issue'] },
|
|
32
|
+
});
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
`issue-tracker` is an example configuration name, not a built-in service.
|
|
36
|
+
Hosting configures it with non-secret JSON:
|
|
37
|
+
|
|
38
|
+
```json
|
|
39
|
+
{
|
|
40
|
+
"url": "https://issues.dev.example/mcp",
|
|
41
|
+
"auth": { "secretKey": "ISSUE_TRACKER_TOKEN", "headerName": null },
|
|
42
|
+
"headers": { "X-Workspace": "development" }
|
|
43
|
+
}
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Production supplies another value under the same name. The helper uses an ordinary
|
|
47
|
+
`defineDynamic` connection at `session.started`, then the usual HTTP MCP lowering,
|
|
48
|
+
validation, permissions, and credential broker. Hosting supplies transport settings,
|
|
49
|
+
not tool policies. URL, authentication references, transport headers belong to hosting; the hosted helper does
|
|
50
|
+
not accept authored overrides for these fields. Referenced secrets still need the agent's secret allowlist and normal
|
|
51
|
+
authorization. Actual tokens must not be returned in configuration headers.
|
|
52
|
+
|
|
53
|
+
Final uses the same generic helper:
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { defineFinalConnection } from '@finalai/agents';
|
|
57
|
+
|
|
58
|
+
export default defineFinalConnection({
|
|
59
|
+
tools: { deny: ['create_agent_session'] },
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This resolves the `final` binding. Hosting supplies its URL and
|
|
64
|
+
`auth: { kind: 'final-session' }`, just as it supplies authentication for any
|
|
65
|
+
other hosted connection. `binding`
|
|
66
|
+
selects another name. Existing explicit `url` calls remain static and compatible;
|
|
67
|
+
they always point at that URL. There is no Final-specific compiler rewrite.
|
|
68
|
+
|
|
69
|
+
## Connection tool policy
|
|
70
|
+
|
|
71
|
+
`tools.allow`, `tools.deny` and `tools.approval` keys are tool names or `*`
|
|
72
|
+
patterns, so a definition can scope a connection whose tool list it does not know:
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
export default defineFinalConnection({
|
|
76
|
+
tools: {
|
|
77
|
+
allow: ['github.*', 'list_goals'],
|
|
78
|
+
deny: ['github.delete_repo'],
|
|
79
|
+
approval: { 'github.delete_*': always() },
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`*` matches any run of characters; everything else matches literally. `deny` wins
|
|
85
|
+
over `allow`. The most specific key governs a tool: an exact name, else the matching
|
|
86
|
+
pattern with the most literal characters, with ties resolved toward `ask`. Hosts
|
|
87
|
+
enforce this through `isToolExposed` and `toolApprovalOf` from
|
|
88
|
+
`@finalai/agent-provider`, and look up a tool's input-approval predicate under the
|
|
89
|
+
key `resolveToolApprovalKey` returns.
|
|
90
|
+
|
|
91
|
+
## Loaded and searchable tools
|
|
92
|
+
|
|
93
|
+
A connection that can expose many tools, such as Final's with every service the
|
|
94
|
+
person has connected, can name the ones the harness should list up front:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
export default defineFinalConnection({
|
|
98
|
+
tools: { load: ['list_goals', 'get_goal', 'draft_goal', 'notify_user'] },
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Without `load`, the harness lists every exposed tool, as before. With it, the host
|
|
103
|
+
lists only the loaded tools and must keep every other exposed tool reachable: it
|
|
104
|
+
serves a search over the connection's remaining exposed tools (name, description,
|
|
105
|
+
input schema) and a call that runs a found tool by its real name, with the same
|
|
106
|
+
exposure and approval checks as a direct call. A host may instead add a found tool
|
|
107
|
+
to the list and send `notifications/tools/list_changed`; harnesses that ignore that
|
|
108
|
+
notification still need the call path. `load: []` leaves every tool to search.
|
|
109
|
+
Entries are tool names or `*` patterns. `isToolLoaded` from `@finalai/agent-provider`
|
|
110
|
+
applies the rule after exposure.
|
|
111
|
+
|
|
112
|
+
## Selecting tools by annotation
|
|
113
|
+
|
|
114
|
+
`tools.allow` and `tools.deny` entries can be MCP annotation selectors as well as
|
|
115
|
+
tool names, so a definition can scope tools it cannot name in advance:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
export default defineFinalConnection({
|
|
119
|
+
tools: {
|
|
120
|
+
allow: ['list_goals', 'draft_goal', { readOnlyHint: true }],
|
|
121
|
+
deny: [{ destructiveHint: true, readOnlyHint: false }],
|
|
122
|
+
},
|
|
123
|
+
});
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
A selector matches when every hint it sets equals the tool's hint, reading hints the
|
|
127
|
+
tool omits as the MCP spec's defaults (not read-only, destructive, not idempotent,
|
|
128
|
+
open world). The annotations come from the connection's server, so select on them
|
|
129
|
+
only for servers trusted to classify their own tools.
|
|
130
|
+
|
|
131
|
+
Selectors lower to `allowAnnotations` (each with the connection default approval and
|
|
132
|
+
input predicate) and `denyAnnotations`. A host exposes a tool when nothing in `deny`
|
|
133
|
+
or `denyAnnotations` matches it and either an `approvals` key (name or pattern)
|
|
134
|
+
governs it, `approvals` is null, or `toolAnnotationRuleFor` finds a rule; a tool an
|
|
135
|
+
`approvals` key governs keeps that approval, otherwise it runs under the rule's. `tools.approval` overrides apply only to
|
|
136
|
+
named tools.
|
|
137
|
+
|
|
138
|
+
## Resources and provider packages
|
|
139
|
+
|
|
140
|
+
`HostedBindingsIface` is the shared `@finalai/agent-provider` contract. Hosting
|
|
141
|
+
implements `get(name)` to return scoped JSON or null. `requireHostedBinding` rejects
|
|
142
|
+
missing hosting, absent names, and invalid JSON without an environment fallback.
|
|
143
|
+
Names are configuration keys, not global permissions or inferred URLs.
|
|
144
|
+
|
|
145
|
+
Tools, hooks, dynamic resolvers, sandbox selectors, and harness/sandbox/channel
|
|
146
|
+
provider contexts expose an optional `bindings` reader. A third-party resolver can
|
|
147
|
+
use the same reader for model or resource configuration:
|
|
148
|
+
|
|
149
|
+
```ts
|
|
150
|
+
import { defineDynamic, requireHostedBinding } from '@finalai/agents';
|
|
151
|
+
|
|
152
|
+
export const model = defineDynamic({
|
|
153
|
+
requiredBindings: [{ name: 'primary-model', schema: { type: 'string', minLength: 1 } }],
|
|
154
|
+
description: 'The deployment model',
|
|
155
|
+
preview: 'Resolved from primary-model',
|
|
156
|
+
events: {
|
|
157
|
+
'session.started': async (_event, ctx) =>
|
|
158
|
+
requireHostedBinding({ bindings: ctx.bindings, name: 'primary-model' }),
|
|
159
|
+
},
|
|
160
|
+
});
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Use that value in a harness configuration supporting dynamic models. A resource
|
|
164
|
+
binding can similarly contain a repository, guide slug, device ID, or non-secret
|
|
165
|
+
SDK base URL; the consumer validates the resource-specific schema. Literal IDs,
|
|
166
|
+
custom URLs, and external credential choices are never silently rewritten.
|
|
167
|
+
|
|
168
|
+
Installed providers already accept factory configuration injected by hosting.
|
|
169
|
+
Keep supplying deployment service URLs there. Computer/WebSocket clients retain
|
|
170
|
+
explicit configuration; a hosted provider can obtain it through this shared reader.
|
|
171
|
+
Package versions stay pinned. Packages do not read a global DEV/PROD flag.
|
|
172
|
+
|
|
173
|
+
## Declared requirements and user experience
|
|
174
|
+
|
|
175
|
+
`defineHostedConnection` declares its binding name and JSON configuration schema
|
|
176
|
+
in the compiled dynamic slot automatically. Other dynamic consumers declare
|
|
177
|
+
`requiredBindings` as in the model example. Hosts can inspect these requirements
|
|
178
|
+
without running authored resolvers. Repeated names must satisfy every declared
|
|
179
|
+
schema; names are looked up once per preflight.
|
|
180
|
+
|
|
181
|
+
Before accepting a release, hosting calls
|
|
182
|
+
`validateHostedBindings({ manifest, bindings })` with a reader scoped to the
|
|
183
|
+
selected deployment, organization, and agent. Hosts compiling source can instead
|
|
184
|
+
pass `hostedBindings` to `compile`; failed preflight returns error diagnostics and
|
|
185
|
+
no manifest or bundle. An offline build can still compile and expose requirements
|
|
186
|
+
without accessing deployment configuration. The CLI does not yet fetch binding
|
|
187
|
+
configuration itself: server-side publication must enable this preflight.
|
|
188
|
+
|
|
189
|
+
When dev is selected, lookups use only dev configuration. A missing dev binding
|
|
190
|
+
fails even if production has the same name; never retry against production or
|
|
191
|
+
substitute a production default. Changing the CLI host selects where to publish;
|
|
192
|
+
the runtime reader comes from that deployment, not from the author's environment.
|
|
193
|
+
Explicit authored URLs retain their literal destination.
|
|
194
|
+
|
|
195
|
+
Authors keep one source definition. Operators configure its named connections
|
|
196
|
+
and resources once in each deployment. End users start the agent as usual; an
|
|
197
|
+
unconfigured required resource produces a configuration failure instead of a
|
|
198
|
+
session silently missing tools. Dynamic handlers validate declared requirements
|
|
199
|
+
before running. Shared manifest resolution rejects null results for required slots,
|
|
200
|
+
even if a host catches a resolver exception and returns null. Hosts must propagate
|
|
201
|
+
that failure to startup. Session-started values stay pinned across turns and resume.
|
|
202
|
+
|
|
203
|
+
This PR adds no configuration UI. A host can use the compiled requirements to show
|
|
204
|
+
which names need configuration and return an actionable deployment-specific error.
|
|
205
|
+
|
|
206
|
+
## Host integration
|
|
207
|
+
|
|
208
|
+
These packages implement contracts and authored runtime behavior, not a deployment
|
|
209
|
+
configuration store or RPC service. Existing hosting needs to:
|
|
210
|
+
|
|
211
|
+
1. Resolve names within the authorized deployment, organization, and agent; never
|
|
212
|
+
expose the process environment or an unrestricted cross-tenant registry.
|
|
213
|
+
2. Inject `bindings` into lifecycle resolution and the tool/hook/selector/provider
|
|
214
|
+
contexts using it. Dynamic approval evaluation and tool reconstruction after
|
|
215
|
+
isolate eviction need the same reader. Readers and tokens are not persisted in
|
|
216
|
+
boundary snapshots.
|
|
217
|
+
3. Configure `final` with that deployment's approved MCP endpoint. The ordinary
|
|
218
|
+
broker continues restricting `final-session` grants to that endpoint.
|
|
219
|
+
4. Return non-secret configuration and credential references, with normal provider,
|
|
220
|
+
secret, resource, and organization authorization.
|
|
221
|
+
5. Run the release preflight above and validate again before starting a new
|
|
222
|
+
session. Treat failed required-binding resolution as a startup/configuration error, not
|
|
223
|
+
an omitted connection or a fallback to production. Preserve existing runtime
|
|
224
|
+
revisions when publication fails.
|
|
225
|
+
6. Retain session-started resolved values across turns/resume; resolve new sessions
|
|
226
|
+
against their own deployment.
|
|
227
|
+
|
|
228
|
+
Optional readers preserve source compatibility with existing hosts. Definitions
|
|
229
|
+
requesting bindings fail clearly if hosting does not provide them. Installing these
|
|
230
|
+
packages alone does not change Final's deployed service wiring or provision secrets.
|
|
231
|
+
|
|
232
|
+
New compiles emit manifest version 3, so older hosts reject them rather than
|
|
233
|
+
stripping required-binding metadata. Updated readers still accept persisted
|
|
234
|
+
version 2 revisions. Upgrade hosting before publishing newly compiled agents.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { HostedBindingsIface } from "./hosted-bindings.mjs";
|
|
1
2
|
import type { ContentBlock, SessionUpdate } from '@agentclientprotocol/sdk/experimental/v2';
|
|
2
3
|
import * as z from 'zod';
|
|
3
4
|
import type { ChannelSessionOperationsIface } from "./channel-context.mjs";
|
|
@@ -265,6 +266,7 @@ export interface ChannelInputResponseIface {
|
|
|
265
266
|
apiKeyId: string | null;
|
|
266
267
|
}
|
|
267
268
|
export interface ChannelReceiveContextIface {
|
|
269
|
+
bindings?: HostedBindingsIface;
|
|
268
270
|
platform: ChannelPlatformIface;
|
|
269
271
|
organizationId: string;
|
|
270
272
|
definitionId: string | null;
|
|
@@ -284,6 +286,7 @@ export interface ChannelReceiveContextIface {
|
|
|
284
286
|
requestedDelivery?: Delivery;
|
|
285
287
|
}
|
|
286
288
|
export interface ChannelRouteContextIface {
|
|
289
|
+
bindings?: HostedBindingsIface;
|
|
287
290
|
request: Request;
|
|
288
291
|
secrets: {
|
|
289
292
|
get(name: string): Promise<string | null>;
|
|
@@ -317,6 +320,7 @@ export interface ChannelTurnStateIface<State> {
|
|
|
317
320
|
set(state: State | null): void;
|
|
318
321
|
}
|
|
319
322
|
export interface ProjectionContextIface<State = JsonValue> {
|
|
323
|
+
bindings?: HostedBindingsIface;
|
|
320
324
|
sessionId?: string;
|
|
321
325
|
platform: ChannelPlatformIface;
|
|
322
326
|
conversation: ConversationIface | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/channel.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ContentBlock, SessionUpdate } from '@agentclientprotocol/sdk/experimental/v2';\nimport * as z from 'zod';\nimport type { ChannelSessionOperationsIface } from \"./channel-context.mjs\";\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// Channels. Messaging has no orchestrator: a channel\n// receives input, inserts it into the conversation, routes it to agent\n// participants as ACP prompt or observe, and projects ACP updates back into\n// visible messages and cards. The built-in messaging channels implement this\n// contract with no private hooks into the session service; the session\n// service hands every channel the same ChannelPlatformIface.\n\nexport enum ConversationKind {\n Direct = 'direct',\n Group = 'group',\n}\n\nexport enum ParticipantKind {\n User = 'user',\n Agent = 'agent',\n System = 'system',\n}\n\nexport enum SystemParticipantKind {\n Schedule = 'schedule',\n Webhook = 'webhook',\n Goal = 'goal',\n Tool = 'tool',\n ApiKey = 'api-key',\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 System = 'system',\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 servicePrincipalId?: string | null;\n definitionId: string | null;\n systemKind: SystemParticipantKind | 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 channelReceiveResultSchema = z.union([\n z.object({ conversationId: z.string().min(1) }),\n z.object({ sessionId: z.string().min(1) }),\n z.null(),\n]);\nexport type ChannelReceiveResult = z.infer<typeof channelReceiveResultSchema>;\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 pendingRequestId: 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?: JsonObject | 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 pending-request 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// What the session service lets a channel do. Implemented once, handed to\n// built-in and custom channels alike.\nexport interface ChannelPlatformIface {\n channelSessions?: ChannelSessionOperationsIface;\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 findOrCreateDirect(args: {\n organizationId: string;\n userId: string;\n definitionId: string;\n }): Promise<ConversationIface>;\n // The conversation a channel binding is attached to.\n boundTo(bindingId: string): Promise<ConversationIface | null>;\n participants(conversationId: string): Promise<ParticipantIface[]>;\n systemParticipant(args: {\n conversationId: string;\n systemKind: SystemParticipantKind;\n displayName: string;\n sourceRef: string;\n }): 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?: JsonObject | null;\n participantId: string;\n pendingId: string;\n outcome: JsonValue;\n actorParticipantId: string;\n userId: string | null;\n apiKeyId: string | null;\n}\n\nexport interface ChannelReceiveContextIface {\n platform: ChannelPlatformIface;\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\n// An HTTP route a channel serves (webhooks), mounted by the front door at\n// /api/events/webhooks/:bindingId<path> and the per-agent aliases.\nexport interface ChannelRouteContextIface {\n request: Request;\n secrets: { get(name: string): Promise<string | null> };\n receive: (input: JsonValue) => Promise<ChannelReceiveResult>;\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\nexport interface HttpChannelRouteDefinitionIface {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE';\n path: string;\n handler: (args: ChannelRouteContextIface) => Promise<Response>;\n}\n\nexport interface WebSocketChannelRouteDefinitionIface {\n method: 'WS';\n path: string;\n // Returning an HTTP response before accept rejects the handshake. The handler lives until close.\n handler: (\n args: ChannelRouteContextIface & { socket: ChannelSocketIface },\n ) => Promise<Response | void>;\n}\n\nexport type RouteDefinitionIface =\n | HttpChannelRouteDefinitionIface\n | WebSocketChannelRouteDefinitionIface;\n\n// The per-turn value a channel keeps between its project and event calls of\n// one turn (the definition's `State`). The platform holds it, so a channel\n// running in a Worker isolate keeps nothing in memory; it starts null each turn\n// and is discarded when the turn's projection finishes.\nexport interface ChannelTurnStateIface<State> {\n get(): State | null;\n set(state: State | null): void;\n}\n\nexport interface ProjectionContextIface<State = JsonValue> {\n sessionId?: string;\n platform: ChannelPlatformIface;\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 PendingEventKind {\n Created = 'pending.created',\n Resolved = 'pending.resolved',\n}\n\nexport type AcpUpdateKind = SessionUpdate['sessionUpdate'];\n\nexport type ChannelEventKind =\n | AcpUpdateKind\n | `${PendingEventKind}`\n | `${SemanticChannelEventKind}`;\n\nexport interface ChannelEventIface {\n type: string;\n data: JsonValue;\n seq: number;\n}\n\nexport type ChannelEventHandler<State = JsonValue> = (\n event: ChannelEventIface,\n ctx: ProjectionContextIface<State>,\n) => Promise<void>;\n\nexport enum PendingKind {\n Permission = 'permission',\n Elicitation = 'elicitation',\n}\n\n// `data` of a pending.created event: an ACP session/request_permission or\n// elicitation/create request awaiting its audience.\nexport const pendingCreatedDataSchema = z.object({\n pendingRequestId: z.string().min(1),\n kind: z.nativeEnum(PendingKind),\n audienceParticipantIds: z.array(z.string()),\n request: jsonValueSchema,\n});\n\nexport type PendingCreatedDataIface = z.infer<typeof pendingCreatedDataSchema>;\n\n// `data` of a pending.resolved event: the answer (or cancellation) as recorded.\nexport const pendingResolvedDataSchema = z.object({\n pendingRequestId: z.string().min(1),\n outcome: jsonValueSchema,\n});\n\nexport type PendingResolvedDataIface = z.infer<typeof pendingResolvedDataSchema>;\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// Built-in and custom (bundle) channels implement exactly this; the\n// session service calls nothing else on a channel.\nexport interface ChannelDefinitionIface<Inbound, State = undefined> {\n config?: JsonObject;\n // Installed execution is an optimization for an uncustomized definition.\n installed?: ProviderRef;\n configure?: (config: JsonObject) => ChannelDefinitionIface<Inbound, State>;\n routes?: RouteDefinitionIface[];\n respond?(\n input: ChannelInputResponseIface,\n ctx: ChannelReceiveContextIface,\n ): Promise<{ resolved: boolean }>;\n cancel?(ctx: ChannelReceiveContextIface): Promise<{ accepted: boolean }>;\n // Inserts the input into its conversation and routes it. Returns where it went.\n receive(input: Inbound, ctx: ChannelReceiveContextIface): Promise<ChannelReceiveResult>;\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<ChannelEventKind, ChannelEventHandler<State>>>;\n}\n\nexport const defineChannel = <Inbound, State = undefined>(\n definition: ChannelDefinitionIface<Inbound, State>,\n): ChannelDefinitionIface<Inbound, State> => definition;\n"],
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { HostedBindingsIface } from \"./hosted-bindings.mjs\";\nimport type { ContentBlock, SessionUpdate } from '@agentclientprotocol/sdk/experimental/v2';\nimport * as z from 'zod';\nimport type { ChannelSessionOperationsIface } from \"./channel-context.mjs\";\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// Channels. Messaging has no orchestrator: a channel\n// receives input, inserts it into the conversation, routes it to agent\n// participants as ACP prompt or observe, and projects ACP updates back into\n// visible messages and cards. The built-in messaging channels implement this\n// contract with no private hooks into the session service; the session\n// service hands every channel the same ChannelPlatformIface.\n\nexport enum ConversationKind {\n Direct = 'direct',\n Group = 'group',\n}\n\nexport enum ParticipantKind {\n User = 'user',\n Agent = 'agent',\n System = 'system',\n}\n\nexport enum SystemParticipantKind {\n Schedule = 'schedule',\n Webhook = 'webhook',\n Goal = 'goal',\n Tool = 'tool',\n ApiKey = 'api-key',\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 System = 'system',\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 servicePrincipalId?: string | null;\n definitionId: string | null;\n systemKind: SystemParticipantKind | 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 channelReceiveResultSchema = z.union([\n z.object({ conversationId: z.string().min(1) }),\n z.object({ sessionId: z.string().min(1) }),\n z.null(),\n]);\nexport type ChannelReceiveResult = z.infer<typeof channelReceiveResultSchema>;\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 pendingRequestId: 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?: JsonObject | 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 pending-request 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// What the session service lets a channel do. Implemented once, handed to\n// built-in and custom channels alike.\nexport interface ChannelPlatformIface {\n channelSessions?: ChannelSessionOperationsIface;\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 findOrCreateDirect(args: {\n organizationId: string;\n userId: string;\n definitionId: string;\n }): Promise<ConversationIface>;\n // The conversation a channel binding is attached to.\n boundTo(bindingId: string): Promise<ConversationIface | null>;\n participants(conversationId: string): Promise<ParticipantIface[]>;\n systemParticipant(args: {\n conversationId: string;\n systemKind: SystemParticipantKind;\n displayName: string;\n sourceRef: string;\n }): 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?: JsonObject | null;\n participantId: string;\n pendingId: string;\n outcome: JsonValue;\n actorParticipantId: string;\n userId: string | null;\n apiKeyId: string | null;\n}\n\nexport interface ChannelReceiveContextIface {\n bindings?: HostedBindingsIface;\n platform: ChannelPlatformIface;\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\n// An HTTP route a channel serves (webhooks), mounted by the front door at\n// /api/events/webhooks/:bindingId<path> and the per-agent aliases.\nexport interface ChannelRouteContextIface {\n bindings?: HostedBindingsIface;\n request: Request;\n secrets: { get(name: string): Promise<string | null> };\n receive: (input: JsonValue) => Promise<ChannelReceiveResult>;\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\nexport interface HttpChannelRouteDefinitionIface {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE';\n path: string;\n handler: (args: ChannelRouteContextIface) => Promise<Response>;\n}\n\nexport interface WebSocketChannelRouteDefinitionIface {\n method: 'WS';\n path: string;\n // Returning an HTTP response before accept rejects the handshake. The handler lives until close.\n handler: (\n args: ChannelRouteContextIface & { socket: ChannelSocketIface },\n ) => Promise<Response | void>;\n}\n\nexport type RouteDefinitionIface =\n | HttpChannelRouteDefinitionIface\n | WebSocketChannelRouteDefinitionIface;\n\n// The per-turn value a channel keeps between its project and event calls of\n// one turn (the definition's `State`). The platform holds it, so a channel\n// running in a Worker isolate keeps nothing in memory; it starts null each turn\n// and is discarded when the turn's projection finishes.\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: ChannelPlatformIface;\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 PendingEventKind {\n Created = 'pending.created',\n Resolved = 'pending.resolved',\n}\n\nexport type AcpUpdateKind = SessionUpdate['sessionUpdate'];\n\nexport type ChannelEventKind =\n | AcpUpdateKind\n | `${PendingEventKind}`\n | `${SemanticChannelEventKind}`;\n\nexport interface ChannelEventIface {\n type: string;\n data: JsonValue;\n seq: number;\n}\n\nexport type ChannelEventHandler<State = JsonValue> = (\n event: ChannelEventIface,\n ctx: ProjectionContextIface<State>,\n) => Promise<void>;\n\nexport enum PendingKind {\n Permission = 'permission',\n Elicitation = 'elicitation',\n}\n\n// `data` of a pending.created event: an ACP session/request_permission or\n// elicitation/create request awaiting its audience.\nexport const pendingCreatedDataSchema = z.object({\n pendingRequestId: z.string().min(1),\n kind: z.nativeEnum(PendingKind),\n audienceParticipantIds: z.array(z.string()),\n request: jsonValueSchema,\n});\n\nexport type PendingCreatedDataIface = z.infer<typeof pendingCreatedDataSchema>;\n\n// `data` of a pending.resolved event: the answer (or cancellation) as recorded.\nexport const pendingResolvedDataSchema = z.object({\n pendingRequestId: z.string().min(1),\n outcome: jsonValueSchema,\n});\n\nexport type PendingResolvedDataIface = z.infer<typeof pendingResolvedDataSchema>;\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// Built-in and custom (bundle) channels implement exactly this; the\n// session service calls nothing else on a channel.\nexport interface ChannelDefinitionIface<Inbound, State = undefined> {\n config?: JsonObject;\n // Installed execution is an optimization for an uncustomized definition.\n installed?: ProviderRef;\n configure?: (config: JsonObject) => ChannelDefinitionIface<Inbound, State>;\n routes?: RouteDefinitionIface[];\n respond?(\n input: ChannelInputResponseIface,\n ctx: ChannelReceiveContextIface,\n ): Promise<{ resolved: boolean }>;\n cancel?(ctx: ChannelReceiveContextIface): Promise<{ accepted: boolean }>;\n // Inserts the input into its conversation and routes it. Returns where it went.\n receive(input: Inbound, ctx: ChannelReceiveContextIface): Promise<ChannelReceiveResult>;\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<ChannelEventKind, ChannelEventHandler<State>>>;\n}\n\nexport const defineChannel = <Inbound, State = undefined>(\n definition: ChannelDefinitionIface<Inbound, State>,\n): ChannelDefinitionIface<Inbound, State> => definition;\n"],
|
|
5
|
+
"mappings": "AAEA,YAAY,OAAO;AAEnB,SAAS,kBAAkB,uBAAwD;AAW5E,IAAK,mBAAL,kBAAKA,sBAAL;AACL,EAAAA,kBAAA,YAAS;AACT,EAAAA,kBAAA,WAAQ;AAFE,SAAAA;AAAA,GAAA;AAKL,IAAK,kBAAL,kBAAKC,qBAAL;AACL,EAAAA,iBAAA,UAAO;AACP,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,YAAS;AAHC,SAAAA;AAAA,GAAA;AAML,IAAK,wBAAL,kBAAKC,2BAAL;AACL,EAAAA,uBAAA,cAAW;AACX,EAAAA,uBAAA,aAAU;AACV,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,UAAO;AACP,EAAAA,uBAAA,YAAS;AALC,SAAAA;AAAA,GAAA;AAQL,IAAK,cAAL,kBAAKC,iBAAL;AACL,EAAAA,aAAA,aAAU;AACV,EAAAA,aAAA,SAAM;AACN,EAAAA,aAAA,aAAU;AAHA,SAAAA;AAAA,GAAA;A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KO,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;AA2BO,MAAM,gBAAgB,CAC3B,eAC2C;",
|
|
6
6
|
"names": ["ConversationKind", "ParticipantKind", "SystemParticipantKind", "RoutingMode", "TurnPolicy", "Delivery", "MessageKind", "CardKind", "PendingEventKind", "PendingKind"]
|
|
7
7
|
}
|
|
@@ -10,6 +10,10 @@ export declare const dynamicSlotSchema: z.ZodObject<{
|
|
|
10
10
|
events: z.ZodArray<z.ZodEnum<typeof DynamicEvent>>;
|
|
11
11
|
description: z.ZodOptional<z.ZodString>;
|
|
12
12
|
preview: z.ZodOptional<z.ZodString>;
|
|
13
|
+
requiredBindings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
14
|
+
name: z.ZodString;
|
|
15
|
+
schema: z.ZodType<import("./json.mjs").JsonObject, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonObject, unknown>>;
|
|
16
|
+
}, z.core.$strip>>>;
|
|
13
17
|
}, z.core.$strip>;
|
|
14
18
|
}, z.core.$strip>;
|
|
15
19
|
export type DynamicSlotIface = z.infer<typeof dynamicSlotSchema>;
|
|
@@ -21,6 +25,10 @@ export declare const maybeDynamic: <T extends z.ZodType>(schema: T) => z.ZodUnio
|
|
|
21
25
|
events: z.ZodArray<z.ZodEnum<typeof DynamicEvent>>;
|
|
22
26
|
description: z.ZodOptional<z.ZodString>;
|
|
23
27
|
preview: z.ZodOptional<z.ZodString>;
|
|
28
|
+
requiredBindings: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
29
|
+
name: z.ZodString;
|
|
30
|
+
schema: z.ZodType<import("./json.mjs").JsonObject, unknown, z.core.$ZodTypeInternals<import("./json.mjs").JsonObject, unknown>>;
|
|
31
|
+
}, z.core.$strip>>>;
|
|
24
32
|
}, z.core.$strip>;
|
|
25
33
|
}, z.core.$strip>, T]>;
|
|
26
34
|
export interface DynamicSlotLocationIface {
|
package/dist/modules/dynamic.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as z from "zod";
|
|
2
|
+
import { hostedBindingRequirementSchema } from "./hosted-bindings.mjs";
|
|
2
3
|
var DynamicEvent = /* @__PURE__ */ ((DynamicEvent2) => {
|
|
3
4
|
DynamicEvent2["SessionStarted"] = "session.started";
|
|
4
5
|
DynamicEvent2["TurnStarted"] = "turn.started";
|
|
@@ -11,7 +12,8 @@ const dynamicSlotSchema = z.object({
|
|
|
11
12
|
events: z.array(z.nativeEnum(DynamicEvent)).min(1),
|
|
12
13
|
// Final additions so Build can render a slot without resolving it.
|
|
13
14
|
description: z.string().optional(),
|
|
14
|
-
preview: z.string().optional()
|
|
15
|
+
preview: z.string().optional(),
|
|
16
|
+
requiredBindings: z.array(hostedBindingRequirementSchema).optional()
|
|
15
17
|
})
|
|
16
18
|
});
|
|
17
19
|
const isDynamicSlot = (value) => dynamicSlotSchema.safeParse(value).success;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/dynamic.ts"],
|
|
4
|
-
"sourcesContent": ["import * as z from 'zod';\nimport type { JsonValue } from \"./json.mjs\";\n\n// Lifecycle boundaries a dynamic slot may resolve at.\n// The harness owns steps, so `step.started` is not supported.\nexport enum DynamicEvent {\n SessionStarted = 'session.started',\n TurnStarted = 'turn.started',\n}\n\nexport const dynamicSlotSchema = z.object({\n $dynamic: z.object({\n // Bundle export that implements the resolver ('instructions/org-context').\n resolver: z.string().min(1),\n events: z.array(z.nativeEnum(DynamicEvent)).min(1),\n // Final additions so Build can render a slot without resolving it.\n description: z.string().optional(),\n preview: z.string().optional(),\n }),\n});\n\nexport type DynamicSlotIface = z.infer<typeof dynamicSlotSchema>;\nexport type Dynamic<_T> = DynamicSlotIface;\n\nexport const isDynamicSlot = <T>(value: T): value is T & DynamicSlotIface =>\n dynamicSlotSchema.safeParse(value).success;\n\nconst slotOf = <T>(value: T): DynamicSlotIface | null => {\n const parsed = dynamicSlotSchema.safeParse(value);\n return parsed.success ? parsed.data : null;\n};\n\nconst listSchema = z.array(z.json());\nconst objectSchema = z.record(z.string(), z.json());\nconst looseListSchema = z.array(z.unknown());\nconst looseObjectSchema = z.record(z.string(), z.unknown());\n\nexport const maybeDynamic = <T extends z.ZodType>(schema: T) =>\n z.union([dynamicSlotSchema, schema]);\n\n// A dynamic slot found while walking a JSON document, addressed by a stable\n// path ('harness.config.instructions[1]') that the manifest's bundle.resolvers\n// map keys by.\nexport interface DynamicSlotLocationIface {\n path: string;\n slot: DynamicSlotIface;\n}\n\nconst indexPath = (parent: string, index: number): string => `${parent}[${index}]`;\nconst keyPath = (parent: string, key: string): string =>\n parent.length === 0 ? key : `${parent}.${key}`;\n\nexport const findDynamicSlots = <T>(value: T, path = ''): DynamicSlotLocationIface[] => {\n const slot = slotOf(value);\n if (slot != null) return [{ path, slot }];\n const list = looseListSchema.safeParse(value);\n if (list.success) {\n return list.data.flatMap((item, index) => findDynamicSlots(item, indexPath(path, index)));\n }\n const object = looseObjectSchema.safeParse(value);\n if (object.success) {\n return Object.entries(object.data).flatMap(([key, item]) =>\n findDynamicSlots(item, keyPath(path, key)),\n );\n }\n return [];\n};\n\nexport const containsDynamicSlot = <T>(value: T): boolean => findDynamicSlots(value).length > 0;\n\n// Replaces each slot with the resolver output for its path. A resolver that\n// returned null removes an array entry and leaves an object field as null.\nexport const replaceDynamicSlots = (\n value: JsonValue,\n resolved: Record<string, JsonValue | null>,\n path = '',\n): JsonValue => {\n if (isDynamicSlot(value)) return resolved[path] ?? null;\n const list = listSchema.safeParse(value);\n if (list.success) {\n const out: JsonValue[] = [];\n list.data.forEach((item, index) => {\n const itemPath = indexPath(path, index);\n if (isDynamicSlot(item) && resolved[itemPath] == null) return;\n out.push(replaceDynamicSlots(item, resolved, itemPath));\n });\n return out;\n }\n const object = objectSchema.safeParse(value);\n if (object.success) {\n return Object.fromEntries(\n Object.entries(object.data).map(([key, item]) => [\n key,\n replaceDynamicSlots(item, resolved, keyPath(path, key)),\n ]),\n );\n }\n return value;\n};\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,OAAO;
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\nimport type { JsonValue } from \"./json.mjs\";\nimport { hostedBindingRequirementSchema } from \"./hosted-bindings.mjs\";\n\n// Lifecycle boundaries a dynamic slot may resolve at.\n// The harness owns steps, so `step.started` is not supported.\nexport enum DynamicEvent {\n SessionStarted = 'session.started',\n TurnStarted = 'turn.started',\n}\n\nexport const dynamicSlotSchema = z.object({\n $dynamic: z.object({\n // Bundle export that implements the resolver ('instructions/org-context').\n resolver: z.string().min(1),\n events: z.array(z.nativeEnum(DynamicEvent)).min(1),\n // Final additions so Build can render a slot without resolving it.\n description: z.string().optional(),\n preview: z.string().optional(),\n requiredBindings: z.array(hostedBindingRequirementSchema).optional(),\n }),\n});\n\nexport type DynamicSlotIface = z.infer<typeof dynamicSlotSchema>;\nexport type Dynamic<_T> = DynamicSlotIface;\n\nexport const isDynamicSlot = <T>(value: T): value is T & DynamicSlotIface =>\n dynamicSlotSchema.safeParse(value).success;\n\nconst slotOf = <T>(value: T): DynamicSlotIface | null => {\n const parsed = dynamicSlotSchema.safeParse(value);\n return parsed.success ? parsed.data : null;\n};\n\nconst listSchema = z.array(z.json());\nconst objectSchema = z.record(z.string(), z.json());\nconst looseListSchema = z.array(z.unknown());\nconst looseObjectSchema = z.record(z.string(), z.unknown());\n\nexport const maybeDynamic = <T extends z.ZodType>(schema: T) =>\n z.union([dynamicSlotSchema, schema]);\n\n// A dynamic slot found while walking a JSON document, addressed by a stable\n// path ('harness.config.instructions[1]') that the manifest's bundle.resolvers\n// map keys by.\nexport interface DynamicSlotLocationIface {\n path: string;\n slot: DynamicSlotIface;\n}\n\nconst indexPath = (parent: string, index: number): string => `${parent}[${index}]`;\nconst keyPath = (parent: string, key: string): string =>\n parent.length === 0 ? key : `${parent}.${key}`;\n\nexport const findDynamicSlots = <T>(value: T, path = ''): DynamicSlotLocationIface[] => {\n const slot = slotOf(value);\n if (slot != null) return [{ path, slot }];\n const list = looseListSchema.safeParse(value);\n if (list.success) {\n return list.data.flatMap((item, index) => findDynamicSlots(item, indexPath(path, index)));\n }\n const object = looseObjectSchema.safeParse(value);\n if (object.success) {\n return Object.entries(object.data).flatMap(([key, item]) =>\n findDynamicSlots(item, keyPath(path, key)),\n );\n }\n return [];\n};\n\nexport const containsDynamicSlot = <T>(value: T): boolean => findDynamicSlots(value).length > 0;\n\n// Replaces each slot with the resolver output for its path. A resolver that\n// returned null removes an array entry and leaves an object field as null.\nexport const replaceDynamicSlots = (\n value: JsonValue,\n resolved: Record<string, JsonValue | null>,\n path = '',\n): JsonValue => {\n if (isDynamicSlot(value)) return resolved[path] ?? null;\n const list = listSchema.safeParse(value);\n if (list.success) {\n const out: JsonValue[] = [];\n list.data.forEach((item, index) => {\n const itemPath = indexPath(path, index);\n if (isDynamicSlot(item) && resolved[itemPath] == null) return;\n out.push(replaceDynamicSlots(item, resolved, itemPath));\n });\n return out;\n }\n const object = objectSchema.safeParse(value);\n if (object.success) {\n return Object.fromEntries(\n Object.entries(object.data).map(([key, item]) => [\n key,\n replaceDynamicSlots(item, resolved, keyPath(path, key)),\n ]),\n );\n }\n return value;\n};\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,OAAO;AAEnB,SAAS,sCAAsC;AAIxC,IAAK,eAAL,kBAAKA,kBAAL;AACL,EAAAA,cAAA,oBAAiB;AACjB,EAAAA,cAAA,iBAAc;AAFJ,SAAAA;AAAA,GAAA;AAKL,MAAM,oBAAoB,EAAE,OAAO;AAAA,EACxC,UAAU,EAAE,OAAO;AAAA;AAAA,IAEjB,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,IAC1B,QAAQ,EAAE,MAAM,EAAE,WAAW,YAAY,CAAC,EAAE,IAAI,CAAC;AAAA;AAAA,IAEjD,aAAa,EAAE,OAAO,EAAE,SAAS;AAAA,IACjC,SAAS,EAAE,OAAO,EAAE,SAAS;AAAA,IAC7B,kBAAkB,EAAE,MAAM,8BAA8B,EAAE,SAAS;AAAA,EACrE,CAAC;AACH,CAAC;AAKM,MAAM,gBAAgB,CAAI,UAC/B,kBAAkB,UAAU,KAAK,EAAE;AAErC,MAAM,SAAS,CAAI,UAAsC;AACvD,QAAM,SAAS,kBAAkB,UAAU,KAAK;AAChD,SAAO,OAAO,UAAU,OAAO,OAAO;AACxC;AAEA,MAAM,aAAa,EAAE,MAAM,EAAE,KAAK,CAAC;AACnC,MAAM,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,KAAK,CAAC;AAClD,MAAM,kBAAkB,EAAE,MAAM,EAAE,QAAQ,CAAC;AAC3C,MAAM,oBAAoB,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,QAAQ,CAAC;AAEnD,MAAM,eAAe,CAAsB,WAChD,EAAE,MAAM,CAAC,mBAAmB,MAAM,CAAC;AAUrC,MAAM,YAAY,CAAC,QAAgB,UAA0B,GAAG,MAAM,IAAI,KAAK;AAC/E,MAAM,UAAU,CAAC,QAAgB,QAC/B,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/C;AAAA,QACA,oBAAoB,MAAM,UAAU,QAAQ,MAAM,GAAG,CAAC;AAAA,MACxD,CAAC;AAAA,IACH;AAAA,EACF;AACA,SAAO;AACT;",
|
|
6
6
|
"names": ["DynamicEvent"]
|
|
7
7
|
}
|
|
@@ -3,6 +3,7 @@ import * as z from 'zod';
|
|
|
3
3
|
import { CredentialRoute, type RouteGrantIface } from "./credential-routes.mjs";
|
|
4
4
|
import { CredentialDelivery, InferenceCredentialKind } from "./credentials.mjs";
|
|
5
5
|
import type { JsonSchema, JsonValue } from "./json.mjs";
|
|
6
|
+
import type { HostedBindingsIface } from "./hosted-bindings.mjs";
|
|
6
7
|
import { BaseCapability, type ResolvedAgentManifestIface } from "./manifest.mjs";
|
|
7
8
|
import { type ProviderRef } from "./provider-ref.mjs";
|
|
8
9
|
export declare const PENDING_BUNDLE_EXPORT = "<pending>";
|
|
@@ -68,6 +69,7 @@ export declare const harnessDescriptionSchema: z.ZodObject<{
|
|
|
68
69
|
fork: z.ZodBoolean;
|
|
69
70
|
authorMeta: z.ZodBoolean;
|
|
70
71
|
nativeToolPolicy: z.ZodOptional<z.ZodBoolean>;
|
|
72
|
+
deferredToolSearch: z.ZodOptional<z.ZodBoolean>;
|
|
71
73
|
}, z.core.$strip>;
|
|
72
74
|
promptWhileRunning: z.ZodDefault<z.ZodEnum<typeof PromptWhileRunning>>;
|
|
73
75
|
sessionSurvivesDisconnect: z.ZodDefault<z.ZodBoolean>;
|
|
@@ -267,6 +269,7 @@ export interface SandboxTargetEndpointIface {
|
|
|
267
269
|
} | null;
|
|
268
270
|
}
|
|
269
271
|
export interface HarnessSessionContextIface {
|
|
272
|
+
bindings?: HostedBindingsIface;
|
|
270
273
|
sessionId: string;
|
|
271
274
|
organizationId: string;
|
|
272
275
|
definitionId: string;
|
package/dist/modules/harness.mjs
CHANGED
|
@@ -80,7 +80,11 @@ const harnessDescriptionSchema = z.object({
|
|
|
80
80
|
// the author's name to the text.
|
|
81
81
|
authorMeta: z.boolean(),
|
|
82
82
|
// Explicit false: native toolPolicy cannot be enforced by this adapter's public surface.
|
|
83
|
-
nativeToolPolicy: z.boolean().optional()
|
|
83
|
+
nativeToolPolicy: z.boolean().optional(),
|
|
84
|
+
// Defers and searches MCP tools itself (a harness-native tool search): the
|
|
85
|
+
// host lists every exposed tool, ignoring connections' `tools.load`, and
|
|
86
|
+
// adds no search of its own. Absent: the host applies `load` and serves search.
|
|
87
|
+
deferredToolSearch: z.boolean().optional()
|
|
84
88
|
}),
|
|
85
89
|
promptWhileRunning: z.nativeEnum(PromptWhileRunning).default(DEFAULT_PROMPT_WHILE_RUNNING),
|
|
86
90
|
// Keeps the session, its running work and its open requests across a dropped
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/harness.ts"],
|
|
4
|
-
"sourcesContent": ["import type { McpServer } from '@agentclientprotocol/sdk/experimental/v2';\nimport * as z from 'zod';\nimport { CredentialRoute, routeGrantSchema, type RouteGrantIface } from \"./credential-routes.mjs\";\nimport { CredentialDelivery, InferenceCredentialKind } from \"./credentials.mjs\";\nimport type { JsonSchema, JsonValue } from \"./json.mjs\";\nimport { jsonObjectSchema, jsonSchemaSchema } from \"./json.mjs\";\nimport { BaseCapability, InstructionRole, type ResolvedAgentManifestIface } from \"./manifest.mjs\";\nimport { bundleRef, providerRefSchema, type ProviderRef } from \"./provider-ref.mjs\";\nimport { referencedSharedSchemas, SCHEMA_IDS } from \"./schemas.mjs\";\n\n// Placeholder export name the compiler replaces with the defining module's path.\nexport const PENDING_BUNDLE_EXPORT = '<pending>';\n\n// A harness is a specific ACP agent program together with how to reach it. Hosting is part of what a harness is, so there is no\n// engine parameter: \"Pi on Final's serverless runtime\" and \"Pi on a server you\n// run\" are two harnesses. The hosting half is deliberately small; everything\n// about what the agent does goes over ACP v2.\n\nexport enum AcpTransport {\n Relay = 'relay',\n Ws = 'ws',\n Http = 'http',\n Stdio = 'stdio',\n}\n\nexport enum McpTransportKind {\n Acp = 'acp',\n Http = 'http',\n Stdio = 'stdio',\n}\n\n// How a harness provides one base capability.\nexport enum BaseToolProvision {\n // Routed to the declared sandbox target.\n Bound = 'bound',\n // Native on the harness's host and switchable through its own allow-lists.\n HostDisableable = 'host-disableable',\n // Native on the harness's host and not switchable.\n HostFixed = 'host-fixed',\n}\n\n// SDK wires a harness speaks to reach a bound sandbox target.\nexport enum SandboxWire {\n HandleRpc = 'handle-rpc',\n Mcp = 'mcp',\n}\n\nexport enum UserInstructionDelivery {\n History = 'history',\n System = 'system',\n}\n\n// Who operates the place a harness's credentials land. Every\n// harness, Final's included, gets the same grant forms; a subscription goes to\n// a third-party harness only when its owner allowed third-party harnesses.\n// Only installed provider packages may declare first-party; a bundle-declared\n// harness is third-party whatever it declares.\nexport enum HarnessTrustClass {\n // The provider operates the harness on infrastructure it runs (Final's serverless harnesses).\n FirstParty = 'first-party',\n // Someone else's host or program (remote hosts, external ACP agents, local processes).\n ThirdParty = 'third-party',\n}\n\n// What an accepted session/prompt does while the session is running. Both are valid; refusing one is a conformance failure.\nexport enum PromptWhileRunning {\n // Joins the running work: the model sees it at its next step.\n Inject = 'inject',\n // Runs after the current work goes idle; dropped by session/cancel if not started.\n Queue = 'queue',\n}\n\n// Defaults for a description that does not declare the hosting contract's\n// newer fields (bundle harnesses, older registrations): the session service\n// then assumes nothing survives a dropped connection and that a prompt while\n// running waits for idle.\nexport const DEFAULT_PROMPT_WHILE_RUNNING = PromptWhileRunning.Queue;\nexport const DEFAULT_SESSION_SURVIVES_DISCONNECT = false;\n\nexport const baseToolDeclarationSchema = z.object({\n provision: z.nativeEnum(BaseToolProvision),\n nativeTools: z.array(z.string()),\n});\n\nexport const harnessDescriptionSchema = z.object({\n // Everything configurable about this harness (model, reasoning, credentials,\n // permission mode, instructions, skills, cwd, ...). JSON Schema so Build can\n // render it; may $ref the shared final://schemas/* fragments.\n configSchema: jsonSchemaSchema,\n // Absent: user fragments enter history. System-only programs declare their conversion.\n userInstructionDelivery: z.nativeEnum(UserInstructionDelivery).optional(),\n acp: z.object({\n transports: z.array(z.nativeEnum(AcpTransport)).min(1),\n mcp: z.array(z.nativeEnum(McpTransportKind)),\n }),\n // A capability missing here is unavailable on this harness.\n baseTools: z.partialRecord(z.nativeEnum(BaseCapability), baseToolDeclarationSchema),\n consumes: z.array(z.nativeEnum(SandboxWire)),\n inference: z.object({\n vendors: z.array(z.string()),\n kinds: z.array(z.nativeEnum(InferenceCredentialKind)),\n delivery: z.nativeEnum(CredentialDelivery),\n }),\n // Absent: third-party.\n trust: z.nativeEnum(HarnessTrustClass).optional(),\n supports: z.object({\n observe: z.boolean(),\n resumeReplay: z.boolean(),\n fork: z.boolean(),\n // Renders _meta[\"final.ai\"].author itself; otherwise the channel prepends\n // the author's name to the text.\n authorMeta: z.boolean(),\n // Explicit false: native toolPolicy cannot be enforced by this adapter's public surface.\n nativeToolPolicy: z.boolean().optional(),\n }),\n promptWhileRunning: z.nativeEnum(PromptWhileRunning).default(DEFAULT_PROMPT_WHILE_RUNNING),\n // Keeps the session, its running work and its open requests across a dropped\n // connection, buffers updates for replay, and re-raises the open requests\n // with the same JSON-RPC ids on the next session/resume. False:\n // open turns end `harness_state_lost` after a reconnect.\n sessionSurvivesDisconnect: z.boolean().default(DEFAULT_SESSION_SURVIVES_DISCONNECT),\n});\n\nexport type BaseToolDeclarationIface = z.infer<typeof baseToolDeclarationSchema>;\nexport type HarnessDescriptionIface = z.infer<typeof harnessDescriptionSchema>;\n\nexport const deliveredHarnessConfig = (args: {\n config: JsonValue;\n description: HarnessDescriptionIface;\n}): JsonValue => {\n if (args.description.userInstructionDelivery !== UserInstructionDelivery.System)\n return args.config;\n const config = jsonObjectSchema.safeParse(args.config);\n if (!config.success) return args.config;\n const fields = referencedSharedSchemas(args.description.configSchema);\n const field =\n Object.entries(fields).find(([, schema]) => schema === SCHEMA_IDS.instructions)?.[0] ??\n 'instructions';\n const instructions = config.data[field];\n if (!Array.isArray(instructions)) return args.config;\n return {\n ...config.data,\n [field]: instructions.map((value) => {\n const fragment = jsonObjectSchema.safeParse(value);\n return fragment.success && fragment.data['role'] === InstructionRole.User\n ? { ...fragment.data, role: InstructionRole.System }\n : value;\n }),\n };\n};\n\nexport const harnessSessionRefSchema = z.object({\n harness: providerRefSchema,\n // Opaque to the session service; the harness's own id for the session.\n harnessSessionRef: z.string().min(1),\n // Bumped whenever the harness loses state; a mismatch on resume means the\n // session service must re-seed with session/new.\n generation: z.number().int().nonnegative(),\n});\n\nexport type HarnessSessionRefIface = z.infer<typeof harnessSessionRefSchema>;\n\n// Route-scoped, short-lived grants: credential-routes.ts.\nexport {\n credentialRefreshRequestSchema,\n CredentialRoute,\n routeGrantSchema,\n type CredentialRefreshRequestIface,\n type RouteGrantIface,\n} from \"./credential-routes.mjs\";\n\nexport interface CredentialGrantIface {\n // Base URL of the broker routes (`<base>/model`, `<base>/refresh`, ...).\n brokerUrl: string;\n grants: RouteGrantIface[];\n // What the model grant resolved to, for harnesses that hand credentials over\n // at open (delivery 'at-open'). Null for per-request harnesses.\n atOpen: AtOpenModelCredentialIface | null;\n // How to renew this grant; null only when it carries no route grant.\n refresh: CredentialGrantRefreshIface | null;\n}\n\n// Renewal is pulled, never pushed. Per-request harnesses fetch\n// `<brokerUrl>/model` on every request. At-open harnesses (or their host)\n// POST `url` with `authorization: Bearer <token>` and a\n// `credentialRefreshRequestSchema` body before `expiresAt` and once after a\n// vendor 401; the answer is the grant's next generation (a\n// `credentialRefreshResultSchema` body with its own `refresh`), which replaces\n// this one. The broker resolves the policy again for it, so a disconnected\n// credential falls through; a revoked grant (every open revokes the previous\n// open's grants) or a closed harness session is refused (401).\nexport interface CredentialGrantRefreshIface {\n // `<brokerUrl>/refresh`.\n url: string;\n // One of this grant's own route grants (the model route's).\n token: string;\n harnessSessionId: string;\n // When `token` expires; a refresh after it is refused.\n expiresAt: string;\n}\n\nexport interface AtOpenModelCredentialIface {\n vendor: string;\n kind: InferenceCredentialKind;\n // Base URL and bearer for an OpenAI- or Anthropic-compatible endpoint (the\n // platform proxy, a corporate gateway) or the vendor itself.\n baseUrl: string | null;\n apiKey: string | null;\n // Subscription material for Final-managed harnesses only (Claude setup token,\n // Codex app-server chatgptAuthTokens); renewed through the grant's refresh route.\n subscription: { format: 'claude-setup-token' | 'chatgpt-auth-tokens'; value: string } | null;\n fingerprint: string;\n}\n\nexport const atOpenModelCredentialSchema = z.object({\n vendor: z.string(),\n kind: z.nativeEnum(InferenceCredentialKind),\n baseUrl: z.string().min(1).nullable(),\n apiKey: z.string().min(1).nullable(),\n subscription: z\n .object({\n format: z.union([z.literal('claude-setup-token'), z.literal('chatgpt-auth-tokens')]),\n value: z.string().min(1),\n })\n .nullable(),\n fingerprint: z.string(),\n}) satisfies z.ZodType<AtOpenModelCredentialIface>;\n\nexport const credentialGrantRefreshSchema = z.object({\n url: z.string().min(1),\n token: z.string().min(1),\n harnessSessionId: z.string().min(1),\n expiresAt: z.string(),\n}) satisfies z.ZodType<CredentialGrantRefreshIface>;\n\nexport const credentialGrantSchema = z.object({\n brokerUrl: z.string().min(1),\n grants: z.array(routeGrantSchema),\n atOpen: atOpenModelCredentialSchema.nullable(),\n refresh: credentialGrantRefreshSchema.nullable(),\n}) satisfies z.ZodType<CredentialGrantIface>;\n\n// An `http` MCP server entry the harness was handed in `session/new`\n// (`mcpServers`), with fresh headers. Same name and url; the harness swaps the\n// headers of the entry with that url.\nexport interface RenewedMcpServerIface {\n name: string;\n url: string;\n headers: { name: string; value: string }[];\n}\n\n// What a refresh answers: the grant's next generation, plus fresh copies of the\n// other short-lived material the harness was handed at open. Renewing the\n// `mcp` route renews the session's `http` MCP server headers; renewing\n// `sandbox` renews the bound sandbox targets' endpoint tokens.\nexport interface CredentialRefreshResultIface extends CredentialGrantIface {\n mcpServers: RenewedMcpServerIface[];\n sandboxes: Record<string, SandboxTargetEndpointIface>;\n}\n\nconst endpointTokenSchema = z.object({\n url: z.string().min(1),\n token: z.string(),\n expiresAt: z.string(),\n});\n\nexport const sandboxTargetEndpointSchema = z.object({\n target: z.string().min(1),\n bindingId: z.string().min(1),\n capabilities: z.array(z.string()),\n rpc: endpointTokenSchema.nullable(),\n mcp: endpointTokenSchema.nullable(),\n}) satisfies z.ZodType<SandboxTargetEndpointIface>;\n\nexport const renewedMcpServerSchema = z.object({\n name: z.string().min(1),\n url: z.string().min(1),\n headers: z.array(z.object({ name: z.string().min(1), value: z.string() })),\n}) satisfies z.ZodType<RenewedMcpServerIface>;\n\n// Absent renewals parse as none, so an answer without them still parses.\nexport const credentialRefreshResultSchema = credentialGrantSchema.extend({\n mcpServers: z.array(renewedMcpServerSchema).default([]),\n sandboxes: z.record(z.string(), sandboxTargetEndpointSchema).default({}),\n}) satisfies z.ZodType<CredentialRefreshResultIface, unknown>;\n\n// The refresh descriptor for a set of route grants: authenticated by the model\n// grant (else the first), due when that token expires.\nexport const grantRefreshFor = (args: {\n brokerUrl: string;\n harnessSessionId: string;\n grants: readonly RouteGrantIface[];\n}): CredentialGrantRefreshIface | null => {\n const grant =\n args.grants.find((candidate) => candidate.route === CredentialRoute.Model) ?? args.grants[0];\n if (grant == null) return null;\n return {\n url: `${args.brokerUrl.replace(/\\/+$/, '')}/refresh`,\n token: grant.token,\n harnessSessionId: args.harnessSessionId,\n expiresAt: grant.expiresAt,\n };\n};\n\nexport interface SecretReaderIface {\n get(name: string): Promise<string | null>;\n}\n\nexport interface TraceContextIface {\n traceparent: string | null;\n tracestate: string | null;\n}\n\n// A bound sandbox target as the session service hands it to a harness: a stable\n// per-binding address that starts the sandbox on the first tool call. Never a lease, a data-plane token for a live VM, or provider code.\nexport interface SandboxTargetEndpointIface {\n target: string;\n bindingId: string;\n capabilities: string[];\n rpc: { url: string; token: string; expiresAt: string } | null;\n mcp: { url: string; token: string; expiresAt: string } | null;\n}\n\nexport interface HarnessSessionContextIface {\n sessionId: string;\n organizationId: string;\n definitionId: string;\n revisionId: string;\n // Public base URL of the session service for this session (MCP over HTTP,\n // sandbox endpoints, the broker).\n sessionServiceUrl: string;\n // The region of the session service serving the session and its sandbox\n // bindings, so a harness can run near it; null when unknown.\n sessionServiceRegion?: string | null;\n}\n\n// Lifecycle signals a harness implementation may report about the runtime\n// hosting a session (invocations, metering, traces). Informational: the\n// session service records them (agent.harness_invocations, Tinybird) and never\n// depends on them for correctness.\nexport interface HarnessObserverIface {\n // The runtime accepted the invocation request (its response began).\n invocationAccepted?(event: { invocationRef: string; at: string }): void;\n invocationStarted?(event: {\n invocationRef: string;\n at: string;\n bootMs: number | null;\n // The runtime's deployed version (Workers version id, commit), for rollouts.\n versionId?: string | null;\n commitSha?: string | null;\n }): void;\n invocationKeepalive?(event: { invocationRef: string; at: string; activeWork: number }): void;\n invocationEnded?(event: {\n invocationRef: string;\n at: string;\n reason: string;\n error: string | null;\n metering: Record<string, number>;\n }): void;\n trace?(event: { name: string; at: string; fields: Record<string, JsonValue> }): void;\n}\n\nexport interface OpenHarnessSessionArgsIface {\n session: HarnessSessionContextIface;\n // The session service's id for this harness session (agent.harness_sessions);\n // implementations key their runtime state and route grants by it.\n harnessSessionId: string;\n // Hosting may authorize the child endpoint to fork this source through ACP.\n forkSource?: { ref: HarnessSessionRefIface; acpSessionId: string };\n observer?: HarnessObserverIface;\n // The binding's config, validated against configSchema, dynamic slots resolved.\n config: JsonValue;\n manifest: ResolvedAgentManifestIface;\n // Already materialized ACP MCP server entries: authored tools, connections\n // (Final's MCP server among them), sandbox MCP projections where applicable.\n mcpServers: McpServer[];\n // Declared base capabilities with the target endpoint each is bound to.\n baseTools: Partial<Record<BaseCapability, SandboxTargetEndpointIface>>;\n sandboxes: Record<string, SandboxTargetEndpointIface>;\n credentials: CredentialGrantIface;\n secrets: SecretReaderIface;\n trace: TraceContextIface;\n}\n\nexport interface ResumeHarnessSessionArgsIface extends OpenHarnessSessionArgsIface {\n ref: HarnessSessionRefIface;\n // Last log seq the session service holds from this harness session; the\n // harness replays anything newer after session/resume.\n lastSeq: number;\n}\n\n// Resolved only in memory; refs/manifests retain secret names, never TLS keys.\nexport interface HarnessClientTlsIface {\n cert: string;\n key: string;\n ca?: string;\n}\n\nexport type HarnessEndpointIface =\n | {\n ref: HarnessSessionRefIface;\n transport: AcpTransport.Ws;\n url: string;\n headers: Record<string, string>;\n resolveHeaders?: () => Promise<Record<string, string>>;\n tls?: HarnessClientTlsIface;\n }\n | {\n ref: HarnessSessionRefIface;\n transport: AcpTransport.Http;\n url: string;\n headers: Record<string, string>;\n resolveHeaders?: () => Promise<Record<string, string>>;\n tls?: HarnessClientTlsIface;\n }\n // websocket-gateway relay channel (Final-managed harnesses).\n | { ref: HarnessSessionRefIface; transport: AcpTransport.Relay; channel: string; token: string }\n // Local development, CI and conformance only.\n | {\n ref: HarnessSessionRefIface;\n transport: AcpTransport.Stdio;\n command: string;\n args: string[];\n env: Record<string, string>;\n };\n\nexport interface HarnessHealthIface {\n ok: boolean;\n detail?: string;\n checkedAt: string;\n}\n\n// The binding a description is asked for: its config (validated against the\n// configSchema of the binding-free description) and the definition's secrets.\nexport interface DescribeHarnessArgsIface {\n config: JsonValue;\n secrets: SecretReaderIface;\n}\n\nexport interface HarnessIface {\n // Without a binding: what Build renders before one exists (configSchema,\n // declared capabilities). With one: the description of that binding, which a\n // harness reaching an arbitrary agent derives from the agent itself (e.g. its\n // `initialize`). Every harness implements both; most ignore the binding.\n describe(binding?: DescribeHarnessArgsIface): Promise<HarnessDescriptionIface>;\n open(args: OpenHarnessSessionArgsIface): Promise<HarnessEndpointIface>;\n resume(args: ResumeHarnessSessionArgsIface): Promise<HarnessEndpointIface>;\n park(ref: HarnessSessionRefIface): Promise<void>;\n // Graceful by default: the program's state is durable (resumable) before it\n // stops, bounded by the implementation's timeout, then forced. `force` skips\n // the wait; the session service passes it when the program did not settle\n // ACP `session/close` within its bound.\n close(ref: HarnessSessionRefIface, opts?: CloseHarnessSessionOptsIface): Promise<void>;\n health(\n ref: HarnessSessionRefIface,\n context?: DescribeHarnessArgsIface,\n ): Promise<HarnessHealthIface>;\n}\n\nexport interface CloseHarnessSessionOptsIface {\n force?: boolean;\n // As with health, retained refs can resolve current client TLS without storing keys in the ref.\n context?: DescribeHarnessArgsIface;\n}\n\n// What an installed harness module exports: the implementation plus an\n// authoring helper that builds the manifest binding.\nexport interface HarnessModuleIface<Config> {\n ref: ProviderRef;\n harness: HarnessIface;\n binding: (config: Config) => { harness: ProviderRef; config: JsonValue };\n}\n\n// Custom harnesses in a definition's bundle. Calling the result\n// with a config yields the manifest binding; the implementation is resolved\n// from the bundle by export name.\nexport interface DefinedHarnessBindingIface {\n harness: ProviderRef;\n config: JsonValue;\n definedHarness: true;\n}\n\nexport interface DefinedHarnessIface<Config> extends HarnessIface {\n (config: Config): DefinedHarnessBindingIface;\n}\n\nexport const defineHarness = <Config extends JsonValue = JsonValue>(\n implementation: HarnessIface,\n): DefinedHarnessIface<Config> => {\n // The export name is unknown here; the compiler rewrites `bundle:<pending>`\n // to the module path that exported this harness.\n const binding = (config: Config): DefinedHarnessBindingIface => ({\n harness: bundleRef(PENDING_BUNDLE_EXPORT),\n config,\n definedHarness: true,\n });\n return Object.assign(binding, implementation);\n};\n\nexport const describeConfigSchema = (description: HarnessDescriptionIface): JsonSchema =>\n description.configSchema;\n"],
|
|
5
|
-
"mappings": "AACA,YAAY,OAAO;AACnB,SAAS,iBAAiB,wBAA8C;AACxE,SAAS,oBAAoB,+BAA+B;
|
|
4
|
+
"sourcesContent": ["import type { McpServer } from '@agentclientprotocol/sdk/experimental/v2';\nimport * as z from 'zod';\nimport { CredentialRoute, routeGrantSchema, type RouteGrantIface } from \"./credential-routes.mjs\";\nimport { CredentialDelivery, InferenceCredentialKind } from \"./credentials.mjs\";\nimport type { JsonSchema, JsonValue } from \"./json.mjs\";\nimport type { HostedBindingsIface } from \"./hosted-bindings.mjs\";\nimport { jsonObjectSchema, jsonSchemaSchema } from \"./json.mjs\";\nimport { BaseCapability, InstructionRole, type ResolvedAgentManifestIface } from \"./manifest.mjs\";\nimport { bundleRef, providerRefSchema, type ProviderRef } from \"./provider-ref.mjs\";\nimport { referencedSharedSchemas, SCHEMA_IDS } from \"./schemas.mjs\";\n\n// Placeholder export name the compiler replaces with the defining module's path.\nexport const PENDING_BUNDLE_EXPORT = '<pending>';\n\n// A harness is a specific ACP agent program together with how to reach it. Hosting is part of what a harness is, so there is no\n// engine parameter: \"Pi on Final's serverless runtime\" and \"Pi on a server you\n// run\" are two harnesses. The hosting half is deliberately small; everything\n// about what the agent does goes over ACP v2.\n\nexport enum AcpTransport {\n Relay = 'relay',\n Ws = 'ws',\n Http = 'http',\n Stdio = 'stdio',\n}\n\nexport enum McpTransportKind {\n Acp = 'acp',\n Http = 'http',\n Stdio = 'stdio',\n}\n\n// How a harness provides one base capability.\nexport enum BaseToolProvision {\n // Routed to the declared sandbox target.\n Bound = 'bound',\n // Native on the harness's host and switchable through its own allow-lists.\n HostDisableable = 'host-disableable',\n // Native on the harness's host and not switchable.\n HostFixed = 'host-fixed',\n}\n\n// SDK wires a harness speaks to reach a bound sandbox target.\nexport enum SandboxWire {\n HandleRpc = 'handle-rpc',\n Mcp = 'mcp',\n}\n\nexport enum UserInstructionDelivery {\n History = 'history',\n System = 'system',\n}\n\n// Who operates the place a harness's credentials land. Every\n// harness, Final's included, gets the same grant forms; a subscription goes to\n// a third-party harness only when its owner allowed third-party harnesses.\n// Only installed provider packages may declare first-party; a bundle-declared\n// harness is third-party whatever it declares.\nexport enum HarnessTrustClass {\n // The provider operates the harness on infrastructure it runs (Final's serverless harnesses).\n FirstParty = 'first-party',\n // Someone else's host or program (remote hosts, external ACP agents, local processes).\n ThirdParty = 'third-party',\n}\n\n// What an accepted session/prompt does while the session is running. Both are valid; refusing one is a conformance failure.\nexport enum PromptWhileRunning {\n // Joins the running work: the model sees it at its next step.\n Inject = 'inject',\n // Runs after the current work goes idle; dropped by session/cancel if not started.\n Queue = 'queue',\n}\n\n// Defaults for a description that does not declare the hosting contract's\n// newer fields (bundle harnesses, older registrations): the session service\n// then assumes nothing survives a dropped connection and that a prompt while\n// running waits for idle.\nexport const DEFAULT_PROMPT_WHILE_RUNNING = PromptWhileRunning.Queue;\nexport const DEFAULT_SESSION_SURVIVES_DISCONNECT = false;\n\nexport const baseToolDeclarationSchema = z.object({\n provision: z.nativeEnum(BaseToolProvision),\n nativeTools: z.array(z.string()),\n});\n\nexport const harnessDescriptionSchema = z.object({\n // Everything configurable about this harness (model, reasoning, credentials,\n // permission mode, instructions, skills, cwd, ...). JSON Schema so Build can\n // render it; may $ref the shared final://schemas/* fragments.\n configSchema: jsonSchemaSchema,\n // Absent: user fragments enter history. System-only programs declare their conversion.\n userInstructionDelivery: z.nativeEnum(UserInstructionDelivery).optional(),\n acp: z.object({\n transports: z.array(z.nativeEnum(AcpTransport)).min(1),\n mcp: z.array(z.nativeEnum(McpTransportKind)),\n }),\n // A capability missing here is unavailable on this harness.\n baseTools: z.partialRecord(z.nativeEnum(BaseCapability), baseToolDeclarationSchema),\n consumes: z.array(z.nativeEnum(SandboxWire)),\n inference: z.object({\n vendors: z.array(z.string()),\n kinds: z.array(z.nativeEnum(InferenceCredentialKind)),\n delivery: z.nativeEnum(CredentialDelivery),\n }),\n // Absent: third-party.\n trust: z.nativeEnum(HarnessTrustClass).optional(),\n supports: z.object({\n observe: z.boolean(),\n resumeReplay: z.boolean(),\n fork: z.boolean(),\n // Renders _meta[\"final.ai\"].author itself; otherwise the channel prepends\n // the author's name to the text.\n authorMeta: z.boolean(),\n // Explicit false: native toolPolicy cannot be enforced by this adapter's public surface.\n nativeToolPolicy: z.boolean().optional(),\n // Defers and searches MCP tools itself (a harness-native tool search): the\n // host lists every exposed tool, ignoring connections' `tools.load`, and\n // adds no search of its own. Absent: the host applies `load` and serves search.\n deferredToolSearch: z.boolean().optional(),\n }),\n promptWhileRunning: z.nativeEnum(PromptWhileRunning).default(DEFAULT_PROMPT_WHILE_RUNNING),\n // Keeps the session, its running work and its open requests across a dropped\n // connection, buffers updates for replay, and re-raises the open requests\n // with the same JSON-RPC ids on the next session/resume. False:\n // open turns end `harness_state_lost` after a reconnect.\n sessionSurvivesDisconnect: z.boolean().default(DEFAULT_SESSION_SURVIVES_DISCONNECT),\n});\n\nexport type BaseToolDeclarationIface = z.infer<typeof baseToolDeclarationSchema>;\nexport type HarnessDescriptionIface = z.infer<typeof harnessDescriptionSchema>;\n\nexport const deliveredHarnessConfig = (args: {\n config: JsonValue;\n description: HarnessDescriptionIface;\n}): JsonValue => {\n if (args.description.userInstructionDelivery !== UserInstructionDelivery.System)\n return args.config;\n const config = jsonObjectSchema.safeParse(args.config);\n if (!config.success) return args.config;\n const fields = referencedSharedSchemas(args.description.configSchema);\n const field =\n Object.entries(fields).find(([, schema]) => schema === SCHEMA_IDS.instructions)?.[0] ??\n 'instructions';\n const instructions = config.data[field];\n if (!Array.isArray(instructions)) return args.config;\n return {\n ...config.data,\n [field]: instructions.map((value) => {\n const fragment = jsonObjectSchema.safeParse(value);\n return fragment.success && fragment.data['role'] === InstructionRole.User\n ? { ...fragment.data, role: InstructionRole.System }\n : value;\n }),\n };\n};\n\nexport const harnessSessionRefSchema = z.object({\n harness: providerRefSchema,\n // Opaque to the session service; the harness's own id for the session.\n harnessSessionRef: z.string().min(1),\n // Bumped whenever the harness loses state; a mismatch on resume means the\n // session service must re-seed with session/new.\n generation: z.number().int().nonnegative(),\n});\n\nexport type HarnessSessionRefIface = z.infer<typeof harnessSessionRefSchema>;\n\n// Route-scoped, short-lived grants: credential-routes.ts.\nexport {\n credentialRefreshRequestSchema,\n CredentialRoute,\n routeGrantSchema,\n type CredentialRefreshRequestIface,\n type RouteGrantIface,\n} from \"./credential-routes.mjs\";\n\nexport interface CredentialGrantIface {\n // Base URL of the broker routes (`<base>/model`, `<base>/refresh`, ...).\n brokerUrl: string;\n grants: RouteGrantIface[];\n // What the model grant resolved to, for harnesses that hand credentials over\n // at open (delivery 'at-open'). Null for per-request harnesses.\n atOpen: AtOpenModelCredentialIface | null;\n // How to renew this grant; null only when it carries no route grant.\n refresh: CredentialGrantRefreshIface | null;\n}\n\n// Renewal is pulled, never pushed. Per-request harnesses fetch\n// `<brokerUrl>/model` on every request. At-open harnesses (or their host)\n// POST `url` with `authorization: Bearer <token>` and a\n// `credentialRefreshRequestSchema` body before `expiresAt` and once after a\n// vendor 401; the answer is the grant's next generation (a\n// `credentialRefreshResultSchema` body with its own `refresh`), which replaces\n// this one. The broker resolves the policy again for it, so a disconnected\n// credential falls through; a revoked grant (every open revokes the previous\n// open's grants) or a closed harness session is refused (401).\nexport interface CredentialGrantRefreshIface {\n // `<brokerUrl>/refresh`.\n url: string;\n // One of this grant's own route grants (the model route's).\n token: string;\n harnessSessionId: string;\n // When `token` expires; a refresh after it is refused.\n expiresAt: string;\n}\n\nexport interface AtOpenModelCredentialIface {\n vendor: string;\n kind: InferenceCredentialKind;\n // Base URL and bearer for an OpenAI- or Anthropic-compatible endpoint (the\n // platform proxy, a corporate gateway) or the vendor itself.\n baseUrl: string | null;\n apiKey: string | null;\n // Subscription material for Final-managed harnesses only (Claude setup token,\n // Codex app-server chatgptAuthTokens); renewed through the grant's refresh route.\n subscription: { format: 'claude-setup-token' | 'chatgpt-auth-tokens'; value: string } | null;\n fingerprint: string;\n}\n\nexport const atOpenModelCredentialSchema = z.object({\n vendor: z.string(),\n kind: z.nativeEnum(InferenceCredentialKind),\n baseUrl: z.string().min(1).nullable(),\n apiKey: z.string().min(1).nullable(),\n subscription: z\n .object({\n format: z.union([z.literal('claude-setup-token'), z.literal('chatgpt-auth-tokens')]),\n value: z.string().min(1),\n })\n .nullable(),\n fingerprint: z.string(),\n}) satisfies z.ZodType<AtOpenModelCredentialIface>;\n\nexport const credentialGrantRefreshSchema = z.object({\n url: z.string().min(1),\n token: z.string().min(1),\n harnessSessionId: z.string().min(1),\n expiresAt: z.string(),\n}) satisfies z.ZodType<CredentialGrantRefreshIface>;\n\nexport const credentialGrantSchema = z.object({\n brokerUrl: z.string().min(1),\n grants: z.array(routeGrantSchema),\n atOpen: atOpenModelCredentialSchema.nullable(),\n refresh: credentialGrantRefreshSchema.nullable(),\n}) satisfies z.ZodType<CredentialGrantIface>;\n\n// An `http` MCP server entry the harness was handed in `session/new`\n// (`mcpServers`), with fresh headers. Same name and url; the harness swaps the\n// headers of the entry with that url.\nexport interface RenewedMcpServerIface {\n name: string;\n url: string;\n headers: { name: string; value: string }[];\n}\n\n// What a refresh answers: the grant's next generation, plus fresh copies of the\n// other short-lived material the harness was handed at open. Renewing the\n// `mcp` route renews the session's `http` MCP server headers; renewing\n// `sandbox` renews the bound sandbox targets' endpoint tokens.\nexport interface CredentialRefreshResultIface extends CredentialGrantIface {\n mcpServers: RenewedMcpServerIface[];\n sandboxes: Record<string, SandboxTargetEndpointIface>;\n}\n\nconst endpointTokenSchema = z.object({\n url: z.string().min(1),\n token: z.string(),\n expiresAt: z.string(),\n});\n\nexport const sandboxTargetEndpointSchema = z.object({\n target: z.string().min(1),\n bindingId: z.string().min(1),\n capabilities: z.array(z.string()),\n rpc: endpointTokenSchema.nullable(),\n mcp: endpointTokenSchema.nullable(),\n}) satisfies z.ZodType<SandboxTargetEndpointIface>;\n\nexport const renewedMcpServerSchema = z.object({\n name: z.string().min(1),\n url: z.string().min(1),\n headers: z.array(z.object({ name: z.string().min(1), value: z.string() })),\n}) satisfies z.ZodType<RenewedMcpServerIface>;\n\n// Absent renewals parse as none, so an answer without them still parses.\nexport const credentialRefreshResultSchema = credentialGrantSchema.extend({\n mcpServers: z.array(renewedMcpServerSchema).default([]),\n sandboxes: z.record(z.string(), sandboxTargetEndpointSchema).default({}),\n}) satisfies z.ZodType<CredentialRefreshResultIface, unknown>;\n\n// The refresh descriptor for a set of route grants: authenticated by the model\n// grant (else the first), due when that token expires.\nexport const grantRefreshFor = (args: {\n brokerUrl: string;\n harnessSessionId: string;\n grants: readonly RouteGrantIface[];\n}): CredentialGrantRefreshIface | null => {\n const grant =\n args.grants.find((candidate) => candidate.route === CredentialRoute.Model) ?? args.grants[0];\n if (grant == null) return null;\n return {\n url: `${args.brokerUrl.replace(/\\/+$/, '')}/refresh`,\n token: grant.token,\n harnessSessionId: args.harnessSessionId,\n expiresAt: grant.expiresAt,\n };\n};\n\nexport interface SecretReaderIface {\n get(name: string): Promise<string | null>;\n}\n\nexport interface TraceContextIface {\n traceparent: string | null;\n tracestate: string | null;\n}\n\n// A bound sandbox target as the session service hands it to a harness: a stable\n// per-binding address that starts the sandbox on the first tool call. Never a lease, a data-plane token for a live VM, or provider code.\nexport interface SandboxTargetEndpointIface {\n target: string;\n bindingId: string;\n capabilities: string[];\n rpc: { url: string; token: string; expiresAt: string } | null;\n mcp: { url: string; token: string; expiresAt: string } | null;\n}\n\nexport interface HarnessSessionContextIface {\n bindings?: HostedBindingsIface;\n sessionId: string;\n organizationId: string;\n definitionId: string;\n revisionId: string;\n // Public base URL of the session service for this session (MCP over HTTP,\n // sandbox endpoints, the broker).\n sessionServiceUrl: string;\n // The region of the session service serving the session and its sandbox\n // bindings, so a harness can run near it; null when unknown.\n sessionServiceRegion?: string | null;\n}\n\n// Lifecycle signals a harness implementation may report about the runtime\n// hosting a session (invocations, metering, traces). Informational: the\n// session service records them (agent.harness_invocations, Tinybird) and never\n// depends on them for correctness.\nexport interface HarnessObserverIface {\n // The runtime accepted the invocation request (its response began).\n invocationAccepted?(event: { invocationRef: string; at: string }): void;\n invocationStarted?(event: {\n invocationRef: string;\n at: string;\n bootMs: number | null;\n // The runtime's deployed version (Workers version id, commit), for rollouts.\n versionId?: string | null;\n commitSha?: string | null;\n }): void;\n invocationKeepalive?(event: { invocationRef: string; at: string; activeWork: number }): void;\n invocationEnded?(event: {\n invocationRef: string;\n at: string;\n reason: string;\n error: string | null;\n metering: Record<string, number>;\n }): void;\n trace?(event: { name: string; at: string; fields: Record<string, JsonValue> }): void;\n}\n\nexport interface OpenHarnessSessionArgsIface {\n session: HarnessSessionContextIface;\n // The session service's id for this harness session (agent.harness_sessions);\n // implementations key their runtime state and route grants by it.\n harnessSessionId: string;\n // Hosting may authorize the child endpoint to fork this source through ACP.\n forkSource?: { ref: HarnessSessionRefIface; acpSessionId: string };\n observer?: HarnessObserverIface;\n // The binding's config, validated against configSchema, dynamic slots resolved.\n config: JsonValue;\n manifest: ResolvedAgentManifestIface;\n // Already materialized ACP MCP server entries: authored tools, connections\n // (Final's MCP server among them), sandbox MCP projections where applicable.\n mcpServers: McpServer[];\n // Declared base capabilities with the target endpoint each is bound to.\n baseTools: Partial<Record<BaseCapability, SandboxTargetEndpointIface>>;\n sandboxes: Record<string, SandboxTargetEndpointIface>;\n credentials: CredentialGrantIface;\n secrets: SecretReaderIface;\n trace: TraceContextIface;\n}\n\nexport interface ResumeHarnessSessionArgsIface extends OpenHarnessSessionArgsIface {\n ref: HarnessSessionRefIface;\n // Last log seq the session service holds from this harness session; the\n // harness replays anything newer after session/resume.\n lastSeq: number;\n}\n\n// Resolved only in memory; refs/manifests retain secret names, never TLS keys.\nexport interface HarnessClientTlsIface {\n cert: string;\n key: string;\n ca?: string;\n}\n\nexport type HarnessEndpointIface =\n | {\n ref: HarnessSessionRefIface;\n transport: AcpTransport.Ws;\n url: string;\n headers: Record<string, string>;\n resolveHeaders?: () => Promise<Record<string, string>>;\n tls?: HarnessClientTlsIface;\n }\n | {\n ref: HarnessSessionRefIface;\n transport: AcpTransport.Http;\n url: string;\n headers: Record<string, string>;\n resolveHeaders?: () => Promise<Record<string, string>>;\n tls?: HarnessClientTlsIface;\n }\n // websocket-gateway relay channel (Final-managed harnesses).\n | { ref: HarnessSessionRefIface; transport: AcpTransport.Relay; channel: string; token: string }\n // Local development, CI and conformance only.\n | {\n ref: HarnessSessionRefIface;\n transport: AcpTransport.Stdio;\n command: string;\n args: string[];\n env: Record<string, string>;\n };\n\nexport interface HarnessHealthIface {\n ok: boolean;\n detail?: string;\n checkedAt: string;\n}\n\n// The binding a description is asked for: its config (validated against the\n// configSchema of the binding-free description) and the definition's secrets.\nexport interface DescribeHarnessArgsIface {\n config: JsonValue;\n secrets: SecretReaderIface;\n}\n\nexport interface HarnessIface {\n // Without a binding: what Build renders before one exists (configSchema,\n // declared capabilities). With one: the description of that binding, which a\n // harness reaching an arbitrary agent derives from the agent itself (e.g. its\n // `initialize`). Every harness implements both; most ignore the binding.\n describe(binding?: DescribeHarnessArgsIface): Promise<HarnessDescriptionIface>;\n open(args: OpenHarnessSessionArgsIface): Promise<HarnessEndpointIface>;\n resume(args: ResumeHarnessSessionArgsIface): Promise<HarnessEndpointIface>;\n park(ref: HarnessSessionRefIface): Promise<void>;\n // Graceful by default: the program's state is durable (resumable) before it\n // stops, bounded by the implementation's timeout, then forced. `force` skips\n // the wait; the session service passes it when the program did not settle\n // ACP `session/close` within its bound.\n close(ref: HarnessSessionRefIface, opts?: CloseHarnessSessionOptsIface): Promise<void>;\n health(\n ref: HarnessSessionRefIface,\n context?: DescribeHarnessArgsIface,\n ): Promise<HarnessHealthIface>;\n}\n\nexport interface CloseHarnessSessionOptsIface {\n force?: boolean;\n // As with health, retained refs can resolve current client TLS without storing keys in the ref.\n context?: DescribeHarnessArgsIface;\n}\n\n// What an installed harness module exports: the implementation plus an\n// authoring helper that builds the manifest binding.\nexport interface HarnessModuleIface<Config> {\n ref: ProviderRef;\n harness: HarnessIface;\n binding: (config: Config) => { harness: ProviderRef; config: JsonValue };\n}\n\n// Custom harnesses in a definition's bundle. Calling the result\n// with a config yields the manifest binding; the implementation is resolved\n// from the bundle by export name.\nexport interface DefinedHarnessBindingIface {\n harness: ProviderRef;\n config: JsonValue;\n definedHarness: true;\n}\n\nexport interface DefinedHarnessIface<Config> extends HarnessIface {\n (config: Config): DefinedHarnessBindingIface;\n}\n\nexport const defineHarness = <Config extends JsonValue = JsonValue>(\n implementation: HarnessIface,\n): DefinedHarnessIface<Config> => {\n // The export name is unknown here; the compiler rewrites `bundle:<pending>`\n // to the module path that exported this harness.\n const binding = (config: Config): DefinedHarnessBindingIface => ({\n harness: bundleRef(PENDING_BUNDLE_EXPORT),\n config,\n definedHarness: true,\n });\n return Object.assign(binding, implementation);\n};\n\nexport const describe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,EAAE,IAAI,CAAC,GAAG,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;AAC3E,CAAC;AAGM,MAAM,gCAAgC,sBAAsB,OAAO;AAAA,EACxE,YAAY,EAAE,MAAM,sBAAsB,EAAE,QAAQ,CAAC,CAAC;AAAA,EACtD,WAAW,EAAE,OAAO,EAAE,OAAO,GAAG,2BAA2B,EAAE,QAAQ,CAAC,CAAC;AACzE,CAAC;AAIM,MAAM,kBAAkB,CAAC,SAIU;AACxC,QAAM,QACJ,KAAK,OAAO,KAAK,CAAC,cAAc,UAAU,UAAU,gBAAgB,KAAK,KAAK,KAAK,OAAO,CAAC;AAC7F,MAAI,SAAS,KAAM,QAAO;AAC1B,SAAO;AAAA,IACL,KAAK,GAAG,KAAK,UAAU,QAAQ,QAAQ,EAAE,CAAC;AAAA,IAC1C,OAAO,MAAM;AAAA,IACb,kBAAkB,KAAK;AAAA,IACvB,WAAW,MAAM;AAAA,EACnB;AACF;AAyLO,MAAM,gBAAgB,CAC3B,mBACgC;AAGhC,QAAM,UAAU,CAAC,YAAgD;AAAA,IAC/D,SAAS,UAAU,qBAAqB;AAAA,IACxC;AAAA,IACA,gBAAgB;AAAA,EAClB;AACA,SAAO,OAAO,OAAO,SAAS,cAAc;AAC9C;AAEO,MAAM,uBAAuB,CAAC,gBACnC,YAAY;",
|
|
6
6
|
"names": ["AcpTransport", "McpTransportKind", "BaseToolProvision", "SandboxWire", "UserInstructionDelivery", "HarnessTrustClass", "PromptWhileRunning", "CredentialRoute", "routeGrantSchema"]
|
|
7
7
|
}
|