@speeq/core 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-CELQUH6A.js +166 -0
- package/dist/chunk-CELQUH6A.js.map +1 -0
- package/dist/{chunk-JA2L35IQ.js → chunk-FRW2OUQL.js} +8 -2
- package/dist/chunk-FRW2OUQL.js.map +1 -0
- package/dist/chunk-PU7PGHHO.js +421 -0
- package/dist/chunk-PU7PGHHO.js.map +1 -0
- package/dist/errors.cjs +6 -0
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.cts +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.js +1 -1
- package/dist/index-DPp4Fwdy.d.cts +236 -0
- package/dist/index-I0oTxGMf.d.ts +236 -0
- package/dist/index.cjs +365 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +176 -3
- package/dist/index.d.ts +176 -3
- package/dist/index.js +87 -4
- package/dist/index.js.map +1 -1
- package/dist/manifest.cjs +230 -0
- package/dist/manifest.cjs.map +1 -0
- package/dist/manifest.d.cts +2523 -0
- package/dist/manifest.d.ts +2523 -0
- package/dist/manifest.js +218 -0
- package/dist/manifest.js.map +1 -0
- package/dist/speech-http.cjs +346 -0
- package/dist/speech-http.cjs.map +1 -0
- package/dist/speech-http.d.cts +41 -0
- package/dist/speech-http.d.ts +41 -0
- package/dist/speech-http.js +264 -0
- package/dist/speech-http.js.map +1 -0
- package/dist/speech-provider-D0YChUSt.d.cts +103 -0
- package/dist/speech-provider-D0YChUSt.d.ts +103 -0
- package/dist/utils.cjs +237 -0
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +2 -156
- package/dist/utils.d.ts +2 -156
- package/dist/utils.js +3 -2
- package/package.json +24 -2
- package/dist/chunk-JA2L35IQ.js.map +0 -1
- package/dist/chunk-JOTEKM5R.js +0 -318
- package/dist/chunk-JOTEKM5R.js.map +0 -1
package/dist/manifest.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
// src/schemas/manifest.ts
|
|
4
|
+
var MANIFEST_VERSION = 1;
|
|
5
|
+
var kindSchema = z.enum(["route", "endpoint", "function", "form", "filter-set"]);
|
|
6
|
+
var supportSchema = z.enum(["proven", "needs-review", "unsupported"]);
|
|
7
|
+
var accessSchema = z.enum(["read", "write", "unknown"]);
|
|
8
|
+
var sensitivity = z.enum(["none", "personal", "financial", "credentials", "admin", "unknown"]);
|
|
9
|
+
var framework = z.enum(["nextjs-app", "nextjs-pages"]);
|
|
10
|
+
var fileSchema = z.string().min(1).refine(
|
|
11
|
+
(s) => !/[:\\\p{Cc}]/u.test(s) && s.split("/").every((v) => v && v !== "." && v !== ".."),
|
|
12
|
+
"Expected a repo-relative POSIX file"
|
|
13
|
+
);
|
|
14
|
+
var line = z.int().positive();
|
|
15
|
+
var source = z.strictObject({ file: fileSchema, line });
|
|
16
|
+
var evidence = source.extend({ detector: z.string().min(1), note: z.string().max(200) });
|
|
17
|
+
var auth = z.strictObject({
|
|
18
|
+
observed: z.enum(["none-found", "present", "unknown"]),
|
|
19
|
+
evidence: z.array(evidence)
|
|
20
|
+
});
|
|
21
|
+
var idSchema = z.string().refine((s) => {
|
|
22
|
+
const i = s.indexOf(":");
|
|
23
|
+
const key = s.slice(i + 1);
|
|
24
|
+
return i > 0 && kindSchema.safeParse(s.slice(0, i)).success && key.length > 0 && key.trim() === key && !/[\p{Cc}\\]/u.test(key);
|
|
25
|
+
}, "Invalid capability id");
|
|
26
|
+
var digest = z.string().regex(/^[a-f0-9]{64}$/);
|
|
27
|
+
var description = z.string().transform((s) => s.replace(/\p{Cc}/gu, "")).pipe(z.string().max(300));
|
|
28
|
+
var base = z.strictObject({
|
|
29
|
+
id: idSchema,
|
|
30
|
+
kind: kindSchema,
|
|
31
|
+
title: z.string().max(80),
|
|
32
|
+
description: description.optional(),
|
|
33
|
+
framework,
|
|
34
|
+
source,
|
|
35
|
+
evidence: z.array(evidence).min(1),
|
|
36
|
+
support: supportSchema,
|
|
37
|
+
supportReason: z.string().trim().min(1).optional(),
|
|
38
|
+
access: accessSchema,
|
|
39
|
+
sensitivity,
|
|
40
|
+
auth,
|
|
41
|
+
fingerprint: digest,
|
|
42
|
+
related: z.array(idSchema)
|
|
43
|
+
});
|
|
44
|
+
var schemaType = z.enum(["null", "boolean", "object", "array", "number", "integer", "string"]);
|
|
45
|
+
var jsonSchema = z.strictObject({
|
|
46
|
+
type: schemaType.optional(),
|
|
47
|
+
get properties() {
|
|
48
|
+
return z.record(z.string(), jsonSchema).optional();
|
|
49
|
+
},
|
|
50
|
+
required: z.array(z.string()).optional(),
|
|
51
|
+
enum: z.array(z.json()).optional(),
|
|
52
|
+
get items() {
|
|
53
|
+
return jsonSchema.optional();
|
|
54
|
+
},
|
|
55
|
+
additionalProperties: z.boolean().optional(),
|
|
56
|
+
minimum: z.number().optional(),
|
|
57
|
+
maximum: z.number().optional(),
|
|
58
|
+
exclusiveMinimum: z.number().optional(),
|
|
59
|
+
exclusiveMaximum: z.number().optional(),
|
|
60
|
+
minItems: z.int().nonnegative().optional(),
|
|
61
|
+
maxItems: z.int().nonnegative().optional(),
|
|
62
|
+
format: z.enum(["email", "uri", "uuid"]).optional(),
|
|
63
|
+
minLength: z.int().nonnegative().optional(),
|
|
64
|
+
maxLength: z.int().nonnegative().optional(),
|
|
65
|
+
pattern: z.string().optional(),
|
|
66
|
+
default: z.json().optional(),
|
|
67
|
+
description: z.string().optional(),
|
|
68
|
+
get anyOf() {
|
|
69
|
+
return z.array(jsonSchema).optional();
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
var parameters = z.array(z.strictObject({ name: z.string(), schema: jsonSchema.optional() }));
|
|
73
|
+
var route = base.extend({
|
|
74
|
+
kind: z.literal("route"),
|
|
75
|
+
path: z.string(),
|
|
76
|
+
pathPattern: z.string(),
|
|
77
|
+
dynamic: z.enum(["static", "dynamic", "catch-all", "optional-catch-all"]),
|
|
78
|
+
pathParams: z.array(z.string()),
|
|
79
|
+
queryParams: parameters
|
|
80
|
+
});
|
|
81
|
+
var endpoint = base.extend({
|
|
82
|
+
kind: z.literal("endpoint"),
|
|
83
|
+
path: z.string(),
|
|
84
|
+
methods: z.array(z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"])),
|
|
85
|
+
input: z.strictObject({
|
|
86
|
+
query: jsonSchema.optional(),
|
|
87
|
+
body: jsonSchema.optional(),
|
|
88
|
+
source: z.enum(["zod", "openapi", "none"])
|
|
89
|
+
}).optional()
|
|
90
|
+
});
|
|
91
|
+
var fn = base.extend({
|
|
92
|
+
kind: z.literal("function"),
|
|
93
|
+
export: z.strictObject({ file: fileSchema, name: z.string(), isServerAction: z.boolean() }),
|
|
94
|
+
input: z.strictObject({ schema: jsonSchema, source: z.enum(["zod", "none"]) }).optional(),
|
|
95
|
+
validatesAtRuntime: z.boolean()
|
|
96
|
+
});
|
|
97
|
+
var form = base.extend({
|
|
98
|
+
kind: z.literal("form"),
|
|
99
|
+
routeId: idSchema.optional(),
|
|
100
|
+
fields: z.array(
|
|
101
|
+
z.strictObject({
|
|
102
|
+
name: z.string(),
|
|
103
|
+
type: z.string(),
|
|
104
|
+
required: z.boolean(),
|
|
105
|
+
sensitive: z.boolean()
|
|
106
|
+
})
|
|
107
|
+
),
|
|
108
|
+
actionRef: idSchema.optional(),
|
|
109
|
+
runtimeBinding: z.literal("none")
|
|
110
|
+
});
|
|
111
|
+
var filter = base.extend({
|
|
112
|
+
kind: z.literal("filter-set"),
|
|
113
|
+
routeId: idSchema.optional(),
|
|
114
|
+
parameters
|
|
115
|
+
});
|
|
116
|
+
var capability = z.discriminatedUnion("kind", [route, endpoint, fn, form, filter]).superRefine((c, ctx) => {
|
|
117
|
+
if (!c.id.startsWith(`${c.kind}:`))
|
|
118
|
+
ctx.addIssue({ code: "custom", path: ["id"], message: "Id kind differs" });
|
|
119
|
+
if (c.support !== "proven" && !c.supportReason)
|
|
120
|
+
ctx.addIssue({ code: "custom", path: ["supportReason"], message: "Expected support reason" });
|
|
121
|
+
if (c.kind === "function" && !c.input && c.support === "proven")
|
|
122
|
+
ctx.addIssue({
|
|
123
|
+
code: "custom",
|
|
124
|
+
path: ["support"],
|
|
125
|
+
message: "Unspecified input needs review"
|
|
126
|
+
});
|
|
127
|
+
});
|
|
128
|
+
var diagnostic = z.strictObject({
|
|
129
|
+
code: z.string().regex(/^SQ\d{4}$/),
|
|
130
|
+
severity: z.enum(["info", "warning", "error"]),
|
|
131
|
+
message: z.string().max(300),
|
|
132
|
+
file: fileSchema.optional(),
|
|
133
|
+
line: line.optional()
|
|
134
|
+
});
|
|
135
|
+
function compare(a, b) {
|
|
136
|
+
return a < b ? -1 : a > b ? 1 : 0;
|
|
137
|
+
}
|
|
138
|
+
var manifestSchema = z.strictObject({
|
|
139
|
+
manifestVersion: z.literal(MANIFEST_VERSION),
|
|
140
|
+
generator: z.strictObject({ name: z.literal("speeq"), version: z.string() }),
|
|
141
|
+
project: z.strictObject({
|
|
142
|
+
root: z.union([z.literal("."), fileSchema]),
|
|
143
|
+
framework: z.enum([...framework.options, "unknown"]),
|
|
144
|
+
packageManager: z.enum(["npm", "pnpm", "yarn", "bun", "unknown"]),
|
|
145
|
+
appDir: fileSchema.optional(),
|
|
146
|
+
language: z.enum(["typescript", "javascript", "mixed"])
|
|
147
|
+
}),
|
|
148
|
+
capabilities: z.array(capability),
|
|
149
|
+
diagnostics: z.array(diagnostic),
|
|
150
|
+
extensions: z.record(z.string(), z.unknown()).optional()
|
|
151
|
+
}).superRefine((m, ctx) => {
|
|
152
|
+
m.capabilities.forEach((c, i) => {
|
|
153
|
+
const prev = m.capabilities[i - 1];
|
|
154
|
+
if (prev && prev.id >= c.id)
|
|
155
|
+
ctx.addIssue({
|
|
156
|
+
code: "custom",
|
|
157
|
+
path: ["capabilities", i, "id"],
|
|
158
|
+
message: "Ids must be unique and sorted"
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
m.diagnostics.forEach((d, i) => {
|
|
162
|
+
const p = m.diagnostics[i - 1];
|
|
163
|
+
if (p && (compare(p.file ?? "", d.file ?? "") || (p.line ?? 0) - (d.line ?? 0) || compare(p.code, d.code)) > 0)
|
|
164
|
+
ctx.addIssue({
|
|
165
|
+
code: "custom",
|
|
166
|
+
path: ["diagnostics", i],
|
|
167
|
+
message: "Diagnostics must be sorted by file, line and code"
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
var decision = z.strictObject({
|
|
172
|
+
review: z.enum(["approved", "disabled"]),
|
|
173
|
+
approvedFingerprint: digest.optional(),
|
|
174
|
+
access: z.enum(["read", "write"]).optional(),
|
|
175
|
+
auth: z.strictObject({
|
|
176
|
+
requirement: z.enum(["public", "authenticated", "roles"]),
|
|
177
|
+
roles: z.array(z.string()).optional()
|
|
178
|
+
}).optional(),
|
|
179
|
+
confirm: z.boolean().optional(),
|
|
180
|
+
allowSensitive: z.boolean().optional(),
|
|
181
|
+
forwardAuth: z.boolean().optional(),
|
|
182
|
+
name: z.string().optional(),
|
|
183
|
+
title: z.string().max(80).optional(),
|
|
184
|
+
description: description.optional(),
|
|
185
|
+
rateLimitPerMinute: z.int().positive().optional(),
|
|
186
|
+
timeoutMs: z.int().positive().optional(),
|
|
187
|
+
note: z.string().optional()
|
|
188
|
+
}).refine((d) => d.review !== "approved" || !!d.approvedFingerprint, {
|
|
189
|
+
path: ["approvedFingerprint"],
|
|
190
|
+
message: "Approval requires a fingerprint"
|
|
191
|
+
});
|
|
192
|
+
var decisionsSchema = z.strictObject({
|
|
193
|
+
decisionsVersion: z.literal(1),
|
|
194
|
+
capabilities: z.record(idSchema, decision)
|
|
195
|
+
});
|
|
196
|
+
function parseManifest(value) {
|
|
197
|
+
return manifestSchema.parse(value);
|
|
198
|
+
}
|
|
199
|
+
function parseDecisions(value) {
|
|
200
|
+
return decisionsSchema.parse(value);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// src/schemas/status.ts
|
|
204
|
+
function resolveStatus(c, d, ctx) {
|
|
205
|
+
const review = d?.review ?? "pending";
|
|
206
|
+
const freshness = review === "approved" && d?.approvedFingerprint !== c.fingerprint ? "stale" : "current";
|
|
207
|
+
let blocked = false;
|
|
208
|
+
if (c.sensitivity === "credentials") blocked = { reason: "credentials" };
|
|
209
|
+
else if ((c.sensitivity === "admin" || c.sensitivity === "financial") && !d?.allowSensitive)
|
|
210
|
+
blocked = { reason: "sensitive-not-allowed" };
|
|
211
|
+
const executable = review === "approved" && freshness === "current" && !blocked && c.support !== "unsupported" && ctx.binding === "bound" && (c.access !== "unknown" || d?.access !== void 0);
|
|
212
|
+
const headline = executable ? "executable" : freshness === "stale" ? "stale" : blocked ? "blocked" : c.support === "unsupported" ? "unsupported" : review === "disabled" ? "disabled" : c.support === "needs-review" ? "needs-review" : "pending";
|
|
213
|
+
return { ...ctx, support: c.support, review, blocked, freshness, executable, headline };
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
export { MANIFEST_VERSION, accessSchema, decisionsSchema, fileSchema, idSchema, kindSchema, manifestSchema, parseDecisions, parseManifest, resolveStatus, supportSchema };
|
|
217
|
+
//# sourceMappingURL=manifest.js.map
|
|
218
|
+
//# sourceMappingURL=manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/manifest.ts","../src/schemas/status.ts"],"names":[],"mappings":";;;AAGO,IAAM,gBAAA,GAAmB;AAEzB,IAAM,UAAA,GAAa,EAAE,IAAA,CAAK,CAAC,SAAS,UAAA,EAAY,UAAA,EAAY,MAAA,EAAQ,YAAY,CAAC;AAEjF,IAAM,gBAAgB,CAAA,CAAE,IAAA,CAAK,CAAC,QAAA,EAAU,cAAA,EAAgB,aAAa,CAAC;AAEtE,IAAM,eAAe,CAAA,CAAE,IAAA,CAAK,CAAC,MAAA,EAAQ,OAAA,EAAS,SAAS,CAAC;AAC/D,IAAM,WAAA,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,OAAA,GACA,UACE,SAAA,GACA,CAAA,CAAE,OAAA,KAAY,aAAA,GACZ,gBACA,MAAA,KAAW,UAAA,GACT,aACA,CAAA,CAAE,OAAA,KAAY,iBACZ,cAAA,GACA,SAAA;AACd,EAAA,OAAO,EAAE,GAAG,GAAA,EAAK,OAAA,EAAS,CAAA,CAAE,SAAS,MAAA,EAAQ,OAAA,EAAS,SAAA,EAAW,UAAA,EAAY,QAAA,EAAS;AACxF","file":"manifest.js","sourcesContent":["import { z } from \"zod\";\n\n/** Current on-disk manifest format. */\nexport const MANIFEST_VERSION = 1 as const;\n/** Discovery categories. */\nexport const kindSchema = z.enum([\"route\", \"endpoint\", \"function\", \"form\", \"filter-set\"]);\n/** Strength of scanner support. */\nexport const supportSchema = z.enum([\"proven\", \"needs-review\", \"unsupported\"]);\n/** Effect on host data. */\nexport const accessSchema = z.enum([\"read\", \"write\", \"unknown\"]);\nconst sensitivity = z.enum([\"none\", \"personal\", \"financial\", \"credentials\", \"admin\", \"unknown\"]);\nconst framework = z.enum([\"nextjs-app\", \"nextjs-pages\"]);\n/** A canonical, repo-relative source file. */\nexport const fileSchema = z\n .string()\n .min(1)\n .refine(\n (s) => !/[:\\\\\\p{Cc}]/u.test(s) && s.split(\"/\").every((v) => v && v !== \".\" && v !== \"..\"),\n \"Expected a repo-relative POSIX file\",\n );\nconst line = z.int().positive();\nconst source = z.strictObject({ file: fileSchema, line });\nconst evidence = source.extend({ detector: z.string().min(1), note: z.string().max(200) });\nconst auth = z.strictObject({\n observed: z.enum([\"none-found\", \"present\", \"unknown\"]),\n evidence: z.array(evidence),\n});\n/** Stable framework identity with a nonempty, printable key. */\nexport const idSchema = z.string().refine((s) => {\n const i = s.indexOf(\":\");\n const key = s.slice(i + 1);\n return (\n i > 0 &&\n kindSchema.safeParse(s.slice(0, i)).success &&\n key.length > 0 &&\n key.trim() === key &&\n !/[\\p{Cc}\\\\]/u.test(key)\n );\n}, \"Invalid capability id\");\nconst digest = z.string().regex(/^[a-f0-9]{64}$/);\nconst description = z\n .string()\n .transform((s) => s.replace(/\\p{Cc}/gu, \"\"))\n .pipe(z.string().max(300));\nconst base = z.strictObject({\n id: idSchema,\n kind: kindSchema,\n title: z.string().max(80),\n description: description.optional(),\n framework,\n source,\n evidence: z.array(evidence).min(1),\n support: supportSchema,\n supportReason: z.string().trim().min(1).optional(),\n access: accessSchema,\n sensitivity,\n auth,\n fingerprint: digest,\n related: z.array(idSchema),\n});\nconst schemaType = z.enum([\"null\", \"boolean\", \"object\", \"array\", \"number\", \"integer\", \"string\"]);\nconst jsonSchema = z.strictObject({\n type: schemaType.optional(),\n get properties(): z.ZodOptional<z.ZodRecord<z.ZodString, typeof jsonSchema>> {\n return z.record(z.string(), jsonSchema).optional();\n },\n required: z.array(z.string()).optional(),\n enum: z.array(z.json()).optional(),\n get items(): z.ZodOptional<typeof jsonSchema> {\n return jsonSchema.optional();\n },\n additionalProperties: z.boolean().optional(),\n minimum: z.number().optional(),\n maximum: z.number().optional(),\n exclusiveMinimum: z.number().optional(),\n exclusiveMaximum: z.number().optional(),\n minItems: z.int().nonnegative().optional(),\n maxItems: z.int().nonnegative().optional(),\n format: z.enum([\"email\", \"uri\", \"uuid\"]).optional(),\n minLength: z.int().nonnegative().optional(),\n maxLength: z.int().nonnegative().optional(),\n pattern: z.string().optional(),\n default: z.json().optional(),\n description: z.string().optional(),\n get anyOf(): z.ZodOptional<z.ZodArray<typeof jsonSchema>> {\n return z.array(jsonSchema).optional();\n },\n});\nconst parameters = z.array(z.strictObject({ name: z.string(), schema: jsonSchema.optional() }));\nconst route = base.extend({\n kind: z.literal(\"route\"),\n path: z.string(),\n pathPattern: z.string(),\n dynamic: z.enum([\"static\", \"dynamic\", \"catch-all\", \"optional-catch-all\"]),\n pathParams: z.array(z.string()),\n queryParams: parameters,\n});\nconst endpoint = base.extend({\n kind: z.literal(\"endpoint\"),\n path: z.string(),\n methods: z.array(z.enum([\"GET\", \"POST\", \"PUT\", \"PATCH\", \"DELETE\", \"HEAD\", \"OPTIONS\"])),\n input: z\n .strictObject({\n query: jsonSchema.optional(),\n body: jsonSchema.optional(),\n source: z.enum([\"zod\", \"openapi\", \"none\"]),\n })\n .optional(),\n});\nconst fn = base.extend({\n kind: z.literal(\"function\"),\n export: z.strictObject({ file: fileSchema, name: z.string(), isServerAction: z.boolean() }),\n input: z.strictObject({ schema: jsonSchema, source: z.enum([\"zod\", \"none\"]) }).optional(),\n validatesAtRuntime: z.boolean(),\n});\nconst form = base.extend({\n kind: z.literal(\"form\"),\n routeId: idSchema.optional(),\n fields: z.array(\n z.strictObject({\n name: z.string(),\n type: z.string(),\n required: z.boolean(),\n sensitive: z.boolean(),\n }),\n ),\n actionRef: idSchema.optional(),\n runtimeBinding: z.literal(\"none\"),\n});\nconst filter = base.extend({\n kind: z.literal(\"filter-set\"),\n routeId: idSchema.optional(),\n parameters,\n});\nconst capability = z\n .discriminatedUnion(\"kind\", [route, endpoint, fn, form, filter])\n .superRefine((c, ctx) => {\n if (!c.id.startsWith(`${c.kind}:`))\n ctx.addIssue({ code: \"custom\", path: [\"id\"], message: \"Id kind differs\" });\n if (c.support !== \"proven\" && !c.supportReason)\n ctx.addIssue({ code: \"custom\", path: [\"supportReason\"], message: \"Expected support reason\" });\n if (c.kind === \"function\" && !c.input && c.support === \"proven\")\n ctx.addIssue({\n code: \"custom\",\n path: [\"support\"],\n message: \"Unspecified input needs review\",\n });\n });\nconst diagnostic = z.strictObject({\n code: z.string().regex(/^SQ\\d{4}$/),\n severity: z.enum([\"info\", \"warning\", \"error\"]),\n message: z.string().max(300),\n file: fileSchema.optional(),\n line: line.optional(),\n});\nfunction compare(a: string, b: string) {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n/** Versioned discovery output. */\nexport const manifestSchema = z\n .strictObject({\n manifestVersion: z.literal(MANIFEST_VERSION),\n generator: z.strictObject({ name: z.literal(\"speeq\"), version: z.string() }),\n project: z.strictObject({\n root: z.union([z.literal(\".\"), fileSchema]),\n framework: z.enum([...framework.options, \"unknown\"]),\n packageManager: z.enum([\"npm\", \"pnpm\", \"yarn\", \"bun\", \"unknown\"]),\n appDir: fileSchema.optional(),\n language: z.enum([\"typescript\", \"javascript\", \"mixed\"]),\n }),\n capabilities: z.array(capability),\n diagnostics: z.array(diagnostic),\n extensions: z.record(z.string(), z.unknown()).optional(),\n })\n .superRefine((m, ctx) => {\n m.capabilities.forEach((c, i) => {\n const prev = m.capabilities[i - 1];\n if (prev && prev.id >= c.id)\n ctx.addIssue({\n code: \"custom\",\n path: [\"capabilities\", i, \"id\"],\n message: \"Ids must be unique and sorted\",\n });\n });\n m.diagnostics.forEach((d, i) => {\n const p = m.diagnostics[i - 1];\n if (\n p &&\n (compare(p.file ?? \"\", d.file ?? \"\") ||\n (p.line ?? 0) - (d.line ?? 0) ||\n compare(p.code, d.code)) > 0\n )\n ctx.addIssue({\n code: \"custom\",\n path: [\"diagnostics\", i],\n message: \"Diagnostics must be sorted by file, line and code\",\n });\n });\n });\nconst decision = z\n .strictObject({\n review: z.enum([\"approved\", \"disabled\"]),\n approvedFingerprint: digest.optional(),\n access: z.enum([\"read\", \"write\"]).optional(),\n auth: z\n .strictObject({\n requirement: z.enum([\"public\", \"authenticated\", \"roles\"]),\n roles: z.array(z.string()).optional(),\n })\n .optional(),\n confirm: z.boolean().optional(),\n allowSensitive: z.boolean().optional(),\n forwardAuth: z.boolean().optional(),\n name: z.string().optional(),\n title: z.string().max(80).optional(),\n description: description.optional(),\n rateLimitPerMinute: z.int().positive().optional(),\n timeoutMs: z.int().positive().optional(),\n note: z.string().optional(),\n })\n .refine((d) => d.review !== \"approved\" || !!d.approvedFingerprint, {\n path: [\"approvedFingerprint\"],\n message: \"Approval requires a fingerprint\",\n });\n/** Developer-owned decisions keyed by capability id. */\nexport const decisionsSchema = z.strictObject({\n decisionsVersion: z.literal(1),\n capabilities: z.record(idSchema, decision),\n});\n/** Validate discovery output and retain Zod issue paths. */\nexport function parseManifest(value: unknown) {\n return manifestSchema.parse(value);\n}\n/** Validate developer decisions and retain Zod issue paths. */\nexport function parseDecisions(value: unknown) {\n return decisionsSchema.parse(value);\n}\n/** Parsed CapabilityKind contract. */\nexport type CapabilityKind = z.infer<typeof kindSchema>;\n/** Parsed Support contract. */\nexport type Support = z.infer<typeof supportSchema>;\n/** Parsed Access contract. */\nexport type Access = z.infer<typeof accessSchema>;\n/** Parsed Sensitivity contract. */\nexport type Sensitivity = z.infer<typeof sensitivity>;\n/** Parsed Framework contract. */\nexport type Framework = z.infer<typeof framework>;\n/** Parsed Evidence contract. */\nexport type Evidence = z.infer<typeof evidence>;\n/** Parsed AuthObservation contract. */\nexport type AuthObservation = z.infer<typeof auth>;\n/** Parsed CapabilityBase contract. */\nexport type CapabilityBase = z.infer<typeof base>;\n/** Parsed JsonSchemaLite contract. */\nexport type JsonSchemaLite = z.infer<typeof jsonSchema>;\n/** Parsed RouteCapability contract. */\nexport type RouteCapability = z.infer<typeof route>;\n/** Parsed EndpointCapability contract. */\nexport type EndpointCapability = z.infer<typeof endpoint>;\n/** Parsed FunctionCapability contract. */\nexport type FunctionCapability = z.infer<typeof fn>;\n/** Parsed FormCapability contract. */\nexport type FormCapability = z.infer<typeof form>;\n/** Parsed FilterSetCapability contract. */\nexport type FilterSetCapability = z.infer<typeof filter>;\n/** Parsed Capability contract. */\nexport type Capability = z.infer<typeof capability>;\n/** Parsed Diagnostic contract. */\nexport type Diagnostic = z.infer<typeof diagnostic>;\n/** Parsed Manifest contract. */\nexport type Manifest = z.infer<typeof manifestSchema>;\n/** Parsed CapabilityDecision contract. */\nexport type CapabilityDecision = z.infer<typeof decision>;\n/** Parsed DecisionsFile contract. */\nexport type DecisionsFile = z.infer<typeof decisionsSchema>;\n","import type { Capability, CapabilityDecision, Support } from \"./manifest.js\";\n/** Runtime binding and verification observed by the caller. */\nexport interface StatusContext {\n binding: \"none\" | \"bound\";\n verification: \"unverified\" | \"verified\" | \"failed\";\n}\n/** Independent review, policy and runtime dimensions. */\nexport interface CapabilityStatus extends StatusContext {\n support: Support;\n review: \"pending\" | \"approved\" | \"disabled\";\n blocked: false | { reason: \"credentials\" | \"sensitive-not-allowed\" };\n freshness: \"current\" | \"stale\";\n executable: boolean;\n headline:\n | \"executable\"\n | \"stale\"\n | \"blocked\"\n | \"unsupported\"\n | \"disabled\"\n | \"needs-review\"\n | \"pending\";\n}\n/** Resolve effective policy per ADR-0015. Verification is reported independently. */\nexport function resolveStatus(\n c: Capability,\n d: CapabilityDecision | undefined,\n ctx: StatusContext,\n): CapabilityStatus {\n const review = d?.review ?? \"pending\";\n const freshness =\n review === \"approved\" && d?.approvedFingerprint !== c.fingerprint ? \"stale\" : \"current\";\n let blocked: CapabilityStatus[\"blocked\"] = false;\n if (c.sensitivity === \"credentials\") blocked = { reason: \"credentials\" };\n else if ((c.sensitivity === \"admin\" || c.sensitivity === \"financial\") && !d?.allowSensitive)\n blocked = { reason: \"sensitive-not-allowed\" };\n const executable =\n review === \"approved\" &&\n freshness === \"current\" &&\n !blocked &&\n c.support !== \"unsupported\" &&\n ctx.binding === \"bound\" &&\n (c.access !== \"unknown\" || d?.access !== undefined);\n const headline = executable\n ? \"executable\"\n : freshness === \"stale\"\n ? \"stale\"\n : blocked\n ? \"blocked\"\n : c.support === \"unsupported\"\n ? \"unsupported\"\n : review === \"disabled\"\n ? \"disabled\"\n : c.support === \"needs-review\"\n ? \"needs-review\"\n : \"pending\";\n return { ...ctx, support: c.support, review, blocked, freshness, executable, headline };\n}\n"]}
|
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/errors.ts
|
|
4
|
+
var ERROR_HTTP_STATUS = {
|
|
5
|
+
UNAUTHENTICATED: 401,
|
|
6
|
+
FORBIDDEN: 403,
|
|
7
|
+
INVALID_INPUT: 400,
|
|
8
|
+
NOT_FOUND: 404,
|
|
9
|
+
CONFLICT: 409,
|
|
10
|
+
RATE_LIMITED: 429,
|
|
11
|
+
SPEECH_UNAVAILABLE: 503,
|
|
12
|
+
PAYLOAD_TOO_LARGE: 413,
|
|
13
|
+
PROVIDER_ERROR: 502,
|
|
14
|
+
TOOL_ERROR: 500,
|
|
15
|
+
TOOL_TIMEOUT: 504,
|
|
16
|
+
CONFIRMATION_REQUIRED: 409,
|
|
17
|
+
SESSION_EXPIRED: 401,
|
|
18
|
+
NOT_CONFIGURED: 500,
|
|
19
|
+
INTERNAL: 500
|
|
20
|
+
};
|
|
21
|
+
var DEFAULT_ERROR_MESSAGES = {
|
|
22
|
+
UNAUTHENTICATED: "Please sign in to continue.",
|
|
23
|
+
FORBIDDEN: "You are not allowed to do that.",
|
|
24
|
+
INVALID_INPUT: "The request was not valid.",
|
|
25
|
+
NOT_FOUND: "That could not be found.",
|
|
26
|
+
CONFLICT: "That was already handled.",
|
|
27
|
+
RATE_LIMITED: "The assistant is busy right now. Please try again in a moment.",
|
|
28
|
+
SPEECH_UNAVAILABLE: "Voice is not available right now. You can type instead.",
|
|
29
|
+
PAYLOAD_TOO_LARGE: "That audio is too long.",
|
|
30
|
+
PROVIDER_ERROR: "The AI provider had a problem. Please try again.",
|
|
31
|
+
TOOL_ERROR: "An action failed to run.",
|
|
32
|
+
TOOL_TIMEOUT: "An action took too long and was stopped.",
|
|
33
|
+
CONFIRMATION_REQUIRED: "This action needs your confirmation.",
|
|
34
|
+
SESSION_EXPIRED: "Your session expired. Starting a new one.",
|
|
35
|
+
NOT_CONFIGURED: "The assistant is not configured correctly.",
|
|
36
|
+
INTERNAL: "Something went wrong."
|
|
37
|
+
};
|
|
38
|
+
var RETRYABLE = /* @__PURE__ */ new Set([
|
|
39
|
+
"RATE_LIMITED",
|
|
40
|
+
"PROVIDER_ERROR",
|
|
41
|
+
"TOOL_TIMEOUT",
|
|
42
|
+
"SESSION_EXPIRED"
|
|
43
|
+
]);
|
|
44
|
+
var SpeeqError = class extends Error {
|
|
45
|
+
/** Brand used by {@link isSpeeqError} so checks work across bundled copies. */
|
|
46
|
+
isSpeeqError = true;
|
|
47
|
+
code;
|
|
48
|
+
retryable;
|
|
49
|
+
retryAfterMs;
|
|
50
|
+
details;
|
|
51
|
+
constructor(code, options = {}) {
|
|
52
|
+
super(options.message ?? DEFAULT_ERROR_MESSAGES[code], { cause: options.cause });
|
|
53
|
+
this.name = "SpeeqError";
|
|
54
|
+
this.code = code;
|
|
55
|
+
this.retryable = options.retryable ?? RETRYABLE.has(code);
|
|
56
|
+
this.retryAfterMs = options.retryAfterMs;
|
|
57
|
+
this.details = options.details;
|
|
58
|
+
}
|
|
59
|
+
/** HTTP status for this error. */
|
|
60
|
+
get status() {
|
|
61
|
+
return ERROR_HTTP_STATUS[this.code];
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
function isAbortError(error) {
|
|
65
|
+
return typeof error === "object" && error !== null && (error.name === "AbortError" || error.name === "TimeoutError");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// src/language.ts
|
|
69
|
+
function baseLanguage(tag) {
|
|
70
|
+
return tag.trim().split(/[-_]/)[0]?.toLowerCase() ?? "";
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/speech-http/detect-then-transcribe.ts
|
|
74
|
+
function createDetectThenTranscribe(o) {
|
|
75
|
+
const { detector, transcriber, candidates } = o;
|
|
76
|
+
if (!detector.capabilities.detectsLanguage || !candidates.length)
|
|
77
|
+
throw new SpeeqError("NOT_CONFIGURED");
|
|
78
|
+
const kinds = [detector.kind, transcriber.kind];
|
|
79
|
+
return {
|
|
80
|
+
id: o.id ?? "detect-then-transcribe",
|
|
81
|
+
kind: kinds.includes("remote-paid") ? "remote-paid" : kinds.includes("remote-free-tier") ? "remote-free-tier" : "self-hosted",
|
|
82
|
+
capabilities: {
|
|
83
|
+
...transcriber.capabilities,
|
|
84
|
+
detectsLanguage: true,
|
|
85
|
+
streaming: "buffered",
|
|
86
|
+
languages: candidates
|
|
87
|
+
},
|
|
88
|
+
async transcribe(req) {
|
|
89
|
+
const start = performance.now();
|
|
90
|
+
const detection = req.language ? void 0 : await detector.transcribe(req);
|
|
91
|
+
const detected = req.language ?? detection?.language;
|
|
92
|
+
req.signal?.throwIfAborted();
|
|
93
|
+
const language = candidates.find((c) => baseLanguage(c) === baseLanguage(detected ?? "")) ?? candidates[0];
|
|
94
|
+
const result = await transcriber.transcribe({ ...req, language });
|
|
95
|
+
return {
|
|
96
|
+
...result,
|
|
97
|
+
language: baseLanguage(language ?? ""),
|
|
98
|
+
languageConfidence: detection?.languageConfidence,
|
|
99
|
+
providerMs: performance.now() - start
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// src/utils/provider-http.ts
|
|
106
|
+
function parseRetryAfter(value) {
|
|
107
|
+
if (!value) return void 0;
|
|
108
|
+
const seconds = Number(value);
|
|
109
|
+
if (Number.isFinite(seconds)) return Math.max(0, Math.round(seconds * 1e3));
|
|
110
|
+
const date = Date.parse(value);
|
|
111
|
+
return Number.isNaN(date) ? void 0 : Math.max(0, date - Date.now());
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// src/speech-http/gemini-stt.ts
|
|
115
|
+
async function audioJson(fetcher, url, init) {
|
|
116
|
+
try {
|
|
117
|
+
const r = await fetcher(url, init);
|
|
118
|
+
if (!r.ok) {
|
|
119
|
+
void r.body?.cancel().catch(() => {
|
|
120
|
+
});
|
|
121
|
+
throw new SpeeqError(r.status === 429 ? "RATE_LIMITED" : "PROVIDER_ERROR", {
|
|
122
|
+
retryAfterMs: parseRetryAfter(r.headers.get("retry-after"))
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return await r.json();
|
|
126
|
+
} catch (e) {
|
|
127
|
+
if (isAbortError(e) || init.signal?.aborted || e instanceof SpeeqError) throw e;
|
|
128
|
+
throw new SpeeqError("PROVIDER_ERROR");
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function base64(bytes) {
|
|
132
|
+
let raw = "";
|
|
133
|
+
for (let i = 0; i < bytes.length; i += 8192)
|
|
134
|
+
raw += String.fromCharCode(...bytes.subarray(i, i + 8192));
|
|
135
|
+
return btoa(raw);
|
|
136
|
+
}
|
|
137
|
+
function createGeminiStt(o) {
|
|
138
|
+
if (!o.apiKey || !o.model || o.kind === "self-hosted") throw new SpeeqError("NOT_CONFIGURED");
|
|
139
|
+
return {
|
|
140
|
+
id: o.id ?? "gemini-stt",
|
|
141
|
+
kind: o.kind ?? "remote-free-tier",
|
|
142
|
+
capabilities: {
|
|
143
|
+
streaming: "buffered",
|
|
144
|
+
detectsLanguage: true,
|
|
145
|
+
vocabulary: "prompt",
|
|
146
|
+
languages: "any",
|
|
147
|
+
maxAudioSeconds: 60
|
|
148
|
+
},
|
|
149
|
+
async transcribe(req) {
|
|
150
|
+
const started = performance.now();
|
|
151
|
+
const instructions = [
|
|
152
|
+
"Transcribe verbatim. Do not translate, summarise or add words. Keep English words in Latin script and native-language words in their own script. Return empty text for unintelligible audio. Report the primary BCP 47 language tag.",
|
|
153
|
+
req.language ? `Expected speech language: ${req.language}` : "",
|
|
154
|
+
req.hints ? `Spell these exactly if spoken: ${[req.hints.prompt, ...req.hints.vocabulary ?? []].filter(Boolean).join(", ")}` : ""
|
|
155
|
+
].filter(Boolean).join("\n");
|
|
156
|
+
const data = await audioJson(
|
|
157
|
+
o.fetch ?? fetch,
|
|
158
|
+
`https://generativelanguage.googleapis.com/v1beta/models/${encodeURIComponent(o.model)}:generateContent`,
|
|
159
|
+
{
|
|
160
|
+
method: "POST",
|
|
161
|
+
headers: { "x-goog-api-key": o.apiKey, "content-type": "application/json" },
|
|
162
|
+
signal: req.signal,
|
|
163
|
+
body: JSON.stringify({
|
|
164
|
+
systemInstruction: { parts: [{ text: instructions }] },
|
|
165
|
+
contents: [
|
|
166
|
+
{
|
|
167
|
+
role: "user",
|
|
168
|
+
parts: [{ inlineData: { mimeType: req.mimeType, data: base64(req.audio) } }]
|
|
169
|
+
}
|
|
170
|
+
],
|
|
171
|
+
generationConfig: {
|
|
172
|
+
temperature: 0,
|
|
173
|
+
...o.model.startsWith("gemini-2.5") ? { thinkingConfig: { thinkingBudget: 0 } } : {},
|
|
174
|
+
responseMimeType: "application/json",
|
|
175
|
+
responseSchema: {
|
|
176
|
+
type: "OBJECT",
|
|
177
|
+
properties: { text: { type: "STRING" }, language: { type: "STRING" } },
|
|
178
|
+
required: ["text", "language"]
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
);
|
|
184
|
+
try {
|
|
185
|
+
const value = JSON.parse(
|
|
186
|
+
data.candidates[0].content.parts.filter((p) => !p.thought).map((p) => p.text).join("")
|
|
187
|
+
);
|
|
188
|
+
if (typeof value.text !== "string" || typeof value.language !== "string" || value.text && !/^[a-z]{2,3}(-[a-z0-9]+)*$/i.test(value.language))
|
|
189
|
+
throw Error();
|
|
190
|
+
return {
|
|
191
|
+
text: value.text,
|
|
192
|
+
language: baseLanguage(value.language) || void 0,
|
|
193
|
+
providerMs: performance.now() - started
|
|
194
|
+
};
|
|
195
|
+
} catch {
|
|
196
|
+
throw new SpeeqError("PROVIDER_ERROR");
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// src/speech-http/openai.ts
|
|
203
|
+
async function send(o, path, body, signal) {
|
|
204
|
+
const headers = new Headers();
|
|
205
|
+
if (o.apiKey) headers.set("authorization", `Bearer ${o.apiKey}`);
|
|
206
|
+
if (typeof body === "string") headers.set("content-type", "application/json");
|
|
207
|
+
let res;
|
|
208
|
+
try {
|
|
209
|
+
res = await (o.fetch ?? fetch)(`${o.baseURL.replace(/\/+$/, "")}/audio/${path}`, {
|
|
210
|
+
method: "POST",
|
|
211
|
+
body,
|
|
212
|
+
headers,
|
|
213
|
+
signal
|
|
214
|
+
});
|
|
215
|
+
} catch (e) {
|
|
216
|
+
if (signal?.aborted || isAbortError(e)) throw e;
|
|
217
|
+
throw new SpeeqError("PROVIDER_ERROR");
|
|
218
|
+
}
|
|
219
|
+
if (!res.ok) {
|
|
220
|
+
void res.body?.cancel().catch(() => {
|
|
221
|
+
});
|
|
222
|
+
if (res.status === 429)
|
|
223
|
+
throw new SpeeqError("RATE_LIMITED", {
|
|
224
|
+
retryAfterMs: parseRetryAfter(res.headers.get("retry-after"))
|
|
225
|
+
});
|
|
226
|
+
throw new SpeeqError("PROVIDER_ERROR");
|
|
227
|
+
}
|
|
228
|
+
return res;
|
|
229
|
+
}
|
|
230
|
+
var languages = /* @__PURE__ */ new Map();
|
|
231
|
+
function baseLanguage2(value) {
|
|
232
|
+
if (typeof value !== "string" || !value) return;
|
|
233
|
+
if (/^[a-z]{2,3}(-[a-z0-9]+)*$/i.test(value)) return value.split("-")[0]?.toLowerCase();
|
|
234
|
+
if (!languages.size) {
|
|
235
|
+
const names = new Intl.DisplayNames("en", { type: "language", fallback: "none" });
|
|
236
|
+
for (let a = 97; a <= 122; a++)
|
|
237
|
+
for (let b = 97; b <= 122; b++) {
|
|
238
|
+
const code = String.fromCharCode(a, b), name = names.of(code);
|
|
239
|
+
if (name && !languages.has(name.toLowerCase())) languages.set(name.toLowerCase(), code);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
return languages.get(value.toLowerCase());
|
|
243
|
+
}
|
|
244
|
+
function createOpenAICompatibleStt(o) {
|
|
245
|
+
return {
|
|
246
|
+
id: o.id ?? "openai-compatible-stt",
|
|
247
|
+
kind: o.kind,
|
|
248
|
+
capabilities: {
|
|
249
|
+
streaming: "buffered",
|
|
250
|
+
detectsLanguage: true,
|
|
251
|
+
vocabulary: "prompt",
|
|
252
|
+
languages: o.languages ?? "any",
|
|
253
|
+
maxAudioSeconds: 60
|
|
254
|
+
},
|
|
255
|
+
async transcribe(req) {
|
|
256
|
+
const body = new FormData();
|
|
257
|
+
const ext = req.mimeType.split("/")[1]?.split(";")[0] ?? "bin";
|
|
258
|
+
body.append(
|
|
259
|
+
"file",
|
|
260
|
+
new Blob([new Uint8Array(req.audio)], { type: req.mimeType }),
|
|
261
|
+
`utterance.${ext}`
|
|
262
|
+
);
|
|
263
|
+
body.set("model", o.model);
|
|
264
|
+
body.set("response_format", "verbose_json");
|
|
265
|
+
body.set("temperature", "0");
|
|
266
|
+
const language = baseLanguage2(req.language);
|
|
267
|
+
if (language) body.set("language", language);
|
|
268
|
+
const prompt = [req.hints?.prompt, req.hints?.vocabulary?.join(", ")].filter(Boolean).join("\n");
|
|
269
|
+
if (prompt) body.set("prompt", prompt);
|
|
270
|
+
const start = performance.now();
|
|
271
|
+
const res = await send(o, "transcriptions", body, req.signal);
|
|
272
|
+
const data = await res.json().catch((e) => {
|
|
273
|
+
if (isAbortError(e)) throw e;
|
|
274
|
+
throw new SpeeqError("PROVIDER_ERROR");
|
|
275
|
+
});
|
|
276
|
+
if (typeof data?.text !== "string") throw new SpeeqError("PROVIDER_ERROR");
|
|
277
|
+
return {
|
|
278
|
+
text: data.text,
|
|
279
|
+
language: baseLanguage2(data.language),
|
|
280
|
+
audioMs: typeof data.duration === "number" ? data.duration * 1e3 : void 0,
|
|
281
|
+
providerMs: performance.now() - start
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function createOpenAICompatibleTts(o) {
|
|
287
|
+
const id = o.id ?? "openai-compatible-tts";
|
|
288
|
+
return {
|
|
289
|
+
id,
|
|
290
|
+
kind: o.kind,
|
|
291
|
+
capabilities: {
|
|
292
|
+
streamingAudio: false,
|
|
293
|
+
formats: ["mp3", "wav", "opus", "pcm16"],
|
|
294
|
+
languages: "any"
|
|
295
|
+
},
|
|
296
|
+
async listVoices() {
|
|
297
|
+
return o.voices.map((v) => ({
|
|
298
|
+
...v,
|
|
299
|
+
provider: id,
|
|
300
|
+
processing: "remote",
|
|
301
|
+
streaming: false
|
|
302
|
+
}));
|
|
303
|
+
},
|
|
304
|
+
async synthesize(req) {
|
|
305
|
+
const format = req.format ?? o.format ?? "mp3";
|
|
306
|
+
const voice = req.voiceId ?? o.defaultVoice ?? o.voices[0]?.id;
|
|
307
|
+
const res = await send(
|
|
308
|
+
o,
|
|
309
|
+
"speech",
|
|
310
|
+
JSON.stringify({
|
|
311
|
+
model: o.model,
|
|
312
|
+
input: req.text,
|
|
313
|
+
voice,
|
|
314
|
+
response_format: format === "pcm16" ? "pcm" : format,
|
|
315
|
+
speed: req.rate
|
|
316
|
+
}),
|
|
317
|
+
req.signal
|
|
318
|
+
);
|
|
319
|
+
if (!res.body) throw new SpeeqError("PROVIDER_ERROR");
|
|
320
|
+
const ignored = ["pitch", "volume", "style"].filter(
|
|
321
|
+
(p) => req[p] !== void 0
|
|
322
|
+
);
|
|
323
|
+
const unapplied = res.headers.get("X-Speeq-Ignored")?.split(",").map((p) => p.trim()) ?? [];
|
|
324
|
+
if (req.rate !== void 0 && (unapplied.includes("speed") || unapplied.includes("rate")))
|
|
325
|
+
ignored.push("rate");
|
|
326
|
+
return {
|
|
327
|
+
audio: res.body,
|
|
328
|
+
mimeType: res.headers.get("content-type") ?? {
|
|
329
|
+
mp3: "audio/mpeg",
|
|
330
|
+
wav: "audio/wav",
|
|
331
|
+
opus: "audio/ogg",
|
|
332
|
+
pcm16: "application/octet-stream"
|
|
333
|
+
}[format],
|
|
334
|
+
ignored
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
exports.audioJson = audioJson;
|
|
341
|
+
exports.createDetectThenTranscribe = createDetectThenTranscribe;
|
|
342
|
+
exports.createGeminiStt = createGeminiStt;
|
|
343
|
+
exports.createOpenAICompatibleStt = createOpenAICompatibleStt;
|
|
344
|
+
exports.createOpenAICompatibleTts = createOpenAICompatibleTts;
|
|
345
|
+
//# sourceMappingURL=speech-http.cjs.map
|
|
346
|
+
//# sourceMappingURL=speech-http.cjs.map
|