@ruakit/agent 0.0.0-stage → 0.1.0-alpha.1

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 (73) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +4 -0
  3. package/dist/approval.d.ts +17 -0
  4. package/dist/approval.d.ts.map +1 -0
  5. package/dist/approval.js +3 -0
  6. package/dist/approval.js.map +7 -0
  7. package/dist/constants.d.ts +12 -0
  8. package/dist/constants.d.ts.map +1 -0
  9. package/dist/constants.js +3 -0
  10. package/dist/constants.js.map +7 -0
  11. package/dist/decision-runtime.d.ts +5 -0
  12. package/dist/decision-runtime.d.ts.map +1 -0
  13. package/dist/decision-runtime.js +3 -0
  14. package/dist/decision-runtime.js.map +7 -0
  15. package/dist/errors.d.ts +22 -0
  16. package/dist/errors.d.ts.map +1 -0
  17. package/dist/errors.js +3 -0
  18. package/dist/errors.js.map +7 -0
  19. package/dist/index.d.ts +22 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +3 -0
  22. package/dist/index.js.map +7 -0
  23. package/dist/operations.d.ts +10 -0
  24. package/dist/operations.d.ts.map +1 -0
  25. package/dist/operations.js +3 -0
  26. package/dist/operations.js.map +7 -0
  27. package/dist/plan-transport.d.ts +11 -0
  28. package/dist/plan-transport.d.ts.map +1 -0
  29. package/dist/plan-transport.js +3 -0
  30. package/dist/plan-transport.js.map +7 -0
  31. package/dist/plan.d.ts +47 -0
  32. package/dist/plan.d.ts.map +1 -0
  33. package/dist/plan.js +3 -0
  34. package/dist/plan.js.map +7 -0
  35. package/dist/request-outcome.d.ts +43 -0
  36. package/dist/request-outcome.d.ts.map +1 -0
  37. package/dist/request-outcome.js +3 -0
  38. package/dist/request-outcome.js.map +7 -0
  39. package/dist/request-state.d.ts +84 -0
  40. package/dist/request-state.d.ts.map +1 -0
  41. package/dist/request-state.js +3 -0
  42. package/dist/request-state.js.map +7 -0
  43. package/dist/runtime.d.ts +29 -0
  44. package/dist/runtime.d.ts.map +1 -0
  45. package/dist/runtime.js +3 -0
  46. package/dist/runtime.js.map +7 -0
  47. package/dist/session.d.ts +49 -0
  48. package/dist/session.d.ts.map +1 -0
  49. package/dist/session.js +3 -0
  50. package/dist/session.js.map +7 -0
  51. package/dist/transport.d.ts +11 -0
  52. package/dist/transport.d.ts.map +1 -0
  53. package/dist/transport.js +3 -0
  54. package/dist/transport.js.map +7 -0
  55. package/dist/user-interruption.d.ts +6 -0
  56. package/dist/user-interruption.d.ts.map +1 -0
  57. package/dist/user-interruption.js +25 -0
  58. package/dist/user-interruption.js.map +1 -0
  59. package/package.json +32 -3
  60. package/src/approval.ts +47 -0
  61. package/src/constants.ts +13 -0
  62. package/src/decision-runtime.ts +26 -0
  63. package/src/errors.ts +56 -0
  64. package/src/index.ts +50 -0
  65. package/src/operations.ts +71 -0
  66. package/src/plan-transport.ts +82 -0
  67. package/src/plan.ts +468 -0
  68. package/src/request-outcome.ts +58 -0
  69. package/src/request-state.ts +189 -0
  70. package/src/runtime.ts +88 -0
  71. package/src/session.ts +408 -0
  72. package/src/transport.ts +52 -0
  73. package/README.md +0 -3
@@ -0,0 +1,52 @@
1
+ // Copyright 2026 RuaKit contributors. SPDX-License-Identifier: MIT
2
+ import { decisionSchema } from '@ruakit/schema';
3
+ import type { DecisionRequest, Decision } from '@ruakit/schema';
4
+ import { RuaKitError, parsePayload } from './errors.js';
5
+
6
+ /** Replace HTTP with another planner without changing browser execution. */
7
+ export interface RuaKitTransport {
8
+ dom(request: DecisionRequest, signal: AbortSignal): Promise<Decision>;
9
+ }
10
+
11
+ export interface HttpTransportOptions {
12
+ serverUrl?: string;
13
+ fetch?: typeof globalThis.fetch;
14
+ }
15
+
16
+ export function createHttpTransport(options: HttpTransportOptions = {}): RuaKitTransport {
17
+ const fetcher = options.fetch ?? globalThis.fetch.bind(globalThis);
18
+ const base = (options.serverUrl ?? '').replace(/\/$/, '');
19
+ return {
20
+ async dom(request, signal) {
21
+ const response = await fetcher(`${base}/v1/plan`, {
22
+ method: 'POST',
23
+ signal,
24
+ cache: 'no-store',
25
+ headers: { 'Content-Type': 'application/json' },
26
+ body: JSON.stringify(request),
27
+ });
28
+ let data: unknown;
29
+ try {
30
+ data = await response.json();
31
+ } catch (cause) {
32
+ throw new RuaKitError('HTTP_ERROR', 'The server returned invalid JSON.', { cause });
33
+ }
34
+ if (!response.ok) {
35
+ const message =
36
+ typeof data === 'object' &&
37
+ data !== null &&
38
+ 'error' in data &&
39
+ typeof data.error === 'string'
40
+ ? data.error
41
+ : `RuaKit request failed (${response.status}).`;
42
+ throw new RuaKitError('HTTP_ERROR', message);
43
+ }
44
+ return parsePayload(
45
+ decisionSchema,
46
+ data,
47
+ 'INVALID_PLAN',
48
+ 'The server returned an invalid decision.',
49
+ );
50
+ },
51
+ };
52
+ }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.