okengine 0.3.5 → 0.3.6

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.
Files changed (98) hide show
  1. package/AGENTS.md +4 -0
  2. package/manifest.v1.schema.json +43 -1
  3. package/package.json +16 -1
  4. package/site/content/docs/ai/skills.mdx +9 -7
  5. package/site/content/docs/console/vault.mdx +4 -0
  6. package/site/content/docs/elements/channel.mdx +5 -4
  7. package/site/content/docs/elements/clock.mdx +1 -0
  8. package/site/content/docs/elements/flow.mdx +15 -0
  9. package/site/content/docs/elements/gate.mdx +16 -11
  10. package/site/content/docs/elements/signal.mdx +8 -7
  11. package/site/content/docs/elements/store.mdx +48 -8
  12. package/site/content/docs/elements/vault.mdx +1 -1
  13. package/site/content/docs/plugins/ip-allowlist.mdx +2 -2
  14. package/site/content/docs/reference/configuration.mdx +2 -2
  15. package/site/content/docs/reference/environment-variables.mdx +8 -0
  16. package/site/content/docs/reference/fx.mdx +40 -0
  17. package/site/content/docs/reference/plugins.mdx +18 -18
  18. package/src/compiler/extract.test.ts +63 -0
  19. package/src/compiler/extract.ts +36 -15
  20. package/src/console/server/channels.ts +2 -0
  21. package/src/console/server/clock.ts +3 -0
  22. package/src/console/server/flows.ts +13 -0
  23. package/src/console/server/gates.ts +2 -0
  24. package/src/console/server/plugins.ts +20 -1
  25. package/src/console/server/signals.ts +5 -0
  26. package/src/console/server/store.test.ts +17 -0
  27. package/src/console/server/store.ts +24 -0
  28. package/src/console/ui/channels/types.ts +1 -0
  29. package/src/console/ui/clock/types.ts +1 -0
  30. package/src/console/ui/display.test.ts +14 -0
  31. package/src/console/ui/display.ts +9 -0
  32. package/src/console/ui/dist/assets/{index-BWo8R7NR.js → index-CrKMmO__.js} +2 -2
  33. package/src/console/ui/dist/assets/panel-channels-DCDd4WAC.js +1 -0
  34. package/src/console/ui/dist/assets/panel-clock-DjGGFPzr.js +1 -0
  35. package/src/console/ui/dist/assets/panel-gates-B5eTE8XH.js +1 -0
  36. package/src/console/ui/dist/assets/{panel-overview-BznEOTnb.js → panel-overview-BsFvDdts.js} +1 -1
  37. package/src/console/ui/dist/assets/panel-plugins-Cj7DK1er.js +1 -0
  38. package/src/console/ui/dist/assets/{panel-runs-CGWNHLR4.js → panel-runs-C0gmnoYL.js} +1 -1
  39. package/src/console/ui/dist/assets/panel-signals-whmDXIg3.js +1 -0
  40. package/src/console/ui/dist/assets/panel-store-CEMHLvaw.js +1 -0
  41. package/src/console/ui/dist/assets/{panel-traces-DBLx2ilD.js → panel-traces-BDiAuVSK.js} +1 -1
  42. package/src/console/ui/dist/assets/panel-vault-C9wjbki8.js +1 -0
  43. package/src/console/ui/dist/index.html +1 -1
  44. package/src/console/ui/gates/types.ts +1 -0
  45. package/src/console/ui/plugins/fixture.ts +7 -0
  46. package/src/console/ui/plugins/types.ts +3 -0
  47. package/src/console/ui/shell/client.ts +3 -0
  48. package/src/console/ui/shell/panels/channels/ChannelsPanel.tsx +7 -2
  49. package/src/console/ui/shell/panels/clock/ClockPanel.tsx +9 -2
  50. package/src/console/ui/shell/panels/gates/GatesPanel.tsx +12 -5
  51. package/src/console/ui/shell/panels/plugins/PluginsPanel.tsx +18 -4
  52. package/src/console/ui/shell/panels/signals/SignalsPanel.tsx +13 -2
  53. package/src/console/ui/shell/panels/store/StorePanel.tsx +11 -4
  54. package/src/console/ui/shell/panels/vault/VaultPanel.tsx +9 -3
  55. package/src/console/ui/signals/types.ts +1 -0
  56. package/src/console/ui/store/fixture.ts +5 -0
  57. package/src/console/ui/store/types.ts +2 -0
  58. package/src/drivers/conformance.test.ts +11 -0
  59. package/src/drivers/drizzle-dialect.test.ts +4 -0
  60. package/src/drivers/drizzle-dialect.ts +8 -4
  61. package/src/drivers/index.ts +4 -0
  62. package/src/drivers/libsql.ts +179 -0
  63. package/src/drivers/pglite.ts +79 -0
  64. package/src/drivers/pgvector.ts +54 -19
  65. package/src/drivers/types.ts +16 -7
  66. package/src/elements/channel/declare.ts +5 -0
  67. package/src/elements/clock/declare.ts +5 -0
  68. package/src/elements/clock/durable.ts +7 -1
  69. package/src/elements/gate/declare.ts +28 -5
  70. package/src/elements/gate.ts +1 -0
  71. package/src/elements/signal/declare.ts +5 -0
  72. package/src/elements/store/declare.ts +10 -2
  73. package/src/elements/store/index-boot.test.ts +257 -0
  74. package/src/elements/store/runtime.ts +67 -9
  75. package/src/elements/store/schema-decl.ts +7 -0
  76. package/src/kernel/abort-scope.ts +116 -0
  77. package/src/kernel/app.ts +12 -2
  78. package/src/kernel/boot-bind/store.test.ts +59 -1
  79. package/src/kernel/boot-bind/store.ts +64 -2
  80. package/src/kernel/concurrency.test.ts +236 -0
  81. package/src/kernel/concurrency.ts +172 -0
  82. package/src/kernel/flow.ts +9 -0
  83. package/src/kernel/fx.test.ts +12 -0
  84. package/src/kernel/fx.ts +44 -0
  85. package/src/kernel/index.ts +14 -0
  86. package/src/kernel/journal.ts +9 -0
  87. package/src/kernel/plugin/capabilities.test.ts +18 -0
  88. package/src/kernel/plugin.ts +11 -3
  89. package/src/kernel/registry.ts +29 -6
  90. package/src/manifest/types.ts +21 -0
  91. package/src/release/measure.ts +4 -0
  92. package/src/console/ui/dist/assets/panel-channels-BOmQ-onL.js +0 -1
  93. package/src/console/ui/dist/assets/panel-clock-giAq0Ccv.js +0 -1
  94. package/src/console/ui/dist/assets/panel-gates-XclZxWD5.js +0 -1
  95. package/src/console/ui/dist/assets/panel-plugins-CcGM1g64.js +0 -1
  96. package/src/console/ui/dist/assets/panel-signals-CNywkdak.js +0 -1
  97. package/src/console/ui/dist/assets/panel-store-KmTbFHMH.js +0 -1
  98. package/src/console/ui/dist/assets/panel-vault-CEnFc0dk.js +0 -1
package/src/kernel/fx.ts CHANGED
@@ -32,9 +32,13 @@ import {
32
32
  touchDryRunStore,
33
33
  } from "./dry-run.ts";
34
34
  import { fail, type FailOptions, type FlowFailure } from "./errors.ts";
35
+ import { currentAbortSignal } from "./abort-scope.ts";
36
+ import { fxAll, fxRace, fxRetry, type FxRetryOptions, type FxThunk } from "./concurrency.ts";
35
37
  import type { JournalSession } from "./journal.ts";
36
38
  import type { RunTelemetry } from "./run-telemetry.ts";
37
39
 
40
+ export type { FxRetryOptions, FxThunk } from "./concurrency.ts";
41
+
38
42
  /** Named ref: plain string or `{ name }` element handle. */
39
43
  export type NamedRef = string | { readonly name: string };
40
44
 
@@ -337,6 +341,34 @@ export interface Fx {
337
341
  * @param fn - Step body
338
342
  */
339
343
  step<T>(name: string, fn: () => T | Promise<T>): Promise<T>;
344
+ /**
345
+ * Ambient abort signal for the current structured-concurrency branch.
346
+ * Outside `all` / `race`, a never-aborted signal.
347
+ */
348
+ readonly signal: AbortSignal;
349
+ /**
350
+ * Run thunks in parallel. On first rejection, abort sibling branches and
351
+ * rethrow. Pass thunks (not started Promises) so abort scopes exist first.
352
+ *
353
+ * @param thunks - Parallel work units
354
+ */
355
+ all<const T extends readonly unknown[]>(thunks: {
356
+ readonly [K in keyof T]: FxThunk<T[K]>;
357
+ }): Promise<{ -readonly [K in keyof T]: Awaited<T[K]> }>;
358
+ /**
359
+ * Race thunks. The first settle wins; losers are aborted.
360
+ *
361
+ * @param thunks - Competing work units
362
+ */
363
+ race<T>(thunks: ReadonlyArray<FxThunk<T>>): Promise<T>;
364
+ /**
365
+ * Retry a thunk with exponential backoff and optional full jitter.
366
+ * Prefer wrapping inside {@link Fx.step} so durable replay skips completed work.
367
+ *
368
+ * @param fn - Operation
369
+ * @param opts - Retry policy
370
+ */
371
+ retry<T>(fn: FxThunk<T>, opts?: FxRetryOptions): Promise<T>;
340
372
  }
341
373
 
342
374
  /**
@@ -1035,6 +1067,18 @@ export function createFxContext(options: CreateFxOptions): FxContext {
1035
1067
  }
1036
1068
  return await fn();
1037
1069
  },
1070
+ get signal(): AbortSignal {
1071
+ return currentAbortSignal();
1072
+ },
1073
+ all(thunks) {
1074
+ return fxAll(thunks);
1075
+ },
1076
+ race(thunks) {
1077
+ return fxRace(thunks);
1078
+ },
1079
+ retry(fn, opts) {
1080
+ return fxRetry(fn, opts);
1081
+ },
1038
1082
  };
1039
1083
 
1040
1084
  return { fx, ledger, capability };
@@ -118,14 +118,27 @@ export {
118
118
  type FxJson,
119
119
  type FxLog,
120
120
  type FxOperator,
121
+ type FxRetryOptions,
121
122
  type FxSearchOptions,
122
123
  type FxSendOptions,
123
124
  type FxStoreHandle,
124
125
  type FxTenant,
126
+ type FxThunk,
125
127
  type JsonResult,
126
128
  type NamedRef,
127
129
  } from "./fx.ts";
128
130
 
131
+ export {
132
+ abortError,
133
+ abortableSleep,
134
+ currentAbortSignal,
135
+ isAbortError,
136
+ linkAbort,
137
+ withAbortSignal,
138
+ } from "./abort-scope.ts";
139
+
140
+ export { defaultRetryWhen, fxAll, fxRace, fxRetry, resolveRetryDelayMs } from "./concurrency.ts";
141
+
129
142
  export {
130
143
  DryRunWriteIsolationError,
131
144
  dryRunWouldHaveFired,
@@ -200,6 +213,7 @@ export {
200
213
  type PluginOptions,
201
214
  type PluginRegistration,
202
215
  type TableContribution,
216
+ type PluginTableMeta,
203
217
  type PluginTableOptions,
204
218
  } from "./plugin.ts";
205
219
 
@@ -201,6 +201,12 @@ export interface JournalSession {
201
201
  * @param execute - Side-effecting body
202
202
  */
203
203
  effect<T>(effectKind: string, resource: string, execute: () => T | Promise<T>): Promise<T>;
204
+ /**
205
+ * Rewind the replay cursor to the start of the entry list.
206
+ * Used by flow-level retry so a re-entered `do` replays completed steps
207
+ * instead of treating the cursor as past them.
208
+ */
209
+ rewind(): void;
204
210
  /** Persist current run status / output. */
205
211
  commit(
206
212
  status: JournalRunStatus,
@@ -325,6 +331,9 @@ export function createJournal(options: CreateJournalOptions): Journal {
325
331
  await persist();
326
332
  return value;
327
333
  },
334
+ rewind() {
335
+ cursor = 0;
336
+ },
328
337
  async commit(status, patch) {
329
338
  run.status = status;
330
339
  if (patch?.wakeAt !== undefined) run.wakeAt = patch.wakeAt;
@@ -81,4 +81,22 @@ describe("plugin capability capture", () => {
81
81
  },
82
82
  });
83
83
  });
84
+
85
+ test("table description lands on capabilities.tables", () => {
86
+ const audit = plugin("audit", { version: "1.0.0" }).table("audit_events", undefined, {
87
+ description: "Immutable audit log",
88
+ plane: "operator",
89
+ });
90
+ const { api, snapshot } = createRecordingApi({
91
+ name: "audit",
92
+ version: "1.0.0",
93
+ });
94
+ audit.register(api);
95
+ expect(snapshot().capabilities.tables).toEqual({
96
+ audit_events: {
97
+ description: "Immutable audit log",
98
+ plane: "operator",
99
+ },
100
+ });
101
+ });
84
102
  });
