@n8n/instance-ai 1.22.0 → 1.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +9 -5
  2. package/dist/agent/credential-guardrails.prompt.d.ts +1 -0
  3. package/dist/agent/credential-guardrails.prompt.js +2 -1
  4. package/dist/agent/credential-guardrails.prompt.js.map +1 -1
  5. package/dist/agent/shared-prompts.d.ts +1 -1
  6. package/dist/agent/shared-prompts.js +1 -1
  7. package/dist/agent/shared-prompts.js.map +1 -1
  8. package/dist/agent/sub-agent-factory.d.ts +1 -1
  9. package/dist/agent/sub-agent-factory.js +2 -1
  10. package/dist/agent/sub-agent-factory.js.map +1 -1
  11. package/dist/agent/system-prompt.js +7 -3
  12. package/dist/agent/system-prompt.js.map +1 -1
  13. package/dist/build.tsbuildinfo +1 -1
  14. package/dist/event-bus/event-bus.interface.d.ts +0 -4
  15. package/dist/index.d.ts +3 -1
  16. package/dist/index.js +10 -4
  17. package/dist/index.js.map +1 -1
  18. package/dist/planned-tasks/planned-task-permissions.d.ts +1 -2
  19. package/dist/planned-tasks/planned-task-permissions.js +0 -13
  20. package/dist/planned-tasks/planned-task-permissions.js.map +1 -1
  21. package/dist/runtime/resumable-stream-executor.js.map +1 -1
  22. package/dist/runtime/stream-runner.js.map +1 -1
  23. package/dist/stream/consume-with-hitl.js.map +1 -1
  24. package/dist/stream/output-redaction.js.map +1 -1
  25. package/dist/tools/credentials.tool.d.ts +3 -3
  26. package/dist/tools/credentials.tool.js +82 -15
  27. package/dist/tools/credentials.tool.js.map +1 -1
  28. package/dist/tools/evals/evals.tool.js +1 -3
  29. package/dist/tools/evals/evals.tool.js.map +1 -1
  30. package/dist/tools/filesystem/create-tools-from-mcp-server.js +4 -51
  31. package/dist/tools/filesystem/create-tools-from-mcp-server.js.map +1 -1
  32. package/dist/tools/nodes.tool.js +3 -3
  33. package/dist/tools/nodes.tool.js.map +1 -1
  34. package/dist/tools/orchestration/build-agent.tool.js +37 -6
  35. package/dist/tools/orchestration/build-agent.tool.js.map +1 -1
  36. package/dist/tools/orchestration/builder-required-artifact.d.ts +202 -0
  37. package/dist/tools/orchestration/builder-required-artifact.js +39 -0
  38. package/dist/tools/orchestration/builder-required-artifact.js.map +1 -0
  39. package/dist/tools/orchestration/verification/analyze-result.d.ts +1 -0
  40. package/dist/tools/orchestration/verification/analyze-result.js +21 -5
  41. package/dist/tools/orchestration/verification/analyze-result.js.map +1 -1
  42. package/dist/tools/orchestration/verification/scripted-gate-run.d.ts +1 -0
  43. package/dist/tools/orchestration/verification/scripted-gate-run.js +2 -0
  44. package/dist/tools/orchestration/verification/scripted-gate-run.js.map +1 -1
  45. package/dist/tools/orchestration/verification/types.d.ts +1 -0
  46. package/dist/tools/orchestration/verify-built-workflow.tool.d.ts +3 -0
  47. package/dist/tools/orchestration/verify-built-workflow.tool.js +13 -0
  48. package/dist/tools/orchestration/verify-built-workflow.tool.js.map +1 -1
  49. package/dist/tools/workflows/build-workflow.tool.d.ts +0 -3
  50. package/dist/tools/workflows/build-workflow.tool.js +14 -19
  51. package/dist/tools/workflows/build-workflow.tool.js.map +1 -1
  52. package/dist/tools/workflows/chat-model-validation.d.ts +2 -2
  53. package/dist/tools/workflows/chat-model-validation.js +6 -28
  54. package/dist/tools/workflows/chat-model-validation.js.map +1 -1
  55. package/dist/tools/workflows/credential-utils.d.ts +1 -1
  56. package/dist/tools/workflows/credential-utils.js +2 -2
  57. package/dist/tools/workflows/credential-utils.js.map +1 -1
  58. package/dist/tools/workflows/detect-python-code-constraints.d.ts +3 -0
  59. package/dist/tools/workflows/detect-python-code-constraints.js +42 -0
  60. package/dist/tools/workflows/detect-python-code-constraints.js.map +1 -0
  61. package/dist/tools/workflows/detect-slack-blocks-shape.d.ts +3 -0
  62. package/dist/tools/workflows/detect-slack-blocks-shape.js +129 -0
  63. package/dist/tools/workflows/detect-slack-blocks-shape.js.map +1 -0
  64. package/dist/tools/workflows/resolve-credentials.d.ts +4 -1
  65. package/dist/tools/workflows/resolve-credentials.js +27 -5
  66. package/dist/tools/workflows/resolve-credentials.js.map +1 -1
  67. package/dist/tools/workflows/setup-workflow.service.d.ts +2 -1
  68. package/dist/tools/workflows/setup-workflow.service.js +22 -13
  69. package/dist/tools/workflows/setup-workflow.service.js.map +1 -1
  70. package/dist/tools/workflows/validate-workflow.service.js +4 -4
  71. package/dist/tools/workflows/validate-workflow.service.js.map +1 -1
  72. package/dist/tools/workflows/workflow-source-compiler.js +4 -0
  73. package/dist/tools/workflows/workflow-source-compiler.js.map +1 -1
  74. package/dist/tools/workflows.tool.js +22 -10
  75. package/dist/tools/workflows.tool.js.map +1 -1
  76. package/dist/tracing/thread-provenance.d.ts +1 -0
  77. package/dist/tracing/thread-provenance.js +18 -0
  78. package/dist/tracing/thread-provenance.js.map +1 -0
  79. package/dist/types.d.ts +7 -3
  80. package/dist/types.js.map +1 -1
  81. package/dist/workspace/snapshot-manager.d.ts +8 -0
  82. package/dist/workspace/snapshot-manager.js +352 -14
  83. package/dist/workspace/snapshot-manager.js.map +1 -1
  84. package/knowledge-base/reference/workflow-builder-guardrails.md +11 -0
  85. package/package.json +12 -12
  86. package/skills/agent-builder/SKILL.md +30 -17
  87. package/skills/post-build-flow/SKILL.md +38 -16
  88. package/skills/workflow-builder/SKILL.md +37 -20
