@lobu/runtime-device 24.7.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 (88) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +35 -51
  3. package/npm-shrinkwrap.json +214 -334
  4. package/package.json +4 -2
  5. package/vendor/cli/dist/bundled-skills/lobu/SKILL.md +14 -3
  6. package/vendor/cli/dist/chrome-extension/manifest.json +5 -4
  7. package/vendor/cli/dist/chrome-extension/tools.js +2 -3
  8. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +27 -0
  9. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +16 -5
  10. package/vendor/cli/dist/commands/_lib/apply/client.js +31 -9
  11. package/vendor/cli/dist/commands/_lib/apply/deployment.d.ts +8 -12
  12. package/vendor/cli/dist/commands/_lib/apply/deployment.js +14 -1
  13. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +8 -4
  14. package/vendor/cli/dist/commands/_lib/apply/desired-state.js +2 -1
  15. package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +26 -7
  16. package/vendor/cli/dist/commands/_lib/apply/diff.js +101 -30
  17. package/vendor/cli/dist/commands/_lib/apply/map-config.js +29 -2
  18. package/vendor/cli/dist/commands/_lib/apply/render.js +2 -0
  19. package/vendor/cli/dist/commands/_lib/apply/shared.d.ts +20 -0
  20. package/vendor/cli/dist/commands/_lib/apply/shared.js +22 -0
  21. package/vendor/cli/dist/commands/_lib/init-from-org/bootstrap.js +14 -0
  22. package/vendor/cli/dist/commands/dev.js +28 -4
  23. package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +6 -2
  24. package/vendor/cli/dist/config/define.d.ts +21 -3
  25. package/vendor/cli/dist/connectors/README.md +6 -2
  26. package/vendor/cli/dist/connectors/github.ts +16 -3
  27. package/vendor/cli/dist/connectors/imessage.ts +953 -0
  28. package/vendor/cli/dist/connectors/linkedin.ts +20 -377
  29. package/vendor/cli/dist/connectors/market_quotes.ts +388 -91
  30. package/vendor/cli/dist/connectors/postgres.ts +21 -14
  31. package/vendor/cli/dist/connectors/x-dm-adapter.js +55 -21
  32. package/vendor/cli/dist/connectors/x.ts +1 -1
  33. package/vendor/cli/dist/runtime-components.json +4 -4
  34. package/vendor/cli/dist/templates/AGENTS.md.tmpl +1 -1
  35. package/vendor/cli/package.json +1 -1
  36. package/vendor/connector-sdk/dist/connector-types.d.ts +23 -2
  37. package/vendor/connector-sdk/package.json +1 -1
  38. package/vendor/connector-worker/dist/daemon/automation.js +7 -4
  39. package/vendor/connector-worker/dist/env.d.ts +15 -0
  40. package/vendor/connector-worker/dist/env.js +17 -0
  41. package/vendor/connector-worker/dist/executor/isolate.d.ts +3 -1
  42. package/vendor/connector-worker/dist/executor/isolate.js +32 -8
  43. package/vendor/connector-worker/package.json +1 -1
  44. package/vendor/core/dist/classify-error.d.ts +3 -4
  45. package/vendor/core/dist/classify-error.js +8 -8
  46. package/vendor/core/dist/connector-query-errors.d.ts +6 -0
  47. package/vendor/core/dist/connector-query-errors.js +4 -0
  48. package/vendor/core/dist/contracts/tools/collection-presentation.d.ts +17 -1
  49. package/vendor/core/dist/contracts/tools/collection-presentation.js +27 -3
  50. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +39 -0
  51. package/vendor/core/dist/contracts/tools/manage-automations.js +11 -1
  52. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +1 -1
  53. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +2 -0
  54. package/vendor/core/dist/contracts/tools/manage-entity.js +7 -0
  55. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +2 -0
  56. package/vendor/core/dist/contracts/tools/manage-feeds.js +3 -0
  57. package/vendor/core/dist/contracts/tools/manage-views.d.ts +249 -7
  58. package/vendor/core/dist/contracts/tools/manage-views.js +83 -21
  59. package/vendor/core/dist/contracts/tools/navigation.d.ts +248 -0
  60. package/vendor/core/dist/contracts/tools/navigation.js +284 -0
  61. package/vendor/core/dist/contracts/tools/view-attach.d.ts +7 -0
  62. package/vendor/core/dist/contracts/tools/view-attach.js +15 -0
  63. package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +4 -1
  64. package/vendor/core/dist/contracts/tools/view-content-hash.js +4 -2
  65. package/vendor/core/dist/contracts/tools/view-definition.d.ts +2 -0
  66. package/vendor/core/dist/contracts/tools/view-definition.js +52 -0
  67. package/vendor/core/dist/contracts/tools/view-host.d.ts +68 -0
  68. package/vendor/core/dist/contracts/tools/view-host.js +30 -1
  69. package/vendor/core/dist/contracts/tools/view-scope.d.ts +31 -0
  70. package/vendor/core/dist/contracts/tools/view-scope.js +45 -0
  71. package/vendor/core/dist/error-report.js +1 -0
  72. package/vendor/core/dist/errors.d.ts +17 -24
  73. package/vendor/core/dist/errors.js +17 -24
  74. package/vendor/core/dist/types.d.ts +0 -6
  75. package/vendor/core/package.json +11 -1
  76. package/vendor/views/dist/api.d.ts +30 -5
  77. package/vendor/views/dist/api.js +22 -8
  78. package/vendor/views/dist/bridge.d.ts +17 -0
  79. package/vendor/views/dist/bridge.js +49 -1
  80. package/vendor/views/dist/components.d.ts +27 -5
  81. package/vendor/views/dist/components.js +57 -7
  82. package/vendor/views/dist/embed.d.ts +98 -0
  83. package/vendor/views/dist/embed.js +418 -0
  84. package/vendor/views/dist/index.d.ts +3 -1
  85. package/vendor/views/dist/index.js +1 -0
  86. package/vendor/views/package.json +1 -1
  87. package/vendor/cli/dist/connectors/linkedin-takeout.ts +0 -577
  88. package/vendor/cli/dist/connectors/takeout-utils.ts +0 -240
