@ancientpantheon/khronoton-core 0.1.1 → 0.3.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/CHANGELOG.md +25 -0
- package/README.md +83 -3
- package/dist/PactCodeMirror-HQTGE2K3.js +64 -0
- package/dist/chunk-DK4CDPXH.js +379 -0
- package/dist/chunk-U3F5HEHO.js +1639 -0
- package/dist/context-BKtdrA2B.d.ts +363 -0
- package/dist/handlers/batch.d.ts +21 -0
- package/dist/handlers/batch.js +57 -0
- package/dist/handlers/context.d.ts +94 -0
- package/dist/handlers/context.js +75 -0
- package/dist/handlers/cronoton.d.ts +70 -0
- package/dist/handlers/cronoton.js +165 -0
- package/dist/handlers/execute.d.ts +30 -0
- package/dist/handlers/execute.js +227 -0
- package/dist/handlers/http.d.ts +85 -0
- package/dist/handlers/http.js +84 -0
- package/dist/handlers/index.d.ts +27 -0
- package/dist/handlers/index.js +34 -0
- package/dist/handlers/read.d.ts +29 -0
- package/dist/handlers/read.js +94 -0
- package/dist/hooks/index.d.ts +143 -0
- package/dist/hooks/index.js +2 -0
- package/dist/provider/index.d.ts +421 -0
- package/dist/provider/index.js +675 -0
- package/dist/server/executor-signers.d.ts +29 -0
- package/dist/server/executor-signers.js +60 -0
- package/dist/server/executor.d.ts +53 -0
- package/dist/server/executor.js +280 -0
- package/dist/server/index.d.ts +27 -0
- package/dist/server/index.js +51 -0
- package/dist/server/loop.d.ts +36 -0
- package/dist/server/loop.js +51 -0
- package/dist/server/pure/capability.d.ts +31 -0
- package/dist/server/pure/capability.js +63 -0
- package/dist/server/pure/fingerprint.d.ts +8 -0
- package/dist/server/pure/fingerprint.js +44 -0
- package/dist/server/pure/runtime-args.d.ts +34 -0
- package/dist/server/pure/runtime-args.js +99 -0
- package/dist/server/resolvers.d.ts +140 -0
- package/dist/server/resolvers.js +200 -0
- package/dist/server/schema.d.ts +31 -0
- package/dist/server/schema.js +93 -0
- package/dist/server/seams.d.ts +231 -0
- package/dist/server/seams.js +34 -0
- package/dist/server/store/claim.d.ts +59 -0
- package/dist/server/store/claim.js +97 -0
- package/dist/server/store/cronoton.d.ts +79 -0
- package/dist/server/store/cronoton.js +268 -0
- package/dist/server/store/errors.d.ts +26 -0
- package/dist/server/store/errors.js +40 -0
- package/dist/server/store/fires.d.ts +77 -0
- package/dist/server/store/fires.js +170 -0
- package/dist/server/store/index.d.ts +26 -0
- package/dist/server/store/index.js +33 -0
- package/dist/server/store/manual-batch.d.ts +38 -0
- package/dist/server/store/manual-batch.js +110 -0
- package/dist/server/store/mappers.d.ts +21 -0
- package/dist/server/store/mappers.js +62 -0
- package/dist/server/tick.d.ts +83 -0
- package/dist/server/tick.js +235 -0
- package/dist/server/types.d.ts +220 -0
- package/dist/server/types.js +14 -0
- package/dist/types-u_nUX1Bg.d.ts +222 -0
- package/dist/ui/index.d.ts +235 -0
- package/dist/ui/index.js +3646 -0
- package/dist/ui.css +35 -0
- package/package.json +64 -5
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared domain types for the Khronoton server-side executor and store.
|
|
3
|
+
*
|
|
4
|
+
* `CodexTxDefinition` is the single constructed-tx shape every caller
|
|
5
|
+
* (simulate API, manual-fire API, scheduled-fire worker tick) passes to the
|
|
6
|
+
* executor. The result + terminal-intent types are imported by those same
|
|
7
|
+
* callers so the executor stays the single source of truth for the contract.
|
|
8
|
+
*
|
|
9
|
+
* The DB row types + their client-facing projections describe the three
|
|
10
|
+
* server tables (`codex_cronotons`, `codex_cronoton_fires`,
|
|
11
|
+
* `codex_cronoton_manual_batches`). JSON columns are raw strings at the row
|
|
12
|
+
* layer; higher layers parse them into the structured types above.
|
|
13
|
+
*/
|
|
14
|
+
import type { ScheduleMode } from "../schedule.js";
|
|
15
|
+
/**
|
|
16
|
+
* Opaque chain identifier. Genericized to `string` — this package carries no
|
|
17
|
+
* chain dependency (the source Hub imported a concrete `ChainId`).
|
|
18
|
+
*/
|
|
19
|
+
export type ChainId = string;
|
|
20
|
+
/** Run mode: `simulate` signs + dirty-reads but never submits; `fire` submits. */
|
|
21
|
+
export type ExecutorMode = "simulate" | "fire";
|
|
22
|
+
/** One-time entries terminate after a single fire; recurring re-fire on schedule. */
|
|
23
|
+
export type ScheduleKind = "one-time" | "recurring";
|
|
24
|
+
/** Capability scoping for a signer: `pure` (unrestricted) or `scoped` (capped). */
|
|
25
|
+
export type CapabilityMode = "pure" | "scoped";
|
|
26
|
+
/** A signer reference — pubkey + how its signature is scoped. Codex-only: no secrets. */
|
|
27
|
+
export interface CodexSigner {
|
|
28
|
+
/** 64-hex Ed25519 public key (no `k:` prefix). Must be resolvable by the codex. */
|
|
29
|
+
readonly publicKey: string;
|
|
30
|
+
readonly capabilityMode: CapabilityMode;
|
|
31
|
+
/** Newline-separated capability lines (e.g. `(coin.GAS)`). Empty for pure signers. */
|
|
32
|
+
readonly capabilities: string;
|
|
33
|
+
}
|
|
34
|
+
/** Gas-payer reference: the protocol gas station, or a codex `k:` account. */
|
|
35
|
+
export interface CodexGasPayer {
|
|
36
|
+
readonly type: "codex" | "gas-station";
|
|
37
|
+
/** Codex gas-payer pubkey/address (the `k:` is derived). Absent for gas-station. */
|
|
38
|
+
readonly address?: string;
|
|
39
|
+
/**
|
|
40
|
+
* The codex public key that signs the gas station's `DALOS.GAS_PAYER`
|
|
41
|
+
* capability. Required (and only meaningful) for `type:'gas-station'`: the
|
|
42
|
+
* executor synthesizes a scoped GAS_PAYER signer for this key, so the gas
|
|
43
|
+
* station pays while this codex key authorizes the payment. The `coin.GAS`
|
|
44
|
+
* for a codex gas-payer rides on `address`, not here.
|
|
45
|
+
*/
|
|
46
|
+
readonly gasStationSignerKey?: string;
|
|
47
|
+
}
|
|
48
|
+
/** Transaction config — chain, gas, ttl. `gasPrice` is in ANU. */
|
|
49
|
+
export interface CodexTxConfig {
|
|
50
|
+
readonly chainId: string;
|
|
51
|
+
/** Gas price in ANU (converted to STOA via `anuToStoa` at build time). */
|
|
52
|
+
readonly gasPrice: number;
|
|
53
|
+
readonly gasLimit: number;
|
|
54
|
+
/** When true, the executor calibrates the gas limit from a dirty-read. */
|
|
55
|
+
readonly autoGasLimit: boolean;
|
|
56
|
+
/** Time-to-live in seconds. */
|
|
57
|
+
readonly ttl: number;
|
|
58
|
+
}
|
|
59
|
+
/** The full constructed-tx definition — the one shape all callers pass. */
|
|
60
|
+
export interface CodexTxDefinition {
|
|
61
|
+
readonly pactCode: string;
|
|
62
|
+
readonly config: CodexTxConfig;
|
|
63
|
+
/** env-data + keysets: each key becomes one `addData(key, value)`. */
|
|
64
|
+
readonly payload: Record<string, unknown>;
|
|
65
|
+
readonly gasPayer: CodexGasPayer;
|
|
66
|
+
readonly signers: CodexSigner[];
|
|
67
|
+
/** Drives terminal-intent computation. Defaults to `recurring` when absent. */
|
|
68
|
+
readonly scheduleKind?: ScheduleKind;
|
|
69
|
+
/**
|
|
70
|
+
* Names a server-side payload resolver (e.g. `'stoicism-mint'`). When set, the
|
|
71
|
+
* fire-time wrapper fills designated payload keys from live server data and
|
|
72
|
+
* settles server balances after a successful on-chain submit. Absent for
|
|
73
|
+
* ordinary cronotons, which fire through the executor unchanged.
|
|
74
|
+
*/
|
|
75
|
+
readonly serverResolver?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Terminal-transition INTENT for a one-time entry, COMPUTED (not persisted) by
|
|
79
|
+
* the executor. The caller reads this off the result and writes the table +
|
|
80
|
+
* clears the next-fire time. `null` for recurring entries and all simulate runs.
|
|
81
|
+
*/
|
|
82
|
+
export interface TerminalIntent {
|
|
83
|
+
readonly status: "completed" | "error";
|
|
84
|
+
/** Always true for one-time terminal transitions — its single attempt is spent. */
|
|
85
|
+
readonly clearNextFire: true;
|
|
86
|
+
}
|
|
87
|
+
/** Result of a `simulate` run. Never submits. */
|
|
88
|
+
export interface SimulateResult {
|
|
89
|
+
readonly ok: boolean;
|
|
90
|
+
readonly mode: "simulate";
|
|
91
|
+
/** Present when `autoGasLimit` and the dirty-read returned a gas figure. */
|
|
92
|
+
readonly calibratedGasLimit?: number;
|
|
93
|
+
readonly gasUsed?: number;
|
|
94
|
+
readonly rawResult?: unknown;
|
|
95
|
+
readonly error?: string;
|
|
96
|
+
/** Always `null` for simulate. */
|
|
97
|
+
readonly terminalIntent: null;
|
|
98
|
+
}
|
|
99
|
+
/** Result of a `fire` run. Submits (unless pre-flight fails). */
|
|
100
|
+
export interface FireResult {
|
|
101
|
+
readonly ok: boolean;
|
|
102
|
+
readonly mode: "fire";
|
|
103
|
+
readonly requestKey?: string;
|
|
104
|
+
readonly chainId?: string;
|
|
105
|
+
readonly rawResult?: unknown;
|
|
106
|
+
readonly error?: string;
|
|
107
|
+
/** Computed one-time terminal intent; `null` for recurring. */
|
|
108
|
+
readonly terminalIntent: TerminalIntent | null;
|
|
109
|
+
}
|
|
110
|
+
export type ExecutorResult = SimulateResult | FireResult;
|
|
111
|
+
/** The raw `codex_cronotons` row shape (JSON columns are still strings here). */
|
|
112
|
+
export interface CodexCronotonRow {
|
|
113
|
+
id: string;
|
|
114
|
+
name: string;
|
|
115
|
+
description: string | null;
|
|
116
|
+
pact_code: string;
|
|
117
|
+
config_json: string;
|
|
118
|
+
payload_json: string | null;
|
|
119
|
+
gas_payer_json: string;
|
|
120
|
+
signers_json: string;
|
|
121
|
+
schedule_mode: ScheduleMode;
|
|
122
|
+
schedule_config_json: string;
|
|
123
|
+
/**
|
|
124
|
+
* Name of the fire-time server payload resolver, or null/absent for ordinary
|
|
125
|
+
* rows. Optional so pre-migration row doubles (test fixtures) typecheck; real
|
|
126
|
+
* rows from `SELECT *` carry the column (value may be null).
|
|
127
|
+
*/
|
|
128
|
+
server_resolver?: string | null;
|
|
129
|
+
/**
|
|
130
|
+
* When 1, this cronoton may be fired by the external HMAC endpoint. Optional
|
|
131
|
+
* so pre-migration row doubles (test fixtures) typecheck; real rows carry it.
|
|
132
|
+
*/
|
|
133
|
+
external_fireable?: number;
|
|
134
|
+
/**
|
|
135
|
+
* JSON string[] of env-data keys a trigger supplies at fire time; null/absent
|
|
136
|
+
* = an ordinary fixed-definition cronoton. Optional so pre-migration row
|
|
137
|
+
* doubles (test fixtures) typecheck.
|
|
138
|
+
*/
|
|
139
|
+
runtime_arg_keys?: string | null;
|
|
140
|
+
status: "active" | "paused" | "completed" | "error";
|
|
141
|
+
next_fire_at: string | null;
|
|
142
|
+
last_fire_at: string | null;
|
|
143
|
+
created_at: string;
|
|
144
|
+
modified_at: string;
|
|
145
|
+
created_by: string;
|
|
146
|
+
}
|
|
147
|
+
/** The list/limbo projection the route attaches `scheduleSummary` to. */
|
|
148
|
+
export interface CodexCronotonListItem {
|
|
149
|
+
id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
scheduleMode: ScheduleMode;
|
|
152
|
+
status: CodexCronotonRow["status"];
|
|
153
|
+
nextFireAt: string | null;
|
|
154
|
+
lastFireAt: string | null;
|
|
155
|
+
createdAt: string;
|
|
156
|
+
modifiedAt: string;
|
|
157
|
+
createdBy: string;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Launch-state provenance of a fire — 'test' pre-lock, 'live' once the
|
|
161
|
+
* consumer's live state is locked.
|
|
162
|
+
*/
|
|
163
|
+
export type CodexFireMode = "test" | "live";
|
|
164
|
+
/**
|
|
165
|
+
* One on-chain transaction recorded under a single fire. A multi-tx fire (e.g.
|
|
166
|
+
* a pool payout) spans many: cross-chain burns + SPV continuations + the bulk
|
|
167
|
+
* transfer. The worker appends one of these as each tx lands; the fire history
|
|
168
|
+
* surfaces a count badge that expands to a per-tx explorer link.
|
|
169
|
+
*/
|
|
170
|
+
export interface FireTxKey {
|
|
171
|
+
/** 'burn' (source→0 initiate) | 'continuation' (SPV step on 0) | 'bulk' (payout transfer). */
|
|
172
|
+
kind: "burn" | "continuation" | "bulk";
|
|
173
|
+
/** Source chain for burn/continuation; '0' for the bulk transfer. */
|
|
174
|
+
chainId: string;
|
|
175
|
+
requestKey: string;
|
|
176
|
+
/** Whether the tx confirmed ok (best-effort; absent = unknown/in-flight). */
|
|
177
|
+
ok?: boolean;
|
|
178
|
+
}
|
|
179
|
+
/** The client-facing projection of a `codex_cronoton_fires` row. */
|
|
180
|
+
export interface CodexCronotonFireRow {
|
|
181
|
+
id: string;
|
|
182
|
+
firedAt: string;
|
|
183
|
+
status: "success" | "failure" | "running" | "nothing";
|
|
184
|
+
requestKey: string | null;
|
|
185
|
+
chainId: string | null;
|
|
186
|
+
errorMessage: string | null;
|
|
187
|
+
chainResponse: unknown;
|
|
188
|
+
definitionFingerprint: string | null;
|
|
189
|
+
mode: CodexFireMode;
|
|
190
|
+
/** Timestamp a failed fire was reconciled to success via `recoverFire`; null for natively-successful or never-recovered fires. */
|
|
191
|
+
recoveredAt: string | null;
|
|
192
|
+
/** Per-tx request keys for a multi-tx fire (empty for ordinary single-tx fires). */
|
|
193
|
+
txKeys: FireTxKey[];
|
|
194
|
+
}
|
|
195
|
+
/** Raw `codex_cronoton_manual_batches` row. */
|
|
196
|
+
export interface CodexManualBatchRow {
|
|
197
|
+
id: string;
|
|
198
|
+
codex_cronoton_id: string;
|
|
199
|
+
total: number;
|
|
200
|
+
completed: number;
|
|
201
|
+
interval_seconds: number;
|
|
202
|
+
status: "active" | "completed" | "cancelled";
|
|
203
|
+
next_at: string | null;
|
|
204
|
+
created_at: string;
|
|
205
|
+
modified_at: string;
|
|
206
|
+
created_by: string;
|
|
207
|
+
}
|
|
208
|
+
/** Client-facing projection of a batch (progress + schedule). */
|
|
209
|
+
export interface ManualBatchView {
|
|
210
|
+
id: string;
|
|
211
|
+
codexCronotonId: string;
|
|
212
|
+
total: number;
|
|
213
|
+
completed: number;
|
|
214
|
+
remaining: number;
|
|
215
|
+
intervalSeconds: number;
|
|
216
|
+
status: "active" | "completed" | "cancelled";
|
|
217
|
+
nextAt: string | null;
|
|
218
|
+
createdBy: string;
|
|
219
|
+
createdAt: string;
|
|
220
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared domain types for the Khronoton server-side executor and store.
|
|
3
|
+
*
|
|
4
|
+
* `CodexTxDefinition` is the single constructed-tx shape every caller
|
|
5
|
+
* (simulate API, manual-fire API, scheduled-fire worker tick) passes to the
|
|
6
|
+
* executor. The result + terminal-intent types are imported by those same
|
|
7
|
+
* callers so the executor stays the single source of truth for the contract.
|
|
8
|
+
*
|
|
9
|
+
* The DB row types + their client-facing projections describe the three
|
|
10
|
+
* server tables (`codex_cronotons`, `codex_cronoton_fires`,
|
|
11
|
+
* `codex_cronoton_manual_batches`). JSON columns are raw strings at the row
|
|
12
|
+
* layer; higher layers parse them into the structured types above.
|
|
13
|
+
*/
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* schedule — pure schedule model and timing math for @ancientpantheon/khronoton-core.
|
|
3
|
+
*
|
|
4
|
+
* Public surface:
|
|
5
|
+
* - ScheduleMode (7 literal values)
|
|
6
|
+
* - ScheduleConfig (discriminated union by `.mode`)
|
|
7
|
+
* - InvalidScheduleConfigError (typed reject)
|
|
8
|
+
* - computeNextFire(mode, config, now): Date | null
|
|
9
|
+
* - summariseSchedule(mode, config): string
|
|
10
|
+
*
|
|
11
|
+
* Contract:
|
|
12
|
+
* - TOTAL — a valid (mode, config, now) triple never throws;
|
|
13
|
+
* InvalidScheduleConfigError is reserved for malformed
|
|
14
|
+
* configs. Recurring modes always yield a future Date; the
|
|
15
|
+
* terminal `one-time` mode legitimately yields `null` once
|
|
16
|
+
* its single fire is in the past (a valid result, not an
|
|
17
|
+
* error).
|
|
18
|
+
* - MONOTONIC — for the same RECURRING schedule, later `now` ->
|
|
19
|
+
* equal-or-later next-fire (when both `now`s sit
|
|
20
|
+
* at-or-after the same prior fire). Enforced by the
|
|
21
|
+
* algorithm shape: every recurring mode iterates strictly
|
|
22
|
+
* forward from `now`. (`one-time` is exempt: once spent it
|
|
23
|
+
* returns `null`, which is the monotonic terminal state.)
|
|
24
|
+
* - PURE — no `Math.random`, no `Date.now()`. `now` is the
|
|
25
|
+
* explicit input. Two calls with identical args return
|
|
26
|
+
* identical results.
|
|
27
|
+
*
|
|
28
|
+
* Cron mode (5-field UTC):
|
|
29
|
+
* - Pruned in-tree parser; no `cron-parser` dependency added.
|
|
30
|
+
* - Standard 5-field shape: `minute hour dayOfMonth month dayOfWeek`.
|
|
31
|
+
* - Syntax supported per field:
|
|
32
|
+
* * (any)
|
|
33
|
+
* N (literal int)
|
|
34
|
+
* N,M,... (comma list)
|
|
35
|
+
* N-M (inclusive range)
|
|
36
|
+
* *<NN (step from start)
|
|
37
|
+
* N/M (step from N)
|
|
38
|
+
* - Out of scope (explicitly rejected): `@hourly` / `@daily` macros,
|
|
39
|
+
* seconds field, `L`/`W`/`#` Quartz extensions.
|
|
40
|
+
*
|
|
41
|
+
* The behavior of this engine is locked by the contract suites in
|
|
42
|
+
* `tests/`: schedule-compute-next-fire.test.ts, schedule-extended-modes.test.ts,
|
|
43
|
+
* schedule-new-modes.test.ts, and schedule-cron-dom-dow-or.test.ts.
|
|
44
|
+
*/
|
|
45
|
+
type ScheduleMode = 'daily-at-utc' | 'every-n-minutes' | 'weekly' | 'monthly' | 'cron-expression' | 'one-time' | 'several-times-per-day';
|
|
46
|
+
type DailyAtUtcConfig = {
|
|
47
|
+
mode: 'daily-at-utc';
|
|
48
|
+
hours: number[];
|
|
49
|
+
minute: number;
|
|
50
|
+
};
|
|
51
|
+
type EveryNMinutesConfig = {
|
|
52
|
+
mode: 'every-n-minutes';
|
|
53
|
+
startDate: string;
|
|
54
|
+
intervalMinutes: number;
|
|
55
|
+
};
|
|
56
|
+
type WeeklyConfig = {
|
|
57
|
+
mode: 'weekly';
|
|
58
|
+
daysOfWeek: number[];
|
|
59
|
+
hour: number;
|
|
60
|
+
minute: number;
|
|
61
|
+
};
|
|
62
|
+
type MonthlyConfig = {
|
|
63
|
+
mode: 'monthly';
|
|
64
|
+
daysOfMonth: number[];
|
|
65
|
+
hour: number;
|
|
66
|
+
minute: number;
|
|
67
|
+
};
|
|
68
|
+
type CronExpressionConfig = {
|
|
69
|
+
mode: 'cron-expression';
|
|
70
|
+
expression: string;
|
|
71
|
+
};
|
|
72
|
+
type OneTimeConfig = {
|
|
73
|
+
mode: 'one-time';
|
|
74
|
+
/** ISO8601 instant at which the schedule fires exactly once. */
|
|
75
|
+
fireAt: string;
|
|
76
|
+
};
|
|
77
|
+
type SeveralTimesPerDayConfig = {
|
|
78
|
+
mode: 'several-times-per-day';
|
|
79
|
+
/** Per-entry UTC time-of-day; fires at each one, every day. */
|
|
80
|
+
times: {
|
|
81
|
+
hour: number;
|
|
82
|
+
minute: number;
|
|
83
|
+
}[];
|
|
84
|
+
};
|
|
85
|
+
type ScheduleConfig = DailyAtUtcConfig | EveryNMinutesConfig | WeeklyConfig | MonthlyConfig | CronExpressionConfig | OneTimeConfig | SeveralTimesPerDayConfig;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Shared domain types for the Khronoton server-side executor and store.
|
|
89
|
+
*
|
|
90
|
+
* `CodexTxDefinition` is the single constructed-tx shape every caller
|
|
91
|
+
* (simulate API, manual-fire API, scheduled-fire worker tick) passes to the
|
|
92
|
+
* executor. The result + terminal-intent types are imported by those same
|
|
93
|
+
* callers so the executor stays the single source of truth for the contract.
|
|
94
|
+
*
|
|
95
|
+
* The DB row types + their client-facing projections describe the three
|
|
96
|
+
* server tables (`codex_cronotons`, `codex_cronoton_fires`,
|
|
97
|
+
* `codex_cronoton_manual_batches`). JSON columns are raw strings at the row
|
|
98
|
+
* layer; higher layers parse them into the structured types above.
|
|
99
|
+
*/
|
|
100
|
+
|
|
101
|
+
/** Capability scoping for a signer: `pure` (unrestricted) or `scoped` (capped). */
|
|
102
|
+
type CapabilityMode = "pure" | "scoped";
|
|
103
|
+
/** A signer reference — pubkey + how its signature is scoped. Codex-only: no secrets. */
|
|
104
|
+
interface CodexSigner {
|
|
105
|
+
/** 64-hex Ed25519 public key (no `k:` prefix). Must be resolvable by the codex. */
|
|
106
|
+
readonly publicKey: string;
|
|
107
|
+
readonly capabilityMode: CapabilityMode;
|
|
108
|
+
/** Newline-separated capability lines (e.g. `(coin.GAS)`). Empty for pure signers. */
|
|
109
|
+
readonly capabilities: string;
|
|
110
|
+
}
|
|
111
|
+
/** Gas-payer reference: the protocol gas station, or a codex `k:` account. */
|
|
112
|
+
interface CodexGasPayer {
|
|
113
|
+
readonly type: "codex" | "gas-station";
|
|
114
|
+
/** Codex gas-payer pubkey/address (the `k:` is derived). Absent for gas-station. */
|
|
115
|
+
readonly address?: string;
|
|
116
|
+
/**
|
|
117
|
+
* The codex public key that signs the gas station's `DALOS.GAS_PAYER`
|
|
118
|
+
* capability. Required (and only meaningful) for `type:'gas-station'`: the
|
|
119
|
+
* executor synthesizes a scoped GAS_PAYER signer for this key, so the gas
|
|
120
|
+
* station pays while this codex key authorizes the payment. The `coin.GAS`
|
|
121
|
+
* for a codex gas-payer rides on `address`, not here.
|
|
122
|
+
*/
|
|
123
|
+
readonly gasStationSignerKey?: string;
|
|
124
|
+
}
|
|
125
|
+
/** Transaction config — chain, gas, ttl. `gasPrice` is in ANU. */
|
|
126
|
+
interface CodexTxConfig {
|
|
127
|
+
readonly chainId: string;
|
|
128
|
+
/** Gas price in ANU (converted to STOA via `anuToStoa` at build time). */
|
|
129
|
+
readonly gasPrice: number;
|
|
130
|
+
readonly gasLimit: number;
|
|
131
|
+
/** When true, the executor calibrates the gas limit from a dirty-read. */
|
|
132
|
+
readonly autoGasLimit: boolean;
|
|
133
|
+
/** Time-to-live in seconds. */
|
|
134
|
+
readonly ttl: number;
|
|
135
|
+
}
|
|
136
|
+
/** The raw `codex_cronotons` row shape (JSON columns are still strings here). */
|
|
137
|
+
interface CodexCronotonRow {
|
|
138
|
+
id: string;
|
|
139
|
+
name: string;
|
|
140
|
+
description: string | null;
|
|
141
|
+
pact_code: string;
|
|
142
|
+
config_json: string;
|
|
143
|
+
payload_json: string | null;
|
|
144
|
+
gas_payer_json: string;
|
|
145
|
+
signers_json: string;
|
|
146
|
+
schedule_mode: ScheduleMode;
|
|
147
|
+
schedule_config_json: string;
|
|
148
|
+
/**
|
|
149
|
+
* Name of the fire-time server payload resolver, or null/absent for ordinary
|
|
150
|
+
* rows. Optional so pre-migration row doubles (test fixtures) typecheck; real
|
|
151
|
+
* rows from `SELECT *` carry the column (value may be null).
|
|
152
|
+
*/
|
|
153
|
+
server_resolver?: string | null;
|
|
154
|
+
/**
|
|
155
|
+
* When 1, this cronoton may be fired by the external HMAC endpoint. Optional
|
|
156
|
+
* so pre-migration row doubles (test fixtures) typecheck; real rows carry it.
|
|
157
|
+
*/
|
|
158
|
+
external_fireable?: number;
|
|
159
|
+
/**
|
|
160
|
+
* JSON string[] of env-data keys a trigger supplies at fire time; null/absent
|
|
161
|
+
* = an ordinary fixed-definition cronoton. Optional so pre-migration row
|
|
162
|
+
* doubles (test fixtures) typecheck.
|
|
163
|
+
*/
|
|
164
|
+
runtime_arg_keys?: string | null;
|
|
165
|
+
status: "active" | "paused" | "completed" | "error";
|
|
166
|
+
next_fire_at: string | null;
|
|
167
|
+
last_fire_at: string | null;
|
|
168
|
+
created_at: string;
|
|
169
|
+
modified_at: string;
|
|
170
|
+
created_by: string;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Launch-state provenance of a fire — 'test' pre-lock, 'live' once the
|
|
174
|
+
* consumer's live state is locked.
|
|
175
|
+
*/
|
|
176
|
+
type CodexFireMode = "test" | "live";
|
|
177
|
+
/**
|
|
178
|
+
* One on-chain transaction recorded under a single fire. A multi-tx fire (e.g.
|
|
179
|
+
* a pool payout) spans many: cross-chain burns + SPV continuations + the bulk
|
|
180
|
+
* transfer. The worker appends one of these as each tx lands; the fire history
|
|
181
|
+
* surfaces a count badge that expands to a per-tx explorer link.
|
|
182
|
+
*/
|
|
183
|
+
interface FireTxKey {
|
|
184
|
+
/** 'burn' (source→0 initiate) | 'continuation' (SPV step on 0) | 'bulk' (payout transfer). */
|
|
185
|
+
kind: "burn" | "continuation" | "bulk";
|
|
186
|
+
/** Source chain for burn/continuation; '0' for the bulk transfer. */
|
|
187
|
+
chainId: string;
|
|
188
|
+
requestKey: string;
|
|
189
|
+
/** Whether the tx confirmed ok (best-effort; absent = unknown/in-flight). */
|
|
190
|
+
ok?: boolean;
|
|
191
|
+
}
|
|
192
|
+
/** The client-facing projection of a `codex_cronoton_fires` row. */
|
|
193
|
+
interface CodexCronotonFireRow {
|
|
194
|
+
id: string;
|
|
195
|
+
firedAt: string;
|
|
196
|
+
status: "success" | "failure" | "running" | "nothing";
|
|
197
|
+
requestKey: string | null;
|
|
198
|
+
chainId: string | null;
|
|
199
|
+
errorMessage: string | null;
|
|
200
|
+
chainResponse: unknown;
|
|
201
|
+
definitionFingerprint: string | null;
|
|
202
|
+
mode: CodexFireMode;
|
|
203
|
+
/** Timestamp a failed fire was reconciled to success via `recoverFire`; null for natively-successful or never-recovered fires. */
|
|
204
|
+
recoveredAt: string | null;
|
|
205
|
+
/** Per-tx request keys for a multi-tx fire (empty for ordinary single-tx fires). */
|
|
206
|
+
txKeys: FireTxKey[];
|
|
207
|
+
}
|
|
208
|
+
/** Client-facing projection of a batch (progress + schedule). */
|
|
209
|
+
interface ManualBatchView {
|
|
210
|
+
id: string;
|
|
211
|
+
codexCronotonId: string;
|
|
212
|
+
total: number;
|
|
213
|
+
completed: number;
|
|
214
|
+
remaining: number;
|
|
215
|
+
intervalSeconds: number;
|
|
216
|
+
status: "active" | "completed" | "cancelled";
|
|
217
|
+
nextAt: string | null;
|
|
218
|
+
createdBy: string;
|
|
219
|
+
createdAt: string;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
export type { CodexCronotonRow as C, ManualBatchView as M, ScheduleMode as S, CodexCronotonFireRow as a, CodexTxConfig as b, CodexGasPayer as c, CodexSigner as d, ScheduleConfig as e, CodexFireMode as f };
|