@lobu/runtime-device 24.8.0 → 24.10.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 (110) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +36 -34
  3. package/npm-shrinkwrap.json +228 -207
  4. package/package.json +1 -1
  5. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +17 -3
  6. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +31 -4
  7. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +37 -22
  8. package/vendor/cli/dist/commands/_lib/apply/client.js +63 -43
  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/dev.js +2 -0
  21. package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +6 -2
  22. package/vendor/cli/dist/config/define.d.ts +21 -3
  23. package/vendor/cli/dist/connectors/README.md +6 -2
  24. package/vendor/cli/dist/connectors/github.ts +16 -3
  25. package/vendor/cli/dist/connectors/market_quotes.ts +388 -91
  26. package/vendor/cli/dist/connectors/postgres.ts +60 -38
  27. package/vendor/cli/dist/connectors/whatsapp-web-adapter.js +41 -10
  28. package/vendor/cli/dist/connectors/whatsapp-web-helpers.ts +12 -2
  29. package/vendor/cli/dist/connectors/whatsapp_web.ts +18 -2
  30. package/vendor/cli/dist/connectors/x-dm-adapter.js +55 -21
  31. package/vendor/cli/dist/connectors/x.ts +1 -1
  32. package/vendor/cli/dist/internal/context.d.ts +5 -0
  33. package/vendor/cli/dist/internal/context.js +23 -9
  34. package/vendor/cli/dist/runtime-components.json +4 -4
  35. package/vendor/cli/package.json +1 -1
  36. package/vendor/connector-sdk/dist/connector-types.d.ts +29 -2
  37. package/vendor/connector-sdk/dist/index.d.ts +1 -0
  38. package/vendor/connector-sdk/dist/index.js +1 -0
  39. package/vendor/connector-sdk/dist/ip-reachability.d.ts +1 -1
  40. package/vendor/connector-sdk/dist/ip-reachability.js +1 -1
  41. package/vendor/connector-sdk/dist/logger.d.ts +1 -1
  42. package/vendor/connector-sdk/dist/logger.js +1 -1
  43. package/vendor/connector-sdk/dist/reaction-client-types.d.ts +3 -1
  44. package/vendor/connector-sdk/dist/retry.d.ts +1 -1
  45. package/vendor/connector-sdk/dist/retry.js +1 -1
  46. package/vendor/connector-sdk/dist/source-withheld-error.d.ts +16 -0
  47. package/vendor/connector-sdk/dist/source-withheld-error.js +19 -0
  48. package/vendor/connector-sdk/package.json +1 -1
  49. package/vendor/connector-worker/dist/daemon/automation.js +7 -4
  50. package/vendor/connector-worker/dist/daemon/index.d.ts +1 -0
  51. package/vendor/connector-worker/dist/daemon/index.js +1 -0
  52. package/vendor/connector-worker/dist/daemon/terminal-delivery.d.ts +12 -2
  53. package/vendor/connector-worker/dist/daemon/terminal-delivery.js +19 -12
  54. package/vendor/connector-worker/dist/executor/interface.d.ts +10 -0
  55. package/vendor/connector-worker/dist/executor/interface.js +6 -0
  56. package/vendor/connector-worker/dist/executor/isolate.d.ts +1 -0
  57. package/vendor/connector-worker/dist/executor/isolate.js +88 -24
  58. package/vendor/connector-worker/dist/isolate/prelude.js +5 -0
  59. package/vendor/connector-worker/package.json +1 -1
  60. package/vendor/core/dist/classify-error.d.ts +4 -5
  61. package/vendor/core/dist/classify-error.js +10 -10
  62. package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +17 -1
  63. package/vendor/core/dist/contracts/tools/collection-presentation.js +27 -3
  64. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +67 -3
  65. package/vendor/core/dist/contracts/tools/manage-automations.js +38 -9
  66. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
  67. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +8 -0
  68. package/vendor/core/dist/contracts/tools/manage-entity.js +11 -3
  69. package/vendor/core/dist/contracts/tools/manage-views.d.ts +249 -7
  70. package/vendor/core/dist/contracts/tools/manage-views.js +83 -21
  71. package/vendor/core/dist/contracts/tools/navigation.d.ts +248 -0
  72. package/vendor/core/dist/contracts/tools/navigation.js +284 -0
  73. package/vendor/core/dist/contracts/tools/save-memory.d.ts +11 -1
  74. package/vendor/core/dist/contracts/tools/save-memory.js +25 -3
  75. package/vendor/core/dist/contracts/tools/search-memory.js +1 -1
  76. package/vendor/core/dist/contracts/tools/view-attach.d.ts +7 -0
  77. package/vendor/core/dist/contracts/tools/view-attach.js +15 -0
  78. package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +4 -1
  79. package/vendor/core/dist/contracts/tools/view-content-hash.js +4 -2
  80. package/vendor/core/dist/contracts/tools/view-definition.d.ts +2 -0
  81. package/vendor/core/dist/contracts/tools/view-definition.js +52 -0
  82. package/vendor/core/dist/contracts/tools/view-host.d.ts +68 -0
  83. package/vendor/core/dist/contracts/tools/view-host.js +28 -1
  84. package/vendor/core/dist/contracts/tools/view-scope.d.ts +31 -0
  85. package/vendor/core/dist/contracts/tools/view-scope.js +45 -0
  86. package/vendor/core/dist/credentials.d.ts +12 -0
  87. package/vendor/core/dist/credentials.js +1 -0
  88. package/vendor/core/dist/errors.d.ts +17 -24
  89. package/vendor/core/dist/errors.js +19 -26
  90. package/vendor/core/dist/types.d.ts +0 -6
  91. package/vendor/core/dist/worker/auth.d.ts +5 -0
  92. package/vendor/core/dist/worker/auth.js +15 -4
  93. package/vendor/core/package.json +11 -1
  94. package/vendor/postgres/cf/src/connection.js +7 -2
  95. package/vendor/postgres/cjs/src/connection.js +7 -2
  96. package/vendor/postgres/src/connection.js +7 -2
  97. package/vendor/views/dist/api.d.ts +30 -5
  98. package/vendor/views/dist/api.js +22 -8
  99. package/vendor/views/dist/bridge.d.ts +17 -0
  100. package/vendor/views/dist/bridge.js +49 -1
  101. package/vendor/views/dist/components.d.ts +27 -5
  102. package/vendor/views/dist/components.js +57 -7
  103. package/vendor/views/dist/embed.d.ts +98 -0
  104. package/vendor/views/dist/embed.js +418 -0
  105. package/vendor/views/dist/index.d.ts +3 -1
  106. package/vendor/views/dist/index.js +1 -0
  107. package/vendor/views/dist/native.d.ts +33 -1
  108. package/vendor/views/dist/native.js +3 -0
  109. package/vendor/views/package.json +1 -1
  110. /package/vendor/postgres/{.bun-tag-c81dacd34e959a7a → .bun-tag-652f2580b8090d71} +0 -0
