aimeat 1.23.2 → 1.24.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.
Files changed (239) hide show
  1. package/dist/locales/en.json +580 -21
  2. package/dist/locales/fi.json +592 -33
  3. package/dist/public/components/ContactCard.js +28 -0
  4. package/dist/public/css/views/admin.css +12 -0
  5. package/dist/public/css/views/agents-detail.css +62 -10
  6. package/dist/public/css/views/landing.css +87 -0
  7. package/dist/public/css/views/offers.css +96 -0
  8. package/dist/public/css/views/portfolio.css +18 -0
  9. package/dist/public/css/views/profile.css +153 -8
  10. package/dist/public/css/views/start.css +96 -0
  11. package/dist/public/css/views/workflows.css +111 -0
  12. package/dist/public/img/business-hero.png +0 -0
  13. package/dist/public/img/toimitus.png +0 -0
  14. package/dist/public/js/components/tag-cloud.js +46 -31
  15. package/dist/public/js/components/tag-editor.js +2 -2
  16. package/dist/public/js/recents.js +40 -0
  17. package/dist/public/js/services/admin.js +6 -0
  18. package/dist/public/js/services/agents.js +34 -0
  19. package/dist/public/js/services/offers.js +152 -0
  20. package/dist/public/js/services/packages.js +1 -0
  21. package/dist/public/js/services/workflows.js +57 -0
  22. package/dist/public/llms-template.txt +7 -0
  23. package/dist/public/spa.html +35 -3
  24. package/dist/public/views/admin/subdomains-tab.js +182 -0
  25. package/dist/public/views/admin.js +2 -0
  26. package/dist/public/views/business.js +119 -0
  27. package/dist/public/views/how-it-works.js +159 -0
  28. package/dist/public/views/landing.js +235 -0
  29. package/dist/public/views/portfolio.js +120 -23
  30. package/dist/public/views/pricing.js +75 -0
  31. package/dist/public/views/profile/access-tab.js +124 -51
  32. package/dist/public/views/profile/agents/agent-card.js +68 -37
  33. package/dist/public/views/profile/agents/shared-board.js +56 -22
  34. package/dist/public/views/profile/agents/tab-activity.js +24 -12
  35. package/dist/public/views/profile/agents/tab-agent-config.js +31 -1
  36. package/dist/public/views/profile/agents/tab-data-access.js +9 -13
  37. package/dist/public/views/profile/agents/tab-integration.js +27 -1
  38. package/dist/public/views/profile/agents/tab-messages.js +6 -11
  39. package/dist/public/views/profile/agents/tab-quality.js +45 -5
  40. package/dist/public/views/profile/agents-tab.js +41 -6
  41. package/dist/public/views/profile/apps-tab.js +7 -1
  42. package/dist/public/views/profile/knowledge-tab.js +4 -1
  43. package/dist/public/views/profile/landing-page.js +428 -123
  44. package/dist/public/views/profile/memory-tab.js +409 -211
  45. package/dist/public/views/profile/nodes-tab.js +18 -3
  46. package/dist/public/views/profile/offers-tab.js +310 -0
  47. package/dist/public/views/profile/organisms-tab.js +289 -28
  48. package/dist/public/views/profile/packages-tab.js +152 -16
  49. package/dist/public/views/profile/portfolio-tab.js +98 -31
  50. package/dist/public/views/profile/workflows-form.js +220 -0
  51. package/dist/public/views/profile/workflows-tab.js +244 -0
  52. package/dist/public/views/profile.js +4 -0
  53. package/dist/public/views/start-flows.js +281 -0
  54. package/dist/public/views/start.js +258 -0
  55. package/dist/src/cli/connect/mcp/tools/index.d.ts.map +1 -1
  56. package/dist/src/cli/connect/mcp/tools/index.js +2 -0
  57. package/dist/src/cli/connect/mcp/tools/index.js.map +1 -1
  58. package/dist/src/cli/connect/mcp/tools/workflows.d.ts +12 -0
  59. package/dist/src/cli/connect/mcp/tools/workflows.d.ts.map +1 -0
  60. package/dist/src/cli/connect/mcp/tools/workflows.js +37 -0
  61. package/dist/src/cli/connect/mcp/tools/workflows.js.map +1 -0
  62. package/dist/src/cli/connect/tool-call.d.ts.map +1 -1
  63. package/dist/src/cli/connect/tool-call.js +37 -0
  64. package/dist/src/cli/connect/tool-call.js.map +1 -1
  65. package/dist/src/generated/api-types.d.ts +1474 -66
  66. package/dist/src/generated/api-types.d.ts.map +1 -1
  67. package/dist/src/generated/prisma-postgres/edge.js +15 -3
  68. package/dist/src/generated/prisma-postgres/index-browser.js +12 -0
  69. package/dist/src/generated/prisma-postgres/index.d.ts +1476 -160
  70. package/dist/src/generated/prisma-postgres/index.js +15 -3
  71. package/dist/src/generated/prisma-postgres/package.json +1 -1
  72. package/dist/src/generated/prisma-postgres/schema.prisma +11 -0
  73. package/dist/src/generated/prisma-postgres/wasm.js +15 -3
  74. package/dist/src/mcp/annotations.d.ts.map +1 -1
  75. package/dist/src/mcp/annotations.js +3 -0
  76. package/dist/src/mcp/annotations.js.map +1 -1
  77. package/dist/src/mcp/catalog/definitions.d.ts.map +1 -1
  78. package/dist/src/mcp/catalog/definitions.js +27 -0
  79. package/dist/src/mcp/catalog/definitions.js.map +1 -1
  80. package/dist/src/mcp/catalog/scopes.d.ts.map +1 -1
  81. package/dist/src/mcp/catalog/scopes.js +5 -1
  82. package/dist/src/mcp/catalog/scopes.js.map +1 -1
  83. package/dist/src/mcp/catalog/surfaces.d.ts.map +1 -1
  84. package/dist/src/mcp/catalog/surfaces.js +1 -0
  85. package/dist/src/mcp/catalog/surfaces.js.map +1 -1
  86. package/dist/src/mcp/index.d.ts.map +1 -1
  87. package/dist/src/mcp/index.js +2 -0
  88. package/dist/src/mcp/index.js.map +1 -1
  89. package/dist/src/mcp/workflows.d.ts +18 -0
  90. package/dist/src/mcp/workflows.d.ts.map +1 -0
  91. package/dist/src/mcp/workflows.js +68 -0
  92. package/dist/src/mcp/workflows.js.map +1 -0
  93. package/dist/src/middleware/subdomain.d.ts +28 -0
  94. package/dist/src/middleware/subdomain.d.ts.map +1 -0
  95. package/dist/src/middleware/subdomain.js +32 -0
  96. package/dist/src/middleware/subdomain.js.map +1 -0
  97. package/dist/src/models/offer-schemas.d.ts +236 -0
  98. package/dist/src/models/offer-schemas.d.ts.map +1 -0
  99. package/dist/src/models/offer-schemas.js +112 -0
  100. package/dist/src/models/offer-schemas.js.map +1 -0
  101. package/dist/src/models/workflow-schemas.d.ts +220 -0
  102. package/dist/src/models/workflow-schemas.d.ts.map +1 -0
  103. package/dist/src/models/workflow-schemas.js +102 -0
  104. package/dist/src/models/workflow-schemas.js.map +1 -0
  105. package/dist/src/routes/agent-tasks.d.ts.map +1 -1
  106. package/dist/src/routes/agent-tasks.js +49 -0
  107. package/dist/src/routes/agent-tasks.js.map +1 -1
  108. package/dist/src/routes/agents.d.ts.map +1 -1
  109. package/dist/src/routes/agents.js +146 -1
  110. package/dist/src/routes/agents.js.map +1 -1
  111. package/dist/src/routes/apps-backup.d.ts +20 -0
  112. package/dist/src/routes/apps-backup.d.ts.map +1 -0
  113. package/dist/src/routes/apps-backup.js +165 -0
  114. package/dist/src/routes/apps-backup.js.map +1 -0
  115. package/dist/src/routes/ghii.d.ts.map +1 -1
  116. package/dist/src/routes/ghii.js +4 -0
  117. package/dist/src/routes/ghii.js.map +1 -1
  118. package/dist/src/routes/instances.d.ts +2 -1
  119. package/dist/src/routes/instances.d.ts.map +1 -1
  120. package/dist/src/routes/instances.js +59 -1
  121. package/dist/src/routes/instances.js.map +1 -1
  122. package/dist/src/routes/memory.d.ts.map +1 -1
  123. package/dist/src/routes/memory.js +5 -0
  124. package/dist/src/routes/memory.js.map +1 -1
  125. package/dist/src/routes/packages.d.ts.map +1 -1
  126. package/dist/src/routes/packages.js +32 -0
  127. package/dist/src/routes/packages.js.map +1 -1
  128. package/dist/src/routes/permissions.d.ts +12 -0
  129. package/dist/src/routes/permissions.d.ts.map +1 -1
  130. package/dist/src/routes/permissions.js +35 -3
  131. package/dist/src/routes/permissions.js.map +1 -1
  132. package/dist/src/routes/portal.d.ts +3 -0
  133. package/dist/src/routes/portal.d.ts.map +1 -1
  134. package/dist/src/routes/portal.js +12 -0
  135. package/dist/src/routes/portal.js.map +1 -1
  136. package/dist/src/routes/public-stats.d.ts +15 -0
  137. package/dist/src/routes/public-stats.d.ts.map +1 -0
  138. package/dist/src/routes/public-stats.js +90 -0
  139. package/dist/src/routes/public-stats.js.map +1 -0
  140. package/dist/src/routes/sse.d.ts +7 -2
  141. package/dist/src/routes/sse.d.ts.map +1 -1
  142. package/dist/src/routes/sse.js +35 -5
  143. package/dist/src/routes/sse.js.map +1 -1
  144. package/dist/src/routes/stats.d.ts.map +1 -1
  145. package/dist/src/routes/stats.js +13 -0
  146. package/dist/src/routes/stats.js.map +1 -1
  147. package/dist/src/routes/subdomains.d.ts +33 -0
  148. package/dist/src/routes/subdomains.d.ts.map +1 -0
  149. package/dist/src/routes/subdomains.js +208 -0
  150. package/dist/src/routes/subdomains.js.map +1 -0
  151. package/dist/src/routes/workflows.d.ts +30 -0
  152. package/dist/src/routes/workflows.d.ts.map +1 -0
  153. package/dist/src/routes/workflows.js +178 -0
  154. package/dist/src/routes/workflows.js.map +1 -0
  155. package/dist/src/server-bootstrap/routes-loader.d.ts +2 -0
  156. package/dist/src/server-bootstrap/routes-loader.d.ts.map +1 -1
  157. package/dist/src/server-bootstrap/routes-loader.js +19 -2
  158. package/dist/src/server-bootstrap/routes-loader.js.map +1 -1
  159. package/dist/src/server-bootstrap/service-init.d.ts +2 -0
  160. package/dist/src/server-bootstrap/service-init.d.ts.map +1 -1
  161. package/dist/src/server-bootstrap/service-init.js +6 -0
  162. package/dist/src/server-bootstrap/service-init.js.map +1 -1
  163. package/dist/src/server.d.ts.map +1 -1
  164. package/dist/src/server.js +5 -0
  165. package/dist/src/server.js.map +1 -1
  166. package/dist/src/services/apps-backup-export.d.ts +22 -0
  167. package/dist/src/services/apps-backup-export.d.ts.map +1 -0
  168. package/dist/src/services/apps-backup-export.js +136 -0
  169. package/dist/src/services/apps-backup-export.js.map +1 -0
  170. package/dist/src/services/apps-backup-import.d.ts +120 -0
  171. package/dist/src/services/apps-backup-import.d.ts.map +1 -0
  172. package/dist/src/services/apps-backup-import.js +259 -0
  173. package/dist/src/services/apps-backup-import.js.map +1 -0
  174. package/dist/src/services/component-registrar.d.ts +17 -0
  175. package/dist/src/services/component-registrar.d.ts.map +1 -1
  176. package/dist/src/services/component-registrar.js +63 -5
  177. package/dist/src/services/component-registrar.js.map +1 -1
  178. package/dist/src/services/handbooks/agent.d.ts +1 -1
  179. package/dist/src/services/handbooks/agent.d.ts.map +1 -1
  180. package/dist/src/services/handbooks/agent.js +10 -0
  181. package/dist/src/services/handbooks/agent.js.map +1 -1
  182. package/dist/src/services/handbooks/appdev.d.ts +1 -1
  183. package/dist/src/services/handbooks/appdev.d.ts.map +1 -1
  184. package/dist/src/services/handbooks/appdev.js +5 -2
  185. package/dist/src/services/handbooks/appdev.js.map +1 -1
  186. package/dist/src/services/scheduler.d.ts +6 -0
  187. package/dist/src/services/scheduler.d.ts.map +1 -1
  188. package/dist/src/services/scheduler.js +22 -0
  189. package/dist/src/services/scheduler.js.map +1 -1
  190. package/dist/src/services/schema-validator.d.ts +9 -0
  191. package/dist/src/services/schema-validator.d.ts.map +1 -1
  192. package/dist/src/services/schema-validator.js +16 -0
  193. package/dist/src/services/schema-validator.js.map +1 -1
  194. package/dist/src/services/workflow/engine.d.ts +84 -0
  195. package/dist/src/services/workflow/engine.d.ts.map +1 -0
  196. package/dist/src/services/workflow/engine.js +545 -0
  197. package/dist/src/services/workflow/engine.js.map +1 -0
  198. package/dist/src/services/workflow/eval-context.d.ts +23 -0
  199. package/dist/src/services/workflow/eval-context.d.ts.map +1 -0
  200. package/dist/src/services/workflow/eval-context.js +52 -0
  201. package/dist/src/services/workflow/eval-context.js.map +1 -0
  202. package/dist/src/services/workflow/lifecycle.d.ts +38 -0
  203. package/dist/src/services/workflow/lifecycle.d.ts.map +1 -0
  204. package/dist/src/services/workflow/lifecycle.js +99 -0
  205. package/dist/src/services/workflow/lifecycle.js.map +1 -0
  206. package/dist/src/services/workflow/signal-eval.d.ts +70 -0
  207. package/dist/src/services/workflow/signal-eval.d.ts.map +1 -0
  208. package/dist/src/services/workflow/signal-eval.js +174 -0
  209. package/dist/src/services/workflow/signal-eval.js.map +1 -0
  210. package/dist/src/services/workflow/store.d.ts +89 -0
  211. package/dist/src/services/workflow/store.d.ts.map +1 -0
  212. package/dist/src/services/workflow/store.js +284 -0
  213. package/dist/src/services/workflow/store.js.map +1 -0
  214. package/dist/src/storage/interface.d.ts +13 -3
  215. package/dist/src/storage/interface.d.ts.map +1 -1
  216. package/dist/src/storage/interface.js.map +1 -1
  217. package/dist/src/storage/providers/mongodb/index.d.ts +10 -1
  218. package/dist/src/storage/providers/mongodb/index.d.ts.map +1 -1
  219. package/dist/src/storage/providers/mongodb/index.js +76 -0
  220. package/dist/src/storage/providers/mongodb/index.js.map +1 -1
  221. package/dist/src/storage/providers/sqlite/index.d.ts +8 -1
  222. package/dist/src/storage/providers/sqlite/index.d.ts.map +1 -1
  223. package/dist/src/storage/providers/sqlite/index.js +61 -0
  224. package/dist/src/storage/providers/sqlite/index.js.map +1 -1
  225. package/dist/src/storage/providers/sqlite/schema.d.ts.map +1 -1
  226. package/dist/src/storage/providers/sqlite/schema.js +11 -0
  227. package/dist/src/storage/providers/sqlite/schema.js.map +1 -1
  228. package/dist/src/storage/repositories/index.d.ts +1 -0
  229. package/dist/src/storage/repositories/index.d.ts.map +1 -1
  230. package/dist/src/storage/repositories/package.repository.d.ts +2 -0
  231. package/dist/src/storage/repositories/package.repository.d.ts.map +1 -1
  232. package/dist/src/storage/repositories/subdomain-site.repository.d.ts +19 -0
  233. package/dist/src/storage/repositories/subdomain-site.repository.d.ts.map +1 -0
  234. package/dist/src/storage/repositories/subdomain-site.repository.js +2 -0
  235. package/dist/src/storage/repositories/subdomain-site.repository.js.map +1 -0
  236. package/dist/static/app-catalog.html +1139 -28
  237. package/package.json +1 -1
  238. package/prisma/schema.postgres.prisma +11 -0
  239. package/prisma/schema.prisma +11 -0
