@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
@@ -167,6 +167,8 @@ export default defineConfig({
167
167
 
168
168
  The entity schema also renders the record page form. Give every array `items` and every object `properties` (bare ones render as raw JSON), put the label in `title` and help text in `description`, mark derived fields `readOnly: true`, and declare every field an Automation writes.
169
169
 
170
+ For a "when did this field last change" timestamp, declare root `metadata_schema["x-lobu-stamps"]: { "stage_at": "stage" }` instead of writing it from an Automation. The stamp field must be a declared `{ type: "string", format: "date-time" }` property (not listed in `required`) and the tracked field a declared property. Every writer (agent, SDK, Automation, connector projection, view action, approval) then gets it for free: the server sets `stage_at` when a record is created with `stage` set or when `stage` changes value, and discards any value a caller sends for `stage_at`. `readOnly` alone is presentation only; it is not enforced.
171
+
170
172
  Seed data records still live as YAML under `./data`. Then seed or operate the memory workspace with:
171
173
 
172
174
  ```bash
@@ -242,7 +244,7 @@ Before authoring UI, inspect available native entity/event pages, existing views
242
244
  2. If that surface cannot meet a concrete requirement, compose its exported parts, such as an individual table, board, graph or shared collection controls when available. Preserve shared selection and action handling instead of rebuilding that logic.
243
245
  3. If those parts still do not fit, use smaller shared primitives and write custom UI only for the remaining gap. Explain the unmet requirement that forced each step down.
244
246
 
245
- Check the current exports and target host before choosing an import; native renderer registrations do not imply React exports. Surface a missing export as a platform gap rather than inventing an API or silently copying the native implementation. `@lobu/views/components` currently supplies theme-aware defaults such as `Card`, `DataTable`, filters, charts, links and query-state components. When exploration needs specialized linked charts, drilldowns, scenario controls or Canvas/SVG, compose a React view from the suitable existing components.
247
+ Check the current exports and target host before choosing an import; native renderer registrations do not imply React exports. Surface a missing export as a platform gap rather than inventing an API or silently copying the native implementation. `@lobu/views/components` currently supplies theme-aware defaults such as `Card`, `DataTable`, filters, charts, links and query-state components. `LoadingState` draws skeleton lines in the host's style; `Skeleton` is a pulsing block to size like the content it stands for (a figure, a row, a chart), so a slow read keeps the page's shape instead of showing text. When exploration needs specialized linked charts, drilldowns, scenario controls or Canvas/SVG, compose a React view from the suitable existing components.
246
248
 
247
249
  Native JSON templates use the target renderer's registered component names and overrides; inspect what that host actually supplies. React views compose imported components in their own bundle, independently of that native renderer map.
248
250
 
@@ -298,7 +300,9 @@ export default function Pipeline() {
298
300
  }
299
301
  ```
300
302
 
301
- `defineView` is the view's only declaration: `key`, optional `name` (defaults to the key) and `description`, `attach`, `params` and `actions` are read from it, never passed separately. `views.set` always requires `source_code` containing the entrypoint module, including when retaining multiple files. Write `defineView` out as a literal (no variables, spreads or `${}` templates): the server reads it without running the module.
303
+ `defineView` is the view's only declaration: `key`, optional `name` (defaults to the key) and `description`, `attach`, `params`, `actions` and `resources` are read from it, never passed separately. `views.set` always requires `source_code` containing the entrypoint module, including when retaining multiple files. Write `defineView` out as a literal (no variables, spreads or `${}` templates): the server reads it without running the module.
304
+
305
+ A view makes no network requests of its own; data comes through `useQuery`. The one exception is images: `resources: ["https://tile.openstreetmap.org"]` declares origins the view may load images (map tiles, logos) from. Each entry is a bare `https://` origin with a public hostname (no path, wildcard, localhost or IP), at most 8. The images-only limit is a save-time check: `views.set` renders the view's empty, error and loading states in an offline browser and refuses the save if anything other than an image from a declared origin is requested. It is not enforced at runtime. MCP hosts receive the origins as the MCP Apps `resourceDomains` CSP, which allows scripts, styles, fonts and media from them as well as images, and the Lobu web app applies no runtime CSP to views. Declare only image or tile CDN origins you trust. Hosts that render through the generic `ui://lobu/views` loader use its CSP, which declares no image origins, so declared images may not load there.
302
306
 
303
307
  For a multi-file view, `files` maps relative paths to complete source strings and `entrypoint` names the view module. Include all three inputs below; `source_code` must exactly equal `files[entrypoint]`:
304
308
 
@@ -368,7 +372,14 @@ Rules that are load-bearing, not style:
368
372
 
369
373
  - Use structured reads: `useQuery(tool("manage_entity", { action: "list", entity_type: type, filters, limit: 100 }))`. The host admits entity `list/get/list_links` and entity-type schema `list/get` reads; tools marked read-only are also available. Use existing tool input/result contracts and preserve server authorization. Send structured arguments, never TypeScript inside a string. `sql` remains available; script-string queries are compatibility support for installed views. `query_sql` allows 500 rows max with a 5 second timeout — branch on the typed `errorCode` (e.g. `UPSTREAM_TIMEOUT`), never on message text, and render `truncated` honestly instead of passing partial data off as complete. Each `query_sql` cell is bounded too: strings keep their first 4,000 Unicode code points plus "… [truncated]"; JSON values over 16 KiB become `{ _truncated: true, bytes }` (attachments become null with `attachments_truncated`). `truncatedColumns` names the affected columns. Select smaller elements or fields, for example one array element per row with `jsonb_array_elements(...)`, and paginate as needed; each returned cell is still subject to these limits.
370
374
  - Never aggregate history in a view: no `GROUP BY`, `DISTINCT ON`, per-row regexp, or leading-wildcard `LIKE` over `events` or other growing tables. For "latest state" views, have an Automation maintain keyed event outputs (each run supersedes the previous event with the same key) and read the current head with `read_knowledge`.
371
- - `run_sdk` is not exposed to views. Writes go only through declared view actions (`useAction` → `invoke_view_action`), which emit the declared event kind and can activate workspace-triggered Automations. Action `value` payloads are capped at 4000 JSON chars — save content first, then pass the id. A subject shown from a superseded event rejects with 409; refetch and ask the user to re-confirm rather than retrying blindly.
375
+ - `run_sdk` is not exposed to views. Writes go only through declared view actions (`useAction` → `invoke_view_action`). An action declares `emits` (append that event kind, which can activate workspace-triggered Automations), `updates: { entityType, fields }` (write those metadata fields on one record), or both, which commit in one transaction. An `updates` action takes `value: { entity_id, set: { field: value } }`; the view must attach to `entityType`, `set` may only name declared fields, and schema-stamped fields are refused. Pass `{ expected }` as the second argument with the values the view read: a stale read returns 409 `PRECONDITION_FAILED` and writes nothing. The write runs as the clicking user without claiming field ownership, so a human-owned field comes back as `pending_approval` instead of `applied`. Do not add an Automation that only copies an action's event onto the record; declare `updates` instead. Action `value` payloads are capped at 4000 JSON chars — save content first, then pass the id. A subject shown from a superseded event rejects with 409; refetch and ask the user to re-confirm rather than retrying blindly.
376
+
377
+ ```tsx
378
+ // actions: { markWon: { emits: "deal.won", updates: { entityType: "deal", fields: ["stage"] } } }
379
+ const markWon = useAction("markWon");
380
+ const sent = await markWon({ entity_id: deal.id, set: { stage: "won" } }, { expected: { stage: deal.metadata.stage } });
381
+ // sent.result.applied: { entity_id, fields } with server stamps; sent.result.pending_approval when held
382
+ ```
372
383
  - Link with `Link` from `@lobu/views/components` (or `useHost().openLink`): `href="<type>/<slug>"` opens that record in the workspace, supported links within the same workspace open in the peek pane, other app links navigate normally, and external URLs open a new tab. A plain `<a href>` goes nowhere inside the sandboxed frame.
373
384
  - For several offers, publish one event with a card for each held proposal. Obtain the real pending approval through the existing agent/Automation write method under its normal policy, then read its returned event ID to obtain the canonical review URL. Link each card to that exact review; the host opens it in peek. Each offer has its own run and decision. Use native Current/Proposed fields for updates and the proposed definition for creation. A resource snapshot alone is a preview, not an approval: never fabricate Approve/Reject buttons or imply that a missing resource ID creates anything. Existing settings `?run_id=` links remain compatible; new offers use the proposal review instead of the settings page.
374
385
  - Views run in a sandboxed frame with no direct network: no fetch, no third-party calls at runtime. Reuse local React components through relative imports and `source_files: { entrypoint, files }` plus `dependencies: {}` for local-only components with `views.set`, or use `viewFromFile` + `lobu apply`. Extra npm dependencies need the CLI-bundled `compiled_code`; listing `dependencies` alone does not install packages.
@@ -262,6 +262,11 @@ export async function fetchRemoteSnapshot(client, state, only, prune = false) {
262
262
  // Views are org-scoped modules (neither agents nor memory): a full apply
263
263
  // reconciles them against `manage_views list` (metadata only).
264
264
  const views = only === undefined ? await client.listViews() : [];
265
+ // Navigation is read only when the config manages it: its revision is the
266
+ // compare-and-swap token the write presents.
267
+ const navigation = only === undefined && state.navigation !== undefined
268
+ ? await client.getNavigation()
269
+ : undefined;
265
270
  return {
266
271
  agents,
267
272
  agentSettings,
@@ -274,6 +279,7 @@ export async function fetchRemoteSnapshot(client, state, only, prune = false) {
274
279
  feedsByConnectionId,
275
280
  inferenceProviders,
276
281
  views,
282
+ ...(navigation ? { navigation } : {}),
277
283
  };
278
284
  }
279
285
  // ── Connector definition install (runs INSIDE executePlan, after confirm) ──
@@ -583,6 +589,23 @@ export async function executePlan(ctx, pendingAuth) {
583
589
  printText(renderProgress(row.verb, "view", row.id, `${result.written ? "(pushed" : "(unchanged"}, ${kb} KB)`));
584
590
  printText(chalk.dim(` → ${ctx.apiBaseUrl}/api/${ctx.orgSlug}/views/${row.id}/shell`));
585
591
  }
592
+ // 2c) Navigation — after views, since its targets must resolve when saved.
593
+ // The write presents the revision this apply read; anyone else's edit
594
+ // in between fails it (409) rather than being overwritten.
595
+ for (const row of rowsByKind("navigation")) {
596
+ if (row.kind !== "navigation")
597
+ continue;
598
+ try {
599
+ const result = await ctx.client.setNavigation(row.revision, row.desired);
600
+ printText(renderProgress(row.verb, "navigation", row.id, `(revision ${result.revision})`));
601
+ }
602
+ catch (error) {
603
+ if (error instanceof ApiError && error.status === 409) {
604
+ throw new Error(`Workspace navigation changed since this apply read it (revision ${row.revision}). Run lobu apply again to plan against the current document.`);
605
+ }
606
+ throw error;
607
+ }
608
+ }
586
609
  // 3) Agents
587
610
  for (const row of rowsByKind("agent")) {
588
611
  if (row.kind !== "agent")
@@ -1219,6 +1242,10 @@ async function applyProject(opts, prepared) {
1219
1242
  return baselineRecord ?? undefined;
1220
1243
  }
1221
1244
  const built = buildAttributionAndOwned(state, snapshot, resolvedOrg?.id, prune);
1245
+ // Navigation is full-apply only: a partial run keeps the last record.
1246
+ if (opts.only !== undefined && baselineRecord?.attribution.navigation) {
1247
+ built.attribution.navigation = baselineRecord.attribution.navigation;
1248
+ }
1222
1249
  if (opts.only === "memory" && baselineRecord) {
1223
1250
  built.owned = [
1224
1251
  ...built.owned,
@@ -1,3 +1,4 @@
1
+ import type { NavigationConfig } from "@lobu/core/contracts/tools/navigation";
1
2
  import type { EntityMetrics } from "@lobu/connector-sdk";
2
3
  import { type AgentSettings } from "@lobu/core";
3
4
  import type { FlatActionInput } from "@lobu/core/contracts/tools/action-input";
@@ -10,7 +11,7 @@ import type { ViewSetInput } from "@lobu/core/contracts/tools/manage-views";
10
11
  import { ApiError } from "../../memory/_lib/errors.js";
11
12
  import type { DeploymentSummary } from "./deployment.js";
12
13
  import type { DesiredAgentMetadata, DesiredEntityType, DesiredRelationshipType } from "./desired-state.js";
13
- import { type AutomationSource, type EntityBacking, type RelationshipRule } from "./shared.js";
14
+ import { type AutomationSource, type EntityBacking, type EntityTypeDisplayFields, type RelationshipRule } from "./shared.js";
14
15
  export interface RemoteAgent {
15
16
  agentId: string;
16
17
  name: string;
@@ -53,12 +54,10 @@ export interface DeploymentPauseState {
53
54
  rollbackOf?: string | null;
54
55
  pausedBy?: string | null;
55
56
  }
56
- export interface RemoteEntityType {
57
+ export interface RemoteEntityType extends EntityTypeDisplayFields {
57
58
  /** Persistent incarnation id (`entity_types.id`) — the `owned` identity for deletes. */
58
59
  id?: number;
59
60
  slug: string;
60
- name?: string;
61
- description?: string;
62
61
  required?: string[];
63
62
  properties?: Record<string, unknown>;
64
63
  /** Event kinds keyed by semantic_type (mirrors {@link DesiredEntityType.eventKinds}); hoisted from the row's `event_kinds`. */
@@ -355,13 +354,25 @@ export declare class ApplyClient {
355
354
  listViews(): Promise<RemoteView[]>;
356
355
  /**
357
356
  * Store a view: source + CLI-bundled browser bundle. The server reads the
358
- * view's key, attach, params and actions from the source. Returns whether a
357
+ * view's key, attach, params, actions and resources from the source. Returns whether a
359
358
  * write happened (same executable artifact is a server-side no-op).
360
359
  */
361
360
  setView(payload: SetViewPayload): Promise<{
362
361
  written: boolean;
363
362
  content_hash: string;
364
363
  }>;
364
+ /**
365
+ * The stored navigation document and its revision. Needs editor access: the
366
+ * raw document is only returned to a caller who could also write it.
367
+ */
368
+ getNavigation(): Promise<{
369
+ revision: number;
370
+ config: NavigationConfig | null;
371
+ }>;
372
+ /** Replace the navigation document; 409 when `expectedRevision` is stale. */
373
+ setNavigation(expectedRevision: number, config: NavigationConfig | null): Promise<{
374
+ revision: number;
375
+ }>;
365
376
  /** Delete an applied view by key (prune-gated removal). */
366
377
  removeView(key: string): Promise<void>;
367
378
  listEntityTypes(): Promise<RemoteEntityType[]>;
@@ -2,7 +2,7 @@ import { getToolResultFailure, isPendingToolApproval, } from "@lobu/core";
2
2
  import { ApiClient } from "../../../internal/api-client.js";
3
3
  import { resolveApiClient } from "../../../internal/index.js";
4
4
  import { ApiError } from "../../memory/_lib/errors.js";
5
- import { isRecord, } from "./shared.js";
5
+ import { ENTITY_TYPE_DISPLAY_FIELDS, isRecord, } from "./shared.js";
6
6
  // ── Shape predicates ───────────────────────────────────────────────────────
7
7
  /**
8
8
  * Read the first array-valued key from a response body. Endpoints that may
@@ -43,13 +43,15 @@ function hoistEntityTypeSchema(row) {
43
43
  const out = {
44
44
  ...(row.id !== undefined ? { id: row.id } : {}),
45
45
  slug: row.slug,
46
- ...(row.name !== undefined ? { name: row.name } : {}),
47
- ...(row.description !== undefined ? { description: row.description } : {}),
48
46
  // Preserve owning org so prune can skip public types from other orgs.
49
47
  ...(row.organization_id !== undefined
50
48
  ? { organization_id: row.organization_id }
51
49
  : {}),
52
50
  };
51
+ for (const field of ENTITY_TYPE_DISPLAY_FIELDS) {
52
+ if (row[field] !== undefined)
53
+ out[field] = row[field];
54
+ }
53
55
  if (isRecord(schema)) {
54
56
  if (isRecord(schema.properties))
55
57
  out.properties = schema.properties;
@@ -326,7 +328,7 @@ export class ApplyClient {
326
328
  }
327
329
  /**
328
330
  * Store a view: source + CLI-bundled browser bundle. The server reads the
329
- * view's key, attach, params and actions from the source. Returns whether a
331
+ * view's key, attach, params, actions and resources from the source. Returns whether a
330
332
  * write happened (same executable artifact is a server-side no-op).
331
333
  */
332
334
  async setView(payload) {
@@ -339,6 +341,24 @@ export class ApplyClient {
339
341
  content_hash: body.view?.content_hash ?? "",
340
342
  };
341
343
  }
344
+ /**
345
+ * The stored navigation document and its revision. Needs editor access: the
346
+ * raw document is only returned to a caller who could also write it.
347
+ */
348
+ async getNavigation() {
349
+ const { body } = await this.request("POST", `/api/${this.orgSlug}/manage_views`, {
350
+ action: "get_navigation",
351
+ });
352
+ if (body.config === undefined) {
353
+ throw new Error("This login cannot read the workspace navigation document; an owner or admin with admin access manages navigation.");
354
+ }
355
+ return { revision: body.revision ?? 0, config: body.config };
356
+ }
357
+ /** Replace the navigation document; 409 when `expectedRevision` is stale. */
358
+ async setNavigation(expectedRevision, config) {
359
+ const { body } = await this.request("POST", `/api/${this.orgSlug}/manage_views`, { action: "set_navigation", expected_revision: expectedRevision, config });
360
+ return { revision: body.revision ?? expectedRevision + 1 };
361
+ }
342
362
  /** Delete an applied view by key (prune-gated removal). */
343
363
  async removeView(key) {
344
364
  await this.request("POST", `/api/${this.orgSlug}/manage_views`, {
@@ -429,12 +449,14 @@ export class ApplyClient {
429
449
  // `properties`/`required`. Fold them into `metadata_schema` so the schema
430
450
  // actually persists (otherwise every apply re-reports a `properties`
431
451
  // update because the stored schema stays empty).
432
- const { slug, name, description, required, properties, eventKinds, backing, metrics, resolutionPolicy, collection, rulesSource, } = entity;
452
+ const { slug, required, properties, eventKinds, backing, metrics, resolutionPolicy, collection, rulesSource, } = entity;
433
453
  const payload = { slug };
434
- if (name !== undefined)
435
- payload.name = name;
436
- if (description !== undefined)
437
- payload.description = description;
454
+ // Declared display fields only: an omitted one is never sent, so the
455
+ // server keeps whatever it has (e.g. an icon set in the UI).
456
+ for (const field of ENTITY_TYPE_DISPLAY_FIELDS) {
457
+ if (entity[field] !== undefined)
458
+ payload[field] = entity[field];
459
+ }
438
460
  if (properties !== undefined ||
439
461
  required !== undefined ||
440
462
  resolutionPolicy !== undefined ||
@@ -1,15 +1,4 @@
1
- /**
2
- * Deployment identity for `lobu apply`.
3
- *
4
- * Each apply run mints an `apply_id`, sends it as `x-lobu-apply-id` on every
5
- * mutation (the server stamps its config-audit events with it), and posts a
6
- * summary to `POST /api/<org>/deployments` at the end — including the
7
- * redacted desired-state snapshot (`manifest`) that makes the deployment
8
- * self-contained: `lobu rollback <apply_id>` re-applies it through the same
9
- * diff/execute engine, repointing connectors to their retained versions. The
10
- * summary still records the config repo's HEAD SHA so git-first rollback
11
- * (revert commit → re-apply) stays first-class for config-as-code orgs.
12
- */
1
+ import type { NavigationConfig } from "@lobu/core/contracts/tools/navigation";
13
2
  import type { DesiredState } from "./desired-state.js";
14
3
  import type { Baseline, DiffPlan, DiffRow, RemoteSnapshot } from "./diff.js";
15
4
  export declare function mintApplyId(): string;
@@ -58,6 +47,8 @@ export interface DeploymentManifest {
58
47
  entityTypes: unknown[];
59
48
  relationshipTypes: unknown[];
60
49
  automations: unknown[];
50
+ /** The navigation document this config last applied (or found equal). */
51
+ navigation?: NavigationBaseline;
61
52
  };
62
53
  /**
63
54
  * Kind-qualified definition incarnation identities (`entity-type:12`,
@@ -65,11 +56,16 @@ export interface DeploymentManifest {
65
56
  */
66
57
  owned?: string[];
67
58
  }
59
+ /** What the workspace navigation was after this config's last apply. */
60
+ export interface NavigationBaseline {
61
+ config: NavigationConfig | null;
62
+ }
68
63
  export interface BaselineRecord {
69
64
  attribution: {
70
65
  entityTypes: unknown[];
71
66
  relationshipTypes: unknown[];
72
67
  automations: unknown[];
68
+ navigation?: NavigationBaseline;
73
69
  };
74
70
  owned: string[];
75
71
  /** Connector key → version from the deployment's post-apply pins. */
@@ -96,11 +96,15 @@ export function loadBaselineFromManifest(manifest) {
96
96
  !Array.isArray(attribution.automations)) {
97
97
  return null;
98
98
  }
99
+ const navigation = attribution.navigation;
99
100
  return {
100
101
  attribution: {
101
102
  entityTypes: attribution.entityTypes,
102
103
  relationshipTypes: attribution.relationshipTypes,
103
104
  automations: attribution.automations,
105
+ ...(navigation && typeof navigation === "object" && "config" in navigation
106
+ ? { navigation: { config: navigation.config } }
107
+ : {}),
104
108
  },
105
109
  owned: manifest.owned,
106
110
  ...(manifest.connector_versions
@@ -242,7 +246,16 @@ export function buildAttributionAndOwned(state, remote, orgId, prune = false) {
242
246
  }
243
247
  }
244
248
  return {
245
- attribution: { entityTypes, relationshipTypes, automations },
249
+ attribution: {
250
+ entityTypes,
251
+ relationshipTypes,
252
+ automations,
253
+ // A full apply that manages navigation leaves it as the config says
254
+ // (a write, or already equal); the next apply compares against this.
255
+ ...(remote.navigation !== undefined && state.navigation !== undefined
256
+ ? { navigation: { config: state.navigation } }
257
+ : {}),
258
+ },
246
259
  owned,
247
260
  };
248
261
  }
@@ -1,19 +1,18 @@
1
+ import type { NavigationConfig } from "@lobu/core/contracts/tools/navigation";
1
2
  import type { ConnectorDefinition, EntityMetrics } from "@lobu/connector-sdk";
2
3
  import type { AgentSettings } from "@lobu/core";
3
4
  import type { CollectionPresentation } from "@lobu/core/contracts/tools/collection-presentation";
4
5
  import type { AutomationEventTrigger, AutomationScheduleTrigger, AutomationWorkspaceEventTrigger, ManageAutomationsArgs } from "@lobu/core/contracts/tools/manage-automations";
5
6
  import type { RetainedSource } from "@lobu/core/contracts/tools/source-files";
6
7
  import type { Automation, InferenceCapabilityBlock, InferenceModality, Project } from "../../../config/index.js";
7
- import { type AutomationSource, type EntityBacking, type RelationshipRule } from "./shared.js";
8
+ import { type AutomationSource, type EntityBacking, type EntityTypeDisplayFields, type RelationshipRule } from "./shared.js";
8
9
  export interface DesiredAgentMetadata {
9
10
  agentId: string;
10
11
  name: string;
11
12
  description?: string;
12
13
  }
13
- export interface DesiredEntityType {
14
+ export interface DesiredEntityType extends EntityTypeDisplayFields {
14
15
  slug: string;
15
- name?: string;
16
- description?: string;
17
16
  required?: string[];
18
17
  properties?: Record<string, unknown>;
19
18
  /**
@@ -323,6 +322,11 @@ export interface DesiredState {
323
322
  * path — and apply re-derives it from the bundle, refusing a mismatch.
324
323
  */
325
324
  views: DesiredView[];
325
+ /**
326
+ * The workspace navigation document, already validated. Undefined when the
327
+ * config leaves navigation unmanaged; null returns it to the default.
328
+ */
329
+ navigation?: NavigationConfig | null;
326
330
  /**
327
331
  * Names of env vars referenced via `secret()` / `$VAR` (provider keys,
328
332
  * auth-profile + mcp credentials). The CLI surfaces these before mutating
@@ -497,7 +497,7 @@ async function resolveViewSources(sources, cwd) {
497
497
  }
498
498
  const bundled = await bundleViewFromFile(abs, baseDir);
499
499
  sourceCode = bundled.sourceFiles.files[bundled.sourceFiles.entrypoint];
500
- const { key, name, description, attach, params, actions } = bundled.definition;
500
+ const { key, name, description, attach, params, actions, resources } = bundled.definition;
501
501
  if (seen.has(key)) {
502
502
  throw new ValidationError(`duplicate view key "${key}" in lobu.config.ts — each viewFromFile must resolve to a unique key`);
503
503
  }
@@ -517,6 +517,7 @@ async function resolveViewSources(sources, cwd) {
517
517
  attach,
518
518
  params,
519
519
  actions,
520
+ resources,
520
521
  }, bundled.compiledCode, {
521
522
  sourceFiles: bundled.sourceFiles,
522
523
  dependencies: bundled.dependencies,
@@ -1,8 +1,9 @@
1
+ import type { NavigationConfig } from "@lobu/core/contracts/tools/navigation";
1
2
  import { type AgentSettings } from "@lobu/core";
2
3
  import type { InferenceModality } from "../../../config/define.js";
3
4
  import type { RemoteAgent, RemoteAuthProfile, RemoteAutomation, RemoteConnection, RemoteConnectorDefinition, RemoteEntityType, RemoteFeed, RemoteInferenceProvider, RemoteRelationshipType, RemoteView, UpdateConnectionPayload, UpdateFeedPayload } from "./client.js";
4
5
  import type { DesiredAgent, DesiredAuthProfile, DesiredAutomation, DesiredAutomationTrigger, DesiredConnection, DesiredConnectorDefinition, DesiredEntityType, DesiredFeed, DesiredOrgProvider, DesiredRelationshipType, DesiredState, DesiredView } from "./desired-state.js";
5
- import { type AutomationSource } from "./shared.js";
6
+ import { type AutomationSource, type EntityTypeDisplayField } from "./shared.js";
6
7
  type DiffVerb = "create" | "update" | "noop" | "drift" | "delete";
7
8
  interface BaseRow {
8
9
  verb: DiffVerb;
@@ -122,6 +123,17 @@ export interface ViewDiffRow extends BaseRow {
122
123
  /** Module key resolved at bundle time; the diff keys on the content hash. */
123
124
  remote?: RemoteView;
124
125
  }
126
+ /**
127
+ * The workspace navigation document: one per workspace, replaced whole. The
128
+ * write presents `revision`, the one apply read, so a concurrent edit fails
129
+ * the apply instead of being overwritten.
130
+ */
131
+ export interface NavigationDiffRow extends BaseRow {
132
+ kind: "navigation";
133
+ desired: NavigationConfig | null;
134
+ remote: NavigationConfig | null;
135
+ revision: number;
136
+ }
125
137
  /**
126
138
  * A blocking drift item: either a field moved remotely or a remote-only
127
139
  * definition is not safe to delete. Apply must not converge over it — the
@@ -131,7 +143,7 @@ export interface BlockingDriftRow extends BaseRow {
131
143
  verb: "drift";
132
144
  /** Always true — distinguishes blocking drift from legacy non-blocking drift. */
133
145
  blocking: true;
134
- kind: "entity-type" | "relationship-type" | "automation";
146
+ kind: "entity-type" | "relationship-type" | "automation" | "navigation";
135
147
  id: string;
136
148
  /** The moved field; absent for a whole remote-only definition. */
137
149
  field?: string;
@@ -149,6 +161,10 @@ export interface AttributionSnapshot {
149
161
  entityTypes: RemoteEntityType[];
150
162
  relationshipTypes: RemoteRelationshipType[];
151
163
  automations: RemoteAutomation[];
164
+ /** The navigation document after this config's last apply. */
165
+ navigation?: {
166
+ config: NavigationConfig | null;
167
+ };
152
168
  }
153
169
  export interface Baseline {
154
170
  /**
@@ -168,7 +184,7 @@ export interface Baseline {
168
184
  connectorVersions?: Record<string, string>;
169
185
  }
170
186
  export declare const ownedKey: (kind: string, id: number | string | undefined) => string;
171
- export type DiffRow = AgentDiffRow | SettingsDiffRow | EntityTypeDiffRow | RelationshipTypeDiffRow | AutomationDiffRow | ConnectorDefinitionDiffRow | AuthProfileDiffRow | ConnectionDiffRow | FeedDiffRow | InferenceProviderDiffRow | ViewDiffRow | BlockingDriftRow;
187
+ export type DiffRow = AgentDiffRow | SettingsDiffRow | EntityTypeDiffRow | RelationshipTypeDiffRow | AutomationDiffRow | ConnectorDefinitionDiffRow | AuthProfileDiffRow | ConnectionDiffRow | FeedDiffRow | InferenceProviderDiffRow | ViewDiffRow | NavigationDiffRow | BlockingDriftRow;
172
188
  export interface DiffPlan {
173
189
  rows: DiffRow[];
174
190
  /** Aggregate counters for the summary line. */
@@ -246,9 +262,7 @@ export declare const UPDATE_FIELD_TABLES: {
246
262
  * The entity-type facets a comparison cares about, normalized so an absent
247
263
  * collection and an empty one compare equal.
248
264
  */
249
- export interface EntityTypeFacets {
250
- name: string | undefined;
251
- description: string | undefined;
265
+ export interface EntityTypeFacets extends Record<EntityTypeDisplayField, string | null> {
252
266
  required: string[];
253
267
  properties: Record<string, unknown>;
254
268
  backing: unknown;
@@ -325,12 +339,17 @@ export interface RemoteSnapshot {
325
339
  inferenceProviders: RemoteInferenceProvider[];
326
340
  /** Applied views (`manage_views list`). Full-apply only. */
327
341
  views: RemoteView[];
342
+ /** The stored navigation document; read only when the config manages it. */
343
+ navigation?: {
344
+ revision: number;
345
+ config: NavigationConfig | null;
346
+ };
328
347
  }
329
348
  /**
330
349
  * The subset of {@link DesiredState} the diff consumes — everything except the
331
350
  * apply-only knobs (prune flag, org metadata, requiredSecrets).
332
351
  */
333
- type DesiredStateForDiff = Pick<DesiredState, "agents" | "memorySchema" | "automations" | "connectors" | "providers" | "views">;
352
+ type DesiredStateForDiff = Pick<DesiredState, "agents" | "memorySchema" | "automations" | "connectors" | "providers" | "views" | "navigation">;
334
353
  interface ComputeDiffOptions {
335
354
  /** Limit the diff to a subset of resource kinds. */
336
355
  only?: "agents" | "memory";