pagegraph 0.13.0 → 0.14.1

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.
Files changed (80) hide show
  1. package/README.md +48 -41
  2. package/dist/anthropic-messages-TqKpKmfW.js +1067 -0
  3. package/dist/anthropic-messages-TqKpKmfW.js.map +1 -0
  4. package/dist/audit.d.ts +2 -0
  5. package/dist/audit.js +1 -1
  6. package/dist/audit.js.map +1 -1
  7. package/dist/azure-openai-responses-DJjBLwoI.js +231 -0
  8. package/dist/azure-openai-responses-DJjBLwoI.js.map +1 -0
  9. package/dist/cli.js +10487 -38044
  10. package/dist/cli.js.map +1 -1
  11. package/dist/cloudflare-workers-ai-system-one-f3ZrvNYZ.js +41 -0
  12. package/dist/cloudflare-workers-ai-system-one-f3ZrvNYZ.js.map +1 -0
  13. package/dist/config.d.ts +6 -6
  14. package/dist/config.js.map +1 -1
  15. package/dist/diagnostics-Wt5faNDM.js +108 -0
  16. package/dist/diagnostics-Wt5faNDM.js.map +1 -0
  17. package/dist/dist-cFoAzruL.js +4794 -0
  18. package/dist/dist-cFoAzruL.js.map +1 -0
  19. package/dist/env-api-keys-C-OA0yM-.js +124 -0
  20. package/dist/env-api-keys-C-OA0yM-.js.map +1 -0
  21. package/dist/error-body-CyiejW4b.js +103 -0
  22. package/dist/error-body-CyiejW4b.js.map +1 -0
  23. package/dist/github-copilot-headers-CEpMOpQF.js +24 -0
  24. package/dist/github-copilot-headers-CEpMOpQF.js.map +1 -0
  25. package/dist/google-generative-ai-BxABKIKO.js +330 -0
  26. package/dist/google-generative-ai-BxABKIKO.js.map +1 -0
  27. package/dist/google-shared-0gpM2jFi.js +19471 -0
  28. package/dist/google-shared-0gpM2jFi.js.map +1 -0
  29. package/dist/google-vertex-D8Eb5cbu.js +376 -0
  30. package/dist/google-vertex-D8Eb5cbu.js.map +1 -0
  31. package/dist/hash-Dp7EzZUo.js +18 -0
  32. package/dist/hash-Dp7EzZUo.js.map +1 -0
  33. package/dist/headers-BRNMVpzu.js +19 -0
  34. package/dist/headers-BRNMVpzu.js.map +1 -0
  35. package/dist/json-parse-C10znB7l.js +383 -0
  36. package/dist/json-parse-C10znB7l.js.map +1 -0
  37. package/dist/mistral-conversations-CvaqBWjR.js +690 -0
  38. package/dist/mistral-conversations-CvaqBWjR.js.map +1 -0
  39. package/dist/models-DcT5qOEL.js +1203 -0
  40. package/dist/models-DcT5qOEL.js.map +1 -0
  41. package/dist/node-Ccvru9GE.js +26 -0
  42. package/dist/node-Ccvru9GE.js.map +1 -0
  43. package/dist/node-MEosBOF2.js +2403 -0
  44. package/dist/node-MEosBOF2.js.map +1 -0
  45. package/dist/openai-BCBEd2eO.js +17350 -0
  46. package/dist/openai-BCBEd2eO.js.map +1 -0
  47. package/dist/openai-codex-responses-vJqxeeRC.js +1268 -0
  48. package/dist/openai-codex-responses-vJqxeeRC.js.map +1 -0
  49. package/dist/openai-completions-Cb_fRAbI.js +989 -0
  50. package/dist/openai-completions-Cb_fRAbI.js.map +1 -0
  51. package/dist/openai-prompt-cache-Bc6qNWt0.js +10 -0
  52. package/dist/openai-prompt-cache-Bc6qNWt0.js.map +1 -0
  53. package/dist/openai-responses-sDuh82G5.js +268 -0
  54. package/dist/openai-responses-sDuh82G5.js.map +1 -0
  55. package/dist/openai-responses-shared-mhuo1Jov.js +599 -0
  56. package/dist/openai-responses-shared-mhuo1Jov.js.map +1 -0
  57. package/dist/openrouter-images-CRmBkzpX.js +127 -0
  58. package/dist/openrouter-images-CRmBkzpX.js.map +1 -0
  59. package/dist/pi-D3mMmYey.js +56805 -0
  60. package/dist/pi-D3mMmYey.js.map +1 -0
  61. package/dist/pi-messages-CejiVYvO.js +308 -0
  62. package/dist/pi-messages-CejiVYvO.js.map +1 -0
  63. package/dist/provider-env-t38GK5FF.js +39 -0
  64. package/dist/provider-env-t38GK5FF.js.map +1 -0
  65. package/dist/provider-retry-DzKoh1X7.js +80 -0
  66. package/dist/provider-retry-DzKoh1X7.js.map +1 -0
  67. package/dist/rolldown-runtime-B-lAHAz2.js +37 -0
  68. package/dist/sanitize-unicode-Ds14l9Om.js +28 -0
  69. package/dist/sanitize-unicode-Ds14l9Om.js.map +1 -0
  70. package/dist/sdk-C9_wiO6w.js +12503 -0
  71. package/dist/sdk-C9_wiO6w.js.map +1 -0
  72. package/dist/state-BuJP_3Lr.js +28102 -0
  73. package/dist/state-BuJP_3Lr.js.map +1 -0
  74. package/dist/system-one-shared-Dl10ZF7Z.js +167 -0
  75. package/dist/system-one-shared-Dl10ZF7Z.js.map +1 -0
  76. package/dist/transform-messages-BLJ8EfK6.js +468 -0
  77. package/dist/transform-messages-BLJ8EfK6.js.map +1 -0
  78. package/dist/typesafe-system-one-CwEWMV8P.js +25 -0
  79. package/dist/typesafe-system-one-CwEWMV8P.js.map +1 -0
  80. package/package.json +4 -8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-messages-BLJ8EfK6.js","names":[],"sources":["../node_modules/@earendil-works/pi-ai/dist/utils/pi-user-agent.js","../node_modules/@earendil-works/pi-ai/dist/api/constrained-sampling.js","../node_modules/@earendil-works/pi-ai/dist/utils/estimate.js","../node_modules/@earendil-works/pi-ai/dist/api/simple-options.js","../node_modules/@earendil-works/pi-ai/dist/api/transform-messages.js"],"sourcesContent":["function loadNodeOs() {\n if (typeof process === \"undefined\" || !(process.versions?.node || process.versions?.bun)) {\n return null;\n }\n return process.getBuiltinModule?.(\"node:os\") ?? null;\n}\n// Keep runtime OS loading browser-safe. A top-level runtime import of node:os breaks browser/Vite builds.\nconst nodeOs = loadNodeOs();\nexport function getPiUserAgent() {\n return nodeOs ? `pi (${nodeOs.platform()} ${nodeOs.release()}; ${nodeOs.arch()})` : \"pi (browser)\";\n}\n//# sourceMappingURL=pi-user-agent.js.map","class UnsupportedStrictJsonSchemaError extends Error {\n}\nconst UNSUPPORTED_STRICT_SCHEMA_KEYS = [\n \"$ref\",\n \"$defs\",\n \"definitions\",\n \"allOf\",\n \"oneOf\",\n \"patternProperties\",\n \"dependentSchemas\",\n \"dependencies\",\n \"unevaluatedProperties\",\n \"propertyNames\",\n \"contains\",\n \"prefixItems\",\n \"not\",\n \"if\",\n \"then\",\n \"else\",\n];\nfunction isJsonSchemaObject(value) {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction isStructuredSchema(schema) {\n if (!isJsonSchemaObject(schema))\n return false;\n const types = typeof schema.type === \"string\" ? [schema.type] : Array.isArray(schema.type) ? schema.type : [];\n return (types.includes(\"object\") ||\n types.includes(\"array\") ||\n schema.properties !== undefined ||\n schema.items !== undefined);\n}\nfunction schemaAllowsNull(schema) {\n if (!isJsonSchemaObject(schema))\n return false;\n if (schema.type === \"null\" || (Array.isArray(schema.type) && schema.type.includes(\"null\")))\n return true;\n if (schema.const === null || (Array.isArray(schema.enum) && schema.enum.includes(null)))\n return true;\n return Array.isArray(schema.anyOf) && schema.anyOf.some((variant) => schemaAllowsNull(variant));\n}\nfunction makeJsonSchemaNodeStrict(schema, isUnsupportedKeyword) {\n if (!isJsonSchemaObject(schema)) {\n throw new UnsupportedStrictJsonSchemaError(\"boolean schemas are unsupported\");\n }\n for (const key of UNSUPPORTED_STRICT_SCHEMA_KEYS) {\n if (schema[key] !== undefined) {\n throw new UnsupportedStrictJsonSchemaError(`${key} schemas are unsupported`);\n }\n }\n if (isUnsupportedKeyword) {\n for (const [key, value] of Object.entries(schema)) {\n if (isUnsupportedKeyword(key, value)) {\n throw new UnsupportedStrictJsonSchemaError(`${key}: ${JSON.stringify(value)} is unsupported`);\n }\n }\n }\n if (schema.anyOf !== undefined) {\n if (!Array.isArray(schema.anyOf) || schema.anyOf.length === 0) {\n throw new UnsupportedStrictJsonSchemaError(\"anyOf must contain at least one schema\");\n }\n for (const variant of schema.anyOf) {\n if (isStructuredSchema(variant)) {\n throw new UnsupportedStrictJsonSchemaError(\"object and array unions are unsupported\");\n }\n makeJsonSchemaNodeStrict(variant, isUnsupportedKeyword);\n }\n }\n if (schema.items !== undefined) {\n if (Array.isArray(schema.items)) {\n throw new UnsupportedStrictJsonSchemaError(\"tuple schemas are unsupported\");\n }\n makeJsonSchemaNodeStrict(schema.items, isUnsupportedKeyword);\n }\n const isObjectSchema = schema.type === \"object\";\n if (schema.properties !== undefined && !isObjectSchema) {\n throw new UnsupportedStrictJsonSchemaError(\"properties require type object\");\n }\n if (!isObjectSchema)\n return;\n if (schema.additionalProperties !== undefined && schema.additionalProperties !== false) {\n throw new UnsupportedStrictJsonSchemaError(\"schema-valued or true additionalProperties is unsupported\");\n }\n if (schema.properties !== undefined && !isJsonSchemaObject(schema.properties)) {\n throw new UnsupportedStrictJsonSchemaError(\"object properties must be a schema map\");\n }\n if (schema.required !== undefined &&\n (!Array.isArray(schema.required) || schema.required.some((key) => typeof key !== \"string\"))) {\n throw new UnsupportedStrictJsonSchemaError(\"object required must be a string array\");\n }\n const properties = schema.properties ?? {};\n const propertyNames = Object.keys(properties);\n const required = new Set(Array.isArray(schema.required) ? schema.required : []);\n if ([...required].some((key) => !propertyNames.includes(key))) {\n throw new UnsupportedStrictJsonSchemaError(\"required contains an unknown property\");\n }\n for (const [key, property] of Object.entries(properties)) {\n makeJsonSchemaNodeStrict(property, isUnsupportedKeyword);\n if (!required.has(key) && !schemaAllowsNull(property)) {\n properties[key] = { anyOf: [property, { type: \"null\" }] };\n }\n }\n schema.required = propertyNames;\n schema.additionalProperties = false;\n}\n/** Convert a tool schema to the strict subset expected by provider constrained sampling. */\nexport function makeStrictJsonSchema(schema, isUnsupportedKeyword) {\n const cloned = structuredClone(schema);\n if (!isJsonSchemaObject(cloned)) {\n throw new UnsupportedStrictJsonSchemaError(\"root schema must have type object\");\n }\n makeJsonSchemaNodeStrict(cloned, isUnsupportedKeyword);\n if (cloned.type !== \"object\") {\n throw new UnsupportedStrictJsonSchemaError(\"root schema must have type object\");\n }\n return cloned;\n}\nexport function getJsonSchemaToolParameters(tool, strict) {\n return (strict === true ? makeStrictJsonSchema(tool.parameters) : tool.parameters);\n}\nexport function getGrammarToolInput(toolName, arguments_, inputProperty) {\n const input = arguments_[inputProperty];\n if (typeof input !== \"string\") {\n throw new Error(`Grammar tool call \"${toolName}\" requires argument \"${inputProperty}\" to be a string.`);\n }\n return input;\n}\nexport function appendGrammarToolInputJsonDelta(buffer, inputProperty, nextInput, close) {\n if (buffer.closed) {\n if (close && nextInput === buffer.input)\n return undefined;\n throw new Error(`grammar tool input for property \"${inputProperty}\" changed after it was closed`);\n }\n if (!nextInput.startsWith(buffer.input)) {\n throw new Error(`grammar tool input for property \"${inputProperty}\" changed non-monotonically`);\n }\n const inputDelta = nextInput.slice(buffer.input.length);\n if (!close && inputDelta.length === 0)\n return undefined;\n let delta = \"\";\n if (!buffer.started) {\n delta += `{${JSON.stringify(inputProperty)}:\"`;\n buffer.started = true;\n }\n delta += JSON.stringify(inputDelta).slice(1, -1);\n buffer.input = nextInput;\n if (close) {\n delta += '\"}';\n buffer.closed = true;\n }\n return delta;\n}\nfunction inferGrammarInputProperty(tool) {\n const schema = tool.parameters;\n if (schema.type !== \"object\") {\n throw new Error(\"grammar constrained sampling requires an object parameter schema\");\n }\n if (!Array.isArray(schema.required) || schema.required.length !== 1 || typeof schema.required[0] !== \"string\") {\n throw new Error(\"grammar constrained sampling requires exactly one required string property\");\n }\n const inputProperty = schema.required[0];\n if (!schema.properties?.[inputProperty]) {\n throw new Error(`grammar constrained sampling requires a properties entry for ${inputProperty}`);\n }\n if (schema.properties[inputProperty]?.type !== \"string\") {\n throw new Error(`grammar constrained sampling property ${inputProperty} must have type string`);\n }\n return inputProperty;\n}\n/**\n * Decide whether a JSON-schema tool is sent in strict mode. `isUnsupportedKeyword` lets a provider\n * reject extra keywords its strict mode does not accept, so \"prefer\" tools fall back to non-strict.\n */\nexport function resolveJsonSchemaStrictSampling(tool, supportsStrictMode, isUnsupportedKeyword) {\n const config = tool.constrainedSampling;\n if (!config || config.type !== \"json_schema\")\n return undefined;\n if (supportsStrictMode) {\n try {\n makeStrictJsonSchema(tool.parameters, isUnsupportedKeyword);\n return true;\n }\n catch (error) {\n if (!(error instanceof UnsupportedStrictJsonSchemaError))\n throw error;\n if (config.strict !== \"require\")\n return undefined;\n throw new Error(`Tool \"${tool.name}\" requires JSON-schema constrained sampling, but ${error.message}.`);\n }\n }\n if (config.strict === \"require\") {\n throw new Error(`Tool \"${tool.name}\" requires JSON-schema constrained sampling, but strict tools are unsupported.`);\n }\n return undefined;\n}\nexport function resolveGrammarConstrainedSampling(tool, supportsOpenAIGrammarTools) {\n const config = tool.constrainedSampling;\n if (!config || config.type !== \"grammar\") {\n return undefined;\n }\n if (!supportsOpenAIGrammarTools) {\n return undefined;\n }\n const larkDefinition = config.variants.openai_lark;\n const regexDefinition = config.variants.openai_regex;\n const hasLarkDefinition = typeof larkDefinition === \"string\" && larkDefinition.trim().length > 0;\n const hasRegexDefinition = typeof regexDefinition === \"string\" && regexDefinition.trim().length > 0;\n if (!hasLarkDefinition && !hasRegexDefinition) {\n throw new Error(`Tool \"${tool.name}\" cannot use grammar constrained sampling: no supported grammar variant was provided.`);\n }\n try {\n return {\n format: hasLarkDefinition ? \"lark\" : \"regex\",\n definition: hasLarkDefinition ? larkDefinition : regexDefinition,\n inputProperty: inferGrammarInputProperty(tool),\n };\n }\n catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n throw new Error(`Tool \"${tool.name}\" cannot use grammar constrained sampling: ${message}.`);\n }\n}\nexport function createGrammarToolInputProperties(tools, supportsOpenAIGrammarTools) {\n const properties = new Map();\n for (const tool of tools ?? []) {\n const grammar = resolveGrammarConstrainedSampling(tool, supportsOpenAIGrammarTools);\n if (grammar) {\n properties.set(tool.name, grammar.inputProperty);\n }\n }\n return properties;\n}\n//# sourceMappingURL=constrained-sampling.js.map","import { getSystemMessageText } from \"./text.js\";\nconst CHARS_PER_TOKEN = 4;\nconst ESTIMATED_IMAGE_CHARS = 4800;\nexport function calculateContextTokens(usage) {\n return usage.totalTokens || usage.input + usage.output + usage.cacheRead + usage.cacheWrite;\n}\nfunction safeJsonStringify(value) {\n try {\n return JSON.stringify(value) ?? \"undefined\";\n }\n catch {\n return \"[unserializable]\";\n }\n}\nfunction estimateTextAndImageContentChars(content) {\n if (typeof content === \"string\")\n return content.length;\n let chars = 0;\n for (const block of content)\n chars += block.type === \"text\" ? block.text.length : ESTIMATED_IMAGE_CHARS;\n return chars;\n}\nexport function estimateTextTokens(text) {\n return Math.ceil(text.length / CHARS_PER_TOKEN);\n}\nexport function estimateTextAndImageContentTokens(content) {\n return Math.ceil(estimateTextAndImageContentChars(content) / CHARS_PER_TOKEN);\n}\nexport function estimateMessageTokens(message) {\n let chars = 0;\n if (message.role === \"system\") {\n return (estimateTextTokens(getSystemMessageText(message)) +\n estimateToolsTokens(message.toolsAdded) +\n estimateToolsTokens(message.toolsRemoved));\n }\n if (message.role === \"user\")\n return estimateTextAndImageContentTokens(message.content);\n if (message.role === \"toolResult\")\n return estimateTextAndImageContentTokens(message.content);\n for (const block of message.content) {\n if (block.type === \"text\") {\n chars += block.text.length;\n }\n else if (block.type === \"thinking\") {\n chars += block.thinking.length;\n }\n else {\n chars += block.name.length + safeJsonStringify(block.arguments).length;\n }\n }\n return Math.ceil(chars / CHARS_PER_TOKEN);\n}\nfunction getLastAssistantUsageInfo(messages) {\n let latestPrefixTimestamp = Number.NEGATIVE_INFINITY;\n let usageInfo;\n for (let i = 0; i < messages.length; i++) {\n const message = messages[i];\n if (message.role === \"assistant\") {\n const assistant = message;\n // A newer prefix message was inserted after this response (for example, a\n // compaction summary), so its usage cannot describe the current prefix.\n const usageAppliesToPrefix = assistant.timestamp >= latestPrefixTimestamp;\n if (usageAppliesToPrefix &&\n assistant.stopReason !== \"aborted\" &&\n assistant.stopReason !== \"error\" &&\n calculateContextTokens(assistant.usage) > 0) {\n usageInfo = { usage: assistant.usage, index: i };\n }\n }\n latestPrefixTimestamp = Math.max(latestPrefixTimestamp, message.timestamp);\n }\n return usageInfo;\n}\nexport function estimateContextTokens(context) {\n const messages = \"messages\" in context ? context.messages : context;\n const usageInfo = getLastAssistantUsageInfo(messages);\n if (usageInfo) {\n const usageTokens = calculateContextTokens(usageInfo.usage);\n let trailingTokens = 0;\n for (let i = usageInfo.index + 1; i < messages.length; i++) {\n trailingTokens += estimateMessageTokens(messages[i]);\n }\n return { tokens: usageTokens + trailingTokens, usageTokens, trailingTokens, lastUsageIndex: usageInfo.index };\n }\n let tokens = 0;\n for (const message of messages)\n tokens += estimateMessageTokens(message);\n return { tokens, usageTokens: 0, trailingTokens: tokens, lastUsageIndex: null };\n}\nfunction estimateToolsTokens(tools) {\n if (!tools || tools.length === 0)\n return 0;\n return estimateTextTokens(safeJsonStringify(tools));\n}\n//# sourceMappingURL=estimate.js.map","import { estimateContextTokens } from \"../utils/estimate.js\";\nconst CONTEXT_SAFETY_TOKENS = 4096;\nconst MIN_MAX_TOKENS = 1;\nexport function clampMaxTokensToContext(model, context, maxTokens) {\n if (model.contextWindow <= 0)\n return Math.max(MIN_MAX_TOKENS, maxTokens);\n const available = model.contextWindow - estimateContextTokens(context).tokens - CONTEXT_SAFETY_TOKENS;\n return Math.min(maxTokens, Math.max(MIN_MAX_TOKENS, available));\n}\nexport function buildBaseOptions(model, context, options, apiKey) {\n return {\n temperature: options?.temperature,\n samplingParams: options?.samplingParams,\n maxTokens: clampMaxTokensToContext(model, context, options?.maxTokens ?? model.maxTokens),\n signal: options?.signal,\n telemetryContext: options?.telemetryContext,\n apiKey: apiKey || options?.apiKey,\n fetch: options?.fetch,\n transport: options?.transport,\n cacheRetention: options?.cacheRetention,\n sessionId: options?.sessionId,\n headers: options?.headers,\n onPayload: options?.onPayload,\n onResponse: options?.onResponse,\n onProviderStreamEvent: options?.onProviderStreamEvent,\n timeoutMs: options?.timeoutMs,\n websocketConnectTimeoutMs: options?.websocketConnectTimeoutMs,\n maxRetries: options?.maxRetries,\n maxRetryDelayMs: options?.maxRetryDelayMs,\n metadata: options?.metadata,\n env: options?.env,\n };\n}\n/** Tokens always left for the answer when a thinking budget shares the response ceiling. */\nexport const MIN_ANSWER_TOKENS = 1024;\nexport const DEFAULT_THINKING_BUDGETS = {\n minimal: 1024,\n low: 2048,\n medium: 8192,\n high: 16384,\n};\nexport function clampReasoning(effort) {\n return effort === \"xhigh\" || effort === \"max\" ? \"high\" : effort;\n}\nexport function thinkingBudgetForLevel(reasoningLevel, customBudgets) {\n const budgets = { ...DEFAULT_THINKING_BUDGETS, ...customBudgets };\n const level = clampReasoning(reasoningLevel);\n return budgets[level];\n}\n/** Cap a thinking budget so at least MIN_ANSWER_TOKENS remain under a shared response ceiling. */\nexport function clampThinkingBudgetToAnswerRoom(thinkingBudget, ceiling) {\n return Math.min(thinkingBudget, Math.max(0, ceiling - MIN_ANSWER_TOKENS));\n}\nexport function adjustMaxTokensForThinking(\n// Undefined means no explicit caller cap. Use the model cap and fit thinking inside it.\nbaseMaxTokens, modelMaxTokens, reasoningLevel, customBudgets) {\n let thinkingBudget = thinkingBudgetForLevel(reasoningLevel, customBudgets);\n const maxTokens = baseMaxTokens === undefined ? modelMaxTokens : Math.min(baseMaxTokens + thinkingBudget, modelMaxTokens);\n if (maxTokens <= thinkingBudget) {\n thinkingBudget = clampThinkingBudgetToAnswerRoom(thinkingBudget, maxTokens);\n }\n return { maxTokens, thinkingBudget };\n}\n//# sourceMappingURL=simple-options.js.map","const NON_VISION_USER_IMAGE_PLACEHOLDER = \"(image omitted: model does not support images)\";\nconst NON_VISION_TOOL_IMAGE_PLACEHOLDER = \"(tool image omitted: model does not support images)\";\nfunction replaceImagesWithPlaceholder(content, placeholder) {\n const result = [];\n let previousWasPlaceholder = false;\n for (const block of content) {\n if (block.type === \"image\") {\n if (!previousWasPlaceholder) {\n result.push({ type: \"text\", text: placeholder });\n }\n previousWasPlaceholder = true;\n continue;\n }\n result.push(block);\n previousWasPlaceholder = block.text === placeholder;\n }\n return result;\n}\nfunction downgradeUnsupportedImages(messages, model) {\n if (model.input.includes(\"image\")) {\n return messages;\n }\n return messages.map((msg) => {\n if (msg.role === \"user\" && Array.isArray(msg.content)) {\n return {\n ...msg,\n content: replaceImagesWithPlaceholder(msg.content, NON_VISION_USER_IMAGE_PLACEHOLDER),\n };\n }\n if (msg.role === \"toolResult\") {\n return {\n ...msg,\n content: replaceImagesWithPlaceholder(msg.content, NON_VISION_TOOL_IMAGE_PLACEHOLDER),\n };\n }\n return msg;\n });\n}\n/**\n * Normalize tool call ID for cross-provider compatibility.\n * OpenAI Responses API generates IDs that are 450+ chars with special characters like `|`.\n * Anthropic APIs require IDs matching ^[a-zA-Z0-9_-]+$ (max 64 chars).\n */\nexport function transformMessages(messages, model, normalizeToolCallId) {\n // Build a map of original tool call IDs to normalized IDs\n const toolCallIdMap = new Map();\n // Normalize null/undefined content from untyped callers (custom tools, hand-built\n // histories, old session files) so downstream code can rely on the type contract.\n const normalizedMessages = messages.map((msg) => (msg.content == null ? { ...msg, content: [] } : msg));\n const imageAwareMessages = downgradeUnsupportedImages(normalizedMessages, model);\n // First pass: transform messages (unsupported image downgrade, thinking blocks, tool call ID normalization)\n const transformed = imageAwareMessages.map((msg) => {\n // System and user messages pass through unchanged\n if (msg.role === \"system\" || msg.role === \"user\") {\n return msg;\n }\n // Handle toolResult messages - normalize toolCallId if we have a mapping\n if (msg.role === \"toolResult\") {\n const normalizedId = toolCallIdMap.get(msg.toolCallId);\n if (normalizedId && normalizedId !== msg.toolCallId) {\n return { ...msg, toolCallId: normalizedId };\n }\n return msg;\n }\n // Assistant messages need transformation check\n if (msg.role === \"assistant\") {\n const assistantMsg = msg;\n const isSameModel = assistantMsg.provider === model.provider &&\n assistantMsg.api === model.api &&\n assistantMsg.model === model.id;\n const transformedContent = assistantMsg.content.flatMap((block) => {\n if (block.type === \"thinking\") {\n // Redacted thinking is opaque encrypted content, only valid for the same model.\n // Drop it for cross-model to avoid API errors.\n if (block.redacted) {\n return isSameModel ? block : [];\n }\n // For same model: keep thinking blocks with signatures (needed for replay)\n // even if the thinking text is empty (OpenAI encrypted reasoning)\n if (isSameModel && block.thinkingSignature)\n return block;\n // Skip empty thinking blocks, convert others to plain text\n if (!block.thinking || block.thinking.trim() === \"\")\n return [];\n if (isSameModel)\n return block;\n return {\n type: \"text\",\n text: block.thinking,\n };\n }\n if (block.type === \"text\") {\n if (isSameModel)\n return block;\n return {\n type: \"text\",\n text: block.text,\n };\n }\n if (block.type === \"toolCall\") {\n const toolCall = block;\n let normalizedToolCall = toolCall;\n if (!isSameModel && toolCall.thoughtSignature) {\n normalizedToolCall = { ...toolCall };\n delete normalizedToolCall.thoughtSignature;\n }\n if (!isSameModel && normalizeToolCallId) {\n const normalizedId = normalizeToolCallId(toolCall.id, model, assistantMsg);\n if (normalizedId !== toolCall.id) {\n toolCallIdMap.set(toolCall.id, normalizedId);\n normalizedToolCall = { ...normalizedToolCall, id: normalizedId };\n }\n }\n return normalizedToolCall;\n }\n return block;\n });\n return {\n ...assistantMsg,\n content: transformedContent,\n };\n }\n return msg;\n });\n // Second pass: insert synthetic empty tool results for orphaned tool calls\n // This preserves thinking signatures and satisfies API requirements\n const result = [];\n let pendingToolCalls = [];\n let existingToolResultIds = new Set();\n // System messages are transparent to tool-call accounting: one that lands between a tool\n // call and its results is held back and emitted after the results (synthetic ones\n // included), so it never causes a duplicate result for a call that is answered later.\n const heldSystemMessages = [];\n const closePendingToolCalls = () => {\n if (pendingToolCalls.length > 0) {\n for (const tc of pendingToolCalls) {\n if (!existingToolResultIds.has(tc.id)) {\n result.push({\n role: \"toolResult\",\n toolCallId: tc.id,\n toolName: tc.name,\n content: [{ type: \"text\", text: \"No result provided\" }],\n isError: true,\n timestamp: Date.now(),\n });\n }\n }\n pendingToolCalls = [];\n existingToolResultIds = new Set();\n }\n result.push(...heldSystemMessages);\n heldSystemMessages.length = 0;\n };\n for (let i = 0; i < transformed.length; i++) {\n const msg = transformed[i];\n if (msg.role === \"assistant\") {\n // If we have pending orphaned tool calls from a previous assistant, insert synthetic results now\n closePendingToolCalls();\n // Skip errored/aborted assistant messages entirely.\n // These are incomplete turns that shouldn't be replayed:\n // - May have partial content (reasoning without message, incomplete tool calls)\n // - Replaying them can cause API errors (e.g., OpenAI \"reasoning without following item\")\n // - The model should retry from the last valid state\n const assistantMsg = msg;\n if (assistantMsg.stopReason === \"error\" || assistantMsg.stopReason === \"aborted\") {\n continue;\n }\n // Track tool calls from this assistant message\n const toolCalls = assistantMsg.content.filter((b) => b.type === \"toolCall\");\n if (toolCalls.length > 0) {\n pendingToolCalls = toolCalls;\n existingToolResultIds = new Set();\n }\n result.push(msg);\n }\n else if (msg.role === \"toolResult\") {\n existingToolResultIds.add(msg.toolCallId);\n result.push(msg);\n }\n else if (msg.role === \"system\") {\n if (pendingToolCalls.length > 0) {\n heldSystemMessages.push(msg);\n }\n else {\n result.push(msg);\n }\n }\n else if (msg.role === \"user\") {\n // A new user turn interrupts tool flow - insert synthetic results for orphaned calls\n closePendingToolCalls();\n result.push(msg);\n }\n else {\n result.push(msg);\n }\n }\n // If the conversation ends with unresolved tool calls, synthesize results now.\n closePendingToolCalls();\n return result;\n}\n//# sourceMappingURL=transform-messages.js.map"],"x_google_ignoreList":[0,1,2,3,4],"mappings":";;AAAA,SAAS,aAAa;CAClB,IAAI,OAAO,YAAY,eAAe,EAAE,QAAQ,UAAU,QAAQ,QAAQ,UAAU,MAChF,OAAO;CAEX,OAAO,QAAQ,mBAAmB,SAAS,KAAK;AACpD;AAEA,MAAM,SAAS,WAAW;AAC1B,SAAgB,iBAAiB;CAC7B,OAAO,SAAS,OAAO,OAAO,SAAS,EAAE,GAAG,OAAO,QAAQ,EAAE,IAAI,OAAO,KAAK,EAAE,KAAK;AACxF;;;ACVA,IAAM,mCAAN,cAA+C,MAAM,CACrD;AACA,MAAM,iCAAiC;CACnC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACJ;AACA,SAAS,mBAAmB,OAAO;CAC/B,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,KAAK;AAC9E;A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AG3B,OAAO,KAAK,GAAG;OAGlB,IAAI,IAAI,SAAS,QAAQ;GAE1B,sBAAsB;GACtB,OAAO,KAAK,GAAG;EACnB,OAEI,OAAO,KAAK,GAAG;CAEvB;CAEA,sBAAsB;CACtB,OAAO;AACX"}