@@ -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";
@@ -1,7 +1,7 @@
1
1
  import { isSystemEntityType } from "@lobu/core";
2
2
  import { ValidationError } from "../../memory/_lib/errors.js";
3
3
  import { isPlatformOwnedRelationshipSlug } from "../platform-owned-types.js";
4
- import { declaredConnectorKeys, referencedConnectorKeys, } from "./shared.js";
4
+ import { declaredConnectorKeys, ENTITY_TYPE_DISPLAY_FIELDS, LEGACY_DISPLAY_FIELDS, referencedConnectorKeys, } from "./shared.js";
5
5
  export const ownedKey = (kind, id) => id === undefined ? "" : `${kind}:${id}`;
6
6
  // ── Equality helpers ───────────────────────────────────────────────────────
7
7
  /**
@@ -272,11 +272,11 @@ function diffEntityType(desired, remote, prune) {
272
272
  desired,
273
273
  remote,
274
274
  fields: [
275
- { name: "name", changed: (d, r) => stringChanged(d.name, r.name) },
276
- {
277
- name: "description",
278
- changed: (d, r) => stringChanged(d.description, r.description),
279
- },
275
+ ...ENTITY_TYPE_DISPLAY_FIELDS.map((field) => ({
276
+ name: field,
277
+ changed: (d, r) => (d[field] !== undefined || LEGACY_DISPLAY_FIELDS.has(field)) &&
278
+ stringChanged(d[field], r[field]),
279
+ })),
280
280
  {
281
281
  // required — prune-aware, like eventKinds. Declared: diff and set on
282
282
  // change. Omitted + prune: a present remote set is a removal (apply
@@ -415,18 +415,17 @@ function classifyThreeWay(triples) {
415
415
  /** Entity-type fields compared per-property-key, three-way, with the baseline. */
