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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/README.md +5 -17
  2. package/dist/Action.d.ts +0 -1
  3. package/dist/Action.js +1 -2
  4. package/dist/AgentChannel.d.ts +11 -3
  5. package/dist/AgentChannel.d.ts.map +1 -1
  6. package/dist/AgentChannel.js +31 -5
  7. package/dist/AgentChannel.js.map +1 -1
  8. package/dist/AgentChannelConformance.d.ts +0 -1
  9. package/dist/AgentChannelConformance.js +1 -2
  10. package/dist/AgentChannelRuntime.d.ts +0 -1
  11. package/dist/AgentChannelRuntime.d.ts.map +1 -1
  12. package/dist/AgentChannelRuntime.js +3 -4
  13. package/dist/AgentChannelRuntime.js.map +1 -1
  14. package/dist/AiProvider.d.ts +0 -1
  15. package/dist/AiProvider.js +1 -2
  16. package/dist/AuthMethod.d.ts +0 -1
  17. package/dist/AuthMethod.js +1 -2
  18. package/dist/AuthMethodBinding.d.ts +0 -1
  19. package/dist/AuthMethodBinding.js +1 -2
  20. package/dist/AuthMethodExecution.d.ts +0 -1
  21. package/dist/AuthMethodExecution.js +1 -2
  22. package/dist/ConnectionResolver.d.ts +0 -1
  23. package/dist/ConnectionResolver.js +1 -2
  24. package/dist/DefinitionError.d.ts +0 -1
  25. package/dist/DefinitionError.js +1 -2
  26. package/dist/DualRegistry.d.ts +0 -1
  27. package/dist/DualRegistry.js +1 -2
  28. package/dist/DualRuntime.d.ts +0 -1
  29. package/dist/DualRuntime.js +1 -2
  30. package/dist/Files.d.ts +0 -1
  31. package/dist/Files.js +1 -2
  32. package/dist/Group.d.ts +0 -1
  33. package/dist/Group.js +1 -2
  34. package/dist/Http.d.ts +0 -1
  35. package/dist/Http.d.ts.map +1 -1
  36. package/dist/Http.js +4 -5
  37. package/dist/Http.js.map +1 -1
  38. package/dist/Mcp.d.ts +0 -1
  39. package/dist/Mcp.js +1 -2
  40. package/dist/OAuth2TokenRefresher.d.ts +0 -1
  41. package/dist/OAuth2TokenRefresher.js +1 -2
  42. package/dist/OAuthFlow.d.ts +0 -1
  43. package/dist/OAuthFlow.js +1 -2
  44. package/dist/Plugin.d.ts +0 -1
  45. package/dist/Plugin.js +1 -2
  46. package/dist/PluginRuntime.d.ts +0 -1
  47. package/dist/PluginRuntime.js +1 -2
  48. package/dist/Runner.js +3 -4
  49. package/dist/Runner.js.map +1 -1
  50. package/dist/ToolFile.d.ts +0 -1
  51. package/dist/ToolFile.js +1 -2
  52. package/dist/Trigger.d.ts +0 -1
  53. package/dist/Trigger.js +1 -2
  54. package/dist/_virtual/_rolldown/runtime.js +1 -2
  55. package/dist/internal/auth-context.d.ts +0 -2
  56. package/dist/internal/auth-context.d.ts.map +1 -1
  57. package/dist/internal/auth-execution.d.ts +0 -2
  58. package/dist/internal/auth-execution.d.ts.map +1 -1
  59. package/dist/internal/auth-execution.js +1 -2
  60. package/dist/internal/auth-runtime.d.ts +0 -2
  61. package/dist/internal/auth-runtime.d.ts.map +1 -1
  62. package/dist/internal/auth-runtime.js +1 -2
  63. package/dist/internal/capabilities.d.ts +0 -2
  64. package/dist/internal/capabilities.d.ts.map +1 -1
  65. package/dist/internal/capabilities.js +1 -2
  66. package/dist/internal/children.d.ts +0 -2
  67. package/dist/internal/children.d.ts.map +1 -1
  68. package/dist/internal/children.js +1 -2
  69. package/dist/internal/collection-utils.d.ts +0 -2
  70. package/dist/internal/collection-utils.d.ts.map +1 -1
  71. package/dist/internal/collection-utils.js +1 -2
  72. package/dist/internal/dual/actions.d.ts +0 -2
  73. package/dist/internal/dual/actions.d.ts.map +1 -1
  74. package/dist/internal/dual/actions.js +1 -2
  75. package/dist/internal/dual/invoke.d.ts +0 -2
  76. package/dist/internal/dual/invoke.d.ts.map +1 -1
  77. package/dist/internal/dual/invoke.js +1 -2
  78. package/dist/internal/dual/registry.d.ts +0 -2
  79. package/dist/internal/dual/registry.d.ts.map +1 -1
  80. package/dist/internal/dual/registry.js +1 -2
  81. package/dist/internal/dual/triggers.d.ts +0 -2
  82. package/dist/internal/dual/triggers.d.ts.map +1 -1
  83. package/dist/internal/dual/triggers.js +1 -2
  84. package/dist/internal/handler-context.d.ts +0 -2
  85. package/dist/internal/handler-context.d.ts.map +1 -1
  86. package/dist/internal/handler-context.js +1 -2
  87. package/dist/internal/identifier.d.ts +0 -2
  88. package/dist/internal/identifier.d.ts.map +1 -1
  89. package/dist/internal/identifier.js +1 -2
  90. package/dist/internal/plugin-handlers.d.ts +0 -2
  91. package/dist/internal/plugin-handlers.d.ts.map +1 -1
  92. package/dist/internal/plugin-handlers.js +1 -2
  93. package/dist/internal/proto.d.ts +0 -2
  94. package/dist/internal/proto.d.ts.map +1 -1
  95. package/dist/internal/proto.js +1 -2
  96. package/dist/internal/schema-runtime.d.ts +0 -2
  97. package/dist/internal/schema-runtime.d.ts.map +1 -1
  98. package/dist/internal/schema-runtime.js +1 -2
  99. package/dist/internal/trigger-runtime-shared.d.ts +0 -2
  100. package/dist/internal/trigger-runtime-shared.d.ts.map +1 -1
  101. package/dist/internal/trigger-runtime-shared.js +1 -2
  102. package/dist/internal/trigger-runtime.d.ts +0 -2
  103. package/dist/internal/trigger-runtime.d.ts.map +1 -1
  104. package/dist/internal/trigger-runtime.js +1 -2
  105. package/dist/internal/types.d.ts +0 -2
  106. package/dist/internal/types.d.ts.map +1 -1
  107. package/dist/remote-runtime.d.ts +0 -1
  108. package/dist/remote-runtime.js +1 -2
  109. package/package.json +6 -7
  110. package/src/AgentChannel.ts +30 -2
  111. package/src/AgentChannelRuntime.ts +2 -1
  112. package/src/Http.ts +21 -4
  113. package/src/Runner.ts +5 -4
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/internal/types.ts"],"mappings":";;YAGY,MAAM,uBAAuB;YAE7B,eAAe,oDAAoD;YAInE,WAAW,uBAAuB,6BAA6B,oBACvE,gBACG,gBAAgB,qBAAqB"}
1
+ {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/internal/types.ts"],"mappings":";YAGY,MAAM,uBAAuB;YAE7B,eAAe,oDAAoD;YAInE,WAAW,uBAAuB,6BAA6B,oBACvE,gBACG,gBAAgB,qBAAqB"}
@@ -580,6 +580,5 @@ export declare const execute: (request: {
580
580
  readonly pluginVersion: string;
581
581
  };
582
582
  }, never, Service$1>;
583
- //#endregion
584
583
  export { remote_runtime_d_exports as RemoteRuntime, remote_runtime_d_exports };
585
584
  //# sourceMappingURL=remote-runtime.d.ts.map
@@ -9,7 +9,7 @@ import { File, FileError, Service as Service$2 } from "./Files.js";
9
9
  import "./remote-runtime.js";
10
10
  import { Array, Cause, Effect, Layer, Match, Option, Predicate, Redacted, Schema, flow, pipe } from "effect";
11
11
  import { HttpClient, HttpClientRequest } from "effect/http";
12
- //#region src/remote-runtime.ts
12
+ // src/remote-runtime.ts
13
13
  /**
14
14
  * Data-only SDK lifecycle requests for an installed, isolated integration plugin.
15
15
  *
@@ -361,7 +361,6 @@ const execute = Effect.fn("RemoteRuntime.execute")(function* (request) {
361
361
  identity: request.identity
362
362
  })));
363
363
  });
364
- //#endregion
365
364
  export { Failure, FileAccess, Identity, Operation, remote_runtime_exports as RemoteRuntime, Request, Response, connectionLayer, execute, failure, filesUnavailable, remote_runtime_exports };
366
365
 
367
366
  //# sourceMappingURL=remote-runtime.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dual-os/sdk",
3
- "version": "0.8.0-next.0",
3
+ "version": "0.8.0-next.1",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist/**/*.js",
@@ -42,16 +42,15 @@
42
42
  "./Runner": "./dist/Runner.js"
43
43
  },
