@lobu/runtime-device 24.8.0 → 24.9.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 (70) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +24 -24
  3. package/npm-shrinkwrap.json +179 -175
  4. package/package.json +1 -1
  5. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +14 -3
  6. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +27 -0
  7. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +16 -5
  8. package/vendor/cli/dist/commands/_lib/apply/client.js +31 -9
  9. package/vendor/cli/dist/commands/_lib/apply/deployment.d.ts +8 -12
  10. package/vendor/cli/dist/commands/_lib/apply/deployment.js +14 -1
  11. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +8 -4
  12. package/vendor/cli/dist/commands/_lib/apply/desired-state.js +2 -1
  13. package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +26 -7
  14. package/vendor/cli/dist/commands/_lib/apply/diff.js +101 -30
  15. package/vendor/cli/dist/commands/_lib/apply/map-config.js +29 -2
  16. package/vendor/cli/dist/commands/_lib/apply/render.js +2 -0
  17. package/vendor/cli/dist/commands/_lib/apply/shared.d.ts +20 -0
  18. package/vendor/cli/dist/commands/_lib/apply/shared.js +22 -0
  19. package/vendor/cli/dist/commands/_lib/init-from-org/bootstrap.js +14 -0
  20. package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +6 -2
  21. package/vendor/cli/dist/config/define.d.ts +21 -3
  22. package/vendor/cli/dist/connectors/README.md +6 -2
  23. package/vendor/cli/dist/connectors/github.ts +16 -3
  24. package/vendor/cli/dist/connectors/market_quotes.ts +388 -91
  25. package/vendor/cli/dist/connectors/postgres.ts +21 -14
  26. package/vendor/cli/dist/connectors/x-dm-adapter.js +55 -21
  27. package/vendor/cli/dist/connectors/x.ts +1 -1
  28. package/vendor/cli/dist/runtime-components.json +4 -4
  29. package/vendor/cli/package.json +1 -1
  30. package/vendor/connector-sdk/dist/connector-types.d.ts +23 -2
  31. package/vendor/connector-sdk/package.json +1 -1
  32. package/vendor/connector-worker/dist/daemon/automation.js +7 -4
  33. package/vendor/connector-worker/dist/executor/isolate.js +3 -0
  34. package/vendor/connector-worker/package.json +1 -1
  35. package/vendor/core/dist/classify-error.d.ts +3 -4
  36. package/vendor/core/dist/classify-error.js +8 -8
  37. package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +17 -1
  38. package/vendor/core/dist/contracts/tools/collection-presentation.js +27 -3
  39. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +39 -0
  40. package/vendor/core/dist/contracts/tools/manage-automations.js +11 -1
  41. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
  42. package/vendor/core/dist/contracts/tools/manage-views.d.ts +249 -7
  43. package/vendor/core/dist/contracts/tools/manage-views.js +83 -21
  44. package/vendor/core/dist/contracts/tools/navigation.d.ts +248 -0
  45. package/vendor/core/dist/contracts/tools/navigation.js +284 -0
  46. package/vendor/core/dist/contracts/tools/view-attach.d.ts +7 -0
  47. package/vendor/core/dist/contracts/tools/view-attach.js +15 -0
  48. package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +4 -1
  49. package/vendor/core/dist/contracts/tools/view-content-hash.js +4 -2
  50. package/vendor/core/dist/contracts/tools/view-definition.d.ts +2 -0
  51. package/vendor/core/dist/contracts/tools/view-definition.js +52 -0
  52. package/vendor/core/dist/contracts/tools/view-host.d.ts +68 -0
  53. package/vendor/core/dist/contracts/tools/view-host.js +28 -1
  54. package/vendor/core/dist/contracts/tools/view-scope.d.ts +31 -0
  55. package/vendor/core/dist/contracts/tools/view-scope.js +45 -0
  56. package/vendor/core/dist/errors.d.ts +17 -24
  57. package/vendor/core/dist/errors.js +17 -24
  58. package/vendor/core/dist/types.d.ts +0 -6
  59. package/vendor/core/package.json +11 -1
  60. package/vendor/views/dist/api.d.ts +30 -5
  61. package/vendor/views/dist/api.js +22 -8
  62. package/vendor/views/dist/bridge.d.ts +17 -0
  63. package/vendor/views/dist/bridge.js +49 -1
  64. package/vendor/views/dist/components.d.ts +27 -5
  65. package/vendor/views/dist/components.js +57 -7
  66. package/vendor/views/dist/embed.d.ts +98 -0
  67. package/vendor/views/dist/embed.js +418 -0
  68. package/vendor/views/dist/index.d.ts +3 -1
  69. package/vendor/views/dist/index.js +1 -0
  70. package/vendor/views/package.json +1 -1
@@ -47,6 +47,18 @@ function readViewDefinition(js) {
47
47
  throw new Error(`${at}: ${message}`);
48
48
  }
49
49
  const def = raw;
