@loxtep/sdk 0.2.3 → 0.3.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 (168) hide show
  1. package/README.md +141 -0
  2. package/dist/authoring/agent.d.ts +164 -0
  3. package/dist/authoring/agent.d.ts.map +1 -0
  4. package/dist/authoring/agent.js +376 -0
  5. package/dist/authoring/agent.js.map +1 -0
  6. package/dist/authoring/compiler.d.ts +98 -0
  7. package/dist/authoring/compiler.d.ts.map +1 -0
  8. package/dist/authoring/compiler.js +156 -0
  9. package/dist/authoring/compiler.js.map +1 -0
  10. package/dist/authoring/define-data-workflow.d.ts +24 -0
  11. package/dist/authoring/define-data-workflow.d.ts.map +1 -0
  12. package/dist/authoring/define-data-workflow.js +93 -0
  13. package/dist/authoring/define-data-workflow.js.map +1 -0
  14. package/dist/authoring/index.d.ts +19 -0
  15. package/dist/authoring/index.d.ts.map +1 -0
  16. package/dist/authoring/index.js +15 -0
  17. package/dist/authoring/index.js.map +1 -0
  18. package/dist/authoring/toolbox.d.ts +133 -0
  19. package/dist/authoring/toolbox.d.ts.map +1 -0
  20. package/dist/authoring/toolbox.js +166 -0
  21. package/dist/authoring/toolbox.js.map +1 -0
  22. package/dist/authoring/triggers.d.ts +41 -0
  23. package/dist/authoring/triggers.d.ts.map +1 -0
  24. package/dist/authoring/triggers.js +60 -0
  25. package/dist/authoring/triggers.js.map +1 -0
  26. package/dist/authoring/types.d.ts +64 -0
  27. package/dist/authoring/types.d.ts.map +1 -0
  28. package/dist/authoring/types.js +9 -0
  29. package/dist/authoring/types.js.map +1 -0
  30. package/dist/cli/commands/activity-cmd.d.ts +28 -0
  31. package/dist/cli/commands/activity-cmd.d.ts.map +1 -0
  32. package/dist/cli/commands/activity-cmd.js +78 -0
  33. package/dist/cli/commands/activity-cmd.js.map +1 -0
  34. package/dist/cli/commands/attach-cmd.d.ts +38 -0
  35. package/dist/cli/commands/attach-cmd.d.ts.map +1 -0
  36. package/dist/cli/commands/attach-cmd.js +141 -0
  37. package/dist/cli/commands/attach-cmd.js.map +1 -0
  38. package/dist/cli/commands/deploy-cmd.d.ts +101 -0
  39. package/dist/cli/commands/deploy-cmd.d.ts.map +1 -0
  40. package/dist/cli/commands/deploy-cmd.js +461 -0
  41. package/dist/cli/commands/deploy-cmd.js.map +1 -0
  42. package/dist/cli/commands/generate-cmd.d.ts +35 -0
  43. package/dist/cli/commands/generate-cmd.d.ts.map +1 -0
  44. package/dist/cli/commands/generate-cmd.js +134 -0
  45. package/dist/cli/commands/generate-cmd.js.map +1 -0
  46. package/dist/cli/commands/improvements-cmd.d.ts +44 -0
  47. package/dist/cli/commands/improvements-cmd.d.ts.map +1 -0
  48. package/dist/cli/commands/improvements-cmd.js +215 -0
  49. package/dist/cli/commands/improvements-cmd.js.map +1 -0
  50. package/dist/cli/commands/init-cmd.d.ts +78 -0
  51. package/dist/cli/commands/init-cmd.d.ts.map +1 -0
  52. package/dist/cli/commands/init-cmd.js +250 -0
  53. package/dist/cli/commands/init-cmd.js.map +1 -0
  54. package/dist/cli/commands/test-cmd.d.ts +89 -0
  55. package/dist/cli/commands/test-cmd.d.ts.map +1 -0
  56. package/dist/cli/commands/test-cmd.js +378 -0
  57. package/dist/cli/commands/test-cmd.js.map +1 -0
  58. package/dist/cli/index.d.ts +1 -1
  59. package/dist/cli/index.js +146 -4
  60. package/dist/cli/index.js.map +1 -1
  61. package/dist/cli/project-context.d.ts +153 -0
  62. package/dist/cli/project-context.d.ts.map +1 -0
  63. package/dist/cli/project-context.js +190 -0
  64. package/dist/cli/project-context.js.map +1 -0
  65. package/dist/client/activity-types.d.ts +66 -0
  66. package/dist/client/activity-types.d.ts.map +1 -0
  67. package/dist/client/activity-types.js +9 -0
  68. package/dist/client/activity-types.js.map +1 -0
  69. package/dist/client/activity.d.ts +22 -0
  70. package/dist/client/activity.d.ts.map +1 -0
  71. package/dist/client/activity.js +43 -0
  72. package/dist/client/activity.js.map +1 -0
  73. package/dist/client/data-products.d.ts.map +1 -1
  74. package/dist/client/data-products.js +4 -98
  75. package/dist/client/data-products.js.map +1 -1
  76. package/dist/client/flow-types.d.ts +4 -2
  77. package/dist/client/flow-types.d.ts.map +1 -1
  78. package/dist/client/flows.d.ts +1 -1
  79. package/dist/client/flows.d.ts.map +1 -1
  80. package/dist/client/flows.js +49 -124
  81. package/dist/client/flows.js.map +1 -1
  82. package/dist/client/improvements-types.d.ts +55 -0
  83. package/dist/client/improvements-types.d.ts.map +1 -0
  84. package/dist/client/improvements-types.js +9 -0
  85. package/dist/client/improvements-types.js.map +1 -0
  86. package/dist/client/improvements.d.ts +29 -0
  87. package/dist/client/improvements.d.ts.map +1 -0
  88. package/dist/client/improvements.js +50 -0
  89. package/dist/client/improvements.js.map +1 -0
  90. package/dist/client/index.d.ts +6 -2
  91. package/dist/client/index.d.ts.map +1 -1
  92. package/dist/client/index.js.map +1 -1
  93. package/dist/client/loxtep-client.d.ts +45 -0
  94. package/dist/client/loxtep-client.d.ts.map +1 -1
  95. package/dist/client/loxtep-client.js +68 -0
  96. package/dist/client/loxtep-client.js.map +1 -1
  97. package/dist/client/projects-types.d.ts +25 -0
  98. package/dist/client/projects-types.d.ts.map +1 -1
  99. package/dist/client/projects.d.ts +2 -1
  100. package/dist/client/projects.d.ts.map +1 -1
  101. package/dist/client/projects.js +17 -0
  102. package/dist/client/projects.js.map +1 -1
  103. package/dist/client/queue-types.d.ts +15 -2
  104. package/dist/client/queue-types.d.ts.map +1 -1
  105. package/dist/client/queues.d.ts.map +1 -1
  106. package/dist/client/queues.js +3 -14
  107. package/dist/client/queues.js.map +1 -1
  108. package/dist/codegen/emit.d.ts +25 -0
  109. package/dist/codegen/emit.d.ts.map +1 -0
  110. package/dist/codegen/emit.js +158 -0
  111. package/dist/codegen/emit.js.map +1 -0
  112. package/dist/codegen/index.d.ts +17 -0
  113. package/dist/codegen/index.d.ts.map +1 -0
  114. package/dist/codegen/index.js +16 -0
  115. package/dist/codegen/index.js.map +1 -0
  116. package/dist/codegen/load-workspace-context.d.ts +30 -0
  117. package/dist/codegen/load-workspace-context.d.ts.map +1 -0
  118. package/dist/codegen/load-workspace-context.js +127 -0
  119. package/dist/codegen/load-workspace-context.js.map +1 -0
  120. package/dist/codegen/normalize.d.ts +35 -0
  121. package/dist/codegen/normalize.d.ts.map +1 -0
  122. package/dist/codegen/normalize.js +77 -0
  123. package/dist/codegen/normalize.js.map +1 -0
  124. package/dist/codegen/types.d.ts +89 -0
  125. package/dist/codegen/types.d.ts.map +1 -0
  126. package/dist/codegen/types.js +9 -0
  127. package/dist/codegen/types.js.map +1 -0
  128. package/dist/codegen/write-artifact.d.ts +40 -0
  129. package/dist/codegen/write-artifact.d.ts.map +1 -0
  130. package/dist/codegen/write-artifact.js +74 -0
  131. package/dist/codegen/write-artifact.js.map +1 -0
  132. package/dist/config/index.d.ts +1 -0
  133. package/dist/config/index.d.ts.map +1 -1
  134. package/dist/config/index.js +1 -0
  135. package/dist/config/index.js.map +1 -1
  136. package/dist/config/workspace-config.d.ts +76 -0
  137. package/dist/config/workspace-config.d.ts.map +1 -0
  138. package/dist/config/workspace-config.js +129 -0
  139. package/dist/config/workspace-config.js.map +1 -0
  140. package/dist/index.d.ts +3 -0
  141. package/dist/index.d.ts.map +1 -1
  142. package/dist/index.js +3 -0
  143. package/dist/index.js.map +1 -1
  144. package/dist/rstreams/event-bridge.d.ts +16 -2
  145. package/dist/rstreams/event-bridge.d.ts.map +1 -1
  146. package/dist/rstreams/event-bridge.js +38 -5
  147. package/dist/rstreams/event-bridge.js.map +1 -1
  148. package/dist/skills/check-scope.d.ts +42 -0
  149. package/dist/skills/check-scope.d.ts.map +1 -0
  150. package/dist/skills/check-scope.js +84 -0
  151. package/dist/skills/check-scope.js.map +1 -0
  152. package/dist/skills/index.d.ts +14 -0
  153. package/dist/skills/index.d.ts.map +1 -0
  154. package/dist/skills/index.js +12 -0
  155. package/dist/skills/index.js.map +1 -0
  156. package/dist/skills/loader.d.ts +79 -0
  157. package/dist/skills/loader.d.ts.map +1 -0
  158. package/dist/skills/loader.js +102 -0
  159. package/dist/skills/loader.js.map +1 -0
  160. package/dist/skills/types.d.ts +55 -0
  161. package/dist/skills/types.d.ts.map +1 -0
  162. package/dist/skills/types.js +9 -0
  163. package/dist/skills/types.js.map +1 -0
  164. package/dist/skills/validate-references.d.ts +54 -0
  165. package/dist/skills/validate-references.d.ts.map +1 -0
  166. package/dist/skills/validate-references.js +80 -0
  167. package/dist/skills/validate-references.js.map +1 -0
  168. package/package.json +5 -3
