@danceiny/gotry 0.0.1-rc.18 → 0.0.1-rc.19
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 +236 -3
- package/bin/gotry-inner.js +66 -20
- package/bin/gotry-runtime-resolution.d.ts +1 -1
- package/bin/gotry-runtime-resolution.js +7 -8
- package/cordis.gotry-patch.yml +15 -5
- package/data/stations-12306-verify.json +524 -0
- package/dist/capabilities/agent-reach.js +4 -4
- package/dist/capabilities/channel-health.js +103 -0
- package/dist/capabilities/channel-registry.js +213 -0
- package/dist/capabilities/doctor.js +285 -0
- package/dist/capabilities/effect.js +178 -5
- package/dist/capabilities/flyai.js +13 -0
- 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 +304 -0
- package/dist/scripts/agent-planning-turn-deadline-tests.js +281 -0
- package/dist/scripts/benchmark-environment-bridge-e2e.js +5 -10
- package/dist/scripts/benchmark-environment-bridge-tests.js +148 -142
- 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 +87 -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 +121 -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/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 +7 -4
- package/dist/src/benchmark-environment-bridge.js +68 -7
- 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 +735 -149
- 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 +6 -26
- package/schemas/booking.surface.schema.json +2593 -0
- package/ts/capabilities/agent-reach.ts +4 -4
- package/ts/capabilities/flyai.ts +21 -3
- 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/package.json +1 -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 +14 -6
- package/ts/src/benchmark-environment-bridge.ts +29 -10
- 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 +489 -171
- package/ts/src/loop.ts +1 -1
- package/ts/src/state-ledger.ts +1 -1
- package/ts/src/turn-deadline.ts +361 -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
package/dist/src/tool-budget.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { randomUUID } from 'node:crypto';
|
|
2
|
-
export const TOOL_BUDGET_SOFT_CALL = 16;
|
|
3
|
-
export const TOOL_BUDGET_HARD_CALL = 18;
|
|
4
|
-
export const TOOL_BUDGET_EXHAUSTED = 'TOOL_BUDGET_EXHAUSTED';
|
|
5
|
-
export function toolBudgetDecision(callNumber) {
|
|
6
|
-
if (callNumber > TOOL_BUDGET_HARD_CALL) {
|
|
7
|
-
return {
|
|
8
|
-
kind: 'deny',
|
|
9
|
-
reason: `${TOOL_BUDGET_EXHAUSTED}: maximum ${TOOL_BUDGET_HARD_CALL} real tool dispatches per agent turn reached; provide a final answer using existing results`
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
return {
|
|
13
|
-
kind: 'allow',
|
|
14
|
-
softSignal: callNumber === TOOL_BUDGET_SOFT_CALL,
|
|
15
|
-
exhaustsBudget: callNumber === TOOL_BUDGET_HARD_CALL
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
export function createToolBudgetState() {
|
|
19
|
-
let calls = 0;
|
|
20
|
-
return {
|
|
21
|
-
nextCall () {
|
|
22
|
-
calls += 1;
|
|
23
|
-
return {
|
|
24
|
-
...toolBudgetDecision(calls),
|
|
25
|
-
callNumber: calls
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
function convergenceContext(code, text) {
|
|
31
|
-
return {
|
|
32
|
-
id: randomUUID(),
|
|
33
|
-
role: 'user',
|
|
34
|
-
content: [
|
|
35
|
-
{
|
|
36
|
-
type: 'text',
|
|
37
|
-
text: `${code}: ${text}`
|
|
38
|
-
}
|
|
39
|
-
],
|
|
40
|
-
source: {
|
|
41
|
-
kind: 'plugin',
|
|
42
|
-
plugin: 'gotry-tool-budget'
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
function exhaustionResult(reason) {
|
|
47
|
-
return {
|
|
48
|
-
isError: true,
|
|
49
|
-
error: {
|
|
50
|
-
message: reason,
|
|
51
|
-
info: {
|
|
52
|
-
name: 'ToolBudgetError',
|
|
53
|
-
code: TOOL_BUDGET_EXHAUSTED
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
content: [
|
|
57
|
-
{
|
|
58
|
-
type: 'text',
|
|
59
|
-
text: reason
|
|
60
|
-
}
|
|
61
|
-
],
|
|
62
|
-
additionalContexts: [
|
|
63
|
-
convergenceContext(TOOL_BUDGET_EXHAUSTED, 'No more tool dispatches are permitted in this turn. Produce the final answer from existing results.')
|
|
64
|
-
]
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
export function installToolBudget(ctx) {
|
|
68
|
-
if (typeof ctx.on !== 'function') return;
|
|
69
|
-
const budgetByAgent = new Map();
|
|
70
|
-
const softExecutions = new Map();
|
|
71
|
-
const pendingFinalOnly = new Map();
|
|
72
|
-
const finalOnlyDisposers = new Map();
|
|
73
|
-
const clearAgent = (agentId)=>{
|
|
74
|
-
budgetByAgent.delete(agentId);
|
|
75
|
-
for (const [token, owner] of softExecutions){
|
|
76
|
-
if (owner === agentId) softExecutions.delete(token);
|
|
77
|
-
}
|
|
78
|
-
pendingFinalOnly.delete(agentId);
|
|
79
|
-
finalOnlyDisposers.get(agentId)?.();
|
|
80
|
-
finalOnlyDisposers.delete(agentId);
|
|
81
|
-
};
|
|
82
|
-
const enterFinalOnly = (agent)=>{
|
|
83
|
-
const agentId = String(agent.id);
|
|
84
|
-
if (finalOnlyDisposers.has(agentId)) return;
|
|
85
|
-
const globalTools = ctx.tools;
|
|
86
|
-
const scopedTools = agent.ctx?.tools;
|
|
87
|
-
if (typeof globalTools.schemas !== 'function' || typeof scopedTools?.restrict !== 'function') return;
|
|
88
|
-
const inheritedNames = globalTools.schemas().map((schema)=>schema.name).filter((name)=>name !== 'run_code');
|
|
89
|
-
if (inheritedNames.length === 0) return;
|
|
90
|
-
finalOnlyDisposers.set(agentId, scopedTools.restrict({
|
|
91
|
-
deny: inheritedNames
|
|
92
|
-
}));
|
|
93
|
-
};
|
|
94
|
-
ctx.on('session/event', (subject, event)=>{
|
|
95
|
-
const agentId = String(subject.id);
|
|
96
|
-
if (event.type === 'turn/start' || event.type === 'turn/end') {
|
|
97
|
-
clearAgent(agentId);
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
if (event.type === 'step/end') {
|
|
101
|
-
const agent = pendingFinalOnly.get(agentId);
|
|
102
|
-
if (agent) {
|
|
103
|
-
pendingFinalOnly.delete(agentId);
|
|
104
|
-
enterFinalOnly(agent);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
ctx.on('session/disposed', (subject)=>clearAgent(String(subject.id)));
|
|
109
|
-
ctx.on('tools/execute', (exec, next)=>{
|
|
110
|
-
if (!exec.agent) return next();
|
|
111
|
-
const agentId = String(exec.agent.id);
|
|
112
|
-
const state = budgetByAgent.get(agentId) ?? createToolBudgetState();
|
|
113
|
-
budgetByAgent.set(agentId, state);
|
|
114
|
-
const decision = state.nextCall();
|
|
115
|
-
if (decision.kind === 'deny') {
|
|
116
|
-
pendingFinalOnly.set(agentId, exec.agent);
|
|
117
|
-
return Promise.resolve(exhaustionResult(decision.reason));
|
|
118
|
-
}
|
|
119
|
-
if (decision.softSignal) softExecutions.set(exec.token, agentId);
|
|
120
|
-
if (decision.exhaustsBudget) pendingFinalOnly.set(agentId, exec.agent);
|
|
121
|
-
return next();
|
|
122
|
-
});
|
|
123
|
-
ctx.on('tools/post-execute', (exec, _result, next)=>{
|
|
124
|
-
if (!softExecutions.delete(exec.token)) return next();
|
|
125
|
-
return next().then((decision)=>({
|
|
126
|
-
...decision,
|
|
127
|
-
additionalContexts: [
|
|
128
|
-
...decision.additionalContexts ?? [],
|
|
129
|
-
convergenceContext('TOOL_BUDGET_SOFT', 'Tool call 16 reached. Converge now and produce the final answer from gathered evidence.')
|
|
130
|
-
]
|
|
131
|
-
}));
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
//# sourceURL=ts/src/tool-budget.ts
|