@dual-os/sdk 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ import { Service as Service$1 } from "./OAuthFlow.js";
8
8
  import "./PluginRuntime.js";
9
9
  import { Cause, Effect, Schema, Stream } from "effect";
10
10
  declare namespace PluginRuntime_d_exports {
11
- export { AuthRequest, ChannelSettingsRequest, ExecutionRequest, Invocation, IpcEvents, IpcSender, OAuthContinuation, OAuthStarted, PluginExecutionError, PluginRuntime_d_exports as PluginRuntime, Request, SandboxAccessResult, cancellationTimeout, checkMessageSize, decodeInput, decodeOutput, encodeInput, encodeOutput, encodeRequest, execute, ipcMessages, maxChannelResultBytes, maxMetadataBytes, maxPayloadBytes, readBounded, responseLimit, sendIpc, verifyResponse };
11
+ export { AuthRequest, ChannelSettingsRequest, ExecutionRequest, Invocation, IpcEvents, IpcSender, OAuthContinuation, OAuthStarted, PluginExecutionError, PluginRuntime_d_exports as PluginRuntime, Request, SandboxAccessResult, cancellationTimeout, checkMessageSize, decodeInput, decodeOutput, encodeInput, encodeOutput, encodeRequest, execute, ipcMessages, maxChannelResultBytes, maxMetadataBytes, maxPayloadBytes, maxResponseBytes, readBounded, responseLimit, sendIpc, verifyResponse };
12
12
  }
13
13
  declare const PluginExecutionError_base: Schema.Class<PluginExecutionError, Schema.TaggedStruct<"PluginExecutionError", {
14
14
  readonly category: Schema.Literals<readonly ["transport", "runner", "protocol", "cleanup", "artifact-expired"]>;
@@ -17,6 +17,7 @@ declare const PluginExecutionError_base: Schema.Class<PluginExecutionError, Sche
17
17
  }>, Cause.YieldableError>;
18
18
  export declare class PluginExecutionError extends PluginExecutionError_base {}
19
19
  export declare const maxPayloadBytes: number;
20
+ export declare const maxResponseBytes: number;
20
21
  export declare const maxMetadataBytes: number;
21
22
  /** An Agent Channel result carries a read asset of up to 14 MiB. */
22
23
  export declare const maxChannelResultBytes: number;
