Commit Graph

94 Commits

Author SHA1 Message Date
Mario Zechner 90c017b05b Merge remote-tracking branch 'origin/main' into bigrefactor
# Conflicts:
#	package-lock.json
#	packages/agent/package.json
2026-05-08 13:38:20 +02:00
Mario Zechner e1647aaa00 refactor(agent): make resource invocation explicit 2026-05-08 13:35:54 +02:00
Mario Zechner 3e5ad67e0f chore: migrate pi packages to earendil works scope 2026-05-07 15:59:42 +02:00
Mario Zechner 65206cfba8 docs(agent): document harness resource types 2026-05-07 11:26:15 +02:00
Mario Zechner ddb18640e3 feat(agent): return diagnostics from resource loaders 2026-05-06 21:59:48 +02:00
Mario Zechner 617d8b317d refactor(agent): tighten harness environment and resources 2026-05-06 19:41:17 +02:00
Mario Zechner e1ca501da8 refactor(agent): expose concrete harness 2026-05-06 13:21:08 +02:00
Mario Zechner 530f14c018 refactor(agent): expose concrete harness session 2026-05-06 12:57:19 +02:00
Mario Zechner d29e47c771 feat(agent): add harness factory helpers 2026-05-04 01:15:53 +02:00
Mario Zechner 3d0f57187d refactor(agent): simplify harness session repo layout 2026-05-04 00:06:35 +02:00
Mario Zechner cdde2e893d refactor(agent): consolidate harness session abstraction 2026-05-03 22:01:40 +02:00
Mario Zechner e612149369 refactor(agent): tighten harness session storage 2026-05-03 13:21:14 +02:00
Mario Zechner 83599e789d feat(agent): split harness compaction and session modules 2026-05-03 03:13:45 +02:00
Mario Zechner a5b27367d3 feat(agent): add initial harness foundation 2026-05-03 00:35:36 +02:00
Mario Zechner b8bb2411ff fix(ai): honor codex transport option
closes #4083
2026-05-02 14:14:22 +02:00
Mario Zechner 80f06d3636 feat: add model thinking level metadata
closes #3208
2026-05-02 01:21:06 +02:00
Mario Zechner 73b7b2c564 feat(agent): add post-turn stop callback 2026-05-02 01:20:26 +02:00
Mario Zechner bf4aa3a601 fix(ai): support xhigh for Codex GPT-5.5 2026-04-23 22:49:09 +02:00
Armin Ronacher 35ff2689ee fix(typebox): migrate to v1 with extension compat (#3474)
* fix(typebox): migrate to v1 with extension compat

Replace AJV-based validation with TypeBox-native validation, keep legacy extension imports working (including @sinclair/typebox/compiler), and restore coercion for serialized/plain JSON schemas.

This change closes #3112.

* fix(typebox): use canonical imports and harden coercion

Switch first-party code to canonical typebox imports while retaining legacy extension aliases in the loader.

Remove obsolete runtime codegen guards, expand serialized JSON-schema coercion coverage, and update related tests and fixtures.

Fixes #3112.

---------

Co-authored-by: Mario Zechner <badlogicgames@gmail.com>
2026-04-22 19:59:33 +02:00
Mario Zechner 049e320570 feat(agent): add terminating tool result hints closes #3525 2026-04-22 13:26:01 +02:00
Mario Zechner 32859bdf9a fix(agent): preserve proxy stream options closes #3512 2026-04-22 00:34:20 +02:00
Mario Zechner 759d551527 fix(agent): emit parallel tool completion eagerly\n\ncloses #3503 2026-04-22 00:15:56 +02:00
Mario Zechner 7b1599058b docs(agent): clarify parallel tool ordering closes #3468 2026-04-20 22:35:43 +02:00
Aliou Diallo bfa11a50e4 feat(agent,coding-agent): per-tool executionMode override for sequential tool execution (#3345)
* feat(agent,coding-agent): add per-tool executionMode field to AgentTool and ToolDefinition

Add optional executionMode?: ToolExecutionMode to AgentTool and
ToolDefinition interfaces. Propagate through wrapToolDefinition and
createToolDefinitionFromAgentTool. No behavioral change yet — agent
loop will read this field in a follow-up.

* feat(agent): support per-tool executionMode override for sequential execution

When a tool defines executionMode='sequential', the agent loop
forces sequential execution of all tool calls in that batch,
even if the global config is parallel.

* feat(coding-agent): re-export ToolExecutionMode from @mariozechner/pi-agent-core

Makes the type available to extensions that want to set
executionMode on tool definitions.

* feat(coding-agent): add tic-tac-toe extension example with executionMode: sequential

Demonstrates per-tool executionMode: the agent plays via move/play
tool calls that share a cursor. Without sequential execution, play
can resolve before earlier moves finish, landing on the wrong cell.
2026-04-18 00:45:57 +02:00
Mario Zechner b9cd557d1d fix(agent): guard afterToolCall hook errors in finalization
closes #3084
2026-04-16 23:51:38 +02:00
Mario Zechner d131fcd4ba feat(coding-agent): add after_provider_response hook closes #3128 2026-04-16 20:28:08 +02:00
Mario Zechner 9022a5b5ea fix(agent): await subscribed event handlers 2026-03-30 14:13:30 +02:00
Mario Zechner cbe1a8b732 fix(agent): simplify state API and update consumers fixes #2633 2026-03-30 12:43:34 +02:00
Mario Zechner b5f425ad15 feat(agent,coding-agent): add prepareArguments hook for pre-validation argument preparation
Add AgentTool.prepareArguments and ToolDefinition.prepareArguments hook
that runs before schema validation in the agent loop. This lets tools
silently accept legacy argument shapes from resumed old sessions without
polluting the public schema.

The built-in edit tool uses this to fold legacy top-level oldText/newText
into edits[] when resuming sessions that predate the edits-only schema.

- AgentTool/ToolDefinition: typed prepareArguments returning Static<TParameters>
- agent-loop: prepareToolCallArguments() runs before validateToolArguments()
- edit tool: prepareEditArguments folds legacy fields, validateEditInput is strict
- Documented in extensions.md with edit-tool example
2026-03-29 21:06:22 +02:00
Mario Zechner 7d4faa080d fix: expose abort signal to extensions closes #2660 2026-03-28 22:25:06 +01:00
Mario Zechner 8a8e2a8049 docs(agent): update steering docs for deferred tool execution closes #2330 2026-03-18 03:49:30 +01:00
Mario Zechner 208a2cc123 fix(agent): defer steering until after tool execution 2026-03-16 20:23:28 +01:00
Mario Zechner 63ac2df24d fix(coding-agent): sync tool hooks with agent event processing closes #2113 2026-03-14 03:10:04 +01:00
Mario Zechner 4aa25bfb72 docs(agent,ai): clarify non-throwing stream and hook contracts 2026-03-13 22:54:41 +01:00
Mario Zechner ea1a1f8266 docs(agent): clarify non-throwing stream contracts fixes #2119 2026-03-13 22:49:27 +01:00
Mario Zechner a3f05423d9 feat(coding-agent): add provider payload hook 2026-03-07 14:34:28 +01:00
Mario Zechner a26a9cfabd feat: add configurable transport and codex websocket session caching 2026-02-13 23:41:49 +01:00
Mario Zechner b050c582a1 fix(agent,coding-agent): resume queued messages after auto-compaction 2026-02-06 11:36:19 +01:00
Mario Zechner b07b72ba2b feat(ai): add xhigh thinking level support for gpt-5.3 models 2026-02-05 20:54:57 +01:00
Mario Zechner 030a61d88c feat: add maxDelayMs setting to cap server-requested retry delays
When a provider (e.g., Google Gemini CLI) requests a retry delay longer
than maxDelayMs (default: 60s), the request fails immediately with an
informative error instead of waiting silently for hours.

The error is then handled by agent-level auto-retry, which shows the
delay to the user and allows aborting with Escape.

- Add maxRetryDelayMs to StreamOptions (packages/ai)
- Add maxRetryDelayMs to AgentOptions (packages/agent)
- Add retry.maxDelayMs to settings (packages/coding-agent)
- Update _isRetryableError to match 'retry delay' errors

fixes #1123
2026-02-01 00:50:41 +01:00
Mario Zechner 2b75948c2e fix(ai): export parseStreamingJson from main package for tsx compatibility 2026-01-13 22:08:19 +01:00
Melih Mucuk 0f27eae77e feat: add thinkingBudgets option to customize token budgets 2026-01-07 15:13:26 +03:00
Mario Zechner edb0da9611 feat(ai,agent,coding-agent): add sessionId for provider session-based caching
- Add sessionId to StreamOptions for providers that support session-based caching
- OpenAI Codex provider uses sessionId for prompt_cache_key and routing headers
- Agent class now accepts and forwards sessionId to stream functions
- coding-agent passes session ID from SessionManager and updates on session changes
- Update ai package README with table of contents, OpenAI Codex OAuth docs, and env vars table
- Increase Codex instructions cache TTL from 15 minutes to 24 hours
- Add tests for sessionId forwarding in ai and agent packages
2026-01-06 11:08:42 +01:00
Mario Zechner 0b9e3ada0c fix: clean up Codex thinking level handling
- Remove per-thinking-level model variants (gpt-5.2-codex-high, etc.)
- Remove thinkingLevels from Model type
- Provider clamps reasoning effort internally
- Omit reasoning field when thinking is off

fixes #472
2026-01-05 21:58:26 +01:00
Ben Vargas 02b72b49d5 fix: codex thinking handling 2026-01-05 21:55:47 +01:00
Mario Zechner c6fc084534 Merge hooks and custom-tools into unified extensions system (#454)
Breaking changes:
- Settings: 'hooks' and 'customTools' arrays replaced with 'extensions'
- CLI: '--hook' and '--tool' flags replaced with '--extension' / '-e'
- API: HookMessage renamed to CustomMessage, role 'hookMessage' to 'custom'
- API: FileSlashCommand renamed to PromptTemplate
- API: discoverSlashCommands() renamed to discoverPromptTemplates()
- Directories: commands/ renamed to prompts/ for prompt templates

Migration:
- Session version bumped to 3 (auto-migrates v2 sessions)
- Old 'hookMessage' role entries converted to 'custom'

Structural changes:
- src/core/hooks/ and src/core/custom-tools/ merged into src/core/extensions/
- src/core/slash-commands.ts renamed to src/core/prompt-templates.ts
- examples/hooks/ and examples/custom-tools/ merged into examples/extensions/
- docs/hooks.md and docs/custom-tools.md merged into docs/extensions.md

New test coverage:
- test/extensions-runner.test.ts (10 tests)
- test/extensions-discovery.test.ts (26 tests)
- test/prompt-templates.test.ts
2026-01-05 01:43:35 +01:00
Mario Zechner d0a4c37028 feat(agent): split queue into steer() and followUp() APIs
Breaking change: replaces queueMessage() with two separate methods:
- steer(msg): interrupt mid-run, delivered after current tool execution
- followUp(msg): wait until agent finishes before delivery

Also renames:
- queueMode -> steeringMode/followUpMode
- getQueuedMessages -> getSteeringMessages/getFollowUpMessages

Refs #403
2026-01-03 00:13:25 +01:00
Mario Zechner 5ef3cc90d1 Add guard against concurrent prompt() calls
Agent.prompt() and Agent.continue() now throw if called while already
streaming, preventing race conditions and corrupted state. Use
queueMessage() to queue messages during streaming, or await the
previous call.

AgentSession.prompt() has the same guard with a message directing
users to queueMessage().

Ref #403
2026-01-02 22:02:24 +01:00
Mario Zechner 74637403b6 Update agent package: changelog, fix README type name, export proxy utilities 2025-12-30 23:33:32 +01:00
Mario Zechner 41af99cccf Support multiple messages in agent.prompt() and agentLoop
- agentLoop now accepts AgentMessage[] instead of single message
- agent.prompt() accepts AgentMessage | AgentMessage[]
- Emits message_start/end for each message in the array
- AgentSession.prompt() builds array with hook message + user message
- TUI now receives events for before_agent_start injected messages
2025-12-30 22:42:22 +01:00