humanish 0.136.1 → 0.138.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 (99) hide show
  1. package/CHANGELOG.md +23 -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/observation.js +2 -0
  5. package/dist/actors/computer-use/loop/session.d.ts +3 -2
  6. package/dist/actors/computer-use/loop/session.js +8 -12
  7. package/dist/actors/computer-use/loop/types.d.ts +14 -1
  8. package/dist/cli/commands/runs.js +2 -2
  9. package/dist/cli/doctor.js +24 -0
  10. package/dist/evidence/browser-network.d.ts +108 -0
  11. package/dist/evidence/browser-network.js +516 -0
  12. package/dist/evidence/trace-page.d.ts +31 -1
  13. package/dist/evidence/trace-page.js +68 -2
  14. package/dist/keys/key-resolution.js +53 -2
  15. package/dist/observer-app.html +2 -2
  16. package/dist/routes/computer-use/bundle.js +1 -0
  17. package/dist/routes/computer-use/e2b-desktop/desktop.js +6 -0
  18. package/dist/routes/computer-use/e2b-desktop/fidelity.d.ts +12 -1
  19. package/dist/routes/computer-use/e2b-desktop/fidelity.js +7 -2
  20. package/dist/routes/computer-use/e2b-desktop/network.d.ts +52 -0
  21. package/dist/routes/computer-use/e2b-desktop/network.js +153 -0
  22. package/dist/routes/computer-use/e2b-desktop/start.js +18 -1
  23. package/dist/routes/computer-use/e2b-desktop/state.d.ts +3 -0
  24. package/dist/routes/computer-use/e2b-desktop/state.js +2 -0
  25. package/dist/routes/computer-use/e2b-desktop/teardown.js +6 -3
  26. package/dist/routes/computer-use/fanout-records.js +10 -0
  27. package/dist/routes/computer-use/participant-desktop.d.ts +7 -2
  28. package/dist/routes/computer-use/participant-model.js +2 -1
  29. package/dist/routes/computer-use/plan.js +2 -1
  30. package/dist/routes/computer-use/single-bundle.d.ts +3 -0
  31. package/dist/routes/computer-use/single-bundle.js +4 -0
  32. package/dist/routes/computer-use/types.d.ts +7 -0
  33. package/dist/routes/scripted/plan.js +2 -2
  34. package/dist/routes/shared-world/plan.js +3 -2
  35. package/dist/routes/terminal/live-sandbox.d.ts +2 -0
  36. package/dist/routes/terminal/live-sandbox.js +8 -3
  37. package/dist/routes/terminal/plan.js +51 -8
  38. package/dist/routes/terminal/session.js +8 -1
  39. package/dist/run/bundle.d.ts +2 -1
  40. package/dist/run/cost-summary.js +9 -4
  41. package/dist/run/live-items.d.ts +20 -2
  42. package/dist/run/live-items.js +23 -14
  43. package/dist/run/pricing.d.ts +11 -0
  44. package/dist/run/pricing.js +18 -5
  45. package/dist/run/reclaim-outcomes.d.ts +4 -1
  46. package/dist/run/reclaim-outcomes.js +8 -6
  47. package/dist/run/reclaim.d.ts +4 -1
  48. package/dist/run/reclaim.js +81 -34
  49. package/dist/run/sandbox-creates.d.ts +7 -4
  50. package/dist/run/sandbox-creates.js +17 -9
  51. package/dist/run/sandbox-receipts.d.ts +13 -5
  52. package/dist/run/sandbox-receipts.js +18 -6
  53. package/dist/run/streams.d.ts +7 -0
  54. package/dist/study/composition-rules.js +11 -10
  55. package/dist/study/config.js +4 -1
  56. package/dist/study/doctor.js +1 -1
  57. package/dist/study/keys.d.ts +3 -0
  58. package/dist/study/keys.js +2 -0
  59. package/dist/study/parse/comms.js +1 -20
  60. package/dist/study/parse/execution.js +35 -3
  61. package/dist/study/parse/values.d.ts +5 -0
  62. package/dist/study/parse/values.js +22 -0
  63. package/dist/study/plan-base.js +6 -1
  64. package/dist/study/plan-types.d.ts +5 -2
  65. package/dist/study/requirements.js +7 -2
  66. package/dist/study/routing.d.ts +1 -1
  67. package/dist/study/routing.js +1 -1
  68. package/dist/study/study-fields.d.ts +7 -1
  69. package/dist/study/study-fields.js +10 -0
  70. package/dist/study/types.d.ts +12 -1
  71. package/dist/study/validation.d.ts +8 -0
  72. package/dist/study/validation.js +31 -2
  73. package/dist/substrates/detached.d.ts +5 -0
  74. package/dist/substrates/detached.js +9 -0
  75. package/dist/substrates/e2b/cdp-network-capture.d.ts +23 -0
  76. package/dist/substrates/e2b/cdp-network-capture.js +194 -0
  77. package/dist/substrates/e2b/cdp-probe.d.ts +20 -5
  78. package/dist/substrates/e2b/cdp-probe.js +98 -34
  79. package/dist/substrates/e2b/desktop-cdp.d.ts +32 -2
  80. package/dist/substrates/e2b/desktop-cdp.js +87 -5
  81. package/dist/substrates/e2b/desktop-resources.d.ts +4 -2
  82. package/dist/substrates/e2b/desktop-resources.js +2 -2
  83. package/dist/substrates/e2b/peer-install.js +1 -1
  84. package/dist/substrates/e2b/sandbox.d.ts +3 -0
  85. package/dist/substrates/e2b/sandbox.js +5 -4
  86. package/dist/substrates/modal/image.d.ts +9 -0
  87. package/dist/substrates/modal/image.js +36 -0
  88. package/dist/substrates/modal/sandbox.d.ts +26 -0
  89. package/dist/substrates/modal/sandbox.js +367 -0
  90. package/dist/substrates/modal/sdk.d.ts +112 -0
  91. package/dist/substrates/modal/sdk.js +61 -0
  92. package/dist/verify/network.d.ts +10 -0
  93. package/dist/verify/network.js +162 -0
  94. package/dist/verify/pages.js +1 -16
  95. package/dist/verify/verify.js +8 -2
  96. package/docs/architecture/terminal-product-route.md +1 -1
  97. package/docs/contracts/run-bundle.md +90 -3
  98. package/docs/contracts/schemas.md +6 -5
  99. package/package.json +8 -2
