tnega 0.1.1 → 0.3.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 (80) hide show
  1. package/README.md +115 -100
  2. package/dist/agent.js +2510 -134
  3. package/dist/agent.js.map +4 -4
  4. package/dist/bin.js +30723 -5163
  5. package/dist/bin.js.map +4 -4
  6. package/dist/cli-runtime.js +30690 -5094
  7. package/dist/cli-runtime.js.map +4 -4
  8. package/dist/coding-agent.js +19088 -0
  9. package/dist/coding-agent.js.map +7 -0
  10. package/dist/core.js +74 -1
  11. package/dist/core.js.map +4 -4
  12. package/dist/eval.js +23159 -1990
  13. package/dist/eval.js.map +4 -4
  14. package/dist/events.js +22 -1
  15. package/dist/events.js.map +2 -2
  16. package/dist/evolve.js +17631 -1815
  17. package/dist/evolve.js.map +4 -4
  18. package/dist/index.js +31848 -6076
  19. package/dist/index.js.map +4 -4
  20. package/dist/llm.js +8 -0
  21. package/dist/llm.js.map +2 -2
  22. package/dist/services.js +12 -1
  23. package/dist/services.js.map +2 -2
  24. package/dist/session.js +793 -122
  25. package/dist/session.js.map +4 -4
  26. package/dist/tools.js +242 -135
  27. package/dist/tools.js.map +4 -4
  28. package/dist/types/packages/agent/src/inbox-durable.d.ts +54 -0
  29. package/dist/types/packages/agent/src/index.d.ts +4 -0
  30. package/dist/types/packages/agent/src/live.d.ts +115 -0
  31. package/dist/types/packages/agent/src/llm-service.d.ts +32 -0
  32. package/dist/types/packages/agent/src/prompt.d.ts +55 -0
  33. package/dist/types/packages/agent/src/service.d.ts +24 -0
  34. package/dist/types/packages/agent/src/types.d.ts +75 -1
  35. package/dist/types/packages/benchmark/src/bigcodebench.d.ts +6 -0
  36. package/dist/types/packages/benchmark/src/humaneval.d.ts +11 -0
  37. package/dist/types/packages/benchmark/src/index.d.ts +9 -0
  38. package/dist/types/packages/benchmark/src/manifest.d.ts +10 -0
  39. package/dist/types/packages/benchmark/src/mbpp.d.ts +10 -0
  40. package/dist/types/packages/benchmark/src/parquet.d.ts +2 -0
  41. package/dist/types/packages/benchmark/src/stdlib.d.ts +3 -0
  42. package/dist/types/packages/benchmark/src/swebench.d.ts +2 -0
  43. package/dist/types/packages/benchmark/src/types.d.ts +58 -0
  44. package/dist/types/packages/cli/src/commands.d.ts +26 -2
  45. package/dist/types/packages/cli/src/config.d.ts +2 -0
  46. package/dist/types/packages/cli/src/index.d.ts +4 -2
  47. package/dist/types/packages/cli/src/profile-file.d.ts +26 -0
  48. package/dist/types/packages/cli/src/profile.d.ts +9 -0
  49. package/dist/types/packages/cli/src/server.d.ts +2 -0
  50. package/dist/types/packages/cli/src/store.d.ts +10 -9
  51. package/dist/types/packages/coding-agent/src/codingAgent.d.ts +25 -0
  52. package/dist/types/packages/coding-agent/src/index.d.ts +6 -0
  53. package/dist/types/packages/coding-agent/src/mcp.d.ts +24 -0
  54. package/dist/types/packages/coding-agent/src/plan.d.ts +13 -0
  55. package/dist/types/packages/coding-agent/src/skills.d.ts +12 -0
  56. package/dist/types/packages/coding-agent/src/slash.d.ts +28 -0
  57. package/dist/types/packages/coding-agent/src/types.d.ts +41 -0
  58. package/dist/types/packages/core/src/events.d.ts +4 -1
  59. package/dist/types/packages/core/src/index.d.ts +1 -0
  60. package/dist/types/packages/core/src/invariant.d.ts +45 -0
  61. package/dist/types/packages/eval/src/codingRuntime.d.ts +18 -0
  62. package/dist/types/packages/eval/src/policy.d.ts +8 -0
  63. package/dist/types/packages/eval/src/runner.d.ts +4 -0
  64. package/dist/types/packages/eval/src/strategies.d.ts +10 -0
  65. package/dist/types/packages/eval/src/trace.d.ts +7 -0
  66. package/dist/types/packages/eval/src/types.d.ts +97 -1
  67. package/dist/types/packages/eval/src/workspace.d.ts +17 -0
  68. package/dist/types/packages/llm/src/types.d.ts +2 -0
  69. package/dist/types/packages/session/src/index.d.ts +397 -12
  70. package/dist/types/packages/session/src/invariant.d.ts +33 -0
  71. package/dist/types/packages/tools/src/builtins.d.ts +2 -0
  72. package/dist/types/packages/tools/src/execution.d.ts +31 -0
  73. package/dist/types/packages/tools/src/index.d.ts +17 -0
  74. package/dist/types/src/index.d.ts +5 -5
  75. package/dist/web/assets/index-45pokiBH.js +270 -0
  76. package/dist/web/assets/index-DCLL69Kz.css +1 -0
  77. package/dist/web/index.html +2 -2
  78. package/package.json +92 -88
  79. package/dist/web/assets/index-C3jFlR4V.css +0 -1
  80. package/dist/web/assets/index-DeFGh2h4.js +0 -268
