@promptbook/cli 0.112.0-81 → 0.112.0-82

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/src/version.ts CHANGED
@@ -16,11 +16,11 @@ export const BOOK_LANGUAGE_VERSION: string_semantic_version = '2.0.0';
16
16
  * @generated
17
17
  * @see https://github.com/webgptorg/promptbook
18
18
  */
19
- export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.112.0-81';
19
+ export const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version = '0.112.0-82';
20
20
 
21
21
  /**
22
22
  * Represents the version string of the Promptbook engine.
23
- * It follows semantic versioning (e.g., `0.112.0-79`).
23
+ * It follows semantic versioning (e.g., `0.112.0-81`).
24
24
  *
25
25
  * @generated
26
26
  */
package/src/versions.txt CHANGED
@@ -1123,3 +1123,4 @@
1123
1123
  0.112.0-78
1124
1124
  0.112.0-79
1125
1125
  0.112.0-81
1126
+ 0.112.0-82
package/umd/index.umd.js CHANGED
@@ -60,7 +60,7 @@
60
60
  * @generated
61
61
  * @see https://github.com/webgptorg/promptbook
62
62
  */
63
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-81';
63
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-82';
64
64
  /**
65
65
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
66
66
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -35832,6 +35832,18 @@
35832
35832
  * @private internal constant of `ptbk agents-server`
35833
35833
  */
35834
35834
  const USER_CHAT_JOB_WORKER_POLL_INTERVAL_MS = 2000;
35835
+ /**
35836
+ * Number of identical worker failures suppressed before logging a repeated summary.
35837
+ *
35838
+ * @private internal constant of `ptbk agents-server`
35839
+ */
35840
+ const USER_CHAT_JOB_WORKER_REPEATED_ERROR_LOG_INTERVAL = 10;
35841
+ /**
35842
+ * Maximum worker response body length shown in foreground diagnostics.
35843
+ *
35844
+ * @private internal constant of `ptbk agents-server`
35845
+ */
35846
+ const USER_CHAT_JOB_WORKER_ERROR_BODY_MAX_LENGTH = 2000;
35835
35847
  /**
35836
35848
  * HTTP status used by an idle internal worker tick with no job to process.
35837
35849
  *
@@ -36064,10 +36076,16 @@
36064
36076
  }
36065
36077
  isTickRunning = true;
36066
36078
  triggerUserChatJobWorkerTick(options)
36079
+ .then(() => {
36080
+ clearUserChatJobWorkerError(options.state);
36081
+ })
36067
36082
  .catch((error) => {
36068
36083
  const message = error instanceof Error ? error.message : String(error);
36069
- logRunnerEvent(options.logStreams.runner, `User chat worker tick failed: ${message}`);
36070
- addUiError(options.state, message);
36084
+ reportUserChatJobWorkerError({
36085
+ logStream: options.logStreams.runner,
36086
+ message,
36087
+ state: options.state,
36088
+ });
36071
36089
  })
36072
36090
  .finally(() => {
36073
36091
  isTickRunning = false;
@@ -36089,8 +36107,87 @@
36089
36107
  body: '{}',
36090
36108
  });
36091
36109
  if (!response.ok && response.status !== HTTP_NO_CONTENT_STATUS_CODE) {
36092
- throw new Error(`Internal user chat worker returned ${response.status} ${response.statusText}.`);
36110
+ const details = await readUserChatJobWorkerErrorDetails(response);
36111
+ throw new Error(createUserChatJobWorkerErrorMessage(response, details));
36112
+ }
36113
+ }
36114
+ /**
36115
+ * Reports worker failures while suppressing identical repeated foreground noise.
36116
+ */
36117
+ function reportUserChatJobWorkerError(options) {
36118
+ const previousError = options.state.lastUserChatJobWorkerError;
36119
+ if ((previousError === null || previousError === void 0 ? void 0 : previousError.message) === options.message) {
36120
+ const repeatCount = previousError.repeatCount + 1;
36121
+ options.state.lastUserChatJobWorkerError = {
36122
+ message: options.message,
36123
+ repeatCount,
36124
+ };
36125
+ if (repeatCount % USER_CHAT_JOB_WORKER_REPEATED_ERROR_LOG_INTERVAL !== 0) {
36126
+ return;
36127
+ }
36128
+ const repeatedMessage = `User chat worker tick is still failing after ${repeatCount} attempts: ${options.message}`;
36129
+ logRunnerEvent(options.logStream, repeatedMessage);
36130
+ addUiError(options.state, repeatedMessage);
36131
+ return;
36132
+ }
36133
+ options.state.lastUserChatJobWorkerError = {
36134
+ message: options.message,
36135
+ repeatCount: 1,
36136
+ };
36137
+ logRunnerEvent(options.logStream, `User chat worker tick failed: ${options.message}`);
36138
+ addUiError(options.state, options.message);
36139
+ }
36140
+ /**
36141
+ * Resets repeated-error suppression after a successful worker tick.
36142
+ */
36143
+ function clearUserChatJobWorkerError(state) {
36144
+ state.lastUserChatJobWorkerError = undefined;
36145
+ }
36146
+ /**
36147
+ * Reads a worker error payload so foreground logs show the route-level reason.
36148
+ */
36149
+ async function readUserChatJobWorkerErrorDetails(response) {
36150
+ const body = await response.text().catch(() => '');
36151
+ const trimmedBody = body.trim();
36152
+ if (!trimmedBody) {
36153
+ return null;
36154
+ }
36155
+ const parsedMessage = parseUserChatJobWorkerErrorMessage(trimmedBody);
36156
+ return truncateUserChatJobWorkerErrorDetails(parsedMessage || trimmedBody);
36157
+ }
36158
+ /**
36159
+ * Extracts a readable error message from the worker route JSON response.
36160
+ */
36161
+ function parseUserChatJobWorkerErrorMessage(body) {
36162
+ try {
36163
+ const parsedBody = JSON.parse(body);
36164
+ const errorMessage = typeof parsedBody.error === 'string' ? parsedBody.error : undefined;
36165
+ const fallbackMessage = typeof parsedBody.message === 'string' ? parsedBody.message : undefined;
36166
+ return errorMessage || fallbackMessage || null;
36167
+ }
36168
+ catch (_a) {
36169
+ return null;
36170
+ }
36171
+ }
36172
+ /**
36173
+ * Builds the foreground worker failure message from HTTP status and route details.
36174
+ */
36175
+ function createUserChatJobWorkerErrorMessage(response, details) {
36176
+ const statusText = response.statusText ? ` ${response.statusText}` : '';
36177
+ const statusMessage = `${response.status}${statusText}`;
36178
+ if (!details) {
36179
+ return `Internal user chat worker returned ${statusMessage}.`;
36180
+ }
36181
+ return `Internal user chat worker returned ${statusMessage}: ${details}`;
36182
+ }
36183
+ /**
36184
+ * Keeps foreground worker diagnostics bounded when a route returns a large payload.
36185
+ */
36186
+ function truncateUserChatJobWorkerErrorDetails(details) {
36187
+ if (details.length <= USER_CHAT_JOB_WORKER_ERROR_BODY_MAX_LENGTH) {
36188
+ return details;
36093
36189
  }
36190
+ return `${details.slice(0, USER_CHAT_JOB_WORKER_ERROR_BODY_MAX_LENGTH)}...`;
36094
36191
  }
36095
36192
  /**
36096
36193
  * Creates file streams for service output persisted below `./logs`.