@@ -7,6 +7,7 @@
7
7
  // examples document;
8
8
  // 3. the owning vendor's native store, where one exists:
9
9
  // E2B_API_KEY <- ~/.e2b/config.json (written by `e2b auth login`);
10
+ // MODAL_TOKEN_ID, MODAL_TOKEN_SECRET <- ~/.modal.toml (written by `modal token new`);
10
11
  // GH_TOKEN <- `gh auth token` (the gh CLI's credential chain);
11
12
  // 4. the humanish user-level store `$XDG_CONFIG_HOME/humanish/keys.env`, written only by
12
13
  // `humanish keys set` (0600, prompted or --stdin), the fallback for vendors that ship
@@ -20,6 +21,7 @@ import { spawn } from "node:child_process";
20
21
  import { chmodSync, closeSync, constants as fsConstants, existsSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, writeSync, } from "node:fs";
21
22
  import { homedir } from "node:os";
22
23
  import path from "node:path";
24
+ import { parse as parseToml } from "smol-toml";
23
25
  import { loadEnvFile } from "./env-file.js";
24
26
  import { cli } from "../cli/invocation.js";
25
27
  import { humanishConfigFile } from "../cli/user-config.js";
@@ -48,6 +50,14 @@ const PROVIDER_KEYS = [
48
50
  listed: { order: 1, use: "hosted desktops" },
49
51
  doctor: true,
50
52
  },
53
+ {
54
+ name: "MODAL_TOKEN_ID",
55
+ vendor: "modal",
56
+ login: "modal token new",
57
+ },
58
+ { name: "MODAL_TOKEN_SECRET", login: "modal token new" },
59
+ // Which Modal environment sandboxes are created in; not a secret, but it names the account.
60
+ { name: "MODAL_ENVIRONMENT" },
51
61
  { name: "ANTHROPIC_API_KEY", vendor: "anthropic" },
