@hasura/promptql 2.0.0-alpha.21 → 2.0.0-alpha.23

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
@@ -316,6 +316,18 @@ type AgentLoopActionUpdate = {
316
316
  artifact_modified: {
317
317
  artifact_update: ArtifactUpdate;
318
318
  };
319
+ } | {
320
+ sql_execute_start: {
321
+ sql_query_id: SqlQueryId;
322
+ sql: Sql;
323
+ is_streaming: boolean;
324
+ };
325
+ } | {
326
+ sql_execute_complete: {
327
+ sql_query_id: SqlQueryId;
328
+ outcome: SqlExecuteOutcome;
329
+ pushdown_mode: string;
330
+ };
319
331
  };
320
332
  type ArtifactType = "text" | "table" | "visualization" | "html" | "file";
321
333
  type ArtifactPreview = {
@@ -326,6 +338,33 @@ type ArtifactPreview = {
326
338
  }[];
327
339
  };
328
340
  };
341
+ type SqlQueryId = string;
342
+ /**
343
+ * A SQL query string.
344
+ */
345
+ type Sql = string;
346
+ type SqlExecuteOutcome = {
347
+ rows_returned: number;
348
+ duration_ms: number;
349
+ type: "success";
350
+ } | {
351
+ duration_ms: number;
352
+ type: "timeout";
353
+ } | {
354
+ errored_after_ms: number;
355
+ error: SqlErrorType;
356
+ type: "error";
357
+ };
358
+ /**
359
+ * Whether a SQL error was caused by the user (bad SQL) or by internal infrastructure.
360
+ */
361
+ type SqlErrorType = {
362
+ message: string;
363
+ type: "user";
364
+ } | {
365
+ message: string;
366
+ type: "internal";
367
+ };
329
368
  /**
330
369
  * The final result of executing an action.
331
370
  */
@@ -1848,7 +1887,7 @@ type ProgramRunnerActionResult = "WriteFile" | {
1848
1887
  } | {
1849
1888
  RunSavedProgram: ProgramRunResult;
1850
1889
  };
1851
- type ProgramRunEvent = RunStarted | StepExecutionStarted | DataArtifactUpdated | OutputEmitted | CodeError | SqlError | BuildError | ArtifactError | InternalError | PipelineProgress | StepExecutionFinished | RunFinished;
1890
+ type ProgramRunEvent = RunStarted | StepExecutionStarted | DataArtifactUpdated | OutputEmitted | CodeError | SqlError | SqlExecuteStarted | SqlExecuteCompleted | BuildError | ArtifactError | InternalError | PipelineProgress | StepExecutionFinished | RunFinished;
1852
1891
  type RunStarted = {
1853
1892
  type: "RunStarted";
1854
1893
  } & RunStartedV1;
