@machinemetrics/mm-react-tools 5.3.0 → 5.4.0

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.
@@ -0,0 +1,69 @@
1
+ /**
2
+ * App → Max, through the dashboard host. Use inside MMProvider.
3
+ *
4
+ * - `report(kind, payload)`: background context for Max (`agent:event`).
5
+ * Never the user's words.
6
+ * - `ask(prompt, { newConversation })`: the user's own message to Max
7
+ * (`agent:ask`), into the open conversation or a fresh one. It says
8
+ * nothing about pages: an app that wants the page to the left of Max to
9
+ * change asks, then navigates (in that order: the host only takes
10
+ * messages from a frame that still exists, and navigating can unmount
11
+ * it). The host holds the prompt until the new page is up.
12
+ *
13
+ * `ask` only works right after a user action (a click or key press): the
14
+ * browser's transient user activation. The host checks the same on its own
15
+ * window, so this check is for a clear error, not the security boundary.
16
+ */
17
+ export declare const ASK_MAX_LENGTH = 4000;
18
+ export declare const AGENT_ASK = "agent:ask";
19
+ export declare const AGENT_ASK_CONSUMED = "agent:ask-consumed";
20
+ export declare const AGENT_ASK_SOURCES: readonly ["app-gallery-builder", "app-gallery", "cml-renderer"];
21
+ /** App-to-host request; the host supplies source and timestamp when forwarding. */
22
+ export interface AgentAskPayload {
23
+ prompt: string;
24
+ newConversation?: boolean;
25
+ }
26
+ export interface AgentHostPrompt {
27
+ at: number;
28
+ prompt: string;
29
+ source: (typeof AGENT_ASK_SOURCES)[number];
30
+ }
31
+ export interface AgentAskConsumedPayload {
32
+ kind: 'newThreadPrompt' | 'agentAsk';
33
+ at: number;
34
+ }
35
+ export type AgentEventKind = 'app.error' | 'app.event' | 'app.context';
36
+ /** Renderer event contract; threadId routes the event to its conversation. */
37
+ export interface AgentEvent {
38
+ id: string;
39
+ kind: AgentEventKind;
40
+ at: string;
41
+ threadId: string;
42
+ app?: string;
43
+ /** Legacy alias; threadId is still required. */
44
+ thread?: string;
45
+ appId?: string;
46
+ surface?: 'page' | 'sidesheet' | 'widget' | 'tab' | 'tools';
47
+ message?: string;
48
+ summary?: string;
49
+ errors?: string[];
50
+ version?: number;
51
+ data?: unknown;
52
+ }
53
+ export type AgentEventPayload = Omit<AgentEvent, 'id' | 'kind' | 'at'>;
54
+ export interface AskOptions {
55
+ /** Start a fresh conversation with this prompt as its first message. */
56
+ newConversation?: boolean;
57
+ }
58
+ export type AskResult = {
59
+ ok: true;
60
+ } | {
61
+ ok: false;
62
+ reason: 'not-embedded' | 'no-user-action' | 'empty' | 'too-long';
63
+ };
64
+ export interface MMAgent {
65
+ report: (kind: AgentEventKind, payload: AgentEventPayload) => boolean;
66
+ ask: (prompt: string, options?: AskOptions) => AskResult;
67
+ }
68
+ export declare const useMMAgent: () => MMAgent;
69
+ //# sourceMappingURL=useMMAgent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMMAgent.d.ts","sourceRoot":"","sources":["../src/useMMAgent.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,OAAO,CAAC;AACnC,eAAO,MAAM,SAAS,cAAc,CAAC;AACrC,eAAO,MAAM,kBAAkB,uBAAuB,CAAC;AACvD,eAAO,MAAM,iBAAiB,iEAIpB,CAAC;AAEX,mFAAmF;AACnF,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,iBAAiB,GAAG,UAAU,CAAC;IACrC,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,WAAW,GAAG,aAAa,CAAC;AAEvE,8EAA8E;AAC9E,MAAM,WAAW,UAAU;IACz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0",
4
4
  "description": "Components, hooks, and helper functions for writing React apps using MachineMetrics APIs.",
5
5
  "author": "machinemetrics",
6
6
  "license": "MIT",