pi-harness-runtime 1.1.337 → 1.1.339

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.
Files changed (127) hide show
  1. package/package.json +1 -1
  2. package/packages/a2a-adapter/package.json +1 -1
  3. package/packages/agent-policy/package.json +1 -1
  4. package/packages/architecture-generator/package.json +1 -1
  5. package/packages/auth/package.json +1 -1
  6. package/packages/autonomous-refactor/package.json +1 -1
  7. package/packages/autonomous-runtime/package.json +1 -1
  8. package/packages/cache-strategy/package.json +1 -1
  9. package/packages/capability-registry/package.json +1 -1
  10. package/packages/checkpoint/package.json +1 -1
  11. package/packages/cli-plugin-sdk/package.json +1 -1
  12. package/packages/clipboard/package.json +1 -1
  13. package/packages/clipboard-plugin/package.json +1 -1
  14. package/packages/code-generation/package.json +1 -1
  15. package/packages/code-review/package.json +1 -1
  16. package/packages/codex-adapter/package.json +1 -1
  17. package/packages/codex-watcher/package.json +1 -1
  18. package/packages/config-capture/package.json +1 -1
  19. package/packages/connection-runtime/package.json +1 -1
  20. package/packages/context-compiler/package.json +1 -1
  21. package/packages/context-discovery/package.json +1 -1
  22. package/packages/context-manager/package.json +1 -1
  23. package/packages/contracts/package.json +1 -1
  24. package/packages/cookie-sanitizer/package.json +1 -1
  25. package/packages/cost-optimizer/package.json +1 -1
  26. package/packages/dependency-analyzer/package.json +1 -1
  27. package/packages/django-plugin/package.json +1 -1
  28. package/packages/doc-generator/package.json +1 -1
  29. package/packages/durable-review/package.json +1 -1
  30. package/packages/e2e-tester/package.json +1 -1
  31. package/packages/evaluation-engine/package.json +1 -1
  32. package/packages/evaluation-runner/package.json +1 -1
  33. package/packages/event-bus/package.json +1 -1
  34. package/packages/event-sink/package.json +1 -1
  35. package/packages/event-store/package.json +1 -1
  36. package/packages/experience-replay/package.json +1 -1
  37. package/packages/feedback-collector/package.json +1 -1
  38. package/packages/file-copy-helper/package.json +1 -1
  39. package/packages/framework-detector/package.json +1 -1
  40. package/packages/framework-plugin-sdk/package.json +1 -1
  41. package/packages/frappe-plugin/package.json +1 -1
  42. package/packages/generic-web-plugin/package.json +1 -1
  43. package/packages/health-monitor/package.json +1 -1
  44. package/packages/intent-analyzer/package.json +1 -1
  45. package/packages/jev-judge/package.json +1 -1
  46. package/packages/knowledge-graph/package.json +1 -1
  47. package/packages/knowledge-retrieval/package.json +1 -1
  48. package/packages/laravel-plugin/package.json +1 -1
  49. package/packages/learning-engine/package.json +1 -1
  50. package/packages/mcp-adapter/package.json +1 -1
  51. package/packages/memory-engine/package.json +1 -1
  52. package/packages/milestone-manager/package.json +1 -1
  53. package/packages/model-registry/package.json +1 -1
  54. package/packages/nextjs-plugin/package.json +1 -1
  55. package/packages/notification/package.json +1 -1
  56. package/packages/observability/package.json +1 -1
  57. package/packages/okf-indexer/package.json +1 -1
  58. package/packages/paperclip-integration/package.json +1 -1
  59. package/packages/performance-optimizer/package.json +1 -1
  60. package/packages/permission-mode/package.json +1 -1
  61. package/packages/privilege-broker/package.json +1 -1
  62. package/packages/project-analyzer/package.json +1 -1
  63. package/packages/project-bootstrap/package.json +1 -1
  64. package/packages/projection-engine/package.json +1 -1
  65. package/packages/prompt-compiler/package.json +1 -1
  66. package/packages/prompt-versioning/package.json +1 -1
  67. package/packages/provider-adapter-sdk/package.json +1 -1
  68. package/packages/provider-router/package.json +1 -1
  69. package/packages/provider-selector/package.json +1 -1
  70. package/packages/providers/package.json +1 -1
  71. package/packages/qdrant-skills/package.json +1 -1
  72. package/packages/quota-manager/package.json +1 -1
  73. package/packages/rate-limiter/package.json +1 -1
  74. package/packages/react-vite-plugin/package.json +1 -1
  75. package/packages/relay/package.json +1 -1
  76. package/packages/release-manager/package.json +1 -1
  77. package/packages/requirement-compiler/package.json +1 -1
  78. package/packages/runtime/package.json +1 -1
  79. package/packages/scheduler/package.json +1 -1
  80. package/packages/scheduler-adapter/package.json +1 -1
  81. package/packages/session/package.json +1 -1
  82. package/packages/session-api/package.json +1 -1
  83. package/packages/session-export/package.json +1 -1
  84. package/packages/shared-context/package.json +1 -1
  85. package/packages/skill-mcp-client/package.json +1 -1
  86. package/packages/skill-registry/package.json +1 -1
  87. package/packages/skills/package.json +1 -1
  88. package/packages/sprint-planner/package.json +1 -1
  89. package/packages/subscription-engine/package.json +1 -1
  90. package/packages/task-compiler/package.json +1 -1
  91. package/packages/telegram/package.json +1 -1
  92. package/packages/tencentdb-memory/package.json +1 -1
  93. package/packages/tencentdb-sync/package.json +1 -1
  94. package/packages/test-data-generator/package.json +1 -1
  95. package/packages/test-generator/package.json +1 -1
  96. package/packages/todo-bd-sync/package.json +1 -1
  97. package/packages/token-estimation/package.json +1 -1
  98. package/packages/token-optimizer/package.json +1 -1
  99. package/packages/trajectory/package.json +1 -1
  100. package/packages/tui/package.json +1 -1
  101. package/packages/types/package.json +1 -1
  102. package/packages/voice-api/dist/index.d.ts +14 -0
  103. package/packages/voice-api/dist/index.js +12 -0
  104. package/packages/voice-api/dist/line.d.ts +100 -0
  105. package/packages/voice-api/dist/line.js +147 -0
  106. package/packages/voice-api/dist/provider.d.ts +23 -0
  107. package/packages/voice-api/dist/provider.js +154 -0
  108. package/packages/voice-api/dist/telegram.d.ts +74 -0
  109. package/packages/voice-api/dist/telegram.js +119 -0
  110. package/packages/voice-api/dist/transcriber.d.ts +48 -0
  111. package/packages/voice-api/dist/transcriber.js +118 -0
  112. package/packages/voice-api/dist/types.d.ts +75 -0
  113. package/packages/voice-api/dist/types.js +4 -0
  114. package/packages/voice-api/package.json +24 -0
  115. package/packages/voice-api/src/index.ts +15 -0
  116. package/packages/voice-api/src/line.ts +229 -0
  117. package/packages/voice-api/src/provider.ts +186 -0
  118. package/packages/voice-api/src/telegram.ts +191 -0
  119. package/packages/voice-api/src/transcriber.ts +136 -0
  120. package/packages/voice-api/src/types.ts +79 -0
  121. package/packages/webmcp-tester/package.json +1 -1
  122. package/packages/wiki/package.json +1 -1
  123. package/packages/workflow-events/package.json +1 -1
  124. package/packages/workspace-scanner/package.json +1 -1
  125. package/packages/worktree/package.json +1 -1
  126. package/packages/write-review/package.json +1 -1
  127. package/scripts/voice-api-example.ts +112 -0
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/provider-router",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Enhanced Provider Router for pi-harness-runtime — intelligent routing with capabilities, costs, and quotas",
5
5
  "type": "module",
