@cendor/core 0.2.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/LICENSE +201 -0
- package/README.md +53 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/bus.d.ts +21 -0
- package/dist/bus.d.ts.map +1 -0
- package/dist/bus.js +48 -0
- package/dist/bus.js.map +1 -0
- package/dist/decimal.d.ts +11 -0
- package/dist/decimal.d.ts.map +1 -0
- package/dist/decimal.js +13 -0
- package/dist/decimal.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -0
- package/dist/instrument.d.ts +26 -0
- package/dist/instrument.d.ts.map +1 -0
- package/dist/instrument.js +478 -0
- package/dist/instrument.js.map +1 -0
- package/dist/json-decimal.d.ts +12 -0
- package/dist/json-decimal.d.ts.map +1 -0
- package/dist/json-decimal.js +189 -0
- package/dist/json-decimal.js.map +1 -0
- package/dist/prices-snapshot.d.ts +8 -0
- package/dist/prices-snapshot.d.ts.map +1 -0
- package/dist/prices-snapshot.js +33 -0
- package/dist/prices-snapshot.js.map +1 -0
- package/dist/prices.d.ts +78 -0
- package/dist/prices.d.ts.map +1 -0
- package/dist/prices.js +311 -0
- package/dist/prices.js.map +1 -0
- package/dist/protocols.d.ts +33 -0
- package/dist/protocols.d.ts.map +1 -0
- package/dist/protocols.js +6 -0
- package/dist/protocols.js.map +1 -0
- package/dist/tokens.d.ts +20 -0
- package/dist/tokens.d.ts.map +1 -0
- package/dist/tokens.js +161 -0
- package/dist/tokens.js.map +1 -0
- package/dist/trace.d.ts +35 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +59 -0
- package/dist/trace.js.map +1 -0
- package/dist/types.d.ts +106 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +146 -0
- package/dist/types.js.map +1 -0
- package/package.json +44 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{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AI,CAAC;QACd,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,MAAM;IACpB,KAAK,GAAG,IAAI,CAAC;IACb,UAAU,GAAG,SAAS,CAAC;IACvB,eAAe,GAAG,SAAS,CAAC;IAC5B,cAAc,GAAG,IAAI,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structural interfaces shared across the stack — the TS mirror of `cendor.core.protocols`. These
|
|
3
|
+
* are duck-typed shapes: a library satisfies an interface by shape, no imports or base classes.
|
|
4
|
+
*/
|
|
5
|
+
/** A restore handle for a reversible compression. `expand()` returns the original content. */
|
|
6
|
+
export interface Handle {
|
|
7
|
+
expand(): unknown;
|
|
8
|
+
}
|
|
9
|
+
/** Shrinks content toward a token budget and returns a restorable {@link Handle}. */
|
|
10
|
+
export interface Compressor {
|
|
11
|
+
compress(content: unknown, opts?: {
|
|
12
|
+
targetTokens?: number | null;
|
|
13
|
+
model?: string | null;
|
|
14
|
+
kind?: string;
|
|
15
|
+
}): [string, Handle];
|
|
16
|
+
}
|
|
17
|
+
/** A pluggable per-block shrink rule. Returns `[newContentOrNull, actionLabel]`. */
|
|
18
|
+
export interface EvictionStrategy {
|
|
19
|
+
evict(content: string, remainingTokens: number, model: string): [string | null, string];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* A destination for records/entries (in-memory, JSONL, SQLite, OTel, ...). `write(entry)` is the
|
|
23
|
+
* only required method; a sink **may** additionally implement `flush()` / `close()`, which callers
|
|
24
|
+
* invoke through capability guards, never assumed present.
|
|
25
|
+
*/
|
|
26
|
+
export interface Sink {
|
|
27
|
+
write(entry: unknown): void;
|
|
28
|
+
flush?(): void | Promise<void>;
|
|
29
|
+
close?(): void | Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
/** A bus subscriber: a callable that receives normalized events. */
|
|
32
|
+
export type Subscriber = (event: unknown) => void;
|
|
33
|
+
//# sourceMappingURL=protocols.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocols.d.ts","sourceRoot":"","sources":["../src/protocols.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,8FAA8F;AAC9F,MAAM,WAAW,MAAM;IACrB,MAAM,IAAI,OAAO,CAAC;CACnB;AAED,qFAAqF;AACrF,MAAM,WAAW,UAAU;IACzB,QAAQ,CACN,OAAO,EAAE,OAAO,EAChB,IAAI,CAAC,EAAE;QAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,GAC5E,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACrB;AAED,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,CAAC,CAAC;CACzF;AAED;;;;GAIG;AACH,MAAM,WAAW,IAAI;IACnB,KAAK,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;IAC5B,KAAK,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,KAAK,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,oEAAoE;AACpE,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocols.js","sourceRoot":"","sources":["../src/protocols.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/dist/tokens.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Message } from './types.js';
|
|
2
|
+
export type TokenizerFamily = 'openai' | 'anthropic' | 'google' | 'default';
|
|
3
|
+
export type Counter = (textOrMessages: string | Message[], model: string) => number;
|
|
4
|
+
/** Tokenizer family for a model id (substring matches handle Bedrock-style prefixed ids). */
|
|
5
|
+
export declare function family(model: string): TokenizerFamily;
|
|
6
|
+
/** Override the counter for a family (e.g. plug in a precise tokenizer). */
|
|
7
|
+
export declare function register(fam: string, counter: Counter): void;
|
|
8
|
+
/** Test helper: drop registered counters (cached encodings are pure memoization and kept). */
|
|
9
|
+
export declare function _reset(): void;
|
|
10
|
+
/**
|
|
11
|
+
* How {@link count} will measure `model`: `"registered"`, `"exact"` (OpenAI, model-native tiktoken),
|
|
12
|
+
* `"bpe-estimate"` (Claude/Gemini via o200k, or an unknown OpenAI id falling back to o200k), or
|
|
13
|
+
* `"heuristic"`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function method(model: string): 'registered' | 'exact' | 'bpe-estimate' | 'heuristic';
|
|
16
|
+
/** `true` when {@link count} is exact for `model` (OpenAI with tiktoken). */
|
|
17
|
+
export declare function isExact(model: string): boolean;
|
|
18
|
+
/** Count tokens for a string or a list of chat messages under `model`. */
|
|
19
|
+
export declare function count(textOrMessages: string | Message[], model: string): number;
|
|
20
|
+
//# sourceMappingURL=tokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAQ1C,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;AAC5E,MAAM,MAAM,OAAO,GAAG,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC;AA4CpF,6FAA6F;AAC7F,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,CAgBrD;AAED,4EAA4E;AAC5E,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAE5D;AAED,8FAA8F;AAC9F,wBAAgB,MAAM,IAAI,IAAI,CAE7B;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,GAAG,OAAO,GAAG,cAAc,GAAG,WAAW,CAS3F;AAED,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE9C;AAED,0EAA0E;AAC1E,wBAAgB,KAAK,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAe/E"}
|
package/dist/tokens.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-aware token counting, the TS mirror of `cendor.core.tokens`. Uses `js-tiktoken` (pure JS,
|
|
3
|
+
* no WASM) so counts are exact for OpenAI models and a close BPE proxy (`o200k_base`) for Claude/
|
|
4
|
+
* Gemini. `js-tiktoken` is a hard dependency here, so the "heuristic" tier only ever appears if an
|
|
5
|
+
* encoding genuinely fails to load; it is kept for parity and edge-case robustness.
|
|
6
|
+
*/
|
|
7
|
+
import { encodingForModel, getEncoding } from 'js-tiktoken';
|
|
8
|
+
const MESSAGE_OVERHEAD = 4;
|
|
9
|
+
const PRIMING = 3;
|
|
10
|
+
const CHARS_PER_TOKEN = { openai: 4.0, default: 4.0 };
|
|
11
|
+
const PIECE_RE = /\w+|[^\w\s]/g;
|
|
12
|
+
const counters = new Map();
|
|
13
|
+
const encCache = new Map();
|
|
14
|
+
const nativeCache = new Map();
|
|
15
|
+
let o200kCache;
|
|
16
|
+
function o200k() {
|
|
17
|
+
if (o200kCache === undefined) {
|
|
18
|
+
try {
|
|
19
|
+
o200kCache = getEncoding('o200k_base');
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
o200kCache = null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return o200kCache;
|
|
26
|
+
}
|
|
27
|
+
function tiktokenEncoding(model) {
|
|
28
|
+
const cached = encCache.get(model);
|
|
29
|
+
if (cached)
|
|
30
|
+
return cached;
|
|
31
|
+
try {
|
|
32
|
+
const enc = encodingForModel(model);
|
|
33
|
+
encCache.set(model, enc);
|
|
34
|
+
return enc;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return o200k();
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function openaiEncodingIsNative(model) {
|
|
41
|
+
const cached = nativeCache.get(model);
|
|
42
|
+
if (cached !== undefined)
|
|
43
|
+
return cached;
|
|
44
|
+
let native;
|
|
45
|
+
try {
|
|
46
|
+
encodingForModel(model);
|
|
47
|
+
native = true;
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
native = false;
|
|
51
|
+
}
|
|
52
|
+
nativeCache.set(model, native);
|
|
53
|
+
return native;
|
|
54
|
+
}
|
|
55
|
+
/** Tokenizer family for a model id (substring matches handle Bedrock-style prefixed ids). */
|
|
56
|
+
export function family(model) {
|
|
57
|
+
const m = model.toLowerCase();
|
|
58
|
+
if (m.startsWith('gpt') ||
|
|
59
|
+
m.startsWith('o1') ||
|
|
60
|
+
m.startsWith('o3') ||
|
|
61
|
+
m.startsWith('o4') ||
|
|
62
|
+
m.startsWith('chatgpt') ||
|
|
63
|
+
m.startsWith('text-') ||
|
|
64
|
+
m.startsWith('davinci')) {
|
|
65
|
+
return 'openai';
|
|
66
|
+
}
|
|
67
|
+
if (m.includes('claude'))
|
|
68
|
+
return 'anthropic';
|
|
69
|
+
if (m.includes('gemini'))
|
|
70
|
+
return 'google';
|
|
71
|
+
return 'default';
|
|
72
|
+
}
|
|
73
|
+
/** Override the counter for a family (e.g. plug in a precise tokenizer). */
|
|
74
|
+
export function register(fam, counter) {
|
|
75
|
+
counters.set(fam, counter);
|
|
76
|
+
}
|
|
77
|
+
/** Test helper: drop registered counters (cached encodings are pure memoization and kept). */
|
|
78
|
+
export function _reset() {
|
|
79
|
+
counters.clear();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* How {@link count} will measure `model`: `"registered"`, `"exact"` (OpenAI, model-native tiktoken),
|
|
83
|
+
* `"bpe-estimate"` (Claude/Gemini via o200k, or an unknown OpenAI id falling back to o200k), or
|
|
84
|
+
* `"heuristic"`.
|
|
85
|
+
*/
|
|
86
|
+
export function method(model) {
|
|
87
|
+
const fam = family(model);
|
|
88
|
+
if (counters.has(fam))
|
|
89
|
+
return 'registered';
|
|
90
|
+
if (fam === 'openai') {
|
|
91
|
+
if (tiktokenEncoding(model) === null)
|
|
92
|
+
return 'heuristic';
|
|
93
|
+
return openaiEncodingIsNative(model) ? 'exact' : 'bpe-estimate';
|
|
94
|
+
}
|
|
95
|
+
if ((fam === 'anthropic' || fam === 'google') && o200k() !== null)
|
|
96
|
+
return 'bpe-estimate';
|
|
97
|
+
return 'heuristic';
|
|
98
|
+
}
|
|
99
|
+
/** `true` when {@link count} is exact for `model` (OpenAI with tiktoken). */
|
|
100
|
+
export function isExact(model) {
|
|
101
|
+
return method(model) === 'exact';
|
|
102
|
+
}
|
|
103
|
+
/** Count tokens for a string or a list of chat messages under `model`. */
|
|
104
|
+
export function count(textOrMessages, model) {
|
|
105
|
+
const fam = family(model);
|
|
106
|
+
const custom = counters.get(fam);
|
|
107
|
+
if (custom)
|
|
108
|
+
return custom(textOrMessages, model);
|
|
109
|
+
if (typeof textOrMessages === 'string') {
|
|
110
|
+
return countText(textOrMessages, fam, model);
|
|
111
|
+
}
|
|
112
|
+
let total = PRIMING;
|
|
113
|
+
for (const msg of textOrMessages) {
|
|
114
|
+
total += MESSAGE_OVERHEAD;
|
|
115
|
+
total += countText(messageText(msg), fam, model);
|
|
116
|
+
}
|
|
117
|
+
return total;
|
|
118
|
+
}
|
|
119
|
+
function messageText(msg) {
|
|
120
|
+
if (typeof msg !== 'object' || msg === null) {
|
|
121
|
+
if (typeof msg === 'string')
|
|
122
|
+
return msg;
|
|
123
|
+
const text = msg?.text;
|
|
124
|
+
return typeof text === 'string' ? text : String(msg);
|
|
125
|
+
}
|
|
126
|
+
const content = msg.content ?? '';
|
|
127
|
+
if (Array.isArray(content)) {
|
|
128
|
+
return content
|
|
129
|
+
.filter((p) => p != null && typeof p === 'object')
|
|
130
|
+
.map((p) => {
|
|
131
|
+
const t = p.text;
|
|
132
|
+
return typeof t === 'string' ? t : '';
|
|
133
|
+
})
|
|
134
|
+
.join('');
|
|
135
|
+
}
|
|
136
|
+
return String(content || '');
|
|
137
|
+
}
|
|
138
|
+
function countText(text, fam, model) {
|
|
139
|
+
if (!text)
|
|
140
|
+
return 0;
|
|
141
|
+
if (fam === 'openai') {
|
|
142
|
+
const enc = tiktokenEncoding(model);
|
|
143
|
+
if (enc)
|
|
144
|
+
return enc.encode(text).length;
|
|
145
|
+
}
|
|
146
|
+
else if (fam === 'anthropic' || fam === 'google') {
|
|
147
|
+
const enc = o200k();
|
|
148
|
+
if (enc)
|
|
149
|
+
return enc.encode(text).length;
|
|
150
|
+
return subwordEstimate(text);
|
|
151
|
+
}
|
|
152
|
+
const cpt = CHARS_PER_TOKEN[fam] ?? CHARS_PER_TOKEN.default ?? 4.0;
|
|
153
|
+
return Math.ceil(text.length / cpt);
|
|
154
|
+
}
|
|
155
|
+
function subwordEstimate(text) {
|
|
156
|
+
const pieces = (text.match(PIECE_RE) ?? []).length;
|
|
157
|
+
const charEst = text.length / 3.5;
|
|
158
|
+
const pieceEst = pieces * 1.2;
|
|
159
|
+
return Math.max(1, Math.ceil((charEst + pieceEst) / 2));
|
|
160
|
+
}
|
|
161
|
+
//# sourceMappingURL=tokens.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tokens.js","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AA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,GAAG,KAAK,QAAQ,EAAE,CAAC;QACnD,MAAM,GAAG,GAAG,KAAK,EAAE,CAAC;QACpB,IAAI,GAAG;YAAE,OAAO,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;QACxC,OAAO,eAAe,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IACD,MAAM,GAAG,GAAG,eAAe,CAAC,GAAG,CAAC,IAAI,eAAe,CAAC,OAAO,IAAI,GAAG,CAAC;IACnE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,eAAe,CAAC,IAAY;IACnC,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC;IACnD,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;IAClC,MAAM,QAAQ,GAAG,MAAM,GAAG,GAAG,CAAC;IAC9B,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
package/dist/trace.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient `traceId` correlation, the TS mirror of `cendor.core`'s `trace()` context manager. Per the
|
|
3
|
+
* api-parity rules, a Python context manager maps to an async-callback scope in TS:
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* await trace('run-42', async () => {
|
|
7
|
+
* await client.chat.completions.create(...); // emitted LLMCall.traceId === 'run-42'
|
|
8
|
+
* });
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Correlation is a *hook*, not an orchestrator — Cendor stamps the id you set; it never invents a run
|
|
12
|
+
* graph. Core keeps zero Node dependencies (so it stays edge/browser-importable), so the default
|
|
13
|
+
* store is a save/restore ambient variable — correct for sync and sequential-async use. For
|
|
14
|
+
* concurrency-correct isolation under overlapping async runs (the SDK's agent loop), a host injects a
|
|
15
|
+
* real `AsyncLocalStorage` via {@link installTraceContext}; its `{ getStore, run }` shape matches.
|
|
16
|
+
*/
|
|
17
|
+
/** The minimal surface Cendor needs from an async-context store (AsyncLocalStorage satisfies it). */
|
|
18
|
+
export interface TraceContextStore {
|
|
19
|
+
getStore(): string | undefined;
|
|
20
|
+
run<T>(traceId: string, fn: () => T): T;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Install a real async-context store (e.g. `new AsyncLocalStorage()` from `node:async_hooks`) so
|
|
24
|
+
* overlapping async traces stay isolated. Optional; without it, correlation uses a save/restore
|
|
25
|
+
* ambient variable. Pass `undefined` to revert to the ambient variable (used by tests).
|
|
26
|
+
*/
|
|
27
|
+
export declare function installTraceContext(impl: TraceContextStore | undefined): void;
|
|
28
|
+
/** The ambient `traceId` for the current context (`''` when unset). */
|
|
29
|
+
export declare function currentTraceId(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Run `fn` with `traceId` stamped onto every `LLMCall`/`ToolCall` emitted inside it. Returns whatever
|
|
32
|
+
* `fn` returns (awaitable if `fn` is async). Nests correctly.
|
|
33
|
+
*/
|
|
34
|
+
export declare function trace<T>(traceId: string, fn: () => T): T;
|
|
35
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,qGAAqG;AACrG,MAAM,WAAW,iBAAiB;IAChC,QAAQ,IAAI,MAAM,GAAG,SAAS,CAAC;IAC/B,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;CACzC;AAKD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,iBAAiB,GAAG,SAAS,GAAG,IAAI,CAE7E;AAED,uEAAuE;AACvE,wBAAgB,cAAc,IAAI,MAAM,CAGvC;AAED;;;GAGG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,CAAC,CAmBxD"}
|
package/dist/trace.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ambient `traceId` correlation, the TS mirror of `cendor.core`'s `trace()` context manager. Per the
|
|
3
|
+
* api-parity rules, a Python context manager maps to an async-callback scope in TS:
|
|
4
|
+
*
|
|
5
|
+
* ```ts
|
|
6
|
+
* await trace('run-42', async () => {
|
|
7
|
+
* await client.chat.completions.create(...); // emitted LLMCall.traceId === 'run-42'
|
|
8
|
+
* });
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Correlation is a *hook*, not an orchestrator — Cendor stamps the id you set; it never invents a run
|
|
12
|
+
* graph. Core keeps zero Node dependencies (so it stays edge/browser-importable), so the default
|
|
13
|
+
* store is a save/restore ambient variable — correct for sync and sequential-async use. For
|
|
14
|
+
* concurrency-correct isolation under overlapping async runs (the SDK's agent loop), a host injects a
|
|
15
|
+
* real `AsyncLocalStorage` via {@link installTraceContext}; its `{ getStore, run }` shape matches.
|
|
16
|
+
*/
|
|
17
|
+
let store;
|
|
18
|
+
let ambient = '';
|
|
19
|
+
/**
|
|
20
|
+
* Install a real async-context store (e.g. `new AsyncLocalStorage()` from `node:async_hooks`) so
|
|
21
|
+
* overlapping async traces stay isolated. Optional; without it, correlation uses a save/restore
|
|
22
|
+
* ambient variable. Pass `undefined` to revert to the ambient variable (used by tests).
|
|
23
|
+
*/
|
|
24
|
+
export function installTraceContext(impl) {
|
|
25
|
+
store = impl;
|
|
26
|
+
}
|
|
27
|
+
/** The ambient `traceId` for the current context (`''` when unset). */
|
|
28
|
+
export function currentTraceId() {
|
|
29
|
+
if (store)
|
|
30
|
+
return store.getStore() ?? '';
|
|
31
|
+
return ambient;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Run `fn` with `traceId` stamped onto every `LLMCall`/`ToolCall` emitted inside it. Returns whatever
|
|
35
|
+
* `fn` returns (awaitable if `fn` is async). Nests correctly.
|
|
36
|
+
*/
|
|
37
|
+
export function trace(traceId, fn) {
|
|
38
|
+
const id = String(traceId);
|
|
39
|
+
if (store)
|
|
40
|
+
return store.run(id, fn);
|
|
41
|
+
const previous = ambient;
|
|
42
|
+
ambient = id;
|
|
43
|
+
let result;
|
|
44
|
+
try {
|
|
45
|
+
result = fn();
|
|
46
|
+
}
|
|
47
|
+
catch (err) {
|
|
48
|
+
ambient = previous;
|
|
49
|
+
throw err;
|
|
50
|
+
}
|
|
51
|
+
if (result instanceof Promise) {
|
|
52
|
+
return result.finally(() => {
|
|
53
|
+
ambient = previous;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
ambient = previous;
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH,IAAI,KAAoC,CAAC;AACzC,IAAI,OAAO,GAAG,EAAE,CAAC;AAEjB;;;;GAIG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAAmC;IACrE,KAAK,GAAG,IAAI,CAAC;AACf,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,cAAc;IAC5B,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;IACzC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAI,OAAe,EAAE,EAAW;IACnD,MAAM,EAAE,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3B,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;IACpC,MAAM,QAAQ,GAAG,OAAO,CAAC;IACzB,OAAO,GAAG,EAAE,CAAC;IACb,IAAI,MAAS,CAAC;IACd,IAAI,CAAC;QACH,MAAM,GAAG,EAAE,EAAE,CAAC;IAChB,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,GAAG,QAAQ,CAAC;QACnB,MAAM,GAAG,CAAC;IACZ,CAAC;IACD,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;QAC9B,OAAO,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE;YACzB,OAAO,GAAG,QAAQ,CAAC;QACrB,CAAC,CAAiB,CAAC;IACrB,CAAC;IACD,OAAO,GAAG,QAAQ,CAAC;IACnB,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical data types shared across the Cendor stack — the cross-language vocabulary defined by the
|
|
3
|
+
* bus-events spec (`events/1`). Type names (`Money`, `Usage`, `LLMCall`, `ToolCall`) are identical
|
|
4
|
+
* across languages; field names map `snake_case` (Python) -> `camelCase` (TS) per the parity rules.
|
|
5
|
+
*/
|
|
6
|
+
import { type Decimal, type DecimalValue } from './decimal.js';
|
|
7
|
+
/**
|
|
8
|
+
* A Decimal-backed monetary amount. **Never use a `number` for money.**
|
|
9
|
+
*
|
|
10
|
+
* Accepts `number` / `string` / `Decimal` for `amount` and coerces to `Decimal` (numbers via their
|
|
11
|
+
* string form, to avoid binary-float noise). Arithmetic and comparisons require a matching
|
|
12
|
+
* `currency`. Scalar serialization is the string `"{amount} {currency}"` (e.g. `"0.0025 USD"`).
|
|
13
|
+
*/
|
|
14
|
+
export declare class Money {
|
|
15
|
+
readonly amount: Decimal;
|
|
16
|
+
readonly currency: string;
|
|
17
|
+
constructor(amount: DecimalValue, currency?: string);
|
|
18
|
+
/** A zero amount in the given currency. */
|
|
19
|
+
static zero(currency?: string): Money;
|
|
20
|
+
private check;
|
|
21
|
+
add(other: Money): Money;
|
|
22
|
+
sub(other: Money): Money;
|
|
23
|
+
mul(scalar: DecimalValue): Money;
|
|
24
|
+
eq(other: Money): boolean;
|
|
25
|
+
lt(other: Money): boolean;
|
|
26
|
+
le(other: Money): boolean;
|
|
27
|
+
gt(other: Money): boolean;
|
|
28
|
+
ge(other: Money): boolean;
|
|
29
|
+
/** `"{amount} {currency}"`, e.g. `"0.0025 USD"`. */
|
|
30
|
+
toString(): string;
|
|
31
|
+
}
|
|
32
|
+
/** Sum a list of Money (empty -> zero in `currency`). Mirrors Python's `sum([...])` over Money. */
|
|
33
|
+
export declare function sumMoney(items: Money[], currency?: string): Money;
|
|
34
|
+
export interface UsageInit {
|
|
35
|
+
inputTokens: number;
|
|
36
|
+
outputTokens?: number;
|
|
37
|
+
cachedTokens?: number;
|
|
38
|
+
reasoningTokens?: number;
|
|
39
|
+
cacheWrite?: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Token usage for a single LLM call. `cachedTokens` is a *subset of* `inputTokens` and
|
|
43
|
+
* `reasoningTokens` is a *subset of* `outputTokens` — breakdowns, not extra tokens, so neither is
|
|
44
|
+
* added into `totalTokens`. `cacheWrite` is a **separate** billed category (not part of input).
|
|
45
|
+
*/
|
|
46
|
+
export declare class Usage {
|
|
47
|
+
readonly inputTokens: number;
|
|
48
|
+
readonly outputTokens: number;
|
|
49
|
+
readonly cachedTokens: number;
|
|
50
|
+
readonly reasoningTokens: number;
|
|
51
|
+
readonly cacheWrite: number;
|
|
52
|
+
constructor(init: UsageInit);
|
|
53
|
+
/** input + output (cached/reasoning are subsets; cacheWrite is billed separately, not added). */
|
|
54
|
+
get totalTokens(): number;
|
|
55
|
+
}
|
|
56
|
+
/** A provider-native chat message (passed through unchanged; not further normalized). */
|
|
57
|
+
export type Message = Record<string, unknown>;
|
|
58
|
+
export interface LLMCallInit {
|
|
59
|
+
id: string;
|
|
60
|
+
provider: string;
|
|
61
|
+
model: string;
|
|
62
|
+
messages: Message[];
|
|
63
|
+
usage?: Usage | null;
|
|
64
|
+
cost?: Money | null;
|
|
65
|
+
latencyMs?: number | null;
|
|
66
|
+
traceId?: string;
|
|
67
|
+
ts?: Date | null;
|
|
68
|
+
metadata?: Record<string, unknown>;
|
|
69
|
+
}
|
|
70
|
+
/** A normalized, provider-agnostic record of one model call. Emitted on the bus. */
|
|
71
|
+
export declare class LLMCall {
|
|
72
|
+
id: string;
|
|
73
|
+
provider: string;
|
|
74
|
+
model: string;
|
|
75
|
+
messages: Message[];
|
|
76
|
+
usage: Usage | null;
|
|
77
|
+
cost: Money | null;
|
|
78
|
+
latencyMs: number | null;
|
|
79
|
+
traceId: string;
|
|
80
|
+
ts: Date | null;
|
|
81
|
+
metadata: Record<string, unknown>;
|
|
82
|
+
constructor(init: LLMCallInit);
|
|
83
|
+
}
|
|
84
|
+
export interface ToolCallInit {
|
|
85
|
+
id: string;
|
|
86
|
+
name: string;
|
|
87
|
+
arguments: Record<string, unknown>;
|
|
88
|
+
result?: unknown;
|
|
89
|
+
latencyMs?: number | null;
|
|
90
|
+
traceId?: string;
|
|
91
|
+
ts?: Date | null;
|
|
92
|
+
metadata?: Record<string, unknown>;
|
|
93
|
+
}
|
|
94
|
+
/** A normalized record of one tool invocation. Emitted when a tool is instrumented. */
|
|
95
|
+
export declare class ToolCall {
|
|
96
|
+
id: string;
|
|
97
|
+
name: string;
|
|
98
|
+
arguments: Record<string, unknown>;
|
|
99
|
+
result: unknown;
|
|
100
|
+
latencyMs: number | null;
|
|
101
|
+
traceId: string;
|
|
102
|
+
ts: Date | null;
|
|
103
|
+
metadata: Record<string, unknown>;
|
|
104
|
+
constructor(init: ToolCallInit);
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version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tB,IAAI,EAAE,WAAW;CAY9B;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,uFAAuF;AACvF,qBAAa,QAAQ;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,EAAE,EAAE,IAAI,GAAG,IAAI,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAEtB,IAAI,EAAE,YAAY;CAU/B"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical data types shared across the Cendor stack — the cross-language vocabulary defined by the
|
|
3
|
+
* bus-events spec (`events/1`). Type names (`Money`, `Usage`, `LLMCall`, `ToolCall`) are identical
|
|
4
|
+
* across languages; field names map `snake_case` (Python) -> `camelCase` (TS) per the parity rules.
|
|
5
|
+
*/
|
|
6
|
+
import { Dec } from './decimal.js';
|
|
7
|
+
/**
|
|
8
|
+
* A Decimal-backed monetary amount. **Never use a `number` for money.**
|
|
9
|
+
*
|
|
10
|
+
* Accepts `number` / `string` / `Decimal` for `amount` and coerces to `Decimal` (numbers via their
|
|
11
|
+
* string form, to avoid binary-float noise). Arithmetic and comparisons require a matching
|
|
12
|
+
* `currency`. Scalar serialization is the string `"{amount} {currency}"` (e.g. `"0.0025 USD"`).
|
|
13
|
+
*/
|
|
14
|
+
export class Money {
|
|
15
|
+
amount;
|
|
16
|
+
currency;
|
|
17
|
+
constructor(amount, currency = 'USD') {
|
|
18
|
+
// Coerce a JS number via its string form (mirrors Python's Decimal(str(x))), so 0.1 does not
|
|
19
|
+
// pick up binary-float noise. Strings and Decimals pass straight through.
|
|
20
|
+
this.amount =
|
|
21
|
+
amount instanceof Dec
|
|
22
|
+
? amount
|
|
23
|
+
: new Dec(typeof amount === 'number' ? String(amount) : amount);
|
|
24
|
+
this.currency = currency;
|
|
25
|
+
}
|
|
26
|
+
/** A zero amount in the given currency. */
|
|
27
|
+
static zero(currency = 'USD') {
|
|
28
|
+
return new Money(new Dec(0), currency);
|
|
29
|
+
}
|
|
30
|
+
check(other) {
|
|
31
|
+
if (this.currency !== other.currency) {
|
|
32
|
+
throw new Error(`currency mismatch: ${this.currency} vs ${other.currency}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
add(other) {
|
|
36
|
+
this.check(other);
|
|
37
|
+
return new Money(this.amount.plus(other.amount), this.currency);
|
|
38
|
+
}
|
|
39
|
+
sub(other) {
|
|
40
|
+
this.check(other);
|
|
41
|
+
return new Money(this.amount.minus(other.amount), this.currency);
|
|
42
|
+
}
|
|
43
|
+
mul(scalar) {
|
|
44
|
+
return new Money(this.amount.times(typeof scalar === 'number' ? String(scalar) : scalar), this.currency);
|
|
45
|
+
}
|
|
46
|
+
eq(other) {
|
|
47
|
+
return this.currency === other.currency && this.amount.equals(other.amount);
|
|
48
|
+
}
|
|
49
|
+
lt(other) {
|
|
50
|
+
this.check(other);
|
|
51
|
+
return this.amount.lessThan(other.amount);
|
|
52
|
+
}
|
|
53
|
+
le(other) {
|
|
54
|
+
this.check(other);
|
|
55
|
+
return this.amount.lessThanOrEqualTo(other.amount);
|
|
56
|
+
}
|
|
57
|
+
gt(other) {
|
|
58
|
+
this.check(other);
|
|
59
|
+
return this.amount.greaterThan(other.amount);
|
|
60
|
+
}
|
|
61
|
+
ge(other) {
|
|
62
|
+
this.check(other);
|
|
63
|
+
return this.amount.greaterThanOrEqualTo(other.amount);
|
|
64
|
+
}
|
|
65
|
+
/** `"{amount} {currency}"`, e.g. `"0.0025 USD"`. */
|
|
66
|
+
toString() {
|
|
67
|
+
return `${this.amount.toString()} ${this.currency}`;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** Sum a list of Money (empty -> zero in `currency`). Mirrors Python's `sum([...])` over Money. */
|
|
71
|
+
export function sumMoney(items, currency = 'USD') {
|
|
72
|
+
let total = Money.zero(currency);
|
|
73
|
+
for (const m of items)
|
|
74
|
+
total = total.add(m);
|
|
75
|
+
return total;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Token usage for a single LLM call. `cachedTokens` is a *subset of* `inputTokens` and
|
|
79
|
+
* `reasoningTokens` is a *subset of* `outputTokens` — breakdowns, not extra tokens, so neither is
|
|
80
|
+
* added into `totalTokens`. `cacheWrite` is a **separate** billed category (not part of input).
|
|
81
|
+
*/
|
|
82
|
+
export class Usage {
|
|
83
|
+
inputTokens;
|
|
84
|
+
outputTokens;
|
|
85
|
+
cachedTokens;
|
|
86
|
+
reasoningTokens;
|
|
87
|
+
cacheWrite;
|
|
88
|
+
constructor(init) {
|
|
89
|
+
this.inputTokens = init.inputTokens;
|
|
90
|
+
this.outputTokens = init.outputTokens ?? 0;
|
|
91
|
+
this.cachedTokens = init.cachedTokens ?? 0;
|
|
92
|
+
this.reasoningTokens = init.reasoningTokens ?? 0;
|
|
93
|
+
this.cacheWrite = init.cacheWrite ?? 0;
|
|
94
|
+
}
|
|
95
|
+
/** input + output (cached/reasoning are subsets; cacheWrite is billed separately, not added). */
|
|
96
|
+
get totalTokens() {
|
|
97
|
+
return this.inputTokens + this.outputTokens;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/** A normalized, provider-agnostic record of one model call. Emitted on the bus. */
|
|
101
|
+
export class LLMCall {
|
|
102
|
+
id;
|
|
103
|
+
provider;
|
|
104
|
+
model;
|
|
105
|
+
messages;
|
|
106
|
+
usage;
|
|
107
|
+
cost;
|
|
108
|
+
latencyMs;
|
|
109
|
+
traceId;
|
|
110
|
+
ts;
|
|
111
|
+
metadata;
|
|
112
|
+
constructor(init) {
|
|
113
|
+
this.id = init.id;
|
|
114
|
+
this.provider = init.provider;
|
|
115
|
+
this.model = init.model;
|
|
116
|
+
this.messages = init.messages;
|
|
117
|
+
this.usage = init.usage ?? null;
|
|
118
|
+
this.cost = init.cost ?? null;
|
|
119
|
+
this.latencyMs = init.latencyMs ?? null;
|
|
120
|
+
this.traceId = init.traceId ?? '';
|
|
121
|
+
this.ts = init.ts ?? null;
|
|
122
|
+
this.metadata = init.metadata ?? {};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/** A normalized record of one tool invocation. Emitted when a tool is instrumented. */
|
|
126
|
+
export class ToolCall {
|
|
127
|
+
id;
|
|
128
|
+
name;
|
|
129
|
+
arguments;
|
|
130
|
+
result;
|
|
131
|
+
latencyMs;
|
|
132
|
+
traceId;
|
|
133
|
+
ts;
|
|
134
|
+
metadata;
|
|
135
|
+
constructor(init) {
|
|
136
|
+
this.id = init.id;
|
|
137
|
+
this.name = init.name;
|
|
138
|
+
this.arguments = init.arguments;
|
|
139
|
+
this.result = init.result ?? null;
|
|
140
|
+
this.latencyMs = init.latencyMs ?? null;
|
|
141
|
+
this.traceId = init.traceId ?? '';
|
|
142
|
+
this.ts = init.ts ?? null;
|
|
143
|
+
this.metadata = init.metadata ?? {};
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;G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