@parcha/agentrun-serve 0.1.0-beta.48 → 0.1.0-beta.49

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 (106) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +144 -16
  3. package/dist/agent-delete.d.ts +33 -10
  4. package/dist/agent-delete.js +184 -26
  5. package/dist/agents-store.d.ts +6 -2
  6. package/dist/agents-store.js +18 -5
  7. package/dist/agents.d.ts +8 -1
  8. package/dist/agents.js +14 -4
  9. package/dist/answer-json.d.ts +2 -2
  10. package/dist/answer-json.js +3 -4
  11. package/dist/archil-routes.d.ts +1 -1
  12. package/dist/archil-routes.js +4 -3
  13. package/dist/browser-sessions.d.ts +56 -0
  14. package/dist/browser-sessions.js +117 -0
  15. package/dist/computer-routes.d.ts +4 -15
  16. package/dist/computer-routes.js +6 -10
  17. package/dist/console/assets/index-Bzn4eUYF.js +715 -0
  18. package/dist/console/assets/index-CR2ZGei1.css +1 -0
  19. package/dist/console/index.html +2 -2
  20. package/dist/errors.d.ts +4 -1
  21. package/dist/errors.js +15 -5
  22. package/dist/import.js +4 -3
  23. package/dist/learn/check.d.ts +11 -2
  24. package/dist/learn/check.js +12 -9
  25. package/dist/learn/promote.d.ts +7 -1
  26. package/dist/learn/promote.js +47 -0
  27. package/dist/learn/repick.d.ts +34 -0
  28. package/dist/learn/repick.js +201 -0
  29. package/dist/learned-workflow.d.ts +2 -0
  30. package/dist/learned-workflow.js +18 -1
  31. package/dist/learning-setting.d.ts +13 -0
  32. package/dist/learning-setting.js +23 -1
  33. package/dist/llms.txt +1 -1
  34. package/dist/openapi.js +170 -12
  35. package/dist/paid-calls.d.ts +4 -1
  36. package/dist/paid-calls.js +1 -1
  37. package/dist/run-learning-served.d.ts +1 -1
  38. package/dist/run-usage.d.ts +110 -0
  39. package/dist/run-usage.js +312 -0
  40. package/dist/runner/adapter-loop.js +51 -20
  41. package/dist/runner/conformance/harness.d.ts +2 -0
  42. package/dist/runner/conformance/harness.js +18 -4
  43. package/dist/runner/feedback-round.d.ts +29 -1
  44. package/dist/runner/feedback-round.js +54 -3
  45. package/dist/runner/journal-kinds.d.ts +3 -1
  46. package/dist/runner/learning-end.js +49 -18
  47. package/dist/runner/loop-contract.d.ts +3 -0
  48. package/dist/runner/monid-run.js +2 -2
  49. package/dist/runner/promotion.js +8 -2
  50. package/dist/runner/reflect-hook.js +3 -2
  51. package/dist/runs-over-store.d.ts +3 -2
  52. package/dist/runs-over-store.js +9 -7
  53. package/dist/server.d.ts +3 -3
  54. package/dist/server.js +221 -98
  55. package/dist/store/index.d.ts +2 -2
  56. package/dist/store/index.js +1 -1
  57. package/dist/store/journal/storage.js +1 -1
  58. package/dist/store/open.d.ts +1 -1
  59. package/dist/store/open.js +1 -1
  60. package/dist/store/postgres/migrations/0021_purged.sql +13 -0
  61. package/dist/store/postgres/migrations/0022_computer_intervals.sql +27 -0
  62. package/dist/store/schema.d.ts +15 -1
  63. package/dist/store/schema.js +50 -5
  64. package/dist/store/sqlite/connection.d.ts +4 -1
  65. package/dist/store/sqlite/connection.js +5 -0
  66. package/dist/store/sqlite/run-patch.d.ts +8 -3
  67. package/dist/store/sqlite/run-patch.js +15 -7
  68. package/dist/store/sqlite/store.d.ts +5 -2
  69. package/dist/store/sqlite/store.js +249 -48
  70. package/dist/store/sqlite/worker.d.ts +9 -0
  71. package/dist/store/sqlite/worker.js +18 -1
  72. package/dist/store/store.d.ts +142 -9
  73. package/dist/store/store.js +63 -0
  74. package/dist/store-reads/analytics.js +2 -1
  75. package/dist/store-reads/cap.d.ts +8 -2
  76. package/dist/store-reads/cap.js +27 -3
  77. package/dist/store-reads/learning.d.ts +1 -1
  78. package/dist/store-reads/learning.js +5 -2
  79. package/dist/store-reads/runs.js +2 -0
  80. package/dist/store-reads/stats.js +4 -2
  81. package/dist/store-view.d.ts +7 -0
  82. package/dist/store-view.js +61 -20
  83. package/dist/tools.js +9 -0
  84. package/dist/trigger-targets.d.ts +7 -4
  85. package/dist/trigger-targets.js +6 -6
  86. package/dist/triggers.d.ts +2 -1
  87. package/dist/triggers.js +5 -2
  88. package/dist/validate.d.ts +4 -2
  89. package/dist/validate.js +13 -3
  90. package/dist/viewer-credential.d.ts +3 -4
  91. package/dist/viewer-credential.js +6 -4
  92. package/dist/workspace/computer-for-claim.d.ts +5 -1
  93. package/dist/workspace/computer-for-claim.js +47 -18
  94. package/dist/workspace/computer-intervals.d.ts +20 -0
  95. package/dist/workspace/computer-intervals.js +49 -0
  96. package/dist/workspace/computer-janitor.d.ts +7 -3
  97. package/dist/workspace/computer-janitor.js +14 -6
  98. package/dist/workspace/computer-kept.d.ts +7 -2
  99. package/dist/workspace/computer-kept.js +9 -2
  100. package/dist/workspace/resolve-computer.d.ts +7 -4
  101. package/dist/workspace/resolve-computer.js +21 -32
  102. package/dist/workspace/run-end-computers.d.ts +1 -0
  103. package/dist/workspace/run-end-computers.js +4 -1
  104. package/package.json +10 -10
  105. package/dist/console/assets/index-CTGegcKt.css +0 -1
  106. package/dist/console/assets/index-D1Se6mgG.js +0 -715
