@lobu/runtime-device 20.1.0 → 21.0.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 (121) hide show
  1. package/dist/component.json +1 -1
  2. package/dist/dependencies.bun.lock +46 -40
  3. package/npm-shrinkwrap.json +283 -237
  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 -75
  7. package/vendor/cli/dist/commands/_lib/apply/client.d.ts +40 -25
  8. package/vendor/cli/dist/commands/_lib/apply/client.js +31 -39
  9. package/vendor/cli/dist/commands/_lib/apply/deployment.d.ts +1 -1
  10. package/vendor/cli/dist/commands/_lib/apply/deployment.js +2 -2
  11. package/vendor/cli/dist/commands/_lib/apply/desired-state.d.ts +47 -11
  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 -6
  14. package/vendor/cli/dist/commands/_lib/apply/diff.js +42 -23
  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 +207 -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/login.js +3 -0
  31. package/vendor/cli/dist/config/define.d.ts +25 -8
  32. package/vendor/cli/dist/config/define.js +24 -0
  33. package/vendor/cli/dist/connectors/README.md +15 -16
  34. package/vendor/cli/dist/connectors/chat-user-identity.ts +41 -0
  35. package/vendor/cli/dist/connectors/github.ts +15 -9
  36. package/vendor/cli/dist/connectors/google-identity.ts +11 -0
  37. package/vendor/cli/dist/connectors/google_calendar.ts +21 -31
  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 +62 -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 +8 -6
  46. package/vendor/cli/dist/connectors/reddit.ts +2 -2
  47. package/vendor/cli/dist/connectors/rss.ts +2 -2
  48. package/vendor/cli/dist/connectors/slack-identity.ts +19 -0
  49. package/vendor/cli/dist/connectors/whatsapp_web.ts +5 -4
  50. package/vendor/cli/dist/connectors/x.ts +32 -17
  51. package/vendor/cli/dist/connectors/youtube.ts +18 -5
  52. package/vendor/cli/dist/internal/connector-compiler.d.ts +1 -1
  53. package/vendor/cli/dist/internal/connector-compiler.js +216 -17
  54. package/vendor/cli/dist/internal/credentials.js +5 -1
  55. package/vendor/cli/dist/internal/oauth.d.ts +15 -1
  56. package/vendor/cli/dist/internal/oauth.js +9 -1
  57. package/vendor/cli/dist/runtime-components.json +4 -4
  58. package/vendor/cli/package.json +2 -1
  59. package/vendor/connector-sdk/dist/connector-runtime.d.ts +4 -6
  60. package/vendor/connector-sdk/dist/connector-runtime.js +3 -5
  61. package/vendor/connector-sdk/dist/connector-types.d.ts +28 -13
  62. package/vendor/connector-sdk/dist/define-connector.d.ts +4 -1
  63. package/vendor/connector-sdk/dist/define-connector.js +4 -1
  64. package/vendor/connector-sdk/dist/http-client.d.ts +18 -7
  65. package/vendor/connector-sdk/dist/http-client.js +15 -13
  66. package/vendor/connector-sdk/dist/index.d.ts +1 -1
  67. package/vendor/connector-sdk/dist/retry.d.ts +15 -3
  68. package/vendor/connector-sdk/dist/retry.js +40 -64
  69. package/vendor/connector-sdk/package.json +1 -1
  70. package/vendor/connector-worker/dist/agent-turn/guest-entry.js +122 -10
  71. package/vendor/connector-worker/dist/agent-turn/guest.bundle.js +78 -10
  72. package/vendor/connector-worker/dist/agent-turn/types.d.ts +34 -4
  73. package/vendor/connector-worker/dist/compile/index.d.ts +21 -2
  74. package/vendor/connector-worker/dist/compile/index.js +41 -8
  75. package/vendor/connector-worker/dist/compile/source-capture.d.ts +10 -0
  76. package/vendor/connector-worker/dist/compile/source-capture.js +108 -0
  77. package/vendor/connector-worker/dist/daemon/agent-turn.js +97 -10
  78. package/vendor/connector-worker/dist/daemon/automation-process.d.ts +32 -0
  79. package/vendor/connector-worker/dist/daemon/automation-process.js +102 -1
  80. package/vendor/connector-worker/dist/daemon/automation.d.ts +1 -1
  81. package/vendor/connector-worker/dist/daemon/builtins/index.js +8 -0
  82. package/vendor/connector-worker/dist/daemon/builtins/os-shell.d.ts +13 -1
  83. package/vendor/connector-worker/dist/daemon/builtins/os-shell.js +28 -2
  84. package/vendor/connector-worker/dist/daemon/executor.d.ts +0 -1
  85. package/vendor/connector-worker/dist/daemon/executor.js +42 -51
  86. package/vendor/connector-worker/dist/daemon/start.js +5 -1
  87. package/vendor/connector-worker/dist/executor/interface.d.ts +12 -8
  88. package/vendor/connector-worker/dist/executor/isolate.js +45 -28
  89. package/vendor/connector-worker/dist/self-check/index.js +15 -13
  90. package/vendor/connector-worker/package.json +1 -1
  91. package/vendor/core/dist/agent-policy.js +3 -0
  92. package/vendor/core/dist/connector-query-errors.d.ts +3 -3
  93. package/vendor/core/dist/connector-query-errors.js +8 -3
  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-feeds.d.ts +11 -0
  99. package/vendor/core/dist/contracts/tools/manage-feeds.js +12 -1
  100. package/vendor/core/dist/contracts/tools/manage-operations.d.ts +47 -6
  101. package/vendor/core/dist/contracts/tools/manage-operations.js +36 -1
  102. package/vendor/core/dist/contracts/tools/manage-views.d.ts +293 -0
  103. package/vendor/core/dist/contracts/tools/manage-views.js +203 -0
  104. package/vendor/core/dist/contracts/tools/source-files-schema.d.ts +7 -0
  105. package/vendor/core/dist/contracts/tools/source-files-schema.js +19 -0
  106. package/vendor/core/dist/contracts/tools/source-files.d.ts +14 -0
  107. package/vendor/core/dist/contracts/tools/source-files.js +55 -0
  108. package/vendor/core/dist/contracts/tools/view-content-hash.d.ts +37 -0
  109. package/vendor/core/dist/contracts/tools/view-content-hash.js +58 -0
  110. package/vendor/core/dist/contracts/tools/view-path.d.ts +18 -0
  111. package/vendor/core/dist/contracts/tools/view-path.js +24 -0
  112. package/vendor/core/dist/contracts/worker/protocol.d.ts +73 -8
  113. package/vendor/core/dist/contracts/worker/protocol.js +58 -9
  114. package/vendor/core/dist/credentials.d.ts +16 -1
  115. package/vendor/core/dist/credentials.js +10 -1
  116. package/vendor/core/dist/reserved.d.ts +3 -3
  117. package/vendor/core/dist/reserved.js +9 -1
  118. package/vendor/core/dist/utils/secret-redaction.js +2 -0
  119. package/vendor/core/package.json +25 -5
  120. package/vendor/core/dist/contracts/tools/manage-view-templates.d.ts +0 -165
  121. 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,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
