@agentproto/runtime 5.2.1 → 5.4.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.
package/dist/config.mjs CHANGED
@@ -11,8 +11,8 @@ import '@agentproto/provider-presets';
11
11
  import '@agentproto/secrets/provision/recipe';
12
12
  import { z } from 'zod';
13
13
  import '@agentproto/auth';
14
- import 'child_process';
15
14
  import '@agentproto/command-sandbox';
15
+ import 'child_process';
16
16
  import '@agentproto/plugin-local-browser';
17
17
  import '@modelcontextprotocol/sdk/types.js';
18
18
  import '@agentproto/provider-kit';
@@ -57,11 +57,13 @@ var __copyProps = (to, from, except, desc) => {
57
57
  var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget);
58
58
 
59
59
  // src/worktree-isolation.ts
60
- var WORKTREE_ISOLATION_ENV, DEFAULT_WORKTREE_ISOLATION;
60
+ var WORKTREE_ISOLATION_ENV, WORKTREE_PROVISION_CONCURRENCY_ENV, DEFAULT_WORKTREE_PROVISION_CONCURRENCY, DEFAULT_WORKTREE_ISOLATION;
61
61
  var init_worktree_isolation = __esm({
62
62
  "src/worktree-isolation.ts"() {
63
63
  init_config();
64
64
  WORKTREE_ISOLATION_ENV = "AGENTPROTO_WORKTREES_ISOLATION";
65
+ WORKTREE_PROVISION_CONCURRENCY_ENV = "AGENTPROTO_WORKTREES_PROVISION_CONCURRENCY";
66
+ DEFAULT_WORKTREE_PROVISION_CONCURRENCY = 2;
65
67
  DEFAULT_WORKTREE_ISOLATION = "on-request";
66
68
  }
67
69
  });
