@framers/agentos-ext-letterboxd 1.0.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 ADDED
@@ -0,0 +1,98 @@
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, and distribution as defined by Sections 1 through 9 of this document.
10
+
11
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
12
+
13
+ "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
14
+
15
+ "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
16
+
17
+ "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
18
+
19
+ "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
20
+
21
+ "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
22
+
23
+ "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
24
+
25
+ "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
26
+
27
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
28
+
29
+ 2. Grant of Copyright License.
30
+
31
+ Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
32
+
33
+ 3. Grant of Patent License.
34
+
35
+ Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
36
+
37
+ 4. Redistribution.
38
+
39
+ You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
40
+
41
+ (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
42
+
43
+ (b) You must cause any modified files to carry prominent notices stating that You changed the files; and
44
+
45
+ (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
46
+
47
+ (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
48
+
49
+ You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
50
+
51
+ 5. Submission of Contributions.
52
+
53
+ Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
54
+
55
+ 6. Trademarks.
56
+
57
+ This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
58
+
59
+ 7. Disclaimer of Warranty.
60
+
61
+ Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
62
+
63
+ 8. Limitation of Liability.
64
+
65
+ In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
66
+
67
+ 9. Accepting Warranty or Additional Liability.
68
+
69
+ While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
70
+
71
+ END OF TERMS AND CONDITIONS
72
+
73
+ APPENDIX: How to apply the Apache License to your work.
74
+
75
+ To apply the Apache License to your work, attach the following
76
+ boilerplate notice, with the fields enclosed by brackets "[]"
77
+ replaced with your own identifying information. (Don't include
78
+ the brackets!) The text should be enclosed in the appropriate
79
+ comment syntax for the file format. We also recommend that a
80
+ file or class name and description of purpose be included on the
81
+ same "printed page" as the copyright notice for easier
82
+ identification within third-party archives.
83
+
84
+ Copyright (c) 2025 Framers
85
+
86
+ Licensed under the Apache License, Version 2.0 (the "License");
87
+ you may not use this file except in compliance with the License.
88
+ You may obtain a copy of the License at
89
+
90
+ http://www.apache.org/licenses/LICENSE-2.0
91
+
92
+ Unless required by applicable law or agreed to in writing, software
93
+ distributed under the License is distributed on an "AS IS" BASIS,
94
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
95
+ See the License for the specific language governing permissions and
96
+ limitations under the License.
97
+
98
+
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Letterboxd Extension Pack — provides movie lookup capabilities for agents.
3
+ *
4
+ * Exposes a single `letterboxd_movie` tool that scrapes Letterboxd for film
5
+ * metadata, aggregate ratings, director credits, genre tags, and a sample
6
+ * of recent user reviews. No API key required.
7
+ *
8
+ * The tool supports an optional integration with the web-scraper extension's
9
+ * recipe system: when a `web_scrape_recipe`-compatible tool reference is
10
+ * supplied via `options.recipeTool`, the tool delegates scraping to the
11
+ * recipe engine for more robust, tiered fetching. Otherwise it falls back
12
+ * to a lightweight built-in `fetch()` scraper.
13
+ *
14
+ * @module @framers/agentos-ext-letterboxd
15
+ */
16
+ import { LetterboxdMovieTool } from './tools/letterboxdMovie.js';
17
+ import type { RecipeToolLike } from './tools/letterboxdMovie.js';
18
+ /**
19
+ * Configuration options for the Letterboxd extension pack.
20
+ */
21
+ export interface LetterboxdExtensionOptions {
22
+ /**
23
+ * Optional reference to a `web_scrape_recipe`-compatible tool.
24
+ * When provided, the `letterboxd_movie` tool attempts recipe-based
25
+ * scraping before falling back to the built-in scraper.
26
+ */
27
+ recipeTool?: RecipeToolLike;
28
+ /**
29
+ * Descriptor priority for tool ordering.
30
+ * Lower numbers are higher priority. Defaults to `50`.
31
+ */
32
+ priority?: number;
33
+ }
34
+ /**
35
+ * Create the Letterboxd extension pack.
36
+ *
37
+ * @param context - Extension activation context provided by the AgentOS
38
+ * runtime. Must contain an `options` property (or empty
39
+ * object) and optionally a `logger` for lifecycle logging.
40
+ * @returns An extension pack descriptor with a single `letterboxd_movie` tool.
41
+ *
42
+ * @example
43
+ * ```ts
44
+ * import { createExtensionPack } from '@framers/agentos-ext-letterboxd';
45
+ *
46
+ * const pack = createExtensionPack({ options: {} });
47
+ * // pack.descriptors[0].payload is the LetterboxdMovieTool instance
48
+ * ```
49
+ */
50
+ export declare function createExtensionPack(context: any): {
51
+ name: string;
52
+ version: string;
53
+ descriptors: {
54
+ id: string;
55
+ kind: "tool";
56
+ priority: number;
57
+ payload: LetterboxdMovieTool;
58
+ requiredSecrets: never[];
59
+ }[];
60
+ onActivate: () => Promise<any>;
61
+ onDeactivate: () => Promise<any>;
62
+ };
63
+ export { LetterboxdMovieTool };
64
+ export type { LetterboxdMovieInput, LetterboxdMovieOutput, LetterboxdReview, RecipeToolLike, } from './tools/letterboxdMovie.js';
65
+ export default createExtensionPack;
66
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC;;;;OAIG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,GAAG;;;;;;;;;;;;EAqB/C;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAC/B,YAAY,EACV,oBAAoB,EACpB,qBAAqB,EACrB,gBAAgB,EAChB,cAAc,GACf,MAAM,4BAA4B,CAAC;AACpC,eAAe,mBAAmB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,57 @@
1
+ // @ts-nocheck
2
+ /**
3
+ * Letterboxd Extension Pack — provides movie lookup capabilities for agents.
4
+ *
5
+ * Exposes a single `letterboxd_movie` tool that scrapes Letterboxd for film
6
+ * metadata, aggregate ratings, director credits, genre tags, and a sample
7
+ * of recent user reviews. No API key required.
8
+ *
9
+ * The tool supports an optional integration with the web-scraper extension's
10
+ * recipe system: when a `web_scrape_recipe`-compatible tool reference is
11
+ * supplied via `options.recipeTool`, the tool delegates scraping to the
12
+ * recipe engine for more robust, tiered fetching. Otherwise it falls back
13
+ * to a lightweight built-in `fetch()` scraper.
14
+ *
15
+ * @module @framers/agentos-ext-letterboxd
16
+ */
17
+ import { LetterboxdMovieTool } from './tools/letterboxdMovie.js';
18
+ /**
19
+ * Create the Letterboxd extension pack.
20
+ *
21
+ * @param context - Extension activation context provided by the AgentOS
22
+ * runtime. Must contain an `options` property (or empty
23
+ * object) and optionally a `logger` for lifecycle logging.
24
+ * @returns An extension pack descriptor with a single `letterboxd_movie` tool.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { createExtensionPack } from '@framers/agentos-ext-letterboxd';
29
+ *
30
+ * const pack = createExtensionPack({ options: {} });
31
+ * // pack.descriptors[0].payload is the LetterboxdMovieTool instance
32
+ * ```
33
+ */
34
+ export function createExtensionPack(context) {
35
+ const options = (context.options || {});
36
+ const tool = new LetterboxdMovieTool(options.recipeTool);
37
+ return {
38
+ name: '@framers/agentos-ext-letterboxd',
39
+ version: '1.0.0',
40
+ descriptors: [
41
+ {
42
+ // IMPORTANT: ToolExecutor uses descriptor id as the lookup key for tool calls.
43
+ // Keep it aligned with `tool.name`.
44
+ id: tool.name,
45
+ kind: 'tool',
46
+ priority: options.priority || 50,
47
+ payload: tool,
48
+ requiredSecrets: [],
49
+ },
50
+ ],
51
+ onActivate: async () => context.logger?.info('Letterboxd Extension activated'),
52
+ onDeactivate: async () => context.logger?.info('Letterboxd Extension deactivated'),
53
+ };
54
+ }
55
+ export { LetterboxdMovieTool };
56
+ export default createExtensionPack;
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAsBjE;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAY;IAC9C,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,EAAE,CAA+B,CAAC;IACtE,MAAM,IAAI,GAAG,IAAI,mBAAmB,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAEzD,OAAO;QACL,IAAI,EAAE,iCAAiC;QACvC,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE;YACX;gBACE,+EAA+E;gBAC/E,oCAAoC;gBACpC,EAAE,EAAE,IAAI,CAAC,IAAI;gBACb,IAAI,EAAE,MAAe;gBACrB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,EAAE;gBAChC,OAAO,EAAE,IAAI;gBACb,eAAe,EAAE,EAAE;aACpB;SACF;QACD,UAAU,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,gCAAgC,CAAC;QAC9E,YAAY,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,IAAI,CAAC,kCAAkC,CAAC;KACnF,CAAC;AACJ,CAAC;AAED,OAAO,EAAE,mBAAmB,EAAE,CAAC;AAO/B,eAAe,mBAAmB,CAAC"}
@@ -0,0 +1,233 @@
1
+ /**
2
+ * Letterboxd Movie Lookup Tool — ITool implementation for Letterboxd scraping.
3
+ *
4
+ * Retrieves film metadata, aggregate ratings, director credits, genre tags,
5
+ * a synopsis, and a sample of recent reviews from Letterboxd. Uses a
6
+ * two-strategy approach:
7
+ *
8
+ * 1. **Recipe delegation** — if a `web_scrape_recipe` tool reference is
9
+ * provided at construction time, the tool delegates to the web-scraper
10
+ * extension's recipe engine for robust, tiered scraping.
11
+ * 2. **Built-in fallback** — a lightweight `fetch()`-based scraper that
12
+ * parses Letterboxd HTML via regex. No API key or headless browser
13
+ * required; works out of the box for most films.
14
+ *
15
+ * @module tools/letterboxdMovie
16
+ */
17
+ import type { ITool, ToolExecutionContext, ToolExecutionResult, JSONSchemaObject } from '@framers/agentos';
18
+ /**
19
+ * Input parameters for the `letterboxd_movie` tool.
20
+ */
21
+ export interface LetterboxdMovieInput {
22
+ /** Film title to search for on Letterboxd. */
23
+ title: string;
24
+ /**
25
+ * Optional release year to disambiguate titles.
26
+ * When provided, the tool favours search results whose year matches.
27
+ */
28
+ year?: number;
29
+ }
30
+ /**
31
+ * A single user review extracted from a Letterboxd film page.
32
+ */
33
+ export interface LetterboxdReview {
34
+ /** Letterboxd username of the reviewer. */
35
+ user: string;
36
+ /** Star rating string (e.g. "★★★★" or "★★★½"). */
37
+ rating: string;
38
+ /** Truncated review body text. */
39
+ text: string;
40
+ }
41
+ /**
42
+ * Output payload returned by the `letterboxd_movie` tool.
43
+ */
44
+ export interface LetterboxdMovieOutput {
45
+ /** Whether a matching film was found on Letterboxd. */
46
+ found: boolean;
47
+ /** Canonical Letterboxd URL for the film (present when `found` is `true`). */
48
+ url?: string;
49
+ /** Film title as displayed on Letterboxd. */
50
+ title?: string;
51
+ /** Release year string (e.g. "2016"). */
52
+ year?: string;
53
+ /** Aggregate Letterboxd rating string (e.g. "4.1"). */
54
+ rating?: string;
55
+ /** Comma-separated director names. */
56
+ directors?: string;
57
+ /** Comma-separated genre tags. */
58
+ genres?: string;
59
+ /** Short plot synopsis / tagline. */
60
+ synopsis?: string;
61
+ /** Sample of recent user reviews (up to 5). */
62
+ reviews?: LetterboxdReview[];
63
+ }
64
+ /**
65
+ * Minimal shape of a recipe-capable tool that can be injected at
66
+ * construction time. Mirrors the `execute` signature of
67
+ * {@link WebScrapeRecipeTool} without requiring an import dependency.
68
+ */
69
+ export interface RecipeToolLike {
70
+ execute(args: {
71
+ recipe: string;
72
+ params: Record<string, string>;
73
+ }, context: ToolExecutionContext): Promise<{
74
+ success: boolean;
75
+ output?: any;
76
+ error?: string;
77
+ }>;
78
+ }
79
+ /**
80
+ * ITool implementation that looks up movie information on Letterboxd.
81
+ *
82
+ * Supports two execution paths:
83
+ * - **Recipe delegation**: when a `web_scrape_recipe` compatible tool is
84
+ * provided via the constructor, the tool delegates scraping to the
85
+ * web-scraper extension for more robust, tiered fetching.
86
+ * - **Built-in fallback**: a lightweight `fetch()` + regex scraper that
87
+ * works without external dependencies or API keys.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * const tool = new LetterboxdMovieTool();
92
+ * const result = await tool.execute({ title: 'Arrival', year: 2016 }, ctx);
93
+ * if (result.success && result.output?.found) {
94
+ * console.log(result.output.title, result.output.rating);
95
+ * }
96
+ * ```
97
+ */
98
+ export declare class LetterboxdMovieTool implements ITool<LetterboxdMovieInput, LetterboxdMovieOutput> {
99
+ readonly id = "letterboxd-movie-v1";
100
+ readonly name = "letterboxd_movie";
101
+ readonly displayName = "Letterboxd Movie Lookup";
102
+ readonly description: string;
103
+ readonly category = "media";
104
+ readonly version = "1.0.0";
105
+ readonly hasSideEffects = false;
106
+ readonly inputSchema: JSONSchemaObject;
107
+ readonly requiredCapabilities: string[];
108
+ /**
109
+ * Optional reference to a recipe-capable scraping tool.
110
+ * When provided, the tool delegates to the web-scraper extension's
111
+ * recipe engine rather than using the built-in fallback scraper.
112
+ */
113
+ private readonly recipeTool;
114
+ /**
115
+ * Create a new LetterboxdMovieTool.
116
+ *
117
+ * @param recipeTool - Optional reference to a `web_scrape_recipe`-compatible
118
+ * tool. When provided, the tool attempts recipe-based
119
+ * scraping before falling back to the built-in scraper.
120
+ */
121
+ constructor(recipeTool?: RecipeToolLike);
122
+ /**
123
+ * Execute a Letterboxd movie lookup.
124
+ *
125
+ * @param args - The film title (and optional year) to search for.
126
+ * @param context - Tool execution context provided by the AgentOS runtime.
127
+ * @returns A {@link ToolExecutionResult} wrapping a {@link LetterboxdMovieOutput}.
128
+ */
129
+ execute(args: LetterboxdMovieInput, context: ToolExecutionContext): Promise<ToolExecutionResult<LetterboxdMovieOutput>>;
130
+ /**
131
+ * Custom argument validation.
132
+ *
133
+ * @param args - Raw arguments from the LLM.
134
+ * @returns Validation result with error details if invalid.
135
+ */
136
+ validateArgs(args: Record<string, unknown>): {
137
+ isValid: boolean;
138
+ errors?: string[];
139
+ };
140
+ /**
141
+ * Attempt to look up the film via the web-scraper recipe engine.
142
+ *
143
+ * Passes the title (and year if provided) to a `letterboxd-movie` recipe.
144
+ * Returns `null` if the recipe is not available or returns no useful data,
145
+ * signalling the caller to fall back to the built-in scraper.
146
+ *
147
+ * @param title - Film title to search for.
148
+ * @param year - Optional release year.
149
+ * @param context - Tool execution context for the delegated call.
150
+ * @returns A {@link ToolExecutionResult} if the recipe succeeded, or `null`
151
+ * to signal fallback.
152
+ */
153
+ private executeViaRecipe;
154
+ /**
155
+ * Look up the film using the built-in `fetch()` + regex scraper.
156
+ *
157
+ * Performs up to three HTTP requests:
158
+ * 1. **Search** — `GET /search/films/{encodedTitle}/` to find the film slug.
159
+ * 2. **Direct URL** — if search fails (e.g. Cloudflare 403), tries
160
+ * `GET /film/{slug}/` where the slug is derived from the title.
161
+ * Film detail pages are typically not behind Cloudflare challenges.
162
+ * 3. **Film page** — `GET /film/{slug}/` to extract metadata and reviews.
163
+ *
164
+ * @param title - Film title to search for.
165
+ * @param year - Optional release year for disambiguation.
166
+ * @returns A {@link ToolExecutionResult} wrapping the extracted film data.
167
+ */
168
+ private executeViaFallback;
169
+ /**
170
+ * Derive a URL slug from a film title.
171
+ *
172
+ * Lowercases the title, replaces non-alphanumeric runs with hyphens,
173
+ * and strips leading/trailing hyphens.
174
+ *
175
+ * @example
176
+ * ```
177
+ * titleToSlug('The Dark Knight') // => 'the-dark-knight'
178
+ * titleToSlug('Parasite') // => 'parasite'
179
+ * ```
180
+ *
181
+ * @param title - Film title to slugify.
182
+ * @returns A URL-safe slug string.
183
+ */
184
+ private titleToSlug;
185
+ /**
186
+ * Search Letterboxd for a film and return the slug of the best match.
187
+ *
188
+ * Parses the search results HTML for film links, optionally filtering
189
+ * by year when provided.
190
+ *
191
+ * @param title - Film title query string.
192
+ * @param year - Optional year to prefer in search results.
193
+ * @returns The film slug (e.g. "arrival-2016") or `null` if not found.
194
+ */
195
+ private searchFilmSlug;
196
+ /**
197
+ * Fetch a page from Letterboxd with realistic browser headers.
198
+ *
199
+ * Follows redirects and returns the response body as a string.
200
+ * Returns `null` on non-2xx status codes or network errors.
201
+ *
202
+ * @param url - Fully qualified URL to fetch.
203
+ * @returns HTML body string or `null` on failure.
204
+ */
205
+ private fetchPage;
206
+ /**
207
+ * Parse a Letterboxd film page HTML and extract structured metadata.
208
+ *
209
+ * Uses regex patterns to extract:
210
+ * - Title and year from the headline / head section
211
+ * - Aggregate rating from the rating histogram section
212
+ * - Director names from the crew section
213
+ * - Genre tags from the genre tab
214
+ * - Synopsis from the truncated description
215
+ * - A sample of recent user reviews
216
+ *
217
+ * @param html - Raw HTML of the film page.
218
+ * @param filmUrl - Canonical URL for inclusion in the output.
219
+ * @returns A {@link LetterboxdMovieOutput} with extracted data.
220
+ */
221
+ private parseFilmPage;
222
+ /**
223
+ * Extract a sample of user reviews from a Letterboxd film page.
224
+ *
225
+ * Looks for review blocks in the "popular reviews" or "recent reviews"
226
+ * section and extracts username, star rating, and review text.
227
+ *
228
+ * @param html - Raw HTML of the film page.
229
+ * @returns An array of up to {@link MAX_REVIEWS} parsed reviews.
230
+ */
231
+ private parseReviews;
232
+ }
233
+ //# sourceMappingURL=letterboxdMovie.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"letterboxdMovie.d.ts","sourceRoot":"","sources":["../../src/tools/letterboxdMovie.ts"],"names":[],"mappings":"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"}