@dual-os/sdk 0.8.0-next.1 → 0.8.0-next.2
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 +18 -929
- package/dist/AgentChannel.d.ts.map +1 -1
- package/dist/AgentChannel.js +23 -157
- package/dist/AgentChannel.js.map +1 -1
- package/dist/AgentChannelConformance.d.ts +8 -500
- package/dist/AgentChannelConformance.d.ts.map +1 -1
- package/dist/AgentChannelConformance.js +3 -3
- package/dist/AgentChannelConformance.js.map +1 -1
- package/dist/AgentChannelRuntime.d.ts.map +1 -1
- package/dist/AgentChannelRuntime.js +6 -7
- package/dist/AgentChannelRuntime.js.map +1 -1
- package/dist/internal/dual/registry.d.ts +1 -3
- package/dist/internal/dual/registry.d.ts.map +1 -1
- package/dist/internal/dual/registry.js.map +1 -1
- package/dist/internal/plugin-handlers.js +4 -2
- package/dist/internal/plugin-handlers.js.map +1 -1
- package/package.json +1 -1
- package/src/AgentChannel.ts +23 -149
- package/src/AgentChannelConformance.ts +2 -6
- package/src/AgentChannelRuntime.ts +9 -13
- package/src/internal/dual/registry.ts +0 -2
- package/src/internal/plugin-handlers.ts +5 -2
|
@@ -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
|
|
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;;;;;;;;;;;;;;;;;;;YAmBT,kBAAkB,SAAS;qBAqB1B,aAAW,OAAA;;;;;YAKZ,qBAAqB,YAAY;qBAChC,OAAK,OAAA;;;;;q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WACG,UAAU;WAA0B,OAAOC,MAAiB;;YAGnE,eAAe,UAAU;WAC1B,oBAAoB;WACpB,oBAAoB;KAC1B,2DAEc;WACF,OAAO,aAAa;;WACpB,MAAM,aAAa;;;YAExB,WAAW,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;;qBAmFV,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
|
@@ -21,7 +21,6 @@ var AgentChannel_exports = /* @__PURE__ */ __exportAll({
|
|
|
21
21
|
Echo: () => Echo,
|
|
22
22
|
ErrorCode: () => ErrorCode,
|
|
23
23
|
Event: () => Event,
|
|
24
|
-
EventV2: () => EventV2,
|
|
25
24
|
Exposure: () => Exposure,
|
|
26
25
|
FailureCode: () => FailureCode,
|
|
27
26
|
Features: () => Features,
|
|
@@ -32,7 +31,6 @@ var AgentChannel_exports = /* @__PURE__ */ __exportAll({
|
|
|
32
31
|
OperationKind: () => OperationKind,
|
|
33
32
|
Plan: () => Plan,
|
|
34
33
|
PlanItem: () => PlanItem,
|
|
35
|
-
Protocol: () => Protocol,
|
|
36
34
|
Reaction: () => Reaction,
|
|
37
35
|
Request: () => Request,
|
|
38
36
|
RequiredChecks: () => RequiredChecks,
|
|
@@ -43,7 +41,6 @@ var AgentChannel_exports = /* @__PURE__ */ __exportAll({
|
|
|
43
41
|
VerifiedIdentity: () => VerifiedIdentity,
|
|
44
42
|
WebhookResponse: () => WebhookResponse,
|
|
45
43
|
commandSchema: () => commandSchema,
|
|
46
|
-
commandSchemaV2: () => commandSchemaV2,
|
|
47
44
|
contextResult: () => contextResult,
|
|
48
45
|
handlerKey: () => handlerKey,
|
|
49
46
|
isAgentChannel: () => isAgentChannel,
|
|
@@ -51,20 +48,12 @@ var AgentChannel_exports = /* @__PURE__ */ __exportAll({
|
|
|
51
48
|
projectContract: () => projectContract,
|
|
52
49
|
resultByteLimit: () => resultByteLimit,
|
|
53
50
|
resultSchema: () => resultSchema,
|
|
54
|
-
resultSchemaV2: () => resultSchemaV2,
|
|
55
|
-
schemasFor: () => schemasFor,
|
|
56
51
|
validateDefinition: () => validateDefinition
|
|
57
52
|
});
|
|
58
53
|
const TypeId = "@dual-os/sdk/AgentChannel";
|
|
59
54
|
/** Keys are opaque and installation-scoped. Never parse them into product identities. */
|
|
60
55
|
const Key = Schema.NonEmptyString.check(Schema.isMaxLength(512), Schema.isPattern(/^[^\p{Cc}]+$/u));
|
|
61
|
-
/**
|
|
62
|
-
* The command and result schemas a version uses. Absent means the original protocol, whose
|
|
63
|
-
* projection stays byte-identical for contracts already published with it. `v2` adds the stop
|
|
64
|
-
* event, conversation reads and output operations.
|
|
65
|
-
*/
|
|
66
|
-
const Protocol = Schema.Literals(["v2"]);
|
|
67
|
-
/** What a `v2` destination can show. Every channel shows `present_outcome`. */
|
|
56
|
+
/** What a destination can show. Every channel shows `present_outcome`. */
|
|
68
57
|
const OperationKind = Schema.Literals([
|
|
69
58
|
"present_outcome",
|
|
70
59
|
"create_message",
|
|
@@ -84,9 +73,9 @@ const Features = Schema.Struct({
|
|
|
84
73
|
/** Maximum Unicode code points per physical text message, including server-added prefixes. */
|
|
85
74
|
maxTextLength: Schema.optionalKey(Schema.Int.check(Schema.isGreaterThan(0))),
|
|
86
75
|
mentions: Schema.Boolean,
|
|
87
|
-
/**
|
|
76
|
+
/** Every definition declares operations; retired catalog contracts still decode without them. */
|
|
88
77
|
operations: Schema.optionalKey(Schema.Array(OperationKind)),
|
|
89
|
-
/**
|
|
78
|
+
/** Whether `read_context` returns the conversation's earlier messages. */
|
|
90
79
|
readContext: Schema.optionalKey(Schema.Boolean),
|
|
91
80
|
replies: Schema.Boolean,
|
|
92
81
|
/** Maximum age of the original responding input before preparation and delivery. */
|
|
@@ -194,12 +183,7 @@ const Echo = Schema.Struct({
|
|
|
194
183
|
messageKey: Key,
|
|
195
184
|
timestamp: Timestamp
|
|
196
185
|
});
|
|
197
|
-
|
|
198
|
-
Message,
|
|
199
|
-
Echo,
|
|
200
|
-
DeliveryUpdate
|
|
201
|
-
]);
|
|
202
|
-
/** `v2`: the sender asked the agent to stop working in this conversation. Access applies. */
|
|
186
|
+
/** The sender asked the agent to stop working in this conversation. Access applies. */
|
|
203
187
|
const Stop = Schema.Struct({
|
|
204
188
|
...VerifiedIdentity.fields,
|
|
205
189
|
eventKey: Key,
|
|
@@ -207,13 +191,13 @@ const Stop = Schema.Struct({
|
|
|
207
191
|
kind: Schema.Literal("stop"),
|
|
208
192
|
timestamp: Timestamp
|
|
209
193
|
});
|
|
210
|
-
const
|
|
194
|
+
const Event = Schema.Union([
|
|
211
195
|
Message,
|
|
212
196
|
Echo,
|
|
213
197
|
DeliveryUpdate,
|
|
214
198
|
Stop
|
|
215
199
|
]);
|
|
216
|
-
/** The reactions every
|
|
200
|
+
/** The reactions every provider can show. Each provider maps them to its own emoji. */
|
|
217
201
|
const Reaction = Schema.Literals([
|
|
218
202
|
"thumbs_up",
|
|
219
203
|
"thumbs_down",
|
|
@@ -242,7 +226,7 @@ const Plan = Schema.Struct({
|
|
|
242
226
|
title: Schema.optionalKey(Schema.NonEmptyString.check(Schema.isMaxLength(256)))
|
|
243
227
|
});
|
|
244
228
|
/**
|
|
245
|
-
* One piece of
|
|
229
|
+
* One piece of output. A `reference` is the `providerDeliveryKey` the provider returned for
|
|
246
230
|
* the message or plan it made; only that provider reads it.
|
|
247
231
|
*/
|
|
248
232
|
const Operation = Schema.Union([
|
|
@@ -336,43 +320,6 @@ var ChannelError = class extends Schema.TaggedError()("AgentChannelError", {
|
|
|
336
320
|
}
|
|
337
321
|
};
|
|
338
322
|
const installedCommandSchema = (state) => {
|
|
339
|
-
const operation = {
|
|
340
|
-
extensions: Schema.optionalKey(Extensions),
|
|
341
|
-
operationKey: Key
|
|
342
|
-
};
|
|
343
|
-
const installed = {
|
|
344
|
-
...operation,
|
|
345
|
-
installationKey: Key,
|
|
346
|
-
state
|
|
347
|
-
};
|
|
348
|
-
return Schema.Union([
|
|
349
|
-
Schema.Struct({
|
|
350
|
-
kind: Schema.Literal("activate"),
|
|
351
|
-
...operation,
|
|
352
|
-
ingressUrl: HttpUrl,
|
|
353
|
-
state: Schema.optionalKey(state)
|
|
354
|
-
}),
|
|
355
|
-
Schema.Struct({
|
|
356
|
-
kind: Schema.Literal("deactivate"),
|
|
357
|
-
...installed
|
|
358
|
-
}),
|
|
359
|
-
Schema.Struct({
|
|
360
|
-
kind: Schema.Literal("receive"),
|
|
361
|
-
...installed,
|
|
362
|
-
request: Request
|
|
363
|
-
}),
|
|
364
|
-
Schema.Struct({
|
|
365
|
-
kind: Schema.Literal("deliver"),
|
|
366
|
-
...installed,
|
|
367
|
-
deliveryKey: Key,
|
|
368
|
-
destination: Destination,
|
|
369
|
-
content: Content,
|
|
370
|
-
/** Original responding input timestamp; retries must preserve this reference. */
|
|
371
|
-
responseToTimestamp: Schema.optionalKey(Timestamp)
|
|
372
|
-
})
|
|
373
|
-
]);
|
|
374
|
-
};
|
|
375
|
-
const installedCommandSchemaV2 = (state) => {
|
|
376
323
|
const operation = {
|
|
377
324
|
extensions: Schema.optionalKey(Extensions),
|
|
378
325
|
operationKey: Key
|
|
@@ -464,65 +411,6 @@ const installedResultSchema = (state) => {
|
|
|
464
411
|
status: Schema.Literal("pending"),
|
|
465
412
|
providerDeliveryKey: Key
|
|
466
413
|
}),
|
|
467
|
-
Schema.Struct({
|
|
468
|
-
kind: Schema.Literal("deliver"),
|
|
469
|
-
...operation,
|
|
470
|
-
deliveryKey: Key,
|
|
471
|
-
status: Schema.Literal("failed"),
|
|
472
|
-
code: Schema.Literals([
|
|
473
|
-
"rejected",
|
|
474
|
-
"unauthorized",
|
|
475
|
-
"rate_limited",
|
|
476
|
-
"unavailable",
|
|
477
|
-
"window_closed"
|
|
478
|
-
])
|
|
479
|
-
})
|
|
480
|
-
]);
|
|
481
|
-
};
|
|
482
|
-
const installedResultSchemaV2 = (state) => {
|
|
483
|
-
const operation = {
|
|
484
|
-
extensions: Schema.optionalKey(Extensions),
|
|
485
|
-
operationKey: Key
|
|
486
|
-
};
|
|
487
|
-
return Schema.Union([
|
|
488
|
-
Schema.Struct({
|
|
489
|
-
kind: Schema.Literal("activate"),
|
|
490
|
-
...operation,
|
|
491
|
-
installationKey: Key,
|
|
492
|
-
state,
|
|
493
|
-
/** Durable read-only provider state that the host must persist before retrying activation. */
|
|
494
|
-
checkpoint: Schema.optionalKey(Schema.Literal(true)),
|
|
495
|
-
/** The host must observe a verified webhook handshake before cutover. */
|
|
496
|
-
verification: Schema.optionalKey(Schema.Literal("ingress"))
|
|
497
|
-
}),
|
|
498
|
-
Schema.Struct({
|
|
499
|
-
kind: Schema.Literal("deactivate"),
|
|
500
|
-
...operation
|
|
501
|
-
}),
|
|
502
|
-
Schema.Struct({
|
|
503
|
-
kind: Schema.Literal("receive"),
|
|
504
|
-
...operation,
|
|
505
|
-
verified: Schema.Literal(true),
|
|
506
|
-
deniedEventKeys: Schema.optionalKey(Schema.Array(Key).check(Schema.isMaxLength(100))),
|
|
507
|
-
events: Schema.Array(EventV2).check(Schema.isMaxLength(100)),
|
|
508
|
-
response: Schema.optionalKey(WebhookResponse),
|
|
509
|
-
/** A provider-native setup challenge or ping proved the configured ingress. */
|
|
510
|
-
activationProof: Schema.optionalKey(Schema.Literal("verified"))
|
|
511
|
-
}),
|
|
512
|
-
Schema.Struct({
|
|
513
|
-
kind: Schema.Literal("deliver"),
|
|
514
|
-
...operation,
|
|
515
|
-
deliveryKey: Key,
|
|
516
|
-
status: Schema.Literal("succeeded"),
|
|
517
|
-
providerDeliveryKey: Key
|
|
518
|
-
}),
|
|
519
|
-
Schema.Struct({
|
|
520
|
-
kind: Schema.Literal("deliver"),
|
|
521
|
-
...operation,
|
|
522
|
-
deliveryKey: Key,
|
|
523
|
-
status: Schema.Literal("pending"),
|
|
524
|
-
providerDeliveryKey: Key
|
|
525
|
-
}),
|
|
526
414
|
Schema.Struct({
|
|
527
415
|
kind: Schema.Literal("deliver"),
|
|
528
416
|
...operation,
|
|
@@ -561,8 +449,6 @@ const readAssetResult = Schema.Struct({
|
|
|
561
449
|
});
|
|
562
450
|
const commandSchema = (state) => Schema.Union([installedCommandSchema(state), readAssetCommand(state)]);
|
|
563
451
|
const resultSchema = (state) => Schema.Union([installedResultSchema(state), readAssetResult]);
|
|
564
|
-
const commandSchemaV2 = (state) => Schema.Union([installedCommandSchemaV2(state), readAssetCommand(state)]);
|
|
565
|
-
const resultSchemaV2 = (state) => Schema.Union([installedResultSchemaV2(state), readAssetResult]);
|
|
566
452
|
/** Maximum UTF-8 bytes in an ordinary Channel command or result, including its JSON envelope. */
|
|
567
453
|
const resultByteLimit = 2097152;
|
|
568
454
|
/** Keep the newest context messages within the checked result budget, oldest first. */
|
|
@@ -585,50 +471,32 @@ function contextResult(operationKey, context) {
|
|
|
585
471
|
}
|
|
586
472
|
return result;
|
|
587
473
|
}
|
|
588
|
-
/**
|
|
589
|
-
const
|
|
590
|
-
command: commandSchemaV2(definition.state),
|
|
591
|
-
result: resultSchemaV2(definition.state),
|
|
592
|
-
typeResult: resultSchemaV2(Schema.toType(definition.state))
|
|
593
|
-
} : {
|
|
594
|
-
command: commandSchema(definition.state),
|
|
595
|
-
result: resultSchema(definition.state),
|
|
596
|
-
typeResult: resultSchema(Schema.toType(definition.state))
|
|
597
|
-
};
|
|
598
|
-
/**
|
|
599
|
-
* Encoded, JSON-safe runtime result suitable for host persistence. It accepts both protocols;
|
|
600
|
-
* a `v1` result decodes unchanged.
|
|
601
|
-
*/
|
|
602
|
-
const CheckedResult = resultSchemaV2(Schema.Json);
|
|
474
|
+
/** Encoded, JSON-safe runtime result suitable for host persistence. */
|
|
475
|
+
const CheckedResult = resultSchema(Schema.Json);
|
|
603
476
|
/** Immutable catalog projection. Live schemas remain the execution validators. */
|
|
604
477
|
const Contract = Schema.Struct({
|
|
605
478
|
definitionSettingsSchemaJson: Schema.Json,
|
|
606
479
|
deploymentSettingsSchemaJson: Schema.Json,
|
|
607
480
|
exposure: Exposure,
|
|
608
481
|
extensionsSchemaJson: Schema.Record(Schema.String, Schema.Json),
|
|
609
|
-
featuresJson: Features,
|
|
482
|
+
featuresJson: Features.check(Schema.makeFilter((features) => (features.operations ?? []).includes("present_outcome"))),
|
|
610
483
|
operationInputSchemaJson: Schema.Json,
|
|
611
484
|
operationOutputSchemaJson: Schema.Json,
|
|
612
|
-
protocol: Schema.optionalKey(Protocol),
|
|
613
485
|
requiredChecks: RequiredChecks,
|
|
614
486
|
stateSchemaJson: Schema.Json
|
|
615
487
|
});
|
|
616
488
|
/** Project the exact declaration once for SDK discovery and server contract comparison. */
|
|
617
|
-
const projectContract = (definition, project = (schema) => Schema.toJsonSchemaDocument(schema, { onExcessProperty: "error" })) => {
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
requiredChecks: definition.requiredChecks,
|
|
629
|
-
stateSchemaJson: project(definition.state)
|
|
630
|
-
}, { onExcessProperty: "error" });
|
|
631
|
-
};
|
|
489
|
+
const projectContract = (definition, project = (schema) => Schema.toJsonSchemaDocument(schema, { onExcessProperty: "error" })) => Schema.decodeUnknownSync(Contract)({
|
|
490
|
+
definitionSettingsSchemaJson: project(definition.definitionSettings),
|
|
491
|
+
deploymentSettingsSchemaJson: project(definition.deploymentSettings),
|
|
492
|
+
exposure: definition.exposure,
|
|
493
|
+
extensionsSchemaJson: Object.fromEntries(Object.entries(definition.extensions ?? {}).map(([key, schema]) => [key, project(schema)])),
|
|
494
|
+
featuresJson: definition.features,
|
|
495
|
+
operationInputSchemaJson: project(commandSchema(definition.state)),
|
|
496
|
+
operationOutputSchemaJson: project(resultSchema(definition.state)),
|
|
497
|
+
requiredChecks: definition.requiredChecks,
|
|
498
|
+
stateSchemaJson: project(definition.state)
|
|
499
|
+
}, { onExcessProperty: "error" });
|
|
632
500
|
const handlerKey = (channelId) => `@dual-os/sdk/AgentChannel/Handler/${channelId}`;
|
|
633
501
|
const SchemaDefinition = Schema.declare(Schema.isSchema);
|
|
634
502
|
const checkSchema = (schema, allowOpaque = false) => {
|
|
@@ -670,11 +538,9 @@ const DefinitionSchema = Schema.Struct({
|
|
|
670
538
|
exposure: Exposure,
|
|
671
539
|
extensions: Schema.optionalKey(Schema.Record(Schema.String, SchemaDefinition).check(Schema.makeFilter((values) => Object.keys(values).every(Schema.is(ExtensionKey))))),
|
|
672
540
|
features: Features,
|
|
673
|
-
protocol: Schema.optionalKey(Protocol),
|
|
674
541
|
requiredChecks: RequiredChecks,
|
|
675
542
|
state: SchemaDefinition
|
|
676
|
-
}).check(Schema.makeFilter(({ features
|
|
677
|
-
if (protocol === void 0) return features.operations === void 0 && features.readContext === void 0;
|
|
543
|
+
}).check(Schema.makeFilter(({ features }) => {
|
|
678
544
|
const operations = features.operations ?? [];
|
|
679
545
|
return operations.includes("present_outcome") && new Set(operations).size === operations.length && (features.maxTextLength === void 0 || operations.includes("create_message"));
|
|
680
546
|
}));
|
|
@@ -729,6 +595,6 @@ const make = (identifier, options) => {
|
|
|
729
595
|
};
|
|
730
596
|
};
|
|
731
597
|
const isAgentChannel = (value) => Predicate.hasProperty(value, TypeId);
|
|
732
|
-
export { AccessOutcome, AgentChannel_exports as AgentChannel, AgentChannel_exports, Asset, AssetFile, ChannelError, CheckedResult, Content, ContextMessage, Contract, DeliveryUpdate, Destination, Echo, ErrorCode, Event,
|
|
598
|
+
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 };
|
|
733
599
|
|
|
734
600
|
//# 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/**\n * The command and result schemas a version uses. Absent means the original protocol, whose\n * projection stays byte-identical for contracts already published with it. `v2` adds the stop\n * event, conversation reads and output operations.\n */\nexport const Protocol = Schema.Literals([\"v2\"]);\nexport type Protocol = typeof Protocol.Type;\n/** What a `v2` 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 /** `v2` only: the output operations every destination of this version shows. */\n operations: Schema.optionalKey(Schema.Array(OperationKind)),\n /** `v2` only: 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});\nexport const Event = Schema.Union([Message, Echo, DeliveryUpdate]);\nexport type Event = typeof Event.Type;\n/** `v2`: 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 EventV2 = Schema.Union([Message, Echo, DeliveryUpdate, Stop]);\nexport type EventV2 = typeof EventV2.Type;\n\n/** The reactions every `v2` 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 `v2` 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;\n/** A message read back from the provider's conversation history. */\nexport const ContextMessage = Schema.Struct({\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});\nexport type ContextMessage = typeof ContextMessage.Type;\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 deliveryKey: Key,\n destination: Destination,\n content: Content,\n /** Original responding input timestamp; retries must preserve this reference. */\n responseToTimestamp: Schema.optionalKey(Timestamp),\n }),\n ]);\n};\n\nconst installedCommandSchemaV2 = <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) => {\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 ]);\n};\n// `v2` keeps every `v1` result except `receive`, which also carries stop events.\nconst installedResultSchemaV2 = <State extends Schema.Top>(state: State) => {\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(EventV2).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 messages: Schema.Array(ContextMessage).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)]);\nexport const resultSchema = <State extends Schema.Top>(state: State) =>\n Schema.Union([installedResultSchema(state), readAssetResult]);\nexport const commandSchemaV2 = <State extends Schema.Top>(state: State) =>\n Schema.Union([installedCommandSchemaV2(state), readAssetCommand(state)]);\nexport const resultSchemaV2 = <State extends Schema.Top>(state: State) =>\n Schema.Union([installedResultSchemaV2(state), 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\"];\nexport type CommandV2<State extends Schema.Top = Schema.Unknown> = ReturnType<\n typeof commandSchemaV2<State>\n>[\"Type\"];\nexport type ResultV2<State extends Schema.Top = Schema.Unknown> = ReturnType<\n typeof resultSchemaV2<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<ResultV2, { 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/** The command and result schemas of a Channel's protocol. */\nexport const schemasFor = (definition: Pick<Definition, \"protocol\" | \"state\">) =>\n definition.protocol === \"v2\"\n ? {\n command: commandSchemaV2(definition.state),\n result: resultSchemaV2(definition.state),\n typeResult: resultSchemaV2(Schema.toType(definition.state)),\n }\n : {\n command: commandSchema(definition.state),\n result: resultSchema(definition.state),\n typeResult: resultSchema(Schema.toType(definition.state)),\n };\n\n/**\n * Encoded, JSON-safe runtime result suitable for host persistence. It accepts both protocols;\n * a `v1` result decodes unchanged.\n */\nexport const CheckedResult = resultSchemaV2(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,\n operationInputSchemaJson: Schema.Json,\n operationOutputSchemaJson: Schema.Json,\n protocol: Schema.optionalKey(Protocol),\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 /** Absent for the original protocol. Publish a new release to change it. */\n readonly protocol?: Protocol;\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 const schemas = schemasFor(definition);\n return 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(schemas.command),\n operationOutputSchemaJson: project(schemas.result),\n ...(definition.protocol === undefined ? {} : { protocol: definition.protocol }),\n requiredChecks: definition.requiredChecks,\n stateSchemaJson: project(definition.state),\n },\n { onExcessProperty: \"error\" },\n );\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, by its protocol. */\nexport type CommandFor<D extends Definition> = D extends { readonly protocol: \"v2\" }\n ? CommandV2<D[\"state\"]>\n : Command<D[\"state\"]>;\n/** The result a Channel's handler returns, by its protocol. */\nexport type ResultFor<D extends Definition> = D extends { readonly protocol: \"v2\" }\n ? ResultV2<D[\"state\"]>\n : 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 protocol: Schema.optionalKey(Protocol),\n requiredChecks: RequiredChecks,\n state: SchemaDefinition,\n}).check(\n Schema.makeFilter(({ features, protocol }) => {\n if (protocol === undefined) {\n return features.operations === undefined && features.readContext === undefined;\n }\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;;;;;;AAMA,MAAa,WAAW,OAAO,SAAS,CAAC,IAAI,CAAC;;AAG9C,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;;CAEjB,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,MAC5B,OAAO,YAAY,IAAI,GACvB,OAAO,YAAW,UAAS;CACzB,MAAM,MAAM,IAAI,MAAM,KAAK;CAC3B,OACE,QAAQ,SACP,IAAI,aAAa,YAAY,IAAI,aAAa,YAC/C,IAAI,aAAa,MACjB,IAAI,aAAa;AAErB,CAAC,CACH;AACA,MAAM,OAAO,OAAO,O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,WAAW,EAAE,CAAC,GAEtF,MAAM,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;CAEzD,QAAQ;EACN,MAAM,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;CACvD;AACF;;AAQA,MAAa,QACX,YACA,YACwB;CACxB,mBAAmB,iBAAiB,UAAU;CAC9C,MAAM,EAAE,aAAa,MAAM,GAAG,eAA4C;CAC1E,mBAAmB,UAAU;CAC7B,OAAO;EACL,GAAG;GACF,SAAS;EACV,YAAY,OAAO,OAAO;GACxB,GAAG;GACH,aAAa,OAAO,OAAO,CAAC,GAAG,WAAW,WAAW,CAAC;GACtD,UAAU,OAAO,OAAO,EAAE,GAAG,WAAW,SAAS,CAAC;GAClD,gBAAgB,OAAO,OAAO,CAAC,GAAG,WAAW,cAAc,CAAC;GAC5D,GAAI,WAAW,eAAe,KAAA,IAC1B,CAAC,IACD,EAAE,YAAY,OAAO,OAAO,EAAE,GAAG,WAAW,WAAW,CAAC,EAAE;EAChE,CAAC;EACD;EACA;EACA;CACF;AACF;AACA,MAAa,kBAAkB,UAC7B,UAAU,YAAY,OAAO,MAAM"}
|
|
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 /** Every definition declares operations; retired catalog contracts still decode without them. */\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;\n/** A message read back from the provider's conversation history. */\nexport const ContextMessage = Schema.Struct({\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});\nexport type ContextMessage = typeof ContextMessage.Type;\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) => {\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 messages: Schema.Array(ContextMessage).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)]);\nexport const resultSchema = <State extends Schema.Top>(state: State) =>\n Schema.Union([installedResultSchema(state), 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)),\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;;CAEjB,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,MAC5B,OAAO,YAAY,IAAI,GACvB,OAAO,YAAW,UAAS;CACzB,MAAM,MAAM,IAAI,MAAM,KAAK;CAC3B,OACE,QAAQ,SACP,IAAI,aAAa,YAAY,IAAI,aAAa,YAC/C,IAAI,aAAa,MACjB,IAAI,aAAa;AAErB,CAAC,CACH;AACA,MAAM,OAAO,OAAO,OAAO,MAAM,OAAO,YAAY,KAAM,CAAC;AAC3D,MAAM,eAAe,OAAO,OAAO,MACjC,OAAO,UAAU,sDAAsD,C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