@danceiny/gotry 0.0.1-rc.15 → 0.0.1-rc.17

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 (238) hide show
  1. package/README.md +51 -13
  2. package/README.zh-CN.md +26 -12
  3. package/bin/gotry-booking-copilot.js +53 -0
  4. package/bin/gotry-bootstrap.js +357 -8
  5. package/bin/gotry-inner.js +442 -60
  6. package/bin/gotry-runtime-resolution.d.ts +27 -0
  7. package/bin/gotry-runtime-resolution.js +50 -0
  8. package/bin/gotry.js +1 -1
  9. package/cordis.gotry-patch.yml +15 -1
  10. package/data/airline-airports.json +39 -0
  11. package/dist/capabilities/agent-reach-deep.js +1 -1
  12. package/dist/capabilities/agent-reach.js +1 -1
  13. package/dist/capabilities/anything.js +1 -1
  14. package/dist/capabilities/artifacts.js +1 -1
  15. package/dist/capabilities/effect.js +293 -0
  16. package/dist/capabilities/fact-log.js +41 -0
  17. package/dist/capabilities/flyai.js +20 -6
  18. package/dist/capabilities/hbcli.js +43 -1
  19. package/dist/capabilities/incident-log.js +1 -1
  20. package/dist/capabilities/model-override.js +18 -0
  21. package/dist/capabilities/opensky.js +1 -1
  22. package/dist/capabilities/resilience.js +90 -0
  23. package/dist/capabilities/session/action-cache.js +1 -1
  24. package/dist/capabilities/session/adapters/ctrip-flight.js +1 -1
  25. package/dist/capabilities/session/adapters/meituan-local.js +1 -1
  26. package/dist/capabilities/session/benchmark.js +2 -1
  27. package/dist/capabilities/session/extension-bridge.js +358 -0
  28. package/dist/capabilities/session/extension-channel.js +93 -0
  29. package/dist/capabilities/session/extension-distribution.js +234 -0
  30. package/dist/capabilities/session/extract.js +1 -1
  31. package/dist/capabilities/session/golden-score.js +92 -0
  32. package/dist/capabilities/session/health-watch.js +216 -0
  33. package/dist/capabilities/session/read-guard.js +1 -1
  34. package/dist/capabilities/session/static-flight-golden.js +137 -0
  35. package/dist/capabilities/session/transport.js +1 -1
  36. package/dist/capabilities/session/wizard.js +147 -0
  37. package/dist/capabilities/session-consent.js +1 -1
  38. package/dist/capabilities/session-login.js +83 -1
  39. package/dist/capabilities/session-search.js +111 -2
  40. package/dist/capabilities/weather.js +168 -46
  41. package/dist/data/session-golden-20.json +25 -0
  42. package/dist/data/sf-golden-manifest.json +102 -0
  43. package/dist/data/sf-static-routes.json +91 -0
  44. package/dist/scripts/action-cache-tests.js +1 -1
  45. package/dist/scripts/agent-planning-budget-e2e.js +227 -0
  46. package/dist/scripts/agent-planning-budget-tests.js +173 -0
  47. package/dist/scripts/agent-reach-deep-tests.js +1 -1
  48. package/dist/scripts/agent-reach-tests.js +1 -1
  49. package/dist/scripts/agent-reach-wrapper-tests.js +1 -1
  50. package/dist/scripts/anything-tests.js +1 -1
  51. package/dist/scripts/async-collect.js +1 -1
  52. package/dist/scripts/benchmark-environment-bridge-e2e.js +981 -0
  53. package/dist/scripts/benchmark-environment-bridge-tests.js +2544 -0
  54. package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +335 -0
  55. package/dist/scripts/booking-copilot-availability-policy-v2-tests.js +1355 -0
  56. package/dist/scripts/booking-copilot-bin-proof-tests.js +89 -0
  57. package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +113 -0
  58. package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +356 -0
  59. package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +557 -0
  60. package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +140 -0
  61. package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +202 -0
  62. package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +102 -0
  63. package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +374 -0
  64. package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +447 -0
  65. package/dist/scripts/booking-copilot-runtime-proof-tests.js +205 -0
  66. package/dist/scripts/booking-copilot-server-proof-tests.js +317 -0
  67. package/dist/scripts/booking-copilot-startup-proof-tests.js +283 -0
  68. package/dist/scripts/booking-copilot-v2-runtime-proof-tests.js +3935 -0
  69. package/dist/scripts/booking-saga-tests.js +1 -1
  70. package/dist/scripts/booking-surface-contract-proof-tests.js +393 -0
  71. package/dist/scripts/booking-surface-v2-contract-proof-tests.js +1174 -0
  72. package/dist/scripts/bootstrap-tests.js +59 -3
  73. package/dist/scripts/build-changelog.js +279 -0
  74. package/dist/scripts/changelog-tests.js +165 -0
  75. package/dist/scripts/companion-tests.js +1 -1
  76. package/dist/scripts/diff-test.js +1 -1
  77. package/dist/scripts/dsh-runtime-closure-tests.js +225 -0
  78. package/dist/scripts/dsh-runtime-closure.js +150 -0
  79. package/dist/scripts/effect-tests.js +474 -0
  80. package/dist/scripts/engine-run.js +1 -1
  81. package/dist/scripts/engine-tests.js +1 -1
  82. package/dist/scripts/evaluation-cadence-tests.js +347 -0
  83. package/dist/scripts/evaluation-contract-tests.js +574 -0
  84. package/dist/scripts/extension-distribution-cli.js +35 -0
  85. package/dist/scripts/extension-distribution-tests.js +341 -0
  86. package/dist/scripts/extension-tests.js +573 -0
  87. package/dist/scripts/fact-gate-tests.js +318 -0
  88. package/dist/scripts/flyai-tests.js +1 -1
  89. package/dist/scripts/hbcli-e2e-tests.js +180 -0
  90. package/dist/scripts/hbcli-tests.js +1 -1
  91. package/dist/scripts/health-watch-cli.js +51 -0
  92. package/dist/scripts/i18n-tests.js +1 -1
  93. package/dist/scripts/incident-tests.js +1 -1
  94. package/dist/scripts/journey-tests.js +1 -1
  95. package/dist/scripts/ledger-tests.js +1 -1
  96. package/dist/scripts/ledger-workflow-crash.js +1 -1
  97. package/dist/scripts/memory-capture-tests.js +1 -1
  98. package/dist/scripts/memory-decay-tests.js +1 -1
  99. package/dist/scripts/memory-metrics.js +1 -1
  100. package/dist/scripts/memory-value-report.js +1 -1
  101. package/dist/scripts/model-override-e2e.js +176 -0
  102. package/dist/scripts/nightly-evidence-tests.js +67 -4
  103. package/dist/scripts/nightly-evidence.js +59 -3
  104. package/dist/scripts/nudge-digest.js +1 -1
  105. package/dist/scripts/onboarding-tests.js +186 -0
  106. package/dist/scripts/opensky-check.js +1 -1
  107. package/dist/scripts/opensky-tests.js +1 -1
  108. package/dist/scripts/pnpm-dsh-closure-proof.js +20 -0
  109. package/dist/scripts/price-drift-tests.js +441 -0
  110. package/dist/scripts/price-drift-watch.js +491 -0
  111. package/dist/scripts/probe-poi-tests.js +1 -1
  112. package/dist/scripts/product-metrics.js +1 -1
  113. package/dist/scripts/publish-preverify.js +40 -4
  114. package/dist/scripts/realtime-pricing-tests.js +1 -1
  115. package/dist/scripts/replay-async.js +1 -1
  116. package/dist/scripts/replay-real.js +1 -1
  117. package/dist/scripts/replay.js +1 -1
  118. package/dist/scripts/session-attach-diagnose.js +1 -1
  119. package/dist/scripts/session-attach-poc.js +1 -1
  120. package/dist/scripts/session-benchmark.js +1 -1
  121. package/dist/scripts/session-extract-tests.js +1 -1
  122. package/dist/scripts/session-login.js +1 -1
  123. package/dist/scripts/session-tests.js +70 -20
  124. package/dist/scripts/sf-live-benchmark.js +338 -0
  125. package/dist/scripts/sf-live-cli-tests.js +21 -0
  126. package/dist/scripts/sf-soft-score-tests.js +108 -0
  127. package/dist/scripts/sf-summary.js +93 -0
  128. package/dist/scripts/skeleton-check.js +1 -1
  129. package/dist/scripts/skeleton-integration-test.js +1 -1
  130. package/dist/scripts/skills-contract-tests.js +1 -1
  131. package/dist/scripts/smoke-session-gate-tests.js +29 -0
  132. package/dist/scripts/smoke.js +154 -33
  133. package/dist/scripts/state-cli-tests.js +1 -1
  134. package/dist/scripts/state-cli.js +1 -1
  135. package/dist/scripts/static-golden-tests.js +299 -0
  136. package/dist/scripts/time-eval-tests.js +1 -1
  137. package/dist/scripts/travel-timeline-tests.js +1 -1
  138. package/dist/scripts/unified-tests.js +1 -1
  139. package/dist/scripts/weather-tests.js +694 -44
  140. package/dist/scripts/z3-race-tests.js +1 -1
  141. package/dist/src/artifact-gate.js +310 -0
  142. package/dist/src/benchmark-agent-conformance.js +370 -0
  143. package/dist/src/benchmark-environment-bridge.js +384 -0
  144. package/dist/src/benchmark-headless-child-diagnostics.js +173 -0
  145. package/dist/src/benchmark-tool-isolation.js +124 -0
  146. package/dist/src/bookable-facts.js +349 -0
  147. package/dist/src/booking-saga.js +1 -1
  148. package/dist/src/booking-surface/availability-policy-v2.js +830 -0
  149. package/dist/src/booking-surface/canonical-schema.js +113 -0
  150. package/dist/src/booking-surface/contracts-v2.js +89 -0
  151. package/dist/src/booking-surface/contracts.js +46 -0
  152. package/dist/src/booking-surface/dsh-planner.js +453 -0
  153. package/dist/src/booking-surface/dsh-plugin.js +93 -0
  154. package/dist/src/booking-surface/error-codes.js +94 -0
  155. package/dist/src/booking-surface/index.js +15 -0
  156. package/dist/src/booking-surface/profile.js +68 -0
  157. package/dist/src/booking-surface/runtime-v2.js +1771 -0
  158. package/dist/src/booking-surface/runtime.js +351 -0
  159. package/dist/src/booking-surface/server-v2.js +334 -0
  160. package/dist/src/booking-surface/server.js +302 -0
  161. package/dist/src/booking-surface/startup.js +159 -0
  162. package/dist/src/booking-surface/validation-v2.js +319 -0
  163. package/dist/src/booking-surface/validation.js +809 -0
  164. package/dist/src/bridge.js +1 -1
  165. package/dist/src/companions.js +1 -1
  166. package/dist/src/contracts.js +1 -1
  167. package/dist/src/dsh-llm.js +1 -1
  168. package/dist/src/engine.js +1 -1
  169. package/dist/src/evaluation-cadence.js +234 -0
  170. package/dist/src/evaluation-contracts.js +906 -0
  171. package/dist/src/i18n.js +1 -1
  172. package/dist/src/index.js +234 -60
  173. package/dist/src/journey.js +1 -1
  174. package/dist/src/loop.js +1 -1
  175. package/dist/src/memory-capture.js +1 -1
  176. package/dist/src/memory-decay.js +1 -1
  177. package/dist/src/memory-utility.js +1 -1
  178. package/dist/src/mock-llm.js +1 -1
  179. package/dist/src/model.js +1 -1
  180. package/dist/src/realtime-pricing.js +14 -7
  181. package/dist/src/slot-spec.js +1 -1
  182. package/dist/src/state-ledger.js +2 -1
  183. package/dist/src/time-anchor.js +1 -1
  184. package/dist/src/tool-budget.js +136 -0
  185. package/dist/src/tool-packet.js +1 -1
  186. package/dist/src/travel-slots.js +1 -1
  187. package/dist/src/travel-timeline.js +1 -1
  188. package/dist/src/unified.js +1 -1
  189. package/dist/src/wish-pool.js +1 -1
  190. package/dist/src/z3-shared.js +1 -1
  191. package/extension/README.md +50 -0
  192. package/extension/background.js +160 -0
  193. package/extension/content-bridge.js +41 -0
  194. package/extension/content-main.js +62 -0
  195. package/extension/manifest.json +32 -0
  196. package/package.json +291 -12
  197. package/schemas/booking.surface.v1.schema.json +927 -0
  198. package/schemas/booking.surface.v2.schema.json +61 -0
  199. package/ts/capabilities/fact-log.ts +54 -0
  200. package/ts/capabilities/flyai.ts +16 -3
  201. package/ts/capabilities/hbcli.ts +46 -0
  202. package/ts/capabilities/session/benchmark.ts +4 -1
  203. package/ts/capabilities/session/extension-bridge.ts +377 -0
  204. package/ts/capabilities/session/extension-channel.ts +95 -0
  205. package/ts/capabilities/session/extension-distribution.ts +264 -0
  206. package/ts/capabilities/session/golden-score.ts +139 -0
  207. package/ts/capabilities/session/health-watch.ts +257 -0
  208. package/ts/capabilities/session/static-flight-golden.ts +209 -0
  209. package/ts/capabilities/session/wizard.ts +140 -0
  210. package/ts/capabilities/session-login.ts +63 -2
  211. package/ts/capabilities/session-search.ts +105 -3
  212. package/ts/capabilities/weather.ts +141 -52
  213. package/ts/package.json +3 -3
  214. package/ts/src/artifact-gate.ts +365 -0
  215. package/ts/src/benchmark-agent-conformance.ts +448 -0
  216. package/ts/src/benchmark-environment-bridge.ts +348 -0
  217. package/ts/src/benchmark-headless-child-diagnostics.ts +184 -0
  218. package/ts/src/benchmark-tool-isolation.ts +166 -0
  219. package/ts/src/bookable-facts.ts +557 -0
  220. package/ts/src/booking-surface/availability-policy-v2.ts +523 -0
  221. package/ts/src/booking-surface/canonical-schema.js +113 -0
  222. package/ts/src/booking-surface/contracts-v2.ts +118 -0
  223. package/ts/src/booking-surface/contracts.ts +380 -0
  224. package/ts/src/booking-surface/dsh-planner.ts +452 -0
  225. package/ts/src/booking-surface/dsh-plugin.js +93 -0
  226. package/ts/src/booking-surface/error-codes.ts +101 -0
  227. package/ts/src/booking-surface/index.ts +12 -0
  228. package/ts/src/booking-surface/profile.ts +42 -0
  229. package/ts/src/booking-surface/runtime-v2.ts +1466 -0
  230. package/ts/src/booking-surface/runtime.ts +483 -0
  231. package/ts/src/booking-surface/server-v2.ts +247 -0
  232. package/ts/src/booking-surface/server.ts +324 -0
  233. package/ts/src/booking-surface/startup.ts +196 -0
  234. package/ts/src/booking-surface/validation-v2.ts +205 -0
  235. package/ts/src/booking-surface/validation.ts +453 -0
  236. package/ts/src/index.ts +161 -14
  237. package/ts/src/state-ledger.ts +1 -0
  238. package/ts/src/tool-budget.ts +165 -0
