@proposit/proposit-core 1.2.0 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/README.md +9 -0
  2. package/dist/extensions/argument-ingestion/index.d.ts +8 -2
  3. package/dist/extensions/argument-ingestion/index.d.ts.map +1 -1
  4. package/dist/extensions/argument-ingestion/index.js +11 -5
  5. package/dist/extensions/argument-ingestion/index.js.map +1 -1
  6. package/dist/extensions/argument-ingestion/shared/finalize-response-v2.d.ts +17 -0
  7. package/dist/extensions/argument-ingestion/shared/finalize-response-v2.d.ts.map +1 -0
  8. package/dist/extensions/argument-ingestion/shared/finalize-response-v2.js +185 -0
  9. package/dist/extensions/argument-ingestion/shared/finalize-response-v2.js.map +1 -0
  10. package/dist/extensions/argument-ingestion/shared/resolve-llm-stage-options.d.ts +19 -0
  11. package/dist/extensions/argument-ingestion/shared/resolve-llm-stage-options.d.ts.map +1 -0
  12. package/dist/extensions/argument-ingestion/shared/resolve-llm-stage-options.js +44 -0
  13. package/dist/extensions/argument-ingestion/shared/resolve-llm-stage-options.js.map +1 -0
  14. package/dist/extensions/argument-ingestion/shared/types.d.ts +39 -0
  15. package/dist/extensions/argument-ingestion/shared/types.d.ts.map +1 -1
  16. package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.d.ts +12 -0
  17. package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.d.ts.map +1 -0
  18. package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.js +51 -0
  19. package/dist/extensions/argument-ingestion/stages/axiom-indicator-detection.js.map +1 -0
  20. package/dist/extensions/argument-ingestion/stages/citation-source-detection.d.ts +12 -0
  21. package/dist/extensions/argument-ingestion/stages/citation-source-detection.d.ts.map +1 -0
  22. package/dist/extensions/argument-ingestion/stages/citation-source-detection.js +51 -0
  23. package/dist/extensions/argument-ingestion/stages/citation-source-detection.js.map +1 -0
  24. package/dist/extensions/argument-ingestion/stages/claim-canonicalization.d.ts +21 -0
  25. package/dist/extensions/argument-ingestion/stages/claim-canonicalization.d.ts.map +1 -0
  26. package/dist/extensions/argument-ingestion/stages/claim-canonicalization.js +157 -0
  27. package/dist/extensions/argument-ingestion/stages/claim-canonicalization.js.map +1 -0
  28. package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.d.ts +12 -0
  29. package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.d.ts.map +1 -0
  30. package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.js +47 -0
  31. package/dist/extensions/argument-ingestion/stages/claim-mention-extraction.js.map +1 -0
  32. package/dist/extensions/argument-ingestion/stages/claim-reference-validation.d.ts +37 -0
  33. package/dist/extensions/argument-ingestion/stages/claim-reference-validation.d.ts.map +1 -0
  34. package/dist/extensions/argument-ingestion/stages/claim-reference-validation.js +108 -0
  35. package/dist/extensions/argument-ingestion/stages/claim-reference-validation.js.map +1 -0
  36. package/dist/extensions/argument-ingestion/stages/claim-type-classification.d.ts +12 -0
  37. package/dist/extensions/argument-ingestion/stages/claim-type-classification.d.ts.map +1 -0
  38. package/dist/extensions/argument-ingestion/stages/claim-type-classification.js +76 -0
  39. package/dist/extensions/argument-ingestion/stages/claim-type-classification.js.map +1 -0
  40. package/dist/extensions/argument-ingestion/stages/conclusion-selection.d.ts +27 -0
  41. package/dist/extensions/argument-ingestion/stages/conclusion-selection.d.ts.map +1 -0
  42. package/dist/extensions/argument-ingestion/stages/conclusion-selection.js +104 -0
  43. package/dist/extensions/argument-ingestion/stages/conclusion-selection.js.map +1 -0
  44. package/dist/extensions/argument-ingestion/stages/formula-compilation.d.ts +27 -0
  45. package/dist/extensions/argument-ingestion/stages/formula-compilation.d.ts.map +1 -0
  46. package/dist/extensions/argument-ingestion/stages/formula-compilation.js +175 -0
  47. package/dist/extensions/argument-ingestion/stages/formula-compilation.js.map +1 -0
  48. package/dist/extensions/argument-ingestion/stages/formula-validation.d.ts +19 -0
  49. package/dist/extensions/argument-ingestion/stages/formula-validation.d.ts.map +1 -0
  50. package/dist/extensions/argument-ingestion/stages/formula-validation.js +101 -0
  51. package/dist/extensions/argument-ingestion/stages/formula-validation.js.map +1 -0
  52. package/dist/extensions/argument-ingestion/stages/index.d.ts +15 -0
  53. package/dist/extensions/argument-ingestion/stages/index.d.ts.map +1 -0
  54. package/dist/extensions/argument-ingestion/stages/index.js +16 -0
  55. package/dist/extensions/argument-ingestion/stages/index.js.map +1 -0
  56. package/dist/extensions/argument-ingestion/stages/relation-extraction.d.ts +13 -0
  57. package/dist/extensions/argument-ingestion/stages/relation-extraction.d.ts.map +1 -0
  58. package/dist/extensions/argument-ingestion/stages/relation-extraction.js +87 -0
  59. package/dist/extensions/argument-ingestion/stages/relation-extraction.js.map +1 -0
  60. package/dist/extensions/argument-ingestion/stages/schemas.d.ts +161 -0
  61. package/dist/extensions/argument-ingestion/stages/schemas.d.ts.map +1 -0
  62. package/dist/extensions/argument-ingestion/stages/schemas.js +218 -0
  63. package/dist/extensions/argument-ingestion/stages/schemas.js.map +1 -0
  64. package/dist/extensions/argument-ingestion/stages/segmentation.d.ts +26 -0
  65. package/dist/extensions/argument-ingestion/stages/segmentation.d.ts.map +1 -0
  66. package/dist/extensions/argument-ingestion/stages/segmentation.js +81 -0
  67. package/dist/extensions/argument-ingestion/stages/segmentation.js.map +1 -0
  68. package/dist/extensions/argument-ingestion/stages/variable-assignment.d.ts +15 -0
  69. package/dist/extensions/argument-ingestion/stages/variable-assignment.d.ts.map +1 -0
  70. package/dist/extensions/argument-ingestion/stages/variable-assignment.js +84 -0
  71. package/dist/extensions/argument-ingestion/stages/variable-assignment.js.map +1 -0
  72. package/dist/extensions/argument-ingestion/v1-single-shot.d.ts +9 -1
  73. package/dist/extensions/argument-ingestion/v1-single-shot.d.ts.map +1 -1
  74. package/dist/extensions/argument-ingestion/v1-single-shot.js +13 -6
  75. package/dist/extensions/argument-ingestion/v1-single-shot.js.map +1 -1
  76. package/dist/extensions/argument-ingestion/v2-multi-stage.d.ts +38 -0
  77. package/dist/extensions/argument-ingestion/v2-multi-stage.d.ts.map +1 -0
  78. package/dist/extensions/argument-ingestion/v2-multi-stage.js +100 -0
  79. package/dist/extensions/argument-ingestion/v2-multi-stage.js.map +1 -0
  80. package/dist/extensions/openai/provider.d.ts.map +1 -1
  81. package/dist/extensions/openai/provider.js +136 -1
  82. package/dist/extensions/openai/provider.js.map +1 -1
  83. package/dist/extensions/openai/types.d.ts +19 -0
  84. package/dist/extensions/openai/types.d.ts.map +1 -1
  85. package/dist/lib/index.d.ts +2 -2
  86. package/dist/lib/index.d.ts.map +1 -1
  87. package/dist/lib/index.js +1 -1
  88. package/dist/lib/index.js.map +1 -1
  89. package/dist/lib/pipelines/debug-log.d.ts +96 -0
  90. package/dist/lib/pipelines/debug-log.d.ts.map +1 -0
  91. package/dist/lib/pipelines/debug-log.js +144 -0
  92. package/dist/lib/pipelines/debug-log.js.map +1 -0
  93. package/dist/lib/pipelines/execute.d.ts.map +1 -1
  94. package/dist/lib/pipelines/execute.js +84 -54
  95. package/dist/lib/pipelines/execute.js.map +1 -1
  96. package/dist/lib/pipelines/index.d.ts +1 -0
  97. package/dist/lib/pipelines/index.d.ts.map +1 -1
  98. package/dist/lib/pipelines/index.js +1 -0
  99. package/dist/lib/pipelines/index.js.map +1 -1
  100. package/package.json +2 -3
