@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.
@@ -1 +1 @@
1
- {"version":3,"file":"PluginRuntime.d.ts","names":["_$__AgentChannel_ts0.ChannelError","DualRuntime.AuthMethodExecutionError","DualRuntime.InvokeError","DualRuntime.Service","OAuthFlow.Service"],"sources":["../src/PluginRuntime.ts"],"mappings":";;;;;;;;;;;;;;qBASa,6BAA6B;qBAS7B;qBACA;;qBAEA;qBACA;;iBAGI;WACN,KAAK,eAAe,WAAW;WAC/B,iBAAiB,eAAe,WAAW;;;iBAIrC;WACN;WACA,SAAS;;;wBAIJ,YAAY,SAAS,YAAS,OAAA,gBAAA;;wBAqC9B,QAAQ,SAAS,WAAW,gBAAa,OAAA,aAAA;YAoB7C,2BAA2B,kBAAkB;qBAC5C,mBAAiB,OAAA;;;;;;YAOlB,sBAAsB,aAAa;qBAClC,cAAY,OAAA;;;;;;;;;;YAYb,6BAA6B,oBAAoB;qBAChD,qBAAmB,OAAA;;;;YAKpB,qBAAqB,YAAY;qBAChC,aAAW,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAoCZ,gCAAgC,uBAAuB;qBACtD,wBAAsB,OAAA;;;;;;;;;;;;;;YASvB,0BAA0B,iBAAiB;qBAC1C,kBAAgB,OAAA,gBAAA,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAMjB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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA5Ca;;;;;;;;;WAgCE;;;;;;;;;UAgBjCG,UAAAC"}
1
+ {"version":3,"file":"PluginRuntime.d.ts","names":["DualRuntime.ActionHandlerError","DualRuntime.RetryableActionHandlerError","DualRuntime.ActionHandlerNotFoundError","DualRuntime.ActionNotFoundError","_$__AuthMethod_ts0.AuthMethodHookError","DualRuntime.AuthMethodNotFoundError","_$__AgentChannel_ts0.ChannelError","DualRuntime.ConnectionIdNotAllowedError","DualRuntime.ConnectionReauthorizationRequiredError","DualRuntime.ConnectionRequiredError","DualRuntime.ConnectionResolverStoreError","DualRuntime.ConnectionSelectionRequiredError","_$__AuthMethod_ts0.ExpectedOAuth2MethodError","DualRuntime.InvalidActionInputError","DualRuntime.InvalidActionOutputError","DualRuntime.InvalidConnectionIdError","DualRuntime.InvalidResolvedConnectionError","_$__AuthMethod_ts0.OAuth2RefreshTokenUnavailableError","DualRuntime.Service","OAuthFlow.Service"],"sources":["../src/PluginRuntime.ts"],"mappings":";;;;;;;;;;;;;;;;;qBASa,6BAA6B;qBAS7B;qBACA;;qBAEA;qBACA;;iBAGI;WACN,KAAK,eAAe,WAAW;WAC/B,iBAAiB,eAAe,WAAW;;;iBAIrC;WACN;WACA,SAAS;;;wBAIJ,YAAY,SAAS,YAAS,OAAA,gBAAA;;wBAqC9B,QAAQ,SAAS,WAAW,gBAAa,OAAA,aAAA;YAoB7C,2BAA2B,kBAAkB;qBAC5C,mBAAiB,OAAA;;;;;;YAOlB,sBAAsB,aAAa;qB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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAjDa;;;;;;;;;WAqCE;;;;;;;;;UAgBjCkB,UAAAC"}
@@ -292,14 +292,20 @@ const executeAuth = Effect.fnUntraced(function* (request) {
292
292
  };
293
293
  })), Effect.catch((error) => {
294
294
  const cause = error._tag === "AuthMethodHookError" ? error.cause : error;
295
- return Effect.succeed({
295
+ const failure$1 = failure(error);
296
+ if (Schema.is(OAuthGrantRejected)(cause) && !("_tag" in failure$1)) return Effect.succeed({
296
297
  _tag: "failure",
297
298
  error: {
298
- ...failure(error),
299
- ...Schema.is(OAuthGrantRejected)(cause) ? { code: "OAuthGrantRejected" } : {}
299
+ ...failure$1,
300
+ code: "OAuthGrantRejected"
300
301
  },
301
302
  identity: request.identity
302
303
  });
304
+ return Effect.succeed({
305
+ _tag: "failure",
306
+ error: failure$1,
307
+ identity: request.identity
308
+ });
303
309
  })));