@@ -0,0 +1,376 @@
1
+ /**
2
+ * `agent()` entry point — agentic operations with input validation,
3
+ * client-side scope enforcement, and action trace recording.
4
+ *
5
+ * The agentic path accepts a prompt and a skills allowlist, validates inputs,
6
+ * enforces scope boundaries before any platform call, and records every
7
+ * operation as an ordered ActionTraceEntry.
8
+ *
9
+ * Requirements: 4.2, 4.3, 4.4, 4.5, 4.6, 7.1
10
+ */
11
+ import { ValidationError } from '../errors/index.js';
12
+ import { LoxtepError } from '../errors/base.js';
13
+ import { checkScope } from '../skills/check-scope.js';
14
+ // ─── Validation ──────────────────────────────────────────────────────────────
15
+ /** Minimum prompt length. */
16
+ const PROMPT_MIN_LENGTH = 1;
17
+ /** Maximum prompt length. */
18
+ const PROMPT_MAX_LENGTH = 10_000;
19
+ /** Minimum skills count. */
20
+ const SKILLS_MIN_COUNT = 1;
21
+ /** Maximum skills count. */
22
+ const SKILLS_MAX_COUNT = 50;
23
+ /**
24
+ * Validate the agent options (prompt + skills).
25
+ * Throws ValidationError on invalid input (R4.6).
26
+ *
27
+ * @param options - The agent options to validate.
28
+ * @param availableSkillNames - Set of skill names present in the generated artifact.
29
+ */
30
+ export function validateAgentOptions(options, availableSkillNames) {
31
+ const errors = [];
32
+ // Validate prompt (1–10,000 characters, non-empty)
33
+ if (typeof options.prompt !== 'string') {
34
+ errors.push({
35
+ field: 'prompt',
36
+ message: `prompt must be a string, got ${typeof options.prompt}`,
37
+ });
38
+ }
39
+ else if (options.prompt.length < PROMPT_MIN_LENGTH) {
40
+ errors.push({
41
+ field: 'prompt',
42
+ message: `prompt must be between 1 and 10,000 characters, got 0`,
43
+ });
44
+ }
45
+ else if (options.prompt.length > PROMPT_MAX_LENGTH) {
46
+ errors.push({
47
+ field: 'prompt',
48
+ message: `prompt must be between 1 and 10,000 characters, got ${options.prompt.length}`,
49
+ });
50
+ }
51
+ // Validate skills (1–50 refs)
52
+ if (!Array.isArray(options.skills)) {
53
+ errors.push({
54
+ field: 'skills',
55
+ message: `skills must be an array, got ${typeof options.skills}`,
56
+ });
57
+ }
58
+ else if (options.skills.length < SKILLS_MIN_COUNT) {
59
+ errors.push({
60
+ field: 'skills',
61
+ message: `skills must contain between 1 and 50 entries, got 0`,
62
+ });
63
+ }
64
+ else if (options.skills.length > SKILLS_MAX_COUNT) {
65
+ errors.push({
66
+ field: 'skills',
67
+ message: `skills must contain between 1 and 50 entries, got ${options.skills.length}`,
68
+ });
69
+ }
70
+ else {
71
+ // Check each skill ref is present in the generated artifact
72
+ for (let i = 0; i < options.skills.length; i++) {
73
+ const skillRef = options.skills[i];
74
+ if (!skillRef || typeof skillRef.name !== 'string' || skillRef.name.length === 0) {
75
+ errors.push({
76
+ field: 'skills',
77
+ message: `skills[${i}] must have a non-empty name`,
78
+ });
79
+ }
80
+ else if (!availableSkillNames.has(skillRef.name)) {
81
+ errors.push({
82
+ field: 'skills',
83
+ message: `skills[${i}] references skill "${skillRef.name}" which is not present in the generated artifact`,
84
+ });
85
+ }
86
+ }
87
+ }
88
+ if (errors.length > 0) {
89
+ const message = errors.map((e) => `${e.field}: ${e.message}`).join('; ');
90
+ throw new ValidationError(`Invalid agent() options: ${message}`, errors);
91
+ }
92
+ }
93
+ // ─── Scope enforcement ───────────────────────────────────────────────────────
94
+ /**
95
+ * Compute the union of all resource scopes from the supplied skill definitions.
96
+ * The reachable set is the union of all skills' scopes (R4.3).
97
+ *
98
+ * @param skills - The skill definitions to union.
99
+ * @returns A merged SkillScope representing all reachable resources.
100
+ */
101
+ export function computeReachableScope(skills) {
102
+ const mergedScope = {
103
+ data_products: [],
104
+ connectors: [],
105
+ workflows: [],
106
+ domains: [],
107
+ queues: [],
108
+ };
109
+ const mergedPermissions = {
110
+ data_products: new Set(),
111
+ connectors: new Set(),
112
+ workflows: new Set(),
113
+ domains: new Set(),
114
+ queues: new Set(),
115
+ };
116
+ for (const skill of skills) {
117
+ // Merge scope entries
118
+ for (const key of Object.keys(mergedScope)) {
119
+ const entries = skill.scope[key];
120
+ if (entries) {
121
+ for (const entry of entries) {
122
+ if (!mergedScope[key].includes(entry)) {
123
+ mergedScope[key].push(entry);
124
+ }
125
+ }
126
+ }
127
+ }
128
+ // Merge permissions
129
+ for (const key of Object.keys(mergedPermissions)) {
130
+ const ops = skill.permissions[key];
131
+ if (ops) {
132
+ for (const op of ops) {
133
+ mergedPermissions[key].add(op);
134
+ }
135
+ }
136
+ }
137
+ }
138
+ // Convert Sets back to arrays
139
+ const permissions = {};
140
+ for (const key of Object.keys(mergedPermissions)) {
141
+ const ops = mergedPermissions[key];
142
+ if (ops.size > 0) {
143
+ permissions[key] = Array.from(ops);
144
+ }
145
+ }
146
+ return {
147
+ name: '__agent_merged_scope__',
148
+ scope: mergedScope,
149
+ permissions,
150
+ };
151
+ }
152
+ /**
153
+ * Check whether a resource access is within the merged scope of the agent's skills.
154
+ * Blocks out-of-scope reaches before any platform call (R4.4).
155
+ *
156
+ * @param mergedSkill - The merged skill scope (union of all supplied skills).
157
+ * @param resourceType - The resource type being accessed.
158
+ * @param resourceId - The resource identifier being accessed.
159
+ * @param operation - The operation being attempted.
160
+ * @returns The scope decision.
161
+ */
162
+ export function enforceAgentScope(mergedSkill, resourceType, resourceId, operation) {
163
+ return checkScope(mergedSkill, resourceType, resourceId, operation);
164
+ }
165
+ // ─── Action trace ────────────────────────────────────────────────────────────
166
+ /**
167
+ * Mutable action trace recorder. Assigns monotonically increasing sequence
168
+ * numbers to each entry (R4.5, R7.1).
169
+ */
170
+ export class ActionTrace {
171
+ entries = [];
172
+ seq = 0;
173
+ /**
174
+ * Record a completed operation in the trace.
175
+ */
176
+ record(entry) {
177
+ this.seq += 1;
178
+ const fullEntry = { seq: this.seq, ...entry };
179
+ this.entries.push(fullEntry);
180
+ return fullEntry;
181
+ }
182
+ /**
183
+ * Get all recorded entries in order.
184
+ */
185
+ getEntries() {
186
+ return [...this.entries];
187
+ }
188
+ /**
189
+ * Get the current sequence number (number of recorded entries).
190
+ */
191
+ getSeq() {
192
+ return this.seq;
193
+ }
194
+ }
195
+ // ─── Agent entry point ───────────────────────────────────────────────────────
196
+ /**
197
+ * Error thrown when an agentic operation is blocked due to a scope violation.
198
+ */
199
+ export class AgentScopeError extends LoxtepError {
200
+ deniedResource;
201
+ constructor(deniedResource, code, message) {
202
+ super(message, {
203
+ code,
204
+ status_code: 403,
205
+ details: { deniedResource },
206
+ });
207
+ this.name = 'AgentScopeError';
208
+ this.deniedResource = deniedResource;
209
+ Object.setPrototypeOf(this, AgentScopeError.prototype);
210
+ }
211
+ }
212
+ /**
213
+ * The `agent()` entry point for agentic operations within a data workflow handler.
214
+ *
215
+ * Validates inputs (R4.6), restricts the model to the supplied skills (R4.3),
216
+ * blocks out-of-scope reaches before any platform call (R4.4), and records
217
+ * every operation in an ordered action trace (R4.5, R7.1).
218
+ *
219
+ * @param ctx - Handler context (workflow name, instance, project).
220
+ * @param options - Agent options (prompt + skills allowlist).
221
+ * @param execContext - Execution context with resolved skills + toolbox.
222
+ * @returns The agent result including the action trace.
223
+ * @throws {ValidationError} If prompt or skills are invalid (R4.6).
224
+ */
225
+ export async function agent(ctx, options, execContext) {
226
+ const { availableSkillNames, skillDefinitions, toolbox } = execContext;
227
+ const trace = new ActionTrace();
228
+ // Step 1: Input validation (R4.6)
229
+ // Throws ValidationError on invalid input — no model invoked.
230
+ validateAgentOptions(options, availableSkillNames);
231
+ // Step 2: Compute the reachable scope — union of all supplied skill scopes (R4.3)
232
+ const mergedSkill = computeReachableScope(skillDefinitions);
233
+ // Step 3: Record scope computation as a trace entry
234
+ const scopeStartedAt = new Date().toISOString();
235
+ trace.record({
236
+ kind: 'scope_check',
237
+ operationName: 'compute_reachable_scope',
238
+ startedAt: scopeStartedAt,
239
+ completedAt: new Date().toISOString(),
240
+ outcome: 'succeeded',
241
+ });
242
+ // Step 4: Create a scope-guarded toolbox proxy that checks scope before
243
+ // every platform call and records trace entries (R4.4, R4.5)
244
+ const guardedToolbox = createScopeGuardedToolbox(toolbox, mergedSkill, trace);
245
+ // Return the agent result with the trace and the scope-guarded toolbox.
246
+ // The actual model invocation is out of scope for this implementation —
247
+ // the model loop would use `guardedToolbox` for platform calls,
248
+ // ensuring all calls pass through scope enforcement.
249
+ return {
250
+ success: true,
251
+ trace: trace.getEntries(),
252
+ };
253
+ }
254
+ /**
255
+ * Create a scope-guarded proxy around the toolbox. Every method call goes through
256
+ * scope enforcement first; if denied, the call is blocked, a trace entry is recorded,
257
+ * and an AgentScopeError is thrown terminating the operation (R4.4).
258
+ *
259
+ * @param toolbox - The underlying toolbox.
260
+ * @param mergedSkill - The merged skill scope for enforcement.
261
+ * @param trace - The action trace to record operations.
262
+ * @returns A guarded toolbox that enforces scope and records traces.
263
+ */
264
+ export function createScopeGuardedToolbox(toolbox, mergedSkill, trace) {
265
+ /**
266
+ * Enforce scope and record the attempt. Returns the scope decision.
267
+ * If denied, records a blocked-attempt trace entry (R4.4).
268
+ */
269
+ function guardCall(resourceType, resourceId, operation, operationName) {
270
+ const startedAt = new Date().toISOString();
271
+ const decision = enforceAgentScope(mergedSkill, resourceType, resourceId, operation);
272
+ if (!decision.allowed) {
273
+ const deniedResource = 'deniedResource' in decision
274
+ ? decision.deniedResource
275
+ : 'resource' in decision
276
+ ? decision.resource
277
+ : `${resourceType}/${resourceId}`;
278
+ // Record blocked-attempt trace entry (R4.4)
279
+ trace.record({
280
+ kind: 'scope_check',
281
+ operationName: `blocked:${operationName}`,
282
+ targetResource: deniedResource,
283
+ startedAt,
284
+ completedAt: new Date().toISOString(),
285
+ outcome: 'blocked',
286
+ error: `Scope violation: ${decision.code} — ${deniedResource}`,
287
+ });
288
+ throw new AgentScopeError(deniedResource, decision.code, `Agent scope enforcement blocked ${operationName}: ${decision.code} for resource ${deniedResource}`);
289
+ }
290
+ }
291
+ /**
292
+ * Wrap a toolbox method to record it in the trace (R4.5, R7.1).
293
+ */
294
+ function wrapWithTrace(operationName, targetResource, fn) {
295
+ return async (...args) => {
296
+ const startedAt = new Date().toISOString();
297
+ try {
298
+ const result = await fn(...args);
299
+ trace.record({
300
+ kind: 'toolbox',
301
+ operationName,
302
+ targetResource,
303
+ startedAt,
304
+ completedAt: new Date().toISOString(),
305
+ outcome: 'succeeded',
306
+ });
307
+ return result;
308
+ }
309
+ catch (err) {
310
+ trace.record({
311
+ kind: 'toolbox',
312
+ operationName,
313
+ targetResource,
314
+ startedAt,
315
+ completedAt: new Date().toISOString(),
316
+ outcome: 'failed',
317
+ error: err instanceof Error ? err.message : String(err),
318
+ });
319
+ throw err;
320
+ }
321
+ };
322
+ }
323
+ return {
324
+ dataProducts: {
325
+ write(ref, event) {
326
+ guardCall('data_products', ref.name, 'write', 'dataProducts.write');
327
+ return wrapWithTrace('dataProducts.write', ref.name, () => toolbox.dataProducts.write(ref, event))();
328
+ },
329
+ query(ref, sql) {
330
+ guardCall('data_products', ref.name, 'read', 'dataProducts.query');
331
+ return wrapWithTrace('dataProducts.query', ref.name, () => toolbox.dataProducts.query(ref, sql))();
332
+ },
333
+ get(ref) {
334
+ guardCall('data_products', ref.name, 'read', 'dataProducts.get');
335
+ return wrapWithTrace('dataProducts.get', ref.name, () => toolbox.dataProducts.get(ref))();
336
+ },
337
+ list(filters) {
338
+ // list is a read on the data_products namespace generally — no specific resource
339
+ return wrapWithTrace('dataProducts.list', undefined, () => toolbox.dataProducts.list(filters))();
340
+ },
341
+ },
342
+ queues: {
343
+ write(ref, event) {
344
+ guardCall('queues', ref.name, 'write', 'queues.write');
345
+ return wrapWithTrace('queues.write', ref.name, () => toolbox.queues.write(ref, event))();
346
+ },
347
+ getMetadata(ref) {
348
+ guardCall('queues', ref.name, 'read', 'queues.getMetadata');
349
+ return wrapWithTrace('queues.getMetadata', ref.name, () => toolbox.queues.getMetadata(ref))();
350
+ },
351
+ },
352
+ connections: {
353
+ list() {
354
+ return wrapWithTrace('connections.list', undefined, () => toolbox.connections.list())();
355
+ },
356
+ get(connectionId) {
357
+ guardCall('connectors', connectionId, 'read', 'connections.get');
358
+ return wrapWithTrace('connections.get', connectionId, () => toolbox.connections.get(connectionId))();
359
+ },
360
+ test(connectionId) {
361
+ guardCall('connectors', connectionId, 'read', 'connections.test');
362
+ return wrapWithTrace('connections.test', connectionId, () => toolbox.connections.test(connectionId))();
363
+ },
364
+ },
365
+ workflows: {
366
+ list() {
367
+ return wrapWithTrace('workflows.list', undefined, () => toolbox.workflows.list())();
368
+ },
369
+ getGraph(ref) {
370
+ guardCall('workflows', ref.name, 'read', 'workflows.getGraph');
371
+ return wrapWithTrace('workflows.getGraph', ref.name, () => toolbox.workflows.getGraph(ref))();
372
+ },
373
+ },
374
+ };
375
+ }
376
+ //# sourceMappingURL=agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.js","sourceRoot":"","sources":["../../src/authoring/agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAmFtD,gFAAgF;AAEhF,6BAA6B;AAC7B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAC5B,6BAA6B;AAC7B,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,4BAA4B;AAC5B,MAAM,gBAAgB,GAAG,CAAC,CAAC;AAC3B,4BAA4B;AAC5B,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAE5B;;;;;;GAMG;AACH,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aAAa,CAAC,kBAAkB,EAAE,SAAS,EAAE,GAAG,EAAE,CACvD,OAAO,CAAC,WAAW,CAAC,IAAI,EAAE,CAC3B,EAAE,CAAC;YACN,CAAC;YACD,GAAG,CAAC,YAAY;gBACd,SAAS,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,iBAAiB,CAAC,CAAC;gBACjE,OAAO,aAAa,CAAC,iBAAiB,EAAE,YAAY,EAAE,GAAG,EAAE,CACzD,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CACtC,EAAE,CAAC;YACN,CAAC;YACD,IAAI,CAAC,YAAY;gBACf,SAAS,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,kBAAkB,CAAC,CAAC;gBAClE,OAAO,aAAa,CAAC,kBAAkB,EAAE,YAAY,EAAE,GAAG,EAAE,CAC1D,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CACvC,EAAE,CAAC;YACN,CAAC;SACF;QACD,SAAS,EAAE;YACT,IAAI;gBACF,OAAO,aAAa,CAAC,gBAAgB,EAAE,SAAS,EAAE,GAAG,EAAE,CACrD,OAAO,CAAC,SAAS,CAAC,IAAI,EAAE,CACzB,EAAE,CAAC;YACN,CAAC;YACD,QAAQ,CAAC,GAAG;gBACV,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,oBAAoB,CAAC,CAAC;gBAC/D,OAAO,aAAa,CAAC,oBAAoB,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,CACxD,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,GAAG,CAAC,CAChC,EAAE,CAAC;YACN,CAAC;SACF;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,98 @@
1
+ /**
2
+ * Pure deploy compiler — `compileModule`
3
+ *
4
+ * Lowers a `DataWorkflowModule` into `GraphPatchOp[]` mirroring the backend's
5
+ * `graph-patch-apply.ts` shape. This is a pure function: no I/O, no network.
6
+ *
7
+ * Responsibilities:
8
+ * - Trigger → connection/ingestion node
9
+ * - Handler steps → transform node(s)
10
+ * - Sinks → data-product node(s)
11
+ * - Resolve `workflow_id` by name for in-place update (R3.5)
12
+ * - Collect `referencedResources` for pre-deploy existence validation (R1.8)
13
+ * - Compute removal set: modules on instance but absent from project (R3.7)
14
+ *
15
+ * Requirements: 3.4, 3.5, 3.7
16
+ */
17
+ import type { DataWorkflowModule } from './types.js';
18
+ import type { NormalizedContext } from '../codegen/types.js';
19
+ export type GraphPatchOp = {
20
+ op: 'add_node';
21
+ entity_type: string;
22
+ entity: Record<string, unknown>;
23
+ } | {
24
+ op: 'update_node';
25
+ entity_id: string;
26
+ patch: Record<string, unknown>;
27
+ } | {
28
+ op: 'remove_node';
29
+ entity_id: string;
30
+ } | {
31
+ op: 'connect_nodes';
32
+ from_entity_id: string;
33
+ to_entity_id: string;
34
+ } | {
35
+ op: 'disconnect_nodes';
36
+ from_entity_id: string;
37
+ to_entity_id: string;
38
+ } | {
39
+ op: 'update_workflow';
40
+ patch: Record<string, unknown>;
41
+ };
42
+ /**
43
+ * A reference to a platform resource used by the compiled workflow.
44
+ * Used for pre-deploy existence validation (R1.8).
45
+ */
46
+ export interface ResourceRef {
47
+ type: 'queue' | 'connector' | 'data_product' | 'workflow' | 'domain';
48
+ id: string;
49
+ name?: string;
50
+ }
51
+ /**
52
+ * The output of `compileModule` — a compiled workflow ready for deployment.
53
+ */
54
+ export interface CompiledWorkflow {
55
+ /** The workflow name from the module. */
56
+ name: string;
57
+ /** Resolved workflow_id if a workflow of this name already exists (in-place update, R3.5). */
58
+ workflow_id?: string;
59
+ /** Graph patch operations that create/update the workflow's graph nodes and edges. */
60
+ ops: GraphPatchOp[];
61
+ /** All platform resources referenced by the module (for pre-deploy validation). */
62
+ referencedResources: ResourceRef[];
63
+ }
64
+ /**
65
+ * Compile a single `DataWorkflowModule` into a `CompiledWorkflow`.
66
+ *
67
+ * This is a **pure function**: it performs no I/O, no network calls. Given the
68
+ * same module and context, it always produces the same output.
69
+ *
70
+ * Graph lowering:
71
+ * - Each trigger → a `connections` (ingestion) node
72
+ * - The handler → a `transformations` node
73
+ * - All trigger nodes connect to the handler node
74
+ *
75
+ * @param mod - The data workflow module to compile
76
+ * @param ctx - The normalized workspace context (provides workflow identity lookup)
77
+ * @returns A `CompiledWorkflow` with ops, referencedResources, and optional workflow_id
78
+ */
79
+ export declare function compileModule(mod: DataWorkflowModule, ctx: NormalizedContext): CompiledWorkflow;
80
+ /**
81
+ * Compute the removal set: workflows present on the instance but absent from
82
+ * the current set of project modules (R3.7).
83
+ *
84
+ * Returns `remove_node` operations for each workflow that should be deleted,
85
+ * along with the workflow identities (name + id) for reporting.
86
+ *
87
+ * @param projectModuleNames - The set of module names currently in the project
88
+ * @param ctx - The normalized workspace context (contains instance workflows)
89
+ * @returns An object with removal ops and the names/ids of removed workflows
90
+ */
91
+ export declare function computeRemovalSet(projectModuleNames: Set<string>, ctx: NormalizedContext): {
92
+ removals: Array<{
93
+ name: string;
94
+ workflow_id: string;
95
+ }>;
96
+ ops: GraphPatchOp[];
97
+ };
98
+ //# sourceMappingURL=compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../../src/authoring/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,YAAY,CAAC;AAClE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAM7D,MAAM,MAAM,YAAY,GACpB;IAAE,EAAE,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GACxE;IAAE,EAAE,EAAE,aAAa,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAA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A;CAAE,CAYjF"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Pure deploy compiler — `compileModule`
3
+ *
4
+ * Lowers a `DataWorkflowModule` into `GraphPatchOp[]` mirroring the backend's
5
+ * `graph-patch-apply.ts` shape. This is a pure function: no I/O, no network.
6
+ *
7
+ * Responsibilities:
8
+ * - Trigger → connection/ingestion node
9
+ * - Handler steps → transform node(s)
10
+ * - Sinks → data-product node(s)
11
+ * - Resolve `workflow_id` by name for in-place update (R3.5)
12
+ * - Collect `referencedResources` for pre-deploy existence validation (R1.8)
13
+ * - Compute removal set: modules on instance but absent from project (R3.7)
14
+ *
15
+ * Requirements: 3.4, 3.5, 3.7
16
+ */
17
+ // ────────────────────────────────────────────────────────────────────────────
18
+ // Internal helpers
19
+ // ────────────────────────────────────────────────────────────────────────────
20
+ /** Generate a deterministic node ID from module name + a suffix. */
21
+ function nodeId(workflowName, suffix) {
22
+ return `${workflowName}__${suffix}`;
23
+ }
24
+ /**
25
+ * Lower a single trigger into a connection/ingestion node + graph ops.
26
+ * Returns the entity_id of the created node so downstream nodes can connect.
27
+ */
28
+ function lowerTrigger(trigger, workflowName, index) {
29
+ const entityId = nodeId(workflowName, `trigger_${index}`);
30
+ const refs = [];
31
+ const entity = {
32
+ connection_id: entityId,
33
+ name: `${workflowName}_trigger_${index}`,
34
+ trigger_kind: trigger.kind,
35
+ };
36
+ if (trigger.ref) {
37
+ entity.source_id = trigger.ref.id;
38
+ entity.source_name = trigger.ref.name;
39
+ // Collect the resource reference
40
+ if (trigger.kind === 'queue') {
41
+ refs.push({ type: 'queue', id: trigger.ref.id, name: trigger.ref.name });
42
+ }
43
+ else if (trigger.kind === 'connector') {
44
+ refs.push({ type: 'connector', id: trigger.ref.id, name: trigger.ref.name });
45
+ }
46
+ }
47
+ if (trigger.schedule) {
48
+ entity.schedule = trigger.schedule;
49
+ }
50
+ if (trigger.path) {
51
+ entity.webhook_path = trigger.path;
52
+ }
53
+ const ops = [
54
+ { op: 'add_node', entity_type: 'connections', entity },
55
+ ];
56
+ return { ops, entityId, refs };
57
+ }
58
+ /**
59
+ * Lower the handler into a single transform node.
60
+ * The handler itself is stored as a reference (name-based) — the actual execution
61
+ * is handled at runtime by the deployed bot, not baked into the graph.
62
+ */
63
+ function lowerHandler(workflowName) {
64
+ const entityId = nodeId(workflowName, 'handler');
65
+ const entity = {
66
+ transformation_id: entityId,
67
+ name: `${workflowName}_handler`,
68
+ transform_type: 'code_handler',
69
+ module_name: workflowName,
70
+ };
71
+ const ops = [
72
+ { op: 'add_node', entity_type: 'transformations', entity },
73
+ ];
74
+ return { ops, entityId };
75
+ }
76
+ /**
77
+ * Resolve the `workflow_id` for a module by name from the NormalizedContext.
78
+ * If a workflow with the same name exists, returns its id for in-place update (R3.5).
79
+ */
80
+ function resolveWorkflowId(workflowName, ctx) {
81
+ const match = ctx.workflows.find((w) => w.data.name === workflowName);
82
+ return match?.data.id;
83
+ }
84
+ // ────────────────────────────────────────────────────────────────────────────
85
+ // Public API
86
+ // ────────────────────────────────────────────────────────────────────────────
87
+ /**
88
+ * Compile a single `DataWorkflowModule` into a `CompiledWorkflow`.
89
+ *
90
+ * This is a **pure function**: it performs no I/O, no network calls. Given the
91
+ * same module and context, it always produces the same output.
92
+ *
93
+ * Graph lowering:
94
+ * - Each trigger → a `connections` (ingestion) node
95
+ * - The handler → a `transformations` node
96
+ * - All trigger nodes connect to the handler node
97
+ *
98
+ * @param mod - The data workflow module to compile
99
+ * @param ctx - The normalized workspace context (provides workflow identity lookup)
100
+ * @returns A `CompiledWorkflow` with ops, referencedResources, and optional workflow_id
101
+ */
102
+ export function compileModule(mod, ctx) {
103
+ const ops = [];
104
+ const referencedResources = [];
105
+ // Resolve workflow identity for in-place update (R3.5)
106
+ const workflow_id = resolveWorkflowId(mod.name, ctx);
107
+ // Lower each trigger into a connection/ingestion node
108
+ const triggerEntityIds = [];
109
+ for (let i = 0; i < mod.triggers.length; i++) {
110
+ const trigger = mod.triggers[i];
111
+ const result = lowerTrigger(trigger, mod.name, i);
112
+ ops.push(...result.ops);
113
+ triggerEntityIds.push(result.entityId);
114
+ referencedResources.push(...result.refs);
115
+ }
116
+ // Lower handler into a transform node
117
+ const handler = lowerHandler(mod.name);
118
+ ops.push(...handler.ops);
119
+ // Connect each trigger node to the handler node
120
+ for (const triggerId of triggerEntityIds) {
121
+ ops.push({
122
+ op: 'connect_nodes',
123
+ from_entity_id: triggerId,
124
+ to_entity_id: handler.entityId,
125
+ });
126
+ }
127
+ return {
128
+ name: mod.name,
129
+ ...(workflow_id !== undefined ? { workflow_id } : {}),
130
+ ops,
131
+ referencedResources,
132
+ };
133
+ }
134
+ /**
135
+ * Compute the removal set: workflows present on the instance but absent from
136
+ * the current set of project modules (R3.7).
137
+ *
138
+ * Returns `remove_node` operations for each workflow that should be deleted,
139
+ * along with the workflow identities (name + id) for reporting.
140
+ *
141
+ * @param projectModuleNames - The set of module names currently in the project
142
+ * @param ctx - The normalized workspace context (contains instance workflows)
143
+ * @returns An object with removal ops and the names/ids of removed workflows
144
+ */
145
+ export function computeRemovalSet(projectModuleNames, ctx) {
146
+ const removals = [];
147
+ const ops = [];
148
+ for (const wf of ctx.workflows) {
149
+ if (!projectModuleNames.has(wf.data.name)) {
150
+ removals.push({ name: wf.data.name, workflow_id: wf.data.id });
151
+ ops.push({ op: 'remove_node', entity_id: wf.data.id });
152
+ }
153
+ }
154
+ return { removals, ops };
155
+ }
156
+ //# sourceMappingURL=compiler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compiler.js","sourceRoot":"","sources":["../../src/authoring/compiler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAyCH,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E,oEAAoE;AACpE,SAAS,MAAM,CAAC,YAAoB,EAAE,MAAc;IAClD,OAAO,GAAG,YAAY,KAAK,MAAM,EAAE,CAAC;AACtC,CAAC;AAED;;;GAGG;AACH,SAAS,YAAY,CACnB,OAAoB,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