@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
@@ -0,0 +1,248 @@
1
+ import { type Static } from "@sinclair/typebox";
2
+ /**
3
+ * Resource ceilings, not product limits: a workspace with a thousand views can
4
+ * nest and group them freely. The tree is recursive; these only stop a
5
+ * document from being unbounded.
6
+ */
7
+ /** Deepest item nesting: a section's items are level 1. */
8
+ export declare const NAVIGATION_MAX_DEPTH = 32;
9
+ export declare const NAVIGATION_MAX_SECTIONS = 100;
10
+ /** Items across every section and level. */
11
+ export declare const NAVIGATION_MAX_ITEMS = 5000;
12
+ /** The whole document, serialized as UTF-8 JSON. */
13
+ export declare const NAVIGATION_MAX_BYTES: number;
14
+ export declare const PageRefSchema: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
15
+ kind: import("@sinclair/typebox").TLiteral<"view">;
16
+ key: import("@sinclair/typebox").TString;
17
+ scope: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
18
+ collection: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
19
+ search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
20
+ filters: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
21
+ field: import("@sinclair/typebox").TString;
22
+ op: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"eq">, import("@sinclair/typebox").TLiteral<"neq">]>;
23
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
24
+ }>, import("@sinclair/typebox").TObject<{
25
+ field: import("@sinclair/typebox").TString;
26
+ op: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"lt">, import("@sinclair/typebox").TLiteral<"lte">, import("@sinclair/typebox").TLiteral<"gt">, import("@sinclair/typebox").TLiteral<"gte">]>;
27
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber]>;
28
+ }>]>>>;
29
+ segment: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
30
+ }>>;
31
+ type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
32
+ entity: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
33
+ event: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
34
+ }>>;
35
+ params: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean]>>>;
36
+ }>, import("@sinclair/typebox").TObject<{
37
+ kind: import("@sinclair/typebox").TLiteral<"collection">;
38
+ entityType: import("@sinclair/typebox").TString;
39
+ }>, import("@sinclair/typebox").TObject<{
40
+ kind: import("@sinclair/typebox").TLiteral<"record">;
41
+ entityId: import("@sinclair/typebox").TInteger;
42
+ }>, import("@sinclair/typebox").TObject<{
43
+ kind: import("@sinclair/typebox").TLiteral<"link">;
44
+ href: import("@sinclair/typebox").TString;
45
+ }>]>;
46
+ export type PageRef = Static<typeof PageRefSchema>;
47
+ export interface NavigationItem {
48
+ id: string;
49
+ label?: string;
50
+ icon?: string;
51
+ target?: PageRef;
52
+ children?: NavigationItem[];
53
+ }
54
+ /**
55
+ * One item. `children` holds items of this same shape; the wire schema
56
+ * describes the shape once (no recursive `$ref`, which not every MCP host or
57
+ * JSON-schema tool reads) and `validateNavigationConfig` checks every nested
58
+ * item against it while it walks the tree.
59
+ */
60
+ export declare const NavigationItemSchema: import("@sinclair/typebox").TObject<{
61
+ id: import("@sinclair/typebox").TString;
62
+ label: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
63
+ icon: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
64
+ target: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
65
+ kind: import("@sinclair/typebox").TLiteral<"view">;
66
+ key: import("@sinclair/typebox").TString;
67
+ scope: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
68
+ collection: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
69
+ search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
70
+ filters: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
71
+ field: import("@sinclair/typebox").TString;
72
+ op: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"eq">, import("@sinclair/typebox").TLiteral<"neq">]>;
73
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
74
+ }>, import("@sinclair/typebox").TObject<{
75
+ field: import("@sinclair/typebox").TString;
76
+ op: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"lt">, import("@sinclair/typebox").TLiteral<"lte">, import("@sinclair/typebox").TLiteral<"gt">, import("@sinclair/typebox").TLiteral<"gte">]>;
77
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber]>;
78
+ }>]>>>;
79
+ segment: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
80
+ }>>;
81
+ type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
82
+ entity: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
83
+ event: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
84
+ }>>;
85
+ params: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean]>>>;
86
+ }>, import("@sinclair/typebox").TObject<{
87
+ kind: import("@sinclair/typebox").TLiteral<"collection">;
88
+ entityType: import("@sinclair/typebox").TString;
89
+ }>, import("@sinclair/typebox").TObject<{
90
+ kind: import("@sinclair/typebox").TLiteral<"record">;
91
+ entityId: import("@sinclair/typebox").TInteger;
92
+ }>, import("@sinclair/typebox").TObject<{
93
+ kind: import("@sinclair/typebox").TLiteral<"link">;
94
+ href: import("@sinclair/typebox").TString;
95
+ }>]>>;
96
+ children: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnknown>>;
97
+ }>;
98
+ export declare const NavigationSectionSchema: import("@sinclair/typebox").TObject<{
99
+ id: import("@sinclair/typebox").TString;
100
+ label: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
101
+ items: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
102
+ id: import("@sinclair/typebox").TString;
103
+ label: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
104
+ icon: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
105
+ target: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
106
+ kind: import("@sinclair/typebox").TLiteral<"view">;
107
+ key: import("@sinclair/typebox").TString;
108
+ scope: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
109
+ collection: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
110
+ search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
111
+ filters: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
112
+ field: import("@sinclair/typebox").TString;
113
+ op: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"eq">, import("@sinclair/typebox").TLiteral<"neq">]>;
114
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
115
+ }>, import("@sinclair/typebox").TObject<{
116
+ field: import("@sinclair/typebox").TString;
117
+ op: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"lt">, import("@sinclair/typebox").TLiteral<"lte">, import("@sinclair/typebox").TLiteral<"gt">, import("@sinclair/typebox").TLiteral<"gte">]>;
118
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber]>;
119
+ }>]>>>;
120
+ segment: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
121
+ }>>;
122
+ type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
123
+ entity: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
124
+ event: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
125
+ }>>;
126
+ params: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean]>>>;
127
+ }>, import("@sinclair/typebox").TObject<{
128
+ kind: import("@sinclair/typebox").TLiteral<"collection">;
129
+ entityType: import("@sinclair/typebox").TString;
130
+ }>, import("@sinclair/typebox").TObject<{
131
+ kind: import("@sinclair/typebox").TLiteral<"record">;
132
+ entityId: import("@sinclair/typebox").TInteger;
133
+ }>, import("@sinclair/typebox").TObject<{
134
+ kind: import("@sinclair/typebox").TLiteral<"link">;
135
+ href: import("@sinclair/typebox").TString;
136
+ }>]>>;
137
+ children: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnknown>>;
138
+ }>>;
139
+ }>;
140
+ export interface NavigationSection {
141
+ id: string;
142
+ label?: string;
143
+ items: NavigationItem[];
144
+ }
145
+ export declare const NavigationConfigSchema: import("@sinclair/typebox").TObject<{
146
+ schemaVersion: import("@sinclair/typebox").TLiteral<1>;
147
+ sections: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
148
+ id: import("@sinclair/typebox").TString;
149
+ label: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
150
+ items: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
151
+ id: import("@sinclair/typebox").TString;
152
+ label: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
153
+ icon: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
154
+ target: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
155
+ kind: import("@sinclair/typebox").TLiteral<"view">;
156
+ key: import("@sinclair/typebox").TString;
157
+ scope: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
158
+ collection: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
159
+ search: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
160
+ filters: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TObject<{
161
+ field: import("@sinclair/typebox").TString;
162
+ op: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"eq">, import("@sinclair/typebox").TLiteral<"neq">]>;
163
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean, import("@sinclair/typebox").TNull]>;
164
+ }>, import("@sinclair/typebox").TObject<{
165
+ field: import("@sinclair/typebox").TString;
166
+ op: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TLiteral<"lt">, import("@sinclair/typebox").TLiteral<"lte">, import("@sinclair/typebox").TLiteral<"gt">, import("@sinclair/typebox").TLiteral<"gte">]>;
167
+ value: import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber]>;
168
+ }>]>>>;
169
+ segment: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
170
+ }>>;
171
+ type: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
172
+ entity: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
173
+ event: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
174
+ }>>;
175
+ params: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TString, import("@sinclair/typebox").TNumber, import("@sinclair/typebox").TBoolean]>>>;
176
+ }>, import("@sinclair/typebox").TObject<{
177
+ kind: import("@sinclair/typebox").TLiteral<"collection">;
178
+ entityType: import("@sinclair/typebox").TString;
179
+ }>, import("@sinclair/typebox").TObject<{
180
+ kind: import("@sinclair/typebox").TLiteral<"record">;
181
+ entityId: import("@sinclair/typebox").TInteger;
182
+ }>, import("@sinclair/typebox").TObject<{
183
+ kind: import("@sinclair/typebox").TLiteral<"link">;
184
+ href: import("@sinclair/typebox").TString;
185
+ }>]>>;
186
+ children: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnknown>>;
187
+ }>>;
188
+ }>>;
189
+ }>;
190
+ export interface NavigationConfig {
191
+ schemaVersion: 1;
192
+ sections: NavigationSection[];
193
+ }
194
+ /** One rendered entry: what the sidebar draws after the server resolved it. */
195
+ export interface ResolvedNavigationItem {
196
+ id: string;
197
+ label: string;
198
+ icon?: string;
199
+ /** App path (`/<workspace>/...`, with query) or an external https URL. */
200
+ href?: string;
201
+ external?: boolean;
202
+ children: ResolvedNavigationItem[];
203
+ }
204
+ export interface ResolvedNavigationSection {
205
+ id: string;
206
+ label?: string;
207
+ items: ResolvedNavigationItem[];
208
+ }
209
+ export declare const ResolvedNavigationSectionSchema: import("@sinclair/typebox").TObject<{
210
+ id: import("@sinclair/typebox").TString;
211
+ label: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
212
+ items: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
213
+ id: import("@sinclair/typebox").TString;
214
+ label: import("@sinclair/typebox").TString;
215
+ icon: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
216
+ href: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
217
+ external: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
218
+ children: import("@sinclair/typebox").TArray<import("@sinclair/typebox").TUnknown>;
219
+ }>>;
220
+ }>;
221
+ export type NavigationDestination = {
222
+ kind: "internal";
223
+ path: string;
224
+ } | {
225
+ kind: "external";
226
+ href: string;
227
+ };
228
+ /**
229
+ * Where a link may go, decided once for both authored navigation links and a
230
+ * view's `openLink`: an absolute `https:` URL off this origin, or a path inside
231
+ * `/<workspace>/` on it. Everything else is refused — other schemes
232
+ * (`javascript:`, `data:`, `http:`), credentials in the URL, and any path that
233
+ * resolves outside the workspace (another workspace, `/account`, `..`).
234
+ */
235
+ export declare function linkDestination(url: string, origin: string, workspace: string): NavigationDestination | null;
236
+ /**
237
+ * An authored `link` href: an absolute https URL, or a path explicitly relative
238
+ * to the workspace root — no scheme, no leading slash, no `.`/`..` segment (in
239
+ * any encoding), no backslash or control character.
240
+ */
241
+ export declare function navigationHrefDestination(href: string, origin: string, workspace: string): NavigationDestination | null;
242
+ /**
243
+ * The one validator every writer runs (server `set`, CLI apply and pull):
244
+ * schema shape and bounds, then the rules a schema cannot say. Returns every
245
+ * problem as `<path>: <message>`; empty means valid.
246
+ */
247
+ export declare function validateNavigationConfig(config: unknown): string[];
248
+ //# sourceMappingURL=navigation.d.ts.map
@@ -0,0 +1,284 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ResolvedNavigationSectionSchema = exports.NavigationConfigSchema = exports.NavigationSectionSchema = exports.NavigationItemSchema = exports.PageRefSchema = exports.NAVIGATION_MAX_BYTES = exports.NAVIGATION_MAX_ITEMS = exports.NAVIGATION_MAX_SECTIONS = exports.NAVIGATION_MAX_DEPTH = void 0;
4
+ exports.linkDestination = linkDestination;
5
+ exports.navigationHrefDestination = navigationHrefDestination;
6
+ exports.validateNavigationConfig = validateNavigationConfig;
7
+ const typebox_1 = require("@sinclair/typebox");
8
+ const value_1 = require("@sinclair/typebox/value");
9
+ const view_scope_1 = require("./view-scope");
10
+ // ============================================
11
+ // Workspace navigation: the sidebar's curated sections.
12
+ // ============================================
13
+ //
14
+ // A workspace-owned, versioned document. It only presents: a section is not a
15
+ // permission or an owner, and hiding a destination never authorizes or
16
+ // denies it. `null` (never set) means the automatic default — the workspace's
17
+ // attached views — and an empty `sections` array means deliberately no custom
18
+ // entries. The product shell (Home, Memory, Search, Settings) is never part of
19
+ // it, so no configuration can remove it.
20
+ /**
21
+ * Resource ceilings, not product limits: a workspace with a thousand views can
22
+ * nest and group them freely. The tree is recursive; these only stop a
23
+ * document from being unbounded.
24
+ */
25
+ /** Deepest item nesting: a section's items are level 1. */
26
+ exports.NAVIGATION_MAX_DEPTH = 32;
27
+ exports.NAVIGATION_MAX_SECTIONS = 100;
28
+ /** Items across every section and level. */
29
+ exports.NAVIGATION_MAX_ITEMS = 5000;
30
+ /** The whole document, serialized as UTF-8 JSON. */
31
+ exports.NAVIGATION_MAX_BYTES = 1024 * 1024;
32
+ const NavigationIdSchema = typebox_1.Type.String({
33
+ pattern: "^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$",
34
+ description: "Stable id, unique across the whole document (sections and items). It names the menu entry, not its destination: two entries may open the same page.",
35
+ });
36
+ const NavigationLabelSchema = typebox_1.Type.String({ minLength: 1, maxLength: 80 });
37
+ const NavigationIconSchema = typebox_1.Type.String({
38
+ pattern: "^[a-z0-9-]{1,40}$",
39
+ description: "A Lucide icon name in kebab-case (https://lucide.dev/icons), e.g. 'building-2'; former Lucide names resolve too. Unknown names render the default icon.",
40
+ });
41
+ const ScalarParamSchema = typebox_1.Type.Union([
42
+ typebox_1.Type.String({ maxLength: 500 }),
43
+ typebox_1.Type.Number(),
44
+ typebox_1.Type.Boolean(),
45
+ ]);
46
+ exports.PageRefSchema = typebox_1.Type.Union([
47
+ typebox_1.Type.Object({
48
+ kind: typebox_1.Type.Literal("view"),
49
+ key: view_scope_1.ViewKeySchema,
50
+ scope: typebox_1.Type.Optional(typebox_1.Type.Object(view_scope_1.ViewScopeSchema.properties, {
51
+ additionalProperties: false,
52
+ })),
53
+ params: typebox_1.Type.Optional(typebox_1.Type.Record(typebox_1.Type.String({ maxLength: 64 }), ScalarParamSchema, {
54
+ maxProperties: 20,
55
+ description: "Declared view params; validated against the view when resolved.",
56
+ })),
57
+ }, { additionalProperties: false }),
58
+ typebox_1.Type.Object({
59
+ kind: typebox_1.Type.Literal("collection"),
60
+ entityType: typebox_1.Type.String({ minLength: 1, maxLength: 120 }),
61
+ }, { additionalProperties: false }),
62
+ typebox_1.Type.Object({
63
+ kind: typebox_1.Type.Literal("record"),
64
+ entityId: typebox_1.Type.Integer({ minimum: 1 }),
65
+ }, { additionalProperties: false }),
66
+ typebox_1.Type.Object({
67
+ kind: typebox_1.Type.Literal("link"),
68
+ href: typebox_1.Type.String({
69
+ minLength: 1,
70
+ maxLength: 2048,
71
+ description: "Workspace-root-relative path (e.g. 'deal?stage=won', resolved under /<workspace>/) or an absolute https:// URL.",
72
+ }),
73
+ }, { additionalProperties: false }),
74
+ ], {
75
+ description: "{ kind: 'view', key, scope?, params? } | { kind: 'collection', entityType } | { kind: 'record', entityId } | { kind: 'link', href }",
76
+ });
77
+ /**
78
+ * One item. `children` holds items of this same shape; the wire schema
79
+ * describes the shape once (no recursive `$ref`, which not every MCP host or
80
+ * JSON-schema tool reads) and `validateNavigationConfig` checks every nested
81
+ * item against it while it walks the tree.
82
+ */
83
+ exports.NavigationItemSchema = typebox_1.Type.Object({
84
+ id: NavigationIdSchema,
85
+ label: typebox_1.Type.Optional(NavigationLabelSchema),
86
+ icon: typebox_1.Type.Optional(NavigationIconSchema),
87
+ target: typebox_1.Type.Optional(exports.PageRefSchema),
88
+ children: typebox_1.Type.Optional(typebox_1.Type.Array(typebox_1.Type.Unknown(), {
89
+ description: "Nested items, each the same shape as this one.",
90
+ })),
91
+ }, { additionalProperties: false });
92
+ exports.NavigationSectionSchema = typebox_1.Type.Object({
93
+ id: NavigationIdSchema,
94
+ label: typebox_1.Type.Optional(NavigationLabelSchema),
95
+ items: typebox_1.Type.Array(exports.NavigationItemSchema),
96
+ }, { additionalProperties: false });
97
+ exports.NavigationConfigSchema = typebox_1.Type.Object({
98
+ schemaVersion: typebox_1.Type.Literal(1),
99
+ sections: typebox_1.Type.Array(exports.NavigationSectionSchema, {
100
+ maxItems: exports.NAVIGATION_MAX_SECTIONS,
101
+ }),
102
+ }, {
103
+ additionalProperties: false,
104
+ description: "{ schemaVersion: 1, sections: [{ id, label?, items: [{ id, label?, icon?, target?, children? }] }] }. An item without a target is a labeled group; with both, the label opens the target and a separate control expands the children.",
105
+ });
106
+ // Children are typed opaque on the wire, as on the input side: a recursive
107
+ // schema publishes a `$ref` the OpenAPI document never defines.
108
+ const ResolvedItemSchema = typebox_1.Type.Object({
109
+ id: typebox_1.Type.String(),
110
+ label: typebox_1.Type.String(),
111
+ icon: typebox_1.Type.Optional(typebox_1.Type.String()),
112
+ href: typebox_1.Type.Optional(typebox_1.Type.String()),
113
+ external: typebox_1.Type.Optional(typebox_1.Type.Boolean()),
114
+ children: typebox_1.Type.Array(typebox_1.Type.Unknown(), {
115
+ description: "Nested items, each the same shape as this one.",
116
+ }),
117
+ });
118
+ exports.ResolvedNavigationSectionSchema = typebox_1.Type.Object({
119
+ id: typebox_1.Type.String(),
120
+ label: typebox_1.Type.Optional(typebox_1.Type.String()),
121
+ items: typebox_1.Type.Array(ResolvedItemSchema),
122
+ });
123
+ const SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*:/;
124
+ // C0 controls, DEL and whitespace never belong in an authored path.
125
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: rejecting control characters is the point
126
+ const UNSAFE_CHARS = /[\u0000- \u007f\\]/;
127
+ /**
128
+ * Where a link may go, decided once for both authored navigation links and a
129
+ * view's `openLink`: an absolute `https:` URL off this origin, or a path inside
130
+ * `/<workspace>/` on it. Everything else is refused — other schemes
131
+ * (`javascript:`, `data:`, `http:`), credentials in the URL, and any path that
132
+ * resolves outside the workspace (another workspace, `/account`, `..`).
133
+ */
134
+ function linkDestination(url, origin, workspace) {
135
+ let parsed;
136
+ try {
137
+ parsed = new URL(url, `${origin}/${encodeURIComponent(workspace)}/`);
138
+ }
139
+ catch {
140
+ return null;
141
+ }
142
+ if (parsed.username || parsed.password)
143
+ return null;
144
+ if (parsed.origin === origin) {
145
+ const root = `/${encodeURIComponent(workspace)}`;
146
+ if (parsed.pathname !== root && !parsed.pathname.startsWith(`${root}/`)) {
147
+ return null;
148
+ }
149
+ return {
150
+ kind: "internal",
151
+ path: parsed.pathname + parsed.search + parsed.hash,
152
+ };
153
+ }
154
+ if (parsed.protocol !== "https:")
155
+ return null;
156
+ return { kind: "external", href: parsed.href };
157
+ }
158
+ /**
159
+ * An authored `link` href: an absolute https URL, or a path explicitly relative
160
+ * to the workspace root — no scheme, no leading slash, no `.`/`..` segment (in
161
+ * any encoding), no backslash or control character.
162
+ */
163
+ function navigationHrefDestination(href, origin, workspace) {
164
+ if (UNSAFE_CHARS.test(href))
165
+ return null;
166
+ if (SCHEME.test(href)) {
167
+ const destination = linkDestination(href, origin, workspace);
168
+ return destination?.kind === "external" ? destination : null;
169
+ }
170
+ if (href.startsWith("/"))
171
+ return null;
172
+ const path = href.split(/[?#]/, 1)[0] ?? "";
173
+ for (const segment of path.split("/")) {
174
+ let decoded;
175
+ try {
176
+ decoded = decodeURIComponent(segment);
177
+ }
178
+ catch {
179
+ return null;
180
+ }
181
+ if (decoded === "." || decoded === ".." || /[/\\]/.test(decoded)) {
182
+ return null;
183
+ }
184
+ }
185
+ return linkDestination(href, origin, workspace);
186
+ }
187
+ // ============================================
188
+ // Validation
189
+ // ============================================
190
+ /** Any origin works: validation only asks whether the href can resolve. */
191
+ const VALIDATION_ORIGIN = "https://workspace.invalid";
192
+ /**
193
+ * The one validator every writer runs (server `set`, CLI apply and pull):
194
+ * schema shape and bounds, then the rules a schema cannot say. Returns every
195
+ * problem as `<path>: <message>`; empty means valid.
196
+ */
197
+ function validateNavigationConfig(config) {
198
+ const bytes = new TextEncoder().encode(JSON.stringify(config) ?? "").length;
199
+ if (bytes > exports.NAVIGATION_MAX_BYTES) {
200
+ return [
201
+ `navigation: ${bytes} bytes exceed the limit of ${exports.NAVIGATION_MAX_BYTES}`,
202
+ ];
203
+ }
204
+ const schemaErrors = (schema, value, at) => [...value_1.Value.Errors(schema, value)]
205
+ .slice(0, 10)
206
+ .map((e) => `${at}${e.path.split("/").join(".")}: ${e.message}`);
207
+ if (!value_1.Value.Check(exports.NavigationConfigSchema, config)) {
208
+ return schemaErrors(exports.NavigationConfigSchema, config, "navigation");
209
+ }
210
+ const doc = config;
211
+ const errors = [];
212
+ const seen = new Set();
213
+ let items = 0;
214
+ const claim = (id, at) => {
215
+ if (seen.has(id))
216
+ errors.push(`${at}: duplicate id '${id}'`);
217
+ seen.add(id);
218
+ };
219
+ // Iterative, so a deep document cannot exhaust the stack; it stops at the
220
+ // first ceiling it crosses.
221
+ const stack = [];
222
+ for (let s = doc.sections.length - 1; s >= 0; s -= 1) {
223
+ const section = doc.sections[s];
224
+ if (!section)
225
+ continue;
226
+ for (let i = section.items.length - 1; i >= 0; i -= 1) {
227
+ stack.push({
228
+ item: section.items[i],
229
+ at: `navigation.sections[${s}].items[${i}]`,
230
+ depth: 1,
231
+ });
232
+ }
233
+ }
234
+ doc.sections.forEach((section, s) => {
235
+ claim(section.id, `navigation.sections[${s}]`);
236
+ });
237
+ while (stack.length > 0 && errors.length < 20) {
238
+ const { item: node, at, depth } = stack.pop();
239
+ items += 1;
240
+ if (items > exports.NAVIGATION_MAX_ITEMS) {
241
+ errors.push(`navigation: more than ${exports.NAVIGATION_MAX_ITEMS} items exceed the limit`);
242
+ break;
243
+ }
244
+ if (depth > exports.NAVIGATION_MAX_DEPTH) {
245
+ errors.push(`${at}: nesting deeper than ${exports.NAVIGATION_MAX_DEPTH} levels exceeds the limit`);
246
+ break;
247
+ }
248
+ if (!value_1.Value.Check(exports.NavigationItemSchema, node)) {
249
+ errors.push(...schemaErrors(exports.NavigationItemSchema, node, at));
250
+ continue;
251
+ }
252
+ const item = node;
253
+ claim(item.id, at);
254
+ const children = item.children ?? [];
255
+ if (!item.target && children.length === 0) {
256
+ errors.push(`${at}: an item needs a target, children, or both`);
257
+ }
258
+ if (!item.target && !item.label) {
259
+ errors.push(`${at}: a group without a target needs a label`);
260
+ }
261
+ if (item.target?.kind === "link" && !item.label) {
262
+ // A plain link has no resource to name it.
263
+ errors.push(`${at}: a link needs a label`);
264
+ }
265
+ if (item.target?.kind === "link" &&
266
+ !navigationHrefDestination(item.target.href, VALIDATION_ORIGIN, "w")) {
267
+ errors.push(`${at}.target.href: must be a workspace-relative path without '..' or an https:// URL`);
268
+ }
269
+ if (item.target?.kind === "view") {
270
+ const shape = (0, view_scope_1.viewScopeShapeError)(item.target.scope ?? {});
271
+ if (shape)
272
+ errors.push(`${at}.target.scope: ${shape}`);
273
+ }
274
+ for (let i = children.length - 1; i >= 0; i -= 1) {
275
+ stack.push({
276
+ item: children[i],
277
+ at: `${at}.children[${i}]`,
278
+ depth: depth + 1,
279
+ });
280
+ }
281
+ }
282
+ return errors;
283
+ }
284
+ //# sourceMappingURL=navigation.js.map
@@ -11,6 +11,13 @@ export declare function matchesRecord(attachment: ViewAttachment, record: {
11
11
  type: string;
12
12
  id: number | string | null;
13
13
  }): boolean;
14
+ /**
15
+ * Whether the view mounts on records of `typeSlug`: a tab on the type's list
16
+ * or a card on its record pages. With `recordId`, a record card pinned to
17
+ * another id does not count. A collection's `when` narrows what the tab
18
+ * shows, not which records the view is about, so it is ignored here.
19
+ */
20
+ export declare function attachesToEntityType(attach: readonly ViewAttachment[], typeSlug: string, recordId?: number): boolean;
14
21
  export declare function hasWorkspaceAttachment(attach: readonly ViewAttachment[]): boolean;
15
22
  /** Without a kind, the web host considers every event attachment a candidate. */
16
23
  export declare function eventAttachmentsFor(attach: readonly ViewAttachment[], semanticType?: string): EventAttachment[];
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isEventAttachment = isEventAttachment;
4
4
  exports.matchesCollection = matchesCollection;
5
5
  exports.matchesRecord = matchesRecord;
6
+ exports.attachesToEntityType = attachesToEntityType;
6
7
  exports.hasWorkspaceAttachment = hasWorkspaceAttachment;
7
8
  exports.eventAttachmentsFor = eventAttachmentsFor;
8
9
  const collection_selection_1 = require("./collection-selection");
@@ -21,6 +22,20 @@ function matchesRecord(attachment, record) {
21
22
  attachment.record === record.type &&
22
23
  (attachment.id === undefined || attachment.id === record.id));
23
24
  }
25
+ /**
26
+ * Whether the view mounts on records of `typeSlug`: a tab on the type's list
27
+ * or a card on its record pages. With `recordId`, a record card pinned to
28
+ * another id does not count. A collection's `when` narrows what the tab
29
+ * shows, not which records the view is about, so it is ignored here.
30
+ */
31
+ function attachesToEntityType(attach, typeSlug, recordId) {
32
+ return attach.some((attachment) => ("collection" in attachment && attachment.collection === typeSlug) ||
33
+ ("record" in attachment &&
34
+ attachment.record === typeSlug &&
35
+ (recordId === undefined ||
36
+ attachment.id === undefined ||
37
+ attachment.id === recordId)));
38
+ }
24
39
  function hasWorkspaceAttachment(attach) {
25
40
  return attach.some((attachment) => "workspace" in attachment);
26
41
  }
@@ -4,7 +4,7 @@ import type { RetainedSource } from "./source-files";
4
4
  * and the CLI (diff-before-apply): ONE function derives the key on both
5
5
  * sides, never read off whatever carried it. The hash covers the source, the
6
6
  * declared metadata that affects the stored row (name, description, attach,
7
- * params, actions), the retained files and dependencies when present, AND
7
+ * params, actions, resources), the retained files and dependencies when present, AND
8
8
  * the digest of the executable browser bundle. The
