@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,50 +1,33 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isEventAttachment = isEventAttachment;
4
- exports.isTabAttachment = isTabAttachment;
5
- exports.matchesType = matchesType;
4
+ exports.matchesCollection = matchesCollection;
6
5
  exports.matchesRecord = matchesRecord;
7
6
  exports.hasWorkspaceAttachment = hasWorkspaceAttachment;
8
7
  exports.eventAttachmentsFor = eventAttachmentsFor;
9
8
  const collection_selection_1 = require("./collection-selection");
10
- /** An event's type qualifies its linked entities; it never names a page tab. */
11
9
  function isEventAttachment(attachment) {
12
- return ("event_kind" in attachment && typeof attachment.event_kind === "string");
10
+ return "event" in attachment;
13
11
  }
14
- function isTabAttachment(attachment) {
15
- return (!isEventAttachment(attachment) && (attachment.placement ?? "tab") === "tab");
12
+ /** A tab on the type's list page, when the list's selection implies `when`. */
13
+ function matchesCollection(attachment, typeSlug, selection = {}) {
14
+ return ("collection" in attachment &&
15
+ attachment.collection === typeSlug &&
16
+ (!attachment.when || (0, collection_selection_1.selectionImplies)(selection, attachment.when)));
16
17
  }
17
- function matchesType(attachment, typeSlug, placement, selection = {}) {
18
- return (!isEventAttachment(attachment) &&
19
- "type" in attachment &&
20
- attachment.type === typeSlug &&
21
- attachment.surface !== "record" &&
22
- (!attachment.when || (0, collection_selection_1.selectionImplies)(selection, attachment.when)) &&
23
- (attachment.placement ?? "tab") === placement);
24
- }
25
- function matchesRecord(attachment, record, placement) {
26
- if (isEventAttachment(attachment))
27
- return false;
28
- if ((attachment.placement ?? "tab") !== placement)
29
- return false;
30
- if ("entity" in attachment) {
31
- return typeof attachment.entity === "number"
32
- ? attachment.entity === record.id
33
- : record.parentId === null && attachment.entity === record.slug;
34
- }
35
- return ("type" in attachment &&
36
- attachment.type === record.type &&
37
- attachment.surface !== "collection");
18
+ /** A card on the record's page: every record of the type, or one pinned id. */
19
+ function matchesRecord(attachment, record) {
20
+ return ("record" in attachment &&
21
+ attachment.record === record.type &&
22
+ (attachment.id === undefined || attachment.id === record.id));
38
23
  }
39
24
  function hasWorkspaceAttachment(attach) {
40
- return attach.some((attachment) => !isEventAttachment(attachment) &&
41
- "workspace" in attachment &&
42
- attachment.workspace === true);
25
+ return attach.some((attachment) => "workspace" in attachment);
43
26
  }
44
27
  /** Without a kind, the web host considers every event attachment a candidate. */
45
28
  function eventAttachmentsFor(attach, semanticType) {
46
29
  return attach
47
30
  .filter(isEventAttachment)
48
- .filter((attachment) => semanticType === undefined || attachment.event_kind === semanticType);
31
+ .filter((attachment) => semanticType === undefined || attachment.event === semanticType);
49
32
  }
50
33
  //# sourceMappingURL=view-attach.js.map
@@ -0,0 +1,21 @@
1
+ import { type ViewActionDecl, type ViewAttachment, type ViewParamDecl } from "./manage-views";
2
+ /** A view's declaration with its defaults applied: what the server stores and
3
+ * what the CLI hashes, so both derive it from the same function. */
4
+ export interface ViewDefinitionRecord {
5
+ key: string;
6
+ name: string;
7
+ description: string;
8
+ attach: ViewAttachment[];
9
+ params: Record<string, ViewParamDecl>;
10
+ actions: Record<string, ViewActionDecl>;
11
+ }
12
+ /**
13
+ * Read `export const view = defineView({...})` out of a view module, without
14
+ * running it. `js` is the module with TypeScript and JSX already stripped
15
+ * (esbuild `transform`); the argument must be a plain literal (objects,
16
+ * arrays, strings, numbers, booleans, null), so a declaration is data the
17
+ * server can read safely from any author's source. Throws an Error whose
18
+ * message names what to fix.
19
+ */
20
+ export declare function readViewDefinition(js: string): ViewDefinitionRecord;
21
+ //# sourceMappingURL=view-definition.d.ts.map
@@ -0,0 +1,165 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readViewDefinition = readViewDefinition;
4
+ const value_1 = require("@sinclair/typebox/value");
5
+ const acorn_1 = require("acorn");
6
+ const manage_views_1 = require("./manage-views");
7
+ const VIEWS_PACKAGE = "@lobu/views";
8
+ /**
9
+ * Read `export const view = defineView({...})` out of a view module, without
10
+ * running it. `js` is the module with TypeScript and JSX already stripped
11
+ * (esbuild `transform`); the argument must be a plain literal (objects,
12
+ * arrays, strings, numbers, booleans, null), so a declaration is data the
13
+ * server can read safely from any author's source. Throws an Error whose
14
+ * message names what to fix.
15
+ */
16
+ function readViewDefinition(js) {
17
+ let program;
18
+ try {
19
+ program = (0, acorn_1.parse)(js, {
20
+ ecmaVersion: "latest",
21
+ sourceType: "module",
22
+ });
23
+ }
24
+ catch (error) {
25
+ throw new Error(`view module does not parse: ${error.message}`);
26
+ }
27
+ const callee = defineViewLocalName(program.body);
28
+ const argument = callee ? viewExportArgument(program.body, callee) : null;
29
+ if (!argument) {
30
+ throw new Error(`the module must export const view = defineView({ key, attach, ... }) with defineView imported from "${VIEWS_PACKAGE}"`);
31
+ }
32
+ if (!hasDefaultExport(program.body)) {
33
+ throw new Error("the module must have a default-export component");
34
+ }
35
+ const raw = literalValue(argument, "defineView");
36
+ if (!value_1.Value.Check(manage_views_1.ViewDefinitionSchema, raw)) {
37
+ const first = value_1.Value.Errors(manage_views_1.ViewDefinitionSchema, raw).First();
38
+ const at = first?.path
39
+ ? `defineView${first.path.split("/").join(".")}`
40
+ : "defineView";
41
+ // A union (an attach entry) names the shapes it accepts, not "Expected
42
+ // union value".
43
+ const schema = first?.schema;
44
+ const message = schema?.anyOf && schema.description
45
+ ? `Expected ${schema.description}`
46
+ : (first?.message ?? "invalid view definition");
47
+ throw new Error(`${at}: ${message}`);
48
+ }
49
+ const def = raw;
50
+ return {
51
+ key: def.key,
52
+ name: def.name?.trim() ? def.name : def.key,
53
+ description: def.description ?? "",
54
+ attach: def.attach,
55
+ params: def.params ?? {},
56
+ actions: def.actions ?? {},
57
+ };
58
+ }
59
+ function defineViewLocalName(body) {
60
+ for (const statement of body) {
61
+ if (statement.type !== "ImportDeclaration")
62
+ continue;
63
+ if (statement.source.value !== VIEWS_PACKAGE)
64
+ continue;
65
+ for (const spec of statement.specifiers) {
66
+ if (spec.type !== "ImportSpecifier")
67
+ continue;
68
+ const imported = spec.imported;
69
+ if (imported.name === "defineView" || imported.value === "defineView") {
70
+ return spec.local.name;
71
+ }
72
+ }
73
+ }
74
+ return null;
75
+ }
76
+ function hasDefaultExport(body) {
77
+ return body.some((statement) => statement.type === "ExportDefaultDeclaration" ||
78
+ (statement.type === "ExportNamedDeclaration" &&
79
+ (statement.specifiers ?? []).some((spec) => spec.exported.name === "default")));
80
+ }
81
+ function viewExportArgument(body, callee) {
82
+ for (const statement of body) {
83
+ if (statement.type !== "ExportNamedDeclaration")
84
+ continue;
85
+ const declaration = statement.declaration;
86
+ if (declaration?.type !== "VariableDeclaration")
87
+ continue;
88
+ for (const declarator of declaration.declarations) {
89
+ if (declarator.id.name !== "view")
90
+ continue;
91
+ const init = declarator.init;
92
+ const args = init?.arguments;
93
+ if (init?.type === "CallExpression" &&
94
+ init.callee.type === "Identifier" &&
95
+ init.callee.name === callee &&
96
+ args?.length === 1) {
97
+ return args[0] ?? null;
98
+ }
99
+ }
100
+ }
101
+ return null;
102
+ }
103
+ function literalValue(node, path) {
104
+ switch (node.type) {
105
+ case "ObjectExpression": {
106
+ const out = {};
107
+ for (const prop of node.properties) {
108
+ if (prop.type !== "Property" ||
109
+ prop.kind !== "init" ||
110
+ prop.computed ||
111
+ prop.method ||
112
+ prop.shorthand) {
113
+ throw notLiteral(path, "a spread, shorthand, method or computed key");
114
+ }
115
+ const keyNode = prop.key;
116
+ const key = keyNode.type === "Identifier"
117
+ ? keyNode.name
118
+ : typeof keyNode.value === "string" ||
119
+ typeof keyNode.value === "number"
120
+ ? String(keyNode.value)
121
+ : null;
122
+ if (key === null || key === "__proto__") {
123
+ throw notLiteral(path, "an unsupported key");
124
+ }
125
+ out[key] = literalValue(prop.value, `${path}.${key}`);
126
+ }
127
+ return out;
128
+ }
129
+ case "ArrayExpression":
130
+ return node.elements.map((element, index) => {
131
+ if (!element || element.type === "SpreadElement") {
132
+ throw notLiteral(`${path}[${index}]`, "a hole or spread");
133
+ }
134
+ return literalValue(element, `${path}[${index}]`);
135
+ });
136
+ case "Literal":
137
+ if (node.regex || node.bigint !== undefined) {
138
+ throw notLiteral(path, "a regular expression or bigint");
139
+ }
140
+ return node.value;
141
+ case "UnaryExpression": {
142
+ const argument = node.argument;
143
+ if (node.operator === "-" &&
144
+ argument.type === "Literal" &&
145
+ typeof argument.value === "number") {
146
+ return -argument.value;
147
+ }
148
+ throw notLiteral(path, `the expression \`${node.operator}…\``);
149
+ }
150
+ case "TemplateLiteral":
151
+ if (node.expressions.length === 0) {
152
+ return (node.quasis[0]?.value)
153
+ .cooked;
154
+ }
155
+ throw notLiteral(path, "a template with ${…}");
156
+ default:
157
+ throw notLiteral(path, node.type === "Identifier"
158
+ ? `the variable \`${node.name}\``
159
+ : `a ${node.type}`);
160
+ }
161
+ }
162
+ function notLiteral(path, found) {
163
+ return new Error(`${path} must be written out as a literal (objects, arrays, strings, numbers, booleans, null); found ${found}`);
164
+ }
165
+ //# sourceMappingURL=view-definition.js.map
@@ -442,6 +442,14 @@ export declare const AgentTurnPollPayloadSchema: import("@sinclair/typebox").TOb
442
442
  * stays off unless the caller explicitly requests an effort level.
443
443
  */
444
444
  reasoning: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
445
+ /**
446
+ * pi-ai's `Model.thinkingLevelMap`: the provider's name for each
447
+ * thinking level, `null` where the model does not serve that level.
448
+ * gpt-5-mini maps `off` to `null` because it cannot turn reasoning off;
449
+ * without the map pi-ai sends `effort: "none"` and OpenAI rejects it.
450
+ * Absent → pi-ai's own defaults.
451
+ */
452
+ thinking_level_map: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>>>;
445
453
  /**
446
454
  * The modalities this model accepts, in pi-ai's own `Model.input`
447
455
  * vocabulary and resolved from pi-ai's model registry — NOT guessed
@@ -489,7 +497,7 @@ export declare const AgentTurnPollPayloadSchema: import("@sinclair/typebox").TOb
489
497
  }>>;
490
498
  /**
491
499
  * The gateway tools available for this turn, by NAME only —
492
- * `ask_user`, `send_message`, `suggest_actions` and the rest of
500
+ * `ask_user`, `send_message` and the rest of
493
501
  * `@lobu/plugin-conversations`. The guest runs that package's own
494
502
  * implementation, so the route, the request body and the schema live
495
503
  * there and never on this wire; sending a name the package does not
@@ -521,6 +529,12 @@ export declare const AgentTurnPollPayloadSchema: import("@sinclair/typebox").TOb
521
529
  conversation_id: import("@sinclair/typebox").TString;
522
530
  platform: import("@sinclair/typebox").TString;
523
531
  }>>;
532
+ /**
533
+ * Ask the turn's own model for follow-up chips after it answers and
534
+ * return them with the completion. Set by the gateway only for a
535
+ * human-facing turn; absent → no chips.
536
+ */
537
+ follow_ups: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TLiteral<true>>;
524
538
  }>>;
525
539
  /**
526
540
  * Long-term memory for this turn: `@lobu/plugin-memory`'s recall hook
@@ -850,6 +864,14 @@ export declare const PollResponseSchema: import("@sinclair/typebox").TObject<{
850
864
  * stays off unless the caller explicitly requests an effort level.
851
865
  */
852
866
  reasoning: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
867
+ /**
868
+ * pi-ai's `Model.thinkingLevelMap`: the provider's name for each
869
+ * thinking level, `null` where the model does not serve that level.
870
+ * gpt-5-mini maps `off` to `null` because it cannot turn reasoning off;
871
+ * without the map pi-ai sends `effort: "none"` and OpenAI rejects it.
872
+ * Absent → pi-ai's own defaults.
873
+ */
874
+ thinking_level_map: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNull]>>>;
853
875
  /**
854
876
  * The modalities this model accepts, in pi-ai's own `Model.input`
855
877
  * vocabulary and resolved from pi-ai's model registry — NOT guessed
@@ -897,7 +919,7 @@ export declare const PollResponseSchema: import("@sinclair/typebox").TObject<{
897
919
  }>>;
898
920
  /**
899
921
  * The gateway tools available for this turn, by NAME only —
900
- * `ask_user`, `send_message`, `suggest_actions` and the rest of
922
+ * `ask_user`, `send_message` and the rest of
901
923
  * `@lobu/plugin-conversations`. The guest runs that package's own
902
924
  * implementation, so the route, the request body and the schema live
903
925
  * there and never on this wire; sending a name the package does not
@@ -929,6 +951,12 @@ export declare const PollResponseSchema: import("@sinclair/typebox").TObject<{
929
951
  conversation_id: import("@sinclair/typebox").TString;
930
952
  platform: import("@sinclair/typebox").TString;
931
953
  }>>;
954
+ /**
955
+ * Ask the turn's own model for follow-up chips after it answers and
956
+ * return them with the completion. Set by the gateway only for a
957
+ * human-facing turn; absent → no chips.
958
+ */
959
+ follow_ups: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TLiteral<true>>;
932
960
  }>>;
