@lobu/runtime-device 20.2.0 → 21.1.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 (126) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +44 -38
  3. package/npm-shrinkwrap.json +277 -231
  4. package/package.json +1 -1
  5. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.d.ts +7 -2
  6. package/vendor/cli/dist/commands/_lib/apply/apply-cmd.js +77 -79
  7. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +41 -29
  8. package/vendor/cli/dist/commands/_lib/apply/client.js +33 -47
  9. package/vendor/cli/dist/commands/_lib/apply/deployment.d.ts +1 -1
  10. package/vendor/cli/dist/commands/_lib/apply/deployment.js +2 -3
  11. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +47 -13
  12. package/vendor/cli/dist/commands/_lib/apply/desired-state.js +106 -7
  13. package/vendor/cli/dist/commands/_lib/apply/diff.d.ts +14 -7
  14. package/vendor/cli/dist/commands/_lib/apply/diff.js +42 -29
  15. package/vendor/cli/dist/commands/_lib/apply/map-config.js +2 -3
  16. package/vendor/cli/dist/commands/_lib/apply/render.js +2 -0
  17. package/vendor/cli/dist/commands/_lib/apply/rollback-cmd.js +3 -3
  18. package/vendor/cli/dist/commands/_lib/connector-loader.d.ts +5 -1
  19. package/vendor/cli/dist/commands/_lib/connector-loader.js +1 -1
  20. package/vendor/cli/dist/commands/_lib/ensure-deps-installed.d.ts +15 -26
  21. package/vendor/cli/dist/commands/_lib/ensure-deps-installed.js +227 -136
  22. package/vendor/cli/dist/commands/_lib/view-bundler.d.ts +33 -0
  23. package/vendor/cli/dist/commands/_lib/view-bundler.js +211 -0
  24. package/vendor/cli/dist/commands/_lib/view-reapply.d.ts +60 -0
  25. package/vendor/cli/dist/commands/_lib/view-reapply.js +182 -0
  26. package/vendor/cli/dist/commands/dev.d.ts +14 -5
  27. package/vendor/cli/dist/commands/dev.js +56 -8
  28. package/vendor/cli/dist/commands/init.d.ts +1 -1
  29. package/vendor/cli/dist/commands/init.js +4 -4
  30. package/vendor/cli/dist/commands/memory/_lib/schema.d.ts +0 -1
  31. package/vendor/cli/dist/commands/memory/_lib/schema.js +0 -9
  32. package/vendor/cli/dist/commands/memory/_lib/seed-cmd.js +0 -2
  33. package/vendor/cli/dist/config/define.d.ts +25 -8
  34. package/vendor/cli/dist/config/define.js +24 -0
  35. package/vendor/cli/dist/connectors/README.md +15 -16
  36. package/vendor/cli/dist/connectors/github.ts +274 -193
  37. package/vendor/cli/dist/connectors/google_calendar.ts +54 -160
  38. package/vendor/cli/dist/connectors/google_drive.ts +106 -131
  39. package/vendor/cli/dist/connectors/google_gmail.ts +53 -30
  40. package/vendor/cli/dist/connectors/hackernews.ts +2 -5
  41. package/vendor/cli/dist/connectors/jira.ts +71 -27
  42. package/vendor/cli/dist/connectors/linear.ts +55 -21
  43. package/vendor/cli/dist/connectors/microsoft_outlook.ts +151 -110
  44. package/vendor/cli/dist/connectors/postgres.ts +19 -11
  45. package/vendor/cli/dist/connectors/producthunt.ts +11 -7
  46. package/vendor/cli/dist/connectors/reddit.ts +36 -6
  47. package/vendor/cli/dist/connectors/rss.ts +2 -2
  48. package/vendor/cli/dist/connectors/whatsapp_web.ts +5 -4
  49. package/vendor/cli/dist/connectors/x.ts +32 -17
  50. package/vendor/cli/dist/connectors/youtube.ts +18 -5
  51. package/vendor/cli/dist/internal/connector-compiler.d.ts +1 -1
  52. package/vendor/cli/dist/internal/connector-compiler.js +216 -17
  53. package/vendor/cli/dist/providers.json +0 -1
  54. package/vendor/cli/dist/runtime-components.json +4 -4
  55. package/vendor/cli/package.json +2 -1
  56. package/vendor/connector-sdk/dist/connector-runtime.d.ts +4 -6
  57. package/vendor/connector-sdk/dist/connector-runtime.js +3 -5
  58. package/vendor/connector-sdk/dist/connector-types.d.ts +28 -15
  59. package/vendor/connector-sdk/dist/define-connector.d.ts +4 -1
  60. package/vendor/connector-sdk/dist/define-connector.js +4 -1
  61. package/vendor/connector-sdk/dist/http-client.d.ts +18 -7
  62. package/vendor/connector-sdk/dist/http-client.js +15 -13
  63. package/vendor/connector-sdk/dist/index.d.ts +1 -1
  64. package/vendor/connector-sdk/dist/retry.d.ts +15 -3
  65. package/vendor/connector-sdk/dist/retry.js +40 -64
  66. package/vendor/connector-sdk/package.json +1 -1
  67. package/vendor/connector-worker/dist/agent-turn/guest-entry.js +122 -10
  68. package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +78 -10
  69. package/vendor/connector-worker/dist/agent-turn/types.d.ts +34 -4
  70. package/vendor/connector-worker/dist/compile/index.d.ts +21 -2
  71. package/vendor/connector-worker/dist/compile/index.js +41 -8
  72. package/vendor/connector-worker/dist/compile/source-capture.d.ts +10 -0
  73. package/vendor/connector-worker/dist/compile/source-capture.js +108 -0
  74. package/vendor/connector-worker/dist/daemon/agent-turn.js +97 -10
  75. package/vendor/connector-worker/dist/daemon/automation.d.ts +1 -1
  76. package/vendor/connector-worker/dist/daemon/client.d.ts +4 -1
  77. package/vendor/connector-worker/dist/daemon/client.js +3 -0
  78. package/vendor/connector-worker/dist/daemon/executor.d.ts +0 -1
  79. package/vendor/connector-worker/dist/daemon/executor.js +46 -51
  80. package/vendor/connector-worker/dist/daemon/start.js +6 -2
  81. package/vendor/connector-worker/dist/executor/interface.d.ts +19 -9
  82. package/vendor/connector-worker/dist/executor/isolate.js +85 -28
  83. package/vendor/connector-worker/dist/self-check/index.js +15 -13
  84. package/vendor/connector-worker/package.json +1 -1
  85. package/vendor/core/dist/agent-policy.js +3 -0
  86. package/vendor/core/dist/connector-query-errors.d.ts +3 -3
  87. package/vendor/core/dist/connector-query-errors.js +8 -3
  88. package/vendor/core/dist/contracts/tools/manage-auth-profiles.d.ts +14 -0
  89. package/vendor/core/dist/contracts/tools/manage-auth-profiles.js +12 -1
  90. package/vendor/core/dist/contracts/tools/manage-automations.d.ts +0 -10
  91. package/vendor/core/dist/contracts/tools/manage-automations.js +0 -33
  92. package/vendor/core/dist/contracts/tools/manage-classifiers.d.ts +4 -34
  93. package/vendor/core/dist/contracts/tools/manage-classifiers.js +13 -44
  94. package/vendor/core/dist/contracts/tools/manage-connections.d.ts +24 -0
  95. package/vendor/core/dist/contracts/tools/manage-connections.js +13 -0
  96. package/vendor/core/dist/contracts/tools/manage-entity-schema.d.ts +15 -25
  97. package/vendor/core/dist/contracts/tools/manage-entity-schema.js +3 -5
  98. package/vendor/core/dist/contracts/tools/manage-entity.d.ts +0 -9
  99. package/vendor/core/dist/contracts/tools/manage-entity.js +0 -6
  100. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +11 -0
  101. package/vendor/core/dist/contracts/tools/manage-feeds.js +12 -1
  102. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +47 -6
  103. package/vendor/core/dist/contracts/tools/manage-operations.js +36 -1
  104. package/vendor/core/dist/contracts/tools/manage-views.d.ts +293 -0
  105. package/vendor/core/dist/contracts/tools/manage-views.js +203 -0
  106. package/vendor/core/dist/contracts/tools/source-files-schema.d.ts +7 -0
  107. package/vendor/core/dist/contracts/tools/source-files-schema.js +19 -0
  108. package/vendor/core/dist/contracts/tools/source-files.d.ts +14 -0
  109. package/vendor/core/dist/contracts/tools/source-files.js +55 -0
  110. package/vendor/core/dist/contracts/tools/view-attach.d.ts +20 -0
  111. package/vendor/core/dist/contracts/tools/view-attach.js +45 -0
  112. package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +37 -0
  113. package/vendor/core/dist/contracts/tools/view-content-hash.js +58 -0
  114. package/vendor/core/dist/contracts/tools/view-path.d.ts +18 -0
  115. package/vendor/core/dist/contracts/tools/view-path.js +24 -0
  116. package/vendor/core/dist/contracts/worker/protocol.d.ts +90 -8
  117. package/vendor/core/dist/contracts/worker/protocol.js +70 -10
  118. package/vendor/core/dist/index.d.ts +1 -1
  119. package/vendor/core/dist/provider-config-types.d.ts +0 -9
  120. package/vendor/core/dist/reserved.d.ts +3 -3
  121. package/vendor/core/dist/reserved.js +9 -1
  122. package/vendor/core/dist/sdk-compat.d.ts +1 -1
  123. package/vendor/core/dist/utils/secret-redaction.js +2 -0
  124. package/vendor/core/package.json +30 -5
  125. package/vendor/core/dist/contracts/tools/manage-view-templates.d.ts +0 -165
  126. package/vendor/core/dist/contracts/tools/manage-view-templates.js +0 -130
