@streamoid/agent 0.11.1 → 0.11.3

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,140 @@
1
+ import { resolveStreamoidProduct as k, streamoidProductLabel as b } from "@streamoid/ui";
2
+ function h(e, n) {
3
+ const i = (e?.groups ?? []).filter((t) => t.starters.length > 0);
4
+ return i.find((t) => t.key === n) ?? i.find((t) => t.key === e?.defaultGroup) ?? i[0] ?? null;
5
+ }
6
+ function q(e) {
7
+ return !!(e?.featured?.prompt?.trim() || h(e));
8
+ }
9
+ function l(e) {
10
+ if (typeof e != "string" || !e.trim()) return null;
11
+ const n = k(e.trim());
12
+ return n && n !== "cxo" ? n : null;
13
+ }
14
+ function d(e) {
15
+ return e && b(e) || "All apps";
16
+ }
17
+ function w(e, n) {
18
+ if (e === null || e !== l(n?.app)) return null;
19
+ const t = (Array.isArray(n?.breadcrumbs) ? n.breadcrumbs.filter((r) => typeof r == "string" && !!r.trim()).map((r) => r.trim()) : []).join(" › ") || (typeof n?.page == "string" ? n.page.trim() : "");
20
+ return t ? `${d(e)} · ${t}` : d(e);
21
+ }
22
+ function p(e, n) {
23
+ return !e.kinds || e.kinds.length === 0 || n === void 0 ? !0 : e.kinds.map((i) => i.toLowerCase()).includes(n.toLowerCase());
24
+ }
25
+ function v(e) {
26
+ return e.charAt(0).toUpperCase() + e.slice(1);
27
+ }
28
+ function m(e, n) {
29
+ const i = e.instruction?.includes("{subject}") ? e.instruction : `${e.label}: {subject}`;
30
+ return v(i.replace(/\{subject\}/g, n).trim());
31
+ }
32
+ function O(e, n) {
33
+ const i = [];
34
+ for (const t of e ?? []) {
35
+ if (!t?.outcomes?.length) continue;
36
+ const r = (t.samples ?? []).find(
37
+ (c) => t.outcomes.some((f) => p(f, c.kind))
38
+ ), o = (c, f) => t.outcomes.find((a) => a.key === f && p(a, c)) ?? t.outcomes.find((a) => p(a, c)), s = n ? o(n.kind, r?.primaryOutcomeKey) : void 0;
39
+ if (n && s) {
40
+ i.push({
41
+ id: `${t.key}:${s.key}:selection`,
42
+ sectionKey: t.key,
43
+ outcomeKey: s.key,
44
+ subject: "selection",
45
+ text: m(s, n.subject || n.label),
46
+ ceilingMinutes: s.ceilingMinutes,
47
+ deliverable: s.deliverable,
48
+ requirements: s.requirements
49
+ });
50
+ continue;
51
+ }
52
+ if (!r) continue;
53
+ const u = o(r.kind, r.primaryOutcomeKey);
54
+ u && i.push({
55
+ id: `${t.key}:${u.key}:${r.id}`,
56
+ sectionKey: t.key,
57
+ outcomeKey: u.key,
58
+ sampleId: r.id,
59
+ sampleTitle: r.subject || r.title,
60
+ subject: "sample",
61
+ text: m(u, r.subject || r.title),
62
+ ceilingMinutes: u.ceilingMinutes,
63
+ deliverable: u.deliverable,
64
+ requirements: u.requirements,
65
+ imageUrl: r.imageUrl ?? null
66
+ });
67
+ }
68
+ return i;
69
+ }
70
+ function A(e, n) {
71
+ return n ? e.length === 0 ? !1 : e.every((i) => l(i) === n) : !0;
72
+ }
73
+ const S = 3;
74
+ function K(e, n, i = S) {
75
+ const t = (s) => (s.value ?? s.title).trim().toLowerCase(), r = e.slice(0, i), o = new Set(r.map(t));
76
+ for (const s of n) {
77
+ if (r.length >= i) break;
78
+ const u = t(s);
79
+ o.has(u) || (o.add(u), r.push(s));
80
+ }
81
+ return r;
82
+ }
83
+ function C(e) {
84
+ return ["headline", "subline", "placeholder"].filter(
85
+ (n) => !e?.[n]?.trim()
86
+ );
87
+ }
88
+ let y = !1;
89
+ function j() {
90
+ try {
91
+ return process.env.NODE_ENV === "development";
92
+ } catch {
93
+ return !1;
94
+ }
95
+ }
96
+ function L(e, n, i = j()) {
97
+ if (!i || y || !e) return !1;
98
+ const t = C(n);
99
+ return t.length === 0 ? !1 : (y = !0, console.warn(
100
+ `[@streamoid/agent] adapters.scope for "${e}" has no ${t.join(", ")}; the Ask CXO panel falls back to generic copy. Pass an app-specific question (headline), helper line (subline) and composer hint (placeholder).`
101
+ ), !0);
102
+ }
103
+ function g(e) {
104
+ return l(e.meta?.origin_app);
105
+ }
106
+ function M(e) {
107
+ const n = e.meta?.scope;
108
+ return n === "all" ? null : l(n) ?? g(e);
109
+ }
110
+ function x(e, n) {
111
+ return n ? e.filter((i) => g(i) === n) : [...e];
112
+ }
113
+ function T(e, n = !1) {
114
+ const i = e?.sections ?? [], t = e?.featured ?? (n ? i.find((o) => o.key === "add-sales") : void 0), r = e?.footer ?? (n ? i.find((o) => o.key === "try-tacx") : void 0);
115
+ return { featured: t, footer: r, sections: i.filter((o) => o.key !== t?.key && o.key !== r?.key) };
116
+ }
117
+ function N(e, n) {
118
+ if (e?.app !== "tactix") return e;
119
+ const i = (n?.sections ?? []).flatMap((t) => t.outcomes.filter((r) => r.requirements?.length).map((r) => ({
120
+ key: t.key,
121
+ outcomeKey: r.key,
122
+ requirements: r.requirements.map(({ key: o, label: s, state: u }) => ({ key: o, label: s, state: u }))
123
+ })));
124
+ return i.length ? { ...e, dataTasks: i } : e;
125
+ }
126
+ export {
127
+ h as a,
128
+ T as b,
129
+ q as c,
130
+ O as d,
131
+ A as e,
132
+ K as f,
133
+ x as g,
134
+ l as h,
135
+ N as i,
136
+ M as j,
137
+ w as k,
138
+ d as s,
139
+ L as w
140
+ };
package/dist/index.d.ts CHANGED
@@ -318,7 +318,43 @@ export interface AgentScopeSuggestion {
318
318
  imageUrl?: string | null;
319
319
  }
