Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/extension/DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ other workspace resources or browser-control tools.

- Required browser capabilities: side panel, scripting, active tab, context menus,
and short-lived session storage for selection handoff. Required host access is
limited to the configured Sim origin.
limited to the configured Sim origin and to `http(s)://sim/*`, which exists only so
one static redirect rule can send a typed `sim/<name>` to the Sim link resolver.
- Other HTTP(S) origins are optional grants requested for the current site from a
user gesture. Each grant can be revoked. Keeping the panel open is not a grant
to read every subsequently selected tab.
Expand Down
3 changes: 2 additions & 1 deletion apps/extension/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ SIM_EXTENSION_DEV=1 SIM_EXTENSION_ORIGIN=http://localhost:3000 bun run --cwd app

## Data and permissions

- Required capabilities: `activeTab`, `scripting`, `sidePanel`, `storage`, `contextMenus`, and access to the configured Sim origin.
- Required capabilities: `activeTab`, `scripting`, `sidePanel`, `storage`, `contextMenus`, `declarativeNetRequestWithHostAccess`, and access to the configured Sim origin and to `http(s)://sim/*`.
- Typing `sim/<name>` in the address bar opens the organization's [Sim link](https://docs.sim.ai/search/sim-links). A single static redirect rule rewrites top-level navigations to `http(s)://sim/*` to `<Sim origin>/sim/*` with the path and query unchanged. The `sim` host permission exists only for that rule: every navigation to that host is redirected before it loads, and no other request is matched or observed. An organization that already serves an intranet host named `sim` should not install this build, since its links would be redirected to Sim.
- Optional HTTP/HTTPS site access is requested only by a menu action naming that site. Chrome's `activeTab` access is temporary and does not follow arbitrary new sites.
- Page capture runs on demand in Chrome's isolated world. It excludes editable fields, inputs, hidden elements, scripts, and embedded documents. It reads only the top frame. PDF viewers and canvas documents may have no accessible text.
- Extraction stops at 50,000 text characters, 150,000 serialized UTF-8 bytes, 15,000 visited nodes, or 150ms. The composer exposes truncation.
Expand Down
27 changes: 25 additions & 2 deletions apps/extension/scripts/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ for (const [size, file] of [
] as const) {
await cp(resolve(root, '../sim/public/favicon', file), resolve(dist, `icon-${size}.png`))
}
/**
* Chrome navigates a typed `sim/<name>` to `http://sim/<name>`; this rewrites it to the Sim link
* resolver on the configured origin, keeping the rest of the path and query verbatim.
*/
const simLinkRules = [
{
id: 1,
priority: 1,
action: { type: 'redirect', redirect: { regexSubstitution: `${origin.origin}/sim/\\1` } },
condition: { regexFilter: '^https?://sim/(.*)$', resourceTypes: ['main_frame'] },
},
]
await writeFile(resolve(dist, 'sim-links.json'), JSON.stringify(simLinkRules, null, 2))
await writeFile(
resolve(dist, 'manifest.json'),
JSON.stringify(
Expand All @@ -98,8 +111,18 @@ await writeFile(
description:
'Ask Sim about the page you are reading, with your existing Sim conversations and tools.',
minimum_chrome_version: '120',
permissions: ['activeTab', 'scripting', 'sidePanel', 'storage', 'contextMenus'],
host_permissions: [`${origin.origin}/*`],
permissions: [
'activeTab',
'scripting',
'sidePanel',
'storage',
'contextMenus',
'declarativeNetRequestWithHostAccess',
],
host_permissions: [`${origin.origin}/*`, 'http://sim/*', 'https://sim/*'],
declarative_net_request: {
rule_resources: [{ id: 'sim_links', enabled: true, path: 'sim-links.json' }],
},
optional_host_permissions: ['https://*/*', 'http://*/*'],
background: { service_worker: 'background.js' },
side_panel: { default_path: 'sidepanel.html' },
Expand Down
12 changes: 12 additions & 0 deletions apps/extension/scripts/test-e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,18 @@ try {
await app.waitForFunction((id) => document.body.dataset.barrierId === id, barrierId)
}

await check(
'A typed sim/ link opens the Sim link resolver on the configured origin',
async () => {
const tab = await page.context().newPage()
for (const path of ['handbook', 'jira/123?view=board']) {
await tab.goto(`http://sim/${path}`)
assert(tab.url() === `${origin}/sim/${path}`, `sim/${path} reached ${tab.url()}`)
}
await tab.close()
}
)

await check('Capture stays local until the trusted hosted frame is ready', async () => {
await capture()
await panel.getByRole('status').filter({ hasText: 'Waiting for Sim' }).waitFor()
Expand Down
Loading