@eggjs/tegg-types 3.83.0 → 3.84.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -28,29 +28,74 @@ export interface InputMessage {
28
28
  content: string | InputContentPart[];
29
29
  metadata?: Record<string, unknown>;
30
30
  }
31
- export interface SDKSystemMessage {
31
+ /** Per-message timing, stamped by the executor as each message streams in. */
32
+ export interface MessageTiming {
33
+ /** Epoch ms when the executor received this message — authoritative per-message time. */
34
+ receivedAtMs: number;
35
+ /** Gap in ms since the previous persisted message's `receivedAtMs`. */
36
+ sincePrevMs?: number;
37
+ /** assistant only: ms the model took to generate this message (turn `message_start` → arrival). */
38
+ genMs?: number;
39
+ /** assistant only: time-to-first-token in ms, carried over from the turn's `stream_event`. */
40
+ ttftMs?: number;
41
+ }
42
+ /** Precise execution timing for a single tool call, derived from PreToolUse / PostToolUse hooks. */
43
+ export interface ToolTiming {
44
+ toolUseId: string;
45
+ name: string;
46
+ /** Epoch ms when the tool started executing (PreToolUse). */
47
+ startedAtMs: number;
48
+ /** Epoch ms when the tool finished (PostToolUse); `null` when interrupted before completion. */
49
+ endedAtMs: number | null;
50
+ /** `endedAtMs - startedAtMs`; `null` when the tool did not finish. */
51
+ durationMs: number | null;
52
+ isError?: boolean;
53
+ /** Set when the tool ran inside a sub-agent. */
54
+ agentId?: string;
55
+ }
56
+ /** Single `eggExt` namespace carrying all framework extension fields on a message. */
57
+ export interface EggExt {
58
+ /** Owning runId. Mirrored here as the forward-looking canonical location; also kept top-level for back-compat. */
59
+ runId?: string;
60
+ /** Per-message timing. */
61
+ timing?: MessageTiming;
62
+ /** Per-tool timing; present on `user` messages that carry tool_result blocks. */
63
+ toolTimings?: ToolTiming[];
64
+ /**
65
+ * Epoch ms when the store persisted this message (server-side clock). A
66
+ * fallback / drift-calibration timestamp stamped on every persisted message;
67
+ * it never overwrites the executor-stamped per-message `timing`. For input
68
+ * messages (which carry no `timing`) this is their only time field.
69
+ */
70
+ persistedAtMs?: number;
71
+ }
72
+ /** Mixin giving every AgentMessage member the `eggExt` extension namespace. */
73
+ export interface AgentMessageExtensions {
74
+ eggExt?: EggExt;
75
+ }
76
+ export interface SDKSystemMessage extends AgentMessageExtensions {
32
77
  type: 'system';
33
78
  subtype: string;
34
79
  session_id?: string;
35
80
  [key: string]: unknown;
36
81
  }
37
- export interface SDKStreamEvent {
82
+ export interface SDKStreamEvent extends AgentMessageExtensions {
38
83
  type: 'stream_event';
39
84
  event: unknown;
40
85
  session_id?: string;
41
86
  [key: string]: unknown;
42
87
  }
43
- export interface SDKUserMessage {
88
+ export interface SDKUserMessage extends AgentMessageExtensions {
44
89
  type: 'user';
45
90
  message: unknown;
46
91
  [key: string]: unknown;
47
92
  }
48
- export interface SDKAssistantMessage {
93
+ export interface SDKAssistantMessage extends AgentMessageExtensions {
49
94
  type: 'assistant';
50
95
  message: unknown;
51
96
  [key: string]: unknown;
52
97
  }
53
- export interface SDKResultMessage {
98
+ export interface SDKResultMessage extends AgentMessageExtensions {
54
99
  type: 'result';
55
100
  subtype: string;
56
101
  usage?: {
@@ -62,7 +107,7 @@ export interface SDKResultMessage {
62
107
  };
63
108
  [key: string]: unknown;
64
109
  }
65
- export interface SDKGenericMessage {
110
+ export interface SDKGenericMessage extends AgentMessageExtensions {
66
111
  type: string;
67
112
  [key: string]: unknown;
68
113
  }
@@ -27,6 +27,12 @@ export interface RunObject {
27
27
  completedAt?: number | null;
28
28
  cancelledAt?: number | null;
29
29
  failedAt?: number | null;
30
+ startedAtMs?: number | null;
31
+ completedAtMs?: number | null;
32
+ /** completedAtMs - startedAtMs (end-to-end run wall time in ms). */
33
+ durationMs?: number | null;
34
+ /** Sum of result.duration_api_ms across the run (pure model API time in ms). */
35
+ apiDurationMs?: number | null;
30
36
  usage?: {
31
37
  promptTokens: number;
32
38
  completionTokens: number;
@@ -62,6 +62,12 @@ export interface RunRecord {
62
62
  completedAt?: number | null;
63
63
  cancelledAt?: number | null;
64
64
  failedAt?: number | null;
65
+ startedAtMs?: number | null;
66
+ completedAtMs?: number | null;
67
+ /** completedAtMs - startedAtMs (end-to-end run wall time in ms). */
68
+ durationMs?: number | null;
69
+ /** Sum of result.duration_api_ms across the run (pure model API time in ms). */
70
+ apiDurationMs?: number | null;
65
71
  }
66
72
  export interface AgentStore {
67
73
  init?(): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eggjs/tegg-types",
3
- "version": "3.83.0",
3
+ "version": "3.84.1",
4
4
  "description": "tegg types",
5
5
  "keywords": [
6
6
  "egg",
@@ -45,5 +45,5 @@
45
45
  "ts-node": "^10.9.1",
46
46
  "typescript": "^5.0.4"
47
47
  },
48
- "gitHead": "a027c9c8b0a0308f47b678959aae0ae2bfdb183c"
48
+ "gitHead": "d68d6ad57bca6bab0ebdcc8dae6769d168499220"
49
49
  }