Compare commits
5 Commits
main
...
fix/api-ch
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba6dced3ca | ||
|
|
f9d156f683 | ||
|
|
a68f8a6b29 | ||
|
|
2b3247b4ac | ||
|
|
e229c8e447 |
@ -12,7 +12,7 @@ Send a message. The agent writes code. You see everything — in real time.
|
||||
[](https://www.npmjs.com/package/@openacp/cli)
|
||||
[](https://x.com/openacp_ai)
|
||||
|
||||
[Documentation](docs/gitbook/) · [Quick Start](#quick-start) · [Features](#features) · [Agents](#supported-agents) · [Contributing](docs/gitbook/extending/contributing.md)
|
||||
[Documentation](https://docs.openacp.ai) · [Quick Start](#quick-start) · [Features](#features) · [Agents](#supported-agents) · [Contributing](docs/gitbook/extending/contributing.md)
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@ -11,6 +11,14 @@
|
||||
"./testing": {
|
||||
"types": "./dist/testing.d.ts",
|
||||
"import": "./dist/testing.js"
|
||||
},
|
||||
"./config": {
|
||||
"types": "./dist/config.d.ts",
|
||||
"import": "./dist/config.js"
|
||||
},
|
||||
"./formatting": {
|
||||
"types": "./dist/formatting.d.ts",
|
||||
"import": "./dist/formatting.js"
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
|
||||
2
packages/plugin-sdk/src/config.ts
Normal file
2
packages/plugin-sdk/src/config.ts
Normal file
@ -0,0 +1,2 @@
|
||||
export type { ConfigFieldDef, DoctorReport, PendingFix } from '@openacp/cli'
|
||||
export { DoctorEngine, getSafeFields, resolveOptions, getConfigValue, isHotReloadable } from '@openacp/cli'
|
||||
5
packages/plugin-sdk/src/formatting.ts
Normal file
5
packages/plugin-sdk/src/formatting.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export {
|
||||
STATUS_ICONS, KIND_ICONS,
|
||||
progressBar, formatTokens, truncateContent, stripCodeFences, splitMessage,
|
||||
extractContentText, formatToolSummary, formatToolTitle, resolveToolIcon,
|
||||
} from '@openacp/cli'
|
||||
@ -21,6 +21,21 @@ export type {
|
||||
PermissionOption, NotificationMessage, AgentCommand,
|
||||
} from '@openacp/cli'
|
||||
|
||||
// Core types
|
||||
export type {
|
||||
Attachment, PlanEntry, InstallProgress,
|
||||
DisplayVerbosity, ToolCallMeta, ToolUpdateMeta, ViewerLinks,
|
||||
AdapterCapabilities, IRenderer, MessagingAdapterConfig, RenderedMessage,
|
||||
} from '@openacp/cli'
|
||||
|
||||
// Core classes & values
|
||||
export { OpenACPCore } from '@openacp/cli'
|
||||
export { Session } from '@openacp/cli'
|
||||
export { SessionManager } from '@openacp/cli'
|
||||
export { CommandRegistry } from '@openacp/cli'
|
||||
export { log, createChildLogger } from '@openacp/cli'
|
||||
export { PRODUCT_GUIDE } from '@openacp/cli'
|
||||
|
||||
// Adapter base classes
|
||||
export { MessagingAdapter, StreamAdapter, BaseRenderer } from '@openacp/cli'
|
||||
|
||||
|
||||
@ -3,3 +3,4 @@ export type { TestPluginContext, TestContextOpts } from './testing/test-context.
|
||||
export { createTestInstallContext } from './testing/test-install-context.js'
|
||||
export type { TestInstallContextOpts } from './testing/test-install-context.js'
|
||||
export { mockServices } from './testing/mock-services.js'
|
||||
export { runAdapterConformanceTests } from './testing/adapter-conformance.js'
|
||||
|
||||
93
packages/plugin-sdk/src/testing/adapter-conformance.ts
Normal file
93
packages/plugin-sdk/src/testing/adapter-conformance.ts
Normal file
@ -0,0 +1,93 @@
|
||||
import { describe, it, expect, afterEach } from 'vitest'
|
||||
import type { IChannelAdapter } from '@openacp/cli'
|
||||
|
||||
export function runAdapterConformanceTests(
|
||||
createAdapter: () => IChannelAdapter | Promise<IChannelAdapter>,
|
||||
cleanup?: () => Promise<void>,
|
||||
) {
|
||||
let adapter: IChannelAdapter
|
||||
|
||||
afterEach(async () => {
|
||||
await cleanup?.()
|
||||
})
|
||||
|
||||
describe('IChannelAdapter conformance', () => {
|
||||
it('has a name', async () => {
|
||||
adapter = await createAdapter()
|
||||
expect(typeof adapter.name).toBe('string')
|
||||
expect(adapter.name.length).toBeGreaterThan(0)
|
||||
})
|
||||
|
||||
it('declares capabilities correctly', async () => {
|
||||
adapter = await createAdapter()
|
||||
const caps = adapter.capabilities
|
||||
expect(typeof caps.streaming).toBe('boolean')
|
||||
expect(typeof caps.richFormatting).toBe('boolean')
|
||||
expect(typeof caps.threads).toBe('boolean')
|
||||
expect(typeof caps.reactions).toBe('boolean')
|
||||
expect(typeof caps.fileUpload).toBe('boolean')
|
||||
expect(typeof caps.voice).toBe('boolean')
|
||||
})
|
||||
|
||||
it('sends text messages without error', async () => {
|
||||
adapter = await createAdapter()
|
||||
await expect(
|
||||
adapter.sendMessage('test-session', { type: 'text', text: 'hello' }),
|
||||
).resolves.not.toThrow()
|
||||
})
|
||||
|
||||
it('sends tool_call messages without error', async () => {
|
||||
adapter = await createAdapter()
|
||||
await expect(
|
||||
adapter.sendMessage('test-session', {
|
||||
type: 'tool_call',
|
||||
text: 'Read',
|
||||
metadata: { id: 't1', name: 'Read', kind: 'read' },
|
||||
}),
|
||||
).resolves.not.toThrow()
|
||||
})
|
||||
|
||||
it('sends usage messages without error', async () => {
|
||||
adapter = await createAdapter()
|
||||
await expect(
|
||||
adapter.sendMessage('test-session', {
|
||||
type: 'usage',
|
||||
text: '',
|
||||
metadata: { tokensUsed: 1000, contextSize: 200000 },
|
||||
}),
|
||||
).resolves.not.toThrow()
|
||||
})
|
||||
|
||||
it('sends error messages without error', async () => {
|
||||
adapter = await createAdapter()
|
||||
await expect(
|
||||
adapter.sendMessage('test-session', { type: 'error', text: 'something failed' }),
|
||||
).resolves.not.toThrow()
|
||||
})
|
||||
|
||||
it('handles session_end without error', async () => {
|
||||
adapter = await createAdapter()
|
||||
await expect(
|
||||
adapter.sendMessage('test-session', { type: 'session_end', text: 'finished' }),
|
||||
).resolves.not.toThrow()
|
||||
})
|
||||
|
||||
it('handles unknown message types gracefully', async () => {
|
||||
adapter = await createAdapter()
|
||||
await expect(
|
||||
adapter.sendMessage('test-session', { type: 'unknown_type' as never, text: '' }),
|
||||
).resolves.not.toThrow()
|
||||
})
|
||||
|
||||
it('sendNotification does not throw', async () => {
|
||||
adapter = await createAdapter()
|
||||
await expect(
|
||||
adapter.sendNotification({
|
||||
sessionId: 'test',
|
||||
type: 'completed',
|
||||
summary: 'done',
|
||||
}),
|
||||
).resolves.not.toThrow()
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -14,6 +14,7 @@ function printApiHelp(): void {
|
||||
openacp api status Show active sessions
|
||||
openacp api session <id> Show session details
|
||||
openacp api new [agent] [workspace] Create a new session
|
||||
[--channel <id>]
|
||||
openacp api send <id> <prompt> Send prompt to session
|
||||
openacp api cancel <id> Cancel a session
|
||||
openacp api dangerous <id> on|off Toggle dangerous mode
|
||||
@ -75,16 +76,19 @@ dangerous mode, queue depth, and channel/thread IDs.
|
||||
|
||||
\x1b[1mUsage:\x1b[0m
|
||||
openacp api new [agent] [workspace]
|
||||
openacp api new [agent] --workspace <path>
|
||||
openacp api new [agent] --workspace <path> [--channel <id>]
|
||||
|
||||
\x1b[1mArguments:\x1b[0m
|
||||
[agent] Agent name (uses default if omitted)
|
||||
[workspace] Working directory for the session
|
||||
|
||||
\x1b[1mOptions:\x1b[0m
|
||||
--channel <id> Target adapter (e.g. telegram, discord). Defaults to first registered adapter.
|
||||
|
||||
\x1b[1mExamples:\x1b[0m
|
||||
openacp api new
|
||||
openacp api new claude /path/to/project
|
||||
openacp api new gemini --workspace /path/to/project
|
||||
openacp api new claude /path/to/project --channel discord
|
||||
`,
|
||||
'send': `
|
||||
\x1b[1mopenacp api send\x1b[0m — Send prompt to a session
|
||||
@ -253,9 +257,16 @@ Shows the version of the currently running daemon process.
|
||||
const agent = args[2]
|
||||
const workspaceIdx = args.indexOf('--workspace')
|
||||
const workspace = workspaceIdx !== -1 ? args[workspaceIdx + 1] : args[3]
|
||||
const channelIdx = args.indexOf('--channel')
|
||||
if (channelIdx !== -1 && !args[channelIdx + 1]) {
|
||||
console.error('Error: --channel requires a value (e.g. telegram, discord)')
|
||||
process.exit(1)
|
||||
}
|
||||
const channel = channelIdx !== -1 ? args[channelIdx + 1] : undefined
|
||||
const body: Record<string, string> = {}
|
||||
if (agent) body.agent = agent
|
||||
if (workspace) body.workspace = workspace
|
||||
if (channel) body.channel = channel
|
||||
|
||||
const res = await apiCall(port, '/api/sessions', {
|
||||
method: 'POST',
|
||||
|
||||
@ -9,18 +9,18 @@ This file provides context for AI coding agents (Claude, Cursor, etc.) working o
|
||||
|
||||
OpenACP is an open-source platform that bridges AI coding agents (Claude Code, Codex, etc.) to messaging platforms (Telegram, Discord, Slack) and custom UIs via the Agent Client Protocol (ACP). It features a microkernel plugin architecture where all features — adapters, services, commands — are plugins.
|
||||
|
||||
- **Website & Docs**: https://openacp.gitbook.io/docs
|
||||
- **Website & Docs**: https://docs.openacp.ai
|
||||
- **GitHub**: https://github.com/Open-ACP/OpenACP
|
||||
- **Plugin Registry**: https://github.com/Open-ACP/plugin-registry
|
||||
|
||||
Key documentation pages:
|
||||
- [Getting Started](https://openacp.gitbook.io/docs/getting-started) — What is OpenACP, quickstart
|
||||
- [Plugin Development](https://openacp.gitbook.io/docs/extending/building-plugins) — How to build plugins
|
||||
- [Architecture](https://openacp.gitbook.io/docs/extending/architecture) — System design, plugin lifecycle
|
||||
- [Dev Mode](https://openacp.gitbook.io/docs/extending/dev-mode) — Hot-reload development workflow
|
||||
- [CLI Commands](https://openacp.gitbook.io/docs/api-reference/cli-commands) — Full CLI reference
|
||||
- [Platform Setup](https://openacp.gitbook.io/docs/platform-setup) — Telegram, Discord, Slack guides
|
||||
- [Configuration](https://openacp.gitbook.io/docs/self-hosting/configuration) — Config and settings reference
|
||||
- [Getting Started](https://docs.openacp.ai/getting-started) — What is OpenACP, quickstart
|
||||
- [Plugin Development](https://docs.openacp.ai/extending/building-plugins) — How to build plugins
|
||||
- [Architecture](https://docs.openacp.ai/extending/architecture) — System design, plugin lifecycle
|
||||
- [Dev Mode](https://docs.openacp.ai/extending/dev-mode) — Hot-reload development workflow
|
||||
- [CLI Commands](https://docs.openacp.ai/api-reference/cli-commands) — Full CLI reference
|
||||
- [Platform Setup](https://docs.openacp.ai/platform-setup) — Telegram, Discord, Slack guides
|
||||
- [Configuration](https://docs.openacp.ai/self-hosting/configuration) — Config and settings reference
|
||||
|
||||
## Project Overview
|
||||
|
||||
|
||||
@ -5,3 +5,6 @@ export { SendQueue, DraftManager, Draft, ToolCallTracker, ActivityTracker } from
|
||||
export type { SendQueueConfig, DraftConfig, TrackedToolCall, ActivityConfig, ActivityCallbacks } from './primitives/index.js'
|
||||
|
||||
export type { DisplayVerbosity, ToolCallMeta, ToolUpdateMeta, FormattedMessage, MessageMetadata, ViewerLinks } from './format-types.js'
|
||||
export { STATUS_ICONS, KIND_ICONS } from './format-types.js'
|
||||
export { progressBar, formatTokens, stripCodeFences, truncateContent, splitMessage } from './format-utils.js'
|
||||
export { extractContentText, formatToolSummary, formatToolTitle, resolveToolIcon } from './message-formatter.js'
|
||||
|
||||
@ -43,6 +43,8 @@ export {
|
||||
} from "./sessions/session-factory.js";
|
||||
export { OpenACPCore } from "./core.js";
|
||||
export { EventBus, type EventBusEvents } from "./event-bus.js";
|
||||
export { CommandRegistry } from "./command-registry.js";
|
||||
export { DoctorEngine, type DoctorReport, type PendingFix } from "./doctor/index.js";
|
||||
export {
|
||||
CONFIG_REGISTRY,
|
||||
getFieldDef,
|
||||
@ -102,6 +104,8 @@ export { EntireProvider } from "../plugins/context/entire/entire-provider.js";
|
||||
export { MessagingAdapter, StreamAdapter } from './adapter-primitives/index.js'
|
||||
export { BaseRenderer } from './adapter-primitives/index.js'
|
||||
export { SendQueue, DraftManager, ToolCallTracker, ActivityTracker } from './adapter-primitives/index.js'
|
||||
export type { MessagingAdapterConfig, IRenderer, RenderedMessage, DisplayVerbosity, ToolCallMeta, ToolUpdateMeta, ViewerLinks } from './adapter-primitives/index.js'
|
||||
export { STATUS_ICONS, KIND_ICONS, progressBar, formatTokens, stripCodeFences, truncateContent, splitMessage, extractContentText, formatToolSummary, formatToolTitle, resolveToolIcon } from './adapter-primitives/index.js'
|
||||
|
||||
// ─── Plugin types (for SDK re-exports) ──────────────────────────────────────
|
||||
export type {
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
export * from './core/index.js'
|
||||
export { PRODUCT_GUIDE } from './data/product-guide.js'
|
||||
export { TelegramAdapter } from './plugins/telegram/adapter.js'
|
||||
export { AgentCatalog } from "./core/agents/agent-catalog.js";
|
||||
export { AgentStore } from "./core/agents/agent-store.js";
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import type { Router } from "../router.js";
|
||||
import type { RouteDeps } from "../api-server.js";
|
||||
import type { IChannelAdapter } from "../../../core/channel.js";
|
||||
import { createChildLogger } from "../../../core/utils/log.js";
|
||||
|
||||
const log = createChildLogger({ module: "api-server" });
|
||||
@ -60,12 +61,14 @@ export function registerSessionRoutes(router: Router, deps: RouteDeps): void {
|
||||
const body = await deps.readBody(req);
|
||||
let agent: string | undefined;
|
||||
let workspace: string | undefined;
|
||||
let channel: string | undefined;
|
||||
|
||||
if (body) {
|
||||
try {
|
||||
const parsed = JSON.parse(body);
|
||||
agent = parsed.agent;
|
||||
workspace = parsed.workspace;
|
||||
channel = parsed.channel;
|
||||
} catch {
|
||||
deps.sendJson(res, 400, { error: "Invalid JSON body" });
|
||||
return;
|
||||
@ -84,11 +87,27 @@ export function registerSessionRoutes(router: Router, deps: RouteDeps): void {
|
||||
return;
|
||||
}
|
||||
|
||||
// Use the first registered adapter (e.g. Telegram) so API sessions appear in the channel
|
||||
const [adapterId, adapter] = deps.core.adapters.entries().next().value ?? [
|
||||
null,
|
||||
null,
|
||||
];
|
||||
// Resolve adapter: use explicit channel if provided, otherwise fall back to first registered adapter
|
||||
let adapterId: string | null = null;
|
||||
let adapter: IChannelAdapter | null = null;
|
||||
|
||||
if (channel) {
|
||||
if (!deps.core.adapters.has(channel)) {
|
||||
const available = Array.from(deps.core.adapters.keys()).join(", ") || "none";
|
||||
deps.sendJson(res, 400, {
|
||||
error: `Adapter '${channel}' is not connected. Available: ${available}`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
adapterId = channel;
|
||||
adapter = deps.core.adapters.get(channel) ?? null;
|
||||
} else {
|
||||
const firstEntry = deps.core.adapters.entries().next().value;
|
||||
if (firstEntry) {
|
||||
[adapterId, adapter] = firstEntry;
|
||||
}
|
||||
}
|
||||
|
||||
const channelId = adapterId ?? "api";
|
||||
|
||||
const resolvedAgent = agent || config.defaultAgent;
|
||||
|
||||
@ -138,7 +138,7 @@ export function buildAssistantSystemPrompt(core: OpenACPCore): string {
|
||||
- The workspace is the project directory where the agent will work (read, write, execute code). It should be a specific project folder like \`~/code/my-project\` or \`${config.workspace.baseDir}/my-app\`.
|
||||
- Ask which agent to use (if multiple are installed). Installed: ${agentNames}
|
||||
- Ask which project directory to use as workspace. Suggest \`${config.workspace.baseDir}\` as the base.
|
||||
- Create via: \`openacp api new <agent> <workspace>\`
|
||||
- Create via: \`openacp api new <agent> <workspace> --channel discord\`
|
||||
|
||||
### Browse & Install Agents
|
||||
- Guide users to \`/agents\` command to see all available agents
|
||||
@ -181,7 +181,7 @@ export function buildAssistantSystemPrompt(core: OpenACPCore): string {
|
||||
# Session management
|
||||
openacp api status # List active sessions
|
||||
openacp api session <id> # Session detail
|
||||
openacp api new <agent> <workspace> # Create new session
|
||||
openacp api new <agent> <workspace> --channel discord # Create new session
|
||||
openacp api send <id> "prompt text" # Send prompt to session
|
||||
openacp api cancel <id> # Cancel session
|
||||
openacp api dangerous <id> on|off # Toggle dangerous mode
|
||||
|
||||
@ -130,7 +130,7 @@ export function buildAssistantSystemPrompt(ctx: AssistantContext): string {
|
||||
- Ask which agent to use (if multiple are installed). Show installed: ${agentNames}
|
||||
- Ask which project directory to use as workspace. Suggest \`${config.workspace.baseDir}\` as the base, but explain the user can provide any path.
|
||||
- Confirm before creating: show agent name + full workspace path.
|
||||
- Create via: \`openacp api new <agent> <workspace>\`
|
||||
- Create via: \`openacp api new <agent> <workspace> --channel telegram\`
|
||||
|
||||
### Browse & Install Agents
|
||||
- Guide users to /agents command to see all available agents (installed + from ACP Registry)
|
||||
@ -192,7 +192,7 @@ export function buildAssistantSystemPrompt(ctx: AssistantContext): string {
|
||||
# Session management
|
||||
openacp api status # List active sessions
|
||||
openacp api session <id> # Session detail
|
||||
openacp api new <agent> <workspace> # Create new session
|
||||
openacp api new <agent> <workspace> --channel telegram # Create new session
|
||||
openacp api send <id> "prompt text" # Send prompt to session
|
||||
openacp api cancel <id> # Cancel session
|
||||
openacp api dangerous <id> on|off # Toggle dangerous mode
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user