320
320
 
321
+ /** A question the host offers as a start: a short label on screen, the full
322
+ * prompt in the composer. */
323
+ export interface AgentScopeStarter {
324
+ label: string;
325
+ /** What the composer gets; complete enough to send as typed. */
326
+ prompt: string;
327
+ /** A quieter second line (shown on the featured starter). */
328
+ description?: string | null;
329
+ }
330
+
331
+ /** One tab of starters: a role and its questions. */
332
+ export interface AgentScopeStarterGroup {
333
+ key: string;
334
+ label: string;
335
+ starters: AgentScopeStarter[];
336
+ }
337
+
338
+ /**
339
+ * The host's own opening questions: one featured above role tabs, each tab a
340
+ * short list. Picking one ONLY fills the composer -- nothing is sent and
341
+ * nothing in the host changes until Send. Switching tabs never touches the
342
+ * draft.
343
+ */
344
+ export interface AgentScopeStarters {
345
+ /** Absent = "Suggested prompts". */
346
+ heading?: string | null;
347
+ featured?: AgentScopeStarter | null;
348
+ groups: AgentScopeStarterGroup[];
349
+ /** The tab shown first; absent = the first group. */
350
+ defaultGroup?: string | null;
351
+ }
352
+
321
353
  export interface AgentScopeAdapter {
354
+ /** The host's opening questions by role. When given, they replace the
355
+ * suggested-task row; a `featured` / `footer` section still shows around
356
+ * them (e.g. "Add your sales data" and "Try it on sample data"). */
357
+ starters?: AgentScopeStarters | null;
322
358
  /** Host-owned task above the suggestions, outside their three-card limit. */
323
359
  featured?: AgentScopeSection | null;
324
360
  /** Host-owned link under suggestions; navigation uses integration.onSuggestion. */