@dual-os/sdk 0.12.3 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/AgentChannel.js +2 -2
- package/dist/AgentChannelRuntime.d.ts +0 -2
- package/dist/AgentChannelRuntime.d.ts.map +1 -1
- package/dist/AgentChannelRuntime.js +5 -8
- package/dist/AgentChannelRuntime.js.map +1 -1
- package/dist/AiProvider.d.ts +1 -1
- package/dist/AiProvider.js +2 -2
- package/dist/AuthMethod.js +1 -1
- package/dist/AuthMethodExecution.js +2 -2
- package/dist/ConnectionResolver.d.ts +0 -1
- package/dist/ConnectionResolver.d.ts.map +1 -1
- package/dist/ConnectionResolver.js.map +1 -1
- package/dist/DualRegistry.d.ts +6 -6
- package/dist/DualRegistry.d.ts.map +1 -1
- package/dist/DualRegistry.js +1 -1
- package/dist/DualRuntime.d.ts +26 -26
- package/dist/DualRuntime.d.ts.map +1 -1
- package/dist/DualRuntime.js +6 -6
- package/dist/DualRuntime.js.map +1 -1
- package/dist/Group.d.ts +1 -1
- package/dist/Group.js +2 -2
- package/dist/Http.d.ts +1 -1
- package/dist/OAuthFlow.js +1 -1
- package/dist/Plugin.d.ts +46 -46
- package/dist/Plugin.js +3 -3
- package/dist/PluginRuntime.d.ts +0 -9
- package/dist/PluginRuntime.d.ts.map +1 -1
- package/dist/Runner.js +1 -1
- package/dist/Trigger.d.ts +3 -3
- package/dist/index.d.ts +14 -14
- package/dist/index.js +12 -12
- package/dist/internal/auth-context.d.ts +1 -1
- package/dist/internal/auth-execution.d.ts +1 -1
- package/dist/internal/auth-execution.d.ts.map +1 -1
- package/dist/internal/auth-execution.js.map +1 -1
- package/dist/internal/capabilities.d.ts +4 -4
- package/dist/internal/children.d.ts +5 -5
- package/dist/internal/children.js +2 -2
- package/dist/internal/dual/actions.d.ts +8 -8
- package/dist/internal/dual/actions.d.ts.map +1 -1
- package/dist/internal/dual/invoke.d.ts +6 -6
- package/dist/internal/dual/invoke.d.ts.map +1 -1
- package/dist/internal/dual/invoke.js +1 -1
- package/dist/internal/dual/invoke.js.map +1 -1
- package/dist/internal/dual/registry.d.ts +2 -2
- package/dist/internal/dual/triggers.d.ts +11 -11
- package/dist/internal/plugin-handlers.d.ts +11 -11
- package/dist/internal/plugin-handlers.d.ts.map +1 -1
- package/dist/internal/plugin-handlers.js +3 -3
- package/dist/internal/plugin-handlers.js.map +1 -1
- package/dist/internal/trigger-runtime-shared.d.ts +1 -1
- package/dist/internal/trigger-runtime-shared.d.ts.map +1 -1
- package/dist/internal/trigger-runtime-shared.js +2 -2
- package/dist/internal/trigger-runtime-shared.js.map +1 -1
- package/dist/internal/trigger-runtime.d.ts +1 -1
- package/dist/remote-runtime.d.ts +0 -2
- package/dist/remote-runtime.d.ts.map +1 -1
- package/dist/remote-runtime.js +12 -15
- package/dist/remote-runtime.js.map +1 -1
- package/package.json +2 -3
- package/src/AgentChannelRuntime.ts +3 -6
- package/src/ConnectionResolver.ts +0 -1
- package/src/DualRuntime.ts +13 -15
- package/src/internal/auth-execution.ts +12 -14
- package/src/internal/dual/invoke.ts +11 -14
- package/src/internal/plugin-handlers.ts +12 -13
- package/src/internal/trigger-runtime-shared.ts +3 -4
- package/src/remote-runtime.ts +1 -1
package/README.md
CHANGED
|
@@ -5,4 +5,5 @@ Runtime-neutral integration definitions and execution. Importing the SDK starts
|
|
|
5
5
|
- **Start.** [SDK guide](../docs/content/sdk/index.mdx) and [checked examples](../docs/examples/).
|
|
6
6
|
- **Public API.** The installed package's `exports` and declarations; shipped implementation modules are not supported entrypoints.
|
|
7
7
|
- **Hosting.** [Runtime guide](../docs/content/sdk/runtime.mdx); the SDK does not provision a product deployment.
|
|
8
|
+
- **Plugin releases.** [Versioning and runner support](../docs/content/sdk/plugins-versions.mdx) owns build, publication and incompatible-pin recovery.
|
|
8
9
|
- **Distribution.** Private registry access; [release procedure](../../docs/releasing.md).
|
package/dist/AgentChannel.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { validateIdentifier } from "./internal/identifier.js";
|
|
3
|
-
import { PipeableProto } from "./internal/proto.js";
|
|
4
2
|
import { isAuthMethod } from "./AuthMethod.js";
|
|
5
3
|
import { File } from "./Files.js";
|
|
4
|
+
import { validateIdentifier } from "./internal/identifier.js";
|
|
5
|
+
import { PipeableProto } from "./internal/proto.js";
|
|
6
6
|
import "./AgentChannel.js";
|
|
7
7
|
import { Match, Option, Predicate, Schema } from "effect";
|
|
8
8
|
// src/AgentChannel.ts
|
|
@@ -22,7 +22,6 @@ export declare const ConnectionContext: Schema.Struct<{
|
|
|
22
22
|
}>>;
|
|
23
23
|
readonly tenant: Schema.optionalKey<Schema.Struct<{
|
|
24
24
|
readonly organizationId: Schema.NonEmptyString;
|
|
25
|
-
readonly teamId: Schema.NonEmptyString;
|
|
26
25
|
}>>;
|
|
27
26
|
}>;
|
|
28
27
|
declare const Pin: Schema.Struct<{
|
|
@@ -46,7 +45,6 @@ declare const Input: Schema.Struct<{
|
|
|
46
45
|
}>>;
|
|
47
46
|
readonly tenant: Schema.optionalKey<Schema.Struct<{
|
|
48
47
|
readonly organizationId: Schema.NonEmptyString;
|
|
49
|
-
readonly teamId: Schema.NonEmptyString;
|
|
50
48
|
}>>;
|
|
51
49
|
}>>;
|
|
52
50
|
readonly definitionSettings: Schema.Unknown;
|
|
@@ -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":";;;;;;;;;;qBAWa,mBAAiB,OAAA
|
|
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":";;;;;;;;;;qBAWa,mBAAiB,OAAA;;;;;;;;;;;;;;;;cAexB,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;IAEzE,iBAAiB,kCACjB,iBAAiB;YAEX,aAAa,UAAUA,SAC/B,eAAe,KACf,sBAAsB,YAAY,MAClC,YAAY,+CACZ,YAAY,+CACZ,YAAY,kCACZ,YAAY,kCACZ,2BAA2B,YAAY,sBACtC,YAAY,kDAAkDG;;qBA8MtD,QAAS,UAAUH,OAAU,kBACtB,QACjB,MAAM,MAAM,gBAAgB,aAAa"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { Service as Service$1 } from "./Files.js";
|
|
3
2
|
import { AccessOutcome, ChannelError, CheckedResult, FailureCode, Key, Verification, VerifiedIdentity, commandSchema, handlerKey, resultByteLimit, resultSchema, validateDefinition } from "./AgentChannel.js";
|
|
4
|
-
import { Service as Service$
|
|
3
|
+
import { Service as Service$1 } from "./ConnectionResolver.js";
|
|
4
|
+
import { Service as Service$2 } from "./Files.js";
|
|
5
5
|
import { findHandler } from "./internal/handler-context.js";
|
|
6
6
|
import "./AgentChannelRuntime.js";
|
|
7
7
|
import { Cause, Context, Effect, Layer, Option, Predicate, Schema } from "effect";
|
|
@@ -26,10 +26,7 @@ const ConnectionContext = Schema.Struct({
|
|
|
26
26
|
kind: Key,
|
|
27
27
|
subjectId: Schema.optionalKey(Key)
|
|
28
28
|
})),
|
|
29
|
-
tenant: Schema.optionalKey(Schema.Struct({
|
|
30
|
-
organizationId: Key,
|
|
31
|
-
teamId: Key
|
|
32
|
-
}))
|
|
29
|
+
tenant: Schema.optionalKey(Schema.Struct({ organizationId: Key }))
|
|
33
30
|
});
|
|
34
31
|
const Pin = Schema.Struct({ channelId: Key });
|
|
35
32
|
const Input = Schema.Struct({
|
|
@@ -63,7 +60,7 @@ const decodeData = Effect.fn("AgentChannelRuntime.decodeData")(function* (schema
|
|
|
63
60
|
yield* decode(boundary, value, code);
|
|
64
61
|
return value;
|
|
65
62
|
});
|
|
66
|
-
const withChannelContext = (captured) => Effect.updateContext((current) => Context.mergeAll(current, captured, Context.pick(Service$
|
|
63
|
+
const withChannelContext = (captured) => Effect.updateContext((current) => Context.mergeAll(current, captured, Context.pick(Service$2)(current)));
|
|
67
64
|
const invokeHandler = (handler, effect) => effect.pipe(withChannelContext(handler.context), Effect.catch((error) => decode(Schema.TaggedStruct("AgentChannelHandlerError", { code: FailureCode }), Predicate.isObject(error) ? { ...error } : error, "provider_failure").pipe(Effect.flatMap((checked) => Effect.fail(new ChannelError({
|
|
68
65
|
code: "provider_failure",
|
|
69
66
|
providerCode: checked.code
|
|
@@ -96,7 +93,7 @@ const resolveAuth = Effect.fn("AgentChannelRuntime.resolveAuth")(function* (prov
|
|
|
96
93
|
return;
|
|
97
94
|
}
|
|
98
95
|
if (connectionId === void 0) return yield* fail("invalid_auth");
|
|
99
|
-
const resolver = yield* Effect.serviceOption(Service$
|
|
96
|
+
const resolver = yield* Effect.serviceOption(Service$1);
|
|
100
97
|
if (Option.isNone(resolver)) return yield* fail("invalid_auth");
|
|
101
98
|
const raw = yield* safe(Effect.suspend(() => resolver.value.resolve({
|
|
102
99
|
connectionId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AgentChannelRuntime.js","names":["AgentChannel.Key","AgentChannel.VerifiedIdentity","AgentChannel.ChannelError","AgentChannel.resultByteLimit","Files.Service","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 { Files } from \"./Files.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\n// The worker supplies Files per invocation, with a grant scoped to that call.\nconst withChannelContext = (captured: Context.Context<never>) =>\n Effect.updateContext(current =>\n Context.mergeAll(current, captured, Context.pick(Files.Service)(current)),\n );\n\nconst invokeHandler = (\n handler: AgentChannel.Handler,\n effect: Effect.Effect<unknown, unknown, unknown>,\n) =>\n effect.pipe(\n withChannelContext(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 if (\n (command.kind === \"read_asset\" && !definition.features.assets) ||\n (command.kind === \"read_sender\" && definition.features.readSender !== true)\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 senderKey = command.kind === \"read_sender\" ? command.identity.senderKey : 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 // A read on behalf of a sender acts for that sender, so the sender must have access.\n if (command.kind === \"read_asset\" || command.kind === \"read_sender\") {\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), definition.features),\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 (result.kind === \"read_sender\" && result.senderKey !== senderKey)\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(\n AgentChannel.resultSchema(definition.state, definition.features),\n )(\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(withChannelContext(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":";;;;;;;;;;;;;;;;AAWA,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,UAAb,cAA6B,QAAQ,QAA4B,CAAC,CAChE,kCACF,CAAC,CAAC,CAAC;AA0BH,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Y,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","Files.Service","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 { Files } from \"./Files.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(Schema.Struct({ organizationId: AgentChannel.Key })),\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 ? | 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\n// The worker supplies Files per invocation, with a grant scoped to that call.\nconst withChannelContext = (captured: Context.Context<never>) =>\n Effect.updateContext(current =>\n Context.mergeAll(current, captured, Context.pick(Files.Service)(current)),\n );\n\nconst invokeHandler = (\n handler: AgentChannel.Handler,\n effect: Effect.Effect<unknown, unknown, unknown>,\n) =>\n effect.pipe(\n withChannelContext(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 if (\n (command.kind === \"read_asset\" && !definition.features.assets) ||\n (command.kind === \"read_sender\" && definition.features.readSender !== true)\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 senderKey = command.kind === \"read_sender\" ? command.identity.senderKey : 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 // A read on behalf of a sender acts for that sender, so the sender must have access.\n if (command.kind === \"read_asset\" || command.kind === \"read_sender\") {\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), definition.features),\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 (result.kind === \"read_sender\" && result.senderKey !== senderKey)\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(\n AgentChannel.resultSchema(definition.state, definition.features),\n )(\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(withChannelContext(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":";;;;;;;;;;;;;;;;AAWA,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,YAAY,OAAO,OAAO,EAAE,gBAAgBA,IAAiB,CAAC,CAAC;AAChF,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,UAAb,cAA6B,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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"}
|
package/dist/AiProvider.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BindingFor } from "./AuthMethodBinding.js";
|
|
2
1
|
import { Any as Any$1 } from "./AuthMethod.js";
|
|
2
|
+
import { BindingFor } from "./AuthMethodBinding.js";
|
|
3
3
|
import { Category } from "./Plugin.js";
|
|
4
4
|
import { Pipeable, Schema } from "effect";
|
|
5
5
|
declare namespace AiProvider_d_exports {
|
package/dist/AiProvider.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { validateIdentifier } from "./internal/identifier.js";
|
|
3
|
-
import { PipeableProto } from "./internal/proto.js";
|
|
4
2
|
import { assertNoDuplicateAuthMethodIdentifiers } from "./internal/auth-runtime.js";
|
|
5
3
|
import { appendElements } from "./internal/collection-utils.js";
|
|
4
|
+
import { validateIdentifier } from "./internal/identifier.js";
|
|
5
|
+
import { PipeableProto } from "./internal/proto.js";
|
|
6
6
|
import { Function, Predicate, Schema } from "effect";
|
|
7
7
|
// src/AiProvider.ts
|
|
8
8
|
var AiProvider_exports = /* @__PURE__ */ __exportAll({
|
package/dist/AuthMethod.js
CHANGED
|
@@ -2,8 +2,8 @@ import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
|
2
2
|
import { validateIdentifier } from "./internal/identifier.js";
|
|
3
3
|
import { PipeableProto } from "./internal/proto.js";
|
|
4
4
|
import { isBindingForMethod, makeBinding } from "./AuthMethodBinding.js";
|
|
5
|
-
import { OAuth2TokenRefresher_exports, Service } from "./OAuth2TokenRefresher.js";
|
|
6
5
|
import { decodeInput, decodeMaterial, decodeSetup, decodeValue, display, prepare, prepareDecoded, prepareOAuth2Tokens, prepareUnknown, refreshDecoded, refreshUnknown, resolve, resolveDecoded, resolveUnknown, test } from "./AuthMethodExecution.js";
|
|
6
|
+
import { OAuth2TokenRefresher_exports, Service } from "./OAuth2TokenRefresher.js";
|
|
7
7
|
import { Function, Predicate, Schema } from "effect";
|
|
8
8
|
// src/AuthMethod.ts
|
|
9
9
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { Service } from "./OAuth2TokenRefresher.js";
|
|
3
|
-
import "./AuthMethodExecution.js";
|
|
4
2
|
import { AuthMethodHookError, ExpectedOAuth2MethodError, OAuth2RefreshTokenUnavailableError } from "./AuthMethod.js";
|
|
3
|
+
import "./AuthMethodExecution.js";
|
|
4
|
+
import { Service } from "./OAuth2TokenRefresher.js";
|
|
5
5
|
import { Effect, Schema } from "effect";
|
|
6
6
|
// src/AuthMethodExecution.ts
|
|
7
7
|
/**
|
|
@@ -18,7 +18,6 @@ export type ConnectionTargetKind = "action" | "trigger" | "ai_model" | "agent-ch
|
|
|
18
18
|
*/
|
|
19
19
|
export interface ConnectionResolutionTenant {
|
|
20
20
|
readonly organizationId: string;
|
|
21
|
-
readonly teamId: string;
|
|
22
21
|
}
|
|
23
22
|
/**
|
|
24
23
|
* Product actor on whose behalf a connection is being selected.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionResolver.d.ts","names":[],"sources":["../src/ConnectionResolver.ts"],"mappings":";;;;;;;;;;;YAcY;;;;;;;iBAQK;WACN
|
|
1
|
+
{"version":3,"file":"ConnectionResolver.d.ts","names":[],"sources":["../src/ConnectionResolver.ts"],"mappings":";;;;;;;;;;;YAcY;;;;;;;iBAQK;WACN;;;;;;;;YASC;WACG;WAAuB;;WACvB;WAAyB;;;;;;;;iBAQvB;WACN;WACA;WACA,WAAW,SAAS;;;;;;;;iBASd;WACN,SAAS;WACT,QAAQ;WACR,SAAS;WACT,WAAW,SAAS;;;;;;;;iBASd;WACN;WACA,YAAY;WACZ;WACA;;iBAGM;WACN,QAAQ;WACR;WACA,UAAU;;iBAGJ;WACN;WACA;WACA;WACA;WACA;WACA;;;;;;;;;;;;;;;qBASE,oCAAoC;;;;;;;;;;;;;qBAiBpC,gCAAgC;;;;;;;;;;;;;qBAgBhC,yCAAyC;;;;;;;;;;;;;;qBAgBzC,iCAAiC;;;;;;;;;;;;;;;qBAiBjC,uCAAuC;;;;;;;;;;;;;;;qBAkBvC,+CAA+C;;;;;;;;;;;;;;;qBAkB/C,qCAAqC;;;;;;;YAkBtC,kBACR,8BACA,0BACA,mCACA,2BACA,iCACA,yCACA;;;;;;;YAQQ,yBACR,0BACA,mCACA,2BACA,iCACA,yCACA;;;;;;;;;;iBAWa;WACN,UACP,OAAO,6BACJ,OAAO,OAAO,4BAA4B;;;;;;;;;qBASpC,gBAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionResolver.js","names":[],"sources":["../src/ConnectionResolver.ts"],"sourcesContent":["/**\n * Host-provided connection resolution contracts for SDK execution flows.\n *\n * @since 0.0.0\n */\nimport type { Effect } from \"effect\";\nimport { Context, Schema } from \"effect\";\n\n/**\n * Connection-aware runtime targets supported by the SDK.\n *\n * @since 0.0.0\n * @category models\n */\nexport type ConnectionTargetKind = \"action\" | \"trigger\" | \"ai_model\" | \"agent-channel\";\n\n/**\n * Tenant boundary for connection resolution and audit.\n *\n * @since 0.0.0\n * @category models\n */\nexport interface ConnectionResolutionTenant {\n readonly organizationId: string;\n
|
|
1
|
+
{"version":3,"file":"ConnectionResolver.js","names":[],"sources":["../src/ConnectionResolver.ts"],"sourcesContent":["/**\n * Host-provided connection resolution contracts for SDK execution flows.\n *\n * @since 0.0.0\n */\nimport type { Effect } from \"effect\";\nimport { Context, Schema } from \"effect\";\n\n/**\n * Connection-aware runtime targets supported by the SDK.\n *\n * @since 0.0.0\n * @category models\n */\nexport type ConnectionTargetKind = \"action\" | \"trigger\" | \"ai_model\" | \"agent-channel\";\n\n/**\n * Tenant boundary for connection resolution and audit.\n *\n * @since 0.0.0\n * @category models\n */\nexport interface ConnectionResolutionTenant {\n readonly organizationId: string;\n}\n\n/**\n * Product actor on whose behalf a connection is being selected.\n *\n * @since 0.0.0\n * @category models\n */\nexport type ConnectionResolutionActor =\n | { readonly kind: \"user\"; readonly userId: string }\n | { readonly kind: \"system\"; readonly reason?: string | undefined };\n\n/**\n * Product source that caused the invocation.\n *\n * @since 0.0.0\n * @category models\n */\nexport interface ConnectionResolutionSource {\n readonly kind: string;\n readonly subjectId?: string;\n readonly metadata?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * Host-owned context used to select, authorize, and audit a connection.\n *\n * @since 0.0.0\n * @category models\n */\nexport interface ConnectionResolutionContext {\n readonly tenant?: ConnectionResolutionTenant;\n readonly actor?: ConnectionResolutionActor;\n readonly source?: ConnectionResolutionSource;\n readonly metadata?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * Request sent to the host connection resolver during action or trigger execution.\n *\n * @since 0.0.0\n * @category models\n */\nexport interface ConnectionResolutionTarget {\n readonly providerId: string;\n readonly targetKind: ConnectionTargetKind;\n readonly targetId: string;\n readonly phase?: string;\n}\n\nexport interface ResolveConnectionRequest {\n readonly target: ConnectionResolutionTarget;\n readonly connectionId?: string;\n readonly context?: ConnectionResolutionContext;\n}\n\nexport interface ResolvedConnectionMaterial {\n readonly encoding?: \"json\";\n readonly providerId: string;\n readonly connectionId: string;\n readonly methodId: string;\n readonly material: unknown;\n readonly setup: unknown;\n}\n\n/**\n * Raised when a runtime target does not accept a connection but a connectionId was still provided.\n *\n * @since 0.0.0\n * @category errors\n */\nexport class ConnectionIdNotAllowedError extends Schema.TaggedError<ConnectionIdNotAllowedError>()(\n \"ConnectionIdNotAllowedError\",\n {\n connectionId: Schema.String,\n phase: Schema.optional(Schema.String),\n providerId: Schema.String,\n targetId: Schema.String,\n targetKind: Schema.Literals([\"action\", \"trigger\", \"ai_model\", \"agent-channel\"]),\n },\n) {}\n\n/**\n * Raised when execution requires a connection and no compatible binding is available.\n *\n * @since 0.0.0\n * @category errors\n */\nexport class ConnectionRequiredError extends Schema.TaggedError<ConnectionRequiredError>()(\n \"ConnectionRequiredError\",\n {\n phase: Schema.optional(Schema.String),\n providerId: Schema.String,\n targetId: Schema.String,\n targetKind: Schema.Literals([\"action\", \"trigger\", \"ai_model\", \"agent-channel\"]),\n },\n) {}\n\n/**\n * Raised when several compatible connection bindings exist and the caller must choose one.\n *\n * @since 0.0.0\n * @category errors\n */\nexport class ConnectionSelectionRequiredError extends Schema.TaggedError<ConnectionSelectionRequiredError>()(\n \"ConnectionSelectionRequiredError\",\n {\n phase: Schema.optional(Schema.String),\n providerId: Schema.String,\n targetId: Schema.String,\n targetKind: Schema.Literals([\"action\", \"trigger\", \"ai_model\", \"agent-channel\"]),\n },\n) {}\n\n/**\n * Raised when the requested connectionId does not resolve to a compatible binding.\n *\n * @since 0.0.0\n * @category errors\n */\nexport class InvalidConnectionIdError extends Schema.TaggedError<InvalidConnectionIdError>()(\n \"InvalidConnectionIdError\",\n {\n connectionId: Schema.String,\n phase: Schema.optional(Schema.String),\n providerId: Schema.String,\n targetId: Schema.String,\n targetKind: Schema.Literals([\"action\", \"trigger\", \"ai_model\", \"agent-channel\"]),\n },\n) {}\n\n/**\n * Raised when the resolved connection value does not satisfy the selected auth method schema.\n *\n * @since 0.0.0\n * @category errors\n */\nexport class InvalidResolvedConnectionError extends Schema.TaggedError<InvalidResolvedConnectionError>()(\n \"InvalidResolvedConnectionError\",\n {\n description: Schema.String,\n methodId: Schema.String,\n phase: Schema.optional(Schema.String),\n providerId: Schema.String,\n targetId: Schema.String,\n targetKind: Schema.Literals([\"action\", \"trigger\", \"ai_model\", \"agent-channel\"]),\n },\n) {}\n\n/**\n * Raised when the provider refuses the connection's stored grant, so the user must sign in again.\n *\n * @since 0.0.0\n * @category errors\n */\nexport class ConnectionReauthorizationRequiredError extends Schema.TaggedError<ConnectionReauthorizationRequiredError>()(\n \"ConnectionReauthorizationRequiredError\",\n {\n connectionId: Schema.String,\n message: Schema.String,\n phase: Schema.optional(Schema.String),\n providerId: Schema.String,\n targetId: Schema.String,\n targetKind: Schema.Literals([\"action\", \"trigger\", \"ai_model\", \"agent-channel\"]),\n },\n) {}\n\n/**\n * Raised when the host credential store cannot be read during connection resolution.\n *\n * @since 0.0.0\n * @category errors\n */\nexport class ConnectionResolverStoreError extends Schema.TaggedError<ConnectionResolverStoreError>()(\n \"ConnectionResolverStoreError\",\n {\n cause: Schema.Defect(),\n operation: Schema.String,\n phase: Schema.optional(Schema.String),\n providerId: Schema.String,\n targetId: Schema.String,\n targetKind: Schema.Literals([\"action\", \"trigger\", \"ai_model\", \"agent-channel\"]),\n },\n) {}\n\n/**\n * Structured connection failures surfaced by SDK runtime boundaries.\n *\n * @since 0.0.0\n * @category errors\n */\nexport type ConnectionError =\n | ConnectionIdNotAllowedError\n | ConnectionRequiredError\n | ConnectionSelectionRequiredError\n | InvalidConnectionIdError\n | InvalidResolvedConnectionError\n | ConnectionReauthorizationRequiredError\n | ConnectionResolverStoreError;\n\n/**\n * Errors the host resolver itself is expected to surface.\n *\n * @since 0.0.0\n * @category errors\n */\nexport type ResolveConnectionError =\n | ConnectionRequiredError\n | ConnectionSelectionRequiredError\n | InvalidConnectionIdError\n | InvalidResolvedConnectionError\n | ConnectionReauthorizationRequiredError\n | ConnectionResolverStoreError;\n\n/**\n * Host-provided service used by SDK runtimes to select one concrete connection binding.\n *\n * The SDK narrows and validates this untyped host binding against the target's allowed methods\n * before exposing it to handlers.\n *\n * @since 0.0.0\n * @category services\n */\nexport interface ConnectionResolverInstance {\n readonly resolve: (\n input: ResolveConnectionRequest,\n ) => Effect.Effect<ResolvedConnectionMaterial, ResolveConnectionError>;\n}\n\n/**\n * Host-provided connection resolver service.\n *\n * @since 0.0.0\n * @category services\n */\nexport class Service extends Context.Service<Service, ConnectionResolverInstance>()(\n \"@dual-os/sdk/ConnectionResolver\",\n) {}\n\nexport * as ConnectionResolver from \"./ConnectionResolver.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+FA,IAAa,8BAAb,cAAiD,OAAO,YAAyC,CAAC,CAChG,+BACA;CACE,cAAc,OAAO;CACrB,OAAO,OAAO,SAAS,OAAO,MAAM;CACpC,YAAY,OAAO;CACnB,UAAU,OAAO;CACjB,YAAY,OAAO,SAAS;EAAC;EAAU;EAAW;EAAY;CAAe,CAAC;AAChF,CACF,CAAC,CAAC,CAAC;;;;;;;AAQH,IAAa,0BAAb,cAA6C,OAAO,YAAqC,CAAC,CACxF,2BACA;CACE,OAAO,OAAO,SAAS,OAAO,MAAM;CACpC,YAAY,OAAO;CACnB,UAAU,OAAO;CACjB,YAAY,OAAO,SAAS;EAAC;EAAU;EAAW;EAAY;CAAe,CAAC;AAChF,CACF,CAAC,CAAC,CAAC;;;;;;;AAQH,IAAa,mCAAb,cAAsD,OAAO,YAA8C,CAAC,CAC1G,oCACA;CACE,OAAO,OAAO,SAAS,OAAO,MAAM;CACpC,YAAY,OAAO;CACnB,UAAU,OAAO;CACjB,YAAY,OAAO,SAAS;EAAC;EAAU;EAAW;EAAY;CAAe,CAAC;AAChF,CACF,CAAC,CAAC,CAAC;;;;;;;AAQH,IAAa,2BAAb,cAA8C,OAAO,YAAsC,CAAC,CAC1F,4BACA;CACE,cAAc,OAAO;CACrB,OAAO,OAAO,SAAS,OAAO,MAAM;CACpC,YAAY,OAAO;CACnB,UAAU,OAAO;CACjB,YAAY,OAAO,SAAS;EAAC;EAAU;EAAW;EAAY;CAAe,CAAC;AAChF,CACF,CAAC,CAAC,CAAC;;;;;;;AAQH,IAAa,iCAAb,cAAoD,OAAO,YAA4C,CAAC,CACtG,kCACA;CACE,aAAa,OAAO;CACpB,UAAU,OAAO;CACjB,OAAO,OAAO,SAAS,OAAO,MAAM;CACpC,YAAY,OAAO;CACnB,UAAU,OAAO;CACjB,YAAY,OAAO,SAAS;EAAC;EAAU;EAAW;EAAY;CAAe,CAAC;AAChF,CACF,CAAC,CAAC,CAAC;;;;;;;AAQH,IAAa,yCAAb,cAA4D,OAAO,YAAoD,CAAC,CACtH,0CACA;CACE,cAAc,OAAO;CACrB,SAAS,OAAO;CAChB,OAAO,OAAO,SAAS,OAAO,MAAM;CACpC,YAAY,OAAO;CACnB,UAAU,OAAO;CACjB,YAAY,OAAO,SAAS;EAAC;EAAU;EAAW;EAAY;CAAe,CAAC;AAChF,CACF,CAAC,CAAC,CAAC;;;;;;;AAQH,IAAa,+BAAb,cAAkD,OAAO,YAA0C,CAAC,CAClG,gCACA;CACE,OAAO,OAAO,OAAO;CACrB,WAAW,OAAO;CAClB,OAAO,OAAO,SAAS,OAAO,MAAM;CACpC,YAAY,OAAO;CACnB,UAAU,OAAO;CACjB,YAAY,OAAO,SAAS;EAAC;EAAU;EAAW;EAAY;CAAe,CAAC;AAChF,CACF,CAAC,CAAC,CAAC;;;;;;;AAoDH,IAAa,UAAb,cAA6B,QAAQ,QAA6C,CAAC,CACjF,iCACF,CAAC,CAAC,CAAC"}
|
package/dist/DualRegistry.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Any } from "./
|
|
2
|
-
import { Any as Any$1 } from "./AiProvider.js";
|
|
3
|
-
import { AllActionEntries } from "./internal/dual/actions.js";
|
|
1
|
+
import { Any } from "./AiProvider.js";
|
|
4
2
|
import { AnyApp, App } from "./DualRuntime.js";
|
|
3
|
+
import { AllActionEntries } from "./internal/dual/actions.js";
|
|
5
4
|
import { MaterializedActionCapabilityVersion, MaterializedAuthMethod, MaterializedCapabilityVersion, MaterializedChannelCapabilityVersion, MaterializedProvider, MaterializedRegistry, MaterializedRegistryOptions, MaterializedTriggerCapabilityVersion } from "./internal/dual/registry.js";
|
|
6
5
|
import { AllTriggerEntries, RuntimeTriggerEntry } from "./internal/dual/triggers.js";
|
|
6
|
+
import { Any as Any$1 } from "./Plugin.js";
|
|
7
7
|
import "./DualRegistry.js";
|
|
8
8
|
import { Schema } from "effect";
|
|
9
9
|
declare namespace DualRegistry_d_exports {
|
|
@@ -20,14 +20,14 @@ export declare class TriggerNotFoundError extends TriggerNotFoundError_base {}
|
|
|
20
20
|
* @since 0.0.0
|
|
21
21
|
* @category getters
|
|
22
22
|
*/
|
|
23
|
-
export declare const actionIds: <const P extends Any, LayerOutput, LayerError, LayerRequirements, const AiProviders extends readonly Any
|
|
23
|
+
export declare const actionIds: <const P extends Any$1, LayerOutput, LayerError, LayerRequirements, const AiProviders extends readonly Any[]>(app: App<P, LayerOutput, LayerError, LayerRequirements, AiProviders>) => readonly AllActionEntries<readonly [P]>["actionId"][];
|
|
24
24
|
/**
|
|
25
25
|
* Enumerate the canonical machine ids for every trigger in the app.
|
|
26
26
|
*
|
|
27
27
|
* @since 0.0.0
|
|
28
28
|
* @category getters
|
|
29
29
|
*/
|
|
30
|
-
export declare const triggerIds: <const P extends Any, LayerOutput, LayerError, LayerRequirements, const AiProviders extends readonly Any
|
|
30
|
+
export declare const triggerIds: <const P extends Any$1, LayerOutput, LayerError, LayerRequirements, const AiProviders extends readonly Any[]>(app: App<P, LayerOutput, LayerError, LayerRequirements, AiProviders>) => readonly AllTriggerEntries<readonly [P]>["triggerId"][];
|
|
31
31
|
/**
|
|
32
32
|
* Resolve one trigger entry from the app, including its auth methods.
|
|
33
33
|
*
|
|
@@ -56,7 +56,7 @@ export interface MaterializedPlugin {
|
|
|
56
56
|
* @since 0.0.0
|
|
57
57
|
* @category registry
|
|
58
58
|
*/
|
|
59
|
-
export declare const materializePlugin: (plugin: Any, options: MaterializedRegistryOptions & {
|
|
59
|
+
export declare const materializePlugin: (plugin: Any$1, options: MaterializedRegistryOptions & {
|
|
60
60
|
readonly version: string;
|
|
61
61
|
}) => MaterializedPlugin;
|
|
62
62
|
/** Every installed plugin release and its contracts. @since 0.0.0 @category registry */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DualRegistry.d.ts","names":["Plugin.Any","AiProvider.Any"],"sources":["../src/DualRegistry.ts"],"mappings":";;;;;;;;;;;;;;;qBAwBa,6BAA6B;;;;;;;qBAW7B,kBACL,UAAUA,
|
|
1
|
+
{"version":3,"file":"DualRegistry.d.ts","names":["Plugin.Any","AiProvider.Any"],"sources":["../src/DualRegistry.ts"],"mappings":";;;;;;;;;;;;;;;qBAwBa,6BAA6B;;;;;;;qBAW7B,kBACL,UAAUA,OAChB,aACA,YACA,yBACM,6BAA6BC,OAAgB,KAE9C,IAAI,GAAG,aAAa,YAAY,mBAAmB,0BAC9C,2BAA2B;;;;;;;qBAU1B,mBACL,UAAUD,OAChB,aACA,YACA,yBACM,6BAA6BC,OAAgB,KAE9C,IAAI,GAAG,aAAa,YAAY,mBAAmB,0BAC9C,4BAA4B;;;;;;;qBAU3B,iBAAc,KACpB,QAAM,mBACM;WACG;MACnB;;;;;;;qBAqBU,sBAAmB,KACzB,QAAM,UACF,gCACR;;iBAWc;WACN;WACA;WACA,oBAAoB;;;;;;;;qBASlB,oBAAiB,QACpBD,OAAU,SACT;WAAyC;MACjD;;qBAcU,qBAAkB,KAAS,QAAM,UAAW;EA5B5B;EACH;EACJ,oBAAS"}
|
package/dist/DualRegistry.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { collectActionEntries } from "./internal/dual/actions.js";
|
|
3
|
-
import { collectTriggerEntries, resolveRuntimeTrigger } from "./internal/dual/triggers.js";
|
|
4
3
|
import { materializeResolvedRegistry } from "./internal/dual/registry.js";
|
|
4
|
+
import { collectTriggerEntries, resolveRuntimeTrigger } from "./internal/dual/triggers.js";
|
|
5
5
|
import "./DualRegistry.js";
|
|
6
6
|
import { Schema } from "effect";
|
|
7
7
|
// src/DualRegistry.ts
|
package/dist/DualRuntime.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
+
import { ActionHandlerError, ActionHandlerFailure, RetryableActionHandlerError } from "./Action.js";
|
|
2
|
+
import { Interface, Requirements } from "./AgentChannelRuntime.js";
|
|
3
|
+
import { AllowedModelIds, Any, RuntimeConfig, RuntimeModel } from "./AiProvider.js";
|
|
4
|
+
import { Any as Any$1, AuthMethodHookError, ExpectedOAuth2MethodError, InputSchema, MaterialSchema, OAuth2RefreshTokenUnavailableError, OAuth2TokenResponse, RefreshReason, Requirements as Requirements$1, SetupSchema, ValueSchema } from "./AuthMethod.js";
|
|
1
5
|
import { Binding } from "./AuthMethodBinding.js";
|
|
2
6
|
import { JsonRequest } from "./AuthMethodExecution.js";
|
|
3
|
-
import { Any, AuthMethodHookError, ExpectedOAuth2MethodError, InputSchema, MaterialSchema, OAuth2RefreshTokenUnavailableError, OAuth2TokenResponse, RefreshReason, Requirements, SetupSchema, ValueSchema } from "./AuthMethod.js";
|
|
4
|
-
import { ActionHandlerError, ActionHandlerFailure, RetryableActionHandlerError } from "./Action.js";
|
|
5
7
|
import { ConnectionIdNotAllowedError, ConnectionReauthorizationRequiredError, ConnectionRequiredError, ConnectionResolutionContext, ConnectionResolverStoreError, ConnectionSelectionRequiredError, InvalidConnectionIdError, InvalidResolvedConnectionError } from "./ConnectionResolver.js";
|
|
6
|
-
import { ActivateSuccess, DeactivateSuccess, EmittedEventsSuccess, VerifySuccess, WebhookRequest } from "./Trigger.js";
|
|
7
|
-
import { Any as Any$1, LayerError, LayerOutput as LayerOutput$1, LayerRequirements as LayerRequirements$1 } from "./Plugin.js";
|
|
8
|
-
import { Interface, Requirements as Requirements$1 } from "./AgentChannelRuntime.js";
|
|
9
|
-
import { AllowedModelIds, Any as Any$2, RuntimeConfig, RuntimeModel } from "./AiProvider.js";
|
|
10
8
|
import { PluginActions } from "./internal/dual/actions.js";
|
|
11
9
|
import { ActionHandlerNotFoundError, ActionNotFoundError, FieldIssue, InvalidActionInputError, InvalidActionOutputError, InvokeError, InvokeMeta, InvokeRequest, InvokeRequirementsFor, InvokeSuccess, PluginRequirements } from "./internal/dual/invoke.js";
|
|
10
|
+
import { Any as Any$2, LayerError, LayerOutput as LayerOutput$1, LayerRequirements as LayerRequirements$1 } from "./Plugin.js";
|
|
11
|
+
import { ActivateSuccess, DeactivateSuccess, EmittedEventsSuccess, VerifySuccess, WebhookRequest } from "./Trigger.js";
|
|
12
12
|
import "./DualRuntime.js";
|
|
13
13
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
14
14
|
import { HttpClientRequest } from "effect/http";
|
|
@@ -21,7 +21,7 @@ declare namespace DualRuntime_d_exports {
|
|
|
21
21
|
* @since 0.7.0
|
|
22
22
|
* @category models
|
|
23
23
|
*/
|
|
24
|
-
export interface PluginInstallation<P extends Any$
|
|
24
|
+
export interface PluginInstallation<P extends Any$2 = Any$2> {
|
|
25
25
|
readonly plugin: P;
|
|
26
26
|
/** The plugin's package version. */
|
|
27
27
|
readonly version: string;
|
|
@@ -32,7 +32,7 @@ export interface PluginInstallation<P extends Any$1 = Any$1> {
|
|
|
32
32
|
* @since 0.7.0
|
|
33
33
|
* @category models
|
|
34
34
|
*/
|
|
35
|
-
export interface App<out P extends Any$
|
|
35
|
+
export interface App<out P extends Any$2 = Any$2, LayerOutput = never, out LayerError = never, out LayerRequirements = never, out AiProviders extends readonly Any[] = readonly Any[]> {
|
|
36
36
|
readonly identifier: string;
|
|
37
37
|
readonly aiProviders: AiProviders;
|
|
38
38
|
readonly plugins: readonly PluginInstallation<P>[];
|
|
@@ -44,14 +44,14 @@ export interface App<out P extends Any$1 = Any$1, LayerOutput = never, out Layer
|
|
|
44
44
|
* @since 0.7.0
|
|
45
45
|
* @category type-level
|
|
46
46
|
*/
|
|
47
|
-
export interface AnyApp extends App<Any$
|
|
47
|
+
export interface AnyApp extends App<Any$2, never, any, any, readonly Any[]> {}
|
|
48
48
|
/**
|
|
49
49
|
* Install one plugin release.
|
|
50
50
|
*
|
|
51
51
|
* @since 0.7.0
|
|
52
52
|
* @category constructors
|
|
53
53
|
*/
|
|
54
|
-
export declare const install: <P extends Any$
|
|
54
|
+
export declare const install: <P extends Any$2>(plugin: P, version: string) => PluginInstallation<P>;
|
|
55
55
|
/**
|
|
56
56
|
* The runtime of one plugin release, as the plugin's own process runs it. `version` defaults to
|
|
57
57
|
* `0.0.0` for tests that do not need the package version.
|
|
@@ -59,7 +59,7 @@ export declare const install: <P extends Any$1>(plugin: P, version: string) => P
|
|
|
59
59
|
* @since 0.7.0
|
|
60
60
|
* @category constructors
|
|
61
61
|
*/
|
|
62
|
-
export declare const fromPlugin: <const P extends Any$
|
|
62
|
+
export declare const fromPlugin: <const P extends Any$2>(plugin: P, version?: string) => App<P, LayerOutput$1<readonly [P]>, LayerError<readonly [P]>, LayerRequirements$1<readonly [P]>, readonly []>;
|
|
63
63
|
/**
|
|
64
64
|
* An app runtime without plugins, for {@link withPlugin} and {@link withPlugins} to fill.
|
|
65
65
|
*
|
|
@@ -78,17 +78,17 @@ type AppLayerRequirements<A extends AnyApp> = A extends App<any, any, any, infer
|
|
|
78
78
|
* @since 0.7.0
|
|
79
79
|
* @category type-level
|
|
80
80
|
*/
|
|
81
|
-
export interface WithPlugin<Self extends AnyApp, Added extends Any$
|
|
82
|
-
type BulkLayerRequirements<Added extends readonly Any$
|
|
81
|
+
export interface WithPlugin<Self extends AnyApp, Added extends Any$2> extends App<AppPlugin<Self> | Added, AppLayerOutput<Self> | LayerOutput$1<readonly [Added]>, AppLayerError<Self> | LayerError<readonly [Added]>, LayerRequirements$1<readonly [Added]> | Exclude<AppLayerRequirements<Self>, LayerOutput$1<readonly [Added]>>, Self["aiProviders"]> {}
|
|
82
|
+
type BulkLayerRequirements<Added extends readonly Any$2[], Requirements> = number extends Added["length"] ? Requirements | Layer.Services<Added[number]["layer"]> : Added extends readonly [infer Head extends Any$2, ...infer Tail extends readonly Any$2[]] ? BulkLayerRequirements<Tail, Layer.Services<Head["layer"]> | Exclude<Requirements, Layer.Success<Head["layer"]>>> : Requirements;
|
|
83
83
|
/**
|
|
84
84
|
* Result of adding several plugin releases to an app runtime in one step.
|
|
85
85
|
*
|
|
86
86
|
* @since 0.7.0
|
|
87
87
|
* @category type-level
|
|
88
88
|
*/
|
|
89
|
-
export interface WithPlugins<Self extends AnyApp, Added extends readonly Any$
|
|
89
|
+
export interface WithPlugins<Self extends AnyApp, Added extends readonly Any$2[]> extends App<AppPlugin<Self> | Added[number], AppLayerOutput<Self> | Layer.Success<Added[number]["layer"]>, AppLayerError<Self> | Layer.Error<Added[number]["layer"]>, BulkLayerRequirements<Added, AppLayerRequirements<Self>>, Self["aiProviders"]> {}
|
|
90
90
|
/** A plugin and the package version of its release. */
|
|
91
|
-
type PluginEntry = readonly [plugin: Any$
|
|
91
|
+
type PluginEntry = readonly [plugin: Any$2, version: string];
|
|
92
92
|
type PluginsOf<Entries extends readonly PluginEntry[]> = { readonly [K in keyof Entries]: Entries[K][0]; };
|
|
93
93
|
/**
|
|
94
94
|
* Add one plugin release: the plugin and its package version.
|
|
@@ -97,8 +97,8 @@ type PluginsOf<Entries extends readonly PluginEntry[]> = { readonly [K in keyof
|
|
|
97
97
|
* @category combinators
|
|
98
98
|
*/
|
|
99
99
|
export declare const withPlugin: {
|
|
100
|
-
<const P extends Any$
|
|
101
|
-
<Self extends AnyApp, const P extends Any$
|
|
100
|
+
<const P extends Any$2>(plugin: P, version: string): <Self extends AnyApp>(app: Self) => WithPlugin<Self, P>;
|
|
101
|
+
<Self extends AnyApp, const P extends Any$2>(app: Self, plugin: P, version: string): WithPlugin<Self, P>;
|
|
102
102
|
};
|
|
103
103
|
/**
|
|
104
104
|
* Add several plugin releases in one step, which keeps a large app's inferred type compact.
|
|
@@ -110,7 +110,7 @@ export declare const withPlugins: {
|
|
|
110
110
|
<const E extends readonly PluginEntry[]>(entries: E): <Self extends AnyApp>(app: Self) => WithPlugins<Self, PluginsOf<E>>;
|
|
111
111
|
<Self extends AnyApp, const E extends readonly PluginEntry[]>(app: Self, entries: E): WithPlugins<Self, PluginsOf<E>>;
|
|
112
112
|
};
|
|
113
|
-
export declare const invoke: <const P extends Any$
|
|
113
|
+
export declare const invoke: <const P extends Any$2, LayerOutput, LayerError, LayerRequirements, const AiProviders extends readonly Any[]>(app: App<P, LayerOutput, LayerError, LayerRequirements, AiProviders>, request: InvokeRequest) => Effect.Effect<InvokeSuccess, InvokeError | LayerError, LayerRequirements | Exclude<RuntimeRequirementsFor<P>, LayerOutput>>;
|
|
114
114
|
/**
|
|
115
115
|
* Runtime-first invocation request accepted by {@link Service}.
|
|
116
116
|
*
|
|
@@ -226,7 +226,7 @@ export interface RuntimeService {
|
|
|
226
226
|
readonly verifyTrigger: (request: RuntimeWebhookTriggerLifecycleRequest) => Effect.Effect<VerifySuccess, unknown>;
|
|
227
227
|
readonly parseTrigger: (request: RuntimeWebhookTriggerLifecycleRequest) => Effect.Effect<EmittedEventsSuccess<string, "parse">, unknown>;
|
|
228
228
|
readonly pollTrigger: (request: RuntimeTriggerLifecycleRequest) => Effect.Effect<EmittedEventsSuccess<string, "poll">, unknown>;
|
|
229
|
-
readonly getAuthMethod: (request: AuthMethodRequest) => Effect.Effect<Any, AuthMethodNotFoundError>;
|
|
229
|
+
readonly getAuthMethod: (request: AuthMethodRequest) => Effect.Effect<Any$1, AuthMethodNotFoundError>;
|
|
230
230
|
readonly decodeAuthMethodSetup: (request: DecodeAuthMethodSetupRequest) => Effect.Effect<unknown, AuthMethodExecutionError>;
|
|
231
231
|
readonly prepareAuthMethod: (request: PrepareAuthMethodRequest) => Effect.Effect<unknown, AuthMethodExecutionError>;
|
|
232
232
|
readonly prepareOAuth2Tokens: (request: PrepareOAuth2TokensRequest) => Effect.Effect<unknown, AuthMethodExecutionError>;
|
|
@@ -244,12 +244,12 @@ declare const Service_base: Context.ServiceClass<Service, "@dual-os/sdk/Dual/Ser
|
|
|
244
244
|
* @category services
|
|
245
245
|
*/
|
|
246
246
|
export declare class Service extends Service_base {}
|
|
247
|
-
export type RuntimeRequirementsFor<P extends Any$
|
|
248
|
-
type AuthProvider = Any$
|
|
247
|
+
export type RuntimeRequirementsFor<P extends Any$2> = Requirements<P> | (P extends Any$2 ? PluginRequirements<P, PluginActions<P>> : never);
|
|
248
|
+
type AuthProvider = Any$2 | Any;
|
|
249
249
|
type AuthMethodFor<Providers extends AuthProvider> = Providers["authMethods"][number];
|
|
250
|
-
type AuthMethodSetupDecodeRequirements<Method extends Any> = SetupSchema<Method> extends Schema.Top ? Schema.Codec.DecodingServices<SetupSchema<Method>> : never;
|
|
251
|
-
type AuthMethodInputDecodeRequirements<Method extends Any> = InputSchema<Method> extends Schema.Top ? Schema.Codec.DecodingServices<InputSchema<Method>> : never;
|
|
252
|
-
type AuthMethodExecutionRequirementsFor<Providers extends AuthProvider> = AuthMethodFor<Providers> extends (infer Method) ? Method extends Any ? Requirements<Method> | AuthMethodSetupDecodeRequirements<Method> | AuthMethodInputDecodeRequirements<Method> | Schema.Codec.DecodingServices<MaterialSchema<Method>> | Schema.Codec.DecodingServices<ValueSchema<Method>> | Schema.Codec.EncodingServices<MaterialSchema<Method>> | Schema.Codec.EncodingServices<ValueSchema<Method>> | (SetupSchema<Method> extends Schema.Top ? Schema.Codec.EncodingServices<SetupSchema<Method>> : never) : never : never;
|
|
250
|
+
type AuthMethodSetupDecodeRequirements<Method extends Any$1> = SetupSchema<Method> extends Schema.Top ? Schema.Codec.DecodingServices<SetupSchema<Method>> : never;
|
|
251
|
+
type AuthMethodInputDecodeRequirements<Method extends Any$1> = InputSchema<Method> extends Schema.Top ? Schema.Codec.DecodingServices<InputSchema<Method>> : never;
|
|
252
|
+
type AuthMethodExecutionRequirementsFor<Providers extends AuthProvider> = AuthMethodFor<Providers> extends (infer Method) ? Method extends Any$1 ? Requirements$1<Method> | AuthMethodSetupDecodeRequirements<Method> | AuthMethodInputDecodeRequirements<Method> | Schema.Codec.DecodingServices<MaterialSchema<Method>> | Schema.Codec.DecodingServices<ValueSchema<Method>> | Schema.Codec.EncodingServices<MaterialSchema<Method>> | Schema.Codec.EncodingServices<ValueSchema<Method>> | (SetupSchema<Method> extends Schema.Top ? Schema.Codec.EncodingServices<SetupSchema<Method>> : never) : never : never;
|
|
253
253
|
/**
|
|
254
254
|
* Requirements still needed by {@link toLayer} for an app.
|
|
255
255
|
*
|
|
@@ -265,7 +265,7 @@ type AuthMethodExecutionRequirementsFor<Providers extends AuthProvider> = AuthMe
|
|
|
265
265
|
* @since 0.0.0
|
|
266
266
|
* @category type-level
|
|
267
267
|
*/
|
|
268
|
-
export type ToLayerRequirements<A extends AnyApp> = A extends App<infer P extends Any$
|
|
268
|
+
export type ToLayerRequirements<A extends AnyApp> = A extends App<infer P extends Any$2, infer LayerOutput, any, infer LayerRequirements, infer AiProviders extends readonly Any[]> ? LayerRequirements | Exclude<RuntimeRequirementsFor<P>, LayerOutput> | Exclude<AuthMethodExecutionRequirementsFor<P | AiProviders[number]>, LayerOutput> : never;
|
|
269
269
|
/**
|
|
270
270
|
* Layer-construction errors surfaced by {@link toLayer} for an app.
|
|
271
271
|
*
|
|
@@ -279,6 +279,6 @@ export type ToLayerError<A extends AnyApp> = A extends App<any, any, infer Layer
|
|
|
279
279
|
* @since 0.0.0
|
|
280
280
|
* @category layers
|
|
281
281
|
*/
|
|
282
|
-
export declare const toLayer: <const P extends Any$
|
|
282
|
+
export declare const toLayer: <const P extends Any$2, LayerOutput, LayerError, LayerRequirements, const AiProviders extends readonly Any[]>(app: App<P, LayerOutput, LayerError, LayerRequirements, AiProviders>) => Layer.Layer<Service, LayerError, LayerRequirements | Exclude<RuntimeRequirementsFor<P>, LayerOutput> | Exclude<AuthMethodExecutionRequirementsFor<P | AiProviders[number]>, LayerOutput>>;
|
|
283
283
|
export { ActionHandlerError, type ActionHandlerFailure, ActionHandlerNotFoundError, ActionNotFoundError, ConnectionIdNotAllowedError, ConnectionReauthorizationRequiredError, ConnectionRequiredError, ConnectionResolverStoreError, ConnectionSelectionRequiredError, DualRuntime_d_exports as DualRuntime, DualRuntime_d_exports, FieldIssue, InvalidActionInputError, InvalidActionOutputError, InvalidConnectionIdError, InvalidResolvedConnectionError, type InvokeError, type InvokeMeta, type InvokeRequest, type InvokeRequirementsFor, type InvokeSuccess, RetryableActionHandlerError };
|
|
284
284
|
//# sourceMappingURL=DualRuntime.d.ts.map
|