933
961
  /**
934
962
  * Long-term memory for this turn: `@lobu/plugin-memory`'s recall hook
@@ -1287,6 +1315,15 @@ export declare const CompleteAgentTurnRequestSchema: import("@sinclair/typebox")
1287
1315
  * (`chat-response-bridge`) already acts on it.
1288
1316
  */
1289
1317
  replied_in_band: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
1318
+ /**
1319
+ * Follow-up chips for the owner's answer, proposed by the same model after it
1320
+ * answered (`tools.follow_ups`). The worker is untrusted, so the completion
1321
+ * route re-sanitizes them; the gateway delivers them with the reply.
1322
+ */
1323
+ suggestions: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
1324
+ title: import("@sinclair/typebox").TString;
1325
+ message: import("@sinclair/typebox").TString;
1326
+ }>>>;
1290
1327
  /**
1291
1328
  * Tool traces that finished too late to ride a heartbeat, oldest first.
1292
1329
  *
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.HeartbeatResponseSchema = exports.DispatchChromeActionResponseSchema = exports.DispatchChromeActionRequestSchema = exports.ExecuteConnectorOperationRequestSchema = exports.HeartbeatRequestSchema = exports.AGENT_TURN_BRIDGE_BYTES = exports.TURN_DELTA_MAX_CHARS = exports.PollAuthSignalResponseSchema = exports.PollAuthSignalRequestSchema = exports.EmitAuthArtifactRequestSchema = exports.CompleteAgentTurnResponseSchema = exports.CompleteAgentTurnRequestSchema = exports.AGENT_TURN_INPUT_MAX = exports.TURN_TOOL_EVENT_QUEUE_MAX = exports.TurnToolEventSchema = exports.TURN_TOOL_OUTPUT_MAX_CHARS = exports.CompleteAutomationResponseSchema = exports.CompleteAutomationRequestSchema = exports.CompleteAuthRequestSchema = exports.CompleteEmbeddingsRequestSchema = exports.EmbeddingEntrySchema = exports.EmbedEventSchema = exports.CompleteActionRequestSchema = exports.CompleteRequestSchema = exports.StreamBatchSchema = exports.ContentItemSchema = exports.ActivatePageResponseSchema = exports.ActivatePageRequestSchema = exports.PollResponseSchema = exports.FeedSourceAckSchema = exports.AgentTurnPollPayloadSchema = exports.AutomationPollPayloadSchema = exports.AutomationPollContextSchema = exports.AutomationPollEventSchema = exports.AutomationPollMetaSchema = exports.AutomationExecutionConfigSchema = exports.PollRequestSchema = exports.WORKER_POLL_MAX_WAIT_SECONDS = exports.FeedNotificationSchema = exports.EXECUTION_BACKENDS = exports.OAuthCredentialsSchema = exports.WorkerExitDiagnosticsSchema = exports.WorkerExitReasonSchema = exports.RunTypeSchema = exports.ConnectorHttpRequestSchema = exports.SourceAttributionSchema = exports.CONNECTOR_HTTP_MAX_BYTES = exports.CONNECTOR_HTTP_AUTH_CAPABILITY = void 0;
30
30
  exports.defaultBackendCapacity = defaultBackendCapacity;
31
31
  const typebox_1 = require("@sinclair/typebox");
32
+ const suggestions_1 = require("../../suggestions");
32
33
  const manage_operations_1 = require("../tools/manage-operations");
33
34
  exports.CONNECTOR_HTTP_AUTH_CAPABILITY = "http_auth";
34
35
  exports.CONNECTOR_HTTP_MAX_BYTES = 4 * 1024 * 1024;
@@ -471,6 +472,14 @@ exports.AgentTurnPollPayloadSchema = typebox_1.Type.Object({
471
472
  * stays off unless the caller explicitly requests an effort level.
472
473
  */