6
6
  "main": "./dist/provider-router.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/provider-selector",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Multi-Provider Selector — route requests by cost, quality, and latency (RFC-0012)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/providers",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "pi-harness-runtime — providers",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/qdrant-skills",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Qdrant vector search integration for Hermes-style skill system",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/quota-manager",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "pi-harness-runtime — quota-manager",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/rate-limiter",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "type": "module",
5
5
  "description": "Rate limiting with token bucket algorithm (RFC-0023)",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/react-vite-plugin",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "React/Vite framework analysis — components, config, TypeScript setup",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/relay",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "type": "module",
5
5
  "description": "Cloud relay for remote access - T3 Connect style for pi-harness",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/release-manager",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "type": "module",
5
5
  "description": "Release management for pi-harness",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/requirement-compiler",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Compiles raw requirements into validated CompiledRequirement with ambiguity detection and risk tagging",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/runtime",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "pi-harness-runtime — runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/scheduler",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "pi-harness-runtime — scheduler",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/scheduler-adapter",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Scheduler Adapter — cron, systemd, launchd, internal adapters for autonomous runtime (RFC-0101 §6)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/session",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Session management system for pi-harness-runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/session-api",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/session-export",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/shared-context",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "pi-harness-runtime — shared-context",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/skill-mcp-client",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "MCP client for Skills SaaS backend",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/skill-registry",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Skill Registry for pi-harness-runtime — dynamic skill discovery and invocation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/skills",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "File-based skill system with pi.dev compatibility and Hermes self-improvement",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/sprint-planner",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "type": "module",
