@aglyn/plugins-ai 1.0.0-beta.226 → 1.0.0-beta.228
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/README.md +3 -2
- package/package.json +17 -17
- package/src/lib/billing/ai-month-meter.js +5 -3
- package/src/lib/billing/ai-month-meter.js.map +1 -1
- package/src/lib/billing/ai-overage-ledger.js +3 -1
- package/src/lib/billing/ai-overage-ledger.js.map +1 -1
- package/src/lib/components/ai-brief-dialog.component.d.ts +6 -2
- package/src/lib/components/ai-brief-dialog.component.js +36 -18
- package/src/lib/components/ai-brief-dialog.component.js.map +1 -1
- package/src/lib/components/ai-describe-automation.component.js +24 -4
- package/src/lib/components/ai-describe-automation.component.js.map +1 -1
- package/src/lib/components/ai-describe-button.component.js +6 -1
- package/src/lib/components/ai-describe-button.component.js.map +1 -1
- package/src/lib/components/ai-describe-page.component.d.ts +1 -1
- package/src/lib/components/ai-describe-page.component.js +1 -1
- package/src/lib/components/ai-describe-page.component.js.map +1 -1
- package/src/lib/components/ai-insight-dialog.component.js +24 -2
- package/src/lib/components/ai-insight-dialog.component.js.map +1 -1
- package/src/lib/components/ai-job-events.d.ts +20 -0
- package/src/lib/components/ai-job-events.js +78 -0
- package/src/lib/components/ai-job-events.js.map +1 -0
- package/src/lib/components/ai-job-follow.component.d.ts +49 -0
- package/src/lib/components/ai-job-follow.component.js +210 -0
- package/src/lib/components/ai-job-follow.component.js.map +1 -0
- package/src/lib/components/ai-job-links.d.ts +42 -0
- package/src/lib/components/ai-job-links.js +140 -0
- package/src/lib/components/ai-job-links.js.map +1 -0
- package/src/lib/components/ai-job-plan.component.d.ts +13 -6
- package/src/lib/components/ai-job-plan.component.js +29 -3
- package/src/lib/components/ai-job-plan.component.js.map +1 -1
- package/src/lib/components/ai-job-requests.d.ts +24 -0
- package/src/lib/components/ai-job-requests.js +76 -0
- package/src/lib/components/ai-job-requests.js.map +1 -0
- package/src/lib/components/ai-job-site.d.ts +22 -0
- package/src/lib/components/ai-job-site.js +73 -0
- package/src/lib/components/ai-job-site.js.map +1 -0
- package/src/lib/components/ai-jobs-indicator.component.d.ts +25 -0
- package/src/lib/components/ai-jobs-indicator.component.js +80 -0
- package/src/lib/components/ai-jobs-indicator.component.js.map +1 -0
- package/src/lib/components/ai-jobs-list-page.component.d.ts +23 -0
- package/src/lib/components/ai-jobs-list-page.component.js +303 -0
- package/src/lib/components/ai-jobs-list-page.component.js.map +1 -0
- package/src/lib/components/ai-jobs-page.component.d.ts +7 -0
- package/src/lib/components/ai-jobs-page.component.js +30 -0
- package/src/lib/components/ai-jobs-page.component.js.map +1 -0
- package/src/lib/components/ai-jobs-store.d.ts +81 -0
- package/src/lib/components/ai-jobs-store.js +218 -0
- package/src/lib/components/ai-jobs-store.js.map +1 -0
- package/src/lib/components/ai-page-brief-dialog.component.d.ts +4 -4
- package/src/lib/components/ai-page-brief-dialog.component.js.map +1 -1
- package/src/lib/components/ai-site-build-page.component.d.ts +51 -0
- package/src/lib/components/ai-site-build-page.component.js +495 -0
- package/src/lib/components/ai-site-build-page.component.js.map +1 -0
- package/src/lib/components/ai-site-start-card.component.d.ts +9 -1
- package/src/lib/components/ai-site-start-card.component.js +533 -132
- package/src/lib/components/ai-site-start-card.component.js.map +1 -1
- package/src/lib/components/ai-site-starter-fallback.component.d.ts +24 -0
- package/src/lib/components/ai-site-starter-fallback.component.js +112 -0
- package/src/lib/components/ai-site-starter-fallback.component.js.map +1 -0
- package/src/lib/components/assist-jobs-drawer.component.d.ts +18 -20
- package/src/lib/components/assist-jobs-drawer.component.js +152 -172
- package/src/lib/components/assist-jobs-drawer.component.js.map +1 -1
- package/src/lib/components/assist-panel.component.js +69 -8
- package/src/lib/components/assist-panel.component.js.map +1 -1
- package/src/lib/components/staff-ai-credit-return.component.d.ts +55 -0
- package/src/lib/components/staff-ai-credit-return.component.js +346 -0
- package/src/lib/components/staff-ai-credit-return.component.js.map +1 -0
- package/src/lib/components/staff-org-ai-card.component.js +364 -279
- package/src/lib/components/staff-org-ai-card.component.js.map +1 -1
- package/src/lib/components/staff-user-ai-usage-card.component.d.ts +4 -0
- package/src/lib/components/staff-user-ai-usage-card.component.js +83 -28
- package/src/lib/components/staff-user-ai-usage-card.component.js.map +1 -1
- package/src/lib/components/use-ai-job-run.js +5 -18
- package/src/lib/components/use-ai-job-run.js.map +1 -1
- package/src/lib/jobs/ai-job-auto-confirm.d.ts +52 -0
- package/src/lib/jobs/ai-job-auto-confirm.js +62 -0
- package/src/lib/jobs/ai-job-auto-confirm.js.map +1 -0
- package/src/lib/jobs/ai-job-draft-ids.d.ts +6 -0
- package/src/lib/jobs/ai-job-draft-ids.js +9 -0
- package/src/lib/jobs/ai-job-draft-ids.js.map +1 -1
- package/src/lib/jobs/ai-job-drafts.d.ts +7 -0
- package/src/lib/jobs/ai-job-drafts.js +16 -7
- package/src/lib/jobs/ai-job-drafts.js.map +1 -1
- package/src/lib/jobs/ai-job-layout-step.js +2 -1
- package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
- package/src/lib/jobs/ai-job-page-sections.d.ts +6 -5
- package/src/lib/jobs/ai-job-page-sections.js +3 -3
- package/src/lib/jobs/ai-job-page-sections.js.map +1 -1
- package/src/lib/jobs/ai-job-page-step.d.ts +19 -1
- package/src/lib/jobs/ai-job-page-step.js +50 -8
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-job-plan-step.d.ts +33 -2
- package/src/lib/jobs/ai-job-plan-step.js +167 -18
- package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
- package/src/lib/jobs/ai-job-site-step.d.ts +28 -0
- package/src/lib/jobs/ai-job-site-step.js +130 -21
- package/src/lib/jobs/ai-job-site-step.js.map +1 -1
- package/src/lib/jobs/ai-job-text-step.d.ts +14 -1
- package/src/lib/jobs/ai-job-text-step.js.map +1 -1
- package/src/lib/jobs/ai-jobs-notify.d.ts +37 -0
- package/src/lib/jobs/ai-jobs-notify.js +51 -0
- package/src/lib/jobs/ai-jobs-notify.js.map +1 -0
- package/src/lib/jobs/ai-jobs.d.ts +39 -4
- package/src/lib/jobs/ai-jobs.js +205 -34
- package/src/lib/jobs/ai-jobs.js.map +1 -1
- package/src/lib/jobs/ai-site-publish.d.ts +98 -0
- package/src/lib/jobs/ai-site-publish.js +372 -0
- package/src/lib/jobs/ai-site-publish.js.map +1 -0
- package/src/lib/jobs/fixtures/ai-page-briefs.d.ts +7 -6
- package/src/lib/jobs/fixtures/ai-page-briefs.js +23 -56
- package/src/lib/jobs/fixtures/ai-page-briefs.js.map +1 -1
- package/src/lib/model/ai-job-activity.d.ts +112 -0
- package/src/lib/model/ai-job-activity.js +144 -0
- package/src/lib/model/ai-job-activity.js.map +1 -0
- package/src/lib/model/ai-job-failure-copy.d.ts +69 -0
- package/src/lib/model/ai-job-failure-copy.js +78 -0
- package/src/lib/model/ai-job-failure-copy.js.map +1 -0
- package/src/lib/model/ai-job-notice.d.ts +63 -0
- package/src/lib/model/ai-job-notice.js +129 -0
- package/src/lib/model/ai-job-notice.js.map +1 -0
- package/src/lib/model/ai-jobs.types.d.ts +53 -0
- package/src/lib/model/ai-jobs.types.js +1 -0
- package/src/lib/model/ai-jobs.types.js.map +1 -1
- package/src/lib/model/ai-plan-capabilities.d.ts +32 -10
- package/src/lib/model/ai-plan-capabilities.js +15 -2
- package/src/lib/model/ai-plan-capabilities.js.map +1 -1
- package/src/lib/model/ai-site-build-progress.d.ts +61 -0
- package/src/lib/model/ai-site-build-progress.js +136 -0
- package/src/lib/model/ai-site-build-progress.js.map +1 -0
- package/src/lib/model/ai-site-inventory.d.ts +9 -0
- package/src/lib/model/ai-site-inventory.js +7 -2
- package/src/lib/model/ai-site-inventory.js.map +1 -1
- package/src/lib/model/ai-site-job.d.ts +93 -2
- package/src/lib/model/ai-site-job.js +88 -7
- package/src/lib/model/ai-site-job.js.map +1 -1
- package/src/lib/model/ai-site-start-seo.d.ts +19 -0
- package/src/lib/model/ai-site-start-seo.js +91 -3
- package/src/lib/model/ai-site-start-seo.js.map +1 -1
- package/src/lib/model/ai-site-start.d.ts +3 -1
- package/src/lib/model/ai-site-start.js +6 -4
- package/src/lib/model/ai-site-start.js.map +1 -1
- package/src/lib/plan-entitlements.d.ts +3 -3
- package/src/lib/plan-entitlements.js +3 -3
- package/src/lib/plan-entitlements.js.map +1 -1
- package/src/lib/plugin.js +38 -2
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/runtime/ai-abuse-guards.d.ts +9 -6
- package/src/lib/runtime/ai-abuse-guards.js +10 -7
- package/src/lib/runtime/ai-abuse-guards.js.map +1 -1
- package/src/lib/runtime/ai-doctrine-validators.d.ts +16 -12
- package/src/lib/runtime/ai-doctrine-validators.js +50 -40
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-doctrine.js +1 -1
- package/src/lib/runtime/ai-doctrine.js.map +1 -1
- package/src/lib/runtime/ai-eval-live.d.ts +1 -1
- package/src/lib/runtime/ai-eval-live.js +1 -1
- package/src/lib/runtime/ai-eval-live.js.map +1 -1
- package/src/lib/runtime/ai-gate.d.ts +3 -2
- package/src/lib/runtime/ai-gate.js +3 -2
- package/src/lib/runtime/ai-gate.js.map +1 -1
- package/src/lib/runtime/site-inventory.d.ts +16 -1
- package/src/lib/runtime/site-inventory.js +43 -3
- package/src/lib/runtime/site-inventory.js.map +1 -1
- package/src/lib/server/ai-admin-credits.d.ts +21 -0
- package/src/lib/server/ai-admin-credits.js +213 -0
- package/src/lib/server/ai-admin-credits.js.map +1 -0
- package/src/lib/server/ai-admin-org.js +12 -5
- package/src/lib/server/ai-admin-org.js.map +1 -1
- package/src/lib/server/ai-admin-signals.js +3 -1
- package/src/lib/server/ai-admin-signals.js.map +1 -1
- package/src/lib/server/ai-admin-user.js +12 -1
- package/src/lib/server/ai-admin-user.js.map +1 -1
- package/src/lib/server/ai-allotments.js +3 -2
- package/src/lib/server/ai-allotments.js.map +1 -1
- package/src/lib/server/ai-jobs-live-sites.d.ts +26 -0
- package/src/lib/server/ai-jobs-live-sites.js +58 -0
- package/src/lib/server/ai-jobs-live-sites.js.map +1 -0
- package/src/lib/server/ai-jobs-route.js +42 -5
- package/src/lib/server/ai-jobs-route.js.map +1 -1
- package/src/lib/server/assist-chat.js +3 -2
- package/src/lib/server/assist-chat.js.map +1 -1
- package/src/lib/server/billing-credits.js +4 -3
- package/src/lib/server/billing-credits.js.map +1 -1
- package/src/lib/server/billing-overage.js +3 -2
- package/src/lib/server/billing-overage.js.map +1 -1
- package/src/lib/server.js +11 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/usage/assist-credit-returns-write.d.ts +75 -0
- package/src/lib/usage/assist-credit-returns-write.js +150 -0
- package/src/lib/usage/assist-credit-returns-write.js.map +1 -0
- package/src/lib/usage/assist-credit-returns.d.ts +68 -0
- package/src/lib/usage/assist-credit-returns.js +79 -0
- package/src/lib/usage/assist-credit-returns.js.map +1 -0
- package/src/lib/usage/assist-free-taste.js +6 -3
- package/src/lib/usage/assist-free-taste.js.map +1 -1
- package/src/lib/usage/assist-job-refund.d.ts +100 -0
- package/src/lib/usage/assist-job-refund.js +109 -0
- package/src/lib/usage/assist-job-refund.js.map +1 -0
- package/src/lib/usage/assist-usage.js +5 -2
- package/src/lib/usage/assist-usage.js.map +1 -1
- package/src/lib/usage/staff-org-ai.d.ts +31 -1
- package/src/lib/usage/staff-org-ai.js +19 -2
- package/src/lib/usage/staff-org-ai.js.map +1 -1
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
18
|
+
import { useEffect, useMemo, useRef, useSyncExternalStore } from "react";
|
|
19
|
+
import { aiJobsActivity } from "../model/ai-job-activity.js";
|
|
20
|
+
import { AI_JOB_TERMINAL_STATUSES } from "../model/ai-jobs.types.js";
|
|
21
|
+
let openRequest = {
|
|
22
|
+
seq: 0,
|
|
23
|
+
jobId: null
|
|
24
|
+
};
|
|
25
|
+
const openListeners = new Set();
|
|
26
|
+
/**
|
|
27
|
+
* Opens the Assist panel on its AI jobs drawer, expanded, scrolled to
|
|
28
|
+
* `jobId` when one is named. A surface that covers the panel — a dialog —
|
|
29
|
+
* closes itself beside the call; this opens, it does not close anything.
|
|
30
|
+
*/ export function openAiJobs(options = {}) {
|
|
31
|
+
var _options_jobId;
|
|
32
|
+
openRequest = {
|
|
33
|
+
seq: openRequest.seq + 1,
|
|
34
|
+
jobId: (_options_jobId = options.jobId) != null ? _options_jobId : null
|
|
35
|
+
};
|
|
36
|
+
for (const listener of openListeners)listener();
|
|
37
|
+
}
|
|
38
|
+
function subscribeOpen(listener) {
|
|
39
|
+
openListeners.add(listener);
|
|
40
|
+
return ()=>{
|
|
41
|
+
openListeners.delete(listener);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const readOpen = ()=>openRequest;
|
|
45
|
+
/** The latest open request, for the panel; a new `seq` is a new request. */ export function useAiJobsOpenRequest() {
|
|
46
|
+
return useSyncExternalStore(subscribeOpen, readOpen, readOpen);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* The query parameter a notification's link carries: a console page opened
|
|
50
|
+
* with `?aiJob={id}` opens AI jobs on that job, the way pressing the
|
|
51
|
+
* indicator does.
|
|
52
|
+
*/ export { AI_JOB_LINK_PARAM } from "../model/ai-job-notice.js";
|
|
53
|
+
// ── The workspace's unsettled jobs ────────────────────────────────────────
|
|
54
|
+
/** How often a list with something in it is read again, while the tab is in view. */ export const AI_JOBS_ACTIVE_POLL_MS = 15000;
|
|
55
|
+
/** The most unsettled jobs one read lists; a glance, not an archive. */ const ACTIVE_LIMIT = 20;
|
|
56
|
+
const NONE = Object.freeze([]);
|
|
57
|
+
const entries = new Map();
|
|
58
|
+
const keyOf = (uid, orgId)=>`${uid}\n${orgId}`;
|
|
59
|
+
function emit(entry) {
|
|
60
|
+
for (const listener of entry.listeners)listener();
|
|
61
|
+
}
|
|
62
|
+
function isSettled(job) {
|
|
63
|
+
return AI_JOB_TERMINAL_STATUSES.includes(job.status);
|
|
64
|
+
}
|
|
65
|
+
function schedule(entry) {
|
|
66
|
+
if (entry.timer) clearTimeout(entry.timer);
|
|
67
|
+
entry.timer = null;
|
|
68
|
+
if (entry.closed || entry.subscribers === 0 || entry.jobs.length === 0) return;
|
|
69
|
+
entry.timer = setTimeout(()=>{
|
|
70
|
+
entry.timer = null;
|
|
71
|
+
const hidden = typeof document !== 'undefined' && document.visibilityState === 'hidden';
|
|
72
|
+
// A hidden tab reads nothing; coming back into view reads at once.
|
|
73
|
+
if (hidden) return;
|
|
74
|
+
void read(entry);
|
|
75
|
+
}, AI_JOBS_ACTIVE_POLL_MS);
|
|
76
|
+
}
|
|
77
|
+
async function read(entry) {
|
|
78
|
+
if (entry.inflight || entry.closed) return;
|
|
79
|
+
entry.inflight = true;
|
|
80
|
+
try {
|
|
81
|
+
var _ref;
|
|
82
|
+
const response = await authorizedFetch(entry.user, `/api/ai/jobs?orgId=${encodeURIComponent(entry.orgId)}&status=active&limit=${ACTIVE_LIMIT}`);
|
|
83
|
+
if (response.status === 404 || response.status === 403) {
|
|
84
|
+
// The release flag off, or a plan or member without generation: there
|
|
85
|
+
// is nothing to count, now or on the next tick.
|
|
86
|
+
entry.closed = true;
|
|
87
|
+
entry.jobs = NONE;
|
|
88
|
+
emit(entry);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (!response.ok) return;
|
|
92
|
+
const payload = await response.json().catch(()=>null);
|
|
93
|
+
entry.jobs = Object.freeze(((_ref = payload == null ? void 0 : payload.jobs) != null ? _ref : []).filter((job)=>!isSettled(job)));
|
|
94
|
+
emit(entry);
|
|
95
|
+
} catch (unused) {
|
|
96
|
+
// An unreachable route keeps what was last read; the next tick asks again.
|
|
97
|
+
} finally{
|
|
98
|
+
entry.inflight = false;
|
|
99
|
+
schedule(entry);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
function entryFor(uid, orgId, user) {
|
|
103
|
+
const key = keyOf(uid, orgId);
|
|
104
|
+
let entry = entries.get(key);
|
|
105
|
+
if (!entry) {
|
|
106
|
+
entry = {
|
|
107
|
+
jobs: NONE,
|
|
108
|
+
user,
|
|
109
|
+
orgId,
|
|
110
|
+
subscribers: 0,
|
|
111
|
+
inflight: false,
|
|
112
|
+
timer: null,
|
|
113
|
+
closed: false,
|
|
114
|
+
listeners: new Set()
|
|
115
|
+
};
|
|
116
|
+
entries.set(key, entry);
|
|
117
|
+
}
|
|
118
|
+
return entry;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Hands a job's latest state to every surface counting this workspace's jobs:
|
|
122
|
+
* a new job joins the list, a settled one leaves it. Keyed on the job's own
|
|
123
|
+
* workspace, for every person whose list holds that workspace in this tab.
|
|
124
|
+
*/ export function publishAiJob(job) {
|
|
125
|
+
if (!(job == null ? void 0 : job.orgId)) return;
|
|
126
|
+
for (const entry of entries.values()){
|
|
127
|
+
if (entry.orgId !== job.orgId || entry.closed) continue;
|
|
128
|
+
const index = entry.jobs.findIndex((known)=>known.id === job.id);
|
|
129
|
+
let next;
|
|
130
|
+
if (isSettled(job)) {
|
|
131
|
+
if (index === -1) continue;
|
|
132
|
+
next = entry.jobs.filter((known)=>known.id !== job.id);
|
|
133
|
+
} else if (index === -1) {
|
|
134
|
+
next = [
|
|
135
|
+
job,
|
|
136
|
+
...entry.jobs
|
|
137
|
+
];
|
|
138
|
+
} else {
|
|
139
|
+
next = [
|
|
140
|
+
...entry.jobs
|
|
141
|
+
];
|
|
142
|
+
next[index] = job;
|
|
143
|
+
}
|
|
144
|
+
entry.jobs = Object.freeze(next);
|
|
145
|
+
emit(entry);
|
|
146
|
+
// A list that just gained its first job starts its timer.
|
|
147
|
+
if (!entry.timer && !entry.inflight) schedule(entry);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/** Forget every list and request; specs start each case from nothing. */ export function resetAiJobsStoreForTests() {
|
|
151
|
+
for (const entry of entries.values()){
|
|
152
|
+
if (entry.timer) clearTimeout(entry.timer);
|
|
153
|
+
}
|
|
154
|
+
entries.clear();
|
|
155
|
+
openListeners.clear();
|
|
156
|
+
openRequest = {
|
|
157
|
+
seq: 0,
|
|
158
|
+
jobId: null
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* The workspace's jobs that are not yet settled, newest first, for the
|
|
163
|
+
* signed-in person — empty while the first read is in flight, where the
|
|
164
|
+
* route refuses, and when `enabled` is false (a surface whose own gates have
|
|
165
|
+
* not passed reads nothing at all).
|
|
166
|
+
*/ export function useAiJobsInFlight(user, orgId, enabled = true) {
|
|
167
|
+
var _ref;
|
|
168
|
+
const uid = (_ref = user == null ? void 0 : user.uid) != null ? _ref : null;
|
|
169
|
+
const userRef = useRef(user);
|
|
170
|
+
userRef.current = user;
|
|
171
|
+
const entry = useMemo(()=>enabled && uid && orgId ? entryFor(uid, orgId, userRef.current) : null, [
|
|
172
|
+
enabled,
|
|
173
|
+
uid,
|
|
174
|
+
orgId
|
|
175
|
+
]);
|
|
176
|
+
useEffect(()=>{
|
|
177
|
+
if (!entry) return undefined;
|
|
178
|
+
entry.user = userRef.current;
|
|
179
|
+
entry.subscribers += 1;
|
|
180
|
+
if (entry.subscribers === 1) void read(entry);
|
|
181
|
+
const onVisible = ()=>{
|
|
182
|
+
if (document.visibilityState === 'visible' && entry.jobs.length > 0) void read(entry);
|
|
183
|
+
};
|
|
184
|
+
document.addEventListener('visibilitychange', onVisible);
|
|
185
|
+
return ()=>{
|
|
186
|
+
document.removeEventListener('visibilitychange', onVisible);
|
|
187
|
+
entry.subscribers -= 1;
|
|
188
|
+
if (entry.subscribers === 0 && entry.timer) {
|
|
189
|
+
clearTimeout(entry.timer);
|
|
190
|
+
entry.timer = null;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}, [
|
|
194
|
+
entry
|
|
195
|
+
]);
|
|
196
|
+
const subscribe = useMemo(()=>(listener)=>{
|
|
197
|
+
if (!entry) return ()=>undefined;
|
|
198
|
+
entry.listeners.add(listener);
|
|
199
|
+
return ()=>{
|
|
200
|
+
entry.listeners.delete(listener);
|
|
201
|
+
};
|
|
202
|
+
}, [
|
|
203
|
+
entry
|
|
204
|
+
]);
|
|
205
|
+
const snapshot = ()=>{
|
|
206
|
+
var _ref;
|
|
207
|
+
return (_ref = entry == null ? void 0 : entry.jobs) != null ? _ref : NONE;
|
|
208
|
+
};
|
|
209
|
+
return useSyncExternalStore(subscribe, snapshot, snapshot);
|
|
210
|
+
}
|
|
211
|
+
/** What the indicator and the launcher show for the workspace, or `null` for nothing. */ export function useAiJobsActivity(user, orgId, enabled = true) {
|
|
212
|
+
const jobs = useAiJobsInFlight(user, orgId, enabled);
|
|
213
|
+
return useMemo(()=>aiJobsActivity(jobs), [
|
|
214
|
+
jobs
|
|
215
|
+
]);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
//# sourceMappingURL=ai-jobs-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-jobs-store.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport {\n authorizedFetch,\n type MaybeTokenSource,\n type TokenSource,\n} from '@aglyn/shared-util-http/authorized-token'\nimport { useEffect, useMemo, useRef, useSyncExternalStore } from 'react'\nimport { aiJobsActivity, type AiJobsActivity } from '../model/ai-job-activity'\nimport { AI_JOB_TERMINAL_STATUSES, type AiJobSummary } from '../model/ai-jobs.types'\n\n/**\n * WHERE A PERSON FINDS THEIR AI JOBS (AGL-3593).\n *\n * Two things every AI surface in the console shares, kept in this module\n * rather than in any one component because the surfaces that need them — a\n * brief dialog on the Screens page, the guided start's full-screen dialog,\n * the top-bar indicator, the Assist launcher and the drawer inside the\n * panel — are mounted in different zones and know nothing of one another.\n * All of them are this plugin's, so no shell, zone or event bus carries it.\n *\n * ── Opening AI jobs ──────────────────────────────────────────────────────\n *\n * {@link openAiJobs} is the one action every \"Open AI jobs\" button, the\n * indicator and a notification's link take: the Assist panel subscribes, opens\n * itself, expands its AI jobs drawer, and scrolls to and highlights the job\n * named. A request is a sequence number as well as a job, so asking twice for\n * the same job opens it twice.\n *\n * ── The workspace's unsettled jobs ───────────────────────────────────────\n *\n * The indicator, the launcher's badge and the drawer's open-by-default rule\n * read the same list: the workspace's jobs that are not yet settled, from\n * the jobs route's `status=active` (a Firestore `in` query under the\n * (status, createdAt) index, never a filter of a loaded window). ONE list per\n * person and workspace however many surfaces read it, re-read on a timer only\n * while something in it is still moving or waiting and the tab is in view —\n * a workspace with nothing running costs one read per page load and no more.\n *\n * Every surface that learns a job's state some other way — the dialog that\n * created it, the drawer's event stream, the in-dialog confirm — hands it in\n * through {@link publishAiJob}, so the indicator moves the moment the job\n * does rather than on the next read.\n */\n\n// ── Opening AI jobs ───────────────────────────────────────────────────────\n\n/** The latest request to open AI jobs; `seq` is 0 until anything asked. */\nexport interface AiJobsOpenRequest {\n seq: number\n /** The job to scroll to and highlight, or `null` for the drawer alone. */\n jobId: string | null\n}\n\nlet openRequest: AiJobsOpenRequest = { seq: 0, jobId: null }\nconst openListeners = new Set<() => void>()\n\n/**\n * Opens the Assist panel on its AI jobs drawer, expanded, scrolled to\n * `jobId` when one is named. A surface that covers the panel — a dialog —\n * closes itself beside the call; this opens, it does not close anything.\n */\nexport function openAiJobs(options: { jobId?: string | null } = {}): void {\n openRequest = { seq: openRequest.seq + 1, jobId: options.jobId ?? null }\n for (const listener of openListeners) listener()\n}\n\nfunction subscribeOpen(listener: () => void): () => void {\n openListeners.add(listener)\n return () => {\n openListeners.delete(listener)\n }\n}\n\nconst readOpen = (): AiJobsOpenRequest => openRequest\n\n/** The latest open request, for the panel; a new `seq` is a new request. */\nexport function useAiJobsOpenRequest(): AiJobsOpenRequest {\n return useSyncExternalStore(subscribeOpen, readOpen, readOpen)\n}\n\n/**\n * The query parameter a notification's link carries: a console page opened\n * with `?aiJob={id}` opens AI jobs on that job, the way pressing the\n * indicator does.\n */\nexport { AI_JOB_LINK_PARAM } from '../model/ai-job-notice'\n\n// ── The workspace's unsettled jobs ────────────────────────────────────────\n\n/** How often a list with something in it is read again, while the tab is in view. */\nexport const AI_JOBS_ACTIVE_POLL_MS = 15_000\n\n/** The most unsettled jobs one read lists; a glance, not an archive. */\nconst ACTIVE_LIMIT = 20\n\nconst NONE: readonly AiJobSummary[] = Object.freeze([])\n\ninterface Entry {\n jobs: readonly AiJobSummary[]\n /** Who reads it, kept current by whichever surface subscribed last. */\n user: MaybeTokenSource\n orgId: string\n subscribers: number\n inflight: boolean\n timer: ReturnType<typeof setTimeout> | null\n /** The route said the feature is not this workspace's: nothing is read again. */\n closed: boolean\n listeners: Set<() => void>\n}\n\nconst entries = new Map<string, Entry>()\n\nconst keyOf = (uid: string, orgId: string): string => `${uid}\\n${orgId}`\n\nfunction emit(entry: Entry): void {\n for (const listener of entry.listeners) listener()\n}\n\nfunction isSettled(job: AiJobSummary): boolean {\n return AI_JOB_TERMINAL_STATUSES.includes(job.status)\n}\n\nfunction schedule(entry: Entry): void {\n if (entry.timer) clearTimeout(entry.timer)\n entry.timer = null\n if (entry.closed || entry.subscribers === 0 || entry.jobs.length === 0) return\n entry.timer = setTimeout(() => {\n entry.timer = null\n const hidden = typeof document !== 'undefined' && document.visibilityState === 'hidden'\n // A hidden tab reads nothing; coming back into view reads at once.\n if (hidden) return\n void read(entry)\n }, AI_JOBS_ACTIVE_POLL_MS)\n}\n\nasync function read(entry: Entry): Promise<void> {\n if (entry.inflight || entry.closed) return\n entry.inflight = true\n try {\n const response = await authorizedFetch(\n entry.user,\n `/api/ai/jobs?orgId=${encodeURIComponent(entry.orgId)}&status=active&limit=${ACTIVE_LIMIT}`,\n )\n if (response.status === 404 || response.status === 403) {\n // The release flag off, or a plan or member without generation: there\n // is nothing to count, now or on the next tick.\n entry.closed = true\n entry.jobs = NONE\n emit(entry)\n return\n }\n if (!response.ok) return\n const payload = (await response.json().catch(() => null)) as { jobs?: AiJobSummary[] } | null\n entry.jobs = Object.freeze((payload?.jobs ?? []).filter((job) => !isSettled(job)))\n emit(entry)\n } catch {\n // An unreachable route keeps what was last read; the next tick asks again.\n } finally {\n entry.inflight = false\n schedule(entry)\n }\n}\n\nfunction entryFor(uid: string, orgId: string, user: MaybeTokenSource): Entry {\n const key = keyOf(uid, orgId)\n let entry = entries.get(key)\n if (!entry) {\n entry = {\n jobs: NONE,\n user,\n orgId,\n subscribers: 0,\n inflight: false,\n timer: null,\n closed: false,\n listeners: new Set(),\n }\n entries.set(key, entry)\n }\n return entry\n}\n\n/**\n * Hands a job's latest state to every surface counting this workspace's jobs:\n * a new job joins the list, a settled one leaves it. Keyed on the job's own\n * workspace, for every person whose list holds that workspace in this tab.\n */\nexport function publishAiJob(job: AiJobSummary | null | undefined): void {\n if (!job?.orgId) return\n for (const entry of entries.values()) {\n if (entry.orgId !== job.orgId || entry.closed) continue\n const index = entry.jobs.findIndex((known) => known.id === job.id)\n let next: AiJobSummary[]\n if (isSettled(job)) {\n if (index === -1) continue\n next = entry.jobs.filter((known) => known.id !== job.id)\n } else if (index === -1) {\n next = [job, ...entry.jobs]\n } else {\n next = [...entry.jobs]\n next[index] = job\n }\n entry.jobs = Object.freeze(next)\n emit(entry)\n // A list that just gained its first job starts its timer.\n if (!entry.timer && !entry.inflight) schedule(entry)\n }\n}\n\n/** Forget every list and request; specs start each case from nothing. */\nexport function resetAiJobsStoreForTests(): void {\n for (const entry of entries.values()) {\n if (entry.timer) clearTimeout(entry.timer)\n }\n entries.clear()\n openListeners.clear()\n openRequest = { seq: 0, jobId: null }\n}\n\n/**\n * The workspace's jobs that are not yet settled, newest first, for the\n * signed-in person — empty while the first read is in flight, where the\n * route refuses, and when `enabled` is false (a surface whose own gates have\n * not passed reads nothing at all).\n */\nexport function useAiJobsInFlight(\n user: (TokenSource & { uid?: string | null }) | null | undefined,\n orgId: string | null | undefined,\n enabled = true,\n): readonly AiJobSummary[] {\n const uid = user?.uid ?? null\n const userRef = useRef<MaybeTokenSource>(user)\n userRef.current = user\n const entry = useMemo(\n () => (enabled && uid && orgId ? entryFor(uid, orgId, userRef.current) : null),\n [enabled, uid, orgId],\n )\n\n useEffect(() => {\n if (!entry) return undefined\n entry.user = userRef.current\n entry.subscribers += 1\n if (entry.subscribers === 1) void read(entry)\n const onVisible = () => {\n if (document.visibilityState === 'visible' && entry.jobs.length > 0) void read(entry)\n }\n document.addEventListener('visibilitychange', onVisible)\n return () => {\n document.removeEventListener('visibilitychange', onVisible)\n entry.subscribers -= 1\n if (entry.subscribers === 0 && entry.timer) {\n clearTimeout(entry.timer)\n entry.timer = null\n }\n }\n }, [entry])\n\n const subscribe = useMemo(\n () => (listener: () => void) => {\n if (!entry) return () => undefined\n entry.listeners.add(listener)\n return () => {\n entry.listeners.delete(listener)\n }\n },\n [entry],\n )\n const snapshot = (): readonly AiJobSummary[] => entry?.jobs ?? NONE\n return useSyncExternalStore(subscribe, snapshot, snapshot)\n}\n\n/** What the indicator and the launcher show for the workspace, or `null` for nothing. */\nexport function useAiJobsActivity(\n user: (TokenSource & { uid?: string | null }) | null | undefined,\n orgId: string | null | undefined,\n enabled = true,\n): AiJobsActivity<AiJobSummary> | null {\n const jobs = useAiJobsInFlight(user, orgId, enabled)\n return useMemo(() => aiJobsActivity(jobs), [jobs])\n}\n"],"names":["authorizedFetch","useEffect","useMemo","useRef","useSyncExternalStore","aiJobsActivity","AI_JOB_TERMINAL_STATUSES","openRequest","seq","jobId","openListeners","Set","openAiJobs","options","listener","subscribeOpen","add","delete","readOpen","useAiJobsOpenRequest","AI_JOB_LINK_PARAM","AI_JOBS_ACTIVE_POLL_MS","ACTIVE_LIMIT","NONE","Object","freeze","entries","Map","keyOf","uid","orgId","emit","entry","listeners","isSettled","job","includes","status","schedule","timer","clearTimeout","closed","subscribers","jobs","length","setTimeout","hidden","document","visibilityState","read","inflight","response","user","encodeURIComponent","ok","payload","json","catch","filter","entryFor","key","get","set","publishAiJob","values","index","findIndex","known","id","next","resetAiJobsStoreForTests","clear","useAiJobsInFlight","enabled","userRef","current","undefined","onVisible","addEventListener","removeEventListener","subscribe","snapshot","useAiJobsActivity"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;AAEA,SACEA,eAAe,QAGV,2CAA0C;AACjD,SAASC,SAAS,EAAEC,OAAO,EAAEC,MAAM,EAAEC,oBAAoB,QAAQ,QAAO;AACxE,SAASC,cAAc,QAA6B,8BAA0B;AAC9E,SAASC,wBAAwB,QAA2B,4BAAwB;AA6CpF,IAAIC,cAAiC;IAAEC,KAAK;IAAGC,OAAO;AAAK;AAC3D,MAAMC,gBAAgB,IAAIC;AAE1B;;;;CAIC,GACD,OAAO,SAASC,WAAWC,UAAqC,CAAC,CAAC;QACfA;IAAjDN,cAAc;QAAEC,KAAKD,YAAYC,GAAG,GAAG;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;QAAS5C;QAAKC;KAAM;IAGvB7B,UAAU;QACR,IAAI,CAAC+B,OAAO,OAAO4C;QACnB5C,MAAMoB,IAAI,GAAGsB,QAAQC,OAAO;QAC5B3C,MAAMU,WAAW,IAAI;QACrB,IAAIV,MAAMU,WAAW,KAAK,GAAG,KAAKO,KAAKjB;QACvC,MAAM6C,YAAY;YAChB,IAAI9B,SAASC,eAAe,KAAK,aAAahB,MAAMW,IAAI,CAACC,MAAM,GAAG,GAAG,KAAKK,KAAKjB;QACjF;QACAe,SAAS+B,gBAAgB,CAAC,oBAAoBD;QAC9C,OAAO;YACL9B,SAASgC,mBAAmB,CAAC,oBAAoBF;YACjD7C,MAAMU,WAAW,IAAI;YACrB,IAAIV,MAAMU,WAAW,KAAK,KAAKV,MAAMO,KAAK,EAAE;gBAC1CC,aAAaR,MAAMO,KAAK;gBACxBP,MAAMO,KAAK,GAAG;YAChB;QACF;IACF,GAAG;QAACP;KAAM;IAEV,MAAMgD,YAAY9E,QAChB,IAAM,CAACY;YACL,IAAI,CAACkB,OAAO,OAAO,IAAM4C;YACzB5C,MAAMC,SAAS,CAACjB,GAAG,CAACF;YACpB,OAAO;gBACLkB,MAAMC,SAAS,CAAChB,MAAM,CAACH;YACzB;QACF,GACA;QAACkB;KAAM;IAET,MAAMiD,WAAW;;uBAA+BjD,yBAAAA,MAAOW,IAAI,mBAAIpB;;IAC/D,OAAOnB,qBAAqB4E,WAAWC,UAAUA;AACnD;AAEA,uFAAuF,GACvF,OAAO,SAASC,kBACd9B,IAAgE,EAChEtB,KAAgC,EAChC2C,UAAU,IAAI;IAEd,MAAM9B,OAAO6B,kBAAkBpB,MAAMtB,OAAO2C;IAC5C,OAAOvE,QAAQ,IAAMG,eAAesC,OAAO;QAACA;KAAK;AACnD"}
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
import { type AiBriefDialogProps } from './ai-brief-dialog.component';
|
|
18
18
|
/**
|
|
19
19
|
* "Describe a page" (AGL-2907): the brief dialog both page entry points open,
|
|
20
|
-
* the Screens page's "
|
|
20
|
+
* the Screens page's "Create with AI" and the Assist panel's AI jobs.
|
|
21
21
|
*
|
|
22
22
|
* It is the shared brief dialog for a `page` job (AGL-3043): one text box and
|
|
23
|
-
* an optional page type. The job plans first
|
|
24
|
-
*
|
|
25
|
-
*
|
|
23
|
+
* an optional page type. The job plans first; the dialog then follows it and
|
|
24
|
+
* offers its plan to confirm, as AI jobs does (AGL-3593). Nothing is built
|
|
25
|
+
* until the member confirms.
|
|
26
26
|
*/
|
|
27
27
|
export type AiPageBriefDialogProps = Omit<AiBriefDialogProps, 'kind'>;
|
|
28
28
|
export declare function AiPageBriefDialog(props: AiPageBriefDialogProps): import("react").JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-page-brief-dialog.component.tsx"],"sourcesContent":["'use client'\n\n/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AiBriefDialog, type AiBriefDialogProps } from './ai-brief-dialog.component'\n\n/**\n * \"Describe a page\" (AGL-2907): the brief dialog both page entry points open,\n * the Screens page's \"
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-page-brief-dialog.component.tsx"],"sourcesContent":["'use client'\n\n/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { AiBriefDialog, type AiBriefDialogProps } from './ai-brief-dialog.component'\n\n/**\n * \"Describe a page\" (AGL-2907): the brief dialog both page entry points open,\n * the Screens page's \"Create with AI\" and the Assist panel's AI jobs.\n *\n * It is the shared brief dialog for a `page` job (AGL-3043): one text box and\n * an optional page type. The job plans first; the dialog then follows it and\n * offers its plan to confirm, as AI jobs does (AGL-3593). Nothing is built\n * until the member confirms.\n */\n\nexport type AiPageBriefDialogProps = Omit<AiBriefDialogProps, 'kind'>\n\nexport function AiPageBriefDialog(props: AiPageBriefDialogProps) {\n return <AiBriefDialog {...props} kind=\"page\" />\n}\n\nexport default AiPageBriefDialog\n"],"names":["AiBriefDialog","AiPageBriefDialog","props","kind"],"mappings":"AAAA;;;AAEA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,aAAa,QAAiC,iCAA6B;AAcpF,OAAO,SAASC,kBAAkBC,KAA6B;IAC7D,qBAAO,KAACF,4BAAkBE;QAAOC,MAAK;;AACxC;AAEA,eAAeF,kBAAiB"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import type { ConsolePluginPageProps } from '@aglyn/aglyn/plugin-manager/feature-plugins';
|
|
18
|
+
import type { MaybeTokenSource } from '@aglyn/shared-util-http/authorized-token';
|
|
19
|
+
import type { AiJobSummary } from '../model/ai-jobs.types';
|
|
20
|
+
/**
|
|
21
|
+
* "Building your site" (AGL-3594): one job's page, at `/ai-jobs/{jobId}`
|
|
22
|
+
* under its site — where the guided start sends a person the moment they
|
|
23
|
+
* plan a site, and where a notification about that job opens.
|
|
24
|
+
*
|
|
25
|
+
* A guided site start confirms its own plan (`autoConfirm`), so there is no
|
|
26
|
+
* approval to make here: the page says what is happening, step by step, live
|
|
27
|
+
* from the job's events route; shows what is being built; and, when the job
|
|
28
|
+
* ends, leads with the next thing to do — the live site and the pages to
|
|
29
|
+
* edit, or, where it stopped, the plain sentence for why and what to do
|
|
30
|
+
* about it. It is linkable and survives a reload, because it reads the job by
|
|
31
|
+
* the id in its own address under the site's own route.
|
|
32
|
+
*
|
|
33
|
+
* Every wait ends (AGL-3596): a site that cannot be read, a job the route
|
|
34
|
+
* does not know, a route that fails, and a first state that never arrives
|
|
35
|
+
* each end on a sentence instead of a spinner.
|
|
36
|
+
*
|
|
37
|
+
* Mounted by `AiJobsPage`, the plugin's unlisted `/ai-jobs` route: no tab on
|
|
38
|
+
* the site's strip, an address under it.
|
|
39
|
+
*/
|
|
40
|
+
/** How long the job's first state may take before the page says it could not be loaded. */
|
|
41
|
+
export declare const AI_JOB_FIRST_STATE_TIMEOUT_MS = 20000;
|
|
42
|
+
/**
|
|
43
|
+
* One job, followed by id: its latest summary; `null` while the first state
|
|
44
|
+
* is out; `'missing'` when the route says there is no such job for this
|
|
45
|
+
* reader; `'error'` when the route failed or no state arrived in time.
|
|
46
|
+
*/
|
|
47
|
+
export type AiJobByIdState = AiJobSummary | 'missing' | 'error' | null;
|
|
48
|
+
/** Follows one job by id. `retry` follows it again after a `'missing'` or `'error'`. */
|
|
49
|
+
export declare function useAiJobById(user: MaybeTokenSource, orgId: string | null, jobId: string | null): [AiJobByIdState, (job: AiJobSummary) => void, () => void];
|
|
50
|
+
export declare function AiSiteBuildPage({ hostId, segments, basePath }: ConsolePluginPageProps): import("react").JSX.Element;
|
|
51
|
+
export default AiSiteBuildPage;
|