theorum 0.1.4 → 0.1.5
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/esm/_dnt.polyfills.d.ts +110 -0
- package/esm/_dnt.polyfills.js +144 -0
- package/esm/_dnt.shims.d.ts +5 -0
- package/esm/_dnt.shims.js +61 -0
- package/{mod.ts → esm/mod.d.ts} +17 -57
- package/esm/mod.js +50 -0
- package/esm/package.json +3 -0
- package/esm/src/cli/commands/profile.d.ts +2 -0
- package/esm/src/cli/commands/profile.js +53 -0
- package/esm/src/cli/commands/run.d.ts +10 -0
- package/esm/src/cli/commands/run.js +55 -0
- package/esm/src/cli/commands/test.d.ts +15 -0
- package/esm/src/cli/commands/test.js +140 -0
- package/esm/src/cli/index.d.ts +4 -0
- package/esm/src/cli/index.js +148 -0
- package/esm/src/cli/matrix/fixtures.d.ts +13 -0
- package/esm/src/cli/matrix/fixtures.js +77 -0
- package/esm/src/cli/matrix/synthesizer.d.ts +29 -0
- package/esm/src/cli/matrix/synthesizer.js +187 -0
- package/esm/src/guardrails/error.d.ts +45 -0
- package/esm/src/guardrails/error.js +149 -0
- package/esm/src/guardrails/injection.d.ts +12 -0
- package/esm/src/guardrails/injection.js +220 -0
- package/esm/src/guardrails/mod.d.ts +16 -0
- package/esm/src/guardrails/mod.js +15 -0
- package/esm/src/guardrails/quota.d.ts +10 -0
- package/esm/src/guardrails/quota.js +64 -0
- package/esm/src/guardrails/sanitize.d.ts +22 -0
- package/esm/src/guardrails/sanitize.js +133 -0
- package/esm/src/guardrails/sensitive.d.ts +12 -0
- package/esm/src/guardrails/sensitive.js +88 -0
- package/esm/src/host/mint-trace.d.ts +27 -0
- package/esm/src/host/mint-trace.js +33 -0
- package/esm/src/host/mod.d.ts +13 -0
- package/{src/host/mod.ts → esm/src/host/mod.js} +3 -11
- package/esm/src/host/reply.d.ts +14 -0
- package/esm/src/host/reply.js +27 -0
- package/esm/src/kernel/engine/boundary.d.ts +10 -0
- package/esm/src/kernel/engine/boundary.js +55 -0
- package/esm/src/kernel/engine/delta.d.ts +8 -0
- package/esm/src/kernel/engine/delta.js +389 -0
- package/esm/src/kernel/engine/hash.d.ts +1 -0
- package/esm/src/kernel/engine/hash.js +9 -0
- package/esm/src/kernel/engine/record.d.ts +2 -0
- package/esm/src/kernel/engine/record.js +7 -0
- package/esm/src/kernel/engine/repair.d.ts +7 -0
- package/esm/src/kernel/engine/repair.js +38 -0
- package/esm/src/kernel/engine/runner/gates.d.ts +4 -0
- package/esm/src/kernel/engine/runner/gates.js +203 -0
- package/esm/src/kernel/engine/runner/mod.d.ts +14 -0
- package/esm/src/kernel/engine/runner/mod.js +109 -0
- package/esm/src/kernel/engine/runner/state.d.ts +16 -0
- package/esm/src/kernel/engine/runner/state.js +8 -0
- package/esm/src/kernel/engine/runner/steps.d.ts +15 -0
- package/esm/src/kernel/engine/runner/steps.js +119 -0
- package/esm/src/kernel/engine/runner/stream.d.ts +11 -0
- package/esm/src/kernel/engine/runner/stream.js +70 -0
- package/esm/src/kernel/engine/runner/tokens.d.ts +3 -0
- package/esm/src/kernel/engine/runner/tokens.js +38 -0
- package/esm/src/kernel/engine/runner/tools.d.ts +13 -0
- package/esm/src/kernel/engine/runner/tools.js +192 -0
- package/{src/kernel/engine/runner.ts → esm/src/kernel/engine/runner.d.ts} +1 -2
- package/esm/src/kernel/engine/runner.js +6 -0
- package/esm/src/kernel/engine/tree.d.ts +2 -0
- package/esm/src/kernel/engine/tree.js +17 -0
- package/esm/src/kernel/mod.d.ts +18 -0
- package/esm/src/kernel/mod.js +16 -0
- package/esm/src/kernel/registry/attachments.d.ts +16 -0
- package/esm/src/kernel/registry/attachments.js +156 -0
- package/esm/src/kernel/registry/catalog.d.ts +31 -0
- package/esm/src/kernel/registry/catalog.js +135 -0
- package/esm/src/kernel/registry/ingress.d.ts +13 -0
- package/esm/src/kernel/registry/ingress.js +163 -0
- package/esm/src/kernel/registry/profiles.d.ts +34 -0
- package/esm/src/kernel/registry/profiles.js +120 -0
- package/esm/src/kernel/registry/provider-request.d.ts +4 -0
- package/esm/src/kernel/registry/provider-request.js +25 -0
- package/esm/src/kernel/registry/resolve.d.ts +19 -0
- package/esm/src/kernel/registry/resolve.js +217 -0
- package/esm/src/kernel/registry/schemas.d.ts +14 -0
- package/esm/src/kernel/registry/schemas.js +23 -0
- package/esm/src/kernel/registry/tools.d.ts +12 -0
- package/esm/src/kernel/registry/tools.js +36 -0
- package/{src/kernel/registry/vault.ts → esm/src/kernel/registry/vault.d.ts} +2 -17
- package/esm/src/kernel/registry/vault.js +18 -0
- package/esm/src/kernel/types.d.ts +524 -0
- package/esm/src/kernel/types.js +10 -0
- package/esm/src/observability/mod.d.ts +12 -0
- package/{src/observability/mod.ts → esm/src/observability/mod.js} +2 -11
- package/esm/src/observability/spans.d.ts +16 -0
- package/esm/src/observability/spans.js +56 -0
- package/esm/src/observability/trace-attach.d.ts +16 -0
- package/esm/src/observability/trace-attach.js +67 -0
- package/esm/src/observability/trace-record.d.ts +113 -0
- package/esm/src/observability/trace-record.js +143 -0
- package/esm/src/observability/trace-usage.d.ts +3 -0
- package/esm/src/observability/trace-usage.js +32 -0
- package/esm/src/observability/trace.d.ts +23 -0
- package/esm/src/observability/trace.js +121 -0
- package/esm/src/presets/google.d.ts +50 -0
- package/esm/src/presets/google.js +96 -0
- package/esm/src/presets/mod.d.ts +11 -0
- package/esm/src/presets/mod.js +10 -0
- package/esm/src/providers/create-provider.d.ts +29 -0
- package/esm/src/providers/create-provider.js +38 -0
- package/esm/src/providers/gemini-tape.d.ts +2 -0
- package/esm/src/providers/gemini-tape.js +46 -0
- package/esm/src/providers/google-tap.d.ts +3 -0
- package/esm/src/providers/google-tap.js +48 -0
- package/esm/src/providers/interactions.d.ts +5 -0
- package/esm/src/providers/interactions.js +153 -0
- package/esm/src/providers/keys.d.ts +19 -0
- package/esm/src/providers/keys.js +129 -0
- package/esm/src/providers/mod.d.ts +12 -0
- package/{src/providers/mod.ts → esm/src/providers/mod.js} +2 -4
- package/esm/src/providers/openrouter-mod.d.ts +13 -0
- package/{src/providers/openrouter-mod.ts → esm/src/providers/openrouter-mod.js} +3 -7
- package/esm/src/providers/openrouter-payload.d.ts +32 -0
- package/esm/src/providers/openrouter-payload.js +179 -0
- package/esm/src/providers/openrouter.d.ts +15 -0
- package/esm/src/providers/openrouter.js +589 -0
- package/esm/src/providers/pcm.d.ts +7 -0
- package/esm/src/providers/pcm.js +35 -0
- package/esm/src/providers/provider.d.ts +15 -0
- package/esm/src/providers/provider.js +160 -0
- package/esm/src/providers/speech.d.ts +23 -0
- package/esm/src/providers/speech.js +125 -0
- package/esm/src/providers/sse.d.ts +7 -0
- package/esm/src/providers/sse.js +53 -0
- package/package.json +45 -36
- package/deno.json +0 -57
- package/deno.lock +0 -469
- package/src/cli/commands/profile.ts +0 -57
- package/src/cli/commands/run.ts +0 -66
- package/src/cli/commands/test.ts +0 -195
- package/src/cli/index.ts +0 -161
- package/src/cli/matrix/fixtures.ts +0 -96
- package/src/cli/matrix/synthesizer.ts +0 -240
- package/src/guardrails/error.ts +0 -142
- package/src/guardrails/injection.ts +0 -254
- package/src/guardrails/mod.ts +0 -40
- package/src/guardrails/quota.ts +0 -87
- package/src/guardrails/sanitize.ts +0 -165
- package/src/guardrails/sensitive.ts +0 -96
- package/src/host/mint-trace.ts +0 -54
- package/src/host/reply.ts +0 -32
- package/src/kernel/engine/assert.ts +0 -29
- package/src/kernel/engine/boundary.ts +0 -75
- package/src/kernel/engine/delta.ts +0 -440
- package/src/kernel/engine/hash.ts +0 -11
- package/src/kernel/engine/record.ts +0 -8
- package/src/kernel/engine/repair.ts +0 -56
- package/src/kernel/engine/runner/gates.ts +0 -338
- package/src/kernel/engine/runner/mod.ts +0 -135
- package/src/kernel/engine/runner/state.ts +0 -31
- package/src/kernel/engine/runner/steps.ts +0 -183
- package/src/kernel/engine/runner/stream.ts +0 -83
- package/src/kernel/engine/runner/tokens.ts +0 -47
- package/src/kernel/engine/runner/tools.ts +0 -266
- package/src/kernel/engine/tree.ts +0 -18
- package/src/kernel/mod.ts +0 -39
- package/src/kernel/registry/attachments.ts +0 -195
- package/src/kernel/registry/catalog.ts +0 -181
- package/src/kernel/registry/ingress.ts +0 -223
- package/src/kernel/registry/profiles.ts +0 -165
- package/src/kernel/registry/provider-request.ts +0 -31
- package/src/kernel/registry/resolve.ts +0 -290
- package/src/kernel/registry/schemas.ts +0 -29
- package/src/kernel/registry/tools.ts +0 -45
- package/src/kernel/types.ts +0 -576
- package/src/observability/spans.ts +0 -70
- package/src/observability/trace-attach.ts +0 -96
- package/src/observability/trace-record.ts +0 -254
- package/src/observability/trace-usage.ts +0 -36
- package/src/observability/trace.ts +0 -143
- package/src/presets/google.ts +0 -147
- package/src/presets/mod.ts +0 -24
- package/src/providers/create-provider.ts +0 -64
- package/src/providers/gemini-tape.ts +0 -59
- package/src/providers/google-tap.ts +0 -57
- package/src/providers/interactions.ts +0 -182
- package/src/providers/keys.ts +0 -182
- package/src/providers/openrouter-payload.ts +0 -232
- package/src/providers/openrouter.ts +0 -758
- package/src/providers/pcm.ts +0 -37
- package/src/providers/provider.ts +0 -206
- package/src/providers/speech.ts +0 -180
- package/src/providers/sse.ts +0 -59
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Object {
|
|
3
|
+
/**
|
|
4
|
+
* Determines whether an object has a property with the specified name.
|
|
5
|
+
* @param o An object.
|
|
6
|
+
* @param v A property name.
|
|
7
|
+
*/
|
|
8
|
+
hasOwn(o: object, v: PropertyKey): boolean;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
export {};
|
|
12
|
+
/**
|
|
13
|
+
* Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
|
|
14
|
+
* but instead of using npm to install additional dependencies,
|
|
15
|
+
* this approach manually consolidates cjs/mjs/d.ts into a single file.
|
|
16
|
+
*
|
|
17
|
+
* Note that this code might be imported multiple times
|
|
18
|
+
* (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
|
|
19
|
+
* or Node.js might dynamically clear the cache and then force a require).
|
|
20
|
+
* Therefore, it's important to avoid redundant writes to global objects.
|
|
21
|
+
* Additionally, consider that commonjs is used alongside esm,
|
|
22
|
+
* so the two ponyfill functions are stored independently in two separate global objects.
|
|
23
|
+
*/
|
|
24
|
+
import { createRequire } from "node:module";
|
|
25
|
+
import { type URL } from "node:url";
|
|
26
|
+
declare global {
|
|
27
|
+
interface ImportMeta {
|
|
28
|
+
/** A string representation of the fully qualified module URL. When the
|
|
29
|
+
* module is loaded locally, the value will be a file URL (e.g.
|
|
30
|
+
* `file:///path/module.ts`).
|
|
31
|
+
*
|
|
32
|
+
* You can also parse the string as a URL to determine more information about
|
|
33
|
+
* how the current module was loaded. For example to determine if a module was
|
|
34
|
+
* local or not:
|
|
35
|
+
*
|
|
36
|
+
* ```ts
|
|
37
|
+
* const url = new URL(import.meta.url);
|
|
38
|
+
* if (url.protocol === "file:") {
|
|
39
|
+
* console.log("this module was loaded locally");
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
url: string;
|
|
44
|
+
/**
|
|
45
|
+
* A function that returns resolved specifier as if it would be imported
|
|
46
|
+
* using `import(specifier)`.
|
|
47
|
+
*
|
|
48
|
+
* ```ts
|
|
49
|
+
* console.log(import.meta.resolve("./foo.js"));
|
|
50
|
+
* // file:///dev/foo.js
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @param specifier The module specifier to resolve relative to `parent`.
|
|
54
|
+
* @param parent The absolute parent module URL to resolve from.
|
|
55
|
+
* @returns The absolute (`file:`) URL string for the resolved module.
|
|
56
|
+
*/
|
|
57
|
+
resolve(specifier: string, parent?: string | URL | undefined): string;
|
|
58
|
+
/** A flag that indicates if the current module is the main module that was
|
|
59
|
+
* called when starting the program under Deno.
|
|
60
|
+
*
|
|
61
|
+
* ```ts
|
|
62
|
+
* if (import.meta.main) {
|
|
63
|
+
* // this was loaded as the main module, maybe do some bootstrapping
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
main: boolean;
|
|
68
|
+
/** The absolute path of the current module.
|
|
69
|
+
*
|
|
70
|
+
* This property is only provided for local modules (ie. using `file://` URLs).
|
|
71
|
+
*
|
|
72
|
+
* Example:
|
|
73
|
+
* ```
|
|
74
|
+
* // Unix
|
|
75
|
+
* console.log(import.meta.filename); // /home/alice/my_module.ts
|
|
76
|
+
*
|
|
77
|
+
* // Windows
|
|
78
|
+
* console.log(import.meta.filename); // C:\alice\my_module.ts
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
filename: string;
|
|
82
|
+
/** The absolute path of the directory containing the current module.
|
|
83
|
+
*
|
|
84
|
+
* This property is only provided for local modules (ie. using `file://` URLs).
|
|
85
|
+
*
|
|
86
|
+
* * Example:
|
|
87
|
+
* ```
|
|
88
|
+
* // Unix
|
|
89
|
+
* console.log(import.meta.dirname); // /home/alice
|
|
90
|
+
*
|
|
91
|
+
* // Windows
|
|
92
|
+
* console.log(import.meta.dirname); // C:\alice
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
dirname: string;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
type NodeRequest = ReturnType<typeof createRequire>;
|
|
99
|
+
type NodeModule = NonNullable<NodeRequest["main"]>;
|
|
100
|
+
interface ImportMetaPonyfillCommonjs {
|
|
101
|
+
(require: NodeRequest, module: NodeModule): ImportMeta;
|
|
102
|
+
}
|
|
103
|
+
interface ImportMetaPonyfillEsmodule {
|
|
104
|
+
(importMeta: ImportMeta): ImportMeta;
|
|
105
|
+
}
|
|
106
|
+
interface ImportMetaPonyfill extends ImportMetaPonyfillCommonjs, ImportMetaPonyfillEsmodule {
|
|
107
|
+
}
|
|
108
|
+
export declare let import_meta_ponyfill_commonjs: ImportMetaPonyfillCommonjs;
|
|
109
|
+
export declare let import_meta_ponyfill_esmodule: ImportMetaPonyfillEsmodule;
|
|
110
|
+
export declare let import_meta_ponyfill: ImportMetaPonyfill;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// https://github.com/tc39/proposal-accessible-object-hasownproperty/blob/main/polyfill.js
|
|
2
|
+
if (!Object.hasOwn) {
|
|
3
|
+
Object.defineProperty(Object, "hasOwn", {
|
|
4
|
+
value: function (object, property) {
|
|
5
|
+
if (object == null) {
|
|
6
|
+
throw new TypeError("Cannot convert undefined or null to object");
|
|
7
|
+
}
|
|
8
|
+
return Object.prototype.hasOwnProperty.call(Object(object), property);
|
|
9
|
+
},
|
|
10
|
+
configurable: true,
|
|
11
|
+
enumerable: false,
|
|
12
|
+
writable: true,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
|
|
17
|
+
* but instead of using npm to install additional dependencies,
|
|
18
|
+
* this approach manually consolidates cjs/mjs/d.ts into a single file.
|
|
19
|
+
*
|
|
20
|
+
* Note that this code might be imported multiple times
|
|
21
|
+
* (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
|
|
22
|
+
* or Node.js might dynamically clear the cache and then force a require).
|
|
23
|
+
* Therefore, it's important to avoid redundant writes to global objects.
|
|
24
|
+
* Additionally, consider that commonjs is used alongside esm,
|
|
25
|
+
* so the two ponyfill functions are stored independently in two separate global objects.
|
|
26
|
+
*/
|
|
27
|
+
//@ts-ignore
|
|
28
|
+
import { createRequire } from "node:module";
|
|
29
|
+
//@ts-ignore
|
|
30
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
31
|
+
//@ts-ignore
|
|
32
|
+
import { dirname } from "node:path";
|
|
33
|
+
const defineGlobalPonyfill = (symbolFor, fn) => {
|
|
34
|
+
if (!Reflect.has(globalThis, Symbol.for(symbolFor))) {
|
|
35
|
+
Object.defineProperty(globalThis, Symbol.for(symbolFor), {
|
|
36
|
+
configurable: true,
|
|
37
|
+
get() {
|
|
38
|
+
return fn;
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export let import_meta_ponyfill_commonjs = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-commonjs")) ??
|
|
44
|
+
(() => {
|
|
45
|
+
const moduleImportMetaWM = new WeakMap();
|
|
46
|
+
return (require, module) => {
|
|
47
|
+
let importMetaCache = moduleImportMetaWM.get(module);
|
|
48
|
+
if (importMetaCache == null) {
|
|
49
|
+
const importMeta = Object.assign(Object.create(null), {
|
|
50
|
+
url: pathToFileURL(module.filename).href,
|
|
51
|
+
main: require.main == module,
|
|
52
|
+
resolve: (specifier, parentURL = importMeta.url) => {
|
|
53
|
+
return pathToFileURL((importMeta.url === parentURL
|
|
54
|
+
? require
|
|
55
|
+
: createRequire(parentURL))
|
|
56
|
+
.resolve(specifier)).href;
|
|
57
|
+
},
|
|
58
|
+
filename: module.filename,
|
|
59
|
+
dirname: module.path,
|
|
60
|
+
});
|
|
61
|
+
moduleImportMetaWM.set(module, importMeta);
|
|
62
|
+
importMetaCache = importMeta;
|
|
63
|
+
}
|
|
64
|
+
return importMetaCache;
|
|
65
|
+
};
|
|
66
|
+
})());
|
|
67
|
+
defineGlobalPonyfill("import-meta-ponyfill-commonjs", import_meta_ponyfill_commonjs);
|
|
68
|
+
export let import_meta_ponyfill_esmodule = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-esmodule")) ??
|
|
69
|
+
((importMeta) => {
|
|
70
|
+
const resolveFunStr = String(importMeta.resolve);
|
|
71
|
+
const shimWs = new WeakSet();
|
|
72
|
+
//@ts-ignore
|
|
73
|
+
const mainUrl = ("file:///" + process.argv[1].replace(/\\/g, "/"))
|
|
74
|
+
.replace(/\/{3,}/, "///");
|
|
75
|
+
const commonShim = (importMeta) => {
|
|
76
|
+
if (typeof importMeta.main !== "boolean") {
|
|
77
|
+
importMeta.main = importMeta.url === mainUrl;
|
|
78
|
+
}
|
|
79
|
+
if (typeof importMeta.filename !== "string") {
|
|
80
|
+
importMeta.filename = fileURLToPath(importMeta.url);
|
|
81
|
+
importMeta.dirname = dirname(importMeta.filename);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
if (
|
|
85
|
+
// v16.2.0+, v14.18.0+: Add support for WHATWG URL object to parentURL parameter.
|
|
86
|
+
resolveFunStr === "undefined" ||
|
|
87
|
+
// v20.0.0+, v18.19.0+"" This API now returns a string synchronously instead of a Promise.
|
|
88
|
+
resolveFunStr.startsWith("async")
|
|
89
|
+
// enable by --experimental-import-meta-resolve flag
|
|
90
|
+
) {
|
|
91
|
+
import_meta_ponyfill_esmodule = (importMeta) => {
|
|
92
|
+
if (!shimWs.has(importMeta)) {
|
|
93
|
+
shimWs.add(importMeta);
|
|
94
|
+
const importMetaUrlRequire = {
|
|
95
|
+
url: importMeta.url,
|
|
96
|
+
require: createRequire(importMeta.url),
|
|
97
|
+
};
|
|
98
|
+
// note: the parameter types must be explicitly annotated because
|
|
99
|
+
// `@types/node` also declares `ImportMeta.resolve`, which makes
|
|
100
|
+
// the contextual type an overload set that provides no inference
|
|
101
|
+
importMeta.resolve = function resolve(specifier, parentURL = importMeta.url) {
|
|
102
|
+
return pathToFileURL((importMetaUrlRequire.url === parentURL
|
|
103
|
+
? importMetaUrlRequire.require
|
|
104
|
+
: createRequire(parentURL)).resolve(specifier)).href;
|
|
105
|
+
};
|
|
106
|
+
commonShim(importMeta);
|
|
107
|
+
}
|
|
108
|
+
return importMeta;
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
/// native support
|
|
113
|
+
import_meta_ponyfill_esmodule = (importMeta) => {
|
|
114
|
+
if (!shimWs.has(importMeta)) {
|
|
115
|
+
shimWs.add(importMeta);
|
|
116
|
+
commonShim(importMeta);
|
|
117
|
+
}
|
|
118
|
+
return importMeta;
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return import_meta_ponyfill_esmodule(importMeta);
|
|
122
|
+
}));
|
|
123
|
+
defineGlobalPonyfill("import-meta-ponyfill-esmodule", import_meta_ponyfill_esmodule);
|
|
124
|
+
export let import_meta_ponyfill = ((...args) => {
|
|
125
|
+
const _MODULE = (() => {
|
|
126
|
+
if (typeof require === "function" && typeof module === "object") {
|
|
127
|
+
return "commonjs";
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
// eval("typeof import.meta");
|
|
131
|
+
return "esmodule";
|
|
132
|
+
}
|
|
133
|
+
})();
|
|
134
|
+
if (_MODULE === "commonjs") {
|
|
135
|
+
//@ts-ignore
|
|
136
|
+
import_meta_ponyfill = (r, m) => import_meta_ponyfill_commonjs(r, m);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
//@ts-ignore
|
|
140
|
+
import_meta_ponyfill = (im) => import_meta_ponyfill_esmodule(im);
|
|
141
|
+
}
|
|
142
|
+
//@ts-ignore
|
|
143
|
+
return import_meta_ponyfill(...args);
|
|
144
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Deno } from "@deno/shim-deno";
|
|
2
|
+
export { Deno } from "@deno/shim-deno";
|
|
3
|
+
const dntGlobals = {
|
|
4
|
+
Deno,
|
|
5
|
+
};
|
|
6
|
+
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
7
|
+
function createMergeProxy(baseObj, extObj) {
|
|
8
|
+
return new Proxy(baseObj, {
|
|
9
|
+
get(_target, prop, _receiver) {
|
|
10
|
+
if (prop in extObj) {
|
|
11
|
+
return extObj[prop];
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
return baseObj[prop];
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
set(_target, prop, value) {
|
|
18
|
+
if (prop in extObj) {
|
|
19
|
+
delete extObj[prop];
|
|
20
|
+
}
|
|
21
|
+
baseObj[prop] = value;
|
|
22
|
+
return true;
|
|
23
|
+
},
|
|
24
|
+
deleteProperty(_target, prop) {
|
|
25
|
+
let success = false;
|
|
26
|
+
if (prop in extObj) {
|
|
27
|
+
delete extObj[prop];
|
|
28
|
+
success = true;
|
|
29
|
+
}
|
|
30
|
+
if (prop in baseObj) {
|
|
31
|
+
delete baseObj[prop];
|
|
32
|
+
success = true;
|
|
33
|
+
}
|
|
34
|
+
return success;
|
|
35
|
+
},
|
|
36
|
+
ownKeys(_target) {
|
|
37
|
+
const baseKeys = Reflect.ownKeys(baseObj);
|
|
38
|
+
const extKeys = Reflect.ownKeys(extObj);
|
|
39
|
+
const extKeysSet = new Set(extKeys);
|
|
40
|
+
return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
|
|
41
|
+
},
|
|
42
|
+
defineProperty(_target, prop, desc) {
|
|
43
|
+
if (prop in extObj) {
|
|
44
|
+
delete extObj[prop];
|
|
45
|
+
}
|
|
46
|
+
Reflect.defineProperty(baseObj, prop, desc);
|
|
47
|
+
return true;
|
|
48
|
+
},
|
|
49
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
50
|
+
if (prop in extObj) {
|
|
51
|
+
return Reflect.getOwnPropertyDescriptor(extObj, prop);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
return Reflect.getOwnPropertyDescriptor(baseObj, prop);
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
has(_target, prop) {
|
|
58
|
+
return prop in extObj || prop in baseObj;
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
package/{mod.ts → esm/mod.d.ts}
RENAMED
|
@@ -36,60 +36,20 @@
|
|
|
36
36
|
*
|
|
37
37
|
* @module
|
|
38
38
|
*/
|
|
39
|
-
|
|
40
|
-
export { publicError, TheorumError } from './src/guardrails/error.
|
|
41
|
-
export type { QuotaSlotStatus } from './src/guardrails/quota.
|
|
42
|
-
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
} from './src/
|
|
50
|
-
export {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
} from './src/
|
|
56
|
-
export { runTurn } from './src/kernel/engine/runner.ts';
|
|
57
|
-
export {
|
|
58
|
-
CATALOG,
|
|
59
|
-
clampThinkingLevel,
|
|
60
|
-
clampThinkingLevelForApiId,
|
|
61
|
-
geminiKindForMime,
|
|
62
|
-
getTool,
|
|
63
|
-
listBuiltinIds,
|
|
64
|
-
mimeAllowed,
|
|
65
|
-
mimeEssence,
|
|
66
|
-
modelEntryByApiId,
|
|
67
|
-
registerTools,
|
|
68
|
-
requireModelSpec,
|
|
69
|
-
resetTools,
|
|
70
|
-
} from './src/kernel/registry/catalog.ts';
|
|
71
|
-
export type { ProfileDefinition } from './src/kernel/registry/profiles.ts';
|
|
72
|
-
export {
|
|
73
|
-
clearProfiles,
|
|
74
|
-
defineProfile,
|
|
75
|
-
getProfile,
|
|
76
|
-
hasProfile,
|
|
77
|
-
listProfiles,
|
|
78
|
-
registerProfile,
|
|
79
|
-
registerProfiles,
|
|
80
|
-
} from './src/kernel/registry/profiles.ts';
|
|
81
|
-
export { projectProfile, resolveTurn } from './src/kernel/registry/resolve.ts';
|
|
82
|
-
export { getStructured, registerStructured } from './src/kernel/registry/schemas.ts';
|
|
83
|
-
export { executeTool } from './src/kernel/registry/tools.ts';
|
|
84
|
-
export type * from './src/kernel/types.ts';
|
|
85
|
-
export {
|
|
86
|
-
jsonlSink,
|
|
87
|
-
memorySink,
|
|
88
|
-
noopSink,
|
|
89
|
-
resolveTraceDir,
|
|
90
|
-
sinkFromDir,
|
|
91
|
-
writeTrace,
|
|
92
|
-
} from './src/observability/trace.ts';
|
|
93
|
-
export type { TraceRecord } from './src/observability/trace-record.ts';
|
|
94
|
-
export type { CreateProviderOptions, GeminiTransport, GeminiVault } from './src/providers/mod.ts';
|
|
95
|
-
export { createProvider } from './src/providers/mod.ts';
|
|
39
|
+
import "./_dnt.polyfills.js";
|
|
40
|
+
export { publicError, describeError, TheorumError, toErrorEvent } from './src/guardrails/error.js';
|
|
41
|
+
export type { QuotaSlotStatus } from './src/guardrails/quota.js';
|
|
42
|
+
export { clientIp, quotaMessage, releaseSlot, resetSlots, skipQuota, takeSlot, } from './src/guardrails/quota.js';
|
|
43
|
+
export { PROJECT_ID_MAX, sanitizeProjectId, sanitizeText, sanitizeTurnRequest, } from './src/guardrails/sanitize.js';
|
|
44
|
+
export { runTurn } from './src/kernel/engine/runner.js';
|
|
45
|
+
export { CATALOG, clampThinkingLevel, clampThinkingLevelForApiId, geminiKindForMime, getTool, listBuiltinIds, mimeAllowed, mimeEssence, modelEntryByApiId, registerTools, requireModelSpec, resetTools, } from './src/kernel/registry/catalog.js';
|
|
46
|
+
export type { ProfileDefinition } from './src/kernel/registry/profiles.js';
|
|
47
|
+
export { clearProfiles, defineProfile, getProfile, hasProfile, listProfiles, registerProfile, registerProfiles, } from './src/kernel/registry/profiles.js';
|
|
48
|
+
export { projectProfile, resolveTurn } from './src/kernel/registry/resolve.js';
|
|
49
|
+
export { getStructured, registerStructured } from './src/kernel/registry/schemas.js';
|
|
50
|
+
export { executeTool } from './src/kernel/registry/tools.js';
|
|
51
|
+
export type * from './src/kernel/types.js';
|
|
52
|
+
export { jsonlSink, memorySink, noopSink, resolveTraceDir, sinkFromDir, writeTrace, } from './src/observability/trace.js';
|
|
53
|
+
export type { TraceRecord } from './src/observability/trace-record.js';
|
|
54
|
+
export type { CreateProviderOptions, GeminiTransport, GeminiVault } from './src/providers/mod.js';
|
|
55
|
+
export { createProvider } from './src/providers/mod.js';
|
package/esm/mod.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THEORUM public API.
|
|
3
|
+
*
|
|
4
|
+
* Import this entrypoint when an application wants the complete kernel surface:
|
|
5
|
+
* profile registration, turn execution, provider constructors, guardrails,
|
|
6
|
+
* observability sinks, and public type contracts.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { defineProfile, registerProfile, runTurn } from "jsr:@theorum/core";
|
|
11
|
+
*
|
|
12
|
+
* const profile = defineProfile({
|
|
13
|
+
* id: "assistant.basic",
|
|
14
|
+
* model: {
|
|
15
|
+
* allow: ["gemini35FlashLite"],
|
|
16
|
+
* config: {
|
|
17
|
+
* gemini35FlashLite: {
|
|
18
|
+
* apiId: "gemini-3.5-flash-lite",
|
|
19
|
+
* thinking: { on: "high", off: "minimal" },
|
|
20
|
+
* thinkingLevels: ["minimal", "low", "medium", "high"],
|
|
21
|
+
* summaries: { on: "auto", off: "none" },
|
|
22
|
+
* maxOutputTokens: 8192,
|
|
23
|
+
* temperature: 1,
|
|
24
|
+
* keyBuiltins: [],
|
|
25
|
+
* },
|
|
26
|
+
* },
|
|
27
|
+
* },
|
|
28
|
+
* tools: { allow: [] },
|
|
29
|
+
* inputs: { text: true },
|
|
30
|
+
* outputs: {},
|
|
31
|
+
* guardrails: { quota: { perDay: 100 } },
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* registerProfile(profile);
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* @module
|
|
38
|
+
*/
|
|
39
|
+
import "./_dnt.polyfills.js";
|
|
40
|
+
export { publicError, describeError, TheorumError, toErrorEvent } from './src/guardrails/error.js';
|
|
41
|
+
export { clientIp, quotaMessage, releaseSlot, resetSlots, skipQuota, takeSlot, } from './src/guardrails/quota.js';
|
|
42
|
+
export { PROJECT_ID_MAX, sanitizeProjectId, sanitizeText, sanitizeTurnRequest, } from './src/guardrails/sanitize.js';
|
|
43
|
+
export { runTurn } from './src/kernel/engine/runner.js';
|
|
44
|
+
export { CATALOG, clampThinkingLevel, clampThinkingLevelForApiId, geminiKindForMime, getTool, listBuiltinIds, mimeAllowed, mimeEssence, modelEntryByApiId, registerTools, requireModelSpec, resetTools, } from './src/kernel/registry/catalog.js';
|
|
45
|
+
export { clearProfiles, defineProfile, getProfile, hasProfile, listProfiles, registerProfile, registerProfiles, } from './src/kernel/registry/profiles.js';
|
|
46
|
+
export { projectProfile, resolveTurn } from './src/kernel/registry/resolve.js';
|
|
47
|
+
export { getStructured, registerStructured } from './src/kernel/registry/schemas.js';
|
|
48
|
+
export { executeTool } from './src/kernel/registry/tools.js';
|
|
49
|
+
export { jsonlSink, memorySink, noopSink, resolveTraceDir, sinkFromDir, writeTrace, } from './src/observability/trace.js';
|
|
50
|
+
export { createProvider } from './src/providers/mod.js';
|
package/esm/package.json
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getProfile, listProfiles } from '../../kernel/registry/profiles.js';
|
|
2
|
+
function formatProfileInputs(p) {
|
|
3
|
+
const inputs = [];
|
|
4
|
+
if (p.inputs.text !== false)
|
|
5
|
+
inputs.push('text');
|
|
6
|
+
if (p.inputs.voice)
|
|
7
|
+
inputs.push('voice');
|
|
8
|
+
if (p.inputs.attachments)
|
|
9
|
+
inputs.push(`attachments [${p.inputs.attachments.accept?.join(', ')}]`);
|
|
10
|
+
return inputs.join(' | ');
|
|
11
|
+
}
|
|
12
|
+
function printProfileCard(p) {
|
|
13
|
+
const tools = p.tools.allow?.length ? p.tools.allow.join(', ') : 'none';
|
|
14
|
+
const models = p.model.allow?.join(', ') || 'default';
|
|
15
|
+
const structured = typeof p.outputs.structured === 'string'
|
|
16
|
+
? p.outputs.structured
|
|
17
|
+
: p.outputs.structured
|
|
18
|
+
? 'custom'
|
|
19
|
+
: 'none';
|
|
20
|
+
console.log(` • Profile: ${p.id.padEnd(16)} (handle: ${p.identity.handle})`);
|
|
21
|
+
console.log(` - Models: ${models}`);
|
|
22
|
+
console.log(` - Inputs: ${formatProfileInputs(p)}`);
|
|
23
|
+
console.log(` - Tools: ${tools}`);
|
|
24
|
+
console.log(` - Structured: ${structured}`);
|
|
25
|
+
console.log(` - Key Bucket: ${p.model.key ?? 'freeA'}`);
|
|
26
|
+
console.log('-'.repeat(70));
|
|
27
|
+
}
|
|
28
|
+
export function listProfilesCommand() {
|
|
29
|
+
const profiles = listProfiles();
|
|
30
|
+
console.log('\n Registered Theorum Profiles:');
|
|
31
|
+
console.log('='.repeat(70));
|
|
32
|
+
if (profiles.length === 0) {
|
|
33
|
+
console.log(' (No profiles registered in runtime)');
|
|
34
|
+
console.log(`${'='.repeat(70)}\n`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
for (const p of profiles) {
|
|
38
|
+
printProfileCard(p);
|
|
39
|
+
}
|
|
40
|
+
console.log(`Total: ${profiles.length} profiles registered.\n`);
|
|
41
|
+
}
|
|
42
|
+
export function showProfileCommand(profileId) {
|
|
43
|
+
try {
|
|
44
|
+
const profile = getProfile(profileId);
|
|
45
|
+
console.log(`\n Profile Details: ${profileId}`);
|
|
46
|
+
console.log('='.repeat(70));
|
|
47
|
+
console.log(JSON.stringify(profile, null, 2));
|
|
48
|
+
console.log(`${'='.repeat(70)}\n`);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
console.error(`\n Error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ModelProvider } from '../../kernel/types.js';
|
|
2
|
+
export interface RunOptions {
|
|
3
|
+
profile: string;
|
|
4
|
+
prompt?: string;
|
|
5
|
+
mode?: string;
|
|
6
|
+
search?: boolean;
|
|
7
|
+
map?: boolean;
|
|
8
|
+
provider?: ModelProvider;
|
|
9
|
+
}
|
|
10
|
+
export declare function runCommand(options: RunOptions): Promise<void>;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
2
|
+
import { runTurn } from '../../kernel/engine/runner.js';
|
|
3
|
+
import { getProfile } from '../../kernel/registry/profiles.js';
|
|
4
|
+
function handleRunEvent(event) {
|
|
5
|
+
if (event.type === 'thought' && event.text) {
|
|
6
|
+
dntShim.Deno.stdout.write(new TextEncoder().encode(`\x1b[2m${event.text}\x1b[0m`));
|
|
7
|
+
}
|
|
8
|
+
else if (event.type === 'text' && event.text) {
|
|
9
|
+
dntShim.Deno.stdout.write(new TextEncoder().encode(event.text));
|
|
10
|
+
}
|
|
11
|
+
else if (event.type === 'tool' && event.tool) {
|
|
12
|
+
console.log(`\n\x1b[33m⚡ [Tool Call] ${event.tool.name}\x1b[0m:`, event.tool.arguments);
|
|
13
|
+
}
|
|
14
|
+
else if (event.type === 'structured' && event.structured) {
|
|
15
|
+
console.log('\n\x1b[32m✓ [Structured Output]\x1b[0m:');
|
|
16
|
+
console.log(JSON.stringify(event.structured, null, 2));
|
|
17
|
+
}
|
|
18
|
+
else if (event.type === 'media' && event.media) {
|
|
19
|
+
console.log(`\n\x1b[34m🖼 [Media Output]\x1b[0m (${event.media.mimeType})`);
|
|
20
|
+
}
|
|
21
|
+
else if (event.type === 'error' && event.error) {
|
|
22
|
+
console.error(`\n\x1b[31m✗ Error\x1b[0m: ${event.error}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export async function runCommand(options) {
|
|
26
|
+
getProfile(options.profile);
|
|
27
|
+
const provider = options.provider;
|
|
28
|
+
if (!provider) {
|
|
29
|
+
console.error('\n\x1b[31mExecution Failed\x1b[0m: Theorum CLI does not create providers or read keys. Run turns from a host app with an explicit ModelProvider.\n');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
const prompt = options.prompt || 'Hello! Please introduce your capabilities.';
|
|
33
|
+
const tools = {};
|
|
34
|
+
if (options.search)
|
|
35
|
+
tools.googleSearch = true;
|
|
36
|
+
if (options.map)
|
|
37
|
+
tools.googleMaps = true;
|
|
38
|
+
const req = {
|
|
39
|
+
profile: options.profile,
|
|
40
|
+
select: options.mode,
|
|
41
|
+
tools: Object.keys(tools).length > 0 ? tools : undefined,
|
|
42
|
+
input: { text: prompt },
|
|
43
|
+
};
|
|
44
|
+
console.log(`\n▶ [RUNNING TURN] Profile: ${options.profile} (${options.mode ?? 'default'})`);
|
|
45
|
+
console.log(`Prompt: "${prompt}"\n`);
|
|
46
|
+
try {
|
|
47
|
+
for await (const event of runTurn(req, provider)) {
|
|
48
|
+
handleRunEvent(event);
|
|
49
|
+
}
|
|
50
|
+
console.log('\n');
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
console.error(`\n\x1b[31mExecution Failed\x1b[0m: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ModelProvider, TurnRequest } from '../../kernel/types.js';
|
|
2
|
+
import { type MatrixOptions } from '../matrix/synthesizer.js';
|
|
3
|
+
export interface TestRunResult {
|
|
4
|
+
passed: boolean;
|
|
5
|
+
name: string;
|
|
6
|
+
durationSec: number;
|
|
7
|
+
tokensTotal?: number;
|
|
8
|
+
error?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare function executeSingleTest(req: TurnRequest, testName: string, provider?: ModelProvider): Promise<TestRunResult>;
|
|
11
|
+
export declare function testProfileCommand(profileId?: string, options?: MatrixOptions & {
|
|
12
|
+
all?: boolean;
|
|
13
|
+
matrix?: boolean;
|
|
14
|
+
provider?: ModelProvider;
|
|
15
|
+
}): Promise<boolean>;
|