@lobu/runtime-device 23.0.0 → 24.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 (63) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +30 -27
  3. package/npm-shrinkwrap.json +131 -115
  4. package/package.json +2 -1
  5. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +73 -0
  6. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +9 -11
  7. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +3 -11
  8. package/vendor/cli/dist/commands/_lib/apply/client.js +3 -3
  9. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +0 -6
  10. package/vendor/cli/dist/commands/_lib/apply/desired-state.js +6 -15
  11. package/vendor/cli/dist/commands/_lib/apply/diff.js +1 -0
  12. package/vendor/cli/dist/commands/_lib/apply/map-config.js +8 -0
  13. package/vendor/cli/dist/commands/_lib/view-bundler.d.ts +2 -9
  14. package/vendor/cli/dist/commands/_lib/view-bundler.js +25 -97
  15. package/vendor/cli/dist/config/define.d.ts +8 -0
  16. package/vendor/cli/dist/connectors/README.md +1 -1
  17. package/vendor/cli/dist/connectors/linkedin-inbox-adapter.js +4 -7
  18. package/vendor/cli/dist/connectors/linkedin.ts +53 -34
  19. package/vendor/cli/dist/connectors/reddit.ts +92 -20
  20. package/vendor/cli/dist/connectors/slack.ts +1 -0
  21. package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +41 -11
  22. package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +1 -1
  23. package/vendor/cli/dist/connectors/whatsapp_web.ts +2 -2
  24. package/vendor/cli/dist/connectors/x-identity.ts +5 -3
  25. package/vendor/cli/dist/runtime-components.json +4 -4
  26. package/vendor/cli/dist/templates/AGENTS.md.tmpl +10 -3
  27. package/vendor/cli/package.json +1 -1
  28. package/vendor/connector-sdk/package.json +1 -1
  29. package/vendor/connector-worker/dist/agent-turn/gateway-tools.d.ts +2 -2
  30. package/vendor/connector-worker/dist/agent-turn/gateway-tools.js +2 -2
  31. package/vendor/connector-worker/dist/agent-turn/guest-entry.js +34 -2
  32. package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +362 -300
  33. package/vendor/connector-worker/dist/agent-turn/native-session.d.ts +12 -0
  34. package/vendor/connector-worker/dist/agent-turn/native-session.js +32 -6
  35. package/vendor/connector-worker/dist/agent-turn/types.d.ts +24 -3
  36. package/vendor/connector-worker/dist/daemon/agent-turn.js +5 -1
  37. package/vendor/connector-worker/dist/daemon/automation.js +20 -15
  38. package/vendor/connector-worker/dist/isolate/prelude.js +93 -44
  39. package/vendor/connector-worker/package.json +1 -1
  40. package/vendor/core/dist/agent-policy.js +0 -3
  41. package/vendor/core/dist/agent-tooling.d.ts +1 -1
  42. package/vendor/core/dist/agent-tooling.js +3 -1
  43. package/vendor/core/dist/contracts/agent-settings.d.ts +6 -2
  44. package/vendor/core/dist/contracts/agent-settings.js +12 -1
  45. package/vendor/core/dist/contracts/tools/manage-views.d.ts +53 -234
  46. package/vendor/core/dist/contracts/tools/manage-views.js +50 -76
  47. package/vendor/core/dist/contracts/tools/view-attach.d.ts +5 -8
  48. package/vendor/core/dist/contracts/tools/view-attach.js +14 -31
  49. package/vendor/core/dist/contracts/tools/view-definition.d.ts +21 -0
  50. package/vendor/core/dist/contracts/tools/view-definition.js +165 -0
  51. package/vendor/core/dist/contracts/worker/protocol.d.ts +39 -2
  52. package/vendor/core/dist/contracts/worker/protocol.js +24 -1
  53. package/vendor/core/dist/index.d.ts +1 -1
  54. package/vendor/core/dist/index.js +2 -1
  55. package/vendor/core/dist/suggestions.d.ts +15 -2
  56. package/vendor/core/dist/suggestions.js +48 -3
  57. package/vendor/core/dist/types.d.ts +26 -0
  58. package/vendor/core/dist/types.js +5 -0
  59. package/vendor/core/package.json +11 -5
  60. package/vendor/postgres/cf/src/connection.js +18 -0
  61. package/vendor/postgres/cjs/src/connection.js +18 -0
  62. package/vendor/postgres/src/connection.js +18 -0
  63. /package/vendor/postgres/{.bun-tag-f39dafdb2305d504 → .bun-tag-2f292c6554a8475e} +0 -0
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * Reddit Connector (V1 runtime)
3
3
  *