473
474
  reasoning: typebox_1.Type.Optional(typebox_1.Type.Boolean()),
475
+ /**
476
+ * pi-ai's `Model.thinkingLevelMap`: the provider's name for each
477
+ * thinking level, `null` where the model does not serve that level.
478
+ * gpt-5-mini maps `off` to `null` because it cannot turn reasoning off;
479
+ * without the map pi-ai sends `effort: "none"` and OpenAI rejects it.
480
+ * Absent → pi-ai's own defaults.
481
+ */
482
+ thinking_level_map: typebox_1.Type.Optional(typebox_1.Type.Record(typebox_1.Type.String(), typebox_1.Type.Union([typebox_1.Type.String(), typebox_1.Type.Null()]))),
474
483
  /**
475
484
  * The modalities this model accepts, in pi-ai's own `Model.input`
476
485
  * vocabulary and resolved from pi-ai's model registry — NOT guessed
@@ -526,7 +535,7 @@ exports.AgentTurnPollPayloadSchema = typebox_1.Type.Object({
526
535
  remote_runtime: typebox_1.Type.Optional(typebox_1.Type.Object({ provider_id: typebox_1.Type.String({ minLength: 1 }) })),
527
536
  /**
528
537
  * The gateway tools available for this turn, by NAME only —
529
- * `ask_user`, `send_message`, `suggest_actions` and the rest of
538
+ * `ask_user`, `send_message` and the rest of
530
539
  * `@lobu/plugin-conversations`. The guest runs that package's own
531
540
  * implementation, so the route, the request body and the schema live
532
541
  * there and never on this wire; sending a name the package does not
@@ -558,6 +567,12 @@ exports.AgentTurnPollPayloadSchema = typebox_1.Type.Object({
558
567
  conversation_id: typebox_1.Type.String({ minLength: 1 }),
559
568
  platform: typebox_1.Type.String({ minLength: 1 }),
560
569
  })),
570
+ /**
571
+ * Ask the turn's own model for follow-up chips after it answers and
572
+ * return them with the completion. Set by the gateway only for a
573
+ * human-facing turn; absent → no chips.
574
+ */
575
+ follow_ups: typebox_1.Type.Optional(typebox_1.Type.Literal(true)),
561
576
  })),
