humanish 0.125.0 → 0.127.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 (128) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/actors/computer-use/actor.d.ts +2 -0
  3. package/dist/actors/computer-use/actor.js +1 -0
  4. package/dist/actors/computer-use/loop/clock.d.ts +9 -8
  5. package/dist/actors/computer-use/loop/clock.js +27 -17
  6. package/dist/actors/computer-use/loop/debrief.d.ts +1 -1
  7. package/dist/actors/computer-use/loop/debrief.js +15 -5
  8. package/dist/actors/computer-use/loop/ending.d.ts +10 -5
  9. package/dist/actors/computer-use/loop/ending.js +12 -7
  10. package/dist/actors/computer-use/loop/observation.d.ts +6 -0
  11. package/dist/actors/computer-use/loop/observation.js +19 -1
  12. package/dist/actors/computer-use/loop/session.d.ts +4 -2
  13. package/dist/actors/computer-use/loop/session.js +4 -1
  14. package/dist/actors/computer-use/loop/trace.js +4 -2
  15. package/dist/actors/computer-use/loop/types.d.ts +22 -8
  16. package/dist/actors/computer-use/loop.js +5 -5
  17. package/dist/actors/computer-use/openai-provider.js +1 -1
  18. package/dist/actors/contract.d.ts +31 -8
  19. package/dist/actors/contract.js +3 -0
  20. package/dist/actors/goal-source.d.ts +32 -2
  21. package/dist/actors/goal-source.js +41 -2
  22. package/dist/actors/stop-cause.js +1 -0
  23. package/dist/analysis/evidence-sources.js +2 -2
  24. package/dist/analysis/types.d.ts +2 -2
  25. package/dist/analysis/validation.js +2 -1
  26. package/dist/cli/commands/study.js +8 -0
  27. package/dist/evidence/redaction.d.ts +1 -0
  28. package/dist/evidence/redaction.js +1 -0
  29. package/dist/evidence/trace-page.d.ts +6 -0
  30. package/dist/evidence/trace-page.js +90 -0
  31. package/dist/observer/data.js +8 -5
  32. package/dist/observer/feed-cursors.d.ts +14 -0
  33. package/dist/observer/feed-cursors.js +61 -0
  34. package/dist/observer/participant-items.d.ts +7 -0
  35. package/dist/observer/pinned-files.d.ts +2 -1
  36. package/dist/observer/pinned-files.js +2 -2
  37. package/dist/observer/run-routes.d.ts +1 -1
  38. package/dist/observer/run-routes.js +38 -17
  39. package/dist/observer-app.html +7 -7
  40. package/dist/routes/computer-use/bundle.js +4 -0
  41. package/dist/routes/computer-use/diagnostics.d.ts +1 -1
  42. package/dist/routes/computer-use/diagnostics.js +3 -3
  43. package/dist/routes/computer-use/e2b-desktop/desktop.js +2 -1
  44. package/dist/routes/computer-use/e2b-desktop/prepare.d.ts +6 -0
  45. package/dist/routes/computer-use/e2b-desktop/prepare.js +47 -1
  46. package/dist/routes/computer-use/e2b-desktop/start.d.ts +2 -1
  47. package/dist/routes/computer-use/e2b-desktop/start.js +15 -3
  48. package/dist/routes/computer-use/e2b-desktop/state.d.ts +3 -1
  49. package/dist/routes/computer-use/e2b-desktop/state.js +2 -0
  50. package/dist/routes/computer-use/fanout-bundle.js +3 -0
  51. package/dist/routes/computer-use/fanout-records.js +5 -1
  52. package/dist/routes/computer-use/participant-deps.d.ts +1 -1
  53. package/dist/routes/computer-use/participant-desktop.d.ts +1 -1
  54. package/dist/routes/computer-use/participant-execution.js +6 -2
  55. package/dist/routes/computer-use/participant-facts.js +4 -1
  56. package/dist/routes/computer-use/participant-model.js +16 -6
  57. package/dist/routes/computer-use/participant-runs.d.ts +10 -10
  58. package/dist/routes/computer-use/participant-runs.js +54 -84
  59. package/dist/routes/computer-use/plan.d.ts +2 -0
  60. package/dist/routes/computer-use/plan.js +65 -17
  61. package/dist/routes/computer-use/rerun-selection.js +8 -5
  62. package/dist/routes/computer-use/setup.d.ts +1 -0
  63. package/dist/routes/computer-use/setup.js +29 -1
  64. package/dist/routes/computer-use/single-bundle.d.ts +5 -1
  65. package/dist/routes/computer-use/single-bundle.js +11 -1
  66. package/dist/routes/computer-use/types.d.ts +18 -13
  67. package/dist/routes/computer-use/types.js +0 -3
  68. package/dist/routes/shared-world/bundle-records.js +4 -1
  69. package/dist/routes/shared-world/external-public.js +1 -1
  70. package/dist/routes/shared-world/participant-specs.js +3 -2
  71. package/dist/routes/shared-world/plan.d.ts +2 -0
  72. package/dist/routes/shared-world/plan.js +8 -3
  73. package/dist/routes/shared-world/provisioned.js +1 -1
  74. package/dist/run/bundle.d.ts +11 -1
  75. package/dist/run/contained-output.d.ts +7 -3
  76. package/dist/run/contained-output.js +11 -7
  77. package/dist/run/judge.d.ts +14 -4
  78. package/dist/run/judge.js +17 -12
  79. package/dist/run/live-items.d.ts +19 -0
  80. package/dist/run/live-items.js +28 -8
  81. package/dist/run/notes.js +1 -1
  82. package/dist/run/outcomes.d.ts +8 -2
  83. package/dist/run/outcomes.js +56 -14
  84. package/dist/run/stream-trace.d.ts +25 -4
  85. package/dist/run/stream-trace.js +55 -17
  86. package/dist/run/streams.d.ts +16 -0
  87. package/dist/study/arrivals.d.ts +105 -34
  88. package/dist/study/arrivals.js +179 -74
  89. package/dist/study/bundle-estimate.d.ts +12 -10
  90. package/dist/study/bundle-estimate.js +138 -72
  91. package/dist/study/desktop-files.d.ts +37 -0
  92. package/dist/study/desktop-files.js +174 -0
  93. package/dist/study/keys.d.ts +8 -0
  94. package/dist/study/keys.js +3 -0
  95. package/dist/study/migrate/v2.js +12 -3
  96. package/dist/study/parse/actors.d.ts +1 -1
  97. package/dist/study/parse/actors.js +28 -20
  98. package/dist/study/parse/clock.d.ts +18 -0
  99. package/dist/study/parse/clock.js +36 -0
  100. package/dist/study/plan-participants.d.ts +19 -10
  101. package/dist/study/plan-participants.js +13 -9
  102. package/dist/study/plan-types.d.ts +6 -1
  103. package/dist/study/plan.d.ts +2 -1
  104. package/dist/study/plan.js +28 -15
  105. package/dist/study/preflight.js +4 -0
  106. package/dist/study/types.d.ts +35 -5
  107. package/dist/study/validation.js +3 -0
  108. package/dist/study/warnings.d.ts +2 -2
  109. package/dist/study/warnings.js +7 -0
  110. package/dist/subject/local-tree-archive.d.ts +7 -0
  111. package/dist/subject/local-tree-archive.js +12 -0
  112. package/dist/substrates/e2b/desktop-browser.d.ts +4 -1
  113. package/dist/substrates/e2b/desktop-browser.js +6 -2
  114. package/dist/substrates/e2b/desktop-clock.d.ts +10 -0
  115. package/dist/substrates/e2b/desktop-clock.js +29 -0
  116. package/dist/substrates/e2b/lifetime.d.ts +22 -8
  117. package/dist/substrates/e2b/lifetime.js +54 -10
  118. package/dist/substrates/e2b/sdk.d.ts +6 -0
  119. package/dist/verify/pages.d.ts +7 -0
  120. package/dist/verify/pages.js +50 -0
  121. package/dist/verify/verify.js +10 -3
  122. package/docs/architecture/actor-contract.md +2 -0
  123. package/docs/architecture/external-public-shared-world.md +4 -1
  124. package/docs/architecture/observer.md +10 -1
  125. package/docs/contracts/policy.md +7 -0
  126. package/docs/contracts/run-bundle.md +31 -1
  127. package/docs/contracts/schemas.md +93 -11
  128. package/package.json +2 -2
