@myagentroam/protocol 0.10.22 → 0.10.24

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/index.d.ts CHANGED
@@ -29978,6 +29978,8 @@ export declare const nodeEnvelopeSchema: z.ZodObject<{
29978
29978
  replyTo?: string | undefined;
29979
29979
  }>;
29980
29980
  export type NodeEnvelope = z.infer<typeof nodeEnvelopeSchema>;
29981
+ /** Accept bounded structured upstream codes without changing their case. */
29982
+ export declare function isPublicErrorCode(value: unknown): value is string;
29981
29983
  export declare const publicErrorSchema: z.ZodObject<{
29982
29984
  code: z.ZodString;
29983
29985
  message: z.ZodString;
package/dist/index.js CHANGED
@@ -3034,7 +3034,12 @@ export const nodeEnvelopeSchema = z.object({
3034
3034
  replyTo: z.string().min(1).max(128).optional(),
3035
3035
  payload: z.unknown()
3036
3036
  });
3037
- const PUBLIC_ERROR_CODE = /^[A-Z][A-Z0-9_]{0,127}$/u;
3037
+ const APPLICATION_ERROR_CODE = /^[A-Z][A-Z0-9_]{0,127}$/u;
3038
+ const PUBLIC_ERROR_CODE = /^[A-Za-z][A-Za-z0-9_]{0,127}$/u;
3039
+ /** Accept bounded structured upstream codes without changing their case. */
3040
+ export function isPublicErrorCode(value) {
3041
+ return typeof value === 'string' && PUBLIC_ERROR_CODE.test(value);
3042
+ }
3038
3043
  const publicErrorTextSchema = z.string().trim().min(1).max(1_000);
3039
3044
  const publicErrorParameterKeySchema = z.string().trim().min(1).max(128);
3040
3045
  const publicErrorParametersSchema = z
@@ -3136,7 +3141,7 @@ function publicErrorSubject(code) {
3136
3141
  }
3137
3142
  /** Generates a readable English fallback for every stable application error code. */
3138
3143
  export function publicErrorMessage(code) {
3139
- const safeCode = PUBLIC_ERROR_CODE.test(code) ? code : 'INTERNAL_ERROR';
3144
+ const safeCode = isPublicErrorCode(code) ? code.toUpperCase() : 'INTERNAL_ERROR';
3140
3145
  const fixed = FIXED_PUBLIC_ERROR_MESSAGES[safeCode];
3141
3146
  if (fixed !== undefined)
3142
3147
  return fixed;
@@ -3189,11 +3194,11 @@ export function publicErrorMessage(code) {
3189
3194
  /** Builds the bounded public error shape shared by Node and Server boundaries. */
3190
3195
  export function safePublicError(error, fallback = 'INTERNAL_ERROR') {
3191
3196
  const record = publicErrorRecord(error);
3192
- const code = error instanceof Error && PUBLIC_ERROR_CODE.test(error.message)
3197
+ const code = error instanceof Error && APPLICATION_ERROR_CODE.test(error.message)
3193
3198
  ? error.message
3194
- : typeof record?.['code'] === 'string' && PUBLIC_ERROR_CODE.test(record['code'])
3199
+ : isPublicErrorCode(record?.['code'])
3195
3200
  ? record['code']
3196
- : PUBLIC_ERROR_CODE.test(fallback)
3201
+ : isPublicErrorCode(fallback)
3197
3202
  ? fallback
3198
3203
  : 'INTERNAL_ERROR';
3199
3204
  const fallbackMessage = publicErrorMessage(code);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@myagentroam/protocol",
3
- "version": "0.10.22",
3
+ "version": "0.10.24",
4
4
  "description": "Shared runtime protocol schemas for MyAgentRoam.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",