@lobu/cli 6.0.1 → 7.0.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 (265) hide show
  1. package/README.md +20 -27
  2. package/dist/bundled-skills/lobu/SKILL.md +11 -11
  3. package/dist/commands/_lib/apply/apply-cmd.d.ts +38 -0
  4. package/dist/commands/_lib/apply/apply-cmd.d.ts.map +1 -1
  5. package/dist/commands/_lib/apply/apply-cmd.js +574 -40
  6. package/dist/commands/_lib/apply/apply-cmd.js.map +1 -1
  7. package/dist/commands/_lib/apply/client.d.ts +180 -1
  8. package/dist/commands/_lib/apply/client.d.ts.map +1 -1
  9. package/dist/commands/_lib/apply/client.js +308 -28
  10. package/dist/commands/_lib/apply/client.js.map +1 -1
  11. package/dist/commands/_lib/apply/desired-state.d.ts +134 -3
  12. package/dist/commands/_lib/apply/desired-state.d.ts.map +1 -1
  13. package/dist/commands/_lib/apply/desired-state.js +703 -89
  14. package/dist/commands/_lib/apply/desired-state.js.map +1 -1
  15. package/dist/commands/_lib/apply/diff.d.ts +61 -3
  16. package/dist/commands/_lib/apply/diff.d.ts.map +1 -1
  17. package/dist/commands/_lib/apply/diff.js +382 -92
  18. package/dist/commands/_lib/apply/diff.js.map +1 -1
  19. package/dist/commands/_lib/apply/prompt.d.ts +6 -0
  20. package/dist/commands/_lib/apply/prompt.d.ts.map +1 -1
  21. package/dist/commands/_lib/apply/prompt.js +16 -0
  22. package/dist/commands/_lib/apply/prompt.js.map +1 -1
  23. package/dist/commands/_lib/apply/render.d.ts +9 -0
  24. package/dist/commands/_lib/apply/render.d.ts.map +1 -1
  25. package/dist/commands/_lib/apply/render.js +80 -3
  26. package/dist/commands/_lib/apply/render.js.map +1 -1
  27. package/dist/commands/agent.d.ts +7 -0
  28. package/dist/commands/agent.d.ts.map +1 -1
  29. package/dist/commands/agent.js +65 -1
  30. package/dist/commands/agent.js.map +1 -1
  31. package/dist/commands/chat.d.ts +12 -9
  32. package/dist/commands/chat.d.ts.map +1 -1
  33. package/dist/commands/chat.js +125 -57
  34. package/dist/commands/chat.js.map +1 -1
  35. package/dist/commands/dev.d.ts +23 -7
  36. package/dist/commands/dev.d.ts.map +1 -1
  37. package/dist/commands/dev.js +197 -49
  38. package/dist/commands/dev.js.map +1 -1
  39. package/dist/commands/doctor.d.ts +1 -0
  40. package/dist/commands/doctor.d.ts.map +1 -1
  41. package/dist/commands/doctor.js +136 -0
  42. package/dist/commands/doctor.js.map +1 -1
  43. package/dist/commands/eval.d.ts +8 -0
  44. package/dist/commands/eval.d.ts.map +1 -1
  45. package/dist/commands/eval.js +72 -6
  46. package/dist/commands/eval.js.map +1 -1
  47. package/dist/commands/init.d.ts +22 -5
  48. package/dist/commands/init.d.ts.map +1 -1
  49. package/dist/commands/init.js +355 -182
  50. package/dist/commands/init.js.map +1 -1
  51. package/dist/commands/link.d.ts +11 -0
  52. package/dist/commands/link.d.ts.map +1 -0
  53. package/dist/commands/link.js +28 -0
  54. package/dist/commands/link.js.map +1 -0
  55. package/dist/commands/login.d.ts.map +1 -1
  56. package/dist/commands/login.js +14 -2
  57. package/dist/commands/login.js.map +1 -1
  58. package/dist/commands/memory/_lib/browser-auth-cmd.d.ts.map +1 -1
  59. package/dist/commands/memory/_lib/browser-auth-cmd.js +3 -3
  60. package/dist/commands/memory/_lib/browser-auth-cmd.js.map +1 -1
  61. package/dist/commands/memory/_lib/mcp.d.ts +2 -2
  62. package/dist/commands/memory/_lib/mcp.d.ts.map +1 -1
  63. package/dist/commands/memory/_lib/mcp.js +24 -12
  64. package/dist/commands/memory/_lib/mcp.js.map +1 -1
  65. package/dist/commands/memory/_lib/openclaw-auth.d.ts +1 -0
  66. package/dist/commands/memory/_lib/openclaw-auth.d.ts.map +1 -1
  67. package/dist/commands/memory/_lib/openclaw-auth.js +14 -3
  68. package/dist/commands/memory/_lib/openclaw-auth.js.map +1 -1
  69. package/dist/commands/memory/_lib/openclaw-cmd.js +1 -1
  70. package/dist/commands/memory/_lib/openclaw-cmd.js.map +1 -1
  71. package/dist/commands/memory/_lib/schema.d.ts +29 -2
  72. package/dist/commands/memory/_lib/schema.d.ts.map +1 -1
  73. package/dist/commands/memory/_lib/schema.js +121 -5
  74. package/dist/commands/memory/_lib/schema.js.map +1 -1
  75. package/dist/commands/memory/_lib/seed-cmd.d.ts.map +1 -1
  76. package/dist/commands/memory/_lib/seed-cmd.js +46 -24
  77. package/dist/commands/memory/_lib/seed-cmd.js.map +1 -1
  78. package/dist/commands/memory/run.d.ts.map +1 -1
  79. package/dist/commands/memory/run.js +2 -2
  80. package/dist/commands/memory/run.js.map +1 -1
  81. package/dist/commands/org.d.ts +4 -0
  82. package/dist/commands/org.d.ts.map +1 -1
  83. package/dist/commands/org.js +10 -0
  84. package/dist/commands/org.js.map +1 -1
  85. package/dist/commands/platforms/platform-prompts.d.ts +0 -1
  86. package/dist/commands/platforms/platform-prompts.d.ts.map +1 -1
  87. package/dist/commands/platforms/platform-prompts.js +54 -8
  88. package/dist/commands/platforms/platform-prompts.js.map +1 -1
  89. package/dist/commands/telemetry.d.ts +10 -0
  90. package/dist/commands/telemetry.d.ts.map +1 -0
  91. package/dist/commands/telemetry.js +68 -0
  92. package/dist/commands/telemetry.js.map +1 -0
  93. package/dist/commands/token.d.ts +9 -0
  94. package/dist/commands/token.d.ts.map +1 -1
  95. package/dist/commands/token.js +54 -0
  96. package/dist/commands/token.js.map +1 -1
  97. package/dist/commands/whoami.d.ts.map +1 -1
  98. package/dist/commands/whoami.js +1 -1
  99. package/dist/commands/whoami.js.map +1 -1
  100. package/dist/connectors/README.md +534 -0
  101. package/dist/connectors/__tests__/browser-scraper-utils.test.ts +186 -0
  102. package/dist/connectors/apple_health.ts +138 -0
  103. package/dist/connectors/apple_screen_time.ts +82 -0
  104. package/dist/connectors/browser-scraper-utils.ts +246 -0
  105. package/dist/connectors/capterra.ts +277 -0
  106. package/dist/connectors/g2.ts +290 -0
  107. package/dist/connectors/github.ts +1530 -0
  108. package/dist/connectors/glassdoor.ts +295 -0
  109. package/dist/connectors/gmaps.ts +197 -0
  110. package/dist/connectors/google_calendar.ts +641 -0
  111. package/dist/connectors/google_gmail.ts +754 -0
  112. package/dist/connectors/google_photos.ts +776 -0
  113. package/dist/connectors/google_play.ts +349 -0
  114. package/dist/connectors/hackernews.ts +471 -0
  115. package/dist/connectors/index.ts +28 -0
  116. package/dist/connectors/ios_appstore.ts +226 -0
  117. package/dist/connectors/linkedin.ts +494 -0
  118. package/dist/connectors/local_directory.ts +91 -0
  119. package/dist/connectors/microsoft_outlook.ts +410 -0
  120. package/dist/connectors/producthunt.ts +471 -0
  121. package/dist/connectors/reddit.ts +600 -0
  122. package/dist/connectors/revolut.ts +572 -0
  123. package/dist/connectors/rss.ts +448 -0
  124. package/dist/connectors/spotify.ts +590 -0
  125. package/dist/connectors/trustpilot.ts +203 -0
  126. package/dist/connectors/website.ts +629 -0
  127. package/dist/connectors/whatsapp.ts +1081 -0
  128. package/dist/connectors/whatsapp_local.ts +125 -0
  129. package/dist/connectors/x.ts +536 -0
  130. package/dist/connectors/youtube.ts +666 -0
  131. package/dist/db/migrations/00000000000000_baseline.sql +4867 -0
  132. package/dist/db/migrations/20260405193000_add_mcp_sessions.sql +33 -0
  133. package/dist/db/migrations/20260408120000_remove_system_connectors.sql +48 -0
  134. package/dist/db/migrations/20260408120001_optional_compiled_code.sql +6 -0
  135. package/dist/db/migrations/20260409110000_add_active_watcher_run_index.sql +9 -0
  136. package/dist/db/migrations/20260409130000_connector_default_config.sql +5 -0
  137. package/dist/db/migrations/20260410120000_add_agent_secrets.sql +25 -0
  138. package/dist/db/migrations/20260413170000_add_watcher_group_id.sql +67 -0
  139. package/dist/db/migrations/20260416120000_add_entity_wa_jid_index.sql +14 -0
  140. package/dist/db/migrations/20260417100000_add_entity_identities.sql +77 -0
  141. package/dist/db/migrations/20260418100000_add_auth_runs.sql +83 -0
  142. package/dist/db/migrations/20260418110000_add_runs_created_by_user.sql +18 -0
  143. package/dist/db/migrations/20260419120000_add_event_identity_indexes.sql +56 -0
  144. package/dist/db/migrations/20260420120000_extend_reserved_org_slugs.sql +56 -0
  145. package/dist/db/migrations/20260424030000_add_watcher_run_correlation.sql +52 -0
  146. package/dist/db/migrations/20260424130000_relax_events_client_id_fk.sql +47 -0
  147. package/dist/db/migrations/20260425100000_normalize_watcher_feedback.sql +91 -0
  148. package/dist/db/migrations/20260425120000_add_run_diagnostics.sql +20 -0
  149. package/dist/db/migrations/20260425130000_add_repair_agent_plumbing.sql +46 -0
  150. package/dist/db/migrations/20260426120000_entities_entity_type_fk.sql +101 -0
  151. package/dist/db/migrations/20260426130000_db_integrity_cleanup.sql +104 -0
  152. package/dist/db/migrations/20260426130001_db_integrity_cleanup_concurrent.sql +187 -0
  153. package/dist/db/migrations/20260427133000_events_created_by_nullable.sql +74 -0
  154. package/dist/db/migrations/20260427140000_identity_engine_indexes.sql +140 -0
  155. package/dist/db/migrations/20260427150000_drop_events_source_id.sql +177 -0
  156. package/dist/db/migrations/20260427160000_drop_dead_schema.sql +76 -0
  157. package/dist/db/migrations/20260427170000_market_founder_to_member.sql +364 -0
  158. package/dist/db/migrations/20260428040000_cascade_events_watchers_org_fk.sql +66 -0
  159. package/dist/db/migrations/20260428050000_add_runs_approved_input.sql +9 -0
  160. package/dist/db/migrations/20260429010000_auth_profile_tenant_scoped_fk.sql +79 -0
  161. package/dist/db/migrations/20260429060000_extend_runs_for_lobu_queue.sql +108 -0
  162. package/dist/db/migrations/20260429120000_agent_changed_notify.sql +97 -0
  163. package/dist/db/migrations/20260429120100_user_auth_profiles_and_model_prefs.sql +36 -0
  164. package/dist/db/migrations/20260429120200_fix_notify_old_keys.sql +130 -0
  165. package/dist/db/migrations/20260429130000_oauth_states_cli_sessions_rate_limits.sql +83 -0
  166. package/dist/db/migrations/20260429140000_phase8_grants_chat_connections_mcp_sessions.sql +84 -0
  167. package/dist/db/migrations/20260429140100_runs_priority_expires_at_retry_delay.sql +44 -0
  168. package/dist/db/migrations/20260429180000_drop_invalidatable_cache_triggers.sql +25 -0
  169. package/dist/db/migrations/20260430005614_agents_apply_fields.sql +21 -0
  170. package/dist/db/migrations/20260430022231_fix_connection_config_encryption.sql +69 -0
  171. package/dist/db/migrations/20260430151215_add_task_run_type.sql +77 -0
  172. package/dist/db/migrations/20260501000000_drop_cli_sessions.sql +27 -0
  173. package/dist/db/migrations/20260501133000_lobu_memory_mcp_id.sql +117 -0
  174. package/dist/db/migrations/20260502000000_drop_chat_connections.sql +60 -0
  175. package/dist/db/migrations/20260503000000_agent_secrets_org_scope.sql +56 -0
  176. package/dist/db/migrations/20260504000000_flatten_agents_drop_sandbox_model.sql +48 -0
  177. package/dist/db/migrations/20260510220000_connector_required_capability.sql +47 -0
  178. package/dist/db/migrations/20260512000000_device_worker_connection_binding.sql +113 -0
  179. package/dist/db/migrations/20260512131703_connections_slug.sql +131 -0
  180. package/dist/db/migrations/20260513000000_chat_user_identities.sql +24 -0
  181. package/dist/db/migrations/20260513120000_auth_profiles_device_binding.sql +50 -0
  182. package/dist/db/migrations/20260513150000_auth_profiles_cdp_url.sql +43 -0
  183. package/dist/db/migrations/20260513200000_notifications_as_events.sql +86 -0
  184. package/dist/db/migrations/20260514000000_scheduled_jobs.sql +97 -0
  185. package/dist/db/migrations/20260514120000_auth_profiles_connector_key_nullable.sql +42 -0
  186. package/dist/eval/types.d.ts +2 -0
  187. package/dist/eval/types.d.ts.map +1 -1
  188. package/dist/index.d.ts +11 -0
  189. package/dist/index.d.ts.map +1 -1
  190. package/dist/index.js +210 -132
  191. package/dist/index.js.map +1 -1
  192. package/dist/internal/api-client.d.ts +4 -8
  193. package/dist/internal/api-client.d.ts.map +1 -1
  194. package/dist/internal/api-client.js +1 -1
  195. package/dist/internal/api-client.js.map +1 -1
  196. package/dist/internal/context.js +2 -2
  197. package/dist/internal/context.js.map +1 -1
  198. package/dist/internal/credentials.d.ts.map +1 -1
  199. package/dist/internal/credentials.js +6 -1
  200. package/dist/internal/credentials.js.map +1 -1
  201. package/dist/internal/gateway-url.d.ts +14 -0
  202. package/dist/internal/gateway-url.d.ts.map +1 -1
  203. package/dist/internal/gateway-url.js +19 -0
  204. package/dist/internal/gateway-url.js.map +1 -1
  205. package/dist/internal/index.d.ts +3 -4
  206. package/dist/internal/index.d.ts.map +1 -1
  207. package/dist/internal/index.js +3 -3
  208. package/dist/internal/index.js.map +1 -1
  209. package/dist/internal/oauth.d.ts +6 -5
  210. package/dist/internal/oauth.d.ts.map +1 -1
  211. package/dist/internal/oauth.js +2 -2
  212. package/dist/internal/project-link.d.ts +10 -0
  213. package/dist/internal/project-link.d.ts.map +1 -0
  214. package/dist/internal/project-link.js +48 -0
  215. package/dist/internal/project-link.js.map +1 -0
  216. package/dist/providers.json +2 -2
  217. package/dist/server.bundle.mjs +31654 -30866
  218. package/dist/start-local.bundle.mjs +74409 -0
  219. package/dist/templates/README.md.tmpl +10 -11
  220. package/dist/templates/TESTING.md.tmpl +9 -9
  221. package/package.json +15 -13
  222. package/dist/__tests__/chat.integration.test.d.ts +0 -2
  223. package/dist/__tests__/chat.integration.test.d.ts.map +0 -1
  224. package/dist/__tests__/chat.integration.test.js +0 -337
  225. package/dist/__tests__/chat.integration.test.js.map +0 -1
  226. package/dist/__tests__/dev.test.d.ts +0 -2
  227. package/dist/__tests__/dev.test.d.ts.map +0 -1
  228. package/dist/__tests__/dev.test.js +0 -25
  229. package/dist/__tests__/dev.test.js.map +0 -1
  230. package/dist/__tests__/init-memory.test.d.ts +0 -2
  231. package/dist/__tests__/init-memory.test.d.ts.map +0 -1
  232. package/dist/__tests__/init-memory.test.js +0 -45
  233. package/dist/__tests__/init-memory.test.js.map +0 -1
  234. package/dist/__tests__/token.test.d.ts +0 -2
  235. package/dist/__tests__/token.test.d.ts.map +0 -1
  236. package/dist/__tests__/token.test.js +0 -52
  237. package/dist/__tests__/token.test.js.map +0 -1
  238. package/dist/commands/_lib/apply/__tests__/client.test.d.ts +0 -2
  239. package/dist/commands/_lib/apply/__tests__/client.test.d.ts.map +0 -1
  240. package/dist/commands/_lib/apply/__tests__/client.test.js +0 -23
  241. package/dist/commands/_lib/apply/__tests__/client.test.js.map +0 -1
  242. package/dist/commands/_lib/apply/__tests__/desired-state.test.d.ts +0 -2
  243. package/dist/commands/_lib/apply/__tests__/desired-state.test.d.ts.map +0 -1
  244. package/dist/commands/_lib/apply/__tests__/desired-state.test.js +0 -140
  245. package/dist/commands/_lib/apply/__tests__/desired-state.test.js.map +0 -1
  246. package/dist/commands/_lib/apply/__tests__/diff.test.d.ts +0 -2
  247. package/dist/commands/_lib/apply/__tests__/diff.test.d.ts.map +0 -1
  248. package/dist/commands/_lib/apply/__tests__/diff.test.js +0 -378
  249. package/dist/commands/_lib/apply/__tests__/diff.test.js.map +0 -1
  250. package/dist/commands/apply.d.ts +0 -3
  251. package/dist/commands/apply.d.ts.map +0 -1
  252. package/dist/commands/apply.js +0 -5
  253. package/dist/commands/apply.js.map +0 -1
  254. package/dist/commands/memory/_lib/openclaw-auth.test.d.ts +0 -2
  255. package/dist/commands/memory/_lib/openclaw-auth.test.d.ts.map +0 -1
  256. package/dist/commands/memory/_lib/openclaw-auth.test.js +0 -9
  257. package/dist/commands/memory/_lib/openclaw-auth.test.js.map +0 -1
  258. package/dist/internal/__tests__/api-client.test.d.ts +0 -2
  259. package/dist/internal/__tests__/api-client.test.d.ts.map +0 -1
  260. package/dist/internal/__tests__/api-client.test.js +0 -95
  261. package/dist/internal/__tests__/api-client.test.js.map +0 -1
  262. package/dist/internal/__tests__/context.test.d.ts +0 -2
  263. package/dist/internal/__tests__/context.test.d.ts.map +0 -1
  264. package/dist/internal/__tests__/context.test.js +0 -77
  265. package/dist/internal/__tests__/context.test.js.map +0 -1