416
416
  function compareEntityTypeThreeWay(desired, remote, attribution, prune) {
417
417
  const triples = [
418
- {
419
- field: "name",
420
- desired: desired.name,
421
- remote: remote.name,
422
- attribution: attribution?.name,
423
- },
424
- {
425
- field: "description",
426
- desired: desired.description,
427
- remote: remote.description,
428
- attribution: attribution?.description,
429
- },
418
+ // Display fields are unmanaged when omitted, under BOTH prune and
419
+ // non-prune: upsert never clears them, so a configMoved classification
420
+ // would perpetual-update without effect. A declared "" (a clear) is
421
+ // declared, though it compares as unset.
422
+ ...ENTITY_TYPE_DISPLAY_FIELDS.filter((field) => desired[field] !== undefined).map((field) => ({
423
+ field,
424
+ desired: comparableDisplayValue(field, desired[field]),
425
+ remote: comparableDisplayValue(field, remote[field]),
426
+ attribution: attribution &&
427
+ comparableDisplayValue(field, withUnrecordedDisplayFromLive(attribution, remote)[field]),
428
+ })),
430
429
  {
431
430
  // Under prune, omitting required means "clear to []" — normalize so an
432
431
  // already-empty remote does not perpetual-update (undefined ≠ []).
@@ -493,10 +492,6 @@ function compareEntityTypeThreeWay(desired, remote, attribution, prune) {
493
492
  // — eventKinds/properties round-trip untouched). Only under
494
493
  // prune does omission mean "remove". Without this, an unchanged omitted facet
495
494
  // would be misclassified as config-moved and executePlan would clear it.
496
- // name/description are unmanaged under BOTH prune and non-prune: upsert
497
- // never clears them when omitted, so a configMoved classification would
498
- // perpetual-update without effect.
499
- const alwaysUnmanaged = new Set(["name", "description"]);
500
495
  const omittableOutsidePrune = new Set([
501
496
  "required",
502
497
  "backing",
@@ -509,8 +504,6 @@ function compareEntityTypeThreeWay(desired, remote, attribution, prune) {
509
504
  return classifyThreeWay(triples.filter((t) => {
510
505
  if (t.desired !== undefined)
511
506
  return true;
512
- if (alwaysUnmanaged.has(t.field))
513
- return false;
514
507
  if (!prune &&
515
508
  (omittableOutsidePrune.has(t.field) ||
516
509
  t.field.startsWith("properties."))) {
@@ -723,8 +716,12 @@ function diffRelationshipTypeWithBaseline(desired, remote, baseline) {
723
716
  };
724
717
  }
725
718
  const normalizeEntityFacets = (e) => ({
726
- name: e.name,
727
- description: e.description,
719
+ // Unset is an explicit null, so a recorded baseline keeps the key and an
720
+ // unset value stays distinguishable from one it never recorded.
721
+ ...Object.fromEntries(ENTITY_TYPE_DISPLAY_FIELDS.map((field) => [
722
+ field,
723
+ comparableDisplayValue(field, e[field]) ?? null,
724
+ ])),
728
725
  required: e.required ?? [],
729
726
  properties: e.properties ?? {},
730
727
  backing: e.backing,
@@ -732,8 +729,34 @@ const normalizeEntityFacets = (e) => ({
732
729
  eventKinds: e.eventKinds,
733
730
  schemaExtras: e.schemaExtras ?? {},
734
731
  });
732
+ /**
733
+ * A display field's value as the three-way compare and the baseline see it.
734
+ * Unset is undefined (recorded as null). For icon/color a declared "" (a
735
+ * clear) is unset too, since the server reads an unset field as null; the
736
+ * two-way diff already treats "" and null alike (`stringChanged`). Legacy
737
+ * fields keep "" as a value.
738
+ */
739
+ function comparableDisplayValue(field, value) {
740
+ if (value == null)
741
+ return undefined;
742
+ return value === "" && !LEGACY_DISPLAY_FIELDS.has(field) ? undefined : value;
743
+ }
735
744
  /** The live remote entity type, in the comparable facet shape. */
736
745
  const remoteEntityTypeFacets = (r) => normalizeEntityFacets(r);
746
+ /**
747
+ * A baseline entity type with the display fields it never recorded read off
748
+ * the live type: a baseline written before a non-legacy display field existed
749
+ * lacks its key (see LEGACY_DISPLAY_FIELDS), and that is not a recorded unset.
750
+ */
751
+ const withUnrecordedDisplayFromLive = (recorded, live) => {
752
+ const out = { ...recorded };
753
+ for (const field of ENTITY_TYPE_DISPLAY_FIELDS) {
754
+ if (!LEGACY_DISPLAY_FIELDS.has(field) && !(field in recorded)) {
755
+ out[field] = live[field];
756
+ }
757
+ }
758
+ return out;
759
+ };
737
760
  /**
738
761
  * What the remote entity type BECOMES after this apply: declared values, plus
739
762
  * the facets the write provably leaves alone — name/description (upsert never
@@ -775,10 +798,13 @@ export const effectiveEntityTypeAfterApply = (d, r, prune) => {
775
798
  ...Object.fromEntries(Object.entries(r?.properties ?? {}).filter(([key]) => !(key in declaredProperties))),
776
799
  ...declaredProperties,
777
800
  };
778
- return normalizeEntityFacets({
801
+ const display = {};
802
+ for (const field of ENTITY_TYPE_DISPLAY_FIELDS) {
779
803
  // Never cleared by omission, under prune or not.
780
- name: d.name !== undefined ? d.name : r?.name,
781
- description: d.description !== undefined ? d.description : r?.description,
804
+ display[field] = d[field] !== undefined ? d[field] : r?.[field];
805
+ }
806
+ return normalizeEntityFacets({
807
+ ...display,
782
808
  required: d.required !== undefined ? d.required : prune ? [] : r?.required,
783
809
  properties,
784
810
  backing: inherit(d.backing, r?.backing),
@@ -1363,7 +1389,7 @@ export function computeDiff(desired, remote, opts = {}) {
1363
1389
  // Looked up BY slug, so only the facets can differ.
1364
1390
  const a = baseline?.attribution.entityTypes.find((x) => x.slug === slug);
1365
1391
  return (!!a &&
1366
- deepEqual(remoteEntityTypeFacets(remoteEntity), remoteEntityTypeFacets(a)));
1392
+ deepEqual(remoteEntityTypeFacets(remoteEntity), remoteEntityTypeFacets(withUnrecordedDisplayFromLive(a, remoteEntity))));
1367
1393
  }));
1368
1394
  }
1369
1395
  }
@@ -1673,6 +1699,51 @@ export function computeDiff(desired, remote, opts = {}) {
1673
1699
  });
1674
1700
  }
1675
1701
  }
1702
+ // Navigation. Full-apply only, and only when the config manages it. The
1703
+ // document is shared with the app's editor and agents, so replacing it is
1704
+ // three-way: the config may only overwrite what it last applied. A document
1705
+ // someone changed since then — or one this config never applied (a file
1706
+ // exported earlier) — blocks until the file adopts it; the revision the
1707
+ // write presents then guards the read-to-write window (409, never retried).
1708
+ if (only === undefined && desired.navigation !== undefined) {
1709
+ const current = remote.navigation ?? { revision: 0, config: null };
1710
+ const inSync = deepEqual(desired.navigation, current.config);
1711
+ const applied = baseline?.recorded
1712
+ ? baseline.attribution.navigation
1713
+ : undefined;
1714
+ // Once this config applied a document, any other remote document —
1715
+ // including a reset to the automatic default (null) — was set elsewhere.
1716
+ // Before that, only a set document (one never applied from here) is.
1717
+ const movedElsewhere = !inSync &&
1718
+ (applied === undefined
1719
+ ? current.config !== null
1720
+ : !deepEqual(current.config, applied.config));
1721
+ rows.push({
1722
+ kind: "navigation",
1723
+ id: "workspace",
1724
+ desired: desired.navigation,
1725
+ remote: current.config,
1726
+ revision: current.revision,
1727
+ verb: inSync || movedElsewhere
1728
+ ? "noop"
1729
+ : current.config === null
1730
+ ? "create"
1731
+ : "update",
1732
+ });
1733
+ if (movedElsewhere) {
1734
+ rows.push({
1735
+ kind: "navigation",
1736
+ verb: "drift",
1737
+ blocking: true,
1738
+ id: "workspace",
1739
+ field: "document",
1740
+ remoteChange: `revision ${current.revision}, edited outside this config`,
1741
+ desiredChange: applied === undefined
1742
+ ? "a different document (never applied from this config)"
1743
+ : "a different document",
1744
+ });
1745
+ }
1746
+ }
1676
1747
  const counts = { create: 0, update: 0, noop: 0, drift: 0, delete: 0 };
1677
1748
  for (const row of rows)
1678
1749
  counts[row.verb]++;
@@ -7,6 +7,7 @@
7
7
  * pure (modulo `installedAt` timestamps, matching the TOML loader) so it can be
8
8
  * unit-tested without importing `lobu.config.ts`.
9
9
  */
10
+ import { validateNavigationConfig, } from "@lobu/core/contracts/tools/navigation";
10
11
  import { validateEntityMetrics } from "@lobu/connector-sdk/metrics";
11
12
  import { isChatPlatform, normalizeEntityTypeSlug, } from "@lobu/core";
12
13
  import { AgentSettingsPatchSchema } from "@lobu/core/contracts/agent-settings";
@@ -18,6 +19,7 @@ import { Value } from "@sinclair/typebox/value";
18
19
  import { CronExpressionParser } from "cron-parser";
19
20
  import { isSecretRef, UNRESOLVED_MODEL_SUFFIX } from "../../../config/index.js";
20
21
  import { ValidationError } from "../../memory/_lib/errors.js";
22
+ import { ENTITY_TYPE_DISPLAY_FIELDS, LEGACY_DISPLAY_FIELDS, } from "./shared.js";
21
23
  /** Source label recorded on connector docs (mirrors the YAML manifest path). */
22
24
  const CONFIG_SOURCE = "lobu.config.ts";
23
25
  // Mirror the TOML loader's structural validators so a malformed TS config fails
@@ -298,10 +300,18 @@ function mapEntityType(entity) {
298
300
  throw new ValidationError(`entity type "${entity.key}" has invalid resolutionPolicy: ${error.message}`);
299
301
  }
300
302
  }
303
+ // Display fields pass through as declared ("" clears); an omitted one stays
304
+ // absent, so it is never sent and never diffed. See LEGACY_DISPLAY_FIELDS
305
+ // for name/description, where "" is dropped too.
306
+ const display = {};
307
+ for (const field of ENTITY_TYPE_DISPLAY_FIELDS) {
308
+ const value = entity[field];
309
+ if (LEGACY_DISPLAY_FIELDS.has(field) ? value : value !== undefined)
310
+ display[field] = value;
311
+ }
301
312
  return {
302
313
  slug: normalizeEntityTypeSlug(entity.key),
303
- ...(entity.name ? { name: entity.name } : {}),
304
- ...(entity.description ? { description: entity.description } : {}),
314
+ ...display,
305
315
  ...(entity.required ? { required: entity.required } : {}),
306
316
  ...(entity.properties ? { properties: entity.properties } : {}),
307
317
  ...(entity.collection !== undefined
@@ -785,8 +795,25 @@ export function mapProjectToDesiredState(project, env = process.env, only) {
785
795
  connectors: { definitions: [], authProfiles, connections },
786
796
  // View modules resolve in the loader (file IO): the mapper stays pure.
787
797
  views: [],
798
+ ...(project.navigation !== undefined
799
+ ? { navigation: canonicalNavigation(project.navigation) }
800
+ : {}),
788
801
  providers,
789
802
  requiredSecrets: [...required].sort(),
790
803
  };
791
804
  }
805
+ /**
806
+ * The navigation document as the server would store it, after the same
807
+ * canonical validation the server runs: a config error fails the load, before
808
+ * anything reaches the workspace.
809
+ */
810
+ function canonicalNavigation(navigation) {
811
+ if (navigation === null)
812
+ return null;
813
+ const errors = validateNavigationConfig(navigation);
814
+ if (errors.length > 0) {
815
+ throw new Error(`Invalid navigation:\n ${errors.join("\n ")}`);
816
+ }
817
+ return navigation;
818
+ }
792
819
  //# sourceMappingURL=map-config.js.map
@@ -14,6 +14,7 @@ const KIND_LABEL = {
14
14
  automation: "automation",
15
15
  "connector-definition": "connector-definition",
16
16
  view: "view",
17
+ navigation: "navigation",
17
18
  "auth-profile": "auth-profile",
18
19
  connection: "connection",
19
20
  feed: "feed",
@@ -27,6 +28,7 @@ const KIND_HEADING = {
27
28
  automation: "automations",
28
29
  "connector-definition": "connector-definitions",
29
30
  view: "views",
31
+ navigation: "navigation",
30
32
  "auth-profile": "auth-profiles",
31
33
  connection: "connections",
32
34
  feed: "feeds",
@@ -1,4 +1,5 @@
1
1
  import type { AutomationExecutionConfig, LegacyAutomationExecutionConfig } from "@lobu/core/contracts/tools/manage-automations";
2
+ import type { ManageEntitySchemaArgs } from "@lobu/core/contracts/tools/manage-entity-schema";
2
3
  /**
3
4
  * Shared structural types + tiny helpers used across the apply pipeline
4
5
  * (desired-state IR, wire client, diff, apply-cmd).
@@ -18,6 +19,25 @@ export interface EntityBacking {
18
19
  sql: string;
19
20
  connection?: string;
20
21
  }
22
+ /**
23
+ * Entity-type display fields whose authoring, desired and wire shapes are the
24
+ * same `manage_entity_schema` string. This one list drives the mapping
25
+ * (map-config), the remote snapshot (client.ts), the diff (diff.ts) and the
26
+ * upsert payload, so a new display field is added here and nowhere else.
27
+ */
28
+ export declare const ENTITY_TYPE_DISPLAY_FIELDS: readonly ["name", "description", "icon", "color"];
29
+ export type EntityTypeDisplayField = (typeof ENTITY_TYPE_DISPLAY_FIELDS)[number];
30
+ /**
31
+ * `name` and `description` predate the list and keep their original rules: a
32
+ * declared empty value is dropped like an omitted one; the two-way diff
33
+ * compares an omitted value as "" against live (reporting an update that sends
34
+ * nothing); and a baseline without the key recorded it unset. The other
35
+ * display fields send a declared "" as a clear, are unmanaged when omitted,
36
+ * and read a baseline without the key as "not recorded", because clients
37
+ * before them never wrote them into the baseline.
38
+ */
39
+ export declare const LEGACY_DISPLAY_FIELDS: ReadonlySet<EntityTypeDisplayField>;
40
+ export type EntityTypeDisplayFields = Pick<ManageEntitySchemaArgs, EntityTypeDisplayField>;
21
41
  /** One relationship-type rule (source/target entity-type slugs). */
22
42
  export interface RelationshipRule {
23
43
  source: string;
@@ -1,3 +1,25 @@
1
+ /**
2
+ * Entity-type display fields whose authoring, desired and wire shapes are the
3
+ * same `manage_entity_schema` string. This one list drives the mapping
4
+ * (map-config), the remote snapshot (client.ts), the diff (diff.ts) and the
5
+ * upsert payload, so a new display field is added here and nowhere else.
6
+ */
7
+ export const ENTITY_TYPE_DISPLAY_FIELDS = [
8
+ "name",
9
+ "description",
10
+ "icon",
11
+ "color",
12
+ ];
13
+ /**
14
+ * `name` and `description` predate the list and keep their original rules: a
15
+ * declared empty value is dropped like an omitted one; the two-way diff
16
+ * compares an omitted value as "" against live (reporting an update that sends
17
+ * nothing); and a baseline without the key recorded it unset. The other
18
+ * display fields send a declared "" as a clear, are unmanaged when omitted,
19
+ * and read a baseline without the key as "not recorded", because clients
20
+ * before them never wrote them into the baseline.
21
+ */
22
+ export const LEGACY_DISPLAY_FIELDS = new Set(["name", "description"]);
1
23
  export function isRecord(value) {
2
24
  return typeof value === "object" && value !== null && !Array.isArray(value);
3
25
  }
@@ -634,6 +634,16 @@ async function fetchOrgState(client, orgId) {
634
634
  // — a fetch failure falls back to placeholder credential keys.
635
635
  client.listConnectors(true).catch(() => []),
636
636
  ]);
637
+ // Only an owner/admin can read the raw document; any other login bootstraps
638
+ // without it and apply leaves the workspace's navigation unmanaged. The
639
+ // export is a starting point, not a license: apply replaces the document
640
+ // only while it is still what this config last applied, so run apply once
641
+ // before editing (a no-op that records it) and a later app edit blocks the
642
+ // stale file instead of being erased.
643
+ const navigation = await client
644
+ .getNavigation()
645
+ .then((state) => state.config)
646
+ .catch(() => null);
637
647
  // The relationship-type `list` action omits rules, so hydrate each type's
638
648
  // rules (list_rules) before emitting — otherwise the generated config drops
639
649
  // every `rules: [...]` binding and the round-trip is lossy. Best-effort per
@@ -705,6 +715,7 @@ async function fetchOrgState(client, orgId) {
705
715
  .sort((a, b) => a.slug.localeCompare(b.slug)),
706
716
  connections,
707
717
  connectorDefinitions,
718
+ navigation,
708
719
  };
709
720
  }
710
721
  function generateProject(orgSlug, orgName, state) {
@@ -841,6 +852,9 @@ function generateProject(orgSlug, orgName, state) {
841
852
  if (automationHandles.length > 0) {
842
853
  configFields.push(`automations: [${automationHandles.join(", ")}]`);
843
854
  }
855
+ if (state.navigation) {
856
+ configFields.push(`navigation: ${emitValue(state.navigation, 1)}`);
857
+ }
844
858
  const blocks = [];
845
859
  const pushBlock = (decls) => {
846
860
  if (decls.length > 0)
@@ -250,6 +250,8 @@ export async function devCommand(cwd, options = {}) {
250
250
  envVars.WEB_DIST_DIR ||
251
251
  (existsSync(bundledWebDistPath) ? bundledWebDistPath : undefined);
252
252
  const childEnv = {
253
+ // Reported by the anonymous install ping; the project .env may override.
254
+ LOBU_DEPLOY_KIND: "cli",
253
255
  ...mergedEnv,
254
256
  ...runtime.env,
255
257
  LOBU_DEV_PROJECT_PATH: projectPath,
@@ -2,6 +2,7 @@ import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
2
2
  import { basename, dirname, join, resolve } from "node:path";
3
3
  import { parse as parseYaml } from "yaml";
4
4
  import { loadDesiredStateFromConfig } from "../../_lib/apply/desired-state.js";
5
+ import { ENTITY_TYPE_DISPLAY_FIELDS, LEGACY_DISPLAY_FIELDS, } from "../../_lib/apply/shared.js";
5
6
  import { isPlatformOwnedRelationshipSlug } from "../../_lib/platform-owned-types.js";
6
7
  import { ApiError, ValidationError } from "./errors.js";
7
8
  import { getUsableToken, mcpUrlForOrg, orgFromMcpUrl, resolveOrg, resolveServerUrl, } from "./memory-auth.js";
@@ -121,9 +122,12 @@ async function seedEntity(entity, ctx) {
121
122
  schema_type: "entity_type",
122
123
  action: "create",
123
124
  slug: entity.slug,
124
- ...(entity.name ? { name: entity.name } : {}),
125
- ...(entity.description ? { description: entity.description } : {}),
126
125
  };
126
+ for (const field of ENTITY_TYPE_DISPLAY_FIELDS) {
127
+ const value = entity[field];
128
+ if (LEGACY_DISPLAY_FIELDS.has(field) ? value : value !== undefined)
129
+ payload[field] = value;
130
+ }
127
131
  if (entity.properties !== undefined || entity.required !== undefined) {
128
132
  payload.metadata_schema = {
129
133
  type: "object",
@@ -12,7 +12,9 @@
12
12
  import type { AutomationEventTrigger, AutomationScheduleTrigger, AutomationScriptContext, AutomationWorkspaceEventTrigger, CollectionPresentation, ConnectorClass, ConnectorRuntime, Dimension, EventSet, Measure, ReactionClient, ReactionContext, Segment } from "@lobu/connector-sdk";
13
13
  import type { AgentSettingsPatch } from "@lobu/core/contracts/agent-settings";
14
14
  import type { AutomationExecutionConfig } from "@lobu/core/contracts/tools/manage-automations";
15
+ import type { ManageEntitySchemaArgs } from "@lobu/core/contracts/tools/manage-entity-schema";
15
16
  import { type StringOptions, type TOptional, type TSchema, type TString } from "@sinclair/typebox";
17
+ import type { NavigationConfig } from "@lobu/core/contracts/tools/navigation";
16
18
  import type { SecretRef } from "./secret.js";
17
19
  /** A connector referenced by its key, or by the class produced by `defineConnector`. */
18
20
  export type ConnectorRef = string | ConnectorClass;
@@ -134,12 +136,16 @@ export interface EntityRulesSource {
134
136
  * the API and a connector sync all reach the same seam.
135
137
  */
136
138
  export declare function rulesFromFile<_Rule extends EntityWriteRule<never> = EntityWriteRule<never>>(path: string): EntityRulesSource;
137
- export interface EntityType {
139
+ /**
140
+ * An entity type's display fields — `name`, `description`, `icon` (an emoji or
141
+ * icon name) and `color` (for UI display) — typed by the `manage_entity_schema`
142
+ * contract they are sent on unchanged. A declared value is applied; an omitted
143
+ * one is left as it is on the server.
144
+ */
145
+ export interface EntityType extends Pick<ManageEntitySchemaArgs, "name" | "description" | "icon" | "color"> {
138
146
  readonly kind: "entityType";
139
147
  /** Stable slug — diff key. */
140
148
  key: string;
141
- name?: string;
142
- description?: string;
143
149
  /** Required property names for the entity's metadata. Omit when the properties
144
150
  * use `field()`/TypeBox — the required list is then derived from which fields
145
151
  * are not marked `optional`. An explicit list always wins. */
@@ -835,6 +841,18 @@ export interface Project {
835
841
  * appears; `lobu run` watches the listed files and their import graph.
836
842
  */
837
843
  views?: ViewSource[];
844
+ /**
845
+ * The workspace sidebar navigation, replacing the stored document on apply.
846
+ * The document is shared with the app's editor and agents, so apply only
847
+ * replaces what this config last applied: if someone changed it since (or
848
+ * it was exported before a later edit), apply blocks until this file adopts
849
+ * that change, and a concurrent edit during apply fails it (409) instead of
850
+ * being overwritten. A freshly exported file applies once as a no-op to
851
+ * record that starting point. Omit to leave it unmanaged; `null` returns
852
+ * the workspace to the automatic default (every workspace view). Targets
853
+ * must resolve when applied, so list the views they name in `views`.
854
+ */
855
+ navigation?: NavigationConfig | null;
838
856
  }
839
857
  export declare function defineConfig(config: Omit<Project, "kind">): Project;
840
858
  //# sourceMappingURL=define.d.ts.map
@@ -75,6 +75,7 @@ interface ConnectorSpec {
75
75
  includeOperations?: string[];
76
76
  excludeOperations?: string[];
77
77
  includeTags?: string[];
78
+ includeMethods?: string[]; // e.g. ['get'] for a read-only surface
78
79
  serverUrl?: string;
79
80
  };
80
81
  query?(ctx: QueryContext): Promise<QueryResult>; // Connection-level SQL/warehouse pushdown
@@ -87,7 +88,7 @@ Set `mcpConfig` to proxy an upstream MCP server through Lobu. The connector acts
87
88
 
88
89
  ### OpenAPI Config
89
90
 
90
- Set `openapiConfig` to auto-generate connector actions from an OpenAPI specification. The platform fetches the spec, filters operations by `includeOperations`/`excludeOperations`/`includeTags`, and exposes them as actions. Useful for REST APIs that already have OpenAPI docs.
91
+ Set `openapiConfig` to auto-generate connector actions from an OpenAPI specification. The platform fetches the spec, filters operations by `includeOperations`/`excludeOperations`/`includeTags`/`includeMethods`, and exposes them as actions. Operation keys are the spec's `operationId`. GET and HEAD operations are reads; every other method is a write, and DELETE is destructive. Use `includeMethods: ['get']` to expose only reads while writes stay hand-written actions. Useful for REST APIs that already have OpenAPI docs.
91
92
 
92
93
  ## Authentication
93
94
 
@@ -116,6 +117,7 @@ authSchema: {
116
117
  example: 'sk-...', // Placeholder hint
117
118
  secret: true, // Mask in UI
118
119
  required: true, // Whether this field is required
120
+ httpCredential: {}, // Optional: send as `Authorization: Bearer <value>`
119
121
  },
120
122
  ],
121
123
  }],
@@ -124,6 +126,8 @@ authSchema: {
124
126
 
125
127
  When `scope` is `'organization'`, the auth profile is shared across all connections in the org. Default is `'connection'` (per-connection credentials).
126
128
 
129
+ `httpCredential` marks the one env field that authenticates generated `openapiConfig` operations and MCP upstream calls for a connection on this env method, sent as `<header>: <scheme> <value>` (defaults `Authorization` and `Bearer`, e.g. `{ header: 'X-Api-Key', scheme: 'Token' }`). An App, OAuth or managed token always wins. The value is set gateway-side and never reaches a worker. At most one field per connector may declare it; `Host`, `Cookie`, framing and hop-by-hop headers are rejected at install. A token kept only in connection config (not an env auth profile) is not used.
130
+
127
131
  ### `oauth` - OAuth providers
128
132
 
129
133
  ```typescript
@@ -557,7 +561,7 @@ For source-backed bundled connectors, the worker recompiles a `.ts` file after i
557
561
  | `github` | app_installation/oauth/env_keys | issues, PRs, comments, discussions, commits, stargazers | create/comment/close/reopen issues; create/merge PRs |
558
562
  | `hackernews` | none | stories, front page, comments | - |
559
563
  | `linkedin` | browser/none | notifications, inbox messages, home feed, company updates, jobs; Data Export requires an injected CSV reader | send direct-message replies; like; prepare message/post/comment drafts |
560
- | `market.quotes` | none | - | quote (read-only, quotes returned to the caller, never persisted) |
564
+ | `market.quotes` | none | - | quote, history (read-only daily closes); results returned to the caller, never persisted |
561
565
  | `producthunt` | env_keys | posts & comments | - |
562
566
  | `reddit` | oauth/none | posts, comments, user activity, home feed | - |
563
567
  | `rss` | none | articles | - |
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * GitHub Connector (V1 runtime)
3
3
  *
4
- * Syncs GitHub repository content and executes write actions. Provider
4
+ * Syncs GitHub repository content, executes write actions, and exposes REST
5
+ * reads generated from GitHub's OpenAPI description. Provider
5
6
  * deliveries (the App webhook, or a per-connection hook for OAuth/PAT) mark the
6
7
  * matching feed due; star deliveries are recorded directly through the
7
8
  * stargazers feed's `normalize`, keyed on the poll's origin_id.
@@ -392,7 +393,7 @@ export default class GitHubConnector extends ConnectorRuntime {
392
393
  key: 'github',
393
394
  name: 'GitHub',
394
395
  description: 'Collects GitHub issues/discussions and executes repo actions.',
395
- version: '1.5.0',
396
+ version: '1.8.0',
396
397
  automationEvents: GITHUB_AUTOMATION_EVENTS,
397
398
  faviconDomain: 'github.com',
398
399
  // A GitHub connection gives the agent's sandbox an authenticated `gh`.
@@ -405,6 +406,16 @@ export default class GitHubConnector extends ConnectorRuntime {
405
406
  env: [{ name: 'GH_TOKEN', credential: 'lease' }],
406
407
  domains: ['api.github.com', 'github.com'],
407
408
  },
409
+ // Reads come from GitHub's official REST description (operation keys are
410
+ // its operationIds, e.g. `pulls/get`, `repos/get-content`) on the
411
+ // connection's own token. GET only: writes stay the hand-written actions
412
+ // below, so each one keeps its explicit contract and approval impact.
413
+ openapiConfig: {
414
+ specUrl:
415
+ 'https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.json',
416
+ includeTags: ['pulls', 'checks', 'repos', 'git', 'actions'],
417
+ includeMethods: ['get'],
418
+ },
408
419
  webhook: {
409
420
  signatureHeader: 'x-hub-signature-256',
410
421
  algorithm: 'sha256',
@@ -501,13 +512,15 @@ export default class GitHubConnector extends ConnectorRuntime {
501
512
  {
502
513
  type: 'env_keys',
503
514
  required: false,
504
- description: 'Optional fallback token for sync/action calls.',
515
+ description: 'Optional fallback token for sync/action calls and generated REST reads.',
505
516
  fields: [
506
517
  {
507
518
  key: 'GITHUB_TOKEN',
508
519
  label: 'GitHub Token',
509
520
  description: 'Personal access token used as fallback auth for API requests.',
510
521
  secret: true,
522
+ // Sent as `Authorization: Bearer <token>` on the generated reads.
523
+ httpCredential: {},
511
524
  },
512
525
  ],
513
526
  },