@@ -10,12 +10,13 @@ import { listRuns } from "../run/stored-runs.js";
10
10
  import { readAnalysisAccounting } from "../run/costs.js";
11
11
  import { bindExistingRunArtifactPaths, isPathInside, isSafeRunIdSegment, } from "../run/paths.js";
12
12
  import { isRunOutcome } from "../run/bundle-shape.js";
13
- import { displayedTraces, loadStreamTraces } from "../run/stream-trace.js";
13
+ import { displayedTraces, loadStreamTraces, } from "../run/stream-trace.js";
14
14
  import { isNodeError, isRecord } from "../run/type-guards.js";
15
15
  import { MAX_NOTE_FILE_BYTES, readRunNotes, RUN_NOTES_DIR, } from "../run/note-files.js";
16
16
  import { analysisCostOf, runCost, runCostLabel } from "../run/run-cost.js";
17
17
  import { RUN_STATUS_FILE, RUN_STATUS_STALE_MS, isRunStatusRecord, } from "../run/status.js";
18
18
  import { renderObserverHtml } from "./artifact.js";
19
+ import { parseFeedCursors, withFeedCursors } from "./feed-cursors.js";
19
20
  import { splitObserverData } from "./participant-items.js";
20
21
  import { buildObserverData, observerDataFromSaved, recordedStreamEmbed, withObserverEndings, } from "./data.js";