@@ -1873,6 +1912,24 @@ type CodeError = {
1873
1912
  type SqlError = {
1874
1913
  type: "SqlError";
1875
1914
  } & SqlErrorV1;
1915
+ type SqlExecuteStarted = {
1916
+ type: "SqlExecuteStarted";
1917
+ } & SqlExecuteStartedV1;
1918
+ type SqlExecuteCompleted = {
1919
+ type: "SqlExecuteCompleted";
1920
+ } & SqlExecuteCompletedV1;
1921
+ type SqlExecuteOutcome2 = {
1922
+ rows_returned: number;
1923
+ duration_ms: number;
1924
+ type: "Success";
1925
+ } | {
1926
+ duration_ms: number;
1927
+ type: "Timeout";
1928
+ } | {
1929
+ errored_after_ms: number;
1930
+ error_type: SqlErrorType;
1931
+ type: "Error";
1932
+ };
1876
1933
  type BuildError = {
1877
1934
  type: "BuildError";
1878
1935
  } & BuildErrorV1;
@@ -3371,6 +3428,20 @@ interface SqlErrorV1 {
3371
3428
  error: string;
3372
3429
  version: "V1";
3373
3430
  }
3431
+ interface SqlExecuteStartedV1 {
3432
+ step_index: number;
3433
+ sql_query_id: SqlQueryId;
3434
+ sql: Sql;
3435
+ is_streaming: boolean;
3436
+ version: "V1";
3437
+ }
3438
+ interface SqlExecuteCompletedV1 {
3439
+ step_index: number;
3440
+ sql_query_id: SqlQueryId;
3441
+ outcome: SqlExecuteOutcome2;
3442
+ pushdown_mode: string;
3443
+ version: "V1";
3444
+ }
3374
3445
  interface BuildErrorV1 {
3375
3446
  step_index: number;
3376
3447
  error: string;
@@ -3517,6 +3588,10 @@ type Scalars = {
3517
3588
  input: number;
3518
3589
  output: number;
3519
3590
  };
3591
+ timestamp: {
3592
+ input: string;
3593
+ output: string;
3594
+ };
3520
3595
  timestamptz: {
3521
3596
  input: string;
3522
3597
  output: string;
@@ -4002,6 +4077,8 @@ type Promptql_Users_Bool_Exp = {
4002
4077
  project_id?: InputMaybe<Uuid_Comparison_Exp>;
4003
4078
  promptql_user_id?: InputMaybe<Uuid_Comparison_Exp>;
4004
4079
  slack_info?: InputMaybe<Slack_Info_Bool_Exp>;
4080
+ starred_artifacts?: InputMaybe<Starred_Artifacts_Bool_Exp>;
4081
+ starred_threads?: InputMaybe<Starred_Threads_Bool_Exp>;
4005
4082
  updated_at?: InputMaybe<Timestamptz_Comparison_Exp>;
4006
4083
  user_group_members?: InputMaybe<User_Group_Members_Bool_Exp>;
4007
4084
  user_preference?: InputMaybe<User_Preferences_Bool_Exp>;
@@ -4020,6 +4097,8 @@ type Promptql_Users_Order_By = {
4020
4097
  project_id?: InputMaybe<Order_By>;
4021
4098
  promptql_user_id?: InputMaybe<Order_By>;
4022
4099
  slack_info?: InputMaybe<Slack_Info_Order_By>;
4100
+ starred_artifacts_aggregate?: InputMaybe<Starred_Artifacts_Aggregate_Order_By>;
4101
+ starred_threads_aggregate?: InputMaybe<Starred_Threads_Aggregate_Order_By>;
4023
4102
  updated_at?: InputMaybe<Order_By>;
4024
4103
  user_group_members_aggregate?: InputMaybe<User_Group_Members_Aggregate_Order_By>;
4025
4104
  user_preference?: InputMaybe<User_Preferences_Order_By>;
@@ -4343,6 +4422,64 @@ type Social_Feed_Candidates_Variance_Order_By = {
4343
4422
  thread_event_id?: InputMaybe<Order_By>;
4344
4423
  version?: InputMaybe<Order_By>;
4345
4424
  };
4425
+ /** order by aggregate values of table "starred_artifacts" */
4426
+ type Starred_Artifacts_Aggregate_Order_By = {
4427
+ count?: InputMaybe<Order_By>;
4428
+ max?: InputMaybe<Starred_Artifacts_Max_Order_By>;
4429
+ min?: InputMaybe<Starred_Artifacts_Min_Order_By>;
4430
+ };
4431
+ /** Boolean expression to filter rows from the table "starred_artifacts". All fields are combined with a logical 'AND'. */
4432
+ type Starred_Artifacts_Bool_Exp = {
4433
+ _and?: InputMaybe<Array<Starred_Artifacts_Bool_Exp>>;
4434
+ _not?: InputMaybe<Starred_Artifacts_Bool_Exp>;
4435
+ _or?: InputMaybe<Array<Starred_Artifacts_Bool_Exp>>;
4436
+ artifact?: InputMaybe<Artifacts_Bool_Exp>;
4437
+ artifact_id?: InputMaybe<Uuid_Comparison_Exp>;
4438
+ created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
4439
+ user?: InputMaybe<Promptql_Users_Bool_Exp>;
4440
+ user_id?: InputMaybe<Uuid_Comparison_Exp>;
4441
+ };
4442
+ /** order by max() on columns of table "starred_artifacts" */
4443
+ type Starred_Artifacts_Max_Order_By = {
4444
+ artifact_id?: InputMaybe<Order_By>;
4445
+ created_at?: InputMaybe<Order_By>;
4446
+ user_id?: InputMaybe<Order_By>;
4447
+ };
4448
+ /** order by min() on columns of table "starred_artifacts" */
4449
+ type Starred_Artifacts_Min_Order_By = {
4450
+ artifact_id?: InputMaybe<Order_By>;
4451
+ created_at?: InputMaybe<Order_By>;
4452
+ user_id?: InputMaybe<Order_By>;
4453
+ };
4454
+ /** order by aggregate values of table "starred_threads" */
4455
+ type Starred_Threads_Aggregate_Order_By = {
4456
+ count?: InputMaybe<Order_By>;
4457
+ max?: InputMaybe<Starred_Threads_Max_Order_By>;
4458
+ min?: InputMaybe<Starred_Threads_Min_Order_By>;
4459
+ };
4460
+ /** Boolean expression to filter rows from the table "starred_threads". All fields are combined with a logical 'AND'. */
4461
+ type Starred_Threads_Bool_Exp = {
4462
+ _and?: InputMaybe<Array<Starred_Threads_Bool_Exp>>;
4463
+ _not?: InputMaybe<Starred_Threads_Bool_Exp>;
4464
+ _or?: InputMaybe<Array<Starred_Threads_Bool_Exp>>;
4465
+ created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
4466
+ thread?: InputMaybe<Threads_V2_Bool_Exp>;
4467
+ thread_id?: InputMaybe<Uuid_Comparison_Exp>;
4468
+ user?: InputMaybe<Promptql_Users_Bool_Exp>;
4469
+ user_id?: InputMaybe<Uuid_Comparison_Exp>;
4470
+ };
4471
+ /** order by max() on columns of table "starred_threads" */
4472
+ type Starred_Threads_Max_Order_By = {
4473
+ created_at?: InputMaybe<Order_By>;
4474
+ thread_id?: InputMaybe<Order_By>;
4475
+ user_id?: InputMaybe<Order_By>;
4476
+ };
4477
+ /** order by min() on columns of table "starred_threads" */
4478
+ type Starred_Threads_Min_Order_By = {
4479
+ created_at?: InputMaybe<Order_By>;
4480
+ thread_id?: InputMaybe<Order_By>;
4481
+ user_id?: InputMaybe<Order_By>;
4482
+ };
4346
4483
  /** order by aggregate values of table "thread_artifacts" */
4347
4484
  type Thread_Artifacts_Aggregate_Order_By = {
4348
4485
  count?: InputMaybe<Order_By>;
@@ -4809,9 +4946,11 @@ type Threads_V2_Bool_Exp = {
4809
4946
  _or?: InputMaybe<Array<Threads_V2_Bool_Exp>>;
4810
4947
  build_id?: InputMaybe<Uuid_Comparison_Exp>;
4811
4948
  created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
4949
+ created_from?: InputMaybe<String_Comparison_Exp>;
4812
4950
  custom_title?: InputMaybe<String_Comparison_Exp>;
4813
4951
  deleted_at?: InputMaybe<Timestamptz_Comparison_Exp>;
4814
4952
  forked_from?: InputMaybe<Uuid_Comparison_Exp>;
4953
+ is_starred?: InputMaybe<Boolean_Comparison_Exp>;
4815
4954
  learning_suggestion?: InputMaybe<String_Comparison_Exp>;
4816
4955
  pinned_threads_v2s?: InputMaybe<Pinned_Threads_V2_Bool_Exp>;
4817
4956
  project_config?: InputMaybe<Project_Configuration_Bool_Exp>;
@@ -4841,6 +4980,7 @@ type Threads_V2_Bool_Exp = {
4841
4980
  type Threads_V2_Max_Order_By = {
4842
4981
  build_id?: InputMaybe<Order_By>;
4843
4982
  created_at?: InputMaybe<Order_By>;
4983
+ created_from?: InputMaybe<Order_By>;
4844
4984
  custom_title?: InputMaybe<Order_By>;
4845
4985
  deleted_at?: InputMaybe<Order_By>;
4846
4986
  forked_from?: InputMaybe<Order_By>;
@@ -4858,6 +4998,7 @@ type Threads_V2_Max_Order_By = {
4858
4998
  type Threads_V2_Min_Order_By = {
4859
4999
  build_id?: InputMaybe<Order_By>;
4860
5000
  created_at?: InputMaybe<Order_By>;
5001
+ created_from?: InputMaybe<Order_By>;
4861
5002
  custom_title?: InputMaybe<Order_By>;
4862
5003
  deleted_at?: InputMaybe<Order_By>;
4863
5004
  forked_from?: InputMaybe<Order_By>;
@@ -4875,9 +5016,11 @@ type Threads_V2_Min_Order_By = {
4875
5016
  type Threads_V2_Order_By = {
4876
5017
  build_id?: InputMaybe<Order_By>;
4877
5018
  created_at?: InputMaybe<Order_By>;
5019
+ created_from?: InputMaybe<Order_By>;
4878
5020
  custom_title?: InputMaybe<Order_By>;
4879
5021
  deleted_at?: InputMaybe<Order_By>;
4880
5022
  forked_from?: InputMaybe<Order_By>;
5023
+ is_starred?: InputMaybe<Order_By>;
4881
5024
  learning_suggestion?: InputMaybe<Order_By>;
4882
5025
  pinned_threads_v2s_aggregate?: InputMaybe<Pinned_Threads_V2_Aggregate_Order_By>;
4883
5026
  project_config?: InputMaybe<Project_Configuration_Order_By>;
@@ -4907,6 +5050,8 @@ type Threads_V2_Select_Column =
4907
5050
  'build_id'
4908
5051
  /** column name */
4909
5052
  | 'created_at'
5053
+ /** column name */
5054
+ | 'created_from'
4910
5055
  /** column name */
4911
5056
  | 'custom_title'
4912
5057
  /** column name */
@@ -5158,6 +5303,7 @@ type StartThreadMutationVariables = Exact<{
5158
5303
  roomId?: InputMaybe<Scalars['String']['input']>;
5159
5304
  uploads?: InputMaybe<Array<UserUploadInput> | UserUploadInput>;
5160
5305
  visibility?: InputMaybe<Scalars['String']['input']>;
5306
+ createdFrom?: InputMaybe<Scalars['String']['input']>;
5161
5307
  }>;
5162
5308
  type StartThreadMutation = {
5163
5309
  __typename?: 'mutation_root';
@@ -5733,4 +5879,4 @@ declare function getAgentInteractionFinishedEvent(eventData: ThreadEvent$1): Int
5733
5879
  */
5734
5880
  declare function getThreadEventMessageId(event: ThreadEvent$1 | undefined): string | undefined;
5735
5881
 
5736
- export { type AgentInteraction, type AgentLearningUpdate, type AgentLoopAction, type AgentLoopActionResult, type AgentLoopActionUpdate, type AgentLoopUpdate, type AgentState, type AgentTrigger, type AgentUpdate, type AgentUpdateContent, type AllTheServerTypes, type AnalyzedCodeAction, type AnalyzedCodeAction2, type ApolloClientOptions, type ArtifactError, type ArtifactErrorV1, type ArtifactId, type ArtifactPreview, type ArtifactReference, type ArtifactReference1, type ArtifactReference2, type ArtifactState, type ArtifactType, type ArtifactType2, type ArtifactUpdate, type ArtifactUpdate1, type AssumptionFactCheck, type BuildError, type BuildErrorV1, type BuiltUi, type BuiltUi1, type CancelAgentMessageMutationVariables, type CheckedAssumption, type CheckedTopic, type CodeAction, type CodeAction2, type CodeBlock, type CodeError, type CodeErrorV1, type CodeExecutionComplete, type CodeOutputAnalysis, type CodeOutputAnalysis1, type CodeOutputAnalyzed, type ComponentResponse, type ComponentResponse1, type ComponentResponse2, type ComponentResponse3, type ComponentResponse4, type ComponentResponse5, type ConfidenceAnalysis, type ConfidenceAnalysis1, type ConfidenceAnalysisLlmUsage, type ConfidenceAnalysisOutcome, type ConfidenceAnalysisUpdate, type ContextExplorerCompleted, type ContextExplorerStarted, type ContextExplorerState, type ContextExplorerUpdate, type CopyFileEntry, type CreateRoomArguments, type CurrentAction, type DataArtifactUpdated, type DataArtifactUpdatedV1, type Dependency, type EventOfKind, type ExternalKnowledgeExplorerAttempt, type ExternalKnowledgeExplorerAttempt1, type ExternalKnowledgeExplorerAttempt2, type ExternalKnowledgeExplorerState, type ExternalKnowledgeSummary, type ExternalKnowledgeTaskGeneratorState, type FactSource, type GeneratedCode, type GeneratedFile, type GeneratedFile2, type GeneratedProgramRunnerOutput, type GeneratedResponse, type GeneratedUiCode, type GeneratedUiCode1, type GetThreadEventOptions, type GetThreadsQueryVariables, type IPromptQLSdk, type Interaction, type InteractionDecision, type InteractionDecisionAccept, type InteractionDecisionDecline, type InteractionDecisionUpdate, type InteractionDeclineReason, type InteractionError, type InteractionFinishedEvent, type InteractionFinishedUpdate, type InteractionOutcome, type InteractionOutcome2, type InteractionOutcomeStatus, type InteractionUpdate, type InternalError, type InternalErrorV1, type InternalUpdate, type KeysOfUnion, type LearningSuggestion, type LearningSuggestionOutcome, type LearningSuggestionUpdate, type LearningSuggestionUpdateV1, type LlmResponse, type LlmUsage, type MessageProcessingStarted, type MessageProcessingState, type MessageProcessingUpdate, type NeedsSupportAnalysis, type NeedsSupportOutcome, type NeedsSupportUpdate, type OrchestratorState, type OrchestratorUpdate, type Order_By, type OutputEmitted, type OutputEmittedV1, type PipelineColumn, type PipelineColumnType, type PipelinePartitionSpec, type PipelinePartitionTransform, type PipelineProgress, type PipelineProgressV1, type PipelineRunStepDetails, type PipelineSchema, type PipelineSink, type PipelineSource, type PipelineStep, type PipelineTransform, type PlanGenerationStarted, type PlanState, type PlanStateStep, type PlanStepGenerated, type PlanningDecisionCompleted, type PlanningDecisionPlanningRequired, type PlanningDecisionStarted, type PlanningDecisionState, type PlanningDecisionUpdate, type ProgramId, type ProgramPackageName, type ProgramRunEvent, type ProgramRunResult, type ProgramRunnerAction, type ProgramRunnerAction2, type ProgramRunnerActionResult, type ProgramRunnerAttempt, type ProgramTransform, type ProgrammerState, type ProgrammerUpdate, PromptQLSdk, type PromptQLSdkOptions, type PromptQlConfigFeatureFlagModel, type PromptQlUserId, type PythonRunStepDetails, type PythonStep, ROOM_NAME_PATTERN, type ResponseGenerationState, type ResponseGenerationUpdate, type ResponseTruncation, type RoomFragment, type RoomVisibilityType, type RunConfigV1, type RunFinished, type RunFinishedOutcome, type RunFinishedV1, type RunProgramRequest, type RunProgramRequest2, type RunSavedProgramRequest, type RunSavedProgramRequest2, type RunStarted, type RunStartedV1, type RunStepDetails, type SavedProgramRunnerStage, type SavedProgramRunnerState, type SavedProgramRunnerUpdate, type SavedProgramRunnerUpdateV0, type ScheduledAgentTriggerEventId, type ScheduledAgentTriggerId, type ScheduledAgentTriggerPayload, type ScheduledAgentTriggerPayloadV1, type ScheduledAgentTriggerType, type SchemaContext, type SchemaContext1, type SchemaExplored, type SchemaExplorerCompleted, type SchemaExplorerStarted, type SchemaExplorerState, type SchemaExplorerUpdate, type SchemaTask, type SchemaTasksGenerationCompleted, type SchemaTasksGenerationStarted, type SchemaTasksGenerationState, type SchemaTasksGenerationUpdate, type SendMessageToThreadArguments, type SendMessageToThreadOutput, type SendThreadMessageMutationVariables, type ShelfActionEvent, type ShelfSink, type ShelfUpdate, type ShelfUpdateV1, type SkillType, type SocialFeedRating, type SocialFeedRatingLlmUsage, type SocialFeedRatingOutcome, type SocialFeedRatingUpdate, type Span, type SqlError, type SqlErrorV1, type SqlRunStepDetails, type SqlSource, type SqlStep, type StartThreadArguments, type StartThreadMutationVariables, type StartThreadOutput, type StartingOrchestrator, type Step, type StepExecutionFinished, type StepExecutionFinishedV1, type StepExecutionStarted, type StepExecutionStartedV1, type StepState, type StepUpdate, type StreamThreadEventOptions, type SummaryAction, type TasksGenerated, type Teaching, type TeachingId, type TeachingOutcome, type TeachingState, type ThreadEvent, type ThreadEvent$1 as ThreadEventData, type ThreadFragment, type ThreadParticipants, type TransactionId, type TzWrapper, type UiBuild, type UiBuild2, type UiBuildFailure, type UiBuildResult, type UiBuildRunStepDetails, type UiBuildStep, type UiMetadata, type UiProgrammerState, type UiProgrammerUpdate, type UserCancel, type UserCancelEvent, type UserInteraction, type UserMessage, type UserMessageEvent, type UserUpload, type UserUploadMetadata, type Version, type VersionedAgentUpdate, type VersionedOrUnversionedAgentUpdate, type Warning, type WikiAuditId, type WikiChange, type WikiContent, type WikiDelta, type WikiExplorerCompleted, type WikiExplorerStarted, type WikiExplorerState, type WikiExplorerUpdate, type WikiGenerationOutcome, type WikiGenerationUpdate, type WikiInfoGenerated, type WikiLearningSuggestionUpdate, type WikiPageV1, type WikiSection, type WikiSelectionUpdate, type WikiTitle, cancelAgentMessage, createApolloClient, createPromptQLAuthTokenGenerator, createRoom, diffThreadEvents, downloadArtifactData, getAgentGeneratedResponse, getAgentInteractionDecisionAcceptInteractionEvent, getAgentInteractionDecisionDeclineInteractionEvent, getAgentInteractionFinishedEvent, getAgentMessageProcessingStartedEvent, getAgentOrchestratorContextExplorerCompletedEvent, getAgentOrchestratorContextExplorerStartedEvent, getAgentOrchestratorContextExplorerUpdateEvent, getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent, getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent, getAgentOrchestratorSchemaExplorerCompletedEvent, getAgentOrchestratorSchemaExplorerGeneratedCodeEvent, getAgentOrchestratorSchemaExplorerSchemaExploredEvent, getAgentOrchestratorSchemaExplorerStartedEvent, getAgentOrchestratorSchemaExplorerUpdateEvent, getAgentOrchestratorSchemaTasksGeneratedEvent, getAgentOrchestratorSchemaTasksGenerationCompletedEvent, getAgentOrchestratorSchemaTasksGenerationStartedEvent, getAgentOrchestratorSchemaTasksGenerationUpdateEvent, getAgentOrchestratorStepProgrammerEvent, getAgentOrchestratorStepSavedProgramRunnerEvent, getAgentOrchestratorStepUiProgrammerEvent, getAgentOrchestratorStepUpdateEvent, getAgentOrchestratorUpdateEvent, getAgentOrchestratorWikiExplorerCompletedEvent, getAgentOrchestratorWikiExplorerStartedEvent, getAgentOrchestratorWikiExplorerUpdateEvent, getAgentOrchestratorWikiInfoGeneratedEvent, getAgentPlanGenerationStartedEvent, getAgentPlanStepGeneratedEvent, getAgentPlanningDecisionCompletedEvent, getAgentPlanningDecisionPlanningRequiredEvent, getAgentPlanningDecisionStartedEvent, getAgentPlanningDecisionUpdateEvent, getAgentStartingOrchestratorEvent, getThread, getThreadEventMessageId, getThreadEvents, getUserCancelEvent, getUserMessageEvent, isInteractionAnalyzing, listRooms, listThreads, sendThreadMessage, startThread, streamThreadMessageEvents, subscribeThreadEvents };
5882
+ export { type AgentInteraction, type AgentLearningUpdate, type AgentLoopAction, type AgentLoopActionResult, type AgentLoopActionUpdate, type AgentLoopUpdate, type AgentState, type AgentTrigger, type AgentUpdate, type AgentUpdateContent, type AllTheServerTypes, type AnalyzedCodeAction, type AnalyzedCodeAction2, type ApolloClientOptions, type ArtifactError, type ArtifactErrorV1, type ArtifactId, type ArtifactPreview, type ArtifactReference, type ArtifactReference1, type ArtifactReference2, type ArtifactState, type ArtifactType, type ArtifactType2, type ArtifactUpdate, type ArtifactUpdate1, type AssumptionFactCheck, type BuildError, type BuildErrorV1, type BuiltUi, type BuiltUi1, type CancelAgentMessageMutationVariables, type CheckedAssumption, type CheckedTopic, type CodeAction, type CodeAction2, type CodeBlock, type CodeError, type CodeErrorV1, type CodeExecutionComplete, type CodeOutputAnalysis, type CodeOutputAnalysis1, type CodeOutputAnalyzed, type ComponentResponse, type ComponentResponse1, type ComponentResponse2, type ComponentResponse3, type ComponentResponse4, type ComponentResponse5, type ConfidenceAnalysis, type ConfidenceAnalysis1, type ConfidenceAnalysisLlmUsage, type ConfidenceAnalysisOutcome, type ConfidenceAnalysisUpdate, type ContextExplorerCompleted, type ContextExplorerStarted, type ContextExplorerState, type ContextExplorerUpdate, type CopyFileEntry, type CreateRoomArguments, type CurrentAction, type DataArtifactUpdated, type DataArtifactUpdatedV1, type Dependency, type EventOfKind, type ExternalKnowledgeExplorerAttempt, type ExternalKnowledgeExplorerAttempt1, type ExternalKnowledgeExplorerAttempt2, type ExternalKnowledgeExplorerState, type ExternalKnowledgeSummary, type ExternalKnowledgeTaskGeneratorState, type FactSource, type GeneratedCode, type GeneratedFile, type GeneratedFile2, type GeneratedProgramRunnerOutput, type GeneratedResponse, type GeneratedUiCode, type GeneratedUiCode1, type GetThreadEventOptions, type GetThreadsQueryVariables, type IPromptQLSdk, type Interaction, type InteractionDecision, type InteractionDecisionAccept, type InteractionDecisionDecline, type InteractionDecisionUpdate, type InteractionDeclineReason, type InteractionError, type InteractionFinishedEvent, type InteractionFinishedUpdate, type InteractionOutcome, type InteractionOutcome2, type InteractionOutcomeStatus, type InteractionUpdate, type InternalError, type InternalErrorV1, type InternalUpdate, type KeysOfUnion, type LearningSuggestion, type LearningSuggestionOutcome, type LearningSuggestionUpdate, type LearningSuggestionUpdateV1, type LlmResponse, type LlmUsage, type MessageProcessingStarted, type MessageProcessingState, type MessageProcessingUpdate, type NeedsSupportAnalysis, type NeedsSupportOutcome, type NeedsSupportUpdate, type OrchestratorState, type OrchestratorUpdate, type Order_By, type OutputEmitted, type OutputEmittedV1, type PipelineColumn, type PipelineColumnType, type PipelinePartitionSpec, type PipelinePartitionTransform, type PipelineProgress, type PipelineProgressV1, type PipelineRunStepDetails, type PipelineSchema, type PipelineSink, type PipelineSource, type PipelineStep, type PipelineTransform, type PlanGenerationStarted, type PlanState, type PlanStateStep, type PlanStepGenerated, type PlanningDecisionCompleted, type PlanningDecisionPlanningRequired, type PlanningDecisionStarted, type PlanningDecisionState, type PlanningDecisionUpdate, type ProgramId, type ProgramPackageName, type ProgramRunEvent, type ProgramRunResult, type ProgramRunnerAction, type ProgramRunnerAction2, type ProgramRunnerActionResult, type ProgramRunnerAttempt, type ProgramTransform, type ProgrammerState, type ProgrammerUpdate, PromptQLSdk, type PromptQLSdkOptions, type PromptQlConfigFeatureFlagModel, type PromptQlUserId, type PythonRunStepDetails, type PythonStep, ROOM_NAME_PATTERN, type ResponseGenerationState, type ResponseGenerationUpdate, type ResponseTruncation, type RoomFragment, type RoomVisibilityType, type RunConfigV1, type RunFinished, type RunFinishedOutcome, type RunFinishedV1, type RunProgramRequest, type RunProgramRequest2, type RunSavedProgramRequest, type RunSavedProgramRequest2, type RunStarted, type RunStartedV1, type RunStepDetails, type SavedProgramRunnerStage, type SavedProgramRunnerState, type SavedProgramRunnerUpdate, type SavedProgramRunnerUpdateV0, type ScheduledAgentTriggerEventId, type ScheduledAgentTriggerId, type ScheduledAgentTriggerPayload, type ScheduledAgentTriggerPayloadV1, type ScheduledAgentTriggerType, type SchemaContext, type SchemaContext1, type SchemaExplored, type SchemaExplorerCompleted, type SchemaExplorerStarted, type SchemaExplorerState, type SchemaExplorerUpdate, type SchemaTask, type SchemaTasksGenerationCompleted, type SchemaTasksGenerationStarted, type SchemaTasksGenerationState, type SchemaTasksGenerationUpdate, type SendMessageToThreadArguments, type SendMessageToThreadOutput, type SendThreadMessageMutationVariables, type ShelfActionEvent, type ShelfSink, type ShelfUpdate, type ShelfUpdateV1, type SkillType, type SocialFeedRating, type SocialFeedRatingLlmUsage, type SocialFeedRatingOutcome, type SocialFeedRatingUpdate, type Span, type Sql, type SqlError, type SqlErrorType, type SqlErrorV1, type SqlExecuteCompleted, type SqlExecuteCompletedV1, type SqlExecuteOutcome, type SqlExecuteOutcome2, type SqlExecuteStarted, type SqlExecuteStartedV1, type SqlQueryId, type SqlRunStepDetails, type SqlSource, type SqlStep, type StartThreadArguments, type StartThreadMutationVariables, type StartThreadOutput, type StartingOrchestrator, type Step, type StepExecutionFinished, type StepExecutionFinishedV1, type StepExecutionStarted, type StepExecutionStartedV1, type StepState, type StepUpdate, type StreamThreadEventOptions, type SummaryAction, type TasksGenerated, type Teaching, type TeachingId, type TeachingOutcome, type TeachingState, type ThreadEvent, type ThreadEvent$1 as ThreadEventData, type ThreadFragment, type ThreadParticipants, type TransactionId, type TzWrapper, type UiBuild, type UiBuild2, type UiBuildFailure, type UiBuildResult, type UiBuildRunStepDetails, type UiBuildStep, type UiMetadata, type UiProgrammerState, type UiProgrammerUpdate, type UserCancel, type UserCancelEvent, type UserInteraction, type UserMessage, type UserMessageEvent, type UserUpload, type UserUploadMetadata, type Version, type VersionedAgentUpdate, type VersionedOrUnversionedAgentUpdate, type Warning, type WikiAuditId, type WikiChange, type WikiContent, type WikiDelta, type WikiExplorerCompleted, type WikiExplorerStarted, type WikiExplorerState, type WikiExplorerUpdate, type WikiGenerationOutcome, type WikiGenerationUpdate, type WikiInfoGenerated, type WikiLearningSuggestionUpdate, type WikiPageV1, type WikiSection, type WikiSelectionUpdate, type WikiTitle, cancelAgentMessage, createApolloClient, createPromptQLAuthTokenGenerator, createRoom, diffThreadEvents, downloadArtifactData, getAgentGeneratedResponse, getAgentInteractionDecisionAcceptInteractionEvent, getAgentInteractionDecisionDeclineInteractionEvent, getAgentInteractionFinishedEvent, getAgentMessageProcessingStartedEvent, getAgentOrchestratorContextExplorerCompletedEvent, getAgentOrchestratorContextExplorerStartedEvent, getAgentOrchestratorContextExplorerUpdateEvent, getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent, getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent, getAgentOrchestratorSchemaExplorerCompletedEvent, getAgentOrchestratorSchemaExplorerGeneratedCodeEvent, getAgentOrchestratorSchemaExplorerSchemaExploredEvent, getAgentOrchestratorSchemaExplorerStartedEvent, getAgentOrchestratorSchemaExplorerUpdateEvent, getAgentOrchestratorSchemaTasksGeneratedEvent, getAgentOrchestratorSchemaTasksGenerationCompletedEvent, getAgentOrchestratorSchemaTasksGenerationStartedEvent, getAgentOrchestratorSchemaTasksGenerationUpdateEvent, getAgentOrchestratorStepProgrammerEvent, getAgentOrchestratorStepSavedProgramRunnerEvent, getAgentOrchestratorStepUiProgrammerEvent, getAgentOrchestratorStepUpdateEvent, getAgentOrchestratorUpdateEvent, getAgentOrchestratorWikiExplorerCompletedEvent, getAgentOrchestratorWikiExplorerStartedEvent, getAgentOrchestratorWikiExplorerUpdateEvent, getAgentOrchestratorWikiInfoGeneratedEvent, getAgentPlanGenerationStartedEvent, getAgentPlanStepGeneratedEvent, getAgentPlanningDecisionCompletedEvent, getAgentPlanningDecisionPlanningRequiredEvent, getAgentPlanningDecisionStartedEvent, getAgentPlanningDecisionUpdateEvent, getAgentStartingOrchestratorEvent, getThread, getThreadEventMessageId, getThreadEvents, getUserCancelEvent, getUserMessageEvent, isInteractionAnalyzing, listRooms, listThreads, sendThreadMessage, startThread, streamThreadMessageEvents, subscribeThreadEvents };
package/dist/index.d.ts CHANGED
@@ -316,6 +316,18 @@ type AgentLoopActionUpdate = {
316
316
  artifact_modified: {
317
317
  artifact_update: ArtifactUpdate;
318
318
  };
319
+ } | {
320
+ sql_execute_start: {
321
+ sql_query_id: SqlQueryId;
322
+ sql: Sql;
323
+ is_streaming: boolean;
324
+ };
325
+ } | {
326
+ sql_execute_complete: {
327
+ sql_query_id: SqlQueryId;
328
+ outcome: SqlExecuteOutcome;
329
+ pushdown_mode: string;
330
+ };
319
331
  };
320
332
  type ArtifactType = "text" | "table" | "visualization" | "html" | "file";
321
333
  type ArtifactPreview = {
@@ -326,6 +338,33 @@ type ArtifactPreview = {
326
338
  }[];
327
339
  };
328
340
  };
341
+ type SqlQueryId = string;
342
+ /**
343
+ * A SQL query string.
344
+ */
345
+ type Sql = string;
346
+ type SqlExecuteOutcome = {
347
+ rows_returned: number;
348
+ duration_ms: number;
349
+ type: "success";
350
+ } | {
351
+ duration_ms: number;
352
+ type: "timeout";
353
+ } | {
354
+ errored_after_ms: number;
355
+ error: SqlErrorType;
356
+ type: "error";
357
+ };
358
+ /**
359
+ * Whether a SQL error was caused by the user (bad SQL) or by internal infrastructure.
360
+ */
361
+ type SqlErrorType = {
362
+ message: string;
363
+ type: "user";
364
+ } | {
365
+ message: string;
366
+ type: "internal";
367
+ };
329
368
  /**
330
369
  * The final result of executing an action.
331
370
  */
@@ -1848,7 +1887,7 @@ type ProgramRunnerActionResult = "WriteFile" | {
1848
1887
  } | {
1849
1888
  RunSavedProgram: ProgramRunResult;
1850
1889
  };
1851
- type ProgramRunEvent = RunStarted | StepExecutionStarted | DataArtifactUpdated | OutputEmitted | CodeError | SqlError | BuildError | ArtifactError | InternalError | PipelineProgress | StepExecutionFinished | RunFinished;
1890
+ type ProgramRunEvent = RunStarted | StepExecutionStarted | DataArtifactUpdated | OutputEmitted | CodeError | SqlError | SqlExecuteStarted | SqlExecuteCompleted | BuildError | ArtifactError | InternalError | PipelineProgress | StepExecutionFinished | RunFinished;
1852
1891
  type RunStarted = {
1853
1892
  type: "RunStarted";
1854
1893
  } & RunStartedV1;
@@ -1873,6 +1912,24 @@ type CodeError = {
1873
1912
  type SqlError = {
1874
1913
  type: "SqlError";
1875
1914
  } & SqlErrorV1;
1915
+ type SqlExecuteStarted = {
1916
+ type: "SqlExecuteStarted";
1917
+ } & SqlExecuteStartedV1;
1918
+ type SqlExecuteCompleted = {
1919
+ type: "SqlExecuteCompleted";
1920
+ } & SqlExecuteCompletedV1;
1921
+ type SqlExecuteOutcome2 = {
1922
+ rows_returned: number;
1923
+ duration_ms: number;
1924
+ type: "Success";
1925
+ } | {
1926
+ duration_ms: number;
1927
+ type: "Timeout";
1928
+ } | {
1929
+ errored_after_ms: number;
1930
+ error_type: SqlErrorType;
1931
+ type: "Error";
1932
+ };
1876
1933
  type BuildError = {
1877
1934
  type: "BuildError";
1878
1935
  } & BuildErrorV1;
@@ -3371,6 +3428,20 @@ interface SqlErrorV1 {
3371
3428
  error: string;
3372
3429
  version: "V1";
3373
3430
  }
3431
+ interface SqlExecuteStartedV1 {
3432
+ step_index: number;
3433
+ sql_query_id: SqlQueryId;
3434
+ sql: Sql;
3435
+ is_streaming: boolean;
3436
+ version: "V1";
3437
+ }
3438
+ interface SqlExecuteCompletedV1 {
3439
+ step_index: number;
3440
+ sql_query_id: SqlQueryId;
3441
+ outcome: SqlExecuteOutcome2;
3442
+ pushdown_mode: string;
3443
+ version: "V1";
3444
+ }
3374
3445
  interface BuildErrorV1 {
3375
3446
  step_index: number;
3376
3447
  error: string;
@@ -3517,6 +3588,10 @@ type Scalars = {
3517
3588
  input: number;
3518
3589
  output: number;
3519
3590
  };
3591
+ timestamp: {
3592
+ input: string;
3593
+ output: string;
3594
+ };
3520
3595
  timestamptz: {
3521
3596
  input: string;
3522
3597
  output: string;
@@ -4002,6 +4077,8 @@ type Promptql_Users_Bool_Exp = {
4002
4077
  project_id?: InputMaybe<Uuid_Comparison_Exp>;
4003
4078
  promptql_user_id?: InputMaybe<Uuid_Comparison_Exp>;
4004
4079
  slack_info?: InputMaybe<Slack_Info_Bool_Exp>;
4080
+ starred_artifacts?: InputMaybe<Starred_Artifacts_Bool_Exp>;
4081
+ starred_threads?: InputMaybe<Starred_Threads_Bool_Exp>;
4005
4082
  updated_at?: InputMaybe<Timestamptz_Comparison_Exp>;
4006
4083
  user_group_members?: InputMaybe<User_Group_Members_Bool_Exp>;
4007
4084
  user_preference?: InputMaybe<User_Preferences_Bool_Exp>;
@@ -4020,6 +4097,8 @@ type Promptql_Users_Order_By = {
4020
4097
  project_id?: InputMaybe<Order_By>;
4021
4098
  promptql_user_id?: InputMaybe<Order_By>;
4022
4099
  slack_info?: InputMaybe<Slack_Info_Order_By>;
4100
+ starred_artifacts_aggregate?: InputMaybe<Starred_Artifacts_Aggregate_Order_By>;
4101
+ starred_threads_aggregate?: InputMaybe<Starred_Threads_Aggregate_Order_By>;
4023
4102
  updated_at?: InputMaybe<Order_By>;
4024
4103
  user_group_members_aggregate?: InputMaybe<User_Group_Members_Aggregate_Order_By>;
4025
4104
  user_preference?: InputMaybe<User_Preferences_Order_By>;
@@ -4343,6 +4422,64 @@ type Social_Feed_Candidates_Variance_Order_By = {
4343
4422
  thread_event_id?: InputMaybe<Order_By>;
4344
4423
  version?: InputMaybe<Order_By>;
4345
4424
  };
4425
+ /** order by aggregate values of table "starred_artifacts" */
4426
+ type Starred_Artifacts_Aggregate_Order_By = {
4427
+ count?: InputMaybe<Order_By>;
4428
+ max?: InputMaybe<Starred_Artifacts_Max_Order_By>;
4429
+ min?: InputMaybe<Starred_Artifacts_Min_Order_By>;
4430
+ };
4431
+ /** Boolean expression to filter rows from the table "starred_artifacts". All fields are combined with a logical 'AND'. */
4432
+ type Starred_Artifacts_Bool_Exp = {
4433
+ _and?: InputMaybe<Array<Starred_Artifacts_Bool_Exp>>;
4434
+ _not?: InputMaybe<Starred_Artifacts_Bool_Exp>;
4435
+ _or?: InputMaybe<Array<Starred_Artifacts_Bool_Exp>>;
4436
+ artifact?: InputMaybe<Artifacts_Bool_Exp>;
4437
+ artifact_id?: InputMaybe<Uuid_Comparison_Exp>;
4438
+ created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
4439
+ user?: InputMaybe<Promptql_Users_Bool_Exp>;
4440
+ user_id?: InputMaybe<Uuid_Comparison_Exp>;
4441
+ };
4442
+ /** order by max() on columns of table "starred_artifacts" */
4443
+ type Starred_Artifacts_Max_Order_By = {
4444
+ artifact_id?: InputMaybe<Order_By>;
4445
+ created_at?: InputMaybe<Order_By>;
4446
+ user_id?: InputMaybe<Order_By>;
4447
+ };
4448
+ /** order by min() on columns of table "starred_artifacts" */
4449
+ type Starred_Artifacts_Min_Order_By = {
4450
+ artifact_id?: InputMaybe<Order_By>;
4451
+ created_at?: InputMaybe<Order_By>;
4452
+ user_id?: InputMaybe<Order_By>;
4453
+ };
4454
+ /** order by aggregate values of table "starred_threads" */
4455
+ type Starred_Threads_Aggregate_Order_By = {
4456
+ count?: InputMaybe<Order_By>;
4457
+ max?: InputMaybe<Starred_Threads_Max_Order_By>;
4458
+ min?: InputMaybe<Starred_Threads_Min_Order_By>;
4459
+ };
4460
+ /** Boolean expression to filter rows from the table "starred_threads". All fields are combined with a logical 'AND'. */
4461
+ type Starred_Threads_Bool_Exp = {
4462
+ _and?: InputMaybe<Array<Starred_Threads_Bool_Exp>>;
4463
+ _not?: InputMaybe<Starred_Threads_Bool_Exp>;
4464
+ _or?: InputMaybe<Array<Starred_Threads_Bool_Exp>>;
4465
+ created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
4466
+ thread?: InputMaybe<Threads_V2_Bool_Exp>;
4467
+ thread_id?: InputMaybe<Uuid_Comparison_Exp>;
4468
+ user?: InputMaybe<Promptql_Users_Bool_Exp>;
4469
+ user_id?: InputMaybe<Uuid_Comparison_Exp>;
4470
+ };
4471
+ /** order by max() on columns of table "starred_threads" */
4472
+ type Starred_Threads_Max_Order_By = {
4473
+ created_at?: InputMaybe<Order_By>;
4474
+ thread_id?: InputMaybe<Order_By>;
4475
+ user_id?: InputMaybe<Order_By>;
4476
+ };
4477
+ /** order by min() on columns of table "starred_threads" */
4478
+ type Starred_Threads_Min_Order_By = {
4479
+ created_at?: InputMaybe<Order_By>;
4480
+ thread_id?: InputMaybe<Order_By>;
4481
+ user_id?: InputMaybe<Order_By>;
4482
+ };
4346
4483
  /** order by aggregate values of table "thread_artifacts" */
4347
4484
  type Thread_Artifacts_Aggregate_Order_By = {
4348
4485
  count?: InputMaybe<Order_By>;
@@ -4809,9 +4946,11 @@ type Threads_V2_Bool_Exp = {
4809
4946
  _or?: InputMaybe<Array<Threads_V2_Bool_Exp>>;
4810
4947
  build_id?: InputMaybe<Uuid_Comparison_Exp>;
4811
4948
  created_at?: InputMaybe<Timestamptz_Comparison_Exp>;
4949
+ created_from?: InputMaybe<String_Comparison_Exp>;
4812
4950
  custom_title?: InputMaybe<String_Comparison_Exp>;
4813
4951
  deleted_at?: InputMaybe<Timestamptz_Comparison_Exp>;
4814
4952
  forked_from?: InputMaybe<Uuid_Comparison_Exp>;
4953
+ is_starred?: InputMaybe<Boolean_Comparison_Exp>;
4815
4954
  learning_suggestion?: InputMaybe<String_Comparison_Exp>;
4816
4955
  pinned_threads_v2s?: InputMaybe<Pinned_Threads_V2_Bool_Exp>;
4817
4956
  project_config?: InputMaybe<Project_Configuration_Bool_Exp>;
@@ -4841,6 +4980,7 @@ type Threads_V2_Bool_Exp = {
4841
4980
  type Threads_V2_Max_Order_By = {
4842
4981
  build_id?: InputMaybe<Order_By>;
4843
4982
  created_at?: InputMaybe<Order_By>;
4983
+ created_from?: InputMaybe<Order_By>;
4844
4984
  custom_title?: InputMaybe<Order_By>;
4845
4985
  deleted_at?: InputMaybe<Order_By>;
4846
4986
  forked_from?: InputMaybe<Order_By>;
@@ -4858,6 +4998,7 @@ type Threads_V2_Max_Order_By = {
4858
4998
  type Threads_V2_Min_Order_By = {
4859
4999
  build_id?: InputMaybe<Order_By>;
4860
5000
  created_at?: InputMaybe<Order_By>;
5001
+ created_from?: InputMaybe<Order_By>;
4861
5002
  custom_title?: InputMaybe<Order_By>;
4862
5003
  deleted_at?: InputMaybe<Order_By>;
4863
5004
  forked_from?: InputMaybe<Order_By>;
@@ -4875,9 +5016,11 @@ type Threads_V2_Min_Order_By = {
4875
5016
  type Threads_V2_Order_By = {
4876
5017
  build_id?: InputMaybe<Order_By>;
4877
5018
  created_at?: InputMaybe<Order_By>;
5019
+ created_from?: InputMaybe<Order_By>;
4878
5020
  custom_title?: InputMaybe<Order_By>;
4879
5021
  deleted_at?: InputMaybe<Order_By>;
4880
5022
  forked_from?: InputMaybe<Order_By>;
5023
+ is_starred?: InputMaybe<Order_By>;
4881
5024
  learning_suggestion?: InputMaybe<Order_By>;
4882
5025
  pinned_threads_v2s_aggregate?: InputMaybe<Pinned_Threads_V2_Aggregate_Order_By>;
4883
5026
  project_config?: InputMaybe<Project_Configuration_Order_By>;
@@ -4907,6 +5050,8 @@ type Threads_V2_Select_Column =
4907
5050
  'build_id'
4908
5051
  /** column name */
4909
5052
  | 'created_at'
5053
+ /** column name */
5054
+ | 'created_from'
4910
5055
  /** column name */
4911
5056
  | 'custom_title'
4912
5057
  /** column name */
@@ -5158,6 +5303,7 @@ type StartThreadMutationVariables = Exact<{
5158
5303
  roomId?: InputMaybe<Scalars['String']['input']>;
5159
5304
  uploads?: InputMaybe<Array<UserUploadInput> | UserUploadInput>;
5160
5305
  visibility?: InputMaybe<Scalars['String']['input']>;
5306
+ createdFrom?: InputMaybe<Scalars['String']['input']>;
5161
5307
  }>;
5162
5308
  type StartThreadMutation = {
5163
5309
  __typename?: 'mutation_root';
@@ -5733,4 +5879,4 @@ declare function getAgentInteractionFinishedEvent(eventData: ThreadEvent$1): Int
5733
5879
  */
5734
5880
  declare function getThreadEventMessageId(event: ThreadEvent$1 | undefined): string | undefined;
5735
5881
 
5736
- export { type AgentInteraction, type AgentLearningUpdate, type AgentLoopAction, type AgentLoopActionResult, type AgentLoopActionUpdate, type AgentLoopUpdate, type AgentState, type AgentTrigger, type AgentUpdate, type AgentUpdateContent, type AllTheServerTypes, type AnalyzedCodeAction, type AnalyzedCodeAction2, type ApolloClientOptions, type ArtifactError, type ArtifactErrorV1, type ArtifactId, type ArtifactPreview, type ArtifactReference, type ArtifactReference1, type ArtifactReference2, type ArtifactState, type ArtifactType, type ArtifactType2, type ArtifactUpdate, type ArtifactUpdate1, type AssumptionFactCheck, type BuildError, type BuildErrorV1, type BuiltUi, type BuiltUi1, type CancelAgentMessageMutationVariables, type CheckedAssumption, type CheckedTopic, type CodeAction, type CodeAction2, type CodeBlock, type CodeError, type CodeErrorV1, type CodeExecutionComplete, type CodeOutputAnalysis, type CodeOutputAnalysis1, type CodeOutputAnalyzed, type ComponentResponse, type ComponentResponse1, type ComponentResponse2, type ComponentResponse3, type ComponentResponse4, type ComponentResponse5, type ConfidenceAnalysis, type ConfidenceAnalysis1, type ConfidenceAnalysisLlmUsage, type ConfidenceAnalysisOutcome, type ConfidenceAnalysisUpdate, type ContextExplorerCompleted, type ContextExplorerStarted, type ContextExplorerState, type ContextExplorerUpdate, type CopyFileEntry, type CreateRoomArguments, type CurrentAction, type DataArtifactUpdated, type DataArtifactUpdatedV1, type Dependency, type EventOfKind, type ExternalKnowledgeExplorerAttempt, type ExternalKnowledgeExplorerAttempt1, type ExternalKnowledgeExplorerAttempt2, type ExternalKnowledgeExplorerState, type ExternalKnowledgeSummary, type ExternalKnowledgeTaskGeneratorState, type FactSource, type GeneratedCode, type GeneratedFile, type GeneratedFile2, type GeneratedProgramRunnerOutput, type GeneratedResponse, type GeneratedUiCode, type GeneratedUiCode1, type GetThreadEventOptions, type GetThreadsQueryVariables, type IPromptQLSdk, type Interaction, type InteractionDecision, type InteractionDecisionAccept, type InteractionDecisionDecline, type InteractionDecisionUpdate, type InteractionDeclineReason, type InteractionError, type InteractionFinishedEvent, type InteractionFinishedUpdate, type InteractionOutcome, type InteractionOutcome2, type InteractionOutcomeStatus, type InteractionUpdate, type InternalError, type InternalErrorV1, type InternalUpdate, type KeysOfUnion, type LearningSuggestion, type LearningSuggestionOutcome, type LearningSuggestionUpdate, type LearningSuggestionUpdateV1, type LlmResponse, type LlmUsage, type MessageProcessingStarted, type MessageProcessingState, type MessageProcessingUpdate, type NeedsSupportAnalysis, type NeedsSupportOutcome, type NeedsSupportUpdate, type OrchestratorState, type OrchestratorUpdate, type Order_By, type OutputEmitted, type OutputEmittedV1, type PipelineColumn, type PipelineColumnType, type PipelinePartitionSpec, type PipelinePartitionTransform, type PipelineProgress, type PipelineProgressV1, type PipelineRunStepDetails, type PipelineSchema, type PipelineSink, type PipelineSource, type PipelineStep, type PipelineTransform, type PlanGenerationStarted, type PlanState, type PlanStateStep, type PlanStepGenerated, type PlanningDecisionCompleted, type PlanningDecisionPlanningRequired, type PlanningDecisionStarted, type PlanningDecisionState, type PlanningDecisionUpdate, type ProgramId, type ProgramPackageName, type ProgramRunEvent, type ProgramRunResult, type ProgramRunnerAction, type ProgramRunnerAction2, type ProgramRunnerActionResult, type ProgramRunnerAttempt, type ProgramTransform, type ProgrammerState, type ProgrammerUpdate, PromptQLSdk, type PromptQLSdkOptions, type PromptQlConfigFeatureFlagModel, type PromptQlUserId, type PythonRunStepDetails, type PythonStep, ROOM_NAME_PATTERN, type ResponseGenerationState, type ResponseGenerationUpdate, type ResponseTruncation, type RoomFragment, type RoomVisibilityType, type RunConfigV1, type RunFinished, type RunFinishedOutcome, type RunFinishedV1, type RunProgramRequest, type RunProgramRequest2, type RunSavedProgramRequest, type RunSavedProgramRequest2, type RunStarted, type RunStartedV1, type RunStepDetails, type SavedProgramRunnerStage, type SavedProgramRunnerState, type SavedProgramRunnerUpdate, type SavedProgramRunnerUpdateV0, type ScheduledAgentTriggerEventId, type ScheduledAgentTriggerId, type ScheduledAgentTriggerPayload, type ScheduledAgentTriggerPayloadV1, type ScheduledAgentTriggerType, type SchemaContext, type SchemaContext1, type SchemaExplored, type SchemaExplorerCompleted, type SchemaExplorerStarted, type SchemaExplorerState, type SchemaExplorerUpdate, type SchemaTask, type SchemaTasksGenerationCompleted, type SchemaTasksGenerationStarted, type SchemaTasksGenerationState, type SchemaTasksGenerationUpdate, type SendMessageToThreadArguments, type SendMessageToThreadOutput, type SendThreadMessageMutationVariables, type ShelfActionEvent, type ShelfSink, type ShelfUpdate, type ShelfUpdateV1, type SkillType, type SocialFeedRating, type SocialFeedRatingLlmUsage, type SocialFeedRatingOutcome, type SocialFeedRatingUpdate, type Span, type SqlError, type SqlErrorV1, type SqlRunStepDetails, type SqlSource, type SqlStep, type StartThreadArguments, type StartThreadMutationVariables, type StartThreadOutput, type StartingOrchestrator, type Step, type StepExecutionFinished, type StepExecutionFinishedV1, type StepExecutionStarted, type StepExecutionStartedV1, type StepState, type StepUpdate, type StreamThreadEventOptions, type SummaryAction, type TasksGenerated, type Teaching, type TeachingId, type TeachingOutcome, type TeachingState, type ThreadEvent, type ThreadEvent$1 as ThreadEventData, type ThreadFragment, type ThreadParticipants, type TransactionId, type TzWrapper, type UiBuild, type UiBuild2, type UiBuildFailure, type UiBuildResult, type UiBuildRunStepDetails, type UiBuildStep, type UiMetadata, type UiProgrammerState, type UiProgrammerUpdate, type UserCancel, type UserCancelEvent, type UserInteraction, type UserMessage, type UserMessageEvent, type UserUpload, type UserUploadMetadata, type Version, type VersionedAgentUpdate, type VersionedOrUnversionedAgentUpdate, type Warning, type WikiAuditId, type WikiChange, type WikiContent, type WikiDelta, type WikiExplorerCompleted, type WikiExplorerStarted, type WikiExplorerState, type WikiExplorerUpdate, type WikiGenerationOutcome, type WikiGenerationUpdate, type WikiInfoGenerated, type WikiLearningSuggestionUpdate, type WikiPageV1, type WikiSection, type WikiSelectionUpdate, type WikiTitle, cancelAgentMessage, createApolloClient, createPromptQLAuthTokenGenerator, createRoom, diffThreadEvents, downloadArtifactData, getAgentGeneratedResponse, getAgentInteractionDecisionAcceptInteractionEvent, getAgentInteractionDecisionDeclineInteractionEvent, getAgentInteractionFinishedEvent, getAgentMessageProcessingStartedEvent, getAgentOrchestratorContextExplorerCompletedEvent, getAgentOrchestratorContextExplorerStartedEvent, getAgentOrchestratorContextExplorerUpdateEvent, getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent, getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent, getAgentOrchestratorSchemaExplorerCompletedEvent, getAgentOrchestratorSchemaExplorerGeneratedCodeEvent, getAgentOrchestratorSchemaExplorerSchemaExploredEvent, getAgentOrchestratorSchemaExplorerStartedEvent, getAgentOrchestratorSchemaExplorerUpdateEvent, getAgentOrchestratorSchemaTasksGeneratedEvent, getAgentOrchestratorSchemaTasksGenerationCompletedEvent, getAgentOrchestratorSchemaTasksGenerationStartedEvent, getAgentOrchestratorSchemaTasksGenerationUpdateEvent, getAgentOrchestratorStepProgrammerEvent, getAgentOrchestratorStepSavedProgramRunnerEvent, getAgentOrchestratorStepUiProgrammerEvent, getAgentOrchestratorStepUpdateEvent, getAgentOrchestratorUpdateEvent, getAgentOrchestratorWikiExplorerCompletedEvent, getAgentOrchestratorWikiExplorerStartedEvent, getAgentOrchestratorWikiExplorerUpdateEvent, getAgentOrchestratorWikiInfoGeneratedEvent, getAgentPlanGenerationStartedEvent, getAgentPlanStepGeneratedEvent, getAgentPlanningDecisionCompletedEvent, getAgentPlanningDecisionPlanningRequiredEvent, getAgentPlanningDecisionStartedEvent, getAgentPlanningDecisionUpdateEvent, getAgentStartingOrchestratorEvent, getThread, getThreadEventMessageId, getThreadEvents, getUserCancelEvent, getUserMessageEvent, isInteractionAnalyzing, listRooms, listThreads, sendThreadMessage, startThread, streamThreadMessageEvents, subscribeThreadEvents };
5882
+ export { type AgentInteraction, type AgentLearningUpdate, type AgentLoopAction, type AgentLoopActionResult, type AgentLoopActionUpdate, type AgentLoopUpdate, type AgentState, type AgentTrigger, type AgentUpdate, type AgentUpdateContent, type AllTheServerTypes, type AnalyzedCodeAction, type AnalyzedCodeAction2, type ApolloClientOptions, type ArtifactError, type ArtifactErrorV1, type ArtifactId, type ArtifactPreview, type ArtifactReference, type ArtifactReference1, type ArtifactReference2, type ArtifactState, type ArtifactType, type ArtifactType2, type ArtifactUpdate, type ArtifactUpdate1, type AssumptionFactCheck, type BuildError, type BuildErrorV1, type BuiltUi, type BuiltUi1, type CancelAgentMessageMutationVariables, type CheckedAssumption, type CheckedTopic, type CodeAction, type CodeAction2, type CodeBlock, type CodeError, type CodeErrorV1, type CodeExecutionComplete, type CodeOutputAnalysis, type CodeOutputAnalysis1, type CodeOutputAnalyzed, type ComponentResponse, type ComponentResponse1, type ComponentResponse2, type ComponentResponse3, type ComponentResponse4, type ComponentResponse5, type ConfidenceAnalysis, type ConfidenceAnalysis1, type ConfidenceAnalysisLlmUsage, type ConfidenceAnalysisOutcome, type ConfidenceAnalysisUpdate, type ContextExplorerCompleted, type ContextExplorerStarted, type ContextExplorerState, type ContextExplorerUpdate, type CopyFileEntry, type CreateRoomArguments, type CurrentAction, type DataArtifactUpdated, type DataArtifactUpdatedV1, type Dependency, type EventOfKind, type ExternalKnowledgeExplorerAttempt, type ExternalKnowledgeExplorerAttempt1, type ExternalKnowledgeExplorerAttempt2, type ExternalKnowledgeExplorerState, type ExternalKnowledgeSummary, type ExternalKnowledgeTaskGeneratorState, type FactSource, type GeneratedCode, type GeneratedFile, type GeneratedFile2, type GeneratedProgramRunnerOutput, type GeneratedResponse, type GeneratedUiCode, type GeneratedUiCode1, type GetThreadEventOptions, type GetThreadsQueryVariables, type IPromptQLSdk, type Interaction, type InteractionDecision, type InteractionDecisionAccept, type InteractionDecisionDecline, type InteractionDecisionUpdate, type InteractionDeclineReason, type InteractionError, type InteractionFinishedEvent, type InteractionFinishedUpdate, type InteractionOutcome, type InteractionOutcome2, type InteractionOutcomeStatus, type InteractionUpdate, type InternalError, type InternalErrorV1, type InternalUpdate, type KeysOfUnion, type LearningSuggestion, type LearningSuggestionOutcome, type LearningSuggestionUpdate, type LearningSuggestionUpdateV1, type LlmResponse, type LlmUsage, type MessageProcessingStarted, type MessageProcessingState, type MessageProcessingUpdate, type NeedsSupportAnalysis, type NeedsSupportOutcome, type NeedsSupportUpdate, type OrchestratorState, type OrchestratorUpdate, type Order_By, type OutputEmitted, type OutputEmittedV1, type PipelineColumn, type PipelineColumnType, type PipelinePartitionSpec, type PipelinePartitionTransform, type PipelineProgress, type PipelineProgressV1, type PipelineRunStepDetails, type PipelineSchema, type PipelineSink, type PipelineSource, type PipelineStep, type PipelineTransform, type PlanGenerationStarted, type PlanState, type PlanStateStep, type PlanStepGenerated, type PlanningDecisionCompleted, type PlanningDecisionPlanningRequired, type PlanningDecisionStarted, type PlanningDecisionState, type PlanningDecisionUpdate, type ProgramId, type ProgramPackageName, type ProgramRunEvent, type ProgramRunResult, type ProgramRunnerAction, type ProgramRunnerAction2, type ProgramRunnerActionResult, type ProgramRunnerAttempt, type ProgramTransform, type ProgrammerState, type ProgrammerUpdate, PromptQLSdk, type PromptQLSdkOptions, type PromptQlConfigFeatureFlagModel, type PromptQlUserId, type PythonRunStepDetails, type PythonStep, ROOM_NAME_PATTERN, type ResponseGenerationState, type ResponseGenerationUpdate, type ResponseTruncation, type RoomFragment, type RoomVisibilityType, type RunConfigV1, type RunFinished, type RunFinishedOutcome, type RunFinishedV1, type RunProgramRequest, type RunProgramRequest2, type RunSavedProgramRequest, type RunSavedProgramRequest2, type RunStarted, type RunStartedV1, type RunStepDetails, type SavedProgramRunnerStage, type SavedProgramRunnerState, type SavedProgramRunnerUpdate, type SavedProgramRunnerUpdateV0, type ScheduledAgentTriggerEventId, type ScheduledAgentTriggerId, type ScheduledAgentTriggerPayload, type ScheduledAgentTriggerPayloadV1, type ScheduledAgentTriggerType, type SchemaContext, type SchemaContext1, type SchemaExplored, type SchemaExplorerCompleted, type SchemaExplorerStarted, type SchemaExplorerState, type SchemaExplorerUpdate, type SchemaTask, type SchemaTasksGenerationCompleted, type SchemaTasksGenerationStarted, type SchemaTasksGenerationState, type SchemaTasksGenerationUpdate, type SendMessageToThreadArguments, type SendMessageToThreadOutput, type SendThreadMessageMutationVariables, type ShelfActionEvent, type ShelfSink, type ShelfUpdate, type ShelfUpdateV1, type SkillType, type SocialFeedRating, type SocialFeedRatingLlmUsage, type SocialFeedRatingOutcome, type SocialFeedRatingUpdate, type Span, type Sql, type SqlError, type SqlErrorType, type SqlErrorV1, type SqlExecuteCompleted, type SqlExecuteCompletedV1, type SqlExecuteOutcome, type SqlExecuteOutcome2, type SqlExecuteStarted, type SqlExecuteStartedV1, type SqlQueryId, type SqlRunStepDetails, type SqlSource, type SqlStep, type StartThreadArguments, type StartThreadMutationVariables, type StartThreadOutput, type StartingOrchestrator, type Step, type StepExecutionFinished, type StepExecutionFinishedV1, type StepExecutionStarted, type StepExecutionStartedV1, type StepState, type StepUpdate, type StreamThreadEventOptions, type SummaryAction, type TasksGenerated, type Teaching, type TeachingId, type TeachingOutcome, type TeachingState, type ThreadEvent, type ThreadEvent$1 as ThreadEventData, type ThreadFragment, type ThreadParticipants, type TransactionId, type TzWrapper, type UiBuild, type UiBuild2, type UiBuildFailure, type UiBuildResult, type UiBuildRunStepDetails, type UiBuildStep, type UiMetadata, type UiProgrammerState, type UiProgrammerUpdate, type UserCancel, type UserCancelEvent, type UserInteraction, type UserMessage, type UserMessageEvent, type UserUpload, type UserUploadMetadata, type Version, type VersionedAgentUpdate, type VersionedOrUnversionedAgentUpdate, type Warning, type WikiAuditId, type WikiChange, type WikiContent, type WikiDelta, type WikiExplorerCompleted, type WikiExplorerStarted, type WikiExplorerState, type WikiExplorerUpdate, type WikiGenerationOutcome, type WikiGenerationUpdate, type WikiInfoGenerated, type WikiLearningSuggestionUpdate, type WikiPageV1, type WikiSection, type WikiSelectionUpdate, type WikiTitle, cancelAgentMessage, createApolloClient, createPromptQLAuthTokenGenerator, createRoom, diffThreadEvents, downloadArtifactData, getAgentGeneratedResponse, getAgentInteractionDecisionAcceptInteractionEvent, getAgentInteractionDecisionDeclineInteractionEvent, getAgentInteractionFinishedEvent, getAgentMessageProcessingStartedEvent, getAgentOrchestratorContextExplorerCompletedEvent, getAgentOrchestratorContextExplorerStartedEvent, getAgentOrchestratorContextExplorerUpdateEvent, getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent, getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent, getAgentOrchestratorSchemaExplorerCompletedEvent, getAgentOrchestratorSchemaExplorerGeneratedCodeEvent, getAgentOrchestratorSchemaExplorerSchemaExploredEvent, getAgentOrchestratorSchemaExplorerStartedEvent, getAgentOrchestratorSchemaExplorerUpdateEvent, getAgentOrchestratorSchemaTasksGeneratedEvent, getAgentOrchestratorSchemaTasksGenerationCompletedEvent, getAgentOrchestratorSchemaTasksGenerationStartedEvent, getAgentOrchestratorSchemaTasksGenerationUpdateEvent, getAgentOrchestratorStepProgrammerEvent, getAgentOrchestratorStepSavedProgramRunnerEvent, getAgentOrchestratorStepUiProgrammerEvent, getAgentOrchestratorStepUpdateEvent, getAgentOrchestratorUpdateEvent, getAgentOrchestratorWikiExplorerCompletedEvent, getAgentOrchestratorWikiExplorerStartedEvent, getAgentOrchestratorWikiExplorerUpdateEvent, getAgentOrchestratorWikiInfoGeneratedEvent, getAgentPlanGenerationStartedEvent, getAgentPlanStepGeneratedEvent, getAgentPlanningDecisionCompletedEvent, getAgentPlanningDecisionPlanningRequiredEvent, getAgentPlanningDecisionStartedEvent, getAgentPlanningDecisionUpdateEvent, getAgentStartingOrchestratorEvent, getThread, getThreadEventMessageId, getThreadEvents, getUserCancelEvent, getUserMessageEvent, isInteractionAnalyzing, listRooms, listThreads, sendThreadMessage, startThread, streamThreadMessageEvents, subscribeThreadEvents };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var B=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var pe=(t,e)=>{for(var a in e)B(t,a,{get:e[a],enumerable:!0})},ue=(t,e,a,_)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ie(e))!oe.call(t,r)&&r!==a&&B(t,r,{get:()=>e[r],enumerable:!(_=ne(e,r))||_.enumerable});return t};var se=t=>ue(B({},"__esModule",{value:!0}),t);var Ke={};pe(Ke,{PromptQLSdk:()=>W,ROOM_NAME_PATTERN:()=>k,cancelAgentMessage:()=>U,createApolloClient:()=>j,createPromptQLAuthTokenGenerator:()=>I,createRoom:()=>O,diffThreadEvents:()=>le,downloadArtifactData:()=>de,getAgentGeneratedResponse:()=>ge,getAgentInteractionDecisionAcceptInteractionEvent:()=>Ae,getAgentInteractionDecisionDeclineInteractionEvent:()=>xe,getAgentInteractionFinishedEvent:()=>De,getAgentMessageProcessingStartedEvent:()=>Se,getAgentOrchestratorContextExplorerCompletedEvent:()=>Oe,getAgentOrchestratorContextExplorerStartedEvent:()=>ke,getAgentOrchestratorContextExplorerUpdateEvent:()=>y,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent:()=>je,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent:()=>Ve,getAgentOrchestratorSchemaExplorerCompletedEvent:()=>Fe,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent:()=>We,getAgentOrchestratorSchemaExplorerSchemaExploredEvent:()=>Ne,getAgentOrchestratorSchemaExplorerStartedEvent:()=>we,getAgentOrchestratorSchemaExplorerUpdateEvent:()=>d,getAgentOrchestratorSchemaTasksGeneratedEvent:()=>Ue,getAgentOrchestratorSchemaTasksGenerationCompletedEvent:()=>Re,getAgentOrchestratorSchemaTasksGenerationStartedEvent:()=>Pe,getAgentOrchestratorSchemaTasksGenerationUpdateEvent:()=>f,getAgentOrchestratorStepProgrammerEvent:()=>ze,getAgentOrchestratorStepSavedProgramRunnerEvent:()=>Ge,getAgentOrchestratorStepUiProgrammerEvent:()=>qe,getAgentOrchestratorStepUpdateEvent:()=>C,getAgentOrchestratorUpdateEvent:()=>x,getAgentOrchestratorWikiExplorerCompletedEvent:()=>Ee,getAgentOrchestratorWikiExplorerStartedEvent:()=>ve,getAgentOrchestratorWikiExplorerUpdateEvent:()=>h,getAgentOrchestratorWikiInfoGeneratedEvent:()=>Te,getAgentPlanGenerationStartedEvent:()=>Ie,getAgentPlanStepGeneratedEvent:()=>Me,getAgentPlanningDecisionCompletedEvent:()=>fe,getAgentPlanningDecisionPlanningRequiredEvent:()=>Ce,getAgentPlanningDecisionStartedEvent:()=>he,getAgentPlanningDecisionUpdateEvent:()=>A,getAgentStartingOrchestratorEvent:()=>Be,getThread:()=>T,getThreadEventMessageId:()=>Qe,getThreadEvents:()=>b,getUserCancelEvent:()=>be,getUserMessageEvent:()=>me,isInteractionAnalyzing:()=>$,listRooms:()=>l,listThreads:()=>E,sendThreadMessage:()=>R,startThread:()=>P,streamThreadMessageEvents:()=>F,subscribeThreadEvents:()=>w});module.exports=se(Ke);async function de(t,e,a,_,r){let i=`https://${t}/promptql-v2/artifacts/${e}/version/${a}/data`,n=await(typeof r=="function"?r:fetch)(i,{method:"GET",headers:_});if(n.status!==200){let c=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to download artifact: ${c}`)}return n.body?n.headers.get("Content-Type")?.startsWith("application/json")?n.json():n.text():null}var N={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelAgentMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"messageId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancel_agent_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"agentMessageId"},value:{kind:"Variable",name:{kind:"Name",value:"messageId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},z={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateRoom"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"name"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"visibility"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"description"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"create_room"},arguments:[{kind:"Argument",name:{kind:"Name",value:"name"},value:{kind:"Variable",name:{kind:"Name",value:"name"}}},{kind:"Argument",name:{kind:"Name",value:"visibility"},value:{kind:"Variable",name:{kind:"Name",value:"visibility"}}},{kind:"Argument",name:{kind:"Name",value:"description"},value:{kind:"Variable",name:{kind:"Name",value:"description"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"room_id"}}]}}]}}]},q={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"SendThreadMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"send_thread_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},G={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"StartThread"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"roomId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"visibility"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"start_thread"},arguments:[{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"buildId"},value:{kind:"Variable",name:{kind:"Name",value:"buildId"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"roomId"},value:{kind:"Variable",name:{kind:"Name",value:"roomId"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}},{kind:"Argument",name:{kind:"Name",value:"visibility"},value:{kind:"Variable",name:{kind:"Name",value:"visibility"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"thread_events"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"thread_event_id"}}]}}]}}]}}]},D={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetProjectInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"get_project_info"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"projectId"}},{kind:"Field",name:{kind:"Name",value:"projectName"}},{kind:"Field",name:{kind:"Name",value:"promptqlConsoleUrl"}}]}}]}}]},Q={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetRooms"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"rooms_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"rooms_order_by"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}},defaultValue:{kind:"IntValue",value:"10"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"rooms"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Room"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Room"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"rooms"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"room_id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"description"}},{kind:"Field",name:{kind:"Name",value:"project_id"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"user_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]},K={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},J={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},L={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"ordering"}},type:{kind:"NamedType",name:{kind:"Name",value:"order_by"}},defaultValue:{kind:"EnumValue",value:"asc"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"Variable",name:{kind:"Name",value:"ordering"}}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]},H={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"subscription",name:{kind:"Name",value:"SubscribeThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]};var k=/([a-z0-9]+-?)*[a-z0-9]+/;function l(t,e){return t.query({query:Q,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.rooms??[])}function O(t,e){if(!e.name)throw new Error("Room name is required");if(k.test(e.name))throw new Error("Room name must be URL-friendly, for example, sample-room-name");return t.mutate({mutation:z,variables:e,fetchPolicy:"no-cache"}).then(a=>{if(!a.data?.create_room?.room_id)throw new Error("expected room_id in response, got null");return a.data?.create_room?.room_id})}var u=require("rxjs");function m(t){return t=t?t.trim():"",t?t[t.length-1]==="/"?t.slice(0,t.length-1):t:""}function v(t){if(t==null)return null;try{Number.parseInt(t)}catch{throw new Error("invalid threadEventId")}return t}function E(t,e){return t.query({query:K,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function T(t,e){if(!e)throw new Error("threadId is required");return t.query({query:J,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function P(t,e){if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:G,variables:e}).then(a=>{if(!a.data?.start_thread)throw new Error(a.error?.message||"Failed to start thread");return a.data.start_thread})}function b(t,e,a){if(!e)throw new Error("threadId is required");let _={thread_id:{_eq:e}};return a&&(a.eventId&&(_.thread_event_id=a.eventId),a.messageId&&(_._or=ye(a.messageId))),t.query({query:L,variables:{where:_,limit:a?.limit,ordering:a?.ordering||"asc"},fetchPolicy:"no-cache"}).then(r=>r.data?.thread_events??[])}function R(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:q,variables:e}).then(a=>{if(!a.data?.send_thread_message)throw new Error(a.error?.message||"Failed to send message to thread");return a.data.send_thread_message})}function U(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.messageId.trim())throw new Error("messageId is required");return t.mutate({mutation:N,variables:e}).then(a=>{if(!a.data?.cancel_agent_message)throw new Error(a.error?.message||"Failed to cancel thread");return a.data.cancel_agent_message})}function w(t,e,a){if(!e)throw new Error("threadId is required");v(a);let _={thread_id:{_eq:e}};return a&&(_.thread_event_id={_gte:a}),t.subscribe({query:H,variables:{where:_}}).pipe((0,u.map)(r=>{if(r.error)throw r.error;return r.data?.thread_events??[]}))}function F(t,e,a){if(!e)throw new Error("threadId is required");let _,r=v(a?.fromEventId),i={eventId:a?.fromEventId?{_gte:r}:void 0,messageId:a?.messageId},o=a?.pollingInterval&&a?.pollingInterval>0?a.pollingInterval:5;return(0,u.defer)(async()=>{let n=_?{messageId:a?.messageId,eventId:{_gt:_}}:i,p=await b(t,e,n);return p.length>0&&(_=p[p.length-1]?.thread_event_id),p}).pipe((0,u.repeat)({count:a?.timeout&&a.timeout>0?Math.ceil(a.timeout/o):void 0,delay:o*1e3}),(0,u.takeWhile)(n=>$(n,a?.skipAnalysis),!0))}function $(t,e){for(let a=t.length-1;a>0;a--){let _=t[a];if(e&&"UserCancel"in _.event_data)return!1;if(!("AgentMessage"in _.event_data))return!0;let r=_.event_data.AgentMessage.update;if("content"in r&&("interaction_finished"in r.content||e&&"interaction_update"in r.content&&"main_agent"in r.content.interaction_update&&"completed"in r.content.interaction_update.main_agent)||"InteractionFinished"in r||e&&"OrchestratorUpdate"in r&&"GeneratedResponse"in r.OrchestratorUpdate.update)return!1}return!0}function ye(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}function Z(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="failure"}function X(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="success"&&"token"in t}function Y(t){return t!=null&&typeof t=="object"&&("data"in t&&!!t.data&&typeof t.data=="object"&&"enrich_token"in t.data&&!!t.data.enrich_token&&typeof t.data.enrich_token=="object"&&"userDirectoryJWT"in t.data.enrich_token||"errors"in t&&Array.isArray(t.errors))}function I(t){let a=`${m(t.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,_={token:"",expiry:new Date(0)},r=t.fetch||fetch,i=async()=>{let o=await r(a,{method:"POST",headers:t.headers});switch(o.status){case 200:{let n=await o.json();if(X(n))return n;throw new Error("malformed token response")}case 401:{let n=await o.json();throw Z(n)?new Error(n?.error||o.statusText):new Error(o.statusText)}default:{let n=await o.text();throw new Error(n)}}};return async()=>{if(_.expiry.getTime()<=Date.now()-1e3){let o=await i(),n=await ce(t.promptqlGraphQLUrl,o.token,t.projectId,r);_.token=n;let p=new Date(o.expiry);if(Number.isNaN(p.getTime())){let c=new Date;c.setHours(1),_.expiry=c}else _.expiry=p}return _.token}}var ce=async(t,e,a,_=fetch)=>{let r=await _(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:e,projectId:a},operationName:"EnrichToken"})});switch(r.status){case 200:{let i=await r.json();if(!Y(i)||!i.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(i)}`);return i.data.enrich_token.userDirectoryJWT}default:{let i=await r.text();throw new Error(i)}}};function ee(t){return{Authorization:`pat ${t}`}}var s=require("@apollo/client"),te=require("@apollo/client/link/context"),ae=require("@apollo/client/link/subscriptions"),re=require("graphql"),_e=require("graphql-ws"),j=t=>{let e=new s.HttpLink({uri:t.url,fetch:t.fetch,headers:t.headers}),a=async n=>{let p=await t.getAuthToken();return{headers:{...n,Authorization:`Bearer ${p}`}}},_=(0,_e.createClient)({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),r=new ae.GraphQLWsLink(_),i=new te.SetContextLink(({headers:n})=>a(n)),o=s.ApolloLink.split(({operationType:n})=>n===re.OperationTypeNode.SUBSCRIPTION,r,i.concat(e));return{client:new s.ApolloClient({link:o,cache:new s.InMemoryCache}),wsClient:_}};var M=class{_options;constructor(e){this._options=e}info(){return V(this._options.client)}};function V(t){return t.query({query:D,fetchPolicy:"cache-first"}).then(e=>{if(!e.data?.get_project_info)throw new Error(e.error?.message||"Project not found");return e.data.get_project_info})}var g=class{_options;constructor(e){this._options=e}list(e){return l(this._options.client,{...e,limit:e.limit&&e.limit>0?e.limit:10})}getByName(e){return l(this._options.client,{where:{name:{_eq:e}},limit:1}).then(a=>a.length?a[0]??null:null)}create(e){return O(this._options.client,e)}};var S=class{_options;constructor(e){this._options=e}list(e){return E(this._options.client,{...e,limit:e.limit&&e.limit>0?e.limit:10})}get(e){if(!e)throw new Error("threadId is required");return T(this._options.client,e)}async start(e){let a=await V(this._options.client);return P(this._options.client,{...e,projectId:a.projectId,buildId:e.buildId||this._options.buildId,timezone:e.timezone||this._options.defaultTimezone})}getEvents(e,a){return b(this._options.client,e,a)}sendMessage(e){return R(this._options.client,{...e,timezone:e.timezone||this._options.defaultTimezone})}cancelAgentMessage(e){return U(this._options.client,e)}subscribeEvents(e,a){return w(this._options.client,e,a)}streamMessageEvents(e,a){return F(this._options.client,e,a)}};var W=class{constructor(e){let a=m(e.promptqlBaseUrl)||"https://promptql.ddn.hasura.app";if(!e.serviceAccountToken)throw new Error("serviceAccountToken must not be empty. If you haven't created any service account token yet, check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account");let _=a.endsWith("/v1/graphql")?a:`${a}/playground-v2-hge/v1/graphql`;this._fetchToken=I({promptqlGraphQLUrl:_,authHost:e.authHost,headers:ee(e.serviceAccountToken),fetch:e.fetch});let{client:r,wsClient:i}=j({getAuthToken:this._fetchToken,url:_,fetch:e.fetch,headers:e.headers});this._wsClient=i,this._options={client:r,buildId:e.buildId,defaultTimezone:e.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone},this.thread=new S(this._options),this.project=new M(this._options),this.room=new g(this._options)}_options;_wsClient;_fetchToken;thread;project;room;authenticated(){return this._fetchToken().then(()=>!0).catch(()=>!1)}close(){this._wsClient.dispose(),this._options.client.clearStore()}};function le(t,e){if(!e.length)return[];if(!t.length)return e;let a=t[t.length-1];if(!a)return e;let _=BigInt(a.thread_event_id),r=e.length-1;for(;r>=0;r--){let i=e[r];if(BigInt(i?.thread_event_id)<=_)break}return e.slice(r+1)}function me(t){return"UserMessage"in t?t.UserMessage:null}function be(t){return"UserCancel"in t?t.UserCancel:null}function Ie(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)||!("PlanGenerationStarted"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function Me(t){let e=x(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function ge(t){return"AgentMessage"in t?"content"in t.AgentMessage.update&&"interaction_update"in t.AgentMessage.update.content&&"main_agent"in t.AgentMessage.update.content.interaction_update&&"completed"in t.AgentMessage.update.content.interaction_update.main_agent?{success:!0,message:t.AgentMessage.update.content.interaction_update.main_agent.completed.summary,modified_artifacts:[],generated_at:t.AgentMessage.update.timestamp}:!("OrchestratorUpdate"in t.AgentMessage.update)||!("GeneratedResponse"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse.response:null}function Se(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("ProcessingStarted"in t.AgentMessage.update.MessageProcessingUpdate.update)?null:t.AgentMessage.update.MessageProcessingUpdate.update.ProcessingStarted}function Ae(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("AcceptInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.AcceptInteraction}function xe(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function A(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function he(t){let e=A(t);return!e||!("Started"in e)?null:e.Started}function fe(t){let e=A(t);return!e||!("Completed"in e)?null:e.Completed}function Ce(t){let e=A(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function Be(t){return!("AgentMessage"in t)||!("StartingOrchestrator"in t.AgentMessage.update)?null:t.AgentMessage.update.StartingOrchestrator}function x(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.OrchestratorUpdate.update}function y(t){let e=x(t);return!e||!("ContextExplorerUpdate"in e)?null:e.ContextExplorerUpdate.update}function ke(t){let e=y(t);return!e||!("Started"in e)?null:e.Started}function Oe(t){let e=y(t);return!e||!("Completed"in e)?null:e.Completed}function h(t){let e=y(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function ve(t){let e=h(t);return!e||!("Started"in e)?null:e.Started}function Ee(t){let e=h(t);return!e||!("Completed"in e)?null:e.Completed}function Te(t){let e=h(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function f(t){let e=y(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function Pe(t){let e=f(t);return!e||!("Started"in e)?null:e.Started}function Re(t){let e=f(t);return!e||!("Completed"in e)?null:e.Completed}function Ue(t){let e=f(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function d(t){let e=y(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function we(t){let e=d(t);return!e||!("Started"in e)?null:e.Started}function Fe(t){let e=d(t);return!e||!("Completed"in e)?null:e.Completed}function je(t){let e=d(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function Ve(t){let e=d(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function We(t){let e=d(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function Ne(t){let e=d(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function C(t){let e=x(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function ze(t){let e=C(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function qe(t){let e=C(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function Ge(t){let e=C(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function De(t){if(!("AgentMessage"in t))return null;if("InteractionFinished"in t.AgentMessage.update){let e=t.AgentMessage.update.InteractionFinished.update;return"Completed"in e?{status:"completed",timestamp:e.Completed.completed_at,warnings:e.Completed.warnings}:"Errored"in e?{status:"errored",timestamp:e.Errored.errored_at,reason:typeof e.Errored.error=="string"?e.Errored.error:e.Errored.error.User.message}:"UserCancelled"in e?{status:"user_cancelled",timestamp:e.UserCancelled.cancelled_at}:"AgentDeclined"in e?{status:"agent_declined",timestamp:e.AgentDeclined.declined_at,reason:e.AgentDeclined.reason}:"ServerCancelled"in e?{status:"server_cancelled",timestamp:e.ServerCancelled.cancelled_at}:{status:"unknown"}}if("content"in t.AgentMessage.update&&"interaction_finished"in t.AgentMessage.update.content){let e=t.AgentMessage.update.content.interaction_finished.outcome;return"errored"in e?{status:"errored",reason:e.errored.user_facing_message||e.errored.raw_error,timestamp:t.AgentMessage.update.timestamp,warnings:e.errored.raw_error?[{message:e.errored.raw_error}]:[]}:"server_cancelled"in e?{status:"server_cancelled",timestamp:t.AgentMessage.update.timestamp}:"user_cancelled"in e?{status:"user_cancelled",timestamp:t.AgentMessage.update.timestamp}:"completed"in e?{status:"completed",timestamp:t.AgentMessage.update.timestamp,warnings:e.completed.warnings}:{status:"unknown"}}return null}function Qe(t){if(t){if("UserMessage"in t)return t.UserMessage.message_id;if("AgentMessage"in t)return t.AgentMessage.message_id;if("UserTeach"in t)return t.UserTeach.agent_message_id;if("UserCancel"in t)return t.UserCancel.message_id}}0&&(module.exports={PromptQLSdk,ROOM_NAME_PATTERN,cancelAgentMessage,createApolloClient,createPromptQLAuthTokenGenerator,createRoom,diffThreadEvents,downloadArtifactData,getAgentGeneratedResponse,getAgentInteractionDecisionAcceptInteractionEvent,getAgentInteractionDecisionDeclineInteractionEvent,getAgentInteractionFinishedEvent,getAgentMessageProcessingStartedEvent,getAgentOrchestratorContextExplorerCompletedEvent,getAgentOrchestratorContextExplorerStartedEvent,getAgentOrchestratorContextExplorerUpdateEvent,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,getAgentOrchestratorSchemaExplorerCompletedEvent,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,getAgentOrchestratorSchemaExplorerSchemaExploredEvent,getAgentOrchestratorSchemaExplorerStartedEvent,getAgentOrchestratorSchemaExplorerUpdateEvent,getAgentOrchestratorSchemaTasksGeneratedEvent,getAgentOrchestratorSchemaTasksGenerationCompletedEvent,getAgentOrchestratorSchemaTasksGenerationStartedEvent,getAgentOrchestratorSchemaTasksGenerationUpdateEvent,getAgentOrchestratorStepProgrammerEvent,getAgentOrchestratorStepSavedProgramRunnerEvent,getAgentOrchestratorStepUiProgrammerEvent,getAgentOrchestratorStepUpdateEvent,getAgentOrchestratorUpdateEvent,getAgentOrchestratorWikiExplorerCompletedEvent,getAgentOrchestratorWikiExplorerStartedEvent,getAgentOrchestratorWikiExplorerUpdateEvent,getAgentOrchestratorWikiInfoGeneratedEvent,getAgentPlanGenerationStartedEvent,getAgentPlanStepGeneratedEvent,getAgentPlanningDecisionCompletedEvent,getAgentPlanningDecisionPlanningRequiredEvent,getAgentPlanningDecisionStartedEvent,getAgentPlanningDecisionUpdateEvent,getAgentStartingOrchestratorEvent,getThread,getThreadEventMessageId,getThreadEvents,getUserCancelEvent,getUserMessageEvent,isInteractionAnalyzing,listRooms,listThreads,sendThreadMessage,startThread,streamThreadMessageEvents,subscribeThreadEvents});
1
+ "use strict";var B=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var oe=Object.prototype.hasOwnProperty;var pe=(t,e)=>{for(var a in e)B(t,a,{get:e[a],enumerable:!0})},ue=(t,e,a,_)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of ie(e))!oe.call(t,r)&&r!==a&&B(t,r,{get:()=>e[r],enumerable:!(_=ne(e,r))||_.enumerable});return t};var se=t=>ue(B({},"__esModule",{value:!0}),t);var Ke={};pe(Ke,{PromptQLSdk:()=>W,ROOM_NAME_PATTERN:()=>k,cancelAgentMessage:()=>U,createApolloClient:()=>j,createPromptQLAuthTokenGenerator:()=>I,createRoom:()=>O,diffThreadEvents:()=>le,downloadArtifactData:()=>de,getAgentGeneratedResponse:()=>Se,getAgentInteractionDecisionAcceptInteractionEvent:()=>Ae,getAgentInteractionDecisionDeclineInteractionEvent:()=>xe,getAgentInteractionFinishedEvent:()=>Ge,getAgentMessageProcessingStartedEvent:()=>ge,getAgentOrchestratorContextExplorerCompletedEvent:()=>Oe,getAgentOrchestratorContextExplorerStartedEvent:()=>ke,getAgentOrchestratorContextExplorerUpdateEvent:()=>y,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent:()=>je,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent:()=>Ve,getAgentOrchestratorSchemaExplorerCompletedEvent:()=>Fe,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent:()=>We,getAgentOrchestratorSchemaExplorerSchemaExploredEvent:()=>Ne,getAgentOrchestratorSchemaExplorerStartedEvent:()=>we,getAgentOrchestratorSchemaExplorerUpdateEvent:()=>d,getAgentOrchestratorSchemaTasksGeneratedEvent:()=>Ue,getAgentOrchestratorSchemaTasksGenerationCompletedEvent:()=>Re,getAgentOrchestratorSchemaTasksGenerationStartedEvent:()=>Pe,getAgentOrchestratorSchemaTasksGenerationUpdateEvent:()=>f,getAgentOrchestratorStepProgrammerEvent:()=>ze,getAgentOrchestratorStepSavedProgramRunnerEvent:()=>De,getAgentOrchestratorStepUiProgrammerEvent:()=>qe,getAgentOrchestratorStepUpdateEvent:()=>C,getAgentOrchestratorUpdateEvent:()=>x,getAgentOrchestratorWikiExplorerCompletedEvent:()=>Ee,getAgentOrchestratorWikiExplorerStartedEvent:()=>ve,getAgentOrchestratorWikiExplorerUpdateEvent:()=>h,getAgentOrchestratorWikiInfoGeneratedEvent:()=>Te,getAgentPlanGenerationStartedEvent:()=>Ie,getAgentPlanStepGeneratedEvent:()=>Me,getAgentPlanningDecisionCompletedEvent:()=>fe,getAgentPlanningDecisionPlanningRequiredEvent:()=>Ce,getAgentPlanningDecisionStartedEvent:()=>he,getAgentPlanningDecisionUpdateEvent:()=>A,getAgentStartingOrchestratorEvent:()=>Be,getThread:()=>T,getThreadEventMessageId:()=>Qe,getThreadEvents:()=>m,getUserCancelEvent:()=>me,getUserMessageEvent:()=>be,isInteractionAnalyzing:()=>$,listRooms:()=>l,listThreads:()=>E,sendThreadMessage:()=>R,startThread:()=>P,streamThreadMessageEvents:()=>F,subscribeThreadEvents:()=>w});module.exports=se(Ke);async function de(t,e,a,_,r){let i=`https://${t}/promptql-v2/artifacts/${e}/version/${a}/data`,n=await(typeof r=="function"?r:fetch)(i,{method:"GET",headers:_});if(n.status!==200){let c=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to download artifact: ${c}`)}return n.body?n.headers.get("Content-Type")?.startsWith("application/json")?n.json():n.text():null}var N={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelAgentMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"messageId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancel_agent_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"agentMessageId"},value:{kind:"Variable",name:{kind:"Name",value:"messageId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},z={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateRoom"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"name"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"visibility"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"description"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"create_room"},arguments:[{kind:"Argument",name:{kind:"Name",value:"name"},value:{kind:"Variable",name:{kind:"Name",value:"name"}}},{kind:"Argument",name:{kind:"Name",value:"visibility"},value:{kind:"Variable",name:{kind:"Name",value:"visibility"}}},{kind:"Argument",name:{kind:"Name",value:"description"},value:{kind:"Variable",name:{kind:"Name",value:"description"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"room_id"}}]}}]}}]},q={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"SendThreadMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"send_thread_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},D={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"StartThread"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"roomId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"visibility"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"createdFrom"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"start_thread"},arguments:[{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"buildId"},value:{kind:"Variable",name:{kind:"Name",value:"buildId"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"roomId"},value:{kind:"Variable",name:{kind:"Name",value:"roomId"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}},{kind:"Argument",name:{kind:"Name",value:"visibility"},value:{kind:"Variable",name:{kind:"Name",value:"visibility"}}},{kind:"Argument",name:{kind:"Name",value:"createdFrom"},value:{kind:"Variable",name:{kind:"Name",value:"createdFrom"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"thread_events"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"thread_event_id"}}]}}]}}]}}]},G={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetProjectInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"get_project_info"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"projectId"}},{kind:"Field",name:{kind:"Name",value:"projectName"}},{kind:"Field",name:{kind:"Name",value:"promptqlConsoleUrl"}}]}}]}}]},Q={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetRooms"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"rooms_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"rooms_order_by"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}},defaultValue:{kind:"IntValue",value:"10"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"rooms"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Room"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Room"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"rooms"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"room_id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"description"}},{kind:"Field",name:{kind:"Name",value:"project_id"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"user_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]},K={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},J={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},L={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"ordering"}},type:{kind:"NamedType",name:{kind:"Name",value:"order_by"}},defaultValue:{kind:"EnumValue",value:"asc"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"Variable",name:{kind:"Name",value:"ordering"}}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]},H={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"subscription",name:{kind:"Name",value:"SubscribeThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]};var k=/([a-z0-9]+-?)*[a-z0-9]+/;function l(t,e){return t.query({query:Q,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.rooms??[])}function O(t,e){if(!e.name)throw new Error("Room name is required");if(!k.test(e.name))throw new Error("Room name must be URL-friendly, for example, sample-room-name");return t.mutate({mutation:z,variables:e,fetchPolicy:"no-cache"}).then(a=>{if(!a.data?.create_room?.room_id)throw new Error("expected room_id in response, got null");return a.data?.create_room?.room_id})}var u=require("rxjs");function b(t){return t=t?t.trim():"",t?t[t.length-1]==="/"?t.slice(0,t.length-1):t:""}function v(t){if(t==null)return null;try{Number.parseInt(t)}catch{throw new Error("invalid threadEventId")}return t}function E(t,e){return t.query({query:K,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function T(t,e){if(!e)throw new Error("threadId is required");return t.query({query:J,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function P(t,e){if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:D,variables:e}).then(a=>{if(!a.data?.start_thread)throw new Error(a.error?.message||"Failed to start thread");return a.data.start_thread})}function m(t,e,a){if(!e)throw new Error("threadId is required");let _={thread_id:{_eq:e}};return a&&(a.eventId&&(_.thread_event_id=a.eventId),a.messageId&&(_._or=ye(a.messageId))),t.query({query:L,variables:{where:_,limit:a?.limit,ordering:a?.ordering||"asc"},fetchPolicy:"no-cache"}).then(r=>r.data?.thread_events??[])}function R(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:q,variables:e}).then(a=>{if(!a.data?.send_thread_message)throw new Error(a.error?.message||"Failed to send message to thread");return a.data.send_thread_message})}function U(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.messageId.trim())throw new Error("messageId is required");return t.mutate({mutation:N,variables:e}).then(a=>{if(!a.data?.cancel_agent_message)throw new Error(a.error?.message||"Failed to cancel thread");return a.data.cancel_agent_message})}function w(t,e,a){if(!e)throw new Error("threadId is required");v(a);let _={thread_id:{_eq:e}};return a&&(_.thread_event_id={_gte:a}),t.subscribe({query:H,variables:{where:_}}).pipe((0,u.map)(r=>{if(r.error)throw r.error;return r.data?.thread_events??[]}))}function F(t,e,a){if(!e)throw new Error("threadId is required");let _,r=v(a?.fromEventId),i={eventId:a?.fromEventId?{_gte:r}:void 0,messageId:a?.messageId},o=a?.pollingInterval&&a?.pollingInterval>0?a.pollingInterval:5;return(0,u.defer)(async()=>{let n=_?{messageId:a?.messageId,eventId:{_gt:_}}:i,p=await m(t,e,n);return p.length>0&&(_=p[p.length-1]?.thread_event_id),p}).pipe((0,u.repeat)({count:a?.timeout&&a.timeout>0?Math.ceil(a.timeout/o):void 0,delay:o*1e3}),(0,u.takeWhile)(n=>$(n,a?.skipAnalysis),!0))}function $(t,e){for(let a=t.length-1;a>0;a--){let _=t[a];if(e&&"UserCancel"in _.event_data)return!1;if(!("AgentMessage"in _.event_data))return!0;let r=_.event_data.AgentMessage.update;if("content"in r&&("interaction_finished"in r.content||e&&"interaction_update"in r.content&&"main_agent"in r.content.interaction_update&&"completed"in r.content.interaction_update.main_agent)||"InteractionFinished"in r||e&&"OrchestratorUpdate"in r&&"GeneratedResponse"in r.OrchestratorUpdate.update)return!1}return!0}function ye(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}function Z(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="failure"}function X(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="success"&&"token"in t}function Y(t){return t!=null&&typeof t=="object"&&("data"in t&&!!t.data&&typeof t.data=="object"&&"enrich_token"in t.data&&!!t.data.enrich_token&&typeof t.data.enrich_token=="object"&&"userDirectoryJWT"in t.data.enrich_token||"errors"in t&&Array.isArray(t.errors))}function I(t){let a=`${b(t.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,_={token:"",expiry:new Date(0)},r=t.fetch||fetch,i=async()=>{let o=await r(a,{method:"POST",headers:t.headers});switch(o.status){case 200:{let n=await o.json();if(X(n))return n;throw new Error("malformed token response")}case 401:{let n=await o.json();throw Z(n)?new Error(n?.error||o.statusText):new Error(o.statusText)}default:{let n=await o.text();throw new Error(n)}}};return async()=>{if(_.expiry.getTime()<=Date.now()-1e3){let o=await i(),n=await ce(t.promptqlGraphQLUrl,o.token,t.projectId,r);_.token=n;let p=new Date(o.expiry);if(Number.isNaN(p.getTime())){let c=new Date;c.setHours(1),_.expiry=c}else _.expiry=p}return _.token}}var ce=async(t,e,a,_=fetch)=>{let r=await _(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:e,projectId:a},operationName:"EnrichToken"})});switch(r.status){case 200:{let i=await r.json();if(!Y(i)||!i.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(i)}`);return i.data.enrich_token.userDirectoryJWT}default:{let i=await r.text();throw new Error(i)}}};function ee(t){return{Authorization:`pat ${t}`}}var s=require("@apollo/client"),te=require("@apollo/client/link/context"),ae=require("@apollo/client/link/subscriptions"),re=require("graphql"),_e=require("graphql-ws"),j=t=>{let e=new s.HttpLink({uri:t.url,fetch:t.fetch,headers:t.headers}),a=async n=>{let p=await t.getAuthToken();return{headers:{...n,Authorization:`Bearer ${p}`}}},_=(0,_e.createClient)({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),r=new ae.GraphQLWsLink(_),i=new te.SetContextLink(({headers:n})=>a(n)),o=s.ApolloLink.split(({operationType:n})=>n===re.OperationTypeNode.SUBSCRIPTION,r,i.concat(e));return{client:new s.ApolloClient({link:o,cache:new s.InMemoryCache}),wsClient:_}};var M=class{_options;constructor(e){this._options=e}info(){return V(this._options.client)}};function V(t){return t.query({query:G,fetchPolicy:"cache-first"}).then(e=>{if(!e.data?.get_project_info)throw new Error(e.error?.message||"Project not found");return e.data.get_project_info})}var S=class{_options;constructor(e){this._options=e}list(e){return l(this._options.client,{...e,limit:e.limit&&e.limit>0?e.limit:10})}getByName(e){return l(this._options.client,{where:{name:{_eq:e}},limit:1}).then(a=>a.length?a[0]??null:null)}create(e){return O(this._options.client,e)}};var g=class{_options;constructor(e){this._options=e}list(e){return E(this._options.client,{...e,limit:e.limit&&e.limit>0?e.limit:10})}get(e){if(!e)throw new Error("threadId is required");return T(this._options.client,e)}async start(e){let a=await V(this._options.client);return P(this._options.client,{...e,projectId:a.projectId,buildId:e.buildId||this._options.buildId,timezone:e.timezone||this._options.defaultTimezone})}getEvents(e,a){return m(this._options.client,e,a)}sendMessage(e){return R(this._options.client,{...e,timezone:e.timezone||this._options.defaultTimezone})}cancelAgentMessage(e){return U(this._options.client,e)}subscribeEvents(e,a){return w(this._options.client,e,a)}streamMessageEvents(e,a){return F(this._options.client,e,a)}};var W=class{constructor(e){let a=b(e.promptqlBaseUrl)||"https://promptql.ddn.hasura.app";if(!e.serviceAccountToken)throw new Error("serviceAccountToken must not be empty. If you haven't created any service account token yet, check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account");let _=a.endsWith("/v1/graphql")?a:`${a}/playground-v2-hge/v1/graphql`;this._fetchToken=I({promptqlGraphQLUrl:_,authHost:e.authHost,headers:ee(e.serviceAccountToken),fetch:e.fetch});let{client:r,wsClient:i}=j({getAuthToken:this._fetchToken,url:_,fetch:e.fetch,headers:e.headers});this._wsClient=i,this._options={client:r,buildId:e.buildId,defaultTimezone:e.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone},this.thread=new g(this._options),this.project=new M(this._options),this.room=new S(this._options)}_options;_wsClient;_fetchToken;thread;project;room;authenticated(){return this._fetchToken().then(()=>!0).catch(()=>!1)}close(){this._wsClient.dispose(),this._options.client.clearStore()}};function le(t,e){if(!e.length)return[];if(!t.length)return e;let a=t[t.length-1];if(!a)return e;let _=BigInt(a.thread_event_id),r=e.length-1;for(;r>=0;r--){let i=e[r];if(BigInt(i?.thread_event_id)<=_)break}return e.slice(r+1)}function be(t){return"UserMessage"in t?t.UserMessage:null}function me(t){return"UserCancel"in t?t.UserCancel:null}function Ie(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)||!("PlanGenerationStarted"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function Me(t){let e=x(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function Se(t){return"AgentMessage"in t?"content"in t.AgentMessage.update&&"interaction_update"in t.AgentMessage.update.content&&"main_agent"in t.AgentMessage.update.content.interaction_update&&"completed"in t.AgentMessage.update.content.interaction_update.main_agent?{success:!0,message:t.AgentMessage.update.content.interaction_update.main_agent.completed.summary,modified_artifacts:[],generated_at:t.AgentMessage.update.timestamp}:!("OrchestratorUpdate"in t.AgentMessage.update)||!("GeneratedResponse"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse.response:null}function ge(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("ProcessingStarted"in t.AgentMessage.update.MessageProcessingUpdate.update)?null:t.AgentMessage.update.MessageProcessingUpdate.update.ProcessingStarted}function Ae(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("AcceptInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.AcceptInteraction}function xe(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function A(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function he(t){let e=A(t);return!e||!("Started"in e)?null:e.Started}function fe(t){let e=A(t);return!e||!("Completed"in e)?null:e.Completed}function Ce(t){let e=A(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function Be(t){return!("AgentMessage"in t)||!("StartingOrchestrator"in t.AgentMessage.update)?null:t.AgentMessage.update.StartingOrchestrator}function x(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.OrchestratorUpdate.update}function y(t){let e=x(t);return!e||!("ContextExplorerUpdate"in e)?null:e.ContextExplorerUpdate.update}function ke(t){let e=y(t);return!e||!("Started"in e)?null:e.Started}function Oe(t){let e=y(t);return!e||!("Completed"in e)?null:e.Completed}function h(t){let e=y(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function ve(t){let e=h(t);return!e||!("Started"in e)?null:e.Started}function Ee(t){let e=h(t);return!e||!("Completed"in e)?null:e.Completed}function Te(t){let e=h(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function f(t){let e=y(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function Pe(t){let e=f(t);return!e||!("Started"in e)?null:e.Started}function Re(t){let e=f(t);return!e||!("Completed"in e)?null:e.Completed}function Ue(t){let e=f(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function d(t){let e=y(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function we(t){let e=d(t);return!e||!("Started"in e)?null:e.Started}function Fe(t){let e=d(t);return!e||!("Completed"in e)?null:e.Completed}function je(t){let e=d(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function Ve(t){let e=d(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function We(t){let e=d(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function Ne(t){let e=d(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function C(t){let e=x(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function ze(t){let e=C(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function qe(t){let e=C(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function De(t){let e=C(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function Ge(t){if(!("AgentMessage"in t))return null;if("InteractionFinished"in t.AgentMessage.update){let e=t.AgentMessage.update.InteractionFinished.update;return"Completed"in e?{status:"completed",timestamp:e.Completed.completed_at,warnings:e.Completed.warnings}:"Errored"in e?{status:"errored",timestamp:e.Errored.errored_at,reason:typeof e.Errored.error=="string"?e.Errored.error:e.Errored.error.User.message}:"UserCancelled"in e?{status:"user_cancelled",timestamp:e.UserCancelled.cancelled_at}:"AgentDeclined"in e?{status:"agent_declined",timestamp:e.AgentDeclined.declined_at,reason:e.AgentDeclined.reason}:"ServerCancelled"in e?{status:"server_cancelled",timestamp:e.ServerCancelled.cancelled_at}:{status:"unknown"}}if("content"in t.AgentMessage.update&&"interaction_finished"in t.AgentMessage.update.content){let e=t.AgentMessage.update.content.interaction_finished.outcome;return"errored"in e?{status:"errored",reason:e.errored.user_facing_message||e.errored.raw_error,timestamp:t.AgentMessage.update.timestamp,warnings:e.errored.raw_error?[{message:e.errored.raw_error}]:[]}:"server_cancelled"in e?{status:"server_cancelled",timestamp:t.AgentMessage.update.timestamp}:"user_cancelled"in e?{status:"user_cancelled",timestamp:t.AgentMessage.update.timestamp}:"completed"in e?{status:"completed",timestamp:t.AgentMessage.update.timestamp,warnings:e.completed.warnings}:{status:"unknown"}}return null}function Qe(t){if(t){if("UserMessage"in t)return t.UserMessage.message_id;if("AgentMessage"in t)return t.AgentMessage.message_id;if("UserTeach"in t)return t.UserTeach.agent_message_id;if("UserCancel"in t)return t.UserCancel.message_id}}0&&(module.exports={PromptQLSdk,ROOM_NAME_PATTERN,cancelAgentMessage,createApolloClient,createPromptQLAuthTokenGenerator,createRoom,diffThreadEvents,downloadArtifactData,getAgentGeneratedResponse,getAgentInteractionDecisionAcceptInteractionEvent,getAgentInteractionDecisionDeclineInteractionEvent,getAgentInteractionFinishedEvent,getAgentMessageProcessingStartedEvent,getAgentOrchestratorContextExplorerCompletedEvent,getAgentOrchestratorContextExplorerStartedEvent,getAgentOrchestratorContextExplorerUpdateEvent,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,getAgentOrchestratorSchemaExplorerCompletedEvent,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,getAgentOrchestratorSchemaExplorerSchemaExploredEvent,getAgentOrchestratorSchemaExplorerStartedEvent,getAgentOrchestratorSchemaExplorerUpdateEvent,getAgentOrchestratorSchemaTasksGeneratedEvent,getAgentOrchestratorSchemaTasksGenerationCompletedEvent,getAgentOrchestratorSchemaTasksGenerationStartedEvent,getAgentOrchestratorSchemaTasksGenerationUpdateEvent,getAgentOrchestratorStepProgrammerEvent,getAgentOrchestratorStepSavedProgramRunnerEvent,getAgentOrchestratorStepUiProgrammerEvent,getAgentOrchestratorStepUpdateEvent,getAgentOrchestratorUpdateEvent,getAgentOrchestratorWikiExplorerCompletedEvent,getAgentOrchestratorWikiExplorerStartedEvent,getAgentOrchestratorWikiExplorerUpdateEvent,getAgentOrchestratorWikiInfoGeneratedEvent,getAgentPlanGenerationStartedEvent,getAgentPlanStepGeneratedEvent,getAgentPlanningDecisionCompletedEvent,getAgentPlanningDecisionPlanningRequiredEvent,getAgentPlanningDecisionStartedEvent,getAgentPlanningDecisionUpdateEvent,getAgentStartingOrchestratorEvent,getThread,getThreadEventMessageId,getThreadEvents,getUserCancelEvent,getUserMessageEvent,isInteractionAnalyzing,listRooms,listThreads,sendThreadMessage,startThread,streamThreadMessageEvents,subscribeThreadEvents});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- async function ye(t,e,a,_,r){let i=`https://${t}/promptql-v2/artifacts/${e}/version/${a}/data`,n=await(typeof r=="function"?r:fetch)(i,{method:"GET",headers:_});if(n.status!==200){let d=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to download artifact: ${d}`)}return n.body?n.headers.get("Content-Type")?.startsWith("application/json")?n.json():n.text():null}var B={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelAgentMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"messageId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancel_agent_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"agentMessageId"},value:{kind:"Variable",name:{kind:"Name",value:"messageId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},k={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateRoom"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"name"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"visibility"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"description"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"create_room"},arguments:[{kind:"Argument",name:{kind:"Name",value:"name"},value:{kind:"Variable",name:{kind:"Name",value:"name"}}},{kind:"Argument",name:{kind:"Name",value:"visibility"},value:{kind:"Variable",name:{kind:"Name",value:"visibility"}}},{kind:"Argument",name:{kind:"Name",value:"description"},value:{kind:"Variable",name:{kind:"Name",value:"description"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"room_id"}}]}}]}}]},O={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"SendThreadMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"send_thread_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},v={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"StartThread"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"roomId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"visibility"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"start_thread"},arguments:[{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"buildId"},value:{kind:"Variable",name:{kind:"Name",value:"buildId"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"roomId"},value:{kind:"Variable",name:{kind:"Name",value:"roomId"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}},{kind:"Argument",name:{kind:"Name",value:"visibility"},value:{kind:"Variable",name:{kind:"Name",value:"visibility"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"thread_events"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"thread_event_id"}}]}}]}}]}}]},E={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetProjectInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"get_project_info"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"projectId"}},{kind:"Field",name:{kind:"Name",value:"projectName"}},{kind:"Field",name:{kind:"Name",value:"promptqlConsoleUrl"}}]}}]}}]},T={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetRooms"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"rooms_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"rooms_order_by"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}},defaultValue:{kind:"IntValue",value:"10"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"rooms"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Room"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Room"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"rooms"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"room_id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"description"}},{kind:"Field",name:{kind:"Name",value:"project_id"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"user_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]},P={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},R={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},U={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"ordering"}},type:{kind:"NamedType",name:{kind:"Name",value:"order_by"}},defaultValue:{kind:"EnumValue",value:"asc"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"Variable",name:{kind:"Name",value:"ordering"}}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]},w={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"subscription",name:{kind:"Name",value:"SubscribeThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]};var F=/([a-z0-9]+-?)*[a-z0-9]+/;function b(t,e){return t.query({query:T,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.rooms??[])}function j(t,e){if(!e.name)throw new Error("Room name is required");if(F.test(e.name))throw new Error("Room name must be URL-friendly, for example, sample-room-name");return t.mutate({mutation:k,variables:e,fetchPolicy:"no-cache"}).then(a=>{if(!a.data?.create_room?.room_id)throw new Error("expected room_id in response, got null");return a.data?.create_room?.room_id})}import{defer as Z,map as X,repeat as Y,takeWhile as ee}from"rxjs";function y(t){return t=t?t.trim():"",t?t[t.length-1]==="/"?t.slice(0,t.length-1):t:""}function I(t){if(t==null)return null;try{Number.parseInt(t)}catch{throw new Error("invalid threadEventId")}return t}function V(t,e){return t.query({query:P,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function W(t,e){if(!e)throw new Error("threadId is required");return t.query({query:R,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function N(t,e){if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:v,variables:e}).then(a=>{if(!a.data?.start_thread)throw new Error(a.error?.message||"Failed to start thread");return a.data.start_thread})}function M(t,e,a){if(!e)throw new Error("threadId is required");let _={thread_id:{_eq:e}};return a&&(a.eventId&&(_.thread_event_id=a.eventId),a.messageId&&(_._or=ae(a.messageId))),t.query({query:U,variables:{where:_,limit:a?.limit,ordering:a?.ordering||"asc"},fetchPolicy:"no-cache"}).then(r=>r.data?.thread_events??[])}function z(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:O,variables:e}).then(a=>{if(!a.data?.send_thread_message)throw new Error(a.error?.message||"Failed to send message to thread");return a.data.send_thread_message})}function q(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.messageId.trim())throw new Error("messageId is required");return t.mutate({mutation:B,variables:e}).then(a=>{if(!a.data?.cancel_agent_message)throw new Error(a.error?.message||"Failed to cancel thread");return a.data.cancel_agent_message})}function G(t,e,a){if(!e)throw new Error("threadId is required");I(a);let _={thread_id:{_eq:e}};return a&&(_.thread_event_id={_gte:a}),t.subscribe({query:w,variables:{where:_}}).pipe(X(r=>{if(r.error)throw r.error;return r.data?.thread_events??[]}))}function D(t,e,a){if(!e)throw new Error("threadId is required");let _,r=I(a?.fromEventId),i={eventId:a?.fromEventId?{_gte:r}:void 0,messageId:a?.messageId},o=a?.pollingInterval&&a?.pollingInterval>0?a.pollingInterval:5;return Z(async()=>{let n=_?{messageId:a?.messageId,eventId:{_gt:_}}:i,p=await M(t,e,n);return p.length>0&&(_=p[p.length-1]?.thread_event_id),p}).pipe(Y({count:a?.timeout&&a.timeout>0?Math.ceil(a.timeout/o):void 0,delay:o*1e3}),ee(n=>te(n,a?.skipAnalysis),!0))}function te(t,e){for(let a=t.length-1;a>0;a--){let _=t[a];if(e&&"UserCancel"in _.event_data)return!1;if(!("AgentMessage"in _.event_data))return!0;let r=_.event_data.AgentMessage.update;if("content"in r&&("interaction_finished"in r.content||e&&"interaction_update"in r.content&&"main_agent"in r.content.interaction_update&&"completed"in r.content.interaction_update.main_agent)||"InteractionFinished"in r||e&&"OrchestratorUpdate"in r&&"GeneratedResponse"in r.OrchestratorUpdate.update)return!1}return!0}function ae(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}function Q(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="failure"}function K(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="success"&&"token"in t}function J(t){return t!=null&&typeof t=="object"&&("data"in t&&!!t.data&&typeof t.data=="object"&&"enrich_token"in t.data&&!!t.data.enrich_token&&typeof t.data.enrich_token=="object"&&"userDirectoryJWT"in t.data.enrich_token||"errors"in t&&Array.isArray(t.errors))}function g(t){let a=`${y(t.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,_={token:"",expiry:new Date(0)},r=t.fetch||fetch,i=async()=>{let o=await r(a,{method:"POST",headers:t.headers});switch(o.status){case 200:{let n=await o.json();if(K(n))return n;throw new Error("malformed token response")}case 401:{let n=await o.json();throw Q(n)?new Error(n?.error||o.statusText):new Error(o.statusText)}default:{let n=await o.text();throw new Error(n)}}};return async()=>{if(_.expiry.getTime()<=Date.now()-1e3){let o=await i(),n=await re(t.promptqlGraphQLUrl,o.token,t.projectId,r);_.token=n;let p=new Date(o.expiry);if(Number.isNaN(p.getTime())){let d=new Date;d.setHours(1),_.expiry=d}else _.expiry=p}return _.token}}var re=async(t,e,a,_=fetch)=>{let r=await _(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:e,projectId:a},operationName:"EnrichToken"})});switch(r.status){case 200:{let i=await r.json();if(!J(i)||!i.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(i)}`);return i.data.enrich_token.userDirectoryJWT}default:{let i=await r.text();throw new Error(i)}}};function L(t){return{Authorization:`pat ${t}`}}import{ApolloClient as _e,ApolloLink as ne,HttpLink as ie,InMemoryCache as oe}from"@apollo/client";import{SetContextLink as pe}from"@apollo/client/link/context";import{GraphQLWsLink as ue}from"@apollo/client/link/subscriptions";import{OperationTypeNode as se}from"graphql";import{createClient as de}from"graphql-ws";var H=t=>{let e=new ie({uri:t.url,fetch:t.fetch,headers:t.headers}),a=async n=>{let p=await t.getAuthToken();return{headers:{...n,Authorization:`Bearer ${p}`}}},_=de({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),r=new ue(_),i=new pe(({headers:n})=>a(n)),o=ne.split(({operationType:n})=>n===se.SUBSCRIPTION,r,i.concat(e));return{client:new _e({link:o,cache:new oe}),wsClient:_}};var c=class{_options;constructor(e){this._options=e}info(){return S(this._options.client)}};function S(t){return t.query({query:E,fetchPolicy:"cache-first"}).then(e=>{if(!e.data?.get_project_info)throw new Error(e.error?.message||"Project not found");return e.data.get_project_info})}var l=class{_options;constructor(e){this._options=e}list(e){return b(this._options.client,{...e,limit:e.limit&&e.limit>0?e.limit:10})}getByName(e){return b(this._options.client,{where:{name:{_eq:e}},limit:1}).then(a=>a.length?a[0]??null:null)}create(e){return j(this._options.client,e)}};var m=class{_options;constructor(e){this._options=e}list(e){return V(this._options.client,{...e,limit:e.limit&&e.limit>0?e.limit:10})}get(e){if(!e)throw new Error("threadId is required");return W(this._options.client,e)}async start(e){let a=await S(this._options.client);return N(this._options.client,{...e,projectId:a.projectId,buildId:e.buildId||this._options.buildId,timezone:e.timezone||this._options.defaultTimezone})}getEvents(e,a){return M(this._options.client,e,a)}sendMessage(e){return z(this._options.client,{...e,timezone:e.timezone||this._options.defaultTimezone})}cancelAgentMessage(e){return q(this._options.client,e)}subscribeEvents(e,a){return G(this._options.client,e,a)}streamMessageEvents(e,a){return D(this._options.client,e,a)}};var $=class{constructor(e){let a=y(e.promptqlBaseUrl)||"https://promptql.ddn.hasura.app";if(!e.serviceAccountToken)throw new Error("serviceAccountToken must not be empty. If you haven't created any service account token yet, check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account");let _=a.endsWith("/v1/graphql")?a:`${a}/playground-v2-hge/v1/graphql`;this._fetchToken=g({promptqlGraphQLUrl:_,authHost:e.authHost,headers:L(e.serviceAccountToken),fetch:e.fetch});let{client:r,wsClient:i}=H({getAuthToken:this._fetchToken,url:_,fetch:e.fetch,headers:e.headers});this._wsClient=i,this._options={client:r,buildId:e.buildId,defaultTimezone:e.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone},this.thread=new m(this._options),this.project=new c(this._options),this.room=new l(this._options)}_options;_wsClient;_fetchToken;thread;project;room;authenticated(){return this._fetchToken().then(()=>!0).catch(()=>!1)}close(){this._wsClient.dispose(),this._options.client.clearStore()}};function dt(t,e){if(!e.length)return[];if(!t.length)return e;let a=t[t.length-1];if(!a)return e;let _=BigInt(a.thread_event_id),r=e.length-1;for(;r>=0;r--){let i=e[r];if(BigInt(i?.thread_event_id)<=_)break}return e.slice(r+1)}function yt(t){return"UserMessage"in t?t.UserMessage:null}function ct(t){return"UserCancel"in t?t.UserCancel:null}function lt(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)||!("PlanGenerationStarted"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function mt(t){let e=x(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function bt(t){return"AgentMessage"in t?"content"in t.AgentMessage.update&&"interaction_update"in t.AgentMessage.update.content&&"main_agent"in t.AgentMessage.update.content.interaction_update&&"completed"in t.AgentMessage.update.content.interaction_update.main_agent?{success:!0,message:t.AgentMessage.update.content.interaction_update.main_agent.completed.summary,modified_artifacts:[],generated_at:t.AgentMessage.update.timestamp}:!("OrchestratorUpdate"in t.AgentMessage.update)||!("GeneratedResponse"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse.response:null}function It(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("ProcessingStarted"in t.AgentMessage.update.MessageProcessingUpdate.update)?null:t.AgentMessage.update.MessageProcessingUpdate.update.ProcessingStarted}function Mt(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("AcceptInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.AcceptInteraction}function gt(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function A(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function St(t){let e=A(t);return!e||!("Started"in e)?null:e.Started}function At(t){let e=A(t);return!e||!("Completed"in e)?null:e.Completed}function xt(t){let e=A(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function ht(t){return!("AgentMessage"in t)||!("StartingOrchestrator"in t.AgentMessage.update)?null:t.AgentMessage.update.StartingOrchestrator}function x(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.OrchestratorUpdate.update}function s(t){let e=x(t);return!e||!("ContextExplorerUpdate"in e)?null:e.ContextExplorerUpdate.update}function ft(t){let e=s(t);return!e||!("Started"in e)?null:e.Started}function Ct(t){let e=s(t);return!e||!("Completed"in e)?null:e.Completed}function h(t){let e=s(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function Bt(t){let e=h(t);return!e||!("Started"in e)?null:e.Started}function kt(t){let e=h(t);return!e||!("Completed"in e)?null:e.Completed}function Ot(t){let e=h(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function f(t){let e=s(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function vt(t){let e=f(t);return!e||!("Started"in e)?null:e.Started}function Et(t){let e=f(t);return!e||!("Completed"in e)?null:e.Completed}function Tt(t){let e=f(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function u(t){let e=s(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function Pt(t){let e=u(t);return!e||!("Started"in e)?null:e.Started}function Rt(t){let e=u(t);return!e||!("Completed"in e)?null:e.Completed}function Ut(t){let e=u(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function wt(t){let e=u(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function Ft(t){let e=u(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function jt(t){let e=u(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function C(t){let e=x(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function Vt(t){let e=C(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function Wt(t){let e=C(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function Nt(t){let e=C(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function zt(t){if(!("AgentMessage"in t))return null;if("InteractionFinished"in t.AgentMessage.update){let e=t.AgentMessage.update.InteractionFinished.update;return"Completed"in e?{status:"completed",timestamp:e.Completed.completed_at,warnings:e.Completed.warnings}:"Errored"in e?{status:"errored",timestamp:e.Errored.errored_at,reason:typeof e.Errored.error=="string"?e.Errored.error:e.Errored.error.User.message}:"UserCancelled"in e?{status:"user_cancelled",timestamp:e.UserCancelled.cancelled_at}:"AgentDeclined"in e?{status:"agent_declined",timestamp:e.AgentDeclined.declined_at,reason:e.AgentDeclined.reason}:"ServerCancelled"in e?{status:"server_cancelled",timestamp:e.ServerCancelled.cancelled_at}:{status:"unknown"}}if("content"in t.AgentMessage.update&&"interaction_finished"in t.AgentMessage.update.content){let e=t.AgentMessage.update.content.interaction_finished.outcome;return"errored"in e?{status:"errored",reason:e.errored.user_facing_message||e.errored.raw_error,timestamp:t.AgentMessage.update.timestamp,warnings:e.errored.raw_error?[{message:e.errored.raw_error}]:[]}:"server_cancelled"in e?{status:"server_cancelled",timestamp:t.AgentMessage.update.timestamp}:"user_cancelled"in e?{status:"user_cancelled",timestamp:t.AgentMessage.update.timestamp}:"completed"in e?{status:"completed",timestamp:t.AgentMessage.update.timestamp,warnings:e.completed.warnings}:{status:"unknown"}}return null}function qt(t){if(t){if("UserMessage"in t)return t.UserMessage.message_id;if("AgentMessage"in t)return t.AgentMessage.message_id;if("UserTeach"in t)return t.UserTeach.agent_message_id;if("UserCancel"in t)return t.UserCancel.message_id}}export{$ as PromptQLSdk,F as ROOM_NAME_PATTERN,q as cancelAgentMessage,H as createApolloClient,g as createPromptQLAuthTokenGenerator,j as createRoom,dt as diffThreadEvents,ye as downloadArtifactData,bt as getAgentGeneratedResponse,Mt as getAgentInteractionDecisionAcceptInteractionEvent,gt as getAgentInteractionDecisionDeclineInteractionEvent,zt as getAgentInteractionFinishedEvent,It as getAgentMessageProcessingStartedEvent,Ct as getAgentOrchestratorContextExplorerCompletedEvent,ft as getAgentOrchestratorContextExplorerStartedEvent,s as getAgentOrchestratorContextExplorerUpdateEvent,Ut as getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,wt as getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,Rt as getAgentOrchestratorSchemaExplorerCompletedEvent,Ft as getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,jt as getAgentOrchestratorSchemaExplorerSchemaExploredEvent,Pt as getAgentOrchestratorSchemaExplorerStartedEvent,u as getAgentOrchestratorSchemaExplorerUpdateEvent,Tt as getAgentOrchestratorSchemaTasksGeneratedEvent,Et as getAgentOrchestratorSchemaTasksGenerationCompletedEvent,vt as getAgentOrchestratorSchemaTasksGenerationStartedEvent,f as getAgentOrchestratorSchemaTasksGenerationUpdateEvent,Vt as getAgentOrchestratorStepProgrammerEvent,Nt as getAgentOrchestratorStepSavedProgramRunnerEvent,Wt as getAgentOrchestratorStepUiProgrammerEvent,C as getAgentOrchestratorStepUpdateEvent,x as getAgentOrchestratorUpdateEvent,kt as getAgentOrchestratorWikiExplorerCompletedEvent,Bt as getAgentOrchestratorWikiExplorerStartedEvent,h as getAgentOrchestratorWikiExplorerUpdateEvent,Ot as getAgentOrchestratorWikiInfoGeneratedEvent,lt as getAgentPlanGenerationStartedEvent,mt as getAgentPlanStepGeneratedEvent,At as getAgentPlanningDecisionCompletedEvent,xt as getAgentPlanningDecisionPlanningRequiredEvent,St as getAgentPlanningDecisionStartedEvent,A as getAgentPlanningDecisionUpdateEvent,ht as getAgentStartingOrchestratorEvent,W as getThread,qt as getThreadEventMessageId,M as getThreadEvents,ct as getUserCancelEvent,yt as getUserMessageEvent,te as isInteractionAnalyzing,b as listRooms,V as listThreads,z as sendThreadMessage,N as startThread,D as streamThreadMessageEvents,G as subscribeThreadEvents};
1
+ async function ye(t,e,a,_,r){let i=`https://${t}/promptql-v2/artifacts/${e}/version/${a}/data`,n=await(typeof r=="function"?r:fetch)(i,{method:"GET",headers:_});if(n.status!==200){let d=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to download artifact: ${d}`)}return n.body?n.headers.get("Content-Type")?.startsWith("application/json")?n.json():n.text():null}var B={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CancelAgentMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"messageId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"cancel_agent_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"agentMessageId"},value:{kind:"Variable",name:{kind:"Name",value:"messageId"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},k={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateRoom"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"name"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"visibility"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"description"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"create_room"},arguments:[{kind:"Argument",name:{kind:"Name",value:"name"},value:{kind:"Variable",name:{kind:"Name",value:"name"}}},{kind:"Argument",name:{kind:"Name",value:"visibility"},value:{kind:"Variable",name:{kind:"Name",value:"visibility"}}},{kind:"Argument",name:{kind:"Name",value:"description"},value:{kind:"Variable",name:{kind:"Name",value:"description"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"room_id"}}]}}]}}]},O={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"SendThreadMessage"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"send_thread_message"},arguments:[{kind:"Argument",name:{kind:"Name",value:"threadId"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}}]}}]}}]},v={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"StartThread"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"message"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"projectId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"timezone"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"roomId"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"uploads"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"UserUploadInput"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"visibility"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"createdFrom"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"start_thread"},arguments:[{kind:"Argument",name:{kind:"Name",value:"message"},value:{kind:"Variable",name:{kind:"Name",value:"message"}}},{kind:"Argument",name:{kind:"Name",value:"projectId"},value:{kind:"Variable",name:{kind:"Name",value:"projectId"}}},{kind:"Argument",name:{kind:"Name",value:"timezone"},value:{kind:"Variable",name:{kind:"Name",value:"timezone"}}},{kind:"Argument",name:{kind:"Name",value:"buildId"},value:{kind:"Variable",name:{kind:"Name",value:"buildId"}}},{kind:"Argument",name:{kind:"Name",value:"buildFqdn"},value:{kind:"Variable",name:{kind:"Name",value:"buildFqdn"}}},{kind:"Argument",name:{kind:"Name",value:"roomId"},value:{kind:"Variable",name:{kind:"Name",value:"roomId"}}},{kind:"Argument",name:{kind:"Name",value:"uploads"},value:{kind:"Variable",name:{kind:"Name",value:"uploads"}}},{kind:"Argument",name:{kind:"Name",value:"visibility"},value:{kind:"Variable",name:{kind:"Name",value:"visibility"}}},{kind:"Argument",name:{kind:"Name",value:"createdFrom"},value:{kind:"Variable",name:{kind:"Name",value:"createdFrom"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"thread_events"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"thread_event_id"}}]}}]}}]}}]},E={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetProjectInfo"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"get_project_info"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"projectId"}},{kind:"Field",name:{kind:"Name",value:"projectName"}},{kind:"Field",name:{kind:"Name",value:"promptqlConsoleUrl"}}]}}]}}]},T={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetRooms"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"rooms_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"rooms_order_by"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}},defaultValue:{kind:"IntValue",value:"10"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"rooms"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Room"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Room"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"rooms"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"room_id"}},{kind:"Field",name:{kind:"Name",value:"name"}},{kind:"Field",name:{kind:"Name",value:"description"}},{kind:"Field",name:{kind:"Name",value:"project_id"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"user_id"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]},P={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},R={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},U={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"ordering"}},type:{kind:"NamedType",name:{kind:"Name",value:"order_by"}},defaultValue:{kind:"EnumValue",value:"asc"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"Variable",name:{kind:"Name",value:"ordering"}}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]},w={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"subscription",name:{kind:"Name",value:"SubscribeThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]};var F=/([a-z0-9]+-?)*[a-z0-9]+/;function m(t,e){return t.query({query:T,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.rooms??[])}function j(t,e){if(!e.name)throw new Error("Room name is required");if(!F.test(e.name))throw new Error("Room name must be URL-friendly, for example, sample-room-name");return t.mutate({mutation:k,variables:e,fetchPolicy:"no-cache"}).then(a=>{if(!a.data?.create_room?.room_id)throw new Error("expected room_id in response, got null");return a.data?.create_room?.room_id})}import{defer as Z,map as X,repeat as Y,takeWhile as ee}from"rxjs";function y(t){return t=t?t.trim():"",t?t[t.length-1]==="/"?t.slice(0,t.length-1):t:""}function I(t){if(t==null)return null;try{Number.parseInt(t)}catch{throw new Error("invalid threadEventId")}return t}function V(t,e){return t.query({query:P,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function W(t,e){if(!e)throw new Error("threadId is required");return t.query({query:R,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function N(t,e){if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:v,variables:e}).then(a=>{if(!a.data?.start_thread)throw new Error(a.error?.message||"Failed to start thread");return a.data.start_thread})}function M(t,e,a){if(!e)throw new Error("threadId is required");let _={thread_id:{_eq:e}};return a&&(a.eventId&&(_.thread_event_id=a.eventId),a.messageId&&(_._or=ae(a.messageId))),t.query({query:U,variables:{where:_,limit:a?.limit,ordering:a?.ordering||"asc"},fetchPolicy:"no-cache"}).then(r=>r.data?.thread_events??[])}function z(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:O,variables:e}).then(a=>{if(!a.data?.send_thread_message)throw new Error(a.error?.message||"Failed to send message to thread");return a.data.send_thread_message})}function q(t,e){if(!e.threadId)throw new Error("threadId is required");if(!e.messageId.trim())throw new Error("messageId is required");return t.mutate({mutation:B,variables:e}).then(a=>{if(!a.data?.cancel_agent_message)throw new Error(a.error?.message||"Failed to cancel thread");return a.data.cancel_agent_message})}function D(t,e,a){if(!e)throw new Error("threadId is required");I(a);let _={thread_id:{_eq:e}};return a&&(_.thread_event_id={_gte:a}),t.subscribe({query:w,variables:{where:_}}).pipe(X(r=>{if(r.error)throw r.error;return r.data?.thread_events??[]}))}function G(t,e,a){if(!e)throw new Error("threadId is required");let _,r=I(a?.fromEventId),i={eventId:a?.fromEventId?{_gte:r}:void 0,messageId:a?.messageId},o=a?.pollingInterval&&a?.pollingInterval>0?a.pollingInterval:5;return Z(async()=>{let n=_?{messageId:a?.messageId,eventId:{_gt:_}}:i,p=await M(t,e,n);return p.length>0&&(_=p[p.length-1]?.thread_event_id),p}).pipe(Y({count:a?.timeout&&a.timeout>0?Math.ceil(a.timeout/o):void 0,delay:o*1e3}),ee(n=>te(n,a?.skipAnalysis),!0))}function te(t,e){for(let a=t.length-1;a>0;a--){let _=t[a];if(e&&"UserCancel"in _.event_data)return!1;if(!("AgentMessage"in _.event_data))return!0;let r=_.event_data.AgentMessage.update;if("content"in r&&("interaction_finished"in r.content||e&&"interaction_update"in r.content&&"main_agent"in r.content.interaction_update&&"completed"in r.content.interaction_update.main_agent)||"InteractionFinished"in r||e&&"OrchestratorUpdate"in r&&"GeneratedResponse"in r.OrchestratorUpdate.update)return!1}return!0}function ae(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}function Q(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="failure"}function K(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="success"&&"token"in t}function J(t){return t!=null&&typeof t=="object"&&("data"in t&&!!t.data&&typeof t.data=="object"&&"enrich_token"in t.data&&!!t.data.enrich_token&&typeof t.data.enrich_token=="object"&&"userDirectoryJWT"in t.data.enrich_token||"errors"in t&&Array.isArray(t.errors))}function S(t){let a=`${y(t.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,_={token:"",expiry:new Date(0)},r=t.fetch||fetch,i=async()=>{let o=await r(a,{method:"POST",headers:t.headers});switch(o.status){case 200:{let n=await o.json();if(K(n))return n;throw new Error("malformed token response")}case 401:{let n=await o.json();throw Q(n)?new Error(n?.error||o.statusText):new Error(o.statusText)}default:{let n=await o.text();throw new Error(n)}}};return async()=>{if(_.expiry.getTime()<=Date.now()-1e3){let o=await i(),n=await re(t.promptqlGraphQLUrl,o.token,t.projectId,r);_.token=n;let p=new Date(o.expiry);if(Number.isNaN(p.getTime())){let d=new Date;d.setHours(1),_.expiry=d}else _.expiry=p}return _.token}}var re=async(t,e,a,_=fetch)=>{let r=await _(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:e,projectId:a},operationName:"EnrichToken"})});switch(r.status){case 200:{let i=await r.json();if(!J(i)||!i.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(i)}`);return i.data.enrich_token.userDirectoryJWT}default:{let i=await r.text();throw new Error(i)}}};function L(t){return{Authorization:`pat ${t}`}}import{ApolloClient as _e,ApolloLink as ne,HttpLink as ie,InMemoryCache as oe}from"@apollo/client";import{SetContextLink as pe}from"@apollo/client/link/context";import{GraphQLWsLink as ue}from"@apollo/client/link/subscriptions";import{OperationTypeNode as se}from"graphql";import{createClient as de}from"graphql-ws";var H=t=>{let e=new ie({uri:t.url,fetch:t.fetch,headers:t.headers}),a=async n=>{let p=await t.getAuthToken();return{headers:{...n,Authorization:`Bearer ${p}`}}},_=de({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),r=new ue(_),i=new pe(({headers:n})=>a(n)),o=ne.split(({operationType:n})=>n===se.SUBSCRIPTION,r,i.concat(e));return{client:new _e({link:o,cache:new oe}),wsClient:_}};var c=class{_options;constructor(e){this._options=e}info(){return g(this._options.client)}};function g(t){return t.query({query:E,fetchPolicy:"cache-first"}).then(e=>{if(!e.data?.get_project_info)throw new Error(e.error?.message||"Project not found");return e.data.get_project_info})}var l=class{_options;constructor(e){this._options=e}list(e){return m(this._options.client,{...e,limit:e.limit&&e.limit>0?e.limit:10})}getByName(e){return m(this._options.client,{where:{name:{_eq:e}},limit:1}).then(a=>a.length?a[0]??null:null)}create(e){return j(this._options.client,e)}};var b=class{_options;constructor(e){this._options=e}list(e){return V(this._options.client,{...e,limit:e.limit&&e.limit>0?e.limit:10})}get(e){if(!e)throw new Error("threadId is required");return W(this._options.client,e)}async start(e){let a=await g(this._options.client);return N(this._options.client,{...e,projectId:a.projectId,buildId:e.buildId||this._options.buildId,timezone:e.timezone||this._options.defaultTimezone})}getEvents(e,a){return M(this._options.client,e,a)}sendMessage(e){return z(this._options.client,{...e,timezone:e.timezone||this._options.defaultTimezone})}cancelAgentMessage(e){return q(this._options.client,e)}subscribeEvents(e,a){return D(this._options.client,e,a)}streamMessageEvents(e,a){return G(this._options.client,e,a)}};var $=class{constructor(e){let a=y(e.promptqlBaseUrl)||"https://promptql.ddn.hasura.app";if(!e.serviceAccountToken)throw new Error("serviceAccountToken must not be empty. If you haven't created any service account token yet, check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account");let _=a.endsWith("/v1/graphql")?a:`${a}/playground-v2-hge/v1/graphql`;this._fetchToken=S({promptqlGraphQLUrl:_,authHost:e.authHost,headers:L(e.serviceAccountToken),fetch:e.fetch});let{client:r,wsClient:i}=H({getAuthToken:this._fetchToken,url:_,fetch:e.fetch,headers:e.headers});this._wsClient=i,this._options={client:r,buildId:e.buildId,defaultTimezone:e.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone},this.thread=new b(this._options),this.project=new c(this._options),this.room=new l(this._options)}_options;_wsClient;_fetchToken;thread;project;room;authenticated(){return this._fetchToken().then(()=>!0).catch(()=>!1)}close(){this._wsClient.dispose(),this._options.client.clearStore()}};function dt(t,e){if(!e.length)return[];if(!t.length)return e;let a=t[t.length-1];if(!a)return e;let _=BigInt(a.thread_event_id),r=e.length-1;for(;r>=0;r--){let i=e[r];if(BigInt(i?.thread_event_id)<=_)break}return e.slice(r+1)}function yt(t){return"UserMessage"in t?t.UserMessage:null}function ct(t){return"UserCancel"in t?t.UserCancel:null}function lt(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)||!("PlanGenerationStarted"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function bt(t){let e=x(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function mt(t){return"AgentMessage"in t?"content"in t.AgentMessage.update&&"interaction_update"in t.AgentMessage.update.content&&"main_agent"in t.AgentMessage.update.content.interaction_update&&"completed"in t.AgentMessage.update.content.interaction_update.main_agent?{success:!0,message:t.AgentMessage.update.content.interaction_update.main_agent.completed.summary,modified_artifacts:[],generated_at:t.AgentMessage.update.timestamp}:!("OrchestratorUpdate"in t.AgentMessage.update)||!("GeneratedResponse"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse.response:null}function It(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("ProcessingStarted"in t.AgentMessage.update.MessageProcessingUpdate.update)?null:t.AgentMessage.update.MessageProcessingUpdate.update.ProcessingStarted}function Mt(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("AcceptInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.AcceptInteraction}function St(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function A(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function gt(t){let e=A(t);return!e||!("Started"in e)?null:e.Started}function At(t){let e=A(t);return!e||!("Completed"in e)?null:e.Completed}function xt(t){let e=A(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function ht(t){return!("AgentMessage"in t)||!("StartingOrchestrator"in t.AgentMessage.update)?null:t.AgentMessage.update.StartingOrchestrator}function x(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.OrchestratorUpdate.update}function s(t){let e=x(t);return!e||!("ContextExplorerUpdate"in e)?null:e.ContextExplorerUpdate.update}function ft(t){let e=s(t);return!e||!("Started"in e)?null:e.Started}function Ct(t){let e=s(t);return!e||!("Completed"in e)?null:e.Completed}function h(t){let e=s(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function Bt(t){let e=h(t);return!e||!("Started"in e)?null:e.Started}function kt(t){let e=h(t);return!e||!("Completed"in e)?null:e.Completed}function Ot(t){let e=h(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function f(t){let e=s(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function vt(t){let e=f(t);return!e||!("Started"in e)?null:e.Started}function Et(t){let e=f(t);return!e||!("Completed"in e)?null:e.Completed}function Tt(t){let e=f(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function u(t){let e=s(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function Pt(t){let e=u(t);return!e||!("Started"in e)?null:e.Started}function Rt(t){let e=u(t);return!e||!("Completed"in e)?null:e.Completed}function Ut(t){let e=u(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function wt(t){let e=u(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function Ft(t){let e=u(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function jt(t){let e=u(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function C(t){let e=x(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function Vt(t){let e=C(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function Wt(t){let e=C(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function Nt(t){let e=C(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function zt(t){if(!("AgentMessage"in t))return null;if("InteractionFinished"in t.AgentMessage.update){let e=t.AgentMessage.update.InteractionFinished.update;return"Completed"in e?{status:"completed",timestamp:e.Completed.completed_at,warnings:e.Completed.warnings}:"Errored"in e?{status:"errored",timestamp:e.Errored.errored_at,reason:typeof e.Errored.error=="string"?e.Errored.error:e.Errored.error.User.message}:"UserCancelled"in e?{status:"user_cancelled",timestamp:e.UserCancelled.cancelled_at}:"AgentDeclined"in e?{status:"agent_declined",timestamp:e.AgentDeclined.declined_at,reason:e.AgentDeclined.reason}:"ServerCancelled"in e?{status:"server_cancelled",timestamp:e.ServerCancelled.cancelled_at}:{status:"unknown"}}if("content"in t.AgentMessage.update&&"interaction_finished"in t.AgentMessage.update.content){let e=t.AgentMessage.update.content.interaction_finished.outcome;return"errored"in e?{status:"errored",reason:e.errored.user_facing_message||e.errored.raw_error,timestamp:t.AgentMessage.update.timestamp,warnings:e.errored.raw_error?[{message:e.errored.raw_error}]:[]}:"server_cancelled"in e?{status:"server_cancelled",timestamp:t.AgentMessage.update.timestamp}:"user_cancelled"in e?{status:"user_cancelled",timestamp:t.AgentMessage.update.timestamp}:"completed"in e?{status:"completed",timestamp:t.AgentMessage.update.timestamp,warnings:e.completed.warnings}:{status:"unknown"}}return null}function qt(t){if(t){if("UserMessage"in t)return t.UserMessage.message_id;if("AgentMessage"in t)return t.AgentMessage.message_id;if("UserTeach"in t)return t.UserTeach.agent_message_id;if("UserCancel"in t)return t.UserCancel.message_id}}export{$ as PromptQLSdk,F as ROOM_NAME_PATTERN,q as cancelAgentMessage,H as createApolloClient,S as createPromptQLAuthTokenGenerator,j as createRoom,dt as diffThreadEvents,ye as downloadArtifactData,mt as getAgentGeneratedResponse,Mt as getAgentInteractionDecisionAcceptInteractionEvent,St as getAgentInteractionDecisionDeclineInteractionEvent,zt as getAgentInteractionFinishedEvent,It as getAgentMessageProcessingStartedEvent,Ct as getAgentOrchestratorContextExplorerCompletedEvent,ft as getAgentOrchestratorContextExplorerStartedEvent,s as getAgentOrchestratorContextExplorerUpdateEvent,Ut as getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,wt as getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,Rt as getAgentOrchestratorSchemaExplorerCompletedEvent,Ft as getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,jt as getAgentOrchestratorSchemaExplorerSchemaExploredEvent,Pt as getAgentOrchestratorSchemaExplorerStartedEvent,u as getAgentOrchestratorSchemaExplorerUpdateEvent,Tt as getAgentOrchestratorSchemaTasksGeneratedEvent,Et as getAgentOrchestratorSchemaTasksGenerationCompletedEvent,vt as getAgentOrchestratorSchemaTasksGenerationStartedEvent,f as getAgentOrchestratorSchemaTasksGenerationUpdateEvent,Vt as getAgentOrchestratorStepProgrammerEvent,Nt as getAgentOrchestratorStepSavedProgramRunnerEvent,Wt as getAgentOrchestratorStepUiProgrammerEvent,C as getAgentOrchestratorStepUpdateEvent,x as getAgentOrchestratorUpdateEvent,kt as getAgentOrchestratorWikiExplorerCompletedEvent,Bt as getAgentOrchestratorWikiExplorerStartedEvent,h as getAgentOrchestratorWikiExplorerUpdateEvent,Ot as getAgentOrchestratorWikiInfoGeneratedEvent,lt as getAgentPlanGenerationStartedEvent,bt as getAgentPlanStepGeneratedEvent,At as getAgentPlanningDecisionCompletedEvent,xt as getAgentPlanningDecisionPlanningRequiredEvent,gt as getAgentPlanningDecisionStartedEvent,A as getAgentPlanningDecisionUpdateEvent,ht as getAgentStartingOrchestratorEvent,W as getThread,qt as getThreadEventMessageId,M as getThreadEvents,ct as getUserCancelEvent,yt as getUserMessageEvent,te as isInteractionAnalyzing,m as listRooms,V as listThreads,z as sendThreadMessage,N as startThread,G as streamThreadMessageEvents,D as subscribeThreadEvents};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hasura/promptql",
3
3
  "description": "A Typescript SDK allows you to interact with PromptQL API",
4
- "version": "2.0.0-alpha.21",
4
+ "version": "2.0.0-alpha.23",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Hasura",
7
7
  "homepage": "https://promptql.hasura.io",