50
+ for (const [name, action] of Object.entries(def.actions ?? {})) {
51
+ if (action.emits === undefined && action.updates === undefined) {
52
+ throw new Error(`defineView.actions.${name}: declare emits, updates, or both`);
53
+ }
54
+ }
55
+ const resources = [...new Set(def.resources ?? [])];
56
+ for (const entry of resources) {
57
+ const problem = imageOriginProblem(entry);
58
+ if (problem) {
59
+ throw new Error(`defineView.resources: ${JSON.stringify(entry)} ${problem}`);
60
+ }
61
+ }
50
62
  return {
51
63
  key: def.key,
52
64
  name: def.name?.trim() ? def.name : def.key,
@@ -54,8 +66,48 @@ function readViewDefinition(js) {
54
66
  attach: def.attach,
55
67
  params: def.params ?? {},
56
68
  actions: def.actions ?? {},
69
+ resources,
57
70
  };
58
71
  }
72
+ /**
73
+ * Why `entry` is not a declarable image origin, or null when it is: exactly
74
+ * `https://<host>[:port]` as the URL parser prints the origin (so no path,
75
+ * query, fragment, userinfo, uppercase or default port), with a public
76
+ * multi-label hostname. Localhost, IP literals and single-label hosts would
77
+ * point a viewer's browser at their own machine or network.
78
+ */
79
+ function imageOriginProblem(entry) {
80
+ let url;
81
+ try {
82
+ url = new URL(entry);
83
+ }
84
+ catch {
85
+ return "is not a URL; write an origin like https://tiles.example.com";
86
+ }
87
+ if (url.protocol !== "https:")
88
+ return "must use https";
89
+ if (url.hostname.includes("*"))
90
+ return "cannot use a wildcard; list each origin";
91
+ if (url.origin !== entry) {
92
+ return `must be a bare origin with no path, query, fragment or credentials; write ${url.origin}`;
93
+ }
94
+ const host = url.hostname;
95
+ // The URL parser brackets every IPv6 literal and rewrites any host whose
96
+ // last label is numeric into IPv4, so these two checks cover IP literals.
97
+ const labels = host.split(".");
98
+ const last = labels[labels.length - 1] ?? "";
99
+ const numeric = last !== "" && [...last].every((c) => c >= "0" && c <= "9");
100
+ if (host.startsWith("[") || numeric) {
101
+ return "must name a host, not an IP address";
102
+ }
103
+ if (host === "localhost" || host.endsWith(".localhost")) {
104
+ return "must be a public host, not localhost";
105
+ }
106
+ if (labels.length < 2 || labels.some((label) => label === "")) {
107
+ return "must be a fully qualified public hostname";
108
+ }
109
+ return null;
110
+ }
59
111
  function defineViewLocalName(body) {
60
112
  for (const statement of body) {
61
113
  if (statement.type !== "ImportDeclaration")
@@ -1,7 +1,75 @@
1
+ import type { CollectionSelection } from "./collection-selection";
1
2
  /** Browser bridge routing hints, never authority. */
2
3
  export declare const VIEW_WORKSPACE_META_KEY = "lobu/view-workspace";
3
4
  export declare const VIEW_OPEN_RECORD_METHOD = "lobu/open-record";
4
5
  /** A mixed read/write tool is admitted only for these fixed read actions.
5
6
  * The server still applies the visiting user's authorization and org scope. */
6
7
  export declare function isViewRead(tool: string, args: Record<string, unknown> | undefined): boolean;
8
+ /**
9
+ * Embedded views: a view places another, independently registered view in a
10
+ * slot. The guest only reports where its slots are; the web host mounts each
11
+ * child as its own sandboxed frame over the slot, with the visitor's session,
12
+ * its own view key and its own actions — the parent never hosts the child's
13
+ * code, so it cannot speak for it. A host that does not implement the methods
14
+ * answers -32601 and the guest says so in the slot.
15
+ */
16
+ /** guest → host request: the slots on screen now. Answered per slot. */
17
+ export declare const VIEW_EMBEDS_SYNC_METHOD = "lobu/embeds/sync";
18
+ /** guest → host request: keyboard focus moves into a slot's child, `{ id,
19
+ * direction? }`; `direction` says which way the visitor was tabbing. */
20
+ export declare const VIEW_EMBEDS_FOCUS_METHOD = "lobu/embeds/focus";
21
+ /** host → guest: a child's height, so the slot reserves its space. */
22
+ export declare const VIEW_EMBED_SIZE_NOTIFICATION = "lobu/notifications/embed-size";
23
+ /** host → guest: keyboard focus left a child; continue after or before it. */
24
+ export declare const VIEW_EMBED_FOCUS_NOTIFICATION = "lobu/notifications/embed-focus";
25
+ /** host → child guest: keyboard focus entered this embedded view, `{ direction
26
+ * }`; it lands on the first control going forward, the last going backward,
27
+ * so entering a child is one Tab, never a stop on its empty document. */
28
+ export declare const VIEW_FOCUS_ENTER_NOTIFICATION = "lobu/notifications/focus-enter";
29
+ export type ViewFocusDirection = "forward" | "backward";
30
+ /** Child frames one view may show at once. */
31
+ export declare const VIEW_EMBED_MAX_COUNT = 8;
32
+ /** Nesting below the page's own view: a child may embed, a grandchild may not. */
33
+ export declare const VIEW_EMBED_MAX_DEPTH = 2;
34
+ /** Params one slot may pass to its child. */
35
+ export declare const VIEW_EMBED_MAX_PARAMS = 20;
36
+ export type ViewEmbedParams = Record<string, string | number | boolean>;
37
+ /** The child's subject, combined by the same rule as `open_view`'s scope
38
+ * (`viewScopeShapeError`); `entity` may also be a source key, which then
39
+ * needs `type`. The collection selection is the host-owned list filter —
40
+ * never one of the child's own params. */
41
+ export interface ViewEmbedScope {
42
+ type?: string;
43
+ entity?: number | string;
44
+ event?: number;
45
+ collection?: CollectionSelection;
46
+ }
47
+ export interface ViewEmbedBox {
48
+ x: number;
49
+ y: number;
50
+ width: number;
51
+ height: number;
52
+ }
53
+ /** One slot as the guest reports it; `rect` is in the guest's viewport.
54
+ * `rect.clip` is the part of it the guest actually shows — inside every
55
+ * scrolling or clipping ancestor, and outside any dialog or menu laid over
56
+ * it — so the host never lets the child cover the parent's own controls.
57
+ * Absent means all of it; an empty box means none. */
58
+ export interface ViewEmbedSlot {
59
+ id: string;
60
+ view: string;
61
+ scope: ViewEmbedScope;
62
+ params: ViewEmbedParams;
63
+ rect: ViewEmbedBox & {
64
+ clip?: ViewEmbedBox;
65
+ };
66
+ }
67
+ export type ViewEmbedStatus = {
68
+ id: string;
69
+ status: "mounted";
70
+ } | {
71
+ id: string;
72
+ status: "refused";
73
+ reason: "cycle" | "depth" | "limit" | "invalid";
74
+ };
7
75
  //# sourceMappingURL=view-host.d.ts.map
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VIEW_OPEN_RECORD_METHOD = exports.VIEW_WORKSPACE_META_KEY = void 0;
3
+ exports.VIEW_EMBED_MAX_PARAMS = exports.VIEW_EMBED_MAX_DEPTH = exports.VIEW_EMBED_MAX_COUNT = exports.VIEW_FOCUS_ENTER_NOTIFICATION = exports.VIEW_EMBED_FOCUS_NOTIFICATION = exports.VIEW_EMBED_SIZE_NOTIFICATION = exports.VIEW_EMBEDS_FOCUS_METHOD = exports.VIEW_EMBEDS_SYNC_METHOD = exports.VIEW_OPEN_RECORD_METHOD = exports.VIEW_WORKSPACE_META_KEY = void 0;
4
4
  exports.isViewRead = isViewRead;
5
5
  /** Browser bridge routing hints, never authority. */
6
6
  exports.VIEW_WORKSPACE_META_KEY = "lobu/view-workspace";
@@ -27,4 +27,31 @@ function isViewRead(tool, args) {
27
27
  args?.schema_type === "entity_type" &&
28
28
  (args.action === "list" || args.action === "get"));
29
29
  }
30
+ /**
31
+ * Embedded views: a view places another, independently registered view in a
32
+ * slot. The guest only reports where its slots are; the web host mounts each
33
+ * child as its own sandboxed frame over the slot, with the visitor's session,
34
+ * its own view key and its own actions — the parent never hosts the child's
35
+ * code, so it cannot speak for it. A host that does not implement the methods
36
+ * answers -32601 and the guest says so in the slot.
37
+ */
38
+ /** guest → host request: the slots on screen now. Answered per slot. */
39
+ exports.VIEW_EMBEDS_SYNC_METHOD = "lobu/embeds/sync";
40
+ /** guest → host request: keyboard focus moves into a slot's child, `{ id,
41
+ * direction? }`; `direction` says which way the visitor was tabbing. */
42
+ exports.VIEW_EMBEDS_FOCUS_METHOD = "lobu/embeds/focus";
43
+ /** host → guest: a child's height, so the slot reserves its space. */
44
+ exports.VIEW_EMBED_SIZE_NOTIFICATION = "lobu/notifications/embed-size";
45
+ /** host → guest: keyboard focus left a child; continue after or before it. */
46
+ exports.VIEW_EMBED_FOCUS_NOTIFICATION = "lobu/notifications/embed-focus";
47
+ /** host → child guest: keyboard focus entered this embedded view, `{ direction
48
+ * }`; it lands on the first control going forward, the last going backward,
49
+ * so entering a child is one Tab, never a stop on its empty document. */
50
+ exports.VIEW_FOCUS_ENTER_NOTIFICATION = "lobu/notifications/focus-enter";
51
+ /** Child frames one view may show at once. */
52
+ exports.VIEW_EMBED_MAX_COUNT = 8;
53
+ /** Nesting below the page's own view: a child may embed, a grandchild may not. */
54
+ exports.VIEW_EMBED_MAX_DEPTH = 2;
55
+ /** Params one slot may pass to its child. */
56
+ exports.VIEW_EMBED_MAX_PARAMS = 20;
30
57
  //# sourceMappingURL=view-host.js.map
@@ -0,0 +1,31 @@
1
+ import { type Static } from "@sinclair/typebox";
2
+ export declare const ViewKeySchema: import("@sinclair/typebox").TString;
3
+ export declare const ViewScopeSchema: import("@sinclair/typebox").TObject<{
4
+ collection: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
5
+ search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
6
+ filters: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
7
+ field: import("@sinclair/typebox").TString;
8
+ op: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"eq">, import("@sinclair/typebox").TLiteral<"neq">]>;
9
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
10
+ }>, import("@sinclair/typebox").TObject<{
11
+ field: import("@sinclair/typebox").TString;
12
+ op: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"lt">, import("@sinclair/typebox").TLiteral<"lte">, import("@sinclair/typebox").TLiteral<"gt">, import("@sinclair/typebox").TLiteral<"gte">]>;
13
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber]>;
14
+ }>]>>>;
15
+ segment: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
16
+ }>>;
17
+ type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
18
+ entity: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
19
+ event: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
20
+ }>;
21
+ export type ViewScopeInput = Static<typeof ViewScopeSchema>;
22
+ /** Which scope fields combine. `open_view`, a navigation entry and an
23
+ * embedded view all apply this one rule, so a scope one accepts the others
24
+ * accept too. Null when the combination is valid. */
25
+ export declare function viewScopeShapeError(scope: {
26
+ type?: unknown;
27
+ entity?: unknown;
28
+ event?: unknown;
29
+ collection?: unknown;
30
+ }): string | null;
31
+ //# sourceMappingURL=view-scope.d.ts.map
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ViewScopeSchema = exports.ViewKeySchema = void 0;
4
+ exports.viewScopeShapeError = viewScopeShapeError;
5
+ const typebox_1 = require("@sinclair/typebox");
6
+ const collection_selection_1 = require("./collection-selection");
7
+ // A view key names the module: lowercase, dashes, 1-64 chars. The folder is
8
+ // only a convention — the key is the identity (no `custom:<name>` prefix).
9
+ exports.ViewKeySchema = typebox_1.Type.String({
10
+ pattern: "^[a-z0-9][a-z0-9-]{0,63}$",
11
+ minLength: 1,
12
+ maxLength: 64,
13
+ description: "View key, e.g. 'pipeline'.",
14
+ });
15
+ // What a view opens for: `open_view`'s scope, and a navigation entry's. The
16
+ // page it lands on follows from the view's attachments; scope is never
17
+ // inferred from where a link sits.
18
+ exports.ViewScopeSchema = typebox_1.Type.Object({
19
+ collection: typebox_1.Type.Optional(collection_selection_1.CollectionSelectionSchema),
20
+ type: typebox_1.Type.Optional(typebox_1.Type.String({
21
+ minLength: 1,
22
+ description: "Entity-type slug the view opens for.",
23
+ })),
24
+ entity: typebox_1.Type.Optional(typebox_1.Type.Integer({ description: "Entity id the view opens for." })),
25
+ event: typebox_1.Type.Optional(typebox_1.Type.Integer({
26
+ description: "Event id the view opens for. It names the event's supersede lineage, so the view shows the current version, and it opens at /events/<id>/-/views/<key>.",
27
+ })),
28
+ }, {
29
+ description: "Required unless the view is attached to the workspace. Pass scope.type, scope.entity, or scope.event to select its subject.",
30
+ });
31
+ /** Which scope fields combine. `open_view`, a navigation entry and an
32
+ * embedded view all apply this one rule, so a scope one accepts the others
33
+ * accept too. Null when the combination is valid. */
34
+ function viewScopeShapeError(scope) {
35
+ if (scope.collection !== undefined &&
36
+ (!scope.type || scope.entity !== undefined || scope.event !== undefined)) {
37
+ return "Collection selection requires scope.type without entity or event";
38
+ }
39
+ if (scope.event !== undefined &&
40
+ (scope.type !== undefined || scope.entity !== undefined)) {
41
+ return "scope.event names the view's subject on its own; drop scope.type and scope.entity";
42
+ }
43
+ return null;
44
+ }
45
+ //# sourceMappingURL=view-scope.js.map
@@ -140,22 +140,17 @@ export declare const AGENT_ERRORS: Record<AgentErrorCode, AgentErrorSpec>;
140
140
  * Provider says: the key is VALID, the account just cannot spend — a balance,
