effect 4.0.0-beta.11 → 4.0.0-beta.12
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/dist/Config.d.ts +157 -0
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +56 -1
- package/dist/Config.js.map +1 -1
- package/dist/Effect.d.ts +79 -0
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +26 -0
- package/dist/Effect.js.map +1 -1
- package/dist/Fiber.d.ts +2 -2
- package/dist/Fiber.d.ts.map +1 -1
- package/dist/Fiber.js.map +1 -1
- package/dist/Graph.d.ts.map +1 -1
- package/dist/Graph.js +3 -6
- package/dist/Graph.js.map +1 -1
- package/dist/Random.d.ts +17 -0
- package/dist/Random.d.ts.map +1 -1
- package/dist/Random.js +17 -0
- package/dist/Random.js.map +1 -1
- package/dist/Schema.d.ts +3 -1
- package/dist/Schema.d.ts.map +1 -1
- package/dist/internal/effect.js +59 -44
- package/dist/internal/effect.js.map +1 -1
- package/dist/unstable/ai/LanguageModel.d.ts.map +1 -1
- package/dist/unstable/ai/LanguageModel.js +49 -18
- package/dist/unstable/ai/LanguageModel.js.map +1 -1
- package/dist/unstable/ai/McpSchema.d.ts +112 -36
- package/dist/unstable/ai/McpSchema.d.ts.map +1 -1
- package/dist/unstable/ai/McpSchema.js +47 -10
- package/dist/unstable/ai/McpSchema.js.map +1 -1
- package/dist/unstable/ai/McpServer.d.ts.map +1 -1
- package/dist/unstable/ai/McpServer.js +33 -6
- package/dist/unstable/ai/McpServer.js.map +1 -1
- package/dist/unstable/ai/Tool.d.ts +16 -0
- package/dist/unstable/ai/Tool.d.ts.map +1 -1
- package/dist/unstable/ai/Tool.js +14 -0
- package/dist/unstable/ai/Tool.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.d.ts.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +2 -2
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/http/HttpClient.d.ts +28 -4
- package/dist/unstable/http/HttpClient.d.ts.map +1 -1
- package/dist/unstable/http/HttpClient.js.map +1 -1
- package/dist/unstable/http/HttpEffect.d.ts +3 -8
- package/dist/unstable/http/HttpEffect.d.ts.map +1 -1
- package/dist/unstable/http/HttpEffect.js +13 -24
- package/dist/unstable/http/HttpEffect.js.map +1 -1
- package/dist/unstable/http/HttpMiddleware.d.ts.map +1 -1
- package/dist/unstable/http/HttpMiddleware.js +4 -8
- package/dist/unstable/http/HttpMiddleware.js.map +1 -1
- package/dist/unstable/http/HttpServerError.d.ts +6 -1
- package/dist/unstable/http/HttpServerError.d.ts.map +1 -1
- package/dist/unstable/http/HttpServerError.js +26 -17
- package/dist/unstable/http/HttpServerError.js.map +1 -1
- package/dist/unstable/http/internal/preResponseHandler.d.ts +2 -0
- package/dist/unstable/http/internal/preResponseHandler.d.ts.map +1 -0
- package/dist/unstable/http/internal/preResponseHandler.js +10 -0
- package/dist/unstable/http/internal/preResponseHandler.js.map +1 -0
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
- package/dist/unstable/reactivity/Atom.js +1 -1
- package/dist/unstable/reactivity/Atom.js.map +1 -1
- package/dist/unstable/rpc/RpcSchema.d.ts +13 -0
- package/dist/unstable/rpc/RpcSchema.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSchema.js +14 -0
- package/dist/unstable/rpc/RpcSchema.js.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcSerialization.js +34 -9
- package/dist/unstable/rpc/RpcSerialization.js.map +1 -1
- package/dist/unstable/rpc/RpcServer.d.ts +0 -7
- package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcServer.js +5 -10
- package/dist/unstable/rpc/RpcServer.js.map +1 -1
- package/package.json +1 -1
- package/src/Config.ts +171 -9
- package/src/Effect.ts +80 -0
- package/src/Fiber.ts +9 -2
- package/src/Graph.ts +16 -6
- package/src/Random.ts +18 -0
- package/src/Schema.ts +1 -1
- package/src/internal/effect.ts +82 -49
- package/src/unstable/ai/LanguageModel.ts +54 -24
- package/src/unstable/ai/McpSchema.ts +57 -11
- package/src/unstable/ai/McpServer.ts +44 -6
- package/src/unstable/ai/Tool.ts +15 -0
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +2 -2
- package/src/unstable/http/HttpClient.ts +45 -10
- package/src/unstable/http/HttpEffect.ts +20 -39
- package/src/unstable/http/HttpMiddleware.ts +4 -14
- package/src/unstable/http/HttpServerError.ts +29 -18
- package/src/unstable/http/internal/preResponseHandler.ts +15 -0
- package/src/unstable/httpapi/HttpApiBuilder.ts +1 -1
- package/src/unstable/reactivity/Atom.ts +1 -1
- package/src/unstable/rpc/RpcSchema.ts +17 -0
- package/src/unstable/rpc/RpcSerialization.ts +44 -9
- package/src/unstable/rpc/RpcServer.ts +10 -19
package/dist/internal/effect.js
CHANGED
|
@@ -323,33 +323,31 @@ const fiberIdStore = {
|
|
|
323
323
|
/** @internal */
|
|
324
324
|
export const getCurrentFiber = () => globalThis[currentFiberTypeId];
|
|
325
325
|
const keepAlive = /*#__PURE__*/(() => {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
326
|
+
let isAvailable;
|
|
327
|
+
const start = () => {
|
|
328
|
+
if (isAvailable === true) return setInterval(constVoid, 2_147_483_647);else if (isAvailable === false) return undefined;
|
|
329
329
|
try {
|
|
330
|
-
const running =
|
|
331
|
-
|
|
332
|
-
return
|
|
333
|
-
setInterval,
|
|
334
|
-
clearInterval
|
|
335
|
-
};
|
|
330
|
+
const running = setInterval(constVoid, 2_147_483_647);
|
|
331
|
+
isAvailable = true;
|
|
332
|
+
return running;
|
|
336
333
|
} catch {
|
|
334
|
+
isAvailable = false;
|
|
337
335
|
return undefined;
|
|
338
336
|
}
|
|
339
|
-
}
|
|
337
|
+
};
|
|
340
338
|
let count = 0;
|
|
341
339
|
let running = undefined;
|
|
342
340
|
return {
|
|
343
341
|
increment() {
|
|
344
342
|
count++;
|
|
345
|
-
if (
|
|
346
|
-
running = start
|
|
343
|
+
if (running === undefined) {
|
|
344
|
+
running = start();
|
|
347
345
|
}
|
|
348
346
|
},
|
|
349
347
|
decrement() {
|
|
350
348
|
count--;
|
|
351
|
-
if (count === 0 &&
|
|
352
|
-
|
|
349
|
+
if (count === 0 && running !== undefined) {
|
|
350
|
+
clearInterval(running);
|
|
353
351
|
running = undefined;
|
|
354
352
|
}
|
|
355
353
|
}
|
|
@@ -615,8 +613,10 @@ export const fiberJoinAll = self => callback(resume => {
|
|
|
615
613
|
/** @internal */
|
|
616
614
|
export const fiberInterrupt = self => withFiber(fiber => fiberInterruptAs(self, fiber.id));
|
|
617
615
|
/** @internal */
|
|
618
|
-
export const fiberInterruptAs = /*#__PURE__*/dual(
|
|
619
|
-
|
|
616
|
+
export const fiberInterruptAs = /*#__PURE__*/dual(args => hasProperty(args[0], FiberTypeId), (self, fiberId, annotations) => withFiber(parent => {
|
|
617
|
+
let ann = fiberStackAnnotations(parent);
|
|
618
|
+
ann = ann && annotations ? ServiceMap.merge(ann, annotations) : ann ?? annotations;
|
|
619
|
+
self.interruptUnsafe(fiberId, ann);
|
|
620
620
|
return asVoid(fiberAwait(self));
|
|
621
621
|
}));
|
|
622
622
|
/** @internal */
|
|
@@ -1134,33 +1134,17 @@ export const updateServices = /*#__PURE__*/dual(2, (self, f) => withFiber(fiber
|
|
|
1134
1134
|
const nextServices = f(prev);
|
|
1135
1135
|
if (prev === nextServices) return self;
|
|
1136
1136
|
fiber.setServices(nextServices);
|
|
1137
|
-
const newServices = new Map();
|
|
1138
|
-
for (const [key, value] of fiber.services.mapUnsafe) {
|
|
1139
|
-
if (!prev.mapUnsafe.has(key) || value !== prev.mapUnsafe.get(key)) {
|
|
1140
|
-
newServices.set(key, value);
|
|
1141
|
-
}
|
|
1142
|
-
}
|
|
1143
1137
|
return onExitPrimitive(self, () => {
|
|
1144
|
-
|
|
1145
|
-
for (const [key, value] of newServices) {
|
|
1146
|
-
if (value !== map.get(key)) continue;
|
|
1147
|
-
if (prev.mapUnsafe.has(key)) {
|
|
1148
|
-
map.set(key, prev.mapUnsafe.get(key));
|
|
1149
|
-
} else {
|
|
1150
|
-
map.delete(key);
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
fiber.setServices(ServiceMap.makeUnsafe(map));
|
|
1138
|
+
fiber.setServices(prev);
|
|
1154
1139
|
return undefined;
|
|
1155
1140
|
});
|
|
1156
1141
|
}));
|
|
1157
1142
|
/** @internal */
|
|
1158
|
-
export const updateService = /*#__PURE__*/dual(3, (self, service, f) =>
|
|
1159
|
-
const prev = ServiceMap.getUnsafe(
|
|
1143
|
+
export const updateService = /*#__PURE__*/dual(3, (self, service, f) => updateServices(self, s => {
|
|
1144
|
+
const prev = ServiceMap.getUnsafe(s, service);
|
|
1160
1145
|
const next = f(prev);
|
|
1161
|
-
if (prev === next) return
|
|
1162
|
-
|
|
1163
|
-
return onExit(self, () => sync(() => fiber.setServices(ServiceMap.add(fiber.services, service, prev))));
|
|
1146
|
+
if (prev === next) return s;
|
|
1147
|
+
return ServiceMap.add(s, service, next);
|
|
1164
1148
|
}));
|
|
1165
1149
|
/** @internal */
|
|
1166
1150
|
export const services = () => getServiceMap;
|
|
@@ -1179,11 +1163,10 @@ export const provideService = function () {
|
|
|
1179
1163
|
}
|
|
1180
1164
|
return dual(3, (self, service, impl) => provideServiceImpl(self, service, impl)).apply(this, arguments);
|
|
1181
1165
|
};
|
|
1182
|
-
const provideServiceImpl = (self, service, implementation) =>
|
|
1183
|
-
const prev =
|
|
1184
|
-
if (prev
|
|
1185
|
-
|
|
1186
|
-
return onExit(self, () => sync(() => fiber.setServices(ServiceMap.addOrOmit(fiber.services, service, prev))));
|
|
1166
|
+
const provideServiceImpl = (self, service, implementation) => updateServices(self, s => {
|
|
1167
|
+
const prev = s.mapUnsafe.get(service.key);
|
|
1168
|
+
if (prev === implementation) return s;
|
|
1169
|
+
return ServiceMap.add(s, service, implementation);
|
|
1187
1170
|
});
|
|
1188
1171
|
/** @internal */
|
|
1189
1172
|
export const provideServiceEffect = /*#__PURE__*/dual(3, (self, service, acquire) => flatMap(acquire, implementation => provideService(self, service, implementation)));
|
|
@@ -1586,11 +1569,11 @@ export const scope = /*#__PURE__*/scopeTag.asEffect();
|
|
|
1586
1569
|
export const provideScope = /*#__PURE__*/provideService(scopeTag);
|
|
1587
1570
|
/** @internal */
|
|
1588
1571
|
export const scoped = self => withFiber(fiber => {
|
|
1589
|
-
const prev =
|
|
1572
|
+
const prev = fiber.services;
|
|
1590
1573
|
const scope = scopeMakeUnsafe();
|
|
1591
1574
|
fiber.setServices(ServiceMap.add(fiber.services, scopeTag, scope));
|
|
1592
1575
|
return onExitPrimitive(self, exit => {
|
|
1593
|
-
fiber.setServices(
|
|
1576
|
+
fiber.setServices(prev);
|
|
1594
1577
|
return scopeCloseUnsafe(scope, exit);
|
|
1595
1578
|
});
|
|
1596
1579
|
});
|
|
@@ -2565,6 +2548,38 @@ export const LogToStderr = /*#__PURE__*/ServiceMap.Reference("effect/Logger/LogT
|
|
|
2565
2548
|
defaultValue: constFalse
|
|
2566
2549
|
});
|
|
2567
2550
|
/** @internal */
|
|
2551
|
+
export const annotateLogsScoped = function () {
|
|
2552
|
+
const entries = typeof arguments[0] === "string" ? [[arguments[0], arguments[1]]] : Object.entries(arguments[0]);
|
|
2553
|
+
return uninterruptible(withFiber(fiber => {
|
|
2554
|
+
const prev = fiber.getRef(CurrentLogAnnotations);
|
|
2555
|
+
const next = {
|
|
2556
|
+
...prev
|
|
2557
|
+
};
|
|
2558
|
+
for (let i = 0; i < entries.length; i++) {
|
|
2559
|
+
const [key, value] = entries[i];
|
|
2560
|
+
next[key] = value;
|
|
2561
|
+
}
|
|
2562
|
+
fiber.setServices(ServiceMap.add(fiber.services, CurrentLogAnnotations, next));
|
|
2563
|
+
return scopeAddFinalizerExit(ServiceMap.getUnsafe(fiber.services, scopeTag), _ => {
|
|
2564
|
+
const current = fiber.getRef(CurrentLogAnnotations);
|
|
2565
|
+
const next = {
|
|
2566
|
+
...current
|
|
2567
|
+
};
|
|
2568
|
+
for (let i = 0; i < entries.length; i++) {
|
|
2569
|
+
const [key, value] = entries[i];
|
|
2570
|
+
if (current[key] !== value) continue;
|
|
2571
|
+
if (key in prev) {
|
|
2572
|
+
next[key] = prev[key];
|
|
2573
|
+
} else {
|
|
2574
|
+
delete next[key];
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
fiber.setServices(ServiceMap.add(fiber.services, CurrentLogAnnotations, next));
|
|
2578
|
+
return void_;
|
|
2579
|
+
});
|
|
2580
|
+
}));
|
|
2581
|
+
};
|
|
2582
|
+
/** @internal */
|
|
2568
2583
|
export const LoggerTypeId = "~effect/Logger";
|
|
2569
2584
|
const LoggerProto = {
|
|
2570
2585
|
[LoggerTypeId]: {
|