@anureo/sdk 0.0.0-stage → 0.3.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 +185 -2
- package/package.json +66 -4
- package/src/adapter/identity.d.ts +41 -0
- package/src/adapter/identity.js +71 -0
- package/src/client-options.d.ts +71 -0
- package/src/client-options.js +0 -0
- package/src/client.d.ts +106 -0
- package/src/client.js +254 -0
- package/src/diagnostics/errors.d.ts +15 -0
- package/src/diagnostics/errors.js +59 -0
- package/src/diagnostics/events.d.ts +46 -0
- package/src/diagnostics/events.js +47 -0
- package/src/diagnostics.d.ts +20 -0
- package/src/diagnostics.js +56 -0
- package/src/errors.d.ts +48 -0
- package/src/errors.js +63 -0
- package/src/index.d.ts +27 -0
- package/src/index.js +23 -0
- package/src/lifecycle/approval.d.ts +16 -0
- package/src/lifecycle/approval.js +18 -0
- package/src/lifecycle/deferred.d.ts +10 -0
- package/src/lifecycle/deferred.js +12 -0
- package/src/lifecycle/errors.d.ts +18 -0
- package/src/lifecycle/errors.js +45 -0
- package/src/lifecycle/events.d.ts +35 -0
- package/src/lifecycle/events.js +141 -0
- package/src/lifecycle/execution-observation.d.ts +33 -0
- package/src/lifecycle/execution-observation.js +0 -0
- package/src/lifecycle/immutable.d.ts +12 -0
- package/src/lifecycle/immutable.js +28 -0
- package/src/lifecycle/input.d.ts +9 -0
- package/src/lifecycle/input.js +19 -0
- package/src/lifecycle/interactions.d.ts +129 -0
- package/src/lifecycle/interactions.js +282 -0
- package/src/lifecycle/limits.d.ts +7 -0
- package/src/lifecycle/limits.js +13 -0
- package/src/lifecycle/result.d.ts +77 -0
- package/src/lifecycle/result.js +213 -0
- package/src/lifecycle/value.d.ts +4 -0
- package/src/lifecycle/value.js +5 -0
- package/src/ports.d.ts +224 -0
- package/src/ports.js +0 -0
- package/src/privacy/file-change-limits.d.ts +20 -0
- package/src/privacy/file-change-limits.js +124 -0
- package/src/privacy/secrets.d.ts +205 -0
- package/src/privacy/secrets.js +564 -0
- package/src/process.d.ts +92 -0
- package/src/process.js +331 -0
- package/src/queue.d.ts +143 -0
- package/src/queue.js +266 -0
- package/src/request.d.ts +28 -0
- package/src/request.js +81 -0
- package/src/requests/guard.d.ts +15 -0
- package/src/requests/guard.js +93 -0
- package/src/session.d.ts +459 -0
- package/src/session.js +1135 -0
- package/src/structured-output/adapter.d.ts +8 -0
- package/src/structured-output/adapter.js +54 -0
- package/src/structured-output/bridge.d.ts +81 -0
- package/src/structured-output/bridge.js +274 -0
- package/src/structured-output/errors.d.ts +17 -0
- package/src/structured-output/errors.js +31 -0
- package/src/structured-output/limits.d.ts +19 -0
- package/src/structured-output/limits.js +0 -0
- package/src/structured-output/schema.d.ts +20 -0
- package/src/structured-output/schema.js +122 -0
- package/src/structured-output/session.d.ts +329 -0
- package/src/structured-output/session.js +846 -0
- package/src/structured-output/stdio.mjs +83 -0
- package/src/structured-output/tool.d.ts +38 -0
- package/src/structured-output/tool.js +34 -0
- package/src/turn.d.ts +75 -0
- package/src/turn.js +95 -0
- package/src/types.d.ts +62 -0
- package/src/types.js +0 -0
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { Capabilities, AhpEventPayload, AhpMethod, AhpResultMap, GoalState, HistoryPage, InteractionRequested, InteractionResponse, Item, JsonValue, SessionState } from "@anureo/protocol";
|
|
2
|
+
/**
|
|
3
|
+
* Register explicitly marked answers before projecting content for public observation.
|
|
4
|
+
* This root-exported implementation helper is owned by Session, which installs registration in
|
|
5
|
+
* InteractionRegistry's pre-response callback and projects events and request results. Direct
|
|
6
|
+
* consumers own the same registration/publication order. Secrets and pending prefixes stay in
|
|
7
|
+
* memory; the optional synchronous hook owns persistence. No native resources are acquired.
|
|
8
|
+
*/
|
|
9
|
+
export declare class SecretRedactor {
|
|
10
|
+
private readonly onRemember?;
|
|
11
|
+
/**
|
|
12
|
+
* Create an empty in-memory registry with an optional synchronous persistence hook. Session
|
|
13
|
+
* forwards runtime.onMarkedSecret here; rememberScalar invokes it before accepting each new value.
|
|
14
|
+
* Construction only retains the hook. The host owns persistence and any effects its hook performs.
|
|
15
|
+
*/
|
|
16
|
+
constructor(onRemember?: ((secret: string) => void) | undefined);
|
|
17
|
+
/**
|
|
18
|
+
* Register answers marked secret/writeOnly by the request before exposing or delivering them.
|
|
19
|
+
* Marked containers contribute their scalar descendants. Numbers and booleans register by string
|
|
20
|
+
* value, while empty strings, null and duplicates are ignored. At most 128 distinct values and
|
|
21
|
+
* 64 KiB of UTF-8 text are retained. Exceeding either cap throws a HarnessSdkError with code
|
|
22
|
+
* BACKPRESSURE_EXCEEDED. Hook exceptions also propagate, leaving earlier registrations intact.
|
|
23
|
+
* Schema traversal stops beyond depth 32, with the request schema at depth zero.
|
|
24
|
+
* Session installs this as InteractionRegistry's pre-response check. InteractionRegistry.respond
|
|
25
|
+
* invokes it after validation and rejects on failure before looking up a replay or starting native
|
|
26
|
+
* delivery. Direct consumers own validation and delivery.
|
|
27
|
+
*/
|
|
28
|
+
rememberResponse(request: InteractionRequested, response: InteractionResponse): void;
|
|
29
|
+
/**
|
|
30
|
+
* Replace complete secret matches with [redacted], preferring the longest match at each position.
|
|
31
|
+
* Unmatched trailing prefixes are emitted without retaining stream state. Session.projectOutput
|
|
32
|
+
* and Session.projectSubmissionStatus use this before exposure. OutputSession.publishOutput
|
|
33
|
+
* revalidates JSON returned through projectOutput and converts schema failures into failed turns.
|
|
34
|
+
*/
|
|
35
|
+
text(value: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Project an ordered text chunk, withholding a possible trailing secret prefix until the next chunk.
|
|
38
|
+
* Complete matches win even when a longer secret is incomplete. event scopes streams by turn/item
|
|
39
|
+
* and discards pending prefixes on item/completed, whose snapshot carries authoritative full text.
|
|
40
|
+
* Direct consumers must use distinct ordered keys; this method has no flush/reset operation, so
|
|
41
|
+
* they must discard the redactor when they no longer need its retained prefixes and secrets.
|
|
42
|
+
*/
|
|
43
|
+
delta(stream: string, value: string): string;
|
|
44
|
+
/**
|
|
45
|
+
* Return recursively projected JSON without mutating the input. Marked numbers and booleans become
|
|
46
|
+
* the string [redacted]. If projected keys collide, the last entry in traversal order wins.
|
|
47
|
+
* Session.projectSubmissionStatus selects receipt and error content. Direct callers should also
|
|
48
|
+
* pass only content fields to preserve protocol identity.
|
|
49
|
+
*/
|
|
50
|
+
json(value: JsonValue): JsonValue;
|
|
51
|
+
/**
|
|
52
|
+
* Project configuration annotations and values without modifying validation constraints or
|
|
53
|
+
* property names. Return the original value when no configuration is advertised. state uses this
|
|
54
|
+
* for session snapshots; the caller owns storing or publishing the result.
|
|
55
|
+
*/
|
|
56
|
+
capabilities(value: Capabilities): Capabilities;
|
|
57
|
+
/**
|
|
58
|
+
* Return a new outer value with projected goal JSON and unchanged native goal metadata.
|
|
59
|
+
* state and result call this before exposing goal content; no session state is written here.
|
|
60
|
+
*/
|
|
61
|
+
goal(value: GoalState): GoalState;
|
|
62
|
+
/**
|
|
63
|
+
* Project content-bearing state fields while preserving bindings, protocol enums and revisions; no
|
|
64
|
+
* session bookkeeping is changed. Session.snapshot calls this on reads; event and result use it
|
|
65
|
+
* for state/config observations. Session freezes reads and validates/stores request results;
|
|
66
|
+
* direct consumers retain responsibility for validation and publication.
|
|
67
|
+
*/
|
|
68
|
+
state(value: SessionState): SessionState;
|
|
69
|
+
/**
|
|
70
|
+
* Project a validated configuration or goal result according to its method. Other results pass
|
|
71
|
+
* through by identity. Session.projectRequestResult routes history to history() and calls this
|
|
72
|
+
* for other projectable results. Session.executeRequest stores projected configuration or goal
|
|
73
|
+
* state and validates and freezes the returned result. Direct callers own validation and storage.
|
|
74
|
+
*/
|
|
75
|
+
result<M extends AhpMethod>(method: M, value: AhpResultMap[M]): AhpResultMap[M];
|
|
76
|
+
/**
|
|
77
|
+
* Project validated item content without changing protocol identity or registering new secrets.
|
|
78
|
+
* Tool-call file changes additionally use the shared material/mirror budget. event uses this for
|
|
79
|
+
* snapshots and validated patches; history applies it to each native entry. Direct consumers
|
|
80
|
+
* must validate item shape first, as Session and deltaValue do for their respective input paths.
|
|
81
|
+
*/
|
|
82
|
+
item(item: Item): Item;
|
|
83
|
+
/**
|
|
84
|
+
* Project public request content while preserving identifiers, answer keys and protocol alternatives.
|
|
85
|
+
* event calls this after Session.requestInteraction applies protocol publicInteraction; direct
|
|
86
|
+
* consumers must likewise apply protocol privacy rules first. If a privatePayload is supplied
|
|
87
|
+
* directly, this method projects its JSON content and retains the field. InteractionRegistry
|
|
88
|
+
* retains the native request for response validation and marked-field lookup.
|
|
89
|
+
*/
|
|
90
|
+
interaction(request: InteractionRequested): InteractionRequested;
|
|
91
|
+
/**
|
|
92
|
+
* Project validated events in publication order, clearing an item's buffered prefix on completion.
|
|
93
|
+
* Supply turnId to isolate reused item IDs across turns. Omission uses an item-only stream key.
|
|
94
|
+
* Session.publish invokes this after lifecycle admission and before retaining/publishing results.
|
|
95
|
+
* An invalid Item-shaped patch throws ProtocolValidationError and rejects Session.emit, which
|
|
96
|
+
* starts observation teardown. Direct consumers own event validation, ordering and publication.
|
|
97
|
+
* Completed snapshots supply authoritative item content.
|
|
98
|
+
*/
|
|
99
|
+
event(event: AhpEventPayload, turnId?: string): AhpEventPayload;
|
|
100
|
+
/**
|
|
101
|
+
* Project a prevalidated history page using live items' privacy/retention rules, preserving
|
|
102
|
+
* pagination and execution identities. The input must already be validated; no history is fetched
|
|
103
|
+
* here. Session.projectRequestResult calls this before executeRequest awaits the optional host
|
|
104
|
+
* redactHistory hook, validates and freezes the result; host-hook rejection fails that request.
|
|
105
|
+
*/
|
|
106
|
+
history(page: HistoryPage): HistoryPage;
|
|
107
|
+
private readonly values;
|
|
108
|
+
private readonly streams;
|
|
109
|
+
private secretBytes;
|
|
110
|
+
/**
|
|
111
|
+
* rememberResponse and fromSchema call this before a response can be sent. Recursively retain marked
|
|
112
|
+
* scalar values within session budgets; invoke the host hook before accepting each new value.
|
|
113
|
+
* Capacity or hook failures throw to InteractionRegistry.respond before native delivery; values
|
|
114
|
+
* already accepted during the traversal remain registered, with no rollback of host effects.
|
|
115
|
+
*/
|
|
116
|
+
private remember;
|
|
117
|
+
/**
|
|
118
|
+
* Accept a new nonempty scalar only after capacity checks and the synchronous persistence hook
|
|
119
|
+
* succeed. remember preserves traversal order, so a later failure never rolls back earlier values;
|
|
120
|
+
* a failed hook leaves this value unregistered and retryable.
|
|
121
|
+
*/
|
|
122
|
+
private rememberScalar;
|
|
123
|
+
/**
|
|
124
|
+
* Resolve a reference beginning with #/ against the original request schema. Decode JSON Pointer
|
|
125
|
+
* escapes and follow object keys. A missing key or non-object intermediate yields undefined.
|
|
126
|
+
* fromSchema checks the returned node's shape before visiting it.
|
|
127
|
+
*/
|
|
128
|
+
private resolveLocalReference;
|
|
129
|
+
/**
|
|
130
|
+
* rememberResponse calls this for elicitation/dynamicTool schemas; recursive branches pass marked
|
|
131
|
+
* values to remember. Collect marked values through bounded local schema traversal, including
|
|
132
|
+
* referenced and sibling rules; does not validate response values or fetch references. Visit
|
|
133
|
+
* references before siblings because registration order determines host-hook and budget failures.
|
|
134
|
+
* Stop beyond depth 32; registration failures propagate without undoing earlier registrations.
|
|
135
|
+
*/
|
|
136
|
+
private fromSchema;
|
|
137
|
+
/**
|
|
138
|
+
* fromSchema calls this between reference and array/composition visits. Register declared
|
|
139
|
+
* properties before additional ones, sharing the next-depth context and propagating registration
|
|
140
|
+
* failures. Even a declared non-schema property excludes that key from additionalProperties.
|
|
141
|
+
*/
|
|
142
|
+
private rememberObjectProperties;
|
|
143
|
+
/**
|
|
144
|
+
* fromSchema visits array elements in order under the same items schema and next-depth context.
|
|
145
|
+
* Tuple arrays and absent items rules contribute no registrations. Registration failures propagate.
|
|
146
|
+
*/
|
|
147
|
+
private rememberArrayItems;
|
|
148
|
+
/**
|
|
149
|
+
* fromSchema visits composition branches after reference, object and array rules. Visit every
|
|
150
|
+
* schema branch in keyword and array order without selecting a validation match. Registration
|
|
151
|
+
* failures stop the remaining visits.
|
|
152
|
+
*/
|
|
153
|
+
private rememberComposedSchemas;
|
|
154
|
+
/**
|
|
155
|
+
* text consumes the complete scan; delta stores a stream scan's pending prefix for the next chunk.
|
|
156
|
+
* Return longest complete matches as redactions. Stream mode withholds an unmatched trailing
|
|
157
|
+
* prefix so it cannot leak before the next chunk arrives; complete mode emits that prefix.
|
|
158
|
+
* This scan reads registered secrets but changes no stream or registration state.
|
|
159
|
+
*/
|
|
160
|
+
private scan;
|
|
161
|
+
/**
|
|
162
|
+
* capabilities calls this for config-option schemas before exposing state. Project schema
|
|
163
|
+
* annotations/defaults recursively while preserving constraints and property names; privacy must not
|
|
164
|
+
* silently change validation rules. Object schemas are copied and boolean schemas pass through.
|
|
165
|
+
*/
|
|
166
|
+
private schema;
|
|
167
|
+
/**
|
|
168
|
+
* item maps user-message content through this projection. Project content-bearing input block fields
|
|
169
|
+
* while preserving modality and protocol structure; return a detached outer block without loading
|
|
170
|
+
* files or fetching URLs. item returns the block in the public user message.
|
|
171
|
+
*/
|
|
172
|
+
private input;
|
|
173
|
+
/**
|
|
174
|
+
* toolCall merges these fields into projected tool-call items before bounding file-change material.
|
|
175
|
+
* Project tool image paths/prompts only; image identity and other native metadata remain
|
|
176
|
+
* authoritative. Return only the image field (or no fields) without reading or modifying an image.
|
|
177
|
+
*/
|
|
178
|
+
private toolImage;
|
|
179
|
+
/**
|
|
180
|
+
* toolCall maps fileChanges through this before boundFileChangeItem enforces retention.
|
|
181
|
+
* Project change paths and material text while preserving source metadata; the caller subsequently
|
|
182
|
+
* applies the shared retention budget. Return copied text material without applying patches or
|
|
183
|
+
* changing unavailable-material metadata.
|
|
184
|
+
*/
|
|
185
|
+
private fileChange;
|
|
186
|
+
/**
|
|
187
|
+
* item delegates tool content projection here after extensions have been projected. Redact every
|
|
188
|
+
* content field before enforcing the shared file-change budget so accounting measures projected
|
|
189
|
+
* text. Return the bounded snapshot without changing native identity or source material.
|
|
190
|
+
*/
|
|
191
|
+
private toolCall;
|
|
192
|
+
/**
|
|
193
|
+
* itemDelta calls this for JSON-valued payloads before Session retains or publishes the event.
|
|
194
|
+
* A patch object with type or fileChanges must pass Item validation before item projection.
|
|
195
|
+
* Item-shaped validation failures throw ProtocolValidationError. Other values receive ordinary
|
|
196
|
+
* JSON projection.
|
|
197
|
+
*/
|
|
198
|
+
private deltaValue;
|
|
199
|
+
/**
|
|
200
|
+
* event projects delta text before validating/projecting an optional JSON value. A malformed patch
|
|
201
|
+
* throws after any prefix update, as publication fails through Session.emit; no buffered state is
|
|
202
|
+
* rolled back. Non-Item JSON still receives ordinary content projection.
|
|
203
|
+
*/
|
|
204
|
+
private itemDelta;
|
|
205
|
+
}
|