@aglyn/plugins-ai 1.0.0-beta.229 → 1.0.0-beta.230
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 -3
- package/package.json +17 -17
- package/src/lib/activity/ai-activity-actions.js +7 -1
- package/src/lib/activity/ai-activity-actions.js.map +1 -1
- package/src/lib/components/ai-automation-zones.d.ts +38 -0
- package/src/lib/components/ai-automation-zones.js +5 -1
- package/src/lib/components/ai-automation-zones.js.map +1 -1
- package/src/lib/components/ai-brief-dialog.component.d.ts +20 -2
- package/src/lib/components/ai-brief-dialog.component.js +87 -8
- package/src/lib/components/ai-brief-dialog.component.js.map +1 -1
- package/src/lib/components/ai-campaign-create.component.d.ts +54 -0
- package/src/lib/components/ai-campaign-create.component.js +270 -0
- package/src/lib/components/ai-campaign-create.component.js.map +1 -0
- package/src/lib/components/ai-describe-automation.component.d.ts +8 -3
- package/src/lib/components/ai-describe-automation.component.js +15 -6
- package/src/lib/components/ai-describe-automation.component.js.map +1 -1
- package/src/lib/components/ai-describe-button.component.d.ts +20 -8
- package/src/lib/components/ai-describe-button.component.js +19 -36
- package/src/lib/components/ai-describe-button.component.js.map +1 -1
- package/src/lib/components/ai-describe-email.component.d.ts +31 -0
- package/src/lib/components/ai-describe-email.component.js +22 -0
- package/src/lib/components/ai-describe-email.component.js.map +1 -0
- package/src/lib/components/ai-describe-org-automation.component.d.ts +36 -0
- package/src/lib/components/ai-describe-org-automation.component.js +238 -0
- package/src/lib/components/ai-describe-org-automation.component.js.map +1 -0
- package/src/lib/components/ai-experiment-cards.component.d.ts +9 -1
- package/src/lib/components/ai-experiment-cards.component.js +104 -18
- package/src/lib/components/ai-experiment-cards.component.js.map +1 -1
- package/src/lib/components/ai-explain-automation.component.js +1 -5
- package/src/lib/components/ai-explain-automation.component.js.map +1 -1
- package/src/lib/components/ai-funnel-zones.component.d.ts +61 -0
- package/src/lib/components/ai-funnel-zones.component.js +178 -0
- package/src/lib/components/ai-funnel-zones.component.js.map +1 -0
- package/src/lib/components/ai-insight-card.component.d.ts +42 -0
- package/src/lib/components/ai-insight-card.component.js +137 -0
- package/src/lib/components/ai-insight-card.component.js.map +1 -0
- package/src/lib/components/ai-insight-dialog.component.d.ts +6 -0
- package/src/lib/components/ai-insight-dialog.component.js +9 -3
- package/src/lib/components/ai-insight-dialog.component.js.map +1 -1
- package/src/lib/components/ai-job-plan.component.d.ts +7 -2
- package/src/lib/components/ai-job-plan.component.js +35 -5
- package/src/lib/components/ai-job-plan.component.js.map +1 -1
- package/src/lib/components/ai-job-requests.d.ts +17 -1
- package/src/lib/components/ai-job-requests.js +39 -3
- package/src/lib/components/ai-job-requests.js.map +1 -1
- package/src/lib/components/ai-logic-zones.d.ts +64 -0
- package/src/lib/components/ai-logic-zones.js +18 -0
- package/src/lib/components/ai-logic-zones.js.map +1 -0
- package/src/lib/components/ai-logic.component.d.ts +77 -0
- package/src/lib/components/ai-logic.component.js +553 -0
- package/src/lib/components/ai-logic.component.js.map +1 -0
- package/src/lib/components/ai-marketing-insight.component.d.ts +30 -0
- package/src/lib/components/ai-marketing-insight.component.js +80 -0
- package/src/lib/components/ai-marketing-insight.component.js.map +1 -0
- package/src/lib/components/ai-media-create.component.d.ts +55 -0
- package/src/lib/components/ai-media-create.component.js +433 -0
- package/src/lib/components/ai-media-create.component.js.map +1 -0
- package/src/lib/components/ai-overlay-cards.component.d.ts +83 -0
- package/src/lib/components/ai-overlay-cards.component.js +505 -0
- package/src/lib/components/ai-overlay-cards.component.js.map +1 -0
- package/src/lib/components/ai-product-zones.d.ts +5 -0
- package/src/lib/components/ai-product-zones.js +1 -1
- package/src/lib/components/ai-product-zones.js.map +1 -1
- package/src/lib/components/ai-products-create-button.component.d.ts +42 -0
- package/src/lib/components/ai-products-create-button.component.js +67 -0
- package/src/lib/components/ai-products-create-button.component.js.map +1 -0
- package/src/lib/components/ai-products-hub-card.component.js +100 -81
- package/src/lib/components/ai-products-hub-card.component.js.map +1 -1
- package/src/lib/components/ai-revise-automation.component.d.ts +16 -0
- package/src/lib/components/ai-revise-automation.component.js +207 -0
- package/src/lib/components/ai-revise-automation.component.js.map +1 -0
- package/src/lib/components/ai-site-build-page.component.js +140 -16
- package/src/lib/components/ai-site-build-page.component.js.map +1 -1
- package/src/lib/components/ai-upsell-dialog.component.d.ts +53 -0
- package/src/lib/components/ai-upsell-dialog.component.js +177 -0
- package/src/lib/components/ai-upsell-dialog.component.js.map +1 -0
- package/src/lib/components/assist-build-card.component.d.ts +42 -0
- package/src/lib/components/assist-build-card.component.js +183 -0
- package/src/lib/components/assist-build-card.component.js.map +1 -0
- package/src/lib/components/assist-edit-canvas.d.ts +2 -0
- package/src/lib/components/assist-edit-canvas.js +56 -1
- package/src/lib/components/assist-edit-canvas.js.map +1 -1
- package/src/lib/components/assist-jobs-drawer.component.js +48 -3
- package/src/lib/components/assist-jobs-drawer.component.js.map +1 -1
- package/src/lib/components/assist-panel.component.js +51 -2
- package/src/lib/components/assist-panel.component.js.map +1 -1
- package/src/lib/components/use-ai-job-run.d.ts +3 -14
- package/src/lib/components/use-ai-job-run.js +0 -50
- package/src/lib/components/use-ai-job-run.js.map +1 -1
- package/src/lib/jobs/ai-build-capabilities.d.ts +58 -0
- package/src/lib/jobs/ai-build-capabilities.js +256 -0
- package/src/lib/jobs/ai-build-capabilities.js.map +1 -0
- package/src/lib/jobs/ai-build-unit-outcome.d.ts +52 -0
- package/src/lib/jobs/ai-build-unit-outcome.js +138 -0
- package/src/lib/jobs/ai-build-unit-outcome.js.map +1 -0
- package/src/lib/jobs/ai-job-build-step.d.ts +144 -0
- package/src/lib/jobs/ai-job-build-step.js +657 -0
- package/src/lib/jobs/ai-job-build-step.js.map +1 -0
- package/src/lib/jobs/ai-job-draft-ids.js +9 -1
- package/src/lib/jobs/ai-job-draft-ids.js.map +1 -1
- package/src/lib/jobs/ai-job-drafts.d.ts +14 -4
- package/src/lib/jobs/ai-job-drafts.js +25 -4
- package/src/lib/jobs/ai-job-drafts.js.map +1 -1
- package/src/lib/jobs/ai-job-logic-step.d.ts +107 -0
- package/src/lib/jobs/ai-job-logic-step.js +395 -0
- package/src/lib/jobs/ai-job-logic-step.js.map +1 -0
- package/src/lib/jobs/ai-job-overlay-copy.d.ts +70 -0
- package/src/lib/jobs/ai-job-overlay-copy.js +178 -0
- package/src/lib/jobs/ai-job-overlay-copy.js.map +1 -0
- package/src/lib/jobs/ai-job-page-step.js +6 -6
- package/src/lib/jobs/ai-job-page-step.js.map +1 -1
- package/src/lib/jobs/ai-job-plan-step.d.ts +26 -1
- package/src/lib/jobs/ai-job-plan-step.js +79 -11
- package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
- package/src/lib/jobs/ai-job-site-step.d.ts +15 -1
- package/src/lib/jobs/ai-job-site-step.js +200 -58
- package/src/lib/jobs/ai-job-site-step.js.map +1 -1
- package/src/lib/jobs/ai-job-text-step.d.ts +22 -1
- package/src/lib/jobs/ai-job-text-step.js +12 -0
- package/src/lib/jobs/ai-job-text-step.js.map +1 -1
- package/src/lib/jobs/ai-job-workflow-step.d.ts +54 -4
- package/src/lib/jobs/ai-job-workflow-step.js +318 -13
- package/src/lib/jobs/ai-job-workflow-step.js.map +1 -1
- package/src/lib/jobs/ai-jobs.d.ts +80 -2
- package/src/lib/jobs/ai-jobs.js +377 -13
- package/src/lib/jobs/ai-jobs.js.map +1 -1
- package/src/lib/jobs/ai-logic-records.d.ts +40 -0
- package/src/lib/jobs/ai-logic-records.js +55 -0
- package/src/lib/jobs/ai-logic-records.js.map +1 -0
- package/src/lib/jobs/ai-site-publish.d.ts +7 -0
- package/src/lib/jobs/ai-site-publish.js +9 -0
- package/src/lib/jobs/ai-site-publish.js.map +1 -1
- package/src/lib/jobs/ai-workflow-records.d.ts +4 -0
- package/src/lib/jobs/ai-workflow-records.js +40 -1
- package/src/lib/jobs/ai-workflow-records.js.map +1 -1
- package/src/lib/model/ai-automation-draft.d.ts +18 -0
- package/src/lib/model/ai-automation-draft.js +86 -0
- package/src/lib/model/ai-automation-draft.js.map +1 -1
- package/src/lib/model/ai-build-job.d.ts +201 -0
- package/src/lib/model/ai-build-job.js +471 -0
- package/src/lib/model/ai-build-job.js.map +1 -0
- package/src/lib/model/ai-build-plan.d.ts +61 -0
- package/src/lib/model/ai-build-plan.js +154 -9
- package/src/lib/model/ai-build-plan.js.map +1 -1
- package/src/lib/model/ai-build-progress.d.ts +56 -0
- package/src/lib/model/ai-build-progress.js +128 -0
- package/src/lib/model/ai-build-progress.js.map +1 -0
- package/src/lib/model/ai-insight.d.ts +20 -10
- package/src/lib/model/ai-insight.js +72 -9
- package/src/lib/model/ai-insight.js.map +1 -1
- package/src/lib/model/ai-job-activity.js +3 -1
- package/src/lib/model/ai-job-activity.js.map +1 -1
- package/src/lib/model/ai-jobs.types.d.ts +80 -2
- package/src/lib/model/ai-jobs.types.js +3 -1
- package/src/lib/model/ai-jobs.types.js.map +1 -1
- package/src/lib/model/ai-logic-job.d.ts +108 -0
- package/src/lib/model/ai-logic-job.js +327 -0
- package/src/lib/model/ai-logic-job.js.map +1 -0
- package/src/lib/model/ai-media-credits.d.ts +52 -0
- package/src/lib/model/ai-media-credits.js +61 -0
- package/src/lib/model/ai-media-credits.js.map +1 -0
- package/src/lib/model/ai-overlay-copy.d.ts +114 -0
- package/src/lib/model/ai-overlay-copy.js +175 -0
- package/src/lib/model/ai-overlay-copy.js.map +1 -0
- package/src/lib/model/ai-site-build-progress.d.ts +20 -3
- package/src/lib/model/ai-site-build-progress.js +170 -10
- package/src/lib/model/ai-site-build-progress.js.map +1 -1
- package/src/lib/model/ai-svg.d.ts +69 -0
- package/src/lib/model/ai-svg.js +265 -0
- package/src/lib/model/ai-svg.js.map +1 -0
- package/src/lib/model/ai-usage-by-user.d.ts +3 -2
- package/src/lib/model/ai-usage-by-user.js.map +1 -1
- package/src/lib/model/ai-workflow-job.d.ts +92 -4
- package/src/lib/model/ai-workflow-job.js +124 -7
- package/src/lib/model/ai-workflow-job.js.map +1 -1
- package/src/lib/model/assist-build.d.ts +58 -0
- package/src/lib/model/assist-build.js +52 -0
- package/src/lib/model/assist-build.js.map +1 -0
- package/src/lib/model/assist-edit.d.ts +48 -3
- package/src/lib/model/assist-edit.js +48 -4
- package/src/lib/model/assist-edit.js.map +1 -1
- package/src/lib/plugin-config.js +2 -0
- package/src/lib/plugin-config.js.map +1 -1
- package/src/lib/plugin.js +240 -11
- package/src/lib/plugin.js.map +1 -1
- package/src/lib/providers/catalog.d.ts +81 -4
- package/src/lib/providers/catalog.js +80 -9
- package/src/lib/providers/catalog.js.map +1 -1
- package/src/lib/providers/image-contract.d.ts +116 -0
- package/src/lib/providers/image-contract.js +74 -0
- package/src/lib/providers/image-contract.js.map +1 -0
- package/src/lib/providers/model-choice.js +11 -0
- package/src/lib/providers/model-choice.js.map +1 -1
- package/src/lib/providers/routing.js +18 -0
- package/src/lib/providers/routing.js.map +1 -1
- package/src/lib/providers/vertex-image.d.ts +121 -0
- package/src/lib/providers/vertex-image.js +312 -0
- package/src/lib/providers/vertex-image.js.map +1 -0
- package/src/lib/runtime/ai-doctrine-validators.d.ts +19 -0
- package/src/lib/runtime/ai-doctrine-validators.js +89 -0
- package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
- package/src/lib/runtime/ai-doctrine.js +11 -5
- package/src/lib/runtime/ai-doctrine.js.map +1 -1
- package/src/lib/runtime/ai-eval-live.js +4 -0
- package/src/lib/runtime/ai-eval-live.js.map +1 -1
- package/src/lib/runtime/ai-eval.d.ts +15 -1
- package/src/lib/runtime/ai-eval.js +52 -1
- package/src/lib/runtime/ai-eval.js.map +1 -1
- package/src/lib/runtime/experiment-variant-copy.d.ts +34 -0
- package/src/lib/runtime/experiment-variant-copy.js +102 -0
- package/src/lib/runtime/experiment-variant-copy.js.map +1 -0
- package/src/lib/server/ai-experiment-versions.d.ts +51 -0
- package/src/lib/server/ai-experiment-versions.js +270 -0
- package/src/lib/server/ai-experiment-versions.js.map +1 -0
- package/src/lib/server/ai-jobs-resume.js +74 -4
- package/src/lib/server/ai-jobs-resume.js.map +1 -1
- package/src/lib/server/ai-media-image.d.ts +66 -0
- package/src/lib/server/ai-media-image.js +521 -0
- package/src/lib/server/ai-media-image.js.map +1 -0
- package/src/lib/server/ai-media-svg.d.ts +91 -0
- package/src/lib/server/ai-media-svg.js +186 -0
- package/src/lib/server/ai-media-svg.js.map +1 -0
- package/src/lib/server/assist-build.d.ts +54 -0
- package/src/lib/server/assist-build.js +121 -0
- package/src/lib/server/assist-build.js.map +1 -0
- package/src/lib/server/assist-chat.js +108 -12
- package/src/lib/server/assist-chat.js.map +1 -1
- package/src/lib/server/assist-edit.js +213 -3
- package/src/lib/server/assist-edit.js.map +1 -1
- package/src/lib/server/assist-view-context.js +242 -4
- package/src/lib/server/assist-view-context.js.map +1 -1
- package/src/lib/server.js +26 -0
- package/src/lib/server.js.map +1 -1
- package/src/lib/tools/ai-logic-tool.d.ts +27 -0
- package/src/lib/tools/ai-logic-tool.js +207 -0
- package/src/lib/tools/ai-logic-tool.js.map +1 -0
- package/src/lib/tools/ai-overlay-tool.d.ts +35 -0
- package/src/lib/tools/ai-overlay-tool.js +107 -0
- package/src/lib/tools/ai-overlay-tool.js.map +1 -0
- package/src/lib/tools/ai-workflow-tool.d.ts +11 -0
- package/src/lib/tools/ai-workflow-tool.js +31 -0
- package/src/lib/tools/ai-workflow-tool.js.map +1 -1
- package/src/lib/usage/assist-job-refund.d.ts +28 -1
- package/src/lib/usage/assist-job-refund.js +44 -9
- package/src/lib/usage/assist-job-refund.js.map +1 -1
- package/src/lib/usage/assist-usage.d.ts +5 -0
- package/src/lib/usage/assist-usage.js +2 -0
- package/src/lib/usage/assist-usage.js.map +1 -1
package/src/lib/server.js
CHANGED
|
@@ -30,7 +30,10 @@ import { registerAiProductsJob } from "./jobs/ai-job-products-step.js";
|
|
|
30
30
|
import { registerAiEmailJob } from "./jobs/ai-job-email-step.js";
|
|
31
31
|
import { registerAiCampaignJob } from "./jobs/ai-job-campaign-step.js";
|
|
32
32
|
import { registerAiSiteJob } from "./jobs/ai-job-site-step.js";
|
|
33
|
+
import { registerAiBuildJob } from "./jobs/ai-job-build-step.js";
|
|
34
|
+
import { registerAiBuildCapabilities } from "./jobs/ai-build-capabilities.js";
|
|
33
35
|
import { registerAiWorkflowJob } from "./jobs/ai-job-workflow-step.js";
|
|
36
|
+
import { registerAiLogicJob } from "./jobs/ai-job-logic-step.js";
|
|
34
37
|
import { registerAiInsightJob } from "./jobs/ai-job-insight-step.js";
|
|
35
38
|
import { registerAiFigureReaders } from "./insights/ai-figure-readers.js";
|
|
36
39
|
import { registerAiTextGenerator } from "./server/plugin-text-generation.js";
|
|
@@ -45,7 +48,9 @@ import { POST as createAiSiteBatch } from "./server/ai-jobs-batch.js";
|
|
|
45
48
|
import { GET as listAiJobs, POST as createAiJob } from "./server/ai-jobs-route.js";
|
|
46
49
|
import { POST as resumeAiJob } from "./server/ai-jobs-resume.js";
|
|
47
50
|
import { POST as aiGenerateComponent } from "./server/ai-generate-component.js";
|
|
51
|
+
import { POST as createAiMediaImages } from "./server/ai-media-image.js";
|
|
48
52
|
import { POST as applyAiSeoAudit } from "./server/ai-seo-apply.js";
|
|
53
|
+
import { POST as createAiExperimentVersions } from "./server/ai-experiment-versions.js";
|
|
49
54
|
import { POST as assistChat } from "./server/assist-chat.js";
|
|
50
55
|
import { POST as assistEditApplied } from "./server/assist-edit-applied.js";
|
|
51
56
|
import { POST as assistFeedback } from "./server/assist-feedback.js";
|
|
@@ -111,12 +116,21 @@ export * from "./runtime/ai-runtime.js";
|
|
|
111
116
|
// Automations drafted from a description, and explained, whose drafts the
|
|
112
117
|
// workflows plugin writes on the resource-draft seam (AGL-2919).
|
|
113
118
|
registerAiWorkflowJob();
|
|
119
|
+
// Site functions and variables proposed from a description, and functions
|
|
120
|
+
// explained, as proposals the logic editor opens unsaved (AGL-3603).
|
|
121
|
+
registerAiLogicJob();
|
|
114
122
|
// Product copy, and a store's products, categories and discounts from a
|
|
115
123
|
// brief, as proposals the commerce plugin's surfaces apply (AGL-2916).
|
|
116
124
|
registerAiProductsJob();
|
|
117
125
|
// The site scaffold, which builds a whole site through the steps above
|
|
118
126
|
// (AGL-2911).
|
|
119
127
|
registerAiSiteJob();
|
|
128
|
+
// A build from one request (AGL-3616): pages, creations and other
|
|
129
|
+
// plugins' drafts, through the steps above and the writers those plugins
|
|
130
|
+
// register, settled item by item. What this plugin lets a build make is
|
|
131
|
+
// registered on the core's capability contract like any plugin's.
|
|
132
|
+
registerAiBuildCapabilities();
|
|
133
|
+
registerAiBuildJob();
|
|
120
134
|
// Insights (AGL-2915): a question about a site's figures, answered from
|
|
121
135
|
// tables the figure readers return, and the weekly digest. The readers for
|
|
122
136
|
// the platform's own records — page views, forms, datasets — are this
|
|
@@ -226,12 +240,24 @@ export * from "./runtime/ai-runtime.js";
|
|
|
226
240
|
registerPluginApiRoute('ai/seo/apply', {
|
|
227
241
|
web: applyAiSeoAudit
|
|
228
242
|
});
|
|
243
|
+
// A page's or a section's A/B variants as draft versions (AGL-3603): the
|
|
244
|
+
// published version copied once per proposed variant, the variant's copy
|
|
245
|
+
// put in, stored unpublished for the experiment editor to pin.
|
|
246
|
+
registerPluginApiRoute('ai/experiments/versions', {
|
|
247
|
+
web: createAiExperimentVersions
|
|
248
|
+
});
|
|
229
249
|
// Save the selection as a reusable component, with AI (AGL-2908): the
|
|
230
250
|
// second entry point of the component job, from the besigner's Attributes
|
|
231
251
|
// panel. It proposes, and the person's Apply writes.
|
|
232
252
|
registerPluginApiRoute('ai/generate/component', {
|
|
233
253
|
web: aiGenerateComponent
|
|
234
254
|
});
|
|
255
|
+
// Pictures from a description, in Media (AGL-3602): photos and SVG
|
|
256
|
+
// illustrations, stored through the media upload route. POST only — the
|
|
257
|
+
// button draws from the shell's gates and asks nothing until it is used.
|
|
258
|
+
registerPluginApiRoute('ai/media/images', {
|
|
259
|
+
web: createAiMediaImages
|
|
260
|
+
});
|
|
235
261
|
registerPluginApiRoute('ai/billing/credits', {
|
|
236
262
|
web: billingCredits
|
|
237
263
|
});
|
package/src/lib/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/server.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\nimport { registerPluginApiRoute } from '@aglyn/aglyn/server'\nimport { registerAiDeclarations } from './declarations'\nimport { AI_JOBS_BEAT_PATH } from './jobs/ai-jobs-beat'\nimport { registerAiJobPlan } from './jobs/ai-job-plan-step'\nimport { registerAiJobsPause } from './jobs/ai-jobs-pause'\nimport { registerAiJobsNotify } from './jobs/ai-jobs-notify'\nimport { registerAiComponentJob } from './jobs/ai-job-component-step'\nimport { registerAiCrmJob } from './jobs/ai-job-crm-step'\nimport { registerAiLayoutJob } from './jobs/ai-job-layout-step'\nimport { registerAiTemplateJob } from './jobs/ai-job-template-step'\nimport { registerAiExperimentJob } from './jobs/ai-job-experiment-step'\nimport { registerAiFormJob } from './jobs/ai-job-form-step'\nimport { registerAiPageJob } from './jobs/ai-job-page-step'\nimport { registerAiProductsJob } from './jobs/ai-job-products-step'\nimport { registerAiEmailJob } from './jobs/ai-job-email-step'\nimport { registerAiCampaignJob } from './jobs/ai-job-campaign-step'\nimport { registerAiSiteJob } from './jobs/ai-job-site-step'\nimport { registerAiWorkflowJob } from './jobs/ai-job-workflow-step'\nimport { registerAiInsightJob } from './jobs/ai-job-insight-step'\nimport { registerAiFigureReaders } from './insights/ai-figure-readers'\nimport { registerAiTextGenerator } from './server/plugin-text-generation'\nimport { firebaseAdmin } from '@aglyn/tenant-data-admin/server/firebase-admin'\nimport { ensureFirstPartyAiProviders } from './providers/registry'\nimport { aiAssistHandler } from './server/ai-assist'\nimport { GET as aiCrmAnswer } from './server/ai-crm-answer'\nimport { POST as runAiJobsBeat } from './server/ai-jobs-beat-route'\nimport { POST as cancelAiJob } from './server/ai-jobs-cancel'\nimport { GET as aiJobEvents } from './server/ai-jobs-events-route'\nimport { POST as createAiSiteBatch } from './server/ai-jobs-batch'\nimport { GET as listAiJobs, POST as createAiJob } from './server/ai-jobs-route'\nimport { POST as resumeAiJob } from './server/ai-jobs-resume'\nimport { POST as aiGenerateComponent } from './server/ai-generate-component'\nimport { POST as applyAiSeoAudit } from './server/ai-seo-apply'\nimport { POST as assistChat } from './server/assist-chat'\nimport { POST as assistEditApplied } from './server/assist-edit-applied'\nimport { POST as assistFeedback } from './server/assist-feedback'\nimport { PATCH as aiHostPermissions } from './server/ai-host-permissions'\nimport { GET as aiAdminOrg } from './server/ai-admin-org'\nimport { GET as aiAdminOrgsSpend } from './server/ai-admin-orgs-spend'\nimport { GET as aiAdminSignals } from './server/ai-admin-signals'\nimport { GET as aiAdminUser } from './server/ai-admin-user'\nimport { POST as aiAdminOverage } from './server/ai-admin-overage'\nimport { POST as aiAdminCredits } from './server/ai-admin-credits'\nimport { GET as aiUsage } from './server/ai-usage'\nimport { GET as aiAllotments } from './server/ai-allotments'\nimport { GET as aiInsightAnswer } from './server/ai-insight-answer'\nimport { POST as runAiInsightsDigest } from './server/ai-insight-digest-route'\nimport { AI_INSIGHTS_DIGEST_PATH } from './insights/ai-insight-digest'\nimport { GET as aiModels } from './server/ai-models'\nimport { GET as billingCredits } from './server/billing-credits'\nimport { POST as billingOverage } from './server/billing-overage'\n\nexport * from './providers/contract'\nexport * from './providers/catalog'\nexport * from './providers/registry'\nexport * from './providers/routing'\nexport * from './runtime/ai-runtime'\n\n/**\n * The two first-party adapters, registered once per process. A marketplace\n * plugin registers its own against `AI_PROVIDER_CONTRACT` from its own\n * entry and never touches this.\n */\nconst registerFirstPartyProviders = ensureFirstPartyAiProviders\n\n/**\n * Every job kind this plugin runs beyond the three the machine registers\n * itself (AGL-3025). Each is a CALL, never an import made for what the\n * module does as it loads: this package declares only this file\n * effect-ful, so a bundler honoring `sideEffects` deletes an import whose\n * exports go unused — and a step registered that way ran in every spec and\n * in neither app. `registrations-survive-a-bundler.spec.ts` holds this.\n *\n * The console surface is the only caller (AGL-3026): its doors run a job's\n * first step inline, and its beat runs every step after it. The tenant app\n * loads no server surface of this plugin at all, so nothing that serves a\n * published site can reach a provider.\n */\nfunction registerAiJobKinds(): void {\n // The workspace AI pause the machine asks before it claims any step, so a\n // paused workspace's queued jobs spend nothing (AGL-3037).\n registerAiJobsPause()\n // The person who started a job is told when it needs them, finishes or\n // stops (AGL-3593), from the write that changed it.\n registerAiJobsNotify()\n // The plan step every planned kind runs first (AGL-2935).\n registerAiJobPlan()\n // Components, layouts and templates (AGL-2908, AGL-2909).\n registerAiComponentJob()\n registerAiLayoutJob()\n registerAiTemplateJob()\n // Forms (AGL-2913).\n registerAiExperimentJob()\n registerAiFormJob()\n // Pages, with the least time one pass needs (AGL-2907).\n registerAiPageJob()\n // Email designs and campaigns, whose drafts the email and marketing\n // plugins write on the resource-draft seam (AGL-2912).\n registerAiEmailJob()\n registerAiCampaignJob()\n // Automations drafted from a description, and explained, whose drafts the\n // workflows plugin writes on the resource-draft seam (AGL-2919).\n registerAiWorkflowJob()\n // Product copy, and a store's products, categories and discounts from a\n // brief, as proposals the commerce plugin's surfaces apply (AGL-2916).\n registerAiProductsJob()\n // The site scaffold, which builds a whole site through the steps above\n // (AGL-2911).\n registerAiSiteJob()\n // Insights (AGL-2915): a question about a site's figures, answered from\n // tables the figure readers return, and the weekly digest. The readers for\n // the platform's own records — page views, forms, datasets — are this\n // plugin's; every other plugin registers its own from its console surface.\n registerAiFigureReaders(() => firebaseAdmin.app().firestore())\n registerAiInsightJob()\n // CRM by AI (AGL-2917): a record's summary and next step, an email draft\n // and an import's column matches, read through the CRM's facts readers.\n registerAiCrmJob()\n}\n\n/**\n * The console-side API (AGL-2939): every AI door, under the `ai` and\n * `assist` prefixes the plugin owns. The URLs the panel and the besigner\n * call are unchanged — `/api/assist/chat`, `/api/ai/assist`,\n * `/api/ai/jobs` — because the dispatcher serves them from the registry\n * exactly where the named routes used to; the two billing doors and the\n * per-member usage read (`ai/usage`) live under the plugin's own prefix.\n * The jobs beat is the one path outside them, for the reason\n * `AI_JOBS_BEAT_PATH` gives.\n */\nexport function registerAiConsoleApi(): void {\n registerAiDeclarations()\n registerFirstPartyProviders()\n registerAiJobKinds()\n // This plugin as the workspace's text generator on the core's seam\n // (AGL-3324): another plugin drafts a paragraph through it under the\n // generation doors' own rules, metered as a text job is.\n registerAiTextGenerator()\n registerPluginApiRoute('assist/chat', { web: assistChat })\n registerPluginApiRoute('assist/feedback', { web: assistFeedback })\n // The applied-edit record (AGL-2906): counts of a proposal the author\n // applied in their editor, written to the site's activity log.\n registerPluginApiRoute('assist/edit-applied', { web: assistEditApplied })\n // A collaborator's AI toggles on one site (AGL-2927), set from the site's\n // collaborators card through this plugin's column there.\n registerPluginApiRoute('ai/host-permissions', { web: aiHostPermissions })\n registerPluginApiRoute('ai/assist', aiAssistHandler)\n registerPluginApiRoute('ai/jobs', {\n web: (request) => (request.method === 'GET' ? listAiJobs(request) : createAiJob(request)),\n })\n // The agency batch (AGL-2911): one brief, one `site` job per named site,\n // under one batch id. Before the `:jobId` routes, which it is not one of.\n registerPluginApiRoute('ai/jobs/batch', { web: createAiSiteBatch })\n registerPluginApiRoute('ai/jobs/:jobId/cancel', {\n web: (request, context) =>\n cancelAiJob(request, { params: Promise.resolve({ jobId: String(context.params['jobId']) }) }),\n })\n registerPluginApiRoute('ai/jobs/:jobId/resume', {\n web: (request, context) =>\n resumeAiJob(request, { params: Promise.resolve({ jobId: String(context.params['jobId']) }) }),\n })\n // An insight job's answer (AGL-2915), which is kept off the job document\n // and served only to the member who asked, or for a digest to the site's\n // members.\n registerPluginApiRoute('ai/insights/:jobId', {\n web: (request, context) =>\n aiInsightAnswer(request, { params: Promise.resolve({ jobId: String(context.params['jobId']) }) }),\n })\n // A CRM job's answer (AGL-2917), which is kept off the job document and\n // served only to a member the CRM still lets read the record.\n registerPluginApiRoute('ai/crm/:jobId', {\n web: (request, context) =>\n aiCrmAnswer(request, { params: Promise.resolve({ jobId: String(context.params['jobId']) }) }),\n })\n registerPluginApiRoute('ai/jobs/:jobId/events', {\n web: (request, context) =>\n aiJobEvents(request, { params: Promise.resolve({ jobId: String(context.params['jobId']) }) }),\n })\n // The jobs beat (AGL-3026): every step the doors leave queued, run every\n // minute by the console's scheduler on the cron secret, on the one surface\n // that holds the provider's key.\n registerPluginApiRoute(AI_JOBS_BEAT_PATH, { web: runAiJobsBeat })\n // The weekly insights (AGL-2915): Monday's digests made for the people who\n // asked for them, and delivered once the beat has written them. Beside the\n // beat under `/api/admin/`, where the console's scheduled sweeps live.\n registerPluginApiRoute(AI_INSIGHTS_DIGEST_PATH, { web: runAiInsightsDigest })\n // A site SEO audit's \"Apply all\" (AGL-2910): content fixes as new\n // unpublished versions, listing values staged for their SEO cards.\n registerPluginApiRoute('ai/seo/apply', { web: applyAiSeoAudit })\n // Save the selection as a reusable component, with AI (AGL-2908): the\n // second entry point of the component job, from the besigner's Attributes\n // panel. It proposes, and the person's Apply writes.\n registerPluginApiRoute('ai/generate/component', { web: aiGenerateComponent })\n registerPluginApiRoute('ai/billing/credits', { web: billingCredits })\n registerPluginApiRoute('ai/billing/overage', { web: billingOverage })\n registerPluginApiRoute('ai/usage', { web: aiUsage })\n // The allotments a manager sets, and the options the model switch lists\n // (AGL-2942). One handler answers the allotments' GET and POST.\n registerPluginApiRoute('ai/allotments', { web: aiAllotments })\n registerPluginApiRoute('ai/models', { web: aiModels })\n // The staff doors (AGL-2928, AGL-2930, AGL-2252): one org's AI in full,\n // one account's usage across its workspaces, and the fleet's Assist\n // signals behind the Assist signal staff page.\n registerPluginApiRoute('ai/admin/org', { web: aiAdminOrg })\n registerPluginApiRoute('ai/admin/orgs-spend', { web: aiAdminOrgsSpend })\n registerPluginApiRoute('ai/admin/user', { web: aiAdminUser })\n registerPluginApiRoute('ai/admin/signals', { web: aiAdminSignals })\n // One workspace's overage standing and the four acts staff have over it\n // (AGL-3011): the ceiling override, lifting a pause — the only way a\n // dispute pause comes off — and resetting the step. Every act audited.\n registerPluginApiRoute('ai/admin/overage', { web: aiAdminOverage })\n // Credits given back to a workspace's band or a Free owner's allowance\n // (AGL-3595): compensation for a fault of ours, bounded by what the month\n // used, keyed against a double-click, and audited.\n registerPluginApiRoute('ai/admin/credits', { web: aiAdminCredits })\n}\n\n// Type-only (AGL-3080): the plugin's entitlement keys, declared by module\n// augmentation, for every program that loads this entry point.\nexport type { aiPlanEntitlements } from './plan-entitlements'\n"],"names":["registerPluginApiRoute","registerAiDeclarations","AI_JOBS_BEAT_PATH","registerAiJobPlan","registerAiJobsPause","registerAiJobsNotify","registerAiComponentJob","registerAiCrmJob","registerAiLayoutJob","registerAiTemplateJob","registerAiExperimentJob","registerAiFormJob","registerAiPageJob","registerAiProductsJob","registerAiEmailJob","registerAiCampaignJob","registerAiSiteJob","registerAiWorkflowJob","registerAiInsightJob","registerAiFigureReaders","registerAiTextGenerator","firebaseAdmin","ensureFirstPartyAiProviders","aiAssistHandler","GET","aiCrmAnswer","POST","runAiJobsBeat","cancelAiJob","aiJobEvents","createAiSiteBatch","listAiJobs","createAiJob","resumeAiJob","aiGenerateComponent","applyAiSeoAudit","assistChat","assistEditApplied","assistFeedback","PATCH","aiHostPermissions","aiAdminOrg","aiAdminOrgsSpend","aiAdminSignals","aiAdminUser","aiAdminOverage","aiAdminCredits","aiUsage","aiAllotments","aiInsightAnswer","runAiInsightsDigest","AI_INSIGHTS_DIGEST_PATH","aiModels","billingCredits","billingOverage","registerFirstPartyProviders","registerAiJobKinds","app","firestore","registerAiConsoleApi","web","request","method","context","params","Promise","resolve","jobId","String"],"mapp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IACpE,+CAA+C;IAC/CpD,uBAAuB,gBAAgB;QAAE4D,KAAKnB;IAAW;IACzDzC,uBAAuB,uBAAuB;QAAE4D,KAAKlB;IAAiB;IACtE1C,uBAAuB,iBAAiB;QAAE4D,KAAKhB;IAAY;IAC3D5C,uBAAuB,oBAAoB;QAAE4D,KAAKjB;IAAe;IACjE,wEAAwE;IACxE,qEAAqE;IACrE,uEAAuE;IACvE3C,uBAAuB,oBAAoB;QAAE4D,KAAKf;IAAe;IACjE,uEAAuE;IACvE,0EAA0E;IAC1E,mDAAmD;IACnD7C,uBAAuB,oBAAoB;QAAE4D,KAAKd;IAAe;AACnE"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/plugins/ai/src/lib/server.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\nimport { registerPluginApiRoute } from '@aglyn/aglyn/server'\nimport { registerAiDeclarations } from './declarations'\nimport { AI_JOBS_BEAT_PATH } from './jobs/ai-jobs-beat'\nimport { registerAiJobPlan } from './jobs/ai-job-plan-step'\nimport { registerAiJobsPause } from './jobs/ai-jobs-pause'\nimport { registerAiJobsNotify } from './jobs/ai-jobs-notify'\nimport { registerAiComponentJob } from './jobs/ai-job-component-step'\nimport { registerAiCrmJob } from './jobs/ai-job-crm-step'\nimport { registerAiLayoutJob } from './jobs/ai-job-layout-step'\nimport { registerAiTemplateJob } from './jobs/ai-job-template-step'\nimport { registerAiExperimentJob } from './jobs/ai-job-experiment-step'\nimport { registerAiFormJob } from './jobs/ai-job-form-step'\nimport { registerAiPageJob } from './jobs/ai-job-page-step'\nimport { registerAiProductsJob } from './jobs/ai-job-products-step'\nimport { registerAiEmailJob } from './jobs/ai-job-email-step'\nimport { registerAiCampaignJob } from './jobs/ai-job-campaign-step'\nimport { registerAiSiteJob } from './jobs/ai-job-site-step'\nimport { registerAiBuildJob } from './jobs/ai-job-build-step'\nimport { registerAiBuildCapabilities } from './jobs/ai-build-capabilities'\nimport { registerAiWorkflowJob } from './jobs/ai-job-workflow-step'\nimport { registerAiLogicJob } from './jobs/ai-job-logic-step'\nimport { registerAiInsightJob } from './jobs/ai-job-insight-step'\nimport { registerAiFigureReaders } from './insights/ai-figure-readers'\nimport { registerAiTextGenerator } from './server/plugin-text-generation'\nimport { firebaseAdmin } from '@aglyn/tenant-data-admin/server/firebase-admin'\nimport { ensureFirstPartyAiProviders } from './providers/registry'\nimport { aiAssistHandler } from './server/ai-assist'\nimport { GET as aiCrmAnswer } from './server/ai-crm-answer'\nimport { POST as runAiJobsBeat } from './server/ai-jobs-beat-route'\nimport { POST as cancelAiJob } from './server/ai-jobs-cancel'\nimport { GET as aiJobEvents } from './server/ai-jobs-events-route'\nimport { POST as createAiSiteBatch } from './server/ai-jobs-batch'\nimport { GET as listAiJobs, POST as createAiJob } from './server/ai-jobs-route'\nimport { POST as resumeAiJob } from './server/ai-jobs-resume'\nimport { POST as aiGenerateComponent } from './server/ai-generate-component'\nimport { POST as createAiMediaImages } from './server/ai-media-image'\nimport { POST as applyAiSeoAudit } from './server/ai-seo-apply'\nimport { POST as createAiExperimentVersions } from './server/ai-experiment-versions'\nimport { POST as assistChat } from './server/assist-chat'\nimport { POST as assistEditApplied } from './server/assist-edit-applied'\nimport { POST as assistFeedback } from './server/assist-feedback'\nimport { PATCH as aiHostPermissions } from './server/ai-host-permissions'\nimport { GET as aiAdminOrg } from './server/ai-admin-org'\nimport { GET as aiAdminOrgsSpend } from './server/ai-admin-orgs-spend'\nimport { GET as aiAdminSignals } from './server/ai-admin-signals'\nimport { GET as aiAdminUser } from './server/ai-admin-user'\nimport { POST as aiAdminOverage } from './server/ai-admin-overage'\nimport { POST as aiAdminCredits } from './server/ai-admin-credits'\nimport { GET as aiUsage } from './server/ai-usage'\nimport { GET as aiAllotments } from './server/ai-allotments'\nimport { GET as aiInsightAnswer } from './server/ai-insight-answer'\nimport { POST as runAiInsightsDigest } from './server/ai-insight-digest-route'\nimport { AI_INSIGHTS_DIGEST_PATH } from './insights/ai-insight-digest'\nimport { GET as aiModels } from './server/ai-models'\nimport { GET as billingCredits } from './server/billing-credits'\nimport { POST as billingOverage } from './server/billing-overage'\n\nexport * from './providers/contract'\nexport * from './providers/catalog'\nexport * from './providers/registry'\nexport * from './providers/routing'\nexport * from './runtime/ai-runtime'\n\n/**\n * The two first-party adapters, registered once per process. A marketplace\n * plugin registers its own against `AI_PROVIDER_CONTRACT` from its own\n * entry and never touches this.\n */\nconst registerFirstPartyProviders = ensureFirstPartyAiProviders\n\n/**\n * Every job kind this plugin runs beyond the three the machine registers\n * itself (AGL-3025). Each is a CALL, never an import made for what the\n * module does as it loads: this package declares only this file\n * effect-ful, so a bundler honoring `sideEffects` deletes an import whose\n * exports go unused — and a step registered that way ran in every spec and\n * in neither app. `registrations-survive-a-bundler.spec.ts` holds this.\n *\n * The console surface is the only caller (AGL-3026): its doors run a job's\n * first step inline, and its beat runs every step after it. The tenant app\n * loads no server surface of this plugin at all, so nothing that serves a\n * published site can reach a provider.\n */\nfunction registerAiJobKinds(): void {\n // The workspace AI pause the machine asks before it claims any step, so a\n // paused workspace's queued jobs spend nothing (AGL-3037).\n registerAiJobsPause()\n // The person who started a job is told when it needs them, finishes or\n // stops (AGL-3593), from the write that changed it.\n registerAiJobsNotify()\n // The plan step every planned kind runs first (AGL-2935).\n registerAiJobPlan()\n // Components, layouts and templates (AGL-2908, AGL-2909).\n registerAiComponentJob()\n registerAiLayoutJob()\n registerAiTemplateJob()\n // Forms (AGL-2913).\n registerAiExperimentJob()\n registerAiFormJob()\n // Pages, with the least time one pass needs (AGL-2907).\n registerAiPageJob()\n // Email designs and campaigns, whose drafts the email and marketing\n // plugins write on the resource-draft seam (AGL-2912).\n registerAiEmailJob()\n registerAiCampaignJob()\n // Automations drafted from a description, and explained, whose drafts the\n // workflows plugin writes on the resource-draft seam (AGL-2919).\n registerAiWorkflowJob()\n // Site functions and variables proposed from a description, and functions\n // explained, as proposals the logic editor opens unsaved (AGL-3603).\n registerAiLogicJob()\n // Product copy, and a store's products, categories and discounts from a\n // brief, as proposals the commerce plugin's surfaces apply (AGL-2916).\n registerAiProductsJob()\n // The site scaffold, which builds a whole site through the steps above\n // (AGL-2911).\n registerAiSiteJob()\n // A build from one request (AGL-3616): pages, creations and other\n // plugins' drafts, through the steps above and the writers those plugins\n // register, settled item by item. What this plugin lets a build make is\n // registered on the core's capability contract like any plugin's.\n registerAiBuildCapabilities()\n registerAiBuildJob()\n // Insights (AGL-2915): a question about a site's figures, answered from\n // tables the figure readers return, and the weekly digest. The readers for\n // the platform's own records — page views, forms, datasets — are this\n // plugin's; every other plugin registers its own from its console surface.\n registerAiFigureReaders(() => firebaseAdmin.app().firestore())\n registerAiInsightJob()\n // CRM by AI (AGL-2917): a record's summary and next step, an email draft\n // and an import's column matches, read through the CRM's facts readers.\n registerAiCrmJob()\n}\n\n/**\n * The console-side API (AGL-2939): every AI door, under the `ai` and\n * `assist` prefixes the plugin owns. The URLs the panel and the besigner\n * call are unchanged — `/api/assist/chat`, `/api/ai/assist`,\n * `/api/ai/jobs` — because the dispatcher serves them from the registry\n * exactly where the named routes used to; the two billing doors and the\n * per-member usage read (`ai/usage`) live under the plugin's own prefix.\n * The jobs beat is the one path outside them, for the reason\n * `AI_JOBS_BEAT_PATH` gives.\n */\nexport function registerAiConsoleApi(): void {\n registerAiDeclarations()\n registerFirstPartyProviders()\n registerAiJobKinds()\n // This plugin as the workspace's text generator on the core's seam\n // (AGL-3324): another plugin drafts a paragraph through it under the\n // generation doors' own rules, metered as a text job is.\n registerAiTextGenerator()\n registerPluginApiRoute('assist/chat', { web: assistChat })\n registerPluginApiRoute('assist/feedback', { web: assistFeedback })\n // The applied-edit record (AGL-2906): counts of a proposal the author\n // applied in their editor, written to the site's activity log.\n registerPluginApiRoute('assist/edit-applied', { web: assistEditApplied })\n // A collaborator's AI toggles on one site (AGL-2927), set from the site's\n // collaborators card through this plugin's column there.\n registerPluginApiRoute('ai/host-permissions', { web: aiHostPermissions })\n registerPluginApiRoute('ai/assist', aiAssistHandler)\n registerPluginApiRoute('ai/jobs', {\n web: (request) => (request.method === 'GET' ? listAiJobs(request) : createAiJob(request)),\n })\n // The agency batch (AGL-2911): one brief, one `site` job per named site,\n // under one batch id. Before the `:jobId` routes, which it is not one of.\n registerPluginApiRoute('ai/jobs/batch', { web: createAiSiteBatch })\n registerPluginApiRoute('ai/jobs/:jobId/cancel', {\n web: (request, context) =>\n cancelAiJob(request, { params: Promise.resolve({ jobId: String(context.params['jobId']) }) }),\n })\n registerPluginApiRoute('ai/jobs/:jobId/resume', {\n web: (request, context) =>\n resumeAiJob(request, { params: Promise.resolve({ jobId: String(context.params['jobId']) }) }),\n })\n // An insight job's answer (AGL-2915), which is kept off the job document\n // and served only to the member who asked, or for a digest to the site's\n // members.\n registerPluginApiRoute('ai/insights/:jobId', {\n web: (request, context) =>\n aiInsightAnswer(request, { params: Promise.resolve({ jobId: String(context.params['jobId']) }) }),\n })\n // A CRM job's answer (AGL-2917), which is kept off the job document and\n // served only to a member the CRM still lets read the record.\n registerPluginApiRoute('ai/crm/:jobId', {\n web: (request, context) =>\n aiCrmAnswer(request, { params: Promise.resolve({ jobId: String(context.params['jobId']) }) }),\n })\n registerPluginApiRoute('ai/jobs/:jobId/events', {\n web: (request, context) =>\n aiJobEvents(request, { params: Promise.resolve({ jobId: String(context.params['jobId']) }) }),\n })\n // The jobs beat (AGL-3026): every step the doors leave queued, run every\n // minute by the console's scheduler on the cron secret, on the one surface\n // that holds the provider's key.\n registerPluginApiRoute(AI_JOBS_BEAT_PATH, { web: runAiJobsBeat })\n // The weekly insights (AGL-2915): Monday's digests made for the people who\n // asked for them, and delivered once the beat has written them. Beside the\n // beat under `/api/admin/`, where the console's scheduled sweeps live.\n registerPluginApiRoute(AI_INSIGHTS_DIGEST_PATH, { web: runAiInsightsDigest })\n // A site SEO audit's \"Apply all\" (AGL-2910): content fixes as new\n // unpublished versions, listing values staged for their SEO cards.\n registerPluginApiRoute('ai/seo/apply', { web: applyAiSeoAudit })\n // A page's or a section's A/B variants as draft versions (AGL-3603): the\n // published version copied once per proposed variant, the variant's copy\n // put in, stored unpublished for the experiment editor to pin.\n registerPluginApiRoute('ai/experiments/versions', { web: createAiExperimentVersions })\n // Save the selection as a reusable component, with AI (AGL-2908): the\n // second entry point of the component job, from the besigner's Attributes\n // panel. It proposes, and the person's Apply writes.\n registerPluginApiRoute('ai/generate/component', { web: aiGenerateComponent })\n // Pictures from a description, in Media (AGL-3602): photos and SVG\n // illustrations, stored through the media upload route. POST only — the\n // button draws from the shell's gates and asks nothing until it is used.\n registerPluginApiRoute('ai/media/images', { web: createAiMediaImages })\n registerPluginApiRoute('ai/billing/credits', { web: billingCredits })\n registerPluginApiRoute('ai/billing/overage', { web: billingOverage })\n registerPluginApiRoute('ai/usage', { web: aiUsage })\n // The allotments a manager sets, and the options the model switch lists\n // (AGL-2942). One handler answers the allotments' GET and POST.\n registerPluginApiRoute('ai/allotments', { web: aiAllotments })\n registerPluginApiRoute('ai/models', { web: aiModels })\n // The staff doors (AGL-2928, AGL-2930, AGL-2252): one org's AI in full,\n // one account's usage across its workspaces, and the fleet's Assist\n // signals behind the Assist signal staff page.\n registerPluginApiRoute('ai/admin/org', { web: aiAdminOrg })\n registerPluginApiRoute('ai/admin/orgs-spend', { web: aiAdminOrgsSpend })\n registerPluginApiRoute('ai/admin/user', { web: aiAdminUser })\n registerPluginApiRoute('ai/admin/signals', { web: aiAdminSignals })\n // One workspace's overage standing and the four acts staff have over it\n // (AGL-3011): the ceiling override, lifting a pause — the only way a\n // dispute pause comes off — and resetting the step. Every act audited.\n registerPluginApiRoute('ai/admin/overage', { web: aiAdminOverage })\n // Credits given back to a workspace's band or a Free owner's allowance\n // (AGL-3595): compensation for a fault of ours, bounded by what the month\n // used, keyed against a double-click, and audited.\n registerPluginApiRoute('ai/admin/credits', { web: aiAdminCredits })\n}\n\n// Type-only (AGL-3080): the plugin's entitlement keys, declared by module\n// augmentation, for every program that loads this entry point.\nexport type { aiPlanEntitlements } from './plan-entitlements'\n"],"names":["registerPluginApiRoute","registerAiDeclarations","AI_JOBS_BEAT_PATH","registerAiJobPlan","registerAiJobsPause","registerAiJobsNotify","registerAiComponentJob","registerAiCrmJob","registerAiLayoutJob","registerAiTemplateJob","registerAiExperimentJob","registerAiFormJob","registerAiPageJob","registerAiProductsJob","registerAiEmailJob","registerAiCampaignJob","registerAiSiteJob","registerAiBuildJob","registerAiBuildCapabilities","registerAiWorkflowJob","registerAiLogicJob","registerAiInsightJob","registerAiFigureReaders","registerAiTextGenerator","firebaseAdmin","ensureFirstPartyAiProviders","aiAssistHandler","GET","aiCrmAnswer","POST","runAiJobsBeat","cancelAiJob","aiJobEvents","createAiSiteBatch","listAiJobs","createAiJob","resumeAiJob","aiGenerateComponent","createAiMediaImages","applyAiSeoAudit","createAiExperimentVersions","assistChat","assistEditApplied","assistFeedback","PATCH","aiHostPermissions","aiAdminOrg","aiAdminOrgsSpend","aiAdminSignals","aiAdminUser","aiAdminOverage","aiAdminCredits","aiUsage","aiAllotments","aiInsightAnswer","runAiInsightsDigest","AI_INSIGHTS_DIGEST_PATH","aiModels","billingCredits","billingOverage","registerFirstPartyProviders","registerAiJobKinds","app","firestore","registerAiConsoleApi","web","request","method","context","params","Promise","resolve","jobId","String"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,sBAAsB,QAAQ,sBAAqB;AAC5D,SAASC,sBAAsB,QAAQ,oBAAgB;AACvD,SAASC,iBAAiB,QAAQ,yBAAqB;AACvD,SAASC,iBAAiB,QAAQ,6BAAyB;AAC3D,SAASC,mBAA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3B;IAAoB;IACrEtC,uBAAuB,sBAAsB;QAAEiE,KAAKP;IAAe;IACnE1D,uBAAuB,sBAAsB;QAAEiE,KAAKN;IAAe;IACnE3D,uBAAuB,YAAY;QAAEiE,KAAKb;IAAQ;IAClD,wEAAwE;IACxE,gEAAgE;IAChEpD,uBAAuB,iBAAiB;QAAEiE,KAAKZ;IAAa;IAC5DrD,uBAAuB,aAAa;QAAEiE,KAAKR;IAAS;IACpD,wEAAwE;IACxE,oEAAoE;IACpE,+CAA+C;IAC/CzD,uBAAuB,gBAAgB;QAAEiE,KAAKnB;IAAW;IACzD9C,uBAAuB,uBAAuB;QAAEiE,KAAKlB;IAAiB;IACtE/C,uBAAuB,iBAAiB;QAAEiE,KAAKhB;IAAY;IAC3DjD,uBAAuB,oBAAoB;QAAEiE,KAAKjB;IAAe;IACjE,wEAAwE;IACxE,qEAAqE;IACrE,uEAAuE;IACvEhD,uBAAuB,oBAAoB;QAAEiE,KAAKf;IAAe;IACjE,uEAAuE;IACvE,0EAA0E;IAC1E,mDAAmD;IACnDlD,uBAAuB,oBAAoB;QAAEiE,KAAKd;IAAe;AACnE"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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 { AiTool } from '../providers/contract';
|
|
18
|
+
/**
|
|
19
|
+
* The strict tools a `logic` job answers through (AGL-3603). Each carries the
|
|
20
|
+
* shape the logic editor stores and nothing else: no id, no flag that saves
|
|
21
|
+
* or publishes. `checkAiLogicFunction` and `checkAiLogicVariable` decide what
|
|
22
|
+
* is kept — the grammar, the names and a first run — never this schema.
|
|
23
|
+
*/
|
|
24
|
+
export declare const AI_LOGIC_FUNCTION_TOOL_NAME = "submit_function";
|
|
25
|
+
export declare const AI_LOGIC_VARIABLE_TOOL_NAME = "submit_variable";
|
|
26
|
+
export declare function aiLogicFunctionTool(): AiTool;
|
|
27
|
+
export declare function aiLogicVariableTool(): AiTool;
|
|
@@ -0,0 +1,207 @@
|
|
|
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
|
+
*/ import { AI_LOGIC_COMPARATORS, AI_LOGIC_EXPRESSION_MAX_CHARS, AI_LOGIC_MAX_LOCALS, AI_LOGIC_MAX_OPERATIONS, AI_LOGIC_MAX_PARAMETERS, AI_LOGIC_MAX_SETS, AI_LOGIC_VALUE_TYPES, AI_LOGIC_VARIABLE_TYPES } from "../model/ai-logic-job.js";
|
|
17
|
+
/**
|
|
18
|
+
* The strict tools a `logic` job answers through (AGL-3603). Each carries the
|
|
19
|
+
* shape the logic editor stores and nothing else: no id, no flag that saves
|
|
20
|
+
* or publishes. `checkAiLogicFunction` and `checkAiLogicVariable` decide what
|
|
21
|
+
* is kept — the grammar, the names and a first run — never this schema.
|
|
22
|
+
*/ export const AI_LOGIC_FUNCTION_TOOL_NAME = 'submit_function';
|
|
23
|
+
export const AI_LOGIC_VARIABLE_TOOL_NAME = 'submit_variable';
|
|
24
|
+
const assignments = {
|
|
25
|
+
type: 'array',
|
|
26
|
+
description: `At most ${AI_LOGIC_MAX_SETS}; empty when nothing changes on that branch.`,
|
|
27
|
+
items: {
|
|
28
|
+
type: 'object',
|
|
29
|
+
additionalProperties: false,
|
|
30
|
+
required: [
|
|
31
|
+
'set',
|
|
32
|
+
'expression'
|
|
33
|
+
],
|
|
34
|
+
properties: {
|
|
35
|
+
set: {
|
|
36
|
+
type: 'string',
|
|
37
|
+
description: 'The parameter or local this assigns.'
|
|
38
|
+
},
|
|
39
|
+
expression: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: `The value, as an expression; at most ${AI_LOGIC_EXPRESSION_MAX_CHARS} characters.`
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export function aiLogicFunctionTool() {
|
|
47
|
+
return {
|
|
48
|
+
name: AI_LOGIC_FUNCTION_TOOL_NAME,
|
|
49
|
+
description: 'Submit the function, as the Functions editor stores it. Every field is required.',
|
|
50
|
+
strict: true,
|
|
51
|
+
inputSchema: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
additionalProperties: false,
|
|
54
|
+
required: [
|
|
55
|
+
'name',
|
|
56
|
+
'parameters',
|
|
57
|
+
'locals',
|
|
58
|
+
'operations',
|
|
59
|
+
'returnValue'
|
|
60
|
+
],
|
|
61
|
+
properties: {
|
|
62
|
+
name: {
|
|
63
|
+
type: 'string',
|
|
64
|
+
description: 'The function’s name: a letter or _, then letters, digits or _.'
|
|
65
|
+
},
|
|
66
|
+
parameters: {
|
|
67
|
+
type: 'array',
|
|
68
|
+
description: `What the function is given; at most ${AI_LOGIC_MAX_PARAMETERS}.`,
|
|
69
|
+
items: {
|
|
70
|
+
type: 'object',
|
|
71
|
+
additionalProperties: false,
|
|
72
|
+
required: [
|
|
73
|
+
'name',
|
|
74
|
+
'type',
|
|
75
|
+
'required',
|
|
76
|
+
'label',
|
|
77
|
+
'defaultValue'
|
|
78
|
+
],
|
|
79
|
+
properties: {
|
|
80
|
+
name: {
|
|
81
|
+
type: 'string'
|
|
82
|
+
},
|
|
83
|
+
type: {
|
|
84
|
+
type: 'string',
|
|
85
|
+
enum: [
|
|
86
|
+
...AI_LOGIC_VALUE_TYPES
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
required: {
|
|
90
|
+
type: 'boolean'
|
|
91
|
+
},
|
|
92
|
+
label: {
|
|
93
|
+
type: 'string',
|
|
94
|
+
description: 'What a visitor reads above the input; empty for none.'
|
|
95
|
+
},
|
|
96
|
+
defaultValue: {
|
|
97
|
+
type: 'string',
|
|
98
|
+
description: 'What the input starts with; empty for none.'
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
locals: {
|
|
104
|
+
type: 'array',
|
|
105
|
+
description: `Working values the operations set; at most ${AI_LOGIC_MAX_LOCALS}.`,
|
|
106
|
+
items: {
|
|
107
|
+
type: 'object',
|
|
108
|
+
additionalProperties: false,
|
|
109
|
+
required: [
|
|
110
|
+
'name',
|
|
111
|
+
'type'
|
|
112
|
+
],
|
|
113
|
+
properties: {
|
|
114
|
+
name: {
|
|
115
|
+
type: 'string'
|
|
116
|
+
},
|
|
117
|
+
type: {
|
|
118
|
+
type: 'string',
|
|
119
|
+
enum: [
|
|
120
|
+
...AI_LOGIC_VALUE_TYPES
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
operations: {
|
|
127
|
+
type: 'array',
|
|
128
|
+
description: `Run in order; at most ${AI_LOGIC_MAX_OPERATIONS}. Each is if (left comparator right) then … otherwise ….`,
|
|
129
|
+
items: {
|
|
130
|
+
type: 'object',
|
|
131
|
+
additionalProperties: false,
|
|
132
|
+
required: [
|
|
133
|
+
'if',
|
|
134
|
+
'then',
|
|
135
|
+
'otherwise'
|
|
136
|
+
],
|
|
137
|
+
properties: {
|
|
138
|
+
if: {
|
|
139
|
+
type: 'object',
|
|
140
|
+
additionalProperties: false,
|
|
141
|
+
required: [
|
|
142
|
+
'left',
|
|
143
|
+
'comparator',
|
|
144
|
+
'right'
|
|
145
|
+
],
|
|
146
|
+
properties: {
|
|
147
|
+
left: {
|
|
148
|
+
type: 'string'
|
|
149
|
+
},
|
|
150
|
+
comparator: {
|
|
151
|
+
type: 'string',
|
|
152
|
+
enum: [
|
|
153
|
+
...AI_LOGIC_COMPARATORS
|
|
154
|
+
]
|
|
155
|
+
},
|
|
156
|
+
right: {
|
|
157
|
+
type: 'string'
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
then: assignments,
|
|
162
|
+
otherwise: assignments
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
returnValue: {
|
|
167
|
+
type: 'string',
|
|
168
|
+
description: 'The parameter or local whose final value the function returns.'
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export function aiLogicVariableTool() {
|
|
175
|
+
return {
|
|
176
|
+
name: AI_LOGIC_VARIABLE_TOOL_NAME,
|
|
177
|
+
description: 'Submit the variable, as the Variables editor stores it. Every field is required.',
|
|
178
|
+
strict: true,
|
|
179
|
+
inputSchema: {
|
|
180
|
+
type: 'object',
|
|
181
|
+
additionalProperties: false,
|
|
182
|
+
required: [
|
|
183
|
+
'name',
|
|
184
|
+
'type',
|
|
185
|
+
'value'
|
|
186
|
+
],
|
|
187
|
+
properties: {
|
|
188
|
+
name: {
|
|
189
|
+
type: 'string',
|
|
190
|
+
description: 'A letter or _, then letters, digits or _.'
|
|
191
|
+
},
|
|
192
|
+
type: {
|
|
193
|
+
type: 'string',
|
|
194
|
+
enum: [
|
|
195
|
+
...AI_LOGIC_VARIABLE_TYPES
|
|
196
|
+
]
|
|
197
|
+
},
|
|
198
|
+
value: {
|
|
199
|
+
type: 'string',
|
|
200
|
+
description: 'The value as stored: a number as digits; true or false; a date as YYYY-MM-DD; a time as HH:MM; a dictionary as a JSON object; a collection as a JSON list.'
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
//# sourceMappingURL=ai-logic-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/tools/ai-logic-tool.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\nimport {\n AI_LOGIC_COMPARATORS,\n AI_LOGIC_EXPRESSION_MAX_CHARS,\n AI_LOGIC_MAX_LOCALS,\n AI_LOGIC_MAX_OPERATIONS,\n AI_LOGIC_MAX_PARAMETERS,\n AI_LOGIC_MAX_SETS,\n AI_LOGIC_VALUE_TYPES,\n AI_LOGIC_VARIABLE_TYPES,\n} from '../model/ai-logic-job'\nimport type { AiTool } from '../providers/contract'\n\n/**\n * The strict tools a `logic` job answers through (AGL-3603). Each carries the\n * shape the logic editor stores and nothing else: no id, no flag that saves\n * or publishes. `checkAiLogicFunction` and `checkAiLogicVariable` decide what\n * is kept — the grammar, the names and a first run — never this schema.\n */\n\nexport const AI_LOGIC_FUNCTION_TOOL_NAME = 'submit_function'\nexport const AI_LOGIC_VARIABLE_TOOL_NAME = 'submit_variable'\n\nconst assignments = {\n type: 'array',\n description: `At most ${AI_LOGIC_MAX_SETS}; empty when nothing changes on that branch.`,\n items: {\n type: 'object',\n additionalProperties: false,\n required: ['set', 'expression'],\n properties: {\n set: { type: 'string', description: 'The parameter or local this assigns.' },\n expression: {\n type: 'string',\n description: `The value, as an expression; at most ${AI_LOGIC_EXPRESSION_MAX_CHARS} characters.`,\n },\n },\n },\n}\n\nexport function aiLogicFunctionTool(): AiTool {\n return {\n name: AI_LOGIC_FUNCTION_TOOL_NAME,\n description: 'Submit the function, as the Functions editor stores it. Every field is required.',\n strict: true,\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n required: ['name', 'parameters', 'locals', 'operations', 'returnValue'],\n properties: {\n name: { type: 'string', description: 'The function’s name: a letter or _, then letters, digits or _.' },\n parameters: {\n type: 'array',\n description: `What the function is given; at most ${AI_LOGIC_MAX_PARAMETERS}.`,\n items: {\n type: 'object',\n additionalProperties: false,\n required: ['name', 'type', 'required', 'label', 'defaultValue'],\n properties: {\n name: { type: 'string' },\n type: { type: 'string', enum: [...AI_LOGIC_VALUE_TYPES] },\n required: { type: 'boolean' },\n label: { type: 'string', description: 'What a visitor reads above the input; empty for none.' },\n defaultValue: { type: 'string', description: 'What the input starts with; empty for none.' },\n },\n },\n },\n locals: {\n type: 'array',\n description: `Working values the operations set; at most ${AI_LOGIC_MAX_LOCALS}.`,\n items: {\n type: 'object',\n additionalProperties: false,\n required: ['name', 'type'],\n properties: {\n name: { type: 'string' },\n type: { type: 'string', enum: [...AI_LOGIC_VALUE_TYPES] },\n },\n },\n },\n operations: {\n type: 'array',\n description: `Run in order; at most ${AI_LOGIC_MAX_OPERATIONS}. Each is if (left comparator right) then … otherwise ….`,\n items: {\n type: 'object',\n additionalProperties: false,\n required: ['if', 'then', 'otherwise'],\n properties: {\n if: {\n type: 'object',\n additionalProperties: false,\n required: ['left', 'comparator', 'right'],\n properties: {\n left: { type: 'string' },\n comparator: { type: 'string', enum: [...AI_LOGIC_COMPARATORS] },\n right: { type: 'string' },\n },\n },\n then: assignments,\n otherwise: assignments,\n },\n },\n },\n returnValue: { type: 'string', description: 'The parameter or local whose final value the function returns.' },\n },\n },\n }\n}\n\nexport function aiLogicVariableTool(): AiTool {\n return {\n name: AI_LOGIC_VARIABLE_TOOL_NAME,\n description: 'Submit the variable, as the Variables editor stores it. Every field is required.',\n strict: true,\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n required: ['name', 'type', 'value'],\n properties: {\n name: { type: 'string', description: 'A letter or _, then letters, digits or _.' },\n type: { type: 'string', enum: [...AI_LOGIC_VARIABLE_TYPES] },\n value: {\n type: 'string',\n description:\n 'The value as stored: a number as digits; true or false; a date as YYYY-MM-DD; a time as HH:MM; a dictionary as a JSON object; a collection as a JSON list.',\n },\n },\n },\n }\n}\n"],"names":["AI_LOGIC_COMPARATORS","AI_LOGIC_EXPRESSION_MAX_CHARS","AI_LOGIC_MAX_LOCALS","AI_LOGIC_MAX_OPERATIONS","AI_LOGIC_MAX_PARAMETERS","AI_LOGIC_MAX_SETS","AI_LOGIC_VALUE_TYPES","AI_LOGIC_VARIABLE_TYPES","AI_LOGIC_FUNCTION_TOOL_NAME","AI_LOGIC_VARIABLE_TOOL_NAME","assignments","type","description","items","additionalProperties","required","properties","set","expression","aiLogicFunctionTool","name","strict","inputSchema","parameters","enum","label","defaultValue","locals","operations","if","left","comparator","right","then","otherwise","returnValue","aiLogicVariableTool","value"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,oBAAoB,EACpBC,6BAA6B,EAC7BC,mBAAmB,EACnBC,uBAAuB,EACvBC,uBAAuB,EACvBC,iBAAiB,EACjBC,oBAAoB,EACpBC,uBAAuB,QAClB,2BAAuB;AAG9B;;;;;CAKC,GAED,OAAO,MAAMC,8BAA8B,kBAAiB;AAC5D,OAAO,MAAMC,8BAA8B,kBAAiB;AAE5D,MAAMC,cAAc;IAClBC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AEA,MAAM;gCAAUa,MAAM;uCAAIlB;iCAAqB;4BAAC;wBAC1D;oBACF;gBACF;gBACAsB,YAAY;oBACVjB,MAAM;oBACNC,aAAa,CAAC,sBAAsB,EAAET,wBAAwB,wDAAwD,CAAC;oBACvHU,OAAO;wBACLF,MAAM;wBACNG,sBAAsB;wBACtBC,UAAU;4BAAC;4BAAM;4BAAQ;yBAAY;wBACrCC,YAAY;4BACVa,IAAI;gCACFlB,MAAM;gCACNG,sBAAsB;gCACtBC,UAAU;oCAAC;oCAAQ;oCAAc;iCAAQ;gCACzCC,YAAY;oCACVc,MAAM;wCAAEnB,MAAM;oCAAS;oCACvBoB,YAAY;wCAAEpB,MAAM;wCAAUa,MAAM;+CAAIxB;yCAAqB;oCAAC;oCAC9DgC,OAAO;wCAAErB,MAAM;oCAAS;gCAC1B;4BACF;4BACAsB,MAAMvB;4BACNwB,WAAWxB;wBACb;oBACF;gBACF;gBACAyB,aAAa;oBAAExB,MAAM;oBAAUC,aAAa;gBAAiE;YAC/G;QACF;IACF;AACF;AAEA,OAAO,SAASwB;IACd,OAAO;QACLhB,MAAMX;QACNG,aAAa;QACbS,QAAQ;QACRC,aAAa;YACXX,MAAM;YACNG,sBAAsB;YACtBC,UAAU;gBAAC;gBAAQ;gBAAQ;aAAQ;YACnCC,YAAY;gBACVI,MAAM;oBAAET,MAAM;oBAAUC,aAAa;gBAA4C;gBACjFD,MAAM;oBAAEA,MAAM;oBAAUa,MAAM;2BAAIjB;qBAAwB;gBAAC;gBAC3D8B,OAAO;oBACL1B,MAAM;oBACNC,aACE;gBACJ;YACF;QACF;IACF;AACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 AiOverlayCopyAnswer, type AiOverlayCopyField, type AiOverlayKind, type AiOverlayTrigger } from '../model/ai-overlay-copy';
|
|
18
|
+
import type { AiTool } from '../providers/contract';
|
|
19
|
+
/**
|
|
20
|
+
* The strict tool overlay copy is answered through (AGL-3603).
|
|
21
|
+
*
|
|
22
|
+
* It carries copy and, for a popup, WHEN it opens — one of the triggers the
|
|
23
|
+
* request lists, or `none`. It has no field for a link, a schedule, the
|
|
24
|
+
* pages it shows on or whether it is switched on: those are a person's
|
|
25
|
+
* decisions in the overlay editor, and a model that could name them could put
|
|
26
|
+
* an overlay in front of visitors nobody chose.
|
|
27
|
+
*/
|
|
28
|
+
export declare const AI_OVERLAY_TOOL_NAME = "write_overlay_copy";
|
|
29
|
+
export declare function aiOverlayTool(kind: AiOverlayKind, limits: Readonly<Record<AiOverlayCopyField, number>>, triggers: readonly AiOverlayTrigger[]): AiTool;
|
|
30
|
+
/**
|
|
31
|
+
* A `write_overlay_copy` call as the check reads it, or `null` when it is not
|
|
32
|
+
* one. Values keep the lengths the model wrote: the check decides what is too
|
|
33
|
+
* long.
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseAiOverlayCopy(input: unknown): AiOverlayCopyAnswer | null;
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
*/ import { AI_OVERLAY_TRIGGERS } from "../model/ai-overlay-copy.js";
|
|
17
|
+
/**
|
|
18
|
+
* The strict tool overlay copy is answered through (AGL-3603).
|
|
19
|
+
*
|
|
20
|
+
* It carries copy and, for a popup, WHEN it opens — one of the triggers the
|
|
21
|
+
* request lists, or `none`. It has no field for a link, a schedule, the
|
|
22
|
+
* pages it shows on or whether it is switched on: those are a person's
|
|
23
|
+
* decisions in the overlay editor, and a model that could name them could put
|
|
24
|
+
* an overlay in front of visitors nobody chose.
|
|
25
|
+
*/ export const AI_OVERLAY_TOOL_NAME = 'write_overlay_copy';
|
|
26
|
+
export function aiOverlayTool(kind, limits, triggers) {
|
|
27
|
+
const properties = {
|
|
28
|
+
name: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
description: `A short internal name for the ${kind === 'bar' ? 'bar' : 'popup'}, for the site owner's list; at most ${limits.name} characters.`
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const required = [
|
|
34
|
+
'name'
|
|
35
|
+
];
|
|
36
|
+
if (kind === 'bar') {
|
|
37
|
+
properties['text'] = {
|
|
38
|
+
type: 'string',
|
|
39
|
+
description: `The bar's one line of copy; at most ${limits.text} characters.`
|
|
40
|
+
};
|
|
41
|
+
required.push('text');
|
|
42
|
+
} else {
|
|
43
|
+
properties['headline'] = {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: `The popup's headline; at most ${limits.headline} characters.`
|
|
46
|
+
};
|
|
47
|
+
properties['body'] = {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: `The popup's supporting copy, one or two short paragraphs; at most ${limits.body} characters.`
|
|
50
|
+
};
|
|
51
|
+
properties['ctaLabel'] = {
|
|
52
|
+
type: 'string',
|
|
53
|
+
description: `The button's label, a few words that start with a verb; at most ${limits.ctaLabel} characters. Empty string for no button.`
|
|
54
|
+
};
|
|
55
|
+
properties['trigger'] = {
|
|
56
|
+
type: 'string',
|
|
57
|
+
enum: [
|
|
58
|
+
...triggers.filter((trigger)=>AI_OVERLAY_TRIGGERS.includes(trigger)),
|
|
59
|
+
'none'
|
|
60
|
+
],
|
|
61
|
+
description: 'When the popup opens, from the triggers the request lists; `none` to leave it as it is.'
|
|
62
|
+
};
|
|
63
|
+
properties['triggerValue'] = {
|
|
64
|
+
type: 'number',
|
|
65
|
+
description: 'Seconds after the page loads for `delay`, the percent of the page scrolled for `scroll`, inside the range the request gives; 0 for `exit` or `none`.'
|
|
66
|
+
};
|
|
67
|
+
required.push('headline', 'body', 'ctaLabel', 'trigger', 'triggerValue');
|
|
68
|
+
}
|
|
69
|
+
properties['rationale'] = {
|
|
70
|
+
type: 'string',
|
|
71
|
+
description: 'One sentence on what the copy leans on; at most 200 characters.'
|
|
72
|
+
};
|
|
73
|
+
required.push('rationale');
|
|
74
|
+
return {
|
|
75
|
+
name: AI_OVERLAY_TOOL_NAME,
|
|
76
|
+
description: `Write the copy for one ${kind === 'bar' ? 'announcement bar' : 'popup'}. Every field is required.`,
|
|
77
|
+
strict: true,
|
|
78
|
+
inputSchema: {
|
|
79
|
+
type: 'object',
|
|
80
|
+
properties,
|
|
81
|
+
required,
|
|
82
|
+
additionalProperties: false
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const isRecord = (value)=>typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
87
|
+
const str = (value)=>typeof value === 'string' ? value : '';
|
|
88
|
+
/**
|
|
89
|
+
* A `write_overlay_copy` call as the check reads it, or `null` when it is not
|
|
90
|
+
* one. Values keep the lengths the model wrote: the check decides what is too
|
|
91
|
+
* long.
|
|
92
|
+
*/ export function parseAiOverlayCopy(input) {
|
|
93
|
+
if (!isRecord(input)) return null;
|
|
94
|
+
const value = input['triggerValue'];
|
|
95
|
+
return {
|
|
96
|
+
name: str(input['name']),
|
|
97
|
+
text: str(input['text']),
|
|
98
|
+
headline: str(input['headline']),
|
|
99
|
+
body: str(input['body']),
|
|
100
|
+
ctaLabel: str(input['ctaLabel']),
|
|
101
|
+
trigger: str(input['trigger']),
|
|
102
|
+
triggerValue: typeof value === 'number' && Number.isFinite(value) ? value : null,
|
|
103
|
+
rationale: str(input['rationale'])
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
//# sourceMappingURL=ai-overlay-tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/ai/src/lib/tools/ai-overlay-tool.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\nimport {\n AI_OVERLAY_TRIGGERS,\n type AiOverlayCopyAnswer,\n type AiOverlayCopyField,\n type AiOverlayKind,\n type AiOverlayTrigger,\n} from '../model/ai-overlay-copy'\nimport type { AiTool } from '../providers/contract'\n\n/**\n * The strict tool overlay copy is answered through (AGL-3603).\n *\n * It carries copy and, for a popup, WHEN it opens — one of the triggers the\n * request lists, or `none`. It has no field for a link, a schedule, the\n * pages it shows on or whether it is switched on: those are a person's\n * decisions in the overlay editor, and a model that could name them could put\n * an overlay in front of visitors nobody chose.\n */\n\nexport const AI_OVERLAY_TOOL_NAME = 'write_overlay_copy'\n\nexport function aiOverlayTool(\n kind: AiOverlayKind,\n limits: Readonly<Record<AiOverlayCopyField, number>>,\n triggers: readonly AiOverlayTrigger[],\n): AiTool {\n const properties: Record<string, unknown> = {\n name: {\n type: 'string',\n description: `A short internal name for the ${kind === 'bar' ? 'bar' : 'popup'}, for the site owner's list; at most ${limits.name} characters.`,\n },\n }\n const required = ['name']\n if (kind === 'bar') {\n properties['text'] = {\n type: 'string',\n description: `The bar's one line of copy; at most ${limits.text} characters.`,\n }\n required.push('text')\n } else {\n properties['headline'] = {\n type: 'string',\n description: `The popup's headline; at most ${limits.headline} characters.`,\n }\n properties['body'] = {\n type: 'string',\n description: `The popup's supporting copy, one or two short paragraphs; at most ${limits.body} characters.`,\n }\n properties['ctaLabel'] = {\n type: 'string',\n description: `The button's label, a few words that start with a verb; at most ${limits.ctaLabel} characters. Empty string for no button.`,\n }\n properties['trigger'] = {\n type: 'string',\n enum: [...triggers.filter((trigger) => (AI_OVERLAY_TRIGGERS as readonly string[]).includes(trigger)), 'none'],\n description: 'When the popup opens, from the triggers the request lists; `none` to leave it as it is.',\n }\n properties['triggerValue'] = {\n type: 'number',\n description:\n 'Seconds after the page loads for `delay`, the percent of the page scrolled for `scroll`, inside the range the request gives; 0 for `exit` or `none`.',\n }\n required.push('headline', 'body', 'ctaLabel', 'trigger', 'triggerValue')\n }\n properties['rationale'] = {\n type: 'string',\n description: 'One sentence on what the copy leans on; at most 200 characters.',\n }\n required.push('rationale')\n return {\n name: AI_OVERLAY_TOOL_NAME,\n description: `Write the copy for one ${kind === 'bar' ? 'announcement bar' : 'popup'}. Every field is required.`,\n strict: true,\n inputSchema: {\n type: 'object',\n properties,\n required,\n additionalProperties: false,\n },\n }\n}\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value)\n\nconst str = (value: unknown): string => (typeof value === 'string' ? value : '')\n\n/**\n * A `write_overlay_copy` call as the check reads it, or `null` when it is not\n * one. Values keep the lengths the model wrote: the check decides what is too\n * long.\n */\nexport function parseAiOverlayCopy(input: unknown): AiOverlayCopyAnswer | null {\n if (!isRecord(input)) return null\n const value = input['triggerValue']\n return {\n name: str(input['name']),\n text: str(input['text']),\n headline: str(input['headline']),\n body: str(input['body']),\n ctaLabel: str(input['ctaLabel']),\n trigger: str(input['trigger']),\n triggerValue: typeof value === 'number' && Number.isFinite(value) ? value : null,\n rationale: str(input['rationale']),\n }\n}\n"],"names":["AI_OVERLAY_TRIGGERS","AI_OVERLAY_TOOL_NAME","aiOverlayTool","kind","limits","triggers","properties","name","type","description","required","text","push","headline","body","ctaLabel","enum","filter","trigger","includes","strict","inputSchema","additionalProperties","isRecord","value","Array","isArray","str","parseAiOverlayCopy","input","triggerValue","Number","isFinite","rationale"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,mBAAmB,QAKd,8BAA0B;AAGjC;;;;;;;;CAQC,GAED,OAAO,MAAMC,uBAAuB,qBAAoB;AAExD,OAAO,SAASC,cACdC,IAAmB,EACnBC,MAAoD,EACpDC,QAAqC;IAErC,MAAMC,aAAsC;QAC1CC,MAAM;YACJC,MAAM;YACNC,aAAa,CAAC,8BAA8B,EAAEN,SAAS,QAAQ,QAAQ,QAAQ,qCAAqC,EAAEC,OAAOG,IAAI,CAAC,YAAY,CAAC;QACjJ;IACF;IACA,MAAMG,WAAW;QAAC;KAAO;IACzB,IAAIP,SAAS,OAAO;QAClBG,UAAU,CAAC,OAAO,GAAG;YACnBE,MAAM;YACNC,aAAa,CAAC,oCAAoC,EAAEL,OAAOO,IAAI,CAAC,YAAY,CAAC;QAC/E;QACAD,SAASE,IAAI,CAAC;IAChB,OAAO;QACLN,UAAU,CAAC,WAAW,GAAG;YACvBE,MAAM;YACNC,aAAa,CAAC,8BAA8B,EAAEL,OAAOS,QAAQ,CAAC,YAAY,CAAC;QAC7E;QACAP,UAAU,CAAC,OAAO,GAAG;YACnBE,MAAM;YACNC,aAAa,CAAC,kEAAkE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K,CAAC,UAAU;QAC7BC,cAAc,OAAON,UAAU,YAAYO,OAAOC,QAAQ,CAACR,SAASA,QAAQ;QAC5ES,WAAWN,IAAIE,KAAK,CAAC,YAAY;IACnC;AACF"}
|
|
@@ -162,6 +162,17 @@ export declare function lifecycleStageOf(value: string): ContactLifecycleStage |
|
|
|
162
162
|
* beside rule 13. `value` is the automation when nothing is refused.
|
|
163
163
|
*/
|
|
164
164
|
export declare function readAiAutomationAnswer(answer: Record<string, unknown>, capabilities: AiAutomationCapabilities): AiGenerationCheckResult<AiAutomationAnswer>;
|
|
165
|
+
/**
|
|
166
|
+
* An answer already read, held as well to an org automation's narrower
|
|
167
|
+
* vocabulary (AGL-3603): its trigger one the vocabulary names, and every step
|
|
168
|
+
* a type it names. A refusal names what the vocabulary holds, so the re-ask
|
|
169
|
+
* can pick from it. An answer that says the automation cannot be built is
|
|
170
|
+
* left as it is.
|
|
171
|
+
*/
|
|
172
|
+
export declare function holdAiAutomationAnswerToVocabulary(result: AiGenerationCheckResult<AiAutomationAnswer>, vocabulary: {
|
|
173
|
+
triggers: readonly HostEventType[];
|
|
174
|
+
steps: readonly AiAutomationStepType[];
|
|
175
|
+
}): AiGenerationCheckResult<AiAutomationAnswer>;
|
|
165
176
|
export interface AiWorkflowExplanation {
|
|
166
177
|
summary: string;
|
|
167
178
|
points: string[];
|