mesedi 0.1.0 → 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/README.md +26 -28
- package/dist/anthropic_integration.d.ts +9 -9
- package/dist/anthropic_integration.js +16 -16
- package/dist/anthropic_integration.js.map +1 -1
- package/dist/client.d.ts +6 -6
- package/dist/client.js +11 -11
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +2 -2
- package/dist/context.js +2 -2
- package/dist/events.d.ts +6 -6
- package/dist/events.js +5 -5
- package/dist/halt.d.ts +12 -12
- package/dist/halt.js +16 -16
- package/dist/halt.js.map +1 -1
- package/dist/halt_stream.d.ts +6 -6
- package/dist/halt_stream.js +11 -11
- package/dist/halt_stream.js.map +1 -1
- package/dist/index.d.ts +11 -11
- package/dist/index.js +11 -11
- package/dist/integrations/vercel_ai.d.ts +6 -6
- package/dist/integrations/vercel_ai.js +10 -10
- package/dist/integrations/vercel_ai.js.map +1 -1
- package/dist/observe.d.ts +3 -3
- package/dist/observe.js +4 -4
- package/dist/observe.js.map +1 -1
- package/dist/tool.d.ts +1 -1
- package/dist/tool.js +4 -4
- package/dist/tool.js.map +1 -1
- package/dist/wrap.d.ts +3 -3
- package/dist/wrap.js +10 -10
- package/dist/wrap.js.map +1 -1
- package/package.json +2 -2
package/dist/halt.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hard-halt primitives
|
|
2
|
+
* Hard-halt primitives, TypeScript port of the Python `mesedi/halt.py`.
|
|
3
3
|
*
|
|
4
4
|
* Three exports:
|
|
5
5
|
*
|
|
6
|
-
* - `Budget
|
|
6
|
+
* - `Budget`: interface describing the per-execution limits
|
|
7
7
|
* (wall-clock seconds, step count, input/output
|
|
8
8
|
* tokens). Any subset of fields can be set; unset
|
|
9
9
|
* fields are "no limit on that axis."
|
|
10
10
|
*
|
|
11
|
-
* - `MesediHalt
|
|
11
|
+
* - `MesediHalt`, Error subclass that the runtime throws when a
|
|
12
12
|
* `Budget` is exceeded. Carries a `reason` and a
|
|
13
13
|
* `trigger` so callers / dashboards can tell which
|
|
14
14
|
* axis blew the budget. Marked with an internal
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
* `try { ... } catch (err) { ... }` and re-threw
|
|
18
18
|
* something else.
|
|
19
19
|
*
|
|
20
|
-
* - `BudgetTracker
|
|
20
|
+
* - `BudgetTracker`, runtime counter struct. One per execution.
|
|
21
21
|
* Tracks wall-clock start (via `performance.now()`
|
|
22
|
-
|
|
22
|
+
*: JS's monotonic clock equivalent of Python's
|
|
23
23
|
* `time.monotonic()`), step count, token totals.
|
|
24
24
|
* `check()` throws MesediHalt if any limit is
|
|
25
25
|
* exceeded; the wrap()'d entry points call it as
|
|
26
26
|
* a halt-safe boundary BEFORE doing work, so the
|
|
27
27
|
* halt always fires between tool/llm/checkpoint
|
|
28
|
-
* calls
|
|
28
|
+
* calls, never mid-call.
|
|
29
29
|
*
|
|
30
30
|
* Cross-language wire-format parity:
|
|
31
31
|
*
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
* Why a marker Symbol on MesediHalt:
|
|
45
45
|
*
|
|
46
46
|
* In Python, `MesediHalt(BaseException)` evades `except Exception:`
|
|
47
|
-
* handlers
|
|
47
|
+
* handlers, broad except blocks miss it. JavaScript has no
|
|
48
48
|
* equivalent of BaseException; `catch (err)` always catches
|
|
49
49
|
* everything. So we mark MesediHalt with a hidden Symbol-keyed
|
|
50
50
|
* property and `wrap()` looks for that symbol, not just an
|
|
@@ -84,7 +84,7 @@ export interface Budget {
|
|
|
84
84
|
*/
|
|
85
85
|
declare const MESEDI_HALT_MARKER: unique symbol;
|
|
86
86
|
/**
|
|
87
|
-
* Trigger that caused a halt
|
|
87
|
+
* Trigger that caused a halt, embedded in the crash_signature
|
|
88
88
|
* (`halt:wall_clock`) so the dashboard groups halts by cause.
|
|
89
89
|
*/
|
|
90
90
|
export type HaltTrigger = "wall_clock" | "step_count" | "token_total" | "remote_signal";
|
|
@@ -110,15 +110,15 @@ export declare class MesediHalt extends Error {
|
|
|
110
110
|
export declare function isMesediHalt(err: unknown): err is MesediHalt;
|
|
111
111
|
/**
|
|
112
112
|
* Runtime counter struct. One instance per execution, lives on the
|
|
113
|
-
* ExecutionContext. Thread-safety isn't a concern in Node
|
|
114
|
-
* single-threaded event loop guarantees serial access
|
|
113
|
+
* ExecutionContext. Thread-safety isn't a concern in Node, the
|
|
114
|
+
* single-threaded event loop guarantees serial access, but the
|
|
115
115
|
* counter writes still need to be coherent across async boundaries,
|
|
116
116
|
* which AsyncLocalStorage gives us for free.
|
|
117
117
|
*
|
|
118
118
|
* `check()` is the halt-safe boundary. Callers (tool, anthropic
|
|
119
119
|
* patch, checkpoint) call it FIRST, then increment counters. If any
|
|
120
120
|
* limit is already exceeded at the time of check, a MesediHalt is
|
|
121
|
-
* thrown
|
|
121
|
+
* thrown, the caller's work is never started.
|
|
122
122
|
*/
|
|
123
123
|
export declare class BudgetTracker {
|
|
124
124
|
private readonly budget;
|
|
@@ -136,7 +136,7 @@ export declare class BudgetTracker {
|
|
|
136
136
|
* `check()` call will throw `MesediHalt(trigger='remote_signal')`
|
|
137
137
|
* with the supplied reason.
|
|
138
138
|
*
|
|
139
|
-
* Idempotent
|
|
139
|
+
* Idempotent, multiple signals overwrite the reason (last one
|
|
140
140
|
* wins). Concurrency is fine: Node's single-threaded event loop
|
|
141
141
|
* means the reader thread's write and the agent thread's read
|
|
142
142
|
* can't interleave at the JS level.
|
package/dist/halt.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Hard-halt primitives
|
|
2
|
+
* Hard-halt primitives, TypeScript port of the Python `mesedi/halt.py`.
|
|
3
3
|
*
|
|
4
4
|
* Three exports:
|
|
5
5
|
*
|
|
6
|
-
* - `Budget
|
|
6
|
+
* - `Budget`: interface describing the per-execution limits
|
|
7
7
|
* (wall-clock seconds, step count, input/output
|
|
8
8
|
* tokens). Any subset of fields can be set; unset
|
|
9
9
|
* fields are "no limit on that axis."
|
|
10
10
|
*
|
|
11
|
-
* - `MesediHalt
|
|
11
|
+
* - `MesediHalt`, Error subclass that the runtime throws when a
|
|
12
12
|
* `Budget` is exceeded. Carries a `reason` and a
|
|
13
13
|
* `trigger` so callers / dashboards can tell which
|
|
14
14
|
* axis blew the budget. Marked with an internal
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
* `try { ... } catch (err) { ... }` and re-threw
|
|
18
18
|
* something else.
|
|
19
19
|
*
|
|
20
|
-
* - `BudgetTracker
|
|
20
|
+
* - `BudgetTracker`, runtime counter struct. One per execution.
|
|
21
21
|
* Tracks wall-clock start (via `performance.now()`
|
|
22
|
-
|
|
22
|
+
*: JS's monotonic clock equivalent of Python's
|
|
23
23
|
* `time.monotonic()`), step count, token totals.
|
|
24
24
|
* `check()` throws MesediHalt if any limit is
|
|
25
25
|
* exceeded; the wrap()'d entry points call it as
|
|
26
26
|
* a halt-safe boundary BEFORE doing work, so the
|
|
27
27
|
* halt always fires between tool/llm/checkpoint
|
|
28
|
-
* calls
|
|
28
|
+
* calls, never mid-call.
|
|
29
29
|
*
|
|
30
30
|
* Cross-language wire-format parity:
|
|
31
31
|
*
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
* Why a marker Symbol on MesediHalt:
|
|
45
45
|
*
|
|
46
46
|
* In Python, `MesediHalt(BaseException)` evades `except Exception:`
|
|
47
|
-
* handlers
|
|
47
|
+
* handlers, broad except blocks miss it. JavaScript has no
|
|
48
48
|
* equivalent of BaseException; `catch (err)` always catches
|
|
49
49
|
* everything. So we mark MesediHalt with a hidden Symbol-keyed
|
|
50
50
|
* property and `wrap()` looks for that symbol, not just an
|
|
@@ -68,7 +68,7 @@ const MESEDI_HALT_MARKER = Symbol.for("mesedi.halt.marker");
|
|
|
68
68
|
export class MesediHalt extends Error {
|
|
69
69
|
reason;
|
|
70
70
|
trigger;
|
|
71
|
-
// Symbol-keyed marker
|
|
71
|
+
// Symbol-keyed marker, invisible to JSON.stringify, hard for user
|
|
72
72
|
// code to spoof.
|
|
73
73
|
[MESEDI_HALT_MARKER] = true;
|
|
74
74
|
constructor(reason, trigger) {
|
|
@@ -95,7 +95,7 @@ export function isMesediHalt(err) {
|
|
|
95
95
|
if (err[MESEDI_HALT_MARKER]) {
|
|
96
96
|
return true;
|
|
97
97
|
}
|
|
98
|
-
// Walk Error.cause chain
|
|
98
|
+
// Walk Error.cause chain, ES2022 standard for wrapped errors.
|
|
99
99
|
let cursor = err.cause;
|
|
100
100
|
let safety = 0;
|
|
101
101
|
while (cursor && safety < 10) {
|
|
@@ -110,15 +110,15 @@ export function isMesediHalt(err) {
|
|
|
110
110
|
}
|
|
111
111
|
/**
|
|
112
112
|
* Runtime counter struct. One instance per execution, lives on the
|
|
113
|
-
* ExecutionContext. Thread-safety isn't a concern in Node
|
|
114
|
-
* single-threaded event loop guarantees serial access
|
|
113
|
+
* ExecutionContext. Thread-safety isn't a concern in Node, the
|
|
114
|
+
* single-threaded event loop guarantees serial access, but the
|
|
115
115
|
* counter writes still need to be coherent across async boundaries,
|
|
116
116
|
* which AsyncLocalStorage gives us for free.
|
|
117
117
|
*
|
|
118
118
|
* `check()` is the halt-safe boundary. Callers (tool, anthropic
|
|
119
119
|
* patch, checkpoint) call it FIRST, then increment counters. If any
|
|
120
120
|
* limit is already exceeded at the time of check, a MesediHalt is
|
|
121
|
-
* thrown
|
|
121
|
+
* thrown, the caller's work is never started.
|
|
122
122
|
*/
|
|
123
123
|
export class BudgetTracker {
|
|
124
124
|
budget;
|
|
@@ -135,7 +135,7 @@ export class BudgetTracker {
|
|
|
135
135
|
constructor(budget) {
|
|
136
136
|
this.budget = budget;
|
|
137
137
|
// performance.now() returns a monotonic millisecond timer that
|
|
138
|
-
// doesn't jump backward on NTP adjustments
|
|
138
|
+
// doesn't jump backward on NTP adjustments, the JS equivalent
|
|
139
139
|
// of Python's time.monotonic().
|
|
140
140
|
this.startMs = performance.now();
|
|
141
141
|
}
|
|
@@ -147,7 +147,7 @@ export class BudgetTracker {
|
|
|
147
147
|
* `check()` call will throw `MesediHalt(trigger='remote_signal')`
|
|
148
148
|
* with the supplied reason.
|
|
149
149
|
*
|
|
150
|
-
* Idempotent
|
|
150
|
+
* Idempotent, multiple signals overwrite the reason (last one
|
|
151
151
|
* wins). Concurrency is fine: Node's single-threaded event loop
|
|
152
152
|
* means the reader thread's write and the agent thread's read
|
|
153
153
|
* can't interleave at the JS level.
|
|
@@ -165,7 +165,7 @@ export class BudgetTracker {
|
|
|
165
165
|
* axis. Local budgets only trip when no remote halt is pending.
|
|
166
166
|
*/
|
|
167
167
|
check() {
|
|
168
|
-
// Remote halt check
|
|
168
|
+
// Remote halt check, runs even when the budget is unbounded,
|
|
169
169
|
// so a wrap()'d agent without explicit local limits can still
|
|
170
170
|
// be remote-halted (dashboard panic-stop semantics).
|
|
171
171
|
if (this.remoteHaltReason !== undefined) {
|
|
@@ -177,7 +177,7 @@ export class BudgetTracker {
|
|
|
177
177
|
this.remoteHaltReason = undefined;
|
|
178
178
|
throw new MesediHalt(reason, "remote_signal");
|
|
179
179
|
}
|
|
180
|
-
// Wall-clock
|
|
180
|
+
// Wall-clock, checked first among the local axes because it's
|
|
181
181
|
// the most common trigger in practice. A runaway agent burns
|
|
182
182
|
// time before it burns steps or tokens.
|
|
183
183
|
if (this.budget.maxWallClockSeconds !== undefined) {
|
package/dist/halt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"halt.js","sourceRoot":"","sources":["../src/halt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AA0BH;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAC;AAY5D;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAC1B,MAAM,CAAS;IAC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;QAC3C,IAAI,QAAQ,GAAG,CAAC;YAAE,IAAI,CAAC,QAAQ,IAAI,QAAQ,CAAC;QAC5C,IAAI,SAAS,GAAG,CAAC;YAAE,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC;IACjD,CAAC;IAED,mDAAmD;IACnD,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IACD,IAAI,eAAe;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IACD,IAAI,gBAAgB;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC;IACxB,CAAC;IACD,IAAI,SAAS;QACX,OAAO,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC;IAC1C,CAAC;CACF"}
|
package/dist/halt_stream.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SSE halt-stream reader
|
|
2
|
+
* SSE halt-stream reader, sub-slice 21e (TS port of 21b.2).
|
|
3
3
|
*
|
|
4
4
|
* When `wrap()` is entered with a `budget` configured, the wrap layer
|
|
5
5
|
* spawns a HaltStreamReader that opens an HTTP stream against
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* - **No thread.** JavaScript is single-threaded; the reader is
|
|
15
15
|
* just an async function returning a Promise that we kick off
|
|
16
16
|
* without awaiting. The fetch's underlying I/O runs on Node's
|
|
17
|
-
* libuv pool
|
|
17
|
+
* libuv pool, same effective concurrency as a Python daemon
|
|
18
18
|
* thread.
|
|
19
19
|
*
|
|
20
20
|
* - **AbortController for stop().** We can't "interrupt" an async
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* stdlib. We pull bytes off `response.body.getReader()`, decode
|
|
29
29
|
* UTF-8 chunks via TextDecoder, accumulate into a buffer, and
|
|
30
30
|
* split on newlines to get SSE lines. The SSE spec uses `\n` or
|
|
31
|
-
* `\r\n` or `\r` as line separators
|
|
31
|
+
* `\r\n` or `\r` as line separators, we normalize all three.
|
|
32
32
|
*
|
|
33
33
|
* - **Fail-open posture.** If subscription fails (connect error,
|
|
34
34
|
* non-200 response, parse error), the reader logs at debug-level
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
*
|
|
39
39
|
* - **One-shot semantics.** After dispatching a halt event, the
|
|
40
40
|
* reader exits. The backend closes the SSE connection at the
|
|
41
|
-
* same moment
|
|
41
|
+
* same moment, both sides agree halt is one signal per
|
|
42
42
|
* subscription.
|
|
43
43
|
*
|
|
44
44
|
* No public API surface: customers don't construct HaltStreamReader.
|
|
@@ -62,8 +62,8 @@ export declare class HaltStreamReader {
|
|
|
62
62
|
private stopped;
|
|
63
63
|
constructor(opts: HaltStreamReaderOptions);
|
|
64
64
|
/**
|
|
65
|
-
* Kick off the async read loop. Idempotent
|
|
66
|
-
* Does NOT await
|
|
65
|
+
* Kick off the async read loop. Idempotent, second call is a no-op.
|
|
66
|
+
* Does NOT await, the wrap layer fires this and continues.
|
|
67
67
|
*/
|
|
68
68
|
start(): void;
|
|
69
69
|
/**
|
package/dist/halt_stream.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* SSE halt-stream reader
|
|
2
|
+
* SSE halt-stream reader, sub-slice 21e (TS port of 21b.2).
|
|
3
3
|
*
|
|
4
4
|
* When `wrap()` is entered with a `budget` configured, the wrap layer
|
|
5
5
|
* spawns a HaltStreamReader that opens an HTTP stream against
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
* - **No thread.** JavaScript is single-threaded; the reader is
|
|
15
15
|
* just an async function returning a Promise that we kick off
|
|
16
16
|
* without awaiting. The fetch's underlying I/O runs on Node's
|
|
17
|
-
* libuv pool
|
|
17
|
+
* libuv pool, same effective concurrency as a Python daemon
|
|
18
18
|
* thread.
|
|
19
19
|
*
|
|
20
20
|
* - **AbortController for stop().** We can't "interrupt" an async
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
* stdlib. We pull bytes off `response.body.getReader()`, decode
|
|
29
29
|
* UTF-8 chunks via TextDecoder, accumulate into a buffer, and
|
|
30
30
|
* split on newlines to get SSE lines. The SSE spec uses `\n` or
|
|
31
|
-
* `\r\n` or `\r` as line separators
|
|
31
|
+
* `\r\n` or `\r` as line separators, we normalize all three.
|
|
32
32
|
*
|
|
33
33
|
* - **Fail-open posture.** If subscription fails (connect error,
|
|
34
34
|
* non-200 response, parse error), the reader logs at debug-level
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
*
|
|
39
39
|
* - **One-shot semantics.** After dispatching a halt event, the
|
|
40
40
|
* reader exits. The backend closes the SSE connection at the
|
|
41
|
-
* same moment
|
|
41
|
+
* same moment, both sides agree halt is one signal per
|
|
42
42
|
* subscription.
|
|
43
43
|
*
|
|
44
44
|
* No public API surface: customers don't construct HaltStreamReader.
|
|
@@ -63,8 +63,8 @@ export class HaltStreamReader {
|
|
|
63
63
|
this.controller = new AbortController();
|
|
64
64
|
}
|
|
65
65
|
/**
|
|
66
|
-
* Kick off the async read loop. Idempotent
|
|
67
|
-
* Does NOT await
|
|
66
|
+
* Kick off the async read loop. Idempotent, second call is a no-op.
|
|
67
|
+
* Does NOT await, the wrap layer fires this and continues.
|
|
68
68
|
*/
|
|
69
69
|
start() {
|
|
70
70
|
if (this.started)
|
|
@@ -86,7 +86,7 @@ export class HaltStreamReader {
|
|
|
86
86
|
this.controller.abort();
|
|
87
87
|
}
|
|
88
88
|
catch {
|
|
89
|
-
// ignore
|
|
89
|
+
// ignore, abort can throw on some Node versions if already aborted
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
async _run() {
|
|
@@ -101,7 +101,7 @@ export class HaltStreamReader {
|
|
|
101
101
|
};
|
|
102
102
|
// Connect-timeout is a separate signal so it doesn't kill the
|
|
103
103
|
// long-lived read after connect succeeds. AbortSignal.timeout()
|
|
104
|
-
// is Node 17.3+ / native; AbortSignal.any() is Node 20
|
|
104
|
+
// is Node 17.3+ / native; AbortSignal.any() is Node 20+, we
|
|
105
105
|
// compose them manually for broader compatibility (Node 18 LTS).
|
|
106
106
|
const connectTimeout = setTimeout(() => this.controller.abort(), CONNECT_TIMEOUT_MS);
|
|
107
107
|
let resp;
|
|
@@ -158,14 +158,14 @@ export class HaltStreamReader {
|
|
|
158
158
|
// Blank line dispatches the accumulated event.
|
|
159
159
|
if (currentEvent === "halt" && dataLines.length > 0) {
|
|
160
160
|
this._dispatchHalt(dataLines.join("\n"));
|
|
161
|
-
return; // one-shot
|
|
161
|
+
return; // one-shot, done
|
|
162
162
|
}
|
|
163
163
|
currentEvent = "message";
|
|
164
164
|
dataLines = [];
|
|
165
165
|
continue;
|
|
166
166
|
}
|
|
167
167
|
if (line.startsWith(":")) {
|
|
168
|
-
// Comment frame (`: keepalive`)
|
|
168
|
+
// Comment frame (`: keepalive`), ignore.
|
|
169
169
|
continue;
|
|
170
170
|
}
|
|
171
171
|
if (line.startsWith("event:")) {
|
|
@@ -207,7 +207,7 @@ export class HaltStreamReader {
|
|
|
207
207
|
this.onHalt(reason);
|
|
208
208
|
}
|
|
209
209
|
catch (err) {
|
|
210
|
-
console.warn("[mesedi.halt_stream] onHalt callback threw
|
|
210
|
+
console.warn("[mesedi.halt_stream] onHalt callback threw, halt may not have fired", { executionId: this.executionId, error: String(err) });
|
|
211
211
|
}
|
|
212
212
|
}
|
|
213
213
|
}
|
package/dist/halt_stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"halt_stream.js","sourceRoot":"","sources":["../src/halt_stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH,MAAM,kBAAkB,GAAG,IAAI,CAAC;AAUhC,MAAM,OAAO,gBAAgB;IACV,WAAW,CAAS;IACpB,OAAO,CAAS;IAChB,MAAM,CAAS;IACf,MAAM,CAA2B;IACjC,aAAa,CAAS;IACtB,UAAU,CAAkB;IACrC,OAAO,GAAG,KAAK,CAAC;IACh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AAE,CAAC;gBACxE,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;YACvB,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,CAAC,KAAK,CACX,8DAA8D,EAC9D,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAC9D,CAAC;QACJ,CAAC;QACD,IAAI,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACtB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CACV,qEAAqE,EACrE,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,KAAK,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CACtD,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mesedi TypeScript SDK
|
|
2
|
+
* Mesedi TypeScript SDK, Guardians for Autonomous AI.
|
|
3
3
|
*
|
|
4
4
|
* Public API:
|
|
5
5
|
*
|
|
6
|
-
* configure(opts)
|
|
6
|
+
* configure(opts): set up the module-level default client.
|
|
7
7
|
* Reads MESEDI_API_KEY / MESEDI_BASE_URL
|
|
8
8
|
* from process.env as fallbacks.
|
|
9
|
-
* wrap(opts?, fn)
|
|
9
|
+
* wrap(opts?, fn): higher-order function that records the
|
|
10
10
|
* wrapped function's invocation as an
|
|
11
11
|
* agent execution.
|
|
12
|
-
* tool(opts?, fn)
|
|
12
|
+
* tool(opts?, fn): higher-order function that records each
|
|
13
13
|
* call as a tool_call event linked to the
|
|
14
14
|
* surrounding wrap()'d execution.
|
|
15
|
-
* checkpoint(name, meta?)
|
|
16
|
-
* validatorResult(name, passed, opts?)
|
|
17
|
-
* instrumentAnthropic(cls?)
|
|
15
|
+
* checkpoint(name, meta?): mark a notable point in execution.
|
|
16
|
+
* validatorResult(name, passed, opts?), report a validator outcome.
|
|
17
|
+
* instrumentAnthropic(cls?), patch @anthropic-ai/sdk's
|
|
18
18
|
* Messages.create to emit llm_call events.
|
|
19
19
|
* Optional `cls` for testing.
|
|
20
|
-
* flush(timeoutMs?)
|
|
20
|
+
* flush(timeoutMs?): wait for the background shipper to
|
|
21
21
|
* drain all events submitted so far.
|
|
22
|
-
* MesediClient
|
|
23
|
-
* Event, Execution
|
|
24
|
-
* EventType, Status
|
|
22
|
+
* MesediClient: explicit client for advanced use cases.
|
|
23
|
+
* Event, Execution: wire-format dataclasses.
|
|
24
|
+
* EventType, Status: enum-style constants.
|
|
25
25
|
*/
|
|
26
26
|
export { MesediClient, configure, flush, getClient } from "./client.js";
|
|
27
27
|
export type { ConfigureOptions } from "./client.js";
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Mesedi TypeScript SDK
|
|
2
|
+
* Mesedi TypeScript SDK, Guardians for Autonomous AI.
|
|
3
3
|
*
|
|
4
4
|
* Public API:
|
|
5
5
|
*
|
|
6
|
-
* configure(opts)
|
|
6
|
+
* configure(opts): set up the module-level default client.
|
|
7
7
|
* Reads MESEDI_API_KEY / MESEDI_BASE_URL
|
|
8
8
|
* from process.env as fallbacks.
|
|
9
|
-
* wrap(opts?, fn)
|
|
9
|
+
* wrap(opts?, fn): higher-order function that records the
|
|
10
10
|
* wrapped function's invocation as an
|
|
11
11
|
* agent execution.
|
|
12
|
-
* tool(opts?, fn)
|
|
12
|
+
* tool(opts?, fn): higher-order function that records each
|
|
13
13
|
* call as a tool_call event linked to the
|
|
14
14
|
* surrounding wrap()'d execution.
|
|
15
|
-
* checkpoint(name, meta?)
|
|
16
|
-
* validatorResult(name, passed, opts?)
|
|
17
|
-
* instrumentAnthropic(cls?)
|
|
15
|
+
* checkpoint(name, meta?): mark a notable point in execution.
|
|
16
|
+
* validatorResult(name, passed, opts?), report a validator outcome.
|
|
17
|
+
* instrumentAnthropic(cls?), patch @anthropic-ai/sdk's
|
|
18
18
|
* Messages.create to emit llm_call events.
|
|
19
19
|
* Optional `cls` for testing.
|
|
20
|
-
* flush(timeoutMs?)
|
|
20
|
+
* flush(timeoutMs?): wait for the background shipper to
|
|
21
21
|
* drain all events submitted so far.
|
|
22
|
-
* MesediClient
|
|
23
|
-
* Event, Execution
|
|
24
|
-
* EventType, Status
|
|
22
|
+
* MesediClient: explicit client for advanced use cases.
|
|
23
|
+
* Event, Execution: wire-format dataclasses.
|
|
24
|
+
* EventType, Status: enum-style constants.
|
|
25
25
|
*/
|
|
26
26
|
export { MesediClient, configure, flush, getClient } from "./client.js";
|
|
27
27
|
export { EventType, Status, utcNowRfc3339, } from "./events.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Vercel AI SDK integration
|
|
2
|
+
* Vercel AI SDK integration, wrap `generateText` to emit Mesedi
|
|
3
3
|
* telemetry.
|
|
4
4
|
*
|
|
5
5
|
* Usage:
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* `wrapGenerateText` is a higher-order function that takes the real
|
|
30
30
|
* Vercel `generateText` and returns a drop-in replacement with the
|
|
31
31
|
* same signature plus telemetry side effects. Customers don't have
|
|
32
|
-
* to refactor their agent code
|
|
32
|
+
* to refactor their agent code, they just swap the import.
|
|
33
33
|
*
|
|
34
34
|
* Multi-step (ReAct) generation is the common case for agent
|
|
35
35
|
* workflows: `generateText({ maxSteps: 5, tools: { ... } })` makes
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
* Mesedi instrumentation produces.
|
|
43
43
|
*
|
|
44
44
|
* Out of scope for this slice:
|
|
45
|
-
* - `streamText` / `streamObject
|
|
45
|
+
* - `streamText` / `streamObject`, emit-on-stream-end variant
|
|
46
46
|
* would need to drain the stream first or instrument the
|
|
47
47
|
* stream's transform. Deferred to a later slice.
|
|
48
|
-
* - `generateObject
|
|
48
|
+
* - `generateObject`, structured output. The shape is similar to
|
|
49
49
|
* `generateText`'s but the response field is `.object` not
|
|
50
50
|
* `.text`. Will compose well with the same wrapper pattern.
|
|
51
51
|
* - OpenTelemetry-based instrumentation via `experimental_telemetry`.
|
|
@@ -68,7 +68,7 @@ interface GenerateTextOptionsLike {
|
|
|
68
68
|
/**
|
|
69
69
|
* Loose duck-typed shape for the Vercel `generateText` result. We
|
|
70
70
|
* read .text, .usage, .toolCalls, .toolResults, .steps. All fields
|
|
71
|
-
* are optional
|
|
71
|
+
* are optional, older versions, custom providers, or streaming
|
|
72
72
|
* adapters may omit them.
|
|
73
73
|
*/
|
|
74
74
|
interface GenerateTextResultLike {
|
|
@@ -112,7 +112,7 @@ export type GenerateTextLike = (opts: GenerateTextOptionsLike) => Promise<Genera
|
|
|
112
112
|
* each invocation emits Mesedi telemetry. Returns a function with
|
|
113
113
|
* the same signature.
|
|
114
114
|
*
|
|
115
|
-
* Outside a `wrap()` execution, the events silently no-op
|
|
115
|
+
* Outside a `wrap()` execution, the events silently no-op, same
|
|
116
116
|
* fail-open pattern as every other Mesedi primitive.
|
|
117
117
|
*/
|
|
118
118
|
export declare function wrapGenerateText<F extends GenerateTextLike>(generateTextFn: F): F;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Vercel AI SDK integration
|
|
2
|
+
* Vercel AI SDK integration, wrap `generateText` to emit Mesedi
|
|
3
3
|
* telemetry.
|
|
4
4
|
*
|
|
5
5
|
* Usage:
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
* `wrapGenerateText` is a higher-order function that takes the real
|
|
30
30
|
* Vercel `generateText` and returns a drop-in replacement with the
|
|
31
31
|
* same signature plus telemetry side effects. Customers don't have
|
|
32
|
-
* to refactor their agent code
|
|
32
|
+
* to refactor their agent code, they just swap the import.
|
|
33
33
|
*
|
|
34
34
|
* Multi-step (ReAct) generation is the common case for agent
|
|
35
35
|
* workflows: `generateText({ maxSteps: 5, tools: { ... } })` makes
|
|
@@ -42,10 +42,10 @@
|
|
|
42
42
|
* Mesedi instrumentation produces.
|
|
43
43
|
*
|
|
44
44
|
* Out of scope for this slice:
|
|
45
|
-
* - `streamText` / `streamObject
|
|
45
|
+
* - `streamText` / `streamObject`, emit-on-stream-end variant
|
|
46
46
|
* would need to drain the stream first or instrument the
|
|
47
47
|
* stream's transform. Deferred to a later slice.
|
|
48
|
-
* - `generateObject
|
|
48
|
+
* - `generateObject`, structured output. The shape is similar to
|
|
49
49
|
* `generateText`'s but the response field is `.object` not
|
|
50
50
|
* `.text`. Will compose well with the same wrapper pattern.
|
|
51
51
|
* - OpenTelemetry-based instrumentation via `experimental_telemetry`.
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
import { getClient } from "../client.js";
|
|
57
57
|
import { currentExecutionContext, newEventId } from "../context.js";
|
|
58
58
|
import { EventType, utcNowRfc3339 } from "../events.js";
|
|
59
|
-
// Truncation budgets
|
|
59
|
+
// Truncation budgets, kept in sync with the Python emit_llm_call and
|
|
60
60
|
// the TS Anthropic patch so wire-format payloads from this adapter and
|
|
61
61
|
// from hand-written code are byte-indistinguishable.
|
|
62
62
|
const MAX_SYSTEM = 1000;
|
|
@@ -70,7 +70,7 @@ const MAX_EXC_MSG = 500;
|
|
|
70
70
|
* each invocation emits Mesedi telemetry. Returns a function with
|
|
71
71
|
* the same signature.
|
|
72
72
|
*
|
|
73
|
-
* Outside a `wrap()` execution, the events silently no-op
|
|
73
|
+
* Outside a `wrap()` execution, the events silently no-op, same
|
|
74
74
|
* fail-open pattern as every other Mesedi primitive.
|
|
75
75
|
*/
|
|
76
76
|
export function wrapGenerateText(generateTextFn) {
|
|
@@ -100,7 +100,7 @@ export function wrapGenerateText(generateTextFn) {
|
|
|
100
100
|
const durationMs = Date.now() - startedAt;
|
|
101
101
|
const ctx = currentExecutionContext();
|
|
102
102
|
if (!ctx) {
|
|
103
|
-
// No active execution
|
|
103
|
+
// No active execution, nothing to attach events to. Return
|
|
104
104
|
// the result unchanged.
|
|
105
105
|
return result;
|
|
106
106
|
}
|
|
@@ -146,7 +146,7 @@ export function wrapGenerateText(generateTextFn) {
|
|
|
146
146
|
return wrapped;
|
|
147
147
|
}
|
|
148
148
|
/**
|
|
149
|
-
* Inline emit_llm_call helper
|
|
149
|
+
* Inline emit_llm_call helper, direct equivalent of the Python
|
|
150
150
|
* `mesedi.observe.emit_llm_call`. Drift / similar-call /
|
|
151
151
|
* identical-call / cost-velocity / prompt-injection detectors all
|
|
152
152
|
* read from the resulting event payload, so a manually-emitted
|
|
@@ -157,7 +157,7 @@ function emitLlmCallEvent(args) {
|
|
|
157
157
|
const ctx = currentExecutionContext();
|
|
158
158
|
if (!ctx)
|
|
159
159
|
return;
|
|
160
|
-
// Halt-safe boundary
|
|
160
|
+
// Halt-safe boundary, matches @mesedi.tool, the Anthropic patch,
|
|
161
161
|
// and the Python emit_llm_call.
|
|
162
162
|
ctx.checkBudget();
|
|
163
163
|
if (ctx.budgetTracker) {
|
|
@@ -272,7 +272,7 @@ function emitToolCallEvent(tc, tr) {
|
|
|
272
272
|
* Extract a stable model identifier from a Vercel model object.
|
|
273
273
|
*
|
|
274
274
|
* Vercel provider models expose either `.modelId` (newer) or
|
|
275
|
-
* `.id` (older). For unknown shapes we try toString()
|
|
275
|
+
* `.id` (older). For unknown shapes we try toString(), most
|
|
276
276
|
* providers stringify to a human-readable label. Last resort:
|
|
277
277
|
* "unknown".
|
|
278
278
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vercel_ai.js","sourceRoot":"","sources":["../../src/integrations/vercel_ai.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsDG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACpE,OAAO,EAAS,SAAS,EAAE,aAAa,EAAE,MAAM,c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