@dual-os/sdk 0.8.0-next.0 → 0.8.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +5 -17
  2. package/dist/Action.d.ts +0 -1
  3. package/dist/Action.js +1 -2
  4. package/dist/AgentChannel.d.ts +11 -3
  5. package/dist/AgentChannel.d.ts.map +1 -1
  6. package/dist/AgentChannel.js +31 -5
  7. package/dist/AgentChannel.js.map +1 -1
  8. package/dist/AgentChannelConformance.d.ts +0 -1
  9. package/dist/AgentChannelConformance.js +1 -2
  10. package/dist/AgentChannelRuntime.d.ts +0 -1
  11. package/dist/AgentChannelRuntime.d.ts.map +1 -1
  12. package/dist/AgentChannelRuntime.js +3 -4
  13. package/dist/AgentChannelRuntime.js.map +1 -1
  14. package/dist/AiProvider.d.ts +0 -1
  15. package/dist/AiProvider.js +1 -2
  16. package/dist/AuthMethod.d.ts +0 -1
  17. package/dist/AuthMethod.js +1 -2
  18. package/dist/AuthMethodBinding.d.ts +0 -1
  19. package/dist/AuthMethodBinding.js +1 -2
  20. package/dist/AuthMethodExecution.d.ts +0 -1
  21. package/dist/AuthMethodExecution.js +1 -2
  22. package/dist/ConnectionResolver.d.ts +0 -1
  23. package/dist/ConnectionResolver.js +1 -2
  24. package/dist/DefinitionError.d.ts +0 -1
  25. package/dist/DefinitionError.js +1 -2
  26. package/dist/DualRegistry.d.ts +0 -1
  27. package/dist/DualRegistry.js +1 -2
  28. package/dist/DualRuntime.d.ts +0 -1
  29. package/dist/DualRuntime.js +1 -2
  30. package/dist/Files.d.ts +0 -1
  31. package/dist/Files.js +1 -2
  32. package/dist/Group.d.ts +0 -1
  33. package/dist/Group.js +1 -2
  34. package/dist/Http.d.ts +0 -1
  35. package/dist/Http.d.ts.map +1 -1
  36. package/dist/Http.js +4 -5
  37. package/dist/Http.js.map +1 -1
  38. package/dist/Mcp.d.ts +0 -1
  39. package/dist/Mcp.js +1 -2
  40. package/dist/OAuth2TokenRefresher.d.ts +0 -1
  41. package/dist/OAuth2TokenRefresher.js +1 -2
  42. package/dist/OAuthFlow.d.ts +0 -1
  43. package/dist/OAuthFlow.js +1 -2
  44. package/dist/Plugin.d.ts +0 -1
  45. package/dist/Plugin.js +1 -2
  46. package/dist/PluginRuntime.d.ts +0 -1
  47. package/dist/PluginRuntime.js +1 -2
  48. package/dist/Runner.js +3 -4
  49. package/dist/Runner.js.map +1 -1
  50. package/dist/ToolFile.d.ts +0 -1
  51. package/dist/ToolFile.js +1 -2
  52. package/dist/Trigger.d.ts +0 -1
  53. package/dist/Trigger.js +1 -2
  54. package/dist/_virtual/_rolldown/runtime.js +1 -2
  55. package/dist/internal/auth-context.d.ts +0 -2
  56. package/dist/internal/auth-context.d.ts.map +1 -1
  57. package/dist/internal/auth-execution.d.ts +0 -2
  58. package/dist/internal/auth-execution.d.ts.map +1 -1
  59. package/dist/internal/auth-execution.js +1 -2
  60. package/dist/internal/auth-runtime.d.ts +0 -2
  61. package/dist/internal/auth-runtime.d.ts.map +1 -1
  62. package/dist/internal/auth-runtime.js +1 -2
  63. package/dist/internal/capabilities.d.ts +0 -2
  64. package/dist/internal/capabilities.d.ts.map +1 -1
  65. package/dist/internal/capabilities.js +1 -2
  66. package/dist/internal/children.d.ts +0 -2
  67. package/dist/internal/children.d.ts.map +1 -1
  68. package/dist/internal/children.js +1 -2
  69. package/dist/internal/collection-utils.d.ts +0 -2
  70. package/dist/internal/collection-utils.d.ts.map +1 -1
  71. package/dist/internal/collection-utils.js +1 -2
  72. package/dist/internal/dual/actions.d.ts +0 -2
  73. package/dist/internal/dual/actions.d.ts.map +1 -1
  74. package/dist/internal/dual/actions.js +1 -2
  75. package/dist/internal/dual/invoke.d.ts +0 -2
  76. package/dist/internal/dual/invoke.d.ts.map +1 -1
  77. package/dist/internal/dual/invoke.js +1 -2
  78. package/dist/internal/dual/registry.d.ts +0 -2
  79. package/dist/internal/dual/registry.d.ts.map +1 -1
  80. package/dist/internal/dual/registry.js +1 -2
  81. package/dist/internal/dual/triggers.d.ts +0 -2
  82. package/dist/internal/dual/triggers.d.ts.map +1 -1
  83. package/dist/internal/dual/triggers.js +1 -2
  84. package/dist/internal/handler-context.d.ts +0 -2
  85. package/dist/internal/handler-context.d.ts.map +1 -1
  86. package/dist/internal/handler-context.js +1 -2
  87. package/dist/internal/identifier.d.ts +0 -2
  88. package/dist/internal/identifier.d.ts.map +1 -1
  89. package/dist/internal/identifier.js +1 -2
  90. package/dist/internal/plugin-handlers.d.ts +0 -2
  91. package/dist/internal/plugin-handlers.d.ts.map +1 -1
  92. package/dist/internal/plugin-handlers.js +1 -2
  93. package/dist/internal/proto.d.ts +0 -2
  94. package/dist/internal/proto.d.ts.map +1 -1
  95. package/dist/internal/proto.js +1 -2
  96. package/dist/internal/schema-runtime.d.ts +0 -2
  97. package/dist/internal/schema-runtime.d.ts.map +1 -1
  98. package/dist/internal/schema-runtime.js +1 -2
  99. package/dist/internal/trigger-runtime-shared.d.ts +0 -2
  100. package/dist/internal/trigger-runtime-shared.d.ts.map +1 -1
  101. package/dist/internal/trigger-runtime-shared.js +1 -2
  102. package/dist/internal/trigger-runtime.d.ts +0 -2
  103. package/dist/internal/trigger-runtime.d.ts.map +1 -1
  104. package/dist/internal/trigger-runtime.js +1 -2
  105. package/dist/internal/types.d.ts +0 -2
  106. package/dist/internal/types.d.ts.map +1 -1
  107. package/dist/remote-runtime.d.ts +0 -1
  108. package/dist/remote-runtime.js +1 -2
  109. package/package.json +6 -7
  110. package/src/AgentChannel.ts +30 -2
  111. package/src/AgentChannelRuntime.ts +2 -1
  112. package/src/Http.ts +21 -4
  113. package/src/Runner.ts +5 -4