304
310
  const executeChannelSettings = Effect.fnUntraced(function* (request) {
305
311
  const runtime = yield* Service;
@@ -1 +1 @@
1
- {"version":3,"file":"PluginRuntime.js","names":["RemoteRuntime.Identity","AuthMethodExecution.JsonRequest","RemoteRuntime.Request","RemoteRuntime.Response","DualRuntime.Service","OAuthFlow.Service","RemoteRuntime.failure","RemoteRuntime.execute"],"sources":["../src/PluginRuntime.ts"],"sourcesContent":["import { Cause, Effect, Queue, Redacted, Schema, Stream, pipe } from \"effect\";\n\nimport { HttpClientRequest } from \"effect/http\";\n\nimport * as AuthMethodExecution from \"./AuthMethodExecution.ts\";\nimport * as DualRuntime from \"./DualRuntime.ts\";\nimport { OAuthFlow, OAuthGrantRejected } from \"./OAuthFlow.ts\";\nimport { RemoteRuntime } from \"./remote-runtime.ts\";\n\nexport class PluginExecutionError extends Schema.TaggedError<PluginExecutionError>()(\n \"PluginExecutionError\",\n {\n category: Schema.Literals([\"transport\", \"runner\", \"protocol\", \"cleanup\", \"artifact-expired\"]),\n cause: Schema.optionalKey(Schema.Redacted(Schema.Defect())),\n message: Schema.String,\n },\n) {}\n\nexport const maxPayloadBytes = 1024 * 1024;\nexport const maxMetadataBytes = 64 * 1024 * 1024;\n/** An Agent Channel result carries a read asset of up to 14 MiB. */\nexport const maxChannelResultBytes = 16 * 1024 * 1024;\nexport const cancellationTimeout = \"5 seconds\";\n\n/** The listener half of a Node or Bun IPC channel: a process or a child process. */\nexport interface IpcEvents {\n readonly on: (event: string, listener: (value: unknown) => void) => unknown;\n readonly removeListener: (event: string, listener: (value: unknown) => void) => unknown;\n}\n\n/** The sending half of a Node or Bun IPC channel: a process or a child process. */\nexport interface IpcSender {\n readonly connected: boolean;\n readonly send?: ((message: object) => unknown) | undefined;\n}\n\n/** Receive native Node and Bun IPC messages without interpreting plugin logs. */\nexport function ipcMessages(channel: IpcEvents) {\n return Stream.callback<unknown, PluginExecutionError>(queue => {\n const message = (value: unknown) => {\n Queue.offerUnsafe(queue, value);\n };\n const disconnected = () => {\n Queue.endUnsafe(queue);\n };\n const failed = (cause: unknown) => {\n Queue.failCauseUnsafe(\n queue,\n Cause.fail(\n PluginExecutionError.make({\n category: \"runner\",\n cause: Redacted.make(cause),\n message: \"Plugin IPC channel failed\",\n }),\n ),\n );\n };\n return Effect.acquireRelease(\n Effect.sync(() => {\n channel.on(\"message\", message);\n channel.on(\"disconnect\", disconnected);\n channel.on(\"error\", failed);\n }),\n () =>\n Effect.sync(() => {\n channel.removeListener(\"message\", message);\n channel.removeListener(\"disconnect\", disconnected);\n channel.removeListener(\"error\", failed);\n }),\n );\n });\n}\n\n/** Queue a JSON message; the runtime reports asynchronous send failures through its error event. */\nexport function sendIpc(channel: IpcSender, value: object) {\n return Effect.try({\n try: () => {\n if (!channel.connected || channel.send === undefined) {\n throw PluginExecutionError.make({\n category: \"runner\",\n message: \"Plugin IPC channel is closed\",\n });\n }\n channel.send(value);\n },\n catch: cause =>\n PluginExecutionError.make({\n category: \"runner\",\n cause: Redacted.make(cause),\n message: \"Cannot send plugin IPC message\",\n }),\n });\n}\n\nexport type OAuthContinuation = typeof OAuthContinuation.Type;\nexport const OAuthContinuation = Schema.Struct({\n expiresAt: Schema.DateFromString,\n pkceVerifier: Schema.NullOr(Schema.String),\n redirectUri: Schema.String,\n state: Schema.String,\n});\n\nexport type OAuthStarted = typeof OAuthStarted.Type;\nexport const OAuthStarted = Schema.Struct({\n authorizationUrl: Schema.String,\n continuation: OAuthContinuation,\n});\n\nconst oauth = {\n authMethodId: Schema.NonEmptyString,\n providerId: Schema.NonEmptyString,\n setup: Schema.optionalKey(Schema.Json),\n};\n\n/** The origins a Connection's credential may reach from a run sandbox, and the headers one request gets. */\nexport type SandboxAccessResult = typeof SandboxAccessResult.Type;\nexport const SandboxAccessResult = Schema.Struct({\n headers: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),\n origins: Schema.Array(Schema.String),\n});\n\nexport type AuthRequest = typeof AuthRequest.Type;\nexport const AuthRequest = Schema.TaggedStruct(\"auth\", {\n identity: RemoteRuntime.Identity,\n operation: Schema.Union([\n AuthMethodExecution.JsonRequest,\n Schema.TaggedStruct(\"oauthStart\", { ...oauth, redirectUri: Schema.String }),\n Schema.TaggedStruct(\"oauthComplete\", {\n ...oauth,\n continuation: OAuthContinuation,\n query: Schema.Record(Schema.String, Schema.String),\n }),\n // Without `request`, only the origins; with it, the headers the plugin adds to that request.\n Schema.TaggedStruct(\"sandboxAccess\", {\n ...oauth,\n material: Schema.Json,\n request: Schema.optionalKey(\n Schema.Struct({\n headers: Schema.Record(Schema.String, Schema.String),\n method: Schema.Literals([\n \"GET\",\n \"POST\",\n \"PUT\",\n \"DELETE\",\n \"PATCH\",\n \"HEAD\",\n \"OPTIONS\",\n \"TRACE\",\n \"QUERY\",\n ]),\n url: Schema.String,\n }),\n ),\n }),\n ]),\n});\n\n/** Decode an Agent Channel's settings outside any tenant, as publication validates them. */\nexport type ChannelSettingsRequest = typeof ChannelSettingsRequest.Type;\nexport const ChannelSettingsRequest = Schema.TaggedStruct(\"channelSettings\", {\n identity: RemoteRuntime.Identity,\n operation: Schema.TaggedStruct(\"decodeChannelSettings\", {\n channelId: Schema.NonEmptyString,\n field: Schema.Literals([\"definitionSettings\", \"deploymentSettings\"]),\n value: Schema.Json,\n }),\n});\n\nexport type ExecutionRequest = typeof ExecutionRequest.Type;\nexport const ExecutionRequest = Schema.Union([\n RemoteRuntime.Request,\n AuthRequest,\n ChannelSettingsRequest,\n]);\n\nexport type Request = typeof Request.Type;\nexport const Request = Schema.Union([\n ExecutionRequest,\n Schema.TaggedStruct(\"extract\", { identity: RemoteRuntime.Identity }),\n]);\n\nexport type Input = typeof Input.Type;\nexport const Input = Schema.Union([\n Request,\n Schema.TaggedStruct(\"cancel\", { identity: RemoteRuntime.Identity }),\n]);\n\nexport type Output = typeof Output.Type;\nexport const Output = Schema.Union([\n RemoteRuntime.Response,\n Schema.TaggedStruct(\"interrupted\", { identity: RemoteRuntime.Identity }),\n]);\n\nexport function checkMessageSize(value: unknown, maximum: number) {\n if (new TextEncoder().encode(JSON.stringify(value)).byteLength <= maximum) return Effect.void;\n return Effect.fail(\n PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin message exceeds its transport limit\",\n }),\n );\n}\n\nexport const encodeInput = Effect.fnUntraced(function* (input: Input) {\n const encoded = yield* Schema.encodeEffect(Input)(input);\n yield* checkMessageSize(encoded, maxPayloadBytes);\n return encoded;\n});\n\nexport const decodeInput = Effect.fnUntraced(function* (input: unknown) {\n const json = yield* Schema.decodeUnknownEffect(Schema.Json)(input);\n yield* checkMessageSize(json, maxPayloadBytes);\n return yield* Schema.decodeUnknownEffect(Input)(json);\n});\n\nexport const encodeOutput = Effect.fnUntraced(function* (output: Output, maximum: number) {\n const encoded = yield* Schema.encodeEffect(Output)(output);\n yield* checkMessageSize(encoded, maximum);\n return encoded;\n});\n\nexport const decodeOutput = Effect.fnUntraced(function* (output: unknown) {\n const json = yield* Schema.decodeUnknownEffect(Schema.Json)(output);\n yield* checkMessageSize(json, maxMetadataBytes);\n return yield* Schema.decodeUnknownEffect(Output)(json);\n});\n\nexport function responseLimit(request: Request) {\n if (\"_tag\" in request && request._tag === \"extract\") return maxMetadataBytes;\n if (\"context\" in request && request.operation._tag === \"channelExecute\") {\n return maxChannelResultBytes;\n }\n return maxPayloadBytes;\n}\n\nexport type Invocation = typeof Invocation.Type;\nexport const Invocation = Schema.Struct({\n entrypoint: Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_-]+(?:[./][A-Za-z0-9_-]+)*$/u)),\n exportName: Schema.String.check(Schema.isPattern(/^[A-Za-z_$][A-Za-z0-9_$]*$/u)),\n request: Request,\n});\n\nexport const encodeRequest = Effect.fnUntraced(function* (request: Request) {\n const encoded = yield* pipe(\n Schema.encodeEffect(Schema.fromJsonString(Request))(request),\n Effect.mapError(cause =>\n PluginExecutionError.make({\n cause: Redacted.make(cause),\n category: \"protocol\",\n message: \"Invalid plugin request\",\n }),\n ),\n );\n if (new TextEncoder().encode(encoded).byteLength > maxPayloadBytes) {\n return yield* PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin request exceeds the 1 MiB transport limit\",\n });\n }\n return encoded;\n});\n\nexport const readBounded = Effect.fnUntraced(function* <E, R>(\n input: Stream.Stream<Uint8Array, E, R>,\n maximum = maxPayloadBytes,\n) {\n const output = { bytes: Buffer.alloc(maximum), size: 0 };\n yield* pipe(\n input,\n Stream.runForEach(chunk =>\n Effect.gen(function* () {\n if (output.size + chunk.byteLength > maximum) {\n return yield* PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin payload exceeds its transport limit\",\n });\n }\n Buffer.from(chunk).copy(output.bytes, output.size);\n output.size += chunk.byteLength;\n }),\n ),\n Effect.mapError(cause =>\n PluginExecutionError.make({\n cause: Redacted.make(cause),\n category: \"protocol\",\n message: \"Cannot read plugin payload\",\n }),\n ),\n );\n return output.bytes.toString(\"utf8\", 0, output.size);\n});\n\nexport const verifyResponse = Effect.fnUntraced(function* <Response extends Output>(\n request: Request,\n response: Response,\n) {\n if (\n response.identity.invocationId !== request.identity.invocationId ||\n response.identity.artifactDigest !== request.identity.artifactDigest ||\n response.identity.organizationId !== request.identity.organizationId ||\n response.identity.pluginKey !== request.identity.pluginKey ||\n response.identity.pluginVersion !== request.identity.pluginVersion\n ) {\n return yield* PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin result does not match its invocation\",\n });\n }\n return response;\n});\n\nconst executeAuth = Effect.fnUntraced(\n function* (request: AuthRequest) {\n const operation = request.operation;\n const runtime = yield* DualRuntime.Service;\n if (operation._tag === \"sandboxAccess\") {\n const access = yield* runtime.resolveSandboxAccess({\n ...operation,\n encoding: \"json\",\n setup: operation.setup,\n });\n if (operation.request === undefined) {\n return yield* Schema.encodeEffect(SandboxAccessResult)({ origins: access.origins });\n }\n const authorized = yield* access.authorize(\n HttpClientRequest.make(operation.request.method)(operation.request.url, {\n headers: operation.request.headers,\n }),\n );\n return yield* Schema.encodeEffect(SandboxAccessResult)({\n headers: authorized.headers,\n origins: access.origins,\n });\n }\n if (operation._tag !== \"oauthStart\" && operation._tag !== \"oauthComplete\") {\n return yield* runtime.executeAuthJson(operation);\n }\n const method = yield* runtime.getAuthMethod(operation);\n const setup = yield* runtime.decodeAuthMethodSetup({\n ...operation,\n encoding: \"json\",\n setup: operation.setup,\n });\n const oauth = yield* OAuthFlow.Service;\n if (operation._tag === \"oauthStart\") {\n return yield* Schema.encodeEffect(OAuthStarted)(\n yield* oauth.start({ method, redirectUri: operation.redirectUri, setup }),\n );\n }\n const completed = yield* oauth.complete({ ...operation, method, setup });\n return yield* runtime.executeAuthJson(\n yield* Schema.decodeUnknownEffect(AuthMethodExecution.JsonRequest)({\n ...operation,\n _tag: \"prepareOAuth2Tokens\",\n tokens: completed.tokens,\n }),\n );\n },\n (effect, request) =>\n pipe(\n effect,\n Effect.flatMap(\n Effect.fnUntraced(function* (value) {\n const result = { _tag: \"success\" as const, identity: request.identity };\n if (value === undefined) return result;\n return { ...result, value: yield* Schema.decodeUnknownEffect(Schema.Json)(value) };\n }),\n ),\n Effect.catch(error => {\n const cause = error._tag === \"AuthMethodHookError\" ? error.cause : error;\n return Effect.succeed({\n _tag: \"failure\" as const,\n error: {\n ...RemoteRuntime.failure(error),\n ...(Schema.is(OAuthGrantRejected)(cause) ? { code: \"OAuthGrantRejected\" } : {}),\n },\n identity: request.identity,\n });\n }),\n ),\n);\n\nconst executeChannelSettings = Effect.fnUntraced(\n function* (request: ChannelSettingsRequest) {\n const runtime = yield* DualRuntime.Service;\n const { channelId, field, value } = request.operation;\n const input = { channelId, value };\n if (field === \"definitionSettings\") {\n return yield* runtime.decodeAgentChannelDefinitionSettings(input);\n }\n return yield* runtime.decodeAgentChannelDeploymentSettings(input);\n },\n (effect, request) =>\n pipe(\n effect,\n Effect.map(value => ({ _tag: \"success\", identity: request.identity, value }) as const),\n Effect.catch(error =>\n Effect.succeed({\n _tag: \"failure\" as const,\n error: RemoteRuntime.failure(error),\n identity: request.identity,\n }),\n ),\n ),\n);\n\n/** Execute one request against the plugin built in this process; only the guest runner calls it in production. */\nexport const execute = Effect.fnUntraced(function* (request: ExecutionRequest) {\n if (!(\"_tag\" in request)) return yield* RemoteRuntime.execute(request);\n if (request._tag === \"auth\") return yield* executeAuth(request);\n return yield* executeChannelSettings(request);\n});\n\nexport * as PluginRuntime from \"./PluginRuntime.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,UAAU,OAAO,SAAS;EAAC;EAAa;EAAU;EAAY;EAAW;CAAkB,CAAC;CAC5F,OAAO,OAAO,YAAY,OAAO,SAAS,OAAO,OAAO,CAAC,CAAC;CAC1D,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,MAAa,kBAAkB;AAC/B,MAAa,mBAAmB;;AAEhC,MAAa,wBAAwB;AACrC,MAAa,sBAAsB;;AAenC,SAAgB,YAAY,SAAoB;CAC9C,OAAO,OA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YAAY,OAAO;CAC9D,OAAO,OAAO,uBAAuB,OAAO;AAC9C,CAAC"}
1
+ {"version":3,"file":"PluginRuntime.js","names":["RemoteRuntime.Identity","AuthMethodExecution.JsonRequest","RemoteRuntime.Request","RemoteRuntime.Response","DualRuntime.Service","OAuthFlow.Service","failure","RemoteRuntime.failure","RemoteRuntime.execute"],"sources":["../src/PluginRuntime.ts"],"sourcesContent":["import { Cause, Effect, Queue, Redacted, Schema, Stream, pipe } from \"effect\";\n\nimport { HttpClientRequest } from \"effect/http\";\n\nimport * as AuthMethodExecution from \"./AuthMethodExecution.ts\";\nimport * as DualRuntime from \"./DualRuntime.ts\";\nimport { OAuthFlow, OAuthGrantRejected } from \"./OAuthFlow.ts\";\nimport { RemoteRuntime } from \"./remote-runtime.ts\";\n\nexport class PluginExecutionError extends Schema.TaggedError<PluginExecutionError>()(\n \"PluginExecutionError\",\n {\n category: Schema.Literals([\"transport\", \"runner\", \"protocol\", \"cleanup\", \"artifact-expired\"]),\n cause: Schema.optionalKey(Schema.Redacted(Schema.Defect())),\n message: Schema.String,\n },\n) {}\n\nexport const maxPayloadBytes = 1024 * 1024;\nexport const maxMetadataBytes = 64 * 1024 * 1024;\n/** An Agent Channel result carries a read asset of up to 14 MiB. */\nexport const maxChannelResultBytes = 16 * 1024 * 1024;\nexport const cancellationTimeout = \"5 seconds\";\n\n/** The listener half of a Node or Bun IPC channel: a process or a child process. */\nexport interface IpcEvents {\n readonly on: (event: string, listener: (value: unknown) => void) => unknown;\n readonly removeListener: (event: string, listener: (value: unknown) => void) => unknown;\n}\n\n/** The sending half of a Node or Bun IPC channel: a process or a child process. */\nexport interface IpcSender {\n readonly connected: boolean;\n readonly send?: ((message: object) => unknown) | undefined;\n}\n\n/** Receive native Node and Bun IPC messages without interpreting plugin logs. */\nexport function ipcMessages(channel: IpcEvents) {\n return Stream.callback<unknown, PluginExecutionError>(queue => {\n const message = (value: unknown) => {\n Queue.offerUnsafe(queue, value);\n };\n const disconnected = () => {\n Queue.endUnsafe(queue);\n };\n const failed = (cause: unknown) => {\n Queue.failCauseUnsafe(\n queue,\n Cause.fail(\n PluginExecutionError.make({\n category: \"runner\",\n cause: Redacted.make(cause),\n message: \"Plugin IPC channel failed\",\n }),\n ),\n );\n };\n return Effect.acquireRelease(\n Effect.sync(() => {\n channel.on(\"message\", message);\n channel.on(\"disconnect\", disconnected);\n channel.on(\"error\", failed);\n }),\n () =>\n Effect.sync(() => {\n channel.removeListener(\"message\", message);\n channel.removeListener(\"disconnect\", disconnected);\n channel.removeListener(\"error\", failed);\n }),\n );\n });\n}\n\n/** Queue a JSON message; the runtime reports asynchronous send failures through its error event. */\nexport function sendIpc(channel: IpcSender, value: object) {\n return Effect.try({\n try: () => {\n if (!channel.connected || channel.send === undefined) {\n throw PluginExecutionError.make({\n category: \"runner\",\n message: \"Plugin IPC channel is closed\",\n });\n }\n channel.send(value);\n },\n catch: cause =>\n PluginExecutionError.make({\n category: \"runner\",\n cause: Redacted.make(cause),\n message: \"Cannot send plugin IPC message\",\n }),\n });\n}\n\nexport type OAuthContinuation = typeof OAuthContinuation.Type;\nexport const OAuthContinuation = Schema.Struct({\n expiresAt: Schema.DateFromString,\n pkceVerifier: Schema.NullOr(Schema.String),\n redirectUri: Schema.String,\n state: Schema.String,\n});\n\nexport type OAuthStarted = typeof OAuthStarted.Type;\nexport const OAuthStarted = Schema.Struct({\n authorizationUrl: Schema.String,\n continuation: OAuthContinuation,\n});\n\nconst oauth = {\n authMethodId: Schema.NonEmptyString,\n providerId: Schema.NonEmptyString,\n setup: Schema.optionalKey(Schema.Json),\n};\n\n/** The origins a Connection's credential may reach from a run sandbox, and the headers one request gets. */\nexport type SandboxAccessResult = typeof SandboxAccessResult.Type;\nexport const SandboxAccessResult = Schema.Struct({\n headers: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),\n origins: Schema.Array(Schema.String),\n});\n\nexport type AuthRequest = typeof AuthRequest.Type;\nexport const AuthRequest = Schema.TaggedStruct(\"auth\", {\n identity: RemoteRuntime.Identity,\n operation: Schema.Union([\n AuthMethodExecution.JsonRequest,\n Schema.TaggedStruct(\"oauthStart\", { ...oauth, redirectUri: Schema.String }),\n Schema.TaggedStruct(\"oauthComplete\", {\n ...oauth,\n continuation: OAuthContinuation,\n query: Schema.Record(Schema.String, Schema.String),\n }),\n // Without `request`, only the origins; with it, the headers the plugin adds to that request.\n Schema.TaggedStruct(\"sandboxAccess\", {\n ...oauth,\n material: Schema.Json,\n request: Schema.optionalKey(\n Schema.Struct({\n headers: Schema.Record(Schema.String, Schema.String),\n method: Schema.Literals([\n \"GET\",\n \"POST\",\n \"PUT\",\n \"DELETE\",\n \"PATCH\",\n \"HEAD\",\n \"OPTIONS\",\n \"TRACE\",\n \"QUERY\",\n ]),\n url: Schema.String,\n }),\n ),\n }),\n ]),\n});\n\n/** Decode an Agent Channel's settings outside any tenant, as publication validates them. */\nexport type ChannelSettingsRequest = typeof ChannelSettingsRequest.Type;\nexport const ChannelSettingsRequest = Schema.TaggedStruct(\"channelSettings\", {\n identity: RemoteRuntime.Identity,\n operation: Schema.TaggedStruct(\"decodeChannelSettings\", {\n channelId: Schema.NonEmptyString,\n field: Schema.Literals([\"definitionSettings\", \"deploymentSettings\"]),\n value: Schema.Json,\n }),\n});\n\nexport type ExecutionRequest = typeof ExecutionRequest.Type;\nexport const ExecutionRequest = Schema.Union([\n RemoteRuntime.Request,\n AuthRequest,\n ChannelSettingsRequest,\n]);\n\nexport type Request = typeof Request.Type;\nexport const Request = Schema.Union([\n ExecutionRequest,\n Schema.TaggedStruct(\"extract\", { identity: RemoteRuntime.Identity }),\n]);\n\nexport type Input = typeof Input.Type;\nexport const Input = Schema.Union([\n Request,\n Schema.TaggedStruct(\"cancel\", { identity: RemoteRuntime.Identity }),\n]);\n\nexport type Output = typeof Output.Type;\nexport const Output = Schema.Union([\n RemoteRuntime.Response,\n Schema.TaggedStruct(\"interrupted\", { identity: RemoteRuntime.Identity }),\n]);\n\nexport function checkMessageSize(value: unknown, maximum: number) {\n if (new TextEncoder().encode(JSON.stringify(value)).byteLength <= maximum) return Effect.void;\n return Effect.fail(\n PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin message exceeds its transport limit\",\n }),\n );\n}\n\nexport const encodeInput = Effect.fnUntraced(function* (input: Input) {\n const encoded = yield* Schema.encodeEffect(Input)(input);\n yield* checkMessageSize(encoded, maxPayloadBytes);\n return encoded;\n});\n\nexport const decodeInput = Effect.fnUntraced(function* (input: unknown) {\n const json = yield* Schema.decodeUnknownEffect(Schema.Json)(input);\n yield* checkMessageSize(json, maxPayloadBytes);\n return yield* Schema.decodeUnknownEffect(Input)(json);\n});\n\nexport const encodeOutput = Effect.fnUntraced(function* (output: Output, maximum: number) {\n const encoded = yield* Schema.encodeEffect(Output)(output);\n yield* checkMessageSize(encoded, maximum);\n return encoded;\n});\n\nexport const decodeOutput = Effect.fnUntraced(function* (output: unknown) {\n const json = yield* Schema.decodeUnknownEffect(Schema.Json)(output);\n yield* checkMessageSize(json, maxMetadataBytes);\n return yield* Schema.decodeUnknownEffect(Output)(json);\n});\n\nexport function responseLimit(request: Request) {\n if (\"_tag\" in request && request._tag === \"extract\") return maxMetadataBytes;\n if (\"context\" in request && request.operation._tag === \"channelExecute\") {\n return maxChannelResultBytes;\n }\n return maxPayloadBytes;\n}\n\nexport type Invocation = typeof Invocation.Type;\nexport const Invocation = Schema.Struct({\n entrypoint: Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_-]+(?:[./][A-Za-z0-9_-]+)*$/u)),\n exportName: Schema.String.check(Schema.isPattern(/^[A-Za-z_$][A-Za-z0-9_$]*$/u)),\n request: Request,\n});\n\nexport const encodeRequest = Effect.fnUntraced(function* (request: Request) {\n const encoded = yield* pipe(\n Schema.encodeEffect(Schema.fromJsonString(Request))(request),\n Effect.mapError(cause =>\n PluginExecutionError.make({\n cause: Redacted.make(cause),\n category: \"protocol\",\n message: \"Invalid plugin request\",\n }),\n ),\n );\n if (new TextEncoder().encode(encoded).byteLength > maxPayloadBytes) {\n return yield* PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin request exceeds the 1 MiB transport limit\",\n });\n }\n return encoded;\n});\n\nexport const readBounded = Effect.fnUntraced(function* <E, R>(\n input: Stream.Stream<Uint8Array, E, R>,\n maximum = maxPayloadBytes,\n) {\n const output = { bytes: Buffer.alloc(maximum), size: 0 };\n yield* pipe(\n input,\n Stream.runForEach(chunk =>\n Effect.gen(function* () {\n if (output.size + chunk.byteLength > maximum) {\n return yield* PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin payload exceeds its transport limit\",\n });\n }\n Buffer.from(chunk).copy(output.bytes, output.size);\n output.size += chunk.byteLength;\n }),\n ),\n Effect.mapError(cause =>\n PluginExecutionError.make({\n cause: Redacted.make(cause),\n category: \"protocol\",\n message: \"Cannot read plugin payload\",\n }),\n ),\n );\n return output.bytes.toString(\"utf8\", 0, output.size);\n});\n\nexport const verifyResponse = Effect.fnUntraced(function* <Response extends Output>(\n request: Request,\n response: Response,\n) {\n if (\n response.identity.invocationId !== request.identity.invocationId ||\n response.identity.artifactDigest !== request.identity.artifactDigest ||\n response.identity.organizationId !== request.identity.organizationId ||\n response.identity.pluginKey !== request.identity.pluginKey ||\n response.identity.pluginVersion !== request.identity.pluginVersion\n ) {\n return yield* PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin result does not match its invocation\",\n });\n }\n return response;\n});\n\nconst executeAuth = Effect.fnUntraced(\n function* (request: AuthRequest) {\n const operation = request.operation;\n const runtime = yield* DualRuntime.Service;\n if (operation._tag === \"sandboxAccess\") {\n const access = yield* runtime.resolveSandboxAccess({\n ...operation,\n encoding: \"json\",\n setup: operation.setup,\n });\n if (operation.request === undefined) {\n return yield* Schema.encodeEffect(SandboxAccessResult)({ origins: access.origins });\n }\n const authorized = yield* access.authorize(\n HttpClientRequest.make(operation.request.method)(operation.request.url, {\n headers: operation.request.headers,\n }),\n );\n return yield* Schema.encodeEffect(SandboxAccessResult)({\n headers: authorized.headers,\n origins: access.origins,\n });\n }\n if (operation._tag !== \"oauthStart\" && operation._tag !== \"oauthComplete\") {\n return yield* runtime.executeAuthJson(operation);\n }\n const method = yield* runtime.getAuthMethod(operation);\n const setup = yield* runtime.decodeAuthMethodSetup({\n ...operation,\n encoding: \"json\",\n setup: operation.setup,\n });\n const oauth = yield* OAuthFlow.Service;\n if (operation._tag === \"oauthStart\") {\n return yield* Schema.encodeEffect(OAuthStarted)(\n yield* oauth.start({ method, redirectUri: operation.redirectUri, setup }),\n );\n }\n const completed = yield* oauth.complete({ ...operation, method, setup });\n return yield* runtime.executeAuthJson(\n yield* Schema.decodeUnknownEffect(AuthMethodExecution.JsonRequest)({\n ...operation,\n _tag: \"prepareOAuth2Tokens\",\n tokens: completed.tokens,\n }),\n );\n },\n (effect, request) =>\n pipe(\n effect,\n Effect.flatMap(\n Effect.fnUntraced(function* (value) {\n const result = { _tag: \"success\" as const, identity: request.identity };\n if (value === undefined) return result;\n return { ...result, value: yield* Schema.decodeUnknownEffect(Schema.Json)(value) };\n }),\n ),\n Effect.catch(error => {\n const cause = error._tag === \"AuthMethodHookError\" ? error.cause : error;\n const failure = RemoteRuntime.failure(error);\n if (Schema.is(OAuthGrantRejected)(cause) && !(\"_tag\" in failure)) {\n return Effect.succeed({\n _tag: \"failure\" as const,\n error: { ...failure, code: \"OAuthGrantRejected\" },\n identity: request.identity,\n });\n }\n return Effect.succeed({\n _tag: \"failure\" as const,\n error: failure,\n identity: request.identity,\n });\n }),\n ),\n);\n\nconst executeChannelSettings = Effect.fnUntraced(\n function* (request: ChannelSettingsRequest) {\n const runtime = yield* DualRuntime.Service;\n const { channelId, field, value } = request.operation;\n const input = { channelId, value };\n if (field === \"definitionSettings\") {\n return yield* runtime.decodeAgentChannelDefinitionSettings(input);\n }\n return yield* runtime.decodeAgentChannelDeploymentSettings(input);\n },\n (effect, request) =>\n pipe(\n effect,\n Effect.map(value => ({ _tag: \"success\", identity: request.identity, value }) as const),\n Effect.catch(error =>\n Effect.succeed({\n _tag: \"failure\" as const,\n error: RemoteRuntime.failure(error),\n identity: request.identity,\n }),\n ),\n ),\n);\n\n/** Execute one request against the plugin built in this process; only the guest runner calls it in production. */\nexport const execute = Effect.fnUntraced(function* (request: ExecutionRequest) {\n if (!(\"_tag\" in request)) return yield* RemoteRuntime.execute(request);\n if (request._tag === \"auth\") return yield* executeAuth(request);\n return yield* executeChannelSettings(request);\n});\n\nexport * as PluginRuntime from \"./PluginRuntime.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAa,uBAAb,cAA0C,OAAO,YAAkC,CAAC,CAClF,wBACA;CACE,UAAU,OAAO,SAAS;EAAC;EAAa;EAAU;EAAY;EAAW;CAAkB,CAAC;CAC5F,OAAO,OAAO,YAAY,OAAO,SAAS,OAAO,OAAO,CAAC,CAAC;CAC1D,SAAS,OAAO;AAClB,CACF,CAAC,CAAC,CAAC;AAEH,MAAa,kBAAkB;AAC/B,MAAa,mBAAmB;;AAEhC,MAAa,wBAAwB;AACrC,MAAa,sBAAsB;;AAenC,SAAgB,YAAY,SAAoB;CAC9C,OAAO,OAAO,UAAwC,UAAS;EAC7D,MAAM,WAAW,UAAmB;GAClC,MAAM,YAAY,OAAO,KAAK;EAChC;EACA,MAAM,qBAAqB;GACzB,MAAM,UAAU,KAAK;EACvB;EACA,MAAM,UAAU,UAAmB;GACjC,MAAM,gBACJ,OACA,MAAM,KACJ,qBAAqB,KAAK;IACxB,UAAU;IACV,OAAO,SAAS,KAAK,KAAK;IAC1B,SAAS;GACX,CAAC,CACH,CACF;EACF;EACA,OAAO,OAAO,eACZ,OAAO,WAAW;GAChB,QAAQ,GAAG,WAAW,OAAO;GAC7B,QAAQ,GAAG,cAAc,YAAY;GACrC,QAAQ,GAAG,SAAS,MAAM;EAC5B,CAAC,SAEC,OAAO,WAAW;GAChB,QAAQ,eAAe,WAAW,OAAO;GACzC,QAAQ,eAAe,cAAc,YAAY;GACjD,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,QAAQ;EACpB,MAAM;EACN,OAAO;GAAE,GAAGA;GAAS,MAAM;EAAqB;EAChD,UAAU,QAAQ;CACpB,CAAC;CAEH,OAAO,OAAO,QAAQ;EACpB,MAAM;EACN,OAAOA;EACP,UAAU,QAAQ;CACpB,CAAC;AACH,CAAC,CACH,CACJ;AAEA,MAAM,yBAAyB,OAAO,WACpC,WAAW,SAAiC;CAC1C,MAAM,UAAU,OAAOF;CACvB,MAAM,EAAE,WAAW,OAAO,UAAU,QAAQ;CAC5C,MAAM,QAAQ;EAAE;EAAW;CAAM;CACjC,IAAI,UAAU,sBACZ,OAAO,OAAO,QAAQ,qCAAqC,KAAK;CAElE,OAAO,OAAO,QAAQ,qCAAqC,KAAK;AAClE,IACC,QAAQ,YACP,KACE,QACA,OAAO,KAAI,WAAU;CAAE,MAAM;CAAW,UAAU,QAAQ;CAAU;AAAM,EAAW,GACrF,OAAO,OAAM,UACX,OAAO,QAAQ;CACb,MAAM;CACN,OAAOG,QAAsB,KAAK;CAClC,UAAU,QAAQ;AACpB,CAAC,CACH,CACF,CACJ;;AAGA,MAAa,UAAU,OAAO,WAAW,WAAW,SAA2B;CAC7E,IAAI,EAAE,UAAU,UAAU,OAAO,OAAOC,UAAsB,OAAO;CACrE,IAAI,QAAQ,SAAS,QAAQ,OAAO,OAAO,YAAY,OAAO;CAC9D,OAAO,OAAO,uBAAuB,OAAO;AAC9C,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { AuthMethodKind } from "../../AuthMethod.js";
2
- import { Exposure, Features, Protocol, RequiredChecks } from "../../AgentChannel.js";
2
+ import { Exposure, Features, RequiredChecks } from "../../AgentChannel.js";
3
3
  import { Category } from "../../Plugin.js";
4
4
  import { Any } from "../../AiProvider.js";
5
5
  import { PluginInstallation } from "../../DualRuntime.js";
@@ -95,8 +95,6 @@ export interface MaterializedChannelCapabilityVersion {
95
95
  readonly extensionsSchemaJson: Readonly<Record<string, unknown>>;
96
96
  readonly featuresJson: Features;
97
97
  readonly exposure: typeof Exposure.Type;
98
- /** Absent for the original protocol. */
99
- readonly protocol?: Protocol;
100
98
  readonly requiredChecks: typeof RequiredChecks.Type;
101
99
  }
102
100
  export type MaterializedCapabilityVersion = MaterializedChannelCapabilityVersion | MaterializedActionCapabilityVersion | MaterializedTriggerCapabilityVersion;
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","names":["AuthMethod.AuthMethodKind","Plugin.Category","AgentChannel.Features","AgentChannel.Protocol","AiProvider.Any"],"sources":["../../../src/internal/dual/registry.ts"],"mappings":";;;;;;iBAYiB;WACN,eAAe,QAAQ,OAAO;WAC9B,cAAc,IAAI,OAAO;;WAEzB,mBAAmB,sBAAsB;;;iBAInC;WACN;WACA;WACA;WACA;WACA;WACA,MAAMA;WACN;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA,qBAAqBC;WACrB;WACA;;WAEA;WACA;WACA;WACA,sBAAsB;WACtB,6BAA6B;;;iBAIvB;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,sBAAsB,SAAS;WAC/B,cAAcC;WACd,iBAAuC,SAAA;;WAEvC,WAAWC;WACX,uBAAmD,eAAA;;YAElD,gCACR,uCACA,sCACA;;iBAGa;WACN;WACA,oBAAoB;;;;;;;;;qBAsDlB,8BAA2B;WAC7B;WACA,kBAAkB;WAClB,sBAAsBC;WACtB,eAAe,QAAQ,OAAO;WAC9B,cAAc,IAAI,OAAO;WACzB,mBAAmB,sBAAsB;MAChD"}
1
+ {"version":3,"file":"registry.d.ts","names":["AuthMethod.AuthMethodKind","Plugin.Category","AgentChannel.Features","AiProvider.Any"],"sources":["../../../src/internal/dual/registry.ts"],"mappings":";;;;;;iBAYiB;WACN,eAAe,QAAQ,OAAO;WAC9B,cAAc,IAAI,OAAO;;WAEzB,mBAAmB,sBAAsB;;;iBAInC;WACN;WACA;WACA;WACA;WACA;WACA,MAAMA;WACN;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA,qBAAqBC;WACrB;WACA;;WAEA;WACA;WACA;WACA,sBAAsB;WACtB,6BAA6B;;;iBAIvB;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;;;iBAIM;WACN;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA;WACA,sBAAsB,SAAS;WAC/B,cAAcC;WACd,iBAAuC,SAAA;WACvC,uBAAmD,eAAA;;YAElD,gCACR,uCACA,sCACA;;iBAGa;WACN;WACA,oBAAoB;;;;;;;;;qBAsDlB,8BAA2B;WAC7B;WACA,kBAAkB;WAClB,sBAAsBC;WACtB,eAAe,QAAQ,OAAO;WAC9B,cAAc,IAAI,OAAO;WACzB,mBAAmB,sBAAsB;MAChD"}
@@ -1 +1 @@
1
- {"version":3,"file":"registry.js","names":["AgentChannel.projectContract","AiProvider.registryId"],"sources":["../../../src/internal/dual/registry.ts"],"sourcesContent":["/** Materialized Dual registry DTOs and resolver. */\nimport { Schema } from \"effect\";\n\nimport * as AgentChannel from \"../../AgentChannel.ts\";\nimport * as AiProvider from \"../../AiProvider.ts\";\nimport type * as AuthMethod from \"../../AuthMethod.ts\";\nimport type { PluginInstallation } from \"../../DualRuntime.ts\";\nimport type * as Plugin from \"../../Plugin.ts\";\n\nimport { collectActionEntries } from \"./actions.ts\";\nimport { collectTriggerEntries } from \"./triggers.ts\";\n\nexport interface MaterializedRegistryOptions {\n readonly schemaJson?: ((schema: Schema.Top) => unknown) | undefined;\n readonly projections?: Map<Schema.Top, unknown> | undefined;\n /** Selects the capability versions whose schemas are projected; the others carry `undefined` schemas. */\n readonly projectSchemas?: ((capabilityId: string, version: string) => boolean) | undefined;\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedAuthMethod {\n readonly id: string;\n readonly providerId: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly kind: AuthMethod.AuthMethodKind;\n readonly setupSchemaJson: unknown | null;\n readonly inputSchemaJson: unknown | null;\n readonly materialSchemaJson: unknown;\n readonly metadataJson: unknown;\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedProvider {\n readonly kind: \"tools\" | \"ai\";\n readonly id: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly iconUrl: string | undefined;\n readonly iconUrlDark: string | undefined;\n readonly categories: readonly Plugin.Category[];\n readonly homepageUrl: string | undefined;\n readonly docsUrl: string | undefined;\n /** Whether a shell in a run sandbox may use the provider's Connections through Dual's gateway. */\n readonly sandboxAccess: boolean;\n readonly sourcePluginKey: string | undefined;\n readonly sourcePluginVersion: string | undefined;\n readonly authMethods: readonly MaterializedAuthMethod[];\n readonly capabilityVersions: readonly MaterializedCapabilityVersion[];\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedActionCapabilityVersion {\n readonly kind: \"action\";\n readonly requireAuth: boolean;\n readonly capabilityId: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly version: string;\n readonly sourcePluginKey: string | undefined;\n readonly sourcePluginVersion: string | undefined;\n readonly authMethodIds: readonly string[];\n readonly inputSchemaJson: unknown;\n readonly outputSchemaJson: unknown;\n readonly examplesJson: unknown;\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedTriggerCapabilityVersion {\n readonly kind: \"trigger\";\n readonly requireAuth: boolean;\n readonly capabilityId: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly version: string;\n readonly sourcePluginKey: string | undefined;\n readonly sourcePluginVersion: string | undefined;\n readonly authMethodIds: readonly string[];\n readonly triggerKind: \"webhook\" | \"polling\";\n readonly configSchemaJson: unknown;\n readonly outputSchemaJson: unknown;\n readonly stateSchemaJson: unknown | undefined;\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedChannelCapabilityVersion {\n readonly kind: \"agent_channel\";\n readonly requireAuth: boolean;\n readonly capabilityId: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly version: string;\n readonly sourcePluginKey: string | undefined;\n readonly sourcePluginVersion: string | undefined;\n readonly authMethodIds: readonly string[];\n readonly definitionSettingsSchemaJson: unknown;\n readonly deploymentSettingsSchemaJson: unknown;\n readonly stateSchemaJson: unknown;\n readonly operationInputSchemaJson: unknown;\n readonly operationOutputSchemaJson: unknown;\n readonly extensionsSchemaJson: Readonly<Record<string, unknown>>;\n readonly featuresJson: AgentChannel.Features;\n readonly exposure: typeof AgentChannel.Exposure.Type;\n /** Absent for the original protocol. */\n readonly protocol?: AgentChannel.Protocol;\n readonly requiredChecks: typeof AgentChannel.RequiredChecks.Type;\n}\nexport type MaterializedCapabilityVersion =\n | MaterializedChannelCapabilityVersion\n | MaterializedActionCapabilityVersion\n | MaterializedTriggerCapabilityVersion;\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedRegistry {\n readonly dualIdentifier: string;\n readonly providers: readonly MaterializedProvider[];\n}\n\nconst authMethodId = (providerId: string, methodId: string): string => `${providerId}/${methodId}`;\n\n// FIXME(live-schema-validation): this JSON Schema is a lossy catalog/snapshot projection.\n// Hard validation must use the live SDK Schema declarations for the pinned version.\nconst schemaJson = (schema: Schema.Top): unknown =>\n Schema.toJsonSchemaDocument(schema, { onExcessProperty: \"error\" });\n\nconst authMethodMetadataJson = (method: AuthMethod.Any): unknown => {\n if (method.oauth2 === undefined) {\n return {};\n }\n\n const staticClient =\n typeof method.oauth2.client === \"function\" ? undefined : method.oauth2.client;\n\n // An endpoint derived from the setup has no value until a connection supplies\n // one, so the registry — which describes the method, not a connection — omits\n // it, exactly as it already omits a client built by a hook.\n const staticEndpoint = (endpoint: string | ((...args: never) => string) | undefined) =>\n typeof endpoint === \"function\" ? undefined : endpoint;\n const discoveryUrl = staticEndpoint(method.oauth2.discoveryUrl);\n const authorizationUrl = staticEndpoint(method.oauth2.authorizationUrl);\n const tokenUrl = staticEndpoint(method.oauth2.tokenUrl);\n\n return {\n oauth2: {\n scopes: method.oauth2.scopes,\n ...(staticClient === undefined\n ? {}\n : { clientAuthentication: staticClient.authentication ?? \"basic\" }),\n ...(discoveryUrl === undefined ? {} : { discoveryUrl }),\n ...(authorizationUrl === undefined ? {} : { authorizationUrl }),\n ...(tokenUrl === undefined ? {} : { tokenUrl }),\n ...(method.oauth2.pkce === undefined ? {} : { pkce: method.oauth2.pkce }),\n ...(method.oauth2.authorizationParams === undefined\n ? {}\n : { authorizationParams: method.oauth2.authorizationParams }),\n ...(method.oauth2.tokenParams === undefined\n ? {}\n : { tokenParams: method.oauth2.tokenParams }),\n },\n };\n};\n\n/**\n * Materialize the provider/capability registry of the installed plugin releases. This is the\n * canonical SDK-owned resolver used by server persistence/bootstrap code.\n *\n * @since 0.0.0\n * @category registry\n */\nexport const materializeResolvedRegistry = (input: {\n readonly dualIdentifier: string;\n readonly plugins: readonly PluginInstallation[];\n readonly aiProviders: readonly AiProvider.Any[];\n readonly schemaJson?: ((schema: Schema.Top) => unknown) | undefined;\n readonly projections?: Map<Schema.Top, unknown> | undefined;\n readonly projectSchemas?: ((capabilityId: string, version: string) => boolean) | undefined;\n}): MaterializedRegistry => {\n // Plugins reuse schema values across capabilities, auth methods and app\n // versions, so project each one once per materialization. The memo is dropped\n // with the caller's materialization rather than retaining every projection for\n // the lifetime of the app definition.\n const projectedSchemas = input.projections ?? new Map<Schema.Top, unknown>();\n const projectSchemaUncached = input.schemaJson ?? schemaJson;\n const projectSchema = (schema: Schema.Top): unknown => {\n if (projectedSchemas.has(schema)) return projectedSchemas.get(schema);\n const projected = projectSchemaUncached(schema);\n projectedSchemas.set(schema, projected);\n return projected;\n };\n const projectSchemasFor = input.projectSchemas ?? (() => true);\n const capabilityVersionsByProvider = new Map<string, MaterializedCapabilityVersion[]>();\n const addCapabilityVersion = (\n providerId: string,\n capabilityVersion: MaterializedCapabilityVersion,\n ) => {\n const versions = capabilityVersionsByProvider.get(providerId) ?? [];\n versions.push(capabilityVersion);\n capabilityVersionsByProvider.set(providerId, versions);\n };\n\n for (const entry of collectActionEntries(input.plugins)) {\n const projected = projectSchemasFor(entry.actionId, entry.pluginVersion);\n addCapabilityVersion(entry.providerId, {\n authMethodIds: entry.authMethods.map(method =>\n authMethodId(entry.providerId, method.identifier),\n ),\n capabilityId: entry.actionId,\n description: entry.action.description,\n examplesJson: entry.action.examples,\n inputSchemaJson: projected ? projectSchema(entry.action.input) : undefined,\n key: entry.localId,\n kind: \"action\" as const,\n requireAuth: entry.action.requireAuth !== false,\n name: entry.action.name,\n outputSchemaJson: projected ? projectSchema(entry.action.output) : undefined,\n sourcePluginKey: entry.providerId,\n sourcePluginVersion: entry.pluginVersion,\n version: entry.pluginVersion,\n });\n }\n\n for (const entry of collectTriggerEntries(input.plugins)) {\n const projected = projectSchemasFor(entry.triggerId, entry.pluginVersion);\n addCapabilityVersion(entry.providerId, {\n authMethodIds: entry.authMethods.map(method =>\n authMethodId(entry.providerId, method.identifier),\n ),\n capabilityId: entry.triggerId,\n configSchemaJson: projected ? projectSchema(entry.trigger.config) : undefined,\n description: entry.trigger.description,\n key: entry.localId,\n kind: \"trigger\" as const,\n requireAuth: entry.trigger.requireAuth !== false,\n name: entry.trigger.name,\n outputSchemaJson: projected ? projectSchema(entry.trigger.output) : undefined,\n sourcePluginKey: entry.providerId,\n sourcePluginVersion: entry.pluginVersion,\n stateSchemaJson:\n projected && entry.trigger.state !== undefined\n ? projectSchema(entry.trigger.state)\n : undefined,\n triggerKind: entry.trigger.kind,\n version: entry.pluginVersion,\n });\n }\n\n for (const { plugin, version } of input.plugins) {\n for (const channel of plugin.agentChannels) {\n const definition = channel.definition;\n AgentChannel.validateDefinition(definition, plugin.identifier, plugin.authMethods);\n addCapabilityVersion(plugin.identifier, {\n authMethodIds: definition.authMethods.map(method =>\n authMethodId(plugin.identifier, method.identifier),\n ),\n capabilityId: `${plugin.identifier}/${channel.identifier}`,\n description: channel.description,\n key: channel.identifier,\n kind: \"agent_channel\",\n requireAuth: true,\n name: channel.name,\n sourcePluginKey: plugin.identifier,\n sourcePluginVersion: version,\n version,\n ...AgentChannel.projectContract(definition, projectSchema),\n });\n }\n }\n const toolProviders: readonly MaterializedProvider[] = input.plugins.map(\n ({ plugin, version }) => ({\n authMethods: plugin.authMethods.map(method => ({\n description: method.description,\n id: authMethodId(plugin.identifier, method.identifier),\n inputSchemaJson: method.input === undefined ? null : projectSchema(method.input),\n key: method.identifier,\n kind: method.kind,\n materialSchemaJson: projectSchema(method.material),\n metadataJson: authMethodMetadataJson(method),\n name: method.name,\n providerId: plugin.identifier,\n setupSchemaJson: method.setup === undefined ? null : projectSchema(method.setup),\n })),\n capabilityVersions: capabilityVersionsByProvider.get(plugin.identifier) ?? [],\n categories: plugin.categories,\n description: plugin.description,\n docsUrl: plugin.docsUrl,\n homepageUrl: plugin.homepageUrl,\n iconUrl: plugin.iconUrl,\n iconUrlDark: plugin.iconUrlDark,\n id: plugin.identifier,\n key: plugin.identifier,\n kind: \"tools\" as const,\n name: plugin.name,\n sandboxAccess: plugin.sandboxAccess !== undefined,\n sourcePluginKey: plugin.identifier,\n sourcePluginVersion: version,\n }),\n );\n\n const aiProviders: readonly MaterializedProvider[] = input.aiProviders.flatMap(provider => {\n const id = AiProvider.registryId(provider.identifier);\n\n return [\n {\n authMethods: provider.authMethods.map(method => ({\n description: method.description,\n id: authMethodId(id, method.identifier),\n inputSchemaJson: method.input === undefined ? null : projectSchema(method.input),\n key: method.identifier,\n kind: method.kind,\n materialSchemaJson: projectSchema(method.material),\n metadataJson: authMethodMetadataJson(method),\n name: method.name,\n providerId: id,\n setupSchemaJson: method.setup === undefined ? null : projectSchema(method.setup),\n })),\n capabilityVersions: [],\n categories: provider.categories,\n description: provider.description,\n docsUrl: provider.docsUrl,\n homepageUrl: provider.homepageUrl,\n iconUrl: provider.iconUrl,\n iconUrlDark: provider.iconUrlDark,\n id,\n key: provider.identifier,\n kind: \"ai\" as const,\n name: provider.name,\n sandboxAccess: false,\n sourcePluginKey: undefined,\n sourcePluginVersion: undefined,\n },\n ];\n });\n\n return { dualIdentifier: input.dualIdentifier, providers: [...toolProviders, ...aiProviders] };\n};\n"],"mappings":";;;;;;;AA2HA,MAAM,gBAAgB,YAAoB,aAA6B,GAAG,WAAW,GAAG;AAIxF,MAAM,cAAc,WAClB,OAAO,qBAAqB,QAAQ,EAAE,kBAAkB,QAAQ,CAAC;AAEnE,MAAM,0BAA0B,WAAoC;CAClE,IAAI,OAAO,WAAW,KAAA,GACpB,OAAO,CAAC;CAGV,MAAM,eACJ,OAAO,OAAO,OAAO,WAAW,aAAa,KAAA,IAAY,OAAO,OAAO;CAKzE,MAAM,kBAAkB,aACtB,OAAO,aAAa,aAAa,KAAA,IAAY;CAC/C,MAAM,eAAe,eAAe,OAAO,OAAO,YAAY;CAC9D,MAAM,mBAAmB,eAAe,OAAO,OAAO,gBAAgB;CACtE,MAAM,WAAW,eAAe,OAAO,OAAO,QAAQ;CAEtD,OAAO,EACL,QAAQ;EACN,QAAQ,OAAO,OAAO;EACtB,GAAI,iBAAiB,KAAA,IACjB,CAAC,IACD,EAAE,sBAAsB,aAAa,kBAAkB,QAAQ;EACnE,GAAI,iBAAiB,KAAA,IAAY,CAAC,IAAI,EAAE,aAAa;EACrD,GAAI,qBAAqB,KAAA,IAAY,CAAC,IAAI,EAAE,iBAAiB;EAC7D,GAAI,aAAa,KAAA,IAAY,CAAC,IAAI,EAAE,SAAS;EAC7C,GAAI,OAAO,OAAO,SAAS,KAAA,IAAY,CAAC,IAAI,EAAE,MAAM,OAAO,OAAO,KAAK;EACvE,GA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ACf,eAAe;GACf,iBAAiB,KAAA;GACjB,qBAAqB,KAAA;EACvB,CACF;CACF,CAAC;CAED,OAAO;EAAE,gBAAgB,MAAM;EAAgB,WAAW,CAAC,GAAG,eAAe,GAAG,WAAW;CAAE;AAC/F"}
1
+ {"version":3,"file":"registry.js","names":["AgentChannel.projectContract","AiProvider.registryId"],"sources":["../../../src/internal/dual/registry.ts"],"sourcesContent":["/** Materialized Dual registry DTOs and resolver. */\nimport { Schema } from \"effect\";\n\nimport * as AgentChannel from \"../../AgentChannel.ts\";\nimport * as AiProvider from \"../../AiProvider.ts\";\nimport type * as AuthMethod from \"../../AuthMethod.ts\";\nimport type { PluginInstallation } from \"../../DualRuntime.ts\";\nimport type * as Plugin from \"../../Plugin.ts\";\n\nimport { collectActionEntries } from \"./actions.ts\";\nimport { collectTriggerEntries } from \"./triggers.ts\";\n\nexport interface MaterializedRegistryOptions {\n readonly schemaJson?: ((schema: Schema.Top) => unknown) | undefined;\n readonly projections?: Map<Schema.Top, unknown> | undefined;\n /** Selects the capability versions whose schemas are projected; the others carry `undefined` schemas. */\n readonly projectSchemas?: ((capabilityId: string, version: string) => boolean) | undefined;\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedAuthMethod {\n readonly id: string;\n readonly providerId: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly kind: AuthMethod.AuthMethodKind;\n readonly setupSchemaJson: unknown | null;\n readonly inputSchemaJson: unknown | null;\n readonly materialSchemaJson: unknown;\n readonly metadataJson: unknown;\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedProvider {\n readonly kind: \"tools\" | \"ai\";\n readonly id: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly iconUrl: string | undefined;\n readonly iconUrlDark: string | undefined;\n readonly categories: readonly Plugin.Category[];\n readonly homepageUrl: string | undefined;\n readonly docsUrl: string | undefined;\n /** Whether a shell in a run sandbox may use the provider's Connections through Dual's gateway. */\n readonly sandboxAccess: boolean;\n readonly sourcePluginKey: string | undefined;\n readonly sourcePluginVersion: string | undefined;\n readonly authMethods: readonly MaterializedAuthMethod[];\n readonly capabilityVersions: readonly MaterializedCapabilityVersion[];\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedActionCapabilityVersion {\n readonly kind: \"action\";\n readonly requireAuth: boolean;\n readonly capabilityId: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly version: string;\n readonly sourcePluginKey: string | undefined;\n readonly sourcePluginVersion: string | undefined;\n readonly authMethodIds: readonly string[];\n readonly inputSchemaJson: unknown;\n readonly outputSchemaJson: unknown;\n readonly examplesJson: unknown;\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedTriggerCapabilityVersion {\n readonly kind: \"trigger\";\n readonly requireAuth: boolean;\n readonly capabilityId: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly version: string;\n readonly sourcePluginKey: string | undefined;\n readonly sourcePluginVersion: string | undefined;\n readonly authMethodIds: readonly string[];\n readonly triggerKind: \"webhook\" | \"polling\";\n readonly configSchemaJson: unknown;\n readonly outputSchemaJson: unknown;\n readonly stateSchemaJson: unknown | undefined;\n}\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedChannelCapabilityVersion {\n readonly kind: \"agent_channel\";\n readonly requireAuth: boolean;\n readonly capabilityId: string;\n readonly key: string;\n readonly name: string | undefined;\n readonly description: string | undefined;\n readonly version: string;\n readonly sourcePluginKey: string | undefined;\n readonly sourcePluginVersion: string | undefined;\n readonly authMethodIds: readonly string[];\n readonly definitionSettingsSchemaJson: unknown;\n readonly deploymentSettingsSchemaJson: unknown;\n readonly stateSchemaJson: unknown;\n readonly operationInputSchemaJson: unknown;\n readonly operationOutputSchemaJson: unknown;\n readonly extensionsSchemaJson: Readonly<Record<string, unknown>>;\n readonly featuresJson: AgentChannel.Features;\n readonly exposure: typeof AgentChannel.Exposure.Type;\n readonly requiredChecks: typeof AgentChannel.RequiredChecks.Type;\n}\nexport type MaterializedCapabilityVersion =\n | MaterializedChannelCapabilityVersion\n | MaterializedActionCapabilityVersion\n | MaterializedTriggerCapabilityVersion;\n\n/** @since 0.0.0 @category registry */\nexport interface MaterializedRegistry {\n readonly dualIdentifier: string;\n readonly providers: readonly MaterializedProvider[];\n}\n\nconst authMethodId = (providerId: string, methodId: string): string => `${providerId}/${methodId}`;\n\n// FIXME(live-schema-validation): this JSON Schema is a lossy catalog/snapshot projection.\n// Hard validation must use the live SDK Schema declarations for the pinned version.\nconst schemaJson = (schema: Schema.Top): unknown =>\n Schema.toJsonSchemaDocument(schema, { onExcessProperty: \"error\" });\n\nconst authMethodMetadataJson = (method: AuthMethod.Any): unknown => {\n if (method.oauth2 === undefined) {\n return {};\n }\n\n const staticClient =\n typeof method.oauth2.client === \"function\" ? undefined : method.oauth2.client;\n\n // An endpoint derived from the setup has no value until a connection supplies\n // one, so the registry — which describes the method, not a connection — omits\n // it, exactly as it already omits a client built by a hook.\n const staticEndpoint = (endpoint: string | ((...args: never) => string) | undefined) =>\n typeof endpoint === \"function\" ? undefined : endpoint;\n const discoveryUrl = staticEndpoint(method.oauth2.discoveryUrl);\n const authorizationUrl = staticEndpoint(method.oauth2.authorizationUrl);\n const tokenUrl = staticEndpoint(method.oauth2.tokenUrl);\n\n return {\n oauth2: {\n scopes: method.oauth2.scopes,\n ...(staticClient === undefined\n ? {}\n : { clientAuthentication: staticClient.authentication ?? \"basic\" }),\n ...(discoveryUrl === undefined ? {} : { discoveryUrl }),\n ...(authorizationUrl === undefined ? {} : { authorizationUrl }),\n ...(tokenUrl === undefined ? {} : { tokenUrl }),\n ...(method.oauth2.pkce === undefined ? {} : { pkce: method.oauth2.pkce }),\n ...(method.oauth2.authorizationParams === undefined\n ? {}\n : { authorizationParams: method.oauth2.authorizationParams }),\n ...(method.oauth2.tokenParams === undefined\n ? {}\n : { tokenParams: method.oauth2.tokenParams }),\n },\n };\n};\n\n/**\n * Materialize the provider/capability registry of the installed plugin releases. This is the\n * canonical SDK-owned resolver used by server persistence/bootstrap code.\n *\n * @since 0.0.0\n * @category registry\n */\nexport const materializeResolvedRegistry = (input: {\n readonly dualIdentifier: string;\n readonly plugins: readonly PluginInstallation[];\n readonly aiProviders: readonly AiProvider.Any[];\n readonly schemaJson?: ((schema: Schema.Top) => unknown) | undefined;\n readonly projections?: Map<Schema.Top, unknown> | undefined;\n readonly projectSchemas?: ((capabilityId: string, version: string) => boolean) | undefined;\n}): MaterializedRegistry => {\n // Plugins reuse schema values across capabilities, auth methods and app\n // versions, so project each one once per materialization. The memo is dropped\n // with the caller's materialization rather than retaining every projection for\n // the lifetime of the app definition.\n const projectedSchemas = input.projections ?? new Map<Schema.Top, unknown>();\n const projectSchemaUncached = input.schemaJson ?? schemaJson;\n const projectSchema = (schema: Schema.Top): unknown => {\n if (projectedSchemas.has(schema)) return projectedSchemas.get(schema);\n const projected = projectSchemaUncached(schema);\n projectedSchemas.set(schema, projected);\n return projected;\n };\n const projectSchemasFor = input.projectSchemas ?? (() => true);\n const capabilityVersionsByProvider = new Map<string, MaterializedCapabilityVersion[]>();\n const addCapabilityVersion = (\n providerId: string,\n capabilityVersion: MaterializedCapabilityVersion,\n ) => {\n const versions = capabilityVersionsByProvider.get(providerId) ?? [];\n versions.push(capabilityVersion);\n capabilityVersionsByProvider.set(providerId, versions);\n };\n\n for (const entry of collectActionEntries(input.plugins)) {\n const projected = projectSchemasFor(entry.actionId, entry.pluginVersion);\n addCapabilityVersion(entry.providerId, {\n authMethodIds: entry.authMethods.map(method =>\n authMethodId(entry.providerId, method.identifier),\n ),\n capabilityId: entry.actionId,\n description: entry.action.description,\n examplesJson: entry.action.examples,\n inputSchemaJson: projected ? projectSchema(entry.action.input) : undefined,\n key: entry.localId,\n kind: \"action\" as const,\n requireAuth: entry.action.requireAuth !== false,\n name: entry.action.name,\n outputSchemaJson: projected ? projectSchema(entry.action.output) : undefined,\n sourcePluginKey: entry.providerId,\n sourcePluginVersion: entry.pluginVersion,\n version: entry.pluginVersion,\n });\n }\n\n for (const entry of collectTriggerEntries(input.plugins)) {\n const projected = projectSchemasFor(entry.triggerId, entry.pluginVersion);\n addCapabilityVersion(entry.providerId, {\n authMethodIds: entry.authMethods.map(method =>\n authMethodId(entry.providerId, method.identifier),\n ),\n capabilityId: entry.triggerId,\n configSchemaJson: projected ? projectSchema(entry.trigger.config) : undefined,\n description: entry.trigger.description,\n key: entry.localId,\n kind: \"trigger\" as const,\n requireAuth: entry.trigger.requireAuth !== false,\n name: entry.trigger.name,\n outputSchemaJson: projected ? projectSchema(entry.trigger.output) : undefined,\n sourcePluginKey: entry.providerId,\n sourcePluginVersion: entry.pluginVersion,\n stateSchemaJson:\n projected && entry.trigger.state !== undefined\n ? projectSchema(entry.trigger.state)\n : undefined,\n triggerKind: entry.trigger.kind,\n version: entry.pluginVersion,\n });\n }\n\n for (const { plugin, version } of input.plugins) {\n for (const channel of plugin.agentChannels) {\n const definition = channel.definition;\n AgentChannel.validateDefinition(definition, plugin.identifier, plugin.authMethods);\n addCapabilityVersion(plugin.identifier, {\n authMethodIds: definition.authMethods.map(method =>\n authMethodId(plugin.identifier, method.identifier),\n ),\n capabilityId: `${plugin.identifier}/${channel.identifier}`,\n description: channel.description,\n key: channel.identifier,\n kind: \"agent_channel\",\n requireAuth: true,\n name: channel.name,\n sourcePluginKey: plugin.identifier,\n sourcePluginVersion: version,\n version,\n ...AgentChannel.projectContract(definition, projectSchema),\n });\n }\n }\n const toolProviders: readonly MaterializedProvider[] = input.plugins.map(\n ({ plugin, version }) => ({\n authMethods: plugin.authMethods.map(method => ({\n description: method.description,\n id: authMethodId(plugin.identifier, method.identifier),\n inputSchemaJson: method.input === undefined ? null : projectSchema(method.input),\n key: method.identifier,\n kind: method.kind,\n materialSchemaJson: projectSchema(method.material),\n metadataJson: authMethodMetadataJson(method),\n name: method.name,\n providerId: plugin.identifier,\n setupSchemaJson: method.setup === undefined ? null : projectSchema(method.setup),\n })),\n capabilityVersions: capabilityVersionsByProvider.get(plugin.identifier) ?? [],\n categories: plugin.categories,\n description: plugin.description,\n docsUrl: plugin.docsUrl,\n homepageUrl: plugin.homepageUrl,\n iconUrl: plugin.iconUrl,\n iconUrlDark: plugin.iconUrlDark,\n id: plugin.identifier,\n key: plugin.identifier,\n kind: \"tools\" as const,\n name: plugin.name,\n sandboxAccess: plugin.sandboxAccess !== undefined,\n sourcePluginKey: plugin.identifier,\n sourcePluginVersion: version,\n }),\n );\n\n const aiProviders: readonly MaterializedProvider[] = input.aiProviders.flatMap(provider => {\n const id = AiProvider.registryId(provider.identifier);\n\n return [\n {\n authMethods: provider.authMethods.map(method => ({\n description: method.description,\n id: authMethodId(id, method.identifier),\n inputSchemaJson: method.input === undefined ? null : projectSchema(method.input),\n key: method.identifier,\n kind: method.kind,\n materialSchemaJson: projectSchema(method.material),\n metadataJson: authMethodMetadataJson(method),\n name: method.name,\n providerId: id,\n setupSchemaJson: method.setup === undefined ? null : projectSchema(method.setup),\n })),\n capabilityVersions: [],\n categories: provider.categories,\n description: provider.description,\n docsUrl: provider.docsUrl,\n homepageUrl: provider.homepageUrl,\n iconUrl: provider.iconUrl,\n iconUrlDark: provider.iconUrlDark,\n id,\n key: provider.identifier,\n kind: \"ai\" as const,\n name: provider.name,\n sandboxAccess: false,\n sourcePluginKey: undefined,\n sourcePluginVersion: undefined,\n },\n ];\n });\n\n return { dualIdentifier: input.dualIdentifier, providers: [...toolProviders, ...aiProviders] };\n};\n"],"mappings":";;;;;;;AAyHA,MAAM,gBAAgB,YAAoB,aAA6B,GAAG,WAAW,GAAG;AAIxF,MAAM,cAAc,WAClB,OAAO,qBAAqB,QAAQ,EAAE,kBAAkB,QAAQ,CAAC;AAEnE,MAAM,0BAA0B,WAAoC;CAClE,IAAI,OAAO,WAAW,KAAA,GACpB,OAAO,CAAC;CAGV,MAAM,eACJ,OAAO,OAAO,OAAO,WAAW,aAAa,KAAA,IAAY,OAAO,OAAO;CAKzE,MAAM,kBAAkB,aACtB,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,UAAU;EAEpD,OAAO,CACL;GACE,aAAa,SAAS,YAAY,KAAI,YAAW;IAC/C,aAAa,OAAO;IACpB,IAAI,aAAa,IAAI,OAAO,UAAU;IACtC,iBAAiB,OAAO,UAAU,KAAA,IAAY,OAAO,cAAc,OAAO,KAAK;IAC/E,KAAK,OAAO;IACZ,MAAM,OAAO;IACb,oBAAoB,cAAc,OAAO,QAAQ;IACjD,cAAc,uBAAuB,MAAM;IAC3C,MAAM,OAAO;IACb,YAAY;IACZ,iBAAiB,OAAO,UAAU,KAAA,IAAY,OAAO,cAAc,OAAO,KAAK;GACjF,EAAE;GACF,oBAAoB,CAAC;GACrB,YAAY,SAAS;GACrB,aAAa,SAAS;GACtB,SAAS,SAAS;GAClB,aAAa,SAAS;GACtB,SAAS,SAAS;GAClB,aAAa,SAAS;GACtB;GACA,KAAK,SAAS;GACd,MAAM;GACN,MAAM,SAAS;GACf,eAAe;GACf,iBAAiB,KAAA;GACjB,qBAAqB,KAAA;EACvB,CACF;CACF,CAAC;CAED,OAAO;EAAE,gBAAgB,MAAM;EAAgB,WAAW,CAAC,GAAG,eAAe,GAAG,WAAW;CAAE;AAC/F"}
@@ -20,8 +20,10 @@ const getNestedHandler = (handlers, localId) => {
20
20
  };
21
21
  /** Register a plugin's handlers as one Context group keyed by the plugin. */
22
22
  const toHandlers = (plugin, handlers) => Effect.gen(function* () {
23
- const services = withoutGroups(yield* Effect.context());
24
- const map = /* @__PURE__ */ new Map();
23
+ const context = yield* Effect.context();
24
+ const services = withoutGroups(context);
25
+ const inherited = context.mapUnsafe.get(handlerGroupKey(plugin.identifier));
26
+ const map = new Map(Predicate.isMap(inherited) ? inherited : []);
25
27
  const find = (kind, declarations, localId) => {
26
28
  const handler = getNestedHandler(declarations, localId);
27
29
  return handler === void 0 ? missingDeclaration(kind, localId, plugin.identifier) : handler;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-handlers.js","names":["Action.handlerKey","Trigger.handlerKey","AgentChannel.handlerKey"],"sources":["../../src/internal/plugin-handlers.ts"],"sourcesContent":["/** Plugin handler services and their registration. */\nimport { Context, Effect, Predicate } from \"effect\";\n\nimport * as Action from \"../Action.ts\";\nimport * as AgentChannel from \"../AgentChannel.ts\";\nimport type * as AuthMethod from \"../AuthMethod.ts\";\nimport type * as Group from \"../Group.ts\";\nimport type { Any } from \"../Plugin.ts\";\nimport * as Trigger from \"../Trigger.ts\";\n\nimport { walkCapabilities } from \"./capabilities.ts\";\nimport { handlerGroupKey, withoutGroups } from \"./handler-context.ts\";\nimport { MachineIdSeparator } from \"./identifier.ts\";\nimport type { IsGenericArray, JoinPrefix } from \"./types.ts\";\n\ntype LocalTriggerEntriesFromTriggers<\n Triggers extends readonly Trigger.Any[],\n Prefix extends string,\n AllowedMethods extends readonly AuthMethod.Any[],\n> = Triggers[number] extends infer TriggerDef\n ? TriggerDef extends Trigger.Any\n ? {\n readonly localId: JoinPrefix<Prefix, TriggerDef[\"identifier\"]>;\n readonly trigger: TriggerDef;\n readonly authMethods: AllowedMethods;\n }\n : never\n : never;\n\ntype LocalTriggerEntriesFromGroups<\n GroupDef extends Group.Any,\n Prefix extends string,\n AllowedMethods extends readonly AuthMethod.Any[],\n> = GroupDef extends unknown\n ?\n | LocalTriggerEntriesFromTriggers<\n GroupDef[\"triggers\"],\n JoinPrefix<Prefix, GroupDef[\"identifier\"]>,\n AllowedMethods\n >\n | (IsGenericArray<GroupDef[\"groups\"]> extends true\n ? LocalTriggerEntriesFromTriggers<readonly Trigger.Any[], string, AllowedMethods>\n : LocalTriggerEntriesFromGroups<\n GroupDef[\"groups\"][number],\n JoinPrefix<Prefix, GroupDef[\"identifier\"]>,\n AllowedMethods\n >)\n : never;\n\nexport type LocalTriggerEntries<P extends Any> =\n | LocalTriggerEntriesFromTriggers<P[\"triggers\"], \"\", P[\"authMethods\"]>\n | LocalTriggerEntriesFromGroups<P[\"groups\"][number], \"\", P[\"authMethods\"]>;\n\nexport type CanonicalTriggerId<\n P extends Any,\n LocalId extends string,\n> = `${P[\"identifier\"]}${typeof MachineIdSeparator}${LocalId}`;\n\n/** Keyed by the plugin's capabilities, which `Plugin.provide` keeps, so a Layer serves only them. */\nexport interface ActionHandlerService<\n in out PluginId extends string,\n in out Actions extends readonly unknown[],\n in out Groups extends readonly unknown[],\n> {\n readonly _: unique symbol;\n readonly pluginId: PluginId;\n readonly actions: Actions;\n readonly groups: Groups;\n}\n\nexport type ActionHandlerServiceOf<P extends Any> = ActionHandlerService<\n P[\"identifier\"],\n P[\"actions\"],\n P[\"groups\"]\n>;\n\nexport type HandlerServices<P extends Any> =\n | ActionHandlerServiceOf<P>\n | ([P[\"agentChannels\"][number]] extends [never]\n ? never\n : AgentChannel.Handler<`${P[\"identifier\"]}/${P[\"agentChannels\"][number][\"identifier\"]}`>)\n | (LocalTriggerEntries<P> extends infer Entry\n ? Entry extends { readonly localId: infer LocalId extends string }\n ? Trigger.Handler<CanonicalTriggerId<P, LocalId>>\n : never\n : never);\n\ninterface Declarations {\n readonly actions: unknown;\n readonly triggers: unknown;\n readonly agentChannels: unknown;\n}\n\n/* Missing handler declarations are builder defects, not expected failures, so\n they intentionally throw instead of entering the Effect failure channel. */\nconst missingDeclaration = (kind: string, localId: string, pluginId: string): never => {\n throw new Error(`missing ${kind} handler for \"${localId}\" in plugin \"${pluginId}\"`);\n};\n\nconst getNestedHandler = (handlers: unknown, localId: string): unknown => {\n let current = handlers;\n for (const segment of localId.split(MachineIdSeparator)) {\n if (!Predicate.hasProperty(current, segment)) return undefined;\n current = current[segment];\n }\n return current;\n};\n\n/** Register a plugin's handlers as one Context group keyed by the plugin. */\nexport const toHandlers = (\n plugin: Any,\n handlers: Declarations,\n): Effect.Effect<Context.Context<never>> =>\n Effect.gen(function* () {\n const services = withoutGroups(yield* Effect.context());\n const map = new Map<string, unknown>();\n // A declared but invalid handler, such as `null` from JavaScript, fails when it is used.\n const find = (kind: string, declarations: unknown, localId: string) => {\n const handler = getNestedHandler(declarations, localId);\n return handler === undefined ? missingDeclaration(kind, localId, plugin.identifier) : handler;\n };\n\n for (const entry of walkCapabilities(plugin, owner => owner.actions)) {\n map.set(Action.handlerKey(entry.canonicalId), {\n actionId: entry.canonicalId,\n context: services,\n handler: find(\"action\", handlers.actions, entry.localId),\n });\n }\n for (const entry of walkCapabilities(plugin, owner => owner.triggers)) {\n map.set(Trigger.handlerKey(entry.canonicalId), {\n context: services,\n runtime: find(\"trigger\", handlers.triggers, entry.localId),\n triggerId: entry.canonicalId,\n });\n }\n for (const channel of plugin.agentChannels) {\n const channelId = `${plugin.identifier}/${channel.identifier}`;\n map.set(AgentChannel.handlerKey(channelId), {\n channelId,\n context: services,\n runtime: find(\"agent channel\", handlers.agentChannels, channel.identifier),\n });\n }\n return Context.makeUnsafe(new Map([[handlerGroupKey(plugin.identifier), map]]));\n });\n"],"mappings":";;;;;;;;;AA+FA,MAAM,sBAAsB,MAAc,SAAiB,aAA4B;CACrF,MAAM,IAAI,MAAM,WAAW,KAAK,gBAAgB,QAAQ,eAAe,SAAS,EAAE;AACpF;AAEA,MAAM,oBAAoB,UAAmB,YAA6B;CACxE,IAAI,UAAU;CACd,KAAK,MAAM,WAAW,QAAQ,MAAA,GAAwB,GAAG;EACvD,IAAI,CAAC,UAAU,YAAY,SAAS,OAAO,GAAG,OAAO,KAAA;EACrD,UAAU,QAAQ;CACpB;CACA,OAAO;AACT;;AAGA,MAAa,cACX,QACA,aAEA,OAAO,IAAI,aAAa;CACtB,MAAM,WAAW,cAAc,OAAO,OAAO,QAAQ,CAAC;CACtD,MAAM,sBAAM,IAAI,IAAqB;CAErC,MAAM,QAAQ,MAAc,cAAuB,YAAoB;EACrE,MAAM,UAAU,iBAAiB,cAAc,OAAO;EACtD,OAAO,YAAY,KAAA,IAAY,mBAAmB,MAAM,SAAS,OAAO,UAAU,IAAI;CACxF;CAEA,KAAK,MAAM,SAAS,iBAAiB,SAAQ,UAAS,MAAM,OAAO,GACjE,IAAI,IAAIA,WAAkB,MAAM,WAAW,GAAG;EAC5C,UAAU,MAAM;EAChB,SAAS;EACT,SAAS,KAAK,UAAU,SAAS,SAAS,MAAM,OAAO;CACzD,CAAC;CAEH,KAAK,MAAM,SAAS,iBAAiB,SAAQ,UAAS,MAAM,QAAQ,GAClE,IAAI,IAAIC,aAAmB,MAAM,WAAW,GAAG;EAC7C,SAAS;EACT,SAAS,KAAK,WAAW,SAAS,UAAU,MAAM,OAAO;EACzD,WAAW,MAAM;CACnB,CAAC;CAEH,KAAK,MAAM,WAAW,OAAO,eAAe;EAC1C,MAAM,YAAY,GAAG,OAAO,WAAW,GAAG,QAAQ;EAClD,IAAI,IAAIC,aAAwB,SAAS,GAAG;GAC1C;GACA,SAAS;GACT,SAAS,KAAK,iBAAiB,SAAS,eAAe,QAAQ,UAAU;EAC3E,CAAC;CACH;CACA,OAAO,QAAQ,2BAAW,IAAI,IAAI,CAAC,CAAC,gBAAgB,OAAO,UAAU,GAAG,GAAG,CAAC,CAAC,CAAC;AAChF,CAAC"}
1
+ {"version":3,"file":"plugin-handlers.js","names":["Action.handlerKey","Trigger.handlerKey","AgentChannel.handlerKey"],"sources":["../../src/internal/plugin-handlers.ts"],"sourcesContent":["/** Plugin handler services and their registration. */\nimport { Context, Effect, Predicate } from \"effect\";\n\nimport * as Action from \"../Action.ts\";\nimport * as AgentChannel from \"../AgentChannel.ts\";\nimport type * as AuthMethod from \"../AuthMethod.ts\";\nimport type * as Group from \"../Group.ts\";\nimport type { Any } from \"../Plugin.ts\";\nimport * as Trigger from \"../Trigger.ts\";\n\nimport { walkCapabilities } from \"./capabilities.ts\";\nimport { handlerGroupKey, withoutGroups } from \"./handler-context.ts\";\nimport { MachineIdSeparator } from \"./identifier.ts\";\nimport type { IsGenericArray, JoinPrefix } from \"./types.ts\";\n\ntype LocalTriggerEntriesFromTriggers<\n Triggers extends readonly Trigger.Any[],\n Prefix extends string,\n AllowedMethods extends readonly AuthMethod.Any[],\n> = Triggers[number] extends infer TriggerDef\n ? TriggerDef extends Trigger.Any\n ? {\n readonly localId: JoinPrefix<Prefix, TriggerDef[\"identifier\"]>;\n readonly trigger: TriggerDef;\n readonly authMethods: AllowedMethods;\n }\n : never\n : never;\n\ntype LocalTriggerEntriesFromGroups<\n GroupDef extends Group.Any,\n Prefix extends string,\n AllowedMethods extends readonly AuthMethod.Any[],\n> = GroupDef extends unknown\n ?\n | LocalTriggerEntriesFromTriggers<\n GroupDef[\"triggers\"],\n JoinPrefix<Prefix, GroupDef[\"identifier\"]>,\n AllowedMethods\n >\n | (IsGenericArray<GroupDef[\"groups\"]> extends true\n ? LocalTriggerEntriesFromTriggers<readonly Trigger.Any[], string, AllowedMethods>\n : LocalTriggerEntriesFromGroups<\n GroupDef[\"groups\"][number],\n JoinPrefix<Prefix, GroupDef[\"identifier\"]>,\n AllowedMethods\n >)\n : never;\n\nexport type LocalTriggerEntries<P extends Any> =\n | LocalTriggerEntriesFromTriggers<P[\"triggers\"], \"\", P[\"authMethods\"]>\n | LocalTriggerEntriesFromGroups<P[\"groups\"][number], \"\", P[\"authMethods\"]>;\n\nexport type CanonicalTriggerId<\n P extends Any,\n LocalId extends string,\n> = `${P[\"identifier\"]}${typeof MachineIdSeparator}${LocalId}`;\n\n/** Keyed by the plugin's capabilities, which `Plugin.provide` keeps, so a Layer serves only them. */\nexport interface ActionHandlerService<\n in out PluginId extends string,\n in out Actions extends readonly unknown[],\n in out Groups extends readonly unknown[],\n> {\n readonly _: unique symbol;\n readonly pluginId: PluginId;\n readonly actions: Actions;\n readonly groups: Groups;\n}\n\nexport type ActionHandlerServiceOf<P extends Any> = ActionHandlerService<\n P[\"identifier\"],\n P[\"actions\"],\n P[\"groups\"]\n>;\n\nexport type HandlerServices<P extends Any> =\n | ActionHandlerServiceOf<P>\n | ([P[\"agentChannels\"][number]] extends [never]\n ? never\n : AgentChannel.Handler<`${P[\"identifier\"]}/${P[\"agentChannels\"][number][\"identifier\"]}`>)\n | (LocalTriggerEntries<P> extends infer Entry\n ? Entry extends { readonly localId: infer LocalId extends string }\n ? Trigger.Handler<CanonicalTriggerId<P, LocalId>>\n : never\n : never);\n\ninterface Declarations {\n readonly actions: unknown;\n readonly triggers: unknown;\n readonly agentChannels: unknown;\n}\n\n/* Missing handler declarations are builder defects, not expected failures, so\n they intentionally throw instead of entering the Effect failure channel. */\nconst missingDeclaration = (kind: string, localId: string, pluginId: string): never => {\n throw new Error(`missing ${kind} handler for \"${localId}\" in plugin \"${pluginId}\"`);\n};\n\nconst getNestedHandler = (handlers: unknown, localId: string): unknown => {\n let current = handlers;\n for (const segment of localId.split(MachineIdSeparator)) {\n if (!Predicate.hasProperty(current, segment)) return undefined;\n current = current[segment];\n }\n return current;\n};\n\n/** Register a plugin's handlers as one Context group keyed by the plugin. */\nexport const toHandlers = (\n plugin: Any,\n handlers: Declarations,\n): Effect.Effect<Context.Context<never>> =>\n Effect.gen(function* () {\n const context = yield* Effect.context();\n const services = withoutGroups(context);\n // Composed capability layers of the same plugin share one handler group.\n const inherited = context.mapUnsafe.get(handlerGroupKey(plugin.identifier));\n const map = new Map(Predicate.isMap(inherited) ? inherited : []);\n // A declared but invalid handler, such as `null` from JavaScript, fails when it is used.\n const find = (kind: string, declarations: unknown, localId: string) => {\n const handler = getNestedHandler(declarations, localId);\n return handler === undefined ? missingDeclaration(kind, localId, plugin.identifier) : handler;\n };\n\n for (const entry of walkCapabilities(plugin, owner => owner.actions)) {\n map.set(Action.handlerKey(entry.canonicalId), {\n actionId: entry.canonicalId,\n context: services,\n handler: find(\"action\", handlers.actions, entry.localId),\n });\n }\n for (const entry of walkCapabilities(plugin, owner => owner.triggers)) {\n map.set(Trigger.handlerKey(entry.canonicalId), {\n context: services,\n runtime: find(\"trigger\", handlers.triggers, entry.localId),\n triggerId: entry.canonicalId,\n });\n }\n for (const channel of plugin.agentChannels) {\n const channelId = `${plugin.identifier}/${channel.identifier}`;\n map.set(AgentChannel.handlerKey(channelId), {\n channelId,\n context: services,\n runtime: find(\"agent channel\", handlers.agentChannels, channel.identifier),\n });\n }\n return Context.make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