Commit graph

222 commits

Author SHA1 Message Date
Mario Zechner
256d9a26bb Add CHANGELOG.md to agent package with refactor details 2025-12-30 22:42:20 +01:00
Mario Zechner
fa22595f25 Update READMEs: remove agent section from pi-ai, rewrite pi-agent-core
- Removed Agent API section from pi-ai README (moved to agent package)
- Rewrote agent package README for new architecture:
  - No more transports (ProviderTransport, AppTransport removed)
  - Uses streamFn directly with streamProxy for proxy usage
  - Documents convertToLlm and transformContext
  - Documents low-level agentLoop/agentLoopContinue API
  - Updated custom message types documentation
2025-12-30 22:42:20 +01:00
Mario Zechner
a055fd4481 WIP: Refactor agent package - not compiling
- Renamed AppMessage to AgentMessage throughout
- New agent-loop.ts with AgentLoopContext, AgentLoopConfig
- Removed transport abstraction, Agent now takes streamFn directly
- Extracted streamProxy to proxy.ts utility
- Removed agent-loop from pi-ai (now in agent package)
- Updated consumers (coding-agent, mom) for AgentMessage rename
- Tests updated but some consumers still need migration

Known issues:
- AgentTool, AgentToolResult not exported from pi-ai
- Attachment not exported from pi-agent-core
- ProviderTransport removed but still referenced
- messageTransformer -> convertToLlm migration incomplete
- CustomMessages declaration merging not working properly
2025-12-30 22:42:20 +01:00
Mario Zechner
f7ef44dc38 Fix: transform userMessage in _runAgentLoop before passing to transport
HookMessage (role: hookMessage) was being passed directly to transport
without transformation. Now it's transformed via messageTransformer
which converts it to a proper user message for the LLM.
2025-12-30 22:42:20 +01:00
Mario Zechner
204d27581b Cleanup: unify HookMessage naming and simplify SessionContext
- Rename HookAppMessage to HookMessage, isHookAppMessage to isHookMessage
- Remove entries array from SessionContext (use isHookMessage type guard instead)
- HookMessage.content now accepts string directly (not just array)
- Fix streamMessage type in AgentState (AppMessage, not Message)
- Rename CustomMessageComponent to HookMessageComponent
- Fix test hook to use pi.sendMessage
2025-12-30 22:42:20 +01:00
Mario Zechner
a2515cf43f Wire context event to preprocessor for per-LLM-call execution
- Change from contextTransform (runs once at agent start) to preprocessor
- preprocessor runs before EACH LLM call inside the agent loop
- ContextEvent now uses Message[] (pi-ai format) instead of AppMessage[]
- Deep copy handled by pi-ai preprocessor, not Agent

This enables:
- Pruning rules applied on every turn (not just agent start)
- /prune during long agent loop takes effect immediately
- Compaction can use same transforms (future work)
2025-12-30 22:42:20 +01:00
Mario Zechner
77fe3f1a13 Add context event for non-destructive message modification before LLM calls
- Add contextTransform option to Agent (runs before messageTransformer)
- Deep copy messages before passing to contextTransform (modifications are ephemeral)
- Add ContextEvent and ContextEventResult types
- Add emitContext() to HookRunner (chains multiple handlers)
- Wire up in sdk.ts when creating Agent with hooks

Enables dynamic context pruning: hooks can modify messages sent to LLM
without changing session data. See discussion #330.
2025-12-30 22:42:20 +01:00
Mario Zechner
c1b4d043a8 Remove emitLastMessage from continue(), use prompt(AppMessage) instead
Cleans up the temporary emitLastMessage plumbing since we now use
Agent.prompt(AppMessage) for hook messages instead of appendMessage+continue.

- Remove emitLastMessage parameter from Agent.continue()
- Remove from transport interface and implementations
- Remove from agentLoopContinue()
2025-12-30 22:42:19 +01:00
Mario Zechner
a6322fda59 Add Agent.prompt(AppMessage) overload for custom message types
Instead of using continue() which validates roles, prompt() now accepts
an AppMessage directly. This allows hook messages with role: 'hookMessage'
to trigger proper agent loop with message events.

