@streamoid/agent 0.8.1-preview.0cae4ef290a8 → 0.8.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.
@@ -0,0 +1,2 @@
1
+ export { notifyAgent, pendingAgentEvents, subscribeAgentEvents } from './index';
2
+ export type { AgentHostEvent } from './index';
package/dist/events.js ADDED
@@ -0,0 +1,109 @@
1
+ const c = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), u = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), s = (e, t) => `streamoid.agent.events.v1:${encodeURIComponent(t)}:${encodeURIComponent(e)}`;
2
+ function f(e, t = 0) {
3
+ if (t > 9) return !1;
4
+ if (e === null || typeof e == "boolean") return !0;
5
+ if (typeof e == "number") return Number.isFinite(e);
6
+ if (typeof e == "string") return e.length <= 2e3;
7
+ if (Array.isArray(e)) return e.length <= 300 && e.every((n) => f(n, t + 1));
8
+ if (typeof e == "object" && e) {
9
+ const n = Object.entries(e);
10
+ return n.length <= 300 && n.every(([r, i]) => r.length <= 100 && f(i, t + 1));
11
+ }
12
+ return !1;
13
+ }
14
+ function y(e) {
15
+ if (!e || typeof e != "object") return null;
16
+ const t = e;
17
+ for (const n of ["id", "workspaceId", "userId", "uploadId", "label"])
18
+ if (typeof t[n] != "string" || !t[n].trim() || t[n].length > 2e3) return null;
19
+ if (!["upload.reviewed", "upload.completed", "upload.failed"].includes(String(t.type))) return null;
20
+ try {
21
+ const n = JSON.stringify(e, (i, o) => {
22
+ if (typeof o == "number" && !Number.isFinite(o)) throw new Error("Nonfinite fact");
23
+ return o;
24
+ });
25
+ if (n.length > 48e3) return null;
26
+ const r = JSON.parse(n);
27
+ return !r.facts || Array.isArray(r.facts) || typeof r.facts != "object" || !f(r.facts) ? null : { ...r, label: r.label.trim() };
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
32
+ function p(e) {
33
+ try {
34
+ const t = JSON.parse(sessionStorage.getItem(`${e}:delivered`) ?? "null");
35
+ if (Array.isArray(t)) return t.filter((n) => typeof n == "string");
36
+ } catch {
37
+ }
38
+ return l.get(e) ?? [];
39
+ }
40
+ function d(e) {
41
+ try {
42
+ const t = sessionStorage.getItem(e);
43
+ if (t) {
44
+ const n = JSON.parse(t);
45
+ if (Array.isArray(n)) return n.map(y).filter((r) => !!r && s(r.workspaceId, r.userId) === e);
46
+ }
47
+ } catch {
48
+ }
49
+ return a.get(e) ?? [];
50
+ }
51
+ function g(e, t) {
52
+ a.set(e, t);
53
+ try {
54
+ sessionStorage.setItem(e, JSON.stringify(t));
55
+ } catch {
56
+ }
57
+ c.forEach((n) => n());
58
+ }
59
+ function m(e) {
60
+ const t = y(e);
61
+ if (!t) return !1;
62
+ const n = s(t.workspaceId, t.userId);
63
+ if (p(n).includes(t.id)) return !0;
64
+ const r = d(n);
65
+ if (r.some((o) => o.id === t.id)) return !0;
66
+ const i = r.filter((o) => o.uploadId !== t.uploadId || t.type === "upload.reviewed" || o.type !== "upload.reviewed");
67
+ return g(n, [...i, t]), !0;
68
+ }
69
+ function I(e, t) {
70
+ return d(s(e, t));
71
+ }
72
+ function b(e) {
73
+ const t = s(e.workspaceId, e.userId), n = [.../* @__PURE__ */ new Set([...p(t), e.id])].slice(-512);
74
+ l.set(t, n);
75
+ try {
76
+ sessionStorage.setItem(`${t}:delivered`, JSON.stringify(n));
77
+ } catch {
78
+ }
79
+ g(t, d(t).filter((r) => r.id !== e.id));
80
+ }
81
+ function S(e) {
82
+ return c.add(e), () => {
83
+ c.delete(e);
84
+ };
85
+ }
86
+ function h(e, t) {
87
+ const n = `${s(e, t)}:conversation`;
88
+ try {
89
+ return sessionStorage.getItem(n) ?? u.get(n) ?? null;
90
+ } catch {
91
+ return u.get(n) ?? null;
92
+ }
93
+ }
94
+ function w(e, t, n) {
95
+ const r = `${s(e, t)}:conversation`;
96
+ u.set(r, n);
97
+ try {
98
+ sessionStorage.setItem(r, n);
99
+ } catch {
100
+ }
101
+ }
102
+ export {
103
+ b as acknowledgeAgentEvent,
104
+ h as eventConversation,
105
+ m as notifyAgent,
106
+ I as pendingAgentEvents,
107
+ w as rememberEventConversation,
108
+ S as subscribeAgentEvents
109
+ };
package/dist/index.d.ts CHANGED
@@ -103,8 +103,6 @@ export interface AgentChatShellAdapters {
103
103
  theme: { mode: 'light' | 'dark' };
104
104
  config: {
105
105
  apiBase: string;
106
- /** Smaller chat, form and composer text for compact host panels. */
107
- textSize?: 'default' | 'small';
108
106
  hide?: {
109
107
  sidepane?: boolean;
110
108
  newBrief?: boolean;
@@ -160,6 +158,7 @@ export interface AgentChatShellAdapters {
160
158
  * turn on `capture_inline_screenshot`.
161
159
  */
162
160
  hostContext?: AgentHostContext | null;
161
+ integration?: AgentHostIntegration;
163
162
  /**
164
163
  * Called when the panel starts or stops showing a non-text artefact — a
165
164
  * table, an image set, a widget, a techpack, a board.
@@ -314,23 +313,7 @@ export interface AgentScopeAdapter {
314
313
  onSuggestion?: (suggestion: AgentScopeSuggestion) => boolean | void;
315
314
  }
316
315
 
317
- export interface AttachedHostCanvas {
318
- /** Connect to the canvas already mounted by the host; no internal canvas pane. */
319
- mode: 'attached';
320
- workspaceId: string;
321
- projectId: string;
322
- documentId: string;
323
- sessionId?: string;
324
- ready: boolean;
325
- /** Hide floating previews while the host hides its assistant. */
326
- visible?: boolean;
327
- onReveal?(): void;
328
- }
329
-
330
- export type HostCanvasContextValue = AttachedHostCanvas | RenderedHostCanvas;
331
-
332
- export interface RenderedHostCanvas {
333
- mode?: 'render';
316
+ export interface HostCanvasContextValue {
334
317
  render(context: {
335
318
  workspaceId: string;
336
319
  projectId: string;
@@ -708,3 +691,28 @@ export interface AgentSidePaneProps {
708
691
  /** Accessible name of the pane landmark. Default "Ask CXO assistant". */
709
692
  ariaLabel?: string;
710
693
  }
694
+
695
+ /** An application event, queued without opening the host pane. */
696
+ export interface AgentHostEvent {
697
+ id: string;
698
+ type: 'upload.reviewed' | 'upload.completed' | 'upload.failed';
699
+ workspaceId: string;
700
+ userId: string;
701
+ uploadId: string;
702
+ label: string;
703
+ facts: Record<string, unknown>;
704
+ }
705
+ export interface AgentHostIntegration {
706
+ active?: boolean;
707
+ compactSuggestions?: boolean;
708
+ /** Return true when the host handled a suggestion click. Other clicks fill the composer. */
709
+ onSuggestion?: (suggestion: { sectionKey: string; outcomeKey: string; text: string }) => boolean | void;
710
+ actions?: {
711
+ list: readonly string[];
712
+ run: (name: string, params: Record<string, unknown>) => Promise<unknown>;
713
+ };
714
+ read?: (name: string, params: Record<string, unknown>) => Promise<unknown>;
715
+ }
716
+ export declare function notifyAgent(event: AgentHostEvent): boolean;
717
+ export declare function pendingAgentEvents(workspaceId: string, userId: string): AgentHostEvent[];
718
+ export declare function subscribeAgentEvents(listener: () => void): () => void;