@wildo-ai/external-connectors-models 1.1.10 → 1.1.12

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 (110) hide show
  1. package/dist/esm/companion-exports.js.map +1 -1
  2. package/dist/esm/core/commons.external-connectors-models.schemas.d.ts +140 -0
  3. package/dist/esm/core/commons.external-connectors-models.schemas.d.ts.map +1 -1
  4. package/dist/esm/core/commons.external-connectors-models.schemas.js +203 -0
  5. package/dist/esm/core/commons.external-connectors-models.schemas.js.map +1 -1
  6. package/dist/esm/core/oauth2.enums.d.ts.map +1 -1
  7. package/dist/esm/core/oauth2.enums.js.map +1 -1
  8. package/dist/esm/core/operation-classification.external-connectors-models.schemas.d.ts.map +1 -1
  9. package/dist/esm/core/operation-classification.external-connectors-models.schemas.js.map +1 -1
  10. package/dist/esm/core/operations.external-connectors-models.schemas.js.map +1 -1
  11. package/dist/esm/core/security.external-connectors-models.schemas.d.ts +4 -2
  12. package/dist/esm/core/security.external-connectors-models.schemas.d.ts.map +1 -1
  13. package/dist/esm/core/security.external-connectors-models.schemas.js +10 -4
  14. package/dist/esm/core/security.external-connectors-models.schemas.js.map +1 -1
  15. package/dist/esm/index.d.ts +8 -0
  16. package/dist/esm/index.d.ts.map +1 -1
  17. package/dist/esm/index.js +8 -0
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/protocols/agent-client-protocol.external-connectors-models.schemas.d.ts +9 -42
  20. package/dist/esm/protocols/agent-client-protocol.external-connectors-models.schemas.d.ts.map +1 -1
  21. package/dist/esm/protocols/agent-client-protocol.external-connectors-models.schemas.js +31 -1
  22. package/dist/esm/protocols/agent-client-protocol.external-connectors-models.schemas.js.map +1 -1
  23. package/dist/esm/protocols/billing.standard-interface.schemas.d.ts +64 -3
  24. package/dist/esm/protocols/billing.standard-interface.schemas.d.ts.map +1 -1
  25. package/dist/esm/protocols/billing.standard-interface.schemas.js +23 -2
  26. package/dist/esm/protocols/billing.standard-interface.schemas.js.map +1 -1
  27. package/dist/esm/protocols/content-safety.external-connectors-models.schemas.d.ts +150 -0
  28. package/dist/esm/protocols/content-safety.external-connectors-models.schemas.d.ts.map +1 -0
  29. package/dist/esm/protocols/content-safety.external-connectors-models.schemas.js +182 -0
  30. package/dist/esm/protocols/content-safety.external-connectors-models.schemas.js.map +1 -0
  31. package/dist/esm/protocols/document-extraction.external-connectors-models.schemas.d.ts +41 -9
  32. package/dist/esm/protocols/document-extraction.external-connectors-models.schemas.d.ts.map +1 -1
  33. package/dist/esm/protocols/document-extraction.external-connectors-models.schemas.js +40 -14
  34. package/dist/esm/protocols/document-extraction.external-connectors-models.schemas.js.map +1 -1
  35. package/dist/esm/protocols/electronic-signature.external-connectors-models.schemas.d.ts +157 -0
  36. package/dist/esm/protocols/electronic-signature.external-connectors-models.schemas.d.ts.map +1 -0
  37. package/dist/esm/protocols/electronic-signature.external-connectors-models.schemas.js +134 -0
  38. package/dist/esm/protocols/electronic-signature.external-connectors-models.schemas.js.map +1 -0
  39. package/dist/esm/protocols/email-inbound.standard-interface.schemas.d.ts +85 -0
  40. package/dist/esm/protocols/email-inbound.standard-interface.schemas.d.ts.map +1 -1
  41. package/dist/esm/protocols/email-inbound.standard-interface.schemas.js +46 -2
  42. package/dist/esm/protocols/email-inbound.standard-interface.schemas.js.map +1 -1
  43. package/dist/esm/protocols/email.external-connectors-models.schemas.js.map +1 -1
  44. package/dist/esm/protocols/email.standard-interface.schemas.d.ts.map +1 -1
  45. package/dist/esm/protocols/email.standard-interface.schemas.js +4 -0
  46. package/dist/esm/protocols/email.standard-interface.schemas.js.map +1 -1
  47. package/dist/esm/protocols/embeddings.external-connectors-models.schemas.d.ts +86 -10
  48. package/dist/esm/protocols/embeddings.external-connectors-models.schemas.d.ts.map +1 -1
  49. package/dist/esm/protocols/embeddings.external-connectors-models.schemas.js +146 -7
  50. package/dist/esm/protocols/embeddings.external-connectors-models.schemas.js.map +1 -1
  51. package/dist/esm/protocols/file-storage.standard-interface.d.ts +14 -1
  52. package/dist/esm/protocols/file-storage.standard-interface.d.ts.map +1 -1
  53. package/dist/esm/protocols/file-storage.standard-interface.js +6 -0
  54. package/dist/esm/protocols/file-storage.standard-interface.js.map +1 -1
  55. package/dist/esm/protocols/frontend.external-connectors-models.schemas.js.map +1 -1
  56. package/dist/esm/protocols/graphql-operations.external-connectors-models.schemas.d.ts +254 -0
  57. package/dist/esm/protocols/graphql-operations.external-connectors-models.schemas.d.ts.map +1 -0
  58. package/dist/esm/protocols/graphql-operations.external-connectors-models.schemas.js +480 -0
  59. package/dist/esm/protocols/graphql-operations.external-connectors-models.schemas.js.map +1 -0
  60. package/dist/esm/protocols/hooks-capability.external-connectors-models.schemas.d.ts +7 -2
  61. package/dist/esm/protocols/hooks-capability.external-connectors-models.schemas.d.ts.map +1 -1
  62. package/dist/esm/protocols/hooks-capability.external-connectors-models.schemas.js.map +1 -1
  63. package/dist/esm/protocols/hooks.external-connectors-models.schemas.d.ts +482 -7
  64. package/dist/esm/protocols/hooks.external-connectors-models.schemas.d.ts.map +1 -1
  65. package/dist/esm/protocols/hooks.external-connectors-models.schemas.js +348 -0
  66. package/dist/esm/protocols/hooks.external-connectors-models.schemas.js.map +1 -1
  67. package/dist/esm/protocols/image.external-connectors-models.schemas.js.map +1 -1
  68. package/dist/esm/protocols/llm.external-connectors-models.schemas.d.ts +165 -8
  69. package/dist/esm/protocols/llm.external-connectors-models.schemas.d.ts.map +1 -1
  70. package/dist/esm/protocols/llm.external-connectors-models.schemas.js +243 -20
  71. package/dist/esm/protocols/llm.external-connectors-models.schemas.js.map +1 -1
  72. package/dist/esm/protocols/oauth2-provider-assurance.definitions.js.map +1 -1
  73. package/dist/esm/protocols/oauth2-provider-assurance.schemas.js.map +1 -1
  74. package/dist/esm/protocols/oauth2.external-connectors-models.schemas.js.map +1 -1
  75. package/dist/esm/protocols/provider-configuration-authoring.external-connectors-models.schemas.d.ts +52 -0
  76. package/dist/esm/protocols/provider-configuration-authoring.external-connectors-models.schemas.d.ts.map +1 -0
  77. package/dist/esm/protocols/provider-configuration-authoring.external-connectors-models.schemas.js +132 -0
  78. package/dist/esm/protocols/provider-configuration-authoring.external-connectors-models.schemas.js.map +1 -0
  79. package/dist/esm/protocols/provider-connection-parameters.external-connectors-models.d.ts +111 -0
  80. package/dist/esm/protocols/provider-connection-parameters.external-connectors-models.d.ts.map +1 -0
  81. package/dist/esm/protocols/provider-connection-parameters.external-connectors-models.js +203 -0
  82. package/dist/esm/protocols/provider-connection-parameters.external-connectors-models.js.map +1 -0
  83. package/dist/esm/protocols/provider-oauth2-token-endpoint-hosts.external-connectors-models.d.ts +6 -0
  84. package/dist/esm/protocols/provider-oauth2-token-endpoint-hosts.external-connectors-models.d.ts.map +1 -1
  85. package/dist/esm/protocols/provider-oauth2-token-endpoint-hosts.external-connectors-models.js +13 -7
  86. package/dist/esm/protocols/provider-oauth2-token-endpoint-hosts.external-connectors-models.js.map +1 -1
  87. package/dist/esm/protocols/provider-vendor-registration.external-connectors-models.d.ts +50 -0
  88. package/dist/esm/protocols/provider-vendor-registration.external-connectors-models.d.ts.map +1 -0
  89. package/dist/esm/protocols/provider-vendor-registration.external-connectors-models.js +30 -0
  90. package/dist/esm/protocols/provider-vendor-registration.external-connectors-models.js.map +1 -0
  91. package/dist/esm/protocols/rest-operations.external-connectors-models.schemas.d.ts +1165 -11
  92. package/dist/esm/protocols/rest-operations.external-connectors-models.schemas.d.ts.map +1 -1
  93. package/dist/esm/protocols/rest-operations.external-connectors-models.schemas.js +1217 -9
  94. package/dist/esm/protocols/rest-operations.external-connectors-models.schemas.js.map +1 -1
  95. package/dist/esm/protocols/service-account-token.external-connectors-models.schemas.d.ts +73 -0
  96. package/dist/esm/protocols/service-account-token.external-connectors-models.schemas.d.ts.map +1 -0
  97. package/dist/esm/protocols/service-account-token.external-connectors-models.schemas.js +82 -0
  98. package/dist/esm/protocols/service-account-token.external-connectors-models.schemas.js.map +1 -0
  99. package/dist/esm/protocols/sms.external-connectors-models.schemas.js.map +1 -1
  100. package/dist/esm/protocols/sms.standard-interface.schemas.d.ts +79 -1
  101. package/dist/esm/protocols/sms.standard-interface.schemas.d.ts.map +1 -1
  102. package/dist/esm/protocols/sms.standard-interface.schemas.js +93 -0
  103. package/dist/esm/protocols/sms.standard-interface.schemas.js.map +1 -1
  104. package/dist/esm/protocols/subject-erasure-effect.standard-interface.d.ts +133 -0
  105. package/dist/esm/protocols/subject-erasure-effect.standard-interface.d.ts.map +1 -0
  106. package/dist/esm/protocols/subject-erasure-effect.standard-interface.js +61 -0
  107. package/dist/esm/protocols/subject-erasure-effect.standard-interface.js.map +1 -0
  108. package/dist/tsconfig.build.tsbuildinfo +1 -1
  109. package/package.json +5 -5
  110. package/dist/esm/.native.tsbuildinfo +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-safety.external-connectors-models.schemas.js","sourceRoot":"","sources":["../../../src/protocols/content-safety.external-connectors-models.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACL,sCAAsC,GACrC,MAAM,oDAAoD,CAAA;AAE7D,iEAAiE;AACjE,kCAAkC;AAClC,WAAW;AACX,0FAA0F;AAC1F,+FAA+F;AAC/F,uHAAuH;AACvH,EAAE;AACF,qDAAqD;AACrD,EAAE;AACF,gGAAgG;AAChG,kGAAkG;AAClG,oGAAoG;AACpG,qGAAqG;AACrG,mGAAmG;AACnG,+FAA+F;AAC/F,kHAAkH;AAClH,UAAU;AACV,EAAE;AACF,uGAAuG;AACvG,0GAA0G;AAC1G,wGAAwG;AACxG,gFAAgF;AAChF,EAAE;AACF,gEAAgE;AAChE,EAAE;AACF,2FAA2F;AAC3F,8FAA8F;AAC9F,+FAA+F;AAC/F,kGAAkG;AAClG,8BAA8B;AAC9B,EAAE;AACF,2DAA2D;AAC3D,EAAE;AACF,6FAA6F;AAC7F,gGAAgG;AAChG,gFAAgF;AAChF,iEAAiE;AAEjE;;;;;GAKG;AAC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CAAC,sCAAsC,CAAC,uBAAuB,CAAC;IACvF,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;CACxB,CAAC,CAAC","sourcesContent":["import { z } from \"zod\"\nimport {\n ExternalProvider_ExchangeProtocol_Kind,\n } from \"../core/commons.external-connectors-models.schemas\"\n\n//===============================================================\n// Content Safety Provider (#2292)\n// --------\n// Text → a classifier's verdict about it. Serves the content guardrails an agent declares\n// (`FlowsActors_Agent.contentGuardrails`): first PROMPT-INJECTION SCREENING of the third-party\n// content an agent reads (what its tools return, an inbound delivery that starts its turn), before its model reads it.\n//\n// ## What is screened, and why it is shaped this way\n//\n// Every vendor that publishes a prompt-attack API separates the same two inputs: the prompt the\n// person driving the conversation wrote, and DOCUMENTS — content somebody else wrote that reaches\n// the model as context (a record, a retrieved passage, a web page, an email). An instruction hidden\n// in a document is an INDIRECT injection: the person never wrote it and the model may still obey it.\n// Azure Prompt Shields takes `userPrompt` and `documents[]` and answers `attackDetected` per item;\n// Bedrock's ApplyGuardrail tags content and its `PROMPT_ATTACK` filter answers per assessment.\n// The engine screens DOCUMENTS: tool results and an inbound delivery's content are what an agent reads from other\n// people.\n//\n// spec-cite: https://learn.microsoft.com/en-us/azure/ai-services/content-safety/quickstart-jailbreak —\n// request `userPrompt` / `documents`, response `documentsAnalysis[].attackDetected` (fetched 2026-10-12).\n// spec-cite: https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-use-independent-api.html —\n// `contentPolicy.filters[].type` includes `PROMPT_ATTACK` (fetched 2026-10-12).\n//\n// ## Deliberately its own protocol kind and its own engine slot\n//\n// The DOCUMENT_EXTRACTION_PROVIDER argument, unchanged: a new `runtimeContract.kind` fails\n// COMPILATION at every switch over the union, where a new operation on an existing kind fails\n// silently; and `EngineCapability.AI_CONTENT_SAFETY` lets an application choose its classifier\n// independently of its chat model — the vendor that screens a model's input should not be decided\n// by which vendor answers it.\n//\n// ## The provider never receives a personal value in clear\n//\n// The engine screens the MODEL-SIDE text: what the model is about to read, after the agent's\n// personal-data treatment has replaced every personal field with a placeholder. So a classifier\n// vendor is a recipient of exactly what the model vendor receives, and no more.\n//===============================================================\n\n/**\n * The content-safety operation vocabulary — disjoint from every other protocol's operation keys, so a key's membership\n * decides its protocol without inspection.\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport enum ContentSafetyProvider_OperationKey {\n /** Documents (third-party text entering a prompt) → whether each carries an injection attack. */\n SCREEN_PROMPT_INJECTION = \"contentSafety.screenPromptInjection\",\n /** Text a model wrote → how severe it is in each harm category the caller asks about. */\n MODERATE_OUTPUT = \"contentSafety.moderateOutput\",\n}\n\n//===============================================================\n// Output moderation (#2292 Phase 3)\n// --------\n// What a model WROTE, judged per harm category before anyone reads it, stores it or sends it.\n//\n// The engine's vocabulary is the set of harm categories the vendors publish in common, with the severity scale they\n// share. Azure AI Content Safety `text:analyze` answers `categoriesAnalysis[].severity` for `Hate`, `Sexual`,\n// `SelfHarm` and `Violence`, on the scale 0 / 2 / 4 / 6 (`outputType: \"FourSeverityLevels\"`) that its guardrails\n// name Safe / Low / Medium / High. Bedrock ApplyGuardrail, called with `source: \"OUTPUT\"`, answers each content\n// filter (`HATE`, `SEXUAL`, `VIOLENCE`, …) with a `confidence` of NONE / LOW / MEDIUM / HIGH. A provider maps its\n// vendor's answer onto these two vocabularies and declares which categories it can assess.\n//\n// spec-cite: https://learn.microsoft.com/en-us/azure/ai-services/content-safety/quickstart-text — request `text`,\n// `categories`, `outputType`; response `categoriesAnalysis[].category` / `.severity` (fetched 2026-10-12).\n// spec-cite: https://learn.microsoft.com/en-us/azure/ai-services/content-safety/region-availability — \"Analyze text\n// API: Default maximum length: 10K characters\" (fetched 2026-10-12).\n// spec-cite: https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-use-independent-api.html — `source`\n// INPUT / OUTPUT, `contentPolicy.filters[].confidence` NONE / LOW / MEDIUM / HIGH (fetched 2026-10-12).\n//===============================================================\n\n/**\n * A harm category output moderation judges. The categories every major moderation vendor assesses; a vendor that\n * assesses fewer declares which (`assessedCategories`), and an agent asking for one its provider cannot assess is\n * refused at configuration rather than silently unjudged.\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport enum ContentSafety_HarmCategory {\n /** Attacks on, or discriminatory language about, a person or a group for who they are. */\n HATE = \"hate\",\n /** Sexual content. */\n SEXUAL = \"sexual\",\n /** Violence: threats, its glorification, instructions for it. */\n VIOLENCE = \"violence\",\n /** Self-harm and suicide: its encouragement, instructions for it. */\n SELF_HARM = \"self_harm\",\n}\n\n/**\n * How severe a text is in one harm category, from SAFE to HIGH. ORDERED: {@link contentSafetyHarmSeverityRank} gives\n * each its rank, and an agent's policy blocks at a severity \"or above\".\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport enum ContentSafety_HarmSeverity {\n /** Nothing harmful in this category (it may still name the subject, in a neutral context). */\n SAFE = \"safe\",\n LOW = \"low\",\n MEDIUM = \"medium\",\n HIGH = \"high\",\n}\n\n/** The rank of each severity, SAFE lowest. The one place the order is written down. */\nconst HARM_SEVERITY_RANK: Readonly<Record<ContentSafety_HarmSeverity, number>> = {\n [ContentSafety_HarmSeverity.SAFE]: 0,\n [ContentSafety_HarmSeverity.LOW]: 1,\n [ContentSafety_HarmSeverity.MEDIUM]: 2,\n [ContentSafety_HarmSeverity.HIGH]: 3,\n}\n\n/**\n * The rank of a severity, SAFE = 0 to HIGH = 3, for comparing two severities.\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport function contentSafetyHarmSeverityRank(severity: ContentSafety_HarmSeverity): number {\n return HARM_SEVERITY_RANK[severity]\n}\n\n/** One category's verdict, as a provider's parser returns it and the audit trail records it. */\nexport const ContentSafety_HarmCategoryVerdictSchema = z.object({\n category: z.enum(ContentSafety_HarmCategory),\n severity: z.enum(ContentSafety_HarmSeverity),\n})\nexport type ContentSafety_HarmCategoryVerdict = z.infer<typeof ContentSafety_HarmCategoryVerdictSchema>\n\n/**\n * What a provider's `parseModerationResponse` returns: a severity for each category it was asked about, or a refusal.\n * A category asked about and missing from the answer is read by the engine as \"not moderated\", never as SAFE. A\n * refusal's `message` is operator-facing and MUST NOT contain the response body or the text: it reaches logs.\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport type ContentSafety_ProviderModeration =\n | {\n moderated: true;\n categories: readonly ContentSafety_HarmCategoryVerdict[];\n }\n | {\n moderated: false;\n /** Operator-facing; MUST NOT contain the response body or the text. */\n message: string;\n };\n\n/**\n * How much text one moderation request may carry, as the vendor documents it. The engine splits a longer text and\n * judges every part, so a provider never receives a request its vendor would refuse for size. Measured in UTF-16 code\n * units, as {@link ContentSafety_PromptInjectionLimitsSchema} is.\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport const ContentSafety_OutputModerationLimitsSchema = z.object({\n /** Most characters one request may carry. */\n maxCharactersPerRequest: z.number().int().positive(),\n})\nexport type ContentSafety_OutputModerationLimits = z.infer<typeof ContentSafety_OutputModerationLimitsSchema>\n\n/**\n * What a SCREENING concluded, as the engine reads a provider's verdicts (#2292): three outcomes, and only CLEAN releases\n * the text. The content-safety protocol's own outcome vocabulary — the decision the agent runtime, the autonomous turn\n * and the audit and evidence layers all name — so it lives with the verdict shapes it summarises.\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport enum ContentSafetyScreeningOutcome {\n /** Every document was screened and none was flagged. */\n CLEAN = \"clean\",\n /** A document was flagged as carrying a prompt-injection attack. */\n ATTACK_DETECTED = \"attack_detected\",\n /** The text was not (fully) screened: no answer, a refusal, a defect in the provider's functions, or too large. */\n NOT_SCREENED = \"not_screened\",\n}\n\n/**\n * What a MODERATION concluded (#2292 Phase 3). A caller withholds what was NOT_MODERATED, and applies its own policy to the\n * severities of what was MODERATED.\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport enum ContentSafetyModerationOutcome {\n /** Every part of the text was judged in every category asked about. */\n MODERATED = \"moderated\",\n /** The text was not (fully) judged: no answer, a refusal, a category missing from an answer, a defect, or too large. */\n NOT_MODERATED = \"not_moderated\",\n}\n\n/**\n * What a provider's `parseScreenResponse` returns: one verdict per document sent, in the order sent, or a refusal.\n *\n * There is ONE failure class and so no failure vocabulary. Extraction needs two because one of them (an unreadable\n * document) changes what the caller does with the input; here every failure means the same thing to the caller — the\n * text was not screened — and the engine withholds it whatever the reason (fail closed). A refusal's `message` is\n * operator-facing and MUST NOT contain the response body or any document: it reaches logs, and a vendor error body can\n * echo request content.\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport type ContentSafety_ProviderScreening =\n | {\n screened: true;\n /** One per document sent, in the order sent. A count that differs from the documents sent is refused by the engine. */\n documents: readonly { readonly attackDetected: boolean }[];\n }\n | {\n screened: false;\n /** Operator-facing; MUST NOT contain the response body or a document. */\n message: string;\n };\n\n/**\n * How much one screening request may carry, as the vendor documents it. The engine splits a long text into documents no\n * longer than `maxCharactersPerRequest` and batches them under both limits, so a provider never receives a request its\n * vendor would refuse for size — a refusal the engine would have to read as \"not screened\" and withhold. Lengths are\n * measured in UTF-16 code units, never fewer than code points, so a limit stated in characters holds either way.\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport const ContentSafety_PromptInjectionLimitsSchema = z.object({\n /** Most documents one request may carry. */\n maxDocumentsPerRequest: z.number().int().positive(),\n /** Most characters the documents of one request may carry together. */\n maxCharactersPerRequest: z.number().int().positive(),\n});\nexport type ContentSafety_PromptInjectionLimits = z.infer<typeof ContentSafety_PromptInjectionLimitsSchema>;\n\nexport const ContentSafetyProvider_ExecutionTransportMetadataSchema = z.object({\n protocolKind: z.literal(ExternalProvider_ExchangeProtocol_Kind.CONTENT_SAFETY_PROVIDER),\n providerRef: z.string(),\n});\nexport type ContentSafetyProvider_ExecutionTransportMetadata = z.infer<typeof ContentSafetyProvider_ExecutionTransportMetadataSchema>;\n"]}