4
- * Fetches posts and comments from Reddit subreddits or search queries.
5
- * Supports both authenticated (OAuth) and unauthenticated (public JSON API) modes.
4
+ * Fetches posts and comments from Reddit subreddits or search queries, and the
5
+ * connected user's home feed. Supports both authenticated (OAuth) and
6
+ * unauthenticated (public JSON API) modes.
6
7
  */
7
8
 
8
9
  import {
@@ -16,6 +17,7 @@ import {
16
17
  type SyncContext,
17
18
  type SyncResult,
18
19
  } from '@lobu/connector-sdk';
20
+ import addFormats from 'ajv-formats';
19
21
 
20
22
  // ---------------------------------------------------------------------------
21
23
  // Reddit API types
@@ -71,6 +73,16 @@ interface RedditCheckpoint {
71
73
  pagination_cutoff?: string;
72
74
  }
73
75
 
76
+ // Use the gateway's URI format check: WHATWG URL parsing also accepts non-URI characters.
77
+ const isUri = addFormats.get('uri') as (value: string) => boolean;
78
+
79
+ /** Metadata declares these fields `format: uri`; one bad value rejects the whole batch. */
80
+ function httpUrl(value: string | undefined): string | undefined {
81
+ if (!value || !isUri(value) || !URL.canParse(value)) return undefined;
82
+ const { protocol } = new URL(value);
83
+ return protocol === 'http:' || protocol === 'https:' ? value : undefined;
84
+ }
85
+
74
86
  // ---------------------------------------------------------------------------
75
87
  // Connector
76
88
  // ---------------------------------------------------------------------------
@@ -79,8 +91,9 @@ export default class RedditConnector extends ConnectorRuntime {
79
91
  readonly definition: RuntimeConnectorDefinition = {
80
92
  key: 'reddit',
81
93
  name: 'Reddit',
82
- description: 'Fetches posts and comments from Reddit subreddits or search queries.',
83
- version: '1.0.0',
94
+ description:
95
+ "Fetches posts and comments from Reddit subreddits or search queries, and the connected user's home feed.",
96
+ version: '1.2.1',
84
97
  faviconDomain: 'reddit.com',
85
98
  authSchema: {
86
99
  methods: [
@@ -88,6 +101,7 @@ export default class RedditConnector extends ConnectorRuntime {
88
101
  type: 'oauth',
89
102
  provider: 'reddit',
90
103
  requiredScopes: ['identity', 'read', 'history'],
104
+ loginScopes: ['identity'],
91
105
  setupInstructions:
92
106
  'Create a Reddit app at https://www.reddit.com/prefs/apps — choose "web app" as the type. Set the redirect URI to {{redirect_uri}}, then copy the client ID and secret below.',
93
107
  },
@@ -238,6 +252,48 @@ export default class RedditConnector extends ConnectorRuntime {
238
252
  },
239
253
  },
240
254
  },
255
+ home_feed: {
256
+ key: 'home_feed',
257
+ name: 'Home feed',
258
+ sync: (ctx) => this.syncFeed(ctx),
259
+ description:
260
+ "Fetch the connected user's personalized home feed (Best). Requires user OAuth.",
261
+ displayNameTemplate: 'Reddit home feed',
262
+ configSchema: {
263
+ type: 'object',
264
+ properties: {
265
+ lookback_days: {
266
+ type: 'integer',
267
+ minimum: 1,
268
+ maximum: 30,
269
+ default: 7,
270
+ description: 'Skip home feed posts older than this many days.',
271
+ },
272
+ },
273
+ },
274
+ eventKinds: {
275
+ post: {
276
+ description: "A Reddit post from the connected user's home feed",
277
+ metadataSchema: {
278
+ type: 'object',
279
+ properties: {
280
+ subreddit: { type: 'string' },
281
+ score: { type: 'number', description: 'Reddit score (upvotes - downvotes)' },
282
+ num_comments: { type: 'number' },
283
+ upvote_ratio: { type: 'number' },
284
+ is_self: { type: 'boolean' },
285
+ domain: { type: 'string' },
286
+ thumbnail: { type: 'string', format: 'uri', description: 'Preview thumbnail URL' },
287
+ media_url: {
288
+ type: 'string',
289
+ format: 'uri',
290
+ description: 'Linked content URL for non-self posts (image, video, article)',
291
+ },
292
+ },
293
+ },
294
+ },
295
+ },
296
+ },
241
297
  },
242
298
  };
243
299
 
@@ -253,17 +309,20 @@ export default class RedditConnector extends ConnectorRuntime {
253
309
  const subreddit = ctx.config.subreddit as string | undefined;
254
310
  const searchTerms = ctx.config.search_terms as string | undefined;
255
311
  const isUserFeed = ctx.feedKey === 'user_activity';
256
- const contentType = isUserFeed ? 'overview' : ctx.feedKey === 'comments' ? 'comment' : 'post';
257
- const lookbackDays = (ctx.config.lookback_days as number) ?? 365;
312
+ // Best is ranked, not chronological: old posts interleave with new ones and
313
+ // a saved `after` anchor is meaningless once the ranking moves.
314
+ const isHomeFeed = ctx.feedKey === 'home_feed';
315
+ const contentType = isUserFeed
316
+ ? 'overview'
317
+ : isHomeFeed
318
+ ? 'home'
319
+ : ctx.feedKey === 'comments'
320
+ ? 'comment'
321
+ : 'post';
322
+ const lookbackDays = (ctx.config.lookback_days as number) ?? (isHomeFeed ? 7 : 365);
258
323
 
259
324
  // Resolve access token: user OAuth > app-only OAuth > unauthenticated
260
325
  const userAccessToken = ctx.credentials?.accessToken ?? null;
261
- let accessToken: string | undefined = userAccessToken ?? undefined;
262
- if (!accessToken) {
263
- accessToken = await this.getAppOnlyToken(ctx);
264
- }
265
- const baseUrl = accessToken ? 'https://oauth.reddit.com' : 'https://www.reddit.com';
266
-
267
326
  let username: string | undefined;
268
327
  if (isUserFeed) {
269
328
  if (!userAccessToken) {
@@ -273,9 +332,18 @@ export default class RedditConnector extends ConnectorRuntime {
273
332
  }
274
333
  username = await this.resolveUsername(ctx, userAccessToken);
275
334
  }
335
+ if (isHomeFeed && !userAccessToken) {
336
+ throw new Error('home_feed requires user OAuth. Connect Reddit with the read scope.');
337
+ }
338
+
339
+ let accessToken: string | undefined = userAccessToken ?? undefined;
340
+ if (!accessToken) {
341
+ accessToken = await this.getAppOnlyToken(ctx);
342
+ }
343
+ const baseUrl = accessToken ? 'https://oauth.reddit.com' : 'https://www.reddit.com';
276
344
 
277
345
  const previous = (ctx.checkpoint ?? {}) as RedditCheckpoint;
278
- const resumeAfter = previous.pagination_token ?? null;
346
+ const resumeAfter = isHomeFeed ? null : (previous.pagination_token ?? null);
279
347
  let cutoffDate = new Date();
280
348
  cutoffDate.setDate(cutoffDate.getDate() - lookbackDays);
281
349
  // Keep items eligible for the whole bounded sweep, even across sync runs.
@@ -355,6 +423,7 @@ export default class RedditConnector extends ConnectorRuntime {
355
423
  const itemDate = new Date(itemData.created_utc * 1000);
356
424
 
357
425
  if (itemDate < cutoffDate) {
426
+ if (isHomeFeed) continue;
358
427
  reachedCutoff = true;
359
428
  break;
360
429
  }
@@ -388,8 +457,9 @@ export default class RedditConnector extends ConnectorRuntime {
388
457
 
389
458
  const checkpoint: RedditCheckpoint = {
390
459
  last_timestamp: new Date().toISOString(),
391
- pagination_token: !reachedCutoff ? (after ?? undefined) : undefined,
392
- pagination_cutoff: !reachedCutoff && after ? cutoffDate.toISOString() : undefined,
460
+ pagination_token: !reachedCutoff && !isHomeFeed ? (after ?? undefined) : undefined,
461
+ pagination_cutoff:
462
+ !reachedCutoff && !isHomeFeed && after ? cutoffDate.toISOString() : undefined,
393
463
  };
394
464
 
395
465
  await ctx.commit(events, checkpoint as Record<string, unknown>);
@@ -498,6 +568,10 @@ export default class RedditConnector extends ConnectorRuntime {
498
568
  return `${baseUrl}/user/${encodeURIComponent(username)}/overview${jsonSuffix}?limit=100&sort=new${afterParam}`;
499
569
  }
500
570
 
571
+ if (contentType === 'home') {
572
+ return `${baseUrl}/best${jsonSuffix}?limit=100${afterParam}`;
573
+ }
574
+
501
575
  if (contentType === 'comment') {
502
576
  // Comments from a subreddit
503
577
  if (subredditPath) {
@@ -541,11 +615,9 @@ export default class RedditConnector extends ConnectorRuntime {
541
615
  });
542
616
 
543
617
  // For non-self posts, the Reddit `url` field points to the linked content (image, article, etc.)
544
- const mediaUrl = !post.is_self ? post.url : undefined;
545
- const thumbnail =
546
- post.thumbnail && !['self', 'default', 'nsfw', 'spoiler', ''].includes(post.thumbnail)
547
- ? post.thumbnail
548
- : undefined;
618
+ const mediaUrl = !post.is_self ? httpUrl(post.url) : undefined;
619
+ // `thumbnail` also carries placeholder words ("self", "image", "nsfw", ...).
620
+ const thumbnail = httpUrl(post.thumbnail);
549
621
 
550
622
  return {
551
623
  origin_id: `reddit_post_${post.name}`,
@@ -65,6 +65,7 @@ const SLACK_BOT_SCOPES = [
65
65
  const SLACK_BOT_EVENTS = [
66
66
  "app_home_opened",
67
67
  "app_mention",
68
+ "assistant_thread_started",
68
69
  "member_joined_channel",
69
70
  "member_left_channel",
70
71
  "message.channels",
@@ -33,8 +33,11 @@ export function whatsAppWebAdapterProgram() {
33
33
  // when this number moves: shipping a fix under the old number leaves every
34
34
  // already-open tab running the previous code with nothing to show for it.
35
35
  // Keep in lockstep with WHATSAPP_ADAPTER_VERSION in whatsapp-web-helpers.ts.
36
- const ADAPTER_VERSION = 25;
36
+ const ADAPTER_VERSION = 26;
37
37
  const SOURCE_ERROR_ID = "whatsapp-web:source-observation-error";
38
+ // Storage rows one `chat:` read examines; a whole personal history is
39
+ // usually under this, so one read answers.
40
+ const CHAT_SCAN_ROWS = 20_000;
38
41
  const MAX_RECORD_BYTES = 128 * 1024;
39
42
  const MAX_BUFFER_BYTES = 16 * 1024 * 1024;
40
43
  const MAX_BUFFER_ENTRIES = 10_000;
@@ -945,6 +948,11 @@ export function whatsAppWebAdapterProgram() {
945
948
  }
946
949
  const keyModule = requireFirst(["WAWebMsgKey"]);
947
950
  const exactId = query.startsWith("id:") ? query.slice(3) : null;
951
+ let chatJid = null;
952
+ if (query.startsWith("chat:")) {
953
+ const chat = await resolveChat(requireFirst(["WAWebCollections"]), { chat_jid: query.slice(5) });
954
+ chatJid = (await canonicalJid(modelData(chat).id ?? chat?.id)).jid;
955
+ }
948
956
  const database = await new Promise((resolve, reject) => {
949
957
  const request = indexedDB.open("model-storage");
950
958
  // Never create an empty replacement database when WhatsApp changes its
@@ -980,24 +988,46 @@ export function whatsAppWebAdapterProgram() {
980
988
  return;
981
989
  }
982
990
  rows.push({ position: cursor.key, id: cursor.value.id });
983
- if (rows.length > limit) resolve(rows);
991
+ if (rows.length > (chatJid === null ? limit : CHAT_SCAN_ROWS)) resolve(rows);
984
992
  else cursor.continue();
985
993
  };
986
994
  });
987
995
  } finally {
988
996
  database.close();
989
997
  }
990
- const hasMore = sourceRows.length > limit;
991
- const page = sourceRows.slice(0, limit);
998
+ let hasMore = sourceRows.length > limit;
999
+ let page = sourceRows.slice(0, limit);
1000
+ let last = page[page.length - 1];
1001
+ if (chatJid !== null) {
1002
+ // A chat read scans one large storage page, then keeps that chat's rows.
1003
+ // Matching happens after the transaction closes because LID conversion
1004
+ // awaits, and history can key a chat by phone or by LID.
1005
+ const examined = sourceRows.slice(0, CHAT_SCAN_ROWS);
1006
+ const canonical = new Map();
1007
+ const matches = [];
1008
+ for (const row of examined) {
1009
+ const remote = keyModule.fromString(row.id).remote;
1010
+ const raw = widString(remote);
1011
+ if (!canonical.has(raw)) canonical.set(raw, (await canonicalJid(remote)).jid);
1012
+ if (canonical.get(raw) !== chatJid) continue;
1013
+ matches.push(row);
1014
+ if (matches.length > limit) break;
1015
+ }
1016
+ page = matches.slice(0, limit);
1017
+ hasMore = matches.length > limit || sourceRows.length > CHAT_SCAN_ROWS;
1018
+ last = matches.length > limit ? page[page.length - 1] : examined[examined.length - 1];
1019
+ }
992
1020
  const collections = requireFirst(["WAWebCollections"]);
993
- const selected = page.filter((row) => {
1021
+ const selected = [];
1022
+ for (const row of page) {
994
1023
  const key = keyModule.fromString(row.id);
995
- if (exactId !== null && key.id !== exactId) return false;
1024
+ if (exactId !== null && key.id !== exactId) continue;
996
1025
  const remote = widString(key.remote);
997
- if (remote === "status@broadcast" || remote.endsWith("@newsletter")) return false;
1026
+ if (remote === "status@broadcast" || remote.endsWith("@newsletter")) continue;
998
1027
  const isGroup = remote.endsWith("@g.us");
999
- return !(chatFilter === "group" && !isGroup) && !(chatFilter === "individual" && isGroup);
1000
- });
1028
+ if ((chatFilter === "group" && !isGroup) || (chatFilter === "individual" && isGroup)) continue;
1029
+ selected.push(row);
1030
+ }
1001
1031
  const results = [];
1002
1032
  if (selected.length) {
1003
1033
  const loaded = await collections.Msg.getMessagesById(selected.map((row) => row.id));
@@ -1014,14 +1044,14 @@ export function whatsAppWebAdapterProgram() {
1014
1044
  // Skip them like search does; throwing would pin every later read to
1015
1045
  // the same cursor.
1016
1046
  if (!message || message.timestamp <= 0) continue;
1017
- if (exactId === null && query && !`${message.body}\n${message.caption}`.toLowerCase().includes(query.toLowerCase())) continue;
1047
+ if (exactId === null && chatJid === null && query && !`${message.body}\n${message.caption}`.toLowerCase().includes(query.toLowerCase())) continue;
1018
1048
  results.push(message);
1019
1049
  }
1020
1050
  }
1021
1051
  return {
1022
1052
  results,
1023
1053
  hasMore,
1024
- ...(hasMore ? { nextCursor: JSON.stringify({ v: 1, before: page[page.length - 1].position, query, chat_filter: chatFilter }) } : {}),
1054
+ ...(hasMore ? { nextCursor: JSON.stringify({ v: 1, before: last.position, query, chat_filter: chatFilter }) } : {}),
1025
1055
  };
1026
1056
  }
1027
1057
 
@@ -14,7 +14,7 @@ import {
14
14
  WHATSAPP_PHONE_SERVER,
15
15
  } from "./whatsapp-web-identity.js";
16
16
 
17
- export const WHATSAPP_ADAPTER_VERSION = 25;
17
+ export const WHATSAPP_ADAPTER_VERSION = 26;
18
18
  export const WHATSAPP_ORIGIN = "https://web.whatsapp.com";
19
19
 
20
20
  export type ChatFilter = "all" | "individual" | "group";
@@ -354,7 +354,7 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
354
354
  name: "WhatsApp",
355
355
  description:
356
356
  "Personal WhatsApp messages read live from WhatsApp Web in the paired Owletto Chrome without importing message history. Automations react to new-message references and read content on demand. Search, draft, send, edit, react to, and revoke messages.",
357
- version: "2.1.0",
357
+ version: "2.2.0",
358
358
  faviconDomain: "whatsapp.com",
359
359
  authSchema: { methods: [{ type: "browser", mode: "live" }] },
360
360
  browser: {
@@ -392,7 +392,7 @@ export default class WhatsAppWebConnector extends ConnectorRuntime<
392
392
  key: "live_messages",
393
393
  name: "Live messages",
394
394
  description:
395
- "Read messages directly from WhatsApp Web without importing history, using literal text search or id:<message ID>. Active Automations can subscribe to new-message references. Requires the paired browser to be online and signed in; reconnects replay messages still available in WhatsApp's local history.",
395
+ "Read messages directly from WhatsApp Web without importing history, using literal text search, id:<message ID>, or chat:<chat JID> for one chat's messages in reverse storage order. Follow cursors even after an empty filtered page. Active Automations can subscribe to new-message references. Requires the paired browser to be online and signed in; reconnects replay messages still available in WhatsApp's local history.",
396
396
  read: (ctx) => this.readMessages(ctx),
397
397
  observe: (ctx) => this.observeMessages(ctx),
398
398
  webhook: { mode: "trigger", events: ["message.created"] },
@@ -75,12 +75,14 @@ export const xIdentityModule: ConnectorIdentityModule = {
75
75
  * X's direct-message sender model. Numeric user ids are unique across X, so
76
76
  * there is no tenant axis: `teamId` is ignored and the scope is global.
77
77
  *
78
- * No login extractor is registered for this descriptor. The chat link offered
79
- * in a direct message proves the sender within the workspace that issued it.
78
+ * Signing in with X proves it: Better Auth's X provider is `twitter`, and the
79
+ * account id it stores is the same numeric user id a direct message carries.
80
+ * The chat link offered in a direct message proves it too, within the
81
+ * workspace that issued it.
80
82
  */
81
83
  export const xChatUserIdentity: ChatUserIdentity = {
82
84
  platform: 'x',
83
- providerId: 'x',
85
+ providerId: 'twitter',
84
86
  namespace: X_IDENTITY.CHAT_USER_ID,
85
87
  buildUserKey(_teamId, platformUserId) {
86
88
  return normalizeXUserId(platformUserId);
@@ -5,7 +5,7 @@
5
5
  "server": "dist/server.bundle.mjs",
6
6
  "embeddingsServer": "dist/embeddings-server.mjs"
7
7
  },
8
- "version": "23.0.0",
8
+ "version": "24.0.0",
9
9
  "verify": "dist/verify.mjs"
10
10
  },
11
11
  "device": {
@@ -16,7 +16,7 @@
16
16
  "connector": "node_modules/@lobu/cli/dist/commands/connector.js",
17
17
  "worker": "node_modules/@lobu/connector-worker/dist/bin.js"
18
18
  },
19
- "version": "23.0.0",
19
+ "version": "24.0.0",
20
20
  "verify": "dist/verify.mjs"
21
21
  },
22
22
  "postgres": {
@@ -24,7 +24,7 @@
24
24
  "entries": {
25
25
  "postgres": "dist/index.mjs"
26
26
  },
27
- "version": "23.0.0",
27
+ "version": "24.0.0",
28
28
  "verify": "dist/verify.mjs"
29
29
  },
30
30
  "embeddings": {
@@ -32,7 +32,7 @@
32
32
  "entries": {
33
33
  "embeddings": "dist/embeddings.js"
34
34
  },
35
- "version": "23.0.0",
35
+ "version": "24.0.0",
36
36
  "verify": "dist/verify.mjs"
37
37
  }
38
38
  }
@@ -172,14 +172,21 @@ const ticket = defineEntityType({
172
172
  name: "Ticket",
173
173
  required: ["subject"],
174
174
  properties: {
175
- subject: { type: "string", "x-table-label": "Subject", "x-table-column": true },
176
- status: { type: "string", enum: ["open", "closed"], "x-table-label": "Status", "x-table-column": true },
175
+ subject: { type: "string", title: "Subject", "x-table-label": "Subject", "x-table-column": true },
176
+ status: { type: "string", title: "Status", enum: ["open", "closed"], "x-table-label": "Status", "x-table-column": true },
177
+ contacts: {
178
+ type: "array",
179
+ title: "Contacts",
180
+ items: { type: "object", properties: { email: { type: "string", title: "Email" } } },
181
+ },
177
182
  },
178
183
  });
179
184
  ```
180
185
 
181
186
  Each property is a JSON Schema fragment. `"x-table-column": true` surfaces it as a
182
- column in the admin UI.
187
+ column in the admin UI. The same schema renders the record page form: give every
188
+ array `items` and every object `properties` (bare ones render as raw JSON), put the
189
+ label in `title` and help text in `description`, and mark derived fields `readOnly: true`.
183
190
 
184
191
  ### Connection (a bundled connector — preferred)
185
192
 
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/cli",
3
- "version": "23.0.0",
3
+ "version": "24.0.0",
4
4
  "description": "CLI for deploying and managing AI agents on Lobu",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/connector-sdk",
3
- "version": "23.0.0",
3
+ "version": "24.0.0",
4
4
  "description": "Lobu memory SDK — build pluggable connectors for Lobu memory",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The turn's gateway tools: `ask_user`, `send_message`, `suggest_actions` and
3
- * the rest of `@lobu/plugin-conversations`.
2
+ * The turn's gateway tools: `ask_user`, `send_message` and the rest of
3
+ * `@lobu/plugin-conversations`.
4
4
  *
5
5
  * GUEST code, bundled with the agent entry, so the same portability rules as
6
6
  * `workspace.ts` apply: no `node:` import, no host module, no root
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The turn's gateway tools: `ask_user`, `send_message`, `suggest_actions` and
3
- * the rest of `@lobu/plugin-conversations`.
2
+ * The turn's gateway tools: `ask_user`, `send_message` and the rest of
3
+ * `@lobu/plugin-conversations`.
4
4
  *
5
5
  * GUEST code, bundled with the agent entry, so the same portability rules as
6
6
  * `workspace.ts` apply: no `node:` import, no host module, no root
@@ -19,16 +19,25 @@
19
19
  * provider credential and the MCP route accepts it as the bearer.
20
20
  */
21
21
  import { mcpToolResult, toolImageBudget } from '@lobu/plugin-toolkit';
22
+ import { FOLLOW_UP_SUGGESTIONS_PROMPT, parseFollowUpSuggestions } from '@lobu/core/agent-tooling';
22
23
  import { createGatewayTools } from './gateway-tools.js';
23
24
  import { createTurnMediaTools } from './media-tools.js';
24
25
  import { createTurnMemoryHooks } from './memory.js';
25
26
  import { estimatePromptTokenCost, memoryFlushDue, MEMORY_FLUSH_STATE_CUSTOM_TYPE } from '@lobu/core/memory-flush';
26
27
  import { isRetrievalTool, summarizeToolTrace } from '@lobu/core/tool-trace-summary';
27
- import { createNativeSession, nativeSessionJsonl, promptNativeSession } from './native-session.js';
28
+ import { askAside, createNativeSession, nativeSessionJsonl, promptNativeSession } from './native-session.js';
28
29
  import { MAX_TOOL_CALLS_PER_TURN } from './types.js';
29
30
  import { createWorkspace, INPUT_DIR, SKILLS_DIR, } from './workspace.js';
30
31
  /** Third-party MCP server on the other side of the gateway: generous, never forever. */
31
32
  const TOOL_CALL_TIMEOUT_MS = 120_000;
33
+ /**
34
+ * The follow-up chips request. It runs after the answer has streamed and
35
+ * before the turn completes, so this bounds how much later the reply is
36
+ * marked done; a slower model simply yields no chips.
37
+ */
38
+ const FOLLOW_UPS_TIMEOUT_MS = 10_000;
39
+ /** A chips reply is a few short JSON objects. */
40
+ const FOLLOW_UPS_MAX_TOKENS = 400;
32
41
  /**
33
42
  * What of a tool's output the host sees in the event stream.
34
43
  *
@@ -454,7 +463,7 @@ export async function runAgentTurn(input, emit, takeSteering = () => [], runtime
454
463
  // another request every time and an answer could still follow `ask_user`.
455
464
  //
456
465
  // `block` keeps its job — a sibling scheduled in the same batch must not
457
- // RUN, since `suggest_actions`/`send_message` post to the user — and
466
+ // RUN, since `send_message` posts to the user — and
458
467
  // `agent.abort()` is what ends generation. Pi's own `terminate` hint cannot
459
468
  // do it here: `shouldTerminateToolBatch` needs every result in the batch to
460
469
  // set it, and a blocked call is short-circuited as `kind:'immediate'`, which
@@ -743,6 +752,28 @@ export async function runAgentTurn(input, emit, takeSteering = () => [], runtime
743
752
  }
744
753
  if (ended)
745
754
  throw new Error(ended);
755
+ // Follow-up chips, asked of the model that just answered. They ride the
756
+ // result, so the gateway delivers them with the reply: embedded on web's
757
+ // `complete`, posted after the reply on chat, and dropped if a guardrail
758
+ // blocks it. Skipped when the turn already handed control back
759
+ // (`ask_user`), posted its answer in-band, or answered steered follow-ups
760
+ // as well — each of those inputs completes on its own.
761
+ let suggestions = [];
762
+ if (input.tools?.followUps && !askedUser && !repliedInBand && steeredMessages.size === 0 && finalText.trim()) {
763
+ try {
764
+ const reply = await askAside(session, credential, FOLLOW_UP_SUGGESTIONS_PROMPT, {
765
+ maxTokens: FOLLOW_UPS_MAX_TOKENS,
766
+ signal: AbortSignal.timeout(FOLLOW_UPS_TIMEOUT_MS),
767
+ });
768
+ suggestions = parseFollowUpSuggestions(reply);
769
+ }
770
+ catch (error) {
771
+ // Chips are optional: a slow or failed request leaves the answer as is.
772
+ console.warn('follow-up suggestions failed; the turn completes without them', {
773
+ error: error instanceof Error ? error.message : String(error),
774
+ });
775
+ }
776
+ }
746
777
  return {
747
778
  // The answer is the last assistant message WITH TEXT after each user
748
779
  // message, not the accumulated stream: a model that narrates before a
@@ -792,6 +823,7 @@ export async function runAgentTurn(input, emit, takeSteering = () => [], runtime
792
823
  }];
793
824
  }),
794
825
  ...(repliedInBand ? { repliedInBand: true } : {}),
826
+ ...(suggestions.length > 0 ? { suggestions } : {}),
795
827
  };
796
828
  }
797
829
  finally {