@@ -1080,6 +1080,7 @@ export declare const CompleteRequestSchema: import("@sinclair/typebox").TObject<
1080
1080
  worker_id: import("@sinclair/typebox").TString;
1081
1081
  checkpoint: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
1082
1082
  items_collected: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
1083
+ more: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
1083
1084
  auth_update: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TRecord<import("@sinclair/typebox").TString, import("@sinclair/typebox").TUnknown>>;
1084
1085
  output_tail: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
1085
1086
  exit_code: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TUnion<[import("@sinclair/typebox").TInteger, import("@sinclair/typebox").TNull]>>;
@@ -1196,13 +1197,21 @@ export declare const TURN_TOOL_OUTPUT_MAX_CHARS = 2000;
1196
1197
  * The server renders this into the established `tool_use` custom event, so the
1197
1198
  * SPA, promptfoo provider and menubar keep one tool-trace shape.
1198
1199
  *
1199
- * Best-effort like the delta it rides with, and for the same reason: a tool
1200
- * trace is a VIEW of the turn, never the turn's answer, so a dropped one costs
1201
- * visibility and nothing else.
1200
+ * Mandatory external-effect evidence. The worker retains each trace until the
1201
+ * server explicitly acknowledges durable storage; capacity overflow fails the
1202
+ * turn honestly rather than dropping evidence.
1202
1203
  */
