hobots 4.0.0 → 4.2.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/README.md +33 -1
- package/dist/{chunk-5WIIACWC.js → chunk-HKCDMUA3.js} +1 -2
- package/dist/chunk-HKCDMUA3.js.map +1 -0
- package/dist/index.cjs +438 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -3
- package/dist/index.d.ts +64 -3
- package/dist/index.js +439 -31
- package/dist/index.js.map +1 -1
- package/dist/protocol.cjs +0 -1
- package/dist/protocol.cjs.map +1 -1
- package/dist/protocol.d.cts +39 -3
- package/dist/protocol.d.ts +39 -3
- package/dist/protocol.js +1 -1
- package/docs/api-reference.md +4 -1
- package/docs/protocol.md +12 -2
- package/docs/runs.md +60 -2
- package/package.json +1 -1
- package/dist/chunk-5WIIACWC.js.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RunAttachmentContentType, EventType, EnvironmentInput, MachineSnapshot, EventPayload, TransactionPayload, HeartbeatPayload, StepStatus, RunLogLevel, StepData, RunItemStatus, RunProgress } from './protocol.cjs';
|
|
2
|
-
export { Breadcrumb, BreadcrumbLevel, Envelope, EnvelopeItem, Environment, EventUser, ExceptionData, InstanceInfo, InstanceMode, ItemColumn, ItemsDeclaration, MachineProcess, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunCreateRequest, RunCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.cjs';
|
|
1
|
+
import { RunAttachmentContentType, EventType, EnvironmentInput, MachineSnapshot, EventPayload, TransactionPayload, HeartbeatPayload, StepStatus, RunLogLevel, StepData, FileRef, RunItemStatus, RunProgress } from './protocol.cjs';
|
|
2
|
+
export { Breadcrumb, BreadcrumbLevel, Envelope, EnvelopeItem, Environment, EventUser, ExceptionData, FileDownloadResponse, FileStorage, InstanceInfo, InstanceMode, ItemColumn, ItemsDeclaration, MachineProcess, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunCreateRequest, RunCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.cjs';
|
|
3
3
|
|
|
4
4
|
/** Espera entre tentativas: ms fixo ou função do número da tentativa que acabou de falhar (1-based). */
|
|
5
5
|
type RetryDelay = number | ((attempt: number) => number);
|
|
@@ -340,9 +340,53 @@ declare class Transaction {
|
|
|
340
340
|
setTag(key: string, value: string): this;
|
|
341
341
|
setStatus(status: string): this;
|
|
342
342
|
setName(name: string): this;
|
|
343
|
+
/**
|
|
344
|
+
* Envia já as steps raiz finalizadas (e todas as descendentes, fechando as que
|
|
345
|
+
* ficaram abertas) como transactions parciais da mesma run (`op` hobots.run.flush,
|
|
346
|
+
* `event_id` novo, até 200 steps cada) e as tira da memória. Steps raiz ainda abertas
|
|
347
|
+
* ficam para o próximo flush ou para o `finish()`. É assim que um agente sempre
|
|
348
|
+
* ligado (`start()`), cuja run não termina, entrega as etapas enquanto processa.
|
|
349
|
+
* Devolve quantas steps foram enviadas.
|
|
350
|
+
*/
|
|
351
|
+
flush(): number;
|
|
352
|
+
/** Entrega já (com teto) o que está na fila do transport — as transactions parciais inclusive. */
|
|
353
|
+
drain(timeoutMs: number): Promise<void>;
|
|
354
|
+
private payload;
|
|
343
355
|
finish(): void;
|
|
344
356
|
}
|
|
345
357
|
|
|
358
|
+
interface FileDownloadOptions {
|
|
359
|
+
/**
|
|
360
|
+
* Destino da cópia: uma pasta existente (ou terminada em `/`) recebe o arquivo com o nome
|
|
361
|
+
* original; qualquer outro caminho é o arquivo final. Omitido: pasta temporária da
|
|
362
|
+
* execução, apagada quando ela termina.
|
|
363
|
+
*/
|
|
364
|
+
dest?: string;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Arquivos dos campos de upload do formulário (`hobots.files`). O valor do campo nos
|
|
368
|
+
* params é um `FileRef` (ou uma lista deles); `download` traz o arquivo para o disco
|
|
369
|
+
* desta máquina — do S3 (enviado pela Central) ou da pasta do Studio (mesmo computador)
|
|
370
|
+
* — e o consome na origem: cada arquivo é baixado uma vez.
|
|
371
|
+
*/
|
|
372
|
+
interface RunFiles {
|
|
373
|
+
/** Todos os arquivos dos params (campos de topo, valor único ou lista), na ordem dos campos. */
|
|
374
|
+
list(): FileRef[];
|
|
375
|
+
/** O arquivo do campo (campo único), a lista (campo "vários arquivos") ou undefined. */
|
|
376
|
+
get(field: string): FileRef | FileRef[] | undefined;
|
|
377
|
+
/**
|
|
378
|
+
* Baixa um arquivo e resolve com o caminho local. Aceita o `FileRef` ou o nome de um
|
|
379
|
+
* campo de arquivo único (para campo com vários arquivos, use `downloadAll`). Só depois
|
|
380
|
+
* da cópia completa e conferida o arquivo é consumido na origem — uma falha não perde
|
|
381
|
+
* nada e pode ser tentada de novo. Respeita o cancelamento da execução.
|
|
382
|
+
*/
|
|
383
|
+
download(refOrField: FileRef | string, options?: FileDownloadOptions): Promise<string>;
|
|
384
|
+
/** Baixa todos os arquivos do campo (único ou lista), em ordem. `dest` aqui é uma pasta. */
|
|
385
|
+
downloadAll(field: string, options?: FileDownloadOptions): Promise<string[]>;
|
|
386
|
+
/** Conteúdo do arquivo em memória — baixa, lê e apaga a cópia temporária. */
|
|
387
|
+
read(refOrField: FileRef | string): Promise<Buffer>;
|
|
388
|
+
}
|
|
389
|
+
|
|
346
390
|
/**
|
|
347
391
|
* `hobots.log`: cada método aceita vários argumentos, como `console.log` — cada um vira
|
|
348
392
|
* texto (`safeString`) e são unidos por espaço. Nunca lança, nem com a run cancelada.
|
|
@@ -483,12 +527,26 @@ interface RunContext {
|
|
|
483
527
|
readonly items: RunItems;
|
|
484
528
|
/** Progresso declarado (barra + ETA no app) — opcional, independente de `items` */
|
|
485
529
|
readonly progress: RunProgressReporter;
|
|
530
|
+
/**
|
|
531
|
+
* Arquivos dos campos de upload do formulário: `list()`, `get(campo)`, `download(refOuCampo)`
|
|
532
|
+
* (caminho local), `downloadAll(campo)` e `read(refOuCampo)` (conteúdo em memória).
|
|
533
|
+
* Cada arquivo é consumido na origem ao ser baixado — baixe uma vez e reaproveite a cópia.
|
|
534
|
+
*/
|
|
535
|
+
readonly files: RunFiles;
|
|
486
536
|
/**
|
|
487
537
|
* Transaction de performance desta execução — já correlacionada à run e finalizada
|
|
488
538
|
* automaticamente ao fim do handler. Use `transaction.startChild(op, description)` para
|
|
489
539
|
* medir as etapas (steps); elas aparecem como waterfall na aba de performance da execução.
|
|
490
540
|
*/
|
|
491
541
|
readonly transaction: Transaction;
|
|
542
|
+
/**
|
|
543
|
+
* Entrega já o que a execução fez: as steps raiz finalizadas viram transactions parciais
|
|
544
|
+
* (waterfall da Central sem esperar a run terminar) e itens, logs e progresso pendentes
|
|
545
|
+
* saem sem esperar o throttle. Quem decide quando chamar é o bot — num agente sempre
|
|
546
|
+
* ligado (`start()`), ao fim de cada rodada que processou itens. Aguarda a entrega com
|
|
547
|
+
* teto (`timeoutMs`, default 15s) e nunca lança.
|
|
548
|
+
*/
|
|
549
|
+
flush(timeoutMs?: number): Promise<void>;
|
|
492
550
|
/** Dispara em cancelamento (run cancelada no app), timeout ou shutdown — cancelamento cooperativo */
|
|
493
551
|
readonly signal: AbortSignal;
|
|
494
552
|
/**
|
|
@@ -527,6 +585,8 @@ interface Hobots extends RunContext {
|
|
|
527
585
|
* `step.setError(err, undefined, { image: png })`. Puro: nenhum I/O até o evento ser registrado.
|
|
528
586
|
*/
|
|
529
587
|
image(input: AttachInput, options?: ImageOptions): ImageAttachment;
|
|
588
|
+
/** O valor tem a forma de um arquivo de campo de upload (`FileRef`) — puro, sem I/O. */
|
|
589
|
+
isFileRef(value: unknown): value is FileRef;
|
|
530
590
|
}
|
|
531
591
|
declare global {
|
|
532
592
|
var hobots: Hobots;
|
|
@@ -538,5 +598,6 @@ declare const close: (timeoutMs?: number) => Promise<boolean>;
|
|
|
538
598
|
declare const captureException: (error: unknown, hint?: CaptureHint) => string | undefined;
|
|
539
599
|
declare const retry: <T>(fn: (attempt: number) => T | Promise<T>, options?: RetryOptions) => Promise<T>;
|
|
540
600
|
declare const image: (input: AttachInput, options?: ImageOptions) => ImageAttachment;
|
|
601
|
+
declare const isFileRef: (value: unknown) => value is FileRef;
|
|
541
602
|
|
|
542
|
-
export { type AttachInput, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventPayload, EventType, HeartbeatPayload, type Hobots, type HobotsOptions, ImageAttachment, type ImageInput, type ImageOptions, type ItemColumnInput, type ItemsOptions, MachineSnapshot, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunHandler, type RunItemHandle, type RunItemImageOptions, type RunItemOptions, RunItemStatus, type RunItems, type RunItemsEachHandler, type RunItemsEachOptions, type RunItemsEachResult, RunLogLevel, type RunLogger, type RunOptions, RunProgress, type RunProgressReporter, type StartOptions, Step, StepData, type StepOutcomeOptions, StepStatus, Transaction, TransactionPayload, captureException, close, hobots as default, hobots, image, register, retry, start };
|
|
603
|
+
export { type AttachInput, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventPayload, EventType, type FileDownloadOptions, FileRef, HeartbeatPayload, type Hobots, type HobotsOptions, ImageAttachment, type ImageInput, type ImageOptions, type ItemColumnInput, type ItemsOptions, MachineSnapshot, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunFiles, type RunHandler, type RunItemHandle, type RunItemImageOptions, type RunItemOptions, RunItemStatus, type RunItems, type RunItemsEachHandler, type RunItemsEachOptions, type RunItemsEachResult, RunLogLevel, type RunLogger, type RunOptions, RunProgress, type RunProgressReporter, type StartOptions, Step, StepData, type StepOutcomeOptions, StepStatus, Transaction, TransactionPayload, captureException, close, hobots as default, hobots, image, isFileRef, register, retry, start };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RunAttachmentContentType, EventType, EnvironmentInput, MachineSnapshot, EventPayload, TransactionPayload, HeartbeatPayload, StepStatus, RunLogLevel, StepData, RunItemStatus, RunProgress } from './protocol.js';
|
|
2
|
-
export { Breadcrumb, BreadcrumbLevel, Envelope, EnvelopeItem, Environment, EventUser, ExceptionData, InstanceInfo, InstanceMode, ItemColumn, ItemsDeclaration, MachineProcess, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunCreateRequest, RunCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.js';
|
|
1
|
+
import { RunAttachmentContentType, EventType, EnvironmentInput, MachineSnapshot, EventPayload, TransactionPayload, HeartbeatPayload, StepStatus, RunLogLevel, StepData, FileRef, RunItemStatus, RunProgress } from './protocol.js';
|
|
2
|
+
export { Breadcrumb, BreadcrumbLevel, Envelope, EnvelopeItem, Environment, EventUser, ExceptionData, FileDownloadResponse, FileStorage, InstanceInfo, InstanceMode, ItemColumn, ItemsDeclaration, MachineProcess, PollRequest, PollResponse, RunAttachmentConfirmRequest, RunAttachmentConfirmResponse, RunAttachmentCreateRequest, RunAttachmentCreateResponse, RunCreateRequest, RunCreateResponse, RunDescriptor, RunError, RunItemInput, RunItemsCreateRequest, RunItemsCreateResponse, RunLogEntry, RunStatus, RunUpdateRequest, RunUpdateResponse, RunUpdateStatus, StackFrame } from './protocol.js';
|
|
3
3
|
|
|
4
4
|
/** Espera entre tentativas: ms fixo ou função do número da tentativa que acabou de falhar (1-based). */
|
|
5
5
|
type RetryDelay = number | ((attempt: number) => number);
|
|
@@ -340,9 +340,53 @@ declare class Transaction {
|
|
|
340
340
|
setTag(key: string, value: string): this;
|
|
341
341
|
setStatus(status: string): this;
|
|
342
342
|
setName(name: string): this;
|
|
343
|
+
/**
|
|
344
|
+
* Envia já as steps raiz finalizadas (e todas as descendentes, fechando as que
|
|
345
|
+
* ficaram abertas) como transactions parciais da mesma run (`op` hobots.run.flush,
|
|
346
|
+
* `event_id` novo, até 200 steps cada) e as tira da memória. Steps raiz ainda abertas
|
|
347
|
+
* ficam para o próximo flush ou para o `finish()`. É assim que um agente sempre
|
|
348
|
+
* ligado (`start()`), cuja run não termina, entrega as etapas enquanto processa.
|
|
349
|
+
* Devolve quantas steps foram enviadas.
|
|
350
|
+
*/
|
|
351
|
+
flush(): number;
|
|
352
|
+
/** Entrega já (com teto) o que está na fila do transport — as transactions parciais inclusive. */
|
|
353
|
+
drain(timeoutMs: number): Promise<void>;
|
|
354
|
+
private payload;
|
|
343
355
|
finish(): void;
|
|
344
356
|
}
|
|
345
357
|
|
|
358
|
+
interface FileDownloadOptions {
|
|
359
|
+
/**
|
|
360
|
+
* Destino da cópia: uma pasta existente (ou terminada em `/`) recebe o arquivo com o nome
|
|
361
|
+
* original; qualquer outro caminho é o arquivo final. Omitido: pasta temporária da
|
|
362
|
+
* execução, apagada quando ela termina.
|
|
363
|
+
*/
|
|
364
|
+
dest?: string;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Arquivos dos campos de upload do formulário (`hobots.files`). O valor do campo nos
|
|
368
|
+
* params é um `FileRef` (ou uma lista deles); `download` traz o arquivo para o disco
|
|
369
|
+
* desta máquina — do S3 (enviado pela Central) ou da pasta do Studio (mesmo computador)
|
|
370
|
+
* — e o consome na origem: cada arquivo é baixado uma vez.
|
|
371
|
+
*/
|
|
372
|
+
interface RunFiles {
|
|
373
|
+
/** Todos os arquivos dos params (campos de topo, valor único ou lista), na ordem dos campos. */
|
|
374
|
+
list(): FileRef[];
|
|
375
|
+
/** O arquivo do campo (campo único), a lista (campo "vários arquivos") ou undefined. */
|
|
376
|
+
get(field: string): FileRef | FileRef[] | undefined;
|
|
377
|
+
/**
|
|
378
|
+
* Baixa um arquivo e resolve com o caminho local. Aceita o `FileRef` ou o nome de um
|
|
379
|
+
* campo de arquivo único (para campo com vários arquivos, use `downloadAll`). Só depois
|
|
380
|
+
* da cópia completa e conferida o arquivo é consumido na origem — uma falha não perde
|
|
381
|
+
* nada e pode ser tentada de novo. Respeita o cancelamento da execução.
|
|
382
|
+
*/
|
|
383
|
+
download(refOrField: FileRef | string, options?: FileDownloadOptions): Promise<string>;
|
|
384
|
+
/** Baixa todos os arquivos do campo (único ou lista), em ordem. `dest` aqui é uma pasta. */
|
|
385
|
+
downloadAll(field: string, options?: FileDownloadOptions): Promise<string[]>;
|
|
386
|
+
/** Conteúdo do arquivo em memória — baixa, lê e apaga a cópia temporária. */
|
|
387
|
+
read(refOrField: FileRef | string): Promise<Buffer>;
|
|
388
|
+
}
|
|
389
|
+
|
|
346
390
|
/**
|
|
347
391
|
* `hobots.log`: cada método aceita vários argumentos, como `console.log` — cada um vira
|
|
348
392
|
* texto (`safeString`) e são unidos por espaço. Nunca lança, nem com a run cancelada.
|
|
@@ -483,12 +527,26 @@ interface RunContext {
|
|
|
483
527
|
readonly items: RunItems;
|
|
484
528
|
/** Progresso declarado (barra + ETA no app) — opcional, independente de `items` */
|
|
485
529
|
readonly progress: RunProgressReporter;
|
|
530
|
+
/**
|
|
531
|
+
* Arquivos dos campos de upload do formulário: `list()`, `get(campo)`, `download(refOuCampo)`
|
|
532
|
+
* (caminho local), `downloadAll(campo)` e `read(refOuCampo)` (conteúdo em memória).
|
|
533
|
+
* Cada arquivo é consumido na origem ao ser baixado — baixe uma vez e reaproveite a cópia.
|
|
534
|
+
*/
|
|
535
|
+
readonly files: RunFiles;
|
|
486
536
|
/**
|
|
487
537
|
* Transaction de performance desta execução — já correlacionada à run e finalizada
|
|
488
538
|
* automaticamente ao fim do handler. Use `transaction.startChild(op, description)` para
|
|
489
539
|
* medir as etapas (steps); elas aparecem como waterfall na aba de performance da execução.
|
|
490
540
|
*/
|
|
491
541
|
readonly transaction: Transaction;
|
|
542
|
+
/**
|
|
543
|
+
* Entrega já o que a execução fez: as steps raiz finalizadas viram transactions parciais
|
|
544
|
+
* (waterfall da Central sem esperar a run terminar) e itens, logs e progresso pendentes
|
|
545
|
+
* saem sem esperar o throttle. Quem decide quando chamar é o bot — num agente sempre
|
|
546
|
+
* ligado (`start()`), ao fim de cada rodada que processou itens. Aguarda a entrega com
|
|
547
|
+
* teto (`timeoutMs`, default 15s) e nunca lança.
|
|
548
|
+
*/
|
|
549
|
+
flush(timeoutMs?: number): Promise<void>;
|
|
492
550
|
/** Dispara em cancelamento (run cancelada no app), timeout ou shutdown — cancelamento cooperativo */
|
|
493
551
|
readonly signal: AbortSignal;
|
|
494
552
|
/**
|
|
@@ -527,6 +585,8 @@ interface Hobots extends RunContext {
|
|
|
527
585
|
* `step.setError(err, undefined, { image: png })`. Puro: nenhum I/O até o evento ser registrado.
|
|
528
586
|
*/
|
|
529
587
|
image(input: AttachInput, options?: ImageOptions): ImageAttachment;
|
|
588
|
+
/** O valor tem a forma de um arquivo de campo de upload (`FileRef`) — puro, sem I/O. */
|
|
589
|
+
isFileRef(value: unknown): value is FileRef;
|
|
530
590
|
}
|
|
531
591
|
declare global {
|
|
532
592
|
var hobots: Hobots;
|
|
@@ -538,5 +598,6 @@ declare const close: (timeoutMs?: number) => Promise<boolean>;
|
|
|
538
598
|
declare const captureException: (error: unknown, hint?: CaptureHint) => string | undefined;
|
|
539
599
|
declare const retry: <T>(fn: (attempt: number) => T | Promise<T>, options?: RetryOptions) => Promise<T>;
|
|
540
600
|
declare const image: (input: AttachInput, options?: ImageOptions) => ImageAttachment;
|
|
601
|
+
declare const isFileRef: (value: unknown) => value is FileRef;
|
|
541
602
|
|
|
542
|
-
export { type AttachInput, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventPayload, EventType, HeartbeatPayload, type Hobots, type HobotsOptions, ImageAttachment, type ImageInput, type ImageOptions, type ItemColumnInput, type ItemsOptions, MachineSnapshot, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunHandler, type RunItemHandle, type RunItemImageOptions, type RunItemOptions, RunItemStatus, type RunItems, type RunItemsEachHandler, type RunItemsEachOptions, type RunItemsEachResult, RunLogLevel, type RunLogger, type RunOptions, RunProgress, type RunProgressReporter, type StartOptions, Step, StepData, type StepOutcomeOptions, StepStatus, Transaction, TransactionPayload, captureException, close, hobots as default, hobots, image, register, retry, start };
|
|
603
|
+
export { type AttachInput, type CaptureAttachment, type CaptureHint, EnvironmentInput, EventPayload, EventType, type FileDownloadOptions, FileRef, HeartbeatPayload, type Hobots, type HobotsOptions, ImageAttachment, type ImageInput, type ImageOptions, type ItemColumnInput, type ItemsOptions, MachineSnapshot, type RegisterOptions, type RetryDelay, type RetryOptions, RunAttachmentContentType, type RunContext, type RunFiles, type RunHandler, type RunItemHandle, type RunItemImageOptions, type RunItemOptions, RunItemStatus, type RunItems, type RunItemsEachHandler, type RunItemsEachOptions, type RunItemsEachResult, RunLogLevel, type RunLogger, type RunOptions, RunProgress, type RunProgressReporter, type StartOptions, Step, StepData, type StepOutcomeOptions, StepStatus, Transaction, TransactionPayload, captureException, close, hobots as default, hobots, image, isFileRef, register, retry, start };
|