796 Commits

Author SHA1 Message Date
0xmrpeter
90120c58fb fix: address code review findings — security, scope enforcement, auth flow
Critical fixes:
- C1: Use timingSafeEqual for JWT signature verification (prevent timing attacks)
- C2: Add requireScopes/requireRole preHandler to ALL routes per spec
- C3: Register auth routes with auth=false so refresh endpoint can accept expired JWTs

Important fixes:
- I1: Add pluginDependencies to SSE adapter for proper boot order
- I3: Log warnings on TokenStore save failures instead of swallowing
- I6: Remove duplicate system routes from server.ts (use v1-system.ts only)
- S6: Add event IDs to SSE connected event for reconnect support

Tests added:
- 14 auth integration tests covering middleware, JWT flow, refresh with expired
  tokens, revocation, scope overrides, token generation, /me endpoint

Entire-Checkpoint: 378950358515
2026-03-31 01:55:43 +07:00
0xmrpeter
2274166c73 feat(connectivity): add openacp remote command, instance discovery, QR codes
- Add instance-discovery utility to find running instances from registry
- Add openacp remote CLI command with token generation + link output
- Support 3 link formats: localhost, tunnel, custom scheme (openacp://)
- ASCII QR code in terminal via qrcode-terminal
- Flags: --role, --expire, --scopes, --name, --no-tunnel, --no-qr
- Auto-generated token names: remote-HHhMM-DD-MM-YYYY
- Auto-detect tunnel URL from health endpoint
2026-03-31 01:44:51 +07:00
0xmrpeter
da35c608cf feat(sse): add SSE adapter plugin for app client messaging
- Create @openacp/sse-adapter plugin implementing IChannelAdapter
- Add event serializer for OutgoingMessage → SSE format
- Add circular EventBuffer for reconnect support (Last-Event-ID)
- Add ConnectionManager for per-session SSE connection lifecycle
- Add Fastify routes: SSE stream, prompt, permission, cancel, command
- Register as core adapter + routes via ApiServerService
- Full middleware chain integration (same as Telegram adapter)
2026-03-31 01:42:33 +07:00
0xmrpeter
0a8ca373ed feat(auth): add JWT auth system with roles, scopes, token management
- Add auth types, role definitions (admin/operator/viewer), scope mappings
- Implement TokenStore (in-memory + JSON persist) with create/revoke/refresh/cleanup
- Implement JWT sign/verify/refresh using Node.js crypto (HMAC-SHA256)
- Extend auth middleware to support both secret token and JWT
- Add auth routes: generate token, list, revoke, refresh, /me
- Wire JWT secret and TokenStore into plugin lifecycle
- Separate jwt-secret file from api-secret for independent rotation
2026-03-31 01:40:07 +07:00
0xmrpeter
a64c0c3bb5 feat(api): complete Fastify migration - server factory, routes, service, auth stub, error handling
- Replace Node.js http with Fastify + @fastify/cors, swagger, rate-limit
- Migrate all routes to Fastify plugins under /api/v1/ prefix
- Add global error handler with consistent ApiError format
- Add auth middleware stub (secret token only, JWT in Plan 2)
- Add ApiServerService for plugin route registration
- Add backward-compat redirects from /api/ to /api/v1/
- Add new /api/v1/commands routes for command execution via API
- Preserve SSE manager, static server, all existing functionality
2026-03-31 01:35:38 +07:00
0xmrpeter
a1af91aad6 chore: add Fastify dependencies for API server refactor 2026-03-31 01:28:04 +07:00
0xmrpeter
ca21d6a98b chore: bump version to 2026.330.2 v2026.330.2 2026-03-30 15:09:11 +07:00
0xmrpeter
b86bb2b32c fix(sdk): remove duplicate type exports and add missing storeOutput/outputUrl to mock tunnel service 2026-03-30 15:08:31 +07:00
0xmrpeter
4c16731851 chore: bump version to 2026.330.1 v2026.330.1 2026-03-30 15:02:53 +07:00
0xmrpeter
7ee72b43c1 Merge branch 'feat/conversation-history' into develop 2026-03-30 15:02:40 +07:00
0xmrpeter
11532fc14e fix(debug-tracer): remove DEBUG_ENABLED guard from log() to ensure testability 2026-03-30 15:02:24 +07:00
0xmrpeter
87ea667b33 feat(tunnel): enhance tunnel service error handling and viewer link generation
- Improved error handling in TunnelService to capture and log start errors when the tunnel fails to initialize.
- Updated startServer function to provide user feedback on tunnel status, including error messages for unavailable viewer links.
- Enhanced MessageTransformer to skip viewer link generation when only localhost URLs are available, preventing unclickable links in Telegram.
- Refined DisplaySpecBuilder to conditionally display content based on the availability of a public tunnel URL.
- Added tests to ensure correct behavior when handling localhost URLs in viewer link generation.
2026-03-30 14:58:00 +07:00
Mr.Peter
8299199dbc
Merge pull request #133 from Open-ACP/feat/conversation-history
feat: output mode, debug tracing & conversation history
2026-03-30 12:27:50 +07:00
0xmrpeter
e55307fa11 feat(diff): enhance line diff computation and update display specifications
- Introduced a new function `computeLineDiff` to accurately calculate line-level diffs by stripping common prefixes and suffixes, improving diff accuracy.
- Updated `MessageTransformer` to utilize the new diff computation for better metadata extraction.
- Enhanced `DisplaySpecBuilder` to include `inputContent` in the display specifications, allowing for inline display of raw input in high verbosity mode.
- Refined title generation logic to improve clarity and consistency in displayed titles across different contexts.
- Adjusted formatting functions to ensure proper display of input content and viewer links in tool cards.
2026-03-30 12:27:30 +07:00
0xmrpeter
09b98abdfa Merge branch 'feat/conversation-history' of github.com:Open-ACP/OpenACP into feat/conversation-history 2026-03-30 09:56:16 +07:00
0xmrpeter
81f9587a8c refactor(logging): streamline logging in agent-instance and activity tracker
- Refined logging in agent-instance to reduce verbosity by removing debug logs for raw input/output.
- Enhanced activity tracker logging to include viewer links for improved traceability.
- Updated .gitignore to exclude .log files from version control.
2026-03-30 09:56:04 +07:00
0xmrpeter
4114359f02 chore: update .gitignore and refine logging in agent-instance and activity tracker
- Added .log to .gitignore to exclude log files from version control.
- Removed debug logging for raw input/output in agent-instance to reduce verbosity.
- Enhanced logging in activity tracker to include viewer links for better traceability.
2026-03-30 09:52:42 +07:00
0xmrpeter
a707bf15e9 fix(trace): log full event/message objects for verbose debug tracing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-30 09:36:48 +07:00
0xmrpeter
196657d3b1 feat(history): add history store, provider, context builder and improve tool display
- Add HistoryStore, HistoryProvider, HistoryContextBuilder with tests
- Wire history provider into context plugin
- Enhance DisplaySpecBuilder with diff stats and output viewer links
- Improve message-transformer with richer tool metadata extraction
- Update extract-file-info to handle more ACP content patterns
- Refine Telegram formatting: inline viewer links, cleaner tool cards
- Fix viewer-store cleanup and core event wiring
2026-03-30 09:01:40 +07:00
0xmrpeter
ce51688c4f feat(history): add HistoryRecorder for event accumulation and turn writing
Implements the write-side component that captures agent events from
middleware hooks, accumulates them into structured turns (text/thinking
chunk merging, tool call tracking, diff extraction, permission capture),
and writes completed turns to disk via HistoryStore.

Includes 32 tests covering all event types, accumulation rules, edge
cases, multi-turn sequences, and session cleanup.
2026-03-30 02:19:18 +07:00
0xmrpeter
16e0884354 fix(output-mode): wire outputViewerLink, fix verbosity callback key, update docs
- DisplaySpecBuilder: add TunnelServiceInterface constructor injection, implement
  outputViewerLink/outputFallbackContent for long output (>15 lines or >800 chars)
- DisplaySpecBuilder: fix buildThoughtSpec indicator to "Thinking..."
- ActivityTracker: store and pass tunnelService to DisplaySpecBuilder, pass sessionContext
  to all buildToolSpec calls
- setupVerbosityCallbacks: write outputMode instead of deprecated displayVerbosity key
- /verbosity static command description updated to note deprecation
- Docs: update displayVerbosity → outputMode across configuration, chat-commands,
  troubleshooting, and architecture docs; add /outputmode command reference
2026-03-30 01:52:51 +07:00
0xmrpeter
646c2d8812 fix(output-mode): fix verbosity callback toast text to say output mode 2026-03-30 01:38:22 +07:00
0xmrpeter
617b94b865 feat(output-mode): add /outputmode command with session-level override
Adds /outputmode [low|medium|high] for adapter-level config and /outputmode session [low|medium|high|reset] for per-session override. Deprecates /verbosity as an alias that forwards to /outputmode. Prefixes unused verbosity params in adapter.ts with underscore to suppress TS warnings.
2026-03-30 01:35:10 +07:00
0xmrpeter
72b675d85f feat(output-mode): filter before serial queue, OutputModeResolver cascade, pass content through tool updates
- Add OutputModeResolver field to TelegramAdapter; resolve mode per-call in handleToolCall, handleToolUpdate, handleThought, handleText, handlePlan instead of forwarding raw DisplayVerbosity
- Update getOrCreateTracker signature from verbosity: DisplayVerbosity to outputMode: OutputMode; pass tunnelService and sessionContext to ActivityTracker constructor
- Pass content, rawInput, and diffStats through onToolUpdate calls so ActivityTracker receives full update payload
2026-03-30 01:30:44 +07:00
0xmrpeter
7bc6215825 fix(tests): update old tool-card-state tests to use new updateFromSpec API
Replace addTool/updateTool/verbosity calls with updateFromSpec(ToolDisplaySpec),
update snapshot field references (entries→specs, hidden→isHidden, visibleCount→totalVisible),
and remove the verbosity config param that was removed from ToolCardStateConfig.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 01:27:18 +07:00
0xmrpeter
210c4927ed fix(output-mode): add sessionContext param to ActivityTracker constructor
Adds sessionContext field and constructor parameter to ActivityTracker,
renames _tunnelService to tunnelService for clarity.
2026-03-30 01:24:33 +07:00
0xmrpeter
515f68791e feat(output-mode): integrate ToolStateMap + DisplaySpecBuilder into ActivityTracker
Rewrites activity.ts to use ToolStateMap for tool state tracking and
DisplaySpecBuilder for spec-driven rendering, removing all @ts-ignore
suppressions and as-any casts added in Task 7. Updates activity.test.ts
to match the new API (updateFromSpec instead of addTool/updateTool,
onThought takes a text param, ToolCard constructor drops verbosity arg).
Also fixes adapter.ts to pass thought text to onThought().
2026-03-30 01:21:27 +07:00
0xmrpeter
69797b1b05 feat(output-mode): update renderToolCard for ToolDisplaySpec[], fix splitToolCardText overflow bug
Replaces the old entries-based renderToolCard implementation with one that
reads from snap.specs (ToolDisplaySpec[]), rendering icon, title, description,
command, outputSummary, outputContent, diffStats, and viewer links per spec.
Fixes splitToolCardText to truncate single sections larger than 4096 chars
instead of passing them through untruncated. Updates formatting-extended tests
to use the new ToolDisplaySpec/specs API.
2026-03-30 01:14:26 +07:00
0xmrpeter
f302d3ee7c feat(output-mode): refactor ToolCardState to store ToolDisplaySpec[] via updateFromSpec()
Replaces ToolCardEntry[]/addTool/updateTool with ToolDisplaySpec[]/updateFromSpec.
Updates primitives/index.ts to export ToolDisplaySpec instead of removed ToolCardEntry.
Adds @ts-ignore suppressions in activity.ts and formatting.ts as temporary bridge until Tasks 8/9.
2026-03-30 01:06:23 +07:00
0xmrpeter
28c1745cae feat(output-mode): add ViewerStore output type, /output/:id route, tunnel outputUrl
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 01:01:00 +07:00
0xmrpeter
7b44367570 feat(output-mode): compute diffStats in enrichWithViewerLinks
Adds net line count change (added/removed) to metadata.diffStats when
a diff is stored, so consumers can display file change statistics.
2026-03-30 00:57:35 +07:00
0xmrpeter
b228b81ab7 fix(output-mode): validate OutputMode values, add missing sessionManager test 2026-03-30 00:56:25 +07:00
0xmrpeter
7bad063f25 feat(output-mode): add OutputModeResolver (cascade global → adapter → session) 2026-03-30 00:54:50 +07:00
0xmrpeter
2386dbeaad fix(output-mode): add TODO for deferred viewer links, add boundary tests 2026-03-30 00:53:19 +07:00
0xmrpeter
3e4033727a feat(output-mode): add DisplaySpecBuilder with ToolDisplaySpec computation
Implements DisplaySpecBuilder that derives ToolDisplaySpec and ThoughtDisplaySpec
from a ToolEntry + OutputMode. Controls title logic per kind, output inlining
threshold (≤15 lines AND ≤800 chars for high mode only), noise hiding, and
diffStats pass-through. 14 tests, all green.
2026-03-30 00:51:05 +07:00
0xmrpeter
99ca58ae6b fix(output-mode): merge returns undefined for out-of-order, fix test helper 2026-03-30 00:48:53 +07:00
0xmrpeter
0f199c9948 feat(output-mode): add StreamAccumulator (ToolStateMap + ThoughtBuffer)
Implements ToolStateMap for accumulating ACP tool_call/tool_call_update
events with out-of-order delivery support, and ThoughtBuffer for
streaming thought chunk accumulation across turns.
2026-03-30 00:46:04 +07:00
0xmrpeter
f5b52d6166 fix: use top-level import type for OutputMode in types.ts 2026-03-30 00:43:58 +07:00
0xmrpeter
a354b15bf8 feat(output-mode): add OutputMode type, SessionRecord field, config schema + migration
Add OutputMode type as the new standard output mode type (replacing DisplayVerbosity
usage pattern). Maintain DisplayVerbosity as deprecated alias for backward compatibility.
Add outputMode to SessionRecord, channel config schema, and global config schema.
Add migration to auto-migrate displayVerbosity to outputMode in channel configs.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-30 00:39:10 +07:00
0xmrpeter
5394aeca77 chore: ignore .worktrees/ directory 2026-03-30 00:37:13 +07:00
0xmrpeter
7c8c10f51b feat: add OPENACP_DEBUG trace logging (3 JSONL files per session)
When OPENACP_DEBUG=true, writes per-session trace files to <workingDir>/.log/:
- <sessionId>_acp.jsonl — raw ACP JSON-RPC protocol (stdin/stdout)
- <sessionId>_core.jsonl — core event pipeline (agent_event → middleware → transform → dispatch)
- <sessionId>_telegram.jsonl — all Telegram UI actions (handlers, tracker, tool card, draft, API calls)

DebugTracer utility with lazy dir creation, appendFileSync writes, zero overhead when disabled.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 21:29:09 +07:00
0xmrpeter
e318bcba46 fix: tool card display issues — serial dispatch, overflow editing, thinking cleanup
- Serialize per-session message dispatch to prevent out-of-order event processing
  (tool_update arriving before tool_call due to concurrent fire-and-forget dispatch)
- Buffer tool updates that arrive before their tool_call and apply on addTool
- Allow post-finalize tool updates to flush immediately (late completion after seal)
- Track overflow message IDs and edit them instead of only sending once
- Forward tool updates to previous sealed card for late completions
- Count failed/error tools as done in header (Tools N/N ✅)
- Stop deleting thinking indicator messages to reduce Telegram API calls

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 19:50:15 +07:00
0xmrpeter
c7913ff67b fix: remove phantom @openacp/usage registration and guard readdirSync
- Remove @openacp/usage from builtin plugin lists (plugin was extracted
  but registration entries remained, causing silent failures on first boot)
- Guard fs.readdirSync(nodeModulesDir) with existsSync check to prevent
  crash when community plugins are registered but node_modules/ missing
- Clean up onboard.ts: remove redundant duplicate imports and local constants

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 17:47:14 +07:00
0xmrpeter
10a7bd8c73 merge: integrate fix/setup-wizard-plugin-init into develop
Combines setup wizard fixes (settingsManager/pluginRegistry passing,
ESM plugin resolution, path centralization) with develop's shell
injection validation and community adapter flow. Adds error handling
and tests for importFromDir.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 17:42:42 +07:00
0xmrpeter
e190ff64a2 fix: add error handling and tests for importFromDir
Wrap package.json parsing with descriptive error messages and validate
entry point exists before importing. Add 7 unit tests covering all
resolution paths and error cases.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-28 17:40:09 +07:00
0xmrpeter
a56120d114 chore: bump version to 2026.328.2 v2026.328.2 2026-03-28 07:48:55 +07:00
0xmrpeter
428e343ea8 Merge branch 'develop' 2026-03-28 07:44:40 +07:00
0xmrpeter
cafd8947f4 chore: bump version to 2026.328.1 v2026.328.1 2026-03-28 07:44:10 +07:00
0xmrpeter
ca20290c63 Merge branch 'fix/codebase-logic-review' into develop 2026-03-28 07:43:59 +07:00
0xmrpeter
08bbc6b134 revert: remove usage plugin (extracted to external package) 2026-03-28 01:39:24 +07:00