@@ -319,9 +321,9 @@ async function exportClaudeCodeSession(adapterSessionId, cwd, configDir) {
319
321
  let stream;
320
322
  try {
321
323
  stream = createReadStream(filePath, { encoding: "utf8" });
322
- await new Promise((resolve16, reject) => {
324
+ await new Promise((resolve17, reject) => {
323
325
  stream.once("error", reject);
324
- stream.once("open", resolve16);
326
+ stream.once("open", resolve17);
325
327
  });
326
328
  } catch (err) {
327
329
  const code = err.code;
@@ -595,7 +597,7 @@ async function discoverHermesSessions(cwd, since, expectedId) {
595
597
  }
596
598
  async function defaultHermesRunner(adapterSessionId) {
597
599
  const { spawn: spawn5 } = await import('child_process');
598
- return new Promise((resolve16, reject) => {
600
+ return new Promise((resolve17, reject) => {
599
601
  const chunks = [];
600
602
  const errChunks = [];
601
603
  const proc = spawn5(
@@ -614,7 +616,7 @@ async function defaultHermesRunner(adapterSessionId) {
614
616
  )
615
617
  );
616
618
  } else {
617
- resolve16(Buffer.concat(chunks).toString("utf8"));
619
+ resolve17(Buffer.concat(chunks).toString("utf8"));
618
620
  }
619
621
  });
620
622
  });
@@ -651,9 +653,9 @@ async function exportDaemonEventsSession(sessionId, desc) {
651
653
  let stream;
652
654
  try {
653
655
  stream = createReadStream(filePath, { encoding: "utf8" });
654
- await new Promise((resolve16, reject) => {
656
+ await new Promise((resolve17, reject) => {
655
657
  stream.once("error", reject);
656
- stream.once("open", resolve16);
658
+ stream.once("open", resolve17);
657
659
  });
658
660
  } catch (err) {
659
661
  const code = err.code;
@@ -1924,6 +1926,10 @@ var init_pr_provenance_stamp = __esm({
1924
1926
  init_pr_provenance();
1925
1927
  }
1926
1928
  });
1929
+ var init_app_boundary = __esm({
1930
+ "src/app-boundary.ts"() {
1931
+ }
1932
+ });
1927
1933
  var init_command_allowlist = __esm({
1928
1934
  "src/command-allowlist.ts"() {
1929
1935
  }
@@ -1932,10 +1938,16 @@ var init_command_tools = __esm({
1932
1938
  "src/command-tools.ts"() {
1933
1939
  init_sessions();
1934
1940
  init_pr_provenance_stamp();
1941
+ init_app_boundary();
1935
1942
  init_command_allowlist();
1936
1943
  init_command_allowlist();
1937
1944
  }
1938
1945
  });
1946
+ var init_process_stats = __esm({
1947
+ "src/process-stats.ts"() {
1948
+ z.preprocess((v) => v === "true" ? true : v === "false" ? false : v, z.union([z.boolean(), z.literal("full")])).optional();
1949
+ }
1950
+ });
1939
1951
  var init_workspaces_config = __esm({
1940
1952
  "src/workspaces-config.ts"() {
1941
1953
  }
@@ -1958,7 +1970,7 @@ var init_bundles = __esm({
1958
1970
  id: bundleIdSchema,
1959
1971
  label: z.string().min(1),
1960
1972
  description: z.string().min(1).optional(),
1961
- mcpImports: z.array(z.string().min(1)),
1973
+ mcpImports: z.union([z.array(z.string().min(1)), z.literal("*")]),
1962
1974
  includeDaemon: z.boolean().optional(),
1963
1975
  skills: z.array(z.string().min(1))
1964
1976
  });
@@ -1987,6 +1999,12 @@ var init_launch_config = __esm({
1987
1999
  }
1988
2000
  });
1989
2001
 
2002
+ // src/adapter-slug-hint.ts
2003
+ var init_adapter_slug_hint = __esm({
2004
+ "src/adapter-slug-hint.ts"() {
2005
+ }
2006
+ });
2007
+
1990
2008
  // src/context-continuity.ts
1991
2009
  var init_context_continuity = __esm({
1992
2010
  "src/context-continuity.ts"() {
@@ -2209,6 +2227,7 @@ var init_sandbox_adapters = __esm({
2209
2227
  });
2210
2228
  var init_session_spawn = __esm({
2211
2229
  "src/session-spawn.ts"() {
2230
+ init_process_stats();
2212
2231
  init_sessions();
2213
2232
  init_transcript_writer();
2214
2233
  init_workspaces_config();
@@ -2221,6 +2240,7 @@ var init_session_spawn = __esm({
2221
2240
  init_claude_code_oauth_source();
2222
2241
  init_providers_store();
2223
2242
  init_catalog_models();
2243
+ init_adapter_slug_hint();
2224
2244
  init_context_continuity();
2225
2245
  init_canonical_posture();
2226
2246
  init_user_presets();
@@ -2232,6 +2252,7 @@ var init_session_spawn = __esm({
2232
2252
  init_agents_md();
2233
2253
  init_workspace_rules();
2234
2254
  init_session_title();
2255
+ init_app_boundary();
2235
2256
  init_inference_binding();
2236
2257
  init_mcp_credential_deps();
2237
2258
  init_sandbox_agent_session_proxy();
@@ -2583,6 +2604,7 @@ var init_agent_tools = __esm({
2583
2604
  "src/agent-tools.ts"() {
2584
2605
  init_transcript_export();
2585
2606
  init_agent_start_schema();
2607
+ init_process_stats();
2586
2608
  init_spawn_field_schemas();
2587
2609
  init_session_spawn();
2588
2610
  init_canonical_posture();
@@ -2673,6 +2695,7 @@ var init_context_checkpoint = __esm({
2673
2695
  // src/session-continue-fresh.ts
2674
2696
  var init_session_continue_fresh = __esm({
2675
2697
  "src/session-continue-fresh.ts"() {
2698
+ init_app_boundary();
2676
2699
  init_context_checkpoint();
2677
2700
  init_context_continuity();
2678
2701
  init_session_spawn();
@@ -2733,6 +2756,21 @@ var init_gh_provenance_shim = __esm({
2733
2756
  DEFAULT_WRAP_GH = false;
2734
2757
  }
2735
2758
  });
2759
+ var DEFAULT_MODEL_ROLES;
2760
+ var init_model_roles = __esm({
2761
+ "src/model-roles.ts"() {
2762
+ DEFAULT_MODEL_ROLES = {
2763
+ /** Reviewer for a small residual (repo-maintenance `review` step). */
2764
+ "review.small": "claude-sonnet-5-5",
2765
+ /** Reviewer for a large residual + the retry reviewer. */
2766
+ "review.large": "claude-opus-5-5",
2767
+ /** CI pull-request reviewer (mirrors `.github/agentic-review.json`'s `reviewerModel`). */
2768
+ "review.pr": "openrouter/z-ai/glm-5.3-flash",
2769
+ /** The session-steward's agent judge. */
2770
+ "judge.session": "claude-sonnet-5-5"
2771
+ };
2772
+ }
2773
+ });
2736
2774
  function validateConfig(raw) {
2737
2775
  const result = agentprotoConfigSchema.safeParse(raw);
2738
2776
  if (result.success) return { ok: true, issues: [] };
@@ -2742,7 +2780,7 @@ function validateConfig(raw) {
2742
2780
  });
2743
2781
  return { ok: false, issues };
2744
2782
  }
2745
- var contextContinuityPolicySchema, deferredToolsConfigSchema, spawnBrowserModeSchema, optionsMapSchema, defaultsAdapterAuthConfigSchema, defaultsAdapterConfigSchema, mcpDefaultsConfigSchema, spawnDefaultsConfigSchema, daemonConfigSchema, titlerConfigSchema, tunnelConfigSchema, featuresConfigSchema, worktreesConfigSchema, spawnConfigSchema, provenanceConfigSchema, sessionsConfigSchema, agentsMdConfigSchema, pairPageSchema, pairingConfigSchema, profileConfigSchema, acpAgentConfigEntrySchema, terminalPresetSchema, agentprotoConfigSchema, bool, str, num, strArray;
2783
+ var contextContinuityPolicySchema, deferredToolsConfigSchema, spawnBrowserModeSchema, optionsMapSchema, defaultsAdapterAuthConfigSchema, defaultsAdapterConfigSchema, mcpDefaultsConfigSchema, spawnDefaultsConfigSchema, daemonConfigSchema, titlerConfigSchema, catalogConfigSchema, tunnelConfigSchema, featuresConfigSchema, worktreesConfigSchema, spawnConfigSchema, provenanceConfigSchema, approvalsConfigSchema, sessionsConfigSchema, agentsMdConfigSchema, pairPageSchema, pairingConfigSchema, modelRoleValueSchema, profileConfigSchema, acpAgentConfigEntrySchema, terminalPresetSchema, agentprotoConfigSchema, bool, str, num, strArray;
2746
2784
  var init_config_schema = __esm({
2747
2785
  "src/config-schema.ts"() {
2748
2786
  init_worktree_isolation();
@@ -2752,6 +2790,7 @@ var init_config_schema = __esm({
2752
2790
  init_gh_provenance_shim();
2753
2791
  init_agents_md();
2754
2792
  init_session_titler();
2793
+ init_model_roles();
2755
2794
  init_background_task_wake();
2756
2795
  init_role();
2757
2796
  contextContinuityPolicySchema = z.object({
@@ -2837,6 +2876,9 @@ var init_config_schema = __esm({
2837
2876
  enabled: z.boolean().optional(),
2838
2877
  model: z.string().optional()
2839
2878
  }).passthrough();
2879
+ catalogConfigSchema = z.object({
2880
+ sources: z.array(z.object({ url: z.string() }).passthrough()).optional()
2881
+ }).passthrough();
2840
2882
  tunnelConfigSchema = z.object({
2841
2883
  host: z.string().optional(),
2842
2884
  token: z.string().optional(),
@@ -2851,13 +2893,17 @@ var init_config_schema = __esm({
2851
2893
  }).passthrough();
2852
2894
  worktreesConfigSchema = z.object({
2853
2895
  root: z.string().optional(),
2854
- isolation: z.enum(["always", "on-request", "never"]).optional()
2896
+ isolation: z.enum(["always", "on-request", "never"]).optional(),
2897
+ provisionConcurrency: z.number().int().min(0).optional(),
2898
+ provisionConcurrencyByRepo: z.record(z.string(), z.number().int().min(0)).optional(),
2899
+ provisionLoadFactor: z.number().min(0).optional()
2855
2900
  }).passthrough();
2856
2901
  spawnConfigSchema = z.object({
2857
2902
  attach: z.enum(["always", "on-request"]).optional(),
2858
2903
  dedupe: z.enum(["always", "on-request"]).optional()
2859
2904
  }).passthrough();
2860
2905
  provenanceConfigSchema = z.object({ wrapGh: z.boolean().optional() }).passthrough();
2906
+ approvalsConfigSchema = z.object({ webOrigins: z.array(z.string()).optional() }).passthrough();
2861
2907
  sessionsConfigSchema = z.object({
2862
2908
  attentionDelaySec: z.number().optional(),
2863
2909
  eventsDir: z.string().optional()
@@ -2875,6 +2921,14 @@ var init_config_schema = __esm({
2875
2921
  autoconnect: z.boolean().optional(),
2876
2922
  pairPage: pairPageSchema.optional()
2877
2923
  }).passthrough();
2924
+ modelRoleValueSchema = z.union([
2925
+ z.string().min(1),
2926
+ z.object({
2927
+ model: z.string().min(1),
2928
+ route: z.string().optional(),
2929
+ profile: z.string().optional()
2930
+ }).passthrough()
2931
+ ]);
2878
2932
  profileConfigSchema = z.object({
2879
2933
  daemon: daemonConfigSchema.optional(),
2880
2934
  tunnel: tunnelConfigSchema.optional(),
@@ -2913,8 +2967,11 @@ var init_config_schema = __esm({
2913
2967
  spawn: spawnConfigSchema.optional(),
2914
2968
  sessions: sessionsConfigSchema.optional(),
2915
2969
  provenance: provenanceConfigSchema.optional(),
2970
+ approvals: approvalsConfigSchema.optional(),
2916
2971
  agentsMd: agentsMdConfigSchema.optional(),
2972
+ models: z.record(z.string(), modelRoleValueSchema).optional(),
2917
2973
  titler: titlerConfigSchema.optional(),
2974
+ catalog: catalogConfigSchema.optional(),
2918
2975
  profiles: z.record(z.string(), profileConfigSchema).optional(),
2919
2976
  activeProfile: z.string().optional(),
2920
2977
  defaults: spawnDefaultsConfigSchema.optional(),
@@ -2965,6 +3022,16 @@ var init_config_schema = __esm({
2965
3022
  label: "Allowed origins",
2966
3023
  help: "Trusted browser origins for mutating /sessions/* routes, in addition to the hardcoded localhost defaults. Lockout: a bad value can lock a browser UI out."
2967
3024
  },
3025
+ {
3026
+ path: "approvals.webOrigins",
3027
+ schema: strArray,
3028
+ apply: "restart",
3029
+ writable: false,
3030
+ section: "daemon",
3031
+ label: "Approval web-click origins",
3032
+ help: "Origins allowed to decide a pending approval via POST /approvals/:id/decision (web_click channel). Empty (default) turns the channel off entirely. A SEPARATE allowlist from daemon.allowedOrigins, which is not automatically trusted to decide approvals. Lockout: a bad value can lock the web decision UI out.",
3033
+ default: []
3034
+ },
2968
3035
  {
2969
3036
  path: "daemon.strictOrigins",
2970
3037
  schema: bool,
@@ -3158,6 +3225,20 @@ var init_config_schema = __esm({
3158
3225
  default: DEFAULT_PAIR_PAGE
3159
3226
  },
3160
3227
  // ── models ──
3228
+ {
3229
+ // One row per configured role. Role names are dotted (`review.pr`), so a
3230
+ // concrete key is `models.review.pr` — `findConfigKey` maps any
3231
+ // `models.<role>` onto this entry, and `splitConfigPath` (config.ts) keeps
3232
+ // the role as ONE segment. The full role list (incl. built-in defaults and
3233
+ // where each value comes from) is the `model_roles` tool.
3234
+ path: "models.*",
3235
+ schema: modelRoleValueSchema,
3236
+ apply: "hot",
3237
+ writable: true,
3238
+ section: "models",
3239
+ label: "Model role",
3240
+ help: `Model for a role (review.small, review.large, review.pr, judge.session, \u2026): a model id, or { model, route?, profile? }. Precedence: explicit run input > the repo's agentproto.json \`models\` > this daemon config > built-in default (\`model_roles\` lists every role and its source). Built-in defaults: ${Object.entries(DEFAULT_MODEL_ROLES).map(([r, m]) => `${r}=${m}`).join(", ")}.`
3241
+ },
3161
3242
  {
3162
3243
  path: "titler.model",
3163
3244
  schema: str,
@@ -3168,6 +3249,16 @@ var init_config_schema = __esm({
3168
3249
  help: "OpenRouter model id used to generate session titles. Requires OPENROUTER_API_KEY.",
3169
3250
  default: DEFAULT_TITLER_MODEL
3170
3251
  },
3252
+ // ── daemon: app catalog ──
3253
+ {
3254
+ path: "catalog.sources",
3255
+ schema: z.array(z.object({ url: str }).passthrough()),
3256
+ apply: "hot",
3257
+ writable: true,
3258
+ section: "daemon",
3259
+ label: "App catalog sources",
3260
+ help: "Remote catalogs merged into `app_catalog`: an array of `{ url }`, each returning `{ entries: AppCatalogEntry[] }`. Wins over `sources` in ~/.agentproto/app-catalog.json when both are set."
3261
+ },
3171
3262
  // ── defaults: spawn ──
3172
3263
  {
3173
3264
  path: "defaults.skills",
@@ -3247,6 +3338,36 @@ var init_config_schema = __esm({
3247
3338
  help: "Whether a freshly-spawned agent_start session is isolated into its own git worktree.",
3248
3339
  default: DEFAULT_WORKTREE_ISOLATION
3249
3340
  },
3341
+ {
3342
+ path: "worktrees.provisionConcurrency",
3343
+ schema: z.number().int().min(0),
3344
+ apply: "hot",
3345
+ env: WORKTREE_PROVISION_CONCURRENCY_ENV,
3346
+ writable: true,
3347
+ section: "defaults",
3348
+ label: "Worktree provisioning concurrency",
3349
+ help: "Max worktree provisionings running their heavy phases (depsCmd, clones, setup hooks) at once; the rest queue FIFO. 0 = unlimited.",
3350
+ default: DEFAULT_WORKTREE_PROVISION_CONCURRENCY
3351
+ },
3352
+ {
3353
+ path: "worktrees.provisionConcurrencyByRepo",
3354
+ schema: z.record(str, z.number().int().min(0)),
3355
+ apply: "hot",
3356
+ writable: true,
3357
+ section: "defaults",
3358
+ label: "Per-repo provisioning concurrency",
3359
+ help: "Per-repo caps on concurrent heavy provisioning, keyed by repo path or directory name; never looser than the global cap."
3360
+ },
3361
+ {
3362
+ path: "worktrees.provisionLoadFactor",
3363
+ schema: z.number().min(0),
3364
+ apply: "hot",
3365
+ writable: true,
3366
+ section: "defaults",
3367
+ label: "Provisioning load guard factor",
3368
+ help: "Hold back a new heavy provisioning while the 1-minute load average exceeds cores x this factor. 0 or unset = off.",
3369
+ default: 0
3370
+ },
3250
3371
  {
3251
3372
  path: "spawn.attach",
3252
3373
  schema: z.enum(["always", "on-request"]),
@@ -3619,6 +3740,34 @@ var init_config_schema = __esm({
3619
3740
  label: "Terminal preset argv",
3620
3741
  help: "Command + args to spawn. Not writable through config_set; set via `agentproto config set` or a hand edit."
3621
3742
  },
3743
+ {
3744
+ path: "jev.apiKey",
3745
+ schema: str,
3746
+ apply: "hot",
3747
+ secret: true,
3748
+ writable: false,
3749
+ section: "advanced",
3750
+ label: "Jev API key",
3751
+ help: "Jev (TypeSafe System One) judge API key. Read by the session steward's Jev backend before falling back to the JEV_API_KEY env var. Not writable through config_set; edit ~/.agentproto/config.json by hand."
3752
+ },
3753
+ {
3754
+ path: "jev.model",
3755
+ schema: str,
3756
+ apply: "hot",
3757
+ writable: true,
3758
+ section: "advanced",
3759
+ label: "Jev model",
3760
+ help: `Jev model id for the session steward's judge backend. Default "jev-latest".`
3761
+ },
3762
+ {
3763
+ path: "jev.baseUrl",
3764
+ schema: str,
3765
+ apply: "hot",
3766
+ writable: true,
3767
+ section: "advanced",
3768
+ label: "Jev base URL",
3769
+ help: "Jev endpoint override. Default https://api.typesafe.ai/v1/systemone."
3770
+ },
3622
3771
  {
3623
3772
  path: "terminalPresets.*.env",
3624
3773
  schema: z.record(str, str),
@@ -3777,16 +3926,22 @@ async function saveConfig(next, path) {
3777
3926
  await promises.writeFile(tmp, JSON.stringify(payload, null, 2) + "\n", "utf8");
3778
3927
  await promises.rename(tmp, target);
3779
3928
  }
3929
+ function splitConfigPath(dotted) {
3930
+ if (dotted.startsWith("models.") && dotted.length > "models.".length) {
3931
+ return ["models", dotted.slice("models.".length)];
3932
+ }
3933
+ return dotted.split(".");
3934
+ }
3780
3935
  function getConfigKey(cfg, dotted) {
3781
3936
  let cur = cfg;
3782
- for (const part of dotted.split(".")) {
3937
+ for (const part of splitConfigPath(dotted)) {
3783
3938
  if (cur == null || typeof cur !== "object") return void 0;
3784
3939
  cur = cur[part];
3785
3940
  }
3786
3941
  return cur;
3787
3942
  }
3788
3943
  function setConfigKey(cfg, dotted, value) {
3789
- const parts = dotted.split(".");
3944
+ const parts = splitConfigPath(dotted);
3790
3945
  const out = { ...cfg };
3791
3946
  let cur = out;
3792
3947
  for (let i = 0; i < parts.length - 1; i++) {
@@ -3818,6 +3973,6 @@ var init_config = __esm({
3818
3973
  });
3819
3974
  init_config();
3820
3975
 
3821
- export { CONFIG_FILE_PATH, CONFIG_VERSION, getConfigKey, loadConfig, saveConfig, setConfigKey };
3976
+ export { CONFIG_FILE_PATH, CONFIG_VERSION, getConfigKey, loadConfig, saveConfig, setConfigKey, splitConfigPath };
3822
3977
  //# sourceMappingURL=config.mjs.map
3823
3978
  //# sourceMappingURL=config.mjs.map