52
62
  {
53
63
  name: "GH_TOKEN",
@@ -81,6 +91,36 @@ export function userKeyStorePath(env, deps = {}) {
81
91
  function e2bConfigPath(deps) {
82
92
  return path.join(deps.homeDir ?? homedir(), ".e2b", "config.json");
83
93
  }
94
+ /**
95
+ * The token pair and environment of the Modal CLI's profile, as Modal picks it: MODAL_PROFILE
96
+ * when set, else the profile marked `active`, else the only profile. Null when there is none.
97
+ */
98
+ function readModalProfile(env, deps) {
99
+ try {
100
+ const file = env.MODAL_CONFIG_PATH?.trim() || path.join(deps.homeDir ?? homedir(), ".modal.toml");
101
+ if (!isRegularFile(file))
102
+ return null;
103
+ const profiles = [];
104
+ for (const [name, values] of Object.entries(parseToml(readFileSync(file, "utf8"))))
105
+ if (values !== null && typeof values === "object" && !Array.isArray(values))
106
+ profiles.push([name, values]);
107
+ const named = env.MODAL_PROFILE?.trim();
108
+ const profile = named
109
+ ? profiles.find(([name]) => name === named)?.[1]
110
+ : (profiles.find(([, values]) => values.active === true)?.[1] ??
111
+ (profiles.length === 1 ? profiles[0]?.[1] : undefined));
112
+ const text = (value) => typeof value === "string" && value.trim() !== "" ? value.trim() : undefined;
113
+ const tokenId = text(profile?.token_id);
114
+ const tokenSecret = text(profile?.token_secret);
115
+ if (tokenId === undefined || tokenSecret === undefined)
116
+ return null;
117
+ const environment = text(profile?.environment);
118
+ return { tokenId, tokenSecret, ...(environment === undefined ? {} : { environment }) };
119
+ }
120
+ catch {
121
+ return null;
122
+ }
123
+ }
84
124
  /** Default exec: bounded, quiet, stdin closed; null on any failure. Never throws. */
85
125
  function defaultExecText(command, args, timeoutMs, env) {
86
126
  return new Promise((resolve) => {
@@ -205,7 +245,18 @@ export async function discoverProviderKeys(args) {
205
245
  if (teamKey !== null)
206
246
  fill("E2B_API_KEY", teamKey, "~/.e2b/config.json (e2b auth login)");
207
247
  }
208
- // Rung 3b: the gh CLI's credential chain. Only consulted when neither GitHub env name is
248
+ // Rung 3b: the modal CLI's profile. Both tokens come from the same profile or neither does.
249
+ if (fillable("MODAL_TOKEN_ID") && fillable("MODAL_TOKEN_SECRET")) {
250
+ const profile = readModalProfile(env, deps);
251
+ if (profile !== null) {
252
+ const source = "~/.modal.toml (modal token new)";
253
+ fill("MODAL_TOKEN_ID", profile.tokenId, source);
254
+ fill("MODAL_TOKEN_SECRET", profile.tokenSecret, source);
255
+ if (profile.environment !== undefined && fillable("MODAL_ENVIRONMENT"))
256
+ fill("MODAL_ENVIRONMENT", profile.environment, source);
257
+ }
258
+ }
259
+ // Rung 3c: the gh CLI's credential chain. Only consulted when neither GitHub env name is
209
260
  // present; fills GH_TOKEN (the name humanish reads first). gh runs without any provider key in
210
261
  // its environment, so the keys the rungs above just filled stay in this process.
211
262
  if (fillable("GH_TOKEN") && fillable("GITHUB_TOKEN")) {
@@ -265,7 +316,7 @@ export function describeMissingKeys(names, env) {
265
316
  const strict = env.HUMANISH_STRICT_KEYS?.trim() === "1";
266
317
  const chain = strict
267
318
  ? "key discovery is disabled (HUMANISH_STRICT_KEYS=1); only process env and --dotenv are read"
268
- : `also checked ${PROJECT_OVERLAY_RELATIVE}, ~/.e2b/config.json, gh auth token, and ${path.join("~", ".config", "humanish", "keys.env")}`;
319
+ : `also checked ${PROJECT_OVERLAY_RELATIVE}, ~/.e2b/config.json, ~/.modal.toml, gh auth token, and ${path.join("~", ".config", "humanish", "keys.env")}`;
269
320
  return `${chain}. Fill: ${hints}.`;
270
321
  }
271
322
  /**