package/dist/src/i18n.js CHANGED
@@ -74,4 +74,4 @@ export function enCoverage() {
74
74
  }
75
75
 
76
76
 
77
- //# sourceURL=/Users/bytedance/work/gotry/ts/src/i18n.ts
77
+ //# sourceURL=ts/src/i18n.ts
package/dist/src/index.js CHANGED
@@ -5,7 +5,6 @@ import { ensureStateDir, recordLatency } from './bridge.js';
5
5
  import { segmentsFromCandidate, solveChoiceSegment } from './unified.js';
6
6
  import { checkConnectivity } from '../scripts/skeleton-check.js';
7
7
  import { parseCandidate, parseRequest } from './model.js';
8
- import { searchHotels as hbcliSearchHotels } from '../capabilities/hbcli.js';
9
8
  import { installProcessGuards, guardToolExecute } from '../capabilities/incident-log.js';
10
9
  import { interpretArgs } from './tool-packet.js';
11
10
  import { projectUtility } from './memory-utility.js';
@@ -14,16 +13,34 @@ import { resolveTimelineDate } from './travel-timeline.js';
14
13
  import { ensureLedger, readCompanionsWithFallback, readMotivationWithFallback, readTripsWithFallback, readWishPoolWithFallback } from './state-ledger.js';
