@ancientpantheon/khronoton-core 0.4.2 → 0.6.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 CHANGED
@@ -4,6 +4,53 @@ All notable changes to `@ancientpantheon/khronoton-core`.
4
4
 
5
5
  The engine's pre-extraction history lives in the AncientHoldings hub, whose inline scheduler ("Cronoton") this package extracts and generalises.
6
6
 
7
+ ## 0.6.0 — 2026-08-02
8
+
9
+ **MINOR — event-driven server resolvers (scheduler-off, host-fired).**
10
+
11
+ Some server-resolver cronotons are conceptually event-driven, not time-based (they fire when an external condition becomes ready, on no meaningful clock). Previously such a resolver had to masquerade as a scheduled cronoton that polls every tick, and the Builder misleadingly showed a schedule editor for it.
12
+
13
+ - **`ServerResolverOption` gains an optional `eventDriven?: boolean`.** A consumer tags a resolver option event-driven; selecting it in the Builder commits the cronoton **scheduler-off** (`next_fire_at = NULL`, so the tick loop never auto-fires it) and replaces the schedule editor with an honest "Event-driven — the host application fires this when its trigger condition is met; there is no schedule." notice, with the schedule summary reading "Event-driven (host-fired)".
14
+ - **The host fires such a cronoton via the existing `executeNow` primitive** — no new firing primitive, no change to `executeNow`. Event-driven is threaded as its own dedicated `eventDriven` flag on the commit envelope (NOT by reusing `externalFireable`, which would wrongly expose the public HMAC trigger endpoint) — an event-driven cronoton is fired in-process by the host, never over HMAC. No new DB column: `next_fire_at = NULL` already carries the scheduler-off state, and the edit/resume paths keep it NULL correctly.
15
+ - **`server_resolver` + event-driven is allowed** (the whole feature); `server_resolver` + `runtime_arg_keys` stays forbidden.
16
+ - Also fixed in the same pass: pausing then resuming an event-driven cronoton no longer resurrects a schedule (resume now recognizes a scheduler-off row by its `next_fire_at = NULL`); and the Builder's trigger-only notice no longer wrongly claims an externally-fireable-only cronoton "declares runtime arguments".
17
+
18
+ Ordinary scheduled resolver cronotons (e.g. `pyth-flush`) are unchanged — same schedule, same UI. A non-event-driven commit body is byte-identical to 0.5.0.
19
+
20
+ **848 specs pass.**
21
+
22
+ ## 0.5.0 — 2026-08-02
23
+
24
+ **MINOR — Builder screen: syntax-highlighted Pact editor, top/bottom layout, live tx-size/gas meter.**
25
+
26
+ - **Syntax highlighting on the Pact-code editor.** Keywords, definitions (`defun`/`defcap`/`defschema`/…),
27
+ types, strings, numbers, booleans, `;;` comments, `@doc`/`@model` annotations, symbols, and
28
+ parens/brackets/braces are now colored distinctly instead of one flat color. Colors are driven entirely
29
+ by the package's existing `--khr-*` theme-token convention (extended with five new tokens, below), so a
30
+ consumer's existing `body .khronoton-ui { --khr-*: ... }` override pattern applies unchanged.
31
+ - **New `--khr-*` tokens:** `--khr-syntax-keyword`, `--khr-syntax-type`, `--khr-syntax-string`,
32
+ `--khr-syntax-number`, `--khr-syntax-atom` (Pact-code syntax coloring — see `THEMING.md`), and
33
+ `--khr-selection` (the Pact editor's text-selection background — previously reused `--khr-accent-tint`,
34
+ which read as nearly invisible against the editor's own background; now its own token, defaulting to a
35
+ visible `#1e3a5f`).
36
+ - **Builder layout: top/bottom, not left/right.** The Pact-code editor now renders full-width at the top of
37
+ the Builder screen, clamped to ~7 visible lines with internal scroll, with the header/tab bar/tab content
38
+ full-width below it — the one standard layout for every cronoton, not a per-consumer option.
39
+ - **Live Tx Size + Gas metering strip**, between the editor's header and its code body: a byte-size bar
40
+ against StoaChain's fixed 2 MB Chainweb ceiling (live, recomputed as you type/configure — a local
41
+ estimate only, never signed or submitted), and a gas-used-vs-gas-limit bar once a Simulate result exists.
42
+ - **Dependency fix:** `@uiw/react-codemirror`, `@codemirror/state`, `@codemirror/view`,
43
+ `@codemirror/language`, `@lezer/highlight` are now real (optional) `peerDependencies` instead of
44
+ `devDependencies` silently relied on via hoisting from an unrelated dependency — a consumer without them
45
+ now sees an honest unmet-peer warning instead of a silent fallback to the plain-textarea editor.
46
+ - **Build fix (pre-existing, found in the same pass):** `tsup.config.ts`'s `external` list was missing
47
+ `@ouronet/ouronet-core` — `/blockchain/stoachain`'s lazy `@ouronet/ouronet-core/constants` import was
48
+ being bundled into `dist/blockchain/stoachain.js` instead of resolving from the consumer's own install,
49
+ reintroducing the version-pinning conflict 0.4.1 existed to fix. No behavior change for anyone not using
50
+ `/blockchain/stoachain`.
51
+
52
+ **832 specs pass.**
53
+
7
54
  ## 0.4.2 — 2026-07-22
8
55
 
9
56
  **PATCH — fix a dangling peerDependenciesMeta key.**
package/README.md CHANGED
@@ -6,6 +6,10 @@ Khronoton is the "When do I act?" Constructor of the Pantheon architecture — t
6
6
 
7
7
  ## Status
8
8
 
9
+ **`0.6.0` on public npmjs** — **MINOR.** Released 2026-08-02. Server resolvers can now declare themselves **event-driven** (`ServerResolverOption.eventDriven`): selecting one in the Builder commits the cronoton scheduler-off (`next_fire_at = NULL`, never auto-fired) and swaps the schedule editor for an event-driven notice — the host fires it in-process via the existing `executeNow` (not the HMAC endpoint). Ordinary scheduled resolvers are unchanged. **848 specs pass.**
10
+
11
+ **`0.5.0` on public npmjs** — **MINOR.** Released 2026-08-02. The Builder screen's Pact-code editor is now syntax-highlighted (via the package's `--khr-*` theme tokens, five new ones added), moved to a full-width top strip (~7 lines, internal scroll) with the header/tabs/tab content full-width below it, and gained a live tx-size/gas metering strip. `@uiw/react-codemirror` + the CodeMirror/Lezer packages it now depends on for highlighting are real optional `peerDependencies`. **832 specs pass.**
12
+
9
13
  **`0.4.2` on public npmjs** — **PATCH.** Released 2026-07-22. Aligns the `peerDependenciesMeta` key with the `@ouronet/ouronet-core` peer renamed in 0.4.1 (the meta entry still named the old `@stoachain` peer). No code change. **799 specs pass.**
10
14
 
11
15
  **`0.4.1` on public npmjs** — **PATCH (dependency rename, no code change).** Released 2026-07-22. `@stoachain/ouronet-core` → `@ouronet/ouronet-core` — same code, new scope, following the Phase-4 split into OuroborosNetwork/ouronet-libs. **799 specs pass.**
@@ -14,7 +18,7 @@ Khronoton is the "When do I act?" Constructor of the Pantheon architecture — t
14
18
 
15
19
  - **`/handlers`** — framework-agnostic HTTP route handlers over the `/server` store + executor (list/get/fires/signers/commit/edit/pause/resume/delete/simulate/execute-now/trigger/batch/recover), driven by a tiny `HandlerRequest`/`HandlerResponse` seam so any router (Next.js, Express, …) can mount them.
16
20
  - **`/provider` + `/hooks`** — the React data layer: `<KhronotonProvider adapter={…}>`, the 16-method `KhronotonAdapter` seam with two reference adapters (`createFetchAdapter` over HTTP, `createMemoryAdapter` over in-process handlers), the shared `runGated` confirm-retry, and the data + action hooks (`useCronotons`/`useCronoton`/`useCronotonFires`/`useManualBatch` + the lifecycle/execute action hooks).
17
- - **`/ui` + `/ui.css`** — the React UI at full Hub parity: the four screens **List**, **Detail/Observe** (fire history with 50/page pager, definition-drift flag, result tooltip, pluggable multi-tx renderer, wired recover), **Builder** (two-pane create + edit, Config/Payload/Gas Payer/Signatures/Execute tabs, Simulate→AUTO-gas calibrate), and a **Public** read-only transparency view — themed entirely through `--khr-*` CSS variables inside `<KhronotonUiRoot>`.
21
+ - **`/ui` + `/ui.css`** — the React UI at full Hub parity: the four screens **List**, **Detail/Observe** (fire history with 50/page pager, definition-drift flag, result tooltip, pluggable multi-tx renderer, wired recover), **Builder** (syntax-highlighted Pact-code editor full-width on top, Config/Payload/Gas Payer/Signatures/Execute tabs full-width below, Simulate→AUTO-gas calibrate, a live tx-size/gas metering strip), and a **Public** read-only transparency view — themed entirely through `--khr-*` CSS variables inside `<KhronotonUiRoot>`.
18
22
 
