@danceiny/gotry 0.2.0-rc.27 → 0.2.0-rc.29

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 (79) hide show
  1. package/README.md +2 -2
  2. package/README.zh-CN.md +2 -2
  3. package/bin/gotry-bootstrap.js +56 -12
  4. package/data/yunnan-pack.json +30 -27
  5. package/dist/capabilities/anything.js +26 -0
  6. package/dist/capabilities/channel-registry.js +4 -4
  7. package/dist/capabilities/doctor.js +14 -7
  8. package/dist/capabilities/effect.js +1 -1
  9. package/dist/capabilities/ground-transfer.js +168 -1
  10. package/dist/capabilities/provider-detail-sanitize.js +64 -0
  11. package/dist/capabilities/route-provider-conformance.js +341 -0
  12. package/dist/capabilities/session/extension-bridge.js +3 -3
  13. package/dist/capabilities/session-search.js +1 -1
  14. package/dist/scripts/anything-path-measure-tests.js +133 -0
  15. package/dist/scripts/anything-path-measure.js +150 -0
  16. package/dist/scripts/anything-tests.js +136 -2
  17. package/dist/scripts/booking-copilot-dsh-warmer-proof.js +5 -2
  18. package/dist/scripts/bootstrap-tests.js +77 -7
  19. package/dist/scripts/city-scenario-tier-tests.js +234 -0
  20. package/dist/scripts/doctor-tests.js +39 -3
  21. package/dist/scripts/drill-multiuser-ledger-tests.js +1076 -0
  22. package/dist/scripts/drill-sdk-descendant-cleanup-tests.js +606 -0
  23. package/dist/scripts/drill-w2a-sensor-tests.js +788 -0
  24. package/dist/scripts/dsh-llm-tests.js +437 -0
  25. package/dist/scripts/g5-guard-tests.js +20 -1
  26. package/dist/scripts/g5-guard.js +5 -1
  27. package/dist/scripts/gotry-backend-kernel-tests.js +1 -1
  28. package/dist/scripts/m3-cohort-tests.js +714 -0
  29. package/dist/scripts/m3-cohort.js +310 -0
  30. package/dist/scripts/nightly-evidence-tests.js +44 -2
  31. package/dist/scripts/nightly-evidence.js +21 -4
  32. package/dist/scripts/outcome-projection-tests.js +427 -0
  33. package/dist/scripts/persona-sim-tests.js +621 -0
  34. package/dist/scripts/persona-sim.js +1081 -0
  35. package/dist/scripts/replay-async.js +2 -0
  36. package/dist/scripts/replay.js +2 -0
  37. package/dist/scripts/route-provider-conformance-tests.js +391 -0
  38. package/dist/scripts/session-dida-live-e2e.js +1 -1
  39. package/dist/scripts/session-zone-crash.js +49 -0
  40. package/dist/scripts/session-zone-ledger-tests.js +432 -0
  41. package/dist/scripts/session-zone-observation-tests.js +492 -0
  42. package/dist/scripts/session-zone-observe.js +135 -0
  43. package/dist/scripts/session-zone-wiring-tests.js +566 -0
  44. package/dist/scripts/session-zones-tests.js +17 -1
  45. package/dist/scripts/spawn-bounded-abort-tests.js +3 -0
  46. package/dist/scripts/state-cli.js +16 -0
  47. package/dist/scripts/time-eval-tests.js +2 -0
  48. package/dist/scripts/unified-tests.js +79 -2
  49. package/dist/scripts/z3-race-tests.js +6 -1
  50. package/dist/src/backend/modules/session-search.js +1 -1
  51. package/dist/src/city-scenario-tier.js +378 -0
  52. package/dist/src/dsh-llm.js +84 -14
  53. package/dist/src/index.js +166 -7
  54. package/dist/src/loop.js +16 -5
  55. package/dist/src/m3-cohort.js +1577 -0
  56. package/dist/src/outcome-projection.js +746 -0
  57. package/dist/src/session-zone-ledger.js +312 -0
  58. package/dist/src/session-zone-observation.js +354 -0
  59. package/dist/src/session-zone-wiring.js +658 -0
  60. package/dist/src/session-zones.js +7 -4
  61. package/dist/src/state-ledger.js +293 -40
  62. package/dist/src/unified.js +69 -5
  63. package/extension/README.md +1 -1
  64. package/extension/README.zh-CN.md +1 -1
  65. package/extension/background.js +1 -1
  66. package/extension/content-bridge.js +1 -1
  67. package/extension/content-main.js +1 -1
  68. package/extension/manifest.json +2 -2
  69. package/package.json +1 -1
  70. package/ts/capabilities/anything.ts +27 -0
  71. package/ts/capabilities/session/extension-bridge.ts +3 -3
  72. package/ts/capabilities/session-search.ts +1 -1
  73. package/ts/scripts/state-cli.ts +18 -0
  74. package/ts/src/contracts.ts +4 -0
  75. package/ts/src/dsh-llm.ts +111 -9
  76. package/ts/src/index.ts +181 -8
  77. package/ts/src/loop.ts +15 -5
  78. package/ts/src/state-ledger.ts +294 -40
  79. package/ts/src/unified.ts +91 -18