15
14
  import { buildTimeAnchor } from './time-anchor.js';
16
15
  import { resolveSlotDate } from './slot-spec.js';
17
- import { geocodePlace, getForecast, getClimate, wmoLabel } from '../capabilities/weather.js';
18
- import { verifyFlight } from '../capabilities/opensky.js';
16
+ import { wmoLabel } from '../capabilities/weather.js';
19
17
  import { anythingSearch } from '../capabilities/anything.js';
20
18
  import { readUrl, reach, reachStatus } from '../capabilities/agent-reach.js';
21
19
  import { videoSubtitle, githubSearch } from '../capabilities/agent-reach-deep.js';
22
- import { flyaiSearch } from '../capabilities/flyai.js';
23
- import { sessionFlightSearch } from '../capabilities/session-search.js';
24
20
  import { sessionLogin } from '../capabilities/session-login.js';
21
+ import { EXTENSION_STORE_URL } from '../capabilities/session/extension-bridge.js';
25
22
  import { createConsentGate, approvalFromContext } from '../capabilities/session-consent.js';
23
+ import { installModelOverride } from '../capabilities/model-override.js';
26
24
  import { listArtifacts, readArtifact } from '../capabilities/artifacts.js';
25
+ import { interpretEffect, declinedObservation } from '../capabilities/effect.js';
26
+ import { appendFacts, loadFactRegistry } from '../capabilities/fact-log.js';
27
+ import { factsFromFlyai, factsFromSession } from './bookable-facts.js';
28
+ import { gateArtifact } from './artifact-gate.js';
29
+ import { installToolBudget } from './tool-budget.js';
30
+ import { registerBenchmarkEnvironmentBridge } from './benchmark-environment-bridge.js';
31
+ import { installBenchmarkToolIsolation } from './benchmark-tool-isolation.js';
32
+ import { installBenchmarkAgentConformance } from './benchmark-agent-conformance.js';
33
+ let airlineAirportMapCache = null;
34
+ async function loadAirlineAirportMap() {
35
+ if (airlineAirportMapCache) return airlineAirportMapCache;
36
+ try {
37
+ const { readFile } = await import('node:fs/promises');
38
+ airlineAirportMapCache = JSON.parse(await readFile(join(import.meta.dirname, '..', '..', 'data', 'airline-airports.json'), 'utf-8'));
39
+ return airlineAirportMapCache;
40
+ } catch {
41
+ return null;
42
+ }
43
+ }
27
44
  export const name = 'gotry-tools';
28
45
  export const inject = [
29
46
  'tools',
@@ -33,7 +50,8 @@ export const Config = z.object({
33
50
  stateRoot: z.string().default('.'),
34
51
  timeoutMs: z.number().default(30_000),
35
52
  hbcliBin: z.string().default('hbcli'),
36
- sessionAccess: z.string().default('ask')
53
+ sessionAccess: z.string().default('ask'),
54
+ benchmarkEnvironmentConfigPath: z.string().default('')
37
55
  });
38
56
  const unwrapQuery = interpretArgs;
39
57
  function renderMotivationBrief(stateRoot) {
@@ -78,6 +96,17 @@ function readTimelineTrips(stateRoot) {
78
96
  })).sort((a, b)=>a.start < b.start ? 1 : -1).slice(0, 3);
