@effect-uai/core 0.5.2 → 0.6.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/README.md +1 -1
- package/dist/{Items-BH8xUkoR.d.mts → Items-pXR5BAgW.d.mts} +12 -12
- package/dist/Items-pXR5BAgW.d.mts.map +1 -0
- package/dist/SandboxError-BvKypkJm.d.mts +158 -0
- package/dist/SandboxError-BvKypkJm.d.mts.map +1 -0
- package/dist/{Tool-87ViKCCO.d.mts → Tool-DP-AwKOf.d.mts} +11 -11
- package/dist/{Tool-87ViKCCO.d.mts.map → Tool-DP-AwKOf.d.mts.map} +1 -1
- package/dist/domain/Items.d.mts +2 -2
- package/dist/domain/Items.mjs +15 -15
- package/dist/domain/Items.mjs.map +1 -1
- package/dist/domain/Turn.d.mts +388 -2
- package/dist/domain/Turn.d.mts.map +1 -0
- package/dist/domain/Turn.mjs +13 -13
- package/dist/domain/Turn.mjs.map +1 -1
- package/dist/index.d.mts +11 -6
- package/dist/index.mjs +8 -3
- package/dist/language-model/LanguageModel.d.mts +5 -5
- package/dist/language-model/LanguageModel.d.mts.map +1 -1
- package/dist/language-model/LanguageModel.mjs.map +1 -1
- package/dist/loop/Loop.d.mts +37 -90
- package/dist/loop/Loop.d.mts.map +1 -1
- package/dist/loop/Loop.mjs +39 -93
- package/dist/loop/Loop.mjs.map +1 -1
- package/dist/loop/Loop.test.mjs +46 -54
- package/dist/loop/Loop.test.mjs.map +1 -1
- package/dist/sandbox/Memory.d.mts +53 -0
- package/dist/sandbox/Memory.d.mts.map +1 -0
- package/dist/sandbox/Memory.mjs +68 -0
- package/dist/sandbox/Memory.mjs.map +1 -0
- package/dist/sandbox/Sandbox.d.mts +717 -0
- package/dist/sandbox/Sandbox.d.mts.map +1 -0
- package/dist/sandbox/Sandbox.mjs +192 -0
- package/dist/sandbox/Sandbox.mjs.map +1 -0
- package/dist/sandbox/SandboxError.d.mts +2 -0
- package/dist/sandbox/SandboxError.mjs +89 -0
- package/dist/sandbox/SandboxError.mjs.map +1 -0
- package/dist/sandbox/SandboxImage.d.mts +28 -0
- package/dist/sandbox/SandboxImage.d.mts.map +1 -0
- package/dist/sandbox/SandboxImage.mjs +32 -0
- package/dist/sandbox/SandboxImage.mjs.map +1 -0
- package/dist/sandbox/SandboxNetwork.d.mts +34 -0
- package/dist/sandbox/SandboxNetwork.d.mts.map +1 -0
- package/dist/sandbox/SandboxNetwork.mjs +36 -0
- package/dist/sandbox/SandboxNetwork.mjs.map +1 -0
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts +98 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.d.mts.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs +32 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.mjs.map +1 -1
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs +56 -2
- package/dist/speech-synthesizer/SpeechSynthesizer.test.mjs.map +1 -1
- package/dist/testing/MockProvider.d.mts +3 -3
- package/dist/testing/MockProvider.d.mts.map +1 -1
- package/dist/testing/MockProvider.mjs.map +1 -1
- package/dist/testing/MockSandbox.d.mts +604 -0
- package/dist/testing/MockSandbox.d.mts.map +1 -0
- package/dist/testing/MockSandbox.mjs +160 -0
- package/dist/testing/MockSandbox.mjs.map +1 -0
- package/dist/testing/MockSpeechSynthesizer.d.mts +26 -11
- package/dist/testing/MockSpeechSynthesizer.d.mts.map +1 -1
- package/dist/testing/MockSpeechSynthesizer.mjs +75 -51
- package/dist/testing/MockSpeechSynthesizer.mjs.map +1 -1
- package/dist/tool/{Resolvers.d.mts → Approval.d.mts} +27 -27
- package/dist/tool/Approval.d.mts.map +1 -0
- package/dist/tool/{Resolvers.mjs → Approval.mjs} +18 -18
- package/dist/tool/Approval.mjs.map +1 -0
- package/dist/tool/{Resolvers.test.mjs → Approval.test.mjs} +40 -40
- package/dist/tool/Approval.test.mjs.map +1 -0
- package/dist/tool/HistoryCheck.d.mts +6 -6
- package/dist/tool/HistoryCheck.d.mts.map +1 -1
- package/dist/tool/HistoryCheck.mjs +5 -5
- package/dist/tool/HistoryCheck.mjs.map +1 -1
- package/dist/tool/Tool.d.mts +2 -2
- package/dist/tool/Tool.mjs +4 -4
- package/dist/tool/Tool.mjs.map +1 -1
- package/dist/tool/ToolEvent.d.mts +19 -19
- package/dist/tool/ToolEvent.d.mts.map +1 -1
- package/dist/tool/ToolEvent.mjs +8 -8
- package/dist/tool/ToolEvent.mjs.map +1 -1
- package/dist/tool/{Outcome.d.mts → ToolResult.d.mts} +29 -29
- package/dist/tool/ToolResult.d.mts.map +1 -0
- package/dist/tool/ToolResult.mjs +61 -0
- package/dist/tool/ToolResult.mjs.map +1 -0
- package/dist/tool/Toolkit.d.mts +58 -26
- package/dist/tool/Toolkit.d.mts.map +1 -1
- package/dist/tool/Toolkit.mjs +62 -34
- package/dist/tool/Toolkit.mjs.map +1 -1
- package/dist/tool/Toolkit.test.mjs +13 -13
- package/dist/tool/Toolkit.test.mjs.map +1 -1
- package/package.json +31 -7
- package/src/domain/Items.ts +9 -9
- package/src/domain/Turn.ts +16 -16
- package/src/index.ts +7 -2
- package/src/language-model/LanguageModel.ts +3 -3
- package/src/loop/Loop.test.ts +93 -91
- package/src/loop/Loop.ts +72 -170
- package/src/sandbox/Memory.ts +128 -0
- package/src/sandbox/Sandbox.ts +639 -0
- package/src/sandbox/SandboxError.ts +140 -0
- package/src/sandbox/SandboxImage.ts +26 -0
- package/src/sandbox/SandboxNetwork.ts +34 -0
- package/src/speech-synthesizer/SpeechSynthesizer.test.ts +89 -0
- package/src/speech-synthesizer/SpeechSynthesizer.ts +124 -0
- package/src/testing/MockProvider.ts +21 -20
- package/src/testing/MockSandbox.ts +342 -0
- package/src/testing/MockSpeechSynthesizer.ts +137 -77
- package/src/tool/{Resolvers.test.ts → Approval.test.ts} +45 -54
- package/src/tool/{Resolvers.ts → Approval.ts} +25 -25
- package/src/tool/HistoryCheck.ts +10 -13
- package/src/tool/Tool.ts +13 -15
- package/src/tool/ToolEvent.ts +7 -7
- package/src/tool/{Outcome.ts → ToolResult.ts} +20 -20
- package/src/tool/Toolkit.test.ts +13 -13
- package/src/tool/Toolkit.ts +97 -73
- package/dist/Items-BH8xUkoR.d.mts.map +0 -1
- package/dist/Turn-0CwCAyVe.d.mts +0 -388
- package/dist/Turn-0CwCAyVe.d.mts.map +0 -1
- package/dist/tool/Outcome.d.mts.map +0 -1
- package/dist/tool/Outcome.mjs +0 -61
- package/dist/tool/Outcome.mjs.map +0 -1
- package/dist/tool/Resolvers.d.mts.map +0 -1
- package/dist/tool/Resolvers.mjs.map +0 -1
- package/dist/tool/Resolvers.test.mjs.map +0 -1
- /package/dist/tool/{Resolvers.test.d.mts → Approval.test.d.mts} +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { n as __exportAll } from "../chunk-uyGKjUfl.mjs";
|
|
2
|
+
import { Brand } from "effect";
|
|
3
|
+
//#region src/sandbox/Memory.ts
|
|
4
|
+
var Memory_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
bytes: () => bytes,
|
|
6
|
+
fromInputUnsafe: () => fromInputUnsafe,
|
|
7
|
+
gb: () => gb,
|
|
8
|
+
gib: () => gib,
|
|
9
|
+
kb: () => kb,
|
|
10
|
+
kib: () => kib,
|
|
11
|
+
mb: () => mb,
|
|
12
|
+
mib: () => mib,
|
|
13
|
+
toBytes: () => toBytes
|
|
14
|
+
});
|
|
15
|
+
const make = Brand.nominal();
|
|
16
|
+
const UNIT_BYTES = {
|
|
17
|
+
b: 1,
|
|
18
|
+
kb: 1e3,
|
|
19
|
+
mb: 1e6,
|
|
20
|
+
gb: 1e9,
|
|
21
|
+
tb: 0xe8d4a51000,
|
|
22
|
+
kib: 1024,
|
|
23
|
+
mib: 1024 * 1024,
|
|
24
|
+
gib: 1024 * 1024 * 1024,
|
|
25
|
+
tib: 1024 * 1024 * 1024 * 1024
|
|
26
|
+
};
|
|
27
|
+
const PARSE_RE = /^\s*(\d+(?:\.\d+)?)\s*([a-zA-Z]*)\s*$/;
|
|
28
|
+
const parseString = (s) => {
|
|
29
|
+
const m = PARSE_RE.exec(s);
|
|
30
|
+
if (m === null) throw new Error(`Memory: cannot parse "${s}" — expected forms like "1024", "10 MB", "1GiB"`);
|
|
31
|
+
const value = Number(m[1]);
|
|
32
|
+
const unit = (m[2] ?? "").toLowerCase();
|
|
33
|
+
if (unit === "") return value;
|
|
34
|
+
const factor = UNIT_BYTES[unit];
|
|
35
|
+
if (factor === void 0) throw new Error(`Memory: unknown unit "${m[2]}" in "${s}" — supported: ${Object.keys(UNIT_BYTES).join(", ")}`);
|
|
36
|
+
return value * factor;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Coerce a {@link Input} to a {@link Memory}. Throws on malformed
|
|
40
|
+
* strings or non-finite numbers. Mirrors `Duration.fromInputUnsafe`.
|
|
41
|
+
*/
|
|
42
|
+
const fromInputUnsafe = (input) => {
|
|
43
|
+
if (typeof input === "number") {
|
|
44
|
+
if (!Number.isFinite(input) || input < 0) throw new Error(`Memory: bytes must be a non-negative finite number, got ${input}`);
|
|
45
|
+
return make(Math.floor(input));
|
|
46
|
+
}
|
|
47
|
+
return make(Math.floor(parseString(input)));
|
|
48
|
+
};
|
|
49
|
+
/** Return the underlying byte count. */
|
|
50
|
+
const toBytes = (m) => typeof m === "number" && m === Math.floor(m) && m >= 0 ? m : fromInputUnsafe(m);
|
|
51
|
+
/** N bytes. */
|
|
52
|
+
const bytes = (n) => make(Math.floor(n));
|
|
53
|
+
/** N KiB (binary kibibytes, `n * 1024`). */
|
|
54
|
+
const kib = (n) => make(Math.floor(n * 1024));
|
|
55
|
+
/** N MiB (binary mebibytes, `n * 1024^2`). */
|
|
56
|
+
const mib = (n) => make(Math.floor(n * 1024 * 1024));
|
|
57
|
+
/** N GiB (binary gibibytes, `n * 1024^3`). */
|
|
58
|
+
const gib = (n) => make(Math.floor(n * 1024 * 1024 * 1024));
|
|
59
|
+
/** N kB (decimal kilobytes, `n * 1000`). */
|
|
60
|
+
const kb = (n) => make(Math.floor(n * 1e3));
|
|
61
|
+
/** N MB (decimal megabytes, `n * 1_000_000`). */
|
|
62
|
+
const mb = (n) => make(Math.floor(n * 1e6));
|
|
63
|
+
/** N GB (decimal gigabytes, `n * 1_000_000_000`). */
|
|
64
|
+
const gb = (n) => make(Math.floor(n * 1e9));
|
|
65
|
+
//#endregion
|
|
66
|
+
export { bytes, fromInputUnsafe, gb, gib, kb, kib, mb, mib, Memory_exports as t, toBytes };
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=Memory.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Memory.mjs","names":[],"sources":["../../src/sandbox/Memory.ts"],"sourcesContent":["import { Brand } from \"effect\"\n\n/**\n * A memory / data size, always represented internally as a number of\n * bytes. Mirrors the `Duration` shape from `effect` — a branded value\n * type with a wider `Input` union for ergonomic construction at call\n * sites.\n *\n * `effect` itself has no byte-count primitive (only `Duration`), so we\n * own this here rather than leak provider-specific shapes (Deno's\n * template-literal `Memory`, Vercel's `mb`, Modal's `gpuMemory`, …)\n * through the cross-provider `Sandbox` request types.\n *\n * @example\n * ```ts\n * import * as Memory from \"@effect-uai/core/Memory\"\n *\n * Memory.gib(2) // 2 GiB → 2_147_483_648 bytes\n * Memory.fromInputUnsafe(\"1.5 GiB\") // human-string parsing\n * Memory.fromInputUnsafe(1_280_000_000) // raw bytes\n * Memory.toBytes(m) // unwrap\n * ```\n */\n\nexport type Memory = Brand.Branded<number, \"Memory\">\n\nconst make = Brand.nominal<Memory>()\n\n// ---------------------------------------------------------------------------\n// Input — what the public APIs accept.\n//\n// Supported string forms (case-insensitive on the unit, whitespace\n// optional between number and unit):\n//\n// \"<n>\" bytes (no unit)\n// \"<n> B\" bytes\n// \"<n> kB\" 1_000 bytes (decimal)\n// \"<n> MB\" 1_000_000 (decimal)\n// \"<n> GB\" 1_000_000_000 (decimal)\n// \"<n> KiB\" 1_024 (binary)\n// \"<n> MiB\" 1_048_576 (binary)\n// \"<n> GiB\" 1_073_741_824 (binary)\n//\n// Decimal vs binary follows the SI / IEC convention (`MB` = 10^6,\n// `MiB` = 2^20). When in doubt, prefer the binary `*iB` units.\n// ---------------------------------------------------------------------------\n\nexport type Input = number | Memory | string\n\nconst UNIT_BYTES: Record<string, number> = {\n b: 1,\n kb: 1_000,\n mb: 1_000_000,\n gb: 1_000_000_000,\n tb: 1_000_000_000_000,\n kib: 1_024,\n mib: 1_024 * 1_024,\n gib: 1_024 * 1_024 * 1_024,\n tib: 1_024 * 1_024 * 1_024 * 1_024,\n}\n\nconst PARSE_RE = /^\\s*(\\d+(?:\\.\\d+)?)\\s*([a-zA-Z]*)\\s*$/\n\nconst parseString = (s: string): number => {\n const m = PARSE_RE.exec(s)\n if (m === null) {\n throw new Error(`Memory: cannot parse \"${s}\" — expected forms like \"1024\", \"10 MB\", \"1GiB\"`)\n }\n const value = Number(m[1])\n const unit = (m[2] ?? \"\").toLowerCase()\n if (unit === \"\") return value\n const factor = UNIT_BYTES[unit]\n if (factor === undefined) {\n throw new Error(\n `Memory: unknown unit \"${m[2]}\" in \"${s}\" — supported: ${Object.keys(UNIT_BYTES).join(\", \")}`,\n )\n }\n return value * factor\n}\n\n/**\n * Coerce a {@link Input} to a {@link Memory}. Throws on malformed\n * strings or non-finite numbers. Mirrors `Duration.fromInputUnsafe`.\n */\nexport const fromInputUnsafe = (input: Input): Memory => {\n if (typeof input === \"number\") {\n if (!Number.isFinite(input) || input < 0) {\n throw new Error(`Memory: bytes must be a non-negative finite number, got ${input}`)\n }\n return make(Math.floor(input))\n }\n return make(Math.floor(parseString(input)))\n}\n\n// ---------------------------------------------------------------------------\n// Unwrap\n// ---------------------------------------------------------------------------\n\n/** Return the underlying byte count. */\nexport const toBytes = (m: Memory | Input): number =>\n typeof m === \"number\" && (m as number) === Math.floor(m as number) && (m as number) >= 0\n ? (m as number)\n : (fromInputUnsafe(m) as unknown as number)\n\n// ---------------------------------------------------------------------------\n// Unit constructors — terse for use at call sites.\n// ---------------------------------------------------------------------------\n\n/** N bytes. */\nexport const bytes = (n: number): Memory => make(Math.floor(n))\n\n/** N KiB (binary kibibytes, `n * 1024`). */\nexport const kib = (n: number): Memory => make(Math.floor(n * 1_024))\n\n/** N MiB (binary mebibytes, `n * 1024^2`). */\nexport const mib = (n: number): Memory => make(Math.floor(n * 1_024 * 1_024))\n\n/** N GiB (binary gibibytes, `n * 1024^3`). */\nexport const gib = (n: number): Memory => make(Math.floor(n * 1_024 * 1_024 * 1_024))\n\n/** N kB (decimal kilobytes, `n * 1000`). */\nexport const kb = (n: number): Memory => make(Math.floor(n * 1_000))\n\n/** N MB (decimal megabytes, `n * 1_000_000`). */\nexport const mb = (n: number): Memory => make(Math.floor(n * 1_000_000))\n\n/** N GB (decimal gigabytes, `n * 1_000_000_000`). */\nexport const gb = (n: number): Memory => make(Math.floor(n * 1_000_000_000))\n"],"mappings":";;;;;;;;;;;;;;AA0BA,MAAM,OAAO,MAAM,SAAiB;AAuBpC,MAAM,aAAqC;CACzC,GAAG;CACH,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,KAAK;CACL,KAAK,OAAQ;CACb,KAAK,OAAQ,OAAQ;CACrB,KAAK,OAAQ,OAAQ,OAAQ;CAC9B;AAED,MAAM,WAAW;AAEjB,MAAM,eAAe,MAAsB;CACzC,MAAM,IAAI,SAAS,KAAK,EAAE;AAC1B,KAAI,MAAM,KACR,OAAM,IAAI,MAAM,yBAAyB,EAAE,iDAAiD;CAE9F,MAAM,QAAQ,OAAO,EAAE,GAAG;CAC1B,MAAM,QAAQ,EAAE,MAAM,IAAI,aAAa;AACvC,KAAI,SAAS,GAAI,QAAO;CACxB,MAAM,SAAS,WAAW;AAC1B,KAAI,WAAW,KAAA,EACb,OAAM,IAAI,MACR,yBAAyB,EAAE,GAAG,QAAQ,EAAE,iBAAiB,OAAO,KAAK,WAAW,CAAC,KAAK,KAAK,GAC5F;AAEH,QAAO,QAAQ;;;;;;AAOjB,MAAa,mBAAmB,UAAyB;AACvD,KAAI,OAAO,UAAU,UAAU;AAC7B,MAAI,CAAC,OAAO,SAAS,MAAM,IAAI,QAAQ,EACrC,OAAM,IAAI,MAAM,2DAA2D,QAAQ;AAErF,SAAO,KAAK,KAAK,MAAM,MAAM,CAAC;;AAEhC,QAAO,KAAK,KAAK,MAAM,YAAY,MAAM,CAAC,CAAC;;;AAQ7C,MAAa,WAAW,MACtB,OAAO,MAAM,YAAa,MAAiB,KAAK,MAAM,EAAY,IAAK,KAAgB,IAClF,IACA,gBAAgB,EAAE;;AAOzB,MAAa,SAAS,MAAsB,KAAK,KAAK,MAAM,EAAE,CAAC;;AAG/D,MAAa,OAAO,MAAsB,KAAK,KAAK,MAAM,IAAI,KAAM,CAAC;;AAGrE,MAAa,OAAO,MAAsB,KAAK,KAAK,MAAM,IAAI,OAAQ,KAAM,CAAC;;AAG7E,MAAa,OAAO,MAAsB,KAAK,KAAK,MAAM,IAAI,OAAQ,OAAQ,KAAM,CAAC;;AAGrF,MAAa,MAAM,MAAsB,KAAK,KAAK,MAAM,IAAI,IAAM,CAAC;;AAGpE,MAAa,MAAM,MAAsB,KAAK,KAAK,MAAM,IAAI,IAAU,CAAC;;AAGxE,MAAa,MAAM,MAAsB,KAAK,KAAK,MAAM,IAAI,IAAc,CAAC"}
|