@aglyn/plugins-ai 1.0.0-beta.293 → 1.0.0-beta.296
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/package.json +17 -17
- package/src/lib/components/ai-job-links.d.ts +15 -2
- package/src/lib/components/ai-job-links.js +24 -3
- package/src/lib/components/ai-job-links.js.map +1 -1
- package/src/lib/components/ai-job-requests.d.ts +9 -0
- package/src/lib/components/ai-job-requests.js +34 -0
- package/src/lib/components/ai-job-requests.js.map +1 -1
- package/src/lib/components/ai-site-build-page.component.js +28 -2
- package/src/lib/components/ai-site-build-page.component.js.map +1 -1
- package/src/lib/components/assist-jobs-drawer.component.d.ts +7 -1
- package/src/lib/components/assist-jobs-drawer.component.js +20 -6
- package/src/lib/components/assist-jobs-drawer.component.js.map +1 -1
- package/src/lib/components/assist-page-change-card.component.d.ts +44 -0
- package/src/lib/components/assist-page-change-card.component.js +166 -0
- package/src/lib/components/assist-page-change-card.component.js.map +1 -0
- package/src/lib/components/assist-panel.component.d.ts +105 -1
- package/src/lib/components/assist-panel.component.js +224 -29
- package/src/lib/components/assist-panel.component.js.map +1 -1
- package/src/lib/jobs/ai-job-edit-step.d.ts +62 -16
- package/src/lib/jobs/ai-job-edit-step.js +172 -61
- package/src/lib/jobs/ai-job-edit-step.js.map +1 -1
- package/src/lib/jobs/ai-job-navigation-step.js +4 -2
- package/src/lib/jobs/ai-job-navigation-step.js.map +1 -1
- package/src/lib/model/ai-edit-job.d.ts +33 -16
- package/src/lib/model/ai-edit-job.js +50 -34
- package/src/lib/model/ai-edit-job.js.map +1 -1
- package/src/lib/model/ai-job-activity.d.ts +6 -11
- package/src/lib/model/ai-job-activity.js +8 -15
- package/src/lib/model/ai-job-activity.js.map +1 -1
- package/src/lib/model/ai-jobs.types.d.ts +6 -0
- package/src/lib/model/ai-jobs.types.js.map +1 -1
- package/src/lib/model/ai-site-inventory.d.ts +6 -0
- package/src/lib/model/ai-site-inventory.js.map +1 -1
- package/src/lib/model/assist-edit.d.ts +18 -1
- package/src/lib/model/assist-edit.js +7 -0
- package/src/lib/model/assist-edit.js.map +1 -1
- package/src/lib/model/assist-page-change.d.ts +86 -0
- package/src/lib/model/assist-page-change.js +86 -0
- package/src/lib/model/assist-page-change.js.map +1 -0
- package/src/lib/runtime/ai-eval.js +3 -1
- package/src/lib/runtime/ai-eval.js.map +1 -1
- package/src/lib/runtime/ai-node-tree.d.ts +5 -0
- package/src/lib/runtime/ai-node-tree.js +18 -3
- package/src/lib/runtime/ai-node-tree.js.map +1 -1
- package/src/lib/runtime/site-inventory.d.ts +8 -1
- package/src/lib/runtime/site-inventory.js +18 -0
- package/src/lib/runtime/site-inventory.js.map +1 -1
- package/src/lib/server/assist-build.js +2 -0
- package/src/lib/server/assist-build.js.map +1 -1
- package/src/lib/server/assist-chat.js +51 -2
- package/src/lib/server/assist-chat.js.map +1 -1
- package/src/lib/server/assist-edit.d.ts +54 -2
- package/src/lib/server/assist-edit.js +219 -30
- package/src/lib/server/assist-edit.js.map +1 -1
- package/src/lib/server/assist-page-change.d.ts +62 -0
- package/src/lib/server/assist-page-change.js +140 -0
- package/src/lib/server/assist-page-change.js.map +1 -0
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
* A change to a page the site already has, asked in the Assist chat
|
|
18
|
+
* (AGL-4116). No plan and no new page: the panel starts one `edit` job on
|
|
19
|
+
* that page, which saves the change into the page's draft — on every plan,
|
|
20
|
+
* the draft the Besigner offers with Open draft — and the card links the
|
|
21
|
+
* page in the Besigner, where the person checks it and publishes it. Only
|
|
22
|
+
* when they ask for a new version, and the plan keeps version history, is
|
|
23
|
+
* the change saved as a new unpublished version instead.
|
|
24
|
+
*
|
|
25
|
+
* Asked through a build, a change to the home page came back as a second
|
|
26
|
+
* page at `/` the plan generated from scratch, and every follow-up made
|
|
27
|
+
* another plan. This is the short way, for the request that only changes
|
|
28
|
+
* what is there.
|
|
29
|
+
*
|
|
30
|
+
* Shared by the chat door that resolves it and the panel that starts it.
|
|
31
|
+
* Pure: no request, no React.
|
|
32
|
+
*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
33
|
+
/** The strict tool the chat model asks for a change to a page through. */ export const ASSIST_PAGE_CHANGE_TOOL_NAME = 'change_page';
|
|
34
|
+
/** The proposal's fixed id, as `assistant_proposal_shown` records it. */ export const ASSIST_PAGE_CHANGE_ACTION_ID = 'page-change';
|
|
35
|
+
/** The longest one-line summary the card shows. */ export const ASSIST_PAGE_CHANGE_SUMMARY_MAX_CHARS = 200;
|
|
36
|
+
const DOCUMENT_ID = /^[A-Za-z0-9_-]{1,100}$/;
|
|
37
|
+
function isRecord(value) {
|
|
38
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
39
|
+
}
|
|
40
|
+
/** Shape-checks a page change before it can start a job. */ export function isAssistPageChangeProposal(value) {
|
|
41
|
+
if (!isRecord(value) || value['id'] !== ASSIST_PAGE_CHANGE_ACTION_ID) return false;
|
|
42
|
+
return typeof value['hostId'] === 'string' && DOCUMENT_ID.test(value['hostId']) && typeof value['pageId'] === 'string' && DOCUMENT_ID.test(value['pageId']) && typeof value['pageName'] === 'string' && typeof value['brief'] === 'string' && value['brief'].trim().length > 0 && typeof value['summary'] === 'string' && (value['newVersion'] === undefined || typeof value['newVersion'] === 'boolean');
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The body of `POST /api/ai/jobs` a page change starts: an `edit` of the
|
|
46
|
+
* page. `versionId` is the version an earlier change in the same
|
|
47
|
+
* conversation wrote to, so a follow-up changes that version's draft rather
|
|
48
|
+
* than starting again from the published page.
|
|
49
|
+
*/ export function assistPageChangeJobRequest(orgId, proposal, versionId) {
|
|
50
|
+
return {
|
|
51
|
+
orgId,
|
|
52
|
+
hostId: proposal.hostId,
|
|
53
|
+
kind: 'edit',
|
|
54
|
+
brief: proposal.brief,
|
|
55
|
+
inputs: _extends({
|
|
56
|
+
target: proposal.pageId,
|
|
57
|
+
targetKind: 'screen'
|
|
58
|
+
}, versionId ? {
|
|
59
|
+
versionId
|
|
60
|
+
} : {}, proposal.newVersion ? {
|
|
61
|
+
newVersion: true
|
|
62
|
+
} : {})
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
/** The version a finished change wrote to the page, or `null` before there is one. */ export function assistPageChangeOutput(job) {
|
|
66
|
+
var _job_outputs_find;
|
|
67
|
+
if (!job || job.status !== 'done') return null;
|
|
68
|
+
return (_job_outputs_find = job.outputs.find((output)=>output.resource === 'screen' && Boolean(output.versionId))) != null ? _job_outputs_find : null;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The version a new change to `pageId` continues (AGL-4116): the one the
|
|
72
|
+
* conversation's latest finished change to that page wrote to — its draft
|
|
73
|
+
* holds that change — or `null` to start from the page as it is.
|
|
74
|
+
*/ export function assistPageChangeDraftVersion(changes, pageId) {
|
|
75
|
+
for(let index = changes.length - 1; index >= 0; index -= 1){
|
|
76
|
+
var _change_pageChangeJob;
|
|
77
|
+
var _change_pageChange;
|
|
78
|
+
const change = changes[index];
|
|
79
|
+
if (((_change_pageChange = change.pageChange) == null ? void 0 : _change_pageChange.pageId) !== pageId) continue;
|
|
80
|
+
const output = assistPageChangeOutput((_change_pageChangeJob = change.pageChangeJob) != null ? _change_pageChangeJob : null);
|
|
81
|
+
if (output == null ? void 0 : output.versionId) return output.versionId;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=assist-page-change.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/model/assist-page-change.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\n/**\n * A change to a page the site already has, asked in the Assist chat\n * (AGL-4116). No plan and no new page: the panel starts one `edit` job on\n * that page, which saves the change into the page's draft — on every plan,\n * the draft the Besigner offers with Open draft — and the card links the\n * page in the Besigner, where the person checks it and publishes it. Only\n * when they ask for a new version, and the plan keeps version history, is\n * the change saved as a new unpublished version instead.\n *\n * Asked through a build, a change to the home page came back as a second\n * page at `/` the plan generated from scratch, and every follow-up made\n * another plan. This is the short way, for the request that only changes\n * what is there.\n *\n * Shared by the chat door that resolves it and the panel that starts it.\n * Pure: no request, no React.\n */\n\nimport type { AiJobOutput, AiJobSummary } from './ai-jobs.types'\n\n/** The strict tool the chat model asks for a change to a page through. */\nexport const ASSIST_PAGE_CHANGE_TOOL_NAME = 'change_page'\n\n/** The proposal's fixed id, as `assistant_proposal_shown` records it. */\nexport const ASSIST_PAGE_CHANGE_ACTION_ID = 'page-change'\n\n/** The longest one-line summary the card shows. */\nexport const ASSIST_PAGE_CHANGE_SUMMARY_MAX_CHARS = 200\n\nconst DOCUMENT_ID = /^[A-Za-z0-9_-]{1,100}$/\n\nexport interface AssistPageChangeProposal {\n id: typeof ASSIST_PAGE_CHANGE_ACTION_ID\n /** The site the request was asked on; the job is created for it. */\n hostId: string\n /** The page to change: one the site has, by its id. */\n pageId: string\n /** The page's name, as the site's list of pages gives it. */\n pageName: string\n /** What to change on it, in the person's words. */\n brief: string\n /** One line saying what will change. */\n summary: string\n /** They asked for a new version of the page; otherwise the change goes into its draft. */\n newVersion?: boolean\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value)\n}\n\n/** Shape-checks a page change before it can start a job. */\nexport function isAssistPageChangeProposal(value: unknown): value is AssistPageChangeProposal {\n if (!isRecord(value) || value['id'] !== ASSIST_PAGE_CHANGE_ACTION_ID) return false\n return (\n typeof value['hostId'] === 'string' &&\n DOCUMENT_ID.test(value['hostId']) &&\n typeof value['pageId'] === 'string' &&\n DOCUMENT_ID.test(value['pageId']) &&\n typeof value['pageName'] === 'string' &&\n typeof value['brief'] === 'string' &&\n value['brief'].trim().length > 0 &&\n typeof value['summary'] === 'string' &&\n (value['newVersion'] === undefined || typeof value['newVersion'] === 'boolean')\n )\n}\n\n/**\n * The body of `POST /api/ai/jobs` a page change starts: an `edit` of the\n * page. `versionId` is the version an earlier change in the same\n * conversation wrote to, so a follow-up changes that version's draft rather\n * than starting again from the published page.\n */\nexport function assistPageChangeJobRequest(\n orgId: string,\n proposal: AssistPageChangeProposal,\n versionId: string | null,\n): {\n orgId: string\n hostId: string\n kind: 'edit'\n brief: string\n inputs: { target: string; targetKind: 'screen'; versionId?: string; newVersion?: true }\n} {\n return {\n orgId,\n hostId: proposal.hostId,\n kind: 'edit',\n brief: proposal.brief,\n inputs: {\n target: proposal.pageId,\n targetKind: 'screen',\n ...(versionId ? { versionId } : {}),\n ...(proposal.newVersion ? { newVersion: true as const } : {}),\n },\n }\n}\n\n/** The version a finished change wrote to the page, or `null` before there is one. */\nexport function assistPageChangeOutput(job: Pick<AiJobSummary, 'status' | 'outputs'> | null): AiJobOutput | null {\n if (!job || job.status !== 'done') return null\n return job.outputs.find((output) => output.resource === 'screen' && Boolean(output.versionId)) ?? null\n}\n\n/**\n * The version a new change to `pageId` continues (AGL-4116): the one the\n * conversation's latest finished change to that page wrote to — its draft\n * holds that change — or `null` to start from the page as it is.\n */\nexport function assistPageChangeDraftVersion(\n changes: ReadonlyArray<{ pageChange?: AssistPageChangeProposal | null; pageChangeJob?: AiJobSummary | null }>,\n pageId: string,\n): string | null {\n for (let index = changes.length - 1; index >= 0; index -= 1) {\n const change = changes[index]\n if (change.pageChange?.pageId !== pageId) continue\n const output = assistPageChangeOutput(change.pageChangeJob ?? null)\n if (output?.versionId) return output.versionId\n }\n return null\n}\n"],"names":["ASSIST_PAGE_CHANGE_TOOL_NAME","ASSIST_PAGE_CHANGE_ACTION_ID","ASSIST_PAGE_CHANGE_SUMMARY_MAX_CHARS","DOCUMENT_ID","isRecord","value","Array","isArray","isAssistPageChangeProposal","test","trim","length","undefined","assistPageChangeJobRequest","orgId","proposal","versionId","hostId","kind","brief","inputs","target","pageId","targetKind","newVersion","assistPageChangeOutput","job","status","outputs","find","output","resource","Boolean","assistPageChangeDraftVersion","changes","index","change","pageChange","pageChangeJob"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;CAgBC;AAID,wEAAwE,GACxE,OAAO,MAAMA,+BAA+B,cAAa;AAEzD,uEAAuE,GACvE,OAAO,MAAMC,+BAA+B,cAAa;AAEzD,iDAAiD,GACjD,OAAO,MAAMC,uCAAuC,IAAG;AAEvD,MAAMC,cAAc;AAkBpB,SAASC,SAASC,KAAc;IAC9B,OAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,CAACC,MAAMC,OAAO,CAACF;AACvE;AAEA,0DAA0D,GAC1D,OAAO,SAASG,2BAA2BH,KAAc;IACvD,IAAI,CAACD,SAASC,UAAUA,KAAK,CAAC,KAAK,KAAKJ,8BAA8B,OAAO;IAC7E,OAC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C,UAAU,qBAAjBD,mBAAmBd,MAAM,MAAKA,QAAQ;QAC1C,MAAMQ,SAASL,wBAAuBW,wBAAAA,OAAOE,aAAa,YAApBF,wBAAwB;QAC9D,IAAIN,0BAAAA,OAAQd,SAAS,EAAE,OAAOc,OAAOd,SAAS;IAChD;IACA,OAAO;AACT"}
|
|
@@ -785,7 +785,9 @@ const CRM_OVER = new Set([
|
|
|
785
785
|
};
|
|
786
786
|
}
|
|
787
787
|
const outline = aiEditJobOutline(brief.nodes);
|
|
788
|
-
const context = outline ? parseAssistEditContext(outline
|
|
788
|
+
const context = outline ? parseAssistEditContext(outline, {
|
|
789
|
+
whole: true
|
|
790
|
+
}) : null;
|
|
789
791
|
if (!context) return {
|
|
790
792
|
readable: false,
|
|
791
793
|
rules: false,
|