- Add overloads: prompt(AppMessage) and prompt(string, attachments?)
- sendHookMessage uses prompt(appMessage) instead of appendMessage+continue
2025-12-30 22:42:19 +01:00
Mario Zechner
357bd946c2 Add emitLastMessage flag to agent.continue()
When calling continue() with emitLastMessage=true, the agent loop
emits message_start/message_end events for the last message in context.
This allows messages added outside the loop (e.g., hook messages via
sendHookMessage) to trigger proper TUI rendering.

Changes across packages:
- packages/ai: agentLoopContinue() accepts emitLastMessage parameter
- packages/agent: Agent.continue(), transports updated to pass flag
- packages/coding-agent: sendHookMessage passes true when triggerTurn
2025-12-30 22:42:19 +01:00
Mario Zechner
0e8173af00 Release v0.30.2 2025-12-26 03:25:55 +01:00
Mario Zechner
9dcb0bdba4 Release v0.30.1
fixes #320
2025-12-26 03:13:37 +01:00
Mario Zechner
6d97d212d5 Release v0.30.0 2025-12-25 20:35:14 +01:00
Mario Zechner
19dde0a988 Release v0.29.1 2025-12-25 18:10:11 +01:00
Mario Zechner
b48a0c9328 Release v0.29.0 2025-12-25 04:16:42 +01:00
Mario Zechner
1059d39d54 Add removeRuntimeApiKey to AuthStorage 2025-12-25 03:57:20 +01:00
Mario Zechner
030788140a WIP: Remove global state from pi-ai OAuth/API key handling
- Remove setApiKey, resolveApiKey, and global apiKeys Map from stream.ts
- Rename getApiKey to getApiKeyFromEnv (only checks env vars)
- Remove OAuth storage layer (storage.ts deleted)
- OAuth login/refresh functions now return credentials instead of saving
- getOAuthApiKey/refreshOAuthToken now take credentials as params
- Add test/oauth.ts helper for ai package tests
- Simplify root npm run check (single biome + tsgo pass)
- Remove redundant check scripts from most packages
- Add web-ui and coding-agent examples to biome/tsgo includes