1203
1204
  export declare const TurnToolEventSchema: import("@sinclair/typebox").TObject<{
1204
1205
  tool_call_id: import("@sinclair/typebox").TString;
1205
1206
  name: import("@sinclair/typebox").TString;
1207
+ /**
1208
+ * The accepted input run this call was started for, so a result that lands
1209
+ * after a mid-turn follow-up stays attributed to the message that initiated
1210
+ * it rather than to whichever input is active when it finishes. Absent on
1211
+ * traces from workers that predate per-input attribution; the completion
1212
+ * route then attributes them to the owning input.
1213
+ */
1214
+ input_run_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
1206
1215
  /**
1207
1216
  * The call's arguments, as the model sent them. The SPA renders `input` as
1208
1217
  * the tool row's args. Absent when the start of the call was not observed.
@@ -1228,12 +1237,14 @@ export declare const TurnToolEventSchema: import("@sinclair/typebox").TObject<{
1228
1237
  * How many finished tool traces a turn holds at once, on the worker's queue and
1229
1238
  * as the bound on the completion body's trailing batch.
1230
1239
  *
1231
- * One definition because it is now both: the worker drops the oldest past this
1232
- * cap, and the completion route rejects a body that exceeds it. A trace is a
1233
- * view of the turn, so a turn that spends its budget on tool calls sheds the
1234
- * oldest rather than growing an unbounded queue or an unbounded request.
1240
+ * One definition because it is now both: the worker fails the turn rather than
1241
+ * exceed this cap, and the completion route rejects a body that exceeds it. A
1242
+ * trace is mandatory external-effect evidence, so a turn that spends its budget
1243
+ * on tool calls fails honestly with its retained prefix instead of growing an
1244
+ * unbounded queue, shedding the oldest silently, or filing an unbounded
1245
+ * request.
1235
1246
  */
1236
- export declare const TURN_TOOL_EVENT_QUEUE_MAX = 20;
1247
+ export declare const TURN_TOOL_EVENT_QUEUE_MAX = 50;
1237
1248
  /** Per-execution input bound shared by repeatable offers and committed receipts. */
1238
1249
  export declare const AGENT_TURN_INPUT_MAX = 32;
1239
1250
  export declare const CompleteAgentTurnRequestSchema: import("@sinclair/typebox").TObject<{
@@ -1252,6 +1263,27 @@ export declare const CompleteAgentTurnRequestSchema: import("@sinclair/typebox")
1252
1263
  consumed_inputs: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
1253
1264
  run_id: import("@sinclair/typebox").TInteger;
1254
1265
  session_entry_id: import("@sinclair/typebox").TString;
1266
+ /**
1267
+ * This input's own answer text, not the execution's. Present on
1268
+ * receipts from workers with per-input attribution; absent on
1269
+ * receipts from older workers, which the completion route delivers
1270
+ * as one execution-wide reply (the pre-#3662 contract those claims
1271
+ * were admitted under).
1272
+ */
1273
+ response_text: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
1274
+ /**
1275
+ * The tools this input's answer actually used, in first-call order.
1276
+ * Per-input like the answer: never the execution-wide ledger, which
1277
+ * would attribute a sibling input's calls to this reply.
1278
+ */
1279
+ tools_used: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
1280
+ /**
1281
+ * The first tool error attributed to this input, quoted exactly as the
1282
+ * tool returned it. Preserved independently of how the model paraphrases
1283
+ * the failure in prose, so the durable record keeps the actionable
1284
+ * message even when the reply does not.
1285
+ */
1286
+ first_error: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
1255
1287
  }>>>;
1256
1288
  /**
1257
1289
  * Every tool this turn invoked, first-call order. Absent and `[]` are NOT
@@ -1260,6 +1292,14 @@ export declare const CompleteAgentTurnRequestSchema: import("@sinclair/typebox")
1260
1292
  * must send the array even when it called nothing.
1261
1293
  */
1262
1294
  tools_used: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TString>>;
1295
+ /**
1296
+ * The owner input's first tool error, quoted exactly as the tool returned
1297
+ * it. Steered inputs carry theirs on their `consumed_inputs` receipts, so
1298
+ * every terminal reply is stamped with its own input's failure rather than
1299
+ * the execution-wide first one. Preserved independently of how the model
1300
+ * paraphrases the failure in prose.
1301
+ */
1302
+ first_error: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TString>;
1263
1303
  /**
1264
1304
  * The turn already posted its answer INTO the conversation it is replying to,
1265
1305
  * through the `send_message`/`present_event` conversation tool. The user has
@@ -1287,6 +1327,14 @@ export declare const CompleteAgentTurnRequestSchema: import("@sinclair/typebox")
1287
1327
  turn_tool_events: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
1288
1328
  tool_call_id: import("@sinclair/typebox").TString;
1289
1329
  name: import("@sinclair/typebox").TString;
1330
+ /**
1331
+ * The accepted input run this call was started for, so a result that lands
1332
+ * after a mid-turn follow-up stays attributed to the message that initiated
1333
+ * it rather than to whichever input is active when it finishes. Absent on
1334
+ * traces from workers that predate per-input attribution; the completion
1335
+ * route then attributes them to the owning input.
1336
+ */
1337
+ input_run_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
1290
1338
  /**
1291
1339
  * The call's arguments, as the model sent them. The SPA renders `input` as
1292
1340
  * the tool row's args. Absent when the start of the call was not observed.
@@ -1422,6 +1470,14 @@ export declare const HeartbeatRequestSchema: import("@sinclair/typebox").TObject
1422
1470
  turn_tool_events: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TArray<import("@sinclair/typebox").TObject<{
1423
1471
  tool_call_id: import("@sinclair/typebox").TString;
1424
1472
  name: import("@sinclair/typebox").TString;
1473
+ /**
1474
+ * The accepted input run this call was started for, so a result that lands
1475
+ * after a mid-turn follow-up stays attributed to the message that initiated
1476
+ * it rather than to whichever input is active when it finishes. Absent on
1477
+ * traces from workers that predate per-input attribution; the completion
1478
+ * route then attributes them to the owning input.
1479
+ */
1480
+ input_run_id: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TInteger>;
1425
1481
  /**
1426
1482
  * The call's arguments, as the model sent them. The SPA renders `input` as
1427
1483
  * the tool row's args. Absent when the start of the call was not observed.
@@ -1526,6 +1582,12 @@ export type AgentTurnToolEvent = Static<typeof TurnToolEventSchema>;
1526
1582
  * already passed acknowledges without publishing, and the worker retires the
1527
1583
  * batch — there is nothing more it can do about it. Only the ABSENCE of an ack
1528
1584
  * keeps the text queued.
1585
+ *
1586
+ * `turn_tool_ack` is the same honesty for the tool traces that rode the beat:
1587
+ * `received` names how many of the sent traces the server durably stored. The
1588
+ * worker retires only that prefix and re-sends the rest. A liveness-only beat
1589
+ * carries no ack and acknowledges nothing; only its absence keeps evidence
1590
+ * queued.
1529
1591
  */
1530
1592
  export declare const HeartbeatResponseSchema: import("@sinclair/typebox").TObject<{
1531
1593
  continue: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TBoolean>;
@@ -1555,6 +1617,9 @@ export declare const HeartbeatResponseSchema: import("@sinclair/typebox").TObjec
1555
1617
  sequence: import("@sinclair/typebox").TInteger;
1556
1618
  published: import("@sinclair/typebox").TBoolean;
1557
1619
  }>>;
1620
+ turn_tool_ack: import("@sinclair/typebox").TOptional<import("@sinclair/typebox").TObject<{
1621
+ received: import("@sinclair/typebox").TInteger;
1622
+ }>>;
1558
1623
  }>;
1559
1624
  export type DispatchChromeActionRequest = Static<typeof DispatchChromeActionRequestSchema>;
1560
1625
  export type DispatchChromeActionResponse = Static<typeof DispatchChromeActionResponseSchema>;