@@ -0,0 +1,25 @@
1
+ import { n as isRecord, t as classifySystemOne } from "./system-one-shared-Dl10ZF7Z.js";
2
+ //#region node_modules/@earendil-works/pi-ai/dist/api/typesafe-system-one.js
3
+ /**
4
+ * TypeSafe's native System One protocol. OpenRouter serves the same protocol,
5
+ * so both providers use this API with different base URLs.
6
+ */
7
+ const transport = {
8
+ api: "typesafe-system-one",
9
+ label: "System One API",
10
+ url: (model) => new URL("systemone", `${model.baseUrl.replace(/\/+$/u, "")}/`),
11
+ payload: (model, request) => ({
12
+ model: model.id,
13
+ ...request
14
+ }),
15
+ output: (body) => {
16
+ if (!isRecord(body)) throw new Error("System One API returned an unexpected response");
17
+ return body;
18
+ }
19
+ };
20
+ /** TypeSafe System One classification with public `bool` values mapped to wire-level `noul`. */
21
+ const classify = (model, context, options) => classifySystemOne(transport, model, context, options);
22
+ //#endregion
23
+ export { classify };
24
+
25
+ //# sourceMappingURL=typesafe-system-one-CwEWMV8P.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typesafe-system-one-CwEWMV8P.js","names":[],"sources":["../node_modules/@earendil-works/pi-ai/dist/api/typesafe-system-one.js"],"sourcesContent":["import { classifySystemOne, isRecord } from \"./system-one-shared.js\";\n/**\n * TypeSafe's native System One protocol. OpenRouter serves the same protocol,\n * so both providers use this API with different base URLs.\n */\nconst transport = {\n api: \"typesafe-system-one\",\n label: \"System One API\",\n url: (model) => new URL(\"systemone\", `${model.baseUrl.replace(/\\/+$/u, \"\")}/`),\n payload: (model, request) => ({ model: model.id, ...request }),\n output: (body) => {\n if (!isRecord(body))\n throw new Error(\"System One API returned an unexpected response\");\n return body;\n },\n};\n/** TypeSafe System One classification with public `bool` values mapped to wire-level `noul`. */\nexport const classify = (model, context, options) => classifySystemOne(transport, model, context, options);\n//# sourceMappingURL=typesafe-system-one.js.map"],"x_google_ignoreList":[0],"mappings":";;;;;;AAKA,MAAM,YAAY;CACd,KAAK;CACL,OAAO;CACP,MAAM,UAAU,IAAI,IAAI,aAAa,GAAG,MAAM,QAAQ,QAAQ,SAAS,EAAE,EAAE,EAAE;CAC7E,UAAU,OAAO,aAAa;EAAE,OAAO,MAAM;EAAI,GAAG;CAAQ;CAC5D,SAAS,SAAS;EACd,IAAI,CAAC,SAAS,IAAI,GACd,MAAM,IAAI,MAAM,gDAAgD;EACpE,OAAO;CACX;AACJ;;AAEA,MAAa,YAAY,OAAO,SAAS,YAAY,kBAAkB,WAAW,OAAO,SAAS,OAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pagegraph",
3
- "version": "0.13.0",
3
+ "version": "0.14.1",
4
4
  "description": "Route-declared SEO graph, audit, and agentic workflow toolkit for TanStack Start.",