@@ -0,0 +1,43 @@
1
+ -- migrate:up
2
+
3
+ -- Add `cdp_url` to auth_profiles. For a device-bound `browser_session`
4
+ -- profile, exactly one of {user_data_dir, cdp_url} should be set:
5
+ -- user_data_dir → managed Chrome with isolated cookies (default)
6
+ -- cdp_url → attach to a running Chrome via remote-debugging-port
7
+ -- The application enforces this invariant; we don't add a CHECK constraint
8
+ -- because the OR-on-NULL semantics are awkward to express and the column
9
+ -- is harmless when both are NULL (legacy fleet path with cookies in
10
+ -- auth_data jsonb).
11
+
12
+ ALTER TABLE public.auth_profiles
13
+ ADD COLUMN IF NOT EXISTS cdp_url text;
14
+
15
+ -- A device-bound browser_session profile MUST set exactly one of
16
+ -- (user_data_dir, cdp_url). Other profile kinds — and non-device-bound
17
+ -- browser_session profiles (cookies in auth_data, fleet-served) — are
18
+ -- exempt. Enforcing this at the DB stops a buggy admin tool or a bad
19
+ -- merge from setting both and then having the connector silently prefer
20
+ -- whichever code path it sees first.
21
+ DO $$
22
+ BEGIN
23
+ IF NOT EXISTS (
24
+ SELECT 1 FROM pg_constraint WHERE conname = 'auth_profiles_device_browser_path_xor'
25
+ ) THEN
26
+ ALTER TABLE public.auth_profiles
27
+ ADD CONSTRAINT auth_profiles_device_browser_path_xor
28
+ CHECK (
29
+ device_worker_id IS NULL
30
+ OR profile_kind <> 'browser_session'
31
+ OR (
32
+ (user_data_dir IS NOT NULL AND cdp_url IS NULL)
33
+ OR (user_data_dir IS NULL AND cdp_url IS NOT NULL)
34
+ )
35
+ );
36
+ END IF;
37
+ END$$;
38
+
39
+ -- migrate:down
40
+
41
+ ALTER TABLE public.auth_profiles
42
+ DROP CONSTRAINT IF EXISTS auth_profiles_device_browser_path_xor,
43
+ DROP COLUMN IF EXISTS cdp_url;
@@ -0,0 +1,86 @@
1
+ -- migrate:up
2
+
3
+ -- Unify notifications with events.
4
+ --
5
+ -- A notification was a (org, user, title, body, type, resource_url) row in
6
+ -- its own table with per-user `is_read`. Conceptually it's an event with a
7
+ -- particular kind + per-user delivery / read-state. This migration turns
8
+ -- every notification into:
9
+ -- 1. an event with semantic_type='notification' (org-wide visibility in
10
+ -- the events stream — searchable, addressable, links into knowledge);
11
+ -- 2. a notification_targets row (event_id, user_id, delivered_at, read_at)
12
+ -- so the inbox still scopes to the targeted user.
13
+ --
14
+ -- After this, "send to admins" inserts one event + N targets; "mark read"
15
+ -- updates a target row; "unread count" counts target rows without read_at.
16
+ -- Search across events naturally includes notifications, but a user's
17
+ -- inbox is still private to them.
18
+
19
+ CREATE TABLE public.notification_targets (
20
+ event_id bigint NOT NULL REFERENCES public.events(id) ON DELETE CASCADE,
21
+ user_id text NOT NULL,
22
+ delivered_at timestamp with time zone NOT NULL DEFAULT now(),
23
+ read_at timestamp with time zone,
24
+ PRIMARY KEY (event_id, user_id)
25
+ );
26
+
27
+ -- Fast inbox lookups: list a user's unread notifications, newest first.
28
+ CREATE INDEX idx_notification_targets_user_unread
29
+ ON public.notification_targets (user_id, delivered_at DESC)
30
+ WHERE read_at IS NULL;
31
+
32
+ -- All of a user's notifications, newest first (for read-list pagination).
33
+ CREATE INDEX idx_notification_targets_user_all
34
+ ON public.notification_targets (user_id, delivered_at DESC);
35
+
36
+ -- Backfill existing notifications. We keep 1:1 row mapping (one event per
37
+ -- legacy notification) for safety — at scale the right model is "one event,
38
+ -- many targets" but the old schema didn't capture that and we can't
39
+ -- retroactively coalesce without an oracle.
40
+ WITH legacy AS (
41
+ SELECT id, organization_id, user_id, type, title, body,
42
+ resource_type, resource_id, resource_url, is_read, created_at
43
+ FROM public.notifications
44
+ ORDER BY id ASC
45
+ ),
46
+ inserted AS (
47
+ INSERT INTO public.events
48
+ (organization_id, title, payload_text, payload_type, semantic_type,
49
+ occurred_at, created_at, metadata, origin_id)
50
+ SELECT
51
+ l.organization_id,
52
+ l.title,
53
+ l.body,
54
+ 'text',
55
+ 'notification',
56
+ l.created_at,
57
+ l.created_at,
58
+ jsonb_build_object(
59
+ 'notification_type', l.type,
60
+ 'resource_type', l.resource_type,
61
+ 'resource_id', l.resource_id,
62
+ 'resource_url', l.resource_url,
63
+ 'legacy_notification_id', l.id
64
+ ),
65
+ 'notification:legacy:' || l.id::text
66
+ FROM legacy l
67
+ RETURNING id AS event_id, (metadata->>'legacy_notification_id')::bigint AS legacy_id
68
+ )
69
+ INSERT INTO public.notification_targets (event_id, user_id, delivered_at, read_at)
70
+ SELECT
71
+ i.event_id,
72
+ l.user_id,
73
+ l.created_at,
74
+ CASE WHEN l.is_read THEN l.created_at ELSE NULL END
75
+ FROM inserted i
76
+ JOIN public.notifications l ON l.id = i.legacy_id;
77
+
78
+ -- Drop the legacy table. All readers/writers go through the new service.
79
+ DROP TABLE public.notifications;
80
+
81
+ -- migrate:down
82
+
83
+ -- One-way migration. Recovery is from backup; events created here stay
84
+ -- (deleting them would also wipe their notification_targets via CASCADE).
85
+ -- If you really need to roll back: re-create the table, copy notifications
86
+ -- back out of events + notification_targets, drop the event rows.
@@ -0,0 +1,97 @@
1
+ -- migrate:up
2
+
3
+ -- User-driven scheduled jobs.
4
+ --
5
+ -- Why a separate table:
6
+ -- * `runs` already holds *fired* / *pending-to-fire* rows via
7
+ -- scheduler.spawn(). Each scheduled_jobs row is the *definition* of a
8
+ -- recurring (or one-shot) schedule — its source of truth.
9
+ -- * The ticker (`scheduled-jobs-tick`) scans this table on cron, spawns
10
+ -- a runs row per firing via TaskScheduler.spawn, and advances
11
+ -- next_run_at from `cron`. If the tick or a firing fails, the next
12
+ -- tick re-reads the same row (next_run_at didn't move forward) and
13
+ -- retries. Self-healing.
14
+ -- * Attribution lives here: who scheduled it (user or agent), what run
15
+ -- was the trigger, what event was the trigger. Lets "why did the
16
+ -- system act?" become a single JOIN.
17
+ -- * Cascade-on-delete: when an agent is deleted, all its schedules
18
+ -- evaporate via the FK — no orphan wake-ups firing into the void.
19
+
20
+ CREATE TABLE public.scheduled_jobs (
21
+ id uuid PRIMARY KEY DEFAULT gen_random_uuid(),
22
+ organization_id text NOT NULL REFERENCES public.organization(id) ON DELETE CASCADE,
23
+
24
+ -- What fires
25
+ action_type text NOT NULL, -- 'send_notification' | 'wake_agent' | ...
26
+ action_args jsonb NOT NULL, -- handler payload
27
+ cron text, -- null = one-shot; cron string = recurring
28
+ next_run_at timestamp with time zone NOT NULL,
29
+ last_fired_at timestamp with time zone,
30
+ last_fired_run_id bigint, -- the runs.id from the most recent firing
31
+ paused boolean NOT NULL DEFAULT false,
32
+
33
+ description text NOT NULL, -- human summary for the UI / audit
34
+
35
+ -- Attribution
36
+ created_by_user text, -- user that scheduled it (null when agent did)
37
+ created_by_agent text, -- agent that scheduled it (null when user did)
38
+ source_run_id bigint, -- runs.id that originated the scheduling, if any
39
+ source_event_id bigint, -- events.id that originated, if any
40
+ source_thread_id text, -- chat-thread context, if any
41
+
42
+ created_at timestamp with time zone NOT NULL DEFAULT now(),
43
+ updated_at timestamp with time zone NOT NULL DEFAULT now(),
44
+
45
+ CONSTRAINT scheduled_jobs_attribution_check CHECK (
46
+ created_by_user IS NOT NULL OR created_by_agent IS NOT NULL
47
+ )
48
+ );
49
+
50
+ -- Cascade: dropping an agent kills its scheduled jobs (so an agent's
51
+ -- wake-ups don't outlive the agent itself). Conditional so the migration
52
+ -- works on installs where the agents table doesn't exist yet (very
53
+ -- old) — every row already has organization_id which is the harder constraint.
54
+ DO $$
55
+ BEGIN
56
+ IF EXISTS (SELECT 1 FROM pg_class WHERE relname = 'agents' AND relkind = 'r') THEN
57
+ ALTER TABLE public.scheduled_jobs
58
+ ADD CONSTRAINT scheduled_jobs_agent_fkey
59
+ FOREIGN KEY (created_by_agent) REFERENCES public.agents(id) ON DELETE CASCADE;
60
+ END IF;
61
+ END$$;
62
+
63
+ DO $$
64
+ BEGIN
65
+ IF EXISTS (SELECT 1 FROM pg_class WHERE relname = 'runs' AND relkind = 'r') THEN
66
+ ALTER TABLE public.scheduled_jobs
67
+ ADD CONSTRAINT scheduled_jobs_source_run_fkey
68
+ FOREIGN KEY (source_run_id) REFERENCES public.runs(id) ON DELETE SET NULL;
69
+ END IF;
70
+ END$$;
71
+
72
+ DO $$
73
+ BEGIN
74
+ IF EXISTS (SELECT 1 FROM pg_class WHERE relname = 'events' AND relkind = 'r') THEN
75
+ ALTER TABLE public.scheduled_jobs
76
+ ADD CONSTRAINT scheduled_jobs_source_event_fkey
77
+ FOREIGN KEY (source_event_id) REFERENCES public.events(id) ON DELETE SET NULL;
78
+ END IF;
79
+ END$$;
80
+
81
+ -- Index: the ticker's hot read.
82
+ CREATE INDEX idx_scheduled_jobs_due
83
+ ON public.scheduled_jobs (next_run_at)
84
+ WHERE NOT paused;
85
+
86
+ -- Index: list per-agent / per-user.
87
+ CREATE INDEX idx_scheduled_jobs_org_agent
88
+ ON public.scheduled_jobs (organization_id, created_by_agent)
89
+ WHERE created_by_agent IS NOT NULL;
90
+
91
+ CREATE INDEX idx_scheduled_jobs_org_user
92
+ ON public.scheduled_jobs (organization_id, created_by_user)
93
+ WHERE created_by_user IS NOT NULL;
94
+
95
+ -- migrate:down
96
+
97
+ DROP TABLE IF EXISTS public.scheduled_jobs;
@@ -0,0 +1,42 @@
1
+ -- migrate:up
2
+
3
+ -- Drop the NOT NULL on auth_profiles.connector_key so browser_session
4
+ -- profiles can be device-bound resources without a connector binding.
5
+ --
6
+ -- A browser_session profile is physically (device, browser_kind, user_data_dir
7
+ -- XOR cdp_url) — the connector_key was always a hint, not a gate. One CDP
8
+ -- attach on a Mac already has cookies for every site the user is logged into;
9
+ -- forcing one row per connector against the same cdp_url was bookkeeping for
10
+ -- the DB's benefit, not the user's. Connection resolution falls back to
11
+ -- "browser_session on the connection's device_worker_id" when no exact
12
+ -- connector match exists.
13
+ --
14
+ -- Other profile kinds (env, oauth_app, oauth_account, interactive) remain
15
+ -- per-connector; the new check constraint keeps them honest.
16
+
17
+ ALTER TABLE public.auth_profiles
18
+ ALTER COLUMN connector_key DROP NOT NULL;
19
+
20
+ DO $$
21
+ BEGIN
22
+ IF NOT EXISTS (
23
+ SELECT 1 FROM pg_constraint WHERE conname = 'auth_profiles_connector_key_required'
24
+ ) THEN
25
+ ALTER TABLE public.auth_profiles
26
+ ADD CONSTRAINT auth_profiles_connector_key_required
27
+ CHECK (
28
+ connector_key IS NOT NULL
29
+ OR profile_kind = 'browser_session'
30
+ );
31
+ END IF;
32
+ END$$;
33
+
34
+ -- migrate:down
35
+
36
+ ALTER TABLE public.auth_profiles
37
+ DROP CONSTRAINT IF EXISTS auth_profiles_connector_key_required;
38
+
39
+ -- Restoring NOT NULL would fail if any browser_session rows now have
40
+ -- connector_key = NULL. Backfill with a placeholder before running this.
41
+ ALTER TABLE public.auth_profiles
42
+ ALTER COLUMN connector_key SET NOT NULL;
@@ -84,6 +84,8 @@ export interface EvalResult {
84
84
  p50LatencyMs: number;
85
85
  totalTokens: TokenUsage;
86
86
  trials: TrialResult[];
87
+ /** Set when the eval crashed before producing trials — counts as a failure. */
88
+ error?: string;
87
89
  }
88
90
  export interface EvalReport {
89
91
  agent: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/eval/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,eAAe;;;;;;;;;;;iBAUnB,CAAC;AAOH,eAAO,MAAM,oBAAoB,IAAI,CAAC;AAEtC,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;iBAc/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAClE,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAIxD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,OAAO,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,UAAU;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EA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AE,YAAY,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,UAAU,CAAC;IACxB,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,+EAA+E;IAC/E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB"}
package/dist/index.d.ts CHANGED
@@ -1,2 +1,13 @@
1
+ /**
2
+ * Options shared by most cloud subcommands. `--context` is always present;
3
+ * `--org` / `--json` are opt-in. Descriptions here are the canonical ones —
4
+ * commands needing a different wording (e.g. "Org slug override (defaults to
5
+ * [memory].org)") keep their own explicit `.option(...)` call.
6
+ */
7
+ export interface CommonActionOpts {
8
+ context?: string;
9
+ org?: string;
10
+ json?: boolean;
11
+ }
1
12
  export declare function runCli(argv?: readonly string[]): Promise<void>;
2
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA8BA,wBAAsB,MAAM,CAC1B,IAAI,GAAE,SAAS,MAAM,EAAiB,GACrC,OAAO,CAAC,IAAI,CAAC,CA2qBf"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiBA;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAyBD,wBAAsB,MAAM,CAC1B,IAAI,GAAE,SAAS,MAAM,EAAiB,GACrC,OAAO,CAAC,IAAI,CAAC,CAu4Bf"}