@jcheesepkg/nanobot 0.8.97 → 0.8.99
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/dist/agent/tools/flex.d.mts +7 -0
- package/dist/agent/tools/flex.d.mts.map +1 -1
- package/dist/agent/tools/flex.mjs +10 -0
- package/dist/agent/tools/flex.mjs.map +1 -1
- package/dist/agent/tools/flex.test.mjs +59 -0
- package/dist/agent/tools/flex.test.mjs.map +1 -1
- package/dist/config/schema.d.mts +36 -36
- package/package.json +1 -1
- package/skills/english/SKILL.md +56 -7
- package/skills/skill-creator/SKILL.md +23 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flex.d.mts","names":[],"sources":["../../../src/agent/tools/flex.ts"],"mappings":";;;;;AASA;;;;;cAAa,QAAA,SAAiB,IAAA;EAAA,SACnB,IAAA;EAAA,SACA,WAAA;EAAA,SAEA,UAAA
|
|
1
|
+
{"version":3,"file":"flex.d.mts","names":[],"sources":["../../../src/agent/tools/flex.ts"],"mappings":";;;;;AASA;;;;;cAAa,QAAA,SAAiB,IAAA;EAAA,SACnB,IAAA;EAAA,SACA,WAAA;EAAA,SAEA,UAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiFH,OAAA,CAAQ,IAAA,EAAM,MAAA,oBAA0B,OAAA;EAAA,QAwCtC,YAAA;EAAA,QAgEA,aAAA;EAAA,QA4BA,kBAAA;EAAA,QAwCA,YAAA;EAAA,QA+CA,mBAAA;EAAA,QAiDA,cAAA;EAAA,QAkCA,WAAA;AAAA"}
|
|
@@ -136,6 +136,11 @@ var FlexTool = class extends Tool {
|
|
|
136
136
|
contents: {
|
|
137
137
|
type: "array",
|
|
138
138
|
description: "Raw Flex body contents array for custom template"
|
|
139
|
+
},
|
|
140
|
+
bubbles: {
|
|
141
|
+
type: "array",
|
|
142
|
+
items: { type: "object" },
|
|
143
|
+
description: "Array of bubble objects for a carousel (horizontal swipeable cards). Each item should be a complete bubble with type, body, etc."
|
|
139
144
|
}
|
|
140
145
|
}
|
|
141
146
|
}
|
|
@@ -483,6 +488,11 @@ var FlexTool = class extends Tool {
|
|
|
483
488
|
};
|
|
484
489
|
}
|
|
485
490
|
buildCustom(data) {
|
|
491
|
+
const bubbles = data.bubbles;
|
|
492
|
+
if (Array.isArray(bubbles) && bubbles.length > 0) return {
|
|
493
|
+
type: "carousel",
|
|
494
|
+
contents: bubbles
|
|
495
|
+
};
|
|
486
496
|
const rawContents = data.contents;
|
|
487
497
|
if (Array.isArray(rawContents) && rawContents.length > 0) return {
|
|
488
498
|
type: "bubble",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flex.mjs","names":[],"sources":["../../../src/agent/tools/flex.ts"],"sourcesContent":["import { Tool } from \"./base.js\";\n\n/**\n * Tool for building LINE Flex Messages from structured data.\n *\n * The LLM calls this tool with a template name and data object,\n * and the tool returns valid Flex JSON that line.ts parseMessage()\n * will detect and send as a Flex Message.\n */\nexport class FlexTool extends Tool {\n readonly name = \"flex_message\";\n readonly description =\n \"Build a LINE Flex Message from a template. Returns JSON that will be rendered as a rich card in LINE. Use this instead of outputting raw JSON.\";\n readonly parameters = {\n type: \"object\",\n properties: {\n template: {\n type: \"string\",\n description:\n \"Template name. Available: fortune, info_card, action_buttons, receipt, morning_summary, hydration, custom.\",\n },\n data: {\n type: \"object\",\n description: \"Template-specific data. See each template for fields.\",\n properties: {\n // fortune\n sign: { type: \"string\", description: \"Zodiac sign with emoji (e.g. '♍ 乙女座')\" },\n stars: { type: \"integer\", description: \"1-5 star rating\" },\n message: { type: \"string\", description: \"Fortune message\" },\n lucky_color: { type: \"string\", description: \"Lucky color name\" },\n lucky_item: { type: \"string\", description: \"Lucky item name\" },\n // info_card\n title: { type: \"string\", description: \"Card title\" },\n body: { type: \"string\", description: \"Card body text\" },\n // action_buttons\n prompt: { type: \"string\", description: \"Question or prompt text\" },\n buttons: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n label: { type: \"string\" },\n text: { type: \"string\" },\n style: { type: \"string\", enum: [\"primary\", \"secondary\", \"link\"] },\n },\n },\n description: \"Button definitions\",\n },\n // receipt\n items: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n value: { type: \"string\" },\n },\n },\n description: \"Line items\",\n },\n total: { type: \"string\", description: \"Total amount\" },\n // morning_summary\n greeting: { type: \"string\", description: \"Greeting text (e.g. 'おはよう!')\" },\n date: { type: \"string\", description: \"Date string (e.g. '2月13日 木曜日')\" },\n weather: { type: \"string\", description: \"Weather info (e.g. '東京 12°C 曇り')\" },\n advice: { type: \"string\", description: \"Short advice (e.g. 'コートでOK')\" },\n schedule: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Schedule/reminder lines\",\n },\n header_color: { type: \"string\", description: \"Header background color hex (default: #1DB446)\" },\n // hydration\n current: { type: \"integer\", description: \"Current count (e.g. glasses drunk)\" },\n goal: { type: \"integer\", description: \"Goal count\" },\n unit: { type: \"string\", description: \"Unit label (default: 杯)\" },\n button_label: { type: \"string\", description: \"Button label (default: '飲んだ!')\" },\n button_text: { type: \"string\", description: \"Button message text (default: '水飲んだ')\" },\n // custom\n contents: {\n type: \"array\",\n description: \"Raw Flex body contents array for custom template\",\n },\n },\n },\n },\n required: [\"template\", \"data\"],\n };\n\n async execute(args: Record<string, unknown>): Promise<string> {\n const template = String(args.template);\n const data = (args.data ?? {}) as Record<string, unknown>;\n\n try {\n let flex: Record<string, unknown>;\n\n switch (template) {\n case \"fortune\":\n flex = this.buildFortune(data);\n break;\n case \"info_card\":\n flex = this.buildInfoCard(data);\n break;\n case \"action_buttons\":\n flex = this.buildActionButtons(data);\n break;\n case \"receipt\":\n flex = this.buildReceipt(data);\n break;\n case \"morning_summary\":\n flex = this.buildMorningSummary(data);\n break;\n case \"hydration\":\n flex = this.buildHydration(data);\n break;\n case \"custom\":\n flex = this.buildCustom(data);\n break;\n default:\n return `Error: unknown template '${template}'. Use: fortune, info_card, action_buttons, receipt, morning_summary, hydration, custom.`;\n }\n\n const json = JSON.stringify(flex);\n return `${json}\\n\\n(Card sent automatically. Do NOT repeat the JSON. Just respond naturally.)`;\n } catch (err) {\n return `Error building flex message: ${err instanceof Error ? err.message : err}`;\n }\n }\n\n private buildFortune(data: Record<string, unknown>): Record<string, unknown> {\n const sign = String(data.sign ?? \"♈ 牡羊座\");\n const stars = Math.max(1, Math.min(5, Number(data.stars ?? 3)));\n const message = String(data.message ?? \"\");\n const luckyColor = data.lucky_color ? String(data.lucky_color) : null;\n const luckyItem = data.lucky_item ? String(data.lucky_item) : null;\n\n const starText = \"★\".repeat(stars) + \"☆\".repeat(5 - stars);\n\n const contents: Record<string, unknown>[] = [\n { type: \"text\", text: sign, weight: \"bold\", size: \"xl\" },\n { type: \"text\", text: \"今日の運勢\", size: \"sm\", color: \"#666666\" },\n { type: \"text\", text: starText, size: \"xxl\", margin: \"md\" },\n ];\n\n if (message) {\n contents.push({\n type: \"text\",\n text: message,\n wrap: true,\n margin: \"sm\",\n });\n }\n\n if (luckyColor || luckyItem) {\n contents.push({ type: \"separator\", margin: \"md\" });\n }\n\n if (luckyColor) {\n contents.push({\n type: \"box\",\n layout: \"horizontal\",\n margin: \"md\",\n contents: [\n { type: \"text\", text: \"ラッキーカラー\", size: \"sm\", color: \"#228B22\", flex: 0 },\n { type: \"text\", text: luckyColor, size: \"sm\", align: \"end\" },\n ],\n });\n }\n\n if (luckyItem) {\n contents.push({\n type: \"box\",\n layout: \"horizontal\",\n margin: luckyColor ? \"sm\" : \"md\",\n contents: [\n { type: \"text\", text: \"ラッキーアイテム\", size: \"sm\", color: \"#228B22\", flex: 0 },\n { type: \"text\", text: luckyItem, size: \"sm\", align: \"end\" },\n ],\n });\n }\n\n return {\n type: \"bubble\",\n size: \"kilo\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n paddingAll: \"lg\",\n contents,\n },\n };\n }\n\n private buildInfoCard(data: Record<string, unknown>): Record<string, unknown> {\n const title = String(data.title ?? \"お知らせ\");\n const body = String(data.body ?? \"\");\n\n const contents: Record<string, unknown>[] = [\n { type: \"text\", text: title, weight: \"bold\", size: \"lg\" },\n { type: \"separator\", margin: \"md\" },\n ];\n\n if (body) {\n contents.push({\n type: \"text\",\n text: body,\n wrap: true,\n margin: \"md\",\n });\n }\n\n return {\n type: \"bubble\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n contents,\n },\n };\n }\n\n private buildActionButtons(data: Record<string, unknown>): Record<string, unknown> {\n const prompt = String(data.prompt ?? \"選択してください\");\n const buttons = (data.buttons ?? []) as Array<Record<string, unknown>>;\n\n if (buttons.length === 0) {\n // Default yes/no\n buttons.push(\n { label: \"はい\", text: \"はい\", style: \"primary\" },\n { label: \"いいえ\", text: \"いいえ\", style: \"secondary\" },\n );\n }\n\n const buttonContents = buttons.map((btn) => ({\n type: \"button\",\n style: String(btn.style ?? \"primary\"),\n action: {\n type: \"message\",\n label: String(btn.label ?? \"\"),\n text: String(btn.text ?? btn.label ?? \"\"),\n },\n }));\n\n return {\n type: \"bubble\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n contents: [\n { type: \"text\", text: prompt, weight: \"bold\", wrap: true },\n ],\n },\n footer: {\n type: \"box\",\n layout: \"vertical\",\n spacing: \"sm\",\n contents: buttonContents,\n },\n };\n }\n\n private buildReceipt(data: Record<string, unknown>): Record<string, unknown> {\n const title = String(data.title ?? \"明細\");\n const items = (data.items ?? []) as Array<Record<string, unknown>>;\n const total = data.total ? String(data.total) : null;\n\n const contents: Record<string, unknown>[] = [\n { type: \"text\", text: `💰 ${title}`, weight: \"bold\" },\n { type: \"separator\", margin: \"lg\" },\n ];\n\n for (const item of items) {\n contents.push({\n type: \"box\",\n layout: \"horizontal\",\n margin: \"md\",\n contents: [\n { type: \"text\", text: String(item.name ?? \"\"), flex: 0 },\n { type: \"text\", text: String(item.value ?? \"\"), align: \"end\" },\n ],\n });\n }\n\n if (total) {\n contents.push(\n { type: \"separator\", margin: \"lg\" },\n {\n type: \"box\",\n layout: \"horizontal\",\n margin: \"md\",\n contents: [\n { type: \"text\", text: \"合計\", weight: \"bold\" },\n { type: \"text\", text: total, weight: \"bold\", align: \"end\" },\n ],\n },\n );\n }\n\n return {\n type: \"bubble\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n contents,\n },\n };\n }\n\n private buildMorningSummary(data: Record<string, unknown>): Record<string, unknown> {\n const greeting = String(data.greeting ?? \"おはよう!\");\n const date = String(data.date ?? \"\");\n const weather = data.weather ? String(data.weather) : null;\n const advice = data.advice ? String(data.advice) : null;\n const schedule = (data.schedule ?? []) as string[];\n const headerColor = String(data.header_color ?? \"#1DB446\");\n\n const headerContents: Record<string, unknown>[] = [\n { type: \"text\", text: greeting, color: \"#ffffff\", weight: \"bold\", size: \"lg\" },\n ];\n if (date) {\n headerContents.push({ type: \"text\", text: date, color: \"#ffffff\", size: \"sm\" });\n }\n\n const bodyContents: Record<string, unknown>[] = [];\n\n if (weather) {\n bodyContents.push({ type: \"text\", text: weather, weight: \"bold\" });\n }\n if (advice) {\n bodyContents.push({ type: \"text\", text: advice, size: \"sm\", color: \"#666666\" });\n }\n\n if (schedule.length > 0) {\n bodyContents.push({ type: \"separator\", margin: \"md\" });\n for (const line of schedule) {\n bodyContents.push({ type: \"text\", text: line, margin: \"md\", wrap: true });\n }\n }\n\n return {\n type: \"bubble\",\n header: {\n type: \"box\",\n layout: \"vertical\",\n backgroundColor: headerColor,\n paddingAll: \"lg\",\n contents: headerContents,\n },\n body: {\n type: \"box\",\n layout: \"vertical\",\n paddingAll: \"lg\",\n contents: bodyContents.length > 0 ? bodyContents : [{ type: \"text\", text: \"良い一日を!\" }],\n },\n };\n }\n\n private buildHydration(data: Record<string, unknown>): Record<string, unknown> {\n const title = String(data.title ?? \"水飲んだ?\");\n const current = Number(data.current ?? 0);\n const goal = Number(data.goal ?? 8);\n const unit = String(data.unit ?? \"杯\");\n const buttonLabel = String(data.button_label ?? \"飲んだ!\");\n const buttonText = String(data.button_text ?? \"水飲んだ\");\n\n return {\n type: \"bubble\",\n size: \"kilo\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n contents: [\n { type: \"text\", text: title, size: \"xl\" },\n { type: \"text\", text: `今日: ${current}${unit} / ${goal}${unit}`, color: \"#666666\" },\n ],\n },\n footer: {\n type: \"box\",\n layout: \"horizontal\",\n contents: [\n {\n type: \"button\",\n style: \"primary\",\n color: \"#00B9ED\",\n action: { type: \"message\", label: buttonLabel, text: buttonText },\n },\n ],\n },\n };\n }\n\n private buildCustom(data: Record<string, unknown>): Record<string, unknown> {\n // If raw contents array is provided, use it directly\n const rawContents = data.contents as unknown[];\n if (Array.isArray(rawContents) && rawContents.length > 0) {\n return {\n type: \"bubble\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n contents: rawContents,\n },\n };\n }\n\n // Fallback: auto-build a card from common fields (title, body, buttons, header_color)\n const title = data.title ? String(data.title) : null;\n const body = data.body ? String(data.body) : null;\n let buttons = Array.isArray(data.buttons) ? data.buttons as Array<Record<string, unknown>> : [];\n const headerColor = data.header_color ? String(data.header_color) : null;\n\n // Support flat button_label/button_text shorthand (like hydration template)\n if (buttons.length === 0 && data.button_label) {\n buttons = [{\n label: String(data.button_label),\n text: String(data.button_text ?? data.button_label),\n style: data.button_style ?? \"primary\",\n }];\n }\n\n if (!title && !body && buttons.length === 0) {\n throw new Error(\"custom template requires 'contents' array, or at least one of: title, body, buttons\");\n }\n\n const bodyContents: Record<string, unknown>[] = [];\n\n if (title) {\n bodyContents.push({ type: \"text\", text: title, weight: \"bold\", size: \"lg\" });\n }\n if (body) {\n if (title) bodyContents.push({ type: \"separator\", margin: \"md\" });\n bodyContents.push({ type: \"text\", text: body, wrap: true, margin: title ? \"md\" : undefined });\n }\n\n const bubble: Record<string, unknown> = {\n type: \"bubble\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n contents: bodyContents.length > 0 ? bodyContents : [{ type: \"text\", text: \" \" }],\n },\n };\n\n // Add colored header if specified\n if (headerColor && title) {\n bubble.header = {\n type: \"box\",\n layout: \"vertical\",\n backgroundColor: headerColor,\n paddingAll: \"lg\",\n contents: [\n { type: \"text\", text: title, color: \"#ffffff\", weight: \"bold\", size: \"lg\" },\n ],\n };\n // Remove title from body since it's in the header now\n bodyContents.shift();\n }\n\n // Add buttons as footer\n if (buttons.length > 0) {\n bubble.footer = {\n type: \"box\",\n layout: \"vertical\",\n spacing: \"sm\",\n contents: buttons.map((btn) => ({\n type: \"button\",\n style: String(btn.style ?? \"primary\"),\n action: {\n type: \"message\",\n label: String(btn.label ?? \"\"),\n text: String(btn.text ?? btn.label ?? \"\"),\n },\n })),\n };\n }\n\n return bubble;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAa,WAAb,cAA8B,KAAK;CACjC,AAAS,OAAO;CAChB,AAAS,cACP;CACF,AAAS,aAAa;EACpB,MAAM;EACN,YAAY;GACV,UAAU;IACR,MAAM;IACN,aACE;IACH;GACD,MAAM;IACJ,MAAM;IACN,aAAa;IACb,YAAY;KAEV,MAAM;MAAE,MAAM;MAAU,aAAa;MAAyC;KAC9E,OAAO;MAAE,MAAM;MAAW,aAAa;MAAmB;KAC1D,SAAS;MAAE,MAAM;MAAU,aAAa;MAAmB;KAC3D,aAAa;MAAE,MAAM;MAAU,aAAa;MAAoB;KAChE,YAAY;MAAE,MAAM;MAAU,aAAa;MAAmB;KAE9D,OAAO;MAAE,MAAM;MAAU,aAAa;MAAc;KACpD,MAAM;MAAE,MAAM;MAAU,aAAa;MAAkB;KAEvD,QAAQ;MAAE,MAAM;MAAU,aAAa;MAA2B;KAClE,SAAS;MACP,MAAM;MACN,OAAO;OACL,MAAM;OACN,YAAY;QACV,OAAO,EAAE,MAAM,UAAU;QACzB,MAAM,EAAE,MAAM,UA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,MAAM;IAAa,QAAQ;IAAM,CAAC;AACjE,gBAAa,KAAK;IAAE,MAAM;IAAQ,MAAM;IAAM,MAAM;IAAM,QAAQ,QAAQ,OAAO;IAAW,CAAC;;EAG/F,MAAM,SAAkC;GACtC,MAAM;GACN,MAAM;IACJ,MAAM;IACN,QAAQ;IACR,UAAU,aAAa,SAAS,IAAI,eAAe,CAAC;KAAE,MAAM;KAAQ,MAAM;KAAK,CAAC;IACjF;GACF;AAGD,MAAI,eAAe,OAAO;AACxB,UAAO,SAAS;IACd,MAAM;IACN,QAAQ;IACR,iBAAiB;IACjB,YAAY;IACZ,UAAU,CACR;KAAE,MAAM;KAAQ,MAAM;KAAO,OAAO;KAAW,QAAQ;KAAQ,MAAM;KAAM,CAC5E;IACF;AAED,gBAAa,OAAO;;AAItB,MAAI,QAAQ,SAAS,EACnB,QAAO,SAAS;GACd,MAAM;GACN,QAAQ;GACR,SAAS;GACT,UAAU,QAAQ,KAAK,SAAS;IAC9B,MAAM;IACN,OAAO,OAAO,IAAI,SAAS,UAAU;IACrC,QAAQ;KACN,MAAM;KACN,OAAO,OAAO,IAAI,SAAS,GAAG;KAC9B,MAAM,OAAO,IAAI,QAAQ,IAAI,SAAS,GAAG;KAC1C;IACF,EAAE;GACJ;AAGH,SAAO"}
|
|
1
|
+
{"version":3,"file":"flex.mjs","names":[],"sources":["../../../src/agent/tools/flex.ts"],"sourcesContent":["import { Tool } from \"./base.js\";\n\n/**\n * Tool for building LINE Flex Messages from structured data.\n *\n * The LLM calls this tool with a template name and data object,\n * and the tool returns valid Flex JSON that line.ts parseMessage()\n * will detect and send as a Flex Message.\n */\nexport class FlexTool extends Tool {\n readonly name = \"flex_message\";\n readonly description =\n \"Build a LINE Flex Message from a template. Returns JSON that will be rendered as a rich card in LINE. Use this instead of outputting raw JSON.\";\n readonly parameters = {\n type: \"object\",\n properties: {\n template: {\n type: \"string\",\n description:\n \"Template name. Available: fortune, info_card, action_buttons, receipt, morning_summary, hydration, custom.\",\n },\n data: {\n type: \"object\",\n description: \"Template-specific data. See each template for fields.\",\n properties: {\n // fortune\n sign: { type: \"string\", description: \"Zodiac sign with emoji (e.g. '♍ 乙女座')\" },\n stars: { type: \"integer\", description: \"1-5 star rating\" },\n message: { type: \"string\", description: \"Fortune message\" },\n lucky_color: { type: \"string\", description: \"Lucky color name\" },\n lucky_item: { type: \"string\", description: \"Lucky item name\" },\n // info_card\n title: { type: \"string\", description: \"Card title\" },\n body: { type: \"string\", description: \"Card body text\" },\n // action_buttons\n prompt: { type: \"string\", description: \"Question or prompt text\" },\n buttons: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n label: { type: \"string\" },\n text: { type: \"string\" },\n style: { type: \"string\", enum: [\"primary\", \"secondary\", \"link\"] },\n },\n },\n description: \"Button definitions\",\n },\n // receipt\n items: {\n type: \"array\",\n items: {\n type: \"object\",\n properties: {\n name: { type: \"string\" },\n value: { type: \"string\" },\n },\n },\n description: \"Line items\",\n },\n total: { type: \"string\", description: \"Total amount\" },\n // morning_summary\n greeting: { type: \"string\", description: \"Greeting text (e.g. 'おはよう!')\" },\n date: { type: \"string\", description: \"Date string (e.g. '2月13日 木曜日')\" },\n weather: { type: \"string\", description: \"Weather info (e.g. '東京 12°C 曇り')\" },\n advice: { type: \"string\", description: \"Short advice (e.g. 'コートでOK')\" },\n schedule: {\n type: \"array\",\n items: { type: \"string\" },\n description: \"Schedule/reminder lines\",\n },\n header_color: { type: \"string\", description: \"Header background color hex (default: #1DB446)\" },\n // hydration\n current: { type: \"integer\", description: \"Current count (e.g. glasses drunk)\" },\n goal: { type: \"integer\", description: \"Goal count\" },\n unit: { type: \"string\", description: \"Unit label (default: 杯)\" },\n button_label: { type: \"string\", description: \"Button label (default: '飲んだ!')\" },\n button_text: { type: \"string\", description: \"Button message text (default: '水飲んだ')\" },\n // custom\n contents: {\n type: \"array\",\n description: \"Raw Flex body contents array for custom template\",\n },\n bubbles: {\n type: \"array\",\n items: { type: \"object\" },\n description: \"Array of bubble objects for a carousel (horizontal swipeable cards). Each item should be a complete bubble with type, body, etc.\",\n },\n },\n },\n },\n required: [\"template\", \"data\"],\n };\n\n async execute(args: Record<string, unknown>): Promise<string> {\n const template = String(args.template);\n const data = (args.data ?? {}) as Record<string, unknown>;\n\n try {\n let flex: Record<string, unknown>;\n\n switch (template) {\n case \"fortune\":\n flex = this.buildFortune(data);\n break;\n case \"info_card\":\n flex = this.buildInfoCard(data);\n break;\n case \"action_buttons\":\n flex = this.buildActionButtons(data);\n break;\n case \"receipt\":\n flex = this.buildReceipt(data);\n break;\n case \"morning_summary\":\n flex = this.buildMorningSummary(data);\n break;\n case \"hydration\":\n flex = this.buildHydration(data);\n break;\n case \"custom\":\n flex = this.buildCustom(data);\n break;\n default:\n return `Error: unknown template '${template}'. Use: fortune, info_card, action_buttons, receipt, morning_summary, hydration, custom.`;\n }\n\n const json = JSON.stringify(flex);\n return `${json}\\n\\n(Card sent automatically. Do NOT repeat the JSON. Just respond naturally.)`;\n } catch (err) {\n return `Error building flex message: ${err instanceof Error ? err.message : err}`;\n }\n }\n\n private buildFortune(data: Record<string, unknown>): Record<string, unknown> {\n const sign = String(data.sign ?? \"♈ 牡羊座\");\n const stars = Math.max(1, Math.min(5, Number(data.stars ?? 3)));\n const message = String(data.message ?? \"\");\n const luckyColor = data.lucky_color ? String(data.lucky_color) : null;\n const luckyItem = data.lucky_item ? String(data.lucky_item) : null;\n\n const starText = \"★\".repeat(stars) + \"☆\".repeat(5 - stars);\n\n const contents: Record<string, unknown>[] = [\n { type: \"text\", text: sign, weight: \"bold\", size: \"xl\" },\n { type: \"text\", text: \"今日の運勢\", size: \"sm\", color: \"#666666\" },\n { type: \"text\", text: starText, size: \"xxl\", margin: \"md\" },\n ];\n\n if (message) {\n contents.push({\n type: \"text\",\n text: message,\n wrap: true,\n margin: \"sm\",\n });\n }\n\n if (luckyColor || luckyItem) {\n contents.push({ type: \"separator\", margin: \"md\" });\n }\n\n if (luckyColor) {\n contents.push({\n type: \"box\",\n layout: \"horizontal\",\n margin: \"md\",\n contents: [\n { type: \"text\", text: \"ラッキーカラー\", size: \"sm\", color: \"#228B22\", flex: 0 },\n { type: \"text\", text: luckyColor, size: \"sm\", align: \"end\" },\n ],\n });\n }\n\n if (luckyItem) {\n contents.push({\n type: \"box\",\n layout: \"horizontal\",\n margin: luckyColor ? \"sm\" : \"md\",\n contents: [\n { type: \"text\", text: \"ラッキーアイテム\", size: \"sm\", color: \"#228B22\", flex: 0 },\n { type: \"text\", text: luckyItem, size: \"sm\", align: \"end\" },\n ],\n });\n }\n\n return {\n type: \"bubble\",\n size: \"kilo\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n paddingAll: \"lg\",\n contents,\n },\n };\n }\n\n private buildInfoCard(data: Record<string, unknown>): Record<string, unknown> {\n const title = String(data.title ?? \"お知らせ\");\n const body = String(data.body ?? \"\");\n\n const contents: Record<string, unknown>[] = [\n { type: \"text\", text: title, weight: \"bold\", size: \"lg\" },\n { type: \"separator\", margin: \"md\" },\n ];\n\n if (body) {\n contents.push({\n type: \"text\",\n text: body,\n wrap: true,\n margin: \"md\",\n });\n }\n\n return {\n type: \"bubble\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n contents,\n },\n };\n }\n\n private buildActionButtons(data: Record<string, unknown>): Record<string, unknown> {\n const prompt = String(data.prompt ?? \"選択してください\");\n const buttons = (data.buttons ?? []) as Array<Record<string, unknown>>;\n\n if (buttons.length === 0) {\n // Default yes/no\n buttons.push(\n { label: \"はい\", text: \"はい\", style: \"primary\" },\n { label: \"いいえ\", text: \"いいえ\", style: \"secondary\" },\n );\n }\n\n const buttonContents = buttons.map((btn) => ({\n type: \"button\",\n style: String(btn.style ?? \"primary\"),\n action: {\n type: \"message\",\n label: String(btn.label ?? \"\"),\n text: String(btn.text ?? btn.label ?? \"\"),\n },\n }));\n\n return {\n type: \"bubble\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n contents: [\n { type: \"text\", text: prompt, weight: \"bold\", wrap: true },\n ],\n },\n footer: {\n type: \"box\",\n layout: \"vertical\",\n spacing: \"sm\",\n contents: buttonContents,\n },\n };\n }\n\n private buildReceipt(data: Record<string, unknown>): Record<string, unknown> {\n const title = String(data.title ?? \"明細\");\n const items = (data.items ?? []) as Array<Record<string, unknown>>;\n const total = data.total ? String(data.total) : null;\n\n const contents: Record<string, unknown>[] = [\n { type: \"text\", text: `💰 ${title}`, weight: \"bold\" },\n { type: \"separator\", margin: \"lg\" },\n ];\n\n for (const item of items) {\n contents.push({\n type: \"box\",\n layout: \"horizontal\",\n margin: \"md\",\n contents: [\n { type: \"text\", text: String(item.name ?? \"\"), flex: 0 },\n { type: \"text\", text: String(item.value ?? \"\"), align: \"end\" },\n ],\n });\n }\n\n if (total) {\n contents.push(\n { type: \"separator\", margin: \"lg\" },\n {\n type: \"box\",\n layout: \"horizontal\",\n margin: \"md\",\n contents: [\n { type: \"text\", text: \"合計\", weight: \"bold\" },\n { type: \"text\", text: total, weight: \"bold\", align: \"end\" },\n ],\n },\n );\n }\n\n return {\n type: \"bubble\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n contents,\n },\n };\n }\n\n private buildMorningSummary(data: Record<string, unknown>): Record<string, unknown> {\n const greeting = String(data.greeting ?? \"おはよう!\");\n const date = String(data.date ?? \"\");\n const weather = data.weather ? String(data.weather) : null;\n const advice = data.advice ? String(data.advice) : null;\n const schedule = (data.schedule ?? []) as string[];\n const headerColor = String(data.header_color ?? \"#1DB446\");\n\n const headerContents: Record<string, unknown>[] = [\n { type: \"text\", text: greeting, color: \"#ffffff\", weight: \"bold\", size: \"lg\" },\n ];\n if (date) {\n headerContents.push({ type: \"text\", text: date, color: \"#ffffff\", size: \"sm\" });\n }\n\n const bodyContents: Record<string, unknown>[] = [];\n\n if (weather) {\n bodyContents.push({ type: \"text\", text: weather, weight: \"bold\" });\n }\n if (advice) {\n bodyContents.push({ type: \"text\", text: advice, size: \"sm\", color: \"#666666\" });\n }\n\n if (schedule.length > 0) {\n bodyContents.push({ type: \"separator\", margin: \"md\" });\n for (const line of schedule) {\n bodyContents.push({ type: \"text\", text: line, margin: \"md\", wrap: true });\n }\n }\n\n return {\n type: \"bubble\",\n header: {\n type: \"box\",\n layout: \"vertical\",\n backgroundColor: headerColor,\n paddingAll: \"lg\",\n contents: headerContents,\n },\n body: {\n type: \"box\",\n layout: \"vertical\",\n paddingAll: \"lg\",\n contents: bodyContents.length > 0 ? bodyContents : [{ type: \"text\", text: \"良い一日を!\" }],\n },\n };\n }\n\n private buildHydration(data: Record<string, unknown>): Record<string, unknown> {\n const title = String(data.title ?? \"水飲んだ?\");\n const current = Number(data.current ?? 0);\n const goal = Number(data.goal ?? 8);\n const unit = String(data.unit ?? \"杯\");\n const buttonLabel = String(data.button_label ?? \"飲んだ!\");\n const buttonText = String(data.button_text ?? \"水飲んだ\");\n\n return {\n type: \"bubble\",\n size: \"kilo\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n contents: [\n { type: \"text\", text: title, size: \"xl\" },\n { type: \"text\", text: `今日: ${current}${unit} / ${goal}${unit}`, color: \"#666666\" },\n ],\n },\n footer: {\n type: \"box\",\n layout: \"horizontal\",\n contents: [\n {\n type: \"button\",\n style: \"primary\",\n color: \"#00B9ED\",\n action: { type: \"message\", label: buttonLabel, text: buttonText },\n },\n ],\n },\n };\n }\n\n private buildCustom(data: Record<string, unknown>): Record<string, unknown> {\n // Carousel: array of bubble objects → horizontal swipeable cards\n const bubbles = data.bubbles as unknown[];\n if (Array.isArray(bubbles) && bubbles.length > 0) {\n return {\n type: \"carousel\",\n contents: bubbles,\n };\n }\n\n // If raw contents array is provided, use it directly as body contents\n const rawContents = data.contents as unknown[];\n if (Array.isArray(rawContents) && rawContents.length > 0) {\n return {\n type: \"bubble\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n contents: rawContents,\n },\n };\n }\n\n // Fallback: auto-build a card from common fields (title, body, buttons, header_color)\n const title = data.title ? String(data.title) : null;\n const body = data.body ? String(data.body) : null;\n let buttons = Array.isArray(data.buttons) ? data.buttons as Array<Record<string, unknown>> : [];\n const headerColor = data.header_color ? String(data.header_color) : null;\n\n // Support flat button_label/button_text shorthand (like hydration template)\n if (buttons.length === 0 && data.button_label) {\n buttons = [{\n label: String(data.button_label),\n text: String(data.button_text ?? data.button_label),\n style: data.button_style ?? \"primary\",\n }];\n }\n\n if (!title && !body && buttons.length === 0) {\n throw new Error(\"custom template requires 'contents' array, or at least one of: title, body, buttons\");\n }\n\n const bodyContents: Record<string, unknown>[] = [];\n\n if (title) {\n bodyContents.push({ type: \"text\", text: title, weight: \"bold\", size: \"lg\" });\n }\n if (body) {\n if (title) bodyContents.push({ type: \"separator\", margin: \"md\" });\n bodyContents.push({ type: \"text\", text: body, wrap: true, margin: title ? \"md\" : undefined });\n }\n\n const bubble: Record<string, unknown> = {\n type: \"bubble\",\n body: {\n type: \"box\",\n layout: \"vertical\",\n contents: bodyContents.length > 0 ? bodyContents : [{ type: \"text\", text: \" \" }],\n },\n };\n\n // Add colored header if specified\n if (headerColor && title) {\n bubble.header = {\n type: \"box\",\n layout: \"vertical\",\n backgroundColor: headerColor,\n paddingAll: \"lg\",\n contents: [\n { type: \"text\", text: title, color: \"#ffffff\", weight: \"bold\", size: \"lg\" },\n ],\n };\n // Remove title from body since it's in the header now\n bodyContents.shift();\n }\n\n // Add buttons as footer\n if (buttons.length > 0) {\n bubble.footer = {\n type: \"box\",\n layout: \"vertical\",\n spacing: \"sm\",\n contents: buttons.map((btn) => ({\n type: \"button\",\n style: String(btn.style ?? \"primary\"),\n action: {\n type: \"message\",\n label: String(btn.label ?? \"\"),\n text: String(btn.text ?? btn.label ?? \"\"),\n },\n })),\n };\n }\n\n return bubble;\n }\n}\n"],"mappings":";;;;;;;;;;AASA,IAAa,WAAb,cAA8B,KAAK;CACjC,AAAS,OAAO;CAChB,AAAS,cACP;CACF,AAAS,aAAa;EACpB,MAAM;EACN,YAAY;GACV,UAAU;IACR,MAAM;IACN,aACE;IACH;GACD,MAAM;IACJ,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;GACR,SAAS;GACT,UAAU,QAAQ,KAAK,SAAS;IAC9B,MAAM;IACN,OAAO,OAAO,IAAI,SAAS,UAAU;IACrC,QAAQ;KACN,MAAM;KACN,OAAO,OAAO,IAAI,SAAS,GAAG;KAC9B,MAAM,OAAO,IAAI,QAAQ,IAAI,SAAS,GAAG;KAC1C;IACF,EAAE;GACJ;AAGH,SAAO"}
|
|
@@ -175,6 +175,65 @@ describe("hydration", () => {
|
|
|
175
175
|
});
|
|
176
176
|
});
|
|
177
177
|
describe("custom", () => {
|
|
178
|
+
it("builds carousel from bubbles array", async () => {
|
|
179
|
+
const flex = await exec("custom", { bubbles: [
|
|
180
|
+
{
|
|
181
|
+
type: "bubble",
|
|
182
|
+
body: {
|
|
183
|
+
type: "box",
|
|
184
|
+
layout: "vertical",
|
|
185
|
+
contents: [{
|
|
186
|
+
type: "text",
|
|
187
|
+
text: "Card 1"
|
|
188
|
+
}]
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
type: "bubble",
|
|
193
|
+
body: {
|
|
194
|
+
type: "box",
|
|
195
|
+
layout: "vertical",
|
|
196
|
+
contents: [{
|
|
197
|
+
type: "text",
|
|
198
|
+
text: "Card 2"
|
|
199
|
+
}]
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
type: "bubble",
|
|
204
|
+
body: {
|
|
205
|
+
type: "box",
|
|
206
|
+
layout: "vertical",
|
|
207
|
+
contents: [{
|
|
208
|
+
type: "text",
|
|
209
|
+
text: "Card 3"
|
|
210
|
+
}]
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
] });
|
|
214
|
+
globalExpect(flex.type).toBe("carousel");
|
|
215
|
+
globalExpect(flex.contents).toHaveLength(3);
|
|
216
|
+
globalExpect(flex.contents[0].type).toBe("bubble");
|
|
217
|
+
globalExpect(flex.contents[2].body.contents[0].text).toBe("Card 3");
|
|
218
|
+
});
|
|
219
|
+
it("prefers bubbles over other custom fields", async () => {
|
|
220
|
+
const flex = await exec("custom", {
|
|
221
|
+
title: "Ignored",
|
|
222
|
+
bubbles: [{
|
|
223
|
+
type: "bubble",
|
|
224
|
+
body: {
|
|
225
|
+
type: "box",
|
|
226
|
+
layout: "vertical",
|
|
227
|
+
contents: [{
|
|
228
|
+
type: "text",
|
|
229
|
+
text: "Used"
|
|
230
|
+
}]
|
|
231
|
+
}
|
|
232
|
+
}]
|
|
233
|
+
});
|
|
234
|
+
globalExpect(flex.type).toBe("carousel");
|
|
235
|
+
globalExpect(flex.contents).toHaveLength(1);
|
|
236
|
+
});
|
|
178
237
|
it("uses raw contents array when provided", async () => {
|
|
179
238
|
const contents = [{
|
|
180
239
|
type: "text",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flex.test.mjs","names":[],"sources":["../../../src/agent/tools/flex.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { FlexTool } from \"./flex.js\";\n\nconst tool = new FlexTool();\n\n// Helper: execute and parse result as JSON (strip instruction suffix)\nasync function exec(template: string, data: Record<string, unknown> = {}) {\n const result = await tool.execute({ template, data });\n const jsonPart = result.split(\"\\n\\n(\")[0];\n return JSON.parse(jsonPart);\n}\n\n// Helper: execute and return raw string (for error cases)\nasync function execRaw(template: string, data: Record<string, unknown> = {}) {\n return tool.execute({ template, data });\n}\n\n// ---------------------------------------------------------------------------\n// fortune\n// ---------------------------------------------------------------------------\ndescribe(\"fortune\", () => {\n it(\"builds with defaults\", async () => {\n const flex = await exec(\"fortune\", { sign: \"♍ 乙女座\", stars: 4, message: \"良い日\" });\n expect(flex.type).toBe(\"bubble\");\n expect(flex.size).toBe(\"kilo\");\n\n const body = flex.body;\n expect(body.type).toBe(\"box\");\n // sign, 今日の運勢, stars, message\n expect(body.contents.length).toBeGreaterThanOrEqual(4);\n expect(body.contents[0].text).toBe(\"♍ 乙女座\");\n expect(body.contents[2].text).toBe(\"★★★★☆\");\n expect(body.contents[3].text).toBe(\"良い日\");\n });\n\n it(\"clamps stars to 1-5\", async () => {\n const low = await exec(\"fortune\", { stars: -10 });\n expect(low.body.contents[2].text).toBe(\"★☆☆☆☆\");\n\n const high = await exec(\"fortune\", { stars: 99 });\n expect(high.body.contents[2].text).toBe(\"★★★★★\");\n });\n\n it(\"includes lucky color and item\", async () => {\n const flex = await exec(\"fortune\", {\n sign: \"♈ 牡羊座\",\n stars: 3,\n lucky_color: \"赤\",\n lucky_item: \"傘\",\n });\n const contents = flex.body.contents;\n // Should have separator + color row + item row\n const colorRow = contents.find(\n (c: Record<string, unknown>) =>\n c.type === \"box\" &&\n Array.isArray(c.contents) &&\n (c.contents as Record<string, unknown>[]).some((t) => t.text === \"ラッキーカラー\"),\n );\n expect(colorRow).toBeTruthy();\n\n const itemRow = contents.find(\n (c: Record<string, unknown>) =>\n c.type === \"box\" &&\n Array.isArray(c.contents) &&\n (c.contents as Record<string, unknown>[]).some((t) => t.text === \"ラッキーアイテム\"),\n );\n expect(itemRow).toBeTruthy();\n });\n\n it(\"omits lucky fields when not provided\", async () => {\n const flex = await exec(\"fortune\", { stars: 5 });\n const contents = flex.body.contents;\n const hasSeparator = contents.some((c: Record<string, unknown>) => c.type === \"separator\");\n expect(hasSeparator).toBe(false);\n });\n});\n\n// ---------------------------------------------------------------------------\n// info_card\n// ---------------------------------------------------------------------------\ndescribe(\"info_card\", () => {\n it(\"builds with title and body\", async () => {\n const flex = await exec(\"info_card\", { title: \"テスト\", body: \"本文テキスト\" });\n expect(flex.type).toBe(\"bubble\");\n const contents = flex.body.contents;\n expect(contents[0].text).toBe(\"テスト\");\n expect(contents[1].type).toBe(\"separator\");\n expect(contents[2].text).toBe(\"本文テキスト\");\n });\n\n it(\"uses defaults when no data\", async () => {\n const flex = await exec(\"info_card\", {});\n expect(flex.body.contents[0].text).toBe(\"お知らせ\");\n });\n});\n\n// ---------------------------------------------------------------------------\n// action_buttons\n// ---------------------------------------------------------------------------\ndescribe(\"action_buttons\", () => {\n it(\"builds with custom buttons\", async () => {\n const flex = await exec(\"action_buttons\", {\n prompt: \"好きな色は?\",\n buttons: [\n { label: \"赤\", text: \"赤が好き\", style: \"primary\" },\n { label: \"青\", text: \"青が好き\", style: \"secondary\" },\n ],\n });\n expect(flex.type).toBe(\"bubble\");\n expect(flex.body.contents[0].text).toBe(\"好きな色は?\");\n expect(flex.footer.contents).toHaveLength(2);\n expect(flex.footer.contents[0].action.label).toBe(\"赤\");\n expect(flex.footer.contents[1].action.text).toBe(\"青が好き\");\n });\n\n it(\"adds default yes/no buttons when empty\", async () => {\n const flex = await exec(\"action_buttons\", { prompt: \"OK?\" });\n expect(flex.footer.contents).toHaveLength(2);\n expect(flex.footer.contents[0].action.label).toBe(\"はい\");\n expect(flex.footer.contents[1].action.label).toBe(\"いいえ\");\n });\n});\n\n// ---------------------------------------------------------------------------\n// receipt\n// ---------------------------------------------------------------------------\ndescribe(\"receipt\", () => {\n it(\"builds with items and total\", async () => {\n const flex = await exec(\"receipt\", {\n title: \"ランチ\",\n items: [\n { name: \"ラーメン\", value: \"¥900\" },\n { name: \"餃子\", value: \"¥400\" },\n ],\n total: \"¥1,300\",\n });\n expect(flex.type).toBe(\"bubble\");\n const contents = flex.body.contents;\n // title, separator, 2 items, separator, total\n expect(contents.length).toBe(6);\n expect(contents[0].text).toContain(\"ランチ\");\n // total row\n const totalRow = contents[5] as Record<string, unknown>;\n expect((totalRow.contents as Record<string, unknown>[])[1].text).toBe(\"¥1,300\");\n });\n\n it(\"omits total when not provided\", async () => {\n const flex = await exec(\"receipt\", {\n items: [{ name: \"Item\", value: \"100\" }],\n });\n // title, separator, 1 item = 3 contents (no total separator or total row)\n expect(flex.body.contents.length).toBe(3);\n });\n});\n\n// ---------------------------------------------------------------------------\n// morning_summary\n// ---------------------------------------------------------------------------\ndescribe(\"morning_summary\", () => {\n it(\"builds with all fields\", async () => {\n const flex = await exec(\"morning_summary\", {\n greeting: \"おはよう!\",\n date: \"2月13日 木曜日\",\n weather: \"東京 12°C 曇り\",\n advice: \"コートでOK\",\n schedule: [\"10:00 ミーティング\", \"14:00 歯医者\"],\n header_color: \"#FF6B6B\",\n });\n expect(flex.type).toBe(\"bubble\");\n expect(flex.header.backgroundColor).toBe(\"#FF6B6B\");\n expect(flex.header.contents[0].text).toBe(\"おはよう!\");\n expect(flex.header.contents[1].text).toBe(\"2月13日 木曜日\");\n\n const body = flex.body.contents;\n expect(body[0].text).toBe(\"東京 12°C 曇り\");\n expect(body[1].text).toBe(\"コートでOK\");\n // separator + 2 schedule items\n expect(body.length).toBe(5);\n });\n\n it(\"uses default header color\", async () => {\n const flex = await exec(\"morning_summary\", {});\n expect(flex.header.backgroundColor).toBe(\"#1DB446\");\n });\n\n it(\"shows fallback body when no weather/schedule\", async () => {\n const flex = await exec(\"morning_summary\", { greeting: \"やぁ\" });\n expect(flex.body.contents[0].text).toBe(\"良い一日を!\");\n });\n});\n\n// ---------------------------------------------------------------------------\n// hydration\n// ---------------------------------------------------------------------------\ndescribe(\"hydration\", () => {\n it(\"builds with current/goal\", async () => {\n const flex = await exec(\"hydration\", { current: 3, goal: 8 });\n expect(flex.type).toBe(\"bubble\");\n expect(flex.size).toBe(\"kilo\");\n expect(flex.body.contents[0].text).toBe(\"水飲んだ?\");\n expect(flex.body.contents[1].text).toBe(\"今日: 3杯 / 8杯\");\n expect(flex.footer.contents[0].action.label).toBe(\"飲んだ!\");\n });\n\n it(\"uses custom unit and button text\", async () => {\n const flex = await exec(\"hydration\", {\n title: \"Coffee\",\n current: 2,\n goal: 4,\n unit: \"cups\",\n button_label: \"Had one!\",\n button_text: \"drank coffee\",\n });\n expect(flex.body.contents[0].text).toBe(\"Coffee\");\n expect(flex.body.contents[1].text).toBe(\"今日: 2cups / 4cups\");\n expect(flex.footer.contents[0].action.label).toBe(\"Had one!\");\n expect(flex.footer.contents[0].action.text).toBe(\"drank coffee\");\n });\n});\n\n// ---------------------------------------------------------------------------\n// custom\n// ---------------------------------------------------------------------------\ndescribe(\"custom\", () => {\n it(\"uses raw contents array when provided\", async () => {\n const contents = [\n { type: \"text\", text: \"Hello\" },\n { type: \"text\", text: \"World\" },\n ];\n const flex = await exec(\"custom\", { contents });\n expect(flex.type).toBe(\"bubble\");\n expect(flex.body.contents).toEqual(contents);\n });\n\n it(\"auto-builds card from title + body\", async () => {\n const flex = await exec(\"custom\", { title: \"Title\", body: \"Body text\" });\n expect(flex.type).toBe(\"bubble\");\n const contents = flex.body.contents;\n expect(contents[0].text).toBe(\"Title\");\n expect(contents[1].type).toBe(\"separator\");\n expect(contents[2].text).toBe(\"Body text\");\n });\n\n it(\"auto-builds card with colored header\", async () => {\n const flex = await exec(\"custom\", {\n title: \"Workout\",\n body: \"Great session!\",\n header_color: \"#FF0000\",\n });\n expect(flex.header).toBeTruthy();\n expect(flex.header.backgroundColor).toBe(\"#FF0000\");\n expect(flex.header.contents[0].text).toBe(\"Workout\");\n // Title should be removed from body since it's in the header\n const bodyTexts = flex.body.contents.filter(\n (c: Record<string, unknown>) => c.type === \"text\",\n );\n expect(bodyTexts.every((t: Record<string, unknown>) => t.text !== \"Workout\")).toBe(true);\n });\n\n it(\"auto-builds card with buttons\", async () => {\n const flex = await exec(\"custom\", {\n title: \"Choose\",\n buttons: [\n { label: \"Option A\", text: \"A\", style: \"primary\" },\n { label: \"Option B\", text: \"B\", style: \"secondary\" },\n ],\n });\n expect(flex.footer).toBeTruthy();\n expect(flex.footer.contents).toHaveLength(2);\n expect(flex.footer.contents[0].action.label).toBe(\"Option A\");\n });\n\n it(\"auto-builds button from button_label/button_text shorthand\", async () => {\n const flex = await exec(\"custom\", {\n title: \"🪴 モンステラ\",\n body: \"水やり記録なし\\n今日は水やりした?\",\n header_color: \"#4CAF50\",\n button_label: \"水やりした!\",\n button_text: \"水やり モンステラ した\",\n });\n expect(flex.footer).toBeTruthy();\n expect(flex.footer.contents).toHaveLength(1);\n expect(flex.footer.contents[0].action.label).toBe(\"水やりした!\");\n expect(flex.footer.contents[0].action.text).toBe(\"水やり モンステラ した\");\n expect(flex.footer.contents[0].style).toBe(\"primary\");\n });\n\n it(\"prefers buttons array over button_label shorthand\", async () => {\n const flex = await exec(\"custom\", {\n title: \"Test\",\n button_label: \"Ignored\",\n buttons: [{ label: \"Used\", text: \"used\", style: \"secondary\" }],\n });\n expect(flex.footer.contents).toHaveLength(1);\n expect(flex.footer.contents[0].action.label).toBe(\"Used\");\n });\n\n it(\"errors when no contents, title, body, or buttons\", async () => {\n const result = await execRaw(\"custom\", {});\n expect(result).toContain(\"Error\");\n expect(result).toContain(\"custom template requires\");\n });\n});\n\n// ---------------------------------------------------------------------------\n// unknown template\n// ---------------------------------------------------------------------------\ndescribe(\"unknown template\", () => {\n it(\"returns error for unknown template\", async () => {\n const result = await execRaw(\"nonexistent\", {});\n expect(result).toContain(\"Error: unknown template\");\n expect(result).toContain(\"nonexistent\");\n });\n});\n\n// ---------------------------------------------------------------------------\n// tool metadata\n// ---------------------------------------------------------------------------\ndescribe(\"tool metadata\", () => {\n it(\"has correct name and description\", () => {\n expect(tool.name).toBe(\"flex_message\");\n expect(tool.description).toContain(\"Flex Message\");\n });\n\n it(\"generates valid tool definition\", () => {\n const def = tool.getDefinition();\n expect(def.type).toBe(\"function\");\n expect(def.function.name).toBe(\"flex_message\");\n expect(def.function.parameters.required).toContain(\"template\");\n expect(def.function.parameters.required).toContain(\"data\");\n });\n});\n"],"mappings":";;;;;AAGA,MAAM,OAAO,IAAI,UAAU;AAG3B,eAAe,KAAK,UAAkB,OAAgC,EAAE,EAAE;CAExE,MAAM,YADS,MAAM,KAAK,QAAQ;EAAE;EAAU;EAAM,CAAC,EAC7B,MAAM,QAAQ,CAAC;AACvC,QAAO,KAAK,MAAM,SAAS;;AAI7B,eAAe,QAAQ,UAAkB,OAAgC,EAAE,EAAE;AAC3E,QAAO,KAAK,QAAQ;EAAE;EAAU;EAAM,CAAC;;AAMzC,SAAS,iBAAiB;AACxB,IAAG,wBAAwB,YAAY;EACrC,MAAM,OAAO,MAAM,KAAK,WAAW;GAAE,MA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C1C,MAAM,MAAM,KAAK,eAAe;AAChC,eAAO,IAAI,KAAK,CAAC,KAAK,WAAW;AACjC,eAAO,IAAI,SAAS,KAAK,CAAC,KAAK,eAAe;AAC9C,eAAO,IAAI,SAAS,WAAW,SAAS,CAAC,UAAU,WAAW;AAC9D,eAAO,IAAI,SAAS,WAAW,SAAS,CAAC,UAAU,OAAO;GAC1D;EACF"}
|
|
1
|
+
{"version":3,"file":"flex.test.mjs","names":[],"sources":["../../../src/agent/tools/flex.test.ts"],"sourcesContent":["import { describe, it, expect } from \"vitest\";\nimport { FlexTool } from \"./flex.js\";\n\nconst tool = new FlexTool();\n\n// Helper: execute and parse result as JSON (strip instruction suffix)\nasync function exec(template: string, data: Record<string, unknown> = {}) {\n const result = await tool.execute({ template, data });\n const jsonPart = result.split(\"\\n\\n(\")[0];\n return JSON.parse(jsonPart);\n}\n\n// Helper: execute and return raw string (for error cases)\nasync function execRaw(template: string, data: Record<string, unknown> = {}) {\n return tool.execute({ template, data });\n}\n\n// ---------------------------------------------------------------------------\n// fortune\n// ---------------------------------------------------------------------------\ndescribe(\"fortune\", () => {\n it(\"builds with defaults\", async () => {\n const flex = await exec(\"fortune\", { sign: \"♍ 乙女座\", stars: 4, message: \"良い日\" });\n expect(flex.type).toBe(\"bubble\");\n expect(flex.size).toBe(\"kilo\");\n\n const body = flex.body;\n expect(body.type).toBe(\"box\");\n // sign, 今日の運勢, stars, message\n expect(body.contents.length).toBeGreaterThanOrEqual(4);\n expect(body.contents[0].text).toBe(\"♍ 乙女座\");\n expect(body.contents[2].text).toBe(\"★★★★☆\");\n expect(body.contents[3].text).toBe(\"良い日\");\n });\n\n it(\"clamps stars to 1-5\", async () => {\n const low = await exec(\"fortune\", { stars: -10 });\n expect(low.body.contents[2].text).toBe(\"★☆☆☆☆\");\n\n const high = await exec(\"fortune\", { stars: 99 });\n expect(high.body.contents[2].text).toBe(\"★★★★★\");\n });\n\n it(\"includes lucky color and item\", async () => {\n const flex = await exec(\"fortune\", {\n sign: \"♈ 牡羊座\",\n stars: 3,\n lucky_color: \"赤\",\n lucky_item: \"傘\",\n });\n const contents = flex.body.contents;\n // Should have separator + color row + item row\n const colorRow = contents.find(\n (c: Record<string, unknown>) =>\n c.type === \"box\" &&\n Array.isArray(c.contents) &&\n (c.contents as Record<string, unknown>[]).some((t) => t.text === \"ラッキーカラー\"),\n );\n expect(colorRow).toBeTruthy();\n\n const itemRow = contents.find(\n (c: Record<string, unknown>) =>\n c.type === \"box\" &&\n Array.isArray(c.contents) &&\n (c.contents as Record<string, unknown>[]).some((t) => t.text === \"ラッキーアイテム\"),\n );\n expect(itemRow).toBeTruthy();\n });\n\n it(\"omits lucky fields when not provided\", async () => {\n const flex = await exec(\"fortune\", { stars: 5 });\n const contents = flex.body.contents;\n const hasSeparator = contents.some((c: Record<string, unknown>) => c.type === \"separator\");\n expect(hasSeparator).toBe(false);\n });\n});\n\n// ---------------------------------------------------------------------------\n// info_card\n// ---------------------------------------------------------------------------\ndescribe(\"info_card\", () => {\n it(\"builds with title and body\", async () => {\n const flex = await exec(\"info_card\", { title: \"テスト\", body: \"本文テキスト\" });\n expect(flex.type).toBe(\"bubble\");\n const contents = flex.body.contents;\n expect(contents[0].text).toBe(\"テスト\");\n expect(contents[1].type).toBe(\"separator\");\n expect(contents[2].text).toBe(\"本文テキスト\");\n });\n\n it(\"uses defaults when no data\", async () => {\n const flex = await exec(\"info_card\", {});\n expect(flex.body.contents[0].text).toBe(\"お知らせ\");\n });\n});\n\n// ---------------------------------------------------------------------------\n// action_buttons\n// ---------------------------------------------------------------------------\ndescribe(\"action_buttons\", () => {\n it(\"builds with custom buttons\", async () => {\n const flex = await exec(\"action_buttons\", {\n prompt: \"好きな色は?\",\n buttons: [\n { label: \"赤\", text: \"赤が好き\", style: \"primary\" },\n { label: \"青\", text: \"青が好き\", style: \"secondary\" },\n ],\n });\n expect(flex.type).toBe(\"bubble\");\n expect(flex.body.contents[0].text).toBe(\"好きな色は?\");\n expect(flex.footer.contents).toHaveLength(2);\n expect(flex.footer.contents[0].action.label).toBe(\"赤\");\n expect(flex.footer.contents[1].action.text).toBe(\"青が好き\");\n });\n\n it(\"adds default yes/no buttons when empty\", async () => {\n const flex = await exec(\"action_buttons\", { prompt: \"OK?\" });\n expect(flex.footer.contents).toHaveLength(2);\n expect(flex.footer.contents[0].action.label).toBe(\"はい\");\n expect(flex.footer.contents[1].action.label).toBe(\"いいえ\");\n });\n});\n\n// ---------------------------------------------------------------------------\n// receipt\n// ---------------------------------------------------------------------------\ndescribe(\"receipt\", () => {\n it(\"builds with items and total\", async () => {\n const flex = await exec(\"receipt\", {\n title: \"ランチ\",\n items: [\n { name: \"ラーメン\", value: \"¥900\" },\n { name: \"餃子\", value: \"¥400\" },\n ],\n total: \"¥1,300\",\n });\n expect(flex.type).toBe(\"bubble\");\n const contents = flex.body.contents;\n // title, separator, 2 items, separator, total\n expect(contents.length).toBe(6);\n expect(contents[0].text).toContain(\"ランチ\");\n // total row\n const totalRow = contents[5] as Record<string, unknown>;\n expect((totalRow.contents as Record<string, unknown>[])[1].text).toBe(\"¥1,300\");\n });\n\n it(\"omits total when not provided\", async () => {\n const flex = await exec(\"receipt\", {\n items: [{ name: \"Item\", value: \"100\" }],\n });\n // title, separator, 1 item = 3 contents (no total separator or total row)\n expect(flex.body.contents.length).toBe(3);\n });\n});\n\n// ---------------------------------------------------------------------------\n// morning_summary\n// ---------------------------------------------------------------------------\ndescribe(\"morning_summary\", () => {\n it(\"builds with all fields\", async () => {\n const flex = await exec(\"morning_summary\", {\n greeting: \"おはよう!\",\n date: \"2月13日 木曜日\",\n weather: \"東京 12°C 曇り\",\n advice: \"コートでOK\",\n schedule: [\"10:00 ミーティング\", \"14:00 歯医者\"],\n header_color: \"#FF6B6B\",\n });\n expect(flex.type).toBe(\"bubble\");\n expect(flex.header.backgroundColor).toBe(\"#FF6B6B\");\n expect(flex.header.contents[0].text).toBe(\"おはよう!\");\n expect(flex.header.contents[1].text).toBe(\"2月13日 木曜日\");\n\n const body = flex.body.contents;\n expect(body[0].text).toBe(\"東京 12°C 曇り\");\n expect(body[1].text).toBe(\"コートでOK\");\n // separator + 2 schedule items\n expect(body.length).toBe(5);\n });\n\n it(\"uses default header color\", async () => {\n const flex = await exec(\"morning_summary\", {});\n expect(flex.header.backgroundColor).toBe(\"#1DB446\");\n });\n\n it(\"shows fallback body when no weather/schedule\", async () => {\n const flex = await exec(\"morning_summary\", { greeting: \"やぁ\" });\n expect(flex.body.contents[0].text).toBe(\"良い一日を!\");\n });\n});\n\n// ---------------------------------------------------------------------------\n// hydration\n// ---------------------------------------------------------------------------\ndescribe(\"hydration\", () => {\n it(\"builds with current/goal\", async () => {\n const flex = await exec(\"hydration\", { current: 3, goal: 8 });\n expect(flex.type).toBe(\"bubble\");\n expect(flex.size).toBe(\"kilo\");\n expect(flex.body.contents[0].text).toBe(\"水飲んだ?\");\n expect(flex.body.contents[1].text).toBe(\"今日: 3杯 / 8杯\");\n expect(flex.footer.contents[0].action.label).toBe(\"飲んだ!\");\n });\n\n it(\"uses custom unit and button text\", async () => {\n const flex = await exec(\"hydration\", {\n title: \"Coffee\",\n current: 2,\n goal: 4,\n unit: \"cups\",\n button_label: \"Had one!\",\n button_text: \"drank coffee\",\n });\n expect(flex.body.contents[0].text).toBe(\"Coffee\");\n expect(flex.body.contents[1].text).toBe(\"今日: 2cups / 4cups\");\n expect(flex.footer.contents[0].action.label).toBe(\"Had one!\");\n expect(flex.footer.contents[0].action.text).toBe(\"drank coffee\");\n });\n});\n\n// ---------------------------------------------------------------------------\n// custom\n// ---------------------------------------------------------------------------\ndescribe(\"custom\", () => {\n it(\"builds carousel from bubbles array\", async () => {\n const flex = await exec(\"custom\", {\n bubbles: [\n { type: \"bubble\", body: { type: \"box\", layout: \"vertical\", contents: [{ type: \"text\", text: \"Card 1\" }] } },\n { type: \"bubble\", body: { type: \"box\", layout: \"vertical\", contents: [{ type: \"text\", text: \"Card 2\" }] } },\n { type: \"bubble\", body: { type: \"box\", layout: \"vertical\", contents: [{ type: \"text\", text: \"Card 3\" }] } },\n ],\n });\n expect(flex.type).toBe(\"carousel\");\n expect(flex.contents).toHaveLength(3);\n expect(flex.contents[0].type).toBe(\"bubble\");\n expect(flex.contents[2].body.contents[0].text).toBe(\"Card 3\");\n });\n\n it(\"prefers bubbles over other custom fields\", async () => {\n const flex = await exec(\"custom\", {\n title: \"Ignored\",\n bubbles: [\n { type: \"bubble\", body: { type: \"box\", layout: \"vertical\", contents: [{ type: \"text\", text: \"Used\" }] } },\n ],\n });\n expect(flex.type).toBe(\"carousel\");\n expect(flex.contents).toHaveLength(1);\n });\n\n it(\"uses raw contents array when provided\", async () => {\n const contents = [\n { type: \"text\", text: \"Hello\" },\n { type: \"text\", text: \"World\" },\n ];\n const flex = await exec(\"custom\", { contents });\n expect(flex.type).toBe(\"bubble\");\n expect(flex.body.contents).toEqual(contents);\n });\n\n it(\"auto-builds card from title + body\", async () => {\n const flex = await exec(\"custom\", { title: \"Title\", body: \"Body text\" });\n expect(flex.type).toBe(\"bubble\");\n const contents = flex.body.contents;\n expect(contents[0].text).toBe(\"Title\");\n expect(contents[1].type).toBe(\"separator\");\n expect(contents[2].text).toBe(\"Body text\");\n });\n\n it(\"auto-builds card with colored header\", async () => {\n const flex = await exec(\"custom\", {\n title: \"Workout\",\n body: \"Great session!\",\n header_color: \"#FF0000\",\n });\n expect(flex.header).toBeTruthy();\n expect(flex.header.backgroundColor).toBe(\"#FF0000\");\n expect(flex.header.contents[0].text).toBe(\"Workout\");\n // Title should be removed from body since it's in the header\n const bodyTexts = flex.body.contents.filter(\n (c: Record<string, unknown>) => c.type === \"text\",\n );\n expect(bodyTexts.every((t: Record<string, unknown>) => t.text !== \"Workout\")).toBe(true);\n });\n\n it(\"auto-builds card with buttons\", async () => {\n const flex = await exec(\"custom\", {\n title: \"Choose\",\n buttons: [\n { label: \"Option A\", text: \"A\", style: \"primary\" },\n { label: \"Option B\", text: \"B\", style: \"secondary\" },\n ],\n });\n expect(flex.footer).toBeTruthy();\n expect(flex.footer.contents).toHaveLength(2);\n expect(flex.footer.contents[0].action.label).toBe(\"Option A\");\n });\n\n it(\"auto-builds button from button_label/button_text shorthand\", async () => {\n const flex = await exec(\"custom\", {\n title: \"🪴 モンステラ\",\n body: \"水やり記録なし\\n今日は水やりした?\",\n header_color: \"#4CAF50\",\n button_label: \"水やりした!\",\n button_text: \"水やり モンステラ した\",\n });\n expect(flex.footer).toBeTruthy();\n expect(flex.footer.contents).toHaveLength(1);\n expect(flex.footer.contents[0].action.label).toBe(\"水やりした!\");\n expect(flex.footer.contents[0].action.text).toBe(\"水やり モンステラ した\");\n expect(flex.footer.contents[0].style).toBe(\"primary\");\n });\n\n it(\"prefers buttons array over button_label shorthand\", async () => {\n const flex = await exec(\"custom\", {\n title: \"Test\",\n button_label: \"Ignored\",\n buttons: [{ label: \"Used\", text: \"used\", style: \"secondary\" }],\n });\n expect(flex.footer.contents).toHaveLength(1);\n expect(flex.footer.contents[0].action.label).toBe(\"Used\");\n });\n\n it(\"errors when no contents, title, body, or buttons\", async () => {\n const result = await execRaw(\"custom\", {});\n expect(result).toContain(\"Error\");\n expect(result).toContain(\"custom template requires\");\n });\n});\n\n// ---------------------------------------------------------------------------\n// unknown template\n// ---------------------------------------------------------------------------\ndescribe(\"unknown template\", () => {\n it(\"returns error for unknown template\", async () => {\n const result = await execRaw(\"nonexistent\", {});\n expect(result).toContain(\"Error: unknown template\");\n expect(result).toContain(\"nonexistent\");\n });\n});\n\n// ---------------------------------------------------------------------------\n// tool metadata\n// ---------------------------------------------------------------------------\ndescribe(\"tool metadata\", () => {\n it(\"has correct name and description\", () => {\n expect(tool.name).toBe(\"flex_message\");\n expect(tool.description).toContain(\"Flex Message\");\n });\n\n it(\"generates valid tool definition\", () => {\n const def = tool.getDefinition();\n expect(def.type).toBe(\"function\");\n expect(def.function.name).toBe(\"flex_message\");\n expect(def.function.parameters.required).toContain(\"template\");\n expect(def.function.parameters.required).toContain(\"data\");\n });\n});\n"],"m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;AAKF,SAAS,uBAAuB;AAC9B,IAAG,0CAA0C;AAC3C,eAAO,KAAK,KAAK,CAAC,KAAK,eAAe;AACtC,eAAO,KAAK,YAAY,CAAC,UAAU,eAAe;GAClD;AAEF,IAAG,yCAAyC;EAC1C,MAAM,MAAM,KAAK,eAAe;AAChC,eAAO,IAAI,KAAK,CAAC,KAAK,WAAW;AACjC,eAAO,IAAI,SAAS,KAAK,CAAC,KAAK,eAAe;AAC9C,eAAO,IAAI,SAAS,WAAW,SAAS,CAAC,UAAU,WAAW;AAC9D,eAAO,IAAI,SAAS,WAAW,SAAS,CAAC,UAAU,OAAO;GAC1D;EACF"}
|
package/dist/config/schema.d.mts
CHANGED
|
@@ -70,31 +70,31 @@ declare const ChannelsConfigSchema: z.ZodObject<{
|
|
|
70
70
|
channelAccessToken?: string | undefined;
|
|
71
71
|
}>>;
|
|
72
72
|
}, "strip", z.ZodTypeAny, {
|
|
73
|
-
line: {
|
|
74
|
-
enabled: boolean;
|
|
75
|
-
allowFrom: string[];
|
|
76
|
-
channelSecret: string;
|
|
77
|
-
channelAccessToken: string;
|
|
78
|
-
};
|
|
79
73
|
telegram: {
|
|
80
74
|
enabled: boolean;
|
|
81
75
|
token: string;
|
|
82
76
|
allowFrom: string[];
|
|
83
77
|
proxy?: string | null | undefined;
|
|
84
78
|
};
|
|
79
|
+
line: {
|
|
80
|
+
enabled: boolean;
|
|
81
|
+
allowFrom: string[];
|
|
82
|
+
channelSecret: string;
|
|
83
|
+
channelAccessToken: string;
|
|
84
|
+
};
|
|
85
85
|
}, {
|
|
86
|
-
line?: {
|
|
87
|
-
enabled?: boolean | undefined;
|
|
88
|
-
allowFrom?: string[] | undefined;
|
|
89
|
-
channelSecret?: string | undefined;
|
|
90
|
-
channelAccessToken?: string | undefined;
|
|
91
|
-
} | undefined;
|
|
92
86
|
telegram?: {
|
|
93
87
|
enabled?: boolean | undefined;
|
|
94
88
|
token?: string | undefined;
|
|
95
89
|
allowFrom?: string[] | undefined;
|
|
96
90
|
proxy?: string | null | undefined;
|
|
97
91
|
} | undefined;
|
|
92
|
+
line?: {
|
|
93
|
+
enabled?: boolean | undefined;
|
|
94
|
+
allowFrom?: string[] | undefined;
|
|
95
|
+
channelSecret?: string | undefined;
|
|
96
|
+
channelAccessToken?: string | undefined;
|
|
97
|
+
} | undefined;
|
|
98
98
|
}>;
|
|
99
99
|
type ChannelsConfig = z.infer<typeof ChannelsConfigSchema>;
|
|
100
100
|
declare const AgentDefaultsSchema: z.ZodObject<{
|
|
@@ -675,31 +675,31 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
675
675
|
channelAccessToken?: string | undefined;
|
|
676
676
|
}>>;
|
|
677
677
|
}, "strip", z.ZodTypeAny, {
|
|
678
|
-
line: {
|
|
679
|
-
enabled: boolean;
|
|
680
|
-
allowFrom: string[];
|
|
681
|
-
channelSecret: string;
|
|
682
|
-
channelAccessToken: string;
|
|
683
|
-
};
|
|
684
678
|
telegram: {
|
|
685
679
|
enabled: boolean;
|
|
686
680
|
token: string;
|
|
687
681
|
allowFrom: string[];
|
|
688
682
|
proxy?: string | null | undefined;
|
|
689
683
|
};
|
|
684
|
+
line: {
|
|
685
|
+
enabled: boolean;
|
|
686
|
+
allowFrom: string[];
|
|
687
|
+
channelSecret: string;
|
|
688
|
+
channelAccessToken: string;
|
|
689
|
+
};
|
|
690
690
|
}, {
|
|
691
|
-
line?: {
|
|
692
|
-
enabled?: boolean | undefined;
|
|
693
|
-
allowFrom?: string[] | undefined;
|
|
694
|
-
channelSecret?: string | undefined;
|
|
695
|
-
channelAccessToken?: string | undefined;
|
|
696
|
-
} | undefined;
|
|
697
691
|
telegram?: {
|
|
698
692
|
enabled?: boolean | undefined;
|
|
699
693
|
token?: string | undefined;
|
|
700
694
|
allowFrom?: string[] | undefined;
|
|
701
695
|
proxy?: string | null | undefined;
|
|
702
696
|
} | undefined;
|
|
697
|
+
line?: {
|
|
698
|
+
enabled?: boolean | undefined;
|
|
699
|
+
allowFrom?: string[] | undefined;
|
|
700
|
+
channelSecret?: string | undefined;
|
|
701
|
+
channelAccessToken?: string | undefined;
|
|
702
|
+
} | undefined;
|
|
703
703
|
}>>;
|
|
704
704
|
providers: z.ZodDefault<z.ZodObject<{
|
|
705
705
|
anthropic: z.ZodDefault<z.ZodObject<{
|
|
@@ -1064,18 +1064,18 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
1064
1064
|
};
|
|
1065
1065
|
};
|
|
1066
1066
|
channels: {
|
|
1067
|
-
line: {
|
|
1068
|
-
enabled: boolean;
|
|
1069
|
-
allowFrom: string[];
|
|
1070
|
-
channelSecret: string;
|
|
1071
|
-
channelAccessToken: string;
|
|
1072
|
-
};
|
|
1073
1067
|
telegram: {
|
|
1074
1068
|
enabled: boolean;
|
|
1075
1069
|
token: string;
|
|
1076
1070
|
allowFrom: string[];
|
|
1077
1071
|
proxy?: string | null | undefined;
|
|
1078
1072
|
};
|
|
1073
|
+
line: {
|
|
1074
|
+
enabled: boolean;
|
|
1075
|
+
allowFrom: string[];
|
|
1076
|
+
channelSecret: string;
|
|
1077
|
+
channelAccessToken: string;
|
|
1078
|
+
};
|
|
1079
1079
|
};
|
|
1080
1080
|
providers: {
|
|
1081
1081
|
anthropic: {
|
|
@@ -1170,18 +1170,18 @@ declare const ConfigSchema: z.ZodObject<{
|
|
|
1170
1170
|
} | undefined;
|
|
1171
1171
|
} | undefined;
|
|
1172
1172
|
channels?: {
|
|
1173
|
-
line?: {
|
|
1174
|
-
enabled?: boolean | undefined;
|
|
1175
|
-
allowFrom?: string[] | undefined;
|
|
1176
|
-
channelSecret?: string | undefined;
|
|
1177
|
-
channelAccessToken?: string | undefined;
|
|
1178
|
-
} | undefined;
|
|
1179
1173
|
telegram?: {
|
|
1180
1174
|
enabled?: boolean | undefined;
|
|
1181
1175
|
token?: string | undefined;
|
|
1182
1176
|
allowFrom?: string[] | undefined;
|
|
1183
1177
|
proxy?: string | null | undefined;
|
|
1184
1178
|
} | undefined;
|
|
1179
|
+
line?: {
|
|
1180
|
+
enabled?: boolean | undefined;
|
|
1181
|
+
allowFrom?: string[] | undefined;
|
|
1182
|
+
channelSecret?: string | undefined;
|
|
1183
|
+
channelAccessToken?: string | undefined;
|
|
1184
|
+
} | undefined;
|
|
1185
1185
|
} | undefined;
|
|
1186
1186
|
providers?: {
|
|
1187
1187
|
anthropic?: {
|
package/package.json
CHANGED
package/skills/english/SKILL.md
CHANGED
|
@@ -5,13 +5,44 @@ description: Casual English conversation practice with corrections.
|
|
|
5
5
|
|
|
6
6
|
# English Chat (英会話練習)
|
|
7
7
|
|
|
8
|
+
## Difficulty Level
|
|
9
|
+
|
|
10
|
+
Settings stored in `data/english.json`:
|
|
11
|
+
```json
|
|
12
|
+
{ "level": "beginner" }
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
On first activation, if `data/english.json` doesn't exist, ask the user to choose their level:
|
|
16
|
+
```
|
|
17
|
+
flex_message(template="action_buttons", data={
|
|
18
|
+
prompt: "英語レベルを選んでね!\nChoose your English level:",
|
|
19
|
+
buttons: [
|
|
20
|
+
{ label: "🌱 Beginner", text: "英語レベル beginner", style: "primary" },
|
|
21
|
+
{ label: "📚 Intermediate", text: "英語レベル intermediate", style: "primary" },
|
|
22
|
+
{ label: "🚀 Advanced", text: "英語レベル advanced", style: "primary" }
|
|
23
|
+
]
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Save the choice to `data/english.json`. User can change anytime with "レベル変更".
|
|
28
|
+
|
|
29
|
+
### Level behavior
|
|
30
|
+
|
|
31
|
+
| | Beginner | Intermediate | Advanced |
|
|
32
|
+
|---|---|---|---|
|
|
33
|
+
| Bot's vocab | Simple, common words | Natural, varied | Idioms, slang, nuance |
|
|
34
|
+
| Corrections | Only major grammar | Grammar + word choice | Everything incl. nuance |
|
|
35
|
+
| Japanese help | Always add 日本語 hints | On request only | Never unless asked |
|
|
36
|
+
| Sentence length | Short, simple | Natural | Complex, compound |
|
|
37
|
+
|
|
8
38
|
## Mode
|
|
9
39
|
|
|
10
40
|
When user says "英語モード" / "English mode" / "英会話":
|
|
11
41
|
|
|
12
|
-
1.
|
|
13
|
-
2.
|
|
14
|
-
3.
|
|
42
|
+
1. Read `data/english.json` for level (default: beginner if missing)
|
|
43
|
+
2. Reply in English, adapted to level
|
|
44
|
+
3. Gently correct mistakes (strictness based on level)
|
|
45
|
+
4. Offer Japanese translation based on level rules above
|
|
15
46
|
|
|
16
47
|
## Conversation Style
|
|
17
48
|
|
|
@@ -29,7 +60,7 @@ Only fix:
|
|
|
29
60
|
- Wrong word usage
|
|
30
61
|
- Natural phrasing
|
|
31
62
|
|
|
32
|
-
Skip minor stuff. Keep flow.
|
|
63
|
+
Adjust strictness per level. Skip minor stuff. Keep flow.
|
|
33
64
|
|
|
34
65
|
## Topic Selection
|
|
35
66
|
|
|
@@ -66,10 +97,28 @@ If user struggles:
|
|
|
66
97
|
How was your day? (今日どうだった?)
|
|
67
98
|
```
|
|
68
99
|
|
|
69
|
-
## Exit
|
|
100
|
+
## Exit & Session Summary
|
|
101
|
+
|
|
102
|
+
When user says "日本語に戻して" / "exit English" / "おわり":
|
|
103
|
+
|
|
104
|
+
1. Review the conversation and gather:
|
|
105
|
+
- Topics discussed
|
|
106
|
+
- Corrections you made (original → fixed)
|
|
107
|
+
- New vocabulary or phrases you introduced
|
|
108
|
+
- An encouraging comment about their performance
|
|
109
|
+
2. Send a session summary using `flex_message`:
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
flex_message(template="custom", data={
|
|
113
|
+
title: "📝 English Session",
|
|
114
|
+
body: "Topics: ...\n\nCorrections:\n❌ I go → ✅ I went\n❌ more easy → ✅ easier\n\nNew vocab:\n• commute (通勤する)\n• grab a bite (軽く食べる)\n\n💪 Great job! Your past tense is improving!",
|
|
115
|
+
header_color: "#4CAF50"
|
|
116
|
+
})
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
Keep it honest — if there were no corrections, say so. If there were many, pick the 3-5 most important ones.
|
|
70
120
|
|
|
71
|
-
|
|
72
|
-
Bot: "Sure! 英語練習お疲れ様!👍"
|
|
121
|
+
After the card, respond: "英語練習お疲れ様!👍"
|
|
73
122
|
|
|
74
123
|
## Tips
|
|
75
124
|
|
|
@@ -76,27 +76,44 @@ Skills use three-level loading:
|
|
|
76
76
|
|
|
77
77
|
If the skill produces output that would benefit from rich visual display (cards, progress trackers, summaries, confirmations), include `flex_message` tool usage in the SKILL.md.
|
|
78
78
|
|
|
79
|
-
Available templates: `fortune`, `info_card`, `action_buttons`, `receipt`, `morning_summary`, `hydration`.
|
|
79
|
+
Available templates: `fortune`, `info_card`, `action_buttons`, `receipt`, `morning_summary`, `hydration`, `custom`.
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
#### Custom template
|
|
82
|
+
|
|
83
|
+
Single card with auto-built layout:
|
|
82
84
|
```
|
|
83
85
|
flex_message(template="custom", data={
|
|
84
86
|
title: "カードタイトル",
|
|
85
87
|
body: "本文テキスト",
|
|
86
|
-
header_color: "#FF6B6B",
|
|
88
|
+
header_color: "#FF6B6B", // optional: colored header
|
|
89
|
+
button_label: "OK", // optional: single button shorthand
|
|
90
|
+
button_text: "送信テキスト",
|
|
91
|
+
// or use buttons array for multiple:
|
|
87
92
|
buttons: [
|
|
88
93
|
{ label: "ボタン", text: "送信テキスト", style: "primary" }
|
|
89
94
|
]
|
|
90
95
|
})
|
|
91
96
|
```
|
|
92
97
|
|
|
93
|
-
|
|
98
|
+
Carousel (horizontally swipeable cards):
|
|
99
|
+
```
|
|
100
|
+
flex_message(template="custom", data={
|
|
101
|
+
bubbles: [
|
|
102
|
+
{ type: "bubble", body: { type: "box", layout: "vertical", contents: [...] } },
|
|
103
|
+
{ type: "bubble", body: { type: "box", layout: "vertical", contents: [...] } }
|
|
104
|
+
]
|
|
105
|
+
})
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
#### Output section for skills using flex
|
|
109
|
+
|
|
110
|
+
The card is **auto-sent** when the tool returns. Include this in SKILL.md:
|
|
94
111
|
```markdown
|
|
95
112
|
## Output
|
|
96
113
|
|
|
97
114
|
**ALWAYS use the `flex_message` tool** to display results as a rich card.
|
|
98
|
-
|
|
115
|
+
The card is sent automatically — do NOT repeat the JSON. Just respond naturally after calling the tool.
|
|
99
116
|
```
|
|
100
117
|
|
|
101
|
-
Good candidates for flex: trackers, reminders, summaries, confirmations, selections.
|
|
118
|
+
Good candidates for flex: trackers, reminders, summaries, confirmations, selections, lists.
|
|
102
119
|
Not needed for: conversational replies, simple text answers, file operations.
|