5
5
  "keywords": [
6
6
  "seo",
@@ -123,12 +123,14 @@
123
123
  },
124
124
  "devDependencies": {
125
125
  "@cloudflare/vite-plugin": "^1.62.5",
126
+ "@earendil-works/pi-agent-core": "1.0.0",
127
+ "@earendil-works/pi-ai": "1.0.0",
126
128
  "@effect/ai-typesafe": "4.0.0",
127
129
  "@effect/platform-bun": "4.0.0",
128
130
  "@effect/platform-node-shared": "4.0.0",
129
131
  "@effect/vitest": "4.0.0",
130
132
  "@noble/hashes": "^2.4.0",
131
- "@opencode/sdk": "2.0.22",
133
+ "@pi-ext/executor": "1.0.2",
132
134
  "@tanstack/react-router": "^1.170.26",
133
135
  "@tanstack/react-start": "^1.168.56",
134
136
  "@tanstack/router-generator": "^1.167.21",
@@ -188,11 +190,5 @@
188
190
  "react-dom": {
189
191
  "optional": true
190
192
  }
191
- },
192
- "overrides": {
193
- "@effect/platform-node": {
194
- "@effect/platform-node-shared": "4.0.0-rc.112",
195
- "effect": "4.0.0-rc.112"
196
- }
197
193
  }
198
194
  }