hobots 3.2.0 → 3.2.2
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.cjs +56 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -2
- package/dist/index.d.ts +13 -2
- package/dist/index.js +56 -5
- package/dist/index.js.map +1 -1
- package/dist/protocol.d.cts +2 -2
- package/dist/protocol.d.ts +2 -2
- package/docs/api-reference.md +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -256,7 +256,18 @@ declare class Step {
|
|
|
256
256
|
endTimestamp?: string;
|
|
257
257
|
data?: Record<string, unknown>;
|
|
258
258
|
constructor(transaction: Transaction, parentStepId: string, op?: string | undefined, description?: string | undefined);
|
|
259
|
-
|
|
259
|
+
/**
|
|
260
|
+
* Desfecho da step. `message` (opcional) é o motivo legível — vai em `data.message`
|
|
261
|
+
* e aparece na Central (performance e banner da execução) e no log de FINISH.
|
|
262
|
+
*/
|
|
263
|
+
setStatus(status: StepStatus, message?: string): this;
|
|
264
|
+
/**
|
|
265
|
+
* Marca a step como `error` guardando o motivo em `data.error` ({ type, message }).
|
|
266
|
+
* Aceita qualquer valor lançado; `message` sobrescreve a mensagem do erro.
|
|
267
|
+
*/
|
|
268
|
+
setError(error: unknown, message?: string): this;
|
|
269
|
+
/** Motivo registrado via setStatus(…, message) ou setError — usado no log de FINISH. */
|
|
270
|
+
private reason;
|
|
260
271
|
setData(key: string, value: unknown): this;
|
|
261
272
|
/** Step aninhada (filha desta step). */
|
|
262
273
|
startChild(op?: string, description?: string): Step;
|
|
@@ -292,7 +303,7 @@ declare class Transaction {
|
|
|
292
303
|
* logs da run no app), e ecoa no terminal apenas com `debug: true` — o SDK não
|
|
293
304
|
* escreve no stdout do processo do usuário sem permissão.
|
|
294
305
|
*/
|
|
295
|
-
emit(kind: 'transaction' | 'step', phase: 'start' | 'finish', label: string, startTs?: string, endTs?: string, status?: StepStatus | string): void;
|
|
306
|
+
emit(kind: 'transaction' | 'step', phase: 'start' | 'finish', label: string, startTs?: string, endTs?: string, status?: StepStatus | string, reason?: string): void;
|
|
296
307
|
/** Conecta o espelho de lifecycle (RunReporter) e faz replay do backlog em ordem. */
|
|
297
308
|
setLifecycleSink(sink: LifecycleSink): void;
|
|
298
309
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -256,7 +256,18 @@ declare class Step {
|
|
|
256
256
|
endTimestamp?: string;
|
|
257
257
|
data?: Record<string, unknown>;
|
|
258
258
|
constructor(transaction: Transaction, parentStepId: string, op?: string | undefined, description?: string | undefined);
|
|
259
|
-
|
|
259
|
+
/**
|
|
260
|
+
* Desfecho da step. `message` (opcional) é o motivo legível — vai em `data.message`
|
|
261
|
+
* e aparece na Central (performance e banner da execução) e no log de FINISH.
|
|
262
|
+
*/
|
|
263
|
+
setStatus(status: StepStatus, message?: string): this;
|
|
264
|
+
/**
|
|
265
|
+
* Marca a step como `error` guardando o motivo em `data.error` ({ type, message }).
|
|
266
|
+
* Aceita qualquer valor lançado; `message` sobrescreve a mensagem do erro.
|
|
267
|
+
*/
|
|
268
|
+
setError(error: unknown, message?: string): this;
|
|
269
|
+
/** Motivo registrado via setStatus(…, message) ou setError — usado no log de FINISH. */
|
|
270
|
+
private reason;
|
|
260
271
|
setData(key: string, value: unknown): this;
|
|
261
272
|
/** Step aninhada (filha desta step). */
|
|
262
273
|
startChild(op?: string, description?: string): Step;
|
|
@@ -292,7 +303,7 @@ declare class Transaction {
|
|
|
292
303
|
* logs da run no app), e ecoa no terminal apenas com `debug: true` — o SDK não
|
|
293
304
|
* escreve no stdout do processo do usuário sem permissão.
|
|
294
305
|
*/
|
|
295
|
-
emit(kind: 'transaction' | 'step', phase: 'start' | 'finish', label: string, startTs?: string, endTs?: string, status?: StepStatus | string): void;
|
|
306
|
+
emit(kind: 'transaction' | 'step', phase: 'start' | 'finish', label: string, startTs?: string, endTs?: string, status?: StepStatus | string, reason?: string): void;
|
|
296
307
|
/** Conecta o espelho de lifecycle (RunReporter) e faz replay do backlog em ordem. */
|
|
297
308
|
setLifecycleSink(sink: LifecycleSink): void;
|
|
298
309
|
/**
|
package/dist/index.js
CHANGED
|
@@ -53,7 +53,7 @@ function scrubSecrets(text) {
|
|
|
53
53
|
|
|
54
54
|
// src/utils.ts
|
|
55
55
|
var SDK_NAME = "hobots";
|
|
56
|
-
var SDK_VERSION = true ? "3.2.
|
|
56
|
+
var SDK_VERSION = true ? "3.2.2" : "0.0.0-dev";
|
|
57
57
|
function isNode() {
|
|
58
58
|
return typeof process !== "undefined" && typeof process.versions?.node === "string";
|
|
59
59
|
}
|
|
@@ -569,6 +569,8 @@ var Heartbeat = class {
|
|
|
569
569
|
this.metadata = options.metadata;
|
|
570
570
|
this.keepAlive = options.keepAlive ?? false;
|
|
571
571
|
}
|
|
572
|
+
client;
|
|
573
|
+
sampler;
|
|
572
574
|
intervalMs;
|
|
573
575
|
instanceId;
|
|
574
576
|
name;
|
|
@@ -705,6 +707,8 @@ var MachineSampler = class {
|
|
|
705
707
|
this.instanceId = instanceId;
|
|
706
708
|
this.logger = logger;
|
|
707
709
|
}
|
|
710
|
+
instanceId;
|
|
711
|
+
logger;
|
|
708
712
|
os;
|
|
709
713
|
fs;
|
|
710
714
|
ready = false;
|
|
@@ -832,6 +836,7 @@ var TasksApiError = class extends Error {
|
|
|
832
836
|
this.status = status;
|
|
833
837
|
this.name = "TasksApiError";
|
|
834
838
|
}
|
|
839
|
+
status;
|
|
835
840
|
};
|
|
836
841
|
async function withRequestTimeout(timeoutMs, external, send) {
|
|
837
842
|
const { signal, cleanup } = withTimeoutSignal(timeoutMs, external);
|
|
@@ -1072,6 +1077,9 @@ var Backoff = class {
|
|
|
1072
1077
|
this.label = label;
|
|
1073
1078
|
this.floorMs = floorMs;
|
|
1074
1079
|
}
|
|
1080
|
+
logger;
|
|
1081
|
+
label;
|
|
1082
|
+
floorMs;
|
|
1075
1083
|
failures = 0;
|
|
1076
1084
|
authFailures = 0;
|
|
1077
1085
|
reset() {
|
|
@@ -1316,6 +1324,9 @@ var RunReporter = class {
|
|
|
1316
1324
|
retry: (fn, options) => retryWithBackoff(fn, { ...options, signal, wait: sleep2 })
|
|
1317
1325
|
};
|
|
1318
1326
|
}
|
|
1327
|
+
api;
|
|
1328
|
+
runId;
|
|
1329
|
+
logger;
|
|
1319
1330
|
context;
|
|
1320
1331
|
buffer = [];
|
|
1321
1332
|
dead = false;
|
|
@@ -1640,6 +1651,7 @@ var RunReporter = class {
|
|
|
1640
1651
|
}
|
|
1641
1652
|
if (error instanceof TasksApiError) {
|
|
1642
1653
|
this.logger.error(`lote de ${batch.length} item(ns) rejeitado pelo servidor:`, error);
|
|
1654
|
+
this.log("warning", `${batch.length} item(ns) descartado(s): envio rejeitado pelo servidor (HTTP ${error.status})`);
|
|
1643
1655
|
return;
|
|
1644
1656
|
}
|
|
1645
1657
|
this.itemsBuffer.unshift(...batch);
|
|
@@ -1866,6 +1878,10 @@ function currentRunReporter() {
|
|
|
1866
1878
|
}
|
|
1867
1879
|
|
|
1868
1880
|
// src/transaction.ts
|
|
1881
|
+
var MAX_STEP_MESSAGE_CHARS = 2e3;
|
|
1882
|
+
function stepMessage(text) {
|
|
1883
|
+
return truncate(scrubSecrets(text), MAX_STEP_MESSAGE_CHARS);
|
|
1884
|
+
}
|
|
1869
1885
|
function stepId() {
|
|
1870
1886
|
return uuid4().slice(0, 16);
|
|
1871
1887
|
}
|
|
@@ -1903,15 +1919,41 @@ var Step = class {
|
|
|
1903
1919
|
this.op = op;
|
|
1904
1920
|
this.description = description;
|
|
1905
1921
|
}
|
|
1922
|
+
transaction;
|
|
1923
|
+
parentStepId;
|
|
1924
|
+
op;
|
|
1925
|
+
description;
|
|
1906
1926
|
stepId = stepId();
|
|
1907
1927
|
startTimestamp = nowISO();
|
|
1908
1928
|
status = "ok";
|
|
1909
1929
|
endTimestamp;
|
|
1910
1930
|
data;
|
|
1911
|
-
|
|
1931
|
+
/**
|
|
1932
|
+
* Desfecho da step. `message` (opcional) é o motivo legível — vai em `data.message`
|
|
1933
|
+
* e aparece na Central (performance e banner da execução) e no log de FINISH.
|
|
1934
|
+
*/
|
|
1935
|
+
setStatus(status, message) {
|
|
1912
1936
|
this.status = status;
|
|
1937
|
+
if (message) this.setData("message", stepMessage(message));
|
|
1913
1938
|
return this;
|
|
1914
1939
|
}
|
|
1940
|
+
/**
|
|
1941
|
+
* Marca a step como `error` guardando o motivo em `data.error` ({ type, message }).
|
|
1942
|
+
* Aceita qualquer valor lançado; `message` sobrescreve a mensagem do erro.
|
|
1943
|
+
*/
|
|
1944
|
+
setError(error, message) {
|
|
1945
|
+
this.status = "error";
|
|
1946
|
+
const type = error instanceof Error ? error.name : typeof error === "object" && error !== null ? "Error" : void 0;
|
|
1947
|
+
const raw = message ?? (error instanceof Error ? error.message || error.name : String(error));
|
|
1948
|
+
this.setData("error", { ...type ? { type } : {}, message: stepMessage(raw) });
|
|
1949
|
+
return this;
|
|
1950
|
+
}
|
|
1951
|
+
/** Motivo registrado via setStatus(…, message) ou setError — usado no log de FINISH. */
|
|
1952
|
+
reason() {
|
|
1953
|
+
const error = this.data?.error;
|
|
1954
|
+
const text = typeof error?.message === "string" ? error.message : this.data?.message;
|
|
1955
|
+
return typeof text === "string" && text ? text : void 0;
|
|
1956
|
+
}
|
|
1915
1957
|
setData(key, value) {
|
|
1916
1958
|
this.data = { ...this.data, [key]: value };
|
|
1917
1959
|
return this;
|
|
@@ -1929,7 +1971,8 @@ var Step = class {
|
|
|
1929
1971
|
stepLabel(this.op, this.description),
|
|
1930
1972
|
this.startTimestamp,
|
|
1931
1973
|
this.endTimestamp,
|
|
1932
|
-
this.status
|
|
1974
|
+
this.status,
|
|
1975
|
+
this.reason()
|
|
1933
1976
|
);
|
|
1934
1977
|
}
|
|
1935
1978
|
toJSON() {
|
|
@@ -1953,6 +1996,10 @@ var Transaction = class {
|
|
|
1953
1996
|
this.runId = runId;
|
|
1954
1997
|
this.emit("transaction", "start", op ? `${name} (${op})` : name);
|
|
1955
1998
|
}
|
|
1999
|
+
client;
|
|
2000
|
+
name;
|
|
2001
|
+
op;
|
|
2002
|
+
runId;
|
|
1956
2003
|
eventId = uuid4();
|
|
1957
2004
|
stepId = stepId();
|
|
1958
2005
|
startTimestamp = nowISO();
|
|
@@ -1972,9 +2019,9 @@ var Transaction = class {
|
|
|
1972
2019
|
* logs da run no app), e ecoa no terminal apenas com `debug: true` — o SDK não
|
|
1973
2020
|
* escreve no stdout do processo do usuário sem permissão.
|
|
1974
2021
|
*/
|
|
1975
|
-
emit(kind, phase, label, startTs, endTs, status) {
|
|
2022
|
+
emit(kind, phase, label, startTs, endTs, status, reason) {
|
|
1976
2023
|
const durationMs = startTs && endTs ? new Date(endTs).getTime() - new Date(startTs).getTime() : void 0;
|
|
1977
|
-
const suffix = durationMs != null ? ` (${durationMs}ms)` : "";
|
|
2024
|
+
const suffix = (durationMs != null ? ` (${durationMs}ms)` : "") + (reason ? `: ${reason}` : "");
|
|
1978
2025
|
if (this.client?.debug) {
|
|
1979
2026
|
const tag = colorize(`[hobots:${kind}] ${phase.toUpperCase()}`, phase === "finish" ? colorForStatus(status ?? "ok") : "cyan");
|
|
1980
2027
|
console.log(`${tag} ${label}${suffix}`);
|
|
@@ -2179,6 +2226,7 @@ var TaskAgent = class {
|
|
|
2179
2226
|
this.pollIntervalMs = Math.max(MIN_POLL_INTERVAL_MS, options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS);
|
|
2180
2227
|
this.backoff = new Backoff(this.logger, "poll", this.pollIntervalMs);
|
|
2181
2228
|
}
|
|
2229
|
+
options;
|
|
2182
2230
|
logger;
|
|
2183
2231
|
pollIntervalMs;
|
|
2184
2232
|
api;
|
|
@@ -2345,6 +2393,8 @@ var LocalRunner = class {
|
|
|
2345
2393
|
this.resolveDone = resolve2;
|
|
2346
2394
|
});
|
|
2347
2395
|
}
|
|
2396
|
+
task;
|
|
2397
|
+
deps;
|
|
2348
2398
|
abort = new AbortController();
|
|
2349
2399
|
backoff;
|
|
2350
2400
|
/** Resolve quando a run terminou (ou o runner foi parado antes de abri-la). */
|
|
@@ -2430,6 +2480,7 @@ var RunTracker = class {
|
|
|
2430
2480
|
constructor(api) {
|
|
2431
2481
|
this.api = api;
|
|
2432
2482
|
}
|
|
2483
|
+
api;
|
|
2433
2484
|
reporters = /* @__PURE__ */ new Set();
|
|
2434
2485
|
waiters = /* @__PURE__ */ new Set();
|
|
2435
2486
|
add(reporter) {
|