@adjudicate/adapter-core 0.1.0 → 0.1.1
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/dist/bridge.d.ts +80 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.js +78 -0
- package/dist/bridge.js.map +1 -0
- package/dist/decisions.d.ts +79 -0
- package/dist/decisions.d.ts.map +1 -0
- package/dist/decisions.js +211 -0
- package/dist/decisions.js.map +1 -0
- package/dist/errors.d.ts +23 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +27 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -0
- package/dist/loop.d.ts +23 -0
- package/dist/loop.d.ts.map +1 -0
- package/dist/loop.js +422 -0
- package/dist/loop.js.map +1 -0
- package/dist/persistence-redis.d.ts +84 -0
- package/dist/persistence-redis.d.ts.map +1 -0
- package/dist/persistence-redis.js +97 -0
- package/dist/persistence-redis.js.map +1 -0
- package/dist/persistence.d.ts +72 -0
- package/dist/persistence.d.ts.map +1 -0
- package/dist/persistence.js +92 -0
- package/dist/persistence.js.map +1 -0
- package/dist/trace.d.ts +76 -0
- package/dist/trace.d.ts.map +1 -0
- package/dist/trace.js +65 -0
- package/dist/trace.js.map +1 -0
- package/dist/types.d.ts +219 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +14 -0
- package/dist/types.js.map +1 -0
- package/package.json +5 -5
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory persistence shims for the adapter loop.
|
|
3
|
+
*
|
|
4
|
+
* Two stores live here:
|
|
5
|
+
* - **DeferRedis + ParkRedis** — implements the combined runtime persistence
|
|
6
|
+
* surface so `parkDeferredIntent` (write) and `resumeDeferredIntent`
|
|
7
|
+
* (read + idempotent claim) both work against a single backing object.
|
|
8
|
+
* Production wires real Redis; the in-memory shim is for tests + the
|
|
9
|
+
* quickstart.
|
|
10
|
+
*
|
|
11
|
+
* - **ConfirmationStore** — separate by design. DEFER persists by
|
|
12
|
+
* `(session, intentHash)`; REQUEST_CONFIRMATION persists by a
|
|
13
|
+
* user-held token (the user clicks "yes/no" at an arbitrary later time).
|
|
14
|
+
* Conflating them muddles both shapes.
|
|
15
|
+
*
|
|
16
|
+
* The persistence layer is provider-neutral — the `assistantHistorySnapshot`
|
|
17
|
+
* on pending confirmations is typed as a generic `H` so adapters thread
|
|
18
|
+
* their SDK's conversation-history shape through unchanged.
|
|
19
|
+
*/
|
|
20
|
+
import type { IntentEnvelope } from "@adjudicate/core";
|
|
21
|
+
/**
|
|
22
|
+
* Read + claim surface used by `resumeDeferredIntent`. Mirrors the
|
|
23
|
+
* `DeferRedis` interface in `@adjudicate/runtime`.
|
|
24
|
+
*/
|
|
25
|
+
export interface DeferRedis {
|
|
26
|
+
get(key: string): Promise<string | null>;
|
|
27
|
+
set(key: string, value: string, options: {
|
|
28
|
+
NX: true;
|
|
29
|
+
EX: number;
|
|
30
|
+
}): Promise<string | null>;
|
|
31
|
+
del(key: string): Promise<unknown>;
|
|
32
|
+
incr?(key: string): Promise<number>;
|
|
33
|
+
decr?(key: string): Promise<number>;
|
|
34
|
+
expire?(key: string, seconds: number): Promise<unknown>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Write + counter surface used by `parkDeferredIntent`. Mirrors the
|
|
38
|
+
* `ParkRedis` interface in `@adjudicate/runtime`.
|
|
39
|
+
*/
|
|
40
|
+
export interface ParkRedis {
|
|
41
|
+
incr(key: string): Promise<number>;
|
|
42
|
+
decr(key: string): Promise<number>;
|
|
43
|
+
expire(key: string, seconds: number, mode?: "NX"): Promise<unknown>;
|
|
44
|
+
set(key: string, value: string, options: {
|
|
45
|
+
EX: number;
|
|
46
|
+
}): Promise<string | null>;
|
|
47
|
+
evalIncrCheck?(counterKey: string, ttlSeconds: number, max: number): Promise<number>;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Combined in-memory implementation of `DeferRedis` AND `ParkRedis`.
|
|
51
|
+
* Suitable for tests and the quickstart. NOT suitable for production —
|
|
52
|
+
* lacks persistence, fan-out, and cross-process coordination.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createInMemoryDeferStore(): DeferRedis & ParkRedis;
|
|
55
|
+
export interface PendingConfirmation<H = unknown> {
|
|
56
|
+
readonly envelope: IntentEnvelope;
|
|
57
|
+
readonly sessionId: string;
|
|
58
|
+
readonly assistantHistorySnapshot: H;
|
|
59
|
+
readonly toolUseId: string;
|
|
60
|
+
readonly prompt: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Persistence for REQUEST_CONFIRMATION pauses. `take()` is get-and-delete:
|
|
64
|
+
* a confirmation token is single-use. A repeated take after the first
|
|
65
|
+
* resolution returns `null` (idempotent yes-then-yes).
|
|
66
|
+
*/
|
|
67
|
+
export interface ConfirmationStore<H = unknown> {
|
|
68
|
+
put(token: string, pending: PendingConfirmation<H>, ttlSeconds: number): Promise<void>;
|
|
69
|
+
take(token: string): Promise<PendingConfirmation<H> | null>;
|
|
70
|
+
}
|
|
71
|
+
export declare function createInMemoryConfirmationStore<H = unknown>(): ConfirmationStore<H>;
|
|
72
|
+
//# sourceMappingURL=persistence.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistence.d.ts","sourceRoot":"","sources":["../src/persistence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAIvD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACzC,GAAG,CACD,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QAAE,EAAE,E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,MAAM,CAAC;IAC3B,QAAQ,CAAC,wBAAwB,EAAE,CAAC,CAAC;IACrC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO;IAC5C,GAAG,CACD,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAC/B,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;CAC7D;AAOD,wBAAgB,+BAA+B,CAAC,CAAC,GAAG,OAAO,KAAK,iBAAiB,CAAC,CAAC,CAAC,CAiBnF"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory persistence shims for the adapter loop.
|
|
3
|
+
*
|
|
4
|
+
* Two stores live here:
|
|
5
|
+
* - **DeferRedis + ParkRedis** — implements the combined runtime persistence
|
|
6
|
+
* surface so `parkDeferredIntent` (write) and `resumeDeferredIntent`
|
|
7
|
+
* (read + idempotent claim) both work against a single backing object.
|
|
8
|
+
* Production wires real Redis; the in-memory shim is for tests + the
|
|
9
|
+
* quickstart.
|
|
10
|
+
*
|
|
11
|
+
* - **ConfirmationStore** — separate by design. DEFER persists by
|
|
12
|
+
* `(session, intentHash)`; REQUEST_CONFIRMATION persists by a
|
|
13
|
+
* user-held token (the user clicks "yes/no" at an arbitrary later time).
|
|
14
|
+
* Conflating them muddles both shapes.
|
|
15
|
+
*
|
|
16
|
+
* The persistence layer is provider-neutral — the `assistantHistorySnapshot`
|
|
17
|
+
* on pending confirmations is typed as a generic `H` so adapters thread
|
|
18
|
+
* their SDK's conversation-history shape through unchanged.
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* Combined in-memory implementation of `DeferRedis` AND `ParkRedis`.
|
|
22
|
+
* Suitable for tests and the quickstart. NOT suitable for production —
|
|
23
|
+
* lacks persistence, fan-out, and cross-process coordination.
|
|
24
|
+
*/
|
|
25
|
+
export function createInMemoryDeferStore() {
|
|
26
|
+
const store = new Map();
|
|
27
|
+
const counters = new Map();
|
|
28
|
+
const isAlive = (entry) => entry !== undefined && entry.expiresAt > Date.now();
|
|
29
|
+
function setRaw(key, value, options) {
|
|
30
|
+
const existing = store.get(key);
|
|
31
|
+
if (options.NX && isAlive(existing))
|
|
32
|
+
return null;
|
|
33
|
+
store.set(key, {
|
|
34
|
+
value,
|
|
35
|
+
expiresAt: Date.now() + options.EX * 1000,
|
|
36
|
+
});
|
|
37
|
+
return "OK";
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
async get(key) {
|
|
41
|
+
const entry = store.get(key);
|
|
42
|
+
if (!isAlive(entry)) {
|
|
43
|
+
if (entry !== undefined)
|
|
44
|
+
store.delete(key);
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
return entry.value;
|
|
48
|
+
},
|
|
49
|
+
async set(key, value, options) {
|
|
50
|
+
return setRaw(key, value, options);
|
|
51
|
+
},
|
|
52
|
+
async del(key) {
|
|
53
|
+
const had = store.delete(key);
|
|
54
|
+
counters.delete(key);
|
|
55
|
+
return had ? 1 : 0;
|
|
56
|
+
},
|
|
57
|
+
async incr(key) {
|
|
58
|
+
const next = (counters.get(key) ?? 0) + 1;
|
|
59
|
+
counters.set(key, next);
|
|
60
|
+
return next;
|
|
61
|
+
},
|
|
62
|
+
async decr(key) {
|
|
63
|
+
const next = (counters.get(key) ?? 0) - 1;
|
|
64
|
+
counters.set(key, next);
|
|
65
|
+
return next;
|
|
66
|
+
},
|
|
67
|
+
async expire(_key, _seconds, _mode) {
|
|
68
|
+
return 1;
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export function createInMemoryConfirmationStore() {
|
|
73
|
+
const store = new Map();
|
|
74
|
+
return {
|
|
75
|
+
async put(token, pending, ttlSeconds) {
|
|
76
|
+
store.set(token, {
|
|
77
|
+
pending,
|
|
78
|
+
expiresAt: Date.now() + ttlSeconds * 1000,
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
async take(token) {
|
|
82
|
+
const entry = store.get(token);
|
|
83
|
+
if (entry === undefined)
|
|
84
|
+
return null;
|
|
85
|
+
store.delete(token);
|
|
86
|
+
if (entry.expiresAt <= Date.now())
|
|
87
|
+
return null;
|
|
88
|
+
return entry.pending;
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=persistence.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persistence.js","sourceRoot":"","sources":["../src/persistence.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAgDH;;;;GAIG;AACH,MAAM,UAAU,wBAAwB;IACtC,MAAM,KAAK,GAAG,IAAI,GAAG,EAAiB,CAAC;IACvC,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE3C,MAAM,OAAO,GAAG,CAAC,KAAwB,EAAkB,EAAE,CAC3D,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAEtD,SAAS,MAAM,CACb,GAAW,EACX,KAAa,EACb,OAAkC;QAElC,MAAM,QAAQ,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAChC,IAAI,OAAO,CAAC,EAAE,IAAI,OAAO,CAAC,QAAQ,CAAC;YAAE,OAAO,IAAI,CAAC;QACjD,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE;YACb,KAAK;YACL,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC,EAAE,GAAG,IAAI;SAC1C,CAAC,CAAC;QACH,OAAO,IAAI,CAAC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EAAE,KAAY;YACvD,OAAO,CAAC,CAAC;QACX,CAAC;KACF,CAAC;AACJ,CAAC;AA+BD,MAAM,UAAU,+BAA+B;IAC7C,MAAM,KAAK,GAAG,IAAI,GAAG,EAAgC,CAAC;IACtD,OAAO;QACL,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,EAAE,UAAU;YAClC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE;gBACf,OAAO;gBACP,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,UAAU,GAAG,IAAI;aAC1C,CAAC,CAAC;QACL,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,KAAK;YACd,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YAC/B,IAAI,KAAK,KAAK,SAAS;gBAAE,OAAO,IAAI,CAAC;YACrC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YACpB,IAAI,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,GAAG,EAAE;gBAAE,OAAO,IAAI,CAAC;YAC/C,OAAO,KAAK,CAAC,OAAO,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/trace.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter loop trace hooks — low-cardinality lifecycle events.
|
|
3
|
+
*
|
|
4
|
+
* The adapter loop's existing `AgentEvent` stream is detailed enough
|
|
5
|
+
* for replay and debugging but unfocused for observability — every
|
|
6
|
+
* tool_use, tool_result, intent_proposed, etc. is an event, which is
|
|
7
|
+
* the WRONG cardinality for production tracing.
|
|
8
|
+
*
|
|
9
|
+
* This module is the focused TRACE surface: a small set of phase
|
|
10
|
+
* transitions an operator dashboard wants to know about, with
|
|
11
|
+
* controlled-vocabulary attribute strings.
|
|
12
|
+
*
|
|
13
|
+
* # What goes through here
|
|
14
|
+
*
|
|
15
|
+
* - `iteration_start` — bumping the iteration counter
|
|
16
|
+
* - `tool_use_seen` — total count of LLM tool_use blocks per turn
|
|
17
|
+
* - `decision_emitted` — kernel returned a Decision
|
|
18
|
+
* - `paused` — DEFER/REQUEST_CONFIRMATION/ESCALATE handled
|
|
19
|
+
* - `completed` — loop terminated cleanly
|
|
20
|
+
*
|
|
21
|
+
* Adopters wire `TraceSink` to their observability stack:
|
|
22
|
+
*
|
|
23
|
+
* const traceSink: TraceSink = {
|
|
24
|
+
* onTrace(evt) {
|
|
25
|
+
* tracer.startSpan(evt.phase, { attributes: evt.attributes }).end();
|
|
26
|
+
* }
|
|
27
|
+
* };
|
|
28
|
+
*
|
|
29
|
+
* Pass to `createAdjudicatedAgent({ ..., traceSink })`. The loop fires
|
|
30
|
+
* one TraceEvent per documented phase per session. NO per-record
|
|
31
|
+
* fan-out. NO high-cardinality data (intent payloads, conversation
|
|
32
|
+
* history). Cardinality is bounded by `(pack-id × decision-kind × phase)`.
|
|
33
|
+
*
|
|
34
|
+
* # Replay safety
|
|
35
|
+
*
|
|
36
|
+
* Trace emission is fire-and-forget. The sink MUST NOT throw — the loop
|
|
37
|
+
* does not try/catch around it. If the sink misbehaves, adjudication
|
|
38
|
+
* still completes; only telemetry is lost.
|
|
39
|
+
*/
|
|
40
|
+
import type { Decision } from "@adjudicate/core";
|
|
41
|
+
export type AdapterTracePhase = "iteration_start" | "decision_emitted" | "paused" | "completed" | "max_iterations_exceeded";
|
|
42
|
+
export type AdapterPauseReason = "deferred" | "awaiting_confirmation" | "escalated";
|
|
43
|
+
/**
|
|
44
|
+
* A single trace event from the adapter loop. The attributes are
|
|
45
|
+
* deliberately small + controlled-vocabulary; adopters MUST NOT add
|
|
46
|
+
* per-payload data here. (For replayable forensic detail use the
|
|
47
|
+
* AgentEvent stream, which is record-grained.)
|
|
48
|
+
*/
|
|
49
|
+
export interface AdapterTraceEvent {
|
|
50
|
+
readonly phase: AdapterTracePhase;
|
|
51
|
+
readonly sessionId: string;
|
|
52
|
+
/** 1-based iteration counter, capped by `maxIterations`. */
|
|
53
|
+
readonly iteration: number;
|
|
54
|
+
/** Set when the event corresponds to a Decision. */
|
|
55
|
+
readonly decisionKind?: Decision["kind"];
|
|
56
|
+
/** Set on `phase === "paused"`. */
|
|
57
|
+
readonly pauseReason?: AdapterPauseReason;
|
|
58
|
+
}
|
|
59
|
+
/** Adopter-supplied trace sink. MUST NOT throw. */
|
|
60
|
+
export interface TraceSink {
|
|
61
|
+
onTrace(event: AdapterTraceEvent): void;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* No-op trace sink. Default when none is supplied. Zero allocation,
|
|
65
|
+
* zero overhead.
|
|
66
|
+
*/
|
|
67
|
+
export declare const noopTraceSink: TraceSink;
|
|
68
|
+
/**
|
|
69
|
+
* In-memory trace sink for tests. Captures every event in
|
|
70
|
+
* registration order.
|
|
71
|
+
*/
|
|
72
|
+
export declare function createInMemoryTraceSink(): TraceSink & {
|
|
73
|
+
readonly events: ReadonlyArray<AdapterTraceEvent>;
|
|
74
|
+
reset(): void;
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=trace.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.d.ts","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,MAAM,MAAM,iBAAiB,GACzB,iBAAiB,GACjB,kBAAkB,GAClB,QAAQ,GACR,WAAW,GACX,yBAAyB,CAAC;AAE9B,MAAM,MAAM,kBAAkB,GAC1B,UAAU,GACV,uBAAuB,GACvB,WAAW,CAAC;AAEhB;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,iBAAiB,CAAC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,4DAA4D;IAC5D,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,oDAAoD;IACpD,QAAQ,CAAC,YAAY,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACzC,mCAAmC;IACnC,QAAQ,CAAC,WAAW,CAAC,EAAE,kBAAkB,CAAC;CAC3C;AAED,mDAAmD;AACnD,MAAM,WAAW,SAAS;IACxB,OAAO,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,CAAC;CACzC;AAED;;;GAGG;AACH,eAAO,MAAM,aAAa,EAAE,SAI3B,CAAC;AAEF;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,SAAS,GAAG;IACrD,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,iBAAiB,CAAC,CAAC;IAClD,KAAK,IAAI,IAAI,CAAC;CACf,CAWA"}
|
package/dist/trace.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter loop trace hooks — low-cardinality lifecycle events.
|
|
3
|
+
*
|
|
4
|
+
* The adapter loop's existing `AgentEvent` stream is detailed enough
|
|
5
|
+
* for replay and debugging but unfocused for observability — every
|
|
6
|
+
* tool_use, tool_result, intent_proposed, etc. is an event, which is
|
|
7
|
+
* the WRONG cardinality for production tracing.
|
|
8
|
+
*
|
|
9
|
+
* This module is the focused TRACE surface: a small set of phase
|
|
10
|
+
* transitions an operator dashboard wants to know about, with
|
|
11
|
+
* controlled-vocabulary attribute strings.
|
|
12
|
+
*
|
|
13
|
+
* # What goes through here
|
|
14
|
+
*
|
|
15
|
+
* - `iteration_start` — bumping the iteration counter
|
|
16
|
+
* - `tool_use_seen` — total count of LLM tool_use blocks per turn
|
|
17
|
+
* - `decision_emitted` — kernel returned a Decision
|
|
18
|
+
* - `paused` — DEFER/REQUEST_CONFIRMATION/ESCALATE handled
|
|
19
|
+
* - `completed` — loop terminated cleanly
|
|
20
|
+
*
|
|
21
|
+
* Adopters wire `TraceSink` to their observability stack:
|
|
22
|
+
*
|
|
23
|
+
* const traceSink: TraceSink = {
|
|
24
|
+
* onTrace(evt) {
|
|
25
|
+
* tracer.startSpan(evt.phase, { attributes: evt.attributes }).end();
|
|
26
|
+
* }
|
|
27
|
+
* };
|
|
28
|
+
*
|
|
29
|
+
* Pass to `createAdjudicatedAgent({ ..., traceSink })`. The loop fires
|
|
30
|
+
* one TraceEvent per documented phase per session. NO per-record
|
|
31
|
+
* fan-out. NO high-cardinality data (intent payloads, conversation
|
|
32
|
+
* history). Cardinality is bounded by `(pack-id × decision-kind × phase)`.
|
|
33
|
+
*
|
|
34
|
+
* # Replay safety
|
|
35
|
+
*
|
|
36
|
+
* Trace emission is fire-and-forget. The sink MUST NOT throw — the loop
|
|
37
|
+
* does not try/catch around it. If the sink misbehaves, adjudication
|
|
38
|
+
* still completes; only telemetry is lost.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* No-op trace sink. Default when none is supplied. Zero allocation,
|
|
42
|
+
* zero overhead.
|
|
43
|
+
*/
|
|
44
|
+
export const noopTraceSink = {
|
|
45
|
+
onTrace() {
|
|
46
|
+
/* no-op */
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* In-memory trace sink for tests. Captures every event in
|
|
51
|
+
* registration order.
|
|
52
|
+
*/
|
|
53
|
+
export function createInMemoryTraceSink() {
|
|
54
|
+
const events = [];
|
|
55
|
+
return {
|
|
56
|
+
events,
|
|
57
|
+
onTrace(event) {
|
|
58
|
+
events.push(event);
|
|
59
|
+
},
|
|
60
|
+
reset() {
|
|
61
|
+
events.length = 0;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=trace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"trace.js","sourceRoot":"","sources":["../src/trace.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAsCH;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAc;IACtC,OAAO;QACL,WAAW;IACb,CAAC;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,uBAAuB;IAIrC,MAAM,MAAM,GAAwB,EAAE,CAAC;IACvC,OAAO;QACL,MAAM;QACN,OAAO,CAAC,KAAK;YACX,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACrB,CAAC;QACD,KAAK;YACH,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QACpB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-neutral types for the adapter loop.
|
|
3
|
+
*
|
|
4
|
+
* The shapes in this module describe what the loop needs to know, NOT
|
|
5
|
+
* what any specific LLM SDK ships. Provider adapters
|
|
6
|
+
* (`@adjudicate/anthropic`, `@adjudicate/openai`, …) translate between
|
|
7
|
+
* their SDK's wire types and these.
|
|
8
|
+
*
|
|
9
|
+
* History `H` is opaque: the loop never inspects it. The provider bridge
|
|
10
|
+
* appends user messages, assistant turns, and tool results in whatever
|
|
11
|
+
* shape the SDK consumes.
|
|
12
|
+
*/
|
|
13
|
+
import type { AuditSink, Decision, IntentEnvelope, Ledger, PackV0, Taint } from "@adjudicate/core";
|
|
14
|
+
import type { PromptRenderer, ToolSchema } from "@adjudicate/core/llm";
|
|
15
|
+
import type { RuntimeContext } from "@adjudicate/core/kernel";
|
|
16
|
+
import type { ConfirmationStore, DeferRedis, ParkRedis } from "./persistence.js";
|
|
17
|
+
import type { TraceSink } from "./trace.js";
|
|
18
|
+
/**
|
|
19
|
+
* Provider-neutral representation of a tool-use request emitted by the
|
|
20
|
+
* model. Anthropic adapters map `ToolUseBlock` → `ToolUseRequest`; OpenAI
|
|
21
|
+
* adapters map `function_call` / `tool_calls[].function` similarly.
|
|
22
|
+
*/
|
|
23
|
+
export interface ToolUseRequest {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly input: unknown;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Provider-neutral representation of a single assistant turn (text and
|
|
30
|
+
* any tool-use blocks). The bridge fans out the SDK-specific response.
|
|
31
|
+
*/
|
|
32
|
+
export interface AssistantTurn {
|
|
33
|
+
readonly textBlocks: ReadonlyArray<string>;
|
|
34
|
+
readonly toolUses: ReadonlyArray<ToolUseRequest>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Provider-neutral tool-result payload returned to the model. The bridge
|
|
38
|
+
* encodes this into whatever shape the SDK consumes (Anthropic
|
|
39
|
+
* `tool_result` block; OpenAI `role: "tool"` message).
|
|
40
|
+
*/
|
|
41
|
+
export interface ToolResultBlock {
|
|
42
|
+
readonly toolUseId: string;
|
|
43
|
+
readonly content: string;
|
|
44
|
+
readonly isError?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Adopter-supplied side-effect runner. Called only after the kernel
|
|
48
|
+
* returns EXECUTE (or REWRITE — the executor receives the rewritten
|
|
49
|
+
* envelope, NOT the original).
|
|
50
|
+
*
|
|
51
|
+
* READ tools that the LLM proposes go through `invokeRead`; intent
|
|
52
|
+
* executions that the kernel authorized go through `invokeIntent`.
|
|
53
|
+
*/
|
|
54
|
+
export interface AdopterExecutor<K extends string, P, S> {
|
|
55
|
+
invokeRead(name: string, input: unknown, state: S): Promise<unknown>;
|
|
56
|
+
invokeIntent(envelope: IntentEnvelope<K, P>, state: S): Promise<unknown>;
|
|
57
|
+
}
|
|
58
|
+
export interface AgentLogger {
|
|
59
|
+
info?: (obj: Record<string, unknown>, msg?: string) => void;
|
|
60
|
+
warn?: (obj: Record<string, unknown>, msg?: string) => void;
|
|
61
|
+
debug?: (obj: Record<string, unknown>, msg?: string) => void;
|
|
62
|
+
}
|
|
63
|
+
export interface ProviderRequest {
|
|
64
|
+
readonly systemPrompt: string;
|
|
65
|
+
readonly maxTokens: number;
|
|
66
|
+
readonly toolSchemas: ReadonlyArray<ToolSchema>;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The provider-neutral driver for the LLM call. Provider adapters
|
|
70
|
+
* implement this against their SDK; the loop calls it once per
|
|
71
|
+
* iteration. `H` is the opaque conversation-history shape — provider
|
|
72
|
+
* adapters choose what `H` is (typically `MessageParam[]` for Anthropic,
|
|
73
|
+
* `ChatCompletionMessageParam[]` for OpenAI). The loop never inspects it.
|
|
74
|
+
*/
|
|
75
|
+
export interface ProviderBridge<H> {
|
|
76
|
+
/** Construct the empty initial history. */
|
|
77
|
+
emptyHistory(): H;
|
|
78
|
+
/** Append a user message to the history. */
|
|
79
|
+
appendUserMessage(history: H, text: string): H;
|
|
80
|
+
/**
|
|
81
|
+
* Send the prompt + history; receive the assistant turn back. The
|
|
82
|
+
* bridge appends the raw assistant response to history before
|
|
83
|
+
* returning. The provider-neutral `turn` describes what the loop
|
|
84
|
+
* actually needs to know about the response.
|
|
85
|
+
*/
|
|
86
|
+
send(history: H, request: ProviderRequest): Promise<{
|
|
87
|
+
history: H;
|
|
88
|
+
turn: AssistantTurn;
|
|
89
|
+
}>;
|
|
90
|
+
/**
|
|
91
|
+
* Append a list of tool-result blocks to the history (typically a
|
|
92
|
+
* user-role message containing tool_result blocks for Anthropic; a
|
|
93
|
+
* series of `role: "tool"` messages for OpenAI).
|
|
94
|
+
*/
|
|
95
|
+
appendToolResults(history: H, results: ReadonlyArray<ToolResultBlock>): H;
|
|
96
|
+
}
|
|
97
|
+
export interface AdjudicatedAgentOptions<K extends string, P, S, C, H> {
|
|
98
|
+
/**
|
|
99
|
+
* Pack the agent adjudicates against. MUST already be the output of
|
|
100
|
+
* `installPack(...)` or `withBasisAudit(...)`. The adapter does NOT
|
|
101
|
+
* double-wrap — Pack-author convention applies.
|
|
102
|
+
*/
|
|
103
|
+
readonly pack: PackV0<K, P, S, C>;
|
|
104
|
+
/** Renderer producing system prompt + tool schemas for each iteration. */
|
|
105
|
+
readonly renderer: PromptRenderer<S, C>;
|
|
106
|
+
/** Provider bridge wrapping the SDK. */
|
|
107
|
+
readonly bridge: ProviderBridge<H>;
|
|
108
|
+
/** Persistence for DEFER. Combined park + resume surface. */
|
|
109
|
+
readonly deferStore: DeferRedis & ParkRedis;
|
|
110
|
+
/** Persistence for REQUEST_CONFIRMATION pauses (generic over H). */
|
|
111
|
+
readonly confirmationStore: ConfirmationStore<H>;
|
|
112
|
+
readonly auditSink?: AuditSink;
|
|
113
|
+
/** Required: Execution Ledger for replay suppression. */
|
|
114
|
+
readonly ledger: Ledger;
|
|
115
|
+
/** Optional tenant context. */
|
|
116
|
+
readonly runtimeContext?: RuntimeContext;
|
|
117
|
+
/** Hard cap on assistant↔tool ping-pong per .send() call. Defaults to 8. */
|
|
118
|
+
readonly maxIterations?: number;
|
|
119
|
+
/** Adopter-owned executor. Required. */
|
|
120
|
+
readonly executor: AdopterExecutor<K, P, S>;
|
|
121
|
+
/** `rk()` namespacer for the deferStore. Defaults to identity. */
|
|
122
|
+
readonly rk?: (raw: string) => string;
|
|
123
|
+
/** Override the nonce derived from each tool_use block. */
|
|
124
|
+
readonly deriveNonce?: (args: {
|
|
125
|
+
sessionId: string;
|
|
126
|
+
toolUseId: string;
|
|
127
|
+
payload: unknown;
|
|
128
|
+
}) => string;
|
|
129
|
+
readonly log?: AgentLogger;
|
|
130
|
+
/** Hash-verification policy for parked envelope blobs at resume. */
|
|
131
|
+
readonly verifyParkedHash?: "strict" | "warn" | "off";
|
|
132
|
+
/**
|
|
133
|
+
* Optional low-cardinality trace sink. The loop emits one event per
|
|
134
|
+
* iteration/decision/pause; sink must NOT throw. Defaults to no-op.
|
|
135
|
+
* See `./trace.ts` for the controlled-vocabulary event shape.
|
|
136
|
+
*/
|
|
137
|
+
readonly traceSink?: TraceSink;
|
|
138
|
+
}
|
|
139
|
+
export interface SendInput<S, C, H> {
|
|
140
|
+
readonly sessionId: string;
|
|
141
|
+
readonly userMessage: string;
|
|
142
|
+
readonly state: S;
|
|
143
|
+
readonly context: C;
|
|
144
|
+
readonly history?: H;
|
|
145
|
+
}
|
|
146
|
+
export interface ResumeArgs<S, C, H> {
|
|
147
|
+
readonly sessionId: string;
|
|
148
|
+
readonly signal: string;
|
|
149
|
+
readonly state: S;
|
|
150
|
+
readonly context: C;
|
|
151
|
+
readonly history?: H;
|
|
152
|
+
}
|
|
153
|
+
export interface ConfirmArgs<S, C> {
|
|
154
|
+
readonly confirmationToken: string;
|
|
155
|
+
readonly accepted: boolean;
|
|
156
|
+
readonly state: S;
|
|
157
|
+
readonly context: C;
|
|
158
|
+
}
|
|
159
|
+
export type AgentOutcome = {
|
|
160
|
+
kind: "completed";
|
|
161
|
+
assistantText: string;
|
|
162
|
+
} | {
|
|
163
|
+
kind: "deferred";
|
|
164
|
+
signal: string;
|
|
165
|
+
intentHash: string;
|
|
166
|
+
} | {
|
|
167
|
+
kind: "awaiting_confirmation";
|
|
168
|
+
prompt: string;
|
|
169
|
+
confirmationToken: string;
|
|
170
|
+
} | {
|
|
171
|
+
kind: "escalated";
|
|
172
|
+
to: "human" | "supervisor";
|
|
173
|
+
reason: string;
|
|
174
|
+
} | {
|
|
175
|
+
kind: "max_iterations_exceeded";
|
|
176
|
+
lastDecision: Decision | null;
|
|
177
|
+
};
|
|
178
|
+
export interface AgentTurnResult<H> {
|
|
179
|
+
readonly events: ReadonlyArray<AgentEvent>;
|
|
180
|
+
readonly history: H;
|
|
181
|
+
readonly outcome: AgentOutcome;
|
|
182
|
+
}
|
|
183
|
+
export type AgentEvent = {
|
|
184
|
+
kind: "user_message";
|
|
185
|
+
text: string;
|
|
186
|
+
} | {
|
|
187
|
+
kind: "assistant_text";
|
|
188
|
+
text: string;
|
|
189
|
+
} | {
|
|
190
|
+
kind: "tool_use";
|
|
191
|
+
toolUseId: string;
|
|
192
|
+
toolName: string;
|
|
193
|
+
input: unknown;
|
|
194
|
+
} | {
|
|
195
|
+
kind: "intent_proposed";
|
|
196
|
+
envelope: IntentEnvelope;
|
|
197
|
+
} | {
|
|
198
|
+
kind: "decision";
|
|
199
|
+
decision: Decision;
|
|
200
|
+
envelope: IntentEnvelope;
|
|
201
|
+
} | {
|
|
202
|
+
kind: "handler_result";
|
|
203
|
+
toolUseId: string;
|
|
204
|
+
result: unknown;
|
|
205
|
+
} | {
|
|
206
|
+
kind: "tool_result";
|
|
207
|
+
toolUseId: string;
|
|
208
|
+
payload: ToolResultBlock;
|
|
209
|
+
};
|
|
210
|
+
export interface AdjudicatedAgent<_K extends string, _P, S, C, H> {
|
|
211
|
+
/** One user message + (state, context) snapshot → resolved turn. */
|
|
212
|
+
send(input: SendInput<S, C, H>): Promise<AgentTurnResult<H>>;
|
|
213
|
+
/** Resume a parked DEFER (typically from an adopter's webhook handler). */
|
|
214
|
+
resume(args: ResumeArgs<S, C, H>): Promise<AgentTurnResult<H>>;
|
|
215
|
+
/** Resume a REQUEST_CONFIRMATION with a yes/no from the user. */
|
|
216
|
+
confirm(args: ConfirmArgs<S, C>): Promise<AgentTurnResult<H>>;
|
|
217
|
+
}
|
|
218
|
+
export type { Taint };
|
|
219
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EACV,SAAS,EACT,QAAQ,EACR,cAAc,EACd,MAAM,EACN,MAAM,EACN,KAAK,EACN,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,KAAK,EACV,iBAAiB,EACjB,UAAU,EACV,SAAS,EACV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAI5C;;;;GAIG;AACH,MAAM,WAAW,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|
3
|
+
*
|
|
4
|
+
* The shapes in this module describe what the loop needs to know, NOT
|
|
5
|
+
* what any specific LLM SDK ships. Provider adapters
|
|
6
|
+
* (`@adjudicate/anthropic`, `@adjudicate/openai`, …) translate between
|
|
7
|
+
* their SDK's wire types and these.
|
|
8
|
+
*
|
|
9
|
+
* History `H` is opaque: the loop never inspects it. The provider bridge
|
|
10
|
+
* appends user messages, assistant turns, and tool results in whatever
|
|
11
|
+
* shape the SDK consumes.
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adjudicate/adapter-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
+
"@adjudicate/audit": "1.0.1",
|
|
18
19
|
"@adjudicate/core": "1.0.0",
|
|
19
|
-
"@adjudicate/
|
|
20
|
-
"@adjudicate/runtime": "0.1.0"
|
|
20
|
+
"@adjudicate/runtime": "0.1.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@eslint/eslintrc": "^3.0.0",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"eslint": "^9.0.0",
|
|
26
26
|
"typescript": "^5.9.0",
|
|
27
27
|
"vitest": "^3.2.0",
|
|
28
|
-
"@adjudicate/
|
|
29
|
-
"@adjudicate/
|
|
28
|
+
"@adjudicate/eslint-config": "0.0.1",
|
|
29
|
+
"@adjudicate/pack-payments-pix": "0.1.1"
|
|
30
30
|
},
|
|
31
31
|
"scripts": {
|
|
32
32
|
"build": "tsc --outDir dist",
|