package/README.md CHANGED
@@ -1,20 +1,8 @@
1
1
  # @dual-os/sdk
2
2
 
3
- Dual's runtime-neutral typed definition layer. Requires exactly the Effect version declared in `dependencies`; importing the SDK starts no services. No Bun or Node runtime APIs are required.
3
+ Runtime-neutral integration definitions and execution. Importing the SDK starts no services.
4
4
 
5
- ```ts
6
- import { Action, Dual, Group, Provider } from "@dual-os/sdk";
7
- import * as Plugin from "@dual-os/sdk/Plugin";
8
- ```
9
-
10
- The root, `package.json`, and named top-level modules listed in `exports` are supported public entrypoints. Internal modules ship only to support those entrypoints and are not public imports.
11
-
12
- ## Build and pack
13
-
14
- From this directory, `vp run build` uses `vp pack` to emit module-preserving ESM JavaScript, declarations and maps into `dist/`. Both workspace and installed-package exports point to those files.
15
-
16
- Run `bun pm pack --destination /absolute/output/directory` to create a tarball. The `prepack` hook runs the cached Vite+ build; Bun replaces workspace dependency references with versions. No manifest rewriting, alternate package manager or bundling is needed. Do not publish directly from a developer checkout.
17
-
18
- Source and declaration maps resolve to shipped `src/` files. Tests and development configuration are excluded. This is ESM-only, not dependency-free.
19
-
20
- Private distribution only; see LICENSE.
5
+ - **Start.** [SDK guide](../docs/content/sdk/index.mdx) and [checked examples](../docs/examples/).
6
+ - **Public API.** The installed package's `exports` and declarations; shipped implementation modules are not supported entrypoints.
7
+ - **Hosting.** [Runtime guide](../docs/content/sdk/runtime.mdx); the SDK does not provision a product deployment.
8
+ - **Distribution.** Private registry access; [release procedure](../../docs/releasing.md).
package/dist/Action.d.ts CHANGED
@@ -196,6 +196,5 @@ export declare const make: <const Identifier extends string, Input extends Schem
196
196
  * @category guards