@@ -0,0 +1,203 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ManageViewsResultSchema = exports.ManageViewsSchema = exports.RemoveViewAction = exports.ListViewsAction = exports.GetViewAction = exports.SetViewAction = exports.ViewRowSchema = exports.ViewActionDeclSchema = exports.ViewParamDeclSchema = exports.ViewAttachmentSchema = exports.ViewKeySchema = void 0;
4
+ const typebox_1 = require("@sinclair/typebox");
5
+ const source_files_schema_1 = require("./source-files-schema");
6
+ // ============================================
7
+ // Lobu views: React modules rendered in the sandboxed frame.
8
+ // ============================================
9
+ // A view key names the module: lowercase, dashes, 1-64 chars. The folder is
10
+ // only a convention — the key is the identity (no `custom:<name>` prefix).
11
+ exports.ViewKeySchema = typebox_1.Type.String({
12
+ pattern: "^[a-z0-9][a-z0-9-]{0,63}$",
13
+ minLength: 1,
14
+ maxLength: 64,
15
+ description: "View key, e.g. 'pipeline'.",
16
+ });
17
+ // Where a view appears. The attach line lives in the module source; there are
18
+ // no attach/detach verbs — changing placement means re-saving the view.
19
+ const ViewPlacementSchema = typebox_1.Type.Optional(typebox_1.Type.Union([typebox_1.Type.Literal("tab"), typebox_1.Type.Literal("overview")], {
20
+ description: "Type-attached views render as a full tab or an Overview card.",
21
+ }));
22
+ // `event_kind` belongs to the event variant alone. The subject variants stay
23
+ // open objects (the handler reports a mixed entry itself), so each one forbids
24
+ // the key: otherwise `{ event_kind, type, placement }` would validate as a
25
+ // type attachment and render as a type tab.
26
+ const NoEventKind = typebox_1.Type.Optional(typebox_1.Type.Never());
27
+ exports.ViewAttachmentSchema = typebox_1.Type.Union([
28
+ typebox_1.Type.Object({
29
+ type: typebox_1.Type.String({
30
+ minLength: 1,
31
+ maxLength: 120,
32
+ description: "Entity-type slug this view attaches to.",
33
+ }),
34
+ placement: ViewPlacementSchema,
35
+ event_kind: NoEventKind,
36
+ }),
37
+ typebox_1.Type.Object({
38
+ entity: typebox_1.Type.Union([typebox_1.Type.Integer(), typebox_1.Type.String()], {
39
+ description: "Entity id (number) or slug (string) this view attaches to.",
40
+ }),
41
+ placement: ViewPlacementSchema,
42
+ event_kind: NoEventKind,
43
+ }),
44
+ typebox_1.Type.Object({
45
+ workspace: typebox_1.Type.Literal(true, {
46
+ description: "A tab on the Data hub, at /data/-/views/<key>.",
47
+ }),
48
+ placement: ViewPlacementSchema,
49
+ event_kind: NoEventKind,
50
+ }),
51
+ // An event subject: the view renders one event (scope.event) on the event's
52
+ // own page, /events/<id>/-/views/<key>. It matches an event whose kind is
53
+ // `event_kind` AND that links at least one entity of `type`. Closed, and no
54
+ // placement: the event page has one layout.
55
+ typebox_1.Type.Object({
56
+ event_kind: typebox_1.Type.String({
57
+ minLength: 1,
58
+ maxLength: 128,
59
+ description: "Event kind (semantic_type) this view renders, e.g. 'deal.won'.",
60
+ }),
61
+ type: typebox_1.Type.String({
62
+ minLength: 1,
63
+ maxLength: 120,
64
+ description: "Entity-type slug the event must link at least one entity of.",
65
+ }),
66
+ }, { additionalProperties: false }),
67
+ ]);
68
+ // Declared, typed URL params. Unknown params are ignored; `peek` and `peek_*`
69
+ // are reserved (the web shell's peek pane reads them on every page).
70
+ exports.ViewParamDeclSchema = typebox_1.Type.Object({
71
+ type: typebox_1.Type.Union([typebox_1.Type.Literal("string"), typebox_1.Type.Literal("number"), typebox_1.Type.Literal("boolean")], { description: "Param type used to validate the URL value." }),
72
+ default: typebox_1.Type.Optional(typebox_1.Type.Unknown({ description: "Default when the URL omits the param." })),
73
+ description: typebox_1.Type.Optional(typebox_1.Type.String()),
74
+ });
75
+ // Actions a view declares as metadata; each emits an event kind through the
76
+ // template-action chokepoint. A removed action stops working on the next read
77
+ // because the check runs against the CURRENT view row.
78
+ exports.ViewActionDeclSchema = typebox_1.Type.Object({
79
+ emits: typebox_1.Type.String({
80
+ minLength: 1,
81
+ maxLength: 128,
82
+ description: "Event kind appended when the action fires, e.g. 'deal.won'.",
83
+ }),
84
+ });
85
+ // Public projection of a stored view: metadata only, never the bundle. The
86
+ // bundle travels over the view resource / shell route; the source over get.
87
+ exports.ViewRowSchema = typebox_1.Type.Object({
88
+ key: exports.ViewKeySchema,
89
+ name: typebox_1.Type.String(),
90
+ description: typebox_1.Type.String(),
91
+ content_hash: typebox_1.Type.String({
92
+ description: "First 16 hex of sha256(source, declared metadata, compiled artifact digest, retained source files and dependencies). Identical content means no write.",
93
+ }),
94
+ attach: typebox_1.Type.Array(exports.ViewAttachmentSchema),
95
+ params: typebox_1.Type.Record(typebox_1.Type.String(), exports.ViewParamDeclSchema),
96
+ actions: typebox_1.Type.Record(typebox_1.Type.String(), exports.ViewActionDeclSchema),
97
+ last_writer: typebox_1.Type.String({
98
+ description: "apply:<apply_id> | <user_id> | migration:view-templates",
99
+ }),
100
+ updated_at: typebox_1.Type.String(),
101
+ compiled_bytes: typebox_1.Type.Integer(),
102
+ source_bytes: typebox_1.Type.Integer(),
103
+ });
104
+ // ============================================
105
+ // Input Schema (union of per-action variants)
106
+ // ============================================
107
+ //
108
+ // The wire schema flattens this union into ONE MCP object and merges duplicate
109
+ // properties first-occurrence-wins, so a property carried by more than one
110
+ // variant must read true for every one of them.
111
+ exports.SetViewAction = typebox_1.Type.Object({
112
+ action: typebox_1.Type.Literal("set", {
113
+ description: "Store a view: compile source_code and upsert by key.",
114
+ }),
115
+ key: exports.ViewKeySchema,
116
+ name: typebox_1.Type.Optional(typebox_1.Type.String({
117
+ maxLength: 120,
118
+ description: "[set] Display name; defaults to key.",
119
+ })),
120
+ description: typebox_1.Type.Optional(typebox_1.Type.String({ maxLength: 500, description: "[set] What the view shows." })),
121
+ source_code: typebox_1.Type.String({
122
+ minLength: 1,
123
+ maxLength: 1000000,
124
+ description: "[set] The view module source (TSX). Compiled server-side.",
125
+ }),
126
+ compiled_code: typebox_1.Type.Optional(typebox_1.Type.String({
127
+ minLength: 1,
128
+ description: "[set] CLI-bundled browser bundle for the source (relative files and npm deps resolved where node_modules exists). When present the server stores it after the size check instead of compiling; when absent the server compiles source_code itself (the chat-agent path).",
129
+ })),
130
+ source_files: typebox_1.Type.Optional(source_files_schema_1.SourceFilesSchema),
131
+ dependencies: typebox_1.Type.Optional(source_files_schema_1.SourceDependenciesSchema),
132
+ attach: typebox_1.Type.Optional(typebox_1.Type.Array(exports.ViewAttachmentSchema, {
133
+ description: "[set] Where the view appears; extracted from the module by the caller.",
134
+ })),
135
+ params: typebox_1.Type.Optional(typebox_1.Type.Record(typebox_1.Type.String(), exports.ViewParamDeclSchema, {
136
+ description: "[set] Declared URL params.",
137
+ })),
138
+ actions: typebox_1.Type.Optional(typebox_1.Type.Record(typebox_1.Type.String(), exports.ViewActionDeclSchema, {
139
+ description: "[set] Declared actions and the event kind each emits.",
140
+ })),
141
+ last_writer: typebox_1.Type.Optional(typebox_1.Type.String({
142
+ maxLength: 200,
143
+ description: "[set] Provenance; defaults to the caller.",
144
+ })),
145
+ });
146
+ exports.GetViewAction = typebox_1.Type.Object({
147
+ action: typebox_1.Type.Literal("get", {
148
+ description: "Fetch one view's metadata + source.",
149
+ }),
150
+ key: exports.ViewKeySchema,
151
+ });
152
+ exports.ListViewsAction = typebox_1.Type.Object({
153
+ action: typebox_1.Type.Literal("list", {
154
+ description: "List every view's metadata (never bundles).",
155
+ }),
156
+ });
157
+ exports.RemoveViewAction = typebox_1.Type.Object({
158
+ action: typebox_1.Type.Literal("remove", {
159
+ description: "Delete a view by key.",
160
+ }),
161
+ key: exports.ViewKeySchema,
162
+ });
163
+ exports.ManageViewsSchema = typebox_1.Type.Union([
164
+ exports.SetViewAction,
165
+ exports.GetViewAction,
166
+ exports.ListViewsAction,
167
+ exports.RemoveViewAction,
168
+ ]);
169
+ // ============================================
170
+ // Result Types
171
+ // ============================================
172
+ /**
173
+ * Result of `manage_views` — discriminated union keyed on `action`.
174
+ * TypeBox-first: `Static<>` derives the TS type from the same schema exposed as
175
+ * the tool's `outputSchema`.
176
+ */
177
+ exports.ManageViewsResultSchema = typebox_1.Type.Union([
178
+ typebox_1.Type.Object({
179
+ action: typebox_1.Type.Literal("set"),
180
+ view: exports.ViewRowSchema,
181
+ written: typebox_1.Type.Boolean({
182
+ description: "False when the same source, retained files, dependencies, metadata and executable artifact were already stored (no write).",
183
+ }),
184
+ }),
185
+ typebox_1.Type.Object({
186
+ action: typebox_1.Type.Literal("get"),
187
+ view: exports.ViewRowSchema,
188
+ source_code: typebox_1.Type.String(),
189
+ source_files: typebox_1.Type.Union([source_files_schema_1.SourceFilesSchema, typebox_1.Type.Null()]),
190
+ dependencies: typebox_1.Type.Union([source_files_schema_1.SourceDependenciesSchema, typebox_1.Type.Null()]),
191
+ source_complete: typebox_1.Type.Boolean(),
192
+ }),
193
+ typebox_1.Type.Object({
194
+ action: typebox_1.Type.Literal("list"),
195
+ views: typebox_1.Type.Array(exports.ViewRowSchema),
196
+ }),
197
+ typebox_1.Type.Object({
198
+ action: typebox_1.Type.Literal("remove"),
199
+ key: typebox_1.Type.String(),
200
+ removed: typebox_1.Type.Boolean(),
201
+ }),
202
+ ]);
203
+ //# sourceMappingURL=manage-views.js.map
@@ -0,0 +1,7 @@
1
+ /** Paths are relative to the author's project, never a build machine. */
2
+ export declare const SourceFilesSchema: import("@sinclair/typebox").TObject<{
3
+ entrypoint: import("@sinclair/typebox").TString;
4
+ files: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
5
+ }>;
6
+ export declare const SourceDependenciesSchema: import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TString>;
7
+ //# sourceMappingURL=source-files-schema.d.ts.map
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SourceDependenciesSchema = exports.SourceFilesSchema = void 0;
4
+ const typebox_1 = require("@sinclair/typebox");
5
+ const source_files_1 = require("./source-files");
6
+ /** Paths are relative to the author's project, never a build machine. */
7
+ exports.SourceFilesSchema = typebox_1.Type.Object({
8
+ entrypoint: typebox_1.Type.String({ minLength: 1, maxLength: 240 }),
9
+ files: typebox_1.Type.Record(typebox_1.Type.String(), typebox_1.Type.String(), {
10
+ maxProperties: source_files_1.SOURCE_MAX_FILES,
11
+ }),
12
+ }, {
13
+ description: "Author files consumed by the build, keyed by portable project-relative paths. entrypoint identifies the file matching source_code. Never include secrets, machine paths, node_modules, or resolved credentials.",
14
+ });
15
+ exports.SourceDependenciesSchema = typebox_1.Type.Record(typebox_1.Type.String(), typebox_1.Type.String(), {
16
+ maxProperties: source_files_1.SOURCE_MAX_FILES,
17
+ description: "Direct npm dependencies and their exact installed versions, captured with source_files. This is not a lockfile.",
18
+ });
19
+ //# sourceMappingURL=source-files-schema.js.map
@@ -0,0 +1,14 @@
1
+ import type { Static } from "@sinclair/typebox";
2
+ import type { SourceDependenciesSchema, SourceFilesSchema } from "./source-files-schema";
3
+ export declare const SOURCE_MAX_BYTES = 1000000;
4
+ export declare const SOURCE_MAX_FILES = 128;
5
+ export type SourceFiles = Static<typeof SourceFilesSchema>;
6
+ export type SourceDependencies = Static<typeof SourceDependenciesSchema>;
7
+ export interface RetainedSource {
8
+ sourceFiles: SourceFiles;
9
+ dependencies: SourceDependencies;
10
+ }
11
+ export declare function assertSourcePath(path: string): void;
12
+ /** Shared validation at capture and API boundaries. No caller can assert completeness. */
13
+ export declare function validateRetainedSource(sourceCode: string, sourceFiles: SourceFiles, dependencies: SourceDependencies): void;
14
+ //# sourceMappingURL=source-files.d.ts.map
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SOURCE_MAX_FILES = exports.SOURCE_MAX_BYTES = void 0;
4
+ exports.assertSourcePath = assertSourcePath;
5
+ exports.validateRetainedSource = validateRetainedSource;
6
+ exports.SOURCE_MAX_BYTES = 1000000;
7
+ exports.SOURCE_MAX_FILES = 128;
8
+ function assertSourcePath(path) {
9
+ const parts = path.split("/");
10
+ if (!path ||
11
+ path.length > 240 ||
12
+ /[\\:%]/.test(path) ||
13
+ path.includes("\0") ||
14
+ parts.some((part) => !part ||
15
+ part === "." ||
16
+ part === ".." ||
17
+ part === "node_modules" ||
18
+ part === ".git" ||
19
+ part === ".lobu" ||
20
+ part === ".npmrc" ||
21
+ part.startsWith(".env"))) {
22
+ throw new Error(`Source path must be a portable project file: ${path}`);
23
+ }
24
+ }
25
+ /** Shared validation at capture and API boundaries. No caller can assert completeness. */
26
+ function validateRetainedSource(sourceCode, sourceFiles, dependencies) {
27
+ assertSourcePath(sourceFiles.entrypoint);
28
+ const files = Object.entries(sourceFiles.files);
29
+ if (files.length === 0 || files.length > exports.SOURCE_MAX_FILES) {
30
+ throw new Error(`Source must contain between 1 and ${exports.SOURCE_MAX_FILES} files`);
31
+ }
32
+ for (const [path, contents] of files) {
33
+ assertSourcePath(path);
34
+ if (typeof contents !== "string")
35
+ throw new Error(`Source file must be text: ${path}`);
36
+ }
37
+ if (!Object.keys(sourceFiles.files).includes(sourceFiles.entrypoint) ||
38
+ sourceFiles.files[sourceFiles.entrypoint] !== sourceCode) {
39
+ throw new Error("Source entrypoint must match source_code exactly");
40
+ }
41
+ const packages = Object.entries(dependencies);
42
+ if (packages.length > exports.SOURCE_MAX_FILES)
43
+ throw new Error("Too many source dependencies");
44
+ for (const [name, version] of packages) {
45
+ if (!/^(?:@[a-z0-9._-]+\/)?[a-z0-9._-]+$/.test(name) ||
46
+ !/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.test(version)) {
47
+ throw new Error(`Source dependency requires a package name and exact version: ${name}`);
48
+ }
49
+ }
50
+ if (new TextEncoder().encode(JSON.stringify({ sourceFiles, dependencies }))
51
+ .length > exports.SOURCE_MAX_BYTES) {
52
+ throw new Error(`Source files exceed ${exports.SOURCE_MAX_BYTES} bytes`);
53
+ }
54
+ }
55
+ //# sourceMappingURL=source-files.js.map
@@ -0,0 +1,20 @@
1
+ import type { ViewAttachment } from "./manage-views";
2
+ type EventAttachment = Extract<ViewAttachment, {
3
+ event_kind: string;
4
+ }>;
5
+ type ViewPlacement = "tab" | "overview";
6
+ /** An event's type qualifies its linked entities; it never names a page tab. */
7
+ export declare function isEventAttachment(attachment: ViewAttachment): attachment is EventAttachment;
8
+ export declare function isTabAttachment(attachment: ViewAttachment): boolean;
9
+ export declare function matchesType(attachment: ViewAttachment, typeSlug: string, placement: ViewPlacement): boolean;
10
+ export declare function matchesRecord(attachment: ViewAttachment, record: {
11
+ type: string;
12
+ id: number;
13
+ slug: string;
14
+ parentId: number | null;
15
+ }, placement: ViewPlacement): boolean;
16
+ export declare function hasWorkspaceAttachment(attach: readonly ViewAttachment[]): boolean;
17
+ /** Without a kind, the web host considers every event attachment a candidate. */
18
+ export declare function eventAttachmentsFor(attach: readonly ViewAttachment[], semanticType?: string): EventAttachment[];
19
+ export {};
20
+ //# sourceMappingURL=view-attach.d.ts.map
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isEventAttachment = isEventAttachment;
4
+ exports.isTabAttachment = isTabAttachment;
5
+ exports.matchesType = matchesType;
6
+ exports.matchesRecord = matchesRecord;
7
+ exports.hasWorkspaceAttachment = hasWorkspaceAttachment;
8
+ exports.eventAttachmentsFor = eventAttachmentsFor;
9
+ /** An event's type qualifies its linked entities; it never names a page tab. */
10
+ function isEventAttachment(attachment) {
11
+ return ("event_kind" in attachment && typeof attachment.event_kind === "string");
12
+ }
13
+ function isTabAttachment(attachment) {
14
+ return (!isEventAttachment(attachment) && (attachment.placement ?? "tab") === "tab");
15
+ }
16
+ function matchesType(attachment, typeSlug, placement) {
17
+ return (!isEventAttachment(attachment) &&
18
+ "type" in attachment &&
19
+ attachment.type === typeSlug &&
20
+ (attachment.placement ?? "tab") === placement);
21
+ }
22
+ function matchesRecord(attachment, record, placement) {
23
+ if (isEventAttachment(attachment))
24
+ return false;
25
+ if ((attachment.placement ?? "tab") !== placement)
26
+ return false;
27
+ if ("entity" in attachment) {
28
+ return typeof attachment.entity === "number"
29
+ ? attachment.entity === record.id
30
+ : record.parentId === null && attachment.entity === record.slug;
31
+ }
32
+ return matchesType(attachment, record.type, placement);
33
+ }
34
+ function hasWorkspaceAttachment(attach) {
35
+ return attach.some((attachment) => !isEventAttachment(attachment) &&
36
+ "workspace" in attachment &&
37
+ attachment.workspace === true);
38
+ }
39
+ /** Without a kind, the web host considers every event attachment a candidate. */
40
+ function eventAttachmentsFor(attach, semanticType) {
41
+ return attach
42
+ .filter(isEventAttachment)
43
+ .filter((attachment) => semanticType === undefined || attachment.event_kind === semanticType);
44
+ }
45
+ //# sourceMappingURL=view-attach.js.map
@@ -0,0 +1,37 @@
1
+ import type { RetainedSource } from "./source-files";
2
+ /**
3
+ * Content identity for Lobu views, shared by the server (compile-at-save)
4
+ * and the CLI (diff-before-apply): ONE function derives the key on both
5
+ * sides, never read off whatever carried it. The hash covers the source, the
6
+ * declared metadata that affects the stored row (name, description, attach,
7
+ * params, actions), the retained files and dependencies when present, AND
8
+ * the digest of the executable browser bundle. The
9
+ * bundle matters because the CLI resolves relative imports and view npm deps
10
+ * where node_modules exists: two different executable artifacts built from
11
+ * the same entry source must never compare identical. `last_writer` is
12
+ * provenance of the last write, not content: including it would defeat no-op
13
+ * detection, since every apply run mints a new apply_id.
14
+ *
15
+ * Canonicalization: `source` verbatim; metadata via `stableStringify`
16
+ * (object keys sorted, arrays in order); the artifact as the full hex
17
+ * sha256 of its UTF-8 bytes. Same bytes on either path (a CLI-supplied
18
+ * `compiled_code` or a server-side compilation) converge on the same
19
+ * identity; byte-identical source/metadata/artifact and retained source stays a no-op.
20
+ */
21
+ /** Deterministic JSON for hashing: object keys sorted, arrays kept in order. */
22
+ export declare function stableStringify(value: unknown): string;
23
+ /** Declared metadata that affects the stored view (everything but provenance). */
24
+ export interface ViewContentMetadata {
25
+ name: string;
26
+ description: string;
27
+ attach: unknown;
28
+ params: unknown;
29
+ actions: unknown;
30
+ }
31
+ /**
32
+ * sha256 of the source plus the declared metadata plus the compiled
33
+ * artifact's digest and retained files/dependencies, first 16 hex. Identical
34
+ * source, metadata, bundle and retained source means nothing is written.
35
+ */
36
+ export declare function contentHash(source: string, metadata: ViewContentMetadata, compiledCode: string, retainedSource?: RetainedSource): string;
37
+ //# sourceMappingURL=view-content-hash.d.ts.map
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.stableStringify = stableStringify;
4
+ exports.contentHash = contentHash;
5
+ const node_crypto_1 = require("node:crypto");
6
+ /**
7
+ * Content identity for Lobu views, shared by the server (compile-at-save)
8
+ * and the CLI (diff-before-apply): ONE function derives the key on both
9
+ * sides, never read off whatever carried it. The hash covers the source, the
10
+ * declared metadata that affects the stored row (name, description, attach,
11
+ * params, actions), the retained files and dependencies when present, AND
12
+ * the digest of the executable browser bundle. The
13
+ * bundle matters because the CLI resolves relative imports and view npm deps
14
+ * where node_modules exists: two different executable artifacts built from
15
+ * the same entry source must never compare identical. `last_writer` is
16
+ * provenance of the last write, not content: including it would defeat no-op
17
+ * detection, since every apply run mints a new apply_id.
18
+ *
19
+ * Canonicalization: `source` verbatim; metadata via `stableStringify`
20
+ * (object keys sorted, arrays in order); the artifact as the full hex
21
+ * sha256 of its UTF-8 bytes. Same bytes on either path (a CLI-supplied
22
+ * `compiled_code` or a server-side compilation) converge on the same
23
+ * identity; byte-identical source/metadata/artifact and retained source stays a no-op.
24
+ */
25
+ /** Deterministic JSON for hashing: object keys sorted, arrays kept in order. */
26
+ function stableStringify(value) {
27
+ if (value === null || value === undefined)
28
+ return "null";
29
+ if (Array.isArray(value))
30
+ return `[${value.map(stableStringify).join(",")}]`;
31
+ if (typeof value === "object") {
32
+ const entries = Object.entries(value)
33
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
34
+ .map(([k, v]) => `${JSON.stringify(k)}:${stableStringify(v)}`);
35
+ return `{${entries.join(",")}}`;
36
+ }
37
+ return JSON.stringify(value) ?? "null";
38
+ }
39
+ /**
40
+ * sha256 of the source plus the declared metadata plus the compiled
41
+ * artifact's digest and retained files/dependencies, first 16 hex. Identical
42
+ * source, metadata, bundle and retained source means nothing is written.
43
+ */
44
+ function contentHash(source, metadata, compiledCode, retainedSource) {
45
+ const artifactDigest = (0, node_crypto_1.createHash)("sha256")
46
+ .update(compiledCode, "utf8")
47
+ .digest("hex");
48
+ const hash = (0, node_crypto_1.createHash)("sha256")
49
+ .update(source)
50
+ .update("\n")
51
+ .update(stableStringify(metadata ?? null))
52
+ .update("\n")
53
+ .update(artifactDigest);
54
+ if (retainedSource)
55
+ hash.update("\n").update(stableStringify(retainedSource));
56
+ return hash.digest("hex").slice(0, 16);
57
+ }
58
+ //# sourceMappingURL=view-content-hash.js.map
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Where a view lives in the web host's URL space. A view is selected by path,
3
+ * never by a query key, so the page's query string is the view's params alone
4
+ * and can never collide with the host's own keys (filters, peek, paging):
5
+ *
6
+ * /<org>/data/-/views/<key> workspace view (Data hub tab)
7
+ * /<org>/<type>/-/views/<key> view attached to a type
8
+ * /<org>/<type>/<slug>/-/views/<key> view attached to a record
9
+ *
10
+ * `-` marks where the host's path ends. It is reserved as a slug: entity-type
11
+ * create rejects it (RESERVED_ENTITY_TYPE_SLUGS) and so does a record's
12
+ * explicit slug, and a derived record slug never is one (slugify trims dashes). The server's `open_view` links and the web host's tabs both build
13
+ * the suffix here, so the two cannot drift apart.
14
+ */
15
+ export declare const VIEW_PATH_MARKER = "-";
16
+ /** The suffix that selects view `key` beneath a host page's path. */
17
+ export declare function viewPathSuffix(key: string): string;
18
+ //# sourceMappingURL=view-path.d.ts.map
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VIEW_PATH_MARKER = void 0;
4
+ exports.viewPathSuffix = viewPathSuffix;
5
+ /**
6
+ * Where a view lives in the web host's URL space. A view is selected by path,
7
+ * never by a query key, so the page's query string is the view's params alone
8
+ * and can never collide with the host's own keys (filters, peek, paging):
9
+ *
10
+ * /<org>/data/-/views/<key> workspace view (Data hub tab)
11
+ * /<org>/<type>/-/views/<key> view attached to a type
12
+ * /<org>/<type>/<slug>/-/views/<key> view attached to a record
13
+ *
14
+ * `-` marks where the host's path ends. It is reserved as a slug: entity-type
15
+ * create rejects it (RESERVED_ENTITY_TYPE_SLUGS) and so does a record's
16
+ * explicit slug, and a derived record slug never is one (slugify trims dashes). The server's `open_view` links and the web host's tabs both build
17
+ * the suffix here, so the two cannot drift apart.
18
+ */
19
+ exports.VIEW_PATH_MARKER = "-";
20
+ /** The suffix that selects view `key` beneath a host page's path. */
21
+ function viewPathSuffix(key) {
22
+ return `/${exports.VIEW_PATH_MARKER}/views/${key}`;
23
+ }
24
+ //# sourceMappingURL=view-path.js.map