21
22
  import { buildArtifactSecurityHeaders } from "./http.js";
@@ -103,14 +104,14 @@ export async function serveRunPath(runRoot, relativePath, response, runtimeStrea
103
104
  return;
104
105
  }
105
106
  if (cleanedRelativePath === "observer/index.html") {
106
- const observerData = await observerDataOrReason(runRoot, runtimeStreamUrls);
107
- if ("unavailable" in observerData) {
108
- writeResponse(response, 404, `Observer data not found: ${observerData.unavailable}`, "text/plain; charset=utf-8");
107
+ const observed = await observerDataOrReason(runRoot, runtimeStreamUrls);
108
+ if ("unavailable" in observed) {
109
+ writeResponse(response, 404, `Observer data not found: ${observed.unavailable}`, "text/plain; charset=utf-8");
109
110
  return;
110
111
  }
111
112
  const analysis = await readObserverAnalysis(runRoot);
112
113
  const notes = await readRunNotes(servedNoteFiles(runRoot));
113
- writeResponse(response, 200, renderObserverHtml(observerData, {
114
+ writeResponse(response, 200, renderObserverHtml(observed.data, {
114
115
  analysis,
115
116
  notes,
116
117
  ...(notesToken === undefined ? {} : { notesToken }),
@@ -121,15 +122,17 @@ export async function serveRunPath(runRoot, relativePath, response, runtimeStrea
121
122
  // polls observer-feed.json, the same data with the items, so one projection serves each poll.
122
123
  if (cleanedRelativePath === "observer/observer-data.json" ||
123
124
  cleanedRelativePath === "observer/observer-feed.json") {
124
- const observerData = await observerDataOrReason(runRoot, runtimeStreamUrls);
125
- if ("unavailable" in observerData) {
126
- writeResponse(response, 404, `Observer data not found: ${observerData.unavailable}`, "text/plain; charset=utf-8");
125
+ const observed = await observerDataOrReason(runRoot, runtimeStreamUrls, cleanedRelativePath === "observer/observer-feed.json"
126
+ ? requestedCursors(runRoot, request)
127
+ : undefined);
128
+ if ("unavailable" in observed) {
129
+ writeResponse(response, 404, `Observer data not found: ${observed.unavailable}`, "text/plain; charset=utf-8");
127
130
  return;
128
131
  }
129
- const { shell, items } = splitObserverData(observerData);
132
+ const { shell, items } = splitObserverData(observed.data);
130
133
  writeResponse(response, 200, cleanedRelativePath === "observer/observer-data.json"
131
134
  ? JSON.stringify(shell, null, 2)
132
- : JSON.stringify({ data: shell, items }), "application/json; charset=utf-8");
135
+ : JSON.stringify({ data: shell, items: withFeedCursors(items, observed.live) }), "application/json; charset=utf-8");
133
136
  return;
134
137
  }
135
138
  if (cleanedRelativePath === "observer/study-analysis.json") {
@@ -163,19 +166,31 @@ export async function serveRunPath(runRoot, relativePath, response, runtimeStrea
163
166
  writeResponse(response, 404, "Not found", "text/plain; charset=utf-8");
164
167
  }
165
168
  }
169
+ /**
170
+ * The live cursors a feed poll sends in `after`. A root that checks reads against admitted files
171
+ * and digests gets none: its digest check covers whole files, and it serves only finished runs.
172
+ */
173
+ function requestedCursors(runRoot, request) {
174
+ if (runRoot.admitsFile !== undefined ||
175
+ runRoot.admitsContent !== undefined ||
176
+ request?.url === undefined)
177
+ return undefined;
178
+ return parseFeedCursors(new URL(request.url, "http://observer.invalid").searchParams.get("after"));
179
+ }
166
180
  /** The run's trace files, read through its pinned folder. */
167
181
  function pinnedTraceReader(runRoot) {
168
- return async (relativePath, maxBytes, length) => {
182
+ return async (relativePath, maxBytes, length, start) => {
169
183
  const bytes = await readContainedFile(runRoot, path.join(runRoot.physicalPath, relativePath), {
170
184
  maxBytes,
171
185
  ...(length === undefined ? {} : { length }),
186
+ ...(start === undefined ? {} : { start }),
172
187
  }).catch(() => null);
173
188
  return bytes === null ? { refused: `${relativePath} could not be read` } : { bytes };
174
189
  };
175
190
  }
176
191
  async function readObserverData(runRoot, runtimeStreamUrls = []) {
177
192
  const read = await observerDataOrReason(runRoot, runtimeStreamUrls);
178
- return "unavailable" in read ? null : read;
193
+ return "unavailable" in read ? null : read.data;
179
194
  }
180
195
  /**
181
196
  * The run's Observer data, or why there is none. run.json is the source: each trace is loaded
@@ -185,7 +200,7 @@ async function readObserverData(runRoot, runtimeStreamUrls = []) {
185
200
  * cannot be read, parsed or used as a bundle (which a browser poll can meet mid-write) gives the
186
201
  * reason, a 404 the poller retries, never the saved projection.
187
202
  */
188
- async function observerDataOrReason(runRoot, runtimeStreamUrls) {
203
+ async function observerDataOrReason(runRoot, runtimeStreamUrls, cursors) {
189
204
  const record = await readLocalRunStatus(runRoot);
190
205
  const runJson = path.join(runRoot.physicalPath, "run.json");
191
206
  const bundleBytes = await readContainedFile(runRoot, runJson).catch(() => null);
@@ -194,8 +209,10 @@ async function observerDataOrReason(runRoot, runtimeStreamUrls) {
194
209
  // A root admitted for safe serving checks every read against the identity and digest admitted
195
210
  // with the run's share_ready verification, so a run.json changed since then is refused, and the
196
211
  // saved projection it may serve is the one admitted with the verified run.
197
- if (absent || (bundleBytes === null && runRoot.admitsContent !== undefined))
198
- return savedObserverData(runRoot, record, runtimeStreamUrls);
212
+ if (absent || (bundleBytes === null && runRoot.admitsContent !== undefined)) {
213
+ const saved = await savedObserverData(runRoot, record, runtimeStreamUrls);
214
+ return "unavailable" in saved ? saved : { data: saved, live: [] };
215
+ }
199
216
  if (bundleBytes === null)
200
217
  return { unavailable: "run.json is there but could not be read: it is a link or changed." };
201
218
  let stored;
@@ -209,8 +226,12 @@ async function observerDataOrReason(runRoot, runtimeStreamUrls) {
209
226
  return { unavailable: "run.json is not a run bundle; it may be mid-write, so try again." };
210
227
  }
211
228
  try {
212
- const bundle = displayedTraces(await loadStreamTraces(pinnedTraceReader(runRoot), stored));
213
- return withRuntimeStreamUrls(withLocalRunStatus(record, buildObserverData(bundle, undefined, record), bundle.outcome), runtimeStreamUrls);
229
+ const loaded = await loadStreamTraces(pinnedTraceReader(runRoot), stored, cursors === undefined ? {} : { liveAfter: (index) => cursors.get(index.path) });
230
+ const bundle = displayedTraces(loaded);
231
+ return {
232
+ data: withRuntimeStreamUrls(withLocalRunStatus(record, buildObserverData(bundle, undefined, record), bundle.outcome), runtimeStreamUrls),
233
+ live: loaded.live,
234
+ };
214
235
  }
215
236
  catch {
216
237
  return { unavailable: "run.json could not be shown as a run." };