@lobu/runtime-device 21.2.1 → 23.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 (233) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +91 -83
  3. package/npm-shrinkwrap.json +492 -438
  4. package/package.json +12 -2
  5. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +1 -1
  6. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +5 -6
  7. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +1 -0
  8. package/vendor/cli/dist/commands/_lib/apply/client.js +26 -7
  9. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +9 -1
  10. package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +1 -0
  11. package/vendor/cli/dist/commands/_lib/apply/diff.js +46 -4
  12. package/vendor/cli/dist/commands/_lib/apply/map-config.js +18 -38
  13. package/vendor/cli/dist/commands/_lib/init-from-org/bootstrap.js +5 -17
  14. package/vendor/cli/dist/commands/init.d.ts +0 -2
  15. package/vendor/cli/dist/commands/init.js +0 -27
  16. package/vendor/cli/dist/commands/login.d.ts +17 -0
  17. package/vendor/cli/dist/commands/login.js +43 -17
  18. package/vendor/cli/dist/commands/memory/_lib/errors.d.ts +0 -8
  19. package/vendor/cli/dist/commands/memory/_lib/errors.js +0 -12
  20. package/vendor/cli/dist/commands/memory/_lib/mcp.js +6 -6
  21. package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +4 -10
  22. package/vendor/cli/dist/config/define.d.ts +21 -15
  23. package/vendor/cli/dist/config/define.js +2 -2
  24. package/vendor/cli/dist/connectors/README.md +21 -6
  25. package/vendor/cli/dist/connectors/_google/actions.ts +270 -0
  26. package/vendor/cli/dist/connectors/_google/discovery/calendar_v3.json +1 -0
  27. package/vendor/cli/dist/connectors/_google/discovery/chat_v1.json +1 -0
  28. package/vendor/cli/dist/connectors/_google/discovery/docs_v1.json +1 -0
  29. package/vendor/cli/dist/connectors/_google/discovery/drive_v3.json +1 -0
  30. package/vendor/cli/dist/connectors/_google/discovery/gmail_v1.json +1 -0
  31. package/vendor/cli/dist/connectors/_google/discovery/people_v1.json +1 -0
  32. package/vendor/cli/dist/connectors/_google/discovery/sheets_v4.json +1 -0
  33. package/vendor/cli/dist/connectors/_google/discovery/tasks_v1.json +1 -0
  34. package/vendor/cli/dist/connectors/_google/discovery/youtube_v3.json +1 -0
  35. package/vendor/cli/dist/connectors/_google/discovery.ts +442 -0
  36. package/vendor/cli/dist/connectors/_google/errors.ts +91 -0
  37. package/vendor/cli/dist/connectors/_google/list-feed.ts +223 -0
  38. package/vendor/cli/dist/connectors/_google/policies.ts +127 -0
  39. package/vendor/cli/dist/connectors/agentid.ts +43 -0
  40. package/vendor/cli/dist/connectors/chat-user-identity.ts +2 -1
  41. package/vendor/cli/dist/connectors/github-automation-events.ts +9 -0
  42. package/vendor/cli/dist/connectors/github-identity.ts +28 -3
  43. package/vendor/cli/dist/connectors/github.ts +101 -59
  44. package/vendor/cli/dist/connectors/google_calendar.ts +207 -719
  45. package/vendor/cli/dist/connectors/google_drive.ts +16 -2
  46. package/vendor/cli/dist/connectors/google_gmail.ts +52 -33
  47. package/vendor/cli/dist/connectors/herdr.ts +406 -0
  48. package/vendor/cli/dist/connectors/jira-helpers.ts +313 -0
  49. package/vendor/cli/dist/connectors/jira.ts +35 -227
  50. package/vendor/cli/dist/connectors/linear.ts +7 -4
  51. package/vendor/cli/dist/connectors/linkedin-browser-script.ts +13 -0
  52. package/vendor/cli/dist/connectors/linkedin-draft-page.js +104 -0
  53. package/vendor/cli/dist/connectors/linkedin-drafts.ts +73 -0
  54. package/vendor/cli/dist/connectors/linkedin-identity.ts +32 -0
  55. package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +1185 -0
  56. package/vendor/cli/dist/connectors/linkedin-inbox.ts +156 -0
  57. package/vendor/cli/dist/connectors/linkedin-like.ts +114 -0
  58. package/vendor/cli/dist/connectors/linkedin-takeout.ts +577 -0
  59. package/vendor/cli/dist/connectors/linkedin.ts +3998 -0
  60. package/vendor/cli/dist/connectors/postgres.ts +27 -2
  61. package/vendor/cli/dist/connectors/takeout-utils.ts +240 -0
  62. package/vendor/cli/dist/connectors/tiktok-inbox-page.js +230 -0
  63. package/vendor/cli/dist/connectors/tiktok-web-page.js +217 -0
  64. package/vendor/cli/dist/connectors/tiktok_web.ts +319 -0
  65. package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +285 -567
  66. package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +74 -455
  67. package/vendor/cli/dist/connectors/whatsapp-web-identity.ts +135 -0
  68. package/vendor/cli/dist/connectors/whatsapp_web.ts +159 -618
  69. package/vendor/cli/dist/connectors/x-dm-adapter.js +556 -0
  70. package/vendor/cli/dist/connectors/x-identity.ts +31 -2
  71. package/vendor/cli/dist/connectors/x.ts +539 -253
  72. package/vendor/cli/dist/index.js +1 -37
  73. package/vendor/cli/dist/internal/context.d.ts +10 -0
  74. package/vendor/cli/dist/internal/context.js +26 -16
  75. package/vendor/cli/dist/internal/node-version.d.ts +1 -1
  76. package/vendor/cli/dist/internal/node-version.js +1 -1
  77. package/vendor/cli/dist/internal/oauth.d.ts +3 -1
  78. package/vendor/cli/dist/internal/oauth.js +4 -3
  79. package/vendor/cli/dist/internal/runtime-components.d.ts +9 -0
  80. package/vendor/cli/dist/internal/runtime-components.js +67 -2
  81. package/vendor/cli/dist/mac-auth.js +17 -1
  82. package/vendor/cli/dist/providers.json +1 -1
  83. package/vendor/cli/dist/runtime-components.json +4 -4
  84. package/vendor/cli/dist/templates/AGENTS.md.tmpl +12 -5
  85. package/vendor/cli/dist/templates/README.md.tmpl +1 -1
  86. package/vendor/cli/dist/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
  87. package/vendor/cli/dist/vendor/ora/index.d.ts +332 -0
  88. package/vendor/cli/dist/vendor/ora/index.js +424 -0
  89. package/vendor/cli/dist/vendor/ora/license +9 -0
  90. package/vendor/cli/dist/vendor/ora/package.json +64 -0
  91. package/vendor/cli/dist/vendor/ora/readme.md +329 -0
  92. package/vendor/cli/package.json +2 -2
  93. package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
  94. package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
  95. package/vendor/connector-sdk/dist/browser-requirement.d.ts +36 -0
  96. package/vendor/connector-sdk/dist/browser-requirement.js +60 -0
  97. package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
  98. package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
  99. package/vendor/connector-sdk/dist/connector-runtime.d.ts +3 -1
  100. package/vendor/connector-sdk/dist/connector-runtime.js +10 -0
  101. package/vendor/connector-sdk/dist/connector-types.d.ts +169 -45
  102. package/vendor/connector-sdk/dist/define-connector.d.ts +4 -2
  103. package/vendor/connector-sdk/dist/define-connector.js +3 -0
  104. package/vendor/connector-sdk/dist/index.d.ts +8 -2
  105. package/vendor/connector-sdk/dist/index.js +3 -0
  106. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +16 -21
  107. package/vendor/connector-sdk/dist/reaction-client-types.typecheck.d.ts +5 -0
  108. package/vendor/connector-sdk/package.json +13 -1
  109. package/vendor/connector-worker/dist/agent-turn/guest-entry.js +43 -30
  110. package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +416 -330
  111. package/vendor/connector-worker/dist/agent-turn/memory.d.ts +3 -2
  112. package/vendor/connector-worker/dist/agent-turn/memory.js +3 -20
  113. package/vendor/connector-worker/dist/agent-turn/types.d.ts +3 -15
  114. package/vendor/connector-worker/dist/agent-turn/workspace.d.ts +2 -2
  115. package/vendor/connector-worker/dist/agent-turn/workspace.js +2 -4
  116. package/vendor/connector-worker/dist/daemon/action-monitor.d.ts +12 -0
  117. package/vendor/connector-worker/dist/daemon/action-monitor.js +25 -0
  118. package/vendor/connector-worker/dist/daemon/agent-turn.js +0 -9
  119. package/vendor/connector-worker/dist/daemon/automation.d.ts +4 -11
  120. package/vendor/connector-worker/dist/daemon/automation.js +6 -6
  121. package/vendor/connector-worker/dist/daemon/builtins/index.d.ts +12 -0
  122. package/vendor/connector-worker/dist/daemon/builtins/index.js +61 -1
  123. package/vendor/connector-worker/dist/daemon/builtins/os-shell.d.ts +2 -1
  124. package/vendor/connector-worker/dist/daemon/builtins/os-shell.js +40 -27
  125. package/vendor/connector-worker/dist/daemon/client.d.ts +6 -4
  126. package/vendor/connector-worker/dist/daemon/client.js +3 -3
  127. package/vendor/connector-worker/dist/daemon/device-concurrency.d.ts +8 -0
  128. package/vendor/connector-worker/dist/daemon/device-concurrency.js +13 -0
  129. package/vendor/connector-worker/dist/daemon/executor.d.ts +1 -1
  130. package/vendor/connector-worker/dist/daemon/executor.js +48 -120
  131. package/vendor/connector-worker/dist/daemon/log.d.ts +2 -0
  132. package/vendor/connector-worker/dist/daemon/log.js +23 -2
  133. package/vendor/connector-worker/dist/daemon/mac-device-daemon.d.ts +23 -6
  134. package/vendor/connector-worker/dist/daemon/mac-device-daemon.js +57 -23
  135. package/vendor/connector-worker/dist/daemon/native-bridge/client.d.ts +6 -0
  136. package/vendor/connector-worker/dist/daemon/native-bridge/client.js +15 -0
  137. package/vendor/connector-worker/dist/daemon/native-bridge/executor.js +29 -25
  138. package/vendor/connector-worker/dist/daemon/native-bridge/protocol.d.ts +1 -1
  139. package/vendor/connector-worker/dist/daemon/native-bridge/protocol.js +1 -0
  140. package/vendor/connector-worker/dist/daemon/poll-loop.d.ts +3 -0
  141. package/vendor/connector-worker/dist/daemon/poll-loop.js +5 -1
  142. package/vendor/connector-worker/dist/daemon/start.d.ts +1 -0
  143. package/vendor/connector-worker/dist/daemon/start.js +15 -20
  144. package/vendor/connector-worker/dist/daemon/terminal-failure.js +0 -11
  145. package/vendor/connector-worker/dist/daemon/worker-id.d.ts +17 -0
  146. package/vendor/connector-worker/dist/daemon/worker-id.js +22 -0
  147. package/vendor/connector-worker/dist/executor/interface.d.ts +34 -2
  148. package/vendor/connector-worker/dist/executor/isolate.js +66 -15
  149. package/vendor/connector-worker/dist/executor/redact.d.ts +1 -0
  150. package/vendor/connector-worker/dist/executor/redact.js +97 -26
  151. package/vendor/connector-worker/dist/executor/runtime.d.ts +7 -0
  152. package/vendor/connector-worker/dist/executor/runtime.js +26 -0
  153. package/vendor/connector-worker/dist/isolate/bridge.js +3 -1
  154. package/vendor/connector-worker/dist/mac-device-daemon.js +24 -29
  155. package/vendor/connector-worker/package.json +2 -2
  156. package/vendor/core/dist/agent-policy.js +1 -1
  157. package/vendor/core/dist/agent-store.d.ts +2 -0
  158. package/vendor/core/dist/agent-tooling.d.ts +1 -1
  159. package/vendor/core/dist/agent-tooling.js +1 -1
  160. package/vendor/core/dist/capabilities.d.ts +1 -1
  161. package/vendor/core/dist/capabilities.js +2 -1
  162. package/vendor/core/dist/connector-query-errors.d.ts +32 -0
  163. package/vendor/core/dist/connector-query-errors.js +41 -1
  164. package/vendor/core/dist/contracts/agent-settings.d.ts +0 -11
  165. package/vendor/core/dist/contracts/agent-settings.js +1 -7
  166. package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +93 -0
  167. package/vendor/core/dist/contracts/tools/collection-presentation.js +88 -0
  168. package/vendor/core/dist/contracts/tools/collection-selection.d.ts +47 -0
  169. package/vendor/core/dist/contracts/tools/collection-selection.js +74 -0
  170. package/vendor/core/dist/contracts/tools/manage-agents.d.ts +10 -4
  171. package/vendor/core/dist/contracts/tools/manage-auth-profiles.d.ts +1 -1
  172. package/vendor/core/dist/contracts/tools/manage-auth-profiles.js +5 -1
  173. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +19 -4
  174. package/vendor/core/dist/contracts/tools/manage-automations.js +25 -8
  175. package/vendor/core/dist/contracts/tools/manage-connections.d.ts +1 -0
  176. package/vendor/core/dist/contracts/tools/manage-connections.js +3 -0
  177. package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
  178. package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +11 -0
  179. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +42 -3
  180. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +181 -152
  181. package/vendor/core/dist/contracts/tools/manage-entity.js +118 -162
  182. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
  183. package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
  184. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +41 -3
  185. package/vendor/core/dist/contracts/tools/manage-operations.js +40 -2
  186. package/vendor/core/dist/contracts/tools/manage-views.d.ts +182 -7
  187. package/vendor/core/dist/contracts/tools/manage-views.js +49 -13
  188. package/vendor/core/dist/contracts/tools/read-knowledge.d.ts +11 -2
  189. package/vendor/core/dist/contracts/tools/read-knowledge.js +23 -3
  190. package/vendor/core/dist/contracts/tools/save-memory.d.ts +3 -6
  191. package/vendor/core/dist/contracts/tools/save-memory.js +2 -6
  192. package/vendor/core/dist/contracts/tools/view-attach.d.ts +2 -1
  193. package/vendor/core/dist/contracts/tools/view-attach.js +7 -2
  194. package/vendor/core/dist/contracts/worker/protocol.d.ts +130 -159
  195. package/vendor/core/dist/contracts/worker/protocol.js +88 -76
  196. package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
  197. package/vendor/core/dist/device-pin-tombstones.js +57 -0
  198. package/vendor/core/dist/index.d.ts +5 -5
  199. package/vendor/core/dist/index.js +4 -6
  200. package/vendor/core/dist/json-template.d.ts +6 -10
  201. package/vendor/core/dist/json-template.js +5 -9
  202. package/vendor/core/dist/logger.js +17 -26
  203. package/vendor/core/dist/shell-safety.d.ts +9 -0
  204. package/vendor/core/dist/shell-safety.js +154 -0
  205. package/vendor/core/dist/suggestions.d.ts +1 -1
  206. package/vendor/core/dist/suggestions.js +1 -1
  207. package/vendor/core/dist/tool-trace-summary.d.ts +1 -1
  208. package/vendor/core/dist/tool-trace-summary.js +1 -1
  209. package/vendor/core/dist/types.d.ts +1 -3
  210. package/vendor/core/dist/utils/diagnostic-scrubber.d.ts +7 -0
  211. package/vendor/core/dist/utils/diagnostic-scrubber.js +437 -0
  212. package/vendor/core/dist/worker/auth.d.ts +44 -6
  213. package/vendor/core/dist/worker/auth.js +44 -11
  214. package/vendor/core/dist/worker/wire.d.ts +0 -10
  215. package/vendor/core/package.json +20 -11
  216. package/vendor/ora/.bun-tag-fde20e9a6df212fa +0 -0
  217. package/vendor/ora/index.d.ts +332 -0
  218. package/vendor/ora/index.js +424 -0
  219. package/vendor/ora/license +9 -0
  220. package/vendor/ora/package.json +53 -0
  221. package/vendor/ora/readme.md +329 -0
  222. package/vendor/cli/dist/commands/telemetry.d.ts +0 -10
  223. package/vendor/cli/dist/commands/telemetry.js +0 -66
  224. package/vendor/connector-worker/dist/daemon/device-chat.d.ts +0 -9
  225. package/vendor/connector-worker/dist/daemon/device-chat.js +0 -61
  226. package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
  227. package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
  228. package/vendor/core/dist/sentry.d.ts +0 -26
  229. package/vendor/core/dist/sentry.js +0 -133
  230. package/vendor/core/dist/tool-policy.d.ts +0 -74
  231. package/vendor/core/dist/tool-policy.js +0 -305
  232. package/vendor/core/dist/utils/sentry-scrubber.d.ts +0 -29
  233. package/vendor/core/dist/utils/sentry-scrubber.js +0 -228
