@tangle-network/agent-app 1.0.25 → 2.0.0
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/dist/assistant/index.js +9 -9
- package/dist/catalog/index.js +1 -1
- package/dist/chat-react/index.js +6 -6
- package/dist/chat-routes/index.js +6 -6
- package/dist/{chunk-HWWER7G6.js → chunk-2ARZ4Y7D.js} +2 -2
- package/dist/{chunk-MM2GG3IX.js → chunk-4W6MDZQH.js} +3 -3
- package/dist/{chunk-SLXJZGXE.js → chunk-6CDNITEO.js} +3 -3
- package/dist/chunk-6CDNITEO.js.map +1 -0
- package/dist/{chunk-3VEXCVZB.js → chunk-6VRM2RVY.js} +3 -3
- package/dist/{chunk-GOPBMDCQ.js → chunk-7IVRHG3L.js} +5 -5
- package/dist/chunk-7IVRHG3L.js.map +1 -0
- package/dist/{chunk-XCUT52I3.js → chunk-GLZMHETS.js} +2 -2
- package/dist/chunk-GLZMHETS.js.map +1 -0
- package/dist/{chunk-MK7VUZU7.js → chunk-HFCPHY5D.js} +4 -4
- package/dist/{chunk-OZWHBH4T.js → chunk-HFWKZHTZ.js} +21 -5
- package/dist/chunk-HFWKZHTZ.js.map +1 -0
- package/dist/{chunk-VLMXVCDQ.js → chunk-KSLTD4FI.js} +8 -2
- package/dist/chunk-KSLTD4FI.js.map +1 -0
- package/dist/{chunk-K7HE6EM4.js → chunk-MS5S4IVF.js} +3 -3
- package/dist/{chunk-IQZSV5YG.js → chunk-PKBNDVGR.js} +15 -13
- package/dist/{chunk-IQZSV5YG.js.map → chunk-PKBNDVGR.js.map} +1 -1
- package/dist/{chunk-X7PYE5C5.js → chunk-RTJJYBVV.js} +2 -2
- package/dist/{chunk-RCSAAWOH.js → chunk-SUWAECFT.js} +2 -1
- package/dist/chunk-SUWAECFT.js.map +1 -0
- package/dist/{chunk-G37LZ2FN.js → chunk-UN3PDU3M.js} +2 -2
- package/dist/harness/index.js +1 -1
- package/dist/hosted-agent/react/index.js +1 -1
- package/dist/hosted-agent/react/index.js.map +1 -1
- package/dist/{mention-editor-HLEB37RK.js → mention-editor-XB4LGO3X.js} +3 -3
- package/dist/public-consultation/index.js +5 -5
- package/dist/runtime/index.js +5 -3
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/model-catalog.d.ts +5 -0
- package/dist/runtime/router-turn.js +2 -2
- package/dist/sandbox/index.js +2 -2
- package/dist/sandbox/prompt-profile.d.ts +1 -1
- package/dist/settings-react/index.js +148 -95
- package/dist/settings-react/index.js.map +1 -1
- package/dist/skills-placement/box.js +2 -2
- package/dist/skills-placement/index.js +2 -2
- package/dist/studio-react/index.js +2 -2
- package/dist/teams/index.d.ts +2 -2
- package/dist/teams-react/components/index.d.ts +0 -2
- package/dist/teams-react/components/invitation-detail.d.ts +1 -1
- package/dist/teams-react/components/member-access.d.ts +2 -2
- package/dist/teams-react/contracts.d.ts +3 -68
- package/dist/teams-react/index.d.ts +5 -6
- package/dist/teams-react/index.js +46 -335
- package/dist/teams-react/index.js.map +1 -1
- package/dist/web-react/agent-profile-editor.js +6 -6
- package/dist/web-react/agent-session-controls.d.ts +6 -4
- package/dist/web-react/effort-picker.d.ts +7 -6
- package/dist/web-react/index.js +9 -9
- package/dist/web-react/picker-presentation.d.ts +2 -2
- package/dist/workspace-react/index.js +4 -4
- package/package.json +3 -3
- package/dist/chunk-GOPBMDCQ.js.map +0 -1
- package/dist/chunk-OZWHBH4T.js.map +0 -1
- package/dist/chunk-RCSAAWOH.js.map +0 -1
- package/dist/chunk-SLXJZGXE.js.map +0 -1
- package/dist/chunk-VLMXVCDQ.js.map +0 -1
- package/dist/chunk-XCUT52I3.js.map +0 -1
- package/dist/chunk-YL5JDX7K.js +0 -70
- package/dist/chunk-YL5JDX7K.js.map +0 -1
- package/dist/stories/settings/team-panels-demo.d.ts +0 -21
- package/dist/teams-react/components/InvitationsPanel.d.ts +0 -13
- package/dist/teams-react/components/InviteForm.d.ts +0 -20
- package/dist/teams-react/components/MembersPanel.d.ts +0 -18
- /package/dist/{chunk-HWWER7G6.js.map → chunk-2ARZ4Y7D.js.map} +0 -0
- /package/dist/{chunk-MM2GG3IX.js.map → chunk-4W6MDZQH.js.map} +0 -0
- /package/dist/{chunk-3VEXCVZB.js.map → chunk-6VRM2RVY.js.map} +0 -0
- /package/dist/{chunk-MK7VUZU7.js.map → chunk-HFCPHY5D.js.map} +0 -0
- /package/dist/{chunk-K7HE6EM4.js.map → chunk-MS5S4IVF.js.map} +0 -0
- /package/dist/{chunk-X7PYE5C5.js.map → chunk-RTJJYBVV.js.map} +0 -0
- /package/dist/{chunk-G37LZ2FN.js.map → chunk-UN3PDU3M.js.map} +0 -0
- /package/dist/{mention-editor-HLEB37RK.js.map → mention-editor-XB4LGO3X.js.map} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hosted-agent/react/LineSetup.tsx","../../../src/hosted-agent/react/LineMembers.tsx","../../../src/hosted-agent/react/LineBilling.tsx","../../../src/hosted-agent/react/ApplicationLineSetup.tsx","../../../src/hosted-agent/react/SharedLineAppNotice.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport type { Line } from '@tangle-network/sandbox'\nimport type {\n LineBoxMode, LineConnectInput, LineConnectionOption, LineIdentityKind, LineIdentityOption,\n LineSetupLine, LineSetupProps, LineSetupSnapshot,\n} from './contracts'\n\nconst useBrowserLayoutEffect = typeof document !== 'undefined' ? useLayoutEffect : useEffect\n\nconst TRANSPORT: Record<Line['transport'], string> = {\n imessage: 'iMessage', sms: 'SMS', whatsapp: 'WhatsApp', email: 'Email', telegram: 'Telegram', voice: 'Voice',\n}\nconst IDENTITY: Record<LineIdentityKind, string> = {\n handle: 'Handle', number: 'Dedicated number', email: 'Email line',\n}\n\ntype Choice = { key: string; connection: LineConnectionOption; identity: LineIdentityOption }\n\nfunction LineMessageAction({ line }: { line: LineSetupLine }) {\n if (line.transport !== 'imessage' || line.targetId === null || line.status !== 'active') return null\n if (!!line.connect !== !!line.routerAddress) return null\n const shared = !!line.connect && !!line.routerAddress\n const number = shared ? line.routerAddress : line.address\n if (!number || !/^\\+[1-9]\\d{7,14}$/.test(number)) return null\n return <a className=\"tangle-lines__primary tangle-lines__message-action\" href={`sms:${number}?body=${encodeURIComponent(shared ? line.connect ?? '' : 'Hello')}`}>\n {shared ? 'Connect iMessage' : 'Text it now'}\n </a>\n}\n\nfunction message(error: unknown): string {\n return error instanceof Error ? error.message : 'The line request failed. Try again.'\n}\n\nfunction dateTime(value: string): string {\n const date = new Date(value)\n return Number.isNaN(date.getTime()) ? value : date.toLocaleString()\n}\n\nfunction choicesFor(snapshot: LineSetupSnapshot): Choice[] {\n return (snapshot.connections ?? []).flatMap(connection => connection.identities.map((identity, index) => ({\n key: `${connection.id}:${index}`,\n connection,\n identity,\n })))\n}\n\nfunction requiresNumber(identity: LineIdentityOption): boolean {\n return identity.transport === 'whatsapp' || identity.transport === 'sms' || identity.transport === 'voice' || identity.requiresPhoneNumberId === true\n}\n\n/** A line answering through the shared router number is the free shared entry;\n * a line with its own address is a dedicated number. */\nfunction isSharedEntry(line: LineSetupLine): boolean {\n return Boolean(line.connect && line.routerAddress)\n}\n\nfunction canOfferReconnect(line: LineSetupLine, choice: Choice): boolean {\n if (line.connectionId !== choice.connection.id || line.transport !== choice.identity.transport || line.targetId !== null) return false\n if (line.providerNumberId === null) return !choice.identity.phoneNumberId && !requiresNumber(choice.identity)\n return choice.identity.phoneNumberId === line.providerNumberId ||\n (!choice.identity.phoneNumberId && requiresNumber(choice.identity))\n}\n\nfunction matchesLineIdentity(line: LineSetupLine, identity: LineIdentityOption, numberId: string): boolean {\n if (line.transport !== identity.transport) return false\n if (line.providerNumberId === null) return !identity.phoneNumberId && !requiresNumber(identity)\n return numberId === line.providerNumberId\n}\n\n/** Set up an owned identity through a host route backed by sandbox.lines and Hub. */\nexport function LineSetup({ client, scopeKey, initialTargetId, targetLabel, canManage, canConnect = canManage, showConnectionSetup = true, connectPrerequisite, setupDescription, emptyConnectionsMessage, dedicatedUpgrade, onNotice }: LineSetupProps) {\n const clientRef = useRef(client)\n clientRef.current = client\n const sequence = useRef(0)\n const incarnation = useRef(0)\n const confirmButton = useRef<HTMLButtonElement>(null)\n const heading = useRef<HTMLHeadingElement>(null)\n const setupHeading = useRef<HTMLHeadingElement>(null)\n const disconnectTriggers = useRef(new Map<string, HTMLButtonElement>())\n const restoreFocusTo = useRef<string | null>(null)\n useBrowserLayoutEffect(() => {\n incarnation.current++\n return () => { incarnation.current++ }\n }, [scopeKey, initialTargetId])\n const [loadedSnapshot, setLoadedSnapshot] = useState<{ scopeKey: string; initialTargetId: string | undefined; value: LineSetupSnapshot } | null>(null)\n const snapshot = loadedSnapshot?.scopeKey === scopeKey && loadedSnapshot.initialTargetId === initialTargetId ? loadedSnapshot.value : null\n const [loading, setLoading] = useState(true)\n const [refreshFailed, setRefreshFailed] = useState(false)\n const [busy, setBusy] = useState(false)\n const [error, setError] = useState<string | null>(null)\n const [kind, setKind] = useState<LineIdentityKind>('handle')\n const [choiceKey, setChoiceKey] = useState('')\n const [targetId, setTargetId] = useState(initialTargetId ?? '')\n const [boxMode, setBoxMode] = useState<LineBoxMode>('per-member')\n const [phoneNumberId, setPhoneNumberId] = useState('')\n const [confirmation, setConfirmation] = useState<{ lineId: string; attachmentId: string | undefined } | null>(null)\n const confirmLineId = confirmation?.lineId ?? null\n\n function stillCurrent(requestIncarnation: number): boolean {\n return requestIncarnation === incarnation.current\n }\n\n async function reload(requestIncarnation: number): Promise<LineSetupSnapshot | null> {\n const request = ++sequence.current\n try {\n const next = await clientRef.current.load()\n if (request !== sequence.current || !stillCurrent(requestIncarnation)) return null\n setLoadedSnapshot({ scopeKey, initialTargetId, value: next })\n setError(null)\n setRefreshFailed(false)\n setTargetId(current => next.targets.some(target => target.id === current)\n ? current : next.targets.find(target => target.id === initialTargetId)?.id ?? next.targets[0]?.id ?? '')\n setLoading(false)\n return next\n } catch (cause) {\n if (request !== sequence.current || !stillCurrent(requestIncarnation)) return null\n setError(message(cause))\n setRefreshFailed(true)\n setLoading(false)\n return null\n }\n }\n\n function retry() {\n if (loading) return\n setLoading(true)\n void reload(incarnation.current)\n }\n\n function closeConfirmation(lineId: string) {\n restoreFocusTo.current = lineId\n setConfirmation(null)\n }\n\n useEffect(() => {\n setLoading(true)\n setLoadedSnapshot(null)\n setError(null)\n setRefreshFailed(false)\n setBusy(false)\n setKind('handle')\n setChoiceKey('')\n setTargetId(initialTargetId ?? '')\n setBoxMode('per-member')\n setPhoneNumberId('')\n setConfirmation(null)\n restoreFocusTo.current = null\n void reload(incarnation.current)\n return () => { sequence.current++ }\n }, [scopeKey, initialTargetId])\n\n useEffect(() => {\n if (confirmLineId) confirmButton.current?.focus()\n }, [confirmLineId])\n\n useEffect(() => {\n const lineId = restoreFocusTo.current\n if (confirmLineId !== null || lineId === null) return\n restoreFocusTo.current = null\n const trigger = disconnectTriggers.current.get(lineId)\n if (trigger && !trigger.disabled) trigger.focus()\n else (heading.current ?? setupHeading.current)?.focus()\n }, [confirmLineId, snapshot, refreshFailed])\n\n const allChoices = snapshot ? choicesFor(snapshot) : []\n const choices = snapshot ? allChoices.filter(choice => {\n const occupied = snapshot.lines.filter(line => line.status !== 'released' && line.transport === choice.identity.transport)\n const [line] = occupied\n return occupied.length === 0 || (occupied.length === 1 && line !== undefined && canOfferReconnect(line, choice))\n }) : []\n const availableKinds = (['handle', 'number', 'email'] as const).filter(value => choices.some(choice => choice.identity.kind === value))\n const selectedKind = availableKinds.includes(kind) ? kind : availableKinds[0]\n const kindChoices = choices.filter(choice => choice.identity.kind === selectedKind)\n const selected = kindChoices.find(choice => choice.key === choiceKey) ?? kindChoices[0]\n const visibleLines = snapshot?.lines.filter(line => line.status !== 'released') ?? []\n const showSetup = Boolean(snapshot && canManage && showConnectionSetup &&\n (snapshot.connections === null || choices.length > 0 || allChoices.length === 0))\n const showExisting = snapshot ? visibleLines.length > 0 || !showSetup : !(canManage && showConnectionSetup)\n const hasSeveralChoices = availableKinds.length > 1 || kindChoices.length > 1 || (snapshot?.targets.length ?? 0) > 1\n const SetupHeading = showExisting ? 'h3' : 'h2'\n const selectedTarget = snapshot?.targets.find(target => target.id === targetId)\n const selectedMode = selectedTarget?.modes.includes(boxMode) ? boxMode : selectedTarget?.modes[0]\n const enteredNumber = (selected?.identity.phoneNumberId ?? phoneNumberId).trim()\n const needsNumber = selected && requiresNumber(selected.identity)\n const occupied = selected && snapshot?.lines.filter(line => line.status !== 'released' && line.transport === selected.identity.transport)\n const [occupiedLine] = occupied || []\n const reconnectChoice = Boolean(selected && occupied?.length === 1 && occupiedLine && canOfferReconnect(occupiedLine, selected))\n const reconnecting = Boolean(reconnectChoice && selected && occupiedLine &&\n matchesLineIdentity(occupiedLine, selected.identity, enteredNumber))\n const blockedByExistingLine = Boolean(occupied?.length && !reconnecting)\n const answeringCount = snapshot?.lines.filter(line => line.answering).length ?? 0\n const draft: LineConnectInput | null = selected && selectedTarget && selectedMode\n ? {\n connectionId: selected.connection.id,\n transport: selected.identity.transport,\n ...(enteredNumber ? { phoneNumberId: enteredNumber } : {}),\n targetId: selectedTarget.id,\n boxMode: selectedMode,\n } : null\n const prerequisite = draft ? connectPrerequisite?.(draft) : null\n const connectReady = Boolean(canManage && canConnect && draft && (prerequisite?.ready ?? true)\n && !(needsNumber && !enteredNumber) && !blockedByExistingLine && !busy && !loading && !refreshFailed)\n\n async function connect() {\n if (!connectReady || !draft || !selected) return\n const requestIncarnation = incarnation.current\n setBusy(true)\n setError(null)\n try {\n await clientRef.current.connect(draft)\n if (!stillCurrent(requestIncarnation)) return\n const updated = await reload(requestIncarnation)\n if (!stillCurrent(requestIncarnation)) return\n if (!updated) {\n onNotice?.({ kind: 'error', message: 'Line connected, but its current status could not be loaded.' })\n return\n }\n const line = updated.lines.find(item => item.status !== 'released' && item.connectionId === selected.connection.id &&\n item.transport === selected.identity.transport && item.providerNumberId === (enteredNumber || null))\n onNotice?.({ kind: 'success', message: line?.answering ? 'The line is answering.' : selected.identity.transport === 'voice'\n ? 'Voice line connected. Configure calls and verify prior member consent in your host.'\n : 'Line connected. Add a member to start answers.' })\n } catch (cause) {\n if (!stillCurrent(requestIncarnation)) return\n const detail = message(cause)\n setError(detail)\n onNotice?.({ kind: 'error', message: detail })\n } finally {\n if (stillCurrent(requestIncarnation)) setBusy(false)\n }\n }\n\n async function disconnect() {\n if (!confirmation || busy || loading || refreshFailed) return\n const { lineId, attachmentId: expectedAttachmentId } = confirmation\n const requestIncarnation = incarnation.current\n setBusy(true)\n setError(null)\n try {\n await clientRef.current.disconnect(lineId, expectedAttachmentId)\n if (!stillCurrent(requestIncarnation)) return\n const updated = await reload(requestIncarnation)\n if (!stillCurrent(requestIncarnation)) return\n closeConfirmation(lineId)\n onNotice?.(updated\n ? { kind: 'success', message: 'The line stopped answering.' }\n : { kind: 'error', message: 'Line disconnected, but its current status could not be loaded.' })\n } catch (cause) {\n if (!stillCurrent(requestIncarnation)) return\n const detail = message(cause)\n setError(detail)\n onNotice?.({ kind: 'error', message: detail })\n } finally {\n if (stillCurrent(requestIncarnation)) setBusy(false)\n }\n }\n\n return <section className=\"tangle-lines\" aria-label=\"Agent lines\">\n {showExisting && <header className=\"tangle-lines__heading\">\n <div>\n <h2 ref={heading} tabIndex={-1}>Lines</h2>\n {snapshot && <p>{snapshot.workspaceName} can use one line per transport.</p>}\n </div>\n {answeringCount > 1 && <span className=\"tangle-lines__count\">{answeringCount} answering</span>}\n </header>}\n\n {error && <div className=\"tangle-lines__error\" role=\"alert\">\n <div><strong>{refreshFailed ? 'Lines are unavailable' : 'Line action failed'}</strong><p>{error}</p></div>\n {(!snapshot || refreshFailed) && <button type=\"button\" disabled={loading} onClick={retry}>Retry</button>}\n </div>}\n {loading && <p className=\"tangle-lines__muted\" role=\"status\">Loading lines…</p>}\n\n {snapshot && <>\n {showExisting && <div className=\"tangle-lines__list\">\n {visibleLines.length === 0 &&\n <div className=\"tangle-lines__empty\"><strong>No lines connected</strong><p>{canManage && showConnectionSetup\n ? 'Connect an owned identity below to let this workspace answer messages.'\n : 'There are no connected lines in this workspace.'}</p></div>}\n {visibleLines.map(line =>\n <div className=\"tangle-lines__row\" key={line.id}>\n <div className=\"tangle-lines__row-main\">\n <div className=\"tangle-lines__row-heading\"><span className=\"tangle-lines__transport\">{TRANSPORT[line.transport]}</span>{isSharedEntry(line) && <span className=\"tangle-lines__entry-kind\">Free shared number</span>}<span className={`tangle-lines__status${line.answering ? ' tangle-lines__status--answering' : ''}`}>{line.answering ? 'Answering' : line.targetId === null ? 'Disconnected' : line.status === 'active' ? line.transport === 'voice' ? 'Not answering' : 'Awaiting member' : line.status}</span></div>\n <strong>{line.address}</strong>\n {line.transport === 'imessage' && line.connect && line.routerAddress && line.targetId !== null && <p>Send <code>{line.connect}</code> to {line.routerAddress}. Then message the number Inkbox sends you.</p>}\n <LineMessageAction line={line} />\n {isSharedEntry(line) && line.targetId !== null && <p className=\"tangle-lines__answering-app\" role=\"status\">{line.answering && line.targetLabel\n ? `${line.targetLabel} answers this shared number.`\n : 'No app answers this shared number yet.'}</p>}\n {isSharedEntry(line) && dedicatedUpgrade && line.targetId !== null\n && <a className=\"tangle-lines__secondary\" href={dedicatedUpgrade.href}>{dedicatedUpgrade.label ?? 'Upgrade to a dedicated number'}</a>}\n <p>{line.targetLabel ?? 'No agent or box assigned'}{line.boxMode && ` · ${line.boxMode === 'per-member' ? 'one box per member' : 'shared box'}`}</p>\n {line.lastTurn.kind === 'latest' ? <p>Last turn: {line.lastTurn.status} · {dateTime(line.lastTurn.at)}</p>\n : <p>{line.lastTurn.kind === 'none' ? 'No turns yet.' : 'Turn history unavailable.'}</p>}\n </div>\n {canManage && line.canDisconnect && line.targetId !== null && line.status === 'active' && <div className=\"tangle-lines__row-actions\">\n {confirmLineId === line.id ? <div className=\"tangle-lines__confirm\" role=\"group\" aria-label={`Disconnect ${line.address}?`}>\n <span>Disconnect this line?</span>\n <button ref={confirmButton} type=\"button\" className=\"tangle-lines__danger\" disabled={busy || loading || refreshFailed} onClick={() => void disconnect()}>Disconnect</button>\n <button type=\"button\" disabled={busy} onClick={() => closeConfirmation(line.id)}>Keep line</button>\n </div> : <button ref={node => { if (node) disconnectTriggers.current.set(line.id, node); else disconnectTriggers.current.delete(line.id) }} type=\"button\" className=\"tangle-lines__quiet\" disabled={busy || loading || refreshFailed} onClick={() => setConfirmation({ lineId: line.id, attachmentId: line.attachmentId ?? undefined })}>Disconnect line</button>}\n </div>}\n </div>)}\n </div>}\n\n {showSetup && <div className={`tangle-lines__setup${showExisting ? '' : ' tangle-lines__setup--first'}`}>\n <SetupHeading ref={setupHeading} tabIndex={-1}>Connect a line</SetupHeading>\n {hasSeveralChoices && setupDescription && <p>{setupDescription}</p>}\n {snapshot.connections === null ? <div className=\"tangle-lines__error\" role=\"status\">\n <span>Hub connections could not be read. Check Hub access and try again.</span>\n <button type=\"button\" disabled={loading} onClick={retry}>Retry</button>\n </div>\n : availableKinds.length === 0 ? <p className=\"tangle-lines__empty\">\n {emptyConnectionsMessage ?? 'Connect an owned handle, number, or mailbox in Hub, then'} <button type=\"button\" disabled={loading} onClick={retry}>reload</button>.\n </p>\n : <>\n {availableKinds.length > 1 && <div className=\"tangle-lines__kinds\" role=\"group\" aria-label=\"Identity type\">\n {availableKinds.map(value => <button key={value} type=\"button\" aria-pressed={selectedKind === value} onClick={() => { setKind(value); setChoiceKey(''); setPhoneNumberId('') }}>{IDENTITY[value]}</button>)}\n </div>}\n <div className=\"tangle-lines__fields\">\n {kindChoices.length > 1 ? <label>Line\n <select value={selected?.key ?? ''} onChange={event => { setChoiceKey(event.target.value); setPhoneNumberId('') }}>\n {kindChoices.map(choice => <option key={choice.key} value={choice.key}>{choice.identity.label} · {TRANSPORT[choice.identity.transport]} via {choice.connection.label}</option>)}\n </select>\n </label> : selected && <div className=\"tangle-lines__fixed-choice\">\n <span>Line</span>\n <strong>{selected.identity.label}</strong>\n <small>{TRANSPORT[selected.identity.transport]} via {selected.connection.label}</small>\n </div>}\n {snapshot.targets.length > 1 ? <label>{targetLabel ?? 'Agent or box'}\n <select value={selectedTarget?.id ?? ''} onChange={event => setTargetId(event.target.value)}>\n {snapshot.targets.map(target => <option key={target.id} value={target.id}>{target.label}{targetLabel ? '' : ` · ${target.kind}`}</option>)}\n </select>\n </label> : selectedTarget && <div className=\"tangle-lines__fixed-choice\">\n <span>{targetLabel ?? 'Agent or box'}</span>\n <strong>{selectedTarget.label}{targetLabel ? '' : ` · ${selectedTarget.kind}`}</strong>\n </div>}\n {selectedTarget && selectedTarget.modes.length > 1 && <fieldset>\n <legend>Conversation space</legend>\n <label><input type=\"radio\" name={`line-box-mode-${scopeKey}`} value=\"per-member\" checked={selectedMode === 'per-member'} disabled={!selectedTarget?.modes.includes('per-member')} onChange={() => setBoxMode('per-member')} /> One box per member</label>\n <label><input type=\"radio\" name={`line-box-mode-${scopeKey}`} value=\"shared\" checked={selectedMode === 'shared'} disabled={!selectedTarget?.modes.includes('shared')} onChange={() => setBoxMode('shared')} /> Shared box for a team</label>\n </fieldset>}\n {needsNumber && !selected?.identity.phoneNumberId && <label>Existing provider number ID\n <input value={phoneNumberId} onChange={event => setPhoneNumberId(event.target.value)} autoComplete=\"off\" placeholder=\"Number ID from Hub\" />\n </label>}\n </div>\n {reconnectChoice && blockedByExistingLine && <p className=\"tangle-lines__warning\">Enter this line's current provider number ID to reconnect.</p>}\n {prerequisite?.content}\n <button className=\"tangle-lines__primary\" type=\"button\" disabled={!connectReady} onClick={() => void connect()}>\n {busy ? (reconnectChoice ? 'Reconnecting…' : 'Connecting…') : `${reconnectChoice ? 'Reconnect' : 'Connect'} ${selected ? TRANSPORT[selected.identity.transport] : 'line'}`}\n </button>\n </>}\n </div>}\n </>}\n </section>\n}\n","import { useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport type { LineMember } from '@tangle-network/sandbox'\nimport type { LineMembersProps } from './contracts'\n\nconst useBrowserLayoutEffect = typeof document !== 'undefined' ? useLayoutEffect : useEffect\n\nconst STATUS: Record<LineMember['status'], { label: string; detail: string }> = {\n invited: { label: 'Awaiting consent', detail: 'The first message from this address confirms consent.' },\n active: { label: 'Consented', detail: 'This member has sent a message to the line.' },\n stopped: { label: 'Stopped', detail: 'The member texted STOP. Only a message from them with START resumes replies.' },\n removed: { label: 'Removed', detail: 'This address no longer has access to the line.' },\n}\n\nfunction errorMessage(cause: unknown): string {\n return cause instanceof Error ? cause.message : 'The member request failed. Try again.'\n}\n\n/** Manage Hub line members while keeping consent and STOP authority with the sender. */\nexport function LineMembers({ lineId, scopeKey, client, roles, canManage, canAdd = true, maxMembers, allowRoleChange = true, allowRemoveLastOwner = false, onNotice }: LineMembersProps) {\n const clientRef = useRef(client)\n clientRef.current = client\n const sequence = useRef(0)\n const incarnation = useRef(0)\n const confirmButton = useRef<HTMLButtonElement>(null)\n const heading = useRef<HTMLHeadingElement>(null)\n const removeTriggers = useRef(new Map<string, HTMLButtonElement>())\n const restoreFocusTo = useRef<string | null>(null)\n useBrowserLayoutEffect(() => {\n incarnation.current++\n return () => { incarnation.current++ }\n }, [lineId, scopeKey])\n const [memberSnapshot, setMemberSnapshot] = useState<{ lineId: string; scopeKey: string; members: LineMember[] } | null>(null)\n const [error, setError] = useState<string | null>(null)\n const [refreshFailed, setRefreshFailed] = useState(false)\n const [address, setAddress] = useState('')\n const [label, setLabel] = useState('')\n const [role, setRole] = useState('member')\n const [busy, setBusy] = useState<string | null>(null)\n const [confirmId, setConfirmId] = useState<string | null>(null)\n const members = memberSnapshot?.lineId === lineId && memberSnapshot.scopeKey === scopeKey ? memberSnapshot.members : null\n\n function stillCurrent(requestIncarnation: number): boolean {\n return requestIncarnation === incarnation.current\n }\n\n async function reload(requestIncarnation: number): Promise<boolean> {\n const request = ++sequence.current\n try {\n const next = await clientRef.current.list(lineId)\n if (request !== sequence.current || !stillCurrent(requestIncarnation)) return false\n setMemberSnapshot({ lineId, scopeKey, members: next })\n setError(null)\n setRefreshFailed(false)\n return true\n } catch (cause) {\n if (request !== sequence.current || !stillCurrent(requestIncarnation)) return false\n setError(errorMessage(cause))\n setRefreshFailed(true)\n return false\n }\n }\n\n async function retry() {\n if (busy) return\n const requestIncarnation = incarnation.current\n setBusy('refresh')\n try { await reload(requestIncarnation) }\n finally { if (stillCurrent(requestIncarnation)) setBusy(null) }\n }\n\n function closeConfirmation(memberId: string) {\n restoreFocusTo.current = memberId\n setConfirmId(null)\n }\n\n useEffect(() => {\n setMemberSnapshot(null)\n setError(null)\n setRefreshFailed(false)\n setAddress('')\n setLabel('')\n setRole('member')\n setConfirmId(null)\n restoreFocusTo.current = null\n setBusy(null)\n void reload(incarnation.current)\n return () => { sequence.current++ }\n }, [lineId, scopeKey])\n\n useEffect(() => {\n if (confirmId) confirmButton.current?.focus()\n }, [confirmId])\n\n useEffect(() => {\n const memberId = restoreFocusTo.current\n if (confirmId !== null || memberId === null) return\n restoreFocusTo.current = null\n const trigger = removeTriggers.current.get(memberId)\n if (trigger && !trigger.disabled) trigger.focus()\n else heading.current?.focus()\n }, [confirmId, members, refreshFailed])\n\n const selectedRole = roles.some(item => item.value === role) ? role : roles.find(item => item.value === 'member')?.value ?? roles[0]?.value ?? ''\n const activeMembers = members?.filter(member => member.status !== 'removed').length ?? 0\n const activeOwners = members?.filter(member => member.role === 'owner' && member.status !== 'removed').length ?? 0\n\n async function mutate(key: string, action: () => Promise<void>, success: string, onSuccess?: () => void) {\n if (busy || refreshFailed) return\n const requestIncarnation = incarnation.current\n setBusy(key)\n setError(null)\n try {\n await action()\n if (!stillCurrent(requestIncarnation)) return\n const refreshed = await reload(requestIncarnation)\n if (!stillCurrent(requestIncarnation)) return\n onSuccess?.()\n onNotice?.(refreshed\n ? { kind: 'success', message: success }\n : { kind: 'error', message: 'Member updated, but the current member list could not be loaded.' })\n } catch (cause) {\n if (!stillCurrent(requestIncarnation)) return\n const detail = errorMessage(cause)\n setError(detail)\n onNotice?.({ kind: 'error', message: detail })\n } finally {\n if (stillCurrent(requestIncarnation)) setBusy(null)\n }\n }\n\n function add() {\n const trimmed = address.trim()\n if (!trimmed || !selectedRole || members === null || (maxMembers !== undefined && activeMembers >= maxMembers)) return\n void mutate('add', () => clientRef.current.add(lineId, { address: trimmed, role: selectedRole, ...(label.trim() ? { label: label.trim() } : {}) }), 'Member invited. Their first message confirms consent.', () => {\n setAddress('')\n setLabel('')\n })\n }\n\n return <section className=\"tangle-lines\" aria-label=\"Line members\">\n <header className=\"tangle-lines__heading\">\n <div><h2 ref={heading} tabIndex={-1}>Members</h2><p>Each address controls its own consent and STOP state.</p></div>\n {members && <span className=\"tangle-lines__count\">{activeMembers} {activeMembers === 1 ? 'member' : 'members'}</span>}\n </header>\n {error && <div className=\"tangle-lines__error\" role=\"alert\">\n <span>{error}</span>\n {(members === null || refreshFailed) && <button type=\"button\" disabled={busy !== null} onClick={() => void retry()}>Retry</button>}\n </div>}\n {members === null ? !error && <p className=\"tangle-lines__muted\" role=\"status\">Loading members…</p> : <div className=\"tangle-lines__list\">\n {members.length === 0 && <p className=\"tangle-lines__empty\">{canAdd ? 'No members yet. Invite an address that you own or have permission to add.' : 'No members yet.'}</p>}\n {members.map(member => {\n const lastOwner = member.role === 'owner' && activeOwners <= 1\n const editable = canManage && member.status !== 'removed' && (!lastOwner || allowRemoveLastOwner)\n return <div className=\"tangle-lines__row\" key={member.id}>\n <div className=\"tangle-lines__row-main\">\n <span className={`tangle-lines__state tangle-lines__state--${member.status}`}>{STATUS[member.status].label}</span>\n <strong>{member.label || member.address}</strong>\n {member.label && <p>{member.address}</p>}\n <p>{STATUS[member.status].detail}</p>\n </div>\n <div className=\"tangle-lines__row-actions\">\n {editable ? <>\n {allowRoleChange && !lastOwner ? <label className=\"tangle-lines__compact-label\">Role\n <select value={member.role} disabled={busy !== null || refreshFailed} onChange={event => void mutate(member.id, () => clientRef.current.update(lineId, member.id, { role: event.target.value }), 'Role updated.')}>\n {!roles.some(item => item.value === member.role) && <option value={member.role}>{member.role}</option>}\n {roles.map(item => <option key={item.value} value={item.value}>{item.label}{item.tools === 'chat' ? ' · chat only' : ''}</option>)}\n </select>\n </label> : <span className=\"tangle-lines__role\">{roles.find(item => item.value === member.role)?.label ?? member.role}</span>}\n {confirmId === member.id ? <div className=\"tangle-lines__confirm\" role=\"group\" aria-label={`Remove ${member.label || member.address}?`}>\n <span>Remove {member.label || member.address}?</span>\n <button ref={confirmButton} type=\"button\" className=\"tangle-lines__danger\" disabled={busy !== null || refreshFailed} onClick={() => void mutate(member.id, () => clientRef.current.remove(lineId, member.id), 'Member removed.', () => closeConfirmation(member.id))}>Remove</button>\n <button type=\"button\" disabled={busy !== null} onClick={() => closeConfirmation(member.id)}>Keep</button>\n </div> : <button ref={node => { if (node) removeTriggers.current.set(member.id, node); else removeTriggers.current.delete(member.id) }} type=\"button\" className=\"tangle-lines__quiet\" disabled={busy !== null || refreshFailed} onClick={() => setConfirmId(member.id)}>Remove</button>}\n </> : <span className=\"tangle-lines__role\">{roles.find(item => item.value === member.role)?.label ?? member.role}</span>}\n </div>\n </div>\n })}\n </div>}\n\n {canManage && canAdd && members !== null && (maxMembers === undefined || activeMembers < maxMembers) && <div className=\"tangle-lines__setup\">\n <h3>Invite a member</h3>\n <p>Hub marks the address as invited. The member confirms by messaging the line.</p>\n <div className=\"tangle-lines__fields\">\n <label>Phone number or email\n <input value={address} onChange={event => setAddress(event.target.value)} autoComplete=\"off\" placeholder=\"+15551234567 or name@example.com\" />\n </label>\n <label>Name (optional)\n <input value={label} onChange={event => setLabel(event.target.value)} placeholder=\"Member name\" />\n </label>\n <label>Role\n <select value={selectedRole} disabled={roles.length === 0} onChange={event => setRole(event.target.value)}>\n {roles.map(item => <option key={item.value} value={item.value}>{item.label}{item.tools === 'chat' ? ' · chat only' : ''}</option>)}\n </select>\n </label>\n </div>\n <button type=\"button\" className=\"tangle-lines__primary\" disabled={busy !== null || refreshFailed || !address.trim() || !selectedRole} onClick={add}>\n {busy === 'add' ? 'Inviting…' : 'Invite member'}\n </button>\n </div>}\n </section>\n}\n","import type { LineBillingProps } from './contracts'\n\nfunction resetTime(value: string): string {\n const date = new Date(value)\n return Number.isNaN(date.getTime()) ? value : date.toLocaleString()\n}\n\n/** Read-only billing facts from the line attachment and Hub allowance status. */\nexport function LineBilling({ view }: LineBillingProps) {\n return <section className=\"tangle-lines\" aria-label=\"Line billing\">\n <header className=\"tangle-lines__heading\">\n <div><h2>Billing</h2><p>{view.lineAddress}</p></div>\n </header>\n <dl className=\"tangle-lines__billing\">\n <div>\n <dt>Line</dt>\n <dd>{view.linePayer.kind === 'workspace' ? view.linePayer.label : 'Payer not verified'}</dd>\n {view.linePayer.kind === 'workspace' && <dd className=\"tangle-lines__billing-detail\">Charged to {view.workspaceName}.</dd>}\n </div>\n <div>\n <dt>Agent turns</dt>\n <dd>{view.turnPayer.kind === 'unverified' ? 'Payer not verified' : view.turnPayer.label}</dd>\n {view.turnPayer.kind === 'member' && <dd className=\"tangle-lines__billing-detail\">Each member pays for their own admitted turns.</dd>}\n </div>\n <div>\n <dt>Allowance</dt>\n {view.allowance ? <>\n <dd>{view.allowance.turnsPerMemberPerDay} turns per member each day</dd>\n {view.allowance.used !== undefined && view.allowance.limit !== undefined &&\n <dd className=\"tangle-lines__billing-detail\">{view.allowance.used} of {view.allowance.limit} turns used{view.allowance.resetsAt ? ` · resets ${resetTime(view.allowance.resetsAt)}` : ''}</dd>}\n </> : <dd>No allowance reported</dd>}\n </div>\n </dl>\n </section>\n}\n","import { useEffect, useMemo, useState } from 'react'\nimport type { ApplicationSenderVerification, ApplicationSenderVerificationStart } from '../application-verification'\nimport { LineSetup } from './LineSetup'\nimport type { LineConnectInput, LineSetupClient, LineSetupProps } from './contracts'\n\nexport type { ApplicationSenderVerification, ApplicationSenderVerificationStart } from '../application-verification'\n\nexport interface ApplicationLineConnectInput extends LineConnectInput {\n senderVerificationId: string\n turnsPerDay: number\n}\n\nexport interface ApplicationLineSetupClient extends Omit<LineSetupClient, 'connect'> {\n /** Host creates or finds the selected owned line, then starts TEST with its owner key. */\n startSenderVerification(input: LineConnectInput): Promise<ApplicationSenderVerificationStart>\n /** Host returns only public fields. approvedSender never reaches the browser. */\n getSenderVerification(lineId: string, testId: string): Promise<ApplicationSenderVerification>\n /** Host rechecks owner authority and consumes the proof during attach. */\n connect(input: ApplicationLineConnectInput): Promise<void>\n}\n\nexport interface ApplicationLineSetupProps extends Omit<LineSetupProps, 'client' | 'canConnect' | 'connectPrerequisite'> {\n client: ApplicationLineSetupClient\n /** Disable new grants without preventing disconnection of an existing line. */\n enabled: boolean\n}\n\nfunction verificationError(cause: unknown): string {\n return cause instanceof Error ? cause.message : 'The phone test could not be checked. Try again.'\n}\n\nfunction draftKey(input: LineConnectInput): string {\n return JSON.stringify(input)\n}\n\nfunction expiry(value: string): number {\n const time = new Date(value).getTime()\n return Number.isFinite(time) ? time : 0\n}\n\nfunction supportsSenderVerification(providerId: string, transport: LineConnectInput['transport']): boolean {\n return (providerId === 'inkbox' && transport === 'imessage')\n || (providerId === 'linq-whatsapp' && transport === 'whatsapp')\n}\n\nfunction hasTestIdentity(input: LineConnectInput): boolean {\n return input.transport === 'imessage' || (input.transport === 'whatsapp' && Boolean(input.phoneNumberId))\n}\n\n/** Verify an owned handset before connecting its supported line to an application. */\nexport function ApplicationLineSetup(props: ApplicationLineSetupProps) {\n return <ApplicationLineSetupScope key={props.scopeKey} {...props} />\n}\n\nfunction ApplicationLineSetupScope({ client, enabled, ...props }: ApplicationLineSetupProps) {\n const [limit, setLimit] = useState('20')\n const [session, setSession] = useState<{\n draftKey: string\n start: ApplicationSenderVerificationStart\n status: ApplicationSenderVerification\n } | null>(null)\n const [pending, setPending] = useState<{ kind: 'start' | 'check'; draftKey: string } | null>(null)\n const [error, setError] = useState<string | null>(null)\n const [needsStatusRefresh, setNeedsStatusRefresh] = useState(false)\n const [now, setNow] = useState(() => Date.now())\n const turnsPerDay = Number(limit)\n const validLimit = Number.isSafeInteger(turnsPerDay) && turnsPerDay >= 1 && turnsPerDay <= 10_000\n\n useEffect(() => {\n const timer = setInterval(() => setNow(Date.now()), 1_000)\n return () => clearInterval(timer)\n }, [])\n\n function activeFor(input: LineConnectInput) {\n return session?.draftKey === draftKey(input) ? session : null\n }\n\n function verifiedFor(input: LineConnectInput, time: number): boolean {\n const active = activeFor(input)\n return Boolean(active && !needsStatusRefresh && !pending && active.status.state === 'verified'\n && active.status.proof.signedInboundTestAt && active.status.proof.providerReplyAcknowledgedAt\n && active.status.proof.signedInboundConfirmAt && expiry(active.status.expiresAt) > time)\n }\n\n async function start(input: LineConnectInput) {\n const key = draftKey(input)\n if (!enabled || !props.canManage || !validLimit || pending || !hasTestIdentity(input)) return\n setPending({ kind: 'start', draftKey: key })\n setError(null)\n setNeedsStatusRefresh(true)\n try {\n const result = await client.startSenderVerification(input)\n if (!result.lineId || !result.testId || !result.testText || result.state !== 'awaiting_test'\n || expiry(result.expiresAt) <= Date.now()) throw new Error('The phone test could not be started. Try again.')\n setSession({\n draftKey: key,\n start: result,\n status: {\n lineId: result.lineId, testId: result.testId, state: result.state, expiresAt: result.expiresAt,\n proof: { signedInboundTestAt: null, providerReplyAcknowledgedAt: null, signedInboundConfirmAt: null },\n },\n })\n setNow(Date.now())\n } catch (cause) {\n setError(verificationError(cause))\n } finally {\n setPending(null)\n }\n }\n\n async function check(active: NonNullable<typeof session>) {\n if (pending) return\n setPending({ kind: 'check', draftKey: active.draftKey })\n setError(null)\n setNeedsStatusRefresh(true)\n try {\n const result = await client.getSenderVerification(active.start.lineId, active.start.testId)\n if (result.lineId !== active.start.lineId || result.testId !== active.start.testId)\n throw new Error('The phone test changed. Start a new test.')\n // Copy only public fields even if a host accidentally returns an SDK owner read.\n const status: ApplicationSenderVerification = {\n lineId: result.lineId, testId: result.testId, state: result.state, expiresAt: result.expiresAt,\n proof: {\n signedInboundTestAt: result.proof.signedInboundTestAt,\n providerReplyAcknowledgedAt: result.proof.providerReplyAcknowledgedAt,\n signedInboundConfirmAt: result.proof.signedInboundConfirmAt,\n },\n }\n setSession(current => current?.start.testId === active.start.testId ? { ...current, status } : current)\n setNeedsStatusRefresh(false)\n setNow(Date.now())\n } catch (cause) {\n setError(verificationError(cause))\n } finally {\n setPending(null)\n }\n }\n\n const lineClient = useMemo<LineSetupClient>(() => ({\n async load() {\n const snapshot = await client.load()\n return {\n ...snapshot,\n connections: snapshot.connections?.map(connection => ({\n ...connection,\n identities: connection.identities.filter(identity =>\n supportsSenderVerification(connection.providerId, identity.transport)),\n })).filter(connection => connection.identities.length > 0) ?? null,\n }\n },\n disconnect: (id, expectedAttachmentId) => client.disconnect(id, expectedAttachmentId),\n async connect(input) {\n const active = activeFor(input)\n if (!enabled || !props.canManage || !validLimit || !verifiedFor(input, Date.now()) || !active)\n throw new Error('Verify the selected phone before connecting this line')\n try {\n await client.connect({ ...input, senderVerificationId: active.start.testId, turnsPerDay })\n setSession(null)\n } catch (cause) {\n setNeedsStatusRefresh(true)\n throw cause\n }\n },\n }), [client, enabled, props.canManage, session, turnsPerDay, validLimit, needsStatusRefresh, pending])\n\n function prerequisite(input: LineConnectInput) {\n const key = draftKey(input)\n const active = activeFor(input)\n const expired = Boolean(active && expiry(active.status.expiresAt) <= now)\n const verified = verifiedFor(input, now)\n const inProgress = active && !expired && ['awaiting_test', 'sending', 'challenge_sent'].includes(active.status.state)\n const busy = pending?.draftKey === key\n const canStart = enabled && props.canManage && validLimit && !pending && hasTestIdentity(input)\n const canCheck = Boolean((inProgress || active?.status.state === 'verified') && !pending)\n\n return {\n ready: validLimit && verified,\n content: <div className=\"tangle-lines__verification\" aria-label=\"Phone verification\">\n <h4>Verify your phone</h4>\n <p>Use the phone that will send commands to this line. Connection opens after that phone is verified.</p>\n {!validLimit && <p className=\"tangle-lines__warning\">Enter a daily message limit from 1 to 10,000 first.</p>}\n {(!active || expired || ['consumed', 'cancelled', 'superseded', 'failed', 'expired'].includes(active.status.state))\n ? <>\n {active && <p role=\"status\">This phone test can no longer connect the line. Start a new test.</p>}\n <button type=\"button\" className=\"tangle-lines__secondary\" disabled={!canStart}\n onClick={() => void start(input)}>{busy && pending?.kind === 'start' ? 'Starting test…' : 'Start phone test'}</button>\n </> : <>\n <p>Text this exact message to the selected line from your phone:</p>\n <code className=\"tangle-lines__test-text\">{active.start.testText}</code>\n <p>Follow the private reply on your phone. No confirmation code is entered here.</p>\n <p className=\"tangle-lines__verification-expiry\">Test expires at {new Date(active.status.expiresAt).toLocaleTimeString()}.</p>\n {verified && <p className=\"tangle-lines__verified\" role=\"status\">Phone verified. You can connect this line.</p>}\n <div className=\"tangle-lines__verification-actions\">\n {!verified && <span role=\"status\">{active.status.state === 'verified'\n ? 'Check verification again before connecting.'\n : active.status.state === 'challenge_sent'\n ? 'Confirmation sent. Reply from the same phone, then check again.'\n : active.status.state === 'sending' ? 'Sending confirmation…' : 'Waiting for your test message.'}</span>}\n <button type=\"button\" className=\"tangle-lines__secondary\" disabled={!canCheck}\n onClick={() => void check(active)}>{busy && pending?.kind === 'check' ? 'Checking…' : 'Check verification'}</button>\n </div>\n </>}\n {error && <p className=\"tangle-lines__verification-error\" role=\"alert\">{error}</p>}\n </div>,\n }\n }\n\n return <>\n {props.canManage && <section className=\"tangle-lines tangle-lines--application\" aria-label=\"Application access\">\n <header className=\"tangle-lines__application-heading\">\n <h2>Text your workspace</h2>\n <p>Connect an owned iMessage or WhatsApp line to a conversation. Verify your phone before it can use application access and compute.</p>\n </header>\n {!enabled ? <div className=\"tangle-lines__notice\" role=\"status\">\n <strong>New connections are disabled</strong>\n <p>You can still review and disconnect an existing line below.</p>\n </div> : <div className=\"tangle-lines__authorization\">\n <label className=\"tangle-lines__limit\">Maximum messages per day\n <input type=\"number\" min={1} max={10_000} step={1} value={limit}\n onChange={event => setLimit(event.target.value)} />\n </label>\n <p className=\"tangle-lines__fine-print\">The message limit is not a dollar cap. STOP stops replies, not an already accepted task; cancel that task in the application.</p>\n </div>}\n </section>}\n <LineSetup {...props} targetLabel={props.targetLabel ?? 'Conversation'} client={lineClient}\n canConnect={props.canManage && enabled} showConnectionSetup={enabled}\n connectPrerequisite={prerequisite}\n setupDescription=\"Choose an owned iMessage or WhatsApp line and the conversation it will answer.\"\n emptyConnectionsMessage=\"Add an owned Inkbox iMessage handle or Linq WhatsApp number in Hub, then\" />\n </>\n}\n","import { useId } from 'react'\n\nexport interface SharedLineApp {\n /** Stable app identity used to collapse duplicate registrations. */\n id: string\n name: string\n}\n\nexport interface SharedLineAppNoticeProps {\n /** Apps the host has verified can handle this same phone conversation. */\n apps: readonly SharedLineApp[]\n /** The host controls dismissal so the choice can persist with its own policy. */\n open: boolean\n onKeepSharing(): void\n /** Omit when the host has no supported dedicated-number flow. */\n onRequestDedicatedNumber?: () => void\n}\n\nfunction distinctApps(apps: readonly SharedLineApp[]): SharedLineApp[] {\n const seen = new Set<string>()\n const result: SharedLineApp[] = []\n\n for (const app of apps) {\n const id = app.id.trim()\n if (!id || seen.has(id)) continue\n seen.add(id)\n result.push({ id, name: app.name.trim() || 'Unnamed app' })\n }\n\n return result\n}\n\n/** A quiet, dismissible notice for apps that the host verified share a phone thread. */\nexport function SharedLineAppNotice({\n apps,\n open,\n onKeepSharing,\n onRequestDedicatedNumber,\n}: SharedLineAppNoticeProps) {\n const titleId = useId()\n const sharingApps = distinctApps(apps)\n if (!open || sharingApps.length < 2) return null\n\n return (\n <section className=\"tangle-lines agent-shared-line-notice\" aria-labelledby={titleId}>\n <div className=\"agent-shared-line-notice__copy\">\n <h2 id={titleId}>These apps share one text conversation</h2>\n <p>Each app keeps its own history here. Their replies appear together in the same conversation on your phone.</p>\n <ul className=\"agent-shared-line-notice__apps\" aria-label=\"Apps sharing this conversation\">\n {sharingApps.map(app => <li key={app.id}>{app.name}</li>)}\n </ul>\n </div>\n <div className=\"agent-shared-line-notice__actions\">\n {onRequestDedicatedNumber && (\n <button\n className=\"agent-shared-line-notice__secondary\"\n type=\"button\"\n onClick={onRequestDedicatedNumber}\n >\n Get a dedicated number\n </button>\n )}\n <button className=\"agent-shared-line-notice__primary\" type=\"button\" onClick={onKeepSharing}>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AAM,KAAK,IAAI,GAAG,KAAK;AACvB,QAAI,CAAC,MAAM,KAAK,IAAI,EAAE,EAAG;AACzB,SAAK,IAAI,EAAE;AACX,WAAO,KAAK,EAAE,IAAI,MAAM,IAAI,KAAK,KAAK,KAAK,cAAc,CAAC;AAAA,EAC5D;AAEA,SAAO;AACT;AAGO,SAAS,oBAAoB;AAAA,EAClC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAA6B;AAC3B,QAAM,UAAU,MAAM;AACtB,QAAM,cAAc,aAAa,IAAI;AACrC,MAAI,CAAC,QAAQ,YAAY,SAAS,EAAG,QAAO;AAE5C,SACE,gBAAAA,MAAC,aAAQ,WAAU,yCAAwC,mBAAiB,SAC1E;AAAA,oBAAAA,MAAC,SAAI,WAAU,kCACb;AAAA,sBAAAD,KAAC,QAAG,IAAI,SAAS,oDAAsC;AAAA,MACvD,gBAAAA,KAAC,OAAE,wHAA0G;AAAA,MAC7G,gBAAAA,KAAC,QAAG,WAAU,kCAAiC,cAAW,kCACvD,sBAAY,IAAI,SAAO,gBAAAA,KAAC,QAAiB,cAAI,QAAb,IAAI,EAAc,CAAK,GAC1D;AAAA,OACF;AAAA,IACA,gBAAAC,MAAC,SAAI,WAAU,qCACZ;AAAA,kCACC,gBAAAD;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,MAAK;AAAA,UACL,SAAS;AAAA,UACV;AAAA;AAAA,MAED;AAAA,MAEF,gBAAAA,KAAC,YAAO,WAAU,qCAAoC,MAAK,UAAS,SAAS,eAAe,0BAE5F;AAAA,OACF;AAAA,KACF;AAEJ;","names":["occupied","line","useEffect","useLayoutEffect","useRef","useState","Fragment","jsx","jsxs","useBrowserLayoutEffect","Fragment","jsx","jsxs","useEffect","useState","Fragment","jsx","jsxs","useState","useEffect","jsx","jsxs"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/hosted-agent/react/LineSetup.tsx","../../../src/hosted-agent/react/LineMembers.tsx","../../../src/hosted-agent/react/LineBilling.tsx","../../../src/hosted-agent/react/ApplicationLineSetup.tsx","../../../src/hosted-agent/react/SharedLineAppNotice.tsx"],"sourcesContent":["import { useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport type { Line } from '@tangle-network/sandbox'\nimport type {\n LineBoxMode, LineConnectInput, LineConnectionOption, LineIdentityKind, LineIdentityOption,\n LineSetupLine, LineSetupProps, LineSetupSnapshot,\n} from './contracts'\n\nconst useBrowserLayoutEffect = typeof document !== 'undefined' ? useLayoutEffect : useEffect\n\nconst TRANSPORT: Record<Line['transport'], string> = {\n imessage: 'iMessage', sms: 'SMS', whatsapp: 'WhatsApp', email: 'Email', telegram: 'Telegram', voice: 'Voice',\n}\nconst IDENTITY: Record<LineIdentityKind, string> = {\n handle: 'Handle', number: 'Dedicated number', email: 'Email line',\n}\n\ntype Choice = { key: string; connection: LineConnectionOption; identity: LineIdentityOption }\n\nfunction LineMessageAction({ line }: { line: LineSetupLine }) {\n if (line.transport !== 'imessage' || line.targetId === null || line.status !== 'active') return null\n if (!!line.connect !== !!line.routerAddress) return null\n const shared = !!line.connect && !!line.routerAddress\n const number = shared ? line.routerAddress : line.address\n if (!number || !/^\\+[1-9]\\d{7,14}$/.test(number)) return null\n return <a className=\"tangle-lines__primary tangle-lines__message-action\" href={`sms:${number}?body=${encodeURIComponent(shared ? line.connect ?? '' : 'Hello')}`}>\n {shared ? 'Connect iMessage' : 'Text it now'}\n </a>\n}\n\nfunction message(error: unknown): string {\n return error instanceof Error ? error.message : 'The line request failed. Try again.'\n}\n\nfunction dateTime(value: string): string {\n const date = new Date(value)\n return Number.isNaN(date.getTime()) ? value : date.toLocaleString()\n}\n\nfunction choicesFor(snapshot: LineSetupSnapshot): Choice[] {\n return (snapshot.connections ?? []).flatMap(connection => connection.identities.map((identity, index) => ({\n key: `${connection.id}:${index}`,\n connection,\n identity,\n })))\n}\n\nfunction requiresNumber(identity: LineIdentityOption): boolean {\n return identity.transport === 'whatsapp' || identity.transport === 'sms' || identity.transport === 'voice' || identity.requiresPhoneNumberId === true\n}\n\n/** A line answering through the shared router number is the free shared entry;\n * a line with its own address is a dedicated number. */\nfunction isSharedEntry(line: LineSetupLine): boolean {\n return Boolean(line.connect && line.routerAddress)\n}\n\nfunction canOfferReconnect(line: LineSetupLine, choice: Choice): boolean {\n if (line.connectionId !== choice.connection.id || line.transport !== choice.identity.transport || line.targetId !== null) return false\n if (line.providerNumberId === null) return !choice.identity.phoneNumberId && !requiresNumber(choice.identity)\n return choice.identity.phoneNumberId === line.providerNumberId ||\n (!choice.identity.phoneNumberId && requiresNumber(choice.identity))\n}\n\nfunction matchesLineIdentity(line: LineSetupLine, identity: LineIdentityOption, numberId: string): boolean {\n if (line.transport !== identity.transport) return false\n if (line.providerNumberId === null) return !identity.phoneNumberId && !requiresNumber(identity)\n return numberId === line.providerNumberId\n}\n\n/** Set up an owned identity through a host route backed by sandbox.lines and Hub. */\nexport function LineSetup({ client, scopeKey, initialTargetId, targetLabel, canManage, canConnect = canManage, showConnectionSetup = true, connectPrerequisite, setupDescription, emptyConnectionsMessage, dedicatedUpgrade, onNotice }: LineSetupProps) {\n const clientRef = useRef(client)\n clientRef.current = client\n const sequence = useRef(0)\n const incarnation = useRef(0)\n const confirmButton = useRef<HTMLButtonElement>(null)\n const heading = useRef<HTMLHeadingElement>(null)\n const setupHeading = useRef<HTMLHeadingElement>(null)\n const disconnectTriggers = useRef(new Map<string, HTMLButtonElement>())\n const restoreFocusTo = useRef<string | null>(null)\n useBrowserLayoutEffect(() => {\n incarnation.current++\n return () => { incarnation.current++ }\n }, [scopeKey, initialTargetId])\n const [loadedSnapshot, setLoadedSnapshot] = useState<{ scopeKey: string; initialTargetId: string | undefined; value: LineSetupSnapshot } | null>(null)\n const snapshot = loadedSnapshot?.scopeKey === scopeKey && loadedSnapshot.initialTargetId === initialTargetId ? loadedSnapshot.value : null\n const [loading, setLoading] = useState(true)\n const [refreshFailed, setRefreshFailed] = useState(false)\n const [busy, setBusy] = useState(false)\n const [error, setError] = useState<string | null>(null)\n const [kind, setKind] = useState<LineIdentityKind>('handle')\n const [choiceKey, setChoiceKey] = useState('')\n const [targetId, setTargetId] = useState(initialTargetId ?? '')\n const [boxMode, setBoxMode] = useState<LineBoxMode>('per-member')\n const [phoneNumberId, setPhoneNumberId] = useState('')\n const [confirmation, setConfirmation] = useState<{ lineId: string; attachmentId: string | undefined } | null>(null)\n const confirmLineId = confirmation?.lineId ?? null\n\n function stillCurrent(requestIncarnation: number): boolean {\n return requestIncarnation === incarnation.current\n }\n\n async function reload(requestIncarnation: number): Promise<LineSetupSnapshot | null> {\n const request = ++sequence.current\n try {\n const next = await clientRef.current.load()\n if (request !== sequence.current || !stillCurrent(requestIncarnation)) return null\n setLoadedSnapshot({ scopeKey, initialTargetId, value: next })\n setError(null)\n setRefreshFailed(false)\n setTargetId(current => next.targets.some(target => target.id === current)\n ? current : next.targets.find(target => target.id === initialTargetId)?.id ?? next.targets[0]?.id ?? '')\n setLoading(false)\n return next\n } catch (cause) {\n if (request !== sequence.current || !stillCurrent(requestIncarnation)) return null\n setError(message(cause))\n setRefreshFailed(true)\n setLoading(false)\n return null\n }\n }\n\n function retry() {\n if (loading) return\n setLoading(true)\n void reload(incarnation.current)\n }\n\n function closeConfirmation(lineId: string) {\n restoreFocusTo.current = lineId\n setConfirmation(null)\n }\n\n useEffect(() => {\n setLoading(true)\n setLoadedSnapshot(null)\n setError(null)\n setRefreshFailed(false)\n setBusy(false)\n setKind('handle')\n setChoiceKey('')\n setTargetId(initialTargetId ?? '')\n setBoxMode('per-member')\n setPhoneNumberId('')\n setConfirmation(null)\n restoreFocusTo.current = null\n void reload(incarnation.current)\n return () => { sequence.current++ }\n }, [scopeKey, initialTargetId])\n\n useEffect(() => {\n if (confirmLineId) confirmButton.current?.focus()\n }, [confirmLineId])\n\n useEffect(() => {\n const lineId = restoreFocusTo.current\n if (confirmLineId !== null || lineId === null) return\n restoreFocusTo.current = null\n const trigger = disconnectTriggers.current.get(lineId)\n if (trigger && !trigger.disabled) trigger.focus()\n else (heading.current ?? setupHeading.current)?.focus()\n }, [confirmLineId, snapshot, refreshFailed])\n\n const allChoices = snapshot ? choicesFor(snapshot) : []\n const choices = snapshot ? allChoices.filter(choice => {\n const occupied = snapshot.lines.filter(line => line.status !== 'released' && line.transport === choice.identity.transport)\n const [line] = occupied\n return occupied.length === 0 || (occupied.length === 1 && line !== undefined && canOfferReconnect(line, choice))\n }) : []\n const availableKinds = (['handle', 'number', 'email'] as const).filter(value => choices.some(choice => choice.identity.kind === value))\n const selectedKind = availableKinds.includes(kind) ? kind : availableKinds[0]\n const kindChoices = choices.filter(choice => choice.identity.kind === selectedKind)\n const selected = kindChoices.find(choice => choice.key === choiceKey) ?? kindChoices[0]\n const visibleLines = snapshot?.lines.filter(line => line.status !== 'released') ?? []\n const showSetup = Boolean(snapshot && canManage && showConnectionSetup &&\n (snapshot.connections === null || choices.length > 0 || allChoices.length === 0))\n const showExisting = snapshot ? visibleLines.length > 0 || !showSetup : !(canManage && showConnectionSetup)\n const hasSeveralChoices = availableKinds.length > 1 || kindChoices.length > 1 || (snapshot?.targets.length ?? 0) > 1\n const SetupHeading = showExisting ? 'h3' : 'h2'\n const selectedTarget = snapshot?.targets.find(target => target.id === targetId)\n const selectedMode = selectedTarget?.modes.includes(boxMode) ? boxMode : selectedTarget?.modes[0]\n const enteredNumber = (selected?.identity.phoneNumberId ?? phoneNumberId).trim()\n const needsNumber = selected && requiresNumber(selected.identity)\n const occupied = selected && snapshot?.lines.filter(line => line.status !== 'released' && line.transport === selected.identity.transport)\n const [occupiedLine] = occupied || []\n const reconnectChoice = Boolean(selected && occupied?.length === 1 && occupiedLine && canOfferReconnect(occupiedLine, selected))\n const reconnecting = Boolean(reconnectChoice && selected && occupiedLine &&\n matchesLineIdentity(occupiedLine, selected.identity, enteredNumber))\n const blockedByExistingLine = Boolean(occupied?.length && !reconnecting)\n const answeringCount = snapshot?.lines.filter(line => line.answering).length ?? 0\n const draft: LineConnectInput | null = selected && selectedTarget && selectedMode\n ? {\n connectionId: selected.connection.id,\n transport: selected.identity.transport,\n ...(enteredNumber ? { phoneNumberId: enteredNumber } : {}),\n targetId: selectedTarget.id,\n boxMode: selectedMode,\n } : null\n const prerequisite = draft ? connectPrerequisite?.(draft) : null\n const connectReady = Boolean(canManage && canConnect && draft && (prerequisite?.ready ?? true)\n && !(needsNumber && !enteredNumber) && !blockedByExistingLine && !busy && !loading && !refreshFailed)\n\n async function connect() {\n if (!connectReady || !draft || !selected) return\n const requestIncarnation = incarnation.current\n setBusy(true)\n setError(null)\n try {\n await clientRef.current.connect(draft)\n if (!stillCurrent(requestIncarnation)) return\n const updated = await reload(requestIncarnation)\n if (!stillCurrent(requestIncarnation)) return\n if (!updated) {\n onNotice?.({ kind: 'error', message: 'Line connected, but its current status could not be loaded.' })\n return\n }\n const line = updated.lines.find(item => item.status !== 'released' && item.connectionId === selected.connection.id &&\n item.transport === selected.identity.transport && item.providerNumberId === (enteredNumber || null))\n onNotice?.({ kind: 'success', message: line?.answering ? 'The line is answering.' : selected.identity.transport === 'voice'\n ? 'Voice line connected. Configure calls and verify prior member consent in your host.'\n : 'Line connected. Add a member to start answers.' })\n } catch (cause) {\n if (!stillCurrent(requestIncarnation)) return\n const detail = message(cause)\n setError(detail)\n onNotice?.({ kind: 'error', message: detail })\n } finally {\n if (stillCurrent(requestIncarnation)) setBusy(false)\n }\n }\n\n async function disconnect() {\n if (!confirmation || busy || loading || refreshFailed) return\n const { lineId, attachmentId: expectedAttachmentId } = confirmation\n const requestIncarnation = incarnation.current\n setBusy(true)\n setError(null)\n try {\n await clientRef.current.disconnect(lineId, expectedAttachmentId)\n if (!stillCurrent(requestIncarnation)) return\n const updated = await reload(requestIncarnation)\n if (!stillCurrent(requestIncarnation)) return\n closeConfirmation(lineId)\n onNotice?.(updated\n ? { kind: 'success', message: 'The line stopped answering.' }\n : { kind: 'error', message: 'Line disconnected, but its current status could not be loaded.' })\n } catch (cause) {\n if (!stillCurrent(requestIncarnation)) return\n const detail = message(cause)\n setError(detail)\n onNotice?.({ kind: 'error', message: detail })\n } finally {\n if (stillCurrent(requestIncarnation)) setBusy(false)\n }\n }\n\n return <section className=\"tangle-lines\" aria-label=\"Agent lines\">\n {showExisting && <header className=\"tangle-lines__heading\">\n <div>\n <h2 ref={heading} tabIndex={-1}>Lines</h2>\n {snapshot && <p>{snapshot.workspaceName} can use one line per transport.</p>}\n </div>\n {answeringCount > 1 && <span className=\"tangle-lines__count\">{answeringCount} answering</span>}\n </header>}\n\n {error && <div className=\"tangle-lines__error\" role=\"alert\">\n <div><strong>{refreshFailed ? 'Lines are unavailable' : 'Line action failed'}</strong><p>{error}</p></div>\n {(!snapshot || refreshFailed) && <button type=\"button\" disabled={loading} onClick={retry}>Retry</button>}\n </div>}\n {loading && <p className=\"tangle-lines__muted\" role=\"status\">Loading lines…</p>}\n\n {snapshot && <>\n {showExisting && <div className=\"tangle-lines__list\">\n {visibleLines.length === 0 &&\n <div className=\"tangle-lines__empty\"><strong>No lines connected</strong><p>{canManage && showConnectionSetup\n ? 'Connect an owned identity below to let this workspace answer messages.'\n : 'There are no connected lines in this workspace.'}</p></div>}\n {visibleLines.map(line =>\n <div className=\"tangle-lines__row\" key={line.id}>\n <div className=\"tangle-lines__row-main\">\n <div className=\"tangle-lines__row-heading\"><span className=\"tangle-lines__transport\">{TRANSPORT[line.transport]}</span>{isSharedEntry(line) && <span className=\"tangle-lines__entry-kind\">Free shared number</span>}<span className={`tangle-lines__status${line.answering ? ' tangle-lines__status--answering' : ''}`}>{line.answering ? 'Answering' : line.targetId === null ? 'Disconnected' : line.status === 'active' ? line.transport === 'voice' ? 'Not answering' : 'Awaiting member' : line.status}</span></div>\n <strong>{line.address}</strong>\n {line.transport === 'imessage' && line.connect && line.routerAddress && line.targetId !== null && <p>Send <code>{line.connect}</code> to {line.routerAddress}. Then message the number Inkbox sends you.</p>}\n <LineMessageAction line={line} />\n {isSharedEntry(line) && line.targetId !== null && <p className=\"tangle-lines__answering-app\">{line.answering && line.targetLabel\n ? `${line.targetLabel} answers this shared number.`\n : 'No app answers this shared number yet.'}</p>}\n {isSharedEntry(line) && dedicatedUpgrade && line.targetId !== null\n && <a className=\"tangle-lines__secondary\" href={dedicatedUpgrade.href}>{dedicatedUpgrade.label ?? 'Upgrade to a dedicated number'}</a>}\n <p>{line.targetLabel ?? 'No agent or box assigned'}{line.boxMode && ` · ${line.boxMode === 'per-member' ? 'one box per member' : 'shared box'}`}</p>\n {line.lastTurn.kind === 'latest' ? <p>Last turn: {line.lastTurn.status} · {dateTime(line.lastTurn.at)}</p>\n : <p>{line.lastTurn.kind === 'none' ? 'No turns yet.' : 'Turn history unavailable.'}</p>}\n </div>\n {canManage && line.canDisconnect && line.targetId !== null && line.status === 'active' && <div className=\"tangle-lines__row-actions\">\n {confirmLineId === line.id ? <div className=\"tangle-lines__confirm\" role=\"group\" aria-label={`Disconnect ${line.address}?`}>\n <span>Disconnect this line?</span>\n <button ref={confirmButton} type=\"button\" className=\"tangle-lines__danger\" disabled={busy || loading || refreshFailed} onClick={() => void disconnect()}>Disconnect</button>\n <button type=\"button\" disabled={busy} onClick={() => closeConfirmation(line.id)}>Keep line</button>\n </div> : <button ref={node => { if (node) disconnectTriggers.current.set(line.id, node); else disconnectTriggers.current.delete(line.id) }} type=\"button\" className=\"tangle-lines__quiet\" disabled={busy || loading || refreshFailed} onClick={() => setConfirmation({ lineId: line.id, attachmentId: line.attachmentId ?? undefined })}>Disconnect line</button>}\n </div>}\n </div>)}\n </div>}\n\n {showSetup && <div className={`tangle-lines__setup${showExisting ? '' : ' tangle-lines__setup--first'}`}>\n <SetupHeading ref={setupHeading} tabIndex={-1}>Connect a line</SetupHeading>\n {hasSeveralChoices && setupDescription && <p>{setupDescription}</p>}\n {snapshot.connections === null ? <div className=\"tangle-lines__error\" role=\"status\">\n <span>Hub connections could not be read. Check Hub access and try again.</span>\n <button type=\"button\" disabled={loading} onClick={retry}>Retry</button>\n </div>\n : availableKinds.length === 0 ? <p className=\"tangle-lines__empty\">\n {emptyConnectionsMessage ?? 'Connect an owned handle, number, or mailbox in Hub, then'} <button type=\"button\" disabled={loading} onClick={retry}>reload</button>.\n </p>\n : <>\n {availableKinds.length > 1 && <div className=\"tangle-lines__kinds\" role=\"group\" aria-label=\"Identity type\">\n {availableKinds.map(value => <button key={value} type=\"button\" aria-pressed={selectedKind === value} onClick={() => { setKind(value); setChoiceKey(''); setPhoneNumberId('') }}>{IDENTITY[value]}</button>)}\n </div>}\n <div className=\"tangle-lines__fields\">\n {kindChoices.length > 1 ? <label>Line\n <select value={selected?.key ?? ''} onChange={event => { setChoiceKey(event.target.value); setPhoneNumberId('') }}>\n {kindChoices.map(choice => <option key={choice.key} value={choice.key}>{choice.identity.label} · {TRANSPORT[choice.identity.transport]} via {choice.connection.label}</option>)}\n </select>\n </label> : selected && <div className=\"tangle-lines__fixed-choice\">\n <span>Line</span>\n <strong>{selected.identity.label}</strong>\n <small>{TRANSPORT[selected.identity.transport]} via {selected.connection.label}</small>\n </div>}\n {snapshot.targets.length > 1 ? <label>{targetLabel ?? 'Agent or box'}\n <select value={selectedTarget?.id ?? ''} onChange={event => setTargetId(event.target.value)}>\n {snapshot.targets.map(target => <option key={target.id} value={target.id}>{target.label}{targetLabel ? '' : ` · ${target.kind}`}</option>)}\n </select>\n </label> : selectedTarget && <div className=\"tangle-lines__fixed-choice\">\n <span>{targetLabel ?? 'Agent or box'}</span>\n <strong>{selectedTarget.label}{targetLabel ? '' : ` · ${selectedTarget.kind}`}</strong>\n </div>}\n {selectedTarget && selectedTarget.modes.length > 1 && <fieldset>\n <legend>Conversation space</legend>\n <label><input type=\"radio\" name={`line-box-mode-${scopeKey}`} value=\"per-member\" checked={selectedMode === 'per-member'} disabled={!selectedTarget?.modes.includes('per-member')} onChange={() => setBoxMode('per-member')} /> One box per member</label>\n <label><input type=\"radio\" name={`line-box-mode-${scopeKey}`} value=\"shared\" checked={selectedMode === 'shared'} disabled={!selectedTarget?.modes.includes('shared')} onChange={() => setBoxMode('shared')} /> Shared box for a team</label>\n </fieldset>}\n {needsNumber && !selected?.identity.phoneNumberId && <label>Existing provider number ID\n <input value={phoneNumberId} onChange={event => setPhoneNumberId(event.target.value)} autoComplete=\"off\" placeholder=\"Number ID from Hub\" />\n </label>}\n </div>\n {reconnectChoice && blockedByExistingLine && <p className=\"tangle-lines__warning\">Enter this line's current provider number ID to reconnect.</p>}\n {prerequisite?.content}\n <button className=\"tangle-lines__primary\" type=\"button\" disabled={!connectReady} onClick={() => void connect()}>\n {busy ? (reconnectChoice ? 'Reconnecting…' : 'Connecting…') : `${reconnectChoice ? 'Reconnect' : 'Connect'} ${selected ? TRANSPORT[selected.identity.transport] : 'line'}`}\n </button>\n </>}\n </div>}\n </>}\n </section>\n}\n","import { useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport type { LineMember } from '@tangle-network/sandbox'\nimport type { LineMembersProps } from './contracts'\n\nconst useBrowserLayoutEffect = typeof document !== 'undefined' ? useLayoutEffect : useEffect\n\nconst STATUS: Record<LineMember['status'], { label: string; detail: string }> = {\n invited: { label: 'Awaiting consent', detail: 'The first message from this address confirms consent.' },\n active: { label: 'Consented', detail: 'This member has sent a message to the line.' },\n stopped: { label: 'Stopped', detail: 'The member texted STOP. Only a message from them with START resumes replies.' },\n removed: { label: 'Removed', detail: 'This address no longer has access to the line.' },\n}\n\nfunction errorMessage(cause: unknown): string {\n return cause instanceof Error ? cause.message : 'The member request failed. Try again.'\n}\n\n/** Manage Hub line members while keeping consent and STOP authority with the sender. */\nexport function LineMembers({ lineId, scopeKey, client, roles, canManage, canAdd = true, maxMembers, allowRoleChange = true, allowRemoveLastOwner = false, onNotice }: LineMembersProps) {\n const clientRef = useRef(client)\n clientRef.current = client\n const sequence = useRef(0)\n const incarnation = useRef(0)\n const confirmButton = useRef<HTMLButtonElement>(null)\n const heading = useRef<HTMLHeadingElement>(null)\n const removeTriggers = useRef(new Map<string, HTMLButtonElement>())\n const restoreFocusTo = useRef<string | null>(null)\n useBrowserLayoutEffect(() => {\n incarnation.current++\n return () => { incarnation.current++ }\n }, [lineId, scopeKey])\n const [memberSnapshot, setMemberSnapshot] = useState<{ lineId: string; scopeKey: string; members: LineMember[] } | null>(null)\n const [error, setError] = useState<string | null>(null)\n const [refreshFailed, setRefreshFailed] = useState(false)\n const [address, setAddress] = useState('')\n const [label, setLabel] = useState('')\n const [role, setRole] = useState('member')\n const [busy, setBusy] = useState<string | null>(null)\n const [confirmId, setConfirmId] = useState<string | null>(null)\n const members = memberSnapshot?.lineId === lineId && memberSnapshot.scopeKey === scopeKey ? memberSnapshot.members : null\n\n function stillCurrent(requestIncarnation: number): boolean {\n return requestIncarnation === incarnation.current\n }\n\n async function reload(requestIncarnation: number): Promise<boolean> {\n const request = ++sequence.current\n try {\n const next = await clientRef.current.list(lineId)\n if (request !== sequence.current || !stillCurrent(requestIncarnation)) return false\n setMemberSnapshot({ lineId, scopeKey, members: next })\n setError(null)\n setRefreshFailed(false)\n return true\n } catch (cause) {\n if (request !== sequence.current || !stillCurrent(requestIncarnation)) return false\n setError(errorMessage(cause))\n setRefreshFailed(true)\n return false\n }\n }\n\n async function retry() {\n if (busy) return\n const requestIncarnation = incarnation.current\n setBusy('refresh')\n try { await reload(requestIncarnation) }\n finally { if (stillCurrent(requestIncarnation)) setBusy(null) }\n }\n\n function closeConfirmation(memberId: string) {\n restoreFocusTo.current = memberId\n setConfirmId(null)\n }\n\n useEffect(() => {\n setMemberSnapshot(null)\n setError(null)\n setRefreshFailed(false)\n setAddress('')\n setLabel('')\n setRole('member')\n setConfirmId(null)\n restoreFocusTo.current = null\n setBusy(null)\n void reload(incarnation.current)\n return () => { sequence.current++ }\n }, [lineId, scopeKey])\n\n useEffect(() => {\n if (confirmId) confirmButton.current?.focus()\n }, [confirmId])\n\n useEffect(() => {\n const memberId = restoreFocusTo.current\n if (confirmId !== null || memberId === null) return\n restoreFocusTo.current = null\n const trigger = removeTriggers.current.get(memberId)\n if (trigger && !trigger.disabled) trigger.focus()\n else heading.current?.focus()\n }, [confirmId, members, refreshFailed])\n\n const selectedRole = roles.some(item => item.value === role) ? role : roles.find(item => item.value === 'member')?.value ?? roles[0]?.value ?? ''\n const activeMembers = members?.filter(member => member.status !== 'removed').length ?? 0\n const activeOwners = members?.filter(member => member.role === 'owner' && member.status !== 'removed').length ?? 0\n\n async function mutate(key: string, action: () => Promise<void>, success: string, onSuccess?: () => void) {\n if (busy || refreshFailed) return\n const requestIncarnation = incarnation.current\n setBusy(key)\n setError(null)\n try {\n await action()\n if (!stillCurrent(requestIncarnation)) return\n const refreshed = await reload(requestIncarnation)\n if (!stillCurrent(requestIncarnation)) return\n onSuccess?.()\n onNotice?.(refreshed\n ? { kind: 'success', message: success }\n : { kind: 'error', message: 'Member updated, but the current member list could not be loaded.' })\n } catch (cause) {\n if (!stillCurrent(requestIncarnation)) return\n const detail = errorMessage(cause)\n setError(detail)\n onNotice?.({ kind: 'error', message: detail })\n } finally {\n if (stillCurrent(requestIncarnation)) setBusy(null)\n }\n }\n\n function add() {\n const trimmed = address.trim()\n if (!trimmed || !selectedRole || members === null || (maxMembers !== undefined && activeMembers >= maxMembers)) return\n void mutate('add', () => clientRef.current.add(lineId, { address: trimmed, role: selectedRole, ...(label.trim() ? { label: label.trim() } : {}) }), 'Member invited. Their first message confirms consent.', () => {\n setAddress('')\n setLabel('')\n })\n }\n\n return <section className=\"tangle-lines\" aria-label=\"Line members\">\n <header className=\"tangle-lines__heading\">\n <div><h2 ref={heading} tabIndex={-1}>Members</h2><p>Each address controls its own consent and STOP state.</p></div>\n {members && <span className=\"tangle-lines__count\">{activeMembers} {activeMembers === 1 ? 'member' : 'members'}</span>}\n </header>\n {error && <div className=\"tangle-lines__error\" role=\"alert\">\n <span>{error}</span>\n {(members === null || refreshFailed) && <button type=\"button\" disabled={busy !== null} onClick={() => void retry()}>Retry</button>}\n </div>}\n {members === null ? !error && <p className=\"tangle-lines__muted\" role=\"status\">Loading members…</p> : <div className=\"tangle-lines__list\">\n {members.length === 0 && <p className=\"tangle-lines__empty\">{canAdd ? 'No members yet. Invite an address that you own or have permission to add.' : 'No members yet.'}</p>}\n {members.map(member => {\n const lastOwner = member.role === 'owner' && activeOwners <= 1\n const editable = canManage && member.status !== 'removed' && (!lastOwner || allowRemoveLastOwner)\n return <div className=\"tangle-lines__row\" key={member.id}>\n <div className=\"tangle-lines__row-main\">\n <span className={`tangle-lines__state tangle-lines__state--${member.status}`}>{STATUS[member.status].label}</span>\n <strong>{member.label || member.address}</strong>\n {member.label && <p>{member.address}</p>}\n <p>{STATUS[member.status].detail}</p>\n </div>\n <div className=\"tangle-lines__row-actions\">\n {editable ? <>\n {allowRoleChange && !lastOwner ? <label className=\"tangle-lines__compact-label\">Role\n <select value={member.role} disabled={busy !== null || refreshFailed} onChange={event => void mutate(member.id, () => clientRef.current.update(lineId, member.id, { role: event.target.value }), 'Role updated.')}>\n {!roles.some(item => item.value === member.role) && <option value={member.role}>{member.role}</option>}\n {roles.map(item => <option key={item.value} value={item.value}>{item.label}{item.tools === 'chat' ? ' · chat only' : ''}</option>)}\n </select>\n </label> : <span className=\"tangle-lines__role\">{roles.find(item => item.value === member.role)?.label ?? member.role}</span>}\n {confirmId === member.id ? <div className=\"tangle-lines__confirm\" role=\"group\" aria-label={`Remove ${member.label || member.address}?`}>\n <span>Remove {member.label || member.address}?</span>\n <button ref={confirmButton} type=\"button\" className=\"tangle-lines__danger\" disabled={busy !== null || refreshFailed} onClick={() => void mutate(member.id, () => clientRef.current.remove(lineId, member.id), 'Member removed.', () => closeConfirmation(member.id))}>Remove</button>\n <button type=\"button\" disabled={busy !== null} onClick={() => closeConfirmation(member.id)}>Keep</button>\n </div> : <button ref={node => { if (node) removeTriggers.current.set(member.id, node); else removeTriggers.current.delete(member.id) }} type=\"button\" className=\"tangle-lines__quiet\" disabled={busy !== null || refreshFailed} onClick={() => setConfirmId(member.id)}>Remove</button>}\n </> : <span className=\"tangle-lines__role\">{roles.find(item => item.value === member.role)?.label ?? member.role}</span>}\n </div>\n </div>\n })}\n </div>}\n\n {canManage && canAdd && members !== null && (maxMembers === undefined || activeMembers < maxMembers) && <div className=\"tangle-lines__setup\">\n <h3>Invite a member</h3>\n <p>Hub marks the address as invited. The member confirms by messaging the line.</p>\n <div className=\"tangle-lines__fields\">\n <label>Phone number or email\n <input value={address} onChange={event => setAddress(event.target.value)} autoComplete=\"off\" placeholder=\"+15551234567 or name@example.com\" />\n </label>\n <label>Name (optional)\n <input value={label} onChange={event => setLabel(event.target.value)} placeholder=\"Member name\" />\n </label>\n <label>Role\n <select value={selectedRole} disabled={roles.length === 0} onChange={event => setRole(event.target.value)}>\n {roles.map(item => <option key={item.value} value={item.value}>{item.label}{item.tools === 'chat' ? ' · chat only' : ''}</option>)}\n </select>\n </label>\n </div>\n <button type=\"button\" className=\"tangle-lines__primary\" disabled={busy !== null || refreshFailed || !address.trim() || !selectedRole} onClick={add}>\n {busy === 'add' ? 'Inviting…' : 'Invite member'}\n </button>\n </div>}\n </section>\n}\n","import type { LineBillingProps } from './contracts'\n\nfunction resetTime(value: string): string {\n const date = new Date(value)\n return Number.isNaN(date.getTime()) ? value : date.toLocaleString()\n}\n\n/** Read-only billing facts from the line attachment and Hub allowance status. */\nexport function LineBilling({ view }: LineBillingProps) {\n return <section className=\"tangle-lines\" aria-label=\"Line billing\">\n <header className=\"tangle-lines__heading\">\n <div><h2>Billing</h2><p>{view.lineAddress}</p></div>\n </header>\n <dl className=\"tangle-lines__billing\">\n <div>\n <dt>Line</dt>\n <dd>{view.linePayer.kind === 'workspace' ? view.linePayer.label : 'Payer not verified'}</dd>\n {view.linePayer.kind === 'workspace' && <dd className=\"tangle-lines__billing-detail\">Charged to {view.workspaceName}.</dd>}\n </div>\n <div>\n <dt>Agent turns</dt>\n <dd>{view.turnPayer.kind === 'unverified' ? 'Payer not verified' : view.turnPayer.label}</dd>\n {view.turnPayer.kind === 'member' && <dd className=\"tangle-lines__billing-detail\">Each member pays for their own admitted turns.</dd>}\n </div>\n <div>\n <dt>Allowance</dt>\n {view.allowance ? <>\n <dd>{view.allowance.turnsPerMemberPerDay} turns per member each day</dd>\n {view.allowance.used !== undefined && view.allowance.limit !== undefined &&\n <dd className=\"tangle-lines__billing-detail\">{view.allowance.used} of {view.allowance.limit} turns used{view.allowance.resetsAt ? ` · resets ${resetTime(view.allowance.resetsAt)}` : ''}</dd>}\n </> : <dd>No allowance reported</dd>}\n </div>\n </dl>\n </section>\n}\n","import { useEffect, useMemo, useState } from 'react'\nimport type { ApplicationSenderVerification, ApplicationSenderVerificationStart } from '../application-verification'\nimport { LineSetup } from './LineSetup'\nimport type { LineConnectInput, LineSetupClient, LineSetupProps } from './contracts'\n\nexport type { ApplicationSenderVerification, ApplicationSenderVerificationStart } from '../application-verification'\n\nexport interface ApplicationLineConnectInput extends LineConnectInput {\n senderVerificationId: string\n turnsPerDay: number\n}\n\nexport interface ApplicationLineSetupClient extends Omit<LineSetupClient, 'connect'> {\n /** Host creates or finds the selected owned line, then starts TEST with its owner key. */\n startSenderVerification(input: LineConnectInput): Promise<ApplicationSenderVerificationStart>\n /** Host returns only public fields. approvedSender never reaches the browser. */\n getSenderVerification(lineId: string, testId: string): Promise<ApplicationSenderVerification>\n /** Host rechecks owner authority and consumes the proof during attach. */\n connect(input: ApplicationLineConnectInput): Promise<void>\n}\n\nexport interface ApplicationLineSetupProps extends Omit<LineSetupProps, 'client' | 'canConnect' | 'connectPrerequisite'> {\n client: ApplicationLineSetupClient\n /** Disable new grants without preventing disconnection of an existing line. */\n enabled: boolean\n}\n\nfunction verificationError(cause: unknown): string {\n return cause instanceof Error ? cause.message : 'The phone test could not be checked. Try again.'\n}\n\nfunction draftKey(input: LineConnectInput): string {\n return JSON.stringify(input)\n}\n\nfunction expiry(value: string): number {\n const time = new Date(value).getTime()\n return Number.isFinite(time) ? time : 0\n}\n\nfunction supportsSenderVerification(providerId: string, transport: LineConnectInput['transport']): boolean {\n return (providerId === 'inkbox' && transport === 'imessage')\n || (providerId === 'linq-whatsapp' && transport === 'whatsapp')\n}\n\nfunction hasTestIdentity(input: LineConnectInput): boolean {\n return input.transport === 'imessage' || (input.transport === 'whatsapp' && Boolean(input.phoneNumberId))\n}\n\n/** Verify an owned handset before connecting its supported line to an application. */\nexport function ApplicationLineSetup(props: ApplicationLineSetupProps) {\n return <ApplicationLineSetupScope key={props.scopeKey} {...props} />\n}\n\nfunction ApplicationLineSetupScope({ client, enabled, ...props }: ApplicationLineSetupProps) {\n const [limit, setLimit] = useState('20')\n const [session, setSession] = useState<{\n draftKey: string\n start: ApplicationSenderVerificationStart\n status: ApplicationSenderVerification\n } | null>(null)\n const [pending, setPending] = useState<{ kind: 'start' | 'check'; draftKey: string } | null>(null)\n const [error, setError] = useState<string | null>(null)\n const [needsStatusRefresh, setNeedsStatusRefresh] = useState(false)\n const [now, setNow] = useState(() => Date.now())\n const turnsPerDay = Number(limit)\n const validLimit = Number.isSafeInteger(turnsPerDay) && turnsPerDay >= 1 && turnsPerDay <= 10_000\n\n useEffect(() => {\n const timer = setInterval(() => setNow(Date.now()), 1_000)\n return () => clearInterval(timer)\n }, [])\n\n function activeFor(input: LineConnectInput) {\n return session?.draftKey === draftKey(input) ? session : null\n }\n\n function verifiedFor(input: LineConnectInput, time: number): boolean {\n const active = activeFor(input)\n return Boolean(active && !needsStatusRefresh && !pending && active.status.state === 'verified'\n && active.status.proof.signedInboundTestAt && active.status.proof.providerReplyAcknowledgedAt\n && active.status.proof.signedInboundConfirmAt && expiry(active.status.expiresAt) > time)\n }\n\n async function start(input: LineConnectInput) {\n const key = draftKey(input)\n if (!enabled || !props.canManage || !validLimit || pending || !hasTestIdentity(input)) return\n setPending({ kind: 'start', draftKey: key })\n setError(null)\n setNeedsStatusRefresh(true)\n try {\n const result = await client.startSenderVerification(input)\n if (!result.lineId || !result.testId || !result.testText || result.state !== 'awaiting_test'\n || expiry(result.expiresAt) <= Date.now()) throw new Error('The phone test could not be started. Try again.')\n setSession({\n draftKey: key,\n start: result,\n status: {\n lineId: result.lineId, testId: result.testId, state: result.state, expiresAt: result.expiresAt,\n proof: { signedInboundTestAt: null, providerReplyAcknowledgedAt: null, signedInboundConfirmAt: null },\n },\n })\n setNow(Date.now())\n } catch (cause) {\n setError(verificationError(cause))\n } finally {\n setPending(null)\n }\n }\n\n async function check(active: NonNullable<typeof session>) {\n if (pending) return\n setPending({ kind: 'check', draftKey: active.draftKey })\n setError(null)\n setNeedsStatusRefresh(true)\n try {\n const result = await client.getSenderVerification(active.start.lineId, active.start.testId)\n if (result.lineId !== active.start.lineId || result.testId !== active.start.testId)\n throw new Error('The phone test changed. Start a new test.')\n // Copy only public fields even if a host accidentally returns an SDK owner read.\n const status: ApplicationSenderVerification = {\n lineId: result.lineId, testId: result.testId, state: result.state, expiresAt: result.expiresAt,\n proof: {\n signedInboundTestAt: result.proof.signedInboundTestAt,\n providerReplyAcknowledgedAt: result.proof.providerReplyAcknowledgedAt,\n signedInboundConfirmAt: result.proof.signedInboundConfirmAt,\n },\n }\n setSession(current => current?.start.testId === active.start.testId ? { ...current, status } : current)\n setNeedsStatusRefresh(false)\n setNow(Date.now())\n } catch (cause) {\n setError(verificationError(cause))\n } finally {\n setPending(null)\n }\n }\n\n const lineClient = useMemo<LineSetupClient>(() => ({\n async load() {\n const snapshot = await client.load()\n return {\n ...snapshot,\n connections: snapshot.connections?.map(connection => ({\n ...connection,\n identities: connection.identities.filter(identity =>\n supportsSenderVerification(connection.providerId, identity.transport)),\n })).filter(connection => connection.identities.length > 0) ?? null,\n }\n },\n disconnect: (id, expectedAttachmentId) => client.disconnect(id, expectedAttachmentId),\n async connect(input) {\n const active = activeFor(input)\n if (!enabled || !props.canManage || !validLimit || !verifiedFor(input, Date.now()) || !active)\n throw new Error('Verify the selected phone before connecting this line')\n try {\n await client.connect({ ...input, senderVerificationId: active.start.testId, turnsPerDay })\n setSession(null)\n } catch (cause) {\n setNeedsStatusRefresh(true)\n throw cause\n }\n },\n }), [client, enabled, props.canManage, session, turnsPerDay, validLimit, needsStatusRefresh, pending])\n\n function prerequisite(input: LineConnectInput) {\n const key = draftKey(input)\n const active = activeFor(input)\n const expired = Boolean(active && expiry(active.status.expiresAt) <= now)\n const verified = verifiedFor(input, now)\n const inProgress = active && !expired && ['awaiting_test', 'sending', 'challenge_sent'].includes(active.status.state)\n const busy = pending?.draftKey === key\n const canStart = enabled && props.canManage && validLimit && !pending && hasTestIdentity(input)\n const canCheck = Boolean((inProgress || active?.status.state === 'verified') && !pending)\n\n return {\n ready: validLimit && verified,\n content: <div className=\"tangle-lines__verification\" aria-label=\"Phone verification\">\n <h4>Verify your phone</h4>\n <p>Use the phone that will send commands to this line. Connection opens after that phone is verified.</p>\n {!validLimit && <p className=\"tangle-lines__warning\">Enter a daily message limit from 1 to 10,000 first.</p>}\n {(!active || expired || ['consumed', 'cancelled', 'superseded', 'failed', 'expired'].includes(active.status.state))\n ? <>\n {active && <p role=\"status\">This phone test can no longer connect the line. Start a new test.</p>}\n <button type=\"button\" className=\"tangle-lines__secondary\" disabled={!canStart}\n onClick={() => void start(input)}>{busy && pending?.kind === 'start' ? 'Starting test…' : 'Start phone test'}</button>\n </> : <>\n <p>Text this exact message to the selected line from your phone:</p>\n <code className=\"tangle-lines__test-text\">{active.start.testText}</code>\n <p>Follow the private reply on your phone. No confirmation code is entered here.</p>\n <p className=\"tangle-lines__verification-expiry\">Test expires at {new Date(active.status.expiresAt).toLocaleTimeString()}.</p>\n {verified && <p className=\"tangle-lines__verified\" role=\"status\">Phone verified. You can connect this line.</p>}\n <div className=\"tangle-lines__verification-actions\">\n {!verified && <span role=\"status\">{active.status.state === 'verified'\n ? 'Check verification again before connecting.'\n : active.status.state === 'challenge_sent'\n ? 'Confirmation sent. Reply from the same phone, then check again.'\n : active.status.state === 'sending' ? 'Sending confirmation…' : 'Waiting for your test message.'}</span>}\n <button type=\"button\" className=\"tangle-lines__secondary\" disabled={!canCheck}\n onClick={() => void check(active)}>{busy && pending?.kind === 'check' ? 'Checking…' : 'Check verification'}</button>\n </div>\n </>}\n {error && <p className=\"tangle-lines__verification-error\" role=\"alert\">{error}</p>}\n </div>,\n }\n }\n\n return <>\n {props.canManage && <section className=\"tangle-lines tangle-lines--application\" aria-label=\"Application access\">\n <header className=\"tangle-lines__application-heading\">\n <h2>Text your workspace</h2>\n <p>Connect an owned iMessage or WhatsApp line to a conversation. Verify your phone before it can use application access and compute.</p>\n </header>\n {!enabled ? <div className=\"tangle-lines__notice\" role=\"status\">\n <strong>New connections are disabled</strong>\n <p>You can still review and disconnect an existing line below.</p>\n </div> : <div className=\"tangle-lines__authorization\">\n <label className=\"tangle-lines__limit\">Maximum messages per day\n <input type=\"number\" min={1} max={10_000} step={1} value={limit}\n onChange={event => setLimit(event.target.value)} />\n </label>\n <p className=\"tangle-lines__fine-print\">The message limit is not a dollar cap. STOP stops replies, not an already accepted task; cancel that task in the application.</p>\n </div>}\n </section>}\n <LineSetup {...props} targetLabel={props.targetLabel ?? 'Conversation'} client={lineClient}\n canConnect={props.canManage && enabled} showConnectionSetup={enabled}\n connectPrerequisite={prerequisite}\n setupDescription=\"Choose an owned iMessage or WhatsApp line and the conversation it will answer.\"\n emptyConnectionsMessage=\"Add an owned Inkbox iMessage handle or Linq WhatsApp number in Hub, then\" />\n </>\n}\n","import { useId } from 'react'\n\nexport interface SharedLineApp {\n /** Stable app identity used to collapse duplicate registrations. */\n id: string\n name: string\n}\n\nexport interface SharedLineAppNoticeProps {\n /** Apps the host has verified can handle this same phone conversation. */\n apps: readonly SharedLineApp[]\n /** The host controls dismissal so the choice can persist with its own policy. */\n open: boolean\n onKeepSharing(): void\n /** Omit when the host has no supported dedicated-number flow. */\n onRequestDedicatedNumber?: () => void\n}\n\nfunction distinctApps(apps: readonly SharedLineApp[]): SharedLineApp[] {\n const seen = new Set<string>()\n const result: SharedLineApp[] = []\n\n for (const app of apps) {\n const id = app.id.trim()\n if (!id || seen.has(id)) continue\n seen.add(id)\n result.push({ id, name: app.name.trim() || 'Unnamed app' })\n }\n\n return result\n}\n\n/** A quiet, dismissible notice for apps that the host verified share a phone thread. */\nexport function SharedLineAppNotice({\n apps,\n open,\n onKeepSharing,\n onRequestDedicatedNumber,\n}: SharedLineAppNoticeProps) {\n const titleId = useId()\n const sharingApps = distinctApps(apps)\n if (!open || sharingApps.length < 2) return null\n\n return (\n <section className=\"tangle-lines agent-shared-line-notice\" aria-labelledby={titleId}>\n <div className=\"agent-shared-line-notice__copy\">\n <h2 id={titleId}>These apps share one text conversation</h2>\n <p>Each app keeps its own history here. Their replies appear together in the same conversation on your phone.</p>\n <ul className=\"agent-shared-line-notice__apps\" aria-label=\"Apps sharing this conversation\">\n {sharingApps.map(app => <li key={app.id}>{app.name}</li>)}\n </ul>\n </div>\n <div className=\"agent-shared-line-notice__actions\">\n {onRequestDedicatedNumber && (\n <button\n className=\"agent-shared-line-notice__secondary\"\n type=\"button\"\n onClick={onRequestDedicatedNumber}\n >\n Get a dedicated number\n </button>\n )}\n <button className=\"agent-shared-line-notice__primary\" type=\"button\" onClick={onKeepSharing}>\n Keep sharing\n </button>\n </div>\n </section>\n )\n}\n"],"mappings":";AAAA,SAAS,WAAW,iBAAiB,QAAQ,gBAAgB;AAwBpD,SAkSK,UAlSL,KA6OY,YA7OZ;AAjBT,IAAM,yBAAyB,OAAO,aAAa,cAAc,kBAAkB;AAEnF,IAAM,YAA+C;AAAA,EACnD,UAAU;AAAA,EAAY,KAAK;AAAA,EAAO,UAAU;AAAA,EAAY,OAAO;AAAA,EAAS,UAAU;AAAA,EAAY,OAAO;AACvG;AACA,IAAM,WAA6C;AAAA,EACjD,QAAQ;AAAA,EAAU,QAAQ;AAAA,EAAoB,OAAO;AACvD;AAIA,SAAS,kBAAkB,EAAE,KAAK,GAA4B;AAC5D,MAAI,KAAK,cAAc,cAAc,KAAK,aAAa,QAAQ,KAAK,WAAW,SAAU,QAAO;AAChG,MAAI,CAAC,CAAC,KAAK,YAAY,CAAC,CAAC,KAAK,cAAe,QAAO;AACpD,QAAM,SAAS,CAAC,CAAC,KAAK,W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AAW,kCACvD,sBAAY,IAAI,SAAO,gBAAAA,KAAC,QAAiB,cAAI,QAAb,IAAI,EAAc,CAAK,GAC1D;AAAA,OACF;AAAA,IACA,gBAAAC,MAAC,SAAI,WAAU,qCACZ;AAAA,kCACC,gBAAAD;AAAA,QAAC;AAAA;AAAA,UACC,WAAU;AAAA,UACV,MAAK;AAAA,UACL,SAAS;AAAA,UACV;AAAA;AAAA,MAED;AAAA,MAEF,gBAAAA,KAAC,YAAO,WAAU,qCAAoC,MAAK,UAAS,SAAS,eAAe,0BAE5F;AAAA,OACF;AAAA,KACF;AAEJ;","names":["occupied","line","useEffect","useLayoutEffect","useRef","useState","Fragment","jsx","jsxs","useBrowserLayoutEffect","Fragment","jsx","jsxs","useEffect","useState","Fragment","jsx","jsxs","useState","useEffect","jsx","jsxs"]}
|
|
@@ -10,10 +10,10 @@ import {
|
|
|
10
10
|
} from "./chunk-L7MB2LLM.js";
|
|
11
11
|
import {
|
|
12
12
|
PopoverSurface
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-6CDNITEO.js";
|
|
14
14
|
import "./chunk-ZAMHLXNS.js";
|
|
15
15
|
import "./chunk-RASGKEAL.js";
|
|
16
|
-
import "./chunk-
|
|
16
|
+
import "./chunk-KSLTD4FI.js";
|
|
17
17
|
|
|
18
18
|
// src/web-react/mention-editor.tsx
|
|
19
19
|
import { useEffect as useEffect2, useId, useRef as useRef2, useState as useState2 } from "react";
|
|
@@ -564,4 +564,4 @@ export {
|
|
|
564
564
|
loadMentionEditor,
|
|
565
565
|
loadTiptapModules
|
|
566
566
|
};
|
|
567
|
-
//# sourceMappingURL=mention-editor-
|
|
567
|
+
//# sourceMappingURL=mention-editor-XB4LGO3X.js.map
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createChatTurnRoutes,
|
|
3
3
|
streamChatRouteAsSandboxEvents
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-MS5S4IVF.js";
|
|
5
5
|
import "../chunk-SBHFMDR7.js";
|
|
6
6
|
import "../chunk-H6BRJU5M.js";
|
|
7
7
|
import "../chunk-4DBHC63F.js";
|
|
8
8
|
import "../chunk-RN4WPTBH.js";
|
|
9
9
|
import "../chunk-MM6RLOXF.js";
|
|
10
|
-
import "../chunk-
|
|
10
|
+
import "../chunk-HFWKZHTZ.js";
|
|
11
11
|
import "../chunk-F4TUZYMX.js";
|
|
12
12
|
import "../chunk-MH74DY2I.js";
|
|
13
13
|
import "../chunk-YHA6W3OW.js";
|
|
@@ -33,13 +33,13 @@ import "../chunk-S5SRJJQG.js";
|
|
|
33
33
|
import "../chunk-C3JXGK3R.js";
|
|
34
34
|
import "../chunk-UGWQLQDS.js";
|
|
35
35
|
import "../chunk-IDRATMRZ.js";
|
|
36
|
-
import "../chunk-
|
|
36
|
+
import "../chunk-2ARZ4Y7D.js";
|
|
37
37
|
import "../chunk-LPW4UVAZ.js";
|
|
38
38
|
import "../chunk-DCPOEDPK.js";
|
|
39
|
-
import "../chunk-
|
|
39
|
+
import "../chunk-KSLTD4FI.js";
|
|
40
40
|
import "../chunk-5VE4IDSU.js";
|
|
41
41
|
import "../chunk-67CSI5PU.js";
|
|
42
|
-
import "../chunk-
|
|
42
|
+
import "../chunk-SUWAECFT.js";
|
|
43
43
|
import "../chunk-INW4FSID.js";
|
|
44
44
|
import "../chunk-HY57QRRW.js";
|
|
45
45
|
import "../chunk-F4XBNR5L.js";
|
package/dist/runtime/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
ProtectedModelSettlementError,
|
|
3
3
|
createRouterProtectedModelPort,
|
|
4
4
|
runProtectedRouterTurn
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-RTJJYBVV.js";
|
|
6
6
|
import {
|
|
7
7
|
DURABLE_HOP_BUDGET_MS,
|
|
8
8
|
asksForLanguage,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
turnKnowledgeInstructions,
|
|
27
27
|
workspaceKnowledgeForTurn,
|
|
28
28
|
workspaceTurnCheckpoints
|
|
29
|
-
} from "../chunk-
|
|
29
|
+
} from "../chunk-2ARZ4Y7D.js";
|
|
30
30
|
import {
|
|
31
31
|
DEFAULT_TANGLE_BILLING_ENFORCEMENT_ENV_VAR,
|
|
32
32
|
DEFAULT_TANGLE_ROUTER_BASE_URL,
|
|
@@ -47,13 +47,14 @@ import {
|
|
|
47
47
|
MAX_RECOMMENDED_MODELS,
|
|
48
48
|
__resetCatalogCache,
|
|
49
49
|
buildCatalog,
|
|
50
|
+
canonicalRouterModelId,
|
|
50
51
|
catalogModelForId,
|
|
51
52
|
fetchModelCatalog,
|
|
52
53
|
isChatCapableModel,
|
|
53
54
|
normalizeModelId,
|
|
54
55
|
resolveCatalogModelId,
|
|
55
56
|
sortModelsByFreshness
|
|
56
|
-
} from "../chunk-
|
|
57
|
+
} from "../chunk-KSLTD4FI.js";
|
|
57
58
|
|
|
58
59
|
// src/runtime/certified-delivery.ts
|
|
59
60
|
import {
|
|
@@ -174,6 +175,7 @@ export {
|
|
|
174
175
|
asksForLanguage,
|
|
175
176
|
budgetTurnKnowledge,
|
|
176
177
|
buildCatalog,
|
|
178
|
+
canonicalRouterModelId,
|
|
177
179
|
catalogModelForId,
|
|
178
180
|
composeRouterTurnPrompt,
|
|
179
181
|
composeRouterTurnPromptSections,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/runtime/certified-delivery.ts","../../src/runtime/surface-profile.ts"],"sourcesContent":["/**\n * Application profile composition using Runtime's certified-guidance source.\n *\n * The shell adapts the prompt source to the application's resolved profile;\n * Runtime owns pulling, cache lifetime, concurrent refresh and retained guidance.\n * Only prompt-compatible guidance is folded here. Tool definitions, execution\n * permissions, MCP servers and files are not installed from certified material.\n * The complete profile remains available through `current()` for inspection and\n * the product's separately authorized materialization path.\n */\nimport {\n createCertifiedPromptSource,\n type CertifiedProfile,\n type CertifiedPromptSourceOptions,\n} from '@tangle-network/agent-runtime/intelligence'\nimport type { ResolvedAgentProfile } from './agent'\n\n/** Pull coordinates, refresh cadence and timeout owned by the shared source. */\nexport type CertifiedDeliveryConfig = CertifiedPromptSourceOptions\n\n/** Adapt certified prompt guidance without granting execution authority. */\nexport interface CertifiedDelivery {\n /** Refresh on the source's cadence and compose the current prompt guidance.\n * Other resolved profile fields pass through unchanged. */\n composeProfile(base: ResolvedAgentProfile): Promise<ResolvedAgentProfile>\n /** Force a pull now, coalescing with an in-flight pull. Best-effort; not a\n * post-activation revision barrier or a permission-revocation protocol. */\n refresh(): Promise<void>\n /** Last successfully pulled profile, or null before a successful pull. */\n current(): CertifiedProfile | null\n}\n\nexport function createCertifiedDelivery(config: CertifiedDeliveryConfig): CertifiedDelivery {\n const source = createCertifiedPromptSource(config)\n return {\n async composeProfile(base) {\n return { ...base, systemPrompt: await source.compose(base.systemPrompt) }\n },\n refresh: () => source.refresh({ force: true }),\n current: source.current,\n }\n}\n","/**\n * Surface-scoped profile overlay — the seam letting any product page (a\n * sequence editor, a brief composer, a dataset view) add MCP servers, a prompt\n * addendum, and permission tightening to the workspace agent profile for turns\n * initiated FROM that surface, without the chat orchestrator knowing any\n * surface's specifics. The orchestrator resolves `(kind, ctx)` through a\n * registry the REQUEST HANDLER constructs per request (construction is a Map\n * build — cheap) and merges the result into the base profile it was about to\n * send to the sandbox. Per-request construction is the trust mechanism, not an\n * optimization target: each `build()` closes over server-trusted request state\n * (env bindings, secrets, the AUTHENTICATED user/workspace), which on Workers\n * exists only per request — a startup-built registry would force identity\n * through the untrusted client `ctx`.\n *\n * SECURITY INVARIANT: the surface `kind` and the ids inside `ctx` arrive on\n * the client request and are pure ROUTING data — never trusted content, never\n * identity. Identity comes from the closure (see above). The registered\n * `build()` runs server-side only: it validates the routing ids against the\n * product's access control, then mints its own URLs from server configuration\n * (`buildHttpMcpServer` in ../tools). A client can therefore never inject an\n * arbitrary MCP url, header, or credential into the agent profile: the\n * overlay's `mcp` values are typed as {@link SurfaceMcpServer} (= the\n * server-built `AppToolMcpServer` entry shape), and only build() constructs\n * them.\n *\n * The credential itself never appears in the overlay. Since the tagged-config\n * contract (`agent-interface` 0.38.0) the `Authorization` header is a\n * `secret-ref` naming a box-environment variable, which the sandbox resolves\n * privately; `build()` supplies that key NAME from server configuration and the\n * product writes the value through `SandboxRuntimeConfig.env` at creation or\n * refreshes it through `SandboxRuntimeConfig.runtimeEnv` before retained-box\n * bootstrap. The value remains workspace-scoped because every member and turn\n * shares the box; runtime renewal does not create a per-user secret channel.\n */\n\nimport type { AppToolMcpServer } from '../tools/mcp'\n\n/** Sandbox permission posture values, ranked deny > ask > allow for merging. */\nexport type SurfacePermissionValue = 'allow' | 'ask' | 'deny'\n\n/** The only MCP entry shape an overlay may carry: the server-built bridge\n * entry from ../tools/mcp (transport, url, headers, and capability token all\n * assembled server-side). The alias exists so overlay authors reach for the\n * builders in ../tools rather than hand-rolling `{ url: ctx.url }` shapes\n * that would let request data become a dialable endpoint. */\nexport type SurfaceMcpServer = AppToolMcpServer\n\n/** What one surface contributes to the agent profile for a single turn. */\nexport interface SurfaceOverlay {\n /** MCP servers to mount for this turn, keyed by tool-routing name. Names\n * must not collide with the base profile's — see {@link mergeSurfaceOverlay}. */\n mcp?: Record<string, SurfaceMcpServer>\n /** Appended to the base system-prompt addendum with a blank-line separator. */\n promptAddendum?: string\n /** Per-key posture the surface wants for its turns. Merging is monotone\n * fail-closed: the stricter of base/overlay wins, so a surface can tighten\n * the workspace posture but never relax it. */\n permissions?: Record<string, SurfacePermissionValue>\n}\n\n/**\n * One registered surface kind. `TCtx` is the shape build() expects — a CLAIM\n * about the client payload, not a guarantee: the registry hands build() the\n * request's `ctx` unvalidated, so build() must treat every field as an\n * untrusted id (resolve it through access control that throws on a bad or\n * foreign id) before minting anything from it.\n */\nexport interface SurfaceKindDefinition<TCtx> {\n kind: string\n build: (ctx: TCtx) => SurfaceOverlay | Promise<SurfaceOverlay>\n}\n\n/** The variance-erased form a registry accepts (`build` is contravariant in\n * `TCtx`, so every concrete definition is assignable to this). */\nexport type AnySurfaceKind = SurfaceKindDefinition<never>\n\n/**\n * Declare one surface kind. The `kind` string is the client-visible routing\n * key (e.g. `'sequences'`); `build` is the server-side factory that turns a\n * validated ctx into the overlay for one turn.\n */\nexport function defineSurfaceKind<TCtx>(opts: {\n kind: string\n build: (ctx: TCtx) => SurfaceOverlay | Promise<SurfaceOverlay>\n}): SurfaceKindDefinition<TCtx> {\n if (typeof opts.kind !== 'string' || opts.kind.length === 0 || /\\s/.test(opts.kind)) {\n throw new Error(`surface kind must be a non-empty string without whitespace (got ${JSON.stringify(opts.kind)})`)\n }\n if (typeof opts.build !== 'function') {\n throw new Error(`surface kind '${opts.kind}' requires a build function`)\n }\n return { kind: opts.kind, build: opts.build }\n}\n\n/** Resolve and build the overlay for a given surface kind within a turn context */\nexport interface SurfaceRegistry {\n /** Build the overlay for one turn. Throws on an unknown kind — an unknown\n * surface is a routing bug (client and server registries drifted), and\n * silently returning an empty overlay would strip the surface's tools from\n * the turn with no signal anywhere. Build errors propagate unwrapped. */\n resolve(kind: string, ctx: unknown): Promise<SurfaceOverlay>\n}\n\n/**\n * Assemble the product's surface registry from its registered kinds. Duplicate\n * kinds throw at construction: two builders behind one routing key would make\n * the mounted toolset depend on registration order.\n */\nexport function createSurfaceRegistry(kinds: readonly AnySurfaceKind[]): SurfaceRegistry {\n const byKind = new Map<string, AnySurfaceKind>()\n for (const definition of kinds) {\n if (byKind.has(definition.kind)) {\n throw new Error(`duplicate surface kind '${definition.kind}' — each kind must be registered exactly once`)\n }\n byKind.set(definition.kind, definition)\n }\n\n return {\n async resolve(kind, ctx) {\n const definition = byKind.get(kind)\n if (!definition) {\n const known = [...byKind.keys()].join(', ') || '(none)'\n throw new Error(\n `unknown surface kind '${kind}' — registered kinds: ${known}. ` +\n 'An unknown surface is a routing bug: register the kind via defineSurfaceKind before clients can reference it.',\n )\n }\n // The trust boundary where static ctx typing ends: the request payload is\n // handed to build() as-is, and build() validates it (see SurfaceKindDefinition).\n const overlay = await definition.build(ctx as never)\n assertSurfaceOverlay(overlay, `surface kind '${kind}'`)\n return overlay\n },\n }\n}\n\n/** Base-profile slice the merge reads/writes. Real callers pass their full\n * profile object; every field outside this slice passes through untouched. */\nexport interface SurfaceMergeBase {\n mcp?: Record<string, unknown>\n systemPromptAddendum?: string\n permissions?: Record<string, SurfacePermissionValue>\n}\n\nconst PERMISSION_SEVERITY: Record<SurfacePermissionValue, number> = { allow: 0, ask: 1, deny: 2 }\n\n/**\n * Merge one surface overlay into a base profile, returning a new object\n * (the base is never mutated; untouched nested records are shared by\n * reference).\n *\n * - `mcp`: overlay servers are added under their own names. A name already\n * present on the base THROWS — a collision is two servers claiming one\n * routing name, and renaming either silently would corrupt tool routing for\n * whichever caller expected the original binding.\n * - `systemPromptAddendum`: the overlay's `promptAddendum` appends after a\n * blank-line separator (no separator when the base has no addendum).\n * - `permissions`: per key the STRICTER value wins (deny > ask > allow). A\n * surface can tighten the base posture for its turns; a base 'deny' survives\n * any overlay.\n */\nexport function mergeSurfaceOverlay<TBase extends SurfaceMergeBase>(\n base: TBase,\n overlay: SurfaceOverlay,\n): TBase & SurfaceMergeBase {\n assertSurfaceOverlay(overlay, 'surface overlay')\n const merged: SurfaceMergeBase = { ...base }\n\n if (overlay.mcp && Object.keys(overlay.mcp).length > 0) {\n const baseMcp = base.mcp ?? {}\n const collisions = Object.keys(overlay.mcp).filter((name) => name in baseMcp)\n if (collisions.length > 0) {\n throw new Error(\n `surface overlay MCP name collision: ${collisions.map((n) => `'${n}'`).join(', ')} already exist on the base profile. ` +\n 'Two servers cannot claim one name — give the surface server a distinct name.',\n )\n }\n merged.mcp = { ...baseMcp, ...overlay.mcp }\n }\n\n if (overlay.promptAddendum !== undefined) {\n merged.systemPromptAddendum = base.systemPromptAddendum\n ? `${base.systemPromptAddendum}\\n\\n${overlay.promptAddendum}`\n : overlay.promptAddendum\n }\n\n if (overlay.permissions && Object.keys(overlay.permissions).length > 0) {\n const permissions: Record<string, SurfacePermissionValue> = { ...(base.permissions ?? {}) }\n for (const [key, value] of Object.entries(overlay.permissions)) {\n const existing = permissions[key]\n permissions[key] =\n existing === undefined || PERMISSION_SEVERITY[value] > PERMISSION_SEVERITY[existing] ? value : existing\n }\n merged.permissions = permissions\n }\n\n // merged began as a shallow copy of base; only the three slice fields were\n // replaced, so the intersection type is the true shape.\n return merged as TBase & SurfaceMergeBase\n}\n\n/** Reject overlays a build() (or hand-rolled caller) malformed, with the exact\n * field named: a relative MCP url, a blank addendum, or an off-vocabulary\n * permission would otherwise surface only as an opaque sandbox failure. */\nfunction assertSurfaceOverlay(overlay: SurfaceOverlay, label: string): void {\n if (overlay.promptAddendum !== undefined) {\n if (typeof overlay.promptAddendum !== 'string' || overlay.promptAddendum.trim().length === 0) {\n throw new Error(`${label}: promptAddendum must be a non-blank string when provided`)\n }\n }\n if (overlay.mcp !== undefined) {\n for (const [name, server] of Object.entries(overlay.mcp)) {\n if (name.trim().length === 0) throw new Error(`${label}: MCP server names must be non-empty`)\n if (server.transport !== 'http') {\n throw new Error(`${label}: MCP server '${name}' must use transport 'http' (got ${JSON.stringify((server as { transport?: unknown }).transport)})`)\n }\n let parsed: URL\n try {\n parsed = new URL(server.url)\n } catch {\n throw new Error(`${label}: MCP server '${name}' url must be an absolute URL (got ${JSON.stringify(server.url)})`)\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n throw new Error(`${label}: MCP server '${name}' url must be http(s) (got ${JSON.stringify(server.url)})`)\n }\n }\n }\n if (overlay.permissions !== undefined) {\n for (const [key, value] of Object.entries(overlay.permissions)) {\n if (!(value in PERMISSION_SEVERITY)) {\n throw new Error(`${label}: permission '${key}' must be 'allow' | 'ask' | 'deny' (got ${JSON.stringify(value)})`)\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA;AAAA,EACE;AAAA,OAGK;AAkB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mBAAmB,YAAY,QAAQ,eAAe,KAAK,EAAE,WAAW,GAAG;AAC5F,YAAM,IAAI,MAAM,GAAG,KAAK,2DAA2D;AAAA,IACrF;AAAA,EACF;AACA,MAAI,QAAQ,QAAQ,QAAW;AAC7B,eAAW,CAAC,MAAM,MAAM,KAAK,OAAO,QAAQ,QAAQ,GAAG,GAAG;AACxD,UAAI,KAAK,KAAK,EAAE,WAAW,EAAG,OAAM,IAAI,MAAM,GAAG,KAAK,sCAAsC;AAC5F,UAAI,OAAO,cAAc,QAAQ;AAC/B,cAAM,IAAI,MAAM,GAAG,KAAK,iBAAiB,IAAI,oCAAoC,KAAK,UAAW,OAAmC,SAAS,CAAC,GAAG;AAAA,MACnJ;AACA,UAAI;AACJ,UAAI;AACF,iBAAS,IAAI,IAAI,OAAO,GAAG;AAAA,MAC7B,QAAQ;AACN,cAAM,IAAI,MAAM,GAAG,KAAK,iBAAiB,IAAI,sCAAsC,KAAK,UAAU,OAAO,GAAG,CAAC,GAAG;AAAA,MAClH;AACA,UAAI,OAAO,aAAa,WAAW,OAAO,aAAa,UAAU;AAC/D,cAAM,IAAI,MAAM,GAAG,KAAK,iBAAiB,IAAI,8BAA8B,KAAK,UAAU,OAAO,GAAG,CAAC,GAAG;AAAA,MAC1G;AAAA,IACF;AAAA,EACF;AACA,MAAI,QAAQ,gBAAgB,QAAW;AACrC,eAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,WAAW,GAAG;AAC9D,UAAI,EAAE,SAAS,sBAAsB;AACnC,cAAM,IAAI,MAAM,GAAG,KAAK,iBAAiB,GAAG,2CAA2C,KAAK,UAAU,KAAK,CAAC,GAAG;AAAA,MACjH;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/runtime/certified-delivery.ts","../../src/runtime/surface-profile.ts"],"sourcesContent":["/**\n * Application profile composition using Runtime's certified-guidance source.\n *\n * The shell adapts the prompt source to the application's resolved profile;\n * Runtime owns pulling, cache lifetime, concurrent refresh and retained guidance.\n * Only prompt-compatible guidance is folded here. Tool definitions, execution\n * permissions, MCP servers and files are not installed from certified material.\n * The complete profile remains available through `current()` for inspection and\n * the product's separately authorized materialization path.\n */\nimport {\n createCertifiedPromptSource,\n type CertifiedProfile,\n type CertifiedPromptSourceOptions,\n} from '@tangle-network/agent-runtime/intelligence'\nimport type { ResolvedAgentProfile } from './agent'\n\n/** Pull coordinates, refresh cadence and timeout owned by the shared source. */\nexport type CertifiedDeliveryConfig = CertifiedPromptSourceOptions\n\n/** Adapt certified prompt guidance without granting execution authority. */\nexport interface CertifiedDelivery {\n /** Refresh on the source's cadence and compose the current prompt guidance.\n * Other resolved profile fields pass through unchanged. */\n composeProfile(base: ResolvedAgentProfile): Promise<ResolvedAgentProfile>\n /** Force a pull now, coalescing with an in-flight pull. Best-effort; not a\n * post-activation revision barrier or a permission-revocation protocol. */\n refresh(): Promise<void>\n /** Last successfully pulled profile, or null before a successful pull. */\n current(): CertifiedProfile | null\n}\n\nexport function createCertifiedDelivery(config: CertifiedDeliveryConfig): CertifiedDelivery {\n const source = createCertifiedPromptSource(config)\n return {\n async composeProfile(base) {\n return { ...base, systemPrompt: await source.compose(base.systemPrompt) }\n },\n refresh: () => source.refresh({ force: true }),\n current: source.current,\n }\n}\n","/**\n * Surface-scoped profile overlay — the seam letting any product page (a\n * sequence editor, a brief composer, a dataset view) add MCP servers, a prompt\n * addendum, and permission tightening to the workspace agent profile for turns\n * initiated FROM that surface, without the chat orchestrator knowing any\n * surface's specifics. The orchestrator resolves `(kind, ctx)` through a\n * registry the REQUEST HANDLER constructs per request (construction is a Map\n * build — cheap) and merges the result into the base profile it was about to\n * send to the sandbox. Per-request construction is the trust mechanism, not an\n * optimization target: each `build()` closes over server-trusted request state\n * (env bindings, secrets, the AUTHENTICATED user/workspace), which on Workers\n * exists only per request — a startup-built registry would force identity\n * through the untrusted client `ctx`.\n *\n * SECURITY INVARIANT: the surface `kind` and the ids inside `ctx` arrive on\n * the client request and are pure ROUTING data — never trusted content, never\n * identity. Identity comes from the closure (see above). The registered\n * `build()` runs server-side only: it validates the routing ids against the\n * product's access control, then mints its own URLs from server configuration\n * (`buildHttpMcpServer` in ../tools). A client can therefore never inject an\n * arbitrary MCP url, header, or credential into the agent profile: the\n * overlay's `mcp` values are typed as {@link SurfaceMcpServer} (= the\n * server-built `AppToolMcpServer` entry shape), and only build() constructs\n * them.\n *\n * The credential itself never appears in the overlay. Since the tagged-config\n * contract (`agent-interface` 0.38.0) the `Authorization` header is a\n * `secret-ref` naming a box-environment variable, which the sandbox resolves\n * privately; `build()` supplies that key NAME from server configuration and the\n * product writes the value through `SandboxRuntimeConfig.env` at creation or\n * refreshes it through `SandboxRuntimeConfig.runtimeEnv` before retained-box\n * bootstrap. The value remains workspace-scoped because every member and turn\n * shares the box; runtime renewal does not create a per-user secret channel.\n */\n\nimport type { AppToolMcpServer } from '../tools/mcp'\n\n/** Sandbox permission posture values, ranked deny > ask > allow for merging. */\nexport type SurfacePermissionValue = 'allow' | 'ask' | 'deny'\n\n/** The only MCP entry shape an overlay may carry: the server-built bridge\n * entry from ../tools/mcp (transport, url, headers, and capability token all\n * assembled server-side). The alias exists so overlay authors reach for the\n * builders in ../tools rather than hand-rolling `{ url: ctx.url }` shapes\n * that would let request data become a dialable endpoint. */\nexport type SurfaceMcpServer = AppToolMcpServer\n\n/** What one surface contributes to the agent profile for a single turn. */\nexport interface SurfaceOverlay {\n /** MCP servers to mount for this turn, keyed by tool-routing name. Names\n * must not collide with the base profile's — see {@link mergeSurfaceOverlay}. */\n mcp?: Record<string, SurfaceMcpServer>\n /** Appended to the base system-prompt addendum with a blank-line separator. */\n promptAddendum?: string\n /** Per-key posture the surface wants for its turns. Merging is monotone\n * fail-closed: the stricter of base/overlay wins, so a surface can tighten\n * the workspace posture but never relax it. */\n permissions?: Record<string, SurfacePermissionValue>\n}\n\n/**\n * One registered surface kind. `TCtx` is the shape build() expects — a CLAIM\n * about the client payload, not a guarantee: the registry hands build() the\n * request's `ctx` unvalidated, so build() must treat every field as an\n * untrusted id (resolve it through access control that throws on a bad or\n * foreign id) before minting anything from it.\n */\nexport interface SurfaceKindDefinition<TCtx> {\n kind: string\n build: (ctx: TCtx) => SurfaceOverlay | Promise<SurfaceOverlay>\n}\n\n/** The variance-erased form a registry accepts (`build` is contravariant in\n * `TCtx`, so every concrete definition is assignable to this). */\nexport type AnySurfaceKind = SurfaceKindDefinition<never>\n\n/**\n * Declare one surface kind. The `kind` string is the client-visible routing\n * key (e.g. `'sequences'`); `build` is the server-side factory that turns a\n * validated ctx into the overlay for one turn.\n */\nexport function defineSurfaceKind<TCtx>(opts: {\n kind: string\n build: (ctx: TCtx) => SurfaceOverlay | Promise<SurfaceOverlay>\n}): SurfaceKindDefinition<TCtx> {\n if (typeof opts.kind !== 'string' || opts.kind.length === 0 || /\\s/.test(opts.kind)) {\n throw new Error(`surface kind must be a non-empty string without whitespace (got ${JSON.stringify(opts.kind)})`)\n }\n if (typeof opts.build !== 'function') {\n throw new Error(`surface kind '${opts.kind}' requires a build function`)\n }\n return { kind: opts.kind, build: opts.build }\n}\n\n/** Resolve and build the overlay for a given surface kind within a turn context */\nexport interface SurfaceRegistry {\n /** Build the overlay for one turn. Throws on an unknown kind — an unknown\n * surface is a routing bug (client and server registries drifted), and\n * silently returning an empty overlay would strip the surface's tools from\n * the turn with no signal anywhere. Build errors propagate unwrapped. */\n resolve(kind: string, ctx: unknown): Promise<SurfaceOverlay>\n}\n\n/**\n * Assemble the product's surface registry from its registered kinds. Duplicate\n * kinds throw at construction: two builders behind one routing key would make\n * the mounted toolset depend on registration order.\n */\nexport function createSurfaceRegistry(kinds: readonly AnySurfaceKind[]): SurfaceRegistry {\n const byKind = new Map<string, AnySurfaceKind>()\n for (const definition of kinds) {\n if (byKind.has(definition.kind)) {\n throw new Error(`duplicate surface kind '${definition.kind}' — each kind must be registered exactly once`)\n }\n byKind.set(definition.kind, definition)\n }\n\n return {\n async resolve(kind, ctx) {\n const definition = byKind.get(kind)\n if (!definition) {\n const known = [...byKind.keys()].join(', ') || '(none)'\n throw new Error(\n `unknown surface kind '${kind}' — registered kinds: ${known}. ` +\n 'An unknown surface is a routing bug: register the kind via defineSurfaceKind before clients can reference it.',\n )\n }\n // The trust boundary where static ctx typing ends: the request payload is\n // handed to build() as-is, and build() validates it (see SurfaceKindDefinition).\n const overlay = await definition.build(ctx as never)\n assertSurfaceOverlay(overlay, `surface kind '${kind}'`)\n return overlay\n },\n }\n}\n\n/** Base-profile slice the merge reads/writes. Real callers pass their full\n * profile object; every field outside this slice passes through untouched. */\nexport interface SurfaceMergeBase {\n mcp?: Record<string, unknown>\n systemPromptAddendum?: string\n permissions?: Record<string, SurfacePermissionValue>\n}\n\nconst PERMISSION_SEVERITY: Record<SurfacePermissionValue, number> = { allow: 0, ask: 1, deny: 2 }\n\n/**\n * Merge one surface overlay into a base profile, returning a new object\n * (the base is never mutated; untouched nested records are shared by\n * reference).\n *\n * - `mcp`: overlay servers are added under their own names. A name already\n * present on the base THROWS — a collision is two servers claiming one\n * routing name, and renaming either silently would corrupt tool routing for\n * whichever caller expected the original binding.\n * - `systemPromptAddendum`: the overlay's `promptAddendum` appends after a\n * blank-line separator (no separator when the base has no addendum).\n * - `permissions`: per key the STRICTER value wins (deny > ask > allow). A\n * surface can tighten the base posture for its turns; a base 'deny' survives\n * any overlay.\n */\nexport function mergeSurfaceOverlay<TBase extends SurfaceMergeBase>(\n base: TBase,\n overlay: SurfaceOverlay,\n): TBase & SurfaceMergeBase {\n assertSurfaceOverlay(overlay, 'surface overlay')\n const merged: SurfaceMergeBase = { ...base }\n\n if (overlay.mcp && Object.keys(overlay.mcp).length > 0) {\n const baseMcp = base.mcp ?? {}\n const collisions = Object.keys(overlay.mcp).filter((name) => name in baseMcp)\n if (collisions.length > 0) {\n throw new Error(\n `surface overlay MCP name collision: ${collisions.map((n) => `'${n}'`).join(', ')} already exist on the base profile. ` +\n 'Two servers cannot claim one name — give the surface server a distinct name.',\n )\n }\n merged.mcp = { ...baseMcp, ...overlay.mcp }\n }\n\n if (overlay.promptAddendum !== undefined) {\n merged.systemPromptAddendum = base.systemPromptAddendum\n ? `${base.systemPromptAddendum}\\n\\n${overlay.promptAddendum}`\n : overlay.promptAddendum\n }\n\n if (overlay.permissions && Object.keys(overlay.permissions).length > 0) {\n const permissions: Record<string, SurfacePermissionValue> = { ...(base.permissions ?? {}) }\n for (const [key, value] of Object.entries(overlay.permissions)) {\n const existing = permissions[key]\n permissions[key] =\n existing === undefined || PERMISSION_SEVERITY[value] > PERMISSION_SEVERITY[existing] ? value : existing\n }\n merged.permissions = permissions\n }\n\n // merged began as a shallow copy of base; only the three slice fields were\n // replaced, so the intersection type is the true shape.\n return merged as TBase & SurfaceMergeBase\n}\n\n/** Reject overlays a build() (or hand-rolled caller) malformed, with the exact\n * field named: a relative MCP url, a blank addendum, or an off-vocabulary\n * permission would otherwise surface only as an opaque sandbox failure. */\nfunction assertSurfaceOverlay(overlay: SurfaceOverlay, label: string): void {\n if (overlay.promptAddendum !== undefined) {\n if (typeof overlay.promptAddendum !== 'string' || overlay.promptAddendum.trim().length === 0) {\n throw new Error(`${label}: promptAddendum must be a non-blank string when provided`)\n }\n }\n if (overlay.mcp !== undefined) {\n for (const [name, server] of Object.entries(overlay.mcp)) {\n if (name.trim().length === 0) throw new Error(`${label}: MCP server names must be non-empty`)\n if (server.transport !== 'http') {\n throw new Error(`${label}: MCP server '${name}' must use transport 'http' (got ${JSON.stringify((server as { transport?: unknown }).transport)})`)\n }\n let parsed: URL\n try {\n parsed = new URL(server.url)\n } catch {\n throw new Error(`${label}: MCP server '${name}' url must be an absolute URL (got ${JSON.stringify(server.url)})`)\n }\n if (parsed.protocol !== 'http:' && parsed.protocol !== 'https:') {\n throw new Error(`${label}: MCP server '${name}' url must be http(s) (got ${JSON.stringify(server.url)})`)\n }\n }\n }\n if (overlay.permissions !== undefined) {\n for (const [key, value] of Object.entries(overlay.permissions)) {\n if (!(value in PERMISSION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AC,GAAG;AAAA,MACjH;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -83,6 +83,11 @@ export interface ModelCatalog {
|
|
|
83
83
|
fetchedAt: string;
|
|
84
84
|
models: CatalogModel[];
|
|
85
85
|
}
|
|
86
|
+
/** Canonical router-facing id: "provider/model". Pickers display, products
|
|
87
|
+
* persist, and turns send this form. The prefix is the RAW router provider
|
|
88
|
+
* ('moonshotai/kimi-k2'), never the normalized display alias, so the id is a
|
|
89
|
+
* live router entry that validation admits. */
|
|
90
|
+
export declare function canonicalRouterModelId(model: Pick<RouterModel, 'id' | '_provider' | 'provider' | 'routeability'>): string;
|
|
86
91
|
/** A short, varied first screen. All other routeable entries remain searchable. */
|
|
87
92
|
export declare const MAX_RECOMMENDED_MODELS = 8;
|
|
88
93
|
/** Strip provider prefix, :free suffix, and trailing date stamps. */
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
turnKnowledgeInstructions,
|
|
14
14
|
workspaceKnowledgeForTurn,
|
|
15
15
|
workspaceTurnCheckpoints
|
|
16
|
-
} from "../chunk-
|
|
16
|
+
} from "../chunk-2ARZ4Y7D.js";
|
|
17
17
|
import "../chunk-LPW4UVAZ.js";
|
|
18
18
|
import "../chunk-DCPOEDPK.js";
|
|
19
|
-
import "../chunk-
|
|
19
|
+
import "../chunk-KSLTD4FI.js";
|
|
20
20
|
export {
|
|
21
21
|
DURABLE_HOP_BUDGET_MS,
|
|
22
22
|
asksForLanguage,
|