@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,303 @@
|
|
|
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 { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
+
import { PLATFORM_BRAND_NAME } from "@aglyn/aglyn";
|
|
19
|
+
import { AppLink } from "@aglyn/shared-ui-jsx";
|
|
20
|
+
import { authorizedFetch } from "@aglyn/shared-util-http/authorized-token";
|
|
21
|
+
import { useUser } from "@aglyn/tenant-feature-instance";
|
|
22
|
+
import { Alert, Box, Button, Card, Chip, CircularProgress, Container, List, ListItemButton, Stack, Typography } from "@mui/material";
|
|
23
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
24
|
+
import { AI_JOB_PHASE_LABELS, aiJobKindNoun, aiJobPhase } from "../model/ai-job-activity.js";
|
|
25
|
+
import { publishAiJob } from "./ai-jobs-store.js";
|
|
26
|
+
import { useAiJobSite } from "./ai-job-site.js";
|
|
27
|
+
/**
|
|
28
|
+
* A site's AI jobs (AGL-3596), at `/ai-jobs` under the site: every job that
|
|
29
|
+
* worked on this site, newest first, each linking to its own page.
|
|
30
|
+
*
|
|
31
|
+
* Read through the jobs route, never Firestore, so the membership, flag and
|
|
32
|
+
* plan rungs that answer every other jobs read answer this one. The site is
|
|
33
|
+
* a query on the route (`hostId`), not a filter of the workspace's list.
|
|
34
|
+
*
|
|
35
|
+
* Every wait ends: the site's read and the list's each settle on content,
|
|
36
|
+
* the empty state, or a sentence with Try again.
|
|
37
|
+
*/ /** The most jobs the page lists; the newest, which is what a person comes for. */ export const AI_JOBS_PAGE_LIMIT = 50;
|
|
38
|
+
/** How long the list may take before the page says it could not be loaded. */ export const AI_JOBS_LIST_TIMEOUT_MS = 20000;
|
|
39
|
+
/** How much of a brief a row shows. */ const BRIEF_PREVIEW_CHARS = 120;
|
|
40
|
+
/** A row's chip, colored as the AI jobs drawer colors it. */ const PHASE_COLOR = {
|
|
41
|
+
queued: 'default',
|
|
42
|
+
planning: 'primary',
|
|
43
|
+
'plan-ready': 'warning',
|
|
44
|
+
building: 'primary',
|
|
45
|
+
attention: 'warning',
|
|
46
|
+
done: 'success',
|
|
47
|
+
failed: 'error',
|
|
48
|
+
canceled: 'default'
|
|
49
|
+
};
|
|
50
|
+
const WHEN = new Intl.DateTimeFormat('en-US', {
|
|
51
|
+
dateStyle: 'medium',
|
|
52
|
+
timeStyle: 'short'
|
|
53
|
+
});
|
|
54
|
+
/** What a job cost the person: what it spent, less what we refunded. */ export function aiJobNetCredits(job) {
|
|
55
|
+
var _job_creditsSpent, _job_refundedCredits;
|
|
56
|
+
return Math.max(0, ((_job_creditsSpent = job.creditsSpent) != null ? _job_creditsSpent : 0) - ((_job_refundedCredits = job.refundedCredits) != null ? _job_refundedCredits : 0));
|
|
57
|
+
}
|
|
58
|
+
/** The kind as a row names it: `Site`, `Page`, `AI job`. */ export function aiJobKindLabel(kind) {
|
|
59
|
+
const noun = aiJobKindNoun(kind);
|
|
60
|
+
return noun === 'AI job' ? noun : noun.charAt(0).toUpperCase() + noun.slice(1);
|
|
61
|
+
}
|
|
62
|
+
const LOAD_ERROR = 'This site’s AI jobs could not be loaded. Try again in a moment.';
|
|
63
|
+
async function readSiteJobs(user, orgId, hostId, signal) {
|
|
64
|
+
try {
|
|
65
|
+
var _ref, _ref1;
|
|
66
|
+
const response = await authorizedFetch(user, `/api/ai/jobs?orgId=${encodeURIComponent(orgId)}&hostId=${encodeURIComponent(hostId)}&limit=${AI_JOBS_PAGE_LIMIT}`, {
|
|
67
|
+
signal
|
|
68
|
+
});
|
|
69
|
+
const payload = await response.json().catch(()=>null);
|
|
70
|
+
if (!response.ok) return {
|
|
71
|
+
status: 'error',
|
|
72
|
+
message: String((_ref = payload == null ? void 0 : payload.error) != null ? _ref : LOAD_ERROR)
|
|
73
|
+
};
|
|
74
|
+
const jobs = (_ref1 = payload == null ? void 0 : payload.jobs) != null ? _ref1 : [];
|
|
75
|
+
// A job the top-bar indicator still counts that has settled since leaves it.
|
|
76
|
+
for (const job of jobs)publishAiJob(job);
|
|
77
|
+
return {
|
|
78
|
+
status: 'ready',
|
|
79
|
+
jobs
|
|
80
|
+
};
|
|
81
|
+
} catch (unused) {
|
|
82
|
+
return {
|
|
83
|
+
status: 'error',
|
|
84
|
+
message: LOAD_ERROR
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export function AiJobsListPage({ hostId, basePath }) {
|
|
89
|
+
var _ref;
|
|
90
|
+
const { data: user } = useUser();
|
|
91
|
+
const userRef = useRef(user);
|
|
92
|
+
userRef.current = user;
|
|
93
|
+
const site = useAiJobSite(hostId);
|
|
94
|
+
const orgId = site.status === 'ready' ? site.orgId : null;
|
|
95
|
+
const [list, setList] = useState({
|
|
96
|
+
status: 'loading'
|
|
97
|
+
});
|
|
98
|
+
const [attempt, setAttempt] = useState(0);
|
|
99
|
+
const uid = (_ref = user == null ? void 0 : user.uid) != null ? _ref : null;
|
|
100
|
+
useEffect(()=>{
|
|
101
|
+
if (!orgId || !hostId || !uid) return undefined;
|
|
102
|
+
const controller = new AbortController();
|
|
103
|
+
let settled = false;
|
|
104
|
+
setList({
|
|
105
|
+
status: 'loading'
|
|
106
|
+
});
|
|
107
|
+
const timer = setTimeout(()=>{
|
|
108
|
+
if (settled) return;
|
|
109
|
+
settled = true;
|
|
110
|
+
controller.abort();
|
|
111
|
+
setList({
|
|
112
|
+
status: 'error',
|
|
113
|
+
message: LOAD_ERROR
|
|
114
|
+
});
|
|
115
|
+
}, AI_JOBS_LIST_TIMEOUT_MS);
|
|
116
|
+
void readSiteJobs(userRef.current, orgId, hostId, controller.signal).then((next)=>{
|
|
117
|
+
if (settled) return;
|
|
118
|
+
settled = true;
|
|
119
|
+
clearTimeout(timer);
|
|
120
|
+
setList(next);
|
|
121
|
+
});
|
|
122
|
+
return ()=>{
|
|
123
|
+
settled = true;
|
|
124
|
+
clearTimeout(timer);
|
|
125
|
+
controller.abort();
|
|
126
|
+
};
|
|
127
|
+
}, [
|
|
128
|
+
orgId,
|
|
129
|
+
hostId,
|
|
130
|
+
uid,
|
|
131
|
+
attempt
|
|
132
|
+
]);
|
|
133
|
+
const retry = useCallback(()=>setAttempt((count)=>count + 1), []);
|
|
134
|
+
const siteName = site.status === 'ready' ? site.name : '';
|
|
135
|
+
const state = site.status === 'error' ? {
|
|
136
|
+
status: 'error',
|
|
137
|
+
message: 'This site could not be read. Check your connection and reload the page.'
|
|
138
|
+
} : list;
|
|
139
|
+
return /*#__PURE__*/ _jsx(Container, {
|
|
140
|
+
maxWidth: "md",
|
|
141
|
+
sx: {
|
|
142
|
+
py: {
|
|
143
|
+
xs: 3,
|
|
144
|
+
sm: 5
|
|
145
|
+
},
|
|
146
|
+
px: {
|
|
147
|
+
xs: 2,
|
|
148
|
+
sm: 3
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
152
|
+
spacing: 3,
|
|
153
|
+
children: [
|
|
154
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
155
|
+
spacing: 1,
|
|
156
|
+
children: [
|
|
157
|
+
siteName ? /*#__PURE__*/ _jsx(Typography, {
|
|
158
|
+
variant: "overline",
|
|
159
|
+
color: "text.secondary",
|
|
160
|
+
children: siteName
|
|
161
|
+
}) : null,
|
|
162
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
163
|
+
variant: "h4",
|
|
164
|
+
component: "h1",
|
|
165
|
+
children: 'AI jobs'
|
|
166
|
+
}),
|
|
167
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
168
|
+
variant: "body1",
|
|
169
|
+
color: "text.secondary",
|
|
170
|
+
children: `What ${PLATFORM_BRAND_NAME} AI has done and is doing on this site, newest first.`
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
}),
|
|
174
|
+
state.status === 'loading' ? /*#__PURE__*/ _jsx(Stack, {
|
|
175
|
+
sx: {
|
|
176
|
+
alignItems: 'center',
|
|
177
|
+
py: 4
|
|
178
|
+
},
|
|
179
|
+
children: /*#__PURE__*/ _jsx(CircularProgress, {
|
|
180
|
+
"aria-label": "Loading AI jobs"
|
|
181
|
+
})
|
|
182
|
+
}) : state.status === 'error' ? /*#__PURE__*/ _jsx(Alert, {
|
|
183
|
+
severity: "warning",
|
|
184
|
+
action: site.status === 'error' ? undefined : /*#__PURE__*/ _jsx(Button, {
|
|
185
|
+
color: "inherit",
|
|
186
|
+
size: "small",
|
|
187
|
+
onClick: retry,
|
|
188
|
+
children: 'Try again'
|
|
189
|
+
}),
|
|
190
|
+
children: state.message
|
|
191
|
+
}) : state.jobs.length === 0 ? /*#__PURE__*/ _jsx(Card, {
|
|
192
|
+
variant: "outlined",
|
|
193
|
+
sx: {
|
|
194
|
+
borderRadius: 2,
|
|
195
|
+
p: {
|
|
196
|
+
xs: 2,
|
|
197
|
+
sm: 3
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
children: /*#__PURE__*/ _jsxs(Stack, {
|
|
201
|
+
spacing: 1,
|
|
202
|
+
children: [
|
|
203
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
204
|
+
variant: "h6",
|
|
205
|
+
component: "h2",
|
|
206
|
+
children: 'No AI jobs on this site yet'
|
|
207
|
+
}),
|
|
208
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
209
|
+
variant: "body1",
|
|
210
|
+
color: "text.secondary",
|
|
211
|
+
children: `An AI job is ${PLATFORM_BRAND_NAME} AI building something for this site from a short ` + 'description you write: a page, a page template, a layout, a form or a reusable component. ' + 'Each one gets a page here that shows its progress and what it built.'
|
|
212
|
+
}),
|
|
213
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
214
|
+
variant: "body1",
|
|
215
|
+
color: "text.secondary",
|
|
216
|
+
children: 'To start one, choose Create with AI on this site’s Pages, Templates, Layouts, Forms or ' + 'Components page. A new site can also be built with AI when it is created.'
|
|
217
|
+
})
|
|
218
|
+
]
|
|
219
|
+
})
|
|
220
|
+
}) : /*#__PURE__*/ _jsx(Card, {
|
|
221
|
+
variant: "outlined",
|
|
222
|
+
sx: {
|
|
223
|
+
borderRadius: 2
|
|
224
|
+
},
|
|
225
|
+
children: /*#__PURE__*/ _jsx(List, {
|
|
226
|
+
disablePadding: true,
|
|
227
|
+
"aria-label": "AI jobs",
|
|
228
|
+
children: state.jobs.map((job, index)=>{
|
|
229
|
+
const phase = aiJobPhase(job);
|
|
230
|
+
const credits = aiJobNetCredits(job);
|
|
231
|
+
const brief = job.brief.length > BRIEF_PREVIEW_CHARS ? `${job.brief.slice(0, BRIEF_PREVIEW_CHARS)}…` : job.brief;
|
|
232
|
+
const created = new Date(job.createdAt);
|
|
233
|
+
return /*#__PURE__*/ _jsxs(ListItemButton, {
|
|
234
|
+
component: AppLink,
|
|
235
|
+
href: `${basePath != null ? basePath : ''}/${encodeURIComponent(job.id)}`,
|
|
236
|
+
divider: index < state.jobs.length - 1,
|
|
237
|
+
sx: {
|
|
238
|
+
display: 'block',
|
|
239
|
+
py: 1.5
|
|
240
|
+
},
|
|
241
|
+
children: [
|
|
242
|
+
/*#__PURE__*/ _jsxs(Stack, {
|
|
243
|
+
direction: "row",
|
|
244
|
+
spacing: 1,
|
|
245
|
+
sx: {
|
|
246
|
+
alignItems: 'center',
|
|
247
|
+
flexWrap: 'wrap',
|
|
248
|
+
rowGap: 0.5
|
|
249
|
+
},
|
|
250
|
+
children: [
|
|
251
|
+
/*#__PURE__*/ _jsx(Chip, {
|
|
252
|
+
size: "small",
|
|
253
|
+
variant: "outlined",
|
|
254
|
+
label: aiJobKindLabel(job.kind)
|
|
255
|
+
}),
|
|
256
|
+
/*#__PURE__*/ _jsx(Chip, {
|
|
257
|
+
size: "small",
|
|
258
|
+
color: PHASE_COLOR[phase],
|
|
259
|
+
label: AI_JOB_PHASE_LABELS[phase]
|
|
260
|
+
}),
|
|
261
|
+
/*#__PURE__*/ _jsx(Box, {
|
|
262
|
+
sx: {
|
|
263
|
+
flexGrow: 1
|
|
264
|
+
}
|
|
265
|
+
}),
|
|
266
|
+
/*#__PURE__*/ _jsxs(Typography, {
|
|
267
|
+
variant: "caption",
|
|
268
|
+
color: "text.secondary",
|
|
269
|
+
children: [
|
|
270
|
+
credits > 0 ? `${credits.toLocaleString('en-US')} credits · ` : '',
|
|
271
|
+
Number.isNaN(created.getTime()) ? null : /*#__PURE__*/ _jsx("time", {
|
|
272
|
+
dateTime: job.createdAt,
|
|
273
|
+
children: WHEN.format(created)
|
|
274
|
+
})
|
|
275
|
+
]
|
|
276
|
+
})
|
|
277
|
+
]
|
|
278
|
+
}),
|
|
279
|
+
/*#__PURE__*/ _jsx(Typography, {
|
|
280
|
+
variant: "body2",
|
|
281
|
+
sx: {
|
|
282
|
+
mt: 0.75,
|
|
283
|
+
wordBreak: 'break-word'
|
|
284
|
+
},
|
|
285
|
+
children: brief
|
|
286
|
+
})
|
|
287
|
+
]
|
|
288
|
+
}, job.id);
|
|
289
|
+
})
|
|
290
|
+
})
|
|
291
|
+
}),
|
|
292
|
+
state.status === 'ready' && state.jobs.length >= AI_JOBS_PAGE_LIMIT ? /*#__PURE__*/ _jsx(Typography, {
|
|
293
|
+
variant: "body2",
|
|
294
|
+
color: "text.secondary",
|
|
295
|
+
children: `Showing the ${AI_JOBS_PAGE_LIMIT} most recent jobs.`
|
|
296
|
+
}) : null
|
|
297
|
+
]
|
|
298
|
+
})
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
export default AiJobsListPage;
|
|
302
|
+
|
|
303
|
+
//# sourceMappingURL=ai-jobs-list-page.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-jobs-list-page.component.tsx"],"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 { PLATFORM_BRAND_NAME } from '@aglyn/aglyn'\nimport type { ConsolePluginPageProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { AppLink } from '@aglyn/shared-ui-jsx'\nimport { authorizedFetch, type MaybeTokenSource } from '@aglyn/shared-util-http/authorized-token'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport {\n Alert,\n Box,\n Button,\n Card,\n Chip,\n CircularProgress,\n Container,\n List,\n ListItemButton,\n Stack,\n Typography,\n} from '@mui/material'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { AI_JOB_PHASE_LABELS, aiJobKindNoun, aiJobPhase, type AiJobPhase } from '../model/ai-job-activity'\nimport type { AiJobSummary } from '../model/ai-jobs.types'\nimport { publishAiJob } from './ai-jobs-store'\nimport { useAiJobSite } from './ai-job-site'\n\n/**\n * A site's AI jobs (AGL-3596), at `/ai-jobs` under the site: every job that\n * worked on this site, newest first, each linking to its own page.\n *\n * Read through the jobs route, never Firestore, so the membership, flag and\n * plan rungs that answer every other jobs read answer this one. The site is\n * a query on the route (`hostId`), not a filter of the workspace's list.\n *\n * Every wait ends: the site's read and the list's each settle on content,\n * the empty state, or a sentence with Try again.\n */\n\n/** The most jobs the page lists; the newest, which is what a person comes for. */\nexport const AI_JOBS_PAGE_LIMIT = 50\n\n/** How long the list may take before the page says it could not be loaded. */\nexport const AI_JOBS_LIST_TIMEOUT_MS = 20_000\n\n/** How much of a brief a row shows. */\nconst BRIEF_PREVIEW_CHARS = 120\n\n/** A row's chip, colored as the AI jobs drawer colors it. */\nconst PHASE_COLOR: Record<AiJobPhase, 'default' | 'primary' | 'success' | 'error' | 'warning'> = {\n queued: 'default',\n planning: 'primary',\n 'plan-ready': 'warning',\n building: 'primary',\n attention: 'warning',\n done: 'success',\n failed: 'error',\n canceled: 'default',\n}\n\nconst WHEN = new Intl.DateTimeFormat('en-US', { dateStyle: 'medium', timeStyle: 'short' })\n\n/** What a job cost the person: what it spent, less what we refunded. */\nexport function aiJobNetCredits(job: Pick<AiJobSummary, 'creditsSpent' | 'refundedCredits'>): number {\n return Math.max(0, (job.creditsSpent ?? 0) - (job.refundedCredits ?? 0))\n}\n\n/** The kind as a row names it: `Site`, `Page`, `AI job`. */\nexport function aiJobKindLabel(kind: AiJobSummary['kind']): string {\n const noun = aiJobKindNoun(kind)\n return noun === 'AI job' ? noun : noun.charAt(0).toUpperCase() + noun.slice(1)\n}\n\ntype ListState =\n | { status: 'loading' }\n | { status: 'ready'; jobs: AiJobSummary[] }\n | { status: 'error'; message: string }\n\nconst LOAD_ERROR = 'This site’s AI jobs could not be loaded. Try again in a moment.'\n\nasync function readSiteJobs(\n user: MaybeTokenSource,\n orgId: string,\n hostId: string,\n signal: AbortSignal,\n): Promise<ListState> {\n try {\n const response = await authorizedFetch(\n user,\n `/api/ai/jobs?orgId=${encodeURIComponent(orgId)}&hostId=${encodeURIComponent(hostId)}&limit=${AI_JOBS_PAGE_LIMIT}`,\n { signal },\n )\n const payload = (await response.json().catch(() => null)) as { jobs?: AiJobSummary[]; error?: string } | null\n if (!response.ok) return { status: 'error', message: String(payload?.error ?? LOAD_ERROR) }\n const jobs = payload?.jobs ?? []\n // A job the top-bar indicator still counts that has settled since leaves it.\n for (const job of jobs) publishAiJob(job)\n return { status: 'ready', jobs }\n } catch {\n return { status: 'error', message: LOAD_ERROR }\n }\n}\n\nexport function AiJobsListPage({ hostId, basePath }: ConsolePluginPageProps) {\n const { data: user } = useUser()\n const userRef = useRef<MaybeTokenSource>(user)\n userRef.current = user\n const site = useAiJobSite(hostId)\n const orgId = site.status === 'ready' ? site.orgId : null\n const [list, setList] = useState<ListState>({ status: 'loading' })\n const [attempt, setAttempt] = useState(0)\n const uid = user?.uid ?? null\n\n useEffect(() => {\n if (!orgId || !hostId || !uid) return undefined\n const controller = new AbortController()\n let settled = false\n setList({ status: 'loading' })\n const timer = setTimeout(() => {\n if (settled) return\n settled = true\n controller.abort()\n setList({ status: 'error', message: LOAD_ERROR })\n }, AI_JOBS_LIST_TIMEOUT_MS)\n void readSiteJobs(userRef.current, orgId, hostId, controller.signal).then((next) => {\n if (settled) return\n settled = true\n clearTimeout(timer)\n setList(next)\n })\n return () => {\n settled = true\n clearTimeout(timer)\n controller.abort()\n }\n }, [orgId, hostId, uid, attempt])\n\n const retry = useCallback(() => setAttempt((count) => count + 1), [])\n\n const siteName = site.status === 'ready' ? site.name : ''\n const state: ListState =\n site.status === 'error'\n ? { status: 'error', message: 'This site could not be read. Check your connection and reload the page.' }\n : list\n\n return (\n <Container maxWidth=\"md\" sx={{ py: { xs: 3, sm: 5 }, px: { xs: 2, sm: 3 } }}>\n <Stack spacing={3}>\n <Stack spacing={1}>\n {siteName ? (\n <Typography variant=\"overline\" color=\"text.secondary\">\n {siteName}\n </Typography>\n ) : null}\n <Typography variant=\"h4\" component=\"h1\">\n {'AI jobs'}\n </Typography>\n <Typography variant=\"body1\" color=\"text.secondary\">\n {`What ${PLATFORM_BRAND_NAME} AI has done and is doing on this site, newest first.`}\n </Typography>\n </Stack>\n {state.status === 'loading' ? (\n <Stack sx={{ alignItems: 'center', py: 4 }}>\n <CircularProgress aria-label=\"Loading AI jobs\" />\n </Stack>\n ) : state.status === 'error' ? (\n <Alert\n severity=\"warning\"\n action={\n site.status === 'error' ? undefined : (\n <Button color=\"inherit\" size=\"small\" onClick={retry}>\n {'Try again'}\n </Button>\n )\n }\n >\n {state.message}\n </Alert>\n ) : state.jobs.length === 0 ? (\n <Card variant=\"outlined\" sx={{ borderRadius: 2, p: { xs: 2, sm: 3 } }}>\n <Stack spacing={1}>\n <Typography variant=\"h6\" component=\"h2\">\n {'No AI jobs on this site yet'}\n </Typography>\n <Typography variant=\"body1\" color=\"text.secondary\">\n {`An AI job is ${PLATFORM_BRAND_NAME} AI building something for this site from a short ` +\n 'description you write: a page, a page template, a layout, a form or a reusable component. ' +\n 'Each one gets a page here that shows its progress and what it built.'}\n </Typography>\n <Typography variant=\"body1\" color=\"text.secondary\">\n {'To start one, choose Create with AI on this site’s Pages, Templates, Layouts, Forms or ' +\n 'Components page. A new site can also be built with AI when it is created.'}\n </Typography>\n </Stack>\n </Card>\n ) : (\n <Card variant=\"outlined\" sx={{ borderRadius: 2 }}>\n <List disablePadding aria-label=\"AI jobs\">\n {state.jobs.map((job, index) => {\n const phase = aiJobPhase(job)\n const credits = aiJobNetCredits(job)\n const brief =\n job.brief.length > BRIEF_PREVIEW_CHARS ? `${job.brief.slice(0, BRIEF_PREVIEW_CHARS)}…` : job.brief\n const created = new Date(job.createdAt)\n return (\n <ListItemButton\n key={job.id}\n component={AppLink}\n href={`${basePath ?? ''}/${encodeURIComponent(job.id)}`}\n divider={index < state.jobs.length - 1}\n sx={{ display: 'block', py: 1.5 }}\n >\n <Stack direction=\"row\" spacing={1} sx={{ alignItems: 'center', flexWrap: 'wrap', rowGap: 0.5 }}>\n <Chip size=\"small\" variant=\"outlined\" label={aiJobKindLabel(job.kind)} />\n <Chip size=\"small\" color={PHASE_COLOR[phase]} label={AI_JOB_PHASE_LABELS[phase]} />\n <Box sx={{ flexGrow: 1 }} />\n <Typography variant=\"caption\" color=\"text.secondary\">\n {credits > 0 ? `${credits.toLocaleString('en-US')} credits · ` : ''}\n {Number.isNaN(created.getTime()) ? null : (\n <time dateTime={job.createdAt}>{WHEN.format(created)}</time>\n )}\n </Typography>\n </Stack>\n <Typography variant=\"body2\" sx={{ mt: 0.75, wordBreak: 'break-word' }}>\n {brief}\n </Typography>\n </ListItemButton>\n )\n })}\n </List>\n </Card>\n )}\n {state.status === 'ready' && state.jobs.length >= AI_JOBS_PAGE_LIMIT ? (\n <Typography variant=\"body2\" color=\"text.secondary\">\n {`Showing the ${AI_JOBS_PAGE_LIMIT} most recent jobs.`}\n </Typography>\n ) : null}\n </Stack>\n </Container>\n )\n}\n\nexport default AiJobsListPage\n"],"names":["PLATFORM_BRAND_NAME","AppLink","authorizedFetch","useUser","Alert","Box","Button","Card","Chip","CircularProgress","Container","List","ListItemButton","Stack","Typography","useCallback","useEffect","useRef","useState","AI_JOB_PHASE_LABELS","aiJobKindNoun","aiJobPhase","publishAiJob","useAiJobSite","AI_JOBS_PAGE_LIMIT","AI_JOBS_LIST_TIMEOUT_MS","BRIEF_PREVIEW_CHARS","PHASE_COLOR","queued","planning","building","attention","done","failed","canceled","WHEN","Intl","DateTimeFormat","dateStyle","timeStyle","aiJobNetCredits","job","Math","max","creditsSpent","refundedCredits","aiJobKindLabel","kind","noun","charAt","toUpperCase","slice","LOAD_ERROR","readSiteJobs","user","orgId","hostId","signal","response","encodeURIComponent","payload","json","catch","ok","status","message","String","error","jobs","AiJobsListPage","basePath","data","userRef","current","site","list","setList","attempt","setAttempt","uid","undefined","controller","AbortController","settled","timer","setTimeout","abort","then","next","clearTimeout","retry","count","siteName","name","state","maxWidth","sx","py","xs","sm","px","spacing","variant","color","component","alignItems","aria-label","severity","action","size","onClick","length","borderRadius","p","disablePadding","map","index","phase","credits","brief","created","Date","createdAt","href","id","divider","display","direction","flexWrap","rowGap","label","flexGrow","toLocaleString","Number","isNaN","getTime","time","dateTime","format","mt","wordBreak"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,mBAAmB,QAAQ,eAAc;AAElD,SAASC,OAAO,QAAQ,uBAAsB;AAC9C,SAASC,eAAe,QAA+B,2CAA0C;AACjG,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SACEC,KAAK,EACLC,GAAG,EACHC,MAAM,EACNC,IAAI,EACJC,IAAI,EACJC,gBAAgB,EAChBC,SAAS,EACTC,IAAI,EACJC,cAAc,EACdC,KAAK,EACLC,UAAU,QACL,gBAAe;AACtB,SA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W4B,OAAOpF,eAAeL,IAAIM,IAAI;;0DACpE,KAACvC;gDAAKqG,MAAK;gDAAQN,OAAO5E,WAAW,CAAC0F,MAAM;gDAAEa,OAAO/G,mBAAmB,CAACkG,MAAM;;0DAC/E,KAAChH;gDAAI2F,IAAI;oDAAEmC,UAAU;gDAAE;;0DACvB,MAACrH;gDAAWwF,SAAQ;gDAAUC,OAAM;;oDACjCe,UAAU,IAAI,GAAGA,QAAQc,cAAc,CAAC,SAAS,WAAW,CAAC,GAAG;oDAChEC,OAAOC,KAAK,CAACd,QAAQe,OAAO,MAAM,qBACjC,KAACC;wDAAKC,UAAUhG,IAAIiF,SAAS;kEAAGvF,KAAKuG,MAAM,CAAClB;;;;;;kDAIlD,KAAC1G;wCAAWwF,SAAQ;wCAAQN,IAAI;4CAAE2C,IAAI;4CAAMC,WAAW;wCAAa;kDACjErB;;;+BAlBE9E,IAAImF,EAAE;wBAsBjB;;;gBAIL9B,MAAM9B,MAAM,KAAK,WAAW8B,MAAM1B,IAAI,CAAC2C,MAAM,IAAIvF,mCAChD,KAACV;oBAAWwF,SAAQ;oBAAQC,OAAM;8BAC/B,CAAC,YAAY,EAAE/E,mBAAmB,kBAAkB,CAAC;qBAEtD;;;;AAIZ;AAEA,eAAe6C,eAAc"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ConsolePluginPageProps } from '@aglyn/aglyn/plugin-manager/feature-plugins';
|
|
2
|
+
/**
|
|
3
|
+
* The AI plugin's `/ai-jobs` route under a site (AGL-3596): the bare address
|
|
4
|
+
* lists the site's jobs, and `/ai-jobs/{jobId}` is one job's page.
|
|
5
|
+
*/
|
|
6
|
+
export declare function AiJobsPage(props: ConsolePluginPageProps): import("react").JSX.Element;
|
|
7
|
+
export default AiJobsPage;
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
19
|
+
import { AiJobsListPage } from "./ai-jobs-list-page.component.js";
|
|
20
|
+
import { AiSiteBuildPage } from "./ai-site-build-page.component.js";
|
|
21
|
+
/**
|
|
22
|
+
* The AI plugin's `/ai-jobs` route under a site (AGL-3596): the bare address
|
|
23
|
+
* lists the site's jobs, and `/ai-jobs/{jobId}` is one job's page.
|
|
24
|
+
*/ export function AiJobsPage(props) {
|
|
25
|
+
var _props_segments;
|
|
26
|
+
return ((_props_segments = props.segments) == null ? void 0 : _props_segments[0]) ? /*#__PURE__*/ _jsx(AiSiteBuildPage, _extends({}, props)) : /*#__PURE__*/ _jsx(AiJobsListPage, _extends({}, props));
|
|
27
|
+
}
|
|
28
|
+
export default AiJobsPage;
|
|
29
|
+
|
|
30
|
+
//# sourceMappingURL=ai-jobs-page.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/components/ai-jobs-page.component.tsx"],"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 type { ConsolePluginPageProps } from '@aglyn/aglyn/plugin-manager/feature-plugins'\nimport { AiJobsListPage } from './ai-jobs-list-page.component'\nimport { AiSiteBuildPage } from './ai-site-build-page.component'\n\n/**\n * The AI plugin's `/ai-jobs` route under a site (AGL-3596): the bare address\n * lists the site's jobs, and `/ai-jobs/{jobId}` is one job's page.\n */\nexport function AiJobsPage(props: ConsolePluginPageProps) {\n return props.segments?.[0] ? <AiSiteBuildPage {...props} /> : <AiJobsListPage {...props} />\n}\n\nexport default AiJobsPage\n"],"names":["AiJobsListPage","AiSiteBuildPage","AiJobsPage","props","segments"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAGA,SAASA,cAAc,QAAQ,mCAA+B;AAC9D,SAASC,eAAe,QAAQ,oCAAgC;AAEhE;;;CAGC,GACD,OAAO,SAASC,WAAWC,KAA6B;QAC/CA;IAAP,OAAOA,EAAAA,kBAAAA,MAAMC,QAAQ,qBAAdD,eAAgB,CAAC,EAAE,kBAAG,KAACF,8BAAoBE,wBAAY,KAACH,6BAAmBG;AACpF;AAEA,eAAeD,WAAU"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { type TokenSource } from '@aglyn/shared-util-http/authorized-token';
|
|
2
|
+
import { type AiJobsActivity } from '../model/ai-job-activity';
|
|
3
|
+
import { type AiJobSummary } from '../model/ai-jobs.types';
|
|
4
|
+
/**
|
|
5
|
+
* WHERE A PERSON FINDS THEIR AI JOBS (AGL-3593).
|
|
6
|
+
*
|
|
7
|
+
* Two things every AI surface in the console shares, kept in this module
|
|
8
|
+
* rather than in any one component because the surfaces that need them — a
|
|
9
|
+
* brief dialog on the Screens page, the guided start's full-screen dialog,
|
|
10
|
+
* the top-bar indicator, the Assist launcher and the drawer inside the
|
|
11
|
+
* panel — are mounted in different zones and know nothing of one another.
|
|
12
|
+
* All of them are this plugin's, so no shell, zone or event bus carries it.
|
|
13
|
+
*
|
|
14
|
+
* ── Opening AI jobs ──────────────────────────────────────────────────────
|
|
15
|
+
*
|
|
16
|
+
* {@link openAiJobs} is the one action every "Open AI jobs" button, the
|
|
17
|
+
* indicator and a notification's link take: the Assist panel subscribes, opens
|
|
18
|
+
* itself, expands its AI jobs drawer, and scrolls to and highlights the job
|
|
19
|
+
* named. A request is a sequence number as well as a job, so asking twice for
|
|
20
|
+
* the same job opens it twice.
|
|
21
|
+
*
|
|
22
|
+
* ── The workspace's unsettled jobs ───────────────────────────────────────
|
|
23
|
+
*
|
|
24
|
+
* The indicator, the launcher's badge and the drawer's open-by-default rule
|
|
25
|
+
* read the same list: the workspace's jobs that are not yet settled, from
|
|
26
|
+
* the jobs route's `status=active` (a Firestore `in` query under the
|
|
27
|
+
* (status, createdAt) index, never a filter of a loaded window). ONE list per
|
|
28
|
+
* person and workspace however many surfaces read it, re-read on a timer only
|
|
29
|
+
* while something in it is still moving or waiting and the tab is in view —
|
|
30
|
+
* a workspace with nothing running costs one read per page load and no more.
|
|
31
|
+
*
|
|
32
|
+
* Every surface that learns a job's state some other way — the dialog that
|
|
33
|
+
* created it, the drawer's event stream, the in-dialog confirm — hands it in
|
|
34
|
+
* through {@link publishAiJob}, so the indicator moves the moment the job
|
|
35
|
+
* does rather than on the next read.
|
|
36
|
+
*/
|
|
37
|
+
/** The latest request to open AI jobs; `seq` is 0 until anything asked. */
|
|
38
|
+
export interface AiJobsOpenRequest {
|
|
39
|
+
seq: number;
|
|
40
|
+
/** The job to scroll to and highlight, or `null` for the drawer alone. */
|
|
41
|
+
jobId: string | null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Opens the Assist panel on its AI jobs drawer, expanded, scrolled to
|
|
45
|
+
* `jobId` when one is named. A surface that covers the panel — a dialog —
|
|
46
|
+
* closes itself beside the call; this opens, it does not close anything.
|
|
47
|
+
*/
|
|
48
|
+
export declare function openAiJobs(options?: {
|
|
49
|
+
jobId?: string | null;
|
|
50
|
+
}): void;
|
|
51
|
+
/** The latest open request, for the panel; a new `seq` is a new request. */
|
|
52
|
+
export declare function useAiJobsOpenRequest(): AiJobsOpenRequest;
|
|
53
|
+
/**
|
|
54
|
+
* The query parameter a notification's link carries: a console page opened
|
|
55
|
+
* with `?aiJob={id}` opens AI jobs on that job, the way pressing the
|
|
56
|
+
* indicator does.
|
|
57
|
+
*/
|
|
58
|
+
export { AI_JOB_LINK_PARAM } from '../model/ai-job-notice';
|
|
59
|
+
/** How often a list with something in it is read again, while the tab is in view. */
|
|
60
|
+
export declare const AI_JOBS_ACTIVE_POLL_MS = 15000;
|
|
61
|
+
/**
|
|
62
|
+
* Hands a job's latest state to every surface counting this workspace's jobs:
|
|
63
|
+
* a new job joins the list, a settled one leaves it. Keyed on the job's own
|
|
64
|
+
* workspace, for every person whose list holds that workspace in this tab.
|
|
65
|
+
*/
|
|
66
|
+
export declare function publishAiJob(job: AiJobSummary | null | undefined): void;
|
|
67
|
+
/** Forget every list and request; specs start each case from nothing. */
|
|
68
|
+
export declare function resetAiJobsStoreForTests(): void;
|
|
69
|
+
/**
|
|
70
|
+
* The workspace's jobs that are not yet settled, newest first, for the
|
|
71
|
+
* signed-in person — empty while the first read is in flight, where the
|
|
72
|
+
* route refuses, and when `enabled` is false (a surface whose own gates have
|
|
73
|
+
* not passed reads nothing at all).
|
|
74
|
+
*/
|
|
75
|
+
export declare function useAiJobsInFlight(user: (TokenSource & {
|
|
76
|
+
uid?: string | null;
|
|
77
|
+
}) | null | undefined, orgId: string | null | undefined, enabled?: boolean): readonly AiJobSummary[];
|
|
78
|
+
/** What the indicator and the launcher show for the workspace, or `null` for nothing. */
|
|
79
|
+
export declare function useAiJobsActivity(user: (TokenSource & {
|
|
80
|
+
uid?: string | null;
|
|
81
|
+
}) | null | undefined, orgId: string | null | undefined, enabled?: boolean): AiJobsActivity<AiJobSummary> | null;
|