@@ -2,15 +2,38 @@ import chalk from "chalk";
2
2
  import open from "open";
3
3
  import ora from "ora";
4
4
  import { clearCredentials, loadCredentials, resolveContext, saveCredentials, } from "../internal/index.js";
5
- import { bumpInterval, DEVICE_CODE_GRANT_TYPE, discoverOAuth, fetchUserInfo, OAuthError, pollDeviceToken, registerClient, revokeToken, startDeviceAuthorization, } from "../internal/oauth.js";
5
+ import { bumpInterval, DEVICE_CODE_GRANT_TYPE, discoverOAuth, fetchUserInfo, LOBU_CLI_CLIENT_NAME, OAuthError, pollDeviceToken, registerClient, revokeToken, startDeviceAuthorization, } from "../internal/oauth.js";
6
+ function withApprovalReturnTo(url, returnTo) {
7
+ if (!returnTo)
8
+ return url;
9
+ try {
10
+ const parsed = new URL(url);
11
+ parsed.searchParams.set("return_to", returnTo);
12
+ return parsed.toString();
13
+ }
14
+ catch {
15
+ return url;
16
+ }
17
+ }
6
18
  /**
7
- * Hard ceiling on the polling loop. RFC 8628 servers typically return
8
- * `expires_in: 600` (10 min), but if the server hands us a much longer
9
- * deadline we still don't want to hammer `/oauth/token` for an hour from
10
- * a backgrounded shell. 5 minutes matches the documented device-code
11
- * expiry and is generous for a human to scan a QR + approve.
19
+ * Bound background polling while allowing Lobu's full 15-minute device-code
20
+ * lifetime. A shorter server-advertised expiry still takes precedence.
21
+ * Stopping earlier can lose a browser approval while its code is still valid.
12
22
  */