141
141
  * credit, or billing-limit wall rather than a windowed rate limit.
142
142
  *
143
- * The native turn classifier maps this wording to
144
- * `PROVIDER_QUOTA_EXHAUSTED`, while `providerQuotaResetNotBefore` parks
145
- * an Automation for a day on the same wording. They were maintained as separate
146
- * literals and drifted in both directions: the parker learned OpenAI's
147
- * "no credits remaining" while the classifier did not, and the classifier
148
- * matched "insufficient quota" while the parker's
149
- * list did not. Because the server gates on the code the worker assigns, the
150
- * first drift silently disabled BOTH the day-park and the provider-health
151
- * writeback for OpenAI balance exhaustion (observed in prod 2026-08-05). This
152
- * union closes both — which deliberately promotes reset-less "insufficient
153
- * quota" wording (OpenAI/Azure billing) into the day-park; the retry-horizon
154
- * guard in `balanceExhaustedNotBefore` keeps windowed 429s out of it.
143
+ * `classifyErrorMessage` maps this wording to `PROVIDER_QUOTA_EXHAUSTED`, and
144
+ * the device daemon stops an OpenCode run that is retrying it, since no retry
145
+ * clears an empty balance. It lives in core because separate copies of this
146
+ * list drifted in both directions: one learned OpenAI's "no credits remaining"
147
+ * while the classifier did not, and the classifier matched "insufficient
148
+ * quota" while the other did not, which left OpenAI balance exhaustion
149
+ * unclassified in prod (2026-08-05). This union closes both.
155
150
  *
