@hue-run/sdk 0.9.0 → 0.11.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.
Files changed (56) hide show
  1. package/CLI.md +240 -49
  2. package/ENVIRONMENTS.md +48 -9
  3. package/EVALUATIONS.md +41 -21
  4. package/README.md +70 -30
  5. package/dist/cli/eval-direct.d.ts +12 -1
  6. package/dist/cli/eval-direct.js +145 -33
  7. package/dist/cli/eval.d.ts +28 -1
  8. package/dist/cli/eval.js +504 -81
  9. package/dist/cli/listen.d.ts +76 -0
  10. package/dist/cli/listen.js +816 -0
  11. package/dist/cli/mcp.d.ts +65 -7
  12. package/dist/cli/mcp.js +271 -73
  13. package/dist/client.d.ts +7 -4
  14. package/dist/client.js +36 -10
  15. package/dist/evals/checkpoint.d.ts +15 -1
  16. package/dist/evals/checkpoint.js +34 -3
  17. package/dist/evals/client.d.ts +24 -4
  18. package/dist/evals/client.js +92 -38
  19. package/dist/evals/environment-target.d.ts +18 -3
  20. package/dist/evals/environment-target.js +22 -10
  21. package/dist/evals/exit-cleanup.d.ts +4 -0
  22. package/dist/evals/exit-cleanup.js +26 -0
  23. package/dist/evals/files.d.ts +69 -3
  24. package/dist/evals/files.js +255 -42
  25. package/dist/evals/json.js +116 -9
  26. package/dist/evals/local-worker.d.ts +21 -3
  27. package/dist/evals/local-worker.js +14 -0
  28. package/dist/evals/runner.d.ts +45 -0
  29. package/dist/evals/runner.js +199 -21
  30. package/dist/evals/scenarios.d.ts +7 -5
  31. package/dist/evals/scenarios.js +71 -14
  32. package/dist/evals/scorer-publication.js +58 -3
  33. package/dist/evals/simulation.d.ts +17 -4
  34. package/dist/evals/simulation.js +8 -0
  35. package/dist/evals/types.d.ts +48 -0
  36. package/dist/evals/verdicts.d.ts +26 -2
  37. package/dist/evals/verdicts.js +72 -9
  38. package/dist/evals.d.ts +4 -3
  39. package/dist/evals.js +2 -2
  40. package/dist/inline-files.d.ts +4 -0
  41. package/dist/inline-files.js +48 -17
  42. package/dist/provider-tools.d.ts +12 -1
  43. package/dist/provider-tools.js +192 -106
  44. package/dist/safety.d.ts +7 -1
  45. package/dist/safety.js +9 -7
  46. package/dist/setup/cli.js +31 -8
  47. package/dist/setup/peers.d.ts +13 -0
  48. package/dist/setup/peers.js +44 -0
  49. package/dist/snapshot.d.ts +2 -2
  50. package/dist/snapshot.js +47 -12
  51. package/dist/tool-definitions.d.ts +18 -0
  52. package/dist/tool-definitions.js +232 -0
  53. package/dist/transport.js +2 -2
  54. package/dist/version.d.ts +1 -1
  55. package/dist/version.js +1 -1
  56. package/package.json +1 -1