13
- const POLL_HARD_TIMEOUT_MS = 5 * 60 * 1000;
23
+ const POLL_HARD_TIMEOUT_MS = 15 * 60 * 1000;
24
+ /**
25
+ * A device code is single-use and short-lived, and the approval page answers
26
+ * "Invalid or expired" both for an expired code and for one already used, so
27
+ * say up front when this one stops working and what to do after that.
28
+ */
29
+ export function codeExpiryLine(deadline, now = Date.now()) {
30
+ const minutes = Math.max(1, Math.round((deadline - now) / 60_000));
31
+ const at = new Date(deadline).toLocaleTimeString([], {
32
+ hour: "2-digit",
33
+ minute: "2-digit",
34
+ });
35
+ return ` This code works once and expires in ${minutes} min (at ${at}). After that, run \`lobu login\` again for a new one.`;
36
+ }
14
37
  /**
15
38
  * `lobu login` runs the OAuth 2.0 device-code grant against the issuer
16
39
  * advertised at `<apiUrl-origin>/.well-known/oauth-authorization-server`.
@@ -62,7 +85,7 @@ export async function loginCommand(options) {
62
85
  }
63
86
  console.log(chalk.dim(`\n Context: ${target.name}`));
64
87
  console.log(chalk.dim(` Issuer: ${discovery.issuer}`));
65
- const client = await tryOAuthStep(() => registerClient(registrationEndpoint, options.cliVersion ?? "unknown"));
88
+ const client = await tryOAuthStep(() => registerClient(registrationEndpoint, options.cliVersion ?? "unknown", options.clientName ?? LOBU_CLI_CLIENT_NAME));
66
89
  if (!client)
67
90
  return;
68
91
  const authorization = await tryOAuthStep(() => startDeviceAuthorization(deviceAuthorizationEndpoint, client));
@@ -72,6 +95,12 @@ export async function loginCommand(options) {
72
95
  // for a human at this terminal, ask the server to email an approval link to
73
96
  // `--email`. Approval happens out of band, so we then poll regardless of TTY.
74
97
  const emailClaim = Boolean(options.email);
98
+ // Cap the wait at the server-advertised lifetime AND our local ceiling.
99
+ // The local ceiling guards against a misconfigured issuer handing us an
100
+ // hour-long deadline that a backgrounded shell would otherwise honour.
101
+ const serverDeadline = Date.now() + authorization.expiresIn * 1000;
102
+ const localDeadline = Date.now() + POLL_HARD_TIMEOUT_MS;
103
+ const deadline = Math.min(serverDeadline, localDeadline);
75
104
  if (emailClaim) {
76
105
  const verificationUrl = authorization.verificationUriComplete ?? authorization.verificationUri;
77
106
  // Support was already verified above, before client/device-code creation.
@@ -87,13 +116,15 @@ export async function loginCommand(options) {
87
116
  console.log(chalk.dim(`\n Sent a confirmation link to ${chalk.white(options.email)}.`));
88
117
  console.log(chalk.dim(` Code: ${chalk.bold.white(authorization.userCode)}`));
89
118
  console.log(chalk.dim(` Fallback approval URL: ${verificationUrl}`));
119
+ console.log(chalk.dim(codeExpiryLine(deadline)));
90
120
  console.log(chalk.dim(" Waiting for the user to approve from their email...\n"));
91
121
  }
92
122
  else {
93
- const verificationUrl = authorization.verificationUriComplete ?? authorization.verificationUri;
123
+ const verificationUrl = withApprovalReturnTo(authorization.verificationUriComplete ?? authorization.verificationUri, options.approvalReturnTo);
94
124
  console.log(chalk.dim("\n Open this URL to approve the login:"));
95
125
  console.log(chalk.cyan(` ${verificationUrl}`));
96
126
  console.log(chalk.dim(` Code: ${chalk.bold.white(authorization.userCode)}`));
127
+ console.log(chalk.dim(codeExpiryLine(deadline)));
97
128
  if (authorization.verificationUriComplete &&
98
129
  authorization.verificationUriComplete !== authorization.verificationUri) {
99
130
  console.log(chalk.dim(` Or visit: ${authorization.verificationUri}\n`));
@@ -132,12 +163,6 @@ export async function loginCommand(options) {
132
163
  const spinner = isInteractive
133
164
  ? ora("Waiting for authorization...").start()
134
165
  : null;
135
- // Cap the wait at the server-advertised lifetime AND our local ceiling.
136
- // The local ceiling guards against a misconfigured issuer handing us an
137
- // hour-long deadline that a backgrounded shell would otherwise honour.
138
- const serverDeadline = Date.now() + authorization.expiresIn * 1000;
139
- const localDeadline = Date.now() + POLL_HARD_TIMEOUT_MS;
140
- const deadline = Math.min(serverDeadline, localDeadline);
141
166
  // If the user kills the spawning shell (SIGHUP) or any supervisor sends
142
167
  // SIGTERM, exit promptly instead of inheriting the orphaned poll loop.
143
168
  // The abortable sleep below wakes immediately when `signal` is set, so we
@@ -233,8 +258,9 @@ export async function loginCommand(options) {
233
258
  return;
234
259
  }
235
260
  spinner?.fail("Login request expired. Run `lobu login` again.");
236
- if (!spinner)
237
- console.log(chalk.red(" Login request expired."));
261
+ if (!spinner) {
262
+ console.log(chalk.red(" Login request expired. Run `lobu login` again."));
263
+ }
238
264
  console.log();
239
265
  process.exitCode = 1;
240
266
  }
@@ -29,13 +29,5 @@ export declare function isFailedToolPayload(tool: string | undefined, result: un
29
29
  * `` `in ${path}` ``.
30
30
  */
