@aglyn/plugins-ai 1.0.0-beta.228 → 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-jobs-list-page.component.js +12 -1
- package/src/lib/components/ai-jobs-list-page.component.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.d.ts +1 -1
- package/src/lib/components/ai-site-build-page.component.js +177 -20
- package/src/lib/components/ai-site-build-page.component.js.map +1 -1
- package/src/lib/components/ai-site-start-card.component.d.ts +10 -1
- package/src/lib/components/ai-site-start-card.component.js +7 -4
- package/src/lib/components/ai-site-start-card.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.d.ts +11 -0
- package/src/lib/components/assist-jobs-drawer.component.js +85 -4
- 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-layout-site-pages.d.ts +70 -0
- package/src/lib/jobs/ai-job-layout-site-pages.js +216 -0
- package/src/lib/jobs/ai-job-layout-site-pages.js.map +1 -0
- package/src/lib/jobs/ai-job-layout-step.d.ts +2 -2
- package/src/lib/jobs/ai-job-layout-step.js +19 -1
- package/src/lib/jobs/ai-job-layout-step.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 +207 -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 +90 -2
- package/src/lib/jobs/ai-jobs.js +495 -61
- 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-job-failure-copy.d.ts +20 -1
- package/src/lib/model/ai-job-failure-copy.js +28 -1
- package/src/lib/model/ai-job-failure-copy.js.map +1 -1
- package/src/lib/model/ai-job-notice.d.ts +3 -0
- package/src/lib/model/ai-job-notice.js +11 -2
- package/src/lib/model/ai-job-notice.js.map +1 -1
- package/src/lib/model/ai-jobs.types.d.ts +87 -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 +28 -3
- package/src/lib/model/ai-site-build-progress.js +231 -17
- package/src/lib/model/ai-site-build-progress.js.map +1 -1
- package/src/lib/model/ai-site-start-seo.d.ts +16 -0
- package/src/lib/model/ai-site-start-seo.js +54 -4
- package/src/lib/model/ai-site-start-seo.js.map +1 -1
- package/src/lib/model/ai-site-start.d.ts +14 -0
- package/src/lib/model/ai-site-start.js +43 -0
- package/src/lib/model/ai-site-start.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.d.ts +6 -0
- package/src/lib/runtime/ai-doctrine.js +16 -6
- 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 +31 -3
- package/src/lib/usage/assist-job-refund.js +46 -10
- 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
|
@@ -31,6 +31,8 @@ import { docsGroundingBlock, retrieveDocsSections } from "@aglyn/aglyn/app-utils
|
|
|
31
31
|
import { composeDocsLinksAnswer, deflectToDocs, questionStandsAlone, sectionLabel, sectionUrl } from "@aglyn/aglyn/app-utils/docs-deflection";
|
|
32
32
|
import { ASSIST_EDIT_TOOL_NAME, assistEditDocumentOf } from "../model/assist-edit.js";
|
|
33
33
|
import { ASSIST_EDIT_MAX_OUTPUT_TOKENS, assistEditTool, editCanvasBlock, editSelectionBlock, parseAssistEditContext, resolveAssistEdit } from "./assist-edit.js";
|
|
34
|
+
import { ASSIST_BUILD_TOOL_NAME } from "../model/assist-build.js";
|
|
35
|
+
import { assistBuildBlock, assistBuildIntents, assistBuildIntentsBlock, assistBuildTool, resolveAssistBuild } from "./assist-build.js";
|
|
34
36
|
import { describeView, extractAssistAction, finalAssistText, resolveAssistProposal, safeOrgFacts, sanitiseId, sanitiseRoute, viewFactsBlock, viewScreenBlock, visibleAssistText } from "./assist-view-context.js";
|
|
35
37
|
import { invalidIdTokenResponse } from "@aglyn/tenant-data-admin/server/id-token-refusal";
|
|
36
38
|
// By its own entry point rather than the barrel (AGL-2903), for the reason
|
|
@@ -519,6 +521,56 @@ ${AI_ACCEPTABLE_USE_BLOCK}`;
|
|
|
519
521
|
context
|
|
520
522
|
};
|
|
521
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* Whether this turn may PROPOSE a build (AGL-3616) — one request turned into
|
|
526
|
+
* one `build` job whose plan card the person confirms — and on which site,
|
|
527
|
+
* or null and the turn is answered as it would be without one.
|
|
528
|
+
*
|
|
529
|
+
* The gates are the generation doors' own, as the edit rung's: the org's
|
|
530
|
+
* `aiGenerative`, `release_ai_generative` (staff preview), the caller's
|
|
531
|
+
* `ai.generate` on the site the page named, and the `ai-generate` switch.
|
|
532
|
+
* No canvas is needed: a build is asked from anywhere on a site. Last, a
|
|
533
|
+
* deployment that loaded the build kind and a site where some operation
|
|
534
|
+
* passes its owner's gates, which is also what the model is told it may
|
|
535
|
+
* offer. The job door checks every one of these again when the panel starts
|
|
536
|
+
* the job; this rung only decides whether the model may propose it.
|
|
537
|
+
*/ async function assistBuildRung(input) {
|
|
538
|
+
var _ref;
|
|
539
|
+
var _body_context;
|
|
540
|
+
const { body, org, staff } = input;
|
|
541
|
+
const hostId = sanitiseId((_ref = (_body_context = body.context) == null ? void 0 : _body_context.hostId) != null ? _ref : '');
|
|
542
|
+
if (!hostId) return null;
|
|
543
|
+
if (!checkEntitlement(org, 'aiGenerative')) return null;
|
|
544
|
+
if (!staff && !await isServerReleaseFlagOnForOrg('release_ai_generative', body.orgId)) {
|
|
545
|
+
return null;
|
|
546
|
+
}
|
|
547
|
+
if (!staff && !await memberHasPermissionOnHost(body.orgId, hostId, input.member, 'ai.generate')) {
|
|
548
|
+
return null;
|
|
549
|
+
}
|
|
550
|
+
if (await featureLockdownRefusal({
|
|
551
|
+
feature: 'ai-generate',
|
|
552
|
+
staff,
|
|
553
|
+
orgId: body.orgId
|
|
554
|
+
})) {
|
|
555
|
+
return null;
|
|
556
|
+
}
|
|
557
|
+
const intents = await assistBuildIntents(input.firestore, {
|
|
558
|
+
orgId: body.orgId,
|
|
559
|
+
hostId,
|
|
560
|
+
org
|
|
561
|
+
}).catch((error)=>{
|
|
562
|
+
// A rung that cannot be decided stays closed: the chat still answers.
|
|
563
|
+
console.error('assist build rung failed', {
|
|
564
|
+
orgId: body.orgId,
|
|
565
|
+
error
|
|
566
|
+
});
|
|
567
|
+
return null;
|
|
568
|
+
});
|
|
569
|
+
return intents ? {
|
|
570
|
+
hostId,
|
|
571
|
+
intents
|
|
572
|
+
} : null;
|
|
573
|
+
}
|
|
522
574
|
/**
|
|
523
575
|
* The level-2 view block (entitled orgs only) and the scope the proposal
|
|
524
576
|
* channel resolves against.
|
|
@@ -824,6 +876,15 @@ async function handler(request) {
|
|
|
824
876
|
staff,
|
|
825
877
|
member: resolved.member
|
|
826
878
|
});
|
|
879
|
+
// The build rung (AGL-3616), decided beside the edit rung for the same
|
|
880
|
+
// reason: a request to make things is not a question the docs answer.
|
|
881
|
+
const buildRung = await assistBuildRung({
|
|
882
|
+
body,
|
|
883
|
+
org: org,
|
|
884
|
+
staff,
|
|
885
|
+
member: resolved.member,
|
|
886
|
+
firestore
|
|
887
|
+
});
|
|
827
888
|
// ── Retrieval FIRST (AGL-2486) ────────────────────────────────────────
|
|
828
889
|
// Level-1 grounding for everyone. Hoisted above the reservation and the
|
|
829
890
|
// model call because it is now a candidate ANSWER, not only a prompt
|
|
@@ -843,7 +904,7 @@ async function handler(request) {
|
|
|
843
904
|
// from the docs there. `questionStandsAlone` is the deflector's own test
|
|
844
905
|
// for a question that needs nothing around it, and the open canvas is
|
|
845
906
|
// exactly what an edit request leans on.
|
|
846
|
-
const deflection = editRung && !questionStandsAlone(body.question) ? null : deflectToDocs(body.question, scored, body.history.length > 0);
|
|
907
|
+
const deflection = (editRung || buildRung) && !questionStandsAlone(body.question) ? null : deflectToDocs(body.question, scored, body.history.length > 0);
|
|
847
908
|
if (deflection == null ? void 0 : deflection.answered) {
|
|
848
909
|
var _ref4;
|
|
849
910
|
var _body_context4, _body_context5;
|
|
@@ -946,7 +1007,7 @@ async function handler(request) {
|
|
|
946
1007
|
// was written by whichever model Auto chose. Nor does a turn on the edit
|
|
947
1008
|
// rung (AGL-2906): that answer is composed against the canvas the request
|
|
948
1009
|
// described, which the key cannot describe either.
|
|
949
|
-
const cacheKey = body.history.length || body.model || editRung ? '' : assistAnswerCacheKey({
|
|
1010
|
+
const cacheKey = body.history.length || body.model || editRung || buildRung ? '' : assistAnswerCacheKey({
|
|
950
1011
|
question: body.question,
|
|
951
1012
|
tier: entitled ? 'entitled' : 'free',
|
|
952
1013
|
route: (_ref = (_body_context2 = body.context) == null ? void 0 : _body_context2.route) != null ? _ref : '',
|
|
@@ -1133,6 +1194,13 @@ async function handler(request) {
|
|
|
1133
1194
|
cacheBreakpoint: true
|
|
1134
1195
|
}
|
|
1135
1196
|
] : [],
|
|
1197
|
+
// The build protocol (AGL-3616): the same for every site, so cached.
|
|
1198
|
+
...buildRung ? [
|
|
1199
|
+
{
|
|
1200
|
+
text: assistBuildBlock(),
|
|
1201
|
+
cacheBreakpoint: true
|
|
1202
|
+
}
|
|
1203
|
+
] : [],
|
|
1136
1204
|
// Per-org, and therefore AFTER every breakpoint — see
|
|
1137
1205
|
// `assistBrandBlock`. Unconditional: a free workspace assembles no
|
|
1138
1206
|
// view block, and it must still be told what the product is called.
|
|
@@ -1153,6 +1221,13 @@ async function handler(request) {
|
|
|
1153
1221
|
volatile: true
|
|
1154
1222
|
}
|
|
1155
1223
|
] : [],
|
|
1224
|
+
// What a build can make on this site: per site, so volatile.
|
|
1225
|
+
...buildRung ? [
|
|
1226
|
+
{
|
|
1227
|
+
text: assistBuildIntentsBlock(buildRung.intents),
|
|
1228
|
+
volatile: true
|
|
1229
|
+
}
|
|
1230
|
+
] : [],
|
|
1156
1231
|
...docsBlock ? [
|
|
1157
1232
|
{
|
|
1158
1233
|
text: docsBlock,
|
|
@@ -1166,11 +1241,17 @@ async function handler(request) {
|
|
|
1166
1241
|
model,
|
|
1167
1242
|
// An edit proposal writes its operations as a tool call, which needs
|
|
1168
1243
|
// room an answer does not.
|
|
1169
|
-
|
|
1244
|
+
// A build's brief is a tool call too, restating the whole request.
|
|
1245
|
+
maxTokens: editRung || buildRung ? ASSIST_EDIT_MAX_OUTPUT_TOKENS : MAX_OUTPUT_TOKENS,
|
|
1170
1246
|
stream: true
|
|
1171
|
-
}, editRung ? {
|
|
1247
|
+
}, editRung || buildRung ? {
|
|
1172
1248
|
tools: [
|
|
1173
|
-
|
|
1249
|
+
...editRung ? [
|
|
1250
|
+
assistEditTool(editRung.target.kind)
|
|
1251
|
+
] : [],
|
|
1252
|
+
...buildRung ? [
|
|
1253
|
+
assistBuildTool()
|
|
1254
|
+
] : []
|
|
1174
1255
|
]
|
|
1175
1256
|
} : {}, CHAT_ROUTE.thinking ? {
|
|
1176
1257
|
thinking: CHAT_ROUTE.thinking
|
|
@@ -1213,6 +1294,7 @@ async function handler(request) {
|
|
|
1213
1294
|
let emitted = 0;
|
|
1214
1295
|
let stopReason = null;
|
|
1215
1296
|
/** The first call of the edit tool, as the stream delivered it. */ let editInput = null;
|
|
1297
|
+
/** The first call of the build tool (AGL-3616). */ let buildInput = null;
|
|
1216
1298
|
/**
|
|
1217
1299
|
* What the model wrote into its tool calls, when the stream stopped
|
|
1218
1300
|
* at its ceiling (AGL-3143). Held here only long enough to be
|
|
@@ -1226,7 +1308,8 @@ async function handler(request) {
|
|
|
1226
1308
|
cacheWriteTokens: 0
|
|
1227
1309
|
};
|
|
1228
1310
|
try {
|
|
1229
|
-
var _ref;
|
|
1311
|
+
var _ref, _ref1, _ref2, _ref3;
|
|
1312
|
+
var _guide_view, _describeView, _body_context;
|
|
1230
1313
|
for await (const event of upstream){
|
|
1231
1314
|
if (event.type === 'delta') {
|
|
1232
1315
|
raw += event.text;
|
|
@@ -1251,6 +1334,9 @@ async function handler(request) {
|
|
|
1251
1334
|
if (editRung && !editInput && event.name === ASSIST_EDIT_TOOL_NAME) {
|
|
1252
1335
|
editInput = event.input;
|
|
1253
1336
|
}
|
|
1337
|
+
if (buildRung && !buildInput && event.name === ASSIST_BUILD_TOOL_NAME) {
|
|
1338
|
+
buildInput = event.input;
|
|
1339
|
+
}
|
|
1254
1340
|
} else if (event.type === 'done') {
|
|
1255
1341
|
var _event_rawOutput;
|
|
1256
1342
|
usage = event.usage;
|
|
@@ -1295,6 +1381,13 @@ async function handler(request) {
|
|
|
1295
1381
|
});
|
|
1296
1382
|
}
|
|
1297
1383
|
}
|
|
1384
|
+
// The build proposal (AGL-3616): the request, held to the site the
|
|
1385
|
+
// turn was asked on. Still nothing is made: the panel starts a
|
|
1386
|
+
// build job whose plan the person confirms.
|
|
1387
|
+
const build = buildRung && stopReason !== 'max_tokens' ? resolveAssistBuild(buildInput, {
|
|
1388
|
+
hostId: buildRung.hostId,
|
|
1389
|
+
screen: (_ref = (_ref1 = guide == null ? void 0 : (_guide_view = guide.view) == null ? void 0 : _guide_view.screen) != null ? _ref1 : (_describeView = describeView(sanitiseRoute((_ref2 = (_body_context = body.context) == null ? void 0 : _body_context.route) != null ? _ref2 : ''))) == null ? void 0 : _describeView.screen) != null ? _ref : null
|
|
1390
|
+
}) : null;
|
|
1298
1391
|
// A refusal is an HTTP 200 with an empty or partial answer, not an
|
|
1299
1392
|
// error — so without this the user watches the spinner stop and
|
|
1300
1393
|
// gets nothing back. Truncation is the same shape: the tokens are
|
|
@@ -1333,14 +1426,14 @@ async function handler(request) {
|
|
|
1333
1426
|
// tokens were spent either way and the miner wants the question.
|
|
1334
1427
|
let exchangeId = null;
|
|
1335
1428
|
try {
|
|
1336
|
-
var
|
|
1337
|
-
var
|
|
1429
|
+
var _ref4;
|
|
1430
|
+
var _body_context1, _body_context2;
|
|
1338
1431
|
exchangeId = await recordAssistExchange(firestore, body.orgId, _extends({
|
|
1339
1432
|
uid: decoded.uid,
|
|
1340
1433
|
question: body.question,
|
|
1341
1434
|
answer: answer.slice(0, MAX_STORED_ANSWER_CHARS),
|
|
1342
|
-
route: (
|
|
1343
|
-
hostId: ((
|
|
1435
|
+
route: (_ref4 = (_body_context1 = body.context) == null ? void 0 : _body_context1.route) != null ? _ref4 : '',
|
|
1436
|
+
hostId: ((_body_context2 = body.context) == null ? void 0 : _body_context2.hostId) || null,
|
|
1344
1437
|
model,
|
|
1345
1438
|
tier,
|
|
1346
1439
|
usage,
|
|
@@ -1372,7 +1465,7 @@ async function handler(request) {
|
|
|
1372
1465
|
// - an answer from a model other than the one the key names — an
|
|
1373
1466
|
// allowlist moved Auto (AGL-2942) — would be served to readers
|
|
1374
1467
|
// the list does not bind.
|
|
1375
|
-
if (cacheKey && answer && !proposal && stopReason !== 'refusal' && stopReason !== 'max_tokens' && model === assistModel()) {
|
|
1468
|
+
if (cacheKey && answer && !proposal && !build && stopReason !== 'refusal' && stopReason !== 'max_tokens' && model === assistModel()) {
|
|
1376
1469
|
await writeAssistAnswerCache(firestore, body.orgId, cacheKey, {
|
|
1377
1470
|
answer,
|
|
1378
1471
|
docs
|
|
@@ -1390,6 +1483,9 @@ async function handler(request) {
|
|
|
1390
1483
|
// The edit proposal (AGL-2906): ops the panel applies in the
|
|
1391
1484
|
// author's editor when they press Apply, and never before.
|
|
1392
1485
|
edit,
|
|
1486
|
+
// The build proposal (AGL-3616): the panel starts its job and
|
|
1487
|
+
// shows the plan card; nothing is built before it is confirmed.
|
|
1488
|
+
build,
|
|
1393
1489
|
// The reservation VERBATIM (AGL-2238). It already describes the
|
|
1394
1490
|
// standing after the message, because it is what moved the
|
|
1395
1491
|
// counter — `reserveAssistMessage` returns `used + 1` and
|
|
@@ -1406,7 +1502,7 @@ async function handler(request) {
|
|
|
1406
1502
|
lastCredits: assistCreditsFromUsd(estimateAssistCostUsd(usage, model)),
|
|
1407
1503
|
model: {
|
|
1408
1504
|
id: model,
|
|
1409
|
-
auto: (
|
|
1505
|
+
auto: (_ref3 = choice == null ? void 0 : choice.auto) != null ? _ref3 : true
|
|
1410
1506
|
}
|
|
1411
1507
|
})
|
|
1412
1508
|
});
|