@turingfocus/chat-protocol 0.8.0 → 0.8.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/dist/resources.d.ts +14 -0
- package/dist/resources.d.ts.map +1 -1
- package/dist/resources.js +38 -1
- package/dist/resources.js.map +1 -1
- package/package.json +1 -1
package/dist/resources.d.ts
CHANGED
|
@@ -17,4 +17,18 @@ export interface ChatResourcePort {
|
|
|
17
17
|
open?(request: ChatResourceRequest): MaybePromise<void>;
|
|
18
18
|
download?(request: ChatResourceRequest): MaybePromise<void>;
|
|
19
19
|
}
|
|
20
|
+
/** Safe resource outcomes; host diagnostics must never be included in UI state. */
|
|
21
|
+
export type ChatResourceErrorCode = "unauthorized" | "network" | "not-found" | "expired" | "unsupported" | "cancelled" | "unknown";
|
|
22
|
+
export interface ChatResourceFailure {
|
|
23
|
+
readonly code: ChatResourceErrorCode;
|
|
24
|
+
/** Explicit retry is useful; this never requests automatic retries. */
|
|
25
|
+
readonly retryable: boolean;
|
|
26
|
+
}
|
|
27
|
+
/** Hosts may throw this error or reject with an object carrying a supported code. */
|
|
28
|
+
export declare class ChatResourceError extends Error {
|
|
29
|
+
readonly code: ChatResourceErrorCode;
|
|
30
|
+
constructor(code: ChatResourceErrorCode);
|
|
31
|
+
}
|
|
32
|
+
/** Whitelist only stable codes, discarding messages, causes, URLs and stacks. */
|
|
33
|
+
export declare function normalizeChatResourceError(error: unknown): ChatResourceFailure;
|
|
20
34
|
//# sourceMappingURL=resources.d.ts.map
|
package/dist/resources.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,KAAK,EAAE,YAAY,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAE3E,MAAM,MAAM,mBAAmB,GAAG,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WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,0FAA0F;IAC1F,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,CAAC;CAC7C;AACD,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAAC,oBAAoB,CAAC,CAAC;IAC3E,IAAI,CAAC,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;IACxD,QAAQ,CAAC,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED,mFAAmF;AACnF,MAAM,MAAM,qBAAqB,GAC7B,cAAc,GACd,SAAS,GACT,WAAW,GACX,SAAS,GACT,aAAa,GACb,WAAW,GACX,SAAS,CAAC;AAEd,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,uEAAuE;IACvE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED,qFAAqF;AACrF,qBAAa,iBAAkB,SAAQ,KAAK;IAC9B,QAAQ,CAAC,IAAI,EAAE,qBAAqB;gBAA3B,IAAI,EAAE,qBAAqB;CAIjD;AAED,iFAAiF;AACjF,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,OAAO,GACb,mBAAmB,CA0BrB"}
|
package/dist/resources.js
CHANGED
|
@@ -1,2 +1,39 @@
|
|
|
1
|
-
|
|
1
|
+
/** Hosts may throw this error or reject with an object carrying a supported code. */
|
|
2
|
+
export class ChatResourceError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(code) {
|
|
5
|
+
super("Chat resource operation did not complete.");
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.name = "ChatResourceError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** Whitelist only stable codes, discarding messages, causes, URLs and stacks. */
|
|
11
|
+
export function normalizeChatResourceError(error) {
|
|
12
|
+
let code = "unknown";
|
|
13
|
+
try {
|
|
14
|
+
if (typeof error === "object" && error !== null) {
|
|
15
|
+
if ("code" in error) {
|
|
16
|
+
const candidate = error.code;
|
|
17
|
+
switch (candidate) {
|
|
18
|
+
case "unauthorized":
|
|
19
|
+
case "network":
|
|
20
|
+
case "not-found":
|
|
21
|
+
case "expired":
|
|
22
|
+
case "unsupported":
|
|
23
|
+
case "cancelled":
|
|
24
|
+
code = candidate;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (code === "unknown" && "name" in error && error.name === "AbortError")
|
|
28
|
+
code = "cancelled";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// Even malformed host errors must have a safe fallback.
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
code,
|
|
36
|
+
retryable: ["unauthorized", "network", "expired", "unknown"].includes(code),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
2
39
|
//# sourceMappingURL=resources.js.map
|
package/dist/resources.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAqCA,qFAAqF;AACrF,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACrB;IAArB,YAAqB,IAA2B;QAC9C,KAAK,CAAC,2CAA2C,CAAC,CAAC;QADhC,SAAI,GAAJ,IAAI,CAAuB;QAE9C,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AAED,iFAAiF;AACjF,MAAM,UAAU,0BAA0B,CACxC,KAAc;IAEd,IAAI,IAAI,GAA0B,SAAS,CAAC;IAC5C,IAAI,CAAC;QACH,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;YAChD,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;gBACpB,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC;gBAC7B,QAAQ,SAAS,EAAE,CAAC;oBAClB,KAAK,cAAc,CAAC;oBACpB,KAAK,SAAS,CAAC;oBACf,KAAK,WAAW,CAAC;oBACjB,KAAK,SAAS,CAAC;oBACf,KAAK,aAAa,CAAC;oBACnB,KAAK,WAAW;wBACd,IAAI,GAAG,SAAS,CAAC;gBACrB,CAAC;YACH,CAAC;YACD,IAAI,IAAI,KAAK,SAAS,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY;gBACtE,IAAI,GAAG,WAAW,CAAC;QACvB,CAAC;IACH,CAAC;IAAC,MAAM,CAAC;QACP,wDAAwD;IAC1D,CAAC;IACD,OAAO;QACL,IAAI;QACJ,SAAS,EAAE,CAAC,cAAc,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;KAC5E,CAAC;AACJ,CAAC"}
|