@@ -63,9 +63,10 @@ export type DocumentExtraction_ModelCatalogEntry = {
63
63
  applicabilities: readonly DocumentExtraction_Applicability[];
64
64
  };
65
65
  /**
66
- * THE document-extraction model catalog — the single per-model fact table (the
67
- * `EMBEDDINGS_MODEL_CATALOG` discipline: an EXHAUSTIVE `Record`, so a new
68
- * `DocumentExtractionProvider_Model` member without a row is a compile error).
66
+ * The ENGINE providers' document-extraction model catalog — the per-model fact table for every model an engine
67
+ * provider serves (the `EMBEDDINGS_MODEL_CATALOG` discipline: an EXHAUSTIVE `Record`, so a new
68
+ * `DocumentExtractionProvider_Model` member without a row is a compile error). A provider installed from the module
69
+ * registry states the same facts on its own contract instead (`DocumentExtraction_ModelDeclaration`, #2021).
69
70
  */
70
71
  export declare const DOCUMENT_EXTRACTION_MODEL_CATALOG: Record<DocumentExtractionProvider_Model, DocumentExtraction_ModelCatalogEntry>;
71
72
  /**
@@ -79,29 +80,60 @@ export declare const DOCUMENT_EXTRACTION_MODEL_CATALOG: Record<DocumentExtractio
79
80
  * nothing else.
80
81
  */