@@ -1 +1 @@
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;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;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAjDa;;;;;;;;;WAqCE;;;;;;;;;UAgBjCkB,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;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,g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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiBzB;;qBAuGW,UAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAjDa;;;;;;;;;WAqCE;;;;;;;;;UAgBjCkB,UAAAC"}
@@ -30,6 +30,7 @@ var PluginRuntime_exports = /* @__PURE__ */ __exportAll({
30
30
  maxChannelResultBytes: () => maxChannelResultBytes,
31
31
  maxMetadataBytes: () => maxMetadataBytes,
32
32
  maxPayloadBytes: () => maxPayloadBytes,
33
+ maxResponseBytes: () => maxResponseBytes,
33
34
  readBounded: () => readBounded,
34
35
  responseLimit: () => responseLimit,
35
36
  sendIpc: () => sendIpc,
@@ -47,6 +48,7 @@ var PluginExecutionError = class extends Schema.TaggedError()("PluginExecutionEr
47
48
  message: Schema.String
48
49
  }) {};
49
50
  const maxPayloadBytes = 1048576;
51
+ const maxResponseBytes = 52428800;
50
52
  const maxMetadataBytes = 67108864;
51
53
  /** An Agent Channel result carries a read asset of up to 14 MiB. */
52
54
  const maxChannelResultBytes = 16777216;
@@ -192,7 +194,7 @@ const decodeOutput = Effect.fnUntraced(function* (output) {
192
194
  function responseLimit(request) {
193
195
  if ("_tag" in request && request._tag === "extract") return maxMetadataBytes;
194
196
  if ("context" in request && request.operation._tag === "channelExecute") return maxChannelResultBytes;
195
- return maxPayloadBytes;
197
+ return maxResponseBytes;
196
198
  }
197
199
  const Invocation = Schema.Struct({
198
200
  entrypoint: Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_-]+(?:[./][A-Za-z0-9_-]+)*$/u)),
@@ -212,23 +214,17 @@ const encodeRequest = Effect.fnUntraced(function* (request) {
212
214
  return encoded;
213
215
  });
214
216
  const readBounded = Effect.fnUntraced(function* (input, maximum = maxPayloadBytes) {
215
- const output = {
216
- bytes: Buffer.alloc(maximum),
217
- size: 0
218
- };
219
- yield* pipe(input, Stream.runForEach((chunk) => Effect.gen(function* () {
220
- if (output.size + chunk.byteLength > maximum) return yield* PluginExecutionError.make({
221
- category: "protocol",
222
- message: "Plugin payload exceeds its transport limit"
223
- });
224
- Buffer.from(chunk).copy(output.bytes, output.size);
225
- output.size += chunk.byteLength;
226
- })), Effect.mapError((cause) => PluginExecutionError.make({
227
- cause: Redacted.make(cause),
217
+ return yield* pipe(input, Stream.mapAccumEffect(() => 0, (size, chunk) => size + chunk.byteLength > maximum ? Effect.fail(PluginExecutionError.make({
228
218
  category: "protocol",
229
- message: "Cannot read plugin payload"
230
- })));
231
- return output.bytes.toString("utf8", 0, output.size);
219
+ message: "Plugin payload exceeds its transport limit"
220
+ })) : Effect.succeed([size + chunk.byteLength, [chunk]])), Stream.mkUint8Array, Effect.mapBoth({
221
+ onSuccess: (bytes) => Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("utf8"),
222
+ onFailure: (cause) => PluginExecutionError.make({
223
+ cause: Redacted.make(cause),
224
+ category: "protocol",
225
+ message: "Cannot read plugin payload"
226
+ })
227
+ }));
232
228
  });
233
229
  const verifyResponse = Effect.fnUntraced(function* (request, response) {
234
230
  if (response.identity.invocationId !== request.identity.invocationId || response.identity.artifactDigest !== request.identity.artifactDigest || response.identity.organizationId !== request.identity.organizationId || response.identity.pluginKey !== request.identity.pluginKey || response.identity.pluginVersion !== request.identity.pluginVersion) return yield* PluginExecutionError.make({
@@ -327,6 +323,6 @@ const execute = Effect.fnUntraced(function* (request) {
327
323
  if (request._tag === "auth") return yield* executeAuth(request);
328
324
  return yield* executeChannelSettings(request);
329
325
  });
330
- export { AuthRequest, ChannelSettingsRequest, ExecutionRequest, Invocation, OAuthContinuation, OAuthStarted, PluginExecutionError, PluginRuntime_exports as PluginRuntime, PluginRuntime_exports, Request, SandboxAccessResult, cancellationTimeout, checkMessageSize, decodeInput, decodeOutput, encodeInput, encodeOutput, encodeRequest, execute, ipcMessages, maxChannelResultBytes, maxMetadataBytes, maxPayloadBytes, readBounded, responseLimit, sendIpc, verifyResponse };
326
+ export { AuthRequest, ChannelSettingsRequest, ExecutionRequest, Invocation, OAuthContinuation, OAuthStarted, PluginExecutionError, PluginRuntime_exports as PluginRuntime, PluginRuntime_exports, Request, SandboxAccessResult, cancellationTimeout, checkMessageSize, decodeInput, decodeOutput, encodeInput, encodeOutput, encodeRequest, execute, ipcMessages, maxChannelResultBytes, maxMetadataBytes, maxPayloadBytes, maxResponseBytes, readBounded, responseLimit, sendIpc, verifyResponse };
331
327
 
332
328
  //# sourceMappingURL=PluginRuntime.js.map
@@ -1 +1 @@
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 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: Request) {\n const encoded = yield* Schema.encodeEffect(Request)(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(Request)(json);\n});\n\nexport const encodeOutput = Effect.fnUntraced(function* (\n output: RemoteRuntime.Response,\n maximum: number,\n) {\n const encoded = yield* Schema.encodeEffect(RemoteRuntime.Response)(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(RemoteRuntime.Response)(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* (\n request: Request,\n response: RemoteRuntime.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,wBAC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AAsB,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
+ {"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 maxResponseBytes = 50 * 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 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: Request) {\n const encoded = yield* Schema.encodeEffect(Request)(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(Request)(json);\n});\n\nexport const encodeOutput = Effect.fnUntraced(function* (\n output: RemoteRuntime.Response,\n maximum: number,\n) {\n const encoded = yield* Schema.encodeEffect(RemoteRuntime.Response)(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(RemoteRuntime.Response)(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 maxResponseBytes;\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 return yield* pipe(\n input,\n Stream.mapAccumEffect(\n () => 0,\n (size, chunk: Uint8Array) =>\n size + chunk.byteLength > maximum\n ? Effect.fail(\n PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin payload exceeds its transport limit\",\n }),\n )\n : Effect.succeed([size + chunk.byteLength, [chunk]] as const),\n ),\n Stream.mkUint8Array,\n Effect.mapBoth({\n onSuccess: bytes =>\n Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString(\"utf8\"),\n onFailure: cause =>\n PluginExecutionError.make({\n cause: Redacted.make(cause),\n category: \"protocol\",\n message: \"Cannot read plugin payload\",\n }),\n }),\n );\n});\n\nexport const verifyResponse = Effect.fnUntraced(function* (\n request: Request,\n response: RemoteRuntime.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;AAChC,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,QA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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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dual-os/sdk",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist/**/*.js",
@@ -17,6 +17,7 @@ export class PluginExecutionError extends Schema.TaggedError<PluginExecutionErro
17
17
  ) {}
18
18
 
19
19
  export const maxPayloadBytes = 1024 * 1024;
20
+ export const maxResponseBytes = 50 * 1024 * 1024;
20
21
  export const maxMetadataBytes = 64 * 1024 * 1024;
21
22
  /** An Agent Channel result carries a read asset of up to 14 MiB. */
22
23
  export const maxChannelResultBytes = 16 * 1024 * 1024;
@@ -221,7 +222,7 @@ export function responseLimit(request: Request) {
221
222
  if ("context" in request && request.operation._tag === "channelExecute") {
222
223
  return maxChannelResultBytes;
223
224
  }
224
- return maxPayloadBytes;
225
+ return maxResponseBytes;
225
226
  }
226
227
 
227
228
  export type Invocation = typeof Invocation.Type;
@@ -255,30 +256,32 @@ export const readBounded = Effect.fnUntraced(function* <E, R>(
255
256
  input: Stream.Stream<Uint8Array, E, R>,
256
257
  maximum = maxPayloadBytes,
257
258
  ) {
258
- const output = { bytes: Buffer.alloc(maximum), size: 0 };
259
- yield* pipe(
259
+ return yield* pipe(
260
260
  input,
261
- Stream.runForEach(chunk =>
262
- Effect.gen(function* () {
263
- if (output.size + chunk.byteLength > maximum) {
264
- return yield* PluginExecutionError.make({
265
- category: "protocol",
266
- message: "Plugin payload exceeds its transport limit",
267
- });
268
- }
269
- Buffer.from(chunk).copy(output.bytes, output.size);
270
- output.size += chunk.byteLength;
271
- }),
272
- ),
273
- Effect.mapError(cause =>
274
- PluginExecutionError.make({
275
- cause: Redacted.make(cause),
276
- category: "protocol",
277
- message: "Cannot read plugin payload",
278
- }),
261
+ Stream.mapAccumEffect(
262
+ () => 0,
263
+ (size, chunk: Uint8Array) =>
264
+ size + chunk.byteLength > maximum
265
+ ? Effect.fail(
266
+ PluginExecutionError.make({
267
+ category: "protocol",
268
+ message: "Plugin payload exceeds its transport limit",
269
+ }),
270
+ )
271
+ : Effect.succeed([size + chunk.byteLength, [chunk]] as const),
279
272
  ),
273
+ Stream.mkUint8Array,
274
+ Effect.mapBoth({
275
+ onSuccess: bytes =>
276
+ Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength).toString("utf8"),
277
+ onFailure: cause =>
278
+ PluginExecutionError.make({
279
+ cause: Redacted.make(cause),
280
+ category: "protocol",
281
+ message: "Cannot read plugin payload",
282
+ }),
283
+ }),
280
284
  );
281
- return output.bytes.toString("utf8", 0, output.size);
282
285
  });
283
286
 
284
287
  export const verifyResponse = Effect.fnUntraced(function* (