@jini-ai/db 0.7.3-next.2 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/README.md +66 -2
- package/dist/core/ports.d.ts +2 -2
- package/dist/core/ports.js +2 -2
- package/dist/data-modules/data-module.d.ts +2 -46
- package/dist/data-modules/plugin-identity.d.ts +2 -11
- package/dist/data-modules/snapshot.d.ts +5 -3
- package/dist/data-modules/snapshot.js +5 -3
- package/dist/events/change-set-repo.sql.d.ts +18 -5
- package/dist/events/change-set-repo.sql.js +25 -8
- package/dist/events/index.d.ts +1 -1
- package/dist/events/outbox-repo.sql.d.ts +26 -1
- package/dist/events/outbox-repo.sql.js +36 -2
- package/dist/events/repo.rows.d.ts +22 -4
- package/dist/events/repo.rows.js +32 -4
- package/dist/kernel/idle-turn.d.ts +62 -0
- package/dist/kernel/idle-turn.js +32 -0
- package/dist/kernel/index.d.ts +1 -0
- package/dist/kernel/index.js +1 -0
- package/dist/kernel/kernel-core.js +28 -0
- package/dist/kernel/schema-scope.js +2 -0
- package/dist/kernel/sqlite/driver.js +2 -0
- package/dist/kernel/sqlite/index.d.ts +1 -1
- package/dist/kernel/sqlite/index.js +1 -1
- package/dist/kernel/sqlite/ops.d.ts +61 -0
- package/dist/kernel/sqlite/ops.js +82 -0
- package/dist/kernel/turn-lock.d.ts +2 -0
- package/dist/kernel/turn-lock.js +7 -0
- package/dist/migrate/runner.d.ts +3 -3
- package/dist/migrate/runner.js +4 -1
- package/dist/owner-store/index.js +1 -1
- package/dist/pglite/copy-source.d.ts +45 -0
- package/dist/pglite/copy-source.js +36 -0
- package/dist/pglite/index.d.ts +1 -0
- package/dist/pglite/index.js +1 -0
- package/dist/react/recovery/Recovery.d.ts +205 -0
- package/dist/react/recovery/Recovery.js +141 -0
- package/dist/react/recovery/Recovery.restore-steps.d.ts +10 -0
- package/dist/react/recovery/Recovery.restore-steps.js +71 -0
- package/dist/recovery/agent-tools.d.ts +33 -0
- package/dist/recovery/agent-tools.js +166 -0
- package/dist/recovery/drift.d.ts +47 -0
- package/dist/recovery/drift.js +51 -0
- package/dist/recovery/journal-kernel.d.ts +80 -0
- package/dist/recovery/journal-kernel.js +40 -0
- package/dist/recovery/journal-repo.sql.d.ts +154 -0
- package/dist/recovery/journal-repo.sql.js +303 -0
- package/dist/recovery/journal-schema.d.ts +37 -0
- package/dist/recovery/journal-schema.js +110 -0
- package/dist/recovery/migrate-forward-hooks.d.ts +2 -1
- package/dist/recovery/migrate-forward-hooks.js +3 -3
- package/dist/recovery/operation-lock.d.ts +2 -17
- package/dist/recovery/reconcile-interrupted-migration.d.ts +2 -5
- package/dist/recovery/reconcile-interrupted-migration.js +0 -30
- package/dist/recovery/restore-hooks.d.ts +4 -0
- package/dist/recovery/restore-hooks.js +1 -1
- package/dist/recovery/tool-registrations.d.ts +175 -0
- package/dist/recovery/tool-registrations.js +295 -0
- package/dist/site/repo.memory.d.ts +149 -0
- package/dist/site/repo.memory.js +162 -0
- package/dist/site/tool-registrations.d.ts +130 -0
- package/dist/site/tool-registrations.js +184 -0
- package/dist/sqlite/backup-policy.d.ts +14 -0
- package/dist/sqlite/backup-policy.js +47 -3
- package/dist/sqlite/compaction-steps.d.ts +43 -0
- package/dist/sqlite/compaction-steps.js +74 -0
- package/dist/sqlite/compaction.d.ts +63 -0
- package/dist/sqlite/compaction.js +263 -0
- package/dist/sqlite/db-ops.js +10 -11
- package/dist/sqlite/index.d.ts +2 -1
- package/dist/sqlite/index.js +2 -1
- package/dist/sqlite/open.d.ts +2 -1
- package/dist/sqlite/open.js +14 -4
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.js +2 -0
- package/dist/tools/plan-store.d.ts +1 -1
- package/dist/tools/plan-store.js +10 -6
- package/dist/tools/read-tools.d.ts +1 -1
- package/dist/tools/site-db-messages.d.ts +10 -0
- package/dist/tools/site-db-messages.js +23 -0
- package/dist/tools/site-transfer-messages.d.ts +9 -0
- package/dist/tools/site-transfer-messages.js +20 -0
- package/dist/transfer/confirmation-ui.d.ts +19 -0
- package/dist/transfer/confirmation-ui.js +39 -0
- package/dist/transfer/copy-engine.js +11 -11
- package/dist/transfer/copy-order.js +1 -3
- package/dist/transfer/destination-store.d.ts +83 -0
- package/dist/transfer/destination-store.js +82 -0
- package/dist/transfer/index.d.ts +2 -0
- package/dist/transfer/index.js +2 -0
- package/dist/transfer/internal-ddl.d.ts +6 -2
- package/dist/transfer/internal-ddl.js +15 -15
- package/dist/transfer/postgres-ddl.js +2 -2
- package/dist/transfer/schema-catalog.d.ts +148 -0
- package/dist/transfer/schema-catalog.js +141 -0
- package/dist/transfer/sqlite-backup.d.ts +27 -0
- package/dist/transfer/sqlite-backup.js +31 -0
- package/dist/transfer/table-catalog.js +1 -0
- package/dist/watermark/kernel.d.ts +64 -0
- package/dist/watermark/kernel.js +45 -0
- package/package.json +107 -9
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from "react";
|
|
2
|
+
import type { AdminRecoveryStatusEnvelope as AdminRecoveryStatus } from "@jini-ai/core/contracts/site/cms-recovery";
|
|
3
|
+
import { type Translate } from "@jini-ai/core/text";
|
|
4
|
+
type Empty = Record<string, never>;
|
|
5
|
+
interface AdminRestorePoint {
|
|
6
|
+
readonly id: string;
|
|
7
|
+
/** What caused this point to be captured (e.g. `"manual"`, `"pre-migration"`) — host-defined. */
|
|
8
|
+
readonly trigger: string;
|
|
9
|
+
readonly costClass: string;
|
|
10
|
+
readonly kind: string;
|
|
11
|
+
/** Null when the host has no watermark concept or none was available at capture time. */
|
|
12
|
+
readonly watermarkAtCapture: number | null;
|
|
13
|
+
readonly createdAt: string;
|
|
14
|
+
}
|
|
15
|
+
interface AdminDisclosureResult {
|
|
16
|
+
readonly partial: true;
|
|
17
|
+
/** `false` means the disclosure could not establish a watermark baseline to diff against — the
|
|
18
|
+
* `counts` below may be less trustworthy than usual, and a panel should say so rather than
|
|
19
|
+
* present them with the same confidence as a normal disclosure. */
|
|
20
|
+
readonly watermarkBaselineAvailable: boolean;
|
|
21
|
+
readonly counts: Readonly<Record<string, number | "unknown">>;
|
|
22
|
+
}
|
|
23
|
+
interface RecoveryController {
|
|
24
|
+
/** `null` until the initial load settles — the caller renders a loading state. */
|
|
25
|
+
status: AdminRecoveryStatus | null;
|
|
26
|
+
points: AdminRestorePoint[] | null;
|
|
27
|
+
error: string | null;
|
|
28
|
+
/** `creating` reflects the in-flight no-argument restore-point creation request. */
|
|
29
|
+
creating: boolean;
|
|
30
|
+
createRestorePoint: () => Promise<void>;
|
|
31
|
+
/** The restore point a "Restore…" row action selected, or the one a resolved deep link matched —
|
|
32
|
+
* `null` shows the plain list, non-null swaps in `RestoreFlow` (design-spec.md §0.1: a full
|
|
33
|
+
* inline swap, never a modal-over-list). */
|
|
34
|
+
selected: AdminRestorePoint | null;
|
|
35
|
+
setSelected: (point: AdminRestorePoint | null) => void;
|
|
36
|
+
/** Bound translator — `key` already resolved against the caller's locale, so `Recovery.tsx` never
|
|
37
|
+
* imports `useAdminLocale`/`recovery-i18n` for the top-level screen. See this file's header. */
|
|
38
|
+
t: Translate;
|
|
39
|
+
/** Raw resolved locale — `Recovery.tsx`'s local `DegradedBannerView`/`RestorePointsList`
|
|
40
|
+
* subcomponents take `locale` directly rather than a bound translator. See this file's header. */
|
|
41
|
+
locale: string;
|
|
42
|
+
}
|
|
43
|
+
interface RestoreFlowController {
|
|
44
|
+
disclosure: AdminDisclosureResult | null;
|
|
45
|
+
error: string | null;
|
|
46
|
+
acknowledged: boolean;
|
|
47
|
+
setAcknowledged: (checked: boolean) => void;
|
|
48
|
+
step: CeremonyStep;
|
|
49
|
+
busy: boolean;
|
|
50
|
+
ceremonyError: string | null;
|
|
51
|
+
plan: {
|
|
52
|
+
planId: string;
|
|
53
|
+
planHash: string;
|
|
54
|
+
} | null;
|
|
55
|
+
confirmationToken: string | null;
|
|
56
|
+
result: {
|
|
57
|
+
restoreRunId: string;
|
|
58
|
+
state: string;
|
|
59
|
+
restartRequired?: boolean | undefined;
|
|
60
|
+
} | null;
|
|
61
|
+
startPlan: () => Promise<void>;
|
|
62
|
+
doConfirm: () => Promise<void>;
|
|
63
|
+
doExecute: () => Promise<void>;
|
|
64
|
+
/** Bound translator — `key` already resolved against the caller's locale, so `RestoreFlow` never
|
|
65
|
+
* imports `useAdminLocale`/`recovery-i18n` itself. See this file's header. */
|
|
66
|
+
t: Translate;
|
|
67
|
+
/** Raw resolved locale — `RestoreFlow`'s own local step subcomponents and several
|
|
68
|
+
* `recovery-i18n.tsx` helpers take `locale` directly rather than a bound translator. See this
|
|
69
|
+
* file's header. */
|
|
70
|
+
locale: string;
|
|
71
|
+
}
|
|
72
|
+
type CeremonyStep = "idle" | "planned" | "confirmed" | "done";
|
|
73
|
+
export interface RecoveryProps {
|
|
74
|
+
/** The `?tab=` query value from `panels.tsx`'s `recovery` route (`URLSearchParams.get` returns
|
|
75
|
+
* `null` when the param is absent). Validated by `useRecoveryNavigation`. */
|
|
76
|
+
tabId?: string | null;
|
|
77
|
+
/**
|
|
78
|
+
* Dependency injection seam for tests — the same convention `@jini-ai/ui`'s `CustomSelect` uses
|
|
79
|
+
* for `useCustomSelect`. The host supplies its wired hook. See `PostsProps.usePostsHook` for the full rationale.
|
|
80
|
+
*/
|
|
81
|
+
useRecoveryHook: () => RecoveryController;
|
|
82
|
+
useRestoreFlowHook: (required: {
|
|
83
|
+
point: AdminRestorePoint;
|
|
84
|
+
}, options?: Empty) => RestoreFlowController;
|
|
85
|
+
useRecoveryNavigationHook: (required: {
|
|
86
|
+
tabId?: string | null | undefined;
|
|
87
|
+
setSelected: (point: AdminRestorePoint | null) => void;
|
|
88
|
+
port: RecoveryProps["navigationPort"];
|
|
89
|
+
}, options?: Empty) => {
|
|
90
|
+
activeTabId: string;
|
|
91
|
+
onTabChange: (nextTabId: string) => void;
|
|
92
|
+
onSelectPoint: (point: AdminRestorePoint) => void;
|
|
93
|
+
onBackFromFlow: () => void;
|
|
94
|
+
};
|
|
95
|
+
navigationPort: {
|
|
96
|
+
navigate: (required: {
|
|
97
|
+
routePath: string;
|
|
98
|
+
}, options: {
|
|
99
|
+
replace?: boolean;
|
|
100
|
+
}) => void;
|
|
101
|
+
};
|
|
102
|
+
kit: {
|
|
103
|
+
DataTable: ComponentType<{
|
|
104
|
+
rows: readonly AdminRestorePoint[];
|
|
105
|
+
rowKey: (row: AdminRestorePoint, index: number) => string;
|
|
106
|
+
empty: ReactNode;
|
|
107
|
+
columns: readonly {
|
|
108
|
+
key: string;
|
|
109
|
+
header?: ReactNode;
|
|
110
|
+
headerLabel?: string;
|
|
111
|
+
cell: (row: AdminRestorePoint, index: number) => ReactNode;
|
|
112
|
+
}[];
|
|
113
|
+
}>;
|
|
114
|
+
I18nProvider: ComponentType<{
|
|
115
|
+
initialLocale: string;
|
|
116
|
+
dictionaries: RecoveryProps["dictionaries"];
|
|
117
|
+
fallbackLocale: "en";
|
|
118
|
+
syncDocumentAttributes: false;
|
|
119
|
+
children: ReactNode;
|
|
120
|
+
}>;
|
|
121
|
+
SettingsDialogShell: ComponentType<{
|
|
122
|
+
tabs: readonly {
|
|
123
|
+
id: string;
|
|
124
|
+
label: string;
|
|
125
|
+
title: string;
|
|
126
|
+
panel: ReactNode;
|
|
127
|
+
}[];
|
|
128
|
+
activeTabId: string;
|
|
129
|
+
onActiveTabIdChange: (tabId: string) => void;
|
|
130
|
+
presentation: "inline";
|
|
131
|
+
className: string;
|
|
132
|
+
fullscreenEnabled: false;
|
|
133
|
+
dialogAriaLabelledBy: string;
|
|
134
|
+
labels: {
|
|
135
|
+
kicker: string;
|
|
136
|
+
sidebarAriaLabel: string;
|
|
137
|
+
};
|
|
138
|
+
}>;
|
|
139
|
+
};
|
|
140
|
+
ServerLabel: ComponentType<{
|
|
141
|
+
value: string;
|
|
142
|
+
}>;
|
|
143
|
+
dictionaries: Partial<Record<string, Record<string, string>>>;
|
|
144
|
+
viewerTimeZone: string;
|
|
145
|
+
copy: {
|
|
146
|
+
t: (required: {
|
|
147
|
+
locale: string;
|
|
148
|
+
key: string;
|
|
149
|
+
}, options?: Empty) => string;
|
|
150
|
+
sinceDiscardMessage: (required: {
|
|
151
|
+
locale: string;
|
|
152
|
+
createdAt: string;
|
|
153
|
+
}, options?: Empty) => ReactNode;
|
|
154
|
+
discardCountLine: (required: {
|
|
155
|
+
locale: string;
|
|
156
|
+
count: number | "unknown";
|
|
157
|
+
categoryLabelText: string;
|
|
158
|
+
classNames: {
|
|
159
|
+
row: string;
|
|
160
|
+
quantity: string;
|
|
161
|
+
category: string;
|
|
162
|
+
};
|
|
163
|
+
}, options?: Empty) => ReactNode;
|
|
164
|
+
baselineUnavailableMessage: (required: {
|
|
165
|
+
locale: string;
|
|
166
|
+
}, options?: Empty) => ReactNode;
|
|
167
|
+
restorePlanReadyMessage: (required: {
|
|
168
|
+
locale: string;
|
|
169
|
+
planId: string;
|
|
170
|
+
}, options?: Empty) => ReactNode;
|
|
171
|
+
restoreDoneMessage: (required: {
|
|
172
|
+
locale: string;
|
|
173
|
+
restoreRunId: string;
|
|
174
|
+
stateNode: ReactNode;
|
|
175
|
+
}, options?: Empty) => ReactNode;
|
|
176
|
+
categoryLabel: (required: {
|
|
177
|
+
category: string;
|
|
178
|
+
locale: string;
|
|
179
|
+
}, options?: Empty) => string;
|
|
180
|
+
costClassLabel: (required: {
|
|
181
|
+
costClass: string;
|
|
182
|
+
locale: string;
|
|
183
|
+
}, options?: Empty) => string;
|
|
184
|
+
isAssertiveRecoveryBanner: (banner: NonNullable<AdminRecoveryStatus["banner"]>) => boolean;
|
|
185
|
+
recoveryBannerTone: (banner: NonNullable<AdminRecoveryStatus["banner"]>) => "error" | "warning" | "";
|
|
186
|
+
restoreButtonAccessibleName: (required: {
|
|
187
|
+
locale: string;
|
|
188
|
+
point: Pick<AdminRestorePoint, "createdAt">;
|
|
189
|
+
viewerTimeZone: string;
|
|
190
|
+
}, options?: Empty) => string;
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
export interface RestoreFlowProps {
|
|
194
|
+
point: AdminRestorePoint;
|
|
195
|
+
onBack: () => void;
|
|
196
|
+
/** Dependency injection seam for tests — see `PostsProps.usePostsHook` for the convention.
|
|
197
|
+
* The host supplies its wired restore hook. */
|
|
198
|
+
useRestoreFlowHook: RecoveryProps["useRestoreFlowHook"];
|
|
199
|
+
copy: RecoveryProps["copy"];
|
|
200
|
+
ServerLabel: RecoveryProps["ServerLabel"];
|
|
201
|
+
viewerTimeZone: string;
|
|
202
|
+
}
|
|
203
|
+
export declare function Recovery({ useRecoveryHook, tabId, useRecoveryNavigationHook, useRestoreFlowHook, navigationPort, kit: { I18nProvider, SettingsDialogShell }, kit, ServerLabel, dictionaries, copy, viewerTimeZone }: RecoveryProps): import("react").JSX.Element;
|
|
204
|
+
export {};
|
|
205
|
+
//# sourceMappingURL=Recovery.d.ts.map
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { agentHandle, buildAgentListHandles } from "@jini-ai/core/agent-handles";
|
|
3
|
+
import { formatTimestamp } from "@jini-ai/core/text";
|
|
4
|
+
import { RestoreFlowBody } from "./Recovery.restore-steps.js";
|
|
5
|
+
/**
|
|
6
|
+
* @file Recovery screen (design-spec.md §4, ADR-045) — the `/admin/recovery` route.
|
|
7
|
+
*
|
|
8
|
+
* Per design-spec.md §0.1: one screen, holding every restore-point capability — never a separate
|
|
9
|
+
* "Backups" route (ADR-045 explicitly rejects that shape). `development/todos.md`'s "Recovery vs
|
|
10
|
+
* Database's Restore Points tab" entry (owner, 2026-09-10, superseded same morning) is the reason
|
|
11
|
+
* this now has two tabs rather than Database's old three: Database's `RestorePointsSection`
|
|
12
|
+
* (list + create, no restore action) moved here in full, and Database's own `restore-points` tab
|
|
13
|
+
* was removed — restore points were never a "database" concern per the owner's own call. This
|
|
14
|
+
* still applies §6's own recommendation (a full swap, not a modal-over-list) — the swap is now
|
|
15
|
+
* between the two tabs below instead of an untabbed inline ternary.
|
|
16
|
+
*
|
|
17
|
+
* ## Tabs (2026-09-10)
|
|
18
|
+
*
|
|
19
|
+
* The initial implementation chose `TabBar` because this is a list-plus-ceremony operational
|
|
20
|
+
* surface, the same shape as Database, rather than a settings form. The owner's explicit
|
|
21
|
+
* `SettingsDialogShell` requirement takes precedence (2026-10-04 cleanup): the inline shell now
|
|
22
|
+
* matches Agent Plugins, while retaining `?tab=` deep-linking and replace-history navigation.
|
|
23
|
+
* Two tabs: **Restore points** (`RestorePointsPanel` — the list, the create action, and
|
|
24
|
+
* the entry point into a restore) and **Restore** (`RestoreTabPanel` — `RestoreFlow` for whichever
|
|
25
|
+
* point is selected, or a prompt back to the list when nothing is selected yet). Selecting a row
|
|
26
|
+
* and confirming/cancelling the ceremony both navigate between the two tabs explicitly (see
|
|
27
|
+
* `use-recovery-navigation.hooks.ts`) rather than deriving the active tab from `selected` — both
|
|
28
|
+
* sections stay independently reachable either way, same as Database's URL-owned tabs.
|
|
29
|
+
*
|
|
30
|
+
* The restore ceremony (`plan`/`confirm`/`execute`, SPEC-019 C-301/C-302/C-303) is wired to the
|
|
31
|
+
* real `core/gated-mutations`-backed routes (Session 5-6 backend gap closure). `executeRestore`
|
|
32
|
+
* now physically swaps `content.db` (2026-07-16, `DbOpsPort.restoreFromArtifact` — an atomic
|
|
33
|
+
* same-filesystem rename, closing the previously-disclosed "ledger-only" gap). Restart-based, by
|
|
34
|
+
* design, not a live hot-swap: the already-running process keeps its own open file handle to the
|
|
35
|
+
* pre-restore data until an operator restarts it — `restartRequired: true` on the response is
|
|
36
|
+
* that signal, surfaced below rather than silently implied.
|
|
37
|
+
*
|
|
38
|
+
* ## Markup only
|
|
39
|
+
*
|
|
40
|
+
* `Recovery`'s own list/status/create state lives in `hooks/use-recovery.hooks.ts`; `RestoreFlow`'s
|
|
41
|
+
* ceremony state lives in `hooks/use-restore-flow.hooks.ts` — independent state with its own
|
|
42
|
+
* lifecycle, keyed to whichever restore point is selected. `DegradedBannerView`,
|
|
43
|
+
* `RestorePointsList`, `RestorePointsPanel`, and `DisclosurePanel` hold no state of their own and
|
|
44
|
+
* stay as plain, props-driven presentation with no hook. Pure logic (category labels, cost-class
|
|
45
|
+
* badge text/tone, the banner urgency check and severity, the deep-link envelope parse) lives in
|
|
46
|
+
* `rules.ts`.
|
|
47
|
+
*
|
|
48
|
+
* `src/__tests__/unit/admin-nav-recovery-acs.unit.test.ts` reads this file's source directly
|
|
49
|
+
* (`readFileSync`) to assert AC-32 against the `page-description` copy below — keep that
|
|
50
|
+
* `className="page-description">...</p>` line intact if editing the header copy.
|
|
51
|
+
*
|
|
52
|
+
* `locale`/`t`: `Recovery` and `RestoreFlow` each have their own hook (`useRecovery`,
|
|
53
|
+
* `useRestoreFlow`), and each hook already independently calls `useAdminLocale()` for its own
|
|
54
|
+
* error-string translations — so each component now gets `t`/`locale` from its OWN hook rather than
|
|
55
|
+
* `Recovery` threading a single resolved `locale` down as a prop, per the standing i18n rule. This
|
|
56
|
+
* adds no new fetch (see each hook's own file header). `DegradedBannerView`/`RestorePointsList`/
|
|
57
|
+
* `RestorePointsPanel` have no hook of their own, so they keep receiving `locale` as a prop from
|
|
58
|
+
* `Recovery` and receive the unbound translator from the host.
|
|
59
|
+
*/
|
|
60
|
+
function DegradedBannerView(props) {
|
|
61
|
+
const { locale, status, copy: { t, isAssertiveRecoveryBanner, recoveryBannerTone } } = props;
|
|
62
|
+
const banner = status.banner;
|
|
63
|
+
if (!banner)
|
|
64
|
+
return null;
|
|
65
|
+
// AC-27/EC-06/INV-07: `pending-migration`'s action always deep-links to Database's own
|
|
66
|
+
// migration ceremony, never a Recovery restore action — restoring to an older snapshot does not
|
|
67
|
+
// resolve schema drift against the current runtime.
|
|
68
|
+
const assertive = isAssertiveRecoveryBanner(banner);
|
|
69
|
+
// Not every degraded state is equally bad — see `recoveryBannerTone`'s own doc comment.
|
|
70
|
+
const tone = recoveryBannerTone(banner);
|
|
71
|
+
return (_jsxs("div", { className: `notice ${tone} recovery-degraded-banner recovery-plain-notice`, role: assertive ? "alert" : undefined, "aria-live": assertive ? "assertive" : "polite", children: [_jsx("span", { children: banner.accessibleText }), banner.actionKind === "deep-link-to-database-migration" ? (_jsx("a", { className: "btn-secondary", href: "/admin/database", ...agentHandle({ handle: "recovery-banner-go-to-database" }, { role: "link", label: "Go to Database to resolve the pending migration" }), children: t({ locale: locale, key: "Go to Database" }) })) : null, banner.actionKind === "unblock-interrupted-migration" ? (_jsx("button", { type: "button", disabled: true, title: t({ locale: locale, key: "No unblock route exists yet — see this screen's file header." }), ...agentHandle({ handle: "recovery-banner-unblock" }, { role: "button", label: "Unblock an interrupted migration (not yet available)" }), children: t({ locale: locale, key: "Unblock (not yet available)" }) })) : null] }));
|
|
72
|
+
}
|
|
73
|
+
function RestorePointsList(props) {
|
|
74
|
+
const { locale, kit: { DataTable }, copy: { t, costClassLabel, restoreButtonAccessibleName }, viewerTimeZone: VIEWER_TIME_ZONE } = props;
|
|
75
|
+
// Restore-point ids are stable and unique, same per-row-handle derivation every other list on
|
|
76
|
+
// this workstream uses (`buildAgentListHandles`) — needed because `DataTable`'s `cell` callback
|
|
77
|
+
// only receives the row, not its index.
|
|
78
|
+
const rowHandles = buildAgentListHandles({ prefix: "recovery-row", ids: props.points.map((p) => p.id) });
|
|
79
|
+
const rowHandleById = new Map(props.points.map((p, index) => [p.id, rowHandles[index]]));
|
|
80
|
+
return (_jsx(DataTable, { rows: props.points, rowKey: (p) => p.id, empty: _jsx("div", { className: "card", children: _jsx("div", { className: "empty-state", children: _jsx("p", { children: t({ locale: locale, key: "No restore points yet." }) }) }) }), columns: [
|
|
81
|
+
{ key: "timestamp", header: t({ locale: locale, key: "Timestamp" }), cell: (p) => formatTimestamp({ iso: p.createdAt }, { viewerTimeZone: VIEWER_TIME_ZONE }) },
|
|
82
|
+
{ key: "trigger", header: t({ locale: locale, key: "Trigger" }), cell: (p) => p.trigger },
|
|
83
|
+
{
|
|
84
|
+
key: "cost-class",
|
|
85
|
+
header: t({ locale: locale, key: "Cost class" }),
|
|
86
|
+
cell: (p) => _jsx("span", { className: `status status-${p.costClass}`, children: costClassLabel({ costClass: p.costClass, locale: locale }) }),
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
key: "restore",
|
|
90
|
+
cell: (p) => p.costClass === "unavailable" ? (_jsx("span", { className: "muted-cell", children: t({ locale: locale, key: "No restore-point mechanism available — see the runbook." }) })) : (_jsx("button", { type: "button", onClick: () => props.onSelect(p), "aria-label": restoreButtonAccessibleName({ locale: locale, point: p, viewerTimeZone: VIEWER_TIME_ZONE }), ...agentHandle({ handle: `${rowHandleById.get(p.id)}-restore` }, { role: "button", label: "Begin the restore ceremony for this restore point" }), children: t({ locale: locale, key: "Restore…" }) })),
|
|
91
|
+
},
|
|
92
|
+
] }));
|
|
93
|
+
}
|
|
94
|
+
/** The "Restore points" tab's full panel — `RestorePointsList` (unchanged from before the tabs
|
|
95
|
+
* pass) plus the create action Database's own `RestorePointsSection` used to own
|
|
96
|
+
* (`development/todos.md`'s "Recovery vs Database's Restore Points tab" entry, 2026-09-10). Split
|
|
97
|
+
* out from `RestorePointsList` itself, rather than folding the header/button into it, so the bare
|
|
98
|
+
* list stays reusable exactly as it already is for anything that only needs the table (there is no
|
|
99
|
+
* such caller today, but the split cost nothing and matches how `Database.tsx`'s own
|
|
100
|
+
* `RestorePointsSection` kept its header separate from its `DataTable` call). */
|
|
101
|
+
function RestorePointsPanel(props) {
|
|
102
|
+
const { locale, kit, copy, viewerTimeZone, copy: { t } } = props;
|
|
103
|
+
return (_jsxs("div", { children: [_jsxs("div", { className: "editor-header", children: [_jsx("h2", { children: t({ locale: locale, key: "Restore points" }) }), _jsx("button", { type: "button", onClick: () => props.onCreate(), disabled: props.creating, ...agentHandle({ handle: "recovery-create-restore-point" }, { role: "button", label: "Create a new restore point now" }), children: props.creating ? t({ locale: locale, key: "Creating…" }) : t({ locale: locale, key: "Create restore point" }) })] }), _jsx(RestorePointsList, { locale: locale, points: props.points, onSelect: props.onSelect, kit: kit, copy: copy, viewerTimeZone: viewerTimeZone })] }));
|
|
104
|
+
}
|
|
105
|
+
function RestoreFlow({ point, onBack, useRestoreFlowHook, copy, ServerLabel, viewerTimeZone }) {
|
|
106
|
+
const controller = useRestoreFlowHook({ point });
|
|
107
|
+
return _jsx(RestoreFlowBody, { point: point, onBack: onBack, controller: controller, copy: copy, ServerLabel: ServerLabel, viewerTimeZone: viewerTimeZone });
|
|
108
|
+
}
|
|
109
|
+
/** The "Restore" tab's own panel — `RestoreFlow` for whichever point is selected, or a prompt back
|
|
110
|
+
* to the "Restore points" tab when nothing is selected yet (a direct `?tab=restore` visit, or the
|
|
111
|
+
* ceremony was already backed out of via `onBack`). Originally split out so `recoveryTabPanel`
|
|
112
|
+
* stayed a flat dispatch (Database's same complexity-gate reason). The shared shell now owns
|
|
113
|
+
* that dispatch; this component keeps the selected-point guard out of the page's markup. */
|
|
114
|
+
function RestoreTabPanel(props) {
|
|
115
|
+
if (!props.selected) {
|
|
116
|
+
return (_jsx("div", { className: "notice", children: _jsx("p", { children: props.copy.t({ locale: props.locale, key: "Select a restore point from the Restore points tab to begin." }) }) }));
|
|
117
|
+
}
|
|
118
|
+
return _jsx(RestoreFlow, { point: props.selected, onBack: props.onBack, useRestoreFlowHook: props.useRestoreFlowHook, copy: props.copy, ServerLabel: props.ServerLabel, viewerTimeZone: props.viewerTimeZone });
|
|
119
|
+
}
|
|
120
|
+
export function Recovery({ useRecoveryHook, tabId, useRecoveryNavigationHook, useRestoreFlowHook, navigationPort, kit: { I18nProvider, SettingsDialogShell }, kit, ServerLabel, dictionaries, copy, viewerTimeZone }) {
|
|
121
|
+
const { status, points, error, creating, createRestorePoint, selected, setSelected, t, locale } = useRecoveryHook();
|
|
122
|
+
const { activeTabId, onTabChange, onSelectPoint, onBackFromFlow } = useRecoveryNavigationHook({ tabId, setSelected, port: navigationPort });
|
|
123
|
+
if (error && !points)
|
|
124
|
+
return _jsx("div", { className: "notice error", children: error });
|
|
125
|
+
if (!points || !status)
|
|
126
|
+
return _jsx("div", { className: "notice", children: t("Loading restore points…") });
|
|
127
|
+
// The former recoveryTabPanel used a flat dispatch to avoid nested JSX branch complexity.
|
|
128
|
+
// The shell now owns that dispatch: each tab supplies one presentation-only panel.
|
|
129
|
+
const tabs = [
|
|
130
|
+
{
|
|
131
|
+
id: "restore-points", label: t("Restore points"), title: t("Recovery"),
|
|
132
|
+
panel: _jsx(RestorePointsPanel, { kit: kit, copy: copy, viewerTimeZone: viewerTimeZone, locale: locale, points: points, creating: creating, onCreate: createRestorePoint, onSelect: onSelectPoint }),
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
id: "restore", label: t("Restore"), title: t("Recovery"),
|
|
136
|
+
panel: _jsx(RestoreTabPanel, { useRestoreFlowHook: useRestoreFlowHook, copy: copy, ServerLabel: ServerLabel, viewerTimeZone: viewerTimeZone, locale: locale, selected: selected, onBack: onBackFromFlow }),
|
|
137
|
+
},
|
|
138
|
+
];
|
|
139
|
+
return (_jsxs("div", { className: "page", children: [_jsx("div", { className: "page-header", children: _jsxs("div", { className: "page-header-text", children: [_jsx("p", { className: "page-kicker", children: t("Operations") }), _jsx("h1", { className: "page-title", children: t("Recovery") }), _jsx("p", { className: "page-description", children: t("Restore this site to a previous point in time using a captured restore point.") })] }) }), error ? _jsx("div", { className: "notice error", children: error }) : null, _jsx(DegradedBannerView, { locale: locale, status: status, copy: copy }), _jsx(I18nProvider, { initialLocale: locale, dictionaries: dictionaries, fallbackLocale: "en", syncDocumentAttributes: false, children: _jsx("div", { className: "settings-ui-section settings-ui-section--page-flow recovery-section", ...agentHandle({ handle: "recovery-tab-bar" }, { role: "region", label: t("Recovery") }), children: _jsx(SettingsDialogShell, { tabs: tabs, activeTabId: activeTabId, onActiveTabIdChange: onTabChange, presentation: "inline", className: "jini-tabbed-dialog--inline", fullscreenEnabled: false, dialogAriaLabelledBy: "recovery-shell-title", labels: { kicker: "", sidebarAriaLabel: t("Recovery") } }) }) })] }));
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=Recovery.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { RecoveryProps, RestoreFlowProps } from "./Recovery.js";
|
|
2
|
+
export declare function RestoreFlowBody({ point, onBack, controller, copy, ServerLabel, viewerTimeZone: VIEWER_TIME_ZONE }: {
|
|
3
|
+
point: RestoreFlowProps["point"];
|
|
4
|
+
onBack: () => void;
|
|
5
|
+
controller: ReturnType<RecoveryProps["useRestoreFlowHook"]>;
|
|
6
|
+
copy: RecoveryProps["copy"];
|
|
7
|
+
ServerLabel: RecoveryProps["ServerLabel"];
|
|
8
|
+
viewerTimeZone: string;
|
|
9
|
+
}): import("react").JSX.Element;
|
|
10
|
+
//# sourceMappingURL=Recovery.restore-steps.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { agentHandle } from "@jini-ai/core/agent-handles";
|
|
3
|
+
import { formatTimestamp } from "@jini-ai/core/text";
|
|
4
|
+
/** This stylesheet's discard-count row classes (`.recovery-loss-qty` carries the numeral's weight). */
|
|
5
|
+
const RECOVERY_LOSS_CLASSES = { row: "recovery-loss-row", quantity: "recovery-loss-qty", category: "recovery-loss-what" };
|
|
6
|
+
/** Step 2 — the discarded-write-window disclosure (design-spec.md §4.3): the load-bearing,
|
|
7
|
+
* blocking centerpiece of this screen. Renders only categories the server response actually
|
|
8
|
+
* contains (never a placeholder row for an uncovered category), and renders `"unknown"` distinctly
|
|
9
|
+
* from `0` (INV-05 — a `0` implies verified-zero-loss, `"unknown"` means the baseline could not be
|
|
10
|
+
* computed at all; these must never be conflated). */
|
|
11
|
+
function DisclosurePanel(props) {
|
|
12
|
+
const { locale, copy: { t, sinceDiscardMessage, discardCountLine, categoryLabel, baselineUnavailableMessage } } = props;
|
|
13
|
+
const categories = Object.entries(props.disclosure.counts);
|
|
14
|
+
return (_jsxs("div", { className: "recovery-disclosure-panel", children: [_jsxs("div", { className: "recovery-loss-manifest", children: [_jsx("p", { className: "recovery-loss-lede", children: sinceDiscardMessage({ locale: locale, createdAt: props.point.createdAt }) }), _jsx("ul", { className: "recovery-loss-list", children: categories.map(([category, count]) => (_jsx("li", { children: discardCountLine({ locale: locale, count: count, categoryLabelText: categoryLabel({ category: category, locale: locale }), classNames: RECOVERY_LOSS_CLASSES }) }, category))) }), _jsx("p", { className: "recovery-loss-caveat", children: t({ locale: locale, key: "This covers watermark-stamped write paths only (posts/pages and plugin-table writes today) and is NOT a complete count of everything written since this restore point — change-sets, taxonomy writes, Collections entries, and sessions are not yet counted here." }) })] }), !props.disclosure.watermarkBaselineAvailable ? (_jsx("p", { className: "save-error recovery-baseline-alarm", role: "alert", children: baselineUnavailableMessage({ locale: locale }) })) : null, _jsxs("label", { id: "recovery-ack-label", className: "recovery-ack-gate", children: [_jsx("input", { type: "checkbox", checked: props.acknowledged, onChange: (e) => props.onAcknowledgeChange(e.target.checked), ...agentHandle({ handle: "recovery-disclosure-acknowledge" }, {
|
|
15
|
+
role: "field",
|
|
16
|
+
label: "Acknowledge the discarded-write-window disclosure",
|
|
17
|
+
}) }), t({ locale: locale, key: "I understand this count is partial, not exhaustive, and accept the loss window described above." })] })] }));
|
|
18
|
+
}
|
|
19
|
+
/** The disclosure section (top of `RestoreFlow`): the discarded-write-window error, its loading
|
|
20
|
+
* placeholder, or the panel itself, in that priority order. Split out because — along with
|
|
21
|
+
* `RestoreCeremonySteps` below — this is one of the two independent "wide branch set" halves of
|
|
22
|
+
* the original `RestoreFlow`: this half decides what to show about data loss, the other half
|
|
23
|
+
* decides what to show about ceremony progress, and neither needs the other's branches in scope. */
|
|
24
|
+
function RestoreDisclosureStatus(props) {
|
|
25
|
+
const { locale, point, disclosure, error, acknowledged, onAcknowledgeChange, copy, copy: { t } } = props;
|
|
26
|
+
if (error)
|
|
27
|
+
return _jsx("div", { className: "notice error", children: error });
|
|
28
|
+
if (!disclosure)
|
|
29
|
+
return _jsx("div", { className: "notice", children: t({ locale: locale, key: "Computing the discarded-write-window disclosure…" }) });
|
|
30
|
+
return _jsx(DisclosurePanel, { locale: locale, point: point, disclosure: disclosure, acknowledged: acknowledged, onAcknowledgeChange: onAcknowledgeChange, copy: copy });
|
|
31
|
+
}
|
|
32
|
+
/** Step 3a (design-spec.md §4.3) — acknowledge-gated entry into the ceremony. Its own component
|
|
33
|
+
* (rather than inline in `RestoreCeremonySteps`) because the busy-label ternary and the
|
|
34
|
+
* not-yet-acknowledged `title` ternary would otherwise nest two levels deep inside that
|
|
35
|
+
* function's own `step === "idle"` branch — exactly the nesting SonarJS's cognitive-complexity
|
|
36
|
+
* rule penalises beyond what the cyclomatic count shows. */
|
|
37
|
+
function RestoreIdleStep(props) {
|
|
38
|
+
const { locale, acknowledged, busy, onStart, copy: { t } } = props;
|
|
39
|
+
return (_jsx("div", { className: "recovery-ceremony-step", children: _jsx("button", { type: "button", className: "btn-primary", disabled: !acknowledged || busy, "aria-describedby": "recovery-ack-label", title: !acknowledged ? t({ locale: locale, key: "Acknowledge the disclosure above to continue." }) : undefined, onClick: onStart, ...agentHandle({ handle: "recovery-restore-start" }, { role: "button", label: "Continue to confirm the restore" }), children: busy ? t({ locale: locale, key: "Planning…" }) : t({ locale: locale, key: "Continue to confirm" }) }) }));
|
|
40
|
+
}
|
|
41
|
+
/** Step 3b (SPEC-019 C-301) — plan issued, not yet confirmed. */
|
|
42
|
+
function RestorePlannedStep(props) {
|
|
43
|
+
const { locale, planId, busy, onConfirm, copy: { t, restorePlanReadyMessage } } = props;
|
|
44
|
+
return (_jsxs("div", { className: "recovery-ceremony-step", children: [_jsx("p", { children: restorePlanReadyMessage({ locale: locale, planId: planId }) }), _jsx("button", { type: "button", className: "btn-secondary", onClick: onConfirm, disabled: busy, ...agentHandle({ handle: "recovery-restore-confirm" }, { role: "button", label: "Confirm the planned restore, issuing a one-time execution token" }), children: busy ? t({ locale: locale, key: "Confirming…" }) : t({ locale: locale, key: "Confirm restore" }) })] }));
|
|
45
|
+
}
|
|
46
|
+
/** Step 3c (SPEC-019 C-302) — confirmed, execution token in hand, not yet executed. */
|
|
47
|
+
function RestoreConfirmedStep(props) {
|
|
48
|
+
const { locale, busy, onExecute, copy: { t } } = props;
|
|
49
|
+
return (_jsxs("div", { className: "recovery-ceremony-step", children: [_jsx("p", { children: t({ locale: locale, key: "Confirmed. Executing performs the restore — this cannot be undone." }) }), _jsx("button", { type: "button", className: "btn-danger", onClick: onExecute, disabled: busy, ...agentHandle({ handle: "recovery-restore-execute" }, { role: "button", label: "Execute the confirmed restore now — cannot be undone" }), children: busy ? t({ locale: locale, key: "Restoring…" }) : t({ locale: locale, key: "Execute restore" }) })] }));
|
|
50
|
+
}
|
|
51
|
+
/** Step 3d (SPEC-019 C-303) — the ceremony's terminal state. `restartRequired` (2026-07-16,
|
|
52
|
+
* `DbOpsPort.restoreFromArtifact`) surfaces the "already-running process still holds the
|
|
53
|
+
* pre-restore file handle" caveat described in this file's header, rather than silently implying
|
|
54
|
+
* a live hot-swap happened. */
|
|
55
|
+
function RestoreDoneStep(props) {
|
|
56
|
+
const { locale, restoreRunId, state, restartRequired, ServerLabel, copy: { t, restoreDoneMessage } } = props;
|
|
57
|
+
return (_jsxs("div", { className: "recovery-ceremony-step", children: [_jsx("p", { role: "status", children: restoreDoneMessage({ locale: locale, restoreRunId: restoreRunId, stateNode: _jsx("span", { className: `status status-${state}`, children: _jsx(ServerLabel, { value: state }) }) }) }), restartRequired ? (_jsx("p", { className: "save-error", role: "alert", children: t({ locale: locale, key: "The database file was replaced — this server process is still serving the pre-restore data from its open connection. Restart the server now to pick up the restored data." }) })) : null] }));
|
|
58
|
+
}
|
|
59
|
+
/** The four-stage ceremony switch (idle → planned → confirmed → done) plus its own error slot.
|
|
60
|
+
* Exactly one of the four step components below renders at a time, keyed off `step` — this
|
|
61
|
+
* function owns that selection so `RestoreFlow` itself doesn't have to. */
|
|
62
|
+
function RestoreCeremonySteps(props) {
|
|
63
|
+
const { locale, ceremonyError, step, busy, acknowledged, plan, confirmationToken, result, onStart, onConfirm, onExecute, copy, ServerLabel } = props;
|
|
64
|
+
return (_jsxs(_Fragment, { children: [ceremonyError ? _jsx("div", { className: "notice error", children: ceremonyError }) : null, step === "idle" ? _jsx(RestoreIdleStep, { locale: locale, acknowledged: acknowledged, busy: busy, onStart: onStart, copy: copy }) : null, step === "planned" && plan ? _jsx(RestorePlannedStep, { locale: locale, planId: plan.planId, busy: busy, onConfirm: onConfirm, copy: copy }) : null, step === "confirmed" && confirmationToken ? _jsx(RestoreConfirmedStep, { locale: locale, busy: busy, onExecute: onExecute, copy: copy }) : null, step === "done" && result ? (_jsx(RestoreDoneStep, { locale: locale, restoreRunId: result.restoreRunId, state: result.state, restartRequired: result.restartRequired, copy: copy, ServerLabel: ServerLabel })) : null] }));
|
|
65
|
+
}
|
|
66
|
+
export function RestoreFlowBody({ point, onBack, controller, copy, ServerLabel, viewerTimeZone: VIEWER_TIME_ZONE }) {
|
|
67
|
+
const { costClassLabel } = copy;
|
|
68
|
+
const { disclosure, error, acknowledged, setAcknowledged, step, busy, ceremonyError, plan, confirmationToken, result, startPlan, doConfirm, doExecute, t, locale, } = controller;
|
|
69
|
+
return (_jsxs("div", { className: "recovery-restore-docket", children: [_jsx("button", { type: "button", className: "btn-ghost recovery-back-link", onClick: onBack, ...agentHandle({ handle: "recovery-back-to-list" }, { role: "button", label: "Back to the restore points list" }), children: t("← Restore points") }), _jsxs("div", { className: "card recovery-restore-card", children: [_jsxs("div", { className: "recovery-ceremony-summary", children: [_jsxs("div", { className: "recovery-restore-title-row", children: [_jsxs("h2", { className: "recovery-restore-title", children: [t("Restore to"), " ", formatTimestamp({ iso: point.createdAt }, { viewerTimeZone: VIEWER_TIME_ZONE })] }), _jsx("span", { className: "visually-hidden", children: t("Cost class") }), _jsx("span", { className: `status status-${point.costClass}`, children: costClassLabel({ costClass: point.costClass, locale: locale }) })] }), _jsxs("p", { className: "recovery-restore-meta", children: [_jsxs("span", { children: [_jsx("span", { className: "recovery-meta-key", children: t("Trigger") }), _jsx("span", { className: "recovery-meta-value", children: point.trigger })] }), _jsxs("span", { children: [_jsx("span", { className: "recovery-meta-key", children: t("Kind") }), _jsx("span", { className: "recovery-meta-value", children: point.kind })] })] })] }), _jsx(RestoreDisclosureStatus, { copy: copy, locale: locale, point: point, disclosure: disclosure, error: error, acknowledged: acknowledged, onAcknowledgeChange: setAcknowledged }), _jsx(RestoreCeremonySteps, { copy: copy, ServerLabel: ServerLabel, locale: locale, ceremonyError: ceremonyError, step: step, busy: busy, acknowledged: acknowledged, plan: plan, confirmationToken: confirmationToken, result: result, onStart: startPlan, onConfirm: doConfirm, onExecute: doExecute })] })] }));
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=Recovery.restore-steps.js.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { AgentToolDefinition as SharedAgentToolDefinition } from "@jini-ai/core";
|
|
2
|
+
export type AgentToolSideEffect = "none" | "mutates-durable-state" | "mints-token";
|
|
3
|
+
export type { AgentToolActorClassRule } from "@jini-ai/core";
|
|
4
|
+
/**
|
|
5
|
+
* JSON Schema for this tool's `input`, published via `ToolDescriptor.inputSchema` (the host's
|
|
6
|
+
* registration pass refuses to wire any tool lacking one). Optional, matching the other catalogs.
|
|
7
|
+
*/
|
|
8
|
+
export type AgentToolDefinition = SharedAgentToolDefinition & {
|
|
9
|
+
sideEffects: AgentToolSideEffect;
|
|
10
|
+
};
|
|
11
|
+
/** Host wording bound into the recovery catalog's model-facing guidance. */
|
|
12
|
+
export interface RecoveryAgentToolCatalogArgs {
|
|
13
|
+
/** Sentences inserted into `backup_get_capabilities`: the host's repository-backup tools and its portable export path. */
|
|
14
|
+
readonly backupWorkflowGuidance: string;
|
|
15
|
+
/** The host read tool(s) that return a restore point id, named in the `restorePointId` field description. */
|
|
16
|
+
readonly restorePointIdSource: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Recovery's fixed agent-tool catalog: reads are freely agent-callable under `backup.read`;
|
|
20
|
+
* `backup_execute_restore` is the one destructive, token-gated tool
|
|
21
|
+
* (`confirmer-must-equal-own-delegatedBy`); `backup_create_restore_point` is an ordinary
|
|
22
|
+
* mutation, never wrapped in a plan/confirm/execute sequence — but see this file's header for why
|
|
23
|
+
* it is nonetheless left unwired from the recovery registrations.
|
|
24
|
+
*
|
|
25
|
+
* @param args.backupWorkflowGuidance - the host's repository-backup / export sentences.
|
|
26
|
+
* @param args.restorePointIdSource - the host read tool(s) that return restore point ids.
|
|
27
|
+
* @param _optional.resolveDeepLinkCitation - a host specification id cited in the deep-link tool description.
|
|
28
|
+
* @returns Seven definitions; ids, permissions, side effects and schemas are fixed by the engine.
|
|
29
|
+
*/
|
|
30
|
+
export declare function createRecoveryAgentToolCatalog({ backupWorkflowGuidance, restorePointIdSource }: RecoveryAgentToolCatalogArgs, _optional?: {
|
|
31
|
+
resolveDeepLinkCitation?: string;
|
|
32
|
+
}): AgentToolDefinition[];
|
|
33
|
+
//# sourceMappingURL=agent-tools.d.ts.map
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Recovery's agent-tool catalog: no agent may hold a direct restore lever.
|
|
3
|
+
*
|
|
4
|
+
* Purpose:
|
|
5
|
+
* A static catalog. No `backup_confirm_restore`-equivalent tool ever exists — the human
|
|
6
|
+
* confirmation step is exactly the one act the gated-mutation gateway reserves for `kind='user'`/api_key
|
|
7
|
+
* principals; no description in this catalog may even claim to perform that step, so a future
|
|
8
|
+
* addition can't quietly reintroduce the capability by wording alone.
|
|
9
|
+
*
|
|
10
|
+
* Catalog notes:
|
|
11
|
+
* - `inputSchema` is part of `AgentToolDefinition` (optional, mirroring the other domain catalogs).
|
|
12
|
+
* - `backup_create_restore_point` is declared here but deliberately left UNWIRED by the host's
|
|
13
|
+
* recovery registrations. Short version: this tool id collides with the Database catalog's own
|
|
14
|
+
* `backup_create_restore_point` (the Database domain is that permission's "named tool"), and a
|
|
15
|
+
* recovery-local restore-point mint that never calls `DbOpsPort.captureRestorePoint()` would
|
|
16
|
+
* silently mint restore-point rows with no real snapshot artifact, reintroducing the
|
|
17
|
+
* "artifactRef silently dropped" defect the Database restore-points module records as fixed.
|
|
18
|
+
* - `recovery_get_status` and `recovery_resolve_deep_link` are read-only, zero-side-effect
|
|
19
|
+
* admin-UI sections (the recovery status bar and the deep-link re-resolution), added under the
|
|
20
|
+
* same "read-only admin-UI section is safe to wrap directly" bar the rest of this catalog uses.
|
|
21
|
+
*
|
|
22
|
+
* How it relates to the project:
|
|
23
|
+
* The server-side tool filter consumes this catalog to decide which tool names an agent
|
|
24
|
+
* session may see at all; `authorize()` and the confirmation-token gateway enforce the actual
|
|
25
|
+
* checks at call time — this module declares shape only, no I/O.
|
|
26
|
+
*
|
|
27
|
+
* The host supplies the wording that names its own tools and screens (the repository-backup
|
|
28
|
+
* workflow, its export path, and the read tools that return restore point ids); the engine never
|
|
29
|
+
* hard-codes a host tool name or product path.
|
|
30
|
+
*/
|
|
31
|
+
const BACKUP_READ_PERMISSION = "backup.read";
|
|
32
|
+
/** No arguments — shared by every parameterless read tool in this catalog. */
|
|
33
|
+
const NO_INPUT_SCHEMA = {
|
|
34
|
+
type: "object",
|
|
35
|
+
additionalProperties: false,
|
|
36
|
+
required: [],
|
|
37
|
+
properties: {},
|
|
38
|
+
};
|
|
39
|
+
/** `recovery_resolve_deep_link`'s input — mirrors `./deep-link`'s
|
|
40
|
+
* `DatabaseContextEnvelope` shape field-for-field. Every id inside is untrusted and re-looked-up
|
|
41
|
+
* server-side on arrival; nothing in this schema grants authority, it only carries display
|
|
42
|
+
* continuity. */
|
|
43
|
+
const DEEP_LINK_ENVELOPE_SCHEMA = {
|
|
44
|
+
type: "object",
|
|
45
|
+
additionalProperties: false,
|
|
46
|
+
required: ["envelope"],
|
|
47
|
+
properties: {
|
|
48
|
+
envelope: {
|
|
49
|
+
type: "object",
|
|
50
|
+
additionalProperties: false,
|
|
51
|
+
required: ["v", "correlationId", "siteId", "ledgerEventId", "restorePointId", "drift", "intent", "issuedAt"],
|
|
52
|
+
properties: {
|
|
53
|
+
v: { type: "integer", description: "Envelope schema version." },
|
|
54
|
+
correlationId: { type: "string", description: "The incident/correlation id minted when this deep-link's chain began." },
|
|
55
|
+
siteId: { type: "string", description: "The site/workspace id the envelope was minted for. Re-verified server-side, never trusted as-is." },
|
|
56
|
+
ledgerEventId: { type: ["string", "null"], description: "The database ledger row id this envelope points at, or null." },
|
|
57
|
+
restorePointId: {
|
|
58
|
+
type: ["string", "null"],
|
|
59
|
+
description: "The restore point id this envelope points at, or null. Re-looked-up server-side; a stale or forged id resolves to found:false rather than being trusted.",
|
|
60
|
+
},
|
|
61
|
+
drift: { type: "string", description: "The drift status carried for display continuity only; never trusted as authoritative." },
|
|
62
|
+
intent: { type: "string", description: "The carried intent (e.g. 'view'), for display continuity only." },
|
|
63
|
+
issuedAt: { type: "string", description: "ISO-8601 timestamp the envelope was minted at." },
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
/** `backup_plan_restore`'s and `backup_execute_restore`'s shared input, naming the host tool that returns ids. */
|
|
69
|
+
function planRestoreInputSchema({ restorePointIdSource }) {
|
|
70
|
+
return {
|
|
71
|
+
type: "object",
|
|
72
|
+
additionalProperties: false,
|
|
73
|
+
required: ["restorePointId"],
|
|
74
|
+
properties: {
|
|
75
|
+
restorePointId: { type: "string", minLength: 1, description: `A restore point id, as returned by ${restorePointIdSource}.` },
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/** The restore flow: list, capabilities, plan, and the one destructive execute tool. */
|
|
80
|
+
function restoreFlowTools({ backupWorkflowGuidance, planRestoreSchema }) {
|
|
81
|
+
return [
|
|
82
|
+
{
|
|
83
|
+
name: "backup_list_restore_points",
|
|
84
|
+
description: "Lists restore points for the current site, newest first, with their capture trigger and cost class.",
|
|
85
|
+
sideEffects: "none",
|
|
86
|
+
authorization: { permission: BACKUP_READ_PERMISSION },
|
|
87
|
+
inputSchema: NO_INPUT_SCHEMA,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
name: "backup_get_capabilities",
|
|
91
|
+
description: `Reports this site's restore-point cost class and mechanism kind. ${backupWorkflowGuidance} Rendered static output commits are a separate publishing workflow.`,
|
|
92
|
+
sideEffects: "none",
|
|
93
|
+
authorization: { permission: BACKUP_READ_PERMISSION },
|
|
94
|
+
inputSchema: NO_INPUT_SCHEMA,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: "backup_plan_restore",
|
|
98
|
+
description: "Previews what restoring to a given restore point would change, including the discarded-write-window disclosure.",
|
|
99
|
+
sideEffects: "none",
|
|
100
|
+
authorization: { permission: BACKUP_READ_PERMISSION },
|
|
101
|
+
inputSchema: planRestoreSchema,
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
// Asks the human in chat first (2026-09-24): wired with `humanConfirmedToolHandler`, which
|
|
105
|
+
// shows a confirm dialog and, only on the human's own click, confirms as that human and
|
|
106
|
+
// executes as the agent acting for them. The model never sees or supplies a token.
|
|
107
|
+
name: "backup_execute_restore",
|
|
108
|
+
description: "Replaces this site's current data with a restore point. Shows the user a confirm dialog first and only runs if they confirm. " +
|
|
109
|
+
"No restore point is taken first, so it can't be undone. Call backup_plan_restore first to see what would be lost.",
|
|
110
|
+
sideEffects: "mutates-durable-state",
|
|
111
|
+
authorization: { permission: "backup.restore" },
|
|
112
|
+
actorClassRule: "confirmer-must-equal-own-delegatedBy",
|
|
113
|
+
inputSchema: planRestoreSchema,
|
|
114
|
+
},
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
/** The restore-point mint plus the two read-only admin-UI sections (status bar, deep-link resolution). */
|
|
118
|
+
function restoreAdminTools({ citation }) {
|
|
119
|
+
return [
|
|
120
|
+
{
|
|
121
|
+
// Catalog entry deliberately left UNWIRED — see this file's header and the host's recovery
|
|
122
|
+
// registrations for the full reasoning: an id collision with the Database catalog's own
|
|
123
|
+
// `backup_create_restore_point`, whose wiring is the canonical one.
|
|
124
|
+
name: "backup_create_restore_point",
|
|
125
|
+
description: "Mints a new restore point independent of any migration, subject to the site's cost-acknowledgment rule.",
|
|
126
|
+
sideEffects: "mutates-durable-state",
|
|
127
|
+
authorization: { permission: "backup.create" },
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
// Read-only "Recovery status bar + degraded banner" admin-UI section.
|
|
131
|
+
name: "recovery_get_status",
|
|
132
|
+
description: "Reports this site's current restore-point cost class plus the single highest-precedence degraded-state banner (migration interrupted, pending migration, an operation already in flight, cost class unavailable, or watermark baseline unavailable), if any.",
|
|
133
|
+
sideEffects: "none",
|
|
134
|
+
authorization: { permission: BACKUP_READ_PERMISSION },
|
|
135
|
+
inputSchema: NO_INPUT_SCHEMA,
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
// Read-only re-resolution of a deep-link envelope. Never trusts the envelope's own carried
|
|
139
|
+
// values; every id is re-looked-up server-side.
|
|
140
|
+
name: "recovery_resolve_deep_link",
|
|
141
|
+
description: `Re-resolves a Database-Timeline deep-link envelope server-side${citation}: looks up the envelope's restorePointId against the current restore-points list rather than trusting the envelope's own carried value. A stale or forged id resolves to found:false.`,
|
|
142
|
+
sideEffects: "none",
|
|
143
|
+
authorization: { permission: BACKUP_READ_PERMISSION },
|
|
144
|
+
inputSchema: DEEP_LINK_ENVELOPE_SCHEMA,
|
|
145
|
+
},
|
|
146
|
+
];
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Recovery's fixed agent-tool catalog: reads are freely agent-callable under `backup.read`;
|
|
150
|
+
* `backup_execute_restore` is the one destructive, token-gated tool
|
|
151
|
+
* (`confirmer-must-equal-own-delegatedBy`); `backup_create_restore_point` is an ordinary
|
|
152
|
+
* mutation, never wrapped in a plan/confirm/execute sequence — but see this file's header for why
|
|
153
|
+
* it is nonetheless left unwired from the recovery registrations.
|
|
154
|
+
*
|
|
155
|
+
* @param args.backupWorkflowGuidance - the host's repository-backup / export sentences.
|
|
156
|
+
* @param args.restorePointIdSource - the host read tool(s) that return restore point ids.
|
|
157
|
+
* @param _optional.resolveDeepLinkCitation - a host specification id cited in the deep-link tool description.
|
|
158
|
+
* @returns Seven definitions; ids, permissions, side effects and schemas are fixed by the engine.
|
|
159
|
+
*/
|
|
160
|
+
export function createRecoveryAgentToolCatalog({ backupWorkflowGuidance, restorePointIdSource }, _optional = {}) {
|
|
161
|
+
// A host that cites its own specification ids passes one; the engine carries none.
|
|
162
|
+
const citation = _optional.resolveDeepLinkCitation === undefined ? "" : ` (${_optional.resolveDeepLinkCitation})`;
|
|
163
|
+
const planRestoreSchema = planRestoreInputSchema({ restorePointIdSource });
|
|
164
|
+
return [...restoreFlowTools({ backupWorkflowGuidance, planRestoreSchema }), ...restoreAdminTools({ citation })];
|
|
165
|
+
}
|
|
166
|
+
//# sourceMappingURL=agent-tools.js.map
|