81
82
  export declare const DOCUMENT_EXTRACTION_MODEL_APPLICABILITY_PREFERENCE: Record<DocumentExtraction_Applicability, readonly DocumentExtractionProvider_Model[]>;
83
+ /**
84
+ * A document-extraction model a provider DECLARES itself (#2021): what the engine's catalog holds for its own providers,
85
+ * for a provider the catalog does not know.
86
+ *
87
+ * The catalog above is closed over an engine enum, which is right for the engine's providers and makes an imported one
88
+ * impossible: a provider installed from the module registry is authored in the application's own package, and the engine
89
+ * cannot hold a row for a model it has never heard of. So such a provider states the same facts on its runtime contract
90
+ * (`models` on the DOCUMENT_EXTRACTION arm), and they are held to the same use: `supportedMimeTypes` is consulted before
91
+ * any byte leaves, and `applicabilities` is what an author's class resolves against.
92
+ *
93
+ * Import path: `@wildo-ai/external-connectors-models`.
94
+ */
95
+ export type DocumentExtraction_ModelDeclaration = {
96
+ /** The vendor's model id, sent as the resolved model. */
97
+ model: string;
98
+ /** MIME types this model can process, as the vendor documents them. Lower-case. */
99
+ supportedMimeTypes: readonly string[];
100
+ /** Which applicability classes this model may be resolved for. */
101
+ applicabilities: readonly DocumentExtraction_Applicability[];
102
+ };
82
103
  /** Why {@link resolveDocumentExtractionModelForApplicability} could not answer — carried into a named CONFIGURATION error. */
83
104
  export declare enum DocumentExtraction_ModelResolutionFailure {
84
105
  /** The applicability has no candidate at all for this provider. */
85
- NO_CANDIDATE_FOR_PROVIDER = "no_candidate_for_provider"
106
+ NO_CANDIDATE_FOR_PROVIDER = "no_candidate_for_provider",
107
+ /**
108
+ * A provider the engine's catalog knows ALSO declares models. The catalog is the one place an engine provider's models
109
+ * live; a second, provider-side list could disagree with it about what may be sent, so it is refused rather than merged.
110
+ */
111
+ CATALOG_PROVIDER_DECLARES_MODELS = "catalog_provider_declares_models"
86
112
  }
87
113
  export type DocumentExtraction_ModelResolution = {
88
114
  resolved: true;
89
- model: DocumentExtractionProvider_Model;
90
- entry: DocumentExtraction_ModelCatalogEntry;
115
+ model: string;
116
+ supportedMimeTypes: readonly string[];
91
117
  } | {
92
118
  resolved: false;
93
119
  failure: DocumentExtraction_ModelResolutionFailure;
94
- consideredModels: readonly DocumentExtractionProvider_Model[];
120
+ consideredModels: readonly string[];
95
121
  };
96
122
  /**
97
123
  * Resolve an applicability class to ONE concrete extraction model for a given provider.
98
124
  *
99
- * Fails CLOSED and explains itself (the `resolveModelForApplicability` contract): a silent
100
- * fallback to some other model would send application documents to a model nobody chose.
125
+ * A provider the engine's catalog knows resolves from the catalog and its preference order, and may not also declare
126
+ * models. Any other provider (one installed from the module registry, #2021) resolves from the models it declares, in
127
+ * the order it declares them.
128
+ *
129
+ * Fails CLOSED and explains itself (the `resolveModelForApplicability` contract): a silent fallback to some other model
130
+ * would send application documents to a model nobody chose.
101
131
  */
102
132
  export declare const resolveDocumentExtractionModelForApplicability: (input: {
103
133
  applicability: DocumentExtraction_Applicability;
104
134
  providerRef: string;
135
+ /** The `models` the provider's runtime contract declares. Absent or empty for an engine provider. */
136
+ declaredModels?: readonly DocumentExtraction_ModelDeclaration[];
105
137
  }, catalog?: Record<DocumentExtractionProvider_Model, DocumentExtraction_ModelCatalogEntry>) => DocumentExtraction_ModelResolution;
106
138
  /**
107
139
  * Usage of one extraction call.
@@ -1 +1 @@
1
- {"version":3,"file":"document-extraction.external-connectors-models.schemas.d.ts","sourceRoot":"","sources":["../../../src/protocols/document-extraction.external-connectors-models.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACL,sCAAsC,EACrC,MAAM,oDAAoD,CAAA;AAmC7D;;;;GAIG;AACH,oBAAY,gCAAgC;IAC1C;;;;;;OAMG;IACH,kBAAkB,uBAAuB;CAC1C;AAED;;;;;;;GAOG;AACH,oBAAY,uCAAuC;IACjD,qDAAqD;IACrD,qBAAqB,2CAA2C;CACjE;AAED;;;;;;;;;;;GAWG;AACH,oBAAY,gCAAgC;IAC1C,+FAA+F;IAC/F,qBAAqB,0BAA0B;CAChD;AACD,uFAAuF;AAEvF;;;GAGG;AACH,MAAM,MAAM,oCAAoC,GAAG;IACjD,4DAA4D;IAC5D,WAAW,EAAE,MAAM,CAAC;IACpB;;;;;;OAMG;IACH,kBAAkB,EAAE,SAAS,MAAM,EAAE,CAAC;IACtC,sFAAsF;IACtF,eAAe,EAAE,SAAS,gCAAgC,EAAE,CAAC;CAC9D,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CACpD,gCAAgC,EAChC,oCAAoC,CAmBrC,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kDAAkD,EAAE,MAAM,CACrE,gCAAgC,EAChC,SAAS,gCAAgC,EAAE,CAK5C,CAAC;AAEF,8HAA8H;AAC9H,oBAAY,yCAAyC;IACnD,mEAAmE;IACnE,yBAAyB,8BAA8B;CACxD;AAED,MAAM,MAAM,kCAAkC,GAC1C;IAAE,QAAQ,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,gCAAgC,CAAC;IAAC,KAAK,EAAE,oCAAoC,CAAA;CAAE,GACxG;IACE,QAAQ,EAAE,KAAK,CAA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,EAAE,gCAAgC,CAAC;CAC1C,GACD;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,YAAY,EAAE,+BAA+B,CAAC;IAC9C;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN;;;;;;;;;;;;;GAaG;AACH,oBAAY,8BAA8B;IACxC,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;CACpC;AAED;;;;GAIG;AACH,MAAM,MAAM,gCAAgC,GACxC;IACE,SAAS,EAAE,IAAI,CAAC;IAChB,oGAAoG;IACpG,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,YAAY,EAAE,+BAA+B,CAAC;IAC9C,4GAA4G;IAC5G,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,iGAAiG;AACjG,oBAAY,2BAA2B;IACrC,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,0BAA0B,GAClC;IAAE,KAAK,EAAE,2BAA2B,CAAC,OAAO,CAAA;CAAE,GAC9C;IAAE,KAAK,EAAE,2BAA2B,CAAC,QAAQ,CAAC;IAAC,UAAU,EAAE,qCAAqC,CAAA;CAAE,CAAC;AAEvG;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oCAAoC,GAAI,QAAQ,MAAM,KAAG,+BAOrE,CAAC"}
1
+ {"version":3,"file":"document-extraction.external-connectors-models.schemas.d.ts","sourceRoot":"","sources":["../../../src/protocols/document-extraction.external-connectors-models.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACL,sCAAsC,EACrC,MAAM,oDAAoD,CAAA;AAmC7D;;;;GAIG;AACH,oBAAY,gCAAgC;IAC1C;;;;;;OAMG;IACH,kBAAkB,uBAAuB;CAC1C;AAED;;;;;;;GAOG;AACH,oBAAY,uCAAuC;IACjD,qDAAqD;IACrD,qBAAq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AAC;IAC9C;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN;;;;;;;;;;;;;GAaG;AACH,oBAAY,8BAA8B;IACxC,cAAc,mBAAmB;IACjC,eAAe,oBAAoB;CACpC;AAED;;;;GAIG;AACH,MAAM,MAAM,gCAAgC,GACxC;IACE,SAAS,EAAE,IAAI,CAAC;IAChB,oGAAoG;IACpG,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,SAAS,EAAE,KAAK,CAAC;IACjB,YAAY,EAAE,+BAA+B,CAAC;IAC9C,4GAA4G;IAC5G,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEN,iGAAiG;AACjG,oBAAY,2BAA2B;IACrC,OAAO,YAAY;IACnB,QAAQ,aAAa;CACtB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,0BAA0B,GAClC;IAAE,KAAK,EAAE,2BAA2B,CAAC,OAAO,CAAA;CAAE,GAC9C;IAAE,KAAK,EAAE,2BAA2B,CAAC,QAAQ,CAAC;IAAC,UAAU,EAAE,qCAAqC,CAAA;CAAE,CAAC;AAEvG;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oCAAoC,GAAI,QAAQ,MAAM,KAAG,+BAOrE,CAAC"}
@@ -79,9 +79,10 @@ export var DocumentExtraction_Applicability;
79
79
  DocumentExtraction_Applicability["DOCUMENT_TEXT_DEFAULT"] = "document-text-default";
80
80
  })(DocumentExtraction_Applicability || (DocumentExtraction_Applicability = {}));
81
81
  /**
82
- * THE document-extraction model catalog — the single per-model fact table (the
83
- * `EMBEDDINGS_MODEL_CATALOG` discipline: an EXHAUSTIVE `Record`, so a new
84
- * `DocumentExtractionProvider_Model` member without a row is a compile error).
82
+ * The ENGINE providers' document-extraction model catalog — the per-model fact table for every model an engine
83
+ * provider serves (the `EMBEDDINGS_MODEL_CATALOG` discipline: an EXHAUSTIVE `Record`, so a new
84
+ * `DocumentExtractionProvider_Model` member without a row is a compile error). A provider installed from the module
85
+ * registry states the same facts on its own contract instead (`DocumentExtraction_ModelDeclaration`, #2021).
85
86
  */