package/ts/src/index.ts CHANGED
@@ -27,7 +27,19 @@ import { interpretArgs, type GotryObservation } from './tool-packet.ts'
27
27
  import { projectUtility } from './memory-utility.ts'
28
28
  import { pickNudgeWish, type WishPoolEntry } from './wish-pool.ts'
29
29
  import { resolveTimelineDate } from './travel-timeline.ts'
30
- import { ensureLedger, readCompanionsWithFallback, readMotivationWithFallback, readTripsWithFallback, readWishPoolWithFallback } from './state-ledger.ts'
30
+ import { ensureLedger, openLedgerIfExists, readCompanionsWithFallback, readMotivationWithFallback, readTripsWithFallback, readWishPoolWithFallback } from './state-ledger.ts'
31
+ import {
32
+ applyZoneNote,
33
+ bindZoneSession,
34
+ boundZoneSession,
35
+ isZoneObservableTool,
36
+ observeToolResult,
37
+ promoteWithRouting,
38
+ renderSessionZoneBrief,
39
+ resolveZoneSwitch,
40
+ zoneScopeOfExec,
41
+ zoneSessionRefFromExec,
42
+ } from './session-zone-wiring.ts'
31
43
  import { isValidHomeCityPreference, resolveDefaultOrigin, type MergedProfile, type ProfilePatch } from './memory-capture.ts'
32
44
  import { applyPlanningWindow } from './loop.ts'
33
45
  import { buildTimeAnchor, type PlanningWindow } from './time-anchor.ts'
