@dual-os/sdk 0.0.0-stage → 0.8.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -0
- package/README.md +19 -2
- package/dist/Action.d.ts +201 -0
- package/dist/Action.d.ts.map +1 -0
- package/dist/Action.js +172 -0
- package/dist/Action.js.map +1 -0
- package/dist/AgentChannel.d.ts +1717 -0
- package/dist/AgentChannel.d.ts.map +1 -0
- package/dist/AgentChannel.js +708 -0
- package/dist/AgentChannel.js.map +1 -0
- package/dist/AgentChannelConformance.d.ts +1543 -0
- package/dist/AgentChannelConformance.d.ts.map +1 -0
- package/dist/AgentChannelConformance.js +163 -0
- package/dist/AgentChannelConformance.js.map +1 -0
- package/dist/AgentChannelRuntime.d.ts +78 -0
- package/dist/AgentChannelRuntime.d.ts.map +1 -0
- package/dist/AgentChannelRuntime.js +270 -0
- package/dist/AgentChannelRuntime.js.map +1 -0
- package/dist/AiProvider.d.ts +132 -0
- package/dist/AiProvider.d.ts.map +1 -0
- package/dist/AiProvider.js +100 -0
- package/dist/AiProvider.js.map +1 -0
- package/dist/AuthMethod.d.ts +381 -0
- package/dist/AuthMethod.d.ts.map +1 -0
- package/dist/AuthMethod.js +225 -0
- package/dist/AuthMethod.js.map +1 -0
- package/dist/AuthMethodBinding.d.ts +77 -0
- package/dist/AuthMethodBinding.d.ts.map +1 -0
- package/dist/AuthMethodBinding.js +31 -0
- package/dist/AuthMethodBinding.js.map +1 -0
- package/dist/AuthMethodExecution.d.ts +223 -0
- package/dist/AuthMethodExecution.d.ts.map +1 -0
- package/dist/AuthMethodExecution.js +277 -0
- package/dist/AuthMethodExecution.js.map +1 -0
- package/dist/ConnectionResolver.d.ts +219 -0
- package/dist/ConnectionResolver.d.ts.map +1 -0
- package/dist/ConnectionResolver.js +153 -0
- package/dist/ConnectionResolver.js.map +1 -0
- package/dist/DefinitionError.d.ts +67 -0
- package/dist/DefinitionError.d.ts.map +1 -0
- package/dist/DefinitionError.js +82 -0
- package/dist/DefinitionError.js.map +1 -0
- package/dist/DualRegistry.d.ts +71 -0
- package/dist/DualRegistry.d.ts.map +1 -0
- package/dist/DualRegistry.js +96 -0
- package/dist/DualRegistry.js.map +1 -0
- package/dist/DualRuntime.d.ts +279 -0
- package/dist/DualRuntime.d.ts.map +1 -0
- package/dist/DualRuntime.js +311 -0
- package/dist/DualRuntime.js.map +1 -0
- package/dist/Files.d.ts +80 -0
- package/dist/Files.d.ts.map +1 -0
- package/dist/Files.js +66 -0
- package/dist/Files.js.map +1 -0
- package/dist/Group.d.ts +106 -0
- package/dist/Group.d.ts.map +1 -0
- package/dist/Group.js +86 -0
- package/dist/Group.js.map +1 -0
- package/dist/Http.d.ts +342 -0
- package/dist/Http.d.ts.map +1 -0
- package/dist/Http.js +677 -0
- package/dist/Http.js.map +1 -0
- package/dist/Mcp.d.ts +109 -0
- package/dist/Mcp.d.ts.map +1 -0
- package/dist/Mcp.js +176 -0
- package/dist/Mcp.js.map +1 -0
- package/dist/OAuth2TokenRefresher.d.ts +18 -0
- package/dist/OAuth2TokenRefresher.d.ts.map +1 -0
- package/dist/OAuth2TokenRefresher.js +19 -0
- package/dist/OAuth2TokenRefresher.js.map +1 -0
- package/dist/OAuthFlow.d.ts +71 -0
- package/dist/OAuthFlow.d.ts.map +1 -0
- package/dist/OAuthFlow.js +488 -0
- package/dist/OAuthFlow.js.map +1 -0
- package/dist/Plugin.d.ts +383 -0
- package/dist/Plugin.d.ts.map +1 -0
- package/dist/Plugin.js +249 -0
- package/dist/Plugin.js.map +1 -0
- package/dist/PluginRuntime.d.ts +3186 -0
- package/dist/PluginRuntime.d.ts.map +1 -0
- package/dist/PluginRuntime.js +331 -0
- package/dist/PluginRuntime.js.map +1 -0
- package/dist/Runner.d.ts +1 -0
- package/dist/Runner.js +124 -0
- package/dist/Runner.js.map +1 -0
- package/dist/ToolFile.d.ts +23 -0
- package/dist/ToolFile.d.ts.map +1 -0
- package/dist/ToolFile.js +33 -0
- package/dist/ToolFile.js.map +1 -0
- package/dist/Trigger.d.ts +358 -0
- package/dist/Trigger.d.ts.map +1 -0
- package/dist/Trigger.js +287 -0
- package/dist/Trigger.js.map +1 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +24 -0
- package/dist/internal/auth-context.d.ts +23 -0
- package/dist/internal/auth-context.d.ts.map +1 -0
- package/dist/internal/auth-context.js +1 -0
- package/dist/internal/auth-execution.d.ts +27 -0
- package/dist/internal/auth-execution.d.ts.map +1 -0
- package/dist/internal/auth-execution.js +66 -0
- package/dist/internal/auth-execution.js.map +1 -0
- package/dist/internal/auth-runtime.d.ts +5 -0
- package/dist/internal/auth-runtime.d.ts.map +1 -0
- package/dist/internal/auth-runtime.js +16 -0
- package/dist/internal/auth-runtime.js.map +1 -0
- package/dist/internal/capabilities.d.ts +24 -0
- package/dist/internal/capabilities.d.ts.map +1 -0
- package/dist/internal/capabilities.js +22 -0
- package/dist/internal/capabilities.js.map +1 -0
- package/dist/internal/children.d.ts +34 -0
- package/dist/internal/children.d.ts.map +1 -0
- package/dist/internal/children.js +53 -0
- package/dist/internal/children.js.map +1 -0
- package/dist/internal/collection-utils.d.ts +4 -0
- package/dist/internal/collection-utils.d.ts.map +1 -0
- package/dist/internal/collection-utils.js +6 -0
- package/dist/internal/collection-utils.js.map +1 -0
- package/dist/internal/dual/actions.d.ts +33 -0
- package/dist/internal/dual/actions.d.ts.map +1 -0
- package/dist/internal/dual/actions.js +26 -0
- package/dist/internal/dual/actions.js.map +1 -0
- package/dist/internal/dual/invoke.d.ts +63 -0
- package/dist/internal/dual/invoke.d.ts.map +1 -0
- package/dist/internal/dual/invoke.js +75 -0
- package/dist/internal/dual/invoke.js.map +1 -0
- package/dist/internal/dual/registry.d.ts +125 -0
- package/dist/internal/dual/registry.d.ts.map +1 -0
- package/dist/internal/dual/registry.js +172 -0
- package/dist/internal/dual/registry.js.map +1 -0
- package/dist/internal/dual/triggers.d.ts +29 -0
- package/dist/internal/dual/triggers.d.ts.map +1 -0
- package/dist/internal/dual/triggers.js +26 -0
- package/dist/internal/dual/triggers.js.map +1 -0
- package/dist/internal/handler-context.d.ts +9 -0
- package/dist/internal/handler-context.d.ts.map +1 -0
- package/dist/internal/handler-context.js +31 -0
- package/dist/internal/handler-context.js.map +1 -0
- package/dist/internal/identifier.d.ts +6 -0
- package/dist/internal/identifier.d.ts.map +1 -0
- package/dist/internal/identifier.js +28 -0
- package/dist/internal/identifier.js.map +1 -0
- package/dist/internal/plugin-handlers.d.ts +38 -0
- package/dist/internal/plugin-handlers.d.ts.map +1 -0
- package/dist/internal/plugin-handlers.js +52 -0
- package/dist/internal/plugin-handlers.js.map +1 -0
- package/dist/internal/proto.d.ts +7 -0
- package/dist/internal/proto.d.ts.map +1 -0
- package/dist/internal/proto.js +10 -0
- package/dist/internal/proto.js.map +1 -0
- package/dist/internal/schema-runtime.d.ts +6 -0
- package/dist/internal/schema-runtime.d.ts.map +1 -0
- package/dist/internal/schema-runtime.js +10 -0
- package/dist/internal/schema-runtime.js.map +1 -0
- package/dist/internal/trigger-runtime-shared.d.ts +41 -0
- package/dist/internal/trigger-runtime-shared.d.ts.map +1 -0
- package/dist/internal/trigger-runtime-shared.js +132 -0
- package/dist/internal/trigger-runtime-shared.js.map +1 -0
- package/dist/internal/trigger-runtime.d.ts +12 -0
- package/dist/internal/trigger-runtime.d.ts.map +1 -0
- package/dist/internal/trigger-runtime.js +95 -0
- package/dist/internal/trigger-runtime.js.map +1 -0
- package/dist/internal/types.d.ts +7 -0
- package/dist/internal/types.d.ts.map +1 -0
- package/dist/internal/types.js +1 -0
- package/dist/remote-runtime.d.ts +585 -0
- package/dist/remote-runtime.d.ts.map +1 -0
- package/dist/remote-runtime.js +367 -0
- package/dist/remote-runtime.js.map +1 -0
- package/package.json +55 -4
- package/src/Action.ts +370 -0
- package/src/AgentChannel.ts +860 -0
- package/src/AgentChannelConformance.ts +124 -0
- package/src/AgentChannelRuntime.ts +616 -0
- package/src/AiProvider.ts +255 -0
- package/src/AuthMethod.ts +954 -0
- package/src/AuthMethodBinding.ts +112 -0
- package/src/AuthMethodExecution.ts +542 -0
- package/src/ConnectionResolver.ts +265 -0
- package/src/DefinitionError.ts +115 -0
- package/src/DualRegistry.ts +152 -0
- package/src/DualRuntime.ts +1081 -0
- package/src/Files.ts +89 -0
- package/src/Group.ts +292 -0
- package/src/Http.ts +1205 -0
- package/src/Mcp.ts +299 -0
- package/src/OAuth2TokenRefresher.ts +22 -0
- package/src/OAuthFlow.ts +874 -0
- package/src/Plugin.ts +912 -0
- package/src/PluginRuntime.ts +414 -0
- package/src/Runner.ts +248 -0
- package/src/ToolFile.ts +28 -0
- package/src/Trigger.ts +722 -0
- package/src/index.ts +158 -0
- package/src/internal/auth-context.ts +27 -0
- package/src/internal/auth-execution.ts +241 -0
- package/src/internal/auth-runtime.ts +20 -0
- package/src/internal/capabilities.ts +55 -0
- package/src/internal/children.ts +126 -0
- package/src/internal/collection-utils.ts +8 -0
- package/src/internal/dual/actions.ts +116 -0
- package/src/internal/dual/invoke.ts +307 -0
- package/src/internal/dual/registry.ts +340 -0
- package/src/internal/dual/triggers.ts +128 -0
- package/src/internal/handler-context.ts +57 -0
- package/src/internal/identifier.ts +27 -0
- package/src/internal/plugin-handlers.ts +146 -0
- package/src/internal/proto.ts +8 -0
- package/src/internal/schema-runtime.ts +15 -0
- package/src/internal/trigger-runtime-shared.ts +449 -0
- package/src/internal/trigger-runtime.ts +223 -0
- package/src/internal/types.ts +12 -0
- package/src/remote-runtime.ts +469 -0
|
@@ -0,0 +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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jCG,UAAAC"}
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { JsonRequest } from "./AuthMethodExecution.js";
|
|
3
|
+
import { Service } from "./DualRuntime.js";
|
|
4
|
+
import { OAuthGrantRejected, Service as Service$1 } from "./OAuthFlow.js";
|
|
5
|
+
import { Identity, Request as Request$1, Response, execute as execute$1, failure } from "./remote-runtime.js";
|
|
6
|
+
import "./PluginRuntime.js";
|
|
7
|
+
import { Cause, Effect, Queue, Redacted, Schema, Stream, pipe } from "effect";
|
|
8
|
+
import { HttpClientRequest } from "effect/http";
|
|
9
|
+
//#region src/PluginRuntime.ts
|
|
10
|
+
var PluginRuntime_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
+
AuthRequest: () => AuthRequest,
|
|
12
|
+
ChannelSettingsRequest: () => ChannelSettingsRequest,
|
|
13
|
+
ExecutionRequest: () => ExecutionRequest,
|
|
14
|
+
Input: () => Input,
|
|
15
|
+
Invocation: () => Invocation,
|
|
16
|
+
OAuthContinuation: () => OAuthContinuation,
|
|
17
|
+
OAuthStarted: () => OAuthStarted,
|
|
18
|
+
Output: () => Output,
|
|
19
|
+
PluginExecutionError: () => PluginExecutionError,
|
|
20
|
+
PluginRuntime: () => PluginRuntime_exports,
|
|
21
|
+
Request: () => Request,
|
|
22
|
+
SandboxAccessResult: () => SandboxAccessResult,
|
|
23
|
+
cancellationTimeout: () => cancellationTimeout,
|
|
24
|
+
checkMessageSize: () => checkMessageSize,
|
|
25
|
+
decodeInput: () => decodeInput,
|
|
26
|
+
decodeOutput: () => decodeOutput,
|
|
27
|
+
encodeInput: () => encodeInput,
|
|
28
|
+
encodeOutput: () => encodeOutput,
|
|
29
|
+
encodeRequest: () => encodeRequest,
|
|
30
|
+
execute: () => execute,
|
|
31
|
+
ipcMessages: () => ipcMessages,
|
|
32
|
+
maxChannelResultBytes: () => maxChannelResultBytes,
|
|
33
|
+
maxMetadataBytes: () => maxMetadataBytes,
|
|
34
|
+
maxPayloadBytes: () => maxPayloadBytes,
|
|
35
|
+
readBounded: () => readBounded,
|
|
36
|
+
responseLimit: () => responseLimit,
|
|
37
|
+
sendIpc: () => sendIpc,
|
|
38
|
+
verifyResponse: () => verifyResponse
|
|
39
|
+
});
|
|
40
|
+
var PluginExecutionError = class extends Schema.TaggedError()("PluginExecutionError", {
|
|
41
|
+
category: Schema.Literals([
|
|
42
|
+
"transport",
|
|
43
|
+
"runner",
|
|
44
|
+
"protocol",
|
|
45
|
+
"cleanup",
|
|
46
|
+
"artifact-expired"
|
|
47
|
+
]),
|
|
48
|
+
cause: Schema.optionalKey(Schema.Redacted(Schema.Defect())),
|
|
49
|
+
message: Schema.String
|
|
50
|
+
}) {};
|
|
51
|
+
const maxPayloadBytes = 1048576;
|
|
52
|
+
const maxMetadataBytes = 67108864;
|
|
53
|
+
/** An Agent Channel result carries a read asset of up to 14 MiB. */
|
|
54
|
+
const maxChannelResultBytes = 16777216;
|
|
55
|
+
const cancellationTimeout = "5 seconds";
|
|
56
|
+
/** Receive native Node and Bun IPC messages without interpreting plugin logs. */
|
|
57
|
+
function ipcMessages(channel) {
|
|
58
|
+
return Stream.callback((queue) => {
|
|
59
|
+
const message = (value) => {
|
|
60
|
+
Queue.offerUnsafe(queue, value);
|
|
61
|
+
};
|
|
62
|
+
const disconnected = () => {
|
|
63
|
+
Queue.endUnsafe(queue);
|
|
64
|
+
};
|
|
65
|
+
const failed = (cause) => {
|
|
66
|
+
Queue.failCauseUnsafe(queue, Cause.fail(PluginExecutionError.make({
|
|
67
|
+
category: "runner",
|
|
68
|
+
cause: Redacted.make(cause),
|
|
69
|
+
message: "Plugin IPC channel failed"
|
|
70
|
+
})));
|
|
71
|
+
};
|
|
72
|
+
return Effect.acquireRelease(Effect.sync(() => {
|
|
73
|
+
channel.on("message", message);
|
|
74
|
+
channel.on("disconnect", disconnected);
|
|
75
|
+
channel.on("error", failed);
|
|
76
|
+
}), () => Effect.sync(() => {
|
|
77
|
+
channel.removeListener("message", message);
|
|
78
|
+
channel.removeListener("disconnect", disconnected);
|
|
79
|
+
channel.removeListener("error", failed);
|
|
80
|
+
}));
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/** Queue a JSON message; the runtime reports asynchronous send failures through its error event. */
|
|
84
|
+
function sendIpc(channel, value) {
|
|
85
|
+
return Effect.try({
|
|
86
|
+
try: () => {
|
|
87
|
+
if (!channel.connected || channel.send === void 0) throw PluginExecutionError.make({
|
|
88
|
+
category: "runner",
|
|
89
|
+
message: "Plugin IPC channel is closed"
|
|
90
|
+
});
|
|
91
|
+
channel.send(value);
|
|
92
|
+
},
|
|
93
|
+
catch: (cause) => PluginExecutionError.make({
|
|
94
|
+
category: "runner",
|
|
95
|
+
cause: Redacted.make(cause),
|
|
96
|
+
message: "Cannot send plugin IPC message"
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
const OAuthContinuation = Schema.Struct({
|
|
101
|
+
expiresAt: Schema.DateFromString,
|
|
102
|
+
pkceVerifier: Schema.NullOr(Schema.String),
|
|
103
|
+
redirectUri: Schema.String,
|
|
104
|
+
state: Schema.String
|
|
105
|
+
});
|
|
106
|
+
const OAuthStarted = Schema.Struct({
|
|
107
|
+
authorizationUrl: Schema.String,
|
|
108
|
+
continuation: OAuthContinuation
|
|
109
|
+
});
|
|
110
|
+
const oauth = {
|
|
111
|
+
authMethodId: Schema.NonEmptyString,
|
|
112
|
+
providerId: Schema.NonEmptyString,
|
|
113
|
+
setup: Schema.optionalKey(Schema.Json)
|
|
114
|
+
};
|
|
115
|
+
const SandboxAccessResult = Schema.Struct({
|
|
116
|
+
headers: Schema.optionalKey(Schema.Record(Schema.String, Schema.String)),
|
|
117
|
+
origins: Schema.Array(Schema.String)
|
|
118
|
+
});
|
|
119
|
+
const AuthRequest = Schema.TaggedStruct("auth", {
|
|
120
|
+
identity: Identity,
|
|
121
|
+
operation: Schema.Union([
|
|
122
|
+
JsonRequest,
|
|
123
|
+
Schema.TaggedStruct("oauthStart", {
|
|
124
|
+
...oauth,
|
|
125
|
+
redirectUri: Schema.String
|
|
126
|
+
}),
|
|
127
|
+
Schema.TaggedStruct("oauthComplete", {
|
|
128
|
+
...oauth,
|
|
129
|
+
continuation: OAuthContinuation,
|
|
130
|
+
query: Schema.Record(Schema.String, Schema.String)
|
|
131
|
+
}),
|
|
132
|
+
Schema.TaggedStruct("sandboxAccess", {
|
|
133
|
+
...oauth,
|
|
134
|
+
material: Schema.Json,
|
|
135
|
+
request: Schema.optionalKey(Schema.Struct({
|
|
136
|
+
headers: Schema.Record(Schema.String, Schema.String),
|
|
137
|
+
method: Schema.Literals([
|
|
138
|
+
"GET",
|
|
139
|
+
"POST",
|
|
140
|
+
"PUT",
|
|
141
|
+
"DELETE",
|
|
142
|
+
"PATCH",
|
|
143
|
+
"HEAD",
|
|
144
|
+
"OPTIONS",
|
|
145
|
+
"TRACE",
|
|
146
|
+
"QUERY"
|
|
147
|
+
]),
|
|
148
|
+
url: Schema.String
|
|
149
|
+
}))
|
|
150
|
+
})
|
|
151
|
+
])
|
|
152
|
+
});
|
|
153
|
+
const ChannelSettingsRequest = Schema.TaggedStruct("channelSettings", {
|
|
154
|
+
identity: Identity,
|
|
155
|
+
operation: Schema.TaggedStruct("decodeChannelSettings", {
|
|
156
|
+
channelId: Schema.NonEmptyString,
|
|
157
|
+
field: Schema.Literals(["definitionSettings", "deploymentSettings"]),
|
|
158
|
+
value: Schema.Json
|
|
159
|
+
})
|
|
160
|
+
});
|
|
161
|
+
const ExecutionRequest = Schema.Union([
|
|
162
|
+
Request$1,
|
|
163
|
+
AuthRequest,
|
|
164
|
+
ChannelSettingsRequest
|
|
165
|
+
]);
|
|
166
|
+
const Request = Schema.Union([ExecutionRequest, Schema.TaggedStruct("extract", { identity: Identity })]);
|
|
167
|
+
const Input = Schema.Union([Request, Schema.TaggedStruct("cancel", { identity: Identity })]);
|
|
168
|
+
const Output = Schema.Union([Response, Schema.TaggedStruct("interrupted", { identity: Identity })]);
|
|
169
|
+
function checkMessageSize(value, maximum) {
|
|
170
|
+
if (new TextEncoder().encode(JSON.stringify(value)).byteLength <= maximum) return Effect.void;
|
|
171
|
+
return Effect.fail(PluginExecutionError.make({
|
|
172
|
+
category: "protocol",
|
|
173
|
+
message: "Plugin message exceeds its transport limit"
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
const encodeInput = Effect.fnUntraced(function* (input) {
|
|
177
|
+
const encoded = yield* Schema.encodeEffect(Input)(input);
|
|
178
|
+
yield* checkMessageSize(encoded, maxPayloadBytes);
|
|
179
|
+
return encoded;
|
|
180
|
+
});
|
|
181
|
+
const decodeInput = Effect.fnUntraced(function* (input) {
|
|
182
|
+
const json = yield* Schema.decodeUnknownEffect(Schema.Json)(input);
|
|
183
|
+
yield* checkMessageSize(json, maxPayloadBytes);
|
|
184
|
+
return yield* Schema.decodeUnknownEffect(Input)(json);
|
|
185
|
+
});
|
|
186
|
+
const encodeOutput = Effect.fnUntraced(function* (output, maximum) {
|
|
187
|
+
const encoded = yield* Schema.encodeEffect(Output)(output);
|
|
188
|
+
yield* checkMessageSize(encoded, maximum);
|
|
189
|
+
return encoded;
|
|
190
|
+
});
|
|
191
|
+
const decodeOutput = Effect.fnUntraced(function* (output) {
|
|
192
|
+
const json = yield* Schema.decodeUnknownEffect(Schema.Json)(output);
|
|
193
|
+
yield* checkMessageSize(json, maxMetadataBytes);
|
|
194
|
+
return yield* Schema.decodeUnknownEffect(Output)(json);
|
|
195
|
+
});
|
|
196
|
+
function responseLimit(request) {
|
|
197
|
+
if ("_tag" in request && request._tag === "extract") return maxMetadataBytes;
|
|
198
|
+
if ("context" in request && request.operation._tag === "channelExecute") return maxChannelResultBytes;
|
|
199
|
+
return maxPayloadBytes;
|
|
200
|
+
}
|
|
201
|
+
const Invocation = Schema.Struct({
|
|
202
|
+
entrypoint: Schema.String.check(Schema.isPattern(/^[A-Za-z0-9_-]+(?:[./][A-Za-z0-9_-]+)*$/u)),
|
|
203
|
+
exportName: Schema.String.check(Schema.isPattern(/^[A-Za-z_$][A-Za-z0-9_$]*$/u)),
|
|
204
|
+
request: Request
|
|
205
|
+
});
|
|
206
|
+
const encodeRequest = Effect.fnUntraced(function* (request) {
|
|
207
|
+
const encoded = yield* pipe(Schema.encodeEffect(Schema.fromJsonString(Request))(request), Effect.mapError((cause) => PluginExecutionError.make({
|
|
208
|
+
cause: Redacted.make(cause),
|
|
209
|
+
category: "protocol",
|
|
210
|
+
message: "Invalid plugin request"
|
|
211
|
+
})));
|
|
212
|
+
if (new TextEncoder().encode(encoded).byteLength > 1048576) return yield* PluginExecutionError.make({
|
|
213
|
+
category: "protocol",
|
|
214
|
+
message: "Plugin request exceeds the 1 MiB transport limit"
|
|
215
|
+
});
|
|
216
|
+
return encoded;
|
|
217
|
+
});
|
|
218
|
+
const readBounded = Effect.fnUntraced(function* (input, maximum = maxPayloadBytes) {
|
|
219
|
+
const output = {
|
|
220
|
+
bytes: Buffer.alloc(maximum),
|
|
221
|
+
size: 0
|
|
222
|
+
};
|
|
223
|
+
yield* pipe(input, Stream.runForEach((chunk) => Effect.gen(function* () {
|
|
224
|
+
if (output.size + chunk.byteLength > maximum) return yield* PluginExecutionError.make({
|
|
225
|
+
category: "protocol",
|
|
226
|
+
message: "Plugin payload exceeds its transport limit"
|
|
227
|
+
});
|
|
228
|
+
Buffer.from(chunk).copy(output.bytes, output.size);
|
|
229
|
+
output.size += chunk.byteLength;
|
|
230
|
+
})), Effect.mapError((cause) => PluginExecutionError.make({
|
|
231
|
+
cause: Redacted.make(cause),
|
|
232
|
+
category: "protocol",
|
|
233
|
+
message: "Cannot read plugin payload"
|
|
234
|
+
})));
|
|
235
|
+
return output.bytes.toString("utf8", 0, output.size);
|
|
236
|
+
});
|
|
237
|
+
const verifyResponse = Effect.fnUntraced(function* (request, response) {
|
|
238
|
+
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({
|
|
239
|
+
category: "protocol",
|
|
240
|
+
message: "Plugin result does not match its invocation"
|
|
241
|
+
});
|
|
242
|
+
return response;
|
|
243
|
+
});
|
|
244
|
+
const executeAuth = Effect.fnUntraced(function* (request) {
|
|
245
|
+
const operation = request.operation;
|
|
246
|
+
const runtime = yield* Service;
|
|
247
|
+
if (operation._tag === "sandboxAccess") {
|
|
248
|
+
const access = yield* runtime.resolveSandboxAccess({
|
|
249
|
+
...operation,
|
|
250
|
+
encoding: "json",
|
|
251
|
+
setup: operation.setup
|
|
252
|
+
});
|
|
253
|
+
if (operation.request === void 0) return yield* Schema.encodeEffect(SandboxAccessResult)({ origins: access.origins });
|
|
254
|
+
const authorized = yield* access.authorize(HttpClientRequest.make(operation.request.method)(operation.request.url, { headers: operation.request.headers }));
|
|
255
|
+
return yield* Schema.encodeEffect(SandboxAccessResult)({
|
|
256
|
+
headers: authorized.headers,
|
|
257
|
+
origins: access.origins
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
if (operation._tag !== "oauthStart" && operation._tag !== "oauthComplete") return yield* runtime.executeAuthJson(operation);
|
|
261
|
+
const method = yield* runtime.getAuthMethod(operation);
|
|
262
|
+
const setup = yield* runtime.decodeAuthMethodSetup({
|
|
263
|
+
...operation,
|
|
264
|
+
encoding: "json",
|
|
265
|
+
setup: operation.setup
|
|
266
|
+
});
|
|
267
|
+
const oauth = yield* Service$1;
|
|
268
|
+
if (operation._tag === "oauthStart") return yield* Schema.encodeEffect(OAuthStarted)(yield* oauth.start({
|
|
269
|
+
method,
|
|
270
|
+
redirectUri: operation.redirectUri,
|
|
271
|
+
setup
|
|
272
|
+
}));
|
|
273
|
+
const completed = yield* oauth.complete({
|
|
274
|
+
...operation,
|
|
275
|
+
method,
|
|
276
|
+
setup
|
|
277
|
+
});
|
|
278
|
+
return yield* runtime.executeAuthJson(yield* Schema.decodeUnknownEffect(JsonRequest)({
|
|
279
|
+
...operation,
|
|
280
|
+
_tag: "prepareOAuth2Tokens",
|
|
281
|
+
tokens: completed.tokens
|
|
282
|
+
}));
|
|
283
|
+
}, (effect, request) => pipe(effect, Effect.flatMap(Effect.fnUntraced(function* (value) {
|
|
284
|
+
const result = {
|
|
285
|
+
_tag: "success",
|
|
286
|
+
identity: request.identity
|
|
287
|
+
};
|
|
288
|
+
if (value === void 0) return result;
|
|
289
|
+
return {
|
|
290
|
+
...result,
|
|
291
|
+
value: yield* Schema.decodeUnknownEffect(Schema.Json)(value)
|
|
292
|
+
};
|
|
293
|
+
})), Effect.catch((error) => {
|
|
294
|
+
const cause = error._tag === "AuthMethodHookError" ? error.cause : error;
|
|
295
|
+
return Effect.succeed({
|
|
296
|
+
_tag: "failure",
|
|
297
|
+
error: {
|
|
298
|
+
...failure(error),
|
|
299
|
+
...Schema.is(OAuthGrantRejected)(cause) ? { code: "OAuthGrantRejected" } : {}
|
|
300
|
+
},
|
|
301
|
+
identity: request.identity
|
|
302
|
+
});
|
|
303
|
+
})));
|
|
304
|
+
const executeChannelSettings = Effect.fnUntraced(function* (request) {
|
|
305
|
+
const runtime = yield* Service;
|
|
306
|
+
const { channelId, field, value } = request.operation;
|
|
307
|
+
const input = {
|
|
308
|
+
channelId,
|
|
309
|
+
value
|
|
310
|
+
};
|
|
311
|
+
if (field === "definitionSettings") return yield* runtime.decodeAgentChannelDefinitionSettings(input);
|
|
312
|
+
return yield* runtime.decodeAgentChannelDeploymentSettings(input);
|
|
313
|
+
}, (effect, request) => pipe(effect, Effect.map((value) => ({
|
|
314
|
+
_tag: "success",
|
|
315
|
+
identity: request.identity,
|
|
316
|
+
value
|
|
317
|
+
})), Effect.catch((error) => Effect.succeed({
|
|
318
|
+
_tag: "failure",
|
|
319
|
+
error: failure(error),
|
|
320
|
+
identity: request.identity
|
|
321
|
+
}))));
|
|
322
|
+
/** Execute one request against the plugin built in this process; only the guest runner calls it in production. */
|
|
323
|
+
const execute = Effect.fnUntraced(function* (request) {
|
|
324
|
+
if (!("_tag" in request)) return yield* execute$1(request);
|
|
325
|
+
if (request._tag === "auth") return yield* executeAuth(request);
|
|
326
|
+
return yield* executeChannelSettings(request);
|
|
327
|
+
});
|
|
328
|
+
//#endregion
|
|
329
|
+
export { AuthRequest, ChannelSettingsRequest, ExecutionRequest, Input, Invocation, OAuthContinuation, OAuthStarted, Output, 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 };
|
|
330
|
+
|
|
331
|
+
//# sourceMappingURL=PluginRuntime.js.map
|
|
@@ -0,0 +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,OAAO,UAAwC,UAAS;EAC7D,MAAM,WAAW,UAAmB;GAClC,MAAM,YAAY,OAAO,KAAK;EAChC;EACA,MAAM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@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/dist/Runner.js
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { materializePlugin } from "./DualRegistry.js";
|
|
2
|
+
import { fromPlugin, toLayer } from "./DualRuntime.js";
|
|
3
|
+
import { layer, oauth2TokenRefresherLayer } from "./OAuthFlow.js";
|
|
4
|
+
import { isPlugin, make } from "./Plugin.js";
|
|
5
|
+
import { Identity, filesUnavailable } from "./remote-runtime.js";
|
|
6
|
+
import { PluginExecutionError, decodeInput, encodeOutput, execute, ipcMessages, responseLimit, sendIpc } from "./PluginRuntime.js";
|
|
7
|
+
import { Array, Cause, ConfigProvider, Context, Deferred, Effect, Exit, Fiber, FiberMap, Formatter, Inspectable, Layer, Match, Option, Predicate, Redacted, Schema, Scope, Stdio, Stream, String, pipe } from "effect";
|
|
8
|
+
import { FetchHttpClient } from "effect/http";
|
|
9
|
+
import { NodeRuntime, NodeServices } from "@effect/platform-node";
|
|
10
|
+
//#region src/Runner.ts
|
|
11
|
+
const guestOAuth = pipe(oauth2TokenRefresherLayer, Layer.provideMerge(layer), Layer.provide(ConfigProvider.layer(ConfigProvider.fromUnknown({}))));
|
|
12
|
+
function initializationError(cause) {
|
|
13
|
+
if (Schema.is(PluginExecutionError)(cause)) return cause;
|
|
14
|
+
return PluginExecutionError.make({
|
|
15
|
+
category: "runner",
|
|
16
|
+
cause: Redacted.make(cause),
|
|
17
|
+
message: pipe(Match.value(cause), Match.when(Predicate.isString, String.trim), Match.orElse((value) => Formatter.format(Inspectable.toJson(value), {
|
|
18
|
+
ignoreToString: true,
|
|
19
|
+
space: 2
|
|
20
|
+
}))) || "No error details returned by the plugin."
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
pipe(Effect.gen(function* () {
|
|
24
|
+
const guestServices = yield* Effect.context();
|
|
25
|
+
const scope = yield* Scope.Scope;
|
|
26
|
+
const runtimeScope = yield* Scope.fork(scope, "sequential");
|
|
27
|
+
const failed = yield* Deferred.make();
|
|
28
|
+
const invocations = yield* FiberMap.make();
|
|
29
|
+
const stdio = yield* Stdio.Stdio;
|
|
30
|
+
const args = yield* Schema.decodeUnknownEffect(Schema.Tuple([
|
|
31
|
+
Schema.NonEmptyString,
|
|
32
|
+
Schema.NonEmptyString,
|
|
33
|
+
Schema.Literals(["inspect", "execute"]),
|
|
34
|
+
Schema.NonEmptyString
|
|
35
|
+
]))(yield* stdio.args);
|
|
36
|
+
const load = yield* Effect.cached(Effect.forkIn(Effect.gen(function* () {
|
|
37
|
+
const plugin = (yield* Schema.decodeUnknownEffect(Schema.Record(Schema.String, Schema.Unknown))(yield* Effect.tryPromise({
|
|
38
|
+
try: () => import(args[0]),
|
|
39
|
+
catch: initializationError
|
|
40
|
+
})))[args[1]];
|
|
41
|
+
if (!isPlugin(plugin)) return yield* PluginExecutionError.make({
|
|
42
|
+
category: "protocol",
|
|
43
|
+
message: "The configured export is not an integration plugin"
|
|
44
|
+
});
|
|
45
|
+
yield* Effect.try({
|
|
46
|
+
try: () => make(plugin.identifier),
|
|
47
|
+
catch: initializationError
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
plugin,
|
|
51
|
+
runtime: yield* Effect.cached(Effect.forkIn(pipe(Layer.buildWithScope(pipe(toLayer(fromPlugin(plugin, args[3])), Layer.provideMerge(Layer.mergeAll(filesUnavailable, FetchHttpClient.layer, guestOAuth))), runtimeScope), Effect.provideContext(Context.makeUnsafe(guestServices.mapUnsafe))), runtimeScope))
|
|
52
|
+
};
|
|
53
|
+
}), runtimeScope));
|
|
54
|
+
const execute$1 = Effect.fnUntraced(function* (request) {
|
|
55
|
+
return yield* pipe(Effect.gen(function* () {
|
|
56
|
+
const { plugin, runtime } = yield* Fiber.join(yield* load);
|
|
57
|
+
if (request.identity.pluginKey !== plugin.identifier && !(args[2] === "inspect" && "_tag" in request && request._tag === "extract")) return yield* PluginExecutionError.make({
|
|
58
|
+
category: "protocol",
|
|
59
|
+
message: "Plugin identity does not match the request"
|
|
60
|
+
});
|
|
61
|
+
if (request.identity.pluginVersion !== args[3]) return yield* PluginExecutionError.make({
|
|
62
|
+
category: "protocol",
|
|
63
|
+
message: "Plugin release does not match the request"
|
|
64
|
+
});
|
|
65
|
+
if ("_tag" in request && request._tag === "extract") return {
|
|
66
|
+
_tag: "success",
|
|
67
|
+
identity: request.identity,
|
|
68
|
+
value: yield* Schema.decodeEffect(Schema.fromJsonString(Schema.Json))(yield* Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown))(materializePlugin(plugin, { version: request.identity.pluginVersion })))
|
|
69
|
+
};
|
|
70
|
+
return yield* pipe(execute(request), Effect.provideContext(yield* Fiber.join(yield* runtime)));
|
|
71
|
+
}), Effect.catchCauseIf((cause) => !Cause.hasInterrupts(cause), (cause) => args[2] === "inspect" ? Effect.fail(initializationError(Cause.squash(cause))) : Effect.succeed({
|
|
72
|
+
_tag: "failure",
|
|
73
|
+
identity: request.identity,
|
|
74
|
+
error: {
|
|
75
|
+
category: "initialization",
|
|
76
|
+
code: "PluginInitializationFailed",
|
|
77
|
+
message: "Cannot initialize the installed plugin",
|
|
78
|
+
retryable: false
|
|
79
|
+
}
|
|
80
|
+
})), Effect.mapError(initializationError));
|
|
81
|
+
});
|
|
82
|
+
yield* Effect.raceFirst(pipe(ipcMessages(process), Stream.runForEach(Effect.fnUntraced(function* (message) {
|
|
83
|
+
const input = yield* decodeInput(message);
|
|
84
|
+
const key = yield* Schema.encodeEffect(Schema.fromJsonString(Identity))(input.identity);
|
|
85
|
+
if ("_tag" in input && input._tag === "cancel") {
|
|
86
|
+
const fiber = Option.getOrUndefined(yield* FiberMap.get(invocations, key));
|
|
87
|
+
if (fiber !== void 0) yield* pipe(Fiber.interrupt(fiber), Effect.forkIn(scope));
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
if ((yield* FiberMap.has(invocations, key)) || (yield* FiberMap.size(invocations)) >= 16) return yield* PluginExecutionError.make({
|
|
91
|
+
category: "protocol",
|
|
92
|
+
message: "Plugin invocation is duplicate or exceeds concurrency"
|
|
93
|
+
});
|
|
94
|
+
const fiber = yield* FiberMap.run(invocations, key, Effect.scoped(execute$1(input)));
|
|
95
|
+
yield* pipe(Effect.gen(function* () {
|
|
96
|
+
const exit = yield* Fiber.await(fiber);
|
|
97
|
+
const send = Effect.fnUntraced(function* (output) {
|
|
98
|
+
const encoded = yield* encodeOutput(output, responseLimit(input));
|
|
99
|
+
if (args[2] !== "inspect") return yield* sendIpc(process, encoded);
|
|
100
|
+
yield* Effect.callback((resume) => {
|
|
101
|
+
if (process.send === void 0) {
|
|
102
|
+
resume(Effect.fail(initializationError("Plugin IPC channel is closed")));
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
process.send(encoded, (error) => {
|
|
106
|
+
if (error !== null) resume(Effect.fail(initializationError(error)));
|
|
107
|
+
else resume(Effect.void);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
if (process.connected) process.disconnect();
|
|
111
|
+
});
|
|
112
|
+
if (Exit.isSuccess(exit)) return yield* send(exit.value);
|
|
113
|
+
if (Array.every(exit.cause.reasons, Cause.isInterruptReason)) return yield* send({
|
|
114
|
+
_tag: "interrupted",
|
|
115
|
+
identity: input.identity
|
|
116
|
+
});
|
|
117
|
+
return yield* initializationError(Cause.squash(exit.cause));
|
|
118
|
+
}), Effect.catchCause((cause) => Deferred.fail(failed, initializationError(Cause.squash(cause)))), Effect.forkIn(scope));
|
|
119
|
+
})), Effect.mapError(initializationError)), Deferred.await(failed));
|
|
120
|
+
}), Effect.scoped, Effect.provide(NodeServices.layer), NodeRuntime.runMain({ disableErrorReporting: process.argv[4] !== "inspect" }));
|
|
121
|
+
//#endregion
|
|
122
|
+
export {};
|
|
123
|
+
|
|
124
|
+
//# sourceMappingURL=Runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Runner.js","names":["OAuthFlow.layer","PluginRuntime.PluginExecutionError","Plugin.isPlugin","Plugin.make","DualRuntime.toLayer","DualRuntime.fromPlugin","RemoteRuntime.filesUnavailable","execute","DualRegistry.materializePlugin","PluginRuntime.execute","PluginRuntime.ipcMessages","PluginRuntime.decodeInput","RemoteRuntime.Identity","PluginRuntime.encodeOutput","PluginRuntime.responseLimit","PluginRuntime.sendIpc"],"sources":["../src/Runner.ts"],"sourcesContent":["import { NodeRuntime, NodeServices } from \"@effect/platform-node\";\n\nimport {\n Array,\n Cause,\n ConfigProvider,\n Context,\n Deferred,\n Effect,\n Exit,\n Fiber,\n FiberMap,\n Formatter,\n Inspectable,\n Layer,\n Match,\n Option,\n Predicate,\n Redacted,\n Schema,\n Scope,\n Stdio,\n Stream,\n String,\n pipe,\n} from \"effect\";\n\nimport { FetchHttpClient } from \"effect/http\";\n\nimport * as DualRegistry from \"./DualRegistry.ts\";\nimport * as DualRuntime from \"./DualRuntime.ts\";\nimport { OAuthFlow, oauth2TokenRefresherLayer } from \"./OAuthFlow.ts\";\nimport * as Plugin from \"./Plugin.ts\";\nimport { PluginRuntime } from \"./PluginRuntime.ts\";\nimport { RemoteRuntime } from \"./remote-runtime.ts\";\n\nconst guestOAuth = pipe(\n oauth2TokenRefresherLayer,\n Layer.provideMerge(OAuthFlow.layer),\n Layer.provide(ConfigProvider.layer(ConfigProvider.fromUnknown({}))),\n);\n\nfunction initializationError(cause: unknown) {\n // Each hop of the runner maps its failure here; the first error keeps its message.\n if (Schema.is(PluginRuntime.PluginExecutionError)(cause)) return cause;\n return PluginRuntime.PluginExecutionError.make({\n category: \"runner\",\n cause: Redacted.make(cause),\n message:\n pipe(\n Match.value(cause),\n Match.when(Predicate.isString, String.trim),\n Match.orElse(value =>\n Formatter.format(Inspectable.toJson(value), { ignoreToString: true, space: 2 }),\n ),\n ) || \"No error details returned by the plugin.\",\n });\n}\n\n// This executable runs only in the plugin's process, using its own SDK and Effect.\npipe(\n Effect.gen(function* () {\n const guestServices = yield* Effect.context<NodeServices.NodeServices>();\n const scope = yield* Scope.Scope;\n const runtimeScope = yield* Scope.fork(scope, \"sequential\");\n const failed = yield* Deferred.make<never, PluginRuntime.PluginExecutionError>();\n const invocations = yield* FiberMap.make<\n string,\n RemoteRuntime.Response,\n PluginRuntime.PluginExecutionError\n >();\n const stdio = yield* Stdio.Stdio;\n const args = yield* Schema.decodeUnknownEffect(\n Schema.Tuple([\n Schema.NonEmptyString,\n Schema.NonEmptyString,\n Schema.Literals([\"inspect\", \"execute\"]),\n Schema.NonEmptyString,\n ]),\n )(yield* stdio.args);\n const load = yield* Effect.cached(\n Effect.forkIn(\n Effect.gen(function* () {\n const exports = yield* Schema.decodeUnknownEffect(\n Schema.Record(Schema.String, Schema.Unknown),\n )(yield* Effect.tryPromise({ try: () => import(args[0]), catch: initializationError }));\n const plugin = exports[args[1]];\n if (!Plugin.isPlugin(plugin)) {\n return yield* PluginRuntime.PluginExecutionError.make({\n category: \"protocol\",\n message: \"The configured export is not an integration plugin\",\n });\n }\n yield* Effect.try({\n try: () => Plugin.make(plugin.identifier),\n catch: initializationError,\n });\n const runtime = yield* Effect.cached(\n Effect.forkIn(\n pipe(\n Layer.buildWithScope(\n pipe(\n // @effect-diagnostics-next-line anyUnknownInErrorContext:off -- Imported plugin requirements are erased; the guest supplies only its own services.\n DualRuntime.toLayer(DualRuntime.fromPlugin(plugin, args[3])),\n Layer.provideMerge(\n Layer.mergeAll(\n RemoteRuntime.filesUnavailable,\n FetchHttpClient.layer,\n guestOAuth,\n ),\n ),\n ),\n runtimeScope,\n ),\n Effect.provideContext(Context.makeUnsafe<unknown>(guestServices.mapUnsafe)),\n ),\n runtimeScope,\n ),\n );\n return { plugin, runtime };\n }),\n runtimeScope,\n ),\n );\n const execute = Effect.fnUntraced(function* (request: PluginRuntime.Request) {\n return yield* pipe(\n Effect.gen(function* () {\n const { plugin, runtime } = yield* Fiber.join(yield* load);\n if (\n request.identity.pluginKey !== plugin.identifier &&\n !(args[2] === \"inspect\" && \"_tag\" in request && request._tag === \"extract\")\n ) {\n return yield* PluginRuntime.PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin identity does not match the request\",\n });\n }\n if (request.identity.pluginVersion !== args[3])\n return yield* PluginRuntime.PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin release does not match the request\",\n });\n if (\"_tag\" in request && request._tag === \"extract\") {\n return {\n _tag: \"success\",\n identity: request.identity,\n value: yield* Schema.decodeEffect(Schema.fromJsonString(Schema.Json))(\n yield* Schema.encodeEffect(Schema.fromJsonString(Schema.Unknown))(\n DualRegistry.materializePlugin(plugin, {\n version: request.identity.pluginVersion,\n }),\n ),\n ),\n } satisfies RemoteRuntime.Response;\n }\n return yield* pipe(\n PluginRuntime.execute(request),\n Effect.provideContext(yield* Fiber.join(yield* runtime)),\n );\n }),\n Effect.catchCauseIf(\n cause => !Cause.hasInterrupts(cause),\n cause =>\n args[2] === \"inspect\"\n ? Effect.fail(initializationError(Cause.squash(cause)))\n : Effect.succeed({\n _tag: \"failure\",\n identity: request.identity,\n error: {\n category: \"initialization\",\n code: \"PluginInitializationFailed\",\n message: \"Cannot initialize the installed plugin\",\n retryable: false,\n },\n } satisfies RemoteRuntime.Response),\n ),\n Effect.mapError(initializationError),\n );\n });\n yield* Effect.raceFirst(\n pipe(\n PluginRuntime.ipcMessages(process),\n Stream.runForEach(\n Effect.fnUntraced(function* (message) {\n const input = yield* PluginRuntime.decodeInput(message);\n const key = yield* Schema.encodeEffect(Schema.fromJsonString(RemoteRuntime.Identity))(\n input.identity,\n );\n if (\"_tag\" in input && input._tag === \"cancel\") {\n const fiber = Option.getOrUndefined(yield* FiberMap.get(invocations, key));\n if (fiber !== undefined) yield* pipe(Fiber.interrupt(fiber), Effect.forkIn(scope));\n return;\n }\n if (\n (yield* FiberMap.has(invocations, key)) ||\n (yield* FiberMap.size(invocations)) >= 16\n ) {\n return yield* PluginRuntime.PluginExecutionError.make({\n category: \"protocol\",\n message: \"Plugin invocation is duplicate or exceeds concurrency\",\n });\n }\n const fiber = yield* FiberMap.run(invocations, key, Effect.scoped(execute(input)));\n yield* pipe(\n Effect.gen(function* () {\n const exit = yield* Fiber.await(fiber);\n const send = Effect.fnUntraced(function* (output: PluginRuntime.Output) {\n const encoded = yield* PluginRuntime.encodeOutput(\n output,\n PluginRuntime.responseLimit(input),\n );\n if (args[2] !== \"inspect\") return yield* PluginRuntime.sendIpc(process, encoded);\n // Bun can discard queued data on disconnect; wait for its native send callback.\n yield* Effect.callback<void, PluginRuntime.PluginExecutionError>(resume => {\n if (process.send === undefined) {\n resume(Effect.fail(initializationError(\"Plugin IPC channel is closed\")));\n return;\n }\n process.send(encoded, error => {\n if (error !== null) resume(Effect.fail(initializationError(error)));\n else resume(Effect.void);\n });\n });\n if (process.connected) process.disconnect();\n });\n if (Exit.isSuccess(exit)) return yield* send(exit.value);\n if (Array.every(exit.cause.reasons, Cause.isInterruptReason)) {\n return yield* send({ _tag: \"interrupted\", identity: input.identity });\n }\n return yield* initializationError(Cause.squash(exit.cause));\n }),\n Effect.catchCause(cause =>\n Deferred.fail(failed, initializationError(Cause.squash(cause))),\n ),\n Effect.forkIn(scope),\n );\n }),\n ),\n Effect.mapError(initializationError),\n ),\n Deferred.await(failed),\n );\n }),\n Effect.scoped,\n // @effect-diagnostics-next-line strictEffectProvide:off -- This executable owns the guest process services.\n Effect.provide(NodeServices.layer),\n NodeRuntime.runMain({ disableErrorReporting: process.argv[4] !== \"inspect\" }),\n);\n"],"mappings":";;;;;;;;;;AAoCA,MAAM,aAAa,KACjB,2BACA,MAAM,aAAaA,KAAe,GAClC,MAAM,QAAQ,eAAe,MAAM,eAAe,YAAY,CAAC,CAAC,CAAC,CAAC,CACpE;AAEA,SAAS,oBAAoB,OAAgB;CAE3C,IAAI,OAAO,GAAGC,oBAAkC,CAAC,CAAC,KAAK,GAAG,OAAO;CACjE,OAAA,qBAA0C,KAAK;EAC7C,UAAU;EACV,OAAO,SAAS,KAAK,KAAK;EAC1B,SACE,KACE,MAAM,MAAM,KAAK,GACjB,MAAM,KAAK,UAAU,UAAU,O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D,IAAI,MAAM,MAAM,KAAK,MAAM,SAAS,MAAM,iBAAiB,GACzD,OAAO,OAAO,KAAK;IAAE,MAAM;IAAe,UAAU,MAAM;GAAS,CAAC;GAEtE,OAAO,OAAO,oBAAoB,MAAM,OAAO,KAAK,KAAK,CAAC;EAC5D,CAAC,GACD,OAAO,YAAW,UAChB,SAAS,KAAK,QAAQ,oBAAoB,MAAM,OAAO,KAAK,CAAC,CAAC,CAChE,GACA,OAAO,OAAO,KAAK,CACrB;CACF,CAAC,CACH,GACA,OAAO,SAAS,mBAAmB,CACrC,GACA,SAAS,MAAM,MAAM,CACvB;AACF,CAAC,GACD,OAAO,QAEP,OAAO,QAAQ,aAAa,KAAK,GACjC,YAAY,QAAQ,EAAE,uBAAuB,QAAQ,KAAK,OAAO,UAAU,CAAC,CAC9E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import "./ToolFile.js";
|
|
2
|
+
import { Schema as Schema$1 } from "effect";
|
|
3
|
+
declare namespace ToolFile_d_exports {
|
|
4
|
+
export { File, Schema, ToolFile_d_exports as ToolFile };
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Complete file content and metadata. Hosts validate the bytes before saving them;
|
|
8
|
+
* a filename is a suggestion, never a trusted destination path.
|
|
9
|
+
*
|
|
10
|
+
* @since 0.0.0
|
|
11
|
+
* @category schemas
|
|
12
|
+
*/
|
|
13
|
+
export declare const Schema: Schema$1.TaggedStruct<"ToolFile", {
|
|
14
|
+
readonly contentBase64: Schema$1.String;
|
|
15
|
+
readonly contentType: Schema$1.NullOr<Schema$1.String>;
|
|
16
|
+
readonly filename: Schema$1.NullOr<Schema$1.String>;
|
|
17
|
+
readonly sizeBytes: Schema$1.Natural;
|
|
18
|
+
}>;
|
|
19
|
+
/** @since 0.0.0 @category models */
|
|
20
|
+
export type File = typeof Schema.Type;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { ToolFile_d_exports as ToolFile, ToolFile_d_exports };
|
|
23
|
+
//# sourceMappingURL=ToolFile.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolFile.d.ts","names":["EffectSchema"],"sources":["../src/ToolFile.ts"],"mappings":";;;;;;;;;;;;qBAca,QAAMA,SAAA;;;;;;;YAWP,cAAc,OAAO"}
|
package/dist/ToolFile.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
+
import "./ToolFile.js";
|
|
3
|
+
import { Schema as Schema$1 } from "effect";
|
|
4
|
+
//#region src/ToolFile.ts
|
|
5
|
+
/**
|
|
6
|
+
* JSON-safe file results that hosts can persist without reconstructing displayed text.
|
|
7
|
+
*
|
|
8
|
+
* @since 0.0.0
|
|
9
|
+
*/
|
|
10
|
+
var ToolFile_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
+
Schema: () => Schema,
|
|
12
|
+
ToolFile: () => ToolFile_exports
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Complete file content and metadata. Hosts validate the bytes before saving them;
|
|
16
|
+
* a filename is a suggestion, never a trusted destination path.
|
|
17
|
+
*
|
|
18
|
+
* @since 0.0.0
|
|
19
|
+
* @category schemas
|
|
20
|
+
*/
|
|
21
|
+
const Schema = Schema$1.TaggedStruct("ToolFile", {
|
|
22
|
+
contentBase64: Schema$1.String.annotate({
|
|
23
|
+
contentEncoding: "base64",
|
|
24
|
+
description: "Complete file bytes in Base64. Preserve this field without truncation."
|
|
25
|
+
}),
|
|
26
|
+
contentType: Schema$1.NullOr(Schema$1.String),
|
|
27
|
+
filename: Schema$1.NullOr(Schema$1.String),
|
|
28
|
+
sizeBytes: Schema$1.Natural
|
|
29
|
+
});
|
|
30
|
+
//#endregion
|
|
31
|
+
export { Schema, ToolFile_exports as ToolFile, ToolFile_exports };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=ToolFile.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolFile.js","names":["EffectSchema"],"sources":["../src/ToolFile.ts"],"sourcesContent":["/**\n * JSON-safe file results that hosts can persist without reconstructing displayed text.\n *\n * @since 0.0.0\n */\nimport { Schema as EffectSchema } from \"effect\";\n\n/**\n * Complete file content and metadata. Hosts validate the bytes before saving them;\n * a filename is a suggestion, never a trusted destination path.\n *\n * @since 0.0.0\n * @category schemas\n */\nexport const Schema = EffectSchema.TaggedStruct(\"ToolFile\", {\n contentBase64: EffectSchema.String.annotate({\n contentEncoding: \"base64\",\n description: \"Complete file bytes in Base64. Preserve this field without truncation.\",\n }),\n contentType: EffectSchema.NullOr(EffectSchema.String),\n filename: EffectSchema.NullOr(EffectSchema.String),\n sizeBytes: EffectSchema.Natural,\n});\n\n/** @since 0.0.0 @category models */\nexport type File = typeof Schema.Type;\n\nexport * as ToolFile from \"./ToolFile.ts\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAcA,MAAa,SAASA,SAAa,aAAa,YAAY;CAC1D,eAAeA,SAAa,OAAO,SAAS;EAC1C,iBAAiB;EACjB,aAAa;CACf,CAAC;CACD,aAAaA,SAAa,OAAOA,SAAa,MAAM;CACpD,UAAUA,SAAa,OAAOA,SAAa,MAAM;CACjD,WAAWA,SAAa;AAC1B,CAAC"}
|