hobots 3.2.2 → 3.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.
package/dist/index.d.cts CHANGED
@@ -339,6 +339,51 @@ interface RunItemOptions {
339
339
  */
340
340
  id?: string;
341
341
  }
342
+ /**
343
+ * O item em processamento dentro de `items.each`: o desfecho (`succeeded`/`failed`/
344
+ * `occurrence`) com o `id` e o payload base já resolvidos, e a step da etapa para quem
345
+ * quiser medir sub-etapas (`item.step.startChild(...)`). Sem chamada explícita, o SDK
346
+ * decide: retornou → `succeeded`; lançou → `failed` com a mensagem do erro.
347
+ */
348
+ interface RunItemHandle {
349
+ /** Posição do elemento na lista (0-based). */
350
+ readonly index: number;
351
+ /** Identidade de negócio resolvida por `options.id` (undefined = o SDK gera uma). */
352
+ readonly id: string | undefined;
353
+ /** Step desta etapa no waterfall de performance; undefined fora de uma execução. */
354
+ readonly step: Step | undefined;
355
+ /** true depois do primeiro desfecho registrado (o SDK não sobrescreve o que o handler decidiu). */
356
+ readonly reported: boolean;
357
+ /** Item processado com sucesso. `payload` é mesclado sobre o payload base de `options.payload`. */
358
+ succeeded(payload?: Record<string, unknown>): void;
359
+ /** Falha sem lançar — o loop segue igual; a step vira `error` com o motivo. */
360
+ failed(message: string, payload?: Record<string, unknown>): void;
361
+ /** Ocorrência de negócio — a step vira `warning` com o motivo. */
362
+ occurrence(message: string, payload?: Record<string, unknown>): void;
363
+ }
364
+ interface RunItemsEachOptions<T> {
365
+ /** Identidade de negócio do item (ex.: nº do cliente). Omitido/null: o SDK gera um id único. */
366
+ id?: (element: T, index: number) => string | number | null | undefined;
367
+ /** Atributos base do item (viram colunas no app) — presentes em qualquer desfecho, inclusive falha. */
368
+ payload?: (element: T, index: number) => Record<string, unknown> | undefined;
369
+ /** `op` da step de cada item no waterfall. Default: 'item'. */
370
+ op?: string;
371
+ /** Descrição da step de cada item. Default: o `id`, senão `#<posição>`. */
372
+ description?: (element: T, index: number) => string;
373
+ /**
374
+ * Progresso automático: declara o total (tamanho da lista, se o bot ainda não declarou um)
375
+ * e avança a cada elemento. `false` deixa o progresso por conta do bot. Default: true.
376
+ */
377
+ progress?: boolean;
378
+ }
379
+ /** Totalizadores do `items.each`, pelo desfecho final de cada elemento. */
380
+ interface RunItemsEachResult {
381
+ total: number;
382
+ succeeded: number;
383
+ failed: number;
384
+ occurrence: number;
385
+ }
386
+ type RunItemsEachHandler<T> = (element: T, item: RunItemHandle, index: number) => unknown;
342
387
  /**
343
388
  * Registro dos itens que a execução processou/gerou (a entrega do bot: notas
344
389
  * fiscais baixadas, boletos emitidos...). Chamadas são síncronas — os itens são
@@ -359,6 +404,15 @@ interface RunItems {
359
404
  failed(message: string, payload?: Record<string, unknown>, options?: RunItemOptions): void;
360
405
  /** Ocorrência de negócio (ex.: "nota nº 10 não encontrada") — não é falha do bot. */
361
406
  occurrence(message: string, payload?: Record<string, unknown>, options?: RunItemOptions): void;
407
+ /**
408
+ * Processa uma lista item a item com o contrato da plataforma garantido pelo SDK: cada
409
+ * elemento vira uma step e um item; uma exceção no handler registra o item como `failed`
410
+ * (com a mensagem do erro), marca a step com `setError` e **segue para o próximo** — a
411
+ * lista inteira é processada, e o progresso avança a cada elemento. Só cancelamento,
412
+ * timeout e shutdown interrompem o loop (o erro sobe como em qualquer ponto de parada).
413
+ * Resolve com os totalizadores por desfecho.
414
+ */
415
+ each<T>(list: Iterable<T> | AsyncIterable<T>, handler: RunItemsEachHandler<T>, options?: RunItemsEachOptions<T>): Promise<RunItemsEachResult>;
362
416
  }
