@dual-os/sdk 0.8.0-next.1 → 0.8.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AgentChannel.d.ts +18 -929
- package/dist/AgentChannel.d.ts.map +1 -1
- package/dist/AgentChannel.js +23 -157
- package/dist/AgentChannel.js.map +1 -1
- package/dist/AgentChannelConformance.d.ts +8 -500
- package/dist/AgentChannelConformance.d.ts.map +1 -1
- package/dist/AgentChannelConformance.js +3 -3
- package/dist/AgentChannelConformance.js.map +1 -1
- package/dist/AgentChannelRuntime.d.ts.map +1 -1
- package/dist/AgentChannelRuntime.js +6 -7
- package/dist/AgentChannelRuntime.js.map +1 -1
- package/dist/PluginRuntime.d.ts +305 -9
- package/dist/PluginRuntime.d.ts.map +1 -1
- package/dist/PluginRuntime.js +9 -3
- package/dist/PluginRuntime.js.map +1 -1
- package/dist/internal/dual/registry.d.ts +1 -3
- package/dist/internal/dual/registry.d.ts.map +1 -1
- package/dist/internal/dual/registry.js.map +1 -1
- package/dist/internal/plugin-handlers.js +4 -2
- package/dist/internal/plugin-handlers.js.map +1 -1
- package/dist/remote-runtime.d.ts +292 -10
- package/dist/remote-runtime.d.ts.map +1 -1
- package/dist/remote-runtime.js +9 -15
- package/dist/remote-runtime.js.map +1 -1
- package/package.json +1 -1
- package/src/AgentChannel.ts +23 -149
- package/src/AgentChannelConformance.ts +2 -6
- package/src/AgentChannelRuntime.ts +9 -13
- package/src/PluginRuntime.ts +9 -4
- package/src/internal/dual/registry.ts +0 -2
- package/src/internal/plugin-handlers.ts +5 -2
- package/src/remote-runtime.ts +12 -23
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { AccessOutcome, ChannelError, CheckedResult, FailureCode, Key, Verification, VerifiedIdentity, handlerKey, resultByteLimit,
|
|
2
|
+
import { AccessOutcome, ChannelError, CheckedResult, FailureCode, Key, Verification, VerifiedIdentity, commandSchema, handlerKey, resultByteLimit, resultSchema, 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";
|
|
@@ -78,7 +78,7 @@ const checkExtensions = Effect.fn("AgentChannelRuntime.checkExtensions")(functio
|
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
const checkMessage = (features, destination, content) => (destination.kind === "direct" || features.groups) && (destination.threadKey === void 0 || features.threads) && (content.mentions === void 0 || features.mentions) && (content.assets === void 0 || features.assets) && (content.replyToMessageKey === void 0 || features.replies);
|
|
81
|
-
const checkDelivery = (features, command) =>
|
|
81
|
+
const checkDelivery = (features, command) => checkMessage(features, command.destination, { text: "" }) && (features.operations ?? []).includes(command.operation.kind);
|
|
82
82
|
const Material = Schema.Struct({
|
|
83
83
|
connectionId: Key,
|
|
84
84
|
encoding: Schema.optionalKey(Schema.Literal("json")),
|
|
@@ -178,12 +178,11 @@ const layer = (plugins) => Layer.effect(Service, Effect.gen(function* () {
|
|
|
178
178
|
if (found === void 0) return yield* fail("not_found");
|
|
179
179
|
const definitionSettings = yield* decodeData(definition.definitionSettings, request.definitionSettings, "invalid_input");
|
|
180
180
|
const deploymentSettings = yield* decodeData(definition.deploymentSettings, request.deploymentSettings, "invalid_input");
|
|
181
|
-
const
|
|
182
|
-
const command = yield* decodeData(schemas.command, request.command, "invalid_input");
|
|
181
|
+
const command = yield* decodeData(commandSchema(definition.state), request.command, "invalid_input");
|
|
183
182
|
yield* checkExtensions(definition, command.extensions, "invalid_input");
|
|
184
183
|
if (command.kind === "deliver" && command.operationKey !== command.deliveryKey) return yield* fail("invalid_input");
|
|
185
184
|
if (command.kind === "deliver" && !checkDelivery(definition.features, command)) return yield* fail("unsupported_feature");
|
|
186
|
-
if (command.kind === "deliver" &&
|
|
185
|
+
if (command.kind === "deliver" && command.operation.kind === "set_reaction" && command.operation.target.kind === "activation" && command.activationMessageKey === void 0) return yield* fail("invalid_input");
|
|
187
186
|
if (command.kind === "read_context" && (definition.features.readContext !== true || !checkMessage(definition.features, command.destination, { text: "" }))) return yield* fail("unsupported_feature");
|
|
188
187
|
const handler = Option.fromNullishOr(findHandler(context, found.provider.identifier, handlerKey(request.channelId)));
|
|
189
188
|
if (Option.isNone(handler)) return yield* fail("handler_unavailable");
|
|
@@ -207,7 +206,7 @@ const layer = (plugins) => Layer.effect(Service, Effect.gen(function* () {
|
|
|
207
206
|
});
|
|
208
207
|
}
|
|
209
208
|
const output = yield* invokeHandler(handler.value, Effect.suspend(() => handler.value.runtime.execute(command, adapterContext)));
|
|
210
|
-
const result = yield* decodeData(
|
|
209
|
+
const result = yield* decodeData(resultSchema(Schema.toType(definition.state)), output, "invalid_result", kind === "read_asset");
|
|
211
210
|
if (result.kind !== kind || result.operationKey !== operationKey || result.kind === "deliver" && result.deliveryKey !== deliveryKey || result.kind === "read_asset" && result.assetKey !== assetKey) return yield* fail("invalid_result");
|
|
212
211
|
yield* checkExtensions(definition, result.extensions, "invalid_result");
|
|
213
212
|
if (result.kind === "deliver" && result.status === "pending" && !definition.features.deliveryState) return yield* fail("invalid_result");
|
|
@@ -239,7 +238,7 @@ const layer = (plugins) => Layer.effect(Service, Effect.gen(function* () {
|
|
|
239
238
|
allowedEvents.push(event);
|
|
240
239
|
}
|
|
241
240
|
}
|
|
242
|
-
const encoded = yield* safe(Schema.encodeUnknownEffect(
|
|
241
|
+
const encoded = yield* safe(Schema.encodeUnknownEffect(resultSchema(definition.state))(result.kind === "receive" ? {
|
|
243
242
|
...result,
|
|
244
243
|
events: allowedEvents,
|
|
245
244
|
...deniedEventKeys.length === 0 ? {} : { deniedEventKeys }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentChannelRuntime.js","names":["AgentChannel.Key","AgentChannel.VerifiedIdentity","AgentChannel.ChannelError","AgentChannel.resultByteLimit","AgentChannel.FailureCode","ConnectionResolver.Service","AgentChannel.handlerKey","AgentChannel.AccessOutcome","AgentChannel.schemasFor","AgentChannel.Verification","AgentChannel.CheckedResult"],"sources":["../src/AgentChannelRuntime.ts"],"sourcesContent":["/** Checked execution of pinned Agent Channel capabilities. No product lifecycle or persistence. */\nimport { Cause, Context, Effect, Layer, Option, Predicate, Schema } from \"effect\";\n\nimport * as AgentChannel from \"./AgentChannel.ts\";\nimport { ConnectionResolver } from \"./ConnectionResolver.ts\";\nimport type { AuthResolutionRequirements } from \"./internal/auth-execution.ts\";\nimport { findHandler } from \"./internal/handler-context.ts\";\nimport type * as Plugin from \"./Plugin.ts\";\n\n/** Host-only connection authority context. It is never included in handler inputs. */\nexport const ConnectionContext = Schema.Struct({\n actor: Schema.optionalKey(\n Schema.Union([\n Schema.Struct({ kind: Schema.Literal(\"user\"), userId: AgentChannel.Key }),\n Schema.Struct({\n kind: Schema.Literal(\"system\"),\n reason: Schema.optionalKey(AgentChannel.Key),\n }),\n ]),\n ),\n source: Schema.optionalKey(\n Schema.Struct({ kind: AgentChannel.Key, subjectId: Schema.optionalKey(AgentChannel.Key) }),\n ),\n tenant: Schema.optionalKey(\n Schema.Struct({ organizationId: AgentChannel.Key, teamId: AgentChannel.Key }),\n ),\n});\nconst Pin = Schema.Struct({ channelId: AgentChannel.Key });\nconst Input = Schema.Struct({\n ...Pin.fields,\n command: Schema.Unknown,\n connectionId: Schema.optionalKey(AgentChannel.Key),\n context: Schema.optionalKey(ConnectionContext),\n definitionSettings: Schema.Unknown,\n deploymentSettings: Schema.Unknown,\n});\nconst AccessInput = Schema.Struct({\n ...Pin.fields,\n connectionId: Schema.optionalKey(AgentChannel.Key),\n context: Schema.optionalKey(ConnectionContext),\n definitionSettings: Schema.Unknown,\n deploymentSettings: Schema.Unknown,\n identity: AgentChannel.VerifiedIdentity,\n});\nexport type Pin = typeof Pin.Type;\nexport type Input = typeof Input.Type;\nexport interface Interface {\n /** Reauthorize an already verified identity; does not verify a transport or execute provider operations. */\n readonly checkAccess: (\n input: unknown,\n ) => Effect.Effect<AgentChannel.AccessOutcome, AgentChannel.ChannelError>;\n readonly get: (pin: unknown) => Effect.Effect<AgentChannel.Definition, AgentChannel.ChannelError>;\n readonly decodeDefinitionSettings: (\n input: unknown,\n ) => Effect.Effect<Schema.Json, AgentChannel.ChannelError>;\n readonly decodeDeploymentSettings: (\n input: unknown,\n ) => Effect.Effect<Schema.Json, AgentChannel.ChannelError>;\n readonly execute: (\n input: unknown,\n ) => Effect.Effect<AgentChannel.CheckedResult, AgentChannel.ChannelError>;\n}\nexport class Service extends Context.Service<Service, Interface>()(\n \"@dual-os/sdk/AgentChannelRuntime\",\n) {}\n\ntype Definitions<P extends Plugin.Any> = P[\"agentChannels\"][number][\"definition\"];\ntype ChannelHandlers<P extends Plugin.Any, C> = C extends AgentChannel.Any\n ? AgentChannel.Handler<`${P[\"identifier\"]}/${C[\"identifier\"]}`>\n : never;\ntype PluginHandlers<P> = P extends Plugin.Any\n ? ChannelHandlers<P, P[\"agentChannels\"][number]>\n : never;\ntype ExtensionRequirements<D> = D extends {\n readonly extensions: infer Extensions extends Readonly<Record<string, Schema.Top>>;\n}\n ?\n | Extensions[keyof Extensions][\"DecodingServices\"]\n | Extensions[keyof Extensions][\"EncodingServices\"]\n : never;\nexport type Requirements<P extends Plugin.Any> =\n | PluginHandlers<P>\n | ExtensionRequirements<Definitions<P>>\n | Definitions<P>[\"definitionSettings\"][\"DecodingServices\"]\n | Definitions<P>[\"deploymentSettings\"][\"DecodingServices\"]\n | Definitions<P>[\"state\"][\"DecodingServices\"]\n | Definitions<P>[\"state\"][\"EncodingServices\"]\n | AuthResolutionRequirements<Definitions<P>[\"authMethods\"]>\n | (Definitions<P>[\"authMethods\"][number] extends never ? never : ConnectionResolver.Service);\n\nconst fail = (code: typeof AgentChannel.ErrorCode.Type) => new AgentChannel.ChannelError({ code });\nconst safe = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n code: typeof AgentChannel.ErrorCode.Type,\n): Effect.Effect<A, AgentChannel.ChannelError, R> =>\n effect.pipe(\n Effect.catchCause(cause =>\n Cause.hasInterrupts(cause) ? Effect.interrupt : Effect.fail(fail(code)),\n ),\n );\nconst AssetResultJson = Schema.Json.check(\n Schema.makeFilter(\n value => new TextEncoder().encode(JSON.stringify(value)).byteLength <= 14_680_064,\n ),\n);\nconst Json = Schema.Json.check(\n Schema.makeFilter(\n value =>\n new TextEncoder().encode(JSON.stringify(value)).byteLength <= AgentChannel.resultByteLimit,\n ),\n);\nconst strict = { onExcessProperty: \"error\" } as const;\nconst decode = <S extends Schema.Top>(\n schema: S,\n input: unknown,\n code: typeof AgentChannel.ErrorCode.Type,\n) =>\n safe(\n Effect.suspend(() => Schema.decodeUnknownEffect(schema)(input, strict)),\n code,\n );\nconst json = (value: unknown, code: typeof AgentChannel.ErrorCode.Type) =>\n decode(Json, value, code);\nconst decodeData = Effect.fn(\"AgentChannelRuntime.decodeData\")(function* <S extends Schema.Top>(\n schema: S,\n input: unknown,\n code: typeof AgentChannel.ErrorCode.Type,\n largeAssetResult = false,\n) {\n const boundary = largeAssetResult ? AssetResultJson : Json;\n yield* decode(boundary, input, code);\n const value = yield* decode(schema, input, code);\n yield* decode(boundary, value, code);\n return value;\n});\n\nconst invokeHandler = (\n handler: AgentChannel.Handler,\n effect: Effect.Effect<unknown, unknown, unknown>,\n) =>\n effect.pipe(\n Effect.provideContext(handler.context),\n Effect.catch(error =>\n decode(\n Schema.TaggedStruct(\"AgentChannelHandlerError\", { code: AgentChannel.FailureCode }),\n Predicate.isObject(error) ? { ...error } : error,\n \"provider_failure\",\n ).pipe(\n Effect.flatMap(checked =>\n Effect.fail(\n new AgentChannel.ChannelError({ code: \"provider_failure\", providerCode: checked.code }),\n ),\n ),\n ),\n ),\n Effect.catchCause(cause => {\n if (Cause.hasInterrupts(cause)) return Effect.interrupt;\n const error = Cause.findErrorOption(cause);\n return Option.isSome(error) && error.value instanceof AgentChannel.ChannelError\n ? Effect.fail(error.value)\n : Effect.fail(fail(\"provider_failure\"));\n }),\n );\n\nconst checkExtensions = Effect.fn(\"AgentChannelRuntime.checkExtensions\")(function* (\n definition: AgentChannel.Definition,\n extensions: Readonly<Record<string, Schema.Json>> | undefined,\n code: typeof AgentChannel.ErrorCode.Type,\n) {\n for (const [key, value] of Object.entries(extensions ?? {})) {\n const schema = definition.extensions?.[key];\n if (schema === undefined) return yield* fail(code);\n // Extensions are checked values, not a provider payload escape hatch. No normalization.\n yield* decodeData(Schema.toType(schema), value, code);\n }\n});\nconst checkMessage = (\n features: AgentChannel.Features,\n destination: AgentChannel.Destination,\n content: AgentChannel.Content,\n): boolean =>\n (destination.kind === \"direct\" || features.groups) &&\n (destination.threadKey === undefined || features.threads) &&\n (content.mentions === undefined || features.mentions) &&\n (content.assets === undefined || features.assets) &&\n (content.replyToMessageKey === undefined || features.replies);\n\nconst checkDelivery = (\n features: AgentChannel.Features,\n command: Extract<AgentChannel.Command | AgentChannel.CommandV2, { kind: \"deliver\" }>,\n): boolean =>\n \"content\" in command\n ? checkMessage(features, command.destination, command.content)\n : checkMessage(features, command.destination, { text: \"\" }) &&\n (features.operations ?? []).includes(command.operation.kind);\n\nconst Material = Schema.Struct({\n connectionId: AgentChannel.Key,\n // The plugin worker's resolver marks its JSON-carried material.\n encoding: Schema.optionalKey(Schema.Literal(\"json\")),\n material: Schema.Unknown,\n methodId: AgentChannel.Key,\n providerId: AgentChannel.Key,\n setup: Schema.Unknown,\n});\nconst ResolveHook = Schema.declare(\n (value): value is (material: unknown, context: { readonly setup: unknown }) => unknown =>\n Predicate.isFunction(value),\n);\nconst resolveAuth = Effect.fn(\"AgentChannelRuntime.resolveAuth\")(function* (\n providerId: string,\n channelId: string,\n definition: AgentChannel.Definition,\n connectionId: string | undefined,\n phase: string,\n context: typeof ConnectionContext.Type | undefined,\n) {\n if (definition.authMethods.length === 0) {\n if (connectionId !== undefined) return yield* fail(\"invalid_auth\");\n return undefined;\n }\n // The host alone selects/authorizes the pinned connection. Its records never reach the plugin.\n if (connectionId === undefined) return yield* fail(\"invalid_auth\");\n const resolver = yield* Effect.serviceOption(ConnectionResolver.Service);\n if (Option.isNone(resolver)) return yield* fail(\"invalid_auth\");\n const raw = yield* safe(\n Effect.suspend(() =>\n resolver.value.resolve({\n connectionId,\n target: { phase, providerId, targetId: channelId, targetKind: \"agent-channel\" },\n ...(context === undefined ? {} : { context }),\n }),\n ),\n \"invalid_auth\",\n );\n const resolved = yield* decode(Material, raw, \"invalid_auth\");\n if (resolved.providerId !== providerId || resolved.connectionId !== connectionId) {\n return yield* fail(\"invalid_auth\");\n }\n const method = definition.authMethods.find(\n method =>\n resolved.methodId === method.identifier ||\n resolved.methodId === `${providerId}/${method.identifier}`,\n );\n if (method === undefined) return yield* fail(\"invalid_auth\");\n // Material the worker received as JSON decodes through each schema's JSON codec.\n const decodeAuth = <S extends Schema.Top>(schema: S, value: unknown) =>\n decode(\n resolved.encoding === \"json\" ? Schema.toCodecJson(schema) : schema,\n value,\n \"invalid_auth\",\n );\n const setup =\n method.setup === undefined\n ? yield* decode(Schema.Undefined, resolved.setup, \"invalid_auth\")\n : yield* decodeAuth(method.setup, resolved.setup);\n const material = yield* decodeAuth(method.material, resolved.material);\n let value: unknown;\n if (method.resolve === undefined) {\n value =\n method.material === method.value\n ? material\n : yield* decode(method.value, material, \"invalid_auth\");\n } else {\n const hook = yield* decode(ResolveHook, method.resolve, \"invalid_auth\");\n const output = yield* safe(\n Effect.suspend(() => {\n const result = hook(material, { setup });\n return Effect.isEffect(result) ? result : Effect.succeed(result);\n }),\n \"invalid_auth\",\n );\n value = yield* decode(method.value, output, \"invalid_auth\");\n }\n // Schemas may use Redacted for auth. Only this checked value, never material/setup/binding,\n // is exposed to the command handler.\n return { methodId: method.identifier, value };\n});\n\nconst find = (plugins: readonly Plugin.Any[], pin: Pin) => {\n for (const provider of plugins) {\n const channel = provider.agentChannels.find(\n channel => `${provider.identifier}/${channel.identifier}` === pin.channelId,\n );\n if (channel !== undefined) return { definition: channel.definition, provider };\n }\n return undefined;\n};\n\n/** Build from the installed plugins. */\nexport const layer = <P extends Plugin.Any>(\n plugins: readonly P[],\n): Layer.Layer<Service, never, Requirements<P>> =>\n Layer.effect(\n Service,\n Effect.gen(function* () {\n const context = yield* Effect.context<Requirements<P>>();\n const get = Effect.fn(\"AgentChannelRuntime.get\")(function* (input: unknown) {\n const pin = yield* decode(Pin, input, \"invalid_input\");\n const found = find(plugins, pin);\n if (found === undefined) return yield* fail(\"not_found\");\n yield* safe(\n Effect.sync(() => {\n AgentChannel.validateDefinition(\n found.definition,\n found.provider.identifier,\n found.provider.authMethods,\n );\n }),\n \"invalid_definition\",\n );\n const handler = Option.fromNullishOr(\n findHandler(\n context,\n found.provider.identifier,\n AgentChannel.handlerKey(pin.channelId),\n ) as AgentChannel.Handler | undefined,\n );\n if (\n Option.isNone(handler) ||\n !Predicate.isObject(handler.value.runtime) ||\n !Predicate.isFunction(handler.value.runtime.execute) ||\n !Predicate.isFunction(handler.value.runtime.verify) ||\n !Predicate.isFunction(handler.value.runtime.checkAccess)\n ) {\n return yield* fail(\"handler_unavailable\");\n }\n return found.definition;\n });\n const checkAccess = Effect.fn(\"AgentChannelRuntime.checkAccess\")(function* (input: unknown) {\n yield* json(input, \"invalid_input\");\n const request = yield* decode(AccessInput, input, \"invalid_input\");\n const definition = yield* get({ channelId: request.channelId });\n const found = find(plugins, request);\n if (found === undefined) return yield* fail(\"not_found\");\n const definitionSettings = yield* decodeData(\n definition.definitionSettings,\n request.definitionSettings,\n \"invalid_input\",\n );\n const deploymentSettings = yield* decodeData(\n definition.deploymentSettings,\n request.deploymentSettings,\n \"invalid_input\",\n );\n if (!checkMessage(definition.features, request.identity.conversation, { text: \"\" })) {\n return yield* fail(\"unsupported_feature\");\n }\n const auth = yield* resolveAuth(\n found.provider.identifier,\n request.channelId,\n definition,\n request.connectionId,\n \"check_access\",\n request.context,\n );\n const handler = Option.fromNullishOr(\n findHandler(\n context,\n found.provider.identifier,\n AgentChannel.handlerKey(request.channelId),\n ) as AgentChannel.Handler | undefined,\n );\n if (Option.isNone(handler)) return yield* fail(\"handler_unavailable\");\n const output = yield* invokeHandler(\n handler.value,\n Effect.suspend(() =>\n handler.value.runtime.checkAccess(request.identity, {\n definitionSettings,\n deploymentSettings,\n ...(auth === undefined ? {} : { auth }),\n }),\n ),\n );\n return yield* decodeData(AgentChannel.AccessOutcome, output, \"invalid_result\");\n });\n const execute = Effect.fn(\"AgentChannelRuntime.execute\")(function* (input: unknown) {\n yield* json(input, \"invalid_input\");\n const request = yield* decode(Input, input, \"invalid_input\");\n const definition = yield* get({ channelId: request.channelId });\n const found = find(plugins, request);\n if (found === undefined) return yield* fail(\"not_found\");\n const definitionSettings = yield* decodeData(\n definition.definitionSettings,\n request.definitionSettings,\n \"invalid_input\",\n );\n const deploymentSettings = yield* decodeData(\n definition.deploymentSettings,\n request.deploymentSettings,\n \"invalid_input\",\n );\n const schemas = AgentChannel.schemasFor(definition);\n const command: AgentChannel.Command | AgentChannel.CommandV2 = yield* decodeData(\n schemas.command,\n request.command,\n \"invalid_input\",\n );\n yield* checkExtensions(definition, command.extensions, \"invalid_input\");\n if (command.kind === \"deliver\" && command.operationKey !== command.deliveryKey) {\n return yield* fail(\"invalid_input\");\n }\n if (command.kind === \"deliver\" && !checkDelivery(definition.features, command)) {\n return yield* fail(\"unsupported_feature\");\n }\n if (\n command.kind === \"deliver\" &&\n \"operation\" in command &&\n command.operation.kind === \"set_reaction\" &&\n command.operation.target.kind === \"activation\" &&\n command.activationMessageKey === undefined\n ) {\n return yield* fail(\"invalid_input\");\n }\n if (\n command.kind === \"read_context\" &&\n (definition.features.readContext !== true ||\n !checkMessage(definition.features, command.destination, { text: \"\" }))\n ) {\n return yield* fail(\"unsupported_feature\");\n }\n const handler = Option.fromNullishOr(\n findHandler(\n context,\n found.provider.identifier,\n AgentChannel.handlerKey(request.channelId),\n ) as AgentChannel.Handler | undefined,\n );\n if (Option.isNone(handler)) return yield* fail(\"handler_unavailable\");\n const auth = yield* resolveAuth(\n found.provider.identifier,\n request.channelId,\n definition,\n request.connectionId,\n command.kind,\n request.context,\n );\n // Keep correlation facts independent of any mutation by provider code.\n const operationKey = command.operationKey;\n const kind = command.kind;\n const deliveryKey = command.kind === \"deliver\" ? command.deliveryKey : undefined;\n const assetKey = command.kind === \"read_asset\" ? command.asset.assetKey : undefined;\n const adapterContext = {\n definitionSettings,\n deploymentSettings,\n ...(auth === undefined ? {} : { auth }),\n };\n if (\n !Predicate.isFunction(handler.value.runtime.execute) ||\n !Predicate.isFunction(handler.value.runtime.verify) ||\n !Predicate.isFunction(handler.value.runtime.checkAccess)\n ) {\n return yield* fail(\"handler_unavailable\");\n }\n if (command.kind === \"receive\") {\n yield* decodeData(\n AgentChannel.Verification,\n yield* invokeHandler(\n handler.value,\n Effect.suspend(() => handler.value.runtime.verify(command.request, adapterContext)),\n ),\n \"invalid_result\",\n );\n }\n if (command.kind === \"read_asset\") {\n if (!definition.features.assets) return yield* fail(\"unsupported_feature\");\n const decision = yield* decodeData(\n AgentChannel.AccessOutcome,\n yield* invokeHandler(\n handler.value,\n Effect.suspend(() =>\n handler.value.runtime.checkAccess(command.identity, adapterContext),\n ),\n ),\n \"invalid_result\",\n );\n if (decision.decision !== \"allow\") {\n return yield* new AgentChannel.ChannelError({\n code: \"provider_failure\",\n providerCode: \"unauthorized\",\n });\n }\n }\n const output = yield* invokeHandler(\n handler.value,\n Effect.suspend(() => handler.value.runtime.execute(command, adapterContext)),\n );\n const result: AgentChannel.Result | AgentChannel.ResultV2 = yield* decodeData(\n schemas.typeResult,\n output,\n \"invalid_result\",\n kind === \"read_asset\",\n );\n if (\n result.kind !== kind ||\n result.operationKey !== operationKey ||\n (result.kind === \"deliver\" && result.deliveryKey !== deliveryKey) ||\n (result.kind === \"read_asset\" && result.assetKey !== assetKey)\n ) {\n return yield* fail(\"invalid_result\");\n }\n yield* checkExtensions(definition, result.extensions, \"invalid_result\");\n if (\n result.kind === \"deliver\" &&\n result.status === \"pending\" &&\n !definition.features.deliveryState\n ) {\n return yield* fail(\"invalid_result\");\n }\n const allowedEvents: AgentChannel.EventV2[] = [];\n const deniedEventKeys: string[] = [];\n if (result.kind === \"receive\") {\n if (result.deniedEventKeys !== undefined) return yield* fail(\"invalid_result\");\n if (\n result.activationProof === \"verified\" &&\n (result.response === undefined || result.events.length !== 0)\n ) {\n return yield* fail(\"invalid_result\");\n }\n const eventKeys = new Set<string>();\n for (const event of result.events) {\n if (eventKeys.has(event.eventKey)) return yield* fail(\"invalid_result\");\n eventKeys.add(event.eventKey);\n if (\n event.kind === \"message\" &&\n !checkMessage(definition.features, event.conversation, event.content)\n ) {\n return yield* fail(\"invalid_result\");\n }\n if (\n (event.kind === \"echo\" || event.kind === \"stop\") &&\n !checkMessage(definition.features, event.conversation, { text: \"\" })\n ) {\n return yield* fail(\"invalid_result\");\n }\n if (event.kind === \"delivery_update\" && !definition.features.deliveryState) {\n return yield* fail(\"invalid_result\");\n }\n yield* checkExtensions(definition, event.extensions, \"invalid_result\");\n let denied = false;\n if (event.kind === \"message\" || event.kind === \"echo\" || event.kind === \"stop\") {\n const identity = yield* decodeData(\n AgentChannel.VerifiedIdentity,\n { conversation: event.conversation, senderKey: event.senderKey },\n \"invalid_result\",\n );\n const decision = yield* decodeData(\n AgentChannel.AccessOutcome,\n yield* invokeHandler(\n handler.value,\n Effect.suspend(() => handler.value.runtime.checkAccess(identity, adapterContext)),\n ),\n \"invalid_result\",\n );\n denied = decision.decision === \"deny\";\n }\n if (denied) {\n deniedEventKeys.push(event.eventKey);\n continue;\n }\n allowedEvents.push(event);\n }\n }\n // Store the encoded state so subsequent pinned commands can decode it exactly once.\n const encoded = yield* safe(\n Schema.encodeUnknownEffect(schemas.result)(\n result.kind === \"receive\"\n ? {\n ...result,\n events: allowedEvents,\n ...(deniedEventKeys.length === 0 ? {} : { deniedEventKeys }),\n }\n : result,\n strict,\n ),\n \"invalid_result\",\n );\n return yield* decodeData(\n AgentChannel.CheckedResult,\n encoded,\n \"invalid_result\",\n kind === \"read_asset\",\n );\n });\n // SAFETY: Requirements above account for each schema, auth method and Channel handler. The\n // dynamic lookup erases their union; the captured application context discharges it here.\n const run = <A>(\n effect: Effect.Effect<A, AgentChannel.ChannelError, unknown>,\n ): Effect.Effect<A, AgentChannel.ChannelError> =>\n // @effect-diagnostics-next-line unsafeEffectTypeAssertion:off -- Channel handlers are checked and their captured context satisfies the declared Requirements (SAFETY above).\n effect.pipe(Effect.provideContext(context)) as Effect.Effect<A, AgentChannel.ChannelError>;\n const decodeSettings = (field: \"definitionSettings\" | \"deploymentSettings\") =>\n Effect.fn(\"AgentChannelRuntime.decodeSettings\")(function* (input: unknown) {\n const request = yield* decode(\n Schema.Struct({ ...Pin.fields, value: Schema.Json }),\n input,\n \"invalid_input\",\n );\n const definition = yield* get({ channelId: request.channelId });\n const schema = definition[field];\n const value = yield* decodeData(schema, request.value, \"invalid_input\");\n return yield* json(\n yield* safe(Schema.encodeUnknownEffect(schema)(value, strict), \"invalid_input\"),\n \"invalid_input\",\n );\n });\n return Service.of({\n checkAccess: input => run(checkAccess(input)),\n decodeDefinitionSettings: input => run(decodeSettings(\"definitionSettings\")(input)),\n decodeDeploymentSettings: input => run(decodeSettings(\"deploymentSettings\")(input)),\n execute: input => run(execute(input)),\n get: input => run(get(input)),\n });\n }),\n );\n\nexport * as AgentChannelRuntime from \"./AgentChannelRuntime.ts\";\n"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAa,oBAAoB,OAAO,OAAO;CAC7C,OAAO,OAAO,YACZ,OAAO,MAAM,CACX,OAAO,OAAO;EAAE,MAAM,OAAO,QAAQ,MAAM;EAAG,QAAQA;CAAiB,CAAC,GACxE,OAAO,OAAO;EACZ,MAAM,OAAO,QAAQ,QAAQ;EAC7B,QAAQ,OAAO,YAAYA,GAAgB;CAC7C,CAAC,CACH,CAAC,CACH;CACA,QAAQ,OAAO,YACb,OAAO,OAAO;EAAE,MAAMA;EAAkB,WAAW,OAAO,Y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;GAAQ,OAAO,OAAO;EAAK,CAAC,GACnD,OACA,eACF;EAEA,MAAM,UAAS,OADW,IAAI,EAAE,WAAW,QAAQ,UAAU,CAAC,EAAA,CACpC;EAC1B,MAAM,QAAQ,OAAO,WAAW,QAAQ,QAAQ,OAAO,eAAe;EACtE,OAAO,OAAO,KACZ,OAAO,KAAK,OAAO,oBAAoB,MAAM,CAAC,CAAC,OAAO,MAAM,GAAG,eAAe,GAC9E,eACF;CACF,CAAC;CACH,OAAO,QAAQ,GAAG;EAChB,cAAa,UAAS,IAAI,YAAY,KAAK,CAAC;EAC5C,2BAA0B,UAAS,IAAI,eAAe,oBAAoB,CAAC,CAAC,KAAK,CAAC;EAClF,2BAA0B,UAAS,IAAI,eAAe,oBAAoB,CAAC,CAAC,KAAK,CAAC;EAClF,UAAS,UAAS,IAAI,QAAQ,KAAK,CAAC;EACpC,MAAK,UAAS,IAAI,IAAI,KAAK,CAAC;CAC9B,CAAC;AACH,CAAC,CACH"}
|
|
1
|
+
{"version":3,"file":"AgentChannelRuntime.js","names":["AgentChannel.Key","AgentChannel.VerifiedIdentity","AgentChannel.ChannelError","AgentChannel.resultByteLimit","AgentChannel.FailureCode","ConnectionResolver.Service","AgentChannel.handlerKey","AgentChannel.AccessOutcome","AgentChannel.commandSchema","AgentChannel.Verification","AgentChannel.resultSchema","AgentChannel.CheckedResult"],"sources":["../src/AgentChannelRuntime.ts"],"sourcesContent":["/** Checked execution of pinned Agent Channel capabilities. No product lifecycle or persistence. */\nimport { Cause, Context, Effect, Layer, Option, Predicate, Schema } from \"effect\";\n\nimport * as AgentChannel from \"./AgentChannel.ts\";\nimport { ConnectionResolver } from \"./ConnectionResolver.ts\";\nimport type { AuthResolutionRequirements } from \"./internal/auth-execution.ts\";\nimport { findHandler } from \"./internal/handler-context.ts\";\nimport type * as Plugin from \"./Plugin.ts\";\n\n/** Host-only connection authority context. It is never included in handler inputs. */\nexport const ConnectionContext = Schema.Struct({\n actor: Schema.optionalKey(\n Schema.Union([\n Schema.Struct({ kind: Schema.Literal(\"user\"), userId: AgentChannel.Key }),\n Schema.Struct({\n kind: Schema.Literal(\"system\"),\n reason: Schema.optionalKey(AgentChannel.Key),\n }),\n ]),\n ),\n source: Schema.optionalKey(\n Schema.Struct({ kind: AgentChannel.Key, subjectId: Schema.optionalKey(AgentChannel.Key) }),\n ),\n tenant: Schema.optionalKey(\n Schema.Struct({ organizationId: AgentChannel.Key, teamId: AgentChannel.Key }),\n ),\n});\nconst Pin = Schema.Struct({ channelId: AgentChannel.Key });\nconst Input = Schema.Struct({\n ...Pin.fields,\n command: Schema.Unknown,\n connectionId: Schema.optionalKey(AgentChannel.Key),\n context: Schema.optionalKey(ConnectionContext),\n definitionSettings: Schema.Unknown,\n deploymentSettings: Schema.Unknown,\n});\nconst AccessInput = Schema.Struct({\n ...Pin.fields,\n connectionId: Schema.optionalKey(AgentChannel.Key),\n context: Schema.optionalKey(ConnectionContext),\n definitionSettings: Schema.Unknown,\n deploymentSettings: Schema.Unknown,\n identity: AgentChannel.VerifiedIdentity,\n});\nexport type Pin = typeof Pin.Type;\nexport type Input = typeof Input.Type;\nexport interface Interface {\n /** Reauthorize an already verified identity; does not verify a transport or execute provider operations. */\n readonly checkAccess: (\n input: unknown,\n ) => Effect.Effect<AgentChannel.AccessOutcome, AgentChannel.ChannelError>;\n readonly get: (pin: unknown) => Effect.Effect<AgentChannel.Definition, AgentChannel.ChannelError>;\n readonly decodeDefinitionSettings: (\n input: unknown,\n ) => Effect.Effect<Schema.Json, AgentChannel.ChannelError>;\n readonly decodeDeploymentSettings: (\n input: unknown,\n ) => Effect.Effect<Schema.Json, AgentChannel.ChannelError>;\n readonly execute: (\n input: unknown,\n ) => Effect.Effect<AgentChannel.CheckedResult, AgentChannel.ChannelError>;\n}\nexport class Service extends Context.Service<Service, Interface>()(\n \"@dual-os/sdk/AgentChannelRuntime\",\n) {}\n\ntype Definitions<P extends Plugin.Any> = P[\"agentChannels\"][number][\"definition\"];\ntype ChannelHandlers<P extends Plugin.Any, C> = C extends AgentChannel.Any\n ? AgentChannel.Handler<`${P[\"identifier\"]}/${C[\"identifier\"]}`>\n : never;\ntype PluginHandlers<P> = P extends Plugin.Any\n ? ChannelHandlers<P, P[\"agentChannels\"][number]>\n : never;\ntype ExtensionRequirements<D> = D extends {\n readonly extensions: infer Extensions extends Readonly<Record<string, Schema.Top>>;\n}\n ?\n | Extensions[keyof Extensions][\"DecodingServices\"]\n | Extensions[keyof Extensions][\"EncodingServices\"]\n : never;\nexport type Requirements<P extends Plugin.Any> =\n | PluginHandlers<P>\n | ExtensionRequirements<Definitions<P>>\n | Definitions<P>[\"definitionSettings\"][\"DecodingServices\"]\n | Definitions<P>[\"deploymentSettings\"][\"DecodingServices\"]\n | Definitions<P>[\"state\"][\"DecodingServices\"]\n | Definitions<P>[\"state\"][\"EncodingServices\"]\n | AuthResolutionRequirements<Definitions<P>[\"authMethods\"]>\n | (Definitions<P>[\"authMethods\"][number] extends never ? never : ConnectionResolver.Service);\n\nconst fail = (code: typeof AgentChannel.ErrorCode.Type) => new AgentChannel.ChannelError({ code });\nconst safe = <A, E, R>(\n effect: Effect.Effect<A, E, R>,\n code: typeof AgentChannel.ErrorCode.Type,\n): Effect.Effect<A, AgentChannel.ChannelError, R> =>\n effect.pipe(\n Effect.catchCause(cause =>\n Cause.hasInterrupts(cause) ? Effect.interrupt : Effect.fail(fail(code)),\n ),\n );\nconst AssetResultJson = Schema.Json.check(\n Schema.makeFilter(\n value => new TextEncoder().encode(JSON.stringify(value)).byteLength <= 14_680_064,\n ),\n);\nconst Json = Schema.Json.check(\n Schema.makeFilter(\n value =>\n new TextEncoder().encode(JSON.stringify(value)).byteLength <= AgentChannel.resultByteLimit,\n ),\n);\nconst strict = { onExcessProperty: \"error\" } as const;\nconst decode = <S extends Schema.Top>(\n schema: S,\n input: unknown,\n code: typeof AgentChannel.ErrorCode.Type,\n) =>\n safe(\n Effect.suspend(() => Schema.decodeUnknownEffect(schema)(input, strict)),\n code,\n );\nconst json = (value: unknown, code: typeof AgentChannel.ErrorCode.Type) =>\n decode(Json, value, code);\nconst decodeData = Effect.fn(\"AgentChannelRuntime.decodeData\")(function* <S extends Schema.Top>(\n schema: S,\n input: unknown,\n code: typeof AgentChannel.ErrorCode.Type,\n largeAssetResult = false,\n) {\n const boundary = largeAssetResult ? AssetResultJson : Json;\n yield* decode(boundary, input, code);\n const value = yield* decode(schema, input, code);\n yield* decode(boundary, value, code);\n return value;\n});\n\nconst invokeHandler = (\n handler: AgentChannel.Handler,\n effect: Effect.Effect<unknown, unknown, unknown>,\n) =>\n effect.pipe(\n Effect.provideContext(handler.context),\n Effect.catch(error =>\n decode(\n Schema.TaggedStruct(\"AgentChannelHandlerError\", { code: AgentChannel.FailureCode }),\n Predicate.isObject(error) ? { ...error } : error,\n \"provider_failure\",\n ).pipe(\n Effect.flatMap(checked =>\n Effect.fail(\n new AgentChannel.ChannelError({ code: \"provider_failure\", providerCode: checked.code }),\n ),\n ),\n ),\n ),\n Effect.catchCause(cause => {\n if (Cause.hasInterrupts(cause)) return Effect.interrupt;\n const error = Cause.findErrorOption(cause);\n return Option.isSome(error) && error.value instanceof AgentChannel.ChannelError\n ? Effect.fail(error.value)\n : Effect.fail(fail(\"provider_failure\"));\n }),\n );\n\nconst checkExtensions = Effect.fn(\"AgentChannelRuntime.checkExtensions\")(function* (\n definition: AgentChannel.Definition,\n extensions: Readonly<Record<string, Schema.Json>> | undefined,\n code: typeof AgentChannel.ErrorCode.Type,\n) {\n for (const [key, value] of Object.entries(extensions ?? {})) {\n const schema = definition.extensions?.[key];\n if (schema === undefined) return yield* fail(code);\n // Extensions are checked values, not a provider payload escape hatch. No normalization.\n yield* decodeData(Schema.toType(schema), value, code);\n }\n});\nconst checkMessage = (\n features: AgentChannel.Features,\n destination: AgentChannel.Destination,\n content: AgentChannel.Content,\n): boolean =>\n (destination.kind === \"direct\" || features.groups) &&\n (destination.threadKey === undefined || features.threads) &&\n (content.mentions === undefined || features.mentions) &&\n (content.assets === undefined || features.assets) &&\n (content.replyToMessageKey === undefined || features.replies);\n\nconst checkDelivery = (\n features: AgentChannel.Features,\n command: Extract<AgentChannel.Command, { kind: \"deliver\" }>,\n): boolean =>\n checkMessage(features, command.destination, { text: \"\" }) &&\n (features.operations ?? []).includes(command.operation.kind);\n\nconst Material = Schema.Struct({\n connectionId: AgentChannel.Key,\n // The plugin worker's resolver marks its JSON-carried material.\n encoding: Schema.optionalKey(Schema.Literal(\"json\")),\n material: Schema.Unknown,\n methodId: AgentChannel.Key,\n providerId: AgentChannel.Key,\n setup: Schema.Unknown,\n});\nconst ResolveHook = Schema.declare(\n (value): value is (material: unknown, context: { readonly setup: unknown }) => unknown =>\n Predicate.isFunction(value),\n);\nconst resolveAuth = Effect.fn(\"AgentChannelRuntime.resolveAuth\")(function* (\n providerId: string,\n channelId: string,\n definition: AgentChannel.Definition,\n connectionId: string | undefined,\n phase: string,\n context: typeof ConnectionContext.Type | undefined,\n) {\n if (definition.authMethods.length === 0) {\n if (connectionId !== undefined) return yield* fail(\"invalid_auth\");\n return undefined;\n }\n // The host alone selects/authorizes the pinned connection. Its records never reach the plugin.\n if (connectionId === undefined) return yield* fail(\"invalid_auth\");\n const resolver = yield* Effect.serviceOption(ConnectionResolver.Service);\n if (Option.isNone(resolver)) return yield* fail(\"invalid_auth\");\n const raw = yield* safe(\n Effect.suspend(() =>\n resolver.value.resolve({\n connectionId,\n target: { phase, providerId, targetId: channelId, targetKind: \"agent-channel\" },\n ...(context === undefined ? {} : { context }),\n }),\n ),\n \"invalid_auth\",\n );\n const resolved = yield* decode(Material, raw, \"invalid_auth\");\n if (resolved.providerId !== providerId || resolved.connectionId !== connectionId) {\n return yield* fail(\"invalid_auth\");\n }\n const method = definition.authMethods.find(\n method =>\n resolved.methodId === method.identifier ||\n resolved.methodId === `${providerId}/${method.identifier}`,\n );\n if (method === undefined) return yield* fail(\"invalid_auth\");\n // Material the worker received as JSON decodes through each schema's JSON codec.\n const decodeAuth = <S extends Schema.Top>(schema: S, value: unknown) =>\n decode(\n resolved.encoding === \"json\" ? Schema.toCodecJson(schema) : schema,\n value,\n \"invalid_auth\",\n );\n const setup =\n method.setup === undefined\n ? yield* decode(Schema.Undefined, resolved.setup, \"invalid_auth\")\n : yield* decodeAuth(method.setup, resolved.setup);\n const material = yield* decodeAuth(method.material, resolved.material);\n let value: unknown;\n if (method.resolve === undefined) {\n value =\n method.material === method.value\n ? material\n : yield* decode(method.value, material, \"invalid_auth\");\n } else {\n const hook = yield* decode(ResolveHook, method.resolve, \"invalid_auth\");\n const output = yield* safe(\n Effect.suspend(() => {\n const result = hook(material, { setup });\n return Effect.isEffect(result) ? result : Effect.succeed(result);\n }),\n \"invalid_auth\",\n );\n value = yield* decode(method.value, output, \"invalid_auth\");\n }\n // Schemas may use Redacted for auth. Only this checked value, never material/setup/binding,\n // is exposed to the command handler.\n return { methodId: method.identifier, value };\n});\n\nconst find = (plugins: readonly Plugin.Any[], pin: Pin) => {\n for (const provider of plugins) {\n const channel = provider.agentChannels.find(\n channel => `${provider.identifier}/${channel.identifier}` === pin.channelId,\n );\n if (channel !== undefined) return { definition: channel.definition, provider };\n }\n return undefined;\n};\n\n/** Build from the installed plugins. */\nexport const layer = <P extends Plugin.Any>(\n plugins: readonly P[],\n): Layer.Layer<Service, never, Requirements<P>> =>\n Layer.effect(\n Service,\n Effect.gen(function* () {\n const context = yield* Effect.context<Requirements<P>>();\n const get = Effect.fn(\"AgentChannelRuntime.get\")(function* (input: unknown) {\n const pin = yield* decode(Pin, input, \"invalid_input\");\n const found = find(plugins, pin);\n if (found === undefined) return yield* fail(\"not_found\");\n yield* safe(\n Effect.sync(() => {\n AgentChannel.validateDefinition(\n found.definition,\n found.provider.identifier,\n found.provider.authMethods,\n );\n }),\n \"invalid_definition\",\n );\n const handler = Option.fromNullishOr(\n findHandler(\n context,\n found.provider.identifier,\n AgentChannel.handlerKey(pin.channelId),\n ) as AgentChannel.Handler | undefined,\n );\n if (\n Option.isNone(handler) ||\n !Predicate.isObject(handler.value.runtime) ||\n !Predicate.isFunction(handler.value.runtime.execute) ||\n !Predicate.isFunction(handler.value.runtime.verify) ||\n !Predicate.isFunction(handler.value.runtime.checkAccess)\n ) {\n return yield* fail(\"handler_unavailable\");\n }\n return found.definition;\n });\n const checkAccess = Effect.fn(\"AgentChannelRuntime.checkAccess\")(function* (input: unknown) {\n yield* json(input, \"invalid_input\");\n const request = yield* decode(AccessInput, input, \"invalid_input\");\n const definition = yield* get({ channelId: request.channelId });\n const found = find(plugins, request);\n if (found === undefined) return yield* fail(\"not_found\");\n const definitionSettings = yield* decodeData(\n definition.definitionSettings,\n request.definitionSettings,\n \"invalid_input\",\n );\n const deploymentSettings = yield* decodeData(\n definition.deploymentSettings,\n request.deploymentSettings,\n \"invalid_input\",\n );\n if (!checkMessage(definition.features, request.identity.conversation, { text: \"\" })) {\n return yield* fail(\"unsupported_feature\");\n }\n const auth = yield* resolveAuth(\n found.provider.identifier,\n request.channelId,\n definition,\n request.connectionId,\n \"check_access\",\n request.context,\n );\n const handler = Option.fromNullishOr(\n findHandler(\n context,\n found.provider.identifier,\n AgentChannel.handlerKey(request.channelId),\n ) as AgentChannel.Handler | undefined,\n );\n if (Option.isNone(handler)) return yield* fail(\"handler_unavailable\");\n const output = yield* invokeHandler(\n handler.value,\n Effect.suspend(() =>\n handler.value.runtime.checkAccess(request.identity, {\n definitionSettings,\n deploymentSettings,\n ...(auth === undefined ? {} : { auth }),\n }),\n ),\n );\n return yield* decodeData(AgentChannel.AccessOutcome, output, \"invalid_result\");\n });\n const execute = Effect.fn(\"AgentChannelRuntime.execute\")(function* (input: unknown) {\n yield* json(input, \"invalid_input\");\n const request = yield* decode(Input, input, \"invalid_input\");\n const definition = yield* get({ channelId: request.channelId });\n const found = find(plugins, request);\n if (found === undefined) return yield* fail(\"not_found\");\n const definitionSettings = yield* decodeData(\n definition.definitionSettings,\n request.definitionSettings,\n \"invalid_input\",\n );\n const deploymentSettings = yield* decodeData(\n definition.deploymentSettings,\n request.deploymentSettings,\n \"invalid_input\",\n );\n const command: AgentChannel.Command = yield* decodeData(\n AgentChannel.commandSchema(definition.state),\n request.command,\n \"invalid_input\",\n );\n yield* checkExtensions(definition, command.extensions, \"invalid_input\");\n if (command.kind === \"deliver\" && command.operationKey !== command.deliveryKey) {\n return yield* fail(\"invalid_input\");\n }\n if (command.kind === \"deliver\" && !checkDelivery(definition.features, command)) {\n return yield* fail(\"unsupported_feature\");\n }\n if (\n command.kind === \"deliver\" &&\n command.operation.kind === \"set_reaction\" &&\n command.operation.target.kind === \"activation\" &&\n command.activationMessageKey === undefined\n ) {\n return yield* fail(\"invalid_input\");\n }\n if (\n command.kind === \"read_context\" &&\n (definition.features.readContext !== true ||\n !checkMessage(definition.features, command.destination, { text: \"\" }))\n ) {\n return yield* fail(\"unsupported_feature\");\n }\n const handler = Option.fromNullishOr(\n findHandler(\n context,\n found.provider.identifier,\n AgentChannel.handlerKey(request.channelId),\n ) as AgentChannel.Handler | undefined,\n );\n if (Option.isNone(handler)) return yield* fail(\"handler_unavailable\");\n const auth = yield* resolveAuth(\n found.provider.identifier,\n request.channelId,\n definition,\n request.connectionId,\n command.kind,\n request.context,\n );\n // Keep correlation facts independent of any mutation by provider code.\n const operationKey = command.operationKey;\n const kind = command.kind;\n const deliveryKey = command.kind === \"deliver\" ? command.deliveryKey : undefined;\n const assetKey = command.kind === \"read_asset\" ? command.asset.assetKey : undefined;\n const adapterContext = {\n definitionSettings,\n deploymentSettings,\n ...(auth === undefined ? {} : { auth }),\n };\n if (\n !Predicate.isFunction(handler.value.runtime.execute) ||\n !Predicate.isFunction(handler.value.runtime.verify) ||\n !Predicate.isFunction(handler.value.runtime.checkAccess)\n ) {\n return yield* fail(\"handler_unavailable\");\n }\n if (command.kind === \"receive\") {\n yield* decodeData(\n AgentChannel.Verification,\n yield* invokeHandler(\n handler.value,\n Effect.suspend(() => handler.value.runtime.verify(command.request, adapterContext)),\n ),\n \"invalid_result\",\n );\n }\n if (command.kind === \"read_asset\") {\n if (!definition.features.assets) return yield* fail(\"unsupported_feature\");\n const decision = yield* decodeData(\n AgentChannel.AccessOutcome,\n yield* invokeHandler(\n handler.value,\n Effect.suspend(() =>\n handler.value.runtime.checkAccess(command.identity, adapterContext),\n ),\n ),\n \"invalid_result\",\n );\n if (decision.decision !== \"allow\") {\n return yield* new AgentChannel.ChannelError({\n code: \"provider_failure\",\n providerCode: \"unauthorized\",\n });\n }\n }\n const output = yield* invokeHandler(\n handler.value,\n Effect.suspend(() => handler.value.runtime.execute(command, adapterContext)),\n );\n const result: AgentChannel.Result = yield* decodeData(\n AgentChannel.resultSchema(Schema.toType(definition.state)),\n output,\n \"invalid_result\",\n kind === \"read_asset\",\n );\n if (\n result.kind !== kind ||\n result.operationKey !== operationKey ||\n (result.kind === \"deliver\" && result.deliveryKey !== deliveryKey) ||\n (result.kind === \"read_asset\" && result.assetKey !== assetKey)\n ) {\n return yield* fail(\"invalid_result\");\n }\n yield* checkExtensions(definition, result.extensions, \"invalid_result\");\n if (\n result.kind === \"deliver\" &&\n result.status === \"pending\" &&\n !definition.features.deliveryState\n ) {\n return yield* fail(\"invalid_result\");\n }\n const allowedEvents: AgentChannel.Event[] = [];\n const deniedEventKeys: string[] = [];\n if (result.kind === \"receive\") {\n if (result.deniedEventKeys !== undefined) return yield* fail(\"invalid_result\");\n if (\n result.activationProof === \"verified\" &&\n (result.response === undefined || result.events.length !== 0)\n ) {\n return yield* fail(\"invalid_result\");\n }\n const eventKeys = new Set<string>();\n for (const event of result.events) {\n if (eventKeys.has(event.eventKey)) return yield* fail(\"invalid_result\");\n eventKeys.add(event.eventKey);\n if (\n event.kind === \"message\" &&\n !checkMessage(definition.features, event.conversation, event.content)\n ) {\n return yield* fail(\"invalid_result\");\n }\n if (\n (event.kind === \"echo\" || event.kind === \"stop\") &&\n !checkMessage(definition.features, event.conversation, { text: \"\" })\n ) {\n return yield* fail(\"invalid_result\");\n }\n if (event.kind === \"delivery_update\" && !definition.features.deliveryState) {\n return yield* fail(\"invalid_result\");\n }\n yield* checkExtensions(definition, event.extensions, \"invalid_result\");\n let denied = false;\n if (event.kind === \"message\" || event.kind === \"echo\" || event.kind === \"stop\") {\n const identity = yield* decodeData(\n AgentChannel.VerifiedIdentity,\n { conversation: event.conversation, senderKey: event.senderKey },\n \"invalid_result\",\n );\n const decision = yield* decodeData(\n AgentChannel.AccessOutcome,\n yield* invokeHandler(\n handler.value,\n Effect.suspend(() => handler.value.runtime.checkAccess(identity, adapterContext)),\n ),\n \"invalid_result\",\n );\n denied = decision.decision === \"deny\";\n }\n if (denied) {\n deniedEventKeys.push(event.eventKey);\n continue;\n }\n allowedEvents.push(event);\n }\n }\n // Store the encoded state so subsequent pinned commands can decode it exactly once.\n const encoded = yield* safe(\n Schema.encodeUnknownEffect(AgentChannel.resultSchema(definition.state))(\n result.kind === \"receive\"\n ? {\n ...result,\n events: allowedEvents,\n ...(deniedEventKeys.length === 0 ? {} : { deniedEventKeys }),\n }\n : result,\n strict,\n ),\n \"invalid_result\",\n );\n return yield* decodeData(\n AgentChannel.CheckedResult,\n encoded,\n \"invalid_result\",\n kind === \"read_asset\",\n );\n });\n // SAFETY: Requirements above account for each schema, auth method and Channel handler. The\n // dynamic lookup erases their union; the captured application context discharges it here.\n const run = <A>(\n effect: Effect.Effect<A, AgentChannel.ChannelError, unknown>,\n ): Effect.Effect<A, AgentChannel.ChannelError> =>\n // @effect-diagnostics-next-line unsafeEffectTypeAssertion:off -- Channel handlers are checked and their captured context satisfies the declared Requirements (SAFETY above).\n effect.pipe(Effect.provideContext(context)) as Effect.Effect<A, AgentChannel.ChannelError>;\n const decodeSettings = (field: \"definitionSettings\" | \"deploymentSettings\") =>\n Effect.fn(\"AgentChannelRuntime.decodeSettings\")(function* (input: unknown) {\n const request = yield* decode(\n Schema.Struct({ ...Pin.fields, value: Schema.Json }),\n input,\n \"invalid_input\",\n );\n const definition = yield* get({ channelId: request.channelId });\n const schema = definition[field];\n const value = yield* decodeData(schema, request.value, \"invalid_input\");\n return yield* json(\n yield* safe(Schema.encodeUnknownEffect(schema)(value, strict), \"invalid_input\"),\n \"invalid_input\",\n );\n });\n return Service.of({\n checkAccess: input => run(checkAccess(input)),\n decodeDefinitionSettings: input => run(decodeSettings(\"definitionSettings\")(input)),\n decodeDeploymentSettings: input => run(decodeSettings(\"deploymentSettings\")(input)),\n execute: input => run(execute(input)),\n get: input => run(get(input)),\n });\n }),\n );\n\nexport * as AgentChannelRuntime from \"./AgentChannelRuntime.ts\";\n"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAa,oBAAoB,OAAO,OAAO;CAC7C,OAAO,OAAO,YACZ,OAAO,MAAM,CACX,OAAO,OAAO;EAAE,MAAM,OAAO,QAAQ,MAAM;EAAG,QAAQA;CAAiB,CAAC,GACxE,OAAO,OAAO;EACZ,MAAM,OAAO,QAAQ,QAAQ;EAC7B,QAAQ,OAAO,YAAYA,GAAgB;CAC7C,CAAC,CACH,CAAC,CACH;CACA,QAAQ,OAAO,YACb,OAAO,OAAO;EAAE,MAAMA;EAAkB,WAAW,OAAO,YAAYA,GAAgB;CAAE,CAAC,CAC3F;CACA,QAAQ,OAAO,YACb,OAAO,OAAO;EAAE,gBAAgBA;EAAkB,QAAQA;CAAiB,CAAC,CAC9E;AACF,CAAC;AACD,MAAM,MAAM,OAAO,OAAO,EAAE,WAAWA,IAAiB,CAAC;AACzD,MAAM,QAAQ,OAAO,OAAO;CAC1B,GAAG,IAAI;CACP,SAAS,OAAO;CAChB,cAAc,OAAO,YAAYA,GAAgB;CACjD,SAAS,OAAO,YAAY,iBAAiB;CAC7C,oBAAoB,OAAO;CAC3B,oBAAoB,OAAO;AAC7B,CAAC;AACD,MAAM,cAAc,OAAO,OAAO;CAChC,GAAG,IAAI;CACP,cAAc,OAAO,YAAYA,GAAgB;CACjD,SAAS,OAAO,YAAY,iBAAiB;CAC7C,oBAAoB,OAAO;CAC3B,oBAAoB,OAAO;CAC3B,UAAUC;AACZ,CAAC;AAmBD,IAAa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CACH"}
|
package/dist/PluginRuntime.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { AuthMethodHookError, ExpectedOAuth2MethodError, OAuth2RefreshTokenUnavailableError } from "./AuthMethod.js";
|
|
2
|
+
import { ActionHandlerError, RetryableActionHandlerError } from "./Action.js";
|
|
1
3
|
import { ChannelError } from "./AgentChannel.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
+
import { ConnectionIdNotAllowedError, ConnectionReauthorizationRequiredError, ConnectionRequiredError, ConnectionResolverStoreError, ConnectionSelectionRequiredError, InvalidConnectionIdError, InvalidResolvedConnectionError } from "./ConnectionResolver.js";
|
|
5
|
+
import { ActionHandlerNotFoundError, ActionNotFoundError, InvalidActionInputError, InvalidActionOutputError } from "./internal/dual/invoke.js";
|
|
6
|
+
import { AuthMethodNotFoundError, Service } from "./DualRuntime.js";
|
|
4
7
|
import { Service as Service$1 } from "./OAuthFlow.js";
|
|
5
8
|
import "./PluginRuntime.js";
|
|
6
9
|
import { Cause, Effect, Schema, Stream } from "effect";
|
|
@@ -905,7 +908,7 @@ export declare const Output: Schema.Union<readonly [Schema.Union<readonly [Schem
|
|
|
905
908
|
}>;
|
|
906
909
|
readonly value: Schema.optionalKey<Schema.Codec<Schema.Json, Schema.Json, never, never>>;
|
|
907
910
|
}>, Schema.TaggedStruct<"failure", {
|
|
908
|
-
readonly error: Schema.Struct<{
|
|
911
|
+
readonly error: Schema.Union<readonly [typeof ActionHandlerError, typeof RetryableActionHandlerError, Schema.Struct<{
|
|
909
912
|
readonly category: Schema.Literals<readonly ["validation", "connection", "handler", "initialization", "protocol"]>;
|
|
910
913
|
readonly channel: Schema.optionalKey<Schema.Struct<{
|
|
911
914
|
readonly code: Schema.Literals<readonly ["invalid_definition", "not_found", "invalid_input", "invalid_auth", "unsupported_feature", "invalid_result", "handler_unavailable", "provider_failure"]>;
|
|
@@ -919,7 +922,7 @@ export declare const Output: Schema.Union<readonly [Schema.Union<readonly [Schem
|
|
|
919
922
|
readonly retryAfterSeconds: Schema.optionalKey<Schema.Finite>;
|
|
920
923
|
readonly retryable: Schema.Boolean;
|
|
921
924
|
readonly status: Schema.optionalKey<Schema.Int>;
|
|
922
|
-
}>;
|
|
925
|
+
}>]>;
|
|
923
926
|
readonly identity: Schema.Struct<{
|
|
924
927
|
readonly artifactDigest: Schema.String;
|
|
925
928
|
readonly invocationId: Schema.NonEmptyString;
|
|
@@ -1850,7 +1853,7 @@ export declare const decodeInput: (input: unknown) => Effect.Effect<{
|
|
|
1850
1853
|
}, PluginExecutionError | Schema.SchemaError, never>;
|
|
1851
1854
|
export declare const encodeOutput: (output: {
|
|
1852
1855
|
readonly _tag: "failure";
|
|
1853
|
-
readonly error: {
|
|
1856
|
+
readonly error: ActionHandlerError | RetryableActionHandlerError | {
|
|
1854
1857
|
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
1855
1858
|
readonly channel?: {
|
|
1856
1859
|
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
@@ -1894,6 +1897,19 @@ export declare const encodeOutput: (output: {
|
|
|
1894
1897
|
}, maximum: number) => Effect.Effect<{
|
|
1895
1898
|
readonly _tag: "failure";
|
|
1896
1899
|
readonly error: {
|
|
1900
|
+
readonly _tag: "ActionHandlerError";
|
|
1901
|
+
readonly cause?: Schema.Json | undefined;
|
|
1902
|
+
readonly details?: unknown;
|
|
1903
|
+
readonly message: string;
|
|
1904
|
+
readonly status?: number | undefined;
|
|
1905
|
+
} | {
|
|
1906
|
+
readonly _tag: "RetryableActionHandlerError";
|
|
1907
|
+
readonly cause?: Schema.Json | undefined;
|
|
1908
|
+
readonly details?: unknown;
|
|
1909
|
+
readonly message: string;
|
|
1910
|
+
readonly retryAfterSeconds?: number | undefined;
|
|
1911
|
+
readonly status?: number | undefined;
|
|
1912
|
+
} | {
|
|
1897
1913
|
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
1898
1914
|
readonly channel?: {
|
|
1899
1915
|
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
@@ -1937,7 +1953,7 @@ export declare const encodeOutput: (output: {
|
|
|
1937
1953
|
}, PluginExecutionError | Schema.SchemaError, never>;
|
|
1938
1954
|
export declare const decodeOutput: (output: unknown) => Effect.Effect<{
|
|
1939
1955
|
readonly _tag: "failure";
|
|
1940
|
-
readonly error: {
|
|
1956
|
+
readonly error: ActionHandlerError | RetryableActionHandlerError | {
|
|
1941
1957
|
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
1942
1958
|
readonly channel?: {
|
|
1943
1959
|
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
@@ -3110,7 +3126,7 @@ export declare const execute: (request: {
|
|
|
3110
3126
|
};
|
|
3111
3127
|
}) => Effect.Effect<{
|
|
3112
3128
|
_tag: "failure";
|
|
3113
|
-
error:
|
|
3129
|
+
error: ActionHandlerError | RetryableActionHandlerError | {
|
|
3114
3130
|
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3115
3131
|
readonly channel?: {
|
|
3116
3132
|
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
@@ -3124,7 +3140,7 @@ export declare const execute: (request: {
|
|
|
3124
3140
|
readonly retryAfterSeconds?: number;
|
|
3125
3141
|
readonly retryable: boolean;
|
|
3126
3142
|
readonly status?: number;
|
|
3127
|
-
} |
|
|
3143
|
+
} | (ActionHandlerError & {
|
|
3128
3144
|
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3129
3145
|
readonly channel?: {
|
|
3130
3146
|
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
@@ -3138,7 +3154,287 @@ export declare const execute: (request: {
|
|
|
3138
3154
|
readonly retryAfterSeconds?: number;
|
|
3139
3155
|
readonly retryable: boolean;
|
|
3140
3156
|
readonly status?: number;
|
|
3141
|
-
}
|
|
3157
|
+
}) | (ActionHandlerNotFoundError & {
|
|
3158
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3159
|
+
readonly channel?: {
|
|
3160
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3161
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3162
|
+
};
|
|
3163
|
+
readonly code: string;
|
|
3164
|
+
readonly fields?: readonly {
|
|
3165
|
+
readonly path: string;
|
|
3166
|
+
}[];
|
|
3167
|
+
readonly message: string;
|
|
3168
|
+
readonly retryAfterSeconds?: number;
|
|
3169
|
+
readonly retryable: boolean;
|
|
3170
|
+
readonly status?: number;
|
|
3171
|
+
}) | (ActionNotFoundError & {
|
|
3172
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3173
|
+
readonly channel?: {
|
|
3174
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3175
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3176
|
+
};
|
|
3177
|
+
readonly code: string;
|
|
3178
|
+
readonly fields?: readonly {
|
|
3179
|
+
readonly path: string;
|
|
3180
|
+
}[];
|
|
3181
|
+
readonly message: string;
|
|
3182
|
+
readonly retryAfterSeconds?: number;
|
|
3183
|
+
readonly retryable: boolean;
|
|
3184
|
+
readonly status?: number;
|
|
3185
|
+
}) | (AuthMethodHookError & {
|
|
3186
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3187
|
+
readonly channel?: {
|
|
3188
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3189
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3190
|
+
};
|
|
3191
|
+
readonly code: string;
|
|
3192
|
+
readonly fields?: readonly {
|
|
3193
|
+
readonly path: string;
|
|
3194
|
+
}[];
|
|
3195
|
+
readonly message: string;
|
|
3196
|
+
readonly retryAfterSeconds?: number;
|
|
3197
|
+
readonly retryable: boolean;
|
|
3198
|
+
readonly status?: number;
|
|
3199
|
+
}) | (AuthMethodNotFoundError & {
|
|
3200
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3201
|
+
readonly channel?: {
|
|
3202
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3203
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3204
|
+
};
|
|
3205
|
+
readonly code: string;
|
|
3206
|
+
readonly fields?: readonly {
|
|
3207
|
+
readonly path: string;
|
|
3208
|
+
}[];
|
|
3209
|
+
readonly message: string;
|
|
3210
|
+
readonly retryAfterSeconds?: number;
|
|
3211
|
+
readonly retryable: boolean;
|
|
3212
|
+
readonly status?: number;
|
|
3213
|
+
}) | (ChannelError & {
|
|
3214
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3215
|
+
readonly channel?: {
|
|
3216
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3217
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3218
|
+
};
|
|
3219
|
+
readonly code: string;
|
|
3220
|
+
readonly fields?: readonly {
|
|
3221
|
+
readonly path: string;
|
|
3222
|
+
}[];
|
|
3223
|
+
readonly message: string;
|
|
3224
|
+
readonly retryAfterSeconds?: number;
|
|
3225
|
+
readonly retryable: boolean;
|
|
3226
|
+
readonly status?: number;
|
|
3227
|
+
}) | (ConnectionIdNotAllowedError & {
|
|
3228
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3229
|
+
readonly channel?: {
|
|
3230
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3231
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3232
|
+
};
|
|
3233
|
+
readonly code: string;
|
|
3234
|
+
readonly fields?: readonly {
|
|
3235
|
+
readonly path: string;
|
|
3236
|
+
}[];
|
|
3237
|
+
readonly message: string;
|
|
3238
|
+
readonly retryAfterSeconds?: number;
|
|
3239
|
+
readonly retryable: boolean;
|
|
3240
|
+
readonly status?: number;
|
|
3241
|
+
}) | (ConnectionReauthorizationRequiredError & {
|
|
3242
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3243
|
+
readonly channel?: {
|
|
3244
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3245
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3246
|
+
};
|
|
3247
|
+
readonly code: string;
|
|
3248
|
+
readonly fields?: readonly {
|
|
3249
|
+
readonly path: string;
|
|
3250
|
+
}[];
|
|
3251
|
+
readonly message: string;
|
|
3252
|
+
readonly retryAfterSeconds?: number;
|
|
3253
|
+
readonly retryable: boolean;
|
|
3254
|
+
readonly status?: number;
|
|
3255
|
+
}) | (ConnectionRequiredError & {
|
|
3256
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3257
|
+
readonly channel?: {
|
|
3258
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3259
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3260
|
+
};
|
|
3261
|
+
readonly code: string;
|
|
3262
|
+
readonly fields?: readonly {
|
|
3263
|
+
readonly path: string;
|
|
3264
|
+
}[];
|
|
3265
|
+
readonly message: string;
|
|
3266
|
+
readonly retryAfterSeconds?: number;
|
|
3267
|
+
readonly retryable: boolean;
|
|
3268
|
+
readonly status?: number;
|
|
3269
|
+
}) | (ConnectionResolverStoreError & {
|
|
3270
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3271
|
+
readonly channel?: {
|
|
3272
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3273
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3274
|
+
};
|
|
3275
|
+
readonly code: string;
|
|
3276
|
+
readonly fields?: readonly {
|
|
3277
|
+
readonly path: string;
|
|
3278
|
+
}[];
|
|
3279
|
+
readonly message: string;
|
|
3280
|
+
readonly retryAfterSeconds?: number;
|
|
3281
|
+
readonly retryable: boolean;
|
|
3282
|
+
readonly status?: number;
|
|
3283
|
+
}) | (ConnectionSelectionRequiredError & {
|
|
3284
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3285
|
+
readonly channel?: {
|
|
3286
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3287
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3288
|
+
};
|
|
3289
|
+
readonly code: string;
|
|
3290
|
+
readonly fields?: readonly {
|
|
3291
|
+
readonly path: string;
|
|
3292
|
+
}[];
|
|
3293
|
+
readonly message: string;
|
|
3294
|
+
readonly retryAfterSeconds?: number;
|
|
3295
|
+
readonly retryable: boolean;
|
|
3296
|
+
readonly status?: number;
|
|
3297
|
+
}) | (ExpectedOAuth2MethodError & {
|
|
3298
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3299
|
+
readonly channel?: {
|
|
3300
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3301
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3302
|
+
};
|
|
3303
|
+
readonly code: string;
|
|
3304
|
+
readonly fields?: readonly {
|
|
3305
|
+
readonly path: string;
|
|
3306
|
+
}[];
|
|
3307
|
+
readonly message: string;
|
|
3308
|
+
readonly retryAfterSeconds?: number;
|
|
3309
|
+
readonly retryable: boolean;
|
|
3310
|
+
readonly status?: number;
|
|
3311
|
+
}) | (InvalidActionInputError & {
|
|
3312
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3313
|
+
readonly channel?: {
|
|
3314
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3315
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3316
|
+
};
|
|
3317
|
+
readonly code: string;
|
|
3318
|
+
readonly fields?: readonly {
|
|
3319
|
+
readonly path: string;
|
|
3320
|
+
}[];
|
|
3321
|
+
readonly message: string;
|
|
3322
|
+
readonly retryAfterSeconds?: number;
|
|
3323
|
+
readonly retryable: boolean;
|
|
3324
|
+
readonly status?: number;
|
|
3325
|
+
}) | (InvalidActionOutputError & {
|
|
3326
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3327
|
+
readonly channel?: {
|
|
3328
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3329
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3330
|
+
};
|
|
3331
|
+
readonly code: string;
|
|
3332
|
+
readonly fields?: readonly {
|
|
3333
|
+
readonly path: string;
|
|
3334
|
+
}[];
|
|
3335
|
+
readonly message: string;
|
|
3336
|
+
readonly retryAfterSeconds?: number;
|
|
3337
|
+
readonly retryable: boolean;
|
|
3338
|
+
readonly status?: number;
|
|
3339
|
+
}) | (InvalidConnectionIdError & {
|
|
3340
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3341
|
+
readonly channel?: {
|
|
3342
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3343
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3344
|
+
};
|
|
3345
|
+
readonly code: string;
|
|
3346
|
+
readonly fields?: readonly {
|
|
3347
|
+
readonly path: string;
|
|
3348
|
+
}[];
|
|
3349
|
+
readonly message: string;
|
|
3350
|
+
readonly retryAfterSeconds?: number;
|
|
3351
|
+
readonly retryable: boolean;
|
|
3352
|
+
readonly status?: number;
|
|
3353
|
+
}) | (InvalidResolvedConnectionError & {
|
|
3354
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3355
|
+
readonly channel?: {
|
|
3356
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3357
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3358
|
+
};
|
|
3359
|
+
readonly code: string;
|
|
3360
|
+
readonly fields?: readonly {
|
|
3361
|
+
readonly path: string;
|
|
3362
|
+
}[];
|
|
3363
|
+
readonly message: string;
|
|
3364
|
+
readonly retryAfterSeconds?: number;
|
|
3365
|
+
readonly retryable: boolean;
|
|
3366
|
+
readonly status?: number;
|
|
3367
|
+
}) | (OAuth2RefreshTokenUnavailableError & {
|
|
3368
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3369
|
+
readonly channel?: {
|
|
3370
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3371
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3372
|
+
};
|
|
3373
|
+
readonly code: string;
|
|
3374
|
+
readonly fields?: readonly {
|
|
3375
|
+
readonly path: string;
|
|
3376
|
+
}[];
|
|
3377
|
+
readonly message: string;
|
|
3378
|
+
readonly retryAfterSeconds?: number;
|
|
3379
|
+
readonly retryable: boolean;
|
|
3380
|
+
readonly status?: number;
|
|
3381
|
+
}) | (RetryableActionHandlerError & {
|
|
3382
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3383
|
+
readonly channel?: {
|
|
3384
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3385
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3386
|
+
};
|
|
3387
|
+
readonly code: string;
|
|
3388
|
+
readonly fields?: readonly {
|
|
3389
|
+
readonly path: string;
|
|
3390
|
+
}[];
|
|
3391
|
+
readonly message: string;
|
|
3392
|
+
readonly retryAfterSeconds?: number;
|
|
3393
|
+
readonly retryable: boolean;
|
|
3394
|
+
readonly status?: number;
|
|
3395
|
+
}) | (Schema.SchemaError & {
|
|
3396
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3397
|
+
readonly channel?: {
|
|
3398
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3399
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3400
|
+
};
|
|
3401
|
+
readonly code: string;
|
|
3402
|
+
readonly fields?: readonly {
|
|
3403
|
+
readonly path: string;
|
|
3404
|
+
}[];
|
|
3405
|
+
readonly message: string;
|
|
3406
|
+
readonly retryAfterSeconds?: number;
|
|
3407
|
+
readonly retryable: boolean;
|
|
3408
|
+
readonly status?: number;
|
|
3409
|
+
}) | ({
|
|
3410
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3411
|
+
readonly channel?: {
|
|
3412
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3413
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3414
|
+
};
|
|
3415
|
+
readonly code: string;
|
|
3416
|
+
readonly fields?: readonly {
|
|
3417
|
+
readonly path: string;
|
|
3418
|
+
}[];
|
|
3419
|
+
readonly message: string;
|
|
3420
|
+
readonly retryAfterSeconds?: number;
|
|
3421
|
+
readonly retryable: boolean;
|
|
3422
|
+
readonly status?: number;
|
|
3423
|
+
} & ActionHandlerError) | ({
|
|
3424
|
+
readonly category: "connection" | "handler" | "initialization" | "protocol" | "validation";
|
|
3425
|
+
readonly channel?: {
|
|
3426
|
+
readonly code: "handler_unavailable" | "invalid_auth" | "invalid_definition" | "invalid_input" | "invalid_result" | "not_found" | "provider_failure" | "unsupported_feature";
|
|
3427
|
+
readonly providerCode?: "rate_limited" | "rejected" | "unauthorized" | "unavailable" | "unknown_completion" | "window_closed";
|
|
3428
|
+
};
|
|
3429
|
+
readonly code: string;
|
|
3430
|
+
readonly fields?: readonly {
|
|
3431
|
+
readonly path: string;
|
|
3432
|
+
}[];
|
|
3433
|
+
readonly message: string;
|
|
3434
|
+
readonly retryAfterSeconds?: number;
|
|
3435
|
+
readonly retryable: boolean;
|
|
3436
|
+
readonly status?: number;
|
|
3437
|
+
} & RetryableActionHandlerError);
|
|
3142
3438
|
identity: {
|
|
3143
3439
|
readonly artifactDigest: string;
|
|
3144
3440
|
readonly invocationId: string;
|