Commit graph

13 commits

Author SHA1 Message Date
Mario Zechner
484d7e06bb Consolidate session events: remove session_before_new/session_new, add reason field to switch events
- Remove session_before_new and session_new hook events
- Add reason: 'new' | 'resume' to session_before_switch and session_switch events
- Remove 'new' reason from custom tool onSession (use 'switch' for both /new and /resume)
- Rename reset() to newSession(options?) in AgentSession
- Add NewSessionOptions with optional parentSession for lineage tracking
- Rename branchedFrom to parentSession in SessionHeader
- Rename RPC reset command to new_session with optional parentSession
- Update example hooks to use new event structure
- Update documentation and changelog

Based on discussion in #293
2026-01-01 23:31:26 +01:00
Mario Zechner
ee64d29487 Fix sdk.md and rpc.md to match actual API
- Remove incorrect prompt(AppMessage) overload
- Change AppMessage to AgentMessage
- Change null to undefined for optional returns
- sendHookMessage returns Promise<void>
- Update rpc.md for entryId change
2025-12-31 13:50:01 +01:00
Mario Zechner
8fb936853b Add sdk.md intro, update CHANGELOG for branch() change 2025-12-31 13:48:22 +01:00
Mario Zechner
8e1e99ca05 Change branch() to use entryId instead of entryIndex
- AgentSession.branch(entryId: string) now takes entry ID
- SessionBeforeBranchEvent.entryId replaces entryIndex
- getUserMessagesForBranching() returns entryId
- Update RPC types and client
- Update UserMessageSelectorComponent
- Update hook examples and tests
- Update docs (hooks.md, sdk.md)
2025-12-31 13:47:34 +01:00
Mario Zechner
d36e0ea2ab Update SDK and RPC docs, remove outdated files
- Remove hooks-v2.md, session-tree.md, UNRELEASED_OLD.md
- sdk.md: Update hook API (sendMessage, appendEntry, registerCommand, etc.)
- sdk.md: Update SessionManager with tree API
- sdk.md: Update AgentSession interface
- rpc.md: Fix attachments -> images in prompt command
2025-12-31 00:46:52 +01:00
Mario Zechner
911963e777 feat(coding-agent): Add --session-dir flag for custom session directory
- Add --session-dir CLI flag to specify custom session directory
- SessionManager API: second param of create(), continueRecent(), list(), open()
  changed from agentDir to sessionDir (direct directory, no cwd encoding)
- When omitted, uses default (~/.pi/agent/sessions/<encoded-cwd>/)
- --session now derives sessionDir from file's parent if --session-dir not provided
- list() validates session header before processing files
- Closes #313

Co-authored-by: scutifer <scutifer@users.noreply.github.com>
2025-12-25 20:27:41 +01:00
Mario Zechner
54018b6cc0 Refactor OAuth/API key handling: AuthStorage and ModelRegistry
- Add AuthStorage class for credential storage (auth.json)
- Add ModelRegistry class for model management with API key resolution
- Add discoverAuthStorage() and discoverModels() discovery functions
- Add migration from legacy oauth.json and settings.json apiKeys to auth.json
- Remove configureOAuthStorage, defaultGetApiKey, findModel, discoverAvailableModels
- Remove apiKeys from Settings type and SettingsManager methods
- Rename getOAuthPath to getAuthPath
- Update SDK, examples, docs, tests, and mom package

Fixes #296
2025-12-25 03:48:36 +01:00
Mario Zechner
bb1da1ec51 Add API keys in settings.json, fixes #295 2025-12-24 02:11:17 +01:00
Mario Zechner
face745f3d Fix SDK tools to respect cwd option
Core tools now properly use the cwd passed to createAgentSession().
Added tool factory functions for SDK users who specify custom cwd with explicit tools.

Fixes #279
2025-12-22 16:17:55 +01:00
Mario Zechner
f835f031eb SDK docs: add links to specific examples in each section 2025-12-22 12:44:41 +01:00
Mario Zechner
5d290f048e Fix SDK docs: AgentSession interface, findModel usage, settings example 2025-12-22 12:32:25 +01:00
Mario Zechner
1e6a23ab3d Update SDK docs for SettingsManager changes 2025-12-22 12:24:58 +01:00
Mario Zechner
05e1f31feb Add SDK documentation
- docs/sdk.md: comprehensive SDK reference
  - Core concepts (createAgentSession, AgentSession, Agent, events)
  - All options with examples
  - Discovery functions
  - Complete example

- README.md: add SDK section with brief overview and links
2025-12-22 03:20:09 +01:00