@helloleo/plugins 0.1.11 → 0.1.12

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/dist/index.js CHANGED
@@ -12332,10 +12332,10 @@ function tool(input) {
12332
12332
  tool.schema = exports_external;
12333
12333
  // src/tools/inspect-http.ts
12334
12334
  var z = tool.schema;
12335
- var ALLOWED_EXACT_HOSTS = new Set(["api.app.helloleo.dev"]);
12336
- var ALLOWED_HOST_SUFFIXES = [
12337
- ".augustin-d60.workers.dev",
12338
- ".live.helloleo.dev"
12335
+ var ALLOWED_BASE_HOSTS = [
12336
+ "helloleo.dev",
12337
+ "helloleo.app",
12338
+ "augustin-d60.workers.dev"
12339
12339
  ];
12340
12340
  var DEFAULT_TIMEOUT_MS = 15000;
12341
12341
  var MAX_TIMEOUT_MS = 30000;
@@ -12343,7 +12343,7 @@ var MAX_RESPONSE_BYTES = 1e6;
12343
12343
  var METHODS = ["GET", "POST", "PUT", "PATCH", "DELETE"];
12344
12344
  var METHODS_AUTO_JSON = new Set(["POST", "PUT", "PATCH"]);
12345
12345
  var argsShape = {
12346
- url: z.string().describe("Fully-qualified URL to request. Must be on the HelloLeo whitelist " + "(api.app.helloleo.dev, *.augustin-d60.workers.dev, *.live.helloleo.dev)."),
12346
+ url: z.string().describe("Fully-qualified URL to request. Must be on the HelloLeo whitelist " + "(**.helloleo.dev, **.helloleo.app, **.augustin-d60.workers.dev)."),
12347
12347
  method: z.enum(METHODS).default("GET").describe(`HTTP method (${METHODS.join(", ")}). Defaults to GET.`),
12348
12348
  body: z.string().optional().describe("Request body as a string. Not valid for GET. Sent with " + "Content-Type: application/json on POST/PUT/PATCH unless a " + "different Content-Type is supplied via headers."),
12349
12349
  headers: z.record(z.string(), z.string()).default({}).describe("Optional additional request headers as key/value pairs (e.g. Authorization)."),
@@ -12351,7 +12351,7 @@ var argsShape = {
12351
12351
  };
12352
12352
  var argsSchema = z.object(argsShape);
12353
12353
  var inspectHttp = tool({
12354
- description: "Send an HTTP request to a HelloLeo endpoint and return the status code, " + "response headers, and response body. Use this to inspect the live behaviour " + "of HelloLeo workers, the production API, or preview deployments so you can " + "self-debug instead of operating blind. " + "Only URLs on the HelloLeo whitelist are allowed: " + "api.app.helloleo.dev, *.augustin-d60.workers.dev, *.live.helloleo.dev. " + "Supports GET, POST, PUT, PATCH and DELETE (with an optional JSON body).",
12354
+ description: "Send an HTTP request to a HelloLeo endpoint and return the status code, " + "response headers, and response body. Use this to inspect the live behaviour " + "of HelloLeo workers, the production API, or preview deployments so you can " + "self-debug instead of operating blind. ",
12355
12355
  args: argsShape,
12356
12356
  async execute(rawArgs, context) {
12357
12357
  const args = argsSchema.parse(rawArgs);
@@ -12437,17 +12437,12 @@ function parseTargetUrl(raw) {
12437
12437
  return url2;
12438
12438
  }
12439
12439
  function allowedHostsHuman() {
12440
- return [
12441
- ...ALLOWED_EXACT_HOSTS,
12442
- ...ALLOWED_HOST_SUFFIXES.map((s) => `*${s}`)
12443
- ].join(", ");
12440
+ return ALLOWED_BASE_HOSTS.map((base) => `**.${base}`).join(", ");
12444
12441
  }
12445
12442
  function isAllowedHost(hostname3) {
12446
12443
  const host = hostname3.toLowerCase().replace(/\.$/, "");
12447
- if (ALLOWED_EXACT_HOSTS.has(host))
12448
- return true;
12449
- for (const suffix of ALLOWED_HOST_SUFFIXES) {
12450
- if (host.endsWith(suffix) && host.length > suffix.length)
12444
+ for (const base of ALLOWED_BASE_HOSTS) {
12445
+ if (host === base || host.endsWith(`.${base}`))
12451
12446
  return true;
12452
12447
  }
12453
12448
  return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@helloleo/plugins",
3
- "version": "0.1.11",
3
+ "version": "0.1.12",
4
4
  "description": "OpenCode plugins for HelloLeo",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -3,10 +3,10 @@ import { tool } from "@opencode-ai/plugin";
3
3
 
4
4
  const z = tool.schema;
5
5
 
6
- const ALLOWED_EXACT_HOSTS = new Set(["api.app.helloleo.dev"]);
7
- const ALLOWED_HOST_SUFFIXES = [
8
- ".augustin-d60.workers.dev",
9
- ".live.helloleo.dev",
6
+ const ALLOWED_BASE_HOSTS = [
7
+ "helloleo.dev",
8
+ "helloleo.app",
9
+ "augustin-d60.workers.dev",
10
10
  ] as const;
11
11
 
12
12
  const DEFAULT_TIMEOUT_MS = 15_000;
@@ -22,7 +22,7 @@ const argsShape = {
22
22
  .string()
23
23
  .describe(
24
24
  "Fully-qualified URL to request. Must be on the HelloLeo whitelist " +
25
- "(api.app.helloleo.dev, *.augustin-d60.workers.dev, *.live.helloleo.dev).",
25
+ "(**.helloleo.dev, **.helloleo.app, **.augustin-d60.workers.dev).",
26
26
  ),
27
27
  method: z
28
28
  .enum(METHODS)
@@ -58,10 +58,7 @@ export const inspectHttp = tool({
58
58
  "Send an HTTP request to a HelloLeo endpoint and return the status code, " +
59
59
  "response headers, and response body. Use this to inspect the live behaviour " +
60
60
  "of HelloLeo workers, the production API, or preview deployments so you can " +
61
- "self-debug instead of operating blind. " +
62
- "Only URLs on the HelloLeo whitelist are allowed: " +
63
- "api.app.helloleo.dev, *.augustin-d60.workers.dev, *.live.helloleo.dev. " +
64
- "Supports GET, POST, PUT, PATCH and DELETE (with an optional JSON body).",
61
+ "self-debug instead of operating blind. ",
65
62
  args: argsShape,
66
63
  async execute(rawArgs, context) {
67
64
  const args = argsSchema.parse(rawArgs);
@@ -180,17 +177,13 @@ function parseTargetUrl(raw: string): URL {
180
177
  }
181
178
 
182
179
  function allowedHostsHuman(): string {
183
- return [
184
- ...ALLOWED_EXACT_HOSTS,
185
- ...ALLOWED_HOST_SUFFIXES.map((s) => `*${s}`),
186
- ].join(", ");
180
+ return ALLOWED_BASE_HOSTS.map((base) => `**.${base}`).join(", ");
187
181
  }
188
182
 
189
183
  function isAllowedHost(hostname: string): boolean {
190
184
  const host = hostname.toLowerCase().replace(/\.$/, "");
191
- if (ALLOWED_EXACT_HOSTS.has(host)) return true;
192
- for (const suffix of ALLOWED_HOST_SUFFIXES) {
193
- if (host.endsWith(suffix) && host.length > suffix.length) return true;
185
+ for (const base of ALLOWED_BASE_HOSTS) {
186
+ if (host === base || host.endsWith(`.${base}`)) return true;
194
187
  }
195
188
  return false;
196
189
  }
@@ -1,22 +0,0 @@
1
- type Success<T> = {
2
- data: T;
3
- error: null;
4
- };
5
-
6
- type Failure<E> = {
7
- data: null;
8
- error: E;
9
- };
10
-
11
- type Result<T, E = Error> = Success<T> | Failure<E>;
12
-
13
- export async function tryCatch<T, E = Error>(
14
- promise: Promise<T>,
15
- ): Promise<Result<T, E>> {
16
- try {
17
- const data = await promise;
18
- return { data, error: null };
19
- } catch (error) {
20
- return { data: null, error: error as E };
21
- }
22
- }