562
577
  /**
563
578
  * Long-term memory for this turn: `@lobu/plugin-memory`'s recall hook
@@ -969,6 +984,14 @@ exports.CompleteAgentTurnRequestSchema = typebox_1.Type.Object({
969
984
  * (`chat-response-bridge`) already acts on it.
970
985
  */
971
986
  replied_in_band: typebox_1.Type.Optional(typebox_1.Type.Boolean()),
987
+ /**
988
+ * Follow-up chips for the owner's answer, proposed by the same model after it
989
+ * answered (`tools.follow_ups`). The worker is untrusted, so the completion
990
+ * route re-sanitizes them; the gateway delivers them with the reply.
991
+ */
992
+ suggestions: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.Object({ title: typebox_1.Type.String(), message: typebox_1.Type.String() }), {
993
+ maxItems: suggestions_1.SUGGESTION_LIMITS.maxPrompts,
994
+ })),
972
995
  /**
973
996
  * Tool traces that finished too late to ride a heartbeat, oldest first.
974
997
  *
@@ -32,7 +32,7 @@ export * from "./secret-refs";
32
32
  export * from "./reserved";
33
33
  export { extractTraceId, generateTraceId } from "./trace";
34
34
  export type { AgentErrorContext, AgentInlineGuardrail, AgentOptions, AuthProfile, ConversationMessage, DeclaredCredential, HistoryMessage, InstructionContext, InstructionProvider, LogLevel, McpOAuthConfig, NetworkConfig, NixConfig, RegistryEntry, SessionContext, SkillConfig, SkillsConfig, SuggestedPrompt, ThinkingLevel, ThreadResponsePayload, } from "./types";
35
- export { hasCredentialSource } from "./types";
35
+ export { hasCredentialSource, isRefreshSuspended } from "./types";
36
36
  export { SUGGESTION_LIMITS, sanitizeSuggestionPrompts } from "./types";
37
37
  export type { BaseMessage } from "./types/message";
38
38
  export * from "./utils/encryption";
@@ -16,7 +16,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.withLobuFileParameters = exports.slugify = exports.titleFromSessionJsonl = exports.parseSessionEntries = exports.entryToMessage = exports.sanitizeSuggestionPrompts = exports.SUGGESTION_LIMITS = exports.hasCredentialSource = exports.generateTraceId = exports.extractTraceId = exports.SDK_COMPAT_PROTOCOLS = exports.resolveSdkCompat = exports.isSdkCompat = exports.withSpan = exports.withChildSpan = exports.shutdownTracing = exports.SpanStatusCode = exports.SpanKind = exports.runInSpanContext = exports.initTracing = exports.getTracer = exports.getTraceparent = exports.getCurrentSpan = exports.flushTracing = exports.createSpan = exports.createRootSpan = exports.createChildSpan = exports.renderSkillMemorySection = exports.renderFallbackSystemContext = exports.BaseInstructionProvider = exports.CommandRegistry = exports.inferGrantKind = void 0;
19
+ exports.withLobuFileParameters = exports.slugify = exports.titleFromSessionJsonl = exports.parseSessionEntries = exports.entryToMessage = exports.sanitizeSuggestionPrompts = exports.SUGGESTION_LIMITS = exports.isRefreshSuspended = exports.hasCredentialSource = exports.generateTraceId = exports.extractTraceId = exports.SDK_COMPAT_PROTOCOLS = exports.resolveSdkCompat = exports.isSdkCompat = exports.withSpan = exports.withChildSpan = exports.shutdownTracing = exports.SpanStatusCode = exports.SpanKind = exports.runInSpanContext = exports.initTracing = exports.getTracer = exports.getTraceparent = exports.getCurrentSpan = exports.flushTracing = exports.createSpan = exports.createRootSpan = exports.createChildSpan = exports.renderSkillMemorySection = exports.renderFallbackSystemContext = exports.BaseInstructionProvider = exports.CommandRegistry = exports.inferGrantKind = void 0;
20
20
  __exportStar(require("./agent-policy"), exports);
21
21
  __exportStar(require("./tool-trace-summary"), exports);
22
22
  __exportStar(require("./shell-safety"), exports);
@@ -84,6 +84,7 @@ Object.defineProperty(exports, "extractTraceId", { enumerable: true, get: functi
84
84
  Object.defineProperty(exports, "generateTraceId", { enumerable: true, get: function () { return trace_1.generateTraceId; } });
85
85
  var types_1 = require("./types");
86
86
  Object.defineProperty(exports, "hasCredentialSource", { enumerable: true, get: function () { return types_1.hasCredentialSource; } });
87
+ Object.defineProperty(exports, "isRefreshSuspended", { enumerable: true, get: function () { return types_1.isRefreshSuspended; } });
87
88
  var types_2 = require("./types");
88
89
  Object.defineProperty(exports, "SUGGESTION_LIMITS", { enumerable: true, get: function () { return types_2.SUGGESTION_LIMITS; } });
89
90
  Object.defineProperty(exports, "sanitizeSuggestionPrompts", { enumerable: true, get: function () { return types_2.sanitizeSuggestionPrompts; } });
@@ -31,9 +31,22 @@ export declare const SUGGESTION_LIMITS: {
31
31
  * Normalize an untrusted `prompts` value into at most {@link SUGGESTION_LIMITS}
32
32
  * valid `{title,message}` entries. Trims BEFORE capping length (so leading
33
33
  * whitespace can't yield an empty displayed title), drops malformed/empty
34
- * entries, and returns `[]` for any non-array input. Shared by the agent tool
35
- * and the gateway route so the worker (untrusted) and the server enforce one
34
+ * entries, and returns `[]` for any non-array input. Shared by the worker
35
+ * and completion route so the worker (untrusted) and the server enforce one
36
36
  * identical contract.
37
37
  */
