target-supabase-sdk 0.2.11 → 0.2.13
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/browser.d.ts +2 -3
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +2 -2
- package/dist/chunks/enable-DqnfLPsQ.js +874 -0
- package/dist/chunks/enable-DqnfLPsQ.js.map +1 -0
- package/dist/chunks/{list.api-DSTOHzOC.js → list.api-BzbTJBsM.js} +35 -2
- package/dist/chunks/list.api-BzbTJBsM.js.map +1 -0
- package/dist/chunks/{task-queue-BHvNgb-X.js → task-queue-6X3aglJh.js} +110 -17
- package/dist/chunks/task-queue-6X3aglJh.js.map +1 -0
- package/dist/node/preload/run-service-preload.d.ts +1 -0
- package/dist/node/preload/run-service-preload.d.ts.map +1 -1
- package/dist/node/preload/service-preload.interface.d.ts +7 -0
- package/dist/node/preload/service-preload.interface.d.ts.map +1 -1
- package/dist/node/process/managed-child-processes.d.ts.map +1 -1
- package/dist/node/service-guard/service-guard-node.d.ts.map +1 -1
- package/dist/node/service-host/index.d.ts +1 -0
- package/dist/node/service-host/index.d.ts.map +1 -1
- package/dist/node/service-host/service-host.d.ts +5 -1
- package/dist/node/service-host/service-host.d.ts.map +1 -1
- package/dist/node.d.ts +10 -5
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +494 -49
- package/dist/node.js.map +1 -1
- package/dist/preload.js +20 -7
- package/dist/preload.js.map +1 -1
- package/dist/resource/resource.interface.d.ts +20 -0
- package/dist/resource/resource.interface.d.ts.map +1 -0
- package/dist/service/config.api.d.ts.map +1 -1
- package/dist/service/index.d.ts +2 -2
- package/dist/service/index.d.ts.map +1 -1
- package/dist/service/registry.service.d.ts +19 -0
- package/dist/service/registry.service.d.ts.map +1 -1
- package/dist/shared/log/core/create-logger.d.ts.map +1 -0
- package/dist/shared/log/{log-batch.d.ts → core/log-batch.d.ts} +4 -4
- package/dist/shared/log/core/log-batch.d.ts.map +1 -0
- package/dist/shared/log/core/log-manager.d.ts.map +1 -0
- package/dist/shared/log/core/log-min-level.d.ts +15 -0
- package/dist/shared/log/core/log-min-level.d.ts.map +1 -0
- package/dist/shared/log/core/log-scope.d.ts.map +1 -0
- package/dist/shared/log/index.d.ts +13 -11
- package/dist/shared/log/index.d.ts.map +1 -1
- package/dist/shared/log/spool/collector.d.ts +21 -0
- package/dist/shared/log/spool/collector.d.ts.map +1 -0
- package/dist/shared/log/spool/config.d.ts +7 -0
- package/dist/shared/log/spool/config.d.ts.map +1 -0
- package/dist/shared/log/spool/coordinator.d.ts +18 -0
- package/dist/shared/log/spool/coordinator.d.ts.map +1 -0
- package/dist/shared/log/spool/enable.d.ts +23 -0
- package/dist/shared/log/spool/enable.d.ts.map +1 -0
- package/dist/shared/log/spool/file.d.ts +21 -0
- package/dist/shared/log/spool/file.d.ts.map +1 -0
- package/dist/shared/log/spool/interface.d.ts +55 -0
- package/dist/shared/log/spool/interface.d.ts.map +1 -0
- package/dist/shared/log/spool/paths.d.ts +6 -0
- package/dist/shared/log/spool/paths.d.ts.map +1 -0
- package/dist/shared/log/spool/process-roles.d.ts +17 -0
- package/dist/shared/log/spool/process-roles.d.ts.map +1 -0
- package/dist/shared/log/spool/register-collect-log-runner.d.ts +15 -0
- package/dist/shared/log/spool/register-collect-log-runner.d.ts.map +1 -0
- package/dist/shared/log/spool/service-lifecycle.d.ts +13 -0
- package/dist/shared/log/spool/service-lifecycle.d.ts.map +1 -0
- package/dist/shared/log/spool/writer.d.ts +32 -0
- package/dist/shared/log/spool/writer.d.ts.map +1 -0
- package/dist/shared/log/{log-persist-batch-id.d.ts → upload/batch-id.d.ts} +3 -3
- package/dist/shared/log/upload/batch-id.d.ts.map +1 -0
- package/dist/shared/log/upload/env.d.ts +7 -0
- package/dist/shared/log/upload/env.d.ts.map +1 -0
- package/dist/shared/log/{log-persist-flush.d.ts → upload/flush.d.ts} +3 -3
- package/dist/shared/log/upload/flush.d.ts.map +1 -0
- package/dist/shared/log/{log-persist-hook.d.ts → upload/hook.d.ts} +2 -2
- package/dist/shared/log/upload/hook.d.ts.map +1 -0
- package/dist/shared/log/upload/interface.d.ts +33 -0
- package/dist/shared/log/upload/interface.d.ts.map +1 -0
- package/dist/shared/log/upload/logger.d.ts +22 -0
- package/dist/shared/log/upload/logger.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/browser.ts +4 -1
- package/src/node/preload/run-service-preload.ts +23 -4
- package/src/node/preload/service-preload.interface.ts +8 -0
- package/src/node/process/create-managed-child-processes.ts +1 -1
- package/src/node/process/managed-child-processes.ts +8 -1
- package/src/node/service-guard/service-guard-node.ts +5 -0
- package/src/node/service-host/index.ts +4 -0
- package/src/node/service-host/service-host.ts +22 -3
- package/src/node.ts +26 -19
- package/src/resource/resource.interface.ts +37 -0
- package/src/service/config.api.ts +1 -0
- package/src/service/index.ts +3 -0
- package/src/service/registry.service.ts +142 -0
- package/src/shared/log/README.md +206 -0
- package/src/shared/log/{log-batch.ts → core/log-batch.ts} +4 -4
- package/src/shared/log/{log-manager.ts → core/log-manager.ts} +3 -3
- package/src/shared/log/core/log-min-level.ts +46 -0
- package/src/shared/log/{log-scope.ts → core/log-scope.ts} +1 -1
- package/src/shared/log/index.ts +17 -15
- package/src/shared/log/spool/collector.ts +330 -0
- package/src/shared/log/spool/config.ts +56 -0
- package/src/shared/log/spool/coordinator.ts +55 -0
- package/src/shared/log/spool/enable.ts +136 -0
- package/src/shared/log/spool/file.ts +75 -0
- package/src/shared/log/spool/interface.ts +62 -0
- package/src/shared/log/spool/paths.ts +30 -0
- package/src/shared/log/spool/process-roles.ts +75 -0
- package/src/shared/log/spool/register-collect-log-runner.ts +63 -0
- package/src/shared/log/spool/service-lifecycle.ts +35 -0
- package/src/shared/log/spool/writer.ts +273 -0
- package/src/shared/log/{log-persist-batch-id.ts → upload/batch-id.ts} +2 -2
- package/src/shared/log/upload/env.ts +26 -0
- package/src/shared/log/{log-persist-flush.ts → upload/flush.ts} +8 -7
- package/src/shared/log/{log-persist-hook.ts → upload/hook.ts} +1 -1
- package/src/shared/log/upload/interface.ts +38 -0
- package/src/shared/log/upload/logger.ts +37 -0
- package/dist/chunks/enable-log-persist-Cu3SGxK7.js +0 -1674
- package/dist/chunks/enable-log-persist-Cu3SGxK7.js.map +0 -1
- package/dist/chunks/list.api-DSTOHzOC.js.map +0 -1
- package/dist/chunks/task-queue-BHvNgb-X.js.map +0 -1
- package/dist/idea/idea.interface.d.ts +0 -25
- package/dist/idea/idea.interface.d.ts.map +0 -1
- package/dist/shared/log/create-logger.d.ts.map +0 -1
- package/dist/shared/log/enable-log-persist.d.ts +0 -28
- package/dist/shared/log/enable-log-persist.d.ts.map +0 -1
- package/dist/shared/log/log-batch.d.ts.map +0 -1
- package/dist/shared/log/log-manager.d.ts.map +0 -1
- package/dist/shared/log/log-persist-batch-id.d.ts.map +0 -1
- package/dist/shared/log/log-persist-coordinator.d.ts +0 -37
- package/dist/shared/log/log-persist-coordinator.d.ts.map +0 -1
- package/dist/shared/log/log-persist-errors.d.ts +0 -4
- package/dist/shared/log/log-persist-errors.d.ts.map +0 -1
- package/dist/shared/log/log-persist-flush.d.ts.map +0 -1
- package/dist/shared/log/log-persist-hook.d.ts.map +0 -1
- package/dist/shared/log/log-persist-logger.d.ts +0 -16
- package/dist/shared/log/log-persist-logger.d.ts.map +0 -1
- package/dist/shared/log/log-persist-registry.d.ts +0 -18
- package/dist/shared/log/log-persist-registry.d.ts.map +0 -1
- package/dist/shared/log/log-persist.config.d.ts +0 -9
- package/dist/shared/log/log-persist.config.d.ts.map +0 -1
- package/dist/shared/log/log-persist.d.ts +0 -62
- package/dist/shared/log/log-persist.d.ts.map +0 -1
- package/dist/shared/log/log-persist.interface.d.ts +0 -132
- package/dist/shared/log/log-persist.interface.d.ts.map +0 -1
- package/dist/shared/log/log-scope.d.ts.map +0 -1
- package/src/idea/idea.interface.ts +0 -28
- package/src/shared/log/enable-log-persist.ts +0 -225
- package/src/shared/log/log-persist-coordinator.ts +0 -107
- package/src/shared/log/log-persist-errors.ts +0 -16
- package/src/shared/log/log-persist-logger.ts +0 -61
- package/src/shared/log/log-persist-registry.ts +0 -252
- package/src/shared/log/log-persist.config.ts +0 -115
- package/src/shared/log/log-persist.interface.ts +0 -150
- package/src/shared/log/log-persist.ts +0 -822
- /package/dist/shared/log/{create-logger.d.ts → core/create-logger.d.ts} +0 -0
- /package/dist/shared/log/{log-manager.d.ts → core/log-manager.d.ts} +0 -0
- /package/dist/shared/log/{log-scope.d.ts → core/log-scope.d.ts} +0 -0
- /package/src/shared/log/{create-logger.ts → core/create-logger.ts} +0 -0
package/dist/node.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import { M as MAX_POLL_TARGET_LIST_SIZE,
|
|
3
|
-
export { B as BaseValidator, C as CREATE_TARGET_ALREADY_EXISTS_MESSAGE, a as CategoryList, L as LOG_BATCH_LOADER_KEY, b as LOG_PERSIST_LOADER_KEY,
|
|
4
|
-
import { l as loadEnvFiles, b as readEnv, c as requireEnv, d as
|
|
5
|
-
export { C as CLI_PROD_FLAG, S as SERVICE_ENV_PROFILE_ENV_KEY,
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
2
|
+
import { M as MAX_POLL_TARGET_LIST_SIZE, V as validateWithSchema, g as createLogger, z as pollTargetList, k as generateResponse, h as createTarget, K as supabase, w as logManager, X as createScope, d as LogLevel, Y as patchScope, J as scanTargetList, Z as withModule, l as getPossibleTarget, t as isOptimisticLockResponse, R as updateTargetDetails } from './chunks/list.api-BzbTJBsM.js';
|
|
3
|
+
export { B as BaseValidator, C as CREATE_TARGET_ALREADY_EXISTS_MESSAGE, a as CategoryList, L as LOG_BATCH_LOADER_KEY, b as LOG_MIN_LEVEL_ENV_KEY, c as LOG_PERSIST_LOADER_KEY, e as MAX_TARGET_LIST_PAGE_SIZE, O as OPTIMISTIC_LOCK_ERROR_CODE, f as OPTIMISTIC_LOCK_FAILED_MESSAGE, P as PostListValidator, S as StatusCode, U as UPDATE_TARGET_NOT_FOUND_MESSAGE, i as deleteTarget, j as formatZodError, m as getTarget, n as getTargetList, o as getTargetTotalCount, p as handleSupabaseError, q as isCreateTargetAlreadyExistsError, r as isDevEnvironment, s as isOptimisticLockError, u as logDev, v as logDevGroup, x as logMinLevelFromEnv, y as patchTarget, A as postListCreate, D as postLogListCreate, E as postTarget, F as postTargetPayloadSchema, G as queryFilterSchema, H as resolveLogMinLevel, I as safeParseWithSchema, N as targetDraftSchema, Q as updateTarget, T as validateWith } from './chunks/list.api-BzbTJBsM.js';
|
|
4
|
+
import { l as loadEnvFiles, b as readEnv, c as requireEnv, d as resolveLogSpoolSpawnEnvForLabel, e as resolveLogSpoolConfig, f as resolveLogSpoolRoot, g as resolveAllLogSpoolProcessRoles, h as logSpoolProcessDir, s as spoolLogger, i as parseLogSpoolBatchFilename, j as computeLogBatchIdempotencyKey, k as buildLogListDraft, n as postLogBatch, a as logSpoolEnabledFromEnv, o as logSpoolConfigFromEnv, L as LOG_SPOOL_SERVICE_ID_ENV, q as ensureLogSpoolFromEnv, t as shutdownLogSpoolFromEnv, u as getLogSpoolStats } from './chunks/enable-DqnfLPsQ.js';
|
|
5
|
+
export { C as CLI_PROD_FLAG, S as SERVICE_ENV_PROFILE_ENV_KEY, w as SERVICE_ENV_PROFILE_PROD, x as buildLogSpoolSpawnEnv, y as envBool, z as envInt, A as envMs, B as envNumber, D as envPort, E as envProfileFromProcess, F as parseEnvFile, G as parseEnvLine, p as pinEnvProfileFromArgv, H as resolveDefaultEnvFiles, r as resolveProjectRootByPackageName, I as resolveProjectRootFromModule, v as validateLogSpoolPreloadEnv } from './chunks/enable-DqnfLPsQ.js';
|
|
6
|
+
import { randomBytes, createHash } from 'node:crypto';
|
|
7
|
+
import { readFile, unlink, mkdir, writeFile, rename, access, stat, readdir, constants } from 'node:fs/promises';
|
|
8
|
+
import { dirname, resolve, join, isAbsolute } from 'node:path';
|
|
9
|
+
import { bh as sha256Hex, bm as getErrorMessage, aL as postRegisterNode, ap as patchChangeNodeStatus, N as NodeStatus, aA as patchStopNode, ax as patchNodeHeartBeat, E as EMPTY_REGISTRY_SLOT_RUNTIME_STATE, ag as isLogEntry, b7 as runRegistrySlotGuardCheck, aZ as registrySlotRuntimePatchFromGuardResult, c as CategoryNode, Q as evaluateBusyNodeLiveness, az as patchServiceRuntime, k as ServiceRegistryError, x as claimServiceRegistrySlot, e as CategoryRepo, R as ResultCode, bn as LOG_TOPIC_TASK, m as TASK_REPO_USAGE, a6 as getScanRemoteRepoValues, at as patchClaimTask, bo as CRITICAL_UNKNOWN_TASK_TRACE_ID, ar as patchChangeTaskStatus, o as TaskStatusAction, bp as toError, aT as postTaskSchema, bq as createTaskRow, n as TaskStatus } from './chunks/task-queue-6X3aglJh.js';
|
|
10
|
+
export { A as ApiMethod, C as CategoryConfig, a as CategoryExtraction, b as CategoryLink, d as CategoryParcel, f as CategoryService, g as CategoryTask, D as DEFAULT_SYSTEM_REGISTRY_SEED_SLOTS, L as LINK_MANIFEST_VERSION, h as LIST_MANIFEST_VERSION, P as POST_TASK_DEFAULT_MAX_ATTEMPTS, i as ParcelManager, j as PostLinkValidator, S as ServiceLifecycleStatus, l as ServiceSlotStatus, T as TARGET_SYSTEM_REGISTRY_KEY, p as apiDetailsSchema, q as appendSystemRegistrySlots, r as assertRegistrySlotAvailable, s as assertRegistrySlotOwner, t as buildEmptyServiceSlots, u as buildLinkTargetDraft, v as buildListTargetDraft, w as buildSystemRegistryConfigDetails, y as classifyNetworkError, z as countTasksByType, B as createActiveServiceLifecycle, F as createClaimedRegistrySlotRuntimeState, G as createStorageProviderRegistry, H as createUploadTracker, I as decodeLogBatch, J as decodeLogBatchList, K as defaultL3ServiceDetails, M as deleteParcel, O as deleteParcelSchema, U as fetchBinaryWithRetry, V as fetchWithRetry, W as fieldDefinitionSchema, X as flattenLogBatch, Y as flattenLogBatches, Z as formatNetworkError, _ as getApi, $ as getApiSchema, a0 as getConfig, a1 as getConfigSchema, a2 as getExtraction, a3 as getExtractionSchema, a4 as getParcel, a5 as getParcelSchema, a7 as getScanRemoteRepoValuesSchema, a8 as getService, a9 as getServiceSchema, aa as getTargetSystemRegistry, ab as getValueAtPath, ac as installChunkFetchRegistry, ad as isHttpUrl, ae as isLocalFilesystemPath, af as isLogBatchList, ah as isOpaqueChunkUrl, ai as isRetryableHttpStatus, aj as linkTargetDraftBuildInputSchema, ak as parcelDetailsSchema, al as parseLogBatchMeta, am as parseProviderPrefixedUrl, an as parseServiceSlot, ao as parseServiceSlots, aq as patchChangeNodeStatusSchema, as as patchChangeTaskStatusSchema, au as patchClaimTaskSchema, av as patchExtractionObjects, aw as patchExtractionObjectsSchema, ay as patchNodeHeartBeatSchema, aB as patchStopNodeSchema, aC as patchTaskProgress, aD as patchTaskProgressSchema, aE as postApi, aF as postApiSchema, aG as postExtraction, aH as postExtractionSchema, aI as postLinkCreate, aJ as postParcel, aK as postParcelSchema, aM as postRegisterNodeSchema, aN as postService, aO as postServiceInstance, aP as postServiceSchema, aQ as postSystemRegistryConfig, aR as postSystemRegistryConfigSchema, aS as postTask, aU as postTaskWithRetry, aV as publishParcel, aW as registerProviderChunkResolver, aX as registerService, aY as registerServiceAtStartup, a_ as releaseSystemRegistrySlots, a$ as releaseSystemRegistrySlotsByServiceId, b0 as requestHasBody, b1 as resetSystemRegistryConfig, b2 as resetSystemRegistryConfigSchema, b3 as resolveActiveRegistryServiceId, b4 as resolveFetchUrl, b5 as restoreParcel, b6 as restoreParcelById, b8 as sanitizeFileName, b9 as sanitizeParcelFileName, ba as scanExtractionList, bb as scanExtractionListSchema, bc as schemaDefinitionSchema, bd as serviceDetailsSchema, be as serviceLifecycleSchema, bf as serviceNodeSnapshotSchema, bg as serviceRuntimeSchema, bi as summarizeTaskQueue, bj as systemRegistrySeedSlotSchema, bk as unregisterService, bl as unregisterServiceAtShutdown } from './chunks/task-queue-6X3aglJh.js';
|
|
10
11
|
import { spawn } from 'node:child_process';
|
|
11
|
-
import { createHash } from 'node:crypto';
|
|
12
12
|
import { tmpdir } from 'node:os';
|
|
13
13
|
import { pathToFileURL } from 'node:url';
|
|
14
14
|
import 'lodash-es';
|
|
@@ -119,6 +119,98 @@ function publicBaseUrlFromEnv(port, options) {
|
|
|
119
119
|
return `http://localhost:${port}`;
|
|
120
120
|
}
|
|
121
121
|
|
|
122
|
+
/** Per-file write queue — serializes read-modify-write for a single JSON path within one process. */
|
|
123
|
+
const writeChains = new Map();
|
|
124
|
+
function withSerializedFileWrites(filePath, operation) {
|
|
125
|
+
const previous = writeChains.get(filePath) ?? Promise.resolve();
|
|
126
|
+
const next = previous.then(operation, operation);
|
|
127
|
+
writeChains.set(filePath, next.then(() => undefined, () => undefined));
|
|
128
|
+
return next;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function mergeWithNested(defaults, current, patch, nestedKeys) {
|
|
132
|
+
const merged = {
|
|
133
|
+
...defaults,
|
|
134
|
+
...current,
|
|
135
|
+
...patch,
|
|
136
|
+
};
|
|
137
|
+
for (const key of nestedKeys) {
|
|
138
|
+
const defaultNested = defaults[key];
|
|
139
|
+
if (defaultNested != null && typeof defaultNested === "object") {
|
|
140
|
+
merged[key] = {
|
|
141
|
+
...defaultNested,
|
|
142
|
+
...current?.[key],
|
|
143
|
+
...patch[key],
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
return merged;
|
|
148
|
+
}
|
|
149
|
+
async function atomicWriteJson(filePath, data) {
|
|
150
|
+
await mkdir(dirname(filePath), { recursive: true });
|
|
151
|
+
const content = `${JSON.stringify(data, null, 2)}\n`;
|
|
152
|
+
JSON.parse(content);
|
|
153
|
+
const tempPath = `${filePath}.${process.pid}.${randomBytes(4).toString("hex")}.tmp`;
|
|
154
|
+
try {
|
|
155
|
+
await writeFile(tempPath, content, "utf8");
|
|
156
|
+
await rename(tempPath, filePath);
|
|
157
|
+
}
|
|
158
|
+
catch (error) {
|
|
159
|
+
await unlink(tempPath).catch(() => undefined);
|
|
160
|
+
throw error;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
/** JSON file-backed state with optional nested key merge and atomic writes. */
|
|
164
|
+
function createJsonFileStateStore(options) {
|
|
165
|
+
const { filePath, defaultState, nestedKeys = [], updatedAtKey } = options;
|
|
166
|
+
function touchUpdatedAt(state) {
|
|
167
|
+
if (updatedAtKey == null) {
|
|
168
|
+
return state;
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
...state,
|
|
172
|
+
[updatedAtKey]: new Date().toISOString(),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async function readFromDisk() {
|
|
176
|
+
try {
|
|
177
|
+
const raw = await readFile(filePath, "utf8");
|
|
178
|
+
const parsed = JSON.parse(raw);
|
|
179
|
+
return mergeWithNested(defaultState, parsed, {}, nestedKeys);
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (error.code === "ENOENT") {
|
|
183
|
+
return mergeWithNested(defaultState, {}, {}, nestedKeys);
|
|
184
|
+
}
|
|
185
|
+
if (error instanceof SyntaxError) {
|
|
186
|
+
await unlink(filePath).catch(() => undefined);
|
|
187
|
+
return mergeWithNested(defaultState, {}, {}, nestedKeys);
|
|
188
|
+
}
|
|
189
|
+
throw error;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
return {
|
|
193
|
+
read() {
|
|
194
|
+
return readFromDisk();
|
|
195
|
+
},
|
|
196
|
+
write(patch) {
|
|
197
|
+
return withSerializedFileWrites(filePath, async () => {
|
|
198
|
+
const current = await readFromDisk();
|
|
199
|
+
const next = touchUpdatedAt(mergeWithNested(defaultState, current, patch, nestedKeys));
|
|
200
|
+
await atomicWriteJson(filePath, next);
|
|
201
|
+
return next;
|
|
202
|
+
});
|
|
203
|
+
},
|
|
204
|
+
reset() {
|
|
205
|
+
return withSerializedFileWrites(filePath, async () => {
|
|
206
|
+
const next = touchUpdatedAt({ ...defaultState });
|
|
207
|
+
await atomicWriteJson(filePath, next);
|
|
208
|
+
return next;
|
|
209
|
+
});
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
|
|
122
214
|
/** Copy a Node.js Buffer view to a standalone ArrayBuffer. */
|
|
123
215
|
function nodeBufferToArrayBuffer(nodeBuffer) {
|
|
124
216
|
return nodeBuffer.buffer.slice(nodeBuffer.byteOffset, nodeBuffer.byteOffset + nodeBuffer.byteLength);
|
|
@@ -725,12 +817,16 @@ class ManagedChildProcesses {
|
|
|
725
817
|
if (existing != null) {
|
|
726
818
|
return { child: existing, created: false };
|
|
727
819
|
}
|
|
820
|
+
const logSpoolEnv = resolveLogSpoolSpawnEnvForLabel(label);
|
|
821
|
+
const childEnv = spawnOptions?.env != null
|
|
822
|
+
? { ...process.env, ...logSpoolEnv, ...spawnOptions.env }
|
|
823
|
+
: { ...process.env, ...logSpoolEnv };
|
|
728
824
|
const child = spawnTsxChild({
|
|
729
825
|
projectRoot: this.projectRoot,
|
|
730
826
|
entryScript,
|
|
731
827
|
preloadModules: this.preloadModules,
|
|
732
828
|
useTsx: spawnOptions?.useTsx ?? this.defaultUseTsx,
|
|
733
|
-
env:
|
|
829
|
+
env: childEnv,
|
|
734
830
|
});
|
|
735
831
|
child.on("exit", (code, signal) => {
|
|
736
832
|
this.logger?.info("child exited", { topic: "process", data: { label, code, signal } });
|
|
@@ -805,6 +901,25 @@ function createManagedChildProcesses(options) {
|
|
|
805
901
|
});
|
|
806
902
|
}
|
|
807
903
|
|
|
904
|
+
function sleep$1(ms) {
|
|
905
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
906
|
+
}
|
|
907
|
+
/**
|
|
908
|
+
* Poll `until()` until it returns true or `timeoutMs` elapses.
|
|
909
|
+
* @throws Error on timeout
|
|
910
|
+
*/
|
|
911
|
+
async function pollUntil(options) {
|
|
912
|
+
const intervalMs = options.intervalMs ?? 500;
|
|
913
|
+
const deadline = Date.now() + options.timeoutMs;
|
|
914
|
+
while (Date.now() < deadline) {
|
|
915
|
+
if (await options.until()) {
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
await sleep$1(intervalMs);
|
|
919
|
+
}
|
|
920
|
+
throw new Error(`pollUntil timeout after ${options.timeoutMs}ms`);
|
|
921
|
+
}
|
|
922
|
+
|
|
808
923
|
/** Factory: all listed env keys must be non-empty. */
|
|
809
924
|
function createRequiredEnvCheck(name, keys, options) {
|
|
810
925
|
return () => {
|
|
@@ -1362,6 +1477,314 @@ async function runRunner(ctx, runner) {
|
|
|
1362
1477
|
return succeeded;
|
|
1363
1478
|
}
|
|
1364
1479
|
|
|
1480
|
+
const UPLOAD_LANE = "slow";
|
|
1481
|
+
/** Per serviceId — guard collect-log tick runs GC at most once per `gc.intervalMs`. */
|
|
1482
|
+
const lastGcAtMsByServiceId = new Map();
|
|
1483
|
+
async function pathExists$1(filePath) {
|
|
1484
|
+
try {
|
|
1485
|
+
await access(filePath, constants.F_OK);
|
|
1486
|
+
return true;
|
|
1487
|
+
}
|
|
1488
|
+
catch {
|
|
1489
|
+
return false;
|
|
1490
|
+
}
|
|
1491
|
+
}
|
|
1492
|
+
async function readBatchTmpFile(tmpPath) {
|
|
1493
|
+
try {
|
|
1494
|
+
const raw = await readFile(tmpPath, "utf8");
|
|
1495
|
+
const parsed = JSON.parse(raw);
|
|
1496
|
+
if (!Array.isArray(parsed.entries) || parsed.entries.length === 0) {
|
|
1497
|
+
return null;
|
|
1498
|
+
}
|
|
1499
|
+
const entries = parsed.entries.filter(isLogEntry);
|
|
1500
|
+
if (entries.length === 0) {
|
|
1501
|
+
return null;
|
|
1502
|
+
}
|
|
1503
|
+
return { entries, meta: parsed.meta };
|
|
1504
|
+
}
|
|
1505
|
+
catch {
|
|
1506
|
+
return null;
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
function processMetaKey(serviceId, processRole) {
|
|
1510
|
+
return `${serviceId}:${processRole}`;
|
|
1511
|
+
}
|
|
1512
|
+
async function uploadTmpBatch(input) {
|
|
1513
|
+
const parsed = parseLogSpoolBatchFilename(input.fileName);
|
|
1514
|
+
if (parsed == null) {
|
|
1515
|
+
spoolLogger.warn("collect-log skipped — invalid tmp filename", { fileName: input.fileName });
|
|
1516
|
+
return "failed";
|
|
1517
|
+
}
|
|
1518
|
+
const jsonFileName = input.fileName.replace(/\.tmp$/, ".json");
|
|
1519
|
+
const jsonPath = join(logSpoolProcessDir(input.spoolRoot, input.serviceId, input.processRole), jsonFileName);
|
|
1520
|
+
if (await pathExists$1(jsonPath)) {
|
|
1521
|
+
try {
|
|
1522
|
+
await unlink(input.tmpPath);
|
|
1523
|
+
spoolLogger.info("collect-log removed orphan tmp (json exists)", {
|
|
1524
|
+
tmpPath: input.tmpPath,
|
|
1525
|
+
jsonPath,
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
catch {
|
|
1529
|
+
// best-effort
|
|
1530
|
+
}
|
|
1531
|
+
return "skipped";
|
|
1532
|
+
}
|
|
1533
|
+
const batch = await readBatchTmpFile(input.tmpPath);
|
|
1534
|
+
if (batch == null) {
|
|
1535
|
+
spoolLogger.warn("collect-log skipped — tmp failed validation", {
|
|
1536
|
+
tmpPath: input.tmpPath,
|
|
1537
|
+
fileName: input.fileName,
|
|
1538
|
+
});
|
|
1539
|
+
try {
|
|
1540
|
+
await unlink(input.tmpPath);
|
|
1541
|
+
spoolLogger.info("collect-log removed invalid tmp", { tmpPath: input.tmpPath });
|
|
1542
|
+
}
|
|
1543
|
+
catch {
|
|
1544
|
+
// best-effort
|
|
1545
|
+
}
|
|
1546
|
+
return "failed";
|
|
1547
|
+
}
|
|
1548
|
+
const processKey = processMetaKey(input.serviceId, input.processRole);
|
|
1549
|
+
// TODO: `lane` is legacy transport metadata — scheduled for removal; fixed to "slow" for downstream decode compatibility.
|
|
1550
|
+
const idempotencyKey = computeLogBatchIdempotencyKey({
|
|
1551
|
+
service: input.serviceValue,
|
|
1552
|
+
process: processKey,
|
|
1553
|
+
lane: UPLOAD_LANE,
|
|
1554
|
+
entries: batch.entries,
|
|
1555
|
+
});
|
|
1556
|
+
const draft = buildLogListDraft({
|
|
1557
|
+
service: input.serviceValue,
|
|
1558
|
+
process: processKey,
|
|
1559
|
+
lane: UPLOAD_LANE,
|
|
1560
|
+
idempotencyKey,
|
|
1561
|
+
entries: batch.entries,
|
|
1562
|
+
});
|
|
1563
|
+
try {
|
|
1564
|
+
await postLogBatch(draft, input.postTimeoutMs);
|
|
1565
|
+
}
|
|
1566
|
+
catch (error) {
|
|
1567
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1568
|
+
spoolLogger.error("collect-log upload failed", {
|
|
1569
|
+
fileName: input.fileName,
|
|
1570
|
+
processRole: input.processRole,
|
|
1571
|
+
error: message,
|
|
1572
|
+
});
|
|
1573
|
+
return "failed";
|
|
1574
|
+
}
|
|
1575
|
+
try {
|
|
1576
|
+
await rename(input.tmpPath, jsonPath);
|
|
1577
|
+
}
|
|
1578
|
+
catch (error) {
|
|
1579
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1580
|
+
spoolLogger.error("collect-log rename tmp→json failed after upload", {
|
|
1581
|
+
tmpPath: input.tmpPath,
|
|
1582
|
+
jsonPath,
|
|
1583
|
+
error: message,
|
|
1584
|
+
});
|
|
1585
|
+
return "failed";
|
|
1586
|
+
}
|
|
1587
|
+
spoolLogger.info("collect-log uploaded batch", {
|
|
1588
|
+
processRole: input.processRole,
|
|
1589
|
+
fileName: jsonFileName,
|
|
1590
|
+
entryCount: batch.entries.length,
|
|
1591
|
+
idempotencyKey,
|
|
1592
|
+
});
|
|
1593
|
+
return "uploaded";
|
|
1594
|
+
}
|
|
1595
|
+
async function gcTmpFiles(input) {
|
|
1596
|
+
const processDir = logSpoolProcessDir(input.spoolRoot, input.serviceId, input.processRole);
|
|
1597
|
+
let removed = 0;
|
|
1598
|
+
try {
|
|
1599
|
+
const names = await readdir(processDir);
|
|
1600
|
+
for (const name of names) {
|
|
1601
|
+
if (!name.endsWith(".tmp")) {
|
|
1602
|
+
continue;
|
|
1603
|
+
}
|
|
1604
|
+
const parsed = parseLogSpoolBatchFilename(name);
|
|
1605
|
+
if (parsed == null) {
|
|
1606
|
+
continue;
|
|
1607
|
+
}
|
|
1608
|
+
if (input.nowMs - parsed.timestampMs <= input.tmpRetentionMs) {
|
|
1609
|
+
continue;
|
|
1610
|
+
}
|
|
1611
|
+
try {
|
|
1612
|
+
await unlink(join(processDir, name));
|
|
1613
|
+
removed += 1;
|
|
1614
|
+
spoolLogger.info("collect-log gc removed stale tmp", {
|
|
1615
|
+
fileName: name,
|
|
1616
|
+
processRole: input.processRole,
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
catch {
|
|
1620
|
+
// best-effort
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
catch {
|
|
1625
|
+
// directory may not exist yet
|
|
1626
|
+
}
|
|
1627
|
+
return removed;
|
|
1628
|
+
}
|
|
1629
|
+
async function gcSyncedJsonFiles(input) {
|
|
1630
|
+
let removed = 0;
|
|
1631
|
+
for (const processRole of resolveAllLogSpoolProcessRoles()) {
|
|
1632
|
+
const processDir = logSpoolProcessDir(input.spoolRoot, input.serviceId, processRole);
|
|
1633
|
+
let names = [];
|
|
1634
|
+
try {
|
|
1635
|
+
names = await readdir(processDir);
|
|
1636
|
+
}
|
|
1637
|
+
catch {
|
|
1638
|
+
continue;
|
|
1639
|
+
}
|
|
1640
|
+
for (const name of names) {
|
|
1641
|
+
if (!name.endsWith(".json")) {
|
|
1642
|
+
continue;
|
|
1643
|
+
}
|
|
1644
|
+
if (parseLogSpoolBatchFilename(name) == null) {
|
|
1645
|
+
continue;
|
|
1646
|
+
}
|
|
1647
|
+
const jsonPath = join(processDir, name);
|
|
1648
|
+
try {
|
|
1649
|
+
const fileStat = await stat(jsonPath);
|
|
1650
|
+
if (input.nowMs - fileStat.mtimeMs <= input.syncedRetentionMs) {
|
|
1651
|
+
continue;
|
|
1652
|
+
}
|
|
1653
|
+
await unlink(jsonPath);
|
|
1654
|
+
removed += 1;
|
|
1655
|
+
spoolLogger.info("collect-log gc removed synced json", {
|
|
1656
|
+
fileName: name,
|
|
1657
|
+
processRole,
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
catch {
|
|
1661
|
+
// best-effort
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
return removed;
|
|
1666
|
+
}
|
|
1667
|
+
function shouldRunGc(serviceId, nowMs, intervalMs) {
|
|
1668
|
+
const lastAt = lastGcAtMsByServiceId.get(serviceId) ?? 0;
|
|
1669
|
+
if (nowMs - lastAt < intervalMs) {
|
|
1670
|
+
return false;
|
|
1671
|
+
}
|
|
1672
|
+
lastGcAtMsByServiceId.set(serviceId, nowMs);
|
|
1673
|
+
return true;
|
|
1674
|
+
}
|
|
1675
|
+
/**
|
|
1676
|
+
* Guard-only: upload pending `.tmp` batches, rename to `.json`, then periodic GC.
|
|
1677
|
+
* Upload completion is implied by `.json` presence; no sync-state file.
|
|
1678
|
+
*/
|
|
1679
|
+
async function runCollectLogTick(input) {
|
|
1680
|
+
const config = resolveLogSpoolConfig(input.config);
|
|
1681
|
+
const spoolRoot = input.spoolRoot ?? resolveLogSpoolRoot();
|
|
1682
|
+
const nowMs = input.nowMs ?? Date.now();
|
|
1683
|
+
const result = {
|
|
1684
|
+
uploaded: 0,
|
|
1685
|
+
skipped: 0,
|
|
1686
|
+
failed: 0,
|
|
1687
|
+
gcTmpRemoved: 0,
|
|
1688
|
+
gcSyncedRemoved: 0,
|
|
1689
|
+
};
|
|
1690
|
+
for (const processRole of resolveAllLogSpoolProcessRoles()) {
|
|
1691
|
+
const processDir = logSpoolProcessDir(spoolRoot, input.serviceId, processRole);
|
|
1692
|
+
let names = [];
|
|
1693
|
+
try {
|
|
1694
|
+
names = await readdir(processDir);
|
|
1695
|
+
}
|
|
1696
|
+
catch {
|
|
1697
|
+
continue;
|
|
1698
|
+
}
|
|
1699
|
+
for (const name of names) {
|
|
1700
|
+
if (!name.endsWith(".tmp")) {
|
|
1701
|
+
continue;
|
|
1702
|
+
}
|
|
1703
|
+
const status = await uploadTmpBatch({
|
|
1704
|
+
serviceId: input.serviceId,
|
|
1705
|
+
serviceValue: input.serviceValue,
|
|
1706
|
+
processRole,
|
|
1707
|
+
tmpPath: join(processDir, name),
|
|
1708
|
+
fileName: name,
|
|
1709
|
+
spoolRoot,
|
|
1710
|
+
postTimeoutMs: config.writer.postTimeoutMs,
|
|
1711
|
+
});
|
|
1712
|
+
if (status === "uploaded") {
|
|
1713
|
+
result.uploaded += 1;
|
|
1714
|
+
}
|
|
1715
|
+
else if (status === "skipped") {
|
|
1716
|
+
result.skipped += 1;
|
|
1717
|
+
}
|
|
1718
|
+
else {
|
|
1719
|
+
result.failed += 1;
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
if (shouldRunGc(input.serviceId, nowMs, config.gc.intervalMs)) {
|
|
1724
|
+
for (const processRole of resolveAllLogSpoolProcessRoles()) {
|
|
1725
|
+
result.gcTmpRemoved += await gcTmpFiles({
|
|
1726
|
+
spoolRoot,
|
|
1727
|
+
serviceId: input.serviceId,
|
|
1728
|
+
processRole,
|
|
1729
|
+
tmpRetentionMs: config.gc.tmpRetentionMs,
|
|
1730
|
+
nowMs,
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
result.gcSyncedRemoved = await gcSyncedJsonFiles({
|
|
1734
|
+
spoolRoot,
|
|
1735
|
+
serviceId: input.serviceId,
|
|
1736
|
+
syncedRetentionMs: config.gc.syncedRetentionMs,
|
|
1737
|
+
nowMs,
|
|
1738
|
+
});
|
|
1739
|
+
}
|
|
1740
|
+
if (result.uploaded > 0 || result.failed > 0) {
|
|
1741
|
+
spoolLogger.info("collect-log tick complete", { ...result, serviceId: input.serviceId });
|
|
1742
|
+
}
|
|
1743
|
+
return result;
|
|
1744
|
+
}
|
|
1745
|
+
|
|
1746
|
+
const COLLECT_LOG_RUNNER_KEY = "collect-log";
|
|
1747
|
+
/**
|
|
1748
|
+
* Guard process only — uploads `.tmp` spool batches and runs GC.
|
|
1749
|
+
* Register before {@link TriggerNode.start} (e.g. in {@link ServiceGuardNode.create}).
|
|
1750
|
+
*/
|
|
1751
|
+
function registerCollectLogRunner(options) {
|
|
1752
|
+
if (!logSpoolEnabledFromEnv()) {
|
|
1753
|
+
return;
|
|
1754
|
+
}
|
|
1755
|
+
const config = logSpoolConfigFromEnv();
|
|
1756
|
+
const intervalMs = options.intervalMs ?? config.collectIntervalMs;
|
|
1757
|
+
TriggerManager.registerRunner({
|
|
1758
|
+
key: options.runnerKey ?? COLLECT_LOG_RUNNER_KEY,
|
|
1759
|
+
intervalMs,
|
|
1760
|
+
initialDelayMs: options.initialDelayMs ?? 0,
|
|
1761
|
+
retryCount: 1,
|
|
1762
|
+
fn: async (ctx) => {
|
|
1763
|
+
const serviceId = await options.getServiceId();
|
|
1764
|
+
if (serviceId == null) {
|
|
1765
|
+
ctx.logger.warn("collect-log skipped — serviceId unavailable", { topic: LOG_TOPIC_TRIGGER });
|
|
1766
|
+
return;
|
|
1767
|
+
}
|
|
1768
|
+
const result = await runCollectLogTick({
|
|
1769
|
+
serviceId,
|
|
1770
|
+
serviceValue: options.serviceValue,
|
|
1771
|
+
spoolRoot: options.spoolRoot,
|
|
1772
|
+
config,
|
|
1773
|
+
});
|
|
1774
|
+
if (result.uploaded > 0 || result.failed > 0) {
|
|
1775
|
+
ctx.logger.info("collect-log runner finished", {
|
|
1776
|
+
topic: LOG_TOPIC_TRIGGER,
|
|
1777
|
+
data: result,
|
|
1778
|
+
});
|
|
1779
|
+
}
|
|
1780
|
+
},
|
|
1781
|
+
});
|
|
1782
|
+
spoolLogger.info("collect-log runner registered", {
|
|
1783
|
+
intervalMs,
|
|
1784
|
+
serviceValue: options.serviceValue,
|
|
1785
|
+
});
|
|
1786
|
+
}
|
|
1787
|
+
|
|
1365
1788
|
/**
|
|
1366
1789
|
* Run registry slot ownership check and optionally SIGTERM the parent main process.
|
|
1367
1790
|
* Used by guard / supervisor TriggerNode runners across L3 services.
|
|
@@ -1646,6 +2069,10 @@ class ServiceGuardNode extends TriggerNode {
|
|
|
1646
2069
|
logTopic: options.logTopic,
|
|
1647
2070
|
...options.guardRunner,
|
|
1648
2071
|
});
|
|
2072
|
+
registerCollectLogRunner({
|
|
2073
|
+
serviceValue: options.serviceValue,
|
|
2074
|
+
getServiceId: options.guardRunner.getServiceId,
|
|
2075
|
+
});
|
|
1649
2076
|
return new ServiceGuardNode(options);
|
|
1650
2077
|
}
|
|
1651
2078
|
async onBeforeRegisterNode(nodeLogger) {
|
|
@@ -1735,11 +2162,21 @@ function createServiceHost(options) {
|
|
|
1735
2162
|
}
|
|
1736
2163
|
throw error;
|
|
1737
2164
|
}
|
|
2165
|
+
const hostCtx = { service: session.service, session, serviceId: session.service.id };
|
|
1738
2166
|
if (options.onRegistryClaimed != null) {
|
|
1739
|
-
await options.onRegistryClaimed(
|
|
2167
|
+
await options.onRegistryClaimed(hostCtx);
|
|
2168
|
+
}
|
|
2169
|
+
const enableSpool = options.enableLogSpoolAfterClaim ?? true;
|
|
2170
|
+
if (enableSpool && logSpoolEnabledFromEnv()) {
|
|
2171
|
+
process.env[LOG_SPOOL_SERVICE_ID_ENV] = session.service.id;
|
|
2172
|
+
await ensureLogSpoolFromEnv({
|
|
2173
|
+
serviceId: session.service.id,
|
|
2174
|
+
serviceValue: options.serviceValue,
|
|
2175
|
+
processRole: "main",
|
|
2176
|
+
});
|
|
1740
2177
|
}
|
|
1741
2178
|
if (options.startSupervisors != null) {
|
|
1742
|
-
await options.startSupervisors();
|
|
2179
|
+
await options.startSupervisors(hostCtx);
|
|
1743
2180
|
}
|
|
1744
2181
|
if (options.waitUntilReady != null) {
|
|
1745
2182
|
await options.waitUntilReady();
|
|
@@ -2265,58 +2702,66 @@ const RepoManager = {
|
|
|
2265
2702
|
clearRepoScriptModuleCache,
|
|
2266
2703
|
};
|
|
2267
2704
|
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
* Each L3 service exports one instance from `src/startup/log-persist.ts`.
|
|
2271
|
-
*/
|
|
2272
|
-
function createLogPersistCoordinator(options) {
|
|
2273
|
-
const { service, registryFilePath, expectedProcesses, readyTimeoutMs } = options;
|
|
2705
|
+
function createLogSpoolCoordinator(options) {
|
|
2706
|
+
const { serviceValue, serviceId } = options;
|
|
2274
2707
|
return {
|
|
2275
2708
|
isEnabled() {
|
|
2276
|
-
return
|
|
2709
|
+
return logSpoolEnabledFromEnv();
|
|
2277
2710
|
},
|
|
2278
|
-
|
|
2279
|
-
return
|
|
2711
|
+
getServiceId() {
|
|
2712
|
+
return serviceId;
|
|
2280
2713
|
},
|
|
2281
2714
|
registerProcess(process) {
|
|
2282
|
-
return
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
});
|
|
2287
|
-
},
|
|
2288
|
-
waitForAllProcessesReady() {
|
|
2289
|
-
return waitForLogPersistReady({
|
|
2290
|
-
registryFilePath,
|
|
2291
|
-
service,
|
|
2292
|
-
expectedProcesses: [...expectedProcesses],
|
|
2293
|
-
timeoutMs: readyTimeoutMs,
|
|
2294
|
-
});
|
|
2295
|
-
},
|
|
2296
|
-
async snapshotProcessesReady() {
|
|
2297
|
-
if (!logPersistEnabledFromEnv()) {
|
|
2298
|
-
return null;
|
|
2299
|
-
}
|
|
2300
|
-
return snapshotLogPersistReady({
|
|
2301
|
-
registryFilePath,
|
|
2302
|
-
expectedProcesses: [...expectedProcesses],
|
|
2715
|
+
return ensureLogSpoolFromEnv({
|
|
2716
|
+
serviceValue,
|
|
2717
|
+
serviceId,
|
|
2718
|
+
processRole: process,
|
|
2303
2719
|
});
|
|
2304
2720
|
},
|
|
2305
|
-
|
|
2306
|
-
if (!
|
|
2721
|
+
getWriterStats() {
|
|
2722
|
+
if (!logSpoolEnabledFromEnv()) {
|
|
2307
2723
|
return null;
|
|
2308
2724
|
}
|
|
2309
|
-
return
|
|
2725
|
+
return getLogSpoolStats();
|
|
2310
2726
|
},
|
|
2311
|
-
async
|
|
2312
|
-
if (!
|
|
2727
|
+
async shutdownLogSpool() {
|
|
2728
|
+
if (!logSpoolEnabledFromEnv()) {
|
|
2313
2729
|
return;
|
|
2314
2730
|
}
|
|
2315
|
-
await
|
|
2731
|
+
await shutdownLogSpoolFromEnv();
|
|
2316
2732
|
},
|
|
2317
2733
|
};
|
|
2318
2734
|
}
|
|
2319
2735
|
|
|
2736
|
+
/** Whether file log spool is enabled (`LOG_PERSIST_ENABLED=true`). */
|
|
2737
|
+
function isLogSpoolEnabled(env = process.env) {
|
|
2738
|
+
return logSpoolEnabledFromEnv(env);
|
|
2739
|
+
}
|
|
2740
|
+
/**
|
|
2741
|
+
* Guard / scheduler / worker (and extra roles) — enable writer from spawn env.
|
|
2742
|
+
* Main is enabled by `createServiceHost` after registry claim.
|
|
2743
|
+
*/
|
|
2744
|
+
async function enableLogSpoolFromEnvInChild() {
|
|
2745
|
+
if (!logSpoolEnabledFromEnv()) {
|
|
2746
|
+
return;
|
|
2747
|
+
}
|
|
2748
|
+
await ensureLogSpoolFromEnv();
|
|
2749
|
+
}
|
|
2750
|
+
/** Writer buffer stats when spool enabled; `null` when disabled. Typical use: main observability. */
|
|
2751
|
+
function getMainLogSpoolWriterStats() {
|
|
2752
|
+
if (!logSpoolEnabledFromEnv()) {
|
|
2753
|
+
return null;
|
|
2754
|
+
}
|
|
2755
|
+
return getLogSpoolStats();
|
|
2756
|
+
}
|
|
2757
|
+
/** Flush memory buffer and disable writer when spool enabled; no-op otherwise. */
|
|
2758
|
+
async function shutdownLogSpool() {
|
|
2759
|
+
if (!logSpoolEnabledFromEnv()) {
|
|
2760
|
+
return;
|
|
2761
|
+
}
|
|
2762
|
+
await shutdownLogSpoolFromEnv();
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2320
2765
|
const EMPTY_RESULT = {
|
|
2321
2766
|
status: "not_configured",
|
|
2322
2767
|
registered: [],
|
|
@@ -3228,5 +3673,5 @@ const patchTriggerFired = validateWithSchema(patchTriggerFiredSchema, "patchTrig
|
|
|
3228
3673
|
}
|
|
3229
3674
|
});
|
|
3230
3675
|
|
|
3231
|
-
export { BaseNodeRuntime, CategoryCommand, CategoryNode, CategoryRepo, CategoryTrigger, CommandType, EMPTY_REGISTRY_SLOT_RUNTIME_STATE, LOG_TOPIC_TRIGGER, LogLevel, MAX_POLL_TARGET_LIST_SIZE, ManagedChildProcesses, NodeStatus, RepoManager, ResultCode, SERVICE_GUARD_RUNNER_KEY, ServiceGuardNode, ServiceRegistryError, TASK_LOCAL_PACKAGE_CONFIG_FILENAME, TASK_REPO_SCRIPT_CATEGORY, TASK_REPO_USAGE, TASK_RUNNER_CONFIG_DIR, TASK_RUNNER_ROOT_CONFIG_FILENAME, TASK_RUNNER_ROOT_CONFIG_LEGACY_RELATIVE_PATH, TASK_RUNNER_ROOT_CONFIG_RELATIVE_PATH, TRIGGER_LOOP_INTERVAL_MS, TRIGGER_RUNNER_DEFAULT_RETRY_COUNT, TRIGGER_RUNNER_DEFAULT_RETRY_DELAY_MS, TaskManager, TaskNode, TaskRepoValidation, TaskStatus, TaskStatusAction, TriggerManager, TriggerNode, TriggerStatus, applyRegistrySlotGuardStep, buildNodeImportArgs, claimServiceRegistrySlot, createJsonFileStateStore,
|
|
3676
|
+
export { BaseNodeRuntime, COLLECT_LOG_RUNNER_KEY, CategoryCommand, CategoryNode, CategoryRepo, CategoryTrigger, CommandType, EMPTY_REGISTRY_SLOT_RUNTIME_STATE, LOG_SPOOL_SERVICE_ID_ENV, LOG_TOPIC_TRIGGER, LogLevel, MAX_POLL_TARGET_LIST_SIZE, ManagedChildProcesses, NodeStatus, RepoManager, ResultCode, SERVICE_GUARD_RUNNER_KEY, ServiceGuardNode, ServiceRegistryError, TASK_LOCAL_PACKAGE_CONFIG_FILENAME, TASK_REPO_SCRIPT_CATEGORY, TASK_REPO_USAGE, TASK_RUNNER_CONFIG_DIR, TASK_RUNNER_ROOT_CONFIG_FILENAME, TASK_RUNNER_ROOT_CONFIG_LEGACY_RELATIVE_PATH, TASK_RUNNER_ROOT_CONFIG_RELATIVE_PATH, TRIGGER_LOOP_INTERVAL_MS, TRIGGER_RUNNER_DEFAULT_RETRY_COUNT, TRIGGER_RUNNER_DEFAULT_RETRY_DELAY_MS, TaskManager, TaskNode, TaskRepoValidation, TaskStatus, TaskStatusAction, TriggerManager, TriggerNode, TriggerStatus, applyRegistrySlotGuardStep, buildNodeImportArgs, claimServiceRegistrySlot, createJsonFileStateStore, createLogSpoolCoordinator, createLogger, createManagedChildProcesses, createPathsExistCheck, createRequiredEnvCheck, createServiceHost, createServiceRuntimeStateStore, createSupabaseReachableCheck, createTarget, enableLogSpoolFromEnvInChild, ensureLogSpoolFromEnv, evaluateBusyNodeLiveness, generateResponse, getConfigFileDir, getLogSpoolStats, getMainLogSpoolWriterStats, getPollCommandList, getPollCommandListSchema, getPossibleTarget, getScanRemoteRepoValues, getWorkerSpawnCooldownLastAt, importJsConfigModule, initSupabaseFromStandardEnv, isChildProcessRunning, isLogEntry, isLogSpoolEnabled, isOptimisticLockResponse, loadCachedJsConfigModule, loadEnvFiles, logManager, logSpoolEnabledFromEnv, markWorkerSpawned, nodeBufferToArrayBuffer, patchChangeNodeStatus, patchChangeTaskStatus, patchClaimTask, patchNodeHeartBeat, patchServiceRuntime, patchStopNode, patchTriggerFired, patchTriggerFiredSchema, pathExists, pollTargetList, pollUntil, postCommand, postCommandSchema, postRegisterNode, postTaskSchema, postTaskWithValidation, postTrigger, postTriggerSchema, publicBaseUrlFromEnv, readAndVerifySourceFile, readEnv, registerCollectLogRunner, registerServiceGuardRunner, registrySlotRuntimePatchFromGuardResult, requireEnv, resolveFirstExistingPath, resolveLogSpoolRoot, resolvePathFromBaseDir, resolvePathFromConfigFile, resolvePathFromCwd, runCollectLogTick, runReadinessChecks, runReadinessGate, runRegistrySlotGuardCheck, runServiceGuardTick, runSingleProcessService, scanEnabledTriggers, scanEnabledTriggersSchema, scanTargetList, sha256Hex, shutdownLogSpool, shutdownLogSpoolFromEnv, spawnTsxChild, supabase, toFileImportHref, updateTargetDetails, validateTaskRepoAndParams, validateWithSchema, waitForServiceReady };
|
|
3232
3677
|
//# sourceMappingURL=node.js.map
|