@lucern/contracts 0.1.0-alpha.3 → 0.1.1-alpha.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.
- package/dist/index.d.ts +2003 -29
- package/dist/index.js +5627 -30
- package/package.json +15 -58
- package/src/agents/v1.ts +8 -0
- package/src/api-enums.contract.ts +183 -0
- package/{dist/auth-context.contract.js → src/auth-context.contract.ts} +1 -1
- package/{dist/auth-session.contract.js → src/auth-session.contract.ts} +1 -1
- package/src/auth.contract.ts +162 -0
- package/src/beliefs/v1.ts +8 -0
- package/src/context-pack.contract.ts +704 -0
- package/src/convex-admin.contract.ts +14 -0
- package/{dist/events-types.contract.js → src/events-types.contract.ts} +1 -1
- package/src/events.contract.ts +376 -0
- package/src/evidence/v1.ts +8 -0
- package/src/gateway.contract.ts +151 -0
- package/src/graph/v1.ts +8 -0
- package/src/ids.contract.ts +36 -0
- package/src/index.ts +30 -0
- package/src/lens-filter.contract.ts +183 -0
- package/src/lens-workflow.contract.ts +162 -0
- package/src/mcp-tools.contract.ts +3636 -0
- package/src/ontologies/v1.ts +8 -0
- package/{dist/ontology-matching.contract.js → src/ontology-matching.contract.ts} +1 -1
- package/src/prompt.contract.ts +50 -0
- package/src/questions/v1.ts +8 -0
- package/src/sdk-methods.contract.ts +522 -0
- package/src/sdk-tools.contract.ts +1545 -0
- package/src/text-matching.contract.ts +347 -0
- package/{dist/topic-scope.contract.js → src/topic-scope.contract.ts} +1 -1
- package/src/topics/v1.ts +8 -0
- package/{dist/v1/agents/v1.d.ts → src/v1/agents/v1.ts} +0 -1
- package/{dist/v1/beliefs/v1.d.ts → src/v1/beliefs/v1.ts} +0 -1
- package/{dist/v1/evidence/v1.d.ts → src/v1/evidence/v1.ts} +0 -1
- package/{dist/v1/graph/v1.d.ts → src/v1/graph/v1.ts} +0 -1
- package/src/v1/ontologies/v1.ts +276 -0
- package/{dist/v1/questions/v1.d.ts → src/v1/questions/v1.ts} +0 -1
- package/src/v1/topics/v1.ts +79 -0
- package/{dist/v1/worktrees/v1.d.ts → src/v1/worktrees/v1.ts} +0 -1
- package/src/workflow-runtime.contract.ts +440 -0
- package/src/worktrees/v1.ts +8 -0
- package/tsconfig.json +9 -0
- package/README.md +0 -43
- package/dist/api-enums.contract.d.ts +0 -59
- package/dist/api-enums.contract.d.ts.map +0 -1
- package/dist/api-enums.contract.js +0 -148
- package/dist/api-enums.contract.js.map +0 -1
- package/dist/auth-context.contract.d.ts +0 -9
- package/dist/auth-context.contract.d.ts.map +0 -1
- package/dist/auth-context.contract.js.map +0 -1
- package/dist/auth-session.contract.d.ts +0 -9
- package/dist/auth-session.contract.d.ts.map +0 -1
- package/dist/auth-session.contract.js.map +0 -1
- package/dist/auth.contract.d.ts +0 -89
- package/dist/auth.contract.d.ts.map +0 -1
- package/dist/auth.contract.js +0 -58
- package/dist/auth.contract.js.map +0 -1
- package/dist/context-pack.contract.d.ts +0 -495
- package/dist/context-pack.contract.d.ts.map +0 -1
- package/dist/context-pack.contract.js +0 -170
- package/dist/context-pack.contract.js.map +0 -1
- package/dist/convex-admin.contract.d.ts +0 -6
- package/dist/convex-admin.contract.d.ts.map +0 -1
- package/dist/convex-admin.contract.js +0 -2
- package/dist/convex-admin.contract.js.map +0 -1
- package/dist/events-types.contract.d.ts +0 -9
- package/dist/events-types.contract.d.ts.map +0 -1
- package/dist/events-types.contract.js.map +0 -1
- package/dist/events.contract.d.ts +0 -177
- package/dist/events.contract.d.ts.map +0 -1
- package/dist/events.contract.js +0 -160
- package/dist/events.contract.js.map +0 -1
- package/dist/gateway.contract.d.ts +0 -75
- package/dist/gateway.contract.d.ts.map +0 -1
- package/dist/gateway.contract.js +0 -20
- package/dist/gateway.contract.js.map +0 -1
- package/dist/ids.contract.d.ts +0 -8
- package/dist/ids.contract.d.ts.map +0 -1
- package/dist/ids.contract.js +0 -25
- package/dist/ids.contract.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lens-filter.contract.d.ts +0 -71
- package/dist/lens-filter.contract.d.ts.map +0 -1
- package/dist/lens-filter.contract.js +0 -96
- package/dist/lens-filter.contract.js.map +0 -1
- package/dist/lens-workflow.contract.d.ts +0 -85
- package/dist/lens-workflow.contract.d.ts.map +0 -1
- package/dist/lens-workflow.contract.js +0 -55
- package/dist/lens-workflow.contract.js.map +0 -1
- package/dist/mcp-tools.contract.d.ts +0 -152
- package/dist/mcp-tools.contract.d.ts.map +0 -1
- package/dist/mcp-tools.contract.js +0 -3282
- package/dist/mcp-tools.contract.js.map +0 -1
- package/dist/ontology-matching.contract.d.ts +0 -9
- package/dist/ontology-matching.contract.d.ts.map +0 -1
- package/dist/ontology-matching.contract.js.map +0 -1
- package/dist/prompt.contract.d.ts +0 -25
- package/dist/prompt.contract.d.ts.map +0 -1
- package/dist/prompt.contract.js +0 -25
- package/dist/prompt.contract.js.map +0 -1
- package/dist/sdk-methods.contract.d.ts +0 -356
- package/dist/sdk-methods.contract.d.ts.map +0 -1
- package/dist/sdk-methods.contract.js +0 -17
- package/dist/sdk-methods.contract.js.map +0 -1
- package/dist/sdk-tools.contract.d.ts +0 -93
- package/dist/sdk-tools.contract.d.ts.map +0 -1
- package/dist/sdk-tools.contract.js +0 -1399
- package/dist/sdk-tools.contract.js.map +0 -1
- package/dist/text-matching.contract.d.ts +0 -54
- package/dist/text-matching.contract.d.ts.map +0 -1
- package/dist/text-matching.contract.js +0 -278
- package/dist/text-matching.contract.js.map +0 -1
- package/dist/topic-scope.contract.d.ts +0 -9
- package/dist/topic-scope.contract.d.ts.map +0 -1
- package/dist/topic-scope.contract.js.map +0 -1
- package/dist/v1/agents/v1.d.ts.map +0 -1
- package/dist/v1/agents/v1.js +0 -2
- package/dist/v1/agents/v1.js.map +0 -1
- package/dist/v1/beliefs/v1.d.ts.map +0 -1
- package/dist/v1/beliefs/v1.js +0 -2
- package/dist/v1/beliefs/v1.js.map +0 -1
- package/dist/v1/evidence/v1.d.ts.map +0 -1
- package/dist/v1/evidence/v1.js +0 -2
- package/dist/v1/evidence/v1.js.map +0 -1
- package/dist/v1/graph/v1.d.ts.map +0 -1
- package/dist/v1/graph/v1.js +0 -2
- package/dist/v1/graph/v1.js.map +0 -1
- package/dist/v1/ontologies/v1.d.ts +0 -77
- package/dist/v1/ontologies/v1.d.ts.map +0 -1
- package/dist/v1/ontologies/v1.js +0 -179
- package/dist/v1/ontologies/v1.js.map +0 -1
- package/dist/v1/questions/v1.d.ts.map +0 -1
- package/dist/v1/questions/v1.js +0 -2
- package/dist/v1/questions/v1.js.map +0 -1
- package/dist/v1/topics/v1.d.ts +0 -20
- package/dist/v1/topics/v1.d.ts.map +0 -1
- package/dist/v1/topics/v1.js +0 -62
- package/dist/v1/topics/v1.js.map +0 -1
- package/dist/v1/worktrees/v1.d.ts.map +0 -1
- package/dist/v1/worktrees/v1.js +0 -2
- package/dist/v1/worktrees/v1.js.map +0 -1
- package/dist/workflow-runtime.contract.d.ts +0 -162
- package/dist/workflow-runtime.contract.d.ts.map +0 -1
- package/dist/workflow-runtime.contract.js +0 -258
- package/dist/workflow-runtime.contract.js.map +0 -1
|
@@ -1,495 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context-Pack Contract v1
|
|
3
|
-
*
|
|
4
|
-
* Canonical TypeScript types and constants for the context-pack output schema.
|
|
5
|
-
* This is the external contract consumed by:
|
|
6
|
-
* - MCP tool `compile_context` (canonical compiler read)
|
|
7
|
-
* - SDK/HTTP consumers that read compiled context packs programmatically
|
|
8
|
-
* - Benchmark harnesses (context-pack-ab)
|
|
9
|
-
*
|
|
10
|
-
* BREAKING CHANGE RULES:
|
|
11
|
-
* - Adding optional fields to ContextPackV1 is NON-breaking
|
|
12
|
-
* - Removing fields or changing types is BREAKING (bump CONTEXT_PACK_SCHEMA_VERSION)
|
|
13
|
-
* - Changing section budget ratios or ranking weights is NON-breaking (tuning)
|
|
14
|
-
* - Changing the version string is BREAKING (consumers check it)
|
|
15
|
-
*/
|
|
16
|
-
/** Canonical version string. Consumers MUST check this field for compatibility. */
|
|
17
|
-
export declare const CONTEXT_PACK_SCHEMA_VERSION: "1.0.0";
|
|
18
|
-
/**
|
|
19
|
-
* Available ranking profiles for context-pack assembly.
|
|
20
|
-
*
|
|
21
|
-
* - `baseline_v1`: Simple token-hit counting. Items with zero query hits are excluded.
|
|
22
|
-
* - `weighted_v1`: Multi-signal scoring combining query relevance, recency, confidence,
|
|
23
|
-
* belief type, priority, and severity with section-specific weight vectors.
|
|
24
|
-
*/
|
|
25
|
-
export type ContextRankingProfile = "baseline_v1" | "weighted_v1";
|
|
26
|
-
export declare const CONTEXT_RANKING_PROFILES: readonly ContextRankingProfile[];
|
|
27
|
-
export declare const DEFAULT_RANKING_PROFILE: ContextRankingProfile;
|
|
28
|
-
/**
|
|
29
|
-
* Context compilation mode.
|
|
30
|
-
*
|
|
31
|
-
* - `standard`: Default — ranked beliefs, questions, evidence, contradictions.
|
|
32
|
-
* - `delta`: Diff-aware — adds failure context, verification obligations,
|
|
33
|
-
* and worktree ledger analysis to the standard context pack.
|
|
34
|
-
*/
|
|
35
|
-
export type ContextCompilationMode = "standard" | "delta";
|
|
36
|
-
export declare const DEFAULT_COMPILATION_MODE: ContextCompilationMode;
|
|
37
|
-
/**
|
|
38
|
-
* The five canonical sections of a context pack.
|
|
39
|
-
* Order matters: invariants are injected first, contradictions last.
|
|
40
|
-
*/
|
|
41
|
-
export type ContextPackSectionKey = "invariants" | "activeBeliefs" | "openQuestions" | "recentEvidence" | "contradictions";
|
|
42
|
-
export declare const CONTEXT_PACK_SECTION_KEYS: readonly ContextPackSectionKey[];
|
|
43
|
-
/**
|
|
44
|
-
* Token budget allocation ratios per section.
|
|
45
|
-
* These sum to 1.0 and determine how the total tokenBudget is divided.
|
|
46
|
-
*
|
|
47
|
-
* Rationale:
|
|
48
|
-
* - invariants (0.28): Highest-priority constraints, injected first
|
|
49
|
-
* - activeBeliefs (0.30): Largest section, carries domain knowledge
|
|
50
|
-
* - openQuestions (0.17): Unresolved work items guide agent behavior
|
|
51
|
-
* - recentEvidence (0.17): Implementation context for grounding
|
|
52
|
-
* - contradictions (0.08): Tension signals, smallest section
|
|
53
|
-
*/
|
|
54
|
-
export declare const SECTION_BUDGET_RATIOS: Readonly<Record<ContextPackSectionKey, number>>;
|
|
55
|
-
/** Minimum allowed token budget. Below this, context packs lose utility. */
|
|
56
|
-
export declare const MIN_TOKEN_BUDGET = 400;
|
|
57
|
-
/** Maximum allowed token budget. Above this, context packs bloat prompts. */
|
|
58
|
-
export declare const MAX_TOKEN_BUDGET = 8000;
|
|
59
|
-
/** Default token budget when caller does not specify. */
|
|
60
|
-
export declare const DEFAULT_TOKEN_BUDGET = 1800;
|
|
61
|
-
/** Default max items per section. */
|
|
62
|
-
export declare const DEFAULT_SECTION_LIMIT = 8;
|
|
63
|
-
/** Hard ceiling on items per section. */
|
|
64
|
-
export declare const MAX_SECTION_LIMIT = 25;
|
|
65
|
-
/** Minimum contradiction section budget floor (tokens). */
|
|
66
|
-
export declare const MIN_CONTRADICTION_BUDGET = 40;
|
|
67
|
-
/**
|
|
68
|
-
* Weight vectors for the weighted_v1 ranking profile.
|
|
69
|
-
* Each section has a different signal mix:
|
|
70
|
-
*
|
|
71
|
-
* - query: How many query tokens appear in the candidate text
|
|
72
|
-
* - recency: Exponential decay from updatedAt (half-life = 30 days)
|
|
73
|
-
* - confidence: Belief confidence score [0,1]
|
|
74
|
-
* - beliefType: Bonus for invariant > tenet > principle > other
|
|
75
|
-
* - priority: Question priority (critical > high > medium > low)
|
|
76
|
-
* - severity: Contradiction severity (critical > high > medium > low)
|
|
77
|
-
*/
|
|
78
|
-
export type RankingWeightVector = {
|
|
79
|
-
query: number;
|
|
80
|
-
recency: number;
|
|
81
|
-
confidence?: number;
|
|
82
|
-
beliefType?: number;
|
|
83
|
-
priority?: number;
|
|
84
|
-
severity?: number;
|
|
85
|
-
};
|
|
86
|
-
export declare const RANKING_WEIGHTS: Readonly<Record<ContextPackSectionKey, RankingWeightVector>>;
|
|
87
|
-
/** Recency decay half-life in days. After 30 days, recency score = 0.5. */
|
|
88
|
-
export declare const RECENCY_HALF_LIFE_DAYS = 30;
|
|
89
|
-
/**
|
|
90
|
-
* Ranking weight vector for the relatedEntities section.
|
|
91
|
-
* Entities are ranked by query relevance and connectivity (bridge edge count).
|
|
92
|
-
* Separate from RANKING_WEIGHTS because entities are not part of the
|
|
93
|
-
* token-budgeted injection plan.
|
|
94
|
-
*/
|
|
95
|
-
export declare const ENTITY_RANKING_WEIGHTS: {
|
|
96
|
-
readonly query: 0.4;
|
|
97
|
-
readonly connectivity: 0.6;
|
|
98
|
-
};
|
|
99
|
-
/** Default max entities to include in the context pack. */
|
|
100
|
-
export declare const DEFAULT_ENTITY_LIMIT = 10;
|
|
101
|
-
/** Hard ceiling on entities per context pack. */
|
|
102
|
-
export declare const MAX_ENTITY_LIMIT = 50;
|
|
103
|
-
/**
|
|
104
|
-
* Bonus multiplier for belief types in ranking.
|
|
105
|
-
* Invariants get 1.0, unknown types get 0.4.
|
|
106
|
-
*/
|
|
107
|
-
export declare const BELIEF_TYPE_BONUS: Readonly<Record<string, number>>;
|
|
108
|
-
export declare const DEFAULT_BELIEF_TYPE_BONUS = 0.4;
|
|
109
|
-
export declare const PRIORITY_SCORES: Readonly<Record<string, number>>;
|
|
110
|
-
export declare const DEFAULT_PRIORITY_SCORE = 0.5;
|
|
111
|
-
export declare const SEVERITY_SCORES: Readonly<Record<string, number>>;
|
|
112
|
-
export declare const DEFAULT_SEVERITY_SCORE = 0.5;
|
|
113
|
-
/** A ranked belief in the invariants or activeBeliefs section. */
|
|
114
|
-
export type ContextPackBelief = {
|
|
115
|
-
nodeId: string;
|
|
116
|
-
canonicalText: string;
|
|
117
|
-
confidence: number | null;
|
|
118
|
-
beliefType: string | null;
|
|
119
|
-
score: number;
|
|
120
|
-
/** Present in activeBeliefs, absent in invariants */
|
|
121
|
-
status?: string;
|
|
122
|
-
updatedAt?: number | null;
|
|
123
|
-
/** Human-readable explanation of why this item was ranked here (RS-2). */
|
|
124
|
-
justification?: string;
|
|
125
|
-
};
|
|
126
|
-
/** A ranked question in the openQuestions section. */
|
|
127
|
-
export type ContextPackQuestion = {
|
|
128
|
-
questionId: string;
|
|
129
|
-
text: string;
|
|
130
|
-
status: string;
|
|
131
|
-
priority: string;
|
|
132
|
-
updatedAt?: number | null;
|
|
133
|
-
score: number;
|
|
134
|
-
/** Human-readable explanation of why this item was ranked here (RS-2). */
|
|
135
|
-
justification?: string;
|
|
136
|
-
};
|
|
137
|
-
/** A ranked evidence item in the recentEvidence section. */
|
|
138
|
-
export type ContextPackEvidence = {
|
|
139
|
-
nodeId: string;
|
|
140
|
-
canonicalText: string;
|
|
141
|
-
sourceUrl: string | null;
|
|
142
|
-
kind: string;
|
|
143
|
-
createdAt: number | null;
|
|
144
|
-
score: number;
|
|
145
|
-
/** Human-readable explanation of why this item was ranked here (RS-2). */
|
|
146
|
-
justification?: string;
|
|
147
|
-
};
|
|
148
|
-
/** A ranked contradiction in the contradictions section. */
|
|
149
|
-
export type ContextPackContradiction = {
|
|
150
|
-
contradictionId: string;
|
|
151
|
-
severity: string;
|
|
152
|
-
status: string;
|
|
153
|
-
description: string;
|
|
154
|
-
score: number;
|
|
155
|
-
/** Human-readable explanation of why this item was ranked here (RS-2). */
|
|
156
|
-
justification?: string;
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* An entity from the ontological layer surfaced in the context pack.
|
|
160
|
-
* Entities are domain objects (companies, people, functions, etc.) connected
|
|
161
|
-
* to beliefs via bridge edges. They provide the "reality anchor" that makes
|
|
162
|
-
* the reasoning graph domain-aware.
|
|
163
|
-
*/
|
|
164
|
-
export type ContextPackEntity = {
|
|
165
|
-
/** Convex document ID of the entity node. */
|
|
166
|
-
nodeId: string;
|
|
167
|
-
/** Entity type (e.g., "company", "person", "function"). */
|
|
168
|
-
entityType: string;
|
|
169
|
-
/** Human-readable title/name of the entity. */
|
|
170
|
-
title: string;
|
|
171
|
-
/** Number of beliefs connected to this entity via bridge edges. */
|
|
172
|
-
connectedBeliefCount: number;
|
|
173
|
-
/** Number of evidence items referencing this entity. */
|
|
174
|
-
connectedEvidenceCount: number;
|
|
175
|
-
/** Relevance score from ranking algorithm. */
|
|
176
|
-
score: number;
|
|
177
|
-
/** Entity metadata (structured per ontology schema). */
|
|
178
|
-
metadata?: Record<string, unknown>;
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* A lattice seed entry representing a belief that was auto-generated
|
|
182
|
-
* to cover an ontology entity type within a topic scope.
|
|
183
|
-
*/
|
|
184
|
-
export type BeliefLatticeSeed = {
|
|
185
|
-
/** The belief node ID that was created or already existed. */
|
|
186
|
-
beliefNodeId: string;
|
|
187
|
-
/** The entity type this seed belief covers. */
|
|
188
|
-
entityType: string;
|
|
189
|
-
/** Whether this seed was newly created or already existed. */
|
|
190
|
-
created: boolean;
|
|
191
|
-
/** The canonical text of the seed belief. */
|
|
192
|
-
canonicalText: string;
|
|
193
|
-
};
|
|
194
|
-
/** Counts and scoped health signals for the context pack. */
|
|
195
|
-
export type ContextPackSummary = {
|
|
196
|
-
totalBeliefs: number;
|
|
197
|
-
invariants: number;
|
|
198
|
-
openQuestions: number;
|
|
199
|
-
evidenceItems: number;
|
|
200
|
-
contradictions: number;
|
|
201
|
-
/** Number of ontological entities in scope (optional, present when entity graph is active). */
|
|
202
|
-
relatedEntities?: number;
|
|
203
|
-
scopedTopics: number;
|
|
204
|
-
descendantDepth: number;
|
|
205
|
-
query: string | null;
|
|
206
|
-
};
|
|
207
|
-
/** A failed approach surfaced from the failure log for anti-repetition. */
|
|
208
|
-
export type ContextPackFailure = {
|
|
209
|
-
/** Lucern attempt/evidence node ID. */
|
|
210
|
-
attemptId: string;
|
|
211
|
-
/** What was tried. */
|
|
212
|
-
approach: string;
|
|
213
|
-
/** Why it failed. */
|
|
214
|
-
outcome: string;
|
|
215
|
-
/** When the attempt was recorded (ms since epoch). */
|
|
216
|
-
recordedAt: number;
|
|
217
|
-
/** Relevance score from ranking algorithm. */
|
|
218
|
-
score: number;
|
|
219
|
-
};
|
|
220
|
-
/** Failure context section appended to context packs in delta mode. */
|
|
221
|
-
export type ContextPackFailureContext = {
|
|
222
|
-
/** Ranked failed approaches relevant to the current query. */
|
|
223
|
-
failures: ContextPackFailure[];
|
|
224
|
-
/** IDs of items suppressed from other sections due to anti-repetition. */
|
|
225
|
-
suppressedIds: string[];
|
|
226
|
-
};
|
|
227
|
-
/** A verification obligation surfaced by delta compilation. */
|
|
228
|
-
export type VerificationObligation = {
|
|
229
|
-
/** What must be verified. */
|
|
230
|
-
description: string;
|
|
231
|
-
/** Source of the obligation (e.g., "belief:xyz confidence drop"). */
|
|
232
|
-
source: string;
|
|
233
|
-
/** Severity: how important it is to verify. */
|
|
234
|
-
severity: "critical" | "high" | "medium" | "low";
|
|
235
|
-
};
|
|
236
|
-
/** Delta report appended to context packs when mode = "delta". */
|
|
237
|
-
export type ContextPackDeltaReport = {
|
|
238
|
-
/** Items that changed since the reference point (new, updated, removed). */
|
|
239
|
-
changedItems: Array<{
|
|
240
|
-
id: string;
|
|
241
|
-
section: ContextPackSectionKey;
|
|
242
|
-
changeType: "added" | "updated" | "removed" | "confidence_changed";
|
|
243
|
-
summary: string;
|
|
244
|
-
}>;
|
|
245
|
-
/** Obligations the consuming session must verify. */
|
|
246
|
-
verificationObligations: VerificationObligation[];
|
|
247
|
-
/** Reference point for the delta (worktree ID, timestamp, or commit SHA). */
|
|
248
|
-
referencePoint: string;
|
|
249
|
-
};
|
|
250
|
-
/**
|
|
251
|
-
* Per-section weight overrides that domain packs can apply.
|
|
252
|
-
* Overrides merge with RANKING_WEIGHTS — only specified fields replace defaults.
|
|
253
|
-
*/
|
|
254
|
-
export type PackWeightOverride = {
|
|
255
|
-
/** Which section to override weights for. */
|
|
256
|
-
section: ContextPackSectionKey;
|
|
257
|
-
/** Partial weight vector — only specified fields replace defaults. */
|
|
258
|
-
weights: Partial<RankingWeightVector>;
|
|
259
|
-
};
|
|
260
|
-
/** Token-budgeted section selections for prompt injection. */
|
|
261
|
-
export type ContextPackInjectionPolicy = {
|
|
262
|
-
/** Total token budget for the entire context pack. */
|
|
263
|
-
tokenBudget: number;
|
|
264
|
-
/** Estimated tokens consumed across all sections. */
|
|
265
|
-
estimatedTokens: number;
|
|
266
|
-
/** Per-section token budgets derived from SECTION_BUDGET_RATIOS. */
|
|
267
|
-
sectionBudgets: Record<ContextPackSectionKey, number>;
|
|
268
|
-
/** Actual token usage per section after greedy fill. */
|
|
269
|
-
sectionUsage: Record<ContextPackSectionKey, number>;
|
|
270
|
-
/** Node/question IDs selected for injection, per section. */
|
|
271
|
-
selected: Record<ContextPackSectionKey, string[]>;
|
|
272
|
-
/** Items that were scored but excluded from injection, with reason (RS-2). */
|
|
273
|
-
excludedItems?: Array<{
|
|
274
|
-
id: string;
|
|
275
|
-
section: ContextPackSectionKey;
|
|
276
|
-
reason: "budget_exceeded" | "anti_repetition" | "below_threshold";
|
|
277
|
-
score: number;
|
|
278
|
-
}>;
|
|
279
|
-
};
|
|
280
|
-
/** Telemetry for context pack assembly. */
|
|
281
|
-
export type ContextPackDiagnostics = {
|
|
282
|
-
/** Total candidates scored across all sections. */
|
|
283
|
-
itemsScored: number;
|
|
284
|
-
/** Ratio of estimatedTokens / tokenBudget. Range [0, 1+]. */
|
|
285
|
-
tokenBudgetUtilization: number;
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* Public context surface returned by the SDK-facing context client.
|
|
289
|
-
*
|
|
290
|
-
* This preserves the existing external shape while the canonical compiler
|
|
291
|
-
* contract evolves in parallel as ContextPackV1.
|
|
292
|
-
*/
|
|
293
|
-
export type PublicContextBelief = {
|
|
294
|
-
beliefId: string;
|
|
295
|
-
text: string;
|
|
296
|
-
confidence: number | null;
|
|
297
|
-
beliefType?: string | null;
|
|
298
|
-
status?: string;
|
|
299
|
-
updatedAt?: number | null;
|
|
300
|
-
score: number;
|
|
301
|
-
justification?: string;
|
|
302
|
-
};
|
|
303
|
-
export type PublicContextQuestion = {
|
|
304
|
-
questionId: string;
|
|
305
|
-
text: string;
|
|
306
|
-
status: string;
|
|
307
|
-
priority: string;
|
|
308
|
-
updatedAt?: number | null;
|
|
309
|
-
score: number;
|
|
310
|
-
justification?: string;
|
|
311
|
-
};
|
|
312
|
-
export type PublicContextEvidence = {
|
|
313
|
-
evidenceId: string;
|
|
314
|
-
text: string;
|
|
315
|
-
sourceUrl?: string | null;
|
|
316
|
-
kind: string;
|
|
317
|
-
createdAt?: number | null;
|
|
318
|
-
score: number;
|
|
319
|
-
justification?: string;
|
|
320
|
-
};
|
|
321
|
-
export type PublicContextContradiction = {
|
|
322
|
-
contradictionId: string;
|
|
323
|
-
severity: string;
|
|
324
|
-
status: string;
|
|
325
|
-
description: string;
|
|
326
|
-
score: number;
|
|
327
|
-
justification?: string;
|
|
328
|
-
};
|
|
329
|
-
export type PublicContextEntity = {
|
|
330
|
-
entityId: string;
|
|
331
|
-
entityType: string;
|
|
332
|
-
title: string;
|
|
333
|
-
text?: string;
|
|
334
|
-
connectedBeliefCount: number;
|
|
335
|
-
connectedEvidenceCount: number;
|
|
336
|
-
score: number;
|
|
337
|
-
metadata?: Record<string, unknown>;
|
|
338
|
-
};
|
|
339
|
-
export type PublicContextInjectionPolicy = {
|
|
340
|
-
tokenBudget: number;
|
|
341
|
-
estimatedTokens: number;
|
|
342
|
-
sectionBudgets: Record<string, number>;
|
|
343
|
-
sectionUsage: Record<string, number>;
|
|
344
|
-
selected: Record<string, string[]>;
|
|
345
|
-
excludedItems?: Array<{
|
|
346
|
-
id: string;
|
|
347
|
-
section: string;
|
|
348
|
-
reason: "budget_exceeded" | "anti_repetition" | "below_threshold";
|
|
349
|
-
score: number;
|
|
350
|
-
}>;
|
|
351
|
-
};
|
|
352
|
-
export type PublicCompiledContext = {
|
|
353
|
-
schemaVersion: string;
|
|
354
|
-
topicId: string;
|
|
355
|
-
topicName: string;
|
|
356
|
-
scopedTopicIds: string[];
|
|
357
|
-
generatedAt: number;
|
|
358
|
-
ranking: ContextRankingProfile;
|
|
359
|
-
summary: Record<string, unknown>;
|
|
360
|
-
invariants: PublicContextBelief[];
|
|
361
|
-
activeBeliefs: PublicContextBelief[];
|
|
362
|
-
openQuestions: PublicContextQuestion[];
|
|
363
|
-
recentEvidence: PublicContextEvidence[];
|
|
364
|
-
contradictions: PublicContextContradiction[];
|
|
365
|
-
relatedEntities?: PublicContextEntity[];
|
|
366
|
-
contextNarrative: string[];
|
|
367
|
-
injectionPolicy: PublicContextInjectionPolicy;
|
|
368
|
-
diagnostics: Record<string, unknown>;
|
|
369
|
-
compilationMode?: string;
|
|
370
|
-
failureContext?: {
|
|
371
|
-
failures: Array<{
|
|
372
|
-
attemptId: string;
|
|
373
|
-
approach: string;
|
|
374
|
-
outcome: string;
|
|
375
|
-
recordedAt: number;
|
|
376
|
-
score: number;
|
|
377
|
-
}>;
|
|
378
|
-
suppressedIds: string[];
|
|
379
|
-
};
|
|
380
|
-
deltaReport?: {
|
|
381
|
-
changedItems: Array<{
|
|
382
|
-
id: string;
|
|
383
|
-
section: string;
|
|
384
|
-
changeType: string;
|
|
385
|
-
summary: string;
|
|
386
|
-
}>;
|
|
387
|
-
verificationObligations: Array<{
|
|
388
|
-
description: string;
|
|
389
|
-
source: string;
|
|
390
|
-
severity: "critical" | "high" | "medium" | "low";
|
|
391
|
-
}>;
|
|
392
|
-
referencePoint: string;
|
|
393
|
-
};
|
|
394
|
-
appliedWeightOverrides?: unknown[];
|
|
395
|
-
};
|
|
396
|
-
/**
|
|
397
|
-
* The canonical output schema for context compilation responses.
|
|
398
|
-
*
|
|
399
|
-
* This is the contract that consumers depend on. All fields are required
|
|
400
|
-
* in the output. Adding optional fields is non-breaking; removing or
|
|
401
|
-
* changing types is breaking (requires version bump).
|
|
402
|
-
*/
|
|
403
|
-
export type ContextPackV1 = {
|
|
404
|
-
/** Schema version for compatibility checking. */
|
|
405
|
-
schemaVersion: typeof CONTEXT_PACK_SCHEMA_VERSION;
|
|
406
|
-
/** Deprecated compatibility alias for the requested scope ID. */
|
|
407
|
-
projectId?: string;
|
|
408
|
-
/** Resolved topic ID after scope resolution. */
|
|
409
|
-
topicId: string;
|
|
410
|
-
/** Human-readable topic name. */
|
|
411
|
-
topicName: string;
|
|
412
|
-
/** All topic IDs included in the neighborhood expansion. */
|
|
413
|
-
scopedTopicIds: string[];
|
|
414
|
-
/** Deterministic freshness watermark for this pack (ms since epoch). */
|
|
415
|
-
generatedAt: number;
|
|
416
|
-
/** Which ranking profile was used. */
|
|
417
|
-
rankingProfile: ContextRankingProfile;
|
|
418
|
-
/** Aggregate counts and health signals. */
|
|
419
|
-
summary: ContextPackSummary;
|
|
420
|
-
/** High-confidence invariant beliefs (beliefType = "invariant"). */
|
|
421
|
-
invariants: ContextPackBelief[];
|
|
422
|
-
/** Active beliefs ranked by query relevance. */
|
|
423
|
-
activeBeliefs: ContextPackBelief[];
|
|
424
|
-
/** Open questions ranked by relevance and priority. */
|
|
425
|
-
openQuestions: ContextPackQuestion[];
|
|
426
|
-
/** Recent evidence ranked by relevance and recency. */
|
|
427
|
-
recentEvidence: ContextPackEvidence[];
|
|
428
|
-
/** Active contradictions ranked by severity. */
|
|
429
|
-
contradictions: ContextPackContradiction[];
|
|
430
|
-
/**
|
|
431
|
-
* Ontological entities connected to beliefs in scope, ranked by connectivity.
|
|
432
|
-
* Optional — present when entity graph substrate is active for this topic.
|
|
433
|
-
* NON-BREAKING addition per contract rules.
|
|
434
|
-
*/
|
|
435
|
-
relatedEntities?: ContextPackEntity[];
|
|
436
|
-
/** Concise instructions for agent context injection. */
|
|
437
|
-
contextNarrative: string[];
|
|
438
|
-
/** Token-budgeted injection selections. */
|
|
439
|
-
injectionPolicy: ContextPackInjectionPolicy;
|
|
440
|
-
/** Assembly telemetry. */
|
|
441
|
-
diagnostics: ContextPackDiagnostics;
|
|
442
|
-
/** Compilation mode used to generate this pack (RS-2). Default: "standard". */
|
|
443
|
-
compilationMode?: ContextCompilationMode;
|
|
444
|
-
/** Failure context for anti-repetition (RS-2). Present when failures are relevant. */
|
|
445
|
-
failureContext?: ContextPackFailureContext;
|
|
446
|
-
/** Delta report (RS-2). Present only when compilationMode = "delta". */
|
|
447
|
-
deltaReport?: ContextPackDeltaReport;
|
|
448
|
-
/** Pack weight overrides applied during ranking (RS-2). */
|
|
449
|
-
appliedWeightOverrides?: PackWeightOverride[];
|
|
450
|
-
};
|
|
451
|
-
/**
|
|
452
|
-
* The canonical input schema for `compile_context`.
|
|
453
|
-
* `topicId` is canonical. `projectId` remains an optional compatibility alias.
|
|
454
|
-
*/
|
|
455
|
-
export type ContextPackRequestV1 = {
|
|
456
|
-
/** Topic scope ID (required). */
|
|
457
|
-
topicId: string;
|
|
458
|
-
/** Deprecated compatibility alias for older callers. */
|
|
459
|
-
projectId?: string;
|
|
460
|
-
/** Focus query for relevance ranking. */
|
|
461
|
-
query?: string;
|
|
462
|
-
/** Max items per section. Default: DEFAULT_SECTION_LIMIT. */
|
|
463
|
-
limit?: number;
|
|
464
|
-
/** Ranking profile. Default: DEFAULT_RANKING_PROFILE. */
|
|
465
|
-
rankingProfile?: ContextRankingProfile;
|
|
466
|
-
/** Total token budget. Default: DEFAULT_TOKEN_BUDGET. */
|
|
467
|
-
tokenBudget?: number;
|
|
468
|
-
/** Descendant topic depth for neighborhood expansion. */
|
|
469
|
-
maxDepth?: number;
|
|
470
|
-
/** Include ontological entities connected to beliefs in scope. Default: true. */
|
|
471
|
-
includeEntities?: boolean;
|
|
472
|
-
/** Compilation mode (RS-2). Default: "standard". */
|
|
473
|
-
mode?: ContextCompilationMode;
|
|
474
|
-
/** Include failure log context for anti-repetition (RS-2). Default: false. */
|
|
475
|
-
includeFailures?: boolean;
|
|
476
|
-
/** Active worktree ID for delta mode reference point (RS-2). */
|
|
477
|
-
worktreeId?: string;
|
|
478
|
-
/** Session ID for anti-repetition dedup (RS-2). */
|
|
479
|
-
sessionId?: string;
|
|
480
|
-
/** Pack weight overrides from domain pack binding (RS-2). */
|
|
481
|
-
packWeightOverrides?: PackWeightOverride[];
|
|
482
|
-
};
|
|
483
|
-
/**
|
|
484
|
-
* Question statuses that are considered "resolved" (not open).
|
|
485
|
-
* Used to filter which questions appear in the openQuestions section.
|
|
486
|
-
*/
|
|
487
|
-
export declare const RESOLVED_QUESTION_STATUSES: readonly string[];
|
|
488
|
-
/**
|
|
489
|
-
* Tokens-per-word multiplier for rough token estimation.
|
|
490
|
-
* Conservative estimate: ~1.35 tokens per whitespace-delimited word.
|
|
491
|
-
*/
|
|
492
|
-
export declare const TOKENS_PER_WORD = 1.35;
|
|
493
|
-
/** Minimum token estimate for any non-empty string. */
|
|
494
|
-
export declare const MIN_TOKEN_ESTIMATE = 8;
|
|
495
|
-
//# sourceMappingURL=context-pack.contract.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context-pack.contract.d.ts","sourceRoot":"","sources":["../src/context-pack.contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAMH,mFAAmF;AACnF,eAAO,MAAM,2BAA2B,SAAmB,CAAC;AAM5D;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAAG,aAAa,GAAG,aAAa,CAAC;AAElE,eAAO,MAAM,wBAAwB,EAAE,SAAS,qBAAqB,EAG3D,CAAC;AAEX,eAAO,MAAM,uBAAuB,EAAE,qBAAqC,CAAC;AAM5E;;;;;;GAMG;AACH,MAAM,MAAM,sBAAsB,GAAG,UAAU,GAAG,OAAO,CAAC;AAE1D,eAAO,MAAM,wBAAwB,EAAE,sBAAmC,CAAC;AAM3E;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAC7B,YAAY,GACZ,eAAe,GACf,eAAe,GACf,gBAAgB,GAChB,gBAAgB,CAAC;AAErB,eAAO,MAAM,yBAAyB,EAAE,SAAS,qBAAqB,EAM5D,CAAC;AAMX;;;;;;;;;;GAUG;AACH,eAAO,MAAM,qBAAqB,EAAE,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,eAAO,MAAM,eAAe,OAAO,CAAC;AAEpC,uDAAuD;AACvD,eAAO,MAAM,kBAAkB,IAAI,CAAC"}
|
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Context-Pack Contract v1
|
|
3
|
-
*
|
|
4
|
-
* Canonical TypeScript types and constants for the context-pack output schema.
|
|
5
|
-
* This is the external contract consumed by:
|
|
6
|
-
* - MCP tool `compile_context` (canonical compiler read)
|
|
7
|
-
* - SDK/HTTP consumers that read compiled context packs programmatically
|
|
8
|
-
* - Benchmark harnesses (context-pack-ab)
|
|
9
|
-
*
|
|
10
|
-
* BREAKING CHANGE RULES:
|
|
11
|
-
* - Adding optional fields to ContextPackV1 is NON-breaking
|
|
12
|
-
* - Removing fields or changing types is BREAKING (bump CONTEXT_PACK_SCHEMA_VERSION)
|
|
13
|
-
* - Changing section budget ratios or ranking weights is NON-breaking (tuning)
|
|
14
|
-
* - Changing the version string is BREAKING (consumers check it)
|
|
15
|
-
*/
|
|
16
|
-
// =============================================================================
|
|
17
|
-
// SCHEMA VERSION
|
|
18
|
-
// =============================================================================
|
|
19
|
-
/** Canonical version string. Consumers MUST check this field for compatibility. */
|
|
20
|
-
export const CONTEXT_PACK_SCHEMA_VERSION = "1.0.0";
|
|
21
|
-
export const CONTEXT_RANKING_PROFILES = [
|
|
22
|
-
"baseline_v1",
|
|
23
|
-
"weighted_v1",
|
|
24
|
-
];
|
|
25
|
-
export const DEFAULT_RANKING_PROFILE = "weighted_v1";
|
|
26
|
-
export const DEFAULT_COMPILATION_MODE = "standard";
|
|
27
|
-
export const CONTEXT_PACK_SECTION_KEYS = [
|
|
28
|
-
"invariants",
|
|
29
|
-
"activeBeliefs",
|
|
30
|
-
"openQuestions",
|
|
31
|
-
"recentEvidence",
|
|
32
|
-
"contradictions",
|
|
33
|
-
];
|
|
34
|
-
// =============================================================================
|
|
35
|
-
// SECTION BUDGET RATIOS
|
|
36
|
-
// =============================================================================
|
|
37
|
-
/**
|
|
38
|
-
* Token budget allocation ratios per section.
|
|
39
|
-
* These sum to 1.0 and determine how the total tokenBudget is divided.
|
|
40
|
-
*
|
|
41
|
-
* Rationale:
|
|
42
|
-
* - invariants (0.28): Highest-priority constraints, injected first
|
|
43
|
-
* - activeBeliefs (0.30): Largest section, carries domain knowledge
|
|
44
|
-
* - openQuestions (0.17): Unresolved work items guide agent behavior
|
|
45
|
-
* - recentEvidence (0.17): Implementation context for grounding
|
|
46
|
-
* - contradictions (0.08): Tension signals, smallest section
|
|
47
|
-
*/
|
|
48
|
-
export const SECTION_BUDGET_RATIOS = {
|
|
49
|
-
invariants: 0.28,
|
|
50
|
-
activeBeliefs: 0.3,
|
|
51
|
-
openQuestions: 0.17,
|
|
52
|
-
recentEvidence: 0.17,
|
|
53
|
-
contradictions: 0.08,
|
|
54
|
-
};
|
|
55
|
-
// =============================================================================
|
|
56
|
-
// TOKEN BUDGET CONSTRAINTS
|
|
57
|
-
// =============================================================================
|
|
58
|
-
/** Minimum allowed token budget. Below this, context packs lose utility. */
|
|
59
|
-
export const MIN_TOKEN_BUDGET = 400;
|
|
60
|
-
/** Maximum allowed token budget. Above this, context packs bloat prompts. */
|
|
61
|
-
export const MAX_TOKEN_BUDGET = 8000;
|
|
62
|
-
/** Default token budget when caller does not specify. */
|
|
63
|
-
export const DEFAULT_TOKEN_BUDGET = 1800;
|
|
64
|
-
/** Default max items per section. */
|
|
65
|
-
export const DEFAULT_SECTION_LIMIT = 8;
|
|
66
|
-
/** Hard ceiling on items per section. */
|
|
67
|
-
export const MAX_SECTION_LIMIT = 25;
|
|
68
|
-
/** Minimum contradiction section budget floor (tokens). */
|
|
69
|
-
export const MIN_CONTRADICTION_BUDGET = 40;
|
|
70
|
-
export const RANKING_WEIGHTS = {
|
|
71
|
-
invariants: {
|
|
72
|
-
query: 0.35,
|
|
73
|
-
recency: 0.1,
|
|
74
|
-
confidence: 0.4,
|
|
75
|
-
beliefType: 0.15,
|
|
76
|
-
},
|
|
77
|
-
activeBeliefs: {
|
|
78
|
-
query: 0.5,
|
|
79
|
-
recency: 0.2,
|
|
80
|
-
confidence: 0.2,
|
|
81
|
-
beliefType: 0.1,
|
|
82
|
-
},
|
|
83
|
-
openQuestions: {
|
|
84
|
-
query: 0.55,
|
|
85
|
-
recency: 0.2,
|
|
86
|
-
priority: 0.25,
|
|
87
|
-
},
|
|
88
|
-
recentEvidence: {
|
|
89
|
-
query: 0.6,
|
|
90
|
-
recency: 0.4,
|
|
91
|
-
},
|
|
92
|
-
contradictions: {
|
|
93
|
-
query: 0.4,
|
|
94
|
-
recency: 0.2,
|
|
95
|
-
severity: 0.4,
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
/** Recency decay half-life in days. After 30 days, recency score = 0.5. */
|
|
99
|
-
export const RECENCY_HALF_LIFE_DAYS = 30;
|
|
100
|
-
/**
|
|
101
|
-
* Ranking weight vector for the relatedEntities section.
|
|
102
|
-
* Entities are ranked by query relevance and connectivity (bridge edge count).
|
|
103
|
-
* Separate from RANKING_WEIGHTS because entities are not part of the
|
|
104
|
-
* token-budgeted injection plan.
|
|
105
|
-
*/
|
|
106
|
-
export const ENTITY_RANKING_WEIGHTS = {
|
|
107
|
-
query: 0.4,
|
|
108
|
-
connectivity: 0.6,
|
|
109
|
-
};
|
|
110
|
-
/** Default max entities to include in the context pack. */
|
|
111
|
-
export const DEFAULT_ENTITY_LIMIT = 10;
|
|
112
|
-
/** Hard ceiling on entities per context pack. */
|
|
113
|
-
export const MAX_ENTITY_LIMIT = 50;
|
|
114
|
-
// =============================================================================
|
|
115
|
-
// BELIEF TYPE BONUS MAP
|
|
116
|
-
// =============================================================================
|
|
117
|
-
/**
|
|
118
|
-
* Bonus multiplier for belief types in ranking.
|
|
119
|
-
* Invariants get 1.0, unknown types get 0.4.
|
|
120
|
-
*/
|
|
121
|
-
export const BELIEF_TYPE_BONUS = {
|
|
122
|
-
invariant: 1.0,
|
|
123
|
-
tenet: 0.8,
|
|
124
|
-
principle: 0.6,
|
|
125
|
-
};
|
|
126
|
-
export const DEFAULT_BELIEF_TYPE_BONUS = 0.4;
|
|
127
|
-
// =============================================================================
|
|
128
|
-
// PRIORITY / SEVERITY SCORE MAPS
|
|
129
|
-
// =============================================================================
|
|
130
|
-
export const PRIORITY_SCORES = {
|
|
131
|
-
critical: 1.0,
|
|
132
|
-
high: 0.85,
|
|
133
|
-
medium: 0.55,
|
|
134
|
-
low: 0.35,
|
|
135
|
-
};
|
|
136
|
-
export const DEFAULT_PRIORITY_SCORE = 0.5;
|
|
137
|
-
export const SEVERITY_SCORES = {
|
|
138
|
-
critical: 1.0,
|
|
139
|
-
high: 0.85,
|
|
140
|
-
medium: 0.6,
|
|
141
|
-
low: 0.35,
|
|
142
|
-
};
|
|
143
|
-
export const DEFAULT_SEVERITY_SCORE = 0.5;
|
|
144
|
-
// =============================================================================
|
|
145
|
-
// RESOLVED QUESTION STATUSES
|
|
146
|
-
// =============================================================================
|
|
147
|
-
/**
|
|
148
|
-
* Question statuses that are considered "resolved" (not open).
|
|
149
|
-
* Used to filter which questions appear in the openQuestions section.
|
|
150
|
-
*/
|
|
151
|
-
export const RESOLVED_QUESTION_STATUSES = [
|
|
152
|
-
"answered",
|
|
153
|
-
"archived",
|
|
154
|
-
"closed",
|
|
155
|
-
"resolved",
|
|
156
|
-
"resolved_support",
|
|
157
|
-
"resolved_contra",
|
|
158
|
-
"belief_forked",
|
|
159
|
-
];
|
|
160
|
-
// =============================================================================
|
|
161
|
-
// TOKEN ESTIMATION
|
|
162
|
-
// =============================================================================
|
|
163
|
-
/**
|
|
164
|
-
* Tokens-per-word multiplier for rough token estimation.
|
|
165
|
-
* Conservative estimate: ~1.35 tokens per whitespace-delimited word.
|
|
166
|
-
*/
|
|
167
|
-
export const TOKENS_PER_WORD = 1.35;
|
|
168
|
-
/** Minimum token estimate for any non-empty string. */
|
|
169
|
-
export const MIN_TOKEN_ESTIMATE = 8;
|
|
170
|
-
//# sourceMappingURL=context-pack.contract.js.map
|