@danceiny/gotry 0.0.1-rc.18 → 0.0.1-rc.20

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 (176) hide show
  1. package/README.md +42 -16
  2. package/README.zh-CN.md +37 -15
  3. package/bin/gotry-bootstrap.js +309 -30
  4. package/bin/gotry-inner.js +74 -23
  5. package/bin/gotry-runtime-resolution.d.ts +1 -1
  6. package/bin/gotry-runtime-resolution.js +7 -8
  7. package/cordis.gotry-patch.yml +22 -8
  8. package/data/stations-12306-verify.json +524 -0
  9. package/dist/capabilities/agent-reach.js +4 -4
  10. package/dist/capabilities/anything.js +62 -29
  11. package/dist/capabilities/channel-health.js +103 -0
  12. package/dist/capabilities/channel-registry.js +213 -0
  13. package/dist/capabilities/doctor.js +307 -0
  14. package/dist/capabilities/effect.js +178 -5
  15. package/dist/capabilities/flyai.js +13 -0
  16. package/dist/capabilities/hbcli.js +28 -2
  17. package/dist/capabilities/session/adapters/ctrip-hotel.js +207 -0
  18. package/dist/capabilities/session/adapters/rail-12306.js +285 -0
  19. package/dist/capabilities/session/extension-bridge.js +14 -1
  20. package/dist/capabilities/session/extension-channel.js +4 -2
  21. package/dist/capabilities/session/extension-distribution.js +1 -1
  22. package/dist/capabilities/session-search.js +311 -0
  23. package/dist/capabilities/visa-policy.js +126 -0
  24. package/dist/scripts/agent-planning-turn-deadline-e2e.js +305 -0
  25. package/dist/scripts/agent-planning-turn-deadline-tests.js +281 -0
  26. package/dist/scripts/anything-tests.js +70 -21
  27. package/dist/scripts/benchmark-environment-bridge-e2e.js +139 -37
  28. package/dist/scripts/benchmark-environment-bridge-tests.js +1099 -306
  29. package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +26 -26
  30. package/dist/scripts/{booking-copilot-availability-policy-v2-tests.js → booking-copilot-availability-policy-tests.js} +115 -115
  31. package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +41 -1
  32. package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +75 -120
  33. package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +370 -61
  34. package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +2 -2
  35. package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +7 -3
  36. package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +15 -9
  37. package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +19 -11
  38. package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +16 -52
  39. package/dist/scripts/booking-copilot-runtime-proof-tests.js +3953 -155
  40. package/dist/scripts/booking-copilot-server-proof-tests.js +58 -23
  41. package/dist/scripts/booking-copilot-startup-proof-tests.js +10 -119
  42. package/dist/scripts/booking-surface-contract-proof-tests.js +1154 -326
  43. package/dist/scripts/bootstrap-tests.js +113 -2
  44. package/dist/scripts/build-metrics-report.js +339 -0
  45. package/dist/scripts/channel-probe-tests.js +148 -0
  46. package/dist/scripts/channel-probe.js +252 -0
  47. package/dist/scripts/channel-registry-tests.js +262 -0
  48. package/dist/scripts/doctor-tests.js +175 -0
  49. package/dist/scripts/effect-tests.js +274 -1
  50. package/dist/scripts/extension-tests.js +129 -11
  51. package/dist/scripts/fact-gate-tests.js +91 -2
  52. package/dist/scripts/flyai-tests.js +17 -1
  53. package/dist/scripts/hbcli-e2e-tests.js +1 -3
  54. package/dist/scripts/hbcli-tests.js +38 -1
  55. package/dist/scripts/metrics-report-tests.js +288 -0
  56. package/dist/scripts/persona-surface-guard-tests.js +19 -0
  57. package/dist/scripts/session-tests.js +401 -1
  58. package/dist/scripts/smoke.js +100 -83
  59. package/dist/scripts/turn-handoff-collect-tests.js +216 -0
  60. package/dist/scripts/turn-handoff-collect.js +189 -0
  61. package/dist/scripts/turn-policy-tests.js +56 -0
  62. package/dist/scripts/typed-contract-canary.js +261 -0
  63. package/dist/scripts/visa-policy-tests.js +75 -0
  64. package/dist/scripts/wish-channel-gate-tests.js +111 -0
  65. package/dist/src/artifact-gate.js +91 -3
  66. package/dist/src/benchmark-agent-conformance.js +39 -16
  67. package/dist/src/benchmark-environment-bridge.js +316 -52
  68. package/dist/src/bookable-facts.js +62 -3
  69. package/dist/src/booking-surface/{availability-policy-v2.js → availability-policy.js} +89 -89
  70. package/dist/src/booking-surface/canonical-schema.js +8 -22
  71. package/dist/src/booking-surface/contracts.js +70 -19
  72. package/dist/src/booking-surface/dsh-planner.js +310 -177
  73. package/dist/src/booking-surface/dsh-plugin.js +3 -3
  74. package/dist/src/booking-surface/index.js +1 -5
  75. package/dist/src/booking-surface/profile.js +1 -1
  76. package/dist/src/booking-surface/runtime.js +1682 -247
  77. package/dist/src/booking-surface/server.js +371 -185
  78. package/dist/src/booking-surface/startup.js +17 -27
  79. package/dist/src/booking-surface/validation.js +270 -760
  80. package/dist/src/index.js +739 -150
  81. package/dist/src/turn-deadline.js +292 -0
  82. package/dist/src/turn-policy.js +146 -0
  83. package/dist/src/wish-pool.js +5 -0
  84. package/extension/background.js +23 -4
  85. package/extension/content-main.js +47 -9
  86. package/extension/manifest.json +27 -9
  87. package/package.json +7 -26
  88. package/schemas/booking.surface.schema.json +2593 -0
  89. package/ts/capabilities/agent-reach.ts +4 -4
  90. package/ts/capabilities/anything.ts +89 -38
  91. package/ts/capabilities/flyai.ts +21 -3
  92. package/ts/capabilities/hbcli.ts +53 -4
  93. package/ts/capabilities/session/action-cache.ts +1 -1
  94. package/ts/capabilities/session/adapters/ctrip-hotel.ts +238 -0
  95. package/ts/capabilities/session/adapters/rail-12306.ts +293 -0
  96. package/ts/capabilities/session/extension-bridge.ts +32 -2
  97. package/ts/capabilities/session/extension-channel.ts +9 -8
  98. package/ts/capabilities/session/extension-distribution.ts +3 -1
  99. package/ts/capabilities/session/health-watch.ts +1 -1
  100. package/ts/capabilities/session/read-guard.ts +1 -1
  101. package/ts/capabilities/session/wizard.ts +1 -1
  102. package/ts/capabilities/session-search.ts +323 -1
  103. package/ts/dsh-runtime/vendor/README.md +60 -0
  104. package/ts/dsh-runtime/vendor/dsh-map-tools/LICENSE +21 -0
  105. package/ts/dsh-runtime/vendor/dsh-map-tools/README.en.md +200 -0
  106. package/ts/dsh-runtime/vendor/dsh-map-tools/README.md +202 -0
  107. package/ts/dsh-runtime/vendor/dsh-map-tools/client/client.js +216 -0
  108. package/ts/dsh-runtime/vendor/dsh-map-tools/cordis.patch.yml +5 -0
  109. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/amap.js +371 -0
  110. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/nominatim.js +63 -0
  111. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/osrm.js +56 -0
  112. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/photon.js +55 -0
  113. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config-file.js +87 -0
  114. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config-route.js +126 -0
  115. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config.js +16 -0
  116. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/index.js +109 -0
  117. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/settings-ns.js +27 -0
  118. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/geocode.js +127 -0
  119. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/poi.js +84 -0
  120. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/routes.js +170 -0
  121. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/amap.d.ts +53 -0
  122. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/nominatim.d.ts +17 -0
  123. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/osrm.d.ts +15 -0
  124. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/photon.d.ts +22 -0
  125. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config-file.d.ts +33 -0
  126. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config-route.d.ts +20 -0
  127. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config.d.ts +23 -0
  128. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/index.d.ts +18 -0
  129. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/settings-ns.d.ts +14 -0
  130. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/geocode.d.ts +11 -0
  131. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/poi.d.ts +9 -0
  132. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/routes.d.ts +16 -0
  133. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/types.d.ts +55 -0
  134. package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types.js +16 -0
  135. package/ts/dsh-runtime/vendor/dsh-map-tools/package.json +91 -0
  136. package/ts/package.json +9 -0
  137. package/ts/scripts/turn-handoff-collect.ts +178 -0
  138. package/ts/src/artifact-gate.ts +82 -2
  139. package/ts/src/benchmark-agent-conformance.ts +54 -15
  140. package/ts/src/benchmark-environment-bridge.ts +234 -46
  141. package/ts/src/bookable-facts.ts +109 -5
  142. package/ts/src/booking-saga.ts +1 -1
  143. package/ts/src/booking-surface/{availability-policy-v2.ts → availability-policy.ts} +124 -125
  144. package/ts/src/booking-surface/canonical-schema.js +8 -22
  145. package/ts/src/booking-surface/contracts.ts +278 -239
  146. package/ts/src/booking-surface/dsh-planner.ts +333 -194
  147. package/ts/src/booking-surface/dsh-plugin.js +3 -3
  148. package/ts/src/booking-surface/index.ts +1 -5
  149. package/ts/src/booking-surface/profile.ts +11 -11
  150. package/ts/src/booking-surface/runtime.ts +1351 -351
  151. package/ts/src/booking-surface/server.ts +282 -175
  152. package/ts/src/booking-surface/startup.ts +36 -48
  153. package/ts/src/booking-surface/validation.ts +194 -442
  154. package/ts/src/contracts.ts +1 -1
  155. package/ts/src/index.ts +492 -172
  156. package/ts/src/loop.ts +1 -1
  157. package/ts/src/state-ledger.ts +1 -1
  158. package/ts/src/turn-deadline.ts +365 -0
  159. package/ts/src/turn-policy.ts +154 -0
  160. package/ts/src/wish-pool.ts +17 -4
  161. package/dist/scripts/agent-planning-budget-e2e.js +0 -227
  162. package/dist/scripts/agent-planning-budget-tests.js +0 -173
  163. package/dist/scripts/booking-copilot-v2-runtime-proof-tests.js +0 -3935
  164. package/dist/scripts/booking-surface-v2-contract-proof-tests.js +0 -1174
  165. package/dist/src/booking-surface/contracts-v2.js +0 -89
  166. package/dist/src/booking-surface/runtime-v2.js +0 -1771
  167. package/dist/src/booking-surface/server-v2.js +0 -334
  168. package/dist/src/booking-surface/validation-v2.js +0 -319
  169. package/dist/src/tool-budget.js +0 -136
  170. package/schemas/booking.surface.v1.schema.json +0 -927
  171. package/schemas/booking.surface.v2.schema.json +0 -61
  172. package/ts/src/booking-surface/contracts-v2.ts +0 -118
  173. package/ts/src/booking-surface/runtime-v2.ts +0 -1466
  174. package/ts/src/booking-surface/server-v2.ts +0 -247
  175. package/ts/src/booking-surface/validation-v2.ts +0 -205
  176. package/ts/src/tool-budget.ts +0 -165
