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.
- package/package.json +1 -1
- package/packages/a2a-adapter/package.json +1 -1
- package/packages/agent-policy/package.json +1 -1
- package/packages/architecture-generator/package.json +1 -1
- package/packages/auth/package.json +1 -1
- package/packages/autonomous-refactor/package.json +1 -1
- package/packages/autonomous-runtime/package.json +1 -1
- package/packages/cache-strategy/package.json +1 -1
- package/packages/capability-registry/package.json +1 -1
- package/packages/checkpoint/package.json +1 -1
- package/packages/cli-plugin-sdk/package.json +1 -1
- package/packages/clipboard/package.json +1 -1
- package/packages/clipboard-plugin/package.json +1 -1
- package/packages/code-generation/package.json +1 -1
- package/packages/code-review/package.json +1 -1
- package/packages/codex-adapter/package.json +1 -1
- package/packages/codex-watcher/package.json +1 -1
- package/packages/config-capture/package.json +1 -1
- package/packages/connection-runtime/package.json +1 -1
- package/packages/context-compiler/package.json +1 -1
- package/packages/context-discovery/package.json +1 -1
- package/packages/context-manager/package.json +1 -1
- package/packages/contracts/package.json +1 -1
- package/packages/cookie-sanitizer/package.json +1 -1
- package/packages/cost-optimizer/package.json +1 -1
- package/packages/dependency-analyzer/package.json +1 -1
- package/packages/django-plugin/package.json +1 -1
- package/packages/doc-generator/package.json +1 -1
- package/packages/durable-review/package.json +1 -1
- package/packages/e2e-tester/package.json +1 -1
- package/packages/evaluation-engine/package.json +1 -1
- package/packages/evaluation-runner/package.json +1 -1
- package/packages/event-bus/package.json +1 -1
- package/packages/event-sink/package.json +1 -1
- package/packages/event-store/package.json +1 -1
- package/packages/experience-replay/package.json +1 -1
- package/packages/feedback-collector/package.json +1 -1
- package/packages/file-copy-helper/package.json +1 -1
- package/packages/framework-detector/package.json +1 -1
- package/packages/framework-plugin-sdk/package.json +1 -1
- package/packages/frappe-plugin/package.json +1 -1
- package/packages/generic-web-plugin/package.json +1 -1
- package/packages/health-monitor/package.json +1 -1
- package/packages/intent-analyzer/package.json +1 -1
- package/packages/jev-judge/package.json +1 -1
- package/packages/knowledge-graph/package.json +1 -1
- package/packages/knowledge-retrieval/package.json +1 -1
- package/packages/laravel-plugin/package.json +1 -1
- package/packages/learning-engine/package.json +1 -1
- package/packages/mcp-adapter/package.json +1 -1
- package/packages/memory-engine/package.json +1 -1
- package/packages/milestone-manager/package.json +1 -1
- package/packages/model-registry/package.json +1 -1
- package/packages/nextjs-plugin/package.json +1 -1
- package/packages/notification/package.json +1 -1
- package/packages/observability/package.json +1 -1
- package/packages/okf-indexer/package.json +1 -1
- package/packages/paperclip-integration/package.json +1 -1
- package/packages/performance-optimizer/package.json +1 -1
- package/packages/permission-mode/package.json +1 -1
- package/packages/privilege-broker/package.json +1 -1
- package/packages/project-analyzer/package.json +1 -1
- package/packages/project-bootstrap/package.json +1 -1
- package/packages/projection-engine/package.json +1 -1
- package/packages/prompt-compiler/package.json +1 -1
- package/packages/prompt-versioning/package.json +1 -1
- package/packages/provider-adapter-sdk/package.json +1 -1
- package/packages/provider-router/package.json +1 -1
- package/packages/provider-selector/package.json +1 -1
- package/packages/providers/package.json +1 -1
- package/packages/qdrant-skills/package.json +1 -1
- package/packages/quota-manager/package.json +1 -1
- package/packages/rate-limiter/package.json +1 -1
- package/packages/react-vite-plugin/package.json +1 -1
- package/packages/relay/package.json +1 -1
- package/packages/release-manager/package.json +1 -1
- package/packages/requirement-compiler/package.json +1 -1
- package/packages/runtime/package.json +1 -1
- package/packages/scheduler/package.json +1 -1
- package/packages/scheduler-adapter/package.json +1 -1
- package/packages/session/package.json +1 -1
- package/packages/session-api/package.json +1 -1
- package/packages/session-export/package.json +1 -1
- package/packages/shared-context/package.json +1 -1
- package/packages/skill-mcp-client/package.json +1 -1
- package/packages/skill-registry/package.json +1 -1
- package/packages/skills/package.json +1 -1
- package/packages/sprint-planner/package.json +1 -1
- package/packages/subscription-engine/package.json +1 -1
- package/packages/task-compiler/package.json +1 -1
- package/packages/telegram/package.json +1 -1
- package/packages/tencentdb-memory/package.json +1 -1
- package/packages/tencentdb-sync/package.json +1 -1
- package/packages/test-data-generator/package.json +1 -1
- package/packages/test-generator/package.json +1 -1
- package/packages/todo-bd-sync/package.json +1 -1
- package/packages/token-estimation/package.json +1 -1
- package/packages/token-optimizer/package.json +1 -1
- package/packages/trajectory/package.json +1 -1
- package/packages/tui/package.json +1 -1
- package/packages/types/package.json +1 -1
- package/packages/voice-api/dist/index.d.ts +14 -0
- package/packages/voice-api/dist/index.js +12 -0
- package/packages/voice-api/dist/line.d.ts +100 -0
- package/packages/voice-api/dist/line.js +147 -0
- package/packages/voice-api/dist/provider.d.ts +23 -0
- package/packages/voice-api/dist/provider.js +154 -0
- package/packages/voice-api/dist/telegram.d.ts +74 -0
- package/packages/voice-api/dist/telegram.js +119 -0
- package/packages/voice-api/dist/transcriber.d.ts +48 -0
- package/packages/voice-api/dist/transcriber.js +118 -0
- package/packages/voice-api/dist/types.d.ts +75 -0
- package/packages/voice-api/dist/types.js +4 -0
- package/packages/voice-api/package.json +24 -0
- package/packages/voice-api/src/index.ts +15 -0
- package/packages/voice-api/src/line.ts +229 -0
- package/packages/voice-api/src/provider.ts +186 -0
- package/packages/voice-api/src/telegram.ts +191 -0
- package/packages/voice-api/src/transcriber.ts +136 -0
- package/packages/voice-api/src/types.ts +79 -0
- package/packages/webmcp-tester/package.json +1 -1
- package/packages/wiki/package.json +1 -1
- package/packages/workflow-events/package.json +1 -1
- package/packages/workspace-scanner/package.json +1 -1
- package/packages/worktree/package.json +1 -1
- package/packages/write-review/package.json +1 -1
- 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.
|
|
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",
|
|
@@ -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;
|