363
417
  /**
364
418
  * Progresso da execução (itens processados / total) — opcional e independente de
@@ -445,4 +499,4 @@ declare const close: (timeoutMs?: number) => Promise<boolean>;
445
499
  declare const captureException: (error: unknown, hint?: CaptureHint) => string | undefined;
446
500
  declare const retry: <T>(fn: (attempt: number) => T | Promise<T>, options?: RetryOptions) => Promise<T>;
447
501
 
448
- export { type AttachFailureReason, type AttachInput, type AttachOptions, type AttachResult, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventPayload, EventType, HeartbeatPayload, type Hobots, type HobotsOptions, type ItemColumnInput, MachineSnapshot, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunItemOptions, RunItemStatus, type RunItems, RunLogLevel, type RunLogger, RunProgress, type RunProgressReporter, type StartOptions, Step, StepData, StepStatus, type TaskHandler, type TaskItemsOptions, type TaskOptions, Transaction, TransactionPayload, captureException, close, hobots as default, hobots, register, retry, start };
502
+ export { type AttachFailureReason, type AttachInput, type AttachOptions, type AttachResult, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventPayload, EventType, HeartbeatPayload, type Hobots, type HobotsOptions, type ItemColumnInput, MachineSnapshot, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunItemHandle, type RunItemOptions, RunItemStatus, type RunItems, type RunItemsEachHandler, type RunItemsEachOptions, type RunItemsEachResult, RunLogLevel, type RunLogger, RunProgress, type RunProgressReporter, type StartOptions, Step, StepData, StepStatus, type TaskHandler, type TaskItemsOptions, type TaskOptions, Transaction, TransactionPayload, captureException, close, hobots as default, hobots, register, retry, start };
package/dist/index.d.ts CHANGED
@@ -339,6 +339,51 @@ interface RunItemOptions {
339
339
  */
340
340
  id?: string;
341
341
  }
342
+ /**
343
+ * O item em processamento dentro de `items.each`: o desfecho (`succeeded`/`failed`/
344
+ * `occurrence`) com o `id` e o payload base já resolvidos, e a step da etapa para quem
345
+ * quiser medir sub-etapas (`item.step.startChild(...)`). Sem chamada explícita, o SDK
346
+ * decide: retornou → `succeeded`; lançou → `failed` com a mensagem do erro.
347
+ */
348
+ interface RunItemHandle {
349
+ /** Posição do elemento na lista (0-based). */
350
+ readonly index: number;
351
+ /** Identidade de negócio resolvida por `options.id` (undefined = o SDK gera uma). */
352
+ readonly id: string | undefined;
353
+ /** Step desta etapa no waterfall de performance; undefined fora de uma execução. */
354
+ readonly step: Step | undefined;
355
+ /** true depois do primeiro desfecho registrado (o SDK não sobrescreve o que o handler decidiu). */
356
+ readonly reported: boolean;
357
+ /** Item processado com sucesso. `payload` é mesclado sobre o payload base de `options.payload`. */
358
+ succeeded(payload?: Record<string, unknown>): void;
359
+ /** Falha sem lançar — o loop segue igual; a step vira `error` com o motivo. */
360
+ failed(message: string, payload?: Record<string, unknown>): void;
361
+ /** Ocorrência de negócio — a step vira `warning` com o motivo. */
362
+ occurrence(message: string, payload?: Record<string, unknown>): void;
363
+ }
364
+ interface RunItemsEachOptions<T> {
365
+ /** Identidade de negócio do item (ex.: nº do cliente). Omitido/null: o SDK gera um id único. */
366
+ id?: (element: T, index: number) => string | number | null | undefined;
367
+ /** Atributos base do item (viram colunas no app) — presentes em qualquer desfecho, inclusive falha. */
368
+ payload?: (element: T, index: number) => Record<string, unknown> | undefined;
369
+ /** `op` da step de cada item no waterfall. Default: 'item'. */
370
+ op?: string;
371
+ /** Descrição da step de cada item. Default: o `id`, senão `#<posição>`. */
372
+ description?: (element: T, index: number) => string;
373
+ /**
374
+ * Progresso automático: declara o total (tamanho da lista, se o bot ainda não declarou um)
375
+ * e avança a cada elemento. `false` deixa o progresso por conta do bot. Default: true.
376
+ */
377
+ progress?: boolean;
378
+ }
379
+ /** Totalizadores do `items.each`, pelo desfecho final de cada elemento. */
380
+ interface RunItemsEachResult {
381
+ total: number;
382
+ succeeded: number;
383
+ failed: number;
384
+ occurrence: number;
385
+ }
386
+ type RunItemsEachHandler<T> = (element: T, item: RunItemHandle, index: number) => unknown;
342
387
  /**
343
388
  * Registro dos itens que a execução processou/gerou (a entrega do bot: notas
344
389
  * fiscais baixadas, boletos emitidos...). Chamadas são síncronas — os itens são
@@ -359,6 +404,15 @@ interface RunItems {
359
404
  failed(message: string, payload?: Record<string, unknown>, options?: RunItemOptions): void;
360
405
  /** Ocorrência de negócio (ex.: "nota nº 10 não encontrada") — não é falha do bot. */