31
31
  export declare function parseJsonObject(raw: string, label: string): Record<string, unknown>;
32
- /**
33
- * Extra guidance for a failed tool call. A 405 on `POST /api/{org}/{tool}` means
34
- * the request reached a host that does not serve the tool API. The usual cause
35
- * is a context with no `memoryUrl`: the CLI then falls back to the default cloud
36
- * MCP host instead of the context's own `url`, and that host answers 405 with an
37
- * empty body, which on its own gives no hint about the wrong host.
38
- */
39
- export declare function wrongHostHint(status: number): string;
40
32
  export {};
41
33
  //# sourceMappingURL=errors.d.ts.map
@@ -63,16 +63,4 @@ export function parseJsonObject(raw, label) {
63
63
  }
64
64
  return parsed;
65
65
  }
66
- /**
67
- * Extra guidance for a failed tool call. A 405 on `POST /api/{org}/{tool}` means
68
- * the request reached a host that does not serve the tool API. The usual cause
69
- * is a context with no `memoryUrl`: the CLI then falls back to the default cloud
70
- * MCP host instead of the context's own `url`, and that host answers 405 with an
71
- * empty body, which on its own gives no hint about the wrong host.
72
- */
73
- export function wrongHostHint(status) {
74
- if (status !== 405)
75
- return "";
76
- return " A 405 usually means this host does not serve the tool API. If the active context has no memoryUrl, the CLI used the default https://lobu.ai/mcp host; set memoryUrl on the context to the host that serves /api/{org}/{tool}.";
77
- }
78
66
  //# sourceMappingURL=errors.js.map
