feat(sdk): export all types and values needed by external adapter plugins
Add missing exports: PlanEntry, DisplayVerbosity, Attachment, OpenACPCore, Session, SessionManager, CommandRegistry, IRenderer, MessagingAdapterConfig, RenderedMessage, ToolCallMeta, ToolUpdateMeta, ViewerLinks, InstallProgress, log, createChildLogger, PRODUCT_GUIDE, DoctorEngine, DoctorReport, PendingFix. Add new SDK sub-path exports: - @openacp/plugin-sdk/config (DoctorEngine, config registry utils) - @openacp/plugin-sdk/formatting (STATUS_ICONS, KIND_ICONS, format utils) - @openacp/plugin-sdk/testing (runAdapterConformanceTests) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f9d156f683
commit
ba6dced3ca
@ -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()
|
||||
})
|
||||
})
|
||||
}
|
||||
@ -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";
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user