@agentchatme/agent-core 0.5.3 → 0.6.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/presets.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { TextsRuntime } from 'agentchatme';
2
- import { a as RunProfile, b as RunRunner, q as RunPreflightOptions, f as RunPreflight, g as RunRequest, c as RunOutcome } from './runner-DYVqz_9P.js';
2
+ import { a as RunProfile, b as RunRunner, q as RunPreflightOptions, f as RunPreflight, g as RunRequest, c as RunOutcome } from './runner-C9kZD3KH.js';
3
3
 
4
4
  /** What a preset needs to build a runner acting as one agent. */
5
5
  interface PresetContext {
@@ -51,12 +51,15 @@ interface Preset {
51
51
  /**
52
52
  * The hosted-tool configuration a listener's run of this preset sees, as
53
53
  * lines for `doctor` (keys never printed): what the run is given, and what
54
- * of the user's own configuration still applies.
54
+ * of the user's own configuration still applies. `profile` is the
55
+ * listener's (`own` changes what is given); absent, the lines are those of
56
+ * the other profiles.
55
57
  */
56
58
  describeMcp(ctx: {
57
59
  readonly home: string;
58
60
  readonly apiBase: string;
59
61
  readonly env?: NodeJS.ProcessEnv;
62
+ readonly profile?: RunProfile;
60
63
  }): string[];
61
64
  /** Variables a service must capture for this runtime (where it keeps its config, when relocated). */
62
65
  readonly serviceEnv: readonly string[];
@@ -251,8 +254,9 @@ interface ClaudeRunArgOptions {
251
254
  /**
252
255
  * A file whose text is appended to the system prompt (`--append-system-prompt-file`,
253
256
  * documented since 2.1.69): how an `answer` run, which loads no CLAUDE.md,
254
- * is told its identity line. A file, not argv text: an argument cannot carry
255
- * a line break through a Windows `.cmd` shim.
257
+ * is told its identity line, and how an `own` run is told it whatever its
258
+ * CLAUDE.md holds (a listener's agent is not the one there). A file, not
259
+ * argv text: an argument cannot carry a line break through a Windows `.cmd` shim.
256
260
  */
257
261
  readonly appendSystemPromptFile?: string | undefined;
258
262
  }
@@ -322,6 +326,8 @@ declare function claudeExtraDirectoriesGrant(configDirOverride: string | undefin
322
326
  * loads no other MCP server — the user's own, a project's, a plugin's, a
323
327
  * claude.ai connector — whatever the user scope registers. `file` must sit
324
328
  * inside a `denyReadPaths` entry (it holds the key), or preflight refuses.
329
+ * An `own` run writes no tool config (it uses the user's servers); its
330
+ * identity-line file is written beside `file` all the same.
325
331
  */
326
332
  interface ClaudeAnswerMcp {
327
333
  readonly file: string;
@@ -335,8 +341,9 @@ interface ClaudeRunnerOptions {
335
341
  /**
336
342
  * The run's working directory; the `work` profile edits and runs shell here.
337
343
  * Must lie outside `denyReadPaths`, or the run cannot read its own cwd —
338
- * preflight says so once and still runs. An `answer` run whose workdir is the
339
- * home folder or contains it works in `answerFallbackWorkdir` instead.
344
+ * preflight says so once and still runs. An `own` or `answer` run whose
345
+ * workdir is the home folder or contains it works in
346
+ * `claudeAnswerFallbackWorkdir` instead.
340
347
  */
341
348
  readonly workdir: string;
342
349
  readonly profile: RunProfile;
@@ -362,15 +369,19 @@ interface ClaudeRunnerOptions {
362
369
  readonly env?: NodeJS.ProcessEnv;
363
370
  }
364
371
  /**
365
- * The folder an `answer` run works in when its configured workdir is the
366
- * user's home folder or contains it (`workdirExposesHome`): an empty folder of
367
- * its own beside Claude Code's config, never inside a denied path. The run
368
- * keeps working — it only cannot read the user's files.
372
+ * The folder an `own` or `answer` run works in when its configured workdir is
373
+ * the user's home folder or contains it (`workdirExposesHome`): an empty folder
374
+ * of its own beside Claude Code's config, never inside a denied path. The run
375
+ * keeps working — it only cannot read the user's files. An `own` run needs
376
+ * this as much: Claude Code lets a run read its working directory without
377
+ * asking in every permission mode, so a home-folder workdir would hand a
378
+ * peer-started run `~/.ssh` whatever the user's allow rules say.
369
379
  */
370
380
  declare function claudeAnswerFallbackWorkdir(configDirOverride: string | undefined): string;
371
381
  declare class ClaudeRunner implements RunRunner {
372
382
  private readonly options;
373
383
  readonly name = "claude";
384
+ readonly label = "Claude Code";
374
385
  private readonly command;
375
386
  /** The workdir warning is one line per process, not one per preflight (preflight repeats every few minutes). */
376
387
  private warnedWorkdir;
@@ -379,7 +390,7 @@ declare class ClaudeRunner implements RunRunner {
379
390
  constructor(options: ClaudeRunnerOptions);
380
391
  /**
381
392
  * Where this runner's runs work: the configured workdir, except that an
382
- * `answer` run never works in the home folder or above it — it gets
393
+ * `own` or `answer` run never works in the home folder or above it — it gets
383
394
  * `claudeAnswerFallbackWorkdir` (its readable folder would be the whole home).
384
395
  */
385
396
  workdir(): string;
@@ -388,8 +399,12 @@ declare class ClaudeRunner implements RunRunner {
388
399
  preflight(options?: RunPreflightOptions): Promise<RunPreflight>;
389
400
  /** `<dir>/<stem>.<run id><ext>`: a file of this run's own beside `file` (the run id reduced to letters, digits and `-`). */
390
401
  private static perRun;
391
- /** The answer run's own files for `runId`: its AgentChat-only tool config (integration path) and its identity-line file. */
392
- private answerRunFiles;
402
+ /**
403
+ * A run's own files for `runId`: an answer run's AgentChat-only tool config
404
+ * (integration path), and the identity-line file of an answer or own run.
405
+ * `work` and `full` write none (they load CLAUDE.md, as before).
406
+ */
407
+ private runFiles;
393
408
  /**
394
409
  * What this runner's runs are denied reading: the key store, and for an
395
410
  * `answer` run also Claude Code's own record of every project
@@ -402,11 +417,17 @@ declare class ClaudeRunner implements RunRunner {
402
417
  private argsFor;
403
418
  /**
404
419
  * The argv of a run — exported for tests to pin per profile. With a `runId`,
405
- * that run's own files (an answer run's tool config and identity-line file);
406
- * without, the configured `answerMcp.file` stands in and no identity file.
420
+ * that run's own files (an answer run's tool config, an answer or own run's
421
+ * identity-line file); without, the configured `answerMcp.file` stands in
422
+ * for an answer run's tool config, and no identity file.
407
423
  */
408
424
  args(runId?: string, identityLine?: boolean): string[];
409
- /** The run's environment: no parent session; an answer run loads no CLAUDE.md and no auto memory (`ANSWER_ENV`). */
425
+ /**
426
+ * The run's environment: no parent session; an answer run loads no CLAUDE.md
427
+ * and no auto memory (`ANSWER_ENV`); an own run carries no `AGENTCHAT_API_KEY`
428
+ * the daemon inherited — it has the user's own shell, and it reaches the
429
+ * hosted tools through its MCP entry, never through that variable.
430
+ */
410
431
  runEnv(): NodeJS.ProcessEnv;
411
432
  start(request: RunRequest): Promise<RunOutcome>;
412
433
  }
@@ -453,6 +474,13 @@ declare function codexProfileArgs(profile: RunProfile): string[];
453
474
  interface CodexMcpOverride {
454
475
  readonly url: string;
455
476
  readonly keyEnv: string;
477
+ /**
478
+ * A headers helper command (`http_headers_helper`) in place of the bearer
479
+ * variable: the run's environment then carries no key. A listener's `own`
480
+ * runs use one (`codexListenerHeadersHelperPath`): with the user's own
481
+ * shell, an environment variable is one `env` away.
482
+ */
483
+ readonly headersHelper?: string;
456
484
  /** The version named in `X-AgentChat-Client-Version` (the front door that placed the run). Defaults to this engine's. */
457
485
  readonly clientVersion?: string;
458
486
  }
@@ -505,12 +533,16 @@ interface CodexRunnerOptions {
505
533
  readonly env?: NodeJS.ProcessEnv;
506
534
  /** Test seam: how long `codex mcp list` may take (`CODEX_MCP_LIST_TIMEOUT_MS`). */
507
535
  readonly mcpListTimeoutMs?: number;
536
+ /** Why no run may start (preflight and every run say it); absent: runs start. */
537
+ readonly refuse?: string;
508
538
  }
509
539
  /**
510
- * The folder an `answer` run works in when its configured workdir is the
511
- * user's home folder or contains it (`workdirExposesHome`): an empty folder of
512
- * its own under CODEX_HOME. The run keeps working — it only cannot reach the
513
- * user's files through its workspace root.
540
+ * The folder an `own` or `answer` run works in when its configured workdir is
541
+ * the user's home folder or contains it (`workdirExposesHome`): an empty folder
542
+ * of its own under CODEX_HOME. The run keeps working — it only cannot reach the
543
+ * user's files through its workspace root. An `own` run needs this as much: a
544
+ * user's `workspace-write` sandbox would let a peer-started run write anywhere
545
+ * under the workspace root, which would be the whole home.
514
546
  */
515
547
  declare function codexAnswerFallbackWorkdir(codexHome: string): string;
516
548
  /** How long `codex mcp list` may take before an answer run is given up (not started). */
@@ -534,6 +566,25 @@ declare function parseCodexMcpList(stdout: string): {
534
566
  ok: false;
535
567
  detail: string;
536
568
  };
569
+ /**
570
+ * What the `agentchat` entry of `codex mcp list --json` would authenticate
571
+ * with besides a headers helper: `bearer_token_env_var`, or an `Authorization`
572
+ * in `env_http_headers` (names only, never values). Codex sends either in
573
+ * place of the helper's `Authorization` ("Helper Authorization is used only
574
+ * when the request has no explicit bearer/OAuth credential",
575
+ * rmcp-client/src/http_headers.rs). A static `http_headers` is not counted:
576
+ * a listener's run replaces that whole table. An entry the list does not
577
+ * have authenticates with nothing else.
578
+ */
579
+ declare function codexAgentchatExplicitAuth(stdout: string): {
580
+ ok: true;
581
+ keys: string[];
582
+ } | {
583
+ ok: false;
584
+ detail: string;
585
+ };
586
+ /** The key variables a `.env` file sets (`AGENTCHAT_API_KEY`, `LISTENER_KEY_ENV`): names only. Codex loads `$CODEX_HOME/.env` into its own environment, and a run's commands inherit it. */
587
+ declare function codexDotEnvKeyNames(content: string): string[];
537
588
  /**
538
589
  * `-c mcp_servers.<name>.enabled=false` for every listed server but AgentChat's,
539
590
  * or why that cannot be done. Only names Codex listed: an override for a server
@@ -570,21 +621,30 @@ declare function codexConfigLayerFiles(codexHome: string, workdir: string, platf
570
621
  declare class CodexRunner implements RunRunner {
571
622
  private readonly options;
572
623
  readonly name = "codex";
624
+ readonly label = "Codex";
573
625
  private readonly command;
574
626
  private warnedHome;
575
627
  /** The last good listing and what it depended on: a stranger's DM does not cost a listing (and its contacts to the user's MCP hosts) on every run. */
576
628
  private listing;
629
+ /** The last listing that showed a listener's own run authenticates with its helper alone (`ownAuthProblem`). */
630
+ private ownListing;
577
631
  constructor(options: CodexRunnerOptions);
578
632
  /**
579
633
  * Where this runner's runs work (`-C`): the configured workdir, except that an
580
- * `answer` run never has the home folder or above it as its workspace root —
581
- * it gets `codexAnswerFallbackWorkdir`.
634
+ * `own` or `answer` run never has the home folder or above it as its
635
+ * workspace root — it gets `codexAnswerFallbackWorkdir`.
582
636
  */
583
637
  workdir(): string;
584
638
  preflight(options?: RunPreflightOptions): Promise<RunPreflight>;
585
639
  /** The exact argv one run uses — exported for tests to pin per profile. An `answer` run adds `answerMcpDisables()` before the prompt. */
586
640
  args(): string[];
587
- /** The child environment: Codex's home and the key the hosted server needs, under the configured name. */
641
+ /**
642
+ * The child environment: Codex's home and the key the hosted server needs,
643
+ * under the configured name. An `own` run gets no key at all — not the
644
+ * configured one, not an `AGENTCHAT_API_KEY` the daemon inherited: it has
645
+ * the user's own shell, and Codex hands a run's commands its environment.
646
+ * Its hosted server authenticates through a headers helper instead.
647
+ */
588
648
  env(): NodeJS.ProcessEnv;
589
649
  /**
590
650
  * For an `answer` run: `-c mcp_servers.<name>.enabled=false` for every MCP
@@ -602,8 +662,42 @@ declare class CodexRunner implements RunRunner {
602
662
  ok: false;
603
663
  detail: string;
604
664
  }>;
665
+ /**
666
+ * For a listener's `own` run (its key from a headers helper, none in its
667
+ * environment): why it must not start, or null. Two things would make it
668
+ * carry or use a key that is not the helper's — another agent's, as a
669
+ * Codex integration from 0.5.2 or earlier left them: `$CODEX_HOME/.env`
670
+ * setting a key variable (Codex loads it into the run's environment), and an
671
+ * `agentchat` entry that names `bearer_token_env_var` or an `Authorization`
672
+ * in `env_http_headers` in any config layer (Codex sends that in place of the
673
+ * helper's: the run would act as that other agent). The entry is asked of
674
+ * Codex itself (`codex mcp list --json` with the run's own flags, cached as
675
+ * an answer run's listing is); a listing that fails means no run.
676
+ */
677
+ ownAuthProblem(): Promise<string | null>;
678
+ /** The run's config flags (`-c <v>` and `--disable <feature>` pairs) and what a listing of them depends on. */
679
+ private listingFlags;
680
+ /** `codex mcp list --json <flags>` from the run's workdir, with the run's environment: its output, or why there is none. Killed with its whole tree past its time. */
681
+ private listMcpServers;
605
682
  start(request: RunRequest): Promise<RunOutcome>;
606
683
  }
684
+ /** Where a listener's `own` runs' headers helper lives: `<home>/presets/codex.mcp-headers.mjs` (owner-only; it holds no key). */
685
+ declare function codexListenerHeadersHelperPath(home: string): string;
686
+ /**
687
+ * The helper, byte for byte. It reads the `credentials` file of the home whose
688
+ * `presets/` it sits in and nothing else (no environment variable: the
689
+ * identity is the home's), prints `{"Authorization":"Bearer <key>"}`, or `{}`
690
+ * when there is no key, and never fails.
691
+ */
692
+ declare const CODEX_LISTENER_HEADERS_HELPER_SOURCE: string;
693
+ /**
694
+ * The helper command: this Node and the script, each quoted for the shell
695
+ * Codex runs it in — single quotes on POSIX (`sh -c`; a `'` inside written as
696
+ * `'\\''`), double quotes on Windows (`cmd /C`). Null when a path holds what
697
+ * that quoting cannot carry (`"`, `%`, `$` or a backtick on Windows) or a line
698
+ * break anywhere.
699
+ */
700
+ declare function codexHeadersHelperCommand(script: string, node?: string, platform?: NodeJS.Platform): string | null;
607
701
  /**
608
702
  * The keys of `[mcp_servers.agentchat]` in a config.toml, or null when the
609
703
  * table is absent. Keys only — a value can be a secret. A line scan, not a
@@ -617,4 +711,4 @@ declare const PRESETS: Readonly<Record<string, Preset>>;
617
711
  declare function presetNamed(name: string): Preset | null;
618
712
  declare function presetNames(): string[];
619
713
 
620
- export { AGENTCHAT_TOOL_ALLOW, ANSWER_DENIED_TOOLS, ANSWER_ENV, ANSWER_SETTINGS, ANSWER_TOOLS, CLAUDE_CODE_ENV_KEPT, CLAUDE_CODE_PRESET, CLAUDE_MCP_SERVER_NAME, CLAUDE_SESSION_ENV, CODEX_ANSWER_DISABLED_FEATURES, CODEX_ANSWER_FILESYSTEM, CODEX_ANSWER_PERMISSIONS, CODEX_MANAGED_PROXY_ENV, CODEX_MCP_LIST_MAX_AGE_MS, CODEX_MCP_LIST_TIMEOUT_MS, CODEX_MCP_SERVER_NAME, CODEX_PRESET, CODEX_PROBE_TIMEOUT_MS, CODEX_PROMPT_FROM_STDIN, CODEX_SESSION_ENV, type ClaudeAnswerMcp, type ClaudeRunArgOptions, ClaudeRunner, type ClaudeRunnerOptions, type ClaudeSignIn, type CodexMcpOverride, CodexRunner, type CodexRunnerOptions, LISTENER_KEY_ENV, MIN_CLAUDE_CODE_VERSION, MIN_CODEX_VERSION, PARENT_ENV_KEYS, PRESETS, PROBE_TIMEOUT_MS, type Preset, type PresetContext, type PresetInspection, WEB_TOOLS, WORK_TOOLS, agentchatTableKeys, buildClaudeEnv, claudeAnswerFallbackWorkdir, claudeCodePreset, claudeConfigDirFrom, claudeExtraDirectoriesGrant, claudeHomeFor, claudeIsLoggedIn, claudeManagedSettingsDir, claudeMcpConfig, claudeMcpConfigPath, claudeProfileArgs, claudeProjectsDirFor, claudeRunArgs, claudeSettingsFilesGrantingDirectories, claudeSignIn, claudeUserStatePathFor, codexAnswerFallbackWorkdir, codexClientHeadersToml, codexConfigLayerFiles, codexHomeFrom, codexIsLoggedIn, codexMcpDisableArgs, codexMcpOverrideArgs, codexPinnedUrlArgs, codexPreset, codexProfileArgs, codexRunArgs, codexServerNameAddressable, deniedAncestorOf, inexpressibleDenyPaths, inspectClaudeRuntime, inspectCodexRuntime, isParentSessionEnv, parseCodexMcpList, presetNamed, presetNames, readDenyRules, semverAtLeast, withoutParentSession, workdirPaths, workdirReadRules };
714
+ export { AGENTCHAT_TOOL_ALLOW, ANSWER_DENIED_TOOLS, ANSWER_ENV, ANSWER_SETTINGS, ANSWER_TOOLS, CLAUDE_CODE_ENV_KEPT, CLAUDE_CODE_PRESET, CLAUDE_MCP_SERVER_NAME, CLAUDE_SESSION_ENV, CODEX_ANSWER_DISABLED_FEATURES, CODEX_ANSWER_FILESYSTEM, CODEX_ANSWER_PERMISSIONS, CODEX_LISTENER_HEADERS_HELPER_SOURCE, CODEX_MANAGED_PROXY_ENV, CODEX_MCP_LIST_MAX_AGE_MS, CODEX_MCP_LIST_TIMEOUT_MS, CODEX_MCP_SERVER_NAME, CODEX_PRESET, CODEX_PROBE_TIMEOUT_MS, CODEX_PROMPT_FROM_STDIN, CODEX_SESSION_ENV, type ClaudeAnswerMcp, type ClaudeRunArgOptions, ClaudeRunner, type ClaudeRunnerOptions, type ClaudeSignIn, type CodexMcpOverride, CodexRunner, type CodexRunnerOptions, LISTENER_KEY_ENV, MIN_CLAUDE_CODE_VERSION, MIN_CODEX_VERSION, PARENT_ENV_KEYS, PRESETS, PROBE_TIMEOUT_MS, type Preset, type PresetContext, type PresetInspection, WEB_TOOLS, WORK_TOOLS, agentchatTableKeys, buildClaudeEnv, claudeAnswerFallbackWorkdir, claudeCodePreset, claudeConfigDirFrom, claudeExtraDirectoriesGrant, claudeHomeFor, claudeIsLoggedIn, claudeManagedSettingsDir, claudeMcpConfig, claudeMcpConfigPath, claudeProfileArgs, claudeProjectsDirFor, claudeRunArgs, claudeSettingsFilesGrantingDirectories, claudeSignIn, claudeUserStatePathFor, codexAgentchatExplicitAuth, codexAnswerFallbackWorkdir, codexClientHeadersToml, codexConfigLayerFiles, codexDotEnvKeyNames, codexHeadersHelperCommand, codexHomeFrom, codexIsLoggedIn, codexListenerHeadersHelperPath, codexMcpDisableArgs, codexMcpOverrideArgs, codexPinnedUrlArgs, codexPreset, codexProfileArgs, codexRunArgs, codexServerNameAddressable, deniedAncestorOf, inexpressibleDenyPaths, inspectClaudeRuntime, inspectCodexRuntime, isParentSessionEnv, parseCodexMcpList, presetNamed, presetNames, readDenyRules, semverAtLeast, withoutParentSession, workdirPaths, workdirReadRules };