361
406
  occurrence(message: string, payload?: Record<string, unknown>, options?: RunItemOptions): void;
407
+ /**
408
+ * Processa uma lista item a item com o contrato da plataforma garantido pelo SDK: cada
409
+ * elemento vira uma step e um item; uma exceção no handler registra o item como `failed`
410
+ * (com a mensagem do erro), marca a step com `setError` e **segue para o próximo** — a
411
+ * lista inteira é processada, e o progresso avança a cada elemento. Só cancelamento,
412
+ * timeout e shutdown interrompem o loop (o erro sobe como em qualquer ponto de parada).
413
+ * Resolve com os totalizadores por desfecho.
414
+ */
415
+ each<T>(list: Iterable<T> | AsyncIterable<T>, handler: RunItemsEachHandler<T>, options?: RunItemsEachOptions<T>): Promise<RunItemsEachResult>;
362
416
  }
363
417
  /**
364
418
  * Progresso da execução (itens processados / total) — opcional e independente de
@@ -445,4 +499,4 @@ declare const close: (timeoutMs?: number) => Promise<boolean>;
445
499
  declare const captureException: (error: unknown, hint?: CaptureHint) => string | undefined;
446
500
  declare const retry: <T>(fn: (attempt: number) => T | Promise<T>, options?: RetryOptions) => Promise<T>;
447
501
 
448
- export { type AttachFailureReason, type AttachInput, type AttachOptions, type AttachResult, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventPayload, EventType, HeartbeatPayload, type Hobots, type HobotsOptions, type ItemColumnInput, MachineSnapshot, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunItemOptions, RunItemStatus, type RunItems, RunLogLevel, type RunLogger, RunProgress, type RunProgressReporter, type StartOptions, Step, StepData, StepStatus, type TaskHandler, type TaskItemsOptions, type TaskOptions, Transaction, TransactionPayload, captureException, close, hobots as default, hobots, register, retry, start };
502
+ export { type AttachFailureReason, type AttachInput, type AttachOptions, type AttachResult, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventPayload, EventType, HeartbeatPayload, type Hobots, type HobotsOptions, type ItemColumnInput, MachineSnapshot, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunItemHandle, type RunItemOptions, RunItemStatus, type RunItems, type RunItemsEachHandler, type RunItemsEachOptions, type RunItemsEachResult, RunLogLevel, type RunLogger, RunProgress, type RunProgressReporter, type StartOptions, Step, StepData, StepStatus, type TaskHandler, type TaskItemsOptions, type TaskOptions, Transaction, TransactionPayload, captureException, close, hobots as default, hobots, register, retry, start };
package/dist/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ import {
2
+ WIRE_LIMITS
3
+ } from "./chunk-5WIIACWC.js";
4
+
1
5
  // src/stacktrace.ts
2
6
  var MAX_FRAMES = 50;
3
7
  var MAX_FILENAME_CHARS = 1024;
@@ -53,7 +57,7 @@ function scrubSecrets(text) {
53
57
 
54
58
  // src/utils.ts
55
59
  var SDK_NAME = "hobots";
56
- var SDK_VERSION = true ? "3.2.2" : "0.0.0-dev";
60
+ var SDK_VERSION = true ? "3.3.0" : "0.0.0-dev";
57
61
  function isNode() {
58
62
  return typeof process !== "undefined" && typeof process.versions?.node === "string";
59
63
  }
@@ -232,7 +236,7 @@ var REQUEST_TIMEOUT_MS = 1e4;
232
236
  var DEFAULT_FLUSH_INTERVAL_MS = 2e3;
233
237
  var DEFAULT_MAX_BATCH_SIZE = 10;
234
238
  var DEFAULT_MAX_QUEUE_SIZE = 200;
235
- var MAX_ITEMS_PER_ENVELOPE = 50;
239
+ var MAX_ITEMS_PER_ENVELOPE = WIRE_LIMITS.MAX_ITEMS_PER_ENVELOPE;
236
240
  var Transport = class {
237
241
  endpoint;
238
242
  key;
@@ -556,9 +560,9 @@ async function fallbackInstanceId() {
556
560
  }
557
561
 
558
562
  // src/heartbeat.ts
559
- var DEFAULT_INTERVAL_MS = 3e4;
560
- var MIN_REPORTED_INTERVAL_MS = 1e3;
561
- var MAX_REPORTED_INTERVAL_MS = 9e5;
563
+ var DEFAULT_INTERVAL_MS = WIRE_LIMITS.HEARTBEAT_DEFAULT_INTERVAL_MS;
564
+ var MIN_REPORTED_INTERVAL_MS = WIRE_LIMITS.HEARTBEAT_MIN_INTERVAL_MS;
565
+ var MAX_REPORTED_INTERVAL_MS = WIRE_LIMITS.HEARTBEAT_MAX_INTERVAL_MS;
562
566
  var Heartbeat = class {
563
567
  constructor(client, options = {}, instanceId, sampler) {
564
568
  this.client = client;
@@ -1118,6 +1122,88 @@ function isTerminalError(error) {
1118
1122
  return error instanceof Error && TERMINAL_ERROR_NAMES.has(error.name);
1119
1123
  }
1120
1124
 
1125
+ // src/tasks/each.ts
1126
+ function thrownMessage(error) {
1127
+ if (error instanceof Error) return error.message || error.name;
1128
+ return safeString(error);
1129
+ }
1130
+ var ItemHandle = class {
1131
+ constructor(index, id, step, basePayload, sink) {
1132
+ this.index = index;
1133
+ this.id = id;
1134
+ this.step = step;
1135
+ this.basePayload = basePayload;
1136
+ this.sink = sink;
1137
+ }
1138
+ index;
1139
+ id;
1140
+ step;
1141
+ basePayload;
1142
+ sink;
1143
+ reported = false;
1144
+ status;
1145
+ succeeded(payload) {
1146
+ this.record("succeeded", void 0, payload);
1147
+ }
1148
+ failed(message, payload) {
1149
+ this.record("failed", message, payload);
1150
+ if (this.step && this.step.status !== "error") this.step.setStatus("error", message);
1151
+ }
1152
+ occurrence(message, payload) {
1153
+ this.record("occurrence", message, payload);
1154
+ if (this.step && this.step.status === "ok") this.step.setStatus("warning", message);
1155
+ }
1156
+ record(status, message, payload) {
1157
+ this.reported = true;
1158
+ this.status = status;
1159
+ const merged = { ...this.basePayload ?? {}, ...payload ?? {} };
1160
+ this.sink.report(status, message, Object.keys(merged).length > 0 ? merged : void 0, this.id);
1161
+ }
1162
+ };
1163
+ function resolveId(options, element, index) {
1164
+ const raw = options.id?.(element, index);
1165
+ if (raw === null || raw === void 0) return void 0;
1166
+ const text = safeString(raw);
1167
+ return text.length > 0 ? text : void 0;
1168
+ }
1169
+ function knownLength(list) {
1170
+ const length = list?.length;
1171
+ return typeof length === "number" && Number.isInteger(length) && length >= 1 ? length : void 0;
1172
+ }
1173
+ async function eachItem(list, handler, options, sink) {
1174
+ const result = { total: 0, succeeded: 0, failed: 0, occurrence: 0 };
1175
+ const length = options.progress === false ? void 0 : knownLength(list);
1176
+ if (length !== void 0) sink.declareTotal(length);
1177
+ let index = 0;
1178
+ for await (const element of list) {
1179
+ sink.checkCanceled();
1180
+ const id = resolveId(options, element, index);
1181
+ const description = options.description?.(element, index) ?? id ?? `#${index + 1}`;
1182
+ const step = sink.startStep(options.op ?? "item", description);
1183
+ const handle = new ItemHandle(index, id, step, options.payload?.(element, index), sink);
1184
+ try {
1185
+ await handler(element, handle, index);
1186
+ if (!handle.reported) handle.succeeded();
1187
+ } catch (error) {
1188
+ if (isTerminalError(error) || sink.isAborted()) {
1189
+ step?.setStatus("cancelled");
1190
+ step?.finish();
1191
+ throw error;
1192
+ }
1193
+ const message = thrownMessage(error);
1194
+ if (!handle.reported) handle.failed(message);
1195
+ step?.setError(error);
1196
+ sink.logError(`item ${description} falhou: ${message}`);
1197
+ }
1198
+ step?.finish();
1199
+ if (options.progress !== false) sink.advance();
1200
+ result.total += 1;
1201
+ result[handle.status ?? "succeeded"] += 1;
1202
+ index += 1;
1203
+ }
1204
+ return result;
1205
+ }
1206
+
1121
1207
  // src/retry.ts
1122
1208
  var DEFAULT_RETRIES = 3;
1123
1209
  var DEFAULT_DELAY_MS = 1e3;
@@ -1145,10 +1231,11 @@ async function retryWithBackoff(fn, options = {}) {
1145
1231
  }
1146
1232
 
1147
1233
  // src/tasks/attachments.ts
1148
- var MAX_ATTACHMENT_BYTES = 5242880;
1149
- var MAX_ATTACHMENTS_PER_RUN = 20;
1234
+ var MAX_ATTACHMENT_BYTES = WIRE_LIMITS.MAX_ATTACHMENT_BYTES;
1235
+ var MAX_ATTACHMENTS_PER_RUN = WIRE_LIMITS.MAX_ATTACHMENTS_PER_RUN;
1236
+ var MAX_ATTACHMENTS_PER_LOG_ENTRY = WIRE_LIMITS.MAX_ATTACHMENTS_PER_LOG_ENTRY;
1150
1237
  var MAX_CONCURRENT_UPLOADS = 3;
1151
- var MAX_CAPTION_CHARS = 200;
1238
+ var MAX_CAPTION_CHARS = WIRE_LIMITS.MAX_CAPTION_CHARS;
1152
1239
  var ATTACHMENT_DRAIN_MS = 15e3;
1153
1240
  async function readImageFile(path) {
1154
1241
  if (!isNode()) {
@@ -1162,7 +1249,7 @@ function startsWith(bytes, signature, offset = 0) {
1162
1249
  return signature.every((byte, index) => bytes[offset + index] === byte);
1163
1250
  }
1164
1251
  var PNG_MAGIC = [137, 80, 78, 71, 13, 10, 26, 10];
1165
- var MAX_PNG_DIMENSION = 2e4;
1252
+ var MAX_PNG_DIMENSION = WIRE_LIMITS.MAX_IMAGE_DIMENSION_PX;
1166
1253
  var JPEG_MAGIC = [255, 216, 255];
1167
1254
  var RIFF_MAGIC = [82, 73, 70, 70];
1168
1255
  var WEBP_MAGIC = [87, 69, 66, 80];
@@ -1225,13 +1312,13 @@ var DEFAULT_LOG_FLUSH_INTERVAL_MS = 2e3;
1225
1312
  var DEFAULT_CANCEL_CHECK_INTERVAL_MS = 5e3;
1226
1313
  var MIN_CANCEL_CHECK_INTERVAL_MS = 1e3;
1227
1314
  var MAX_CANCEL_CHECK_INTERVAL_MS = 15e3;
1228
- var MAX_LOG_MESSAGE_CHARS = 1e4;
1229
- var MAX_LOGS_PER_PATCH = 100;
1315
+ var MAX_LOG_MESSAGE_CHARS = WIRE_LIMITS.MAX_LOG_MESSAGE_CHARS;
1316
+ var MAX_LOGS_PER_PATCH = WIRE_LIMITS.MAX_LOGS_PER_PATCH;
1230
1317
  var FLUSH_AT_BUFFERED = 20;
1231
- var MAX_ITEMS_PER_RUN = 1e4;
1232
- var MAX_ITEMS_PER_REQUEST = 500;
1233
- var MAX_ITEM_MESSAGE_CHARS = 2e3;
1234
- var MAX_ITEM_PAYLOAD_BYTES = 16384;
1318
+ var MAX_ITEMS_PER_RUN = WIRE_LIMITS.MAX_ITEMS_PER_RUN;
1319
+ var MAX_ITEMS_PER_REQUEST = WIRE_LIMITS.MAX_ITEMS_PER_REQUEST;
1320
+ var MAX_ITEM_MESSAGE_CHARS = WIRE_LIMITS.MAX_ITEM_MESSAGE_CHARS;
1321
+ var MAX_ITEM_PAYLOAD_BYTES = WIRE_LIMITS.MAX_ITEM_PAYLOAD_BYTES;
1235
1322
  var ITEMS_FLUSH_AT_BUFFERED = 100;
1236
1323
  var ITEMS_DRAIN_MS = 15e3;
1237
1324
  var PROGRESS_FLUSH_MS = 1e3;
@@ -1265,6 +1352,17 @@ var RunReporter = class {
1265
1352
  tx.setLifecycleSink((level, message) => this.push(level, message));
1266
1353
  const checkCanceled = () => this.checkCanceled();
1267
1354
  tx.setStepGuard(checkCanceled);
1355
+ const eachSink = {
1356
+ report: (status, message, payload, id) => this.addItem(status, message, payload, id),
1357
+ startStep: (op, description) => tx.startChild(op, description),
1358
+ declareTotal: (total) => {
1359
+ if (this.progressTotal == null) this.setProgress(this.progressCurrent, total);
1360
+ },
1361
+ advance: () => this.setProgress(this.progressCurrent + 1, this.progressTotal),
1362
+ checkCanceled,
1363
+ isAborted: () => this.abortController.signal.aborted,
1364
+ logError: (message) => this.log("error", message)
1365
+ };
1268
1366
  const items = {
1269
1367
  add: (item) => {
1270
1368
  checkCanceled();
@@ -1281,7 +1379,8 @@ var RunReporter = class {
1281
1379
  occurrence: (message, payload, options) => {
1282
1380
  checkCanceled();
1283
1381
  this.addItem("occurrence", message, payload, options?.id);
1284
- }
1382
+ },
1383
+ each: (list, handler, options = {}) => eachItem(list, handler, options, eachSink)
1285
1384
  };
1286
1385
  const progress = Object.defineProperties(
1287
1386
  {
@@ -1426,7 +1525,7 @@ var RunReporter = class {
1426
1525
  ts,
1427
1526
  level,
1428
1527
  message: truncate(scrubbed, MAX_LOG_MESSAGE_CHARS),
1429
- ...attachments && attachments.length > 0 ? { attachments } : {}
1528
+ ...attachments && attachments.length > 0 ? { attachments: attachments.slice(0, WIRE_LIMITS.MAX_ATTACHMENTS_PER_LOG_ENTRY) } : {}
1430
1529
  });
1431
1530
  if (this.buffer.length >= FLUSH_AT_BUFFERED) {
1432
1531
  this.flushLogs();
@@ -2127,6 +2226,7 @@ async function executeRun(input) {
2127
2226
  await runWithRunContext({ reporter }, () => invokeWithRetry(task, run, reporter, logger));
2128
2227
  await reporter.finalizeAttachments();
2129
2228
  await reporter.finalizeItems();
2229
+ warnIncompleteProgress(reporter);
2130
2230
  tx.setStatus("ok");
2131
2231
  tx.finish();
2132
2232
  reporter.reportSuccess();
@@ -2144,6 +2244,13 @@ async function executeRun(input) {
2144
2244
  tracker.remove(reporter);
2145
2245
  }
2146
2246
  }
2247
+ function warnIncompleteProgress(reporter) {
2248
+ const snapshot = reporter.context.progress.snapshot;
2249
+ if (!snapshot || snapshot.current >= snapshot.total) return;
2250
+ reporter.context.log.warn(
2251
+ `execu\xE7\xE3o conclu\xEDda com progresso incompleto: ${snapshot.current}/${snapshot.total} \u2014 o handler terminou sem processar (ou sem avan\xE7ar) todos os itens previstos`
2252
+ );
2253
+ }
2147
2254
  function invokeWithRetry(task, run, reporter, logger) {
2148
2255
  const { retries, retryDelayMs } = task.options;
2149
2256
  const total = retries + 1;
@@ -2198,8 +2305,8 @@ function waitForCancelGrace(signal, graceMs) {
2198
2305
  signal.addEventListener("abort", () => setTimeout(resolve2, graceMs), { once: true });
2199
2306
  });
2200
2307
  }
2201
- var MAX_ERROR_MESSAGE_CHARS = 1e4;
2202
- var MAX_ERROR_STACK_CHARS = 2e4;
2308
+ var MAX_ERROR_MESSAGE_CHARS = WIRE_LIMITS.MAX_ERROR_MESSAGE_CHARS;
2309
+ var MAX_ERROR_STACK_CHARS = WIRE_LIMITS.MAX_ERROR_STACK_CHARS;
2203
2310
  function toRunError(error) {
2204
2311
  if (error instanceof Error) {
2205
2312
  return {
@@ -2214,7 +2321,7 @@ function toRunError(error) {
2214
2321
  // src/tasks/agent.ts
2215
2322
  var DEFAULT_POLL_INTERVAL_MS = 2e3;
2216
2323
  var MIN_POLL_INTERVAL_MS = 1e3;
2217
- var MAX_CLAIM_PER_POLL = 5;
2324
+ var MAX_CLAIM_PER_POLL = WIRE_LIMITS.MAX_CLAIM_PER_POLL;
2218
2325
  var TaskAgent = class {
2219
2326
  constructor(options) {
2220
2327
  this.options = options;
@@ -2349,8 +2456,8 @@ var TaskAgent = class {
2349
2456
 
2350
2457
  // src/tasks/item-columns.ts
2351
2458
  var KEY_RE = /^[a-zA-Z0-9_.-]{1,100}$/;
2352
- var MAX_COLUMNS = 12;
2353
- var MAX_LABEL_CHARS = 60;
2459
+ var MAX_COLUMNS = WIRE_LIMITS.MAX_ITEM_COLUMNS;
2460
+ var MAX_LABEL_CHARS = WIRE_LIMITS.MAX_ITEM_COLUMN_LABEL_CHARS;
2354
2461
  function normalizeItemColumns(slug, input, logger) {
2355
2462
  if (input === void 0 || input === null) return void 0;
2356
2463
  const columns = input.columns;
@@ -2858,7 +2965,22 @@ var fallbackLog = {
2858
2965
  success: (message, ...rest) => printRunLog(FALLBACK_TASK, "success", joinLogArgs(message, rest))
2859
2966
  };
2860
2967
  var noop = () => void 0;
2861
- var fallbackItems = { add: noop, succeeded: noop, failed: noop, occurrence: noop };
2968
+ var fallbackEachSink = {
2969
+ report: noop,
2970
+ startStep: () => void 0,
2971
+ declareTotal: noop,
2972
+ advance: noop,
2973
+ checkCanceled: noop,
2974
+ isAborted: () => false,
2975
+ logError: (message) => printRunLog(FALLBACK_TASK, "error", message)
2976
+ };
2977
+ var fallbackItems = {
2978
+ add: noop,
2979
+ succeeded: noop,
2980
+ failed: noop,
2981
+ occurrence: noop,
2982
+ each: (list, handler, options = {}) => eachItem(list, handler, options, fallbackEachSink)
2983
+ };
2862
2984
  var fallbackProgress = { total: noop, advance: noop, set: noop, current: 0, snapshot: null };
2863
2985
  var neverAborts = new AbortController().signal;
2864
2986
  var detachedTransaction;