44
44
  "scripts": {
45
- "prepack": "vp run build"
45
+ "prepack": "vp run build",
46
+ "typecheck": "tsrs --build tsconfig.json --force --pretty false"
46
47
  },
47
48
  "dependencies": {
48
- "@effect/platform-node": "4.0.6",
49
- "effect": "4.0.6"
49
+ "@effect/platform-node": "4.1.2",
50
+ "effect": "4.1.2"
50
51
  },
51
52
  "devDependencies": {
52
- "@deslop/coding-standards": "0.1.1193",
53
53
  "@types/node": "^22.15.3",
54
- "bun-types": "^1.3.11",
55
- "typescript": "7.0.2"
54
+ "bun-types": "^1.3.11"
56
55
  }
57
56
  }
@@ -116,7 +116,10 @@ const ResponseHeaders = Schema.Record(
116
116
  Object.keys(headers).every(name => name === "content-type" || name === "cache-control"),
117
117
  ),
118
118
  );
119
- /** Bounded provider-required webhook response, returned only after request verification. */
119
+ /**
120
+ * Bounded provider-required webhook response, returned only after request verification. A 204 or
121
+ * 205 response has an empty body.
122
+ */
120
123
  export const WebhookResponse = Schema.Struct({
121
124
  body: Schema.String.check(
122
125
  Schema.isMaxLength(65_536),
@@ -124,7 +127,11 @@ export const WebhookResponse = Schema.Struct({
124
127
  ),
125
128
  headers: Schema.optionalKey(ResponseHeaders),
126
129
  status: Schema.Int.check(Schema.isBetween({ maximum: 299, minimum: 200 })),
127
- });
130
+ }).check(
131
+ Schema.makeFilter(
132
+ response => (response.status !== 204 && response.status !== 205) || response.body === "",
133
+ ),
134
+ );
128
135
  export type WebhookResponse = typeof WebhookResponse.Type;
