mirror of
https://github.com/MoonshotAI/kimi-code.git
synced 2026-09-10 19:00:46 +00:00
* feat(protocol): extract shared protocol package from agent-core - add `@moonshot-ai/protocol` package with REST/WS schemas, envelopes, error codes, event types, and display schemas\n- migrate agent-core `events.ts` and `display/schemas.ts` to re-export from protocol - add centralized `onUnexpectedError` handler for safe emitter listener callbacks - reject forkSession when source session has an active running turn - add protocol schema tests and unexpectedError handler tests
14 lines
371 B
TypeScript
14 lines
371 B
TypeScript
import { isValid, ulid } from 'ulid';
|
|
|
|
export const ulidRegex = /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/;
|
|
|
|
export function parseOrGenerateRequestId(headerValue: string | undefined): string {
|
|
if (typeof headerValue === 'string' && isValid(headerValue)) {
|
|
return headerValue;
|
|
}
|
|
return ulid();
|
|
}
|
|
|
|
export function isUlid(value: string): boolean {
|
|
return isValid(value);
|
|
}
|