@ractive-ch/tab-mcp-client 0.16.2 → 0.17.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/CHANGELOG.md +849 -0
- package/README.md +102 -73
- package/address.d.ts +8 -8
- package/cdn/{confirm-y30cx7e1.min.js → confirm-mqmvsxg1.min.js} +2 -2
- package/cdn/{connect-bbhj2y7w.min.js → connect-c7wn48yp.min.js} +2 -2
- package/cdn/{connect-bbhj2y7w.min.js.map → connect-c7wn48yp.min.js.map} +1 -1
- package/cdn/{connection-w97tf22a.min.js → connection-0xqwz17v.min.js} +7 -7
- package/cdn/{connection-w97tf22a.min.js.map → connection-0xqwz17v.min.js.map} +5 -5
- package/cdn/{index-vt5zk9me.min.js → index-t33bb2g4.min.js} +4 -4
- package/cdn/{index-vt5zk9me.min.js.map → index-t33bb2g4.min.js.map} +4 -4
- package/cdn/tab-mcp-client.min.js +3 -3
- package/cdn/tab-mcp-client.min.js.map +3 -3
- package/{confirm-fgnjgd08.js → confirm-vj2zbq4w.js} +2 -2
- package/{connect-8jpb0k29.js → connect-9pefy0xe.js} +2 -2
- package/{connect-8jpb0k29.js.map → connect-9pefy0xe.js.map} +1 -1
- package/{connection-g91xjjgm.js → connection-gang7f5x.js} +10 -23
- package/{connection-g91xjjgm.js.map → connection-gang7f5x.js.map} +5 -5
- package/connection.d.ts +2 -2
- package/index-dmh5vm5m.js.map +1 -1
- package/{index-jnz7w9xa.js → index-qw8qy5ed.js} +11 -11
- package/{index-jnz7w9xa.js.map → index-qw8qy5ed.js.map} +2 -2
- package/index.js +21 -7
- package/index.js.map +3 -3
- package/internal.d.ts +2 -0
- package/package.json +1 -1
- package/protocol.d.ts +6 -7
- package/strings.d.ts +1 -1
- package/tab-mcp.d.ts +10 -1
- package/types.d.ts +16 -2
- package/visible.d.ts +1 -1
- /package/cdn/{confirm-y30cx7e1.min.js.map → confirm-mqmvsxg1.min.js.map} +0 -0
- /package/{confirm-fgnjgd08.js.map → confirm-vj2zbq4w.js.map} +0 -0
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"import { deepCompareStrict } from './deep-compare-strict.js';\nimport { dereference } from './dereference.js';\nimport { format } from './format.js';\nimport { encodePointer } from './pointer.js';\nimport { ucs2length } from './ucs2-length.js';\nfunction hasOwnProperty(instance, key) {\n return Object.prototype.hasOwnProperty.call(instance, key);\n}\nfunction decimalInteger(value) {\n const coefficientAndExponent = Math.abs(value).toString().split('e');\n const coefficient = coefficientAndExponent[0];\n const exponent = coefficientAndExponent[1] ?? '0';\n const point = coefficient.indexOf('.');\n const fractionLength = point === -1 ? 0 : coefficient.length - point - 1;\n return [\n BigInt(coefficient.replace('.', '')),\n Number(exponent) - fractionLength\n ];\n}\nfunction isMultipleOf(instance, divisor) {\n if (!Number.isFinite(instance) || !Number.isFinite(divisor) || divisor <= 0) {\n return false;\n }\n const [instanceCoefficient, instanceExponent] = decimalInteger(instance);\n const [divisorCoefficient, divisorExponent] = decimalInteger(divisor);\n const exponentDifference = instanceExponent - divisorExponent;\n if (exponentDifference >= 0) {\n return ((instanceCoefficient * 10n ** BigInt(exponentDifference)) %\n divisorCoefficient ===\n 0n);\n }\n return (instanceCoefficient %\n (divisorCoefficient * 10n ** BigInt(-exponentDifference)) ===\n 0n);\n}\nexport function validate(instance, schema, draft = '2019-09', lookup = dereference(schema), shortCircuit = true, recursiveAnchor = null, instanceLocation = '#', schemaLocation = '#', evaluated = Object.create(null)) {\n if (schema === true) {\n return { valid: true, errors: [] };\n }\n if (schema === false) {\n return {\n valid: false,\n errors: [\n {\n instanceLocation,\n keyword: 'false',\n keywordLocation: instanceLocation,\n error: 'False boolean schema.'\n }\n ]\n };\n }\n const rawInstanceType = typeof instance;\n let instanceType;\n switch (rawInstanceType) {\n case 'boolean':\n case 'number':\n case 'string':\n instanceType = rawInstanceType;\n break;\n case 'object':\n if (instance === null) {\n instanceType = 'null';\n }\n else if (Array.isArray(instance)) {\n instanceType = 'array';\n }\n else {\n instanceType = 'object';\n }\n break;\n default:\n throw new Error(`Instances of \"${rawInstanceType}\" type are not supported.`);\n }\n const { $ref, $recursiveRef, $recursiveAnchor, type: $type, const: $const, enum: $enum, required: $required, not: $not, anyOf: $anyOf, allOf: $allOf, oneOf: $oneOf, if: $if, then: $then, else: $else, format: $format, properties: $properties, patternProperties: $patternProperties, additionalProperties: $additionalProperties, unevaluatedProperties: $unevaluatedProperties, minProperties: $minProperties, maxProperties: $maxProperties, propertyNames: $propertyNames, dependentRequired: $dependentRequired, dependentSchemas: $dependentSchemas, dependencies: $dependencies, prefixItems: $prefixItems, items: $items, additionalItems: $additionalItems, unevaluatedItems: $unevaluatedItems, contains: $contains, minContains: $minContains, maxContains: $maxContains, minItems: $minItems, maxItems: $maxItems, uniqueItems: $uniqueItems, minimum: $minimum, maximum: $maximum, exclusiveMinimum: $exclusiveMinimum, exclusiveMaximum: $exclusiveMaximum, multipleOf: $multipleOf, minLength: $minLength, maxLength: $maxLength, pattern: $pattern, __absolute_ref__, __absolute_recursive_ref__ } = schema;\n const errors = [];\n if ($recursiveAnchor === true && recursiveAnchor === null) {\n recursiveAnchor = schema;\n }\n if ($recursiveRef === '#') {\n const refSchema = recursiveAnchor === null\n ? lookup[__absolute_recursive_ref__]\n : recursiveAnchor;\n const keywordLocation = `${schemaLocation}/$recursiveRef`;\n const result = validate(instance, recursiveAnchor === null ? schema : recursiveAnchor, draft, lookup, shortCircuit, refSchema, instanceLocation, keywordLocation, evaluated);\n if (!result.valid) {\n errors.push({\n instanceLocation,\n keyword: '$recursiveRef',\n keywordLocation,\n error: 'A subschema had errors.'\n }, ...result.errors);\n }\n }\n if ($ref !== undefined) {\n const uri = __absolute_ref__ || $ref;\n const refSchema = lookup[uri];\n if (refSchema === undefined) {\n let message = `Unresolved $ref \"${$ref}\".`;\n if (__absolute_ref__ && __absolute_ref__ !== $ref) {\n message += ` Absolute URI \"${__absolute_ref__}\".`;\n }\n message += `\\nKnown schemas:\\n- ${Object.keys(lookup).join('\\n- ')}`;\n throw new Error(message);\n }\n const keywordLocation = `${schemaLocation}/$ref`;\n const result = validate(instance, refSchema, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation, evaluated);\n if (!result.valid) {\n errors.push({\n instanceLocation,\n keyword: '$ref',\n keywordLocation,\n error: 'A subschema had errors.'\n }, ...result.errors);\n }\n if (draft === '4' || draft === '7') {\n return { valid: errors.length === 0, errors };\n }\n }\n if (Array.isArray($type)) {\n let length = $type.length;\n let valid = false;\n for (let i = 0; i < length; i++) {\n if (instanceType === $type[i] ||\n ($type[i] === 'integer' &&\n instanceType === 'number' &&\n instance % 1 === 0 &&\n instance === instance)) {\n valid = true;\n break;\n }\n }\n if (!valid) {\n errors.push({\n instanceLocation,\n keyword: 'type',\n keywordLocation: `${schemaLocation}/type`,\n error: `Instance type \"${instanceType}\" is invalid. Expected \"${$type.join('\", \"')}\".`\n });\n }\n }\n else if ($type === 'integer') {\n if (instanceType !== 'number' || instance % 1 || instance !== instance) {\n errors.push({\n instanceLocation,\n keyword: 'type',\n keywordLocation: `${schemaLocation}/type`,\n error: `Instance type \"${instanceType}\" is invalid. Expected \"${$type}\".`\n });\n }\n }\n else if ($type !== undefined && instanceType !== $type) {\n errors.push({\n instanceLocation,\n keyword: 'type',\n keywordLocation: `${schemaLocation}/type`,\n error: `Instance type \"${instanceType}\" is invalid. Expected \"${$type}\".`\n });\n }\n if ($const !== undefined) {\n if (instanceType === 'object' || instanceType === 'array') {\n if (!deepCompareStrict(instance, $const)) {\n errors.push({\n instanceLocation,\n keyword: 'const',\n keywordLocation: `${schemaLocation}/const`,\n error: `Instance does not match ${JSON.stringify($const)}.`\n });\n }\n }\n else if (instance !== $const) {\n errors.push({\n instanceLocation,\n keyword: 'const',\n keywordLocation: `${schemaLocation}/const`,\n error: `Instance does not match ${JSON.stringify($const)}.`\n });\n }\n }\n if ($enum !== undefined) {\n if (instanceType === 'object' || instanceType === 'array') {\n if (!$enum.some(value => deepCompareStrict(instance, value))) {\n errors.push({\n instanceLocation,\n keyword: 'enum',\n keywordLocation: `${schemaLocation}/enum`,\n error: `Instance does not match any of ${JSON.stringify($enum)}.`\n });\n }\n }\n else if (!$enum.some(value => instance === value)) {\n errors.push({\n instanceLocation,\n keyword: 'enum',\n keywordLocation: `${schemaLocation}/enum`,\n error: `Instance does not match any of ${JSON.stringify($enum)}.`\n });\n }\n }\n if ($not !== undefined) {\n const keywordLocation = `${schemaLocation}/not`;\n const result = validate(instance, $not, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation);\n if (result.valid) {\n errors.push({\n instanceLocation,\n keyword: 'not',\n keywordLocation,\n error: 'Instance matched \"not\" schema.'\n });\n }\n }\n let subEvaluateds = [];\n if ($anyOf !== undefined) {\n const keywordLocation = `${schemaLocation}/anyOf`;\n const errorsLength = errors.length;\n let anyValid = false;\n for (const [i, subSchema] of $anyOf.entries()) {\n const subEvaluated = Object.create(evaluated);\n const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);\n errors.push(...result.errors);\n anyValid = anyValid || result.valid;\n if (result.valid) {\n subEvaluateds.push(subEvaluated);\n }\n }\n if (anyValid) {\n errors.length = errorsLength;\n }\n else {\n errors.splice(errorsLength, 0, {\n instanceLocation,\n keyword: 'anyOf',\n keywordLocation,\n error: 'Instance does not match any subschemas.'\n });\n }\n }\n if ($allOf !== undefined) {\n const keywordLocation = `${schemaLocation}/allOf`;\n const errorsLength = errors.length;\n let allValid = true;\n for (const [i, subSchema] of $allOf.entries()) {\n const subEvaluated = Object.create(evaluated);\n const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);\n errors.push(...result.errors);\n allValid = allValid && result.valid;\n if (result.valid) {\n subEvaluateds.push(subEvaluated);\n }\n }\n if (allValid) {\n errors.length = errorsLength;\n }\n else {\n errors.splice(errorsLength, 0, {\n instanceLocation,\n keyword: 'allOf',\n keywordLocation,\n error: `Instance does not match every subschema.`\n });\n }\n }\n if ($oneOf !== undefined) {\n const keywordLocation = `${schemaLocation}/oneOf`;\n const errorsLength = errors.length;\n const matches = $oneOf.filter((subSchema, i) => {\n const subEvaluated = Object.create(evaluated);\n const result = validate(instance, subSchema, draft, lookup, shortCircuit, $recursiveAnchor === true ? recursiveAnchor : null, instanceLocation, `${keywordLocation}/${i}`, subEvaluated);\n errors.push(...result.errors);\n if (result.valid) {\n subEvaluateds.push(subEvaluated);\n }\n return result.valid;\n }).length;\n if (matches === 1) {\n errors.length = errorsLength;\n }\n else {\n errors.splice(errorsLength, 0, {\n instanceLocation,\n keyword: 'oneOf',\n keywordLocation,\n error: `Instance does not match exactly one subschema (${matches} matches).`\n });\n }\n }\n if (instanceType === 'object' || instanceType === 'array') {\n Object.assign(evaluated, ...subEvaluateds);\n }\n if ($if !== undefined) {\n const keywordLocation = `${schemaLocation}/if`;\n const ifEvaluated = Object.create(null);\n const conditionResult = validate(instance, $if, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, keywordLocation, ifEvaluated).valid;\n if (conditionResult) {\n Object.assign(evaluated, ifEvaluated);\n if ($then !== undefined) {\n const thenResult = validate(instance, $then, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${schemaLocation}/then`, evaluated);\n if (!thenResult.valid) {\n errors.push({\n instanceLocation,\n keyword: 'if',\n keywordLocation,\n error: `Instance does not match \"then\" schema.`\n }, ...thenResult.errors);\n }\n }\n }\n else if ($else !== undefined) {\n const elseResult = validate(instance, $else, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${schemaLocation}/else`, evaluated);\n if (!elseResult.valid) {\n errors.push({\n instanceLocation,\n keyword: 'if',\n keywordLocation,\n error: `Instance does not match \"else\" schema.`\n }, ...elseResult.errors);\n }\n }\n }\n if (instanceType === 'object') {\n if ($required !== undefined) {\n for (const key of $required) {\n if (!hasOwnProperty(instance, key)) {\n errors.push({\n instanceLocation,\n keyword: 'required',\n keywordLocation: `${schemaLocation}/required`,\n error: `Instance does not have required property \"${key}\".`\n });\n }\n }\n }\n const keys = Object.keys(instance);\n if ($minProperties !== undefined && keys.length < $minProperties) {\n errors.push({\n instanceLocation,\n keyword: 'minProperties',\n keywordLocation: `${schemaLocation}/minProperties`,\n error: `Instance does not have at least ${$minProperties} properties.`\n });\n }\n if ($maxProperties !== undefined && keys.length > $maxProperties) {\n errors.push({\n instanceLocation,\n keyword: 'maxProperties',\n keywordLocation: `${schemaLocation}/maxProperties`,\n error: `Instance does not have at least ${$maxProperties} properties.`\n });\n }\n if ($propertyNames !== undefined) {\n const keywordLocation = `${schemaLocation}/propertyNames`;\n for (const key in instance) {\n const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;\n const result = validate(key, $propertyNames, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);\n if (!result.valid) {\n errors.push({\n instanceLocation,\n keyword: 'propertyNames',\n keywordLocation,\n error: `Property name \"${key}\" does not match schema.`\n }, ...result.errors);\n }\n }\n }\n if ($dependentRequired !== undefined) {\n const keywordLocation = `${schemaLocation}/dependantRequired`;\n for (const key in $dependentRequired) {\n if (hasOwnProperty(instance, key)) {\n const required = $dependentRequired[key];\n for (const dependantKey of required) {\n if (!hasOwnProperty(instance, dependantKey)) {\n errors.push({\n instanceLocation,\n keyword: 'dependentRequired',\n keywordLocation,\n error: `Instance has \"${key}\" but does not have \"${dependantKey}\".`\n });\n }\n }\n }\n }\n }\n if ($dependentSchemas !== undefined) {\n for (const [key, dependentSchema] of Object.entries($dependentSchemas)) {\n const keywordLocation = `${schemaLocation}/dependentSchemas`;\n if (hasOwnProperty(instance, key)) {\n const result = validate(instance, dependentSchema, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${keywordLocation}/${encodePointer(key)}`, evaluated);\n if (!result.valid) {\n errors.push({\n instanceLocation,\n keyword: 'dependentSchemas',\n keywordLocation,\n error: `Instance has \"${key}\" but does not match dependant schema.`\n }, ...result.errors);\n }\n }\n }\n }\n if ($dependencies !== undefined) {\n const keywordLocation = `${schemaLocation}/dependencies`;\n for (const key in $dependencies) {\n if (hasOwnProperty(instance, key)) {\n const propsOrSchema = $dependencies[key];\n if (Array.isArray(propsOrSchema)) {\n for (const dependantKey of propsOrSchema) {\n if (!hasOwnProperty(instance, dependantKey)) {\n errors.push({\n instanceLocation,\n keyword: 'dependencies',\n keywordLocation,\n error: `Instance has \"${key}\" but does not have \"${dependantKey}\".`\n });\n }\n }\n }\n else {\n const result = validate(instance, propsOrSchema, draft, lookup, shortCircuit, recursiveAnchor, instanceLocation, `${keywordLocation}/${encodePointer(key)}`);\n if (!result.valid) {\n errors.push({\n instanceLocation,\n keyword: 'dependencies',\n keywordLocation,\n error: `Instance has \"${key}\" but does not match dependant schema.`\n }, ...result.errors);\n }\n }\n }\n }\n }\n const thisEvaluated = Object.create(null);\n let stop = false;\n if ($properties !== undefined) {\n const keywordLocation = `${schemaLocation}/properties`;\n for (const [key, propertySchema] of Object.entries($properties)) {\n if (!hasOwnProperty(instance, key)) {\n continue;\n }\n const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;\n const result = validate(instance[key], propertySchema, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, `${keywordLocation}/${encodePointer(key)}`);\n thisEvaluated[key] = true;\n if (result.valid) {\n evaluated[key] = true;\n }\n else {\n stop = shortCircuit;\n errors.push({\n instanceLocation,\n keyword: 'properties',\n keywordLocation,\n error: `Property \"${key}\" does not match schema.`\n }, ...result.errors);\n if (stop)\n break;\n }\n }\n }\n if (!stop && $patternProperties !== undefined) {\n const keywordLocation = `${schemaLocation}/patternProperties`;\n for (const [pattern, subSchema] of Object.entries($patternProperties)) {\n const regex = new RegExp(pattern, 'u');\n for (const key in instance) {\n if (!regex.test(key)) {\n continue;\n }\n const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;\n const result = validate(instance[key], subSchema, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, `${keywordLocation}/${encodePointer(pattern)}`);\n thisEvaluated[key] = true;\n if (result.valid) {\n evaluated[key] = true;\n }\n else {\n stop = shortCircuit;\n errors.push({\n instanceLocation,\n keyword: 'patternProperties',\n keywordLocation,\n error: `Property \"${key}\" matches pattern \"${pattern}\" but does not match associated schema.`\n }, ...result.errors);\n }\n }\n }\n }\n if (!stop && $additionalProperties !== undefined) {\n const keywordLocation = `${schemaLocation}/additionalProperties`;\n for (const key in instance) {\n if (thisEvaluated[key]) {\n continue;\n }\n const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;\n const result = validate(instance[key], $additionalProperties, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);\n if (result.valid) {\n evaluated[key] = true;\n }\n else {\n stop = shortCircuit;\n errors.push({\n instanceLocation,\n keyword: 'additionalProperties',\n keywordLocation,\n error: `Property \"${key}\" does not match additional properties schema.`\n }, ...result.errors);\n }\n }\n }\n else if (!stop && $unevaluatedProperties !== undefined) {\n const keywordLocation = `${schemaLocation}/unevaluatedProperties`;\n for (const key in instance) {\n if (!evaluated[key]) {\n const subInstancePointer = `${instanceLocation}/${encodePointer(key)}`;\n const result = validate(instance[key], $unevaluatedProperties, draft, lookup, shortCircuit, recursiveAnchor, subInstancePointer, keywordLocation);\n if (result.valid) {\n evaluated[key] = true;\n }\n else {\n errors.push({\n instanceLocation,\n keyword: 'unevaluatedProperties',\n keywordLocation,\n error: `Property \"${key}\" does not match unevaluated properties schema.`\n }, ...result.errors);\n }\n }\n }\n }\n }\n else if (instanceType === 'array') {\n if ($maxItems !== undefined && instance.length > $maxItems) {\n errors.push({\n instanceLocation,\n keyword: 'maxItems',\n keywordLocation: `${schemaLocation}/maxItems`,\n error: `Array has too many items (${instance.length} > ${$maxItems}).`\n });\n }\n if ($minItems !== undefined && instance.length < $minItems) {\n errors.push({\n instanceLocation,\n keyword: 'minItems',\n keywordLocation: `${schemaLocation}/minItems`,\n error: `Array has too few items (${instance.length} < ${$minItems}).`\n });\n }\n const length = instance.length;\n let i = 0;\n let stop = false;\n if ($prefixItems !== undefined) {\n const keywordLocation = `${schemaLocation}/prefixItems`;\n const length2 = Math.min($prefixItems.length, length);\n for (; i < length2; i++) {\n const result = validate(instance[i], $prefixItems[i], draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, `${keywordLocation}/${i}`);\n evaluated[i] = true;\n if (!result.valid) {\n stop = shortCircuit;\n errors.push({\n instanceLocation,\n keyword: 'prefixItems',\n keywordLocation,\n error: `Items did not match schema.`\n }, ...result.errors);\n if (stop)\n break;\n }\n }\n }\n if ($items !== undefined) {\n const keywordLocation = `${schemaLocation}/items`;\n if (Array.isArray($items)) {\n const length2 = Math.min($items.length, length);\n for (; i < length2; i++) {\n const result = validate(instance[i], $items[i], draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, `${keywordLocation}/${i}`);\n evaluated[i] = true;\n if (!result.valid) {\n stop = shortCircuit;\n errors.push({\n instanceLocation,\n keyword: 'items',\n keywordLocation,\n error: `Items did not match schema.`\n }, ...result.errors);\n if (stop)\n break;\n }\n }\n }\n else {\n for (; i < length; i++) {\n const result = validate(instance[i], $items, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);\n evaluated[i] = true;\n if (!result.valid) {\n stop = shortCircuit;\n errors.push({\n instanceLocation,\n keyword: 'items',\n keywordLocation,\n error: `Items did not match schema.`\n }, ...result.errors);\n if (stop)\n break;\n }\n }\n }\n if (!stop && $additionalItems !== undefined) {\n const keywordLocation = `${schemaLocation}/additionalItems`;\n for (; i < length; i++) {\n const result = validate(instance[i], $additionalItems, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);\n evaluated[i] = true;\n if (!result.valid) {\n stop = shortCircuit;\n errors.push({\n instanceLocation,\n keyword: 'additionalItems',\n keywordLocation,\n error: `Items did not match additional items schema.`\n }, ...result.errors);\n }\n }\n }\n }\n if ($contains !== undefined) {\n if (length === 0 && $minContains === undefined) {\n errors.push({\n instanceLocation,\n keyword: 'contains',\n keywordLocation: `${schemaLocation}/contains`,\n error: `Array is empty. It must contain at least one item matching the schema.`\n });\n }\n else if ($minContains !== undefined && length < $minContains) {\n errors.push({\n instanceLocation,\n keyword: 'minContains',\n keywordLocation: `${schemaLocation}/minContains`,\n error: `Array has less items (${length}) than minContains (${$minContains}).`\n });\n }\n else {\n const keywordLocation = `${schemaLocation}/contains`;\n const errorsLength = errors.length;\n let contained = 0;\n for (let j = 0; j < length; j++) {\n const result = validate(instance[j], $contains, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${j}`, keywordLocation);\n if (result.valid) {\n evaluated[j] = true;\n contained++;\n }\n else {\n errors.push(...result.errors);\n }\n }\n if (contained >= ($minContains || 0)) {\n errors.length = errorsLength;\n }\n if ($minContains === undefined && contained === 0) {\n errors.splice(errorsLength, 0, {\n instanceLocation,\n keyword: 'contains',\n keywordLocation,\n error: `Array does not contain item matching schema.`\n });\n }\n else if ($minContains !== undefined && contained < $minContains) {\n errors.push({\n instanceLocation,\n keyword: 'minContains',\n keywordLocation: `${schemaLocation}/minContains`,\n error: `Array must contain at least ${$minContains} items matching schema. Only ${contained} items were found.`\n });\n }\n else if ($maxContains !== undefined && contained > $maxContains) {\n errors.push({\n instanceLocation,\n keyword: 'maxContains',\n keywordLocation: `${schemaLocation}/maxContains`,\n error: `Array may contain at most ${$maxContains} items matching schema. ${contained} items were found.`\n });\n }\n }\n }\n if (!stop && $unevaluatedItems !== undefined) {\n const keywordLocation = `${schemaLocation}/unevaluatedItems`;\n for (i; i < length; i++) {\n if (evaluated[i]) {\n continue;\n }\n const result = validate(instance[i], $unevaluatedItems, draft, lookup, shortCircuit, recursiveAnchor, `${instanceLocation}/${i}`, keywordLocation);\n evaluated[i] = true;\n if (!result.valid) {\n errors.push({\n instanceLocation,\n keyword: 'unevaluatedItems',\n keywordLocation,\n error: `Items did not match unevaluated items schema.`\n }, ...result.errors);\n }\n }\n }\n if ($uniqueItems) {\n for (let j = 0; j < length; j++) {\n const a = instance[j];\n const ao = typeof a === 'object' && a !== null;\n for (let k = 0; k < length; k++) {\n if (j === k) {\n continue;\n }\n const b = instance[k];\n const bo = typeof b === 'object' && b !== null;\n if (a === b || (ao && bo && deepCompareStrict(a, b))) {\n errors.push({\n instanceLocation,\n keyword: 'uniqueItems',\n keywordLocation: `${schemaLocation}/uniqueItems`,\n error: `Duplicate items at indexes ${j} and ${k}.`\n });\n j = Number.MAX_SAFE_INTEGER;\n k = Number.MAX_SAFE_INTEGER;\n }\n }\n }\n }\n }\n else if (instanceType === 'number') {\n if (draft === '4') {\n if ($minimum !== undefined &&\n (($exclusiveMinimum === true && instance <= $minimum) ||\n instance < $minimum)) {\n errors.push({\n instanceLocation,\n keyword: 'minimum',\n keywordLocation: `${schemaLocation}/minimum`,\n error: `${instance} is less than ${$exclusiveMinimum ? 'or equal to ' : ''} ${$minimum}.`\n });\n }\n if ($maximum !== undefined &&\n (($exclusiveMaximum === true && instance >= $maximum) ||\n instance > $maximum)) {\n errors.push({\n instanceLocation,\n keyword: 'maximum',\n keywordLocation: `${schemaLocation}/maximum`,\n error: `${instance} is greater than ${$exclusiveMaximum ? 'or equal to ' : ''} ${$maximum}.`\n });\n }\n }\n else {\n if ($minimum !== undefined && instance < $minimum) {\n errors.push({\n instanceLocation,\n keyword: 'minimum',\n keywordLocation: `${schemaLocation}/minimum`,\n error: `${instance} is less than ${$minimum}.`\n });\n }\n if ($maximum !== undefined && instance > $maximum) {\n errors.push({\n instanceLocation,\n keyword: 'maximum',\n keywordLocation: `${schemaLocation}/maximum`,\n error: `${instance} is greater than ${$maximum}.`\n });\n }\n if ($exclusiveMinimum !== undefined && instance <= $exclusiveMinimum) {\n errors.push({\n instanceLocation,\n keyword: 'exclusiveMinimum',\n keywordLocation: `${schemaLocation}/exclusiveMinimum`,\n error: `${instance} is less than ${$exclusiveMinimum}.`\n });\n }\n if ($exclusiveMaximum !== undefined && instance >= $exclusiveMaximum) {\n errors.push({\n instanceLocation,\n keyword: 'exclusiveMaximum',\n keywordLocation: `${schemaLocation}/exclusiveMaximum`,\n error: `${instance} is greater than or equal to ${$exclusiveMaximum}.`\n });\n }\n }\n if ($multipleOf !== undefined) {\n if (!isMultipleOf(instance, $multipleOf)) {\n errors.push({\n instanceLocation,\n keyword: 'multipleOf',\n keywordLocation: `${schemaLocation}/multipleOf`,\n error: `${instance} is not a multiple of ${$multipleOf}.`\n });\n }\n }\n }\n else if (instanceType === 'string') {\n const length = $minLength === undefined && $maxLength === undefined\n ? 0\n : ucs2length(instance);\n if ($minLength !== undefined && length < $minLength) {\n errors.push({\n instanceLocation,\n keyword: 'minLength',\n keywordLocation: `${schemaLocation}/minLength`,\n error: `String is too short (${length} < ${$minLength}).`\n });\n }\n if ($maxLength !== undefined && length > $maxLength) {\n errors.push({\n instanceLocation,\n keyword: 'maxLength',\n keywordLocation: `${schemaLocation}/maxLength`,\n error: `String is too long (${length} > ${$maxLength}).`\n });\n }\n if ($pattern !== undefined && !new RegExp($pattern, 'u').test(instance)) {\n errors.push({\n instanceLocation,\n keyword: 'pattern',\n keywordLocation: `${schemaLocation}/pattern`,\n error: `String does not match pattern.`\n });\n }\n if ($format !== undefined &&\n format[$format] &&\n !format[$format](instance)) {\n errors.push({\n instanceLocation,\n keyword: 'format',\n keywordLocation: `${schemaLocation}/format`,\n error: `String does not match format \"${$format}\".`\n });\n }\n }\n return { valid: errors.length === 0, errors };\n}\n//# sourceMappingURL=validate.js.map",
|
|
12
12
|
"/**\n * WebMCP → MCP mapping of annotations (DEC-022) and results (DEC-023).\n */\n\nimport type { ToolAnnotations } from \"./types.ts\";\n\n/** `_meta` key that keeps the original WebMCP hints. */\nexport const ANNOTATIONS_META_KEY = \"ch.ractive.tab-mcp/annotations\";\n\nconst WEBMCP_HINTS = [\n\t\"readOnlyHint\",\n\t\"untrustedContentHint\",\n\t\"consequentialHint\",\n\t\"debugging\",\n] as const;\nconst MCP_ONLY_HINTS = [\n\t\"destructiveHint\",\n\t\"idempotentHint\",\n\t\"openWorldHint\",\n] as const;\n\nexport interface McpToolAnnotations {\n\tannotations?: Record<string, boolean>;\n\tmeta?: Record<string, boolean>;\n}\n\n/** MCP annotations plus the WebMCP originals for `_meta`. */\nexport function mapAnnotations(hints: ToolAnnotations): McpToolAnnotations {\n\tconst annotations: Record<string, boolean> = {};\n\tif (hints.readOnlyHint === true) {\n\t\tannotations[\"readOnlyHint\"] = true;\n\t\tannotations[\"destructiveHint\"] = false;\n\t} else if (hints.readOnlyHint === false) {\n\t\tannotations[\"readOnlyHint\"] = false;\n\t}\n\tif (hints.consequentialHint === true) annotations[\"destructiveHint\"] = true;\n\tif (hints.untrustedContentHint === true) annotations[\"openWorldHint\"] = true;\n\tfor (const key of MCP_ONLY_HINTS) {\n\t\tconst value = hints[key];\n\t\tif (value !== undefined) annotations[key] = value; // MCP hints win\n\t}\n\tconst meta: Record<string, boolean> = {};\n\tfor (const key of WEBMCP_HINTS) {\n\t\tconst value = hints[key];\n\t\tif (value !== undefined) meta[key] = value;\n\t}\n\tconst out: McpToolAnnotations = {};\n\tif (Object.keys(annotations).length > 0) out.annotations = annotations;\n\tif (Object.keys(meta).length > 0) out.meta = meta;\n\treturn out;\n}\n\nexport interface CallToolResult {\n\tcontent: unknown[];\n\tstructuredContent?: Record<string, unknown>;\n\tisError?: boolean;\n\t_meta?: Record<string, unknown>;\n\t[key: string]: unknown;\n}\n\n/**\n * `result` with `_meta[\"ch.ractive.tab-mcp/annotations\"].untrustedContentHint`\n * set, for every result of a tool marked `untrustedContentHint` (DEC-166):\n * MCP has no such hint, and `openWorldHint` in `tools/list` says something\n * else. The tool's own `_meta` is kept; `result` is not changed.\n */\nexport function markUntrusted(result: CallToolResult): CallToolResult {\n\tconst meta = result._meta ?? {};\n\tconst own = meta[ANNOTATIONS_META_KEY];\n\treturn {\n\t\t...result,\n\t\t_meta: {\n\t\t\t...meta,\n\t\t\t[ANNOTATIONS_META_KEY]: {\n\t\t\t\t...(isObject(own) ? own : {}),\n\t\t\t\tuntrustedContentHint: true,\n\t\t\t},\n\t\t},\n\t};\n}\n\nexport function errorResult(message: string): CallToolResult {\n\treturn { content: [{ type: \"text\", text: message }], isError: true };\n}\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n\treturn typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\nconst isString = (v: unknown): v is string => typeof v === \"string\";\n\n/**\n * Whether `block` is an MCP 2026-07-28 content block with the fields its\n * type requires: `text` a string `text`; `image` and `audio` string `data`\n * and `mimeType`; `resource_link` string `uri` and `name`; `resource` a\n * `resource` object with a string `uri`.\n */\nfunction isContentBlock(block: unknown): boolean {\n\tif (!isObject(block)) return false;\n\tswitch (block[\"type\"]) {\n\t\tcase \"text\":\n\t\t\treturn isString(block[\"text\"]);\n\t\tcase \"image\":\n\t\tcase \"audio\":\n\t\t\treturn isString(block[\"data\"]) && isString(block[\"mimeType\"]);\n\t\tcase \"resource_link\":\n\t\t\treturn isString(block[\"uri\"]) && isString(block[\"name\"]);\n\t\tcase \"resource\":\n\t\t\treturn isObject(block[\"resource\"]) && isString(block[\"resource\"][\"uri\"]);\n\t\tdefault:\n\t\t\treturn false;\n\t}\n}\n\n/** The keys of a `CallToolResult` (`resultType` is set by the server). */\nconst RESULT_KEYS = new Set([\n\t\"content\",\n\t\"structuredContent\",\n\t\"isError\",\n\t\"_meta\",\n\t\"resultType\",\n]);\n\n/**\n * Whether `value` is an MCP `CallToolResult`: an object whose `content` is an\n * array of MCP content blocks (`isContentBlock`), with `isError` a boolean\n * and `structuredContent` and `_meta` objects where present. Domain data\n * that happens to have a `content` array (a ProseMirror document,\n * `{ title, content: [\"…\"] }`, a chat message with its own blocks) is not\n * one (CC 3). Other keys are allowed next to blocks, as MCP allows them on a\n * result; with an empty `content` they are not, so that `{ title, content:\n * [] }` is data, not an empty result.\n */\nexport function isCallToolResult(value: unknown): value is CallToolResult {\n\tif (!isObject(value) || !Array.isArray(value[\"content\"])) return false;\n\tconst { content, isError, structuredContent, _meta } = value;\n\treturn (\n\t\t(content.length > 0\n\t\t\t? content.every(isContentBlock)\n\t\t\t: Object.keys(value).every((key) => RESULT_KEYS.has(key))) &&\n\t\t(isError === undefined || typeof isError === \"boolean\") &&\n\t\t(structuredContent === undefined || isObject(structuredContent)) &&\n\t\t(_meta === undefined || isObject(_meta))\n\t);\n}\n\n/**\n * What `execute` returned → a `CallToolResult`: a string is one text block; a\n * `CallToolResult` (`isCallToolResult`) passes through; `undefined` is an\n * empty result; any other JSON value is a text block with its JSON, plus\n * that JSON as `structuredContent` when it is an object (so a `Date` or a\n * `URL`, whose JSON is a string, has none).\n */\nexport function toCallToolResult(value: unknown): CallToolResult {\n\tif (typeof value === \"string\")\n\t\treturn { content: [{ type: \"text\", text: value }] };\n\tif (value === undefined) return { content: [] };\n\tif (isCallToolResult(value)) return value;\n\tlet text: string | undefined;\n\ttry {\n\t\ttext = JSON.stringify(value);\n\t} catch {\n\t\t// cyclic or BigInt\n\t}\n\tif (text === undefined)\n\t\treturn errorResult(\"The tool returned a value that is not JSON.\");\n\tconst result: CallToolResult = { content: [{ type: \"text\", text }] };\n\t// What the text says, not the value: `toJSON` applied, no class instances.\n\tconst parsed: unknown = JSON.parse(text);\n\tif (isObject(parsed)) result.structuredContent = parsed;\n\treturn result;\n}\n\n/**\n * The text blocks of a result, one per line. With `noted`, each other block\n * (an image, a resource) is a line that says it was left out, naming its type.\n */\nexport function resultText(result: CallToolResult, noted = false): string {\n\treturn result.content\n\t\t.map((block) =>\n\t\t\tisObject(block) &&\n\t\t\tblock[\"type\"] === \"text\" &&\n\t\t\ttypeof block[\"text\"] === \"string\"\n\t\t\t\t? block[\"text\"]\n\t\t\t\t: noted\n\t\t\t\t\t? `[${isObject(block) ? String(block[\"type\"]) : \"A\"} content left out: WebMCP results are text.]`\n\t\t\t\t\t: \"\",\n\t\t)\n\t\t.filter((text) => text !== \"\")\n\t\t.join(\"\\n\");\n}\n\n/**\n * What a WebMCP caller gets for what `execute` returned (WM 4, WM 6): an MCP\n * result as its `structuredContent` if it has one, else as its text\n * (`resultText`, other blocks noted); `undefined` (which a browser cannot\n * serialize as JSON, so the call would fail) and an empty MCP result as\n * \"Done.\"; any other value as it is.\n */\nexport function webMcpValue(value: unknown): unknown {\n\tif (isCallToolResult(value))\n\t\treturn value.structuredContent ?? (resultText(value, true) || \"Done.\");\n\treturn value === undefined ? \"Done.\" : value;\n}\n\n/** A thrown value → an `isError` result with its message. */\nexport function thrownResult(error: unknown): CallToolResult {\n\tconst message = error instanceof Error ? error.message : String(error);\n\treturn errorResult(message || \"The tool failed.\");\n}\n",
|
|
13
13
|
"/**\n * The tab's MCP server: the stateless 2026-07-28 subset tab-mcp needs\n * (DEC-049), written for the page instead of bundling the SDK. It answers\n * `server/discover`, `tools/list`, `tools/call` (as SSE, DEC-020) and\n * `subscriptions/listen`, and applies the request checks of the 2026-07-28\n * Streamable HTTP transport (content type, JSON-RPC shape, `_meta` envelope,\n * `MCP-Protocol-Version` / `Mcp-Method` / `Mcp-Name`). Status codes and error\n * codes follow the MCP TypeScript SDK's `createMcpHandler`; the conformance\n * tests compare the two.\n */\n\nimport {\n\tdereference,\n\ttype OutputUnit,\n\ttype Schema,\n\tvalidate as validateSchema,\n} from \"@cfworker/json-schema\";\nimport { cleanIcons } from \"./icons.ts\";\nimport {\n\tANNOTATIONS_META_KEY,\n\ttype CallToolResult,\n\terrorResult,\n\tmapAnnotations,\n\tmarkUntrusted,\n\tresultText,\n\tthrownResult,\n\ttoCallToolResult,\n\twebMcpValue,\n} from \"./mapping.ts\";\nimport type { GrantRef } from \"./protocol.ts\";\nimport type { RegisteredTool, ToolRegistry } from \"./registry.ts\";\nimport type {\n\tConfirmAnswer,\n\tConfirmRequest,\n\tServerInfo,\n\tToolCallClient,\n\tToolCallEnd,\n\tToolCallOutcome,\n\tToolCallStart,\n} from \"./types.ts\";\n\nexport const MCP_PROTOCOL_VERSION = \"2026-07-28\";\nconst META_VERSION = \"io.modelcontextprotocol/protocolVersion\";\nconst META_CAPABILITIES = \"io.modelcontextprotocol/clientCapabilities\";\nconst META_CLIENT_INFO = \"io.modelcontextprotocol/clientInfo\";\nconst META_SERVER_INFO = \"io.modelcontextprotocol/serverInfo\";\nconst META_SUBSCRIPTION = \"io.modelcontextprotocol/subscriptionId\";\n\nconst HEADER_MISMATCH = -32020;\nconst UNSUPPORTED_VERSION = -32022;\n\n/** After the description of a consequential tool in `tools/list`. */\nexport const CONFIRMED_IN_TAB =\n\t\"The page may ask the user to allow each call, usually in the page's browser tab.\";\n\ntype Id = string | number;\ntype Json = Record<string, unknown>;\n\nexport interface ToolSource {\n\tlist(): RegisteredTool[];\n\tget(name: string): RegisteredTool | undefined;\n}\n\n/** What a tool call needs, through the relay or through WebMCP. */\nexport interface CallContext {\n\ttools: ToolSource;\n\t/** Ask the user before a consequential tool runs. */\n\tconfirm(request: ConfirmRequest): Promise<ConfirmAnswer>;\n\t/**\n\t * `confirm` is an own `onConfirm` (the page's, or a serve's), which may\n\t * ask anywhere: `tools/list` then does not say where (DEC-169).\n\t */\n\townConfirm?: boolean;\n\t/** Told about every call of a known tool, as it starts and as it ends. */\n\tobserve?: {\n\t\tstart(call: ToolCallStart): void;\n\t\tend(call: ToolCallEnd): void;\n\t};\n}\n\nexport interface McpHandlerOptions extends CallContext {\n\tserver: ServerInfo;\n\t/** The caller of a request, from its grant. */\n\tclient(grant: GrantRef): ToolCallClient;\n\t/**\n\t * The largest response body the relay passes on (`limits.maxBodyBytes`);\n\t * `undefined`: no limit. A larger tool result is answered as an error\n\t * result instead (CC 7).\n\t */\n\tmaxBodyBytes?: () => number | undefined;\n}\n\n/** Tool call ids, unique in the page. */\nlet lastCallId = 0;\n\n/** Checks arguments against a tool's input schema. */\nexport type ArgumentValidator = (args: unknown) => {\n\tvalid: boolean;\n\terrors: OutputUnit[];\n};\n\nconst compiled = new WeakMap<RegisteredTool, ArgumentValidator>();\n\n/**\n * The validator of a tool's input schema, built once per tool. Throws what\n * the validator would throw at call time: a `$ref` that does not resolve\n * (the validator resolves one only when an argument reaches it, against the\n * base of the nearest `$id`), an `$id` that is not a URL, a duplicate one.\n * `compileRegistry` makes the registry call it at registration (DEC-086).\n */\nexport function compileTool(tool: RegisteredTool): ArgumentValidator {\n\tconst known = compiled.get(tool);\n\tif (known !== undefined) return known;\n\tconst schema = tool.inputSchema as Schema;\n\tlet lookup: Record<string, Schema | boolean>;\n\ttry {\n\t\tlookup = dereference(schema);\n\t} catch (error) {\n\t\t// Only the first line: the validator appends the URIs it knows.\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\tthrow new Error(message.split(\"\\n\")[0]);\n\t}\n\tfor (const node of Object.values(lookup)) {\n\t\tif (typeof node !== \"object\" || node.$ref === undefined) continue;\n\t\tconst absolute = (node as { __absolute_ref__?: string }).__absolute_ref__;\n\t\tif (lookup[absolute ?? node.$ref] === undefined)\n\t\t\tthrow new Error(`$ref ${JSON.stringify(node.$ref)} does not resolve`);\n\t}\n\tconst validator: ArgumentValidator = (args) =>\n\t\tvalidateSchema(args, schema, \"2020-12\", lookup, false);\n\tcompiled.set(tool, validator);\n\treturn validator;\n}\n\nfunction schemaError(name: string, error: unknown, suffix = \"\"): TypeError {\n\tconst message = error instanceof Error ? error.message : String(error);\n\treturn new TypeError(\n\t\t`registerTool: the inputSchema of ${name}: ${message}${suffix}`,\n\t);\n}\n\n/**\n * The validator is loaded (on `connect()`): compile the schemas of the tools\n * registered so far, before any AI app lists them, and from now on at\n * registration, so that `registerTool` rejects a schema the validator cannot\n * use. A tool registered before that it refuses is unregistered; the errors\n * are for the page's `error` event.\n */\nexport function compileRegistry(registry: ToolRegistry): TypeError[] {\n\tconst refused: TypeError[] = [];\n\tfor (const tool of registry.list()) {\n\t\ttry {\n\t\t\tcompileTool(tool);\n\t\t} catch (error) {\n\t\t\tregistry.remove(tool);\n\t\t\trefused.push(\n\t\t\t\tschemaError(tool.name, error, \"; the tool was unregistered\"),\n\t\t\t);\n\t\t}\n\t}\n\tregistry.setCompiler((tool) => {\n\t\ttry {\n\t\t\tcompileTool(tool);\n\t\t} catch (error) {\n\t\t\tthrow schemaError(tool.name, error);\n\t\t}\n\t});\n\treturn refused;\n}\n\n/** A deep copy for an event; the value itself when it cannot be cloned. */\nfunction copy<T>(value: T): T {\n\ttry {\n\t\treturn structuredClone(value);\n\t} catch {\n\t\treturn value;\n\t}\n}\n\nexport interface McpRequestContext {\n\tgrant: GrantRef;\n\t/** The body as text when the caller already has it. */\n\tbody?: string;\n}\n\nexport interface McpHandler {\n\thandle(request: Request, context: McpRequestContext): Promise<Response>;\n\t/** The tool list changed: tell the listen streams. */\n\ttoolsChanged(): void;\n\t/** End every listen stream (the session is over). */\n\tclose(): void;\n}\n\nconst encoder = new TextEncoder();\n\nfunction isObject(v: unknown): v is Json {\n\treturn typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\nfunction json(status: number, value: unknown): Response {\n\treturn new Response(JSON.stringify(value), {\n\t\tstatus,\n\t\theaders: { \"content-type\": \"application/json\" },\n\t});\n}\n\nfunction rpcError(\n\tstatus: number,\n\tid: Id | null,\n\tcode: number,\n\tmessage: string,\n\tdata?: unknown,\n): Response {\n\tconst error: Json = { code, message };\n\tif (data !== undefined) error[\"data\"] = data;\n\treturn json(status, { jsonrpc: \"2.0\", id, error });\n}\n\nfunction mismatch(id: Id | null, header: string, body: string): Response {\n\treturn rpcError(\n\t\t400,\n\t\tid,\n\t\tHEADER_MISMATCH,\n\t\t`Bad Request: the request headers and body disagree: ${body}`,\n\t\t{\n\t\t\tmismatch: { header, body },\n\t\t},\n\t);\n}\n\nfunction sseEvent(message: unknown): Uint8Array {\n\treturn encoder.encode(`event: message\\ndata: ${JSON.stringify(message)}\\n\\n`);\n}\n\nconst SSE_HEADERS = {\n\t\"content-type\": \"text/event-stream\",\n\t\"cache-control\": \"no-cache\",\n};\n\n/** `application/json`, with or without parameters. */\nfunction isJsonContentType(value: string | null): boolean {\n\treturn (\n\t\t(value ?? \"\").split(\";\")[0]?.trim().toLowerCase() === \"application/json\"\n\t);\n}\n\n/** Decode the `=?base64?…?=` sentinel of SEP-2243 headers; `undefined` if malformed. */\nexport function decodeHeaderValue(value: string): string | undefined {\n\tif (!(value.startsWith(\"=?base64?\") && value.endsWith(\"?=\"))) return value;\n\tconst b64 = value.slice(9, -2);\n\tif (\n\t\t!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(\n\t\t\tb64,\n\t\t)\n\t)\n\t\treturn undefined;\n\ttry {\n\t\tconst bin = atob(b64);\n\t\tconst bytes = Uint8Array.from(bin, (c) => c.charCodeAt(0));\n\t\treturn new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** The first problem of a 2026-07-28 `_meta` envelope, or `undefined`. */\nfunction envelopeIssue(\n\tmeta: Json,\n): { key: string; problem: string } | undefined {\n\tif (!(META_VERSION in meta)) return { key: META_VERSION, problem: \"missing\" };\n\tif (!(META_CAPABILITIES in meta))\n\t\treturn { key: META_CAPABILITIES, problem: \"missing\" };\n\tif (typeof meta[META_VERSION] !== \"string\") {\n\t\treturn { key: META_VERSION, problem: \"expected a protocol version string\" };\n\t}\n\tif (!isObject(meta[META_CAPABILITIES]))\n\t\treturn { key: META_CAPABILITIES, problem: \"expected an object\" };\n\tconst info = meta[META_CLIENT_INFO];\n\tif (\n\t\tinfo !== undefined &&\n\t\t!(\n\t\t\tisObject(info) &&\n\t\t\ttypeof info[\"name\"] === \"string\" &&\n\t\t\ttypeof info[\"version\"] === \"string\"\n\t\t)\n\t) {\n\t\treturn { key: META_CLIENT_INFO, problem: \"expected {name, version}\" };\n\t}\n\treturn undefined;\n}\n\n/** Listen streams honour only the tool list (the tab has nothing else). */\nfunction honoured(params: Json): Json {\n\tconst requested = params[\"notifications\"];\n\treturn isObject(requested) && requested[\"toolsListChanged\"] === true\n\t\t? { toolsListChanged: true }\n\t\t: {};\n}\n\nfunction validate(tool: RegisteredTool, args: Json): string | undefined {\n\tlet outcome: ReturnType<ArgumentValidator>;\n\ttry {\n\t\toutcome = compileTool(tool)(args);\n\t} catch (error) {\n\t\t// Refused at registration through `TabMcp`; this is for any other registry.\n\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\treturn `The input schema of tool ${tool.name} cannot be used: ${message}`;\n\t}\n\tif (outcome.valid) return undefined;\n\tconst detail = outcome.errors\n\t\t.filter((e) => e.keyword !== \"properties\" && e.keyword !== \"$ref\")\n\t\t.map((e) => `${e.instanceLocation} ${e.error}`)\n\t\t.slice(0, 5)\n\t\t.join(\"; \");\n\treturn `Input validation error: Invalid arguments for tool ${tool.name}: ${detail || \"the arguments do not match the schema\"}`;\n}\n\n/**\n * How a call ended. `stop`: why it did not run to its end: invalid\n * arguments, declined by the user, not answered by the user, cancelled, or\n * its tool gone. `returned`: what `execute` returned.\n */\nexport interface CallRun {\n\toutcome: ToolCallOutcome;\n\tresult: CallToolResult;\n\tstop?: \"invalid\" | \"declined\" | \"unanswered\" | \"cancelled\" | \"gone\";\n\treturned?: { value: unknown };\n}\n\n/**\n * One call of a known tool, from an AI app through the relay or from an\n * agent in the browser through WebMCP: the `toolcall` and `toolcallend`\n * events around the argument check, the confirmation of a consequential\n * tool and `execute`. The one path for both callers, so they cannot drift.\n */\nexport async function runCall(\n\tcontext: CallContext,\n\ttool: RegisteredTool,\n\traw: Json,\n\tsignal: AbortSignal,\n\tclient: ToolCallClient,\n\t/**\n\t * Whether the caller can be sent this result: `undefined` if so, else an\n\t * error result to send instead. Before `toolcallend`, so that the event\n\t * says what the caller gets.\n\t */\n\tdeliverable?: (result: CallToolResult) => CallToolResult | undefined,\n): Promise<CallRun> {\n\t// Copies: a listener cannot change what the tool gets or the caller receives.\n\tconst call: ToolCallStart = {\n\t\tid: ++lastCallId,\n\t\ttool: tool.name,\n\t\targuments: copy(raw),\n\t\tclient: { ...client },\n\t};\n\tif (tool.title !== undefined) call.title = tool.title;\n\tconst started = Date.now();\n\tcontext.observe?.start(call);\n\t// Every start has its end, also when something fails outside the tool.\n\tlet run: CallRun = {\n\t\toutcome: \"error\",\n\t\tresult: errorResult(\"Internal error\"),\n\t};\n\ttry {\n\t\trun = await decideAndRun(context, tool, raw, signal, client);\n\t\t// The caller learns per result, not only from tools/list, that this\n\t\t// text is not the page's (DEC-166).\n\t\tif (tool.annotations.untrustedContentHint === true)\n\t\t\trun.result = markUntrusted(run.result);\n\t\tconst instead = signal.aborted ? undefined : deliverable?.(run.result);\n\t\tif (instead !== undefined) run = { outcome: \"error\", result: instead };\n\t} finally {\n\t\tcontext.observe?.end({\n\t\t\tid: call.id,\n\t\t\ttool: tool.name,\n\t\t\tclient: { ...client },\n\t\t\toutcome: run.outcome,\n\t\t\tresult: copy(run.result),\n\t\t\tdurationMs: Date.now() - started,\n\t\t});\n\t}\n\treturn run;\n}\n\n/** What the AI app reads when the user was asked and did not answer. */\nconst UNANSWERED = \"The user was asked and did not answer.\";\n\n/** Validate, confirm and run one call. */\nasync function decideAndRun(\n\tcontext: CallContext,\n\ttool: RegisteredTool,\n\traw: Json,\n\tsignal: AbortSignal,\n\tclient: ToolCallClient,\n): Promise<CallRun> {\n\tconst stopped = (\n\t\toutcome: ToolCallOutcome,\n\t\tmessage: string,\n\t\tstop: NonNullable<CallRun[\"stop\"]>,\n\t): CallRun => ({ outcome, result: errorResult(message), stop });\n\tconst invalid = validate(tool, raw);\n\tif (invalid !== undefined) return stopped(\"error\", invalid, \"invalid\");\n\t// Rejects once the call is cancelled (or timed out): the call ends then,\n\t// also when a question or a tool does not heed the signal, and what they\n\t// answer later is dropped (DEC-167).\n\tconst cancelled = new Promise<never>((_, reject) => {\n\t\tif (signal.aborted) reject(signal.reason);\n\t\tsignal.addEventListener(\"abort\", () => reject(signal.reason));\n\t});\n\tcancelled.catch(() => {});\n\tif (tool.annotations.consequentialHint === true) {\n\t\tconst question: ConfirmRequest = {\n\t\t\ttool: { name: tool.name, description: tool.description },\n\t\t\targuments: raw,\n\t\t\tclient,\n\t\t\tsignal,\n\t\t};\n\t\tif (tool.title !== undefined) question.tool.title = tool.title;\n\t\tlet answer: ConfirmAnswer = false;\n\t\ttry {\n\t\t\tanswer = await Promise.race([context.confirm(question), cancelled]);\n\t\t} catch {\n\t\t\tanswer = false; // a failing question is a refusal\n\t\t}\n\t\tif (answer !== true) {\n\t\t\tif (signal.aborted)\n\t\t\t\treturn stopped(\"cancelled\", \"The user declined\", \"cancelled\");\n\t\t\treturn answer === \"unanswered\"\n\t\t\t\t? stopped(\"unanswered\", UNANSWERED, \"unanswered\")\n\t\t\t\t: stopped(\"declined\", \"The user declined\", \"declined\");\n\t\t}\n\t}\n\tif (signal.aborted) return stopped(\"cancelled\", \"Cancelled\", \"cancelled\");\n\t// Unregistered (or replaced) while the user was asked: not the tool\n\t// the user allowed, or one the page still offers.\n\tif (context.tools.get(tool.name) !== tool)\n\t\treturn stopped(\"error\", \"The tool is no longer available\", \"gone\");\n\tlet run: CallRun;\n\ttry {\n\t\tconst value = await Promise.race([\n\t\t\ttool.execute(raw, { signal, client }),\n\t\t\tcancelled,\n\t\t]);\n\t\trun = {\n\t\t\toutcome: \"ok\",\n\t\t\tresult: toCallToolResult(value),\n\t\t\treturned: { value },\n\t\t};\n\t} catch (error) {\n\t\trun = { outcome: \"error\", result: thrownResult(error) };\n\t}\n\t// Cancelled is cancelled, however the tool answered the abort.\n\tif (signal.aborted)\n\t\treturn { ...run, outcome: \"cancelled\", stop: \"cancelled\" };\n\tif (run.result.isError === true) run.outcome = \"error\";\n\treturn run;\n}\n\n/**\n * A call from an agent in the browser (WebMCP) of the mirrored `tool`: the\n * same path as an AI app's call (`runCall`), its outcome as WebMCP has it.\n * Resolves with what `execute` returned, as `webMcpValue` maps it. Every\n * failure the agent should read resolves too, as `{ error: \"<message>\" }`:\n * invalid arguments, \"Don't allow\", a question not answered, a tool that is\n * gone, what `execute` threw, an `isError` result.\n * WebMCP hands the agent a rejection without its message (the draft: an\n * `OperationError`; Chrome 156: `UnknownError`), so the agent would learn\n * neither why nor what to change (DEC-120). Only a call the browser\n * cancelled rejects (`AbortError`): its caller has gone already.\n */\nexport async function webMcpCall(\n\tcontext: CallContext,\n\ttool: RegisteredTool,\n\tinput: unknown,\n\tsignal: unknown,\n): Promise<unknown> {\n\tconst failed = (error: string) => ({ error });\n\tconst gone = `The tool ${tool.name} is no longer available.`;\n\t// Gone already, e.g. refused by the validator just loaded: no call.\n\tif (context.tools.get(tool.name) !== tool) return failed(gone);\n\tif (!isObject(input)) return failed(\"The input must be an object.\");\n\tconst run = await runCall(\n\t\tcontext,\n\t\ttool,\n\t\tinput,\n\t\tsignal instanceof AbortSignal ? signal : new AbortController().signal,\n\t\t{ kind: \"webmcp\" },\n\t);\n\tif (run.stop === \"cancelled\")\n\t\tthrow new DOMException(\"Cancelled\", \"AbortError\");\n\tif (run.stop === \"declined\")\n\t\treturn failed(`The user did not allow ${tool.name} to run.`);\n\tif (run.stop === \"unanswered\")\n\t\treturn failed(`The user did not answer whether ${tool.name} may run.`);\n\tif (run.stop === \"gone\") return failed(gone);\n\tif (run.result.isError === true)\n\t\treturn failed(resultText(run.result) || \"The tool failed.\");\n\treturn webMcpValue(run.returned?.value);\n}\n\nexport function createMcpHandler(options: McpHandlerOptions): McpHandler {\n\tconst { tools, server } = options;\n\tconst serverInfo: Json = { name: server.name, version: server.version };\n\tif (server.title !== undefined) serverInfo[\"title\"] = server.title;\n\t// The icons only in server/discover: every other result carries\n\t// serverInfo too, and the app needs them once.\n\tconst icons = cleanIcons(server.icons ?? []);\n\tconst discoverInfo: Json =\n\t\ticons.length > 0 ? { ...serverInfo, icons } : serverInfo;\n\tconst listeners = new Set<{\n\t\tid: Id;\n\t\tsend(message: unknown): void;\n\t\tend(): void;\n\t}>();\n\tlet changeQueued = false;\n\n\tconst resultMeta = (extra: Json = {}) => ({\n\t\t...extra,\n\t\t[META_SERVER_INFO]: serverInfo,\n\t});\n\n\tfunction result(id: Id, value: Json, meta: Json = resultMeta()): Json {\n\t\treturn {\n\t\t\tjsonrpc: \"2.0\",\n\t\t\tid,\n\t\t\tresult: { ...value, resultType: \"complete\", _meta: meta },\n\t\t};\n\t}\n\n\tfunction listTools(): Json[] {\n\t\treturn tools.list().map((tool) => {\n\t\t\tconst entry: Json = { name: tool.name };\n\t\t\tif (tool.title !== undefined) entry[\"title\"] = tool.title;\n\t\t\t// The AI app waits while the page asks: it can tell the user where\n\t\t\t// (CU 9). Not with an own `onConfirm`, which may ask elsewhere (a\n\t\t\t// side panel, the site's chat; DEC-169). The tool's own description\n\t\t\t// is unchanged elsewhere.\n\t\t\tentry[\"description\"] =\n\t\t\t\ttool.annotations.consequentialHint === true && !options.ownConfirm\n\t\t\t\t\t? `${tool.description} ${CONFIRMED_IN_TAB}`\n\t\t\t\t\t: tool.description;\n\t\t\tentry[\"inputSchema\"] = tool.inputSchema;\n\t\t\tif (tool.outputSchema !== undefined)\n\t\t\t\tentry[\"outputSchema\"] = tool.outputSchema;\n\t\t\tconst { annotations, meta } = mapAnnotations(tool.annotations);\n\t\t\tif (annotations !== undefined) entry[\"annotations\"] = annotations;\n\t\t\tif (meta !== undefined) entry[\"_meta\"] = { [ANNOTATIONS_META_KEY]: meta };\n\t\t\treturn entry;\n\t\t});\n\t}\n\n\t/**\n\t * A call's outcome: a JSON-RPC error (`invalid`) or a result. Tagged, so\n\t * that a result's own keys never decide which (a tool may return any).\n\t */\n\ttype RunOutcome =\n\t\t| { kind: \"invalid\"; message: string }\n\t\t| { kind: \"result\"; result: CallToolResult };\n\n\tconst invalidParams = (message: string): RunOutcome => ({\n\t\tkind: \"invalid\",\n\t\tmessage,\n\t});\n\n\tasync function runTool(\n\t\tparams: Json,\n\t\tsignal: AbortSignal,\n\t\tgrant: GrantRef,\n\t\tdeliverable: (result: CallToolResult) => CallToolResult | undefined,\n\t): Promise<RunOutcome> {\n\t\tconst name = params[\"name\"];\n\t\tif (typeof name !== \"string\")\n\t\t\treturn invalidParams(\"Invalid params: name must be a string\");\n\t\tconst tool = tools.get(name);\n\t\tif (tool === undefined) return invalidParams(`Tool ${name} not found`);\n\t\tconst raw = params[\"arguments\"] ?? {};\n\t\tif (!isObject(raw))\n\t\t\treturn invalidParams(\"Invalid params: arguments must be an object\");\n\t\tconst run = await runCall(\n\t\t\toptions,\n\t\t\ttool,\n\t\t\traw,\n\t\t\tsignal,\n\t\t\toptions.client(grant),\n\t\t\tdeliverable,\n\t\t);\n\t\treturn { kind: \"result\", result: run.result };\n\t}\n\n\tfunction callTool(\n\t\tid: Id,\n\t\tparams: Json,\n\t\tsignal: AbortSignal,\n\t\tgrant: GrantRef,\n\t): Response {\n\t\t/** The answer's event; the tool's own `_meta` is kept, next to serverInfo. */\n\t\tconst answer = (value: CallToolResult): Uint8Array =>\n\t\t\tsseEvent(result(id, value, resultMeta(value._meta)));\n\t\t/** The event of the result checked last, so that it is encoded once. */\n\t\tlet checked: { result: CallToolResult; event: Uint8Array } | undefined;\n\t\t/** A result the caller cannot get: not JSON, or more than the relay passes on (CC 7). */\n\t\tconst deliverable = (value: CallToolResult): CallToolResult | undefined => {\n\t\t\tlet event: Uint8Array;\n\t\t\ttry {\n\t\t\t\tevent = answer(value);\n\t\t\t} catch {\n\t\t\t\t// e.g. a BigInt or a cycle inside a passed-through result\n\t\t\t\treturn errorResult(\"The tool returned a result that is not JSON.\");\n\t\t\t}\n\t\t\tconst max = options.maxBodyBytes?.();\n\t\t\tif (max !== undefined && event.byteLength > max) {\n\t\t\t\treturn errorResult(\n\t\t\t\t\t`The result is ${event.byteLength} bytes; the relay passes on at most ${max}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tchecked = { result: value, event };\n\t\t\treturn undefined;\n\t\t};\n\t\tconst stream = new ReadableStream<Uint8Array>({\n\t\t\tstart: (controller) => {\n\t\t\t\t/**\n\t\t\t\t * Send the one answer and end the stream, whatever happens. Encoded\n\t\t\t\t * only if someone listens: a cancelled call's result was not checked.\n\t\t\t\t */\n\t\t\t\tconst finish = (event: () => Uint8Array) => {\n\t\t\t\t\tif (signal.aborted) return; // nobody listens any more\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcontroller.enqueue(event());\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// the stream was cancelled meanwhile\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\trunTool(params, signal, grant, deliverable).then(\n\t\t\t\t\t(outcome) =>\n\t\t\t\t\t\tfinish(() =>\n\t\t\t\t\t\t\toutcome.kind === \"invalid\"\n\t\t\t\t\t\t\t\t? sseEvent({\n\t\t\t\t\t\t\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\t\t\terror: { code: -32602, message: outcome.message },\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t: outcome.result === checked?.result\n\t\t\t\t\t\t\t\t\t? checked.event\n\t\t\t\t\t\t\t\t\t: answer(outcome.result),\n\t\t\t\t\t\t),\n\t\t\t\t\t() =>\n\t\t\t\t\t\tfinish(() =>\n\t\t\t\t\t\t\tsseEvent({\n\t\t\t\t\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\t\t\t\t\tid,\n\t\t\t\t\t\t\t\terror: { code: -32603, message: \"Internal error\" },\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t},\n\t\t});\n\t\treturn new Response(stream, { status: 200, headers: SSE_HEADERS });\n\t}\n\n\tfunction listen(id: Id, params: Json, signal: AbortSignal): Response {\n\t\tconst notifications = honoured(params);\n\t\tconst finalResult = {\n\t\t\tjsonrpc: \"2.0\",\n\t\t\tid,\n\t\t\tresult: {\n\t\t\t\tresultType: \"complete\",\n\t\t\t\t_meta: resultMeta({ [META_SUBSCRIPTION]: id }),\n\t\t\t},\n\t\t};\n\t\t// This stream's own listener: two AI apps may both use the same id.\n\t\tlet own: { id: Id; send(m: unknown): void; end(): void } | undefined;\n\t\tconst stream = new ReadableStream<Uint8Array>({\n\t\t\tstart: (controller) => {\n\t\t\t\tcontroller.enqueue(\n\t\t\t\t\tsseEvent({\n\t\t\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\t\t\tmethod: \"notifications/subscriptions/acknowledged\",\n\t\t\t\t\t\tparams: { notifications, _meta: { [META_SUBSCRIPTION]: id } },\n\t\t\t\t\t}),\n\t\t\t\t);\n\t\t\t\tif (Object.keys(notifications).length === 0) {\n\t\t\t\t\tcontroller.enqueue(sseEvent(finalResult));\n\t\t\t\t\tcontroller.close();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst listener = {\n\t\t\t\t\tid,\n\t\t\t\t\tsend: (message: unknown) => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tcontroller.enqueue(sseEvent(message));\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\tlisteners.delete(listener);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tend: () => {\n\t\t\t\t\t\tlisteners.delete(listener);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tcontroller.enqueue(sseEvent(finalResult));\n\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t} catch {\n\t\t\t\t\t\t\t// already cancelled\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t\town = listener;\n\t\t\t\tlisteners.add(listener);\n\t\t\t\tsignal.addEventListener(\"abort\", () => {\n\t\t\t\t\tlisteners.delete(listener);\n\t\t\t\t\ttry {\n\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t} catch {\n\t\t\t\t\t\t// already closed\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t\tcancel: () => {\n\t\t\t\tif (own !== undefined) listeners.delete(own);\n\t\t\t},\n\t\t});\n\t\treturn new Response(stream, { status: 200, headers: SSE_HEADERS });\n\t}\n\n\t/** The request checks; a `Response` when the request is refused. */\n\tfunction check(\n\t\trequest: Request,\n\t\tbody: unknown,\n\t): Response | { id: Id; method: string; params: Json } | \"notification\" {\n\t\tif (Array.isArray(body)) {\n\t\t\treturn rpcError(\n\t\t\t\t400,\n\t\t\t\tnull,\n\t\t\t\t-32600,\n\t\t\t\t\"Bad Request: JSON-RPC batches are not supported by this endpoint\",\n\t\t\t);\n\t\t}\n\t\tif (!isObject(body) || body[\"jsonrpc\"] !== \"2.0\") {\n\t\t\treturn rpcError(\n\t\t\t\t400,\n\t\t\t\tnull,\n\t\t\t\t-32600,\n\t\t\t\t\"Bad Request: the request body is not a valid JSON-RPC message\",\n\t\t\t);\n\t\t}\n\t\tconst method = body[\"method\"];\n\t\tconst rawId = body[\"id\"];\n\t\tif (typeof method !== \"string\") {\n\t\t\treturn \"result\" in body || \"error\" in body\n\t\t\t\t? rpcError(\n\t\t\t\t\t\t400,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t-32600,\n\t\t\t\t\t\t\"Bad Request: JSON-RPC responses cannot be posted to this endpoint\",\n\t\t\t\t\t)\n\t\t\t\t: rpcError(\n\t\t\t\t\t\t400,\n\t\t\t\t\t\tnull,\n\t\t\t\t\t\t-32600,\n\t\t\t\t\t\t\"Bad Request: the request body is not a valid JSON-RPC message\",\n\t\t\t\t\t);\n\t\t}\n\t\tconst headerVersion = request.headers.get(\"mcp-protocol-version\");\n\t\tconst headerMethod = request.headers.get(\"mcp-method\");\n\t\tconst params = isObject(body[\"params\"]) ? body[\"params\"] : {};\n\t\tconst meta = isObject(params[\"_meta\"]) ? params[\"_meta\"] : undefined;\n\t\tconst claim = meta !== undefined && META_VERSION in meta;\n\t\tconst claimed =\n\t\t\ttypeof meta?.[META_VERSION] === \"string\"\n\t\t\t\t? (meta[META_VERSION] as string)\n\t\t\t\t: undefined;\n\t\tconst headerModern =\n\t\t\theaderVersion !== null && headerVersion >= MCP_PROTOCOL_VERSION;\n\n\t\tif (rawId === undefined) {\n\t\t\t// A notification: nothing to answer, but the headers must agree.\n\t\t\tif (\n\t\t\t\tclaimed !== undefined &&\n\t\t\t\theaderVersion !== null &&\n\t\t\t\theaderVersion !== claimed\n\t\t\t) {\n\t\t\t\treturn mismatch(\n\t\t\t\t\tnull,\n\t\t\t\t\theaderVersion,\n\t\t\t\t\t`the notification envelope names protocol version ${claimed} but the MCP-Protocol-Version header names ${headerVersion}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (\n\t\t\t\t(claim || headerModern) &&\n\t\t\t\theaderMethod !== null &&\n\t\t\t\theaderMethod !== method\n\t\t\t) {\n\t\t\t\treturn mismatch(\n\t\t\t\t\tnull,\n\t\t\t\t\theaderMethod,\n\t\t\t\t\t`the notification body names method ${method} but the Mcp-Method header names ${headerMethod}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn \"notification\";\n\t\t}\n\t\tif (typeof rawId !== \"string\" && typeof rawId !== \"number\") {\n\t\t\treturn rpcError(\n\t\t\t\t400,\n\t\t\t\tnull,\n\t\t\t\t-32600,\n\t\t\t\t\"Bad Request: the request body is not a valid JSON-RPC message\",\n\t\t\t);\n\t\t}\n\t\tconst id = rawId;\n\t\tif (\n\t\t\t!claim ||\n\t\t\t(method === \"initialize\" &&\n\t\t\t\t(claimed === undefined || claimed < MCP_PROTOCOL_VERSION))\n\t\t) {\n\t\t\tif (method === \"initialize\") {\n\t\t\t\tif (headerModern) {\n\t\t\t\t\treturn mismatch(\n\t\t\t\t\t\tid,\n\t\t\t\t\t\theaderVersion,\n\t\t\t\t\t\t\"an initialize request (legacy handshake) was sent with a modern MCP-Protocol-Version header\",\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst requested =\n\t\t\t\t\ttypeof params[\"protocolVersion\"] === \"string\"\n\t\t\t\t\t\t? params[\"protocolVersion\"]\n\t\t\t\t\t\t: undefined;\n\t\t\t\treturn unsupported(id, requested);\n\t\t\t}\n\t\t\tif (headerModern) {\n\t\t\t\tconst missing = meta === undefined ? [\"_meta\"] : [META_VERSION];\n\t\t\t\treturn rpcError(\n\t\t\t\t\t400,\n\t\t\t\t\tid,\n\t\t\t\t\t-32602,\n\t\t\t\t\t`Invalid params: the MCP-Protocol-Version header names protocol revision ${headerVersion}, but the request is missing the required per-request envelope key(s): ${missing.join(\", \")}`,\n\t\t\t\t\t{ envelope: { missing } },\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn unsupported(id, headerVersion ?? undefined);\n\t\t}\n\t\tconst issue = envelopeIssue(meta);\n\t\tif (issue !== undefined) {\n\t\t\treturn rpcError(\n\t\t\t\t400,\n\t\t\t\tid,\n\t\t\t\t-32602,\n\t\t\t\t`Invalid _meta envelope for protocol revision ${MCP_PROTOCOL_VERSION}: ${issue.key}: ${issue.problem}`,\n\t\t\t\t{ envelope: issue },\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\theaderVersion !== null &&\n\t\t\tclaimed !== undefined &&\n\t\t\theaderVersion !== claimed\n\t\t) {\n\t\t\treturn mismatch(\n\t\t\t\tid,\n\t\t\t\theaderVersion,\n\t\t\t\t`the body envelope names protocol version ${claimed} but the MCP-Protocol-Version header names ${headerVersion}`,\n\t\t\t);\n\t\t}\n\t\tif (headerMethod !== null && headerMethod !== method) {\n\t\t\treturn mismatch(\n\t\t\t\tid,\n\t\t\t\theaderMethod,\n\t\t\t\t`the body names method ${method} but the Mcp-Method header names ${headerMethod}`,\n\t\t\t);\n\t\t}\n\t\tif (claimed !== MCP_PROTOCOL_VERSION) return unsupported(id, claimed);\n\t\tif (headerVersion === null) {\n\t\t\treturn mismatch(\n\t\t\t\tid,\n\t\t\t\t\"(missing)\",\n\t\t\t\t`the body envelope names protocol version ${claimed} but the required MCP-Protocol-Version header is absent`,\n\t\t\t);\n\t\t}\n\t\tif (headerMethod === null) {\n\t\t\treturn mismatch(\n\t\t\t\tid,\n\t\t\t\t\"(missing)\",\n\t\t\t\t`the body names method ${method} but the required Mcp-Method header is absent`,\n\t\t\t);\n\t\t}\n\t\tif (method === \"tools/call\" && typeof params[\"name\"] === \"string\") {\n\t\t\tconst name = params[\"name\"];\n\t\t\tconst header = request.headers.get(\"mcp-name\");\n\t\t\tif (header === null) {\n\t\t\t\treturn mismatch(\n\t\t\t\t\tid,\n\t\t\t\t\t\"(missing)\",\n\t\t\t\t\t`the body carries params.name=\"${name}\" but the required Mcp-Name header is absent`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst decoded = decodeHeaderValue(header);\n\t\t\tif (decoded === undefined) {\n\t\t\t\treturn mismatch(\n\t\t\t\t\tid,\n\t\t\t\t\theader,\n\t\t\t\t\t\"the Mcp-Name header carries an invalid Base64 sentinel value\",\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (decoded !== name) {\n\t\t\t\treturn mismatch(\n\t\t\t\t\tid,\n\t\t\t\t\theader,\n\t\t\t\t\t`the body carries params.name=\"${name}\" but the Mcp-Name header names \"${decoded}\"`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\treturn { id, method, params };\n\t}\n\n\tfunction unsupported(id: Id, requested: string | undefined): Response {\n\t\treturn requested === undefined\n\t\t\t? rpcError(\n\t\t\t\t\t400,\n\t\t\t\t\tid,\n\t\t\t\t\tUNSUPPORTED_VERSION,\n\t\t\t\t\t\"Unsupported protocol version: the request did not name a protocol version\",\n\t\t\t\t\t{ supported: [MCP_PROTOCOL_VERSION] },\n\t\t\t\t)\n\t\t\t: rpcError(\n\t\t\t\t\t400,\n\t\t\t\t\tid,\n\t\t\t\t\tUNSUPPORTED_VERSION,\n\t\t\t\t\t`Unsupported protocol version: ${requested}`,\n\t\t\t\t\t{ supported: [MCP_PROTOCOL_VERSION], requested },\n\t\t\t\t);\n\t}\n\n\tasync function handle(\n\t\trequest: Request,\n\t\tcontext: McpRequestContext,\n\t): Promise<Response> {\n\t\tif (request.method.toUpperCase() !== \"POST\")\n\t\t\treturn rpcError(405, null, -32000, \"Method not allowed.\");\n\t\tif (!isJsonContentType(request.headers.get(\"content-type\"))) {\n\t\t\treturn rpcError(\n\t\t\t\t415,\n\t\t\t\tnull,\n\t\t\t\t-32000,\n\t\t\t\t\"Unsupported Media Type: Content-Type must be application/json\",\n\t\t\t);\n\t\t}\n\t\tlet body: unknown;\n\t\ttry {\n\t\t\tbody = JSON.parse(context.body ?? (await request.text()));\n\t\t} catch {\n\t\t\treturn rpcError(\n\t\t\t\t400,\n\t\t\t\tnull,\n\t\t\t\t-32700,\n\t\t\t\t\"Parse error: the request body is not valid JSON\",\n\t\t\t);\n\t\t}\n\t\tconst checked = check(request, body);\n\t\tif (checked instanceof Response) return checked;\n\t\tif (checked === \"notification\") return new Response(null, { status: 202 });\n\t\tconst { id, method, params } = checked;\n\t\tswitch (method) {\n\t\t\tcase \"server/discover\": {\n\t\t\t\tconst discover: Json = {\n\t\t\t\t\tsupportedVersions: [MCP_PROTOCOL_VERSION],\n\t\t\t\t\tcapabilities: { tools: { listChanged: true } },\n\t\t\t\t};\n\t\t\t\tif (server.instructions !== undefined)\n\t\t\t\t\tdiscover[\"instructions\"] = server.instructions;\n\t\t\t\tdiscover[\"ttlMs\"] = 0;\n\t\t\t\tdiscover[\"cacheScope\"] = \"private\";\n\t\t\t\treturn json(\n\t\t\t\t\t200,\n\t\t\t\t\tresult(id, discover, { [META_SERVER_INFO]: discoverInfo }),\n\t\t\t\t);\n\t\t\t}\n\t\t\tcase \"tools/list\":\n\t\t\t\treturn json(\n\t\t\t\t\t200,\n\t\t\t\t\tresult(id, { tools: listTools(), ttlMs: 0, cacheScope: \"private\" }),\n\t\t\t\t);\n\t\t\tcase \"tools/call\":\n\t\t\t\treturn callTool(id, params, request.signal, context.grant);\n\t\t\tcase \"subscriptions/listen\":\n\t\t\t\treturn listen(id, params, request.signal);\n\t\t\tdefault:\n\t\t\t\treturn rpcError(404, id, -32601, \"Method not found\");\n\t\t}\n\t}\n\n\treturn {\n\t\thandle: (request, context) =>\n\t\t\thandle(request, context).catch(() =>\n\t\t\t\trpcError(500, null, -32603, \"Internal server error\"),\n\t\t\t),\n\t\ttoolsChanged() {\n\t\t\tif (changeQueued) return;\n\t\t\tchangeQueued = true;\n\t\t\t// Several registrations in one task produce one notification.\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tchangeQueued = false;\n\t\t\t\tfor (const listener of [...listeners]) {\n\t\t\t\t\tlistener.send({\n\t\t\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\t\t\tmethod: \"notifications/tools/list_changed\",\n\t\t\t\t\t\tparams: { _meta: { [META_SUBSCRIPTION]: listener.id } },\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\t\tclose() {\n\t\t\tfor (const listener of [...listeners]) listener.end();\n\t\t},\n\t};\n}\n",
|
|
14
|
-
"/**\n * The tab↔relay protocol, version 1, as the tab speaks it\n * (`docs/protocol.md`, normative). Internal: not part of the public API.\n */\n\nimport type { Grant, Limits } from \"./types.ts\";\n\nexport const SUBPROTOCOL = \"tab-mcp.v1\";\n\n/** Who is calling a tunnelled request (the relay's view of the grant). */\nexport interface GrantRef {\n\tgrantId: string;\n\tclientId: string;\n\tscopes: string[];\n}\n\n// Relay → tab\n\nexport interface SessionMessage {\n\ttype: \"session\";\n\tsessionId: string;\n\taddress: string;\n\torigin: string;\n\tappName?: string;\n\t/** How AI apps pair: `code` or `oidc` (identity binding). Older relays omit it. */\n\tpairing?: \"code\" | \"oidc\";\n\texpiresAt: string;\n\tlimits: Limits;\n\tgrants: Grant[];\n}\nexport interface PingMessage {\n\ttype: \"ping\";\n\tt: number;\n}\nexport interface ByeMessage {\n\ttype: \"bye\";\n\treason: string;\n}\nexport interface HttpRequestMessage {\n\ttype: \"http.request\";\n\tid: string;\n\tmethod: string;\n\tpath: string;\n\theaders: Record<string, string>;\n\tbody: string;\n\tgrant: GrantRef;\n}\nexport interface HttpCancelMessage {\n\ttype: \"http.cancel\";\n\tid: string;\n\treason: string;\n}\nexport interface PairingCodeMessage {\n\ttype: \"pairing.code\";\n\tcode: string;\n\texpiresAt: string;\n\t/** Why it came; left out
|
|
14
|
+
"/**\n * The tab↔relay protocol, version 1, as the tab speaks it\n * (`docs/protocol.md`, normative). Internal: not part of the public API.\n */\n\nimport type { Grant, Limits } from \"./types.ts\";\n\nexport const SUBPROTOCOL = \"tab-mcp.v1\";\n\n/** Who is calling a tunnelled request (the relay's view of the grant). */\nexport interface GrantRef {\n\tgrantId: string;\n\tclientId: string;\n\tscopes: string[];\n}\n\n// Relay → tab\n\nexport interface SessionMessage {\n\ttype: \"session\";\n\tsessionId: string;\n\taddress: string;\n\torigin: string;\n\tappName?: string;\n\t/** How AI apps pair: `code` or `oidc` (identity binding). Older relays omit it. */\n\tpairing?: \"code\" | \"oidc\";\n\texpiresAt: string;\n\tlimits: Limits;\n\tgrants: Grant[];\n}\nexport interface PingMessage {\n\ttype: \"ping\";\n\tt: number;\n}\nexport interface ByeMessage {\n\ttype: \"bye\";\n\treason: string;\n}\nexport interface HttpRequestMessage {\n\ttype: \"http.request\";\n\tid: string;\n\tmethod: string;\n\tpath: string;\n\theaders: Record<string, string>;\n\tbody: string;\n\tgrant: GrantRef;\n}\nexport interface HttpCancelMessage {\n\ttype: \"http.cancel\";\n\tid: string;\n\treason: string;\n}\nexport interface PairingCodeMessage {\n\ttype: \"pairing.code\";\n\tcode: string;\n\texpiresAt: string;\n\t/** Why it came; left out when it is not one of these. */\n\treason?: \"start\" | \"used\" | \"expired\";\n}\n\nconst CODE_REASONS = new Set([\"start\", \"used\", \"expired\"]);\nexport interface GrantAddedMessage {\n\ttype: \"grant.added\";\n\tgrant: Grant;\n}\nexport interface GrantRemovedMessage {\n\ttype: \"grant.removed\";\n\tgrantId: string;\n\treason: string;\n}\nexport interface IdentityBoundMessage {\n\ttype: \"identity.bound\";\n\t/** The `round` of the `identity` this answers. */\n\tround?: number;\n}\nexport interface ErrorMessage {\n\ttype: \"error\";\n\tcode: string;\n\tmessage: string;\n\tid?: string;\n\t/** On `identity_refused`: the `round` of the `identity` it answers. */\n\tround?: number;\n\t/**\n\t * On `unknown_id` and `store_unavailable` from relay 0.10.2: the type of\n\t * the page's message it answers (`grant.revoke`, `grants.revokeAll`,\n\t * `identity.logout`); older relays leave it out.\n\t */\n\tfor?: unknown;\n\t/** With `for: \"grant.revoke\"`: that message's grant. */\n\tgrantId?: unknown;\n}\nexport type RelayMessage =\n\t| SessionMessage\n\t| PingMessage\n\t| ByeMessage\n\t| HttpRequestMessage\n\t| HttpCancelMessage\n\t| PairingCodeMessage\n\t| GrantAddedMessage\n\t| GrantRemovedMessage\n\t| IdentityBoundMessage\n\t| ErrorMessage;\n\n// Tab → relay\n\nexport type TabMessage =\n\t| {\n\t\t\ttype: \"hello\";\n\t\t\tlibrary: { name: string; version: string };\n\t\t\t/** `id`: the `<app>` of the address `/s/<app>/mcp` (DEC-196). */\n\t\t\tapp: { id: string; name?: string };\n\t\t\tsecret: string;\n\t\t\t/** Take the address back: the relay revokes its grants as it claims it (DEC-095). */\n\t\t\trevokeAll?: true;\n\t }\n\t| { type: \"pong\"; t: number }\n\t| { type: \"bye\"; reason: string }\n\t| {\n\t\t\ttype: \"http.response\";\n\t\t\tid: string;\n\t\t\tstatus: number;\n\t\t\theaders: Record<string, string>;\n\t\t\tbody: string;\n\t }\n\t| {\n\t\t\ttype: \"http.response.start\";\n\t\t\tid: string;\n\t\t\tstatus: number;\n\t\t\theaders: Record<string, string>;\n\t }\n\t| { type: \"http.response.chunk\"; id: string; data: string }\n\t| { type: \"http.response.end\"; id: string }\n\t| { type: \"pairing.start\" }\n\t| { type: \"pairing.stop\" }\n\t| { type: \"grant.revoke\"; grantId: string }\n\t| { type: \"grants.revokeAll\" }\n\t| { type: \"identity\"; assertion: string; round: number }\n\t| { type: \"identity.logout\" }\n\t| { type: \"error\"; code: string; message: string; id?: string };\n\ntype Json = Record<string, unknown>;\n\nfunction isObject(v: unknown): v is Json {\n\treturn typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\nconst str = (v: unknown): v is string => typeof v === \"string\";\n\nfunction isGrant(v: unknown): v is Grant {\n\tif (!isObject(v) || !str(v[\"grantId\"]) || !str(v[\"createdAt\"])) return false;\n\tconst c = v[\"client\"];\n\treturn isObject(c) && str(c[\"id\"]) && str(c[\"name\"]) && str(c[\"host\"]);\n}\n\nfunction isLimits(v: unknown): v is Limits {\n\tif (!isObject(v)) return false;\n\treturn [\n\t\t\"maxMessageBytes\",\n\t\t\"maxBodyBytes\",\n\t\t\"requestTimeoutMs\",\n\t\t\"idleTimeoutMs\",\n\t\t\"heartbeatMs\",\n\t\t\"keepAliveMs\",\n\t\t\"maxConcurrentRequests\",\n\t].every((k) => typeof v[k] === \"number\");\n}\n\nfunction isStringRecord(v: unknown): v is Record<string, string> {\n\treturn isObject(v) && Object.values(v).every(str);\n}\n\n/**\n * Parse one frame from the relay. Returns `undefined` for anything malformed\n * or unknown; the caller ignores it (forward compatibility).\n */\nexport function parseRelayMessage(text: string): RelayMessage | undefined {\n\tlet v: unknown;\n\ttry {\n\t\tv = JSON.parse(text);\n\t} catch {\n\t\treturn undefined;\n\t}\n\tif (!isObject(v)) return undefined;\n\tswitch (v[\"type\"]) {\n\t\tcase \"session\":\n\t\t\treturn str(v[\"sessionId\"]) &&\n\t\t\t\tstr(v[\"address\"]) &&\n\t\t\t\tstr(v[\"origin\"]) &&\n\t\t\t\tstr(v[\"expiresAt\"]) &&\n\t\t\t\tisLimits(v[\"limits\"]) &&\n\t\t\t\tArray.isArray(v[\"grants\"]) &&\n\t\t\t\tv[\"grants\"].every(isGrant) &&\n\t\t\t\t(v[\"appName\"] === undefined || str(v[\"appName\"])) &&\n\t\t\t\t(v[\"pairing\"] === undefined || str(v[\"pairing\"]))\n\t\t\t\t? (v as unknown as SessionMessage)\n\t\t\t\t: undefined;\n\t\tcase \"ping\":\n\t\t\treturn typeof v[\"t\"] === \"number\"\n\t\t\t\t? (v as unknown as PingMessage)\n\t\t\t\t: undefined;\n\t\tcase \"bye\":\n\t\t\treturn { type: \"bye\", reason: str(v[\"reason\"]) ? v[\"reason\"] : \"\" };\n\t\tcase \"http.request\":\n\t\t\treturn str(v[\"id\"]) &&\n\t\t\t\tstr(v[\"method\"]) &&\n\t\t\t\tstr(v[\"path\"]) &&\n\t\t\t\tisStringRecord(v[\"headers\"]) &&\n\t\t\t\tstr(v[\"body\"]) &&\n\t\t\t\tisObject(v[\"grant\"]) &&\n\t\t\t\tstr(v[\"grant\"][\"grantId\"]) &&\n\t\t\t\tstr(v[\"grant\"][\"clientId\"])\n\t\t\t\t? (v as unknown as HttpRequestMessage)\n\t\t\t\t: undefined;\n\t\tcase \"http.cancel\":\n\t\t\treturn str(v[\"id\"]) ? (v as unknown as HttpCancelMessage) : undefined;\n\t\tcase \"pairing.code\": {\n\t\t\tif (!str(v[\"code\"]) || !str(v[\"expiresAt\"])) return undefined;\n\t\t\tconst message: PairingCodeMessage = {\n\t\t\t\ttype: \"pairing.code\",\n\t\t\t\tcode: v[\"code\"],\n\t\t\t\texpiresAt: v[\"expiresAt\"],\n\t\t\t};\n\t\t\t// An unknown reason (a newer relay) counts as none.\n\t\t\tconst reason = v[\"reason\"];\n\t\t\tif (typeof reason === \"string\" && CODE_REASONS.has(reason))\n\t\t\t\tmessage.reason = reason as NonNullable<PairingCodeMessage[\"reason\"]>;\n\t\t\treturn message;\n\t\t}\n\t\tcase \"grant.added\":\n\t\t\treturn isGrant(v[\"grant\"])\n\t\t\t\t? (v as unknown as GrantAddedMessage)\n\t\t\t\t: undefined;\n\t\tcase \"grant.removed\":\n\t\t\treturn str(v[\"grantId\"])\n\t\t\t\t? {\n\t\t\t\t\t\ttype: \"grant.removed\",\n\t\t\t\t\t\tgrantId: v[\"grantId\"],\n\t\t\t\t\t\treason: str(v[\"reason\"]) ? v[\"reason\"] : \"\",\n\t\t\t\t\t}\n\t\t\t\t: undefined;\n\t\tcase \"identity.bound\":\n\t\t\treturn typeof v[\"round\"] === \"number\"\n\t\t\t\t? { type: \"identity.bound\", round: v[\"round\"] }\n\t\t\t\t: { type: \"identity.bound\" };\n\t\tcase \"error\":\n\t\t\treturn str(v[\"code\"]) ? (v as unknown as ErrorMessage) : undefined;\n\t\tdefault:\n\t\t\treturn undefined;\n\t}\n}\n",
|
|
15
15
|
"/**\n * The page's end of the HTTP tunnel (`docs/protocol.md`, \"Tunnelled MCP\n * requests\"): `http.request` and `http.cancel` in, `http.response*` out. The\n * relay connection uses it (`connection.ts`), and so does `TabMcp.serve`,\n * which answers the same messages over a port, without a relay\n * (iteration 28). Part of the lazily loaded chunk.\n */\n\nimport { pageIcons } from \"./icons.ts\";\nimport type { CallHost } from \"./internal.ts\";\nimport {\n\ttype CallContext,\n\tcreateMcpHandler,\n\ttype McpHandler,\n\ttype ToolSource,\n} from \"./mcp.ts\";\nimport type { GrantRef, HttpRequestMessage, TabMessage } from \"./protocol.ts\";\nimport type { RegisteredTool, ToolRegistry } from \"./registry.ts\";\nimport type {\n\tConfirmAnswer,\n\tLocalClient,\n\tServeHandle,\n\tServeOptions,\n\tServerInfo,\n\tToolCaller,\n\tTunnelPort,\n} from \"./types.ts\";\n\n/**\n * The tools that callers of `kind` see (`RegisterToolOptions.callers`): to\n * the others a tool they cannot see does not exist, in `tools/list` and in\n * `tools/call` alike. Without `callers`, the relay and a port see every tool.\n * The rule for WebMCP lives in the core's `mirror` (webmcp.ts), and WebMCP\n * calls come only for the tools it mirrored. Not one shared helper: a module\n * the core and this chunk both import would split the core in two.\n */\nexport function toolsFor(\n\tregistry: ToolRegistry,\n\tkind: \"relay\" | \"local\",\n): ToolSource {\n\tconst sees = (tool: RegisteredTool | undefined) =>\n\t\ttool && (tool.callers?.includes(kind) ?? true);\n\treturn {\n\t\tlist: () => registry.list().filter(sees),\n\t\tget: (name) => {\n\t\t\tconst tool = registry.get(name);\n\t\t\treturn sees(tool) ? tool : undefined;\n\t\t},\n\t};\n}\n\n/**\n * Calls `changed` when the list that `tools` gives changed, not on every\n * change of the registry: a tool another kind of caller sees is no news to\n * this one (`list_changed` per caller). Returns a function that stops.\n */\nexport function watchTools(\n\tregistry: ToolRegistry,\n\ttools: ToolSource,\n\tchanged: () => void,\n): () => void {\n\tlet last = tools.list();\n\treturn registry.onChange(() => {\n\t\tconst now = tools.list();\n\t\tif (now.length === last.length && now.every((t, i) => t === last[i]))\n\t\t\treturn;\n\t\tlast = now;\n\t\tchanged();\n\t});\n}\n\n/** What a call of `kind` through the relay, a port or WebMCP needs (`mcp.ts`), from the core's host. */\nexport function callContext(host: CallHost, kind: ToolCaller): CallContext {\n\treturn {\n\t\ttools: kind === \"webmcp\" ? host.registry : toolsFor(host.registry, kind),\n\t\tconfirm: (request) => host.confirm(request),\n\t\townConfirm: host.ownConfirm(),\n\t\tobserve: {\n\t\t\tstart: (call) => host.toolCallStarted(call),\n\t\t\tend: (call) => host.toolCallEnded(call),\n\t\t},\n\t};\n}\n\n/** Response headers that are passed on (the relay drops the rest). */\nconst RESPONSE_HEADERS = [\"content-type\", \"cache-control\"];\n\n/**\n * Split text into pieces of at most `max` UTF-16 units, never between the two\n * halves of a surrogate pair (a lone half would not survive JSON and UTF-8).\n */\nexport function* pieces(text: string, max: number): Generator<string> {\n\tlet i = 0;\n\twhile (i < text.length) {\n\t\tlet end = Math.min(i + max, text.length);\n\t\tconst last = text.charCodeAt(end - 1);\n\t\tif (end < text.length && last >= 0xd800 && last <= 0xdbff) {\n\t\t\tend += end - 1 > i ? -1 : 1; // keep the pair together\n\t\t}\n\t\tyield text.slice(i, end);\n\t\ti = end;\n\t}\n}\n\n/** The relay's JSON-RPC error for a request that took too long, as `createTunnelFetch` sends it. */\nconst TIMEOUT = -31002;\nconst TIMED_OUT = \"The page did not answer in time.\";\n\n/** The JSON-RPC id of a request body, for the error that answers it. */\nfunction rpcId(body: string): string | number | null {\n\ttry {\n\t\tconst id: unknown = JSON.parse(body)?.id;\n\t\treturn typeof id === \"string\" || typeof id === \"number\" ? id : null;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n/** The requests in flight of one channel (a relay session or a port). */\nexport interface Tunnel {\n\t/** Answer one request; nothing is sent for it once it is cancelled or the tunnel closed. */\n\trequest(message: HttpRequestMessage): void;\n\tcancel(id: string): void;\n\t/** Abort every request in flight; later requests are ignored. */\n\tclose(): void;\n}\n\nexport function createTunnel(options: {\n\thandler: McpHandler;\n\tsend(message: TabMessage): boolean;\n\t/** The largest piece of body text in one message (UTF-16 units), read per answer. */\n\tmaxChunk(): number;\n\t/** Something failed outside the handler. */\n\terror(error: Error): void;\n\t/**\n\t * How long a request may take until its answer has ended\n\t * (`ServeOptions.requestTimeoutMs`); none for the relay's session, whose\n\t * relay has its own. A `subscriptions/listen` stream is not limited.\n\t */\n\ttimeoutMs?: number;\n}): Tunnel {\n\tconst { handler, send, timeoutMs } = options;\n\tconst inflight = new Map<string, AbortController>();\n\tlet closed = false;\n\n\tasync function run(msg: HttpRequestMessage): Promise<void> {\n\t\tconst controller = new AbortController();\n\t\t// An id that is still in flight (a relay never sends one; another end\n\t\t// of a port may): the earlier request ends here, so that it does not\n\t\t// run on unheard, out of reach of `http.cancel`.\n\t\tinflight.get(msg.id)?.abort();\n\t\tinflight.set(msg.id, controller);\n\t\tconst live = () =>\n\t\t\t!closed &&\n\t\t\tinflight.get(msg.id) === controller &&\n\t\t\t!controller.signal.aborted;\n\t\t/**\n\t\t * Whether an event stream has started, for the time limit's error (a\n\t\t * body in pieces goes out in one task, which no timer interrupts).\n\t\t */\n\t\tlet started = false;\n\t\t/** The last two characters of that stream: empty or a blank line is between two events. */\n\t\tlet tail = \"\";\n\t\t// Header names in any case, as the handler reads them (review of PR 129).\n\t\tconst listen = Object.entries(msg.headers).some(\n\t\t\t([name, value]) =>\n\t\t\t\tname.toLowerCase() === \"mcp-method\" && value === \"subscriptions/listen\",\n\t\t);\n\t\tconst timer =\n\t\t\ttimeoutMs === undefined || listen\n\t\t\t\t? undefined\n\t\t\t\t: setTimeout(() => {\n\t\t\t\t\t\tif (!live()) return;\n\t\t\t\t\t\t// The call ends as cancelled; whatever it answers later is dropped.\n\t\t\t\t\t\tcontroller.abort();\n\t\t\t\t\t\tconst error = JSON.stringify({\n\t\t\t\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\t\t\t\tid: rpcId(msg.body),\n\t\t\t\t\t\t\terror: { code: TIMEOUT, message: TIMED_OUT },\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (!started) {\n\t\t\t\t\t\t\tsend({\n\t\t\t\t\t\t\t\ttype: \"http.response\",\n\t\t\t\t\t\t\t\tid: msg.id,\n\t\t\t\t\t\t\t\tstatus: 200,\n\t\t\t\t\t\t\t\theaders: { \"content-type\": \"application/json\" },\n\t\t\t\t\t\t\t\tbody: error,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// As `createTunnelFetch` does: the error as the stream's last\n\t\t\t\t\t\t// event where it stands between two events. The handler\n\t\t\t\t\t\t// (mcp.ts) enqueues whole events and each read's text goes out\n\t\t\t\t\t\t// in one task, so the timer always finds the stream between\n\t\t\t\t\t\t// two events; the check only guards against sending an event\n\t\t\t\t\t\t// into the middle of another (review of PR 129).\n\t\t\t\t\t\tif (tail === \"\" || tail === \"\\n\\n\")\n\t\t\t\t\t\t\tsend({\n\t\t\t\t\t\t\t\ttype: \"http.response.chunk\",\n\t\t\t\t\t\t\t\tid: msg.id,\n\t\t\t\t\t\t\t\tdata: `event: message\\ndata: ${error}\\n\\n`,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\tsend({ type: \"http.response.end\", id: msg.id });\n\t\t\t\t\t}, timeoutMs);\n\t\ttry {\n\t\t\tconst request = new Request(`https://tab.invalid${msg.path}`, {\n\t\t\t\tmethod: msg.method,\n\t\t\t\theaders: msg.headers,\n\t\t\t\tsignal: controller.signal,\n\t\t\t});\n\t\t\tconst response = await handler.handle(request, {\n\t\t\t\tgrant: msg.grant,\n\t\t\t\tbody: msg.body,\n\t\t\t});\n\t\t\tif (!live()) {\n\t\t\t\tawait response.body?.cancel().catch(() => {});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst headers: Record<string, string> = {};\n\t\t\tfor (const name of RESPONSE_HEADERS) {\n\t\t\t\tconst value = response.headers.get(name);\n\t\t\t\tif (value !== null) headers[name] = value;\n\t\t\t}\n\t\t\tconst streamed = (headers[\"content-type\"] ?? \"\").startsWith(\n\t\t\t\t\"text/event-stream\",\n\t\t\t);\n\t\t\tconst maxChunk = options.maxChunk();\n\t\t\tif (!streamed || response.body === null) {\n\t\t\t\tconst body = await response.text();\n\t\t\t\tif (!live()) return;\n\t\t\t\tif (body.length <= maxChunk) {\n\t\t\t\t\tsend({\n\t\t\t\t\t\ttype: \"http.response\",\n\t\t\t\t\t\tid: msg.id,\n\t\t\t\t\t\tstatus: response.status,\n\t\t\t\t\t\theaders,\n\t\t\t\t\t\tbody,\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Too big for one message: stream it (the relay passes it on whole).\n\t\t\t\tsend({\n\t\t\t\t\ttype: \"http.response.start\",\n\t\t\t\t\tid: msg.id,\n\t\t\t\t\tstatus: response.status,\n\t\t\t\t\theaders,\n\t\t\t\t});\n\t\t\t\tfor (const data of pieces(body, maxChunk)) {\n\t\t\t\t\tif (!live()) break;\n\t\t\t\t\tsend({ type: \"http.response.chunk\", id: msg.id, data });\n\t\t\t\t}\n\t\t\t\tif (live()) send({ type: \"http.response.end\", id: msg.id });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsend({\n\t\t\t\ttype: \"http.response.start\",\n\t\t\t\tid: msg.id,\n\t\t\t\tstatus: response.status,\n\t\t\t\theaders,\n\t\t\t});\n\t\t\tstarted = true;\n\t\t\tconst reader = response.body.getReader();\n\t\t\tconst decoder = new TextDecoder();\n\t\t\tcontroller.signal.addEventListener(\"abort\", () => {\n\t\t\t\treader.cancel().catch(() => {});\n\t\t\t});\n\t\t\tfor (;;) {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done || !live()) break;\n\t\t\t\tconst text = decoder.decode(value, { stream: true });\n\t\t\t\tif (text !== \"\") tail = (tail + text).slice(-2);\n\t\t\t\tfor (const data of pieces(text, maxChunk)) {\n\t\t\t\t\tsend({ type: \"http.response.chunk\", id: msg.id, data });\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (live()) send({ type: \"http.response.end\", id: msg.id });\n\t\t} catch (error) {\n\t\t\tif (live()) {\n\t\t\t\toptions.error(\n\t\t\t\t\terror instanceof Error ? error : new Error(String(error)),\n\t\t\t\t);\n\t\t\t\tsend({\n\t\t\t\t\ttype: \"http.response\",\n\t\t\t\t\tid: msg.id,\n\t\t\t\t\tstatus: 500,\n\t\t\t\t\theaders: { \"content-type\": \"application/json\" },\n\t\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\t\tjsonrpc: \"2.0\",\n\t\t\t\t\t\tid: null,\n\t\t\t\t\t\terror: { code: -32603, message: \"Internal server error\" },\n\t\t\t\t\t}),\n\t\t\t\t});\n\t\t\t}\n\t\t} finally {\n\t\t\tclearTimeout(timer);\n\t\t\tif (inflight.get(msg.id) === controller) inflight.delete(msg.id);\n\t\t}\n\t}\n\n\treturn {\n\t\trequest(message) {\n\t\t\tif (!closed) void run(message);\n\t\t},\n\t\tcancel(id) {\n\t\t\tinflight.get(id)?.abort();\n\t\t\tinflight.delete(id);\n\t\t},\n\t\tclose() {\n\t\t\tif (closed) return;\n\t\t\tclosed = true;\n\t\t\tfor (const controller of inflight.values()) controller.abort();\n\t\t\tinflight.clear();\n\t\t},\n\t};\n}\n\n/** What `serve` needs from the `TabMcp`. */\nexport interface ServeHost extends CallHost {\n\treadonly server: ServerInfo;\n\terror(error: Error): void;\n}\n\n/** The default and the smallest `ServeOptions.maxChunk`. */\nconst MAX_CHUNK = 64 * 1024;\nconst MIN_CHUNK = 64;\n/** The default `ServeOptions.requestTimeoutMs`, as `createTunnelFetch`'s and the relay's. */\nconst REQUEST_TIMEOUT_MS = 300_000;\n/** The longest request id, as between relay and tab. */\nconst MAX_ID = 128;\n\n/** The ports being served now. */\nconst served = new WeakSet<object>();\n\n/** One per `serve` call: the `n` of its grant id `local:<n>`. */\nlet lastPort = 0;\n\nconst str = (v: unknown): v is string => typeof v === \"string\";\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n\treturn typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\n/**\n * `TabMcp.serve`: answer the tunnel's messages on `port` until `close()` or\n * `options.signal`. Every request runs as `options.client` (`kind: \"local\"`),\n * whatever `grant` it carries: the other end cannot pose as an AI app of the\n * relay. Throws a `TypeError` for options it cannot use.\n */\nexport function servePort(\n\thost: ServeHost,\n\tport: TunnelPort,\n\toptions: ServeOptions,\n): ServeHandle {\n\tconst who = options?.client;\n\tif (\n\t\t!isObject(who) ||\n\t\t!str(who.id) ||\n\t\twho.id === \"\" ||\n\t\t(who.name !== undefined && !str(who.name))\n\t) {\n\t\tthrow new TypeError(\"serve: client needs an id (and may have a name)\");\n\t}\n\tconst maxChunk = options.maxChunk ?? MAX_CHUNK;\n\tif (!Number.isInteger(maxChunk) || maxChunk < MIN_CHUNK) {\n\t\tthrow new TypeError(\n\t\t\t`serve: maxChunk must be a whole number of at least ${MIN_CHUNK}`,\n\t\t);\n\t}\n\tconst timeoutMs = options.requestTimeoutMs ?? REQUEST_TIMEOUT_MS;\n\t// What `setTimeout` can keep: beyond it (and for Infinity) it fires at once.\n\tif (typeof timeoutMs !== \"number\" || !(timeoutMs > 0) || timeoutMs >= 2 ** 31)\n\t\tthrow new TypeError(\n\t\t\t\"serve: requestTimeoutMs must be milliseconds above 0 and below 2^31\",\n\t\t);\n\tconst ask = options.onConfirm;\n\tif (ask !== undefined && typeof ask !== \"function\")\n\t\tthrow new TypeError(\"serve: onConfirm must be a function\");\n\tif (\n\t\ttypeof port?.postMessage !== \"function\" ||\n\t\t!(\"onmessage\" in (port as object))\n\t) {\n\t\tthrow new TypeError(\"serve: the port needs postMessage and onmessage\");\n\t}\n\t// A second serve would take `onmessage` from the first, whose calls in\n\t// flight would then run on unheard and unanswered.\n\tif (served.has(port)) {\n\t\tthrow new DOMException(\n\t\t\t\"serve: this port is served already; close that first\",\n\t\t\t\"InvalidStateError\",\n\t\t);\n\t}\n\tconst client: LocalClient = { kind: \"local\", id: who.id };\n\tif (who.name !== undefined && who.name !== \"\") client.name = who.name;\n\tconst grant: GrantRef = {\n\t\tgrantId: `local:${++lastPort}`,\n\t\tclientId: who.id,\n\t\tscopes: [\"tools\"],\n\t};\n\tlet closed = false;\n\n\tconst send = (message: TabMessage): boolean => {\n\t\tif (closed) return false;\n\t\ttry {\n\t\t\tport.postMessage(message);\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t};\n\tconst context = callContext(host, \"local\");\n\t// This port's own question, in place of the page's (DEC-164). Normalised\n\t// as the page's: anything but `true` or \"unanswered\" is a refusal, and a\n\t// throw too (`runCall`).\n\tif (ask !== undefined) {\n\t\tcontext.confirm = (request) =>\n\t\t\tPromise.resolve()\n\t\t\t\t.then(() => ask(request))\n\t\t\t\t.then(\n\t\t\t\t\t(answer): ConfirmAnswer =>\n\t\t\t\t\t\tanswer === \"unanswered\" ? answer : answer === true,\n\t\t\t\t);\n\t\tcontext.ownConfirm = true;\n\t}\n\tconst handler = createMcpHandler({\n\t\t...context,\n\t\t// Without `icons`, the page's own <link rel=\"icon\">, read now.\n\t\tserver: { ...host.server, icons: host.server.icons ?? pageIcons() },\n\t\tclient: () => ({ ...client }),\n\t});\n\tconst stopWatching = watchTools(host.registry, context.tools, () =>\n\t\thandler.toolsChanged(),\n\t);\n\tconst tunnel = createTunnel({\n\t\thandler,\n\t\tsend,\n\t\tmaxChunk: () => maxChunk,\n\t\terror: (error) => host.error(error),\n\t\ttimeoutMs,\n\t});\n\n\tconst bad = (message: string, id?: unknown): void => {\n\t\tconst error: TabMessage = { type: \"error\", code: \"bad_message\", message };\n\t\tif (str(id) && id.length <= MAX_ID) error.id = id;\n\t\tsend(error);\n\t};\n\tconst onMessage = (event: { data: unknown }): void => {\n\t\tif (closed) return;\n\t\tconst m = event?.data;\n\t\tif (!isObject(m) || !str(m[\"type\"])) {\n\t\t\tbad(\"not a message\");\n\t\t\treturn;\n\t\t}\n\t\tconst id = m[\"id\"];\n\t\tswitch (m[\"type\"]) {\n\t\t\tcase \"http.request\": {\n\t\t\t\tconst { method, path, headers, body } = m;\n\t\t\t\tif (\n\t\t\t\t\t!str(id) ||\n\t\t\t\t\tid === \"\" ||\n\t\t\t\t\tid.length > MAX_ID ||\n\t\t\t\t\t!str(method) ||\n\t\t\t\t\t!str(path) ||\n\t\t\t\t\t!path.startsWith(\"/\") ||\n\t\t\t\t\t!isObject(headers) ||\n\t\t\t\t\t!Object.values(headers).every(str) ||\n\t\t\t\t\t!str(body)\n\t\t\t\t) {\n\t\t\t\t\tbad(\"malformed http.request\", id);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\ttunnel.request({\n\t\t\t\t\ttype: \"http.request\",\n\t\t\t\t\tid,\n\t\t\t\t\tmethod,\n\t\t\t\t\tpath,\n\t\t\t\t\theaders: headers as Record<string, string>,\n\t\t\t\t\tbody,\n\t\t\t\t\tgrant, // never the one in the message\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tcase \"http.cancel\":\n\t\t\t\tif (str(id)) tunnel.cancel(id);\n\t\t\t\telse bad(\"malformed http.cancel\");\n\t\t\t\treturn;\n\t\t\tcase \"error\":\n\t\t\t\treturn; // never answered, so that two ends cannot answer each other for ever\n\t\t\tdefault:\n\t\t\t\tbad(`unexpected ${m[\"type\"].slice(0, 64)}`, id);\n\t\t}\n\t};\n\n\t// A `MessagePort` fires `close` when its other end is gone (closed, or its\n\t// frame unloaded), where the browser has the event: the calls, listen\n\t// streams and an open confirmation end then too, not only on `close()`.\n\tconst events = port as Partial<\n\t\tPick<EventTarget, \"addEventListener\" | \"removeEventListener\">\n\t>;\n\tconst close = (): void => {\n\t\tif (closed) return;\n\t\toptions.signal?.removeEventListener(\"abort\", close);\n\t\tevents.removeEventListener?.(\"close\", close);\n\t\tstopWatching();\n\t\ttunnel.close();\n\t\thandler.close();\n\t\t// The other end is told, so that its requests end now and not with\n\t\t// their timeout; a port that was never served hears nothing.\n\t\tif (served.delete(port)) send({ type: \"bye\", reason: \"closed\" });\n\t\tclosed = true;\n\t\tif (port.onmessage === onMessage) port.onmessage = null;\n\t};\n\tif (options.signal?.aborted === true) {\n\t\tclose();\n\t\treturn { close };\n\t}\n\toptions.signal?.addEventListener(\"abort\", close);\n\tevents.addEventListener?.(\"close\", close);\n\tserved.add(port);\n\tport.onmessage = onMessage; // starts a MessagePort\n\treturn { close };\n}\n",
|
|
16
|
-
"/**\n *
|
|
17
|
-
"/**\n * The lazily loaded part (DEC-035): the WebSocket session with the relay, the\n * HTTP tunnel and the MCP handler. Loaded by `TabMcp.connect()`.\n */\n\nimport { pageIcons } from \"./icons.ts\";\nimport type { CallHost, ConnectionHandle, ConnectionHost } from \"./internal.ts\";\nimport { createMcpHandler, webMcpCall } from \"./mcp.ts\";\nimport {\n\tparseRelayMessage,\n\ttype RelayMessage,\n\tSUBPROTOCOL,\n\ttype TabMessage,\n} from \"./protocol.ts\";\nimport type { RegisteredTool } from \"./registry.ts\";\nimport { callContext, createTunnel, watchTools } from \"./serve.ts\";\nimport type { DisconnectReason, SessionInfo } from \"./types.ts\";\n\n/** For the core: the address id in the `/tab` URL (DEC-098). */\nexport { addressIdOf, withAddress } from \"./address.ts\";\n/** For the core: compiles the schemas once this chunk (and the validator) is loaded. */\nexport { compileRegistry } from \"./mcp.ts\";\n/** For the core: `TabMcp.serve`, the tunnel over a port (iteration 28). */\nexport { pieces, servePort } from \"./serve.ts\";\n\n/**\n * For the core: a WebMCP call of a mirrored tool (iteration 25), on the\n * same path as an AI app's (`webMcpCall` in `mcp.ts`).\n */\nexport function callFromWebMcp(\n\thost: CallHost,\n\ttool: RegisteredTool,\n\tinput: unknown,\n\tsignal: unknown,\n): Promise<unknown> {\n\treturn webMcpCall(callContext(host, \"webmcp\"), tool, input, signal);\n}\n\n/** How long `connect()` waits for the relay's `session`. */\nconst CONNECT_TIMEOUT_MS = 15_000;\n\nconst CLOSE_REASONS: Record<number, DisconnectReason> = {\n\t1000: \"closed\",\n\t/**\n\t * Going away, internal error, service restart, try again later: what a\n\t * proxy or platform in front of the relay sends when the relay behind it\n\t * restarts without its own `bye`. Reconnecting may help.\n\t */\n\t1001: \"shutdown\",\n\t1008: \"policy\",\n\t1009: \"too_large\",\n\t1011: \"shutdown\",\n\t1012: \"shutdown\",\n\t1013: \"shutdown\",\n\t4001: \"expired\",\n\t4002: \"idle\",\n\t4003: \"heartbeat\",\n\t4004: \"shutdown\",\n\t4005: \"replaced\",\n\t4008: \"rate_limited\",\n\t/** The URL's address id is not the secret's (DEC-098): retrying cannot help. */\n\t4009: \"policy\",\n};\n\nconst BYE_REASONS: Record<string, DisconnectReason> = {\n\treplaced: \"replaced\",\n\texpired: \"expired\",\n\tidle: \"idle\",\n\tshutdown: \"shutdown\",\n};\n\n/**\n * An error of `ready` that says why the connection did not open, so that\n * reconnecting retries only what may get better (DEC-082).\n */\nfunction refused(message: string, reason: DisconnectReason): Error {\n\treturn Object.assign(new Error(message), { reason });\n}\n\n/**\n * Room for a message's envelope (`http.response` with its headers, or a\n * chunk) with an id of up to 128 characters (protocol limit).\n */\nconst ENVELOPE_BYTES = 512;\n/** Worst case per UTF-16 unit once JSON-encoded as UTF-8: `\\u0001` is 6 bytes. */\nconst WORST_BYTES_PER_UNIT = 6;\nconst MIN_CHUNK_UNITS = 64;\nexport const MIN_MESSAGE_BYTES: number =\n\tENVELOPE_BYTES + WORST_BYTES_PER_UNIT * MIN_CHUNK_UNITS;\n\n/**\n * The largest piece of body text (UTF-16 units) whose message cannot exceed\n * the relay's `maxMessageBytes`; `undefined` if the limit is too small to\n * frame anything useful.\n */\nexport function chunkSize(maxMessageBytes: number): number | undefined {\n\tconst units = Math.floor(\n\t\t(maxMessageBytes - ENVELOPE_BYTES) / WORST_BYTES_PER_UNIT,\n\t);\n\treturn units >= MIN_CHUNK_UNITS ? units : undefined;\n}\n\n/**\n * How long after a sibling tab's `claimed` a `replaced` counts as caused by\n * it (DEC-095). That tab posts it when the relay accepted its session, which\n * is when the relay ended this one.\n */\nexport const SIBLING_WINDOW_MS = 10_000;\n\n/**\n * How long a replaced tab that heard no `claimed` yet waits for one before it\n * reports `replaced`: the sibling's session and this tab's `bye` leave the\n * relay at about the same time, so the message usually comes after the `bye`.\n */\nexport const SIBLING_GRACE_MS = 1_000;\n\n/**\n * The tabs of one page (same relay, same storage key) tell each other on a\n * `BroadcastChannel` when the relay accepted their claim of an address\n * (`claimed`, once their `session` arrived), so that a replaced tab can tell\n * a sibling from an impostor. A sibling whose `hello` failed says nothing.\n * The message carries the address id (as in the `/tab` URL; no secret), and\n * only a claim of this tab's own address, heard after this tab's own\n * `session`, counts: one heard while this tab was still connecting, or from\n * a tab on another address (after `newAddress()` there), cannot have caused\n * the replacement (CC 5). A claim without an address, from a tab still on a\n * library up to 0.15, counts as before. Without `BroadcastChannel` nothing is heard, and\n * every `replaced` counts as unknown.\n */\nfunction siblingTabs(\n\tname: string | undefined,\n\taddress: string | undefined,\n): {\n\t/** The own session arrived: say so, and listen to the others from now on. */\n\tclaimed(): void;\n\t/** `true` once `claimed` was heard in the window, `false` after the grace. */\n\theard(): Promise<boolean>;\n\tclose(): void;\n} {\n\tlet channel: BroadcastChannel | undefined;\n\tlet listening = false;\n\tlet at = Number.NEGATIVE_INFINITY;\n\tlet onClaim: (() => void) | undefined;\n\ttry {\n\t\tif (name !== undefined && typeof BroadcastChannel === \"function\") {\n\t\t\tchannel = new BroadcastChannel(name);\n\t\t\tchannel.onmessage = (event: MessageEvent) => {\n\t\t\t\tconst data = event.data as { type?: unknown; address?: unknown } | null;\n\t\t\t\t// No address: a tab with a library up to 0.15, while both run.\n\t\t\t\tif (\n\t\t\t\t\t!listening ||\n\t\t\t\t\tdata?.type !== \"claimed\" ||\n\t\t\t\t\t(data.address !== undefined && data.address !== address)\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tat = Date.now();\n\t\t\t\tonClaim?.();\n\t\t\t};\n\t\t}\n\t} catch {\n\t\tchannel = undefined; // e.g. an opaque origin\n\t}\n\treturn {\n\t\tclaimed() {\n\t\t\tlistening = true;\n\t\t\ttry {\n\t\t\t\tchannel?.postMessage({ type: \"claimed\", address });\n\t\t\t} catch {\n\t\t\t\t// closed or not allowed: the other tab counts it as unknown\n\t\t\t}\n\t\t},\n\t\theard() {\n\t\t\tif (Date.now() - at <= SIBLING_WINDOW_MS) return Promise.resolve(true);\n\t\t\tif (channel === undefined) return Promise.resolve(false);\n\t\t\treturn new Promise((resolve) => {\n\t\t\t\tconst timer = setTimeout(() => resolve(false), SIBLING_GRACE_MS);\n\t\t\t\tonClaim = () => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tresolve(true);\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\tclose() {\n\t\t\tchannel?.close();\n\t\t},\n\t};\n}\n\n/**\n * Open the WebSocket and run the session. `address`: the secret's address id\n * (`addressIdOf`). `revokeAll`: take the address back (DEC-095); the relay\n * revokes every grant as it claims the address, and its `session` lists none.\n */\nexport function openConnection(\n\thost: ConnectionHost,\n\turl: string,\n\tsecret: string,\n\toptions: { address?: string | undefined; revokeAll?: boolean } = {},\n): ConnectionHandle {\n\tconst revokeAll = options.revokeAll === true;\n\tconst ws = new WebSocket(url, SUBPROTOCOL);\n\tlet state: \"opening\" | \"ready\" | \"closed\" = \"opening\";\n\tlet byeReason: DisconnectReason | undefined;\n\tlet maxChunk = 64 * 1024;\n\t/** The relay's limit on a response body (CC 7); known once `session` came. */\n\tlet maxBodyBytes: number | undefined;\n\tlet heartbeat: ReturnType<typeof setTimeout> | undefined;\n\tlet heartbeatMs = 0;\n\tconst siblings = siblingTabs(host.tabs, options.address);\n\n\tlet resolveReady!: (session: SessionInfo) => void;\n\tlet rejectReady!: (error: Error) => void;\n\tconst ready = new Promise<SessionInfo>((resolve, reject) => {\n\t\tresolveReady = resolve;\n\t\trejectReady = reject;\n\t});\n\tready.catch(() => {}); // the caller handles it; never an unhandled rejection here\n\tconst connectTimer = setTimeout(() => {\n\t\tfail(refused(\"The relay did not answer in time.\", \"network\"));\n\t}, CONNECT_TIMEOUT_MS);\n\n\tconst context = callContext(host, \"relay\");\n\tconst handler = createMcpHandler({\n\t\t...context,\n\t\t// Without `icons`, the page's own <link rel=\"icon\">, read now.\n\t\tserver: { ...host.server, icons: host.server.icons ?? pageIcons() },\n\t\tclient: (grant) => host.clientFor(grant),\n\t\tmaxBodyBytes: () => maxBodyBytes,\n\t});\n\tconst stopWatching = watchTools(host.registry, context.tools, () =>\n\t\thandler.toolsChanged(),\n\t);\n\n\tfunction send(message: TabMessage): boolean {\n\t\tif (ws.readyState !== WebSocket.OPEN) return false;\n\t\ttry {\n\t\t\tws.send(JSON.stringify(message));\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Two missed pings mean the connection is dead (protocol: heartbeat). */\n\tfunction armHeartbeat(): void {\n\t\tif (heartbeatMs <= 0) return;\n\t\tclearTimeout(heartbeat);\n\t\theartbeat = setTimeout(() => {\n\t\t\tbyeReason ??= \"heartbeat\";\n\t\t\tfinish(4003);\n\t\t\ttry {\n\t\t\t\tws.close();\n\t\t\t} catch {\n\t\t\t\t// already closing\n\t\t\t}\n\t\t}, heartbeatMs * 2.5);\n\t}\n\n\tfunction fail(error: Error): void {\n\t\tif (state !== \"opening\") return;\n\t\tfinish(0);\n\t\trejectReady(error);\n\t\ttry {\n\t\t\tws.close();\n\t\t} catch {\n\t\t\t// already closed\n\t\t}\n\t}\n\n\t/** The session is over: clean up once and tell the host. */\n\tfunction finish(code: number): void {\n\t\tif (state === \"closed\") return;\n\t\tconst wasReady = state === \"ready\";\n\t\tstate = \"closed\";\n\t\tclearTimeout(connectTimer);\n\t\tclearTimeout(heartbeat);\n\t\tstopWatching();\n\t\ttunnel.close();\n\t\thandler.close();\n\t\tif (wasReady) {\n\t\t\tconst reason =\n\t\t\t\tbyeReason ??\n\t\t\t\tCLOSE_REASONS[code] ??\n\t\t\t\t(code === 1006 ? \"network\" : \"closed\");\n\t\t\t// Over at once; only the detail of `replaced` waits for a sibling's\n\t\t\t// `claimed`, which comes a moment after the `bye` (DEC-095).\n\t\t\thost.closed(reason, code);\n\t\t\tif (reason === \"replaced\") {\n\t\t\t\tvoid siblings.heard().then((sibling) => {\n\t\t\t\t\tsiblings.close();\n\t\t\t\t\thost.replaced({ sibling });\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tsiblings.close();\n\t}\n\n\tconst tunnel = createTunnel({\n\t\thandler,\n\t\tsend,\n\t\tmaxChunk: () => maxChunk,\n\t\terror: (error) => host.error(error),\n\t});\n\n\tfunction onMessage(message: RelayMessage): void {\n\t\tif (state === \"opening\") {\n\t\t\tif (message.type === \"session\") {\n\t\t\t\tconst chunk = chunkSize(message.limits.maxMessageBytes);\n\t\t\t\tif (chunk === undefined) {\n\t\t\t\t\tfail(\n\t\t\t\t\t\trefused(\n\t\t\t\t\t\t\t`The relay's message limit (${message.limits.maxMessageBytes} bytes) is too small; tab-mcp needs at least ${MIN_MESSAGE_BYTES}.`,\n\t\t\t\t\t\t\t\"policy\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (revokeAll && message.grants.length > 0) {\n\t\t\t\t\t// A relay older than 0.5 ignores hello.revokeAll and lists the\n\t\t\t\t\t// grants: the address was not taken back (DEC-136).\n\t\t\t\t\tfail(\n\t\t\t\t\t\trefused(\n\t\t\t\t\t\t\t\"The relay did not revoke the address's grants (it needs tab-mcp 0.5 or later).\",\n\t\t\t\t\t\t\t\"policy\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tmaxChunk = chunk;\n\t\t\t\tmaxBodyBytes = message.limits.maxBodyBytes;\n\t\t\t\tstate = \"ready\";\n\t\t\t\tclearTimeout(connectTimer);\n\t\t\t\theartbeatMs = message.limits.heartbeatMs;\n\t\t\t\tarmHeartbeat();\n\t\t\t\tsiblings.claimed();\n\t\t\t\tresolveReady(host.sessionStarted(message));\n\t\t\t} else if (message.type === \"error\") {\n\t\t\t\tfail(\n\t\t\t\t\trefused(\n\t\t\t\t\t\t`The relay refused the connection: ${message.message || message.code}`,\n\t\t\t\t\t\tmessage.code === \"rate_limited\" ? \"rate_limited\" : \"policy\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else if (message.type === \"bye\") {\n\t\t\t\tfail(\n\t\t\t\t\trefused(\n\t\t\t\t\t\t`The relay ended the connection: ${message.reason}`,\n\t\t\t\t\t\tBYE_REASONS[message.reason] ?? \"closed\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (state !== \"ready\") return;\n\t\tswitch (message.type) {\n\t\t\tcase \"ping\":\n\t\t\t\tarmHeartbeat();\n\t\t\t\tsend({ type: \"pong\", t: message.t });\n\t\t\t\treturn;\n\t\t\tcase \"http.request\":\n\t\t\t\ttunnel.request(message);\n\t\t\t\treturn;\n\t\t\tcase \"http.cancel\":\n\t\t\t\ttunnel.cancel(message.id);\n\t\t\t\treturn;\n\t\t\tcase \"pairing.code\":\n\t\t\t\thost.pairingCode(\n\t\t\t\t\tmessage.reason === undefined\n\t\t\t\t\t\t? { code: message.code, expiresAt: message.expiresAt }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tcode: message.code,\n\t\t\t\t\t\t\t\texpiresAt: message.expiresAt,\n\t\t\t\t\t\t\t\treason: message.reason,\n\t\t\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\tcase \"grant.added\":\n\t\t\t\thost.grantAdded(message.grant);\n\t\t\t\treturn;\n\t\t\tcase \"grant.removed\":\n\t\t\t\thost.grantRemoved(message.grantId);\n\t\t\t\treturn;\n\t\t\tcase \"identity.bound\":\n\t\t\t\thost.identityResult(true, message.round);\n\t\t\t\treturn;\n\t\t\tcase \"bye\":\n\t\t\t\tbyeReason = BYE_REASONS[message.reason] ?? \"closed\";\n\t\t\t\t// Taken over: over at once, not when the socket closes (review of PR 39).\n\t\t\t\tif (byeReason === \"replaced\") finish(4005);\n\t\t\t\treturn;\n\t\t\tcase \"error\":\n\t\t\t\tif (message.code === \"identity_refused\") {\n\t\t\t\t\thost.identityResult(\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\ttypeof message.round === \"number\" ? message.round : undefined,\n\t\t\t\t\t\tmessage.message,\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// The relay does not know a grant the page lists: it is gone (it\n\t\t\t\t// expired), and a `revoke()` of it resolves (DEC-168).\n\t\t\t\tif (\n\t\t\t\t\tmessage.code === \"unknown_id\" &&\n\t\t\t\t\tmessage.for === \"grant.revoke\" &&\n\t\t\t\t\ttypeof message.grantId === \"string\"\n\t\t\t\t)\n\t\t\t\t\thost.grantRemoved(message.grantId);\n\t\t\t\t// With its `code`, and what it answers (relay 0.10.2), so that\n\t\t\t\t// only the pending `revoke()` or `signOut()` it answers settles\n\t\t\t\t// (`store_unavailable`, `unknown_id`).\n\t\t\t\thost.error(\n\t\t\t\t\tObject.assign(\n\t\t\t\t\t\tnew Error(`Relay error ${message.code}: ${message.message}`),\n\t\t\t\t\t\t{ code: message.code },\n\t\t\t\t\t\ttypeof message.for === \"string\" ? { for: message.for } : {},\n\t\t\t\t\t\ttypeof message.grantId === \"string\"\n\t\t\t\t\t\t\t? { grantId: message.grantId }\n\t\t\t\t\t\t\t: {},\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\tcase \"session\":\n\t\t\t\treturn; // only once\n\t\t}\n\t}\n\n\tws.addEventListener(\"open\", () => {\n\t\tif (ws.protocol !== \"\" && ws.protocol !== SUBPROTOCOL) {\n\t\t\tfail(\n\t\t\t\trefused(\n\t\t\t\t\t`The relay speaks ${ws.protocol}, not ${SUBPROTOCOL}.`,\n\t\t\t\t\t\"policy\",\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tconst hello: TabMessage = {\n\t\t\ttype: \"hello\",\n\t\t\tlibrary: host.library,\n\t\t\t// The relay never read the title (CC 6); relays up to 0.9 still\n\t\t\t// require the field.\n\t\t\tpage: { title: \"\" },\n\t\t\tsecret,\n\t\t};\n\t\tif (host.appName !== undefined) hello.app = { name: host.appName };\n\t\tif (revokeAll) hello.revokeAll = true;\n\t\tsend(hello);\n\t});\n\tws.addEventListener(\"message\", (event: MessageEvent) => {\n\t\tif (typeof event.data !== \"string\") return;\n\t\t// A frame the tab cannot read is dropped without an answer (CC 15): the\n\t\t// relay only logged one, and its request ends at its own timeout.\n\t\tconst message = parseRelayMessage(event.data);\n\t\tif (message === undefined) return;\n\t\tif (state === \"ready\") armHeartbeat(); // any traffic shows the link is alive\n\t\tonMessage(message);\n\t});\n\tws.addEventListener(\"close\", (event: CloseEvent) => {\n\t\tif (state === \"opening\") {\n\t\t\tfinish(event.code);\n\t\t\t// No WebSocket at all: browsers say 1006, Bun 1002. The page cannot\n\t\t\t// tell a refused origin from an unreachable relay (DEC-082).\n\t\t\tconst unreachable = event.code === 1006 || event.code === 1002;\n\t\t\trejectReady(\n\t\t\t\trefused(\n\t\t\t\t\tunreachable\n\t\t\t\t\t\t? \"Could not connect to the relay (refused, unreachable, or this page's origin is not allowed).\"\n\t\t\t\t\t\t: `The relay closed the connection (${event.code}${event.reason ? `: ${event.reason}` : \"\"}).`,\n\t\t\t\t\tCLOSE_REASONS[event.code] ?? (unreachable ? \"network\" : \"closed\"),\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tfinish(event.code);\n\t});\n\n\treturn {\n\t\tready,\n\t\tsend,\n\t\tclose(reason: DisconnectReason) {\n\t\t\tif (state === \"closed\") return;\n\t\t\tif (state === \"opening\") {\n\t\t\t\tfail(\n\t\t\t\t\tnew DOMException(\n\t\t\t\t\t\t\"The connection was cancelled\",\n\t\t\t\t\t\t\"AbortError\",\n\t\t\t\t\t) as Error,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbyeReason = reason;\n\t\t\tsend({ type: \"bye\", reason: \"user\" });\n\t\t\tfinish(1000);\n\t\t\ttry {\n\t\t\t\tws.close(1000, \"bye\");\n\t\t\t} catch {\n\t\t\t\t// already closed\n\t\t\t}\n\t\t},\n\t};\n}\n"
|
|
16
|
+
"/**\n * A hash of the page's secret: what the tabs of one page tell each other by\n * when one of them takes over (DEC-095), in place of the secret. It is not the\n * relay's address id, which is of the app and the secret (DEC-196), and never\n * part of a URL. Part of the lazily loaded chunk\n * (DEC-035), not the core.\n */\n\nconst BASE32 = \"abcdefghijklmnopqrstuvwxyz234567\";\n\n/** RFC 4648 base32, lower case, without padding (the relay's address ids). */\nfunction base32(bytes: Uint8Array): string {\n\tlet out = \"\";\n\tlet buffer = 0;\n\tlet bits = 0;\n\tfor (const byte of bytes) {\n\t\tbuffer = (buffer << 8) | byte;\n\t\tbits += 8;\n\t\twhile (bits >= 5) {\n\t\t\tbits -= 5;\n\t\t\tout += BASE32[(buffer >>> bits) & 31];\n\t\t}\n\t\tbuffer &= (1 << bits) - 1;\n\t}\n\tif (bits > 0) out += BASE32[(buffer << (5 - bits)) & 31];\n\treturn out;\n}\n\n/**\n * The hash of a secret that the tabs of a page name it by:\n * base32(sha256(secret)). `undefined` where Web Crypto is missing (`null`: a\n * page on plain http other than localhost) or fails; a replaced tab then\n * cannot tell a sibling tab from an impostor.\n */\nexport async function addressIdOf(\n\tsecret: string,\n\tsubtle: SubtleCrypto | null = globalThis.crypto?.subtle ?? null,\n): Promise<string | undefined> {\n\tif (subtle === null) return undefined;\n\ttry {\n\t\tconst digest = await subtle.digest(\n\t\t\t\"SHA-256\",\n\t\t\tnew TextEncoder().encode(secret),\n\t\t);\n\t\treturn base32(new Uint8Array(digest));\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n",
|
|
17
|
+
"/**\n * The lazily loaded part (DEC-035): the WebSocket session with the relay, the\n * HTTP tunnel and the MCP handler. Loaded by `TabMcp.connect()`.\n */\n\nimport { pageIcons } from \"./icons.ts\";\nimport type { CallHost, ConnectionHandle, ConnectionHost } from \"./internal.ts\";\nimport { createMcpHandler, webMcpCall } from \"./mcp.ts\";\nimport {\n\tparseRelayMessage,\n\ttype RelayMessage,\n\tSUBPROTOCOL,\n\ttype TabMessage,\n} from \"./protocol.ts\";\nimport type { RegisteredTool } from \"./registry.ts\";\nimport { callContext, createTunnel, watchTools } from \"./serve.ts\";\nimport type { DisconnectReason, SessionInfo } from \"./types.ts\";\n\n/** For the core: the address id the page's tabs tell each other by (DEC-095). */\nexport { addressIdOf } from \"./address.ts\";\n/** For the core: compiles the schemas once this chunk (and the validator) is loaded. */\nexport { compileRegistry } from \"./mcp.ts\";\n/** For the core: `TabMcp.serve`, the tunnel over a port (iteration 28). */\nexport { pieces, servePort } from \"./serve.ts\";\n\n/**\n * For the core: a WebMCP call of a mirrored tool (iteration 25), on the\n * same path as an AI app's (`webMcpCall` in `mcp.ts`).\n */\nexport function callFromWebMcp(\n\thost: CallHost,\n\ttool: RegisteredTool,\n\tinput: unknown,\n\tsignal: unknown,\n): Promise<unknown> {\n\treturn webMcpCall(callContext(host, \"webmcp\"), tool, input, signal);\n}\n\n/** How long `connect()` waits for the relay's `session`. */\nconst CONNECT_TIMEOUT_MS = 15_000;\n\nconst CLOSE_REASONS: Record<number, DisconnectReason> = {\n\t1000: \"closed\",\n\t/**\n\t * Going away, internal error, service restart, try again later: what a\n\t * proxy or platform in front of the relay sends when the relay behind it\n\t * restarts without its own `bye`. Reconnecting may help.\n\t */\n\t1001: \"shutdown\",\n\t1008: \"policy\",\n\t1009: \"too_large\",\n\t1011: \"shutdown\",\n\t1012: \"shutdown\",\n\t1013: \"shutdown\",\n\t4001: \"expired\",\n\t4002: \"idle\",\n\t4003: \"heartbeat\",\n\t4004: \"shutdown\",\n\t4005: \"replaced\",\n\t4008: \"rate_limited\",\n};\n\nconst BYE_REASONS: Record<string, DisconnectReason> = {\n\treplaced: \"replaced\",\n\texpired: \"expired\",\n\tidle: \"idle\",\n\tshutdown: \"shutdown\",\n};\n\n/**\n * An error of `ready` that says why the connection did not open, so that\n * reconnecting retries only what may get better (DEC-082).\n */\nfunction refused(message: string, reason: DisconnectReason): Error {\n\treturn Object.assign(new Error(message), { reason });\n}\n\n/**\n * Room for a message's envelope (`http.response` with its headers, or a\n * chunk) with an id of up to 128 characters (protocol limit).\n */\nconst ENVELOPE_BYTES = 512;\n/** Worst case per UTF-16 unit once JSON-encoded as UTF-8: `\\u0001` is 6 bytes. */\nconst WORST_BYTES_PER_UNIT = 6;\nconst MIN_CHUNK_UNITS = 64;\nexport const MIN_MESSAGE_BYTES: number =\n\tENVELOPE_BYTES + WORST_BYTES_PER_UNIT * MIN_CHUNK_UNITS;\n\n/**\n * The largest piece of body text (UTF-16 units) whose message cannot exceed\n * the relay's `maxMessageBytes`; `undefined` if the limit is too small to\n * frame anything useful.\n */\nexport function chunkSize(maxMessageBytes: number): number | undefined {\n\tconst units = Math.floor(\n\t\t(maxMessageBytes - ENVELOPE_BYTES) / WORST_BYTES_PER_UNIT,\n\t);\n\treturn units >= MIN_CHUNK_UNITS ? units : undefined;\n}\n\n/**\n * How long after a sibling tab's `claimed` a `replaced` counts as caused by\n * it (DEC-095). That tab posts it when the relay accepted its session, which\n * is when the relay ended this one.\n */\nexport const SIBLING_WINDOW_MS = 10_000;\n\n/**\n * How long a replaced tab that heard no `claimed` yet waits for one before it\n * reports `replaced`: the sibling's session and this tab's `bye` leave the\n * relay at about the same time, so the message usually comes after the `bye`.\n */\nexport const SIBLING_GRACE_MS = 1_000;\n\n/**\n * The tabs of one page (same relay, same storage key) tell each other on a\n * `BroadcastChannel` when the relay accepted their claim of an address\n * (`claimed`, once their `session` arrived), so that a replaced tab can tell\n * a sibling from an impostor. A sibling whose `hello` failed says nothing.\n * The message carries the address id of the secret (`addressIdOf`; never the\n * secret), and\n * only a claim of this tab's own address, heard after this tab's own\n * `session`, counts: one heard while this tab was still connecting, or from\n * a tab on another address (after `newAddress()` there), cannot have caused\n * the replacement (CC 5). A claim without an address counts for any. Without\n * `BroadcastChannel` nothing is heard, and every `replaced` counts as unknown.\n */\nfunction siblingTabs(\n\tname: string | undefined,\n\taddress: string | undefined,\n): {\n\t/** The own session arrived: say so, and listen to the others from now on. */\n\tclaimed(): void;\n\t/** `true` once `claimed` was heard in the window, `false` after the grace. */\n\theard(): Promise<boolean>;\n\tclose(): void;\n} {\n\tlet channel: BroadcastChannel | undefined;\n\tlet listening = false;\n\tlet at = Number.NEGATIVE_INFINITY;\n\tlet onClaim: (() => void) | undefined;\n\ttry {\n\t\tif (name !== undefined && typeof BroadcastChannel === \"function\") {\n\t\t\tchannel = new BroadcastChannel(name);\n\t\t\tchannel.onmessage = (event: MessageEvent) => {\n\t\t\t\tconst data = event.data as { type?: unknown; address?: unknown } | null;\n\t\t\t\t// No address: a tab with a library up to 0.15, while both run.\n\t\t\t\tif (\n\t\t\t\t\t!listening ||\n\t\t\t\t\tdata?.type !== \"claimed\" ||\n\t\t\t\t\t(data.address !== undefined && data.address !== address)\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tat = Date.now();\n\t\t\t\tonClaim?.();\n\t\t\t};\n\t\t}\n\t} catch {\n\t\tchannel = undefined; // e.g. an opaque origin\n\t}\n\treturn {\n\t\tclaimed() {\n\t\t\tlistening = true;\n\t\t\ttry {\n\t\t\t\tchannel?.postMessage({ type: \"claimed\", address });\n\t\t\t} catch {\n\t\t\t\t// closed or not allowed: the other tab counts it as unknown\n\t\t\t}\n\t\t},\n\t\theard() {\n\t\t\tif (Date.now() - at <= SIBLING_WINDOW_MS) return Promise.resolve(true);\n\t\t\tif (channel === undefined) return Promise.resolve(false);\n\t\t\treturn new Promise((resolve) => {\n\t\t\t\tconst timer = setTimeout(() => resolve(false), SIBLING_GRACE_MS);\n\t\t\t\tonClaim = () => {\n\t\t\t\t\tclearTimeout(timer);\n\t\t\t\t\tresolve(true);\n\t\t\t\t};\n\t\t\t});\n\t\t},\n\t\tclose() {\n\t\t\tchannel?.close();\n\t\t},\n\t};\n}\n\n/**\n * Open the WebSocket and run the session. `address`: the secret's address id\n * (`addressIdOf`). `revokeAll`: take the address back (DEC-095); the relay\n * revokes every grant as it claims the address, and its `session` lists none.\n */\nexport function openConnection(\n\thost: ConnectionHost,\n\turl: string,\n\tsecret: string,\n\toptions: { address?: string | undefined; revokeAll?: boolean } = {},\n): ConnectionHandle {\n\tconst revokeAll = options.revokeAll === true;\n\tconst ws = new WebSocket(url, SUBPROTOCOL);\n\tlet state: \"opening\" | \"ready\" | \"closed\" = \"opening\";\n\tlet byeReason: DisconnectReason | undefined;\n\tlet maxChunk = 64 * 1024;\n\t/** The relay's limit on a response body (CC 7); known once `session` came. */\n\tlet maxBodyBytes: number | undefined;\n\tlet heartbeat: ReturnType<typeof setTimeout> | undefined;\n\tlet heartbeatMs = 0;\n\tconst siblings = siblingTabs(host.tabs, options.address);\n\n\tlet resolveReady!: (session: SessionInfo) => void;\n\tlet rejectReady!: (error: Error) => void;\n\tconst ready = new Promise<SessionInfo>((resolve, reject) => {\n\t\tresolveReady = resolve;\n\t\trejectReady = reject;\n\t});\n\tready.catch(() => {}); // the caller handles it; never an unhandled rejection here\n\tconst connectTimer = setTimeout(() => {\n\t\tfail(refused(\"The relay did not answer in time.\", \"network\"));\n\t}, CONNECT_TIMEOUT_MS);\n\n\tconst context = callContext(host, \"relay\");\n\tconst handler = createMcpHandler({\n\t\t...context,\n\t\t// Without `icons`, the page's own <link rel=\"icon\">, read now.\n\t\tserver: { ...host.server, icons: host.server.icons ?? pageIcons() },\n\t\tclient: (grant) => host.clientFor(grant),\n\t\tmaxBodyBytes: () => maxBodyBytes,\n\t});\n\tconst stopWatching = watchTools(host.registry, context.tools, () =>\n\t\thandler.toolsChanged(),\n\t);\n\n\tfunction send(message: TabMessage): boolean {\n\t\tif (ws.readyState !== WebSocket.OPEN) return false;\n\t\ttry {\n\t\t\tws.send(JSON.stringify(message));\n\t\t\treturn true;\n\t\t} catch {\n\t\t\treturn false;\n\t\t}\n\t}\n\n\t/** Two missed pings mean the connection is dead (protocol: heartbeat). */\n\tfunction armHeartbeat(): void {\n\t\tif (heartbeatMs <= 0) return;\n\t\tclearTimeout(heartbeat);\n\t\theartbeat = setTimeout(() => {\n\t\t\tbyeReason ??= \"heartbeat\";\n\t\t\tfinish(4003);\n\t\t\ttry {\n\t\t\t\tws.close();\n\t\t\t} catch {\n\t\t\t\t// already closing\n\t\t\t}\n\t\t}, heartbeatMs * 2.5);\n\t}\n\n\tfunction fail(error: Error): void {\n\t\tif (state !== \"opening\") return;\n\t\tfinish(0);\n\t\trejectReady(error);\n\t\ttry {\n\t\t\tws.close();\n\t\t} catch {\n\t\t\t// already closed\n\t\t}\n\t}\n\n\t/** The session is over: clean up once and tell the host. */\n\tfunction finish(code: number): void {\n\t\tif (state === \"closed\") return;\n\t\tconst wasReady = state === \"ready\";\n\t\tstate = \"closed\";\n\t\tclearTimeout(connectTimer);\n\t\tclearTimeout(heartbeat);\n\t\tstopWatching();\n\t\ttunnel.close();\n\t\thandler.close();\n\t\tif (wasReady) {\n\t\t\tconst reason =\n\t\t\t\tbyeReason ??\n\t\t\t\tCLOSE_REASONS[code] ??\n\t\t\t\t(code === 1006 ? \"network\" : \"closed\");\n\t\t\t// Over at once; only the detail of `replaced` waits for a sibling's\n\t\t\t// `claimed`, which comes a moment after the `bye` (DEC-095).\n\t\t\thost.closed(reason, code);\n\t\t\tif (reason === \"replaced\") {\n\t\t\t\tvoid siblings.heard().then((sibling) => {\n\t\t\t\t\tsiblings.close();\n\t\t\t\t\thost.replaced({ sibling });\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t}\n\t\tsiblings.close();\n\t}\n\n\tconst tunnel = createTunnel({\n\t\thandler,\n\t\tsend,\n\t\tmaxChunk: () => maxChunk,\n\t\terror: (error) => host.error(error),\n\t});\n\n\tfunction onMessage(message: RelayMessage): void {\n\t\tif (state === \"opening\") {\n\t\t\tif (message.type === \"session\") {\n\t\t\t\tconst chunk = chunkSize(message.limits.maxMessageBytes);\n\t\t\t\tif (chunk === undefined) {\n\t\t\t\t\tfail(\n\t\t\t\t\t\trefused(\n\t\t\t\t\t\t\t`The relay's message limit (${message.limits.maxMessageBytes} bytes) is too small; tab-mcp needs at least ${MIN_MESSAGE_BYTES}.`,\n\t\t\t\t\t\t\t\"policy\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (revokeAll && message.grants.length > 0) {\n\t\t\t\t\t// A relay older than 0.5 ignores hello.revokeAll and lists the\n\t\t\t\t\t// grants: the address was not taken back (DEC-136).\n\t\t\t\t\tfail(\n\t\t\t\t\t\trefused(\n\t\t\t\t\t\t\t\"The relay did not revoke the address's grants (it needs tab-mcp 0.5 or later).\",\n\t\t\t\t\t\t\t\"policy\",\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tmaxChunk = chunk;\n\t\t\t\tmaxBodyBytes = message.limits.maxBodyBytes;\n\t\t\t\tstate = \"ready\";\n\t\t\t\tclearTimeout(connectTimer);\n\t\t\t\theartbeatMs = message.limits.heartbeatMs;\n\t\t\t\tarmHeartbeat();\n\t\t\t\tsiblings.claimed();\n\t\t\t\tresolveReady(host.sessionStarted(message));\n\t\t\t} else if (message.type === \"error\") {\n\t\t\t\tfail(\n\t\t\t\t\trefused(\n\t\t\t\t\t\t`The relay refused the connection: ${message.message || message.code}`,\n\t\t\t\t\t\tmessage.code === \"rate_limited\" ? \"rate_limited\" : \"policy\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t} else if (message.type === \"bye\") {\n\t\t\t\tfail(\n\t\t\t\t\trefused(\n\t\t\t\t\t\t`The relay ended the connection: ${message.reason}`,\n\t\t\t\t\t\tBYE_REASONS[message.reason] ?? \"closed\",\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (state !== \"ready\") return;\n\t\tswitch (message.type) {\n\t\t\tcase \"ping\":\n\t\t\t\tarmHeartbeat();\n\t\t\t\tsend({ type: \"pong\", t: message.t });\n\t\t\t\treturn;\n\t\t\tcase \"http.request\":\n\t\t\t\ttunnel.request(message);\n\t\t\t\treturn;\n\t\t\tcase \"http.cancel\":\n\t\t\t\ttunnel.cancel(message.id);\n\t\t\t\treturn;\n\t\t\tcase \"pairing.code\":\n\t\t\t\thost.pairingCode(\n\t\t\t\t\tmessage.reason === undefined\n\t\t\t\t\t\t? { code: message.code, expiresAt: message.expiresAt }\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tcode: message.code,\n\t\t\t\t\t\t\t\texpiresAt: message.expiresAt,\n\t\t\t\t\t\t\t\treason: message.reason,\n\t\t\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\tcase \"grant.added\":\n\t\t\t\thost.grantAdded(message.grant);\n\t\t\t\treturn;\n\t\t\tcase \"grant.removed\":\n\t\t\t\thost.grantRemoved(message.grantId);\n\t\t\t\treturn;\n\t\t\tcase \"identity.bound\":\n\t\t\t\thost.identityResult(true, message.round);\n\t\t\t\treturn;\n\t\t\tcase \"bye\":\n\t\t\t\tbyeReason = BYE_REASONS[message.reason] ?? \"closed\";\n\t\t\t\t// Taken over: over at once, not when the socket closes (review of PR 39).\n\t\t\t\tif (byeReason === \"replaced\") finish(4005);\n\t\t\t\treturn;\n\t\t\tcase \"error\":\n\t\t\t\tif (message.code === \"identity_refused\") {\n\t\t\t\t\thost.identityResult(\n\t\t\t\t\t\tfalse,\n\t\t\t\t\t\ttypeof message.round === \"number\" ? message.round : undefined,\n\t\t\t\t\t\tmessage.message,\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// The relay does not know a grant the page lists: it is gone (it\n\t\t\t\t// expired), and a `revoke()` of it resolves (DEC-168).\n\t\t\t\tif (\n\t\t\t\t\tmessage.code === \"unknown_id\" &&\n\t\t\t\t\tmessage.for === \"grant.revoke\" &&\n\t\t\t\t\ttypeof message.grantId === \"string\"\n\t\t\t\t)\n\t\t\t\t\thost.grantRemoved(message.grantId);\n\t\t\t\t// With its `code`, and what it answers (relay 0.10.2), so that\n\t\t\t\t// only the pending `revoke()` or `signOut()` it answers settles\n\t\t\t\t// (`store_unavailable`, `unknown_id`).\n\t\t\t\thost.error(\n\t\t\t\t\tObject.assign(\n\t\t\t\t\t\tnew Error(`Relay error ${message.code}: ${message.message}`),\n\t\t\t\t\t\t{ code: message.code },\n\t\t\t\t\t\ttypeof message.for === \"string\" ? { for: message.for } : {},\n\t\t\t\t\t\ttypeof message.grantId === \"string\"\n\t\t\t\t\t\t\t? { grantId: message.grantId }\n\t\t\t\t\t\t\t: {},\n\t\t\t\t\t),\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\tcase \"session\":\n\t\t\t\treturn; // only once\n\t\t}\n\t}\n\n\tws.addEventListener(\"open\", () => {\n\t\tif (ws.protocol !== \"\" && ws.protocol !== SUBPROTOCOL) {\n\t\t\tfail(\n\t\t\t\trefused(\n\t\t\t\t\t`The relay speaks ${ws.protocol}, not ${SUBPROTOCOL}.`,\n\t\t\t\t\t\"policy\",\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tsend({\n\t\t\ttype: \"hello\",\n\t\t\tlibrary: host.library,\n\t\t\tapp:\n\t\t\t\thost.appName === undefined\n\t\t\t\t\t? { id: host.app }\n\t\t\t\t\t: { id: host.app, name: host.appName },\n\t\t\tsecret,\n\t\t\t...(revokeAll ? { revokeAll: true } : {}),\n\t\t});\n\t});\n\tws.addEventListener(\"message\", (event: MessageEvent) => {\n\t\tif (typeof event.data !== \"string\") return;\n\t\t// A frame the tab cannot read is dropped without an answer (CC 15): the\n\t\t// relay only logged one, and its request ends at its own timeout.\n\t\tconst message = parseRelayMessage(event.data);\n\t\tif (message === undefined) return;\n\t\tif (state === \"ready\") armHeartbeat(); // any traffic shows the link is alive\n\t\tonMessage(message);\n\t});\n\tws.addEventListener(\"close\", (event: CloseEvent) => {\n\t\tif (state === \"opening\") {\n\t\t\tfinish(event.code);\n\t\t\t// No WebSocket at all: browsers say 1006, Bun 1002. The page cannot\n\t\t\t// tell a refused origin from an unreachable relay (DEC-082).\n\t\t\tconst unreachable = event.code === 1006 || event.code === 1002;\n\t\t\trejectReady(\n\t\t\t\trefused(\n\t\t\t\t\tunreachable\n\t\t\t\t\t\t? \"Could not connect to the relay (refused, unreachable, or this page's origin is not allowed).\"\n\t\t\t\t\t\t: `The relay closed the connection (${event.code}${event.reason ? `: ${event.reason}` : \"\"}).`,\n\t\t\t\t\tCLOSE_REASONS[event.code] ?? (unreachable ? \"network\" : \"closed\"),\n\t\t\t\t),\n\t\t\t);\n\t\t\treturn;\n\t\t}\n\t\tfinish(event.code);\n\t});\n\n\treturn {\n\t\tready,\n\t\tsend,\n\t\tclose(reason: DisconnectReason) {\n\t\t\tif (state === \"closed\") return;\n\t\t\tif (state === \"opening\") {\n\t\t\t\tfail(\n\t\t\t\t\tnew DOMException(\n\t\t\t\t\t\t\"The connection was cancelled\",\n\t\t\t\t\t\t\"AbortError\",\n\t\t\t\t\t) as Error,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tbyeReason = reason;\n\t\t\tsend({ type: \"bye\", reason: \"user\" });\n\t\t\tfinish(1000);\n\t\t\ttry {\n\t\t\t\tws.close(1000, \"bye\");\n\t\t\t} catch {\n\t\t\t\t// already closed\n\t\t\t}\n\t\t},\n\t};\n}\n"
|
|
18
18
|
],
|
|
19
|
-
"mappings": "AAWA,IAAM,GAAO,4BAOb,SAAS,EAAK,CAAC,EAA8B,CAC5C,IAAQ,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