@@ -0,0 +1,76 @@
1
+ import { lookup as dnsLookup } from "node:dns";
2
+ /**
3
+ * `hue listen`: delivers a simulated world's events to a receiver on this machine, the way a
4
+ * provider would post them to a public request URL. The client pulls leased deliveries from Hue
5
+ * with the subscription's own credential (a world token or a connection key, never a project
6
+ * key), forwards each stored request unchanged to the local URL, and acknowledges it with the
7
+ * local answer. Every pull is one bounded request; nothing holds a connection open. A delivery is
8
+ * acknowledged only after the receiver answered or its window closed, so stopping never marks an
9
+ * event delivered that was not: an unacknowledged lease lapses and Hue retries it on the
10
+ * provider's schedule.
11
+ */
12
+ /** Streams, environment, network and signal seams for {@link runListenCommand}; tests inject these. */
13
+ export interface ListenCommandIo {
14
+ stdout?: NodeJS.WritableStream;
15
+ stderr?: NodeJS.WritableStream;
16
+ env?: NodeJS.ProcessEnv;
17
+ cwd?: string;
18
+ fetch?: typeof fetch;
19
+ /** Registers the stop request (SIGINT and SIGTERM by default) and returns its removal. */
20
+ onInterrupt?: (listener: () => void) => () => void;
21
+ /** The acknowledgement window a forward waits for; the provider's three seconds by default. */
22
+ forwardTimeoutMs?: number;
23
+ /** Delays between retries of a failed pull. */
24
+ retryDelaysMs?: readonly number[];
25
+ }
26
+ export declare const LISTEN_USAGE = "Usage: hue listen --subscription ID --forward-to URL [--origin URL] [--env-path PATH]\n [--credential world-token|connection-key] [--max N] [--allow-remote-forward]\n\nDeliver a simulated world's events to a receiver on this machine. Hue's signed requests (Slack\nEvents API requests today) are pulled with the subscription's own credential, forwarded unchanged\nto --forward-to, and acknowledged with the receiver's answer. Press Ctrl+C to stop: pulls stop,\ndeliveries in flight are finished and acknowledged, and nothing unanswered is acknowledged.\n\nThe credential is read from the environment, never from the command line:\n HUE_WORLD_TOKEN the world token, for a subscription on one world\n HUE_CONNECTION_KEY the connection key, for a subscription on a connection key\nA project key (HUE_API_KEY, HUE_MCP_KEY) is refused.\n\nOptions:\n --subscription ID The listen subscription to deliver (its id from Hue)\n --forward-to URL The local receiver, for example http://localhost:3000/slack/events\n --origin URL Hue origin (default HUE_BASE_URL, then https://app.hue.run)\n --env-path PATH Load a dotenv file first (--env-file also works when it exists)\n --credential KIND world-token or connection-key, when both variables are set\n --max N Deliveries leased per pull and forwarded at once, 1 to 10 (default 10)\n --allow-remote-forward Allow a --forward-to host other than this machine, over https only\n -h, --help Show this help";
27
+ /** A leased delivery: the exact request the provider would send. */
28
+ interface Delivery {
29
+ deliveryId: string;
30
+ eventId: string | null;
31
+ kind: "url_verification" | "event_callback";
32
+ retryNum: number;
33
+ /** The lease's end as the server stated it, or null when absent. */
34
+ leaseExpiresAt: number | null;
35
+ request: {
36
+ headers: Record<string, string>;
37
+ body: string;
38
+ };
39
+ }
40
+ /** The local answer, in the acknowledgement's own shape. */
41
+ interface LocalAnswer {
42
+ outcome: "response" | "timeout" | "connection_failed" | "tls_error";
43
+ status?: number;
44
+ durationMs: number;
45
+ noRetry?: boolean;
46
+ body?: string;
47
+ }
48
+ /** A loopback address: 127.0.0.0/8, ::1, or 127.0.0.0/8 carried in IPv4-mapped IPv6. */
49
+ export declare function isLoopbackAddress(address: string): boolean;
50
+ /**
51
+ * The receiver URL, or why it is refused: HTTP or HTTPS without credentials or fragment, on this
52
+ * machine (`localhost`, a `.localhost` name or a loopback address) unless `allowRemote`, and then
53
+ * HTTPS only off this machine.
54
+ */
55
+ export declare function parseForwardTarget(value: string, allowRemote: boolean): URL | string;
56
+ /**
57
+ * Sends one delivery to the receiver and reports its answer, or null when `signal` abandoned it.
58
+ * The body bytes and every header go out unchanged (the provider's signature covers them), no
59
+ * redirect is followed, and the answer counts only inside `timeoutMs`. Only a URL verification's
60
+ * successful answer body is read.
61
+ */
62
+ export declare function forwardDelivery(target: URL, delivery: Delivery, options?: {
63
+ timeoutMs?: number;
64
+ allowRemote?: boolean;
65
+ signal?: AbortSignal;
66
+ /** Resolves `--forward-to` names; tests stand in for DNS. */
67
+ resolver?: typeof dnsLookup;
68
+ }): Promise<LocalAnswer | null>;
69
+ /** One delivery from a pull answer, or null when it is not one this client can forward safely. */
70
+ export declare function parseDelivery(value: unknown, subscriptionId: string): Delivery | null;
71
+ /**
72
+ * Runs `hue listen` and returns the process exit code: 0 stopped, 1 failed, 2 usage error, 130
73
+ * interrupted twice (acknowledgements abandoned). `argv` may start with the `listen` command word.
74
+ */
75
+ export declare function runListenCommand(argv: string[], io?: ListenCommandIo): Promise<number>;
76
+ export {};