@circuitwall/jarela 2.5.1 → 2.5.2
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/.next/standalone/.next/BUILD_ID +1 -1
- package/.next/standalone/.next/app-path-routes-manifest.json +5 -5
- package/.next/standalone/.next/build-manifest.json +2 -2
- package/.next/standalone/.next/prerender-manifest.json +3 -3
- package/.next/standalone/.next/react-loadable-manifest.json +2 -2
- package/.next/standalone/.next/server/app/_global-error/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_global-error.html +1 -1
- package/.next/standalone/.next/server/app/_global-error.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/_not-found.html +1 -1
- package/.next/standalone/.next/server/app/_not-found.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/chats/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/lookup/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/pair/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/bridges/[id]/status/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/builtin-tools/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/credentials/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/credentials/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/credentials/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/dashboard/pricing-task/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/delegations/codex/[job_id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/reindex/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/documents/sources/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/documents/sources/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/events/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/events/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extension/agents/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extension/fill/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extension/refine/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extension/turn/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/config/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/extensions/tools/[name]/secrets/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/health/probes/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/health/probes/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/integrations/[name]/test/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/callback/route.js +22 -1
- package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/start/route.js +22 -1
- package/.next/standalone/.next/server/app/api/v1/integrations/gmail/oauth/status/route.js +22 -1
- package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/callback/route.js +19 -2
- package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/start/route.js +19 -2
- package/.next/standalone/.next/server/app/api/v1/integrations/outlook/oauth/status/route.js +19 -2
- package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js +12 -2
- package/.next/standalone/.next/server/app/api/v1/packages/defaults/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/packages/install/[id]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/install/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/packages/install/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/enabled/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/[name]/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/packages/manifests/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js +12 -2
- package/.next/standalone/.next/server/app/api/v1/packages/reload/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/packages/route.js +12 -2
- package/.next/standalone/.next/server/app/api/v1/packages/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/page-capture/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/page-capture/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/approve/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/pending-actions/[id]/deny/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/pending-actions/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/scheduled-tasks/[id]/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/system/restart/route.js +7 -0
- package/.next/standalone/.next/server/app/api/v1/system/restart/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js +52 -45
- package/.next/standalone/.next/server/app/api/v1/threads/[thread_id]/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/tools/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/tools/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/update/apply/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/watchers/[id]/run/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/api/v1/watchers/route.js +8 -1
- package/.next/standalone/.next/server/app/api/v1/watchers/route.js.nft.json +1 -1
- package/.next/standalone/.next/server/app/page.js +72982 -72980
- package/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app/setup/page_client-reference-manifest.js +1 -1
- package/.next/standalone/.next/server/app-paths-manifest.json +5 -5
- package/.next/standalone/.next/server/chunks/1433.js +1 -1
- package/.next/standalone/.next/server/chunks/210.js +6 -6
- package/.next/standalone/.next/server/chunks/2471.js +17 -17
- package/.next/standalone/.next/server/chunks/3524.js +31 -15
- package/.next/standalone/.next/server/chunks/3566.js +1 -1
- package/.next/standalone/.next/server/chunks/4189.js +1 -1
- package/.next/standalone/.next/server/chunks/{9590.js → 423.js} +10 -3
- package/.next/standalone/.next/server/chunks/4508.js +2 -2
- package/.next/standalone/.next/server/chunks/4596.js +5 -2
- package/.next/standalone/.next/server/chunks/46.js +7 -0
- package/.next/standalone/.next/server/chunks/540.js +29 -5
- package/.next/standalone/.next/server/chunks/5585.js +41 -3
- package/.next/standalone/.next/server/chunks/5908.js +10 -10
- package/.next/standalone/.next/server/chunks/{3399.js → 6058.js} +882 -400
- package/.next/standalone/.next/server/chunks/{9164.js → 6190.js} +13777 -13530
- package/.next/standalone/.next/server/chunks/6649.js +1 -1
- package/.next/standalone/.next/server/chunks/{1388.js → 8842.js} +5961 -5793
- package/.next/standalone/.next/server/chunks/9032.js +5 -5
- package/.next/standalone/.next/server/chunks/{7547.js → 9217.js} +485 -3
- package/.next/standalone/.next/server/instrumentation.js +7 -0
- package/.next/standalone/.next/server/middleware-build-manifest.js +2 -2
- package/.next/standalone/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/standalone/.next/server/middleware.js +7 -0
- package/.next/standalone/.next/server/pages/404.html +1 -1
- package/.next/standalone/.next/server/pages/500.html +1 -1
- package/.next/standalone/.next/server/preview-props.json +3 -3
- package/.next/standalone/.next/server/server-reference-manifest.json +1 -1
- package/.next/standalone/.next/static/chunks/app/{page-dd05bcb5f5b81157.js → page-4112e14360a9909e.js} +1576 -1574
- package/.next/standalone/docs/adoption/changesets.json +139 -0
- package/.next/standalone/package.json +2 -1
- package/CHANGELOG.md +38 -0
- package/browser-extension/background.js +5 -539
- package/browser-extension/lib/form-editing.mjs +541 -0
- package/components/chat/MessageBubble.tsx +4 -736
- package/components/chat/MessageContent.tsx +749 -0
- package/components/layout/MenuPanel.tsx +1 -1
- package/hooks/useSSE.test.ts +46 -0
- package/lib/agents/llm.ts +1 -1
- package/lib/agents/output-validator/validator.test.ts +4 -0
- package/lib/agents/output-validator/validator.ts +1 -1
- package/lib/agents/prompt-registry.test.ts +11 -0
- package/lib/agents/prompt-registry.ts +13 -0
- package/lib/agents/retry-prompts.ts +17 -0
- package/lib/agents/run-retry.ts +671 -0
- package/lib/agents/run-thread.retry.test.ts +176 -2
- package/lib/agents/run-thread.test.ts +6 -6
- package/lib/agents/run-thread.ts +9 -717
- package/lib/agents/stream-collector.test.ts +28 -4
- package/lib/agents/stream-collector.ts +5 -28
- package/lib/agents/tool-outcomes.ts +61 -0
- package/lib/documents/remote/confluence.test.ts +65 -0
- package/lib/documents/remote/confluence.ts +35 -9
- package/lib/documents/remote/jira.ts +1 -1
- package/lib/health/probes.test.ts +32 -0
- package/lib/health/probes.ts +29 -14
- package/lib/integrations/atlassian/manifest.ts +5 -3
- package/lib/integrations/github/manifest.ts +7 -4
- package/lib/integrations/gmail-oauth.ts +16 -1
- package/lib/integrations/microsoft-oauth.ts +17 -2
- package/lib/integrations/outlook/manifest.ts +10 -8
- package/lib/stores/integrations.ts +1 -0
- package/lib/tools/communications/calendar-aliases.test.ts +77 -1
- package/lib/tools/communications/gmail.test.ts +13 -0
- package/lib/tools/communications/ms-graph.test.ts +26 -3
- package/lib/tools/communications/ms-graph.ts +9 -11
- package/lib/tools/communications/outlook-calendar.ts +94 -17
- package/lib/tools/packages/default-packages/atlassian.ts +8 -2
- package/package.json +2 -1
- package/scripts/standalone-footprint.mjs +1 -1
- /package/.next/standalone/.next/static/{XFZTDssHBZKKX2mzH2ld0 → VZXMorlOmSmi3dUr7K5UX}/_buildManifest.js +0 -0
- /package/.next/standalone/.next/static/{XFZTDssHBZKKX2mzH2ld0 → VZXMorlOmSmi3dUr7K5UX}/_ssgManifest.js +0 -0
|
@@ -5,47 +5,15 @@
|
|
|
5
5
|
// and updates the action icon + tooltip accordingly. State lives in a
|
|
6
6
|
// SW-local var; if the SW is killed mid-cycle the next alarm tick simply
|
|
7
7
|
// re-evaluates from a fresh fetch.
|
|
8
|
-
|
|
9
|
-
import {
|
|
10
|
-
STORAGE_KEY,
|
|
11
|
-
SELECTED_AGENT_STORAGE_KEY,
|
|
12
|
-
DEFAULT_CONFIG,
|
|
13
|
-
parseConfig,
|
|
14
|
-
healthUrl,
|
|
15
|
-
captureUrl,
|
|
16
|
-
extensionRefineUrl,
|
|
17
|
-
extensionFillUrl,
|
|
18
|
-
extensionTurnUrl,
|
|
19
|
-
extensionAgentsUrl,
|
|
20
|
-
allowedSitesUrl,
|
|
21
|
-
allowedSiteHostUrl,
|
|
22
|
-
browserPollUrl,
|
|
23
|
-
browserResultUrl,
|
|
24
|
-
browserProgressUrl,
|
|
25
|
-
browserForegroundUrl,
|
|
26
|
-
buildBase,
|
|
27
|
-
} from "./lib/config.mjs";
|
|
8
|
+
import { STORAGE_KEY, SELECTED_AGENT_STORAGE_KEY, DEFAULT_CONFIG, parseConfig, healthUrl, captureUrl, extensionRefineUrl, extensionFillUrl, extensionTurnUrl, extensionAgentsUrl, allowedSitesUrl, allowedSiteHostUrl, browserPollUrl, browserResultUrl, browserProgressUrl, browserForegroundUrl, buildBase } from "./lib/config.mjs";
|
|
28
9
|
import { BRAND } from "./lib/brand.mjs";
|
|
29
10
|
import { dispatchCommand } from "./lib/browser-control.mjs";
|
|
30
11
|
import { gateCommand, setApproval } from "./lib/approvals.mjs";
|
|
31
12
|
import { classifyCommandRisk } from "./lib/command-risk.mjs";
|
|
32
|
-
import {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
clearPinnedTab,
|
|
37
|
-
isUsableUrl,
|
|
38
|
-
} from "./lib/tab-target.mjs";
|
|
39
|
-
import {
|
|
40
|
-
getForegroundTab,
|
|
41
|
-
buildForegroundPushPayload,
|
|
42
|
-
handleTabActivated as handleTabActivatedFg,
|
|
43
|
-
handleTabUpdated as handleTabUpdatedFg,
|
|
44
|
-
handleWindowFocused as handleWindowFocusedFg,
|
|
45
|
-
handleTabRemoved as handleTabRemovedFg,
|
|
46
|
-
seedForegroundTab,
|
|
47
|
-
recordSidePanelCurrentTab,
|
|
48
|
-
} from "./lib/foreground-tab.mjs";
|
|
13
|
+
import { resolveTargetTab as resolveTargetTabPure, getPinnedTab, setPinnedTab, clearPinnedTab, isUsableUrl } from "./lib/tab-target.mjs";
|
|
14
|
+
import { getForegroundTab, buildForegroundPushPayload, handleTabActivated as handleTabActivatedFg, handleTabUpdated as handleTabUpdatedFg, handleWindowFocused as handleWindowFocusedFg, handleTabRemoved as handleTabRemovedFg, seedForegroundTab, recordSidePanelCurrentTab } from "./lib/foreground-tab.mjs";
|
|
15
|
+
|
|
16
|
+
import { copyTextToClipboard, captureField, clearFillTarget, getFillContext, fillFocusedField, showFillSpinner, hideFillSpinner } from "./lib/form-editing.mjs";
|
|
49
17
|
|
|
50
18
|
const ALARM_NAME = "jarela-health";
|
|
51
19
|
const BROWSER_POLL_ALARM_NAME = "jarela-browser-poll";
|
|
@@ -684,508 +652,6 @@ async function collectPageInfo(tabId) {
|
|
|
684
652
|
return result;
|
|
685
653
|
}
|
|
686
654
|
|
|
687
|
-
async function copyTextToClipboard(tabId, text) {
|
|
688
|
-
const [{ result }] = await chrome.scripting.executeScript({
|
|
689
|
-
target: { tabId },
|
|
690
|
-
args: [text],
|
|
691
|
-
func: async (value) => {
|
|
692
|
-
try {
|
|
693
|
-
await navigator.clipboard.writeText(value);
|
|
694
|
-
return { ok: true };
|
|
695
|
-
} catch {
|
|
696
|
-
try {
|
|
697
|
-
const ta = document.createElement("textarea");
|
|
698
|
-
ta.value = value;
|
|
699
|
-
ta.style.position = "fixed";
|
|
700
|
-
ta.style.left = "-9999px";
|
|
701
|
-
ta.style.top = "0";
|
|
702
|
-
document.body.appendChild(ta);
|
|
703
|
-
ta.focus();
|
|
704
|
-
ta.select();
|
|
705
|
-
const copied = document.execCommand("copy");
|
|
706
|
-
ta.remove();
|
|
707
|
-
return { ok: copied };
|
|
708
|
-
} catch {
|
|
709
|
-
return { ok: false };
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
},
|
|
713
|
-
});
|
|
714
|
-
return Boolean(result?.ok);
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
// Unified capture: in one pass per same-origin frame, find the focused
|
|
718
|
-
// editable (and pin it with `data-jarela-fill-target` + dataset offsets
|
|
719
|
-
// so we can restore the caret/selection after the LLM round-trip blurs
|
|
720
|
-
// the field) AND/OR snapshot the current selection text. Returns:
|
|
721
|
-
// { ok, frameId, hasField, original }
|
|
722
|
-
// where `original` is the selected text inside the editable (rewrite
|
|
723
|
-
// mode) or the loose page selection (clipboard mode), and is empty for
|
|
724
|
-
// pure-fill mode (caret-only). Picks the frame with an editable; falls
|
|
725
|
-
// back to the longest selection-only frame.
|
|
726
|
-
async function captureField(tabId) {
|
|
727
|
-
let results;
|
|
728
|
-
try {
|
|
729
|
-
results = await chrome.scripting.executeScript({
|
|
730
|
-
target: { tabId, allFrames: true },
|
|
731
|
-
func: () => {
|
|
732
|
-
function dig(root) {
|
|
733
|
-
let el = root?.activeElement || null;
|
|
734
|
-
while (el && el.shadowRoot && el.shadowRoot.activeElement) {
|
|
735
|
-
el = el.shadowRoot.activeElement;
|
|
736
|
-
}
|
|
737
|
-
return el;
|
|
738
|
-
}
|
|
739
|
-
function isEditable(el) {
|
|
740
|
-
if (!el) return false;
|
|
741
|
-
if (el instanceof HTMLTextAreaElement) return true;
|
|
742
|
-
if (el instanceof HTMLInputElement) return /^(text|search|email|url|tel)$/i.test(el.type || "text");
|
|
743
|
-
return Boolean(el.isContentEditable);
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
const sel = window.getSelection?.();
|
|
747
|
-
const trimmedSelection = (sel?.toString() || "").trim();
|
|
748
|
-
|
|
749
|
-
// Reuse an existing mark if a prior call already pinned the
|
|
750
|
-
// editable in this frame (e.g. the menu has stolen focus).
|
|
751
|
-
let el = document.querySelector("[data-jarela-fill-target]");
|
|
752
|
-
if (!el) {
|
|
753
|
-
el = dig(document);
|
|
754
|
-
if (el && !isEditable(el) && typeof el.closest === "function") {
|
|
755
|
-
const ce = el.closest("[contenteditable=''], [contenteditable='true']");
|
|
756
|
-
if (ce) el = ce;
|
|
757
|
-
}
|
|
758
|
-
if (!isEditable(el)) {
|
|
759
|
-
const dialog = document.querySelector("[role='dialog'], dialog[open]");
|
|
760
|
-
if (dialog) {
|
|
761
|
-
el = dialog.querySelector(
|
|
762
|
-
"textarea, input[type='text'], input[type='search'], input[type='email'], input[type='url'], input[type='tel'], [contenteditable=''], [contenteditable='true']",
|
|
763
|
-
);
|
|
764
|
-
}
|
|
765
|
-
}
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
if (!isEditable(el)) {
|
|
769
|
-
// Selection-only state (no field focused in this frame).
|
|
770
|
-
return trimmedSelection ? { hasField: false, original: trimmedSelection } : null;
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
// Clear stale marks on siblings, then pin this one.
|
|
774
|
-
document.querySelectorAll("[data-jarela-fill-target]").forEach((n) => {
|
|
775
|
-
if (n !== el) {
|
|
776
|
-
n.removeAttribute("data-jarela-fill-target");
|
|
777
|
-
delete n.dataset?.jarelaFillStart;
|
|
778
|
-
delete n.dataset?.jarelaFillEnd;
|
|
779
|
-
delete n.dataset?.jarelaFillCaretOffset;
|
|
780
|
-
delete n.dataset?.jarelaFillCaretEndOffset;
|
|
781
|
-
}
|
|
782
|
-
});
|
|
783
|
-
document.querySelectorAll("[data-jarela-fill-caret]").forEach((n) => n.remove());
|
|
784
|
-
el.setAttribute("data-jarela-fill-target", "1");
|
|
785
|
-
|
|
786
|
-
// Capture range NOW (start..end). For input/textarea: selection
|
|
787
|
-
// indices. For contenteditable: text-offsets from the editable's
|
|
788
|
-
// start, measured via synthetic range so element-node containers
|
|
789
|
-
// (multi-paragraph selections in Gmail/Outlook) work the same as
|
|
790
|
-
// text-node containers. Dataset on the editable root survives
|
|
791
|
-
// framework reconciliation where a marker <span> would be
|
|
792
|
-
// stripped. `original` is empty when the selection is collapsed.
|
|
793
|
-
let original = "";
|
|
794
|
-
if (el instanceof HTMLTextAreaElement || el instanceof HTMLInputElement) {
|
|
795
|
-
const s = Number(el.selectionStart ?? el.value.length);
|
|
796
|
-
const e = Number(el.selectionEnd ?? el.value.length);
|
|
797
|
-
el.dataset.jarelaFillStart = String(s);
|
|
798
|
-
el.dataset.jarelaFillEnd = String(e);
|
|
799
|
-
if (s !== e) original = String(el.value || "").slice(Math.min(s, e), Math.max(s, e));
|
|
800
|
-
} else if (el.isContentEditable) {
|
|
801
|
-
try {
|
|
802
|
-
const doc = el.ownerDocument || document;
|
|
803
|
-
if (sel && sel.rangeCount > 0) {
|
|
804
|
-
const range = sel.getRangeAt(0);
|
|
805
|
-
if (el.contains(range.startContainer) && el.contains(range.endContainer)) {
|
|
806
|
-
function offsetFromStart(container, offsetInContainer) {
|
|
807
|
-
const r = doc.createRange();
|
|
808
|
-
r.selectNodeContents(el);
|
|
809
|
-
r.setEnd(container, offsetInContainer);
|
|
810
|
-
return r.toString().length;
|
|
811
|
-
}
|
|
812
|
-
const startOffset = offsetFromStart(range.startContainer, range.startOffset);
|
|
813
|
-
const endOffset = offsetFromStart(range.endContainer, range.endOffset);
|
|
814
|
-
el.dataset.jarelaFillCaretOffset = String(startOffset);
|
|
815
|
-
el.dataset.jarelaFillCaretEndOffset = String(endOffset);
|
|
816
|
-
if (startOffset !== endOffset) original = range.toString();
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
} catch {
|
|
820
|
-
// Best-effort — fall back to end-of-field insertion.
|
|
821
|
-
}
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
return { hasField: true, original };
|
|
825
|
-
},
|
|
826
|
-
});
|
|
827
|
-
} catch {
|
|
828
|
-
return { ok: false };
|
|
829
|
-
}
|
|
830
|
-
|
|
831
|
-
let fieldHit = null;
|
|
832
|
-
let selHit = null;
|
|
833
|
-
for (const r of results || []) {
|
|
834
|
-
const v = r?.result;
|
|
835
|
-
if (!v) continue;
|
|
836
|
-
if (v.hasField) {
|
|
837
|
-
if (!fieldHit) fieldHit = { ...v, frameId: r.frameId ?? 0 };
|
|
838
|
-
} else if (!selHit || (v.original?.length ?? 0) > (selHit.original?.length ?? 0)) {
|
|
839
|
-
selHit = { ...v, frameId: r.frameId ?? 0 };
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
const winner = fieldHit || selHit;
|
|
843
|
-
return winner ? { ok: true, ...winner } : { ok: false };
|
|
844
|
-
}
|
|
845
|
-
|
|
846
|
-
async function clearFillTarget(tabId, frameId) {
|
|
847
|
-
try {
|
|
848
|
-
await chrome.scripting.executeScript({
|
|
849
|
-
target: typeof frameId === "number" ? { tabId, frameIds: [frameId] } : { tabId },
|
|
850
|
-
func: () => {
|
|
851
|
-
document.querySelectorAll("[data-jarela-fill-target]").forEach((n) => {
|
|
852
|
-
n.removeAttribute("data-jarela-fill-target");
|
|
853
|
-
delete n.dataset?.jarelaFillStart;
|
|
854
|
-
delete n.dataset?.jarelaFillEnd;
|
|
855
|
-
delete n.dataset?.jarelaFillCaretOffset;
|
|
856
|
-
delete n.dataset?.jarelaFillCaretEndOffset;
|
|
857
|
-
});
|
|
858
|
-
document.querySelectorAll("[data-jarela-fill-caret]").forEach((n) => n.remove());
|
|
859
|
-
},
|
|
860
|
-
});
|
|
861
|
-
} catch {
|
|
862
|
-
// Tab/frame may be gone — nothing to clean up.
|
|
863
|
-
}
|
|
864
|
-
}
|
|
865
|
-
|
|
866
|
-
async function getFillContext(tabId, frameId, selectionOverride) {
|
|
867
|
-
const [{ result }] = await chrome.scripting.executeScript({
|
|
868
|
-
target: typeof frameId === "number" ? { tabId, frameIds: [frameId] } : { tabId },
|
|
869
|
-
args: [selectionOverride ?? ""],
|
|
870
|
-
func: (selectedTextOverride) => {
|
|
871
|
-
function normalizeText(v, max = 5000) {
|
|
872
|
-
return (v || "").replace(/\s+/g, " ").trim().slice(0, max);
|
|
873
|
-
}
|
|
874
|
-
|
|
875
|
-
const marked = document.querySelector("[data-jarela-fill-target]");
|
|
876
|
-
const active = marked || document.activeElement;
|
|
877
|
-
const isTextarea = active instanceof HTMLTextAreaElement;
|
|
878
|
-
const isTextInput = active instanceof HTMLInputElement && /^(text|search|email|url|tel)$/i.test(active.type || "text");
|
|
879
|
-
const isEditable = Boolean(active && (isTextarea || isTextInput || active.isContentEditable));
|
|
880
|
-
const target = isEditable ? active : null;
|
|
881
|
-
|
|
882
|
-
let selectedText = normalizeText(selectedTextOverride || "", 3000);
|
|
883
|
-
if (!selectedText) {
|
|
884
|
-
if (isTextarea || isTextInput) {
|
|
885
|
-
const start = Number(active.selectionStart ?? 0);
|
|
886
|
-
const end = Number(active.selectionEnd ?? 0);
|
|
887
|
-
selectedText = normalizeText(String(active.value || "").slice(Math.min(start, end), Math.max(start, end)), 3000);
|
|
888
|
-
} else {
|
|
889
|
-
selectedText = normalizeText(window.getSelection?.()?.toString() || "", 3000);
|
|
890
|
-
}
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
const title = document.title;
|
|
894
|
-
const url = location.href;
|
|
895
|
-
const h1 = normalizeText(document.querySelector("h1")?.textContent || "", 300);
|
|
896
|
-
const h2 = normalizeText(document.querySelector("h2")?.textContent || "", 300);
|
|
897
|
-
const meta = normalizeText(document.querySelector('meta[name="description"]')?.getAttribute("content") || "", 400);
|
|
898
|
-
|
|
899
|
-
// Find the nearest meaningful container around the focused field.
|
|
900
|
-
// Walk up the DOM and keep the largest ancestor whose text content is
|
|
901
|
-
// "reasonable" (>= 200 chars, <= 20000). This picks the email thread
|
|
902
|
-
// around a Gmail reply, the issue around a GitHub comment box, the
|
|
903
|
-
// dialog around a compose form — but stops short of containers that
|
|
904
|
-
// have already absorbed the whole page chrome (nav, sidebars, inbox
|
|
905
|
-
// listing). Empty when there's no focused field.
|
|
906
|
-
function findScope(field) {
|
|
907
|
-
let node = field?.parentElement || null;
|
|
908
|
-
let best = null;
|
|
909
|
-
while (node && node !== document.body) {
|
|
910
|
-
const len = (node.innerText || "").trim().length;
|
|
911
|
-
if (len > 20000) break;
|
|
912
|
-
if (len >= 200) best = node;
|
|
913
|
-
node = node.parentElement;
|
|
914
|
-
}
|
|
915
|
-
return best;
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
// Pull the scope's text minus the field's own current draft (so the
|
|
919
|
-
// model doesn't see its own future output reflected back). Keep the
|
|
920
|
-
// tail when truncating because email threads / comment threads put
|
|
921
|
-
// the message being replied to closest to the reply box.
|
|
922
|
-
function scopeText(scope, field, max = 6000) {
|
|
923
|
-
if (!scope) return "";
|
|
924
|
-
let raw = scope.innerText || "";
|
|
925
|
-
let draft = "";
|
|
926
|
-
if (field instanceof HTMLTextAreaElement || field instanceof HTMLInputElement) {
|
|
927
|
-
draft = String(field.value || "");
|
|
928
|
-
} else if (field?.isContentEditable) {
|
|
929
|
-
draft = field.innerText || "";
|
|
930
|
-
}
|
|
931
|
-
if (draft && draft.trim().length > 0 && raw.includes(draft)) {
|
|
932
|
-
raw = raw.split(draft).join(" ");
|
|
933
|
-
}
|
|
934
|
-
const cleaned = raw.replace(/\s+/g, " ").trim();
|
|
935
|
-
if (cleaned.length <= max) return cleaned;
|
|
936
|
-
return "... " + cleaned.slice(-max);
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
// Coarse classification of WHAT the field is for. The model already
|
|
940
|
-
// gets the raw signals (tag, type, label, placeholder, host) and is
|
|
941
|
-
// free to override this hint, but stating an explicit kind makes the
|
|
942
|
-
// output style much more consistent: "search query" stays a bare
|
|
943
|
-
// keyword list, "email reply" gets a greeting + sign-off, "chat
|
|
944
|
-
// message" stays terse, etc.
|
|
945
|
-
function detectFieldKind(field, hostName) {
|
|
946
|
-
if (!field) return "";
|
|
947
|
-
const tag = (field.tagName || "").toLowerCase();
|
|
948
|
-
const type = (field.type || "").toLowerCase();
|
|
949
|
-
const role = (field.getAttribute?.("role") || "").toLowerCase();
|
|
950
|
-
const label = String(
|
|
951
|
-
(field.id ? document.querySelector(`label[for="${CSS.escape(field.id)}"]`)?.textContent : "")
|
|
952
|
-
|| field.closest?.("label")?.textContent
|
|
953
|
-
|| field.getAttribute?.("aria-label")
|
|
954
|
-
|| field.placeholder
|
|
955
|
-
|| field.name
|
|
956
|
-
|| "",
|
|
957
|
-
).toLowerCase();
|
|
958
|
-
const host = (hostName || "").toLowerCase();
|
|
959
|
-
|
|
960
|
-
if (type === "search" || role === "searchbox" || /\bsearch\b|\bquery\b/.test(label)) return "search query";
|
|
961
|
-
if (type === "email") return "email address";
|
|
962
|
-
if (type === "url") return "url";
|
|
963
|
-
if (type === "tel") return "phone number";
|
|
964
|
-
if (type === "number") return "numeric value";
|
|
965
|
-
if (type === "password") return "password";
|
|
966
|
-
|
|
967
|
-
const emailHost = /(^|\.)mail\.google\.com$|(^|\.)outlook\.(live|office)\.com$|(^|\.)mail\.yahoo\.com$|(^|\.)proton\.me$/.test(host);
|
|
968
|
-
const isLongForm = tag === "textarea" || field.isContentEditable;
|
|
969
|
-
|
|
970
|
-
if (emailHost && isLongForm) return "email reply";
|
|
971
|
-
if (emailHost && /subject/.test(label)) return "email subject";
|
|
972
|
-
if (/(^|\.)github\.com$/.test(host) && isLongForm) return "github comment";
|
|
973
|
-
if (/(^|\.)(x|twitter)\.com$/.test(host) && isLongForm) return "social post";
|
|
974
|
-
if (/(^|\.)linkedin\.com$/.test(host) && isLongForm) return "social post";
|
|
975
|
-
if (/(^|\.)slack\.com$|(^|\.)discord\.com$/.test(host) && isLongForm) return "chat message";
|
|
976
|
-
if (/(^|\.)reddit\.com$|(^|\.)stackoverflow\.com$/.test(host) && isLongForm) return "forum post";
|
|
977
|
-
|
|
978
|
-
if (/reply|response/.test(label)) return "reply";
|
|
979
|
-
if (/comment/.test(label)) return "comment";
|
|
980
|
-
if (/message|chat|send/.test(label) && isLongForm) return "chat message";
|
|
981
|
-
if (/subject|title|headline/.test(label)) return "short title";
|
|
982
|
-
if (/description|bio|about/.test(label) && isLongForm) return "description";
|
|
983
|
-
|
|
984
|
-
if (isLongForm) return "long-form text";
|
|
985
|
-
if (tag === "input") return "short form field";
|
|
986
|
-
return "";
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
let targetInfo = "";
|
|
990
|
-
const scope = target ? findScope(target) : null;
|
|
991
|
-
if (target) {
|
|
992
|
-
const label = target.id
|
|
993
|
-
? document.querySelector(`label[for="${CSS.escape(target.id)}"]`)?.textContent
|
|
994
|
-
: target.closest("label")?.textContent;
|
|
995
|
-
const placeholder = "placeholder" in target ? String(target.placeholder || "") : "";
|
|
996
|
-
const name = "name" in target ? String(target.name || "") : "";
|
|
997
|
-
const aria = target.getAttribute?.("aria-label") || "";
|
|
998
|
-
const tag = (target.tagName || "").toLowerCase();
|
|
999
|
-
const type = "type" in target ? String(target.type || "") : "";
|
|
1000
|
-
const role = target.getAttribute?.("role") || "";
|
|
1001
|
-
const maxlen = "maxLength" in target && Number(target.maxLength) > 0 ? Number(target.maxLength) : 0;
|
|
1002
|
-
const kind = detectFieldKind(target, location.host);
|
|
1003
|
-
targetInfo = [
|
|
1004
|
-
kind ? `Field kind: ${kind}` : "",
|
|
1005
|
-
`Field tag: ${tag}${target.isContentEditable ? " (contenteditable)" : ""}`,
|
|
1006
|
-
type ? `Field type: ${type}` : "",
|
|
1007
|
-
role ? `Field role: ${role}` : "",
|
|
1008
|
-
maxlen ? `Field maxlength: ${maxlen}` : "",
|
|
1009
|
-
`Field label: ${normalizeText(label || "", 200)}`,
|
|
1010
|
-
`Field name: ${normalizeText(name, 120)}`,
|
|
1011
|
-
`Field placeholder: ${normalizeText(placeholder, 200)}`,
|
|
1012
|
-
`Field aria-label: ${normalizeText(aria, 200)}`,
|
|
1013
|
-
].filter((line) => line && !line.endsWith(": ")).join("\n");
|
|
1014
|
-
}
|
|
1015
|
-
|
|
1016
|
-
const pageContext = [
|
|
1017
|
-
`Host: ${location.host}`,
|
|
1018
|
-
h1 ? `Main heading: ${h1}` : "",
|
|
1019
|
-
h2 ? `Secondary heading: ${h2}` : "",
|
|
1020
|
-
meta ? `Meta description: ${meta}` : "",
|
|
1021
|
-
targetInfo,
|
|
1022
|
-
].filter(Boolean).join("\n");
|
|
1023
|
-
|
|
1024
|
-
// Priority order for the primary text payload:
|
|
1025
|
-
// 1. user's explicit selection (always wins)
|
|
1026
|
-
// 2. scope text around the focused field (the thread / form / dialog
|
|
1027
|
-
// the field actually belongs to)
|
|
1028
|
-
// 3. document.body.innerText cap 5000 (only when there's no focused
|
|
1029
|
-
// field at all — context-menu fill on a passive page region)
|
|
1030
|
-
let text;
|
|
1031
|
-
if (selectedText) text = selectedText;
|
|
1032
|
-
else if (target) text = scopeText(scope, target) || "";
|
|
1033
|
-
else text = normalizeText(document.body?.innerText || "", 5000);
|
|
1034
|
-
return { url, title, text, page_context: pageContext, has_target: Boolean(target) };
|
|
1035
|
-
},
|
|
1036
|
-
});
|
|
1037
|
-
return result;
|
|
1038
|
-
}
|
|
1039
|
-
|
|
1040
|
-
async function fillFocusedField(tabId, frameId, value) {
|
|
1041
|
-
const [{ result }] = await chrome.scripting.executeScript({
|
|
1042
|
-
target: typeof frameId === "number" ? { tabId, frameIds: [frameId] } : { tabId },
|
|
1043
|
-
args: [value],
|
|
1044
|
-
func: (nextText) => {
|
|
1045
|
-
const marked = document.querySelector("[data-jarela-fill-target]");
|
|
1046
|
-
const active = marked || document.activeElement;
|
|
1047
|
-
if (!active) return { ok: false, reason: "No focused field" };
|
|
1048
|
-
|
|
1049
|
-
if (active instanceof HTMLTextAreaElement || (active instanceof HTMLInputElement && /^(text|search|email|url|tel)$/i.test(active.type || "text"))) {
|
|
1050
|
-
active.focus();
|
|
1051
|
-
// Prefer the caret captured at mark time \u2014 the context menu +
|
|
1052
|
-
// spinner + LLM round-trip blur the field, after which
|
|
1053
|
-
// selectionStart/End reset to value.length and we'd append.
|
|
1054
|
-
const savedStart = active.dataset?.jarelaFillStart;
|
|
1055
|
-
const savedEnd = active.dataset?.jarelaFillEnd;
|
|
1056
|
-
const start = savedStart !== undefined
|
|
1057
|
-
? Number(savedStart)
|
|
1058
|
-
: Number(active.selectionStart ?? active.value.length);
|
|
1059
|
-
const end = savedEnd !== undefined
|
|
1060
|
-
? Number(savedEnd)
|
|
1061
|
-
: Number(active.selectionEnd ?? active.value.length);
|
|
1062
|
-
const left = active.value.slice(0, Math.min(start, end));
|
|
1063
|
-
const right = active.value.slice(Math.max(start, end));
|
|
1064
|
-
active.value = `${left}${nextText}${right}`;
|
|
1065
|
-
const cursor = left.length + nextText.length;
|
|
1066
|
-
active.selectionStart = cursor;
|
|
1067
|
-
active.selectionEnd = cursor;
|
|
1068
|
-
active.dispatchEvent(new Event("input", { bubbles: true }));
|
|
1069
|
-
active.dispatchEvent(new Event("change", { bubbles: true }));
|
|
1070
|
-
return { ok: true };
|
|
1071
|
-
}
|
|
1072
|
-
|
|
1073
|
-
if (active.isContentEditable) {
|
|
1074
|
-
active.focus();
|
|
1075
|
-
// Restore the saved range (start..end) so insertText REPLACES any
|
|
1076
|
-
// selected text. Falls back to caret-only or end-of-field if the
|
|
1077
|
-
// field's text shrank between mark and fill.
|
|
1078
|
-
const savedStart = active.dataset?.jarelaFillCaretOffset;
|
|
1079
|
-
const savedEnd = active.dataset?.jarelaFillCaretEndOffset ?? savedStart;
|
|
1080
|
-
try {
|
|
1081
|
-
const sel = window.getSelection();
|
|
1082
|
-
const range = document.createRange();
|
|
1083
|
-
if (savedStart !== undefined) {
|
|
1084
|
-
const startTarget = Number(savedStart);
|
|
1085
|
-
const endTarget = Number(savedEnd);
|
|
1086
|
-
const walker = document.createTreeWalker(active, NodeFilter.SHOW_TEXT);
|
|
1087
|
-
let n;
|
|
1088
|
-
let acc = 0;
|
|
1089
|
-
let placedStart = false;
|
|
1090
|
-
let placedEnd = false;
|
|
1091
|
-
while ((n = walker.nextNode())) {
|
|
1092
|
-
const len = (n.nodeValue || "").length;
|
|
1093
|
-
if (!placedStart && startTarget <= acc + len) {
|
|
1094
|
-
range.setStart(n, startTarget - acc);
|
|
1095
|
-
placedStart = true;
|
|
1096
|
-
}
|
|
1097
|
-
if (!placedEnd && endTarget <= acc + len) {
|
|
1098
|
-
range.setEnd(n, endTarget - acc);
|
|
1099
|
-
placedEnd = true;
|
|
1100
|
-
}
|
|
1101
|
-
if (placedStart && placedEnd) break;
|
|
1102
|
-
acc += len;
|
|
1103
|
-
}
|
|
1104
|
-
if (!placedStart || !placedEnd) {
|
|
1105
|
-
// Field shrank or text changed; clamp to end.
|
|
1106
|
-
range.selectNodeContents(active);
|
|
1107
|
-
range.collapse(false);
|
|
1108
|
-
}
|
|
1109
|
-
} else {
|
|
1110
|
-
// No offset captured (shadow-root host or detached frame).
|
|
1111
|
-
range.selectNodeContents(active);
|
|
1112
|
-
range.collapse(false);
|
|
1113
|
-
}
|
|
1114
|
-
sel?.removeAllRanges();
|
|
1115
|
-
sel?.addRange(range);
|
|
1116
|
-
} catch {
|
|
1117
|
-
// Selection APIs throw inside detached frames; fall through to insertText.
|
|
1118
|
-
}
|
|
1119
|
-
delete active.dataset?.jarelaFillCaretOffset;
|
|
1120
|
-
delete active.dataset?.jarelaFillCaretEndOffset;
|
|
1121
|
-
const inserted = document.execCommand("insertText", false, nextText);
|
|
1122
|
-
if (!inserted) {
|
|
1123
|
-
// execCommand can be a no-op in some shadow roots / custom editors —
|
|
1124
|
-
// fall back to a plain textContent assignment + input event so the
|
|
1125
|
-
// host framework still sees the change.
|
|
1126
|
-
active.textContent = `${active.textContent || ""}${nextText}`;
|
|
1127
|
-
}
|
|
1128
|
-
active.dispatchEvent(new Event("input", { bubbles: true }));
|
|
1129
|
-
return { ok: true };
|
|
1130
|
-
}
|
|
1131
|
-
|
|
1132
|
-
return { ok: false, reason: "Focused element is not editable" };
|
|
1133
|
-
},
|
|
1134
|
-
});
|
|
1135
|
-
return result;
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
// Anchors a small rotating SVG spinner to the focused field so the user
|
|
1139
|
-
// gets visual confirmation that a fill turn is running. Mirrors the chat
|
|
1140
|
-
// CountdownRing geometry (r=5.5, viewBox 14×14) at field-sized scale.
|
|
1141
|
-
async function showFillSpinner(tabId, frameId) {
|
|
1142
|
-
try {
|
|
1143
|
-
await chrome.scripting.insertCSS({
|
|
1144
|
-
target: typeof frameId === "number" ? { tabId, frameIds: [frameId] } : { tabId },
|
|
1145
|
-
css: `
|
|
1146
|
-
#jarela-fill-spinner { position: fixed; z-index: 2147483647; pointer-events: none;
|
|
1147
|
-
width: 18px; height: 18px; border-radius: 50%;
|
|
1148
|
-
background: rgba(15, 23, 42, 0.92); box-shadow: 0 1px 4px rgba(0,0,0,0.4);
|
|
1149
|
-
display: flex; align-items: center; justify-content: center; }
|
|
1150
|
-
#jarela-fill-spinner svg { width: 14px; height: 14px; animation: jarela-fill-spin 1s linear infinite; }
|
|
1151
|
-
#jarela-fill-spinner circle { fill: none; stroke: #818cf8; stroke-width: 1.5;
|
|
1152
|
-
stroke-linecap: round; stroke-dasharray: 8.6 26; }
|
|
1153
|
-
@keyframes jarela-fill-spin { to { transform: rotate(360deg); } }
|
|
1154
|
-
@media (prefers-reduced-motion: reduce) { #jarela-fill-spinner svg { animation: none; } }
|
|
1155
|
-
`,
|
|
1156
|
-
});
|
|
1157
|
-
await chrome.scripting.executeScript({
|
|
1158
|
-
target: typeof frameId === "number" ? { tabId, frameIds: [frameId] } : { tabId },
|
|
1159
|
-
func: () => {
|
|
1160
|
-
const marked = document.querySelector("[data-jarela-fill-target]");
|
|
1161
|
-
const active = marked || document.activeElement;
|
|
1162
|
-
if (!active || typeof active.getBoundingClientRect !== "function") return;
|
|
1163
|
-
const rect = active.getBoundingClientRect();
|
|
1164
|
-
document.getElementById("jarela-fill-spinner")?.remove();
|
|
1165
|
-
const el = document.createElement("div");
|
|
1166
|
-
el.id = "jarela-fill-spinner";
|
|
1167
|
-
el.innerHTML = '<svg viewBox="0 0 14 14"><circle cx="7" cy="7" r="5.5"/></svg>';
|
|
1168
|
-
el.style.top = `${Math.max(2, rect.top + 4)}px`;
|
|
1169
|
-
el.style.left = `${Math.max(2, rect.right - 22)}px`;
|
|
1170
|
-
document.body.appendChild(el);
|
|
1171
|
-
},
|
|
1172
|
-
});
|
|
1173
|
-
} catch (err) {
|
|
1174
|
-
console.warn("[jarela] showFillSpinner failed:", err);
|
|
1175
|
-
}
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
async function hideFillSpinner(tabId, frameId) {
|
|
1179
|
-
try {
|
|
1180
|
-
await chrome.scripting.executeScript({
|
|
1181
|
-
target: typeof frameId === "number" ? { tabId, frameIds: [frameId] } : { tabId },
|
|
1182
|
-
func: () => { document.getElementById("jarela-fill-spinner")?.remove(); },
|
|
1183
|
-
});
|
|
1184
|
-
} catch {
|
|
1185
|
-
// Tab may have navigated away — nothing to clean up.
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
655
|
// Prompt templates for the unified write path. Auto-fill (no user
|
|
1190
656
|
// intent) reads the field/page and drafts something plausible.
|
|
1191
657
|
// Custom-intent fill polishes the user's wording into a reply that fits
|