synabun 2.2.0 → 2.2.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/CHANGELOG.md +45 -0
- package/README.md +1 -1
- package/hooks/claude-code/pre-websearch.mjs +4 -1
- package/hooks/claude-code/prompt-submit.mjs +7 -0
- package/lib/release-scan.mjs +23 -10
- package/lib/virustotal.mjs +143 -39
- package/mcp-server/dist/http.d.ts +19 -0
- package/mcp-server/dist/http.d.ts.map +1 -1
- package/mcp-server/dist/http.js +55 -13
- package/mcp-server/dist/http.js.map +1 -1
- package/mcp-server/dist/index.d.ts.map +1 -1
- package/mcp-server/dist/index.js +14 -9
- package/mcp-server/dist/index.js.map +1 -1
- package/mcp-server/dist/services/browser-route-flow.d.ts +118 -0
- package/mcp-server/dist/services/browser-route-flow.d.ts.map +1 -0
- package/mcp-server/dist/services/browser-route-flow.js +339 -0
- package/mcp-server/dist/services/browser-route-flow.js.map +1 -0
- package/mcp-server/dist/services/desktop-client.js +2 -2
- package/mcp-server/dist/services/desktop-client.js.map +1 -1
- package/mcp-server/dist/services/identity.d.ts +66 -3
- package/mcp-server/dist/services/identity.d.ts.map +1 -1
- package/mcp-server/dist/services/identity.js +61 -4
- package/mcp-server/dist/services/identity.js.map +1 -1
- package/mcp-server/dist/services/neural-interface.d.ts +112 -1
- package/mcp-server/dist/services/neural-interface.d.ts.map +1 -1
- package/mcp-server/dist/services/neural-interface.js +555 -61
- package/mcp-server/dist/services/neural-interface.js.map +1 -1
- package/mcp-server/dist/tools/bluesky.d.ts +20 -7
- package/mcp-server/dist/tools/bluesky.d.ts.map +1 -1
- package/mcp-server/dist/tools/bluesky.js +147 -45
- package/mcp-server/dist/tools/bluesky.js.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.d.ts +11 -2
- package/mcp-server/dist/tools/browser-advanced.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-advanced.js +131 -18
- package/mcp-server/dist/tools/browser-advanced.js.map +1 -1
- package/mcp-server/dist/tools/browser-cheatsheet.d.ts +2 -0
- package/mcp-server/dist/tools/browser-cheatsheet.d.ts.map +1 -1
- package/mcp-server/dist/tools/browser-cheatsheet.js +3 -0
- package/mcp-server/dist/tools/browser-cheatsheet.js.map +1 -1
- package/mcp-server/dist/tools/morelogin.d.ts.map +1 -1
- package/mcp-server/dist/tools/morelogin.js +4 -2
- package/mcp-server/dist/tools/morelogin.js.map +1 -1
- package/mcp-server/dist/tools/skill-tools.d.ts +4 -4
- package/mcp-server/dist/tools/youtube/helpers.d.ts +1 -0
- package/mcp-server/dist/tools/youtube/helpers.d.ts.map +1 -1
- package/mcp-server/dist/tools/youtube/helpers.js +1 -1
- package/mcp-server/dist/tools/youtube/helpers.js.map +1 -1
- package/mcp-server/package-lock.json +2 -2
- package/mcp-server/package.json +1 -1
- package/mcp-server/src/http.ts +58 -12
- package/mcp-server/src/index.ts +15 -9
- package/mcp-server/src/services/browser-route-flow.ts +402 -0
- package/mcp-server/src/services/desktop-client.ts +2 -2
- package/mcp-server/src/services/identity.ts +80 -4
- package/mcp-server/src/services/neural-interface.ts +572 -70
- package/mcp-server/src/tools/bluesky.ts +164 -51
- package/mcp-server/src/tools/browser-advanced.ts +121 -17
- package/mcp-server/src/tools/browser-cheatsheet.ts +3 -0
- package/mcp-server/src/tools/morelogin.ts +4 -2
- package/mcp-server/src/tools/youtube/helpers.ts +2 -2
- package/neural-interface/i18n/en.json +27 -0
- package/neural-interface/i18n/pt-BR.json +27 -0
- package/neural-interface/lib/assistant-api.js +64 -23
- package/neural-interface/lib/assistant-brains/codex.js +6 -1
- package/neural-interface/lib/assistant-catalog.js +20 -2
- package/neural-interface/lib/assistant-dispatch.js +31 -2
- package/neural-interface/lib/assistant-persona.js +1 -0
- package/neural-interface/lib/assistant-runtime.js +15 -1
- package/neural-interface/lib/assistant-tools.js +10 -1
- package/neural-interface/lib/browser-automation-routes.js +84 -0
- package/neural-interface/lib/browser-execution.js +16 -3
- package/neural-interface/lib/browser-owner.js +48 -0
- package/neural-interface/lib/browser-session-close.js +84 -0
- package/neural-interface/lib/browser-start-handoff.js +202 -0
- package/neural-interface/lib/browser-tool-policy.js +21 -4
- package/neural-interface/lib/browser-wedge-retire.js +64 -0
- package/neural-interface/lib/claude-agent-bridge.js +36 -1
- package/neural-interface/lib/claude-background-hold.js +239 -0
- package/neural-interface/lib/exec-loop-command.js +8 -0
- package/neural-interface/lib/http-guards.js +11 -6
- package/neural-interface/lib/loop-logger.js +6 -1
- package/neural-interface/lib/mcp-external-servers.js +64 -13
- package/neural-interface/lib/native-loop-providers.js +122 -10
- package/neural-interface/lib/native-loop-runtime.js +112 -11
- package/neural-interface/lib/opencode-native-boundary.js +155 -21
- package/neural-interface/lib/owner-authority.js +113 -37
- package/neural-interface/lib/page-session.js +81 -23
- package/neural-interface/lib/peer-identity.js +311 -47
- package/neural-interface/lib/provider-panel-api-key-auth.js +7 -2
- package/neural-interface/lib/pty-host/core.js +36 -0
- package/neural-interface/lib/pty-host/protocol.js +2 -0
- package/neural-interface/lib/skills/api-v2.js +13 -2
- package/neural-interface/lib/skills/creation-api.js +3 -1
- package/neural-interface/lib/skills/evals-api.js +5 -1
- package/neural-interface/lib/social-write-pacing.js +151 -0
- package/neural-interface/lib/terminal-token-redaction.js +293 -0
- package/neural-interface/lib/terminal-tokens.js +359 -0
- package/neural-interface/lib/worker-mcp-channel.js +45 -10
- package/neural-interface/package-lock.json +2 -2
- package/neural-interface/package.json +1 -1
- package/neural-interface/public/shared/agy/agy-render.js +41 -1
- package/neural-interface/public/shared/agy/agy-styles.js +5 -0
- package/neural-interface/public/shared/api.js +1 -0
- package/neural-interface/public/shared/assistant/asst-api.js +14 -2
- package/neural-interface/public/shared/assistant/asst-computer.js +73 -4
- package/neural-interface/public/shared/assistant/asst-limit-wait.js +3 -1
- package/neural-interface/public/shared/assistant/asst-motion-gate.js +80 -0
- package/neural-interface/public/shared/assistant/asst-panel.js +8 -4
- package/neural-interface/public/shared/assistant/asst-render.js +72 -11
- package/neural-interface/public/shared/assistant/asst-scene-styles.js +55 -23
- package/neural-interface/public/shared/assistant/asst-scenes.js +225 -79
- package/neural-interface/public/shared/assistant/asst-sidepanel-styles.js +4 -4
- package/neural-interface/public/shared/assistant/asst-style-cache.js +44 -0
- package/neural-interface/public/shared/assistant/asst-styles.js +26 -5
- package/neural-interface/public/shared/cdx/cdx-render.js +73 -7
- package/neural-interface/public/shared/cdx/cdx-tabs.js +3 -3
- package/neural-interface/public/shared/cp/cp-agents.js +8 -0
- package/neural-interface/public/shared/cp/cp-permissions.js +18 -2
- package/neural-interface/public/shared/cp/cp-rehydrate.js +25 -1
- package/neural-interface/public/shared/cp/cp-tasks-model.js +33 -0
- package/neural-interface/public/shared/judgments-log-origins.js +29 -0
- package/neural-interface/public/shared/loading-teardown.js +34 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-automation-ownership.js +23 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-childpanel.js +6 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-events.js +13 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-icons.js +3 -1
- package/neural-interface/public/shared/ocp-v2/ocp-v2-panel.js +5 -2
- package/neural-interface/public/shared/ocp-v2/ocp-v2-render.js +16 -86
- package/neural-interface/public/shared/ocp-v2/ocp-v2-send.js +6 -0
- package/neural-interface/public/shared/ocp-v2/ocp-v2-styles.js +88 -72
- package/neural-interface/public/shared/ocp-v2/ocp-v2-ws.js +5 -2
- package/neural-interface/public/shared/owner-access.js +134 -0
- package/neural-interface/public/shared/owner-authority-view.js +92 -0
- package/neural-interface/public/shared/page-session.js +143 -14
- package/neural-interface/public/shared/poll-backoff.js +59 -0
- package/neural-interface/public/shared/settings/settings-data.js +6 -1
- package/neural-interface/public/shared/settings/settings-kit.js +11 -3
- package/neural-interface/public/shared/settings/settings-shell.js +7 -0
- package/neural-interface/public/shared/shown-children.js +72 -0
- package/neural-interface/public/shared/static-bg-state.js +22 -0
- package/neural-interface/public/shared/storage-retry.js +47 -0
- package/neural-interface/public/shared/storage.js +25 -4
- package/neural-interface/public/shared/styles.css +109 -8
- package/neural-interface/public/shared/synabun-mascot.js +27 -8
- package/neural-interface/public/shared/synabun-ticker.js +147 -12
- package/neural-interface/public/shared/synabun-tools.js +173 -0
- package/neural-interface/public/shared/tool-heartbeat.js +43 -0
- package/neural-interface/public/shared/tool-list-picker.js +3 -1
- package/neural-interface/public/shared/tool-list-view.js +23 -4
- package/neural-interface/public/shared/ui-automation-studio.js +8 -1
- package/neural-interface/public/shared/ui-claude-panel.js +238 -90
- package/neural-interface/public/shared/ui-judgments.js +37 -10
- package/neural-interface/public/shared/ui-loading.js +5 -4
- package/neural-interface/public/shared/ui-navbar.js +6 -0
- package/neural-interface/public/shared/ui-owner-access.js +191 -0
- package/neural-interface/public/shared/ui-owner-authority.js +162 -0
- package/neural-interface/public/shared/ui-sessions.js +45 -16
- package/neural-interface/public/shared/ui-settings.js +86 -15
- package/neural-interface/public/shared/ui-terminal.js +15 -7
- package/neural-interface/public/shared/ui-tutorial-preview.js +4 -0
- package/neural-interface/public/shared/ui-update.js +3 -0
- package/neural-interface/public/shared/ui-whiteboard.js +4 -0
- package/neural-interface/public/shared/window-keys.js +38 -0
- package/neural-interface/server.js +1240 -238
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
import {
|
|
36
36
|
revertToMessage, restoreReverted, retryFromMessage, forkSession,
|
|
37
37
|
} from './ocp-v2-session-actions.js';
|
|
38
|
+
import { synabunToolKey, synabunToolLabel, synabunToolSummary } from '../synabun-tools.js';
|
|
38
39
|
|
|
39
40
|
const _expandedReasoningIds = new Set();
|
|
40
41
|
const _activeRenderers = new Set();
|
|
@@ -748,62 +749,14 @@ function extractQuestionsFromToolInput(input) {
|
|
|
748
749
|
// ── SynaBun MCP tool branding ────────────────────────────────────────────────
|
|
749
750
|
const SYNABUN_LOGO_HTML = '<img src="logoHD.png" alt="" style="width:14px;height:14px;object-fit:contain;">';
|
|
750
751
|
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
forget: 'Forget', restore: 'Restore', memories: 'Memories', sync: 'Sync',
|
|
754
|
-
category: 'Category', loop: 'Loop', git: 'Git', tictactoe: 'TicTacToe',
|
|
755
|
-
image_staged: 'Images', profile: 'Profile',
|
|
756
|
-
browser_navigate: 'Browser · Navigate', browser_screenshot: 'Browser · Screenshot', browser_console: 'Browser · Console',
|
|
757
|
-
browser_snapshot: 'Browser · Snapshot', browser_content: 'Browser · Content',
|
|
758
|
-
browser_click: 'Browser · Click', browser_type: 'Browser · Type',
|
|
759
|
-
browser_fill: 'Browser · Fill', browser_hover: 'Browser · Hover',
|
|
760
|
-
browser_select: 'Browser · Select', browser_press: 'Browser · Press',
|
|
761
|
-
browser_scroll: 'Browser · Scroll', browser_wait: 'Browser · Wait',
|
|
762
|
-
browser_go_back: 'Browser · Back', browser_go_forward: 'Browser · Forward',
|
|
763
|
-
browser_reload: 'Browser · Reload', browser_evaluate: 'Browser · Evaluate',
|
|
764
|
-
browser_upload: 'Browser · Upload', browser_session: 'Browser · Session',
|
|
765
|
-
browser_cheatsheet: 'Browser · Cheatsheet',
|
|
766
|
-
browser_extract_tweets: 'Extract · Tweets', browser_extract_fb_posts: 'Extract · Facebook',
|
|
767
|
-
browser_fb_composer_state: 'Facebook · Composer', browser_extract_fb_groups: 'Extract · FB Groups',
|
|
768
|
-
browser_extract_ig_feed: 'Extract · Instagram', browser_extract_ig_post: 'Extract · IG Post',
|
|
769
|
-
browser_extract_ig_reels: 'Extract · IG Reels', browser_extract_ig_profile: 'Extract · IG Profile',
|
|
770
|
-
browser_extract_ig_search: 'Extract · IG Search',
|
|
771
|
-
browser_extract_tiktok_videos: 'Extract · TikTok', browser_extract_tiktok_search: 'Extract · TikTok Search',
|
|
772
|
-
browser_extract_tiktok_studio: 'Extract · TikTok Studio', browser_extract_tiktok_profile: 'Extract · TikTok Profile',
|
|
773
|
-
browser_extract_li_feed: 'Extract · LinkedIn', browser_extract_li_profile: 'Extract · LI Profile',
|
|
774
|
-
browser_extract_li_post: 'Extract · LI Post', browser_extract_li_notifications: 'Extract · LI Notifications',
|
|
775
|
-
browser_extract_li_messages: 'Extract · LI Messages', browser_extract_li_search_people: 'Extract · LI People',
|
|
776
|
-
browser_extract_li_network: 'Extract · LI Network', browser_extract_li_jobs: 'Extract · LI Jobs',
|
|
777
|
-
browser_extract_wa_chats: 'Extract · WhatsApp', browser_extract_wa_messages: 'Extract · WA Messages',
|
|
778
|
-
bluesky_session: 'BlueSky · Session', bluesky_timeline: 'BlueSky · Timeline',
|
|
779
|
-
bluesky_author_feed: 'BlueSky · Author Feed', bluesky_thread: 'BlueSky · Thread',
|
|
780
|
-
bluesky_profile: 'BlueSky · Profile', bluesky_search_posts: 'BlueSky · Search Posts',
|
|
781
|
-
bluesky_search_actors: 'BlueSky · Search Users', bluesky_notifications: 'BlueSky · Notifications',
|
|
782
|
-
bluesky_graph: 'BlueSky · Graph', bluesky_likes: 'BlueSky · Likes', bluesky_feed: 'BlueSky · Feed',
|
|
783
|
-
bluesky_post: 'BlueSky · Post', bluesky_action: 'BlueSky · Action',
|
|
784
|
-
bluesky_resolve: 'BlueSky · Resolve', bluesky_dm: 'BlueSky · DM',
|
|
785
|
-
whiteboard_read: 'Whiteboard · Read', whiteboard_add: 'Whiteboard · Add',
|
|
786
|
-
whiteboard_update: 'Whiteboard · Update', whiteboard_remove: 'Whiteboard · Remove',
|
|
787
|
-
whiteboard_screenshot: 'Whiteboard · Screenshot',
|
|
788
|
-
card_list: 'Cards · List', card_open: 'Cards · Open', card_close: 'Cards · Close',
|
|
789
|
-
card_update: 'Cards · Update', card_screenshot: 'Cards · Screenshot',
|
|
790
|
-
discord_guild: 'Discord · Guild', discord_channel: 'Discord · Channel',
|
|
791
|
-
discord_role: 'Discord · Role', discord_message: 'Discord · Message',
|
|
792
|
-
discord_member: 'Discord · Member', discord_onboarding: 'Discord · Onboarding',
|
|
793
|
-
discord_webhook: 'Discord · Webhook', discord_thread: 'Discord · Thread',
|
|
794
|
-
};
|
|
795
|
-
|
|
752
|
+
// Which call is SynaBun's, its name and its one-line summary: synabun-tools.js, the same
|
|
753
|
+
// for every panel (`SynaBun_x` here, `mcp__SynaBun__x` from the others, any letter case).
|
|
796
754
|
function isSynaBunTool(name) {
|
|
797
|
-
return typeof name === 'string' && (name
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
function synabunToolKey(name) {
|
|
801
|
-
return (name || '').replace(/^mcp__SynaBun__/, '').replace(/^SynaBun_/, '');
|
|
755
|
+
return typeof name === 'string' && synabunToolKey(name) != null;
|
|
802
756
|
}
|
|
803
757
|
|
|
804
758
|
function synabunDisplayName(name) {
|
|
805
|
-
|
|
806
|
-
return SYNABUN_LABELS[key] || (key.charAt(0).toUpperCase() + key.slice(1).replace(/_/g, ' '));
|
|
759
|
+
return synabunToolLabel(synabunToolKey(name) || '');
|
|
807
760
|
}
|
|
808
761
|
|
|
809
762
|
function _truncate(s, n = 90) {
|
|
@@ -813,46 +766,21 @@ function _truncate(s, n = 90) {
|
|
|
813
766
|
|
|
814
767
|
function synabunSummaryText(name, input) {
|
|
815
768
|
if (!input || typeof input !== 'object') return '';
|
|
816
|
-
|
|
817
|
-
const t = (s) => _truncate(s, 90);
|
|
818
|
-
switch (key) {
|
|
819
|
-
case 'recall': return t(input.query);
|
|
820
|
-
case 'remember': return t(input.content);
|
|
821
|
-
case 'reflect': return t(input.content || input.memory_id);
|
|
822
|
-
case 'forget':
|
|
823
|
-
case 'restore': return t(input.memory_id);
|
|
824
|
-
case 'memories': return t(input.action);
|
|
825
|
-
case 'category': return t(`${input.action || ''}${input.name ? ' · ' + input.name : ''}`);
|
|
826
|
-
case 'sync': return '';
|
|
827
|
-
case 'git': return t(input.action);
|
|
828
|
-
case 'loop': return t(`${input.action || ''}${input.prompt ? ' · ' + input.prompt : ''}`);
|
|
829
|
-
case 'browser_navigate': return t(input.url);
|
|
830
|
-
case 'browser_click':
|
|
831
|
-
case 'browser_hover': return t(input.selector || input.label);
|
|
832
|
-
case 'browser_type':
|
|
833
|
-
case 'browser_fill': return t(input.text || input.value || input.selector);
|
|
834
|
-
case 'browser_select': return t(input.value || input.selector);
|
|
835
|
-
case 'browser_press': return t(input.key);
|
|
836
|
-
case 'browser_scroll': return t(input.direction || input.selector);
|
|
837
|
-
case 'browser_evaluate': return t(input.script);
|
|
838
|
-
case 'browser_session': return t(input.action);
|
|
839
|
-
case 'image_staged': return t(input.action);
|
|
840
|
-
case 'discord_message': return t(input.content || input.action);
|
|
841
|
-
case 'discord_channel':
|
|
842
|
-
case 'discord_member':
|
|
843
|
-
case 'discord_role': return t(input.action || input.name);
|
|
844
|
-
case 'whiteboard_add':
|
|
845
|
-
case 'whiteboard_update': return t(input.content || input.title);
|
|
846
|
-
case 'card_open':
|
|
847
|
-
case 'card_update': return t(input.title || input.id);
|
|
848
|
-
default: return '';
|
|
849
|
-
}
|
|
769
|
+
return synabunToolSummary(synabunToolKey(name) || '', input);
|
|
850
770
|
}
|
|
851
771
|
|
|
852
772
|
// Persist expand/collapse state across re-renders (render() rebuilds DOM).
|
|
853
773
|
const _expandedToolIds = new Set();
|
|
854
774
|
const SYNABUN_CHEVRON_SVG = '<svg viewBox="0 0 24 24" width="11" height="11" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>';
|
|
855
775
|
|
|
776
|
+
function spinRing() {
|
|
777
|
+
const ring = document.createElement('span');
|
|
778
|
+
ring.className = 'ocpv2-spin-ring';
|
|
779
|
+
ring.setAttribute('aria-hidden', 'true');
|
|
780
|
+
ring.appendChild(document.createElement('i'));
|
|
781
|
+
return ring;
|
|
782
|
+
}
|
|
783
|
+
|
|
856
784
|
function renderSynaBunToolPart(part, toolName, stateStatus) {
|
|
857
785
|
const callId = part.callID || part.id || part.toolCallId || part.tool_use_id || `sb-${toolName}`;
|
|
858
786
|
const expanded = _expandedToolIds.has(callId);
|
|
@@ -861,6 +789,8 @@ function renderSynaBunToolPart(part, toolName, stateStatus) {
|
|
|
861
789
|
wrap.className = 'ocpv2-part ocpv2-part-tool ocpv2-tool-synabun' + (expanded ? ' ocpv2-tool-expanded' : '');
|
|
862
790
|
wrap.dataset.toolId = callId;
|
|
863
791
|
wrap.dataset.status = stateStatus;
|
|
792
|
+
// The working ring (.ocpv2-spin-ring): a box the compositor turns while the call runs or waits.
|
|
793
|
+
wrap.appendChild(spinRing());
|
|
864
794
|
|
|
865
795
|
const head = document.createElement('div');
|
|
866
796
|
head.className = 'ocpv2-tool-head ocpv2-sb-head';
|
|
@@ -211,6 +211,12 @@ export function mountCompose(rootEl, store = getDefaultStore(), opts = {}) {
|
|
|
211
211
|
const wrap = document.createElement('div');
|
|
212
212
|
wrap.className = 'ocpv2-input-wrap';
|
|
213
213
|
_wrap = wrap;
|
|
214
|
+
// The focus ring (.ocpv2-spin-ring): a box the compositor turns while the composer has focus.
|
|
215
|
+
const ring = document.createElement('span');
|
|
216
|
+
ring.className = 'ocpv2-spin-ring';
|
|
217
|
+
ring.setAttribute('aria-hidden', 'true');
|
|
218
|
+
ring.appendChild(document.createElement('i'));
|
|
219
|
+
wrap.appendChild(ring);
|
|
214
220
|
|
|
215
221
|
const inner = document.createElement('div');
|
|
216
222
|
inner.className = 'ocpv2-input-inner';
|
|
@@ -412,55 +412,56 @@ html.desktop-titlebar--win32 .ocpv2-panel { backdrop-filter: none; -webkit-backd
|
|
|
412
412
|
}
|
|
413
413
|
|
|
414
414
|
/* ── Tray pill (minimize-to-pill) ───────────────────────────────────────── */
|
|
415
|
-
@property --ocpv2-pill-angle {
|
|
416
|
-
syntax: '<angle>';
|
|
417
|
-
initial-value: 0deg;
|
|
418
|
-
inherits: false;
|
|
419
|
-
}
|
|
420
415
|
.ocpv2-session-pill {
|
|
421
416
|
position: relative;
|
|
422
417
|
overflow: hidden;
|
|
423
418
|
border-color: rgba(232, 224, 220, 0.12);
|
|
424
419
|
transition: border-color 0.2s;
|
|
425
420
|
}
|
|
426
|
-
|
|
427
|
-
|
|
421
|
+
/* A working pill's ring: a conic gradient turning inside the 1px border (the mask keeps only the
|
|
422
|
+
ring). The gradient is a square box that turns (rotate, run by the compositor) under the mask; an
|
|
423
|
+
animated custom property (the old --ocpv2-pill-angle) repainted the pill on the main thread every
|
|
424
|
+
frame for as long as the session worked. The square is wider than the pill's diagonal, so the
|
|
425
|
+
ring is the same conic gradient at every angle. */
|
|
426
|
+
.ocpv2-pill-ring {
|
|
428
427
|
position: absolute; inset: 0;
|
|
428
|
+
display: none;
|
|
429
429
|
border-radius: 8px;
|
|
430
430
|
padding: 1px;
|
|
431
|
+
overflow: hidden;
|
|
431
432
|
pointer-events: none;
|
|
432
|
-
background: transparent;
|
|
433
433
|
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
|
|
434
434
|
-webkit-mask-composite: xor;
|
|
435
435
|
mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
|
|
436
436
|
mask-composite: exclude;
|
|
437
|
-
opacity: 0;
|
|
438
|
-
}
|
|
439
|
-
.ocpv2-session-pill.ocpv2-pill-running {
|
|
440
|
-
border-color: transparent;
|
|
441
437
|
}
|
|
442
|
-
.ocpv2-
|
|
438
|
+
.ocpv2-pill-ring > i {
|
|
439
|
+
position: absolute; left: 50%; top: 50%;
|
|
440
|
+
width: calc(100% + 32px);
|
|
441
|
+
aspect-ratio: 1;
|
|
442
|
+
translate: -50% -50%;
|
|
443
443
|
background: conic-gradient(
|
|
444
|
-
from var(--ocpv2-pill-angle, 0deg),
|
|
445
444
|
rgba(232,224,220,0.0) 0%,
|
|
446
445
|
rgba(232,224,220,0.55) 25%,
|
|
447
446
|
rgba(232,224,220,0.10) 50%,
|
|
448
447
|
rgba(232,224,220,0.55) 75%,
|
|
449
448
|
rgba(232,224,220,0.0) 100%
|
|
450
449
|
);
|
|
451
|
-
animation: ocpv2-pill-
|
|
452
|
-
|
|
450
|
+
animation: ocpv2-pill-ring-turn 2.4s linear infinite;
|
|
451
|
+
}
|
|
452
|
+
.ocpv2-session-pill.ocpv2-pill-running {
|
|
453
|
+
border-color: transparent;
|
|
453
454
|
}
|
|
454
|
-
|
|
455
|
-
|
|
455
|
+
.ocpv2-session-pill.ocpv2-pill-running .ocpv2-pill-ring { display: block; }
|
|
456
|
+
@keyframes ocpv2-pill-ring-turn {
|
|
457
|
+
to { rotate: 360deg; }
|
|
456
458
|
}
|
|
457
459
|
.ocpv2-session-pill .term-minimized-pill-icon { color: rgba(232, 224, 220, 0.45); transition: color 0.2s; }
|
|
458
460
|
.ocpv2-session-pill.ocpv2-pill-running .term-minimized-pill-icon { color: rgba(232, 224, 220, 1); }
|
|
459
461
|
.ocpv2-session-pill:hover { border-color: rgba(232, 224, 220, 0.24); }
|
|
460
462
|
.ocpv2-session-pill:hover .term-minimized-pill-icon { color: rgba(232, 224, 220, 0.85); }
|
|
461
|
-
.ocpv2-session-pill:hover.ocpv2-pill-
|
|
463
|
+
.ocpv2-session-pill:hover .ocpv2-pill-ring > i {
|
|
462
464
|
background: conic-gradient(
|
|
463
|
-
from var(--ocpv2-pill-angle, 0deg),
|
|
464
465
|
rgba(232,224,220,0.0) 0%,
|
|
465
466
|
rgba(232,224,220,0.75) 25%,
|
|
466
467
|
rgba(232,224,220,0.20) 50%,
|
|
@@ -476,11 +477,11 @@ html.platform-win32 .ocpv2-session-pill.ocpv2-pill-running:hover,
|
|
|
476
477
|
html.desktop-titlebar--win32 .ocpv2-session-pill.ocpv2-pill-running:hover {
|
|
477
478
|
border-color: rgba(232, 224, 220, 0.58);
|
|
478
479
|
}
|
|
479
|
-
html.platform-win32 .ocpv2-session-pill.ocpv2-pill-running
|
|
480
|
-
html.desktop-titlebar--win32 .ocpv2-session-pill.ocpv2-pill-running
|
|
481
|
-
|
|
482
|
-
opacity: 0;
|
|
480
|
+
html.platform-win32 .ocpv2-session-pill.ocpv2-pill-running .ocpv2-pill-ring,
|
|
481
|
+
html.desktop-titlebar--win32 .ocpv2-session-pill.ocpv2-pill-running .ocpv2-pill-ring {
|
|
482
|
+
display: none;
|
|
483
483
|
}
|
|
484
|
+
body.ui-interacting .ocpv2-pill-ring > i { animation-play-state: paused; }
|
|
484
485
|
.ocpv2-session-pill.ocpv2-pill-running .term-minimized-pill-label::before {
|
|
485
486
|
content: '';
|
|
486
487
|
display: inline-block;
|
|
@@ -509,6 +510,12 @@ html.desktop-titlebar--win32 .ocpv2-session-pill.ocpv2-pill-running::before {
|
|
|
509
510
|
0%, 100% { opacity: 0.45; }
|
|
510
511
|
50% { opacity: 1; }
|
|
511
512
|
}
|
|
513
|
+
/* Reduced motion: the ring, the dot and the edge hold still (the working look stays). */
|
|
514
|
+
@media (prefers-reduced-motion: reduce) {
|
|
515
|
+
.ocpv2-pill-ring > i,
|
|
516
|
+
.ocpv2-session-pill.ocpv2-pill-running .term-minimized-pill-label::before,
|
|
517
|
+
.ocpv2-session-pill.ocpv2-pill-running::after { animation: none; }
|
|
518
|
+
}
|
|
512
519
|
|
|
513
520
|
/* Parent pill marker: sub-agent attached → arrow appears after the label.
|
|
514
521
|
Brightens + pulses when the child is actively running. Without this a
|
|
@@ -1309,12 +1316,44 @@ html.desktop-titlebar--win32 .ocpv2-session-pill.ocpv2-pill-running::before {
|
|
|
1309
1316
|
}
|
|
1310
1317
|
|
|
1311
1318
|
/* ── SynaBun-branded tool cards (OpenCode cream palette) ───────────────── */
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1319
|
+
/* ── Spinning border ring (a SynaBun tool card at work, the composer with focus) ──
|
|
1320
|
+
A conic gradient turning inside the 1px edge, the mask keeping only the ring. The gradient is a
|
|
1321
|
+
square box that turns (rotate, run by the compositor) under the mask, and only while its owner's
|
|
1322
|
+
state is on; an animated custom property (the old --ocpv2-sb-angle / --ocpv2-border-angle,
|
|
1323
|
+
@property + a conic gradient from it) restyled and repainted the owner on the main thread 60 times
|
|
1324
|
+
a second. The ring is a size container and the square 142cqmax + 4px, wider than the owner's
|
|
1325
|
+
diagonal at any shape, so what the mask shows is the same conic gradient at every angle. Markup:
|
|
1326
|
+
<span class="ocpv2-spin-ring" aria-hidden="true"><i></i></span>, the owner's first child. */
|
|
1327
|
+
.ocpv2-spin-ring {
|
|
1328
|
+
position: absolute;
|
|
1329
|
+
inset: 0;
|
|
1330
|
+
padding: 1px;
|
|
1331
|
+
overflow: hidden;
|
|
1332
|
+
pointer-events: none;
|
|
1333
|
+
container-type: size;
|
|
1334
|
+
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
|
|
1335
|
+
-webkit-mask-composite: xor;
|
|
1336
|
+
mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
|
|
1337
|
+
mask-composite: exclude;
|
|
1338
|
+
opacity: 0;
|
|
1339
|
+
transition: opacity 0.4s;
|
|
1340
|
+
}
|
|
1341
|
+
.ocpv2-spin-ring > i {
|
|
1342
|
+
position: absolute;
|
|
1343
|
+
left: 50%;
|
|
1344
|
+
top: 50%;
|
|
1345
|
+
width: calc(142cqmax + 4px);
|
|
1346
|
+
aspect-ratio: 1;
|
|
1347
|
+
translate: -50% -50%;
|
|
1348
|
+
}
|
|
1349
|
+
@keyframes ocpv2-spin-ring-turn {
|
|
1350
|
+
to { rotate: 360deg; }
|
|
1351
|
+
}
|
|
1352
|
+
body.ui-interacting .ocpv2-spin-ring > i { animation-play-state: paused !important; }
|
|
1353
|
+
/* Reduced motion: the ring holds still where the turn starts (the working / focus look stays). */
|
|
1354
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1355
|
+
.ocpv2-spin-ring > i { animation: none !important; will-change: auto !important; }
|
|
1316
1356
|
}
|
|
1317
|
-
@keyframes ocpv2-sb-spin { to { --ocpv2-sb-angle: 360deg; } }
|
|
1318
1357
|
|
|
1319
1358
|
.ocpv2-part-tool.ocpv2-tool-synabun {
|
|
1320
1359
|
position: relative;
|
|
@@ -1329,33 +1368,27 @@ html.desktop-titlebar--win32 .ocpv2-session-pill.ocpv2-pill-running::before {
|
|
|
1329
1368
|
.ocpv2-part-tool.ocpv2-tool-synabun[data-status="error"] {
|
|
1330
1369
|
border-left-color: rgba(220,140,140,0.5);
|
|
1331
1370
|
}
|
|
1332
|
-
.ocpv2-part-tool.ocpv2-tool-synabun
|
|
1333
|
-
content: '';
|
|
1334
|
-
position: absolute;
|
|
1335
|
-
inset: 0;
|
|
1371
|
+
.ocpv2-part-tool.ocpv2-tool-synabun > .ocpv2-spin-ring {
|
|
1336
1372
|
border-radius: 12px;
|
|
1337
|
-
|
|
1373
|
+
z-index: 1;
|
|
1374
|
+
}
|
|
1375
|
+
.ocpv2-part-tool.ocpv2-tool-synabun > .ocpv2-spin-ring > i {
|
|
1338
1376
|
background: conic-gradient(
|
|
1339
|
-
from var(--ocpv2-sb-angle, 0deg),
|
|
1340
1377
|
rgba(232,224,220,0.0) 0%,
|
|
1341
1378
|
rgba(232,224,220,0.35) 25%,
|
|
1342
1379
|
rgba(232,224,220,0.06) 50%,
|
|
1343
1380
|
rgba(232,224,220,0.35) 75%,
|
|
1344
1381
|
rgba(232,224,220,0.0) 100%
|
|
1345
1382
|
);
|
|
1346
|
-
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
|
|
1347
|
-
-webkit-mask-composite: xor;
|
|
1348
|
-
mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
|
|
1349
|
-
mask-composite: exclude;
|
|
1350
|
-
opacity: 0;
|
|
1351
|
-
transition: opacity 0.4s;
|
|
1352
|
-
pointer-events: none;
|
|
1353
|
-
z-index: 1;
|
|
1354
1383
|
}
|
|
1355
|
-
.ocpv2-part-tool.ocpv2-tool-synabun[data-status="running"]
|
|
1356
|
-
.ocpv2-part-tool.ocpv2-tool-synabun[data-status="pending"]
|
|
1384
|
+
.ocpv2-part-tool.ocpv2-tool-synabun[data-status="running"] > .ocpv2-spin-ring,
|
|
1385
|
+
.ocpv2-part-tool.ocpv2-tool-synabun[data-status="pending"] > .ocpv2-spin-ring {
|
|
1357
1386
|
opacity: 1;
|
|
1358
|
-
|
|
1387
|
+
}
|
|
1388
|
+
.ocpv2-part-tool.ocpv2-tool-synabun[data-status="running"] > .ocpv2-spin-ring > i,
|
|
1389
|
+
.ocpv2-part-tool.ocpv2-tool-synabun[data-status="pending"] > .ocpv2-spin-ring > i {
|
|
1390
|
+
animation: ocpv2-spin-ring-turn 3s linear infinite;
|
|
1391
|
+
will-change: rotate;
|
|
1359
1392
|
}
|
|
1360
1393
|
|
|
1361
1394
|
.ocpv2-tool-synabun .ocpv2-sb-head {
|
|
@@ -2105,15 +2138,7 @@ img.ocpv2-tool-screenshot {
|
|
|
2105
2138
|
cursor: zoom-in;
|
|
2106
2139
|
}
|
|
2107
2140
|
|
|
2108
|
-
/*
|
|
2109
|
-
@property --ocpv2-border-angle {
|
|
2110
|
-
syntax: '<angle>';
|
|
2111
|
-
initial-value: 0deg;
|
|
2112
|
-
inherits: false;
|
|
2113
|
-
}
|
|
2114
|
-
@keyframes ocpv2-border-spin {
|
|
2115
|
-
to { --ocpv2-border-angle: 360deg; }
|
|
2116
|
-
}
|
|
2141
|
+
/* Composer wrapper: a cream ring turns inside its edge on focus (the shared .ocpv2-spin-ring) */
|
|
2117
2142
|
.ocpv2-input-wrap {
|
|
2118
2143
|
flex: 1;
|
|
2119
2144
|
position: relative;
|
|
@@ -2124,30 +2149,20 @@ img.ocpv2-tool-screenshot {
|
|
|
2124
2149
|
min-width: 0;
|
|
2125
2150
|
overflow: hidden;
|
|
2126
2151
|
}
|
|
2127
|
-
.ocpv2-input-wrap
|
|
2128
|
-
|
|
2129
|
-
position: absolute; inset: 0;
|
|
2130
|
-
border-radius: 14px;
|
|
2131
|
-
padding: 1px;
|
|
2132
|
-
pointer-events: none;
|
|
2152
|
+
.ocpv2-input-wrap > .ocpv2-spin-ring { border-radius: 14px; }
|
|
2153
|
+
.ocpv2-input-wrap > .ocpv2-spin-ring > i {
|
|
2133
2154
|
background: conic-gradient(
|
|
2134
|
-
from var(--ocpv2-border-angle, 0deg),
|
|
2135
2155
|
rgba(232,224,220,0.0) 0%,
|
|
2136
2156
|
rgba(232,224,220,0.45) 25%,
|
|
2137
2157
|
rgba(232,224,220,0.10) 50%,
|
|
2138
2158
|
rgba(232,224,220,0.45) 75%,
|
|
2139
2159
|
rgba(232,224,220,0.0) 100%
|
|
2140
2160
|
);
|
|
2141
|
-
-webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
|
|
2142
|
-
-webkit-mask-composite: xor;
|
|
2143
|
-
mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
|
|
2144
|
-
mask-composite: exclude;
|
|
2145
|
-
opacity: 0;
|
|
2146
|
-
transition: opacity 0.4s;
|
|
2147
2161
|
}
|
|
2148
|
-
.ocpv2-input-wrap:focus-within
|
|
2149
|
-
|
|
2150
|
-
animation: ocpv2-
|
|
2162
|
+
.ocpv2-input-wrap:focus-within > .ocpv2-spin-ring { opacity: 1; }
|
|
2163
|
+
.ocpv2-input-wrap:focus-within > .ocpv2-spin-ring > i {
|
|
2164
|
+
animation: ocpv2-spin-ring-turn 3s linear infinite;
|
|
2165
|
+
will-change: rotate;
|
|
2151
2166
|
}
|
|
2152
2167
|
.ocpv2-input-wrap:focus-within {
|
|
2153
2168
|
background: rgba(232,224,220,0.04);
|
|
@@ -3346,7 +3361,8 @@ const PARITY_CSS = `
|
|
|
3346
3361
|
background: rgba(232,180,80,0.22);
|
|
3347
3362
|
box-shadow: 0 0 20px rgba(232,180,80,0.04);
|
|
3348
3363
|
}
|
|
3349
|
-
.ocpv2-input-wrap.ocpv2-shell-mode
|
|
3364
|
+
.ocpv2-input-wrap.ocpv2-shell-mode > .ocpv2-spin-ring { opacity: 0; }
|
|
3365
|
+
.ocpv2-input-wrap.ocpv2-shell-mode > .ocpv2-spin-ring > i { animation: none; will-change: auto; }
|
|
3350
3366
|
.ocpv2-input-wrap.ocpv2-shell-mode .ocpv2-input-inner::before {
|
|
3351
3367
|
content: '!';
|
|
3352
3368
|
align-self: center;
|
|
@@ -12,8 +12,8 @@ import { createOutcomeNotifications } from './ocp-v2-outcome-notifications.js';
|
|
|
12
12
|
import { getDefaultStore } from './ocp-v2-state.js';
|
|
13
13
|
import { notify as uiNotify, NOTIF_TYPE } from '../ui-notifications.js';
|
|
14
14
|
import { nativeLoopWindowId } from '../ui-native-window-id.js';
|
|
15
|
-
import { registerAutomationSession } from './ocp-v2-automation-ownership.js';
|
|
16
|
-
import { applyEvent, resolveEventTargets } from './ocp-v2-events.js';
|
|
15
|
+
import { registerAutomationSession, automationRunAnswersAsks } from './ocp-v2-automation-ownership.js';
|
|
16
|
+
import { applyEvent, resolveEventTargets, askNotifies } from './ocp-v2-events.js';
|
|
17
17
|
import { createCapabilities, gatedRequest } from './ocp-v2-caps.js';
|
|
18
18
|
import { shouldAutoAccept, autoAcceptRequest, autoAcceptInherited } from './ocp-v2-approvals.js';
|
|
19
19
|
import { verifyDescendant, descendantState, knownDescendant, createReconnectNotifier, requestOwner } from './ocp-v2-rehydrate.js';
|
|
@@ -535,6 +535,9 @@ const EVENT_HOOKS = {
|
|
|
535
535
|
onAsk(store, id, kind, ev) {
|
|
536
536
|
if (!id || _notifiedPermissionIds.has(id)) return;
|
|
537
537
|
_notifiedPermissionIds.add(id);
|
|
538
|
+
// A live automation answers its own session's permission asks by itself (a protected worker's
|
|
539
|
+
// OpenCode asks for every shell call): the card shows while the reply is out, nothing is announced.
|
|
540
|
+
if (!askNotifies(kind, ev, { runAnswers: automationRunAnswersAsks })) return;
|
|
538
541
|
// Auto-accept is the user's standing answer for this session: reply and
|
|
539
542
|
// stay quiet. A refused reply leaves the card up for them.
|
|
540
543
|
if (kind === 'permission' && shouldAutoAccept(autoAcceptEnabledFor(store), ev)) {
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
// ═══════════════════════════════════════════
|
|
2
|
+
// SynaBun Neural Interface — a page without the owner's access: what it is and what it says
|
|
3
|
+
// ═══════════════════════════════════════════
|
|
4
|
+
//
|
|
5
|
+
// SynaBun's automation browser (the one its browser tools drive) may open SynaBun's own page, by design: it reads it,
|
|
6
|
+
// clicks it and takes screenshots. It never gets the owner's page secret (GET /api/page-session answers 403
|
|
7
|
+
// WORKER_BROWSER), so every owner route refuses it (403 WORKER_BROWSER, PAGE_SECRET_REQUIRED, OWNER_ROUTE). That
|
|
8
|
+
// refusal is right and stays. What this module is for is the page's side of it: a refused read is not an empty list,
|
|
9
|
+
// a default value or an "Off" state, and the page says so in one way everywhere (ui-owner-access.js draws it: one
|
|
10
|
+
// banner, and a "No access" state in the panels whose data was refused, their Save and actions disabled).
|
|
11
|
+
//
|
|
12
|
+
// page-session.js (the page's fetch, wrapped once) tells every final refusal (`synabun:owner-access-refused`); the
|
|
13
|
+
// panels that read through their own paths ask `refusalOfError` / `refusalOfResponse` about what they got.
|
|
14
|
+
//
|
|
15
|
+
// No DOM: `node --test` loads this file (tests/owner-access.test.mjs). OWNER_ACCESS_COPY is the English of every
|
|
16
|
+
// sentence; `ownerAccess.*` in i18n/en.json must equal it and i18n/pt-BR.json must have the same keys.
|
|
17
|
+
|
|
18
|
+
import { OWNER_ACCESS_CODES } from './page-session.js';
|
|
19
|
+
|
|
20
|
+
export { OWNER_ACCESS_CODES };
|
|
21
|
+
|
|
22
|
+
export const OWNER_ACCESS_COPY = Object.freeze({
|
|
23
|
+
label: 'No owner access',
|
|
24
|
+
title: 'This page doesn\'t have owner access.',
|
|
25
|
+
bodyAutomation: 'It was opened from SynaBun\'s automation browser, which can read SynaBun\'s pages but not your settings, files or actions. Open SynaBun in your own browser or the desktop app.',
|
|
26
|
+
bodyOwner: 'SynaBun refused this page your settings and actions. Reload the page; if it persists, open SynaBun in your own browser or the desktop app.',
|
|
27
|
+
reload: 'Reload',
|
|
28
|
+
dismiss: 'Dismiss',
|
|
29
|
+
panelTitle: 'No access',
|
|
30
|
+
panelBody: 'This page doesn\'t have owner access, so this can\'t be shown or changed here. Open SynaBun in your own browser or the desktop app.',
|
|
31
|
+
navStatus: 'No access',
|
|
32
|
+
actionDisabled: 'Needs owner access',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
/** Why a page has no owner access: SynaBun's automation browser, or a refusal the page could not cure. */
|
|
36
|
+
export const OWNER_ACCESS_REASONS = Object.freeze(['automation', 'owner']);
|
|
37
|
+
|
|
38
|
+
/** The English of a key with its {values} filled; an unknown key is itself. */
|
|
39
|
+
export function ownerAccessText(key, params = {}) {
|
|
40
|
+
const template = OWNER_ACCESS_COPY[key];
|
|
41
|
+
if (typeof template !== 'string') return key;
|
|
42
|
+
return template.replace(/\{(\w+)\}/g, (whole, name) => (params[name] != null ? String(params[name]) : whole));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const reasonOf = (code) => (code === 'WORKER_BROWSER' ? 'automation' : 'owner');
|
|
46
|
+
|
|
47
|
+
/** A refusal from an answer's status and body: { code, reason } when it is a final owner refusal, else null. */
|
|
48
|
+
export function readOwnerAccessRefusal(status, body) {
|
|
49
|
+
if (Number(status) !== 403 || !body || typeof body !== 'object') return null;
|
|
50
|
+
const code = typeof body.code === 'string' ? body.code : null;
|
|
51
|
+
if (!code || !OWNER_ACCESS_CODES.includes(code)) return null;
|
|
52
|
+
return { code, reason: reasonOf(code) };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* The refusal an error (or a read result) stands for: api.js / asst-api.js errors carry `status` and `code` (and
|
|
57
|
+
* `body`), a pane's own reading `{ ok: false, status, code }` too. null for anything else (a network error, a 500…).
|
|
58
|
+
*/
|
|
59
|
+
export function refusalOfError(err) {
|
|
60
|
+
if (!err || typeof err !== 'object') return null;
|
|
61
|
+
const status = Number(err.status ?? err.statusCode);
|
|
62
|
+
const code = typeof err.code === 'string' ? err.code : (typeof err.body?.code === 'string' ? err.body.code : null);
|
|
63
|
+
return readOwnerAccessRefusal(status, { code });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The refusal a fetch Response stands for (its body read from a clone: the response is untouched). */
|
|
67
|
+
export async function refusalOfResponse(res) {
|
|
68
|
+
if (!res || Number(res.status) !== 403 || typeof res.clone !== 'function') return null;
|
|
69
|
+
try { return readOwnerAccessRefusal(res.status, await res.clone().json()); } catch { return null; }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* What the page knows about its own access: null (nothing refused, or restored since) or { code, reason, url, at }.
|
|
74
|
+
* Once SynaBun's automation browser is named (WORKER_BROWSER) the reason stays `automation` whatever comes after: that
|
|
75
|
+
* is the one that explains the rest. `subscribe(fn)` is told every change (fn(current)); returns the unsubscribe.
|
|
76
|
+
*/
|
|
77
|
+
export function createOwnerAccessState({ now = () => Date.now() } = {}) {
|
|
78
|
+
let current = null;
|
|
79
|
+
const listeners = new Set();
|
|
80
|
+
const tell = () => { for (const fn of [...listeners]) { try { fn(current); } catch { /* a listener's own error */ } } };
|
|
81
|
+
return {
|
|
82
|
+
current: () => current,
|
|
83
|
+
/** A refusal was seen (an event's detail or a refusal): true when what the page knows changed. */
|
|
84
|
+
note(detail) {
|
|
85
|
+
const code = typeof detail?.code === 'string' ? detail.code : null;
|
|
86
|
+
if (!code || !OWNER_ACCESS_CODES.includes(code)) return false;
|
|
87
|
+
const reason = current?.reason === 'automation' ? 'automation' : reasonOf(code);
|
|
88
|
+
if (current && current.reason === reason) return false;
|
|
89
|
+
current = { code, reason, url: typeof detail.url === 'string' ? detail.url : '', at: now() };
|
|
90
|
+
tell();
|
|
91
|
+
return true;
|
|
92
|
+
},
|
|
93
|
+
/** The page got this boot's page secret: it is the owner's again. */
|
|
94
|
+
clear() {
|
|
95
|
+
if (!current) return false;
|
|
96
|
+
current = null;
|
|
97
|
+
tell();
|
|
98
|
+
return true;
|
|
99
|
+
},
|
|
100
|
+
subscribe(fn) {
|
|
101
|
+
if (typeof fn !== 'function') return () => {};
|
|
102
|
+
listeners.add(fn);
|
|
103
|
+
return () => listeners.delete(fn);
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** A translator over OWNER_ACCESS_COPY: a key the page's translator does not know is English. */
|
|
109
|
+
export function ownerAccessSayer(t) {
|
|
110
|
+
return (key, params) => {
|
|
111
|
+
if (typeof t !== 'function') return ownerAccessText(key, params);
|
|
112
|
+
try {
|
|
113
|
+
const text = t(key, params);
|
|
114
|
+
return typeof text === 'string' && text && text !== key && !text.endsWith(`.${key}`) ? text : ownerAccessText(key, params);
|
|
115
|
+
} catch { return ownerAccessText(key, params); }
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* What the banner shows for what the page knows, or null (nothing refused).
|
|
121
|
+
* → { key, label, title, body, actions: [{ id: 'reload'|'dismiss', label }] }. `key` is what a dismissal is
|
|
122
|
+
* remembered by: the same reason stays dismissed.
|
|
123
|
+
*/
|
|
124
|
+
export function ownerAccessNoticeView(refusal, { t = null } = {}) {
|
|
125
|
+
if (!refusal || !OWNER_ACCESS_REASONS.includes(refusal.reason)) return null;
|
|
126
|
+
const say = ownerAccessSayer(t);
|
|
127
|
+
return {
|
|
128
|
+
key: `owner-access:${refusal.reason}`,
|
|
129
|
+
label: say('label'),
|
|
130
|
+
title: say('title'),
|
|
131
|
+
body: say(refusal.reason === 'automation' ? 'bodyAutomation' : 'bodyOwner'),
|
|
132
|
+
actions: [{ id: 'reload', label: say('reload') }, { id: 'dismiss', label: say('dismiss') }],
|
|
133
|
+
};
|
|
134
|
+
}
|