@@ -111,9 +111,7 @@ export interface TableContribution {
111
111
  * Non-column metadata (e.g. data plane). Prefer this over stuffing `plane`
112
112
  * into the column map.
113
113
  */
114
- readonly options?: {
115
- readonly plane?: "operator" | "user" | "shared" | string;
116
- };
114
+ readonly options?: PluginTableOptions;
117
115
  /**
118
116
  * Opaque schema descriptor (legacy). Prefer {@link columns} + {@link options}.
119
117
  * Still set for plane-only contributions so older readers keep working.
@@ -124,6 +122,14 @@ export interface TableContribution {
124
122
  /** Options for {@link PluginApi.table} / {@link PluginDef.table}. */
125
123
  export interface PluginTableOptions {
126
124
  readonly plane?: "operator" | "user" | "shared" | string;
125
+ /** Optional human description for Console / docs (falls back to the table name). */
126
+ readonly description?: string;
127
+ }
128
+
129
+ /** Per-table metadata captured on {@link PluginCapabilities} / Manifest Plugin. */
130
+ export interface PluginTableMeta {
131
+ readonly plane?: string;
132
+ readonly description?: string;
127
133
  }
128
134
 
129
135
  /** Driver contribution. */
@@ -253,6 +259,8 @@ export interface PluginCapabilities {
253
259
  readonly intercepts: readonly string[];
254
260
  /** Declared dependencies from `.needs()`. */
255
261
  readonly needs: readonly string[];
262
+ /** Optional metadata for contributed tables (description / plane). */
263
+ readonly tables?: Readonly<Record<string, PluginTableMeta>>;
256
264
  }
257
265
 
258
266
  /** Snapshot of everything a registration requested. */
@@ -166,6 +166,7 @@ export function createRecordingApi(identity: { readonly name: string; readonly v
166
166
  return {
167
167
  api,
168
168
  snapshot(): PluginRegistration {
169
+ const tableMeta = tablesMetaFromContributions(tables);
169
170
  return {
170
171
  capabilities: {
171
172
  name: identity.name,
@@ -173,6 +174,7 @@ export function createRecordingApi(identity: { readonly name: string; readonly v
173
174
  declares: declares.slice(),
174
175
  intercepts: intercepts.slice(),
175
176
  needs: needs.slice(),
177
+ ...(tableMeta ? { tables: tableMeta } : {}),
176
178
  },
177
179
  hooks: { ...hooks },
178
180
  edges: edges.slice(),
@@ -440,9 +442,12 @@ function normalizeTableContribution(
440
442
  };
441
443
  }
442
444
 
443
- if (columnsOrOptions && isPlaneOnlyOptions(columnsOrOptions)) {
445
+ if (columnsOrOptions && isLegacyTableOptions(columnsOrOptions)) {
444
446
  const planeOptions: PluginTableOptions = {
445
- plane: columnsOrOptions.plane as string,
447
+ ...(typeof columnsOrOptions.plane === "string" ? { plane: columnsOrOptions.plane } : {}),
448
+ ...(typeof columnsOrOptions.description === "string"
449
+ ? { description: columnsOrOptions.description }
450
+ : {}),
446
451
  };
447
452
  return {
448
453
  name,
@@ -462,9 +467,27 @@ function normalizeTableContribution(
462
467
  return { name };
463
468
  }
464
469
 
465
- function isPlaneOnlyOptions(
466
- value: Readonly<Record<string, unknown>>,
467
- ): value is { readonly plane: string } {
470
+ function isLegacyTableOptions(value: Readonly<Record<string, unknown>>): boolean {
468
471
  const keys = Object.keys(value);
469
- return keys.length === 1 && keys[0] === "plane" && typeof value.plane === "string";
472
+ if (keys.length === 0) return false;
473
+ return keys.every((k) => k === "plane" || k === "description");
474
+ }
475
+
476
+ function tablesMetaFromContributions(
477
+ contributions: readonly TableContribution[],
478
+ ): Record<string, { readonly plane?: string; readonly description?: string }> | undefined {
479
+ if (contributions.length === 0) return undefined;
480
+ const out: Record<string, { readonly plane?: string; readonly description?: string }> = {};
481
+ let any = false;
482
+ for (const t of contributions) {
483
+ const plane = t.options?.plane;
484
+ const description = t.options?.description;
485
+ if (plane === undefined && description === undefined) continue;
486
+ any = true;
487
+ out[t.name] = {
488
+ ...(plane !== undefined ? { plane } : {}),
489
+ ...(description !== undefined ? { description } : {}),
490
+ };
491
+ }
492
+ return any ? out : undefined;
470
493
  }
@@ -165,6 +165,8 @@ export interface Flow {
165
165
  /** One Signal declaration. */
166
166
  export interface Signal {
167
167
  delivery: SignalDelivery;
168
+ /** Optional human description (falls back to the signal map key). */
169
+ description?: string;
168
170
  retries?: number;
169
171
  deadLetter?: boolean;
170
172
  schema?: JsonSchema;
@@ -201,6 +203,8 @@ export interface DeclaredColumn extends ColumnClassification {
201
203
  default?: string | number | boolean | null;
202
204
  /** Database column name (snake_case by default). */
203
205
  sqlName?: string;
206
+ /** Optional human description (falls back to the column map key). */
207
+ description?: string;
204
208
  /** Foreign key when `.references()` was declared. */
205
209
  references?: DeclaredColumnReference;
206
210
  }
@@ -217,6 +221,8 @@ export interface Table {
217
221
  /** One Store declaration. */
218
222
  export interface Store {
219
223
  facet: StoreFacet;
224
+ /** Optional human description (falls back to the store map key). */
225
+ description?: string;
220
226
  tables?: Record<string, Table>;
221
227
  namespaces?: string[];
222
228
  buckets?: string[];
@@ -230,6 +236,8 @@ export interface Clock {
230
236
  every?: string;
231
237
  timezone?: string;
232
238
  overridable?: boolean;
239
+ /** Optional human description (falls back to the clock map key). */
240
+ description?: string;
233
241
  }
234
242
 
235
243
  /** Named gate — policy or rate strategy. */
@@ -242,6 +250,8 @@ export interface Gate {
242
250
  keyBy?: string;
243
251
  scopes?: string[];
244
252
  roles?: string[];
253
+ /** Optional human description (falls back to the gate map key). */
254
+ description?: string;
245
255
  }
246
256
 
247
257
  /** Vault secret / config contract (never a secret value). */
@@ -258,6 +268,8 @@ export interface SecretContract {
258
268
 
259
269
  /** Channel template. */
260
270
  export interface Channel {
271
+ /** Optional human description (falls back to the channel map key). */
272
+ description?: string;
261
273
  medium?: ChannelMedium;
262
274
  locales?: string[];
263
275
  schema?: JsonSchema;
@@ -302,12 +314,21 @@ export interface Ai {
302
314
  agents?: Record<string, AiAgent>;
303
315
  }
304
316
 
317
+ /** Per-table metadata on a Manifest {@link Plugin}. */
318
+ export interface PluginTable {
319
+ plane?: string;
320
+ /** Optional human description (falls back to the table name). */
321
+ description?: string;
322
+ }
323
+
305
324
  /** Plugin capability declaration. */
306
325
  export interface Plugin {
307
326
  origin?: PluginOrigin;
308
327
  version?: string;
309
328
  declares?: string[];
310
329
  intercepts?: string[];
330
+ /** Optional metadata for `table:*` contributions. */
331
+ tables?: Record<string, PluginTable>;
311
332
  }
312
333
 
313
334
  /** Tenancy configuration (resolver is code; isolation is data). */
@@ -36,6 +36,10 @@ const EXPORT_BUILD_EXTERNALS = [
36
36
  "ajv-formats",
37
37
  "oxc-parser",
38
38
  "zod",
39
+ "@libsql/client",
40
+ "@libsql/*",
41
+ "@electric-sql/pglite",
42
+ "@electric-sql/*",
39
43
  ] as const;
40
44
 
41
45
  /** How a sample is gated. */
@@ -1 +0,0 @@
1
- import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,Z as i,a,b as o,d as s,et as c,g as l,nt as u,o as d,r as f,tt as p,u as m,w as h,y as g}from"./panel-access-C0J2D-a2.js";var _=g({q:o().optional(),template:o().optional(),locale:o().optional(),view:l([`inbox`,`outcomes`,`receipts`,`suppression`,`preview`]).optional()});function v(e){let t=_.safeParse(e);return t.success?t.data:{}}function y(e){let t={};return e.q&&(t.q=e.q),e.template&&(t.template=e.template),e.locale&&(t.locale=e.locale),e.view&&(t.view=e.view),t}function b(e,t){return{...e,template:t}}var x={"suppressed/opted-out":`Suppressed · opted out`,"suppressed/prior-bounce":`Suppressed · prior hard bounce`,"blocked/invalid-address":`Blocked · invalid address`,"soft-bounce":`Soft bounce`,"hard-bounce":`Hard bounce`,"provider-error":`Provider error`,"delivered-then-complained":`Delivered then complained`},S={correct:`correct`,retry:`retry`,suppress:`suppress`,review:`review`};function C(e){return[...e].sort((e,t)=>t.weight===e.weight?t.count-e.count:t.weight-e.weight)}function w(e){return e.weight>=10&&e.count>0}function T(e){return e.filter(e=>e.state===`delivered-then-complained`&&w(e)).map(e=>({state:`delivered-then-complained`,count:e.count,verdict:e.verdict,weight:e.weight}))}function E(e){return e.totalCount===0?`No sends in the last week`:e.chainExample?`${e.chainExample} · ${e.summary}`:e.summary}function D(e){return e.length===0?`default`:e.join(` → `)}function O(e={production:!0}){return e.production?{kind:`typed`,phrase:`SEND`,requireReason:!0}:{kind:`undo`,windowMs:f}}function k(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||e.medium.toLowerCase().includes(n)||e.locales.some(e=>e.toLowerCase().includes(n))):e}var A=e(u(),1),j=p();function M(){let e=h({from:`/channels`}),t=n({from:`/channels`}),o=c(),[l,u]=(0,A.useState)(``),[f,p]=(0,A.useState)(``),[g,_]=(0,A.useState)(`test@example.com`),[v,T]=(0,A.useState)(e.locale??``),[M,N]=(0,A.useState)(null),P=e=>{t({search:y(e),replace:!0})},F=r({queryKey:[`console.channel.list`],queryFn:async()=>{let e=await s.channelsList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}),I=F.data,L=(0,A.useMemo)(()=>k(I?.templates??[],e.q??``),[I?.templates,e.q]),R=L.find(t=>t.name===e.template)??I?.templates.find(t=>t.name===e.template),z=C(I?.outcomes??[]),B=O({production:I?.production??!0}),V=r({queryKey:[`console.channel.preview`,R?.name,v||e.locale],enabled:!!R,queryFn:async()=>{if(!R)return null;let t=await s.channelPreview({template:R.name,locale:v||e.locale||R.locales[0]});if(t.error)throw Error(t.error.code);return t.data}}),H=r({queryKey:[`console.channel.verifyAuth`,R?.from],enabled:!!R?.from,queryFn:async()=>{if(!R?.from)return null;let e=await s.channelVerifyAuth({from:R.from});if(e.error)throw Error(e.error.code);return e.data}});(0,A.useEffect)(()=>{u(``),p(``),N(null),R?.locales[0]&&!v&&T(R.locales[0])},[R?.name]);let U=i({mutationFn:async()=>{if(!R)throw Error(`No template selected`);if(B.kind===`typed`){let e=a({typed:l,reason:f,phrase:B.phrase});if(e)throw Error(e.typed??e.reason??`Confirm required`)}let e=await s.channelSendTest({template:R.name,to:g,locale:v||R.locales[0],confirmation:B.kind===`typed`?B.phrase:void 0,reason:B.kind===`typed`?f:void 0});if(e.error)throw Error(e.error.code);return e.data},onSuccess:e=>{N(e.ok?`Sent · ${e.messageId}${e.chain?` · ${e.chain}`:``}`:`Failed · ${e.status}`),o.invalidateQueries({queryKey:[`console.channel.list`]}),u(``),p(``)},onError:e=>{N(e instanceof Error?e.message:String(e))}});return(0,j.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,j.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,j.jsx)(`h1`,{className:`text-lg text-[var(--oke-fg)]`,children:`Channels`}),(0,j.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:I?.face===`inbox`?`Dev inbox — all media land here instead of sending`:`Deliverability — seven states of did not arrive`}),(0,j.jsxs)(`label`,{className:`mt-3 block text-sm text-[var(--oke-muted)]`,children:[`Filter templates`,(0,j.jsx)(`input`,{"aria-label":`Filter templates`,className:`mt-1 block w-full max-w-md border border-[var(--oke-line)] bg-transparent px-2 py-1 text-[var(--oke-fg)]`,value:e.q??``,onChange:t=>P({...e,q:t.target.value})})]})]}),(0,j.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,j.jsxs)(`section`,{"aria-label":`Templates`,className:`w-64 shrink-0 overflow-y-auto border-r border-[var(--oke-line)] p-3`,children:[(0,j.jsx)(`h2`,{className:`mb-2 text-xs tracking-wide text-[var(--oke-muted)]`,children:`Templates`}),F.isLoading?(0,j.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Loading…`}):(0,j.jsx)(`ul`,{className:`space-y-1`,children:L.map(t=>(0,j.jsx)(`li`,{children:(0,j.jsxs)(`button`,{type:`button`,"aria-pressed":t.name===e.template,className:m(`flex min-h-8 w-full items-center justify-between px-2 text-left text-sm`,t.name===e.template?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`),onClick:()=>P(b(e,t.name)),children:[(0,j.jsx)(`span`,{children:t.name}),(0,j.jsx)(`span`,{className:`font-mono text-xs`,children:t.medium})]})},t.name))})]}),(0,j.jsxs)(`main`,{id:`channels-main`,className:`min-w-0 flex-1 overflow-y-auto p-4`,children:[I?.face===`inbox`?(0,j.jsxs)(`section`,{"aria-label":`Inbox`,className:`mb-8`,children:[(0,j.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Inbox`}),(0,j.jsxs)(`ul`,{className:`mt-3 space-y-2`,children:[(I.inbox??[]).map(e=>(0,j.jsxs)(`li`,{className:`border-b border-[var(--oke-line)] pb-2 text-sm`,children:[(0,j.jsxs)(`div`,{className:`flex gap-2 text-[var(--oke-muted)]`,children:[(0,j.jsx)(`span`,{children:e.medium}),(0,j.jsx)(`span`,{children:e.toMasked}),e.template?(0,j.jsx)(`span`,{children:e.template}):null]}),(0,j.jsx)(`p`,{className:`mt-1 text-[var(--oke-fg)]`,children:e.subject??e.text??`(empty)`})]},e.id)),(I.inbox??[]).length===0?(0,j.jsx)(`li`,{className:`text-sm text-[var(--oke-muted)]`,children:`No messages yet`}):null]})]}):null,(0,j.jsxs)(`section`,{"aria-label":`Did not arrive`,className:`mb-8`,children:[(0,j.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Did not arrive`}),(0,j.jsxs)(`table`,{className:`mt-3 w-full text-left text-sm`,children:[(0,j.jsx)(`caption`,{className:`sr-only`,children:`Seven-state taxonomy with verdicts`}),(0,j.jsx)(`thead`,{children:(0,j.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,j.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`State`}),(0,j.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`Count`}),(0,j.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`Verdict`})]})}),(0,j.jsx)(`tbody`,{children:z.map(e=>(0,j.jsxs)(`tr`,{className:m(`border-t border-[var(--oke-line)]`,w(e)&&`text-[var(--oke-fg)]`),children:[(0,j.jsx)(`th`,{scope:`row`,className:`py-2 font-normal`,children:x[e.state]}),(0,j.jsx)(`td`,{className:`py-2`,children:e.count}),(0,j.jsx)(`td`,{className:`py-2`,children:S[e.verdict]})]},e.state))})]})]}),(0,j.jsxs)(`section`,{"aria-label":`Fallback chains`,className:`mb-8`,children:[(0,j.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Fallback`}),(0,j.jsx)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,role:`status`,children:I?E(I.fallback):`—`})]}),R?(0,j.jsxs)(`section`,{"aria-label":`Template detail`,className:`mb-8`,children:[(0,j.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:R.name}),(0,j.jsxs)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:[`From `,R.from??`unset`,` · Locales `,R.locales.join(`, `)||`none`]}),R.from?(0,j.jsxs)(`section`,{"aria-label":`Email authentication`,className:`mt-4`,children:[(0,j.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`SPF / DKIM / DMARC`}),H.data?(0,j.jsxs)(`ul`,{className:`mt-2 space-y-1 text-sm text-[var(--oke-muted)]`,children:[(0,j.jsxs)(`li`,{children:[`SPF: `,H.data.spf]}),(0,j.jsxs)(`li`,{children:[`DKIM: `,H.data.dkim]}),(0,j.jsxs)(`li`,{children:[`DMARC: `,H.data.dmarc]}),(0,j.jsx)(`li`,{className:`font-mono text-xs`,children:H.data.domain})]}):(0,j.jsx)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,children:`Checking…`})]}):null,(0,j.jsxs)(`section`,{"aria-label":`Locale preview`,className:`mt-4`,children:[(0,j.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`Preview`}),(0,j.jsxs)(`label`,{className:`mt-2 block text-sm text-[var(--oke-muted)]`,children:[`Locale`,(0,j.jsx)(`select`,{"aria-label":`Preview locale`,className:`mt-1 block border border-[var(--oke-line)] bg-transparent px-2 py-1`,value:v||R.locales[0]||`en`,onChange:e=>T(e.target.value),children:(R.locales.length>0?R.locales:[`en`]).map(e=>(0,j.jsx)(`option`,{value:e,children:e},e))})]}),V.data?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`p`,{className:`mt-2 text-xs text-[var(--oke-muted)]`,children:[`Locale chain: `,D(V.data.localeChain)]}),(0,j.jsxs)(`div`,{className:`mt-2 max-w-prose border border-[var(--oke-line)] p-3 text-sm text-[var(--oke-fg)]`,dir:V.data.dir,lang:V.data.locale,children:[V.data.subject?(0,j.jsx)(`p`,{className:`mb-2 font-medium`,children:V.data.subject}):null,(0,j.jsx)(`p`,{children:V.data.text??V.data.html})]})]}):null]}),(0,j.jsxs)(`section`,{"aria-label":`Send test`,className:`mt-6`,children:[(0,j.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`Send test`}),(0,j.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,role:`status`,children:`Real send to a designated recipient — not a dry run`}),(0,j.jsxs)(`label`,{className:`mt-3 block text-sm text-[var(--oke-muted)]`,children:[`Recipient`,(0,j.jsx)(`input`,{"aria-label":`Test recipient`,className:`mt-1 block w-full max-w-md border border-[var(--oke-line)] bg-transparent px-2 py-1 text-[var(--oke-fg)]`,value:g,onChange:e=>_(e.target.value)})]}),B.kind===`typed`?(0,j.jsxs)(j.Fragment,{children:[(0,j.jsxs)(`label`,{className:`mt-3 block text-sm text-[var(--oke-muted)]`,children:[`Type `,B.phrase,` to confirm`,(0,j.jsx)(`input`,{"aria-label":`Type ${B.phrase} to confirm`,className:`mt-1 block w-full max-w-md border border-[var(--oke-line)] bg-transparent px-2 py-1 text-[var(--oke-fg)]`,value:l,onChange:e=>u(e.target.value),autoComplete:`off`})]}),(0,j.jsxs)(`label`,{className:`mt-3 block text-sm text-[var(--oke-muted)]`,children:[`Reason`,(0,j.jsx)(`input`,{"aria-label":`Reason for send test`,className:`mt-1 block w-full max-w-md border border-[var(--oke-line)] bg-transparent px-2 py-1 text-[var(--oke-fg)]`,value:f,onChange:e=>p(e.target.value)})]})]}):null,(0,j.jsx)(`div`,{className:`mt-3`,children:(0,j.jsx)(d,{type:`button`,onClick:()=>U.mutate(),disabled:U.isPending||!g.trim(),children:`Send test`})}),M?(0,j.jsx)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,role:`status`,children:M}):null]})]}):(0,j.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a template to preview and send a test.`}),(0,j.jsxs)(`section`,{"aria-label":`Suppression list`,className:`mb-8`,children:[(0,j.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Suppression`}),(0,j.jsxs)(`ul`,{className:`mt-3 space-y-1 text-sm text-[var(--oke-muted)]`,children:[(I?.suppression??[]).map(e=>(0,j.jsxs)(`li`,{children:[e.subjectMasked,` · `,e.reason,` · `,e.medium]},`${e.subjectMasked}-${e.reason}-${e.at}`)),(I?.suppression??[]).length===0?(0,j.jsx)(`li`,{children:`Empty`}):null]})]}),(0,j.jsxs)(`section`,{"aria-label":`Recent receipts`,children:[(0,j.jsx)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:`Receipts`}),(0,j.jsxs)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:[(I?.receipts??[]).map(e=>(0,j.jsxs)(`li`,{className:`border-b border-[var(--oke-line)] pb-2 text-[var(--oke-muted)]`,children:[(0,j.jsx)(`span`,{className:`text-[var(--oke-fg)]`,children:e.template}),` → `,e.toMasked,` · `,e.status,e.chain?` · ${e.chain}`:``,e.localeChain.length>0?(0,j.jsxs)(`span`,{className:`block text-xs`,children:[`Locale: `,D(e.localeChain)]}):null]},e.id)),(I?.receipts??[]).length===0?(0,j.jsx)(`li`,{children:`No receipts yet`}):null]})]})]})]})]})}var N=t({default:()=>M});export{T as n,v as r,N as t};
@@ -1 +0,0 @@
1
- import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,Z as i,a,b as o,c as s,d as c,et as l,g as u,nt as d,o as f,r as p,tt as m,u as h,w as g,y as _}from"./panel-access-C0J2D-a2.js";var v=_({q:o().optional(),cron:o().optional(),wake:o().optional(),action:u([`run`,`edit`]).optional()});function y(e){let t=v.safeParse(e);return t.success?t.data:{}}function b(e){let t={};return e.q&&(t.q=e.q),e.cron&&(t.cron=e.cron),e.wake&&(t.wake=e.wake),e.action&&(t.action=e.action),t}function x(e,t){return{...e,cron:t,wake:void 0,action:void 0}}function S(e,t){return{...e,wake:t,cron:void 0,action:void 0}}function C(e,t){let n=t+1440*60*1e3;return e.filter(e=>e.at>=t&&e.at<n).slice().sort((e,t)=>e.at-t.at||e.name.localeCompare(t.name))}function w(e,t){let n=e-t;if(n<0)return`past`;if(n<6e4)return`in ${Math.round(n/1e3)}s`;if(n<36e5)return`in ${Math.round(n/6e4)}m`;if(n<864e5){let e=Math.floor(n/36e5),t=Math.round(n%36e5/6e4);return t>0?`in ${e}h ${t}m`:`in ${e}h`}return new Date(e).toISOString()}function ee(e,t){return e===0?`Nothing waiting`:`${e} sleeping — ${t.slice(0,4).map(e=>`${e.count} ${e.label}`).join(`, `)}`}function T(e){if(e<=0)return`due`;if(e<1e3)return`${e}ms`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<48){let e=n%60;return e>0?`${r}h ${e}m`:`${r}h`}return`${Math.floor(r/24)}d`}function E(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.label.toLowerCase().includes(n)||e.flow.toLowerCase().includes(n)||e.runId.toLowerCase().includes(n)||(e.step?.toLowerCase().includes(n)??!1)):e}function D(e){return{drift:e.driftMs==null?`drift unknown`:`drift ${k(e.driftMs)}`,overdue:e.overdue?`overdue`:`on time`,missedWithPolicy:`${e.missedRuns} missed · catch-up ${e.catchUp}`,lease:e.leaderInstanceId?`lease ${e.leaderInstanceId}`:`no lease`}}function O(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)||(e.effectiveCron?.toLowerCase().includes(n)??!1)||(e.effectiveEvery?.toLowerCase().includes(n)??!1)||e.flowIds.some(e=>e.toLowerCase().includes(n))):e}function k(e){let t=e>=0?`+`:`-`,n=Math.abs(e);return n<1e3?`${t}${n}ms`:n<6e4?`${t}${Math.round(n/1e3)}s`:`${t}${Math.round(n/6e4)}m`}function A(e){return e.filter(e=>e.health.overdue).map(e=>({name:e.name,driftMs:e.health.driftMs,missedRuns:e.health.missedRuns,...e.nextRunAt===void 0?{}:{nextRunAt:e.nextRunAt},flowIds:e.flowIds})).sort((e,t)=>t.missedRuns-e.missedRuns||e.name.localeCompare(t.name))}function j(e,t={production:!0}){return t.production&&e.external?{kind:`typed`,phrase:`RUN`,requireReason:!0}:{kind:`undo`,windowMs:p}}var M=e(d(),1),N=m();function P(){let e=g({from:`/clock`}),t=n({from:`/clock`}),o=l(),[u,d]=(0,M.useState)(``),[p,m]=(0,M.useState)(``),[_,v]=(0,M.useState)(``),[y,k]=(0,M.useState)(``),[A,P]=(0,M.useState)(null),F=e=>{t({search:b(e),replace:!0})},I=r({queryKey:[`console.clock.list`],queryFn:async()=>{let e=await c.clockList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:5e3}),L=I.data,R=L?.now??Date.now(),z=e.q??``,B=(0,M.useMemo)(()=>O(L?.crons??[],z),[L?.crons,z]),V=(0,M.useMemo)(()=>E(L?.waitingOn??[],z),[L?.waitingOn,z]),H=(0,M.useMemo)(()=>C(L?.timeline??[],R),[L?.timeline,R]),U=L?.waitingOnCounts??[],W=ee(V.length,U),G=B.find(t=>t.name===e.cron),K=V.find(t=>t.runId===e.wake),q=G?j(G,{production:!0}):null,J=G?D(G.health):null;(0,M.useEffect)(()=>{d(``),m(``),P(null),G&&(v(G.effectiveCron??``),k(G.effectiveEvery??``))},[G?.name,e.action,K?.runId]);let Y=()=>o.invalidateQueries({queryKey:[`console.clock.list`]}),X=i({mutationFn:async()=>{if(!G||!q)throw Error(`no cron`);if(q.kind===`typed`){let e=a({typed:u,reason:p,phrase:q.phrase});if(e)throw Error(e.typed??e.reason??`confirm`)}let e=await c.clockRunNow({name:G.name,confirmation:q.kind===`typed`?u:void 0,reason:q.kind===`typed`?p:void 0});if(e.error)throw Error(e.error.code);return e.data},onSuccess:async e=>{P(e?.ran?`Ran now`:`Did not acquire lease`),d(``),m(``),await Y()},onError:e=>{P(e instanceof Error?e.message:`Run failed`)}}),Z=i({mutationFn:async()=>{if(!G)throw Error(`no cron`);let e=await c.clockPause({name:G.name});if(e.error)throw Error(e.error.code);return e.data},onSuccess:async()=>{P(`Paused`),await Y()}}),Q=i({mutationFn:async()=>{if(!G?.overridable)throw Error(`not overridable`);let e=await c.clockEditSchedule({name:G.name,cron:_||void 0,every:y||void 0});if(e.error)throw Error(e.error.code);return e.data},onSuccess:async()=>{P(`Schedule updated`),F({...e,action:void 0}),await Y()},onError:e=>{P(e instanceof Error?e.message:`Edit failed`)}}),$=i({mutationFn:async()=>{if(!K)throw Error(`no wake`);let e=await c.clockWakeEarly({runId:K.runId});if(e.error)throw Error(e.error.code);return e.data},onSuccess:async()=>{P(`Woke early`),F({...e,wake:void 0}),await Y()}});return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,N.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,N.jsx)(`h1`,{className:`text-lg font-medium`,children:`Clock`}),(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Forward timeline, waiting-on, cron health`}),(0,N.jsxs)(`label`,{className:`mt-2 block max-w-sm text-sm`,children:[(0,N.jsx)(`span`,{className:`sr-only`,children:`Filter clock`}),(0,N.jsx)(s,{"aria-label":`Filter clock`,placeholder:`Filter…`,value:z,onChange:t=>F({...e,q:t.currentTarget.value||void 0})})]})]}),(0,N.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-0 overflow-hidden lg:grid-cols-[1fr_1fr_1.2fr]`,children:[(0,N.jsxs)(`section`,{"aria-label":`Forward timeline`,className:`min-h-0 overflow-y-auto border-b border-[var(--oke-line)] p-4 lg:border-b-0 lg:border-r`,children:[(0,N.jsx)(`h2`,{className:`mb-2 text-sm font-medium`,children:`Next 24 hours`}),I.isLoading?(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Loading…`}):H.length===0?(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Nothing in the next 24h`}):(0,N.jsx)(`ol`,{className:`space-y-1`,children:H.map(e=>(0,N.jsxs)(`li`,{className:`flex min-h-8 items-baseline gap-2 text-sm`,children:[(0,N.jsx)(`span`,{className:`w-24 shrink-0 text-[var(--oke-muted)]`,children:w(e.at,R)}),(0,N.jsxs)(`span`,{children:[e.kind===`cron`?`cron`:`wake`,` · `,e.name]})]},`${e.kind}-${e.name}-${e.at}`))})]}),(0,N.jsxs)(`section`,{"aria-label":`Waiting on`,className:`min-h-0 overflow-y-auto border-b border-[var(--oke-line)] p-4 lg:border-b-0 lg:border-r`,children:[(0,N.jsx)(`h2`,{className:`mb-1 text-sm font-medium`,children:`Waiting on`}),(0,N.jsx)(`p`,{className:`mb-2 text-sm text-[var(--oke-muted)]`,role:`status`,children:W}),(0,N.jsx)(`ul`,{className:`space-y-1`,children:V.map(t=>{let n=U.find(e=>e.label===(t.label||`(unlabelled)`))?.count??1;return(0,N.jsx)(`li`,{children:(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":t.runId===e.wake,className:h(`flex min-h-8 w-full flex-col items-start px-2 py-1 text-left text-sm`,t.runId===e.wake?`bg-[var(--oke-line)]`:`hover:bg-[var(--oke-line)]/40`),onClick:()=>F(S(e,t.runId)),children:[(0,N.jsx)(`span`,{children:t.label||t.flow}),(0,N.jsxs)(`span`,{className:`text-[var(--oke-muted)]`,children:[`wake-in `,T(t.wakeInMs),t.step?` · step ${t.step}`:``,` · ${n} run${n===1?``:`s`}`]})]})},t.runId)})})]}),(0,N.jsxs)(`section`,{"aria-label":`Cron schedules`,className:`min-h-0 overflow-y-auto p-4`,children:[(0,N.jsx)(`h2`,{className:`mb-2 text-sm font-medium`,children:`Schedules`}),(0,N.jsx)(`ul`,{className:`mb-4 space-y-1`,children:B.map(t=>{let n=D(t.health);return(0,N.jsx)(`li`,{children:(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":t.name===e.cron,className:h(`flex min-h-8 w-full flex-col items-start px-2 py-1 text-left text-sm`,t.name===e.cron?`bg-[var(--oke-line)]`:`hover:bg-[var(--oke-line)]/40`),onClick:()=>F(x(e,t.name)),children:[(0,N.jsxs)(`span`,{className:`flex items-center gap-1`,children:[t.name,t.external?(0,N.jsx)(`span`,{"aria-label":`external effect`,children:`↗`}):null,t.health.overdue?(0,N.jsx)(`span`,{role:`status`,className:`text-[var(--oke-danger)]`,children:`overdue`}):null,t.dstAmbiguity?(0,N.jsxs)(`span`,{role:`status`,children:[`DST `,t.dstAmbiguity.kind]}):null]}),(0,N.jsxs)(`span`,{className:`text-[var(--oke-muted)]`,children:[n.drift,` · `,n.missedWithPolicy,` · `,n.lease]})]})},t.name)})}),G&&J?(0,N.jsxs)(`section`,{"aria-label":`Cron detail`,"aria-live":`polite`,className:`space-y-3 border-t border-[var(--oke-line)] pt-3`,children:[(0,N.jsx)(`h3`,{className:`text-base font-medium`,children:G.name}),(0,N.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[G.effectiveCron??G.effectiveEvery,` · `,G.timezone,G.status===`active`?``:` · ${G.status}`]}),(0,N.jsxs)(`dl`,{className:`grid grid-cols-2 gap-2 text-sm`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Drift`}),(0,N.jsx)(`dd`,{children:J.drift})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Overdue`}),(0,N.jsx)(`dd`,{children:J.overdue})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Missed + catch-up`}),(0,N.jsx)(`dd`,{children:J.missedWithPolicy})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Lease`}),(0,N.jsx)(`dd`,{children:J.lease})]})]}),G.dstAmbiguity?(0,N.jsx)(`p`,{role:`alert`,className:`text-sm`,children:G.dstAmbiguity.reason}):null,(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,N.jsx)(f,{type:`button`,variant:G.external?`external`:`primary`,disabled:X.isPending,onClick:()=>{if(q?.kind===`typed`&&e.action!==`run`){F({...e,action:`run`});return}X.mutate()},children:`Run now`}),(0,N.jsx)(f,{type:`button`,variant:`ghost`,disabled:Z.isPending||G.status===`paused`,onClick:()=>Z.mutate(),children:`Pause`}),G.overridable?(0,N.jsx)(f,{type:`button`,variant:`ghost`,onClick:()=>F({...e,action:e.action===`edit`?void 0:`edit`}),children:`Edit schedule`}):null]}),e.action===`run`&&q?.kind===`typed`?(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`p`,{className:`text-sm`,children:[`This cron has an external effect. Type `,(0,N.jsx)(`strong`,{children:`RUN`}),` and a reason.`]}),(0,N.jsxs)(`label`,{className:`block text-sm`,children:[`Type RUN to confirm`,(0,N.jsx)(s,{"aria-label":`Type RUN to confirm`,value:u,onChange:e=>d(e.currentTarget.value)})]}),(0,N.jsxs)(`label`,{className:`block text-sm`,children:[`Reason`,(0,N.jsx)(s,{"aria-label":`Reason`,value:p,onChange:e=>m(e.currentTarget.value)})]}),(0,N.jsx)(f,{type:`button`,variant:`external`,disabled:X.isPending,onClick:()=>X.mutate(),children:`Confirm run now`})]}):null,e.action===`edit`&&G.overridable?(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsxs)(`label`,{className:`block text-sm`,children:[`Cron expression`,(0,N.jsx)(s,{"aria-label":`Cron expression`,value:_,onChange:e=>v(e.currentTarget.value)})]}),(0,N.jsxs)(`label`,{className:`block text-sm`,children:[`Every interval`,(0,N.jsx)(s,{"aria-label":`Every interval`,value:y,onChange:e=>k(e.currentTarget.value)})]}),(0,N.jsx)(f,{type:`button`,disabled:Q.isPending,onClick:()=>Q.mutate(),children:`Save schedule`})]}):null]}):null,K?(0,N.jsxs)(`section`,{"aria-label":`Wake detail`,"aria-live":`polite`,className:`mt-4 space-y-2 border-t border-[var(--oke-line)] pt-3`,children:[(0,N.jsx)(`h3`,{className:`text-base font-medium`,children:K.label||K.flow}),(0,N.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[K.flow,` · wake in `,T(K.wakeInMs),K.step?` · step ${K.step}`:``]}),(0,N.jsx)(f,{type:`button`,disabled:$.isPending,onClick:()=>$.mutate(),children:`Wake early`})]}):null,A?(0,N.jsx)(`p`,{className:`mt-3 text-sm`,role:`status`,children:A}):null]})]})]})}var F=t({default:()=>P});export{A as n,y as r,F as t};
@@ -1 +0,0 @@
1
- import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,Z as i,b as a,c as o,d as s,g as c,nt as l,o as u,tt as d,u as f,w as p,y as m}from"./panel-access-C0J2D-a2.js";var h=m({q:a().optional(),from:c([`principal`,`flow`]).optional(),principal:a().optional(),flow:a().optional(),as:a().optional()});function g(e){let t=h.safeParse(e);return t.success?t.data:{}}function _(e){let t={};return e.q&&(t.q=e.q),e.from&&(t.from=e.from),e.principal&&(t.principal=e.principal),e.flow&&(t.flow=e.flow),e.as&&(t.as=e.as),t}function v(e,t){return`${e}:${t}`}function y(e){if(!e)return null;let t=e.indexOf(`:`);if(t===-1)return null;let n=e.slice(0,t),r=e.slice(t+1);return n!==`role`&&n!==`key`&&n!==`user`||!r?null:{kind:n,id:r}}function b(e,t,n){return{...e,from:`principal`,principal:v(t,n),flow:void 0}}function x(e,t){return{...e,from:`flow`,flow:t,principal:void 0}}function S(e,t=``){let n=t.trim().toLowerCase(),r=n?e.filter(e=>e.name.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)||(e.email?.toLowerCase().includes(n)??!1)||e.scopes.some(e=>e.toLowerCase().includes(n))):e,i=[`role`,`key`,`user`],a={role:`Roles`,key:`API keys`,user:`Users`};return i.map(e=>({id:e,label:a[e],items:r.filter(t=>t.kind===e).map(t=>({id:`${t.kind}:${t.id}`,label:t.name,meta:e===`role`?`${t.scopes.length} scopes · ${t.memberCount??0} members`:`${t.scopes.length} scopes`,flag:t.plane===`operator`?`operator`:void 0}))})).filter(e=>e.items.length>0)}function C(e,t=``){let n=t.trim().toLowerCase(),r=n?e.filter(e=>e.flowId.toLowerCase().includes(n)||e.gates.some(e=>e.toLowerCase().includes(n))):e,i=[`user`,`operator`],a={user:`User plane`,operator:`Operator plane`};return i.map(e=>({id:e,label:a[e],items:r.filter(t=>t.plane===e).map(e=>({id:e.flowId,label:e.flowId,meta:e.gates.length===0?`ungated`:e.gates.join(` → `),flag:e.unguarded?`unguarded`:void 0}))})).filter(e=>e.items.length>0)}function w(e){let t=[];return e.unguardedFlows.length>0&&t.push({code:`unguarded`,count:e.unguardedFlows.length,message:`${e.unguardedFlows.length} user-plane flow${e.unguardedFlows.length===1?``:`s`} unguarded (public)`}),e.orphanPermissions.length>0&&t.push({code:`orphan-permissions`,count:e.orphanPermissions.length,message:`${e.orphanPermissions.length} permission${e.orphanPermissions.length===1?``:`s`} granted to no role`}),e.emptyRoles.length>0&&t.push({code:`empty-roles`,count:e.emptyRoles.length,message:`${e.emptyRoles.length} role${e.emptyRoles.length===1?``:`s`} with no members`}),e.unattachedGates.length>0&&t.push({code:`unattached`,count:e.unattachedGates.length,message:`${e.unattachedGates.length} gate${e.unattachedGates.length===1?``:`s`} never attached`}),t}function T(e){let t=e.applicationScopes.join(`, `);return`${e.email?`${e.name} <${e.email}>`:e.name} holds application scope(s): ${t}`}function E(e){return w(e).filter(e=>e.code===`unguarded`)}function D(e){switch(e.code){case`RateLimited`:return`RateLimited { retryAfterMs: ${typeof e.data.retryAfterMs==`number`?e.data.retryAfterMs:0} } · HTTP ${e.status}`;case`Forbidden`:{let t=typeof e.data.gate==`string`?e.data.gate:`?`,n=typeof e.data.reason==`string`?e.data.reason:``;return`Forbidden { gate: ${t}${n?`, reason: ${n}`:``} } · HTTP ${e.status}`}case`Unauthorized`:return`Unauthorized {} · HTTP ${e.status}`}}function O(e,t){let n=e.allowed?`pass`:`deny`,r=e.kind===`rate`&&e.retryAfterMs!==void 0?` · retryAfterMs ${e.retryAfterMs}`:e.reason?` · ${e.reason}`:``;return`${t+1}. ${e.name} — ${n}${r}`}var k=e(l(),1),A=d();function j(){let e=p({from:`/gates`}),t=n({from:`/gates`}),a=e.from??`flow`,[c,l]=(0,k.useState)(e.as??``),[d,m]=(0,k.useState)(null),[h,g]=(0,k.useState)(null),v=e=>{t({search:_(e),replace:!0})},E=r({queryKey:[`console.gates.list`],queryFn:async()=>{let e=await s.gatesList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}),j=E.data,M=j?.principals??[],N=j?.flows??[],P=j?.violations??[],F=j?.widenings??[],I=j?.audit??{unguardedFlows:[],orphanPermissions:[],emptyRoles:[],unattachedGates:[]},L=(0,k.useMemo)(()=>w(I),[I]),R=(0,k.useMemo)(()=>a===`principal`?S(M,e.q??``):C(N,e.q??``),[a,M,N,e.q]),z=y(e.principal),B=z?M.find(e=>e.kind===z.kind&&e.id===z.id):void 0,V=N.find(t=>t.flowId===e.flow),H=i({mutationFn:async()=>{if(a===`flow`){if(!V)throw Error(`Select a flow`);let t=y(c||e.as);if(!t)throw Error(`Pick a principal to simulate as`);let n=await s.gatesSimulate({flowId:V.flowId,principal:t});if(n.error)throw Error(n.error.code);return n.data}if(!z)throw Error(`Select a principal`);let t=c||e.as;if(!t)throw Error(`Pick a flow to simulate`);let n=await s.gatesSimulate({flowId:t,principal:z});if(n.error)throw Error(n.error.code);return n.data},onSuccess:e=>{m(e)}}),U=i({mutationFn:async()=>{if(!z)throw Error(`Select a principal`);let e=await s.gatesPowers(z);if(e.error)throw Error(e.error.code);return e.data},onSuccess:e=>{g(e)}});return(0,A.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,A.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-3 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h1`,{className:`text-lg font-medium text-[var(--oke-fg)]`,children:`Gates`}),(0,A.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`What can this principal do · what guards this flow`})]}),(0,A.jsxs)(`div`,{role:`group`,"aria-label":`Inquiry direction`,className:`flex gap-1`,children:[(0,A.jsx)(u,{type:`button`,variant:a===`principal`?`primary`:`ghost`,"aria-pressed":a===`principal`,onClick:()=>v({...e,from:`principal`,flow:void 0}),children:`From principal`}),(0,A.jsx)(u,{type:`button`,variant:a===`flow`?`primary`:`ghost`,"aria-pressed":a===`flow`,onClick:()=>v({...e,from:`flow`,principal:void 0}),children:`From flow`})]}),(0,A.jsxs)(`label`,{className:`ml-auto flex min-w-[12rem] flex-col gap-1 text-sm`,children:[(0,A.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter gates`}),(0,A.jsx)(o,{"aria-label":`Filter gates`,value:e.q??``,onChange:t=>v({...e,q:t.currentTarget.value||void 0})})]})]}),L.length>0?(0,A.jsxs)(`section`,{"aria-label":`Continuous security audit`,className:`border-b border-[var(--oke-line)] px-4 py-2`,role:`status`,children:[(0,A.jsx)(`h2`,{className:`sr-only`,children:`Standing audit`}),(0,A.jsx)(`ul`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-sm text-[var(--oke-danger)]`,children:L.map(e=>(0,A.jsx)(`li`,{children:e.message},e.code))})]}):null,P.length>0?(0,A.jsxs)(`section`,{"aria-label":`Plane violations`,className:`border-b border-[var(--oke-line)] bg-[var(--oke-danger)]/10 px-4 py-2`,role:`alert`,children:[(0,A.jsx)(`h2`,{className:`text-sm font-medium text-[var(--oke-danger)]`,children:`Two-plane violations`}),(0,A.jsx)(`ul`,{className:`mt-1 text-sm text-[var(--oke-fg)]`,children:P.map(e=>(0,A.jsx)(`li`,{children:T(e)},e.operatorId))})]}):null,(0,A.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,A.jsxs)(`section`,{"aria-label":a===`principal`?`Principal list`:`Flow list`,className:`w-80 shrink-0 overflow-y-auto border-r border-[var(--oke-line)]`,children:[(0,A.jsx)(`h2`,{className:`sr-only`,children:a===`principal`?`Principals`:`Flows`}),E.isLoading?(0,A.jsx)(`p`,{className:`p-4 text-sm text-[var(--oke-muted)]`,children:`Loading…`}):null,R.map(t=>(0,A.jsxs)(`section`,{"aria-label":t.label,className:`py-2`,children:[(0,A.jsx)(`h3`,{className:`px-4 py-1 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:t.label}),(0,A.jsx)(`ul`,{children:t.items.map(t=>{let n=a===`flow`?t.id===e.flow:t.id===e.principal;return(0,A.jsx)(`li`,{children:(0,A.jsxs)(`button`,{type:`button`,"aria-pressed":n,className:f(`flex min-h-10 w-full flex-col items-start px-4 py-2 text-left text-sm`,n?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)] hover:text-[var(--oke-fg)]`),onClick:()=>{if(m(null),g(null),a===`flow`)v(x(e,t.id));else{let n=y(t.id);if(!n)return;v(b(e,n.kind,n.id))}},children:[(0,A.jsx)(`span`,{className:`font-mono`,children:t.label}),t.meta?(0,A.jsx)(`span`,{className:`truncate text-xs`,children:t.meta}):null,t.flag?(0,A.jsx)(`span`,{role:`status`,className:`text-xs text-[var(--oke-danger)]`,children:t.flag}):null]})},t.id)})})]},t.id))]}),(0,A.jsx)(`section`,{"aria-label":`Gates detail`,"aria-live":`polite`,className:`min-w-0 flex-1 overflow-y-auto p-4`,children:!V&&!B?(0,A.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Choose a principal or a flow. The matrix is not the entry point.`}):(0,A.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-6`,children:[a===`flow`&&V?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`font-mono text-lg text-[var(--oke-fg)]`,children:V.flowId}),(0,A.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`What guards this — registration order`}),V.gates.length===0?(0,A.jsx)(`p`,{className:`mt-2 text-sm`,role:`status`,children:V.unguarded?`Unguarded — public on the user plane`:`No gates`}):(0,A.jsx)(`ol`,{"aria-label":`Gate chain`,className:`mt-3 list-decimal space-y-1 pl-5 text-sm`,children:V.gates.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsx)(`code`,{className:`font-mono`,children:e})},e))})]}):null,a===`principal`&&B?(0,A.jsxs)(`div`,{children:[(0,A.jsx)(`h2`,{className:`font-mono text-lg text-[var(--oke-fg)]`,children:B.name}),(0,A.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[B.kind,` · `,B.plane,` plane`,B.email?` · ${B.email}`:``]}),(0,A.jsx)(`h3`,{className:`mt-4 text-sm font-medium`,children:`Scopes`}),(0,A.jsx)(`ul`,{"aria-label":`Scopes`,className:`mt-1 flex flex-wrap gap-2 text-sm`,children:B.scopes.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsx)(`code`,{className:`font-mono`,children:e})},e))}),(0,A.jsx)(u,{type:`button`,variant:`ghost`,className:`mt-3`,onClick:()=>U.mutate(),children:`What can this do`}),h?(0,A.jsxs)(`div`,{className:`mt-3 text-sm`,children:[(0,A.jsxs)(`p`,{role:`status`,children:[h.allowedFlowIds.length,` flows allowed · `,h.deniedFlowIds.length,` `,`denied`]}),(0,A.jsx)(`ul`,{"aria-label":`Allowed flows`,className:`mt-2 list-disc pl-5`,children:h.allowedFlowIds.map(e=>(0,A.jsx)(`li`,{children:(0,A.jsx)(`code`,{className:`font-mono`,children:e})},e))})]}):null]}):null,(0,A.jsxs)(`section`,{"aria-label":`Simulator`,className:`border-t border-[var(--oke-line)] pt-4`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-medium text-[var(--oke-fg)]`,children:`Simulator`}),(0,A.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Evaluates the real gate chain only — never runs the handler`}),(0,A.jsxs)(`label`,{className:`mt-3 flex max-w-md flex-col gap-1 text-sm`,children:[(0,A.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:a===`flow`?`Simulate as principal`:`Simulate against flow`}),(0,A.jsxs)(`select`,{"aria-label":`Companion selection`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2 text-sm text-[var(--oke-fg)]`,value:c,onChange:t=>{let n=t.currentTarget.value;l(n),v({...e,as:n||void 0})},children:[(0,A.jsx)(`option`,{value:``,children:`Select…`}),a===`flow`?M.map(e=>(0,A.jsxs)(`option`,{value:`${e.kind}:${e.id}`,children:[e.kind,`: `,e.name]},`${e.kind}:${e.id}`)):N.filter(e=>e.plane===`user`).map(e=>(0,A.jsx)(`option`,{value:e.flowId,children:e.flowId},e.flowId))]})]}),(0,A.jsx)(u,{type:`button`,className:`mt-3`,onClick:()=>H.mutate(),disabled:H.isPending,children:`Simulate`}),H.isError?(0,A.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-[var(--oke-danger)]`,children:H.error instanceof Error?H.error.message:`Simulate failed`}):null,d?(0,A.jsxs)(`div`,{className:`mt-4`,children:[(0,A.jsx)(`ol`,{"aria-label":`Evaluation order`,className:`list-decimal space-y-1 pl-5 text-sm`,children:d.evaluations.map((e,t)=>(0,A.jsx)(`li`,{children:O(e,t)},`${e.name}-${t}`))}),(0,A.jsx)(`p`,{role:`status`,className:`mt-3 text-sm`,"data-denial":d.denial?.code??`allowed`,children:d.denial?D(d.denial):`Allowed — chain passed`})]}):null]}),F.length>0?(0,A.jsxs)(`section`,{"aria-label":`Permission widenings`,children:[(0,A.jsx)(`h3`,{className:`text-sm font-medium text-[var(--oke-danger)]`,children:`Deploy widenings`}),(0,A.jsx)(`ul`,{className:`mt-2 list-disc pl-5 text-sm`,children:F.map(e=>(0,A.jsx)(`li`,{children:e.summary},`${e.path}:${e.summary}`))})]}):null]})})]})]})}var M=t({default:()=>j});export{E as n,g as r,M as t};
@@ -1 +0,0 @@
1
- import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,c as i,d as a,nt as o,o as s,tt as c,u as l,w as u}from"./panel-access-C0J2D-a2.js";function d(e){return{q:typeof e.q==`string`&&e.q.length>0?e.q:void 0,origin:m(e.origin)?e.origin:void 0,state:e.state===`on`||e.state===`off`?e.state:void 0,plugin:typeof e.plugin==`string`&&e.plugin.length>0?e.plugin:void 0}}function f(e){let t={};return e.q&&(t.q=e.q),e.origin&&(t.origin=e.origin),e.state&&(t.state=e.state),e.plugin&&(t.plugin=e.plugin),t}function p(e,t){return{...e,plugin:t}}function m(e){return e===`core`||e===`local`||e===`community`}function h(e){return e.installCommand?e.installCommand:e.enableHint?e.enableHint:null}function g(e){return e.installCommand?`Copy bun add command`:e.enableHint?`Copy enable hint`:`No command`}var _={core:`Core`,local:`Local`,community:`Community`};function v(e,t){let n=(t.q??``).trim().toLowerCase(),r=e.filter(e=>t.origin&&e.origin!==t.origin||t.state&&e.state!==t.state?!1:!n||e.id.toLowerCase().includes(n)||(e.summary?.toLowerCase().includes(n)??!1)||(e.packageName?.toLowerCase().includes(n)??!1)||e.declares.some(e=>e.toLowerCase().includes(n))||e.intercepts.some(e=>e.stage.toLowerCase().includes(n))),i=[`core`,`local`,`community`],a=[];for(let e of i){let t=r.filter(t=>t.origin===e).sort((e,t)=>y(e.state,t.state,e.id,t.id));t.length!==0&&a.push({id:e,label:_[e],items:t})}return a}function y(e,t,n,r){return e===t?n.localeCompare(r):e===`on`?-1:1}var b=e(o(),1),x=c();function S(){let e=u({from:`/plugins`}),t=n({from:`/plugins`}),[o,s]=(0,b.useState)(null),c=e=>{t({search:f(e),replace:!0})},d=r({queryKey:[`console.plugin.list`],queryFn:async()=>{let e=await a.pluginsList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:15e3}),m=d.data,g=(0,b.useMemo)(()=>v(m?.plugins??[],e),[m?.plugins,e]),_=m?.plugins.find(t=>t.id===e.plugin)??m?.plugins[0]??null,y=_?h(_):null,S=async()=>{y&&(await navigator.clipboard.writeText(y),s(y),window.setTimeout(()=>s(null),2e3))};return(0,x.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,x.jsxs)(`header`,{className:`shrink-0 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,x.jsx)(`h1`,{className:`text-lg text-[var(--oke-fg)]`,children:`Plugins`}),(0,x.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:`Origin × state — CORE stays listed when off; local/community only when plugged. Read-only; git review is the approval.`}),(0,x.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-3`,children:[(0,x.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-[var(--oke-muted)]`,children:[`Filter`,(0,x.jsx)(i,{"aria-label":`Filter plugins`,value:e.q??``,onChange:t=>c({...e,q:t.target.value||void 0}),className:`min-h-8 w-56`})]}),(0,x.jsx)(T,{value:e.origin,onChange:t=>c({...e,origin:t})}),(0,x.jsx)(E,{value:e.state,onChange:t=>c({...e,state:t})})]})]}),(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,x.jsx)(`section`,{"aria-label":`Plugins by origin`,className:`w-80 shrink-0 overflow-y-auto border-r border-[var(--oke-line)]`,children:d.isLoading?(0,x.jsx)(`p`,{className:`p-4 text-sm text-[var(--oke-muted)]`,children:`Loading…`}):g.length===0?(0,x.jsx)(`p`,{className:`p-4 text-sm text-[var(--oke-muted)]`,children:`No plugins`}):g.map(t=>(0,x.jsxs)(`div`,{className:`border-b border-[var(--oke-line)]`,children:[(0,x.jsx)(`h2`,{className:`px-3 py-2 text-xs tracking-wide text-[var(--oke-muted)] uppercase`,children:t.label}),(0,x.jsx)(`ul`,{children:t.items.map(t=>(0,x.jsx)(`li`,{children:(0,x.jsxs)(`button`,{type:`button`,"aria-pressed":_?.id===t.id,className:l(`flex min-h-8 w-full items-center gap-2 px-3 py-2 text-left text-sm`,_?.id===t.id?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)] hover:text-[var(--oke-fg)]`),onClick:()=>c(p(e,t.id)),children:[(0,x.jsx)(`span`,{className:`font-mono`,children:t.id}),(0,x.jsx)(`span`,{className:`ml-auto text-xs`,children:t.state})]})},t.id))})]},t.id))}),(0,x.jsx)(`section`,{"aria-label":`Plugin detail`,"aria-live":`polite`,className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:_?(0,x.jsx)(C,{plugin:_,command:y,copied:o,onCopy:()=>void S()}):(0,x.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a plugin`})})]})]})}function C(e){let{plugin:t,command:n,copied:r,onCopy:i}=e;return(0,x.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h2`,{className:`text-base text-[var(--oke-fg)]`,children:[(0,x.jsx)(`span`,{className:`font-mono`,children:t.id}),` `,(0,x.jsxs)(`span`,{className:`text-sm text-[var(--oke-muted)]`,children:[`(`,t.origin,` · `,t.state,`)`]})]}),t.summary?(0,x.jsx)(`p`,{className:`mt-1 text-sm text-[var(--oke-muted)]`,children:t.summary}):null,t.version?(0,x.jsxs)(`p`,{className:`mt-1 text-xs text-[var(--oke-muted)]`,children:[`Version `,t.version]}):null]}),(0,x.jsxs)(`section`,{"aria-label":`Declares`,children:[(0,x.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`Declares`}),(0,x.jsx)(`p`,{className:`text-xs text-[var(--oke-muted)]`,children:`Boot-time — schema, elements, drivers, panels, CLI`}),t.declares.length===0?(0,x.jsx)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,children:`None`}):(0,x.jsx)(`ul`,{className:`mt-2 list-inside list-disc font-mono text-sm`,children:t.declares.map(e=>(0,x.jsx)(`li`,{children:e},e))})]}),(0,x.jsxs)(`section`,{"aria-label":`Intercepts`,children:[(0,x.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`Intercepts`}),(0,x.jsx)(`p`,{className:`text-xs text-[var(--oke-muted)]`,children:`Per-request hooks — measured in the kernel pipeline`}),t.intercepts.length===0?(0,x.jsx)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,children:`None`}):(0,x.jsxs)(`table`,{className:`mt-2 w-full text-left text-sm`,children:[(0,x.jsx)(`caption`,{className:`sr-only`,children:`Hook stages and measured mean cost`}),(0,x.jsx)(`thead`,{children:(0,x.jsxs)(`tr`,{className:`text-xs text-[var(--oke-muted)]`,children:[(0,x.jsx)(`th`,{scope:`col`,className:`py-1 pr-3 font-normal`,children:`Stage`}),(0,x.jsx)(`th`,{scope:`col`,className:`py-1 pr-3 font-normal`,children:`Mean ms`}),(0,x.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`Samples`})]})}),(0,x.jsx)(`tbody`,{children:t.intercepts.map(e=>(0,x.jsxs)(`tr`,{className:`border-t border-[var(--oke-line)]`,children:[(0,x.jsx)(`th`,{scope:`row`,className:`py-1 pr-3 font-mono font-normal`,children:e.stage}),(0,x.jsx)(`td`,{className:`py-1 pr-3`,children:e.meanMs===null?`—`:e.meanMs.toFixed(2)}),(0,x.jsx)(`td`,{className:`py-1`,children:e.count})]},e.stage))})]}),t.hookCost?(0,x.jsxs)(`p`,{className:`mt-2 text-xs text-[var(--oke-muted)]`,role:`status`,children:[`p50 `,t.hookCost.p50Ms.toFixed(2),` ms · p95 `,t.hookCost.p95Ms.toFixed(2),` ms · n=`,t.hookCost.count]}):null]}),(0,x.jsxs)(`section`,{"aria-label":`Supply chain`,children:[(0,x.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`Supply chain`}),(0,x.jsxs)(`ul`,{className:`mt-2 space-y-1 text-sm`,children:[(0,x.jsx)(w,{label:`Lifecycle scripts`,state:t.supplyChain.lifecycleScripts.state,detail:t.supplyChain.lifecycleScripts.detail}),(0,x.jsx)(w,{label:`Release cooldown`,state:t.supplyChain.releaseCooldown.state,detail:t.supplyChain.releaseCooldown.detail}),(0,x.jsx)(w,{label:`node: scan`,state:t.supplyChain.nodeImportScan.state,detail:t.supplyChain.nodeImportScan.detail}),(0,x.jsx)(w,{label:`npm provenance`,state:t.supplyChain.npmProvenance.state,detail:t.supplyChain.npmProvenance.detail}),(0,x.jsx)(w,{label:`Boot conflicts`,state:t.supplyChain.bootConflicts.state,detail:t.supplyChain.bootConflicts.detail})]})]}),(0,x.jsxs)(`section`,{"aria-label":`Capability diff`,children:[(0,x.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`Capability diff`}),(0,x.jsx)(`p`,{className:`text-xs text-[var(--oke-muted)]`,children:`Git merge-base via diffManifest (oke doctor --diff) — not recomputed`}),t.capabilityDiff.length===0?(0,x.jsx)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,children:`No pending capability changes for this plugin`}):(0,x.jsx)(`ul`,{className:`mt-2 space-y-1 text-sm`,children:t.capabilityDiff.map(e=>(0,x.jsxs)(`li`,{children:[(0,x.jsx)(`a`,{className:`text-[var(--oke-fg)] underline`,href:`/manifest-diff?path=${encodeURIComponent(e.path)}`,children:e.summary}),(0,x.jsx)(`span`,{className:`ml-2 text-xs text-[var(--oke-muted)]`,children:e.category})]},e.path))})]}),(0,x.jsxs)(`section`,{"aria-label":`Install command`,children:[(0,x.jsx)(`h3`,{className:`text-sm text-[var(--oke-fg)]`,children:`Command`}),n?(0,x.jsxs)(`div`,{className:`mt-2 flex flex-col gap-2`,children:[(0,x.jsx)(`pre`,{className:`overflow-x-auto rounded border border-[var(--oke-line)] bg-[var(--oke-bg)] p-3 font-mono text-sm`,children:(0,x.jsx)(`code`,{children:n})}),(0,x.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,x.jsx)(s,{type:`button`,onClick:i,className:`min-h-8`,children:g(t)}),r?(0,x.jsx)(`span`,{className:`text-xs text-[var(--oke-muted)]`,role:`status`,children:`Copied`}):null]}),(0,x.jsx)(`p`,{className:`text-xs text-[var(--oke-muted)]`,children:`The Console never installs. Git review is the approval — run this yourself.`})]}):(0,x.jsx)(`p`,{className:`mt-2 text-sm text-[var(--oke-muted)]`,children:`No install command — turn off by removing the code line, not from this UI.`})]})]})}function w(e){return(0,x.jsxs)(`li`,{children:[(0,x.jsxs)(`span`,{className:`text-[var(--oke-muted)]`,children:[e.label,`:`]}),` `,(0,x.jsx)(`span`,{className:`font-mono text-xs`,children:e.state}),(0,x.jsxs)(`span`,{className:`text-[var(--oke-muted)]`,children:[` — `,e.detail]})]})}function T(e){return(0,x.jsxs)(`fieldset`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,x.jsx)(`legend`,{className:`sr-only`,children:`Origin`}),[[void 0,`All origins`],[`core`,`Core`],[`local`,`Local`],[`community`,`Community`]].map(([t,n])=>(0,x.jsxs)(`label`,{className:`inline-flex min-h-8 items-center gap-1`,children:[(0,x.jsx)(`input`,{type:`radio`,name:`plugins-origin`,checked:e.value===t,onChange:()=>e.onChange(t)}),n]},n))]})}function E(e){return(0,x.jsxs)(`fieldset`,{className:`flex flex-wrap items-center gap-2 text-xs`,children:[(0,x.jsx)(`legend`,{className:`sr-only`,children:`State`}),[[void 0,`All states`],[`on`,`On`],[`off`,`Off`]].map(([t,n])=>(0,x.jsxs)(`label`,{className:`inline-flex min-h-8 items-center gap-1`,children:[(0,x.jsx)(`input`,{type:`radio`,name:`plugins-state`,checked:e.value===t,onChange:()=>e.onChange(t)}),n]},n))]})}var D=t({default:()=>S});export{d as n,D as t};
@@ -1 +0,0 @@
1
- import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,Z as i,_ as a,a as o,b as s,d as c,et as ee,nt as l,o as u,r as d,tt as f,u as te,v as p,w as ne,x as m,y as h}from"./panel-access-C0J2D-a2.js";import{r as g}from"./panel-runs-CGWNHLR4.js";import{i as _}from"./panel-ai-D_m6WQI8.js";var v=h({q:s().optional(),signal:s().optional(),dlq:s().optional(),paused:m([a(),p(`true`),p(`false`)]).optional().transform(e=>e===void 0?void 0:e===!0||e===`true`),rate:_().min(1).max(1e3).optional(),sub:s().optional()});function y(e){let t=v.safeParse(e);return t.success?t.data:{}}function b(e){let t={};return e.q&&(t.q=e.q),e.signal&&(t.signal=e.signal),e.dlq&&(t.dlq=e.dlq),e.paused===!0&&(t.paused=!0),e.rate!==void 0&&e.rate!==10&&(t.rate=e.rate),e.sub&&(t.sub=e.sub),t}function x(e,t){return{...e,signal:t,dlq:void 0}}function re(e){let{signal:t,dlq:n,...r}=e;return r}function ie(e,t){return{...e,dlq:t}}function S(e){let{dlq:t,...n}=e;return n}var C=[`once`,`broadcast`,`live`],w={once:`Once — competing consumers`,broadcast:`Broadcast — every subscriber`,live:`Live — client stream`};function T(e,t=``){let n=t.trim().toLowerCase(),r=n?e.filter(e=>e.name.toLowerCase().includes(n)||e.delivery.includes(n)||e.producers.some(e=>e.flowId.toLowerCase().includes(n))||e.consumers.some(e=>e.flowId.toLowerCase().includes(n))):e;return C.map(e=>({delivery:e,label:w[e],signals:r.filter(t=>t.delivery===e)})).filter(e=>e.signals.length>0)}function E(e){return e===!0?{durable:!0,statement:`Consumer is durable — replay resumes at the failed journal step and side effects will not repeat.`}:e===!1?{durable:!1,statement:`Consumer is not durable — everything re-runs from the start, including side effects. Declare durable: true on the consumer so replay resumes at the failed journal step.`}:{durable:null,statement:`No consumer declared — replay has no target flow.`}}function D(e,t={production:!0}){return t.production&&e.consumers.some(e=>e.external)&&e.consumersDurable!==!0?{kind:`typed`,phrase:`REPLAY`,requireReason:!0}:{kind:`undo`,windowMs:d}}function O(e,t={production:!0}){return t.production&&(e.consumers.some(e=>e.external||!e.durable)||e.dead>0)?{kind:`typed`,phrase:`DISCARD`,requireReason:!0}:{kind:`undo`,windowMs:d}}function k(e){if(!e||typeof e!=`object`||Array.isArray(e))return[];let t=e;if(t.type!==`object`||!t.properties)return[];let n=new Set(Array.isArray(t.required)?t.required.filter(e=>typeof e==`string`):[]);return Object.entries(t.properties).map(([e,t])=>{let r=t??{},i=Array.isArray(r.enum)?r.enum.filter(e=>typeof e==`string`):void 0;return{key:e,type:r.type===`string`||r.type===`number`||r.type===`boolean`||r.type===`integer`?r.type:`unknown`,required:n.has(e),...i&&i.length>0?{enumValues:i}:{}}})}function A(e,t){let n=e&&typeof e==`object`&&!Array.isArray(e)?e:{},r={};for(let e of t){let t=n[e.key];t==null?r[e.key]=``:typeof t==`boolean`?r[e.key]=t?`true`:`false`:r[e.key]=String(t)}return t.length===0&&(r._raw=JSON.stringify(e??null,null,2)),r}function j(e,t){if(t.length===0)try{return JSON.parse(e._raw??`null`)}catch{return e._raw??null}let n={};for(let r of t){let t=e[r.key]??``;if(!(t===``&&!r.required))if(r.type===`boolean`)n[r.key]=t===`true`;else if(r.type===`number`||r.type===`integer`){let e=Number(t);n[r.key]=Number.isFinite(e)?e:t}else n[r.key]=t}return n}function M(e,t){return{...e,paused:t,autoPausedByScroll:t?e.autoPausedByScroll:!1}}function N(e){return e.paused?e:{...e,paused:!0,autoPausedByScroll:!0}}function P(e){return JSON.stringify(e,null,2)}function F(e=[]){return{paused:!1,autoPausedByScroll:!1,payloads:[...e]}}function I(e){return e.orphaned?{ok:!1,reason:`Orphaned signal — consumer shape unknown; dry-run refused rather than risk a side effect.`}:e.consumers.length===0?{ok:!1,reason:`No Manifest consumer — dry-run refused rather than invoke an unknown handler unsafely.`}:{ok:!0}}var L=e(l(),1),R=f();function z(){let e=ne({from:`/signals`}),t=n({from:`/signals`}),a=ee(),[s,l]=(0,L.useState)({}),[d,f]=(0,L.useState)(``),[p,m]=(0,L.useState)(``),[h,_]=(0,L.useState)(null),[v,y]=(0,L.useState)(()=>F()),[C,w]=(0,L.useState)(new Set),z=e=>{t({search:b(e),replace:!0})},B=e.rate??10,V=r({queryKey:[`console.signals.list`],queryFn:async()=>{let e=await c.signalsList();if(e.error)throw Error(e.error.code);return e.data.signals},refetchInterval:!e.paused&&5e3}),H=V.data??[],U=(0,L.useMemo)(()=>T(H,e.q??``),[H,e.q]),W=H.find(t=>t.name===e.signal),G=W?E(W.consumersDurable):null,K=W?.deadLetters.find(t=>t.id===e.dlq),q=W?k(W.schema):[],J=W?D(W,{production:!0}):null,Y=W?O(W,{production:!0}):null,X=W?I(W):null;(0,L.useEffect)(()=>{K&&(l(A(K.payload,q)),f(``),m(``))},[K?.id,W?.name]),(0,L.useEffect)(()=>{if(!(!W||W.delivery!==`live`)){if(e.paused){y(e=>M(e,!0));return}y(e=>({...M(e,!1),payloads:e.payloads.length===0?[...W.recentLive]:e.payloads}))}},[W?.name,W?.recentLive,W?.delivery,e.paused]);let Z=i({mutationFn:async()=>{if(!W)return;if(X&&!X.ok)throw Error(X.reason);let t=C.size>0?[...C]:W.deadLetters.map(e=>e.id),n=await c.signalsDryRunReplay({signal:W.name,messageIds:t,subscriberId:e.sub,ratePerSec:B});if(n.error)throw Error(n.error.code);return n.data},onSuccess:e=>{if(!e)return;let t=e.wouldHaveFired?.length>0?` · ${e.wouldHaveFired.length} external effect(s) stubbed`:``;_(`${e.succeeded} would succeed, ${e.failed} would still fail${t}`)},onError:e=>{_(e instanceof Error?e.message:`Dry-run refused`)}}),Q=i({mutationFn:async()=>{if(!W||!J)return;if(J.kind===`typed`){let e=o({typed:d,reason:p,phrase:J.phrase});if(e)throw Error(e.typed??e.reason??`confirm`)}let t=C.size>0?[...C]:K?[K.id]:W.deadLetters.map(e=>e.id),n=K&&q?{[K.id]:j(s,q)}:void 0,r=await c.signalsReplay({signal:W.name,messageIds:t,subscriberId:e.sub,ratePerSec:B,dryRun:!1,payloads:n,confirmation:J.kind===`typed`?d:void 0,reason:J.kind===`typed`?p:void 0});if(r.error)throw Error(r.error.code);return r.data},onSuccess:()=>{a.invalidateQueries({queryKey:[`console.signals.list`]}),_(null),w(new Set)}}),$=i({mutationFn:async()=>{if(!W||!Y)return;if(Y.kind===`typed`){let e=o({typed:d,reason:p,phrase:Y.phrase});if(e)throw Error(e.typed??e.reason??`confirm`)}let e=C.size>0?[...C]:K?[K.id]:W.deadLetters.map(e=>e.id),t=await c.signalsDiscard({signal:W.name,messageIds:e,confirmation:Y.kind===`typed`?d:void 0,reason:Y.kind===`typed`?p:void 0});if(t.error)throw Error(t.error.code);return t.data},onSuccess:()=>{a.invalidateQueries({queryKey:[`console.signals.list`]}),K&&z(S(e)),w(new Set)}});return(0,R.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,R.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-4 border-b border-[var(--oke-line)] px-6 py-4`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsx)(`p`,{className:`text-xs uppercase tracking-[0.2em] text-[var(--oke-muted)]`,children:`Signals`}),(0,R.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight`,children:`Delivery physics`}),(0,R.jsx)(`p`,{className:`text-xs text-[var(--oke-muted)]`,children:`One list — once · broadcast · live`})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter`}),(0,R.jsx)(`input`,{"aria-label":`Filter signals`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2 text-sm`,value:e.q??``,onChange:t=>z({...e,q:t.target.value||void 0})})]})]}),(0,R.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 md:grid-cols-[minmax(0,1fr)_minmax(0,1.5fr)]`,children:[(0,R.jsx)(`section`,{"aria-label":`Signal list`,className:`min-h-0 overflow-auto border-r border-[var(--oke-line)]`,children:V.isLoading?(0,R.jsx)(`p`,{className:`px-6 py-8 text-sm text-[var(--oke-muted)]`,children:`Loading signals…`}):U.length===0?(0,R.jsx)(`p`,{className:`px-6 py-8 text-sm text-[var(--oke-muted)]`,children:`No signals declared.`}):U.map(t=>(0,R.jsxs)(`section`,{"aria-label":t.label,className:`border-b border-[var(--oke-line)]`,children:[(0,R.jsx)(`h2`,{className:`sticky top-0 bg-[var(--oke-bg)] px-6 py-2 text-xs font-medium uppercase tracking-[0.15em] text-[var(--oke-muted)]`,children:t.label}),(0,R.jsx)(`ul`,{children:t.signals.map(t=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":t.name===e.signal,className:te(`flex w-full min-h-10 flex-col items-start gap-0.5 px-6 py-2 text-left text-sm`,t.name===e.signal?`bg-[var(--oke-line)]/40`:`hover:bg-[var(--oke-line)]/20`),onClick:()=>z(x(e,t.name)),children:[(0,R.jsxs)(`span`,{className:`font-medium`,children:[t.name,t.orphaned?(0,R.jsx)(`span`,{role:`status`,className:`ml-2 text-xs text-[var(--oke-muted)]`,children:`orphaned`}):null]}),(0,R.jsxs)(`span`,{className:`text-xs text-[var(--oke-muted)]`,children:[t.delivery===`once`&&(0,R.jsxs)(R.Fragment,{children:[`pending `,t.pending,` · in-flight `,t.inflight,` · DLQ `,t.dead,t.outboxLagMs!=null&&t.outboxLagMs>0?` · outbox ${t.outboxLagMs}ms`:``]}),t.delivery===`broadcast`&&(0,R.jsxs)(R.Fragment,{children:[t.subscribers.length,` subscribers · lag`,` `,t.subscribers.reduce((e,t)=>e+t.lag,0)]}),t.delivery===`live`&&(0,R.jsxs)(R.Fragment,{children:[t.connections,` connections · `,t.throughputPerSec,`/s`]})]})]})},t.name))})]},t.delivery))}),(0,R.jsx)(`section`,{"aria-label":`Signal detail`,"aria-live":`polite`,className:`min-h-0 overflow-auto px-6 py-4`,children:!W||!G?(0,R.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a signal to inspect delivery, DLQ, and consumers.`}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-lg font-semibold`,children:W.name}),(0,R.jsx)(`p`,{role:`status`,className:`mt-2 max-w-prose text-sm leading-relaxed`,"data-durable":String(G.durable),children:G.statement})]}),(0,R.jsx)(u,{type:`button`,variant:`ghost`,onClick:()=>z(re(e)),children:`Close`})]}),W.delivery===`once`?(0,R.jsxs)(`dl`,{className:`grid grid-cols-2 gap-3 text-sm sm:grid-cols-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Pending`}),(0,R.jsx)(`dd`,{className:`text-lg font-medium`,children:W.pending})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`In-flight`}),(0,R.jsx)(`dd`,{className:`text-lg font-medium`,children:W.inflight})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`DLQ`}),(0,R.jsx)(`dd`,{className:`text-lg font-medium`,children:W.dead})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Retry policy`}),(0,R.jsxs)(`dd`,{className:`text-lg font-medium`,children:[W.retries,` retries`,W.deadLetterEnabled?` → DLQ`:``]})]}),W.outboxLagMs==null?null:(0,R.jsxs)(`div`,{className:`col-span-2`,children:[(0,R.jsx)(`dt`,{className:`text-[var(--oke-muted)]`,children:`Outbox lag`}),(0,R.jsxs)(`dd`,{className:`font-medium`,children:[W.outboxLagMs,` ms`]})]})]}):null,W.delivery===`broadcast`?(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium`,children:`Subscribers`}),(0,R.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,R.jsx)(`caption`,{className:`sr-only`,children:`Per-subscriber lag and errors`}),(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:`text-[var(--oke-muted)]`,children:[(0,R.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`Subscriber`}),(0,R.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`Lag`}),(0,R.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`Errors`}),(0,R.jsx)(`th`,{scope:`col`,className:`py-1 font-normal`,children:`Replay`})]})}),(0,R.jsx)(`tbody`,{children:W.subscribers.map(t=>(0,R.jsxs)(`tr`,{className:`border-t border-[var(--oke-line)]`,children:[(0,R.jsx)(`td`,{className:`py-2 font-mono text-xs`,children:t.id}),(0,R.jsx)(`td`,{className:`py-2`,children:t.lag}),(0,R.jsx)(`td`,{className:`py-2`,children:t.errorCount}),(0,R.jsx)(`td`,{className:`py-2`,children:(0,R.jsx)(u,{type:`button`,variant:`ghost`,"aria-pressed":e.sub===t.id,onClick:()=>z({...e,sub:e.sub===t.id?void 0:t.id}),children:e.sub===t.id?`Targeted`:`Target`})})]},t.id))})]})]}):null,W.delivery===`live`?(0,R.jsxs)(`section`,{"aria-label":`Payload monitor`,className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,R.jsx)(`h3`,{className:`text-sm font-medium`,children:`Payload monitor`}),(0,R.jsxs)(`span`,{className:`text-xs text-[var(--oke-muted)]`,children:[W.connections,` connections · `,W.throughputPerSec,`/s`]}),(0,R.jsx)(u,{type:`button`,variant:`ghost`,onClick:()=>{let t=!v.paused;y(e=>M(e,t)),z({...e,paused:t||void 0})},children:v.paused?`Resume`:`Pause`}),(0,R.jsx)(u,{type:`button`,variant:`ghost`,onClick:()=>{let e=new Blob([P(v.payloads)],{type:`application/json`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`${W.name}-live.json`,n.click(),URL.revokeObjectURL(t)},children:`Export`}),v.autoPausedByScroll?(0,R.jsx)(`span`,{role:`status`,className:`text-xs text-[var(--oke-muted)]`,children:`Auto-paused on scroll`}):null]}),(0,R.jsx)(`ul`,{className:`max-h-48 overflow-auto border border-[var(--oke-line)] p-2 font-mono text-xs`,onScroll:()=>{y(t=>{let n=N(t);return n.paused&&!t.paused&&z({...e,paused:!0}),n})},children:(v.payloads.length?v.payloads:W.recentLive).map((e,t)=>(0,R.jsx)(`li`,{className:`border-b border-[var(--oke-line)]/50 py-1`,children:JSON.stringify(e)},t))})]}):null,(0,R.jsxs)(`section`,{"aria-label":`Producers and consumers`,children:[(0,R.jsx)(`h3`,{className:`mb-2 text-sm font-medium`,children:`Causality`}),(0,R.jsxs)(`div`,{className:`grid gap-4 text-sm sm:grid-cols-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-1 text-xs uppercase tracking-[0.15em] text-[var(--oke-muted)]`,children:`Producers`}),(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:W.producers.length===0?(0,R.jsx)(`li`,{className:`text-[var(--oke-muted)]`,children:`None`}):W.producers.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsx)(g,{to:`/flows`,search:{sel:`flow`,flow:e.flowId},className:`underline-offset-2 hover:underline`,children:e.flowId})},e.flowId))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`mb-1 text-xs uppercase tracking-[0.15em] text-[var(--oke-muted)]`,children:`Consumers`}),(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:W.consumers.length===0?(0,R.jsx)(`li`,{className:`text-[var(--oke-muted)]`,children:`None`}):W.consumers.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(g,{to:`/flows`,search:{sel:`flow`,flow:e.flowId},className:`underline-offset-2 hover:underline`,children:[e.flowId,e.durable?` · durable`:``]})},e.flowId))})]})]})]}),W.dead>0?(0,R.jsxs)(`section`,{"aria-label":`Dead letters`,className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`h3`,{className:`text-sm font-medium`,children:[`Dead letters (`,W.dead,`)`]}),(0,R.jsx)(`p`,{className:`text-xs text-[var(--oke-muted)]`,children:`Bulk repair: dry run first, then replay at a controlled rate — never an unthrottled flood.`}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,R.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Rate (per second)`}),(0,R.jsx)(`input`,{"aria-label":`Replay rate (per second)`,type:`number`,min:1,max:1e3,className:`min-h-8 w-24 border border-[var(--oke-line)] bg-transparent px-2`,value:B,onChange:t=>z({...e,rate:Number(t.target.value)||10})})]}),(0,R.jsx)(u,{type:`button`,onClick:()=>Z.mutate(),disabled:Z.isPending||X!==null&&!X.ok,title:X&&!X.ok?X.reason:void 0,children:`Dry run`}),X&&!X.ok?(0,R.jsx)(`p`,{role:`status`,className:`basis-full text-xs text-[var(--oke-muted)]`,children:X.reason}):null,(0,R.jsx)(u,{type:`button`,onClick:()=>Q.mutate(),disabled:Q.isPending||!h,children:`Replay`}),(0,R.jsx)(u,{type:`button`,variant:`ghost`,onClick:()=>$.mutate(),disabled:$.isPending,children:`Discard`})]}),h?(0,R.jsx)(`p`,{role:`status`,className:`text-sm`,children:h}):null,(J?.kind===`typed`||Y?.kind===`typed`)&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 border border-[var(--oke-line)] p-3`,children:[(0,R.jsx)(`p`,{className:`text-xs text-[var(--oke-muted)]`,children:`This action re-triggers external effects or permanently discards messages. Type the phrase and a reason.`}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[`Confirmation`,(0,R.jsx)(`input`,{"aria-label":`Confirmation phrase`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:d,onChange:e=>f(e.target.value),placeholder:J?.kind===`typed`?J.phrase:Y?.kind===`typed`?Y.phrase:``})]}),(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[`Reason`,(0,R.jsx)(`input`,{"aria-label":`Confirmation reason`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:p,onChange:e=>m(e.target.value)})]})]}),(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:W.deadLetters.map(t=>{let n=t.failures[t.failures.length-1];return(0,R.jsxs)(`li`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`input`,{type:`checkbox`,"aria-label":`Select ${t.id}`,checked:C.has(t.id),onChange:e=>{w(n=>{let r=new Set(n);return e.target.checked?r.add(t.id):r.delete(t.id),r})}}),(0,R.jsxs)(`button`,{type:`button`,"aria-pressed":t.id===e.dlq,className:`min-h-8 flex-1 text-left text-sm`,onClick:()=>z(ie(e,t.id)),children:[(0,R.jsx)(`span`,{className:`font-mono text-xs`,children:t.id}),n?(0,R.jsx)(`span`,{role:`status`,className:`ml-2`,children:n.code}):null]})]},t.id)})})]}):null,K?(0,R.jsxs)(`section`,{"aria-label":`Dead-letter detail`,className:`flex flex-col gap-3 border-t border-[var(--oke-line)] pt-4`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,R.jsxs)(`h3`,{className:`text-sm font-medium`,children:[`Dead letter `,K.id]}),(0,R.jsx)(u,{type:`button`,variant:`ghost`,onClick:()=>z(S(e)),children:`Close letter`})]}),(0,R.jsx)(`p`,{role:`status`,className:`text-sm`,children:G.statement}),(0,R.jsx)(`form`,{"aria-label":`Editable payload`,className:`flex flex-col gap-2`,onSubmit:e=>e.preventDefault(),children:q.length>0?q.map(e=>(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[e.key,e.enumValues?(0,R.jsx)(`select`,{"aria-label":e.key,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:s[e.key]??``,onChange:t=>l(n=>({...n,[e.key]:t.target.value})),children:e.enumValues.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))}):(0,R.jsx)(`input`,{"aria-label":e.key,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:s[e.key]??``,onChange:t=>l(n=>({...n,[e.key]:t.target.value}))})]},e.key)):(0,R.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[`Payload JSON`,(0,R.jsx)(`textarea`,{"aria-label":`Payload JSON`,className:`min-h-24 border border-[var(--oke-line)] bg-transparent px-2 font-mono text-xs`,value:s._raw??``,onChange:e=>l({_raw:e.target.value}),rows:4})]})}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h4`,{className:`mb-1 text-xs uppercase tracking-[0.15em] text-[var(--oke-muted)]`,children:`Attempt history`}),(0,R.jsx)(`ol`,{className:`list-decimal space-y-1 pl-5 text-sm`,children:K.failures.map(e=>(0,R.jsxs)(`li`,{children:[`Attempt `,e.attempt,`: `,(0,R.jsx)(`strong`,{children:e.code}),` — `,e.message]},`${e.attempt}-${e.code}-${e.at}`))})]}),K.causeRunId?(0,R.jsxs)(`p`,{className:`text-sm`,children:[`Causal chain:`,` `,(0,R.jsx)(g,{to:`/traces`,search:{trace:K.causeRunId},className:`underline-offset-2 hover:underline`,children:K.causeFlow??K.causeRunId})]}):null,(0,R.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,R.jsx)(u,{type:`button`,onClick:()=>{w(new Set([K.id])),Q.mutate()},children:`Replay this message`}),(0,R.jsx)(u,{type:`button`,variant:`ghost`,onClick:()=>{w(new Set([K.id])),$.mutate()},children:`Discard`})]})]}):null]})})]})]})}var B=t({default:()=>z});export{y as n,B as t};
@@ -1 +0,0 @@
1
- import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,Z as i,a,b as o,d as s,et as c,g as l,nt as u,o as d,r as f,tt as p,u as m,w as h,y as g}from"./panel-access-C0J2D-a2.js";import{r as _}from"./panel-runs-CGWNHLR4.js";var v=g({q:o().optional(),ref:o().optional(),child:o().optional(),tenant:o().optional(),view:l([`browse`,`cache`,`sql`,`probe`]).optional(),prefix:o().optional()});function y(e){let t=v.safeParse(e);return t.success?t.data:{}}function b(e){let t={};return e.q&&(t.q=e.q),e.ref&&(t.ref=e.ref),e.child&&(t.child=e.child),e.tenant&&(t.tenant=e.tenant),e.view&&e.view!==`browse`&&(t.view=e.view),e.prefix&&(t.prefix=e.prefix),t}function x(e,t){return{...e,ref:t,child:void 0,view:`browse`}}function S(e,t){return{...e,child:t,view:`browse`}}var C=[`sql`,`kv`,`files`,`index`],w={sql:`SQL`,kv:`KV`,files:`Files`,index:`Index`};function T(e,t=``){let n=t.trim().toLowerCase(),r=n?e.filter(e=>e.name.toLowerCase().includes(n)||e.ref.toLowerCase().includes(n)||e.children.some(e=>e.name.toLowerCase().includes(n))):e;return C.map(e=>({facet:e,label:w[e],stores:r.filter(t=>t.facet===e)})).filter(e=>e.stores.length>0)}function E(e={production:!0}){return e.production?{kind:`typed`,phrase:`EDIT`,requireReason:!0}:{kind:`undo`,windowMs:f}}function D(e={production:!0}){return e.production?{kind:`typed`,phrase:`DELETE`,requireReason:!0}:{kind:`undo`,windowMs:f}}function O(e={production:!0}){return e.production?{kind:`typed`,phrase:`PURGE`,requireReason:!0}:{kind:`undo`,windowMs:f}}function k(e){let t=[];for(let n of e.signals)t.push(`Signal \`${n}\` will not be emitted`);for(let n of e.channels)t.push(`Channel \`${n}\` will not fire`);return e.writerFlowIds.length>0&&t.push(`Owning flow(s): ${e.writerFlowIds.map(e=>`\`${e}\``).join(`, `)} — not executed`),{headline:`Direct edit is not a flow execution — the following will NOT happen:`,lines:t,empty:t.length===0}}function A(e){return e.facet===`index`?{ok:!1,reason:`Index facet has no bulk-update preview — similarity probe is read-only.`}:{ok:!0}}function j(e){let t=e.cache,n=t.invalidatedByWrites,r=t.invalidatingFlowIds,i=n.length===0?`Read key \`${t.producedByRead}\` — no write invalidators declared.`:`Read key \`${t.producedByRead}\` — invalidated by writes to ${n.map(e=>`\`${e}\``).join(`, `)}.`;return{producedByRead:t.producedByRead,invalidatedBy:n,invalidatingFlows:r,summary:i}}var M=e(u(),1),N=p();function P(){let e=h({from:`/store`}),t=n({from:`/store`}),o=c(),[l,u]=(0,M.useState)(``),[d,f]=(0,M.useState)(``),[p,g]=(0,M.useState)(`{}`),[_,v]=(0,M.useState)(`SELECT * FROM "bookings" LIMIT 50`),[y,S]=(0,M.useState)(`0.1,0.2,0.3`),[C,w]=(0,M.useState)(null),P=e=>{t({search:b(e),replace:!0})},I=r({queryKey:[`console.store.list`],queryFn:async()=>{let e=await s.storeList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}),L=I.data?.tenancyDeclared??!1,ee=I.data?.tenants??[],R=I.data?.stores??[],te=(0,M.useMemo)(()=>T(R,e.q??``),[R,e.q]),z=R.find(t=>t.ref===e.ref),B=z?.children.find(t=>t.name===e.child)??z?.children[0],V=e.view??`browse`,H=E({production:!0}),U=D({production:!0}),W=O({production:!0}),G=z?A(z):null,ne=B?k(B.willNotFire):null,re=B?j(B):null,K=r({queryKey:[`console.store.query`,e.ref,B?.name,e.tenant,e.prefix,V,y],enabled:!!z&&!!B&&V===`browse`&&(!L||!!e.tenant),queryFn:async()=>{if(!z||!B)return null;let t=z.facet===`index`?y.split(`,`).map(e=>Number(e.trim())).filter(e=>!Number.isNaN(e)):void 0,n=await s.storeQuery({ref:z.ref,child:B.name,tenant:e.tenant,prefix:e.prefix,vector:t,topK:5});if(n.error)throw Error(n.error.code);return n.data}});(0,M.useEffect)(()=>{u(``),f(``),w(null)},[z?.ref,B?.name]);let q=()=>{o.invalidateQueries({queryKey:[`console.store.list`]}),o.invalidateQueries({queryKey:[`console.store.query`]})},J=i({mutationFn:async()=>{if(!z||!B)return;if(G&&!G.ok)throw Error(G.reason);let t={};try{t=JSON.parse(p)}catch{throw Error(`Patch must be valid JSON`)}let n=await s.storePreview({ref:z.ref,child:B.name,tenant:e.tenant,id:String(t.id??`preview`),key:typeof t.key==`string`?t.key:void 0,patch:t});if(n.error)throw Error(n.error.code);let r=n.data;return w(k(r.willNotFire).lines),r}}),Y=i({mutationFn:async()=>{if(!z||!B)return;if(H.kind===`typed`){let e=a({typed:l,reason:d,phrase:H.phrase});if(e)throw Error(e.typed??e.reason)}let t={};try{t=JSON.parse(p)}catch{throw Error(`Patch must be valid JSON`)}let n=await s.storeEdit({ref:z.ref,child:B.name,tenant:e.tenant,id:String(t.id??``),key:typeof t.key==`string`?t.key:void 0,patch:t,confirmation:l,reason:d,commit:!0});if(n.error)throw Error(n.error.code);return n.data},onSuccess:q}),X=i({mutationFn:async t=>{if(!z||!B)return;if(U.kind===`typed`){let e=a({typed:l,reason:d,phrase:U.phrase});if(e)throw Error(e.typed??e.reason)}let n=await s.storeDelete({ref:z.ref,child:B.name,tenant:e.tenant,ids:z.facet===`sql`||z.facet===`index`?t:void 0,keys:z.facet===`kv`||z.facet===`files`?t:void 0,confirmation:l,reason:d});if(n.error)throw Error(n.error.code);return n.data},onSuccess:q}),Z=i({mutationFn:async()=>{if(!B)return;if(W.kind===`typed`){let e=a({typed:l,reason:d,phrase:W.phrase});if(e)throw Error(e.typed??e.reason)}let e=await s.storePurgeCache({resource:B.effectRef,confirmation:l,reason:d});if(e.error)throw Error(e.error.code);return e.data},onSuccess:q}),Q=i({mutationFn:async()=>{if(!z||z.facet!==`sql`)return;let t=await s.storeSql({ref:z.ref,sql:_,tenant:e.tenant,allowWrite:!1});if(t.error)throw Error(t.error.code);return t.data}}),$=i({mutationFn:async t=>{if(!z||!B)return;let n=await s.storeReveal({ref:z.ref,child:B.name,tenant:e.tenant,id:t.id,column:t.column});if(n.error)throw Error(n.error.code);return n.data}});return(0,N.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,N.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-3 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,N.jsxs)(`div`,{className:`mr-auto`,children:[(0,N.jsx)(`h1`,{className:`text-lg font-medium`,children:`Store`}),(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`One list, grouped by facet — direct edits are not flow executions`})]}),L?(0,N.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,N.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Tenant`}),(0,N.jsxs)(`select`,{"aria-label":`Tenant`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:e.tenant??``,onChange:t=>P({...e,tenant:t.target.value||void 0}),children:[(0,N.jsx)(`option`,{value:``,children:`Select tenant…`}),ee.map(e=>(0,N.jsx)(`option`,{value:e,children:e},e))]})]}):null,(0,N.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,N.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter`}),(0,N.jsx)(`input`,{"aria-label":`Filter stores`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:e.q??``,onChange:t=>P({...e,q:t.target.value||void 0})})]})]}),(0,N.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,N.jsxs)(`section`,{"aria-label":`Store list`,className:`w-72 shrink-0 overflow-y-auto border-r border-[var(--oke-line)]`,children:[I.isLoading?(0,N.jsx)(`p`,{className:`p-3 text-sm text-[var(--oke-muted)]`,children:`Loading…`}):null,te.map(t=>(0,N.jsxs)(`div`,{className:`border-b border-[var(--oke-line)]`,children:[(0,N.jsx)(`h2`,{className:`px-3 py-2 text-xs tracking-wide text-[var(--oke-muted)]`,children:t.label}),(0,N.jsx)(`ul`,{children:t.stores.map(t=>(0,N.jsx)(`li`,{children:(0,N.jsxs)(`button`,{type:`button`,"aria-pressed":t.ref===e.ref,className:m(`flex min-h-8 w-full flex-col items-start px-3 py-2 text-left text-sm`,t.ref===e.ref?`bg-[var(--oke-line)]/40`:`hover:bg-[var(--oke-line)]/20`),onClick:()=>P(x(e,t.ref)),children:[(0,N.jsx)(`span`,{children:t.name}),(0,N.jsxs)(`span`,{className:`text-xs text-[var(--oke-muted)]`,children:[t.children.length,` resource(s)`,t.replicaLagMs==null?``:` · lag ${t.replicaLagMs}ms`,t.migrationDrift?.drifted?` · drift`:``,t.warnings.length>0?` · ${t.warnings.length} warn`:``]})]})},t.ref))})]},t.facet))]}),(0,N.jsx)(`section`,{"aria-label":`Store detail`,className:`min-w-0 flex-1 overflow-y-auto p-4`,"aria-live":`polite`,children:z?L&&!e.tenant?(0,N.jsx)(`p`,{role:`status`,className:`text-sm`,children:`Select a tenant in the header before browsing — compliance boundary, not a display filter.`}):(0,N.jsx)(F,{open:z,childName:B?.name,view:V,search:e,setSearch:P,browse:K.data,browseLoading:K.isLoading,cache:re,willNot:ne,willNotPreview:C,patchJson:p,setPatchJson:g,typed:l,setTyped:u,reason:d,setReason:f,sqlText:_,setSqlText:v,probeVector:y,setProbeVector:S,onPreview:()=>J.mutate(),onCommit:()=>Y.mutate(),onDelete:e=>X.mutate(e),onPurge:()=>Z.mutate(),onSql:()=>Q.mutate(),sqlResult:Q.data,onReveal:(e,t)=>$.mutate({id:e,column:t}),revealValue:$.data?.value,error:J.error?.message??Y.error?.message??X.error?.message??Z.error?.message??Q.error?.message??$.error?.message}):(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a store. Tenant selector appears only when tenancy is declared on the Manifest.`})})]})]})}function F(e){let{open:t,childName:n,view:r,search:i,setSearch:a,browse:o,browseLoading:s,cache:c,willNot:l,willNotPreview:u,patchJson:f,setPatchJson:p,typed:h,setTyped:g,reason:v,setReason:y,sqlText:b,setSqlText:x,probeVector:C,setProbeVector:w,onPreview:T,onCommit:E,onDelete:D,onPurge:O,onSql:k,sqlResult:A,onReveal:j,revealValue:M,error:P}=e,F=t.children.find(e=>e.name===n);return(0,N.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-2`,children:[(0,N.jsx)(`h2`,{className:`text-base font-medium`,children:t.name}),(0,N.jsx)(`span`,{className:`text-sm text-[var(--oke-muted)]`,children:t.ref}),t.contentAddressed?(0,N.jsx)(`span`,{role:`status`,className:`text-xs text-[var(--oke-muted)]`,children:`content-addressed keys`}):null]}),(0,N.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`tablist`,"aria-label":`Views`,children:[[`browse`,`Browse`],[`cache`,`Cache`],...t.facet===`sql`?[[`sql`,`SQL`]]:[],...t.facet===`index`?[[`probe`,`Probe`]]:[]].map(([e,t])=>(0,N.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r===e,className:m(`min-h-8 px-2 text-sm`,r===e?`text-[var(--oke-fg)] underline`:`text-[var(--oke-muted)]`),onClick:()=>a({...i,view:e}),children:t},e))}),(0,N.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,N.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Resource`}),(0,N.jsx)(`select`,{"aria-label":`Store resource`,className:`min-h-8 max-w-xs border border-[var(--oke-line)] bg-transparent px-2`,value:n??``,onChange:e=>a(S(i,e.target.value)),children:t.children.map(e=>(0,N.jsx)(`option`,{value:e.name,children:e.name},e.name))})]}),F?(0,N.jsxs)(`p`,{className:`text-sm`,role:`status`,children:[`Writers:`,` `,F.writers.map(e=>(0,N.jsx)(_,{to:`/flows`,search:{flow:e},className:`mr-2 underline`,children:e},e)),F.writers.length===0?`none`:null,` · `,`Readers: `,F.readers.join(`, `)||`none`,F.piiColumns.length>0?` · PII columns: ${F.piiColumns.join(`, `)}`:``]}):null,t.migrationDrift?(0,N.jsxs)(`p`,{className:`text-sm`,role:`status`,children:[`Migration: declared `,t.migrationDrift.declared.slice(0,12),`…`,t.migrationDrift.applied?` / applied ${t.migrationDrift.applied.slice(0,12)}…`:` / applied (none)`,t.migrationDrift.drifted?` — drifted`:` — in sync`]}):null,t.warnings.length>0?(0,N.jsx)(`ul`,{"aria-label":`Operational warnings`,className:`text-sm`,children:t.warnings.map(e=>(0,N.jsxs)(`li`,{role:`status`,children:[e.key,`: `,e.message]},`${e.key}:${e.code}`))}):null,r===`cache`&&c?(0,N.jsxs)(`section`,{"aria-label":`Cache`,children:[(0,N.jsx)(`h3`,{className:`text-sm font-medium`,children:`Cache`}),(0,N.jsx)(`p`,{className:`text-sm`,role:`status`,children:c.summary}),(0,N.jsxs)(`p`,{className:`text-xs text-[var(--oke-muted)]`,children:[`Invalidating flows: `,c.invalidatingFlows.join(`, `)||`none`]}),(0,N.jsx)(d,{type:`button`,onClick:O,children:`Purge cache namespace`})]}):null,r===`sql`&&t.facet===`sql`?(0,N.jsxs)(`section`,{"aria-label":`SQL console`,className:`flex flex-col gap-2`,children:[(0,N.jsx)(`h3`,{className:`text-sm font-medium`,children:`SQL console (read-only)`}),(0,N.jsx)(`textarea`,{"aria-label":`SQL console`,className:`min-h-24 border border-[var(--oke-line)] bg-transparent p-2 font-mono text-sm`,value:b,onChange:e=>x(e.target.value)}),(0,N.jsx)(d,{type:`button`,onClick:k,children:`Run`}),A?(0,N.jsxs)(`p`,{className:`text-xs text-[var(--oke-muted)]`,children:[A.rows.length,` row(s) · routed `,A.routedRole,A.masked?` · PII masked`:``]}):null]}):null,(r===`browse`||r===`probe`)&&(0,N.jsxs)(`section`,{"aria-label":`Browse`,children:[t.facet===`index`?(0,N.jsxs)(`label`,{className:`mb-2 flex flex-col gap-1 text-sm`,children:[(0,N.jsx)(`span`,{children:`Probe vector`}),(0,N.jsx)(`input`,{"aria-label":`Probe vector`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2 font-mono`,value:C,onChange:e=>w(e.target.value)})]}):null,s?(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Loading…`}):null,o?.rows?(0,N.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,N.jsx)(`thead`,{children:(0,N.jsxs)(`tr`,{children:[Object.keys(o.rows[0]??{id:1}).map(e=>(0,N.jsx)(`th`,{scope:`col`,className:`border-b px-2 py-1`,children:e},e)),(0,N.jsx)(`th`,{scope:`col`,className:`border-b px-2 py-1`,children:`Actions`})]})}),(0,N.jsx)(`tbody`,{children:o.rows.map((e,t)=>(0,N.jsxs)(`tr`,{children:[Object.entries(e).map(([t,n])=>(0,N.jsxs)(`td`,{className:`border-b px-2 py-1 font-mono`,children:[String(n),F?.piiColumns.includes(t)?(0,N.jsx)(`button`,{type:`button`,className:`ml-2 underline`,style:{minHeight:32},onClick:()=>j(String(e.id??``),t),children:`Reveal`}):null]},t)),(0,N.jsx)(`td`,{className:`border-b px-2 py-1`,children:(0,N.jsx)(d,{type:`button`,onClick:()=>D([String(e.id??``)]),children:`Delete`})})]},t))})]}):null,o?.keys?(0,N.jsx)(`ul`,{"aria-label":`Keys`,className:`text-sm`,children:o.keys.map(e=>(0,N.jsxs)(`li`,{className:`flex min-h-8 items-center gap-2`,children:[(0,N.jsx)(`span`,{className:`font-mono`,children:e.key}),e.value===void 0?null:(0,N.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:JSON.stringify(e.value)}),e.warnings?.map(e=>(0,N.jsx)(`span`,{role:`status`,className:`text-xs`,children:e.message},e.code)),(0,N.jsx)(d,{type:`button`,onClick:()=>D([e.key]),children:`Delete`})]},e.key))}):null,o?.hits?(0,N.jsx)(`ul`,{"aria-label":`Similarity hits`,className:`text-sm`,children:o.hits.map(e=>(0,N.jsxs)(`li`,{children:[e.id,` · score `,e.score.toFixed(3)]},e.id))}):null,M===void 0?null:(0,N.jsxs)(`p`,{role:`status`,className:`text-sm`,children:[`Revealed: `,String(M)]})]}),(0,N.jsxs)(`section`,{"aria-label":`Direct edit`,className:`flex flex-col gap-2 border-t border-[var(--oke-line)] pt-4`,children:[(0,N.jsx)(`h3`,{className:`text-sm font-medium`,children:`Direct edit`}),(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Not a flow execution. Before saving, preview names what will not fire.`}),l&&!l.empty?(0,N.jsx)(`ul`,{className:`text-sm`,children:(u??l.lines).map(e=>(0,N.jsx)(`li`,{children:e},e))}):(0,N.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`No owning-flow emissions declared for this resource.`}),(0,N.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[`Patch (JSON)`,(0,N.jsx)(`textarea`,{"aria-label":`Edit patch JSON`,className:`min-h-20 border border-[var(--oke-line)] bg-transparent p-2 font-mono text-sm`,value:f,onChange:e=>p(e.target.value)})]}),(0,N.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[`Type EDIT / DELETE / PURGE`,(0,N.jsx)(`input`,{"aria-label":`Confirmation phrase`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:h,onChange:e=>g(e.target.value)})]}),(0,N.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[`Reason`,(0,N.jsx)(`input`,{"aria-label":`Confirmation reason`,className:`min-h-8 border border-[var(--oke-line)] bg-transparent px-2`,value:v,onChange:e=>y(e.target.value)})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,N.jsx)(d,{type:`button`,onClick:T,children:`Preview`}),(0,N.jsx)(d,{type:`button`,onClick:E,children:`Save edit`})]}),P?(0,N.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:P}):null]})]})}var I=t({default:()=>P});export{y as n,I as t};
@@ -1 +0,0 @@
1
- import{a as e,r as t}from"./rolldown-runtime-CNC7AqOf.js";import{C as n,Q as r,Z as i,a,b as o,c as s,d as c,et as l,g as u,nt as d,o as f,tt as p,u as m,w as h,y as g}from"./panel-access-C0J2D-a2.js";var _=g({q:o().optional(),name:o().optional(),action:u([`set`,`rotate`]).optional()});function v(e){let t=_.safeParse(e);return t.success?t.data:{}}function y(e){let t={};return e.q&&(t.q=e.q),e.name&&(t.name=e.name),e.action&&(t.action=e.action),t}function b(e,t){return{...e,name:t,action:void 0}}function x(e,t=``){let n=t.trim().toLowerCase(),r=n?e.filter(e=>e.name.toLowerCase().includes(n)||(e.description?.toLowerCase().includes(n)??!1)):e,i=[`secret`,`config`],a={secret:`Secrets`,config:`Config`};return i.map(e=>({kind:e,label:a[e],secrets:r.filter(t=>t.kind===e)})).filter(e=>e.secrets.length>0)}function S(e={production:!0}){return e.production?{kind:`typed`,phrase:`SET`,requireReason:!0}:{kind:`undo`,windowMs:15e3}}function C(e={production:!0}){return{kind:`typed`,phrase:`ROTATE`,requireReason:!0}}function w(e){if(e.count===0)return{summary:`No in-flight durable runs hold this secret`,detail:null,warn:!1};let t=e.longestOutstandingMs==null?null:T(e.longestOutstandingMs);return{summary:`${e.count} in-flight durable run(s) will wake holding a new key`,detail:t?`Longest outstanding wake in ${t}`:e.longestWakeAt==null?null:`Longest wake at ${new Date(e.longestWakeAt).toISOString()}`,warn:!0}}function T(e){if(e<1e3)return`${e}ms`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<48?`${r}h`:`${Math.floor(r/24)}d`}function E(e){return{name:e.name,kind:e.kind,sensitive:e.sensitive,description:e.description??null,rotate:e.rotate??null,fingerprints:{...e.fingerprints},fingerprint:e.fingerprint,cleartext:e.sensitive?null:e.cleartext,winner:e.winner,resolution:e.resolution.map(e=>({...e})),readers:[...e.readers],blastRadius:{count:e.blastRadius.count,longestWakeAt:e.blastRadius.longestWakeAt,longestOutstandingMs:e.blastRadius.longestOutstandingMs,runIds:[...e.blastRadius.runIds]},lastReadAt:e.lastReadAt,sharedFingerprintEnvs:[...e.sharedFingerprintEnvs]}}function D(e){return JSON.stringify(e.map(e=>E(e)),null,2)}var O=e(d(),1),k=p();function A(){let e=h({from:`/vault`}),t=n({from:`/vault`}),o=l(),[u,d]=(0,O.useState)(``),[p,g]=(0,O.useState)(``),[_,v]=(0,O.useState)(``),[T,E]=(0,O.useState)(null),A=e=>{t({search:y(e),replace:!0})},j=r({queryKey:[`console.vault.list`],queryFn:async()=>{let e=await c.vaultList();if(e.error)throw Error(e.error.code);return e.data},refetchInterval:1e4}),M=j.data?.secrets??[],N=j.data?.env??`local`,P=(0,O.useMemo)(()=>x(M,e.q??``),[M,e.q]),F=M.find(t=>t.name===e.name),I=F?w(F.blastRadius):null,L=S({production:!0}),R=C({production:!0}),z=e.action;(0,O.useEffect)(()=>{d(``),g(``),v(``),E(null)},[F?.name,z]);let B=i({mutationFn:async()=>{if(!F)throw Error(`no secret`);if(L.kind===`typed`){let e=a({typed:u,reason:p,phrase:L.phrase});if(e)throw Error(e.typed??e.reason??`confirm`)}let e=await c.vaultSet({name:F.name,value:_,confirmation:L.kind===`typed`?u:void 0,reason:p||void 0});if(e.error)throw Error(e.error.code);return e.data},onSuccess:async()=>{v(``),d(``),g(``),A({...e,action:void 0}),await o.invalidateQueries({queryKey:[`console.vault.list`]})}}),V=i({mutationFn:async()=>{if(!F)throw Error(`no secret`);let e=a({typed:u,reason:p,phrase:R.kind===`typed`?R.phrase:`ROTATE`});if(e)throw Error(e.typed??e.reason??`confirm`);let t=await c.vaultRotate({name:F.name,value:_,confirmation:u,reason:p});if(t.error)throw Error(t.error.code);return t.data},onSuccess:async()=>{v(``),d(``),g(``),A({...e,action:void 0}),await o.invalidateQueries({queryKey:[`console.vault.list`]})}});return(0,k.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,k.jsxs)(`header`,{className:`flex shrink-0 flex-wrap items-end gap-3 border-b border-[var(--oke-line)] px-4 py-3`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h1`,{className:`text-lg font-medium text-[var(--oke-fg)]`,children:`Vault`}),(0,k.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Fingerprints only — secrets are write-only`})]}),(0,k.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,role:`status`,children:[`Environment `,N]}),(0,k.jsxs)(`label`,{className:`ml-auto flex min-w-[12rem] flex-col gap-1 text-sm`,children:[(0,k.jsx)(`span`,{className:`text-[var(--oke-muted)]`,children:`Filter vault`}),(0,k.jsx)(s,{"aria-label":`Filter vault`,value:e.q??``,onChange:t=>A({...e,q:t.currentTarget.value||void 0})})]}),(0,k.jsx)(f,{type:`button`,variant:`ghost`,onClick:()=>{let e=D(M);navigator.clipboard?.writeText(e),E(`Exported fingerprints only (no secret values)`)},children:`Export`})]}),T?(0,k.jsx)(`p`,{className:`px-4 py-2 text-sm text-[var(--oke-muted)]`,role:`status`,children:T}):null,(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,k.jsxs)(`section`,{"aria-label":`Vault list`,className:`w-80 shrink-0 overflow-y-auto border-r border-[var(--oke-line)]`,children:[(0,k.jsx)(`h2`,{className:`sr-only`,children:`Contracts`}),j.isLoading?(0,k.jsx)(`p`,{className:`p-4 text-sm text-[var(--oke-muted)]`,children:`Loading…`}):null,P.map(t=>(0,k.jsxs)(`section`,{"aria-label":t.label,className:`py-2`,children:[(0,k.jsx)(`h3`,{className:`px-4 py-1 text-xs uppercase tracking-wide text-[var(--oke-muted)]`,children:t.label}),(0,k.jsx)(`ul`,{children:t.secrets.map(t=>(0,k.jsx)(`li`,{children:(0,k.jsxs)(`button`,{type:`button`,"aria-pressed":t.name===F?.name,className:m(`flex min-h-10 w-full flex-col items-start px-4 py-2 text-left text-sm`,t.name===F?.name?`bg-[var(--oke-line)] text-[var(--oke-fg)]`:`text-[var(--oke-muted)] hover:text-[var(--oke-fg)]`),onClick:()=>A(b(e,t.name)),children:[(0,k.jsx)(`span`,{className:`font-mono`,children:t.name}),(0,k.jsx)(`span`,{className:`truncate text-xs`,children:t.sensitive?t.fingerprint??`unset`:t.cleartext??`unset`}),t.blastRadius.count>0?(0,k.jsxs)(`span`,{role:`status`,className:`text-xs text-[var(--oke-danger)]`,children:[`blast `,t.blastRadius.count]}):null,t.sharedFingerprintEnvs.length>0?(0,k.jsx)(`span`,{role:`status`,className:`text-xs`,children:`shared fingerprint`}):null]})},t.name))})]},t.kind))]}),(0,k.jsx)(`section`,{"aria-label":`Vault detail`,"aria-live":`polite`,className:`min-w-0 flex-1 overflow-y-auto p-4`,children:F?(0,k.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-6`,children:[(0,k.jsxs)(`div`,{children:[(0,k.jsx)(`h2`,{className:`font-mono text-lg text-[var(--oke-fg)]`,children:F.name}),F.description?(0,k.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:F.description}):null,F.rotate?(0,k.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[`Rotate hint: `,F.rotate]}):null]}),(0,k.jsxs)(`section`,{"aria-label":`Fingerprints by environment`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-sm font-medium`,children:`Fingerprints`}),F.sensitive?(0,k.jsxs)(`ul`,{className:`space-y-1 font-mono text-sm`,children:[Object.entries(F.fingerprints).map(([e,t])=>(0,k.jsxs)(`li`,{children:[(0,k.jsxs)(`span`,{className:`text-[var(--oke-muted)]`,children:[e,`:`]}),` `,t,F.sharedFingerprintEnvs.includes(e)?(0,k.jsxs)(`span`,{role:`status`,className:`ml-2 text-[var(--oke-warn,var(--oke-muted))]`,children:[`(matches `,N,` — warning, may be deliberate)`]}):null]},e)),Object.keys(F.fingerprints).length===0?(0,k.jsx)(`li`,{className:`text-[var(--oke-muted)]`,children:`Unset`}):null]}):(0,k.jsx)(`p`,{className:`font-mono text-sm`,role:`status`,children:F.cleartext??`unset`})]}),(0,k.jsxs)(`section`,{"aria-label":`Resolution chain`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-sm font-medium`,children:`Resolution chain`}),(0,k.jsx)(`ol`,{className:`list-decimal space-y-1 pl-5 text-sm`,children:F.resolution.map(e=>(0,k.jsxs)(`li`,{className:e.won?`text-[var(--oke-fg)]`:`text-[var(--oke-muted)]`,children:[(0,k.jsx)(`span`,{className:`font-mono`,children:e.source}),e.won?` — won`:e.present?` — present (lost)`:` — absent`]},e.source))}),(0,k.jsxs)(`p`,{className:`mt-2 text-sm`,role:`status`,children:[`Winner: `,(0,k.jsx)(`span`,{className:`font-mono`,children:F.winner??`none`})]})]}),(0,k.jsxs)(`section`,{"aria-label":`Readers`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-sm font-medium`,children:`Readers`}),(0,k.jsxs)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:[`Flows that declare `,(0,k.jsxs)(`code`,{className:`font-mono`,children:[`fx.vault(`,F.name,`)`]})]}),(0,k.jsx)(`ul`,{className:`mt-1 list-disc pl-5 font-mono text-sm`,children:F.readers.length===0?(0,k.jsx)(`li`,{className:`text-[var(--oke-muted)]`,children:`none`}):F.readers.map(e=>(0,k.jsx)(`li`,{children:e},e))})]}),(0,k.jsxs)(`section`,{"aria-label":`Rotation blast radius`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-sm font-medium`,children:`Rotation blast radius`}),I?(0,k.jsxs)(k.Fragment,{children:[(0,k.jsx)(`p`,{className:`text-sm`,role:I.warn?`alert`:`status`,children:I.summary}),I.detail?(0,k.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:I.detail}):null,F.blastRadius.runIds.length>0?(0,k.jsx)(`p`,{className:`mt-1 font-mono text-xs text-[var(--oke-muted)]`,children:F.blastRadius.runIds.join(`, `)}):null]}):null]}),(0,k.jsxs)(`section`,{"aria-label":`Last read`,children:[(0,k.jsx)(`h3`,{className:`mb-2 text-sm font-medium`,children:`Last read`}),(0,k.jsx)(`p`,{className:`text-sm`,role:`status`,children:F.lastReadAt==null?`Never read — possible dead secret`:new Date(F.lastReadAt).toISOString()})]}),(0,k.jsxs)(`section`,{"aria-label":`Set or rotate`,className:`space-y-3`,children:[(0,k.jsx)(`h3`,{className:`text-sm font-medium`,children:`Set / rotate`}),(0,k.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Write-only. Values are never revealed after submit. No preview.`}),(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(f,{type:`button`,variant:z===`set`?`primary`:`ghost`,"aria-pressed":z===`set`,onClick:()=>A({...e,action:`set`}),children:`Set`}),(0,k.jsx)(f,{type:`button`,variant:z===`rotate`?`danger`:`ghost`,"aria-pressed":z===`rotate`,onClick:()=>A({...e,action:`rotate`}),children:`Rotate`})]}),z?(0,k.jsxs)(`div`,{className:`space-y-3 border border-[var(--oke-line)] p-3`,children:[(0,k.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,k.jsx)(`span`,{children:`New value`}),(0,k.jsx)(s,{"aria-label":`New vault value`,type:`password`,autoComplete:`off`,value:_,onChange:e=>v(e.currentTarget.value)})]}),(z===`rotate`||L.kind===`typed`)&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,k.jsxs)(`span`,{children:[`Type`,` `,z===`rotate`?R.kind===`typed`?R.phrase:`ROTATE`:L.kind===`typed`?L.phrase:`SET`,` `,`to confirm`]}),(0,k.jsx)(s,{"aria-label":`Confirmation phrase`,value:u,onChange:e=>d(e.currentTarget.value)})]}),(0,k.jsxs)(`label`,{className:`flex flex-col gap-1 text-sm`,children:[(0,k.jsx)(`span`,{children:`Reason`}),(0,k.jsx)(s,{"aria-label":`Reason for vault write`,value:p,onChange:e=>g(e.currentTarget.value)})]})]}),(0,k.jsx)(f,{type:`button`,variant:z===`rotate`?`danger`:`primary`,disabled:!_||(z===`set`?B.isPending:V.isPending),onClick:()=>{z===`set`?B.mutate():V.mutate()},children:z===`set`?`Commit set`:`Commit rotate`}),(B.isError||V.isError)&&(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-[var(--oke-danger)]`,children:(B.error??V.error)?.message??`Failed`})]}):null]})]}):(0,k.jsx)(`p`,{className:`text-sm text-[var(--oke-muted)]`,children:`Select a contract to inspect fingerprints, resolution, and readers.`})})]})]})}var j=t({default:()=>A});export{v as n,j as t};