@cartanova/qgrid-cli 2.23.2 → 2.23.4
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/bundle/dist/application/qgrid/qgrid-run-lifecycle.js +2 -1
- package/bundle/dist/application/qgrid/qgrid.frame.js +3 -2
- package/bundle/dist/application/qgrid/qgrid.types.js +6 -1
- package/bundle/dist/application/qgrid/transcribe-stream.js +6 -2
- package/bundle/dist/application/request-log/request-log.model.js +2 -1
- package/bundle/dist/application/sonamu.generated.js +4 -1
- package/bundle/dist/application/sonamu.generated.sso.js +3 -1
- package/bundle/dist/i18n/sd.generated.js +2 -1
- package/bundle/dist/migrations/20261128174146_alter_request_logs_add1_alter1.js +15 -0
- package/bundle/src/application/qgrid/qgrid-run-lifecycle.test.ts +2 -1
- package/bundle/src/application/qgrid/qgrid-run-lifecycle.ts +1 -0
- package/bundle/src/application/qgrid/qgrid.frame.ts +16 -11
- package/bundle/src/application/qgrid/qgrid.types.ts +10 -0
- package/bundle/src/application/qgrid/transcribe-stream.test.ts +64 -0
- package/bundle/src/application/qgrid/transcribe-stream.ts +17 -3
- package/bundle/src/application/request-log/request-log.entity.json +8 -0
- package/bundle/src/application/request-log/request-log.model.ts +2 -0
- package/bundle/src/application/sonamu.generated.http +1 -0
- package/bundle/src/application/sonamu.generated.sso.ts +2 -0
- package/bundle/src/application/sonamu.generated.ts +4 -0
- package/bundle/src/i18n/sd.generated.ts +2 -0
- package/bundle/src/migrations/20261128174146_alter_request_logs_add1_alter1.ts +15 -0
- package/bundle/web-dist/client/assets/{index-OvyZBkKa.js → index-CI-R2Y6-.js} +4 -4
- package/bundle/web-dist/client/assets/{logs-C5N7bVwK.js → logs-BlaF8qQu.js} +1 -1
- package/bundle/web-dist/client/assets/{monit-ONVht_8U.js → monit-DgkexSi6.js} +1 -1
- package/bundle/web-dist/client/assets/{routes-B06qZZ28.js → routes-BMcHMfOY.js} +1 -1
- package/bundle/web-dist/client/assets/{settings-DH-Qxh7s.js → settings-WAk6T5Wl.js} +1 -1
- package/bundle/web-dist/client/assets/{show-CKavN1Mk.js → show-C4Re5OcA.js} +1 -1
- package/bundle/web-dist/client/assets/{tokens-CymM-WtB.js → tokens-RD8MsUX3.js} +1 -1
- package/bundle/web-dist/client/assets/{use-oauth-login-flow-Bfx3FpzB.js → use-oauth-login-flow-B-OuDISt.js} +1 -1
- package/bundle/web-dist/client/assets/{use-update-token-mutation-BQScxp-D.js → use-update-token-mutation-4MhI_1yF.js} +1 -1
- package/bundle/web-dist/client/assets/{voice-BtklUyAS.js → voice-wXLwSHbu.js} +1 -1
- package/bundle/web-dist/client/index.html +1 -1
- package/bundle/web-dist/server/assets/{TimedPlayer-B9ds1sqM.js → TimedPlayer-VT6tFLOM.js} +1 -1
- package/bundle/web-dist/server/assets/{logs-JziKvWBp.js → logs-Cqx4Jhc9.js} +3 -3
- package/bundle/web-dist/server/assets/{monit-CzjNOowb.js → monit-4UNrQGu8.js} +2 -2
- package/bundle/web-dist/server/assets/{plus-BrRDgdaN.js → plus-BKzvhOKB.js} +1 -1
- package/bundle/web-dist/server/assets/{refresh-cw-wU5-wVTi.js → refresh-cw-CL3Dbyw3.js} +1 -1
- package/bundle/web-dist/server/assets/{request-model-D07WSRKx.js → request-model-fBjOYKZz.js} +1 -1
- package/bundle/web-dist/server/assets/{routes-C1tDj0QN.js → routes-CpOVGpbq.js} +3 -3
- package/bundle/web-dist/server/assets/{services.generated-rlOX8J2n.js → services.generated-HOu_08u8.js} +1 -0
- package/bundle/web-dist/server/assets/{settings-DJQUI8bU.js → settings-DVTtWfpo.js} +3 -3
- package/bundle/web-dist/server/assets/{show-BElTj6MG.js → show-DOAr5y67.js} +7 -3
- package/bundle/web-dist/server/assets/{tokens-CRpUPv-5.js → tokens-BdNjDtTq.js} +4 -4
- package/bundle/web-dist/server/assets/{use-oauth-login-flow-DLRPNhNE.js → use-oauth-login-flow-Cg2PUcyj.js} +1 -1
- package/bundle/web-dist/server/assets/{use-update-token-mutation-DJkct-j8.js → use-update-token-mutation-DJ-IuE1l.js} +1 -1
- package/bundle/web-dist/server/assets/{voice-DiZoRBX0.js → voice-BGNlieSv.js} +2 -2
- package/bundle/web-dist/server/entry-server.generated.js +17 -9
- package/package.json +1 -1
|
@@ -1616,19 +1616,23 @@ async function startTranscribeStream(
|
|
|
1616
1616
|
const token = { name: "" };
|
|
1617
1617
|
|
|
1618
1618
|
// Every (re)open picks a token the usual way and refreshes a 401 once.
|
|
1619
|
-
const session = new TranscribeStreamSession(
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1619
|
+
const session = new TranscribeStreamSession(
|
|
1620
|
+
async (onEvent) => {
|
|
1621
|
+
const opened = await dispatcher.startTranscriptionStream({
|
|
1622
|
+
model: id,
|
|
1623
|
+
language: input.language,
|
|
1624
|
+
prompt: input.prompt,
|
|
1625
|
+
onEvent,
|
|
1626
|
+
...selection,
|
|
1627
|
+
});
|
|
1627
1628
|
|
|
1628
|
-
|
|
1629
|
+
token.name = opened.tokenName;
|
|
1629
1630
|
|
|
1630
|
-
|
|
1631
|
-
|
|
1631
|
+
return opened.result;
|
|
1632
|
+
},
|
|
1633
|
+
publish,
|
|
1634
|
+
input.commit,
|
|
1635
|
+
);
|
|
1632
1636
|
|
|
1633
1637
|
const run: TranscribeStreamRun = {
|
|
1634
1638
|
session,
|
|
@@ -1702,6 +1706,7 @@ async function finishTranscribeStream(
|
|
|
1702
1706
|
model: run.route,
|
|
1703
1707
|
transport: "realtime-ws-stream",
|
|
1704
1708
|
sampleRate: run.sampleRate,
|
|
1709
|
+
...(run.input.commit && { commit: run.input.commit }),
|
|
1705
1710
|
language: run.input.language,
|
|
1706
1711
|
prompt: run.input.prompt,
|
|
1707
1712
|
audioMs,
|
|
@@ -612,6 +612,16 @@ export const TranscribeStreamStart = z.object({
|
|
|
612
612
|
prompt: z.string().min(1).max(2_000).optional(),
|
|
613
613
|
// Mono PCM16 at this rate; 16 kHz is resampled to the upstream 24 kHz.
|
|
614
614
|
sampleRate: z.union([z.literal(16_000), z.literal(24_000)]),
|
|
615
|
+
// When the server ends a segment on quiet (defaults 1500 / 600 / 2000 ms): after pauseMs of quiet
|
|
616
|
+
// once the segment holds minSpeechMs of speech, or after longPauseMs of quiet with any speech.
|
|
617
|
+
// Callers that judge end of turn themselves can cut short (e.g. 300 / 300 / 0) and join segments.
|
|
618
|
+
commit: z
|
|
619
|
+
.object({
|
|
620
|
+
pauseMs: z.number().int().min(200).max(5_000).optional(),
|
|
621
|
+
longPauseMs: z.number().int().min(200).max(5_000).optional(),
|
|
622
|
+
minSpeechMs: z.number().int().min(0).max(5_000).optional(),
|
|
623
|
+
})
|
|
624
|
+
.optional(),
|
|
615
625
|
...MediaCallOptions,
|
|
616
626
|
});
|
|
617
627
|
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
type OpenAITranscriptionStream,
|
|
4
4
|
type OpenAITranscriptionStreamEvent,
|
|
5
5
|
} from "../../utils/providers/openai/openai-voice-client";
|
|
6
|
+
import { TranscribeStreamStart } from "./qgrid.types";
|
|
6
7
|
import { CommitPolicy, type StreamOutEvent, TranscribeStreamSession } from "./transcribe-stream";
|
|
7
8
|
|
|
8
9
|
const RATE = 24_000;
|
|
@@ -44,6 +45,39 @@ describe("CommitPolicy", () => {
|
|
|
44
45
|
const out = Array.from({ length: 20 }, () => p.push(frame(0)));
|
|
45
46
|
expect(out.indexOf("commit")).toBe(19); // 2 s of quiet
|
|
46
47
|
});
|
|
48
|
+
|
|
49
|
+
it("commits a short answer after a short pause when the caller shortens the timers", () => {
|
|
50
|
+
const short = new CommitPolicy({ pauseMs: 300, longPauseMs: 300, minSpeechMs: 0 });
|
|
51
|
+
const byDefault = new CommitPolicy();
|
|
52
|
+
for (const p of [short, byDefault]) for (let i = 0; i < 2; i++) p.push(frame(0.2)); // 0.2 s "Yes."
|
|
53
|
+
const out = Array.from({ length: 20 }, () => short.push(frame(0)));
|
|
54
|
+
const outDefault = Array.from({ length: 20 }, () => byDefault.push(frame(0)));
|
|
55
|
+
expect(out.indexOf("commit")).toBe(2); // 0.3 s of quiet
|
|
56
|
+
expect(outDefault.indexOf("commit")).toBe(19); // still 2 s by default
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
describe("TranscribeStreamStart commit", () => {
|
|
61
|
+
const start = { sampleRate: 16_000 } as const;
|
|
62
|
+
|
|
63
|
+
it("accepts timers in range and leaves them out by default", () => {
|
|
64
|
+
expect(TranscribeStreamStart.parse(start).commit).toBeUndefined();
|
|
65
|
+
expect(
|
|
66
|
+
TranscribeStreamStart.parse({ ...start, commit: { pauseMs: 300, longPauseMs: 300, minSpeechMs: 0 } })
|
|
67
|
+
.commit,
|
|
68
|
+
).toEqual({ pauseMs: 300, longPauseMs: 300, minSpeechMs: 0 });
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it.each([
|
|
72
|
+
{ pauseMs: 199 },
|
|
73
|
+
{ pauseMs: 5_001 },
|
|
74
|
+
{ longPauseMs: 100 },
|
|
75
|
+
{ minSpeechMs: -1 },
|
|
76
|
+
{ minSpeechMs: 5_001 },
|
|
77
|
+
{ pauseMs: 300.5 },
|
|
78
|
+
])("rejects %o", (commit) => {
|
|
79
|
+
expect(TranscribeStreamStart.safeParse({ ...start, commit }).success).toBe(false);
|
|
80
|
+
});
|
|
47
81
|
});
|
|
48
82
|
|
|
49
83
|
function fakeUpstream() {
|
|
@@ -99,6 +133,36 @@ describe("TranscribeStreamSession", () => {
|
|
|
99
133
|
expect(session.segments.map((s) => s.text)).toEqual(["안녕하세요.", "다음 안건입니다."]);
|
|
100
134
|
});
|
|
101
135
|
|
|
136
|
+
it("records the time from commit to final text for the request log only", async () => {
|
|
137
|
+
vi.useFakeTimers();
|
|
138
|
+
|
|
139
|
+
try {
|
|
140
|
+
const up = fakeUpstream();
|
|
141
|
+
const out: StreamOutEvent[] = [];
|
|
142
|
+
const session = new TranscribeStreamSession(up.opens, (e) => out.push(e), {
|
|
143
|
+
pauseMs: 300,
|
|
144
|
+
longPauseMs: 300,
|
|
145
|
+
minSpeechMs: 0,
|
|
146
|
+
});
|
|
147
|
+
await session.start();
|
|
148
|
+
await speak(session, 200, 300); // the policy commits on the last quiet frame
|
|
149
|
+
expect(up.calls).toContain("commit");
|
|
150
|
+
vi.advanceTimersByTime(250);
|
|
151
|
+
up.send({ type: "committed", itemId: "e" });
|
|
152
|
+
up.send({ type: "completed", itemId: "e", text: "Yes." });
|
|
153
|
+
|
|
154
|
+
expect(session.segments).toEqual([
|
|
155
|
+
{ segmentId: "s0", text: "Yes.", startMs: 0, endMs: 500, commitToTextMs: 250 },
|
|
156
|
+
]);
|
|
157
|
+
expect(out.at(-1)).toEqual({
|
|
158
|
+
event: "segment",
|
|
159
|
+
data: { segmentId: "s0", text: "Yes.", startMs: 0, endMs: 500 },
|
|
160
|
+
});
|
|
161
|
+
} finally {
|
|
162
|
+
vi.useRealTimers();
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
|
|
102
166
|
it("clears quiet-only audio instead of committing it", async () => {
|
|
103
167
|
const up = fakeUpstream();
|
|
104
168
|
const session = new TranscribeStreamSession(up.opens, () => {});
|
|
@@ -94,7 +94,14 @@ export type StreamOutEvent =
|
|
|
94
94
|
| { event: "segment"; data: { segmentId: string; text: string; startMs: number; endMs: number } }
|
|
95
95
|
| { event: "error"; data: { message: string; fatal: boolean } };
|
|
96
96
|
|
|
97
|
-
export type StreamSegment = {
|
|
97
|
+
export type StreamSegment = {
|
|
98
|
+
segmentId: string;
|
|
99
|
+
text: string;
|
|
100
|
+
startMs: number;
|
|
101
|
+
endMs: number;
|
|
102
|
+
/** Wall-clock ms from sending the commit to receiving the final text; request log only. */
|
|
103
|
+
commitToTextMs?: number;
|
|
104
|
+
};
|
|
98
105
|
|
|
99
106
|
/** Opens (or reopens) the upstream stream; events must be routed to `onEvent`. */
|
|
100
107
|
export type OpenUpstream = (
|
|
@@ -107,6 +114,8 @@ type PendingSegment = {
|
|
|
107
114
|
/** First frame above the silence threshold; reported as the segment start. */
|
|
108
115
|
speechStartMs?: number;
|
|
109
116
|
endMs?: number;
|
|
117
|
+
/** Date.now() when the commit went upstream. */
|
|
118
|
+
committedAt?: number;
|
|
110
119
|
text?: string;
|
|
111
120
|
};
|
|
112
121
|
|
|
@@ -197,6 +206,7 @@ export class TranscribeStreamSession {
|
|
|
197
206
|
}
|
|
198
207
|
|
|
199
208
|
this.awaitingAck.push(segment.index);
|
|
209
|
+
segment.committedAt = Date.now();
|
|
200
210
|
await upstream.commit();
|
|
201
211
|
}
|
|
202
212
|
|
|
@@ -286,14 +296,18 @@ export class TranscribeStreamSession {
|
|
|
286
296
|
this.emit({ event: "error", data: { message: event.message, fatal: false } });
|
|
287
297
|
|
|
288
298
|
if (segment.text) {
|
|
289
|
-
const out
|
|
299
|
+
const out = {
|
|
290
300
|
segmentId: `s${segment.index}`,
|
|
291
301
|
text: segment.text,
|
|
292
302
|
startMs: segment.speechStartMs ?? segment.startMs,
|
|
293
303
|
endMs: segment.endMs ?? Math.round(ms(this.receivedSamples)),
|
|
294
304
|
};
|
|
295
305
|
|
|
296
|
-
this.segments.push(
|
|
306
|
+
this.segments.push(
|
|
307
|
+
segment.committedAt === undefined
|
|
308
|
+
? out
|
|
309
|
+
: { ...out, commitToTextMs: Date.now() - segment.committedAt },
|
|
310
|
+
);
|
|
297
311
|
this.emit({ event: "segment", data: out });
|
|
298
312
|
}
|
|
299
313
|
|
|
@@ -157,6 +157,12 @@
|
|
|
157
157
|
"nullable": true,
|
|
158
158
|
"desc": "effort level"
|
|
159
159
|
},
|
|
160
|
+
{
|
|
161
|
+
"name": "thinking",
|
|
162
|
+
"type": "boolean",
|
|
163
|
+
"nullable": true,
|
|
164
|
+
"desc": "Requested thinking switch; null when the caller left the model default"
|
|
165
|
+
},
|
|
160
166
|
{
|
|
161
167
|
"name": "history",
|
|
162
168
|
"type": "json",
|
|
@@ -309,6 +315,7 @@
|
|
|
309
315
|
"image_cost_usd",
|
|
310
316
|
"image_cost_method",
|
|
311
317
|
"effort",
|
|
318
|
+
"thinking",
|
|
312
319
|
"service_tier",
|
|
313
320
|
"history",
|
|
314
321
|
"input_images",
|
|
@@ -342,6 +349,7 @@
|
|
|
342
349
|
"image_cost_usd",
|
|
343
350
|
"image_cost_method",
|
|
344
351
|
"effort",
|
|
352
|
+
"thinking",
|
|
345
353
|
"service_tier",
|
|
346
354
|
"status",
|
|
347
355
|
"response_json_ok",
|
|
@@ -548,6 +548,7 @@ class RequestLogModelClass extends BaseModelClass<
|
|
|
548
548
|
system_prompt?: string | null;
|
|
549
549
|
requested_model_name?: string | null;
|
|
550
550
|
effort?: string | null;
|
|
551
|
+
thinking?: boolean | null;
|
|
551
552
|
service_tier?: string | null;
|
|
552
553
|
project_name?: string | null;
|
|
553
554
|
history?: HistoryItems;
|
|
@@ -567,6 +568,7 @@ class RequestLogModelClass extends BaseModelClass<
|
|
|
567
568
|
requested_model_name: params.requested_model_name ?? null,
|
|
568
569
|
model_name: null,
|
|
569
570
|
effort: params.effort ?? null,
|
|
571
|
+
thinking: params.thinking ?? null,
|
|
570
572
|
service_tier: params.service_tier ?? null,
|
|
571
573
|
project_name: params.project_name ?? null,
|
|
572
574
|
status: "running",
|
|
@@ -45,6 +45,7 @@ export const requestLogSubsetQueries = {
|
|
|
45
45
|
image_cost_usd: "request_logs.image_cost_usd",
|
|
46
46
|
image_cost_method: "request_logs.image_cost_method",
|
|
47
47
|
effort: "request_logs.effort",
|
|
48
|
+
thinking: "request_logs.thinking",
|
|
48
49
|
service_tier: "request_logs.service_tier",
|
|
49
50
|
history: "request_logs.history",
|
|
50
51
|
input_images: "request_logs.input_images",
|
|
@@ -80,6 +81,7 @@ export const requestLogSubsetQueries = {
|
|
|
80
81
|
image_cost_usd: "request_logs.image_cost_usd",
|
|
81
82
|
image_cost_method: "request_logs.image_cost_method",
|
|
82
83
|
effort: "request_logs.effort",
|
|
84
|
+
thinking: "request_logs.thinking",
|
|
83
85
|
service_tier: "request_logs.service_tier",
|
|
84
86
|
status: "request_logs.status",
|
|
85
87
|
response_json_ok: "request_logs.response_json_ok",
|
|
@@ -205,6 +205,7 @@ export const RequestLogBaseSchema = z.object({
|
|
|
205
205
|
image_cost_method: z.string().max(100).nullable(),
|
|
206
206
|
service_tier: z.string().max(20).nullable(),
|
|
207
207
|
effort: z.string().max(10).nullable(),
|
|
208
|
+
thinking: z.boolean().nullable(),
|
|
208
209
|
history: HistoryItems.nullable(),
|
|
209
210
|
input_images: InputImages.nullable(),
|
|
210
211
|
tools: ToolDefinitions.nullable(),
|
|
@@ -242,6 +243,7 @@ export type RequestLogBaseSchema = z.infer<typeof RequestLogBaseSchema> & {
|
|
|
242
243
|
"image_cost_method",
|
|
243
244
|
"service_tier",
|
|
244
245
|
"effort",
|
|
246
|
+
"thinking",
|
|
245
247
|
"history",
|
|
246
248
|
"input_images",
|
|
247
249
|
"tools",
|
|
@@ -449,6 +451,7 @@ export const RequestLogSubsetA = z.object({
|
|
|
449
451
|
image_cost_usd: z.int().nullable(),
|
|
450
452
|
image_cost_method: z.string().max(100).nullable(),
|
|
451
453
|
effort: z.string().max(10).nullable(),
|
|
454
|
+
thinking: z.boolean().nullable(),
|
|
452
455
|
service_tier: z.string().max(20).nullable(),
|
|
453
456
|
history: HistoryItems.nullable(),
|
|
454
457
|
input_images: InputImages.nullable(),
|
|
@@ -483,6 +486,7 @@ export const RequestLogSubsetP = z.object({
|
|
|
483
486
|
image_cost_usd: z.int().nullable(),
|
|
484
487
|
image_cost_method: z.string().max(100).nullable(),
|
|
485
488
|
effort: z.string().max(10).nullable(),
|
|
489
|
+
thinking: z.boolean().nullable(),
|
|
486
490
|
service_tier: z.string().max(20).nullable(),
|
|
487
491
|
status: RequestLogStatus,
|
|
488
492
|
response_json_ok: z.boolean().nullable(),
|
|
@@ -238,6 +238,8 @@ const entityLabels = {
|
|
|
238
238
|
"entity.RequestLog.image_cost_method": "이미지 비용 계산 방식",
|
|
239
239
|
"entity.RequestLog.service_tier": "Requested OpenAI service tier",
|
|
240
240
|
"entity.RequestLog.effort": "effort level",
|
|
241
|
+
"entity.RequestLog.thinking":
|
|
242
|
+
"Requested thinking switch; null when the caller left the model default",
|
|
241
243
|
"entity.RequestLog.history": "inject_items 히스토리",
|
|
242
244
|
"entity.RequestLog.input_images": "현재 user turn 입력 이미지",
|
|
243
245
|
"entity.RequestLog.tools": "요청에 장착된 tool 정의 목록",
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Knex } from "knex";
|
|
2
|
+
|
|
3
|
+
export async function up(knex: Knex): Promise<void> {
|
|
4
|
+
await knex.schema.alterTable("request_logs", (table) => {
|
|
5
|
+
// add
|
|
6
|
+
table.boolean("thinking").nullable();
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function down(knex: Knex): Promise<void> {
|
|
11
|
+
await knex.schema.alterTable("request_logs", (table) => {
|
|
12
|
+
// rollback - add
|
|
13
|
+
table.dropColumns("thinking");
|
|
14
|
+
});
|
|
15
|
+
}
|