@@ -105,6 +117,8 @@ export interface Config {
105
117
  hbcliBin: string
106
118
  /** 账号会话检索总闸(RFC 支柱④「用户明示授权+随时可关」):ask=gotry_session_search 每会话每站点首次调用弹审批卡、会话内记住(默认);allow=用户已在配置明示预授权(直接放行);off=总闸关闭,直接拒绝 */
107
119
  sessionAccess: string
120
+ /** 会话双区记忆总闸(issue #255 P4-3):off=默认(缺省/未知值同样 fail-closed 关),接线完全惰性(零账本事件/读回空串/工具不注册);on=创始人本地启用 */
121
+ sessionZones?: string
108
122
  /** Owner-local benchmark environment bridge config; empty disables the bridge. */
109
123
  benchmarkEnvironmentConfigPath?: string
110
124
  /** Trusted absolute path of the installed `lavish-axi@0.1.67` package; empty disables the local Lavish Editor product tools. */
@@ -116,6 +130,7 @@ export const Config: z<Config> = z.object({
116
130
  timeoutMs: z.number().default(30_000),
117
131
  hbcliBin: z.string().default('hbcli'),
118
132
  sessionAccess: z.string().default('ask'),
133
+ sessionZones: z.string().default('off'),
119
134
  benchmarkEnvironmentConfigPath: z.string().default(''),
120
135
  lavishAxiPackageRoot: z.string().default(''),
121
136
  })
@@ -533,8 +548,11 @@ export function apply(ctx: Context, config: Config, seams: ApplyTestSeams = {}):
533
548
 
534
549
  // 时间感知:注册动态变量,persona 里用 {{current_date}} 引用。
535
550
  // 每次 assemble 时取系统时钟——LLM 始终知道「今天是几号」。
551
+ // provider 收到本次组装的 AssembleContext(dsh-system-prompt 契约:
552
+ // `variable(name, provider: (context: AssembleContext) => string | undefined)`);
553
+ // `scope` 是不透明、按身份比较的 ScopeKey —— 分区读回据此分辨会话。
536
554
  const sp = (ctx as unknown as Record<string, unknown>)['systemPrompt'] as {
537
- variable?: (name: string, provider: () => string) => void
555
+ variable?: (name: string, provider: (context?: { scope?: object }) => string) => void
538
556
  } | undefined
539
557
  sp?.variable?.('current_date', () => {
540
558
  const d = new Date()
@@ -551,6 +569,33 @@ export function apply(ctx: Context, config: Config, seams: ApplyTestSeams = {}):
551
569
  // 渲染成紧凑 brief 注入 persona;为空 = 首访。与当轮说法冲突时以用户为准。
552
570
  sp?.variable?.('motivation_brief', () => renderMotivationBrief(config.stateRoot ?? '.'))
553
571
 
572
+ // 会话双区记忆读回(issue #255 P4-3,design/session-dual-zone-memory-design.md §5):
573
+ // 变量恒注册(persona 侧可随时引用),但总闸 off(默认)时恒返回空串 —— 接线惰性,
574
+ // 不建库、不读库、零事件;persona 模板本身不在本 PR 改动,因此开关 off 时注入面
575
+ // 输出逐字节不变。空串 = 首访/无活笔记(与 motivation_brief 同纪律)。
576
+ // 会话双区读回(issue #255 P4-3):**只在总闸 on 时注册**。
577
+ // - 为什么是条件注册:默认关必须与 main **不可区分**——注入面多出一个变量名
578
+ // 就已经是可观测差异(§48 benchmark-environment-bridge-tests 的
579
+ // 「normal product mode keeps its prompt variables」逐项断言会红)。
580
+ // 出厂 persona(cordis.gotry-patch.yml)今天不引用本变量,所以条件注册安全。
581
+ // - **后续约束**:创始人一旦把 `{{session_zone_brief}}` 写进出厂 persona,
582
+ // 本变量必须改为**无条件注册**(关闸时返回空串)——strict 插值下未注册的
583
+ // 引用会让整段 persona 渲染失败。那一步同时要改 §48 的变量清单断言、
584
+ // persona-surface-guard-tests 的注入面清单与 benchmark-environment-bridge-e2e
585
+ // 的 CANONICAL_RAW_VARIABLES。
586
+ // - 读回按**组装 scope** 取会话身份(dsh agent-loop 以 agent 对象为 ScopeKey,
587
+ // 与工具侧 exec.agent 同一身份):同一宿主进程里的两个会话因此读不到对方的
588
+ // resource 层笔记(设计 §1.1);取不到 scope → 不出 resource 段(fail-closed)。
589
+ const zoneSwitch = resolveZoneSwitch(config.sessionZones)
590
+ if (zoneSwitch === 'on') {
591
+ sp?.variable?.('session_zone_brief', assembleContext => renderSessionZoneBrief({
592
+ ledger: openLedgerIfExists(config.stateRoot ?? '.'),
593
+ now: new Date().toISOString(),
594
+ sessionRef: boundZoneSession(assembleContext?.scope),
595
+ zoneSwitch,
596
+ }))
597
+ }
598
+
554
599
  // 通道路由卡(通道注册表生成,docs/design/tool-orchestration-design.md §2.1/D-8):
555
600
  // persona 检索条款只留行为契约,机/火/酒通道顺位与额度口径查卡——prose 教义
556
601
  // 变查表教义,注册表加通道卡片自动一致。
@@ -631,6 +676,29 @@ export function apply(ctx: Context, config: Config, seams: ApplyTestSeams = {}):
631
676
  if (typeof t.execute === 'function') {
632
677
  t.execute = guardToolExecute(String(t.name), config.stateRoot ?? '.', t.execute as (args: never, exec: unknown) => never)
633
678
  }
679
+ // 工具观察捕获缝(issue #255 P4-3):总闸 on 且工具在闭集白名单内才包裹——
680
+ // off(默认)时 execute 一层不多包,行为逐字节不变。捕获只投影形状字段
681
+ // (verdict/条数/价格带),证据只走指针;捕获失败永不影响工具返回值。
682
+ if (zoneSwitch === 'on' && typeof t.execute === 'function' && isZoneObservableTool(t.name)) {
683
+ const inner = t.execute as (args: never, exec: unknown) => Promise<unknown>
684
+ const toolName = String(t.name)
685
+ t.execute = async (args: never, exec: unknown): Promise<unknown> => {
686
+ const result = await inner(args, exec)
687
+ try {
688
+ const sessionRef = zoneSessionRefFromExec(exec)
689
+ if (sessionRef) {
690
+ bindZoneSession(zoneScopeOfExec(exec), sessionRef)
691
+ observeToolResult(openLedgerIfExists(config.stateRoot ?? '.') ?? ensureLedger(config.stateRoot ?? '.'), {
692
+ tool: toolName,
693
+ result,
694
+ session_ref: sessionRef,
695
+ ts: new Date().toISOString(),
696
+ })
697
+ }
698
+ } catch { /* 记忆面永不把产品主路径带红 */ }
699
+ return result
700
+ }
701
+ }
634
702
  ctx.tools.register(t as unknown as ReturnType<typeof defineTool>)
635
703
  }
636
704
 
@@ -1156,6 +1224,111 @@ export function apply(ctx: Context, config: Config, seams: ApplyTestSeams = {}):
1156
1224
  presentCall: args => ({ card: 'generic', title: '记录旅行', kind: 'edit', rawInput: args }),
1157
1225
  }))
