fortrip 5.3.0 → 6.0.0-rc.0
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 +34 -20
- package/THIRD-PARTY-NOTICES +0 -26
- package/dist/{chunk-TEXEQ57H.js → chunk-OUCQQEEU.js} +1591 -966
- package/dist/cli.js +125 -756
- package/dist/{mcp-bridge-M763WDKU.js → mcp-bridge-ANLTZ4MB.js} +24 -19
- package/package.json +2 -3
|
@@ -3,7 +3,10 @@ import {
|
|
|
3
3
|
CONTRACT_VERSION,
|
|
4
4
|
CliError,
|
|
5
5
|
EXIT,
|
|
6
|
+
META_KEYS,
|
|
7
|
+
SERVER_INFO,
|
|
6
8
|
TOOLS,
|
|
9
|
+
USER_AGENT,
|
|
7
10
|
isEnvelope,
|
|
8
11
|
loadSession,
|
|
9
12
|
localRequestId,
|
|
@@ -11,7 +14,7 @@ import {
|
|
|
11
14
|
renderError,
|
|
12
15
|
renderGuide,
|
|
13
16
|
requireToken
|
|
14
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-OUCQQEEU.js";
|
|
15
18
|
|
|
16
19
|
// src/mcp-bridge.ts
|
|
17
20
|
import {
|
|
@@ -30,11 +33,13 @@ var SIGN_IN_REQUIRED = -32001;
|
|
|
30
33
|
var INTERNAL_ERROR = -32603;
|
|
31
34
|
var LOGIN_COMMAND = "npx -y fortrip login";
|
|
32
35
|
var SignInRequired = class extends Error {
|
|
33
|
-
constructor(message, data = {}) {
|
|
36
|
+
constructor(message, data = {}, advice = message) {
|
|
34
37
|
super(message);
|
|
35
38
|
this.data = data;
|
|
39
|
+
this.advice = advice;
|
|
36
40
|
}
|
|
37
41
|
data;
|
|
42
|
+
advice;
|
|
38
43
|
};
|
|
39
44
|
var signInAdvice = (link = "") => `Run \`${LOGIN_COMMAND}\` in a terminal${link}, then try again.`;
|
|
40
45
|
async function signedIn(run) {
|
|
@@ -44,11 +49,11 @@ async function signedIn(run) {
|
|
|
44
49
|
if (error instanceof CliError && error.exitCode === EXIT.unauthenticated) {
|
|
45
50
|
if (error.details.tokenSource === "FORTRIP_TOKEN") throw new SignInRequired(error.message);
|
|
46
51
|
const { loginUrl, userCode, expiresInSeconds } = error.details;
|
|
52
|
+
const advice = signInAdvice(loginUrl ? `, or open ${loginUrl} and approve` : "");
|
|
47
53
|
throw new SignInRequired(
|
|
48
|
-
`Not signed in to Fortrip, or the saved sign-in no longer works. ${
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
{ loginUrl, userCode, expiresInSeconds }
|
|
54
|
+
`Not signed in to Fortrip, or the saved sign-in no longer works. ${advice}`,
|
|
55
|
+
{ loginUrl, userCode, expiresInSeconds },
|
|
56
|
+
advice
|
|
52
57
|
);
|
|
53
58
|
}
|
|
54
59
|
throw error;
|
|
@@ -69,6 +74,7 @@ function authorizedFetch(mcpUrl, apiUrl) {
|
|
|
69
74
|
const withToken = (token2) => {
|
|
70
75
|
const headers = new Headers(init?.headers);
|
|
71
76
|
headers.set("authorization", `Bearer ${token2}`);
|
|
77
|
+
headers.set("user-agent", USER_AGENT);
|
|
72
78
|
return attempt(url, { ...init, headers });
|
|
73
79
|
};
|
|
74
80
|
const started = turn.then(async () => {
|
|
@@ -147,6 +153,7 @@ function rpcErrorOf(error) {
|
|
|
147
153
|
}
|
|
148
154
|
function toolErrorOf(error) {
|
|
149
155
|
let envelope;
|
|
156
|
+
let text;
|
|
150
157
|
if (error instanceof SignInRequired) {
|
|
151
158
|
envelope = {
|
|
152
159
|
error: {
|
|
@@ -156,6 +163,8 @@ function toolErrorOf(error) {
|
|
|
156
163
|
requestId: localRequestId()
|
|
157
164
|
}
|
|
158
165
|
};
|
|
166
|
+
text = `${renderError(envelope, void 0, "cli")}
|
|
167
|
+
${error.advice}`;
|
|
159
168
|
} else if (error instanceof SdkHttpError) {
|
|
160
169
|
envelope = bodyOf(error);
|
|
161
170
|
} else if (error instanceof CliError) {
|
|
@@ -164,11 +173,8 @@ function toolErrorOf(error) {
|
|
|
164
173
|
if (!isEnvelope(envelope)) return void 0;
|
|
165
174
|
return {
|
|
166
175
|
isError: true,
|
|
167
|
-
content: [
|
|
168
|
-
|
|
169
|
-
{ type: "text", text: JSON.stringify(envelope) }
|
|
170
|
-
],
|
|
171
|
-
_meta: { "ai.fortrip/error": envelope }
|
|
176
|
+
content: [{ type: "text", text: text ?? renderError(envelope) }],
|
|
177
|
+
_meta: { [META_KEYS.error]: envelope }
|
|
172
178
|
};
|
|
173
179
|
}
|
|
174
180
|
function failureAnswer(id, method, error) {
|
|
@@ -197,22 +203,21 @@ function passThrough(schema) {
|
|
|
197
203
|
}
|
|
198
204
|
function localServer() {
|
|
199
205
|
const server = new McpServer(
|
|
200
|
-
{
|
|
206
|
+
{ ...SERVER_INFO, version: CONTRACT_VERSION },
|
|
201
207
|
{ instructions: renderGuide("mcp", "main") }
|
|
202
208
|
);
|
|
203
209
|
const handler = () => {
|
|
204
210
|
throw new Error("Fortrip's tools run on the hosted server.");
|
|
205
211
|
};
|
|
206
212
|
for (const spec of TOOLS) {
|
|
207
|
-
const config = {
|
|
208
|
-
title: spec.title,
|
|
209
|
-
description: spec.description,
|
|
210
|
-
annotations: spec.annotations,
|
|
211
|
-
outputSchema: passThrough(spec.output)
|
|
212
|
-
};
|
|
213
213
|
server.registerTool(
|
|
214
214
|
spec.name,
|
|
215
|
-
{
|
|
215
|
+
{
|
|
216
|
+
title: spec.title,
|
|
217
|
+
description: spec.description,
|
|
218
|
+
annotations: spec.annotations,
|
|
219
|
+
inputSchema: passThrough(spec.input)
|
|
220
|
+
},
|
|
216
221
|
handler
|
|
217
222
|
);
|
|
218
223
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fortrip",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.0.0-rc.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"description": "Search, price and book Fortrip hotels from the terminal or an AI agent.",
|
|
6
6
|
"mcpName": "io.github.FortripEngineering/fortrip",
|
|
@@ -31,9 +31,8 @@
|
|
|
31
31
|
"tsup": "^8.5.1",
|
|
32
32
|
"tsx": "^4.20.0",
|
|
33
33
|
"typescript": "^5.9.0",
|
|
34
|
-
"uqr": "0.1.3",
|
|
35
34
|
"zod": "4.4.3",
|
|
36
|
-
"@fortrip/agent-contract": "
|
|
35
|
+
"@fortrip/agent-contract": "6.0.0-rc.0"
|
|
37
36
|
},
|
|
38
37
|
"scripts": {
|
|
39
38
|
"build": "tsup",
|