86
87
  export const DOCUMENT_EXTRACTION_MODEL_CATALOG = {
87
88
  [DocumentExtractionProvider_Model.MISTRAL_OCR_LATEST]: {
@@ -122,28 +123,53 @@ export var DocumentExtraction_ModelResolutionFailure;
122
123
  (function (DocumentExtraction_ModelResolutionFailure) {
123
124
  /** The applicability has no candidate at all for this provider. */
124
125
  DocumentExtraction_ModelResolutionFailure["NO_CANDIDATE_FOR_PROVIDER"] = "no_candidate_for_provider";
126
+ /**
127
+ * A provider the engine's catalog knows ALSO declares models. The catalog is the one place an engine provider's models
128
+ * live; a second, provider-side list could disagree with it about what may be sent, so it is refused rather than merged.
129
+ */
130
+ DocumentExtraction_ModelResolutionFailure["CATALOG_PROVIDER_DECLARES_MODELS"] = "catalog_provider_declares_models";
125
131
  })(DocumentExtraction_ModelResolutionFailure || (DocumentExtraction_ModelResolutionFailure = {}));
126
132
  /**
127
133
  * Resolve an applicability class to ONE concrete extraction model for a given provider.
128
134
  *
129
- * Fails CLOSED and explains itself (the `resolveModelForApplicability` contract): a silent
130
- * fallback to some other model would send application documents to a model nobody chose.
135
+ * A provider the engine's catalog knows resolves from the catalog and its preference order, and may not also declare
136
+ * models. Any other provider (one installed from the module registry, #2021) resolves from the models it declares, in
137
+ * the order it declares them.
138
+ *
139
+ * Fails CLOSED and explains itself (the `resolveModelForApplicability` contract): a silent fallback to some other model
140
+ * would send application documents to a model nobody chose.
131
141
  */
132
142
  export const resolveDocumentExtractionModelForApplicability = (input, catalog = DOCUMENT_EXTRACTION_MODEL_CATALOG) => {
133
- const candidates = DOCUMENT_EXTRACTION_MODEL_APPLICABILITY_PREFERENCE[input.applicability];
134
- const forProvider = candidates.filter((model) => {
135
- const entry = catalog[model];
136
- return entry.providerRef === input.providerRef && entry.applicabilities.includes(input.applicability);
137
- });
138
- if (forProvider.length === 0) {
143
+ const declaredModels = input.declaredModels ?? [];
144
+ const catalogKnowsProvider = Object.values(catalog).some((entry) => entry.providerRef === input.providerRef);
145
+ if (catalogKnowsProvider) {
146
+ const candidates = DOCUMENT_EXTRACTION_MODEL_APPLICABILITY_PREFERENCE[input.applicability];
147
+ if (declaredModels.length > 0) {
148
+ return {
149
+ resolved: false,
150
+ failure: DocumentExtraction_ModelResolutionFailure.CATALOG_PROVIDER_DECLARES_MODELS,
151
+ consideredModels: declaredModels.map((declaration) => declaration.model),
152
+ };
153
+ }
154
+ const forProvider = candidates.filter((model) => {
155
+ const entry = catalog[model];
156
+ return entry.providerRef === input.providerRef && entry.applicabilities.includes(input.applicability);
157
+ });
158
+ if (forProvider.length === 0) {
159
+ return { resolved: false, failure: DocumentExtraction_ModelResolutionFailure.NO_CANDIDATE_FOR_PROVIDER, consideredModels: candidates };
160
+ }
161
+ const model = forProvider[0];
162
+ return { resolved: true, model, supportedMimeTypes: catalog[model].supportedMimeTypes };
163
+ }
164
+ const declared = declaredModels.find((declaration) => declaration.applicabilities.includes(input.applicability));
165
+ if (declared === undefined) {
139
166
  return {
140
167
  resolved: false,
141
168
  failure: DocumentExtraction_ModelResolutionFailure.NO_CANDIDATE_FOR_PROVIDER,
142
- consideredModels: candidates,
169
+ consideredModels: declaredModels.map((declaration) => declaration.model),
143
170
  };
144
171
  }
145
- const model = forProvider[0];
146
- return { resolved: true, model, entry: catalog[model] };
172
+ return { resolved: true, model: declared.model, supportedMimeTypes: declared.supportedMimeTypes };
147
173
  };
148
174
  // ===============================================================
149
175
  // Document Extraction Operations Context
@@ -1 +1 @@
1
- {"version":3,"file":"document-extraction.external-connectors-models.schemas.js","sourceRoot":"","sources":["../../../../src/protocols/document-extraction.external-connectors-models.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACL,sCAAsC,GACrC,MAAM,oDAAoD,CAAA;AAE7D,iEAAiE;AACjE,+BAA+B;AAC/B,WAAW;AACX,iEAAiE;AACjE,6EAA6E;AAC7E,mD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AaG;AACH,MAAM,CAAN,IAAY,+BAaX;AAbD,WAAY,+BAA+B;IACzC;;;;OAIG;IACH,8EAA2C,CAAA;IAC3C;;;;OAIG;IACH,gFAA6C,CAAA;AAC/C,CAAC,EAbW,+BAA+B,KAA/B,+BAA+B,QAa1C;AAiCD;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAN,IAAY,8BAGX;AAHD,WAAY,8BAA8B;IACxC,mEAAiC,CAAA;IACjC,qEAAmC,CAAA;AACrC,CAAC,EAHW,8BAA8B,KAA9B,8BAA8B,QAGzC;AAoBD,iGAAiG;AACjG,MAAM,CAAN,IAAY,2BAGX;AAHD,WAAY,2BAA2B;IACrC,kDAAmB,CAAA;IACnB,oDAAqB,CAAA;AACvB,CAAC,EAHW,2BAA2B,KAA3B,2BAA2B,QAGtC;AAgBD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,CAAC,MAAc,EAAmC,EAAE;IACtG,MAAM,iBAAiB,GAAG,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,CAAC;IAC3D,MAAM,mBAAmB,GAAG,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,CAAC;IAC7D,MAAM,aAAa,GAAG,MAAM,IAAI,GAAG,CAAC;IACpC,OAAO,iBAAiB,IAAI,mBAAmB,IAAI,aAAa;QAC9D,CAAC,CAAC,+BAA+B,CAAC,oBAAoB;QACtD,CAAC,CAAC,+BAA+B,CAAC,mBAAmB,CAAC;AAC1D,CAAC,CAAC","sourcesContent":["import { z } from \"zod\"\nimport {\n ExternalProvider_ExchangeProtocol_Kind,\n } from \"../core/commons.external-connectors-models.schemas\"\n\n//===============================================================\n// Document Extraction Provider\n// --------\n// Document bytes → text. Serves the file-side TEXT PROVIDER that\n// `FileTextExtractionBackendService` owns, whose largest consumer is the RAG\n// ingestion path (`.ragSource()` corpus building).\n//\n// ## Why this is a provider at all, and not just a better library\n//\n// The local `pdfjs-dist` path reads a PDF's TEXT LAYER. A scanned document — the\n// common case for uploaded contracts, invoices and forms — is an IMAGE of a page\n// and carries no text layer, so it extracts to the empty string, contributes no\n// chunks, and becomes silently unanswerable. That is not a defect in the local\n// library; it is its nature, and it is the entire reason a provider exists here.\n//\n// ## Deliberately a SEPARATE protocol kind from `LLM_PROVIDER`\n//\n// Same reasoning as `EMBEDDINGS_PROVIDER` (RAG plan DL2) and the `IMAGE_PROVIDER`\n// precedent before it: an unmapped LLM operation key fails SILENTLY across every\n// consumer surface (the registry's semantic-operation map filters it out, the\n// executor never dispatches it, the capability slot never fills), whereas a new\n// `runtimeContract.kind` fails COMPILATION at every switch over the union. That\n// compile-enforcement is the whole argument, and it is verified rather than\n// asserted — deleting an arm from `describeProviderProtocolSecretRef` reddens the\n// `never` check with the offending contract named in the diagnostic.\n//\n// It also fills its own `EngineCapability.AI_DOCUMENT_EXTRACTION` slot, so an\n// application selects its OCR provider INDEPENDENTLY of its chat and embeddings\n// providers. Those are three unrelated procurement decisions — a deployment may\n// well want Anthropic for chat, OpenAI for embeddings, and Mistral for OCR — and\n// fusing any two of them into one `selection` entry makes that unexpressible.\n//===============================================================\n\n/**\n * Concrete document-extraction model ids the framework knows.\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport enum DocumentExtractionProvider_Model {\n /**\n * Mistral's OCR model alias. An ALIAS deliberately, not a dated snapshot: unlike an embedding\n * model — where the concrete id is persisted as a stamp on every chunk and a silent change\n * would fracture the vector space — extraction output is consumed immediately and re-derived\n * on every ingestion pass, so tracking the vendor's current model is a benefit rather than a\n * hazard.\n */\n MISTRAL_OCR_LATEST = \"mistral-ocr-latest\",\n}\n\n/**\n * The document-extraction operation vocabulary — deliberately DISJOINT from\n * `LLMProvider_OperationKey`, `ImageProvider_OperationKey` and\n * `EmbeddingsProvider_OperationKey` (each protocol kind owns its own operation enum, so a key's\n * membership decides its protocol without inspection).\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport enum DocumentExtractionProvider_OperationKey {\n /** One document's bytes → its text, page by page. */\n EXTRACT_DOCUMENT_TEXT = \"documentExtraction.extractDocumentText\",\n}\n\n/**\n * @wildo_source:part:start saas.external-providers.document-extraction.applicability facet:kind:api facet:audience:app-developer\n *\n * WHAT a document is being extracted FOR — the durable axis of extraction-model selection\n * (model-selection-by-applicability rule: an author names a CLASS, never a concrete model id;\n * the framework resolves the id from the catalog + preference below).\n *\n * One class today, and that is a statement rather than a placeholder: every extraction in the\n * engine feeds `FileTextExtractionBackendService`, and a second class would only be earned by a\n * surface with genuinely different requirements (a layout-preserving export, say, or a\n * cheap-and-approximate preview tier).\n */\nexport enum DocumentExtraction_Applicability {\n /** The default document-text surface: file text extraction, and the RAG corpus built on it. */\n DOCUMENT_TEXT_DEFAULT = \"document-text-default\",\n}\n/** @wildo_source:part:end saas.external-providers.document-extraction.applicability */\n\n/**\n * One row per document-extraction model: everything the framework knows about a concrete id.\n * Mirrors `Embeddings_ModelCatalogEntry`'s shape at the size this axis needs today.\n */\nexport type DocumentExtraction_ModelCatalogEntry = {\n /** The `ref` of the provider module that serves this id. */\n providerRef: string;\n /**\n * MIME types this model can process, as declared by the provider's documentation.\n *\n * Consulted BEFORE bytes leave the deployment: sending a document the model cannot read wastes\n * an egress of application content, which the data-minimization posture on the execution seam\n * exists to avoid.\n */\n supportedMimeTypes: readonly string[];\n /** FRAMEWORK OPINION — which applicability classes this model may be resolved for. */\n applicabilities: readonly DocumentExtraction_Applicability[];\n};\n\n/**\n * THE document-extraction model catalog — the single per-model fact table (the\n * `EMBEDDINGS_MODEL_CATALOG` discipline: an EXHAUSTIVE `Record`, so a new\n * `DocumentExtractionProvider_Model` member without a row is a compile error).\n */\nexport const DOCUMENT_EXTRACTION_MODEL_CATALOG: Record<\n DocumentExtractionProvider_Model,\n DocumentExtraction_ModelCatalogEntry\n> = {\n [DocumentExtractionProvider_Model.MISTRAL_OCR_LATEST]: {\n providerRef: \"mistral\",\n /**\n * Mistral's published OCR format list (docs.mistral.ai \"Known limitations\": \"Supported\n * formats for OCR: PDF, PNG, JPG, JPEG, TIFF, BMP, GIF, WEBP\"), narrowed to the MIME types\n * the engine's own extraction gate admits today.\n *\n * `application/pdf` is the only entry that is currently REACHABLE: image MIME types are\n * refused by `FileTextExtractionBackendService.isExtractionSupported`, which is a separate,\n * deliberate decision (an uploaded photo is not a document). The image types are declared\n * here anyway because this row states what the MODEL can do, not what the engine currently\n * asks it to do — and admitting images to extraction later must be an engine decision, not\n * an accidental consequence of a catalog edit.\n */\n supportedMimeTypes: [\"application/pdf\", \"image/png\", \"image/jpeg\", \"image/tiff\", \"image/webp\"],\n applicabilities: [DocumentExtraction_Applicability.DOCUMENT_TEXT_DEFAULT],\n },\n};\n\n/**\n * The framework's DEFAULT answer to \"which extraction model serves this class\", ordered by\n * preference, highest first.\n *\n * Unlike the embeddings preference — which is a MIGRATION KEY, because editing it re-binds a\n * class and forces every stamped chunk to be re-embedded — this one carries no durable\n * consequence: extraction output is re-derived on the next ingestion pass and nothing persists\n * the model that produced it. Editing this list changes what the next extraction uses and\n * nothing else.\n */\nexport const DOCUMENT_EXTRACTION_MODEL_APPLICABILITY_PREFERENCE: Record<\n DocumentExtraction_Applicability,\n readonly DocumentExtractionProvider_Model[]\n> = {\n [DocumentExtraction_Applicability.DOCUMENT_TEXT_DEFAULT]: [\n DocumentExtractionProvider_Model.MISTRAL_OCR_LATEST,\n ],\n};\n\n/** Why {@link resolveDocumentExtractionModelForApplicability} could not answer — carried into a named CONFIGURATION error. */\nexport enum DocumentExtraction_ModelResolutionFailure {\n /** The applicability has no candidate at all for this provider. */\n NO_CANDIDATE_FOR_PROVIDER = \"no_candidate_for_provider\",\n}\n\nexport type DocumentExtraction_ModelResolution =\n | { resolved: true; model: DocumentExtractionProvider_Model; entry: DocumentExtraction_ModelCatalogEntry }\n | {\n resolved: false;\n failure: DocumentExtraction_ModelResolutionFailure;\n consideredModels: readonly DocumentExtractionProvider_Model[];\n };\n\n/**\n * Resolve an applicability class to ONE concrete extraction model for a given provider.\n *\n * Fails CLOSED and explains itself (the `resolveModelForApplicability` contract): a silent\n * fallback to some other model would send application documents to a model nobody chose.\n */\nexport const resolveDocumentExtractionModelForApplicability = (\n input: { applicability: DocumentExtraction_Applicability; providerRef: string },\n catalog: Record<DocumentExtractionProvider_Model, DocumentExtraction_ModelCatalogEntry> = DOCUMENT_EXTRACTION_MODEL_CATALOG,\n): DocumentExtraction_ModelResolution => {\n const candidates = DOCUMENT_EXTRACTION_MODEL_APPLICABILITY_PREFERENCE[input.applicability];\n const forProvider = candidates.filter((model) => {\n const entry = catalog[model];\n return entry.providerRef === input.providerRef && entry.applicabilities.includes(input.applicability);\n });\n if (forProvider.length === 0) {\n return {\n resolved: false,\n failure: DocumentExtraction_ModelResolutionFailure.NO_CANDIDATE_FOR_PROVIDER,\n consideredModels: candidates,\n };\n }\n const model = forProvider[0]!;\n return { resolved: true, model, entry: catalog[model] };\n};\n\n// ===============================================================\n// Document Extraction Operations Context\n// ===============================================================\n\n/**\n * Usage of one extraction call.\n *\n * There is NO token dimension, and its absence is structural rather than an omission: an OCR\n * call is billed and reported per PAGE, not per token. Any consumer judging usage completeness\n * for an extraction must do so on `pagesProcessed` alone — the operation-aware discipline the\n * embeddings arm records for its own missing completion-token dimension.\n */\nexport const DocumentExtractionProvider_UsageSchema = z.object({\n /**\n * Pages the provider reports having processed.\n *\n * The FRAMEWORK's name for the dimension. Which vendor field it is projected from is the\n * provider's `parseExtractResponse` to know — the wired one reads Mistral's\n * `usage_info.pages_processed`, and a second provider will read something else.\n */\n pagesProcessed: z.number().optional(),\n /** Document size the provider reports having received. Same ownership as `pagesProcessed`. */\n documentSizeBytes: z.number().optional(),\n});\nexport type DocumentExtractionProvider_Usage = z.infer<typeof DocumentExtractionProvider_UsageSchema>;\n\nexport const DocumentExtractionProvider_ExecutionTransportMetadataSchema = z.object({\n protocolKind: z.literal(ExternalProvider_ExchangeProtocol_Kind.DOCUMENT_EXTRACTION_PROVIDER),\n providerRef: z.string(),\n model: z.string().optional(),\n});\nexport type DocumentExtractionProvider_ExecutionTransportMetadata = z.infer<\n typeof DocumentExtractionProvider_ExecutionTransportMetadataSchema\n>;\n\n// ===============================================================\n// Document Extraction I/O Schemas\n// ===============================================================\n\n/**\n * Input DESCRIPTOR of the {@link DocumentExtractionProvider_OperationKey.EXTRACT_DOCUMENT_TEXT}\n * operation — the metadata about the document, deliberately NOT the document.\n *\n * ⚠️ THE BYTES ARE ABSENT ON PURPOSE, and this is the design decision most likely to be\n * \"corrected\" by a later reader. A `documentBase64: z.string()` field here would be structurally\n * correct and operationally dangerous: a Zod-shaped input object is the thing every diagnostic\n * path in this codebase reaches for when something goes wrong — error `context`, debug logs,\n * agent-call traces — and a multi-megabyte base64 blob of an application's private contract is\n * the single worst payload to make casually loggable. The embeddings arm reached the same\n * conclusion from the other direction (its header forbids raw texts and vectors from ever\n * entering a trace); here the prohibition is enforced by the SHAPE rather than by discipline.\n *\n * The bytes travel as a `Buffer` on the execution service's own request type, which no\n * serializer walks.\n */\nexport const DocumentExtractionProvider_ExtractDocumentTextInputSchema = z.object({\n /** The document's MIME type — checked against the model's catalog row before any egress. */\n mimeType: z.string(),\n /** Byte length of the document being sent. Diagnostic and ceiling-checking only. */\n documentByteLength: z.number().int().nonnegative(),\n});\nexport type DocumentExtractionProvider_ExtractDocumentTextInput = z.infer<\n typeof DocumentExtractionProvider_ExtractDocumentTextInputSchema\n>;\n\n/**\n * Output of {@link DocumentExtractionProvider_OperationKey.EXTRACT_DOCUMENT_TEXT}.\n *\n * `text` is the concatenation of the provider's per-page output in document order. Providers in\n * this family return MARKDOWN per page (Mistral's `pages[].markdown`), which is kept as-is:\n * headings and table structure are signal for a retrieval corpus, and stripping them to \"plain\"\n * text would discard information the provider was paid to recover.\n */\nexport const DocumentExtractionProvider_ExtractDocumentTextOutputSchema = z.object({\n text: z.string(),\n /** Pages the provider actually returned — the authoritative count, not the request's estimate. */\n pageCount: z.number().int().nonnegative(),\n /** The concrete model that produced the text. */\n model: z.string(),\n usage: DocumentExtractionProvider_UsageSchema,\n});\nexport type DocumentExtractionProvider_ExtractDocumentTextOutput = z.infer<\n typeof DocumentExtractionProvider_ExtractDocumentTextOutputSchema\n>;\n\n// ===============================================================\n// The PROVIDER-OWNED WIRE SEAM\n// --------\n// Until 2026-09-09 this arm declared `baseUrl`, `endpointPath`, `apiKey` and `models` — where the\n// call goes and how it authenticates — and NOTHING about the body or the response. So the engine's\n// execution seam composed Mistral's `/v1/ocr` request (`document: { type: 'document_url',\n// document_url }`, `include_image_base64`) and read Mistral's response (`pages[].markdown`,\n// `usage_info.pages_processed`) with the vendor named nowhere, and a second provider declaring\n// DOCUMENT_EXTRACTION_PROVIDER would have been sent through Mistral's API carrying its own key.\n//\n// The remedy is the one the EMAIL and SMS arms already converged on: the provider declares PURE\n// FUNCTIONS and the engine owns transport and credentials. The types those functions are written\n// against live HERE rather than beside the contract, because the failure vocabulary is read by\n// BOTH sides — the provider produces it, the engine's caller branches on it — and a vocabulary\n// with two homes is a vocabulary that drifts.\n// ===============================================================\n\n/**\n * WHY an extraction failed, in the only two senses a caller can act on differently.\n *\n * This is the arm's most load-bearing output after the text itself, and the consequence of\n * confusing the two is CORPUS DELETION rather than a misleading log line:\n * `RagIngestionBackendService` deletes a field's entire chunk set when an ingestion pass yields no\n * text, so reporting a provider OUTAGE as an unreadable document silently destroys a live,\n * already-embedded corpus and reports success.\n *\n * It lived in `saas-backend-lib`'s execution seam until 2026-09-09, which is exactly why the wire\n * shape lived there too: a vocabulary a provider cannot reach is one a provider cannot answer in,\n * so classification had to be done by whoever could. Moving it here is what makes\n * {@link DocumentExtraction_ProviderExtraction} expressible at all.\n */\nexport enum DocumentExtraction_FailureClass {\n /**\n * The provider read the request and judged the DOCUMENT unprocessable — corrupt bytes, an\n * unsupported format, a password-protected file. PERMANENT: re-sending the same bytes cannot\n * succeed, so a sweep may safely stop retrying and skip the document.\n */\n UNREADABLE_DOCUMENT = \"unreadable_document\",\n /**\n * The provider could not be reached, refused the credential, throttled, or failed internally —\n * a network error, a 401/403, a 429, any 5xx, or a timeout. TRANSIENT and, decisively, says\n * NOTHING about the document. A caller must not conclude anything about the bytes from this.\n */\n PROVIDER_UNAVAILABLE = \"provider_unavailable\",\n}\n\n/**\n * What a provider's `parseExtractResponse` returns, and what a COMPLETE poll carries (#2020): the extraction, or a\n * CLASSIFIED refusal.\n *\n * A discriminated union rather than \"return the output or throw\", for the reason the failure class\n * exists: a thrown `Error` carries no class, and the engine would have to guess one — which is the\n * guess that deletes a corpus. A provider that cannot classify a response must still say which of\n * the two it is, and the arm's JSDoc tells it to prefer `PROVIDER_UNAVAILABLE` when unsure,\n * because that is the answer with no destructive consequence.\n */\nexport type DocumentExtraction_ProviderExtraction =\n | {\n extracted: true;\n /** Per-page text joined in document order. Markdown is kept as-is; see the output schema. */\n text: string;\n /** Pages the provider actually returned — the authoritative count, not the request estimate. */\n pageCount: number;\n /** The model the provider says produced the text. Absent means \"the resolved model\". */\n model?: string;\n usage?: DocumentExtractionProvider_Usage;\n }\n | {\n extracted: false;\n failureClass: DocumentExtraction_FailureClass;\n /**\n * Operator-facing reason. MUST NOT contain the provider's response body or any part of the\n * document: this message reaches logs, and a provider error body can echo request content.\n */\n message: string;\n };\n\n/**\n * HOW a document-extraction provider exchanges with its vendor (#2020) — the discriminator of the runtime arm's\n * `exchange`.\n *\n * Two shapes exist in the field and they cannot be folded into one:\n * - SINGLE_REQUEST: one request carries the document and the answer carries the text (Mistral OCR).\n * - SUBMIT_AND_POLL: the vendor accepts the document, answers with a job, and the text is fetched later by polling\n * that job until it is done (Azure Document Intelligence's `Operation-Location`, VLM Run). Asynchronous Textract is\n * a job-based vendor this form does NOT serve (SigV4, S3 input, POST polls); see the private exchange type.\n * Folding this into one request is what #2001 showed failing: the first request answers a job id, not text.\n *\n * A closed vocabulary with one home, so the engine's switch over it is exhaustive: a new form, or a deleted one, is a\n * compile error at the one place that executes the exchange.\n */\nexport enum DocumentExtractionExchangeForm {\n SINGLE_REQUEST = \"single-request\",\n SUBMIT_AND_POLL = \"submit-and-poll\",\n}\n\n/**\n * What a SUBMIT_AND_POLL provider's `parseSubmitResponse` returns: the vendor's job id, or a CLASSIFIED refusal. The\n * refusal carries the same two classes as an extraction, for the same reason: a vendor refusing THIS document at\n * submission is permanent, an outage is not, and confusing them deletes a corpus.\n */\nexport type DocumentExtraction_JobSubmission =\n | {\n submitted: true;\n /** The vendor's identifier for the job. Opaque to the engine; handed back to `buildPollRequest`. */\n jobId: string;\n }\n | {\n submitted: false;\n failureClass: DocumentExtraction_FailureClass;\n /** Operator-facing; MUST NOT contain the response body or the document (see the extraction's `message`). */\n message: string;\n };\n\n/** Where a polled job stands. PENDING keeps the engine polling until the provider's deadline. */\nexport enum DocumentExtraction_JobState {\n PENDING = \"pending\",\n COMPLETE = \"complete\",\n}\n\n/**\n * What a SUBMIT_AND_POLL provider's `parsePollResponse` returns for one poll: still running, or done — with the\n * extraction or its classified refusal, exactly what a single-request parser returns.\n *\n * COMPLETE means the VENDOR says the job has ended. A job the vendor reports failed is COMPLETE with a refusal, and\n * only then may the engine submit the document again, because only then is nothing still running. A poll the vendor\n * answered with a transient error (a 5xx or 429 on the poll route) says nothing about the job, so it is PENDING: the\n * engine polls again until the deadline. Reading it as COMPLETE would stop the engine while the job may still run,\n * and a retry would then pay the vendor twice for one document.\n */\nexport type DocumentExtraction_JobPoll =\n | { state: DocumentExtraction_JobState.PENDING }\n | { state: DocumentExtraction_JobState.COMPLETE; extraction: DocumentExtraction_ProviderExtraction };\n\n/**\n * The framework's DEFAULT reading of an extraction response's HTTP status.\n *\n * Offered to every provider's `parseExtractResponse` rather than applied by the engine, because\n * only the provider knows whether its vendor also signals a per-document verdict inside a 2xx\n * body (Twilio does exactly that on the SMS arm). What it prevents is each provider re-deriving a\n * classification whose worst case is corpus deletion.\n *\n * Every boundary is deliberate:\n * - 4xx generally means the provider READ the request and refused THIS DOCUMENT → permanent.\n * - 401/403 is a CREDENTIAL fault, not a document fault. Classifying it as unreadable would make\n * a rotated key look like a corpus of corrupt files and delete chunk sets across every\n * document for as long as the key was wrong.\n * - 408/429 are explicitly retryable by their own definition.\n * - 5xx is the provider's fault, never the document's.\n */\nexport const classifyDocumentExtractionHttpStatus = (status: number): DocumentExtraction_FailureClass => {\n const isCredentialFault = status === 401 || status === 403;\n const isThrottleOrTimeout = status === 408 || status === 429;\n const isServerFault = status >= 500;\n return isCredentialFault || isThrottleOrTimeout || isServerFault\n ? DocumentExtraction_FailureClass.PROVIDER_UNAVAILABLE\n : DocumentExtraction_FailureClass.UNREADABLE_DOCUMENT;\n};\n\n"]}
1
+ {"version":3,"file":"document-extraction.external-connectors-models.schemas.js","sourceRoot":"","sources":["../../../src/protocols/document-extraction.external-connectors-models.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,EACL,sCAAsC,GACrC,MAAM,oDAAoD,CAAA;AAE7D,iEAAiE;AACjE,+BAA+B;AAC/B,WAAW;AACX,iEAAiE;AACjE,6EAA6E;AAC7E,mDAAmD;AACnD,EAAE;AACF,kEAAkE;AAClE,EAAE;AACF,iFAAiF;AACjF,iFAAiF;AACjF,gFAAgF;AAChF,+EAA+E;AAC/E,iFAAiF;AACjF,EAAE;AACF,+DAA+D;AAC/D,EAAE;AACF,kFAAkF;AAClF,iFAAiF;AACjF,8EAA8E;AAC9E,gFAAgF;AAChF,gFAAgF;AAChF,4EAA4E;AAC5E,kFAAkF;AAClF,qEAAqE;AACrE,EAAE;AACF,8EAA8E;AAC9E,gFAAgF;AAChF,gFAAgF;AAChF,iFAAiF;AACjF,8EAA8E;AAC9E,iEAAiE;AAEjE;;;;GAIG;AACH,MAAM,CAAN,IAAY,gCASX;AATD,WAAY,gCAAgC;IAC1C;;;;;;OAMG;IACH,6EAAyC,CAAA;AAC3C,CAAC,EATW,gCAAgC,KAAhC,gCAAgC,QAS3C;AAED;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,u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,MAAM,KAAK,GAAG,IAAI,MAAM,KAAK,GAAG,CAAC;IAC7D,MAAM,aAAa,GAAG,MAAM,IAAI,GAAG,CAAC;IACpC,OAAO,iBAAiB,IAAI,mBAAmB,IAAI,aAAa;QAC9D,CAAC,CAAC,+BAA+B,CAAC,oBAAoB;QACtD,CAAC,CAAC,+BAA+B,CAAC,mBAAmB,CAAC;AAC1D,CAAC,CAAC","sourcesContent":["import { z } from \"zod\"\nimport {\n ExternalProvider_ExchangeProtocol_Kind,\n } from \"../core/commons.external-connectors-models.schemas\"\n\n//===============================================================\n// Document Extraction Provider\n// --------\n// Document bytes → text. Serves the file-side TEXT PROVIDER that\n// `FileTextExtractionBackendService` owns, whose largest consumer is the RAG\n// ingestion path (`.ragSource()` corpus building).\n//\n// ## Why this is a provider at all, and not just a better library\n//\n// The local `pdfjs-dist` path reads a PDF's TEXT LAYER. A scanned document — the\n// common case for uploaded contracts, invoices and forms — is an IMAGE of a page\n// and carries no text layer, so it extracts to the empty string, contributes no\n// chunks, and becomes silently unanswerable. That is not a defect in the local\n// library; it is its nature, and it is the entire reason a provider exists here.\n//\n// ## Deliberately a SEPARATE protocol kind from `LLM_PROVIDER`\n//\n// Same reasoning as `EMBEDDINGS_PROVIDER` (RAG plan DL2) and the `IMAGE_PROVIDER`\n// precedent before it: an unmapped LLM operation key fails SILENTLY across every\n// consumer surface (the registry's semantic-operation map filters it out, the\n// executor never dispatches it, the capability slot never fills), whereas a new\n// `runtimeContract.kind` fails COMPILATION at every switch over the union. That\n// compile-enforcement is the whole argument, and it is verified rather than\n// asserted — deleting an arm from `describeProviderProtocolSecretRef` reddens the\n// `never` check with the offending contract named in the diagnostic.\n//\n// It also fills its own `EngineCapability.AI_DOCUMENT_EXTRACTION` slot, so an\n// application selects its OCR provider INDEPENDENTLY of its chat and embeddings\n// providers. Those are three unrelated procurement decisions — a deployment may\n// well want Anthropic for chat, OpenAI for embeddings, and Mistral for OCR — and\n// fusing any two of them into one `selection` entry makes that unexpressible.\n//===============================================================\n\n/**\n * Concrete document-extraction model ids the framework knows.\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport enum DocumentExtractionProvider_Model {\n /**\n * Mistral's OCR model alias. An ALIAS deliberately, not a dated snapshot: unlike an embedding\n * model — where the concrete id is persisted as a stamp on every chunk and a silent change\n * would fracture the vector space — extraction output is consumed immediately and re-derived\n * on every ingestion pass, so tracking the vendor's current model is a benefit rather than a\n * hazard.\n */\n MISTRAL_OCR_LATEST = \"mistral-ocr-latest\",\n}\n\n/**\n * The document-extraction operation vocabulary — deliberately DISJOINT from\n * `LLMProvider_OperationKey`, `ImageProvider_OperationKey` and\n * `EmbeddingsProvider_OperationKey` (each protocol kind owns its own operation enum, so a key's\n * membership decides its protocol without inspection).\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport enum DocumentExtractionProvider_OperationKey {\n /** One document's bytes → its text, page by page. */\n EXTRACT_DOCUMENT_TEXT = \"documentExtraction.extractDocumentText\",\n}\n\n/**\n * @wildo_source:part:start saas.external-providers.document-extraction.applicability facet:kind:api facet:audience:app-developer\n *\n * WHAT a document is being extracted FOR — the durable axis of extraction-model selection\n * (model-selection-by-applicability rule: an author names a CLASS, never a concrete model id;\n * the framework resolves the id from the catalog + preference below).\n *\n * One class today, and that is a statement rather than a placeholder: every extraction in the\n * engine feeds `FileTextExtractionBackendService`, and a second class would only be earned by a\n * surface with genuinely different requirements (a layout-preserving export, say, or a\n * cheap-and-approximate preview tier).\n */\nexport enum DocumentExtraction_Applicability {\n /** The default document-text surface: file text extraction, and the RAG corpus built on it. */\n DOCUMENT_TEXT_DEFAULT = \"document-text-default\",\n}\n/** @wildo_source:part:end saas.external-providers.document-extraction.applicability */\n\n/**\n * One row per document-extraction model: everything the framework knows about a concrete id.\n * Mirrors `Embeddings_ModelCatalogEntry`'s shape at the size this axis needs today.\n */\nexport type DocumentExtraction_ModelCatalogEntry = {\n /** The `ref` of the provider module that serves this id. */\n providerRef: string;\n /**\n * MIME types this model can process, as declared by the provider's documentation.\n *\n * Consulted BEFORE bytes leave the deployment: sending a document the model cannot read wastes\n * an egress of application content, which the data-minimization posture on the execution seam\n * exists to avoid.\n */\n supportedMimeTypes: readonly string[];\n /** FRAMEWORK OPINION — which applicability classes this model may be resolved for. */\n applicabilities: readonly DocumentExtraction_Applicability[];\n};\n\n/**\n * The ENGINE providers' document-extraction model catalog — the per-model fact table for every model an engine\n * provider serves (the `EMBEDDINGS_MODEL_CATALOG` discipline: an EXHAUSTIVE `Record`, so a new\n * `DocumentExtractionProvider_Model` member without a row is a compile error). A provider installed from the module\n * registry states the same facts on its own contract instead (`DocumentExtraction_ModelDeclaration`, #2021).\n */\nexport const DOCUMENT_EXTRACTION_MODEL_CATALOG: Record<\n DocumentExtractionProvider_Model,\n DocumentExtraction_ModelCatalogEntry\n> = {\n [DocumentExtractionProvider_Model.MISTRAL_OCR_LATEST]: {\n providerRef: \"mistral\",\n /**\n * Mistral's published OCR format list (docs.mistral.ai \"Known limitations\": \"Supported\n * formats for OCR: PDF, PNG, JPG, JPEG, TIFF, BMP, GIF, WEBP\"), narrowed to the MIME types\n * the engine's own extraction gate admits today.\n *\n * `application/pdf` is the only entry that is currently REACHABLE: image MIME types are\n * refused by `FileTextExtractionBackendService.isExtractionSupported`, which is a separate,\n * deliberate decision (an uploaded photo is not a document). The image types are declared\n * here anyway because this row states what the MODEL can do, not what the engine currently\n * asks it to do — and admitting images to extraction later must be an engine decision, not\n * an accidental consequence of a catalog edit.\n */\n supportedMimeTypes: [\"application/pdf\", \"image/png\", \"image/jpeg\", \"image/tiff\", \"image/webp\"],\n applicabilities: [DocumentExtraction_Applicability.DOCUMENT_TEXT_DEFAULT],\n },\n};\n\n/**\n * The framework's DEFAULT answer to \"which extraction model serves this class\", ordered by\n * preference, highest first.\n *\n * Unlike the embeddings preference — which is a MIGRATION KEY, because editing it re-binds a\n * class and forces every stamped chunk to be re-embedded — this one carries no durable\n * consequence: extraction output is re-derived on the next ingestion pass and nothing persists\n * the model that produced it. Editing this list changes what the next extraction uses and\n * nothing else.\n */\nexport const DOCUMENT_EXTRACTION_MODEL_APPLICABILITY_PREFERENCE: Record<\n DocumentExtraction_Applicability,\n readonly DocumentExtractionProvider_Model[]\n> = {\n [DocumentExtraction_Applicability.DOCUMENT_TEXT_DEFAULT]: [\n DocumentExtractionProvider_Model.MISTRAL_OCR_LATEST,\n ],\n};\n\n/**\n * A document-extraction model a provider DECLARES itself (#2021): what the engine's catalog holds for its own providers,\n * for a provider the catalog does not know.\n *\n * The catalog above is closed over an engine enum, which is right for the engine's providers and makes an imported one\n * impossible: a provider installed from the module registry is authored in the application's own package, and the engine\n * cannot hold a row for a model it has never heard of. So such a provider states the same facts on its runtime contract\n * (`models` on the DOCUMENT_EXTRACTION arm), and they are held to the same use: `supportedMimeTypes` is consulted before\n * any byte leaves, and `applicabilities` is what an author's class resolves against.\n *\n * Import path: `@wildo-ai/external-connectors-models`.\n */\nexport type DocumentExtraction_ModelDeclaration = {\n /** The vendor's model id, sent as the resolved model. */\n model: string;\n /** MIME types this model can process, as the vendor documents them. Lower-case. */\n supportedMimeTypes: readonly string[];\n /** Which applicability classes this model may be resolved for. */\n applicabilities: readonly DocumentExtraction_Applicability[];\n};\n\n/** Why {@link resolveDocumentExtractionModelForApplicability} could not answer — carried into a named CONFIGURATION error. */\nexport enum DocumentExtraction_ModelResolutionFailure {\n /** The applicability has no candidate at all for this provider. */\n NO_CANDIDATE_FOR_PROVIDER = \"no_candidate_for_provider\",\n /**\n * A provider the engine's catalog knows ALSO declares models. The catalog is the one place an engine provider's models\n * live; a second, provider-side list could disagree with it about what may be sent, so it is refused rather than merged.\n */\n CATALOG_PROVIDER_DECLARES_MODELS = \"catalog_provider_declares_models\",\n}\n\nexport type DocumentExtraction_ModelResolution =\n | { resolved: true; model: string; supportedMimeTypes: readonly string[] }\n | {\n resolved: false;\n failure: DocumentExtraction_ModelResolutionFailure;\n consideredModels: readonly string[];\n };\n\n/**\n * Resolve an applicability class to ONE concrete extraction model for a given provider.\n *\n * A provider the engine's catalog knows resolves from the catalog and its preference order, and may not also declare\n * models. Any other provider (one installed from the module registry, #2021) resolves from the models it declares, in\n * the order it declares them.\n *\n * Fails CLOSED and explains itself (the `resolveModelForApplicability` contract): a silent fallback to some other model\n * would send application documents to a model nobody chose.\n */\nexport const resolveDocumentExtractionModelForApplicability = (\n input: {\n applicability: DocumentExtraction_Applicability;\n providerRef: string;\n /** The `models` the provider's runtime contract declares. Absent or empty for an engine provider. */\n declaredModels?: readonly DocumentExtraction_ModelDeclaration[];\n },\n catalog: Record<DocumentExtractionProvider_Model, DocumentExtraction_ModelCatalogEntry> = DOCUMENT_EXTRACTION_MODEL_CATALOG,\n): DocumentExtraction_ModelResolution => {\n const declaredModels = input.declaredModels ?? [];\n const catalogKnowsProvider = Object.values(catalog).some((entry) => entry.providerRef === input.providerRef);\n if (catalogKnowsProvider) {\n const candidates = DOCUMENT_EXTRACTION_MODEL_APPLICABILITY_PREFERENCE[input.applicability];\n if (declaredModels.length > 0) {\n return {\n resolved: false,\n failure: DocumentExtraction_ModelResolutionFailure.CATALOG_PROVIDER_DECLARES_MODELS,\n consideredModels: declaredModels.map((declaration) => declaration.model),\n };\n }\n const forProvider = candidates.filter((model) => {\n const entry = catalog[model];\n return entry.providerRef === input.providerRef && entry.applicabilities.includes(input.applicability);\n });\n if (forProvider.length === 0) {\n return { resolved: false, failure: DocumentExtraction_ModelResolutionFailure.NO_CANDIDATE_FOR_PROVIDER, consideredModels: candidates };\n }\n const model = forProvider[0]!;\n return { resolved: true, model, supportedMimeTypes: catalog[model].supportedMimeTypes };\n }\n const declared = declaredModels.find((declaration) => declaration.applicabilities.includes(input.applicability));\n if (declared === undefined) {\n return {\n resolved: false,\n failure: DocumentExtraction_ModelResolutionFailure.NO_CANDIDATE_FOR_PROVIDER,\n consideredModels: declaredModels.map((declaration) => declaration.model),\n };\n }\n return { resolved: true, model: declared.model, supportedMimeTypes: declared.supportedMimeTypes };\n};\n\n// ===============================================================\n// Document Extraction Operations Context\n// ===============================================================\n\n/**\n * Usage of one extraction call.\n *\n * There is NO token dimension, and its absence is structural rather than an omission: an OCR\n * call is billed and reported per PAGE, not per token. Any consumer judging usage completeness\n * for an extraction must do so on `pagesProcessed` alone — the operation-aware discipline the\n * embeddings arm records for its own missing completion-token dimension.\n */\nexport const DocumentExtractionProvider_UsageSchema = z.object({\n /**\n * Pages the provider reports having processed.\n *\n * The FRAMEWORK's name for the dimension. Which vendor field it is projected from is the\n * provider's `parseExtractResponse` to know — the wired one reads Mistral's\n * `usage_info.pages_processed`, and a second provider will read something else.\n */\n pagesProcessed: z.number().optional(),\n /** Document size the provider reports having received. Same ownership as `pagesProcessed`. */\n documentSizeBytes: z.number().optional(),\n});\nexport type DocumentExtractionProvider_Usage = z.infer<typeof DocumentExtractionProvider_UsageSchema>;\n\nexport const DocumentExtractionProvider_ExecutionTransportMetadataSchema = z.object({\n protocolKind: z.literal(ExternalProvider_ExchangeProtocol_Kind.DOCUMENT_EXTRACTION_PROVIDER),\n providerRef: z.string(),\n model: z.string().optional(),\n});\nexport type DocumentExtractionProvider_ExecutionTransportMetadata = z.infer<\n typeof DocumentExtractionProvider_ExecutionTransportMetadataSchema\n>;\n\n// ===============================================================\n// Document Extraction I/O Schemas\n// ===============================================================\n\n/**\n * Input DESCRIPTOR of the {@link DocumentExtractionProvider_OperationKey.EXTRACT_DOCUMENT_TEXT}\n * operation — the metadata about the document, deliberately NOT the document.\n *\n * ⚠️ THE BYTES ARE ABSENT ON PURPOSE, and this is the design decision most likely to be\n * \"corrected\" by a later reader. A `documentBase64: z.string()` field here would be structurally\n * correct and operationally dangerous: a Zod-shaped input object is the thing every diagnostic\n * path in this codebase reaches for when something goes wrong — error `context`, debug logs,\n * agent-call traces — and a multi-megabyte base64 blob of an application's private contract is\n * the single worst payload to make casually loggable. The embeddings arm reached the same\n * conclusion from the other direction (its header forbids raw texts and vectors from ever\n * entering a trace); here the prohibition is enforced by the SHAPE rather than by discipline.\n *\n * The bytes travel as a `Buffer` on the execution service's own request type, which no\n * serializer walks.\n */\nexport const DocumentExtractionProvider_ExtractDocumentTextInputSchema = z.object({\n /** The document's MIME type — checked against the model's catalog row before any egress. */\n mimeType: z.string(),\n /** Byte length of the document being sent. Diagnostic and ceiling-checking only. */\n documentByteLength: z.number().int().nonnegative(),\n});\nexport type DocumentExtractionProvider_ExtractDocumentTextInput = z.infer<\n typeof DocumentExtractionProvider_ExtractDocumentTextInputSchema\n>;\n\n/**\n * Output of {@link DocumentExtractionProvider_OperationKey.EXTRACT_DOCUMENT_TEXT}.\n *\n * `text` is the concatenation of the provider's per-page output in document order. Providers in\n * this family return MARKDOWN per page (Mistral's `pages[].markdown`), which is kept as-is:\n * headings and table structure are signal for a retrieval corpus, and stripping them to \"plain\"\n * text would discard information the provider was paid to recover.\n */\nexport const DocumentExtractionProvider_ExtractDocumentTextOutputSchema = z.object({\n text: z.string(),\n /** Pages the provider actually returned — the authoritative count, not the request's estimate. */\n pageCount: z.number().int().nonnegative(),\n /** The concrete model that produced the text. */\n model: z.string(),\n usage: DocumentExtractionProvider_UsageSchema,\n});\nexport type DocumentExtractionProvider_ExtractDocumentTextOutput = z.infer<\n typeof DocumentExtractionProvider_ExtractDocumentTextOutputSchema\n>;\n\n// ===============================================================\n// The PROVIDER-OWNED WIRE SEAM\n// --------\n// Until 2026-09-09 this arm declared `baseUrl`, `endpointPath`, `apiKey` and `models` — where the\n// call goes and how it authenticates — and NOTHING about the body or the response. So the engine's\n// execution seam composed Mistral's `/v1/ocr` request (`document: { type: 'document_url',\n// document_url }`, `include_image_base64`) and read Mistral's response (`pages[].markdown`,\n// `usage_info.pages_processed`) with the vendor named nowhere, and a second provider declaring\n// DOCUMENT_EXTRACTION_PROVIDER would have been sent through Mistral's API carrying its own key.\n//\n// The remedy is the one the EMAIL and SMS arms already converged on: the provider declares PURE\n// FUNCTIONS and the engine owns transport and credentials. The types those functions are written\n// against live HERE rather than beside the contract, because the failure vocabulary is read by\n// BOTH sides — the provider produces it, the engine's caller branches on it — and a vocabulary\n// with two homes is a vocabulary that drifts.\n// ===============================================================\n\n/**\n * WHY an extraction failed, in the only two senses a caller can act on differently.\n *\n * This is the arm's most load-bearing output after the text itself, and the consequence of\n * confusing the two is CORPUS DELETION rather than a misleading log line:\n * `RagIngestionBackendService` deletes a field's entire chunk set when an ingestion pass yields no\n * text, so reporting a provider OUTAGE as an unreadable document silently destroys a live,\n * already-embedded corpus and reports success.\n *\n * It lived in `saas-backend-lib`'s execution seam until 2026-09-09, which is exactly why the wire\n * shape lived there too: a vocabulary a provider cannot reach is one a provider cannot answer in,\n * so classification had to be done by whoever could. Moving it here is what makes\n * {@link DocumentExtraction_ProviderExtraction} expressible at all.\n */\nexport enum DocumentExtraction_FailureClass {\n /**\n * The provider read the request and judged the DOCUMENT unprocessable — corrupt bytes, an\n * unsupported format, a password-protected file. PERMANENT: re-sending the same bytes cannot\n * succeed, so a sweep may safely stop retrying and skip the document.\n */\n UNREADABLE_DOCUMENT = \"unreadable_document\",\n /**\n * The provider could not be reached, refused the credential, throttled, or failed internally —\n * a network error, a 401/403, a 429, any 5xx, or a timeout. TRANSIENT and, decisively, says\n * NOTHING about the document. A caller must not conclude anything about the bytes from this.\n */\n PROVIDER_UNAVAILABLE = \"provider_unavailable\",\n}\n\n/**\n * What a provider's `parseExtractResponse` returns, and what a COMPLETE poll carries (#2020): the extraction, or a\n * CLASSIFIED refusal.\n *\n * A discriminated union rather than \"return the output or throw\", for the reason the failure class\n * exists: a thrown `Error` carries no class, and the engine would have to guess one — which is the\n * guess that deletes a corpus. A provider that cannot classify a response must still say which of\n * the two it is, and the arm's JSDoc tells it to prefer `PROVIDER_UNAVAILABLE` when unsure,\n * because that is the answer with no destructive consequence.\n */\nexport type DocumentExtraction_ProviderExtraction =\n | {\n extracted: true;\n /** Per-page text joined in document order. Markdown is kept as-is; see the output schema. */\n text: string;\n /** Pages the provider actually returned — the authoritative count, not the request estimate. */\n pageCount: number;\n /** The model the provider says produced the text. Absent means \"the resolved model\". */\n model?: string;\n usage?: DocumentExtractionProvider_Usage;\n }\n | {\n extracted: false;\n failureClass: DocumentExtraction_FailureClass;\n /**\n * Operator-facing reason. MUST NOT contain the provider's response body or any part of the\n * document: this message reaches logs, and a provider error body can echo request content.\n */\n message: string;\n };\n\n/**\n * HOW a document-extraction provider exchanges with its vendor (#2020) — the discriminator of the runtime arm's\n * `exchange`.\n *\n * Two shapes exist in the field and they cannot be folded into one:\n * - SINGLE_REQUEST: one request carries the document and the answer carries the text (Mistral OCR).\n * - SUBMIT_AND_POLL: the vendor accepts the document, answers with a job, and the text is fetched later by polling\n * that job until it is done (Azure Document Intelligence's `Operation-Location`, VLM Run). Asynchronous Textract is\n * a job-based vendor this form does NOT serve (SigV4, S3 input, POST polls); see the private exchange type.\n * Folding this into one request is what #2001 showed failing: the first request answers a job id, not text.\n *\n * A closed vocabulary with one home, so the engine's switch over it is exhaustive: a new form, or a deleted one, is a\n * compile error at the one place that executes the exchange.\n */\nexport enum DocumentExtractionExchangeForm {\n SINGLE_REQUEST = \"single-request\",\n SUBMIT_AND_POLL = \"submit-and-poll\",\n}\n\n/**\n * What a SUBMIT_AND_POLL provider's `parseSubmitResponse` returns: the vendor's job id, or a CLASSIFIED refusal. The\n * refusal carries the same two classes as an extraction, for the same reason: a vendor refusing THIS document at\n * submission is permanent, an outage is not, and confusing them deletes a corpus.\n */\nexport type DocumentExtraction_JobSubmission =\n | {\n submitted: true;\n /** The vendor's identifier for the job. Opaque to the engine; handed back to `buildPollRequest`. */\n jobId: string;\n }\n | {\n submitted: false;\n failureClass: DocumentExtraction_FailureClass;\n /** Operator-facing; MUST NOT contain the response body or the document (see the extraction's `message`). */\n message: string;\n };\n\n/** Where a polled job stands. PENDING keeps the engine polling until the provider's deadline. */\nexport enum DocumentExtraction_JobState {\n PENDING = \"pending\",\n COMPLETE = \"complete\",\n}\n\n/**\n * What a SUBMIT_AND_POLL provider's `parsePollResponse` returns for one poll: still running, or done — with the\n * extraction or its classified refusal, exactly what a single-request parser returns.\n *\n * COMPLETE means the VENDOR says the job has ended. A job the vendor reports failed is COMPLETE with a refusal, and\n * only then may the engine submit the document again, because only then is nothing still running. A poll the vendor\n * answered with a transient error (a 5xx or 429 on the poll route) says nothing about the job, so it is PENDING: the\n * engine polls again until the deadline. Reading it as COMPLETE would stop the engine while the job may still run,\n * and a retry would then pay the vendor twice for one document.\n */\nexport type DocumentExtraction_JobPoll =\n | { state: DocumentExtraction_JobState.PENDING }\n | { state: DocumentExtraction_JobState.COMPLETE; extraction: DocumentExtraction_ProviderExtraction };\n\n/**\n * The framework's DEFAULT reading of an extraction response's HTTP status.\n *\n * Offered to every provider's `parseExtractResponse` rather than applied by the engine, because\n * only the provider knows whether its vendor also signals a per-document verdict inside a 2xx\n * body (Twilio does exactly that on the SMS arm). What it prevents is each provider re-deriving a\n * classification whose worst case is corpus deletion.\n *\n * Every boundary is deliberate:\n * - 4xx generally means the provider READ the request and refused THIS DOCUMENT → permanent.\n * - 401/403 is a CREDENTIAL fault, not a document fault. Classifying it as unreadable would make\n * a rotated key look like a corpus of corrupt files and delete chunk sets across every\n * document for as long as the key was wrong.\n * - 408/429 are explicitly retryable by their own definition.\n * - 5xx is the provider's fault, never the document's.\n */\nexport const classifyDocumentExtractionHttpStatus = (status: number): DocumentExtraction_FailureClass => {\n const isCredentialFault = status === 401 || status === 403;\n const isThrottleOrTimeout = status === 408 || status === 429;\n const isServerFault = status >= 500;\n return isCredentialFault || isThrottleOrTimeout || isServerFault\n ? DocumentExtraction_FailureClass.PROVIDER_UNAVAILABLE\n : DocumentExtraction_FailureClass.UNREADABLE_DOCUMENT;\n};\n\n"]}
@@ -0,0 +1,157 @@
1
+ import { z } from "zod";
2
+ import type { API_HttpMethod } from "../core/commons.external-connectors-models.schemas";
3
+ /**
4
+ * The level of electronic signature a deliverable requires, and a provider declares it can apply.
5
+ *
6
+ * eIDAS Art. 3(10) and Art. 26: an advanced signature is uniquely linked to and capable of identifying the signatory,
7
+ * created with data under their sole control, and linked to the signed data so that any later change is detectable.
8
+ * Qualified signatures (Art. 3(12)) are deliberately not a member (Paul, 2026-10-19).
9
+ *
10
+ * spec-cite: Regulation (EU) No 910/2014, Art. 3(10), 3(11), 3(12) and Art. 26 — the definitions of simple, advanced
11
+ * and qualified electronic signatures; paraphrased, not quoted.
12
+ *
13
+ * Import path: `@wildo-ai/external-connectors-models`.
14
+ */
15
+ export declare enum ElectronicSignature_Level {
16
+ /** A simple electronic signature: data the signatory attaches to sign (Art. 3(10)). Any vendor applies it. */
17
+ SIMPLE = "simple",
18
+ /** An advanced electronic signature (Art. 26), applied by a trust-service vendor. */
19
+ ADVANCED = "advanced"
20
+ }
21
+ /**
22
+ * Whether a signature at `achieved` meets a requirement of `required`. An advanced signature is also a simple one, so it
23
+ * meets a SIMPLE requirement; a simple one never meets an ADVANCED requirement.
24
+ *
25
+ * Import path: `@wildo-ai/external-connectors-models`.
26
+ */
27
+ export declare function electronicSignatureLevelSatisfies(achieved: ElectronicSignature_Level, required: ElectronicSignature_Level): boolean;
28
+ /**
29
+ * Whether a provider's contract reaches the vendor's PRODUCTION environment or one of its test environments. Evidence
30
+ * signed in a test environment is refused in production (its chain does not reach the production anchors), and a
31
+ * contract declaring a test environment is refused at startup in a production runtime.
32
+ *
33
+ * Import path: `@wildo-ai/external-connectors-models`.
34
+ */
35
+ export declare enum ElectronicSignature_VendorEnvironment {
36
+ PRODUCTION = "production",
37
+ NON_PRODUCTION = "non_production"
38
+ }
39
+ /**
40
+ * The electronic-signature operation vocabulary — disjoint from every other protocol's operation keys.
41
+ *
42
+ * Import path: `@wildo-ai/external-connectors-models`.
43
+ */
44
+ export declare enum ElectronicSignatureProvider_OperationKey {
45
+ /** Create a request at the vendor: the document, its signers, the level. */
46
+ SEND_REQUEST = "electronicSignature.sendRequest",
47
+ /** Re-read a request's status at the vendor. */
48
+ READ_REQUEST = "electronicSignature.readRequest",
49
+ /** Download the signed document of a request the vendor reports complete. */
50
+ DOWNLOAD_SIGNED_DOCUMENT = "electronicSignature.downloadSignedDocument",
51
+ /** Cancel an open request at the vendor, and (where the provider deletes on removal) delete it there. */
52
+ CANCEL_REQUEST = "electronicSignature.cancelRequest"
53
+ }
54
+ /**
55
+ * Where the vendor says a request stands, read from its own API. A CLAIM of the vendor's: the engine moves its own record
56
+ * on it (declined, expired, cancelled, partially signed) but never to SIGNED, which needs the validated document.
57
+ *
58
+ * Import path: `@wildo-ai/external-connectors-models`.
59
+ */
60
+ export declare enum ElectronicSignature_VendorRequestStatus {
61
+ /** Created and waiting for its signers; nobody has signed. */
62
+ PENDING = "pending",
63
+ /** Some signers signed, others have not yet. */
64
+ PARTIALLY_SIGNED = "partially_signed",
65
+ /** Every signer signed; the signed document can be downloaded. */
66
+ COMPLETED = "completed",
67
+ /** A signer refused. */
68
+ DECLINED = "declined",
69
+ /** The vendor's deadline passed. */
70
+ EXPIRED = "expired",
71
+ /** Cancelled at the vendor. */
72
+ CANCELLED = "cancelled"
73
+ }
74
+ /**
75
+ * One HTTP request a provider function asks the engine to send. The engine owns the host (the contract's base URL, never
76
+ * anything here), the API-key header, the timeout and the redirect refusal; `path` is appended to the base URL and must
77
+ * start with `/` (an absolute URL is refused). `body` is already encoded; `transportHeaders` describe it (a
78
+ * `content-type` at minimum when there is a body) and can never replace the engine's authentication header.
79
+ */
80
+ export interface ElectronicSignature_ProviderRequest {
81
+ readonly method: API_HttpMethod;
82
+ readonly path: string;
83
+ readonly body?: string | Uint8Array;
84
+ readonly transportHeaders?: Readonly<Record<string, string>>;
85
+ }
86
+ /** A vendor answer as the engine hands it to a provider function: status, lower-cased headers, best-effort decoded body. */
87
+ export interface ElectronicSignature_ProviderResponse {
88
+ readonly status: number;
89
+ readonly headers: Readonly<Record<string, string>>;
90
+ readonly body: unknown;
91
+ }
92
+ /** One signer of a request, as a provider is given it. */
93
+ export interface ElectronicSignature_SignerInput {
94
+ /** The engine's own opaque reference to this signer (its signer row). The provider maps it to the vendor's signer. */
95
+ readonly signerRef: string;
96
+ /** The order in which the vendor asks the signers, from 0. Equal orders sign in parallel. */
97
+ readonly signingOrder: number;
98
+ readonly firstName: string;
99
+ readonly lastName: string;
100
+ readonly email: string;
101
+ }
102
+ /** What a provider is given to send a request. Nothing about the tenant, the record or the approval. */
103
+ export interface ElectronicSignature_SendInput {
104
+ readonly document: Uint8Array;
105
+ readonly documentName: string;
106
+ readonly mimeType: string;
107
+ /** The SHA-256 of `document`, lower-case hex, as the file recorded it. */
108
+ readonly contentSha256: string;
109
+ readonly level: ElectronicSignature_Level;
110
+ readonly signers: readonly ElectronicSignature_SignerInput[];
111
+ }
112
+ /**
113
+ * What a provider answers at each step of sending: another request to make (with JSON-safe state it wants back), or
114
+ * the end, SENT or REFUSED.
115
+ */
116
+ export type ElectronicSignature_SendStep = {
117
+ readonly kind: "request";
118
+ readonly request: ElectronicSignature_ProviderRequest;
119
+ readonly carry?: unknown;
120
+ } | {
121
+ readonly kind: "sent";
122
+ /** The vendor's references for the request: several when the vendor splits it per document. Never empty. */
123
+ readonly vendorReferences: readonly string[];
124
+ /** The vendor's reference to each signer, keyed by the engine's `signerRef`. */
125
+ readonly vendorSignerReferences: Readonly<Record<string, string>>;
126
+ } | {
127
+ readonly kind: "refused";
128
+ readonly reason: string;
129
+ /** Whether asking again later could succeed (a vendor outage or throttle), as opposed to a refusal of the request. */
130
+ readonly retryable: boolean;
131
+ };
132
+ /** What a provider reads from the vendor's answer to a status re-read. */
133
+ export declare const ElectronicSignature_VendorRequestReadingSchema: z.ZodObject<{
134
+ status: z.ZodEnum<typeof ElectronicSignature_VendorRequestStatus>;
135
+ signedVendorSignerReferences: z.ZodOptional<z.ZodArray<z.ZodString>>;
136
+ }, z.core.$strip>;
137
+ export type ElectronicSignature_VendorRequestReading = z.infer<typeof ElectronicSignature_VendorRequestReadingSchema>;
138
+ /** What a provider reads from the vendor's answer to a cancellation. */
139
+ export declare enum ElectronicSignature_CancellationOutcome {
140
+ /** The request is cancelled at the vendor (now, or already). */
141
+ CANCELLED = "cancelled",
142
+ /** The vendor refuses: the request is already final there (signed, declined, expired). */
143
+ ALREADY_FINAL = "already_final",
144
+ /** The vendor could not be asked or did not answer usably. Try again. */
145
+ FAILED = "failed"
146
+ }
147
+ /**
148
+ * The provider's limits the engine enforces on its side: how many steps a sending may take, and how large a document
149
+ * and a signed document may be. A provider declares its vendor's documented maxima.
150
+ */
151
+ export declare const ElectronicSignature_LimitsSchema: z.ZodObject<{
152
+ maxSendSteps: z.ZodNumber;
153
+ maxDocumentBytes: z.ZodNumber;
154
+ maxSignedDocumentBytes: z.ZodNumber;
155
+ }, z.core.$strip>;
156
+ export type ElectronicSignature_Limits = z.infer<typeof ElectronicSignature_LimitsSchema>;
157
+ //# sourceMappingURL=electronic-signature.external-connectors-models.schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"electronic-signature.external-connectors-models.schemas.d.ts","sourceRoot":"","sources":["../../../src/protocols/electronic-signature.external-connectors-models.schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AACvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAA;AA4BxF;;;;;;;;;;;GAWG;AACH,oBAAY,yBAAyB;IACnC,8GAA8G;IAC9G,MAAM,WAAW;IACjB,qFAAqF;IACrF,QAAQ,aAAa;CACtB;AAKD;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE,yBAAyB,EAAE,QAAQ,EAAE,yBAAyB,GAAG,OAAO,CAEnI;AAED;;;;;;GAMG;AACH,oBAAY,qCAAqC;IAC/C,UAAU,eAAe;IACzB,cAAc,mBAAmB;CAClC;AAED;;;;GAIG;AACH,oBAAY,wCAAwC;IAClD,4EAA4E;IAC5E,YAAY,oCAAoC;IAChD,gDAAgD;IAChD,YAAY,oCAAoC;IAChD,6EAA6E;IAC7E,wBAAwB,+CAA+C;IACvE,yGAAyG;IACzG,cAAc,sCAAsC;CACrD;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