79
97
  }
80
98
  export function apply(ctx, config) {
99
+ installToolBudget(ctx);
100
+ const rawBenchmarkEnvironmentConfigPath = config.benchmarkEnvironmentConfigPath ?? '';
101
+ if (rawBenchmarkEnvironmentConfigPath.trim()) {
102
+ installModelOverride(ctx);
103
+ const getService = ctx.get;
104
+ const directSubprocess = typeof getService === 'function' ? getService.call(ctx, 'subprocess') : undefined;
105
+ const projection = registerBenchmarkEnvironmentBridge(rawBenchmarkEnvironmentConfigPath, (tool)=>ctx.tools.register(tool), directSubprocess);
106
+ installBenchmarkToolIsolation(ctx);
107
+ installBenchmarkAgentConformance(ctx, projection);
108
+ return;
109
+ }
81
110
  const sp = ctx['systemPrompt'];
82
111
  sp?.variable?.('current_date', ()=>{
83
112
  const d = new Date();
@@ -106,6 +135,7 @@ export function apply(ctx, config) {
106
135
  approval: approvalFromContext(ctx)
107
136
  }));
108
137
  }
138
+ installModelOverride(ctx);
109
139
  const registerGuarded = (tool)=>{
110
140
  const t = {
111
141
  ...tool
@@ -549,16 +579,20 @@ export function apply(ctx, config) {
549
579
  if (r.raw !== r.date) dateNotes.push(`slot-resolved: ${r.raw} → ${r.date}`);
550
580
  return r.date;
551
581
  };
552
- const resp = await hbcliSearchHotels({
553
- destination: q.destination,
554
- checkIn: resolveDate(q.checkIn),
555
- checkOut: resolveDate(q.checkOut),
556
- adults: q.adults
557
- }, {
558
- hbcliBin: config.hbcliBin,
559
- timeoutMs: config.timeoutMs,
560
- fallbackPath
582
+ const itp = await interpretEffect({
583
+ effect: 'HBCLI_HOTEL_SEARCH',
584
+ params: {
585
+ destination: q.destination,
586
+ checkIn: resolveDate(q.checkIn),
587
+ checkOut: resolveDate(q.checkOut),
588
+ adults: q.adults,
589
+ hbcliBin: config.hbcliBin,
590
+ timeoutMs: config.timeoutMs,
591
+ fallbackPath
592
+ }
561
593
  });
594
+ if (!itp.result) return declinedObservation('HBCLI_HOTEL_SEARCH', itp.trace);
595
+ const resp = itp.result;
562
596
  const dir = await ensureStateDir(config.stateRoot);
563
597
  const isLive = resp.via === 'hbcli-realtime';
564
598
  const evidence = isLive ? resp.evidence : '[静态包:估算]';
@@ -672,7 +706,14 @@ export function apply(ctx, config) {
672
706
  let placeLabel = q.place ?? `${q.lat},${q.lng}`;
673
707
  if (lat === undefined || lng === undefined) {
674
708
  if (!q.place) throw new Error('gotry_weather_check requires place name or lat/lng');
675
- const geo = await geocodePlace(q.place);
709
+ const geoItp = await interpretEffect({
710
+ effect: 'WEATHER_GEOCODE',
711
+ params: {
712
+ name: q.place
713
+ }
714
+ });
715
+ if (!geoItp.result) return declinedObservation('WEATHER_GEOCODE', geoItp.trace);
716
+ const geo = geoItp.result;
676
717
  if (!geo.ok || geo.results.length === 0) {
677
718
  return JSON.parse(JSON.stringify({
678
719
  ok: false,
@@ -686,15 +727,23 @@ export function apply(ctx, config) {
686
727
  placeLabel = `${hit.name}(${hit.admin1 ?? hit.country ?? ''})`;
687
728
  }
688
729
  const isClimate = q.mode === 'climate' || q.month !== undefined && q.mode !== 'forecast';
689
- const r = isClimate ? await getClimate({
690
- latitude: lat,
691
- longitude: lng
692
- }, q.month ?? new Date().getMonth() + 1) : await getForecast({
693
- latitude: lat,
694
- longitude: lng
695
- }, {
696
- days: q.days
730
+ const wxItp = isClimate ? await interpretEffect({
731
+ effect: 'WEATHER_CLIMATE',
732
+ params: {
733
+ latitude: lat,
734
+ longitude: lng,
735
+ month: q.month ?? new Date().getMonth() + 1
736
+ }
737
+ }) : await interpretEffect({
738
+ effect: 'WEATHER_FORECAST',
739
+ params: {
740
+ latitude: lat,
741
+ longitude: lng,
742
+ days: q.days
743
+ }
697
744
  });
745
+ if (!wxItp.result) return declinedObservation(isClimate ? 'WEATHER_CLIMATE' : 'WEATHER_FORECAST', wxItp.trace);
746
+ const r = wxItp.result;
698
747
  const dir = await ensureStateDir(config.stateRoot);
699
748
  await recordLatency(join(dir, 'bridge-latency.jsonl'), Date.now() - started, `weather:${r.via}`).catch(()=>{});
700
749
  const dailyLines = (r.daily ?? []).slice(0, 7).map((d)=>`${d.date} ${d.tempMinC.toFixed(0)}–${d.tempMaxC.toFixed(0)}°C ${wmoLabel(d.weatherCode)}${d.precipProbMaxPct !== null ? ` 降水概率${d.precipProbMaxPct}%` : ''}`);
@@ -762,11 +811,16 @@ export function apply(ctx, config) {
762
811
  summary: 'callsign 必填'
763
812
  }));
764
813
  }
765
- const r = await verifyFlight({
766
- callsign: q.callsign,
767
- airport: q.airport,
768
- timeoutMs: q.timeoutMs
814
+ const itp = await interpretEffect({
815
+ effect: 'OPENSKY_FLIGHT_VERIFY',
816
+ params: {
817
+ callsign: q.callsign,
818
+ airport: q.airport,
819
+ timeoutMs: q.timeoutMs
820
+ }
769
821
  });
822
+ if (!itp.result) return declinedObservation('OPENSKY_FLIGHT_VERIFY', itp.trace);
823
+ const r = itp.result;
770
824
  const dir = await ensureStateDir(config.stateRoot);
771
825
  await recordLatency(join(dir, 'bridge-latency.jsonl'), Date.now() - started, `flight_verify:${r.via}`).catch(()=>{});
772
826
  const summary = r.verdict === 'observed' ? `${r.callsign} 当前 ADS-B 观测命中 (${r.hits?.length ?? 0} 架)${r.airport ? ` 在 ${r.airport}` : ''}\n${r.evidence}` : r.verdict === 'not_observed' ? `${r.callsign} 当前观测列表未见(ADS-B 覆盖有限,不否定该航班存在)\n${r.evidence}` : `${r.callsign} OpenSky 不可用:${r.error}\n${r.evidence}`;
@@ -842,13 +896,18 @@ export function apply(ctx, config) {
842
896
  };
843
897
  }
844
898
  }
845
- const r = await flyaiSearch({
846
- kind: 'hotel',
847
- destName: dest,
848
- checkInDate: q.checkIn,
849
- checkOutDate: q.checkOut,
850
- keyWords: q.keyWords
899
+ const itp = await interpretEffect({
900
+ effect: 'FLYAI_SEARCH',
901
+ params: {
902
+ kind: 'hotel',
903
+ destName: dest,
904
+ checkInDate: q.checkIn,
905
+ checkOutDate: q.checkOut,
906
+ keyWords: q.keyWords
907
+ }
851
908
  });
909
+ if (!itp.result) return declinedObservation('FLYAI_SEARCH', itp.trace);
910
+ const r = itp.result;
852
911
  const top = (r.hotels ?? []).slice(0, 8).map((o)=>`${o.name}${o.star ? `(${o.star})` : ''} ${o.priceRaw ?? '价待询'}${o.poi ? ` · ${o.poi}` : ''}`);
853
912
  const summary = r.verdict === 'hit' ? `${dest} 酒店(飞猪官方只读)前 ${top.length} 家(价格多为打码,真实价以 jumpUrl 为准):\n${top.join('\n')}\n${r.evidence}` : `${dest} 酒店无结果或失败:${r.error ?? 'miss'} ${r.evidence}`;
854
913
  return JSON.parse(JSON.stringify({
@@ -873,12 +932,24 @@ export function apply(ctx, config) {
873
932
  summary: `未发起查询:日期 ${q.date} 已是过去(今天 ${todayYmd}),过去不存在在售机/火车票。` + `多为用户时间表达未带年份所致——向用户确认年份(或按未来最近的同月日修正)后再查。`
874
933
  }));
875
934
  }
876
- const r = await flyaiSearch({
935
+ const itp = await interpretEffect({
936
+ effect: 'FLYAI_SEARCH',
937
+ params: {
938
+ kind,
939
+ origin: q.from,
940
+ destination: q.to,
941
+ depDate: q.date
942
+ }
943
+ });
944
+ if (!itp.result) return declinedObservation('FLYAI_SEARCH', itp.trace);
945
+ const r = itp.result;
946
+ const avMap = await loadAirlineAirportMap();
947
+ await appendFacts(config.stateRoot ?? '.', factsFromFlyai({
877
948
  kind,
878
949
  origin: q.from,
879
950
  destination: q.to,
880
- depDate: q.date
881
- });
951
+ date: q.date
952
+ }, r, new Date().toISOString(), avMap?.city_alias));
882
953
  const top = (r.options ?? []).slice(0, 8).map((o)=>`${o.no} ${o.name} ${o.depDateTime.slice(11, 16)}→${o.arrDateTime.slice(11, 16)} ¥${o.price}`);
883
954
  const label = kind === 'flight' ? '机票' : '火车票';
884
955
  const summary = r.verdict === 'hit' ? `${q.from}→${q.to} ${q.date} ${label}(飞猪官方只读)前 ${top.length} 条:\n${top.join('\n')}\n${r.evidence}` : r.verdict === 'miss' ? `${q.from}→${q.to} ${q.date} ${label}官方通道正常返回 0 条(常见原因:航线未开放/当日售罄)。${r.evidence}` : `${q.from}→${q.to} ${q.date} ${label}检索失败(可能限流/网络):${r.error ?? ''} ${r.evidence}`;
@@ -912,7 +983,7 @@ export function apply(ctx, config) {
912
983
  }));
913
984
  registerGuarded(defineTool({
914
985
  name: 'gotry_session_login',
915
- description: 'Productized login bootstrap for the account session channel (call this when gotry_session_search returns needs-login — the user never needs a terminal). ' + 'AUTO-DETECTION FIRST: it reads ticket-cookie NAMES before anything else — if the user already logged in (on the external site) it confirms instantly WITHOUT opening any page. ' + 'OPENS the site login entry in the USER\'S OWN Chrome and waits for the user to finish logging in on the external site. ' + 'GoTry NEVER collects, stores, or transmits credentials: no passwords, no SMS codes, no cookie values — it only checks the boolean fact "already logged in" (reads cookie NAMES only, zero values). ' + 'verdict logged-in (tickets detected) | pending (login tab opened, user not done yet — offer to re-check later) | needs-attach (one-time Chrome remote-debugging switch instructions). ' + 'Evidence [会话:<site>-login@ts].',
986
+ description: 'Productized login bootstrap for the account session channel (call this when gotry_session_search returns needs-login — the user never needs a terminal). ' + 'AUTO-DETECTION FIRST: it reads ticket-cookie NAMES before anything else — if the user already logged in (on the external site) it confirms instantly WITHOUT opening any page. ' + 'OPENS the site login entry in the USER\'S OWN Chrome (foreground tab, left open for the user) and waits for the user to finish logging in on the external site. ' + 'GoTry NEVER collects, stores, or transmits credentials: no passwords, no SMS codes, no cookie values — it only checks the boolean fact "already logged in" (reads cookie NAMES only, zero values). ' + 'Transport: the GoTry Session Bridge browser extension (one-time install, ZERO Chrome system dialogs). ' + `verdict logged-in (tickets detected) | pending (login tab opened, user not done yet — offer to re-check later) | needs-extension (one-time extension install: the verdict surfaces the Chrome Web Store installUrl as a clickable link for dsh UI to render — installation is a browser concern, not gotry's). ` + 'Evidence [会话:<site>-login@ts].',
916
987
  parameters: {
917
988
  query: {
918
989
  type: 'json',
@@ -936,7 +1007,7 @@ export function apply(ctx, config) {
936
1007
  const r = await sessionLogin({
937
1008
  waitMs: typeof q?.waitSeconds === 'number' ? q.waitSeconds * 1000 : undefined
938
1009
  });
939
- const summary = r.verdict === 'logged-in' ? `${r.site} 登录完成确认(票据 cookie 名已检出,只读名字)。说明:登录是在携程官网、用你自己的浏览器完成的——gotry 全程未接触任何密码/验证码/cookie 值。现在可以继续会话检索了。${r.evidence}` : r.verdict === 'pending' ? `登录入口已在你的 Chrome 打开;请在弹出的标签页里正常登录携程(登录由你在官网完成,不属于 gotry)。完成后说一声"继续",我再确认。gotry 只检查"是否已登录",永不收集你的账号信息。${r.evidence}` : r.verdict === 'needs-attach' ? `需要一次性开启你 Chrome 的远程调试开关:在你的 Chrome 地址栏打开 chrome://inspect/#remote-debugging 并打开开关,然后说一声"重试"。${r.evidence}` : `登录引导未完成:${r.error ?? '未知原因'} ${r.evidence}`;
1010
+ const summary = r.verdict === 'logged-in' ? `${r.site} 登录完成确认(票据 cookie 名已检出,只读名字)。说明:登录是在携程官网、用你自己的浏览器完成的——gotry 全程未接触任何密码/验证码/cookie 值。现在可以继续会话检索了。${r.evidence}` : r.verdict === 'pending' ? `登录入口已在你的 Chrome 打开;请在弹出的标签页里正常登录携程(登录由你在官网完成,不属于 gotry)。完成后说一声"继续",我再确认。gotry 只检查"是否已登录",永不收集你的账号信息。${r.evidence}` : r.verdict === 'needs-extension' ? `需要一次性安装 GoTry Session Bridge 浏览器扩展:这是浏览器的事,gotry 不弹面板不开剪贴板——请直接在 Chrome 应用商店一键装(add-to-chrome 自动更新)。storeUrl=${EXTENSION_STORE_URL}. 装好即生效,装完后告诉我「重试」即可。${r.evidence}` : r.verdict === 'needs-attach' ? `cdp 车道需要一次性开启你 Chrome 的远程调试开关:在你的 Chrome 地址栏打开 chrome://inspect/#remote-debugging 并打开开关,然后说一声"重试"(默认走扩展车道,无需此步)。${r.evidence}` : `登录引导未完成:${r.error ?? '未知原因'} ${r.evidence}`;
940
1011
  return JSON.parse(JSON.stringify({
941
1012
  ...r,
942
1013
  summary
@@ -950,22 +1021,28 @@ export function apply(ctx, config) {
950
1021
  }),
951
1022
  presentResult: (_args, value)=>{
952
1023
  const r = value;
953
- const label = r.verdict === 'logged-in' ? `已登录(${(r.tickets ?? []).length} 票据)` : r.verdict === 'pending' ? '等待你在携程页面完成登录' : r.verdict ?? '降级';
1024
+ const needsExt = r.verdict === 'needs-extension';
1025
+ const label = r.verdict === 'logged-in' ? `已登录(${(r.tickets ?? []).length} 票据)` : r.verdict === 'pending' ? '等待你在携程页面完成登录' : needsExt ? '🧩 需装 GoTry Session Bridge 扩展(浏览器商店一键装,自动更新)' : r.verdict ?? '降级';
1026
+ const content = [
1027
+ {
1028
+ type: 'text',
1029
+ text: String(value.summary ?? '')
1030
+ }
1031
+ ];
1032
+ if (needsExt && r.installUrl) content.push({
1033
+ type: 'text',
1034
+ text: `安装链接:${r.installUrl}`
1035
+ });
954
1036
  return {
955
1037
  card: 'generic',
956
1038
  title: `账号登录:${label}`,
957
- content: [
958
- {
959
- type: 'text',
960
- text: String(value.summary ?? '')
961
- }
962
- ]
1039
+ content
963
1040
  };
964
1041
  }
965
1042
  }));
966
1043
  registerGuarded(defineTool({
967
1044
  name: 'gotry_session_search',
968
- description: 'Search on the USER\'S OWN logged-in browser session (Ctrip flights today; the account channel, not an anonymous instance). ' + 'Consent gate: the FIRST call in a session asks the user via the runtime approval card; once granted it holds for the session, a refusal revokes it for the session (no repeat prompting). ' + 'ReadGuard = physically read-only (write requests aborted at network layer; agent NEVER touches credentials/captcha; on captcha it stops and returns challenged). ' + 'Currently ctrip-flight: sniffs the site search API for structured options. Evidence [会话:ctrip-flight@ts]. ' + 'verdict needs-login = call gotry_session_login (product tool: opens the Ctrip login entry in the user\'s own Chrome and waits for them to log in on the external site — no terminal, no credentials through GoTry); needs-attach = one-time Chrome remote-debugging switch. ' + 'Rate-limited (≥30s between same-site calls; a challenged/timeout verdict means STOP — never retry, fall back to other tools).',
1045
+ description: 'Search on the USER\'S OWN logged-in browser session (Ctrip flights today; the account channel, not an anonymous instance). ' + 'Consent gate: the FIRST call in a session asks the user via the runtime approval card; once granted it holds for the session, a refusal revokes it for the session (no repeat prompting). ' + 'Transport: GoTry Session Bridge browser extension (one-time install) — the agent side never talks to Chrome debugging, ZERO system dialogs; read-only by construction (the extension never issues requests; it only passively forwards the site\'s own search responses; agent NEVER touches credentials/captcha; on captcha it stops and returns challenged). ' + 'Currently ctrip-flight: sniffs the site search API for structured options. Evidence [会话:ctrip-flight@ts]. ' + 'verdict needs-login = call gotry_session_login (opens the Ctrip login entry in the user\'s own foreground tab — no terminal, no credentials through GoTry); ' + `needs-extension = one-time browser-extension install (Chrome Web Store one-click, installUrl is also surfaced as a clickable link in the verdict field for dsh UI to render) — the DEFAULT transport; cdp (chrome://inspect remote debugging) is a diagnostic fallback only via GOTRY_SESSION_TRANSPORT=cdp. ` + 'Rate-limited (≥30s between same-site calls; a challenged/timeout verdict means STOP — never retry, fall back to other tools).',
969
1046
  parameters: {
970
1047
  query: {
971
1048
  type: 'json',
@@ -992,12 +1069,23 @@ export function apply(ctx, config) {
992
1069
  summary: '需要 from/to(中文城市名,词表内)与 date(YYYY-MM-DD)'
993
1070
  };
994
1071
  }
995
- const r = await sessionFlightSearch({
996
- from: q.from,
997
- to: q.to,
998
- date: q.date,
999
- auditPath: join(config.stateRoot ?? '.', 'gotry-state', 'session-incidents.jsonl')
1072
+ const itp = await interpretEffect({
1073
+ effect: 'SESSION_FLIGHT_SEARCH',
1074
+ params: {
1075
+ from: q.from,
1076
+ to: q.to,
1077
+ date: q.date,
1078
+ auditPath: join(config.stateRoot ?? '.', 'gotry-state', 'session-incidents.jsonl')
1079
+ }
1000
1080
  });
1081
+ if (!itp.result) return declinedObservation('SESSION_FLIGHT_SEARCH', itp.trace);
1082
+ const r = itp.result;
1083
+ const avMapS = await loadAirlineAirportMap();
1084
+ await appendFacts(config.stateRoot ?? '.', factsFromSession({
1085
+ origin: q.from,
1086
+ destination: q.to,
1087
+ date: q.date
1088
+ }, r, new Date().toISOString(), avMapS?.city_alias));
1001
1089
  const top = (r.options ?? []).slice(0, 8).map((o)=>`${o.flightNo} ${o.airline} ${o.depDateTime.slice(11, 16)}→${o.arrDateTime.slice(11, 16)} ¥${o.price}`);
1002
1090
  const summary = r.verdict === 'hit' ? `${q.from}→${q.to} ${q.date} 会话检索(携程,用户本人登录态)前 ${top.length} 条:\n${top.join('\n')}\n${r.evidence}` : `会话检索未取回(${r.verdict}):${r.error ?? ''} ${r.evidence}`;
1003
1091
  return JSON.parse(JSON.stringify({
@@ -1013,16 +1101,22 @@ export function apply(ctx, config) {
1013
1101
  }),
1014
1102
  presentResult: (_args, value)=>{
1015
1103
  const r = value;
1016
- const label = r.verdict === 'hit' ? `会话 ${r.options.length} 条` : r.verdict === 'needs-login' ? '需登录' : r.verdict ?? '降级';
1104
+ const needsExt = r.verdict === 'needs-extension';
1105
+ const label = r.verdict === 'hit' ? `会话 ${r.options.length} 条` : r.verdict === 'needs-login' ? '需登录' : needsExt ? '🧩 需装 GoTry Session Bridge 扩展(浏览器商店一键装,自动更新)' : r.verdict ?? '降级';
1106
+ const content = [
1107
+ {
1108
+ type: 'text',
1109
+ text: String(value.summary ?? '')
1110
+ }
1111
+ ];
1112
+ if (needsExt && r.installUrl) content.push({
1113
+ type: 'text',
1114
+ text: `安装链接:${r.installUrl}`
1115
+ });
1017
1116
  return {
1018
1117
  card: 'generic',
1019
1118
  title: `会话检索:${label}`,
1020
- content: [
1021
- {
1022
- type: 'text',
1023
- text: String(value.summary ?? '')
1024
- }
1025
- ]
1119
+ content
1026
1120
  };
1027
1121
  }
1028
1122
  }));
@@ -1490,7 +1584,87 @@ export function apply(ctx, config) {
1490
1584
  };
1491
1585
  }
1492
1586
  }));
1587
+ registerGuarded(defineTool({
1588
+ name: 'gotry_fact_gate',
1589
+ description: 'Factuality gate for itinerary artifacts (issue #46): call BEFORE delivering any artifact that contains bookable facts ' + '(flight numbers, times, airports, prices, visa/entry policies). Every bookable claim in the markdown is checked against ' + 'the session fact registry (exact-date tool results recorded by gotry_flyai_search / gotry_session_search — hit AND miss). ' + 'Blocked when: a claimed flight is absent from the exact-date source (never backfill from route pages/history/adjacent dates); ' + 'route+date never queried; times contradict the snapshot; carrier→airport mapping conflicts (FD=DMK vs VZ=BKK are NOT interchangeable); ' + '「联程」without protected_connection=true; policy claims without 「截至 YYYY-MM-DD」; unconditional ✓ on unverified claims. ' + 'Optional itinerary object enables machine invariants (hotel_nights + onboard_nights = total nights, O&D segments vs flight legs, ' + 'budget floor ≥ sum of item minimums). verdict=blocked ⇒ fix or downgrade wording — never present as a verified plan.',
1590
+ parameters: {
1591
+ query: {
1592
+ type: 'json',
1593
+ required: true,
1594
+ description: '{ markdown?: "<产物全文>", path?: "<产物路径(artifacts_list 返回的)>— 二选一", tripYear?: 2027, itinerary?: { trip_start, trip_end, stays: [{place,check_in,check_out}], onboard_nights, od_segments: [{from,to,date,mode,legs}], budget_items: [{label,min_cny,max_cny}], claimed_floor_cny? } }'
1595
+ }
1596
+ },
1597
+ output: {
1598
+ schema: {
1599
+ type: 'json'
1600
+ },
1601
+ render: (_args, value)=>[
1602
+ {
1603
+ type: 'text',
1604
+ text: String(value.summary ?? JSON.stringify(value).slice(0, 800))
1605
+ }
1606
+ ]
1607
+ },
1608
+ async execute (args, _exec) {
1609
+ const q = unwrapQuery(args, 'markdown');
1610
+ const avMap = await loadAirlineAirportMap();
1611
+ if (!avMap) {
1612
+ return JSON.parse(JSON.stringify({
1613
+ ok: false,
1614
+ summary: '航司机场映射缺失(data/airline-airports.json)——事实闸不可用,fail closed:产物不得宣称已验证'
1615
+ }));
1616
+ }
1617
+ let markdown = q.markdown;
1618
+ if (!markdown && q.path) {
1619
+ const r = await readArtifact({
1620
+ stateRoot: config.stateRoot ?? '.',
1621
+ path: q.path
1622
+ });
1623
+ if (!r.ok) return JSON.parse(JSON.stringify({
1624
+ ok: false,
1625
+ summary: `产物读取失败:${String(r.error ?? '')}`
1626
+ }));
1627
+ markdown = r.content;
1628
+ }
1629
+ if (!markdown) return JSON.parse(JSON.stringify({
1630
+ ok: false,
1631
+ summary: '需要 markdown(产物全文)或 path(产物路径)'
1632
+ }));
1633
+ const itinerary = q.itinerary;
1634
+ const registry = await loadFactRegistry(config.stateRoot ?? '.');
1635
+ const report = gateArtifact(markdown, registry, avMap, {
1636
+ trip_year: q.tripYear,
1637
+ itinerary
1638
+ });
1639
+ const lines = report.violations.slice(0, 20).map((v)=>` L${v.line} [${v.kind}] ${v.detail}`);
1640
+ const summary = report.verdict === 'pass' ? `事实闸 PASS:${report.traceable}/${report.claims_checked} 可下单 claim 全部回溯到 exact-date 工具结果(query_id 可重放)——可宣称「已验证方案」。` : `事实闸 BLOCKED(${report.violations.length} 违例,${report.traceable}/${report.claims_checked} claim 可回溯)——不得宣称「已验证方案」:\n${lines.join('\n')}\n修正路径:逐条改成 exact-date 源返回的事实,或降级为「未确认/当前不可售,到 D-xx 复核」;exact-date miss 的 route+date 不得用历史班期/相邻日期/航线页填充。`;
1641
+ return JSON.parse(JSON.stringify({
1642
+ ok: true,
1643
+ ...report,
1644
+ summary
1645
+ }));
1646
+ },
1647
+ presentCall: (args)=>({
1648
+ card: 'generic',
1649
+ title: '产物事实闸',
1650
+ kind: 'execute',
1651
+ rawInput: args.query
1652
+ }),
1653
+ presentResult: (_args, value)=>{
1654
+ const r = value;
1655
+ return {
1656
+ card: 'generic',
1657
+ title: `事实闸:${r.verdict === 'pass' ? '✅ pass' : `⛔ blocked(${r.violations?.length ?? '?'})`}`,
1658
+ content: [
1659
+ {
1660
+ type: 'text',
1661
+ text: String(r.summary ?? '')
1662
+ }
1663
+ ]
1664
+ };
1665
+ }
1666
+ }));
1493
1667
  }
1494
1668
 
1495
1669
 
1496
- //# sourceURL=/Users/bytedance/work/gotry/ts/src/index.ts
1670
+ //# sourceURL=ts/src/index.ts
@@ -140,4 +140,4 @@ export function parseFlightPackLegs(pack) {
140
140
  }
141
141
 
142
142
 
143
- //# sourceURL=/Users/bytedance/work/gotry/ts/src/journey.ts
143
+ //# sourceURL=ts/src/journey.ts
package/dist/src/loop.js CHANGED
@@ -408,4 +408,4 @@ export function probePoi(msg) {
408
408
  }
409
409
 
410
410
 
411
- //# sourceURL=/Users/bytedance/work/gotry/ts/src/loop.ts
411
+ //# sourceURL=ts/src/loop.ts
@@ -37,4 +37,4 @@ export function mergeProfile(current, patch) {
37
37
  }
38
38
 
39
39
 
40
- //# sourceURL=/Users/bytedance/work/gotry/ts/src/memory-capture.ts
40
+ //# sourceURL=ts/src/memory-capture.ts
@@ -28,4 +28,4 @@ function round4(x) {
28
28
  }
29
29
 
30
30
 
31
- //# sourceURL=/Users/bytedance/work/gotry/ts/src/memory-decay.ts
31
+ //# sourceURL=ts/src/memory-decay.ts
@@ -52,4 +52,4 @@ export function projectUtility(events) {
52
52
  }
53
53
 
54
54
 
55
- //# sourceURL=/Users/bytedance/work/gotry/ts/src/memory-utility.ts
55
+ //# sourceURL=ts/src/memory-utility.ts
@@ -100,4 +100,4 @@ export function createMockLlm(flightPackPath, slotScript = []) {
100
100
  }
101
101
 
102
102
 
103
- //# sourceURL=/Users/bytedance/work/gotry/ts/src/mock-llm.ts
103
+ //# sourceURL=ts/src/mock-llm.ts
package/dist/src/model.js CHANGED
@@ -131,4 +131,4 @@ export function trueCostToDict(t) {
131
131
  }
132
132
 
133
133
 
134
- //# sourceURL=/Users/bytedance/work/gotry/ts/src/model.ts
134
+ //# sourceURL=ts/src/model.ts
@@ -1,4 +1,4 @@
1
- import { flyaiSearch } from '../capabilities/flyai.js';
1
+ import { interpretEffect } from '../capabilities/effect.js';
2
2
  const IATA_TO_CITY = {
3
3
  HKG: '香港',
4
4
  HKT: '普吉',
@@ -76,12 +76,19 @@ export async function overlayRealtimeFlightPrices(spec, opts = {}) {
76
76
  }
77
77
  return out;
78
78
  }
79
- const defaultQuery = (q)=>flyaiSearch({
80
- kind: q.kind,
81
- origin: q.origin,
82
- destination: q.destination,
83
- depDate: q.depDate
79
+ const defaultQuery = async (q)=>{
80
+ const itp = await interpretEffect({
81
+ effect: 'FLYAI_SEARCH',
82
+ params: {
83
+ kind: q.kind,
84
+ origin: q.origin,
85
+ destination: q.destination,
86
+ depDate: q.depDate
87
+ }
84
88
  });
89
+ if (!itp.result) throw new Error(itp.trace.evidence.join(';'));
90
+ return itp.result;
91
+ };
85
92
  export function realtimeSolvePort(base, opts = {}) {
86
93
  return async (spec)=>{
87
94
  const enabled = opts.enabled ?? process.env['GOTRY_REALTIME_PRICING'] === '1';
@@ -102,4 +109,4 @@ export function realtimeSolvePort(base, opts = {}) {
102
109
  }
103
110
 
104
111
 
105
- //# sourceURL=/Users/bytedance/work/gotry/ts/src/realtime-pricing.ts
112
+ //# sourceURL=ts/src/realtime-pricing.ts
@@ -162,4 +162,4 @@ export function specDateMismatches(spec, resolved) {
162
162
  }
163
163
 
164
164
 
165
- //# sourceURL=/Users/bytedance/work/gotry/ts/src/slot-spec.ts
165
+ //# sourceURL=ts/src/slot-spec.ts
@@ -694,6 +694,7 @@ export class StateLedger {
694
694
  }
695
695
  close() {
696
696
  this.db.close();
697
+ for (const [key, value] of openLedgers)if (value === this) openLedgers.delete(key);
697
698
  }
698
699
  }
699
700
  const openLedgers = new Map();
@@ -924,4 +925,4 @@ export function readCompanionsWithFallback(stateRoot) {
924
925
  }
925
926
 
926
927
 
927
- //# sourceURL=/Users/bytedance/work/gotry/ts/src/state-ledger.ts
928
+ //# sourceURL=ts/src/state-ledger.ts
@@ -97,4 +97,4 @@ export function parseAbsoluteDate(expr, anchorYear) {
97
97
  }
98
98
 
99
99
 
100
- //# sourceURL=/Users/bytedance/work/gotry/ts/src/time-anchor.ts
100
+ //# sourceURL=ts/src/time-anchor.ts