react-semaphor 0.1.578 → 0.1.580
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/dist/assistant-context/index.js +1 -1
- package/dist/assistant-protocol/index.js +75 -70
- package/dist/briefings/index.js +1 -1
- package/dist/chunks/add-to-dashboard-DhP8wVtM.js +291 -0
- package/dist/chunks/{assistant-chat-B_tmsxEK.js → assistant-chat-CUwGURJj.js} +2261 -2184
- package/dist/chunks/{bookmark-impact-DUWw3wlA.js → bookmark-impact-BNyR-yDX.js} +1 -1
- package/dist/chunks/{card-filter-builder-CwnMUZU2.js → card-filter-builder-k9yqDSw8.js} +168 -180
- package/dist/chunks/{comparison-window-caption-PtcDWvkN.js → comparison-window-caption-DdLqMgiG.js} +180 -183
- package/dist/chunks/{context-R31TSL5V.js → context-BTLBjQNh.js} +99 -83
- package/dist/chunks/{dashboard-BcIIBCTP.js → dashboard-DvcAk8uJ.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-BBpECqg2.js → dashboard-briefing-launcher-DBgS97ZH.js} +155 -155
- package/dist/chunks/{dashboard-controls-CONzvjmO.js → dashboard-controls-BiZ1rlNC.js} +7 -7
- package/dist/chunks/{dashboard-json-BF2chEVd.js → dashboard-json-B25xzYcJ.js} +1 -1
- package/dist/chunks/{dates-DlYMDaF2.js → dates-3Pah03_l.js} +5 -5
- package/dist/chunks/{edit-dashboard-visual-Bf-RcbuD.js → edit-dashboard-visual-DYuO3mEU.js} +9 -10
- package/dist/chunks/{filter-reach-copy-BTAXnbwQ.js → filter-reach-copy-CzLt96tq.js} +125 -125
- package/dist/chunks/{index-8BxDk8EP.js → index-BMZq6JT6.js} +2 -2
- package/dist/chunks/{report-preferences-dialog-RN4g9PEN.js → report-preferences-dialog-DpAetrdY.js} +7 -7
- package/dist/chunks/{resolve-dashboard-input-context-DBFuNhZo.js → resolve-dashboard-input-context-CNxtkCzj.js} +6266 -6191
- package/dist/chunks/{saved-dashboard-context-AChHk4tw.js → saved-dashboard-context-Bnt0H7mi.js} +3 -3
- package/dist/chunks/{semaphor-ready-indicator-DtivanBy.js → semaphor-ready-indicator-Dwmvmf0S.js} +15010 -14990
- package/dist/chunks/{shelf-drop-preview-context-BTjYxbHC.js → shelf-drop-preview-context-CiveteBS.js} +2 -2
- package/dist/chunks/{stored-dashboard-rpLzf4mk.js → stored-dashboard-D3gu-D7A.js} +67 -67
- package/dist/chunks/{table-export-sheet-CP8zSOhj.js → table-export-sheet-BNGSJA2N.js} +1 -1
- package/dist/chunks/{variable-draft-DPSMDwqt.js → variable-draft-C3_RL2gI.js} +2 -2
- package/dist/dashboard/index.js +1 -1
- package/dist/dashboard-authoring/index.js +357 -350
- package/dist/format-utils/index.js +4 -4
- package/dist/index.js +12 -12
- package/dist/style.css +1 -1
- package/dist/surfboard/index.js +1 -1
- package/dist/types/shared/assistant-protocol/answer-text.d.ts +5 -1
- package/dist/types/shared/assistant-protocol/context.d.ts +2 -1
- package/dist/types/shared/assistant-protocol/model-change.d.ts +23 -3
- package/dist/types/shared/assistant-protocol/parts.d.ts +12 -2
- package/dist/types/shared/dashboard-authoring/changes/aggregates.d.ts +2 -0
- package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +9 -58
- package/dist/types/shared/dashboard-authoring/changes/domain-change.d.ts +1738 -0
- package/dist/types/shared/dashboard-authoring/index.d.ts +1 -0
- package/dist/types/shared/usage-events/catalog.d.ts +5 -3
- package/dist/types/shared/usage-events/details.d.ts +66 -0
- package/dist/types/shared/usage-events/envelope.d.ts +5 -5
- package/dist/usage-events/index.js +154 -115
- package/package.json +1 -1
- package/dist/chunks/add-to-dashboard-B6Ah8Lub.js +0 -267
|
@@ -43,6 +43,7 @@ export * from './changes/diagnostics.js';
|
|
|
43
43
|
export * from './changes/card-query-part.js';
|
|
44
44
|
export * from './changes/read-card-query.js';
|
|
45
45
|
export * from './changes/dashboard-change.js';
|
|
46
|
+
export * from './changes/domain-change.js';
|
|
46
47
|
export { resolveDashboardChanges, type CardSource, type ChangeServices, type ChangeRef, type ChangeResolution, } from './changes/resolve-dashboard-changes.js';
|
|
47
48
|
export * from './changes/resolve-dashboard-create.js';
|
|
48
49
|
export * from './text-card-words/index.js';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { AutomationRunCompletedDetails, DashboardOpenedDetails, ExportCompletedDetails, QueryExecutedDetails, TokenIssuedDetails, ToolCalledDetails } from './details.js';
|
|
2
|
+
import { AssistantTurnCompletedDetails, AutomationRunCompletedDetails, DashboardOpenedDetails, ExportCompletedDetails, QueryExecutedDetails, TokenIssuedDetails, ToolCalledDetails } from './details.js';
|
|
3
3
|
/**
|
|
4
4
|
* The usage events catalog (usage-events TECH-SPEC §2.1): every event type,
|
|
5
5
|
* its category, version, producer and details schema, and the vocabulary the
|
|
6
6
|
* envelope and query tags share. A type lands with its producer: Phase 1 adds
|
|
7
|
-
* `token_issued`, Phase 2 the server events, Phase 6 exports and automation runs
|
|
7
|
+
* `token_issued`, Phase 2 the server events, Phase 6 exports and automation runs,
|
|
8
|
+
* Phase A the built-in assistant's questions.
|
|
8
9
|
*/
|
|
9
|
-
export declare const USAGE_EVENT_TYPES: readonly ["token_issued", "dashboard_opened", "query_executed", "tool_called", "export_completed", "automation_run_completed"];
|
|
10
|
+
export declare const USAGE_EVENT_TYPES: readonly ["token_issued", "dashboard_opened", "query_executed", "tool_called", "export_completed", "automation_run_completed", "assistant_turn_completed"];
|
|
10
11
|
export type UsageEventType = (typeof USAGE_EVENT_TYPES)[number];
|
|
11
12
|
export declare const USAGE_EVENT_CATEGORIES: readonly ["usage", "runtime", "agent", "delivery"];
|
|
12
13
|
export type UsageEventCategory = (typeof USAGE_EVENT_CATEGORIES)[number];
|
|
@@ -25,6 +26,7 @@ export type UsageEventDetailsByType = {
|
|
|
25
26
|
tool_called: ToolCalledDetails;
|
|
26
27
|
export_completed: ExportCompletedDetails;
|
|
27
28
|
automation_run_completed: AutomationRunCompletedDetails;
|
|
29
|
+
assistant_turn_completed: AssistantTurnCompletedDetails;
|
|
28
30
|
};
|
|
29
31
|
export type UsageEventCatalogEntry<T extends UsageEventType> = {
|
|
30
32
|
category: UsageEventCategory;
|
|
@@ -212,6 +212,8 @@ export declare const queryExecutedDetailsSchema: z.ZodObject<{
|
|
|
212
212
|
export_job_id?: string | undefined;
|
|
213
213
|
}>;
|
|
214
214
|
export type QueryExecutedDetails = z.infer<typeof queryExecutedDetailsSchema>;
|
|
215
|
+
export declare const TOOL_CALL_ORIGINS: readonly ["assistant", "mcp"];
|
|
216
|
+
export type ToolCallOrigin = (typeof TOOL_CALL_ORIGINS)[number];
|
|
215
217
|
export declare const toolCalledDetailsSchema: z.ZodObject<{
|
|
216
218
|
tool: z.ZodString;
|
|
217
219
|
args_json: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
@@ -223,7 +225,10 @@ export declare const toolCalledDetailsSchema: z.ZodObject<{
|
|
|
223
225
|
access_mode: z.ZodOptional<z.ZodString>;
|
|
224
226
|
scopes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
225
227
|
response_bytes: z.ZodOptional<z.ZodNumber>;
|
|
228
|
+
/** Who called: the built-in assistant or an MCP client (Phase A, AL-D46). */
|
|
229
|
+
origin: z.ZodEnum<["assistant", "mcp"]>;
|
|
226
230
|
}, "strict", z.ZodTypeAny, {
|
|
231
|
+
origin: "assistant" | "mcp";
|
|
227
232
|
tool: string;
|
|
228
233
|
arg_keys: string[];
|
|
229
234
|
args_json?: string | undefined;
|
|
@@ -235,6 +240,7 @@ export declare const toolCalledDetailsSchema: z.ZodObject<{
|
|
|
235
240
|
scopes?: string[] | undefined;
|
|
236
241
|
response_bytes?: number | undefined;
|
|
237
242
|
}, {
|
|
243
|
+
origin: "assistant" | "mcp";
|
|
238
244
|
tool: string;
|
|
239
245
|
arg_keys: string[];
|
|
240
246
|
args_json?: string | undefined;
|
|
@@ -310,3 +316,63 @@ export declare const automationRunCompletedDetailsSchema: z.ZodObject<{
|
|
|
310
316
|
scheduled_for?: string | undefined;
|
|
311
317
|
}>;
|
|
312
318
|
export type AutomationRunCompletedDetails = z.infer<typeof automationRunCompletedDetailsSchema>;
|
|
319
|
+
/** How a turn that emits ended: the assistant's own words (a running or interrupted turn never emits). */
|
|
320
|
+
export declare const ASSISTANT_TURN_ENDINGS: readonly ["completed", "refused", "stopped", "failed"];
|
|
321
|
+
/** One question to the built-in assistant (Phase A, AL-D45): never the answer, the context or a result. */
|
|
322
|
+
export declare const assistantTurnCompletedDetailsSchema: z.ZodObject<{
|
|
323
|
+
/** Absent only when the request was refused before it could be read (no turn id was sent). */
|
|
324
|
+
turn_id: z.ZodOptional<z.ZodString>;
|
|
325
|
+
conversation_id: z.ZodOptional<z.ZodString>;
|
|
326
|
+
question_text: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
327
|
+
question_truncated: z.ZodOptional<z.ZodBoolean>;
|
|
328
|
+
turn_outcome: z.ZodEnum<["completed", "refused", "stopped", "failed"]>;
|
|
329
|
+
refusal: z.ZodOptional<z.ZodEnum<["assistant_unavailable", "context_invalid", "context_too_large", "conversation_not_found", "conversation_full", "turn_in_progress", "daily_limit_reached", "budget_exhausted", "not_permitted", "no_data_found", "model_unavailable"]>>;
|
|
330
|
+
context_surface: z.ZodEnum<["dashboard", "editor", "none"]>;
|
|
331
|
+
model: z.ZodString;
|
|
332
|
+
instructions_version: z.ZodString;
|
|
333
|
+
input_tokens: z.ZodNumber;
|
|
334
|
+
cached_input_tokens: z.ZodNumber;
|
|
335
|
+
output_tokens: z.ZodNumber;
|
|
336
|
+
tools: z.ZodArray<z.ZodString, "many">;
|
|
337
|
+
tool_call_count: z.ZodNumber;
|
|
338
|
+
tool_error_count: z.ZodNumber;
|
|
339
|
+
asked_user: z.ZodOptional<z.ZodBoolean>;
|
|
340
|
+
finish_reason: z.ZodOptional<z.ZodString>;
|
|
341
|
+
}, "strict", z.ZodTypeAny, {
|
|
342
|
+
model: string;
|
|
343
|
+
tools: string[];
|
|
344
|
+
turn_outcome: "failed" | "refused" | "completed" | "stopped";
|
|
345
|
+
context_surface: "none" | "dashboard" | "editor";
|
|
346
|
+
instructions_version: string;
|
|
347
|
+
input_tokens: number;
|
|
348
|
+
cached_input_tokens: number;
|
|
349
|
+
output_tokens: number;
|
|
350
|
+
tool_call_count: number;
|
|
351
|
+
tool_error_count: number;
|
|
352
|
+
refusal?: "not_permitted" | "context_too_large" | "assistant_unavailable" | "context_invalid" | "conversation_not_found" | "conversation_full" | "turn_in_progress" | "daily_limit_reached" | "budget_exhausted" | "no_data_found" | "model_unavailable" | undefined;
|
|
353
|
+
turn_id?: string | undefined;
|
|
354
|
+
conversation_id?: string | undefined;
|
|
355
|
+
question_text?: string | undefined;
|
|
356
|
+
question_truncated?: boolean | undefined;
|
|
357
|
+
asked_user?: boolean | undefined;
|
|
358
|
+
finish_reason?: string | undefined;
|
|
359
|
+
}, {
|
|
360
|
+
model: string;
|
|
361
|
+
tools: string[];
|
|
362
|
+
turn_outcome: "failed" | "refused" | "completed" | "stopped";
|
|
363
|
+
context_surface: "none" | "dashboard" | "editor";
|
|
364
|
+
instructions_version: string;
|
|
365
|
+
input_tokens: number;
|
|
366
|
+
cached_input_tokens: number;
|
|
367
|
+
output_tokens: number;
|
|
368
|
+
tool_call_count: number;
|
|
369
|
+
tool_error_count: number;
|
|
370
|
+
refusal?: "not_permitted" | "context_too_large" | "assistant_unavailable" | "context_invalid" | "conversation_not_found" | "conversation_full" | "turn_in_progress" | "daily_limit_reached" | "budget_exhausted" | "no_data_found" | "model_unavailable" | undefined;
|
|
371
|
+
turn_id?: string | undefined;
|
|
372
|
+
conversation_id?: string | undefined;
|
|
373
|
+
question_text?: string | undefined;
|
|
374
|
+
question_truncated?: boolean | undefined;
|
|
375
|
+
asked_user?: boolean | undefined;
|
|
376
|
+
finish_reason?: string | undefined;
|
|
377
|
+
}>;
|
|
378
|
+
export type AssistantTurnCompletedDetails = z.infer<typeof assistantTurnCompletedDetailsSchema>;
|
|
@@ -52,7 +52,7 @@ export type UsageEvent<T extends UsageEventType = UsageEventType> = {
|
|
|
52
52
|
export declare const USAGE_EVENT_TEXT_MAX_BYTES: number;
|
|
53
53
|
export declare const usageEventEnvelopeSchema: z.ZodObject<{
|
|
54
54
|
event_id: z.ZodString;
|
|
55
|
-
event_type: z.ZodEnum<["token_issued", "dashboard_opened", "query_executed", "tool_called", "export_completed", "automation_run_completed"]>;
|
|
55
|
+
event_type: z.ZodEnum<["token_issued", "dashboard_opened", "query_executed", "tool_called", "export_completed", "automation_run_completed", "assistant_turn_completed"]>;
|
|
56
56
|
event_version: z.ZodNumber;
|
|
57
57
|
category: z.ZodEnum<["usage", "runtime", "agent", "delivery"]>;
|
|
58
58
|
occurred_at: z.ZodString;
|
|
@@ -90,7 +90,7 @@ export declare const usageEventEnvelopeSchema: z.ZodObject<{
|
|
|
90
90
|
code: string;
|
|
91
91
|
message: string;
|
|
92
92
|
} | null;
|
|
93
|
-
surface: "api" | "embed" | "console" | "
|
|
93
|
+
surface: "api" | "embed" | "console" | "mcp" | "public_link" | "scheduler" | "pdf_renderer";
|
|
94
94
|
category: "usage" | "runtime" | "delivery" | "agent";
|
|
95
95
|
connection_id: string | null;
|
|
96
96
|
card_id: string | null;
|
|
@@ -101,7 +101,7 @@ export declare const usageEventEnvelopeSchema: z.ZodObject<{
|
|
|
101
101
|
dashboard_id: string | null;
|
|
102
102
|
duration_ms: number | null;
|
|
103
103
|
event_id: string;
|
|
104
|
-
event_type: "token_issued" | "dashboard_opened" | "query_executed" | "tool_called" | "export_completed" | "automation_run_completed";
|
|
104
|
+
event_type: "token_issued" | "dashboard_opened" | "query_executed" | "tool_called" | "export_completed" | "automation_run_completed" | "assistant_turn_completed";
|
|
105
105
|
event_version: number;
|
|
106
106
|
occurred_at: string;
|
|
107
107
|
producer: "scheduler" | "app";
|
|
@@ -119,7 +119,7 @@ export declare const usageEventEnvelopeSchema: z.ZodObject<{
|
|
|
119
119
|
code: string;
|
|
120
120
|
message: string;
|
|
121
121
|
} | null;
|
|
122
|
-
surface: "api" | "embed" | "console" | "
|
|
122
|
+
surface: "api" | "embed" | "console" | "mcp" | "public_link" | "scheduler" | "pdf_renderer";
|
|
123
123
|
category: "usage" | "runtime" | "delivery" | "agent";
|
|
124
124
|
connection_id: string | null;
|
|
125
125
|
card_id: string | null;
|
|
@@ -130,7 +130,7 @@ export declare const usageEventEnvelopeSchema: z.ZodObject<{
|
|
|
130
130
|
dashboard_id: string | null;
|
|
131
131
|
duration_ms: number | null;
|
|
132
132
|
event_id: string;
|
|
133
|
-
event_type: "token_issued" | "dashboard_opened" | "query_executed" | "tool_called" | "export_completed" | "automation_run_completed";
|
|
133
|
+
event_type: "token_issued" | "dashboard_opened" | "query_executed" | "tool_called" | "export_completed" | "automation_run_completed" | "assistant_turn_completed";
|
|
134
134
|
event_version: number;
|
|
135
135
|
occurred_at: string;
|
|
136
136
|
producer: "scheduler" | "app";
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { z as e } from "zod";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { g as h, l as S } from "../chunks/context-BTLBjQNh.js";
|
|
3
|
+
import { Q as b, a as y, b as x } from "../chunks/attribution-BvoKvhcj.js";
|
|
4
|
+
import { U as te, c as ne, u as ae } from "../chunks/attribution-BvoKvhcj.js";
|
|
5
|
+
const r = e.string().min(1).max(128), t = e.string().max(500), m = e.array(e.string().max(500)).max(500), n = e.number().int().nonnegative(), p = e.string().refine((o) => new TextEncoder().encode(o).length <= 16 * 1024), f = e.object({
|
|
5
6
|
token_type: e.enum(["dashboard", "project"]),
|
|
6
7
|
token_purpose: e.enum(["embed", "console"]).optional(),
|
|
7
8
|
ttl_s: e.number().int().nonnegative().optional(),
|
|
8
9
|
embed_origin: e.string().max(2048).optional(),
|
|
9
|
-
initial_dashboard_id:
|
|
10
|
+
initial_dashboard_id: r.optional(),
|
|
10
11
|
dashboard_title: t.optional(),
|
|
11
12
|
project_name: t.optional(),
|
|
12
13
|
user_verified: e.boolean(),
|
|
@@ -16,34 +17,34 @@ const i = e.string().min(1).max(128), t = e.string().max(500), p = e.array(e.str
|
|
|
16
17
|
role: e.string().max(128).optional(),
|
|
17
18
|
user_provisioned: e.boolean().optional(),
|
|
18
19
|
domain_access_mode: e.enum(["all", "none", "include", "exclude"]).optional(),
|
|
19
|
-
domain_ids: e.array(
|
|
20
|
-
rls_policy_names:
|
|
21
|
-
cls_policy_names:
|
|
20
|
+
domain_ids: e.array(r).max(500).optional(),
|
|
21
|
+
rls_policy_names: m.optional(),
|
|
22
|
+
cls_policy_names: m.optional(),
|
|
22
23
|
has_sls: e.boolean().optional(),
|
|
23
|
-
security_param_keys:
|
|
24
|
+
security_param_keys: m.optional(),
|
|
24
25
|
timezone: e.string().max(128).optional(),
|
|
25
26
|
mcp_scopes: e.array(e.string().max(128)).max(64).optional(),
|
|
26
27
|
mcp_sql: e.boolean().optional(),
|
|
27
28
|
mcp_live: e.boolean().optional()
|
|
28
|
-
}).strict(),
|
|
29
|
+
}).strict(), E = e.object({
|
|
29
30
|
requested_version: e.number().int().optional(),
|
|
30
31
|
served: e.enum(["current", "version"]).optional(),
|
|
31
32
|
dashboard_title: t.optional(),
|
|
32
33
|
project_name: t.optional(),
|
|
33
|
-
sheet_count:
|
|
34
|
-
card_count:
|
|
35
|
-
}).strict(),
|
|
36
|
-
statement: e.enum(
|
|
34
|
+
sheet_count: n.optional(),
|
|
35
|
+
card_count: n.optional()
|
|
36
|
+
}).strict(), T = e.object({
|
|
37
|
+
statement: e.enum(b),
|
|
37
38
|
duration_ms: e.number().nonnegative(),
|
|
38
39
|
outcome: e.enum(["succeeded", "failed", "cancelled"]),
|
|
39
|
-
rows:
|
|
40
|
-
}).strict(),
|
|
41
|
-
data_service_calls:
|
|
42
|
-
query_run_id:
|
|
43
|
-
parent_query_run_id:
|
|
44
|
-
query_kind: e.enum(
|
|
45
|
-
statements: e.array(
|
|
46
|
-
trigger: e.enum(
|
|
40
|
+
rows: n.optional()
|
|
41
|
+
}).strict(), v = e.object({
|
|
42
|
+
data_service_calls: n,
|
|
43
|
+
query_run_id: r,
|
|
44
|
+
parent_query_run_id: r.optional(),
|
|
45
|
+
query_kind: e.enum(x).optional(),
|
|
46
|
+
statements: e.array(T).max(64),
|
|
47
|
+
trigger: e.enum(y).optional(),
|
|
47
48
|
card_title: t.optional(),
|
|
48
49
|
card_type: e.string().max(128).optional(),
|
|
49
50
|
dashboard_title: t.optional(),
|
|
@@ -53,17 +54,17 @@ const i = e.string().min(1).max(128), t = e.string().max(500), p = e.array(e.str
|
|
|
53
54
|
connection_type: e.string().max(128).optional(),
|
|
54
55
|
dialect: e.string().max(128).optional(),
|
|
55
56
|
dataset: t.optional(),
|
|
56
|
-
rows:
|
|
57
|
+
rows: n.optional(),
|
|
57
58
|
row_limit_exceeded: e.boolean().optional(),
|
|
58
|
-
sql_text:
|
|
59
|
+
sql_text: p.optional(),
|
|
59
60
|
sql_truncated: e.boolean().optional(),
|
|
60
61
|
sql_hash: e.string().regex(/^[0-9a-f]{64}$/).optional(),
|
|
61
|
-
input_ids_applied: e.array(
|
|
62
|
+
input_ids_applied: e.array(r).max(500).optional(),
|
|
62
63
|
page: e.number().int().positive().optional(),
|
|
63
|
-
export_job_id:
|
|
64
|
-
}).strict(),
|
|
64
|
+
export_job_id: r.optional()
|
|
65
|
+
}).strict(), A = ["assistant", "mcp"], q = e.object({
|
|
65
66
|
tool: e.string().min(1).max(128),
|
|
66
|
-
args_json:
|
|
67
|
+
args_json: p.optional(),
|
|
67
68
|
args_truncated: e.boolean().optional(),
|
|
68
69
|
arg_keys: e.array(e.string().max(128)).max(200),
|
|
69
70
|
user_agent: e.string().max(1024).optional(),
|
|
@@ -71,45 +72,67 @@ const i = e.string().min(1).max(128), t = e.string().max(500), p = e.array(e.str
|
|
|
71
72
|
credential: e.string().max(64).optional(),
|
|
72
73
|
access_mode: e.string().max(64).optional(),
|
|
73
74
|
scopes: e.array(e.string().max(128)).max(64).optional(),
|
|
74
|
-
response_bytes:
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
75
|
+
response_bytes: n.optional(),
|
|
76
|
+
/** Who called: the built-in assistant or an MCP client (Phase A, AL-D46). */
|
|
77
|
+
origin: e.enum(A)
|
|
78
|
+
}).strict(), U = ["job", "matrix_direct", "rendered"], R = ["csv", "xlsx", "pdf", "png"], O = ["visual", "card", "dashboard"], k = ["create", "acquire", "deadline", "render"], I = e.object({
|
|
79
|
+
export_id: r.optional(),
|
|
80
|
+
mechanism: e.enum(U),
|
|
81
|
+
format: e.enum(R),
|
|
82
|
+
scope: e.enum(O).optional(),
|
|
83
|
+
rows: n.optional(),
|
|
84
|
+
bytes: n.optional(),
|
|
85
|
+
chunks: n.optional(),
|
|
86
|
+
stage: e.enum(k).optional()
|
|
87
|
+
}).strict(), N = ["export", "briefing", "cache_refresh"], j = ["scheduled", "manual", "api"], D = e.object({
|
|
88
|
+
run_id: r,
|
|
89
|
+
rule_id: r,
|
|
87
90
|
rule_name: t.optional(),
|
|
88
|
-
kind: e.enum(
|
|
91
|
+
kind: e.enum(N),
|
|
89
92
|
trigger_source: e.enum(j).optional(),
|
|
90
|
-
attempt:
|
|
93
|
+
attempt: n.optional(),
|
|
91
94
|
scheduled_for: e.string().datetime({ offset: !0 }).optional()
|
|
92
|
-
}).strict(), G = [
|
|
95
|
+
}).strict(), G = ["completed", "refused", "stopped", "failed"], C = e.object({
|
|
96
|
+
/** Absent only when the request was refused before it could be read (no turn id was sent). */
|
|
97
|
+
turn_id: r.optional(),
|
|
98
|
+
conversation_id: r.optional(),
|
|
99
|
+
question_text: p.optional(),
|
|
100
|
+
question_truncated: e.boolean().optional(),
|
|
101
|
+
turn_outcome: e.enum(G),
|
|
102
|
+
refusal: e.enum(S).optional(),
|
|
103
|
+
context_surface: e.enum(h),
|
|
104
|
+
model: e.string().min(1).max(128),
|
|
105
|
+
instructions_version: e.string().min(1).max(128),
|
|
106
|
+
input_tokens: n,
|
|
107
|
+
cached_input_tokens: n,
|
|
108
|
+
output_tokens: n,
|
|
109
|
+
tools: e.array(e.string().min(1).max(128)).max(500),
|
|
110
|
+
tool_call_count: n,
|
|
111
|
+
tool_error_count: n,
|
|
112
|
+
asked_user: e.boolean().optional(),
|
|
113
|
+
finish_reason: e.string().max(64).optional()
|
|
114
|
+
}).strict(), B = [
|
|
93
115
|
"token_issued",
|
|
94
116
|
"dashboard_opened",
|
|
95
117
|
"query_executed",
|
|
96
118
|
"tool_called",
|
|
97
119
|
"export_completed",
|
|
98
|
-
"automation_run_completed"
|
|
99
|
-
|
|
120
|
+
"automation_run_completed",
|
|
121
|
+
"assistant_turn_completed"
|
|
122
|
+
], M = ["usage", "runtime", "agent", "delivery"], P = ["org_user", "tenant_user", "tenant", "api_key", "system", "anonymous"], w = ["console", "embed", "public_link", "mcp", "api", "scheduler", "pdf_renderer"], L = ["succeeded", "failed", "cancelled", "timed_out"], X = ["app", "scheduler"], Y = {
|
|
100
123
|
token_issued: {
|
|
101
124
|
category: "usage",
|
|
102
125
|
version: 1,
|
|
103
126
|
emittedBy: "semaphor-app/src/lib/usage-events/token-issued.ts",
|
|
104
127
|
personalData: !0,
|
|
105
|
-
detailsSchema:
|
|
128
|
+
detailsSchema: f
|
|
106
129
|
},
|
|
107
130
|
dashboard_opened: {
|
|
108
131
|
category: "usage",
|
|
109
132
|
version: 1,
|
|
110
133
|
emittedBy: "semaphor-app/src/lib/usage-events/dashboard-opened.ts",
|
|
111
134
|
personalData: !1,
|
|
112
|
-
detailsSchema:
|
|
135
|
+
detailsSchema: E
|
|
113
136
|
},
|
|
114
137
|
query_executed: {
|
|
115
138
|
category: "runtime",
|
|
@@ -117,7 +140,7 @@ const i = e.string().min(1).max(128), t = e.string().max(500), p = e.array(e.str
|
|
|
117
140
|
emittedBy: "semaphor-app/src/app/api/v1/query/query-run.ts",
|
|
118
141
|
// sql_text holds the filter and control values the app compiled in.
|
|
119
142
|
personalData: !0,
|
|
120
|
-
detailsSchema:
|
|
143
|
+
detailsSchema: v
|
|
121
144
|
},
|
|
122
145
|
tool_called: {
|
|
123
146
|
category: "agent",
|
|
@@ -125,14 +148,14 @@ const i = e.string().min(1).max(128), t = e.string().max(500), p = e.array(e.str
|
|
|
125
148
|
emittedBy: "semaphor-app/src/lib/mcp/tool-telemetry.ts",
|
|
126
149
|
// args_json is what the agent sent.
|
|
127
150
|
personalData: !0,
|
|
128
|
-
detailsSchema:
|
|
151
|
+
detailsSchema: q
|
|
129
152
|
},
|
|
130
153
|
export_completed: {
|
|
131
154
|
category: "delivery",
|
|
132
155
|
version: 1,
|
|
133
156
|
emittedBy: "semaphor-app/src/lib/usage-events/export-completed.ts",
|
|
134
157
|
personalData: !1,
|
|
135
|
-
detailsSchema:
|
|
158
|
+
detailsSchema: I
|
|
136
159
|
},
|
|
137
160
|
automation_run_completed: {
|
|
138
161
|
category: "delivery",
|
|
@@ -140,52 +163,60 @@ const i = e.string().min(1).max(128), t = e.string().max(500), p = e.array(e.str
|
|
|
140
163
|
emittedBy: "semaphor-app/src/lib/usage-events/automation-run-completed.ts",
|
|
141
164
|
// rule_name is what its author typed; error.message is the run's own error text.
|
|
142
165
|
personalData: !0,
|
|
143
|
-
detailsSchema:
|
|
166
|
+
detailsSchema: D
|
|
167
|
+
},
|
|
168
|
+
assistant_turn_completed: {
|
|
169
|
+
category: "agent",
|
|
170
|
+
version: 1,
|
|
171
|
+
emittedBy: "semaphor-app/src/lib/usage-events/assistant-turn-completed.ts",
|
|
172
|
+
// question_text is what the person typed (AL-D45).
|
|
173
|
+
personalData: !0,
|
|
174
|
+
detailsSchema: C
|
|
144
175
|
}
|
|
145
|
-
},
|
|
146
|
-
event_id: e.string().regex(
|
|
147
|
-
event_type: e.enum(
|
|
176
|
+
}, $ = 16 * 1024, F = /^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/, V = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{1,9})?Z$/, Q = e.string().min(1).max(128), i = Q.nullable(), H = e.object({
|
|
177
|
+
event_id: e.string().regex(F),
|
|
178
|
+
event_type: e.enum(B),
|
|
148
179
|
event_version: e.number().int().positive(),
|
|
149
|
-
category: e.enum(
|
|
150
|
-
occurred_at: e.string().regex(
|
|
151
|
-
producer: e.enum(
|
|
180
|
+
category: e.enum(M),
|
|
181
|
+
occurred_at: e.string().regex(V),
|
|
182
|
+
producer: e.enum(X),
|
|
152
183
|
release: e.string().min(1).max(64),
|
|
153
|
-
org_id:
|
|
154
|
-
project_id:
|
|
155
|
-
tenant_id:
|
|
156
|
-
actor_type: e.enum(
|
|
157
|
-
org_user_id:
|
|
158
|
-
tenant_user_id:
|
|
159
|
-
surface: e.enum(
|
|
160
|
-
session_id:
|
|
161
|
-
operation_id:
|
|
162
|
-
dashboard_id:
|
|
163
|
-
sheet_id:
|
|
164
|
-
card_id:
|
|
165
|
-
connection_id:
|
|
166
|
-
domain_id:
|
|
167
|
-
outcome: e.enum(
|
|
184
|
+
org_id: i,
|
|
185
|
+
project_id: i,
|
|
186
|
+
tenant_id: i,
|
|
187
|
+
actor_type: e.enum(P),
|
|
188
|
+
org_user_id: i,
|
|
189
|
+
tenant_user_id: i,
|
|
190
|
+
surface: e.enum(w),
|
|
191
|
+
session_id: i,
|
|
192
|
+
operation_id: i,
|
|
193
|
+
dashboard_id: i,
|
|
194
|
+
sheet_id: i,
|
|
195
|
+
card_id: i,
|
|
196
|
+
connection_id: i,
|
|
197
|
+
domain_id: i,
|
|
198
|
+
outcome: e.enum(L).nullable(),
|
|
168
199
|
duration_ms: e.number().nonnegative().nullable(),
|
|
169
200
|
error: e.object({
|
|
170
201
|
code: e.string().min(1).max(128),
|
|
171
|
-
message: e.string().refine((o) => new TextEncoder().encode(o).length <=
|
|
202
|
+
message: e.string().refine((o) => new TextEncoder().encode(o).length <= $)
|
|
172
203
|
}).strict().nullable(),
|
|
173
204
|
details: e.unknown()
|
|
174
205
|
}).strict();
|
|
175
|
-
function
|
|
176
|
-
const
|
|
177
|
-
if (!
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
const
|
|
181
|
-
|
|
182
|
-
const
|
|
183
|
-
return
|
|
206
|
+
function W(o) {
|
|
207
|
+
const s = H.safeParse(o);
|
|
208
|
+
if (!s.success) return { ok: !1, issues: g(s.error.issues) };
|
|
209
|
+
const a = s.data, d = a.event_type, u = Y[d], l = [];
|
|
210
|
+
a.event_version !== u.version && l.push("event_version: not the catalog version"), a.category !== u.category && l.push("category: not the catalog category");
|
|
211
|
+
const _ = a.outcome === "failed" || a.outcome === "timed_out";
|
|
212
|
+
_ && a.error === null && l.push("error: required when the outcome is failed or timed_out"), !_ && a.error !== null && l.push("error: set only when the outcome is failed or timed_out"), l.push(...z[d](a));
|
|
213
|
+
const c = u.detailsSchema.safeParse(a.details);
|
|
214
|
+
return c.success || l.push(...g(c.error.issues, "details")), l.length > 0 ? { ok: !1, issues: l } : { ok: !0, event: { ...a, details: c.success ? c.data : a.details } };
|
|
184
215
|
}
|
|
185
|
-
const
|
|
216
|
+
const z = {
|
|
186
217
|
token_issued: (o) => {
|
|
187
|
-
const
|
|
188
|
-
return ["org_user", "tenant_user", "tenant", "anonymous"].includes(o.actor_type) ||
|
|
218
|
+
const s = [];
|
|
219
|
+
return ["org_user", "tenant_user", "tenant", "anonymous"].includes(o.actor_type) || s.push("actor_type: not a token_issued actor"), ["embed", "console", "mcp"].includes(o.surface) || s.push("surface: not a token_issued surface"), o.outcome === null && s.push("outcome: required"), o.outcome === "succeeded" && (o.session_id === null && s.push("session_id: required on success"), o.project_id === null && s.push("project_id: required on success")), s;
|
|
189
220
|
},
|
|
190
221
|
dashboard_opened: (o) => [
|
|
191
222
|
...o.outcome === null ? ["outcome: required"] : [],
|
|
@@ -208,39 +239,47 @@ const V = {
|
|
|
208
239
|
automation_run_completed: (o) => [
|
|
209
240
|
...o.outcome === null ? ["outcome: required"] : [],
|
|
210
241
|
...o.duration_ms === null ? ["duration_ms: required"] : []
|
|
242
|
+
],
|
|
243
|
+
assistant_turn_completed: (o) => [
|
|
244
|
+
...o.outcome === null ? ["outcome: required"] : [],
|
|
245
|
+
...o.duration_ms === null ? ["duration_ms: required"] : [],
|
|
246
|
+
...o.operation_id === null ? ["operation_id: required"] : []
|
|
211
247
|
]
|
|
212
248
|
};
|
|
213
|
-
function
|
|
214
|
-
return o.map((
|
|
249
|
+
function g(o, s) {
|
|
250
|
+
return o.map((a) => `${[s, ...a.path].filter((u) => u !== void 0).join(".") || "(root)"}: ${a.code}`);
|
|
215
251
|
}
|
|
216
252
|
export {
|
|
217
|
-
|
|
253
|
+
G as ASSISTANT_TURN_ENDINGS,
|
|
254
|
+
N as AUTOMATION_RUN_KINDS,
|
|
218
255
|
j as AUTOMATION_TRIGGER_SOURCES,
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
T as
|
|
244
|
-
|
|
245
|
-
|
|
256
|
+
R as EXPORT_FORMATS,
|
|
257
|
+
U as EXPORT_MECHANISMS,
|
|
258
|
+
O as EXPORT_SCOPES,
|
|
259
|
+
k as EXPORT_STAGES,
|
|
260
|
+
x as QUERY_KINDS,
|
|
261
|
+
b as QUERY_STATEMENTS,
|
|
262
|
+
y as QUERY_TRIGGERS,
|
|
263
|
+
A as TOOL_CALL_ORIGINS,
|
|
264
|
+
P as USAGE_ACTOR_TYPES,
|
|
265
|
+
te as USAGE_ATTRIBUTION_ID_MAX_LENGTH,
|
|
266
|
+
ne as USAGE_ATTRIBUTION_TITLE_MAX_LENGTH,
|
|
267
|
+
Y as USAGE_EVENT_CATALOG,
|
|
268
|
+
M as USAGE_EVENT_CATEGORIES,
|
|
269
|
+
$ as USAGE_EVENT_TEXT_MAX_BYTES,
|
|
270
|
+
B as USAGE_EVENT_TYPES,
|
|
271
|
+
L as USAGE_OUTCOMES,
|
|
272
|
+
X as USAGE_PRODUCERS,
|
|
273
|
+
w as USAGE_SURFACES,
|
|
274
|
+
C as assistantTurnCompletedDetailsSchema,
|
|
275
|
+
D as automationRunCompletedDetailsSchema,
|
|
276
|
+
E as dashboardOpenedDetailsSchema,
|
|
277
|
+
I as exportCompletedDetailsSchema,
|
|
278
|
+
W as parseUsageEvent,
|
|
279
|
+
v as queryExecutedDetailsSchema,
|
|
280
|
+
T as queryStatementRecordSchema,
|
|
281
|
+
f as tokenIssuedDetailsSchema,
|
|
282
|
+
q as toolCalledDetailsSchema,
|
|
283
|
+
ae as usageAttributionFieldsSchema,
|
|
284
|
+
H as usageEventEnvelopeSchema
|
|
246
285
|
};
|