@riverintel/stayfinder-plugin 0.2.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/LICENSE +201 -0
- package/README.md +94 -0
- package/dist/adapter-client.d.ts +68 -0
- package/dist/adapter-client.d.ts.map +1 -0
- package/dist/adapter-client.js +149 -0
- package/dist/adapter-client.js.map +1 -0
- package/dist/credential-store.d.ts +71 -0
- package/dist/credential-store.d.ts.map +1 -0
- package/dist/credential-store.js +143 -0
- package/dist/credential-store.js.map +1 -0
- package/dist/errors.d.ts +55 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +160 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +28 -0
- package/dist/index.js.map +1 -0
- package/dist/plugin-config.d.ts +37 -0
- package/dist/plugin-config.d.ts.map +1 -0
- package/dist/plugin-config.js +63 -0
- package/dist/plugin-config.js.map +1 -0
- package/dist/thumbnails.d.ts +31 -0
- package/dist/thumbnails.d.ts.map +1 -0
- package/dist/thumbnails.js +32 -0
- package/dist/thumbnails.js.map +1 -0
- package/dist/tool-result.d.ts +19 -0
- package/dist/tool-result.d.ts.map +1 -0
- package/dist/tool-result.js +18 -0
- package/dist/tool-result.js.map +1 -0
- package/dist/tools/search-stays.d.ts +45 -0
- package/dist/tools/search-stays.d.ts.map +1 -0
- package/dist/tools/search-stays.js +191 -0
- package/dist/tools/search-stays.js.map +1 -0
- package/dist/tools/stayfinder-signup.d.ts +38 -0
- package/dist/tools/stayfinder-signup.d.ts.map +1 -0
- package/dist/tools/stayfinder-signup.js +102 -0
- package/dist/tools/stayfinder-signup.js.map +1 -0
- package/dist/tools/stayfinder-verify.d.ts +26 -0
- package/dist/tools/stayfinder-verify.d.ts.map +1 -0
- package/dist/tools/stayfinder-verify.js +124 -0
- package/dist/tools/stayfinder-verify.js.map +1 -0
- package/dist/types.d.ts +193 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/dist/validation.d.ts +51 -0
- package/dist/validation.d.ts.map +1 -0
- package/dist/validation.js +174 -0
- package/dist/validation.js.map +1 -0
- package/openclaw.plugin.json +41 -0
- package/package.json +87 -0
- package/skills/lodging-search/SKILL.md +235 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# StayFinder
|
|
2
|
+
|
|
3
|
+
OpenClaw plugin for live hotel and vacation rental search. Ask your agent for a hotel and get back real prices, real availability, and real booking redirect links. No web scraping. No browser automation. No fabricated URLs.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
openclaw plugins install @riverintel/stayfinder
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Add the tools to your `~/.openclaw/openclaw.json`:
|
|
12
|
+
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"tools": {
|
|
16
|
+
"alsoAllow": ["search_stays", "stayfinder_signup", "stayfinder_verify"]
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Restart the gateway:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
openclaw gateway restart
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## How it works
|
|
28
|
+
|
|
29
|
+
Ask your agent about hotels or vacation rentals:
|
|
30
|
+
|
|
31
|
+
> "Find me a hotel in Manhattan for next weekend, two adults"
|
|
32
|
+
|
|
33
|
+
The first time, the agent walks you through a one-time setup — it asks for your email, sends you a 6-digit code, and you paste the digits back into the chat. The whole thing takes about two minutes. After that, searches just work.
|
|
34
|
+
|
|
35
|
+
Your access stays active as long as you keep using it. If you go about a week without searching, the agent sends you a fresh code automatically — you don't have to re-enter your email.
|
|
36
|
+
|
|
37
|
+
## What you get back
|
|
38
|
+
|
|
39
|
+
The agent presents real-time results from Expedia and Vrbo with prices, ratings, and direct booking links:
|
|
40
|
+
|
|
41
|
+
> **The Plaza** ⭐⭐⭐⭐⭐ · 9.0/10 (1,000 reviews)
|
|
42
|
+
> $1,258/night · $2,894 total
|
|
43
|
+
> Iconic NYC landmark on Central Park & 5th Ave. Full-service spa, family-friendly.
|
|
44
|
+
> 👉 [Book on Expedia](https://expedia.com/r/...)
|
|
45
|
+
|
|
46
|
+
You can refine with follow-ups like "only 5-star", "pet-friendly", "under $300/night", or "show me vacation rentals instead" — the agent re-searches with updated filters each time.
|
|
47
|
+
|
|
48
|
+
## Tools
|
|
49
|
+
|
|
50
|
+
| Tool | Purpose |
|
|
51
|
+
|------|---------|
|
|
52
|
+
| `search_stays` | Search hotels and vacation rentals with filters, sorting, and an optional trip-intent description |
|
|
53
|
+
| `stayfinder_signup` | Send a 6-digit verification code to your email (first-time setup or re-auth) |
|
|
54
|
+
| `stayfinder_verify` | Exchange the code for an API token, saved automatically to your credential store |
|
|
55
|
+
|
|
56
|
+
The bundled `lodging-search` skill tells the agent when and how to use each tool — including the setup flow, re-authentication after inactivity, error handling, and output formatting.
|
|
57
|
+
|
|
58
|
+
## Configuration
|
|
59
|
+
|
|
60
|
+
All configuration is optional. The plugin defaults to the public hosted StayFinder service and US pricing.
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"plugins": {
|
|
65
|
+
"entries": {
|
|
66
|
+
"stayfinder": {
|
|
67
|
+
"enabled": true,
|
|
68
|
+
"config": {
|
|
69
|
+
"adapter_url": "https://api.stayfinder.riverintel.com",
|
|
70
|
+
"default_pos_country": "US",
|
|
71
|
+
"default_currency": "USD",
|
|
72
|
+
"request_timeout_ms": 10000
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Self-hosters can point `adapter_url` at their own deployment.
|
|
81
|
+
|
|
82
|
+
## Privacy
|
|
83
|
+
|
|
84
|
+
StayFinder receives the search parameters needed to find lodging — destination, dates, party size, filters, and (optionally) a one-sentence description of what kind of trip you're planning. It does not see your browsing history, the rest of your conversation with the agent, or anything you didn't tell the agent about your trip.
|
|
85
|
+
|
|
86
|
+
Your email address is used once during signup verification and stored only as a tenant identifier on the StayFinder service. The API token is written to `~/.openclaw/credentials/stayfinder.json` (mode 0600, readable only by you) and is never shown to the user or the agent.
|
|
87
|
+
|
|
88
|
+
## Issues and contributions
|
|
89
|
+
|
|
90
|
+
Bug reports, feature requests, and PRs welcome at [github.com/RiverIntel/stayfinder/issues](https://github.com/RiverIntel/stayfinder/issues).
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
Apache 2.0 — see [LICENSE](./LICENSE).
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the StayFinder service.
|
|
3
|
+
*
|
|
4
|
+
* Intentionally minimal: builds the request, fires it, parses the
|
|
5
|
+
* response, and either returns the success body or throws an
|
|
6
|
+
* `AdapterError` for the caller to format. No retries (the adapter
|
|
7
|
+
* already retries to Expedia internally), no connection pooling
|
|
8
|
+
* beyond Node's defaults, no in-process caching.
|
|
9
|
+
*
|
|
10
|
+
* The client is a class so tools can inject a fake `fetch` for tests.
|
|
11
|
+
* Production code constructs one per call from the tool's `execute`
|
|
12
|
+
* function — no global state, no singletons, no init step. The class
|
|
13
|
+
* is small enough that the per-call cost is irrelevant.
|
|
14
|
+
*/
|
|
15
|
+
import type { SearchStaysRequest, SearchStaysResponse, SignupResponse, SignupVerifyResponse, StayFinderPluginConfig, TenantMeResponse } from './types.js';
|
|
16
|
+
/**
|
|
17
|
+
* Minimal `fetch` shape we depend on. Matches the global `fetch`
|
|
18
|
+
* available in Node 20+ and lets tests inject a fake without pulling
|
|
19
|
+
* in any HTTP-mocking library.
|
|
20
|
+
*/
|
|
21
|
+
export type FetchLike = (input: string, init?: {
|
|
22
|
+
method: string;
|
|
23
|
+
headers: Record<string, string>;
|
|
24
|
+
body?: string;
|
|
25
|
+
signal?: AbortSignal;
|
|
26
|
+
}) => Promise<{
|
|
27
|
+
ok: boolean;
|
|
28
|
+
status: number;
|
|
29
|
+
statusText: string;
|
|
30
|
+
json(): Promise<unknown>;
|
|
31
|
+
text(): Promise<string>;
|
|
32
|
+
}>;
|
|
33
|
+
export interface AdapterClientOptions {
|
|
34
|
+
/** Plugin config (defaults are applied by readPluginConfig before this is constructed). */
|
|
35
|
+
config: StayFinderPluginConfig;
|
|
36
|
+
/** Bearer token for authenticated endpoints. Omit for /v1/signup and /v1/signup/verify. */
|
|
37
|
+
apiToken?: string;
|
|
38
|
+
/** Plugin version, included in the User-Agent header for adapter logs. */
|
|
39
|
+
pluginVersion: string;
|
|
40
|
+
/** Optional fetch override for tests. Defaults to globalThis.fetch. */
|
|
41
|
+
fetch?: FetchLike;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Body shape we POST to /v1/search/stays. The plugin's TypeBox schema
|
|
45
|
+
* matches this exactly; we re-state it as a TS type to keep the HTTP
|
|
46
|
+
* layer self-contained and to make it obvious to a code reader what
|
|
47
|
+
* the wire format is.
|
|
48
|
+
*
|
|
49
|
+
* Identical to SearchStaysRequest from types.ts; aliased here for clarity.
|
|
50
|
+
*/
|
|
51
|
+
export type SearchStaysRequestBody = SearchStaysRequest;
|
|
52
|
+
export declare class AdapterClient {
|
|
53
|
+
private readonly config;
|
|
54
|
+
private readonly apiToken;
|
|
55
|
+
private readonly userAgent;
|
|
56
|
+
private readonly fetchImpl;
|
|
57
|
+
constructor(opts: AdapterClientOptions);
|
|
58
|
+
searchStays(body: SearchStaysRequestBody): Promise<SearchStaysResponse>;
|
|
59
|
+
signup(email: string): Promise<SignupResponse>;
|
|
60
|
+
signupVerify(email: string, code: string): Promise<SignupVerifyResponse>;
|
|
61
|
+
tenantMe(): Promise<TenantMeResponse>;
|
|
62
|
+
private post;
|
|
63
|
+
private get;
|
|
64
|
+
private request;
|
|
65
|
+
private buildUrl;
|
|
66
|
+
private buildHeaders;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=adapter-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter-client.d.ts","sourceRoot":"","sources":["../src/adapter-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAEV,kBAAkB,EAClB,mBAAmB,EACnB,cAAc,EACd,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,CACtB,KAAK,EAAE,MAAM,EACb,IAAI,CAAC,EAAE;IACL,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,KACE,OAAO,CAAC;IACX,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IACzB,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CACzB,CAAC,CAAC;AAEH,MAAM,WAAW,oBAAoB;IACnC,2FAA2F;IAC3F,MAAM,EAAE,sBAAsB,CAAC;IAC/B,2FAA2F;IAC3F,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,aAAa,EAAE,MAAM,CAAC;IACtB,uEAAuE;IACvE,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG,kBAAkB,CAAC;AAExD,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAyB;IAChD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAqB;IAC9C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;gBAE1B,IAAI,EAAE,oBAAoB;IAWtC,WAAW,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAIvE,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAQ9C,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAQxE,QAAQ,IAAI,OAAO,CAAC,gBAAgB,CAAC;YAQvB,IAAI;YAQJ,GAAG;YAIH,OAAO;IAyFrB,OAAO,CAAC,QAAQ;IAQhB,OAAO,CAAC,YAAY;CAmBrB"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP client for the StayFinder service.
|
|
3
|
+
*
|
|
4
|
+
* Intentionally minimal: builds the request, fires it, parses the
|
|
5
|
+
* response, and either returns the success body or throws an
|
|
6
|
+
* `AdapterError` for the caller to format. No retries (the adapter
|
|
7
|
+
* already retries to Expedia internally), no connection pooling
|
|
8
|
+
* beyond Node's defaults, no in-process caching.
|
|
9
|
+
*
|
|
10
|
+
* The client is a class so tools can inject a fake `fetch` for tests.
|
|
11
|
+
* Production code constructs one per call from the tool's `execute`
|
|
12
|
+
* function — no global state, no singletons, no init step. The class
|
|
13
|
+
* is small enough that the per-call cost is irrelevant.
|
|
14
|
+
*/
|
|
15
|
+
import { AdapterError } from './errors.js';
|
|
16
|
+
export class AdapterClient {
|
|
17
|
+
config;
|
|
18
|
+
apiToken;
|
|
19
|
+
userAgent;
|
|
20
|
+
fetchImpl;
|
|
21
|
+
constructor(opts) {
|
|
22
|
+
this.config = opts.config;
|
|
23
|
+
this.apiToken = opts.apiToken;
|
|
24
|
+
this.userAgent = `openclaw-plugin-stayfinder/${opts.pluginVersion}`;
|
|
25
|
+
this.fetchImpl = opts.fetch ?? globalThis.fetch;
|
|
26
|
+
}
|
|
27
|
+
// -------------------------------------------------------------------------
|
|
28
|
+
// Public methods — one per adapter endpoint we call
|
|
29
|
+
// -------------------------------------------------------------------------
|
|
30
|
+
searchStays(body) {
|
|
31
|
+
return this.post('/v1/search/stays', body, { authenticated: true });
|
|
32
|
+
}
|
|
33
|
+
signup(email) {
|
|
34
|
+
return this.post('/v1/signup', { email, consumer_hint: this.userAgent }, { authenticated: false });
|
|
35
|
+
}
|
|
36
|
+
signupVerify(email, code) {
|
|
37
|
+
return this.post('/v1/signup/verify', { email, code }, { authenticated: false });
|
|
38
|
+
}
|
|
39
|
+
tenantMe() {
|
|
40
|
+
return this.get('/v1/tenant/me', { authenticated: true });
|
|
41
|
+
}
|
|
42
|
+
// -------------------------------------------------------------------------
|
|
43
|
+
// Internal HTTP plumbing
|
|
44
|
+
// -------------------------------------------------------------------------
|
|
45
|
+
async post(path, body, opts) {
|
|
46
|
+
return this.request('POST', path, JSON.stringify(body), opts);
|
|
47
|
+
}
|
|
48
|
+
async get(path, opts) {
|
|
49
|
+
return this.request('GET', path, undefined, opts);
|
|
50
|
+
}
|
|
51
|
+
async request(method, path, body, opts) {
|
|
52
|
+
const url = this.buildUrl(path);
|
|
53
|
+
const headers = this.buildHeaders(body !== undefined, opts.authenticated);
|
|
54
|
+
const controller = new AbortController();
|
|
55
|
+
const timer = setTimeout(() => controller.abort(), this.config.request_timeout_ms);
|
|
56
|
+
let res;
|
|
57
|
+
try {
|
|
58
|
+
res = await this.fetchImpl(url, {
|
|
59
|
+
method,
|
|
60
|
+
headers,
|
|
61
|
+
body,
|
|
62
|
+
signal: controller.signal,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
const isAbort = err?.name === 'AbortError';
|
|
67
|
+
if (isAbort) {
|
|
68
|
+
throw new Error(`StayFinder request to ${path} timed out after ${this.config.request_timeout_ms}ms. ` +
|
|
69
|
+
'The service may be slow or unreachable. Tell the user briefly and offer to retry.');
|
|
70
|
+
}
|
|
71
|
+
throw new Error(`StayFinder request to ${path} failed: ${err.message}. ` +
|
|
72
|
+
'Check that the adapter URL is correct and reachable.');
|
|
73
|
+
}
|
|
74
|
+
finally {
|
|
75
|
+
clearTimeout(timer);
|
|
76
|
+
}
|
|
77
|
+
// -----------------------------------------------------------------------
|
|
78
|
+
// Non-2xx → parse the standard error envelope and throw AdapterError
|
|
79
|
+
// -----------------------------------------------------------------------
|
|
80
|
+
if (!res.ok) {
|
|
81
|
+
// Read the body once. If it parses as our error envelope, surface
|
|
82
|
+
// that; otherwise wrap the raw text in a generic error so we still
|
|
83
|
+
// see what came back.
|
|
84
|
+
let envelope = null;
|
|
85
|
+
let rawText = '';
|
|
86
|
+
try {
|
|
87
|
+
rawText = await res.text();
|
|
88
|
+
const parsed = rawText.length > 0 ? JSON.parse(rawText) : null;
|
|
89
|
+
if (parsed &&
|
|
90
|
+
typeof parsed === 'object' &&
|
|
91
|
+
'error' in parsed) {
|
|
92
|
+
envelope = parsed;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
// body wasn't JSON; fall through to the synthetic envelope below
|
|
97
|
+
}
|
|
98
|
+
if (envelope) {
|
|
99
|
+
throw new AdapterError(envelope, res.status);
|
|
100
|
+
}
|
|
101
|
+
// Synthetic envelope for "the server returned a non-2xx with no
|
|
102
|
+
// structured body" — usually a Cloud Run-side outage rather than
|
|
103
|
+
// an application error. Surface it as `internal_error` so the
|
|
104
|
+
// model gets a coherent recovery path.
|
|
105
|
+
const synthetic = {
|
|
106
|
+
error: {
|
|
107
|
+
code: 'internal_error',
|
|
108
|
+
message: `StayFinder service returned HTTP ${res.status} ${res.statusText} ` +
|
|
109
|
+
`with no JSON body${rawText ? ` (body excerpt: ${rawText.slice(0, 200)})` : ''}`,
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
throw new AdapterError(synthetic, res.status);
|
|
113
|
+
}
|
|
114
|
+
// -----------------------------------------------------------------------
|
|
115
|
+
// 2xx → parse JSON and return
|
|
116
|
+
// -----------------------------------------------------------------------
|
|
117
|
+
try {
|
|
118
|
+
return (await res.json());
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
throw new Error(`StayFinder response from ${path} was not valid JSON: ${err.message}`);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
buildUrl(path) {
|
|
125
|
+
// Trim trailing slash off adapter_url so we don't end up with double
|
|
126
|
+
// slashes in the path. Adapter URLs from the config schema are
|
|
127
|
+
// unlikely to have one, but defense in depth.
|
|
128
|
+
const base = this.config.adapter_url.replace(/\/+$/, '');
|
|
129
|
+
return `${base}${path}`;
|
|
130
|
+
}
|
|
131
|
+
buildHeaders(hasBody, authenticated) {
|
|
132
|
+
const headers = {
|
|
133
|
+
Accept: 'application/json',
|
|
134
|
+
'User-Agent': this.userAgent,
|
|
135
|
+
};
|
|
136
|
+
if (hasBody) {
|
|
137
|
+
headers['Content-Type'] = 'application/json';
|
|
138
|
+
}
|
|
139
|
+
if (authenticated) {
|
|
140
|
+
if (!this.apiToken) {
|
|
141
|
+
throw new Error('Internal: tried to call an authenticated StayFinder endpoint without a token. ' +
|
|
142
|
+
'This is a plugin bug — adapter-client.ts should have refused to construct.');
|
|
143
|
+
}
|
|
144
|
+
headers['Authorization'] = `Bearer ${this.apiToken}`;
|
|
145
|
+
}
|
|
146
|
+
return headers;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
//# sourceMapp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|
1
|
+
/**
|
|
2
|
+
* On-disk credential store for the StayFinder plugin.
|
|
3
|
+
*
|
|
4
|
+
* The plugin writes a single JSON file at ~/.openclaw/credentials/stayfinder.json
|
|
5
|
+
* (mode 0600 — readable only by the user) containing the API token and
|
|
6
|
+
* the small amount of metadata the plugin needs to drive re-auth without
|
|
7
|
+
* re-prompting the user for their email.
|
|
8
|
+
*
|
|
9
|
+
* The credential file shape is documented in types.ts (CredentialFile)
|
|
10
|
+
* and matches what stayfinder_verify writes after a successful exchange.
|
|
11
|
+
*
|
|
12
|
+
* Why a file (and not OpenClaw's credential API):
|
|
13
|
+
* The plugin manifest's `credentialPath` field is a READ-time hint, not
|
|
14
|
+
* a write API. There's no documented runtime API for plugins to write
|
|
15
|
+
* their own credentials back through OpenClaw. Owning the file directly
|
|
16
|
+
* at the documented path is the simplest forward-compatible answer:
|
|
17
|
+
* if a write API ever lands, we switch to it; until then, the file
|
|
18
|
+
* format we control is the contract.
|
|
19
|
+
*
|
|
20
|
+
* Read pattern:
|
|
21
|
+
* - search-stays.ts reads the file on every call (no in-process cache)
|
|
22
|
+
* so a fresh stayfinder_verify takes effect immediately
|
|
23
|
+
* - The file is small (~200 bytes) and the read is local; the cost
|
|
24
|
+
* is irrelevant
|
|
25
|
+
*
|
|
26
|
+
* Write pattern:
|
|
27
|
+
* - stayfinder-verify.ts writes the file once after a successful
|
|
28
|
+
* /v1/signup/verify response
|
|
29
|
+
* - Atomic write via "write to temp + rename" so a crash mid-write
|
|
30
|
+
* can't leave a half-written file the next read would choke on
|
|
31
|
+
* - mode 0600 enforced explicitly (Node's default umask honors this
|
|
32
|
+
* but we set it again at write time as defense in depth)
|
|
33
|
+
*/
|
|
34
|
+
import type { CredentialFile } from './types.js';
|
|
35
|
+
/**
|
|
36
|
+
* Resolve the credential file path.
|
|
37
|
+
*
|
|
38
|
+
* Honors the OPENCLAW_HOME environment variable if set (used by OpenClaw's
|
|
39
|
+
* test/dev profiles to isolate state). Falls back to ~/.openclaw.
|
|
40
|
+
*
|
|
41
|
+
* The credentials/ subdirectory and the file itself are created on demand
|
|
42
|
+
* by writeCredential. They're never assumed to exist at read time.
|
|
43
|
+
*/
|
|
44
|
+
export declare function resolveCredentialPath(env?: NodeJS.ProcessEnv): string;
|
|
45
|
+
/**
|
|
46
|
+
* Read the credential file. Returns null if it doesn't exist or if its
|
|
47
|
+
* contents don't parse as the expected shape.
|
|
48
|
+
*
|
|
49
|
+
* Critically: a missing or unreadable file returns null, NOT an error.
|
|
50
|
+
* "No credentials" is a normal state — the search_stays tool uses it as
|
|
51
|
+
* the trigger to surface `unauthorized` and walk the user through setup.
|
|
52
|
+
*
|
|
53
|
+
* We DO throw on a permission denied or other unexpected I/O error,
|
|
54
|
+
* because that's an environmental problem the user needs to know about
|
|
55
|
+
* and "silently treat as no creds" would be wrong (we'd loop them
|
|
56
|
+
* through signup forever without ever fixing the underlying issue).
|
|
57
|
+
*/
|
|
58
|
+
export declare function readCredential(env?: NodeJS.ProcessEnv): Promise<CredentialFile | null>;
|
|
59
|
+
/**
|
|
60
|
+
* Write the credential file atomically with mode 0600.
|
|
61
|
+
*
|
|
62
|
+
* Creates the credentials/ directory (mode 0700) if it doesn't exist.
|
|
63
|
+
* Writes to a temp file in the same directory, sets permissions, then
|
|
64
|
+
* renames into place — so a crash mid-write leaves either the old file
|
|
65
|
+
* untouched or the new file complete, never a half-written file.
|
|
66
|
+
*
|
|
67
|
+
* Throws on any I/O failure. The signup_verify tool catches it and
|
|
68
|
+
* surfaces a clean error to the model.
|
|
69
|
+
*/
|
|
70
|
+
export declare function writeCredential(credential: CredentialFile, env?: NodeJS.ProcessEnv): Promise<void>;
|
|
71
|
+
//# sourceMappingURL=credential-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credential-store.d.ts","sourceRoot":"","sources":["../src/credential-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAOH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAMjD;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAGlF;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAsB,cAAc,CAClC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAyBhC;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,eAAe,CACnC,UAAU,EAAE,cAAc,EAC1B,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,IAAI,CAAC,CAef"}
|