package/README.md CHANGED
@@ -1,100 +1,115 @@
1
- # Tnega
2
-
3
- [中文](docs/zh-CN.md)
4
-
5
- **Tnega** is "agent" spelled backwards. It is an eval-first agent harness with spacetime-composable plugin lifecycles: components can be hot-swapped and rolled back safely, and Eval is a first-class citizen on par with the agent loop and tools.
6
-
7
- ## Install
8
-
9
- Requires Node.js >= 22.
10
-
11
- ```bash
12
- npm install -g tnega
13
- # or
14
- pnpm add -g tnega
15
- ```
16
-
17
- ## Quick Start
18
-
19
- ```bash
20
- export OPENCODE_GO_API_KEY=sk-...
21
- tnega run "Reply with: hello"
22
- ```
23
-
24
- `tnega run` uses OpenCode Go's `deepseek-v4-flash` model through the OpenAI compatible endpoint by default. `minimax-m3` is also available through the Anthropic Messages endpoint. The API key can also come from `~/.tnega/config.json` (Windows: `%USERPROFILE%\.tnega\config.json`) with fields `apiKey`, `model`, `baseUrl`, and `temperature`. Precedence: CLI flags > environment variables > config file > defaults.
25
-
26
- Run a deterministic eval without an API key:
27
-
28
- ```bash
29
- tnega eval run examples/tasks.yml
30
- ```
31
-
32
- Start the local web UI:
33
-
34
- ```bash
35
- tnega web
36
- # http://127.0.0.1:3080
37
- ```
38
-
39
- ## CLI
40
-
41
- ```text
42
- tnega run "prompt" # one agent session
43
- tnega run --allow-shell "list files" # enable high-permission tools
44
- tnega web # local web UI
45
- tnega eval run tasks.yml # run evals
46
- tnega eval compare <base> <head> # compare two eval runs
47
- tnega evolve run tasks.yml # run a self-evolution loop
48
- ```
49
-
50
- Options include `--model`, `--base-url`, `--max-tokens`, `--temperature`, `--cwd`, `--session`, `--timeout-ms`, `--max-retries`, and `--retry-delay-ms`. Sessions are recorded as JSONL under `.tnega/`.
51
-
52
- ## Built-in Tools
53
-
54
- The default tool set is `echo`, `now`, `calculator`, `json`, `read_file`, `write_file`, `list_dir`, `glob`, and `grep`. High-permission tools are opt-in: `http_get` requires `--allow-network`, `shell` requires `--allow-shell`. File and shell tools are confined to the working directory.
55
-
56
- ## Library
57
-
58
- Tnega is published as a library as well as a CLI. Use the root package or domain subpaths (`tnega/core`, `tnega/agent`, `tnega/eval`, `tnega/evolve`, `tnega/session`, `tnega/tools`, `tnega/llm`, ...):
59
-
60
- ```ts
61
- import { Context, defineAgent, openaiCompatAdapter } from 'tnega'
62
-
63
- const root = new Context()
64
- const fiber = await root.plugin(
65
- defineAgent({
66
- name: 'coding-agent',
67
- version: '0.1.1',
68
- system: 'You are a coding agent.',
69
- }),
70
- { llm: openaiCompatAdapter({ apiKey: process.env.OPENCODE_GO_API_KEY! }) },
71
- )
72
-
73
- const loop = root.get('agentLoop')
74
- const result = await loop({ text: 'implement the feature' })
75
- console.log(result.output)
76
-
77
- await fiber.dispose()
78
- ```
79
-
80
- ## Concepts
81
-
82
- - **Spacetime composability**: components can be inserted, replaced, and removed at runtime; effects are reversed in order on teardown, so hot-swaps leave no residue.
83
- - **Eval as infrastructure**: strategies, tasks, evidence, verdicts, and runs are pluggable primitives, and evaluation is also the fitness function for self-evolution.
84
- - **Self-evolution**: `evolve` proposes candidates, evaluates them in isolated scopes, and accepts or rejects them through deterministic gates.
85
-
86
- See the [Chinese guide](docs/zh-CN.md) for the detailed design, model pricing table, library contracts, and roadmap.
87
-
88
- ## Development
89
-
90
- ```bash
91
- pnpm install
92
- pnpm test
93
- pnpm typecheck
94
- pnpm lint
95
- pnpm build
96
- ```
97
-
98
- ## License
99
-
100
- MIT
1
+ # Tnega
2
+
3
+ [中文](docs/zh-CN.md)
4
+
5
+ **Tnega** is "agent" spelled backwards. It is an eval-first agent harness with spacetime-composable plugin lifecycles: components can be hot-swapped and rolled back safely, and Eval is a first-class citizen on par with the agent loop and tools.
6
+
7
+ ## Install
8
+
9
+ Requires Node.js >= 22.
10
+
11
+ ```bash
12
+ npm install -g tnega
13
+ # or
14
+ pnpm add -g tnega
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```bash
20
+ export OPENCODE_GO_API_KEY=sk-...
21
+ tnega run "Reply with: hello"
22
+ ```
23
+
24
+ `tnega run` uses OpenCode Go's `deepseek-v4-flash` model through the OpenAI compatible endpoint by default. `minimax-m3` is also available through the Anthropic Messages endpoint. The API key can also come from `~/.tnega/config.json` (Windows: `%USERPROFILE%\.tnega\config.json`) with fields `apiKey`, `model`, `baseUrl`, and `temperature`. Precedence: CLI flags > environment variables > config file > defaults.
25
+
26
+ Run a deterministic eval without an API key:
27
+
28
+ ```bash
29
+ tnega eval run examples/tasks.yml
30
+ ```
31
+
32
+ Start the local web UI:
33
+
34
+ ```bash
35
+ tnega web
36
+ # http://127.0.0.1:3080
37
+ ```
38
+
39
+ The web UI creates sessions as either `general` or `coding` agents. Coding
40
+ sessions support `auto` / `plan` / `execute` modes; plan mode shows the LLM
41
+ generated todo list above the composer and updates each item as tools mark it
42
+ done or failed. `/` slash commands such as `/mode`, `/skills`, and `/mcp` are
43
+ available in coding sessions.
44
+
45
+ ## CLI
46
+
47
+ ```text
48
+ tnega run "prompt" # one agent session
49
+ tnega run --allow-shell "list files" # enable high-permission tools
50
+ tnega web # local web UI
51
+ tnega eval run tasks.yml # run evals
52
+ tnega eval compare <base> <head> # compare two eval runs
53
+ tnega evolve run tasks.yml # run a self-evolution loop
54
+ ```
55
+
56
+ Options include `--model`, `--base-url`, `--max-tokens`, `--temperature`, `--cwd`, `--session`, `--timeout-ms`, `--max-retries`, and `--retry-delay-ms`. Sessions are recorded as JSONL under `.tnega/`.
57
+
58
+ ## Built-in Tools
59
+
60
+ The default tool set is `echo`, `now`, `calculator`, `json`, `read_file`, `write_file`, `list_dir`, `glob`, and `grep`. High-permission tools are opt-in: `http_get` requires `--allow-network`, `shell` requires `--allow-shell`. File and shell tools are confined to the working directory.
61
+
62
+ ## Coding Agent
63
+
64
+ `tnega/coding-agent` is a packaged agent plugin for workspace-oriented coding
65
+ sessions. It contributes plan generation, `plan_execute_mark` /
66
+ `plan_execute_result` tools, workspace skills (`skills_list` / `skill_read`),
67
+ stdio MCP servers from `.tnega/mcp.json`, and a slash command registry. The web
68
+ server enables it per session through `agentType: "coding"`, while general
69
+ sessions keep the default loop unchanged.
70
+
71
+ ## Library
72
+
73
+ Tnega is published as a library as well as a CLI. Use the root package or domain subpaths (`tnega/core`, `tnega/agent`, `tnega/coding-agent`, `tnega/eval`, `tnega/evolve`, `tnega/session`, `tnega/tools`, `tnega/llm`, ...):
74
+
75
+ ```ts
76
+ import { Context, defineAgent, openaiCompatAdapter } from 'tnega'
77
+
78
+ const root = new Context()
79
+ const fiber = await root.plugin(
80
+ defineAgent({
81
+ name: 'coding-agent',
82
+ version: '0.3.0',
83
+ system: 'You are a coding agent.',
84
+ }),
85
+ { llm: openaiCompatAdapter({ apiKey: process.env.OPENCODE_GO_API_KEY! }) },
86
+ )
87
+
88
+ const loop = root.get('agentLoop')
89
+ const result = await loop({ text: 'implement the feature' })
90
+ console.log(result.output)
91
+
92
+ await fiber.dispose()
93
+ ```
94
+
95
+ ## Concepts
96
+
97
+ - **Spacetime composability**: components can be inserted, replaced, and removed at runtime; effects are reversed in order on teardown, so hot-swaps leave no residue.
98
+ - **Eval as infrastructure**: strategies, tasks, evidence, verdicts, and runs are pluggable primitives, and evaluation is also the fitness function for self-evolution.
99
+ - **Self-evolution**: `evolve` proposes candidates, evaluates them in isolated scopes, and accepts or rejects them through deterministic gates.
100
+
101
+ See the [Chinese guide](docs/zh-CN.md) for the detailed design, model pricing table, library contracts, and roadmap.
102
+
103
+ ## Development
104
+
105
+ ```bash
106
+ pnpm install
107
+ pnpm test
108
+ pnpm typecheck
109
+ pnpm lint
110
+ pnpm build
111
+ ```
112
+
113
+ ## License
114
+
115
+ MIT