@dual-os/sdk 0.9.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentChannel.d.ts +830 -71
- package/dist/AgentChannel.d.ts.map +1 -1
- package/dist/AgentChannel.js +120 -15
- package/dist/AgentChannel.js.map +1 -1
- package/dist/AgentChannelConformance.d.ts +602 -6
- package/dist/AgentChannelConformance.d.ts.map +1 -1
- package/dist/AgentChannelRuntime.js +4 -3
- package/dist/AgentChannelRuntime.js.map +1 -1
- package/dist/Files.d.ts +1 -1
- package/dist/Files.js +2 -2
- package/dist/Files.js.map +1 -1
- package/dist/Http.d.ts +38 -36
- package/dist/Http.d.ts.map +1 -1
- package/dist/Http.js +28 -25
- package/dist/Http.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/remote-runtime.d.ts.map +1 -1
- package/dist/remote-runtime.js +15 -11
- package/dist/remote-runtime.js.map +1 -1
- package/package.json +1 -1
- package/src/AgentChannel.ts +125 -22
- package/src/AgentChannelRuntime.ts +11 -3
- package/src/Files.ts +2 -2
- package/src/Http.ts +33 -31
- package/src/remote-runtime.ts +10 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentChannel.d.ts","names":["AuthMethod.Any","AuthMethod.Value"],"sources":["../src/AgentChannel.ts"],"mappings":";;;;;;qBASa;YACD,gBAAgB;;qBAGf,KAAG,OAAA;;qBAKH,eAAa,OAAA;YASd,uBAAuB,cAAc;qBACpC,UAAQ,OAAA
|
|
1
|
+
{"version":3,"file":"AgentChannel.d.ts","names":["AuthMethod.Any","AuthMethod.Value"],"sources":["../src/AgentChannel.ts"],"mappings":";;;;;;qBASa;YACD,gBAAgB;;qBAGf,KAAG,OAAA;;qBAKH,eAAa,OAAA;YASd,uBAAuB,cAAc;qBACpC,UAAQ,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;YA0BT,kBAAkB,SAAS;qBAqB1B,aAAW,OAAA;;;;;Y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AW,UAAU,cAAc,QAAQ;;YAE3C,UAAU,UAAU,cAAc,OAAO;iBACpC,gBAAgB,UAAU,YAAY;WAC5C,SACP,SAAS,SACT,SAAS,eAAe,OACrB,OAAO,OAAO,cAAc,cAAc;WACtC,cACP,UAAU,kBACV,SAAS,eAAe,OACrB,OAAO,OAAO,eAAe,cAAc;WACvC,UACP,SAAS,WAAW,IACpB,SAAS,eAAe,OACrB,OAAO,OAAO,UAAU,IAAI,cAAc;;;iBAGhC,QAAQ;WACd,WAAW;WACX,SAAS,QAAQ;WACjB;aACE,SACP,kBACA,qBACG,OAAO;aACH,cACP,mBACA,qBACG,OAAO;aACH,UACP,kBACA,qBACG,OAAO;;;qBAGH,aAAU;;qBAqFV,qBAAkB,YACjB,YAAU,qBACH,mBACAD;iBAyCJ;WACN;WACA;;;qBAIE,aAAc,yBAAyB,UAAU,aAAa,gBAAc,YAC3E,IAAE,SACL,MACR,aAAa,IAAI;qBAqBP,iBAAc,mBAAqB,SAAS"}
|
package/dist/AgentChannel.js
CHANGED
|
@@ -2,9 +2,9 @@ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
|
2
2
|
import { validateIdentifier } from "./internal/identifier.js";
|
|
3
3
|
import { PipeableProto } from "./internal/proto.js";
|
|
4
4
|
import { isAuthMethod } from "./AuthMethod.js";
|
|
5
|
-
import {
|
|
5
|
+
import { File } from "./Files.js";
|
|
6
6
|
import "./AgentChannel.js";
|
|
7
|
-
import { Match, Predicate, Schema } from "effect";
|
|
7
|
+
import { Match, Option, Predicate, Schema } from "effect";
|
|
8
8
|
// src/AgentChannel.ts
|
|
9
9
|
var AgentChannel_exports = /* @__PURE__ */ __exportAll({
|
|
10
10
|
AccessOutcome: () => AccessOutcome,
|
|
@@ -34,6 +34,7 @@ var AgentChannel_exports = /* @__PURE__ */ __exportAll({
|
|
|
34
34
|
Reaction: () => Reaction,
|
|
35
35
|
Request: () => Request,
|
|
36
36
|
RequiredChecks: () => RequiredChecks,
|
|
37
|
+
SenderDetails: () => SenderDetails,
|
|
37
38
|
Stop: () => Stop,
|
|
38
39
|
Timestamp: () => Timestamp,
|
|
39
40
|
TypeId: () => TypeId,
|
|
@@ -48,6 +49,7 @@ var AgentChannel_exports = /* @__PURE__ */ __exportAll({
|
|
|
48
49
|
projectContract: () => projectContract,
|
|
49
50
|
resultByteLimit: () => resultByteLimit,
|
|
50
51
|
resultSchema: () => resultSchema,
|
|
52
|
+
senderDetails: () => senderDetails,
|
|
51
53
|
validateDefinition: () => validateDefinition
|
|
52
54
|
});
|
|
53
55
|
const TypeId = "@dual-os/sdk/AgentChannel";
|
|
@@ -80,7 +82,11 @@ const Features = Schema.Struct({
|
|
|
80
82
|
operations: Schema.optionalKey(Schema.Array(OperationKind)),
|
|
81
83
|
/** Whether `read_context` returns the conversation's earlier messages. */
|
|
82
84
|
readContext: Schema.optionalKey(Schema.Boolean),
|
|
85
|
+
/** Whether `read_sender` names a sender its messages do not; requires `senderDetails`. */
|
|
86
|
+
readSender: Schema.optionalKey(Schema.Boolean),
|
|
83
87
|
replies: Schema.Boolean,
|
|
88
|
+
/** Whether messages and context messages may name their sender beyond `senderKey`. */
|
|
89
|
+
senderDetails: Schema.optionalKey(Schema.Boolean),
|
|
84
90
|
/** Maximum age of the original responding input before preparation and delivery. */
|
|
85
91
|
responseWindowMs: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
|
|
86
92
|
threads: Schema.Boolean
|
|
@@ -151,11 +157,53 @@ const VerifiedIdentity = Schema.Struct({
|
|
|
151
157
|
conversation: Destination,
|
|
152
158
|
senderKey: Key
|
|
153
159
|
});
|
|
160
|
+
const DisplayText = Schema.NonEmptyString.check(Schema.isMaxLength(256), Schema.isPattern(/^[^\p{Cc}]+$/u));
|
|
161
|
+
const SenderEmail = Schema.NonEmptyString.check(Schema.isMaxLength(320), Schema.isPattern(/^[^\s@\p{Cc}]+@[^\s@\p{Cc}]+$/u));
|
|
162
|
+
/** What a provider says about a sender besides `senderKey`, the ID to act on; none grants. */
|
|
163
|
+
const SenderDetails = Schema.Struct({
|
|
164
|
+
/** An address the provider lists for the sender. */
|
|
165
|
+
senderEmail: Schema.optionalKey(SenderEmail),
|
|
166
|
+
/** The name others mention the sender by, such as a username, without a leading `@`. */
|
|
167
|
+
senderHandle: Schema.optionalKey(DisplayText),
|
|
168
|
+
senderName: Schema.optionalKey(DisplayText)
|
|
169
|
+
});
|
|
170
|
+
const clip = (text, max) => {
|
|
171
|
+
let kept = "";
|
|
172
|
+
for (const character of text) {
|
|
173
|
+
if (kept.length + character.length > max) break;
|
|
174
|
+
kept += character;
|
|
175
|
+
}
|
|
176
|
+
return kept;
|
|
177
|
+
};
|
|
178
|
+
const display = (value) => Option.liftPredicate(clip((value ?? "").replace(/\p{Cc}+/gu, " ").trim(), 256).trim(), (text) => text !== "");
|
|
179
|
+
/**
|
|
180
|
+
* Sender details from a provider's raw values: names trimmed, without control characters and cut
|
|
181
|
+
* to 256 characters, a handle without its leading `@`; an empty value or an invalid email is left out.
|
|
182
|
+
*/
|
|
183
|
+
const senderDetails = (values) => {
|
|
184
|
+
const email = Option.liftPredicate((values.email ?? "").trim(), Schema.is(SenderEmail));
|
|
185
|
+
const handle = display((values.handle ?? "").replace(/^@+/u, ""));
|
|
186
|
+
const name = display(values.name);
|
|
187
|
+
return {
|
|
188
|
+
...Option.match(email, {
|
|
189
|
+
onNone: () => ({}),
|
|
190
|
+
onSome: (senderEmail) => ({ senderEmail })
|
|
191
|
+
}),
|
|
192
|
+
...Option.match(handle, {
|
|
193
|
+
onNone: () => ({}),
|
|
194
|
+
onSome: (senderHandle) => ({ senderHandle })
|
|
195
|
+
}),
|
|
196
|
+
...Option.match(name, {
|
|
197
|
+
onNone: () => ({}),
|
|
198
|
+
onSome: (senderName) => ({ senderName })
|
|
199
|
+
})
|
|
200
|
+
};
|
|
201
|
+
};
|
|
154
202
|
const AccessOutcome = Schema.Struct({ decision: Schema.Literals(["allow", "deny"]) });
|
|
155
203
|
const Verification = Schema.Struct({ verified: Schema.Literal(true) });
|
|
156
204
|
const Exposure = Schema.Literals(["webhook", "host"]);
|
|
157
205
|
const RequiredChecks = Schema.Tuple([Schema.Literal("access")]);
|
|
158
|
-
const
|
|
206
|
+
const messageFields = {
|
|
159
207
|
content: Content,
|
|
160
208
|
conversation: Destination,
|
|
161
209
|
eventKey: Key,
|
|
@@ -165,6 +213,13 @@ const Message = Schema.Struct({
|
|
|
165
213
|
respond: Schema.Boolean,
|
|
166
214
|
senderKey: Key,
|
|
167
215
|
timestamp: Timestamp
|
|
216
|
+
};
|
|
217
|
+
/** Published contracts of versions without `senderDetails` keep this shape. */
|
|
218
|
+
const KeyedMessage = Schema.Struct(messageFields);
|
|
219
|
+
/** A message; sender details only where a version declares `senderDetails`. */
|
|
220
|
+
const Message = Schema.Struct({
|
|
221
|
+
...messageFields,
|
|
222
|
+
...SenderDetails.fields
|
|
168
223
|
});
|
|
169
224
|
const DeliveryUpdate = Schema.Struct({
|
|
170
225
|
deliveryKey: Key,
|
|
@@ -200,6 +255,12 @@ const Event = Schema.Union([
|
|
|
200
255
|
DeliveryUpdate,
|
|
201
256
|
Stop
|
|
202
257
|
]);
|
|
258
|
+
const KeyedEvent = Schema.Union([
|
|
259
|
+
KeyedMessage,
|
|
260
|
+
Echo,
|
|
261
|
+
DeliveryUpdate,
|
|
262
|
+
Stop
|
|
263
|
+
]);
|
|
203
264
|
/** The reactions every provider can show. Each provider maps them to its own emoji. */
|
|
204
265
|
const Reaction = Schema.Literals([
|
|
205
266
|
"thumbs_up",
|
|
@@ -291,15 +352,33 @@ const contextMessageFields = {
|
|
|
291
352
|
text: Text,
|
|
292
353
|
timestamp: Timestamp
|
|
293
354
|
};
|
|
294
|
-
|
|
295
|
-
const
|
|
296
|
-
|
|
355
|
+
const contextAssets = { assets: Schema.optionalKey(Schema.Array(Asset).check(Schema.isMaxLength(20))) };
|
|
356
|
+
const contextSender = {
|
|
357
|
+
senderEmail: SenderDetails.fields.senderEmail,
|
|
358
|
+
senderHandle: SenderDetails.fields.senderHandle
|
|
359
|
+
};
|
|
360
|
+
/** A message read back from history; each optional group only where its features allow it. */
|
|
297
361
|
const ContextMessage = Schema.Struct({
|
|
298
362
|
...contextMessageFields,
|
|
299
|
-
|
|
363
|
+
...contextAssets,
|
|
364
|
+
...contextSender
|
|
365
|
+
});
|
|
366
|
+
const TextContextMessage = Schema.Struct(contextMessageFields);
|
|
367
|
+
const AssetContextMessage = Schema.Struct({
|
|
368
|
+
...contextMessageFields,
|
|
369
|
+
...contextAssets
|
|
370
|
+
});
|
|
371
|
+
const SenderContextMessage = Schema.Struct({
|
|
372
|
+
...contextMessageFields,
|
|
373
|
+
...contextSender
|
|
300
374
|
});
|
|
375
|
+
const contextMessageFor = (features) => {
|
|
376
|
+
const sender = features.senderDetails === true;
|
|
377
|
+
if (features.assets && features.readContext === true) return sender ? ContextMessage : AssetContextMessage;
|
|
378
|
+
return sender ? SenderContextMessage : TextContextMessage;
|
|
379
|
+
};
|
|
301
380
|
/** Decoded originals are limited separately by the host; ordinary command JSON stays bounded. */
|
|
302
|
-
const AssetFile =
|
|
381
|
+
const AssetFile = File.check(Schema.makeFilter((file) => file.sizeBytes > 0 && file.sizeBytes <= 10485760));
|
|
303
382
|
/** Closed error vocabulary: provider messages, payloads, and causes never cross this seam. */
|
|
304
383
|
const FailureCode = Schema.Literals([
|
|
305
384
|
"rejected",
|
|
@@ -401,7 +480,7 @@ const installedResultSchema = (state, features) => {
|
|
|
401
480
|
...operation,
|
|
402
481
|
verified: Schema.Literal(true),
|
|
403
482
|
deniedEventKeys: Schema.optionalKey(Schema.Array(Key).check(Schema.isMaxLength(100))),
|
|
404
|
-
events: Schema.Array(Event).check(Schema.isMaxLength(100)),
|
|
483
|
+
events: Schema.Array(features === void 0 || features.senderDetails === true ? Event : KeyedEvent).check(Schema.isMaxLength(100)),
|
|
405
484
|
response: Schema.optionalKey(WebhookResponse),
|
|
406
485
|
/** A provider-native setup challenge or ping proved the configured ingress. */
|
|
407
486
|
activationProof: Schema.optionalKey(Schema.Literal("verified"))
|
|
@@ -436,7 +515,7 @@ const installedResultSchema = (state, features) => {
|
|
|
436
515
|
Schema.Struct({
|
|
437
516
|
kind: Schema.Literal("read_context"),
|
|
438
517
|
...operation,
|
|
439
|
-
messages: Schema.Array(features === void 0
|
|
518
|
+
messages: Schema.Array(features === void 0 ? ContextMessage : contextMessageFor(features)).check(Schema.isMaxLength(200))
|
|
440
519
|
})
|
|
441
520
|
]);
|
|
442
521
|
};
|
|
@@ -456,9 +535,35 @@ const readAssetResult = Schema.Struct({
|
|
|
456
535
|
kind: Schema.Literal("read_asset"),
|
|
457
536
|
operationKey: Key
|
|
458
537
|
});
|
|
459
|
-
|
|
538
|
+
/** What the provider says about the sender of `identity`, after the host checks its access. */
|
|
539
|
+
const readSenderCommand = (state) => Schema.Struct({
|
|
540
|
+
extensions: Schema.optionalKey(Extensions),
|
|
541
|
+
identity: VerifiedIdentity,
|
|
542
|
+
installationKey: Key,
|
|
543
|
+
kind: Schema.Literal("read_sender"),
|
|
544
|
+
operationKey: Key,
|
|
545
|
+
state
|
|
546
|
+
});
|
|
547
|
+
const readSenderResult = Schema.Struct({
|
|
548
|
+
...SenderDetails.fields,
|
|
549
|
+
extensions: Schema.optionalKey(Extensions),
|
|
550
|
+
kind: Schema.Literal("read_sender"),
|
|
551
|
+
operationKey: Key,
|
|
552
|
+
senderKey: Key
|
|
553
|
+
});
|
|
554
|
+
const readsSender = (features) => features === void 0 || features.readSender === true;
|
|
555
|
+
/** Pass a version's features to check its commands against its own contract. */
|
|
556
|
+
const commandSchema = (state, features) => Schema.Union([
|
|
557
|
+
installedCommandSchema(state),
|
|
558
|
+
readAssetCommand(state),
|
|
559
|
+
...readsSender(features) ? [readSenderCommand(state)] : []
|
|
560
|
+
]);
|
|
460
561
|
/** Pass a version's features to check its results against its own contract. */
|
|
461
|
-
const resultSchema = (state, features) => Schema.Union([
|
|
562
|
+
const resultSchema = (state, features) => Schema.Union([
|
|
563
|
+
installedResultSchema(state, features),
|
|
564
|
+
readAssetResult,
|
|
565
|
+
...readsSender(features) ? [readSenderResult] : []
|
|
566
|
+
]);
|
|
462
567
|
/** Maximum UTF-8 bytes in an ordinary Channel command or result, including its JSON envelope. */
|
|
463
568
|
const resultByteLimit = 2097152;
|
|
464
569
|
/** Keep the newest context messages within the checked result budget, oldest first. */
|
|
@@ -502,7 +607,7 @@ const projectContract = (definition, project = (schema) => Schema.toJsonSchemaDo
|
|
|
502
607
|
exposure: definition.exposure,
|
|
503
608
|
extensionsSchemaJson: Object.fromEntries(Object.entries(definition.extensions ?? {}).map(([key, schema]) => [key, project(schema)])),
|
|
504
609
|
featuresJson: definition.features,
|
|
505
|
-
operationInputSchemaJson: project(commandSchema(definition.state)),
|
|
610
|
+
operationInputSchemaJson: project(commandSchema(definition.state, definition.features)),
|
|
506
611
|
operationOutputSchemaJson: project(resultSchema(definition.state, definition.features)),
|
|
507
612
|
requiredChecks: definition.requiredChecks,
|
|
508
613
|
stateSchemaJson: project(definition.state)
|
|
@@ -552,7 +657,7 @@ const DefinitionSchema = Schema.Struct({
|
|
|
552
657
|
state: SchemaDefinition
|
|
553
658
|
}).check(Schema.makeFilter(({ features }) => {
|
|
554
659
|
const operations = features.operations ?? [];
|
|
555
|
-
return operations.includes("present_outcome") && new Set(operations).size === operations.length && (features.maxTextLength === void 0 || operations.includes("create_message"));
|
|
660
|
+
return operations.includes("present_outcome") && new Set(operations).size === operations.length && (features.maxTextLength === void 0 || operations.includes("create_message")) && (features.readSender !== true || features.senderDetails === true);
|
|
556
661
|
}));
|
|
557
662
|
/** Validate declarations at registration as well as at builder time. */
|
|
558
663
|
const validateDefinition = (definition, providerId, methods) => {
|
|
@@ -605,6 +710,6 @@ const make = (identifier, options) => {
|
|
|
605
710
|
};
|
|
606
711
|
};
|
|
607
712
|
const isAgentChannel = (value) => Predicate.hasProperty(value, TypeId);
|
|
608
|
-
export { AccessOutcome, AgentChannel_exports as AgentChannel, AgentChannel_exports, Asset, AssetFile, ChannelError, CheckedResult, Content, ContextMessage, Contract, DeliveryUpdate, Destination, Echo, ErrorCode, Event, Exposure, FailureCode, Features, HandlerError, Key, Message, Operation, OperationKind, Plan, PlanItem, Reaction, Request, RequiredChecks, Stop, Timestamp, TypeId, Verification, VerifiedIdentity, WebhookResponse, commandSchema, contextResult, handlerKey, isAgentChannel, make, projectContract, resultByteLimit, resultSchema, validateDefinition };
|
|
713
|
+
export { AccessOutcome, AgentChannel_exports as AgentChannel, AgentChannel_exports, Asset, AssetFile, ChannelError, CheckedResult, Content, ContextMessage, Contract, DeliveryUpdate, Destination, Echo, ErrorCode, Event, Exposure, FailureCode, Features, HandlerError, Key, Message, Operation, OperationKind, Plan, PlanItem, Reaction, Request, RequiredChecks, SenderDetails, Stop, Timestamp, TypeId, Verification, VerifiedIdentity, WebhookResponse, commandSchema, contextResult, handlerKey, isAgentChannel, make, projectContract, resultByteLimit, resultSchema, senderDetails, validateDefinition };
|
|
609
714
|
|
|
610
715
|
//# sourceMappingURL=AgentChannel.js.map
|
package/dist/AgentChannel.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentChannel.js","names":["AuthMethod.isAuthMethod"],"sources":["../src/AgentChannel.ts"],"sourcesContent":["/** Provider-neutral external Agent Channel contracts. @since 0.0.0 */\nimport type { Context, Effect, Pipeable, SchemaAST } from \"effect\";\nimport { Match, Predicate, Schema } from \"effect\";\n\nimport * as AuthMethod from \"./AuthMethod.ts\";\nimport { validateIdentifier } from \"./internal/identifier.ts\";\nimport { PipeableProto } from \"./internal/proto.ts\";\nimport * as ToolFile from \"./ToolFile.ts\";\n\nexport const TypeId = \"@dual-os/sdk/AgentChannel\" as const;\nexport type TypeId = typeof TypeId;\n\n/** Keys are opaque and installation-scoped. Never parse them into product identities. */\nexport const Key = Schema.NonEmptyString.check(\n Schema.isMaxLength(512),\n Schema.isPattern(/^[^\\p{Cc}]+$/u),\n);\n/** What a destination can show. Every channel shows `present_outcome`. */\nexport const OperationKind = Schema.Literals([\n \"present_outcome\",\n \"create_message\",\n \"update_message\",\n \"delete_message\",\n \"set_reaction\",\n \"set_activity\",\n \"render_plan\",\n]);\nexport type OperationKind = typeof OperationKind.Type;\nexport const Features = Schema.Struct({\n assets: Schema.Boolean,\n /** Whether replaying one durable delivery key is safe at the provider boundary. */\n deliveryMode: Schema.Literals([\"idempotent\", \"at-most-once\"]),\n deliveryState: Schema.Boolean,\n directText: Schema.Literal(true),\n groups: Schema.Boolean,\n /** Maximum Unicode code points per physical text message, including server-added prefixes. */\n maxTextLength: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),\n mentions: Schema.Boolean,\n /**\n * The output operations every destination of this version shows. Every definition declares\n * them; retired catalog contracts that predate them still decode.\n */\n operations: Schema.optionalKey(Schema.Array(OperationKind)),\n /** Whether `read_context` returns the conversation's earlier messages. */\n readContext: Schema.optionalKey(Schema.Boolean),\n replies: Schema.Boolean,\n /** Maximum age of the original responding input before preparation and delivery. */\n responseWindowMs: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),\n threads: Schema.Boolean,\n});\nexport type Features = typeof Features.Type;\n\nconst HttpUrl = Schema.String.check(\n Schema.isMaxLength(8192),\n Schema.makeFilter(value => {\n const url = URL.parse(value);\n return (\n url !== null &&\n (url.protocol === \"https:\" || url.protocol === \"http:\") &&\n url.username === \"\" &&\n url.password === \"\"\n );\n }),\n);\nconst Text = Schema.String.check(Schema.isMaxLength(65_536));\nconst ExtensionKey = Schema.String.check(\n Schema.isPattern(/^[a-z0-9]+(?:-[a-z0-9]+)*\\/[a-z0-9]+(?:-[a-z0-9]+)*$/),\n);\nconst Extensions = Schema.Record(Schema.String, Schema.Json).check(\n Schema.makeFilter(values => Object.keys(values).every(Schema.is(ExtensionKey))),\n);\nexport const Destination = Schema.Struct({\n conversationKey: Key,\n kind: Schema.Literals([\"direct\", \"group\"]),\n threadKey: Schema.optionalKey(Key),\n});\nexport type Destination = typeof Destination.Type;\nexport const Asset = Schema.Struct({\n assetKey: Key,\n mediaType: Schema.NonEmptyString.check(Schema.isMaxLength(256)),\n url: HttpUrl,\n});\nexport const Content = Schema.Struct({\n assets: Schema.optionalKey(Schema.Array(Asset).check(Schema.isMaxLength(20))),\n mentions: Schema.optionalKey(Schema.Array(Key).check(Schema.isMaxLength(100))),\n replyToMessageKey: Schema.optionalKey(Key),\n text: Text,\n}).check(\n Schema.makeFilter(content => content.text.length > 0 || (content.assets?.length ?? 0) > 0),\n);\nexport type Content = typeof Content.Type;\n\n/** The body is the unmodified UTF-8 provider body, before JSON parsing/signature verification. */\nexport const Request = Schema.Struct({\n body: Schema.String.check(\n Schema.isMaxLength(1_048_576),\n Schema.makeFilter(body => new TextEncoder().encode(body).byteLength <= 1_048_576),\n ),\n headers: Schema.Record(\n Schema.NonEmptyString.check(Schema.isMaxLength(256)),\n Schema.String.check(Schema.isMaxLength(8192)),\n ),\n method: Schema.Literals([\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\"]),\n url: HttpUrl,\n});\nexport type Request = typeof Request.Type;\nconst ResponseHeaders = Schema.Record(\n Schema.NonEmptyString.check(Schema.isMaxLength(256), Schema.isPattern(/^[a-z0-9-]+$/)),\n Schema.String.check(Schema.isMaxLength(8192)),\n).check(\n Schema.makeFilter(headers =>\n Object.keys(headers).every(name => name === \"content-type\" || name === \"cache-control\"),\n ),\n);\n/**\n * Bounded provider-required webhook response, returned only after request verification. A 204 or\n * 205 response has an empty body.\n */\nexport const WebhookResponse = Schema.Struct({\n body: Schema.String.check(\n Schema.isMaxLength(65_536),\n Schema.makeFilter(body => new TextEncoder().encode(body).byteLength <= 65_536),\n ),\n headers: Schema.optionalKey(ResponseHeaders),\n status: Schema.Int.check(Schema.isBetween({ maximum: 299, minimum: 200 })),\n}).check(\n Schema.makeFilter(\n response => (response.status !== 204 && response.status !== 205) || response.body === \"\",\n ),\n);\nexport type WebhookResponse = typeof WebhookResponse.Type;\nexport const Timestamp = Schema.String.check(\n Schema.isMaxLength(64),\n Schema.isPattern(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$/),\n Schema.makeFilter(value => {\n const year = Number(value.slice(0, 4));\n const month = Number(value.slice(5, 7));\n const day = Number(value.slice(8, 10));\n const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);\n const days = month === 2 ? (leap ? 29 : 28) : [4, 6, 9, 11].includes(month) ? 30 : 31;\n return (\n month >= 1 &&\n month <= 12 &&\n day >= 1 &&\n day <= days &&\n Number(value.slice(11, 13)) < 24 &&\n Number(value.slice(14, 16)) < 60 &&\n Number(value.slice(17, 19)) < 60 &&\n Schema.decodeUnknownExit(Schema.DateTimeUtcFromString)(value)._tag === \"Success\"\n );\n }),\n);\nexport const VerifiedIdentity = Schema.Struct({ conversation: Destination, senderKey: Key });\nexport type VerifiedIdentity = typeof VerifiedIdentity.Type;\nexport const AccessOutcome = Schema.Struct({ decision: Schema.Literals([\"allow\", \"deny\"]) });\nexport type AccessOutcome = typeof AccessOutcome.Type;\nexport const Verification = Schema.Struct({ verified: Schema.Literal(true) });\nexport type Verification = typeof Verification.Type;\nexport const Exposure = Schema.Literals([\"webhook\", \"host\"]);\nexport const RequiredChecks = Schema.Tuple([Schema.Literal(\"access\")]);\nexport const Message = Schema.Struct({\n content: Content,\n conversation: Destination,\n eventKey: Key,\n extensions: Schema.optionalKey(Extensions),\n kind: Schema.Literal(\"message\"),\n messageKey: Key,\n respond: Schema.Boolean,\n senderKey: Key,\n timestamp: Timestamp,\n});\nexport const DeliveryUpdate = Schema.Struct({\n deliveryKey: Key,\n deliveryUpdateKey: Key,\n eventKey: Key,\n extensions: Schema.optionalKey(Extensions),\n kind: Schema.Literal(\"delivery_update\"),\n providerDeliveryKey: Key,\n sequence: Schema.Natural,\n status: Schema.Literals([\"succeeded\", \"failed\"]),\n timestamp: Timestamp,\n});\n/** Provider-confirmed own output. No content is accepted or added to conversation history. */\nexport const Echo = Schema.Struct({\n ...VerifiedIdentity.fields,\n eventKey: Key,\n extensions: Schema.optionalKey(Extensions),\n kind: Schema.Literal(\"echo\"),\n messageKey: Key,\n timestamp: Timestamp,\n});\n/** The sender asked the agent to stop working in this conversation. Access applies. */\nexport const Stop = Schema.Struct({\n ...VerifiedIdentity.fields,\n eventKey: Key,\n extensions: Schema.optionalKey(Extensions),\n kind: Schema.Literal(\"stop\"),\n timestamp: Timestamp,\n});\nexport const Event = Schema.Union([Message, Echo, DeliveryUpdate, Stop]);\nexport type Event = typeof Event.Type;\n\n/** The reactions every provider can show. Each provider maps them to its own emoji. */\nexport const Reaction = Schema.Literals([\n \"thumbs_up\",\n \"thumbs_down\",\n \"laugh\",\n \"confused\",\n \"heart\",\n \"hooray\",\n \"rocket\",\n \"eyes\",\n]);\nexport type Reaction = typeof Reaction.Type;\nconst ShortText = Schema.NonEmptyString.check(Schema.isMaxLength(200));\nexport const PlanItem = Schema.Struct({\n itemKey: Key,\n note: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(2000))),\n state: Schema.Literals([\"pending\", \"in_progress\", \"completed\", \"failed\"]),\n title: Schema.NonEmptyString.check(Schema.isMaxLength(256)),\n});\n/** A whole task list, always sent complete. Item keys are unique and stable across revisions. */\nexport const Plan = Schema.Struct({\n items: Schema.Array(PlanItem).check(\n Schema.isMaxLength(50),\n Schema.makeFilter(items => new Set(items.map(item => item.itemKey)).size === items.length),\n ),\n title: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(256))),\n});\nexport type Plan = typeof Plan.Type;\n/**\n * One piece of output. A `reference` is the `providerDeliveryKey` the provider returned for\n * the message or plan it made; only that provider reads it.\n */\nexport const Operation = Schema.Union([\n /**\n * End the turn. `awaiting_input` ends it with a question, optionally with choices. The\n * provider clears any activity it shows. Earlier parts of a long text arrive as\n * `create_message` operations.\n */\n Schema.Struct({\n kind: Schema.Literal(\"present_outcome\"),\n options: Schema.optionalKey(Schema.Array(ShortText).check(Schema.isMaxLength(10))),\n outcome: Schema.Literals([\"completed\", \"failed\", \"awaiting_input\"]),\n text: Text,\n }).check(\n Schema.makeFilter(\n operation => operation.options === undefined || operation.outcome === \"awaiting_input\",\n ),\n ),\n Schema.Struct({\n kind: Schema.Literal(\"create_message\"),\n messageKey: Key,\n text: Text.check(Schema.isMinLength(1)),\n }),\n Schema.Struct({\n kind: Schema.Literal(\"update_message\"),\n messageKey: Key,\n reference: Key,\n text: Text.check(Schema.isMinLength(1)),\n }),\n Schema.Struct({ kind: Schema.Literal(\"delete_message\"), messageKey: Key, reference: Key }),\n /** Make the agent's reaction present (`active`) or absent. Desired state: repeating is safe. */\n Schema.Struct({\n active: Schema.Boolean,\n kind: Schema.Literal(\"set_reaction\"),\n reaction: Reaction,\n target: Schema.Union([\n /** The message that started the turn: `activationMessageKey` of the command. */\n Schema.Struct({ kind: Schema.Literal(\"activation\") }),\n Schema.Struct({ kind: Schema.Literal(\"message\"), reference: Key }),\n ]),\n }),\n /** What the agent is doing now, such as a typing indicator or a status line. Latest wins. */\n Schema.Struct({\n activity: Schema.Union([\n Schema.Struct({ kind: Schema.Literal(\"working\"), text: Schema.optionalKey(ShortText) }),\n Schema.Struct({ kind: Schema.Literal(\"idle\") }),\n ]),\n kind: Schema.Literal(\"set_activity\"),\n }),\n /** Show this revision of the plan, replacing the one at `reference` when there is one. */\n Schema.Struct({\n kind: Schema.Literal(\"render_plan\"),\n plan: Plan,\n reference: Schema.optionalKey(Key),\n revision: Schema.Int.check(Schema.isGreaterThan(0)),\n }),\n]);\nexport type Operation = typeof Operation.Type;\nconst contextMessageFields = {\n messageKey: Key,\n /** The agent's own message. */\n own: Schema.Boolean,\n senderKey: Key,\n senderName: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(256))),\n text: Text,\n timestamp: Timestamp,\n};\n/** Published contracts of versions without both `assets` and `readContext` keep this shape. */\nconst TextContextMessage = Schema.Struct(contextMessageFields);\n/** A message read back from history; `assets` only where a version declares assets and context. */\nexport const ContextMessage = Schema.Struct({\n ...contextMessageFields,\n assets: Schema.optionalKey(Schema.Array(Asset).check(Schema.isMaxLength(20))),\n});\nexport type ContextMessage = typeof ContextMessage.Type;\n\n/** Decoded originals are limited separately by the host; ordinary command JSON stays bounded. */\nexport const AssetFile = ToolFile.Schema.check(\n Schema.makeFilter(\n file =>\n file.sizeBytes > 0 && file.sizeBytes <= 10_485_760 && file.contentBase64.length <= 13_981_016,\n ),\n);\n\n/** Closed error vocabulary: provider messages, payloads, and causes never cross this seam. */\nexport const FailureCode = Schema.Literals([\n \"rejected\",\n \"unauthorized\",\n \"rate_limited\",\n \"unavailable\",\n \"unknown_completion\",\n /** The provider definitely refused this send because its delivery window was closed. */\n \"window_closed\",\n]);\nexport class HandlerError extends Schema.TaggedError<HandlerError>()(\"AgentChannelHandlerError\", {\n code: FailureCode,\n}) {}\nexport const ErrorCode = Schema.Literals([\n \"invalid_definition\",\n \"not_found\",\n \"invalid_input\",\n \"invalid_auth\",\n \"unsupported_feature\",\n \"invalid_result\",\n \"handler_unavailable\",\n \"provider_failure\",\n]);\nexport class ChannelError extends Schema.TaggedError<ChannelError>()(\"AgentChannelError\", {\n code: ErrorCode,\n providerCode: Schema.optionalKey(FailureCode),\n}) {\n override get message(): string {\n return `Agent Channel ${this.code}`;\n }\n}\n\nconst installedCommandSchema = <State extends Schema.Top>(state: State) => {\n const operation = { extensions: Schema.optionalKey(Extensions), operationKey: Key };\n const installed = { ...operation, installationKey: Key, state };\n return Schema.Union([\n Schema.Struct({\n kind: Schema.Literal(\"activate\"),\n ...operation,\n ingressUrl: HttpUrl,\n state: Schema.optionalKey(state),\n }),\n Schema.Struct({ kind: Schema.Literal(\"deactivate\"), ...installed }),\n Schema.Struct({ kind: Schema.Literal(\"receive\"), ...installed, request: Request }),\n Schema.Struct({\n kind: Schema.Literal(\"deliver\"),\n ...installed,\n /** The provider message that started the turn, when the host knows it. */\n activationMessageKey: Schema.optionalKey(Key),\n deliveryKey: Key,\n destination: Destination,\n operation: Operation,\n /** Original responding input timestamp; retries must preserve this reference. */\n responseToTimestamp: Schema.optionalKey(Timestamp),\n }),\n /** The conversation's latest messages, oldest first, at most `limit`. */\n Schema.Struct({\n kind: Schema.Literal(\"read_context\"),\n ...installed,\n destination: Destination,\n limit: Schema.Int.check(Schema.isBetween({ maximum: 200, minimum: 1 })),\n }),\n ]);\n};\n\nconst installedResultSchema = <State extends Schema.Top>(state: State, features?: Features) => {\n const operation = { extensions: Schema.optionalKey(Extensions), operationKey: Key };\n return Schema.Union([\n Schema.Struct({\n kind: Schema.Literal(\"activate\"),\n ...operation,\n installationKey: Key,\n state,\n /** Durable read-only provider state that the host must persist before retrying activation. */\n checkpoint: Schema.optionalKey(Schema.Literal(true)),\n /** The host must observe a verified webhook handshake before cutover. */\n verification: Schema.optionalKey(Schema.Literal(\"ingress\")),\n }),\n Schema.Struct({ kind: Schema.Literal(\"deactivate\"), ...operation }),\n Schema.Struct({\n kind: Schema.Literal(\"receive\"),\n ...operation,\n verified: Schema.Literal(true),\n deniedEventKeys: Schema.optionalKey(Schema.Array(Key).check(Schema.isMaxLength(100))),\n events: Schema.Array(Event).check(Schema.isMaxLength(100)),\n response: Schema.optionalKey(WebhookResponse),\n /** A provider-native setup challenge or ping proved the configured ingress. */\n activationProof: Schema.optionalKey(Schema.Literal(\"verified\")),\n }),\n Schema.Struct({\n kind: Schema.Literal(\"deliver\"),\n ...operation,\n deliveryKey: Key,\n status: Schema.Literal(\"succeeded\"),\n providerDeliveryKey: Key,\n }),\n Schema.Struct({\n kind: Schema.Literal(\"deliver\"),\n ...operation,\n deliveryKey: Key,\n status: Schema.Literal(\"pending\"),\n providerDeliveryKey: Key,\n }),\n Schema.Struct({\n kind: Schema.Literal(\"deliver\"),\n ...operation,\n deliveryKey: Key,\n status: Schema.Literal(\"failed\"),\n code: Schema.Literals([\n \"rejected\",\n \"unauthorized\",\n \"rate_limited\",\n \"unavailable\",\n \"window_closed\",\n ]),\n }),\n Schema.Struct({\n kind: Schema.Literal(\"read_context\"),\n ...operation,\n // Without a version's features, any checked result: the host reads every version's.\n messages: Schema.Array(\n features === undefined || (features.assets && features.readContext === true)\n ? ContextMessage\n : TextContextMessage,\n ).check(Schema.isMaxLength(200)),\n }),\n ]);\n};\nconst readAssetCommand = <State extends Schema.Top>(state: State) =>\n Schema.Struct({\n asset: Asset,\n extensions: Schema.optionalKey(Extensions),\n identity: VerifiedIdentity,\n installationKey: Key,\n kind: Schema.Literal(\"read_asset\"),\n operationKey: Key,\n state,\n });\nconst readAssetResult = Schema.Struct({\n assetKey: Key,\n extensions: Schema.optionalKey(Extensions),\n file: AssetFile,\n kind: Schema.Literal(\"read_asset\"),\n operationKey: Key,\n});\nexport const commandSchema = <State extends Schema.Top>(state: State) =>\n Schema.Union([installedCommandSchema(state), readAssetCommand(state)]);\n/** Pass a version's features to check its results against its own contract. */\nexport const resultSchema = <State extends Schema.Top>(state: State, features?: Features) =>\n Schema.Union([installedResultSchema(state, features), readAssetResult]);\nexport type Command<State extends Schema.Top = Schema.Unknown> = ReturnType<\n typeof commandSchema<State>\n>[\"Type\"];\nexport type Result<State extends Schema.Top = Schema.Unknown> = ReturnType<\n typeof resultSchema<State>\n>[\"Type\"];\n/** Maximum UTF-8 bytes in an ordinary Channel command or result, including its JSON envelope. */\nexport const resultByteLimit = 2_097_152;\n/** Keep the newest context messages within the checked result budget, oldest first. */\nexport function contextResult(\n operationKey: string,\n context: readonly ContextMessage[],\n): Extract<Result, { readonly kind: \"read_context\" }> {\n const messages: ContextMessage[] = [];\n const result = { kind: \"read_context\" as const, messages, operationKey };\n const encoder = new TextEncoder();\n let bytes = encoder.encode(JSON.stringify(result)).byteLength;\n for (let index = context.length - 1; index >= 0; index--) {\n const message = context[index];\n if (message === undefined) continue;\n const size = encoder.encode(JSON.stringify(message)).byteLength + 1;\n if (bytes + size > resultByteLimit) break;\n bytes += size;\n messages.unshift(message);\n }\n return result;\n}\n/** Encoded, JSON-safe runtime result suitable for host persistence. */\nexport const CheckedResult = resultSchema(Schema.Json);\nexport type CheckedResult = typeof CheckedResult.Type;\n\n/** Immutable catalog projection. Live schemas remain the execution validators. */\nexport const Contract = Schema.Struct({\n definitionSettingsSchemaJson: Schema.Json,\n deploymentSettingsSchemaJson: Schema.Json,\n exposure: Exposure,\n extensionsSchemaJson: Schema.Record(Schema.String, Schema.Json),\n featuresJson: Features.check(\n Schema.makeFilter(features => (features.operations ?? []).includes(\"present_outcome\")),\n ),\n operationInputSchemaJson: Schema.Json,\n operationOutputSchemaJson: Schema.Json,\n requiredChecks: RequiredChecks,\n stateSchemaJson: Schema.Json,\n});\nexport type Contract = typeof Contract.Type;\n\nexport interface Definition<\n Settings extends Schema.Top = Schema.Top,\n Mappings extends Schema.Top = Schema.Top,\n State extends Schema.Top = Schema.Top,\n Methods extends readonly AuthMethod.Any[] = readonly AuthMethod.Any[],\n> {\n readonly definitionSettings: Settings;\n readonly deploymentSettings: Mappings;\n readonly state: State;\n readonly features: Features;\n readonly exposure: typeof Exposure.Type;\n readonly requiredChecks: typeof RequiredChecks.Type;\n /** Explicit subset of the provider's methods; [] means the channel accepts no connection. */\n readonly authMethods: Methods;\n /** Each key is provider/name. Values are checked on every command/result/event. */\n readonly extensions?: Readonly<Record<string, Schema.Top>>;\n}\n/** Project the exact declaration once for SDK discovery and server contract comparison. */\nexport const projectContract = (\n definition: Definition,\n project: (schema: Schema.Top) => unknown = schema =>\n Schema.toJsonSchemaDocument(schema, { onExcessProperty: \"error\" }),\n): Contract =>\n Schema.decodeUnknownSync(Contract)(\n {\n definitionSettingsSchemaJson: project(definition.definitionSettings),\n deploymentSettingsSchemaJson: project(definition.deploymentSettings),\n exposure: definition.exposure,\n extensionsSchemaJson: Object.fromEntries(\n Object.entries(definition.extensions ?? {}).map(([key, schema]) => [key, project(schema)]),\n ),\n featuresJson: definition.features,\n operationInputSchemaJson: project(commandSchema(definition.state)),\n operationOutputSchemaJson: project(resultSchema(definition.state, definition.features)),\n requiredChecks: definition.requiredChecks,\n stateSchemaJson: project(definition.state),\n },\n { onExcessProperty: \"error\" },\n );\nexport interface Any extends Pipeable.Pipeable {\n readonly [TypeId]: TypeId;\n readonly identifier: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly definition: Definition;\n}\nexport interface AgentChannel<\n out Identifier extends string = string,\n out D extends Definition = Definition,\n> extends Any {\n readonly identifier: Identifier;\n readonly definition: D;\n}\nexport type ResolvedAuth<Methods extends readonly AuthMethod.Any[]> =\n Methods[number] extends infer M\n ? M extends AuthMethod.Any\n ? { readonly methodId: M[\"identifier\"]; readonly value: AuthMethod.Value<M> }\n : never\n : never;\nexport type HandlerContext<D extends Definition> = {\n readonly definitionSettings: D[\"definitionSettings\"][\"Type\"];\n readonly deploymentSettings: D[\"deploymentSettings\"][\"Type\"];\n} & (D[\"authMethods\"] extends readonly []\n ? {}\n : number extends D[\"authMethods\"][\"length\"]\n ? { readonly auth?: ResolvedAuth<D[\"authMethods\"]> }\n : { readonly auth: ResolvedAuth<D[\"authMethods\"]> });\n/** The command a Channel's handler receives. */\nexport type CommandFor<D extends Definition> = Command<D[\"state\"]>;\n/** The result a Channel's handler returns. */\nexport type ResultFor<D extends Definition> = Result<D[\"state\"]>;\nexport interface RuntimeContract<D extends Definition, R = never> {\n readonly verify: (\n request: Request,\n context: HandlerContext<D>,\n ) => Effect.Effect<Verification, HandlerError, R>;\n readonly checkAccess: (\n identity: VerifiedIdentity,\n context: HandlerContext<D>,\n ) => Effect.Effect<AccessOutcome, HandlerError, R>;\n readonly execute: (\n command: CommandFor<D>,\n context: HandlerContext<D>,\n ) => Effect.Effect<ResultFor<D>, HandlerError, R>;\n}\n/** Erased service representation. Input and output are checked by AgentChannelRuntime. */\nexport interface Handler<Id extends string = string> {\n readonly channelId: Id;\n readonly context: Context.Context<never>;\n readonly runtime: {\n readonly verify: (\n request: unknown,\n context: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>;\n readonly checkAccess: (\n identity: unknown,\n context: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>;\n readonly execute: (\n command: unknown,\n context: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>;\n };\n}\nexport const handlerKey = (channelId: string): string =>\n `@dual-os/sdk/AgentChannel/Handler/${channelId}`;\n\nconst SchemaDefinition = Schema.declare(Schema.isSchema);\n// Fail closed on holes such as Unknown nested inside an otherwise typed state schema.\nconst checkSchema = (schema: Schema.Top, allowOpaque = false): void => {\n const seen = new Set<SchemaAST.AST>();\n const visit = (ast: SchemaAST.AST): void => {\n if (seen.has(ast)) return;\n seen.add(ast);\n if (\n ast.annotations?.[\"parseOptions\"] !== undefined ||\n (ast.checks?.some(check => check.annotations?.[\"parseOptions\"] !== undefined) ?? false)\n ) {\n throw new ChannelError({ code: \"invalid_definition\" });\n }\n ast.encoding?.forEach(link => {\n visit(link.to);\n });\n Match.value(ast).pipe(\n Match.tag(\"Unknown\", \"Any\", \"ObjectKeyword\", () => {\n throw new ChannelError({ code: \"invalid_definition\" });\n }),\n Match.tag(\"Declaration\", declaration => {\n if (!allowOpaque) throw new ChannelError({ code: \"invalid_definition\" });\n declaration.typeParameters.forEach(visit);\n }),\n Match.tag(\"Objects\", objects => {\n objects.propertySignatures.forEach(property => visit(property.type));\n objects.indexSignatures.forEach(index => {\n // Filtered keys may disappear silently; a channel contract must retain them.\n if (\n index.parameter._tag !== \"String\" ||\n index.parameter.checks !== undefined ||\n index.parameter.encoding !== undefined\n ) {\n throw new ChannelError({ code: \"invalid_definition\" });\n }\n visit(index.parameter);\n visit(index.type);\n });\n }),\n Match.tag(\"Arrays\", arrays => {\n arrays.elements.forEach(visit);\n arrays.rest.forEach(visit);\n }),\n Match.tag(\"Union\", union => {\n union.types.forEach(visit);\n }),\n Match.tag(\"Suspend\", suspend => {\n visit(suspend.thunk());\n }),\n Match.orElse(() => undefined),\n );\n };\n visit(schema.ast);\n};\nconst DefinitionSchema = Schema.Struct({\n authMethods: Schema.Array(Schema.declare(AuthMethod.isAuthMethod)),\n definitionSettings: SchemaDefinition,\n deploymentSettings: SchemaDefinition,\n exposure: Exposure,\n extensions: Schema.optionalKey(\n Schema.Record(Schema.String, SchemaDefinition).check(\n Schema.makeFilter(values => Object.keys(values).every(Schema.is(ExtensionKey))),\n ),\n ),\n features: Features,\n requiredChecks: RequiredChecks,\n state: SchemaDefinition,\n}).check(\n Schema.makeFilter(({ features }) => {\n const operations = features.operations ?? [];\n return (\n operations.includes(\"present_outcome\") &&\n new Set(operations).size === operations.length &&\n // A long text arrives as messages before its outcome.\n (features.maxTextLength === undefined || operations.includes(\"create_message\"))\n );\n }),\n);\n\n/** Validate declarations at registration as well as at builder time. */\nexport const validateDefinition = (\n definition: Definition,\n providerId?: string,\n methods?: readonly AuthMethod.Any[],\n): void => {\n try {\n Schema.decodeUnknownSync(DefinitionSchema)(definition, { onExcessProperty: \"error\" });\n for (const schema of [\n definition.definitionSettings,\n definition.deploymentSettings,\n definition.state,\n ...Object.values(definition.extensions ?? {}),\n ]) {\n // A JSON projection must exist; it is catalog metadata, never the execution validator.\n checkSchema(schema);\n Schema.toJsonSchemaDocument(schema);\n }\n const seen = new Set<string>();\n for (const method of definition.authMethods) {\n if (seen.has(method.identifier) || (methods !== undefined && !methods.includes(method))) {\n throw new ChannelError({ code: \"invalid_definition\" });\n }\n seen.add(method.identifier);\n Schema.decodeUnknownSync(SchemaDefinition)(method.material);\n Schema.decodeUnknownSync(SchemaDefinition)(method.value);\n for (const schema of [\n method.material,\n method.value,\n ...(method.setup === undefined ? [] : [method.setup]),\n ]) {\n checkSchema(schema, true);\n }\n }\n if (\n providerId !== undefined &&\n Object.keys(definition.extensions ?? {}).some(key => !key.startsWith(`${providerId}/`))\n ) {\n throw new ChannelError({ code: \"invalid_definition\" });\n }\n } catch {\n throw new ChannelError({ code: \"invalid_definition\" });\n }\n};\n\nexport interface ChannelOptions {\n readonly name?: string;\n readonly description?: string;\n}\n\n/** Create a Channel from its contract. */\nexport const make = <const Id extends string, const O extends Definition & ChannelOptions>(\n identifier: Id,\n options: O,\n): AgentChannel<Id, O> => {\n validateIdentifier(\"agent-channel\", identifier);\n const { description, name, ...definition }: Definition & ChannelOptions = options;\n validateDefinition(definition);\n return {\n ...PipeableProto,\n [TypeId]: TypeId,\n definition: Object.freeze({\n ...definition,\n authMethods: Object.freeze([...definition.authMethods]),\n features: Object.freeze({ ...definition.features }),\n requiredChecks: Object.freeze([...definition.requiredChecks]),\n ...(definition.extensions === undefined\n ? {}\n : { extensions: Object.freeze({ ...definition.extensions }) }),\n }),\n description,\n identifier,\n name,\n } as AgentChannel<Id, O>;\n};\nexport const isAgentChannel = (value: unknown): value is Any =>\n Predicate.hasProperty(value, TypeId);\n\nexport * as AgentChannel from \"./AgentChannel.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,SAAS;;AAItB,MAAa,MAAM,OAAO,eAAe,MACvC,OAAO,YAAY,GAAG,GACtB,OAAO,UAAU,eAAe,CAClC;;AAEA,MAAa,gBAAgB,OAAO,SAAS;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,WAAW,OAAO,OAAO;CACpC,QAAQ,OAAO;;CAEf,cAAc,OAAO,SAAS,CAAC,cAAc,cAAc,CAAC;CAC5D,eAAe,OAAO;CACtB,YAAY,OAAO,QAAQ,IAAI;CAC/B,QAAQ,OAAO;;CAEf,eAAe,OAAO,YAAY,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC,CAAC;CAC3E,UAAU,OAAO;;;;;CAKjB,YAAY,OAAO,YAAY,OAAO,MAAM,aAAa,CAAC;;CAE1D,aAAa,OAAO,YAAY,OAAO,OAAO;CAC9C,SAAS,OAAO;;CAEhB,kBAAkB,OAAO,YAAY,OAAO,IAAI,MAAM,OAAO,cAAc,CAAC,CAAC,CAAC;CAC9E,SAAS,OAAO;AAClB,CAAC;AAGD,MAAM,UAAU,OAAO,OAAO,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../src/AgentChannel.ts"],"sourcesContent":["/** Provider-neutral external Agent Channel contracts. @since 0.0.0 */\nimport type { Context, Effect, Pipeable, SchemaAST } from \"effect\";\nimport { Match, Option, Predicate, Schema } from \"effect\";\n\nimport * as AuthMethod from \"./AuthMethod.ts\";\nimport { Files } from \"./Files.ts\";\nimport { validateIdentifier } from \"./internal/identifier.ts\";\nimport { PipeableProto } from \"./internal/proto.ts\";\n\nexport const TypeId = \"@dual-os/sdk/AgentChannel\" as const;\nexport type TypeId = typeof TypeId;\n\n/** Keys are opaque and installation-scoped. Never parse them into product identities. */\nexport const Key = Schema.NonEmptyString.check(\n Schema.isMaxLength(512),\n Schema.isPattern(/^[^\\p{Cc}]+$/u),\n);\n/** What a destination can show. Every channel shows `present_outcome`. */\nexport const OperationKind = Schema.Literals([\n \"present_outcome\",\n \"create_message\",\n \"update_message\",\n \"delete_message\",\n \"set_reaction\",\n \"set_activity\",\n \"render_plan\",\n]);\nexport type OperationKind = typeof OperationKind.Type;\nexport const Features = Schema.Struct({\n assets: Schema.Boolean,\n /** Whether replaying one durable delivery key is safe at the provider boundary. */\n deliveryMode: Schema.Literals([\"idempotent\", \"at-most-once\"]),\n deliveryState: Schema.Boolean,\n directText: Schema.Literal(true),\n groups: Schema.Boolean,\n /** Maximum Unicode code points per physical text message, including server-added prefixes. */\n maxTextLength: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),\n mentions: Schema.Boolean,\n /**\n * The output operations every destination of this version shows. Every definition declares\n * them; retired catalog contracts that predate them still decode.\n */\n operations: Schema.optionalKey(Schema.Array(OperationKind)),\n /** Whether `read_context` returns the conversation's earlier messages. */\n readContext: Schema.optionalKey(Schema.Boolean),\n /** Whether `read_sender` names a sender its messages do not; requires `senderDetails`. */\n readSender: Schema.optionalKey(Schema.Boolean),\n replies: Schema.Boolean,\n /** Whether messages and context messages may name their sender beyond `senderKey`. */\n senderDetails: Schema.optionalKey(Schema.Boolean),\n /** Maximum age of the original responding input before preparation and delivery. */\n responseWindowMs: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),\n threads: Schema.Boolean,\n});\nexport type Features = typeof Features.Type;\n\nconst HttpUrl = Schema.String.check(\n Schema.isMaxLength(8192),\n Schema.makeFilter(value => {\n const url = URL.parse(value);\n return (\n url !== null &&\n (url.protocol === \"https:\" || url.protocol === \"http:\") &&\n url.username === \"\" &&\n url.password === \"\"\n );\n }),\n);\nconst Text = Schema.String.check(Schema.isMaxLength(65_536));\nconst ExtensionKey = Schema.String.check(\n Schema.isPattern(/^[a-z0-9]+(?:-[a-z0-9]+)*\\/[a-z0-9]+(?:-[a-z0-9]+)*$/),\n);\nconst Extensions = Schema.Record(Schema.String, Schema.Json).check(\n Schema.makeFilter(values => Object.keys(values).every(Schema.is(ExtensionKey))),\n);\nexport const Destination = Schema.Struct({\n conversationKey: Key,\n kind: Schema.Literals([\"direct\", \"group\"]),\n threadKey: Schema.optionalKey(Key),\n});\nexport type Destination = typeof Destination.Type;\nexport const Asset = Schema.Struct({\n assetKey: Key,\n mediaType: Schema.NonEmptyString.check(Schema.isMaxLength(256)),\n url: HttpUrl,\n});\nexport const Content = Schema.Struct({\n assets: Schema.optionalKey(Schema.Array(Asset).check(Schema.isMaxLength(20))),\n mentions: Schema.optionalKey(Schema.Array(Key).check(Schema.isMaxLength(100))),\n replyToMessageKey: Schema.optionalKey(Key),\n text: Text,\n}).check(\n Schema.makeFilter(content => content.text.length > 0 || (content.assets?.length ?? 0) > 0),\n);\nexport type Content = typeof Content.Type;\n\n/** The body is the unmodified UTF-8 provider body, before JSON parsing/signature verification. */\nexport const Request = Schema.Struct({\n body: Schema.String.check(\n Schema.isMaxLength(1_048_576),\n Schema.makeFilter(body => new TextEncoder().encode(body).byteLength <= 1_048_576),\n ),\n headers: Schema.Record(\n Schema.NonEmptyString.check(Schema.isMaxLength(256)),\n Schema.String.check(Schema.isMaxLength(8192)),\n ),\n method: Schema.Literals([\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\"]),\n url: HttpUrl,\n});\nexport type Request = typeof Request.Type;\nconst ResponseHeaders = Schema.Record(\n Schema.NonEmptyString.check(Schema.isMaxLength(256), Schema.isPattern(/^[a-z0-9-]+$/)),\n Schema.String.check(Schema.isMaxLength(8192)),\n).check(\n Schema.makeFilter(headers =>\n Object.keys(headers).every(name => name === \"content-type\" || name === \"cache-control\"),\n ),\n);\n/**\n * Bounded provider-required webhook response, returned only after request verification. A 204 or\n * 205 response has an empty body.\n */\nexport const WebhookResponse = Schema.Struct({\n body: Schema.String.check(\n Schema.isMaxLength(65_536),\n Schema.makeFilter(body => new TextEncoder().encode(body).byteLength <= 65_536),\n ),\n headers: Schema.optionalKey(ResponseHeaders),\n status: Schema.Int.check(Schema.isBetween({ maximum: 299, minimum: 200 })),\n}).check(\n Schema.makeFilter(\n response => (response.status !== 204 && response.status !== 205) || response.body === \"\",\n ),\n);\nexport type WebhookResponse = typeof WebhookResponse.Type;\nexport const Timestamp = Schema.String.check(\n Schema.isMaxLength(64),\n Schema.isPattern(/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(?:\\.\\d+)?(?:Z|[+-]\\d{2}:\\d{2})$/),\n Schema.makeFilter(value => {\n const year = Number(value.slice(0, 4));\n const month = Number(value.slice(5, 7));\n const day = Number(value.slice(8, 10));\n const leap = year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);\n const days = month === 2 ? (leap ? 29 : 28) : [4, 6, 9, 11].includes(month) ? 30 : 31;\n return (\n month >= 1 &&\n month <= 12 &&\n day >= 1 &&\n day <= days &&\n Number(value.slice(11, 13)) < 24 &&\n Number(value.slice(14, 16)) < 60 &&\n Number(value.slice(17, 19)) < 60 &&\n Schema.decodeUnknownExit(Schema.DateTimeUtcFromString)(value)._tag === \"Success\"\n );\n }),\n);\nexport const VerifiedIdentity = Schema.Struct({ conversation: Destination, senderKey: Key });\nconst DisplayText = Schema.NonEmptyString.check(\n Schema.isMaxLength(256),\n Schema.isPattern(/^[^\\p{Cc}]+$/u),\n);\nconst SenderEmail = Schema.NonEmptyString.check(\n Schema.isMaxLength(320),\n Schema.isPattern(/^[^\\s@\\p{Cc}]+@[^\\s@\\p{Cc}]+$/u),\n);\n/** What a provider says about a sender besides `senderKey`, the ID to act on; none grants. */\nexport const SenderDetails = Schema.Struct({\n /** An address the provider lists for the sender. */\n senderEmail: Schema.optionalKey(SenderEmail),\n /** The name others mention the sender by, such as a username, without a leading `@`. */\n senderHandle: Schema.optionalKey(DisplayText),\n senderName: Schema.optionalKey(DisplayText),\n});\nexport type SenderDetails = typeof SenderDetails.Type;\n// Whole characters only, so a cut never splits a surrogate pair.\nconst clip = (text: string, max: number) => {\n let kept = \"\";\n for (const character of text) {\n if (kept.length + character.length > max) break;\n kept += character;\n }\n return kept;\n};\nconst display = (value: string | null | undefined) =>\n Option.liftPredicate(\n clip((value ?? \"\").replace(/\\p{Cc}+/gu, \" \").trim(), 256).trim(),\n text => text !== \"\",\n );\n/**\n * Sender details from a provider's raw values: names trimmed, without control characters and cut\n * to 256 characters, a handle without its leading `@`; an empty value or an invalid email is left out.\n */\nexport const senderDetails = (values: {\n readonly email?: string | null | undefined;\n readonly handle?: string | null | undefined;\n readonly name?: string | null | undefined;\n}): SenderDetails => {\n const email = Option.liftPredicate((values.email ?? \"\").trim(), Schema.is(SenderEmail));\n const handle = display((values.handle ?? \"\").replace(/^@+/u, \"\"));\n const name = display(values.name);\n return {\n ...Option.match(email, { onNone: () => ({}), onSome: senderEmail => ({ senderEmail }) }),\n ...Option.match(handle, { onNone: () => ({}), onSome: senderHandle => ({ senderHandle }) }),\n ...Option.match(name, { onNone: () => ({}), onSome: senderName => ({ senderName }) }),\n };\n};\nexport type VerifiedIdentity = typeof VerifiedIdentity.Type;\nexport const AccessOutcome = Schema.Struct({ decision: Schema.Literals([\"allow\", \"deny\"]) });\nexport type AccessOutcome = typeof AccessOutcome.Type;\nexport const Verification = Schema.Struct({ verified: Schema.Literal(true) });\nexport type Verification = typeof Verification.Type;\nexport const Exposure = Schema.Literals([\"webhook\", \"host\"]);\nexport const RequiredChecks = Schema.Tuple([Schema.Literal(\"access\")]);\nconst messageFields = {\n content: Content,\n conversation: Destination,\n eventKey: Key,\n extensions: Schema.optionalKey(Extensions),\n kind: Schema.Literal(\"message\"),\n messageKey: Key,\n respond: Schema.Boolean,\n senderKey: Key,\n timestamp: Timestamp,\n};\n/** Published contracts of versions without `senderDetails` keep this shape. */\nconst KeyedMessage = Schema.Struct(messageFields);\n/** A message; sender details only where a version declares `senderDetails`. */\nexport const Message = Schema.Struct({ ...messageFields, ...SenderDetails.fields });\nexport const DeliveryUpdate = Schema.Struct({\n deliveryKey: Key,\n deliveryUpdateKey: Key,\n eventKey: Key,\n extensions: Schema.optionalKey(Extensions),\n kind: Schema.Literal(\"delivery_update\"),\n providerDeliveryKey: Key,\n sequence: Schema.Natural,\n status: Schema.Literals([\"succeeded\", \"failed\"]),\n timestamp: Timestamp,\n});\n/** Provider-confirmed own output. No content is accepted or added to conversation history. */\nexport const Echo = Schema.Struct({\n ...VerifiedIdentity.fields,\n eventKey: Key,\n extensions: Schema.optionalKey(Extensions),\n kind: Schema.Literal(\"echo\"),\n messageKey: Key,\n timestamp: Timestamp,\n});\n/** The sender asked the agent to stop working in this conversation. Access applies. */\nexport const Stop = Schema.Struct({\n ...VerifiedIdentity.fields,\n eventKey: Key,\n extensions: Schema.optionalKey(Extensions),\n kind: Schema.Literal(\"stop\"),\n timestamp: Timestamp,\n});\nexport const Event = Schema.Union([Message, Echo, DeliveryUpdate, Stop]);\nexport type Event = typeof Event.Type;\nconst KeyedEvent = Schema.Union([KeyedMessage, Echo, DeliveryUpdate, Stop]);\n\n/** The reactions every provider can show. Each provider maps them to its own emoji. */\nexport const Reaction = Schema.Literals([\n \"thumbs_up\",\n \"thumbs_down\",\n \"laugh\",\n \"confused\",\n \"heart\",\n \"hooray\",\n \"rocket\",\n \"eyes\",\n]);\nexport type Reaction = typeof Reaction.Type;\nconst ShortText = Schema.NonEmptyString.check(Schema.isMaxLength(200));\nexport const PlanItem = Schema.Struct({\n itemKey: Key,\n note: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(2000))),\n state: Schema.Literals([\"pending\", \"in_progress\", \"completed\", \"failed\"]),\n title: Schema.NonEmptyString.check(Schema.isMaxLength(256)),\n});\n/** A whole task list, always sent complete. Item keys are unique and stable across revisions. */\nexport const Plan = Schema.Struct({\n items: Schema.Array(PlanItem).check(\n Schema.isMaxLength(50),\n Schema.makeFilter(items => new Set(items.map(item => item.itemKey)).size === items.length),\n ),\n title: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(256))),\n});\nexport type Plan = typeof Plan.Type;\n/**\n * One piece of output. A `reference` is the `providerDeliveryKey` the provider returned for\n * the message or plan it made; only that provider reads it.\n */\nexport const Operation = Schema.Union([\n /**\n * End the turn. `awaiting_input` ends it with a question, optionally with choices. The\n * provider clears any activity it shows. Earlier parts of a long text arrive as\n * `create_message` operations.\n */\n Schema.Struct({\n kind: Schema.Literal(\"present_outcome\"),\n options: Schema.optionalKey(Schema.Array(ShortText).check(Schema.isMaxLength(10))),\n outcome: Schema.Literals([\"completed\", \"failed\", \"awaiting_input\"]),\n text: Text,\n }).check(\n Schema.makeFilter(\n operation => operation.options === undefined || operation.outcome === \"awaiting_input\",\n ),\n ),\n Schema.Struct({\n kind: Schema.Literal(\"create_message\"),\n messageKey: Key,\n text: Text.check(Schema.isMinLength(1)),\n }),\n Schema.Struct({\n kind: Schema.Literal(\"update_message\"),\n messageKey: Key,\n reference: Key,\n text: Text.check(Schema.isMinLength(1)),\n }),\n Schema.Struct({ kind: Schema.Literal(\"delete_message\"), messageKey: Key, reference: Key }),\n /** Make the agent's reaction present (`active`) or absent. Desired state: repeating is safe. */\n Schema.Struct({\n active: Schema.Boolean,\n kind: Schema.Literal(\"set_reaction\"),\n reaction: Reaction,\n target: Schema.Union([\n /** The message that started the turn: `activationMessageKey` of the command. */\n Schema.Struct({ kind: Schema.Literal(\"activation\") }),\n Schema.Struct({ kind: Schema.Literal(\"message\"), reference: Key }),\n ]),\n }),\n /** What the agent is doing now, such as a typing indicator or a status line. Latest wins. */\n Schema.Struct({\n activity: Schema.Union([\n Schema.Struct({ kind: Schema.Literal(\"working\"), text: Schema.optionalKey(ShortText) }),\n Schema.Struct({ kind: Schema.Literal(\"idle\") }),\n ]),\n kind: Schema.Literal(\"set_activity\"),\n }),\n /** Show this revision of the plan, replacing the one at `reference` when there is one. */\n Schema.Struct({\n kind: Schema.Literal(\"render_plan\"),\n plan: Plan,\n reference: Schema.optionalKey(Key),\n revision: Schema.Int.check(Schema.isGreaterThan(0)),\n }),\n]);\nexport type Operation = typeof Operation.Type;\nconst contextMessageFields = {\n messageKey: Key,\n /** The agent's own message. */\n own: Schema.Boolean,\n senderKey: Key,\n senderName: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(256))),\n text: Text,\n timestamp: Timestamp,\n};\nconst contextAssets = {\n assets: Schema.optionalKey(Schema.Array(Asset).check(Schema.isMaxLength(20))),\n};\nconst contextSender = {\n senderEmail: SenderDetails.fields.senderEmail,\n senderHandle: SenderDetails.fields.senderHandle,\n};\n/** A message read back from history; each optional group only where its features allow it. */\nexport const ContextMessage = Schema.Struct({\n ...contextMessageFields,\n ...contextAssets,\n ...contextSender,\n});\nexport type ContextMessage = typeof ContextMessage.Type;\n// Published contracts keep the shape their features had before each optional field existed.\nconst TextContextMessage = Schema.Struct(contextMessageFields);\nconst AssetContextMessage = Schema.Struct({ ...contextMessageFields, ...contextAssets });\nconst SenderContextMessage = Schema.Struct({ ...contextMessageFields, ...contextSender });\nconst contextMessageFor = (features: Features) => {\n const sender = features.senderDetails === true;\n if (features.assets && features.readContext === true) {\n return sender ? ContextMessage : AssetContextMessage;\n }\n return sender ? SenderContextMessage : TextContextMessage;\n};\n\n/** Decoded originals are limited separately by the host; ordinary command JSON stays bounded. */\nexport const AssetFile = Files.File.check(\n Schema.makeFilter(file => file.sizeBytes > 0 && file.sizeBytes <= 10_485_760),\n);\n\n/** Closed error vocabulary: provider messages, payloads, and causes never cross this seam. */\nexport const FailureCode = Schema.Literals([\n \"rejected\",\n \"unauthorized\",\n \"rate_limited\",\n \"unavailable\",\n \"unknown_completion\",\n /** The provider definitely refused this send because its delivery window was closed. */\n \"window_closed\",\n]);\nexport class HandlerError extends Schema.TaggedError<HandlerError>()(\"AgentChannelHandlerError\", {\n code: FailureCode,\n}) {}\nexport const ErrorCode = Schema.Literals([\n \"invalid_definition\",\n \"not_found\",\n \"invalid_input\",\n \"invalid_auth\",\n \"unsupported_feature\",\n \"invalid_result\",\n \"handler_unavailable\",\n \"provider_failure\",\n]);\nexport class ChannelError extends Schema.TaggedError<ChannelError>()(\"AgentChannelError\", {\n code: ErrorCode,\n providerCode: Schema.optionalKey(FailureCode),\n}) {\n override get message(): string {\n return `Agent Channel ${this.code}`;\n }\n}\n\nconst installedCommandSchema = <State extends Schema.Top>(state: State) => {\n const operation = { extensions: Schema.optionalKey(Extensions), operationKey: Key };\n const installed = { ...operation, installationKey: Key, state };\n return Schema.Union([\n Schema.Struct({\n kind: Schema.Literal(\"activate\"),\n ...operation,\n ingressUrl: HttpUrl,\n state: Schema.optionalKey(state),\n }),\n Schema.Struct({ kind: Schema.Literal(\"deactivate\"), ...installed }),\n Schema.Struct({ kind: Schema.Literal(\"receive\"), ...installed, request: Request }),\n Schema.Struct({\n kind: Schema.Literal(\"deliver\"),\n ...installed,\n /** The provider message that started the turn, when the host knows it. */\n activationMessageKey: Schema.optionalKey(Key),\n deliveryKey: Key,\n destination: Destination,\n operation: Operation,\n /** Original responding input timestamp; retries must preserve this reference. */\n responseToTimestamp: Schema.optionalKey(Timestamp),\n }),\n /** The conversation's latest messages, oldest first, at most `limit`. */\n Schema.Struct({\n kind: Schema.Literal(\"read_context\"),\n ...installed,\n destination: Destination,\n limit: Schema.Int.check(Schema.isBetween({ maximum: 200, minimum: 1 })),\n }),\n ]);\n};\n\nconst installedResultSchema = <State extends Schema.Top>(state: State, features?: Features) => {\n const operation = { extensions: Schema.optionalKey(Extensions), operationKey: Key };\n return Schema.Union([\n Schema.Struct({\n kind: Schema.Literal(\"activate\"),\n ...operation,\n installationKey: Key,\n state,\n /** Durable read-only provider state that the host must persist before retrying activation. */\n checkpoint: Schema.optionalKey(Schema.Literal(true)),\n /** The host must observe a verified webhook handshake before cutover. */\n verification: Schema.optionalKey(Schema.Literal(\"ingress\")),\n }),\n Schema.Struct({ kind: Schema.Literal(\"deactivate\"), ...operation }),\n Schema.Struct({\n kind: Schema.Literal(\"receive\"),\n ...operation,\n verified: Schema.Literal(true),\n deniedEventKeys: Schema.optionalKey(Schema.Array(Key).check(Schema.isMaxLength(100))),\n events: Schema.Array(\n features === undefined || features.senderDetails === true ? Event : KeyedEvent,\n ).check(Schema.isMaxLength(100)),\n response: Schema.optionalKey(WebhookResponse),\n /** A provider-native setup challenge or ping proved the configured ingress. */\n activationProof: Schema.optionalKey(Schema.Literal(\"verified\")),\n }),\n Schema.Struct({\n kind: Schema.Literal(\"deliver\"),\n ...operation,\n deliveryKey: Key,\n status: Schema.Literal(\"succeeded\"),\n providerDeliveryKey: Key,\n }),\n Schema.Struct({\n kind: Schema.Literal(\"deliver\"),\n ...operation,\n deliveryKey: Key,\n status: Schema.Literal(\"pending\"),\n providerDeliveryKey: Key,\n }),\n Schema.Struct({\n kind: Schema.Literal(\"deliver\"),\n ...operation,\n deliveryKey: Key,\n status: Schema.Literal(\"failed\"),\n code: Schema.Literals([\n \"rejected\",\n \"unauthorized\",\n \"rate_limited\",\n \"unavailable\",\n \"window_closed\",\n ]),\n }),\n Schema.Struct({\n kind: Schema.Literal(\"read_context\"),\n ...operation,\n // Without a version's features, any checked result: the host reads every version's.\n messages: Schema.Array(\n features === undefined ? ContextMessage : contextMessageFor(features),\n ).check(Schema.isMaxLength(200)),\n }),\n ]);\n};\nconst readAssetCommand = <State extends Schema.Top>(state: State) =>\n Schema.Struct({\n asset: Asset,\n extensions: Schema.optionalKey(Extensions),\n identity: VerifiedIdentity,\n installationKey: Key,\n kind: Schema.Literal(\"read_asset\"),\n operationKey: Key,\n state,\n });\nconst readAssetResult = Schema.Struct({\n assetKey: Key,\n extensions: Schema.optionalKey(Extensions),\n file: AssetFile,\n kind: Schema.Literal(\"read_asset\"),\n operationKey: Key,\n});\n/** What the provider says about the sender of `identity`, after the host checks its access. */\nconst readSenderCommand = <State extends Schema.Top>(state: State) =>\n Schema.Struct({\n extensions: Schema.optionalKey(Extensions),\n identity: VerifiedIdentity,\n installationKey: Key,\n kind: Schema.Literal(\"read_sender\"),\n operationKey: Key,\n state,\n });\nconst readSenderResult = Schema.Struct({\n ...SenderDetails.fields,\n extensions: Schema.optionalKey(Extensions),\n kind: Schema.Literal(\"read_sender\"),\n operationKey: Key,\n senderKey: Key,\n});\n// Without a version's features, every command and result: the host reads every version's.\nconst readsSender = (features: Features | undefined) =>\n features === undefined || features.readSender === true;\n/** Pass a version's features to check its commands against its own contract. */\nexport const commandSchema = <State extends Schema.Top>(state: State, features?: Features) =>\n Schema.Union([\n installedCommandSchema(state),\n readAssetCommand(state),\n ...(readsSender(features) ? ([readSenderCommand(state)] as const) : ([] as const)),\n ]);\n/** Pass a version's features to check its results against its own contract. */\nexport const resultSchema = <State extends Schema.Top>(state: State, features?: Features) =>\n Schema.Union([\n installedResultSchema(state, features),\n readAssetResult,\n ...(readsSender(features) ? ([readSenderResult] as const) : ([] as const)),\n ]);\nexport type Command<State extends Schema.Top = Schema.Unknown> = ReturnType<\n typeof commandSchema<State>\n>[\"Type\"];\nexport type Result<State extends Schema.Top = Schema.Unknown> = ReturnType<\n typeof resultSchema<State>\n>[\"Type\"];\n/** Maximum UTF-8 bytes in an ordinary Channel command or result, including its JSON envelope. */\nexport const resultByteLimit = 2_097_152;\n/** Keep the newest context messages within the checked result budget, oldest first. */\nexport function contextResult(\n operationKey: string,\n context: readonly ContextMessage[],\n): Extract<Result, { readonly kind: \"read_context\" }> {\n const messages: ContextMessage[] = [];\n const result = { kind: \"read_context\" as const, messages, operationKey };\n const encoder = new TextEncoder();\n let bytes = encoder.encode(JSON.stringify(result)).byteLength;\n for (let index = context.length - 1; index >= 0; index--) {\n const message = context[index];\n if (message === undefined) continue;\n const size = encoder.encode(JSON.stringify(message)).byteLength + 1;\n if (bytes + size > resultByteLimit) break;\n bytes += size;\n messages.unshift(message);\n }\n return result;\n}\n/** Encoded, JSON-safe runtime result suitable for host persistence. */\nexport const CheckedResult = resultSchema(Schema.Json);\nexport type CheckedResult = typeof CheckedResult.Type;\n\n/** Immutable catalog projection. Live schemas remain the execution validators. */\nexport const Contract = Schema.Struct({\n definitionSettingsSchemaJson: Schema.Json,\n deploymentSettingsSchemaJson: Schema.Json,\n exposure: Exposure,\n extensionsSchemaJson: Schema.Record(Schema.String, Schema.Json),\n featuresJson: Features.check(\n Schema.makeFilter(features => (features.operations ?? []).includes(\"present_outcome\")),\n ),\n operationInputSchemaJson: Schema.Json,\n operationOutputSchemaJson: Schema.Json,\n requiredChecks: RequiredChecks,\n stateSchemaJson: Schema.Json,\n});\nexport type Contract = typeof Contract.Type;\n\nexport interface Definition<\n Settings extends Schema.Top = Schema.Top,\n Mappings extends Schema.Top = Schema.Top,\n State extends Schema.Top = Schema.Top,\n Methods extends readonly AuthMethod.Any[] = readonly AuthMethod.Any[],\n> {\n readonly definitionSettings: Settings;\n readonly deploymentSettings: Mappings;\n readonly state: State;\n readonly features: Features;\n readonly exposure: typeof Exposure.Type;\n readonly requiredChecks: typeof RequiredChecks.Type;\n /** Explicit subset of the provider's methods; [] means the channel accepts no connection. */\n readonly authMethods: Methods;\n /** Each key is provider/name. Values are checked on every command/result/event. */\n readonly extensions?: Readonly<Record<string, Schema.Top>>;\n}\n/** Project the exact declaration once for SDK discovery and server contract comparison. */\nexport const projectContract = (\n definition: Definition,\n project: (schema: Schema.Top) => unknown = schema =>\n Schema.toJsonSchemaDocument(schema, { onExcessProperty: \"error\" }),\n): Contract =>\n Schema.decodeUnknownSync(Contract)(\n {\n definitionSettingsSchemaJson: project(definition.definitionSettings),\n deploymentSettingsSchemaJson: project(definition.deploymentSettings),\n exposure: definition.exposure,\n extensionsSchemaJson: Object.fromEntries(\n Object.entries(definition.extensions ?? {}).map(([key, schema]) => [key, project(schema)]),\n ),\n featuresJson: definition.features,\n operationInputSchemaJson: project(commandSchema(definition.state, definition.features)),\n operationOutputSchemaJson: project(resultSchema(definition.state, definition.features)),\n requiredChecks: definition.requiredChecks,\n stateSchemaJson: project(definition.state),\n },\n { onExcessProperty: \"error\" },\n );\nexport interface Any extends Pipeable.Pipeable {\n readonly [TypeId]: TypeId;\n readonly identifier: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly definition: Definition;\n}\nexport interface AgentChannel<\n out Identifier extends string = string,\n out D extends Definition = Definition,\n> extends Any {\n readonly identifier: Identifier;\n readonly definition: D;\n}\nexport type ResolvedAuth<Methods extends readonly AuthMethod.Any[]> =\n Methods[number] extends infer M\n ? M extends AuthMethod.Any\n ? { readonly methodId: M[\"identifier\"]; readonly value: AuthMethod.Value<M> }\n : never\n : never;\nexport type HandlerContext<D extends Definition> = {\n readonly definitionSettings: D[\"definitionSettings\"][\"Type\"];\n readonly deploymentSettings: D[\"deploymentSettings\"][\"Type\"];\n} & (D[\"authMethods\"] extends readonly []\n ? {}\n : number extends D[\"authMethods\"][\"length\"]\n ? { readonly auth?: ResolvedAuth<D[\"authMethods\"]> }\n : { readonly auth: ResolvedAuth<D[\"authMethods\"]> });\n/** The command a Channel's handler receives. */\nexport type CommandFor<D extends Definition> = Command<D[\"state\"]>;\n/** The result a Channel's handler returns. */\nexport type ResultFor<D extends Definition> = Result<D[\"state\"]>;\nexport interface RuntimeContract<D extends Definition, R = never> {\n readonly verify: (\n request: Request,\n context: HandlerContext<D>,\n ) => Effect.Effect<Verification, HandlerError, R>;\n readonly checkAccess: (\n identity: VerifiedIdentity,\n context: HandlerContext<D>,\n ) => Effect.Effect<AccessOutcome, HandlerError, R>;\n readonly execute: (\n command: CommandFor<D>,\n context: HandlerContext<D>,\n ) => Effect.Effect<ResultFor<D>, HandlerError, R>;\n}\n/** Erased service representation. Input and output are checked by AgentChannelRuntime. */\nexport interface Handler<Id extends string = string> {\n readonly channelId: Id;\n readonly context: Context.Context<never>;\n readonly runtime: {\n readonly verify: (\n request: unknown,\n context: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>;\n readonly checkAccess: (\n identity: unknown,\n context: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>;\n readonly execute: (\n command: unknown,\n context: unknown,\n ) => Effect.Effect<unknown, unknown, unknown>;\n };\n}\nexport const handlerKey = (channelId: string): string =>\n `@dual-os/sdk/AgentChannel/Handler/${channelId}`;\n\nconst SchemaDefinition = Schema.declare(Schema.isSchema);\n// Fail closed on holes such as Unknown nested inside an otherwise typed state schema.\nconst checkSchema = (schema: Schema.Top, allowOpaque = false): void => {\n const seen = new Set<SchemaAST.AST>();\n const visit = (ast: SchemaAST.AST): void => {\n if (seen.has(ast)) return;\n seen.add(ast);\n if (\n ast.annotations?.[\"parseOptions\"] !== undefined ||\n (ast.checks?.some(check => check.annotations?.[\"parseOptions\"] !== undefined) ?? false)\n ) {\n throw new ChannelError({ code: \"invalid_definition\" });\n }\n ast.encoding?.forEach(link => {\n visit(link.to);\n });\n Match.value(ast).pipe(\n Match.tag(\"Unknown\", \"Any\", \"ObjectKeyword\", () => {\n throw new ChannelError({ code: \"invalid_definition\" });\n }),\n Match.tag(\"Declaration\", declaration => {\n if (!allowOpaque) throw new ChannelError({ code: \"invalid_definition\" });\n declaration.typeParameters.forEach(visit);\n }),\n Match.tag(\"Objects\", objects => {\n objects.propertySignatures.forEach(property => visit(property.type));\n objects.indexSignatures.forEach(index => {\n // Filtered keys may disappear silently; a channel contract must retain them.\n if (\n index.parameter._tag !== \"String\" ||\n index.parameter.checks !== undefined ||\n index.parameter.encoding !== undefined\n ) {\n throw new ChannelError({ code: \"invalid_definition\" });\n }\n visit(index.parameter);\n visit(index.type);\n });\n }),\n Match.tag(\"Arrays\", arrays => {\n arrays.elements.forEach(visit);\n arrays.rest.forEach(visit);\n }),\n Match.tag(\"Union\", union => {\n union.types.forEach(visit);\n }),\n Match.tag(\"Suspend\", suspend => {\n visit(suspend.thunk());\n }),\n Match.orElse(() => undefined),\n );\n };\n visit(schema.ast);\n};\nconst DefinitionSchema = Schema.Struct({\n authMethods: Schema.Array(Schema.declare(AuthMethod.isAuthMethod)),\n definitionSettings: SchemaDefinition,\n deploymentSettings: SchemaDefinition,\n exposure: Exposure,\n extensions: Schema.optionalKey(\n Schema.Record(Schema.String, SchemaDefinition).check(\n Schema.makeFilter(values => Object.keys(values).every(Schema.is(ExtensionKey))),\n ),\n ),\n features: Features,\n requiredChecks: RequiredChecks,\n state: SchemaDefinition,\n}).check(\n Schema.makeFilter(({ features }) => {\n const operations = features.operations ?? [];\n return (\n operations.includes(\"present_outcome\") &&\n new Set(operations).size === operations.length &&\n // A long text arrives as messages before its outcome.\n (features.maxTextLength === undefined || operations.includes(\"create_message\")) &&\n // What a read finds about a sender, its messages may carry too.\n (features.readSender !== true || features.senderDetails === true)\n );\n }),\n);\n\n/** Validate declarations at registration as well as at builder time. */\nexport const validateDefinition = (\n definition: Definition,\n providerId?: string,\n methods?: readonly AuthMethod.Any[],\n): void => {\n try {\n Schema.decodeUnknownSync(DefinitionSchema)(definition, { onExcessProperty: \"error\" });\n for (const schema of [\n definition.definitionSettings,\n definition.deploymentSettings,\n definition.state,\n ...Object.values(definition.extensions ?? {}),\n ]) {\n // A JSON projection must exist; it is catalog metadata, never the execution validator.\n checkSchema(schema);\n Schema.toJsonSchemaDocument(schema);\n }\n const seen = new Set<string>();\n for (const method of definition.authMethods) {\n if (seen.has(method.identifier) || (methods !== undefined && !methods.includes(method))) {\n throw new ChannelError({ code: \"invalid_definition\" });\n }\n seen.add(method.identifier);\n Schema.decodeUnknownSync(SchemaDefinition)(method.material);\n Schema.decodeUnknownSync(SchemaDefinition)(method.value);\n for (const schema of [\n method.material,\n method.value,\n ...(method.setup === undefined ? [] : [method.setup]),\n ]) {\n checkSchema(schema, true);\n }\n }\n if (\n providerId !== undefined &&\n Object.keys(definition.extensions ?? {}).some(key => !key.startsWith(`${providerId}/`))\n ) {\n throw new ChannelError({ code: \"invalid_definition\" });\n }\n } catch {\n throw new ChannelError({ code: \"invalid_definition\" });\n }\n};\n\nexport interface ChannelOptions {\n readonly name?: string;\n readonly description?: string;\n}\n\n/** Create a Channel from its contract. */\nexport const make = <const Id extends string, const O extends Definition & ChannelOptions>(\n identifier: Id,\n options: O,\n): AgentChannel<Id, O> => {\n validateIdentifier(\"agent-channel\", identifier);\n const { description, name, ...definition }: Definition & ChannelOptions = options;\n validateDefinition(definition);\n return {\n ...PipeableProto,\n [TypeId]: TypeId,\n definition: Object.freeze({\n ...definition,\n authMethods: Object.freeze([...definition.authMethods]),\n features: Object.freeze({ ...definition.features }),\n requiredChecks: Object.freeze([...definition.requiredChecks]),\n ...(definition.extensions === undefined\n ? {}\n : { extensions: Object.freeze({ ...definition.extensions }) }),\n }),\n description,\n identifier,\n name,\n } as AgentChannel<Id, O>;\n};\nexport const isAgentChannel = (value: unknown): value is Any =>\n Predicate.hasProperty(value, TypeId);\n\nexport * as AgentChannel from \"./AgentChannel.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAa,SAAS;;AAItB,MAAa,MAAM,OAAO,eAAe,MACvC,OAAO,YAAY,GAAG,GACtB,OAAO,UAAU,eAAe,CAClC;;AAEA,MAAa,gBAAgB,OAAO,SAAS;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,MAAa,WAAW,OAAO,OAAO;CACpC,QAAQ,OAAO;;CAEf,cAAc,OAAO,SAAS,CAAC,cAAc,cAAc,CAAC;CAC5D,eAAe,OAAO;CACtB,YAAY,OAAO,QAAQ,IAAI;CAC/B,QAAQ,OAAO;;CAEf,eAAe,OAAO,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