@fiber-pay/runtime 0.1.0-rc.4 → 0.1.0-rc.5
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 +4 -4
- package/dist/index.d.ts +13 -2
- package/dist/index.js +41 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -126,10 +126,10 @@ fiber-pay logs --source runtime --follow
|
|
|
126
126
|
|
|
127
127
|
When started from `fiber-pay node start` or `fiber-pay runtime start`, runtime/fnn logs are persisted to:
|
|
128
128
|
|
|
129
|
-
- `<data-dir>/logs
|
|
130
|
-
- `<data-dir>/logs
|
|
131
|
-
- `<data-dir>/logs
|
|
129
|
+
- `<data-dir>/logs/<YYYY-MM-DD>/fnn.stdout.log`
|
|
130
|
+
- `<data-dir>/logs/<YYYY-MM-DD>/fnn.stderr.log`
|
|
131
|
+
- `<data-dir>/logs/<YYYY-MM-DD>/runtime.alerts.jsonl`
|
|
132
132
|
|
|
133
|
-
`<data-dir>/runtime.meta.json` stores
|
|
133
|
+
`<data-dir>/runtime.meta.json` is written at startup and stores the log file paths for that startup day, along with `logsBaseDir`, so agents can read those files directly during troubleshooting. Because logs rotate daily at UTC midnight while `runtime.meta.json` is not rewritten, its stored per-file paths can become stale; for other days' logs, use `logsBaseDir` together with the appropriate `<YYYY-MM-DD>` directory (or the `fiber-pay logs --date/--list-dates` options).
|
|
134
134
|
|
|
135
135
|
You can view these files directly via CLI without `cat` using `fiber-pay logs` (alias: `fiber-pay log`).
|
package/dist/index.d.ts
CHANGED
|
@@ -88,7 +88,10 @@ interface ChannelJobAlertData {
|
|
|
88
88
|
idempotencyKey: string;
|
|
89
89
|
retryCount: number;
|
|
90
90
|
action?: string;
|
|
91
|
+
peerId?: string;
|
|
92
|
+
temporaryChannelId?: `0x${string}`;
|
|
91
93
|
channelId?: `0x${string}`;
|
|
94
|
+
fundingAmount?: string;
|
|
92
95
|
error?: string;
|
|
93
96
|
}
|
|
94
97
|
interface AlertBackend {
|
|
@@ -228,7 +231,12 @@ interface FileAlertConfig {
|
|
|
228
231
|
type: 'file';
|
|
229
232
|
path: string;
|
|
230
233
|
}
|
|
231
|
-
|
|
234
|
+
interface DailyFileAlertConfig {
|
|
235
|
+
type: 'daily-file';
|
|
236
|
+
baseLogsDir: string;
|
|
237
|
+
filename?: string;
|
|
238
|
+
}
|
|
239
|
+
type AlertBackendConfig = StdoutAlertConfig | WebhookAlertConfig | WebsocketAlertConfig | FileAlertConfig | DailyFileAlertConfig;
|
|
232
240
|
interface RuntimeConfig {
|
|
233
241
|
fiberRpcUrl: string;
|
|
234
242
|
channelPollIntervalMs: number;
|
|
@@ -305,6 +313,9 @@ declare class FiberMonitorService extends EventEmitter {
|
|
|
305
313
|
private extractPaymentHash;
|
|
306
314
|
private extractInvoiceHash;
|
|
307
315
|
private extractChannelId;
|
|
316
|
+
private extractChannelPeerId;
|
|
317
|
+
private extractTemporaryChannelId;
|
|
318
|
+
private extractChannelFundingAmount;
|
|
308
319
|
private normalizeHash;
|
|
309
320
|
}
|
|
310
321
|
|
|
@@ -658,4 +669,4 @@ declare class PaymentProofManager {
|
|
|
658
669
|
private ensureDirectory;
|
|
659
670
|
}
|
|
660
671
|
|
|
661
|
-
export { type Alert, type AlertBackend, type AlertBackendConfig, type AlertFilter, type AlertInput, type AlertPriority, type AlertType, type ChannelBalanceChangedData, type ChannelJob, type ChannelJobAction, type ChannelJobAlertData, type ChannelJobParams, type ChannelJobResult, type ChannelStateChangedData, type ClassifiedError, type ErrorCategory, FiberMonitorService, type FileAlertConfig, type InvoiceJob, type InvoiceJobAction, type InvoiceJobAlertData, type InvoiceJobParams, type InvoiceJobResult, type Job, type JobEvent, type JobEventType, type JobFilter, JobManager, type JobState, type JobType, MemoryStore, type PaymentJob, type PaymentJobAlertData, type PaymentJobParams, type PaymentJobResult, type PaymentProof, PaymentProofManager, type PaymentProofSummary, type PeerEventData, type PendingTlcChangedData, type RetryPolicy, type RpcHealthData, RpcMonitorProxy, type RuntimeConfig, type RuntimeConfigInput, type RuntimeJob, SqliteJobStore, type StdoutAlertConfig, TERMINAL_JOB_STATES, type TrackedInvoiceState, type TrackedPaymentState, type WebhookAlertConfig, type WebsocketAlertConfig, alertPriorityOrder, alertTypeValues, classifyRpcError, computeRetryDelay, createRuntimeConfig, defaultPaymentRetryPolicy, defaultRuntimeConfig, formatRuntimeAlert, isAlertPriority, isAlertType, parseListenAddress, paymentStateMachine, shouldRetry, startRuntimeService };
|
|
672
|
+
export { type Alert, type AlertBackend, type AlertBackendConfig, type AlertFilter, type AlertInput, type AlertPriority, type AlertType, type ChannelBalanceChangedData, type ChannelJob, type ChannelJobAction, type ChannelJobAlertData, type ChannelJobParams, type ChannelJobResult, type ChannelStateChangedData, type ClassifiedError, type DailyFileAlertConfig, type ErrorCategory, FiberMonitorService, type FileAlertConfig, type InvoiceJob, type InvoiceJobAction, type InvoiceJobAlertData, type InvoiceJobParams, type InvoiceJobResult, type Job, type JobEvent, type JobEventType, type JobFilter, JobManager, type JobState, type JobType, MemoryStore, type PaymentJob, type PaymentJobAlertData, type PaymentJobParams, type PaymentJobResult, type PaymentProof, PaymentProofManager, type PaymentProofSummary, type PeerEventData, type PendingTlcChangedData, type RetryPolicy, type RpcHealthData, RpcMonitorProxy, type RuntimeConfig, type RuntimeConfigInput, type RuntimeJob, SqliteJobStore, type StdoutAlertConfig, TERMINAL_JOB_STATES, type TrackedInvoiceState, type TrackedPaymentState, type WebhookAlertConfig, type WebsocketAlertConfig, alertPriorityOrder, alertTypeValues, classifyRpcError, computeRetryDelay, createRuntimeConfig, defaultPaymentRetryPolicy, defaultRuntimeConfig, formatRuntimeAlert, isAlertPriority, isAlertType, parseListenAddress, paymentStateMachine, shouldRetry, startRuntimeService };
|
package/dist/index.js
CHANGED
|
@@ -219,7 +219,7 @@ var AlertManager = class {
|
|
|
219
219
|
|
|
220
220
|
// src/alerts/backends/file-jsonl.ts
|
|
221
221
|
import { appendFileSync, mkdirSync } from "fs";
|
|
222
|
-
import { dirname } from "path";
|
|
222
|
+
import { dirname, join } from "path";
|
|
223
223
|
var JsonlFileAlertBackend = class {
|
|
224
224
|
path;
|
|
225
225
|
constructor(path) {
|
|
@@ -231,6 +231,27 @@ var JsonlFileAlertBackend = class {
|
|
|
231
231
|
`, "utf-8");
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
|
+
function todayDateString() {
|
|
235
|
+
const now = /* @__PURE__ */ new Date();
|
|
236
|
+
const y = now.getUTCFullYear();
|
|
237
|
+
const m = String(now.getUTCMonth() + 1).padStart(2, "0");
|
|
238
|
+
const d = String(now.getUTCDate()).padStart(2, "0");
|
|
239
|
+
return `${y}-${m}-${d}`;
|
|
240
|
+
}
|
|
241
|
+
var DailyJsonlFileAlertBackend = class {
|
|
242
|
+
baseLogsDir;
|
|
243
|
+
filename;
|
|
244
|
+
constructor(baseLogsDir, filename = "runtime.alerts.jsonl") {
|
|
245
|
+
this.baseLogsDir = baseLogsDir;
|
|
246
|
+
this.filename = filename;
|
|
247
|
+
}
|
|
248
|
+
async send(alert) {
|
|
249
|
+
const dateDir = join(this.baseLogsDir, todayDateString());
|
|
250
|
+
mkdirSync(dateDir, { recursive: true });
|
|
251
|
+
appendFileSync(join(dateDir, this.filename), `${JSON.stringify(alert)}
|
|
252
|
+
`, "utf-8");
|
|
253
|
+
}
|
|
254
|
+
};
|
|
234
255
|
|
|
235
256
|
// src/alerts/backends/stdout.ts
|
|
236
257
|
var StdoutAlertBackend = class {
|
|
@@ -953,7 +974,8 @@ async function* runChannelJob(job, rpc, policy, signal) {
|
|
|
953
974
|
}
|
|
954
975
|
});
|
|
955
976
|
yield current;
|
|
956
|
-
|
|
977
|
+
const waitForClosed = current.params.waitForClosed ?? Boolean(shutdownParams.force);
|
|
978
|
+
if (!waitForClosed) {
|
|
957
979
|
current = transitionJobState(current, channelStateMachine, "payment_success");
|
|
958
980
|
yield current;
|
|
959
981
|
return;
|
|
@@ -3449,6 +3471,9 @@ var FiberMonitorService = class extends EventEmitter2 {
|
|
|
3449
3471
|
if (alertConfig.type === "file") {
|
|
3450
3472
|
return new JsonlFileAlertBackend(alertConfig.path);
|
|
3451
3473
|
}
|
|
3474
|
+
if (alertConfig.type === "daily-file") {
|
|
3475
|
+
return new DailyJsonlFileAlertBackend(alertConfig.baseLogsDir, alertConfig.filename);
|
|
3476
|
+
}
|
|
3452
3477
|
const [host, portText] = alertConfig.listen.split(":");
|
|
3453
3478
|
return new WebsocketAlertBackend({
|
|
3454
3479
|
host,
|
|
@@ -3522,7 +3547,10 @@ var FiberMonitorService = class extends EventEmitter2 {
|
|
|
3522
3547
|
idempotencyKey: channelJob.idempotencyKey,
|
|
3523
3548
|
retryCount: channelJob.retryCount,
|
|
3524
3549
|
action: channelJob.params.action,
|
|
3550
|
+
peerId: this.extractChannelPeerId(channelJob),
|
|
3551
|
+
temporaryChannelId: this.extractTemporaryChannelId(channelJob),
|
|
3525
3552
|
channelId: this.extractChannelId(channelJob),
|
|
3553
|
+
fundingAmount: this.extractChannelFundingAmount(channelJob),
|
|
3526
3554
|
error
|
|
3527
3555
|
};
|
|
3528
3556
|
}
|
|
@@ -3554,6 +3582,17 @@ var FiberMonitorService = class extends EventEmitter2 {
|
|
|
3554
3582
|
job.result?.channelId ?? job.result?.acceptedChannelId ?? job.params.channelId ?? job.params.shutdownChannelParams?.channel_id
|
|
3555
3583
|
);
|
|
3556
3584
|
}
|
|
3585
|
+
extractChannelPeerId(job) {
|
|
3586
|
+
return job.params.peerId ?? job.params.openChannelParams?.peer_id;
|
|
3587
|
+
}
|
|
3588
|
+
extractTemporaryChannelId(job) {
|
|
3589
|
+
return this.normalizeHash(
|
|
3590
|
+
job.result?.temporaryChannelId ?? job.params.acceptChannelParams?.temporary_channel_id
|
|
3591
|
+
);
|
|
3592
|
+
}
|
|
3593
|
+
extractChannelFundingAmount(job) {
|
|
3594
|
+
return job.params.openChannelParams?.funding_amount;
|
|
3595
|
+
}
|
|
3557
3596
|
normalizeHash(value) {
|
|
3558
3597
|
if (!value || !value.startsWith("0x")) {
|
|
3559
3598
|
return void 0;
|