19
23
  Khronoton isn't chain-*agnostic* — it's chain-*polyglot*: the root schedule/tick engine orchestrates, and the **`/blockchain/<chain>`** subpath family teaches it to speak each supported chain's language natively (0.4.0):
20
24
 
@@ -232,6 +236,10 @@ npm install @ancientpantheon/khronoton-core
232
236
 
233
237
  ## Version history
234
238
 
239
+ **v0.6.0** — Event-driven server resolvers. `ServerResolverOption` gains an optional `eventDriven` flag; a cronoton on an event-driven resolver commits scheduler-off (`next_fire_at = NULL`, excluded from the tick due-query) and the Builder shows an "Event-driven (host-fired)" notice instead of a schedule editor. The host fires it via the existing `executeNow` primitive, in-process — event-driven is a dedicated commit-envelope flag, deliberately NOT `externalFireable`, so it never exposes the public HMAC trigger endpoint. `server_resolver` + event-driven is allowed; `server_resolver` + `runtime_arg_keys` stays forbidden. No new DB column (the `next_fire_at = NULL` state carries it; edit and pause/resume keep it NULL). Ordinary scheduled resolvers unchanged; a non-event-driven commit body is byte-identical to 0.5.0. Released 2026-08-02. **848 specs pass.**
240
+
241
+ **v0.5.0** — Builder screen upgrade: the Pact-code editor is syntax-highlighted (keywords, definitions, types, strings, numbers, booleans, comments, `@doc`/`@model` annotations, parens/atoms — colored via new `--khr-syntax-*`/`--khr-selection` tokens, not hardcoded), moved to a full-width top strip (~7 lines, internal scroll) with the header/tab bar/tab content full-width below it as the one standard layout, and gained a live tx-size/gas metering strip (local byte estimate against StoaChain's 2 MB ceiling; gas-used-vs-limit once Simulate runs). `@uiw/react-codemirror`, `@codemirror/state`, `@codemirror/view`, `@codemirror/language`, `@lezer/highlight` are now real optional `peerDependencies` instead of silently relied upon via hoisting. Released 2026-08-02. **832 specs pass.**
242
+
235
243
  **v0.4.2** — fix dangling `peerDependenciesMeta` key (was still `@stoachain/ouronet-core`). Released 2026-07-22. **799 specs pass.**
236
244
 
237
245
  **v0.4.1** — dependency rename, no code change. Released 2026-07-22. `@stoachain/ouronet-core` → `@ouronet/ouronet-core`. **799 specs pass.**
@@ -0,0 +1,226 @@
1
+ import CodeMirror from '@uiw/react-codemirror';
2
+ import { EditorView } from '@codemirror/view';
3
+ import { syntaxHighlighting, HighlightStyle, StreamLanguage } from '@codemirror/language';
4
+ import { tags } from '@lezer/highlight';
5
+ import { jsx } from 'react/jsx-runtime';
6
+
7
+ // src/ui/PactCodeMirror.tsx
8
+ var DEFINITION_KEYWORDS = /* @__PURE__ */ new Set([
9
+ "defun",
10
+ "defcap",
11
+ "defconst",
12
+ "defpact",
13
+ "defschema",
14
+ "deftable",
15
+ "module",
16
+ "interface",
17
+ "defproperty"
18
+ ]);
19
+ var KEYWORDS = /* @__PURE__ */ new Set([
20
+ "if",
21
+ "let",
22
+ "let*",
23
+ "lambda",
24
+ "cond",
25
+ "use",
26
+ "namespace",
27
+ "implements",
28
+ "bless",
29
+ "with-read",
30
+ "with-default-read",
31
+ "with-capability",
32
+ "bind",
33
+ "step",
34
+ "step-with-rollback",
35
+ "resume",
36
+ "yield",
37
+ "enforce",
38
+ "enforce-one",
39
+ "enforce-keyset",
40
+ "enforce-guard",
41
+ "require-capability",
42
+ "compose-capability",
43
+ "read",
44
+ "write",
45
+ "update",
46
+ "select",
47
+ "where",
48
+ "and",
49
+ "or",
50
+ "not",
51
+ "try",
52
+ "format",
53
+ "map",
54
+ "fold",
55
+ "filter",
56
+ "define-keyset",
57
+ "define-namespace"
58
+ ]);
59
+ var TYPE_NAMES = /* @__PURE__ */ new Set([
60
+ "integer",
61
+ "decimal",
62
+ "time",
63
+ "bool",
64
+ "string",
65
+ "list",
66
+ "value",
67
+ "keyset",
68
+ "guard",
69
+ "object",
70
+ "table"
71
+ ]);
72
+ function token(stream) {
73
+ if (stream.eatSpace()) return null;
74
+ if (stream.match(";;")) {
75
+ stream.skipToEnd();
76
+ return "lineComment";
77
+ }
78
+ if (stream.match(/^"(?:[^"\\]|\\.)*"?/)) return "string";
79
+ if (stream.match(/^\d+(\.\d+)?/)) return "number";
80
+ if (stream.match(/^'[a-zA-Z_-][a-zA-Z0-9_-]*/)) return "atom";
81
+ if (stream.match(/^@[a-zA-Z_][a-zA-Z0-9_-]*/)) return "meta";
82
+ if (stream.match(/^(:=|::)/)) return "operator";
83
+ if (stream.match(/^[+\-*/=<>!]=?/)) return "operator";
84
+ if (stream.match(/^[()]/)) return "paren";
85
+ if (stream.match(/^[[\]]/)) return "squareBracket";
86
+ if (stream.match(/^[{}]/)) return "brace";
87
+ const identifierMatch = stream.match(
88
+ /^[a-zA-Z_][a-zA-Z0-9_\-.%#+&$@<>=?*!|/]*/
89
+ );
90
+ if (identifierMatch) {
91
+ const word = identifierMatch[0];
92
+ if (DEFINITION_KEYWORDS.has(word)) return "definitionKeyword";
93
+ if (KEYWORDS.has(word)) return "keyword";
94
+ if (TYPE_NAMES.has(word)) return "typeName";
95
+ if (word === "true" || word === "false") return "bool";
96
+ return "variableName";
97
+ }
98
+ stream.next();
99
+ return null;
100
+ }
101
+ var PACT_TOKEN_TABLE = {
102
+ definitionKeyword: tags.definitionKeyword,
103
+ keyword: tags.keyword,
104
+ typeName: tags.typeName,
105
+ bool: tags.bool,
106
+ string: tags.string,
107
+ number: tags.number,
108
+ lineComment: tags.lineComment,
109
+ variableName: tags.variableName,
110
+ atom: tags.atom,
111
+ operator: tags.operator,
112
+ meta: tags.meta,
113
+ paren: tags.paren,
114
+ squareBracket: tags.squareBracket,
115
+ brace: tags.brace
116
+ };
117
+ function pactLanguageSupport() {
118
+ return StreamLanguage.define({
119
+ token,
120
+ languageData: {
121
+ commentTokens: { line: ";;" },
122
+ closeBrackets: { brackets: ["(", "[", "{", '"'] }
123
+ },
124
+ tokenTable: PACT_TOKEN_TABLE
125
+ });
126
+ }
127
+ var PACT_HIGHLIGHT_SPECS = [
128
+ { tag: tags.keyword, color: "var(--khr-syntax-keyword, #c586c0)" },
129
+ {
130
+ tag: tags.definitionKeyword,
131
+ color: "var(--khr-accent, #f0a500)",
132
+ fontWeight: "bold"
133
+ },
134
+ { tag: tags.typeName, color: "var(--khr-syntax-type, #4ec9b0)" },
135
+ { tag: tags.bool, color: "var(--khr-blue, #60a5fa)" },
136
+ { tag: tags.string, color: "var(--khr-syntax-string, #ce9178)" },
137
+ { tag: tags.number, color: "var(--khr-syntax-number, #b5cea8)" },
138
+ {
139
+ tag: tags.lineComment,
140
+ color: "var(--khr-text-dim2, #6b7280)",
141
+ fontStyle: "italic"
142
+ },
143
+ { tag: tags.variableName, color: "var(--khr-mono, #d2d3d4)" },
144
+ { tag: tags.atom, color: "var(--khr-syntax-atom, #d7ba7d)" },
145
+ // Reuses --khr-blue (also used for `bool`) — `@doc`/`@model` meta tags
146
+ // and `true`/`false` literals never appear adjacent in real Pact
147
+ // source, so sharing the color carries no real ambiguity risk, and it
148
+ // avoids a brand-new token for a single rare-elsewhere role.
149
+ { tag: tags.meta, color: "var(--khr-blue, #60a5fa)" },
150
+ { tag: tags.operator, color: "var(--khr-text-dim, #8a8f98)" },
151
+ { tag: tags.paren, color: "var(--khr-text-dim, #8a8f98)" },
152
+ { tag: tags.squareBracket, color: "var(--khr-text-dim, #8a8f98)" },
153
+ { tag: tags.brace, color: "var(--khr-text-dim, #8a8f98)" }
154
+ ];
155
+ var pactHighlightExtension = syntaxHighlighting(
156
+ HighlightStyle.define(PACT_HIGHLIGHT_SPECS)
157
+ );
158
+ var GUTTER_BG = "#0d1117";
159
+ var ACTIVE_LINE_BG = "#161616";
160
+ var KHRONOTON_EDITOR_THEME_SPEC = {
161
+ "&": {
162
+ backgroundColor: "var(--khr-panel, #0a0a0a)",
163
+ color: "var(--khr-mono, #d2d3d4)",
164
+ fontSize: "12px"
165
+ },
166
+ ".cm-content": {
167
+ fontFamily: "var(--khr-mono-font, ui-monospace, monospace)",
168
+ caretColor: "var(--khr-accent, #f0a500)",
169
+ lineHeight: "1.4"
170
+ },
171
+ ".cm-cursor, .cm-dropCursor": {
172
+ borderLeftColor: "var(--khr-accent, #f0a500)"
173
+ },
174
+ "&.cm-focused": {
175
+ outline: "none"
176
+ },
177
+ "&.cm-editor.cm-focused": {
178
+ outline: "1px solid var(--khr-accent, #f0a500)"
179
+ },
180
+ "&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": {
181
+ backgroundColor: "var(--khr-selection, #1e3a5f)"
182
+ },
183
+ ".cm-gutters": {
184
+ backgroundColor: GUTTER_BG,
185
+ color: "var(--khr-text-dim, #8a8f98)",
186
+ border: "none"
187
+ },
188
+ ".cm-activeLine": { backgroundColor: ACTIVE_LINE_BG },
189
+ ".cm-activeLineGutter": { backgroundColor: ACTIVE_LINE_BG }
190
+ };
191
+ var khronotonEditorTheme = EditorView.theme(KHRONOTON_EDITOR_THEME_SPEC, {
192
+ dark: true
193
+ });
194
+ var PACT_EDITOR_EXTENSIONS = [
195
+ pactLanguageSupport(),
196
+ pactHighlightExtension
197
+ ];
198
+ function buildPactEditorExtensions() {
199
+ return PACT_EDITOR_EXTENSIONS;
200
+ }
201
+ var BASIC_SETUP = {
202
+ lineNumbers: true,
203
+ foldGutter: false,
204
+ closeBrackets: false,
205
+ autocompletion: false,
206
+ highlightActiveLine: true
207
+ };
208
+ function PactCodeMirror({
209
+ value,
210
+ onChange,
211
+ height
212
+ }) {
213
+ return /* @__PURE__ */ jsx(
214
+ CodeMirror,
215
+ {
216
+ value,
217
+ height: `${height}px`,
218
+ theme: khronotonEditorTheme,
219
+ extensions: buildPactEditorExtensions(),
220
+ basicSetup: BASIC_SETUP,
221
+ onChange
222
+ }
223
+ );
224
+ }
225
+
226
+ export { KHRONOTON_EDITOR_THEME_SPEC, buildPactEditorExtensions, PactCodeMirror as default };
@@ -1067,7 +1067,7 @@ function commitCodexCronoton(input, opts) {
1067
1067
  );
1068
1068
  }
1069
1069
  const now = opts.now ?? /* @__PURE__ */ new Date();
1070
- const triggerOnly = input.externalFireable === true || runtimeArgKeys.length > 0;
1070
+ const triggerOnly = input.externalFireable === true || runtimeArgKeys.length > 0 || input.eventDriven === true;
1071
1071
  const nextFireAt = triggerOnly ? null : computeNextOrReject(input.scheduleMode, input.scheduleConfig, now).toISOString();
1072
1072
  const id = crypto2.randomUUID();
1073
1073
  const nowIso = now.toISOString();
@@ -1192,7 +1192,12 @@ function editCodexCronoton(id, patch, opts) {
1192
1192
  changedFields.push("schedule");
1193
1193
  }
1194
1194
  const rowTriggerOnly = rowExternalFireable(row) || rowRuntimeArgKeys(row).length > 0;
1195
- if (scheduleChanged && !rowTriggerOnly) {
1195
+ if (patch.eventDriven === true) {
1196
+ if (nextFireAt !== null && !changedFields.includes("schedule")) {
1197
+ changedFields.push("schedule");
1198
+ }
1199
+ nextFireAt = null;
1200
+ } else if (scheduleChanged && !rowTriggerOnly) {
1196
1201
  const next = computeNextOrReject(
1197
1202
  nextScheduleMode,
1198
1203
  JSON.parse(nextScheduleConfigJson),
@@ -1248,8 +1253,8 @@ function resumeCodexCronoton(id, opts) {
1248
1253
  if (!row) throw new CodexCronotonValidationError("not found");
1249
1254
  assertNotTerminal(row);
1250
1255
  const now = opts.now ?? /* @__PURE__ */ new Date();
1251
- const rowTriggerOnly = rowExternalFireable(row) || rowRuntimeArgKeys(row).length > 0;
1252
- const nextFireAt = rowTriggerOnly ? null : computeNextOrReject(
1256
+ const rowSchedulerOff = row.next_fire_at === null;
1257
+ const nextFireAt = rowSchedulerOff ? null : computeNextOrReject(
1253
1258
  row.schedule_mode,
1254
1259
  JSON.parse(row.schedule_config_json),
1255
1260
  now
@@ -1,4 +1,4 @@
1
- import { useKhronotonAdapter, useKhronotonConfig, runGated } from './chunk-U3F5HEHO.js';
1
+ import { useKhronotonAdapter, useKhronotonConfig, runGated } from './chunk-FBQTTDOZ.js';
2
2
  import { useState, useRef, useEffect, useCallback } from 'react';
3
3
 
4
4
  function useCronotons(query) {
@@ -94,6 +94,7 @@ interface CommitEnvelope {
94
94
  serverResolver?: string;
95
95
  externalFireable?: boolean;
96
96
  runtimeArgKeys?: string[];
97
+ eventDriven?: boolean;
97
98
  }
98
99
  /** The schedule half of a {@link CommitBody}: mode + its config. */
99
100
  interface CommitSchedule {
@@ -315,6 +316,13 @@ interface ServerResolverOption {
315
316
  label: string;
316
317
  /** Optional gold side-note shown in the builder when this resolver is selected. */
317
318
  note?: string;
319
+ /**
320
+ * When true, a cronoton using this resolver is EVENT-DRIVEN — the scheduler never
321
+ * auto-fires it (persisted scheduler-off); the host application fires it on its own
322
+ * trigger via `executeNow`. Selecting such a resolver in the Builder replaces the
323
+ * schedule UI with an event-driven notice. Omit/false = ordinary scheduled cronoton.
324
+ */
325
+ eventDriven?: boolean;
318
326
  }
319
327
  /** A pluggable multi-tx breakdown renderer (the Hub's pool-payout is one impl). */
320
328
  type RenderMultiTx = (fire: CodexCronotonFireRow) => ReactNode;
@@ -40,6 +40,7 @@ export interface CommitEnvelope {
40
40
  serverResolver?: string;
41
41
  externalFireable?: boolean;
42
42
  runtimeArgKeys?: string[];
43
+ eventDriven?: boolean;
43
44
  }
44
45
  /** The schedule half of a {@link CommitBody}: mode + its config. */
45
46
  export interface CommitSchedule {
@@ -60,6 +60,7 @@ function toCommitInput(body, createdBy) {
60
60
  serverResolver: envelope.serverResolver,
61
61
  externalFireable: envelope.externalFireable,
62
62
  runtimeArgKeys: envelope.runtimeArgKeys,
63
+ eventDriven: envelope.eventDriven,
63
64
  };
64
65
  }
65
66
  /** Adapt a `Partial<CommitBody>` into a store edit patch (apply-at-next-fire). */
@@ -85,6 +86,8 @@ function toEditPatch(body) {
85
86
  patch.signers = e.signers;
86
87
  if (e.serverResolver !== undefined)
87
88
  patch.serverResolver = e.serverResolver;
89
+ if (e.eventDriven !== undefined)
90
+ patch.eventDriven = e.eventDriven;
88
91
  }
89
92
  const sched = b.schedule;
90
93
  if (sched && typeof sched === "object") {
@@ -1,5 +1,5 @@
1
- import { L as ListCronotonsQuery, C as CommitBody, a as CommitView, E as EditPatch, b as EditView, T as ToggleView, D as DeleteView, c as CancelBatchView, d as ExecuteView, R as RecoverView, S as SimulateEnvelope, e as SimulateView, f as StartBatchView, g as RuntimeArgs } from '../context-BKtdrA2B.js';
2
- export { U as UseKhronotonResult, u as useKhronoton } from '../context-BKtdrA2B.js';
1
+ import { L as ListCronotonsQuery, C as CommitBody, a as CommitView, E as EditPatch, b as EditView, T as ToggleView, D as DeleteView, c as CancelBatchView, d as ExecuteView, R as RecoverView, S as SimulateEnvelope, e as SimulateView, f as StartBatchView, g as RuntimeArgs } from '../context-D7LCfXdC.js';
2
+ export { U as UseKhronotonResult, u as useKhronoton } from '../context-D7LCfXdC.js';
3
3
  import { C as CodexCronotonRow, a as CodexCronotonFireRow, M as ManualBatchView } from '../types-u_nUX1Bg.js';
4
4
  import 'react';
5
5
 
@@ -1,2 +1,2 @@
1
- export { useCancelBatch, useCronoton, useCronotonActions, useCronotonFires, useCronotons, useExecuteNow, useManualBatch, useRecoverFire, useSimulate, useStartBatch, useTrigger } from '../chunk-DK4CDPXH.js';
2
- export { useKhronoton } from '../chunk-U3F5HEHO.js';
1
+ export { useCancelBatch, useCronoton, useCronotonActions, useCronotonFires, useCronotons, useExecuteNow, useManualBatch, useRecoverFire, useSimulate, useStartBatch, useTrigger } from '../chunk-ZVMHHW53.js';
2
+ export { useKhronoton } from '../chunk-FBQTTDOZ.js';
@@ -1,6 +1,6 @@
1
1
  import { ReactNode } from 'react';
2
- import { H as HandlerRequest, h as HandlerResponse, K as KhronotonProviderProps, i as KhronotonAdapter, j as SignerSource } from '../context-BKtdrA2B.js';
3
- export { c as CancelBatchView, k as CodexSignerDescriptor, C as CommitBody, a as CommitView, l as ConfirmGate, m as ConfirmOpts, n as DEFAULT_EXPLORER_BASE, o as DEFAULT_PAGE_SIZE, p as DEFAULT_POLL_CADENCE_MS, D as DeleteView, E as EditPatch, b as EditView, d as ExecuteView, F as FiresQuery, q as FiresView, G as GetBatchView, r as GetCronotonView, s as KhronotonConfig, t as KhronotonSnapshot, L as ListCronotonsQuery, v as ListCronotonsView, R as RecoverView, w as RenderMultiTx, g as RuntimeArgs, x as ServerResolverOption, y as SignersView, S as SimulateEnvelope, e as SimulateView, f as StartBatchView, T as ToggleView, U as UseKhronotonResult, z as assertAdapter, A as emptySnapshot, u as useKhronoton } from '../context-BKtdrA2B.js';
2
+ import { H as HandlerRequest, h as HandlerResponse, K as KhronotonProviderProps, i as KhronotonAdapter, j as SignerSource } from '../context-D7LCfXdC.js';
3
+ export { c as CancelBatchView, k as CodexSignerDescriptor, C as CommitBody, a as CommitView, l as ConfirmGate, m as ConfirmOpts, n as DEFAULT_EXPLORER_BASE, o as DEFAULT_PAGE_SIZE, p as DEFAULT_POLL_CADENCE_MS, D as DeleteView, E as EditPatch, b as EditView, d as ExecuteView, F as FiresQuery, q as FiresView, G as GetBatchView, r as GetCronotonView, s as KhronotonConfig, t as KhronotonSnapshot, L as ListCronotonsQuery, v as ListCronotonsView, R as RecoverView, w as RenderMultiTx, g as RuntimeArgs, x as ServerResolverOption, y as SignersView, S as SimulateEnvelope, e as SimulateView, f as StartBatchView, T as ToggleView, U as UseKhronotonResult, z as assertAdapter, A as emptySnapshot, u as useKhronoton } from '../context-D7LCfXdC.js';
4
4
  import { D as Database, C as ChainRuntime, K as KeyResolver, R as ResolveFireMode, O as OnAudit, a as Config } from '../seams-BvPnTSmg.js';
5
5
  export { a as CodexCronotonFireRow, C as CodexCronotonRow, M as ManualBatchView } from '../types-u_nUX1Bg.js';
6
6
 
@@ -1,5 +1,5 @@
1
- import { assertAdapter, resolveConfig, KhronotonStaticContext, KhronotonStatusContext, NeedsConfirmError, installSchema, defaultOpenAuth, withConfirm, err, recoverFire, json, createManualBatch, manualBatchView, getCodexCronoton, validateRuntimeArgs, rowRuntimeArgKeys, applyRuntimeArgs, rowToDefinition, getServerResolver, resolveServerVars, executeCodexTransaction, CodexCronotonValidationError, deleteCodexCronoton, resumeCodexCronoton, pauseCodexCronoton, editCodexCronoton, commitCodexCronoton, withRead, listFires, listCodexCronotons, getActiveManualBatchForCronoton, cancelManualBatch, defaultSignerSource, fireByServerResolver, computeDefinitionFingerprint, recordFire, applyTerminalIntent } from '../chunk-U3F5HEHO.js';
2
- export { DEFAULT_EXPLORER_BASE, DEFAULT_PAGE_SIZE, DEFAULT_POLL_CADENCE_MS, NeedsConfirmError, assertAdapter, emptySnapshot, runGated, useKhronoton } from '../chunk-U3F5HEHO.js';
1
+ import { assertAdapter, resolveConfig, KhronotonStaticContext, KhronotonStatusContext, NeedsConfirmError, installSchema, defaultOpenAuth, withConfirm, err, recoverFire, json, createManualBatch, manualBatchView, getCodexCronoton, validateRuntimeArgs, rowRuntimeArgKeys, applyRuntimeArgs, rowToDefinition, getServerResolver, resolveServerVars, executeCodexTransaction, CodexCronotonValidationError, deleteCodexCronoton, resumeCodexCronoton, pauseCodexCronoton, editCodexCronoton, commitCodexCronoton, withRead, listFires, listCodexCronotons, getActiveManualBatchForCronoton, cancelManualBatch, defaultSignerSource, fireByServerResolver, computeDefinitionFingerprint, recordFire, applyTerminalIntent } from '../chunk-FBQTTDOZ.js';
2
+ export { DEFAULT_EXPLORER_BASE, DEFAULT_PAGE_SIZE, DEFAULT_POLL_CADENCE_MS, NeedsConfirmError, assertAdapter, emptySnapshot, runGated, useKhronoton } from '../chunk-FBQTTDOZ.js';
3
3
  import { useRef, useState, useEffect } from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
 
@@ -266,7 +266,8 @@ function toCommitInput(body, createdBy) {
266
266
  createdBy,
267
267
  serverResolver: envelope.serverResolver,
268
268
  externalFireable: envelope.externalFireable,
269
- runtimeArgKeys: envelope.runtimeArgKeys
269
+ runtimeArgKeys: envelope.runtimeArgKeys,
270
+ eventDriven: envelope.eventDriven
270
271
  };
271
272
  }
272
273
  function toEditPatch(body) {
@@ -283,6 +284,7 @@ function toEditPatch(body) {
283
284
  if (e.gasPayer !== void 0) patch.gasPayer = e.gasPayer;
284
285
  if (e.signers !== void 0) patch.signers = e.signers;
285
286
  if (e.serverResolver !== void 0) patch.serverResolver = e.serverResolver;
287
+ if (e.eventDriven !== void 0) patch.eventDriven = e.eventDriven;
286
288
  }
287
289
  const sched = b.schedule;
288
290
  if (sched && typeof sched === "object") {
@@ -19,6 +19,9 @@ export interface CommitCodexCronotonInput {
19
19
  /** env-data keys supplied by a trigger at fire time (default none). Must be
20
20
  * DISJOINT from the fixed payload keys — a runtime arg must never override a keyset. */
21
21
  runtimeArgKeys?: string[];
22
+ /** When true, the row is host-fired on an event (via executeNow) rather than on a
23
+ * timer — a THIRD trigger-only reason: it commits scheduler-off (next_fire_at NULL). */
24
+ eventDriven?: boolean;
22
25
  }
23
26
  interface CommitOpts extends DbDep {
24
27
  now?: Date;
@@ -53,6 +56,10 @@ export interface EditCodexCronotonPatch {
53
56
  scheduleConfig?: ScheduleConfig;
54
57
  /** Set/clear the fire-time server resolver. `null` clears it. */
55
58
  serverResolver?: string | null;
59
+ /** When true, force the row scheduler-off (next_fire_at NULL) — an event-driven
60
+ * edit or a scheduled→event-driven conversion. There is no persisted column, so
61
+ * the edit path relies on this patch signal (the persisted row can't reveal it). */
62
+ eventDriven?: boolean;
56
63
  }
57
64
  /**
58
65
  * Apply-at-next-fire edit. Recomputes next_fire_at when the schedule changes,
@@ -10,9 +10,10 @@
10
10
  * Schedule math is imported, never reimplemented (REQ-16): {@link computeNextFire}
11
11
  * runs at commit/edit/resume time through {@link computeNextOrReject}, which maps
12
12
  * an {@link InvalidScheduleConfigError} to a typed {@link CodexCronotonValidationError}
13
- * and treats a null next-fire as a "no future fires" reject. A TRIGGER-ONLY row
14
- * (externally fireable OR declaring runtime args) carries NO schedule at all — its
15
- * `next_fire_at` stays NULL and the schedule engine is never consulted for it.
13
+ * and treats a null next-fire as a "no future fires" reject. A SCHEDULER-OFF row
14
+ * (externally fireable, OR declaring runtime args, OR event-driven — a
15
+ * server-resolver the host fires via `executeNow`) carries NO schedule at all —
16
+ * its `next_fire_at` stays NULL and the schedule engine is never consulted for it.
16
17
  */
17
18
  import crypto from "node:crypto";
18
19
  import { computeNextFire, InvalidScheduleConfigError, } from "../../schedule.js";
@@ -65,11 +66,14 @@ export function commitCodexCronoton(input, opts) {
65
66
  throw new CodexCronotonValidationError("server-resolver rows cannot declare runtime args");
66
67
  }
67
68
  const now = opts.now ?? new Date();
68
- // A TRIGGER-ONLY cronoton (externally fireable OR declaring runtime args) fires
69
- // on demand — never on a timer — so it carries NO schedule: skip the next-fire
69
+ // A SCHEDULER-OFF cronoton (externally fireable, OR declaring runtime args, OR
70
+ // event-driven — a server-resolver the host fires via `executeNow`) fires on
71
+ // demand, never on a timer — so it carries NO schedule: skip the next-fire
70
72
  // computation and store next_fire_at = NULL. The scheduler's
71
73
  // `next_fire_at IS NOT NULL` gate then skips it.
72
- const triggerOnly = input.externalFireable === true || runtimeArgKeys.length > 0;
74
+ const triggerOnly = input.externalFireable === true ||
75
+ runtimeArgKeys.length > 0 ||
76
+ input.eventDriven === true;
73
77
  const nextFireAt = triggerOnly
74
78
  ? null
75
79
  : computeNextOrReject(input.scheduleMode, input.scheduleConfig, now).toISOString();
@@ -210,7 +214,19 @@ export function editCodexCronoton(id, patch, opts) {
210
214
  // next_fire_at is NULL and the scheduler skips it) — never resurrect a next-fire
211
215
  // for it, even if a schedule patch slips through. Keep next_fire_at as-is (NULL).
212
216
  const rowTriggerOnly = rowExternalFireable(row) || rowRuntimeArgKeys(row).length > 0;
213
- if (scheduleChanged && !rowTriggerOnly) {
217
+ // An event-driven edit forces the row scheduler-off (next_fire_at NULL). There is
218
+ // no persisted event_driven column, so `rowTriggerOnly` can't see it — this patch
219
+ // signal takes precedence and covers BOTH an event-driven→event-driven edit (keep
220
+ // NULL) and a scheduled→event-driven conversion (clear the row's stale non-null
221
+ // next_fire_at). Marking "schedule" ensures the UPDATE runs even when the clear is
222
+ // the only change (a pure conversion), so the early-out below doesn't skip the write.
223
+ if (patch.eventDriven === true) {
224
+ if (nextFireAt !== null && !changedFields.includes("schedule")) {
225
+ changedFields.push("schedule");
226
+ }
227
+ nextFireAt = null;
228
+ }
229
+ else if (scheduleChanged && !rowTriggerOnly) {
214
230
  const next = computeNextOrReject(nextScheduleMode, JSON.parse(nextScheduleConfigJson), opts.now ?? new Date());
215
231
  nextFireAt = next.toISOString();
216
232
  }
@@ -248,10 +264,17 @@ export function resumeCodexCronoton(id, opts) {
248
264
  throw new CodexCronotonValidationError("not found");
249
265
  assertNotTerminal(row);
250
266
  const now = opts.now ?? new Date();
251
- // A trigger-only row (externally fireable OR runtime-arg) has no schedule — resume
252
- // it to 'active' but keep next_fire_at NULL so the scheduler still never picks it up.
253
- const rowTriggerOnly = rowExternalFireable(row) || rowRuntimeArgKeys(row).length > 0;
254
- const nextFireAt = rowTriggerOnly
267
+ // A scheduler-off row has no schedule — resume it to 'active' but keep
268
+ // next_fire_at NULL so the scheduler still never picks it up. Every scheduler-off
269
+ // row (externally fireable, runtime-arg, OR event-driven — a server-resolver the
270
+ // host fires via executeNow) is committed with next_fire_at NULL, pause preserves
271
+ // it, and every genuinely-scheduled active row carries a NON-null next_fire_at —
272
+ // so the row's own current next_fire_at is the reliable, column-free marker here.
273
+ // (Event-driven persists no distinguishing column; this is what keeps resume from
274
+ // resurrecting a schedule for it. The edit path keys off the incoming patch signal
275
+ // instead, because an edit may be CONVERTING a row to or from a schedule.)
276
+ const rowSchedulerOff = row.next_fire_at === null;
277
+ const nextFireAt = rowSchedulerOff
255
278
  ? null
256
279
  : computeNextOrReject(row.schedule_mode, JSON.parse(row.schedule_config_json), now).toISOString();
257
280
  db.prepare(`UPDATE codex_cronotons SET status = 'active', next_fire_at = ?, modified_at = ? WHERE id = ?`).run(nextFireAt, now.toISOString(), id);
@@ -125,7 +125,9 @@ interface DetailProps {
125
125
  declare function Detail({ id, access, onBack, onEdit, onNavigateToList, robots, }: DetailProps): ReactNode;
126
126
 
127
127
  /**
128
- * Builder assembly — the two-pane create/edit form (REQ-B01/B02/B11).
128
+ * Builder assembly — the top/bottom create/edit form (REQ-B01/B02/B11): the
129
+ * Pact-code editor renders full-width at the top (with the shared tx-size/gas
130
+ * meter strip), and the header + five-tab bar render full-width below it.
129
131
  *
130
132
  * This is the single owner of the shared {@link BuilderState}: it hosts the
131
133
  * already-built controlled tabs (Config, Payload, Gas Payer, Signatures, Execute)
@@ -159,9 +161,10 @@ interface BuilderProps {
159
161
  readonly robots?: string;
160
162
  }
161
163
  /**
162
- * The two-pane codex-cronoton builder. Owns `BuilderState`; renders the Pact editor
163
- * on the left and the header + five-tab bar on the right, feeding every tab the
164
- * shared state and folding its `onChange` back in.
164
+ * The top/bottom codex-cronoton builder. Owns `BuilderState`; renders the Pact
165
+ * editor full-width at the top (with the shared tx-size/gas meter strip) and the
166
+ * header + five-tab bar full-width below it, feeding every tab the shared state
167
+ * and folding its `onChange` back in.
165
168
  */
166
169
  declare function Builder({ editId, access: _access, onDone, robots, }: BuilderProps): ReactNode;
167
170
 
package/dist/ui/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { useCronotons, useCronoton, useCronotonActions, useExecuteNow, useSimulate, useManualBatch, useStartBatch, useCancelBatch, useTrigger, useCronotonFires, useRecoverFire } from '../chunk-DK4CDPXH.js';
2
- import { useKhronotonAdapter, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-U3F5HEHO.js';
1
+ import { useCronotons, useCronoton, useCronotonActions, useExecuteNow, useSimulate, useManualBatch, useStartBatch, useCancelBatch, useTrigger, useCronotonFires, useRecoverFire } from '../chunk-ZVMHHW53.js';
2
+ import { useKhronotonAdapter, useKhronotonConfig, parseRuntimeArgKeys, summariseSchedule, KhronotonStaticContext, useKhronoton, computeNextFire, InvalidScheduleConfigError } from '../chunk-FBQTTDOZ.js';
3
3
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
4
4
  import { lazy, forwardRef, createElement, useState, useEffect, useCallback, Suspense, useContext } from 'react';
5
5
 
@@ -1453,7 +1453,7 @@ function toSigner(row) {
1453
1453
  capabilities: row.capabilityMode === "scoped" ? row.capabilities : ""
1454
1454
  };
1455
1455
  }
1456
- function builderToCommit(state) {
1456
+ function builderToCommit(state, opts) {
1457
1457
  const config = {
1458
1458
  chainId: state.config.chainId,
1459
1459
  gasPrice: state.config.gasPriceAnu,
@@ -1476,6 +1476,7 @@ function builderToCommit(state) {
1476
1476
  if (state.description.trim().length > 0) body.description = state.description;
1477
1477
  if (state.serverResolver) body.envelope.serverResolver = state.serverResolver;
1478
1478
  if (state.externalFireable) body.envelope.externalFireable = true;
1479
+ if (opts?.eventDriven) body.envelope.eventDriven = true;
1479
1480
  if (runtimeArgKeys.length > 0) body.envelope.runtimeArgKeys = runtimeArgKeys;
1480
1481
  return body;
1481
1482
  }
@@ -1619,7 +1620,7 @@ function detailToBuilderState(row) {
1619
1620
  runtimeArgKeysText: ""
1620
1621
  };
1621
1622
  }
1622
- var LazyPactCodeMirror = lazy(() => import('../PactCodeMirror-HQTGE2K3.js'));
1623
+ var LazyPactCodeMirror = lazy(() => import('../PactCodeMirror-4MRUD325.js'));
1623
1624
  var panelStyle = {
1624
1625
  display: "flex",
1625
1626
  flexDirection: "column",
@@ -1651,12 +1652,17 @@ var clearButtonStyle = {
1651
1652
  padding: "3px 10px",
1652
1653
  cursor: "pointer"
1653
1654
  };
1655
+ var subBarWrapStyle = {
1656
+ padding: "0 12px 10px",
1657
+ borderBottom: "1px solid var(--khr-border)"
1658
+ };
1654
1659
  function PactCodeEditor({
1655
1660
  value,
1656
1661
  onChange,
1657
1662
  onClear,
1658
1663
  height = 460,
1659
- forceFallback = false
1664
+ forceFallback = false,
1665
+ subBar
1660
1666
  }) {
1661
1667
  const [mounted, setMounted] = useState(false);
1662
1668
  useEffect(() => {
@@ -1691,6 +1697,7 @@ function PactCodeEditor({
1691
1697
  /* @__PURE__ */ jsx("span", { style: eyebrowStyle, children: "PACT Code Editor" }),
1692
1698
  onClear ? /* @__PURE__ */ jsx("button", { type: "button", onClick: onClear, style: clearButtonStyle, children: "Clear" }) : null
1693
1699
  ] }),
1700
+ subBar ? /* @__PURE__ */ jsx("div", { "data-testid": "pact-editor-subbar", style: subBarWrapStyle, children: subBar }) : null,
1694
1701
  /* @__PURE__ */ jsx("div", { style: { height }, children: useCodeMirror ? /* @__PURE__ */ jsx(Suspense, { fallback, children: /* @__PURE__ */ jsx(LazyPactCodeMirror, { value, onChange, height }) }) : fallback })
1695
1702
  ] });
1696
1703
  }
@@ -1805,6 +1812,11 @@ function BuilderHeader({
1805
1812
  ] })
1806
1813
  ] });
1807
1814
  }
1815
+
1816
+ // src/ui/builder/format.ts
1817
+ function formatThousands(n) {
1818
+ return n.toLocaleString("en-US");
1819
+ }
1808
1820
  var INPUT_STYLE4 = {
1809
1821
  display: "block",
1810
1822
  width: "100%",
@@ -1875,9 +1887,6 @@ var GAS_LABEL_STYLE = {
1875
1887
  function Hint({ children }) {
1876
1888
  return /* @__PURE__ */ jsx("p", { style: HINT_STYLE, children });
1877
1889
  }
1878
- function formatThousands(n) {
1879
- return n.toLocaleString("en-US");
1880
- }
1881
1890
  function ConfigTab({ state, onChange, calibratedGasLimit }) {
1882
1891
  const config = state.config;
1883
1892
  const patch = (next) => {
@@ -3308,13 +3317,12 @@ var REASONS_STYLE = {
3308
3317
  lineHeight: 1.6
3309
3318
  };
3310
3319
  var TRIGGER_ONLY_SCHEDULE = "Trigger-only (external / manual)";
3311
- function formatThousands2(n) {
3312
- return n.toLocaleString("en-US");
3313
- }
3320
+ var EVENT_DRIVEN_SCHEDULE = "Event-driven (host-fired)";
3321
+ var EVENT_DRIVEN_NOTICE = "Event-driven \u2014 the host application fires this when its trigger condition is met; there is no schedule.";
3314
3322
  function gasLine(state) {
3315
3323
  const c = state.config;
3316
3324
  const suffix = c.autoGasLimit ? " (AUTO)" : "";
3317
- return `${formatThousands2(c.gasLimit)} @ ${c.gasPriceAnu} ANU${suffix}`;
3325
+ return `${formatThousands(c.gasLimit)} @ ${c.gasPriceAnu} ANU${suffix}`;
3318
3326
  }
3319
3327
  function gasPayerLabel(gasPayer) {
3320
3328
  if (gasPayer.type === "gas-station") return "Gas Station";
@@ -3329,8 +3337,10 @@ function scopedCapLineCount(state) {
3329
3337
  function signersLine(state) {
3330
3338
  return `${effectiveSignerCount(state)} (${scopedCapLineCount(state)} caps)`;
3331
3339
  }
3332
- function scheduleLine3(state) {
3333
- return isTriggerOnly2(state) ? TRIGGER_ONLY_SCHEDULE : summariseSchedule(state.schedule.mode, state.schedule.config);
3340
+ function scheduleLine3(state, eventDrivenResolver) {
3341
+ if (eventDrivenResolver) return EVENT_DRIVEN_SCHEDULE;
3342
+ if (isTriggerOnly2(state) || state.externalFireable) return TRIGGER_ONLY_SCHEDULE;
3343
+ return summariseSchedule(state.schedule.mode, state.schedule.config);
3334
3344
  }
3335
3345
  function SummaryRow({
3336
3346
  label,
@@ -3342,8 +3352,14 @@ function SummaryRow({
3342
3352
  /* @__PURE__ */ jsx("span", { style: ROW_VALUE_STYLE, children: value })
3343
3353
  ] });
3344
3354
  }
3345
- function ExecuteTab({ state, onChange, onCommit, committing }) {
3346
- const sim = useSimulate();
3355
+ function ExecuteTab({
3356
+ state,
3357
+ onChange,
3358
+ onCommit,
3359
+ committing,
3360
+ eventDrivenResolver,
3361
+ sim
3362
+ }) {
3347
3363
  const [banner, setBanner] = useState(null);
3348
3364
  const commit = builderToCommit(state);
3349
3365
  const payloadKeyCount = Object.keys(commit.envelope.payload ?? {}).length;
@@ -3352,6 +3368,7 @@ function ExecuteTab({ state, onChange, onCommit, committing }) {
3352
3368
  );
3353
3369
  const gate = canCommit(state, { simulateCalibrated });
3354
3370
  const triggerOnly = isTriggerOnly2(state);
3371
+ const schedulerOff = triggerOnly || state.externalFireable || Boolean(eventDrivenResolver);
3355
3372
  const onSimulate = async () => {
3356
3373
  const view = await sim.run(commit.envelope);
3357
3374
  if (!view) {
@@ -3372,7 +3389,7 @@ function ExecuteTab({ state, onChange, onCommit, committing }) {
3372
3389
  setBanner(
3373
3390
  renderBanner(
3374
3391
  "var(--khr-success)",
3375
- `Simulation succeeded \u2014 calibrated ${formatThousands2(view.calibratedGasLimit)} gas.`
3392
+ `Simulation succeeded \u2014 calibrated ${formatThousands(view.calibratedGasLimit)} gas.`
3376
3393
  )
3377
3394
  );
3378
3395
  return;
@@ -3398,7 +3415,7 @@ function ExecuteTab({ state, onChange, onCommit, committing }) {
3398
3415
  /* @__PURE__ */ jsx(SummaryRow, { label: "Payload keys", value: String(payloadKeyCount), testId: "summary-payload" }),
3399
3416
  /* @__PURE__ */ jsx(SummaryRow, { label: "Gas payer", value: gasPayerLabel(state.gasPayer), testId: "summary-gaspayer" }),
3400
3417
  /* @__PURE__ */ jsx(SummaryRow, { label: "Signers", value: signersLine(state), testId: "summary-signers" }),
3401
- /* @__PURE__ */ jsx(SummaryRow, { label: "Schedule", value: scheduleLine3(state), testId: "summary-schedule" })
3418
+ /* @__PURE__ */ jsx(SummaryRow, { label: "Schedule", value: scheduleLine3(state, eventDrivenResolver), testId: "summary-schedule" })
3402
3419
  ] }),
3403
3420
  /* @__PURE__ */ jsxs("div", { style: { marginBottom: "16px" }, children: [
3404
3421
  /* @__PURE__ */ jsx(
@@ -3413,7 +3430,7 @@ function ExecuteTab({ state, onChange, onCommit, committing }) {
3413
3430
  ),
3414
3431
  banner
3415
3432
  ] }),
3416
- /* @__PURE__ */ jsx("div", { style: { marginBottom: "16px" }, children: triggerOnly ? /* @__PURE__ */ jsx("div", { style: TRIGGER_BOX_STYLE, children: "Trigger-only. This cronoton declares runtime arguments and never runs on a timer \u2014 it fires only via the external trigger endpoint or a manual run." }) : /* @__PURE__ */ jsx(ScheduleStep, { state, onChange }) }),
3433
+ /* @__PURE__ */ jsx("div", { style: { marginBottom: "16px" }, children: schedulerOff ? eventDrivenResolver ? /* @__PURE__ */ jsx("div", { style: TRIGGER_BOX_STYLE, children: EVENT_DRIVEN_NOTICE }) : /* @__PURE__ */ jsx("div", { style: TRIGGER_BOX_STYLE, children: "Trigger-only. This cronoton never runs on a timer \u2014 it fires only via the external trigger endpoint or a manual run." }) : /* @__PURE__ */ jsx(ScheduleStep, { state, onChange }) }),
3417
3434
  /* @__PURE__ */ jsxs("div", { children: [
3418
3435
  /* @__PURE__ */ jsx(
3419
3436
  "button",
@@ -3439,6 +3456,146 @@ function renderBanner(color, message) {
3439
3456
  }
3440
3457
  );
3441
3458
  }
3459
+
3460
+ // src/ui/tx-size.ts
3461
+ var STOA_TX_BYTE_CEILING = 2 * 1024 * 1024;
3462
+ var PROXY_SOFT_LIMIT = 1 * 1024 * 1024;
3463
+ var BYTES_PER_SIGNATURE = 140;
3464
+ function estimateFallbackBytes(pactCode, payload) {
3465
+ return new TextEncoder().encode(pactCode + JSON.stringify(payload)).length;
3466
+ }
3467
+ async function estimateTxSize(state) {
3468
+ const commit = builderToCommit(state);
3469
+ const { pactCode, config, payload, signers } = commit.envelope;
3470
+ let bytes;
3471
+ try {
3472
+ const { Pact } = await import('@stoachain/kadena-stoic-legacy/client');
3473
+ const { anuToStoa } = await import('@stoachain/stoa-core/gas');
3474
+ const { KADENA_NETWORK } = await import('@stoachain/stoa-core/constants');
3475
+ const builder = Pact.builder.execution(pactCode || "").setMeta({
3476
+ senderAccount: state.gasPayer.type === "codex" ? state.gasPayer.address ?? "" : "c:gas-station",
3477
+ chainId: config.chainId,
3478
+ gasLimit: config.gasLimit,
3479
+ gasPrice: anuToStoa(config.gasPrice),
3480
+ ttl: config.ttl
3481
+ }).setNetworkId(KADENA_NETWORK);
3482
+ for (const [k, v] of Object.entries(payload ?? {})) {
3483
+ builder.addData(k, v);
3484
+ }
3485
+ const tx = builder.createTransaction();
3486
+ const body = JSON.stringify({ cmds: [tx] });
3487
+ bytes = new TextEncoder().encode(body).length + signers.length * BYTES_PER_SIGNATURE;
3488
+ } catch {
3489
+ bytes = estimateFallbackBytes(pactCode, payload);
3490
+ }
3491
+ return {
3492
+ bytes,
3493
+ ceiling: STOA_TX_BYTE_CEILING,
3494
+ fraction: bytes / STOA_TX_BYTE_CEILING,
3495
+ permille: bytes / STOA_TX_BYTE_CEILING * 1e3,
3496
+ over: bytes > STOA_TX_BYTE_CEILING
3497
+ };
3498
+ }
3499
+ var WRAP_STYLE = {
3500
+ display: "flex",
3501
+ flexDirection: "column",
3502
+ gap: "4px"
3503
+ };
3504
+ var ROW_STYLE5 = {
3505
+ display: "flex",
3506
+ alignItems: "center",
3507
+ gap: "8px",
3508
+ fontSize: "11px"
3509
+ };
3510
+ var LABEL_STYLE2 = {
3511
+ color: "var(--khr-text-dim)",
3512
+ textTransform: "uppercase",
3513
+ letterSpacing: "0.06em",
3514
+ minWidth: "46px"
3515
+ };
3516
+ var TRACK_STYLE = {
3517
+ flex: 1,
3518
+ height: "6px",
3519
+ borderRadius: "999px",
3520
+ backgroundColor: "var(--khr-inset)",
3521
+ overflow: "hidden",
3522
+ display: "flex"
3523
+ };
3524
+ var VALUE_STYLE = {
3525
+ fontFamily: "var(--khr-mono-font)",
3526
+ minWidth: "120px",
3527
+ textAlign: "right"
3528
+ };
3529
+ function formatBytes(n) {
3530
+ if (n < 1024) return `${n} B`;
3531
+ if (n < 1024 * 1024) return `${(n / 1024).toFixed(2)} KB`;
3532
+ return `${(n / 1024 / 1024).toFixed(3)} MB`;
3533
+ }
3534
+ function TxMeters({ state, sim }) {
3535
+ const [estimate, setEstimate] = useState(null);
3536
+ useEffect(() => {
3537
+ let active = true;
3538
+ void (async () => {
3539
+ const next = await estimateTxSize(state);
3540
+ if (active) setEstimate(next);
3541
+ })();
3542
+ return () => {
3543
+ active = false;
3544
+ };
3545
+ }, [
3546
+ state.pactCode,
3547
+ state.config.chainId,
3548
+ state.config.gasLimit,
3549
+ state.config.gasPriceAnu,
3550
+ state.config.ttl,
3551
+ state.payload,
3552
+ state.signers.length,
3553
+ state.gasPayer
3554
+ ]);
3555
+ const sizeTier = !estimate ? "pending" : estimate.over ? "error" : estimate.bytes > PROXY_SOFT_LIMIT ? "amber" : "ok";
3556
+ const sizeColor = sizeTier === "error" ? "var(--khr-error)" : sizeTier === "amber" ? "var(--khr-amber)" : sizeTier === "ok" ? "var(--khr-success)" : "var(--khr-text-dim)";
3557
+ const sizeValue = estimate ? `${formatBytes(estimate.bytes)} \xB7 ${estimate.permille.toFixed(4)} \u2030${estimate.over ? " \u26A0" : ""}` : "\u2026";
3558
+ const used = sim.result?.gasUsed;
3559
+ const limit = state.config.gasLimit;
3560
+ const hasSim = sim.result?.ok === true && typeof used === "number" && limit > 0;
3561
+ const overLimit = hasSim && used > limit;
3562
+ const usedFraction = hasSim ? Math.min(used / limit * 100, 100) : 0;
3563
+ const gasValue = hasSim ? overLimit ? `${formatThousands(used)} > ${formatThousands(limit)} \u26A0` : `${formatThousands(used)} / ${formatThousands(limit)}` : "Run Simulate";
3564
+ return /* @__PURE__ */ jsxs("div", { style: WRAP_STYLE, children: [
3565
+ /* @__PURE__ */ jsxs("div", { style: ROW_STYLE5, children: [
3566
+ /* @__PURE__ */ jsx("span", { style: LABEL_STYLE2, children: "Tx Size" }),
3567
+ /* @__PURE__ */ jsx("div", { style: TRACK_STYLE, children: /* @__PURE__ */ jsx(
3568
+ "div",
3569
+ {
3570
+ style: {
3571
+ width: estimate ? `${Math.min(estimate.fraction * 100, 100)}%` : "0%",
3572
+ backgroundColor: sizeColor
3573
+ }
3574
+ }
3575
+ ) }),
3576
+ /* @__PURE__ */ jsx("span", { style: { ...VALUE_STYLE, color: sizeColor }, children: sizeValue })
3577
+ ] }),
3578
+ /* @__PURE__ */ jsxs("div", { style: ROW_STYLE5, children: [
3579
+ /* @__PURE__ */ jsx("span", { style: LABEL_STYLE2, children: "Gas" }),
3580
+ /* @__PURE__ */ jsx("div", { style: TRACK_STYLE, children: hasSim ? overLimit ? /* @__PURE__ */ jsx("div", { style: { width: "100%", backgroundColor: "var(--khr-error)" } }) : /* @__PURE__ */ jsxs(Fragment, { children: [
3581
+ /* @__PURE__ */ jsx("div", { style: { width: `${usedFraction}%`, backgroundColor: "var(--khr-amber)" } }),
3582
+ /* @__PURE__ */ jsx(
3583
+ "div",
3584
+ {
3585
+ style: { width: `${100 - usedFraction}%`, backgroundColor: "var(--khr-error)" }
3586
+ }
3587
+ )
3588
+ ] }) : null }),
3589
+ /* @__PURE__ */ jsx(
3590
+ "span",
3591
+ {
3592
+ style: { ...VALUE_STYLE, color: hasSim ? "var(--khr-text)" : "var(--khr-text-dim)" },
3593
+ children: gasValue
3594
+ }
3595
+ )
3596
+ ] })
3597
+ ] });
3598
+ }
3442
3599
  var DEFAULT_BUILDER_ROBOTS = "noindex,nofollow";
3443
3600
  var TABS = [
3444
3601
  { key: "config", label: "Config" },
@@ -3448,10 +3605,9 @@ var TABS = [
3448
3605
  { key: "execute", label: "Execute" }
3449
3606
  ];
3450
3607
  var PANE_WRAP = {
3451
- display: "grid",
3452
- gridTemplateColumns: "minmax(0, 1fr) minmax(0, 1fr)",
3453
- gap: "1rem",
3454
- alignItems: "start"
3608
+ display: "flex",
3609
+ flexDirection: "column",
3610
+ gap: "1rem"
3455
3611
  };
3456
3612
  var TABLIST = {
3457
3613
  display: "flex",
@@ -3489,7 +3645,9 @@ function Builder({
3489
3645
  robots = DEFAULT_BUILDER_ROBOTS
3490
3646
  }) {
3491
3647
  const adapter = useKhronotonAdapter();
3648
+ const config = useKhronotonConfig();
3492
3649
  const actions = useCronotonActions(editId);
3650
+ const sim = useSimulate();
3493
3651
  const [state, setState] = useState(() => makeEmptyBuilderState());
3494
3652
  const [signers, setSigners] = useState([]);
3495
3653
  const [activeTab, setActiveTab] = useState("config");
@@ -3498,6 +3656,9 @@ function Builder({
3498
3656
  const [loadedEditId, setLoadedEditId] = useState(void 0);
3499
3657
  const isEdit = Boolean(editId);
3500
3658
  const editReady = !editId || loadedEditId === editId;
3659
+ const eventDrivenResolver = Boolean(
3660
+ state.serverResolver && config.serverResolverOptions.find((o) => o.value === state.serverResolver)?.eventDriven
3661
+ );
3501
3662
  useEffect(() => {
3502
3663
  let active = true;
3503
3664
  void (async () => {
@@ -3531,7 +3692,7 @@ function Builder({
3531
3692
  const handleCommit = useCallback(async () => {
3532
3693
  setCommitting(true);
3533
3694
  try {
3534
- const body = builderToCommit(state);
3695
+ const body = builderToCommit(state, { eventDriven: eventDrivenResolver });
3535
3696
  if (isEdit && editId) {
3536
3697
  const res = await actions.edit.run(body);
3537
3698
  if (res.ok) onDone?.(editId);
@@ -3544,8 +3705,11 @@ function Builder({
3544
3705
  } finally {
3545
3706
  setCommitting(false);
3546
3707
  }
3547
- }, [state, isEdit, editId, actions, onDone]);
3708
+ }, [state, isEdit, editId, actions, onDone, eventDrivenResolver]);
3548
3709
  const calibratedGasLimit = state.config.autoGasLimit ? state.config.gasLimit : null;
3710
+ const handlePactCodeChange = useCallback((pactCode) => {
3711
+ setState((s) => ({ ...s, pactCode }));
3712
+ }, []);
3549
3713
  return /* @__PURE__ */ jsxs("div", { className: "khronoton-ui", children: [
3550
3714
  /* @__PURE__ */ jsx("meta", { name: "robots", content: robots }),
3551
3715
  isEdit && /* @__PURE__ */ jsxs("div", { style: EDIT_BANNER, children: [
@@ -3562,8 +3726,10 @@ function Builder({
3562
3726
  PactCodeEditor,
3563
3727
  {
3564
3728
  value: state.pactCode,
3565
- onChange: (pactCode) => setState((s) => ({ ...s, pactCode })),
3566
- onClear: () => setState((s) => ({ ...s, pactCode: "" }))
3729
+ onChange: handlePactCodeChange,
3730
+ onClear: () => setState((s) => ({ ...s, pactCode: "" })),
3731
+ height: 126,
3732
+ subBar: /* @__PURE__ */ jsx(TxMeters, { state, sim })
3567
3733
  }
3568
3734
  ),
3569
3735
  /* @__PURE__ */ jsxs("div", { children: [
@@ -3590,7 +3756,9 @@ function Builder({
3590
3756
  state,
3591
3757
  onChange: setState,
3592
3758
  onCommit: handleCommit,
3593
- committing
3759
+ committing,
3760
+ eventDrivenResolver,
3761
+ sim
3594
3762
  }
3595
3763
  )
3596
3764
  ] })
package/dist/ui.css CHANGED
@@ -32,4 +32,10 @@
32
32
  --khr-radius-lg: 14px;
33
33
  --khr-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
34
34
  --khr-mono-font: ui-monospace, "SFMono-Regular", "Geist Mono", Menlo, Consolas, monospace;
35
+ --khr-syntax-keyword: #c586c0;
36
+ --khr-syntax-type: #4ec9b0;
37
+ --khr-syntax-string: #ce9178;
38
+ --khr-syntax-number: #b5cea8;
39
+ --khr-syntax-atom: #d7ba7d;
40
+ --khr-selection: #1e3a5f;
35
41
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancientpantheon/khronoton-core",
3
- "version": "0.4.2",
3
+ "version": "0.6.0",
4
4
  "description": "Headless framework-agnostic scheduler engine: pure schedule math plus an injectable tick engine. No database, no job queue, no framework — hosts inject storage and firing via hooks.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -74,9 +74,14 @@
74
74
  },
75
75
  "license": "UNLICENSED",
76
76
  "peerDependencies": {
77
+ "@codemirror/language": "^6.12.4",
78
+ "@codemirror/state": "^6.5.2",
79
+ "@codemirror/view": "^6.36.4",
80
+ "@lezer/highlight": "^1.2.3",
77
81
  "@ouronet/ouronet-core": "^4.3.6",
78
82
  "@stoachain/kadena-stoic-legacy": "^4.3.6",
79
83
  "@stoachain/stoa-core": "^4.3.6",
84
+ "@uiw/react-codemirror": "^4.23.10",
80
85
  "react": "^18 || ^19",
81
86
  "react-dom": "^18 || ^19"
82
87
  },
@@ -95,14 +100,31 @@
95
100
  },
96
101
  "@ouronet/ouronet-core": {
97
102
  "optional": true
103
+ },
104
+ "@uiw/react-codemirror": {
105
+ "optional": true
106
+ },
107
+ "@codemirror/state": {
108
+ "optional": true
109
+ },
110
+ "@codemirror/view": {
111
+ "optional": true
112
+ },
113
+ "@codemirror/language": {
114
+ "optional": true
115
+ },
116
+ "@lezer/highlight": {
117
+ "optional": true
98
118
  }
99
119
  },
100
120
  "optionalDependencies": {
101
121
  "better-sqlite3": "^12.11.1"
102
122
  },
103
123
  "devDependencies": {
124
+ "@codemirror/language": "^6.12.4",
104
125
  "@codemirror/state": "^6.5.2",
105
126
  "@codemirror/view": "^6.36.4",
127
+ "@lezer/highlight": "^1.2.3",
106
128
  "@ouronet/ouronet-core": "^4.3.6",
107
129
  "@stoachain/kadena-stoic-legacy": "^4.3.6",
108
130
  "@stoachain/stoa-core": "^4.3.6",
@@ -1,64 +0,0 @@
1
- import CodeMirror from '@uiw/react-codemirror';
2
- import { EditorView } from '@codemirror/view';
3
- import { jsx } from 'react/jsx-runtime';
4
-
5
- // src/ui/PactCodeMirror.tsx
6
- var GUTTER_BG = "#0d1117";
7
- var ACTIVE_LINE_BG = "#161616";
8
- var khronotonEditorTheme = EditorView.theme(
9
- {
10
- "&": {
11
- backgroundColor: "var(--khr-panel, #0a0a0a)",
12
- color: "var(--khr-mono, #d2d3d4)",
13
- fontSize: "12px"
14
- },
15
- ".cm-content": {
16
- fontFamily: "var(--khr-mono-font, ui-monospace, monospace)",
17
- caretColor: "var(--khr-accent, #f0a500)"
18
- },
19
- ".cm-cursor, .cm-dropCursor": {
20
- borderLeftColor: "var(--khr-accent, #f0a500)"
21
- },
22
- "&.cm-focused": {
23
- outline: "none"
24
- },
25
- "&.cm-editor.cm-focused": {
26
- outline: "1px solid var(--khr-accent, #f0a500)"
27
- },
28
- "&.cm-focused .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection": {
29
- backgroundColor: "var(--khr-accent-tint, #1a1500)"
30
- },
31
- ".cm-gutters": {
32
- backgroundColor: GUTTER_BG,
33
- color: "var(--khr-text-dim, #8a8f98)",
34
- border: "none"
35
- },
36
- ".cm-activeLine": { backgroundColor: ACTIVE_LINE_BG },
37
- ".cm-activeLineGutter": { backgroundColor: ACTIVE_LINE_BG }
38
- },
39
- { dark: true }
40
- );
41
- function PactCodeMirror({
42
- value,
43
- onChange,
44
- height
45
- }) {
46
- return /* @__PURE__ */ jsx(
47
- CodeMirror,
48
- {
49
- value,
50
- height: `${height}px`,
51
- theme: khronotonEditorTheme,
52
- basicSetup: {
53
- lineNumbers: true,
54
- foldGutter: false,
55
- closeBrackets: false,
56
- autocompletion: false,
57
- highlightActiveLine: true
58
- },
59
- onChange
60
- }
61
- );
62
- }
63
-
64
- export { PactCodeMirror as default };