@remnic/core 1.1.4 → 1.1.6
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/access-cli.js +32 -30
- package/dist/access-cli.js.map +1 -1
- package/dist/access-http.d.ts +7 -7
- package/dist/access-http.js +13 -13
- package/dist/access-mcp.d.ts +7 -7
- package/dist/access-mcp.js +12 -12
- package/dist/access-schema.d.ts +89 -4
- package/dist/access-schema.js +3 -3
- package/dist/{access-service-CtXFnprR.d.ts → access-service-CcKu1Yc0.d.ts} +22 -18
- package/dist/access-service.d.ts +7 -7
- package/dist/access-service.js +10 -10
- package/dist/active-memory-bridge.d.ts +1 -1
- package/dist/active-recall.d.ts +1 -1
- package/dist/behavior-learner.d.ts +1 -1
- package/dist/behavior-signals.d.ts +1 -1
- package/dist/bootstrap.d.ts +6 -6
- package/dist/briefing.d.ts +2 -2
- package/dist/briefing.js +3 -3
- package/dist/buffer-surprise-report.d.ts +1 -1
- package/dist/buffer.d.ts +2 -2
- package/dist/calibration.d.ts +1 -1
- package/dist/calibration.js +1 -1
- package/dist/{capsule-crypto-5CYAGVC5.js → capsule-crypto-SJS5VVAP.js} +2 -2
- package/dist/{capsule-export-NZQPOTQ4.js → capsule-export-LLEVB2RG.js} +3 -3
- package/dist/{capsule-import-SDCUXLEV.js → capsule-import-UW45R2MZ.js} +3 -3
- package/dist/causal-behavior.d.ts +1 -1
- package/dist/causal-consolidation.d.ts +2 -2
- package/dist/causal-consolidation.js +4 -4
- package/dist/{chunk-CRU27Q4J.js → chunk-3P6TPZM4.js} +64 -5
- package/dist/chunk-3P6TPZM4.js.map +1 -0
- package/dist/{chunk-LW2NMHDW.js → chunk-5NS6NN5A.js} +2 -2
- package/dist/{chunk-KNKUID7G.js → chunk-767ODGE6.js} +1 -1
- package/dist/{chunk-V7TEH5I2.js → chunk-7RAW2T4P.js} +2 -2
- package/dist/{chunk-RILIVK4O.js → chunk-A4ACKWIW.js} +29 -3
- package/dist/chunk-A4ACKWIW.js.map +1 -0
- package/dist/{chunk-F5VQOQ2E.js → chunk-AIT53NLG.js} +2 -2
- package/dist/chunk-AKV3HOGZ.js +757 -0
- package/dist/chunk-AKV3HOGZ.js.map +1 -0
- package/dist/{chunk-NZS2BLTP.js → chunk-AOABCJVL.js} +772 -59
- package/dist/chunk-AOABCJVL.js.map +1 -0
- package/dist/{chunk-B2TL6GA2.js → chunk-BFVBG5XY.js} +2 -2
- package/dist/{chunk-43EKP2UK.js → chunk-COAGZQT7.js} +1 -1
- package/dist/{chunk-43EKP2UK.js.map → chunk-COAGZQT7.js.map} +1 -1
- package/dist/{chunk-USFPPRAF.js → chunk-D7WYTVUQ.js} +5 -3
- package/dist/chunk-D7WYTVUQ.js.map +1 -0
- package/dist/{chunk-Y4A6M3B6.js → chunk-DLYTYJ43.js} +2 -2
- package/dist/{chunk-ZIBOQULP.js → chunk-EONJ7GK3.js} +2 -2
- package/dist/{chunk-JWSENLQI.js → chunk-FSWYMUWI.js} +15 -1
- package/dist/chunk-FSWYMUWI.js.map +1 -0
- package/dist/{chunk-SMA4IMHV.js → chunk-KUIEFH2S.js} +3 -3
- package/dist/{chunk-EGEPUGN4.js → chunk-LKJA5MR2.js} +2 -2
- package/dist/{chunk-XRCYKJ3V.js → chunk-M3QQ5DRA.js} +61 -18
- package/dist/chunk-M3QQ5DRA.js.map +1 -0
- package/dist/{chunk-CUI2STX6.js → chunk-MYMOXFMR.js} +12 -6
- package/dist/chunk-MYMOXFMR.js.map +1 -0
- package/dist/{chunk-AEMBDV7M.js → chunk-OZAFME7S.js} +22 -17
- package/dist/chunk-OZAFME7S.js.map +1 -0
- package/dist/{chunk-IYY4MCPG.js → chunk-P73JTV34.js} +2 -2
- package/dist/{chunk-52PDY6GD.js → chunk-PT2EZWOH.js} +2 -2
- package/dist/{chunk-3KIS4VGT.js → chunk-QIGOEM65.js} +2 -2
- package/dist/{chunk-47WOM4YW.js → chunk-RXGR3YLU.js} +2 -2
- package/dist/{chunk-VTJVUHRK.js → chunk-SRBJUAMP.js} +1 -1
- package/dist/chunk-SRBJUAMP.js.map +1 -0
- package/dist/{chunk-XQ4EJLUD.js → chunk-TMSHGSIG.js} +2 -2
- package/dist/{chunk-X6VBWOVZ.js → chunk-UE2OQNQQ.js} +2 -2
- package/dist/{chunk-HIRKCQGF.js → chunk-XOG2FHYW.js} +44 -44
- package/dist/{chunk-HIRKCQGF.js.map → chunk-XOG2FHYW.js.map} +1 -1
- package/dist/{chunk-MUELDH4F.js → chunk-YELFQNQH.js} +2 -2
- package/dist/{chunk-TIFRGAKO.js → chunk-YKGRACQP.js} +5 -5
- package/dist/{chunk-AGZHRWPT.js → chunk-ZBZVNWQO.js} +2 -2
- package/dist/{chunk-W7WWT4FJ.js → chunk-ZOMA7J3J.js} +2 -2
- package/dist/{cli-lMql2FCr.d.ts → cli-WahR0rs-.d.ts} +4 -4
- package/dist/cli.d.ts +8 -8
- package/dist/cli.js +25 -25
- package/dist/{codex-materialize-CQlLTzke.d.ts → codex-materialize-D5d5vvyS.d.ts} +1 -1
- package/dist/compression-optimizer.d.ts +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +1 -1
- package/dist/consolidation-provenance-check.d.ts +2 -2
- package/dist/consolidation-undo.d.ts +2 -2
- package/dist/day-summary.d.ts +1 -1
- package/dist/delinearize.d.ts +1 -1
- package/dist/direct-answer-wiring.d.ts +1 -1
- package/dist/direct-answer.d.ts +1 -1
- package/dist/embedding-fallback.d.ts +1 -1
- package/dist/{engine-O6YWKQM3.js → engine-5OTS6GY3.js} +4 -4
- package/dist/entity-retrieval.d.ts +2 -2
- package/dist/entity-retrieval.js +3 -3
- package/dist/entity-schema.d.ts +1 -1
- package/dist/explicit-capture.d.ts +6 -6
- package/dist/explicit-cue-recall.d.ts +40 -0
- package/dist/explicit-cue-recall.js +21 -0
- package/dist/extraction-judge-telemetry.d.ts +1 -1
- package/dist/extraction-judge-training.d.ts +1 -1
- package/dist/extraction-judge.d.ts +1 -1
- package/dist/extraction.d.ts +1 -1
- package/dist/extraction.js +2 -2
- package/dist/fallback-llm.d.ts +3 -1
- package/dist/fallback-llm.js +1 -1
- package/dist/identity-continuity.d.ts +1 -1
- package/dist/importance.d.ts +1 -1
- package/dist/index.d.ts +14 -13
- package/dist/index.js +191 -52
- package/dist/index.js.map +1 -1
- package/dist/intent.d.ts +1 -1
- package/dist/lifecycle.d.ts +1 -1
- package/dist/live-connectors-runner.d.ts +1 -1
- package/dist/local-llm.d.ts +1 -1
- package/dist/memory-action-policy.d.ts +1 -1
- package/dist/memory-cache.d.ts +1 -1
- package/dist/{memory-governance-JZHZDOLN.js → memory-governance-7MI7KE35.js} +4 -4
- package/dist/memory-governance-7MI7KE35.js.map +1 -0
- package/dist/memory-lifecycle-ledger-utils.d.ts +1 -1
- package/dist/{memory-projection-store-CY8TU40w.d.ts → memory-projection-store-BQt5VUQ8.d.ts} +1 -1
- package/dist/memory-projection-store.d.ts +2 -2
- package/dist/memory-worth-outcomes.d.ts +2 -2
- package/dist/models-json.d.ts +1 -1
- package/dist/native-knowledge.d.ts +1 -1
- package/dist/operator-toolkit.d.ts +2 -2
- package/dist/operator-toolkit.js +6 -6
- package/dist/{orchestrator-ChkesB8U.d.ts → orchestrator-D2lHhFWI.d.ts} +36 -11
- package/dist/orchestrator.d.ts +6 -6
- package/dist/orchestrator.js +24 -22
- package/dist/patterns-cli.d.ts +1 -1
- package/dist/policy-runtime.d.ts +1 -1
- package/dist/{port-hqGnoStS.d.ts → port-5W-r5SKc.d.ts} +1 -1
- package/dist/qmd-recall-cache.d.ts +2 -2
- package/dist/qmd.d.ts +2 -2
- package/dist/recall-disclosure-escalation.d.ts +1 -1
- package/dist/recall-explain-renderer.d.ts +1 -1
- package/dist/recall-explain-renderer.js +3 -3
- package/dist/recall-state.d.ts +1 -1
- package/dist/recall-tag-filter.d.ts +1 -1
- package/dist/recall-xray-cli.d.ts +1 -1
- package/dist/recall-xray-cli.js +4 -4
- package/dist/recall-xray-renderer.d.ts +1 -1
- package/dist/recall-xray-renderer.js +3 -3
- package/dist/recall-xray.d.ts +2 -2
- package/dist/recall-xray.js +2 -2
- package/dist/resolve-auth-token.d.ts +1 -1
- package/dist/resume-bundles.js +3 -3
- package/dist/retrieval-agents.d.ts +2 -2
- package/dist/retrieval-tiers.d.ts +1 -1
- package/dist/schemas.d.ts +54 -54
- package/dist/{semantic-consolidation-ByBXb-sf.d.ts → semantic-consolidation-tDODR2je.d.ts} +2 -2
- package/dist/semantic-consolidation.d.ts +3 -3
- package/dist/semantic-consolidation.js +3 -3
- package/dist/semantic-rule-promotion.js +3 -3
- package/dist/semantic-rule-verifier.d.ts +1 -1
- package/dist/semantic-rule-verifier.js +3 -3
- package/dist/session-observer-bands.d.ts +1 -1
- package/dist/session-observer-state.d.ts +1 -1
- package/dist/signal.d.ts +1 -1
- package/dist/storage.d.ts +2 -2
- package/dist/storage.js +2 -2
- package/dist/summarizer.d.ts +1 -1
- package/dist/summarizer.js +2 -2
- package/dist/summary-snapshot.d.ts +1 -1
- package/dist/temporal-supersession.d.ts +2 -2
- package/dist/temporal-validity.d.ts +1 -1
- package/dist/threading.d.ts +1 -1
- package/dist/tier-migration.d.ts +3 -3
- package/dist/tier-routing.d.ts +1 -1
- package/dist/topics.d.ts +1 -1
- package/dist/transcript.d.ts +1 -1
- package/dist/types-C-USTTAx.d.ts +2713 -0
- package/dist/types.d.ts +1 -2668
- package/dist/types.js +1 -1
- package/dist/utility-runtime.d.ts +1 -1
- package/dist/verified-recall.js +3 -3
- package/package.json +1 -1
- package/dist/chunk-AEMBDV7M.js.map +0 -1
- package/dist/chunk-CRU27Q4J.js.map +0 -1
- package/dist/chunk-CUI2STX6.js.map +0 -1
- package/dist/chunk-JWSENLQI.js.map +0 -1
- package/dist/chunk-NZS2BLTP.js.map +0 -1
- package/dist/chunk-RILIVK4O.js.map +0 -1
- package/dist/chunk-USFPPRAF.js.map +0 -1
- package/dist/chunk-VTJVUHRK.js.map +0 -1
- package/dist/chunk-XRCYKJ3V.js.map +0 -1
- /package/dist/{capsule-crypto-5CYAGVC5.js.map → capsule-crypto-SJS5VVAP.js.map} +0 -0
- /package/dist/{capsule-export-NZQPOTQ4.js.map → capsule-export-LLEVB2RG.js.map} +0 -0
- /package/dist/{capsule-import-SDCUXLEV.js.map → capsule-import-UW45R2MZ.js.map} +0 -0
- /package/dist/{chunk-LW2NMHDW.js.map → chunk-5NS6NN5A.js.map} +0 -0
- /package/dist/{chunk-KNKUID7G.js.map → chunk-767ODGE6.js.map} +0 -0
- /package/dist/{chunk-V7TEH5I2.js.map → chunk-7RAW2T4P.js.map} +0 -0
- /package/dist/{chunk-F5VQOQ2E.js.map → chunk-AIT53NLG.js.map} +0 -0
- /package/dist/{chunk-B2TL6GA2.js.map → chunk-BFVBG5XY.js.map} +0 -0
- /package/dist/{chunk-Y4A6M3B6.js.map → chunk-DLYTYJ43.js.map} +0 -0
- /package/dist/{chunk-ZIBOQULP.js.map → chunk-EONJ7GK3.js.map} +0 -0
- /package/dist/{chunk-SMA4IMHV.js.map → chunk-KUIEFH2S.js.map} +0 -0
- /package/dist/{chunk-EGEPUGN4.js.map → chunk-LKJA5MR2.js.map} +0 -0
- /package/dist/{chunk-IYY4MCPG.js.map → chunk-P73JTV34.js.map} +0 -0
- /package/dist/{chunk-52PDY6GD.js.map → chunk-PT2EZWOH.js.map} +0 -0
- /package/dist/{chunk-3KIS4VGT.js.map → chunk-QIGOEM65.js.map} +0 -0
- /package/dist/{chunk-47WOM4YW.js.map → chunk-RXGR3YLU.js.map} +0 -0
- /package/dist/{chunk-XQ4EJLUD.js.map → chunk-TMSHGSIG.js.map} +0 -0
- /package/dist/{chunk-X6VBWOVZ.js.map → chunk-UE2OQNQQ.js.map} +0 -0
- /package/dist/{chunk-MUELDH4F.js.map → chunk-YELFQNQH.js.map} +0 -0
- /package/dist/{chunk-TIFRGAKO.js.map → chunk-YKGRACQP.js.map} +0 -0
- /package/dist/{chunk-AGZHRWPT.js.map → chunk-ZBZVNWQO.js.map} +0 -0
- /package/dist/{chunk-W7WWT4FJ.js.map → chunk-ZOMA7J3J.js.map} +0 -0
- /package/dist/{engine-O6YWKQM3.js.map → engine-5OTS6GY3.js.map} +0 -0
- /package/dist/{memory-governance-JZHZDOLN.js.map → explicit-cue-recall.js.map} +0 -0
|
@@ -0,0 +1,757 @@
|
|
|
1
|
+
import {
|
|
2
|
+
buildEvidencePack
|
|
3
|
+
} from "./chunk-74WWN7ZW.js";
|
|
4
|
+
|
|
5
|
+
// src/explicit-cue-recall.ts
|
|
6
|
+
var DEFAULT_MAX_CHARS = 2400;
|
|
7
|
+
var DEFAULT_MAX_ITEM_CHARS = 1200;
|
|
8
|
+
var DEFAULT_MAX_REFERENCES = 24;
|
|
9
|
+
var REFERENCE_SCAN_TOKEN_FACTOR = 3;
|
|
10
|
+
var TURN_REFERENCE_WINDOW_RADIUS = 0;
|
|
11
|
+
var LEXICAL_CUE_WINDOW_RADIUS = 1;
|
|
12
|
+
var LEXICAL_CUE_SEARCH_LIMIT = 3;
|
|
13
|
+
var LEXICAL_CUE_MAX_TOKENS = 400;
|
|
14
|
+
var LATEST_STATE_CUES = /* @__PURE__ */ new Set([
|
|
15
|
+
"as of",
|
|
16
|
+
"currently",
|
|
17
|
+
"latest",
|
|
18
|
+
"most recent",
|
|
19
|
+
"newest",
|
|
20
|
+
"now",
|
|
21
|
+
"updated",
|
|
22
|
+
"changed",
|
|
23
|
+
"change"
|
|
24
|
+
]);
|
|
25
|
+
var STRUCTURED_PLAN_FIELD_CUES = /* @__PURE__ */ new Set([
|
|
26
|
+
"accommodation",
|
|
27
|
+
"attraction",
|
|
28
|
+
"breakfast",
|
|
29
|
+
"current city",
|
|
30
|
+
"dinner",
|
|
31
|
+
"flight",
|
|
32
|
+
"flights",
|
|
33
|
+
"hotel",
|
|
34
|
+
"lunch",
|
|
35
|
+
"restaurant",
|
|
36
|
+
"restaurants",
|
|
37
|
+
"transportation",
|
|
38
|
+
"traveler",
|
|
39
|
+
"travelers"
|
|
40
|
+
]);
|
|
41
|
+
var STRUCTURED_PLAN_DEPENDENCY_CUES = /* @__PURE__ */ new Set([
|
|
42
|
+
"comparison",
|
|
43
|
+
"constraint",
|
|
44
|
+
"constraints",
|
|
45
|
+
"dependency",
|
|
46
|
+
"dependencies",
|
|
47
|
+
"join",
|
|
48
|
+
"same",
|
|
49
|
+
"shared"
|
|
50
|
+
]);
|
|
51
|
+
var BENCHMARK_ABILITY_CUES = /* @__PURE__ */ new Map([
|
|
52
|
+
["information extraction", "ability=information_extraction"],
|
|
53
|
+
["knowledge update", "ability=knowledge_update"],
|
|
54
|
+
["multi session reasoning", "ability=multi_session_reasoning"],
|
|
55
|
+
["multi-session reasoning", "ability=multi_session_reasoning"],
|
|
56
|
+
["instruction following", "ability=instruction_following"]
|
|
57
|
+
]);
|
|
58
|
+
var BENCHMARK_ANCHOR_VALUE_STOPWORDS = /* @__PURE__ */ new Set([
|
|
59
|
+
"a",
|
|
60
|
+
"about",
|
|
61
|
+
"an",
|
|
62
|
+
"for",
|
|
63
|
+
"from",
|
|
64
|
+
"in",
|
|
65
|
+
"on",
|
|
66
|
+
"the",
|
|
67
|
+
"to",
|
|
68
|
+
"use",
|
|
69
|
+
"using",
|
|
70
|
+
"with"
|
|
71
|
+
]);
|
|
72
|
+
var RELATIVE_TEMPORAL_CUES = [
|
|
73
|
+
"as of",
|
|
74
|
+
"most recent",
|
|
75
|
+
"last time",
|
|
76
|
+
"last week",
|
|
77
|
+
"last month",
|
|
78
|
+
"last year",
|
|
79
|
+
"last session",
|
|
80
|
+
"last conversation",
|
|
81
|
+
"next time",
|
|
82
|
+
"next week",
|
|
83
|
+
"next month",
|
|
84
|
+
"next year",
|
|
85
|
+
"next session",
|
|
86
|
+
"next conversation",
|
|
87
|
+
"previous time",
|
|
88
|
+
"previous week",
|
|
89
|
+
"previous month",
|
|
90
|
+
"previous year",
|
|
91
|
+
"previous session",
|
|
92
|
+
"previous conversation",
|
|
93
|
+
"prior time",
|
|
94
|
+
"prior week",
|
|
95
|
+
"prior month",
|
|
96
|
+
"prior year",
|
|
97
|
+
"prior session",
|
|
98
|
+
"prior conversation",
|
|
99
|
+
"today",
|
|
100
|
+
"yesterday",
|
|
101
|
+
"tomorrow",
|
|
102
|
+
"tonight",
|
|
103
|
+
"earlier",
|
|
104
|
+
"later",
|
|
105
|
+
"recently",
|
|
106
|
+
"previously",
|
|
107
|
+
"currently",
|
|
108
|
+
"now",
|
|
109
|
+
"latest",
|
|
110
|
+
"newest",
|
|
111
|
+
"oldest",
|
|
112
|
+
"earliest",
|
|
113
|
+
"before",
|
|
114
|
+
"after",
|
|
115
|
+
"since",
|
|
116
|
+
"updated",
|
|
117
|
+
"changed",
|
|
118
|
+
"change"
|
|
119
|
+
];
|
|
120
|
+
var SPEAKER_NAME_STOPWORDS = /* @__PURE__ */ new Set([
|
|
121
|
+
"A",
|
|
122
|
+
"According",
|
|
123
|
+
"An",
|
|
124
|
+
"And",
|
|
125
|
+
"Are",
|
|
126
|
+
"As",
|
|
127
|
+
"At",
|
|
128
|
+
"Before",
|
|
129
|
+
"Can",
|
|
130
|
+
"Compare",
|
|
131
|
+
"Could",
|
|
132
|
+
"Did",
|
|
133
|
+
"Do",
|
|
134
|
+
"Does",
|
|
135
|
+
"For",
|
|
136
|
+
"From",
|
|
137
|
+
"Had",
|
|
138
|
+
"Has",
|
|
139
|
+
"Have",
|
|
140
|
+
"How",
|
|
141
|
+
"In",
|
|
142
|
+
"Is",
|
|
143
|
+
"It",
|
|
144
|
+
"Join",
|
|
145
|
+
"Of",
|
|
146
|
+
"On",
|
|
147
|
+
"Or",
|
|
148
|
+
"Please",
|
|
149
|
+
"Review",
|
|
150
|
+
"Step",
|
|
151
|
+
"Tell",
|
|
152
|
+
"The",
|
|
153
|
+
"To",
|
|
154
|
+
"Turn",
|
|
155
|
+
"Use",
|
|
156
|
+
"Was",
|
|
157
|
+
"Were",
|
|
158
|
+
"What",
|
|
159
|
+
"When",
|
|
160
|
+
"Where",
|
|
161
|
+
"Which",
|
|
162
|
+
"Who",
|
|
163
|
+
"Why",
|
|
164
|
+
"Will",
|
|
165
|
+
"Would"
|
|
166
|
+
]);
|
|
167
|
+
var QUESTION_SLOT_STOPWORDS = /* @__PURE__ */ new Set([
|
|
168
|
+
"answer",
|
|
169
|
+
"choice",
|
|
170
|
+
"did",
|
|
171
|
+
"does",
|
|
172
|
+
"do",
|
|
173
|
+
"is",
|
|
174
|
+
"should",
|
|
175
|
+
"single",
|
|
176
|
+
"the",
|
|
177
|
+
"user",
|
|
178
|
+
"was",
|
|
179
|
+
"were"
|
|
180
|
+
]);
|
|
181
|
+
async function buildExplicitCueRecallSection(options) {
|
|
182
|
+
const engine = options.engine;
|
|
183
|
+
const query = options.query.trim();
|
|
184
|
+
const maxChars = normalizePositiveInteger(options.maxChars, DEFAULT_MAX_CHARS);
|
|
185
|
+
if (!engine || query.length === 0 || maxChars <= 0) {
|
|
186
|
+
return "";
|
|
187
|
+
}
|
|
188
|
+
const maxReferences = normalizePositiveInteger(
|
|
189
|
+
options.maxReferences,
|
|
190
|
+
DEFAULT_MAX_REFERENCES
|
|
191
|
+
);
|
|
192
|
+
if (maxReferences <= 0) {
|
|
193
|
+
return "";
|
|
194
|
+
}
|
|
195
|
+
const evidenceItems = [];
|
|
196
|
+
const seenTurns = /* @__PURE__ */ new Set();
|
|
197
|
+
await collectTurnReferenceEvidence({
|
|
198
|
+
engine,
|
|
199
|
+
sessionId: options.sessionId,
|
|
200
|
+
query,
|
|
201
|
+
maxReferences,
|
|
202
|
+
evidenceItems,
|
|
203
|
+
seenTurns
|
|
204
|
+
});
|
|
205
|
+
await collectLexicalCueEvidence({
|
|
206
|
+
engine,
|
|
207
|
+
sessionId: options.sessionId,
|
|
208
|
+
query,
|
|
209
|
+
maxReferences,
|
|
210
|
+
includeBenchmarkAnchorCues: options.includeBenchmarkAnchorCues,
|
|
211
|
+
includeStructuredPlanCues: options.includeStructuredPlanCues,
|
|
212
|
+
evidenceItems,
|
|
213
|
+
seenTurns
|
|
214
|
+
});
|
|
215
|
+
return buildEvidencePack(evidenceItems, {
|
|
216
|
+
title: "Explicit Cue Evidence",
|
|
217
|
+
maxChars,
|
|
218
|
+
maxItemChars: normalizePositiveInteger(
|
|
219
|
+
options.maxItemChars,
|
|
220
|
+
DEFAULT_MAX_ITEM_CHARS
|
|
221
|
+
)
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
async function collectTurnReferenceEvidence(options) {
|
|
225
|
+
if (!options.sessionId) {
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
const references = collectExplicitTurnReferences(options.query).slice(
|
|
229
|
+
0,
|
|
230
|
+
options.maxReferences
|
|
231
|
+
);
|
|
232
|
+
if (references.length === 0) {
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
const windows = /* @__PURE__ */ new Map();
|
|
236
|
+
for (const reference of references) {
|
|
237
|
+
for (const center of candidateTurnIndexesForReference(reference)) {
|
|
238
|
+
if (center < 0) {
|
|
239
|
+
continue;
|
|
240
|
+
}
|
|
241
|
+
const fromTurn = Math.max(0, center - TURN_REFERENCE_WINDOW_RADIUS);
|
|
242
|
+
const toTurn = center + TURN_REFERENCE_WINDOW_RADIUS;
|
|
243
|
+
windows.set(`${fromTurn}:${toTurn}`, { fromTurn, toTurn });
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
for (const window of [...windows.values()].sort(
|
|
247
|
+
(left, right) => left.fromTurn - right.fromTurn || left.toTurn - right.toTurn
|
|
248
|
+
)) {
|
|
249
|
+
const expanded = await options.engine.expandContext(
|
|
250
|
+
options.sessionId,
|
|
251
|
+
window.fromTurn,
|
|
252
|
+
window.toTurn,
|
|
253
|
+
2e3
|
|
254
|
+
);
|
|
255
|
+
appendExpandedEvidence(
|
|
256
|
+
options.evidenceItems,
|
|
257
|
+
options.seenTurns,
|
|
258
|
+
options.sessionId,
|
|
259
|
+
expanded
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
async function collectLexicalCueEvidence(options) {
|
|
264
|
+
const cues = collectLexicalCues(options.query, {
|
|
265
|
+
includeBenchmarkAnchorCues: options.includeBenchmarkAnchorCues,
|
|
266
|
+
includeStructuredPlanCues: options.includeStructuredPlanCues
|
|
267
|
+
}).slice(0, options.maxReferences);
|
|
268
|
+
const preferLatest = hasLatestStateIntent(options.query);
|
|
269
|
+
for (const cue of cues) {
|
|
270
|
+
const results = sortLexicalCueResults(
|
|
271
|
+
await options.engine.searchContextFull(
|
|
272
|
+
cue,
|
|
273
|
+
LEXICAL_CUE_SEARCH_LIMIT,
|
|
274
|
+
options.sessionId
|
|
275
|
+
),
|
|
276
|
+
preferLatest
|
|
277
|
+
);
|
|
278
|
+
for (const result of results) {
|
|
279
|
+
const windowRadius = preferLatest ? 0 : LEXICAL_CUE_WINDOW_RADIUS;
|
|
280
|
+
const fromTurn = Math.max(0, result.turn_index - windowRadius);
|
|
281
|
+
const toTurn = result.turn_index + windowRadius;
|
|
282
|
+
const expanded = await options.engine.expandContext(
|
|
283
|
+
result.session_id,
|
|
284
|
+
fromTurn,
|
|
285
|
+
toTurn,
|
|
286
|
+
LEXICAL_CUE_MAX_TOKENS
|
|
287
|
+
);
|
|
288
|
+
if (expanded.length === 0) {
|
|
289
|
+
appendEvidenceItem(options.evidenceItems, options.seenTurns, {
|
|
290
|
+
id: `${result.session_id}:${result.turn_index}`,
|
|
291
|
+
sessionId: result.session_id,
|
|
292
|
+
turnIndex: result.turn_index,
|
|
293
|
+
role: result.role,
|
|
294
|
+
content: result.content,
|
|
295
|
+
...typeof result.score === "number" ? { score: result.score } : {}
|
|
296
|
+
});
|
|
297
|
+
continue;
|
|
298
|
+
}
|
|
299
|
+
appendExpandedEvidence(
|
|
300
|
+
options.evidenceItems,
|
|
301
|
+
options.seenTurns,
|
|
302
|
+
result.session_id,
|
|
303
|
+
expanded
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
function appendExpandedEvidence(evidenceItems, seenTurns, sessionId, expanded) {
|
|
309
|
+
for (const message of expanded) {
|
|
310
|
+
appendEvidenceItem(evidenceItems, seenTurns, {
|
|
311
|
+
id: `${sessionId}:${message.turn_index}`,
|
|
312
|
+
sessionId,
|
|
313
|
+
turnIndex: message.turn_index,
|
|
314
|
+
role: message.role,
|
|
315
|
+
content: message.content
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
function appendEvidenceItem(evidenceItems, seenTurns, item) {
|
|
320
|
+
if (seenTurns.has(item.id)) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
seenTurns.add(item.id);
|
|
324
|
+
evidenceItems.push(item);
|
|
325
|
+
}
|
|
326
|
+
function collectExplicitTurnReferences(query) {
|
|
327
|
+
const references = /* @__PURE__ */ new Map();
|
|
328
|
+
const addReference = (value, label) => {
|
|
329
|
+
const existing = references.get(String(value));
|
|
330
|
+
references.set(String(value), {
|
|
331
|
+
number: value,
|
|
332
|
+
includeDirectTurn: (existing?.includeDirectTurn ?? false) || label === "turn"
|
|
333
|
+
});
|
|
334
|
+
};
|
|
335
|
+
const tokens = tokenizeReferenceQuery(query);
|
|
336
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
337
|
+
const label = normalizeReferenceLabel(tokens[index]);
|
|
338
|
+
if (!label) {
|
|
339
|
+
continue;
|
|
340
|
+
}
|
|
341
|
+
const parsed = parseReferenceNumbers(tokens, index + 1);
|
|
342
|
+
for (const number of parsed.numbers) {
|
|
343
|
+
addReference(number, label);
|
|
344
|
+
}
|
|
345
|
+
index = Math.max(index, parsed.nextIndex - 1);
|
|
346
|
+
}
|
|
347
|
+
return [...references.values()].sort((left, right) => left.number - right.number);
|
|
348
|
+
}
|
|
349
|
+
function collectLexicalCues(query, options = {}) {
|
|
350
|
+
const cues = /* @__PURE__ */ new Set();
|
|
351
|
+
for (const match of query.matchAll(/\b[A-Za-z][A-Za-z0-9]{0,12}\d+:\d+\b/g)) {
|
|
352
|
+
cues.add(match[0]);
|
|
353
|
+
}
|
|
354
|
+
for (const match of query.matchAll(/\b\d{4}-\d{2}-\d{2}(?:T\d{2}:\d{2}(?::\d{2})?Z?)?\b/g)) {
|
|
355
|
+
cues.add(match[0]);
|
|
356
|
+
}
|
|
357
|
+
for (const cue of collectTemporalLexicalCues(query)) {
|
|
358
|
+
cues.add(cue);
|
|
359
|
+
}
|
|
360
|
+
for (const cue of collectQuestionSlotCues(query)) {
|
|
361
|
+
cues.add(cue);
|
|
362
|
+
}
|
|
363
|
+
if (options.includeBenchmarkAnchorCues) {
|
|
364
|
+
for (const cue of collectBenchmarkAnchorCues(query)) {
|
|
365
|
+
cues.add(cue);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
if (options.includeStructuredPlanCues) {
|
|
369
|
+
for (const cue of collectStructuredPlanCues(query)) {
|
|
370
|
+
cues.add(cue);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
for (const match of query.matchAll(/\b(?:session|source|chat|plan|task|event|file|tool)[_-][A-Za-z0-9][A-Za-z0-9_.:-]{0,80}\b/gi)) {
|
|
374
|
+
cues.add(match[0]);
|
|
375
|
+
}
|
|
376
|
+
for (const match of query.matchAll(/\b[A-Z][a-z]{1,30}(?:\s+[A-Z][a-z]{1,30}){0,2}\b/g)) {
|
|
377
|
+
const value = normalizeSpeakerNameCue(match[0]);
|
|
378
|
+
if (value) {
|
|
379
|
+
cues.add(value);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
for (const match of query.matchAll(/\[([A-Za-z0-9][A-Za-z0-9_.:/ -]{1,80})\]/g)) {
|
|
383
|
+
const value = match[1]?.trim();
|
|
384
|
+
if (value) {
|
|
385
|
+
cues.add(value);
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return [...cues].sort((left, right) => left.localeCompare(right));
|
|
389
|
+
}
|
|
390
|
+
function collectQuestionSlotCues(query) {
|
|
391
|
+
const cues = /* @__PURE__ */ new Set();
|
|
392
|
+
for (const match of query.matchAll(
|
|
393
|
+
/\b(?:what|which)\s+([a-z][a-z0-9_-]{2,30})\s+(?:does|do|did|is|are|was|were|should|would|could|can|will)\b/gi
|
|
394
|
+
)) {
|
|
395
|
+
const value = match[1]?.toLowerCase();
|
|
396
|
+
if (value && !QUESTION_SLOT_STOPWORDS.has(value)) {
|
|
397
|
+
cues.add(value);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
return [...cues].sort((left, right) => left.localeCompare(right));
|
|
401
|
+
}
|
|
402
|
+
function collectBenchmarkAnchorCues(query) {
|
|
403
|
+
const cues = /* @__PURE__ */ new Set();
|
|
404
|
+
const normalizedQuery = query.toLowerCase().replace(/\s+/g, " ");
|
|
405
|
+
for (const [phrase, cue] of BENCHMARK_ABILITY_CUES) {
|
|
406
|
+
if (containsBoundedPhrase(normalizedQuery, phrase)) {
|
|
407
|
+
cues.add(cue);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
const tokens = tokenizeAnchorQuery(query);
|
|
411
|
+
for (let index = 0; index < tokens.length; index += 1) {
|
|
412
|
+
let prefix = normalizeBenchmarkAnchorPrefix(tokens[index]);
|
|
413
|
+
if (!prefix) {
|
|
414
|
+
continue;
|
|
415
|
+
}
|
|
416
|
+
let valueIndex = index + 1;
|
|
417
|
+
if (prefix === "source" && tokens[valueIndex]?.toLowerCase() === "chat") {
|
|
418
|
+
prefix = "source_chat";
|
|
419
|
+
valueIndex += 1;
|
|
420
|
+
}
|
|
421
|
+
const maybeIdLabel = tokens[valueIndex]?.toLowerCase();
|
|
422
|
+
if (maybeIdLabel === "id" || maybeIdLabel === "ids") {
|
|
423
|
+
valueIndex += 1;
|
|
424
|
+
}
|
|
425
|
+
let consumedValue = false;
|
|
426
|
+
for (let currentValueIndex = valueIndex; currentValueIndex < tokens.length; currentValueIndex += 1) {
|
|
427
|
+
const rawValue = tokens[currentValueIndex];
|
|
428
|
+
const normalizedValue = rawValue?.toLowerCase();
|
|
429
|
+
if (!rawValue || normalizeBenchmarkAnchorPrefix(rawValue)) {
|
|
430
|
+
break;
|
|
431
|
+
}
|
|
432
|
+
if (normalizedValue === "and" || normalizedValue === "or") {
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
if (BENCHMARK_ANCHOR_VALUE_STOPWORDS.has(normalizedValue)) {
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
if (!isBenchmarkAnchorValue(rawValue)) {
|
|
439
|
+
break;
|
|
440
|
+
}
|
|
441
|
+
addBenchmarkAnchorCues(cues, prefix, rawValue);
|
|
442
|
+
consumedValue = true;
|
|
443
|
+
index = currentValueIndex;
|
|
444
|
+
}
|
|
445
|
+
if (!consumedValue) {
|
|
446
|
+
continue;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
return [...cues].sort((left, right) => left.localeCompare(right));
|
|
450
|
+
}
|
|
451
|
+
function addBenchmarkAnchorCues(cues, prefix, rawValue) {
|
|
452
|
+
cues.add(`${prefix}_id=${rawValue}`);
|
|
453
|
+
cues.add(`${prefix}-${rawValue}`);
|
|
454
|
+
if (prefix === "source_chat") {
|
|
455
|
+
cues.add(`chat_id=${rawValue}`);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
function isBenchmarkAnchorValue(token) {
|
|
459
|
+
for (const char of token) {
|
|
460
|
+
if (isAsciiDigitChar(char)) {
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return false;
|
|
465
|
+
}
|
|
466
|
+
function isAsciiDigitChar(char) {
|
|
467
|
+
const code = char.charCodeAt(0);
|
|
468
|
+
return code >= 48 && code <= 57;
|
|
469
|
+
}
|
|
470
|
+
function normalizeBenchmarkAnchorPrefix(token) {
|
|
471
|
+
switch (token?.toLowerCase()) {
|
|
472
|
+
case "ability":
|
|
473
|
+
case "chat":
|
|
474
|
+
case "plan":
|
|
475
|
+
case "rubric":
|
|
476
|
+
case "source":
|
|
477
|
+
return token.toLowerCase();
|
|
478
|
+
default:
|
|
479
|
+
return void 0;
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
function tokenizeAnchorQuery(query) {
|
|
483
|
+
const tokens = [];
|
|
484
|
+
let current = "";
|
|
485
|
+
const push = () => {
|
|
486
|
+
const token = trimTrailingAnchorTokenPunctuation(current);
|
|
487
|
+
if (token.length > 0) {
|
|
488
|
+
tokens.push(token);
|
|
489
|
+
}
|
|
490
|
+
current = "";
|
|
491
|
+
};
|
|
492
|
+
for (const char of query) {
|
|
493
|
+
if (isAsciiLetterOrDigit(char) || char === "_" || char === "-" || char === "." || char === ":") {
|
|
494
|
+
current += char;
|
|
495
|
+
continue;
|
|
496
|
+
}
|
|
497
|
+
push();
|
|
498
|
+
}
|
|
499
|
+
push();
|
|
500
|
+
return tokens;
|
|
501
|
+
}
|
|
502
|
+
function trimTrailingAnchorTokenPunctuation(token) {
|
|
503
|
+
let end = token.length;
|
|
504
|
+
while (end > 0) {
|
|
505
|
+
const char = token[end - 1];
|
|
506
|
+
if (char !== "." && char !== ":" && char !== ";" && char !== "!" && char !== "?") {
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
end -= 1;
|
|
510
|
+
}
|
|
511
|
+
return token.slice(0, end);
|
|
512
|
+
}
|
|
513
|
+
function collectStructuredPlanCues(query) {
|
|
514
|
+
const cues = /* @__PURE__ */ new Set();
|
|
515
|
+
const normalizedQuery = query.toLowerCase().replace(/\s+/g, " ");
|
|
516
|
+
for (const cue of STRUCTURED_PLAN_FIELD_CUES) {
|
|
517
|
+
if (containsBoundedPhrase(normalizedQuery, cue)) {
|
|
518
|
+
cues.add(cue);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
if (cues.size === 0) {
|
|
522
|
+
return [];
|
|
523
|
+
}
|
|
524
|
+
for (const cue of STRUCTURED_PLAN_DEPENDENCY_CUES) {
|
|
525
|
+
if (containsBoundedPhrase(normalizedQuery, cue)) {
|
|
526
|
+
cues.add(cue);
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return [...cues].sort((left, right) => left.localeCompare(right));
|
|
530
|
+
}
|
|
531
|
+
function containsBoundedPhrase(normalizedHaystack, phrase) {
|
|
532
|
+
let searchFrom = 0;
|
|
533
|
+
while (searchFrom < normalizedHaystack.length) {
|
|
534
|
+
const index = normalizedHaystack.indexOf(phrase, searchFrom);
|
|
535
|
+
if (index < 0) {
|
|
536
|
+
return false;
|
|
537
|
+
}
|
|
538
|
+
const afterIndex = index + phrase.length;
|
|
539
|
+
if (isTemporalCueBoundary(normalizedHaystack[index - 1]) && isTemporalCueBoundary(normalizedHaystack[afterIndex])) {
|
|
540
|
+
return true;
|
|
541
|
+
}
|
|
542
|
+
searchFrom = afterIndex;
|
|
543
|
+
}
|
|
544
|
+
return false;
|
|
545
|
+
}
|
|
546
|
+
function collectTemporalLexicalCues(query) {
|
|
547
|
+
const cues = /* @__PURE__ */ new Set();
|
|
548
|
+
const normalizedQuery = query.toLowerCase().replace(/\s+/g, " ");
|
|
549
|
+
for (const cue of RELATIVE_TEMPORAL_CUES) {
|
|
550
|
+
if (containsBoundedPhrase(normalizedQuery, cue)) {
|
|
551
|
+
cues.add(cue);
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
return [...cues].sort((left, right) => left.localeCompare(right));
|
|
555
|
+
}
|
|
556
|
+
function hasLatestStateIntent(query) {
|
|
557
|
+
return collectTemporalLexicalCues(query).some(
|
|
558
|
+
(cue) => LATEST_STATE_CUES.has(cue)
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
function sortLexicalCueResults(results, preferLatest) {
|
|
562
|
+
return [...results].sort((left, right) => {
|
|
563
|
+
if (preferLatest) {
|
|
564
|
+
const sessionOrder2 = left.session_id.localeCompare(right.session_id);
|
|
565
|
+
if (sessionOrder2 !== 0) {
|
|
566
|
+
return sessionOrder2;
|
|
567
|
+
}
|
|
568
|
+
const turnOrder = right.turn_index - left.turn_index;
|
|
569
|
+
if (turnOrder !== 0) {
|
|
570
|
+
return turnOrder;
|
|
571
|
+
}
|
|
572
|
+
return (right.score ?? 0) - (left.score ?? 0);
|
|
573
|
+
}
|
|
574
|
+
const scoreDelta = (right.score ?? 0) - (left.score ?? 0);
|
|
575
|
+
if (scoreDelta !== 0) {
|
|
576
|
+
return scoreDelta;
|
|
577
|
+
}
|
|
578
|
+
const sessionOrder = left.session_id.localeCompare(right.session_id);
|
|
579
|
+
if (sessionOrder !== 0) {
|
|
580
|
+
return sessionOrder;
|
|
581
|
+
}
|
|
582
|
+
return left.turn_index - right.turn_index;
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
function normalizeSpeakerNameCue(value) {
|
|
586
|
+
const words = value.trim().split(/\s+/).filter(Boolean);
|
|
587
|
+
while (words.length > 0 && SPEAKER_NAME_STOPWORDS.has(words[0])) {
|
|
588
|
+
words.shift();
|
|
589
|
+
}
|
|
590
|
+
while (words.length > 0 && SPEAKER_NAME_STOPWORDS.has(words[words.length - 1])) {
|
|
591
|
+
words.pop();
|
|
592
|
+
}
|
|
593
|
+
return words.length > 0 ? words.join(" ") : void 0;
|
|
594
|
+
}
|
|
595
|
+
function isTemporalCueBoundary(char) {
|
|
596
|
+
if (!char) {
|
|
597
|
+
return true;
|
|
598
|
+
}
|
|
599
|
+
return !isAsciiLetterOrDigit(char);
|
|
600
|
+
}
|
|
601
|
+
function tokenizeReferenceQuery(query) {
|
|
602
|
+
const tokens = [];
|
|
603
|
+
let current = "";
|
|
604
|
+
const flushCurrent = () => {
|
|
605
|
+
if (current) {
|
|
606
|
+
tokens.push(current);
|
|
607
|
+
current = "";
|
|
608
|
+
}
|
|
609
|
+
};
|
|
610
|
+
for (const char of query) {
|
|
611
|
+
if (isAsciiLetterOrDigit(char)) {
|
|
612
|
+
current += char;
|
|
613
|
+
continue;
|
|
614
|
+
}
|
|
615
|
+
flushCurrent();
|
|
616
|
+
if (char === "#" || char === ",") {
|
|
617
|
+
tokens.push(char);
|
|
618
|
+
} else if (isReferenceDash(char)) {
|
|
619
|
+
tokens.push("-");
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
flushCurrent();
|
|
623
|
+
return tokens;
|
|
624
|
+
}
|
|
625
|
+
function parseReferenceNumbers(tokens, startIndex) {
|
|
626
|
+
const numbers = [];
|
|
627
|
+
let lastNumber;
|
|
628
|
+
let pendingRangeStart;
|
|
629
|
+
let index = startIndex;
|
|
630
|
+
const scanEnd = Math.min(
|
|
631
|
+
tokens.length,
|
|
632
|
+
startIndex + DEFAULT_MAX_REFERENCES * REFERENCE_SCAN_TOKEN_FACTOR
|
|
633
|
+
);
|
|
634
|
+
for (; index < scanEnd; index += 1) {
|
|
635
|
+
const token = tokens[index];
|
|
636
|
+
const normalized = token.toLowerCase();
|
|
637
|
+
const value = parseNonNegativeIntegerToken(token);
|
|
638
|
+
if (value !== void 0) {
|
|
639
|
+
if (pendingRangeStart !== void 0) {
|
|
640
|
+
numbers.push(...expandReferenceRange(pendingRangeStart, value));
|
|
641
|
+
pendingRangeStart = void 0;
|
|
642
|
+
} else {
|
|
643
|
+
numbers.push(value);
|
|
644
|
+
}
|
|
645
|
+
lastNumber = value;
|
|
646
|
+
continue;
|
|
647
|
+
}
|
|
648
|
+
if (normalized === "#" || normalized === "number" || normalized === ",") {
|
|
649
|
+
continue;
|
|
650
|
+
}
|
|
651
|
+
if (normalized === "-" || normalized === "to" || normalized === "through" || normalized === "thru") {
|
|
652
|
+
if (lastNumber !== void 0) {
|
|
653
|
+
if (numbers[numbers.length - 1] === lastNumber) {
|
|
654
|
+
numbers.pop();
|
|
655
|
+
}
|
|
656
|
+
pendingRangeStart = lastNumber;
|
|
657
|
+
}
|
|
658
|
+
continue;
|
|
659
|
+
}
|
|
660
|
+
if (normalized === "and" && numbers.length > 0) {
|
|
661
|
+
continue;
|
|
662
|
+
}
|
|
663
|
+
if (normalizeReferenceLabel(token)) {
|
|
664
|
+
break;
|
|
665
|
+
}
|
|
666
|
+
break;
|
|
667
|
+
}
|
|
668
|
+
if (pendingRangeStart !== void 0) {
|
|
669
|
+
numbers.push(pendingRangeStart);
|
|
670
|
+
}
|
|
671
|
+
return {
|
|
672
|
+
numbers: [...new Set(numbers)],
|
|
673
|
+
nextIndex: index
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
function expandReferenceRange(start, end) {
|
|
677
|
+
const low = Math.min(start, end);
|
|
678
|
+
const high = Math.max(start, end);
|
|
679
|
+
if (high - low + 1 > DEFAULT_MAX_REFERENCES) {
|
|
680
|
+
return [start, end];
|
|
681
|
+
}
|
|
682
|
+
const values = [];
|
|
683
|
+
for (let value = low; value <= high; value += 1) {
|
|
684
|
+
values.push(value);
|
|
685
|
+
}
|
|
686
|
+
return values;
|
|
687
|
+
}
|
|
688
|
+
function normalizeReferenceLabel(token) {
|
|
689
|
+
const normalized = token?.toLowerCase();
|
|
690
|
+
switch (normalized) {
|
|
691
|
+
case "step":
|
|
692
|
+
case "steps":
|
|
693
|
+
return "step";
|
|
694
|
+
case "turn":
|
|
695
|
+
case "turns":
|
|
696
|
+
return "turn";
|
|
697
|
+
case "action":
|
|
698
|
+
case "actions":
|
|
699
|
+
return "action";
|
|
700
|
+
case "observation":
|
|
701
|
+
case "observations":
|
|
702
|
+
return "observation";
|
|
703
|
+
default:
|
|
704
|
+
return void 0;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
function candidateTurnIndexesForReference(reference) {
|
|
708
|
+
const candidates = /* @__PURE__ */ new Set();
|
|
709
|
+
if (reference.includeDirectTurn) {
|
|
710
|
+
for (let offset = -1; offset <= 1; offset += 1) {
|
|
711
|
+
candidates.add(reference.number + offset);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
const pairedBase = reference.number * 2;
|
|
715
|
+
for (let offset = -2; offset <= 3; offset += 1) {
|
|
716
|
+
candidates.add(pairedBase + offset);
|
|
717
|
+
}
|
|
718
|
+
return [...candidates].sort((left, right) => left - right);
|
|
719
|
+
}
|
|
720
|
+
function parseNonNegativeIntegerToken(token) {
|
|
721
|
+
if (token.length === 0) {
|
|
722
|
+
return void 0;
|
|
723
|
+
}
|
|
724
|
+
let value = 0;
|
|
725
|
+
for (const char of token) {
|
|
726
|
+
const code = char.charCodeAt(0);
|
|
727
|
+
if (code < 48 || code > 57) {
|
|
728
|
+
return void 0;
|
|
729
|
+
}
|
|
730
|
+
value = value * 10 + (code - 48);
|
|
731
|
+
}
|
|
732
|
+
return value;
|
|
733
|
+
}
|
|
734
|
+
function normalizePositiveInteger(value, fallback) {
|
|
735
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
736
|
+
return fallback;
|
|
737
|
+
}
|
|
738
|
+
return Math.max(0, Math.floor(value));
|
|
739
|
+
}
|
|
740
|
+
function isAsciiLetterOrDigit(char) {
|
|
741
|
+
const code = char.charCodeAt(0);
|
|
742
|
+
return code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122;
|
|
743
|
+
}
|
|
744
|
+
function isReferenceDash(char) {
|
|
745
|
+
return char === "-" || char === "\u2010" || char === "\u2011" || char === "\u2012" || char === "\u2013" || char === "\u2014" || char === "\u2015";
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
export {
|
|
749
|
+
buildExplicitCueRecallSection,
|
|
750
|
+
collectExplicitTurnReferences,
|
|
751
|
+
collectLexicalCues,
|
|
752
|
+
collectQuestionSlotCues,
|
|
753
|
+
collectBenchmarkAnchorCues,
|
|
754
|
+
collectStructuredPlanCues,
|
|
755
|
+
collectTemporalLexicalCues
|
|
756
|
+
};
|
|
757
|
+
//# sourceMappingURL=chunk-AKV3HOGZ.js.map
|