dsh-realtime 0.1.1 → 0.2.1
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/lib/error.d.ts +48 -2
- package/lib/error.d.ts.map +1 -1
- package/lib/error.js +56 -1
- package/lib/error.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/redact.d.ts +35 -0
- package/lib/redact.d.ts.map +1 -0
- package/lib/redact.js +80 -0
- package/lib/redact.js.map +1 -0
- package/lib/types.d.ts +41 -3
- package/lib/types.d.ts.map +1 -1
- package/lib/types.js.map +1 -1
- package/package.json +10 -6
- package/src/error.ts +85 -2
- package/src/index.ts +1 -0
- package/src/redact.ts +80 -0
- package/src/types.ts +43 -3
- package/LICENSE +0 -21
package/lib/error.d.ts
CHANGED
|
@@ -26,9 +26,51 @@ export declare const REALTIME_ERROR_CODES: Readonly<{
|
|
|
26
26
|
PROVIDER_ERROR: "PROVIDER_ERROR";
|
|
27
27
|
/** A recorded session could not be read as a recording. */
|
|
28
28
|
INVALID_RECORDING: "INVALID_RECORDING";
|
|
29
|
+
/**
|
|
30
|
+
* The capability is not configured yet — an expected state on a fresh install, not a fault.
|
|
31
|
+
*
|
|
32
|
+
* Distinct from {@link REALTIME_ERROR_CODES.CREDENTIAL_REJECTED}: absent is fixed by supplying a
|
|
33
|
+
* value, unusable by replacing one.
|
|
34
|
+
*/
|
|
35
|
+
NOT_CONFIGURED: "NOT_CONFIGURED";
|
|
36
|
+
/** A credential is present and the provider refused it. Replace it; retrying cannot help. */
|
|
37
|
+
CREDENTIAL_REJECTED: "CREDENTIAL_REJECTED";
|
|
38
|
+
/** The credential is valid but the account cannot use what was requested (model, region, scope). */
|
|
39
|
+
NOT_ENTITLED: "NOT_ENTITLED";
|
|
40
|
+
/** The account cannot pay for the request — an exhausted balance or a hard billing limit. */
|
|
41
|
+
INSUFFICIENT_CREDIT: "INSUFFICIENT_CREDIT";
|
|
42
|
+
/** The provider throttled the request. Repeating later may succeed. */
|
|
43
|
+
RATE_LIMITED: "RATE_LIMITED";
|
|
44
|
+
/** The provider was asked something and did not answer within the bound. */
|
|
45
|
+
PROVIDER_TIMEOUT: "PROVIDER_TIMEOUT";
|
|
46
|
+
/** The transport failed — a socket error, not a decision the provider made. */
|
|
47
|
+
NETWORK: "NETWORK";
|
|
29
48
|
}>;
|
|
30
49
|
/** One of {@link REALTIME_ERROR_CODES}. */
|
|
31
50
|
export type RealtimeErrorCode = (typeof REALTIME_ERROR_CODES)[keyof typeof REALTIME_ERROR_CODES];
|
|
51
|
+
/**
|
|
52
|
+
* What a caller can act on, carried as structure rather than prose.
|
|
53
|
+
*
|
|
54
|
+
* A failure a user cannot act on is a failure report that wasted their time. Every field here exists
|
|
55
|
+
* so the *class* of a failure survives translation: an agent can relay `remedy` verbatim, a settings
|
|
56
|
+
* surface can highlight `setting`, a retry loop can consult `retryable`, and a human reading a log
|
|
57
|
+
* can see the provider's own `providerCode` instead of a paraphrase of it.
|
|
58
|
+
*
|
|
59
|
+
* Never carries secret material. `providerCode` is the provider's own error code, never a credential.
|
|
60
|
+
*/
|
|
61
|
+
export interface RealtimeFailureDetail {
|
|
62
|
+
/**
|
|
63
|
+
* What to do about it, written to be relayed **verbatim** to whoever is trying to use the feature.
|
|
64
|
+
* One sentence, imperative, no jargon.
|
|
65
|
+
*/
|
|
66
|
+
remedy?: string;
|
|
67
|
+
/** The configuration key that must be supplied, when the failure is a configuration state. */
|
|
68
|
+
setting?: string;
|
|
69
|
+
/** Whether repeating the identical call could succeed without any change. */
|
|
70
|
+
retryable?: boolean;
|
|
71
|
+
/** The provider's own error code, verbatim. Never a translated or inferred value. */
|
|
72
|
+
providerCode?: string;
|
|
73
|
+
}
|
|
32
74
|
/**
|
|
33
75
|
* A typed seam failure.
|
|
34
76
|
*
|
|
@@ -38,11 +80,15 @@ export type RealtimeErrorCode = (typeof REALTIME_ERROR_CODES)[keyof typeof REALT
|
|
|
38
80
|
export declare class RealtimeError extends Error {
|
|
39
81
|
/** Stable machine code. Branch on this, never on `message`. */
|
|
40
82
|
readonly code: RealtimeErrorCode;
|
|
83
|
+
/** What a caller can act on, when the failure is one they can act on. */
|
|
84
|
+
readonly detail: RealtimeFailureDetail | undefined;
|
|
41
85
|
/**
|
|
42
86
|
* @param message - non-empty human-readable summary. Must not contain secret material.
|
|
43
87
|
* @param code - one of {@link REALTIME_ERROR_CODES}.
|
|
44
|
-
* @param options - optional `cause`.
|
|
88
|
+
* @param options - optional `cause`, and an optional structured `detail`.
|
|
45
89
|
*/
|
|
46
|
-
constructor(message: string, code: RealtimeErrorCode, options?: ErrorOptions
|
|
90
|
+
constructor(message: string, code: RealtimeErrorCode, options?: ErrorOptions & {
|
|
91
|
+
detail?: RealtimeFailureDetail;
|
|
92
|
+
});
|
|
47
93
|
}
|
|
48
94
|
//# sourceMappingURL=error.d.ts.map
|
package/lib/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,gDAAgD;AAChD,eAAO,MAAM,oBAAoB;IAC/B,iEAAiE;;IAEjE,yEAAyE;;IAEzE,yEAAyE;;IAEzE,wDAAwD;;IAExD,mEAAmE;;IAEnE,2CAA2C;;IAE3C,iGAAiG;;IAEjG,iGAAiG;;IAEjG,2DAA2D;;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,gDAAgD;AAChD,eAAO,MAAM,oBAAoB;IAC/B,iEAAiE;;IAEjE,yEAAyE;;IAEzE,yEAAyE;;IAEzE,wDAAwD;;IAExD,mEAAmE;;IAEnE,2CAA2C;;IAE3C,iGAAiG;;IAEjG,iGAAiG;;IAEjG,2DAA2D;;IAS3D;;;;;OAKG;;IAEH,6FAA6F;;IAE7F,oGAAoG;;IAEpG,6FAA6F;;IAE7F,uEAAuE;;IAEvE,4EAA4E;;IAE5E,+EAA+E;;EAE/E,CAAA;AAEF,2CAA2C;AAC3C,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,OAAO,oBAAoB,CAAC,CAAA;AAEhG;;;;;;;;;GASG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8FAA8F;IAC9F,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,6EAA6E;IAC7E,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,qFAAqF;IACrF,YAAY,CAAC,EAAE,MAAM,CAAA;CACtB;AA4BD;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,+DAA+D;IAC/D,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAA;IAEhC,yEAAyE;IACzE,QAAQ,CAAC,MAAM,EAAE,qBAAqB,GAAG,SAAS,CAAA;IAElD;;;;OAIG;IACH,YAAY,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG;QAAE,MAAM,CAAC,EAAE,qBAAqB,CAAA;KAAE,EAchH;CACF"}
|
package/lib/error.js
CHANGED
|
@@ -26,7 +26,56 @@ export const REALTIME_ERROR_CODES = Object.freeze({
|
|
|
26
26
|
PROVIDER_ERROR: 'PROVIDER_ERROR',
|
|
27
27
|
/** A recorded session could not be read as a recording. */
|
|
28
28
|
INVALID_RECORDING: 'INVALID_RECORDING',
|
|
29
|
+
// ---------------------------------------------------------------------------------------------
|
|
30
|
+
// Failure taxonomy. These exist so a consumer can branch on the *class* of a failure rather than
|
|
31
|
+
// parse prose: a setup state, a rejected credential, an account that cannot pay, and a throttle
|
|
32
|
+
// need four different responses, and collapsing them is what makes onboarding feel unfinished.
|
|
33
|
+
// ---------------------------------------------------------------------------------------------
|
|
34
|
+
/**
|
|
35
|
+
* The capability is not configured yet — an expected state on a fresh install, not a fault.
|
|
36
|
+
*
|
|
37
|
+
* Distinct from {@link REALTIME_ERROR_CODES.CREDENTIAL_REJECTED}: absent is fixed by supplying a
|
|
38
|
+
* value, unusable by replacing one.
|
|
39
|
+
*/
|
|
40
|
+
NOT_CONFIGURED: 'NOT_CONFIGURED',
|
|
41
|
+
/** A credential is present and the provider refused it. Replace it; retrying cannot help. */
|
|
42
|
+
CREDENTIAL_REJECTED: 'CREDENTIAL_REJECTED',
|
|
43
|
+
/** The credential is valid but the account cannot use what was requested (model, region, scope). */
|
|
44
|
+
NOT_ENTITLED: 'NOT_ENTITLED',
|
|
45
|
+
/** The account cannot pay for the request — an exhausted balance or a hard billing limit. */
|
|
46
|
+
INSUFFICIENT_CREDIT: 'INSUFFICIENT_CREDIT',
|
|
47
|
+
/** The provider throttled the request. Repeating later may succeed. */
|
|
48
|
+
RATE_LIMITED: 'RATE_LIMITED',
|
|
49
|
+
/** The provider was asked something and did not answer within the bound. */
|
|
50
|
+
PROVIDER_TIMEOUT: 'PROVIDER_TIMEOUT',
|
|
51
|
+
/** The transport failed — a socket error, not a decision the provider made. */
|
|
52
|
+
NETWORK: 'NETWORK',
|
|
53
|
+
});
|
|
54
|
+
/** Expected `typeof` for each optional detail field. Data, so the check costs one loop and not a branch each. */
|
|
55
|
+
const DETAIL_FIELD_TYPES = Object.freeze({
|
|
56
|
+
remedy: 'string',
|
|
57
|
+
setting: 'string',
|
|
58
|
+
providerCode: 'string',
|
|
59
|
+
retryable: 'boolean',
|
|
29
60
|
});
|
|
61
|
+
/**
|
|
62
|
+
* Reject a malformed detail before it is attached to a failure.
|
|
63
|
+
* @param detail - candidate detail.
|
|
64
|
+
* @throws TypeError naming the offending field.
|
|
65
|
+
*/
|
|
66
|
+
function assertDetail(detail) {
|
|
67
|
+
for (const [field, expected] of Object.entries(DETAIL_FIELD_TYPES)) {
|
|
68
|
+
const value = detail[field];
|
|
69
|
+
if (value === undefined)
|
|
70
|
+
continue;
|
|
71
|
+
if (typeof value !== expected) {
|
|
72
|
+
throw new TypeError(`RealtimeError detail.${field} must be a ${expected}`);
|
|
73
|
+
}
|
|
74
|
+
if (expected === 'string' && value === '') {
|
|
75
|
+
throw new TypeError(`RealtimeError detail.${field} must be non-empty when supplied`);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
30
79
|
/**
|
|
31
80
|
* A typed seam failure.
|
|
32
81
|
*
|
|
@@ -36,10 +85,12 @@ export const REALTIME_ERROR_CODES = Object.freeze({
|
|
|
36
85
|
export class RealtimeError extends Error {
|
|
37
86
|
/** Stable machine code. Branch on this, never on `message`. */
|
|
38
87
|
code;
|
|
88
|
+
/** What a caller can act on, when the failure is one they can act on. */
|
|
89
|
+
detail;
|
|
39
90
|
/**
|
|
40
91
|
* @param message - non-empty human-readable summary. Must not contain secret material.
|
|
41
92
|
* @param code - one of {@link REALTIME_ERROR_CODES}.
|
|
42
|
-
* @param options - optional `cause`.
|
|
93
|
+
* @param options - optional `cause`, and an optional structured `detail`.
|
|
43
94
|
*/
|
|
44
95
|
constructor(message, code, options) {
|
|
45
96
|
if (typeof message !== 'string' || message.length === 0) {
|
|
@@ -48,9 +99,13 @@ export class RealtimeError extends Error {
|
|
|
48
99
|
if (typeof code !== 'string' || code.length === 0) {
|
|
49
100
|
throw new TypeError('RealtimeError code must be a non-empty string');
|
|
50
101
|
}
|
|
102
|
+
if (options?.detail !== undefined) {
|
|
103
|
+
assertDetail(options.detail);
|
|
104
|
+
}
|
|
51
105
|
super(message, options);
|
|
52
106
|
this.name = 'RealtimeError';
|
|
53
107
|
this.code = code;
|
|
108
|
+
this.detail = options?.detail;
|
|
54
109
|
}
|
|
55
110
|
}
|
|
56
111
|
//# sourceMappingURL=error.js.map
|
package/lib/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":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DAAkD,CAAC,CAAA;QACzE,CAAC;QACD,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAClD,MAAM,IAAI,SAAS,CAAC,+CAA+C,CAAC,CAAA;QACtE,CAAC;QACD,IAAI,OAAO,EAAE,MAAM,KAAK,SAAS,EAAE,CAAC;YAClC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;QAC9B,CAAC;QACD,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;QACvB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAA;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,CAAA;IAC/B,CAAC;CACF"}
|
package/lib/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ import { Service, type Context } from '@deepseek-ai/cordis';
|
|
|
12
12
|
import type { RealtimeDelegation, RealtimeModelInfo, RealtimeProviderInfo, RealtimeSession, RealtimeSessionHandlers, RealtimeSessionOptions } from './types.ts';
|
|
13
13
|
export * from './types.ts';
|
|
14
14
|
export * from './error.ts';
|
|
15
|
+
export * from './redact.ts';
|
|
15
16
|
export { RealtimeError, REALTIME_ERROR_CODES } from './error.ts';
|
|
16
17
|
declare module '@deepseek-ai/cordis' {
|
|
17
18
|
interface Context {
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAE3D,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,uBAAuB,EACvB,sBAAsB,EACvB,MAAM,YAAY,CAAA;AAEnB,cAAc,YAAY,CAAA;AAC1B,cAAc,Y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,OAAO,CAAC,eAAe,CAAC,CAAA;CAC5E;AAQD;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,OAAO;IAC1C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAyC;IAElE;;OAEG;IACH,YAAY,GAAG,EAAE,OAAO,EAEvB;IAED;;;;;;;;OAQG;IACH,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,eAAe,GAAG,yBAAyB,CAiCxF;IAED;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,OAAO;IAgCf;;;;;OAKG;IACH,OAAO,CAAC,MAAM;IASd;;;OAGG;IACH,aAAa,IAAI,oBAAoB,EAAE,CAEtC;IAED;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAQpB;;;;OAIG;IACG,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAe/D;IAED;;;;;;;;OAQG;IACG,OAAO,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,eAAe,CAAC,CAgBvE;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAWjE;CACF;AAED,qFAAqF;AACrF,YAAY,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,CAAA;eAE5C,eAAe"}
|
package/lib/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import { Service } from '@deepseek-ai/cordis';
|
|
|
12
12
|
import { REALTIME_ERROR_CODES, RealtimeError } from './error.js';
|
|
13
13
|
export * from './types.js';
|
|
14
14
|
export * from './error.js';
|
|
15
|
+
export * from './redact.js';
|
|
15
16
|
export { RealtimeError, REALTIME_ERROR_CODES } from './error.js';
|
|
16
17
|
/**
|
|
17
18
|
* Provider-wire adapter for the realtime session vocabulary.
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","source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K,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM;aAC7B,CAAC,CAAA;QACJ,CAAC;QACD,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC3E,CAAC;IAED;;;;;;;;;;OAUG;IACH,MAAM,CAAC,gBAAgB,CAAC,OAAe,EAAE,QAAgB;QACvD,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxD,MAAM,IAAI,aAAa,CAAC,mCAAmC,EAAE,oBAAoB,CAAC,cAAc,CAAC,CAAA;QACnG,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,GAAG,QAAQ,EAAE,CAAC;YAC9B,MAAM,IAAI,aAAa,CACrB,gBAAgB,OAAO,CAAC,MAAM,2BAA2B,QAAQ,uBAAuB,EACxF,oBAAoB,CAAC,cAAc,CACpC,CAAA;QACH,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;CACF;AAKD,eAAe,eAAe,CAAA"}
|
package/lib/redact.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redaction: the one place provider text becomes text a human or a log may see.
|
|
3
|
+
*
|
|
4
|
+
* The plugin's job is to hold a live session, so credentials flow through every path it has. Three
|
|
5
|
+
* surfaces introduced for diagnostics — a journal, a route and spoken failures — are three new places
|
|
6
|
+
* a provider key or the route's capability token could escape into, and a disclosure outlives the
|
|
7
|
+
* debugging session that introduced it. Review does not scale to that; a primitive that every sink
|
|
8
|
+
* passes through, with a test that fails on a planted string, does.
|
|
9
|
+
*
|
|
10
|
+
* Two arms, because the two kinds of secret cannot be caught the same way:
|
|
11
|
+
*
|
|
12
|
+
* - **Shape.** A key with a distinctive prefix (`sk-…`), a bearer header, a private-key block, a JWT,
|
|
13
|
+
* a recorded key fingerprint. These are unambiguous by construction and match anywhere.
|
|
14
|
+
* - **Value.** The route's capability token is 32 random bytes in base64url — it has no prefix, no
|
|
15
|
+
* `=` padding and no structure, so no pattern can ever catch it. A caller that *holds* the secret
|
|
16
|
+
* must name it. That is why {@link redact} takes a list.
|
|
17
|
+
*
|
|
18
|
+
* There is deliberately **no allow-list and no "safe" mode**: a check with a compliant path relocates
|
|
19
|
+
* the work instead of preventing it. Naming the setting is more useful to a reader than a literal
|
|
20
|
+
* anyway.
|
|
21
|
+
*
|
|
22
|
+
* @module dsh-realtime/redact
|
|
23
|
+
*/
|
|
24
|
+
/** What replaces a value that must not travel. One marker, so a reader can count the removals. */
|
|
25
|
+
export declare const REDACTED = "[redacted]";
|
|
26
|
+
/**
|
|
27
|
+
* Make text safe to journal, serve or speak.
|
|
28
|
+
*
|
|
29
|
+
* @param text - candidate text; returned unchanged when it is empty or not a string.
|
|
30
|
+
* @param secrets - values the caller knows must not appear. Omit when the caller holds none — the
|
|
31
|
+
* shape rules still apply.
|
|
32
|
+
* @returns the text with every matched secret replaced.
|
|
33
|
+
*/
|
|
34
|
+
export declare function redact(text: string, secrets?: readonly string[]): string;
|
|
35
|
+
//# sourceMappingURL=redact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,kGAAkG;AAClG,eAAO,MAAM,QAAQ,eAAe,CAAA;AAyCpC;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,SAAS,MAAM,EAAO,GAAG,MAAM,CAK5E"}
|
package/lib/redact.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redaction: the one place provider text becomes text a human or a log may see.
|
|
3
|
+
*
|
|
4
|
+
* The plugin's job is to hold a live session, so credentials flow through every path it has. Three
|
|
5
|
+
* surfaces introduced for diagnostics — a journal, a route and spoken failures — are three new places
|
|
6
|
+
* a provider key or the route's capability token could escape into, and a disclosure outlives the
|
|
7
|
+
* debugging session that introduced it. Review does not scale to that; a primitive that every sink
|
|
8
|
+
* passes through, with a test that fails on a planted string, does.
|
|
9
|
+
*
|
|
10
|
+
* Two arms, because the two kinds of secret cannot be caught the same way:
|
|
11
|
+
*
|
|
12
|
+
* - **Shape.** A key with a distinctive prefix (`sk-…`), a bearer header, a private-key block, a JWT,
|
|
13
|
+
* a recorded key fingerprint. These are unambiguous by construction and match anywhere.
|
|
14
|
+
* - **Value.** The route's capability token is 32 random bytes in base64url — it has no prefix, no
|
|
15
|
+
* `=` padding and no structure, so no pattern can ever catch it. A caller that *holds* the secret
|
|
16
|
+
* must name it. That is why {@link redact} takes a list.
|
|
17
|
+
*
|
|
18
|
+
* There is deliberately **no allow-list and no "safe" mode**: a check with a compliant path relocates
|
|
19
|
+
* the work instead of preventing it. Naming the setting is more useful to a reader than a literal
|
|
20
|
+
* anyway.
|
|
21
|
+
*
|
|
22
|
+
* @module dsh-realtime/redact
|
|
23
|
+
*/
|
|
24
|
+
/** What replaces a value that must not travel. One marker, so a reader can count the removals. */
|
|
25
|
+
export const REDACTED = '[redacted]';
|
|
26
|
+
/**
|
|
27
|
+
* Secrets whose *shape* is unambiguous, and the marker that replaces each.
|
|
28
|
+
*
|
|
29
|
+
* Every entry must be unmistakable on its own: a pattern that could match ordinary prose would
|
|
30
|
+
* corrupt the diagnostic it was meant to protect, which is the same failure as leaking — a report
|
|
31
|
+
* nobody can act on.
|
|
32
|
+
*/
|
|
33
|
+
const SHAPES = Object.freeze([
|
|
34
|
+
// A PEM block, before the generic rules can chew holes in it.
|
|
35
|
+
[/-----BEGIN[^\n]*PRIVATE KEY-----[\s\S]*?-----END[^\n]*PRIVATE KEY-----/g, '[redacted private key]'],
|
|
36
|
+
// A named API key: `sk-`, `rk-`, `pk-` and the vendor suffix they share.
|
|
37
|
+
[/\b(?:sk|rk|pk)-[A-Za-z0-9_-]{8,}/g, REDACTED],
|
|
38
|
+
// An Authorization header carried in a message.
|
|
39
|
+
[/\bBearer[ \t]+[A-Za-z0-9._~+/=-]{8,}/gi, `Bearer ${REDACTED}`],
|
|
40
|
+
// A JSON Web Token — three base64url segments, which is a credential or contains one.
|
|
41
|
+
[/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{4,}/g, REDACTED],
|
|
42
|
+
// A recorded key fingerprint: stable, org-identifying, and a leak in its own right.
|
|
43
|
+
[/\bfp=[0-9a-f]{16,}/gi, `fp=${REDACTED}`],
|
|
44
|
+
]);
|
|
45
|
+
/**
|
|
46
|
+
* Remove every occurrence of a secret the caller holds.
|
|
47
|
+
*
|
|
48
|
+
* Longest first: one secret can contain another (a fingerprint inside a key), and replacing the
|
|
49
|
+
* shorter one first would leave a recognisable fragment of the longer one behind.
|
|
50
|
+
*
|
|
51
|
+
* @param text - candidate text.
|
|
52
|
+
* @param secrets - values that must not appear, in any form.
|
|
53
|
+
* @returns the text with each secret replaced, and no partial key material left.
|
|
54
|
+
*/
|
|
55
|
+
function stripKnown(text, secrets) {
|
|
56
|
+
const ordered = secrets
|
|
57
|
+
.filter(secret => typeof secret === 'string' && secret.length > 0)
|
|
58
|
+
.sort((a, b) => b.length - a.length);
|
|
59
|
+
let out = text;
|
|
60
|
+
for (const secret of ordered)
|
|
61
|
+
out = out.split(secret).join(REDACTED);
|
|
62
|
+
return out;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Make text safe to journal, serve or speak.
|
|
66
|
+
*
|
|
67
|
+
* @param text - candidate text; returned unchanged when it is empty or not a string.
|
|
68
|
+
* @param secrets - values the caller knows must not appear. Omit when the caller holds none — the
|
|
69
|
+
* shape rules still apply.
|
|
70
|
+
* @returns the text with every matched secret replaced.
|
|
71
|
+
*/
|
|
72
|
+
export function redact(text, secrets = []) {
|
|
73
|
+
if (typeof text !== 'string' || text.length === 0)
|
|
74
|
+
return text;
|
|
75
|
+
let out = text;
|
|
76
|
+
for (const [shape, replacement] of SHAPES)
|
|
77
|
+
out = out.replace(shape, replacement);
|
|
78
|
+
return secrets.length === 0 ? out : stripKnown(out, secrets);
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=redact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redact.js","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,kGAAkG;AAClG,MAAM,CAAC,MAAM,QAAQ,GAAG,YAAY,CAAA;AAEpC;;;;;;GAMG;AACH,MAAM,MAAM,GAA2C,MAAM,CAAC,MAAM,CAAC;IACnE,8DAA8D;IAC9D,CAAC,yEAAyE,EAAE,wBAAwB,CAAC;IACrG,yEAAyE;IACzE,CAAC,mCAAmC,EAAE,QAAQ,CAAC;IAC/C,gDAAgD;IAChD,CAAC,wCAAwC,EAAE,UAAU,QAAQ,EAAE,CAAC;IAChE,sFAAsF;IACtF,CAAC,+DAA+D,EAAE,QAAQ,CAAC;IAC3E,oFAAoF;IACpF,CAAC,sBAAsB,EAAE,MAAM,QAAQ,EAAE,CAAC;CAClC,CAAC,CAAA;AAEX;;;;;;;;;GASG;AACH,SAAS,UAAU,CAAC,IAAY,EAAE,OAA0B;IAC1D,MAAM,OAAO,GAAG,OAAO;SACpB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;SACjE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAA;IACtC,IAAI,GAAG,GAAG,IAAI,CAAA;IACd,KAAK,MAAM,MAAM,IAAI,OAAO;QAAE,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;IACpE,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,MAAM,CAAC,IAAY,EAAE,OAAO,GAAsB,EAAE;IAClE,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAA;IAC9D,IAAI,GAAG,GAAG,IAAI,CAAA;IACd,KAAK,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,IAAI,MAAM;QAAE,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA;IAChF,OAAO,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;AAC9D,CAAC"}
|
package/lib/types.d.ts
CHANGED
|
@@ -144,20 +144,32 @@ export interface RealtimeSession {
|
|
|
144
144
|
unmuteInput(): void;
|
|
145
145
|
/**
|
|
146
146
|
* Return a delegated result for the model to **speak aloud**.
|
|
147
|
+
*
|
|
148
|
+
* Resolves on the provider's **acknowledgement** when it answers a delegation. With no
|
|
149
|
+
* `delegationId` there is no acknowledgement to wait for: the provider accepts a session-wide append
|
|
150
|
+
* in silence, because it does not begin applying context at a bare `session.start`. That form
|
|
151
|
+
* therefore resolves on the write and is **best-effort** — it is applied once audio has flowed, and
|
|
152
|
+
* this seam cannot say when. It is not a way to speak unprompted.
|
|
147
153
|
* @param content - plain text, non-empty and within {@link MAX_APPEND_CHARS}.
|
|
148
|
-
* @param delegationId - the delegation this answers, or `undefined` for
|
|
154
|
+
* @param delegationId - the delegation this answers, or `undefined` for best-effort session context.
|
|
149
155
|
*/
|
|
150
156
|
appendCommentary(content: string, delegationId?: string): Promise<void>;
|
|
151
157
|
/**
|
|
152
158
|
* Add context the model may use **without speaking it** — progress, facts, intermediate state.
|
|
159
|
+
*
|
|
160
|
+
* With no `delegationId` this resolves on the write and is best-effort, for the reason recorded on
|
|
161
|
+
* {@link appendCommentary}: the provider does not acknowledge a session-wide append.
|
|
153
162
|
* @param content - plain text, non-empty and within {@link MAX_APPEND_CHARS}.
|
|
154
|
-
* @param delegationId - the delegation this relates to, or `undefined` for
|
|
163
|
+
* @param delegationId - the delegation this relates to, or `undefined` for best-effort session context.
|
|
155
164
|
*/
|
|
156
165
|
appendThinking(content: string, delegationId?: string): Promise<void>;
|
|
157
166
|
/**
|
|
158
167
|
* Steer the live conversation's behaviour (tone, brevity, policy) without speaking anything.
|
|
168
|
+
*
|
|
169
|
+
* With no `delegationId` this resolves on the write and is best-effort, for the reason recorded on
|
|
170
|
+
* {@link appendCommentary}.
|
|
159
171
|
* @param content - plain text, non-empty and within {@link MAX_APPEND_CHARS}.
|
|
160
|
-
* @param delegationId - `undefined` for session-wide steering.
|
|
172
|
+
* @param delegationId - `undefined` for best-effort session-wide steering.
|
|
161
173
|
*/
|
|
162
174
|
appendInstructions(content: string, delegationId?: string): Promise<void>;
|
|
163
175
|
/**
|
|
@@ -175,4 +187,30 @@ export interface RealtimeSession {
|
|
|
175
187
|
* halfway through a live conversation. Exact token accounting belongs to the adapter.
|
|
176
188
|
*/
|
|
177
189
|
export declare const MAX_APPEND_CHARS = 2000;
|
|
190
|
+
/**
|
|
191
|
+
* How one delegated turn ended, when the answer was not an answer.
|
|
192
|
+
*
|
|
193
|
+
* Carried so a refusal can be *described* rather than only counted. The four cases are the four
|
|
194
|
+
* different things a person would do about it — nothing was asked, the controller refused (and said
|
|
195
|
+
* why), or it was admitted and nothing came back in time — and collapsing them into one `undefined`
|
|
196
|
+
* is what made the plugin's failures indistinguishable from outside it.
|
|
197
|
+
*/
|
|
198
|
+
export type RealtimeDelegationOutcome = 'answered' | 'declined' | 'refused' | 'timeout';
|
|
199
|
+
/**
|
|
200
|
+
* One delegated turn, settled, reported for diagnostics.
|
|
201
|
+
*
|
|
202
|
+
* `reason` is present only on `refused`, and is **redacted** before it is emitted: this is the first
|
|
203
|
+
* surface on which text the plugin did not author reaches a human, so it is safe by construction
|
|
204
|
+
* rather than by a later pass.
|
|
205
|
+
*/
|
|
206
|
+
export interface RealtimeDelegationSettlement {
|
|
207
|
+
/** The delegation this settles. Correlates with the ask, the answer and the journal. */
|
|
208
|
+
readonly id: string;
|
|
209
|
+
/** The session that raised it. */
|
|
210
|
+
readonly sessionId: string;
|
|
211
|
+
/** How it ended. */
|
|
212
|
+
readonly outcome: RealtimeDelegationOutcome;
|
|
213
|
+
/** The controller's own reason, redacted, when the outcome is `refused`. */
|
|
214
|
+
readonly reason?: string;
|
|
215
|
+
}
|
|
178
216
|
//# sourceMappingURL=types.d.ts.map
|
package/lib/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,kDAAkD;AAClD,MAAM,WAAW,oBAAoB;IACnC,sGAAsG;IACtG,EAAE,EAAE,MAAM,CAAA;IACV,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAA;IACZ,+DAA+D;IAC/D,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED,0GAA0G;AAC1G,MAAM,WAAW,iBAAiB;IAChC,+DAA+D;IAC/D,EAAE,EAAE,MAAM,CAAA;IACV,4BAA4B;IAC5B,IAAI,EAAE,MAAM,CAAA;IACZ,iEAAiE;IACjE,eAAe,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAA;IAC7C,qDAAqD;IACrD,gBAAgB,CAAC,EAAE,SAAS,gBAAgB,EAAE,CAAA;CAC/C;AAED,oDAAoD;AACpD,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAA;AAEzD,+CAA+C;AAC/C,MAAM,WAAW,mBAAmB;IAClC,iDAAiD;IACjD,UAAU,EAAE,MAAM,CAAA;IAClB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CA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,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEvE;;;;;;;OAOG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAErE;;;;;;;OAOG;IACH,kBAAkB,CAAC,OAAO,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEzE;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CACvB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB,OAAO,CAAA;AAEpC;;;;;;;GAOG;AACH,MAAM,MAAM,yBAAyB,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAA;AAEvF;;;;;;GAMG;AACH,MAAM,WAAW,4BAA4B;IAC3C,wFAAwF;IACxF,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;IACnB,kCAAkC;IAClC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,oBAAoB;IACpB,QAAQ,CAAC,OAAO,EAAE,yBAAyB,CAAA;IAC3C,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB"}
|
package/lib/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAkMH;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-realtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Realtime voice capability seam for DeepSeek Harness: a provider registry plus the session adapter base.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -18,6 +18,10 @@
|
|
|
18
18
|
"types": "./lib/error.d.ts",
|
|
19
19
|
"default": "./lib/error.js"
|
|
20
20
|
},
|
|
21
|
+
"./redact": {
|
|
22
|
+
"types": "./lib/redact.d.ts",
|
|
23
|
+
"default": "./lib/redact.js"
|
|
24
|
+
},
|
|
21
25
|
"./src/*": "./src/*",
|
|
22
26
|
"./package.json": "./package.json"
|
|
23
27
|
},
|
|
@@ -49,14 +53,14 @@
|
|
|
49
53
|
"access": "public",
|
|
50
54
|
"registry": "https://registry.npmjs.org"
|
|
51
55
|
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"build": "tsc -b",
|
|
58
|
+
"typecheck": "tsc -b --dry"
|
|
59
|
+
},
|
|
52
60
|
"peerDependencies": {
|
|
53
61
|
"@deepseek-ai/cordis": "^4.0.3"
|
|
54
62
|
},
|
|
55
63
|
"devDependencies": {
|
|
56
64
|
"@deepseek-ai/cordis": "^4.0.4"
|
|
57
|
-
},
|
|
58
|
-
"scripts": {
|
|
59
|
-
"build": "tsc -b",
|
|
60
|
-
"typecheck": "tsc -b --dry"
|
|
61
65
|
}
|
|
62
|
-
}
|
|
66
|
+
}
|
package/src/error.ts
CHANGED
|
@@ -27,11 +27,87 @@ export const REALTIME_ERROR_CODES = Object.freeze({
|
|
|
27
27
|
PROVIDER_ERROR: 'PROVIDER_ERROR',
|
|
28
28
|
/** A recorded session could not be read as a recording. */
|
|
29
29
|
INVALID_RECORDING: 'INVALID_RECORDING',
|
|
30
|
+
|
|
31
|
+
// ---------------------------------------------------------------------------------------------
|
|
32
|
+
// Failure taxonomy. These exist so a consumer can branch on the *class* of a failure rather than
|
|
33
|
+
// parse prose: a setup state, a rejected credential, an account that cannot pay, and a throttle
|
|
34
|
+
// need four different responses, and collapsing them is what makes onboarding feel unfinished.
|
|
35
|
+
// ---------------------------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* The capability is not configured yet — an expected state on a fresh install, not a fault.
|
|
39
|
+
*
|
|
40
|
+
* Distinct from {@link REALTIME_ERROR_CODES.CREDENTIAL_REJECTED}: absent is fixed by supplying a
|
|
41
|
+
* value, unusable by replacing one.
|
|
42
|
+
*/
|
|
43
|
+
NOT_CONFIGURED: 'NOT_CONFIGURED',
|
|
44
|
+
/** A credential is present and the provider refused it. Replace it; retrying cannot help. */
|
|
45
|
+
CREDENTIAL_REJECTED: 'CREDENTIAL_REJECTED',
|
|
46
|
+
/** The credential is valid but the account cannot use what was requested (model, region, scope). */
|
|
47
|
+
NOT_ENTITLED: 'NOT_ENTITLED',
|
|
48
|
+
/** The account cannot pay for the request — an exhausted balance or a hard billing limit. */
|
|
49
|
+
INSUFFICIENT_CREDIT: 'INSUFFICIENT_CREDIT',
|
|
50
|
+
/** The provider throttled the request. Repeating later may succeed. */
|
|
51
|
+
RATE_LIMITED: 'RATE_LIMITED',
|
|
52
|
+
/** The provider was asked something and did not answer within the bound. */
|
|
53
|
+
PROVIDER_TIMEOUT: 'PROVIDER_TIMEOUT',
|
|
54
|
+
/** The transport failed — a socket error, not a decision the provider made. */
|
|
55
|
+
NETWORK: 'NETWORK',
|
|
30
56
|
})
|
|
31
57
|
|
|
32
58
|
/** One of {@link REALTIME_ERROR_CODES}. */
|
|
33
59
|
export type RealtimeErrorCode = (typeof REALTIME_ERROR_CODES)[keyof typeof REALTIME_ERROR_CODES]
|
|
34
60
|
|
|
61
|
+
/**
|
|
62
|
+
* What a caller can act on, carried as structure rather than prose.
|
|
63
|
+
*
|
|
64
|
+
* A failure a user cannot act on is a failure report that wasted their time. Every field here exists
|
|
65
|
+
* so the *class* of a failure survives translation: an agent can relay `remedy` verbatim, a settings
|
|
66
|
+
* surface can highlight `setting`, a retry loop can consult `retryable`, and a human reading a log
|
|
67
|
+
* can see the provider's own `providerCode` instead of a paraphrase of it.
|
|
68
|
+
*
|
|
69
|
+
* Never carries secret material. `providerCode` is the provider's own error code, never a credential.
|
|
70
|
+
*/
|
|
71
|
+
export interface RealtimeFailureDetail {
|
|
72
|
+
/**
|
|
73
|
+
* What to do about it, written to be relayed **verbatim** to whoever is trying to use the feature.
|
|
74
|
+
* One sentence, imperative, no jargon.
|
|
75
|
+
*/
|
|
76
|
+
remedy?: string
|
|
77
|
+
/** The configuration key that must be supplied, when the failure is a configuration state. */
|
|
78
|
+
setting?: string
|
|
79
|
+
/** Whether repeating the identical call could succeed without any change. */
|
|
80
|
+
retryable?: boolean
|
|
81
|
+
/** The provider's own error code, verbatim. Never a translated or inferred value. */
|
|
82
|
+
providerCode?: string
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Expected `typeof` for each optional detail field. Data, so the check costs one loop and not a branch each. */
|
|
86
|
+
const DETAIL_FIELD_TYPES = Object.freeze({
|
|
87
|
+
remedy: 'string',
|
|
88
|
+
setting: 'string',
|
|
89
|
+
providerCode: 'string',
|
|
90
|
+
retryable: 'boolean',
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Reject a malformed detail before it is attached to a failure.
|
|
95
|
+
* @param detail - candidate detail.
|
|
96
|
+
* @throws TypeError naming the offending field.
|
|
97
|
+
*/
|
|
98
|
+
function assertDetail(detail: RealtimeFailureDetail): void {
|
|
99
|
+
for (const [field, expected] of Object.entries(DETAIL_FIELD_TYPES)) {
|
|
100
|
+
const value = (detail as Record<string, unknown>)[field]
|
|
101
|
+
if (value === undefined) continue
|
|
102
|
+
if (typeof value !== expected) {
|
|
103
|
+
throw new TypeError(`RealtimeError detail.${field} must be a ${expected}`)
|
|
104
|
+
}
|
|
105
|
+
if (expected === 'string' && value === '') {
|
|
106
|
+
throw new TypeError(`RealtimeError detail.${field} must be non-empty when supplied`)
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
35
111
|
/**
|
|
36
112
|
* A typed seam failure.
|
|
37
113
|
*
|
|
@@ -42,20 +118,27 @@ export class RealtimeError extends Error {
|
|
|
42
118
|
/** Stable machine code. Branch on this, never on `message`. */
|
|
43
119
|
readonly code: RealtimeErrorCode
|
|
44
120
|
|
|
121
|
+
/** What a caller can act on, when the failure is one they can act on. */
|
|
122
|
+
readonly detail: RealtimeFailureDetail | undefined
|
|
123
|
+
|
|
45
124
|
/**
|
|
46
125
|
* @param message - non-empty human-readable summary. Must not contain secret material.
|
|
47
126
|
* @param code - one of {@link REALTIME_ERROR_CODES}.
|
|
48
|
-
* @param options - optional `cause`.
|
|
127
|
+
* @param options - optional `cause`, and an optional structured `detail`.
|
|
49
128
|
*/
|
|
50
|
-
constructor(message: string, code: RealtimeErrorCode, options?: ErrorOptions) {
|
|
129
|
+
constructor(message: string, code: RealtimeErrorCode, options?: ErrorOptions & { detail?: RealtimeFailureDetail }) {
|
|
51
130
|
if (typeof message !== 'string' || message.length === 0) {
|
|
52
131
|
throw new TypeError('RealtimeError message must be a non-empty string')
|
|
53
132
|
}
|
|
54
133
|
if (typeof code !== 'string' || code.length === 0) {
|
|
55
134
|
throw new TypeError('RealtimeError code must be a non-empty string')
|
|
56
135
|
}
|
|
136
|
+
if (options?.detail !== undefined) {
|
|
137
|
+
assertDetail(options.detail)
|
|
138
|
+
}
|
|
57
139
|
super(message, options)
|
|
58
140
|
this.name = 'RealtimeError'
|
|
59
141
|
this.code = code
|
|
142
|
+
this.detail = options?.detail
|
|
60
143
|
}
|
|
61
144
|
}
|
package/src/index.ts
CHANGED
package/src/redact.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Redaction: the one place provider text becomes text a human or a log may see.
|
|
3
|
+
*
|
|
4
|
+
* The plugin's job is to hold a live session, so credentials flow through every path it has. Three
|
|
5
|
+
* surfaces introduced for diagnostics — a journal, a route and spoken failures — are three new places
|
|
6
|
+
* a provider key or the route's capability token could escape into, and a disclosure outlives the
|
|
7
|
+
* debugging session that introduced it. Review does not scale to that; a primitive that every sink
|
|
8
|
+
* passes through, with a test that fails on a planted string, does.
|
|
9
|
+
*
|
|
10
|
+
* Two arms, because the two kinds of secret cannot be caught the same way:
|
|
11
|
+
*
|
|
12
|
+
* - **Shape.** A key with a distinctive prefix (`sk-…`), a bearer header, a private-key block, a JWT,
|
|
13
|
+
* a recorded key fingerprint. These are unambiguous by construction and match anywhere.
|
|
14
|
+
* - **Value.** The route's capability token is 32 random bytes in base64url — it has no prefix, no
|
|
15
|
+
* `=` padding and no structure, so no pattern can ever catch it. A caller that *holds* the secret
|
|
16
|
+
* must name it. That is why {@link redact} takes a list.
|
|
17
|
+
*
|
|
18
|
+
* There is deliberately **no allow-list and no "safe" mode**: a check with a compliant path relocates
|
|
19
|
+
* the work instead of preventing it. Naming the setting is more useful to a reader than a literal
|
|
20
|
+
* anyway.
|
|
21
|
+
*
|
|
22
|
+
* @module dsh-realtime/redact
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
/** What replaces a value that must not travel. One marker, so a reader can count the removals. */
|
|
26
|
+
export const REDACTED = '[redacted]'
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Secrets whose *shape* is unambiguous, and the marker that replaces each.
|
|
30
|
+
*
|
|
31
|
+
* Every entry must be unmistakable on its own: a pattern that could match ordinary prose would
|
|
32
|
+
* corrupt the diagnostic it was meant to protect, which is the same failure as leaking — a report
|
|
33
|
+
* nobody can act on.
|
|
34
|
+
*/
|
|
35
|
+
const SHAPES: readonly (readonly [RegExp, string])[] = Object.freeze([
|
|
36
|
+
// A PEM block, before the generic rules can chew holes in it.
|
|
37
|
+
[/-----BEGIN[^\n]*PRIVATE KEY-----[\s\S]*?-----END[^\n]*PRIVATE KEY-----/g, '[redacted private key]'],
|
|
38
|
+
// A named API key: `sk-`, `rk-`, `pk-` and the vendor suffix they share.
|
|
39
|
+
[/\b(?:sk|rk|pk)-[A-Za-z0-9_-]{8,}/g, REDACTED],
|
|
40
|
+
// An Authorization header carried in a message.
|
|
41
|
+
[/\bBearer[ \t]+[A-Za-z0-9._~+/=-]{8,}/gi, `Bearer ${REDACTED}`],
|
|
42
|
+
// A JSON Web Token — three base64url segments, which is a credential or contains one.
|
|
43
|
+
[/\beyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{4,}/g, REDACTED],
|
|
44
|
+
// A recorded key fingerprint: stable, org-identifying, and a leak in its own right.
|
|
45
|
+
[/\bfp=[0-9a-f]{16,}/gi, `fp=${REDACTED}`],
|
|
46
|
+
] as const)
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Remove every occurrence of a secret the caller holds.
|
|
50
|
+
*
|
|
51
|
+
* Longest first: one secret can contain another (a fingerprint inside a key), and replacing the
|
|
52
|
+
* shorter one first would leave a recognisable fragment of the longer one behind.
|
|
53
|
+
*
|
|
54
|
+
* @param text - candidate text.
|
|
55
|
+
* @param secrets - values that must not appear, in any form.
|
|
56
|
+
* @returns the text with each secret replaced, and no partial key material left.
|
|
57
|
+
*/
|
|
58
|
+
function stripKnown(text: string, secrets: readonly string[]): string {
|
|
59
|
+
const ordered = secrets
|
|
60
|
+
.filter(secret => typeof secret === 'string' && secret.length > 0)
|
|
61
|
+
.sort((a, b) => b.length - a.length)
|
|
62
|
+
let out = text
|
|
63
|
+
for (const secret of ordered) out = out.split(secret).join(REDACTED)
|
|
64
|
+
return out
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Make text safe to journal, serve or speak.
|
|
69
|
+
*
|
|
70
|
+
* @param text - candidate text; returned unchanged when it is empty or not a string.
|
|
71
|
+
* @param secrets - values the caller knows must not appear. Omit when the caller holds none — the
|
|
72
|
+
* shape rules still apply.
|
|
73
|
+
* @returns the text with every matched secret replaced.
|
|
74
|
+
*/
|
|
75
|
+
export function redact(text: string, secrets: readonly string[] = []): string {
|
|
76
|
+
if (typeof text !== 'string' || text.length === 0) return text
|
|
77
|
+
let out = text
|
|
78
|
+
for (const [shape, replacement] of SHAPES) out = out.replace(shape, replacement)
|
|
79
|
+
return secrets.length === 0 ? out : stripKnown(out, secrets)
|
|
80
|
+
}
|
package/src/types.ts
CHANGED
|
@@ -159,22 +159,34 @@ export interface RealtimeSession {
|
|
|
159
159
|
|
|
160
160
|
/**
|
|
161
161
|
* Return a delegated result for the model to **speak aloud**.
|
|
162
|
+
*
|
|
163
|
+
* Resolves on the provider's **acknowledgement** when it answers a delegation. With no
|
|
164
|
+
* `delegationId` there is no acknowledgement to wait for: the provider accepts a session-wide append
|
|
165
|
+
* in silence, because it does not begin applying context at a bare `session.start`. That form
|
|
166
|
+
* therefore resolves on the write and is **best-effort** — it is applied once audio has flowed, and
|
|
167
|
+
* this seam cannot say when. It is not a way to speak unprompted.
|
|
162
168
|
* @param content - plain text, non-empty and within {@link MAX_APPEND_CHARS}.
|
|
163
|
-
* @param delegationId - the delegation this answers, or `undefined` for
|
|
169
|
+
* @param delegationId - the delegation this answers, or `undefined` for best-effort session context.
|
|
164
170
|
*/
|
|
165
171
|
appendCommentary(content: string, delegationId?: string): Promise<void>
|
|
166
172
|
|
|
167
173
|
/**
|
|
168
174
|
* Add context the model may use **without speaking it** — progress, facts, intermediate state.
|
|
175
|
+
*
|
|
176
|
+
* With no `delegationId` this resolves on the write and is best-effort, for the reason recorded on
|
|
177
|
+
* {@link appendCommentary}: the provider does not acknowledge a session-wide append.
|
|
169
178
|
* @param content - plain text, non-empty and within {@link MAX_APPEND_CHARS}.
|
|
170
|
-
* @param delegationId - the delegation this relates to, or `undefined` for
|
|
179
|
+
* @param delegationId - the delegation this relates to, or `undefined` for best-effort session context.
|
|
171
180
|
*/
|
|
172
181
|
appendThinking(content: string, delegationId?: string): Promise<void>
|
|
173
182
|
|
|
174
183
|
/**
|
|
175
184
|
* Steer the live conversation's behaviour (tone, brevity, policy) without speaking anything.
|
|
185
|
+
*
|
|
186
|
+
* With no `delegationId` this resolves on the write and is best-effort, for the reason recorded on
|
|
187
|
+
* {@link appendCommentary}.
|
|
176
188
|
* @param content - plain text, non-empty and within {@link MAX_APPEND_CHARS}.
|
|
177
|
-
* @param delegationId - `undefined` for session-wide steering.
|
|
189
|
+
* @param delegationId - `undefined` for best-effort session-wide steering.
|
|
178
190
|
*/
|
|
179
191
|
appendInstructions(content: string, delegationId?: string): Promise<void>
|
|
180
192
|
|
|
@@ -194,3 +206,31 @@ export interface RealtimeSession {
|
|
|
194
206
|
* halfway through a live conversation. Exact token accounting belongs to the adapter.
|
|
195
207
|
*/
|
|
196
208
|
export const MAX_APPEND_CHARS = 2000
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* How one delegated turn ended, when the answer was not an answer.
|
|
212
|
+
*
|
|
213
|
+
* Carried so a refusal can be *described* rather than only counted. The four cases are the four
|
|
214
|
+
* different things a person would do about it — nothing was asked, the controller refused (and said
|
|
215
|
+
* why), or it was admitted and nothing came back in time — and collapsing them into one `undefined`
|
|
216
|
+
* is what made the plugin's failures indistinguishable from outside it.
|
|
217
|
+
*/
|
|
218
|
+
export type RealtimeDelegationOutcome = 'answered' | 'declined' | 'refused' | 'timeout'
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* One delegated turn, settled, reported for diagnostics.
|
|
222
|
+
*
|
|
223
|
+
* `reason` is present only on `refused`, and is **redacted** before it is emitted: this is the first
|
|
224
|
+
* surface on which text the plugin did not author reaches a human, so it is safe by construction
|
|
225
|
+
* rather than by a later pass.
|
|
226
|
+
*/
|
|
227
|
+
export interface RealtimeDelegationSettlement {
|
|
228
|
+
/** The delegation this settles. Correlates with the ask, the answer and the journal. */
|
|
229
|
+
readonly id: string
|
|
230
|
+
/** The session that raised it. */
|
|
231
|
+
readonly sessionId: string
|
|
232
|
+
/** How it ended. */
|
|
233
|
+
readonly outcome: RealtimeDelegationOutcome
|
|
234
|
+
/** The controller's own reason, redacted, when the outcome is `refused`. */
|
|
235
|
+
readonly reason?: string
|
|
236
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Travis Driessen
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|