@celljs/ta-client 4.11.0 → 4.13.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.
@@ -59,7 +59,11 @@ export var SessionReducer;
59
59
  return { ...state, compacting: undefined };
60
60
  case 'auto_retry_start': {
61
61
  const { attempt, maxAttempts, delayMs, errorMessage } = event;
62
- return { ...state, retry: { attempt, maxAttempts, delayMs, errorMessage } };
62
+ // pi leaves the attempt that failed out of the conversation it keeps: so does the client, which
63
+ // would show it until the conversation is read again (and count its messages one more).
64
+ const last = state.messages[state.messages.length - 1];
65
+ const messages = (last === null || last === void 0 ? void 0 : last.role) === 'assistant' && last.stopReason === 'error' ? state.messages.slice(0, -1) : state.messages;
66
+ return { ...state, messages, retry: { attempt, maxAttempts, delayMs, errorMessage } };
63
67
  }
64
68
  case 'auto_retry_end':
65
69
  return { ...state, retry: undefined };
@@ -7,9 +7,13 @@ export declare class TaRemoteError extends Error {
7
7
  readonly code?: TaErrorCode | undefined;
8
8
  readonly hint?: string | undefined;
9
9
  readonly rpcCode?: number | undefined;
10
+ /** All ta serve said of the failure: for a refused call, the action it needs (TaForbiddenData). */
11
+ readonly data?: Readonly<Record<string, unknown>> | undefined;
10
12
  /** JSON-RPC's code for a method the server does not have. */
11
13
  static readonly METHOD_NOT_FOUND = -32601;
12
- constructor(message: string, code?: TaErrorCode | undefined, hint?: string | undefined, rpcCode?: number | undefined);
14
+ constructor(message: string, code?: TaErrorCode | undefined, hint?: string | undefined, rpcCode?: number | undefined,
15
+ /** All ta serve said of the failure: for a refused call, the action it needs (TaForbiddenData). */
16
+ data?: Readonly<Record<string, unknown>> | undefined);
13
17
  /** The error of a JSON-RPC answer: its code, and the code and hint of ta serve when it named the failure. */
14
18
  static of(error: {
15
19
  message: string;
@@ -4,18 +4,21 @@ import { TA_ACCESS_SERVICE, TA_AUTH_SERVICE, TA_CLIENT_SERVICE, TA_GATEWAY_SERVI
4
4
  * by which a client tells a method an older ta serve does not have (`TaRemoteError.METHOD_NOT_FOUND`).
5
5
  */
6
6
  export class TaRemoteError extends Error {
7
- constructor(message, code, hint, rpcCode) {
7
+ constructor(message, code, hint, rpcCode,
8
+ /** All ta serve said of the failure: for a refused call, the action it needs (TaForbiddenData). */
9
+ data) {
8
10
  super(message);
9
11
  this.code = code;
10
12
  this.hint = hint;
11
13
  this.rpcCode = rpcCode;
14
+ this.data = data;
12
15
  this.name = 'TaRemoteError';
13
16
  }
14
17
  /** The error of a JSON-RPC answer: its code, and the code and hint of ta serve when it named the failure. */
15
18
  static of(error) {
16
19
  var _a;
17
20
  const data = (_a = error.data) === null || _a === void 0 ? void 0 : _a.data;
18
- return new TaRemoteError(error.message, data === null || data === void 0 ? void 0 : data.code, data === null || data === void 0 ? void 0 : data.hint, error.code);
21
+ return new TaRemoteError(error.message, data === null || data === void 0 ? void 0 : data.code, data === null || data === void 0 ? void 0 : data.hint, error.code, data);
19
22
  }
20
23
  /** A call that waited for a connection that did not come back. */
21
24
  static notConnected() {
@@ -62,7 +62,11 @@ var SessionReducer;
62
62
  return { ...state, compacting: undefined };
63
63
  case 'auto_retry_start': {
64
64
  const { attempt, maxAttempts, delayMs, errorMessage } = event;
65
- return { ...state, retry: { attempt, maxAttempts, delayMs, errorMessage } };
65
+ // pi leaves the attempt that failed out of the conversation it keeps: so does the client, which
66
+ // would show it until the conversation is read again (and count its messages one more).
67
+ const last = state.messages[state.messages.length - 1];
68
+ const messages = (last === null || last === void 0 ? void 0 : last.role) === 'assistant' && last.stopReason === 'error' ? state.messages.slice(0, -1) : state.messages;
69
+ return { ...state, messages, retry: { attempt, maxAttempts, delayMs, errorMessage } };
66
70
  }
67
71
  case 'auto_retry_end':
68
72
  return { ...state, retry: undefined };
@@ -7,9 +7,13 @@ export declare class TaRemoteError extends Error {
7
7
  readonly code?: TaErrorCode | undefined;
8
8
  readonly hint?: string | undefined;
9
9
  readonly rpcCode?: number | undefined;
10
+ /** All ta serve said of the failure: for a refused call, the action it needs (TaForbiddenData). */
11
+ readonly data?: Readonly<Record<string, unknown>> | undefined;
10
12
  /** JSON-RPC's code for a method the server does not have. */
11
13
  static readonly METHOD_NOT_FOUND = -32601;
12
- constructor(message: string, code?: TaErrorCode | undefined, hint?: string | undefined, rpcCode?: number | undefined);
14
+ constructor(message: string, code?: TaErrorCode | undefined, hint?: string | undefined, rpcCode?: number | undefined,
15
+ /** All ta serve said of the failure: for a refused call, the action it needs (TaForbiddenData). */
16
+ data?: Readonly<Record<string, unknown>> | undefined);
13
17
  /** The error of a JSON-RPC answer: its code, and the code and hint of ta serve when it named the failure. */
14
18
  static of(error: {
15
19
  message: string;
@@ -7,18 +7,21 @@ const ta_protocol_1 = require("@celljs/ta-protocol");
7
7
  * by which a client tells a method an older ta serve does not have (`TaRemoteError.METHOD_NOT_FOUND`).
8
8
  */
9
9
  class TaRemoteError extends Error {
10
- constructor(message, code, hint, rpcCode) {
10
+ constructor(message, code, hint, rpcCode,
11
+ /** All ta serve said of the failure: for a refused call, the action it needs (TaForbiddenData). */
12
+ data) {
11
13
  super(message);
12
14
  this.code = code;
13
15
  this.hint = hint;
14
16
  this.rpcCode = rpcCode;
17
+ this.data = data;
15
18
  this.name = 'TaRemoteError';
16
19
  }
17
20
  /** The error of a JSON-RPC answer: its code, and the code and hint of ta serve when it named the failure. */
18
21
  static of(error) {
19
22
  var _a;
20
23
  const data = (_a = error.data) === null || _a === void 0 ? void 0 : _a.data;
21
- return new TaRemoteError(error.message, data === null || data === void 0 ? void 0 : data.code, data === null || data === void 0 ? void 0 : data.hint, error.code);
24
+ return new TaRemoteError(error.message, data === null || data === void 0 ? void 0 : data.code, data === null || data === void 0 ? void 0 : data.hint, error.code, data);
22
25
  }
23
26
  /** A call that waited for a connection that did not come back. */
24
27
  static notConnected() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-client",
3
- "version": "4.11.0",
3
+ "version": "4.13.0",
4
4
  "description": "A client of ta serve for any JavaScript runtime: connection and UI-independent session state",
5
5
  "homepage": "https://github.com/cellbang/cell",
6
6
  "bugs": {
@@ -29,7 +29,7 @@
29
29
  "watch": "tsc -b -w --preserveWatchOutput"
30
30
  },
31
31
  "dependencies": {
32
- "@celljs/ta-protocol": "4.11.0"
32
+ "@celljs/ta-protocol": "4.13.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@earendil-works/pi-ai": "^1.5.2",