effect-cf 0.35.0 → 0.36.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/CHANGELOG.md +6 -0
- package/dist/ComputerWorkspace.d.mts +1 -1
- package/dist/ComputerWorkspace.mjs +1 -1
- package/dist/DurableObjectState-CpgAmFqo.d.mts +244 -0
- package/dist/{DurableObjectState-DcqElJ4e.mjs → DurableObjectState-DCh4PZMN.mjs} +3 -60
- package/dist/Mcp.d.mts +122 -0
- package/dist/Mcp.mjs +270 -0
- package/dist/Vitest.d.mts +2 -2
- package/dist/Vitest.mjs +2 -1
- package/dist/{DurableObjectState-DpYdNZgT.d.mts → Worker-Dl6_Pijl.d.mts} +2 -242
- package/dist/Worker-XsGJsCJX.mjs +885 -0
- package/dist/WorkerContext-Yobnfw-K.mjs +60 -0
- package/dist/{WorkflowBinding-Cn3AuUyP.d.mts → WorkflowBinding-CvJT9hB5.d.mts} +1 -1
- package/dist/index.d.mts +3 -2
- package/dist/index.mjs +90 -966
- package/package.json +12 -1
- package/src/Mcp.ts +531 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Cause, Effect, Exit, FiberSet } from "effect";
|
|
2
|
+
//#region src/internal/NativeCallback.ts
|
|
3
|
+
/**
|
|
4
|
+
* Runs an Effect callback owned by a native Promise operation.
|
|
5
|
+
*
|
|
6
|
+
* The callback keeps the caller's context, while a private scope owns its
|
|
7
|
+
* fiber. Closing that scope interrupts and joins the callback before awaiting
|
|
8
|
+
* the native operation's settlement.
|
|
9
|
+
*/
|
|
10
|
+
const runNativeCallback = Effect.fnUntraced(function* (operation) {
|
|
11
|
+
const callerContext = yield* Effect.context();
|
|
12
|
+
return yield* Effect.scoped(Effect.gen(function* () {
|
|
13
|
+
let nativePromise;
|
|
14
|
+
yield* Effect.addFinalizer(() => {
|
|
15
|
+
const promise = nativePromise;
|
|
16
|
+
return promise === void 0 ? Effect.void : Effect.promise(() => promise.then(() => void 0, () => void 0));
|
|
17
|
+
});
|
|
18
|
+
const runPromise = yield* FiberSet.makeRuntimePromise();
|
|
19
|
+
return yield* Effect.callback((resume) => {
|
|
20
|
+
try {
|
|
21
|
+
nativePromise = operation((effect) => runPromise(Effect.provideContext(Effect.exit(effect), callerContext)));
|
|
22
|
+
} catch (cause) {
|
|
23
|
+
resume(Effect.fail(cause));
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
nativePromise.then((value) => resume(Effect.succeed(value)), (cause) => resume(Effect.fail(cause)));
|
|
27
|
+
});
|
|
28
|
+
}));
|
|
29
|
+
});
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/internal/WorkerContext.ts
|
|
32
|
+
const causeError = (cause) => {
|
|
33
|
+
const squashed = Cause.squash(cause);
|
|
34
|
+
return squashed instanceof Error ? squashed : new Error(Cause.pretty(cause), { cause: squashed });
|
|
35
|
+
};
|
|
36
|
+
const failureHandler = (label, cause, options) => Effect.suspend(() => options?.onFailure?.(cause) ?? Effect.logError(`${label} failed`, Cause.pretty(cause))).pipe(Effect.catchCause((handlerCause) => Effect.logError(`${label} failure handler failed`, Cause.pretty(cause), Cause.pretty(handlerCause))));
|
|
37
|
+
const makeWaitUntilScheduler = (label, register, runPromiseExit = (effect) => Effect.runPromiseExit(effect)) => {
|
|
38
|
+
return (effect, options, mode) => Effect.context().pipe(Effect.flatMap((context) => Effect.sync(() => {
|
|
39
|
+
const runHandler = (cause) => runPromiseExit(Effect.provideContext(Effect.scoped(failureHandler(label, cause, options)), context)).then((exit) => {
|
|
40
|
+
if (Exit.isFailure(exit)) console.error(`${label} failure handler failed`, Cause.pretty(exit.cause));
|
|
41
|
+
});
|
|
42
|
+
register(runPromiseExit(Effect.provideContext(Effect.scoped(effect), context)).then(async (exit) => {
|
|
43
|
+
if (Exit.isSuccess(exit)) return;
|
|
44
|
+
await runHandler(exit.cause);
|
|
45
|
+
if (mode === "propagate") throw causeError(exit.cause);
|
|
46
|
+
}));
|
|
47
|
+
})));
|
|
48
|
+
};
|
|
49
|
+
const fromExecutionContext = (ctx, runPromiseExit = (effect) => Effect.runPromiseExit(effect)) => {
|
|
50
|
+
const schedule = makeWaitUntilScheduler("WorkerContext.waitUntil", (promise) => ctx.waitUntil(promise), runPromiseExit);
|
|
51
|
+
return {
|
|
52
|
+
raw: ctx,
|
|
53
|
+
waitUntil: (effect, options) => schedule(effect, options, options?.mode ?? "observe"),
|
|
54
|
+
waitUntilPropagating: (effect, options) => schedule(effect, options, "propagate"),
|
|
55
|
+
passThroughOnException: Effect.sync(() => ctx.passThroughOnException()),
|
|
56
|
+
abort: (reason) => Effect.sync(() => ctx.abort(reason))
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
//#endregion
|
|
60
|
+
export { makeWaitUntilScheduler as n, runNativeCallback as r, fromExecutionContext as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as WorkerEnvironment, r as BindingValidationError, t as BindingNotFoundError } from "./Binding-DKcLrQCM.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { S as ServiceFreeSchema } from "./Worker-Dl6_Pijl.mjs";
|
|
3
3
|
import { Context, Effect, Option, Schema } from "effect";
|
|
4
4
|
declare namespace WorkflowBinding_d_exports {
|
|
5
5
|
export { WorkflowBindingClient, WorkflowBindingDefinition, WorkflowInstance, WorkflowInstanceCreateBatchOptions, WorkflowInstanceCreateOptions, WorkflowInstanceEvent, WorkflowInstanceLocationHint, WorkflowInstanceRestartOptions, WorkflowInstanceStatus, WorkflowInstanceStatusName, WorkflowInstanceTerminateOptions, WorkflowOperationError, WorkflowResultDecodeError, isWorkflow, layer, makeClient };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { a as Environment_d_exports, c as WorkerEnvironment, i as Binding_d_exports, n as BindingService, o as WorkerConfig, r as BindingValidationError, s as WorkerEnv, t as BindingNotFoundError } from "./Binding-DKcLrQCM.mjs";
|
|
2
2
|
import { l as Artifacts_d_exports } from "./Artifacts-B3r3RuTB.mjs";
|
|
3
|
-
import {
|
|
3
|
+
import { a as AcceptedUpgrade, c as DurableWebSocketAttachmentError, i as AcceptUpgradeOptions, l as DurableObjectStorage_d_exports, o as DurableObjectWebSocket_d_exports, r as DurableObjectState_d_exports, s as DurableWebSocket, t as DurableObjectState, u as StorageOperationError } from "./DurableObjectState-CpgAmFqo.mjs";
|
|
4
|
+
import { C as Provider, S as ServiceFreeSchema$1, _ as QueueBinding_d_exports, a as Worker_d_exports, b as ReservedMethodName$2, c as AsyncMethodArgs, d as AsyncMethodSuccess, f as ReceiverOptions, g as QueueDefinition_d_exports, h as Queue_d_exports, l as AsyncMethodCloudflareReturn, m as RpcTracing_d_exports, n as NativeRequest, o as WorkerDefinition_d_exports, p as RpcInvocationInfo, r as WorkerContext, s as ServiceBinding_d_exports, t as ExecutionContext, u as AsyncMethodKey, v as Definition$4, w as Rpc_d_exports, x as RpcDefinition_d_exports, y as Method$2 } from "./Worker-Dl6_Pijl.mjs";
|
|
4
5
|
import { t as Hyperdrive_d_exports } from "./Hyperdrive-HrwFlZ6x.mjs";
|
|
5
6
|
import { t as ContainerNamespace_d_exports } from "./ContainerNamespace-DbLaeFhN.mjs";
|
|
6
|
-
import { a as WorkflowInstanceCreateOptions, i as WorkflowInstanceCreateBatchOptions, n as WorkflowBinding_d_exports, r as WorkflowInstance, s as WorkflowOperationError, t as WorkflowBindingClient } from "./WorkflowBinding-
|
|
7
|
+
import { a as WorkflowInstanceCreateOptions, i as WorkflowInstanceCreateBatchOptions, n as WorkflowBinding_d_exports, r as WorkflowInstance, s as WorkflowOperationError, t as WorkflowBindingClient } from "./WorkflowBinding-CvJT9hB5.mjs";
|
|
7
8
|
import { Cause, Config, Context, Data, DateTime, Duration, Effect, Layer, Option, Predicate, Redacted, Schema, Scope } from "effect";
|
|
8
9
|
import { Headers as Headers$1, HttpClient, HttpClientResponse } from "effect/unstable/http";
|
|
9
10
|
import { OtlpExporter, OtlpResource } from "effect/unstable/observability";
|