Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions packages/familiar-chat/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@endo/familiar-chat",
"version": "1.0.0",
"type": "module",
"main": "./src/index.js",
"exports": {
".": "./src/index.js"
},
"scripts": {
"build": "yarn build",
"test": "yarn test",
"lint": "yarn lint"
},
"dependencies": {
"@endo/far": "^1.1.4",
"@endo/nat": "^1.1.4",
"@endo/marshal": "^1.1.4",
"@endo/pass-style": "^1.1.4",
"@endo/patterns": "^1.1.4"
},
"devDependencies": {
"@endo/init": "^1.1.4",
"ava": "^6.1.3"
},
"ava": {
"files": [
"test/**/*.test.js"
]
}
}
35 changes: 35 additions & 0 deletions packages/familiar-chat/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { makeCapability } from '@endo/captp/init.js';
import { makePromiseKit } from '@endo/promise-kit';

/**
* Create a chat caplet with the given persona and configuration.
*
* @param {object} persona - The chat persona configuration
* @param {object} config - Additional chat configuration options
* @returns {object} The chat caplet
*/
export const makeChatCaplet = (persona, config = {}) => {
const { name = 'chat', description = 'A chat interface' } = persona;

const chatKit = makePromiseKit();
const [chatP, chatR] = chatKit;

const chatCaplet = makeCapability(
'chat',
{
name,
description,
async chat(message) {
// Basic echo implementation - to be enhanced with actual chat logic
const response = `Echo: ${message}`;
chatR.resolve(response);
return chatP;
},
},
{}
);

return chatCaplet;
};

export default makeChatCaplet;