@eminent337/aery 0.1.27 → 0.1.29
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/README.md +2 -0
- package/dist/core/sdk.d.ts.map +1 -1
- package/dist/core/sdk.js +1 -1
- package/dist/core/sdk.js.map +1 -1
- package/dist/core/system-prompt.d.ts.map +1 -1
- package/dist/core/system-prompt.js +1 -1
- package/dist/core/system-prompt.js.map +1 -1
- package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
- package/dist/modes/interactive/interactive-mode.js +2 -2
- package/dist/modes/interactive/interactive-mode.js.map +1 -1
- package/docs/compaction.md +10 -10
- package/docs/custom-provider.md +18 -18
- package/docs/development.md +3 -3
- package/docs/extensions.md +163 -163
- package/docs/json.md +3 -3
- package/docs/keybindings.md +5 -5
- package/docs/models.md +1 -1
- package/docs/packages.md +9 -9
- package/docs/prompt-templates.md +3 -3
- package/docs/providers.md +2 -2
- package/docs/rpc.md +8 -8
- package/docs/sdk.md +15 -15
- package/docs/session.md +3 -3
- package/docs/settings.md +7 -7
- package/docs/shell-aliases.md +1 -1
- package/docs/skills.md +5 -5
- package/docs/terminal-setup.md +1 -1
- package/docs/termux.md +2 -2
- package/docs/themes.md +5 -5
- package/docs/tree.md +1 -1
- package/docs/tui.md +9 -9
- package/docs/windows.md +1 -1
- package/package.json +3 -2
package/docs/compaction.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Compaction & Branch Summarization
|
|
2
2
|
|
|
3
|
-
LLMs have limited context windows. When conversations grow too long,
|
|
3
|
+
LLMs have limited context windows. When conversations grow too long, Aery uses compaction to summarize older content while preserving recent work. This page covers both auto-compaction and branch summarization.
|
|
4
4
|
|
|
5
5
|
**Source files** ([aery](https://github.com/eminent337/aery)):
|
|
6
6
|
- [`packages/coding-agent/src/core/compaction/compaction.ts`](https://github.com/eminent337/aery/blob/main/packages/coding-agent/src/core/compaction/compaction.ts) - Auto-compaction logic
|
|
@@ -32,13 +32,13 @@ Auto-compaction triggers when:
|
|
|
32
32
|
contextTokens > contextWindow - reserveTokens
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
By default, `reserveTokens` is 16384 tokens (configurable in `~/.
|
|
35
|
+
By default, `reserveTokens` is 16384 tokens (configurable in `~/.aery/agent/settings.json` or `<project-dir>/.aery/settings.json`). This leaves room for the LLM's response.
|
|
36
36
|
|
|
37
37
|
You can also trigger manually with `/compact [instructions]`, where optional instructions focus the summary.
|
|
38
38
|
|
|
39
39
|
### How It Works
|
|
40
40
|
|
|
41
|
-
1. **Find cut point**: Walk backwards from newest message, accumulating token estimates until `keepRecentTokens` (default 20k, configurable in `~/.
|
|
41
|
+
1. **Find cut point**: Walk backwards from newest message, accumulating token estimates until `keepRecentTokens` (default 20k, configurable in `~/.aery/agent/settings.json` or `<project-dir>/.aery/settings.json`) is reached
|
|
42
42
|
2. **Extract messages**: Collect messages from the previous kept boundary (or session start) up to the cut point
|
|
43
43
|
3. **Generate summary**: Call LLM to summarize with structured format, passing the previous summary as iterative context when present
|
|
44
44
|
4. **Append entry**: Save `CompactionEntry` with summary and `firstKeptEntryId`
|
|
@@ -102,7 +102,7 @@ Split turn (one huge turn exceeds budget):
|
|
|
102
102
|
turnPrefixMessages = [usr, ass, tool, ass, tool, tool]
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
-
For split turns,
|
|
105
|
+
For split turns, Aery generates two summaries and merges them:
|
|
106
106
|
1. **History summary**: Previous context (if any)
|
|
107
107
|
2. **Turn prefix summary**: The early part of the split turn
|
|
108
108
|
|
|
@@ -148,7 +148,7 @@ See [`prepareCompaction()`](https://github.com/eminent337/aery/blob/main/package
|
|
|
148
148
|
|
|
149
149
|
### When It Triggers
|
|
150
150
|
|
|
151
|
-
When you use `/tree` to navigate to a different branch,
|
|
151
|
+
When you use `/tree` to navigate to a different branch, Aery offers to summarize the work you're leaving. This injects context from the left branch into the new branch.
|
|
152
152
|
|
|
153
153
|
### How It Works
|
|
154
154
|
|
|
@@ -177,7 +177,7 @@ After navigation with summary:
|
|
|
177
177
|
|
|
178
178
|
### Cumulative File Tracking
|
|
179
179
|
|
|
180
|
-
Both compaction and branch summarization track files cumulatively. When generating a summary,
|
|
180
|
+
Both compaction and branch summarization track files cumulatively. When generating a summary, Aery extracts file operations from:
|
|
181
181
|
- Tool calls in the messages being summarized
|
|
182
182
|
- Previous compaction or branch summary `details` (if any)
|
|
183
183
|
|
|
@@ -275,7 +275,7 @@ Extensions can intercept and customize both compaction and branch summarization.
|
|
|
275
275
|
Fired before auto-compaction or `/compact`. Can cancel or provide custom summary. See `SessionBeforeCompactEvent` and `CompactionPreparation` in the types file.
|
|
276
276
|
|
|
277
277
|
```typescript
|
|
278
|
-
|
|
278
|
+
aery.on("session_before_compact", async (event, ctx) => {
|
|
279
279
|
const { preparation, branchEntries, customInstructions, signal } = event;
|
|
280
280
|
|
|
281
281
|
// preparation.messagesToSummarize - messages to summarize
|
|
@@ -311,7 +311,7 @@ To generate a summary with your own model, convert messages to text using `seria
|
|
|
311
311
|
```typescript
|
|
312
312
|
import { convertToLlm, serializeConversation } from "@eminent337/aery";
|
|
313
313
|
|
|
314
|
-
|
|
314
|
+
aery.on("session_before_compact", async (event, ctx) => {
|
|
315
315
|
const { preparation } = event;
|
|
316
316
|
|
|
317
317
|
// Convert AgentMessage[] to Message[], then serialize to text
|
|
@@ -345,7 +345,7 @@ See [custom-compaction.ts](../examples/extensions/custom-compaction.ts) for a co
|
|
|
345
345
|
Fired before `/tree` navigation. Always fires regardless of whether user chose to summarize. Can cancel navigation or provide custom summary.
|
|
346
346
|
|
|
347
347
|
```typescript
|
|
348
|
-
|
|
348
|
+
aery.on("session_before_tree", async (event, ctx) => {
|
|
349
349
|
const { preparation, signal } = event;
|
|
350
350
|
|
|
351
351
|
// preparation.targetId - where we're navigating to
|
|
@@ -373,7 +373,7 @@ See `SessionBeforeTreeEvent` and `TreePreparation` in the types file.
|
|
|
373
373
|
|
|
374
374
|
## Settings
|
|
375
375
|
|
|
376
|
-
Configure compaction in `~/.
|
|
376
|
+
Configure compaction in `~/.aery/agent/settings.json` or `<project-dir>/.aery/settings.json`:
|
|
377
377
|
|
|
378
378
|
```json
|
|
379
379
|
{
|
package/docs/custom-provider.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Custom Providers
|
|
2
2
|
|
|
3
|
-
Extensions can register custom model providers via `
|
|
3
|
+
Extensions can register custom model providers via `aery.registerProvider()`. This enables:
|
|
4
4
|
|
|
5
5
|
- **Proxies** - Route requests through corporate proxies or API gateways
|
|
6
6
|
- **Custom endpoints** - Use self-hosted or private model deployments
|
|
@@ -33,14 +33,14 @@ See these complete provider examples:
|
|
|
33
33
|
```typescript
|
|
34
34
|
import type { ExtensionAPI } from "@eminent337/aery";
|
|
35
35
|
|
|
36
|
-
export default function (
|
|
36
|
+
export default function (aery: ExtensionAPI) {
|
|
37
37
|
// Override baseUrl for existing provider
|
|
38
|
-
|
|
38
|
+
aery.registerProvider("anthropic", {
|
|
39
39
|
baseUrl: "https://proxy.example.com"
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
// Register new provider with models
|
|
43
|
-
|
|
43
|
+
aery.registerProvider("my-provider", {
|
|
44
44
|
baseUrl: "https://api.example.com",
|
|
45
45
|
apiKey: "MY_API_KEY",
|
|
46
46
|
api: "openai-completions",
|
|
@@ -59,7 +59,7 @@ export default function (pi: ExtensionAPI) {
|
|
|
59
59
|
}
|
|
60
60
|
```
|
|
61
61
|
|
|
62
|
-
The extension factory can also be `async`. For dynamic model discovery, fetch and register models in the factory instead of `session_start`.
|
|
62
|
+
The extension factory can also be `async`. For dynamic model discovery, fetch and register models in the factory instead of `session_start`. Aery waits for the factory before startup continues, so the provider is available during interactive startup and to `aery --list-models`.
|
|
63
63
|
|
|
64
64
|
## Override Existing Provider
|
|
65
65
|
|
|
@@ -67,19 +67,19 @@ The simplest use case: redirect an existing provider through a proxy.
|
|
|
67
67
|
|
|
68
68
|
```typescript
|
|
69
69
|
// All Anthropic requests now go through your proxy
|
|
70
|
-
|
|
70
|
+
aery.registerProvider("anthropic", {
|
|
71
71
|
baseUrl: "https://proxy.example.com"
|
|
72
72
|
});
|
|
73
73
|
|
|
74
74
|
// Add custom headers to OpenAI requests
|
|
75
|
-
|
|
75
|
+
aery.registerProvider("openai", {
|
|
76
76
|
headers: {
|
|
77
77
|
"X-Custom-Header": "value"
|
|
78
78
|
}
|
|
79
79
|
});
|
|
80
80
|
|
|
81
81
|
// Both baseUrl and headers
|
|
82
|
-
|
|
82
|
+
aery.registerProvider("google", {
|
|
83
83
|
baseUrl: "https://ai-gateway.corp.com/google",
|
|
84
84
|
headers: {
|
|
85
85
|
"X-Corp-Auth": "CORP_AUTH_TOKEN" // env var or literal
|
|
@@ -98,7 +98,7 @@ If the model list comes from a remote endpoint, use an async extension factory:
|
|
|
98
98
|
```typescript
|
|
99
99
|
import type { ExtensionAPI } from "@eminent337/aery";
|
|
100
100
|
|
|
101
|
-
export default async function (
|
|
101
|
+
export default async function (aery: ExtensionAPI) {
|
|
102
102
|
const response = await fetch("http://localhost:1234/v1/models");
|
|
103
103
|
const payload = (await response.json()) as {
|
|
104
104
|
data: Array<{
|
|
@@ -109,7 +109,7 @@ export default async function (pi: ExtensionAPI) {
|
|
|
109
109
|
}>;
|
|
110
110
|
};
|
|
111
111
|
|
|
112
|
-
|
|
112
|
+
aery.registerProvider("local-openai", {
|
|
113
113
|
baseUrl: "http://localhost:1234/v1",
|
|
114
114
|
apiKey: "LOCAL_OPENAI_API_KEY",
|
|
115
115
|
api: "openai-completions",
|
|
@@ -129,7 +129,7 @@ export default async function (pi: ExtensionAPI) {
|
|
|
129
129
|
This registers the fetched models before startup finishes.
|
|
130
130
|
|
|
131
131
|
```typescript
|
|
132
|
-
|
|
132
|
+
aery.registerProvider("my-llm", {
|
|
133
133
|
baseUrl: "https://api.my-llm.com/v1",
|
|
134
134
|
apiKey: "MY_LLM_API_KEY", // env var name or literal value
|
|
135
135
|
api: "openai-completions", // which streaming API to use
|
|
@@ -156,11 +156,11 @@ When `models` is provided, it **replaces** all existing models for that provider
|
|
|
156
156
|
|
|
157
157
|
## Unregister Provider
|
|
158
158
|
|
|
159
|
-
Use `
|
|
159
|
+
Use `aery.unregisterProvider(name)` to remove a provider that was previously registered via `aery.registerProvider(name, ...)`:
|
|
160
160
|
|
|
161
161
|
```typescript
|
|
162
162
|
// Register
|
|
163
|
-
|
|
163
|
+
aery.registerProvider("my-llm", {
|
|
164
164
|
baseUrl: "https://api.my-llm.com/v1",
|
|
165
165
|
apiKey: "MY_LLM_API_KEY",
|
|
166
166
|
api: "openai-completions",
|
|
@@ -178,7 +178,7 @@ pi.registerProvider("my-llm", {
|
|
|
178
178
|
});
|
|
179
179
|
|
|
180
180
|
// Later, remove it
|
|
181
|
-
|
|
181
|
+
aery.unregisterProvider("my-llm");
|
|
182
182
|
```
|
|
183
183
|
|
|
184
184
|
Unregistering removes that provider's dynamic models, API key fallback, OAuth provider registration, and custom stream handler registrations. Any built-in models or provider behavior that were overridden are restored.
|
|
@@ -238,7 +238,7 @@ Use `cacheControlFormat: "anthropic"` for OpenAI-compatible providers that expos
|
|
|
238
238
|
If your provider expects `Authorization: Bearer <key>` but doesn't use a standard API, set `authHeader: true`:
|
|
239
239
|
|
|
240
240
|
```typescript
|
|
241
|
-
|
|
241
|
+
aery.registerProvider("custom-api", {
|
|
242
242
|
baseUrl: "https://api.example.com",
|
|
243
243
|
apiKey: "MY_API_KEY",
|
|
244
244
|
authHeader: true, // adds Authorization: Bearer header
|
|
@@ -254,7 +254,7 @@ Add OAuth/SSO authentication that integrates with `/login`:
|
|
|
254
254
|
```typescript
|
|
255
255
|
import type { OAuthCredentials, OAuthLoginCallbacks } from "@eminent337/aery-ai";
|
|
256
256
|
|
|
257
|
-
|
|
257
|
+
aery.registerProvider("corporate-ai", {
|
|
258
258
|
baseUrl: "https://ai.corp.com/v1",
|
|
259
259
|
api: "openai-responses",
|
|
260
260
|
models: [...],
|
|
@@ -330,7 +330,7 @@ interface OAuthLoginCallbacks {
|
|
|
330
330
|
|
|
331
331
|
### OAuthCredentials
|
|
332
332
|
|
|
333
|
-
Credentials are persisted in `~/.
|
|
333
|
+
Credentials are persisted in `~/.aery/agent/auth.json`:
|
|
334
334
|
|
|
335
335
|
```typescript
|
|
336
336
|
interface OAuthCredentials {
|
|
@@ -511,7 +511,7 @@ calculateCost(model, output.usage);
|
|
|
511
511
|
Register your stream function:
|
|
512
512
|
|
|
513
513
|
```typescript
|
|
514
|
-
|
|
514
|
+
aery.registerProvider("my-provider", {
|
|
515
515
|
baseUrl: "https://api.example.com",
|
|
516
516
|
apiKey: "MY_API_KEY",
|
|
517
517
|
api: "my-custom-api",
|
package/docs/development.md
CHANGED
|
@@ -26,8 +26,8 @@ Configure via `package.json`:
|
|
|
26
26
|
```json
|
|
27
27
|
{
|
|
28
28
|
"aeryConfig": {
|
|
29
|
-
"name": "
|
|
30
|
-
"configDir": ".
|
|
29
|
+
"name": "aery",
|
|
30
|
+
"configDir": ".aery"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
```
|
|
@@ -48,7 +48,7 @@ Never use `__dirname` directly for package assets.
|
|
|
48
48
|
|
|
49
49
|
## Debug Command
|
|
50
50
|
|
|
51
|
-
`/debug` (hidden) writes to `~/.
|
|
51
|
+
`/debug` (hidden) writes to `~/.aery/agent/aery-debug.log`:
|
|
52
52
|
- Rendered TUI lines with ANSI codes
|
|
53
53
|
- Last messages sent to the LLM
|
|
54
54
|
|