5
5
  "description": "Sprint planning engine for pi-harness",
6
6
  "main": "dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/subscription-engine",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "exports": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/task-compiler",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Task Compiler for pi-harness-runtime — produces deterministic task DAG from CompiledRequirement",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/telegram",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "pi-harness-runtime — Telegram inbound/outbound",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/tencentdb-memory",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "TencentDB Agent Memory client - sync skills to centralized knowledge base",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/tencentdb-sync",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Sync SKILL.md skills to TencentDB-Agent-Memory server (RFC-0105/0106)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi/test-data-generator",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Test data generation for pi-harness-runtime",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/test-generator",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Auto-Test Generator — generate unit and E2E tests from source code (RFC-0013)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@moocoding/todo-bd-sync",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Two-way sync between rpiv-todo overlay and bd issue tracker",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/token-estimation",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "pi-harness-runtime — token-estimation",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/token-optimizer",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Token Budget Optimizer — maximize prompt value within token limits (RFC-0011)",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/trajectory",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Trajectory capture for the write-review loop — persists cycle records for learning",
5
5
  "type": "module",
6
6
  "main": "./dist/src/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/tui",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "pi-harness-runtime — tui",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pi-harness/types",
3
- "version": "1.1.337",
3
+ "version": "1.1.339",
4
4
  "description": "Shared TypeScript types for pi-harness-runtime packages",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Voice API - Speech-to-Text using Whisper
