pybao-xc-sdk 1.5.57 → 1.5.59

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.mts CHANGED
@@ -2415,13 +2415,11 @@ interface Attachment {
2415
2415
  }
2416
2416
  interface PromptResponse {
2417
2417
  requestId: string;
2418
- messages: Message[];
2419
- finishReason: 'end_turn' | 'tool_calls' | 'max_tokens' | 'aborted';
2420
- usage: {
2421
- inputTokens: number;
2422
- outputTokens: number;
2423
- totalTokens: number;
2424
- };
2418
+ sessionId: string;
2419
+ accepted: boolean;
2420
+ acceptedAt: number;
2421
+ transport: 'events';
2422
+ stream: 'events';
2425
2423
  }
2426
2424
  interface PermissionResponseRequest {
2427
2425
  decision: 'allow' | 'deny' | 'allowAll';
@@ -2528,6 +2526,9 @@ declare class PybClient {
2528
2526
  items: unknown[];
2529
2527
  }>;
2530
2528
  };
2529
+ readonly command: {
2530
+ promptAsync: (sessionId: string, request: PromptRequest) => Promise<PromptResponse>;
2531
+ };
2531
2532
  readonly mcp: {
2532
2533
  list: () => Promise<unknown[]>;
2533
2534
  connect: (serverName: string) => Promise<unknown>;
@@ -2581,6 +2582,7 @@ declare class PybClient {
2581
2582
  private updateSessionRequest;
2582
2583
  private deleteSessionRequest;
2583
2584
  private sendPromptRequest;
2585
+ private sendPromptCommandRequest;
2584
2586
  private abortRequestRequest;
2585
2587
  private getMessagesRequest;
2586
2588
  respondToPermission(permissionId: string, request: PermissionResponseRequest): Promise<{
@@ -3338,6 +3340,11 @@ type ProtocolClientLike = {
3338
3340
  requestId?: string;
3339
3341
  }>;
3340
3342
  };
3343
+ command?: {
3344
+ promptAsync: (sessionId: string, request: Record<string, unknown>) => Promise<{
3345
+ requestId: string;
3346
+ }>;
3347
+ };
3341
3348
  };
3342
3349
  type ProtocolSseEventLike = {
3343
3350
  type: string;
@@ -3442,6 +3449,6 @@ declare function resolveDefaultBackendFromEnv(input?: {
3442
3449
  routeSource: SessionBackendRouteSource;
3443
3450
  };
3444
3451
 
3445
- declare const SDK_VERSION = "1.5.57";
3452
+ declare const SDK_VERSION = "1.5.59";
3446
3453
 
3447
3454
  export { type APIError, type Attachment, type AuthRemoveResponse, type AuthSetRequest, type AuthSetResponse, type BackendKind, BackendKindSchema, type CanUseToolCallback, type CanUseToolDecision, type ContentBlock, ContentBlockSchema, type CreateSessionRequest, type CreateSessionResponse, DEFAULT_SESSION_BACKEND_ROUTER_CONFIG, type DualTrackMetrics, DualTrackMetricsSchema, type DualTrackRawStats, DualTrackRawStatsSchema, type DualTrackThresholds, DualTrackThresholdsSchema, type ErrorEvent, ErrorEventSchema, type ErrorStreamEvent, ErrorStreamEventSchema, FALLBACK_TRIGGER_MATRIX, type FallbackTriggerReason, FallbackTriggerReasonSchema, type GetDefaultModelRequest, type GetDefaultModelResponse, type HealthResponse, type Message, type MessageCompletedEvent, MessageCompletedEventSchema, type MessageCreatedEvent, MessageCreatedEventSchema, MessageSchema, type MessageUpdatedEvent, MessageUpdatedEventSchema, type ModelCatalogItem, type ModelCatalogResponse, type ModelPoolSourceRecord, type ModelPoolStatusItem, type ModelPoolStatusResponse, type ModelRef, PROTOCOL_ERROR_TO_RUNTIME_ERROR_TYPE, type PermissionEvaluator, type PermissionMode, type PermissionRequestedEvent, PermissionRequestedEventSchema, type PermissionRespondedEvent, PermissionRespondedEventSchema, type PermissionResponseRequest, type PermissionTimeoutEvent, PermissionTimeoutEventSchema, type PromptRequest, type PromptResponse, type ProtocolErrorCode, ProtocolErrorCodeSchema, type ProtocolErrorMapping, ProtocolErrorMappingSchema, type ProtocolSessionStreamBinding, ProtocolSessionStreamBindingManager, type ProviderAuthMethod, type ProviderListResponse, type ProviderOAuthAuthorizeRequest, type ProviderOAuthAuthorizeResponse, type ProviderOAuthCallbackRequest, type ProviderOAuthCallbackResponse, type ProviderRef, PybAPIError, PybClient, PybConfigError, PybNetworkError, PybResponseParseError, type PybSSEEvent, PybSSEEventSchema, type QuerySessionExecutor, type RequestCompletedEvent, RequestCompletedEventSchema, type RequestStartedEvent, RequestStartedEventSchema, type ResolvePermissionDecisionInput, type ResolveRuntimeModelRequest, type ResolveRuntimeModelResponse, type RuntimeBackendErrorPhase, type RuntimeCompatibleLegacyEvent, type RuntimeEvent, type RuntimeEventDomain, RuntimeEventDomainSchema, type RuntimeEventErrorType, RuntimeEventErrorTypeSchema, RuntimeEventSchema, type RuntimePermissionPolicy, type RuntimeSession, type RuntimeSessionConfig, type RuntimeSessionEvent, RuntimeSessionEventSchema, type RuntimeSessionInput, RuntimeSessionInputSchema, type RuntimeSessionStatus, RuntimeSessionStatusSchema, S4_PROTOCOL_ERROR_TOP_CODES, S5_A0_EQUIVALENCE_SAMPLE_SET, SDK_VERSION, SESSION_BACKEND_CONFIG_CONTRACT_VERSION, SESSION_BACKEND_ENV_KEY, SESSION_BACKEND_OBSERVABILITY_SPEC, SSEClient, type SSEDedupEvent, SSEDedupEventSchema, type SSEEvent, type SSEReplayEvent, SSEReplayEventSchema, type SSEReplayGapEvent, SSEReplayGapEventSchema, type ServerConnectedEvent, ServerConnectedEventSchema, type ServerHeartbeatEvent, ServerHeartbeatEventSchema, type ServerStatusEvent, ServerStatusEventSchema, type SessionBackend, type SessionBackendRouteSource, type SessionBackendRouterConfig, SessionBackendRouterConfigSchema, type SessionBackendSession, type SessionBackendUserConfig, type SessionCreatedEvent, SessionCreatedEventSchema, type SessionDeletedEvent, SessionDeletedEventSchema, type SessionEventPublisher, type SessionInfo, type SessionUpdatedEvent, SessionUpdatedEventSchema, type SetDefaultModelRequest, type SetDefaultModelResponse, type ToolCompletedEvent, ToolCompletedEventSchema, type ToolErrorEvent, ToolErrorEventSchema, type ToolInfo, type ToolPermissionContext, type ToolProgressEvent, ToolProgressEventSchema, type ToolResolver, type ToolStartedEvent, ToolStartedEventSchema, type V2Message, V2MessageSchema, V2RequestStatusSchema, type V2Session, V2SessionSchema, type V2SessionStatus, V2SessionStatusSchema, type V2ToolUseContext, V2ToolUseContextSchema, buildDefaultDualTrackThresholds, buildV2ToolUseContextFromPromptRequest, canTransitionV2SessionStatus, createDefaultToolPermissionContextForSdk, createProtocolSessionBackend, createPybClient, createRuntimePermissionContextForSession, createRuntimeSession, createRuntimeSessionBackend, createSSEClient, createSessionBackendRouter, emitBackendConfigWarning, evaluateDualTrackMetrics, evaluateV1DeprecationReadiness, getRuntimeEventMappingRules, isToolAutoExecutableInContext, mapProtocolErrorCodeToRuntimeErrorType, mapRuntimeBackendErrorToRuntimeEvent, mapRuntimeMessageToV2, mapRuntimeSessionStatusToV2, mapV1MessageToV2, mapV1SessionStatusToV2, projectLegacyEventToRuntimeEvent, projectRuntimeEventToLegacyEvent, resolveDefaultBackend, resolveDefaultBackendFromEnv, resolvePermissionDecision, resolvePermissionModeForSdk, resolveRouterBackendKind, shouldTriggerFallback, validateV2Message, validateV2Session, validateV2ToolUseContext };
package/dist/index.d.ts CHANGED
@@ -2415,13 +2415,11 @@ interface Attachment {
2415
2415
  }
2416
2416
  interface PromptResponse {
2417
2417
  requestId: string;
2418
- messages: Message[];
2419
- finishReason: 'end_turn' | 'tool_calls' | 'max_tokens' | 'aborted';
2420
- usage: {
2421
- inputTokens: number;
2422
- outputTokens: number;
2423
- totalTokens: number;
2424
- };
2418
+ sessionId: string;
2419
+ accepted: boolean;
2420
+ acceptedAt: number;
2421
+ transport: 'events';
2422
+ stream: 'events';
2425
2423
  }
2426
2424
  interface PermissionResponseRequest {
2427
2425
  decision: 'allow' | 'deny' | 'allowAll';
@@ -2528,6 +2526,9 @@ declare class PybClient {
2528
2526
  items: unknown[];
2529
2527
  }>;
2530
2528
  };
2529
+ readonly command: {
2530
+ promptAsync: (sessionId: string, request: PromptRequest) => Promise<PromptResponse>;
2531
+ };
2531
2532
  readonly mcp: {
2532
2533
  list: () => Promise<unknown[]>;
2533
2534
  connect: (serverName: string) => Promise<unknown>;
@@ -2581,6 +2582,7 @@ declare class PybClient {
2581
2582
  private updateSessionRequest;
2582
2583
  private deleteSessionRequest;
2583
2584
  private sendPromptRequest;
2585
+ private sendPromptCommandRequest;
2584
2586
  private abortRequestRequest;
2585
2587
  private getMessagesRequest;
2586
2588
  respondToPermission(permissionId: string, request: PermissionResponseRequest): Promise<{
@@ -3338,6 +3340,11 @@ type ProtocolClientLike = {
3338
3340
  requestId?: string;
3339
3341
  }>;
3340
3342
  };
3343
+ command?: {
3344
+ promptAsync: (sessionId: string, request: Record<string, unknown>) => Promise<{
3345
+ requestId: string;
3346
+ }>;
3347
+ };
3341
3348
  };
3342
3349
  type ProtocolSseEventLike = {
3343
3350
  type: string;
@@ -3442,6 +3449,6 @@ declare function resolveDefaultBackendFromEnv(input?: {
3442
3449
  routeSource: SessionBackendRouteSource;
3443
3450
  };
3444
3451
 
3445
- declare const SDK_VERSION = "1.5.57";
3452
+ declare const SDK_VERSION = "1.5.59";
3446
3453
 
3447
3454
  export { type APIError, type Attachment, type AuthRemoveResponse, type AuthSetRequest, type AuthSetResponse, type BackendKind, BackendKindSchema, type CanUseToolCallback, type CanUseToolDecision, type ContentBlock, ContentBlockSchema, type CreateSessionRequest, type CreateSessionResponse, DEFAULT_SESSION_BACKEND_ROUTER_CONFIG, type DualTrackMetrics, DualTrackMetricsSchema, type DualTrackRawStats, DualTrackRawStatsSchema, type DualTrackThresholds, DualTrackThresholdsSchema, type ErrorEvent, ErrorEventSchema, type ErrorStreamEvent, ErrorStreamEventSchema, FALLBACK_TRIGGER_MATRIX, type FallbackTriggerReason, FallbackTriggerReasonSchema, type GetDefaultModelRequest, type GetDefaultModelResponse, type HealthResponse, type Message, type MessageCompletedEvent, MessageCompletedEventSchema, type MessageCreatedEvent, MessageCreatedEventSchema, MessageSchema, type MessageUpdatedEvent, MessageUpdatedEventSchema, type ModelCatalogItem, type ModelCatalogResponse, type ModelPoolSourceRecord, type ModelPoolStatusItem, type ModelPoolStatusResponse, type ModelRef, PROTOCOL_ERROR_TO_RUNTIME_ERROR_TYPE, type PermissionEvaluator, type PermissionMode, type PermissionRequestedEvent, PermissionRequestedEventSchema, type PermissionRespondedEvent, PermissionRespondedEventSchema, type PermissionResponseRequest, type PermissionTimeoutEvent, PermissionTimeoutEventSchema, type PromptRequest, type PromptResponse, type ProtocolErrorCode, ProtocolErrorCodeSchema, type ProtocolErrorMapping, ProtocolErrorMappingSchema, type ProtocolSessionStreamBinding, ProtocolSessionStreamBindingManager, type ProviderAuthMethod, type ProviderListResponse, type ProviderOAuthAuthorizeRequest, type ProviderOAuthAuthorizeResponse, type ProviderOAuthCallbackRequest, type ProviderOAuthCallbackResponse, type ProviderRef, PybAPIError, PybClient, PybConfigError, PybNetworkError, PybResponseParseError, type PybSSEEvent, PybSSEEventSchema, type QuerySessionExecutor, type RequestCompletedEvent, RequestCompletedEventSchema, type RequestStartedEvent, RequestStartedEventSchema, type ResolvePermissionDecisionInput, type ResolveRuntimeModelRequest, type ResolveRuntimeModelResponse, type RuntimeBackendErrorPhase, type RuntimeCompatibleLegacyEvent, type RuntimeEvent, type RuntimeEventDomain, RuntimeEventDomainSchema, type RuntimeEventErrorType, RuntimeEventErrorTypeSchema, RuntimeEventSchema, type RuntimePermissionPolicy, type RuntimeSession, type RuntimeSessionConfig, type RuntimeSessionEvent, RuntimeSessionEventSchema, type RuntimeSessionInput, RuntimeSessionInputSchema, type RuntimeSessionStatus, RuntimeSessionStatusSchema, S4_PROTOCOL_ERROR_TOP_CODES, S5_A0_EQUIVALENCE_SAMPLE_SET, SDK_VERSION, SESSION_BACKEND_CONFIG_CONTRACT_VERSION, SESSION_BACKEND_ENV_KEY, SESSION_BACKEND_OBSERVABILITY_SPEC, SSEClient, type SSEDedupEvent, SSEDedupEventSchema, type SSEEvent, type SSEReplayEvent, SSEReplayEventSchema, type SSEReplayGapEvent, SSEReplayGapEventSchema, type ServerConnectedEvent, ServerConnectedEventSchema, type ServerHeartbeatEvent, ServerHeartbeatEventSchema, type ServerStatusEvent, ServerStatusEventSchema, type SessionBackend, type SessionBackendRouteSource, type SessionBackendRouterConfig, SessionBackendRouterConfigSchema, type SessionBackendSession, type SessionBackendUserConfig, type SessionCreatedEvent, SessionCreatedEventSchema, type SessionDeletedEvent, SessionDeletedEventSchema, type SessionEventPublisher, type SessionInfo, type SessionUpdatedEvent, SessionUpdatedEventSchema, type SetDefaultModelRequest, type SetDefaultModelResponse, type ToolCompletedEvent, ToolCompletedEventSchema, type ToolErrorEvent, ToolErrorEventSchema, type ToolInfo, type ToolPermissionContext, type ToolProgressEvent, ToolProgressEventSchema, type ToolResolver, type ToolStartedEvent, ToolStartedEventSchema, type V2Message, V2MessageSchema, V2RequestStatusSchema, type V2Session, V2SessionSchema, type V2SessionStatus, V2SessionStatusSchema, type V2ToolUseContext, V2ToolUseContextSchema, buildDefaultDualTrackThresholds, buildV2ToolUseContextFromPromptRequest, canTransitionV2SessionStatus, createDefaultToolPermissionContextForSdk, createProtocolSessionBackend, createPybClient, createRuntimePermissionContextForSession, createRuntimeSession, createRuntimeSessionBackend, createSSEClient, createSessionBackendRouter, emitBackendConfigWarning, evaluateDualTrackMetrics, evaluateV1DeprecationReadiness, getRuntimeEventMappingRules, isToolAutoExecutableInContext, mapProtocolErrorCodeToRuntimeErrorType, mapRuntimeBackendErrorToRuntimeEvent, mapRuntimeMessageToV2, mapRuntimeSessionStatusToV2, mapV1MessageToV2, mapV1SessionStatusToV2, projectLegacyEventToRuntimeEvent, projectRuntimeEventToLegacyEvent, resolveDefaultBackend, resolveDefaultBackendFromEnv, resolvePermissionDecision, resolvePermissionModeForSdk, resolveRouterBackendKind, shouldTriggerFallback, validateV2Message, validateV2Session, validateV2ToolUseContext };
package/dist/index.js CHANGED
@@ -530,6 +530,7 @@ var PybClient = class _PybClient {
530
530
  headers;
531
531
  directory;
532
532
  session;
533
+ command;
533
534
  mcp;
534
535
  tool;
535
536
  config;
@@ -559,6 +560,9 @@ var PybClient = class _PybClient {
559
560
  abort: (sessionId) => this.abortRequestRequest(sessionId),
560
561
  messages: (sessionId, params) => this.getMessagesRequest(sessionId, params)
561
562
  };
563
+ this.command = {
564
+ promptAsync: (sessionId, request) => this.sendPromptCommandRequest(sessionId, request)
565
+ };
562
566
  this.mcp = {
563
567
  list: () => this.listMCPServersRequest(),
564
568
  connect: (serverName) => this.connectMCPServerRequest(serverName),
@@ -652,12 +656,29 @@ var PybClient = class _PybClient {
652
656
  // Message API
653
657
  // ============================================================
654
658
  async sendPromptRequest(sessionId, request) {
659
+ if (request.options?.stream === true) {
660
+ throw new PybConfigError(
661
+ "SDK_PROMPT_STREAM_UNSUPPORTED",
662
+ "session.prompt no longer supports stream=true; use command.promptAsync and /events",
663
+ { sessionId }
664
+ );
665
+ }
655
666
  const response = await this.fetch(`/sessions/${sessionId}/prompt`, {
656
667
  method: "POST",
657
668
  body: JSON.stringify({ ...request, options: { stream: false, ...request.options } })
658
669
  });
659
670
  return this.parseData(response, `/sessions/${sessionId}/prompt`);
660
671
  }
672
+ async sendPromptCommandRequest(sessionId, request) {
673
+ const response = await this.fetch(`/sessions/${sessionId}/prompt`, {
674
+ method: "POST",
675
+ body: JSON.stringify({
676
+ ...request,
677
+ options: { ...request.options, stream: false }
678
+ })
679
+ });
680
+ return this.parseData(response, `/sessions/${sessionId}/prompt`);
681
+ }
661
682
  async abortRequestRequest(sessionId) {
662
683
  const response = await this.fetch(`/sessions/${sessionId}/abort`, {
663
684
  method: "POST"
@@ -2099,11 +2120,15 @@ function createProtocolSessionBackend(input) {
2099
2120
  return {
2100
2121
  send(input2) {
2101
2122
  if (closed) throw new Error("PROTOCOL_BACKEND_SESSION_CLOSED");
2102
- pybClient.session.prompt(sessionId, {
2123
+ const promptOperation = pybClient.command?.promptAsync ? pybClient.command.promptAsync(sessionId, {
2124
+ message: input2.message,
2125
+ attachments: input2.attachments
2126
+ }) : pybClient.session.prompt(sessionId, {
2103
2127
  message: input2.message,
2104
2128
  attachments: input2.attachments,
2105
- options: { stream: true }
2106
- }).catch((error) => {
2129
+ options: { stream: false }
2130
+ });
2131
+ promptOperation.catch((error) => {
2107
2132
  const runtimeErrorEvent = toRuntimeErrorEvent(error, sessionId);
2108
2133
  runtimeQueue.push(runtimeErrorEvent);
2109
2134
  legacyQueue.push({
@@ -2600,7 +2625,7 @@ function isRecord4(value) {
2600
2625
  }
2601
2626
 
2602
2627
  // src/version.ts
2603
- var SDK_VERSION = "1.5.57";
2628
+ var SDK_VERSION = "1.5.59";
2604
2629
  // Annotate the CommonJS export names for ESM import in node:
2605
2630
  0 && (module.exports = {
2606
2631
  BackendKindSchema,
package/dist/index.mjs CHANGED
@@ -411,6 +411,7 @@ var PybClient = class _PybClient {
411
411
  headers;
412
412
  directory;
413
413
  session;
414
+ command;
414
415
  mcp;
415
416
  tool;
416
417
  config;
@@ -440,6 +441,9 @@ var PybClient = class _PybClient {
440
441
  abort: (sessionId) => this.abortRequestRequest(sessionId),
441
442
  messages: (sessionId, params) => this.getMessagesRequest(sessionId, params)
442
443
  };
444
+ this.command = {
445
+ promptAsync: (sessionId, request) => this.sendPromptCommandRequest(sessionId, request)
446
+ };
443
447
  this.mcp = {
444
448
  list: () => this.listMCPServersRequest(),
445
449
  connect: (serverName) => this.connectMCPServerRequest(serverName),
@@ -533,12 +537,29 @@ var PybClient = class _PybClient {
533
537
  // Message API
534
538
  // ============================================================
535
539
  async sendPromptRequest(sessionId, request) {
540
+ if (request.options?.stream === true) {
541
+ throw new PybConfigError(
542
+ "SDK_PROMPT_STREAM_UNSUPPORTED",
543
+ "session.prompt no longer supports stream=true; use command.promptAsync and /events",
544
+ { sessionId }
545
+ );
546
+ }
536
547
  const response = await this.fetch(`/sessions/${sessionId}/prompt`, {
537
548
  method: "POST",
538
549
  body: JSON.stringify({ ...request, options: { stream: false, ...request.options } })
539
550
  });
540
551
  return this.parseData(response, `/sessions/${sessionId}/prompt`);
541
552
  }
553
+ async sendPromptCommandRequest(sessionId, request) {
554
+ const response = await this.fetch(`/sessions/${sessionId}/prompt`, {
555
+ method: "POST",
556
+ body: JSON.stringify({
557
+ ...request,
558
+ options: { ...request.options, stream: false }
559
+ })
560
+ });
561
+ return this.parseData(response, `/sessions/${sessionId}/prompt`);
562
+ }
542
563
  async abortRequestRequest(sessionId) {
543
564
  const response = await this.fetch(`/sessions/${sessionId}/abort`, {
544
565
  method: "POST"
@@ -1980,11 +2001,15 @@ function createProtocolSessionBackend(input) {
1980
2001
  return {
1981
2002
  send(input2) {
1982
2003
  if (closed) throw new Error("PROTOCOL_BACKEND_SESSION_CLOSED");
1983
- pybClient.session.prompt(sessionId, {
2004
+ const promptOperation = pybClient.command?.promptAsync ? pybClient.command.promptAsync(sessionId, {
2005
+ message: input2.message,
2006
+ attachments: input2.attachments
2007
+ }) : pybClient.session.prompt(sessionId, {
1984
2008
  message: input2.message,
1985
2009
  attachments: input2.attachments,
1986
- options: { stream: true }
1987
- }).catch((error) => {
2010
+ options: { stream: false }
2011
+ });
2012
+ promptOperation.catch((error) => {
1988
2013
  const runtimeErrorEvent = toRuntimeErrorEvent(error, sessionId);
1989
2014
  runtimeQueue.push(runtimeErrorEvent);
1990
2015
  legacyQueue.push({
@@ -2481,7 +2506,7 @@ function isRecord4(value) {
2481
2506
  }
2482
2507
 
2483
2508
  // src/version.ts
2484
- var SDK_VERSION = "1.5.57";
2509
+ var SDK_VERSION = "1.5.59";
2485
2510
  export {
2486
2511
  BackendKindSchema,
2487
2512
  ContentBlockSchema,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pybao-xc-sdk",
3
- "version": "1.5.57",
3
+ "version": "1.5.59",
4
4
  "description": "PYB-CLI Server SDK",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",