@aglyn/plugins-ai 1.0.0-beta.246 → 1.0.0-beta.249

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.
Files changed (130) hide show
  1. package/package.json +17 -17
  2. package/src/lib/activity/ai-activity-actions.js +5 -1
  3. package/src/lib/activity/ai-activity-actions.js.map +1 -1
  4. package/src/lib/components/ai-job-links.js +14 -0
  5. package/src/lib/components/ai-job-links.js.map +1 -1
  6. package/src/lib/components/ai-site-start-card.component.d.ts +1 -1
  7. package/src/lib/components/ai-site-start-card.component.js +92 -19
  8. package/src/lib/components/ai-site-start-card.component.js.map +1 -1
  9. package/src/lib/declarations.server.js +12 -0
  10. package/src/lib/declarations.server.js.map +1 -1
  11. package/src/lib/jobs/ai-build-capabilities.js +56 -2
  12. package/src/lib/jobs/ai-build-capabilities.js.map +1 -1
  13. package/src/lib/jobs/ai-job-build-step.d.ts +3 -8
  14. package/src/lib/jobs/ai-job-build-step.js +49 -12
  15. package/src/lib/jobs/ai-job-build-step.js.map +1 -1
  16. package/src/lib/jobs/ai-job-form-dataset.d.ts +8 -5
  17. package/src/lib/jobs/ai-job-form-dataset.js +28 -10
  18. package/src/lib/jobs/ai-job-form-dataset.js.map +1 -1
  19. package/src/lib/jobs/ai-job-form-step.d.ts +20 -4
  20. package/src/lib/jobs/ai-job-form-step.js +98 -28
  21. package/src/lib/jobs/ai-job-form-step.js.map +1 -1
  22. package/src/lib/jobs/ai-job-layout-language.d.ts +6 -2
  23. package/src/lib/jobs/ai-job-layout-language.js +16 -5
  24. package/src/lib/jobs/ai-job-layout-language.js.map +1 -1
  25. package/src/lib/jobs/ai-job-layout-step.js +4 -1
  26. package/src/lib/jobs/ai-job-layout-step.js.map +1 -1
  27. package/src/lib/jobs/ai-job-media-step.d.ts +239 -0
  28. package/src/lib/jobs/ai-job-media-step.js +610 -0
  29. package/src/lib/jobs/ai-job-media-step.js.map +1 -0
  30. package/src/lib/jobs/ai-job-page-language.d.ts +2 -0
  31. package/src/lib/jobs/ai-job-page-language.js +9 -0
  32. package/src/lib/jobs/ai-job-page-language.js.map +1 -1
  33. package/src/lib/jobs/ai-job-page-sections.js +4 -3
  34. package/src/lib/jobs/ai-job-page-sections.js.map +1 -1
  35. package/src/lib/jobs/ai-job-page-step.js +3 -2
  36. package/src/lib/jobs/ai-job-page-step.js.map +1 -1
  37. package/src/lib/jobs/ai-job-plan-step.d.ts +10 -1
  38. package/src/lib/jobs/ai-job-plan-step.js +73 -15
  39. package/src/lib/jobs/ai-job-plan-step.js.map +1 -1
  40. package/src/lib/jobs/ai-job-settings-step.d.ts +0 -4
  41. package/src/lib/jobs/ai-job-settings-step.js +2 -7
  42. package/src/lib/jobs/ai-job-settings-step.js.map +1 -1
  43. package/src/lib/jobs/ai-job-site-content.d.ts +2 -2
  44. package/src/lib/jobs/ai-job-site-content.js +5 -3
  45. package/src/lib/jobs/ai-job-site-content.js.map +1 -1
  46. package/src/lib/jobs/ai-job-site-datasets.d.ts +1 -1
  47. package/src/lib/jobs/ai-job-site-datasets.js +3 -2
  48. package/src/lib/jobs/ai-job-site-datasets.js.map +1 -1
  49. package/src/lib/jobs/ai-job-site-events.d.ts +148 -0
  50. package/src/lib/jobs/ai-job-site-events.js +313 -0
  51. package/src/lib/jobs/ai-job-site-events.js.map +1 -0
  52. package/src/lib/jobs/ai-job-site-step.d.ts +9 -3
  53. package/src/lib/jobs/ai-job-site-step.js +63 -17
  54. package/src/lib/jobs/ai-job-site-step.js.map +1 -1
  55. package/src/lib/jobs/ai-job-tracking-step.d.ts +184 -0
  56. package/src/lib/jobs/ai-job-tracking-step.js +501 -0
  57. package/src/lib/jobs/ai-job-tracking-step.js.map +1 -0
  58. package/src/lib/jobs/ai-layout-stock-photos.d.ts +41 -0
  59. package/src/lib/jobs/ai-layout-stock-photos.js +71 -3
  60. package/src/lib/jobs/ai-layout-stock-photos.js.map +1 -1
  61. package/src/lib/jobs/ai-site-publish.js +2 -3
  62. package/src/lib/jobs/ai-site-publish.js.map +1 -1
  63. package/src/lib/jobs/ai-stock-photo-picker.d.ts +24 -0
  64. package/src/lib/jobs/ai-stock-photo-picker.js +108 -0
  65. package/src/lib/jobs/ai-stock-photo-picker.js.map +1 -0
  66. package/src/lib/jobs/fixtures/ai-jazz-events-build-plan-recording.d.ts +37 -0
  67. package/src/lib/jobs/fixtures/ai-jazz-events-build-plan-recording.js +47 -0
  68. package/src/lib/jobs/fixtures/ai-jazz-events-build-plan-recording.js.map +1 -0
  69. package/src/lib/jobs/fixtures/ai-stock-photo-agl3760-recordings.d.ts +21 -0
  70. package/src/lib/jobs/fixtures/ai-stock-photo-agl3760-recordings.js +128 -0
  71. package/src/lib/jobs/fixtures/ai-stock-photo-agl3760-recordings.js.map +1 -0
  72. package/src/lib/jobs/fixtures/ai-stock-photo-agl3769-recordings.d.ts +21 -0
  73. package/src/lib/jobs/fixtures/ai-stock-photo-agl3769-recordings.js +126 -0
  74. package/src/lib/jobs/fixtures/ai-stock-photo-agl3769-recordings.js.map +1 -0
  75. package/src/lib/layout-language/ai-layout-compiler.d.ts +10 -4
  76. package/src/lib/layout-language/ai-layout-compiler.js +38 -19
  77. package/src/lib/layout-language/ai-layout-compiler.js.map +1 -1
  78. package/src/lib/layout-language/ai-layout-frame.d.ts +7 -5
  79. package/src/lib/layout-language/ai-layout-frame.js +12 -9
  80. package/src/lib/layout-language/ai-layout-frame.js.map +1 -1
  81. package/src/lib/layout-language/ai-layout-gaps.js +3 -1
  82. package/src/lib/layout-language/ai-layout-gaps.js.map +1 -1
  83. package/src/lib/layout-language/ai-layout-labels.d.ts +70 -0
  84. package/src/lib/layout-language/ai-layout-labels.js +162 -0
  85. package/src/lib/layout-language/ai-layout-labels.js.map +1 -0
  86. package/src/lib/layout-language/ai-layout-links.js +5 -2
  87. package/src/lib/layout-language/ai-layout-links.js.map +1 -1
  88. package/src/lib/layout-language/ai-layout-listings.d.ts +14 -1
  89. package/src/lib/layout-language/ai-layout-listings.js +32 -5
  90. package/src/lib/layout-language/ai-layout-listings.js.map +1 -1
  91. package/src/lib/model/ai-build-event-page.d.ts +70 -0
  92. package/src/lib/model/ai-build-event-page.js +145 -0
  93. package/src/lib/model/ai-build-event-page.js.map +1 -0
  94. package/src/lib/model/ai-build-job.d.ts +21 -0
  95. package/src/lib/model/ai-build-job.js +39 -0
  96. package/src/lib/model/ai-build-job.js.map +1 -1
  97. package/src/lib/model/ai-build-plan.d.ts +25 -14
  98. package/src/lib/model/ai-build-plan.js +33 -23
  99. package/src/lib/model/ai-build-plan.js.map +1 -1
  100. package/src/lib/model/ai-job-activity.js +3 -1
  101. package/src/lib/model/ai-job-activity.js.map +1 -1
  102. package/src/lib/model/ai-jobs.types.d.ts +10 -2
  103. package/src/lib/model/ai-jobs.types.js +3 -1
  104. package/src/lib/model/ai-jobs.types.js.map +1 -1
  105. package/src/lib/model/ai-plan-capabilities.d.ts +8 -0
  106. package/src/lib/model/ai-plan-capabilities.js.map +1 -1
  107. package/src/lib/model/ai-site-inventory.d.ts +2 -0
  108. package/src/lib/model/ai-site-inventory.js +5 -0
  109. package/src/lib/model/ai-site-inventory.js.map +1 -1
  110. package/src/lib/model/ai-site-job.d.ts +2 -2
  111. package/src/lib/model/ai-site-job.js +3 -3
  112. package/src/lib/model/ai-site-job.js.map +1 -1
  113. package/src/lib/runtime/ai-doctrine-validators.d.ts +25 -3
  114. package/src/lib/runtime/ai-doctrine-validators.js +53 -6
  115. package/src/lib/runtime/ai-doctrine-validators.js.map +1 -1
  116. package/src/lib/runtime/ai-doctrine.d.ts +6 -1
  117. package/src/lib/runtime/ai-doctrine.js +13 -9
  118. package/src/lib/runtime/ai-doctrine.js.map +1 -1
  119. package/src/lib/runtime/ai-eval-live.d.ts +1 -1
  120. package/src/lib/runtime/ai-eval-live.js +1 -1
  121. package/src/lib/runtime/ai-eval-live.js.map +1 -1
  122. package/src/lib/runtime/ai-palette.d.ts +3 -1
  123. package/src/lib/runtime/ai-palette.generated.js +498 -10
  124. package/src/lib/runtime/ai-palette.generated.js.map +1 -1
  125. package/src/lib/runtime/ai-palette.js +5 -3
  126. package/src/lib/runtime/ai-palette.js.map +1 -1
  127. package/src/lib/runtime/ai-template-examples.js +8 -2
  128. package/src/lib/runtime/ai-template-examples.js.map +1 -1
  129. package/src/lib/server.js +8 -0
  130. package/src/lib/server.js.map +1 -1