156
151
  * Keep this to balance/billing wording only. Windowed limits ("too many
157
- * requests", a bare 429) classify as quota too, but must NOT day-park — they
158
- * self-heal, often within the minute.
152
+ * requests", a bare 429) classify as quota too, but they self-heal, often
153
+ * within the minute, so they belong in {@link PROVIDER_WINDOWED_QUOTA}.
159
154
  */
160
155
  export declare const PROVIDER_BALANCE_EXHAUSTED: RegExp;
161
156
  /**
@@ -165,17 +160,15 @@ export declare const PROVIDER_BALANCE_EXHAUSTED: RegExp;
165
160
  *
166
161
  * Hoisted here for exactly the reason {@link PROVIDER_BALANCE_EXHAUSTED} was.
167
162
  * This alternation was maintained as three independent literals — the turn
168
- * classifier (`classify-error.ts`), the device schedule parker
169
- * (`deviceProviderQuotaResetNotBefore`) and the server's own `INFRA_PATTERNS`
170
- * — and drifted the same way the balance list did: the device parker learned
171
- * ChatGPT's `usage limit` and the other two did not, so over the 30 days to
172
- * 2026-09-15, 47 runs the provider had refused were recorded as the agent's
173
- * fault, rendered to the user with no remediation CTA, and dodged the
174
- * PROVIDER_* alert.
163
+ * classifier (`classify-error.ts`), a since-removed device schedule check and
164
+ * the server's own `INFRA_PATTERNS` — and drifted the same way the balance
165
+ * list did: the device check learned ChatGPT's `usage limit` and the other two
166
+ * did not, so over the 30 days to 2026-09-15, 47 runs the provider had refused
167
+ * were recorded as the agent's fault, rendered to the user with no remediation
168
+ * CTA, and dodged the PROVIDER_* alert.
175
169
  *
176
- * Keep windowed wording ONLY. These must classify as quota but must NOT reach
177
- * the day-park: they often clear within the minute, and the caller decides the
178
- * horizon from the provider's own named reset.
170
+ * Keep windowed wording ONLY. These classify as quota, but they often clear
171
+ * within the minute, so nothing may treat them as a balance wall.
179
172
  */
180
173
  export declare const PROVIDER_WINDOWED_QUOTA: RegExp;
181
174
  /** Parse an `AgentErrorCode` from an unknown value (payload/DB boundary). */
@@ -211,22 +211,17 @@ exports.AGENT_ERRORS = {
211
211
  * Provider says: the key is VALID, the account just cannot spend — a balance,
212
212
  * credit, or billing-limit wall rather than a windowed rate limit.
213
213
  *
214
- * The native turn classifier maps this wording to
215
- * `PROVIDER_QUOTA_EXHAUSTED`, while `providerQuotaResetNotBefore` parks
216
- * an Automation for a day on the same wording. They were maintained as separate
217
- * literals and drifted in both directions: the parker learned OpenAI's
218
- * "no credits remaining" while the classifier did not, and the classifier
219
- * matched "insufficient quota" while the parker's
220
- * list did not. Because the server gates on the code the worker assigns, the
221
- * first drift silently disabled BOTH the day-park and the provider-health
222
- * writeback for OpenAI balance exhaustion (observed in prod 2026-08-05). This
223
- * union closes both — which deliberately promotes reset-less "insufficient
224
- * quota" wording (OpenAI/Azure billing) into the day-park; the retry-horizon
225
- * guard in `balanceExhaustedNotBefore` keeps windowed 429s out of it.
214
+ * `classifyErrorMessage` maps this wording to `PROVIDER_QUOTA_EXHAUSTED`, and
215
+ * the device daemon stops an OpenCode run that is retrying it, since no retry
216
+ * clears an empty balance. It lives in core because separate copies of this
217
+ * list drifted in both directions: one learned OpenAI's "no credits remaining"
218
+ * while the classifier did not, and the classifier matched "insufficient
219
+ * quota" while the other did not, which left OpenAI balance exhaustion
220
+ * unclassified in prod (2026-08-05). This union closes both.
226
221
  *
227
222
  * Keep this to balance/billing wording only. Windowed limits ("too many
228
- * requests", a bare 429) classify as quota too, but must NOT day-park — they
229
- * self-heal, often within the minute.
223
+ * requests", a bare 429) classify as quota too, but they self-heal, often
224
+ * within the minute, so they belong in {@link PROVIDER_WINDOWED_QUOTA}.
230
225
  */
231
226
  exports.PROVIDER_BALANCE_EXHAUSTED = /credit balance is too low|insufficient (?:credits?|balance|funds|quota)\b|no resource package|billing_hard_limit_reached|payment required|exceeded your current quota|out of credits?\b|no credits remaining/i;
232
227
  /**
@@ -236,17 +231,15 @@ exports.PROVIDER_BALANCE_EXHAUSTED = /credit balance is too low|insufficient (?:
236
231
  *
237
232
  * Hoisted here for exactly the reason {@link PROVIDER_BALANCE_EXHAUSTED} was.
238
233
  * This alternation was maintained as three independent literals — the turn
239
- * classifier (`classify-error.ts`), the device schedule parker
240
- * (`deviceProviderQuotaResetNotBefore`) and the server's own `INFRA_PATTERNS`
241
- * — and drifted the same way the balance list did: the device parker learned
242
- * ChatGPT's `usage limit` and the other two did not, so over the 30 days to
243
- * 2026-09-15, 47 runs the provider had refused were recorded as the agent's
244
- * fault, rendered to the user with no remediation CTA, and dodged the
245
- * PROVIDER_* alert.
234
+ * classifier (`classify-error.ts`), a since-removed device schedule check and
235
+ * the server's own `INFRA_PATTERNS` — and drifted the same way the balance
236
+ * list did: the device check learned ChatGPT's `usage limit` and the other two
237
+ * did not, so over the 30 days to 2026-09-15, 47 runs the provider had refused
238
+ * were recorded as the agent's fault, rendered to the user with no remediation
239
+ * CTA, and dodged the PROVIDER_* alert.
246
240
  *
247
- * Keep windowed wording ONLY. These must classify as quota but must NOT reach
248
- * the day-park: they often clear within the minute, and the caller decides the
249
- * horizon from the provider's own named reset.
241
+ * Keep windowed wording ONLY. These classify as quota, but they often clear
242
+ * within the minute, so nothing may treat them as a balance wall.
250
243
  */
251
244
  exports.PROVIDER_WINDOWED_QUOTA = /limit exhausted|usage limit|rate[-\s]?limit|quota (?:exceeded|exhausted)|too many requests|\b429\b|resource_exhausted/i;
252
245
  /** Parse an `AgentErrorCode` from an unknown value (payload/DB boundary). */
@@ -266,12 +266,6 @@ export interface ThreadResponsePayload {
266
266
  * the provider's sentence; `errorCode` selects the CTA link.
267
267
  */
268
268
  error?: string;
269
- /**
270
- * Original terminal error used only for durable run bookkeeping when an
271
- * output guardrail replaces the user-visible error text. Gateway-owned;
272
- * renderers must never expose this field to clients.
273
- */
274
- bookkeepingError?: string;
275
269
  errorCode?: string;
276
270
  /** Non-secret provider/model targeting for the error CTA. */
277
271
  errorContext?: AgentErrorContext;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lobu/core",
3
- "version": "24.8.0",
3
+ "version": "24.9.0",
4
4
  "license": "Apache-2.0",
5
5
  "description": "Core types and utilities for Lobu agent platform",
6
6
  "repository": {
@@ -241,6 +241,16 @@
241
241
  "import": "./dist/contracts/tools/pagination.js",
242
242
  "require": "./dist/contracts/tools/pagination.js"
243
243
  },
244
+ "./contracts/tools/navigation": {
245
+ "types": "./dist/contracts/tools/navigation.d.ts",
246
+ "import": "./dist/contracts/tools/navigation.js",
247
+ "require": "./dist/contracts/tools/navigation.js"
248
+ },
249
+ "./contracts/tools/view-scope": {
250
+ "types": "./dist/contracts/tools/view-scope.d.ts",
251
+ "import": "./dist/contracts/tools/view-scope.js",
252
+ "require": "./dist/contracts/tools/view-scope.js"
253
+ },
244
254
  "./contracts/tools/view-host": {
245
255
  "types": "./dist/contracts/tools/view-host.d.ts",
246
256
  "import": "./dist/contracts/tools/view-host.js",
@@ -145,9 +145,33 @@ export interface ViewDefinition {
145
145
  * no attach/detach verbs. */
146
146
  attach: Attachment[];
147
147
  params?: Record<string, ParamDef>;
148
- actions?: Record<string, {
149
- emits: string;
150
- }>;
148
+ actions?: Record<string, ActionDef>;
149
+ /** External origins the view may load images from, such as a map tile
150
+ * server: bare https origins with a public hostname and no path
151
+ * (`"https://tile.openstreetmap.org"`), at most 8. Images only is a
152
+ * save-time check (the validator renders the empty, error and loading
153
+ * states), not a runtime limit: MCP hosts receive these as
154
+ * `resourceDomains`, which also allows scripts, styles, fonts and media
155
+ * from them, and the Lobu web app applies no runtime CSP to views. Declare
156
+ * only image or tile CDN origins you trust. */
157
+ resources?: string[];
158
+ }
159
+ /** A declared action: the event kind it emits, the entity fields it may
160
+ * update, or both (committed in one transaction). */
161
+ export interface ActionDef {
162
+ emits?: string;
163
+ /** Submit `{ entity_id, set: { field: value } }` as the action value. The
164
+ * view must attach to `entityType`. Stamped (x-lobu-stamps) fields are
165
+ * server-owned and refused. */
166
+ updates?: {
167
+ entityType: string;
168
+ fields: string[];
169
+ };
170
+ }
171
+ export interface ActionOptions {
172
+ /** For an `updates` action: metadata field -> the value this view read.
173
+ * The server checks it under the row lock and refuses a stale write (409). */
174
+ expected?: Record<string, unknown>;
151
175
  }
152
176
  export declare function defineView(def: ViewDefinition): ViewDefinition;
153
177
  export declare function useParams(): readonly [
@@ -264,8 +288,9 @@ export interface ActionResult {
264
288
  /** Mint one id for a deliberate submission, retained by its retry closure. */
265
289
  export declare function mintInteractionId(): string;
266
290
  /** Submit a declared action. Failed acknowledgements expose an explicit retry
267
- * that keeps the original value, event subject and interaction id. */
268
- export declare function useAction(name: string): (value?: Record<string, unknown>) => Promise<ActionResult>;
291
+ * that keeps the original value, expected values, event subject and
292
+ * interaction id. */
293
+ export declare function useAction(name: string): (value?: Record<string, unknown>, options?: ActionOptions) => Promise<ActionResult>;
269
294
  export declare function defaultsFor(def: ViewDefinition): Params;
270
295
  export declare function coerceParams(def: ViewDefinition, raw: unknown): Params;
271
296
  export declare function coerceScope(raw: unknown): Scope;
@@ -2,6 +2,7 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import { Component, createContext, useCallback, useContext, useEffect, useMemo, useRef, useState, } from "react";
3
3
  import { createRoot } from "react-dom/client";
4
4
  import { ViewBridge, ViewBridgeError, } from "./bridge.js";
5
+ import { EmbedProvider, EmbedRegistry } from "./embed.js";
5
6
  export function defineView(def) {
6
7
  if (!def || typeof def.key !== "string" || def.key.length === 0) {
7
8
  throw new Error("defineView({ key, attach, ... }) requires a non-empty key");
@@ -302,13 +303,14 @@ export function mintInteractionId() {
302
303
  return `${Date.now()}-${Math.floor(Math.random() * 1e9)}`;
303
304
  }
304
305
  /** Submit a declared action. Failed acknowledgements expose an explicit retry
305
- * that keeps the original value, event subject and interaction id. */
306
+ * that keeps the original value, expected values, event subject and
307
+ * interaction id. */
306
308
  export function useAction(name) {
307
309
  const rt = useRuntime();
308
310
  if (!rt.def.actions?.[name]) {
309
311
  throw new Error(`Action "${name}" is not declared on view "${rt.def.key}"`);
310
312
  }
311
- return useCallback(async (value = {}) => {
313
+ return useCallback(async (value = {}, options = {}) => {
312
314
  if (!rt.ready) {
313
315
  return {
314
316
  ok: false,
@@ -325,6 +327,9 @@ export function useAction(name) {
325
327
  view: rt.def.key,
326
328
  action: name,
327
329
  value,
330
+ ...(options.expected === undefined
331
+ ? {}
332
+ : { expected: options.expected }),
328
333
  ...(rt.scope.event === undefined
329
334
  ? {}
330
335
  : { scope: { event: rt.scope.event } }),
@@ -446,9 +451,10 @@ function applyTheme(theme) {
446
451
  /**
447
452
  * The MCP Apps standard style variables (`McpUiStyleVariableKey`, protocol
448
453
  * `2026-01-26`). A host sends any subset in `hostContext.styles.variables`;
449
- * the shell's tokens (`--fg`, `--muted`, `--border`, `--accent`, the font and
450
- * radii) derive from them, so a view takes the host's look. Built from the
451
- * spec's own axes rather than imported: the guest carries no ext-apps code.
454
+ * the shell's shadcn tokens (`--foreground`, `--muted-foreground`, `--muted`,
455
+ * `--accent`, `--border`, the font and radii) derive from them, so a view takes
456
+ * the host's look. Built from the spec's own axes rather than imported: the
457
+ * guest carries no ext-apps code.
452
458
  */
453
459
  const SEMANTIC = ["primary", "secondary", "tertiary", "inverse", "ghost"];
454
460
  const STATUS = ["info", "danger", "success", "warning"];
@@ -512,7 +518,7 @@ class RenderBoundary extends Component {
512
518
  render() {
513
519
  if (!this.state.error)
514
520
  return this.props.children;
515
- return (_jsxs("div", { role: "alert", "data-lobu-render-error": "true", style: { padding: 12, color: "var(--fg)" }, children: ["This view failed to render: ", this.state.error.message] }));
521
+ return (_jsxs("div", { role: "alert", "data-lobu-render-error": "true", style: { padding: 12, color: "var(--foreground)" }, children: ["This view failed to render: ", this.state.error.message] }));
516
522
  }
517
523
  }
518
524
  /**
@@ -535,6 +541,10 @@ export function Provider({ def, bridge, children, }) {
535
541
  bridgeRef.current = bridge;
536
542
  if (bridgeRef.current === null)
537
543
  bridgeRef.current = new ViewBridge();
544
+ const embedsRef = useRef(null);
545
+ if (embedsRef.current === null)
546
+ embedsRef.current = new EmbedRegistry(() => bridgeRef.current);
547
+ const embeds = embedsRef.current;
538
548
  useEffect(() => {
539
549
  const b = bridgeRef.current;
540
550
  // Unreachable in practice (the body above always installs a bridge
@@ -565,10 +575,12 @@ export function Provider({ def, bridge, children, }) {
565
575
  };
566
576
  const offCtx = b.onHostContext(adoptContext);
567
577
  const offData = b.onDataChanged(() => setDataVersion((v) => v + 1));
578
+ const offEmbeds = embeds.attach(b);
568
579
  b.connect()
569
580
  .then((ctx) => {
570
581
  adoptContext(ctx);
571
582
  setConnected(true);
583
+ embeds.setConnected(true);
572
584
  setReady(b.hasToolInput());
573
585
  document.documentElement.setAttribute("data-ready", "true");
574
586
  })
@@ -578,8 +590,10 @@ export function Provider({ def, bridge, children, }) {
578
590
  offResult();
579
591
  offCtx();
580
592
  offData();
593
+ offEmbeds();
594
+ embeds.setConnected(false);
581
595
  };
582
- }, [def]);
596
+ }, [def, embeds]);
583
597
  // Report the document height so the host can fit the frame. This lives in
584
598
  // the provider, not `mountView`: the server bootstrap renders the provider
585
599
  // directly, and a frame that never hears a size stays at its minimum height.
@@ -700,7 +714,7 @@ export function Provider({ def, bridge, children, }) {
700
714
  ]);
701
715
  // A host-resolved replacement is a new form, including in MCP hosts that
702
716
  // keep the iframe mounted while delivering the opening result.
703
- return (_jsx(Ctx.Provider, { value: value, children: _jsx(RenderBoundary, { resetKey: `${ready}:${JSON.stringify(scope)}:${JSON.stringify(params)}:${dataVersion}`, children: children }) }, scope.event ?? "unbound"));
717
+ return (_jsx(Ctx.Provider, { value: value, children: _jsx(EmbedProvider, { registry: embeds, children: _jsx(RenderBoundary, { resetKey: `${ready}:${JSON.stringify(scope)}:${JSON.stringify(params)}:${dataVersion}`, children: children }) }) }, scope.event ?? "unbound"));
704
718
  }
705
719
  /** Entry point the compiled bundle calls once. Mounts the component into
706
720
  * `#root` and connects to the host. */
@@ -14,6 +14,7 @@
14
14
  * like the SDK's transport.
15
15
  */
16
16
  import type { EntityGetInput } from "@lobu/core/contracts/tools/manage-entity";
17
+ import { type ViewEmbedSlot, type ViewEmbedStatus, type ViewFocusDirection } from "@lobu/core/contracts/tools/view-host";
17
18
  export declare class ViewBridgeError extends Error {
18
19
  readonly code: number;
19
20
  constructor(message: string, code: number);
@@ -74,6 +75,9 @@ export declare class ViewBridge {
74
75
  private toolCancelledListeners;
75
76
  private hostContextListeners;
76
77
  private dataChangedListeners;
78
+ private embedSizeListeners;
79
+ private embedFocusListeners;
80
+ private focusEnterListeners;
77
81
  /** Set by the first `tool-input` and never cleared: queries must not fire
78
82
  * before it (the host seeds scope + params there; anything read earlier
79
83
  * runs against defaults and double-fetches). */
@@ -103,6 +107,19 @@ export declare class ViewBridge {
103
107
  /** The host saw workspace data change (Lobu hosts only; other hosts never
104
108
  * send it, and reads then refresh on their own triggers). */
105
109
  onDataChanged(listener: () => void): () => void;
110
+ /** A child view's height in a slot (Lobu web host only). */
111
+ onEmbedSize(listener: (id: string, height: number) => void): () => void;
112
+ /** Keyboard focus left a slot's child (Lobu web host only). */
113
+ onEmbedFocus(listener: (id: string, direction: ViewFocusDirection) => void): () => void;
114
+ /** Keyboard focus entered this view as a slot's child (Lobu web host only). */
115
+ onFocusEnter(listener: (direction: ViewFocusDirection) => void): () => void;
116
+ /** Report every slot on screen. Rejects with code -32601 on a host that
117
+ * does not mount embedded views. */
118
+ syncEmbeds(embeds: ViewEmbedSlot[]): Promise<{
119
+ embeds?: ViewEmbedStatus[];
120
+ }>;
121
+ /** Move keyboard focus into a slot's child. */
122
+ focusEmbed(id: string, direction: ViewFocusDirection): Promise<unknown>;
106
123
  /**
107
124
  * Run the `ui/initialize` handshake, then announce readiness. Resolves with
108
125
  * the host context. Rejects when the host answers with an error or stays