@zigil/agent-react 0.1.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/LICENSE +202 -0
- package/dist/attention-telemetry.d.ts +61 -0
- package/dist/attention-telemetry.js +206 -0
- package/dist/attention-telemetry.js.map +1 -0
- package/dist/attention.d.ts +45 -0
- package/dist/attention.js +358 -0
- package/dist/attention.js.map +1 -0
- package/dist/context-draft.d.ts +68 -0
- package/dist/context-draft.js +722 -0
- package/dist/context-draft.js.map +1 -0
- package/dist/context-privacy.d.ts +13 -0
- package/dist/context-privacy.js +82 -0
- package/dist/context-privacy.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1078 -0
- package/dist/index.js.map +1 -0
- package/dist/session.d.ts +11 -0
- package/dist/session.js +26 -0
- package/dist/session.js.map +1 -0
- package/dist/thread-controls.d.ts +11 -0
- package/dist/thread-controls.js +27 -0
- package/dist/thread-controls.js.map +1 -0
- package/package.json +60 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/attention.tsx","../src/attention-telemetry.ts","../src/context-draft.ts","../src/context-privacy.ts","../src/session.tsx","../src/thread-controls.tsx"],"sourcesContent":["import {\n createContext,\n createElement,\n useContext,\n type ReactNode,\n} from \"react\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nimport type { AttentionPrivacyLevel } from \"./context-privacy.js\";\n\nconst MAX_SERIALIZED_BYTES = 4 * 1024;\nconst MAX_REQUIRED_FIELD_LENGTH = 128;\nconst MAX_SELECTIONS = 12;\nconst MAX_HISTORY = 40;\nconst MAX_FOCUSED_HISTORY = 8;\nconst MAX_HOVER_HISTORY = 2;\n\nexport interface AttentionSelection {\n readonly kind: string;\n readonly id: string;\n readonly label?: string;\n readonly detail?: Readonly<Record<string, string>>;\n}\n\nexport const ATTENTION_ACTIVITY_ACTIONS = [\n \"focus\",\n \"select\",\n \"navigate\",\n \"edit\",\n \"execute\",\n \"approve\",\n \"dismiss\",\n \"hover\",\n] as const;\n\nexport type AttentionActivityAction =\n (typeof ATTENTION_ACTIVITY_ACTIONS)[number];\n\nexport interface AttentionActivityEvent {\n readonly action: AttentionActivityAction;\n readonly target: AttentionSelection;\n readonly timestamp: number;\n readonly summary?: string;\n readonly detail?: Readonly<Record<string, string>>;\n}\n\nexport interface AttentionContext {\n readonly application: string;\n readonly route: string;\n readonly workspace?: {\n readonly kind: string;\n readonly id: string;\n readonly label?: string;\n readonly revision?: number;\n };\n readonly selection?: AttentionSelection;\n readonly selections?: readonly AttentionSelection[];\n readonly hover?: AttentionSelection;\n readonly history?: readonly AttentionActivityEvent[];\n}\n\ntype MutableSelection = {\n kind: string;\n id: string;\n label?: string;\n detail?: Record<string, string>;\n};\n\ntype MutableActivity = {\n action: AttentionActivityAction;\n target: MutableSelection;\n timestamp: number;\n summary?: string;\n detail?: Record<string, string>;\n};\n\ntype MutableAttention = {\n application: string;\n route: string;\n workspace?: {\n kind: string;\n id: string;\n label?: string;\n revision?: number;\n };\n selection?: MutableSelection;\n selections?: MutableSelection[];\n hover?: MutableSelection;\n history?: MutableActivity[];\n};\n\nconst AttentionContextReact = createContext<AttentionContext | null>(null);\n\nexport function AttentionProvider({\n children,\n context,\n}: {\n readonly children: ReactNode;\n readonly context: AttentionContext;\n}) {\n return createElement(\n AttentionContextReact.Provider,\n { value: context },\n children,\n );\n}\n\nexport function useAttention(): AttentionContext | null {\n return useContext(AttentionContextReact);\n}\n\nexport function formatAttentionLabel(\n attention: AttentionContext | null,\n): string {\n const primary =\n attention?.selection?.label ??\n attention?.selection?.id ??\n attention?.workspace?.label ??\n \"this workspace\";\n const extraSelections = Math.max(0, (attention?.selections?.length ?? 0) - 1);\n return extraSelections > 0 ? `${primary} +${extraSelections}` : primary;\n}\n\nexport const AttentionContextSchema = standardSchema<AttentionContext>(\n (value) => {\n const issues = validateAttentionContext(value);\n return issues.length > 0 ? issues : (value as AttentionContext);\n },\n);\n\nexport function serializeAttention(\n context: AttentionContext,\n privacy: AttentionPrivacyLevel = \"focused\",\n): string {\n const normalized = normalizeAttention(context, privacy);\n assertClosedAttention(normalized);\n let serialized = JSON.stringify(normalized);\n if (byteLength(serialized) <= MAX_SERIALIZED_BYTES) return serialized;\n\n warnOversizedAttention();\n\n while (normalized.history?.some((event) => event.action === \"hover\")) {\n const hoverIndex = normalized.history.findIndex(\n (event) => event.action === \"hover\",\n );\n normalized.history.splice(hoverIndex, 1);\n if (normalized.history.length === 0) delete normalized.history;\n serialized = JSON.stringify(normalized);\n if (byteLength(serialized) <= MAX_SERIALIZED_BYTES) return serialized;\n }\n\n while ((normalized.history?.length ?? 0) > 0) {\n normalized.history?.shift();\n if (normalized.history?.length === 0) delete normalized.history;\n serialized = JSON.stringify(normalized);\n if (byteLength(serialized) <= MAX_SERIALIZED_BYTES) return serialized;\n }\n\n delete normalized.hover;\n serialized = JSON.stringify(normalized);\n if (byteLength(serialized) <= MAX_SERIALIZED_BYTES) return serialized;\n\n removeOptionalSelectionFields(normalized);\n serialized = JSON.stringify(normalized);\n if (byteLength(serialized) <= MAX_SERIALIZED_BYTES) return serialized;\n\n const required = truncateRequiredFields(normalized);\n serialized = JSON.stringify(required);\n while (\n byteLength(serialized) > MAX_SERIALIZED_BYTES &&\n (required.selections?.length ?? 0) > 0\n ) {\n required.selections?.pop();\n if (required.selections?.length === 0) delete required.selections;\n serialized = JSON.stringify(required);\n }\n return serialized;\n}\n\nexport function validateAttentionContext(\n value: unknown,\n path: readonly PropertyKey[] = [],\n): StandardSchemaV1.Issue[] {\n if (!isRecord(value)) return [issue(\"Expected attention context\", ...path)];\n const issues: StandardSchemaV1.Issue[] = [];\n if (\n !hasOnlyKeys(value, [\n \"application\",\n \"route\",\n \"workspace\",\n \"selection\",\n \"selections\",\n \"hover\",\n \"history\",\n ])\n )\n issues.push(issue(\"Unexpected attention field\", ...path));\n if (typeof value.application !== \"string\")\n issues.push(issue(\"Expected a string\", ...path, \"application\"));\n if (typeof value.route !== \"string\")\n issues.push(issue(\"Expected a string\", ...path, \"route\"));\n if (value.workspace !== undefined)\n issues.push(...validateWorkspace(value.workspace, [...path, \"workspace\"]));\n if (value.selection !== undefined)\n issues.push(...validateSelection(value.selection, [...path, \"selection\"]));\n if (value.hover !== undefined)\n issues.push(...validateSelection(value.hover, [...path, \"hover\"]));\n if (value.selections !== undefined) {\n if (!Array.isArray(value.selections))\n issues.push(issue(\"Expected selections\", ...path, \"selections\"));\n else\n value.selections.forEach((selection, index) =>\n issues.push(\n ...validateSelection(selection, [...path, \"selections\", index]),\n ),\n );\n }\n if (value.history !== undefined) {\n if (!Array.isArray(value.history))\n issues.push(issue(\"Expected activity history\", ...path, \"history\"));\n else\n value.history.forEach((event, index) =>\n issues.push(...validateActivity(event, [...path, \"history\", index])),\n );\n }\n return issues;\n}\n\nfunction normalizeAttention(\n context: AttentionContext,\n privacy: AttentionPrivacyLevel,\n): MutableAttention {\n const workspace = context.workspace\n ? {\n kind: context.workspace.kind,\n id: context.workspace.id,\n ...(context.workspace.revision === undefined\n ? {}\n : { revision: context.workspace.revision }),\n ...(privacy === \"minimal\" || context.workspace.label === undefined\n ? {}\n : { label: context.workspace.label }),\n }\n : undefined;\n const primary = context.selection\n ? normalizeSelection(context.selection, privacy !== \"minimal\")\n : undefined;\n\n if (privacy === \"minimal\") {\n return {\n application: context.application,\n route: context.route,\n ...(workspace ? { workspace } : {}),\n ...(primary ? { selection: primary } : {}),\n };\n }\n\n const selections = normalizeSelections(context.selections, primary);\n const history = normalizeHistory(\n context.history,\n privacy === \"focused\" ? MAX_FOCUSED_HISTORY : MAX_HISTORY,\n privacy === \"expanded\",\n );\n return {\n application: context.application,\n route: context.route,\n ...(workspace ? { workspace } : {}),\n ...(primary ? { selection: primary } : {}),\n ...(selections.length > 0 ? { selections } : {}),\n ...(privacy === \"expanded\" && context.hover\n ? { hover: normalizeSelection(context.hover, true) }\n : {}),\n ...(history.length > 0 ? { history } : {}),\n };\n}\n\nfunction normalizeSelections(\n selections: readonly AttentionSelection[] | undefined,\n primary: MutableSelection | undefined,\n): MutableSelection[] {\n const ordered = primary\n ? [\n primary,\n ...(selections ?? []).map((item) => normalizeSelection(item, true)),\n ]\n : (selections ?? []).map((item) => normalizeSelection(item, true));\n const seen = new Set<string>();\n return ordered\n .filter((item) => {\n const key = selectionKey(item);\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n })\n .slice(0, MAX_SELECTIONS);\n}\n\nfunction normalizeHistory(\n history: readonly AttentionActivityEvent[] | undefined,\n limit: number,\n includeHover: boolean,\n): MutableActivity[] {\n const semantic: MutableActivity[] = [];\n const hovers: MutableActivity[] = [];\n for (const event of history ?? []) {\n const normalized = normalizeEvent(event);\n if (normalized.action !== \"hover\") semantic.push(normalized);\n else if (includeHover) {\n const previous = hovers.at(-1);\n if (\n previous &&\n selectionKey(previous.target) === selectionKey(normalized.target)\n )\n hovers[hovers.length - 1] = normalized;\n else hovers.push(normalized);\n }\n }\n const retainedSemantic = semantic.slice(-limit);\n const remaining = Math.max(0, limit - retainedSemantic.length);\n const hoverLimit = Math.min(MAX_HOVER_HISTORY, remaining);\n const retainedHover = hoverLimit > 0 ? hovers.slice(-hoverLimit) : [];\n return [...retainedSemantic, ...retainedHover].sort(\n (left, right) => left.timestamp - right.timestamp,\n );\n}\n\nfunction normalizeEvent(event: AttentionActivityEvent): MutableActivity {\n return {\n action: event.action,\n target: normalizeSelection(event.target, true),\n timestamp: event.timestamp,\n ...(event.summary === undefined ? {} : { summary: event.summary }),\n ...(event.detail === undefined ? {} : { detail: sortRecord(event.detail) }),\n };\n}\n\nfunction normalizeSelection(\n selection: AttentionSelection,\n includeOptional: boolean,\n): MutableSelection {\n return {\n kind: selection.kind,\n id: selection.id,\n ...(includeOptional && selection.label !== undefined\n ? { label: selection.label }\n : {}),\n ...(includeOptional && selection.detail !== undefined\n ? { detail: sortRecord(selection.detail) }\n : {}),\n };\n}\n\nfunction removeOptionalSelectionFields(context: MutableAttention): void {\n const selections = [\n context.selection,\n ...(context.selections ?? []),\n context.hover,\n ].filter((selection): selection is MutableSelection => Boolean(selection));\n for (const selection of selections.reverse()) {\n for (const key of Object.keys(selection.detail ?? {}).reverse()) {\n if (!selection.detail) break;\n delete selection.detail[key];\n if (Object.keys(selection.detail).length === 0) delete selection.detail;\n }\n delete selection.label;\n }\n if (context.workspace) delete context.workspace.label;\n}\n\nfunction truncateRequiredFields(context: MutableAttention): MutableAttention {\n return {\n application: truncateText(context.application),\n route: truncateText(context.route),\n ...(context.workspace\n ? {\n workspace: {\n kind: truncateText(context.workspace.kind),\n id: truncateText(context.workspace.id),\n ...(context.workspace.revision === undefined\n ? {}\n : { revision: context.workspace.revision }),\n },\n }\n : {}),\n ...(context.selection\n ? {\n selection: {\n kind: truncateText(context.selection.kind),\n id: truncateText(context.selection.id),\n },\n }\n : {}),\n ...(context.selections\n ? {\n selections: context.selections\n .slice(0, MAX_SELECTIONS)\n .map((item) => ({\n kind: truncateText(item.kind),\n id: truncateText(item.id),\n })),\n }\n : {}),\n };\n}\n\nfunction validateWorkspace(\n value: unknown,\n path: readonly PropertyKey[],\n): StandardSchemaV1.Issue[] {\n if (!isRecord(value)) return [issue(\"Expected a workspace\", ...path)];\n const issues: StandardSchemaV1.Issue[] = [];\n if (!hasOnlyKeys(value, [\"kind\", \"id\", \"label\", \"revision\"]))\n issues.push(issue(\"Unexpected workspace field\", ...path));\n for (const key of [\"kind\", \"id\"] as const)\n if (typeof value[key] !== \"string\")\n issues.push(issue(\"Expected a string\", ...path, key));\n if (value.label !== undefined && typeof value.label !== \"string\")\n issues.push(issue(\"Expected a string\", ...path, \"label\"));\n if (\n value.revision !== undefined &&\n (typeof value.revision !== \"number\" || !Number.isFinite(value.revision))\n )\n issues.push(issue(\"Expected a finite revision\", ...path, \"revision\"));\n return issues;\n}\n\nfunction validateSelection(\n value: unknown,\n path: readonly PropertyKey[],\n): StandardSchemaV1.Issue[] {\n if (!isRecord(value)) return [issue(\"Expected a selection\", ...path)];\n const issues: StandardSchemaV1.Issue[] = [];\n if (!hasOnlyKeys(value, [\"kind\", \"id\", \"label\", \"detail\"]))\n issues.push(issue(\"Unexpected selection field\", ...path));\n for (const key of [\"kind\", \"id\"] as const)\n if (typeof value[key] !== \"string\")\n issues.push(issue(\"Expected a string\", ...path, key));\n if (value.label !== undefined && typeof value.label !== \"string\")\n issues.push(issue(\"Expected a string\", ...path, \"label\"));\n issues.push(...validateStringRecord(value.detail, [...path, \"detail\"]));\n return issues;\n}\n\nfunction validateActivity(\n value: unknown,\n path: readonly PropertyKey[],\n): StandardSchemaV1.Issue[] {\n if (!isRecord(value)) return [issue(\"Expected activity\", ...path)];\n const issues: StandardSchemaV1.Issue[] = [];\n if (\n !hasOnlyKeys(value, [\"action\", \"target\", \"timestamp\", \"summary\", \"detail\"])\n )\n issues.push(issue(\"Unexpected activity field\", ...path));\n if (\n typeof value.action !== \"string\" ||\n !ATTENTION_ACTIVITY_ACTIONS.includes(\n value.action as AttentionActivityAction,\n )\n )\n issues.push(issue(\"Expected an action\", ...path, \"action\"));\n if (typeof value.timestamp !== \"number\" || !Number.isFinite(value.timestamp))\n issues.push(issue(\"Expected a finite timestamp\", ...path, \"timestamp\"));\n if (value.summary !== undefined && typeof value.summary !== \"string\")\n issues.push(issue(\"Expected a string\", ...path, \"summary\"));\n issues.push(...validateSelection(value.target, [...path, \"target\"]));\n issues.push(...validateStringRecord(value.detail, [...path, \"detail\"]));\n return issues;\n}\n\nfunction validateStringRecord(\n value: unknown,\n path: readonly PropertyKey[],\n): StandardSchemaV1.Issue[] {\n if (value === undefined) return [];\n if (\n !isRecord(value) ||\n !Object.values(value).every((item) => typeof item === \"string\")\n )\n return [issue(\"Expected string details\", ...path)];\n return [];\n}\n\nfunction assertClosedAttention(value: unknown): void {\n const issues = validateAttentionContext(value);\n if (issues.length > 0)\n throw new Error(`Invalid attention serialization: ${issues[0]?.message}`);\n}\n\nfunction standardSchema<T>(\n validate: (value: unknown) => T | readonly StandardSchemaV1.Issue[],\n): StandardSchemaV1<unknown, T> {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"sigil-agent\",\n validate(value) {\n const result = validate(value);\n return Array.isArray(result)\n ? { issues: result }\n : { value: result as T };\n },\n },\n };\n}\n\nfunction issue(\n message: string,\n ...path: PropertyKey[]\n): StandardSchemaV1.Issue {\n return { message, path };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction hasOnlyKeys(\n value: Record<string, unknown>,\n allowed: readonly string[],\n): boolean {\n const keys = new Set(allowed);\n return Object.keys(value).every((key) => keys.has(key));\n}\n\nfunction sortRecord(\n record: Readonly<Record<string, string>>,\n): Record<string, string> {\n return Object.fromEntries(\n Object.entries(record).sort(([left], [right]) => left.localeCompare(right)),\n );\n}\n\nfunction selectionKey(\n selection: Pick<AttentionSelection, \"kind\" | \"id\">,\n): string {\n return `${selection.kind}\\u0000${selection.id}`;\n}\n\nfunction truncateText(value: string): string {\n return value.length <= MAX_REQUIRED_FIELD_LENGTH\n ? value\n : `${value.slice(0, MAX_REQUIRED_FIELD_LENGTH - 1)}…`;\n}\n\nfunction byteLength(value: string): number {\n return new TextEncoder().encode(value).byteLength;\n}\n\nfunction warnOversizedAttention(): void {\n const isDevelopment =\n (import.meta as ImportMeta & { env?: { DEV?: boolean } }).env?.DEV === true;\n if (isDevelopment)\n console.warn(\n \"Agent attention exceeded 4 KB; optional context was removed before sending.\",\n );\n}\n","import { useCallback, useEffect, useReducer, useRef } from \"react\";\n\nimport type {\n AttentionActivityAction,\n AttentionActivityEvent,\n AttentionSelection,\n} from \"./attention.js\";\n\nconst DEFAULT_HOVER_DELAY_MS = 500;\nconst DEFAULT_HISTORY_LIMIT = 40;\n\nexport interface RecordAttentionActivityOptions {\n readonly timestamp?: number;\n readonly summary?: string;\n readonly detail?: Readonly<Record<string, string>>;\n}\n\nexport interface UseAttentionTelemetryOptions {\n readonly initialSelections?: readonly AttentionSelection[];\n readonly hoverDelayMs?: number;\n readonly historyLimit?: number;\n}\n\nexport interface AttentionTelemetryState {\n readonly selections: readonly AttentionSelection[];\n readonly hover?: AttentionSelection;\n readonly history: readonly AttentionActivityEvent[];\n}\n\nexport type AttentionTelemetryAction =\n | {\n readonly type: \"select\";\n readonly target: AttentionSelection;\n readonly mode: \"replace\" | \"toggle\";\n readonly event: AttentionActivityEvent;\n readonly historyLimit?: number;\n }\n | {\n readonly type: \"record\";\n readonly event: AttentionActivityEvent;\n readonly historyLimit?: number;\n }\n | {\n readonly type: \"hover\";\n readonly target: AttentionSelection;\n readonly event: AttentionActivityEvent;\n readonly historyLimit?: number;\n }\n | { readonly type: \"end-hover\" }\n | { readonly type: \"clear-selections\" }\n | { readonly type: \"clear-history\" };\n\nexport function createAttentionTelemetryState(\n initialSelections: readonly AttentionSelection[] = [],\n): AttentionTelemetryState {\n return {\n selections: deduplicateTargets(initialSelections),\n history: [],\n };\n}\n\nexport function reduceAttentionTelemetry(\n state: AttentionTelemetryState,\n action: AttentionTelemetryAction,\n): AttentionTelemetryState {\n switch (action.type) {\n case \"select\": {\n const exists = state.selections.some((item) =>\n sameAttentionTarget(item, action.target),\n );\n const selections =\n action.mode === \"replace\"\n ? [action.target]\n : exists\n ? state.selections.filter(\n (item) => !sameAttentionTarget(item, action.target),\n )\n : [action.target, ...state.selections];\n return {\n ...state,\n selections,\n history: appendBoundedActivity(\n state.history,\n action.event,\n action.historyLimit,\n ),\n };\n }\n case \"record\":\n return {\n ...state,\n history: appendBoundedActivity(\n state.history,\n action.event,\n action.historyLimit,\n ),\n };\n case \"hover\":\n return {\n ...state,\n hover: action.target,\n history: appendBoundedActivity(\n state.history,\n action.event,\n action.historyLimit,\n ),\n };\n case \"end-hover\": {\n const { hover: _hover, ...withoutHover } = state;\n return withoutHover;\n }\n case \"clear-selections\":\n return { ...state, selections: [] };\n case \"clear-history\":\n return { ...state, history: [] };\n }\n}\n\nexport function useAttentionTelemetry({\n initialSelections = [],\n hoverDelayMs = DEFAULT_HOVER_DELAY_MS,\n historyLimit = DEFAULT_HISTORY_LIMIT,\n}: UseAttentionTelemetryOptions = {}) {\n const [state, dispatch] = useReducer(\n reduceAttentionTelemetry,\n initialSelections,\n createAttentionTelemetryState,\n );\n const hoverTimer = useRef<ReturnType<typeof setTimeout> | undefined>(\n undefined,\n );\n const hoverTarget = useRef<AttentionSelection | undefined>(undefined);\n\n useEffect(\n () => () => {\n if (hoverTimer.current) clearTimeout(hoverTimer.current);\n },\n [],\n );\n\n const recordActivity = useCallback(\n (\n action: AttentionActivityAction,\n target: AttentionSelection,\n options: RecordAttentionActivityOptions = {},\n ) => {\n dispatch({\n type: \"record\",\n event: createActivity(action, target, options),\n historyLimit,\n });\n },\n [historyLimit],\n );\n\n const select = useCallback(\n (target: AttentionSelection) => {\n dispatch({\n type: \"select\",\n target,\n mode: \"replace\",\n event: createActivity(\"select\", target),\n historyLimit,\n });\n },\n [historyLimit],\n );\n\n const toggleSelection = useCallback(\n (target: AttentionSelection) => {\n dispatch({\n type: \"select\",\n target,\n mode: \"toggle\",\n event: createActivity(\"select\", target),\n historyLimit,\n });\n },\n [historyLimit],\n );\n\n const clearSelections = useCallback(\n () => dispatch({ type: \"clear-selections\" }),\n [],\n );\n\n const beginHover = useCallback(\n (target: AttentionSelection) => {\n if (hoverTimer.current) clearTimeout(hoverTimer.current);\n hoverTarget.current = target;\n hoverTimer.current = setTimeout(() => {\n if (\n !hoverTarget.current ||\n !sameAttentionTarget(hoverTarget.current, target)\n )\n return;\n dispatch({\n type: \"hover\",\n target,\n event: createActivity(\"hover\", target),\n historyLimit,\n });\n }, hoverDelayMs);\n },\n [historyLimit, hoverDelayMs],\n );\n\n const endHover = useCallback((target?: AttentionSelection) => {\n if (\n target &&\n hoverTarget.current &&\n !sameAttentionTarget(target, hoverTarget.current)\n )\n return;\n if (hoverTimer.current) clearTimeout(hoverTimer.current);\n hoverTimer.current = undefined;\n hoverTarget.current = undefined;\n dispatch({ type: \"end-hover\" });\n }, []);\n\n const clearHistory = useCallback(\n () => dispatch({ type: \"clear-history\" }),\n [],\n );\n\n return {\n selection: state.selections[0],\n selections: state.selections,\n hover: state.hover,\n history: state.history,\n select,\n toggleSelection,\n clearSelections,\n beginHover,\n endHover,\n recordActivity,\n clearHistory,\n };\n}\n\nexport function appendBoundedActivity(\n history: readonly AttentionActivityEvent[],\n event: AttentionActivityEvent,\n limit = DEFAULT_HISTORY_LIMIT,\n): AttentionActivityEvent[] {\n const withoutDuplicateHover =\n event.action === \"hover\"\n ? history.filter(\n (item) =>\n item.action !== \"hover\" ||\n !sameAttentionTarget(item.target, event.target),\n )\n : [...history];\n const next = [...withoutDuplicateHover, event];\n const hoverIndexes = next\n .map((item, index) => (item.action === \"hover\" ? index : -1))\n .filter((index) => index >= 0);\n for (const index of hoverIndexes.slice(0, -2).reverse())\n next.splice(index, 1);\n while (next.length > Math.max(0, limit)) {\n const firstHover = next.findIndex((item) => item.action === \"hover\");\n next.splice(firstHover >= 0 ? firstHover : 0, 1);\n }\n return next;\n}\n\nexport function sameAttentionTarget(\n left: AttentionSelection,\n right: AttentionSelection,\n): boolean {\n return left.kind === right.kind && left.id === right.id;\n}\n\nfunction createActivity(\n action: AttentionActivityAction,\n target: AttentionSelection,\n {\n timestamp = Date.now(),\n summary,\n detail,\n }: RecordAttentionActivityOptions = {},\n): AttentionActivityEvent {\n return {\n action,\n target,\n timestamp,\n ...(summary === undefined ? {} : { summary }),\n ...(detail === undefined ? {} : { detail }),\n };\n}\n\nfunction deduplicateTargets(\n selections: readonly AttentionSelection[],\n): AttentionSelection[] {\n const seen = new Set<string>();\n return selections.filter((selection) => {\n const key = `${selection.kind}\\u0000${selection.id}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\n","import { useSyncExternalStore } from \"react\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nimport {\n serializeAttention,\n validateAttentionContext,\n type AttentionActivityEvent,\n type AttentionContext,\n type AttentionSelection,\n} from \"./attention.js\";\nimport type { AttentionPrivacyLevel } from \"./context-privacy.js\";\n\nconst listeners = new Set<() => void>();\nconst drafts = new Map<string, ContextDraftState>();\nlet activeDraftScope = \"default\";\n\nconst MAX_ATTACHMENTS = 6;\nconst MAX_ATTACHMENT_TEXT_LENGTH = 192;\nconst MAX_CONTEXT_DRAFT_BYTES = 8 * 1024;\n\nexport type ContextRetention = \"turn\" | \"session\";\nexport type ContextAttachmentSource =\n | \"application-selection\"\n | \"semantic-fork\"\n | \"agent-requested\";\nexport type ContextAttachmentInclusion =\n | \"user-added\"\n | \"automatic\"\n | \"agent-requested\";\n\nexport interface TurnContextAttachment {\n readonly id: string;\n readonly source: ContextAttachmentSource;\n readonly inclusion: ContextAttachmentInclusion;\n readonly resource: {\n readonly kind: string;\n readonly id: string;\n };\n readonly label: string;\n readonly summary?: string;\n readonly retention: ContextRetention;\n}\n\ninterface ContextDraftState {\n attachments: readonly TurnContextAttachment[];\n exclusions: readonly string[];\n}\n\nexport interface AttentionContextPreview {\n readonly attachmentCount: number;\n readonly attachments: readonly TurnContextAttachment[];\n readonly byteLength: number;\n readonly estimatedTokens: number;\n readonly formatted: string;\n readonly history: readonly AttentionActivityEvent[];\n readonly selectionCount: number;\n readonly selections: readonly AttentionSelection[];\n readonly serialized: string;\n readonly summary: string;\n readonly truncatedAttachmentCount: number;\n}\n\nexport interface ContextDraftPayload {\n readonly application?: string;\n readonly route?: string;\n readonly workspace?: AttentionContext[\"workspace\"];\n readonly selection?: AttentionContext[\"selection\"];\n readonly selections?: AttentionContext[\"selections\"];\n readonly hover?: AttentionContext[\"hover\"];\n readonly history?: AttentionContext[\"history\"];\n readonly attachments?: readonly TurnContextAttachment[];\n}\n\nexport const ContextAttachmentSchema = standardSchema<TurnContextAttachment>(\n (value) => {\n const issues = validateAttachment(value);\n return issues.length > 0 ? issues : (value as TurnContextAttachment);\n },\n);\n\nexport const ContextDraftPayloadSchema = standardSchema<ContextDraftPayload>(\n (value) => {\n const issues = validateDraftPayload(value);\n return issues.length > 0 ? issues : (value as ContextDraftPayload);\n },\n);\n\nexport function attentionSelectionKey(selection: AttentionSelection): string {\n return `selection:${selection.kind}:${selection.id}`;\n}\n\nexport function attentionHistoryKey(event: AttentionActivityEvent): string {\n return `history:${event.timestamp}:${event.action}:${event.target.kind}:${event.target.id}`;\n}\n\nexport function getContextDraftScope(): string {\n return activeDraftScope;\n}\n\nexport function getAttentionExclusions(): readonly string[] {\n return getDraftState().exclusions;\n}\n\nexport function getTurnContextAttachments(): readonly TurnContextAttachment[] {\n return getDraftState().attachments;\n}\n\nexport function setContextDraftScope(scopeId: string): void {\n const normalized = scopeId.trim();\n if (!normalized) throw new Error(\"Context draft scope must be non-empty\");\n if (activeDraftScope === normalized) return;\n activeDraftScope = normalized;\n getDraftState();\n emitChange();\n}\n\nexport function addContextAttachment(attachment: TurnContextAttachment): void {\n const validated = validateAttachment(attachment);\n if (validated.length > 0)\n throw new Error(`Invalid context attachment: ${validated[0]?.message}`);\n const normalized = normalizeAttachment(attachment, \"expanded\");\n const state = getDraftState();\n state.attachments = [\n ...state.attachments.filter((item) => item.id !== normalized.id),\n normalized,\n ].slice(-MAX_ATTACHMENTS);\n emitChange();\n}\n\nexport function addTurnContextAttachment(\n selection: AttentionSelection,\n retention: ContextRetention = \"turn\",\n): void {\n addContextAttachment({\n id: attentionSelectionKey(selection),\n source: \"application-selection\",\n inclusion: \"user-added\",\n resource: { kind: selection.kind, id: selection.id },\n label: truncateAttachmentText(selection.label ?? selection.id),\n ...(selection.detail\n ? {\n summary: truncateAttachmentText(\n Object.entries(selection.detail)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, value]) => `${key}: ${value}`)\n .join(\" · \"),\n ),\n }\n : {}),\n retention,\n });\n}\n\nexport function removeTurnContextAttachment(id: string): void {\n const state = getDraftState();\n const next = state.attachments.filter((item) => item.id !== id);\n if (next.length === state.attachments.length) return;\n state.attachments = next;\n emitChange();\n}\n\nexport function moveTurnContextAttachment(id: string, direction: -1 | 1): void {\n const state = getDraftState();\n const index = state.attachments.findIndex((item) => item.id === id);\n const target = index + direction;\n if (index < 0 || target < 0 || target >= state.attachments.length) return;\n const next = [...state.attachments];\n [next[index], next[target]] = [next[target]!, next[index]!];\n state.attachments = next;\n emitChange();\n}\n\nexport function setTurnContextAttachmentRetention(\n id: string,\n retention: ContextRetention,\n): void {\n let changed = false;\n const state = getDraftState();\n state.attachments = state.attachments.map((item) => {\n if (item.id !== id || item.retention === retention) return item;\n changed = true;\n return { ...item, retention };\n });\n if (changed) emitChange();\n}\n\nexport function clearTurnContextAttachments(): void {\n const state = getDraftState();\n const next = state.attachments.filter((item) => item.retention === \"session\");\n if (next.length === state.attachments.length) return;\n state.attachments = next;\n emitChange();\n}\n\nexport function clearContextDraft(): void {\n const state = getDraftState();\n if (state.exclusions.length === 0 && state.attachments.length === 0) return;\n state.exclusions = [];\n state.attachments = [];\n emitChange();\n}\n\nexport function resetContextDraftForTests(): void {\n drafts.clear();\n activeDraftScope = \"default\";\n emitChange();\n}\n\nexport function setAttentionItemExcluded(key: string, excluded: boolean): void {\n const state = getDraftState();\n const next = new Set(state.exclusions);\n if (excluded) next.add(key);\n else next.delete(key);\n state.exclusions = [...next].sort();\n emitChange();\n}\n\nexport function clearAttentionExclusions(): void {\n const state = getDraftState();\n if (state.exclusions.length === 0) return;\n state.exclusions = [];\n emitChange();\n}\n\nexport function useAttentionExclusions(): readonly string[] {\n return useSyncExternalStore(\n subscribeContextDraft,\n getAttentionExclusions,\n getAttentionExclusions,\n );\n}\n\nexport function useTurnContextAttachments(): readonly TurnContextAttachment[] {\n return useSyncExternalStore(\n subscribeContextDraft,\n getTurnContextAttachments,\n getTurnContextAttachments,\n );\n}\n\nexport function serializeAttentionDraft(\n context: AttentionContext | null,\n privacy: AttentionPrivacyLevel,\n excludedKeys: readonly string[] = getAttentionExclusions(),\n contextAttachments: readonly TurnContextAttachment[] = getTurnContextAttachments(),\n): string {\n const attention = context\n ? (JSON.parse(\n serializeAttention(\n applyAttentionExclusions(context, excludedKeys),\n privacy,\n ),\n ) as Record<string, unknown>)\n : {};\n const normalizedAttachments = contextAttachments\n .slice(0, MAX_ATTACHMENTS)\n .map((attachment) => normalizeAttachment(attachment, privacy));\n const serialized = fitContextPayload(attention, normalizedAttachments);\n const parsed: unknown = JSON.parse(serialized);\n const issues = validateDraftPayload(parsed);\n if (issues.length > 0)\n throw new Error(\n `Invalid context draft serialization: ${issues[0]?.message}`,\n );\n return serialized;\n}\n\nexport function createAttentionContextPreview(\n context: AttentionContext | null,\n privacy: AttentionPrivacyLevel,\n excludedKeys: readonly string[] = getAttentionExclusions(),\n contextAttachments: readonly TurnContextAttachment[] = getTurnContextAttachments(),\n): AttentionContextPreview {\n const serialized = serializeAttentionDraft(\n context,\n privacy,\n excludedKeys,\n contextAttachments,\n );\n const normalized = JSON.parse(serialized) as Partial<AttentionContext> & {\n attachments?: TurnContextAttachment[];\n };\n const selections = normalized.selections?.length\n ? normalized.selections\n : normalized.selection\n ? [normalized.selection]\n : [];\n const history = normalized.history ?? [];\n const normalizedAttachments = normalized.attachments ?? [];\n const truncatedAttachmentCount = Math.max(\n 0,\n contextAttachments.length - normalizedAttachments.length,\n );\n const byteLength = new TextEncoder().encode(serialized).byteLength;\n const parts = [\n `${selections.length} selection${selections.length === 1 ? \"\" : \"s\"}`,\n `${normalizedAttachments.length} attachment${normalizedAttachments.length === 1 ? \"\" : \"s\"}`,\n `${history.length} recent action${history.length === 1 ? \"\" : \"s\"}`,\n ];\n return {\n attachmentCount: normalizedAttachments.length,\n attachments: normalizedAttachments,\n byteLength,\n estimatedTokens: Math.ceil(byteLength / 4),\n formatted: JSON.stringify(normalized, null, 2),\n history,\n selectionCount: selections.length,\n selections,\n serialized,\n summary: parts.join(\" · \"),\n truncatedAttachmentCount,\n };\n}\n\nexport function applyAttentionExclusions(\n context: AttentionContext,\n excludedKeys: readonly string[],\n): AttentionContext {\n if (excludedKeys.length === 0) return context;\n const excluded = new Set(excludedKeys);\n const selectionCandidates = deduplicateSelections([\n ...(context.selection ? [context.selection] : []),\n ...(context.selections ?? []),\n ]);\n const selections = selectionCandidates.filter(\n (selection) => !excluded.has(attentionSelectionKey(selection)),\n );\n const excludedTargets = new Set(\n selectionCandidates\n .filter((selection) => excluded.has(attentionSelectionKey(selection)))\n .map((selection) => `${selection.kind}\\u0000${selection.id}`),\n );\n const history = (context.history ?? []).filter(\n (event) =>\n !excluded.has(attentionHistoryKey(event)) &&\n !excludedTargets.has(`${event.target.kind}\\u0000${event.target.id}`),\n );\n const hover =\n context.hover &&\n !excluded.has(attentionSelectionKey(context.hover)) &&\n !excludedTargets.has(`${context.hover.kind}\\u0000${context.hover.id}`)\n ? context.hover\n : undefined;\n return {\n ...context,\n selection: selections[0],\n selections: selections.length > 0 ? selections : undefined,\n history: history.length > 0 ? history : undefined,\n hover,\n };\n}\n\nfunction deduplicateSelections(\n selections: readonly AttentionSelection[],\n): AttentionSelection[] {\n const seen = new Set<string>();\n return selections.filter((selection) => {\n const key = `${selection.kind}\\u0000${selection.id}`;\n if (seen.has(key)) return false;\n seen.add(key);\n return true;\n });\n}\n\nfunction subscribeContextDraft(listener: () => void): () => void {\n listeners.add(listener);\n return () => listeners.delete(listener);\n}\n\nfunction emitChange(): void {\n listeners.forEach((listener) => listener());\n}\n\nfunction getDraftState(): ContextDraftState {\n let state = drafts.get(activeDraftScope);\n if (!state) {\n state = { attachments: [], exclusions: [] };\n drafts.set(activeDraftScope, state);\n }\n return state;\n}\n\nfunction normalizeAttachment(\n attachment: TurnContextAttachment,\n privacy: AttentionPrivacyLevel,\n): TurnContextAttachment {\n return {\n id: truncateAttachmentText(attachment.id),\n source: attachment.source,\n inclusion: attachment.inclusion,\n resource: {\n kind: truncateAttachmentText(attachment.resource.kind),\n id: truncateAttachmentText(attachment.resource.id),\n },\n label:\n privacy === \"minimal\"\n ? truncateAttachmentText(attachment.resource.id)\n : truncateAttachmentText(attachment.label),\n ...(privacy === \"minimal\" || attachment.summary === undefined\n ? {}\n : { summary: truncateAttachmentText(attachment.summary) }),\n retention: attachment.retention,\n };\n}\n\nfunction fitContextPayload(\n attention: Record<string, unknown>,\n contextAttachments: TurnContextAttachment[],\n): string {\n const included = contextAttachments.map((attachment) => ({ ...attachment }));\n let serialized = serializeContextPayload(attention, included);\n if (byteLength(serialized) <= MAX_CONTEXT_DRAFT_BYTES) return serialized;\n\n for (let index = included.length - 1; index >= 0; index -= 1) {\n if (included[index]?.summary === undefined) continue;\n delete included[index].summary;\n serialized = serializeContextPayload(attention, included);\n if (byteLength(serialized) <= MAX_CONTEXT_DRAFT_BYTES) return serialized;\n }\n while (included.length > 0) {\n included.pop();\n serialized = serializeContextPayload(attention, included);\n if (byteLength(serialized) <= MAX_CONTEXT_DRAFT_BYTES) return serialized;\n }\n return serialized;\n}\n\nfunction serializeContextPayload(\n attention: Record<string, unknown>,\n included: readonly TurnContextAttachment[],\n): string {\n return JSON.stringify({\n ...attention,\n ...(included.length > 0 ? { attachments: included } : {}),\n });\n}\n\nfunction validateDraftPayload(value: unknown): StandardSchemaV1.Issue[] {\n if (!isRecord(value)) return [issue(\"Expected a context draft payload\")];\n const { attachments, ...attention } = value;\n const issues: StandardSchemaV1.Issue[] = [];\n if (Object.keys(attention).length > 0)\n issues.push(...validateAttentionContext(attention));\n if (attachments !== undefined) {\n if (!Array.isArray(attachments))\n issues.push(issue(\"Expected attachments\", \"attachments\"));\n else\n attachments.forEach((attachment, index) =>\n issues.push(...validateAttachment(attachment, [\"attachments\", index])),\n );\n }\n return issues;\n}\n\nfunction validateAttachment(\n value: unknown,\n path: readonly PropertyKey[] = [],\n): StandardSchemaV1.Issue[] {\n if (!isRecord(value)) return [issue(\"Expected an attachment\", ...path)];\n const issues: StandardSchemaV1.Issue[] = [];\n if (\n !hasOnlyKeys(value, [\n \"id\",\n \"source\",\n \"inclusion\",\n \"resource\",\n \"label\",\n \"summary\",\n \"retention\",\n ])\n )\n issues.push(issue(\"Unexpected attachment field\", ...path));\n for (const key of [\"id\", \"label\"] as const)\n if (typeof value[key] !== \"string\")\n issues.push(issue(\"Expected a string\", ...path, key));\n if (value.summary !== undefined && typeof value.summary !== \"string\")\n issues.push(issue(\"Expected a string\", ...path, \"summary\"));\n if (\n value.source !== \"application-selection\" &&\n value.source !== \"semantic-fork\" &&\n value.source !== \"agent-requested\"\n )\n issues.push(issue(\"Expected a supported source\", ...path, \"source\"));\n if (\n value.inclusion !== \"user-added\" &&\n value.inclusion !== \"automatic\" &&\n value.inclusion !== \"agent-requested\"\n )\n issues.push(issue(\"Expected a supported inclusion\", ...path, \"inclusion\"));\n if (value.retention !== \"turn\" && value.retention !== \"session\")\n issues.push(\n issue(\"Expected turn or session retention\", ...path, \"retention\"),\n );\n if (!isRecord(value.resource))\n issues.push(issue(\"Expected a resource\", ...path, \"resource\"));\n else {\n if (!hasOnlyKeys(value.resource, [\"kind\", \"id\"]))\n issues.push(issue(\"Unexpected resource field\", ...path, \"resource\"));\n for (const key of [\"kind\", \"id\"] as const)\n if (typeof value.resource[key] !== \"string\")\n issues.push(issue(\"Expected a string\", ...path, \"resource\", key));\n }\n return issues;\n}\n\nfunction standardSchema<T>(\n validate: (value: unknown) => T | readonly StandardSchemaV1.Issue[],\n): StandardSchemaV1<unknown, T> {\n return {\n \"~standard\": {\n version: 1,\n vendor: \"sigil-agent\",\n validate(value) {\n const result = validate(value);\n return Array.isArray(result)\n ? { issues: result }\n : { value: result as T };\n },\n },\n };\n}\n\nfunction issue(\n message: string,\n ...path: PropertyKey[]\n): StandardSchemaV1.Issue {\n return { message, path };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction hasOnlyKeys(\n value: Record<string, unknown>,\n allowed: readonly string[],\n): boolean {\n const keys = new Set(allowed);\n return Object.keys(value).every((key) => keys.has(key));\n}\n\nfunction truncateAttachmentText(value: string): string {\n return value.length <= MAX_ATTACHMENT_TEXT_LENGTH\n ? value\n : `${value.slice(0, MAX_ATTACHMENT_TEXT_LENGTH - 1)}…`;\n}\n\nfunction byteLength(value: string): number {\n return new TextEncoder().encode(value).byteLength;\n}\n","import { useSyncExternalStore } from \"react\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nexport type AttentionPrivacyLevel = \"minimal\" | \"focused\" | \"expanded\";\n\nexport const ATTENTION_PRIVACY_STORAGE_KEY = \"sigil-agent:attention-privacy\";\n\nconst listeners = new Set<() => void>();\nlet cachedLevel: AttentionPrivacyLevel | undefined;\nlet listeningForStorage = false;\n\nexport const AttentionPrivacyLevelSchema: StandardSchemaV1<\n unknown,\n AttentionPrivacyLevel\n> = {\n \"~standard\": {\n version: 1,\n vendor: \"sigil-agent\",\n validate(value) {\n return isAttentionPrivacyLevel(value)\n ? { value }\n : { issues: [{ message: \"Expected minimal, focused, or expanded\" }] };\n },\n },\n};\n\nexport function getAttentionPrivacyLevel(): AttentionPrivacyLevel {\n if (typeof window === \"undefined\") return \"focused\";\n if (cachedLevel === undefined)\n cachedLevel = parseAttentionPrivacyLevel(\n window.localStorage.getItem(ATTENTION_PRIVACY_STORAGE_KEY),\n );\n return cachedLevel;\n}\n\nexport function setAttentionPrivacyLevel(level: AttentionPrivacyLevel): void {\n cachedLevel = level;\n if (typeof window !== \"undefined\")\n window.localStorage.setItem(ATTENTION_PRIVACY_STORAGE_KEY, level);\n emitChange();\n}\n\nexport function useAttentionPrivacyLevel(): AttentionPrivacyLevel {\n return useSyncExternalStore(\n subscribeAttentionPrivacyLevel,\n getAttentionPrivacyLevel,\n () => \"focused\",\n );\n}\n\nexport function subscribeAttentionPrivacyLevel(\n listener: () => void,\n): () => void {\n listeners.add(listener);\n if (typeof window !== \"undefined\" && !listeningForStorage) {\n window.addEventListener(\"storage\", handleStorage);\n listeningForStorage = true;\n }\n return () => {\n listeners.delete(listener);\n if (\n typeof window !== \"undefined\" &&\n listeningForStorage &&\n listeners.size === 0\n ) {\n window.removeEventListener(\"storage\", handleStorage);\n listeningForStorage = false;\n }\n };\n}\n\nexport function parseAttentionPrivacyLevel(\n value: unknown,\n): AttentionPrivacyLevel {\n return value === \"minimal\" || value === \"expanded\" ? value : \"focused\";\n}\n\nexport function resetAttentionPrivacyForTests(): void {\n cachedLevel = undefined;\n listeners.clear();\n if (typeof window !== \"undefined\" && listeningForStorage)\n window.removeEventListener(\"storage\", handleStorage);\n listeningForStorage = false;\n}\n\nfunction handleStorage(event: StorageEvent): void {\n if (event.key !== ATTENTION_PRIVACY_STORAGE_KEY) return;\n cachedLevel = parseAttentionPrivacyLevel(event.newValue);\n emitChange();\n}\n\nfunction isAttentionPrivacyLevel(\n value: unknown,\n): value is AttentionPrivacyLevel {\n return value === \"minimal\" || value === \"focused\" || value === \"expanded\";\n}\n\nfunction emitChange(): void {\n listeners.forEach((listener) => listener());\n}\n","import { createContext, useContext, type ReactNode } from \"react\";\n\nimport type { AgentRuntimeSession } from \"@zigil/agent-surface\";\n\nconst AgentRuntimeSessionContext = createContext<AgentRuntimeSession | null>(\n null,\n);\n\nexport function AgentRuntimeSessionProvider({\n children,\n session,\n}: {\n children: ReactNode;\n session: AgentRuntimeSession;\n}) {\n return (\n <AgentRuntimeSessionContext.Provider value={session}>\n {children}\n </AgentRuntimeSessionContext.Provider>\n );\n}\n\nexport function useAgentRuntimeSession(): AgentRuntimeSession {\n const session = useContext(AgentRuntimeSessionContext);\n if (!session) {\n throw new Error(\n \"useAgentRuntimeSession must be used within <AgentRuntimeSessionProvider>.\",\n );\n }\n return session;\n}\n","import {\n createContext,\n createElement,\n useContext,\n type ReactNode,\n} from \"react\";\n\nimport type { AgentThreadControls } from \"@zigil/agent-surface\";\n\nconst AgentThreadControlsContext = createContext<AgentThreadControls | null>(\n null,\n);\n\nexport function AgentThreadControlsProvider({\n children,\n value,\n}: {\n readonly children: ReactNode;\n readonly value: AgentThreadControls;\n}) {\n return createElement(\n AgentThreadControlsContext.Provider,\n { value },\n children,\n );\n}\n\nexport function useAgentThreadControls(): AgentThreadControls | null {\n return useContext(Ag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C,YAAW,0BAA0B;AACrD,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;;;AC9BA;AAAA,EACE,iBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,cAAAC;AAAA,OAEK;AAIP,IAAM,6BAA6BF;AAAA,EACjC;AACF;AAEO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AACF,GAGG;AACD,SAAOC;AAAA,IACL,2BAA2B;AAAA,IAC3B,EAAE,MAAM;AAAA,IACR;AAAA,EACF;AACF;AAEO,SAAS,yBAAqD;AACnE,SAAOC,YAAW,0BAA0B;AAC9C;","names":["standardSchema","byteLength","isRecord","issue","hasOnlyKeys","useSyncExternalStore","listeners","emitChange","createContext","useContext","createContext","createElement","useContext"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { AgentRuntimeSession } from '@zigil/agent-surface';
|
|
4
|
+
|
|
5
|
+
declare function AgentRuntimeSessionProvider({ children, session, }: {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
session: AgentRuntimeSession;
|
|
8
|
+
}): react_jsx_runtime.JSX.Element;
|
|
9
|
+
declare function useAgentRuntimeSession(): AgentRuntimeSession;
|
|
10
|
+
|
|
11
|
+
export { AgentRuntimeSessionProvider, useAgentRuntimeSession };
|
package/dist/session.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/session.tsx
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
var AgentRuntimeSessionContext = createContext(
|
|
5
|
+
null
|
|
6
|
+
);
|
|
7
|
+
function AgentRuntimeSessionProvider({
|
|
8
|
+
children,
|
|
9
|
+
session
|
|
10
|
+
}) {
|
|
11
|
+
return /* @__PURE__ */ jsx(AgentRuntimeSessionContext.Provider, { value: session, children });
|
|
12
|
+
}
|
|
13
|
+
function useAgentRuntimeSession() {
|
|
14
|
+
const session = useContext(AgentRuntimeSessionContext);
|
|
15
|
+
if (!session) {
|
|
16
|
+
throw new Error(
|
|
17
|
+
"useAgentRuntimeSession must be used within <AgentRuntimeSessionProvider>."
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
return session;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
AgentRuntimeSessionProvider,
|
|
24
|
+
useAgentRuntimeSession
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=session.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/session.tsx"],"sourcesContent":["import { createContext, useContext, type ReactNode } from \"react\";\n\nimport type { AgentRuntimeSession } from \"@zigil/agent-surface\";\n\nconst AgentRuntimeSessionContext = createContext<AgentRuntimeSession | null>(\n null,\n);\n\nexport function AgentRuntimeSessionProvider({\n children,\n session,\n}: {\n children: ReactNode;\n session: AgentRuntimeSession;\n}) {\n return (\n <AgentRuntimeSessionContext.Provider value={session}>\n {children}\n </AgentRuntimeSessionContext.Provider>\n );\n}\n\nexport function useAgentRuntimeSession(): AgentRuntimeSession {\n const session = useContext(AgentRuntimeSessionContext);\n if (!session) {\n throw new Error(\n \"useAgentRuntimeSession must be used within <AgentRuntimeSessionProvider>.\",\n );\n }\n return session;\n}\n"],"mappings":";AAAA,SAAS,eAAe,kBAAkC;AAgBtD;AAZJ,IAAM,6BAA6B;AAAA,EACjC;AACF;AAEO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AACF,GAGG;AACD,SACE,oBAAC,2BAA2B,UAA3B,EAAoC,OAAO,SACzC,UACH;AAEJ;AAEO,SAAS,yBAA8C;AAC5D,QAAM,UAAU,WAAW,0BAA0B;AACrD,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
import { AgentThreadControls } from '@zigil/agent-surface';
|
|
4
|
+
|
|
5
|
+
declare function AgentThreadControlsProvider({ children, value, }: {
|
|
6
|
+
readonly children: ReactNode;
|
|
7
|
+
readonly value: AgentThreadControls;
|
|
8
|
+
}): react.FunctionComponentElement<react.ProviderProps<AgentThreadControls | null>>;
|
|
9
|
+
declare function useAgentThreadControls(): AgentThreadControls | null;
|
|
10
|
+
|
|
11
|
+
export { AgentThreadControlsProvider, useAgentThreadControls };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// src/thread-controls.tsx
|
|
2
|
+
import {
|
|
3
|
+
createContext,
|
|
4
|
+
createElement,
|
|
5
|
+
useContext
|
|
6
|
+
} from "react";
|
|
7
|
+
var AgentThreadControlsContext = createContext(
|
|
8
|
+
null
|
|
9
|
+
);
|
|
10
|
+
function AgentThreadControlsProvider({
|
|
11
|
+
children,
|
|
12
|
+
value
|
|
13
|
+
}) {
|
|
14
|
+
return createElement(
|
|
15
|
+
AgentThreadControlsContext.Provider,
|
|
16
|
+
{ value },
|
|
17
|
+
children
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
function useAgentThreadControls() {
|
|
21
|
+
return useContext(AgentThreadControlsContext);
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
AgentThreadControlsProvider,
|
|
25
|
+
useAgentThreadControls
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=thread-controls.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/thread-controls.tsx"],"sourcesContent":["import {\n createContext,\n createElement,\n useContext,\n type ReactNode,\n} from \"react\";\n\nimport type { AgentThreadControls } from \"@zigil/agent-surface\";\n\nconst AgentThreadControlsContext = createContext<AgentThreadControls | null>(\n null,\n);\n\nexport function AgentThreadControlsProvider({\n children,\n value,\n}: {\n readonly children: ReactNode;\n readonly value: AgentThreadControls;\n}) {\n return createElement(\n AgentThreadControlsContext.Provider,\n { value },\n children,\n );\n}\n\nexport function useAgentThreadControls(): AgentThreadControls | null {\n return useContext(AgentThreadControlsContext);\n}\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAIP,IAAM,6BAA6B;AAAA,EACjC;AACF;AAEO,SAAS,4BAA4B;AAAA,EAC1C;AAAA,EACA;AACF,GAGG;AACD,SAAO;AAAA,IACL,2BAA2B;AAAA,IAC3B,EAAE,MAAM;AAAA,IACR;AAAA,EACF;AACF;AAEO,SAAS,yBAAqD;AACnE,SAAO,WAAW,0BAA0B;AAC9C;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@zigil/agent-react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "React bindings for the Sigil agent interaction contract.",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist"
|
|
9
|
+
],
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./attention": {
|
|
16
|
+
"types": "./dist/attention.d.ts",
|
|
17
|
+
"import": "./dist/attention.js"
|
|
18
|
+
},
|
|
19
|
+
"./attention-telemetry": {
|
|
20
|
+
"types": "./dist/attention-telemetry.d.ts",
|
|
21
|
+
"import": "./dist/attention-telemetry.js"
|
|
22
|
+
},
|
|
23
|
+
"./context-draft": {
|
|
24
|
+
"types": "./dist/context-draft.d.ts",
|
|
25
|
+
"import": "./dist/context-draft.js"
|
|
26
|
+
},
|
|
27
|
+
"./context-privacy": {
|
|
28
|
+
"types": "./dist/context-privacy.d.ts",
|
|
29
|
+
"import": "./dist/context-privacy.js"
|
|
30
|
+
},
|
|
31
|
+
"./session": {
|
|
32
|
+
"types": "./dist/session.d.ts",
|
|
33
|
+
"import": "./dist/session.js"
|
|
34
|
+
},
|
|
35
|
+
"./thread-controls": {
|
|
36
|
+
"types": "./dist/thread-controls.d.ts",
|
|
37
|
+
"import": "./dist/thread-controls.js"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@standard-schema/spec": "^1.1.0",
|
|
42
|
+
"@zigil/agent-surface": "0.1.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"react": "^19.0.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@types/react": "^19.0.0",
|
|
49
|
+
"react": "^19.0.0",
|
|
50
|
+
"tsup": "^8.5.1",
|
|
51
|
+
"typescript": "^5.9.3",
|
|
52
|
+
"vitest": "^3.2.4"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsup",
|
|
56
|
+
"lint": "eslint src",
|
|
57
|
+
"test": "vitest run",
|
|
58
|
+
"typecheck": "tsc --noEmit"
|
|
59
|
+
}
|
|
60
|
+
}
|