@frost1994/agentic-core 1.0.0 → 1.0.3
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 +5 -5
- package/dist/index.cjs +324 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +505 -5
- package/dist/index.js +324 -0
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.ts +384 -5
- package/package.json +1 -1
- package/LICENSE +0 -201
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,16 @@ export declare interface ActionDescriptor {
|
|
|
8
8
|
riskLevel: 'safe' | 'caution' | 'danger';
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/** A write-action pending 二次确认. */
|
|
12
|
+
export declare interface ActionPart {
|
|
13
|
+
kind: 'action';
|
|
14
|
+
actionId: string;
|
|
15
|
+
title: string;
|
|
16
|
+
summary?: string;
|
|
17
|
+
riskLevel: RiskLevel;
|
|
18
|
+
params: Record<string, string | number | boolean | null>;
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
export declare interface AiAssistantError extends Error {
|
|
12
22
|
code: ErrorCode;
|
|
13
23
|
retriable: boolean;
|
|
@@ -49,6 +59,15 @@ export declare type AiOpenMode = 'launcher' | 'floating' | 'drawer' | 'fullscree
|
|
|
49
59
|
|
|
50
60
|
export declare type AiThemeMode = 'system' | 'light' | 'dark' | 'custom';
|
|
51
61
|
|
|
62
|
+
/** A backend-produced insight (never re-derived from rows on the client). */
|
|
63
|
+
declare interface AnalysisInsight {
|
|
64
|
+
type: InsightType;
|
|
65
|
+
title: string;
|
|
66
|
+
detail: string;
|
|
67
|
+
/** Optional references to column keys / row indices backing the insight. */
|
|
68
|
+
refs?: string[];
|
|
69
|
+
}
|
|
70
|
+
|
|
52
71
|
export declare interface AssistantMessage {
|
|
53
72
|
id: string;
|
|
54
73
|
conversationId: string;
|
|
@@ -139,6 +158,76 @@ export declare interface AssistantState {
|
|
|
139
158
|
lastError: string | null;
|
|
140
159
|
}
|
|
141
160
|
|
|
161
|
+
/**
|
|
162
|
+
* Card payload — discriminated union on `kind`. Mirrors Java `sealed interface
|
|
163
|
+
* CardData permits SqlCard, TableCard, ChartCard, MetricCard, SourceCard,
|
|
164
|
+
* SuggestionCard, GlossaryCard, AnalysisCard, CitationCard`.
|
|
165
|
+
*/
|
|
166
|
+
declare type CardData = {
|
|
167
|
+
kind: 'sql';
|
|
168
|
+
sql: string;
|
|
169
|
+
dialect: Dialect;
|
|
170
|
+
tables: string[];
|
|
171
|
+
estimatedRows: number;
|
|
172
|
+
isReadonly: boolean;
|
|
173
|
+
isSensitive: boolean;
|
|
174
|
+
explanation?: string;
|
|
175
|
+
} | {
|
|
176
|
+
kind: 'table';
|
|
177
|
+
columns: ColumnDef[];
|
|
178
|
+
rows: Row[];
|
|
179
|
+
total: number;
|
|
180
|
+
truncated?: boolean;
|
|
181
|
+
} | {
|
|
182
|
+
kind: 'chart';
|
|
183
|
+
spec: ChartSpec;
|
|
184
|
+
} | {
|
|
185
|
+
kind: 'metric';
|
|
186
|
+
items: MetricItem[];
|
|
187
|
+
} | {
|
|
188
|
+
kind: 'source';
|
|
189
|
+
items: SourceItem[];
|
|
190
|
+
} | {
|
|
191
|
+
kind: 'suggestion';
|
|
192
|
+
items: SuggestionItem[];
|
|
193
|
+
} | {
|
|
194
|
+
kind: 'glossary';
|
|
195
|
+
columns: ColumnDef[];
|
|
196
|
+
} | {
|
|
197
|
+
kind: 'analysis';
|
|
198
|
+
insights: AnalysisInsight[];
|
|
199
|
+
} | {
|
|
200
|
+
kind: 'citation';
|
|
201
|
+
items: CitationItem[];
|
|
202
|
+
};
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* v2 protocol — card payloads (discriminated union on `kind`).
|
|
206
|
+
*
|
|
207
|
+
* Per REARCHITECTURE-PLAN §4.3 / §4.4: rich content is delivered through a
|
|
208
|
+
* single `card` event whose `data` is a strongly-typed, `kind`-discriminated
|
|
209
|
+
* union. Adding a new card = adding a new `kind` here + one frontend registry
|
|
210
|
+
* entry; the core envelope (events.ts) never changes (CLAUDE.md §12 扩展预留).
|
|
211
|
+
*
|
|
212
|
+
* These types MUST stay shape-for-shape identical to the Java sealed records
|
|
213
|
+
* (`CardData` permits SqlCard/TableCard/... ) so the shared golden fixture
|
|
214
|
+
* (see __fixtures__/golden-events.ts) round-trips on both sides.
|
|
215
|
+
*
|
|
216
|
+
* Pure TS — zero Vue / framework dependency.
|
|
217
|
+
*/
|
|
218
|
+
/** Closed enum of card kinds. The `card` event carries one of these. */
|
|
219
|
+
declare type CardKind = 'sql' | 'table' | 'chart' | 'metric' | 'source' | 'suggestion' | 'glossary' | 'analysis' | 'citation';
|
|
220
|
+
|
|
221
|
+
/** A rich content card (sql / table / chart / metric / …). */
|
|
222
|
+
export declare interface CardPart {
|
|
223
|
+
kind: 'card';
|
|
224
|
+
id: string;
|
|
225
|
+
cardKind: CardKind;
|
|
226
|
+
data: CardData;
|
|
227
|
+
transient?: boolean;
|
|
228
|
+
status?: string;
|
|
229
|
+
}
|
|
230
|
+
|
|
142
231
|
export declare interface ChartConfig {
|
|
143
232
|
type: 'bar' | 'line' | 'pie' | 'heatmap' | 'gantt' | 'scatter';
|
|
144
233
|
title: string;
|
|
@@ -146,6 +235,33 @@ export declare interface ChartConfig {
|
|
|
146
235
|
options?: Record<string, unknown>;
|
|
147
236
|
}
|
|
148
237
|
|
|
238
|
+
/** Encoding: which column keys map to which visual channels. */
|
|
239
|
+
declare interface ChartEncoding {
|
|
240
|
+
/** Column key for the x axis (category / time). */
|
|
241
|
+
x: string;
|
|
242
|
+
/** One or more column keys for the y axis (measures). */
|
|
243
|
+
y: string[];
|
|
244
|
+
/** Optional column key used to split into series. */
|
|
245
|
+
series?: string;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Closed enum of neutral chart kinds. `''` means "no suitable chart — fall back
|
|
250
|
+
* to table" (mirrors WrenAI's empty chart_type). Frontend maps these to ECharts.
|
|
251
|
+
*/
|
|
252
|
+
declare type ChartKind = '' | 'bar' | 'line' | 'pie' | 'scatter' | 'area' | 'grouped-bar' | 'stacked-bar';
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Neutral, framework-agnostic chart spec. Backend owns the spec; frontend owns
|
|
256
|
+
* the ECharts mapping. `data` is the full result set (rows) for plotting.
|
|
257
|
+
*/
|
|
258
|
+
declare interface ChartSpec {
|
|
259
|
+
chartKind: ChartKind;
|
|
260
|
+
title?: string;
|
|
261
|
+
encoding: ChartEncoding;
|
|
262
|
+
data: Row[];
|
|
263
|
+
}
|
|
264
|
+
|
|
149
265
|
export declare class ChunkMatcher {
|
|
150
266
|
/**
|
|
151
267
|
* Match parsed citations to a list of knowledge chunks.
|
|
@@ -184,6 +300,14 @@ export declare interface Citation {
|
|
|
184
300
|
end: number;
|
|
185
301
|
}
|
|
186
302
|
|
|
303
|
+
/** A knowledge-base citation entry (Phase 2 预留). */
|
|
304
|
+
declare interface CitationItem {
|
|
305
|
+
docName: string;
|
|
306
|
+
page: number;
|
|
307
|
+
section: string;
|
|
308
|
+
content: string;
|
|
309
|
+
}
|
|
310
|
+
|
|
187
311
|
export declare class CitationParser {
|
|
188
312
|
/** Regex for citation markers: [1], [12], etc. */
|
|
189
313
|
private static readonly MARKER_RE;
|
|
@@ -215,6 +339,36 @@ export declare class CitationParser {
|
|
|
215
339
|
/** Clamp a number between min and max (inclusive). */
|
|
216
340
|
export declare function clamp(value: number, min: number, max: number): number;
|
|
217
341
|
|
|
342
|
+
/** A clarification request asking the user to choose or answer. */
|
|
343
|
+
export declare interface ClarifyPart {
|
|
344
|
+
kind: 'clarify';
|
|
345
|
+
question: string;
|
|
346
|
+
options?: string[];
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* A result-table / glossary column. Semantic fields (displayName/role/...) come
|
|
351
|
+
* from the backend semantic layer — never re-derived on the client.
|
|
352
|
+
*/
|
|
353
|
+
declare interface ColumnDef {
|
|
354
|
+
key: string;
|
|
355
|
+
title: string;
|
|
356
|
+
type?: string;
|
|
357
|
+
/** Business-friendly Chinese name, e.g. "设备温度". */
|
|
358
|
+
displayName?: string;
|
|
359
|
+
/** Semantic role for analysis/charting. */
|
|
360
|
+
role?: ColumnRole;
|
|
361
|
+
/** Human description, e.g. "通信状态(0正常/1异常)". */
|
|
362
|
+
description?: string;
|
|
363
|
+
/** Display unit, e.g. "℃", "件". */
|
|
364
|
+
unit?: string;
|
|
365
|
+
/** Sensitive columns are stripped before the LLM; flagged here for UI only. */
|
|
366
|
+
sensitive?: boolean;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** Semantic role of a result column (drives glossary + analysis). */
|
|
370
|
+
declare type ColumnRole = 'dimension' | 'metric' | 'time';
|
|
371
|
+
|
|
218
372
|
export declare interface Conversation {
|
|
219
373
|
id: string;
|
|
220
374
|
title: string;
|
|
@@ -290,6 +444,9 @@ export declare function deserialize(data: unknown): AssistantState | null;
|
|
|
290
444
|
/** Convenience: deserialize from JSON string. */
|
|
291
445
|
export declare function deserializeFromString(json: string): AssistantState | null;
|
|
292
446
|
|
|
447
|
+
/** SQL dialect produced by the engine (closed set; never free-form). */
|
|
448
|
+
declare type Dialect = 'mysql' | 'postgresql';
|
|
449
|
+
|
|
293
450
|
export declare type ErrorCode = keyof typeof ErrorCodes;
|
|
294
451
|
|
|
295
452
|
/**
|
|
@@ -333,6 +490,9 @@ export declare interface FeaturesConfig {
|
|
|
333
490
|
enableActionConfirm?: boolean;
|
|
334
491
|
}
|
|
335
492
|
|
|
493
|
+
/** Why a run finished. */
|
|
494
|
+
declare type FinishReason = 'stop' | 'length' | 'tool_calls' | 'content_filter' | 'error';
|
|
495
|
+
|
|
336
496
|
/** Format a Date or timestamp to locale string. */
|
|
337
497
|
export declare function formatDate(input: Date | number | string, options?: Intl.DateTimeFormatOptions): string;
|
|
338
498
|
|
|
@@ -352,6 +512,12 @@ export declare interface I18nConfig {
|
|
|
352
512
|
messages?: Record<string, string>;
|
|
353
513
|
}
|
|
354
514
|
|
|
515
|
+
/** Factory for a blank accumulator. */
|
|
516
|
+
export declare function initialState(): ReduceState;
|
|
517
|
+
|
|
518
|
+
/** Type of an analysis insight (drives icon/severity on the client). */
|
|
519
|
+
declare type InsightType = 'trend' | 'outlier' | 'comparison' | 'summary' | 'anomaly';
|
|
520
|
+
|
|
355
521
|
/**
|
|
356
522
|
* Check whether an error represents a user abort.
|
|
357
523
|
*/
|
|
@@ -372,6 +538,17 @@ export declare function isRetriable(error: unknown): boolean;
|
|
|
372
538
|
|
|
373
539
|
export declare function isString(value: unknown): value is string;
|
|
374
540
|
|
|
541
|
+
/**
|
|
542
|
+
* RFC 6902 JSON Patch op (subset) used by `card.patch` for in-place updates.
|
|
543
|
+
* Kept narrow on purpose; the transitional path may instead re-send the full
|
|
544
|
+
* `card` with the same id.
|
|
545
|
+
*/
|
|
546
|
+
declare interface JsonPatchOp {
|
|
547
|
+
op: 'add' | 'remove' | 'replace';
|
|
548
|
+
path: string;
|
|
549
|
+
value?: string | number | boolean | null | Record<string, unknown> | unknown[];
|
|
550
|
+
}
|
|
551
|
+
|
|
375
552
|
export declare interface KnowledgeChunk {
|
|
376
553
|
/** Chunk index (1-based, matching citation numbers) */
|
|
377
554
|
index: number;
|
|
@@ -390,12 +567,56 @@ export declare interface MatchedChunk extends KnowledgeChunk {
|
|
|
390
567
|
citedBy: number[];
|
|
391
568
|
}
|
|
392
569
|
|
|
570
|
+
/** Internal indexes for the current (last) message. */
|
|
571
|
+
declare interface MessageIndexes {
|
|
572
|
+
/** partId → index in `parts` for text/reasoning parts */
|
|
573
|
+
byPartId: Map<string, number>;
|
|
574
|
+
/** toolCallId → index in `parts` for tool parts */
|
|
575
|
+
byToolCallId: Map<string, number>;
|
|
576
|
+
/** card.id → index in `parts` for card parts */
|
|
577
|
+
byCardId: Map<string, number>;
|
|
578
|
+
}
|
|
579
|
+
|
|
393
580
|
export declare type MessageRole = 'user' | 'assistant' | 'system' | 'tool';
|
|
394
581
|
|
|
582
|
+
/**
|
|
583
|
+
* Complete snapshot of a single assistant message at a point in time.
|
|
584
|
+
* Parts are ordered by the `seq` of their originating start event.
|
|
585
|
+
*/
|
|
586
|
+
export declare interface MessageSnapshot {
|
|
587
|
+
messageId: string;
|
|
588
|
+
conversationId: string;
|
|
589
|
+
status: RunStatus;
|
|
590
|
+
parts: Part[];
|
|
591
|
+
usage?: Usage;
|
|
592
|
+
finishReason?: FinishReason;
|
|
593
|
+
/** Wall-clock latency reported by the backend on `run.finish`. */
|
|
594
|
+
latencyMs?: number;
|
|
595
|
+
/** Timestamp (ms) when `run.start` was received. */
|
|
596
|
+
startedAt: number;
|
|
597
|
+
}
|
|
598
|
+
|
|
395
599
|
export declare type MessageStatus = 'pending' | 'streaming' | 'success' | 'failed';
|
|
396
600
|
|
|
397
601
|
export declare type MessageType = 'text' | 'markdown' | 'chart' | 'table' | 'tool' | 'error' | 'sql' | 'metric' | 'action' | 'source';
|
|
398
602
|
|
|
603
|
+
/** A single KPI / metric tile. Multiple tiles share one metric card. */
|
|
604
|
+
declare interface MetricItem {
|
|
605
|
+
label: string;
|
|
606
|
+
value: string | number;
|
|
607
|
+
unit?: string;
|
|
608
|
+
trend?: MetricTrend;
|
|
609
|
+
/** Display format hint, e.g. "percent", "currency", "integer". */
|
|
610
|
+
format?: string;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
/** A trend annotation on a metric value. */
|
|
614
|
+
declare interface MetricTrend {
|
|
615
|
+
value: number;
|
|
616
|
+
direction: TrendDirection;
|
|
617
|
+
label?: string;
|
|
618
|
+
}
|
|
619
|
+
|
|
399
620
|
export declare interface ModelOption {
|
|
400
621
|
code: string;
|
|
401
622
|
name: string;
|
|
@@ -425,6 +646,9 @@ export declare interface PageContext {
|
|
|
425
646
|
extras?: Record<string, unknown>;
|
|
426
647
|
}
|
|
427
648
|
|
|
649
|
+
/** Discriminated union of all renderable parts of an assistant turn. */
|
|
650
|
+
export declare type Part = TextPart | ReasoningPart | ToolPart | CardPart | ActionPart | ClarifyPart;
|
|
651
|
+
|
|
428
652
|
export declare interface PluginConfig {
|
|
429
653
|
systemCode: string;
|
|
430
654
|
defaultMode: string;
|
|
@@ -439,13 +663,55 @@ export declare interface PluginConfig {
|
|
|
439
663
|
rateLimitPerHour: number;
|
|
440
664
|
}
|
|
441
665
|
|
|
666
|
+
/** Chain-of-thought reasoning block (optional; default not rendered). */
|
|
667
|
+
export declare interface ReasoningPart {
|
|
668
|
+
kind: 'reasoning';
|
|
669
|
+
partId: string;
|
|
670
|
+
text: string;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Pure fold: given the current accumulator state and one v2 `StreamEvent`,
|
|
675
|
+
* return the next state. Never mutates `state`. Unknown event types are
|
|
676
|
+
* ignored silently.
|
|
677
|
+
*/
|
|
678
|
+
export declare function reduce(state: ReduceState, event: StreamEvent_2): ReduceState;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* Convenience fold: reduce an entire ordered sequence of events from scratch.
|
|
682
|
+
* Equivalent to `events.reduce(reduce, initialState())`.
|
|
683
|
+
*/
|
|
684
|
+
export declare function reduceAll(events: StreamEvent_2[]): ReduceState;
|
|
685
|
+
|
|
442
686
|
export declare function reducer(state: AssistantState, action: StateAction): AssistantState;
|
|
443
687
|
|
|
688
|
+
/**
|
|
689
|
+
* Accumulator state for `reduce`. Plain / serialisable (Maps are the only
|
|
690
|
+
* non-JSON-native field; callers that need JSON-round-trip should serialise
|
|
691
|
+
* them separately).
|
|
692
|
+
*/
|
|
693
|
+
export declare interface ReduceState {
|
|
694
|
+
/** Ordered list of assistant messages produced so far. */
|
|
695
|
+
messages: MessageSnapshot[];
|
|
696
|
+
/** Last `seq` accepted (used for duplicate/OOO filtering). */
|
|
697
|
+
lastSeq: number;
|
|
698
|
+
/* Excluded from this release type: _idx */
|
|
699
|
+
}
|
|
700
|
+
|
|
444
701
|
export declare interface RegisteredTool {
|
|
445
702
|
definition: ToolDefinition;
|
|
446
703
|
executor: ToolExecutor;
|
|
447
704
|
}
|
|
448
705
|
|
|
706
|
+
/** Risk level for a proposed write action (Action Center 二次确认). */
|
|
707
|
+
declare type RiskLevel = 'safe' | 'caution' | 'danger';
|
|
708
|
+
|
|
709
|
+
/** A single result row: column key → cell value. */
|
|
710
|
+
declare type Row = Record<string, string | number | boolean | null>;
|
|
711
|
+
|
|
712
|
+
/** Status of an assistant message lifetime (v2 reducer). */
|
|
713
|
+
export declare type RunStatus = 'streaming' | 'complete' | 'error';
|
|
714
|
+
|
|
449
715
|
/** Serialize state to JSON-safe object (excludes transient stream fields). */
|
|
450
716
|
export declare function serialize(state: AssistantState): SerializedState;
|
|
451
717
|
|
|
@@ -457,6 +723,26 @@ export declare interface SerializedState {
|
|
|
457
723
|
/** Convenience: serialize to JSON string. */
|
|
458
724
|
export declare function serializeToString(state: AssistantState): string;
|
|
459
725
|
|
|
726
|
+
/**
|
|
727
|
+
* A data-source provenance entry. Discriminated on `kind` to remove the v1
|
|
728
|
+
* polymorphism where `table` was sometimes a real table, sometimes a tool name.
|
|
729
|
+
*/
|
|
730
|
+
declare type SourceItem = {
|
|
731
|
+
kind: 'table';
|
|
732
|
+
name: string;
|
|
733
|
+
query?: string;
|
|
734
|
+
rowCount: number | null;
|
|
735
|
+
durationMs: number;
|
|
736
|
+
timestamp: string;
|
|
737
|
+
} | {
|
|
738
|
+
kind: 'tool';
|
|
739
|
+
name: string;
|
|
740
|
+
query?: string;
|
|
741
|
+
rowCount: number | null;
|
|
742
|
+
durationMs: number;
|
|
743
|
+
timestamp: string;
|
|
744
|
+
};
|
|
745
|
+
|
|
460
746
|
export declare interface SourceRef {
|
|
461
747
|
table: string;
|
|
462
748
|
query: string;
|
|
@@ -783,6 +1069,141 @@ export declare type StreamEvent = {
|
|
|
783
1069
|
ts: number;
|
|
784
1070
|
};
|
|
785
1071
|
|
|
1072
|
+
/**
|
|
1073
|
+
* The full v2 stream-event union. Discriminated on `type`; every member carries
|
|
1074
|
+
* a monotonic `seq`.
|
|
1075
|
+
*/
|
|
1076
|
+
declare type StreamEvent_2 = {
|
|
1077
|
+
type: 'run.start';
|
|
1078
|
+
seq: number;
|
|
1079
|
+
conversationId: string;
|
|
1080
|
+
messageId: string;
|
|
1081
|
+
} | {
|
|
1082
|
+
type: 'run.finish';
|
|
1083
|
+
seq: number;
|
|
1084
|
+
reason: FinishReason;
|
|
1085
|
+
usage: Usage;
|
|
1086
|
+
latencyMs: number;
|
|
1087
|
+
} | {
|
|
1088
|
+
type: 'run.error';
|
|
1089
|
+
seq: number;
|
|
1090
|
+
code: string;
|
|
1091
|
+
message: string;
|
|
1092
|
+
retriable: boolean;
|
|
1093
|
+
} | {
|
|
1094
|
+
type: 'text.start';
|
|
1095
|
+
seq: number;
|
|
1096
|
+
partId: string;
|
|
1097
|
+
} | {
|
|
1098
|
+
type: 'text.delta';
|
|
1099
|
+
seq: number;
|
|
1100
|
+
partId: string;
|
|
1101
|
+
delta: string;
|
|
1102
|
+
} | {
|
|
1103
|
+
type: 'text.end';
|
|
1104
|
+
seq: number;
|
|
1105
|
+
partId: string;
|
|
1106
|
+
} | {
|
|
1107
|
+
type: 'reasoning.start';
|
|
1108
|
+
seq: number;
|
|
1109
|
+
partId: string;
|
|
1110
|
+
} | {
|
|
1111
|
+
type: 'reasoning.delta';
|
|
1112
|
+
seq: number;
|
|
1113
|
+
partId: string;
|
|
1114
|
+
delta: string;
|
|
1115
|
+
} | {
|
|
1116
|
+
type: 'reasoning.end';
|
|
1117
|
+
seq: number;
|
|
1118
|
+
partId: string;
|
|
1119
|
+
} | {
|
|
1120
|
+
type: 'tool.start';
|
|
1121
|
+
seq: number;
|
|
1122
|
+
toolCallId: string;
|
|
1123
|
+
toolName: string;
|
|
1124
|
+
} | {
|
|
1125
|
+
type: 'tool.input.delta';
|
|
1126
|
+
seq: number;
|
|
1127
|
+
toolCallId: string;
|
|
1128
|
+
delta: string;
|
|
1129
|
+
} | {
|
|
1130
|
+
type: 'tool.input';
|
|
1131
|
+
seq: number;
|
|
1132
|
+
toolCallId: string;
|
|
1133
|
+
input: Record<string, string | number | boolean | null>;
|
|
1134
|
+
} | {
|
|
1135
|
+
type: 'tool.executing';
|
|
1136
|
+
seq: number;
|
|
1137
|
+
toolCallId: string;
|
|
1138
|
+
} | {
|
|
1139
|
+
type: 'tool.output';
|
|
1140
|
+
seq: number;
|
|
1141
|
+
toolCallId: string;
|
|
1142
|
+
output: ToolOutput;
|
|
1143
|
+
status: ToolStatus;
|
|
1144
|
+
} | {
|
|
1145
|
+
type: 'tool.error';
|
|
1146
|
+
seq: number;
|
|
1147
|
+
toolCallId: string;
|
|
1148
|
+
error: string;
|
|
1149
|
+
} | {
|
|
1150
|
+
type: 'card';
|
|
1151
|
+
seq: number;
|
|
1152
|
+
id: string;
|
|
1153
|
+
kind: CardKind;
|
|
1154
|
+
data: CardData;
|
|
1155
|
+
status?: string;
|
|
1156
|
+
transient?: boolean;
|
|
1157
|
+
} | {
|
|
1158
|
+
type: 'card.patch';
|
|
1159
|
+
seq: number;
|
|
1160
|
+
id: string;
|
|
1161
|
+
patch: JsonPatchOp[];
|
|
1162
|
+
} | {
|
|
1163
|
+
type: 'action.proposed';
|
|
1164
|
+
seq: number;
|
|
1165
|
+
actionId: string;
|
|
1166
|
+
title: string;
|
|
1167
|
+
summary?: string;
|
|
1168
|
+
riskLevel: RiskLevel;
|
|
1169
|
+
params: Record<string, string | number | boolean | null>;
|
|
1170
|
+
} | {
|
|
1171
|
+
type: 'clarify';
|
|
1172
|
+
seq: number;
|
|
1173
|
+
question: string;
|
|
1174
|
+
options?: string[];
|
|
1175
|
+
};
|
|
1176
|
+
|
|
1177
|
+
/** Convenience: the closed set of v2 event `type` discriminants. */
|
|
1178
|
+
declare type StreamEventType = StreamEvent_2['type'];
|
|
1179
|
+
|
|
1180
|
+
/** A structured follow-up suggestion (programmatically routable). */
|
|
1181
|
+
declare interface SuggestionItem {
|
|
1182
|
+
text: string;
|
|
1183
|
+
/** Optional intent code for programmatic routing. */
|
|
1184
|
+
intent?: string;
|
|
1185
|
+
/** Optional pre-filled params for the routed intent. */
|
|
1186
|
+
params?: Record<string, string | number | boolean | null>;
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
/**
|
|
1190
|
+
* A result-table column. The semantic fields (displayName/description/role) are
|
|
1191
|
+
* optional and backward-compatible: when the backend populates them from the
|
|
1192
|
+
* registered column metadata (ColumnConfigDTO) they drive the 字段说明 glossary
|
|
1193
|
+
* and the table-header tooltip; when absent the table renders exactly as before.
|
|
1194
|
+
*/
|
|
1195
|
+
export declare interface TableColumn {
|
|
1196
|
+
key: string;
|
|
1197
|
+
title: string;
|
|
1198
|
+
type?: string;
|
|
1199
|
+
/** Business-friendly Chinese name (e.g. "虚拟温度") for the glossary. */
|
|
1200
|
+
displayName?: string;
|
|
1201
|
+
/** Human description of the column (e.g. "设备ID", "通信状态(0正常/1异常)"). */
|
|
1202
|
+
description?: string;
|
|
1203
|
+
/** Semantic role for analysis: dimension / metric / time. */
|
|
1204
|
+
role?: 'dimension' | 'metric' | 'time';
|
|
1205
|
+
}
|
|
1206
|
+
|
|
786
1207
|
export declare interface TableInfo {
|
|
787
1208
|
tableName: string;
|
|
788
1209
|
tableComment?: string;
|
|
@@ -795,15 +1216,18 @@ export declare interface TableInfo {
|
|
|
795
1216
|
}
|
|
796
1217
|
|
|
797
1218
|
export declare interface TableResult {
|
|
798
|
-
columns:
|
|
799
|
-
key: string;
|
|
800
|
-
title: string;
|
|
801
|
-
type?: string;
|
|
802
|
-
}[];
|
|
1219
|
+
columns: TableColumn[];
|
|
803
1220
|
rows: Record<string, unknown>[];
|
|
804
1221
|
total?: number;
|
|
805
1222
|
}
|
|
806
1223
|
|
|
1224
|
+
/** A streamed text block (main reply or continuation). */
|
|
1225
|
+
export declare interface TextPart {
|
|
1226
|
+
kind: 'text';
|
|
1227
|
+
partId: string;
|
|
1228
|
+
text: string;
|
|
1229
|
+
}
|
|
1230
|
+
|
|
807
1231
|
export declare function throttle<T extends (...args: unknown[]) => unknown>(fn: T, waitMs: number, options?: {
|
|
808
1232
|
leading?: boolean;
|
|
809
1233
|
trailing?: boolean;
|
|
@@ -849,6 +1273,38 @@ export declare class ToolOrchestrator {
|
|
|
849
1273
|
private executeParallel;
|
|
850
1274
|
}
|
|
851
1275
|
|
|
1276
|
+
/**
|
|
1277
|
+
* Structured tool result (replaces v1's perpetually-null `result`). Always a
|
|
1278
|
+
* populated object describing what the tool did.
|
|
1279
|
+
*/
|
|
1280
|
+
declare interface ToolOutput {
|
|
1281
|
+
executed: boolean;
|
|
1282
|
+
rowCount?: number;
|
|
1283
|
+
durationMs?: number;
|
|
1284
|
+
/** Optional human-readable summary of the tool outcome. */
|
|
1285
|
+
summary?: string;
|
|
1286
|
+
/** Optional structured payload (kept open for tool-specific extras). */
|
|
1287
|
+
data?: Record<string, string | number | boolean | null>;
|
|
1288
|
+
}
|
|
1289
|
+
|
|
1290
|
+
/** A tool invocation with full lifecycle state. */
|
|
1291
|
+
export declare interface ToolPart {
|
|
1292
|
+
kind: 'tool';
|
|
1293
|
+
toolCallId: string;
|
|
1294
|
+
toolName: string;
|
|
1295
|
+
status: ToolPartStatus;
|
|
1296
|
+
/** Accumulated raw JSON string of the input (from `tool.input.delta`). */
|
|
1297
|
+
inputRaw?: string;
|
|
1298
|
+
/** Authoritative parsed input (from `tool.input`). */
|
|
1299
|
+
input?: Record<string, string | number | boolean | null>;
|
|
1300
|
+
output?: ToolOutput;
|
|
1301
|
+
outputStatus?: ToolStatus;
|
|
1302
|
+
error?: string;
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
/** Status of a tool call across its state machine. */
|
|
1306
|
+
export declare type ToolPartStatus = 'pending' | 'input-streaming' | 'input-ready' | 'executing' | 'output-available' | 'output-error';
|
|
1307
|
+
|
|
852
1308
|
export declare class ToolRegistry {
|
|
853
1309
|
private readonly tools;
|
|
854
1310
|
/** Register a tool with its definition and executor. */
|
|
@@ -867,6 +1323,9 @@ export declare class ToolRegistry {
|
|
|
867
1323
|
clear(): void;
|
|
868
1324
|
}
|
|
869
1325
|
|
|
1326
|
+
/** Tool-call lifecycle status carried by `tool.output`. */
|
|
1327
|
+
declare type ToolStatus = 'output-available' | 'output-error';
|
|
1328
|
+
|
|
870
1329
|
export declare interface ToolStep {
|
|
871
1330
|
stepId: string;
|
|
872
1331
|
toolName: string;
|
|
@@ -892,6 +1351,16 @@ export declare interface TransportConfig {
|
|
|
892
1351
|
fetchFallback?: boolean;
|
|
893
1352
|
}
|
|
894
1353
|
|
|
1354
|
+
/** Direction of a metric trend. */
|
|
1355
|
+
declare type TrendDirection = 'up' | 'down' | 'flat';
|
|
1356
|
+
|
|
1357
|
+
/** Token usage, filled authoritatively on `run.finish` (fixes v1 durationMs=0). */
|
|
1358
|
+
declare interface Usage {
|
|
1359
|
+
prompt: number;
|
|
1360
|
+
completion: number;
|
|
1361
|
+
total: number;
|
|
1362
|
+
}
|
|
1363
|
+
|
|
895
1364
|
export declare interface UserInfo {
|
|
896
1365
|
userId: string;
|
|
897
1366
|
username: string;
|
|
@@ -901,4 +1370,35 @@ export declare interface UserInfo {
|
|
|
901
1370
|
dataScope?: 'all' | 'org' | 'area' | 'self';
|
|
902
1371
|
}
|
|
903
1372
|
|
|
1373
|
+
declare namespace v2 {
|
|
1374
|
+
export {
|
|
1375
|
+
StreamEvent_2 as StreamEvent,
|
|
1376
|
+
StreamEventType,
|
|
1377
|
+
Usage,
|
|
1378
|
+
FinishReason,
|
|
1379
|
+
ToolStatus,
|
|
1380
|
+
ToolOutput,
|
|
1381
|
+
RiskLevel,
|
|
1382
|
+
JsonPatchOp,
|
|
1383
|
+
CardData,
|
|
1384
|
+
CardKind,
|
|
1385
|
+
Dialect,
|
|
1386
|
+
ColumnRole,
|
|
1387
|
+
ColumnDef,
|
|
1388
|
+
Row,
|
|
1389
|
+
ChartKind,
|
|
1390
|
+
ChartEncoding,
|
|
1391
|
+
ChartSpec,
|
|
1392
|
+
TrendDirection,
|
|
1393
|
+
MetricTrend,
|
|
1394
|
+
MetricItem,
|
|
1395
|
+
SourceItem,
|
|
1396
|
+
SuggestionItem,
|
|
1397
|
+
InsightType,
|
|
1398
|
+
AnalysisInsight,
|
|
1399
|
+
CitationItem
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
export { v2 }
|
|
1403
|
+
|
|
904
1404
|
export { }
|