pybao-xc-sdk 1.5.56 → 1.5.58

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
@@ -2397,23 +2397,6 @@ interface CreateSessionResponse {
2397
2397
  outputStyle: string;
2398
2398
  };
2399
2399
  }
2400
- type WorkspaceButtonGateReason = 'supported' | 'health_unavailable' | 'create_echo_missing' | 'session_echo_missing' | 'list_echo_missing' | 'probe_failed';
2401
- interface WorkspaceButtonCopy {
2402
- label: '新会话工作区';
2403
- description: '工作区切换影响新会话运行目录';
2404
- sharedModelNotice: '模型池仍为全局共享,默认模型可按工作区覆盖';
2405
- disabledNotice: '当前 pyb 版本未完成工作区能力升级时,此功能保持禁用';
2406
- }
2407
- interface WorkspaceNewSessionButtonState {
2408
- enabled: boolean;
2409
- reason: WorkspaceButtonGateReason;
2410
- requestedCwd: string;
2411
- serverVersion?: string;
2412
- createEchoedCwd?: string;
2413
- sessionEchoedCwd?: string;
2414
- listEchoedCwd?: string;
2415
- copy: WorkspaceButtonCopy;
2416
- }
2417
2400
  interface PromptRequest {
2418
2401
  message: string;
2419
2402
  attachments?: Attachment[];
@@ -2432,13 +2415,11 @@ interface Attachment {
2432
2415
  }
2433
2416
  interface PromptResponse {
2434
2417
  requestId: string;
2435
- messages: Message[];
2436
- finishReason: 'end_turn' | 'tool_calls' | 'max_tokens' | 'aborted';
2437
- usage: {
2438
- inputTokens: number;
2439
- outputTokens: number;
2440
- totalTokens: number;
2441
- };
2418
+ sessionId: string;
2419
+ accepted: boolean;
2420
+ acceptedAt: number;
2421
+ transport: 'events';
2422
+ stream: 'events';
2442
2423
  }
2443
2424
  interface PermissionResponseRequest {
2444
2425
  decision: 'allow' | 'deny' | 'allowAll';
@@ -2502,11 +2483,13 @@ interface PybClientConfig {
2502
2483
  baseUrl?: string;
2503
2484
  timeout?: number;
2504
2485
  headers?: Record<string, string>;
2486
+ directory?: string;
2505
2487
  }
2506
2488
  declare class PybClient {
2507
2489
  private baseUrl;
2508
2490
  private timeout;
2509
2491
  private headers;
2492
+ readonly directory: string | undefined;
2510
2493
  readonly session: {
2511
2494
  create: (request?: CreateSessionRequest) => Promise<CreateSessionResponse>;
2512
2495
  list: (params?: {
@@ -2543,6 +2526,9 @@ declare class PybClient {
2543
2526
  items: unknown[];
2544
2527
  }>;
2545
2528
  };
2529
+ readonly command: {
2530
+ promptAsync: (sessionId: string, request: PromptRequest) => Promise<PromptResponse>;
2531
+ };
2546
2532
  readonly mcp: {
2547
2533
  list: () => Promise<unknown[]>;
2548
2534
  connect: (serverName: string) => Promise<unknown>;
@@ -2587,19 +2573,16 @@ declare class PybClient {
2587
2573
  readonly modelPool: {
2588
2574
  status: () => Promise<ModelPoolStatusResponse>;
2589
2575
  };
2590
- readonly workspace: {
2591
- getNewSessionButtonState: (cwd: string) => Promise<WorkspaceNewSessionButtonState>;
2592
- };
2593
2576
  constructor(config?: PybClientConfig);
2594
2577
  getHealth(): Promise<HealthResponse>;
2595
- private getWorkspaceButtonCopy;
2596
- private getWorkspaceNewSessionButtonStateRequest;
2578
+ withDirectory(directory: string): PybClient;
2597
2579
  private createSessionRequest;
2598
2580
  private listSessionsRequest;
2599
2581
  private getSessionRequest;
2600
2582
  private updateSessionRequest;
2601
2583
  private deleteSessionRequest;
2602
2584
  private sendPromptRequest;
2585
+ private sendPromptCommandRequest;
2603
2586
  private abortRequestRequest;
2604
2587
  private getMessagesRequest;
2605
2588
  respondToPermission(permissionId: string, request: PermissionResponseRequest): Promise<{
@@ -2630,6 +2613,7 @@ declare class PybClient {
2630
2613
  private isRecoverableResponseStatus;
2631
2614
  private fetch;
2632
2615
  }
2616
+ declare function createPybClient(config?: PybClientConfig): PybClient;
2633
2617
 
2634
2618
  interface SSEClientOptions {
2635
2619
  baseUrl?: string;
@@ -3356,6 +3340,11 @@ type ProtocolClientLike = {
3356
3340
  requestId?: string;
3357
3341
  }>;
3358
3342
  };
3343
+ command?: {
3344
+ promptAsync: (sessionId: string, request: Record<string, unknown>) => Promise<{
3345
+ requestId: string;
3346
+ }>;
3347
+ };
3359
3348
  };
3360
3349
  type ProtocolSseEventLike = {
3361
3350
  type: string;
@@ -3460,6 +3449,6 @@ declare function resolveDefaultBackendFromEnv(input?: {
3460
3449
  routeSource: SessionBackendRouteSource;
3461
3450
  };
3462
3451
 
3463
- declare const SDK_VERSION = "1.5.56";
3452
+ declare const SDK_VERSION = "1.5.58";
3464
3453
 
3465
- 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, type WorkspaceButtonCopy, type WorkspaceButtonGateReason, type WorkspaceNewSessionButtonState, buildDefaultDualTrackThresholds, buildV2ToolUseContextFromPromptRequest, canTransitionV2SessionStatus, createDefaultToolPermissionContextForSdk, createProtocolSessionBackend, 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 };
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
@@ -2397,23 +2397,6 @@ interface CreateSessionResponse {
2397
2397
  outputStyle: string;
2398
2398
  };
2399
2399
  }
2400
- type WorkspaceButtonGateReason = 'supported' | 'health_unavailable' | 'create_echo_missing' | 'session_echo_missing' | 'list_echo_missing' | 'probe_failed';
2401
- interface WorkspaceButtonCopy {
2402
- label: '新会话工作区';
2403
- description: '工作区切换影响新会话运行目录';
2404
- sharedModelNotice: '模型池仍为全局共享,默认模型可按工作区覆盖';
2405
- disabledNotice: '当前 pyb 版本未完成工作区能力升级时,此功能保持禁用';
2406
- }
2407
- interface WorkspaceNewSessionButtonState {
2408
- enabled: boolean;
2409
- reason: WorkspaceButtonGateReason;
2410
- requestedCwd: string;
2411
- serverVersion?: string;
2412
- createEchoedCwd?: string;
2413
- sessionEchoedCwd?: string;
2414
- listEchoedCwd?: string;
2415
- copy: WorkspaceButtonCopy;
2416
- }
2417
2400
  interface PromptRequest {
2418
2401
  message: string;
2419
2402
  attachments?: Attachment[];
@@ -2432,13 +2415,11 @@ interface Attachment {
2432
2415
  }
2433
2416
  interface PromptResponse {
2434
2417
  requestId: string;
2435
- messages: Message[];
2436
- finishReason: 'end_turn' | 'tool_calls' | 'max_tokens' | 'aborted';
2437
- usage: {
2438
- inputTokens: number;
2439
- outputTokens: number;
2440
- totalTokens: number;
2441
- };
2418
+ sessionId: string;
2419
+ accepted: boolean;
2420
+ acceptedAt: number;
2421
+ transport: 'events';
2422
+ stream: 'events';
2442
2423
  }
2443
2424
  interface PermissionResponseRequest {
2444
2425
  decision: 'allow' | 'deny' | 'allowAll';
@@ -2502,11 +2483,13 @@ interface PybClientConfig {
2502
2483
  baseUrl?: string;
2503
2484
  timeout?: number;
2504
2485
  headers?: Record<string, string>;
2486
+ directory?: string;
2505
2487
  }
2506
2488
  declare class PybClient {
2507
2489
  private baseUrl;
2508
2490
  private timeout;
2509
2491
  private headers;
2492
+ readonly directory: string | undefined;
2510
2493
  readonly session: {
2511
2494
  create: (request?: CreateSessionRequest) => Promise<CreateSessionResponse>;
2512
2495
  list: (params?: {
@@ -2543,6 +2526,9 @@ declare class PybClient {
2543
2526
  items: unknown[];
2544
2527
  }>;
2545
2528
  };
2529
+ readonly command: {
2530
+ promptAsync: (sessionId: string, request: PromptRequest) => Promise<PromptResponse>;
2531
+ };
2546
2532
  readonly mcp: {
2547
2533
  list: () => Promise<unknown[]>;
2548
2534
  connect: (serverName: string) => Promise<unknown>;
@@ -2587,19 +2573,16 @@ declare class PybClient {
2587
2573
  readonly modelPool: {
2588
2574
  status: () => Promise<ModelPoolStatusResponse>;
2589
2575
  };
2590
- readonly workspace: {
2591
- getNewSessionButtonState: (cwd: string) => Promise<WorkspaceNewSessionButtonState>;
2592
- };
2593
2576
  constructor(config?: PybClientConfig);
2594
2577
  getHealth(): Promise<HealthResponse>;
2595
- private getWorkspaceButtonCopy;
2596
- private getWorkspaceNewSessionButtonStateRequest;
2578
+ withDirectory(directory: string): PybClient;
2597
2579
  private createSessionRequest;
2598
2580
  private listSessionsRequest;
2599
2581
  private getSessionRequest;
2600
2582
  private updateSessionRequest;
2601
2583
  private deleteSessionRequest;
2602
2584
  private sendPromptRequest;
2585
+ private sendPromptCommandRequest;
2603
2586
  private abortRequestRequest;
2604
2587
  private getMessagesRequest;
2605
2588
  respondToPermission(permissionId: string, request: PermissionResponseRequest): Promise<{
@@ -2630,6 +2613,7 @@ declare class PybClient {
2630
2613
  private isRecoverableResponseStatus;
2631
2614
  private fetch;
2632
2615
  }
2616
+ declare function createPybClient(config?: PybClientConfig): PybClient;
2633
2617
 
2634
2618
  interface SSEClientOptions {
2635
2619
  baseUrl?: string;
@@ -3356,6 +3340,11 @@ type ProtocolClientLike = {
3356
3340
  requestId?: string;
3357
3341
  }>;
3358
3342
  };
3343
+ command?: {
3344
+ promptAsync: (sessionId: string, request: Record<string, unknown>) => Promise<{
3345
+ requestId: string;
3346
+ }>;
3347
+ };
3359
3348
  };
3360
3349
  type ProtocolSseEventLike = {
3361
3350
  type: string;
@@ -3460,6 +3449,6 @@ declare function resolveDefaultBackendFromEnv(input?: {
3460
3449
  routeSource: SessionBackendRouteSource;
3461
3450
  };
3462
3451
 
3463
- declare const SDK_VERSION = "1.5.56";
3452
+ declare const SDK_VERSION = "1.5.58";
3464
3453
 
3465
- 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, type WorkspaceButtonCopy, type WorkspaceButtonGateReason, type WorkspaceNewSessionButtonState, buildDefaultDualTrackThresholds, buildV2ToolUseContextFromPromptRequest, canTransitionV2SessionStatus, createDefaultToolPermissionContextForSdk, createProtocolSessionBackend, 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 };
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
@@ -86,6 +86,7 @@ __export(index_exports, {
86
86
  canTransitionV2SessionStatus: () => canTransitionV2SessionStatus,
87
87
  createDefaultToolPermissionContextForSdk: () => createDefaultToolPermissionContextForSdk,
88
88
  createProtocolSessionBackend: () => createProtocolSessionBackend,
89
+ createPybClient: () => createPybClient,
89
90
  createRuntimePermissionContextForSession: () => createRuntimePermissionContextForSession,
90
91
  createRuntimeSession: () => createRuntimeSession,
91
92
  createRuntimeSessionBackend: () => createRuntimeSessionBackend,
@@ -441,7 +442,8 @@ var PYB_CLIENT_DEFAULT_TIMEOUT = 12e4;
441
442
  var pybClientConfigSchema = import_zod2.z.object({
442
443
  baseUrl: import_zod2.z.string().url().optional(),
443
444
  timeout: import_zod2.z.number().finite().positive().optional(),
444
- headers: import_zod2.z.record(import_zod2.z.string()).optional()
445
+ headers: import_zod2.z.record(import_zod2.z.string()).optional(),
446
+ directory: import_zod2.z.string().min(1).optional()
445
447
  });
446
448
  function normalizePybClientConfig(input) {
447
449
  const parsed = pybClientConfigSchema.safeParse(input);
@@ -463,7 +465,8 @@ function normalizePybClientConfig(input) {
463
465
  headers: {
464
466
  "Content-Type": "application/json",
465
467
  ...parsed.data.headers ?? {}
466
- }
468
+ },
469
+ directory: parsed.data.directory
467
470
  }
468
471
  };
469
472
  }
@@ -521,11 +524,13 @@ var PybResponseParseError = class extends PybAPIError {
521
524
  };
522
525
 
523
526
  // src/client.ts
524
- var PybClient = class {
527
+ var PybClient = class _PybClient {
525
528
  baseUrl;
526
529
  timeout;
527
530
  headers;
531
+ directory;
528
532
  session;
533
+ command;
529
534
  mcp;
530
535
  tool;
531
536
  config;
@@ -534,7 +539,6 @@ var PybClient = class {
534
539
  runtime;
535
540
  auth;
536
541
  modelPool;
537
- workspace;
538
542
  constructor(config = {}) {
539
543
  const normalizedConfig = normalizePybClientConfig(config);
540
544
  if (normalizedConfig.success === false) {
@@ -545,6 +549,7 @@ var PybClient = class {
545
549
  this.baseUrl = normalizedConfig.data.baseUrl;
546
550
  this.timeout = normalizedConfig.data.timeout;
547
551
  this.headers = normalizedConfig.data.headers;
552
+ this.directory = normalizedConfig.data.directory;
548
553
  this.session = {
549
554
  create: (request = {}) => this.createSessionRequest(request),
550
555
  list: (params) => this.listSessionsRequest(params),
@@ -555,6 +560,9 @@ var PybClient = class {
555
560
  abort: (sessionId) => this.abortRequestRequest(sessionId),
556
561
  messages: (sessionId, params) => this.getMessagesRequest(sessionId, params)
557
562
  };
563
+ this.command = {
564
+ promptAsync: (sessionId, request) => this.sendPromptCommandRequest(sessionId, request)
565
+ };
558
566
  this.mcp = {
559
567
  list: () => this.listMCPServersRequest(),
560
568
  connect: (serverName) => this.connectMCPServerRequest(serverName),
@@ -591,9 +599,6 @@ var PybClient = class {
591
599
  this.modelPool = {
592
600
  status: () => this.getModelPoolStatusRequest()
593
601
  };
594
- this.workspace = {
595
- getNewSessionButtonState: (cwd) => this.getWorkspaceNewSessionButtonStateRequest(cwd)
596
- };
597
602
  }
598
603
  // ============================================================
599
604
  // Health API
@@ -602,107 +607,22 @@ var PybClient = class {
602
607
  const response = await this.fetch("/health");
603
608
  return this.parseJson(response, "/health");
604
609
  }
605
- getWorkspaceButtonCopy() {
606
- return {
607
- label: "\u65B0\u4F1A\u8BDD\u5DE5\u4F5C\u533A",
608
- description: "\u5DE5\u4F5C\u533A\u5207\u6362\u5F71\u54CD\u65B0\u4F1A\u8BDD\u8FD0\u884C\u76EE\u5F55",
609
- sharedModelNotice: "\u6A21\u578B\u6C60\u4ECD\u4E3A\u5168\u5C40\u5171\u4EAB\uFF0C\u9ED8\u8BA4\u6A21\u578B\u53EF\u6309\u5DE5\u4F5C\u533A\u8986\u76D6",
610
- disabledNotice: "\u5F53\u524D pyb \u7248\u672C\u672A\u5B8C\u6210\u5DE5\u4F5C\u533A\u80FD\u529B\u5347\u7EA7\u65F6\uFF0C\u6B64\u529F\u80FD\u4FDD\u6301\u7981\u7528"
611
- };
612
- }
613
- async getWorkspaceNewSessionButtonStateRequest(cwd) {
614
- const copy = this.getWorkspaceButtonCopy();
615
- let serverVersion;
616
- try {
617
- const health = await this.getHealth();
618
- serverVersion = health.version;
619
- } catch {
620
- return {
621
- enabled: false,
622
- reason: "health_unavailable",
623
- requestedCwd: cwd,
624
- copy
625
- };
626
- }
627
- let sessionId;
628
- let createEchoedCwd;
629
- let sessionEchoedCwd;
630
- let listEchoedCwd;
631
- try {
632
- const created = await this.createSessionRequest({ cwd });
633
- sessionId = created.sessionId;
634
- createEchoedCwd = created.cwd;
635
- if (createEchoedCwd !== cwd) {
636
- return {
637
- enabled: false,
638
- reason: "create_echo_missing",
639
- requestedCwd: cwd,
640
- serverVersion,
641
- createEchoedCwd,
642
- copy
643
- };
644
- }
645
- const session = await this.getSessionRequest(sessionId);
646
- sessionEchoedCwd = session.cwd;
647
- if (sessionEchoedCwd !== cwd) {
648
- return {
649
- enabled: false,
650
- reason: "session_echo_missing",
651
- requestedCwd: cwd,
652
- serverVersion,
653
- createEchoedCwd,
654
- sessionEchoedCwd,
655
- copy
656
- };
657
- }
658
- const listedSessions = await this.listSessionsRequest({ limit: 100 });
659
- listEchoedCwd = listedSessions.items.find((item) => item.id === sessionId)?.cwd;
660
- if (listEchoedCwd !== cwd) {
661
- return {
662
- enabled: false,
663
- reason: "list_echo_missing",
664
- requestedCwd: cwd,
665
- serverVersion,
666
- createEchoedCwd,
667
- sessionEchoedCwd,
668
- listEchoedCwd,
669
- copy
670
- };
671
- }
672
- return {
673
- enabled: true,
674
- reason: "supported",
675
- requestedCwd: cwd,
676
- serverVersion,
677
- createEchoedCwd,
678
- sessionEchoedCwd,
679
- listEchoedCwd,
680
- copy
681
- };
682
- } catch {
683
- return {
684
- enabled: false,
685
- reason: "probe_failed",
686
- requestedCwd: cwd,
687
- serverVersion,
688
- createEchoedCwd,
689
- sessionEchoedCwd,
690
- listEchoedCwd,
691
- copy
692
- };
693
- } finally {
694
- if (sessionId) {
695
- await this.deleteSessionRequest(sessionId).catch(() => void 0);
696
- }
697
- }
610
+ withDirectory(directory) {
611
+ return new _PybClient({
612
+ baseUrl: this.baseUrl,
613
+ timeout: this.timeout,
614
+ headers: this.headers,
615
+ directory
616
+ });
698
617
  }
699
618
  // ============================================================
700
619
  // Session API
701
620
  // ============================================================
702
621
  async createSessionRequest(request = {}) {
622
+ const payload = request.cwd === void 0 && this.directory !== void 0 ? { ...request, cwd: this.directory } : request;
703
623
  const response = await this.fetch("/sessions", {
704
624
  method: "POST",
705
- body: JSON.stringify(request)
625
+ body: JSON.stringify(payload)
706
626
  });
707
627
  return this.parseData(response, "/sessions");
708
628
  }
@@ -736,12 +656,29 @@ var PybClient = class {
736
656
  // Message API
737
657
  // ============================================================
738
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
+ }
739
666
  const response = await this.fetch(`/sessions/${sessionId}/prompt`, {
740
667
  method: "POST",
741
668
  body: JSON.stringify({ ...request, options: { stream: false, ...request.options } })
742
669
  });
743
670
  return this.parseData(response, `/sessions/${sessionId}/prompt`);
744
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
+ }
745
682
  async abortRequestRequest(sessionId) {
746
683
  const response = await this.fetch(`/sessions/${sessionId}/abort`, {
747
684
  method: "POST"
@@ -1002,6 +939,9 @@ var PybClient = class {
1002
939
  }
1003
940
  }
1004
941
  };
942
+ function createPybClient(config = {}) {
943
+ return new PybClient(config);
944
+ }
1005
945
 
1006
946
  // src/sse.ts
1007
947
  var DEFAULT_CONNECT_TIMEOUT_MS = 1e4;
@@ -2180,11 +2120,15 @@ function createProtocolSessionBackend(input) {
2180
2120
  return {
2181
2121
  send(input2) {
2182
2122
  if (closed) throw new Error("PROTOCOL_BACKEND_SESSION_CLOSED");
2183
- 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, {
2184
2127
  message: input2.message,
2185
2128
  attachments: input2.attachments,
2186
- options: { stream: true }
2187
- }).catch((error) => {
2129
+ options: { stream: false }
2130
+ });
2131
+ promptOperation.catch((error) => {
2188
2132
  const runtimeErrorEvent = toRuntimeErrorEvent(error, sessionId);
2189
2133
  runtimeQueue.push(runtimeErrorEvent);
2190
2134
  legacyQueue.push({
@@ -2681,7 +2625,7 @@ function isRecord4(value) {
2681
2625
  }
2682
2626
 
2683
2627
  // src/version.ts
2684
- var SDK_VERSION = "1.5.56";
2628
+ var SDK_VERSION = "1.5.58";
2685
2629
  // Annotate the CommonJS export names for ESM import in node:
2686
2630
  0 && (module.exports = {
2687
2631
  BackendKindSchema,
@@ -2750,6 +2694,7 @@ var SDK_VERSION = "1.5.56";
2750
2694
  canTransitionV2SessionStatus,
2751
2695
  createDefaultToolPermissionContextForSdk,
2752
2696
  createProtocolSessionBackend,
2697
+ createPybClient,
2753
2698
  createRuntimePermissionContextForSession,
2754
2699
  createRuntimeSession,
2755
2700
  createRuntimeSessionBackend,
package/dist/index.mjs CHANGED
@@ -323,7 +323,8 @@ var PYB_CLIENT_DEFAULT_TIMEOUT = 12e4;
323
323
  var pybClientConfigSchema = z2.object({
324
324
  baseUrl: z2.string().url().optional(),
325
325
  timeout: z2.number().finite().positive().optional(),
326
- headers: z2.record(z2.string()).optional()
326
+ headers: z2.record(z2.string()).optional(),
327
+ directory: z2.string().min(1).optional()
327
328
  });
328
329
  function normalizePybClientConfig(input) {
329
330
  const parsed = pybClientConfigSchema.safeParse(input);
@@ -345,7 +346,8 @@ function normalizePybClientConfig(input) {
345
346
  headers: {
346
347
  "Content-Type": "application/json",
347
348
  ...parsed.data.headers ?? {}
348
- }
349
+ },
350
+ directory: parsed.data.directory
349
351
  }
350
352
  };
351
353
  }
@@ -403,11 +405,13 @@ var PybResponseParseError = class extends PybAPIError {
403
405
  };
404
406
 
405
407
  // src/client.ts
406
- var PybClient = class {
408
+ var PybClient = class _PybClient {
407
409
  baseUrl;
408
410
  timeout;
409
411
  headers;
412
+ directory;
410
413
  session;
414
+ command;
411
415
  mcp;
412
416
  tool;
413
417
  config;
@@ -416,7 +420,6 @@ var PybClient = class {
416
420
  runtime;
417
421
  auth;
418
422
  modelPool;
419
- workspace;
420
423
  constructor(config = {}) {
421
424
  const normalizedConfig = normalizePybClientConfig(config);
422
425
  if (normalizedConfig.success === false) {
@@ -427,6 +430,7 @@ var PybClient = class {
427
430
  this.baseUrl = normalizedConfig.data.baseUrl;
428
431
  this.timeout = normalizedConfig.data.timeout;
429
432
  this.headers = normalizedConfig.data.headers;
433
+ this.directory = normalizedConfig.data.directory;
430
434
  this.session = {
431
435
  create: (request = {}) => this.createSessionRequest(request),
432
436
  list: (params) => this.listSessionsRequest(params),
@@ -437,6 +441,9 @@ var PybClient = class {
437
441
  abort: (sessionId) => this.abortRequestRequest(sessionId),
438
442
  messages: (sessionId, params) => this.getMessagesRequest(sessionId, params)
439
443
  };
444
+ this.command = {
445
+ promptAsync: (sessionId, request) => this.sendPromptCommandRequest(sessionId, request)
446
+ };
440
447
  this.mcp = {
441
448
  list: () => this.listMCPServersRequest(),
442
449
  connect: (serverName) => this.connectMCPServerRequest(serverName),
@@ -473,9 +480,6 @@ var PybClient = class {
473
480
  this.modelPool = {
474
481
  status: () => this.getModelPoolStatusRequest()
475
482
  };
476
- this.workspace = {
477
- getNewSessionButtonState: (cwd) => this.getWorkspaceNewSessionButtonStateRequest(cwd)
478
- };
479
483
  }
480
484
  // ============================================================
481
485
  // Health API
@@ -484,107 +488,22 @@ var PybClient = class {
484
488
  const response = await this.fetch("/health");
485
489
  return this.parseJson(response, "/health");
486
490
  }
487
- getWorkspaceButtonCopy() {
488
- return {
489
- label: "\u65B0\u4F1A\u8BDD\u5DE5\u4F5C\u533A",
490
- description: "\u5DE5\u4F5C\u533A\u5207\u6362\u5F71\u54CD\u65B0\u4F1A\u8BDD\u8FD0\u884C\u76EE\u5F55",
491
- sharedModelNotice: "\u6A21\u578B\u6C60\u4ECD\u4E3A\u5168\u5C40\u5171\u4EAB\uFF0C\u9ED8\u8BA4\u6A21\u578B\u53EF\u6309\u5DE5\u4F5C\u533A\u8986\u76D6",
492
- disabledNotice: "\u5F53\u524D pyb \u7248\u672C\u672A\u5B8C\u6210\u5DE5\u4F5C\u533A\u80FD\u529B\u5347\u7EA7\u65F6\uFF0C\u6B64\u529F\u80FD\u4FDD\u6301\u7981\u7528"
493
- };
494
- }
495
- async getWorkspaceNewSessionButtonStateRequest(cwd) {
496
- const copy = this.getWorkspaceButtonCopy();
497
- let serverVersion;
498
- try {
499
- const health = await this.getHealth();
500
- serverVersion = health.version;
501
- } catch {
502
- return {
503
- enabled: false,
504
- reason: "health_unavailable",
505
- requestedCwd: cwd,
506
- copy
507
- };
508
- }
509
- let sessionId;
510
- let createEchoedCwd;
511
- let sessionEchoedCwd;
512
- let listEchoedCwd;
513
- try {
514
- const created = await this.createSessionRequest({ cwd });
515
- sessionId = created.sessionId;
516
- createEchoedCwd = created.cwd;
517
- if (createEchoedCwd !== cwd) {
518
- return {
519
- enabled: false,
520
- reason: "create_echo_missing",
521
- requestedCwd: cwd,
522
- serverVersion,
523
- createEchoedCwd,
524
- copy
525
- };
526
- }
527
- const session = await this.getSessionRequest(sessionId);
528
- sessionEchoedCwd = session.cwd;
529
- if (sessionEchoedCwd !== cwd) {
530
- return {
531
- enabled: false,
532
- reason: "session_echo_missing",
533
- requestedCwd: cwd,
534
- serverVersion,
535
- createEchoedCwd,
536
- sessionEchoedCwd,
537
- copy
538
- };
539
- }
540
- const listedSessions = await this.listSessionsRequest({ limit: 100 });
541
- listEchoedCwd = listedSessions.items.find((item) => item.id === sessionId)?.cwd;
542
- if (listEchoedCwd !== cwd) {
543
- return {
544
- enabled: false,
545
- reason: "list_echo_missing",
546
- requestedCwd: cwd,
547
- serverVersion,
548
- createEchoedCwd,
549
- sessionEchoedCwd,
550
- listEchoedCwd,
551
- copy
552
- };
553
- }
554
- return {
555
- enabled: true,
556
- reason: "supported",
557
- requestedCwd: cwd,
558
- serverVersion,
559
- createEchoedCwd,
560
- sessionEchoedCwd,
561
- listEchoedCwd,
562
- copy
563
- };
564
- } catch {
565
- return {
566
- enabled: false,
567
- reason: "probe_failed",
568
- requestedCwd: cwd,
569
- serverVersion,
570
- createEchoedCwd,
571
- sessionEchoedCwd,
572
- listEchoedCwd,
573
- copy
574
- };
575
- } finally {
576
- if (sessionId) {
577
- await this.deleteSessionRequest(sessionId).catch(() => void 0);
578
- }
579
- }
491
+ withDirectory(directory) {
492
+ return new _PybClient({
493
+ baseUrl: this.baseUrl,
494
+ timeout: this.timeout,
495
+ headers: this.headers,
496
+ directory
497
+ });
580
498
  }
581
499
  // ============================================================
582
500
  // Session API
583
501
  // ============================================================
584
502
  async createSessionRequest(request = {}) {
503
+ const payload = request.cwd === void 0 && this.directory !== void 0 ? { ...request, cwd: this.directory } : request;
585
504
  const response = await this.fetch("/sessions", {
586
505
  method: "POST",
587
- body: JSON.stringify(request)
506
+ body: JSON.stringify(payload)
588
507
  });
589
508
  return this.parseData(response, "/sessions");
590
509
  }
@@ -618,12 +537,29 @@ var PybClient = class {
618
537
  // Message API
619
538
  // ============================================================
620
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
+ }
621
547
  const response = await this.fetch(`/sessions/${sessionId}/prompt`, {
622
548
  method: "POST",
623
549
  body: JSON.stringify({ ...request, options: { stream: false, ...request.options } })
624
550
  });
625
551
  return this.parseData(response, `/sessions/${sessionId}/prompt`);
626
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
+ }
627
563
  async abortRequestRequest(sessionId) {
628
564
  const response = await this.fetch(`/sessions/${sessionId}/abort`, {
629
565
  method: "POST"
@@ -884,6 +820,9 @@ var PybClient = class {
884
820
  }
885
821
  }
886
822
  };
823
+ function createPybClient(config = {}) {
824
+ return new PybClient(config);
825
+ }
887
826
 
888
827
  // src/sse.ts
889
828
  var DEFAULT_CONNECT_TIMEOUT_MS = 1e4;
@@ -2062,11 +2001,15 @@ function createProtocolSessionBackend(input) {
2062
2001
  return {
2063
2002
  send(input2) {
2064
2003
  if (closed) throw new Error("PROTOCOL_BACKEND_SESSION_CLOSED");
2065
- 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, {
2066
2008
  message: input2.message,
2067
2009
  attachments: input2.attachments,
2068
- options: { stream: true }
2069
- }).catch((error) => {
2010
+ options: { stream: false }
2011
+ });
2012
+ promptOperation.catch((error) => {
2070
2013
  const runtimeErrorEvent = toRuntimeErrorEvent(error, sessionId);
2071
2014
  runtimeQueue.push(runtimeErrorEvent);
2072
2015
  legacyQueue.push({
@@ -2563,7 +2506,7 @@ function isRecord4(value) {
2563
2506
  }
2564
2507
 
2565
2508
  // src/version.ts
2566
- var SDK_VERSION = "1.5.56";
2509
+ var SDK_VERSION = "1.5.58";
2567
2510
  export {
2568
2511
  BackendKindSchema,
2569
2512
  ContentBlockSchema,
@@ -2631,6 +2574,7 @@ export {
2631
2574
  canTransitionV2SessionStatus,
2632
2575
  createDefaultToolPermissionContextForSdk,
2633
2576
  createProtocolSessionBackend,
2577
+ createPybClient,
2634
2578
  createRuntimePermissionContextForSession,
2635
2579
  createRuntimeSession,
2636
2580
  createRuntimeSessionBackend,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pybao-xc-sdk",
3
- "version": "1.5.56",
3
+ "version": "1.5.58",
4
4
  "description": "PYB-CLI Server SDK",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",