@@ -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)
@@ -17,6 +17,8 @@ import { checkNodeSupport } from "../internal/node-version.js";
17
17
  import { loadProjectLink } from "../internal/project-link.js";
18
18
  import { prepareRuntime } from "../internal/runtime-components.js";
19
19
  import { loadProjectConfig } from "./_lib/apply/desired-state.js";
20
+ /** How long `lobu run` waits after forwarding a signal before forcing exit. */
21
+ const SERVER_SHUTDOWN_GRACE_MS = 45_000;
20
22
  function connectorRefKey(ref) {
21
23
  return typeof ref === "string" ? ref : new ref().definition.key;
22
24
  }
@@ -270,10 +272,16 @@ export async function devCommand(cwd, options = {}) {
270
272
  // is a verified Node 26 binary (the current process when it already is one).
271
273
  // `--no-node-snapshot` is isolated-vm's upstream launch requirement on
272
274
  // Node 20+.
275
+ // The server leads its own process group, so the embedded Postgres and the
276
+ // embeddings child it starts share that group with it. Signals still go to
277
+ // the server alone and its teardown stops those children in order; the group
278
+ // is only for the forced kill below, which must not leave them listening.
279
+ const ownProcessGroup = process.platform !== "win32";
273
280
  const child = spawn(nodeBinary, ["--no-node-snapshot", bundlePath], {
274
281
  cwd,
275
282
  env: childEnv,
276
283
  stdio: "inherit",
284
+ detached: ownProcessGroup,
277
285
  });
278
286
  child.on("error", (err) => {
279
287
  console.error(chalk.red(`\n Failed to start Lobu: ${err.message}\n`));
@@ -329,20 +337,36 @@ export async function devCommand(cwd, options = {}) {
329
337
  await printPreviewInstructions(cwd);
330
338
  }
331
339
  });
332
- // Forward Ctrl+C to the child so it can clean up its own subprocess workers
333
- // before the parent exits. SIGKILL after a timeout in case it wedges.
340
+ // Forward Ctrl+C / SIGTERM to the server so it can run its ordered shutdown
341
+ // before the parent exits. The grace period covers the server's SIGTERM
342
+ // budget (connector worker 15s, HTTP close 10s, service and tracing
343
+ // teardown); a shorter one cut that teardown off mid-way. If it still wedges,
344
+ // SIGKILL its whole process group so no child outlives `lobu run`.
334
345
  const forwardSignal = (signal) => {
335
346
  if (child.exitCode !== null || child.signalCode !== null)
336
347
  return;
337
348
  child.kill(signal);
338
349
  setTimeout(() => {
339
- if (child.exitCode === null && child.signalCode === null) {
350
+ if (child.exitCode !== null || child.signalCode !== null)
351
+ return;
352
+ if (ownProcessGroup && child.pid !== undefined) {
353
+ process.kill(-child.pid, "SIGKILL");
354
+ }
355
+ else {
340
356
  child.kill("SIGKILL");
341
357
  }
342
- }, 10_000).unref();
358
+ }, SERVER_SHUTDOWN_GRACE_MS).unref();
343
359
  };
344
360
  process.on("SIGINT", () => forwardSignal("SIGINT"));
345
361
  process.on("SIGTERM", () => forwardSignal("SIGTERM"));
362
+ // In its own session the server no longer receives the terminal's hangup or
363
+ // Ctrl+\, and either signal would kill this process at once by default,
364
+ // orphaning the server with its ports held. Turn both into the same ordered
365
+ // shutdown (and forced group kill) as SIGTERM.
366
+ if (ownProcessGroup) {
367
+ process.on("SIGHUP", () => forwardSignal("SIGTERM"));
368
+ process.on("SIGQUIT", () => forwardSignal("SIGTERM"));
369
+ }
346
370
  child.on("exit", (code, signal) => {
347
371
  if (signal) {
348
372
  console.log(chalk.dim(`\n Lobu exited (${signal}).\n`));
@@ -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
  },