theorum 0.1.3 → 0.1.4
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 +30 -9
- package/deno.json +57 -0
- package/deno.lock +469 -0
- package/{esm/mod.d.ts → mod.ts} +57 -15
- package/package.json +35 -44
- package/src/cli/commands/profile.ts +57 -0
- package/src/cli/commands/run.ts +66 -0
- package/src/cli/commands/test.ts +195 -0
- package/src/cli/index.ts +161 -0
- package/src/cli/matrix/fixtures.ts +96 -0
- package/src/cli/matrix/synthesizer.ts +240 -0
- package/src/guardrails/error.ts +142 -0
- package/src/guardrails/injection.ts +254 -0
- package/src/guardrails/mod.ts +40 -0
- package/src/guardrails/quota.ts +87 -0
- package/src/guardrails/sanitize.ts +165 -0
- package/src/guardrails/sensitive.ts +96 -0
- package/src/host/mint-trace.ts +54 -0
- package/{esm/src/host/mod.js → src/host/mod.ts} +11 -3
- package/src/host/reply.ts +32 -0
- package/src/kernel/engine/assert.ts +29 -0
- package/src/kernel/engine/boundary.ts +75 -0
- package/src/kernel/engine/delta.ts +440 -0
- package/src/kernel/engine/hash.ts +11 -0
- package/src/kernel/engine/record.ts +8 -0
- package/src/kernel/engine/repair.ts +56 -0
- package/src/kernel/engine/runner/gates.ts +338 -0
- package/src/kernel/engine/runner/mod.ts +135 -0
- package/src/kernel/engine/runner/state.ts +31 -0
- package/src/kernel/engine/runner/steps.ts +183 -0
- package/src/kernel/engine/runner/stream.ts +83 -0
- package/src/kernel/engine/runner/tokens.ts +47 -0
- package/src/kernel/engine/runner/tools.ts +266 -0
- package/{esm/src/kernel/engine/runner.d.ts → src/kernel/engine/runner.ts} +2 -1
- package/src/kernel/engine/tree.ts +18 -0
- package/src/kernel/mod.ts +39 -0
- package/src/kernel/registry/attachments.ts +195 -0
- package/src/kernel/registry/catalog.ts +181 -0
- package/src/kernel/registry/ingress.ts +223 -0
- package/src/kernel/registry/profiles.ts +165 -0
- package/src/kernel/registry/provider-request.ts +31 -0
- package/src/kernel/registry/resolve.ts +290 -0
- package/src/kernel/registry/schemas.ts +29 -0
- package/src/kernel/registry/tools.ts +45 -0
- package/{esm/src/kernel/registry/vault.d.ts → src/kernel/registry/vault.ts} +17 -2
- package/src/kernel/types.ts +576 -0
- package/{esm/src/observability/mod.js → src/observability/mod.ts} +11 -2
- package/src/observability/spans.ts +70 -0
- package/src/observability/trace-attach.ts +96 -0
- package/src/observability/trace-record.ts +254 -0
- package/src/observability/trace-usage.ts +36 -0
- package/src/observability/trace.ts +143 -0
- package/src/presets/google.ts +147 -0
- package/src/presets/mod.ts +24 -0
- package/src/providers/create-provider.ts +64 -0
- package/src/providers/gemini-tape.ts +59 -0
- package/src/providers/google-tap.ts +57 -0
- package/src/providers/interactions.ts +182 -0
- package/src/providers/keys.ts +182 -0
- package/{esm/src/providers/mod.js → src/providers/mod.ts} +4 -2
- package/{esm/src/providers/openrouter-mod.js → src/providers/openrouter-mod.ts} +7 -3
- package/src/providers/openrouter-payload.ts +232 -0
- package/src/providers/openrouter.ts +758 -0
- package/src/providers/pcm.ts +37 -0
- package/src/providers/provider.ts +206 -0
- package/src/providers/speech.ts +180 -0
- package/src/providers/sse.ts +59 -0
- package/esm/_dnt.polyfills.d.ts +0 -110
- package/esm/_dnt.polyfills.js +0 -144
- package/esm/_dnt.shims.d.ts +0 -5
- package/esm/_dnt.shims.js +0 -61
- package/esm/mod.js +0 -49
- package/esm/package.json +0 -3
- package/esm/src/cli/commands/profile.d.ts +0 -2
- package/esm/src/cli/commands/profile.js +0 -53
- package/esm/src/cli/commands/run.d.ts +0 -10
- package/esm/src/cli/commands/run.js +0 -55
- package/esm/src/cli/commands/test.d.ts +0 -15
- package/esm/src/cli/commands/test.js +0 -140
- package/esm/src/cli/index.d.ts +0 -4
- package/esm/src/cli/index.js +0 -148
- package/esm/src/cli/matrix/fixtures.d.ts +0 -13
- package/esm/src/cli/matrix/fixtures.js +0 -77
- package/esm/src/cli/matrix/synthesizer.d.ts +0 -29
- package/esm/src/cli/matrix/synthesizer.js +0 -187
- package/esm/src/guardrails/error.d.ts +0 -33
- package/esm/src/guardrails/error.js +0 -114
- package/esm/src/guardrails/injection.d.ts +0 -12
- package/esm/src/guardrails/injection.js +0 -220
- package/esm/src/guardrails/mod.d.ts +0 -14
- package/esm/src/guardrails/mod.js +0 -14
- package/esm/src/guardrails/sanitize.d.ts +0 -22
- package/esm/src/guardrails/sanitize.js +0 -133
- package/esm/src/guardrails/sensitive.d.ts +0 -12
- package/esm/src/guardrails/sensitive.js +0 -88
- package/esm/src/host/mint-trace.d.ts +0 -27
- package/esm/src/host/mint-trace.js +0 -33
- package/esm/src/host/mod.d.ts +0 -13
- package/esm/src/host/reply.d.ts +0 -14
- package/esm/src/host/reply.js +0 -27
- package/esm/src/kernel/engine/boundary.d.ts +0 -10
- package/esm/src/kernel/engine/boundary.js +0 -55
- package/esm/src/kernel/engine/delta.d.ts +0 -8
- package/esm/src/kernel/engine/delta.js +0 -389
- package/esm/src/kernel/engine/hash.d.ts +0 -1
- package/esm/src/kernel/engine/hash.js +0 -9
- package/esm/src/kernel/engine/record.d.ts +0 -2
- package/esm/src/kernel/engine/record.js +0 -7
- package/esm/src/kernel/engine/repair.d.ts +0 -7
- package/esm/src/kernel/engine/repair.js +0 -38
- package/esm/src/kernel/engine/runner/gates.d.ts +0 -4
- package/esm/src/kernel/engine/runner/gates.js +0 -206
- package/esm/src/kernel/engine/runner/mod.d.ts +0 -14
- package/esm/src/kernel/engine/runner/mod.js +0 -103
- package/esm/src/kernel/engine/runner/state.d.ts +0 -16
- package/esm/src/kernel/engine/runner/state.js +0 -8
- package/esm/src/kernel/engine/runner/steps.d.ts +0 -15
- package/esm/src/kernel/engine/runner/steps.js +0 -119
- package/esm/src/kernel/engine/runner/stream.d.ts +0 -11
- package/esm/src/kernel/engine/runner/stream.js +0 -65
- package/esm/src/kernel/engine/runner/tokens.d.ts +0 -3
- package/esm/src/kernel/engine/runner/tokens.js +0 -38
- package/esm/src/kernel/engine/runner/tools.d.ts +0 -13
- package/esm/src/kernel/engine/runner/tools.js +0 -197
- package/esm/src/kernel/engine/runner.js +0 -6
- package/esm/src/kernel/engine/tree.d.ts +0 -2
- package/esm/src/kernel/engine/tree.js +0 -17
- package/esm/src/kernel/mod.d.ts +0 -18
- package/esm/src/kernel/mod.js +0 -16
- package/esm/src/kernel/registry/attachments.d.ts +0 -16
- package/esm/src/kernel/registry/attachments.js +0 -156
- package/esm/src/kernel/registry/catalog.d.ts +0 -31
- package/esm/src/kernel/registry/catalog.js +0 -135
- package/esm/src/kernel/registry/ingress.d.ts +0 -13
- package/esm/src/kernel/registry/ingress.js +0 -163
- package/esm/src/kernel/registry/profiles.d.ts +0 -34
- package/esm/src/kernel/registry/profiles.js +0 -120
- package/esm/src/kernel/registry/provider-request.d.ts +0 -4
- package/esm/src/kernel/registry/provider-request.js +0 -25
- package/esm/src/kernel/registry/resolve.d.ts +0 -19
- package/esm/src/kernel/registry/resolve.js +0 -217
- package/esm/src/kernel/registry/schemas.d.ts +0 -14
- package/esm/src/kernel/registry/schemas.js +0 -23
- package/esm/src/kernel/registry/tools.d.ts +0 -12
- package/esm/src/kernel/registry/tools.js +0 -36
- package/esm/src/kernel/registry/vault.js +0 -18
- package/esm/src/kernel/types.d.ts +0 -521
- package/esm/src/kernel/types.js +0 -10
- package/esm/src/observability/mod.d.ts +0 -12
- package/esm/src/observability/spans.d.ts +0 -16
- package/esm/src/observability/spans.js +0 -56
- package/esm/src/observability/trace-attach.d.ts +0 -16
- package/esm/src/observability/trace-attach.js +0 -67
- package/esm/src/observability/trace-record.d.ts +0 -112
- package/esm/src/observability/trace-record.js +0 -140
- package/esm/src/observability/trace-usage.d.ts +0 -3
- package/esm/src/observability/trace-usage.js +0 -32
- package/esm/src/observability/trace.d.ts +0 -23
- package/esm/src/observability/trace.js +0 -121
- package/esm/src/presets/google.d.ts +0 -50
- package/esm/src/presets/google.js +0 -96
- package/esm/src/presets/mod.d.ts +0 -11
- package/esm/src/presets/mod.js +0 -10
- package/esm/src/providers/create-provider.d.ts +0 -29
- package/esm/src/providers/create-provider.js +0 -38
- package/esm/src/providers/gemini-tape.d.ts +0 -2
- package/esm/src/providers/gemini-tape.js +0 -46
- package/esm/src/providers/google-tap.d.ts +0 -3
- package/esm/src/providers/google-tap.js +0 -48
- package/esm/src/providers/interactions.d.ts +0 -5
- package/esm/src/providers/interactions.js +0 -152
- package/esm/src/providers/keys.d.ts +0 -19
- package/esm/src/providers/keys.js +0 -129
- package/esm/src/providers/mod.d.ts +0 -12
- package/esm/src/providers/openrouter-mod.d.ts +0 -13
- package/esm/src/providers/openrouter-payload.d.ts +0 -32
- package/esm/src/providers/openrouter-payload.js +0 -179
- package/esm/src/providers/openrouter.d.ts +0 -15
- package/esm/src/providers/openrouter.js +0 -589
- package/esm/src/providers/pcm.d.ts +0 -7
- package/esm/src/providers/pcm.js +0 -35
- package/esm/src/providers/provider.d.ts +0 -15
- package/esm/src/providers/provider.js +0 -166
- package/esm/src/providers/speech.d.ts +0 -23
- package/esm/src/providers/speech.js +0 -125
- package/esm/src/providers/sse.d.ts +0 -7
- package/esm/src/providers/sse.js +0 -53
package/esm/_dnt.polyfills.js
DELETED
|
@@ -1,144 +0,0 @@
|
|
|
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
|
-
});
|
package/esm/_dnt.shims.d.ts
DELETED
package/esm/_dnt.shims.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
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/esm/mod.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
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, TheorumError } from './src/guardrails/error.js';
|
|
41
|
-
export { PROJECT_ID_MAX, sanitizeProjectId, sanitizeText, sanitizeTurnRequest, } from './src/guardrails/sanitize.js';
|
|
42
|
-
export { runTurn } from './src/kernel/engine/runner.js';
|
|
43
|
-
export { CATALOG, clampThinkingLevel, clampThinkingLevelForApiId, getTool, listBuiltinIds, modelEntryByApiId, registerTools, requireModelSpec, resetTools, } from './src/kernel/registry/catalog.js';
|
|
44
|
-
export { clearProfiles, defineProfile, getProfile, hasProfile, listProfiles, registerProfile, registerProfiles, } from './src/kernel/registry/profiles.js';
|
|
45
|
-
export { projectProfile, resolveTurn } from './src/kernel/registry/resolve.js';
|
|
46
|
-
export { getStructured, registerStructured } from './src/kernel/registry/schemas.js';
|
|
47
|
-
export { executeTool } from './src/kernel/registry/tools.js';
|
|
48
|
-
export { jsonlSink, memorySink, noopSink, resolveTraceDir, sinkFromDir, writeTrace, } from './src/observability/trace.js';
|
|
49
|
-
export { createProvider } from './src/providers/mod.js';
|
package/esm/package.json
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
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>;
|
|
@@ -1,55 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
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>;
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import * as dntShim from "../../../_dnt.shims.js";
|
|
2
|
-
import { runTurn } from '../../kernel/engine/runner.js';
|
|
3
|
-
import { getProfile, listProfiles } from '../../kernel/registry/profiles.js';
|
|
4
|
-
import { buildCustomTurnRequest, synthesizeMatrixCombos, } from '../matrix/synthesizer.js';
|
|
5
|
-
function printTestHeader(req, testName) {
|
|
6
|
-
const activeTools = Object.entries(req.tools ?? {})
|
|
7
|
-
.filter(([, v]) => Boolean(v))
|
|
8
|
-
.map(([k]) => k)
|
|
9
|
-
.join(', ');
|
|
10
|
-
console.log(`\n▶ [THEORUM TEST] ${testName}`);
|
|
11
|
-
console.log(` Profile: ${req.profile} (Mode: ${req.select ?? 'default'})`);
|
|
12
|
-
console.log(` Tools: ${activeTools || 'none'}`);
|
|
13
|
-
console.log(` Attachments: ${req.input?.attachments?.length ?? 0} file(s) | Voice: ${req.input?.voice?.length ? 'yes' : 'no'}`);
|
|
14
|
-
console.log(` ${'-'.repeat(60)}`);
|
|
15
|
-
}
|
|
16
|
-
function processTestEvent(event, acc) {
|
|
17
|
-
if (event.type === 'thought' && event.text) {
|
|
18
|
-
dntShim.Deno.stdout.write(new TextEncoder().encode('.'));
|
|
19
|
-
}
|
|
20
|
-
else if (event.type === 'tool' && event.tool) {
|
|
21
|
-
console.log(`\n ⚡ [Tool Dispatched] ${event.tool.name}(${JSON.stringify(event.tool.arguments ?? {})})`);
|
|
22
|
-
}
|
|
23
|
-
else if (event.type === 'structured') {
|
|
24
|
-
console.log(`\n ✓ [Structured Schema Validated]`);
|
|
25
|
-
}
|
|
26
|
-
else if (event.type === 'media') {
|
|
27
|
-
console.log(`\n ✓ [Media Generated] (${event.media?.mimeType})`);
|
|
28
|
-
}
|
|
29
|
-
else if (event.type === 'tokens' && event.tokens) {
|
|
30
|
-
acc.totalTokens = event.tokens.total;
|
|
31
|
-
}
|
|
32
|
-
else if (event.type === 'error' && event.error) {
|
|
33
|
-
acc.hasError = true;
|
|
34
|
-
acc.errorMessage = event.error;
|
|
35
|
-
console.error(`\n [Test Error Detail]: ${event.error}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function printTestResult(passed, durationSec, acc) {
|
|
39
|
-
if (passed) {
|
|
40
|
-
console.log(`\n ✓ STATUS: PASSED (took ${durationSec.toFixed(2)}s, ${acc.totalTokens ? `${acc.totalTokens} tokens` : 'ok'})`);
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
console.log(`\n ✗ STATUS: FAILED: ${acc.errorMessage} (${durationSec.toFixed(2)}s)`);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
export async function executeSingleTest(req, testName, provider) {
|
|
47
|
-
const start = Date.now();
|
|
48
|
-
getProfile(req.profile);
|
|
49
|
-
printTestHeader(req, testName);
|
|
50
|
-
const acc = {
|
|
51
|
-
totalTokens: 0,
|
|
52
|
-
hasError: false,
|
|
53
|
-
errorMessage: '',
|
|
54
|
-
};
|
|
55
|
-
try {
|
|
56
|
-
if (!provider) {
|
|
57
|
-
throw new Error('Theorum CLI does not create providers or read keys. Pass an explicit ModelProvider from the host app.');
|
|
58
|
-
}
|
|
59
|
-
for await (const event of runTurn(req, provider)) {
|
|
60
|
-
processTestEvent(event, acc);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
catch (err) {
|
|
64
|
-
acc.hasError = true;
|
|
65
|
-
acc.errorMessage = err instanceof Error ? err.message : String(err);
|
|
66
|
-
}
|
|
67
|
-
const durationSec = (Date.now() - start) / 1000;
|
|
68
|
-
const passed = !acc.hasError;
|
|
69
|
-
printTestResult(passed, durationSec, acc);
|
|
70
|
-
return {
|
|
71
|
-
passed,
|
|
72
|
-
name: testName,
|
|
73
|
-
durationSec,
|
|
74
|
-
tokensTotal: acc.totalTokens,
|
|
75
|
-
error: acc.errorMessage,
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
function resolveTargetProfiles(profileId, all) {
|
|
79
|
-
if (all) {
|
|
80
|
-
return listProfiles();
|
|
81
|
-
}
|
|
82
|
-
if (profileId) {
|
|
83
|
-
try {
|
|
84
|
-
return [getProfile(profileId)];
|
|
85
|
-
}
|
|
86
|
-
catch (err) {
|
|
87
|
-
console.error(`\n Error: ${err instanceof Error ? err.message : String(err)}\n`);
|
|
88
|
-
return null;
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
console.error('Error: Please specify a profile ID (e.g. `theorum test --profile your-profile`) or `--all`.');
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
async function runProfileMatrix(profile, provider) {
|
|
95
|
-
const results = [];
|
|
96
|
-
const combos = synthesizeMatrixCombos(profile);
|
|
97
|
-
for (const combo of combos) {
|
|
98
|
-
const res = await executeSingleTest(combo.req, `${profile.id} [${combo.name}]`, provider);
|
|
99
|
-
results.push(res);
|
|
100
|
-
}
|
|
101
|
-
return results;
|
|
102
|
-
}
|
|
103
|
-
async function runProfileSingle(profile, options, provider) {
|
|
104
|
-
const req = buildCustomTurnRequest(profile, options);
|
|
105
|
-
const testName = options.lite ? `${profile.id} [Lite]` : `${profile.id} [Stress Combo]`;
|
|
106
|
-
return await executeSingleTest(req, testName, provider);
|
|
107
|
-
}
|
|
108
|
-
function printSummaryReport(results) {
|
|
109
|
-
console.log(`\n${'='.repeat(70)}`);
|
|
110
|
-
console.log(' TEST SUMMARY:');
|
|
111
|
-
console.log('='.repeat(70));
|
|
112
|
-
let allPassed = true;
|
|
113
|
-
for (const r of results) {
|
|
114
|
-
const status = r.passed ? '✓ PASSED' : '✗ FAILED';
|
|
115
|
-
console.log(` ${status.padEnd(10)} ${r.name.padEnd(45)} (${r.durationSec.toFixed(2)}s)`);
|
|
116
|
-
if (!r.passed) {
|
|
117
|
-
allPassed = false;
|
|
118
|
-
if (r.error)
|
|
119
|
-
console.log(` Reason: ${r.error}`);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
console.log(`${'='.repeat(70)}\n`);
|
|
123
|
-
return allPassed;
|
|
124
|
-
}
|
|
125
|
-
export async function testProfileCommand(profileId, options = {}) {
|
|
126
|
-
const targetProfiles = resolveTargetProfiles(profileId, options.all);
|
|
127
|
-
if (!targetProfiles || targetProfiles.length === 0) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
const results = [];
|
|
131
|
-
for (const profile of targetProfiles) {
|
|
132
|
-
if (options.matrix) {
|
|
133
|
-
results.push(...(await runProfileMatrix(profile, options.provider)));
|
|
134
|
-
}
|
|
135
|
-
else {
|
|
136
|
-
results.push(await runProfileSingle(profile, options, options.provider));
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return printSummaryReport(results);
|
|
140
|
-
}
|
package/esm/src/cli/index.d.ts
DELETED