9
9
  * bundle matters because the CLI resolves relative imports and view npm deps
10
10
  * where node_modules exists: two different executable artifacts built from
@@ -27,6 +27,9 @@ export interface ViewContentMetadata {
27
27
  attach: unknown;
28
28
  params: unknown;
29
29
  actions: unknown;
30
+ /** Hashed only when non-empty, so a view that declares none keeps the
31
+ * identity it had before views could declare resources. */
32
+ resources: readonly string[];
30
33
  }
31
34
  /**
32
35
  * sha256 of the source plus the declared metadata plus the compiled
@@ -8,7 +8,7 @@ const node_crypto_1 = require("node:crypto");
8
8
  * and the CLI (diff-before-apply): ONE function derives the key on both
9
9
  * sides, never read off whatever carried it. The hash covers the source, the
10
10
  * declared metadata that affects the stored row (name, description, attach,
11
- * params, actions), the retained files and dependencies when present, AND
11
+ * params, actions, resources), the retained files and dependencies when present, AND
12
12
  * the digest of the executable browser bundle. The
13
13
  * bundle matters because the CLI resolves relative imports and view npm deps
14
14
  * where node_modules exists: two different executable artifacts built from
@@ -45,10 +45,12 @@ function contentHash(source, metadata, compiledCode, retainedSource) {
45
45
  const artifactDigest = (0, node_crypto_1.createHash)("sha256")
46
46
  .update(compiledCode, "utf8")
47
47
  .digest("hex");
48
+ const { resources, ...declared } = metadata;
49
+ const hashed = resources.length > 0 ? metadata : declared;
48
50
  const hash = (0, node_crypto_1.createHash)("sha256")
49
51
  .update(source)
50
52
  .update("\n")
51
- .update(stableStringify(metadata ?? null))
53
+ .update(stableStringify(hashed))
52
54
  .update("\n")
53
55
  .update(artifactDigest);
54
56
  if (retainedSource)
@@ -8,6 +8,8 @@ export interface ViewDefinitionRecord {
8
8
  attach: ViewAttachment[];
9
9
  params: Record<string, ViewParamDecl>;
10
10
  actions: Record<string, ViewActionDecl>;
11
+ /** Bare https origins the view may load images from, deduplicated. */
12
+ resources: string[];
11
13
  }
12
14
  /**
13
15
  * Read `export const view = defineView({...})` out of a view module, without