38
38
  export declare function sanitizeSuggestionPrompts(value: unknown): SuggestedPrompt[];
39
+ /**
40
+ * The follow-up question asked after a human-facing turn's reply, on the same
41
+ * session and model that wrote it. Asked as a side request — never appended to
42
+ * the conversation — so the model can use the user's language and preferences
43
+ * retained in its current context. Reusing the prefix enables prompt caching.
44
+ */
45
+ export declare const FOLLOW_UP_SUGGESTIONS_PROMPT: string;
46
+ /**
47
+ * The chips in a reply to {@link FOLLOW_UP_SUGGESTIONS_PROMPT}, sanitized.
48
+ * Tolerates a markdown fence or prose around the object by parsing from the
49
+ * first `{` to the last `}`; anything unparseable is no suggestions.
50
+ */
51
+ export declare function parseFollowUpSuggestions(reply: string): SuggestedPrompt[];
39
52
  //# sourceMappingURL=suggestions.d.ts.map
@@ -9,8 +9,9 @@
9
9
  * `@lobu/core` import here.
10
10
  */
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.SUGGESTION_LIMITS = void 0;
12
+ exports.FOLLOW_UP_SUGGESTIONS_PROMPT = exports.SUGGESTION_LIMITS = void 0;
13
13
  exports.sanitizeSuggestionPrompts = sanitizeSuggestionPrompts;
