@moikapy/lich 0.4.0 → 0.5.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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.0
4
+
5
+ - add a `game_bridge` example plugin that queues batched enemy actions
6
+ and durable dungeon memory under `.lich/game/` for a Godot combat tick.
7
+ a `before_tool_call` hook holds meteor until round 3. node loads the
8
+ `.mjs` entry from `config.plugins`.
9
+ - load `config.plugins` on every CLI entry point and on `run_agent`
10
+ (`create_agent_with_plugins`). one-shot, chat, tui, and the gateway
11
+ bus no longer ignore plugin entries. broken plugins still warn and
12
+ continue. `create_agent` stays plugin-free.
13
+ - bare `lich` opens the TUI. On a TTY, when no config is in the search
14
+ chain and `LICH_MODEL` is unset, a readline wizard collects agent name,
15
+ provider, gateway env-var names (never secrets), and plugins, then
16
+ writes `.lich/config.json` once. Non-TTY stdin skips the wizard and
17
+ prints guidance. `lich init` writes the starter file through the same
18
+ writer and never overwrites an existing `.lich/config.json`.
19
+ - add `lich update`: compare the installed version with `npm view
20
+ @moikapy/lich version` and, when newer, run
21
+ `npm install -g @moikapy/lich@latest`. git clones are told to
22
+ `git pull`; npx cannot persist an update.
23
+ - document embedding that plugin beside a Godot game: one webhook call
24
+ per combat round, and the `.lich/game/` drain tick. see
25
+ docs/user-guide/godot.md.
26
+
3
27
  ## 0.4.0
4
28
 
5
29
  - add a self-improvement loop: `run_tests`, a gatekeeper plugin, and
@@ -1881,6 +1881,43 @@ var ProviderError = class extends Error {
1881
1881
 
1882
1882
  // src/agent/config.ts
1883
1883
  import { z } from "zod";
1884
+
1885
+ // src/gateway/token_env.ts
1886
+ var DEFAULT_GATEWAY_TOKEN_ENVS = {
1887
+ webhook: "LICH_GATEWAY_TOKEN",
1888
+ telegram: "LICH_TELEGRAM_BOT_TOKEN",
1889
+ discord: "LICH_DISCORD_BOT_TOKEN",
1890
+ twitch: "LICH_TWITCH_OAUTH_TOKEN"
1891
+ };
1892
+ var ENV_VAR_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
1893
+ function is_env_var_name(value) {
1894
+ return ENV_VAR_NAME.test(value) === true;
1895
+ }
1896
+ function platform_token_env(config, platform) {
1897
+ const named = config.gateway?.token_envs[platform];
1898
+ if (named !== void 0 && named.length > 0) {
1899
+ return is_env_var_name(named) === true ? named : "";
1900
+ }
1901
+ return DEFAULT_GATEWAY_TOKEN_ENVS[platform] ?? "";
1902
+ }
1903
+ function read_platform_token(config, platform) {
1904
+ const key = platform_token_env(config, platform);
1905
+ if (is_env_var_name(key) === false) {
1906
+ return void 0;
1907
+ }
1908
+ const value = process.env[key];
1909
+ if (typeof value !== "string" || value.length === 0) {
1910
+ return void 0;
1911
+ }
1912
+ return value;
1913
+ }
1914
+
1915
+ // src/agent/config.ts
1916
+ var gateway_schema = z.object({
1917
+ platforms: z.array(z.enum(["webhook", "telegram", "discord", "twitch"])).default([]),
1918
+ /** Env-var names that hold tokens. Never store the secrets themselves. */
1919
+ token_envs: z.record(z.string(), z.string().regex(ENV_VAR_NAME, "invalid env var name")).default({})
1920
+ }).optional();
1884
1921
  var provider_schema = z.object({
1885
1922
  kind: z.enum(["openai_compat", "anthropic", "ollama"]),
1886
1923
  name: z.string().min(1),
@@ -1893,6 +1930,8 @@ var provider_schema = z.object({
1893
1930
  fetch_fn: z.custom(() => true).optional()
1894
1931
  }).passthrough();
1895
1932
  var agent_config_schema = z.object({
1933
+ /** Display name used by the TUI banner. */
1934
+ agent_name: z.string().min(1).default("lich"),
1896
1935
  system_prompt: z.string().optional(),
1897
1936
  max_turns: z.number().int().min(1).default(25),
1898
1937
  providers: z.array(provider_schema).min(1),
@@ -1906,6 +1945,7 @@ var agent_config_schema = z.object({
1906
1945
  terminal_timeout_ms: z.number().int().positive().default(6e4),
1907
1946
  /** Plugin entry module specifiers, relative to work_dir or absolute. */
1908
1947
  plugins: z.array(z.string()).default([]),
1948
+ gateway: gateway_schema,
1909
1949
  log_level: z.enum(["debug", "info", "warn", "error"]).default("info")
1910
1950
  }).transform((config) => {
1911
1951
  const work_dir = config.work_dir ?? process.cwd();
@@ -1922,6 +1962,11 @@ function freeze_config(config) {
1922
1962
  for (const provider of config.providers) {
1923
1963
  Object.freeze(provider);
1924
1964
  }
1965
+ if (config.gateway !== void 0) {
1966
+ Object.freeze(config.gateway.platforms);
1967
+ Object.freeze(config.gateway.token_envs);
1968
+ Object.freeze(config.gateway);
1969
+ }
1925
1970
  return config;
1926
1971
  }
1927
1972
  function parse_agent_config(raw) {
@@ -3734,7 +3779,7 @@ async function create_agent_with_plugins(raw_config) {
3734
3779
  return new Agent(config, plugins);
3735
3780
  }
3736
3781
  async function run_agent(raw_config, input, options) {
3737
- const agent = create_agent(raw_config);
3782
+ const agent = await create_agent_with_plugins(raw_config);
3738
3783
  return agent.run({ input, signal: options?.signal, label: options?.label });
3739
3784
  }
3740
3785
 
@@ -3750,6 +3795,10 @@ export {
3750
3795
  plugin_errors_summary,
3751
3796
  sleep,
3752
3797
  ProviderError,
3798
+ DEFAULT_GATEWAY_TOKEN_ENVS,
3799
+ is_env_var_name,
3800
+ platform_token_env,
3801
+ read_platform_token,
3753
3802
  parse_agent_config,
3754
3803
  AgentEmitter,
3755
3804
  Agent,
@@ -3757,4 +3806,4 @@ export {
3757
3806
  create_agent_with_plugins,
3758
3807
  run_agent
3759
3808
  };
3760
- //# sourceMappingURL=chunk-MLFJW4JU.js.map
3809
+ //# sourceMappingURL=chunk-CV2YH3FH.js.map