@mulmochat-plugin/quiz 0.1.3 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +28 -34
- package/README.md +28 -34
- package/README.npm.md +49 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/plugin.d.ts +12 -0
- package/dist/core/types.d.ts +242 -0
- package/dist/core.cjs +1 -0
- package/dist/core.js +144 -0
- package/dist/index.cjs +1 -3
- package/dist/index.d.ts +12 -8
- package/dist/index.js +7 -312
- package/dist/style.css +1 -0
- package/dist/{previews/QuizPreview.vue.d.ts → vue/Preview.vue.d.ts} +1 -1
- package/dist/{views/QuizView.vue.d.ts → vue/View.vue.d.ts} +1 -1
- package/dist/vue/index.d.ts +22 -0
- package/dist/vue/types.d.ts +32 -0
- package/dist/vue.cjs +3 -0
- package/dist/vue.js +145 -0
- package/package.json +12 -2
- package/dist/common/index.d.ts +0 -7
- package/dist/common/types.d.ts +0 -128
- package/dist/plugin.d.ts +0 -36
- package/dist/quiz.css +0 -1
- package/dist/types.d.ts +0 -5
package/README.ja.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# MulmoChat Plugin Quiz
|
|
2
2
|
|
|
3
|
+
> **📦 テンプレートリポジトリ**
|
|
4
|
+
> これは [MulmoChat](https://github.com/receptron/MulmoChat) プラグインのリファレンス実装です。
|
|
5
|
+
> このリポジトリをテンプレートとして使用し、独自のプラグインを作成できます。
|
|
6
|
+
> 詳細は [TEMPLATE.md](./TEMPLATE.md) を参照してください。
|
|
7
|
+
|
|
3
8
|
MulmoChat用のクイズプラグイン。複数選択式のクイズをユーザーに提示します。
|
|
4
9
|
|
|
5
10
|
## 概要
|
|
@@ -72,16 +77,16 @@ yarn lint
|
|
|
72
77
|
MulmoChatPluginQuiz/
|
|
73
78
|
├── src/
|
|
74
79
|
│ ├── index.ts # エクスポート定義
|
|
75
|
-
│ ├── plugin.ts # クイズ固有のプラグイン実装
|
|
76
|
-
│ ├── types.ts # 共通型の再エクスポート(後方互換)
|
|
77
80
|
│ ├── style.css # Tailwind CSSエントリー
|
|
78
81
|
│ ├── common/ # プラグイン非依存の共通コード
|
|
79
82
|
│ │ ├── index.ts # 共通エクスポート
|
|
80
83
|
│ │ └── types.ts # ToolPlugin, ToolResult など
|
|
81
|
-
│
|
|
82
|
-
│
|
|
83
|
-
│
|
|
84
|
-
│
|
|
84
|
+
│ └── plugin/ # クイズ固有の実装
|
|
85
|
+
│ ├── index.ts # プラグインインスタンスと実行ロジック
|
|
86
|
+
│ ├── types.ts # クイズの型とTOOL_DEFINITION
|
|
87
|
+
│ ├── samples.ts # テスト用サンプルデータ
|
|
88
|
+
│ ├── View.vue # メインビューコンポーネント
|
|
89
|
+
│ └── Preview.vue # サイドバープレビューコンポーネント
|
|
85
90
|
├── demo/ # 汎用プラグインデモ(どのプラグインでも動作)
|
|
86
91
|
│ ├── App.vue # 動的コンポーネント描画
|
|
87
92
|
│ └── main.ts
|
|
@@ -94,43 +99,32 @@ MulmoChatPluginQuiz/
|
|
|
94
99
|
### ディレクトリの役割
|
|
95
100
|
|
|
96
101
|
- **src/common/**: プラグイン非依存の型とユーティリティ。新しいプラグインにコピーするか、このパッケージからインポート。
|
|
97
|
-
- **src/plugin
|
|
98
|
-
- **src/views/**, **src/previews/**: クイズ固有のVueコンポーネント。独自のものを作成。
|
|
102
|
+
- **src/plugin/**: クイズ固有の実装。独自のプラグインロジックに置き換える。
|
|
99
103
|
- **demo/**: 任意のToolPluginで動作する汎用デモ。インポートを変更するだけで使用可能。
|
|
100
104
|
|
|
101
105
|
## 新しいプラグインの作成
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
1. リポジトリをコピー:
|
|
106
|
-
```bash
|
|
107
|
-
cp -r MulmoChatPluginQuiz MulmoChatPluginYourPlugin
|
|
108
|
-
cd MulmoChatPluginYourPlugin
|
|
109
|
-
rm -rf .git node_modules dist *.tgz
|
|
110
|
-
git init
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
2. `package.json`を編集:
|
|
114
|
-
- `name`: `mulmochat-plugin-yourplugin`
|
|
115
|
-
- `description`: プラグインの説明
|
|
107
|
+
自動生成スクリプトを使用するか、詳細なテンプレートガイドを参照してください:
|
|
116
108
|
|
|
117
|
-
|
|
118
|
-
- `TOOL_DEFINITION`: ツール名、説明、パラメータを定義
|
|
119
|
-
- `execute`: ツール実行ロジックを実装
|
|
120
|
-
- 必要に応じて型定義を追加
|
|
109
|
+
### クイックスタート(推奨)
|
|
121
110
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
- Emit: `updateResult`
|
|
111
|
+
```bash
|
|
112
|
+
# 新規プラグインを生成
|
|
113
|
+
./scripts/create-plugin.sh my-plugin "My Plugin" "プラグインの説明"
|
|
126
114
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
115
|
+
# 生成されたディレクトリに移動してインストール
|
|
116
|
+
cd ../MulmoChatPluginMyPlugin
|
|
117
|
+
yarn install
|
|
118
|
+
yarn dev
|
|
119
|
+
```
|
|
130
120
|
|
|
131
|
-
|
|
121
|
+
### 手動セットアップ
|
|
132
122
|
|
|
133
|
-
|
|
123
|
+
詳細な手順は [TEMPLATE.md](./TEMPLATE.md) を参照:
|
|
124
|
+
- そのままコピーできるファイル
|
|
125
|
+
- 変更が必要なファイル(`package.json` のみ)
|
|
126
|
+
- プラグイン固有の実装要件
|
|
127
|
+
- 重要なパターン(View.vue のリアクティビティ)
|
|
134
128
|
|
|
135
129
|
## ToolPlugin インターフェース
|
|
136
130
|
|
package/README.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# MulmoChat Plugin Quiz
|
|
2
2
|
|
|
3
|
+
> **📦 Template Repository**
|
|
4
|
+
> This is the reference implementation for [MulmoChat](https://github.com/receptron/MulmoChat) plugins.
|
|
5
|
+
> Use this repository as a template to create your own plugins.
|
|
6
|
+
> See [TEMPLATE.md](./TEMPLATE.md) for detailed instructions.
|
|
7
|
+
|
|
3
8
|
A quiz plugin for MulmoChat. Presents multiple choice quizzes to users.
|
|
4
9
|
|
|
5
10
|
## Overview
|
|
@@ -72,16 +77,16 @@ yarn lint
|
|
|
72
77
|
MulmoChatPluginQuiz/
|
|
73
78
|
├── src/
|
|
74
79
|
│ ├── index.ts # Export definitions
|
|
75
|
-
│ ├── plugin.ts # Quiz-specific plugin implementation
|
|
76
|
-
│ ├── types.ts # Re-exports common types (backward compat)
|
|
77
80
|
│ ├── style.css # Tailwind CSS entry
|
|
78
81
|
│ ├── common/ # Plugin-agnostic shared code
|
|
79
82
|
│ │ ├── index.ts # Common exports
|
|
80
83
|
│ │ └── types.ts # ToolPlugin, ToolResult, etc.
|
|
81
|
-
│
|
|
82
|
-
│
|
|
83
|
-
│
|
|
84
|
-
│
|
|
84
|
+
│ └── plugin/ # Quiz-specific implementation
|
|
85
|
+
│ ├── index.ts # Plugin instance and execute logic
|
|
86
|
+
│ ├── types.ts # Quiz types and TOOL_DEFINITION
|
|
87
|
+
│ ├── samples.ts # Sample data for testing
|
|
88
|
+
│ ├── View.vue # Main view component
|
|
89
|
+
│ └── Preview.vue # Sidebar preview component
|
|
85
90
|
├── demo/ # Generic plugin demo (works with any plugin)
|
|
86
91
|
│ ├── App.vue # Dynamic component rendering
|
|
87
92
|
│ └── main.ts
|
|
@@ -94,43 +99,32 @@ MulmoChatPluginQuiz/
|
|
|
94
99
|
### Directory Purpose
|
|
95
100
|
|
|
96
101
|
- **src/common/**: Plugin-agnostic types and utilities. Copy this to your new plugin or import from this package.
|
|
97
|
-
- **src/plugin
|
|
98
|
-
- **src/views/**, **src/previews/**: Quiz-specific Vue components. Create your own.
|
|
102
|
+
- **src/plugin/**: Quiz-specific implementation. Replace with your plugin logic.
|
|
99
103
|
- **demo/**: Generic demo that works with any ToolPlugin. Just change the import.
|
|
100
104
|
|
|
101
105
|
## Creating a New Plugin
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
1. Copy the repository:
|
|
106
|
-
```bash
|
|
107
|
-
cp -r MulmoChatPluginQuiz MulmoChatPluginYourPlugin
|
|
108
|
-
cd MulmoChatPluginYourPlugin
|
|
109
|
-
rm -rf .git node_modules dist *.tgz
|
|
110
|
-
git init
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
2. Edit `package.json`:
|
|
114
|
-
- `name`: `mulmochat-plugin-yourplugin`
|
|
115
|
-
- `description`: Your plugin description
|
|
107
|
+
Use the automated script or follow the detailed template guide:
|
|
116
108
|
|
|
117
|
-
|
|
118
|
-
- `TOOL_DEFINITION`: Define tool name, description, and parameters
|
|
119
|
-
- `execute`: Implement tool execution logic
|
|
120
|
-
- Add type definitions as needed
|
|
109
|
+
### Quick Start (Recommended)
|
|
121
110
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
- Emit: `updateResult`
|
|
111
|
+
```bash
|
|
112
|
+
# Generate a new plugin
|
|
113
|
+
./scripts/create-plugin.sh my-plugin "My Plugin" "Description of my plugin"
|
|
126
114
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
115
|
+
# Move to generated directory and install
|
|
116
|
+
cd ../MulmoChatPluginMyPlugin
|
|
117
|
+
yarn install
|
|
118
|
+
yarn dev
|
|
119
|
+
```
|
|
130
120
|
|
|
131
|
-
|
|
121
|
+
### Manual Setup
|
|
132
122
|
|
|
133
|
-
|
|
123
|
+
See [TEMPLATE.md](./TEMPLATE.md) for detailed instructions on:
|
|
124
|
+
- Files that can be copied as-is
|
|
125
|
+
- Files requiring modification (only `package.json`)
|
|
126
|
+
- Plugin-specific implementation requirements
|
|
127
|
+
- Important patterns (View.vue reactivity)
|
|
134
128
|
|
|
135
129
|
## ToolPlugin Interface
|
|
136
130
|
|
package/README.npm.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# MulmoChat Plugin
|
|
2
|
+
|
|
3
|
+
A plugin for [MulmoChat](https://github.com/receptron/MulmoChat) - a multi-modal voice chat application with OpenAI's GPT-4 Realtime API.
|
|
4
|
+
|
|
5
|
+
## What this plugin does
|
|
6
|
+
|
|
7
|
+
{plugin-description}
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
yarn add @mulmochat-plugin/{plugin-name}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import Plugin from "@mulmochat-plugin/{plugin-name}";
|
|
19
|
+
import "@mulmochat-plugin/{plugin-name}/style.css";
|
|
20
|
+
|
|
21
|
+
// Add to pluginList
|
|
22
|
+
const pluginList = [
|
|
23
|
+
// ... other plugins
|
|
24
|
+
Plugin,
|
|
25
|
+
];
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Development
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
# Install dependencies
|
|
32
|
+
yarn install
|
|
33
|
+
|
|
34
|
+
# Start dev server (http://localhost:5173/)
|
|
35
|
+
yarn dev
|
|
36
|
+
|
|
37
|
+
# Build
|
|
38
|
+
yarn build
|
|
39
|
+
|
|
40
|
+
# Type check
|
|
41
|
+
yarn typecheck
|
|
42
|
+
|
|
43
|
+
# Lint
|
|
44
|
+
yarn lint
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
MIT
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MulmoChat Plugin Core Exports
|
|
3
|
+
*
|
|
4
|
+
* Framework-agnostic types and plugin logic.
|
|
5
|
+
* Import from "@mulmochat-plugin/quiz/core"
|
|
6
|
+
*/
|
|
7
|
+
export type { BackendType, ToolContextApp, ToolContext, ToolResult, ToolResultComplete, JsonSchemaProperty, ToolDefinition, StartApiResponse, ToolSample, InputHandler, FileInputHandler, ClipboardImageInputHandler, UrlInputHandler, TextInputHandler, FileUploadConfig, ConfigValue, ConfigFieldSchema, StringFieldSchema, NumberFieldSchema, BooleanFieldSchema, SelectFieldSchema, MultiSelectFieldSchema, SelectOption, PluginConfigSchema, ViewComponentProps, PreviewComponentProps, ToolPluginCore, QuizQuestion, QuizData, QuizArgs, } from "./types";
|
|
8
|
+
export { pluginCore, TOOL_NAME, TOOL_DEFINITION, SAMPLES, executeQuiz } from "./plugin";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MulmoChat Quiz Plugin Core (Framework-agnostic)
|
|
3
|
+
*
|
|
4
|
+
* Contains the plugin logic without UI components.
|
|
5
|
+
* Can be used by any framework (Vue, React, etc.)
|
|
6
|
+
*/
|
|
7
|
+
import type { ToolPluginCore, ToolContext, ToolResult, ToolDefinition, ToolSample, QuizData, QuizArgs } from "./types";
|
|
8
|
+
export declare const TOOL_NAME = "putQuestions";
|
|
9
|
+
export declare const TOOL_DEFINITION: ToolDefinition;
|
|
10
|
+
export declare const SAMPLES: ToolSample[];
|
|
11
|
+
export declare const executeQuiz: (_context: ToolContext, args: QuizArgs) => Promise<ToolResult<never, QuizData>>;
|
|
12
|
+
export declare const pluginCore: ToolPluginCore<never, QuizData, QuizArgs>;
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MulmoChat Plugin Core Types (Framework-agnostic)
|
|
3
|
+
*
|
|
4
|
+
* These types can be used by any framework implementation (Vue, React, etc.)
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Backend types that plugins can declare they use.
|
|
8
|
+
* App layer manages actual provider/model settings for each type.
|
|
9
|
+
*/
|
|
10
|
+
export type BackendType = "textLLM" | "imageGen" | "audio" | "search" | "browse" | "map" | "mulmocast";
|
|
11
|
+
/**
|
|
12
|
+
* App interface provided to plugins via context.app
|
|
13
|
+
* Contains backend functions and config accessors
|
|
14
|
+
*/
|
|
15
|
+
export interface ToolContextApp extends Record<string, (...args: any[]) => any> {
|
|
16
|
+
getConfig: <T = unknown>(key: string) => T | undefined;
|
|
17
|
+
setConfig: (key: string, value: unknown) => void;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Context passed to plugin execute function
|
|
21
|
+
*/
|
|
22
|
+
export interface ToolContext {
|
|
23
|
+
currentResult?: ToolResult<unknown> | null;
|
|
24
|
+
app?: ToolContextApp;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Result returned from plugin execution
|
|
28
|
+
*/
|
|
29
|
+
export interface ToolResult<T = unknown, J = unknown> {
|
|
30
|
+
toolName?: string;
|
|
31
|
+
uuid?: string;
|
|
32
|
+
message: string;
|
|
33
|
+
title?: string;
|
|
34
|
+
jsonData?: J;
|
|
35
|
+
instructions?: string;
|
|
36
|
+
instructionsRequired?: boolean;
|
|
37
|
+
updating?: boolean;
|
|
38
|
+
cancelled?: boolean;
|
|
39
|
+
data?: T;
|
|
40
|
+
viewState?: Record<string, unknown>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Complete tool result with required fields
|
|
44
|
+
*/
|
|
45
|
+
export interface ToolResultComplete<T = unknown, J = unknown> extends ToolResult<T, J> {
|
|
46
|
+
toolName: string;
|
|
47
|
+
uuid: string;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* JSON Schema property definition for tool parameters
|
|
51
|
+
*/
|
|
52
|
+
export interface JsonSchemaProperty {
|
|
53
|
+
type?: string;
|
|
54
|
+
description?: string;
|
|
55
|
+
enum?: string[];
|
|
56
|
+
items?: JsonSchemaProperty;
|
|
57
|
+
minimum?: number;
|
|
58
|
+
maximum?: number;
|
|
59
|
+
minItems?: number;
|
|
60
|
+
maxItems?: number;
|
|
61
|
+
properties?: Record<string, JsonSchemaProperty>;
|
|
62
|
+
required?: string[];
|
|
63
|
+
additionalProperties?: boolean;
|
|
64
|
+
oneOf?: JsonSchemaProperty[];
|
|
65
|
+
[key: string]: unknown;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Tool definition for OpenAI-compatible function calling
|
|
69
|
+
*/
|
|
70
|
+
export interface ToolDefinition {
|
|
71
|
+
type: "function";
|
|
72
|
+
name: string;
|
|
73
|
+
description: string;
|
|
74
|
+
parameters?: {
|
|
75
|
+
type: "object";
|
|
76
|
+
properties: Record<string, JsonSchemaProperty>;
|
|
77
|
+
required: string[];
|
|
78
|
+
additionalProperties?: boolean;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* API response from server start endpoint
|
|
83
|
+
*/
|
|
84
|
+
export interface StartApiResponse {
|
|
85
|
+
hasOpenAIApiKey?: boolean;
|
|
86
|
+
hasAnthropicApiKey?: boolean;
|
|
87
|
+
hasGoogleApiKey?: boolean;
|
|
88
|
+
[key: string]: unknown;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Sample arguments for testing
|
|
92
|
+
*/
|
|
93
|
+
export interface ToolSample {
|
|
94
|
+
name: string;
|
|
95
|
+
args: Record<string, unknown>;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* File input handler
|
|
99
|
+
*/
|
|
100
|
+
export interface FileInputHandler {
|
|
101
|
+
type: "file";
|
|
102
|
+
acceptedTypes: string[];
|
|
103
|
+
handleInput: (fileData: string, fileName: string) => ToolResult<unknown, unknown>;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Clipboard image input handler
|
|
107
|
+
*/
|
|
108
|
+
export interface ClipboardImageInputHandler {
|
|
109
|
+
type: "clipboard-image";
|
|
110
|
+
handleInput: (imageData: string) => ToolResult<unknown, unknown>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* URL input handler
|
|
114
|
+
*/
|
|
115
|
+
export interface UrlInputHandler {
|
|
116
|
+
type: "url";
|
|
117
|
+
patterns?: string[];
|
|
118
|
+
handleInput: (url: string) => ToolResult<unknown, unknown>;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Text input handler
|
|
122
|
+
*/
|
|
123
|
+
export interface TextInputHandler {
|
|
124
|
+
type: "text";
|
|
125
|
+
patterns?: string[];
|
|
126
|
+
handleInput: (text: string) => ToolResult<unknown, unknown>;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Union of all input handler types
|
|
130
|
+
*/
|
|
131
|
+
export type InputHandler = FileInputHandler | ClipboardImageInputHandler | UrlInputHandler | TextInputHandler;
|
|
132
|
+
/**
|
|
133
|
+
* Legacy file upload config (for backward compatibility)
|
|
134
|
+
* @deprecated Use InputHandler instead
|
|
135
|
+
*/
|
|
136
|
+
export interface FileUploadConfig {
|
|
137
|
+
acceptedTypes: string[];
|
|
138
|
+
handleUpload: (fileData: string, fileName: string, ...args: unknown[]) => ToolResult<unknown, unknown>;
|
|
139
|
+
}
|
|
140
|
+
export type ConfigValue = string | number | boolean | string[];
|
|
141
|
+
interface BaseFieldSchema {
|
|
142
|
+
label: string;
|
|
143
|
+
description?: string;
|
|
144
|
+
required?: boolean;
|
|
145
|
+
}
|
|
146
|
+
export interface StringFieldSchema extends BaseFieldSchema {
|
|
147
|
+
type: "string";
|
|
148
|
+
placeholder?: string;
|
|
149
|
+
minLength?: number;
|
|
150
|
+
maxLength?: number;
|
|
151
|
+
pattern?: string;
|
|
152
|
+
}
|
|
153
|
+
export interface NumberFieldSchema extends BaseFieldSchema {
|
|
154
|
+
type: "number";
|
|
155
|
+
min?: number;
|
|
156
|
+
max?: number;
|
|
157
|
+
step?: number;
|
|
158
|
+
}
|
|
159
|
+
export interface BooleanFieldSchema extends BaseFieldSchema {
|
|
160
|
+
type: "boolean";
|
|
161
|
+
}
|
|
162
|
+
export interface SelectOption {
|
|
163
|
+
value: string;
|
|
164
|
+
label: string;
|
|
165
|
+
description?: string;
|
|
166
|
+
disabled?: boolean;
|
|
167
|
+
}
|
|
168
|
+
export interface SelectFieldSchema extends BaseFieldSchema {
|
|
169
|
+
type: "select";
|
|
170
|
+
options: SelectOption[];
|
|
171
|
+
}
|
|
172
|
+
export interface MultiSelectFieldSchema extends BaseFieldSchema {
|
|
173
|
+
type: "multiselect";
|
|
174
|
+
options: SelectOption[];
|
|
175
|
+
minItems?: number;
|
|
176
|
+
maxItems?: number;
|
|
177
|
+
}
|
|
178
|
+
export type ConfigFieldSchema = StringFieldSchema | NumberFieldSchema | BooleanFieldSchema | SelectFieldSchema | MultiSelectFieldSchema;
|
|
179
|
+
/**
|
|
180
|
+
* Plugin configuration schema (JSON Schema based)
|
|
181
|
+
*/
|
|
182
|
+
export interface PluginConfigSchema {
|
|
183
|
+
key: string;
|
|
184
|
+
defaultValue: ConfigValue;
|
|
185
|
+
schema: ConfigFieldSchema;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Standard props for View components
|
|
189
|
+
*/
|
|
190
|
+
export interface ViewComponentProps<T = unknown, J = unknown> {
|
|
191
|
+
selectedResult: ToolResultComplete<T, J>;
|
|
192
|
+
sendTextMessage: (text?: string) => void;
|
|
193
|
+
onUpdateResult?: (result: Partial<ToolResult<T, J>>) => void;
|
|
194
|
+
pluginConfigs?: Record<string, unknown>;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Standard props for Preview components
|
|
198
|
+
*/
|
|
199
|
+
export interface PreviewComponentProps<T = unknown, J = unknown> {
|
|
200
|
+
result: ToolResultComplete<T, J>;
|
|
201
|
+
isSelected?: boolean;
|
|
202
|
+
onSelect?: () => void;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Core plugin interface - framework agnostic
|
|
206
|
+
* Does not include UI components
|
|
207
|
+
*/
|
|
208
|
+
export interface ToolPluginCore<T = unknown, J = unknown, A extends object = object> {
|
|
209
|
+
toolDefinition: ToolDefinition;
|
|
210
|
+
execute: (context: ToolContext, args: A) => Promise<ToolResult<T, J>>;
|
|
211
|
+
generatingMessage: string;
|
|
212
|
+
waitingMessage?: string;
|
|
213
|
+
uploadMessage?: string;
|
|
214
|
+
isEnabled: (startResponse?: StartApiResponse | null) => boolean;
|
|
215
|
+
delayAfterExecution?: number;
|
|
216
|
+
systemPrompt?: string;
|
|
217
|
+
inputHandlers?: InputHandler[];
|
|
218
|
+
/** @deprecated Use inputHandlers instead */
|
|
219
|
+
fileUpload?: FileUploadConfig;
|
|
220
|
+
/** New JSON Schema based config (framework-agnostic) */
|
|
221
|
+
configSchema?: PluginConfigSchema;
|
|
222
|
+
samples?: ToolSample[];
|
|
223
|
+
backends?: BackendType[];
|
|
224
|
+
}
|
|
225
|
+
/** Single quiz question */
|
|
226
|
+
export interface QuizQuestion {
|
|
227
|
+
question: string;
|
|
228
|
+
choices: string[];
|
|
229
|
+
correctAnswer?: number;
|
|
230
|
+
}
|
|
231
|
+
/** Quiz data stored in result.jsonData */
|
|
232
|
+
export interface QuizData {
|
|
233
|
+
title?: string;
|
|
234
|
+
questions: QuizQuestion[];
|
|
235
|
+
userAnswers?: number[];
|
|
236
|
+
}
|
|
237
|
+
/** Arguments passed to the quiz tool */
|
|
238
|
+
export interface QuizArgs {
|
|
239
|
+
title?: string;
|
|
240
|
+
questions: QuizQuestion[];
|
|
241
|
+
}
|
|
242
|
+
export {};
|
package/dist/core.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i="putQuestions",o={type:"function",name:i,description:"Present a set of multiple choice questions to test the user's knowledge or abilities. Each question should have 2-6 answer choices.",parameters:{type:"object",properties:{title:{type:"string",description:"Optional title for the quiz (e.g., 'JavaScript Basics Quiz')"},questions:{type:"array",description:"Array of multiple choice questions",items:{type:"object",properties:{question:{type:"string",description:"The question text"},choices:{type:"array",description:"Array of answer choices (2-6 choices)",items:{type:"string"},minItems:2,maxItems:6},correctAnswer:{type:"number",description:"Optional: The index of the correct answer (0-based). Include this if you want to track correct answers."}},required:["question","choices"]},minItems:1}},required:["questions"]}},n=[{name:"JavaScript Quiz",args:{title:"JavaScript Basics",questions:[{question:"What does 'const' do in JavaScript?",choices:["Declares a constant variable","Declares a mutable variable","Creates a function","Imports a module"],correctAnswer:0},{question:"Which method adds an element to the end of an array?",choices:["pop()","shift()","push()","unshift()"],correctAnswer:2},{question:"What is the output of: typeof null?",choices:['"null"','"undefined"','"object"','"boolean"'],correctAnswer:2}]}},{name:"World Capitals",args:{title:"World Capitals Quiz",questions:[{question:"What is the capital of Japan?",choices:["Osaka","Kyoto","Tokyo","Hiroshima"],correctAnswer:2},{question:"What is the capital of Australia?",choices:["Sydney","Melbourne","Canberra","Brisbane"],correctAnswer:2}]}},{name:"Simple Yes/No",args:{questions:[{question:"Is the Earth round?",choices:["Yes","No"],correctAnswer:0}]}}],a=async(l,c)=>{try{const{title:s,questions:e}=c;if(!e||!Array.isArray(e)||e.length===0)throw new Error("At least one question is required");for(let t=0;t<e.length;t++){const r=e[t];if(!r.question||typeof r.question!="string")throw new Error(`Question ${t+1} must have a question text`);if(!Array.isArray(r.choices)||r.choices.length<2)throw new Error(`Question ${t+1} must have at least 2 choices`);if(r.choices.length>6)throw new Error(`Question ${t+1} cannot have more than 6 choices`)}const u={title:s,questions:e};return{message:`Quiz presented with ${e.length} question${e.length>1?"s":""}`,jsonData:u,instructions:"The quiz has been presented to the user. Wait for the user to submit their answers. They will tell you their answers in text format."}}catch(s){return console.error("Quiz creation error",s),{message:`Quiz error: ${s instanceof Error?s.message:"Unknown error"}`,instructions:"Acknowledge that there was an error creating the quiz and suggest trying again."}}},h={toolDefinition:o,execute:a,generatingMessage:"Preparing quiz...",isEnabled:()=>!0,samples:n};exports.SAMPLES=n;exports.TOOL_DEFINITION=o;exports.TOOL_NAME=i;exports.executeQuiz=a;exports.pluginCore=h;
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
const n = "putQuestions", a = {
|
|
2
|
+
type: "function",
|
|
3
|
+
name: n,
|
|
4
|
+
description: "Present a set of multiple choice questions to test the user's knowledge or abilities. Each question should have 2-6 answer choices.",
|
|
5
|
+
parameters: {
|
|
6
|
+
type: "object",
|
|
7
|
+
properties: {
|
|
8
|
+
title: {
|
|
9
|
+
type: "string",
|
|
10
|
+
description: "Optional title for the quiz (e.g., 'JavaScript Basics Quiz')"
|
|
11
|
+
},
|
|
12
|
+
questions: {
|
|
13
|
+
type: "array",
|
|
14
|
+
description: "Array of multiple choice questions",
|
|
15
|
+
items: {
|
|
16
|
+
type: "object",
|
|
17
|
+
properties: {
|
|
18
|
+
question: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "The question text"
|
|
21
|
+
},
|
|
22
|
+
choices: {
|
|
23
|
+
type: "array",
|
|
24
|
+
description: "Array of answer choices (2-6 choices)",
|
|
25
|
+
items: {
|
|
26
|
+
type: "string"
|
|
27
|
+
},
|
|
28
|
+
minItems: 2,
|
|
29
|
+
maxItems: 6
|
|
30
|
+
},
|
|
31
|
+
correctAnswer: {
|
|
32
|
+
type: "number",
|
|
33
|
+
description: "Optional: The index of the correct answer (0-based). Include this if you want to track correct answers."
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
required: ["question", "choices"]
|
|
37
|
+
},
|
|
38
|
+
minItems: 1
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
required: ["questions"]
|
|
42
|
+
}
|
|
43
|
+
}, c = [
|
|
44
|
+
{
|
|
45
|
+
name: "JavaScript Quiz",
|
|
46
|
+
args: {
|
|
47
|
+
title: "JavaScript Basics",
|
|
48
|
+
questions: [
|
|
49
|
+
{
|
|
50
|
+
question: "What does 'const' do in JavaScript?",
|
|
51
|
+
choices: [
|
|
52
|
+
"Declares a constant variable",
|
|
53
|
+
"Declares a mutable variable",
|
|
54
|
+
"Creates a function",
|
|
55
|
+
"Imports a module"
|
|
56
|
+
],
|
|
57
|
+
correctAnswer: 0
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
question: "Which method adds an element to the end of an array?",
|
|
61
|
+
choices: ["pop()", "shift()", "push()", "unshift()"],
|
|
62
|
+
correctAnswer: 2
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
question: "What is the output of: typeof null?",
|
|
66
|
+
choices: ['"null"', '"undefined"', '"object"', '"boolean"'],
|
|
67
|
+
correctAnswer: 2
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: "World Capitals",
|
|
74
|
+
args: {
|
|
75
|
+
title: "World Capitals Quiz",
|
|
76
|
+
questions: [
|
|
77
|
+
{
|
|
78
|
+
question: "What is the capital of Japan?",
|
|
79
|
+
choices: ["Osaka", "Kyoto", "Tokyo", "Hiroshima"],
|
|
80
|
+
correctAnswer: 2
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
question: "What is the capital of Australia?",
|
|
84
|
+
choices: ["Sydney", "Melbourne", "Canberra", "Brisbane"],
|
|
85
|
+
correctAnswer: 2
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: "Simple Yes/No",
|
|
92
|
+
args: {
|
|
93
|
+
questions: [
|
|
94
|
+
{
|
|
95
|
+
question: "Is the Earth round?",
|
|
96
|
+
choices: ["Yes", "No"],
|
|
97
|
+
correctAnswer: 0
|
|
98
|
+
}
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
], u = async (h, o) => {
|
|
103
|
+
try {
|
|
104
|
+
const { title: s, questions: e } = o;
|
|
105
|
+
if (!e || !Array.isArray(e) || e.length === 0)
|
|
106
|
+
throw new Error("At least one question is required");
|
|
107
|
+
for (let t = 0; t < e.length; t++) {
|
|
108
|
+
const r = e[t];
|
|
109
|
+
if (!r.question || typeof r.question != "string")
|
|
110
|
+
throw new Error(`Question ${t + 1} must have a question text`);
|
|
111
|
+
if (!Array.isArray(r.choices) || r.choices.length < 2)
|
|
112
|
+
throw new Error(`Question ${t + 1} must have at least 2 choices`);
|
|
113
|
+
if (r.choices.length > 6)
|
|
114
|
+
throw new Error(`Question ${t + 1} cannot have more than 6 choices`);
|
|
115
|
+
}
|
|
116
|
+
const i = {
|
|
117
|
+
title: s,
|
|
118
|
+
questions: e
|
|
119
|
+
};
|
|
120
|
+
return {
|
|
121
|
+
message: `Quiz presented with ${e.length} question${e.length > 1 ? "s" : ""}`,
|
|
122
|
+
jsonData: i,
|
|
123
|
+
instructions: "The quiz has been presented to the user. Wait for the user to submit their answers. They will tell you their answers in text format."
|
|
124
|
+
};
|
|
125
|
+
} catch (s) {
|
|
126
|
+
return console.error("Quiz creation error", s), {
|
|
127
|
+
message: `Quiz error: ${s instanceof Error ? s.message : "Unknown error"}`,
|
|
128
|
+
instructions: "Acknowledge that there was an error creating the quiz and suggest trying again."
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}, l = {
|
|
132
|
+
toolDefinition: a,
|
|
133
|
+
execute: u,
|
|
134
|
+
generatingMessage: "Preparing quiz...",
|
|
135
|
+
isEnabled: () => !0,
|
|
136
|
+
samples: c
|
|
137
|
+
};
|
|
138
|
+
export {
|
|
139
|
+
c as SAMPLES,
|
|
140
|
+
a as TOOL_DEFINITION,
|
|
141
|
+
n as TOOL_NAME,
|
|
142
|
+
u as executeQuiz,
|
|
143
|
+
l as pluginCore
|
|
144
|
+
};
|