react-semaphor 0.1.548 → 0.1.549

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.
Files changed (36) hide show
  1. package/dist/assistant-context/index.js +1 -1
  2. package/dist/briefings/index.js +1 -1
  3. package/dist/chunks/{assistant-chat-DCcWsoGm.js → assistant-chat-CUSvuESS.js} +1831 -1846
  4. package/dist/chunks/{custom-visual-inputs-BTRnwsfd.js → custom-visual-inputs-CwAcigQS.js} +1 -1
  5. package/dist/chunks/{dashboard-BZHL9a-z.js → dashboard-Cm7WkARH.js} +1 -1
  6. package/dist/chunks/{dashboard-briefing-launcher-DML-cAzB.js → dashboard-briefing-launcher-X0HzNpS8.js} +627 -629
  7. package/dist/chunks/{dashboard-controls-BGoBTPS7.js → dashboard-controls-BuX6TMNK.js} +219 -219
  8. package/dist/chunks/{dashboard-json-iHPsdn3j.js → dashboard-json-Cc4u2xvy.js} +1 -1
  9. package/dist/chunks/{document-dashboard-inputs-B2AqPfrq.js → document-dashboard-inputs-DPQ_wUGD.js} +2 -2
  10. package/dist/chunks/{edit-dashboard-visual-CLEFFf2T.js → edit-dashboard-visual-DX2CzibK.js} +606 -606
  11. package/dist/chunks/{filter-reach-copy-ByzGadUk.js → filter-reach-copy-Bc-Gei83.js} +3 -3
  12. package/dist/chunks/{global-date-filter-utils-CeeFJ1CP.js → global-date-filter-utils-CnumW4j2.js} +1656 -1651
  13. package/dist/chunks/{index-DeDHr3iz.js → index-DzsdV1o4.js} +3 -3
  14. package/dist/chunks/{raw-temporal-presentation-CrUM2I_o.js → raw-temporal-presentation-CBKeEPYA.js} +1 -1
  15. package/dist/chunks/report-preferences-dialog-B9oYQ6OJ.js +2180 -0
  16. package/dist/chunks/{resolve-dashboard-input-context-BmWF9hSl.js → resolve-dashboard-input-context-DVWF7p5C.js} +1 -1
  17. package/dist/chunks/{saved-dashboard-context-qtfzl9Eb.js → saved-dashboard-context-BMqMzNAo.js} +4 -4
  18. package/dist/chunks/{semaphor-ready-indicator-Ol6VcaR7.js → semaphor-ready-indicator-wWkPH4ue.js} +11743 -11720
  19. package/dist/chunks/{shelf-drop-preview-context-C2SEC3I9.js → shelf-drop-preview-context-B86d8IZO.js} +3 -3
  20. package/dist/chunks/{use-create-flow-overlay-state-CbGIjaVD.js → use-create-flow-overlay-state-DPNjYyi3.js} +2 -2
  21. package/dist/dashboard/index.js +1 -1
  22. package/dist/dashboard-authoring/index.js +7 -7
  23. package/dist/index.js +12 -12
  24. package/dist/live-channel/index.js +124 -0
  25. package/dist/style.css +1 -1
  26. package/dist/surfboard/index.js +1 -1
  27. package/dist/types/components/surfboard/dashboard-plus.d.ts +1 -1
  28. package/dist/types/lib/stores/dashboard-store.d.ts +9 -0
  29. package/dist/types/lib/types/common-types.d.ts +26 -1
  30. package/dist/types/live-channel.d.ts +2 -0
  31. package/dist/types/shared/assistant-protocol/parts.d.ts +11 -0
  32. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +14 -44
  33. package/dist/types/shared/live-channel/index.d.ts +1 -0
  34. package/dist/types/shared/live-channel/live-channel-contract.d.ts +126 -0
  35. package/package.json +5 -1
  36. package/dist/chunks/report-preferences-dialog-CM7kXmXp.js +0 -1977
@@ -1,4 +1,4 @@
1
- import { a, R as s, D as o } from "../chunks/report-preferences-dialog-CM7kXmXp.js";
1
+ import { a, R as s, D as o } from "../chunks/report-preferences-dialog-B9oYQ6OJ.js";
2
2
  import { C as f, E as D } from "../chunks/table-settings-WysCBj62.js";