129
136
  export const Timestamp = Schema.String.check(
130
137
  Schema.isMaxLength(64),
@@ -544,6 +551,27 @@ export type CommandV2<State extends Schema.Top = Schema.Unknown> = ReturnType<
544
551
  export type ResultV2<State extends Schema.Top = Schema.Unknown> = ReturnType<
545
552
  typeof resultSchemaV2<State>
546
553
  >["Type"];
554
+ /** Maximum UTF-8 bytes in an ordinary Channel command or result, including its JSON envelope. */
555
+ export const resultByteLimit = 2_097_152;
556
+ /** Keep the newest context messages within the checked result budget, oldest first. */
557
+ export function contextResult(
558
+ operationKey: string,
559
+ context: readonly ContextMessage[],
560
+ ): Extract<ResultV2, { readonly kind: "read_context" }> {
561
+ const messages: ContextMessage[] = [];
562
+ const result = { kind: "read_context" as const, messages, operationKey };
563
+ const encoder = new TextEncoder();
564
+ let bytes = encoder.encode(JSON.stringify(result)).byteLength;
565
+ for (let index = context.length - 1; index >= 0; index--) {
566
+ const message = context[index];
567
+ if (message === undefined) continue;
568
+ const size = encoder.encode(JSON.stringify(message)).byteLength + 1;
569
+ if (bytes + size > resultByteLimit) break;
570
+ bytes += size;
571
+ messages.unshift(message);
572
+ }
573
+ return result;
574
+ }
547
575
  /** The command and result schemas of a Channel's protocol. */
548
576
  export const schemasFor = (definition: Pick<Definition, "protocol" | "state">) =>
549
577
  definition.protocol === "v2"
@@ -105,7 +105,8 @@ const AssetResultJson = Schema.Json.check(
105
105
  );
106
106
  const Json = Schema.Json.check(
107
107
  Schema.makeFilter(
108
- value => new TextEncoder().encode(JSON.stringify(value)).byteLength <= 2_097_152,
108
+ value =>
109
+ new TextEncoder().encode(JSON.stringify(value)).byteLength <= AgentChannel.resultByteLimit,
109
110
  ),
110
111
  );
111
112
  const strict = { onExcessProperty: "error" } as const;
package/src/Http.ts CHANGED
@@ -32,6 +32,8 @@ import {
32
32
  HttpClient,
33
33
  HttpClientError,
34
34
  HttpClientRequest,
35
+ Headers,
36
+ UrlParams,
35
37
  } from "effect/http";
36
38
  import type { HttpClientResponse } from "effect/http";
37
39
 
@@ -661,9 +663,14 @@ export function continuation(request: HttpClientRequest.HttpClientRequest, nextL
661
663
  return refused("A continuation URL must be an HTTPS link to the same operation path");
662
664
  }
663
665
  return Effect.succeed(
664
- HttpClientRequest.make(request.method)(`${declared.origin}${next.pathname}${next.search}`, {
665
- headers: request.headers,
666
- }),
666
+ HttpClientRequest.makeWith(
667
+ request.method,
668
+ `${declared.origin}${next.pathname}${next.search}`,
669
+ UrlParams.empty,
670
+ Option.none(),
671
+ request.headers,
672
+ HttpBody.empty,
673
+ ),
667
674
  );
668
675
  }