197
197
  */
198
198
  export declare const isAction: (u: unknown) => u is Any;
199
- //#endregion
200
199
  export { Action_d_exports };
201
200
  //# sourceMappingURL=Action.d.ts.map
package/dist/Action.js CHANGED
@@ -3,7 +3,7 @@ import { validateIdentifier } from "./internal/identifier.js";
3
3
  import { PipeableProto } from "./internal/proto.js";
4
4
  import { Array, DateTime, Duration, Effect, Match, Number, Option, Predicate, Schema, pipe } from "effect";
5
5
  import { Headers, HttpClientError } from "effect/http";
6
- //#region src/Action.ts
6
+ // src/Action.ts
7
7
  var Action_exports = /* @__PURE__ */ __exportAll({
8
8
  ActionHandlerError: () => ActionHandlerError,
9
9
  RetryableActionHandlerError: () => RetryableActionHandlerError,
@@ -166,7 +166,6 @@ const make = (identifier, options) => {
166
166
  * @category guards
167
167
  */
168
168
  const isAction = (u) => Predicate.hasProperty(u, TypeId);
169
- //#endregion
170
169
  export { ActionHandlerError, Action_exports, RetryableActionHandlerError, TypeId, fromHttpClientFailure, handlerKey, isAction, make, orHttpClientFailure };
171
170
 
172
171
  //# sourceMappingURL=Action.js.map
@@ -2,7 +2,7 @@ import { Any as Any$1, Value } from "./AuthMethod.js";
2
2
  import "./AgentChannel.js";
3
3
  import { Context, Effect, Pipeable, Schema } from "effect";
4
4
  declare namespace AgentChannel_d_exports {
5
- export { AccessOutcome, AgentChannel, Any, Asset, AssetFile, ChannelError, ChannelOptions, CheckedResult, Command, CommandFor, CommandV2, Content, ContextMessage, Contract, Definition, DeliveryUpdate, Destination, Echo, ErrorCode, Event, EventV2, Exposure, FailureCode, Features, Handler, HandlerContext, HandlerError, Key, Message, Operation, OperationKind, Plan, PlanItem, Protocol, Reaction, Request, RequiredChecks, ResolvedAuth, Result, ResultFor, ResultV2, RuntimeContract, Stop, Timestamp, TypeId, Verification, VerifiedIdentity, WebhookResponse, commandSchema, commandSchemaV2, handlerKey, isAgentChannel, make, projectContract, resultSchema, resultSchemaV2, schemasFor, validateDefinition };
5
+ export { AccessOutcome, AgentChannel, Any, Asset, AssetFile, ChannelError, ChannelOptions, CheckedResult, Command, CommandFor, CommandV2, Content, ContextMessage, Contract, Definition, DeliveryUpdate, Destination, Echo, ErrorCode, Event, EventV2, Exposure, FailureCode, Features, Handler, HandlerContext, HandlerError, Key, Message, Operation, OperationKind, Plan, PlanItem, Protocol, Reaction, Request, RequiredChecks, ResolvedAuth, Result, ResultFor, ResultV2, RuntimeContract, Stop, Timestamp, TypeId, Verification, VerifiedIdentity, WebhookResponse, commandSchema, commandSchemaV2, contextResult, handlerKey, isAgentChannel, make, projectContract, resultByteLimit, resultSchema, resultSchemaV2, schemasFor, validateDefinition };
6
6
  }
7
7
  export declare const TypeId: "@dual-os/sdk/AgentChannel";
8
8
  export type TypeId = typeof TypeId;
@@ -68,7 +68,10 @@ export declare const Request: Schema.Struct<{
68
68
  readonly url: Schema.String;
69
69
  }>;
70
70
  export type Request = typeof Request.Type;
71
- /** Bounded provider-required webhook response, returned only after request verification. */
71
+ /**
72
+ * Bounded provider-required webhook response, returned only after request verification. A 204 or
73
+ * 205 response has an empty body.
74
+ */
72
75
  export declare const WebhookResponse: Schema.Struct<{
73
76
  readonly body: Schema.String;
74
77
  readonly headers: Schema.optionalKey<Schema.$Record<Schema.NonEmptyString, Schema.String>>;
@@ -802,6 +805,12 @@ export type Command<State extends Schema.Top = Schema.Unknown> = ReturnType<type
802
805
  export type Result<State extends Schema.Top = Schema.Unknown> = ReturnType<typeof resultSchema<State>>["Type"];
803
806
  export type CommandV2<State extends Schema.Top = Schema.Unknown> = ReturnType<typeof commandSchemaV2<State>>["Type"];
804
807
  export type ResultV2<State extends Schema.Top = Schema.Unknown> = ReturnType<typeof resultSchemaV2<State>>["Type"];
808
+ /** Maximum UTF-8 bytes in an ordinary Channel command or result, including its JSON envelope. */
809
+ export declare const resultByteLimit = 2097152;
810
+ /** Keep the newest context messages within the checked result budget, oldest first. */
811
+ export declare function contextResult(operationKey: string, context: readonly ContextMessage[]): Extract<ResultV2, {
812
+ readonly kind: "read_context";
813
+ }>;
805
814
  /** The command and result schemas of a Channel's protocol. */
806
815
  export declare const schemasFor: (definition: Pick<Definition, "protocol" | "state">) => {
807
816
  command: Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
@@ -1712,6 +1721,5 @@ export interface ChannelOptions {
1712
1721
  /** Create a Channel from its contract. */
1713
1722
  export declare const make: <const Id extends string, const O extends Definition & ChannelOptions>(identifier: Id, options: O) => AgentChannel<Id, O>;
1714
1723
  export declare const isAgentChannel: (value: unknown) => value is Any;
1715
- //#endregion
1716
1724
  export { AgentChannel_d_exports };
1717
1725
  //# sourceMappingURL=AgentChannel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AgentChannel.d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AO;;;qBAGH,aAAU;;qBAuFV,qBAAkB,YACjB,YAAU,qBACH,mBACAD;iBAyCJ;WACN;WACA;;;qBAIE,aAAc,yBAAyB,UAAU,aAAa,gBAAc,YAC3E,IAAE,SACL,MACR,aAAa,IAAI;qBAqBP,iBAAc,mBAAqB,SAAS"}
@@ -5,7 +5,7 @@ import { isAuthMethod } from "./AuthMethod.js";
5
5
  import { Schema as Schema$1 } from "./ToolFile.js";
6
6
  import "./AgentChannel.js";
7
7
  import { Match, Predicate, Schema } from "effect";
8
- //#region src/AgentChannel.ts
8
+ // src/AgentChannel.ts
9
9
  var AgentChannel_exports = /* @__PURE__ */ __exportAll({
10
10
  AccessOutcome: () => AccessOutcome,
11
11
  AgentChannel: () => AgentChannel_exports,
@@ -44,10 +44,12 @@ var AgentChannel_exports = /* @__PURE__ */ __exportAll({
44
44
  WebhookResponse: () => WebhookResponse,
45
45
  commandSchema: () => commandSchema,
46
46
  commandSchemaV2: () => commandSchemaV2,
47
+ contextResult: () => contextResult,
47
48
  handlerKey: () => handlerKey,
48
49
  isAgentChannel: () => isAgentChannel,
49
50
  make: () => make,
50
51
  projectContract: () => projectContract,
52
+ resultByteLimit: () => resultByteLimit,
51
53
  resultSchema: () => resultSchema,
52
54
  resultSchemaV2: () => resultSchemaV2,
53
55
  schemasFor: () => schemasFor,
@@ -128,7 +130,10 @@ const Request = Schema.Struct({
128
130
  url: HttpUrl
129
131
  });
130
132
  const ResponseHeaders = Schema.Record(Schema.NonEmptyString.check(Schema.isMaxLength(256), Schema.isPattern(/^[a-z0-9-]+$/)), Schema.String.check(Schema.isMaxLength(8192))).check(Schema.makeFilter((headers) => Object.keys(headers).every((name) => name === "content-type" || name === "cache-control")));
131
- /** Bounded provider-required webhook response, returned only after request verification. */
133
+ /**
134
+ * Bounded provider-required webhook response, returned only after request verification. A 204 or
135
+ * 205 response has an empty body.
136
+ */
132
137
  const WebhookResponse = Schema.Struct({
133
138
  body: Schema.String.check(Schema.isMaxLength(65536), Schema.makeFilter((body) => new TextEncoder().encode(body).byteLength <= 65536)),
134
139
  headers: Schema.optionalKey(ResponseHeaders),
@@ -136,7 +141,7 @@ const WebhookResponse = Schema.Struct({
136
141
  maximum: 299,
137
142
  minimum: 200
138
143
  }))
139
- });
144
+ }).check(Schema.makeFilter((response) => response.status !== 204 && response.status !== 205 || response.body === ""));
140
145
  const Timestamp = Schema.String.check(Schema.isMaxLength(64), Schema.isPattern(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d+)?(?:Z|[+-]\d{2}:\d{2})$/), Schema.makeFilter((value) => {
141
146
  const year = Number(value.slice(0, 4));
142
147
  const month = Number(value.slice(5, 7));
@@ -558,6 +563,28 @@ const commandSchema = (state) => Schema.Union([installedCommandSchema(state), re
558
563
  const resultSchema = (state) => Schema.Union([installedResultSchema(state), readAssetResult]);
559
564
  const commandSchemaV2 = (state) => Schema.Union([installedCommandSchemaV2(state), readAssetCommand(state)]);
560
565
  const resultSchemaV2 = (state) => Schema.Union([installedResultSchemaV2(state), readAssetResult]);
566
+ /** Maximum UTF-8 bytes in an ordinary Channel command or result, including its JSON envelope. */
567
+ const resultByteLimit = 2097152;
568
+ /** Keep the newest context messages within the checked result budget, oldest first. */
569
+ function contextResult(operationKey, context) {
570
+ const messages = [];
571
+ const result = {
572
+ kind: "read_context",
573
+ messages,
574
+ operationKey
575
+ };
576
+ const encoder = new TextEncoder();
577
+ let bytes = encoder.encode(JSON.stringify(result)).byteLength;
578
+ for (let index = context.length - 1; index >= 0; index--) {
579
+ const message = context[index];
580
+ if (message === void 0) continue;
581
+ const size = encoder.encode(JSON.stringify(message)).byteLength + 1;
582
+ if (bytes + size > 2097152) break;
583
+ bytes += size;
584
+ messages.unshift(message);
585
+ }
586
+ return result;
587
+ }
561
588
  /** The command and result schemas of a Channel's protocol. */
562
589
  const schemasFor = (definition) => definition.protocol === "v2" ? {
563
590
  command: commandSchemaV2(definition.state),
@@ -702,7 +729,6 @@ const make = (identifier, options) => {
702
729
  };
703
730
  };
704
731
  const isAgentChannel = (value) => Predicate.hasProperty(value, TypeId);
705
- //#endregion
706
- export { AccessOutcome, AgentChannel_exports as AgentChannel, AgentChannel_exports, Asset, AssetFile, ChannelError, CheckedResult, Content, ContextMessage, Contract, DeliveryUpdate, Destination, Echo, ErrorCode, Event, EventV2, Exposure, FailureCode, Features, HandlerError, Key, Message, Operation, OperationKind, Plan, PlanItem, Protocol, Reaction, Request, RequiredChecks, Stop, Timestamp, TypeId, Verification, VerifiedIdentity, WebhookResponse, commandSchema, commandSchemaV2, handlerKey, isAgentChannel, make, projectContract, resultSchema, resultSchemaV2, schemasFor, validateDefinition };
732
+ export { AccessOutcome, AgentChannel_exports as AgentChannel, AgentChannel_exports, Asset, AssetFile, ChannelError, CheckedResult, Content, ContextMessage, Contract, DeliveryUpdate, Destination, Echo, ErrorCode, Event, EventV2, Exposure, FailureCode, Features, HandlerError, Key, Message, Operation, OperationKind, Plan, PlanItem, Protocol, Reaction, Request, RequiredChecks, Stop, Timestamp, TypeId, Verification, VerifiedIdentity, WebhookResponse, commandSchema, commandSchemaV2, contextResult, handlerKey, isAgentChannel, make, projectContract, resultByteLimit, resultSchema, resultSchemaV2, schemasFor, validateDefinition };
707
733
 
708
734
  //# sourceMappingURL=AgentChannel.js.map
@@ -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/** Bounded provider-required webhook response, returned only after request verification. */\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});\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/** 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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O,kBAAkB,gBAAgB,CAAC,CAAC,OAAO,KAAK;GACvD,KAAK,MAAM,UAAU;IACnB,OAAO;IACP,OAAO;IACP,GAAI,OAAO,UAAU,KAAA,IAAY,CAAC,IAAI,CAAC,OAAO,KAAK;GACrD,GACE,YAAY,QAAQ,IAAI;EAE5B;EACA,IACE,eAAe,KAAA,KACf,OAAO,KAAK,WAAW,cAAc,CAAC,CAAC,CAAC,CAAC,MAAK,QAAO,CAAC,IAAI,WAAW,GAAG,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/**\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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;GAEvD,KAAK,IAAI,OAAO,UAAU;GAC1B,OAAO,kBAAkB,gBAAgB,CAAC,CAAC,OAAO,QAAQ;GAC1D,OAAO,kBAAkB,gBAAgB,CAAC,CAAC,OAAO,KAAK;GACvD,KAAK,MAAM,UAAU;IACnB,OAAO;IACP,OAAO;IACP,GAAI,OAAO,UAAU,KAAA,IAAY,CAAC,IAAI,CAAC,OAAO,KAAK;GACrD,GACE,YAAY,QAAQ,IAAI;EAE5B;EACA,IACE,eAAe,KAAA,KACf,OAAO,KAAK,WAAW,cAAc,CAAC,CAAC,CAAC,CAAC,MAAK,QAAO,CAAC,IAAI,WAAW,GAAG,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"}
@@ -1538,6 +1538,5 @@ export declare const run: (input: {
1538
1538
  readonly state: Schema.Json;
1539
1539
  };
1540
1540
  }) => Effect.Effect<undefined, ChannelError | ConformanceError | Schema.SchemaError, Service>;
1541
- //#endregion
1542
1541
  export { AgentChannelConformance_d_exports as AgentChannelConformance, AgentChannelConformance_d_exports };
1543
1542
  //# sourceMappingURL=AgentChannelConformance.d.ts.map
@@ -3,7 +3,7 @@ import { EventV2, Key, commandSchema, commandSchemaV2 } from "./AgentChannel.js"
3
3
  import { Service } from "./DualRuntime.js";
4
4
  import "./AgentChannelConformance.js";
5
5
  import { Effect, Schema } from "effect";
6
- //#region src/AgentChannelConformance.ts
6
+ // src/AgentChannelConformance.ts
7
7
  /** Public replay conformance suite for channel plugins, runnable with @effect/vitest. */
8
8
  var AgentChannelConformance_exports = /* @__PURE__ */ __exportAll({
9
9
  AgentChannelConformance: () => AgentChannelConformance_exports,
@@ -157,7 +157,6 @@ const run = Effect.fn("AgentChannelConformance.run")(function* (input) {
157
157
  }
158
158
  }
159
159
  }, Effect.scoped);
160
- //#endregion
161
160
  export { AgentChannelConformance_exports as AgentChannelConformance, AgentChannelConformance_exports, ConformanceError, Fixture, run };
162
161
 
163
162
  //# sourceMappingURL=AgentChannelConformance.js.map
@@ -73,6 +73,5 @@ type ExtensionRequirements<D> = D extends {
73
73
  export type Requirements<P extends Any$1> = PluginHandlers<P> | ExtensionRequirements<Definitions<P>> | Definitions<P>["definitionSettings"]["DecodingServices"] | Definitions<P>["deploymentSettings"]["DecodingServices"] | Definitions<P>["state"]["DecodingServices"] | Definitions<P>["state"]["EncodingServices"] | AuthResolutionRequirements<Definitions<P>["authMethods"]> | (Definitions<P>["authMethods"][number] extends never ? never : Service$1);
74
74
  /** Build from the installed plugins. */
75
75
  export declare const layer: <P extends Any$1>(plugins: readonly P[]) => Layer.Layer<Service, never, Requirements<P>>;
76
- //#endregion
77
76
  export { AgentChannelRuntime_d_exports as AgentChannelRuntime, AgentChannelRuntime_d_exports, Input, Pin };
78
77
  //# sourceMappingURL=AgentChannelRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AgentChannelRuntime.d.ts","names":["AgentChannel.AccessOutcome","AgentChannel.ChannelError","AgentChannel.Definition","AgentChannel.CheckedResult","Plugin.Any","AgentChannel.Any","AgentChannel.Handler","ConnectionResolver.Service"],"sources":["../src/AgentChannelRuntime.ts"],"mappings":";;;;;;;;;;qBAUa,mBAAiB,OAAA;;;;;;;;;;;;;;;;;cAiBxB,KAAG,OAAA;;;cACH,OAAK,OAAA;;;;;;;;;;;;;;;;;;;;;;;;KAgBC,aAAa,IAAI;KACjB,eAAe,MAAM;iBAChB;;WAEN,cACP,mBACG,OAAO,OAAOA,eAA4BC;WACtC,MAAM,iBAAiB,OAAO,OAAOC,YAAyBD;WAC9D,2BACP,mBACG,OAAO,OAAO,OAAO,MAAMA;WACvB,2BACP,mBACG,OAAO,OAAO,OAAO,MAAMA;WACvB,UACP,mBACG,OAAO,OAAOE,eAA4BF;;;qBAEpC,gBAAgB;KAIxB,YAAY,UAAUG,SAAc;KACpC,gBAAgB,UAAUA,OAAY,KAAK,UAAUC,MACtDC,WAAwB,mBAAmB;KAE1C,eAAe,KAAK,UAAUF,QAC/B,gBAAgB,GAAG;KAElB,sBAAsB,KAAK;WACrB,kBAAkB,mBAAmB,SAAS,eAAe,OAAO;IAGvE,iBAAiB,kCACjB,iBAAiB;YAEb,aAAa,UAAUA,SAC/B,eAAe,KACf,sBAAsB,YAAY,MAClC,YAAY,+CACZ,YAAY,+CACZ,YAAY,kCACZ,YAAY,kCACZ,2BAA2B,YAAY,sBACtC,YAAY,kDAAkDG;;qBAyMtD,QAAS,UAAUH,OAAU,kBACtB,QACjB,MAAM,MAAM,gBAAgB,aAAa"}
1
+ {"version":3,"file":"AgentChannelRuntime.d.ts","names":["AgentChannel.AccessOutcome","AgentChannel.ChannelError","AgentChannel.Definition","AgentChannel.CheckedResult","Plugin.Any","AgentChannel.Any","AgentChannel.Handler","ConnectionResolver.Service"],"sources":["../src/AgentChannelRuntime.ts"],"mappings":";;;;;;;;;;qBAUa,mBAAiB,OAAA;;;;;;;;;;;;;;;;;cAiBxB,KAAG,OAAA;;;cACH,OAAK,OAAA;;;;;;;;;;;;;;;;;;;;;;;;KAgBC,aAAa,IAAI;KACjB,eAAe,MAAM;iBAChB;;WAEN,cACP,mBACG,OAAO,OAAOA,eAA4BC;WACtC,MAAM,iBAAiB,OAAO,OAAOC,YAAyBD;WAC9D,2BACP,mBACG,OAAO,OAAO,OAAO,MAAMA;WACvB,2BACP,mBACG,OAAO,OAAO,OAAO,MAAMA;WACvB,UACP,mBACG,OAAO,OAAOE,eAA4BF;;;qBAEpC,gBAAgB;KAIxB,YAAY,UAAUG,SAAc;KACpC,gBAAgB,UAAUA,OAAY,KAAK,UAAUC,MACtDC,WAAwB,mBAAmB;KAE1C,eAAe,KAAK,UAAUF,QAC/B,gBAAgB,GAAG;KAElB,sBAAsB,KAAK;WACrB,kBAAkB,mBAAmB,SAAS,eAAe,OAAO;IAGvE,iBAAiB,kCACjB,iBAAiB;YAEb,aAAa,UAAUA,SAC/B,eAAe,KACf,sBAAsB,YAAY,MAClC,YAAY,+CACZ,YAAY,+CACZ,YAAY,kCACZ,YAAY,kCACZ,2BAA2B,YAAY,sBACtC,YAAY,kDAAkDG;;qBA0MtD,QAAS,UAAUH,OAAU,kBACtB,QACjB,MAAM,MAAM,gBAAgB,aAAa"}
@@ -1,10 +1,10 @@
1
1
  import { __exportAll } from "./_virtual/_rolldown/runtime.js";
2
- import { AccessOutcome, ChannelError, CheckedResult, FailureCode, Key, Verification, VerifiedIdentity, handlerKey, schemasFor, validateDefinition } from "./AgentChannel.js";
2
+ import { AccessOutcome, ChannelError, CheckedResult, FailureCode, Key, Verification, VerifiedIdentity, handlerKey, resultByteLimit, schemasFor, validateDefinition } from "./AgentChannel.js";
3
3
  import { Service as Service$1 } from "./ConnectionResolver.js";
4
4
  import { findHandler } from "./internal/handler-context.js";
5
5
  import "./AgentChannelRuntime.js";
6
6
  import { Cause, Context, Effect, Layer, Option, Predicate, Schema } from "effect";
7
- //#region src/AgentChannelRuntime.ts
7
+ // src/AgentChannelRuntime.ts
8
8
  /** Checked execution of pinned Agent Channel capabilities. No product lifecycle or persistence. */
9
9
  var AgentChannelRuntime_exports = /* @__PURE__ */ __exportAll({
10
10
  AgentChannelRuntime: () => AgentChannelRuntime_exports,
@@ -51,7 +51,7 @@ var Service = class extends Context.Service()("@dual-os/sdk/AgentChannelRuntime"
51
51
  const fail = (code) => new ChannelError({ code });
52
52
  const safe = (effect, code) => effect.pipe(Effect.catchCause((cause) => Cause.hasInterrupts(cause) ? Effect.interrupt : Effect.fail(fail(code))));
53
53
  const AssetResultJson = Schema.Json.check(Schema.makeFilter((value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= 14680064));
54
- const Json = Schema.Json.check(Schema.makeFilter((value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= 2097152));
54
+ const Json = Schema.Json.check(Schema.makeFilter((value) => new TextEncoder().encode(JSON.stringify(value)).byteLength <= resultByteLimit));
55
55
  const strict = { onExcessProperty: "error" };
56
56
  const decode = (schema, input, code) => safe(Effect.suspend(() => Schema.decodeUnknownEffect(schema)(input, strict)), code);
57
57
  const json = (value, code) => decode(Json, value, code);
@@ -264,7 +264,6 @@ const layer = (plugins) => Layer.effect(Service, Effect.gen(function* () {
264
264
  get: (input) => run(get(input))
265
265
  });
266
266
  }));
267
- //#endregion
268
267
  export { AgentChannelRuntime_exports as AgentChannelRuntime, AgentChannelRuntime_exports, ConnectionContext, Service, layer };
269
268
 
270
269
  //# sourceMappingURL=AgentChannelRuntime.js.map