@@ -19,20 +19,9 @@ export declare const COMPUTER_ROUTES: ReadonlySet<string>;
19
19
  export declare const TAKE_OVER_MINUTES: number;
20
20
  /** Run `runId`'s desktop or phone, from the store: its kind, whether it is up, and who drives it. */
21
21
  export declare function computerViewOf(store: ComputerCallStore, runId: string, options?: ComputerCallOptions): Promise<ComputerViewRead>;
22
- /** How a request to one of the routes came: by the owner's signed-in page, or with a token (the server's, checked before
23
- * this); whether this server is API-only (its token is then its backend's, and takes the routes); whether this server
24
- * has accounts (for the refusal's words); its body. */
25
- export type ComputerRequest = {
26
- readonly ownerSession: boolean;
27
- readonly token: boolean;
28
- readonly apiOnly: boolean;
29
- readonly accounts: boolean;
30
- readonly body?: unknown;
31
- };
32
22
  /**
33
- * One of our routes (COMPUTER_ROUTES, by its name in serve's route table) for run `runId`: { hold, outcome? }, or an
34
- * ApiError. A token is refused (forbidden): a take-over drives the computer, so it takes the owner's signed-in page, as a
35
- * run's browser does; on an API-only server, which has no owner, the server's token takes it. The take-over takes an
36
- * empty body; the hand-back an `outcome` (done or cancelled) at most. Serve's dispatch sends what this answers.
23
+ * One of our routes (COMPUTER_ROUTES, by its name in serve's route table) for run `runId`, with the request's body:
24
+ * { hold, outcome? }, or an ApiError. The caller was admitted already (server.ts). The take-over takes an empty body; the
25
+ * hand-back an `outcome` (done or cancelled) at most. Serve's dispatch sends what this answers.
37
26
  */
38
- export declare function computerRoute(name: string, runId: string, request: ComputerRequest, store: ComputerCallStore, options?: ComputerCallOptions): Promise<ComputerHoldAnswer>;
27
+ export declare function computerRoute(name: string, runId: string, request: unknown, store: ComputerCallStore, options?: ComputerCallOptions): Promise<ComputerHoldAnswer>;
@@ -1,7 +1,7 @@
1
1
  // A run's desktop or phone, as its owner takes it: POST /v2/runs/{id}/computer/take-over and POST .../computer/hand-back
2
2
  // (the hand-back for every kind: a browser's answers its agent's ask, as POST .../browser/hand-back does). Owner-only, as
3
- // a run's browser is: the owner's password session in the console, never a token; on an API-only server (api-only.ts),
4
- // which has no owner, the server's token, its backend's own. GET /v2/runs/{id}/computer is answered by
3
+ // a run's browser is; server.ts decides who may call them, with GET /v2/runs/{id}/computer, under one guard (the owner's
4
+ // password session, or on an API-only server the server's token). GET /v2/runs/{id}/computer is answered by
5
5
  // server.ts from computerView (computer-view.ts) over computerHoldOf; computerViewOf is the store-backed read of the run's
6
6
  // computer the take-over tests check against.
7
7
  //
@@ -30,16 +30,12 @@ export async function computerViewOf(store, runId, options = {}) {
30
30
  return { kind, state: "live", hold: holdShown(hold, await store.commands(runId, 0)).state };
31
31
  }
32
32
  /**
33
- * One of our routes (COMPUTER_ROUTES, by its name in serve's route table) for run `runId`: { hold, outcome? }, or an
34
- * ApiError. A token is refused (forbidden): a take-over drives the computer, so it takes the owner's signed-in page, as a
35
- * run's browser does; on an API-only server, which has no owner, the server's token takes it. The take-over takes an
36
- * empty body; the hand-back an `outcome` (done or cancelled) at most. Serve's dispatch sends what this answers.
33
+ * One of our routes (COMPUTER_ROUTES, by its name in serve's route table) for run `runId`, with the request's body:
34
+ * { hold, outcome? }, or an ApiError. The caller was admitted already (server.ts). The take-over takes an empty body; the
35
+ * hand-back an `outcome` (done or cancelled) at most. Serve's dispatch sends what this answers.
37
36
  */
38
37
  export async function computerRoute(name, runId, request, store, options = {}) {
39
- if (!request.ownerSession && request.token && !request.apiOnly) {
40
- throw new ApiError("forbidden", request.accounts ? "A run's computer takes the owner's password sign-in in the console, never a token." : "A run's computer takes the owner's password sign-in, and this server has no accounts (AGENTRUN_ACCOUNTS=0).");
41
- }
42
- const body = request.body ?? {};
38
+ const body = request ?? {};
43
39
  if (typeof body !== "object" || body === null || Array.isArray(body))
44
40
  throw new ApiError("input_invalid", "the body is a JSON object");
45
41
  const given = body;