@kici-dev/shared 0.5.0 → 0.6.1

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/db.js CHANGED
@@ -76,7 +76,8 @@ function isPoolAcquireTimeout(err) {
76
76
  * its own schema type (e.g., orchestrator Database vs Platform Database).
77
77
  */
78
78
  function createDb(pool) {
79
- return new Kysely({ dialect: new PostgresDialect({ pool }) });
79
+ const dialect = new PostgresDialect({ pool });
80
+ return new Kysely({ dialect });
80
81
  }
81
82
  //#endregion
82
83
  export { createDb, createPool, isPoolAcquireTimeout };
@@ -1,19 +1,17 @@
1
1
  /**
2
2
  * Shared debug-bundle archive primitives.
3
3
  *
4
- * Allowlist config redaction and windowed log-file archiving, used by the
5
- * orchestrator's in-process bundle writer, the kici-admin CLI's local bundle,
6
- * and the agent's fleet mini-bundle assembler. Keeping one copy means a node
7
- * cannot drift from the redaction posture of its peers.
4
+ * Windowed log-file archiving, used by the orchestrator's in-process bundle
5
+ * writer, the kici-admin CLI's local bundle, and the agent's fleet mini-bundle
6
+ * assembler. Keeping one copy means a node cannot drift from the archiving
7
+ * posture of its peers.
8
+ *
9
+ * The redaction primitives it applies live in `@kici-dev/core` so the `kici`
10
+ * CLI can reuse them without importing this package.
8
11
  */
9
12
  import type { Archiver } from 'archiver';
10
13
  /** Maximum total log bytes to include in bundle (50MB). */
11
14
  export declare const MAX_LOG_BYTES: number;
12
- /**
13
- * Redact config values using allowlist approach.
14
- * Only known-safe fields are preserved; everything else becomes "****".
15
- */
16
- export declare function redactConfig(obj: unknown, parentKey?: string): unknown;
17
15
  /**
18
16
  * Add log files from logDir to the archive, respecting MAX_LOG_BYTES cap
19
17
  * and the logWindow time filter. Matches any `*.log` file in the directory,
@@ -1,94 +1,21 @@
1
1
  import "../rolldown-runtime-ClRpJifh.js";
2
+ import { scrubText } from "@kici-dev/core";
2
3
  import * as fs from "node:fs";
3
4
  import * as path$1 from "node:path";
4
5
  //#region src/diagnostics/bundle-archive.ts
5
6
  /**
6
7
  * Shared debug-bundle archive primitives.
7
8
  *
8
- * Allowlist config redaction and windowed log-file archiving, used by the
9
- * orchestrator's in-process bundle writer, the kici-admin CLI's local bundle,
10
- * and the agent's fleet mini-bundle assembler. Keeping one copy means a node
11
- * cannot drift from the redaction posture of its peers.
9
+ * Windowed log-file archiving, used by the orchestrator's in-process bundle
10
+ * writer, the kici-admin CLI's local bundle, and the agent's fleet mini-bundle
11
+ * assembler. Keeping one copy means a node cannot drift from the archiving
12
+ * posture of its peers.
13
+ *
14
+ * The redaction primitives it applies live in `@kici-dev/core` so the `kici`
15
+ * CLI can reuse them without importing this package.
12
16
  */
13
17
  /** Maximum total log bytes to include in bundle (50MB). */
14
- const MAX_LOG_BYTES = 50 * 1024 * 1024;
15
- /**
16
- * Config field names that are safe to include unredacted.
17
- * Everything else gets replaced with "****".
18
- */
19
- const SAFE_CONFIG_KEYS = /* @__PURE__ */ new Set([
20
- "mode",
21
- "host",
22
- "port",
23
- "logLevel",
24
- "region",
25
- "environment",
26
- "name",
27
- "label",
28
- "labels",
29
- "enabled",
30
- "disabled",
31
- "timeout",
32
- "interval",
33
- "maxRetries",
34
- "retries",
35
- "workers",
36
- "concurrency",
37
- "maxConcurrency",
38
- "batchSize",
39
- "bufferSize",
40
- "warmPool",
41
- "cooldown",
42
- "type",
43
- "provider",
44
- "scaler",
45
- "driver",
46
- "backend",
47
- "protocol",
48
- "scheme",
49
- "path",
50
- "basePath",
51
- "metricsPath",
52
- "healthPath",
53
- "logFormat",
54
- "logFile",
55
- "logDir",
56
- "dataDir",
57
- "version",
58
- "debug",
59
- "verbose",
60
- "quiet",
61
- "tls",
62
- "cors",
63
- "rateLimiting",
64
- "maxConnections",
65
- "poolSize",
66
- "minPool",
67
- "maxPool",
68
- "idleTimeout",
69
- "connectTimeout",
70
- "requestTimeout",
71
- "shutdownTimeout",
72
- "gracefulShutdown"
73
- ]);
74
- /**
75
- * Redact config values using allowlist approach.
76
- * Only known-safe fields are preserved; everything else becomes "****".
77
- */
78
- function redactConfig(obj, parentKey) {
79
- if (obj === null || obj === void 0) return obj;
80
- if (Array.isArray(obj)) return obj.map((item) => redactConfig(item, parentKey));
81
- if (typeof obj === "object") {
82
- const result = {};
83
- for (const [key, value] of Object.entries(obj)) result[key] = redactConfig(value, key);
84
- return result;
85
- }
86
- if (typeof obj === "string" && parentKey && !SAFE_CONFIG_KEYS.has(parentKey)) return "****";
87
- if (typeof obj === "number" || typeof obj === "boolean") return obj;
88
- if (typeof obj === "string" && parentKey && SAFE_CONFIG_KEYS.has(parentKey)) return obj;
89
- if (typeof obj === "string") return "****";
90
- return obj;
91
- }
18
+ const MAX_LOG_BYTES = 52428800;
92
19
  /**
93
20
  * Add log files from logDir to the archive, respecting MAX_LOG_BYTES cap
94
21
  * and the logWindow time filter. Matches any `*.log` file in the directory,
@@ -117,9 +44,9 @@ async function addLogsToArchive(archive, logDir, logWindowHours) {
117
44
  const filePath = path$1.join(logDir, entry);
118
45
  const stat = fs.statSync(filePath);
119
46
  if (totalBytes + stat.size > 52428800) break;
120
- const content = fs.readFileSync(filePath, "utf-8");
47
+ const content = scrubText(fs.readFileSync(filePath, "utf-8"));
121
48
  archive.append(content, { name: `logs/${entry}` });
122
- totalBytes += stat.size;
49
+ totalBytes += Buffer.byteLength(content, "utf-8");
123
50
  const lines = content.split("\n");
124
51
  totalLines += lines.length;
125
52
  for (const line of lines) {
@@ -136,6 +63,6 @@ async function addLogsToArchive(archive, logDir, logWindowHours) {
136
63
  archive.append(JSON.stringify(summary, null, 2), { name: "logs/summary.json" });
137
64
  }
138
65
  //#endregion
139
- export { MAX_LOG_BYTES, addLogsToArchive, redactConfig };
66
+ export { MAX_LOG_BYTES, addLogsToArchive };
140
67
 
141
68
  //# sourceMappingURL=bundle-archive.js.map
@@ -9,7 +9,7 @@ import "../rolldown-runtime-ClRpJifh.js";
9
9
  * the receiver. Used on both the orchestrator-agent and peer channels.
10
10
  */
11
11
  /** Raw bytes per chunk before base64 (matches webhook-relay's ~85 KiB frames). */
12
- const FLEET_CHUNK_BYTES = 85 * 1024;
12
+ const FLEET_CHUNK_BYTES = 87040;
13
13
  /** Split a Buffer into ordered base64 frames. An empty buffer yields one final frame. */
14
14
  function chunkBuffer(buf, chunkBytes = FLEET_CHUNK_BYTES) {
15
15
  const frames = [];
@@ -112,12 +112,13 @@ export declare function defineEnv<TShape extends z.ZodRawShape>(opts: DefineEnvO
112
112
  * `hack/lib/commit-build-counter.mjs` (skip the per-build `.build-counter`
113
113
  * commit on a force-synced checkout, e.g. a remote E2E executor). Set in the
114
114
  * ambient shell for `pnpm build`; the native orchestrator spawn inherits it.
115
- * - `KICI_TEST_ISOLATION`: the test-isolation marker set at config-eval time
116
- * by every vitest config in this repository (`hack/lib/vitest-isolation.ts`,
117
- * enforced by `hack/check-vitest-isolation.ts`). It makes the CLI's
118
- * `getConfigDir` refuse the developer machine's ambient `~/.kici` config, and
119
- * it is inherited by every service a test spawns — same leak-by-inheritance
120
- * shape as the `KICI_E2E_` prefix below.
115
+ * - `KICI_CONFIG_DIR`: the isolated, empty config directory the vitest harness
116
+ * sets at config-eval time (`hack/lib/vitest-isolation.ts`, enforced by
117
+ * `hack/check-vitest-isolation.ts`) so the CLI's `getConfigDir` reads a
118
+ * throwaway dir instead of the developer machine's ambient `~/.kici`. It is a
119
+ * real CLI var (not a config typo) inherited by every service a test spawns —
120
+ * which do not read it — same leak-by-inheritance shape as the `KICI_E2E_`
121
+ * prefix below.
121
122
  *
122
123
  * Keep this list small and well-justified. Every addition is a typo we can
123
124
  * no longer catch, so only list things that are (a) actually set in the
@@ -231,12 +231,13 @@ function suggestClosest(name, candidates) {
231
231
  * `hack/lib/commit-build-counter.mjs` (skip the per-build `.build-counter`
232
232
  * commit on a force-synced checkout, e.g. a remote E2E executor). Set in the
233
233
  * ambient shell for `pnpm build`; the native orchestrator spawn inherits it.
234
- * - `KICI_TEST_ISOLATION`: the test-isolation marker set at config-eval time
235
- * by every vitest config in this repository (`hack/lib/vitest-isolation.ts`,
236
- * enforced by `hack/check-vitest-isolation.ts`). It makes the CLI's
237
- * `getConfigDir` refuse the developer machine's ambient `~/.kici` config, and
238
- * it is inherited by every service a test spawns — same leak-by-inheritance
239
- * shape as the `KICI_E2E_` prefix below.
234
+ * - `KICI_CONFIG_DIR`: the isolated, empty config directory the vitest harness
235
+ * sets at config-eval time (`hack/lib/vitest-isolation.ts`, enforced by
236
+ * `hack/check-vitest-isolation.ts`) so the CLI's `getConfigDir` reads a
237
+ * throwaway dir instead of the developer machine's ambient `~/.kici`. It is a
238
+ * real CLI var (not a config typo) inherited by every service a test spawns —
239
+ * which do not read it — same leak-by-inheritance shape as the `KICI_E2E_`
240
+ * prefix below.
240
241
  *
241
242
  * Keep this list small and well-justified. Every addition is a typo we can
242
243
  * no longer catch, so only list things that are (a) actually set in the
@@ -246,7 +247,7 @@ const RESERVED_NON_SCHEMA_KICI_VARS = [
246
247
  "KICI_CACHE",
247
248
  "KICI_DEV",
248
249
  "KICI_BUILD_COUNTER_NO_COMMIT",
249
- "KICI_TEST_ISOLATION"
250
+ "KICI_CONFIG_DIR"
250
251
  ];
251
252
  /**
252
253
  * `KICI_*` prefixes that are entirely outside the service-config namespace —
@@ -44,8 +44,12 @@ export interface GracefulShutdownOptions {
44
44
  * trigger shutdown programmatically (e.g., from SIGUSR1 drain handlers).
45
45
  */
46
46
  export interface ShutdownHandle {
47
- /** Trigger shutdown with the given reason string. */
48
- shutdown(signal: string): Promise<void>;
47
+ /**
48
+ * Trigger shutdown with the given reason string. Pass a non-zero `code` for a
49
+ * deliberate-but-failed stop (e.g. a one-shot agent whose self-bootstrap claim
50
+ * was rejected) so the process exits non-zero; omit it for a clean stop.
51
+ */
52
+ shutdown(signal: string, code?: number): Promise<void>;
49
53
  }
50
54
  /**
51
55
  * Wire up SIGTERM / SIGINT (and optionally uncaughtException /
@@ -77,7 +77,7 @@ function setupGracefulShutdown(options) {
77
77
  gracefulShutdown("unhandledRejection", 1);
78
78
  });
79
79
  }
80
- return { shutdown: (signal) => gracefulShutdown(signal) };
80
+ return { shutdown: (signal, code = 0) => gracefulShutdown(signal, code) };
81
81
  }
82
82
  //#endregion
83
83
  export { setupGracefulShutdown };
@@ -195,7 +195,8 @@ function renderEnvDiffBody(entry, opts) {
195
195
  const local = entry.localContent ?? "";
196
196
  const remote = entry.category === "new" ? "" : entry.remoteContent ?? "";
197
197
  if (local === "" && remote === "" && entry.category !== "new") return [];
198
- return renderEnvDiff(diffEnvFiles(local, remote), {
198
+ const diff = diffEnvFiles(local, remote);
199
+ return renderEnvDiff(diff, {
199
200
  reveal: opts.revealEnvValues ?? false,
200
201
  color: opts.color ?? false
201
202
  });
package/dist/index.d.ts CHANGED
@@ -2,11 +2,11 @@ export * from '@kici-dev/core';
2
2
  export * from './agent-platform.js';
3
3
  export { encrypt, decrypt, deriveKey, generateMasterKey, type EncryptedValue, } from './secret-crypto.js';
4
4
  export { RingBuffer } from './ring-buffer.js';
5
- export { redactConfig, addLogsToArchive, MAX_LOG_BYTES } from './diagnostics/bundle-archive.js';
5
+ export { addLogsToArchive, MAX_LOG_BYTES } from './diagnostics/bundle-archive.js';
6
6
  export { chunkBuffer, BundleChunkAssembler, ChunkRequestWaiter, FLEET_CHUNK_BYTES, type BundleChunkFrame, } from './diagnostics/bundle-chunks.js';
7
7
  export { createPool, createDb, isPoolAcquireTimeout, type CreatePoolOptions, type PgPoolErrorSource, type PoolAcquireOutcome, } from './db.js';
8
8
  export { isPgUniqueViolation } from './pg-errors.js';
9
- export { parseDatabaseUrl, maskDatabaseUrl, dropAndCreateDatabase, dropDatabaseDirect, ensureDatabase, type EnsureDatabaseOpts, createDbRole, createReadOnlyDbUser, computeMigrationsHash, storeMigrationContentHash, readStoredMigrationContentHash, isSchemaCurrent, clearDispatchQueueDirect, clearScalerStateDirect, purgeStaleExecutionDirect, purgeStaleSourcesDirect, purgeScopedSecretsDirect, purgeContextsDirect, seedContextDirect, deleteContextDirect, seedContextBindingDirect, setContextPolicyDirect, listContextsDirect, showContextDirect, createContextTemplateDirect, setContextSecretDirect, listQueueDirect, showQueueEntryDirect, listExecutionRunsDirect, showExecutionRunDirect, listCheckRunTrackingDirect, listExecutionJobsDirect, listRegistrationsDirect, showRegistrationDirect, registerWorkflowManualDirect, resetRaftStateDirect, emitKiciEventDirect, seedGenericWebhookSourceDirect, purgeSecretBackendsDirect, apiKeyExistsDirect, seedApiKeyInlineDirect, platformConnectionExistsDirect, countWebhookSourcesByConnectionIdDirect, getWebhookSourceByRoutingKeyDirect, findAnyUserApiKeyIdDirect, seedSyntheticGithubSourceDirect, seedWebhookSecretDirect, seedSourcePrivateKeyDirect, bumpRegistryVersionDirect, pollKiciEventsDirect, waitForPostgresDirect, waitForRunCompletionDirect, cleanupExecutionRowsDirect, isSchemaCurrentFromFilesDirect, storeMigrationContentHashInTableDirect, createJoinTokenDirect, deleteJoinTokensByCreatedByDirect, updateSourceRoutingKeyDirect, prunePeerCredentialsDirect, waitForPlatformRegistrationsDirect, seedUniversalGitSourceDirect, seedCiSecurityFixturesDirect, CI_SECURITY_OTHER_REPO, waitForExecutionRunReachesStatusSinceDirect, latestExecutionRunByStatusDirect, waitForLatestExecutionJobStatusDirect, describeTableColumnsDirect, tableExistsDirect, insertKiciEventRawDirect, showKiciEventDirect, listKiciEventsDirect, deleteKiciEventsDirect, insertKiciEventAtDirect, paginateUnprocessedEventsKeysetDirect, verifyKiciEventNotifyDirect, seedCrossRepoTrustDirect, listCrossRepoTrustBySourceRoutingKeyDirect, deleteCrossRepoTrustDirect, insertCrossRepoTrustStrictDirect, deleteWorkflowRegistrationsDirect, getWorkflowRegistrationByIdDirect, listRegistrationsByRoutingKeyDirect, waitForRegistrationsByRoutingKeyDirect, waitForRegistrationsUpdatedAtAdvanceDirect, updateWorkflowRegistrationCommitShaDirect, insertWorkflowRegistrationRawDirect, insertWorkflowRegistrationStrictDirect, getRegistryVersionDirect, bumpRegistryVersionSimpleDirect, upsertCronLastFiredDirect, countCronLastFiredDirect, insertCronLastFiredNowDirect, deleteCronLastFiredDirect, deleteExecutionRunsByWorkflowNameDirect, getGenericWebhookSourceByRoutingKeyDirect, listActiveGenericWebhookSourcesDirect, updateGenericWebhookVerificationConfigDirect, deleteGenericWebhookSourcesByNameDirect, restoreSoftDeletedGenericWebhookSourceDirect, upsertOrgSettingsGlobalWorkflowsDirect, setClusterGlobalWorkflowsEnabledDirect, updateOrgSettingsDeniedReposDirect, deleteOrgSettingsByCustomerIdDirect, getExecutionRunSecurityDirect, getHeldRunByIdDirect, listHeldRunApprovalsDirect, countHeldRunsByRunIdDirect, waitForPlatformExecutionRunStatusDirect, waitForPlatformEventLogDistinctRoutedDirect, waitForEventLogRowByDeliveryIdDirect, resolvePlatformWebhookSourceRoutingKeyDirect, ensureOrgOwnerMemberDirect, deletePeerCredentialsByInstanceIdLikeDirect, insertPeerCredentialExpiredDirect, getPeerCredentialRevokedAtDirect, listActivePeerCredentialsExcludingDirect, clearPeerCredentialsRevokedAtByIdsDirect, countActivePeerCredentialsByInstanceDirect, terminateIdleDbBackendsDirect, type ColumnInfo, type KiciEventRow, type CrossRepoTrustRow, type WorkflowRegistrationFullRow, type RegistrationsScopedResult, type LatestExecutionRunResult, type WaitForLatestJobResult, type ExecutionRunSecurityRow, type HeldRunSecurityRow, type EventLogRow as PlatformEventLogRow, type UpsertOrgSettingsOpts, type OrgSettingsRepoPatternEntry, type InsertKiciEventRawOpts, type EmitKiciEventOpts, type SeedGenericWebhookSourceOpts, REGISTERABLE_TRIGGER_TYPES, MIGRATION_HASH_TABLE, type PurgeStaleExecutionResult, type PurgeStaleSourcesResult, type SeedContextOpts, type SeedContextResult, type SeedContextBindingOpts, type SetContextPolicyOpts, type ContextRow, type ContextVariableRow, type ContextBindingRow, type ShowContextResult, type CreateContextTemplateOpts, type SetContextSecretOpts, type DispatchQueueRow, type ListQueueOpts, type ExecutionRunRow, type ExecutionJobRow, type ListExecutionRunsOpts, type CheckRunTrackingDirectRow, type ListCheckRunTrackingOpts, type WorkflowRegistrationRow, type ListRegistrationsOpts, type ListRegistrationsResult, type ShowRegistrationResult, type RegisterWorkflowManualOpts, type RegisterWorkflowManualResult, } from './db-admin.js';
9
+ export { parseDatabaseUrl, maskDatabaseUrl, dropAndCreateDatabase, ensureDatabase, type EnsureDatabaseOpts, createDbRole, createReadOnlyDbUser, computeMigrationsHash, storeMigrationContentHash, readStoredMigrationContentHash, isSchemaCurrent, clearDispatchQueueDirect, purgeStaleExecutionDirect, purgeStaleSourcesDirect, purgeScopedSecretsDirect, purgeContextsDirect, seedContextDirect, deleteContextDirect, seedContextBindingDirect, setContextPolicyDirect, listContextsDirect, showContextDirect, createContextTemplateDirect, setContextSecretDirect, listQueueDirect, showQueueEntryDirect, listExecutionRunsDirect, showExecutionRunDirect, listCheckRunTrackingDirect, listRegistrationsDirect, showRegistrationDirect, registerWorkflowManualDirect, resetRaftStateDirect, emitKiciEventDirect, purgeSecretBackendsDirect, prunePeerCredentialsDirect, type EventLogRow as PlatformEventLogRow, type OrgSettingsRepoPatternEntry, type EmitKiciEventOpts, REGISTERABLE_TRIGGER_TYPES, MIGRATION_HASH_TABLE, type PurgeStaleExecutionResult, type PurgeStaleSourcesResult, type SeedContextOpts, type SeedContextResult, type SeedContextBindingOpts, type SetContextPolicyOpts, type ContextRow, type ContextVariableRow, type ContextBindingRow, type ShowContextResult, type CreateContextTemplateOpts, type SetContextSecretOpts, type DispatchQueueRow, type ListQueueOpts, type ExecutionRunRow, type ExecutionJobRow, type ListExecutionRunsOpts, type CheckRunTrackingDirectRow, type ListCheckRunTrackingOpts, type WorkflowRegistrationRow, type ListRegistrationsOpts, type ListRegistrationsResult, type ShowRegistrationResult, type RegisterWorkflowManualOpts, type RegisterWorkflowManualResult, } from './db-admin.js';
10
10
  export { createMetricsRoutes, type MetricsRoutesDeps } from './routes/metrics.js';
11
11
  export { createHealthRoutes, type HealthRoutesDeps } from './routes/health.js';
12
12
  export { getReconnectDelay } from './reconnect-delay.js';
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import "./rolldown-runtime-ClRpJifh.js";
2
2
  import { AgentDeliveryMode, AgentPlatform, splitAgentPlatform } from "./agent-platform.js";
3
3
  import { createDb, createPool, isPoolAcquireTimeout } from "./db.js";
4
- import { CI_SECURITY_OTHER_REPO, MIGRATION_HASH_TABLE, REGISTERABLE_TRIGGER_TYPES, apiKeyExistsDirect, bumpRegistryVersionDirect, bumpRegistryVersionSimpleDirect, cleanupExecutionRowsDirect, clearDispatchQueueDirect, clearPeerCredentialsRevokedAtByIdsDirect, clearScalerStateDirect, computeMigrationsHash, countActivePeerCredentialsByInstanceDirect, countCronLastFiredDirect, countHeldRunsByRunIdDirect, countWebhookSourcesByConnectionIdDirect, createContextTemplateDirect, createDbRole, createJoinTokenDirect, createReadOnlyDbUser, deleteContextDirect, deleteCronLastFiredDirect, deleteCrossRepoTrustDirect, deleteExecutionRunsByWorkflowNameDirect, deleteGenericWebhookSourcesByNameDirect, deleteJoinTokensByCreatedByDirect, deleteKiciEventsDirect, deleteOrgSettingsByCustomerIdDirect, deletePeerCredentialsByInstanceIdLikeDirect, deleteWorkflowRegistrationsDirect, describeTableColumnsDirect, dropAndCreateDatabase, dropDatabaseDirect, emitKiciEventDirect, ensureDatabase, ensureOrgOwnerMemberDirect, findAnyUserApiKeyIdDirect, getExecutionRunSecurityDirect, getGenericWebhookSourceByRoutingKeyDirect, getHeldRunByIdDirect, getPeerCredentialRevokedAtDirect, getRegistryVersionDirect, getWebhookSourceByRoutingKeyDirect, getWorkflowRegistrationByIdDirect, insertCronLastFiredNowDirect, insertCrossRepoTrustStrictDirect, insertKiciEventAtDirect, insertKiciEventRawDirect, insertPeerCredentialExpiredDirect, insertWorkflowRegistrationRawDirect, insertWorkflowRegistrationStrictDirect, isSchemaCurrent, isSchemaCurrentFromFilesDirect, latestExecutionRunByStatusDirect, listActiveGenericWebhookSourcesDirect, listActivePeerCredentialsExcludingDirect, listCheckRunTrackingDirect, listContextsDirect, listCrossRepoTrustBySourceRoutingKeyDirect, listExecutionJobsDirect, listExecutionRunsDirect, listHeldRunApprovalsDirect, listKiciEventsDirect, listQueueDirect, listRegistrationsByRoutingKeyDirect, listRegistrationsDirect, maskDatabaseUrl, paginateUnprocessedEventsKeysetDirect, parseDatabaseUrl, platformConnectionExistsDirect, pollKiciEventsDirect, prunePeerCredentialsDirect, purgeContextsDirect, purgeScopedSecretsDirect, purgeSecretBackendsDirect, purgeStaleExecutionDirect, purgeStaleSourcesDirect, readStoredMigrationContentHash, registerWorkflowManualDirect, resetRaftStateDirect, resolvePlatformWebhookSourceRoutingKeyDirect, restoreSoftDeletedGenericWebhookSourceDirect, seedApiKeyInlineDirect, seedCiSecurityFixturesDirect, seedContextBindingDirect, seedContextDirect, seedCrossRepoTrustDirect, seedGenericWebhookSourceDirect, seedSourcePrivateKeyDirect, seedSyntheticGithubSourceDirect, seedUniversalGitSourceDirect, seedWebhookSecretDirect, setClusterGlobalWorkflowsEnabledDirect, setContextPolicyDirect, setContextSecretDirect, showContextDirect, showExecutionRunDirect, showKiciEventDirect, showQueueEntryDirect, showRegistrationDirect, storeMigrationContentHash, storeMigrationContentHashInTableDirect, tableExistsDirect, terminateIdleDbBackendsDirect, updateGenericWebhookVerificationConfigDirect, updateOrgSettingsDeniedReposDirect, updateSourceRoutingKeyDirect, updateWorkflowRegistrationCommitShaDirect, upsertCronLastFiredDirect, upsertOrgSettingsGlobalWorkflowsDirect, verifyKiciEventNotifyDirect, waitForEventLogRowByDeliveryIdDirect, waitForExecutionRunReachesStatusSinceDirect, waitForLatestExecutionJobStatusDirect, waitForPlatformEventLogDistinctRoutedDirect, waitForPlatformExecutionRunStatusDirect, waitForPlatformRegistrationsDirect, waitForPostgresDirect, waitForRegistrationsByRoutingKeyDirect, waitForRegistrationsUpdatedAtAdvanceDirect, waitForRunCompletionDirect } from "./db-admin.js";
4
+ import { MIGRATION_HASH_TABLE, REGISTERABLE_TRIGGER_TYPES, clearDispatchQueueDirect, computeMigrationsHash, createContextTemplateDirect, createDbRole, createReadOnlyDbUser, deleteContextDirect, dropAndCreateDatabase, emitKiciEventDirect, ensureDatabase, isSchemaCurrent, listCheckRunTrackingDirect, listContextsDirect, listExecutionRunsDirect, listQueueDirect, listRegistrationsDirect, maskDatabaseUrl, parseDatabaseUrl, prunePeerCredentialsDirect, purgeContextsDirect, purgeScopedSecretsDirect, purgeSecretBackendsDirect, purgeStaleExecutionDirect, purgeStaleSourcesDirect, readStoredMigrationContentHash, registerWorkflowManualDirect, resetRaftStateDirect, seedContextBindingDirect, seedContextDirect, setContextPolicyDirect, setContextSecretDirect, showContextDirect, showExecutionRunDirect, showQueueEntryDirect, showRegistrationDirect, storeMigrationContentHash } from "./db-admin.js";
5
5
  import { setupGracefulShutdown } from "./graceful-shutdown.js";
6
6
  import { decrypt, deriveKey, encrypt, generateMasterKey } from "./secret-crypto.js";
7
7
  import { RingBuffer } from "./ring-buffer.js";
8
- import { MAX_LOG_BYTES, addLogsToArchive, redactConfig } from "./diagnostics/bundle-archive.js";
8
+ import { MAX_LOG_BYTES, addLogsToArchive } from "./diagnostics/bundle-archive.js";
9
9
  import { BundleChunkAssembler, ChunkRequestWaiter, FLEET_CHUNK_BYTES, chunkBuffer } from "./diagnostics/bundle-chunks.js";
10
10
  import { isPgUniqueViolation } from "./pg-errors.js";
11
11
  import { createMetricsRoutes } from "./routes/metrics.js";
@@ -28,4 +28,4 @@ import { BaseColdStore } from "./cold-store/cold-store.js";
28
28
  import { ChunkLru } from "./cold-store/lru.js";
29
29
  import "./cold-store/index.js";
30
30
  export * from "@kici-dev/core";
31
- export { AgentDeliveryMode, AgentPlatform, BaseColdStore, BundleChunkAssembler, CI_SECURITY_OTHER_REPO, COLD_BUCKET_NAMES, ChunkLru, ChunkRequestWaiter, DEFAULT_TABLE_CONFIG, FLEET_CHUNK_BYTES, MAX_LOG_BYTES, MIGRATION_HASH_TABLE, REGISTERABLE_TRIGGER_TYPES, RingBuffer, addLogsToArchive, apiKeyExistsDirect, bumpRegistryVersionDirect, bumpRegistryVersionSimpleDirect, chunkBuffer, chunkObjectKey, cleanupExecutionRowsDirect, clearDispatchQueueDirect, clearPeerCredentialsRevokedAtByIdsDirect, clearScalerStateDirect, coldDaysToBucket, coldStoreArchiveBytesTotal, coldStoreArchiveCyclesTotal, coldStoreArchiveDurationSeconds, coldStoreArchiveRowsTotal, coldStorePurgeBytesTotal, coldStorePurgeChunksTotal, coldStorePurgeDurationSeconds, coldStoreRehydrateBytesTotal, coldStoreRehydrateDurationSeconds, coldStoreRehydrateRequestsTotal, coldStoreReplayDurationSeconds, coldStoreReplayRowsTotal, coldStoreVerifyFailuresTotal, collectRuntimeMetricNames, computeChunkId, computeMigrationsHash, countActivePeerCredentialsByInstanceDirect, countCronLastFiredDirect, countHeldRunsByRunIdDirect, countWebhookSourcesByConnectionIdDirect, createContextTemplateDirect, createDb, createDbRole, createHealthRoutes, createJoinTokenDirect, createMeter, createMetricsRoutes, createPool, createReadOnlyDbUser, createS3Client, decodeChunk, decrypt, deleteContextDirect, deleteCronLastFiredDirect, deleteCrossRepoTrustDirect, deleteExecutionRunsByWorkflowNameDirect, deleteGenericWebhookSourcesByNameDirect, deleteJoinTokensByCreatedByDirect, deleteKiciEventsDirect, deleteOrgSettingsByCustomerIdDirect, deletePeerCredentialsByInstanceIdLikeDirect, deleteWorkflowRegistrationsDirect, deriveKey, describeTableColumnsDirect, dropAndCreateDatabase, dropDatabaseDirect, emitKiciEventDirect, encodeChunk, encodeKeySegment, encrypt, ensureDatabase, ensureOrgOwnerMemberDirect, findAnyUserApiKeyIdDirect, generateMasterKey, getExecutionRunSecurityDirect, getGenericWebhookSourceByRoutingKeyDirect, getHeldRunByIdDirect, getPeerCredentialRevokedAtDirect, getPrometheusExporter, getReconnectDelay, getRegistryVersionDirect, getWebhookSourceByRoutingKeyDirect, getWorkflowRegistrationByIdDirect, initTelemetry, insertCronLastFiredNowDirect, insertCrossRepoTrustStrictDirect, insertKiciEventAtDirect, insertKiciEventRawDirect, insertPeerCredentialExpiredDirect, insertWorkflowRegistrationRawDirect, insertWorkflowRegistrationStrictDirect, isLongerColdRetention, isPgUniqueViolation, isPoolAcquireTimeout, isSchemaCurrent, isSchemaCurrentFromFilesDirect, kiciMkdtemp, kiciTmpBase, latestExecutionRunByStatusDirect, listActiveGenericWebhookSourcesDirect, listActivePeerCredentialsExcludingDirect, listCheckRunTrackingDirect, listContextsDirect, listCrossRepoTrustBySourceRoutingKeyDirect, listExecutionJobsDirect, listExecutionRunsDirect, listHeldRunApprovalsDirect, listKiciEventsDirect, listQueueDirect, listRegistrationsByRoutingKeyDirect, listRegistrationsDirect, maskDatabaseUrl, paginateUnprocessedEventsKeysetDirect, parseDatabaseUrl, parseManifest, platformConnectionExistsDirect, pollKiciEventsDirect, prunePeerCredentialsDirect, purgeContextsDirect, purgeScopedSecretsDirect, purgeSecretBackendsDirect, purgeStaleExecutionDirect, purgeStaleSourcesDirect, readStoredMigrationContentHash, redactConfig, registerWorkflowManualDirect, resetRaftStateDirect, resolvePlatformWebhookSourceRoutingKeyDirect, resolveTableConfig, restoreSoftDeletedGenericWebhookSourceDirect, seedApiKeyInlineDirect, seedCiSecurityFixturesDirect, seedContextBindingDirect, seedContextDirect, seedCrossRepoTrustDirect, seedGenericWebhookSourceDirect, seedSourcePrivateKeyDirect, seedSyntheticGithubSourceDirect, seedUniversalGitSourceDirect, seedWebhookSecretDirect, serializeManifest, setClusterGlobalWorkflowsEnabledDirect, setContextPolicyDirect, setContextSecretDirect, setupGracefulShutdown, showContextDirect, showExecutionRunDirect, showKiciEventDirect, showQueueEntryDirect, showRegistrationDirect, splitAgentPlatform, storeMigrationContentHash, storeMigrationContentHashInTableDirect, tableExistsDirect, tablePrefix, tenantDayBucketPrefix, tenantDayPrefix, terminateIdleDbBackendsDirect, updateGenericWebhookVerificationConfigDirect, updateOrgSettingsDeniedReposDirect, updateSourceRoutingKeyDirect, updateWorkflowRegistrationCommitShaDirect, upsertCronLastFiredDirect, upsertOrgSettingsGlobalWorkflowsDirect, validateRequiredTools, verifyKiciEventNotifyDirect, waitForEventLogRowByDeliveryIdDirect, waitForExecutionRunReachesStatusSinceDirect, waitForLatestExecutionJobStatusDirect, waitForPlatformEventLogDistinctRoutedDirect, waitForPlatformExecutionRunStatusDirect, waitForPlatformRegistrationsDirect, waitForPostgresDirect, waitForRegistrationsByRoutingKeyDirect, waitForRegistrationsUpdatedAtAdvanceDirect, waitForRunCompletionDirect };
31
+ export { AgentDeliveryMode, AgentPlatform, BaseColdStore, BundleChunkAssembler, COLD_BUCKET_NAMES, ChunkLru, ChunkRequestWaiter, DEFAULT_TABLE_CONFIG, FLEET_CHUNK_BYTES, MAX_LOG_BYTES, MIGRATION_HASH_TABLE, REGISTERABLE_TRIGGER_TYPES, RingBuffer, addLogsToArchive, chunkBuffer, chunkObjectKey, clearDispatchQueueDirect, coldDaysToBucket, coldStoreArchiveBytesTotal, coldStoreArchiveCyclesTotal, coldStoreArchiveDurationSeconds, coldStoreArchiveRowsTotal, coldStorePurgeBytesTotal, coldStorePurgeChunksTotal, coldStorePurgeDurationSeconds, coldStoreRehydrateBytesTotal, coldStoreRehydrateDurationSeconds, coldStoreRehydrateRequestsTotal, coldStoreReplayDurationSeconds, coldStoreReplayRowsTotal, coldStoreVerifyFailuresTotal, collectRuntimeMetricNames, computeChunkId, computeMigrationsHash, createContextTemplateDirect, createDb, createDbRole, createHealthRoutes, createMeter, createMetricsRoutes, createPool, createReadOnlyDbUser, createS3Client, decodeChunk, decrypt, deleteContextDirect, deriveKey, dropAndCreateDatabase, emitKiciEventDirect, encodeChunk, encodeKeySegment, encrypt, ensureDatabase, generateMasterKey, getPrometheusExporter, getReconnectDelay, initTelemetry, isLongerColdRetention, isPgUniqueViolation, isPoolAcquireTimeout, isSchemaCurrent, kiciMkdtemp, kiciTmpBase, listCheckRunTrackingDirect, listContextsDirect, listExecutionRunsDirect, listQueueDirect, listRegistrationsDirect, maskDatabaseUrl, parseDatabaseUrl, parseManifest, prunePeerCredentialsDirect, purgeContextsDirect, purgeScopedSecretsDirect, purgeSecretBackendsDirect, purgeStaleExecutionDirect, purgeStaleSourcesDirect, readStoredMigrationContentHash, registerWorkflowManualDirect, resetRaftStateDirect, resolveTableConfig, seedContextBindingDirect, seedContextDirect, serializeManifest, setContextPolicyDirect, setContextSecretDirect, setupGracefulShutdown, showContextDirect, showExecutionRunDirect, showQueueEntryDirect, showRegistrationDirect, splitAgentPlatform, storeMigrationContentHash, tablePrefix, tenantDayBucketPrefix, tenantDayPrefix, validateRequiredTools };
@@ -23,10 +23,11 @@ function initTelemetry(config) {
23
23
  prefix: config.metricPrefix
24
24
  });
25
25
  _prometheusExporter = prometheusExporter;
26
+ const traceExporter = config.otlpEndpoint ? new OTLPTraceExporter({ url: `${config.otlpEndpoint}/v1/traces` }) : void 0;
26
27
  const sdk = new NodeSDK({
27
28
  resource,
28
29
  metricReader: prometheusExporter,
29
- traceExporter: config.otlpEndpoint ? new OTLPTraceExporter({ url: `${config.otlpEndpoint}/v1/traces` }) : void 0,
30
+ traceExporter,
30
31
  instrumentations: [new RuntimeNodeInstrumentation()]
31
32
  });
32
33
  sdk.start();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kici-dev/shared",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Shared utilities for the KiCI CI/CD stack — logging, zx setup, crypto, telemetry, health and metrics routes. No business logic.",
5
5
  "keywords": [
6
6
  "ci",
@@ -89,10 +89,14 @@
89
89
  "./package-manager-types": {
90
90
  "import": "./dist/package-manager-types.js",
91
91
  "types": "./dist/package-manager-types.d.ts"
92
+ },
93
+ "./container-runtime": {
94
+ "import": "./dist/container-runtime.js",
95
+ "types": "./dist/container-runtime.d.ts"
92
96
  }
93
97
  },
94
98
  "dependencies": {
95
- "@aws-sdk/client-s3": "^3.1089.0",
99
+ "@aws-sdk/client-s3": "^3.1121.0",
96
100
  "@opentelemetry/api": "^1.9.1",
97
101
  "@opentelemetry/exporter-metrics-otlp-http": "^0.221.0",
98
102
  "@opentelemetry/exporter-prometheus": "^0.221.0",
@@ -103,22 +107,24 @@
103
107
  "@opentelemetry/semantic-conventions": "^1.43.0",
104
108
  "archiver": "^8.0.0",
105
109
  "diff": "^9.0.0",
106
- "hono": "^4.12.32",
110
+ "hono": "^4.13.2",
107
111
  "kysely": "^0.29.4",
108
112
  "oxc-transform": "0.140.0",
109
- "pg": "^8.22.0",
113
+ "pg": "^8.23.0",
110
114
  "picocolors": "^1.1.1",
111
115
  "winston": "^3.19.0",
112
116
  "winston-daily-rotate-file": "^5.0.0",
113
117
  "yaml": "^2.9.0",
114
118
  "zod": "^4.4.3",
115
119
  "zx": "^8.8.5",
116
- "@kici-dev/core": "0.5.0",
117
- "@kici-dev/engine": "0.5.0"
120
+ "@kici-dev/core": "0.6.1",
121
+ "@kici-dev/engine": "0.6.1"
118
122
  },
119
123
  "devDependencies": {
120
124
  "@opentelemetry/sdk-trace-base": "^2.10.0",
121
- "@types/archiver": "^8.0.0"
125
+ "@types/archiver": "^8.0.0",
126
+ "@types/dockerode": "^4.0.1",
127
+ "dockerode": "^5.0.1"
122
128
  },
123
129
  "scripts": {
124
130
  "build": "node ../../scripts/build-ts.mjs && tsgo --emitDeclarationOnly",