@@ -2,13 +2,33 @@ import { mkdtempSync, rmSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { tmpdir } from 'node:os';
4
4
  import { ensureLedger } from '../src/state-ledger.js';
5
- import { BOOKING_SURFACE_SCHEMA_SHA256, BOOKING_SURFACE_SCHEMA_VERSION } from '../src/booking-surface/contracts.js';
5
+ import { BOOKING_SURFACE_ALLOWED_ACTIONS, BOOKING_SURFACE_SCHEMA_SHA256, BOOKING_SURFACE_SCHEMA_VERSION } from '../src/booking-surface/contracts.js';
6
6
  import { BookingCopilotTaskRuntime } from '../src/booking-surface/runtime.js';
7
7
  import { startBookingCopilotServer } from '../src/booking-surface/server.js';
8
+ import '../src/booking-surface/runtime.js';
8
9
  const API_KEY = 'test-only-cross-repo-key';
9
10
  const stateRoot = mkdtempSync(join(tmpdir(), 'gotry-booking-copilot-crossrepo-'));
10
11
  const ledger = ensureLedger(stateRoot);
11
12
  let sequence = 0;
13
+ const principal = {
14
+ subject: 'fixture-crossrepo-bff',
15
+ scope: 'booking:read'
16
+ };
17
+ const ingressMode = 'bff-ingress-binding';
18
+ const ingressBinding = {
19
+ bind (input) {
20
+ const surface = input.surfaceHint;
21
+ return {
22
+ taskId: `fixture-task-${input.requestKey}`,
23
+ turnId: `fixture-turn-${input.requestKey}`,
24
+ contextRef: `ctx-fixture-${input.requestKey}`,
25
+ surface,
26
+ allowedActions: [
27
+ ...BOOKING_SURFACE_ALLOWED_ACTIONS[surface]
28
+ ]
29
+ };
30
+ }
31
+ };
12
32
  const plannerFactory = (initialTask)=>{
13
33
  let receiptObserved = initialTask.lastReceipt !== undefined;
14
34
  return {
@@ -26,6 +46,23 @@ const plannerFactory = (initialTask)=>{
26
46
  }
27
47
  ];
28
48
  }
49
+ if (turn.kind === 'user.turn' && turn.request.approval) {
50
+ return [
51
+ {
52
+ kind: 'operation',
53
+ action: {
54
+ schemaVersion: BOOKING_SURFACE_SCHEMA_VERSION,
55
+ kind: 'search.run',
56
+ actionId: 'cross-repo-action-2',
57
+ contextRef: task.contextRef,
58
+ expectedRevision: task.revision,
59
+ reason: 'Run the approved relaxed search.',
60
+ factRefs: [],
61
+ input: {}
62
+ }
63
+ }
64
+ ];
65
+ }
29
66
  if (receiptObserved) {
30
67
  return [
31
68
  {
@@ -77,6 +114,9 @@ async function main() {
77
114
  apiKey: API_KEY,
78
115
  runtime,
79
116
  plannerFactory,
117
+ ingressBinding,
118
+ principal,
119
+ ingressMode,
80
120
  host: '127.0.0.1',
81
121
  port: 0
82
122
  });
@@ -3,9 +3,9 @@ import { createServer } from 'node:http';
3
3
  import { mkdtempSync, rmSync } from 'node:fs';
4
4
  import { tmpdir } from 'node:os';
5
5
  import { join } from 'node:path';
6
- import { createDshEmbeddedBookingPlanner, createDshEmbeddedBookingPlannerV2, DSH_EMBEDDED_BOOKING_TOOL_NAMES } from '../src/booking-surface/dsh-planner.js';
6
+ import { createDshEmbeddedBookingPlanner, DSH_EMBEDDED_BOOKING_TOOL_NAMES } from '../src/booking-surface/dsh-planner.js';
7
7
  const action = {
8
- schemaVersion: 'booking.surface.v1',
8
+ schemaVersion: 'booking.surface',
9
9
  kind: 'search.run',
10
10
  actionId: 'action-real-dsh-1',
11
11
  contextRef: 'ctx-real-dsh-1',
@@ -32,6 +32,7 @@ function objectKeys(value) {
32
32
  }
33
33
  const requests = [];
34
34
  let modelCall = 0;
35
+ let continuationServed = false;
35
36
  const modelServer = createServer((req, res)=>{
36
37
  const parts = [];
37
38
  req.on('data', (part)=>parts.push(part));
@@ -42,10 +43,11 @@ const modelServer = createServer((req, res)=>{
42
43
  body
43
44
  });
44
45
  modelCall += 1;
45
- if (modelCall === 1) {
46
+ if (!continuationServed && JSON.stringify(body).includes('action.receipt.continuation')) {
47
+ continuationServed = true;
46
48
  sse(res, [
47
49
  {
48
- id: 'chatcmpl-booking-1',
50
+ id: 'chatcmpl-booking-continuation',
49
51
  object: 'chat.completion.chunk',
50
52
  created: 0,
51
53
  model: 'deepseek-v4-flash',
@@ -57,14 +59,18 @@ const modelServer = createServer((req, res)=>{
57
59
  tool_calls: [
58
60
  {
59
61
  index: 0,
60
- id: 'call-booking-1',
62
+ id: 'call-booking-continuation',
61
63
  type: 'function',
62
64
  function: {
63
65
  name: 'booking_search_hotels',
64
66
  arguments: JSON.stringify({
65
67
  decision: {
66
- kind: 'operation',
67
- action
68
+ kind: 'terminal',
69
+ terminal: {
70
+ status: 'stopped',
71
+ summary: 'receipt continuation handled',
72
+ factRefs: []
73
+ }
68
74
  }
69
75
  })
70
76
  }
@@ -73,20 +79,15 @@ const modelServer = createServer((req, res)=>{
73
79
  },
74
80
  finish_reason: 'tool_calls'
75
81
  }
76
- ],
77
- usage: {
78
- prompt_tokens: 10,
79
- completion_tokens: 5,
80
- total_tokens: 15
81
- }
82
+ ]
82
83
  }
83
84
  ]);
84
85
  return;
85
86
  }
86
- if (modelCall === 3) {
87
+ if (modelCall === 1) {
87
88
  sse(res, [
88
89
  {
89
- id: 'chatcmpl-booking-v2-continuation',
90
+ id: 'chatcmpl-booking-1',
90
91
  object: 'chat.completion.chunk',
91
92
  created: 0,
92
93
  model: 'deepseek-v4-flash',
@@ -98,18 +99,14 @@ const modelServer = createServer((req, res)=>{
98
99
  tool_calls: [
99
100
  {
100
101
  index: 0,
101
- id: 'call-booking-v2-continuation',
102
+ id: 'call-booking-1',
102
103
  type: 'function',
103
104
  function: {
104
105
  name: 'booking_search_hotels',
105
106
  arguments: JSON.stringify({
106
107
  decision: {
107
- kind: 'terminal',
108
- terminal: {
109
- status: 'stopped',
110
- summary: 'v2 continuation handled',
111
- factRefs: []
112
- }
108
+ kind: 'operation',
109
+ action
113
110
  }
114
111
  })
115
112
  }
@@ -118,7 +115,12 @@ const modelServer = createServer((req, res)=>{
118
115
  },
119
116
  finish_reason: 'tool_calls'
120
117
  }
121
- ]
118
+ ],
119
+ usage: {
120
+ prompt_tokens: 10,
121
+ completion_tokens: 5,
122
+ total_tokens: 15
123
+ }
122
124
  }
123
125
  ]);
124
126
  return;
@@ -156,7 +158,7 @@ const address = modelServer.address();
156
158
  assert.ok(typeof address === 'object' && address);
157
159
  const stateRoot = mkdtempSync(join(tmpdir(), 'gotry-booking-dsh-core-'));
158
160
  const workspace = {
159
- schemaVersion: 'booking.surface.v1',
161
+ schemaVersion: 'booking.surface',
160
162
  contextRef: action.contextRef,
161
163
  surface: 'tenant',
162
164
  revision: 0,
@@ -177,24 +179,27 @@ const workspace = {
177
179
  }
178
180
  };
179
181
  const turn = {
180
- schemaVersion: 'booking.surface.v1',
182
+ schemaVersion: 'booking.surface',
181
183
  kind: 'user.turn',
182
184
  taskId: 'task-real-dsh-1',
183
- workspace: {
184
- ...workspace,
185
- capabilities: {
186
- ...workspace.capabilities,
187
- allowedActions: [
188
- ...workspace.capabilities.allowedActions
189
- ]
190
- }
191
- },
185
+ turnId: 'real-dsh-turn-1',
186
+ workspace,
192
187
  request: {
193
188
  text: '执行当前酒店搜索'
194
189
  }
195
190
  };
191
+ const availability = {
192
+ initialized: true,
193
+ recoveryStarted: false,
194
+ availabilityPhase: 'need_offers',
195
+ activeHotelOrdinal: 0,
196
+ hotelRefs: [],
197
+ hotels: {},
198
+ attempts: [],
199
+ queryReservations: []
200
+ };
196
201
  const task = {
197
- schemaVersion: 'booking.surface.v1',
202
+ schemaVersion: 'booking.surface',
198
203
  taskId: 'task-real-dsh-1',
199
204
  contextRef: action.contextRef,
200
205
  surface: 'tenant',
@@ -203,9 +208,12 @@ const task = {
203
208
  'search.run'
204
209
  ],
205
210
  userTurnCount: 1,
206
- lastUserTurnDigest: 'digest-only',
211
+ lastTurnId: 'real-dsh-turn-1',
212
+ operationCount: 0,
207
213
  phase: 'planning',
208
- lastSequence: 0
214
+ lastSequence: 0,
215
+ availability,
216
+ workspaceSnapshot: workspace
209
217
  };
210
218
  let planner;
211
219
  try {
@@ -220,7 +228,8 @@ try {
220
228
  },
221
229
  maxTokens: 512
222
230
  });
223
- const decisions = await planner.plannerFactory(task).next({
231
+ const session = planner.plannerFactory(task);
232
+ const decisions = await session.next({
224
233
  turn,
225
234
  task
226
235
  });
@@ -234,68 +243,27 @@ try {
234
243
  const toolNames = requests[0].body.tools.map((tool)=>tool.function.name).sort();
235
244
  assert.deepEqual(toolNames, [
236
245
  ...DSH_EMBEDDED_BOOKING_TOOL_NAMES
237
- ].sort(), 'real model request exposes exactly the seven embedded tools');
246
+ ].sort(), 'real model request exposes exactly the six embedded tools');
238
247
  assert.ok(!toolNames.some((name)=>/gotry_book|payment|holder|guest/i.test(name)), 'real model request exposes no booking write or PII tool');
239
248
  const executableKeys = requests[0].body.tools.flatMap((tool)=>objectKeys(tool.function.parameters));
240
249
  assert.ok(!executableKeys.some((key)=>/^(book|payment|holder|guest|portalToken|supplierCost)$/i.test(key)), 'tool inputs expose no write or PII field');
241
250
  assert.equal(requests[0].headers.authorization, 'Bearer fixture-model-key');
242
251
  assert.ok(!JSON.stringify(requests).includes('must-not-enter-dsh'), 'BFF and portal credentials never enter the dsh model transport');
243
- const v2Workspace = {
244
- schemaVersion: 'booking.surface.v2',
245
- contextRef: 'ctx-real-dsh-v2',
246
- surface: 'tenant',
247
- revision: 1,
248
- locale: 'en-US',
249
- currency: 'AED',
250
- searchDraft: {},
251
- results: {
252
- status: 'idle'
253
- },
254
- visibleHotels: [],
255
- loadedOffers: [],
256
- shortlistedOfferRefs: [],
257
- capabilities: {
258
- surface: 'tenant',
259
- allowedActions: [
260
- 'search.run'
261
- ]
262
- }
263
- };
264
- const v2Task = {
265
- schemaVersion: 'booking.surface.v2',
266
- taskId: 'task-real-dsh-v2',
267
- contextRef: v2Workspace.contextRef,
268
- surface: 'tenant',
269
- revision: 1,
270
- allowedActions: [
271
- 'search.run'
272
- ],
273
- userTurnCount: 1,
274
- operationCount: 1,
275
- phase: 'planning',
276
- lastSequence: 1,
277
- availability: {
278
- initialized: true,
279
- recoveryStarted: false,
280
- availabilityPhase: 'need_offers',
281
- activeHotelOrdinal: 0,
282
- hotelRefs: [],
283
- hotels: {},
284
- attempts: [],
285
- queryReservations: []
286
- },
287
- workspaceSnapshot: v2Workspace
288
- };
289
- const v2Continuation = {
290
- schemaVersion: 'booking.surface.v2',
252
+ const proseDecisions = await session.next({
253
+ turn,
254
+ task
255
+ });
256
+ assert.equal(proseDecisions[0]?.kind, 'error', 'assistant prose without a tool call never becomes a decision');
257
+ const continuation = {
258
+ schemaVersion: 'booking.surface',
291
259
  kind: 'action.receipt.continuation',
292
- taskId: v2Task.taskId,
293
- workspace: v2Workspace,
260
+ taskId: task.taskId,
261
+ workspace,
294
262
  receipt: {
295
- schemaVersion: 'booking.surface.v2',
263
+ schemaVersion: 'booking.surface',
296
264
  kind: 'action.receipt',
297
- actionId: 'action-real-dsh-v2',
298
- contextRef: v2Workspace.contextRef,
265
+ actionId: action.actionId,
266
+ contextRef: workspace.contextRef,
299
267
  status: 'applied',
300
268
  revision: 1,
301
269
  observation: {
@@ -312,36 +280,23 @@ try {
312
280
  }
313
281
  }
314
282
  };
315
- const v2Planner = await createDshEmbeddedBookingPlannerV2({
316
- stateRoot,
317
- env: {
318
- PATH: process.env.PATH,
319
- DEEPSEEK_API_KEY: 'fixture-model-key',
320
- DEEPSEEK_BASE_URL: `http://127.0.0.1:${address.port}/v1`
321
- },
322
- maxTokens: 512
283
+ const continuationDecisions = await session.next({
284
+ turn: continuation,
285
+ task: {
286
+ ...task,
287
+ lastReceipt: continuation.kind === 'action.receipt.continuation' ? continuation.receipt : undefined
288
+ }
323
289
  });
324
- try {
325
- const continuationDecisions = await v2Planner.plannerFactory(v2Task).next({
326
- turn: v2Continuation,
327
- task: {
328
- ...v2Task,
329
- lastReceipt: v2Continuation.receipt
330
- }
331
- });
332
- assert.deepEqual(continuationDecisions, [
333
- {
334
- kind: 'terminal',
335
- terminal: {
336
- status: 'stopped',
337
- summary: 'v2 continuation handled',
338
- factRefs: []
339
- }
290
+ assert.deepEqual(continuationDecisions, [
291
+ {
292
+ kind: 'terminal',
293
+ terminal: {
294
+ status: 'stopped',
295
+ summary: 'receipt continuation handled',
296
+ factRefs: []
340
297
  }
341
- ], 'real dsh v2 accepts action.receipt.continuation through the typed planner seam');
342
- } finally{
343
- await v2Planner.close();
344
- }
298
+ }
299
+ ], 'real dsh accepts action.receipt.continuation through the typed planner seam');
345
300
  } finally{
346
301
  await planner?.close();
347
302
  await new Promise((resolve, reject)=>modelServer.close((error)=>error ? reject(error) : resolve()));