14
+ exports.parseFollowUpSuggestions = parseFollowUpSuggestions;
14
15
  /** Limits enforced wherever suggestions enter or leave durable storage.
15
16
  * `maxTitleChars` counts UTF-16 code units, matching how Slack measures its
16
17
  * 75-char button-text cap (the tightest limit a title reaches on a surface this
@@ -28,8 +29,8 @@ exports.SUGGESTION_LIMITS = {
28
29
  * Normalize an untrusted `prompts` value into at most {@link SUGGESTION_LIMITS}
29
30
  * valid `{title,message}` entries. Trims BEFORE capping length (so leading
30
31
  * whitespace can't yield an empty displayed title), drops malformed/empty
31
- * entries, and returns `[]` for any non-array input. Shared by the agent tool
32
- * and the gateway route so the worker (untrusted) and the server enforce one
32
+ * entries, and returns `[]` for any non-array input. Shared by the worker
33
+ * and completion route so the worker (untrusted) and the server enforce one
33
34
  * identical contract.
34
35
  */
35
36
  function sanitizeSuggestionPrompts(value) {
@@ -59,6 +60,50 @@ function sanitizeSuggestionPrompts(value) {
59
60
  }
60
61
  return out;
61
62
  }
63
+ /**
64
+ * The follow-up question asked after a human-facing turn's reply, on the same
65
+ * session and model that wrote it. Asked as a side request — never appended to
66
+ * the conversation — so the model can use the user's language and preferences
67
+ * retained in its current context. Reusing the prefix enables prompt caching.
68
+ */
69
+ exports.FOLLOW_UP_SUGGESTIONS_PROMPT = [
70
+ "Before the user replies: decide whether your last reply needs follow-up action chips the user can tap.",
71
+ 'Default to {"prompts":[]} when your reply leaves nothing open.',
72
+ 'If your reply offers concrete next steps ("If you want, I can …", "Want me to …?"), turn up to three distinct offers into chips.',
73
+ "Otherwise offer a chip only for a concrete next step your reply leaves open that would help the user proceed.",
74
+ "Return no suggestions for routine answers, acknowledgements, corrections, a finished request with nothing left open, a question the user must answer in their own words, or a reply that closes the topic, and none at all if the user asked for no suggestions.",
75
+ "Do not invent extra work or add a generic offer to explore further.",
76
+ "When useful next steps remain, return 1-3 distinct actions. A single useful action is enough; never pad the list.",
77
+ "",
78
+ 'Each item is {"title","message"}:',
79
+ '- "title": a short tappable label, at most 20 characters.',
80
+ '- "message": the full message sent verbatim AS THE USER if tapped.',
81
+ "",
82
+ "Write both in the language the user writes in. Write `message` in the user's voice, as a request to you:",
83
+ ' good: "Show me the diff" bad: "I can show you the diff"',
84
+ 'Do not call any tool. Reply with STRICT JSON {"prompts":[{"title":"...","message":"..."}]} and nothing else.',
85
+ ].join("\n");
86
+ /**
87
+ * The chips in a reply to {@link FOLLOW_UP_SUGGESTIONS_PROMPT}, sanitized.
88
+ * Tolerates a markdown fence or prose around the object by parsing from the
89
+ * first `{` to the last `}`; anything unparseable is no suggestions.
90
+ */
91
+ function parseFollowUpSuggestions(reply) {
92
+ const start = reply.indexOf("{");
93
+ const end = reply.lastIndexOf("}");
94
+ if (start < 0 || end <= start)
95
+ return [];
96
+ let parsed;
97
+ try {
98
+ parsed = JSON.parse(reply.slice(start, end + 1));
99
+ }
100
+ catch {
101
+ return [];
102
+ }
103
+ if (!parsed || typeof parsed !== "object")
104
+ return [];
105
+ return sanitizeSuggestionPrompts(parsed.prompts);
106
+ }
62
107
  /**
63
108
  * Truncate to at most `maxUnits` UTF-16 code units without splitting a
64
109
  * surrogate pair. Counting code POINTS would undercount against platform caps
@@ -1,4 +1,5 @@
1
1
  import type { SecretRef } from "./secret-refs";
2
+ import type { SuggestedPrompt } from "./suggestions";
2
3
  /**
3
4
  * Unified authentication profile for any model provider.
4
5
  * Persisted per-(userId, agentId) by the gateway's UserAuthProfileStore;
@@ -30,9 +31,23 @@ export interface AuthProfile {
30
31
  /** Durable secret reference for the refresh token. */