@@ -0,0 +1,244 @@
1
+ /**
2
+ * @file workflows-tab.js
3
+ * @description Profile › Workflows — the owner-facing surface for Agent Workflows (declared, ordered
4
+ * agent pipelines with per-step input/output signals). Three views: a list of workflows with a
5
+ * health sparkline; a detail view showing the derived blueprint (the "whole workflow" graph) + the
6
+ * recent runs; and a single-run view with the per-step timeline (state + expected-vs-observed).
7
+ * Run-now offers a signals-only health check or a full live run. Reads the /v1/workflows API; the
8
+ * deterministic engine is node-owned. See docs/plans/2026-06-13-agent-workflows-node-plan.md §12.
9
+ * @structure WorkflowsTab (default) — view state machine (list | detail | run)
10
+ * @usage Registered in profile.js TABS as { id:'workflows', component: WorkflowsTab }.
11
+ * @version-history
12
+ * v1.0.0 -- 2026-06-13 -- Phase 9: list + blueprint + runs + run-now + health.
13
+ */
14
+ import { h } from 'preact';
15
+ import { useState, useEffect, useRef, useCallback } from 'preact/hooks';
16
+ import htm from 'htm';
17
+ import { t } from '/js/i18n.js';
18
+ import { timeAgo } from '/js/utils.js';
19
+ import { listWorkflows, getWorkflow, getBlueprint, getHealth, listRuns, getRun, runWorkflow } from '/js/services/workflows.js';
20
+ import WorkflowForm from './workflows-form.js';
21
+
22
+ const html = htm.bind(h);
23
+
24
+ /** Pick a display string from a localized value (string | { locale: text }). */
25
+ function loc(s) {
26
+ if (!s) return '';
27
+ if (typeof s === 'string') return s;
28
+ return s.en_US || s.fi_FI || Object.values(s)[0] || '';
29
+ }
30
+
31
+ function triggerSummary(trigger) {
32
+ if (!trigger) return '';
33
+ if (trigger.kind === 'schedule') return `${t('profile.workflows.trigger.schedule')} · ${trigger.cron}${trigger.timezone ? ` (${trigger.timezone})` : ''}`;
34
+ if (trigger.kind === 'event') return `${t('profile.workflows.trigger.event')} · ${trigger.on}`;
35
+ return t('profile.workflows.trigger.manual');
36
+ }
37
+
38
+ /** Map a run/step status to a badge CSS modifier. */
39
+ function statusClass(status) {
40
+ if (status === 'done' || status === 'green') return 'wf-badge--ok';
41
+ if (status === 'partial' || status === 'red' || (typeof status === 'string' && status.endsWith('-red')) || status === 'timed-out') return 'wf-badge--err';
42
+ if (status === 'skipped') return 'wf-badge--muted';
43
+ return 'wf-badge--run';
44
+ }
45
+
46
+ function StatusBadge({ status }) {
47
+ if (!status) return html`<span class="wf-muted">—</span>`;
48
+ return html`<span class="wf-badge ${statusClass(status)}">${status}</span>`;
49
+ }
50
+
51
+ /** A tiny sparkline of the last-N run states for one step (green/red bars). */
52
+ function Sparkline({ steps }) {
53
+ if (!steps || steps.length === 0) return html`<span class="wf-muted">—</span>`;
54
+ return html`<span class="wf-spark" title=${t('profile.workflows.health.title')}>
55
+ ${steps.map(s => {
56
+ const total = s.green + s.red;
57
+ const cls = total === 0 ? 'wf-spark-bar--none' : s.red > 0 ? 'wf-spark-bar--err' : 'wf-spark-bar--ok';
58
+ return html`<span class="wf-spark-bar ${cls}" title=${`${s.stepId}: ${s.green}✓ / ${s.red}✗`}></span>`;
59
+ })}
60
+ </span>`;
61
+ }
62
+
63
+ export default function WorkflowsTab({ showToast }) {
64
+ // view: { name:'list' } | { name:'detail', id } | { name:'run', id, runId }
65
+ const [view, setView] = useState({ name: 'list' });
66
+ const [items, setItems] = useState([]); // [{ def, health }]
67
+ const [loading, setLoading] = useState(true);
68
+ const [error, setError] = useState(null);
69
+
70
+ const loadList = useCallback(async () => {
71
+ try {
72
+ const res = await listWorkflows();
73
+ const defs = res?.data?.workflows || [];
74
+ const withHealth = await Promise.all(defs.map(async (def) => {
75
+ const hr = await getHealth(def.id).catch(() => null);
76
+ return { def, health: hr?.data || null };
77
+ }));
78
+ setItems(withHealth);
79
+ setError(null);
80
+ } catch (e) {
81
+ setError(e.message || 'Failed to load workflows');
82
+ } finally {
83
+ setLoading(false);
84
+ }
85
+ }, []);
86
+
87
+ const loadRef = useRef(loadList);
88
+ loadRef.current = loadList;
89
+ useEffect(() => {
90
+ loadList();
91
+ const handler = () => { if (view.name === 'list') loadRef.current(); };
92
+ window.addEventListener('aimeat-live-update', handler);
93
+ return () => window.removeEventListener('aimeat-live-update', handler);
94
+ }, [loadList, view.name]);
95
+
96
+ const doRun = async (id, mode) => {
97
+ try {
98
+ const res = await runWorkflow(id, mode);
99
+ const runId = res?.data?.runId;
100
+ showToast?.(t('profile.workflows.runStarted'), 'success');
101
+ if (runId) setView({ name: 'run', id, runId });
102
+ else loadList();
103
+ } catch (e) {
104
+ showToast?.(e.message || 'Run failed', 'error');
105
+ }
106
+ };
107
+
108
+ if (loading) return html`<div class="wf-loading">${t('profile.workflows.loading')}</div>`;
109
+ if (view.name === 'create') return html`<${WorkflowForm} existing=${null} showToast=${showToast}
110
+ onCancel=${() => setView({ name: 'list' })} onSaved=${(id) => { setView({ name: 'detail', id }); }} />`;
111
+ if (view.name === 'edit') return html`<${EditFormView} id=${view.id} showToast=${showToast}
112
+ onCancel=${() => setView({ name: 'detail', id: view.id })} onSaved=${(id) => setView({ name: 'detail', id })} />`;
113
+ if (view.name === 'detail') return html`<${DetailView} id=${view.id} onBack=${() => { setView({ name: 'list' }); loadList(); }} onOpenRun=${(runId) => setView({ name: 'run', id: view.id, runId })} onRun=${doRun} onEdit=${() => setView({ name: 'edit', id: view.id })} />`;
114
+ if (view.name === 'run') return html`<${RunView} id=${view.id} runId=${view.runId} onBack=${() => setView({ name: 'detail', id: view.id })} />`;
115
+
116
+ // ── list ──
117
+ return html`
118
+ <div class="wf-tab">
119
+ <div class="wf-head">
120
+ <div>
121
+ <div class="section-title">${t('profile.workflows.title')}</div>
122
+ <div class="section-desc">${t('profile.workflows.desc')}</div>
123
+ </div>
124
+ <button class="btn-primary" onClick=${() => setView({ name: 'create' })}>+ ${t('profile.workflows.new')}</button>
125
+ </div>
126
+ ${error && html`<div class="wf-error">${error}</div>`}
127
+ ${items.length === 0
128
+ ? html`<div class="wf-empty">${t('profile.workflows.empty')}</div>`
129
+ : html`<div class="wf-card-list">
130
+ ${items.map(({ def, health }) => html`
131
+ <div class="wf-card" key=${def.id}>
132
+ <div class="wf-card-main" onClick=${() => setView({ name: 'detail', id: def.id })}>
133
+ <div class="wf-card-title">
134
+ ${loc(def.title) || def.id}
135
+ <${StatusBadge} status=${health?.lastStatus} />
136
+ </div>
137
+ <div class="wf-card-meta">${triggerSummary(def.trigger)}</div>
138
+ <div class="wf-card-meta">
139
+ ${t('profile.workflows.stepCount', { count: def.steps?.length || 0 })}
140
+ ${health?.lastRunAt ? html` · ${t('profile.workflows.lastRun')} ${timeAgo(health.lastRunAt)}` : ''}
141
+ </div>
142
+ <${Sparkline} steps=${health?.steps} />
143
+ </div>
144
+ <div class="wf-card-actions">
145
+ <button class="btn-outline" onClick=${() => doRun(def.id, 'signals-only')}>${t('profile.workflows.check')}</button>
146
+ <button class="btn-primary" onClick=${() => doRun(def.id, 'full')}>${t('profile.workflows.run')}</button>
147
+ </div>
148
+ </div>`)}
149
+ </div>`}
150
+ </div>`;
151
+ }
152
+
153
+ // ── Detail: blueprint + recent runs ─────────────────────────────────────────────
154
+ function EditFormView({ id, onCancel, onSaved, showToast }) {
155
+ const [def, setDef] = useState(null);
156
+ const [err, setErr] = useState(null);
157
+ useEffect(() => { getWorkflow(id).then(r => setDef(r?.data || null)).catch(e => setErr(e.message)); }, [id]);
158
+ if (err) return html`<div class="wf-tab"><div class="wf-error">${err}</div></div>`;
159
+ if (!def) return html`<div class="wf-loading">${t('profile.workflows.loading')}</div>`;
160
+ return html`<${WorkflowForm} existing=${def} showToast=${showToast} onCancel=${onCancel} onSaved=${onSaved} />`;
161
+ }
162
+
163
+ function DetailView({ id, onBack, onOpenRun, onRun, onEdit }) {
164
+ const [blueprint, setBlueprint] = useState(null);
165
+ const [runs, setRuns] = useState([]);
166
+ const [err, setErr] = useState(null);
167
+
168
+ const load = useCallback(async () => {
169
+ const [bp, rr] = await Promise.all([getBlueprint(id).catch(e => ({ _err: e.message })), listRuns(id).catch(() => null)]);
170
+ if (bp?._err) setErr(bp._err); else setBlueprint(bp?.data || null);
171
+ setRuns(rr?.data?.runs || []);
172
+ }, [id]);
173
+ useEffect(() => { load(); }, [load]);
174
+
175
+ return html`
176
+ <div class="wf-tab">
177
+ <div class="wf-detail-head">
178
+ <button class="btn-ghost" onClick=${onBack}>← ${t('profile.workflows.back')}</button>
179
+ <div class="wf-detail-title">${id}</div>
180
+ <div class="wf-detail-actions">
181
+ <button class="btn-ghost" onClick=${onEdit}>${t('profile.workflows.edit')}</button>
182
+ <button class="btn-outline" onClick=${() => onRun(id, 'signals-only')}>${t('profile.workflows.check')}</button>
183
+ <button class="btn-primary" onClick=${() => onRun(id, 'full')}>${t('profile.workflows.run')}</button>
184
+ </div>
185
+ </div>
186
+
187
+ ${err && html`<div class="wf-error">${err}</div>`}
188
+
189
+ <div class="wf-section-title">${t('profile.workflows.blueprint')}</div>
190
+ ${blueprint && html`<div class="wf-graph">
191
+ ${blueprint.nodes.map(n => html`<div class="wf-node" key=${n.stepId}>
192
+ <div class="wf-node-id">${n.stepId}</div>
193
+ <div class="wf-node-agent">${(n.agents || []).join(', ')} · ${n.offerId}</div>
194
+ ${n.reads.length > 0 && html`<div class="wf-node-io">↘ ${n.reads.join(', ')}</div>`}
195
+ ${n.writes.length > 0 && html`<div class="wf-node-io">↗ ${n.writes.join(', ')}</div>`}
196
+ ${(() => {
197
+ const deps = (blueprint.edges || []).filter(e => e.to === n.stepId).map(e => e.from);
198
+ return deps.length > 0 ? html`<div class="wf-node-dep">${t('profile.workflows.after')}: ${deps.join(', ')}</div>` : '';
199
+ })()}
200
+ </div>`)}
201
+ </div>`}
202
+
203
+ <div class="wf-section-title">${t('profile.workflows.recentRuns')}</div>
204
+ ${runs.length === 0
205
+ ? html`<div class="wf-empty">${t('profile.workflows.noRuns')}</div>`
206
+ : html`<table class="wf-table"><tbody>
207
+ ${runs.map(r => html`<tr key=${r.runId} class="wf-run-row" onClick=${() => onOpenRun(r.runId)}>
208
+ <td>${timeAgo(r.startedAt)}</td>
209
+ <td><${StatusBadge} status=${r.status} /></td>
210
+ <td class="wf-muted">${r.mode}</td>
211
+ </tr>`)}
212
+ </tbody></table>`}
213
+ </div>`;
214
+ }
215
+
216
+ // ── Run: per-step timeline ──────────────────────────────────────────────────────
217
+ function RunView({ id, runId, onBack }) {
218
+ const [run, setRun] = useState(null);
219
+ const [err, setErr] = useState(null);
220
+ useEffect(() => { getRun(id, runId).then(r => setRun(r?.data || null)).catch(e => setErr(e.message)); }, [id, runId]);
221
+
222
+ return html`
223
+ <div class="wf-tab">
224
+ <div class="wf-detail-head">
225
+ <button class="btn-ghost" onClick=${onBack}>← ${t('profile.workflows.back')}</button>
226
+ <div class="wf-detail-title">${t('profile.workflows.run')} · ${run ? timeAgo(run.startedAt) : runId.slice(0, 8)}</div>
227
+ ${run && html`<${StatusBadge} status=${run.status} />`}
228
+ </div>
229
+ ${err && html`<div class="wf-error">${err}</div>`}
230
+ ${run && html`<div class="wf-steps">
231
+ ${Object.entries(run.steps).map(([stepId, s]) => html`<div class="wf-step" key=${stepId}>
232
+ <div class="wf-step-row">
233
+ <${StatusBadge} status=${s.state} />
234
+ <span class="wf-step-id">${stepId}</span>
235
+ ${s.reads?.length > 0 && html`<span class="wf-muted">↘ ${s.reads.length}</span>`}
236
+ ${s.writes?.length > 0 && html`<span class="wf-muted">↗ ${s.writes.length}</span>`}
237
+ ${s.attempt > 0 && html`<span class="wf-muted">${t('profile.workflows.attempt')} ${s.attempt + 1}</span>`}
238
+ </div>
239
+ ${(s.outputObserved || s.inputObserved) && html`<pre class="wf-observed">${JSON.stringify(s.outputObserved || s.inputObserved, null, 2)}</pre>`}
240
+ </div>`)}
241
+ ${(run.inspections || []).length > 0 && html`<div class="wf-inspections">${t('profile.workflows.inspectorDispatched', { count: run.inspections.length })}</div>`}
242
+ </div>`}
243
+ </div>`;
244
+ }
@@ -58,6 +58,7 @@ import SecurityTab from './profile/security-tab.js';
58
58
  import EmailTab from './profile/email-tab.js';