@@ -1,6 +1,7 @@
1
1
  import { MCP_PROTOCOL_VERSION } from "@lobu/core";
2
+ import { toolApiOriginForMcpUrl } from "../../../internal/context.js";
2
3
  import { extractApiError } from "../../../internal/http.js";
3
- import { ApiError, wrongHostHint } from "./errors.js";
4
+ import { ApiError } from "./errors.js";
4
5
  import { getUsableToken, orgFromMcpUrl, resolveServerUrl, } from "./memory-auth.js";
5
6
  const JSON_MCP_ACCEPT = "application/json";
6
7
  function uniqueStrings(values) {
@@ -98,7 +99,7 @@ async function mcpFetch(mcpUrl, body, sessionId, protocolVersion, contextName) {
98
99
  : " without an access token";
99
100
  const hint = res.status === 401
100
101
  ? `${authContext}. Try --context <name> or run \`lobu context use <name>\`.`
101
- : `${authContext}${wrongHostHint(res.status)}`;
102
+ : authContext;
102
103
  throw new ApiError(`MCP request failed via ${usedUrl}: ${res.status} ${res.statusText}${hint}`, res.status);
103
104
  }
104
105
  const raw = await res.text();
@@ -147,7 +148,7 @@ export async function mcpRpc(mcpUrl, method, params, contextName) {
147
148
  return data.result;
148
149
  }
149
150
  /**
150
- * Shared REST-proxy call against `{origin}/api/{orgSlug}/{path}`, reusing the
151
+ * Shared REST-proxy call against `{tool API origin}/api/{orgSlug}/{path}`, reusing the
151
152
  * same auth resolution and localhost/docker-host fallback as `mcpRpc`. Returns
152
153
  * the raw handler result as parsed JSON (no MCP envelope). Throws `ApiError` on
153
154
  * non-2xx, surfacing the server's `{ error }` message when present.
@@ -168,8 +169,7 @@ async function restCall(mcpUrl, path, opts, contextName) {
168
169
  if (!orgSlug) {
169
170
  throw new ApiError(opts.noOrgMessage(mcpUrl));
170
171
  }
171
- const baseUrl = new URL(mcpUrl).origin;
172
- const endpoint = `${baseUrl}/api/${orgSlug}/${path}`;
172
+ const endpoint = `${toolApiOriginForMcpUrl(mcpUrl)}/api/${orgSlug}/${path}`;
173
173
  const { response: res, usedUrl } = await fetchMcpWithFallback(endpoint, {
174
174
  method: opts.method,
175
175
  headers,
@@ -191,7 +191,7 @@ async function restCall(mcpUrl, path, opts, contextName) {
191
191
  : " without an access token";
192
192
  const hint = res.status === 401
193
193
  ? `${authContext}. Try --context <name> or run \`lobu context use <name>\`.`
194
- : `${authContext}${wrongHostHint(res.status)}`;
194
+ : authContext;
195
195
  throw new ApiError(`${opts.failureLabel} failed via ${usedUrl}: ${message}${hint}`, res.status);
196
196
  }
197
197
  return (raw.length > 0 ? JSON.parse(raw) : {});
@@ -3,8 +3,9 @@ import { basename, dirname, join, resolve } from "node:path";
3
3
  import { parse as parseYaml } from "yaml";
4
4
  import { loadDesiredStateFromConfig } from "../../_lib/apply/desired-state.js";
5
5
  import { isPlatformOwnedRelationshipSlug } from "../../_lib/platform-owned-types.js";
6
- import { ApiError, ValidationError, wrongHostHint } from "./errors.js";
6
+ import { ApiError, ValidationError } from "./errors.js";
7
7
  import { getSessionForOrg, getUsableToken, mcpUrlForOrg, orgFromMcpUrl, resolveOrg, resolveServerUrl, } from "./memory-auth.js";
8
+ import { toolApiOriginForMcpUrl } from "../../../internal/context.js";
8
9
  import { printError, printText } from "../../../internal/output.js";
9
10
  import { validateDataRecord, } from "./schema.js";
10
11
  function readYamlFilesRecursive(dir, prefix = "") {
@@ -75,13 +76,6 @@ function loadDataRecords(dataPath) {
75
76
  recordType: data.type,
76
77
  }));
77
78
  }
78
- function deriveApiBaseUrl(mcpUrl) {
79
- const url = new URL(mcpUrl);
80
- url.pathname = "";
81
- url.search = "";
82
- url.hash = "";
83
- return url.toString().replace(/\/+$/, "");
84
- }
85
79
  export async function callTool(ctx, toolName, args) {
86
80
  const url = `${ctx.apiBaseUrl}/api/${ctx.orgSlug}/${toolName}`;
87
81
  const res = await fetch(url, {
@@ -106,7 +100,7 @@ export async function callTool(ctx, toolName, args) {
106
100
  : `HTTP ${res.status} ${res.statusText}`.trim();
107
101
  throw new ApiError(res.ok
108
102
  ? `Invalid JSON from ${toolName} via ${url}: ${detail}`
109
- : `${toolName} failed via ${url}: ${detail}${wrongHostHint(res.status)}`, res.status);
103
+ : `${toolName} failed via ${url}: ${detail}`, res.status);
110
104
  }
111
105
  if (!res.ok) {
112
106
  const msg = typeof parsed.error === "string" ? parsed.error : `HTTP ${res.status}`;
@@ -368,7 +362,7 @@ export async function seedMemoryWorkspace(opts = {}) {
368
362
  const { layout, state } = await resolveProjectLayout(opts.path);
369
363
  const orgOverride = opts.org || layout.org;
370
364
  const { token, mcpUrl, orgSlug } = await resolveAuth(opts.url, orgOverride, opts.context);
371
- const apiBaseUrl = deriveApiBaseUrl(mcpUrl);
365
+ const apiBaseUrl = toolApiOriginForMcpUrl(mcpUrl);
372
366
  const dryRun = opts.dryRun ?? false;
373
367
  const ctx = { apiBaseUrl, orgSlug, token, dryRun };
374
368
  printText(`Seeding org: ${orgSlug}${dryRun ? " (dry-run)" : ""}`);
@@ -9,7 +9,7 @@
9
9
  * Automation reactions) live in their own modules; these objects only declare
10
10
  * config and references.
11
11
  */
12
- import type { AutomationEventTrigger, AutomationScheduleTrigger, AutomationWorkspaceEventTrigger, ConnectorClass, ConnectorRuntime, Dimension, EventSet, Measure, ReactionClient, AutomationScriptContext, ReactionContext, Segment } from "@lobu/connector-sdk";
12
+ import type { AutomationEventTrigger, AutomationScheduleTrigger, AutomationWorkspaceEventTrigger, ConnectorClass, ConnectorRuntime, CollectionPresentation, Dimension, EventSet, Measure, ReactionClient, AutomationScriptContext, ReactionContext, Segment } from "@lobu/connector-sdk";
13
13
  import { type StringOptions, type TOptional, type TSchema, type TString } from "@sinclair/typebox";
14
14
  import type { SecretRef } from "./secret.js";
15
15
  /** A connector referenced by its key, or by the class produced by `defineConnector`. */
@@ -52,6 +52,8 @@ export interface EntityEventKind {
52
52
  /**
53
53
  * Optional authored render template (render-DSL root node). When omitted,
54
54
  * events of this kind render a default field card built from `metadataSchema`.
55
+ * It renders the event card only; build an interactive dashboard as a
56
+ * React view (`defineView`) attached with `{ event_kind }`.
55
57
  */
56
58
  jsonTemplate?: Record<string, unknown>;
57
59
  /**
@@ -78,8 +80,8 @@ export interface EntityWriteRow<Fields = Record<string, unknown>> {
78
80
  /** `{ ...committed, ...patch }`, i.e. the row as it would commit. */
79
81
  next: Partial<Fields> & Record<string, unknown>;
80
82
  /**
81
- * Deletes and merges use the existing row-shaped contract: they arrive as
82
- * `op: "update"` with `$deleted` or `$merged_into` changing respectively.
83
+ * Deletes use the existing row-shaped contract: they arrive as
84
+ * `op: "update"` with `$deleted` changing.
83
85
  */
84
86
  op: "create" | "update";
85
87
  /**
@@ -146,6 +148,8 @@ export interface EntityType {
146
148
  * placement, and per-field optionality; raw JSON Schema objects stay valid.
147
149
  */
148
150
  properties?: Record<string, unknown>;
151
+ /** Collection presets, table defaults and a read-only facet query. */
152
+ collection?: CollectionPresentation;
149
153
  /**
150
154
  * Event kinds (semantic types) valid for events linked to this entity type,
151
155
  * keyed by semantic_type. Declares each kind's metadata contract + optional
@@ -162,18 +166,18 @@ export interface EntityType {
162
166
  /**
163
167
  * Entity-resolution policy (the `x-lobu-resolution` metadata_schema key the
164
168
  * server reads to decide whether duplicate entities sharing a normalized
165
- * identity auto-merge or queue human review). Declared here so the policy is
169
+ * identity auto-link or queue human review). Declared here so the policy is
166
170
  * git-audited like the rest of the schema; `lobu apply` folds it into the
167
171
  * type's metadata_schema. A rule's `fields` are metadata keys or identity
168
172
  * namespaces (e.g. `email`), `normalizer` is `email` | `phone` | `exact`, and
169
- * `onMatch` is `auto_merge` | `review`. When the key is absent, `person`
170
- * falls back to email/phone review rules; other entity types have no rules.
173
+ * `onMatch` is `auto_link` | `review`. A type without an explicit policy
174
+ * has no matching rules. Association preserves each record and its ID.
171
175
  */
172
176
  resolutionPolicy?: {
173
177
  rules: Array<{
174
178
  fields: string[];
175
179
  normalizer: "email" | "phone" | "exact";
176
- onMatch: "auto_merge" | "review";
180
+ onMatch: "auto_link" | "review";
177
181
  }>;
178
182
  };
179
183
  metadata?: Record<string, unknown>;
@@ -238,6 +242,7 @@ export interface FieldOptions extends StringOptions {
238
242
  }
239
243
  export declare function defineEntityType(config: Omit<EntityType, "kind">): EntityType;
240
244
  export interface RelationshipType {
245
+ purpose?: "identity";
241
246
  readonly kind: "relationshipType";
242
247
  key: string;
243
248
  name?: string;
@@ -475,6 +480,15 @@ export interface AutomationEntityOutput {
475
480
  export interface AutomationEventOutput {
476
481
  /** Semantic type assigned to every standard event draft in this output. */
477
482
  event: string;
483
+ /**
484
+ * Optional one to four metadata fields forming one exact composite identity
485
+ * tuple, scoped to the semantic type (not the Automation, so a migration can
486
+ * seed rows the Automation later adopts). Every draft must contain every
487
+ * field in `metadata` as a non-blank string, safe integer, or boolean.
488
+ * Field order is significant. When set, each run supersedes the current
489
+ * event carrying the same key values. Omit for append-only per-item logs.
490
+ */
491
+ key?: string[];
478
492
  }
479
493
  export type AutomationOutput = AutomationEntityOutput | AutomationEventOutput;
480
494
  /**
@@ -700,13 +714,6 @@ export interface NetworkConfig {
700
714
  /** Domains explicitly blocked (takes precedence over `allowed`). */
701
715
  denied?: string[];
702
716
  }
703
- /** Worker-side tool permissions. */
704
- export interface ToolsConfig {
705
- allowed?: string[];
706
- denied?: string[];
707
- /** Reject tool calls that aren't in `allowed`. */
708
- strict?: boolean;
709
- }
710
717
  export interface Agent {
711
718
  readonly kind: "agent";
712
719
  id: string;
@@ -726,7 +733,6 @@ export interface Agent {
726
733
  skills?: Skill[];
727
734
  providers?: ProviderConfig[];
728
735
  network?: NetworkConfig;
729
- tools?: ToolsConfig;
730
736
  /** Guardrails enabled for this agent, by registered name. */
731
737
  guardrails?: string[];
732
738
  /** Nix packages provisioned into the worker environment. */
@@ -263,8 +263,8 @@ export function context(query) {
263
263
  */
264
264
  export const UNRESOLVED_MODEL_SUFFIX = "__unresolved__";
265
265
  export function defineAgent(config) {
266
- if (config.tools && "preApproved" in config.tools) {
267
- throw new Error(`Agent '${config.id}' declares removed 'tools.preApproved'. Delete it from your config; connector approvals are managed in Settings → Policies.`);
266
+ if ("tools" in config) {
267
+ throw new Error(`Agent '${config.id}' declares removed 'tools' settings. Delete this block; action permissions are managed in Settings → Policies.`);
268
268
  }
269
269
  return { ...config, kind: "agent" };
270
270
  }
@@ -197,16 +197,18 @@ type ConnectorFeedSpec = {
197
197
  metadataSchema?: object;
198
198
  }>;
199
199
  } & (
200
- | { sync: FeedSyncHandler; read?: FeedReadHandler }
201
- | { sync?: FeedSyncHandler; read: FeedReadHandler }
200
+ | { sync: FeedSyncHandler; read?: FeedReadHandler; observe?: never }
201
+ | { sync?: never; read: FeedReadHandler; observe?: (ctx: FeedObserveContext) => Promise<void> }
202
202
  );
203
203
  ```
204
204
 
205
205
  The record key becomes the feed key. A `sync` handler publishes
206
206
  `operations: ['sync']`, a `read` handler publishes `['read']`, and defining both
207
- publishes `['sync', 'read']`. Metadata-only device or MCP connector definitions
208
- declare `operations` explicitly because their executable handlers live outside
209
- the connector process.
207
+ publishes `['sync', 'read']`. An optional `observe(ctx): Promise<void>` hook
208
+ attaches browser listeners for a read-only trigger feed. It returns no data
209
+ and does not add a public operation; notifications use existing subscriptions.
210
+ Metadata-only device or MCP connector definitions declare `operations`
211
+ explicitly because their executable handlers live outside the connector process.
210
212
 
211
213
  `configSchema` describes the persisted feed instance, not one operation. Its
212
214
  top-level `required` fields are therefore enforced for read-only, sync-only,
@@ -250,7 +252,19 @@ feeds: {
250
252
  }
251
253
  ```
252
254
 
253
- A feed's `eventKinds` are also the **default Automation trigger catalog**. The first successful non-dry sync establishes a baseline without activation; later inserts whose kind matches a declared `eventKinds` key activate subscribers. A non-empty `automationEvents` declaration (camelCase in `ConnectorDefinition`, persisted as `automation_events` in the catalog) replaces that derived catalog in the trigger picker. Keys that differ from the feed's `eventKinds` fire only when the emitted `EventEnvelope` carries matching `automation_signals`.
255
+ A feed's `eventKinds` are also the **default Automation trigger catalog**. The first successful non-dry sync establishes a baseline without activation; later inserts whose kind matches a declared `eventKinds` key activate subscribers. A non-empty `automationEvents` declaration (camelCase in `ConnectorDefinition`, persisted as `automation_events` in the catalog) replaces that derived catalog in the trigger picker. Keys outside the feed kinds and their opted-in updated types fire only when the emitted `EventEnvelope` carries matching `automation_signals`.
256
+
257
+ Set `eventKinds.<kind>.updatedEvent: true` to also expose a distinct `<kind>.updated`
258
+ trigger (for example, Gmail's `thread.updated`). After the baseline, it fires when
259
+ ingestion supersedes the source item with changed durable content and strictly
260
+ newer `occurred_at` than the previous head. Use source activity time, not a scheduled
261
+ start time. Unchanged rows, volatile-only counter updates and same-time reformats
262
+ stay quiet. The original `<kind>` trigger remains insert-only; subscribe to both
263
+ types for new items and later activity. Literal kinds declared by any feed of the
264
+ connector win slug collisions, and composite keys over 100 characters are omitted.
265
+ The optional boolean persists unchanged in `connector_definitions.feeds_schema`;
266
+ existing definitions without it retain their semantics. Explicit `automationEvents`
267
+ still replace the derived picker catalog, so include the updated key there if used.
254
268
 
255
269
  ## Syncing Data
256
270
 
@@ -542,6 +556,7 @@ For source-backed bundled connectors, the worker recompiles a `.ts` file after i
542
556
  |-----------|------|-------|---------|
543
557
  | `github` | app_installation/oauth/env_keys | issues, PRs, comments, discussions, commits, stargazers | create/comment/close/reopen issues; create/merge PRs |
544
558
  | `hackernews` | none | stories, front page, comments | - |
559
+ | `linkedin` | browser/none | notifications, inbox messages, home feed, company updates, jobs; Data Export requires an injected CSV reader | send direct-message replies; like; prepare message/post/comment drafts |
545
560
  | `market.quotes` | none | - | quote (read-only, quotes returned to the caller, never persisted) |
546
561
  | `producthunt` | env_keys | posts & comments | - |
547
562
  | `reddit` | oauth/none | posts, comments, user activity | - |