1158
1226
 
1227
+ // 会话双区记忆工具面(issue #255 P4-3):**只在总闸 on 时注册**——off(默认)时
1228
+ // 工具清单逐项不变,模型看不到任何分区入口(接线惰性的第一道)。
1229
+ if (zoneSwitch === 'on') {
1230
+ registerGuarded(defineTool({
1231
+ name: 'gotry_session_zone_note',
1232
+ description:
1233
+ 'Session working-zone memory (hot context, issue #255): capture a STRUCTURED fragment of what is still in play this session '
1234
+ + '(destination / date window / party size / budget stance = intent tier, 24h; search shapes = resource tier, 30min), '
1235
+ + 'revise it with optimistic CAS when the user corrects a detail, or drop it when it stops being true. '
1236
+ + 'Payload must be typed slot-spec-family fields — NEVER raw conversation text, IDs, phone numbers, URLs or credentials '
1237
+ + '(the write gate rejects those shapes). Evidence is a pointer (session + observation index), never content. '
1238
+ + 'action="propose" only PROPOSES moving a note into the durable notebook: it writes NOTHING; the owner must confirm in their own words, '
1239
+ + 'after which you call gotry_session_zone_promote with that quote. The model may never self-promote. '
1240
+ + 'action="deny" records that the owner declined to remember it long-term (writes nothing; stop re-proposing it this session).',
1241
+ parameters: {
1242
+ action: { type: 'string', required: true, enum: ['capture', 'revise', 'drop', 'propose', 'deny'], description: 'capture=新片段入工作区;revise=CAS 修订(需 noteId+expectedRev);drop=更正即弃;propose=提议晋升(零写入);deny=owner 否决提议(零写入)' },
1243
+ tier: { type: 'string', enum: ['resource', 'intent'], description: 'capture 必填:intent(目的地/日期/人数/预算立场,24h)或 resource(检索形态,30min)' },
1244
+ kind: { type: 'string', enum: ['availability', 'price_band', 'destination', 'date_window', 'party_size', 'budget_stance'], description: 'capture 必填;revise 可选(改 kind)' },
1245
+ payload: { type: 'object', additionalProperties: true, description: '结构化片段,如 { city: "大理" } / { start: "2026-11-01", end: "2026-11-05" };禁放原文/证件/电话/URL/凭证' },
1246
+ noteId: { type: 'string', description: 'revise/drop/propose 的目标笔记 id' },
1247
+ expectedRev: { type: 'integer', description: 'revise 的父 rev(必须等于当前 rev,否则 stale_rev 拒绝)' },
1248
+ promoteKind: { type: 'string', enum: ['trip_fact', 'preference', 'constraint', 'lesson'], description: 'propose 时提议的持久条目类别' },
1249
+ },
1250
+ output: {
1251
+ schema: { type: 'json' },
1252
+ render: (_args, value) => [{ type: 'text', text: String((value as { summary?: string }).summary ?? '') }],
1253
+ },
1254
+ async execute(args, exec: unknown) {
1255
+ const sessionRef = zoneSessionRefFromExec(exec)
1256
+ if (!sessionRef) {
1257
+ return { ok: false, code: 'bad_session', summary: '无会话身份(exec.agent.session.id 缺失):分区不记忆无主体的片段' } as never
1258
+ }
1259
+ bindZoneSession(zoneScopeOfExec(exec), sessionRef)
1260
+ const r = applyZoneNote(ensureLedger(config.stateRoot), {
1261
+ action: args.action as never,
1262
+ ...(args.tier !== undefined ? { tier: args.tier } : {}),
1263
+ ...(args.kind !== undefined ? { kind: args.kind } : {}),
1264
+ ...(args.payload !== undefined ? { payload: args.payload as Record<string, unknown> } : {}),
1265
+ ...(args.noteId !== undefined ? { noteId: args.noteId } : {}),
1266
+ ...(args.expectedRev !== undefined ? { expectedRev: args.expectedRev } : {}),
1267
+ ...(args.promoteKind !== undefined ? { promoteKind: args.promoteKind } : {}),
1268
+ session_ref: sessionRef,
1269
+ ts: new Date().toISOString(),
1270
+ })
1271
+ if (!r.ok) return { ok: false, code: r.code, summary: r.detail } as never
1272
+ const summary = r.proposed
1273
+ ? `已提议(未写入):${r.ask ?? ''}`
1274
+ : `${r.action}${r.appended ? ' 已落账' : ' 幂等跳过'}${r.noteId ? `:${r.noteId.slice(0, 60)}` : ''}`
1275
+ return { ok: true, action: r.action, appended: r.appended, note_id: r.noteId, requires_owner_confirm: r.requiresOwnerConfirm === true, summary } as never
1276
+ },
1277
+ presentCall: args => ({ card: 'generic', title: `会话记忆:${String(args.action ?? '')}`, kind: 'edit', rawInput: args }),
1278
+ }))
1279
+
1280
+ registerGuarded(defineTool({
1281
+ name: 'gotry_session_zone_promote',
1282
+ description:
1283
+ 'Owner-confirmed promotion into the durable trip notebook (issue #255) — the ONLY write path into durable memory. '
1284
+ + 'Requires ownerQuote: the user\'s OWN words confirming they want this remembered long-term; your own summary is not a confirmation. '
1285
+ + 'Routing rule: a preference ALSO goes through the motivation-profile gate (pass motivation.{weights|hard|homeCity}), '
1286
+ + 'a trip fact through the timeline gate (pass trip.{destination,start}), a companion constraint through the companion gate (pass companion.{label,constraints}). '
1287
+ + 'Without the required routed payload the promotion is REJECTED — the notebook never becomes a parallel store for a fact that already has an owner. '
1288
+ + 'Generic constraints and lessons live in the notebook itself. The notebook write and the routed gate write are one transaction: they cannot diverge.',
1289
+ parameters: {
1290
+ noteId: { type: 'string', required: true, description: '源工作区笔记 id(必须未过期)' },
1291
+ kind: { type: 'string', required: true, enum: ['trip_fact', 'preference', 'constraint', 'lesson'], description: '持久条目类别' },
1292
+ ownerQuote: { type: 'string', required: true, description: '用户本人确认要长期记住的原话(≤200 字;模型自述不算确认)' },
1293
+ surface: { type: 'string', required: true, enum: ['user_reply', 'approval_card'], description: '确认表面:用户回复 或 审批卡' },
1294
+ payload: { type: 'object', additionalProperties: true, description: '可选:覆盖源笔记载荷的结构化断言' },
1295
+ motivation: { type: 'object', additionalProperties: true, description: 'preference 必填:{ weights?, hard?, homeCity? } 至少一项(经动机画像闸)' },
1296
+ trip: { type: 'object', additionalProperties: true, description: 'trip_fact 必填:{ destination, start(YYYY-MM-DD), end?, companions? }(经时间线闸)' },
1297
+ companion: { type: 'object', additionalProperties: true, description: '同行人约束必填:{ label, constraints:{ mobility?, health?, prefs? } }(经同行人闸)' },
1298
+ },
1299
+ output: {
1300
+ schema: { type: 'json' },
1301
+ render: (_args, value) => [{ type: 'text', text: String((value as { summary?: string }).summary ?? '') }],
1302
+ },
1303
+ async execute(args, exec: unknown) {
1304
+ const sessionRef = zoneSessionRefFromExec(exec)
1305
+ if (sessionRef) bindZoneSession(zoneScopeOfExec(exec), sessionRef)
1306
+ const r = promoteWithRouting(ensureLedger(config.stateRoot), {
1307
+ noteId: String(args.noteId ?? ''),
1308
+ kind: String(args.kind ?? ''),
1309
+ ownerQuote: String(args.ownerQuote ?? ''),
1310
+ surface: String(args.surface ?? ''),
1311
+ ...(args.payload !== undefined ? { payload: args.payload as Record<string, unknown> } : {}),
1312
+ ...(args.motivation !== undefined ? { motivation: args.motivation as never } : {}),
1313
+ ...(args.trip !== undefined ? { trip: args.trip as never } : {}),
1314
+ ...(args.companion !== undefined ? { companion: args.companion as never } : {}),
1315
+ ts: new Date().toISOString(),
1316
+ })
1317
+ if (!r.ok) return { ok: false, code: r.code, summary: r.detail } as never
1318
+ const routed = r.routed ? `;并经 ${r.routed.authority} 闸${r.routed.applied ? '落地' : '幂等跳过'}` : ''
1319
+ return {
1320
+ ok: true,
1321
+ appended: r.appended,
1322
+ entry_id: r.entryId,
1323
+ authority: r.authority,
1324
+ routed: r.routed ? JSON.parse(JSON.stringify(r.routed)) as JsonObject : null,
1325
+ summary: `${r.appended ? '已写入笔记本' : '笔记本幂等跳过'}${routed}`,
1326
+ } as never
1327
+ },
1328
+ presentCall: args => ({ card: 'generic', title: '笔记本晋升(owner 确认)', kind: 'edit', rawInput: args }),
1329
+ }))
1330
+ }
1331
+
1159
1332
  registerGuarded(defineTool({
1160
1333
  name: 'gotry_hotel_search',
1161
1334
  description: routed('gotry_hotel_search',
@@ -1615,7 +1788,7 @@ export function apply(ctx: Context, config: Config, seams: ApplyTestSeams = {}):
1615
1788
  '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. '
1616
1789
  + '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. '
1617
1790
  + '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). '
1618
- + 'Transport: the GoTry Session Bridge browser extension (one-time install, ZERO Chrome system dialogs). '
1791
+ + 'Transport: the Stai Travel Bridge browser extension (one-time install, ZERO Chrome system dialogs). '
1619
1792
  + `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). `
1620
1793
  + 'Evidence [会话:<site>-login@ts].',
1621
1794
  // D-30 第三刀(issue #112):query blob → 平铺 typed;全字段可选 → interpretArgs 容忍层
@@ -1634,7 +1807,7 @@ export function apply(ctx: Context, config: Config, seams: ApplyTestSeams = {}):
1634
1807
  : r.verdict === 'pending'
1635
1808
  ? `登录入口已在你的 Chrome 打开;请在弹出的标签页里正常登录携程(登录由你在官网完成,不属于 gotry)。完成后说一声"继续",我再确认。gotry 只检查"是否已登录",永不收集你的账号信息。${r.evidence}`
1636
1809
  : r.verdict === 'needs-extension'
1637
- ? `需要一次性安装 GoTry Session Bridge 浏览器扩展:这是浏览器的事,gotry 不弹面板不开剪贴板——请直接在 Chrome 应用商店一键装(add-to-chrome 自动更新)。storeUrl=${EXTENSION_STORE_URL}. 装好即生效,装完后告诉我「重试」即可。${r.evidence}`
1810
+ ? `需要一次性安装 Stai Travel Bridge 浏览器扩展:这是浏览器的事,gotry 不弹面板不开剪贴板——请直接在 Chrome 应用商店一键装(add-to-chrome 自动更新)。storeUrl=${EXTENSION_STORE_URL}. 装好即生效,装完后告诉我「重试」即可。${r.evidence}`
1638
1811
  : r.verdict === 'needs-attach'
1639
1812
  ? `cdp 车道需要一次性开启你 Chrome 的远程调试开关:在你的 Chrome 地址栏打开 chrome://inspect/#remote-debugging 并打开开关,然后说一声"重试"(默认走扩展车道,无需此步)。${r.evidence}`
1640
1813
  : `登录引导未完成:${r.error ?? '未知原因'} ${r.evidence}`
@@ -1649,7 +1822,7 @@ export function apply(ctx: Context, config: Config, seams: ApplyTestSeams = {}):
1649
1822
  : r.verdict === 'pending'
1650
1823
  ? '等待你在携程页面完成登录'
1651
1824
  : needsExt
1652
- ? '🧩 需装 GoTry Session Bridge 扩展(浏览器商店一键装,自动更新)'
1825
+ ? '🧩 需装 Stai Travel Bridge 扩展(浏览器商店一键装,自动更新)'
1653
1826
  : r.verdict ?? '降级'
1654
1827
  const content: Array<{ type: 'text'; text: string }> = [{ type: 'text', text: String((value as { summary?: string }).summary ?? '') }]
1655
1828
  // needs-extension:把商店 URL 渲成可点链接(浏览器自己当安装器,gotry 不插手)
@@ -1664,7 +1837,7 @@ export function apply(ctx: Context, config: Config, seams: ApplyTestSeams = {}):
1664
1837
  description: routed('gotry_session_search',
1665
1838
  'Search on the USER\'S OWN browser session (Ctrip kind="flight"(default)/"hotel"; 12306 kind="train" — public query face, no login needed). '
1666
1839
  + '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). '
1667
- + '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). '
1840
+ + 'Transport: Stai Travel 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). '
1668
1841
  + 'kind="flight": from/to 中文城市名 + date YYYY-MM-DD — sniffs the site search API for structured options. Evidence [会话:ctrip-flight@ts]. '
1669
1842
  + 'kind="hotel": to=目的地中文, cityId? = the numeric city= in a hotels.ctrip.com list URL (web-search it when the destination is outside the built-in city table), checkIn?/checkOut? (YYYY-MM-DD), adults?; hotel prices are the user\'s real logged-in prices. Evidence [会话:ctrip-hotel@ts]. '
1670
1843
  + 'kind="dida": Dida supplier-portal realtime hotel rates on the employee\'s own logged-in session (hotel-be portal integration line) — no from/to needed; the portal find page\'s own requests are sniffed passively. Rates carry ratePlanId/referenceNo for the server-side booking chain. Evidence [会话:dida-portal@ts]. '
@@ -1838,7 +2011,7 @@ export function apply(ctx: Context, config: Config, seams: ApplyTestSeams = {}):
1838
2011
  : r.verdict === 'needs-login'
1839
2012
  ? '需登录'
1840
2013
  : needsExt
1841
- ? '🧩 需装 GoTry Session Bridge 扩展(浏览器商店一键装,自动更新)'
2014
+ ? '🧩 需装 Stai Travel Bridge 扩展(浏览器商店一键装,自动更新)'
1842
2015
  : r.verdict ?? '降级'
1843
2016
  const content: Array<{ type: 'text'; text: string }> = [{ type: 'text', text: String((value as { summary?: string }).summary ?? '') }]
1844
2017
  if (needsExt && r.installUrl) content.push({ type: 'text', text: `安装链接:${r.installUrl}` })
@@ -2128,7 +2301,7 @@ export function apply(ctx: Context, config: Config, seams: ApplyTestSeams = {}):
2128
2301
  registerGuarded(defineTool({
2129
2302
  name: 'gotry_doctor',
2130
2303
  description:
2131
- 'Check optional-dependency health for ALL gotry tools (read-only by default). Coverage: GoTry Session Bridge extension / Agent Reach (.venv) / hbcli (hotel realtime) / FlyAI key + recent trial-quota exhaustion time / dsh-calendar mount state / dsh-better-sidebar / dsh-map-tools / dsh-tool-ask-user. '
2304
+ 'Check optional-dependency health for ALL gotry tools (read-only by default). Coverage: Stai Travel Bridge extension / Agent Reach (.venv) / hbcli (hotel realtime) / FlyAI key + recent trial-quota exhaustion time / dsh-calendar mount state / dsh-better-sidebar / dsh-map-tools / dsh-tool-ask-user. '
2132
2305
  + 'Call this when ANY gotry tool returns not-installed / needs-setup, when the user asks 「体检/依赖状态/工具为什么不可用」, or BEFORE leaning on a channel for a plan. '
2133
2306
  + 'Returns per-item status (ok/degraded/missing) with exact fix commands. '
2134
2307
  + 'Action=diagnose (default): pure read-only — never installs anything, only renders the report. '
package/ts/src/loop.ts CHANGED
@@ -238,13 +238,18 @@ function terminalOutcomeFromState(ticketId: string, state: TripState): AsyncTerm
238
238
  })
239
239
  }
240
240
 
241
+ // issue #620:求解器自身失败时既没有产物也没有判定——2 条不成立;但「做不到诚实说」
242
+ // 恰恰成立(我们明说了是引擎故障而非不可行),不靠 unsat_core 冒充自检通过。
243
+ const solverFailed = Boolean(state.solve.solver_error)
241
244
  return asyncTerminalOutcome(ticketId, {
242
245
  '1_承诺时间后必有明确产物': Boolean(state.solve.legs?.length || state.solve.verdicts?.length),
243
- '2_产物通过自检清单': state.solve.feasible
244
- ? (state.solve.legs?.every(l => (l as Record<string, unknown>)['energy_pct'] !== undefined) ?? false)
245
- : Boolean(state.solve.unsat_core?.length),
246
+ '2_产物通过自检清单': solverFailed
247
+ ? false
248
+ : state.solve.feasible
249
+ ? (state.solve.legs?.every(l => (l as Record<string, unknown>)['energy_pct'] !== undefined) ?? false)
250
+ : Boolean(state.solve.unsat_core?.length),
246
251
  '3_待决问题全部是简单选择题': state.gates.every(g => g.id === 'budget' || g.options.length >= 2),
247
- '4_做不到的诚实说': state.solve.feasible || Boolean(state.solve.suggestions?.length),
252
+ '4_做不到的诚实说': solverFailed || state.solve.feasible || Boolean(state.solve.suggestions?.length),
248
253
  })
249
254
  }
250
255
 
@@ -292,7 +297,12 @@ export function renderSolve(state: TripState): string {
292
297
  const s = state.solve
293
298
  if (!s) return '(无求解结果)'
294
299
  const lines: string[] = []
295
- if (s.feasible) {
300
+ if (s.solver_error) {
301
+ // issue #620:求解器自己失败 ≠ 行程不可行。这里**不**说「不可行」、不列「冲突」,
302
+ // 也不把机器 token(solver_error.code)渲染给用户——它只在日志/证据里。
303
+ lines.push('**这轮没算出结论——求解器自身出错了,不是你的行程不可行**')
304
+ lines.push('- 我不把引擎故障说成「不可行」:这条已记录,修好或换候选形态(枚举)后重算')
305
+ } else if (s.feasible) {
296
306
  lines.push(`**方案可行,机票合计 ¥${s.money_cny}**`)
297
307
  // §7-1 issue #559 卡点 4:从 s.skeleton_notes 字符串编码里推断 unscaffolded 的 seg.id,
298
308
  // 不动 unified.ts/journey.ts(内核冻结面 #234),用户面给 ⚠ 前缀与「枢纽对未在骨架覆盖」补充。