59
59
  import KnowledgeTab from './profile/knowledge-tab.js';
60
60
  import OrganismsTab from './profile/organisms-tab.js';
61
+ import OffersTab from './profile/offers-tab.js';
61
62
  import NotificationsTab from './profile/notifications-tab.js';
62
63
  import GeneratorTab from './profile/generator-tab.js';
63
64
  import FoundryTab from './profile/foundry-tab.js';
@@ -65,6 +66,7 @@ import CalibratorTab from './profile/calibrator-tab.js';
65
66
  import PackagesTab from './profile/packages-tab.js';
66
67
  import CapabilitiesTab from './profile/capabilities-tab.js';
67
68
  import SchedulerTab from './profile/scheduler-tab.js';
69
+ import WorkflowsTab from './profile/workflows-tab.js';
68
70
 
69
71
  // Each tab has a minTier: 'new' | 'active' | 'experienced'
70
72
  // Tabs with minTier <= current tier are visible in the tab bar.
@@ -72,7 +74,9 @@ import SchedulerTab from './profile/scheduler-tab.js';
72
74
  const TABS = [
73
75
  { id: 'portfolio', key: 'portfolio.tabLabel', component: PortfolioTab, minTier: 'active' },
74
76
  { id: 'agents', key: 'profile.tabs.agents', component: AgentsTab, minTier: 'active' },
77
+ { id: 'offers', key: 'profile.tabs.offers', component: OffersTab, minTier: 'active' },
75
78
  { id: 'scheduler', key: 'profile.tabs.scheduler', component: SchedulerTab, minTier: 'active' },
79
+ { id: 'workflows', key: 'profile.tabs.workflows', component: WorkflowsTab, minTier: 'active' },
76
80
  { id: 'chatsessions', key: 'profile.tabs.chatSessions', component: ChatSessionsTab, minTier: 'active' },
77
81
  { id: 'mcp', key: 'profile.tabs.mcp', component: McpTab, minTier: 'active' },
78
82
  { id: 'wallet', key: 'profile.tabs.wallet', component: WalletTab, minTier: 'new' },
@@ -0,0 +1,281 @@
1
+ /**
2
+ * @file start-flows.js
3
+ * @description Data + logic for the /v1/start diagnosis page: entrance configs
4
+ * (per LinkedIn-post angle, selected via ?from=), diagnostic questions with
5
+ * scores, verdict tiers, the build questions (path / tool / need / automation)
6
+ * and the playbook builder that turns the answers into a checklist with real,
7
+ * verified attach commands (sourced from connect.html — do not invent new ones).
8
+ * All user-visible copy is i18n key + English fallback pairs `{ k, f }`,
9
+ * resolved by the view; Finnish lives in locales/fi.json.
10
+ * @structure ENTRANCES, BUILD_QUESTIONS, scoreAnswers(), tierFor(),
11
+ * buildPlaybook(), playbookToMarkdown()
12
+ * @usage import { ENTRANCES, ... } from './start-flows.js' (relative — no importmap entry)
13
+ * @version-history
14
+ * v1.0.0 — 2026-06-11 — Initial: jira + default entrances, 4 verdict tiers,
15
+ * hosted/self/help playbooks (Spider rules: diagnosis framing, shareable
16
+ * verdict, ends in a copyable prompt, no email gate).
17
+ */
18
+
19
+ // ── Diagnostic questions (shared by jira + default entrances) ──
20
+
21
+ const Q_IDEA_FATE = {
22
+ id: 'ideaFate',
23
+ title: { k: 'start.q1.title', f: 'When someone drops a good idea, what happens to it?' },
24
+ options: [
25
+ { id: 'prod', score: 3, text: { k: 'start.q1.prod', f: "It's in production before the evening news" } },
26
+ { id: 'backlog', score: 1, text: { k: 'start.q1.backlog', f: 'Into the backlog. Groomed. Maybe Q3.' } },
27
+ { id: 'grave', score: 0, text: { k: 'start.q1.grave', f: "It's taken to JIRA to die. Ceremonies twice a week." } },
28
+ { id: 'chaos', score: 0, text: { k: 'start.q1.chaos', f: 'Nowhere. Someone might remember it next week.' } },
29
+ ],
30
+ };
31
+
32
+ const Q_AI_MEMORY = {
33
+ id: 'aiMemory',
34
+ title: { k: 'start.q2.title', f: 'What does your AI remember about yesterday?' },
35
+ options: [
36
+ { id: 'all', score: 3, text: { k: 'start.q2.all', f: 'Everything: it has a memory, a task queue and a work history' } },
37
+ { id: 'paste', score: 1, text: { k: 'start.q2.paste', f: 'Whatever I bother to copy-paste into the chat' } },
38
+ { id: 'none', score: 0, text: { k: 'start.q2.none', f: 'Nothing. I reintroduce myself to it every morning.' } },
39
+ ],
40
+ };
41
+
42
+ const Q_AGENT_HOME = {
43
+ id: 'agentHome',
44
+ title: { k: 'start.q3.title', f: "Where does your AI's work live?" },
45
+ options: [
46
+ { id: 'home', score: 3, text: { k: 'start.q3.home', f: 'In a shared home where the team and other agents can find it' } },
47
+ { id: 'disk', score: 1, text: { k: 'start.q3.disk', f: 'On my machine, in a folder called final_v3_REAL' } },
48
+ { id: 'scattered', score: 0, text: { k: 'start.q3.scattered', f: 'Scattered across chat histories. Nobody digs those up.' } },
49
+ ],
50
+ };
51
+
52
+ // ── Entrances — one per LinkedIn-post angle (?from=jira|sotku|omistus).
53
+ // sotku/omistus copy is not written yet; they fall back to the neutral
54
+ // entrance so the links can ship before their entrance copy does. ──
55
+
56
+ export const ENTRANCES = {
57
+ jira: {
58
+ id: 'jira',
59
+ title: { k: 'start.jira.title', f: 'How dead is your JIRA?' },
60
+ sub: { k: 'start.jira.sub', f: 'The diagnosis takes 90 seconds. No email gate, no form, no sales call. At the end you get a verdict and a playbook for trying the cure yourself.' },
61
+ questions: [Q_IDEA_FATE, Q_AI_MEMORY, Q_AGENT_HOME],
62
+ },
63
+ default: {
64
+ id: 'default',
65
+ title: { k: 'start.def.title', f: 'What shape are your agents in?' },
66
+ sub: { k: 'start.def.sub', f: 'The diagnosis takes 90 seconds. No email gate, no form, no sales call. At the end you get a verdict and a playbook for trying the cure yourself.' },
67
+ questions: [Q_IDEA_FATE, Q_AI_MEMORY, Q_AGENT_HOME],
68
+ },
69
+ };
70
+
71
+ export function entranceFor(slug) {
72
+ return ENTRANCES[slug] || ENTRANCES.default;
73
+ }
74
+
75
+ // ── Verdict tiers (max score 9) ──
76
+
77
+ export const TIERS = [
78
+ { id: 't0', min: 0, name: { k: 'start.t0.name', f: 'Level 0: The Graveyard' },
79
+ desc: { k: 'start.t0.desc', f: 'Your ideas die ceremonially and your AI has amnesia. You pay for tools that remember nothing and a process that ships nothing. Good news: the only way is up, and the climb starts below.' } },
80
+ { id: 't1', min: 3, name: { k: 'start.t1.name', f: 'Level 1: In Therapy' },
81
+ desc: { k: 'start.t1.desc', f: 'Your AI goes to therapy, not to work: you carry its context in every morning and it forgets everything by night. You hired a brilliant employee and gave it amnesia.' } },
82
+ { id: 't2', min: 6, name: { k: 'start.t2.name', f: 'Level 2: Working Without a Manager' },
83
+ desc: { k: 'start.t2.desc', f: 'You have agents and they do things, but nothing sticks and nobody runs the whole. Missing: a home, a memory and a manager.' } },
84
+ { id: 't3', min: 8, name: { k: 'start.t3.name', f: 'Level 3: Goes to Work' },
85
+ desc: { k: 'start.t3.desc', f: 'Your agents actually go to work. Rare. Congratulations. Your playbook shows how to scale this and own the whole chain yourself.' } },
86
+ ];
87
+
88
+ export function scoreAnswers(questions, answers) {
89
+ let sum = 0;
90
+ for (const q of questions) {
91
+ const opt = q.options.find((o) => o.id === answers[q.id]);
92
+ if (opt) sum += opt.score;
93
+ }
94
+ return sum;
95
+ }
96
+
97
+ export function tierFor(score) {
98
+ let tier = TIERS[0];
99
+ for (const t of TIERS) if (score >= t.min) tier = t;
100
+ return tier;
101
+ }
102
+
103
+ // ── Build questions (asked after the verdict; they become the playbook) ──
104
+
105
+ export const Q_PATH = {
106
+ id: 'path',
107
+ title: { k: 'start.q4.title', f: 'How do you want to try this?' },
108
+ options: [
109
+ { id: 'hosted', text: { k: 'start.q4.hosted', f: 'Try it first: hosted aimeat.io, nothing to install' } },
110
+ { id: 'self', text: { k: 'start.q4.self', f: "I'll build it myself: my own node on my own hardware (MIT, free)" } },
111
+ { id: 'help', text: { k: 'start.q4.help', f: 'I want help: you do it ($$)' } },
112
+ ],
113
+ };
114
+
115
+ export const Q_TOOL = {
116
+ id: 'tool',
117
+ title: { k: 'start.q5.title', f: 'What tool does your AI live in?' },
118
+ options: [
119
+ { id: 'claude', text: { k: 'start.q5.claude', f: 'Claude (web or desktop)' } },
120
+ { id: 'claudeCode', text: { k: 'start.q5.claudeCode', f: 'Claude Code (terminal)' } },
121
+ { id: 'copilot', text: { k: 'start.q5.copilot', f: 'VS Code + Copilot' } },
122
+ { id: 'cursor', text: { k: 'start.q5.cursor', f: 'Cursor' } },
123
+ { id: 'otherChat', text: { k: 'start.q5.otherChat', f: 'Some other chat (ChatGPT, Gemini, …)' } },
124
+ ],
125
+ };
126
+
127
+ export const Q_NEED = {
128
+ id: 'need',
129
+ title: { k: 'start.q5n.title', f: 'What would you want agents to handle first?' },
130
+ options: [
131
+ { id: 'code', text: { k: 'start.q5n.code', f: 'Code and PRs' } },
132
+ { id: 'docs', text: { k: 'start.q5n.docs', f: 'Documentation and a home for knowledge' } },
133
+ { id: 'watch', text: { k: 'start.q5n.watch', f: "Monitoring and reporting: what's happening, every morning" } },
134
+ { id: 'unsure', text: { k: 'start.q5n.unsure', f: "I don't know yet, that's why I'm asking" } },
135
+ ],
136
+ };
137
+
138
+ export const Q_AUTOMATION = {
139
+ id: 'automation',
140
+ title: { k: 'start.q6.title', f: 'Does the work happen by itself, or when you say so?' },
141
+ options: [
142
+ { id: 'manual', text: { k: 'start.q6.manual', f: 'When I say so: the AI helps when I ask' } },
143
+ { id: 'routine', text: { k: 'start.q6.routine', f: 'An agreed routine: the AI checks the queue regularly' } },
144
+ { id: 'continuous', text: { k: 'start.q6.continuous', f: 'By itself: the AI works while I sleep' } },
145
+ ],
146
+ };
147
+
148
+ /** The build-phase question sequence for a chosen path. The help path skips
149
+ * the automation question — its playbook never uses the answer, and we don't
150
+ * ask what we don't use. */
151
+ export function buildQuestionsFor(answers) {
152
+ if (answers.path === 'help') return [Q_PATH, Q_NEED];
153
+ return [Q_PATH, Q_TOOL, Q_AUTOMATION];
154
+ }
155
+
156
+ // ── Playbook builder ──
157
+ // Returns sections: { title: {k,f}, items: [{ text?: {k,f}, code?: string,
158
+ // prompt?: {k,f}, link?: { href, label: {k,f} } }] }.
159
+ // Commands come from connect.html — keep them verbatim, do not invent.
160
+
161
+ export function buildPlaybook(answers, mcpUrl) {
162
+ const { path, tool, need, automation } = answers;
163
+ const sections = [];
164
+
165
+ if (path === 'help') {
166
+ const needText = { k: `start.q5n.${need}`, f: '' };
167
+ sections.push({
168
+ title: { k: 'start.pb.h1.title', f: 'Step 1: Tell us what you need' },
169
+ items: [
170
+ { text: { k: 'start.pb.h1.a', f: "Send a message to jouni.miikki@aimeat.io. Subject 'Agents', body: your pick below. You'll get an honest assessment: what to build yourself, what to buy." } },
171
+ { text: needText, quote: true },
172
+ ],
173
+ });
174
+ sections.push({
175
+ title: { k: 'start.pb.h2.title', f: 'Step 2: See the pricing' },
176
+ items: [
177
+ { text: { k: 'start.pb.h2.a', f: 'Self-serve tiers and done-for-you packages:' },
178
+ link: { href: '/v1/pricing', label: { k: 'start.pb.h2.link', f: 'See pricing →' } } },
179
+ ],
180
+ });
181
+ sections.push({
182
+ title: { k: 'start.pb.h3.title', f: 'Step 3: Try it meanwhile' },
183
+ items: [
184
+ { text: { k: 'start.pb.h3.a', f: "Nothing stops you from seeing it yourself before paying anything: create a free account and connect your own AI." },
185
+ link: { href: '/v1/portal', label: { k: 'start.pb.h3.link', f: 'Create a free account →' } } },
186
+ ],
187
+ });
188
+ return sections;
189
+ }
190
+
191
+ // Step 1 — account / own node
192
+ if (path === 'self') {
193
+ sections.push({
194
+ title: { k: 'start.pb.s1self.title', f: 'Step 1: Install your own node' },
195
+ items: [
196
+ { text: { k: 'start.pb.s1self.a', f: 'Clone and run the init wizard, it asks the rest:' },
197
+ code: 'git clone https://github.com/miikkij/aimeat-protocol\ncd aimeat-protocol\npnpm install && pnpm aimeat init' },
198
+ { text: { k: 'start.pb.s1self.b', f: 'Everything below is then done against your own node: replace the aimeat.io address with yours. Your hardware, your keys, your data.' } },
199
+ ],
200
+ });
201
+ } else {
202
+ sections.push({
203
+ title: { k: 'start.pb.s1.title', f: 'Step 1: An account and a home' },
204
+ items: [
205
+ { text: { k: 'start.pb.s1.a', f: "Create a free account. No card, no payment. The account is your agent's home and your permission for it to exist." },
206
+ link: { href: '/v1/portal', label: { k: 'start.pb.s1.link', f: 'Create account →' } } },
207
+ ],
208
+ });
209
+ }
210
+
211
+ // Step 2 — connect the AI (per tool, commands verbatim from connect.html)
212
+ const connect = { title: { k: 'start.pb.s2.title', f: 'Step 2: Connect your AI' }, items: [] };
213
+ if (tool === 'claude') {
214
+ connect.items.push({ text: { k: 'start.pb.s2.claude', f: 'Open Claude: Settings → Connectors → Add custom connector, and paste this address:' }, code: mcpUrl });
215
+ connect.items.push({ text: { k: 'start.pb.s2.claudeNote', f: 'The free claude.ai tier fits one custom connector, and that is enough for this.' } });
216
+ } else if (tool === 'claudeCode') {
217
+ connect.items.push({ text: { k: 'start.pb.s2.cli', f: 'Run this in a terminal:' }, code: `claude mcp add aimeat --transport http ${mcpUrl}` });
218
+ } else if (tool === 'copilot') {
219
+ connect.items.push({ text: { k: 'start.pb.s2.cli', f: 'Run this in a terminal:' }, code: `code --add-mcp '{"name":"aimeat","url":"${mcpUrl}"}'` });
220
+ } else if (tool === 'cursor') {
221
+ connect.items.push({ text: { k: 'start.pb.s2.cursor', f: 'Use the 1-click install on the connect page:' },
222
+ link: { href: '/v1/connect', label: { k: 'start.pb.s2.cursorLink', f: 'Open the connect page →' } } });
223
+ } else {
224
+ connect.items.push({ text: { k: 'start.pb.s2.other', f: 'If your tool supports Connectors / custom MCP, paste this address into it:' }, code: mcpUrl });
225
+ connect.items.push({ text: { k: 'start.pb.s2.otherNote', f: "No MCP support? AIMEAT also works prompt-driven: the app composes the prompts, you carry them to your chat and bring the answers back. Free, and works with any AI." } });
226
+ }
227
+ connect.items.push({ text: { k: 'start.pb.s2.approve', f: 'When the AI asks for access, approve the agent in your profile and pick its permissions. No agent is ever created without your approval.' } });
228
+ sections.push(connect);
229
+
230
+ // Step 3 — startup prompt (the conversion: the AI creates the first organism)
231
+ sections.push({
232
+ title: { k: 'start.pb.s3.title', f: 'Step 3: Put your AI to work' },
233
+ items: [
234
+ { text: { k: 'start.pb.s3.lead', f: 'Copy this prompt to your AI:' },
235
+ prompt: { k: 'start.pb.s3.prompt', f: "You are connected to the AIMEAT platform via MCP. Create an organism for me called 'My Office' with a workspace. Then read what's there, ask me what I want you to do, and record my answer as the first task in the workspace. Confirm when the task is saved." } },
236
+ { text: { k: 'start.pb.s3.check', f: 'Check your profile: the task appeared. You just watched the whole loop: idea → memory → task queue. No ceremonies.' } },
237
+ ],
238
+ });
239
+
240
+ // Step 4 — first real job
241
+ sections.push({
242
+ title: { k: 'start.pb.s4.title', f: 'Step 4: The first real job' },
243
+ items: [
244
+ { text: { k: 'start.pb.s4.a', f: 'Give the AI one small, real task from your day: file a note, turn a project status into a document, sort a list.' } },
245
+ { text: { k: 'start.pb.s4.b', f: 'Everything the AI writes stays with you. The memory, the documents and the tasks are yours, not an AI vendor’s.' } },
246
+ ],
247
+ });
248
+
249
+ // Step 5 — automation level
250
+ const auto = { title: { k: 'start.pb.s5.title', f: 'Step 5: Automation level' }, items: [] };
251
+ if (automation === 'continuous') {
252
+ auto.items.push({ text: { k: 'start.pb.s5.continuous', f: 'You picked: by itself. A connector serve daemon runs your agent in the background and tasks arrive as pushes, no polling. A fleet of 33 agents runs in production on this model.' },
253
+ link: { href: '/v1/connect', label: { k: 'start.pb.s5.link', f: 'Connector docs →' } } });
254
+ } else if (automation === 'routine') {
255
+ auto.items.push({ text: { k: 'start.pb.s5.routine', f: 'You picked: an agreed routine. Agree a scheduled check with your AI that reads the task queue regularly. AIMEAT’s own schedules work as the wake-up call and reminder.' } });
256
+ } else {
257
+ auto.items.push({ text: { k: 'start.pb.s5.manual', f: "You picked: when I say so. Start every session with the prompt: 'Read the open tasks in the workspace and handle them.' You are the scheduler, and that is enough to start." } });
258
+ }
259
+ if (automation !== 'continuous') {
260
+ auto.items.push({ text: { k: 'start.pb.s5.upgrade', f: 'You can raise the level any time: by hand → routine → daemon. The playbook does not expire.' } });
261
+ }
262
+ sections.push(auto);
263
+
264
+ return sections;
265
+ }
266
+
267
+ /** Plain-markdown rendering of the playbook for the copy button. */
268
+ export function playbookToMarkdown(sections, trr, titleText) {
269
+ const lines = [`# ${titleText}`, ''];
270
+ for (const s of sections) {
271
+ lines.push(`## ${trr(s.title)}`, '');
272
+ for (const it of s.items) {
273
+ if (it.text) lines.push(it.quote ? `> ${trr(it.text)}` : `- [ ] ${trr(it.text)}`);
274
+ if (it.code) lines.push('', '```', it.code, '```', '');
275
+ if (it.prompt) lines.push('', '> ' + trr(it.prompt), '');
276
+ if (it.link) lines.push(` ${trr(it.link.label)} ${it.link.href}`);
277
+ }
278
+ lines.push('');
279
+ }
280
+ return lines.join('\n');
281
+ }