@@ -14,6 +14,20 @@ const SNAPSHOT_WORKSPACE_LAYOUT_DIRS = ['src', 'chunks', 'node-types'];
14
14
  const SNAPSHOT_BUILDING_STATES = new Set(['building', 'pending', 'pulling']);
15
15
  const SNAPSHOT_VERIFY_POLL_MS = 5_000;
16
16
  const DEFAULT_SNAPSHOT_VERIFY_TIMEOUT_S = 1_800;
17
+ const SNAPSHOT_NAME_PREFIX = 'n8n/instance-ai:';
18
+ const MAX_TRANSIENT_CREATE_RETRIES = 3;
19
+ const TRANSIENT_CREATE_RETRY_BACKOFF_MS = 5_000;
20
+ const MAX_FAILED_SNAPSHOT_CLEANUPS = 2;
21
+ const SNAPSHOT_LIST_PAGE_SIZE = 100;
22
+ const MAX_SNAPSHOT_LIST_PAGES = 20;
23
+ const SNAPSHOT_PRUNE_TIMEOUT_MS = 5 * 60_000;
24
+ const SNAPSHOT_REMOVAL_WAIT_MS = 60_000;
25
+ const SNAPSHOT_REMOVAL_POLL_MS = 2_000;
26
+ const MAX_ACTIVATION_ATTEMPTS = 3;
27
+ const ACTIVATION_SETTLE_POLLS = 6;
28
+ const SNAPSHOT_DELETABLE_STATES = new Set(['active', 'inactive', 'error', 'build_failed']);
29
+ const SNAPSHOT_FAILED_STATES = new Set(['error', 'build_failed']);
30
+ const MIN_KEEP_NEWEST_VERSIONS = 3;
17
31
  function isAlreadyExistsError(error) {
18
32
  const { DaytonaError } = (0, sandbox_1.loadDaytona)();
19
33
  if (!(error instanceof DaytonaError))
@@ -22,6 +36,48 @@ function isAlreadyExistsError(error) {
22
36
  return true;
23
37
  return /already exists/i.test(error.message);
24
38
  }
39
+ function isCreateFailedStateError(error) {
40
+ const { DaytonaError } = (0, sandbox_1.loadDaytona)();
41
+ return error instanceof DaytonaError && /^failed to create snapshot\b/i.test(error.message);
42
+ }
43
+ class SnapshotUnusableError extends Error {
44
+ snapshotState;
45
+ constructor(message, snapshotState) {
46
+ super(message);
47
+ this.snapshotState = snapshotState;
48
+ }
49
+ }
50
+ function isTransientDaytonaError(error) {
51
+ const { DaytonaError } = (0, sandbox_1.loadDaytona)();
52
+ if (!(error instanceof DaytonaError))
53
+ return false;
54
+ if (error.name === 'DaytonaConnectionError' || error.name === 'DaytonaTimeoutError')
55
+ return true;
56
+ const status = error.statusCode;
57
+ return status !== undefined && (status >= 500 || status === 408 || status === 429);
58
+ }
59
+ function isQuotaExceededError(error) {
60
+ const { DaytonaError } = (0, sandbox_1.loadDaytona)();
61
+ return error instanceof DaytonaError && /snapshot quota exceeded/i.test(error.message);
62
+ }
63
+ function compareSnapshotVersionsDesc(a, b) {
64
+ return parseSnapshotVersionRank(b.name) - parseSnapshotVersionRank(a.name);
65
+ }
66
+ function parseSnapshotVersionRank(name) {
67
+ const version = name.slice(SNAPSHOT_NAME_PREFIX.length);
68
+ const match = /^(\d+)\.(\d+)\.(\d+)(-.+)?$/.exec(version);
69
+ if (!match)
70
+ return Number.NEGATIVE_INFINITY;
71
+ const [, major, minor, patch, suffix] = match;
72
+ return (Number(major) * 1e8 + Number(minor) * 1e4 + Number(patch) + (suffix !== undefined ? -0.5 : 0));
73
+ }
74
+ function isPlainVersionName(name) {
75
+ return /^\d+\.\d+\.\d+$/.test(name.slice(SNAPSHOT_NAME_PREFIX.length));
76
+ }
77
+ function lastUsedTime(snapshot) {
78
+ const time = new Date(snapshot.lastUsedAt ?? snapshot.createdAt).getTime();
79
+ return Number.isNaN(time) ? Number.POSITIVE_INFINITY : time;
80
+ }
25
81
  class SnapshotManager {
26
82
  baseImage;
27
83
  logger;
@@ -76,45 +132,327 @@ class SnapshotManager {
76
132
  if (!name) {
77
133
  throw new Error('SnapshotManager: n8nVersion is required to derive a snapshot name');
78
134
  }
135
+ const timeoutS = options?.timeout !== undefined && options.timeout > 0
136
+ ? options.timeout
137
+ : DEFAULT_SNAPSHOT_VERIFY_TIMEOUT_S;
138
+ const deadline = Date.now() + timeoutS * 1000;
139
+ for (let rebuilds = 0;; rebuilds++) {
140
+ await this.createWithRecovery(daytona, name, deadline, options);
141
+ try {
142
+ await this.verifySnapshot(daytona, name, deadline);
143
+ break;
144
+ }
145
+ catch (error) {
146
+ const rebuildable = error instanceof SnapshotUnusableError &&
147
+ SNAPSHOT_FAILED_STATES.has(error.snapshotState) &&
148
+ rebuilds < 1 &&
149
+ Date.now() < deadline;
150
+ if (!rebuildable)
151
+ throw error;
152
+ this.logger.warn('Published Daytona snapshot is unusable; deleting it and rebuilding', {
153
+ name,
154
+ state: error.snapshotState,
155
+ });
156
+ await this.reconcileFailedSnapshotRecord(daytona, name, deadline);
157
+ }
158
+ }
79
159
  try {
80
- await daytona.snapshot.create({ name, image: await this.ensureImage() }, options);
81
- this.logger.info('Created versioned Daytona snapshot; verifying it is usable', { name });
160
+ await this.withDeadline(this.pruneSnapshots(daytona, name, options), Date.now() + SNAPSHOT_PRUNE_TIMEOUT_MS, 'Timed out pruning Daytona snapshots');
82
161
  }
83
162
  catch (error) {
84
- if (isAlreadyExistsError(error)) {
85
- this.logger.info('Versioned Daytona snapshot already exists; verifying it is usable', {
86
- name,
87
- });
163
+ this.logger.warn('Snapshot pruning did not complete', {
164
+ error: error instanceof Error ? error.message : String(error),
165
+ });
166
+ }
167
+ return name;
168
+ }
169
+ async createWithRecovery(daytona, name, deadline, options) {
170
+ const createOptions = { timeout: options?.timeout, onLogs: options?.onLogs };
171
+ let transientRetries = 0;
172
+ let failedCleanups = 0;
173
+ let prunedForQuota = false;
174
+ for (;;) {
175
+ try {
176
+ const image = await this.withDeadline(this.ensureImage(), deadline, `Timed out preparing the image for Daytona snapshot "${name}"`);
177
+ await this.withDeadline(daytona.snapshot.create({ name, image }, createOptions), deadline, `Timed out creating Daytona snapshot "${name}"`);
178
+ this.logger.info('Created versioned Daytona snapshot; verifying it is usable', { name });
179
+ return;
88
180
  }
89
- else {
181
+ catch (error) {
182
+ if (isCreateFailedStateError(error)) {
183
+ if (failedCleanups < MAX_FAILED_SNAPSHOT_CLEANUPS) {
184
+ const record = await this.reconcileFailedSnapshotRecord(daytona, name, deadline);
185
+ if (record !== 'usable') {
186
+ failedCleanups++;
187
+ await (0, sleep_1.sleep)(Math.min(TRANSIENT_CREATE_RETRY_BACKOFF_MS * failedCleanups, deadline - Date.now()));
188
+ if (Date.now() >= deadline)
189
+ throw error;
190
+ continue;
191
+ }
192
+ }
193
+ throw error;
194
+ }
195
+ if (isAlreadyExistsError(error)) {
196
+ this.logger.info('Versioned Daytona snapshot already exists; verifying it is usable', {
197
+ name,
198
+ });
199
+ return;
200
+ }
201
+ const canPrune = (options?.retention ?? 0) > 0 || (options?.maxAgeDays ?? 0) > 0;
202
+ if (isQuotaExceededError(error) && !prunedForQuota && canPrune) {
203
+ prunedForQuota = true;
204
+ this.logger.warn('Snapshot quota exceeded; pruning old versioned snapshots', { name });
205
+ const deleted = await this.withDeadline(this.pruneSnapshots(daytona, name, options, { ensureAtLeastOne: true }), deadline, 'Timed out pruning Daytona snapshots').catch(() => []);
206
+ if (deleted.length === 0)
207
+ throw error;
208
+ await this.waitForSnapshotRemoval(daytona, deleted, deadline);
209
+ continue;
210
+ }
211
+ if (isTransientDaytonaError(error) &&
212
+ transientRetries < MAX_TRANSIENT_CREATE_RETRIES &&
213
+ Date.now() < deadline) {
214
+ transientRetries++;
215
+ this.logger.warn('Transient Daytona error during snapshot create; retrying', {
216
+ name,
217
+ attempt: transientRetries,
218
+ error: error instanceof Error ? error.message : String(error),
219
+ });
220
+ await (0, sleep_1.sleep)(Math.min(TRANSIENT_CREATE_RETRY_BACKOFF_MS * transientRetries, deadline - Date.now()));
221
+ if (Date.now() >= deadline)
222
+ throw error;
223
+ continue;
224
+ }
90
225
  throw error;
91
226
  }
92
227
  }
93
- await this.verifySnapshot(daytona, name, options?.timeout);
94
- return name;
95
228
  }
96
- async verifySnapshot(daytona, name, timeoutS = DEFAULT_SNAPSHOT_VERIFY_TIMEOUT_S) {
97
- const deadline = Date.now() + timeoutS * 1000;
229
+ async reconcileFailedSnapshotRecord(daytona, name, deadline) {
230
+ const { DaytonaNotFoundError } = (0, sandbox_1.loadDaytona)();
231
+ let snapshot;
232
+ try {
233
+ snapshot = await this.withDeadline(daytona.snapshot.get(name), deadline, `Timed out fetching state of Daytona snapshot "${name}"`);
234
+ }
235
+ catch (error) {
236
+ if (error instanceof DaytonaNotFoundError)
237
+ return 'absent';
238
+ throw error;
239
+ }
240
+ if (!SNAPSHOT_FAILED_STATES.has(snapshot.state))
241
+ return 'usable';
242
+ this.logger.warn('Versioned Daytona snapshot is in a failed state; deleting it to retry', {
243
+ name,
244
+ state: snapshot.state,
245
+ ...(snapshot.errorReason ? { reason: snapshot.errorReason } : {}),
246
+ });
247
+ await this.withDeadline(daytona.snapshot.delete(snapshot), deadline, `Timed out deleting failed Daytona snapshot "${name}"`);
248
+ await this.waitForSnapshotRemoval(daytona, [snapshot], deadline);
249
+ return 'cleaned';
250
+ }
251
+ async waitForSnapshotRemoval(daytona, snapshots, deadline) {
252
+ const { DaytonaNotFoundError } = (0, sandbox_1.loadDaytona)();
253
+ const waitDeadline = Math.min(deadline, Date.now() + SNAPSHOT_REMOVAL_WAIT_MS);
254
+ for (const snapshot of snapshots) {
255
+ for (;;) {
256
+ try {
257
+ await this.withDeadline(daytona.snapshot.get(snapshot.name), waitDeadline, `Timed out waiting for Daytona snapshot "${snapshot.name}" to be removed`);
258
+ }
259
+ catch (error) {
260
+ if (!(error instanceof DaytonaNotFoundError)) {
261
+ this.logger.warn('Unexpected error while waiting for snapshot removal', {
262
+ name: snapshot.name,
263
+ error: error instanceof Error ? error.message : String(error),
264
+ });
265
+ }
266
+ break;
267
+ }
268
+ if (Date.now() >= waitDeadline) {
269
+ this.logger.warn('Timed out waiting for pruned snapshots to be removed', {
270
+ name: snapshot.name,
271
+ });
272
+ return;
273
+ }
274
+ await (0, sleep_1.sleep)(SNAPSHOT_REMOVAL_POLL_MS);
275
+ }
276
+ }
277
+ }
278
+ async verifySnapshot(daytona, name, deadline) {
279
+ let activationAttempts = 0;
280
+ let pollsSinceActivation = ACTIVATION_SETTLE_POLLS;
98
281
  for (;;) {
99
- const snapshot = await daytona.snapshot.get(name);
282
+ let snapshot;
283
+ try {
284
+ snapshot = await this.withDeadline(daytona.snapshot.get(name), deadline, `Timed out fetching state of Daytona snapshot "${name}"`);
285
+ }
286
+ catch (error) {
287
+ if (!isTransientDaytonaError(error) || Date.now() >= deadline)
288
+ throw error;
289
+ this.logger.warn('Transient Daytona error while polling snapshot state; retrying', {
290
+ name,
291
+ error: error instanceof Error ? error.message : String(error),
292
+ });
293
+ await (0, sleep_1.sleep)(SNAPSHOT_VERIFY_POLL_MS);
294
+ continue;
295
+ }
100
296
  if (snapshot.state === 'active') {
101
297
  this.logger.info('Versioned Daytona snapshot is active', { name });
102
298
  return;
103
299
  }
300
+ if (snapshot.state === 'inactive') {
301
+ if (pollsSinceActivation >= ACTIVATION_SETTLE_POLLS) {
302
+ if (activationAttempts >= MAX_ACTIVATION_ATTEMPTS) {
303
+ throw new Error(`Versioned Daytona snapshot "${name}" remained inactive after ${MAX_ACTIVATION_ATTEMPTS} activation requests`);
304
+ }
305
+ activationAttempts++;
306
+ pollsSinceActivation = 0;
307
+ this.logger.info('Versioned Daytona snapshot is inactive; requesting activation', {
308
+ name,
309
+ attempt: activationAttempts,
310
+ });
311
+ try {
312
+ await this.withDeadline(daytona.snapshot.activate(snapshot), deadline, `Timed out requesting activation of Daytona snapshot "${name}"`);
313
+ }
314
+ catch (error) {
315
+ if (!isTransientDaytonaError(error))
316
+ throw error;
317
+ this.logger.warn('Transient Daytona error during snapshot activation; will retry', {
318
+ name,
319
+ error: error instanceof Error ? error.message : String(error),
320
+ });
321
+ }
322
+ }
323
+ else {
324
+ pollsSinceActivation++;
325
+ }
326
+ if (Date.now() >= deadline) {
327
+ throw new Error(`Timed out waiting for existing Daytona snapshot "${name}" to become active (state: ${snapshot.state})`);
328
+ }
329
+ await (0, sleep_1.sleep)(SNAPSHOT_VERIFY_POLL_MS);
330
+ continue;
331
+ }
104
332
  if (!SNAPSHOT_BUILDING_STATES.has(snapshot.state)) {
105
333
  const reason = snapshot.errorReason ? `, reason: ${snapshot.errorReason}` : '';
106
- throw new Error(`Versioned Daytona snapshot "${name}" exists but is unusable (state: ${snapshot.state}${reason})`);
334
+ throw new SnapshotUnusableError(`Versioned Daytona snapshot "${name}" exists but is unusable (state: ${snapshot.state}${reason})`, snapshot.state);
107
335
  }
108
336
  if (Date.now() >= deadline) {
109
337
  throw new Error(`Timed out waiting for existing Daytona snapshot "${name}" to become active (state: ${snapshot.state})`);
110
338
  }
111
- this.logger.info('Waiting for existing Daytona snapshot to finish building', {
339
+ this.logger.info('Waiting for existing Daytona snapshot to become active', {
112
340
  name,
113
341
  state: snapshot.state,
114
342
  });
115
343
  await (0, sleep_1.sleep)(SNAPSHOT_VERIFY_POLL_MS);
116
344
  }
117
345
  }
346
+ async pruneSnapshots(daytona, protectedName, options, { ensureAtLeastOne = false } = {}) {
347
+ const retention = options?.retention;
348
+ const maxAgeDays = options?.maxAgeDays;
349
+ if (!retention && !maxAgeDays)
350
+ return [];
351
+ let matching;
352
+ try {
353
+ matching = await this.listVersionedSnapshots(daytona);
354
+ }
355
+ catch (error) {
356
+ this.logger.warn('Failed to list Daytona snapshots for pruning; skipping', {
357
+ error: error instanceof Error ? error.message : String(error),
358
+ });
359
+ return [];
360
+ }
361
+ const newestVersionNames = new Set(matching
362
+ .filter((snapshot) => !SNAPSHOT_FAILED_STATES.has(snapshot.state) && isPlainVersionName(snapshot.name))
363
+ .sort(compareSnapshotVersionsDesc)
364
+ .slice(0, MIN_KEEP_NEWEST_VERSIONS)
365
+ .map((snapshot) => snapshot.name));
366
+ const isDeletable = (snapshot) => snapshot.name !== protectedName && SNAPSHOT_DELETABLE_STATES.has(snapshot.state);
367
+ const isPrunable = (snapshot) => isDeletable(snapshot) && !newestVersionNames.has(snapshot.name);
368
+ const toDelete = [];
369
+ const selected = new Set();
370
+ const select = (snapshot) => {
371
+ if (selected.has(snapshot.name))
372
+ return;
373
+ selected.add(snapshot.name);
374
+ toDelete.push(snapshot);
375
+ };
376
+ for (const snapshot of matching) {
377
+ if (SNAPSHOT_FAILED_STATES.has(snapshot.state) && isDeletable(snapshot))
378
+ select(snapshot);
379
+ }
380
+ if (maxAgeDays) {
381
+ const cutoff = Date.now() - maxAgeDays * 24 * 60 * 60 * 1000;
382
+ for (const snapshot of matching) {
383
+ if (!selected.has(snapshot.name) && isPrunable(snapshot) && lastUsedTime(snapshot) < cutoff)
384
+ select(snapshot);
385
+ }
386
+ }
387
+ if (retention) {
388
+ const remaining = matching.filter((snapshot) => !selected.has(snapshot.name));
389
+ let excess = remaining.length - retention;
390
+ const evictable = remaining
391
+ .filter(isPrunable)
392
+ .sort((a, b) => lastUsedTime(a) - lastUsedTime(b));
393
+ for (const snapshot of evictable) {
394
+ if (excess <= 0)
395
+ break;
396
+ select(snapshot);
397
+ excess--;
398
+ }
399
+ }
400
+ if (ensureAtLeastOne && toDelete.length === 0) {
401
+ const lruCandidate = matching
402
+ .filter(isPrunable)
403
+ .sort((a, b) => lastUsedTime(a) - lastUsedTime(b))[0];
404
+ if (lruCandidate) {
405
+ this.logger.warn('Quota pressure: evicting least-recently-used snapshot despite retention policy', { name: lruCandidate.name });
406
+ select(lruCandidate);
407
+ }
408
+ }
409
+ const deleted = [];
410
+ for (const snapshot of toDelete) {
411
+ try {
412
+ await daytona.snapshot.delete(snapshot);
413
+ deleted.push(snapshot);
414
+ this.logger.info('Pruned versioned Daytona snapshot', {
415
+ name: snapshot.name,
416
+ state: snapshot.state,
417
+ lastUsedAt: snapshot.lastUsedAt ?? null,
418
+ });
419
+ }
420
+ catch (error) {
421
+ this.logger.warn('Failed to delete Daytona snapshot during pruning', {
422
+ name: snapshot.name,
423
+ error: error instanceof Error ? error.message : String(error),
424
+ });
425
+ }
426
+ }
427
+ return deleted;
428
+ }
429
+ async listVersionedSnapshots(daytona) {
430
+ const matching = [];
431
+ let page = 1;
432
+ for (let fetched = 0; fetched < MAX_SNAPSHOT_LIST_PAGES; fetched++) {
433
+ const result = await daytona.snapshot.list(page, SNAPSHOT_LIST_PAGE_SIZE);
434
+ matching.push(...result.items.filter((item) => item.name.startsWith(SNAPSHOT_NAME_PREFIX)));
435
+ if (result.items.length === 0 || result.page >= result.totalPages)
436
+ break;
437
+ page = result.page + 1;
438
+ }
439
+ return matching;
440
+ }
441
+ async withDeadline(promise, deadline, timeoutMessage) {
442
+ let timer;
443
+ try {
444
+ return await Promise.race([
445
+ promise,
446
+ new Promise((_, reject) => {
447
+ timer = setTimeout(() => reject(new Error(timeoutMessage)), Math.max(deadline - Date.now(), 0));
448
+ }),
449
+ ]);
450
+ }
451
+ finally {
452
+ clearTimeout(timer);
453
+ promise.catch(() => { });
454
+ }
455
+ }
118
456
  snapshotName() {
119
457
  if (!this.n8nVersion)
120
458
  return null;
@@ -1 +1 @@
1
- {"version":3,"file":"snapshot-manager.js","sourceRoot":"","sources":["../../src/workspace/snapshot-manager.ts"],"names":[],"mappings":";;;AAgBA,iDAA0E;AAC1E,4CAAyC;AAEzC,6FAGsD;AAEtD,2EAGqC;AACrC,mDAAyE;AACzE,qEAAuE;AACvE,qFAAwF;AACxF,6DAA4E;AAO5E,MAAM,2BAA2B,GAAG,yBAAyB,CAAC;AAC9D,MAAM,8BAA8B,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,CAAU,CAAC;AAChF,MAAM,wBAAwB,GAAG,IAAI,GAAG,CAAC,CAAC,UAAU,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;AAC7E,MAAM,uBAAuB,GAAG,KAAK,CAAC;AACtC,MAAM,iCAAiC,GAAG,KAAK,CAAC;AAEhD,SAAS,oBAAoB,CAAC,KAAc;IAC3C,MAAM,EAAE,YAAY,EAAE,GAAG,IAAA,qBAAW,GAAE,CAAC;IACvC,IAAI,CAAC,CAAC,KAAK,YAAY,YAAY,CAAC;QAAE,OAAO,KAAK,CAAC;IACnD,IAAI,KAAK,CAAC,UAAU,KAAK,GAAG;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC9C,CAAC;AAED;IASmB,SAAS;IACT,MAAM;IACN,UAAU;IACV,kBAAkB;IAClB,gBAAgB;IAZ1B,WAAW,GAA0B,IAAI,CAAC;IAE1C,yBAAyB,GAChC,IAAI,CAAC;IAEE,0BAA0B,GAAiD,IAAI,CAAC;IAExF,YACkB,SAA6B,EAC7B,MAAc,EACd,UAA8B,EAC9B,kBAAuC,EACvC,gBAA0C;yBAJ1C,SAAS;sBACT,MAAM;0BACN,UAAU;kCACV,kBAAkB;gCAClB,gBAAgB;IAC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D,YAAY;QACX,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO,IAAI,CAAC;QAClC,OAAO,mBAAmB,IAAI,CAAC,UAAU,EAAE,CAAC;IAC7C,CAAC;IAEO,KAAK,CAAC,kBAAkB;QAC/B,IAAI,CAAC,yBAAyB,KAAK,IAAA,6DAAgC,EAAC;YACnE,MAAM,EAAE,IAAI,CAAC,kBAAkB,IAAI,IAAA,iDAAgC,GAAE;YACrE,IAAI,EAAE,gCAAsB;YAC5B,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CAAC,CAAC;QAEH,OAAO,MAAM,IAAI,CAAC,yBAAyB,CAAC;IAC7C,CAAC;IAEO,KAAK,CAAC,mBAAmB;QAChC,IAAI,CAAC,0BAA0B,KAAK,IAAI,CAAC,wBAAwB,EAAE,CAAC;QACpE,OAAO,MAAM,IAAI,CAAC,0BAA0B,CAAC;IAC9C,CAAC;IAEO,KAAK,CAAC,wBAAwB;QACrC,MAAM,gBAAgB,GACrB,IAAI,CAAC,gBAAgB;YACrB,IAAI,mDAAuB,CAAC,IAAA,0DAA8B,EAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACtF,MAAM,eAAe,GAAG,MAAM,gBAAgB,CAAC,SAAS,EAAE,CAAC;QAE3D,OAAO,MAAM,IAAA,8DAAiC,EAAC;YAC9C,IAAI,EAAE,gCAAsB;YAC5B,gBAAgB,EAAE,eAAe,CAAC,OAAO;YACzC,MAAM,EAAE,IAAI,CAAC,MAAM;SACnB,CAAC,CAAC;IACJ,CAAC;IAOD,UAAU;QACT,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QACxB,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,0BAA0B,GAAG,IAAI,CAAC;IACxC,CAAC;CACD"}
@@ -119,6 +119,17 @@ expression there produce "Failed to parse schema" and crash the node before
119
119
  any output. Serialize the schema with double-quoted keys and strings, keep it
120
120
  minimal, and set the sibling `name` field.
121
121
 
122
+ ## Slack Blocks Fields Take the Whole Block Kit Payload
123
+
124
+ The Slack node's Blocks field (`blocksUi`) holds the **whole Block Kit payload
125
+ object** — `{ "blocks": [ ... ] }` — not the bare blocks array. The node reads
126
+ that value as an object and picks the blocks off its `blocks` key before
127
+ sending. A top-level `[ { "type": "section" }, ... ]` leaves that key
128
+ undefined, so Slack gets a body with no blocks, replies `ok: true`, and the
129
+ message renders empty — a silent failure the run never reports. Also set
130
+ `messageType: "block"`; with any other message type the payload is dropped and
131
+ only the plain text is posted.
132
+
122
133
  ## Data After Side-Effect Nodes
123
134
 
124
135
  Send/notify/write nodes (Gmail, Slack, Telegram, email send, most "create"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@n8n/instance-ai",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "src/index.ts",
6
6
  "types": "dist/index.d.ts",
@@ -8,8 +8,8 @@
8
8
  "dist/**/*",
9
9
  "knowledge-base/**/*",
10
10
  "skills/**/*",
11
- "LICENSE.md",
12
- "LICENSE_EE.md"
11
+ "LICENSE_EE.md",
12
+ "LICENSE.md"
13
13
  ],
14
14
  "exports": {
15
15
  ".": {
@@ -40,7 +40,7 @@
40
40
  }
41
41
  },
42
42
  "dependencies": {
43
- "@daytona/sdk": "0.194.0",
43
+ "@daytona/sdk": "0.205.1",
44
44
  "@e965/xlsx": "0.20.3",
45
45
  "@opentelemetry/api": "1.9.1",
46
46
  "@thednp/dommatrix": "^3.1.1",
@@ -57,13 +57,13 @@
57
57
  "turndown": "^7.2.4",
58
58
  "zod": "3.25.76",
59
59
  "zod-from-json-schema-v3": "npm:zod-from-json-schema@^0.0.5",
60
- "@n8n/agents": "0.22.0",
61
- "@n8n/ai-utilities": "0.30.0",
62
- "@n8n/api-types": "1.37.0",
63
- "@n8n/mcp-browser": "0.19.0",
64
- "@n8n/utils": "1.45.0",
65
- "@n8n/workflow-sdk": "0.30.0",
66
- "n8n-workflow": "2.37.0"
60
+ "@n8n/agents": "0.23.0",
61
+ "@n8n/api-types": "1.38.0",
62
+ "@n8n/workflow-sdk": "0.31.0",
63
+ "@n8n/utils": "1.46.0",
64
+ "@n8n/mcp-browser": "0.20.0",
65
+ "n8n-workflow": "2.38.0",
66
+ "@n8n/ai-utilities": "0.31.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@langchain/anthropic": "1.5.6",
@@ -82,7 +82,7 @@
82
82
  "vitest": "^4.1.9",
83
83
  "vitest-mock-extended": "^3.1.0",
84
84
  "@n8n/vitest-config": "1.21.0",
85
- "@n8n/typescript-config": "1.10.0"
85
+ "@n8n/typescript-config": "1.11.0"
86
86
  },
87
87
  "license": "SEE LICENSE IN LICENSE.md",
88
88
  "homepage": "https://n8n.io",
@@ -49,8 +49,8 @@ and interactive tools.
49
49
 
50
50
  ## Prerequisites
51
51
 
52
- Before the first `build-agent` call, create every prerequisite the builder
53
- cannot create:
52
+ Before the first `build-agent` call, create prerequisites the builder cannot
53
+ create when they must be attached to or used by the Agent:
54
54
 
55
55
  - Create a workflow tool only when one Agent tool call must run an ordered
56
56
  multi-node procedure, or when the user explicitly needs that workflow to be
@@ -64,8 +64,27 @@ List prerequisite names and schemas in `message`. Let the builder gather the
64
64
  remaining Agent-specific requirements, including model, credentials,
65
65
  integrations, and direct tools.
66
66
 
67
- If a `builderReply` lists missing workflows or tables, create them and call
68
- `build-agent` again. Never ask the user to create them manually.
67
+ `build-agent` can return structured `requiredArtifacts` when the embedded
68
+ builder discovers something Instance AI must create:
69
+
70
+ - For a workflow with `relationship: "agent-tool"`, build it, pass it in
71
+ `workflowContext`, and call `build-agent` again so the builder can attach it.
72
+ - For a workflow with `relationship: "agent-entrypoint"`, build it after the
73
+ Agent exists, using the returned `agentId`. This workflow invokes the Agent;
74
+ never pass it in `workflowContext`, never attach it to the Agent as a tool,
75
+ and do not call `build-agent` again solely to attach it.
76
+ - For a data table, create it and call `build-agent` again with its name and
77
+ schema in `message`.
78
+
79
+ For an unsupported chat channel, an `agent-entrypoint` workflow should connect
80
+ the platform trigger to Message an Agent, map the incoming message, use a
81
+ stable platform conversation/sender identifier as the custom session key, and
82
+ send the Agent's `text` response through the platform. Native Agent channels do
83
+ not need this wrapper.
84
+
85
+ If an older builder only lists missing workflows or tables in `builderReply`,
86
+ handle them the same way based on whether the workflow calls the Agent or is
87
+ called by the Agent. Never ask the user to create prerequisites manually.
69
88
 
70
89
  ## Targeting across turns
71
90
 
@@ -85,22 +104,16 @@ Naming or renaming the current Agent never silently creates another one.
85
104
  ## Saved sub-agent dependencies
86
105
 
87
106
  When the user asks for an Agent that uses other newly built Agents as saved
88
- sub-agents, treat publication as a dependency:
107
+ sub-agents:
89
108
 
90
109
  1. Build each child Agent under its own `agentRef` before attaching it to the
91
110
  parent.
92
- 2. A saved sub-agent must be published before the parent can attach it. Building
93
- the child does not imply publication. Never attach a draft child or pass its
94
- raw `agentId` to the parent builder as a user requirement.
95
- 3. If the user already asked to publish, activate, or make the Agents usable,
96
- call `build-agent` for the child and faithfully forward that publication
97
- intent. Otherwise, ask whether to publish the child before continuing with
98
- the parent attachment.
99
- 4. Wait for the child publication to succeed. Then call `build-agent` for the
100
- parent and identify the child by its display name. The parent builder must
101
- discover the published child and map its name to the valid stored ID.
102
- 5. If publication is declined or fails, leave the child unattached and explain
103
- that saved sub-agents must be published first.
111
+ 2. Call `build-agent` for the parent and identify the child by its display name.
112
+ The parent builder must discover the saved child and map its name to the
113
+ valid stored ID. Do not pass a raw `agentId` as a user requirement.
114
+ 3. Publication is not required for saved sub-agent delegation. Forward
115
+ publication intent only when the user explicitly asks to publish or activate
116
+ an Agent.
104
117
 
105
118
  ## Builder-owned interactions
106
119