@smithers-orchestrator/db 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/package.json +43 -0
- package/src/JsonBounds.ts +6 -0
- package/src/SchemaRegistryEntry.ts +6 -0
- package/src/SqlMessageStorage.js +818 -0
- package/src/SqlMessageStorageEventHistoryQuery.ts +7 -0
- package/src/SqliteWriteRetryOptions.ts +7 -0
- package/src/adapter/AlertRow.ts +29 -0
- package/src/adapter/AlertSeverity.ts +2 -0
- package/src/adapter/AlertStatus.ts +2 -0
- package/src/adapter/ApprovalRow.ts +13 -0
- package/src/adapter/AttemptRow.ts +17 -0
- package/src/adapter/CacheRow.ts +12 -0
- package/src/adapter/DB_ALERT_ALLOWED_SEVERITIES.js +5 -0
- package/src/adapter/DB_ALERT_ALLOWED_STATUSES.js +6 -0
- package/src/adapter/DB_ALERT_ID_MAX_LENGTH.js +1 -0
- package/src/adapter/DB_ALERT_MESSAGE_MAX_LENGTH.js +1 -0
- package/src/adapter/DB_ALERT_POLICY_NAME_MAX_LENGTH.js +1 -0
- package/src/adapter/DB_RUN_ALLOWED_STATUSES.js +10 -0
- package/src/adapter/DB_RUN_ID_MAX_LENGTH.js +1 -0
- package/src/adapter/DB_RUN_WORKFLOW_NAME_MAX_LENGTH.js +1 -0
- package/src/adapter/EventHistoryQuery.ts +7 -0
- package/src/adapter/HumanRequestRow.ts +19 -0
- package/src/adapter/NodeDiffCacheRow.ts +9 -0
- package/src/adapter/NodeRow.ts +10 -0
- package/src/adapter/PendingHumanRequestRow.ts +7 -0
- package/src/adapter/RunAncestryRow.ts +5 -0
- package/src/adapter/RunRow.ts +21 -0
- package/src/adapter/SignalQuery.ts +6 -0
- package/src/adapter/SignalRow.ts +9 -0
- package/src/adapter/SmithersDb.js +2236 -0
- package/src/adapter/StaleRunRecord.ts +7 -0
- package/src/adapter/index.js +27 -0
- package/src/adapter.js +2359 -0
- package/src/assertJsonPayloadWithinBounds.js +94 -0
- package/src/assertMaxBytes.js +23 -0
- package/src/assertMaxJsonDepth.js +40 -0
- package/src/assertMaxStringLength.js +16 -0
- package/src/assertOptionalArrayMaxLength.js +16 -0
- package/src/assertOptionalStringMaxLength.js +11 -0
- package/src/assertPositiveFiniteInteger.js +14 -0
- package/src/assertPositiveFiniteNumber.js +12 -0
- package/src/buildHumanRequestId.js +9 -0
- package/src/cache/nodeDiffCache.js +124 -0
- package/src/ensure.js +18 -0
- package/src/ensureSqlMessageStorage.js +11 -0
- package/src/ensureSqlMessageStorageEffect.js +12 -0
- package/src/frame-codec/FRAME_KEYFRAME_INTERVAL.js +1 -0
- package/src/frame-codec/FrameDelta.ts +6 -0
- package/src/frame-codec/FrameDeltaOp.ts +20 -0
- package/src/frame-codec/FrameEncoding.ts +1 -0
- package/src/frame-codec/JsonPath.ts +3 -0
- package/src/frame-codec/JsonPathSegment.ts +1 -0
- package/src/frame-codec/applyFrameDelta.js +143 -0
- package/src/frame-codec/applyFrameDeltaJson.js +10 -0
- package/src/frame-codec/encodeFrameDelta.js +247 -0
- package/src/frame-codec/index.js +15 -0
- package/src/frame-codec/normalizeFrameEncoding.js +13 -0
- package/src/frame-codec/parseFrameDelta.js +27 -0
- package/src/frame-codec/serializeFrameDelta.js +9 -0
- package/src/frame-codec.js +409 -0
- package/src/getSqlMessageStorage.js +11 -0
- package/src/index.d.ts +5203 -0
- package/src/index.js +20 -0
- package/src/input-bounds.js +12 -0
- package/src/input.js +17 -0
- package/src/internal-schema/index.js +19 -0
- package/src/internal-schema/smithersAlerts.js +27 -0
- package/src/internal-schema/smithersApprovals.js +18 -0
- package/src/internal-schema/smithersAttempts.js +20 -0
- package/src/internal-schema/smithersCache.js +13 -0
- package/src/internal-schema/smithersCron.js +11 -0
- package/src/internal-schema/smithersEvents.js +10 -0
- package/src/internal-schema/smithersFrames.js +14 -0
- package/src/internal-schema/smithersHumanRequests.js +17 -0
- package/src/internal-schema/smithersNodeDiffs.js +12 -0
- package/src/internal-schema/smithersNodes.js +13 -0
- package/src/internal-schema/smithersRalph.js +10 -0
- package/src/internal-schema/smithersRuns.js +22 -0
- package/src/internal-schema/smithersSandboxes.js +16 -0
- package/src/internal-schema/smithersSignals.js +12 -0
- package/src/internal-schema/smithersTimeTravelAudit.js +12 -0
- package/src/internal-schema/smithersToolCalls.js +19 -0
- package/src/internal-schema/smithersVectors.js +12 -0
- package/src/internal-schema.js +245 -0
- package/src/isRetryableSqliteWriteError.js +53 -0
- package/src/loadInputEffect.js +28 -0
- package/src/loadOutputsEffect.js +87 -0
- package/src/output/OutputKey.ts +1 -0
- package/src/output/buildKeyWhere.js +17 -0
- package/src/output/buildOutputRow.js +34 -0
- package/src/output/describeSchemaShape.js +70 -0
- package/src/output/getAgentOutputSchema.js +13 -0
- package/src/output/getKeyColumns.js +19 -0
- package/src/output/index.js +14 -0
- package/src/output/selectOutputRowEffect.js +30 -0
- package/src/output/stripAutoColumns.js +10 -0
- package/src/output/upsertOutputRowEffect.js +38 -0
- package/src/output/validateExistingOutput.js +17 -0
- package/src/output/validateOutput.js +17 -0
- package/src/output-schema-descriptor.js +163 -0
- package/src/output.js +240 -0
- package/src/react-output.js +10 -0
- package/src/runState/ComputeRunStateOptions.ts +4 -0
- package/src/runState/DeriveRunStateInput.ts +10 -0
- package/src/runState/RUN_STATE_HEARTBEAT_STALE_MS.js +1 -0
- package/src/runState/ReasonBlocked.ts +10 -0
- package/src/runState/ReasonUnhealthy.ts +6 -0
- package/src/runState/RunState.ts +12 -0
- package/src/runState/RunStateView.ts +11 -0
- package/src/runState/computeRunState.js +22 -0
- package/src/runState/computeRunStateFromRow.js +102 -0
- package/src/runState/deriveRunState.js +109 -0
- package/src/runState/parseEventMeta.js +18 -0
- package/src/runState/parseTimerMeta.js +16 -0
- package/src/runState-types.ts +23 -0
- package/src/runState.js +7 -0
- package/src/schema-signature.js +22 -0
- package/src/snapshot.js +125 -0
- package/src/sql-message-storage.js +839 -0
- package/src/storage/InMemoryStorage.js +484 -0
- package/src/storage/StorageService.js +7 -0
- package/src/storage/StorageServiceShape.ts +122 -0
- package/src/storage/StorageServiceTypes.ts +150 -0
- package/src/unwrapZodType.js +17 -0
- package/src/utils/camelToSnake.js +6 -0
- package/src/withSqliteWriteRetryEffect.js +110 -0
- package/src/write-retry.js +49 -0
- package/src/zodToCreateTableSQL.js +41 -0
- package/src/zodToTable.js +60 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AlertSeverity } from "./AlertSeverity";
|
|
2
|
+
import type { AlertStatus } from "./AlertStatus";
|
|
3
|
+
|
|
4
|
+
export type AlertRow = {
|
|
5
|
+
alertId: string;
|
|
6
|
+
runId: string | null;
|
|
7
|
+
policyName: string;
|
|
8
|
+
severity: AlertSeverity;
|
|
9
|
+
status: AlertStatus;
|
|
10
|
+
firedAtMs: number;
|
|
11
|
+
resolvedAtMs: number | null;
|
|
12
|
+
acknowledgedAtMs: number | null;
|
|
13
|
+
message: string;
|
|
14
|
+
detailsJson: string | null;
|
|
15
|
+
fingerprint?: string | null;
|
|
16
|
+
nodeId?: string | null;
|
|
17
|
+
iteration?: number | null;
|
|
18
|
+
owner?: string | null;
|
|
19
|
+
runbook?: string | null;
|
|
20
|
+
labelsJson?: string | null;
|
|
21
|
+
reactionJson?: string | null;
|
|
22
|
+
sourceEventType?: string | null;
|
|
23
|
+
firstFiredAtMs?: number | null;
|
|
24
|
+
lastFiredAtMs?: number | null;
|
|
25
|
+
occurrenceCount?: number;
|
|
26
|
+
silencedUntilMs?: number | null;
|
|
27
|
+
acknowledgedBy?: string | null;
|
|
28
|
+
resolvedBy?: string | null;
|
|
29
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type ApprovalRow = {
|
|
2
|
+
runId: string;
|
|
3
|
+
nodeId: string;
|
|
4
|
+
iteration: number;
|
|
5
|
+
status: string;
|
|
6
|
+
requestedAtMs: number | null;
|
|
7
|
+
decidedAtMs: number | null;
|
|
8
|
+
note: string | null;
|
|
9
|
+
decidedBy: string | null;
|
|
10
|
+
requestJson: string | null;
|
|
11
|
+
decisionJson: string | null;
|
|
12
|
+
autoApproved: boolean;
|
|
13
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type AttemptRow = {
|
|
2
|
+
runId: string;
|
|
3
|
+
nodeId: string;
|
|
4
|
+
iteration: number;
|
|
5
|
+
attempt: number;
|
|
6
|
+
state: string;
|
|
7
|
+
startedAtMs: number;
|
|
8
|
+
finishedAtMs: number | null;
|
|
9
|
+
heartbeatAtMs: number | null;
|
|
10
|
+
heartbeatDataJson: string | null;
|
|
11
|
+
errorJson: string | null;
|
|
12
|
+
jjPointer: string | null;
|
|
13
|
+
responseText: string | null;
|
|
14
|
+
jjCwd: string | null;
|
|
15
|
+
cached: boolean;
|
|
16
|
+
metaJson: string | null;
|
|
17
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type CacheRow = {
|
|
2
|
+
cacheKey: string;
|
|
3
|
+
createdAtMs: number;
|
|
4
|
+
workflowName: string;
|
|
5
|
+
nodeId: string;
|
|
6
|
+
outputTable: string;
|
|
7
|
+
schemaSig: string;
|
|
8
|
+
agentSig: string | null;
|
|
9
|
+
toolsSig: string | null;
|
|
10
|
+
jjPointer: string | null;
|
|
11
|
+
payloadJson: string;
|
|
12
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DB_ALERT_ID_MAX_LENGTH = 256;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DB_ALERT_MESSAGE_MAX_LENGTH = 4096;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DB_ALERT_POLICY_NAME_MAX_LENGTH = 256;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DB_RUN_ID_MAX_LENGTH = 256;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const DB_RUN_WORKFLOW_NAME_MAX_LENGTH = 256;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type HumanRequestKind = "ask" | "confirm" | "select" | "json";
|
|
2
|
+
export type HumanRequestStatus = "pending" | "answered" | "cancelled" | "expired";
|
|
3
|
+
|
|
4
|
+
export type HumanRequestRow = {
|
|
5
|
+
requestId: string;
|
|
6
|
+
runId: string;
|
|
7
|
+
nodeId: string;
|
|
8
|
+
iteration: number;
|
|
9
|
+
kind: HumanRequestKind;
|
|
10
|
+
status: HumanRequestStatus;
|
|
11
|
+
prompt: string;
|
|
12
|
+
schemaJson: string | null;
|
|
13
|
+
optionsJson: string | null;
|
|
14
|
+
responseJson: string | null;
|
|
15
|
+
requestedAtMs: number;
|
|
16
|
+
answeredAtMs: number | null;
|
|
17
|
+
answeredBy: string | null;
|
|
18
|
+
timeoutAtMs: number | null;
|
|
19
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type RunRow = {
|
|
2
|
+
runId: string;
|
|
3
|
+
parentRunId: string | null;
|
|
4
|
+
workflowName: string;
|
|
5
|
+
workflowPath: string | null;
|
|
6
|
+
workflowHash: string | null;
|
|
7
|
+
status: string;
|
|
8
|
+
createdAtMs: number;
|
|
9
|
+
startedAtMs: number | null;
|
|
10
|
+
finishedAtMs: number | null;
|
|
11
|
+
heartbeatAtMs: number | null;
|
|
12
|
+
runtimeOwnerId: string | null;
|
|
13
|
+
cancelRequestedAtMs: number | null;
|
|
14
|
+
hijackRequestedAtMs: number | null;
|
|
15
|
+
hijackTarget: string | null;
|
|
16
|
+
vcsType: string | null;
|
|
17
|
+
vcsRoot: string | null;
|
|
18
|
+
vcsRevision: string | null;
|
|
19
|
+
errorJson: string | null;
|
|
20
|
+
configJson: string | null;
|
|
21
|
+
};
|