@everworker/oneringai 0.4.7 → 0.4.8
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 +3 -3
- package/dist/capabilities/agents/index.cjs +8 -0
- package/dist/capabilities/agents/index.cjs.map +1 -1
- package/dist/capabilities/agents/index.d.cts +1 -1
- package/dist/capabilities/agents/index.d.ts +1 -1
- package/dist/capabilities/agents/index.js +8 -0
- package/dist/capabilities/agents/index.js.map +1 -1
- package/dist/capabilities/images/index.cjs +11 -1
- package/dist/capabilities/images/index.cjs.map +1 -1
- package/dist/capabilities/images/index.js +11 -1
- package/dist/capabilities/images/index.js.map +1 -1
- package/dist/{index-Blci0FEd.d.ts → index-13HQuxEB.d.ts} +192 -8
- package/dist/{index-D8RCwpK9.d.cts → index-Cbd5vY_8.d.cts} +192 -8
- package/dist/index.cjs +4100 -2650
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1894 -1609
- package/dist/index.d.ts +1894 -1609
- package/dist/index.js +4060 -2614
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -98,6 +98,148 @@ interface ReasoningItem {
|
|
|
98
98
|
type InputItem = Message | CompactionItem;
|
|
99
99
|
type OutputItem = Message | CompactionItem | ReasoningItem;
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* IHistoryJournal - Interface for append-only conversation history logging
|
|
103
|
+
*
|
|
104
|
+
* Provides a durable, append-only log of all conversation messages,
|
|
105
|
+
* independent of context compaction. While the agent's working window
|
|
106
|
+
* (_conversation) may be compacted to fit the LLM context, the journal
|
|
107
|
+
* preserves the full conversation history on disk/database.
|
|
108
|
+
*
|
|
109
|
+
* The journal is a companion capability of IContextStorage — storage
|
|
110
|
+
* implementations that support history logging expose it via the
|
|
111
|
+
* `journal` property. Consumers never configure the journal separately;
|
|
112
|
+
* it comes for free with the storage backend.
|
|
113
|
+
*
|
|
114
|
+
* Access patterns:
|
|
115
|
+
* - **Write**: append-only, per-message, fire-and-forget (non-blocking)
|
|
116
|
+
* - **Read**: on-demand, explicit (never loaded automatically)
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* // File storage → FileHistoryJournal (JSONL files)
|
|
121
|
+
* const storage = new FileContextStorage({ agentId: 'my-agent' });
|
|
122
|
+
* storage.journal.append('session-1', [entry]);
|
|
123
|
+
*
|
|
124
|
+
* // Mongo storage → MongoHistoryJournal (collection)
|
|
125
|
+
* const storage = new MongoContextStorage({ agentId: 'my-agent', db });
|
|
126
|
+
* storage.journal.append('session-1', [entry]);
|
|
127
|
+
*
|
|
128
|
+
* // Reading history (on-demand, explicit)
|
|
129
|
+
* const entries = await storage.journal.read('session-1', { limit: 50 });
|
|
130
|
+
* const total = await storage.journal.count('session-1');
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Type of history entry, derived from the message's role/purpose.
|
|
136
|
+
*/
|
|
137
|
+
type HistoryEntryType = 'user' | 'assistant' | 'tool_result' | 'system';
|
|
138
|
+
/**
|
|
139
|
+
* A single entry in the history journal.
|
|
140
|
+
*
|
|
141
|
+
* Wraps an InputItem with metadata for ordering and filtering.
|
|
142
|
+
* The `item` field is the exact InputItem as it was added to the conversation,
|
|
143
|
+
* preserving full fidelity (including __images, tool_use_id, etc.).
|
|
144
|
+
*/
|
|
145
|
+
interface HistoryEntry {
|
|
146
|
+
/** When this entry was recorded (epoch ms) */
|
|
147
|
+
timestamp: number;
|
|
148
|
+
/** Entry type for filtering */
|
|
149
|
+
type: HistoryEntryType;
|
|
150
|
+
/** The actual conversation item (Message or CompactionItem) */
|
|
151
|
+
item: InputItem;
|
|
152
|
+
/**
|
|
153
|
+
* Monotonically increasing turn counter.
|
|
154
|
+
* A "turn" is one user message + one assistant response (+ any tool calls in between).
|
|
155
|
+
* Useful for grouping related messages and pagination.
|
|
156
|
+
*/
|
|
157
|
+
turnIndex: number;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Options for reading history entries.
|
|
161
|
+
*/
|
|
162
|
+
interface HistoryReadOptions {
|
|
163
|
+
/** Skip this many entries from the start */
|
|
164
|
+
offset?: number;
|
|
165
|
+
/** Maximum number of entries to return */
|
|
166
|
+
limit?: number;
|
|
167
|
+
/** Filter by entry type(s) */
|
|
168
|
+
types?: HistoryEntryType[];
|
|
169
|
+
/** Only entries after this timestamp (epoch ms, inclusive) */
|
|
170
|
+
after?: number;
|
|
171
|
+
/** Only entries before this timestamp (epoch ms, inclusive) */
|
|
172
|
+
before?: number;
|
|
173
|
+
/** Only entries from this turn index onwards (inclusive) */
|
|
174
|
+
fromTurn?: number;
|
|
175
|
+
/** Only entries up to this turn index (inclusive) */
|
|
176
|
+
toTurn?: number;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Append-only history journal for conversation persistence.
|
|
180
|
+
*
|
|
181
|
+
* Implementations:
|
|
182
|
+
* - FileHistoryJournal: JSONL files at ~/.oneringai/agents/<agentId>/sessions/<sessionId>.history.jsonl
|
|
183
|
+
* - (Future) MongoHistoryJournal: MongoDB collection
|
|
184
|
+
* - (Future) RedisHistoryJournal: Redis Streams
|
|
185
|
+
*/
|
|
186
|
+
interface IHistoryJournal {
|
|
187
|
+
/**
|
|
188
|
+
* Append entries to the journal.
|
|
189
|
+
*
|
|
190
|
+
* This is the primary write operation, called on every addUserMessage(),
|
|
191
|
+
* addAssistantResponse(), and addToolResults(). Should be fast (append-only).
|
|
192
|
+
*
|
|
193
|
+
* @param sessionId - Session to append to
|
|
194
|
+
* @param entries - One or more history entries to append
|
|
195
|
+
*/
|
|
196
|
+
append(sessionId: string, entries: HistoryEntry[]): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* Read history entries with optional filtering and pagination.
|
|
199
|
+
*
|
|
200
|
+
* Entries are returned in chronological order (oldest first).
|
|
201
|
+
*
|
|
202
|
+
* @param sessionId - Session to read from
|
|
203
|
+
* @param options - Filtering and pagination options
|
|
204
|
+
* @returns Array of history entries
|
|
205
|
+
*/
|
|
206
|
+
read(sessionId: string, options?: HistoryReadOptions): Promise<HistoryEntry[]>;
|
|
207
|
+
/**
|
|
208
|
+
* Get the total number of entries in the journal.
|
|
209
|
+
*
|
|
210
|
+
* @param sessionId - Session to count
|
|
211
|
+
* @returns Number of entries (0 if session has no journal)
|
|
212
|
+
*/
|
|
213
|
+
count(sessionId: string): Promise<number>;
|
|
214
|
+
/**
|
|
215
|
+
* Delete all history for a session.
|
|
216
|
+
*
|
|
217
|
+
* Called when a session is deleted via IContextStorage.delete().
|
|
218
|
+
*
|
|
219
|
+
* @param sessionId - Session to clear
|
|
220
|
+
*/
|
|
221
|
+
clear(sessionId: string): Promise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* Stream history entries for large histories.
|
|
224
|
+
*
|
|
225
|
+
* Optional — implementations may omit this if streaming isn't practical
|
|
226
|
+
* (e.g., in-memory storage). Callers should fall back to read() with
|
|
227
|
+
* pagination if stream() is not available.
|
|
228
|
+
*
|
|
229
|
+
* @param sessionId - Session to stream
|
|
230
|
+
* @param options - Same filtering options as read()
|
|
231
|
+
* @returns AsyncIterable of history entries in chronological order
|
|
232
|
+
*/
|
|
233
|
+
stream?(sessionId: string, options?: HistoryReadOptions): AsyncIterable<HistoryEntry>;
|
|
234
|
+
/**
|
|
235
|
+
* Get a human-readable location string for debugging/display.
|
|
236
|
+
*
|
|
237
|
+
* @param sessionId - Session ID
|
|
238
|
+
* @returns Location string (file path, MongoDB URI, etc.)
|
|
239
|
+
*/
|
|
240
|
+
getLocation?(sessionId: string): string;
|
|
241
|
+
}
|
|
242
|
+
|
|
101
243
|
/**
|
|
102
244
|
* Memory entities for WorkingMemory
|
|
103
245
|
*
|
|
@@ -723,6 +865,21 @@ interface IContextStorage {
|
|
|
723
865
|
* Falls back to getPath() if not implemented.
|
|
724
866
|
*/
|
|
725
867
|
getLocation?(): string;
|
|
868
|
+
/**
|
|
869
|
+
* History journal companion for full conversation logging.
|
|
870
|
+
*
|
|
871
|
+
* When present, AgentContextNextGen automatically appends every message
|
|
872
|
+
* to the journal (append-only, fire-and-forget). The journal is never
|
|
873
|
+
* affected by compaction, preserving full conversation history.
|
|
874
|
+
*
|
|
875
|
+
* Storage implementations create the appropriate journal for their backend:
|
|
876
|
+
* - FileContextStorage → FileHistoryJournal (JSONL files)
|
|
877
|
+
* - MongoContextStorage → MongoHistoryJournal (collection)
|
|
878
|
+
*
|
|
879
|
+
* Consumers never configure the journal separately — it comes for free
|
|
880
|
+
* with the storage backend.
|
|
881
|
+
*/
|
|
882
|
+
readonly journal?: IHistoryJournal;
|
|
726
883
|
}
|
|
727
884
|
/**
|
|
728
885
|
* Options for listing sessions
|
|
@@ -1055,12 +1212,6 @@ declare class ToolCatalogRegistry {
|
|
|
1055
1212
|
static reset(): void;
|
|
1056
1213
|
}
|
|
1057
1214
|
|
|
1058
|
-
/**
|
|
1059
|
-
* AgentContextNextGen - Type Definitions
|
|
1060
|
-
*
|
|
1061
|
-
* Clean, minimal type definitions for the next-generation context manager.
|
|
1062
|
-
*/
|
|
1063
|
-
|
|
1064
1215
|
/**
|
|
1065
1216
|
* A single auth identity: connector + optional account alias.
|
|
1066
1217
|
*
|
|
@@ -1569,6 +1720,13 @@ interface AgentContextNextGenConfig {
|
|
|
1569
1720
|
* Default: 0 (disabled - relies on each tool's own timeout)
|
|
1570
1721
|
*/
|
|
1571
1722
|
toolExecutionTimeout?: number;
|
|
1723
|
+
/**
|
|
1724
|
+
* Filter which message types are written to the history journal.
|
|
1725
|
+
* When set, only entries matching these types are appended.
|
|
1726
|
+
* Default: undefined (all types journaled).
|
|
1727
|
+
* Example: ['user', 'assistant'] to exclude tool_result entries.
|
|
1728
|
+
*/
|
|
1729
|
+
journalFilter?: HistoryEntryType[];
|
|
1572
1730
|
}
|
|
1573
1731
|
/**
|
|
1574
1732
|
* Default configuration values
|
|
@@ -1809,6 +1967,7 @@ declare enum StreamEventType {
|
|
|
1809
1967
|
REASONING_DELTA = "response.reasoning.delta",
|
|
1810
1968
|
REASONING_DONE = "response.reasoning.done",
|
|
1811
1969
|
RESPONSE_COMPLETE = "response.complete",
|
|
1970
|
+
RETRY = "response.retry",
|
|
1812
1971
|
ERROR = "response.error",
|
|
1813
1972
|
AUDIO_CHUNK_READY = "response.audio_chunk.ready",
|
|
1814
1973
|
AUDIO_CHUNK_ERROR = "response.audio_chunk.error",
|
|
@@ -1923,6 +2082,18 @@ interface ResponseCompleteEvent extends BaseStreamEvent {
|
|
|
1923
2082
|
usage: TokenUsage;
|
|
1924
2083
|
iterations: number;
|
|
1925
2084
|
duration_ms?: number;
|
|
2085
|
+
/** Raw provider stop reason for diagnostics (e.g., 'end_turn', 'max_tokens', 'SAFETY') */
|
|
2086
|
+
stop_reason?: string;
|
|
2087
|
+
}
|
|
2088
|
+
/**
|
|
2089
|
+
* Retry event - emitted when agent retries an empty/incomplete LLM response
|
|
2090
|
+
*/
|
|
2091
|
+
interface RetryEvent extends BaseStreamEvent {
|
|
2092
|
+
type: StreamEventType.RETRY;
|
|
2093
|
+
attempt: number;
|
|
2094
|
+
max_attempts: number;
|
|
2095
|
+
reason: string;
|
|
2096
|
+
delay_ms: number;
|
|
1926
2097
|
}
|
|
1927
2098
|
/**
|
|
1928
2099
|
* Reasoning/thinking delta - incremental reasoning output
|
|
@@ -1995,7 +2166,7 @@ interface AudioStreamCompleteEvent extends BaseStreamEvent {
|
|
|
1995
2166
|
* Union type of all stream events
|
|
1996
2167
|
* Discriminated by 'type' field for type narrowing
|
|
1997
2168
|
*/
|
|
1998
|
-
type StreamEvent = ResponseCreatedEvent | ResponseInProgressEvent | OutputTextDeltaEvent | OutputTextDoneEvent | ReasoningDeltaEvent | ReasoningDoneEvent | ToolCallStartEvent | ToolCallArgumentsDeltaEvent | ToolCallArgumentsDoneEvent | ToolExecutionStartEvent | ToolExecutionDoneEvent | IterationCompleteEvent$1 | ResponseCompleteEvent | ErrorEvent | AudioChunkReadyEvent | AudioChunkErrorEvent | AudioStreamCompleteEvent;
|
|
2169
|
+
type StreamEvent = ResponseCreatedEvent | ResponseInProgressEvent | OutputTextDeltaEvent | OutputTextDoneEvent | ReasoningDeltaEvent | ReasoningDoneEvent | ToolCallStartEvent | ToolCallArgumentsDeltaEvent | ToolCallArgumentsDoneEvent | ToolExecutionStartEvent | ToolExecutionDoneEvent | IterationCompleteEvent$1 | ResponseCompleteEvent | RetryEvent | ErrorEvent | AudioChunkReadyEvent | AudioChunkErrorEvent | AudioStreamCompleteEvent;
|
|
1999
2170
|
/**
|
|
2000
2171
|
* Type guard to check if event is a specific type
|
|
2001
2172
|
*/
|
|
@@ -2272,6 +2443,14 @@ interface ExecutionEmptyOutputEvent {
|
|
|
2272
2443
|
duration: number;
|
|
2273
2444
|
usage?: TokenUsage;
|
|
2274
2445
|
}
|
|
2446
|
+
interface ExecutionRetryEvent {
|
|
2447
|
+
executionId: string;
|
|
2448
|
+
attempt: number;
|
|
2449
|
+
maxAttempts: number;
|
|
2450
|
+
reason: string;
|
|
2451
|
+
delayMs: number;
|
|
2452
|
+
timestamp: Date;
|
|
2453
|
+
}
|
|
2275
2454
|
interface ExecutionMaxIterationsEvent {
|
|
2276
2455
|
executionId: string;
|
|
2277
2456
|
iteration: number;
|
|
@@ -2390,6 +2569,7 @@ interface AgenticLoopEvents {
|
|
|
2390
2569
|
'tool:timeout': ToolTimeoutEvent;
|
|
2391
2570
|
'hook:error': HookErrorEvent;
|
|
2392
2571
|
'execution:empty_output': ExecutionEmptyOutputEvent;
|
|
2572
|
+
'execution:retry': ExecutionRetryEvent;
|
|
2393
2573
|
'circuit:opened': CircuitOpenedEvent;
|
|
2394
2574
|
'circuit:half-open': CircuitHalfOpenEvent;
|
|
2395
2575
|
'circuit:closed': CircuitClosedEvent;
|
|
@@ -2607,6 +2787,10 @@ declare class HookManager {
|
|
|
2607
2787
|
* Clear all hooks and reset error tracking
|
|
2608
2788
|
*/
|
|
2609
2789
|
clear(): void;
|
|
2790
|
+
/**
|
|
2791
|
+
* Destroy the hook manager and release all references
|
|
2792
|
+
*/
|
|
2793
|
+
destroy(): void;
|
|
2610
2794
|
/**
|
|
2611
2795
|
* Re-enable a disabled hook
|
|
2612
2796
|
*/
|
|
@@ -2617,4 +2801,4 @@ declare class HookManager {
|
|
|
2617
2801
|
getDisabledHooks(): string[];
|
|
2618
2802
|
}
|
|
2619
2803
|
|
|
2620
|
-
export { type
|
|
2804
|
+
export { type MemoryIndex as $, type AgentContextNextGenConfig as A, type BeforeCompactionCallback as B, type ContextFeatures as C, type AuditEntry as D, ExecutionContext as E, type FunctionToolDefinition as F, type HookName as G, type HookConfig as H, type IContextStorage as I, type ITokenEstimator as J, type ToolCategoryScope as K, type LLMResponse as L, type MemoryEntry as M, type CompactionContext as N, type OutputItem as O, type PriorityCalculator as P, type CompactionResult as Q, type AudioChunkReadyEvent as R, type SerializedContextState as S, type Tool as T, type ContextStorageListOptions as U, type ContextSessionSummary as V, type WorkingMemoryConfig as W, type HistoryEntry as X, type HistoryReadOptions as Y, type StaleEntryInfo as Z, type PriorityContext as _, type MemoryScope as a, type ToolModification as a$, type TaskStatusForMemory as a0, type WorkingMemoryAccess as a1, type TokenUsage as a2, StreamEventType as a3, type TextGenerateOptions as a4, type ModelCapabilities as a5, MessageRole as a6, type AfterToolContext as a7, type AgentEventName as a8, type AgenticLoopEventName as a9, type MemoryEntryInput as aA, type MemoryIndexEntry as aB, type Message as aC, type ModifyingHook as aD, type OutputTextContent as aE, type OutputTextDeltaEvent as aF, type OutputTextDoneEvent as aG, type OversizedInputResult as aH, type PluginConfigs as aI, type ReasoningDeltaEvent as aJ, type ReasoningDoneEvent as aK, type ReasoningItem as aL, type ResponseCompleteEvent as aM, type ResponseCreatedEvent as aN, type ResponseInProgressEvent as aO, type SimpleScope as aP, type TaskAwareScope as aQ, type ThinkingContent as aR, type ToolCallArgumentsDeltaEvent as aS, type ToolCallArgumentsDoneEvent as aT, type ToolCallStartEvent as aU, ToolCallState as aV, ToolCatalogRegistry as aW, type ToolCategoryDefinition as aX, type ToolExecutionContext as aY, type ToolExecutionDoneEvent as aZ, type ToolExecutionStartEvent as a_, type AgenticLoopEvents as aa, type ApprovalResult as ab, type ApproveToolContext as ac, type AudioChunkErrorEvent as ad, type AudioStreamCompleteEvent as ae, type BeforeToolContext as af, type BuiltInTool as ag, CONTEXT_SESSION_FORMAT_VERSION as ah, type ToolRegistryEntry as ai, type CatalogToolEntry as aj, type CompactionItem as ak, type ConnectorCategoryInfo as al, ContentType as am, DEFAULT_CONFIG as an, DEFAULT_FEATURES as ao, DEFAULT_MEMORY_CONFIG as ap, type ErrorEvent as aq, type ExecutionConfig as ar, type HistoryEntryType as as, type Hook as at, HookManager as au, type InputImageContent as av, type InputTextContent as aw, type IterationCompleteEvent$1 as ax, type JSONSchema as ay, MEMORY_PRIORITY_VALUES as az, type ToolFunction as b, type ToolResultContent as b0, type ToolUseContent as b1, calculateEntrySize as b2, defaultDescribeCall as b3, forPlan as b4, forTasks as b5, getToolCallDescription as b6, isAudioChunkError as b7, isAudioChunkReady as b8, isAudioStreamComplete as b9, isErrorEvent as ba, isOutputTextDelta as bb, isReasoningDelta as bc, isReasoningDone as bd, isResponseComplete as be, isSimpleScope as bf, isStreamEvent as bg, isTaskAwareScope as bh, isTerminalMemoryStatus as bi, isToolCallArgumentsDelta as bj, isToolCallArgumentsDone as bk, isToolCallStart as bl, scopeEquals as bm, scopeMatches as bn, type ExecutionCompleteEvent as bo, type ExecutionStartEvent as bp, type LLMRequestEvent as bq, type LLMResponseEvent as br, type ToolCompleteEvent as bs, type ToolStartEvent as bt, type ToolContext as c, type ToolPermissionConfig as d, type ContextBudget as e, type ToolCall as f, type IContextPluginNextGen as g, type MemoryPriority as h, type MemoryTier as i, type ContextEvents as j, type AuthIdentity as k, type ICompactionStrategy as l, type InputItem as m, type Content as n, type PreparedContext as o, type ToolResult as p, type IHistoryJournal as q, type ConsolidationResult as r, type StoredContextSession as s, type ITextProvider as t, type ContextSessionMetadata as u, type StreamEvent as v, type HistoryMode as w, type AgentEvents as x, type AgentResponse as y, type ExecutionMetrics as z };
|
|
@@ -98,6 +98,148 @@ interface ReasoningItem {
|
|
|
98
98
|
type InputItem = Message | CompactionItem;
|
|
99
99
|
type OutputItem = Message | CompactionItem | ReasoningItem;
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* IHistoryJournal - Interface for append-only conversation history logging
|
|
103
|
+
*
|
|
104
|
+
* Provides a durable, append-only log of all conversation messages,
|
|
105
|
+
* independent of context compaction. While the agent's working window
|
|
106
|
+
* (_conversation) may be compacted to fit the LLM context, the journal
|
|
107
|
+
* preserves the full conversation history on disk/database.
|
|
108
|
+
*
|
|
109
|
+
* The journal is a companion capability of IContextStorage — storage
|
|
110
|
+
* implementations that support history logging expose it via the
|
|
111
|
+
* `journal` property. Consumers never configure the journal separately;
|
|
112
|
+
* it comes for free with the storage backend.
|
|
113
|
+
*
|
|
114
|
+
* Access patterns:
|
|
115
|
+
* - **Write**: append-only, per-message, fire-and-forget (non-blocking)
|
|
116
|
+
* - **Read**: on-demand, explicit (never loaded automatically)
|
|
117
|
+
*
|
|
118
|
+
* @example
|
|
119
|
+
* ```typescript
|
|
120
|
+
* // File storage → FileHistoryJournal (JSONL files)
|
|
121
|
+
* const storage = new FileContextStorage({ agentId: 'my-agent' });
|
|
122
|
+
* storage.journal.append('session-1', [entry]);
|
|
123
|
+
*
|
|
124
|
+
* // Mongo storage → MongoHistoryJournal (collection)
|
|
125
|
+
* const storage = new MongoContextStorage({ agentId: 'my-agent', db });
|
|
126
|
+
* storage.journal.append('session-1', [entry]);
|
|
127
|
+
*
|
|
128
|
+
* // Reading history (on-demand, explicit)
|
|
129
|
+
* const entries = await storage.journal.read('session-1', { limit: 50 });
|
|
130
|
+
* const total = await storage.journal.count('session-1');
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Type of history entry, derived from the message's role/purpose.
|
|
136
|
+
*/
|
|
137
|
+
type HistoryEntryType = 'user' | 'assistant' | 'tool_result' | 'system';
|
|
138
|
+
/**
|
|
139
|
+
* A single entry in the history journal.
|
|
140
|
+
*
|
|
141
|
+
* Wraps an InputItem with metadata for ordering and filtering.
|
|
142
|
+
* The `item` field is the exact InputItem as it was added to the conversation,
|
|
143
|
+
* preserving full fidelity (including __images, tool_use_id, etc.).
|
|
144
|
+
*/
|
|
145
|
+
interface HistoryEntry {
|
|
146
|
+
/** When this entry was recorded (epoch ms) */
|
|
147
|
+
timestamp: number;
|
|
148
|
+
/** Entry type for filtering */
|
|
149
|
+
type: HistoryEntryType;
|
|
150
|
+
/** The actual conversation item (Message or CompactionItem) */
|
|
151
|
+
item: InputItem;
|
|
152
|
+
/**
|
|
153
|
+
* Monotonically increasing turn counter.
|
|
154
|
+
* A "turn" is one user message + one assistant response (+ any tool calls in between).
|
|
155
|
+
* Useful for grouping related messages and pagination.
|
|
156
|
+
*/
|
|
157
|
+
turnIndex: number;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Options for reading history entries.
|
|
161
|
+
*/
|
|
162
|
+
interface HistoryReadOptions {
|
|
163
|
+
/** Skip this many entries from the start */
|
|
164
|
+
offset?: number;
|
|
165
|
+
/** Maximum number of entries to return */
|
|
166
|
+
limit?: number;
|
|
167
|
+
/** Filter by entry type(s) */
|
|
168
|
+
types?: HistoryEntryType[];
|
|
169
|
+
/** Only entries after this timestamp (epoch ms, inclusive) */
|
|
170
|
+
after?: number;
|
|
171
|
+
/** Only entries before this timestamp (epoch ms, inclusive) */
|
|
172
|
+
before?: number;
|
|
173
|
+
/** Only entries from this turn index onwards (inclusive) */
|
|
174
|
+
fromTurn?: number;
|
|
175
|
+
/** Only entries up to this turn index (inclusive) */
|
|
176
|
+
toTurn?: number;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Append-only history journal for conversation persistence.
|
|
180
|
+
*
|
|
181
|
+
* Implementations:
|
|
182
|
+
* - FileHistoryJournal: JSONL files at ~/.oneringai/agents/<agentId>/sessions/<sessionId>.history.jsonl
|
|
183
|
+
* - (Future) MongoHistoryJournal: MongoDB collection
|
|
184
|
+
* - (Future) RedisHistoryJournal: Redis Streams
|
|
185
|
+
*/
|
|
186
|
+
interface IHistoryJournal {
|
|
187
|
+
/**
|
|
188
|
+
* Append entries to the journal.
|
|
189
|
+
*
|
|
190
|
+
* This is the primary write operation, called on every addUserMessage(),
|
|
191
|
+
* addAssistantResponse(), and addToolResults(). Should be fast (append-only).
|
|
192
|
+
*
|
|
193
|
+
* @param sessionId - Session to append to
|
|
194
|
+
* @param entries - One or more history entries to append
|
|
195
|
+
*/
|
|
196
|
+
append(sessionId: string, entries: HistoryEntry[]): Promise<void>;
|
|
197
|
+
/**
|
|
198
|
+
* Read history entries with optional filtering and pagination.
|
|
199
|
+
*
|
|
200
|
+
* Entries are returned in chronological order (oldest first).
|
|
201
|
+
*
|
|
202
|
+
* @param sessionId - Session to read from
|
|
203
|
+
* @param options - Filtering and pagination options
|
|
204
|
+
* @returns Array of history entries
|
|
205
|
+
*/
|
|
206
|
+
read(sessionId: string, options?: HistoryReadOptions): Promise<HistoryEntry[]>;
|
|
207
|
+
/**
|
|
208
|
+
* Get the total number of entries in the journal.
|
|
209
|
+
*
|
|
210
|
+
* @param sessionId - Session to count
|
|
211
|
+
* @returns Number of entries (0 if session has no journal)
|
|
212
|
+
*/
|
|
213
|
+
count(sessionId: string): Promise<number>;
|
|
214
|
+
/**
|
|
215
|
+
* Delete all history for a session.
|
|
216
|
+
*
|
|
217
|
+
* Called when a session is deleted via IContextStorage.delete().
|
|
218
|
+
*
|
|
219
|
+
* @param sessionId - Session to clear
|
|
220
|
+
*/
|
|
221
|
+
clear(sessionId: string): Promise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* Stream history entries for large histories.
|
|
224
|
+
*
|
|
225
|
+
* Optional — implementations may omit this if streaming isn't practical
|
|
226
|
+
* (e.g., in-memory storage). Callers should fall back to read() with
|
|
227
|
+
* pagination if stream() is not available.
|
|
228
|
+
*
|
|
229
|
+
* @param sessionId - Session to stream
|
|
230
|
+
* @param options - Same filtering options as read()
|
|
231
|
+
* @returns AsyncIterable of history entries in chronological order
|
|
232
|
+
*/
|
|
233
|
+
stream?(sessionId: string, options?: HistoryReadOptions): AsyncIterable<HistoryEntry>;
|
|
234
|
+
/**
|
|
235
|
+
* Get a human-readable location string for debugging/display.
|
|
236
|
+
*
|
|
237
|
+
* @param sessionId - Session ID
|
|
238
|
+
* @returns Location string (file path, MongoDB URI, etc.)
|
|
239
|
+
*/
|
|
240
|
+
getLocation?(sessionId: string): string;
|
|
241
|
+
}
|
|
242
|
+
|
|
101
243
|
/**
|
|
102
244
|
* Memory entities for WorkingMemory
|
|
103
245
|
*
|
|
@@ -723,6 +865,21 @@ interface IContextStorage {
|
|
|
723
865
|
* Falls back to getPath() if not implemented.
|
|
724
866
|
*/
|
|
725
867
|
getLocation?(): string;
|
|
868
|
+
/**
|
|
869
|
+
* History journal companion for full conversation logging.
|
|
870
|
+
*
|
|
871
|
+
* When present, AgentContextNextGen automatically appends every message
|
|
872
|
+
* to the journal (append-only, fire-and-forget). The journal is never
|
|
873
|
+
* affected by compaction, preserving full conversation history.
|
|
874
|
+
*
|
|
875
|
+
* Storage implementations create the appropriate journal for their backend:
|
|
876
|
+
* - FileContextStorage → FileHistoryJournal (JSONL files)
|
|
877
|
+
* - MongoContextStorage → MongoHistoryJournal (collection)
|
|
878
|
+
*
|
|
879
|
+
* Consumers never configure the journal separately — it comes for free
|
|
880
|
+
* with the storage backend.
|
|
881
|
+
*/
|
|
882
|
+
readonly journal?: IHistoryJournal;
|
|
726
883
|
}
|
|
727
884
|
/**
|
|
728
885
|
* Options for listing sessions
|
|
@@ -1055,12 +1212,6 @@ declare class ToolCatalogRegistry {
|
|
|
1055
1212
|
static reset(): void;
|
|
1056
1213
|
}
|
|
1057
1214
|
|
|
1058
|
-
/**
|
|
1059
|
-
* AgentContextNextGen - Type Definitions
|
|
1060
|
-
*
|
|
1061
|
-
* Clean, minimal type definitions for the next-generation context manager.
|
|
1062
|
-
*/
|
|
1063
|
-
|
|
1064
1215
|
/**
|
|
1065
1216
|
* A single auth identity: connector + optional account alias.
|
|
1066
1217
|
*
|
|
@@ -1569,6 +1720,13 @@ interface AgentContextNextGenConfig {
|
|
|
1569
1720
|
* Default: 0 (disabled - relies on each tool's own timeout)
|
|
1570
1721
|
*/
|
|
1571
1722
|
toolExecutionTimeout?: number;
|
|
1723
|
+
/**
|
|
1724
|
+
* Filter which message types are written to the history journal.
|
|
1725
|
+
* When set, only entries matching these types are appended.
|
|
1726
|
+
* Default: undefined (all types journaled).
|
|
1727
|
+
* Example: ['user', 'assistant'] to exclude tool_result entries.
|
|
1728
|
+
*/
|
|
1729
|
+
journalFilter?: HistoryEntryType[];
|
|
1572
1730
|
}
|
|
1573
1731
|
/**
|
|
1574
1732
|
* Default configuration values
|
|
@@ -1809,6 +1967,7 @@ declare enum StreamEventType {
|
|
|
1809
1967
|
REASONING_DELTA = "response.reasoning.delta",
|
|
1810
1968
|
REASONING_DONE = "response.reasoning.done",
|
|
1811
1969
|
RESPONSE_COMPLETE = "response.complete",
|
|
1970
|
+
RETRY = "response.retry",
|
|
1812
1971
|
ERROR = "response.error",
|
|
1813
1972
|
AUDIO_CHUNK_READY = "response.audio_chunk.ready",
|
|
1814
1973
|
AUDIO_CHUNK_ERROR = "response.audio_chunk.error",
|
|
@@ -1923,6 +2082,18 @@ interface ResponseCompleteEvent extends BaseStreamEvent {
|
|
|
1923
2082
|
usage: TokenUsage;
|
|
1924
2083
|
iterations: number;
|
|
1925
2084
|
duration_ms?: number;
|
|
2085
|
+
/** Raw provider stop reason for diagnostics (e.g., 'end_turn', 'max_tokens', 'SAFETY') */
|
|
2086
|
+
stop_reason?: string;
|
|
2087
|
+
}
|
|
2088
|
+
/**
|
|
2089
|
+
* Retry event - emitted when agent retries an empty/incomplete LLM response
|
|
2090
|
+
*/
|
|
2091
|
+
interface RetryEvent extends BaseStreamEvent {
|
|
2092
|
+
type: StreamEventType.RETRY;
|
|
2093
|
+
attempt: number;
|
|
2094
|
+
max_attempts: number;
|
|
2095
|
+
reason: string;
|
|
2096
|
+
delay_ms: number;
|
|
1926
2097
|
}
|
|
1927
2098
|
/**
|
|
1928
2099
|
* Reasoning/thinking delta - incremental reasoning output
|
|
@@ -1995,7 +2166,7 @@ interface AudioStreamCompleteEvent extends BaseStreamEvent {
|
|
|
1995
2166
|
* Union type of all stream events
|
|
1996
2167
|
* Discriminated by 'type' field for type narrowing
|
|
1997
2168
|
*/
|
|
1998
|
-
type StreamEvent = ResponseCreatedEvent | ResponseInProgressEvent | OutputTextDeltaEvent | OutputTextDoneEvent | ReasoningDeltaEvent | ReasoningDoneEvent | ToolCallStartEvent | ToolCallArgumentsDeltaEvent | ToolCallArgumentsDoneEvent | ToolExecutionStartEvent | ToolExecutionDoneEvent | IterationCompleteEvent$1 | ResponseCompleteEvent | ErrorEvent | AudioChunkReadyEvent | AudioChunkErrorEvent | AudioStreamCompleteEvent;
|
|
2169
|
+
type StreamEvent = ResponseCreatedEvent | ResponseInProgressEvent | OutputTextDeltaEvent | OutputTextDoneEvent | ReasoningDeltaEvent | ReasoningDoneEvent | ToolCallStartEvent | ToolCallArgumentsDeltaEvent | ToolCallArgumentsDoneEvent | ToolExecutionStartEvent | ToolExecutionDoneEvent | IterationCompleteEvent$1 | ResponseCompleteEvent | RetryEvent | ErrorEvent | AudioChunkReadyEvent | AudioChunkErrorEvent | AudioStreamCompleteEvent;
|
|
1999
2170
|
/**
|
|
2000
2171
|
* Type guard to check if event is a specific type
|
|
2001
2172
|
*/
|
|
@@ -2272,6 +2443,14 @@ interface ExecutionEmptyOutputEvent {
|
|
|
2272
2443
|
duration: number;
|
|
2273
2444
|
usage?: TokenUsage;
|
|
2274
2445
|
}
|
|
2446
|
+
interface ExecutionRetryEvent {
|
|
2447
|
+
executionId: string;
|
|
2448
|
+
attempt: number;
|
|
2449
|
+
maxAttempts: number;
|
|
2450
|
+
reason: string;
|
|
2451
|
+
delayMs: number;
|
|
2452
|
+
timestamp: Date;
|
|
2453
|
+
}
|
|
2275
2454
|
interface ExecutionMaxIterationsEvent {
|
|
2276
2455
|
executionId: string;
|
|
2277
2456
|
iteration: number;
|
|
@@ -2390,6 +2569,7 @@ interface AgenticLoopEvents {
|
|
|
2390
2569
|
'tool:timeout': ToolTimeoutEvent;
|
|
2391
2570
|
'hook:error': HookErrorEvent;
|
|
2392
2571
|
'execution:empty_output': ExecutionEmptyOutputEvent;
|
|
2572
|
+
'execution:retry': ExecutionRetryEvent;
|
|
2393
2573
|
'circuit:opened': CircuitOpenedEvent;
|
|
2394
2574
|
'circuit:half-open': CircuitHalfOpenEvent;
|
|
2395
2575
|
'circuit:closed': CircuitClosedEvent;
|
|
@@ -2607,6 +2787,10 @@ declare class HookManager {
|
|
|
2607
2787
|
* Clear all hooks and reset error tracking
|
|
2608
2788
|
*/
|
|
2609
2789
|
clear(): void;
|
|
2790
|
+
/**
|
|
2791
|
+
* Destroy the hook manager and release all references
|
|
2792
|
+
*/
|
|
2793
|
+
destroy(): void;
|
|
2610
2794
|
/**
|
|
2611
2795
|
* Re-enable a disabled hook
|
|
2612
2796
|
*/
|
|
@@ -2617,4 +2801,4 @@ declare class HookManager {
|
|
|
2617
2801
|
getDisabledHooks(): string[];
|
|
2618
2802
|
}
|
|
2619
2803
|
|
|
2620
|
-
export { type
|
|
2804
|
+
export { type MemoryIndex as $, type AgentContextNextGenConfig as A, type BeforeCompactionCallback as B, type ContextFeatures as C, type AuditEntry as D, ExecutionContext as E, type FunctionToolDefinition as F, type HookName as G, type HookConfig as H, type IContextStorage as I, type ITokenEstimator as J, type ToolCategoryScope as K, type LLMResponse as L, type MemoryEntry as M, type CompactionContext as N, type OutputItem as O, type PriorityCalculator as P, type CompactionResult as Q, type AudioChunkReadyEvent as R, type SerializedContextState as S, type Tool as T, type ContextStorageListOptions as U, type ContextSessionSummary as V, type WorkingMemoryConfig as W, type HistoryEntry as X, type HistoryReadOptions as Y, type StaleEntryInfo as Z, type PriorityContext as _, type MemoryScope as a, type ToolModification as a$, type TaskStatusForMemory as a0, type WorkingMemoryAccess as a1, type TokenUsage as a2, StreamEventType as a3, type TextGenerateOptions as a4, type ModelCapabilities as a5, MessageRole as a6, type AfterToolContext as a7, type AgentEventName as a8, type AgenticLoopEventName as a9, type MemoryEntryInput as aA, type MemoryIndexEntry as aB, type Message as aC, type ModifyingHook as aD, type OutputTextContent as aE, type OutputTextDeltaEvent as aF, type OutputTextDoneEvent as aG, type OversizedInputResult as aH, type PluginConfigs as aI, type ReasoningDeltaEvent as aJ, type ReasoningDoneEvent as aK, type ReasoningItem as aL, type ResponseCompleteEvent as aM, type ResponseCreatedEvent as aN, type ResponseInProgressEvent as aO, type SimpleScope as aP, type TaskAwareScope as aQ, type ThinkingContent as aR, type ToolCallArgumentsDeltaEvent as aS, type ToolCallArgumentsDoneEvent as aT, type ToolCallStartEvent as aU, ToolCallState as aV, ToolCatalogRegistry as aW, type ToolCategoryDefinition as aX, type ToolExecutionContext as aY, type ToolExecutionDoneEvent as aZ, type ToolExecutionStartEvent as a_, type AgenticLoopEvents as aa, type ApprovalResult as ab, type ApproveToolContext as ac, type AudioChunkErrorEvent as ad, type AudioStreamCompleteEvent as ae, type BeforeToolContext as af, type BuiltInTool as ag, CONTEXT_SESSION_FORMAT_VERSION as ah, type ToolRegistryEntry as ai, type CatalogToolEntry as aj, type CompactionItem as ak, type ConnectorCategoryInfo as al, ContentType as am, DEFAULT_CONFIG as an, DEFAULT_FEATURES as ao, DEFAULT_MEMORY_CONFIG as ap, type ErrorEvent as aq, type ExecutionConfig as ar, type HistoryEntryType as as, type Hook as at, HookManager as au, type InputImageContent as av, type InputTextContent as aw, type IterationCompleteEvent$1 as ax, type JSONSchema as ay, MEMORY_PRIORITY_VALUES as az, type ToolFunction as b, type ToolResultContent as b0, type ToolUseContent as b1, calculateEntrySize as b2, defaultDescribeCall as b3, forPlan as b4, forTasks as b5, getToolCallDescription as b6, isAudioChunkError as b7, isAudioChunkReady as b8, isAudioStreamComplete as b9, isErrorEvent as ba, isOutputTextDelta as bb, isReasoningDelta as bc, isReasoningDone as bd, isResponseComplete as be, isSimpleScope as bf, isStreamEvent as bg, isTaskAwareScope as bh, isTerminalMemoryStatus as bi, isToolCallArgumentsDelta as bj, isToolCallArgumentsDone as bk, isToolCallStart as bl, scopeEquals as bm, scopeMatches as bn, type ExecutionCompleteEvent as bo, type ExecutionStartEvent as bp, type LLMRequestEvent as bq, type LLMResponseEvent as br, type ToolCompleteEvent as bs, type ToolStartEvent as bt, type ToolContext as c, type ToolPermissionConfig as d, type ContextBudget as e, type ToolCall as f, type IContextPluginNextGen as g, type MemoryPriority as h, type MemoryTier as i, type ContextEvents as j, type AuthIdentity as k, type ICompactionStrategy as l, type InputItem as m, type Content as n, type PreparedContext as o, type ToolResult as p, type IHistoryJournal as q, type ConsolidationResult as r, type StoredContextSession as s, type ITextProvider as t, type ContextSessionMetadata as u, type StreamEvent as v, type HistoryMode as w, type AgentEvents as x, type AgentResponse as y, type ExecutionMetrics as z };
|