@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/dist/index.cjs
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("
|
|
2
|
-
${s.value.map((a,c)=>{if(a===null)return null;const p=c+1,u=String.fromCharCode(65+a),g=o.value.questions[c].choices[a];return`Q${p}: ${u} - ${g}`}).filter(a=>a!==null).join(`
|
|
3
|
-
`)}`;t.sendTextMessage(l)}return(n,l)=>(e.openBlock(),e.createElementBlock("div",y,[o.value?(e.openBlock(),e.createElementBlock("div",w,[o.value.title?(e.openBlock(),e.createElementBlock("h2",b,e.toDisplayString(o.value.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",_,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(o.value.questions,(a,c)=>(e.openBlock(),e.createElementBlock("div",{key:c,class:"bg-[#2d2d44] rounded-lg p-6 border-2 border-[#3d3d5c]"},[e.createElementVNode("div",q,[e.createElementVNode("span",x,e.toDisplayString(c+1)+".",1),e.createTextVNode(" "+e.toDisplayString(a.question),1)]),e.createElementVNode("div",k,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.choices,(p,u)=>(e.openBlock(),e.createElementBlock("label",{key:u,class:e.normalizeClass([f(c,u),"flex items-start p-4 rounded-lg cursor-pointer transition-all duration-200 border-2"])},[e.withDirectives(e.createElementVNode("input",{type:"radio",name:`question-${c}`,value:u,"onUpdate:modelValue":g=>s.value[c]=g,class:"mt-1 mr-3 size-4 shrink-0"},null,8,E),[[e.vModelRadio,s.value[c]]]),e.createElementVNode("span",A,[e.createElementVNode("span",S,e.toDisplayString(String.fromCharCode(65+u))+".",1),e.createTextVNode(" "+e.toDisplayString(p),1)])],2))),128))])]))),128))]),e.createElementVNode("div",N,[e.createElementVNode("button",{onClick:v,disabled:!m.value,class:e.normalizeClass([m.value?"bg-blue-600 hover:bg-blue-700":"bg-gray-600 cursor-not-allowed opacity-50","py-3 px-8 rounded-lg text-white font-semibold text-lg transition-colors border-none cursor-pointer"])}," Submit Answers ",10,B)]),e.createElementVNode("div",V,e.toDisplayString(i.value)+" / "+e.toDisplayString(o.value.questions.length)+" questions answered ",1)])):e.createCommentVNode("",!0)]))}}),Q={class:"p-3 bg-blue-50 rounded-md"},C={key:0,class:"flex flex-col gap-2"},D={class:"text-sm font-semibold text-gray-800 text-center"},$={class:"text-center"},T={class:"inline-block bg-blue-600 text-white text-xs font-bold py-1 px-3 rounded-full"},M={class:"text-xs text-gray-600 overflow-hidden line-clamp-2"},O={class:"flex justify-center gap-1"},W={key:0,class:"text-xs text-gray-500"},j=e.defineComponent({__name:"QuizPreview",props:{result:{}},setup(h){const d=h,t=e.computed(()=>d.result.jsonData);return(r,o)=>(e.openBlock(),e.createElementBlock("div",Q,[t.value?(e.openBlock(),e.createElementBlock("div",C,[e.createElementVNode("div",D,e.toDisplayString(t.value.title||"Quiz"),1),e.createElementVNode("div",$,[e.createElementVNode("span",T,e.toDisplayString(t.value.questions.length)+" "+e.toDisplayString(t.value.questions.length===1?"Question":"Questions"),1)]),e.createElementVNode("div",M,e.toDisplayString(t.value.questions[0]?.question),1),e.createElementVNode("div",O,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.min(t.value.questions[0]?.choices.length||0,4),(s,i)=>(e.openBlock(),e.createElementBlock("div",{key:i,class:"size-2 bg-gray-400 rounded-full"}))),128)),(t.value.questions[0]?.choices.length||0)>4?(e.openBlock(),e.createElementBlock("div",W," +"+e.toDisplayString(t.value.questions[0].choices.length-4),1)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)]))}}),P="putQuestions",L=[{name:"Geography Quiz",args:{title:"World Geography",questions:[{question:"What is the capital of France?",choices:["London","Berlin","Paris","Madrid"],correctAnswer:2},{question:"Which is the largest ocean?",choices:["Atlantic","Indian","Arctic","Pacific"],correctAnswer:3},{question:"Mount Everest is located in which mountain range?",choices:["Alps","Andes","Himalayas","Rockies"],correctAnswer:2}]}},{name:"Science Quiz",args:{title:"Science Basics",questions:[{question:"Which planet is known as the Red Planet?",choices:["Venus","Mars","Jupiter","Saturn"],correctAnswer:1},{question:"What is the chemical symbol for water?",choices:["O2","CO2","H2O","NaCl"],correctAnswer:2},{question:"How many bones are in the adult human body?",choices:["186","206","226","246"],correctAnswer:1},{question:"What is the speed of light?",choices:["300,000 km/s","150,000 km/s","500,000 km/s","1,000,000 km/s"],correctAnswer:0}]}},{name:"Math Quiz",args:{title:"Math Challenge",questions:[{question:"What is 15 x 15?",choices:["200","215","225","250"],correctAnswer:2},{question:"What is the square root of 144?",choices:["10","11","12","13"],correctAnswer:2}]}},{name:"No Correct Answer",args:{title:"Opinion Poll",questions:[{question:"What is your favorite color?",choices:["Red","Blue","Green","Yellow"]},{question:"Which season do you prefer?",choices:["Spring","Summer","Autumn","Winter"]}]}},{name:"Single Question",args:{title:"Quick Question",questions:[{question:"Is this quiz plugin working correctly?",choices:["Yes","No"],correctAnswer:0}]}}],R={type:"function",name:P,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"]}},F=async(h,d)=>{try{const{title:t,questions:r}=d;if(!r||!Array.isArray(r)||r.length===0)throw new Error("At least one question is required");for(let s=0;s<r.length;s++){const i=r[s];if(!i.question||typeof i.question!="string")throw new Error(`Question ${s+1} must have a question text`);if(!Array.isArray(i.choices)||i.choices.length<2)throw new Error(`Question ${s+1} must have at least 2 choices`);if(i.choices.length>6)throw new Error(`Question ${s+1} cannot have more than 6 choices`)}const o={title:t,questions:r};return{message:`Quiz presented with ${r.length} question${r.length>1?"s":""}`,jsonData:o,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(t){return console.error("Quiz creation error",t),{message:`Quiz error: ${t instanceof Error?t.message:"Unknown error"}`,instructions:"Acknowledge that there was an error creating the quiz and suggest trying again."}}},H={toolDefinition:R,execute:F,generatingMessage:"Preparing quiz...",isEnabled:()=>!0,viewComponent:z,previewComponent:j,samples:L},G={plugin:H};exports.default=G;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./core.cjs");exports.SAMPLES=e.SAMPLES;exports.TOOL_DEFINITION=e.TOOL_DEFINITION;exports.TOOL_NAME=e.TOOL_NAME;exports.default=e.pluginCore;exports.executeQuiz=e.executeQuiz;exports.pluginCore=e.pluginCore;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* MulmoChat Quiz Plugin
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Default export is the framework-agnostic core.
|
|
5
|
+
* For Vue implementation, import from "@mulmochat-plugin/quiz/vue"
|
|
6
|
+
*
|
|
7
|
+
* @example Default (Core - framework-agnostic)
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { pluginCore, TOOL_NAME, QuizData } from "@mulmochat-plugin/quiz";
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* @example Vue implementation
|
|
5
13
|
* ```typescript
|
|
6
|
-
* import QuizPlugin from "@mulmochat-plugin/quiz";
|
|
14
|
+
* import QuizPlugin from "@mulmochat-plugin/quiz/vue";
|
|
7
15
|
* import "@mulmochat-plugin/quiz/style.css";
|
|
8
16
|
* ```
|
|
9
17
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
declare const _default: {
|
|
13
|
-
plugin: ToolPlugin;
|
|
14
|
-
};
|
|
15
|
-
export default _default;
|
|
18
|
+
export * from "./core";
|
|
19
|
+
export { pluginCore as default } from "./core";
|
package/dist/index.js
CHANGED
|
@@ -1,314 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const T = { class: "size-full overflow-y-auto p-8 bg-[#1a1a2e]" }, M = {
|
|
3
|
-
key: 0,
|
|
4
|
-
class: "max-w-3xl w-full mx-auto"
|
|
5
|
-
}, W = {
|
|
6
|
-
key: 0,
|
|
7
|
-
class: "text-[#f0f0f0] text-3xl font-bold mb-8 text-center"
|
|
8
|
-
}, D = { class: "flex flex-col gap-6" }, N = { class: "text-white text-lg font-semibold mb-4" }, O = { class: "text-blue-400 mr-2" }, j = { class: "flex flex-col gap-3" }, P = ["name", "value", "onUpdate:modelValue"], R = { class: "text-white flex-1" }, V = { class: "font-semibold mr-2" }, B = { class: "mt-8 flex justify-center" }, L = ["disabled"], F = { class: "mt-4 text-center text-gray-400 text-sm" }, H = /* @__PURE__ */ z({
|
|
9
|
-
__name: "QuizView",
|
|
10
|
-
props: {
|
|
11
|
-
selectedResult: {},
|
|
12
|
-
sendTextMessage: { type: Function }
|
|
13
|
-
},
|
|
14
|
-
emits: ["updateResult"],
|
|
15
|
-
setup(g, { emit: p }) {
|
|
16
|
-
const e = g, c = p, o = x(null), t = x([]);
|
|
17
|
-
A(
|
|
18
|
-
() => e.selectedResult,
|
|
19
|
-
(n) => {
|
|
20
|
-
n?.toolName === "putQuestions" && n.jsonData && (o.value = n.jsonData, n.viewState?.userAnswers ? t.value = n.viewState.userAnswers : t.value = new Array(o.value.questions.length).fill(null));
|
|
21
|
-
},
|
|
22
|
-
{ immediate: !0 }
|
|
23
|
-
), A(
|
|
24
|
-
t,
|
|
25
|
-
(n) => {
|
|
26
|
-
if (e.selectedResult && n) {
|
|
27
|
-
const d = {
|
|
28
|
-
...e.selectedResult,
|
|
29
|
-
viewState: {
|
|
30
|
-
userAnswers: n
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
c("updateResult", d);
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
{ deep: !0 }
|
|
37
|
-
);
|
|
38
|
-
const l = _(() => t.value.filter((n) => n !== null).length), v = _(() => o.value && l.value === o.value.questions.length);
|
|
39
|
-
function $(n, d) {
|
|
40
|
-
return t.value[n] === d ? "border-blue-500 bg-blue-500/20" : "border-[#4b4b6b] hover:border-[#6b6b8b] hover:bg-[#6b6b8b]/20";
|
|
41
|
-
}
|
|
42
|
-
function S() {
|
|
43
|
-
if (!o.value || !v.value) return;
|
|
44
|
-
const d = `Here are my answers:
|
|
45
|
-
${t.value.map((u, h) => {
|
|
46
|
-
if (u === null) return null;
|
|
47
|
-
const w = h + 1, m = String.fromCharCode(65 + u), b = o.value.questions[h].choices[u];
|
|
48
|
-
return `Q${w}: ${m} - ${b}`;
|
|
49
|
-
}).filter((u) => u !== null).join(`
|
|
50
|
-
`)}`;
|
|
51
|
-
e.sendTextMessage(d);
|
|
52
|
-
}
|
|
53
|
-
return (n, d) => (r(), i("div", T, [
|
|
54
|
-
o.value ? (r(), i("div", M, [
|
|
55
|
-
o.value.title ? (r(), i("h2", W, a(o.value.title), 1)) : f("", !0),
|
|
56
|
-
s("div", D, [
|
|
57
|
-
(r(!0), i(y, null, q(o.value.questions, (u, h) => (r(), i("div", {
|
|
58
|
-
key: h,
|
|
59
|
-
class: "bg-[#2d2d44] rounded-lg p-6 border-2 border-[#3d3d5c]"
|
|
60
|
-
}, [
|
|
61
|
-
s("div", N, [
|
|
62
|
-
s("span", O, a(h + 1) + ".", 1),
|
|
63
|
-
k(" " + a(u.question), 1)
|
|
64
|
-
]),
|
|
65
|
-
s("div", j, [
|
|
66
|
-
(r(!0), i(y, null, q(u.choices, (w, m) => (r(), i("label", {
|
|
67
|
-
key: m,
|
|
68
|
-
class: Q([$(h, m), "flex items-start p-4 rounded-lg cursor-pointer transition-all duration-200 border-2"])
|
|
69
|
-
}, [
|
|
70
|
-
C(s("input", {
|
|
71
|
-
type: "radio",
|
|
72
|
-
name: `question-${h}`,
|
|
73
|
-
value: m,
|
|
74
|
-
"onUpdate:modelValue": (b) => t.value[h] = b,
|
|
75
|
-
class: "mt-1 mr-3 size-4 shrink-0"
|
|
76
|
-
}, null, 8, P), [
|
|
77
|
-
[E, t.value[h]]
|
|
78
|
-
]),
|
|
79
|
-
s("span", R, [
|
|
80
|
-
s("span", V, a(String.fromCharCode(65 + m)) + ".", 1),
|
|
81
|
-
k(" " + a(w), 1)
|
|
82
|
-
])
|
|
83
|
-
], 2))), 128))
|
|
84
|
-
])
|
|
85
|
-
]))), 128))
|
|
86
|
-
]),
|
|
87
|
-
s("div", B, [
|
|
88
|
-
s("button", {
|
|
89
|
-
onClick: S,
|
|
90
|
-
disabled: !v.value,
|
|
91
|
-
class: Q([v.value ? "bg-blue-600 hover:bg-blue-700" : "bg-gray-600 cursor-not-allowed opacity-50", "py-3 px-8 rounded-lg text-white font-semibold text-lg transition-colors border-none cursor-pointer"])
|
|
92
|
-
}, " Submit Answers ", 10, L)
|
|
93
|
-
]),
|
|
94
|
-
s("div", F, a(l.value) + " / " + a(o.value.questions.length) + " questions answered ", 1)
|
|
95
|
-
])) : f("", !0)
|
|
96
|
-
]));
|
|
97
|
-
}
|
|
98
|
-
}), G = { class: "p-3 bg-blue-50 rounded-md" }, U = {
|
|
99
|
-
key: 0,
|
|
100
|
-
class: "flex flex-col gap-2"
|
|
101
|
-
}, J = { class: "text-sm font-semibold text-gray-800 text-center" }, Y = { class: "text-center" }, I = { class: "inline-block bg-blue-600 text-white text-xs font-bold py-1 px-3 rounded-full" }, K = { class: "text-xs text-gray-600 overflow-hidden line-clamp-2" }, X = { class: "flex justify-center gap-1" }, Z = {
|
|
102
|
-
key: 0,
|
|
103
|
-
class: "text-xs text-gray-500"
|
|
104
|
-
}, ee = /* @__PURE__ */ z({
|
|
105
|
-
__name: "QuizPreview",
|
|
106
|
-
props: {
|
|
107
|
-
result: {}
|
|
108
|
-
},
|
|
109
|
-
setup(g) {
|
|
110
|
-
const p = g, e = _(() => p.result.jsonData);
|
|
111
|
-
return (c, o) => (r(), i("div", G, [
|
|
112
|
-
e.value ? (r(), i("div", U, [
|
|
113
|
-
s("div", J, a(e.value.title || "Quiz"), 1),
|
|
114
|
-
s("div", Y, [
|
|
115
|
-
s("span", I, a(e.value.questions.length) + " " + a(e.value.questions.length === 1 ? "Question" : "Questions"), 1)
|
|
116
|
-
]),
|
|
117
|
-
s("div", K, a(e.value.questions[0]?.question), 1),
|
|
118
|
-
s("div", X, [
|
|
119
|
-
(r(!0), i(y, null, q(Math.min(e.value.questions[0]?.choices.length || 0, 4), (t, l) => (r(), i("div", {
|
|
120
|
-
key: l,
|
|
121
|
-
class: "size-2 bg-gray-400 rounded-full"
|
|
122
|
-
}))), 128)),
|
|
123
|
-
(e.value.questions[0]?.choices.length || 0) > 4 ? (r(), i("div", Z, " +" + a(e.value.questions[0].choices.length - 4), 1)) : f("", !0)
|
|
124
|
-
])
|
|
125
|
-
])) : f("", !0)
|
|
126
|
-
]));
|
|
127
|
-
}
|
|
128
|
-
}), te = "putQuestions", se = [
|
|
129
|
-
{
|
|
130
|
-
name: "Geography Quiz",
|
|
131
|
-
args: {
|
|
132
|
-
title: "World Geography",
|
|
133
|
-
questions: [
|
|
134
|
-
{
|
|
135
|
-
question: "What is the capital of France?",
|
|
136
|
-
choices: ["London", "Berlin", "Paris", "Madrid"],
|
|
137
|
-
correctAnswer: 2
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
question: "Which is the largest ocean?",
|
|
141
|
-
choices: ["Atlantic", "Indian", "Arctic", "Pacific"],
|
|
142
|
-
correctAnswer: 3
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
question: "Mount Everest is located in which mountain range?",
|
|
146
|
-
choices: ["Alps", "Andes", "Himalayas", "Rockies"],
|
|
147
|
-
correctAnswer: 2
|
|
148
|
-
}
|
|
149
|
-
]
|
|
150
|
-
}
|
|
151
|
-
},
|
|
152
|
-
{
|
|
153
|
-
name: "Science Quiz",
|
|
154
|
-
args: {
|
|
155
|
-
title: "Science Basics",
|
|
156
|
-
questions: [
|
|
157
|
-
{
|
|
158
|
-
question: "Which planet is known as the Red Planet?",
|
|
159
|
-
choices: ["Venus", "Mars", "Jupiter", "Saturn"],
|
|
160
|
-
correctAnswer: 1
|
|
161
|
-
},
|
|
162
|
-
{
|
|
163
|
-
question: "What is the chemical symbol for water?",
|
|
164
|
-
choices: ["O2", "CO2", "H2O", "NaCl"],
|
|
165
|
-
correctAnswer: 2
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
question: "How many bones are in the adult human body?",
|
|
169
|
-
choices: ["186", "206", "226", "246"],
|
|
170
|
-
correctAnswer: 1
|
|
171
|
-
},
|
|
172
|
-
{
|
|
173
|
-
question: "What is the speed of light?",
|
|
174
|
-
choices: [
|
|
175
|
-
"300,000 km/s",
|
|
176
|
-
"150,000 km/s",
|
|
177
|
-
"500,000 km/s",
|
|
178
|
-
"1,000,000 km/s"
|
|
179
|
-
],
|
|
180
|
-
correctAnswer: 0
|
|
181
|
-
}
|
|
182
|
-
]
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
name: "Math Quiz",
|
|
187
|
-
args: {
|
|
188
|
-
title: "Math Challenge",
|
|
189
|
-
questions: [
|
|
190
|
-
{
|
|
191
|
-
question: "What is 15 x 15?",
|
|
192
|
-
choices: ["200", "215", "225", "250"],
|
|
193
|
-
correctAnswer: 2
|
|
194
|
-
},
|
|
195
|
-
{
|
|
196
|
-
question: "What is the square root of 144?",
|
|
197
|
-
choices: ["10", "11", "12", "13"],
|
|
198
|
-
correctAnswer: 2
|
|
199
|
-
}
|
|
200
|
-
]
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
{
|
|
204
|
-
name: "No Correct Answer",
|
|
205
|
-
args: {
|
|
206
|
-
title: "Opinion Poll",
|
|
207
|
-
questions: [
|
|
208
|
-
{
|
|
209
|
-
question: "What is your favorite color?",
|
|
210
|
-
choices: ["Red", "Blue", "Green", "Yellow"]
|
|
211
|
-
},
|
|
212
|
-
{
|
|
213
|
-
question: "Which season do you prefer?",
|
|
214
|
-
choices: ["Spring", "Summer", "Autumn", "Winter"]
|
|
215
|
-
}
|
|
216
|
-
]
|
|
217
|
-
}
|
|
218
|
-
},
|
|
219
|
-
{
|
|
220
|
-
name: "Single Question",
|
|
221
|
-
args: {
|
|
222
|
-
title: "Quick Question",
|
|
223
|
-
questions: [
|
|
224
|
-
{
|
|
225
|
-
question: "Is this quiz plugin working correctly?",
|
|
226
|
-
choices: ["Yes", "No"],
|
|
227
|
-
correctAnswer: 0
|
|
228
|
-
}
|
|
229
|
-
]
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
], oe = {
|
|
233
|
-
type: "function",
|
|
234
|
-
name: te,
|
|
235
|
-
description: "Present a set of multiple choice questions to test the user's knowledge or abilities. Each question should have 2-6 answer choices.",
|
|
236
|
-
parameters: {
|
|
237
|
-
type: "object",
|
|
238
|
-
properties: {
|
|
239
|
-
title: {
|
|
240
|
-
type: "string",
|
|
241
|
-
description: "Optional title for the quiz (e.g., 'JavaScript Basics Quiz')"
|
|
242
|
-
},
|
|
243
|
-
questions: {
|
|
244
|
-
type: "array",
|
|
245
|
-
description: "Array of multiple choice questions",
|
|
246
|
-
items: {
|
|
247
|
-
type: "object",
|
|
248
|
-
properties: {
|
|
249
|
-
question: {
|
|
250
|
-
type: "string",
|
|
251
|
-
description: "The question text"
|
|
252
|
-
},
|
|
253
|
-
choices: {
|
|
254
|
-
type: "array",
|
|
255
|
-
description: "Array of answer choices (2-6 choices)",
|
|
256
|
-
items: {
|
|
257
|
-
type: "string"
|
|
258
|
-
},
|
|
259
|
-
minItems: 2,
|
|
260
|
-
maxItems: 6
|
|
261
|
-
},
|
|
262
|
-
correctAnswer: {
|
|
263
|
-
type: "number",
|
|
264
|
-
description: "Optional: The index of the correct answer (0-based). Include this if you want to track correct answers."
|
|
265
|
-
}
|
|
266
|
-
},
|
|
267
|
-
required: ["question", "choices"]
|
|
268
|
-
},
|
|
269
|
-
minItems: 1
|
|
270
|
-
}
|
|
271
|
-
},
|
|
272
|
-
required: ["questions"]
|
|
273
|
-
}
|
|
274
|
-
}, ne = async (g, p) => {
|
|
275
|
-
try {
|
|
276
|
-
const { title: e, questions: c } = p;
|
|
277
|
-
if (!c || !Array.isArray(c) || c.length === 0)
|
|
278
|
-
throw new Error("At least one question is required");
|
|
279
|
-
for (let t = 0; t < c.length; t++) {
|
|
280
|
-
const l = c[t];
|
|
281
|
-
if (!l.question || typeof l.question != "string")
|
|
282
|
-
throw new Error(`Question ${t + 1} must have a question text`);
|
|
283
|
-
if (!Array.isArray(l.choices) || l.choices.length < 2)
|
|
284
|
-
throw new Error(`Question ${t + 1} must have at least 2 choices`);
|
|
285
|
-
if (l.choices.length > 6)
|
|
286
|
-
throw new Error(`Question ${t + 1} cannot have more than 6 choices`);
|
|
287
|
-
}
|
|
288
|
-
const o = {
|
|
289
|
-
title: e,
|
|
290
|
-
questions: c
|
|
291
|
-
};
|
|
292
|
-
return {
|
|
293
|
-
message: `Quiz presented with ${c.length} question${c.length > 1 ? "s" : ""}`,
|
|
294
|
-
jsonData: o,
|
|
295
|
-
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."
|
|
296
|
-
};
|
|
297
|
-
} catch (e) {
|
|
298
|
-
return console.error("Quiz creation error", e), {
|
|
299
|
-
message: `Quiz error: ${e instanceof Error ? e.message : "Unknown error"}`,
|
|
300
|
-
instructions: "Acknowledge that there was an error creating the quiz and suggest trying again."
|
|
301
|
-
};
|
|
302
|
-
}
|
|
303
|
-
}, ie = {
|
|
304
|
-
toolDefinition: oe,
|
|
305
|
-
execute: ne,
|
|
306
|
-
generatingMessage: "Preparing quiz...",
|
|
307
|
-
isEnabled: () => !0,
|
|
308
|
-
viewComponent: H,
|
|
309
|
-
previewComponent: ee,
|
|
310
|
-
samples: se
|
|
311
|
-
}, ae = { plugin: ie };
|
|
1
|
+
import { SAMPLES as O, TOOL_DEFINITION as o, TOOL_NAME as r, pluginCore as i, executeQuiz as l, pluginCore as p } from "./core.js";
|
|
312
2
|
export {
|
|
313
|
-
|
|
3
|
+
O as SAMPLES,
|
|
4
|
+
o as TOOL_DEFINITION,
|
|
5
|
+
r as TOOL_NAME,
|
|
6
|
+
i as default,
|
|
7
|
+
l as executeQuiz,
|
|
8
|
+
p as pluginCore
|
|
314
9
|
};
|
package/dist/style.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-border-style:solid;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-duration:initial}}}@layer theme{:root,:host{--font-sans:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";--font-mono:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;--color-red-600:oklch(57.7% .245 27.325);--color-emerald-50:oklch(97.9% .021 166.113);--color-emerald-100:oklch(95% .052 163.051);--color-emerald-200:oklch(90.5% .093 164.15);--color-emerald-800:oklch(43.2% .095 166.913);--color-blue-50:oklch(97% .014 254.604);--color-blue-400:oklch(70.7% .165 254.624);--color-blue-500:oklch(62.3% .214 259.815);--color-blue-600:oklch(54.6% .245 262.881);--color-blue-700:oklch(48.8% .243 264.376);--color-indigo-100:oklch(93% .034 272.788);--color-indigo-200:oklch(87% .065 274.039);--color-indigo-300:oklch(78.5% .115 274.713);--color-indigo-500:oklch(58.5% .233 277.117);--color-indigo-600:oklch(51.1% .262 276.966);--color-indigo-700:oklch(45.7% .24 277.023);--color-gray-50:oklch(98.5% .002 247.839);--color-gray-100:oklch(96.7% .003 264.542);--color-gray-200:oklch(92.8% .006 264.531);--color-gray-300:oklch(87.2% .01 258.338);--color-gray-400:oklch(70.7% .022 261.325);--color-gray-500:oklch(55.1% .027 264.364);--color-gray-600:oklch(44.6% .03 256.802);--color-gray-800:oklch(27.8% .033 256.848);--color-white:#fff;--spacing:.25rem;--container-3xl:48rem;--text-xs:.75rem;--text-xs--line-height:calc(1/.75);--text-sm:.875rem;--text-sm--line-height:calc(1.25/.875);--text-lg:1.125rem;--text-lg--line-height:calc(1.75/1.125);--text-xl:1.25rem;--text-xl--line-height:calc(1.75/1.25);--text-3xl:1.875rem;--text-3xl--line-height: 1.2 ;--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--radius-md:.375rem;--radius-lg:.5rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4,0,.2,1);--default-font-family:var(--font-sans);--default-mono-font-family:var(--font-mono)}}@layer base{*,:after,:before,::backdrop{box-sizing:border-box;border:0 solid;margin:0;padding:0}::file-selector-button{box-sizing:border-box;border:0 solid;margin:0;padding:0}html,:host{-webkit-text-size-adjust:100%;tab-size:4;line-height:1.5;font-family:var(--default-font-family,ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji");font-feature-settings:var(--default-font-feature-settings,normal);font-variation-settings:var(--default-font-variation-settings,normal);-webkit-tap-highlight-color:transparent}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;-webkit-text-decoration:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:var(--default-mono-font-family,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace);font-feature-settings:var(--default-mono-font-feature-settings,normal);font-variation-settings:var(--default-mono-font-variation-settings,normal);font-size:1em}small{font-size:80%}sub,sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}:-moz-focusring{outline:auto}progress{vertical-align:baseline}summary{display:list-item}ol,ul,menu{list-style:none}img,svg,video,canvas,audio,iframe,embed,object{vertical-align:middle;display:block}img,video{max-width:100%;height:auto}button,input,select,optgroup,textarea{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}::file-selector-button{font:inherit;font-feature-settings:inherit;font-variation-settings:inherit;letter-spacing:inherit;color:inherit;opacity:1;background-color:#0000;border-radius:0}:where(select:is([multiple],[size])) optgroup{font-weight:bolder}:where(select:is([multiple],[size])) optgroup option{padding-inline-start:20px}::file-selector-button{margin-inline-end:4px}::placeholder{opacity:1}@supports (not ((-webkit-appearance:-apple-pay-button))) or (contain-intrinsic-size:1px){::placeholder{color:currentColor}@supports (color:color-mix(in lab,red,red)){::placeholder{color:color-mix(in oklab,currentcolor 50%,transparent)}}}textarea{resize:vertical}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-date-and-time-value{min-height:1lh;text-align:inherit}::-webkit-datetime-edit{display:inline-flex}::-webkit-datetime-edit-fields-wrapper{padding:0}::-webkit-datetime-edit{padding-block:0}::-webkit-datetime-edit-year-field{padding-block:0}::-webkit-datetime-edit-month-field{padding-block:0}::-webkit-datetime-edit-day-field{padding-block:0}::-webkit-datetime-edit-hour-field{padding-block:0}::-webkit-datetime-edit-minute-field{padding-block:0}::-webkit-datetime-edit-second-field{padding-block:0}::-webkit-datetime-edit-millisecond-field{padding-block:0}::-webkit-datetime-edit-meridiem-field{padding-block:0}::-webkit-calendar-picker-indicator{line-height:1}:-moz-ui-invalid{box-shadow:none}button,input:where([type=button],[type=reset],[type=submit]){appearance:button}::file-selector-button{appearance:button}::-webkit-inner-spin-button{height:auto}::-webkit-outer-spin-button{height:auto}[hidden]:where(:not([hidden=until-found])){display:none!important}}@layer components;@layer utilities{.static{position:static}.m-0{margin:calc(var(--spacing)*0)}.mx-auto{margin-inline:auto}.mt-1{margin-top:calc(var(--spacing)*1)}.mt-3{margin-top:calc(var(--spacing)*3)}.mt-4{margin-top:calc(var(--spacing)*4)}.mt-8{margin-top:calc(var(--spacing)*8)}.mr-2{margin-right:calc(var(--spacing)*2)}.mr-3{margin-right:calc(var(--spacing)*3)}.mb-2{margin-bottom:calc(var(--spacing)*2)}.mb-3{margin-bottom:calc(var(--spacing)*3)}.mb-4{margin-bottom:calc(var(--spacing)*4)}.mb-5{margin-bottom:calc(var(--spacing)*5)}.mb-8{margin-bottom:calc(var(--spacing)*8)}.line-clamp-2{-webkit-line-clamp:2;-webkit-box-orient:vertical;display:-webkit-box;overflow:hidden}.block{display:block}.contents{display:contents}.flex{display:flex}.inline-block{display:inline-block}.size-2{width:calc(var(--spacing)*2);height:calc(var(--spacing)*2)}.size-4{width:calc(var(--spacing)*4);height:calc(var(--spacing)*4)}.size-full{width:100%;height:100%}.h-32{height:calc(var(--spacing)*32)}.h-full{height:100%}.w-full{width:100%}.max-w-3xl{max-width:var(--container-3xl)}.max-w-\[200px\]{max-width:200px}.flex-1{flex:1}.shrink-0{flex-shrink:0}.cursor-not-allowed{cursor:not-allowed}.cursor-pointer{cursor:pointer}.resize-y{resize:vertical}.flex-col{flex-direction:column}.flex-wrap{flex-wrap:wrap}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-center{justify-content:center}.gap-1{gap:calc(var(--spacing)*1)}.gap-2{gap:calc(var(--spacing)*2)}.gap-3{gap:calc(var(--spacing)*3)}.gap-6{gap:calc(var(--spacing)*6)}.overflow-hidden{overflow:hidden}.overflow-x-auto{overflow-x:auto}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-lg{border-radius:var(--radius-lg)}.rounded-md{border-radius:var(--radius-md)}.border{border-style:var(--tw-border-style);border-width:1px}.border-2{border-style:var(--tw-border-style);border-width:2px}.border-none{--tw-border-style:none;border-style:none}.border-\[\#3d3d5c\]{border-color:#3d3d5c}.border-\[\#4b4b6b\]{border-color:#4b4b6b}.border-blue-500{border-color:var(--color-blue-500)}.border-emerald-200{border-color:var(--color-emerald-200)}.border-gray-200{border-color:var(--color-gray-200)}.border-gray-300{border-color:var(--color-gray-300)}.border-indigo-200{border-color:var(--color-indigo-200)}.bg-\[\#1a1a2e\]{background-color:#1a1a2e}.bg-\[\#2d2d44\]{background-color:#2d2d44}.bg-blue-50{background-color:var(--color-blue-50)}.bg-blue-500\/20{background-color:#3080ff33}@supports (color:color-mix(in lab,red,red)){.bg-blue-500\/20{background-color:color-mix(in oklab,var(--color-blue-500)20%,transparent)}}.bg-blue-600{background-color:var(--color-blue-600)}.bg-emerald-50{background-color:var(--color-emerald-50)}.bg-emerald-100{background-color:var(--color-emerald-100)}.bg-gray-50{background-color:var(--color-gray-50)}.bg-gray-100{background-color:var(--color-gray-100)}.bg-gray-200{background-color:var(--color-gray-200)}.bg-gray-400{background-color:var(--color-gray-400)}.bg-gray-600{background-color:var(--color-gray-600)}.bg-indigo-100{background-color:var(--color-indigo-100)}.bg-indigo-600{background-color:var(--color-indigo-600)}.bg-white{background-color:var(--color-white)}.p-3{padding:calc(var(--spacing)*3)}.p-4{padding:calc(var(--spacing)*4)}.p-5{padding:calc(var(--spacing)*5)}.p-6{padding:calc(var(--spacing)*6)}.p-8{padding:calc(var(--spacing)*8)}.px-3{padding-inline:calc(var(--spacing)*3)}.px-4{padding-inline:calc(var(--spacing)*4)}.px-6{padding-inline:calc(var(--spacing)*6)}.px-8{padding-inline:calc(var(--spacing)*8)}.py-1{padding-block:calc(var(--spacing)*1)}.py-2{padding-block:calc(var(--spacing)*2)}.py-2\.5{padding-block:calc(var(--spacing)*2.5)}.py-3{padding-block:calc(var(--spacing)*3)}.text-center{text-align:center}.font-mono{font-family:var(--font-mono)}.text-3xl{font-size:var(--text-3xl);line-height:var(--tw-leading,var(--text-3xl--line-height))}.text-lg{font-size:var(--text-lg);line-height:var(--tw-leading,var(--text-lg--line-height))}.text-sm{font-size:var(--text-sm);line-height:var(--tw-leading,var(--text-sm--line-height))}.text-xl{font-size:var(--text-xl);line-height:var(--tw-leading,var(--text-xl--line-height))}.text-xs{font-size:var(--text-xs);line-height:var(--tw-leading,var(--text-xs--line-height))}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.whitespace-pre-wrap{white-space:pre-wrap}.text-\[\#f0f0f0\]{color:#f0f0f0}.text-blue-400{color:var(--color-blue-400)}.text-emerald-800{color:var(--color-emerald-800)}.text-gray-400{color:var(--color-gray-400)}.text-gray-500{color:var(--color-gray-500)}.text-gray-600{color:var(--color-gray-600)}.text-gray-800{color:var(--color-gray-800)}.text-indigo-700{color:var(--color-indigo-700)}.text-red-600{color:var(--color-red-600)}.text-white{color:var(--color-white)}.opacity-50{opacity:.5}.shadow-md{--tw-shadow:0 4px 6px -1px var(--tw-shadow-color,#0000001a),0 2px 4px -2px var(--tw-shadow-color,#0000001a);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.transition-all{transition-property:all;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-200{--tw-duration:.2s;transition-duration:.2s}@media(hover:hover){.hover\:border-\[\#6b6b8b\]:hover{border-color:#6b6b8b}.hover\:border-indigo-300:hover{border-color:var(--color-indigo-300)}.hover\:bg-\[\#6b6b8b\]\/20:hover{background-color:#6b6b8b33}.hover\:bg-blue-700:hover{background-color:var(--color-blue-700)}.hover\:bg-indigo-200:hover{background-color:var(--color-indigo-200)}.hover\:bg-indigo-700:hover{background-color:var(--color-indigo-700)}}.focus\:border-indigo-500:focus{border-color:var(--color-indigo-500)}.focus\:ring-\[3px\]:focus{--tw-ring-shadow:var(--tw-ring-inset,)0 0 0 calc(3px + var(--tw-ring-offset-width))var(--tw-ring-color,currentcolor);box-shadow:var(--tw-inset-shadow),var(--tw-inset-ring-shadow),var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow)}.focus\:ring-indigo-500\/10:focus{--tw-ring-color:#625fff1a}@supports (color:color-mix(in lab,red,red)){.focus\:ring-indigo-500\/10:focus{--tw-ring-color:color-mix(in oklab,var(--color-indigo-500)10%,transparent)}}.focus\:outline-none:focus{--tw-outline-style:none;outline-style:none}}body{margin:calc(var(--spacing)*0);background-color:var(--color-gray-100);padding:calc(var(--spacing)*5);font-family:var(--font-sans)}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-duration{syntax:"*";inherits:false}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MulmoChat Quiz Plugin - Vue Implementation
|
|
3
|
+
*
|
|
4
|
+
* Full Vue plugin with UI components.
|
|
5
|
+
* Import from "@mulmochat-plugin/quiz/vue"
|
|
6
|
+
*/
|
|
7
|
+
import "../style.css";
|
|
8
|
+
import type { ToolPlugin, QuizData, QuizArgs } from "./types";
|
|
9
|
+
import View from "./View.vue";
|
|
10
|
+
import Preview from "./Preview.vue";
|
|
11
|
+
/**
|
|
12
|
+
* Quiz plugin instance with Vue components
|
|
13
|
+
*/
|
|
14
|
+
export declare const plugin: ToolPlugin<never, QuizData, QuizArgs>;
|
|
15
|
+
export type { ToolPlugin, ToolPluginConfig } from "./types";
|
|
16
|
+
export type { BackendType, ToolContextApp, ToolContext, ToolResult, ToolResultComplete, JsonSchemaProperty, ToolDefinition, StartApiResponse, ToolSample, InputHandler, FileUploadConfig, ConfigValue, ConfigFieldSchema, PluginConfigSchema, ViewComponentProps, PreviewComponentProps, ToolPluginCore, QuizQuestion, QuizData, QuizArgs, } from "./types";
|
|
17
|
+
export { TOOL_NAME, TOOL_DEFINITION, SAMPLES, executeQuiz, pluginCore } from "../core/plugin";
|
|
18
|
+
export { View, Preview };
|
|
19
|
+
declare const _default: {
|
|
20
|
+
plugin: ToolPlugin<never, QuizData, QuizArgs>;
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MulmoChat Plugin Vue Types
|
|
3
|
+
*
|
|
4
|
+
* Vue-specific types that extend the core plugin interface.
|
|
5
|
+
*/
|
|
6
|
+
import type { Component } from "vue";
|
|
7
|
+
import type { ToolPluginCore } from "../core/types";
|
|
8
|
+
type VueComponent = Component<any>;
|
|
9
|
+
/**
|
|
10
|
+
* Legacy Vue component-based config
|
|
11
|
+
* @deprecated Use PluginConfigSchema instead
|
|
12
|
+
*/
|
|
13
|
+
export interface ToolPluginConfig {
|
|
14
|
+
key: string;
|
|
15
|
+
defaultValue: unknown;
|
|
16
|
+
component: VueComponent;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Vue plugin interface - extends core with Vue components
|
|
20
|
+
*/
|
|
21
|
+
export interface ToolPlugin<T = unknown, J = unknown, A extends object = object> extends ToolPluginCore<T, J, A> {
|
|
22
|
+
/** Vue component for full view */
|
|
23
|
+
viewComponent?: VueComponent;
|
|
24
|
+
/** Vue component for preview/thumbnail */
|
|
25
|
+
previewComponent?: VueComponent;
|
|
26
|
+
/**
|
|
27
|
+
* Legacy Vue component-based config (for backward compatibility)
|
|
28
|
+
* @deprecated Use configSchema instead
|
|
29
|
+
*/
|
|
30
|
+
config?: ToolPluginConfig;
|
|
31
|
+
}
|
|
32
|
+
export type { BackendType, ToolContextApp, ToolContext, ToolResult, ToolResultComplete, JsonSchemaProperty, ToolDefinition, StartApiResponse, ToolSample, InputHandler, FileInputHandler, ClipboardImageInputHandler, UrlInputHandler, TextInputHandler, FileUploadConfig, ConfigValue, ConfigFieldSchema, PluginConfigSchema, ViewComponentProps, PreviewComponentProps, ToolPluginCore, QuizQuestion, QuizData, QuizArgs, } from "../core/types";
|
package/dist/vue.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a=require("./core.cjs"),e=require("vue"),k={class:"size-full overflow-y-auto p-8 bg-[#1a1a2e]"},E={key:0,class:"max-w-3xl w-full mx-auto"},N={key:0,class:"text-[#f0f0f0] text-3xl font-bold mb-8 text-center"},S={class:"flex flex-col gap-6"},w={class:"text-white text-lg font-semibold mb-4"},V={class:"text-blue-400 mr-2"},B={class:"flex flex-col gap-3"},C=["name","value","onUpdate:modelValue"],D={class:"text-white flex-1"},T={class:"font-semibold mr-2"},q={class:"mt-8 flex justify-center"},$=["disabled"],O={class:"mt-4 text-center text-gray-400 text-sm"},h=e.defineComponent({__name:"View",props:{selectedResult:{},sendTextMessage:{type:Function}},emits:["updateResult"],setup(d,{emit:m}){const o=d,_=m,s=e.ref(null),l=e.ref([]);e.watch(()=>o.selectedResult,t=>{t?.toolName===a.TOOL_NAME&&t.jsonData&&(s.value=t.jsonData,t.viewState?.userAnswers?l.value=t.viewState.userAnswers:l.value=new Array(s.value.questions.length).fill(null))},{immediate:!0}),e.watch(l,t=>{if(o.selectedResult&&t){const i={...o.selectedResult,viewState:{userAnswers:t}};_("updateResult",i)}},{deep:!0});const u=e.computed(()=>l.value.filter(t=>t!==null).length),p=e.computed(()=>s.value&&u.value===s.value.questions.length);function x(t,i){return l.value[t]===i?"border-blue-500 bg-blue-500/20":"border-[#4b4b6b] hover:border-[#6b6b8b] hover:bg-[#6b6b8b]/20"}function y(){if(!s.value||!p.value)return;const i=`Here are my answers:
|
|
2
|
+
${l.value.map((n,r)=>{if(n===null)return null;const v=r+1,c=String.fromCharCode(65+n),g=s.value.questions[r].choices[n];return`Q${v}: ${c} - ${g}`}).filter(n=>n!==null).join(`
|
|
3
|
+
`)}`;o.sendTextMessage(i)}return(t,i)=>(e.openBlock(),e.createElementBlock("div",k,[s.value?(e.openBlock(),e.createElementBlock("div",E,[s.value.title?(e.openBlock(),e.createElementBlock("h2",N,e.toDisplayString(s.value.title),1)):e.createCommentVNode("",!0),e.createElementVNode("div",S,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value.questions,(n,r)=>(e.openBlock(),e.createElementBlock("div",{key:r,class:"bg-[#2d2d44] rounded-lg p-6 border-2 border-[#3d3d5c]"},[e.createElementVNode("div",w,[e.createElementVNode("span",V,e.toDisplayString(r+1)+".",1),e.createTextVNode(" "+e.toDisplayString(n.question),1)]),e.createElementVNode("div",B,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.choices,(v,c)=>(e.openBlock(),e.createElementBlock("label",{key:c,class:e.normalizeClass([x(r,c),"flex items-start p-4 rounded-lg cursor-pointer transition-all duration-200 border-2"])},[e.withDirectives(e.createElementVNode("input",{type:"radio",name:`question-${r}`,value:c,"onUpdate:modelValue":g=>l.value[r]=g,class:"mt-1 mr-3 size-4 shrink-0"},null,8,C),[[e.vModelRadio,l.value[r]]]),e.createElementVNode("span",D,[e.createElementVNode("span",T,e.toDisplayString(String.fromCharCode(65+c))+".",1),e.createTextVNode(" "+e.toDisplayString(v),1)])],2))),128))])]))),128))]),e.createElementVNode("div",q,[e.createElementVNode("button",{onClick:y,disabled:!p.value,class:e.normalizeClass([p.value?"bg-blue-600 hover:bg-blue-700":"bg-gray-600 cursor-not-allowed opacity-50","py-3 px-8 rounded-lg text-white font-semibold text-lg transition-colors border-none cursor-pointer"])}," Submit Answers ",10,$)]),e.createElementVNode("div",O,e.toDisplayString(u.value)+" / "+e.toDisplayString(s.value.questions.length)+" questions answered ",1)])):e.createCommentVNode("",!0)]))}}),A={class:"p-3 bg-blue-50 rounded-md"},L={key:0,class:"flex flex-col gap-2"},M={class:"text-sm font-semibold text-gray-800 text-center"},z={class:"text-center"},j={class:"inline-block bg-blue-600 text-white text-xs font-bold py-1 px-3 rounded-full"},Q={class:"text-xs text-gray-600 overflow-hidden line-clamp-2"},F={class:"flex justify-center gap-1"},P={key:0,class:"text-xs text-gray-500"},b=e.defineComponent({__name:"Preview",props:{result:{}},setup(d){const m=d,o=e.computed(()=>m.result.jsonData);return(_,s)=>(e.openBlock(),e.createElementBlock("div",A,[o.value?(e.openBlock(),e.createElementBlock("div",L,[e.createElementVNode("div",M,e.toDisplayString(o.value.title||"Quiz"),1),e.createElementVNode("div",z,[e.createElementVNode("span",j,e.toDisplayString(o.value.questions.length)+" "+e.toDisplayString(o.value.questions.length===1?"Question":"Questions"),1)]),e.createElementVNode("div",Q,e.toDisplayString(o.value.questions[0]?.question),1),e.createElementVNode("div",F,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Math.min(o.value.questions[0]?.choices.length||0,4),(l,u)=>(e.openBlock(),e.createElementBlock("div",{key:u,class:"size-2 bg-gray-400 rounded-full"}))),128)),(o.value.questions[0]?.choices.length||0)>4?(e.openBlock(),e.createElementBlock("div",P," +"+e.toDisplayString(o.value.questions[0].choices.length-4),1)):e.createCommentVNode("",!0)])])):e.createCommentVNode("",!0)]))}}),f={...a.pluginCore,viewComponent:h,previewComponent:b},R={plugin:f};exports.SAMPLES=a.SAMPLES;exports.TOOL_DEFINITION=a.TOOL_DEFINITION;exports.TOOL_NAME=a.TOOL_NAME;exports.executeQuiz=a.executeQuiz;exports.pluginCore=a.pluginCore;exports.Preview=b;exports.View=h;exports.default=R;exports.plugin=f;
|
package/dist/vue.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { TOOL_NAME as A, pluginCore as D } from "./core.js";
|
|
2
|
+
import { SAMPLES as ue, TOOL_DEFINITION as ce, executeQuiz as de } from "./core.js";
|
|
3
|
+
import { defineComponent as S, ref as C, watch as $, computed as g, createElementBlock as l, openBlock as n, createCommentVNode as m, createElementVNode as e, toDisplayString as i, Fragment as x, renderList as w, createTextVNode as k, normalizeClass as q, withDirectives as N, vModelRadio as V } from "vue";
|
|
4
|
+
const j = { class: "size-full overflow-y-auto p-8 bg-[#1a1a2e]" }, M = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "max-w-3xl w-full mx-auto"
|
|
7
|
+
}, Q = {
|
|
8
|
+
key: 0,
|
|
9
|
+
class: "text-[#f0f0f0] text-3xl font-bold mb-8 text-center"
|
|
10
|
+
}, E = { class: "flex flex-col gap-6" }, L = { class: "text-white text-lg font-semibold mb-4" }, O = { class: "text-blue-400 mr-2" }, R = { class: "flex flex-col gap-3" }, F = ["name", "value", "onUpdate:modelValue"], P = { class: "text-white flex-1" }, B = { class: "font-semibold mr-2" }, U = { class: "mt-8 flex justify-center" }, H = ["disabled"], G = { class: "mt-4 text-center text-gray-400 text-sm" }, J = /* @__PURE__ */ S({
|
|
11
|
+
__name: "View",
|
|
12
|
+
props: {
|
|
13
|
+
selectedResult: {},
|
|
14
|
+
sendTextMessage: { type: Function }
|
|
15
|
+
},
|
|
16
|
+
emits: ["updateResult"],
|
|
17
|
+
setup(_, { emit: h }) {
|
|
18
|
+
const s = _, y = h, o = C(null), a = C([]);
|
|
19
|
+
$(
|
|
20
|
+
() => s.selectedResult,
|
|
21
|
+
(t) => {
|
|
22
|
+
t?.toolName === A && t.jsonData && (o.value = t.jsonData, t.viewState?.userAnswers ? a.value = t.viewState.userAnswers : a.value = new Array(o.value.questions.length).fill(null));
|
|
23
|
+
},
|
|
24
|
+
{ immediate: !0 }
|
|
25
|
+
), $(
|
|
26
|
+
a,
|
|
27
|
+
(t) => {
|
|
28
|
+
if (s.selectedResult && t) {
|
|
29
|
+
const c = {
|
|
30
|
+
...s.selectedResult,
|
|
31
|
+
viewState: {
|
|
32
|
+
userAnswers: t
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
y("updateResult", c);
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{ deep: !0 }
|
|
39
|
+
);
|
|
40
|
+
const v = g(() => a.value.filter((t) => t !== null).length), p = g(() => o.value && v.value === o.value.questions.length);
|
|
41
|
+
function T(t, c) {
|
|
42
|
+
return a.value[t] === c ? "border-blue-500 bg-blue-500/20" : "border-[#4b4b6b] hover:border-[#6b6b8b] hover:bg-[#6b6b8b]/20";
|
|
43
|
+
}
|
|
44
|
+
function z() {
|
|
45
|
+
if (!o.value || !p.value) return;
|
|
46
|
+
const c = `Here are my answers:
|
|
47
|
+
${a.value.map((r, u) => {
|
|
48
|
+
if (r === null) return null;
|
|
49
|
+
const b = u + 1, d = String.fromCharCode(65 + r), f = o.value.questions[u].choices[r];
|
|
50
|
+
return `Q${b}: ${d} - ${f}`;
|
|
51
|
+
}).filter((r) => r !== null).join(`
|
|
52
|
+
`)}`;
|
|
53
|
+
s.sendTextMessage(c);
|
|
54
|
+
}
|
|
55
|
+
return (t, c) => (n(), l("div", j, [
|
|
56
|
+
o.value ? (n(), l("div", M, [
|
|
57
|
+
o.value.title ? (n(), l("h2", Q, i(o.value.title), 1)) : m("", !0),
|
|
58
|
+
e("div", E, [
|
|
59
|
+
(n(!0), l(x, null, w(o.value.questions, (r, u) => (n(), l("div", {
|
|
60
|
+
key: u,
|
|
61
|
+
class: "bg-[#2d2d44] rounded-lg p-6 border-2 border-[#3d3d5c]"
|
|
62
|
+
}, [
|
|
63
|
+
e("div", L, [
|
|
64
|
+
e("span", O, i(u + 1) + ".", 1),
|
|
65
|
+
k(" " + i(r.question), 1)
|
|
66
|
+
]),
|
|
67
|
+
e("div", R, [
|
|
68
|
+
(n(!0), l(x, null, w(r.choices, (b, d) => (n(), l("label", {
|
|
69
|
+
key: d,
|
|
70
|
+
class: q([T(u, d), "flex items-start p-4 rounded-lg cursor-pointer transition-all duration-200 border-2"])
|
|
71
|
+
}, [
|
|
72
|
+
N(e("input", {
|
|
73
|
+
type: "radio",
|
|
74
|
+
name: `question-${u}`,
|
|
75
|
+
value: d,
|
|
76
|
+
"onUpdate:modelValue": (f) => a.value[u] = f,
|
|
77
|
+
class: "mt-1 mr-3 size-4 shrink-0"
|
|
78
|
+
}, null, 8, F), [
|
|
79
|
+
[V, a.value[u]]
|
|
80
|
+
]),
|
|
81
|
+
e("span", P, [
|
|
82
|
+
e("span", B, i(String.fromCharCode(65 + d)) + ".", 1),
|
|
83
|
+
k(" " + i(b), 1)
|
|
84
|
+
])
|
|
85
|
+
], 2))), 128))
|
|
86
|
+
])
|
|
87
|
+
]))), 128))
|
|
88
|
+
]),
|
|
89
|
+
e("div", U, [
|
|
90
|
+
e("button", {
|
|
91
|
+
onClick: z,
|
|
92
|
+
disabled: !p.value,
|
|
93
|
+
class: q([p.value ? "bg-blue-600 hover:bg-blue-700" : "bg-gray-600 cursor-not-allowed opacity-50", "py-3 px-8 rounded-lg text-white font-semibold text-lg transition-colors border-none cursor-pointer"])
|
|
94
|
+
}, " Submit Answers ", 10, H)
|
|
95
|
+
]),
|
|
96
|
+
e("div", G, i(v.value) + " / " + i(o.value.questions.length) + " questions answered ", 1)
|
|
97
|
+
])) : m("", !0)
|
|
98
|
+
]));
|
|
99
|
+
}
|
|
100
|
+
}), K = { class: "p-3 bg-blue-50 rounded-md" }, W = {
|
|
101
|
+
key: 0,
|
|
102
|
+
class: "flex flex-col gap-2"
|
|
103
|
+
}, X = { class: "text-sm font-semibold text-gray-800 text-center" }, Y = { class: "text-center" }, Z = { class: "inline-block bg-blue-600 text-white text-xs font-bold py-1 px-3 rounded-full" }, I = { class: "text-xs text-gray-600 overflow-hidden line-clamp-2" }, ee = { class: "flex justify-center gap-1" }, te = {
|
|
104
|
+
key: 0,
|
|
105
|
+
class: "text-xs text-gray-500"
|
|
106
|
+
}, se = /* @__PURE__ */ S({
|
|
107
|
+
__name: "Preview",
|
|
108
|
+
props: {
|
|
109
|
+
result: {}
|
|
110
|
+
},
|
|
111
|
+
setup(_) {
|
|
112
|
+
const h = _, s = g(() => h.result.jsonData);
|
|
113
|
+
return (y, o) => (n(), l("div", K, [
|
|
114
|
+
s.value ? (n(), l("div", W, [
|
|
115
|
+
e("div", X, i(s.value.title || "Quiz"), 1),
|
|
116
|
+
e("div", Y, [
|
|
117
|
+
e("span", Z, i(s.value.questions.length) + " " + i(s.value.questions.length === 1 ? "Question" : "Questions"), 1)
|
|
118
|
+
]),
|
|
119
|
+
e("div", I, i(s.value.questions[0]?.question), 1),
|
|
120
|
+
e("div", ee, [
|
|
121
|
+
(n(!0), l(x, null, w(Math.min(s.value.questions[0]?.choices.length || 0, 4), (a, v) => (n(), l("div", {
|
|
122
|
+
key: v,
|
|
123
|
+
class: "size-2 bg-gray-400 rounded-full"
|
|
124
|
+
}))), 128)),
|
|
125
|
+
(s.value.questions[0]?.choices.length || 0) > 4 ? (n(), l("div", te, " +" + i(s.value.questions[0].choices.length - 4), 1)) : m("", !0)
|
|
126
|
+
])
|
|
127
|
+
])) : m("", !0)
|
|
128
|
+
]));
|
|
129
|
+
}
|
|
130
|
+
}), oe = {
|
|
131
|
+
...D,
|
|
132
|
+
viewComponent: J,
|
|
133
|
+
previewComponent: se
|
|
134
|
+
}, ie = { plugin: oe };
|
|
135
|
+
export {
|
|
136
|
+
se as Preview,
|
|
137
|
+
ue as SAMPLES,
|
|
138
|
+
ce as TOOL_DEFINITION,
|
|
139
|
+
A as TOOL_NAME,
|
|
140
|
+
J as View,
|
|
141
|
+
ie as default,
|
|
142
|
+
de as executeQuiz,
|
|
143
|
+
oe as plugin,
|
|
144
|
+
D as pluginCore
|
|
145
|
+
};
|