feat: prepare Zhinian desktop client for pilot release
This commit is contained in:
12
packages/kernel-adapter-openclaw/package.json
Normal file
12
packages/kernel-adapter-openclaw/package.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"name": "@yinian/kernel-adapter-openclaw",
|
||||
"version": "0.1.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
"dependencies": {
|
||||
"@yinian/kernel-core": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
||||
81
packages/kernel-adapter-openclaw/src/index.ts
Normal file
81
packages/kernel-adapter-openclaw/src/index.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import type {
|
||||
Adapter,
|
||||
AdapterFactory,
|
||||
Conversation,
|
||||
ConversationId,
|
||||
ConversationPort,
|
||||
ConversationStreamEvent,
|
||||
CreateConversationInput,
|
||||
Message,
|
||||
SendMessageInput,
|
||||
} from '@yinian/kernel-core';
|
||||
|
||||
export interface OpenClawAdapterConfig {
|
||||
wsUrl: string;
|
||||
token: string;
|
||||
reconnect?: {
|
||||
maxAttempts: number;
|
||||
backoffMs: number;
|
||||
};
|
||||
}
|
||||
|
||||
class NotImplementedConversationPort implements ConversationPort {
|
||||
async list(): Promise<Conversation[]> {
|
||||
return [];
|
||||
}
|
||||
|
||||
async get(_id: ConversationId): Promise<Conversation> {
|
||||
throw new Error('OpenClaw conversation.get adapter is not implemented yet.');
|
||||
}
|
||||
|
||||
async create(_input: CreateConversationInput): Promise<Conversation> {
|
||||
throw new Error('OpenClaw conversation.create adapter is not implemented yet.');
|
||||
}
|
||||
|
||||
async delete(_id: ConversationId): Promise<void> {
|
||||
throw new Error('OpenClaw conversation.delete adapter is not implemented yet.');
|
||||
}
|
||||
|
||||
async *send(_input: SendMessageInput): AsyncIterable<ConversationStreamEvent> {
|
||||
yield {
|
||||
type: 'error',
|
||||
error: {
|
||||
code: 'kernel_unavailable',
|
||||
message: 'OpenClaw conversation.send adapter is not implemented yet.',
|
||||
retryable: false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
async abort(_conversationId: ConversationId): Promise<void> {
|
||||
throw new Error('OpenClaw conversation.abort adapter is not implemented yet.');
|
||||
}
|
||||
|
||||
async history(_conversationId: ConversationId): Promise<Message[]> {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
export const createOpenClawAdapter: AdapterFactory<OpenClawAdapterConfig> = (config): Adapter => {
|
||||
const conversation = new NotImplementedConversationPort();
|
||||
|
||||
return {
|
||||
info: { name: 'openclaw', kernelVersion: 'unknown' },
|
||||
async connect() {
|
||||
if (!config.wsUrl || !config.token) {
|
||||
throw new Error('OpenClaw adapter requires wsUrl and token.');
|
||||
}
|
||||
},
|
||||
async disconnect() {
|
||||
// No persistent socket yet. The real implementation lands with the Gateway contract.
|
||||
},
|
||||
async health() {
|
||||
return {
|
||||
ready: false,
|
||||
details: { wsUrl: config.wsUrl, reason: 'adapter_stub' },
|
||||
};
|
||||
},
|
||||
conversation,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user