669
676
 
@@ -707,7 +714,17 @@ function redirect(response: HttpClientResponse.HttpClientResponse) {
707
714
  : sent;
708
715
  return url.origin === new URL(sent.url).origin
709
716
  ? HttpClientRequest.setUrl(request, url)
710
- : HttpClientRequest.make(request.method)(url, { body: request.body });
717
+ : HttpClientRequest.setUrl(
718
+ HttpClientRequest.makeWith(
719
+ request.method,
720
+ "",
721
+ UrlParams.empty,
722
+ Option.none(),
723
+ Headers.empty,
724
+ request.body,
725
+ ),
726
+ url,
727
+ );
711
728
  }
712
729
 
713
730
  function follow(
package/src/Runner.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { NodeRuntime, NodeServices } from "@effect/platform-node";
1
+ import { NodeCrypto, NodeRuntime, NodeServices } from "@effect/platform-node";
2
2
 
3
3
  import {
4
4
  Array,
@@ -60,7 +60,9 @@ function initializationError(cause: unknown) {
60
60
  // This executable runs only in the plugin's process, using its own SDK and Effect.
61
61
  pipe(
62
62
  Effect.gen(function* () {
63
- const guestServices = yield* Effect.context<NodeServices.NodeServices>();
63
+ const guestServices = yield* Effect.context<
64
+ NodeServices.NodeServices | Layer.Success<typeof NodeCrypto.layer>
65
+ >();
64
66
  const scope = yield* Scope.Scope;
65
67
  const runtimeScope = yield* Scope.fork(scope, "sequential");
66
68
  const failed = yield* Deferred.make<never, PluginRuntime.PluginExecutionError>();
@@ -242,7 +244,6 @@ pipe(
242
244
  );
243
245
  }),
244
246
  Effect.scoped,
245
- // @effect-diagnostics-next-line strictEffectProvide:off -- This executable owns the guest process services.
246
- Effect.provide(NodeServices.layer),
247
+ Effect.provide([NodeServices.layer, NodeCrypto.layer]),
247
248
  NodeRuntime.runMain({ disableErrorReporting: process.argv[4] !== "inspect" }),
248
249
  );