@finalai/agent-provider 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +23 -35
- package/dist/modules/channel.d.mts +53 -12
- package/dist/modules/channel.mjs +1 -0
- package/dist/modules/channel.mjs.map +2 -2
- package/dist/modules/credential-routes.d.mts +1 -3
- package/dist/modules/credential-routes.mjs +0 -2
- package/dist/modules/credential-routes.mjs.map +2 -2
- package/dist/modules/document.d.mts +0 -18
- package/dist/modules/document.mjs +1 -16
- package/dist/modules/document.mjs.map +3 -3
- package/dist/modules/index.d.mts +0 -1
- package/dist/modules/index.mjs +0 -1
- package/dist/modules/index.mjs.map +2 -2
- package/dist/modules/local-channel-context.d.mts +1 -1
- package/dist/modules/local-channel-context.mjs +1 -1
- package/dist/modules/local-channel-context.mjs.map +2 -2
- package/dist/modules/sandbox/client.mjs +0 -3
- package/dist/modules/sandbox/client.mjs.map +2 -2
- package/dist/modules/sandbox/execution-guard.d.mts +0 -1
- package/dist/modules/sandbox/execution-guard.mjs +0 -9
- package/dist/modules/sandbox/execution-guard.mjs.map +2 -2
- package/dist/modules/sandbox/grant.d.mts +0 -1
- package/dist/modules/sandbox/grant.mjs +0 -4
- package/dist/modules/sandbox/grant.mjs.map +2 -2
- package/dist/modules/sandbox/index.d.mts +0 -2
- package/dist/modules/sandbox/index.mjs +1 -10
- package/dist/modules/sandbox/index.mjs.map +2 -2
- package/dist/modules/sandbox/mcp-hosted.d.mts +0 -1
- package/dist/modules/sandbox/mcp-hosted.mjs +1 -8
- package/dist/modules/sandbox/mcp-hosted.mjs.map +2 -2
- package/dist/modules/sandbox/mcp.d.mts +2 -4
- package/dist/modules/sandbox/mcp.mjs +6 -52
- package/dist/modules/sandbox/mcp.mjs.map +2 -2
- package/dist/modules/sandbox/remote/body.d.mts +1 -0
- package/dist/modules/sandbox/remote/body.mjs +27 -0
- package/dist/modules/sandbox/remote/body.mjs.map +7 -0
- package/dist/modules/sandbox/remote/serve.mjs +3 -2
- package/dist/modules/sandbox/remote/serve.mjs.map +2 -2
- package/dist/modules/sandbox/server.mjs +0 -14
- package/dist/modules/sandbox/server.mjs.map +2 -2
- package/dist/modules/sandbox/setup/apply.d.mts +1 -2
- package/dist/modules/sandbox/setup/apply.mjs +6 -20
- package/dist/modules/sandbox/setup/apply.mjs.map +2 -2
- package/dist/modules/sandbox/setup/describe.mjs +1 -1
- package/dist/modules/sandbox/setup/describe.mjs.map +1 -1
- package/dist/modules/sandbox/setup/schema.d.mts +2 -1
- package/dist/modules/sandbox/tool-policy.mjs +1 -19
- package/dist/modules/sandbox/tool-policy.mjs.map +2 -2
- package/dist/modules/sandbox/types.d.mts +2 -16
- package/dist/modules/sandbox/types.mjs +4 -13
- package/dist/modules/sandbox/types.mjs.map +3 -3
- package/dist/modules/sandbox/wire.d.mts +0 -17
- package/dist/modules/sandbox/wire.mjs +0 -12
- package/dist/modules/sandbox/wire.mjs.map +2 -2
- package/package.json +3 -8
- package/dist/modules/room-surface.d.mts +0 -350
- package/dist/modules/room-surface.mjs +0 -156
- package/dist/modules/room-surface.mjs.map +0 -7
- package/dist/modules/sandbox/networking.d.mts +0 -73
- package/dist/modules/sandbox/networking.mjs +0 -157
- package/dist/modules/sandbox/networking.mjs.map +0 -7
package/README.md
CHANGED
|
@@ -64,24 +64,6 @@ so a resumed sandbox redoes only what its attach lost, and passes secrets to
|
|
|
64
64
|
process environments only. `describeSandbox` reports the real checkout paths,
|
|
65
65
|
service URLs and commands.
|
|
66
66
|
|
|
67
|
-
Sandbox networking is a composable extension. `SandboxNetworkingExtensionIface`
|
|
68
|
-
owns policy persistence, controller setup, readiness and suspension; the sandbox
|
|
69
|
-
provider supplies its Linux executor and provider firewall/lifecycle operations.
|
|
70
|
-
`attachSandboxNetworking` installs an extension on a handle and defers workspace
|
|
71
|
-
setup until admission succeeds. `withSandboxNetworking` supports providers that
|
|
72
|
-
need to initialize the controller earlier. Both preserve host/provider execution
|
|
73
|
-
policies and distinguish runtime detach from physical stop/delete. Reads and
|
|
74
|
-
passive attachments never recover networking. A running handle can remain blocked
|
|
75
|
-
for execution while its networking configuration is repaired.
|
|
76
|
-
|
|
77
|
-
Validate extension workspace identities before changing provider policy. Save the
|
|
78
|
-
original policy before fencing or booting, initialize the controller in the same
|
|
79
|
-
namespace used by commands, then restore the outer policy through `afterGuard`.
|
|
80
|
-
The extension must authorize every ongoing operation, including cached MCP access;
|
|
81
|
-
a one-time startup check is insufficient. Custom `attach` implementations own
|
|
82
|
-
equivalent admission, deferred setup and failure cleanup. Namespace-only adapters
|
|
83
|
-
must disclose the startup traffic window when their provider cannot fence boot.
|
|
84
|
-
|
|
85
67
|
Hosts pass `credentials` (`SandboxCredentialsIface`) on sandbox contexts:
|
|
86
68
|
`secret({ secretRef })`, resolved in the sandbox's project. Providers that need a
|
|
87
69
|
third-party key take `credential: { secretRef }` (`sandboxCredentialRefSchema`) in
|
|
@@ -127,9 +109,9 @@ Admission covers commands, process stdin, file mutations, network-policy updates
|
|
|
127
109
|
screen acquisition and cached MCP channels. The callback receives the operation
|
|
128
110
|
and a `background` flag for protocol maintenance; the flag is not an authorization
|
|
129
111
|
grant. Reads and lifecycle cleanup remain available when execution is refused.
|
|
130
|
-
Hosts must explicitly authorize SetNetworkPolicy
|
|
131
|
-
|
|
132
|
-
|
|
112
|
+
Hosts must explicitly authorize SetNetworkPolicy operations to allow network repair
|
|
113
|
+
while other execution is refused. Policies choose authorization. Already-running
|
|
114
|
+
processes and port grants need separate controls.
|
|
133
115
|
|
|
134
116
|
Keep the raw session internal for trusted setup/controller work. Low-level hosts
|
|
135
117
|
that construct handles without `defineSandboxProvider` use `createSandboxHandle`.
|
|
@@ -144,33 +126,37 @@ URL-backed MCP endpoints served through a host-owned transport; the provider's f
|
|
|
144
126
|
retains ownership of its endpoints, with the host transport as a fallback. Pass the same transport to the MCP projection.
|
|
145
127
|
|
|
146
128
|
Pass the complete keys from `sandboxMcpToolPolicyKeys` to `resolveSandboxToolPolicy`.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
are refused. The host owns approval policy, including any explicit preauthorization.
|
|
129
|
+
Hosted tools that share a built-in name keep their ordinary tool policy and cannot
|
|
130
|
+
borrow a built-in Allow. A grant without `shell` cannot change network policy,
|
|
131
|
+
including with lifecycle authority. The host owns approval policy, including any
|
|
132
|
+
explicit preauthorization.
|
|
152
133
|
|
|
153
134
|
Policies turn URL-backed MCP into checked message channels. Handle RPC servers
|
|
154
135
|
serving policy-protected sessions must enable `mcpChannels`; clients must support
|
|
155
136
|
the channel protocol, or use the MCP projection. Legacy RPC clients do not get
|
|
156
137
|
unguarded URL endpoints; attempts receive an explicit negotiation error.
|
|
157
138
|
|
|
158
|
-
Confined reads require a trusted system `python3` in `/usr/bin` or `/usr/local/bin`. Images with only conda, pyenv or nix Python must provide that prerequisite. Hosts supplying `authorizeOperation` own the complete RPC authorization decision
|
|
139
|
+
Confined reads require a trusted system `python3` in `/usr/bin` or `/usr/local/bin`. Images with only conda, pyenv or nix Python must provide that prerequisite. Hosts supplying `authorizeOperation` own the complete RPC authorization decision; audit-only hooks must delegate to an authorization policy.
|
|
159
140
|
|
|
160
141
|
Acquiring a hosted MCP endpoint or channel is foreground work: it may start a server and perform deferred workspace setup. Catalog polling on an acquired channel is background maintenance and does not start setup. Abortable operations pass their signal to admission; cancellation rejects pending admission and prevents dispatch even if a host policy settles later.
|
|
161
142
|
|
|
162
143
|
## Channels
|
|
163
144
|
|
|
164
145
|
`ChannelDefinitionIface<Config, Inbound, State>` describes a provider namespace,
|
|
165
|
-
|
|
166
|
-
receive function, and typed semantic event handlers. Channels resolve people and
|
|
146
|
+
the provider application credentials it requires, identity proof, place kinds,
|
|
147
|
+
routes/listeners, receive function, and typed semantic event handlers. Channels resolve people and
|
|
167
148
|
places through `ChannelReceiveContextIface`; they do not supply Final user,
|
|
168
149
|
conversation or agent IDs. A host validates every opaque person/conversation
|
|
169
150
|
handle against its binding and invocation.
|
|
170
151
|
|
|
171
152
|
`post` records a linked person's message. `input` without `principal` is a
|
|
172
153
|
nonhuman event; `input` with a principal represents an unlinked person and requires
|
|
173
|
-
an explicitly configured `anyone` audience.
|
|
154
|
+
an explicitly configured `anyone` audience. `input`'s `actingAs` names the linked
|
|
155
|
+
person the agent's turn acts for; an input acting for nobody waits for the running
|
|
156
|
+
turn. `replyExpected: false` lets the agent stay silent when it has nothing to say.
|
|
157
|
+
An unlinked person resolves with the install's `linkUrl` and an unconnected place
|
|
158
|
+
with its `connectUrl` only when the installer provided those pages; otherwise the
|
|
159
|
+
channel explains linking in its own words. A shared place cannot target Home.
|
|
174
160
|
`attach` records content without dispatching a turn. It supports recordings and
|
|
175
161
|
other channel-produced attachments. Explicit `anyone`/`group` defaults let `places.resolve`
|
|
176
162
|
create a Shared chat for a new anonymous call. Input idempotency keys are scoped to
|
|
@@ -185,10 +171,13 @@ Semantic events cover messages, tools, plans, decisions and turn completion, plu
|
|
|
185
171
|
origin-bearing edits/removals/reactions. Completion events include the reply and
|
|
186
172
|
are delivered at least once; channels persist provider reply IDs in `store` for
|
|
187
173
|
deduplication. `replies: all` enables `message.posted` mirroring. Raw ACP updates
|
|
188
|
-
belong to harnesses
|
|
174
|
+
belong to harnesses.
|
|
175
|
+
|
|
176
|
+
`observe` streams one turn's events, from its start, and accepts a cancellation signal. Use `events` to hear a conversation over time. HTTP and binary WebSocket routes receive the same capabilities; listeners additionally receive an abort signal. Speech providers and audio processing belong to application code, using its declared credentials and ordinary HTTP/socket requests.
|
|
177
|
+
|
|
178
|
+
A channel declares the provider application it needs in `require.app`: an OAuth client and named secret slots (a signing secret, an app-level token). A channel app satisfies it, either the installer's own or one the channel's publisher attached to the publication; an install whose app cannot meet the declaration is refused. App credentials stay with the host in every execution mode. `credentials.client()` exposes only the public client ID; `verify({ secret })` checks a signed payload with a slot's key without returning it. `exchange()` returns an opaque, short-lived OAuth credential handle. Select that handle, a provider tenant's installed token (`{ kind: 'app', tenant }`) or a secret slot (`{ kind: 'secret', slot }`) with `credentials.fetch`'s `credential` option; requests default to no credential. `credentials.connect()` supports host-injected credentials in outgoing JSON socket frames. Hosts enforce the same destination and grant checks for all these operations. `secret(slot)` reads only slots the channel declares. Sockets accept bounded caller-owned headers for provider handshakes. Exchange handles are invocation-scoped and expire; they do not provide durable person-token storage or automatic refresh. An application's authorization callback must use provider APIs that can establish the current person's access.
|
|
189
179
|
|
|
190
|
-
|
|
191
|
-
Installed app credentials stay with the host in every execution mode. `credentials.client()` exposes only the public client ID; `verify()` checks signed payloads without returning the signing key. `exchange()` returns an opaque, short-lived OAuth credential handle. Select that handle or the installed app with `credentials.fetch`'s `credential` option; requests default to no credential. `credentials.connect()` supports host-injected credentials in outgoing JSON socket frames. Hosts enforce the same destination and grant checks for all these operations. Only explicitly declared project secrets can be read through `secret(name)`. Sockets accept bounded caller-owned headers for provider handshakes. Installed app credentials remain opaque and can be injected into JSON frames. Exchange handles are invocation-scoped and expire; they do not provide durable person-token storage or automatic refresh. An application's authorization callback must use provider APIs that can establish the current person's access.
|
|
180
|
+
A provider tenant (a workspace, a server) installs the app through the channel's own code. `tenants.installPath` names a GET route that receives a single-use `ticket`; it calls `credentials.redirect({ path, ticket })`, and the redirect route calls `credentials.exchange({ ..., store: { tenant } })`, which stores the token as that tenant's install (`store: { tenantPath }` reads the tenant from the token response when the provider names it only there). A tenant belongs to one install of an app at a time: a later install takes it over. Routes marked `shared: true` are also served at the app's shared ingress URL, one URL per app registered with the provider once. The publication the app routes its ingress through declares `ingress.tenantOf`, which verifies each request with app-only credentials and returns the tenant, a direct `respond` for app-level handshakes, or null to reject it; the host then runs the shared route of the binding that holds that tenant.
|
|
192
181
|
|
|
193
182
|
`binding.url` is the host's canonical binding base URL for routes. Provider settings must not hold it when an application serves more than one binding. For OAuth, declare the callback route with `redirect: true` and call `credentials.redirect({ path })`: the returned `url` is the same for every binding, so an application registers it once, and `state` returns the person to this binding. Send both unchanged, and use the same `url` in the token exchange. A `redirect` route must be a GET and is reachable only through that URL. A channel is published as one self-contained module; naming an installed implementation does not grant additional authority. `resources.resolve` maps an application URL to a canonical provider place; the required companion `resources.authorize` checks the linked person's current provider access. Hosts repeat that authorization for later observation access. `places.follow` and `unfollow` manage observation under a linked person's authority, while `places.observers` enumerates authorized deliveries.
|
|
194
183
|
|
|
@@ -199,8 +188,7 @@ the tenant applies this lifecycle change to the binding's namespace. A socket ha
|
|
|
199
188
|
cleanup grace after disconnect; every other operation is revoked immediately, and all
|
|
200
189
|
capabilities end when the handler returns. Attachment authorization still applies.
|
|
201
190
|
|
|
202
|
-
A channel's handlers always run on Final's serverless runtime.
|
|
203
|
-
the Final chat itself is typed separately in `@finalai/agent-provider/room-surface`.
|
|
191
|
+
A channel's handlers always run on Final's serverless runtime.
|
|
204
192
|
|
|
205
193
|
## Durable processes
|
|
206
194
|
|
|
@@ -34,10 +34,10 @@ export type PersonResolution = {
|
|
|
34
34
|
displayName: string;
|
|
35
35
|
} | {
|
|
36
36
|
kind: 'unlinked';
|
|
37
|
-
linkUrl
|
|
37
|
+
linkUrl?: string;
|
|
38
38
|
} | {
|
|
39
39
|
kind: 'blocked';
|
|
40
|
-
reason: 'not-
|
|
40
|
+
reason: 'not-a-member' | 'suspended';
|
|
41
41
|
};
|
|
42
42
|
export declare enum ChannelReplies {
|
|
43
43
|
Origin = "origin",
|
|
@@ -68,7 +68,7 @@ export type PlaceResolution = {
|
|
|
68
68
|
policy: PlacePolicy;
|
|
69
69
|
} | {
|
|
70
70
|
kind: 'unconnected';
|
|
71
|
-
connectUrl
|
|
71
|
+
connectUrl?: string;
|
|
72
72
|
defaults: PlaceDefaultsIface | null;
|
|
73
73
|
};
|
|
74
74
|
export interface Refusal {
|
|
@@ -108,6 +108,7 @@ export declare const channelReceiveResultSchema: z.ZodUnion<readonly [z.ZodObjec
|
|
|
108
108
|
}, z.core.$strip>]>;
|
|
109
109
|
export declare enum ChannelCredentialKind {
|
|
110
110
|
App = "app",
|
|
111
|
+
Secret = "secret",
|
|
111
112
|
OAuth = "oauth",
|
|
112
113
|
None = "none"
|
|
113
114
|
}
|
|
@@ -115,7 +116,11 @@ export declare const channelCredentialHandleSchema: z.core.$ZodBranded<z.ZodStri
|
|
|
115
116
|
export type ChannelCredentialHandle = z.infer<typeof channelCredentialHandleSchema>;
|
|
116
117
|
export type ChannelCredentialRef = {
|
|
117
118
|
kind: ChannelCredentialKind.App;
|
|
118
|
-
tenant
|
|
119
|
+
tenant: string;
|
|
120
|
+
} | {
|
|
121
|
+
kind: ChannelCredentialKind.Secret;
|
|
122
|
+
slot: string;
|
|
123
|
+
scheme?: string;
|
|
119
124
|
} | {
|
|
120
125
|
kind: ChannelCredentialKind.OAuth;
|
|
121
126
|
handle: ChannelCredentialHandle;
|
|
@@ -140,6 +145,7 @@ export interface ChannelCredentialRequestInitIface extends RequestInit {
|
|
|
140
145
|
credential?: ChannelCredentialRef;
|
|
141
146
|
}
|
|
142
147
|
export interface ChannelVerifyOptionsIface {
|
|
148
|
+
secret: string;
|
|
143
149
|
algorithm: ChannelSigningAlgorithm;
|
|
144
150
|
encoding: ChannelSignatureEncoding;
|
|
145
151
|
data: string;
|
|
@@ -151,9 +157,15 @@ export interface ChannelOAuthExchangeOptionsIface {
|
|
|
151
157
|
authentication: ChannelOAuthClientAuthentication;
|
|
152
158
|
clientId?: string;
|
|
153
159
|
signal?: AbortSignal;
|
|
160
|
+
store?: {
|
|
161
|
+
tenant: string;
|
|
162
|
+
} | {
|
|
163
|
+
tenantPath: string[];
|
|
164
|
+
};
|
|
154
165
|
}
|
|
155
166
|
export interface ChannelRedirectOptionsIface {
|
|
156
167
|
path: string;
|
|
168
|
+
ticket?: string;
|
|
157
169
|
}
|
|
158
170
|
export interface ChannelRedirectIface {
|
|
159
171
|
url: string;
|
|
@@ -184,7 +196,7 @@ export interface ChannelCredentialsIface {
|
|
|
184
196
|
redirect(args: ChannelRedirectOptionsIface): Promise<ChannelRedirectIface>;
|
|
185
197
|
fetch(input: RequestInfo | URL, init?: ChannelCredentialRequestInitIface): Promise<Response>;
|
|
186
198
|
connect(args: ChannelCredentialConnectOptionsIface): Promise<ChannelCredentialSocketIface>;
|
|
187
|
-
secret(
|
|
199
|
+
secret(slot: string): Promise<string | null>;
|
|
188
200
|
}
|
|
189
201
|
export interface ChannelPostArgsIface {
|
|
190
202
|
from: PersonHandle;
|
|
@@ -202,6 +214,8 @@ export interface ChannelConversationIface {
|
|
|
202
214
|
input(args: {
|
|
203
215
|
label: string;
|
|
204
216
|
principal?: PrincipalRef;
|
|
217
|
+
actingAs?: PersonHandle;
|
|
218
|
+
replyExpected?: boolean;
|
|
205
219
|
content: ContentBlock[];
|
|
206
220
|
context?: string[];
|
|
207
221
|
origin: OriginIface;
|
|
@@ -260,10 +274,7 @@ export interface ChannelReceiveContextIface<Config = JsonObject> {
|
|
|
260
274
|
binding: {
|
|
261
275
|
id: string;
|
|
262
276
|
url: string;
|
|
263
|
-
|
|
264
|
-
kind: 'install';
|
|
265
|
-
installId: string;
|
|
266
|
-
};
|
|
277
|
+
projectId: string;
|
|
267
278
|
};
|
|
268
279
|
config: Config;
|
|
269
280
|
credentials: ChannelCredentialsIface;
|
|
@@ -364,6 +375,7 @@ export interface HttpChannelRouteDefinitionIface<Config = JsonObject> {
|
|
|
364
375
|
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
365
376
|
path: string;
|
|
366
377
|
redirect?: boolean;
|
|
378
|
+
shared?: boolean;
|
|
367
379
|
handler(args: ChannelRouteContextIface<Config>): Promise<Response>;
|
|
368
380
|
}
|
|
369
381
|
export interface WebSocketChannelRouteDefinitionIface<Config = JsonObject> {
|
|
@@ -378,14 +390,43 @@ export type ChannelEventHandlersIface<Config, State> = {
|
|
|
378
390
|
[Kind in keyof ChannelSemanticDataByKindIface]?: (data: ChannelSemanticDataByKindIface[Kind], ctx: ChannelEventContextIface<Config, State>) => Promise<void>;
|
|
379
391
|
};
|
|
380
392
|
export type ChannelEventKind = keyof ChannelSemanticDataByKindIface;
|
|
393
|
+
export interface ChannelAppRequirementIface {
|
|
394
|
+
description: string;
|
|
395
|
+
oauthClient?: {
|
|
396
|
+
description: string;
|
|
397
|
+
optional?: boolean;
|
|
398
|
+
};
|
|
399
|
+
secrets?: Record<string, {
|
|
400
|
+
description: string;
|
|
401
|
+
optional?: boolean;
|
|
402
|
+
}>;
|
|
403
|
+
}
|
|
404
|
+
export interface ChannelRequireIface {
|
|
405
|
+
app?: ChannelAppRequirementIface;
|
|
406
|
+
}
|
|
407
|
+
export interface ChannelIngressContextIface {
|
|
408
|
+
app: {
|
|
409
|
+
id: string;
|
|
410
|
+
};
|
|
411
|
+
credentials: Pick<ChannelCredentialsIface, 'verify' | 'secret' | 'client'>;
|
|
412
|
+
log(message: string, details?: JsonObject): void;
|
|
413
|
+
}
|
|
414
|
+
export interface ChannelIngressIface {
|
|
415
|
+
tenantOf(request: Request, ctx: ChannelIngressContextIface): Promise<{
|
|
416
|
+
tenant: string;
|
|
417
|
+
} | {
|
|
418
|
+
respond: Response;
|
|
419
|
+
} | null>;
|
|
420
|
+
}
|
|
381
421
|
export interface ChannelDefinitionIface<Config = JsonObject, Inbound = JsonValue, State = JsonValue> {
|
|
382
422
|
name: string;
|
|
383
423
|
config?: Config;
|
|
384
424
|
configure?(config: Config): ChannelDefinitionIface<Config, Inbound, State>;
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
425
|
+
require?: ChannelRequireIface;
|
|
426
|
+
tenants?: {
|
|
427
|
+
installPath: string;
|
|
388
428
|
};
|
|
429
|
+
ingress?: ChannelIngressIface;
|
|
389
430
|
identity: {
|
|
390
431
|
kind: 'redirect';
|
|
391
432
|
start(args: {
|
package/dist/modules/channel.mjs
CHANGED
|
@@ -54,6 +54,7 @@ const channelReceiveResultSchema = z.union([
|
|
|
54
54
|
]);
|
|
55
55
|
var ChannelCredentialKind = /* @__PURE__ */ ((ChannelCredentialKind2) => {
|
|
56
56
|
ChannelCredentialKind2["App"] = "app";
|
|
57
|
+
ChannelCredentialKind2["Secret"] = "secret";
|
|
57
58
|
ChannelCredentialKind2["OAuth"] = "oauth";
|
|
58
59
|
ChannelCredentialKind2["None"] = "none";
|
|
59
60
|
return ChannelCredentialKind2;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/channel.ts"],
|
|
4
|
-
"sourcesContent": ["import type { ContentBlock } from '@agentclientprotocol/sdk/experimental/v2';\nimport * as z from 'zod';\nimport { jsonObjectSchema, type JsonObject, type JsonValue } from \"./json.mjs\";\nimport type { ChannelSemanticDataByKindIface } from \"./semantic-events.mjs\";\n\n// Handles carry no authority until the platform validates their binding and invocation signature.\nexport const personHandleSchema = z.string().min(1).brand<'ChannelPerson'>();\nexport const conversationHandleSchema = z.string().min(1).brand<'ChannelConversation'>();\nexport type PersonHandle = z.infer<typeof personHandleSchema>;\nexport type ConversationHandle = z.infer<typeof conversationHandleSchema>;\n\nexport const principalRefSchema = z.object({\n id: z.string().min(1),\n tenant: z.string().min(1).optional(),\n displayName: z.string().optional(),\n});\nexport type PrincipalRef = z.infer<typeof principalRefSchema>;\nexport interface PlaceRef {\n kind: string;\n id: string;\n tenant?: string;\n parent?: PlaceRef;\n title?: string;\n}\nexport const placeRefSchema: z.ZodType<PlaceRef> = z.lazy(() =>\n z.object({\n kind: z.string().min(1),\n id: z.string().min(1),\n tenant: z.string().min(1).optional(),\n parent: placeRefSchema.optional(),\n title: z.string().optional(),\n }),\n);\nexport interface OriginIface {\n place: PlaceRef;\n ref?: JsonObject;\n}\nexport const originSchema = z.object({ place: placeRefSchema, ref: jsonObjectSchema.optional() });\n\nexport type PersonResolution =\n | { kind: 'member'; person: PersonHandle; displayName: string }\n | { kind: 'unlinked'; linkUrl: string }\n | { kind: 'blocked'; reason: 'not-in-organization' | 'suspended' };\nexport enum ChannelReplies {\n Origin = 'origin',\n All = 'all',\n}\nexport enum ChannelAudience {\n Members = 'members',\n Anyone = 'anyone',\n}\nexport enum ChannelCreate {\n DirectWithAgent = 'direct-with-agent',\n Group = 'group',\n}\nexport const placePolicySchema = z.object({\n replies: z.nativeEnum(ChannelReplies),\n audience: z.nativeEnum(ChannelAudience),\n});\nexport interface PlacePolicy {\n replies: ChannelReplies | `${ChannelReplies}`;\n audience: ChannelAudience | `${ChannelAudience}`;\n}\nexport interface PlaceDefaultsIface extends PlacePolicy {\n create: ChannelCreate | `${ChannelCreate}`;\n}\nexport type PlaceResolution =\n | { kind: 'connected'; conversation: ConversationHandle; policy: PlacePolicy }\n | { kind: 'unconnected'; connectUrl: string; defaults: PlaceDefaultsIface | null };\nexport interface Refusal {\n refused: 'unlinked' | 'no-access' | 'unconnected' | 'not-audience';\n linkUrl?: string;\n connectUrl?: string;\n message: string;\n}\nexport type ChannelReceiveResult =\n | { accepted: true }\n | { accepted: false; refusal: Refusal }\n | { ignored: true; reason: string };\nexport const refusalSchema = z.object({\n refused: z.union([\n z.literal('unlinked'),\n z.literal('no-access'),\n z.literal('unconnected'),\n z.literal('not-audience'),\n ]),\n linkUrl: z.string().optional(),\n connectUrl: z.string().optional(),\n message: z.string(),\n});\nexport const channelReceiveResultSchema = z.union([\n z.object({ accepted: z.literal(true) }),\n z.object({ accepted: z.literal(false), refusal: refusalSchema }),\n z.object({ ignored: z.literal(true), reason: z.string() }),\n]);\nexport enum ChannelCredentialKind {\n App = 'app',\n OAuth = 'oauth',\n None = 'none',\n}\nexport const channelCredentialHandleSchema = z.string().min(1).brand<'ChannelCredential'>();\nexport type ChannelCredentialHandle = z.infer<typeof channelCredentialHandleSchema>;\nexport type ChannelCredentialRef =\n | { kind: ChannelCredentialKind.App; tenant?: string }\n | { kind: ChannelCredentialKind.OAuth; handle: ChannelCredentialHandle }\n | { kind: ChannelCredentialKind.None };\nexport enum ChannelSigningAlgorithm {\n HmacSha256 = 'hmac-sha256',\n HmacSha1 = 'hmac-sha1',\n Ed25519 = 'ed25519',\n}\nexport enum ChannelSignatureEncoding {\n Hex = 'hex',\n Base64 = 'base64',\n}\nexport enum ChannelOAuthClientAuthentication {\n Body = 'body',\n Basic = 'basic',\n None = 'none',\n}\nexport interface ChannelCredentialRequestInitIface extends RequestInit {\n credential?: ChannelCredentialRef;\n}\nexport interface ChannelVerifyOptionsIface {\n algorithm: ChannelSigningAlgorithm;\n encoding: ChannelSignatureEncoding;\n data: string;\n signature: string;\n}\nexport interface ChannelOAuthExchangeOptionsIface {\n url: string;\n parameters: Record<string, string>;\n authentication: ChannelOAuthClientAuthentication;\n clientId?: string;\n signal?: AbortSignal;\n}\nexport interface ChannelRedirectOptionsIface {\n // A GET route of this channel declared with `redirect: true`.\n path: string;\n}\nexport interface ChannelRedirectIface {\n url: string;\n state: string;\n}\nexport interface ChannelCredentialConnectOptionsIface {\n url: string;\n signal?: AbortSignal;\n}\nexport interface ChannelCredentialInjectionIface {\n path: string[];\n credential: ChannelCredentialRef;\n}\nexport interface ChannelCredentialSocketIface {\n messages: AsyncIterable<string | Uint8Array>;\n send(\n data: string | Uint8Array,\n options?: { inject?: ChannelCredentialInjectionIface[] },\n ): Promise<void>;\n close(code?: number, reason?: string): Promise<void>;\n closeCode(): number | null;\n}\nexport interface ChannelCredentialsIface {\n // Installed credentials stay with the host in every execution mode.\n client(): Promise<{ clientId: string }>;\n verify(args: ChannelVerifyOptionsIface): Promise<boolean>;\n exchange(args: ChannelOAuthExchangeOptionsIface): Promise<ChannelCredentialHandle>;\n // Send `url` as the OAuth redirect URI and `state` unchanged. `url` is the same for every\n // binding, so a provider application registers it once; `state` returns to this binding.\n redirect(args: ChannelRedirectOptionsIface): Promise<ChannelRedirectIface>;\n // Requests without an explicit credential are unauthenticated.\n fetch(input: RequestInfo | URL, init?: ChannelCredentialRequestInitIface): Promise<Response>;\n connect(args: ChannelCredentialConnectOptionsIface): Promise<ChannelCredentialSocketIface>;\n // Only explicitly declared project secrets can be read by authored code.\n secret(name: string): Promise<string | null>;\n}\nexport interface ChannelPostArgsIface {\n from: PersonHandle;\n content: ContentBlock[];\n context?: string[];\n origin: OriginIface;\n idempotencyKey: string;\n waitForAcceptance?: boolean;\n}\nexport interface ChannelConversationIface {\n post(args: ChannelPostArgsIface): Promise<{ messageId: string; turnId?: string } | Refusal>;\n input(args: {\n label: string;\n principal?: PrincipalRef;\n content: ContentBlock[];\n context?: string[];\n origin: OriginIface;\n idempotencyKey: string;\n waitForAcceptance?: boolean;\n }): Promise<{ inputId: string; turnId?: string } | Refusal>;\n attach(args: {\n origin: OriginIface;\n content: ContentBlock[];\n label: string;\n idempotencyKey: string;\n from?: PersonHandle;\n }): Promise<{ messageId: string } | Refusal>;\n edit(args: {\n externalKey: string;\n by: PersonHandle;\n content: ContentBlock[];\n }): Promise<{ messageId: string } | Refusal>;\n remove(args: { externalKey: string; by: PersonHandle }): Promise<{ removed: boolean } | Refusal>;\n react(args: {\n target: { externalKey: string } | { replyOf: { externalKey: string; turnId: string } };\n emoji: string;\n by: PersonHandle;\n op: 'add' | 'remove';\n }): Promise<{ ok: true } | Refusal>;\n}\nexport type SemanticEvent = {\n [Kind in keyof ChannelSemanticDataByKindIface]: {\n type: Kind;\n data: ChannelSemanticDataByKindIface[Kind];\n seq: number;\n };\n}[keyof ChannelSemanticDataByKindIface];\nexport interface ChannelReceiveContextIface<Config = JsonObject> {\n binding: {\n id: string;\n url: string;\n owner: { kind: 'install'; installId: string };\n };\n config: Config;\n credentials: ChannelCredentialsIface;\n people: {\n resolve(principal: PrincipalRef): Promise<PersonResolution>;\n identify(person: PersonHandle): Promise<PrincipalRef | null>;\n // Tenant-wide uninstall/revocation also disconnects that tenant's places.\n revoke(args: {\n principal?: PrincipalRef;\n tenant?: string;\n reason: 'deactivated' | 'uninstalled' | 'provider-revoked';\n }): Promise<void>;\n confirm(args: { ticket: string; principal: PrincipalRef }): Promise<{ linked: true } | Refusal>;\n };\n places: {\n // Explicit anyone/group defaults may create a Shared chat while resolving a new place.\n resolve(place: PlaceRef): Promise<PlaceResolution>;\n observers(place: PlaceRef): Promise<ConversationHandle[]>;\n connect(\n place: PlaceRef,\n to: {\n by: PersonHandle;\n conversation?: ConversationHandle;\n create?: ChannelCreate | `${ChannelCreate}`;\n },\n ): Promise<ConversationHandle>;\n disconnect(place: PlaceRef, by: PersonHandle): Promise<void>;\n follow(\n place: PlaceRef,\n args: { by: PersonHandle; conversation: ConversationHandle; ttlSeconds?: number },\n ): Promise<void>;\n unfollow(\n place: PlaceRef,\n args: { by: PersonHandle; conversation: ConversationHandle },\n ): Promise<void>;\n };\n conversation(handle: ConversationHandle): ChannelConversationIface;\n observe(\n handle: ConversationHandle,\n args: { turnId: string; signal?: AbortSignal },\n ): AsyncIterable<SemanticEvent>;\n decisions: {\n resolve(args: {\n decisionId: string;\n outcome: JsonValue;\n by: PersonHandle;\n }): Promise<{ resolved: boolean } | Refusal>;\n };\n turns: {\n cancel(args: {\n conversation: ConversationHandle;\n by?: PersonHandle;\n turnId?: string;\n }): Promise<{ accepted: boolean } | Refusal>;\n };\n store: {\n get(key: string): Promise<JsonValue | null>;\n set(key: string, value: JsonValue | null, options?: { ttlSeconds?: number }): Promise<void>;\n };\n log(message: string, details?: JsonObject): void;\n}\nexport interface ChannelSocketIface {\n readonly signal: AbortSignal;\n readonly messages: AsyncIterable<string | Uint8Array>;\n // Authenticate the request before accepting. The selected protocol must have been offered.\n accept(options?: { protocol?: string }): void;\n send(data: string | Uint8Array): void;\n close(code?: number, reason?: string): void;\n}\n// State starts null and persists for the callbacks of one turn.\nexport interface ChannelTurnStateIface<State> {\n get(): State | null;\n set(state: State | null): void;\n}\nexport interface ChannelEventContextIface<Config = JsonObject, State = JsonValue> extends Pick<\n ChannelReceiveContextIface<Config>,\n 'binding' | 'config' | 'credentials' | 'store' | 'log'\n> {\n origin: OriginIface;\n conversation: ConversationHandle;\n turn: { id: string; agent: { displayName: string } };\n state: ChannelTurnStateIface<State>;\n}\nexport interface ChannelRouteContextIface<\n Config = JsonObject,\n> extends ChannelReceiveContextIface<Config> {\n request: Request;\n receive(input: JsonValue): Promise<ChannelReceiveResult>;\n}\nexport interface HttpChannelRouteDefinitionIface<Config = JsonObject> {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE';\n path: string;\n // Served only for a provider returning with `credentials.redirect` state.\n redirect?: boolean;\n handler(args: ChannelRouteContextIface<Config>): Promise<Response>;\n}\nexport interface WebSocketChannelRouteDefinitionIface<Config = JsonObject> {\n method: 'WS';\n path: string;\n handler(\n args: ChannelRouteContextIface<Config> & { socket: ChannelSocketIface },\n ): Promise<Response | void>;\n}\nexport type RouteDefinitionIface<Config = JsonObject> =\n | HttpChannelRouteDefinitionIface<Config>\n | WebSocketChannelRouteDefinitionIface<Config>;\nexport type ChannelEventHandlersIface<Config, State> = {\n [Kind in keyof ChannelSemanticDataByKindIface]?: (\n data: ChannelSemanticDataByKindIface[Kind],\n ctx: ChannelEventContextIface<Config, State>,\n ) => Promise<void>;\n};\nexport type ChannelEventKind = keyof ChannelSemanticDataByKindIface;\nexport interface ChannelDefinitionIface<\n Config = JsonObject,\n Inbound = JsonValue,\n State = JsonValue,\n> {\n name: string;\n config?: Config;\n configure?(config: Config): ChannelDefinitionIface<Config, Inbound, State>;\n credentials: { app: string | null; secrets?: string[] };\n identity:\n | {\n kind: 'redirect';\n start(\n args: { ticket: string; principal: PrincipalRef },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<URL>;\n }\n | {\n kind: 'challenge';\n deliver(\n args: { principal: PrincipalRef; code: string },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<void>;\n }\n | { kind: 'none' };\n places: { kinds: readonly string[]; defaults?(place: PlaceRef): PlaceDefaultsIface | null };\n resources?: {\n authorize(\n args: { place: PlaceRef; principal: PrincipalRef },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<boolean>;\n resolve(\n args: { url: string; principal: PrincipalRef },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<PlaceRef | null>;\n };\n routes?: RouteDefinitionIface<Config>[];\n listeners?: {\n key: string;\n run(ctx: ChannelReceiveContextIface<Config> & { signal: AbortSignal }): Promise<void>;\n }[];\n receive(input: Inbound, ctx: ChannelReceiveContextIface<Config>): Promise<ChannelReceiveResult>;\n events?: ChannelEventHandlersIface<Config, State>;\n}\nexport const defineChannel = <Config = JsonObject, Inbound = JsonValue, State = JsonValue>(\n definition: ChannelDefinitionIface<Config, Inbound, State>,\n): ChannelDefinitionIface<Config, Inbound, State> => definition;\n"],
|
|
5
|
-
"mappings": "AACA,YAAY,OAAO;AACnB,SAAS,wBAAyD;AAI3D,MAAM,qBAAqB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAuB;AACpE,MAAM,2BAA2B,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAA6B;AAIhF,MAAM,qBAAqB,EAAE,OAAO;AAAA,EACzC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACpB,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,EACnC,aAAa,EAAE,OAAO,EAAE,SAAS;AACnC,CAAC;AASM,MAAM,iBAAsC,EAAE;AAAA,EAAK,MACxD,EAAE,OAAO;AAAA,IACP,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,IACtB,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,IACpB,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,SAAS;AAAA,IACnC,QAAQ,eAAe,SAAS;AAAA,IAChC,OAAO,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,CAAC;AACH;AAKO,MAAM,eAAe,EAAE,OAAO,EAAE,OAAO,gBAAgB,KAAK,iBAAiB,SAAS,EAAE,CAAC;
|
|
4
|
+
"sourcesContent": ["import type { ContentBlock } from '@agentclientprotocol/sdk/experimental/v2';\nimport * as z from 'zod';\nimport { jsonObjectSchema, type JsonObject, type JsonValue } from \"./json.mjs\";\nimport type { ChannelSemanticDataByKindIface } from \"./semantic-events.mjs\";\n\n// Handles carry no authority until the platform validates their binding and invocation signature.\nexport const personHandleSchema = z.string().min(1).brand<'ChannelPerson'>();\nexport const conversationHandleSchema = z.string().min(1).brand<'ChannelConversation'>();\nexport type PersonHandle = z.infer<typeof personHandleSchema>;\nexport type ConversationHandle = z.infer<typeof conversationHandleSchema>;\n\nexport const principalRefSchema = z.object({\n id: z.string().min(1),\n tenant: z.string().min(1).optional(),\n displayName: z.string().optional(),\n});\nexport type PrincipalRef = z.infer<typeof principalRefSchema>;\nexport interface PlaceRef {\n kind: string;\n id: string;\n tenant?: string;\n parent?: PlaceRef;\n title?: string;\n}\nexport const placeRefSchema: z.ZodType<PlaceRef> = z.lazy(() =>\n z.object({\n kind: z.string().min(1),\n id: z.string().min(1),\n tenant: z.string().min(1).optional(),\n parent: placeRefSchema.optional(),\n title: z.string().optional(),\n }),\n);\nexport interface OriginIface {\n place: PlaceRef;\n ref?: JsonObject;\n}\nexport const originSchema = z.object({ place: placeRefSchema, ref: jsonObjectSchema.optional() });\n\nexport type PersonResolution =\n | { kind: 'member'; person: PersonHandle; displayName: string }\n // `linkUrl` is the installer's link page for this person, when the install has one; without\n // it, the channel tells the person how to link in its own words.\n | { kind: 'unlinked'; linkUrl?: string }\n | { kind: 'blocked'; reason: 'not-a-member' | 'suspended' };\nexport enum ChannelReplies {\n Origin = 'origin',\n All = 'all',\n}\nexport enum ChannelAudience {\n Members = 'members',\n Anyone = 'anyone',\n}\nexport enum ChannelCreate {\n DirectWithAgent = 'direct-with-agent',\n Group = 'group',\n}\nexport const placePolicySchema = z.object({\n replies: z.nativeEnum(ChannelReplies),\n audience: z.nativeEnum(ChannelAudience),\n});\nexport interface PlacePolicy {\n replies: ChannelReplies | `${ChannelReplies}`;\n audience: ChannelAudience | `${ChannelAudience}`;\n}\nexport interface PlaceDefaultsIface extends PlacePolicy {\n create: ChannelCreate | `${ChannelCreate}`;\n}\nexport type PlaceResolution =\n | { kind: 'connected'; conversation: ConversationHandle; policy: PlacePolicy }\n // `connectUrl` is the installer's connect page for this place, when the install has one.\n | { kind: 'unconnected'; connectUrl?: string; defaults: PlaceDefaultsIface | null };\nexport interface Refusal {\n refused: 'unlinked' | 'no-access' | 'unconnected' | 'not-audience';\n linkUrl?: string;\n connectUrl?: string;\n message: string;\n}\nexport type ChannelReceiveResult =\n | { accepted: true }\n | { accepted: false; refusal: Refusal }\n | { ignored: true; reason: string };\nexport const refusalSchema = z.object({\n refused: z.union([\n z.literal('unlinked'),\n z.literal('no-access'),\n z.literal('unconnected'),\n z.literal('not-audience'),\n ]),\n linkUrl: z.string().optional(),\n connectUrl: z.string().optional(),\n message: z.string(),\n});\nexport const channelReceiveResultSchema = z.union([\n z.object({ accepted: z.literal(true) }),\n z.object({ accepted: z.literal(false), refusal: refusalSchema }),\n z.object({ ignored: z.literal(true), reason: z.string() }),\n]);\nexport enum ChannelCredentialKind {\n // A provider tenant's token, stored when the tenant installed the channel's app.\n App = 'app',\n // A secret slot of the channel's app, injected without the channel reading it.\n Secret = 'secret',\n OAuth = 'oauth',\n None = 'none',\n}\nexport const channelCredentialHandleSchema = z.string().min(1).brand<'ChannelCredential'>();\nexport type ChannelCredentialHandle = z.infer<typeof channelCredentialHandleSchema>;\nexport type ChannelCredentialRef =\n | { kind: ChannelCredentialKind.App; tenant: string }\n // `scheme` is the Authorization scheme the secret is sent with (`Bearer` when omitted). Frame\n // injection writes the bare value.\n | { kind: ChannelCredentialKind.Secret; slot: string; scheme?: string }\n | { kind: ChannelCredentialKind.OAuth; handle: ChannelCredentialHandle }\n | { kind: ChannelCredentialKind.None };\nexport enum ChannelSigningAlgorithm {\n HmacSha256 = 'hmac-sha256',\n HmacSha1 = 'hmac-sha1',\n Ed25519 = 'ed25519',\n}\nexport enum ChannelSignatureEncoding {\n Hex = 'hex',\n Base64 = 'base64',\n}\nexport enum ChannelOAuthClientAuthentication {\n Body = 'body',\n Basic = 'basic',\n None = 'none',\n}\nexport interface ChannelCredentialRequestInitIface extends RequestInit {\n credential?: ChannelCredentialRef;\n}\nexport interface ChannelVerifyOptionsIface {\n // The app secret slot holding the signing secret or public key; its value is never read.\n secret: string;\n algorithm: ChannelSigningAlgorithm;\n encoding: ChannelSignatureEncoding;\n data: string;\n signature: string;\n}\nexport interface ChannelOAuthExchangeOptionsIface {\n url: string;\n parameters: Record<string, string>;\n authentication: ChannelOAuthClientAuthentication;\n clientId?: string;\n signal?: AbortSignal;\n // Stores the token as this provider tenant's install of the channel's app. Honoured only in a\n // redirect route whose state carries an unused tenant-install ticket for this binding. A\n // provider that names the tenant only in its token response is read at `tenantPath` there.\n store?: { tenant: string } | { tenantPath: string[] };\n}\nexport interface ChannelRedirectOptionsIface {\n // A GET route of this channel declared with `redirect: true`.\n path: string;\n // A tenant-install ticket the install route received; it is bound into the signed state.\n ticket?: string;\n}\nexport interface ChannelRedirectIface {\n url: string;\n state: string;\n}\nexport interface ChannelCredentialConnectOptionsIface {\n url: string;\n signal?: AbortSignal;\n}\nexport interface ChannelCredentialInjectionIface {\n path: string[];\n credential: ChannelCredentialRef;\n}\nexport interface ChannelCredentialSocketIface {\n messages: AsyncIterable<string | Uint8Array>;\n send(\n data: string | Uint8Array,\n options?: { inject?: ChannelCredentialInjectionIface[] },\n ): Promise<void>;\n close(code?: number, reason?: string): Promise<void>;\n closeCode(): number | null;\n}\nexport interface ChannelCredentialsIface {\n // The channel app's credentials stay with the host in every execution mode.\n client(): Promise<{ clientId: string }>;\n verify(args: ChannelVerifyOptionsIface): Promise<boolean>;\n exchange(args: ChannelOAuthExchangeOptionsIface): Promise<ChannelCredentialHandle>;\n // Send `url` as the OAuth redirect URI and `state` unchanged. `url` is the same for every\n // binding, so a provider application registers it once; `state` returns to this binding.\n redirect(args: ChannelRedirectOptionsIface): Promise<ChannelRedirectIface>;\n // Requests without an explicit credential are unauthenticated.\n fetch(input: RequestInfo | URL, init?: ChannelCredentialRequestInitIface): Promise<Response>;\n connect(args: ChannelCredentialConnectOptionsIface): Promise<ChannelCredentialSocketIface>;\n // The value of an app secret slot the channel declares in `require.app.secrets`; null for any\n // other slot.\n secret(slot: string): Promise<string | null>;\n}\nexport interface ChannelPostArgsIface {\n from: PersonHandle;\n content: ContentBlock[];\n context?: string[];\n origin: OriginIface;\n idempotencyKey: string;\n waitForAcceptance?: boolean;\n}\nexport interface ChannelConversationIface {\n post(args: ChannelPostArgsIface): Promise<{ messageId: string; turnId?: string } | Refusal>;\n input(args: {\n label: string;\n principal?: PrincipalRef;\n // The linked person the agent's turn acts for; with nobody, the input waits for the\n // running turn.\n actingAs?: PersonHandle;\n // False when the agent should reply only if it has something to say. Default true.\n replyExpected?: boolean;\n content: ContentBlock[];\n context?: string[];\n origin: OriginIface;\n idempotencyKey: string;\n waitForAcceptance?: boolean;\n }): Promise<{ inputId: string; turnId?: string } | Refusal>;\n attach(args: {\n origin: OriginIface;\n content: ContentBlock[];\n label: string;\n idempotencyKey: string;\n from?: PersonHandle;\n }): Promise<{ messageId: string } | Refusal>;\n edit(args: {\n externalKey: string;\n by: PersonHandle;\n content: ContentBlock[];\n }): Promise<{ messageId: string } | Refusal>;\n remove(args: { externalKey: string; by: PersonHandle }): Promise<{ removed: boolean } | Refusal>;\n react(args: {\n target: { externalKey: string } | { replyOf: { externalKey: string; turnId: string } };\n emoji: string;\n by: PersonHandle;\n op: 'add' | 'remove';\n }): Promise<{ ok: true } | Refusal>;\n}\nexport type SemanticEvent = {\n [Kind in keyof ChannelSemanticDataByKindIface]: {\n type: Kind;\n data: ChannelSemanticDataByKindIface[Kind];\n seq: number;\n };\n}[keyof ChannelSemanticDataByKindIface];\nexport interface ChannelReceiveContextIface<Config = JsonObject> {\n binding: {\n id: string;\n url: string;\n // The project the install belongs to.\n projectId: string;\n };\n config: Config;\n credentials: ChannelCredentialsIface;\n people: {\n resolve(principal: PrincipalRef): Promise<PersonResolution>;\n identify(person: PersonHandle): Promise<PrincipalRef | null>;\n // Tenant-wide uninstall/revocation also disconnects that tenant's places.\n revoke(args: {\n principal?: PrincipalRef;\n tenant?: string;\n reason: 'deactivated' | 'uninstalled' | 'provider-revoked';\n }): Promise<void>;\n confirm(args: { ticket: string; principal: PrincipalRef }): Promise<{ linked: true } | Refusal>;\n };\n places: {\n // Explicit anyone/group defaults may create a Shared chat while resolving a new place.\n resolve(place: PlaceRef): Promise<PlaceResolution>;\n observers(place: PlaceRef): Promise<ConversationHandle[]>;\n connect(\n place: PlaceRef,\n to: {\n by: PersonHandle;\n conversation?: ConversationHandle;\n create?: ChannelCreate | `${ChannelCreate}`;\n },\n ): Promise<ConversationHandle>;\n disconnect(place: PlaceRef, by: PersonHandle): Promise<void>;\n follow(\n place: PlaceRef,\n args: { by: PersonHandle; conversation: ConversationHandle; ttlSeconds?: number },\n ): Promise<void>;\n unfollow(\n place: PlaceRef,\n args: { by: PersonHandle; conversation: ConversationHandle },\n ): Promise<void>;\n };\n conversation(handle: ConversationHandle): ChannelConversationIface;\n observe(\n handle: ConversationHandle,\n args: { turnId: string; signal?: AbortSignal },\n ): AsyncIterable<SemanticEvent>;\n decisions: {\n resolve(args: {\n decisionId: string;\n outcome: JsonValue;\n by: PersonHandle;\n }): Promise<{ resolved: boolean } | Refusal>;\n };\n turns: {\n cancel(args: {\n conversation: ConversationHandle;\n by?: PersonHandle;\n turnId?: string;\n }): Promise<{ accepted: boolean } | Refusal>;\n };\n store: {\n get(key: string): Promise<JsonValue | null>;\n set(key: string, value: JsonValue | null, options?: { ttlSeconds?: number }): Promise<void>;\n };\n log(message: string, details?: JsonObject): void;\n}\nexport interface ChannelSocketIface {\n readonly signal: AbortSignal;\n readonly messages: AsyncIterable<string | Uint8Array>;\n // Authenticate the request before accepting. The selected protocol must have been offered.\n accept(options?: { protocol?: string }): void;\n send(data: string | Uint8Array): void;\n close(code?: number, reason?: string): void;\n}\n// State starts null and persists for the callbacks of one turn.\nexport interface ChannelTurnStateIface<State> {\n get(): State | null;\n set(state: State | null): void;\n}\nexport interface ChannelEventContextIface<Config = JsonObject, State = JsonValue> extends Pick<\n ChannelReceiveContextIface<Config>,\n 'binding' | 'config' | 'credentials' | 'store' | 'log'\n> {\n origin: OriginIface;\n conversation: ConversationHandle;\n turn: { id: string; agent: { displayName: string } };\n state: ChannelTurnStateIface<State>;\n}\nexport interface ChannelRouteContextIface<\n Config = JsonObject,\n> extends ChannelReceiveContextIface<Config> {\n request: Request;\n receive(input: JsonValue): Promise<ChannelReceiveResult>;\n}\nexport interface HttpChannelRouteDefinitionIface<Config = JsonObject> {\n method: 'GET' | 'POST' | 'PUT' | 'DELETE';\n path: string;\n // Served only for a provider returning with `credentials.redirect` state.\n redirect?: boolean;\n // Also served at the app's shared ingress URL, for the binding `ingress.tenantOf` picks.\n shared?: boolean;\n handler(args: ChannelRouteContextIface<Config>): Promise<Response>;\n}\nexport interface WebSocketChannelRouteDefinitionIface<Config = JsonObject> {\n method: 'WS';\n path: string;\n handler(\n args: ChannelRouteContextIface<Config> & { socket: ChannelSocketIface },\n ): Promise<Response | void>;\n}\nexport type RouteDefinitionIface<Config = JsonObject> =\n | HttpChannelRouteDefinitionIface<Config>\n | WebSocketChannelRouteDefinitionIface<Config>;\nexport type ChannelEventHandlersIface<Config, State> = {\n [Kind in keyof ChannelSemanticDataByKindIface]?: (\n data: ChannelSemanticDataByKindIface[Kind],\n ctx: ChannelEventContextIface<Config, State>,\n ) => Promise<void>;\n};\nexport type ChannelEventKind = keyof ChannelSemanticDataByKindIface;\n\n// Provider application credentials the channel needs, satisfied by a channel app: the install's\n// own, or the one the channel's publisher attached.\nexport interface ChannelAppRequirementIface {\n description: string;\n oauthClient?: { description: string; optional?: boolean };\n // Secret slots, by name (a signing secret, an app-level token).\n secrets?: Record<string, { description: string; optional?: boolean }>;\n}\nexport interface ChannelRequireIface {\n app?: ChannelAppRequirementIface;\n}\nexport interface ChannelIngressContextIface {\n app: { id: string };\n credentials: Pick<ChannelCredentialsIface, 'verify' | 'secret' | 'client'>;\n log(message: string, details?: JsonObject): void;\n}\nexport interface ChannelIngressIface {\n // Reads which provider tenant a request to the app's shared ingress URL is for, after verifying\n // it. `respond` answers an app-level request (a URL handshake) with no binding; null rejects it.\n tenantOf(\n request: Request,\n ctx: ChannelIngressContextIface,\n ): Promise<{ tenant: string } | { respond: Response } | null>;\n}\nexport interface ChannelDefinitionIface<\n Config = JsonObject,\n Inbound = JsonValue,\n State = JsonValue,\n> {\n name: string;\n config?: Config;\n configure?(config: Config): ChannelDefinitionIface<Config, Inbound, State>;\n require?: ChannelRequireIface;\n // A GET route that starts the provider's app install for a tenant; it receives `ticket`.\n tenants?: { installPath: string };\n // Present on the publication an app routes its shared ingress through.\n ingress?: ChannelIngressIface;\n identity:\n | {\n kind: 'redirect';\n start(\n args: { ticket: string; principal: PrincipalRef },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<URL>;\n }\n | {\n kind: 'challenge';\n deliver(\n args: { principal: PrincipalRef; code: string },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<void>;\n }\n | { kind: 'none' };\n places: { kinds: readonly string[]; defaults?(place: PlaceRef): PlaceDefaultsIface | null };\n resources?: {\n authorize(\n args: { place: PlaceRef; principal: PrincipalRef },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<boolean>;\n resolve(\n args: { url: string; principal: PrincipalRef },\n ctx: ChannelReceiveContextIface<Config>,\n ): Promise<PlaceRef | null>;\n };\n routes?: RouteDefinitionIface<Config>[];\n listeners?: {\n key: string;\n run(ctx: ChannelReceiveContextIface<Config> & { signal: AbortSignal }): Promise<void>;\n }[];\n receive(input: Inbound, ctx: ChannelReceiveContextIface<Config>): Promise<ChannelReceiveResult>;\n events?: ChannelEventHandlersIface<Config, State>;\n}\nexport const defineChannel = <Config = JsonObject, Inbound = JsonValue, State = JsonValue>(\n definition: ChannelDefinitionIface<Config, Inbound, State>,\n): ChannelDefinitionIface<Config, Inbound, State> => definition;\n"],
|
|
5
|
+
"mappings": "AACA,YAAY,OAAO;AACnB,SAAS,wBAAyD;AAI3D,MAAM,qBAAqB,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,MAAuB;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ureEncoding", "ChannelOAuthClientAuthentication"]
|
|
7
7
|
}
|
|
@@ -3,11 +3,9 @@ export declare enum CredentialRoute {
|
|
|
3
3
|
Model = "model",
|
|
4
4
|
Mcp = "mcp",
|
|
5
5
|
Sandbox = "sandbox",
|
|
6
|
-
TranscriptStore = "transcript-store",
|
|
7
6
|
SessionStore = "session-store",
|
|
8
7
|
FrameAttachments = "frame-attachments",
|
|
9
|
-
SubscriptionRelay = "subscription-relay"
|
|
10
|
-
FinalMcp = "final-mcp"
|
|
8
|
+
SubscriptionRelay = "subscription-relay"
|
|
11
9
|
}
|
|
12
10
|
export interface RouteGrantIface {
|
|
13
11
|
route: CredentialRoute;
|
|
@@ -3,11 +3,9 @@ var CredentialRoute = /* @__PURE__ */ ((CredentialRoute2) => {
|
|
|
3
3
|
CredentialRoute2["Model"] = "model";
|
|
4
4
|
CredentialRoute2["Mcp"] = "mcp";
|
|
5
5
|
CredentialRoute2["Sandbox"] = "sandbox";
|
|
6
|
-
CredentialRoute2["TranscriptStore"] = "transcript-store";
|
|
7
6
|
CredentialRoute2["SessionStore"] = "session-store";
|
|
8
7
|
CredentialRoute2["FrameAttachments"] = "frame-attachments";
|
|
9
8
|
CredentialRoute2["SubscriptionRelay"] = "subscription-relay";
|
|
10
|
-
CredentialRoute2["FinalMcp"] = "final-mcp";
|
|
11
9
|
return CredentialRoute2;
|
|
12
10
|
})(CredentialRoute || {});
|
|
13
11
|
const routeGrantSchema = z.object({
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/credential-routes.ts"],
|
|
4
|
-
"sourcesContent": ["import * as z from 'zod';\n\n// Route-scoped, short-lived grants. A harness reads its model\n// credential through the broker's `model` route with `token`; it never sees a\n// subscription secret unless it is Final-managed and the grant says so. A leaf\n// module: a harness session's Durable Object evaluates it (with the relay\n// contract) before its started line, without the rest of harness.ts.\n\nexport enum CredentialRoute {\n Model = 'model',\n Mcp = 'mcp',\n Sandbox = 'sandbox',\n
|
|
5
|
-
"mappings": "AAAA,YAAY,OAAO;AAQZ,IAAK,kBAAL,kBAAKA,qBAAL;AACL,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,SAAM;AACN,EAAAA,iBAAA,aAAU;
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\n\n// Route-scoped, short-lived grants. A harness reads its model\n// credential through the broker's `model` route with `token`; it never sees a\n// subscription secret unless it is Final-managed and the grant says so. A leaf\n// module: a harness session's Durable Object evaluates it (with the relay\n// contract) before its started line, without the rest of harness.ts.\n\nexport enum CredentialRoute {\n Model = 'model',\n Mcp = 'mcp',\n Sandbox = 'sandbox',\n // Issued for each HarnessService the harness or its ACP adapter declares.\n SessionStore = 'session-store',\n FrameAttachments = 'frame-attachments',\n SubscriptionRelay = 'subscription-relay',\n}\n\nexport interface RouteGrantIface {\n route: CredentialRoute;\n token: string;\n expiresAt: string;\n}\n\nexport const routeGrantSchema = z.object({\n route: z.nativeEnum(CredentialRoute),\n token: z.string().min(1),\n expiresAt: z.string(),\n}) satisfies z.ZodType<RouteGrantIface>;\n\n// The body of a refresh: the harness session the token belongs to and the\n// routes to renew (at-open harnesses: `model`, whose renewal carries `atOpen`;\n// `mcp` and `sandbox` for the MCP headers and sandbox endpoints they hold).\nexport const credentialRefreshRequestSchema = z.object({\n harnessSessionId: z.string().uuid(),\n routes: z.array(z.nativeEnum(CredentialRoute)).min(1).max(8),\n});\n\nexport type CredentialRefreshRequestIface = z.infer<typeof credentialRefreshRequestSchema>;\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,OAAO;AAQZ,IAAK,kBAAL,kBAAKA,qBAAL;AACL,EAAAA,iBAAA,WAAQ;AACR,EAAAA,iBAAA,SAAM;AACN,EAAAA,iBAAA,aAAU;AAEV,EAAAA,iBAAA,kBAAe;AACf,EAAAA,iBAAA,sBAAmB;AACnB,EAAAA,iBAAA,uBAAoB;AAPV,SAAAA;AAAA,GAAA;AAgBL,MAAM,mBAAmB,EAAE,OAAO;AAAA,EACvC,OAAO,EAAE,WAAW,eAAe;AAAA,EACnC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC;AAAA,EACvB,WAAW,EAAE,OAAO;AACtB,CAAC;AAKM,MAAM,iCAAiC,EAAE,OAAO;AAAA,EACrD,kBAAkB,EAAE,OAAO,EAAE,KAAK;AAAA,EAClC,QAAQ,EAAE,MAAM,EAAE,WAAW,eAAe,CAAC,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC;AAC7D,CAAC;",
|
|
6
6
|
"names": ["CredentialRoute"]
|
|
7
7
|
}
|
|
@@ -235,17 +235,6 @@ export declare const requirementsSchema: z.ZodObject<{
|
|
|
235
235
|
}, z.core.$strict>>>;
|
|
236
236
|
}, z.core.$strict>;
|
|
237
237
|
export type RequirementsIface = z.infer<typeof requirementsSchema>;
|
|
238
|
-
export declare enum ScheduleTarget {
|
|
239
|
-
OwnerDirect = "owner-direct",
|
|
240
|
-
BoundConversation = "bound-conversation"
|
|
241
|
-
}
|
|
242
|
-
export declare const documentScheduleSchema: z.ZodObject<{
|
|
243
|
-
key: z.ZodString;
|
|
244
|
-
cron: z.ZodString;
|
|
245
|
-
timezone: z.ZodString;
|
|
246
|
-
prompt: z.ZodString;
|
|
247
|
-
target: z.ZodEnum<typeof ScheduleTarget>;
|
|
248
|
-
}, z.core.$strict>;
|
|
249
238
|
export declare const agentIdentitySchema: z.ZodObject<{
|
|
250
239
|
name: z.ZodString;
|
|
251
240
|
description: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
@@ -361,13 +350,6 @@ export declare const agentDocumentSchema: z.ZodObject<{
|
|
|
361
350
|
}, z.core.$strict>>>;
|
|
362
351
|
toolPolicy: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<typeof ToolApprovalMode>>>;
|
|
363
352
|
secrets: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
364
|
-
schedules: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
365
|
-
key: z.ZodString;
|
|
366
|
-
cron: z.ZodString;
|
|
367
|
-
timezone: z.ZodString;
|
|
368
|
-
prompt: z.ZodString;
|
|
369
|
-
target: z.ZodEnum<typeof ScheduleTarget>;
|
|
370
|
-
}, z.core.$strict>>>;
|
|
371
353
|
}, z.core.$strict>;
|
|
372
354
|
export type AgentDocumentIface = z.output<typeof agentDocumentSchema>;
|
|
373
355
|
export type AgentDocumentInputIface = z.input<typeof agentDocumentSchema>;
|
|
@@ -120,18 +120,6 @@ const requirementsSchema = z.strictObject({
|
|
|
120
120
|
compute: computeRequirementsSchema.default({}),
|
|
121
121
|
integrations: z.record(z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/), integrationRequirementSchema).default({})
|
|
122
122
|
});
|
|
123
|
-
var ScheduleTarget = /* @__PURE__ */ ((ScheduleTarget2) => {
|
|
124
|
-
ScheduleTarget2["OwnerDirect"] = "owner-direct";
|
|
125
|
-
ScheduleTarget2["BoundConversation"] = "bound-conversation";
|
|
126
|
-
return ScheduleTarget2;
|
|
127
|
-
})(ScheduleTarget || {});
|
|
128
|
-
const documentScheduleSchema = z.strictObject({
|
|
129
|
-
key: z.string().min(1),
|
|
130
|
-
cron: z.string().min(1),
|
|
131
|
-
timezone: z.string().min(1),
|
|
132
|
-
prompt: z.string().min(1),
|
|
133
|
-
target: z.nativeEnum(ScheduleTarget)
|
|
134
|
-
});
|
|
135
123
|
const agentIdentitySchema = z.strictObject({
|
|
136
124
|
name: z.string().min(1).max(120),
|
|
137
125
|
description: z.string().max(2e3).nullable().default(null),
|
|
@@ -153,8 +141,7 @@ const agentDocumentSchema = z.strictObject({
|
|
|
153
141
|
// (`shell`, `files.write`).
|
|
154
142
|
toolPolicy: z.record(z.string().min(1), z.nativeEnum(ToolApprovalMode)).default({}),
|
|
155
143
|
// Project secrets the agent's code may read, by name.
|
|
156
|
-
secrets: z.array(z.string().min(1)).default([])
|
|
157
|
-
schedules: z.array(documentScheduleSchema).default([])
|
|
144
|
+
secrets: z.array(z.string().min(1)).default([])
|
|
158
145
|
});
|
|
159
146
|
const inProcessCodeOf = (document) => {
|
|
160
147
|
const names = [];
|
|
@@ -182,7 +169,6 @@ export {
|
|
|
182
169
|
AGENT_DOCUMENT_VERSION,
|
|
183
170
|
CodePlacement,
|
|
184
171
|
HarnessFeature,
|
|
185
|
-
ScheduleTarget,
|
|
186
172
|
ToolApprovalMode,
|
|
187
173
|
agentDocumentHash,
|
|
188
174
|
agentDocumentSchema,
|
|
@@ -191,7 +177,6 @@ export {
|
|
|
191
177
|
computeRequirementsOf,
|
|
192
178
|
computeRequirementsSchema,
|
|
193
179
|
documentHookSchema,
|
|
194
|
-
documentScheduleSchema,
|
|
195
180
|
documentSkillSchema,
|
|
196
181
|
documentToolSchema,
|
|
197
182
|
harnessRecommendationSchema,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/document.ts"],
|
|
4
|
-
"sourcesContent": ["import * as z from 'zod';\nimport {\n agentAvatarSchema,\n Capability,\n capabilityAccessSchemas,\n type CapabilityAccess,\n} from '@finalai/agent-protocol';\nimport { PermissionLevel } from '@finalai/agent-protocol/agent-platform';\nimport { contentHash } from \"./canonical-json.mjs\";\nimport { jsonSchemaSchema, jsonValueSchema } from \"./json.mjs\";\n\n// The agent's document (manifest v5): everything an agent is, as data. It\n// states what the agent requires and never what provides it: no sandboxes,\n// servers, credentials, models or harness placement. A session pins one\n// document by its content hash (./canonical-json.ts).\n//\n// Custom code is part of the document only when it runs on Final's runtime:\n// a serverless tool or hook carries its self-contained ES module source. An\n// in-process one carries only its interface; its body never leaves the\n// process that created the session.\n\nexport const AGENT_DOCUMENT_VERSION = 5;\n\nexport enum CodePlacement {\n // Runs in the process that created the session, over its connection.\n InProcess = 'in-process',\n // Runs on Final's runtime from the source in the document.\n Serverless = 'serverless',\n}\n\nexport enum ToolApprovalMode {\n Allow = 'allow',\n Ask = 'ask',\n}\n\n// One self-contained ES module. It may use the runtime's globals (`fetch`,\n// `crypto`, `URL`, ...) and its `ctx` argument; it imports nothing.\nexport const serverlessSourceSchema = z.strictObject({\n source: z\n .string()\n .min(1)\n .max(4 * 1024 * 1024),\n // The module export implementing it.\n export: z.string().min(1).default('default'),\n});\n\nexport const codeSchema = z.discriminatedUnion('placement', [\n z.strictObject({ placement: z.literal(CodePlacement.InProcess) }),\n z.strictObject({\n placement: z.literal(CodePlacement.Serverless),\n ...serverlessSourceSchema.shape,\n }),\n]);\n\nexport type CodeIface = z.infer<typeof codeSchema>;\n\nexport const toolAnnotationsSchema = z.strictObject({\n title: z.string().optional(),\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n});\n\n// Fixed approval, or a predicate over the input that runs where the tool runs.\nexport const toolApprovalSchema = z.union([\n z.nativeEnum(ToolApprovalMode),\n z.strictObject({ whenInput: codeSchema }),\n]);\n\nexport const documentToolSchema = z.strictObject({\n description: z.string(),\n inputSchema: jsonSchemaSchema,\n outputSchema: jsonSchemaSchema.optional(),\n annotations: toolAnnotationsSchema.optional(),\n approval: toolApprovalSchema.optional(),\n code: codeSchema,\n});\n\nexport type DocumentToolIface = z.infer<typeof documentToolSchema>;\n\nexport const documentHookSchema = z.strictObject({\n name: z.string().min(1).max(120),\n events: z.array(z.string().min(1)).min(1),\n code: codeSchema,\n});\n\nexport type DocumentHookIface = z.infer<typeof documentHookSchema>;\n\nexport const documentSkillSchema = z.strictObject({\n name: z.string().min(1).max(120),\n description: z.string().max(2000).optional(),\n files: z.record(z.string().min(1), z.string()),\n});\n\nexport type DocumentSkillIface = z.infer<typeof documentSkillSchema>;\n\n// Features of a harness the agent can live without. Everything else the\n// agent's parts need (./harness-requirements.ts) must be supported.\nexport enum HarnessFeature {\n Skills = 'skills',\n McpTools = 'mcpTools',\n NativeToolPolicy = 'nativeToolPolicy',\n SystemInstructions = 'systemInstructions',\n}\n\nexport const harnessRecommendationSchema = z.strictObject({\n harness: z.string().min(1),\n model: z.string().min(1).optional(),\n reasoning: z.string().min(1).optional(),\n});\n\nexport const harnessRequirementSchema = z.strictObject({\n // Binding: the most a caller's harness may be allowed to do unasked.\n permissionMode: z.nativeEnum(PermissionLevel),\n optionalFeatures: z.array(z.nativeEnum(HarnessFeature)).default([]),\n // A hint: binds nobody. The platform and the SDK never act on it.\n recommended: harnessRecommendationSchema.optional(),\n});\n\nexport type HarnessRequirementIface = z.infer<typeof harnessRequirementSchema>;\n\nconst computeRequirementFor = <Access extends z.ZodType<CapabilityAccess>>(access: Access) =>\n z.strictObject({\n access,\n optional: z.boolean().default(false),\n description: z.string().max(2000).optional(),\n });\n\nexport const computeRequirementsSchema = z.strictObject({\n [Capability.Files]: computeRequirementFor(capabilityAccessSchemas[Capability.Files]).optional(),\n [Capability.Shell]: computeRequirementFor(capabilityAccessSchemas[Capability.Shell]).optional(),\n [Capability.ComputerUse]: computeRequirementFor(\n capabilityAccessSchemas[Capability.ComputerUse],\n ).optional(),\n [Capability.BrowserUse]: computeRequirementFor(\n capabilityAccessSchemas[Capability.BrowserUse],\n ).optional(),\n});\n\nexport interface ComputeRequirementIface {\n access: CapabilityAccess;\n optional: boolean;\n description?: string;\n}\n\n// MCP tool annotation hints a slot's policy selects on.\nexport const toolAnnotationSelectorSchema = z\n .strictObject({\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n })\n .refine((selector) => Object.keys(selector).length > 0, 'Select at least one annotation');\n\n// The most an integration provided for a slot may expose. Names and `*`\n// patterns (./tool-patterns.ts); the most specific matching key governs.\nexport const integrationToolPolicySchema = z.strictObject({\n // Absent: every tool the server lists.\n allow: z.array(z.string().min(1)).optional(),\n deny: z.array(z.string().min(1)).optional(),\n // Tools listed up front; the rest stay reachable through search.\n load: z.array(z.string().min(1)).optional(),\n allowAnnotations: z.array(toolAnnotationSelectorSchema).optional(),\n denyAnnotations: z.array(toolAnnotationSelectorSchema).optional(),\n});\n\nexport const integrationRequirementSchema = z.strictObject({\n description: z.string().min(1).max(2000),\n optional: z.boolean().default(false),\n tools: integrationToolPolicySchema.optional(),\n // Tool name or pattern \u2192 approval.\n approvals: z.record(z.string().min(1), z.nativeEnum(ToolApprovalMode)).optional(),\n});\n\nexport type IntegrationRequirementIface = z.infer<typeof integrationRequirementSchema>;\n\nexport const requirementsSchema = z.strictObject({\n harness: harnessRequirementSchema,\n compute: computeRequirementsSchema.default({}),\n integrations: z\n .record(z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/), integrationRequirementSchema)\n .default({}),\n});\n\nexport type RequirementsIface = z.infer<typeof requirementsSchema>;\n\nexport enum ScheduleTarget {\n OwnerDirect = 'owner-direct',\n BoundConversation = 'bound-conversation',\n}\n\nexport const documentScheduleSchema = z.strictObject({\n key: z.string().min(1),\n cron: z.string().min(1),\n timezone: z.string().min(1),\n prompt: z.string().min(1),\n target: z.nativeEnum(ScheduleTarget),\n});\n\nexport const agentIdentitySchema = z.strictObject({\n name: z.string().min(1).max(120),\n description: z.string().max(2000).nullable().default(null),\n avatar: agentAvatarSchema.optional(),\n});\n\nexport const agentDocumentSchema = z.strictObject({\n version: z.literal(AGENT_DOCUMENT_VERSION),\n identity: agentIdentitySchema,\n // Markdown, given to the harness as system instructions.\n instructions: z.string().max(200_000).default(''),\n skills: z.array(documentSkillSchema).default([]),\n require: requirementsSchema,\n // Files written into the workspace of whatever provides `files`, once per sandbox.\n workspace: z.record(z.string().min(1), z.string()).default({}),\n // Key is the tool's name.\n tools: z.record(z.string().regex(/^[a-zA-Z0-9_-]{1,64}$/), documentToolSchema).default({}),\n hooks: z.array(documentHookSchema).default([]),\n // Approval for the harness's own tools, by capability or tool name\n // (`shell`, `files.write`).\n toolPolicy: z.record(z.string().min(1), z.nativeEnum(ToolApprovalMode)).default({}),\n // Project secrets the agent's code may read, by name.\n secrets: z.array(z.string().min(1)).default([]),\n schedules: z.array(documentScheduleSchema).default([]),\n});\n\nexport type AgentDocumentIface = z.output<typeof agentDocumentSchema>;\nexport type AgentDocumentInputIface = z.input<typeof agentDocumentSchema>;\n\n// Names of the tools and hooks whose code only runs in the creating process.\nexport const inProcessCodeOf = (document: AgentDocumentIface): string[] => {\n const names: string[] = [];\n for (const [name, tool] of Object.entries(document.tools)) {\n if (tool.code.placement === CodePlacement.InProcess) names.push(name);\n else if (\n typeof tool.approval === 'object' &&\n tool.approval.whenInput.placement === CodePlacement.InProcess\n )\n names.push(`${name} (approval)`);\n }\n for (const hook of document.hooks)\n if (hook.code.placement === CodePlacement.InProcess) names.push(`hook ${hook.name}`);\n return names;\n};\n\n// The compute requirements in a fixed order, with defaults applied.\nexport const computeRequirementsOf = (\n document: AgentDocumentIface,\n): [Capability, ComputeRequirementIface][] => {\n const entries: [Capability, ComputeRequirementIface][] = [];\n for (const capability of Object.values(Capability)) {\n const requirement = document.require.compute[capability];\n if (requirement != null) entries.push([capability, requirement]);\n }\n return entries;\n};\n\n// The agent's identity: the content hash of its document with defaults\n// applied, so a document written out in full and one leaving defaults out are\n// the same agent. Nothing a caller provides (harness settings, compute,\n// integrations) is part of it.\nexport const agentDocumentHash = async (document: AgentDocumentInputIface): Promise<string> =>\n contentHash(\n jsonValueSchema.parse(JSON.parse(JSON.stringify(agentDocumentSchema.parse(document)))),\n );\n"],
|
|
5
|
-
"mappings": "AAAA,YAAY,OAAO;AACnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB,uBAAuB;AAY3C,MAAM,yBAAyB;AAE/B,IAAK,gBAAL,kBAAKA,mBAAL;AAEL,EAAAA,eAAA,eAAY;AAEZ,EAAAA,eAAA,gBAAa;AAJH,SAAAA;AAAA,GAAA;AAOL,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,WAAQ;AACR,EAA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AClF,CAAC;AAIM,MAAM,qBAAqB,EAAE,aAAa;AAAA,EAC/C,SAAS;AAAA,EACT,SAAS,0BAA0B,QAAQ,CAAC,CAAC;AAAA,EAC7C,cAAc,EACX,OAAO,EAAE,OAAO,EAAE,MAAM,yBAAyB,GAAG,4BAA4B,EAChF,QAAQ,CAAC,CAAC;AACf,CAAC;AAIM,
|
|
6
|
-
"names": ["CodePlacement", "ToolApprovalMode", "HarnessFeature"
|
|
4
|
+
"sourcesContent": ["import * as z from 'zod';\nimport {\n agentAvatarSchema,\n Capability,\n capabilityAccessSchemas,\n type CapabilityAccess,\n} from '@finalai/agent-protocol';\nimport { PermissionLevel } from '@finalai/agent-protocol/agent-platform';\nimport { contentHash } from \"./canonical-json.mjs\";\nimport { jsonSchemaSchema, jsonValueSchema } from \"./json.mjs\";\n\n// The agent's document (manifest v5): everything an agent is, as data. It\n// states what the agent requires and never what provides it: no sandboxes,\n// servers, credentials, models or harness placement. A session pins one\n// document by its content hash (./canonical-json.ts).\n//\n// Custom code is part of the document only when it runs on Final's runtime:\n// a serverless tool or hook carries its self-contained ES module source. An\n// in-process one carries only its interface; its body never leaves the\n// process that created the session.\n\nexport const AGENT_DOCUMENT_VERSION = 5;\n\nexport enum CodePlacement {\n // Runs in the process that created the session, over its connection.\n InProcess = 'in-process',\n // Runs on Final's runtime from the source in the document.\n Serverless = 'serverless',\n}\n\nexport enum ToolApprovalMode {\n Allow = 'allow',\n Ask = 'ask',\n}\n\n// One self-contained ES module. It may use the runtime's globals (`fetch`,\n// `crypto`, `URL`, ...) and its `ctx` argument; it imports nothing.\nexport const serverlessSourceSchema = z.strictObject({\n source: z\n .string()\n .min(1)\n .max(4 * 1024 * 1024),\n // The module export implementing it.\n export: z.string().min(1).default('default'),\n});\n\nexport const codeSchema = z.discriminatedUnion('placement', [\n z.strictObject({ placement: z.literal(CodePlacement.InProcess) }),\n z.strictObject({\n placement: z.literal(CodePlacement.Serverless),\n ...serverlessSourceSchema.shape,\n }),\n]);\n\nexport type CodeIface = z.infer<typeof codeSchema>;\n\nexport const toolAnnotationsSchema = z.strictObject({\n title: z.string().optional(),\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n});\n\n// Fixed approval, or a predicate over the input that runs where the tool runs.\nexport const toolApprovalSchema = z.union([\n z.nativeEnum(ToolApprovalMode),\n z.strictObject({ whenInput: codeSchema }),\n]);\n\nexport const documentToolSchema = z.strictObject({\n description: z.string(),\n inputSchema: jsonSchemaSchema,\n outputSchema: jsonSchemaSchema.optional(),\n annotations: toolAnnotationsSchema.optional(),\n approval: toolApprovalSchema.optional(),\n code: codeSchema,\n});\n\nexport type DocumentToolIface = z.infer<typeof documentToolSchema>;\n\nexport const documentHookSchema = z.strictObject({\n name: z.string().min(1).max(120),\n events: z.array(z.string().min(1)).min(1),\n code: codeSchema,\n});\n\nexport type DocumentHookIface = z.infer<typeof documentHookSchema>;\n\nexport const documentSkillSchema = z.strictObject({\n name: z.string().min(1).max(120),\n description: z.string().max(2000).optional(),\n files: z.record(z.string().min(1), z.string()),\n});\n\nexport type DocumentSkillIface = z.infer<typeof documentSkillSchema>;\n\n// Features of a harness the agent can live without. Everything else the\n// agent's parts need (./harness-requirements.ts) must be supported.\nexport enum HarnessFeature {\n Skills = 'skills',\n McpTools = 'mcpTools',\n NativeToolPolicy = 'nativeToolPolicy',\n SystemInstructions = 'systemInstructions',\n}\n\nexport const harnessRecommendationSchema = z.strictObject({\n harness: z.string().min(1),\n model: z.string().min(1).optional(),\n reasoning: z.string().min(1).optional(),\n});\n\nexport const harnessRequirementSchema = z.strictObject({\n // Binding: the most a caller's harness may be allowed to do unasked.\n permissionMode: z.nativeEnum(PermissionLevel),\n optionalFeatures: z.array(z.nativeEnum(HarnessFeature)).default([]),\n // A hint: binds nobody. The platform and the SDK never act on it.\n recommended: harnessRecommendationSchema.optional(),\n});\n\nexport type HarnessRequirementIface = z.infer<typeof harnessRequirementSchema>;\n\nconst computeRequirementFor = <Access extends z.ZodType<CapabilityAccess>>(access: Access) =>\n z.strictObject({\n access,\n optional: z.boolean().default(false),\n description: z.string().max(2000).optional(),\n });\n\nexport const computeRequirementsSchema = z.strictObject({\n [Capability.Files]: computeRequirementFor(capabilityAccessSchemas[Capability.Files]).optional(),\n [Capability.Shell]: computeRequirementFor(capabilityAccessSchemas[Capability.Shell]).optional(),\n [Capability.ComputerUse]: computeRequirementFor(\n capabilityAccessSchemas[Capability.ComputerUse],\n ).optional(),\n [Capability.BrowserUse]: computeRequirementFor(\n capabilityAccessSchemas[Capability.BrowserUse],\n ).optional(),\n});\n\nexport interface ComputeRequirementIface {\n access: CapabilityAccess;\n optional: boolean;\n description?: string;\n}\n\n// MCP tool annotation hints a slot's policy selects on.\nexport const toolAnnotationSelectorSchema = z\n .strictObject({\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n })\n .refine((selector) => Object.keys(selector).length > 0, 'Select at least one annotation');\n\n// The most an integration provided for a slot may expose. Names and `*`\n// patterns (./tool-patterns.ts); the most specific matching key governs.\nexport const integrationToolPolicySchema = z.strictObject({\n // Absent: every tool the server lists.\n allow: z.array(z.string().min(1)).optional(),\n deny: z.array(z.string().min(1)).optional(),\n // Tools listed up front; the rest stay reachable through search.\n load: z.array(z.string().min(1)).optional(),\n allowAnnotations: z.array(toolAnnotationSelectorSchema).optional(),\n denyAnnotations: z.array(toolAnnotationSelectorSchema).optional(),\n});\n\nexport const integrationRequirementSchema = z.strictObject({\n description: z.string().min(1).max(2000),\n optional: z.boolean().default(false),\n tools: integrationToolPolicySchema.optional(),\n // Tool name or pattern \u2192 approval.\n approvals: z.record(z.string().min(1), z.nativeEnum(ToolApprovalMode)).optional(),\n});\n\nexport type IntegrationRequirementIface = z.infer<typeof integrationRequirementSchema>;\n\nexport const requirementsSchema = z.strictObject({\n harness: harnessRequirementSchema,\n compute: computeRequirementsSchema.default({}),\n integrations: z\n .record(z.string().regex(/^[a-z][a-z0-9_-]{0,63}$/), integrationRequirementSchema)\n .default({}),\n});\n\nexport type RequirementsIface = z.infer<typeof requirementsSchema>;\n\nexport const agentIdentitySchema = z.strictObject({\n name: z.string().min(1).max(120),\n description: z.string().max(2000).nullable().default(null),\n avatar: agentAvatarSchema.optional(),\n});\n\nexport const agentDocumentSchema = z.strictObject({\n version: z.literal(AGENT_DOCUMENT_VERSION),\n identity: agentIdentitySchema,\n // Markdown, given to the harness as system instructions.\n instructions: z.string().max(200_000).default(''),\n skills: z.array(documentSkillSchema).default([]),\n require: requirementsSchema,\n // Files written into the workspace of whatever provides `files`, once per sandbox.\n workspace: z.record(z.string().min(1), z.string()).default({}),\n // Key is the tool's name.\n tools: z.record(z.string().regex(/^[a-zA-Z0-9_-]{1,64}$/), documentToolSchema).default({}),\n hooks: z.array(documentHookSchema).default([]),\n // Approval for the harness's own tools, by capability or tool name\n // (`shell`, `files.write`).\n toolPolicy: z.record(z.string().min(1), z.nativeEnum(ToolApprovalMode)).default({}),\n // Project secrets the agent's code may read, by name.\n secrets: z.array(z.string().min(1)).default([]),\n});\n\nexport type AgentDocumentIface = z.output<typeof agentDocumentSchema>;\nexport type AgentDocumentInputIface = z.input<typeof agentDocumentSchema>;\n\n// Names of the tools and hooks whose code only runs in the creating process.\nexport const inProcessCodeOf = (document: AgentDocumentIface): string[] => {\n const names: string[] = [];\n for (const [name, tool] of Object.entries(document.tools)) {\n if (tool.code.placement === CodePlacement.InProcess) names.push(name);\n else if (\n typeof tool.approval === 'object' &&\n tool.approval.whenInput.placement === CodePlacement.InProcess\n )\n names.push(`${name} (approval)`);\n }\n for (const hook of document.hooks)\n if (hook.code.placement === CodePlacement.InProcess) names.push(`hook ${hook.name}`);\n return names;\n};\n\n// The compute requirements in a fixed order, with defaults applied.\nexport const computeRequirementsOf = (\n document: AgentDocumentIface,\n): [Capability, ComputeRequirementIface][] => {\n const entries: [Capability, ComputeRequirementIface][] = [];\n for (const capability of Object.values(Capability)) {\n const requirement = document.require.compute[capability];\n if (requirement != null) entries.push([capability, requirement]);\n }\n return entries;\n};\n\n// The agent's identity: the content hash of its document with defaults\n// applied, so a document written out in full and one leaving defaults out are\n// the same agent. Nothing a caller provides (harness settings, compute,\n// integrations) is part of it.\nexport const agentDocumentHash = async (document: AgentDocumentInputIface): Promise<string> =>\n contentHash(\n jsonValueSchema.parse(JSON.parse(JSON.stringify(agentDocumentSchema.parse(document)))),\n );\n"],
|
|
5
|
+
"mappings": "AAAA,YAAY,OAAO;AACnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AACP,SAAS,uBAAuB;AAChC,SAAS,mBAAmB;AAC5B,SAAS,kBAAkB,uBAAuB;AAY3C,MAAM,yBAAyB;AAE/B,IAAK,gBAAL,kBAAKA,mBAAL;AAEL,EAAAA,eAAA,eAAY;AAEZ,EAAAA,eAAA,gBAAa;AAJH,SAAAA;AAAA,GAAA;AAOL,IAAK,mBAAL,kBAAKC,sBAAL;AACL,EAAAA,kBAAA,WAAQ;AACR,EAAAA,kBAAA,SAAM;AAFI,SAAAA;AAAA,GAAA;AAOL,MAAM,yBAAyB,EAAE,aAAa;AAAA,EACnD,QAAQ,EACL,OAAO,EACP,IAAI,CAAC,EACL,IAAI,IAAI,OAAO,IAAI;AAAA;AAAA,EAEtB,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,QAAQ,SAAS;AAC7C,CAAC;AAEM,MAAM,aAAa,EAAE,mBAAmB,aAAa;AAAA,EAC1D,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,4BAAuB,EAAE,CAAC;AAAA,EAChE,EAAE,aAAa;AAAA,IACb,WAAW,EAAE,QAAQ,6BAAwB;AAAA,IAC7C,GAAG,uBAAuB;AAAA,EAC5B,CAAC;AACH,CAAC;AAIM,MAAM,wBAAwB,EAAE,aAAa;AAAA,EAClD,OAAO,EAAE,OAAO,EAAE,SAAS;AA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;AACvD,QAAI,eAAe,KAAM,SAAQ,KAAK,CAAC,YAAY,WAAW,CAAC;AAAA,EACjE;AACA,SAAO;AACT;AAMO,MAAM,oBAAoB,OAAO,aACtC;AAAA,EACE,gBAAgB,MAAM,KAAK,MAAM,KAAK,UAAU,oBAAoB,MAAM,QAAQ,CAAC,CAAC,CAAC;AACvF;",
|
|
6
|
+
"names": ["CodePlacement", "ToolApprovalMode", "HarnessFeature"]
|
|
7
7
|
}
|
package/dist/modules/index.d.mts
CHANGED
|
@@ -6,7 +6,6 @@ export * from "./harness-definition.mjs";
|
|
|
6
6
|
export * from "./harness-provider.mjs";
|
|
7
7
|
export * from "./json.mjs";
|
|
8
8
|
export * from "./document.mjs";
|
|
9
|
-
export * from "./room-surface.mjs";
|
|
10
9
|
export * from "./sandbox/types.mjs";
|
|
11
10
|
export * from "./schemas.mjs";
|
|
12
11
|
export * from "./tool-annotations.mjs";
|
package/dist/modules/index.mjs
CHANGED
|
@@ -13,7 +13,6 @@ export * from "./harness-definition.mjs";
|
|
|
13
13
|
export * from "./harness-provider.mjs";
|
|
14
14
|
export * from "./json.mjs";
|
|
15
15
|
export * from "./document.mjs";
|
|
16
|
-
export * from "./room-surface.mjs";
|
|
17
16
|
export * from "./sandbox/types.mjs";
|
|
18
17
|
export * from "./schemas.mjs";
|
|
19
18
|
export * from "./tool-annotations.mjs";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["export {\n ProcessInspectionOperation,\n inspectedProcessSchema,\n processInspectionDetailSchema,\n processInspectionPageSchema,\n processInspectionRequestSchema,\n processInspectionResultSchema,\n type InspectedProcessIface,\n type ProcessInspectionDetailIface,\n type ProcessInspectionPageIface,\n type ProcessInspectionRequestIface,\n type ProcessInspectionResultIface,\n} from '@finalai/agent-protocol/process-inspection';\nexport * from \"./channel.mjs\";\nexport * from \"./harness.mjs\";\nexport * from \"./harness-configuration.mjs\";\nexport * from \"./harness-definition.mjs\";\nexport * from \"./harness-provider.mjs\";\nexport * from \"./json.mjs\";\nexport * from \"./document.mjs\";\nexport * from \"./
|
|
5
|
-
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;
|
|
4
|
+
"sourcesContent": ["export {\n ProcessInspectionOperation,\n inspectedProcessSchema,\n processInspectionDetailSchema,\n processInspectionPageSchema,\n processInspectionRequestSchema,\n processInspectionResultSchema,\n type InspectedProcessIface,\n type ProcessInspectionDetailIface,\n type ProcessInspectionPageIface,\n type ProcessInspectionRequestIface,\n type ProcessInspectionResultIface,\n} from '@finalai/agent-protocol/process-inspection';\nexport * from \"./channel.mjs\";\nexport * from \"./harness.mjs\";\nexport * from \"./harness-configuration.mjs\";\nexport * from \"./harness-definition.mjs\";\nexport * from \"./harness-provider.mjs\";\nexport * from \"./json.mjs\";\nexport * from \"./document.mjs\";\nexport * from \"./sandbox/types.mjs\";\nexport * from \"./schemas.mjs\";\nexport * from \"./tool-annotations.mjs\";\nexport * from \"./tool-patterns.mjs\";\nexport * from \"./tool-descriptor.mjs\";\nexport * from \"./sandbox/grant.mjs\";\nexport * from \"./sandbox/setup/index.mjs\";\nexport * from \"./code-host/index.mjs\";\n\nexport * from \"./semantic-events.mjs\";\n\nexport * from \"./sandbox/snapshots.mjs\";\n\nexport {\n SandboxEditorOperation,\n sandboxEditorRequestSchema,\n sandboxEditorResultSchema,\n sandboxEditorSessionSchema,\n type SandboxEditorRequestIface,\n type SandboxEditorResultIface,\n type SandboxEditorSessionIface,\n} from \"./sandbox/editor.mjs\";\nexport * from \"./canonical-json.mjs\";\nexport * from \"./harness-requirements.mjs\";\nexport * from \"./inference.mjs\";\nexport * from \"./requirements-check.mjs\";\n"],
|
|
5
|
+
"mappings": "AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AAEd,cAAc;AAEd,cAAc;AAEd;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AACP,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|