coding-agent still has compile errors - needs refactoring for new API
2025-12-25 01:01:03 +01:00
Mario Zechner
8fdd77b652 Release v0.27.9 2025-12-24 21:25:20 +01:00
Mario Zechner
a965b6f160 Release v0.27.8 - OAuth takes priority over settings.json API keys 2025-12-24 20:52:22 +01:00
Mario Zechner
89630b0d44 Release v0.27.7 2025-12-24 18:30:53 +01:00
Mario Zechner
3eb460ee50 Release v0.27.6 2025-12-24 13:59:09 +01:00
Mario Zechner
bf313d2713 Release v0.27.5 2025-12-24 12:18:51 +01:00
Mario Zechner
20b24cf5a4 Fix symlinked skill directories not being discovered
Release v0.27.4
2025-12-24 03:32:54 +01:00
Mario Zechner
f8619c1564 Release v0.27.3 2025-12-24 02:46:23 +01:00
Mario Zechner
c57ed89110 Release v0.27.2 2025-12-23 03:48:52 +01:00
Mario Zechner
4492a3f304 Release v0.27.1 2025-12-22 19:28:26 +01:00
Mario Zechner
b9b44f4cf4 Release v0.27.0 2025-12-22 18:20:10 +01:00
Mario Zechner
7e1b632596 Release v0.26.1 2025-12-22 16:19:19 +01:00
Mario Zechner
42bc368e70 Release v0.26.0 2025-12-22 12:53:58 +01:00
Mario Zechner
11e743373d Fix syntax highlighting stderr spam with malformed markdown, fixes #274 2025-12-22 00:23:01 +01:00
Mario Zechner
9c18439c4d Release v0.25.3 2025-12-21 21:01:27 +01:00
Mario Zechner
299986f06b Release v0.25.2 2025-12-21 02:59:03 +01:00
Mario Zechner
c97702cf91 Release v0.25.1 2025-12-21 02:43:47 +01:00
Mario Zechner
df07a74ad5 Release v0.25.0 2025-12-20 22:02:47 +01:00
Mario Zechner
085294b764 Release v0.24.5 2025-12-19 22:09:35 +01:00
Mario Zechner
f377c3c9c3 Release v0.24.4 2025-12-19 21:54:36 +01:00
Mario Zechner
ad4eb3afa6 Release v0.24.3 2025-12-19 21:36:16 +01:00
Mario Zechner
5095b4eb02 Release v0.24.2 2025-12-19 21:12:53 +01:00
Mario Zechner
50b055f3ae Release v0.24.1 2025-12-19 20:51:44 +01:00
theBucky
4f981d8ebc feat: add xhigh thinking level support for gpt-5.2 and gpt-5.2-codex
- Add XHIGH_MODELS constant and getAvailableThinkingLevels() to AgentSession
- Update ThinkingSelectorComponent to accept availableLevels parameter
- Both shift+tab cycling and /thinking command now show xhigh for supported models
- Update types.ts documentation to list supported models
2025-12-19 19:59:13 +01:00
Mario Zechner
16685a36ec Release v0.24.0 2025-12-19 05:21:25 +01:00
Mario Zechner
f92147ffe8 Release v0.23.5 2025-12-19 05:15:34 +01:00
Mario Zechner
774aaadbc0 Simplify getApiKey pass-through, add changelog entry for #223 2025-12-19 01:37:53 +01:00
Ahmed Kamal
1167e84453
Fix expired OAuth tokens in long-running agent loops (#223)
Add getApiKey hook to AgentLoopConfig that resolves API keys dynamically
before each LLM call. This allows short-lived OAuth tokens (e.g. GitHub
Copilot, Anthropic OAuth) to be refreshed between turns when tool
execution takes a long time.

Previously, the API key was resolved once when ProviderTransport.run()
was called and passed as a static string to the agent loop. If the loop
ran for longer than the token lifetime (e.g. 30 minutes for Copilot),
subsequent LLM calls would fail with expired token errors.

Changes:
- Add getApiKey hook to AgentLoopConfig (packages/ai)
- Call getApiKey before each LLM call in streamAssistantResponse
- Update ProviderTransport to pass getApiKey instead of static apiKey
- Update web-ui ProviderTransport with same pattern
2025-12-19 01:36:25 +01:00
Mario Zechner
2f86c8bc3c Release v0.23.4 2025-12-18 16:56:50 +01:00
Mario Zechner
b02516a5cd Switch to more stable, oldder tsgo, switch all check scripts to tsgo 2025-12-18 15:20:41 +01:00
Mario Zechner
21229398ad Update tsgo, switch to tsc for agent package, as tsgo hangs on Alpine in Docker x86 2025-12-18 15:02:03 +01:00
Mario Zechner
00851369fc Release v0.23.3 2025-12-17 22:29:46 +01:00
Mario Zechner
5e5bdadbf9 Improve system prompt docs, clean up theme/skills/hooks docs, fix toolResults type
- System prompt: clearer pointers to specific doc files
- theme.md: added thinkingXhigh, bashMode tokens, fixed Theme class methods
- skills.md: rewrote with better framing, examples, and skill repositories
- hooks.md: fixed timeout/error handling docs, added custom tool interception note
- Breaking: turn_end event toolResults changed from AppMessage[] to ToolResultMessage[]
2025-12-17 21:27:28 +01:00
Mario Zechner
4894fa411c Release v0.23.2
Fixed Claude models via GitHub Copilot re-answering all previous prompts.

fixes #209
2025-12-17 17:56:00 +01:00