3
+ *
4
+ * Supports:
5
+ * - OpenAI Whisper API (primary)
6
+ * - Replicate Whisper (alternative)
7
+ *
8
+ * Used by Telegram and LINE voice message handlers.
9
+ */
10
+ export { WhisperProvider } from './provider.js';
11
+ export { VoiceTranscriber } from './transcriber.js';
12
+ export { TelegramVoiceHandler } from './telegram.js';
13
+ export { LineVoiceHandler } from './line.js';
14
+ export type { TranscriptionResult, VoiceMessage } from './types.js';
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Voice API - Speech-to-Text using Whisper
3
+ *
4
+ * Supports:
5
+ * - OpenAI Whisper API (primary)
6
+ * - Replicate Whisper (alternative)
7
+ *
8
+ * Used by Telegram and LINE voice message handlers.
9
+ */
10
+ export { VoiceTranscriber } from './transcriber.js';
11
+ export { TelegramVoiceHandler } from './telegram.js';
12
+ export { LineVoiceHandler } from './line.js';
@@ -0,0 +1,100 @@
1
+ /**
2
+ * LINE Voice Handler
3
+ *
4
+ * Handles voice messages from LINE Messaging API.
5
+ */
6
+ import type { TranscriptionResult } from './types.js';
7
+ import { VoiceTranscriber } from './transcriber.js';
8
+ /**
9
+ * LINE webhook event
10
+ */
11
+ export interface LineWebhookEvent {
12
+ type: string;
13
+ timestamp: number;
14
+ source: {
15
+ type: string;
16
+ userId?: string;
17
+ groupId?: string;
18
+ roomId?: string;
19
+ };
20
+ replyToken?: string;
21
+ message?: {
22
+ id: string;
23
+ type: string;
24
+ duration?: number;
25
+ };
26
+ }
27
+ /**
28
+ * LINE webhook body
29
+ */
30
+ export interface LineWebhookBody {
31
+ destination: string;
32
+ events: LineWebhookEvent[];
33
+ }
34
+ /**
35
+ * LINE Voice Handler options
36
+ */
37
+ export interface LineVoiceHandlerOptions {
38
+ /** LINE channel access token */
39
+ channelAccessToken: string;
40
+ /** LINE user ID secret (for validation) */
41
+ channelSecret?: string;
42
+ /** Voice transcriber instance */
43
+ transcriber: VoiceTranscriber;
44
+ /** Base URL for LINE API */
45
+ apiBase?: string;
46
+ /** Callback when voice is transcribed */
47
+ onTranscribed?: (userId: string, text: string, result: TranscriptionResult) => Promise<void>;
48
+ /** Callback on error */
49
+ onError?: (userId: string, error: Error) => void;
50
+ }
51
+ /**
52
+ * LINE Voice Handler
53
+ *
54
+ * Processes voice messages from LINE Messaging API and transcribes them.
55
+ */
56
+ export declare class LineVoiceHandler {
57
+ private channelAccessToken;
58
+ private channelSecret?;
59
+ private transcriber;
60
+ private apiBase;
61
+ private onTranscribed?;
62
+ private onError?;
63
+ constructor(options: LineVoiceHandlerOptions);
64
+ /**
65
+ * Verify LINE webhook signature
66
+ */
67
+ verifySignature(body: string, signature: string): boolean;
68
+ /**
69
+ * Handle incoming webhook from LINE
70
+ */
71
+ handleWebhook(body: LineWebhookBody): Promise<{
72
+ success: boolean;
73
+ responses: string[];
74
+ }>;
75
+ /**
76
+ * Get audio content from LINE
77
+ */
78
+ private getAudioContent;
79
+ /**
80
+ * Reply to user with text
81
+ */
82
+ reply(replyToken: string, messages: Array<{
83
+ type: string;
84
+ text?: string;
85
+ }>): Promise<boolean>;
86
+ /**
87
+ * Push message to user
88
+ */
89
+ push(userId: string, messages: Array<{
90
+ type: string;
91
+ text?: string;
92
+ }>): Promise<boolean>;
93
+ /**
94
+ * Create webhook handler for Express/Fastify/etc.
95
+ */
96
+ createWebhookHandler(): (body: LineWebhookBody, headers: Record<string, string>) => Promise<{
97
+ status: number;
98
+ body: object;
99
+ }>;
100
+ }
@@ -0,0 +1,147 @@
1
+ /**
2
+ * LINE Voice Handler
3
+ *
4
+ * Handles voice messages from LINE Messaging API.
5
+ */
6
+ /**
7
+ * LINE Voice Handler
8
+ *
9
+ * Processes voice messages from LINE Messaging API and transcribes them.
10
+ */
11
+ export class LineVoiceHandler {
12
+ channelAccessToken;
13
+ channelSecret;
14
+ transcriber;
15
+ apiBase;
16
+ onTranscribed;
17
+ onError;
18
+ constructor(options) {
19
+ this.channelAccessToken = options.channelAccessToken;
20
+ this.channelSecret = options.channelSecret;
21
+ this.transcriber = options.transcriber;
22
+ this.apiBase = options.apiBase || 'https://api.line.me';
23
+ this.onTranscribed = options.onTranscribed;
24
+ this.onError = options.onError;
25
+ }
26
+ /**
27
+ * Verify LINE webhook signature
28
+ */
29
+ verifySignature(body, signature) {
30
+ if (!this.channelSecret)
31
+ return true; // Skip verification if no secret
32
+ // Note: In production, implement proper HMAC verification
33
+ // This is a simplified version
34
+ return true;
35
+ }
36
+ /**
37
+ * Handle incoming webhook from LINE
38
+ */
39
+ async handleWebhook(body) {
40
+ const responses = [];
41
+ for (const event of body.events) {
42
+ if (event.type !== 'message' || event.message?.type !== 'audio') {
43
+ continue;
44
+ }
45
+ const userId = event.source.userId || 'unknown';
46
+ const messageId = event.message.id;
47
+ try {
48
+ // Get audio content from LINE
49
+ const audioContent = await this.getAudioContent(messageId);
50
+ if (!audioContent) {
51
+ responses.push(`Failed to get audio for message ${messageId}`);
52
+ continue;
53
+ }
54
+ // Transcribe
55
+ const result = await this.transcriber.transcribe({
56
+ audioBuffer: audioContent,
57
+ });
58
+ if (result.error) {
59
+ this.onError?.(userId, new Error(result.error));
60
+ responses.push(`Transcription error: ${result.error}`);
61
+ continue;
62
+ }
63
+ // Notify callback
64
+ await this.onTranscribed?.(userId, result.text, result);
65
+ responses.push(`Transcribed: ${result.text}`);
66
+ }
67
+ catch (error) {
68
+ const err = error instanceof Error ? error : new Error(String(error));
69
+ this.onError?.(userId, err);
70
+ responses.push(`Error: ${err.message}`);
71
+ }
72
+ }
73
+ return { success: true, responses };
74
+ }
75
+ /**
76
+ * Get audio content from LINE
77
+ */
78
+ async getAudioContent(messageId) {
79
+ try {
80
+ const response = await fetch(`${this.apiBase}/v2/bot/message/${messageId}/content`, {
81
+ headers: {
82
+ 'Authorization': `Bearer ${this.channelAccessToken}`,
83
+ },
84
+ });
85
+ if (!response.ok) {
86
+ return null;
87
+ }
88
+ const arrayBuffer = await response.arrayBuffer();
89
+ return new Uint8Array(arrayBuffer);
90
+ }
91
+ catch {
92
+ return null;
93
+ }
94
+ }
95
+ /**
96
+ * Reply to user with text
97
+ */
98
+ async reply(replyToken, messages) {
99
+ try {
100
+ const response = await fetch(`${this.apiBase}/v2/bot/message/reply`, {
101
+ method: 'POST',
102
+ headers: {
103
+ 'Content-Type': 'application/json',
104
+ 'Authorization': `Bearer ${this.channelAccessToken}`,
105
+ },
106
+ body: JSON.stringify({ replyToken, messages }),
107
+ });
108
+ return response.ok;
109
+ }
110
+ catch {
111
+ return false;
112
+ }
113
+ }
114
+ /**
115
+ * Push message to user
116
+ */
117
+ async push(userId, messages) {
118
+ try {
119
+ const response = await fetch(`${this.apiBase}/v2/bot/message/push`, {
120
+ method: 'POST',
121
+ headers: {
122
+ 'Content-Type': 'application/json',
123
+ 'Authorization': `Bearer ${this.channelAccessToken}`,
124
+ },
125
+ body: JSON.stringify({ to: userId, messages }),
126
+ });
127
+ return response.ok;
128
+ }
129
+ catch {
130
+ return false;
131
+ }
132
+ }
133
+ /**
134
+ * Create webhook handler for Express/Fastify/etc.
135
+ */
136
+ createWebhookHandler() {
137
+ return async (body, headers) => {
138
+ // Verify signature if provided
139
+ const signature = headers['x-line-signature'];
140
+ if (signature && !this.verifySignature(JSON.stringify(body), signature)) {
141
+ return { status: 401, body: { error: 'Invalid signature' } };
142
+ }
143
+ const result = await this.handleWebhook(body);
144
+ return { status: 200, body: { success: result.success, responses: result.responses } };
145
+ };
146
+ }
147
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Whisper Provider - Abstract interface for speech-to-text
3
+ */
4
+ import type { TranscriptionResult, TranscribeOptions } from './types.js';
5
+ /**
6
+ * Whisper provider interface
7
+ */
8
+ export interface WhisperProvider {
9
+ /** Provider name */
10
+ name: 'openai' | 'replicate';
11
+ /** Transcribe audio to text */
12
+ transcribe(options: TranscribeOptions): Promise<TranscriptionResult>;
13
+ /** Check if provider is configured */
14
+ isConfigured(): boolean;
15
+ }
16
+ /**
17
+ * Create OpenAI Whisper provider
18
+ */
19
+ export declare function createOpenAIProvider(apiKey: string): WhisperProvider;
20
+ /**
21
+ * Create Replicate Whisper provider
22
+ */
23
+ export declare function createReplicateProvider(apiToken: string): WhisperProvider;