@danceiny/gotry 0.0.1-rc.16 → 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.
- package/README.md +47 -13
- package/README.zh-CN.md +20 -10
- package/bin/gotry-booking-copilot.js +53 -0
- package/bin/gotry-bootstrap.js +111 -51
- package/bin/gotry-inner.js +442 -60
- package/bin/gotry-runtime-resolution.d.ts +27 -0
- package/bin/gotry-runtime-resolution.js +50 -0
- package/bin/gotry.js +1 -1
- package/cordis.gotry-patch.yml +5 -1
- package/dist/capabilities/agent-reach-deep.js +1 -1
- package/dist/capabilities/agent-reach.js +1 -1
- package/dist/capabilities/anything.js +1 -1
- package/dist/capabilities/artifacts.js +1 -1
- package/dist/capabilities/effect.js +1 -1
- package/dist/capabilities/fact-log.js +1 -1
- package/dist/capabilities/flyai.js +20 -6
- package/dist/capabilities/hbcli.js +1 -1
- package/dist/capabilities/incident-log.js +1 -1
- package/dist/capabilities/model-override.js +18 -0
- package/dist/capabilities/opensky.js +1 -1
- package/dist/capabilities/resilience.js +1 -1
- package/dist/capabilities/session/action-cache.js +1 -1
- package/dist/capabilities/session/adapters/ctrip-flight.js +1 -1
- package/dist/capabilities/session/adapters/meituan-local.js +1 -1
- package/dist/capabilities/session/benchmark.js +1 -1
- package/dist/capabilities/session/extension-bridge.js +19 -6
- package/dist/capabilities/session/extension-channel.js +3 -3
- package/dist/capabilities/session/extension-distribution.js +234 -0
- package/dist/capabilities/session/extract.js +1 -1
- package/dist/capabilities/session/golden-score.js +92 -0
- package/dist/capabilities/session/health-watch.js +1 -1
- package/dist/capabilities/session/read-guard.js +1 -1
- package/dist/capabilities/session/static-flight-golden.js +137 -0
- package/dist/capabilities/session/transport.js +1 -1
- package/dist/capabilities/session/wizard.js +21 -251
- package/dist/capabilities/session-consent.js +1 -1
- package/dist/capabilities/session-login.js +11 -5
- package/dist/capabilities/session-search.js +46 -4
- package/dist/capabilities/weather.js +168 -46
- package/dist/data/session-golden-20.json +25 -0
- package/dist/data/sf-golden-manifest.json +102 -0
- package/dist/data/sf-static-routes.json +91 -0
- package/dist/scripts/action-cache-tests.js +1 -1
- package/dist/scripts/agent-planning-budget-e2e.js +227 -0
- package/dist/scripts/agent-planning-budget-tests.js +173 -0
- package/dist/scripts/agent-reach-deep-tests.js +1 -1
- package/dist/scripts/agent-reach-tests.js +1 -1
- package/dist/scripts/agent-reach-wrapper-tests.js +1 -1
- package/dist/scripts/anything-tests.js +1 -1
- package/dist/scripts/async-collect.js +1 -1
- package/dist/scripts/benchmark-environment-bridge-e2e.js +981 -0
- package/dist/scripts/benchmark-environment-bridge-tests.js +2544 -0
- package/dist/scripts/booking-copilot-availability-ledger-binding-tests.js +335 -0
- package/dist/scripts/booking-copilot-availability-policy-v2-tests.js +1355 -0
- package/dist/scripts/booking-copilot-bin-proof-tests.js +89 -0
- package/dist/scripts/booking-copilot-crossrepo-fixture-server.js +113 -0
- package/dist/scripts/booking-copilot-dsh-core-proof-tests.js +356 -0
- package/dist/scripts/booking-copilot-dsh-planner-proof-tests.js +557 -0
- package/dist/scripts/booking-copilot-dsh-plugin-proof-tests.js +140 -0
- package/dist/scripts/booking-copilot-event-sequence-concurrency-proof-tests.js +202 -0
- package/dist/scripts/booking-copilot-gap-code-contract-proof-tests.js +102 -0
- package/dist/scripts/booking-copilot-operation-ledger-concurrency-proof-tests.js +374 -0
- package/dist/scripts/booking-copilot-receipt-ledger-concurrency-proof-tests.js +447 -0
- package/dist/scripts/booking-copilot-runtime-proof-tests.js +205 -0
- package/dist/scripts/booking-copilot-server-proof-tests.js +317 -0
- package/dist/scripts/booking-copilot-startup-proof-tests.js +283 -0
- package/dist/scripts/booking-copilot-v2-runtime-proof-tests.js +3935 -0
- package/dist/scripts/booking-saga-tests.js +1 -1
- package/dist/scripts/booking-surface-contract-proof-tests.js +393 -0
- package/dist/scripts/booking-surface-v2-contract-proof-tests.js +1174 -0
- package/dist/scripts/bootstrap-tests.js +30 -10
- package/dist/scripts/build-changelog.js +1 -1
- package/dist/scripts/changelog-tests.js +1 -1
- package/dist/scripts/companion-tests.js +1 -1
- package/dist/scripts/diff-test.js +1 -1
- package/dist/scripts/dsh-runtime-closure-tests.js +225 -0
- package/dist/scripts/dsh-runtime-closure.js +150 -0
- package/dist/scripts/effect-tests.js +1 -1
- package/dist/scripts/engine-run.js +1 -1
- package/dist/scripts/engine-tests.js +1 -1
- package/dist/scripts/evaluation-cadence-tests.js +347 -0
- package/dist/scripts/evaluation-contract-tests.js +574 -0
- package/dist/scripts/extension-distribution-cli.js +35 -0
- package/dist/scripts/extension-distribution-tests.js +341 -0
- package/dist/scripts/extension-tests.js +128 -23
- package/dist/scripts/fact-gate-tests.js +1 -1
- package/dist/scripts/flyai-tests.js +1 -1
- package/dist/scripts/hbcli-e2e-tests.js +1 -1
- package/dist/scripts/hbcli-tests.js +1 -1
- package/dist/scripts/health-watch-cli.js +1 -1
- package/dist/scripts/i18n-tests.js +1 -1
- package/dist/scripts/incident-tests.js +1 -1
- package/dist/scripts/journey-tests.js +1 -1
- package/dist/scripts/ledger-tests.js +1 -1
- package/dist/scripts/ledger-workflow-crash.js +1 -1
- package/dist/scripts/memory-capture-tests.js +1 -1
- package/dist/scripts/memory-decay-tests.js +1 -1
- package/dist/scripts/memory-metrics.js +1 -1
- package/dist/scripts/memory-value-report.js +1 -1
- package/dist/scripts/model-override-e2e.js +176 -0
- package/dist/scripts/nightly-evidence-tests.js +1 -1
- package/dist/scripts/nightly-evidence.js +1 -1
- package/dist/scripts/nudge-digest.js +1 -1
- package/dist/scripts/onboarding-tests.js +21 -53
- package/dist/scripts/opensky-check.js +1 -1
- package/dist/scripts/opensky-tests.js +1 -1
- package/dist/scripts/pnpm-dsh-closure-proof.js +20 -0
- package/dist/scripts/price-drift-tests.js +1 -1
- package/dist/scripts/price-drift-watch.js +1 -1
- package/dist/scripts/probe-poi-tests.js +1 -1
- package/dist/scripts/product-metrics.js +1 -1
- package/dist/scripts/publish-preverify.js +40 -4
- package/dist/scripts/realtime-pricing-tests.js +1 -1
- package/dist/scripts/replay-async.js +1 -1
- package/dist/scripts/replay-real.js +1 -1
- package/dist/scripts/replay.js +1 -1
- package/dist/scripts/session-attach-diagnose.js +1 -1
- package/dist/scripts/session-attach-poc.js +1 -1
- package/dist/scripts/session-benchmark.js +1 -1
- package/dist/scripts/session-extract-tests.js +1 -1
- package/dist/scripts/session-login.js +1 -1
- package/dist/scripts/session-tests.js +70 -20
- package/dist/scripts/sf-live-benchmark.js +338 -0
- package/dist/scripts/sf-live-cli-tests.js +21 -0
- package/dist/scripts/sf-soft-score-tests.js +108 -0
- package/dist/scripts/sf-summary.js +93 -0
- package/dist/scripts/skeleton-check.js +1 -1
- package/dist/scripts/skeleton-integration-test.js +1 -1
- package/dist/scripts/skills-contract-tests.js +1 -1
- package/dist/scripts/smoke-session-gate-tests.js +29 -0
- package/dist/scripts/smoke.js +79 -33
- package/dist/scripts/state-cli-tests.js +1 -1
- package/dist/scripts/state-cli.js +1 -1
- package/dist/scripts/static-golden-tests.js +299 -0
- package/dist/scripts/time-eval-tests.js +1 -1
- package/dist/scripts/travel-timeline-tests.js +1 -1
- package/dist/scripts/unified-tests.js +1 -1
- package/dist/scripts/weather-tests.js +694 -44
- package/dist/scripts/z3-race-tests.js +1 -1
- package/dist/src/artifact-gate.js +1 -1
- package/dist/src/benchmark-agent-conformance.js +370 -0
- package/dist/src/benchmark-environment-bridge.js +384 -0
- package/dist/src/benchmark-headless-child-diagnostics.js +173 -0
- package/dist/src/benchmark-tool-isolation.js +124 -0
- package/dist/src/bookable-facts.js +1 -1
- package/dist/src/booking-saga.js +1 -1
- package/dist/src/booking-surface/availability-policy-v2.js +830 -0
- package/dist/src/booking-surface/canonical-schema.js +113 -0
- package/dist/src/booking-surface/contracts-v2.js +89 -0
- package/dist/src/booking-surface/contracts.js +46 -0
- package/dist/src/booking-surface/dsh-planner.js +453 -0
- package/dist/src/booking-surface/dsh-plugin.js +93 -0
- package/dist/src/booking-surface/error-codes.js +94 -0
- package/dist/src/booking-surface/index.js +15 -0
- package/dist/src/booking-surface/profile.js +68 -0
- package/dist/src/booking-surface/runtime-v2.js +1771 -0
- package/dist/src/booking-surface/runtime.js +351 -0
- package/dist/src/booking-surface/server-v2.js +334 -0
- package/dist/src/booking-surface/server.js +302 -0
- package/dist/src/booking-surface/startup.js +159 -0
- package/dist/src/booking-surface/validation-v2.js +319 -0
- package/dist/src/booking-surface/validation.js +809 -0
- package/dist/src/bridge.js +1 -1
- package/dist/src/companions.js +1 -1
- package/dist/src/contracts.js +1 -1
- package/dist/src/dsh-llm.js +1 -1
- package/dist/src/engine.js +1 -1
- package/dist/src/evaluation-cadence.js +234 -0
- package/dist/src/evaluation-contracts.js +906 -0
- package/dist/src/i18n.js +1 -1
- package/dist/src/index.js +50 -19
- package/dist/src/journey.js +1 -1
- package/dist/src/loop.js +1 -1
- package/dist/src/memory-capture.js +1 -1
- package/dist/src/memory-decay.js +1 -1
- package/dist/src/memory-utility.js +1 -1
- package/dist/src/mock-llm.js +1 -1
- package/dist/src/model.js +1 -1
- package/dist/src/realtime-pricing.js +1 -1
- package/dist/src/slot-spec.js +1 -1
- package/dist/src/state-ledger.js +2 -1
- package/dist/src/time-anchor.js +1 -1
- package/dist/src/tool-budget.js +136 -0
- package/dist/src/tool-packet.js +1 -1
- package/dist/src/travel-slots.js +1 -1
- package/dist/src/travel-timeline.js +1 -1
- package/dist/src/unified.js +1 -1
- package/dist/src/wish-pool.js +1 -1
- package/dist/src/z3-shared.js +1 -1
- package/extension/README.md +31 -7
- package/package.json +286 -11
- package/schemas/booking.surface.v1.schema.json +927 -0
- package/schemas/booking.surface.v2.schema.json +61 -0
- package/ts/capabilities/flyai.ts +16 -3
- package/ts/capabilities/session/extension-bridge.ts +37 -14
- package/ts/capabilities/session/extension-channel.ts +6 -3
- package/ts/capabilities/session/extension-distribution.ts +264 -0
- package/ts/capabilities/session/golden-score.ts +139 -0
- package/ts/capabilities/session/health-watch.ts +1 -1
- package/ts/capabilities/session/static-flight-golden.ts +209 -0
- package/ts/capabilities/session/wizard.ts +34 -176
- package/ts/capabilities/session-login.ts +15 -5
- package/ts/capabilities/session-search.ts +40 -3
- package/ts/capabilities/weather.ts +141 -52
- package/ts/package.json +3 -3
- package/ts/src/benchmark-agent-conformance.ts +448 -0
- package/ts/src/benchmark-environment-bridge.ts +348 -0
- package/ts/src/benchmark-headless-child-diagnostics.ts +184 -0
- package/ts/src/benchmark-tool-isolation.ts +166 -0
- package/ts/src/booking-surface/availability-policy-v2.ts +523 -0
- package/ts/src/booking-surface/canonical-schema.js +113 -0
- package/ts/src/booking-surface/contracts-v2.ts +118 -0
- package/ts/src/booking-surface/contracts.ts +380 -0
- package/ts/src/booking-surface/dsh-planner.ts +452 -0
- package/ts/src/booking-surface/dsh-plugin.js +93 -0
- package/ts/src/booking-surface/error-codes.ts +101 -0
- package/ts/src/booking-surface/index.ts +12 -0
- package/ts/src/booking-surface/profile.ts +42 -0
- package/ts/src/booking-surface/runtime-v2.ts +1466 -0
- package/ts/src/booking-surface/runtime.ts +483 -0
- package/ts/src/booking-surface/server-v2.ts +247 -0
- package/ts/src/booking-surface/server.ts +324 -0
- package/ts/src/booking-surface/startup.ts +196 -0
- package/ts/src/booking-surface/validation-v2.ts +205 -0
- package/ts/src/booking-surface/validation.ts +453 -0
- package/ts/src/index.ts +64 -11
- package/ts/src/state-ledger.ts +1 -0
- package/ts/src/tool-budget.ts +165 -0
- package/dist/scripts/wizard-bootstrap.js +0 -32
package/dist/src/i18n.js
CHANGED
package/dist/src/index.js
CHANGED
|
@@ -18,12 +18,18 @@ import { anythingSearch } from '../capabilities/anything.js';
|
|
|
18
18
|
import { readUrl, reach, reachStatus } from '../capabilities/agent-reach.js';
|
|
19
19
|
import { videoSubtitle, githubSearch } from '../capabilities/agent-reach-deep.js';
|
|
20
20
|
import { sessionLogin } from '../capabilities/session-login.js';
|
|
21
|
+
import { EXTENSION_STORE_URL } from '../capabilities/session/extension-bridge.js';
|
|
21
22
|
import { createConsentGate, approvalFromContext } from '../capabilities/session-consent.js';
|
|
23
|
+
import { installModelOverride } from '../capabilities/model-override.js';
|
|
22
24
|
import { listArtifacts, readArtifact } from '../capabilities/artifacts.js';
|
|
23
25
|
import { interpretEffect, declinedObservation } from '../capabilities/effect.js';
|
|
24
26
|
import { appendFacts, loadFactRegistry } from '../capabilities/fact-log.js';
|
|
25
27
|
import { factsFromFlyai, factsFromSession } from './bookable-facts.js';
|
|
26
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';
|
|
27
33
|
let airlineAirportMapCache = null;
|
|
28
34
|
async function loadAirlineAirportMap() {
|
|
29
35
|
if (airlineAirportMapCache) return airlineAirportMapCache;
|
|
@@ -44,7 +50,8 @@ export const Config = z.object({
|
|
|
44
50
|
stateRoot: z.string().default('.'),
|
|
45
51
|
timeoutMs: z.number().default(30_000),
|
|
46
52
|
hbcliBin: z.string().default('hbcli'),
|
|
47
|
-
sessionAccess: z.string().default('ask')
|
|
53
|
+
sessionAccess: z.string().default('ask'),
|
|
54
|
+
benchmarkEnvironmentConfigPath: z.string().default('')
|
|
48
55
|
});
|
|
49
56
|
const unwrapQuery = interpretArgs;
|
|
50
57
|
function renderMotivationBrief(stateRoot) {
|
|
@@ -89,6 +96,17 @@ function readTimelineTrips(stateRoot) {
|
|
|
89
96
|
})).sort((a, b)=>a.start < b.start ? 1 : -1).slice(0, 3);
|
|
90
97
|
}
|
|
91
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
|
+
}
|
|
92
110
|
const sp = ctx['systemPrompt'];
|
|
93
111
|
sp?.variable?.('current_date', ()=>{
|
|
94
112
|
const d = new Date();
|
|
@@ -117,6 +135,7 @@ export function apply(ctx, config) {
|
|
|
117
135
|
approval: approvalFromContext(ctx)
|
|
118
136
|
}));
|
|
119
137
|
}
|
|
138
|
+
installModelOverride(ctx);
|
|
120
139
|
const registerGuarded = (tool)=>{
|
|
121
140
|
const t = {
|
|
122
141
|
...tool
|
|
@@ -964,7 +983,7 @@ export function apply(ctx, config) {
|
|
|
964
983
|
}));
|
|
965
984
|
registerGuarded(defineTool({
|
|
966
985
|
name: 'gotry_session_login',
|
|
967
|
-
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). ' +
|
|
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].',
|
|
968
987
|
parameters: {
|
|
969
988
|
query: {
|
|
970
989
|
type: 'json',
|
|
@@ -988,7 +1007,7 @@ export function apply(ctx, config) {
|
|
|
988
1007
|
const r = await sessionLogin({
|
|
989
1008
|
waitMs: typeof q?.waitSeconds === 'number' ? q.waitSeconds * 1000 : undefined
|
|
990
1009
|
});
|
|
991
|
-
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
|
|
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}`;
|
|
992
1011
|
return JSON.parse(JSON.stringify({
|
|
993
1012
|
...r,
|
|
994
1013
|
summary
|
|
@@ -1002,22 +1021,28 @@ export function apply(ctx, config) {
|
|
|
1002
1021
|
}),
|
|
1003
1022
|
presentResult: (_args, value)=>{
|
|
1004
1023
|
const r = value;
|
|
1005
|
-
const
|
|
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
|
+
});
|
|
1006
1036
|
return {
|
|
1007
1037
|
card: 'generic',
|
|
1008
1038
|
title: `账号登录:${label}`,
|
|
1009
|
-
content
|
|
1010
|
-
{
|
|
1011
|
-
type: 'text',
|
|
1012
|
-
text: String(value.summary ?? '')
|
|
1013
|
-
}
|
|
1014
|
-
]
|
|
1039
|
+
content
|
|
1015
1040
|
};
|
|
1016
1041
|
}
|
|
1017
1042
|
}));
|
|
1018
1043
|
registerGuarded(defineTool({
|
|
1019
1044
|
name: 'gotry_session_search',
|
|
1020
|
-
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); ' +
|
|
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).',
|
|
1021
1046
|
parameters: {
|
|
1022
1047
|
query: {
|
|
1023
1048
|
type: 'json',
|
|
@@ -1076,16 +1101,22 @@ export function apply(ctx, config) {
|
|
|
1076
1101
|
}),
|
|
1077
1102
|
presentResult: (_args, value)=>{
|
|
1078
1103
|
const r = value;
|
|
1079
|
-
const
|
|
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
|
+
});
|
|
1080
1116
|
return {
|
|
1081
1117
|
card: 'generic',
|
|
1082
1118
|
title: `会话检索:${label}`,
|
|
1083
|
-
content
|
|
1084
|
-
{
|
|
1085
|
-
type: 'text',
|
|
1086
|
-
text: String(value.summary ?? '')
|
|
1087
|
-
}
|
|
1088
|
-
]
|
|
1119
|
+
content
|
|
1089
1120
|
};
|
|
1090
1121
|
}
|
|
1091
1122
|
}));
|
|
@@ -1636,4 +1667,4 @@ export function apply(ctx, config) {
|
|
|
1636
1667
|
}
|
|
1637
1668
|
|
|
1638
1669
|
|
|
1639
|
-
//# sourceURL
|
|
1670
|
+
//# sourceURL=ts/src/index.ts
|
package/dist/src/journey.js
CHANGED
package/dist/src/loop.js
CHANGED
package/dist/src/memory-decay.js
CHANGED
package/dist/src/mock-llm.js
CHANGED
package/dist/src/model.js
CHANGED
package/dist/src/slot-spec.js
CHANGED
package/dist/src/state-ledger.js
CHANGED
|
@@ -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
|
|
928
|
+
//# sourceURL=ts/src/state-ledger.ts
|
package/dist/src/time-anchor.js
CHANGED
|
@@ -0,0 +1,136 @@
|
|
|
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
|
package/dist/src/tool-packet.js
CHANGED
package/dist/src/travel-slots.js
CHANGED
package/dist/src/unified.js
CHANGED
package/dist/src/wish-pool.js
CHANGED
package/dist/src/z3-shared.js
CHANGED
package/extension/README.md
CHANGED
|
@@ -11,16 +11,40 @@
|
|
|
11
11
|
- ❌ 不向任何站点发起请求(检索请求由站点页面自己发出,扩展只听不写);
|
|
12
12
|
- ❌ 不动你已打开的任何标签页(只创建/关闭自己的检索标签;登录标签留给你)。
|
|
13
13
|
|
|
14
|
-
## 安装(
|
|
14
|
+
## 安装(每台浏览器一次)
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
### 方式一(推荐):Chrome 应用商店一键安装
|
|
17
|
+
|
|
18
|
+
打开商店页点「添加至 Chrome」即可,零开发者模式、零手动加载,**自动更新**:
|
|
19
|
+
|
|
20
|
+
**https://chromewebstore.google.com/detail/gotry-session-bridge/oeajpiccmonococjcegddlooeeohlbgd**
|
|
21
|
+
|
|
22
|
+
商店版经 Google 审核上架(2026-09-02),版本跟随商店发版节奏。
|
|
23
|
+
|
|
24
|
+
### 方式二:GitHub Releases 本地加载(免审核,版本更新更快)
|
|
25
|
+
|
|
26
|
+
不经商店审核,版本化 tarball + SHA256 校验,与 npm 发版节奏解耦,更新比商店快:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npx gotry setup --extension-from=github # 自动下载校验并落位 ~/.gotry/extension
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
(或手动:从 [github.com/Danceiny/gotry/releases](https://github.com/Danceiny/gotry/releases) 标签 `ext-*` 下载 `gotry-session-bridge.tar.gz` 解压到任意固定位置。)
|
|
33
|
+
|
|
34
|
+
然后在 Chrome 地址栏打开 `chrome://extensions` → 右上角开启「开发者模式」→ 点「加载已解压的扩展程序」选择该目录。
|
|
35
|
+
|
|
36
|
+
### 方式三:npm 包内副本本地加载(离线确定性)
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx gotry setup # 把包内扩展落位到 ~/.gotry/extension
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
再按方式二的 `chrome://extensions` 三步加载该目录。
|
|
20
43
|
|
|
21
44
|
装好即生效,无任何系统弹窗。卸载/随时可停:扩展卡片上的开关即是总闸(仍受 gotry 授权闸 `sessionAccess` 双重控制)。
|
|
22
45
|
|
|
23
46
|
## 自检
|
|
24
47
|
|
|
25
|
-
-
|
|
26
|
-
-
|
|
48
|
+
- 商店版扩展 ID 固定为 `oeajpiccmonococjcegddlooeeohlbgd`(商店用自己的签名 key,与 unpacked 版 ID 不同,二者都是同一扩展,本机 gotry 桥双通道同信);
|
|
49
|
+
- 本地加载(unpacked)版扩展 ID 应为固定的 `olpgkofjhhiiiahdkkbcninhjmegghfe`(manifest 带 `key`,跨机器稳定)——若不一致,说明 manifest 被改动过,不要加载;
|
|
50
|
+
- gotry 侧运行 `npx gotry` 后发起一次会话检索,扩展图标应出现(无需点击);桥状态可看 `curl http://127.0.0.1:8791/status`(仅本机回环)。
|