3
3
  export {
4
4
  f as CONTROL_CARD_DEFAULT_VALUE,
@@ -3,5 +3,5 @@ type DashboardPlusProps = {
3
3
  showControls?: boolean;
4
4
  showFooter?: boolean;
5
5
  } & DashboardProps;
6
- export declare function DashboardPlus({ showControls, showFooter, ...rest }: DashboardPlusProps): import("react").JSX.Element;
6
+ export declare function DashboardPlus({ showControls, showFooter, liveScreen, ...rest }: DashboardPlusProps): import("react").JSX.Element;
7
7
  export {};
@@ -154,6 +154,13 @@ export type DashboardStore = {
154
154
  * replacement of the document but a proposal's own Undo, clears them.
155
155
  */
156
156
  appliedProposals: AppliedProposal[];
157
+ /**
158
+ * Advances each time an edit session ends: leaving edit mode (Cancel,
159
+ * close) or a successful Save that stays in edit mode. Save keeps the
160
+ * dashboard object (P7-27), so identity alone can't mark it; a live screen
161
+ * drops every kept copy here (embedded live changes LC-D14).
162
+ */
163
+ editSessionEpoch: number;
157
164
  /** The last toolbar Arrange, for its Undo. Cleared by any dashboard load, leaving edit mode, or a successful undo (responsive layouts SPEC §6.4). */
158
165
  lastArrange?: LastArrange;
159
166
  isVisualEditing: boolean;
@@ -420,6 +427,8 @@ type Actions = {
420
427
  removeFrame: (sheetId: string, frameId: string) => void;
421
428
  removeCard: (sheetId: string, card: TCard) => void;
422
429
  setIsDashboardEditing: (editing: boolean) => void;
430
+ /** The toolbar's Save succeeded: the edit session's changes are saved (LC-D14). */
431
+ markDashboardSaved: () => void;
423
432
  /**
424
433
  * Applies an assistant proposal to the dashboard on screen (spec 8.1,
425
434
  * D7-18, D7-27): only while the dashboard is still `basedOn`, checked and
@@ -15,6 +15,7 @@ import { DashboardAIContext } from './ai-context-types.js';
15
15
  import { CardInteractionConfig, InteractionTargetOverride } from './interaction-types.js';
16
16
  import { SemanticExecutionPayload } from './semantic-runtime-types.js';
17
17
  import { ReportRuntimeContext } from '../../shared/report-runtime-context/index.js';
18
+ import { LiveScreenPort } from '../../shared/live-channel/index.js';
18
19
  import { CsvEncoding } from '../../shared/format-utils/exporters/csv-utils.js';
19
20
  import { PresentationExecutionSnapshot, TemporalInputPresentation } from '../../shared/format-utils/index.js';
20
21
  import { JSX } from 'react';
@@ -285,6 +286,12 @@ export type DashboardProps = {
285
286
  onEvent?: (event: TEvent) => void;
286
287
  /** Receives dashboard editing lifecycle transitions from the shared runtime. */
287
288
  onDashboardLifecycleEvent?: (event: DashboardLifecycleEvent) => void;
289
+ /**
290
+ * Makes this dashboard a live screen: an agent's changes arrive through the
291
+ * port and land unsaved, with Undo in a one-line note (embedded live changes
292
+ * LC-D31). Only Semaphor's embed page passes it.
293
+ */
294
+ liveScreen?: LiveScreenPort;
288
295
  onSave?: (dashboard: TDashboard) => void;
289
296
  onFilterValuesChange?: (filterValues: TFilterValue[]) => void;
290
297
  LoadingComponent?: (props: LoadingProps) => React.ReactNode;
@@ -1578,13 +1585,31 @@ export type TEvent = {
1578
1585
  type: 'success' | 'error' | 'info' | 'warning';
1579
1586
  message: any;
1580
1587
  };
1581
- /** Supported lifecycle transitions emitted by an editable dashboard session. */
1588
+ /**
1589
+ * Supported lifecycle transitions emitted by an editable dashboard session:
1590
+ * its unsaved state, and an assistant's change applied on a live screen or
1591
+ * undone from its note (embedded live changes LC-D13).
1592
+ */
1582
1593
  export type DashboardLifecycleEvent = {
1583
1594
  type: 'dashboard:dirty-state';
1584
1595
  dashboardId: string;
1585
1596
  payload: {
1586
1597
  dirty: boolean;
1587
1598
  };
1599
+ } | {
1600
+ type: 'dashboard:change-applied';
1601
+ dashboardId: string;
1602
+ payload: {
1603
+ deliveryId: string;
1604
+ summary: string[];
1605
+ };
1606
+ } | {
1607
+ type: 'dashboard:change-undone';
1608
+ dashboardId: string;
1609
+ payload: {
1610
+ deliveryId: string;
1611
+ summary: string[];
1612
+ };
1588
1613
  };
1589
1614
  /**
1590
1615
  * Style for the dashboard
@@ -0,0 +1,2 @@
1
+ export * from './shared/live-channel/index.js'
2
+ export {}
@@ -82,12 +82,23 @@ export type AssistantStagePart = {
82
82
  stageId: string;
83
83
  label: string;
84
84
  state: 'live' | 'done' | 'skipped';
85
+ /**
86
+ * What kind of work the step does, for its icon: the server picks it with
87
+ * the label, from the same table. Absent on a step with no kind of its own
88
+ * and on turns stored before it.
89
+ */
90
+ activity?: AssistantStepActivity;
85
91
  /**
86
92
  * A step that changes the dashboard on screen (Phase 7): what the model
87
93
  * wrote before it is the answer, not a working note (P7-23, P7-45).
88
94
  */
89
95
  change?: true;
90
96
  };
97
+ /**
98
+ * Finding what to use, reading it, running an analysis or SQL, changing the
99
+ * dashboard, or working out another way after a step failed.
100
+ */
101
+ export type AssistantStepActivity = 'find' | 'read' | 'analyze' | 'sql' | 'change' | 'retry';
91
102
  /**
92
103
  * Where one answer's time and tokens went (spec 3.9, AG-D25). The server
93
104
  * sends it only to people who may see it (a development server, a super
@@ -7821,56 +7821,26 @@ export type ProposeChangeCaller = {
7821
7821
  generate: boolean;
7822
7822
  /** The SQL query form. */
7823
7823
  sql: boolean;
7824
+ /**
7825
+ * A session that changes the dashboard on the user's screen (a live token,
7826
+ * Semaphor's own assistant): it changes only the open dashboard, in place,
7827
+ * so `saveAs`, `preview` and `domainId` are not offered and, since the schema
7828
+ * is strict, are refused if sent (embedded live changes LC-D17).
7829
+ */
7830
+ onScreen: boolean;
7824
7831
  };
7825
7832
  /**
7826
7833
  * The propose tool's input for one caller (DE-INV-7, design rule 5): only the
7827
7834
  * changes and query forms this caller may use. `shape` is what an MCP tool
7828
- * registers; `schema` parses a call.
7835
+ * registers; `schema` parses a call. This is the one place that decides what
7836
+ * on-screen propose accepts (LC-D17).
7829
7837
  */
7830
7838
  export declare function buildProposeChangeInputSchema(caller: ProposeChangeCaller): {
7831
- shape: {
7832
- projectId: z.ZodOptional<z.ZodString>;
7833
- dashboardId: z.ZodOptional<z.ZodString>;
7834
- domainId: z.ZodOptional<z.ZodString>;
7835
- changes: z.ZodArray<z.ZodDiscriminatedUnion<"op", [z.ZodDiscriminatedUnionOption<"op">, ...z.ZodDiscriminatedUnionOption<"op">[]]>, "many">;
7836
- saveAs: z.ZodOptional<z.ZodEnum<["original", "copy"]>>;
7837
- preview: z.ZodOptional<z.ZodEnum<["sample", "rows", "none"]>>;
7838
- include: z.ZodOptional<z.ZodArray<z.ZodLiteral<"outline">, "many">>;
7839
- rationale: z.ZodOptional<z.ZodString>;
7840
- };
7841
- schema: z.ZodObject<{
7842
- projectId: z.ZodOptional<z.ZodString>;
7843
- dashboardId: z.ZodOptional<z.ZodString>;
7844
- domainId: z.ZodOptional<z.ZodString>;
7845
- changes: z.ZodArray<z.ZodDiscriminatedUnion<"op", [z.ZodDiscriminatedUnionOption<"op">, ...z.ZodDiscriminatedUnionOption<"op">[]]>, "many">;
7846
- saveAs: z.ZodOptional<z.ZodEnum<["original", "copy"]>>;
7847
- preview: z.ZodOptional<z.ZodEnum<["sample", "rows", "none"]>>;
7848
- include: z.ZodOptional<z.ZodArray<z.ZodLiteral<"outline">, "many">>;
7849
- rationale: z.ZodOptional<z.ZodString>;
7850
- }, "strict", z.ZodTypeAny, {
7851
- changes: {
7852
- [x: string]: any;
7853
- op?: unknown;
7854
- }[];
7855
- domainId?: string | undefined;
7856
- dashboardId?: string | undefined;
7857
- projectId?: string | undefined;
7858
- saveAs?: "original" | "copy" | undefined;
7859
- preview?: "rows" | "none" | "sample" | undefined;
7860
- include?: "outline"[] | undefined;
7861
- rationale?: string | undefined;
7862
- }, {
7863
- changes: {
7864
- [x: string]: any;
7865
- op?: unknown;
7866
- }[];
7867
- domainId?: string | undefined;
7868
- dashboardId?: string | undefined;
7869
- projectId?: string | undefined;
7870
- saveAs?: "original" | "copy" | undefined;
7871
- preview?: "rows" | "none" | "sample" | undefined;
7872
- include?: "outline"[] | undefined;
7873
- rationale?: string | undefined;
7839
+ shape: z.ZodRawShape;
7840
+ schema: z.ZodObject<z.ZodRawShape, "strict", z.ZodTypeAny, {
7841
+ [x: string]: any;
7842
+ }, {
7843
+ [x: string]: any;
7874
7844
  }>;
7875
7845
  };
7876
7846
  export type ProposeChangeInput = {
@@ -0,0 +1 @@
1
+ export * from './live-channel-contract.js';
@@ -0,0 +1,126 @@
1
+ import { TDashboard } from '../../lib/types/common-types.js';
2
+ import { DashboardOperation, OperationContext } from '../dashboard-authoring/operations/operation-types.js';
3
+ /**
4
+ * The live channel's shared contract (embedded live changes LC-D30, SPEC.md
5
+ * section 2): what travels between Semaphor's server and a live screen (the
6
+ * embedded dashboard), what agents hear back, and every timing. Pure and
7
+ * server-safe; semaphor-app imports it as `react-semaphor/live-channel`, and
8
+ * nothing else in either repo declares these types (LC-INV-30).
9
+ *
10
+ * Every value crossing the wire is parsed by its validator on receipt, on
11
+ * both sides; a value that fails is dropped (an event) or refused 400 (a
12
+ * POST), never half-used (C-1).
13
+ */
14
+ /** Always the first event on a connection. */
15
+ export type ConnectedEvent = {
16
+ type: 'connected';
17
+ connectionId: string;
18
+ };
19
+ export type ScreenCopyRequest = {
20
+ type: 'copy_request';
21
+ requestId: string;
22
+ /** The dashboard the call asked for. */
23
+ dashboardId: string;
24
+ };
25
+ export type ScreenDelivery = {
26
+ type: 'delivery';
27
+ deliveryId: string;
28
+ /** The revision it was built on. */
29
+ revisionId: string;
30
+ proposalId: string;
31
+ operations: DashboardOperation[];
32
+ context: OperationContext;
33
+ /** Propose's summary sentences. */
34
+ summary: string[];
35
+ /** Positive; the screen never writes after receipt plus this. */
36
+ applyWithinMs: number;
37
+ };
38
+ export type LiveChannelEvent = ConnectedEvent | ScreenCopyRequest | ScreenDelivery;
39
+ export type ScreenCopyAnswer = {
40
+ kind: 'uploaded';
41
+ screenId: string;
42
+ requestId: string;
43
+ revisionId: string;
44
+ dashboard: TDashboard;
45
+ };
46
+ export type ScreenOutcome = {
47
+ status: 'applied';
48
+ } | {
49
+ status: 'not_applied';
50
+ reason: 'dashboard_changed' | 'not_editable' | 'refused' | 'expired';
51
+ message: string;
52
+ };
53
+ export type DeliveryOutcomeReport = {
54
+ screenId: string;
55
+ deliveryId: string;
56
+ outcome: ScreenOutcome;
57
+ };
58
+ /**
59
+ * A delivery ends when propose returns (plan revision 20): the screen's
60
+ * report, or `not_confirmed` when none came within the outcome wait. The
61
+ * dashboard on screen is the truth; the agent reads it again to see whether
62
+ * the change is there.
63
+ */
64
+ export type DeliveryOutcome = ScreenOutcome | {
65
+ status: 'not_confirmed';
66
+ };
67
+ export type LiveDelivery = {
68
+ deliveryId: string;
69
+ outcome: DeliveryOutcome;
70
+ };
71
+ export type LiveScreenState = {
72
+ eligible: boolean;
73
+ dashboardId?: string;
74
+ };
75
+ /**
76
+ * What the embed page hands the dashboard (LC-D31): semaphor-app owns the
77
+ * transport behind it; react-semaphor's dashboard owns the screen state.
78
+ */
79
+ export type LiveScreenPort = {
80
+ /** UUID v4, made once per page load. */
81
+ screenId: string;
82
+ setScreenState(state: LiveScreenState): void;
83
+ subscribe(listener: (event: ScreenCopyRequest | ScreenDelivery) => void): () => void;
84
+ /** Once, no retry: the server's wait is short. */
85
+ answerCopyRequest(answer: ScreenCopyAnswer): Promise<void>;
86
+ /** Once, no retry: a report that doesn't arrive is `not_confirmed`. */
87
+ reportOutcome(report: DeliveryOutcomeReport): Promise<void>;
88
+ };
89
+ export declare const LIVE_CHANNEL_TIMINGS: {
90
+ readonly heartbeatMs: 25000;
91
+ /** A screen's record expires this long after its last heartbeat: it is gone. */
92
+ readonly heartbeatExpiryMs: 75000;
93
+ readonly hiddenTabGraceMs: 120000;
94
+ /** Then the last value repeatedly. */
95
+ readonly reconnectBackoffMs: readonly [0, 1000, 2000, 5000];
96
+ /** One per call. */
97
+ readonly copyAnswerWaitMs: 3000;
98
+ readonly outcomeWaitMs: 8000;
99
+ /** applyWithinMs = the outcome wait less this. */
100
+ readonly applyMarginMs: 1000;
101
+ /** A copy answer or an outcome is kept this long past its call's wait. */
102
+ readonly replyRetentionMs: 30000;
103
+ /** Distinct screens; a sixth gets 429. */
104
+ readonly connectionsPerToken: 5;
105
+ };
106
+ /** The shape of the timings; tests pass shorter ones. */
107
+ export type LiveChannelTimings = {
108
+ readonly [K in keyof typeof LIVE_CHANNEL_TIMINGS]: (typeof LIVE_CHANNEL_TIMINGS)[K] extends readonly number[] ? readonly number[] : number;
109
+ };
110
+ export type Parsed<T> = {
111
+ ok: true;
112
+ value: T;
113
+ } | {
114
+ ok: false;
115
+ problem: string;
116
+ };
117
+ /** A screen id: a UUID v4. */
118
+ export declare function isScreenId(value: unknown): value is string;
119
+ export declare function parseLiveChannelEvent(eventName: string, data: string): Parsed<LiveChannelEvent>;
120
+ export declare function parseScreenCopyAnswer(body: unknown, query: {
121
+ screenId: string;
122
+ requestId: string;
123
+ }): Parsed<ScreenCopyAnswer>;
124
+ export declare function parseDeliveryOutcomeReport(body: unknown): Parsed<DeliveryOutcomeReport>;
125
+ /** A screen's outcome, as reported and as stored. */
126
+ export declare function parseScreenOutcome(value: unknown): ScreenOutcome | null;
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "email": "support@semaphor.cloud"
6
6
  },
7
7
  "license": "MIT",
8
- "version": "0.1.548",
8
+ "version": "0.1.549",
9
9
  "description": "Fully interactive and customizable dashboards for your apps.",
10
10
  "keywords": [
11
11
  "react",
@@ -92,6 +92,10 @@
92
92
  "types": "./dist/types/activity.d.ts",
93
93
  "import": "./dist/activity/index.js"
94
94
  },
95
+ "./live-channel": {
96
+ "types": "./dist/types/live-channel.d.ts",
97
+ "import": "./dist/live-channel/index.js"
98
+ },
95
99
  "./briefings": {
96
100
  "types": "./dist/types/briefings.d.ts",
97
101
  "import": "./dist/briefings/index.js"