31
32
  refreshTokenRef?: SecretRef;
32
33
  accountId?: string;
34
+ /**
35
+ * Refresh suspension set by the token-refresh job when the provider
36
+ * reports the grant itself is dead (`invalid_grant`). Suspended profiles
37
+ * are excluded from token refresh and credential selection until the user
38
+ * reconnects, which writes fresh metadata without this field.
39
+ */
40
+ refreshSuspended?: {
41
+ /** Provider OAuth error code that killed the grant. */
42
+ code: string;
43
+ /** Epoch ms when the suspension was recorded. */
44
+ at: number;
45
+ };
33
46
  };
34
47
  createdAt: number;
35
48
  }
49
+ /** True when the token-refresh job suspended this profile's grant as dead. */
50
+ export declare function isRefreshSuspended(profile: AuthProfile): boolean;
36
51
  /** True if the profile has any credential source (resolved or ref). */
37
52
  export declare function hasCredentialSource(profile: AuthProfile): boolean;
38
53
  /**
@@ -234,6 +249,17 @@ export interface ThreadResponsePayload {
234
249
  * duplicate of the reply and must always surface.
235
250
  */
236
251
  repliedInBand?: boolean;
252
+ /**
253
+ * Follow-up chips for this reply, proposed by the model that wrote it. Set
254
+ * only on the COMPLETION row; delivered with the reply once output
255
+ * guardrails pass.
256
+ */
257
+ suggestions?: SuggestedPrompt[];
258
+ /**
259
+ * The agent_turn `runs.id` that produced this terminal row. Orders a late
260
+ * terminal against newer turns of the same conversation.
261
+ */
262
+ turnRunId?: number;
237
263
  /**
238
264
  * Raw error message. When provider context is available, the gateway labels
239
265
  * the source and unwraps the common JSON message envelope without rewording
@@ -1,7 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SUGGESTION_LIMITS = exports.sanitizeSuggestionPrompts = void 0;
4
+ exports.isRefreshSuspended = isRefreshSuspended;
4
5
  exports.hasCredentialSource = hasCredentialSource;
6
+ /** True when the token-refresh job suspended this profile's grant as dead. */
7
+ function isRefreshSuspended(profile) {
8
+ return Boolean(profile.metadata?.refreshSuspended);
9
+ }
5
10
  /** True if the profile has any credential source (resolved or ref). */