@@ -0,0 +1,184 @@
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 { dropPluginSiteCache } from '@aglyn/aglyn/plugin-manager/plugin-site-cache';
18
+ import type { PluginAiCapabilityArgsSchema } from '@aglyn/aglyn/plugin-manager/plugin-ai-capabilities';
19
+ import { getLockdownVerdict } from '@aglyn/tenant-data-admin/server/lockdown';
20
+ import { resolveOrgIdForHost } from '@aglyn/tenant-data-admin/server/organizations';
21
+ import { type Firestore } from 'firebase-admin/firestore';
22
+ import { type AiJobAdmission } from './ai-job-admission';
23
+ import type { AiJobStepRunner } from './ai-job-text-step';
24
+ /**
25
+ * The `tracking` step (AGL-3751): the site's analytics and advertising tags,
26
+ * as the console's Setup → Tracking card sets them — Google Analytics, Google
27
+ * Tag Manager, and the Meta, Google Ads, LinkedIn, TikTok and Pinterest tags —
28
+ * as a first-class build operation, so "connect Google Analytics G-4R7KX2PQ9Z"
29
+ * is one item on Assist's plan card.
30
+ *
31
+ * NO MODEL. The planner already wrote the ids as the item's arguments; this
32
+ * holds each to the pattern the card's field (and the tenant's loader) holds
33
+ * it to and writes it, so it costs no credits.
34
+ *
35
+ * ── Only the card's own fields, and only public ids ──────────────────────
36
+ *
37
+ * Every field written is one the Tracking card writes, under the same name:
38
+ * `analytics.gaMeasurementId`, `analytics.gtmContainerId` and
39
+ * `analytics.adTags.{meta,google-ads,linkedin,tiktok,pinterest}`, each tested
40
+ * by the same expression (`GA_MEASUREMENT_ID_PATTERN` and its siblings in
41
+ * `visitor-consent.ts`). Each is an id that is printed in every page's HTML
42
+ * anyway, never a credential. Removing one deletes the field, as the card's
43
+ * cleared box does (`CLEARABLE_TRACKING_PATHS`).
44
+ *
45
+ * NEVER: the consent banner (`consent.*` — turning it off, its mode, or the
46
+ * advertising question), search indexing, verification tokens, and anything
47
+ * that needs a secret the person pastes — the Ad conversions card's access
48
+ * tokens, Zapier, order webhooks' signing secrets. Those are not arguments.
49
+ * The tags load only where the consent banner lets them, exactly as a tag the
50
+ * card saved does: the tenant gates on the stored ids, not on who wrote them.
51
+ *
52
+ * ── Live on confirm, who may, idempotent ─────────────────────────────────
53
+ *
54
+ * As the `settings` step (AGL-3748): a tag has no draft, so the plan card's
55
+ * confirm is the agreement and the write is live. One transaction re-reads
56
+ * the host, re-checks the role, writes only what differs with a site-wide
57
+ * publish outbox entry, and the site's cached pages are dropped after. The
58
+ * gate is the Firestore rules' for the host document (`canWriteHostContent`,
59
+ * `hostWritesFrozen`): an admin, editor or author, while no lockdown freezes
60
+ * the site, its org or the platform.
61
+ */
62
+ export declare const AI_TRACKING_KIND: "tracking";
63
+ /** ASSUMED: the least time the step needs — the site, the org and one transaction. */
64
+ export declare const AI_JOB_TRACKING_STEP_MINIMUM_MS = 5000;
65
+ export declare const AI_TRACKING_NO_SITE_COPY = "Open the site whose tracking should change.";
66
+ export declare const AI_TRACKING_ROLE_COPY = "Changing the site\u2019s tracking needs the admin, editor or author role on this site.";
67
+ export declare const AI_TRACKING_LOCKED_COPY = "This site is not accepting changes right now.";
68
+ export declare const AI_TRACKING_NOTHING_COPY = "The request named no tracking id this could set or remove.";
69
+ /** Where a person finds what the op changed: the card that edits it. */
70
+ export declare const AI_TRACKING_WHERE = "Setup \u2192 Tracking";
71
+ /** The output's fixed id: one site's tracking, whatever changed. */
72
+ export declare const AI_TRACKING_OUTPUT_ID = "tracking";
73
+ /** One tag the card sets: its argument, its stored field, its name, and its pattern. */
74
+ export interface AiTrackingTag {
75
+ arg: string;
76
+ path: string;
77
+ label: string;
78
+ pattern: RegExp;
79
+ /** What the card's field says the id looks like. */
80
+ shape: string;
81
+ /** Asked when a request names this tag and no usable id, from the card's helper text. */
82
+ ask: string;
83
+ /** Words that name this tag in an item's name. */
84
+ named: RegExp;
85
+ }
86
+ /** The Tracking card's fields, in its order (`trackingSchema`, host-settings-scope.tsx). */
87
+ export declare const AI_TRACKING_TAGS: readonly AiTrackingTag[];
88
+ /** Asked when an item names no tag at all. */
89
+ export declare const AI_TRACKING_WHICH_COPY = "Which tag should be connected, and what is its ID? Google Analytics, Google Tag Manager, the Meta pixel, Google Ads, LinkedIn, TikTok or Pinterest.";
90
+ /** The item's arguments, as the planner fills them in. Every one optional. */
91
+ export declare const AI_TRACKING_ARGS_SCHEMA: PluginAiCapabilityArgsSchema;
92
+ /** What an item asks: ids to set by field, and fields to clear. */
93
+ export interface AiTrackingRequest {
94
+ set: Record<string, string>;
95
+ remove: string[];
96
+ }
97
+ export interface AiTrackingRead {
98
+ request: AiTrackingRequest;
99
+ /** A sentence per value that could not be used, so the rest still are. */
100
+ problems: string[];
101
+ }
102
+ /** The item's arguments read: what may be written, and a sentence for each that may not. */
103
+ export declare function aiTrackingRequestOf(inputs: Readonly<Record<string, unknown>> | null | undefined): AiTrackingRead;
104
+ /**
105
+ * The question a planned tracking change asks the person, or `null` when it
106
+ * sets or removes something (AGL-3751). An item with no usable id — the
107
+ * planner kept "add my Meta pixel" with no id, or an id of the wrong shape —
108
+ * is never built: it asks for the id of the tag its arguments or its name
109
+ * name, in the card's own words, and says why an id given was not one.
110
+ */
111
+ export declare function aiTrackingMissingInput(item: {
112
+ name?: string;
113
+ why?: string;
114
+ args: Readonly<Record<string, unknown>>;
115
+ }): string | null;
116
+ /** Whether a read request asks for anything at all. */
117
+ export declare function aiTrackingRequestEmpty(request: AiTrackingRequest): boolean;
118
+ /** One change to the host document, with the sentence that says it was made. */
119
+ export interface AiTrackingChange {
120
+ path: string;
121
+ /** The id to store, or `null` to delete the field. */
122
+ value: string | null;
123
+ said: string;
124
+ }
125
+ /** Every change the request asks, in the card's order, before comparing with what is stored. */
126
+ export declare function aiTrackingChanges(request: AiTrackingRequest): AiTrackingChange[];
127
+ /**
128
+ * What the person should know about the tags the site now carries, in the
129
+ * card's own words: where the consent banner is off, nothing of ours gates
130
+ * them; and a container beside a direct Google tag counts everything twice.
131
+ */
132
+ export declare function aiTrackingWarnings(host: Record<string, unknown>): string[];
133
+ export type AiTrackingWrite = {
134
+ ok: true;
135
+ done: string[];
136
+ changed: string[];
137
+ warnings: string[];
138
+ outboxId: string | null;
139
+ } | {
140
+ ok: false;
141
+ error: string;
142
+ };
143
+ /**
144
+ * The tags written, in one transaction that reads the host as it is stored
145
+ * NOW: the member still holds a write role, and only the values that differ
146
+ * from what is stored are written, with a site-wide publish outbox entry
147
+ * beside them so the live site's cached pages are dropped.
148
+ */
149
+ export declare function writeAiSiteTracking(firestore: Firestore, input: {
150
+ hostId: string;
151
+ uid: string;
152
+ request: AiTrackingRequest;
153
+ now: Date;
154
+ }): Promise<AiTrackingWrite>;
155
+ /** Why this member may not change this site's tracking now, or `null`. */
156
+ export declare function aiTrackingAccessRefusal(input: {
157
+ host: FirebaseFirestore.DocumentSnapshot;
158
+ uid: string;
159
+ org: object | null;
160
+ }, deps?: {
161
+ lockdown?: typeof getLockdownVerdict;
162
+ }): Promise<string | null>;
163
+ /** The output's note: what changed, that it is live, how consent gates it, and what was not done. */
164
+ export declare function aiTrackingOutputNote(done: readonly string[], warnings: readonly string[], notDone: readonly string[], changedAny: boolean): string;
165
+ export interface AiJobTrackingStepDeps {
166
+ write?: typeof writeAiSiteTracking;
167
+ lockdown?: typeof getLockdownVerdict;
168
+ dropCache?: typeof dropPluginSiteCache;
169
+ }
170
+ export declare function createAiJobTrackingStep(deps?: AiJobTrackingStepDeps): AiJobStepRunner;
171
+ export declare const runAiJobTrackingStep: AiJobStepRunner;
172
+ export interface AiTrackingJobAdmissionDeps {
173
+ ownerOf?: typeof resolveOrgIdForHost;
174
+ lockdown?: typeof getLockdownVerdict;
175
+ }
176
+ /**
177
+ * A tracking change is admitted on a site of the job's own org, for a member
178
+ * who may write its settings now, where the request names at least one tag
179
+ * this can set or remove. Refused in those words before anything is written.
180
+ */
181
+ export declare function createAiTrackingJobAdmission(deps?: AiTrackingJobAdmissionDeps): AiJobAdmission;
182
+ export declare const aiTrackingJobAdmission: AiJobAdmission;
183
+ /** Registers the tracking step and its door (AGL-3751). */
184
+ export declare function registerAiTrackingJob(): void;