@streamoid/agent 0.8.6 → 0.9.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.
@@ -1,5 +1,5 @@
1
1
  import { resolveStreamoidProduct as b, streamoidProductLabel as k } from "@streamoid/ui";
2
- function a(e) {
2
+ function l(e) {
3
3
  if (typeof e != "string" || !e.trim()) return null;
4
4
  const n = b(e.trim());
5
5
  return n && n !== "cxo" ? n : null;
@@ -8,7 +8,7 @@ function d(e) {
8
8
  return e && k(e) || "All apps";
9
9
  }
10
10
  function $(e, n) {
11
- if (e === null || e !== a(n?.app)) return null;
11
+ if (e === null || e !== l(n?.app)) return null;
12
12
  const i = (Array.isArray(n?.breadcrumbs) ? n.breadcrumbs.filter((t) => typeof t == "string" && !!t.trim()).map((t) => t.trim()) : []).join(" › ") || (typeof n?.page == "string" ? n.page.trim() : "");
13
13
  return i ? `${d(e)} · ${i}` : d(e);
14
14
  }
@@ -22,13 +22,13 @@ function m(e, n) {
22
22
  const r = e.instruction?.includes("{subject}") ? e.instruction : `${e.label}: {subject}`;
23
23
  return h(r.replace(/\{subject\}/g, n).trim());
24
24
  }
25
- function w(e, n) {
25
+ function q(e, n) {
26
26
  const r = [];
27
27
  for (const i of e ?? []) {
28
28
  if (!i?.outcomes?.length) continue;
29
29
  const t = (i.samples ?? []).find(
30
- (u) => i.outcomes.some((f) => p(f, u.kind))
31
- ), c = (u, f) => i.outcomes.find((l) => l.key === f && p(l, u)) ?? i.outcomes.find((l) => p(l, u)), s = n ? c(n.kind, t?.primaryOutcomeKey) : void 0;
30
+ (c) => i.outcomes.some((f) => p(f, c.kind))
31
+ ), o = (c, f) => i.outcomes.find((a) => a.key === f && p(a, c)) ?? i.outcomes.find((a) => p(a, c)), s = n ? o(n.kind, t?.primaryOutcomeKey) : void 0;
32
32
  if (n && s) {
33
33
  r.push({
34
34
  id: `${i.key}:${s.key}:selection`,
@@ -37,37 +37,39 @@ function w(e, n) {
37
37
  subject: "selection",
38
38
  text: m(s, n.subject || n.label),
39
39
  ceilingMinutes: s.ceilingMinutes,
40
- deliverable: s.deliverable
40
+ deliverable: s.deliverable,
41
+ requirements: s.requirements
41
42
  });
42
43
  continue;
43
44
  }
44
45
  if (!t) continue;
45
- const o = c(t.kind, t.primaryOutcomeKey);
46
- o && r.push({
47
- id: `${i.key}:${o.key}:${t.id}`,
46
+ const u = o(t.kind, t.primaryOutcomeKey);
47
+ u && r.push({
48
+ id: `${i.key}:${u.key}:${t.id}`,
48
49
  sectionKey: i.key,
49
- outcomeKey: o.key,
50
+ outcomeKey: u.key,
50
51
  sampleId: t.id,
51
52
  sampleTitle: t.subject || t.title,
52
53
  subject: "sample",
53
- text: m(o, t.subject || t.title),
54
- ceilingMinutes: o.ceilingMinutes,
55
- deliverable: o.deliverable,
54
+ text: m(u, t.subject || t.title),
55
+ ceilingMinutes: u.ceilingMinutes,
56
+ deliverable: u.deliverable,
57
+ requirements: u.requirements,
56
58
  imageUrl: t.imageUrl ?? null
57
59
  });
58
60
  }
59
61
  return r;
60
62
  }
61
- function O(e, n) {
62
- return n ? e.length === 0 ? !1 : e.every((r) => a(r) === n) : !0;
63
+ function w(e, n) {
64
+ return n ? e.length === 0 ? !1 : e.every((r) => l(r) === n) : !0;
63
65
  }
64
66
  const v = 3;
65
- function A(e, n, r = v) {
66
- const i = (s) => (s.value ?? s.title).trim().toLowerCase(), t = e.slice(0, r), c = new Set(t.map(i));
67
+ function O(e, n, r = v) {
68
+ const i = (s) => (s.value ?? s.title).trim().toLowerCase(), t = e.slice(0, r), o = new Set(t.map(i));
67
69
  for (const s of n) {
68
70
  if (t.length >= r) break;
69
- const o = i(s);
70
- c.has(o) || (c.add(o), t.push(s));
71
+ const u = i(s);
72
+ o.has(u) || (o.add(u), t.push(s));
71
73
  }
72
74
  return t;
73
75
  }
@@ -76,7 +78,7 @@ function S(e) {
76
78
  (n) => !e?.[n]?.trim()
77
79
  );
78
80
  }
79
- let g = !1;
81
+ let y = !1;
80
82
  function C() {
81
83
  try {
82
84
  return process.env.NODE_ENV === "development";
@@ -84,31 +86,46 @@ function C() {
84
86
  return !1;
85
87
  }
86
88
  }
87
- function L(e, n, r = C()) {
88
- if (!r || g || !e) return !1;
89
+ function A(e, n, r = C()) {
90
+ if (!r || y || !e) return !1;
89
91
  const i = S(n);
90
- return i.length === 0 ? !1 : (g = !0, console.warn(
92
+ return i.length === 0 ? !1 : (y = !0, console.warn(
91
93
  `[@streamoid/agent] adapters.scope for "${e}" has no ${i.join(", ")}; the Ask CXO panel falls back to generic copy. Pass an app-specific question (headline), helper line (subline) and composer hint (placeholder).`
92
94
  ), !0);
93
95
  }
94
- function y(e) {
95
- return a(e.meta?.origin_app);
96
+ function g(e) {
97
+ return l(e.meta?.origin_app);
96
98
  }
97
99
  function K(e) {
98
100
  const n = e.meta?.scope;
99
- return n === "all" ? null : a(n) ?? y(e);
101
+ return n === "all" ? null : l(n) ?? g(e);
102
+ }
103
+ function L(e, n) {
104
+ return n ? e.filter((r) => g(r) === n) : [...e];
105
+ }
106
+ function M(e, n = !1) {
107
+ const r = e?.sections ?? [], i = e?.featured ?? (n ? r.find((o) => o.key === "add-sales") : void 0), t = e?.footer ?? (n ? r.find((o) => o.key === "try-tacx") : void 0);
108
+ return { featured: i, footer: t, sections: r.filter((o) => o.key !== i?.key && o.key !== t?.key) };
100
109
  }
101
- function M(e, n) {
102
- return n ? e.filter((r) => y(r) === n) : [...e];
110
+ function x(e, n) {
111
+ if (e?.app !== "tactix") return e;
112
+ const r = (n?.sections ?? []).flatMap((i) => i.outcomes.filter((t) => t.requirements?.length).map((t) => ({
113
+ key: i.key,
114
+ outcomeKey: t.key,
115
+ requirements: t.requirements.map(({ key: o, label: s, state: u }) => ({ key: o, label: s, state: u }))
116
+ })));
117
+ return r.length ? { ...e, dataTasks: r } : e;
103
118
  }
104
119
  export {
105
120
  M as a,
106
- O as b,
107
- K as c,
108
- w as d,
109
- $ as e,
110
- A as f,
111
- a as h,
121
+ w as b,
122
+ L as c,
123
+ q as d,
124
+ x as e,
125
+ O as f,
126
+ K as g,
127
+ l as h,
128
+ $ as i,
112
129
  d as s,
113
- L as w
130
+ A as w
114
131
  };
package/dist/index.d.ts CHANGED
@@ -239,6 +239,13 @@ export interface AgentChatShellAdapters {
239
239
  support?: AgentSupportAdapter | null;
240
240
  }
241
241
 
242
+ export interface AgentScopeRequirement {
243
+ /** Stable data-source id, supplied by the host. */
244
+ key: string;
245
+ label: string;
246
+ state: 'missing' | 'connected';
247
+ }
248
+
242
249
  export interface AgentScopeOutcome {
243
250
  key: string;
244
251
  label: string;
@@ -247,6 +254,7 @@ export interface AgentScopeOutcome {
247
254
  /** A ceiling, not an estimate. */
248
255
  ceilingMinutes?: number;
249
256
  deliverable?: string;
257
+ requirements?: AgentScopeRequirement[];
250
258
  kinds?: string[];
251
259
  }
252
260
 
@@ -290,10 +298,15 @@ export interface AgentScopeSuggestion {
290
298
  text: string;
291
299
  ceilingMinutes?: number;
292
300
  deliverable?: string;
301
+ requirements?: AgentScopeRequirement[];
293
302
  imageUrl?: string | null;
294
303
  }
295
304
 
296
305
  export interface AgentScopeAdapter {
306
+ /** Host-owned task above the suggestions, outside their three-card limit. */
307
+ featured?: AgentScopeSection | null;
308
+ /** Host-owned link under suggestions; navigation uses integration.onSuggestion. */
309
+ footer?: AgentScopeSection | null;
297
310
  sections?: AgentScopeSection[] | null;
298
311
  selection?: AgentScopeSelection | null;
299
312
  /** The line above the composer before the first turn, in the host's own
@@ -708,7 +721,7 @@ export interface AgentHostIntegration {
708
721
  active?: boolean;
709
722
  compactSuggestions?: boolean;
710
723
  /** Return true when the host handled a suggestion click. Other clicks fill the composer. */
711
- onSuggestion?: (suggestion: { sectionKey: string; outcomeKey: string; text: string }) => boolean | void;
724
+ onSuggestion?: (suggestion: { sectionKey: string; outcomeKey: string; text: string; requirements?: AgentScopeRequirement[] }) => boolean | void;
712
725
  actions?: {
713
726
  list: readonly string[];
714
727
  run: (name: string, params: Record<string, unknown>) => Promise<unknown>;