6
11
  function hasCredentialSource(profile) {
7
12
  return Boolean(profile.credential || profile.credentialRef);
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/core",
3
- "version": "23.0.0",
3
+ "version": "24.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Core types and utilities for Lobu agent platform",
6
6
  "repository": {
@@ -221,6 +221,11 @@
221
221
  "import": "./dist/contracts/tools/view-attach.js",
222
222
  "require": "./dist/contracts/tools/view-attach.js"
223
223
  },
224
+ "./contracts/tools/view-definition": {
225
+ "types": "./dist/contracts/tools/view-definition.d.ts",
226
+ "import": "./dist/contracts/tools/view-definition.js",
227
+ "require": "./dist/contracts/tools/view-definition.js"
228
+ },
224
229
  "./contracts/tools/view-path": {
225
230
  "types": "./dist/contracts/tools/view-path.d.ts",
226
231
  "import": "./dist/contracts/tools/view-path.js",
@@ -233,14 +238,15 @@
233
238
  }
234
239
  },
235
240
  "dependencies": {
236
- "@sinclair/typebox": "^0.34.41",
237
- "ajv": "^8.17.1",
238
- "ajv-formats": "^3.0.1",
239
241
  "@opentelemetry/api": "^1.9.0",
240
- "@opentelemetry/sdk-trace-node": "^2.11.0",
241
242
  "@opentelemetry/exporter-trace-otlp-grpc": "^0.222.0",
242
243
  "@opentelemetry/resources": "^2.11.0",
244
+ "@opentelemetry/sdk-trace-node": "^2.11.0",
243
245
  "@opentelemetry/semantic-conventions": "^1.28.0",
246
+ "@sinclair/typebox": "^0.34.41",
247
+ "acorn": "^8.16.0",
248
+ "ajv": "^8.17.1",
249
+ "ajv-formats": "^3.0.1",
244
250
  "winston": "^3.17.0"
245
251
  }
246
252
  }