@silverprotocol/core 0.9.0 → 0.11.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 +7 -2
- package/dist/agjson.d.ts +14 -19
- package/dist/agjson.d.ts.map +1 -1
- package/dist/agjson.js +5 -2
- package/dist/agjson.js.map +1 -1
- package/dist/atomic-push.d.ts +16 -2
- package/dist/atomic-push.d.ts.map +1 -1
- package/dist/atomic-push.js +11 -2
- package/dist/atomic-push.js.map +1 -1
- package/dist/input-check.d.ts +1 -1
- package/dist/input-check.js +1 -1
- package/dist/reduce.d.ts.map +1 -1
- package/dist/reduce.js +4 -0
- package/dist/reduce.js.map +1 -1
- package/dist/stream-assembler.d.ts +32 -5
- package/dist/stream-assembler.d.ts.map +1 -1
- package/dist/stream-assembler.js +5 -0
- package/dist/stream-assembler.js.map +1 -1
- package/dist/wire.d.ts +36 -5
- package/dist/wire.d.ts.map +1 -1
- package/dist/wire.js +26 -3
- package/dist/wire.js.map +1 -1
- package/package.json +1 -1
- package/src/agjson.ts +5 -2
- package/src/atomic-push.ts +16 -2
- package/src/input-check.ts +1 -1
- package/src/reduce.ts +3 -0
- package/src/stream-assembler.ts +32 -5
- package/src/wire.ts +36 -5
package/dist/wire.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wire.js","sourceRoot":"","sources":["../src/wire.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,MAAM,CAAC,CAAU;IAC/B,MAAM,CAAC,GAAc,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,MAAM,UAAU,WAAW,CAAC,CAAU;IACpC,MAAM,CAAC,GAAc,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IACnD,OAAO,CAAC,CAAC;AACX,CAAC;AAED
|
|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AAC;gBAChC,IAAI,IAAa,CAAC;gBAClB,IAAI,CAAC;oBACH,IAAI,GAAI,GAA+B,CAAC,CAAC,CAAC,CAAC;gBAC7C,CAAC;gBAAC,MAAM,CAAC;oBACP,MAAM,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,CAAC,CAAC;oBAClD,SAAS;gBACX,CAAC;gBACD,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;gBACzC,IAAI,CAAC,KAAK,IAAI;oBAAE,SAAS;gBACzB,kEAAkE;gBAClE,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;YACpG,CAAC;YACD,OAAO,GAAG,CAAC;QACb,CAAC;gBAAS,CAAC;YACT,SAAS,CAAC,GAAG,EAAE,CAAC;QAClB,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACnC,OAAO,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,CAAC;AACtD,CAAC"}
|
package/package.json
CHANGED
package/src/agjson.ts
CHANGED
|
@@ -711,6 +711,7 @@ export const AgTurnRecord = z.object({
|
|
|
711
711
|
})).optional(), // grounding sources folded from source events (audit M23); sourceIds stays as the derived index
|
|
712
712
|
promptBlocked: z.object({
|
|
713
713
|
reason: z.enum(["safety", "blocklist", "prohibited", "other"]), // mirrors the §4 prompt.blocked reason enum exactly
|
|
714
|
+
reasonRaw: z.string().optional(), // folded from prompt.blocked.reasonRaw verbatim (draft.8)
|
|
714
715
|
safety: z.array(AgSafety).optional(),
|
|
715
716
|
}).optional(), // audit M28
|
|
716
717
|
asks: z.array(AgPausedAsk).optional(),
|
|
@@ -742,6 +743,7 @@ export const AgMemoryRecord = z.object({
|
|
|
742
743
|
durable: z.boolean().optional(),
|
|
743
744
|
turnId: z.string().optional(),
|
|
744
745
|
threadId: z.string().optional(),
|
|
746
|
+
_meta: AgMeta.optional(), // the setting write's _meta (§5): a value write replaces it, a patch only when it carries one
|
|
745
747
|
});
|
|
746
748
|
export type AgMemoryRecord = z.infer<typeof AgMemoryRecord>;
|
|
747
749
|
|
|
@@ -794,7 +796,7 @@ export type AgClientCapabilities = z.infer<typeof AgClientCapabilities>;
|
|
|
794
796
|
// + Anthropic/Gemini thinking `budgetTokens`.
|
|
795
797
|
export const AgReasoningConfig = z.object({
|
|
796
798
|
mode: z.enum(["enabled", "disabled"]),
|
|
797
|
-
effort: z.
|
|
799
|
+
effort: z.string().optional(), // an open string (§3, §12 draft.8): "minimal" | "low" | "medium" | "high" are documented; any other value passes
|
|
798
800
|
budgetTokens: z.number().optional(),
|
|
799
801
|
});
|
|
800
802
|
export type AgReasoningConfig = z.infer<typeof AgReasoningConfig>;
|
|
@@ -858,7 +860,7 @@ export type AgRunConfig = z.infer<typeof AgRunConfig>;
|
|
|
858
860
|
|
|
859
861
|
// The spec version this SDK implements (SPEC.md status line + §12). Consumers
|
|
860
862
|
// reject a MAJOR mismatch and accept any same-major version (§12 negotiation).
|
|
861
|
-
export const AGJSON_VERSION = "1.0.0-draft.
|
|
863
|
+
export const AGJSON_VERSION = "1.0.0-draft.8";
|
|
862
864
|
|
|
863
865
|
const agjsonWireVersion = z
|
|
864
866
|
.string()
|
|
@@ -1375,6 +1377,7 @@ export const AgClosedEvent = z.discriminatedUnion("type", [
|
|
|
1375
1377
|
...base,
|
|
1376
1378
|
type: z.literal("prompt.blocked"),
|
|
1377
1379
|
reason: z.enum(["safety", "blocklist", "prohibited", "other"]),
|
|
1380
|
+
reasonRaw: z.string().optional(), // the native block reason verbatim, e.g. when reason is "other" (§4, draft.8)
|
|
1378
1381
|
safety: z.array(AgSafety).optional(),
|
|
1379
1382
|
}),
|
|
1380
1383
|
// ── MESSAGE OPERATIONS ──
|
package/src/atomic-push.ts
CHANGED
|
@@ -22,11 +22,18 @@ import type { AgEvent, JsonValue } from "./agjson.js";
|
|
|
22
22
|
import type { Normalizer } from "./stream-assembler.js";
|
|
23
23
|
import { isJsonValue, toJsonValue, toJsonValueSafe } from "./wire.js";
|
|
24
24
|
|
|
25
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* The constant `message` of the guard's core `error` event.
|
|
27
|
+
*
|
|
28
|
+
* @beta
|
|
29
|
+
*/
|
|
26
30
|
export const NORMALIZER_ERROR_MESSAGE = "normalizer error";
|
|
27
31
|
|
|
28
32
|
/** The guard's `code`: the thrown value's constructor NAME only, never its
|
|
29
|
-
* message (a SyntaxError quotes its input) and never the native.
|
|
33
|
+
* message (a SyntaxError quotes its input) and never the native.
|
|
34
|
+
*
|
|
35
|
+
* @beta
|
|
36
|
+
*/
|
|
30
37
|
export function normalizerErrorCode(err: unknown): string {
|
|
31
38
|
try {
|
|
32
39
|
if (err instanceof Error) return err.constructor.name || "Error";
|
|
@@ -36,6 +43,11 @@ export function normalizerErrorCode(err: unknown): string {
|
|
|
36
43
|
return "NonError";
|
|
37
44
|
}
|
|
38
45
|
|
|
46
|
+
/**
|
|
47
|
+
* Options for {@link withAtomicPush}.
|
|
48
|
+
*
|
|
49
|
+
* @beta
|
|
50
|
+
*/
|
|
39
51
|
export interface AtomicPushOptions {
|
|
40
52
|
/** Run {@link toJsonValueSafe} on each native before the inner push (default
|
|
41
53
|
* true). With it the journal holds a JSON deep copy of what the inner saw,
|
|
@@ -79,6 +91,8 @@ export interface AtomicPushOptions {
|
|
|
79
91
|
* invoke (§8.0 obligation 3).
|
|
80
92
|
* - Time: O(bad × prefix). Each throw re-drives the invoke so far, output
|
|
81
93
|
* dropped. Nothing is paid when nothing throws, beyond the copy.
|
|
94
|
+
*
|
|
95
|
+
* @beta
|
|
82
96
|
*/
|
|
83
97
|
export function withAtomicPush(createInner: () => Normalizer, opts: AtomicPushOptions = {}): Normalizer {
|
|
84
98
|
const normalize = opts.normalize ?? true;
|
package/src/input-check.ts
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
* - `major-mismatch`, at `["version"]`: `version` differs in MAJOR (§12);
|
|
12
12
|
* - `unknown-value`: the value at the path is a STRING that the closed set
|
|
13
13
|
* there does not define (an `AgInput.kind`, an `AgHitlAnswer.status`, a
|
|
14
|
-
* reasoning `
|
|
14
|
+
* reasoning `mode`, an `AgBlock` `type`, …). zod's codes alone cannot
|
|
15
15
|
* tell this from malformed, so the rule reads the raw value (bar CB-6);
|
|
16
16
|
* - `malformed`: every other failure — a missing value, a value of the wrong
|
|
17
17
|
* JSON type, a value that breaks a stated constraint, a non-JSON input, or
|
package/src/reduce.ts
CHANGED
|
@@ -938,6 +938,7 @@ export class Reducer {
|
|
|
938
938
|
}
|
|
939
939
|
turn.promptBlocked = {
|
|
940
940
|
reason: ev.reason,
|
|
941
|
+
...(ev.reasonRaw !== undefined ? { reasonRaw: ev.reasonRaw } : {}),
|
|
941
942
|
...(ev.safety !== undefined ? { safety: ev.safety } : {}),
|
|
942
943
|
};
|
|
943
944
|
break;
|
|
@@ -1109,6 +1110,7 @@ export class Reducer {
|
|
|
1109
1110
|
...(ev.reason !== undefined ? { reason: ev.reason } : {}),
|
|
1110
1111
|
...(ev.durable !== undefined ? { durable: ev.durable } : {}),
|
|
1111
1112
|
...(ev.turnId !== undefined ? { turnId: ev.turnId } : {}),
|
|
1113
|
+
...(ev._meta !== undefined ? { _meta: ev._meta } : {}),
|
|
1112
1114
|
};
|
|
1113
1115
|
this.#memory.set(memKey, record);
|
|
1114
1116
|
} else if (ev.patch !== undefined) {
|
|
@@ -1129,6 +1131,7 @@ export class Reducer {
|
|
|
1129
1131
|
existing.value = result.value;
|
|
1130
1132
|
if (ev.reason !== undefined) existing.reason = ev.reason;
|
|
1131
1133
|
if (ev.durable !== undefined) existing.durable = ev.durable;
|
|
1134
|
+
if (ev._meta !== undefined) existing._meta = ev._meta;
|
|
1132
1135
|
}
|
|
1133
1136
|
break;
|
|
1134
1137
|
}
|
package/src/stream-assembler.ts
CHANGED
|
@@ -52,19 +52,33 @@ type DistributiveOmit<T, K extends keyof never> = T extends unknown ? Omit<T, K>
|
|
|
52
52
|
* `AgClosedEventType` arm spreads `...base`, which already carries both), but
|
|
53
53
|
* `DistributiveOmit` over the union does not surface them uniformly to callers
|
|
54
54
|
* (e.g. `emit()`'s `ev.turnId` read) without this alias-level annotation.
|
|
55
|
+
*
|
|
56
|
+
* @beta
|
|
55
57
|
*/
|
|
56
58
|
export type SeqlessEvent = DistributiveOmit<AgClosedEventType, "seq"> & {
|
|
57
59
|
turnId?: string;
|
|
58
60
|
messageId?: string;
|
|
59
61
|
};
|
|
60
62
|
|
|
61
|
-
/**
|
|
63
|
+
/**
|
|
64
|
+
* Fields for `toolStart`: the tool.start arm minus base envelope fields.
|
|
65
|
+
*
|
|
66
|
+
* @beta
|
|
67
|
+
*/
|
|
62
68
|
export type ToolStartFields = Omit<ToolStartEvent, "type" | "seq" | "turnId">;
|
|
63
69
|
|
|
64
|
-
/**
|
|
70
|
+
/**
|
|
71
|
+
* Fields for `toolDone`: the tool.done arm minus base envelope fields + optional turnId for backfill.
|
|
72
|
+
*
|
|
73
|
+
* @beta
|
|
74
|
+
*/
|
|
65
75
|
export type ToolDoneFields = Omit<ToolDoneEvent, "type" | "seq"> & { turnId?: string };
|
|
66
76
|
|
|
67
|
-
/**
|
|
77
|
+
/**
|
|
78
|
+
* Fields required by `openMessage`. Mirrors the load-bearing fields on `message.start`.
|
|
79
|
+
*
|
|
80
|
+
* @beta
|
|
81
|
+
*/
|
|
68
82
|
export interface OpenMessageFields {
|
|
69
83
|
id: string;
|
|
70
84
|
role: AgRole;
|
|
@@ -78,7 +92,11 @@ export interface OpenMessageFields {
|
|
|
78
92
|
model?: string;
|
|
79
93
|
}
|
|
80
94
|
|
|
81
|
-
/**
|
|
95
|
+
/**
|
|
96
|
+
* Fields required by `closeTurnDone`.
|
|
97
|
+
*
|
|
98
|
+
* @beta
|
|
99
|
+
*/
|
|
82
100
|
export type TurnDoneFields = Omit<TurnDoneEvent, "type" | "seq" | "turnId">;
|
|
83
101
|
|
|
84
102
|
/** Stateful push/flush interface implemented by concrete Normalizer facets. */
|
|
@@ -104,7 +122,11 @@ const RESERVED_EXT_KEYS = new Set<string>([
|
|
|
104
122
|
"_meta",
|
|
105
123
|
]);
|
|
106
124
|
|
|
107
|
-
/**
|
|
125
|
+
/**
|
|
126
|
+
* An opaque {@link StreamAssembler.checkpoint} value: restore it with {@link StreamAssembler.rollback}.
|
|
127
|
+
*
|
|
128
|
+
* @beta
|
|
129
|
+
*/
|
|
108
130
|
export interface AssemblerCheckpoint {
|
|
109
131
|
readonly seq: number;
|
|
110
132
|
readonly seenTurns: ReadonlySet<string>;
|
|
@@ -118,6 +140,11 @@ export interface AssemblerCheckpoint {
|
|
|
118
140
|
readonly bufferLength: number;
|
|
119
141
|
}
|
|
120
142
|
|
|
143
|
+
/**
|
|
144
|
+
* The seq, turn and message bookkeeping a normalizer emits through: it stamps `seq`, opens and closes turns and messages, and backfills ids.
|
|
145
|
+
*
|
|
146
|
+
* @beta
|
|
147
|
+
*/
|
|
121
148
|
export class StreamAssembler {
|
|
122
149
|
// Turn-scoped monotonic sequence counter (never calls Date.now/Math.random).
|
|
123
150
|
#seq = 0;
|
package/src/wire.ts
CHANGED
|
@@ -13,19 +13,40 @@ export function toWire(e: AgEvent): JsonValue {
|
|
|
13
13
|
return w;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* A JSON round-trip of `v` (throws where `JSON.stringify` throws; see {@link toJsonValueSafe}).
|
|
18
|
+
*
|
|
19
|
+
* @beta
|
|
20
|
+
*/
|
|
16
21
|
export function toJsonValue(v: unknown): JsonValue {
|
|
17
22
|
const w: JsonValue = JSON.parse(JSON.stringify(v));
|
|
18
23
|
return w;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
|
-
/**
|
|
26
|
+
/**
|
|
27
|
+
* The value a cycle is replaced with by {@link toJsonValueSafe} (at the repeated node only).
|
|
28
|
+
*
|
|
29
|
+
* @beta
|
|
30
|
+
*/
|
|
22
31
|
export const JSON_SAFE_CIRCULAR = "[Circular]";
|
|
23
|
-
/**
|
|
32
|
+
/**
|
|
33
|
+
* The value a node nested deeper than {@link JSON_SAFE_MAX_DEPTH} is replaced with.
|
|
34
|
+
*
|
|
35
|
+
* @beta
|
|
36
|
+
*/
|
|
24
37
|
export const JSON_SAFE_MAX_DEPTH_MARK = "[MaxDepth]";
|
|
25
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* The nesting depth past which the helpers stop descending (never reached by real data).
|
|
40
|
+
*
|
|
41
|
+
* @beta
|
|
42
|
+
*/
|
|
26
43
|
export const JSON_SAFE_MAX_DEPTH = 1000;
|
|
27
44
|
|
|
28
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Why {@link toJsonValueSafe} had to degrade a node that `JSON.stringify` would have thrown on.
|
|
47
|
+
*
|
|
48
|
+
* @beta
|
|
49
|
+
*/
|
|
29
50
|
export type JsonSafeIssueKind =
|
|
30
51
|
| "bigint" // converted to its decimal string
|
|
31
52
|
| "circular" // replaced with JSON_SAFE_CIRCULAR
|
|
@@ -34,7 +55,11 @@ export type JsonSafeIssueKind =
|
|
|
34
55
|
| "throwing-keys" // the node's keys could not be enumerated: node omitted
|
|
35
56
|
| "max-depth"; // replaced with JSON_SAFE_MAX_DEPTH_MARK
|
|
36
57
|
|
|
37
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* One degraded node: `path` is `$` for the top, then `.key` / `[index]` segments.
|
|
60
|
+
*
|
|
61
|
+
* @beta
|
|
62
|
+
*/
|
|
38
63
|
export interface JsonSafeIssue {
|
|
39
64
|
path: string;
|
|
40
65
|
kind: JsonSafeIssueKind;
|
|
@@ -48,6 +73,8 @@ export interface JsonSafeIssue {
|
|
|
48
73
|
* shallower than {@link JSON_SAFE_MAX_DEPTH}. Never throws (a throwing getter
|
|
49
74
|
* or proxy trap answers `false`). The walk allocates nothing per node beyond
|
|
50
75
|
* an ancestor stack, so a facet can afford it on every native event.
|
|
76
|
+
*
|
|
77
|
+
* @beta
|
|
51
78
|
*/
|
|
52
79
|
export function isJsonValue(v: unknown): v is JsonValue {
|
|
53
80
|
const ancestors: object[] = [];
|
|
@@ -155,6 +182,8 @@ export function isJsonValue(v: unknown): v is JsonValue {
|
|
|
155
182
|
* inside emitted events. A caller that needs isolation copies the result
|
|
156
183
|
* ({@link isJsonValue} is the cheap check). A facet must neither mutate the
|
|
157
184
|
* returned value nor retain it past the `push()` that produced it.
|
|
185
|
+
*
|
|
186
|
+
* @beta
|
|
158
187
|
*/
|
|
159
188
|
export function toJsonValueSafe(v: unknown): JsonValue {
|
|
160
189
|
return toJsonValueSafeWithIssues(v).value;
|
|
@@ -175,6 +204,8 @@ function isErrorObject(o: object): boolean {
|
|
|
175
204
|
* {@link toJsonValueSafe}, plus the list of nodes it had to degrade (empty when
|
|
176
205
|
* the input was JSON-able). A consumer that must not forward an invented value
|
|
177
206
|
* can branch on `issues.length > 0` instead of using `value`.
|
|
207
|
+
*
|
|
208
|
+
* @beta
|
|
178
209
|
*/
|
|
179
210
|
export function toJsonValueSafeWithIssues(v: unknown): { value: JsonValue; issues: readonly JsonSafeIssue[] } {
|
|
180
211
|
if (isJsonValue(v)) return { value: v, issues: [] };
|