@@ -0,0 +1,161 @@
1
+ import Type, { type Static } from "typebox";
2
+ export declare const SpanSchema: Type.TObject<{
3
+ start: Type.TNumber;
4
+ end: Type.TNumber;
5
+ }>;
6
+ export type TSpan = Static<typeof SpanSchema>;
7
+ export declare const SegmentationOutputSchema: Type.TObject<{
8
+ segments: Type.TArray<Type.TObject<{
9
+ segmentId: Type.TString;
10
+ text: Type.TString;
11
+ span: Type.TObject<{
12
+ start: Type.TNumber;
13
+ end: Type.TNumber;
14
+ }>;
15
+ }>>;
16
+ }>;
17
+ export type TSegmentationOutput = Static<typeof SegmentationOutputSchema>;
18
+ export type TSegment = TSegmentationOutput["segments"][number];
19
+ export declare const ClaimMentionExtractionOutputSchema: Type.TObject<{
20
+ mentions: Type.TArray<Type.TObject<{
21
+ mentionId: Type.TString;
22
+ segmentId: Type.TString;
23
+ text: Type.TString;
24
+ span: Type.TObject<{
25
+ start: Type.TNumber;
26
+ end: Type.TNumber;
27
+ }>;
28
+ }>>;
29
+ }>;
30
+ export type TClaimMentionExtractionOutput = Static<typeof ClaimMentionExtractionOutputSchema>;
31
+ export type TClaimMention = TClaimMentionExtractionOutput["mentions"][number];
32
+ export declare const CitationSourceDetectionOutputSchema: Type.TObject<{
33
+ sources: Type.TArray<Type.TObject<{
34
+ sourceId: Type.TString;
35
+ segmentIds: Type.TArray<Type.TString>;
36
+ sourceString: Type.TString;
37
+ url: Type.TUnion<[Type.TString, Type.TNull]>;
38
+ spans: Type.TArray<Type.TObject<{
39
+ start: Type.TNumber;
40
+ end: Type.TNumber;
41
+ }>>;
42
+ }>>;
43
+ }>;
44
+ export type TCitationSourceDetectionOutput = Static<typeof CitationSourceDetectionOutputSchema>;
45
+ export type TCitationSource = TCitationSourceDetectionOutput["sources"][number];
46
+ export declare const AxiomIndicatorDetectionOutputSchema: Type.TObject<{
47
+ axioms: Type.TArray<Type.TObject<{
48
+ axiomId: Type.TString;
49
+ segmentIds: Type.TArray<Type.TString>;
50
+ indicator: Type.TString;
51
+ spans: Type.TArray<Type.TObject<{
52
+ start: Type.TNumber;
53
+ end: Type.TNumber;
54
+ }>>;
55
+ }>>;
56
+ }>;
57
+ export type TAxiomIndicatorDetectionOutput = Static<typeof AxiomIndicatorDetectionOutputSchema>;
58
+ export type TAxiomIndicator = TAxiomIndicatorDetectionOutput["axioms"][number];
59
+ export declare const BaseCanonicalClaimSchema: Type.TObject<{
60
+ miniId: Type.TString;
61
+ mentionIds: Type.TArray<Type.TString>;
62
+ suggestedSymbol: Type.TString;
63
+ type: Type.TUnion<[Type.TLiteral<"normal">, Type.TLiteral<"citation">, Type.TLiteral<"axiomatic">]>;
64
+ }>;
65
+ export type TBaseCanonicalClaim = Static<typeof BaseCanonicalClaimSchema>;
66
+ export declare const MentionToClaimEntrySchema: Type.TObject<{
67
+ mentionId: Type.TString;
68
+ claimMiniId: Type.TString;
69
+ }>;
70
+ export type TMentionToClaimEntry = Static<typeof MentionToClaimEntrySchema>;
71
+ export declare const ClaimCanonicalizationOutputSchema: Type.TObject<{
72
+ canonicalClaims: Type.TArray<Type.TObject<{
73
+ miniId: Type.TString;
74
+ mentionIds: Type.TArray<Type.TString>;
75
+ suggestedSymbol: Type.TString;
76
+ type: Type.TUnion<[Type.TLiteral<"normal">, Type.TLiteral<"citation">, Type.TLiteral<"axiomatic">]>;
77
+ }>>;
78
+ mentionToClaim: Type.TArray<Type.TObject<{
79
+ mentionId: Type.TString;
80
+ claimMiniId: Type.TString;
81
+ }>>;
82
+ }>;
83
+ export type TClaimCanonicalizationOutput = Static<typeof ClaimCanonicalizationOutputSchema>;
84
+ /** Per-claim record including the extension-injected fields. */
85
+ export type TCanonicalClaim = TBaseCanonicalClaim & Record<string, unknown>;
86
+ export declare const ClaimTypeClassificationEntrySchema: Type.TObject<{
87
+ miniId: Type.TString;
88
+ type: Type.TUnion<[Type.TLiteral<"normal">, Type.TLiteral<"citation">, Type.TLiteral<"axiomatic">]>;
89
+ sourceString: Type.TUnion<[Type.TString, Type.TNull]>;
90
+ }>;
91
+ export type TClaimTypeClassificationEntry = Static<typeof ClaimTypeClassificationEntrySchema>;
92
+ export declare const ClaimTypeClassificationOutputSchema: Type.TObject<{
93
+ classifications: Type.TArray<Type.TObject<{
94
+ miniId: Type.TString;
95
+ type: Type.TUnion<[Type.TLiteral<"normal">, Type.TLiteral<"citation">, Type.TLiteral<"axiomatic">]>;
96
+ sourceString: Type.TUnion<[Type.TString, Type.TNull]>;
97
+ }>>;
98
+ }>;
99
+ export type TClaimTypeClassificationOutput = Static<typeof ClaimTypeClassificationOutputSchema>;
100
+ export declare const VariableAssignmentOutputSchema: Type.TArray<Type.TObject<{
101
+ miniId: Type.TString;
102
+ symbol: Type.TString;
103
+ claimMiniId: Type.TString;
104
+ }>>;
105
+ export type TVariableAssignmentOutput = Static<typeof VariableAssignmentOutputSchema>;
106
+ export type TAssignedVariable = TVariableAssignmentOutput[number];
107
+ export declare const RelationKindSchema: Type.TUnion<[Type.TLiteral<"support">, Type.TLiteral<"joint-support">, Type.TLiteral<"derivation-support">]>;
108
+ export type TRelationKind = Static<typeof RelationKindSchema>;
109
+ export declare const RelationExtractionOutputSchema: Type.TObject<{
110
+ relations: Type.TArray<Type.TObject<{
111
+ relationId: Type.TString;
112
+ type: Type.TUnion<[Type.TLiteral<"support">, Type.TLiteral<"joint-support">, Type.TLiteral<"derivation-support">]>;
113
+ sources: Type.TArray<Type.TString>;
114
+ target: Type.TString;
115
+ evidence: Type.TObject<{
116
+ segmentIds: Type.TArray<Type.TString>;
117
+ quote: Type.TString;
118
+ }>;
119
+ }>>;
120
+ }>;
121
+ export type TRelationExtractionOutput = Static<typeof RelationExtractionOutputSchema>;
122
+ export type TRelation = TRelationExtractionOutput["relations"][number];
123
+ export declare const ConclusionSelectionOutputSchema: Type.TObject<{
124
+ conclusionMiniId: Type.TUnion<[Type.TString, Type.TNull]>;
125
+ rationale: Type.TString;
126
+ }>;
127
+ export type TConclusionSelectionOutput = Static<typeof ConclusionSelectionOutputSchema>;
128
+ export declare const FormulaPremiseRoleHintSchema: Type.TUnion<[Type.TLiteral<"support">, Type.TLiteral<"joint-support">, Type.TLiteral<"derivation">, Type.TLiteral<"conclusion">]>;
129
+ export type TFormulaPremiseRoleHint = Static<typeof FormulaPremiseRoleHintSchema>;
130
+ export declare const FormulaCompilationOutputSchema: Type.TObject<{
131
+ premises: Type.TArray<Type.TObject<{
132
+ premiseMiniId: Type.TString;
133
+ formula: Type.TString;
134
+ roleHint: Type.TUnion<[Type.TLiteral<"support">, Type.TLiteral<"joint-support">, Type.TLiteral<"derivation">, Type.TLiteral<"conclusion">]>;
135
+ sourceRelationId: Type.TUnion<[Type.TString, Type.TNull]>;
136
+ }>>;
137
+ conclusionPremiseMiniId: Type.TUnion<[Type.TString, Type.TNull]>;
138
+ }>;
139
+ export type TFormulaCompilationOutput = Static<typeof FormulaCompilationOutputSchema>;
140
+ export type TCompiledPremise = TFormulaCompilationOutput["premises"][number];
141
+ export declare const ValidationStageOutputSchema: Type.TArray<Type.TObject<{
142
+ code: Type.TString;
143
+ message: Type.TString;
144
+ context: Type.TOptional<Type.TRecord<"^.*$", Type.TUnknown>>;
145
+ }>>;
146
+ export type TValidationStageOutput = Static<typeof ValidationStageOutputSchema>;
147
+ export declare const STAGE_IDS: {
148
+ readonly segmentation: "segmentation";
149
+ readonly claimMentionExtraction: "claim-mention-extraction";
150
+ readonly citationSourceDetection: "citation-source-detection";
151
+ readonly axiomIndicatorDetection: "axiom-indicator-detection";
152
+ readonly claimCanonicalization: "claim-canonicalization";
153
+ readonly claimTypeClassification: "claim-type-classification";
154
+ readonly claimReferenceValidation: "claim-reference-validation";
155
+ readonly variableAssignment: "variable-assignment";
156
+ readonly relationExtraction: "relation-extraction";
157
+ readonly conclusionSelection: "conclusion-selection";
158
+ readonly formulaCompilation: "formula-compilation";
159
+ readonly formulaValidation: "formula-validation";
160
+ };
161
+ //# sourceMappingURL=schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/schemas.ts"],"names":[],"mappings":"AAOA,OAAO,IAAI,EAAE,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAA;AAiB3C,eAAO,MAAM,UAAU;;;EASrB,CAAA;AACF,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,UAAU,CAAC,CAAA;AAiB7C,eAAO,MAAM,wBAAwB;;;;;;;;;EAQnC,CAAA;AACF,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAA;AACzE,MAAM,MAAM,QAAQ,GAAG,mBAAmB,CAAC,UAAU,CAAC,CAAC,MAAM,CA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stage's output schema lives here (rather than next to the stage
4
+ // module) so the schemas can be referenced from `finalize-response-v2.ts`,
5
+ // the v2 unit tests, and any future consumer that wants to validate a
6
+ // recorded stage output without importing the stage's `run` function.
7
+ import Type, {} from "typebox";
8
+ // **Span shape (`{ start, end }`).** Spans use a named-key object
9
+ // rather than a positional tuple. The original tuple shape
10
+ // (`Type.Tuple([Type.Number(), Type.Number()])`) caused the OpenAI
11
+ // structured-output converter to throw `UnsupportedSchemaError:
12
+ // "Tuple"` at request-build time — `segmentation` then surfaced a
13
+ // `LLM_NON_RETRYABLE_ERROR` on first attempt, every downstream stage
14
+ // cascade-skipped on the required dep, and the recording mode
15
+ // completed in ~9ms with `output: null` and zero LLM calls. The
16
+ // named-key form is also more LLM-friendly (each value carries its
17
+ // semantic role rather than relying on positional convention) and
18
+ // stays within the converter's supported subset (Object, Array,
19
+ // String, Number, Integer, Boolean, Literal, Union, Optional, Record,
20
+ // Null). See `test/extensions/argument-ingestion/stages/schema-converter-regression.test.ts`
21
+ // for the regression coverage that pins every v2 LLM stage's
22
+ // `outputSchema` through `typeboxToOpenAiSchema`.
23
+ export const SpanSchema = Type.Object({
24
+ start: Type.Number({
25
+ description: "Inclusive character offset where the span begins (relative to the parent text).",
26
+ }),
27
+ end: Type.Number({
28
+ description: "Exclusive character offset where the span ends (relative to the parent text).",
29
+ }),
30
+ });
31
+ // -- Stage 1: segmentation --
32
+ // **Why every LLM-stage output is wrapped in a single-key object.**
33
+ // The OpenAI Responses-API strict-mode structured output requires the
34
+ // root schema to be `{ "type": "object" }`. Bare top-level arrays are
35
+ // rejected with a 400 `invalid_json_schema` ("schema must be a JSON
36
+ // Schema of 'type: object', got 'type: array'"). To keep every LLM
37
+ // stage's outputSchema acceptable to the converter + the API, we wrap
38
+ // the natural array shape in a single-key envelope (`segments`,
39
+ // `mentions`, `sources`, `axioms`, `relations`). Downstream readers
40
+ // access the array via `output.segments` (etc.); the envelope is
41
+ // shallow and does not change the per-item shape. The same regression
42
+ // test that pins `typeboxToOpenAiSchema` survival now also asserts
43
+ // every LLM-stage's converted root is `type: object`.
44
+ export const SegmentationOutputSchema = Type.Object({
45
+ segments: Type.Array(Type.Object({
46
+ segmentId: Type.String(),
47
+ text: Type.String(),
48
+ span: SpanSchema,
49
+ })),
50
+ });
51
+ // -- Stage 2: claim-mention-extraction --
52
+ export const ClaimMentionExtractionOutputSchema = Type.Object({
53
+ mentions: Type.Array(Type.Object({
54
+ mentionId: Type.String(),
55
+ segmentId: Type.String(),
56
+ text: Type.String(),
57
+ span: SpanSchema,
58
+ })),
59
+ });
60
+ // -- Stage 3: citation-source-detection --
61
+ export const CitationSourceDetectionOutputSchema = Type.Object({
62
+ sources: Type.Array(Type.Object({
63
+ sourceId: Type.String(),
64
+ segmentIds: Type.Array(Type.String()),
65
+ sourceString: Type.String(),
66
+ url: Type.Union([Type.String(), Type.Null()]),
67
+ spans: Type.Array(SpanSchema),
68
+ })),
69
+ });
70
+ // -- Stage 4: axiom-indicator-detection --
71
+ export const AxiomIndicatorDetectionOutputSchema = Type.Object({
72
+ axioms: Type.Array(Type.Object({
73
+ axiomId: Type.String(),
74
+ segmentIds: Type.Array(Type.String()),
75
+ indicator: Type.String(),
76
+ spans: Type.Array(SpanSchema),
77
+ })),
78
+ });
79
+ // -- Stage 5: claim-canonicalization --
80
+ // The per-claim record in `canonicalClaims` carries:
81
+ // - `miniId` — c1, c2, ... allocated by the canonicalizer
82
+ // - `mentionIds` — list of mention ids that resolved to this claim
83
+ // - `suggestedSymbol` — snake_case-ish symbol proposal (validated
84
+ // downstream by `variable-assignment`)
85
+ // - the extension fields from `extension.claimSchema` (e.g. for
86
+ // `basics`: a discriminated union over `type`)
87
+ //
88
+ // We can't bake the extension shape into a static TypeBox object —
89
+ // the canonicalizer's schema is built per-extension by
90
+ // `buildCanonicalClaimsSchema(extension)` below. The exported
91
+ // `ClaimCanonicalizationOutputSchema` is the *base* shape (without the
92
+ // extension fields) and is used by tests that don't need the per-
93
+ // extension constraints.
94
+ export const BaseCanonicalClaimSchema = Type.Object({
95
+ miniId: Type.String(),
96
+ mentionIds: Type.Array(Type.String()),
97
+ suggestedSymbol: Type.String(),
98
+ // Per spec §7.2 row 5, the canonicalizer also drafts the
99
+ // per-claim type. We capture it as `type` and let
100
+ // `claim-type-classification` refine/confirm. Extension fields
101
+ // (title/body/url/axiom) come from the merged extension schema.
102
+ type: Type.Union([
103
+ Type.Literal("normal"),
104
+ Type.Literal("citation"),
105
+ Type.Literal("axiomatic"),
106
+ ]),
107
+ });
108
+ // **Why `mentionToClaim` is an array, not a map.** OpenAI Responses-API
109
+ // strict-mode JSON Schema does not support `additionalProperties` or
110
+ // `patternProperties` — fixed-shape objects only. `Type.Record(K, V)`
111
+ // generates JSON Schema like `{ type: "object", additionalProperties:
112
+ // <V> }`, which strict mode rejects with 400 `invalid_json_schema`
113
+ // ("'required' is required to be supplied and to be an array
114
+ // including every key in properties. Extra required key
115
+ // 'mentionToClaim' supplied."). Surfacing the map as an explicit
116
+ // `[{ mentionId, claimMiniId }, ...]` list bypasses the constraint
117
+ // entirely. Downstream readers convert to a `Map<string, string>`
118
+ // when they need O(1) lookups.
119
+ export const MentionToClaimEntrySchema = Type.Object({
120
+ mentionId: Type.String(),
121
+ claimMiniId: Type.String(),
122
+ });
123
+ export const ClaimCanonicalizationOutputSchema = Type.Object({
124
+ canonicalClaims: Type.Array(BaseCanonicalClaimSchema),
125
+ mentionToClaim: Type.Array(MentionToClaimEntrySchema),
126
+ });
127
+ // -- Stage 6: claim-type-classification --
128
+ // Same OpenAI strict-mode constraint as above. The natural shape
129
+ // `Record<miniId, { type, sourceString }>` becomes an explicit list
130
+ // of `{ miniId, type, sourceString }` entries, wrapped in a
131
+ // single-key `classifications` envelope (the lambda-fold 3 root-
132
+ // must-be-object invariant). Downstream readers build a Map on
133
+ // receipt when they need keyed lookups.
134
+ export const ClaimTypeClassificationEntrySchema = Type.Object({
135
+ miniId: Type.String(),
136
+ type: Type.Union([
137
+ Type.Literal("normal"),
138
+ Type.Literal("citation"),
139
+ Type.Literal("axiomatic"),
140
+ ]),
141
+ sourceString: Type.Union([Type.String(), Type.Null()]),
142
+ });
143
+ export const ClaimTypeClassificationOutputSchema = Type.Object({
144
+ classifications: Type.Array(ClaimTypeClassificationEntrySchema),
145
+ });
146
+ // -- Stage 8: variable-assignment --
147
+ export const VariableAssignmentOutputSchema = Type.Array(Type.Object({
148
+ miniId: Type.String(),
149
+ symbol: Type.String(),
150
+ claimMiniId: Type.String(),
151
+ }));
152
+ // -- Stage 9: relation-extraction --
153
+ export const RelationKindSchema = Type.Union([
154
+ Type.Literal("support"),
155
+ Type.Literal("joint-support"),
156
+ Type.Literal("derivation-support"),
157
+ ]);
158
+ export const RelationExtractionOutputSchema = Type.Object({
159
+ relations: Type.Array(Type.Object({
160
+ relationId: Type.String(),
161
+ type: RelationKindSchema,
162
+ sources: Type.Array(Type.String()),
163
+ target: Type.String(),
164
+ evidence: Type.Object({
165
+ segmentIds: Type.Array(Type.String()),
166
+ quote: Type.String(),
167
+ }),
168
+ })),
169
+ });
170
+ // -- Stage 10: conclusion-selection --
171
+ export const ConclusionSelectionOutputSchema = Type.Object({
172
+ conclusionMiniId: Type.Union([Type.String(), Type.Null()]),
173
+ rationale: Type.String(),
174
+ });
175
+ // -- Stage 11: formula-compilation --
176
+ export const FormulaPremiseRoleHintSchema = Type.Union([
177
+ Type.Literal("support"),
178
+ Type.Literal("joint-support"),
179
+ Type.Literal("derivation"),
180
+ Type.Literal("conclusion"),
181
+ ]);
182
+ export const FormulaCompilationOutputSchema = Type.Object({
183
+ premises: Type.Array(Type.Object({
184
+ premiseMiniId: Type.String(),
185
+ formula: Type.String(),
186
+ roleHint: FormulaPremiseRoleHintSchema,
187
+ // Optional pointer back to the relation that produced this
188
+ // premise (null for the conclusion premise, which is
189
+ // synthesized rather than extracted).
190
+ sourceRelationId: Type.Union([Type.String(), Type.Null()]),
191
+ })),
192
+ conclusionPremiseMiniId: Type.Union([Type.String(), Type.Null()]),
193
+ });
194
+ // -- Stage 7 + 12 are validation stages whose `run` return value is
195
+ // the same shape: an array of structured processing-failure-context
196
+ // records. They emit failures via `ctx.addFailure` as the load-bearing
197
+ // channel; the array return is mirroring + downstream-readable.
198
+ export const ValidationStageOutputSchema = Type.Array(Type.Object({
199
+ code: Type.String(),
200
+ message: Type.String(),
201
+ context: Type.Optional(Type.Record(Type.String(), Type.Unknown())),
202
+ }));
203
+ // -- Per-stage ids --
204
+ export const STAGE_IDS = {
205
+ segmentation: "segmentation",
206
+ claimMentionExtraction: "claim-mention-extraction",
207
+ citationSourceDetection: "citation-source-detection",
208
+ axiomIndicatorDetection: "axiom-indicator-detection",
209
+ claimCanonicalization: "claim-canonicalization",
210
+ claimTypeClassification: "claim-type-classification",
211
+ claimReferenceValidation: "claim-reference-validation",
212
+ variableAssignment: "variable-assignment",
213
+ relationExtraction: "relation-extraction",
214
+ conclusionSelection: "conclusion-selection",
215
+ formulaCompilation: "formula-compilation",
216
+ formulaValidation: "formula-validation",
217
+ };
218
+ //# sourceMappingURL=schemas.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/schemas.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAClE,EAAE;AACF,uEAAuE;AACvE,2EAA2E;AAC3E,sEAAsE;AACtE,sEAAsE;AAEtE,OAAO,IAAI,EAAE,EAAe,MAAM,SAAS,CAAA;AAE3C,kEAAkE;AAClE,2DAA2D;AAC3D,mEAAmE;AACnE,gEAAgE;AAChE,kEAAkE;AAClE,qEAAqE;AACrE,8DAA8D;AAC9D,gEAAgE;AAChE,mEAAmE;AACnE,kEAAkE;AAClE,gEAAgE;AAChE,sEAAsE;AACtE,6FAA6F;AAC7F,6DAA6D;AAC7D,kDAAkD;AAClD,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC;IAClC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;QACf,WAAW,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MAAM,CAAC,MAAM,SAAS,GAAG;IACrB,YAAY,EAAE,cAAc;IAC5B,sBAAsB,EAAE,0BAA0B;IAClD,uBAAuB,EAAE,2BAA2B;IACpD,uBAAuB,EAAE,2BAA2B;IACpD,qBAAqB,EAAE,wBAAwB;IAC/C,uBAAuB,EAAE,2BAA2B;IACpD,wBAAwB,EAAE,4BAA4B;IACtD,kBAAkB,EAAE,qBAAqB;IACzC,kBAAkB,EAAE,qBAAqB;IACzC,mBAAmB,EAAE,sBAAsB;IAC3C,kBAAkB,EAAE,qBAAqB;IACzC,iBAAiB,EAAE,oBAAoB;CACjC,CAAA"}
@@ -0,0 +1,26 @@
1
+ import { type TSegmentationOutput } from "./schemas.js";
2
+ import type { TStage } from "../../../lib/pipelines/types.js";
3
+ import type { TLlmStageOptionsOverride } from "../shared/types.js";
4
+ export declare const SEGMENTATION_MODEL = "gpt-5.4-mini";
5
+ export declare const SEGMENTATION_MAX_OUTPUT_TOKENS = 8192;
6
+ export declare const SEGMENTATION_SYSTEM_PROMPT = "You are the first stage of an argument-ingestion pipeline. Your job is to split the supplied input text into a list of segments.\n\nReturn an object with a single key `segments` whose value is the array of segments.\n\nA segment is a sentence-or-thereabouts span of text \u2014 a self-contained clause that a human could read on its own. Sentence-final punctuation usually marks segment boundaries; bullet items in a list count as separate segments; multi-clause sentences split into one segment per major clause when the clauses each carry their own assertion.\n\nAssign each segment a short stable id like \"s1\", \"s2\", ... in left-to-right order, copy the segment's text verbatim (no rewriting), and record the character \"span\" as an object with \"start\" (inclusive) and \"end\" (exclusive) character offsets into the input. Whitespace between segments is owned by neither segment.\n\nCover the input completely: every non-whitespace character must fall inside some segment's span. Do not invent text. Do not classify segments \u2014 that is a later stage's job.";
7
+ /**
8
+ * Internal default knobs for the segmentation stage. Exported so the
9
+ * pipeline factory can compose `resolveLlmStageOptions` over them.
10
+ */
11
+ export declare const SEGMENTATION_STAGE_DEFAULTS: TLlmStageOptionsOverride;
12
+ /**
13
+ * Build the segmentation stage with optional caller overrides. The
14
+ * pipeline factory threads `TLlmStageOptionsOverride` through this
15
+ * factory; standalone consumers can call it with no args to get the
16
+ * default-options stage.
17
+ */
18
+ export declare function createSegmentationStage(options?: TLlmStageOptionsOverride): TStage<TSegmentationOutput>;
19
+ /**
20
+ * Backward-compatible default-options stage. Existing consumers
21
+ * (tests, the v2 factory's pre-1.3.1 path) keep importing this and
22
+ * see the new internal defaults — same as if they had called
23
+ * `createSegmentationStage()` with no args.
24
+ */
25
+ export declare const segmentationStage: TStage<TSegmentationOutput>;
26
+ //# sourceMappingURL=segmentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segmentation.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/segmentation.ts"],"names":[],"mappings":"AAYA,OAAO,EAGH,KAAK,mBAAmB,EAC3B,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,MAAM,EAAiB,MAAM,iCAAiC,CAAA;AAC5E,OAAO,KAAK,EAER,wBAAwB,EAC3B,MAAM,oBAAoB,CAAA;AAE3B,eAAO,MAAM,kBAAkB,iBAAiB,CAAA;AAqBhD,eAAO,MAAM,8BAA8B,OAAO,CAAA;AAElD,eAAO,MAAM,0BAA0B,mjCAQsI,CAAA;AAY7K;;;GAGG;AACH,eAAO,MAAM,2BAA2B,EAAE,wBAEzC,CAAA;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CACnC,OAAO,CAAC,EAAE,wBAAwB,GACnC,MAAM,CAAC,mBAAmB,CAAC,CAW7B;AAED;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,EAAE,MAAM,CAAC,mBAAmB,CAC7B,CAAA"}
@@ -0,0 +1,81 @@
1
+ // `segmentation` — first stage of the v2 multi-stage ingestion
2
+ // pipeline. Splits the raw input text into segments (sentences or
3
+ // sentence-like chunks) and emits a stable `segmentId` per segment
4
+ // plus the text + character span.
5
+ //
6
+ // Why this lives in its own stage: downstream stages key their
7
+ // extractions to `segmentId`s rather than to character offsets, so
8
+ // extraction outputs survive small text edits if the segment ids are
9
+ // stable. Splitting is also a cheap-tier task; running it as its own
10
+ // stage prevents the larger downstream stages from burning tokens on
11
+ // the same job.
12
+ import { STAGE_IDS, SegmentationOutputSchema, } from "./schemas.js";
13
+ import { llmStage } from "../../../lib/pipelines/stage-helpers.js";
14
+ export const SEGMENTATION_MODEL = "gpt-5.4-mini";
15
+ // **Output cap (v1.3.1 fix for the segmentation-truncation
16
+ // regression).** Segmentation emits an array of `{ segmentId, text,
17
+ // span }` records — each segment's `text` is copied verbatim from
18
+ // the input (per the prompt). For a 15 KB input the model
19
+ // legitimately wants 30–50 segments at ~80–150 tokens of JSON each,
20
+ // so the output budget needs to comfortably exceed 5 k tokens.
21
+ // Without an explicit cap the Responses API's default
22
+ // `max_output_tokens` for `gpt-5.4-mini` kicks in mid-string and
23
+ // the model returns `status: "incomplete"` + partial JSON; v1.3.0
24
+ // reproduced this against Singer's "Solution to World Poverty"
25
+ // (15.5 KB / ~4 k input tokens). 8192 tokens is roughly 2× the
26
+ // expected upper bound on realistic input sizes and stays well below
27
+ // any per-model context-window limit — comfortable headroom without
28
+ // burning tokens on an over-spec'd cap.
29
+ //
30
+ // Callers that ingest larger inputs can raise the cap further via
31
+ // `createIngestionV2Pipeline(extension, { llm: { overrides: {
32
+ // segmentation: { maxOutputTokens: N } } } })` — see
33
+ // `shared/types.ts`.
34
+ export const SEGMENTATION_MAX_OUTPUT_TOKENS = 8192;
35
+ export const SEGMENTATION_SYSTEM_PROMPT = `You are the first stage of an argument-ingestion pipeline. Your job is to split the supplied input text into a list of segments.
36
+
37
+ Return an object with a single key \`segments\` whose value is the array of segments.
38
+
39
+ A segment is a sentence-or-thereabouts span of text — a self-contained clause that a human could read on its own. Sentence-final punctuation usually marks segment boundaries; bullet items in a list count as separate segments; multi-clause sentences split into one segment per major clause when the clauses each carry their own assertion.
40
+
41
+ Assign each segment a short stable id like "s1", "s2", ... in left-to-right order, copy the segment's text verbatim (no rewriting), and record the character "span" as an object with "start" (inclusive) and "end" (exclusive) character offsets into the input. Whitespace between segments is owned by neither segment.
42
+
43
+ Cover the input completely: every non-whitespace character must fall inside some segment's span. Do not invent text. Do not classify segments — that is a later stage's job.`;
44
+ function buildSegmentationPrompt(ctx) {
45
+ const input = ctx.input;
46
+ const markedSystem = `<!-- stage-id: ${STAGE_IDS.segmentation} -->\n${SEGMENTATION_SYSTEM_PROMPT}`;
47
+ const user = `Input text:\n\n${input.text}`;
48
+ return { system: markedSystem, user };
49
+ }
50
+ /**
51
+ * Internal default knobs for the segmentation stage. Exported so the
52
+ * pipeline factory can compose `resolveLlmStageOptions` over them.
53
+ */
54
+ export const SEGMENTATION_STAGE_DEFAULTS = {
55
+ maxOutputTokens: SEGMENTATION_MAX_OUTPUT_TOKENS,
56
+ };
57
+ /**
58
+ * Build the segmentation stage with optional caller overrides. The
59
+ * pipeline factory threads `TLlmStageOptionsOverride` through this
60
+ * factory; standalone consumers can call it with no args to get the
61
+ * default-options stage.
62
+ */
63
+ export function createSegmentationStage(options) {
64
+ return llmStage({
65
+ id: STAGE_IDS.segmentation,
66
+ dependsOn: [],
67
+ outputSchema: SegmentationOutputSchema,
68
+ model: SEGMENTATION_MODEL,
69
+ maxOutputTokens: options?.maxOutputTokens ?? SEGMENTATION_MAX_OUTPUT_TOKENS,
70
+ reasoningEffort: options?.reasoningEffort,
71
+ buildPrompt: buildSegmentationPrompt,
72
+ });
73
+ }
74
+ /**
75
+ * Backward-compatible default-options stage. Existing consumers
76
+ * (tests, the v2 factory's pre-1.3.1 path) keep importing this and
77
+ * see the new internal defaults — same as if they had called
78
+ * `createSegmentationStage()` with no args.
79
+ */
80
+ export const segmentationStage = createSegmentationStage();
81
+ //# sourceMappingURL=segmentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segmentation.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/segmentation.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,kEAAkE;AAClE,mE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;QACtC,KAAK,EAAE,kBAAkB;QACzB,eAAe,EACX,OAAO,EAAE,eAAe,IAAI,8BAA8B;QAC9D,eAAe,EAAE,OAAO,EAAE,eAAe;QACzC,WAAW,EAAE,uBAAuB;KACvC,CAAC,CAAA;AACN,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAC1B,uBAAuB,EAAE,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { type TClaimCanonicalizationOutput, type TVariableAssignmentOutput } from "./schemas.js";
2
+ import type { TStage } from "../../../lib/pipelines/types.js";
3
+ export declare function isValidVariableSymbol(symbol: string): boolean;
4
+ export type TAssignVariablesInput = {
5
+ canonicalClaims: TClaimCanonicalizationOutput["canonicalClaims"];
6
+ generateId: () => string;
7
+ };
8
+ /**
9
+ * Pure helper exposed for direct unit testing. The `variable-assignment`
10
+ * stage is a thin wrapper that reads `ctx.get(claim-canonicalization)`
11
+ * and calls this function with `ctx.generateId`.
12
+ */
13
+ export declare function assignVariables(input: TAssignVariablesInput): TVariableAssignmentOutput;
14
+ export declare const variableAssignmentStage: TStage<TVariableAssignmentOutput>;
15
+ //# sourceMappingURL=variable-assignment.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable-assignment.d.ts","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/variable-assignment.ts"],"names":[],"mappings":"AAwBA,OAAO,EAIH,KAAK,4BAA4B,EACjC,KAAK,yBAAyB,EACjC,MAAM,cAAc,CAAA;AAErB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AAI7D,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAI7D;AAED,MAAM,MAAM,qBAAqB,GAAG;IAChC,eAAe,EAAE,4BAA4B,CAAC,iBAAiB,CAAC,CAAA;IAChE,UAAU,EAAE,MAAM,MAAM,CAAA;CAC3B,CAAA;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC3B,KAAK,EAAE,qBAAqB,GAC7B,yBAAyB,CA0B3B;AAED,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,yBAAyB,CAoBhE,CAAA"}
@@ -0,0 +1,84 @@
1
+ // `variable-assignment` — deterministic stage that mints one
2
+ // `TParsedVariable`-shaped record per canonical claim.
3
+ //
4
+ // Behavior (spec §7.2 row 8):
5
+ // 1. Read `claim-canonicalization.canonicalClaims` (in canonicalization
6
+ // order).
7
+ // 2. For each claim, attempt to use its `suggestedSymbol` as the
8
+ // variable symbol. The symbol is valid iff it matches the regex
9
+ // `/^[a-zA-Z_][a-zA-Z0-9_]{0,31}$/` AND is unique among already-
10
+ // assigned variable symbols.
11
+ // 3. If the suggested symbol is invalid or already used, fall back to
12
+ // `p1`, `p2`, `p3`, ... where the integer is the smallest one not
13
+ // already used by any valid suggested symbol or earlier fallback.
14
+ // 4. Mint a fresh variable `miniId` (separate from the claim's
15
+ // `miniId`) via `ctx.generateId` for each output record. Tests use
16
+ // a deterministic stub generator that produces `v1`, `v2`, ...
17
+ //
18
+ // The framework default `ctx.generateId` is `crypto.randomUUID()`; the
19
+ // recording-replay tests inject a deterministic counter so the
20
+ // recorded fixtures stay stable.
21
+ //
22
+ // Errors / failures: this stage never throws and emits no
23
+ // `ProcessingFailure`s. Empty input simply yields an empty array.
24
+ import { STAGE_IDS, VariableAssignmentOutputSchema, } from "./schemas.js";
25
+ import { deterministicStage } from "../../../lib/pipelines/stage-helpers.js";
26
+ const SYMBOL_REGEX = /^[a-zA-Z_][a-zA-Z0-9_]{0,31}$/;
27
+ export function isValidVariableSymbol(symbol) {
28
+ if (symbol.length === 0)
29
+ return false;
30
+ if (symbol.length > 32)
31
+ return false;
32
+ return SYMBOL_REGEX.test(symbol);
33
+ }
34
+ /**
35
+ * Pure helper exposed for direct unit testing. The `variable-assignment`
36
+ * stage is a thin wrapper that reads `ctx.get(claim-canonicalization)`
37
+ * and calls this function with `ctx.generateId`.
38
+ */
39
+ export function assignVariables(input) {
40
+ const out = [];
41
+ const usedSymbols = new Set();
42
+ let fallbackCounter = 1;
43
+ for (const claim of input.canonicalClaims) {
44
+ let symbol;
45
+ const suggested = claim.suggestedSymbol;
46
+ if (isValidVariableSymbol(suggested) && !usedSymbols.has(suggested)) {
47
+ symbol = suggested;
48
+ }
49
+ else {
50
+ // Walk fallback counter to the next unused `p<n>`.
51
+ while (usedSymbols.has(`p${fallbackCounter}`)) {
52
+ fallbackCounter += 1;
53
+ }
54
+ symbol = `p${fallbackCounter}`;
55
+ fallbackCounter += 1;
56
+ }
57
+ usedSymbols.add(symbol);
58
+ out.push({
59
+ miniId: input.generateId(),
60
+ symbol,
61
+ claimMiniId: claim.miniId,
62
+ });
63
+ }
64
+ return out;
65
+ }
66
+ export const variableAssignmentStage = deterministicStage({
67
+ id: STAGE_IDS.variableAssignment,
68
+ dependsOn: [STAGE_IDS.claimCanonicalization],
69
+ outputSchema: VariableAssignmentOutputSchema,
70
+ fn: (ctx) => {
71
+ const canon = ctx.get(STAGE_IDS.claimCanonicalization);
72
+ if (!canon) {
73
+ // Required dep — executor wouldn't have scheduled us
74
+ // without it. Defensive: empty array if it somehow
75
+ // arrived.
76
+ return [];
77
+ }
78
+ return assignVariables({
79
+ canonicalClaims: canon.canonicalClaims,
80
+ generateId: ctx.generateId,
81
+ });
82
+ },
83
+ });
84
+ //# sourceMappingURL=variable-assignment.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable-assignment.js","sourceRoot":"","sources":["../../../../src/extensions/argument-ingestion/stages/variable-assignment.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,uDAAuD;AACvD,EAAE;AACF,8BAA8B;AAC9B,0EAA0E;AAC1E,eAAe;AACf,mEAAmE;AACnE,qEAAqE;AACrE,sEAAsE;AACtE,kCAAkC;AAClC,wEAAwE;AACxE,uEAAuE;AACvE,uEAAuE;AACvE,iEAAiE;AACjE,wEAAwE;AACxE,oEAAoE;AACpE,EAAE;AACF,uEAAuE;AACvE,+DAA+D;A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