@pellux/goodvibes-sdk 0.25.6 → 0.25.8
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/_internal/contracts/artifacts/operator-contract.json +280 -4
- package/dist/_internal/contracts/generated/foundation-metadata.d.ts +2 -2
- package/dist/_internal/contracts/generated/foundation-metadata.js +2 -2
- package/dist/_internal/contracts/generated/operator-contract.d.ts.map +1 -1
- package/dist/_internal/contracts/generated/operator-contract.js +280 -4
- package/dist/_internal/contracts/generated/operator-method-ids.d.ts +1 -1
- package/dist/_internal/contracts/generated/operator-method-ids.d.ts.map +1 -1
- package/dist/_internal/contracts/generated/operator-method-ids.js +2 -0
- package/dist/_internal/contracts/zod-schemas/providers.d.ts +132 -0
- package/dist/_internal/contracts/zod-schemas/providers.d.ts.map +1 -1
- package/dist/_internal/contracts/zod-schemas/providers.js +16 -0
- package/dist/_internal/daemon/context.d.ts +1 -0
- package/dist/_internal/daemon/context.d.ts.map +1 -1
- package/dist/_internal/daemon/media-route-types.d.ts +10 -0
- package/dist/_internal/daemon/media-route-types.d.ts.map +1 -1
- package/dist/_internal/daemon/media-routes.d.ts +1 -1
- package/dist/_internal/daemon/media-routes.d.ts.map +1 -1
- package/dist/_internal/daemon/media-routes.js +91 -10
- package/dist/_internal/daemon/operator.d.ts +1 -1
- package/dist/_internal/daemon/operator.d.ts.map +1 -1
- package/dist/_internal/daemon/operator.js +2 -0
- package/dist/_internal/platform/adapters/ntfy/index.js +13 -2
- package/dist/_internal/platform/adapters/types.d.ts +2 -0
- package/dist/_internal/platform/adapters/types.d.ts.map +1 -1
- package/dist/_internal/platform/batch/index.d.ts +4 -0
- package/dist/_internal/platform/batch/index.d.ts.map +1 -0
- package/dist/_internal/platform/batch/index.js +2 -0
- package/dist/_internal/platform/batch/manager.d.ts +41 -0
- package/dist/_internal/platform/batch/manager.d.ts.map +1 -0
- package/dist/_internal/platform/batch/manager.js +400 -0
- package/dist/_internal/platform/batch/types.d.ts +85 -0
- package/dist/_internal/platform/batch/types.d.ts.map +1 -0
- package/dist/_internal/platform/batch/types.js +10 -0
- package/dist/_internal/platform/channels/builtin/plugins.d.ts.map +1 -1
- package/dist/_internal/platform/channels/builtin/plugins.js +1 -0
- package/dist/_internal/platform/channels/reply-pipeline.d.ts +9 -1
- package/dist/_internal/platform/channels/reply-pipeline.d.ts.map +1 -1
- package/dist/_internal/platform/channels/reply-pipeline.js +156 -6
- package/dist/_internal/platform/companion/companion-chat-manager.d.ts +2 -1
- package/dist/_internal/platform/companion/companion-chat-manager.d.ts.map +1 -1
- package/dist/_internal/platform/companion/companion-chat-manager.js +21 -0
- package/dist/_internal/platform/companion/companion-chat-routes.d.ts +1 -0
- package/dist/_internal/platform/companion/companion-chat-routes.d.ts.map +1 -1
- package/dist/_internal/platform/companion/companion-chat-routes.js +76 -0
- package/dist/_internal/platform/companion/companion-chat-types.d.ts +9 -0
- package/dist/_internal/platform/companion/companion-chat-types.d.ts.map +1 -1
- package/dist/_internal/platform/companion/index.d.ts +1 -1
- package/dist/_internal/platform/companion/index.d.ts.map +1 -1
- package/dist/_internal/platform/config/schema-domain-core.d.ts +6 -0
- package/dist/_internal/platform/config/schema-domain-core.d.ts.map +1 -1
- package/dist/_internal/platform/config/schema-domain-core.js +30 -0
- package/dist/_internal/platform/config/schema-domain-runtime.d.ts +19 -0
- package/dist/_internal/platform/config/schema-domain-runtime.d.ts.map +1 -1
- package/dist/_internal/platform/config/schema-domain-runtime.js +118 -0
- package/dist/_internal/platform/config/schema-types.d.ts +33 -2
- package/dist/_internal/platform/config/schema-types.d.ts.map +1 -1
- package/dist/_internal/platform/config/schema.d.ts.map +1 -1
- package/dist/_internal/platform/config/schema.js +3 -0
- package/dist/_internal/platform/control-plane/method-catalog-control-core.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/method-catalog-control-core.js +17 -0
- package/dist/_internal/platform/control-plane/method-catalog-media.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/method-catalog-media.js +17 -0
- package/dist/_internal/platform/control-plane/routes/operator.d.ts +1 -1
- package/dist/_internal/platform/control-plane/routes/operator.d.ts.map +1 -1
- package/dist/_internal/platform/control-plane/routes/operator.js +2 -0
- package/dist/_internal/platform/daemon/facade-composition.d.ts +2 -0
- package/dist/_internal/platform/daemon/facade-composition.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/facade-composition.js +10 -0
- package/dist/_internal/platform/daemon/http/batch-routes.d.ts +8 -0
- package/dist/_internal/platform/daemon/http/batch-routes.d.ts.map +1 -0
- package/dist/_internal/platform/daemon/http/batch-routes.js +113 -0
- package/dist/_internal/platform/daemon/http/provider-routes.d.ts +3 -0
- package/dist/_internal/platform/daemon/http/provider-routes.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/http/provider-routes.js +79 -20
- package/dist/_internal/platform/daemon/http/router-route-contexts.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/http/router-route-contexts.js +1 -0
- package/dist/_internal/platform/daemon/http/router.d.ts +4 -0
- package/dist/_internal/platform/daemon/http/router.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/http/router.js +15 -0
- package/dist/_internal/platform/daemon/http/runtime-route-types.d.ts +2 -0
- package/dist/_internal/platform/daemon/http/runtime-route-types.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/surface-actions.d.ts +6 -0
- package/dist/_internal/platform/daemon/surface-actions.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/surface-actions.js +13 -0
- package/dist/_internal/platform/daemon/surface-delivery.d.ts +3 -0
- package/dist/_internal/platform/daemon/surface-delivery.d.ts.map +1 -1
- package/dist/_internal/platform/daemon/surface-delivery.js +42 -6
- package/dist/_internal/platform/daemon/types.d.ts +2 -0
- package/dist/_internal/platform/daemon/types.d.ts.map +1 -1
- package/dist/_internal/platform/providers/anthropic.d.ts +13 -1
- package/dist/_internal/platform/providers/anthropic.d.ts.map +1 -1
- package/dist/_internal/platform/providers/anthropic.js +219 -1
- package/dist/_internal/platform/providers/interface.d.ts +48 -0
- package/dist/_internal/platform/providers/interface.d.ts.map +1 -1
- package/dist/_internal/platform/providers/openai.d.ts +13 -1
- package/dist/_internal/platform/providers/openai.d.ts.map +1 -1
- package/dist/_internal/platform/providers/openai.js +189 -1
- package/dist/_internal/platform/version.js +1 -1
- package/dist/_internal/platform/voice/index.d.ts +1 -1
- package/dist/_internal/platform/voice/index.d.ts.map +1 -1
- package/dist/_internal/platform/voice/providers/elevenlabs.d.ts.map +1 -1
- package/dist/_internal/platform/voice/providers/elevenlabs.js +150 -4
- package/dist/_internal/platform/voice/service.d.ts +2 -1
- package/dist/_internal/platform/voice/service.d.ts.map +1 -1
- package/dist/_internal/platform/voice/service.js +7 -0
- package/dist/_internal/platform/voice/types.d.ts +18 -1
- package/dist/_internal/platform/voice/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/workers.d.ts +40 -0
- package/dist/workers.d.ts.map +1 -0
- package/dist/workers.js +144 -0
- package/package.json +5 -1
package/dist/workers.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
export function createGoodVibesCloudflareWorker(options = {}) {
|
|
2
|
+
return {
|
|
3
|
+
async fetch(request, env, _ctx) {
|
|
4
|
+
const url = new URL(request.url);
|
|
5
|
+
if (url.pathname === '/health' || url.pathname === '/batch/health') {
|
|
6
|
+
return json({ ok: true, service: 'goodvibes-cloudflare-worker' });
|
|
7
|
+
}
|
|
8
|
+
if (url.pathname === '/batch/tick/enqueue' && request.method === 'POST') {
|
|
9
|
+
const queue = env.GOODVIBES_BATCH_QUEUE;
|
|
10
|
+
if (!queue)
|
|
11
|
+
return json({ error: 'GOODVIBES_BATCH_QUEUE is not bound', code: 'QUEUE_NOT_CONFIGURED' }, 503);
|
|
12
|
+
const body = await optionalJson(request);
|
|
13
|
+
await queue.send({
|
|
14
|
+
type: 'batch.tick',
|
|
15
|
+
force: toRecord(body)['force'] === true,
|
|
16
|
+
enqueuedAt: Date.now(),
|
|
17
|
+
});
|
|
18
|
+
return json({ queued: true }, 202);
|
|
19
|
+
}
|
|
20
|
+
const daemonPath = toDaemonBatchPath(url.pathname);
|
|
21
|
+
if (!daemonPath)
|
|
22
|
+
return json({ error: 'Not found', code: 'NOT_FOUND' }, 404);
|
|
23
|
+
if (url.pathname === '/batch/jobs/enqueue' && request.method === 'POST') {
|
|
24
|
+
if (!options.queueJobPayloads) {
|
|
25
|
+
return json({
|
|
26
|
+
error: 'Queueing full batch job payloads is disabled. Post /batch/jobs to proxy directly to the daemon, or enable queueJobPayloads explicitly.',
|
|
27
|
+
code: 'QUEUE_PAYLOADS_DISABLED',
|
|
28
|
+
}, 409);
|
|
29
|
+
}
|
|
30
|
+
const queue = env.GOODVIBES_BATCH_QUEUE;
|
|
31
|
+
if (!queue)
|
|
32
|
+
return json({ error: 'GOODVIBES_BATCH_QUEUE is not bound', code: 'QUEUE_NOT_CONFIGURED' }, 503);
|
|
33
|
+
const body = await optionalJson(request);
|
|
34
|
+
await queue.send({
|
|
35
|
+
type: 'batch.job.create',
|
|
36
|
+
body: toRecord(body),
|
|
37
|
+
enqueuedAt: Date.now(),
|
|
38
|
+
});
|
|
39
|
+
return json({ queued: true }, 202);
|
|
40
|
+
}
|
|
41
|
+
return proxyDaemonBatch(request, env, options, daemonPath);
|
|
42
|
+
},
|
|
43
|
+
async queue(batch, env, _ctx) {
|
|
44
|
+
for (const message of batch.messages) {
|
|
45
|
+
try {
|
|
46
|
+
const response = await handleQueuePayload(message.body, env, options);
|
|
47
|
+
if (response.ok) {
|
|
48
|
+
message.ack?.();
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
message.retry?.();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
message.retry?.();
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
async scheduled(_event, env) {
|
|
60
|
+
await proxyDaemonJson(env, options, '/api/batch/tick', {
|
|
61
|
+
method: 'POST',
|
|
62
|
+
body: JSON.stringify({ force: false }),
|
|
63
|
+
});
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async function handleQueuePayload(payload, env, options) {
|
|
68
|
+
if (payload.type === 'batch.tick') {
|
|
69
|
+
return proxyDaemonJson(env, options, '/api/batch/tick', {
|
|
70
|
+
method: 'POST',
|
|
71
|
+
body: JSON.stringify({ force: payload.force === true }),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
return proxyDaemonJson(env, options, '/api/batch/jobs', {
|
|
75
|
+
method: 'POST',
|
|
76
|
+
body: JSON.stringify({
|
|
77
|
+
...payload.body,
|
|
78
|
+
source: {
|
|
79
|
+
kind: 'cloudflare-queue',
|
|
80
|
+
id: typeof payload.body['id'] === 'string' ? payload.body['id'] : undefined,
|
|
81
|
+
},
|
|
82
|
+
}),
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
async function proxyDaemonBatch(request, env, options, daemonPath) {
|
|
86
|
+
const body = request.method === 'GET' || request.method === 'HEAD' ? undefined : await request.text();
|
|
87
|
+
return proxyDaemonJson(env, options, daemonPath, {
|
|
88
|
+
method: request.method,
|
|
89
|
+
body,
|
|
90
|
+
search: new URL(request.url).search,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
async function proxyDaemonJson(env, options, path, init) {
|
|
94
|
+
const baseUrl = resolveDaemonUrl(env, options);
|
|
95
|
+
if (!baseUrl) {
|
|
96
|
+
return json({ error: 'GOODVIBES_DAEMON_URL is not configured', code: 'DAEMON_URL_REQUIRED' }, 503);
|
|
97
|
+
}
|
|
98
|
+
const headers = new Headers();
|
|
99
|
+
if (init.body !== undefined)
|
|
100
|
+
headers.set('Content-Type', 'application/json');
|
|
101
|
+
const token = options.authToken ?? env.GOODVIBES_OPERATOR_TOKEN ?? '';
|
|
102
|
+
if (token)
|
|
103
|
+
headers.set('Authorization', `Bearer ${token}`);
|
|
104
|
+
return fetch(`${baseUrl}${path}${init.search ?? ''}`, {
|
|
105
|
+
method: init.method,
|
|
106
|
+
headers,
|
|
107
|
+
body: init.body,
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function toDaemonBatchPath(pathname) {
|
|
111
|
+
if (pathname.startsWith('/api/batch'))
|
|
112
|
+
return pathname;
|
|
113
|
+
if (pathname.startsWith('/batch/'))
|
|
114
|
+
return `/api${pathname}`;
|
|
115
|
+
if (pathname === '/batch')
|
|
116
|
+
return '/api/batch';
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
function resolveDaemonUrl(env, options) {
|
|
120
|
+
const raw = options.daemonUrl ?? env.GOODVIBES_DAEMON_URL ?? '';
|
|
121
|
+
return raw.replace(/\/+$/, '');
|
|
122
|
+
}
|
|
123
|
+
async function optionalJson(request) {
|
|
124
|
+
const text = await request.text();
|
|
125
|
+
if (!text.trim())
|
|
126
|
+
return {};
|
|
127
|
+
try {
|
|
128
|
+
return JSON.parse(text);
|
|
129
|
+
}
|
|
130
|
+
catch {
|
|
131
|
+
return {};
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function json(body, status = 200) {
|
|
135
|
+
return new Response(JSON.stringify(body), {
|
|
136
|
+
status,
|
|
137
|
+
headers: { 'Content-Type': 'application/json' },
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function toRecord(value) {
|
|
141
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
142
|
+
? value
|
|
143
|
+
: {};
|
|
144
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pellux/goodvibes-sdk",
|
|
3
|
-
"version": "0.25.
|
|
3
|
+
"version": "0.25.8",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/mgd34msu/goodvibes-sdk.git"
|
|
@@ -92,6 +92,10 @@
|
|
|
92
92
|
"types": "./dist/web.d.ts",
|
|
93
93
|
"import": "./dist/web.js"
|
|
94
94
|
},
|
|
95
|
+
"./workers": {
|
|
96
|
+
"types": "./dist/workers.d.ts",
|
|
97
|
+
"import": "./dist/workers.js"
|
|
98
|
+
},
|
|
95
99
|
"./react-native": {
|
|
96
100
|
"types": "./dist/react-native.d.ts",
|
|
97
101
|
"import": "./dist/react-native.js"
|