@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.
- package/README.md +42 -16
- package/README.zh-CN.md +37 -15
- package/bin/gotry-bootstrap.js +309 -30
- package/bin/gotry-inner.js +74 -23
- package/bin/gotry-runtime-resolution.d.ts +1 -1
- package/bin/gotry-runtime-resolution.js +7 -8
- package/cordis.gotry-patch.yml +22 -8
- package/data/stations-12306-verify.json +524 -0
- package/dist/capabilities/agent-reach.js +4 -4
- package/dist/capabilities/anything.js +62 -29
- package/dist/capabilities/channel-health.js +103 -0
- package/dist/capabilities/channel-registry.js +213 -0
- package/dist/capabilities/doctor.js +307 -0
- package/dist/capabilities/effect.js +178 -5
- package/dist/capabilities/flyai.js +13 -0
- package/dist/capabilities/hbcli.js +28 -2
- package/dist/capabilities/session/adapters/ctrip-hotel.js +207 -0
- package/dist/capabilities/session/adapters/rail-12306.js +285 -0
- package/dist/capabilities/session/extension-bridge.js +14 -1
- package/dist/capabilities/session/extension-channel.js +4 -2
- package/dist/capabilities/session/extension-distribution.js +1 -1
- package/dist/capabilities/session-search.js +311 -0
- package/dist/capabilities/visa-policy.js +126 -0
- package/dist/scripts/agent-planning-turn-deadline-e2e.js +305 -0
- package/dist/scripts/agent-planning-turn-deadline-tests.js +281 -0
- package/dist/scripts/anything-tests.js +70 -21
- package/dist/scripts/benchmark-environment-bridge-e2e.js +139 -37
- package/dist/scripts/benchmark-environment-bridge-tests.js +1099 -306
- package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +26 -26
- package/dist/scripts/{booking-copilot-availability-policy-v2-tests.js → booking-copilot-availability-policy-tests.js} +115 -115
- package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +41 -1
- package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +75 -120
- package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +370 -61
- package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +2 -2
- package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +7 -3
- package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +15 -9
- package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +19 -11
- package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +16 -52
- package/dist/scripts/booking-copilot-runtime-proof-tests.js +3953 -155
- package/dist/scripts/booking-copilot-server-proof-tests.js +58 -23
- package/dist/scripts/booking-copilot-startup-proof-tests.js +10 -119
- package/dist/scripts/booking-surface-contract-proof-tests.js +1154 -326
- package/dist/scripts/bootstrap-tests.js +113 -2
- package/dist/scripts/build-metrics-report.js +339 -0
- package/dist/scripts/channel-probe-tests.js +148 -0
- package/dist/scripts/channel-probe.js +252 -0
- package/dist/scripts/channel-registry-tests.js +262 -0
- package/dist/scripts/doctor-tests.js +175 -0
- package/dist/scripts/effect-tests.js +274 -1
- package/dist/scripts/extension-tests.js +129 -11
- package/dist/scripts/fact-gate-tests.js +91 -2
- package/dist/scripts/flyai-tests.js +17 -1
- package/dist/scripts/hbcli-e2e-tests.js +1 -3
- package/dist/scripts/hbcli-tests.js +38 -1
- package/dist/scripts/metrics-report-tests.js +288 -0
- package/dist/scripts/persona-surface-guard-tests.js +19 -0
- package/dist/scripts/session-tests.js +401 -1
- package/dist/scripts/smoke.js +100 -83
- package/dist/scripts/turn-handoff-collect-tests.js +216 -0
- package/dist/scripts/turn-handoff-collect.js +189 -0
- package/dist/scripts/turn-policy-tests.js +56 -0
- package/dist/scripts/typed-contract-canary.js +261 -0
- package/dist/scripts/visa-policy-tests.js +75 -0
- package/dist/scripts/wish-channel-gate-tests.js +111 -0
- package/dist/src/artifact-gate.js +91 -3
- package/dist/src/benchmark-agent-conformance.js +39 -16
- package/dist/src/benchmark-environment-bridge.js +316 -52
- package/dist/src/bookable-facts.js +62 -3
- package/dist/src/booking-surface/{availability-policy-v2.js → availability-policy.js} +89 -89
- package/dist/src/booking-surface/canonical-schema.js +8 -22
- package/dist/src/booking-surface/contracts.js +70 -19
- package/dist/src/booking-surface/dsh-planner.js +310 -177
- package/dist/src/booking-surface/dsh-plugin.js +3 -3
- package/dist/src/booking-surface/index.js +1 -5
- package/dist/src/booking-surface/profile.js +1 -1
- package/dist/src/booking-surface/runtime.js +1682 -247
- package/dist/src/booking-surface/server.js +371 -185
- package/dist/src/booking-surface/startup.js +17 -27
- package/dist/src/booking-surface/validation.js +270 -760
- package/dist/src/index.js +739 -150
- package/dist/src/turn-deadline.js +292 -0
- package/dist/src/turn-policy.js +146 -0
- package/dist/src/wish-pool.js +5 -0
- package/extension/background.js +23 -4
- package/extension/content-main.js +47 -9
- package/extension/manifest.json +27 -9
- package/package.json +7 -26
- package/schemas/booking.surface.schema.json +2593 -0
- package/ts/capabilities/agent-reach.ts +4 -4
- package/ts/capabilities/anything.ts +89 -38
- package/ts/capabilities/flyai.ts +21 -3
- package/ts/capabilities/hbcli.ts +53 -4
- package/ts/capabilities/session/action-cache.ts +1 -1
- package/ts/capabilities/session/adapters/ctrip-hotel.ts +238 -0
- package/ts/capabilities/session/adapters/rail-12306.ts +293 -0
- package/ts/capabilities/session/extension-bridge.ts +32 -2
- package/ts/capabilities/session/extension-channel.ts +9 -8
- package/ts/capabilities/session/extension-distribution.ts +3 -1
- package/ts/capabilities/session/health-watch.ts +1 -1
- package/ts/capabilities/session/read-guard.ts +1 -1
- package/ts/capabilities/session/wizard.ts +1 -1
- package/ts/capabilities/session-search.ts +323 -1
- package/ts/dsh-runtime/vendor/README.md +60 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/LICENSE +21 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.en.md +200 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/README.md +202 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/client/client.js +216 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/cordis.patch.yml +5 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/amap.js +371 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/nominatim.js +63 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/osrm.js +56 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/clients/photon.js +55 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config-file.js +87 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config-route.js +126 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/config.js +16 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/index.js +109 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/settings-ns.js +27 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/geocode.js +127 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/poi.js +84 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/tools/routes.js +170 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/amap.d.ts +53 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/nominatim.d.ts +17 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/osrm.d.ts +15 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/clients/photon.d.ts +22 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config-file.d.ts +33 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config-route.d.ts +20 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/config.d.ts +23 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/index.d.ts +18 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/settings-ns.d.ts +14 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/geocode.d.ts +11 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/poi.d.ts +9 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/tools/routes.d.ts +16 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types/types.d.ts +55 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/lib/types.js +16 -0
- package/ts/dsh-runtime/vendor/dsh-map-tools/package.json +91 -0
- package/ts/package.json +9 -0
- package/ts/scripts/turn-handoff-collect.ts +178 -0
- package/ts/src/artifact-gate.ts +82 -2
- package/ts/src/benchmark-agent-conformance.ts +54 -15
- package/ts/src/benchmark-environment-bridge.ts +234 -46
- package/ts/src/bookable-facts.ts +109 -5
- package/ts/src/booking-saga.ts +1 -1
- package/ts/src/booking-surface/{availability-policy-v2.ts → availability-policy.ts} +124 -125
- package/ts/src/booking-surface/canonical-schema.js +8 -22
- package/ts/src/booking-surface/contracts.ts +278 -239
- package/ts/src/booking-surface/dsh-planner.ts +333 -194
- package/ts/src/booking-surface/dsh-plugin.js +3 -3
- package/ts/src/booking-surface/index.ts +1 -5
- package/ts/src/booking-surface/profile.ts +11 -11
- package/ts/src/booking-surface/runtime.ts +1351 -351
- package/ts/src/booking-surface/server.ts +282 -175
- package/ts/src/booking-surface/startup.ts +36 -48
- package/ts/src/booking-surface/validation.ts +194 -442
- package/ts/src/contracts.ts +1 -1
- package/ts/src/index.ts +492 -172
- package/ts/src/loop.ts +1 -1
- package/ts/src/state-ledger.ts +1 -1
- package/ts/src/turn-deadline.ts +365 -0
- package/ts/src/turn-policy.ts +154 -0
- package/ts/src/wish-pool.ts +17 -4
- package/dist/scripts/agent-planning-budget-e2e.js +0 -227
- package/dist/scripts/agent-planning-budget-tests.js +0 -173
- package/dist/scripts/booking-copilot-v2-runtime-proof-tests.js +0 -3935
- package/dist/scripts/booking-surface-v2-contract-proof-tests.js +0 -1174
- package/dist/src/booking-surface/contracts-v2.js +0 -89
- package/dist/src/booking-surface/runtime-v2.js +0 -1771
- package/dist/src/booking-surface/server-v2.js +0 -334
- package/dist/src/booking-surface/validation-v2.js +0 -319
- package/dist/src/tool-budget.js +0 -136
- package/schemas/booking.surface.v1.schema.json +0 -927
- package/schemas/booking.surface.v2.schema.json +0 -61
- package/ts/src/booking-surface/contracts-v2.ts +0 -118
- package/ts/src/booking-surface/runtime-v2.ts +0 -1466
- package/ts/src/booking-surface/server-v2.ts +0 -247
- package/ts/src/booking-surface/validation-v2.ts +0 -205
- 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,
|
|
6
|
+
import { createDshEmbeddedBookingPlanner, DSH_EMBEDDED_BOOKING_TOOL_NAMES } from '../src/booking-surface/dsh-planner.js';
|
|
7
7
|
const action = {
|
|
8
|
-
schemaVersion: 'booking.surface
|
|
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 (
|
|
46
|
+
if (!continuationServed && JSON.stringify(body).includes('action.receipt.continuation')) {
|
|
47
|
+
continuationServed = true;
|
|
46
48
|
sse(res, [
|
|
47
49
|
{
|
|
48
|
-
id: 'chatcmpl-booking-
|
|
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-
|
|
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: '
|
|
67
|
-
|
|
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 ===
|
|
87
|
+
if (modelCall === 1) {
|
|
87
88
|
sse(res, [
|
|
88
89
|
{
|
|
89
|
-
id: 'chatcmpl-booking-
|
|
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-
|
|
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: '
|
|
108
|
-
|
|
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
|
|
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
|
|
182
|
+
schemaVersion: 'booking.surface',
|
|
181
183
|
kind: 'user.turn',
|
|
182
184
|
taskId: 'task-real-dsh-1',
|
|
183
|
-
|
|
184
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
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:
|
|
293
|
-
workspace
|
|
260
|
+
taskId: task.taskId,
|
|
261
|
+
workspace,
|
|
294
262
|
receipt: {
|
|
295
|
-
schemaVersion: 'booking.surface
|
|
263
|
+
schemaVersion: 'booking.surface',
|
|
296
264
|
kind: 'action.receipt',
|
|
297
|
-
actionId:
|
|
298
|
-
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
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
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
|
-
|
|
342
|
-
|
|
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()));
|