@hasura/promptql 2.0.0-alpha.24 → 2.0.0-alpha.25

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/biome.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$schema": "https://biomejs.dev/schemas/2.4.5/schema.json",
2
+ "$schema": "https://biomejs.dev/schemas/2.4.6/schema.json",
3
3
  "root": false,
4
4
  "files": {
5
5
  "includes": [
package/dist/index.d.mts CHANGED
@@ -135,18 +135,32 @@ type WikiSelectionUpdate = {
135
135
  started: {};
136
136
  } | {
137
137
  wiki_pages_selected: {
138
- /**
139
- * Titles of wiki pages that were found to be relevant
140
- */
141
- wiki_page_titles: string[];
138
+ wiki_page_titles?: string[] | null;
139
+ target_pages?: TargetWikiPage[] | null;
142
140
  /**
143
141
  * LLM usage during wiki selection
144
142
  */
145
143
  llm_usage?: LlmUsage[];
144
+ /**
145
+ * Which user message this wiki selection is for. `None` for legacy
146
+ * threads or for the current trigger's selection. `Some(id)` for
147
+ * retroactive wiki selection of a past user message.
148
+ */
149
+ user_message_id?: string | null;
146
150
  };
147
151
  } | {
148
152
  completed: {};
149
153
  };
154
+ type TargetWikiPage = {
155
+ RegularPage: {
156
+ title: string;
157
+ };
158
+ } | {
159
+ FederatedPage: {
160
+ federated_wiki_name: string;
161
+ page_title: string;
162
+ };
163
+ };
150
164
  type AgentLoopUpdate = {
151
165
  started: {};
152
166
  } | {
@@ -199,6 +213,27 @@ type AgentLoopUpdate = {
199
213
  completed: {
200
214
  summary: string;
201
215
  };
216
+ } | {
217
+ thread_summarized: {
218
+ summary_text: string;
219
+ /**
220
+ * The trigger of the first conversation NOT covered by this summary.
221
+ */
222
+ next_unsummarized_trigger: {
223
+ user_message: {
224
+ /**
225
+ * A unique index for a user message in a thread
226
+ */
227
+ message_id: string;
228
+ };
229
+ } | {
230
+ scheduled_agent_trigger_event: {
231
+ scheduled_agent_trigger_event_id: ScheduledAgentTriggerEventId;
232
+ };
233
+ };
234
+ usage: LlmUsage;
235
+ thinking_text?: string | null;
236
+ };
202
237
  };
203
238
  /**
204
239
  * Actions the agent can perform.
@@ -258,6 +293,7 @@ type AgentLoopAction = {
258
293
  } | {
259
294
  read_wiki_page: {
260
295
  page_title: string;
296
+ federated_wiki_name?: FederatedWikiName | null;
261
297
  };
262
298
  } | {
263
299
  search_wiki_pages: {
@@ -277,6 +313,10 @@ type AgentLoopAction = {
277
313
  delete_scheduled_trigger: {
278
314
  trigger_id: ScheduledAgentTriggerId;
279
315
  };
316
+ } | {
317
+ preview_artifact: {
318
+ artifact_identifier: string;
319
+ };
280
320
  };
281
321
  /**
282
322
  * Program Package Name is the unique name for a program within a project that usable from code
@@ -286,7 +326,11 @@ type ProgramPackageName = string;
286
326
  /**
287
327
  * Skill type identifier for the new skill-based architecture.
288
328
  */
289
- type SkillType = "python_programming" | "react_programming" | "knowledge_exploration" | "saved_programs" | "response_generation";
329
+ type SkillType = "python_programming" | "react_programming" | "knowledge_exploration" | "saved_programs" | "response_generation" | "shelf_pipeline_programming";
330
+ /**
331
+ * The name of a federated wiki
332
+ */
333
+ type FederatedWikiName = string;
290
334
  type ScheduledAgentTriggerType = {
291
335
  one_time: {
292
336
  scheduled_for: string;
@@ -330,7 +374,7 @@ type AgentLoopActionUpdate = {
330
374
  };
331
375
  };
332
376
  type ArtifactType = "text" | "table" | "visualization" | "html" | "file";
333
- type ArtifactPreview = {
377
+ type ArtifactDataPreview = {
334
378
  Table: {
335
379
  total_row_count: number;
336
380
  preview_rows: {
@@ -411,6 +455,7 @@ type AgentLoopActionResult = {
411
455
  } | {
412
456
  page_title: string;
413
457
  page: WikiPageV1;
458
+ federated_wiki_name?: FederatedWikiName | null;
414
459
  agent_loop_action_result_type: "wiki_page_read";
415
460
  } | {
416
461
  page_titles: string[];
@@ -431,6 +476,10 @@ type AgentLoopActionResult = {
431
476
  } | {
432
477
  trigger_id: ScheduledAgentTriggerId;
433
478
  agent_loop_action_result_type: "scheduled_trigger_deleted";
479
+ } | {
480
+ artifact_reference: ArtifactReference1;
481
+ artifact_identifier: string;
482
+ agent_loop_action_result_type: "artifact_previewed";
434
483
  };
435
484
  /**
436
485
  * The title of a wiki page or section
@@ -2282,7 +2331,7 @@ interface ArtifactUpdate {
2282
2331
  identifier: string;
2283
2332
  title: string;
2284
2333
  artifact_type: ArtifactType;
2285
- data?: ArtifactPreview | null;
2334
+ data?: ArtifactDataPreview | null;
2286
2335
  artifact_reference: ArtifactReference1;
2287
2336
  }
2288
2337
  interface ArtifactReference1 {
@@ -2619,7 +2668,7 @@ interface ArtifactUpdate1 {
2619
2668
  identifier: string;
2620
2669
  title: string;
2621
2670
  artifact_type: ArtifactType;
2622
- data?: ArtifactPreview | null;
2671
+ data?: ArtifactDataPreview | null;
2623
2672
  artifact_reference: ArtifactReference1;
2624
2673
  }
2625
2674
  /**
@@ -3492,7 +3541,12 @@ interface ConfidenceAnalysis1 {
3492
3541
  artifact_assumptions: CheckedTopic[];
3493
3542
  }
3494
3543
  interface ThreadParticipants {
3495
- user_ids: PromptQlUserId[];
3544
+ user_profiles: UserInfo[];
3545
+ }
3546
+ interface UserInfo {
3547
+ user_id: PromptQlUserId;
3548
+ display_name: string;
3549
+ email: string;
3496
3550
  }
3497
3551
  /**
3498
3552
  * Metadata about an uploaded artifact, fetched before agent starts
@@ -5344,6 +5398,10 @@ type GetThreadsQueryVariables = Exact<{
5344
5398
  }>;
5345
5399
 
5346
5400
  declare const USER_AGENT = "PromptQL TypeScript SDK";
5401
+ /**
5402
+ * Regular expression for validating room name.
5403
+ */
5404
+ declare const ROOM_NAME_PATTERN: RegExp;
5347
5405
  /**
5348
5406
  * Options to initialize a PromptQL SDK client.
5349
5407
  */
@@ -5353,9 +5411,9 @@ type PromptQLSdkOptions = {
5353
5411
  */
5354
5412
  authHost?: string;
5355
5413
  /**
5356
- * Base URL of the Hasura control plane.
5414
+ * Host of the Hasura control plane.
5357
5415
  */
5358
- controlPlaneUrl?: string;
5416
+ controlPlaneHost?: string;
5359
5417
  /**
5360
5418
  * Service account token of the PromptQL project.
5361
5419
  * Check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account to know how to create a token.
@@ -5527,10 +5585,6 @@ type RoomVisibilityType = "public" | "private";
5527
5585
  type CreateRoomArguments = Omit<CreateRoomMutationVariables, "visibility"> & {
5528
5586
  visibility: RoomVisibilityType;
5529
5587
  };
5530
- /**
5531
- * Regular expression for validating room name.
5532
- */
5533
- declare const ROOM_NAME_PATTERN: RegExp;
5534
5588
  /**
5535
5589
  * Metadata response of an artifact.
5536
5590
  */
@@ -5677,7 +5731,7 @@ declare class Artifact {
5677
5731
  /**
5678
5732
  * Get artifact metadata.
5679
5733
  */
5680
- getMetadata(artifactId: string, version: number): Promise<unknown>;
5734
+ getMetadata(artifactId: string, version: number): Promise<ArtifactMetadata>;
5681
5735
  }
5682
5736
 
5683
5737
  /**
@@ -5808,10 +5862,16 @@ declare function getAgentPlanGenerationStartedEvent(eventData: ThreadEvent$1): P
5808
5862
  * Validate and return the PlanStepGenerated event that generates a query plan item.
5809
5863
  */
5810
5864
  declare function getAgentPlanStepGeneratedEvent(eventData: ThreadEvent$1): PlanStepGenerated | null;
5865
+ /**
5866
+ * The agent generated response with an extra messageId field.
5867
+ */
5868
+ type AgentGeneratedResponse = ComponentResponse5 & {
5869
+ messageId: string;
5870
+ };
5811
5871
  /**
5812
5872
  * Validate and return the GeneratedResponse from AgentMessage.
5813
5873
  */
5814
- declare function getAgentGeneratedResponse(eventData: ThreadEvent$1): ComponentResponse5 | null;
5874
+ declare function getAgentGeneratedResponse(eventData: ThreadEvent$1): AgentGeneratedResponse | null;
5815
5875
  /**
5816
5876
  * Validate and return the ProcessingStarted event from AgentMessage.
5817
5877
  */
@@ -5963,4 +6023,4 @@ declare function getThreadEventMessageId(event: ThreadEvent$1 | undefined): stri
5963
6023
  */
5964
6024
  declare function buildPromptQLUrl(fqdn: string): string;
5965
6025
 
5966
- 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 ArtifactMetadata, 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, type ProjectInfoOutput, 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, USER_AGENT, 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, buildPromptQLUrl, 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, getArtifactMetadata, getThread, getThreadEventMessageId, getThreadEvents, getUserCancelEvent, getUserMessageEvent, isInteractionAnalyzing, listArtifactMetadataByThreadId, listRooms, listThreads, sendThreadMessage, startThread, streamThreadMessageEvents, subscribeThreadEvents };
6026
+ export { type AgentGeneratedResponse, 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 ArtifactDataPreview, type ArtifactError, type ArtifactErrorV1, type ArtifactId, type ArtifactMetadata, 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 FederatedWikiName, 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, type ProjectInfoOutput, 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 TargetWikiPage, 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, USER_AGENT, type UiBuild, type UiBuild2, type UiBuildFailure, type UiBuildResult, type UiBuildRunStepDetails, type UiBuildStep, type UiMetadata, type UiProgrammerState, type UiProgrammerUpdate, type UserCancel, type UserCancelEvent, type UserInfo, 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, buildPromptQLUrl, 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, getArtifactMetadata, getThread, getThreadEventMessageId, getThreadEvents, getUserCancelEvent, getUserMessageEvent, isInteractionAnalyzing, listArtifactMetadataByThreadId, listRooms, listThreads, sendThreadMessage, startThread, streamThreadMessageEvents, subscribeThreadEvents };
package/dist/index.d.ts CHANGED
@@ -135,18 +135,32 @@ type WikiSelectionUpdate = {
135
135
  started: {};
136
136
  } | {
137
137
  wiki_pages_selected: {
138
- /**
139
- * Titles of wiki pages that were found to be relevant
140
- */
141
- wiki_page_titles: string[];
138
+ wiki_page_titles?: string[] | null;
139
+ target_pages?: TargetWikiPage[] | null;
142
140
  /**
143
141
  * LLM usage during wiki selection
144
142
  */
145
143
  llm_usage?: LlmUsage[];
144
+ /**
145
+ * Which user message this wiki selection is for. `None` for legacy
146
+ * threads or for the current trigger's selection. `Some(id)` for
147
+ * retroactive wiki selection of a past user message.
148
+ */
149
+ user_message_id?: string | null;
146
150
  };
147
151
  } | {
148
152
  completed: {};
149
153
  };
154
+ type TargetWikiPage = {
155
+ RegularPage: {
156
+ title: string;
157
+ };
158
+ } | {
159
+ FederatedPage: {
160
+ federated_wiki_name: string;
161
+ page_title: string;
162
+ };
163
+ };
150
164
  type AgentLoopUpdate = {
151
165
  started: {};
152
166
  } | {
@@ -199,6 +213,27 @@ type AgentLoopUpdate = {
199
213
  completed: {
200
214
  summary: string;
201
215
  };
216
+ } | {
217
+ thread_summarized: {
218
+ summary_text: string;
219
+ /**
220
+ * The trigger of the first conversation NOT covered by this summary.
221
+ */
222
+ next_unsummarized_trigger: {
223
+ user_message: {
224
+ /**
225
+ * A unique index for a user message in a thread
226
+ */
227
+ message_id: string;
228
+ };
229
+ } | {
230
+ scheduled_agent_trigger_event: {
231
+ scheduled_agent_trigger_event_id: ScheduledAgentTriggerEventId;
232
+ };
233
+ };
234
+ usage: LlmUsage;
235
+ thinking_text?: string | null;
236
+ };
202
237
  };
203
238
  /**
204
239
  * Actions the agent can perform.
@@ -258,6 +293,7 @@ type AgentLoopAction = {
258
293
  } | {
259
294
  read_wiki_page: {
260
295
  page_title: string;
296
+ federated_wiki_name?: FederatedWikiName | null;
261
297
  };
262
298
  } | {
263
299
  search_wiki_pages: {
@@ -277,6 +313,10 @@ type AgentLoopAction = {
277
313
  delete_scheduled_trigger: {
278
314
  trigger_id: ScheduledAgentTriggerId;
279
315
  };
316
+ } | {
317
+ preview_artifact: {
318
+ artifact_identifier: string;
319
+ };
280
320
  };
281
321
  /**
282
322
  * Program Package Name is the unique name for a program within a project that usable from code
@@ -286,7 +326,11 @@ type ProgramPackageName = string;
286
326
  /**
287
327
  * Skill type identifier for the new skill-based architecture.
288
328
  */
289
- type SkillType = "python_programming" | "react_programming" | "knowledge_exploration" | "saved_programs" | "response_generation";
329
+ type SkillType = "python_programming" | "react_programming" | "knowledge_exploration" | "saved_programs" | "response_generation" | "shelf_pipeline_programming";
330
+ /**
331
+ * The name of a federated wiki
332
+ */
333
+ type FederatedWikiName = string;
290
334
  type ScheduledAgentTriggerType = {
291
335
  one_time: {
292
336
  scheduled_for: string;
@@ -330,7 +374,7 @@ type AgentLoopActionUpdate = {
330
374
  };
331
375
  };
332
376
  type ArtifactType = "text" | "table" | "visualization" | "html" | "file";
333
- type ArtifactPreview = {
377
+ type ArtifactDataPreview = {
334
378
  Table: {
335
379
  total_row_count: number;
336
380
  preview_rows: {
@@ -411,6 +455,7 @@ type AgentLoopActionResult = {
411
455
  } | {
412
456
  page_title: string;
413
457
  page: WikiPageV1;
458
+ federated_wiki_name?: FederatedWikiName | null;
414
459
  agent_loop_action_result_type: "wiki_page_read";
415
460
  } | {
416
461
  page_titles: string[];
@@ -431,6 +476,10 @@ type AgentLoopActionResult = {
431
476
  } | {
432
477
  trigger_id: ScheduledAgentTriggerId;
433
478
  agent_loop_action_result_type: "scheduled_trigger_deleted";
479
+ } | {
480
+ artifact_reference: ArtifactReference1;
481
+ artifact_identifier: string;
482
+ agent_loop_action_result_type: "artifact_previewed";
434
483
  };
435
484
  /**
436
485
  * The title of a wiki page or section
@@ -2282,7 +2331,7 @@ interface ArtifactUpdate {
2282
2331
  identifier: string;
2283
2332
  title: string;
2284
2333
  artifact_type: ArtifactType;
2285
- data?: ArtifactPreview | null;
2334
+ data?: ArtifactDataPreview | null;
2286
2335
  artifact_reference: ArtifactReference1;
2287
2336
  }
2288
2337
  interface ArtifactReference1 {
@@ -2619,7 +2668,7 @@ interface ArtifactUpdate1 {
2619
2668
  identifier: string;
2620
2669
  title: string;
2621
2670
  artifact_type: ArtifactType;
2622
- data?: ArtifactPreview | null;
2671
+ data?: ArtifactDataPreview | null;
2623
2672
  artifact_reference: ArtifactReference1;
2624
2673
  }
2625
2674
  /**
@@ -3492,7 +3541,12 @@ interface ConfidenceAnalysis1 {
3492
3541
  artifact_assumptions: CheckedTopic[];
3493
3542
  }
3494
3543
  interface ThreadParticipants {
3495
- user_ids: PromptQlUserId[];
3544
+ user_profiles: UserInfo[];
3545
+ }
3546
+ interface UserInfo {
3547
+ user_id: PromptQlUserId;
3548
+ display_name: string;
3549
+ email: string;
3496
3550
  }
3497
3551
  /**
3498
3552
  * Metadata about an uploaded artifact, fetched before agent starts
@@ -5344,6 +5398,10 @@ type GetThreadsQueryVariables = Exact<{
5344
5398
  }>;
5345
5399
 
5346
5400
  declare const USER_AGENT = "PromptQL TypeScript SDK";
5401
+ /**
5402
+ * Regular expression for validating room name.
5403
+ */
5404
+ declare const ROOM_NAME_PATTERN: RegExp;
5347
5405
  /**
5348
5406
  * Options to initialize a PromptQL SDK client.
5349
5407
  */
@@ -5353,9 +5411,9 @@ type PromptQLSdkOptions = {
5353
5411
  */
5354
5412
  authHost?: string;
5355
5413
  /**
5356
- * Base URL of the Hasura control plane.
5414
+ * Host of the Hasura control plane.
5357
5415
  */
5358
- controlPlaneUrl?: string;
5416
+ controlPlaneHost?: string;
5359
5417
  /**
5360
5418
  * Service account token of the PromptQL project.
5361
5419
  * Check out Hasura docs https://hasura.io/docs/3.0/project-configuration/project-management/service-accounts/#how-to-create-service-account to know how to create a token.
@@ -5527,10 +5585,6 @@ type RoomVisibilityType = "public" | "private";
5527
5585
  type CreateRoomArguments = Omit<CreateRoomMutationVariables, "visibility"> & {
5528
5586
  visibility: RoomVisibilityType;
5529
5587
  };
5530
- /**
5531
- * Regular expression for validating room name.
5532
- */
5533
- declare const ROOM_NAME_PATTERN: RegExp;
5534
5588
  /**
5535
5589
  * Metadata response of an artifact.
5536
5590
  */
@@ -5677,7 +5731,7 @@ declare class Artifact {
5677
5731
  /**
5678
5732
  * Get artifact metadata.
5679
5733
  */
5680
- getMetadata(artifactId: string, version: number): Promise<unknown>;
5734
+ getMetadata(artifactId: string, version: number): Promise<ArtifactMetadata>;
5681
5735
  }
5682
5736
 
5683
5737
  /**
@@ -5808,10 +5862,16 @@ declare function getAgentPlanGenerationStartedEvent(eventData: ThreadEvent$1): P
5808
5862
  * Validate and return the PlanStepGenerated event that generates a query plan item.
5809
5863
  */
5810
5864
  declare function getAgentPlanStepGeneratedEvent(eventData: ThreadEvent$1): PlanStepGenerated | null;
5865
+ /**
5866
+ * The agent generated response with an extra messageId field.
5867
+ */
5868
+ type AgentGeneratedResponse = ComponentResponse5 & {
5869
+ messageId: string;
5870
+ };
5811
5871
  /**
5812
5872
  * Validate and return the GeneratedResponse from AgentMessage.
5813
5873
  */
5814
- declare function getAgentGeneratedResponse(eventData: ThreadEvent$1): ComponentResponse5 | null;
5874
+ declare function getAgentGeneratedResponse(eventData: ThreadEvent$1): AgentGeneratedResponse | null;
5815
5875
  /**
5816
5876
  * Validate and return the ProcessingStarted event from AgentMessage.
5817
5877
  */
@@ -5963,4 +6023,4 @@ declare function getThreadEventMessageId(event: ThreadEvent$1 | undefined): stri
5963
6023
  */
5964
6024
  declare function buildPromptQLUrl(fqdn: string): string;
5965
6025
 
5966
- 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 ArtifactMetadata, 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, type ProjectInfoOutput, 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, USER_AGENT, 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, buildPromptQLUrl, 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, getArtifactMetadata, getThread, getThreadEventMessageId, getThreadEvents, getUserCancelEvent, getUserMessageEvent, isInteractionAnalyzing, listArtifactMetadataByThreadId, listRooms, listThreads, sendThreadMessage, startThread, streamThreadMessageEvents, subscribeThreadEvents };
6026
+ export { type AgentGeneratedResponse, 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 ArtifactDataPreview, type ArtifactError, type ArtifactErrorV1, type ArtifactId, type ArtifactMetadata, 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 FederatedWikiName, 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, type ProjectInfoOutput, 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 TargetWikiPage, 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, USER_AGENT, type UiBuild, type UiBuild2, type UiBuildFailure, type UiBuildResult, type UiBuildRunStepDetails, type UiBuildStep, type UiMetadata, type UiProgrammerState, type UiProgrammerUpdate, type UserCancel, type UserCancelEvent, type UserInfo, 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, buildPromptQLUrl, 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, getArtifactMetadata, getThread, getThreadEventMessageId, getThreadEvents, getUserCancelEvent, getUserMessageEvent, isInteractionAnalyzing, listArtifactMetadataByThreadId, listRooms, listThreads, sendThreadMessage, startThread, streamThreadMessageEvents, subscribeThreadEvents };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var me=Object.prototype.hasOwnProperty;var be=(t,e)=>{for(var a in e)v(t,a,{get:e[a],enumerable:!0})},Ie=(t,e,a,_)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of le(e))!me.call(t,r)&&r!==a&&v(t,r,{get:()=>e[r],enumerable:!(_=ce(e,r))||_.enumerable});return t};var Me=t=>Ie(v({},"__esModule",{value:!0}),t);var Ye={};be(Ye,{PromptQLSdk:()=>L,ROOM_NAME_PATTERN:()=>R,USER_AGENT:()=>d,buildPromptQLUrl:()=>Q,cancelAgentMessage:()=>N,createApolloClient:()=>G,createPromptQLAuthTokenGenerator:()=>M,createRoom:()=>U,diffThreadEvents:()=>Ae,downloadArtifactData:()=>E,getAgentGeneratedResponse:()=>Be,getAgentInteractionDecisionAcceptInteractionEvent:()=>Oe,getAgentInteractionDecisionDeclineInteractionEvent:()=>ve,getAgentInteractionFinishedEvent:()=>Ze,getAgentMessageProcessingStartedEvent:()=>ke,getAgentOrchestratorContextExplorerCompletedEvent:()=>we,getAgentOrchestratorContextExplorerStartedEvent:()=>Ue,getAgentOrchestratorContextExplorerUpdateEvent:()=>c,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent:()=>Ge,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent:()=>Qe,getAgentOrchestratorSchemaExplorerCompletedEvent:()=>De,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent:()=>Le,getAgentOrchestratorSchemaExplorerSchemaExploredEvent:()=>Ke,getAgentOrchestratorSchemaExplorerStartedEvent:()=>qe,getAgentOrchestratorSchemaExplorerUpdateEvent:()=>y,getAgentOrchestratorSchemaTasksGeneratedEvent:()=>ze,getAgentOrchestratorSchemaTasksGenerationCompletedEvent:()=>Ne,getAgentOrchestratorSchemaTasksGenerationStartedEvent:()=>We,getAgentOrchestratorSchemaTasksGenerationUpdateEvent:()=>h,getAgentOrchestratorStepProgrammerEvent:()=>Je,getAgentOrchestratorStepSavedProgramRunnerEvent:()=>$e,getAgentOrchestratorStepUiProgrammerEvent:()=>He,getAgentOrchestratorStepUpdateEvent:()=>x,getAgentOrchestratorUpdateEvent:()=>S,getAgentOrchestratorWikiExplorerCompletedEvent:()=>je,getAgentOrchestratorWikiExplorerStartedEvent:()=>Fe,getAgentOrchestratorWikiExplorerUpdateEvent:()=>A,getAgentOrchestratorWikiInfoGeneratedEvent:()=>Ve,getAgentPlanGenerationStartedEvent:()=>fe,getAgentPlanStepGeneratedEvent:()=>Ce,getAgentPlanningDecisionCompletedEvent:()=>Te,getAgentPlanningDecisionPlanningRequiredEvent:()=>Pe,getAgentPlanningDecisionStartedEvent:()=>Ee,getAgentPlanningDecisionUpdateEvent:()=>g,getAgentStartingOrchestratorEvent:()=>Re,getArtifactMetadata:()=>P,getThread:()=>j,getThreadEventMessageId:()=>Xe,getThreadEvents:()=>I,getUserCancelEvent:()=>xe,getUserMessageEvent:()=>he,isInteractionAnalyzing:()=>_e,listArtifactMetadataByThreadId:()=>T,listRooms:()=>b,listThreads:()=>F,sendThreadMessage:()=>W,startThread:()=>V,streamThreadMessageEvents:()=>q,subscribeThreadEvents:()=>z});module.exports=Me(Ye);var K={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"}}]}}]}}]},J={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"}}]}}]}}]},H={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"}}]}}]}}]},$={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"}}]}}]}}]}}]},Z={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetArtifactsByThreadId"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"artifacts"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_artifacts"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_id"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"_eq"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}}]}}]}}]}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"updated_at"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"artifact_id"}},{kind:"Field",name:{kind:"Name",value:"latest_version_object"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"description"}},{kind:"Field",name:{kind:"Name",value:"user_id"}},{kind:"Field",name:{kind:"Name",value:"artifact_metadata"}},{kind:"Field",name:{kind:"Name",value:"artifact_type"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"size"}},{kind:"Field",name:{kind:"Name",value:"version"}}]}}]}}]}}]},X={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"}}]}}]},Y={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"}}]}}]}}]},ee={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"}}]}}]}}]},te={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"}}]}}]},ae={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"}}]}}]};async function E(t,e,a,_,r){let o=`${t}/promptql-v2/artifacts/${e}/version/${a}/data`,n=await(typeof r=="function"?r:fetch)(o,{method:"GET",headers:_});if(n.status!==200){let m=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to download artifact: ${m}`)}return n.body?n.headers.get("Content-Type")?.startsWith("application/json")?n.json():n.text():null}async function T(t,e,a){let _=await t.query({query:Z,variables:{threadId:a},fetchPolicy:"no-cache"});return _.data?.artifacts?.length?_.data.artifacts.filter(r=>r.latest_version_object).map(r=>({project_id:e,artifact_id:r.artifact_id,artifact_type:r.latest_version_object.artifact_type,version:r.latest_version_object.version,title:r.latest_version_object.title,description:r.latest_version_object.description??null,user_id:r.latest_version_object.user_id,metadata:r.latest_version_object.artifact_metadata,created_at:r.latest_version_object.created_at,size_bytes:Number.parseInt(r.latest_version_object.size)})):[]}async function P(t,e,a,_,r){let o=`${t}/promptql-v2/artifacts/${e}/version/${a}/metadata`,n=await(typeof r=="function"?r:fetch)(o,{method:"GET",headers:_});if(n.status!==200){let p=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to get artifact metadata: ${p}`)}return n.json()}var d="PromptQL TypeScript SDK",R=/([a-z0-9]+-?)*[a-z0-9]+/;function b(t,e){return t.query({query:X,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.rooms??[])}function U(t,e){if(!e.name)throw new Error("Room name is required");if(!R.test(e.name))throw new Error("Room name must be URL-friendly, for example, sample-room-name");return t.mutate({mutation:J,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 re(t){return t=t?t.trim():"",t?t[t.length-1]==="/"?t.slice(0,t.length-1):t:""}function w(t){if(t==null)return null;try{Number.parseInt(t)}catch{throw new Error("invalid threadEventId")}return t}function F(t,e){return t.query({query:Y,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function j(t,e){if(!e)throw new Error("threadId is required");return t.query({query:ee,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function V(t,e){if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:$,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 I(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=ge(a.messageId))),t.query({query:te,variables:{where:_,limit:a?.limit,ordering:a?.ordering||"asc"},fetchPolicy:"no-cache"}).then(r=>r.data?.thread_events??[])}function W(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:H,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 N(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:K,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 z(t,e,a){if(!e)throw new Error("threadId is required");w(a);let _={thread_id:{_eq:e}};return a&&(_.thread_event_id={_gte:a}),t.subscribe({query:ae,variables:{where:_}}).pipe((0,u.map)(r=>{if(r.error)throw r.error;return r.data?.thread_events??[]}))}function q(t,e,a){if(!e)throw new Error("threadId is required");let _,r=w(a?.fromEventId),o={eventId:a?.fromEventId?{_gte:r}:void 0,messageId:a?.messageId},i=a?.pollingInterval&&a?.pollingInterval>0?a.pollingInterval:5;return(0,u.defer)(async()=>{let n=_?{messageId:a?.messageId,eventId:{_gt:_}}:o,p=await I(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/i):void 0,delay:i*1e3}),(0,u.takeWhile)(n=>_e(n,a?.skipAnalysis),!0))}function _e(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 ge(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}function ne(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="failure"}function ie(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="success"&&"token"in t}function oe(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 M(t){let a=`${re(t.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,_={token:"",expiry:new Date(0)},r=t.fetch||fetch,o=async()=>{let i=await r(a,{method:"POST",headers:t.headers});switch(i.status){case 200:{let n=await i.json();if(ie(n))return n;throw new Error("malformed token response")}case 401:{let n=await i.json();throw ne(n)?new Error(n?.error||i.statusText):new Error(i.statusText)}default:{let n=await i.text();throw new Error(n)}}};return async()=>{if(_.expiry.getTime()<=Date.now()-1e3){let i=await o(),n=await Se(t.promptqlGraphQLUrl,i.token,t.projectId,r);_.token=n;let p=new Date(i.expiry);if(Number.isNaN(p.getTime())){let m=new Date;m.setHours(1),_.expiry=m}else _.expiry=p}return _.token}}var Se=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 o=await r.json();if(!oe(o)||!o.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(o)}`);return o.data.enrich_token.userDirectoryJWT}default:{let o=await r.text();throw new Error(o)}}};function D(t){return{Authorization:`pat ${t}`}}var s=require("@apollo/client"),pe=require("@apollo/client/link/context"),ue=require("@apollo/client/link/subscriptions"),se=require("graphql"),de=require("graphql-ws");var G=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:{"User-Agent":d,...n,Authorization:`Bearer ${p}`}}},_=(0,de.createClient)({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),r=new ue.GraphQLWsLink(_),o=new pe.SetContextLink(({headers:n})=>a(n)),i=s.ApolloLink.split(({operationType:n})=>n===se.OperationTypeNode.SUBSCRIPTION,r,o.concat(e));return{client:new s.ApolloClient({link:i,cache:new s.InMemoryCache}),wsClient:_}};function Ae(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 o=e[r];if(BigInt(o?.thread_event_id)<=_)break}return e.slice(r+1)}function he(t){return"UserMessage"in t?t.UserMessage:null}function xe(t){return"UserCancel"in t?t.UserCancel:null}function fe(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 Ce(t){let e=S(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function Be(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 ke(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 Oe(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 ve(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 g(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function Ee(t){let e=g(t);return!e||!("Started"in e)?null:e.Started}function Te(t){let e=g(t);return!e||!("Completed"in e)?null:e.Completed}function Pe(t){let e=g(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function Re(t){return!("AgentMessage"in t)||!("StartingOrchestrator"in t.AgentMessage.update)?null:t.AgentMessage.update.StartingOrchestrator}function S(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.OrchestratorUpdate.update}function c(t){let e=S(t);return!e||!("ContextExplorerUpdate"in e)?null:e.ContextExplorerUpdate.update}function Ue(t){let e=c(t);return!e||!("Started"in e)?null:e.Started}function we(t){let e=c(t);return!e||!("Completed"in e)?null:e.Completed}function A(t){let e=c(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function Fe(t){let e=A(t);return!e||!("Started"in e)?null:e.Started}function je(t){let e=A(t);return!e||!("Completed"in e)?null:e.Completed}function Ve(t){let e=A(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function h(t){let e=c(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function We(t){let e=h(t);return!e||!("Started"in e)?null:e.Started}function Ne(t){let e=h(t);return!e||!("Completed"in e)?null:e.Completed}function ze(t){let e=h(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function y(t){let e=c(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function qe(t){let e=y(t);return!e||!("Started"in e)?null:e.Started}function De(t){let e=y(t);return!e||!("Completed"in e)?null:e.Completed}function Ge(t){let e=y(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function Qe(t){let e=y(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function Le(t){let e=y(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function Ke(t){let e=y(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function x(t){let e=S(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function Je(t){let e=x(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function He(t){let e=x(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function $e(t){let e=x(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function Ze(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,messageId:t.AgentMessage.message_id}:"Errored"in e?{status:"errored",timestamp:e.Errored.errored_at,messageId:t.AgentMessage.message_id,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,messageId:t.AgentMessage.message_id}:"AgentDeclined"in e?{status:"agent_declined",timestamp:e.AgentDeclined.declined_at,reason:e.AgentDeclined.reason,messageId:t.AgentMessage.message_id}:"ServerCancelled"in e?{status:"server_cancelled",timestamp:e.ServerCancelled.cancelled_at,messageId:t.AgentMessage.message_id}:{status:"unknown",messageId:t.AgentMessage.message_id}}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",messageId:t.AgentMessage.message_id,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",messageId:t.AgentMessage.message_id,timestamp:t.AgentMessage.update.timestamp}:"user_cancelled"in e?{status:"user_cancelled",messageId:t.AgentMessage.message_id,timestamp:t.AgentMessage.update.timestamp}:"completed"in e?{status:"completed",messageId:t.AgentMessage.message_id,timestamp:t.AgentMessage.update.timestamp,warnings:e.completed.warnings}:{status:"unknown",messageId:t.AgentMessage.message_id}}return null}function Xe(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}}function Q(t){return`https://promptql.${t}/playground-v2-hge/v1/graphql`}var f=class{controlPlaneUrl;options;defaultTimezone;getAuthTokenFn;project;client;wsClient;constructor(e){if(this.options=e,!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");this.defaultTimezone=e.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone,this.controlPlaneUrl=e.controlPlaneUrl||"https://data.pro.hasura.io/v1/graphql"}async getAuthToken(){if(typeof this.getAuthTokenFn=="function")return this.getAuthTokenFn();let e=await this.getProjectInfo();return this.getAuthTokenFn=M({promptqlGraphQLUrl:e.promptqlGraphQLUrl,authHost:this.options.authHost,headers:D(this.options.serviceAccountToken),fetch:this.options.fetch}),this.getAuthTokenFn()}async getGraphQLClient(){if(this.client)return this.client;let e=await this.getProjectInfo(),{client:a,wsClient:_}=G({getAuthToken:this.getAuthToken.bind(this),url:e.promptqlGraphQLUrl,fetch:this.options.fetch,headers:this.options.headers});return this.wsClient=_,this.client=a,this.client}async getProjectInfo(){if(this.project)return this.project;let e={operationName:"GetDdnProjects",query:"query GetDdnProjects { ddn_projects(limit: 1) { id name private_ddn { fqdn path_routing_context path_routing_enabled }}}"},a=typeof this.options.fetch=="function"?this.options.fetch:fetch,_=D(this.options.serviceAccountToken);_["User-Agent"]=d;let r=await a(this.controlPlaneUrl,{method:"POST",headers:_,body:JSON.stringify(e)});if(r.status!==200){let n=r.body?await r.text():r.statusText;throw new Error(`[${r.status}] failed to get project info: ${n}`)}let o=await r.json();if(!o.data?.ddn_projects?.length)throw new Error("Project not found");let i=o.data.ddn_projects[0];return{projectId:i.id,projectName:i.name,projectHost:`https://${i.name}.${i.private_ddn.fqdn}`,promptqlConsoleUrl:`https://prompt.ql.app/project/${i.name}`,promptqlGraphQLUrl:Q(i.private_ddn.fqdn)}}close(){this.wsClient?.dispose()}};var C=class{api;constructor(e){this.api=e}async listMetadataByThreadId(e){let a=await this.api.getProjectInfo(),_=await this.api.getGraphQLClient();return T(_,a.projectId,e)}async download(e,a){let _=await this.api.getProjectInfo(),r=await this.api.getAuthToken();return E(_.projectHost,e,a,ye(r),this.api.options.fetch)}async getMetadata(e,a){let _=await this.api.getProjectInfo(),r=await this.api.getAuthToken();return P(_.projectHost,e,a,ye(r),this.api.options.fetch)}};function ye(t){return{Authorization:`Bearer ${t}`,"User-Agent":d}}var B=class{api;constructor(e){this.api=e}info(){return this.api.getProjectInfo()}};var k=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return b(a,{...e,limit:e.limit&&e.limit>0?e.limit:10})}async getByName(e){let a=await this.api.getGraphQLClient();return b(a,{where:{name:{_eq:e}},limit:1}).then(_=>_.length?_[0]??null:null)}async create(e){let a=await this.api.getGraphQLClient();return U(a,e)}};var l=require("rxjs");var O=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return F(a,{...e,limit:e.limit&&e.limit>0?e.limit:10})}async get(e){if(!e)throw new Error("threadId is required");let a=await this.api.getGraphQLClient();return j(a,e)}async start(e){let a=await this.api.getProjectInfo(),_=await this.api.getGraphQLClient();return V(_,{...e,projectId:a.projectId,buildId:e.buildId||this.api.options.buildId,timezone:e.timezone||this.api.defaultTimezone})}async getEvents(e,a){let _=await this.api.getGraphQLClient();return I(_,e,a)}async sendMessage(e){let a=await this.api.getGraphQLClient();return W(a,{...e,timezone:e.timezone||this.api.defaultTimezone})}async cancelAgentMessage(e){let a=await this.api.getGraphQLClient();return N(a,e)}subscribeEvents(e,a){return(0,l.from)(this.api.getGraphQLClient()).pipe((0,l.switchMap)(_=>z(_,e,a)))}streamMessageEvents(e,a){return(0,l.from)(this.api.getGraphQLClient()).pipe((0,l.switchMap)(_=>q(_,e,a)))}};var L=class{constructor(e){let a=new f(e);this.api=a,this.thread=new O(a),this.project=new B(a),this.room=new k(a),this.artifact=new C(a)}api;thread;project;room;artifact;close(){this.api.close()}};0&&(module.exports={PromptQLSdk,ROOM_NAME_PATTERN,USER_AGENT,buildPromptQLUrl,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,getArtifactMetadata,getThread,getThreadEventMessageId,getThreadEvents,getUserCancelEvent,getUserMessageEvent,isInteractionAnalyzing,listArtifactMetadataByThreadId,listRooms,listThreads,sendThreadMessage,startThread,streamThreadMessageEvents,subscribeThreadEvents});
1
+ "use strict";var E=Object.defineProperty;var ce=Object.getOwnPropertyDescriptor;var le=Object.getOwnPropertyNames;var me=Object.prototype.hasOwnProperty;var be=(t,e)=>{for(var a in e)E(t,a,{get:e[a],enumerable:!0})},Ie=(t,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let _ of le(e))!me.call(t,_)&&_!==a&&E(t,_,{get:()=>e[_],enumerable:!(r=ce(e,_))||r.enumerable});return t};var Me=t=>Ie(E({},"__esModule",{value:!0}),t);var Ye={};be(Ye,{PromptQLSdk:()=>K,ROOM_NAME_PATTERN:()=>U,USER_AGENT:()=>d,buildPromptQLUrl:()=>L,cancelAgentMessage:()=>z,createApolloClient:()=>Q,createPromptQLAuthTokenGenerator:()=>g,createRoom:()=>w,diffThreadEvents:()=>Ae,downloadArtifactData:()=>T,getAgentGeneratedResponse:()=>Be,getAgentInteractionDecisionAcceptInteractionEvent:()=>Oe,getAgentInteractionDecisionDeclineInteractionEvent:()=>ve,getAgentInteractionFinishedEvent:()=>Ze,getAgentMessageProcessingStartedEvent:()=>ke,getAgentOrchestratorContextExplorerCompletedEvent:()=>we,getAgentOrchestratorContextExplorerStartedEvent:()=>Ue,getAgentOrchestratorContextExplorerUpdateEvent:()=>c,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent:()=>Ge,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent:()=>Qe,getAgentOrchestratorSchemaExplorerCompletedEvent:()=>De,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent:()=>Le,getAgentOrchestratorSchemaExplorerSchemaExploredEvent:()=>Ke,getAgentOrchestratorSchemaExplorerStartedEvent:()=>qe,getAgentOrchestratorSchemaExplorerUpdateEvent:()=>y,getAgentOrchestratorSchemaTasksGeneratedEvent:()=>ze,getAgentOrchestratorSchemaTasksGenerationCompletedEvent:()=>Ne,getAgentOrchestratorSchemaTasksGenerationStartedEvent:()=>We,getAgentOrchestratorSchemaTasksGenerationUpdateEvent:()=>x,getAgentOrchestratorStepProgrammerEvent:()=>Je,getAgentOrchestratorStepSavedProgramRunnerEvent:()=>$e,getAgentOrchestratorStepUiProgrammerEvent:()=>He,getAgentOrchestratorStepUpdateEvent:()=>f,getAgentOrchestratorUpdateEvent:()=>A,getAgentOrchestratorWikiExplorerCompletedEvent:()=>je,getAgentOrchestratorWikiExplorerStartedEvent:()=>Fe,getAgentOrchestratorWikiExplorerUpdateEvent:()=>h,getAgentOrchestratorWikiInfoGeneratedEvent:()=>Ve,getAgentPlanGenerationStartedEvent:()=>fe,getAgentPlanStepGeneratedEvent:()=>Ce,getAgentPlanningDecisionCompletedEvent:()=>Te,getAgentPlanningDecisionPlanningRequiredEvent:()=>Pe,getAgentPlanningDecisionStartedEvent:()=>Ee,getAgentPlanningDecisionUpdateEvent:()=>S,getAgentStartingOrchestratorEvent:()=>Re,getArtifactMetadata:()=>R,getThread:()=>V,getThreadEventMessageId:()=>Xe,getThreadEvents:()=>M,getUserCancelEvent:()=>xe,getUserMessageEvent:()=>he,isInteractionAnalyzing:()=>_e,listArtifactMetadataByThreadId:()=>P,listRooms:()=>b,listThreads:()=>j,sendThreadMessage:()=>N,startThread:()=>W,streamThreadMessageEvents:()=>D,subscribeThreadEvents:()=>q});module.exports=Me(Ye);var J={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"}}]}}]}}]},H={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"}}]}}]}}]},$={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"}}]}}]}}]},Z={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"}}]}}]}}]}}]},X={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetArtifactsByThreadId"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"artifacts"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_artifacts"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_id"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"_eq"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}}]}}]}}]}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"updated_at"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"artifact_id"}},{kind:"Field",name:{kind:"Name",value:"latest_version_object"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"description"}},{kind:"Field",name:{kind:"Name",value:"user_id"}},{kind:"Field",name:{kind:"Name",value:"artifact_metadata"}},{kind:"Field",name:{kind:"Name",value:"artifact_type"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"size"}},{kind:"Field",name:{kind:"Name",value:"version"}}]}}]}}]}}]},Y={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"}}]}}]},ee={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"}}]}}]}}]},te={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"}}]}}]}}]},ae={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"}}]}}]},re={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"}}]}}]};async function T(t,e,a,r,_){let i=`${t}/promptql-v2/artifacts/${e}/version/${a}/data`,n=await(typeof _=="function"?_:fetch)(i,{method:"GET",headers:r});if(n.status!==200){let m=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to download artifact: ${m}`)}return n.body?n.headers.get("Content-Type")?.startsWith("application/json")?n.json():n.text():null}async function P(t,e,a){let r=await t.query({query:X,variables:{threadId:a},fetchPolicy:"no-cache"});return r.data?.artifacts?.length?r.data.artifacts.filter(_=>_.latest_version_object).map(_=>({project_id:e,artifact_id:_.artifact_id,artifact_type:_.latest_version_object.artifact_type,version:_.latest_version_object.version,title:_.latest_version_object.title,description:_.latest_version_object.description??null,user_id:_.latest_version_object.user_id,metadata:_.latest_version_object.artifact_metadata,created_at:_.latest_version_object.created_at,size_bytes:Number.parseInt(_.latest_version_object.size)})):[]}async function R(t,e,a,r,_){let i=`${t}/promptql-v2/artifacts/${e}/version/${a}/metadata`,n=await(typeof _=="function"?_:fetch)(i,{method:"GET",headers:r});if(n.status!==200){let p=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to get artifact metadata: ${p}`)}return n.json()}var d="PromptQL TypeScript SDK",U=/^([a-z0-9]+-?)*[a-z0-9]+$/;function b(t,e){return t.query({query:Y,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.rooms??[])}function w(t,e){if(!e.name)throw new Error("Room name is required");if(!U.test(e.name))throw new Error("Room name must be URL-friendly, for example, sample-room-name");return t.mutate({mutation:H,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 I(t){return t=t?t.trim():"",t?t[t.length-1]==="/"?t.slice(0,t.length-1):t:""}function F(t){if(t==null)return null;try{Number.parseInt(t)}catch{throw new Error("invalid threadEventId")}return t}function j(t,e){return t.query({query:ee,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function V(t,e){if(!e)throw new Error("threadId is required");return t.query({query:te,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function W(t,e){if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:Z,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 r={thread_id:{_eq:e}};return a&&(a.eventId&&(r.thread_event_id=a.eventId),a.messageId&&(r._or=ge(a.messageId))),t.query({query:ae,variables:{where:r,limit:a?.limit,ordering:a?.ordering||"asc"},fetchPolicy:"no-cache"}).then(_=>_.data?.thread_events??[])}function N(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:$,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 z(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:J,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 q(t,e,a){if(!e)throw new Error("threadId is required");F(a);let r={thread_id:{_eq:e}};return a&&(r.thread_event_id={_gte:a}),t.subscribe({query:re,variables:{where:r}}).pipe((0,u.map)(_=>{if(_.error)throw _.error;return _.data?.thread_events??[]}))}function D(t,e,a){if(!e)throw new Error("threadId is required");let r,_=F(a?.fromEventId),i={eventId:a?.fromEventId?{_gte:_}:void 0,messageId:a?.messageId},o=a?.pollingInterval&&a?.pollingInterval>0?a.pollingInterval:5;return(0,u.defer)(async()=>{let n=r?{messageId:a?.messageId,eventId:{_gt:r}}:i,p=await M(t,e,n);return p.length>0&&(r=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=>_e(n,a?.skipAnalysis),!0))}function _e(t,e){for(let a=t.length-1;a>0;a--){let r=t[a];if(e&&"UserCancel"in r.event_data)return!1;if(!("AgentMessage"in r.event_data))return!0;let _=r.event_data.AgentMessage.update;if("content"in _&&("interaction_finished"in _.content||e&&"interaction_update"in _.content&&"main_agent"in _.content.interaction_update&&"completed"in _.content.interaction_update.main_agent)||"InteractionFinished"in _||e&&"OrchestratorUpdate"in _&&"GeneratedResponse"in _.OrchestratorUpdate.update)return!1}return!0}function ge(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}function ne(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="failure"}function ie(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="success"&&"token"in t}function oe(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=`${I(t.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,r={token:"",expiry:new Date(0)},_=t.fetch||fetch,i=async()=>{let o=await _(a,{method:"POST",headers:t.headers});switch(o.status){case 200:{let n=await o.json();if(ie(n))return n;throw new Error("malformed token response")}case 401:{let n=await o.json();throw ne(n)?new Error(n?.error||o.statusText):new Error(o.statusText)}default:{let n=await o.text();throw new Error(n)}}};return async()=>{if(r.expiry.getTime()<=Date.now()-1e3){let o=await i(),n=await Se(t.promptqlGraphQLUrl,o.token,t.projectId,_);r.token=n;let p=new Date(o.expiry);if(Number.isNaN(p.getTime())){let m=new Date;m.setHours(1),r.expiry=m}else r.expiry=p}return r.token}}var Se=async(t,e,a,r=fetch)=>{let _=await r(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(_.status){case 200:{let i=await _.json();if(!oe(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 _.text();throw new Error(i)}}};function G(t){return{Authorization:`pat ${t}`}}var s=require("@apollo/client"),pe=require("@apollo/client/link/context"),ue=require("@apollo/client/link/subscriptions"),se=require("graphql"),de=require("graphql-ws");var Q=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:{"User-Agent":d,...n,Authorization:`Bearer ${p}`}}},r=(0,de.createClient)({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),_=new ue.GraphQLWsLink(r),i=new pe.SetContextLink(({headers:n})=>a(n)),o=s.ApolloLink.split(({operationType:n})=>n===se.OperationTypeNode.SUBSCRIPTION,_,i.concat(e));return{client:new s.ApolloClient({link:o,cache:new s.InMemoryCache}),wsClient:r}};function Ae(t,e){if(!e.length)return[];if(!t.length)return e;let a=t[t.length-1];if(!a)return e;let r=BigInt(a.thread_event_id),_=e.length-1;for(;_>=0;_--){let i=e[_];if(BigInt(i?.thread_event_id)<=r)break}return e.slice(_+1)}function he(t){return"UserMessage"in t?t.UserMessage:null}function xe(t){return"UserCancel"in t?t.UserCancel:null}function fe(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 Ce(t){let e=A(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function Be(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,messageId:t.AgentMessage.message_id}:!("OrchestratorUpdate"in t.AgentMessage.update)||!("GeneratedResponse"in t.AgentMessage.update.OrchestratorUpdate.update)?null:{...t.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse.response,messageId:t.AgentMessage.message_id}:null}function ke(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 Oe(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 ve(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 S(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function Ee(t){let e=S(t);return!e||!("Started"in e)?null:e.Started}function Te(t){let e=S(t);return!e||!("Completed"in e)?null:e.Completed}function Pe(t){let e=S(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function Re(t){return!("AgentMessage"in t)||!("StartingOrchestrator"in t.AgentMessage.update)?null:t.AgentMessage.update.StartingOrchestrator}function A(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.OrchestratorUpdate.update}function c(t){let e=A(t);return!e||!("ContextExplorerUpdate"in e)?null:e.ContextExplorerUpdate.update}function Ue(t){let e=c(t);return!e||!("Started"in e)?null:e.Started}function we(t){let e=c(t);return!e||!("Completed"in e)?null:e.Completed}function h(t){let e=c(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function Fe(t){let e=h(t);return!e||!("Started"in e)?null:e.Started}function je(t){let e=h(t);return!e||!("Completed"in e)?null:e.Completed}function Ve(t){let e=h(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function x(t){let e=c(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function We(t){let e=x(t);return!e||!("Started"in e)?null:e.Started}function Ne(t){let e=x(t);return!e||!("Completed"in e)?null:e.Completed}function ze(t){let e=x(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function y(t){let e=c(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function qe(t){let e=y(t);return!e||!("Started"in e)?null:e.Started}function De(t){let e=y(t);return!e||!("Completed"in e)?null:e.Completed}function Ge(t){let e=y(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function Qe(t){let e=y(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function Le(t){let e=y(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function Ke(t){let e=y(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function f(t){let e=A(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function Je(t){let e=f(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function He(t){let e=f(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function $e(t){let e=f(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function Ze(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,messageId:t.AgentMessage.message_id}:"Errored"in e?{status:"errored",timestamp:e.Errored.errored_at,messageId:t.AgentMessage.message_id,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,messageId:t.AgentMessage.message_id}:"AgentDeclined"in e?{status:"agent_declined",timestamp:e.AgentDeclined.declined_at,reason:e.AgentDeclined.reason,messageId:t.AgentMessage.message_id}:"ServerCancelled"in e?{status:"server_cancelled",timestamp:e.ServerCancelled.cancelled_at,messageId:t.AgentMessage.message_id}:{status:"unknown",messageId:t.AgentMessage.message_id}}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",messageId:t.AgentMessage.message_id,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",messageId:t.AgentMessage.message_id,timestamp:t.AgentMessage.update.timestamp}:"user_cancelled"in e?{status:"user_cancelled",messageId:t.AgentMessage.message_id,timestamp:t.AgentMessage.update.timestamp}:"completed"in e?{status:"completed",messageId:t.AgentMessage.message_id,timestamp:t.AgentMessage.update.timestamp,warnings:e.completed.warnings}:{status:"unknown",messageId:t.AgentMessage.message_id}}return null}function Xe(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}}function L(t){return`https://promptql.${t}/playground-v2-hge/v1/graphql`}var C=class{controlPlaneUrl;options;defaultTimezone;getAuthTokenFn;project;client;wsClient;constructor(e){if(this.options=e,!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");this.defaultTimezone=e.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone;let a=e.controlPlaneHost?I(e.controlPlaneHost):"https://data.pro.hasura.io";this.controlPlaneUrl=`${a}/v1/graphql`}async getAuthToken(){if(typeof this.getAuthTokenFn=="function")return this.getAuthTokenFn();let e=await this.getProjectInfo();return this.getAuthTokenFn=g({promptqlGraphQLUrl:e.promptqlGraphQLUrl,authHost:this.options.authHost,headers:G(this.options.serviceAccountToken),fetch:this.options.fetch}),this.getAuthTokenFn()}async getGraphQLClient(){if(this.client)return this.client;let e=await this.getProjectInfo(),{client:a,wsClient:r}=Q({getAuthToken:this.getAuthToken.bind(this),url:e.promptqlGraphQLUrl,fetch:this.options.fetch,headers:this.options.headers});return this.wsClient=r,this.client=a,this.client}async getProjectInfo(){if(this.project)return this.project;let e={operationName:"GetDdnProjects",query:"query GetDdnProjects { ddn_projects(limit: 1) { id name private_ddn { fqdn path_routing_context path_routing_enabled }}}"},r=await(typeof this.options.fetch=="function"?this.options.fetch:fetch)(this.controlPlaneUrl,{method:"POST",headers:{...G(this.options.serviceAccountToken),"User-Agent":d,"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.status!==200){let o=r.body?await r.text():r.statusText;throw new Error(`[${r.status}] failed to get project info: ${o}`)}let _=await r.json();if(!_.data?.ddn_projects?.length)throw new Error("Project not found");let i=_.data.ddn_projects[0];return this.project={projectId:i.id,projectName:i.name,projectHost:`https://${i.name}.${i.private_ddn.fqdn}`,promptqlConsoleUrl:`https://prompt.ql.app/project/${i.name}`,promptqlGraphQLUrl:L(i.private_ddn.fqdn)},this.project}close(){if(this.wsClient&&(this.wsClient.dispose(),this.wsClient=void 0),this.client){try{this.client.stop?.()}catch{}try{this.client.clearStore?.()}catch{}this.client=void 0,this.project=void 0,this.getAuthTokenFn=void 0}}};var B=class{api;constructor(e){this.api=e}async listMetadataByThreadId(e){let a=await this.api.getProjectInfo(),r=await this.api.getGraphQLClient();return P(r,a.projectId,e)}async download(e,a){let r=await this.api.getProjectInfo(),_=await this.api.getAuthToken();return T(r.projectHost,e,a,ye(_),this.api.options.fetch)}async getMetadata(e,a){let r=await this.api.getProjectInfo(),_=await this.api.getAuthToken();return R(r.projectHost,e,a,ye(_),this.api.options.fetch)}};function ye(t){return{Authorization:`Bearer ${t}`,"User-Agent":d}}var k=class{api;constructor(e){this.api=e}info(){return this.api.getProjectInfo()}};var O=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return b(a,{...e,limit:e.limit&&e.limit>0?e.limit:10})}async getByName(e){let a=await this.api.getGraphQLClient();return b(a,{where:{name:{_eq:e}},limit:1}).then(r=>r.length?r[0]??null:null)}async create(e){let a=await this.api.getGraphQLClient();return w(a,e)}};var l=require("rxjs");var v=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return j(a,{...e,limit:e.limit&&e.limit>0?e.limit:10})}async get(e){if(!e)throw new Error("threadId is required");let a=await this.api.getGraphQLClient();return V(a,e)}async start(e){let a=await this.api.getProjectInfo(),r=await this.api.getGraphQLClient();return W(r,{...e,projectId:a.projectId,buildId:e.buildId||this.api.options.buildId,timezone:e.timezone||this.api.defaultTimezone})}async getEvents(e,a){let r=await this.api.getGraphQLClient();return M(r,e,a)}async sendMessage(e){let a=await this.api.getGraphQLClient();return N(a,{...e,timezone:e.timezone||this.api.defaultTimezone})}async cancelAgentMessage(e){let a=await this.api.getGraphQLClient();return z(a,e)}subscribeEvents(e,a){return(0,l.from)(this.api.getGraphQLClient()).pipe((0,l.switchMap)(r=>q(r,e,a)))}streamMessageEvents(e,a){return(0,l.from)(this.api.getGraphQLClient()).pipe((0,l.switchMap)(r=>D(r,e,a)))}};var K=class{constructor(e){let a=new C(e);this.api=a,this.thread=new v(a),this.project=new k(a),this.room=new O(a),this.artifact=new B(a)}api;thread;project;room;artifact;close(){this.api.close()}};0&&(module.exports={PromptQLSdk,ROOM_NAME_PATTERN,USER_AGENT,buildPromptQLUrl,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,getArtifactMetadata,getThread,getThreadEventMessageId,getThreadEvents,getUserCancelEvent,getUserMessageEvent,isInteractionAnalyzing,listArtifactMetadataByThreadId,listRooms,listThreads,sendThreadMessage,startThread,streamThreadMessageEvents,subscribeThreadEvents});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- var O={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"}}]}}]}}]},v={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"}}]}}]}}]},E={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"}}]}}]}}]},T={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"}}]}}]}}]}}]},P={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetArtifactsByThreadId"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"artifacts"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_artifacts"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_id"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"_eq"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}}]}}]}}]}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"updated_at"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"artifact_id"}},{kind:"Field",name:{kind:"Name",value:"latest_version_object"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"description"}},{kind:"Field",name:{kind:"Name",value:"user_id"}},{kind:"Field",name:{kind:"Name",value:"artifact_metadata"}},{kind:"Field",name:{kind:"Name",value:"artifact_type"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"size"}},{kind:"Field",name:{kind:"Name",value:"version"}}]}}]}}]}}]},R={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"}}]}}]},U={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"}}]}}]}}]},w={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"}}]}}]}}]},F={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"}}]}}]},j={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"}}]}}]};async function V(t,e,a,_,r){let o=`${t}/promptql-v2/artifacts/${e}/version/${a}/data`,n=await(typeof r=="function"?r:fetch)(o,{method:"GET",headers:_});if(n.status!==200){let y=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to download artifact: ${y}`)}return n.body?n.headers.get("Content-Type")?.startsWith("application/json")?n.json():n.text():null}async function W(t,e,a){let _=await t.query({query:P,variables:{threadId:a},fetchPolicy:"no-cache"});return _.data?.artifacts?.length?_.data.artifacts.filter(r=>r.latest_version_object).map(r=>({project_id:e,artifact_id:r.artifact_id,artifact_type:r.latest_version_object.artifact_type,version:r.latest_version_object.version,title:r.latest_version_object.title,description:r.latest_version_object.description??null,user_id:r.latest_version_object.user_id,metadata:r.latest_version_object.artifact_metadata,created_at:r.latest_version_object.created_at,size_bytes:Number.parseInt(r.latest_version_object.size)})):[]}async function N(t,e,a,_,r){let o=`${t}/promptql-v2/artifacts/${e}/version/${a}/metadata`,n=await(typeof r=="function"?r:fetch)(o,{method:"GET",headers:_});if(n.status!==200){let p=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to get artifact metadata: ${p}`)}return n.json()}var u="PromptQL TypeScript SDK",z=/([a-z0-9]+-?)*[a-z0-9]+/;function M(t,e){return t.query({query:R,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.rooms??[])}function q(t,e){if(!e.name)throw new Error("Room name is required");if(!z.test(e.name))throw new Error("Room name must be URL-friendly, for example, sample-room-name");return t.mutate({mutation:v,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 ie,map as oe,repeat as pe,takeWhile as ue}from"rxjs";function D(t){return t=t?t.trim():"",t?t[t.length-1]==="/"?t.slice(0,t.length-1):t:""}function g(t){if(t==null)return null;try{Number.parseInt(t)}catch{throw new Error("invalid threadEventId")}return t}function G(t,e){return t.query({query:U,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function Q(t,e){if(!e)throw new Error("threadId is required");return t.query({query:w,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function L(t,e){if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:T,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 S(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=de(a.messageId))),t.query({query:F,variables:{where:_,limit:a?.limit,ordering:a?.ordering||"asc"},fetchPolicy:"no-cache"}).then(r=>r.data?.thread_events??[])}function K(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:E,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 J(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:O,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 H(t,e,a){if(!e)throw new Error("threadId is required");g(a);let _={thread_id:{_eq:e}};return a&&(_.thread_event_id={_gte:a}),t.subscribe({query:j,variables:{where:_}}).pipe(oe(r=>{if(r.error)throw r.error;return r.data?.thread_events??[]}))}function $(t,e,a){if(!e)throw new Error("threadId is required");let _,r=g(a?.fromEventId),o={eventId:a?.fromEventId?{_gte:r}:void 0,messageId:a?.messageId},i=a?.pollingInterval&&a?.pollingInterval>0?a.pollingInterval:5;return ie(async()=>{let n=_?{messageId:a?.messageId,eventId:{_gt:_}}:o,p=await S(t,e,n);return p.length>0&&(_=p[p.length-1]?.thread_event_id),p}).pipe(pe({count:a?.timeout&&a.timeout>0?Math.ceil(a.timeout/i):void 0,delay:i*1e3}),ue(n=>se(n,a?.skipAnalysis),!0))}function se(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 de(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 A(t){let a=`${D(t.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,_={token:"",expiry:new Date(0)},r=t.fetch||fetch,o=async()=>{let i=await r(a,{method:"POST",headers:t.headers});switch(i.status){case 200:{let n=await i.json();if(X(n))return n;throw new Error("malformed token response")}case 401:{let n=await i.json();throw Z(n)?new Error(n?.error||i.statusText):new Error(i.statusText)}default:{let n=await i.text();throw new Error(n)}}};return async()=>{if(_.expiry.getTime()<=Date.now()-1e3){let i=await o(),n=await ye(t.promptqlGraphQLUrl,i.token,t.projectId,r);_.token=n;let p=new Date(i.expiry);if(Number.isNaN(p.getTime())){let y=new Date;y.setHours(1),_.expiry=y}else _.expiry=p}return _.token}}var ye=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 o=await r.json();if(!Y(o)||!o.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(o)}`);return o.data.enrich_token.userDirectoryJWT}default:{let o=await r.text();throw new Error(o)}}};function h(t){return{Authorization:`pat ${t}`}}import{ApolloClient as ce,ApolloLink as le,HttpLink as me,InMemoryCache as be}from"@apollo/client";import{SetContextLink as Ie}from"@apollo/client/link/context";import{GraphQLWsLink as Me}from"@apollo/client/link/subscriptions";import{OperationTypeNode as ge}from"graphql";import{createClient as Se}from"graphql-ws";var ee=t=>{let e=new me({uri:t.url,fetch:t.fetch,headers:t.headers}),a=async n=>{let p=await t.getAuthToken();return{headers:{"User-Agent":u,...n,Authorization:`Bearer ${p}`}}},_=Se({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),r=new Me(_),o=new Ie(({headers:n})=>a(n)),i=le.split(({operationType:n})=>n===ge.SUBSCRIPTION,r,o.concat(e));return{client:new ce({link:i,cache:new be}),wsClient:_}};function ot(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 o=e[r];if(BigInt(o?.thread_event_id)<=_)break}return e.slice(r+1)}function pt(t){return"UserMessage"in t?t.UserMessage:null}function ut(t){return"UserCancel"in t?t.UserCancel:null}function st(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 dt(t){let e=f(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function yt(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 ct(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 lt(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 mt(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 x(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function bt(t){let e=x(t);return!e||!("Started"in e)?null:e.Started}function It(t){let e=x(t);return!e||!("Completed"in e)?null:e.Completed}function Mt(t){let e=x(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function gt(t){return!("AgentMessage"in t)||!("StartingOrchestrator"in t.AgentMessage.update)?null:t.AgentMessage.update.StartingOrchestrator}function f(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.OrchestratorUpdate.update}function d(t){let e=f(t);return!e||!("ContextExplorerUpdate"in e)?null:e.ContextExplorerUpdate.update}function St(t){let e=d(t);return!e||!("Started"in e)?null:e.Started}function At(t){let e=d(t);return!e||!("Completed"in e)?null:e.Completed}function C(t){let e=d(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function ht(t){let e=C(t);return!e||!("Started"in e)?null:e.Started}function xt(t){let e=C(t);return!e||!("Completed"in e)?null:e.Completed}function ft(t){let e=C(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function B(t){let e=d(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function Ct(t){let e=B(t);return!e||!("Started"in e)?null:e.Started}function Bt(t){let e=B(t);return!e||!("Completed"in e)?null:e.Completed}function kt(t){let e=B(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function s(t){let e=d(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function Ot(t){let e=s(t);return!e||!("Started"in e)?null:e.Started}function vt(t){let e=s(t);return!e||!("Completed"in e)?null:e.Completed}function Et(t){let e=s(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function Tt(t){let e=s(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function Pt(t){let e=s(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function Rt(t){let e=s(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function k(t){let e=f(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function Ut(t){let e=k(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function wt(t){let e=k(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function Ft(t){let e=k(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function jt(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,messageId:t.AgentMessage.message_id}:"Errored"in e?{status:"errored",timestamp:e.Errored.errored_at,messageId:t.AgentMessage.message_id,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,messageId:t.AgentMessage.message_id}:"AgentDeclined"in e?{status:"agent_declined",timestamp:e.AgentDeclined.declined_at,reason:e.AgentDeclined.reason,messageId:t.AgentMessage.message_id}:"ServerCancelled"in e?{status:"server_cancelled",timestamp:e.ServerCancelled.cancelled_at,messageId:t.AgentMessage.message_id}:{status:"unknown",messageId:t.AgentMessage.message_id}}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",messageId:t.AgentMessage.message_id,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",messageId:t.AgentMessage.message_id,timestamp:t.AgentMessage.update.timestamp}:"user_cancelled"in e?{status:"user_cancelled",messageId:t.AgentMessage.message_id,timestamp:t.AgentMessage.update.timestamp}:"completed"in e?{status:"completed",messageId:t.AgentMessage.message_id,timestamp:t.AgentMessage.update.timestamp,warnings:e.completed.warnings}:{status:"unknown",messageId:t.AgentMessage.message_id}}return null}function Vt(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}}function te(t){return`https://promptql.${t}/playground-v2-hge/v1/graphql`}var c=class{controlPlaneUrl;options;defaultTimezone;getAuthTokenFn;project;client;wsClient;constructor(e){if(this.options=e,!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");this.defaultTimezone=e.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone,this.controlPlaneUrl=e.controlPlaneUrl||"https://data.pro.hasura.io/v1/graphql"}async getAuthToken(){if(typeof this.getAuthTokenFn=="function")return this.getAuthTokenFn();let e=await this.getProjectInfo();return this.getAuthTokenFn=A({promptqlGraphQLUrl:e.promptqlGraphQLUrl,authHost:this.options.authHost,headers:h(this.options.serviceAccountToken),fetch:this.options.fetch}),this.getAuthTokenFn()}async getGraphQLClient(){if(this.client)return this.client;let e=await this.getProjectInfo(),{client:a,wsClient:_}=ee({getAuthToken:this.getAuthToken.bind(this),url:e.promptqlGraphQLUrl,fetch:this.options.fetch,headers:this.options.headers});return this.wsClient=_,this.client=a,this.client}async getProjectInfo(){if(this.project)return this.project;let e={operationName:"GetDdnProjects",query:"query GetDdnProjects { ddn_projects(limit: 1) { id name private_ddn { fqdn path_routing_context path_routing_enabled }}}"},a=typeof this.options.fetch=="function"?this.options.fetch:fetch,_=h(this.options.serviceAccountToken);_["User-Agent"]=u;let r=await a(this.controlPlaneUrl,{method:"POST",headers:_,body:JSON.stringify(e)});if(r.status!==200){let n=r.body?await r.text():r.statusText;throw new Error(`[${r.status}] failed to get project info: ${n}`)}let o=await r.json();if(!o.data?.ddn_projects?.length)throw new Error("Project not found");let i=o.data.ddn_projects[0];return{projectId:i.id,projectName:i.name,projectHost:`https://${i.name}.${i.private_ddn.fqdn}`,promptqlConsoleUrl:`https://prompt.ql.app/project/${i.name}`,promptqlGraphQLUrl:te(i.private_ddn.fqdn)}}close(){this.wsClient?.dispose()}};var l=class{api;constructor(e){this.api=e}async listMetadataByThreadId(e){let a=await this.api.getProjectInfo(),_=await this.api.getGraphQLClient();return W(_,a.projectId,e)}async download(e,a){let _=await this.api.getProjectInfo(),r=await this.api.getAuthToken();return V(_.projectHost,e,a,ae(r),this.api.options.fetch)}async getMetadata(e,a){let _=await this.api.getProjectInfo(),r=await this.api.getAuthToken();return N(_.projectHost,e,a,ae(r),this.api.options.fetch)}};function ae(t){return{Authorization:`Bearer ${t}`,"User-Agent":u}}var m=class{api;constructor(e){this.api=e}info(){return this.api.getProjectInfo()}};var b=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return M(a,{...e,limit:e.limit&&e.limit>0?e.limit:10})}async getByName(e){let a=await this.api.getGraphQLClient();return M(a,{where:{name:{_eq:e}},limit:1}).then(_=>_.length?_[0]??null:null)}async create(e){let a=await this.api.getGraphQLClient();return q(a,e)}};import{from as re,switchMap as _e}from"rxjs";var I=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return G(a,{...e,limit:e.limit&&e.limit>0?e.limit:10})}async get(e){if(!e)throw new Error("threadId is required");let a=await this.api.getGraphQLClient();return Q(a,e)}async start(e){let a=await this.api.getProjectInfo(),_=await this.api.getGraphQLClient();return L(_,{...e,projectId:a.projectId,buildId:e.buildId||this.api.options.buildId,timezone:e.timezone||this.api.defaultTimezone})}async getEvents(e,a){let _=await this.api.getGraphQLClient();return S(_,e,a)}async sendMessage(e){let a=await this.api.getGraphQLClient();return K(a,{...e,timezone:e.timezone||this.api.defaultTimezone})}async cancelAgentMessage(e){let a=await this.api.getGraphQLClient();return J(a,e)}subscribeEvents(e,a){return re(this.api.getGraphQLClient()).pipe(_e(_=>H(_,e,a)))}streamMessageEvents(e,a){return re(this.api.getGraphQLClient()).pipe(_e(_=>$(_,e,a)))}};var ne=class{constructor(e){let a=new c(e);this.api=a,this.thread=new I(a),this.project=new m(a),this.room=new b(a),this.artifact=new l(a)}api;thread;project;room;artifact;close(){this.api.close()}};export{ne as PromptQLSdk,z as ROOM_NAME_PATTERN,u as USER_AGENT,te as buildPromptQLUrl,J as cancelAgentMessage,ee as createApolloClient,A as createPromptQLAuthTokenGenerator,q as createRoom,ot as diffThreadEvents,V as downloadArtifactData,yt as getAgentGeneratedResponse,lt as getAgentInteractionDecisionAcceptInteractionEvent,mt as getAgentInteractionDecisionDeclineInteractionEvent,jt as getAgentInteractionFinishedEvent,ct as getAgentMessageProcessingStartedEvent,At as getAgentOrchestratorContextExplorerCompletedEvent,St as getAgentOrchestratorContextExplorerStartedEvent,d as getAgentOrchestratorContextExplorerUpdateEvent,Et as getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,Tt as getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,vt as getAgentOrchestratorSchemaExplorerCompletedEvent,Pt as getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,Rt as getAgentOrchestratorSchemaExplorerSchemaExploredEvent,Ot as getAgentOrchestratorSchemaExplorerStartedEvent,s as getAgentOrchestratorSchemaExplorerUpdateEvent,kt as getAgentOrchestratorSchemaTasksGeneratedEvent,Bt as getAgentOrchestratorSchemaTasksGenerationCompletedEvent,Ct as getAgentOrchestratorSchemaTasksGenerationStartedEvent,B as getAgentOrchestratorSchemaTasksGenerationUpdateEvent,Ut as getAgentOrchestratorStepProgrammerEvent,Ft as getAgentOrchestratorStepSavedProgramRunnerEvent,wt as getAgentOrchestratorStepUiProgrammerEvent,k as getAgentOrchestratorStepUpdateEvent,f as getAgentOrchestratorUpdateEvent,xt as getAgentOrchestratorWikiExplorerCompletedEvent,ht as getAgentOrchestratorWikiExplorerStartedEvent,C as getAgentOrchestratorWikiExplorerUpdateEvent,ft as getAgentOrchestratorWikiInfoGeneratedEvent,st as getAgentPlanGenerationStartedEvent,dt as getAgentPlanStepGeneratedEvent,It as getAgentPlanningDecisionCompletedEvent,Mt as getAgentPlanningDecisionPlanningRequiredEvent,bt as getAgentPlanningDecisionStartedEvent,x as getAgentPlanningDecisionUpdateEvent,gt as getAgentStartingOrchestratorEvent,N as getArtifactMetadata,Q as getThread,Vt as getThreadEventMessageId,S as getThreadEvents,ut as getUserCancelEvent,pt as getUserMessageEvent,se as isInteractionAnalyzing,W as listArtifactMetadataByThreadId,M as listRooms,G as listThreads,K as sendThreadMessage,L as startThread,$ as streamThreadMessageEvents,H as subscribeThreadEvents};
1
+ var v={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"}}]}}]}}]},E={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"}}]}}]}}]},T={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"}}]}}]}}]},P={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"}}]}}]}}]}}]},R={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetArtifactsByThreadId"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"threadId"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"artifacts"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_artifacts"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_id"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"_eq"},value:{kind:"Variable",name:{kind:"Name",value:"threadId"}}}]}}]}}]}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"updated_at"},value:{kind:"EnumValue",value:"asc"}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"artifact_id"}},{kind:"Field",name:{kind:"Name",value:"latest_version_object"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"description"}},{kind:"Field",name:{kind:"Name",value:"user_id"}},{kind:"Field",name:{kind:"Name",value:"artifact_metadata"}},{kind:"Field",name:{kind:"Name",value:"artifact_type"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"size"}},{kind:"Field",name:{kind:"Name",value:"version"}}]}}]}}]}}]},U={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"}}]}}]},w={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"}}]}}]}}]},F={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"}}]}}]}}]},j={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"}}]}}]},V={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"}}]}}]};async function W(t,e,a,r,_){let i=`${t}/promptql-v2/artifacts/${e}/version/${a}/data`,n=await(typeof _=="function"?_:fetch)(i,{method:"GET",headers:r});if(n.status!==200){let y=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to download artifact: ${y}`)}return n.body?n.headers.get("Content-Type")?.startsWith("application/json")?n.json():n.text():null}async function N(t,e,a){let r=await t.query({query:R,variables:{threadId:a},fetchPolicy:"no-cache"});return r.data?.artifacts?.length?r.data.artifacts.filter(_=>_.latest_version_object).map(_=>({project_id:e,artifact_id:_.artifact_id,artifact_type:_.latest_version_object.artifact_type,version:_.latest_version_object.version,title:_.latest_version_object.title,description:_.latest_version_object.description??null,user_id:_.latest_version_object.user_id,metadata:_.latest_version_object.artifact_metadata,created_at:_.latest_version_object.created_at,size_bytes:Number.parseInt(_.latest_version_object.size)})):[]}async function z(t,e,a,r,_){let i=`${t}/promptql-v2/artifacts/${e}/version/${a}/metadata`,n=await(typeof _=="function"?_:fetch)(i,{method:"GET",headers:r});if(n.status!==200){let p=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to get artifact metadata: ${p}`)}return n.json()}var u="PromptQL TypeScript SDK",q=/^([a-z0-9]+-?)*[a-z0-9]+$/;function g(t,e){return t.query({query:U,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.rooms??[])}function D(t,e){if(!e.name)throw new Error("Room name is required");if(!q.test(e.name))throw new Error("Room name must be URL-friendly, for example, sample-room-name");return t.mutate({mutation:E,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 ie,map as oe,repeat as pe,takeWhile as ue}from"rxjs";function c(t){return t=t?t.trim():"",t?t[t.length-1]==="/"?t.slice(0,t.length-1):t:""}function S(t){if(t==null)return null;try{Number.parseInt(t)}catch{throw new Error("invalid threadEventId")}return t}function G(t,e){return t.query({query:w,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function Q(t,e){if(!e)throw new Error("threadId is required");return t.query({query:F,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function L(t,e){if(!e.message.trim())throw new Error("message must not be empty");return t.mutate({mutation:P,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 A(t,e,a){if(!e)throw new Error("threadId is required");let r={thread_id:{_eq:e}};return a&&(a.eventId&&(r.thread_event_id=a.eventId),a.messageId&&(r._or=de(a.messageId))),t.query({query:j,variables:{where:r,limit:a?.limit,ordering:a?.ordering||"asc"},fetchPolicy:"no-cache"}).then(_=>_.data?.thread_events??[])}function K(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:T,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 J(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:v,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 H(t,e,a){if(!e)throw new Error("threadId is required");S(a);let r={thread_id:{_eq:e}};return a&&(r.thread_event_id={_gte:a}),t.subscribe({query:V,variables:{where:r}}).pipe(oe(_=>{if(_.error)throw _.error;return _.data?.thread_events??[]}))}function $(t,e,a){if(!e)throw new Error("threadId is required");let r,_=S(a?.fromEventId),i={eventId:a?.fromEventId?{_gte:_}:void 0,messageId:a?.messageId},o=a?.pollingInterval&&a?.pollingInterval>0?a.pollingInterval:5;return ie(async()=>{let n=r?{messageId:a?.messageId,eventId:{_gt:r}}:i,p=await A(t,e,n);return p.length>0&&(r=p[p.length-1]?.thread_event_id),p}).pipe(pe({count:a?.timeout&&a.timeout>0?Math.ceil(a.timeout/o):void 0,delay:o*1e3}),ue(n=>se(n,a?.skipAnalysis),!0))}function se(t,e){for(let a=t.length-1;a>0;a--){let r=t[a];if(e&&"UserCancel"in r.event_data)return!1;if(!("AgentMessage"in r.event_data))return!0;let _=r.event_data.AgentMessage.update;if("content"in _&&("interaction_finished"in _.content||e&&"interaction_update"in _.content&&"main_agent"in _.content.interaction_update&&"completed"in _.content.interaction_update.main_agent)||"InteractionFinished"in _||e&&"OrchestratorUpdate"in _&&"GeneratedResponse"in _.OrchestratorUpdate.update)return!1}return!0}function de(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 h(t){let a=`${c(t.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,r={token:"",expiry:new Date(0)},_=t.fetch||fetch,i=async()=>{let o=await _(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(r.expiry.getTime()<=Date.now()-1e3){let o=await i(),n=await ye(t.promptqlGraphQLUrl,o.token,t.projectId,_);r.token=n;let p=new Date(o.expiry);if(Number.isNaN(p.getTime())){let y=new Date;y.setHours(1),r.expiry=y}else r.expiry=p}return r.token}}var ye=async(t,e,a,r=fetch)=>{let _=await r(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(_.status){case 200:{let i=await _.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 _.text();throw new Error(i)}}};function x(t){return{Authorization:`pat ${t}`}}import{ApolloClient as ce,ApolloLink as le,HttpLink as me,InMemoryCache as be}from"@apollo/client";import{SetContextLink as Ie}from"@apollo/client/link/context";import{GraphQLWsLink as Me}from"@apollo/client/link/subscriptions";import{OperationTypeNode as ge}from"graphql";import{createClient as Se}from"graphql-ws";var ee=t=>{let e=new me({uri:t.url,fetch:t.fetch,headers:t.headers}),a=async n=>{let p=await t.getAuthToken();return{headers:{"User-Agent":u,...n,Authorization:`Bearer ${p}`}}},r=Se({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),_=new Me(r),i=new Ie(({headers:n})=>a(n)),o=le.split(({operationType:n})=>n===ge.SUBSCRIPTION,_,i.concat(e));return{client:new ce({link:o,cache:new be}),wsClient:r}};function ot(t,e){if(!e.length)return[];if(!t.length)return e;let a=t[t.length-1];if(!a)return e;let r=BigInt(a.thread_event_id),_=e.length-1;for(;_>=0;_--){let i=e[_];if(BigInt(i?.thread_event_id)<=r)break}return e.slice(_+1)}function pt(t){return"UserMessage"in t?t.UserMessage:null}function ut(t){return"UserCancel"in t?t.UserCancel:null}function st(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 dt(t){let e=C(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function yt(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,messageId:t.AgentMessage.message_id}:!("OrchestratorUpdate"in t.AgentMessage.update)||!("GeneratedResponse"in t.AgentMessage.update.OrchestratorUpdate.update)?null:{...t.AgentMessage.update.OrchestratorUpdate.update.GeneratedResponse.response,messageId:t.AgentMessage.message_id}:null}function ct(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 lt(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 mt(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 f(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function bt(t){let e=f(t);return!e||!("Started"in e)?null:e.Started}function It(t){let e=f(t);return!e||!("Completed"in e)?null:e.Completed}function Mt(t){let e=f(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function gt(t){return!("AgentMessage"in t)||!("StartingOrchestrator"in t.AgentMessage.update)?null:t.AgentMessage.update.StartingOrchestrator}function C(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.OrchestratorUpdate.update}function d(t){let e=C(t);return!e||!("ContextExplorerUpdate"in e)?null:e.ContextExplorerUpdate.update}function St(t){let e=d(t);return!e||!("Started"in e)?null:e.Started}function At(t){let e=d(t);return!e||!("Completed"in e)?null:e.Completed}function B(t){let e=d(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function ht(t){let e=B(t);return!e||!("Started"in e)?null:e.Started}function xt(t){let e=B(t);return!e||!("Completed"in e)?null:e.Completed}function ft(t){let e=B(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function k(t){let e=d(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function Ct(t){let e=k(t);return!e||!("Started"in e)?null:e.Started}function Bt(t){let e=k(t);return!e||!("Completed"in e)?null:e.Completed}function kt(t){let e=k(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function s(t){let e=d(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function Ot(t){let e=s(t);return!e||!("Started"in e)?null:e.Started}function vt(t){let e=s(t);return!e||!("Completed"in e)?null:e.Completed}function Et(t){let e=s(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function Tt(t){let e=s(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function Pt(t){let e=s(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function Rt(t){let e=s(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function O(t){let e=C(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function Ut(t){let e=O(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function wt(t){let e=O(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function Ft(t){let e=O(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function jt(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,messageId:t.AgentMessage.message_id}:"Errored"in e?{status:"errored",timestamp:e.Errored.errored_at,messageId:t.AgentMessage.message_id,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,messageId:t.AgentMessage.message_id}:"AgentDeclined"in e?{status:"agent_declined",timestamp:e.AgentDeclined.declined_at,reason:e.AgentDeclined.reason,messageId:t.AgentMessage.message_id}:"ServerCancelled"in e?{status:"server_cancelled",timestamp:e.ServerCancelled.cancelled_at,messageId:t.AgentMessage.message_id}:{status:"unknown",messageId:t.AgentMessage.message_id}}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",messageId:t.AgentMessage.message_id,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",messageId:t.AgentMessage.message_id,timestamp:t.AgentMessage.update.timestamp}:"user_cancelled"in e?{status:"user_cancelled",messageId:t.AgentMessage.message_id,timestamp:t.AgentMessage.update.timestamp}:"completed"in e?{status:"completed",messageId:t.AgentMessage.message_id,timestamp:t.AgentMessage.update.timestamp,warnings:e.completed.warnings}:{status:"unknown",messageId:t.AgentMessage.message_id}}return null}function Vt(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}}function te(t){return`https://promptql.${t}/playground-v2-hge/v1/graphql`}var l=class{controlPlaneUrl;options;defaultTimezone;getAuthTokenFn;project;client;wsClient;constructor(e){if(this.options=e,!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");this.defaultTimezone=e.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone;let a=e.controlPlaneHost?c(e.controlPlaneHost):"https://data.pro.hasura.io";this.controlPlaneUrl=`${a}/v1/graphql`}async getAuthToken(){if(typeof this.getAuthTokenFn=="function")return this.getAuthTokenFn();let e=await this.getProjectInfo();return this.getAuthTokenFn=h({promptqlGraphQLUrl:e.promptqlGraphQLUrl,authHost:this.options.authHost,headers:x(this.options.serviceAccountToken),fetch:this.options.fetch}),this.getAuthTokenFn()}async getGraphQLClient(){if(this.client)return this.client;let e=await this.getProjectInfo(),{client:a,wsClient:r}=ee({getAuthToken:this.getAuthToken.bind(this),url:e.promptqlGraphQLUrl,fetch:this.options.fetch,headers:this.options.headers});return this.wsClient=r,this.client=a,this.client}async getProjectInfo(){if(this.project)return this.project;let e={operationName:"GetDdnProjects",query:"query GetDdnProjects { ddn_projects(limit: 1) { id name private_ddn { fqdn path_routing_context path_routing_enabled }}}"},r=await(typeof this.options.fetch=="function"?this.options.fetch:fetch)(this.controlPlaneUrl,{method:"POST",headers:{...x(this.options.serviceAccountToken),"User-Agent":u,"Content-Type":"application/json"},body:JSON.stringify(e)});if(r.status!==200){let o=r.body?await r.text():r.statusText;throw new Error(`[${r.status}] failed to get project info: ${o}`)}let _=await r.json();if(!_.data?.ddn_projects?.length)throw new Error("Project not found");let i=_.data.ddn_projects[0];return this.project={projectId:i.id,projectName:i.name,projectHost:`https://${i.name}.${i.private_ddn.fqdn}`,promptqlConsoleUrl:`https://prompt.ql.app/project/${i.name}`,promptqlGraphQLUrl:te(i.private_ddn.fqdn)},this.project}close(){if(this.wsClient&&(this.wsClient.dispose(),this.wsClient=void 0),this.client){try{this.client.stop?.()}catch{}try{this.client.clearStore?.()}catch{}this.client=void 0,this.project=void 0,this.getAuthTokenFn=void 0}}};var m=class{api;constructor(e){this.api=e}async listMetadataByThreadId(e){let a=await this.api.getProjectInfo(),r=await this.api.getGraphQLClient();return N(r,a.projectId,e)}async download(e,a){let r=await this.api.getProjectInfo(),_=await this.api.getAuthToken();return W(r.projectHost,e,a,ae(_),this.api.options.fetch)}async getMetadata(e,a){let r=await this.api.getProjectInfo(),_=await this.api.getAuthToken();return z(r.projectHost,e,a,ae(_),this.api.options.fetch)}};function ae(t){return{Authorization:`Bearer ${t}`,"User-Agent":u}}var b=class{api;constructor(e){this.api=e}info(){return this.api.getProjectInfo()}};var I=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return g(a,{...e,limit:e.limit&&e.limit>0?e.limit:10})}async getByName(e){let a=await this.api.getGraphQLClient();return g(a,{where:{name:{_eq:e}},limit:1}).then(r=>r.length?r[0]??null:null)}async create(e){let a=await this.api.getGraphQLClient();return D(a,e)}};import{from as re,switchMap as _e}from"rxjs";var M=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return G(a,{...e,limit:e.limit&&e.limit>0?e.limit:10})}async get(e){if(!e)throw new Error("threadId is required");let a=await this.api.getGraphQLClient();return Q(a,e)}async start(e){let a=await this.api.getProjectInfo(),r=await this.api.getGraphQLClient();return L(r,{...e,projectId:a.projectId,buildId:e.buildId||this.api.options.buildId,timezone:e.timezone||this.api.defaultTimezone})}async getEvents(e,a){let r=await this.api.getGraphQLClient();return A(r,e,a)}async sendMessage(e){let a=await this.api.getGraphQLClient();return K(a,{...e,timezone:e.timezone||this.api.defaultTimezone})}async cancelAgentMessage(e){let a=await this.api.getGraphQLClient();return J(a,e)}subscribeEvents(e,a){return re(this.api.getGraphQLClient()).pipe(_e(r=>H(r,e,a)))}streamMessageEvents(e,a){return re(this.api.getGraphQLClient()).pipe(_e(r=>$(r,e,a)))}};var ne=class{constructor(e){let a=new l(e);this.api=a,this.thread=new M(a),this.project=new b(a),this.room=new I(a),this.artifact=new m(a)}api;thread;project;room;artifact;close(){this.api.close()}};export{ne as PromptQLSdk,q as ROOM_NAME_PATTERN,u as USER_AGENT,te as buildPromptQLUrl,J as cancelAgentMessage,ee as createApolloClient,h as createPromptQLAuthTokenGenerator,D as createRoom,ot as diffThreadEvents,W as downloadArtifactData,yt as getAgentGeneratedResponse,lt as getAgentInteractionDecisionAcceptInteractionEvent,mt as getAgentInteractionDecisionDeclineInteractionEvent,jt as getAgentInteractionFinishedEvent,ct as getAgentMessageProcessingStartedEvent,At as getAgentOrchestratorContextExplorerCompletedEvent,St as getAgentOrchestratorContextExplorerStartedEvent,d as getAgentOrchestratorContextExplorerUpdateEvent,Et as getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,Tt as getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,vt as getAgentOrchestratorSchemaExplorerCompletedEvent,Pt as getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,Rt as getAgentOrchestratorSchemaExplorerSchemaExploredEvent,Ot as getAgentOrchestratorSchemaExplorerStartedEvent,s as getAgentOrchestratorSchemaExplorerUpdateEvent,kt as getAgentOrchestratorSchemaTasksGeneratedEvent,Bt as getAgentOrchestratorSchemaTasksGenerationCompletedEvent,Ct as getAgentOrchestratorSchemaTasksGenerationStartedEvent,k as getAgentOrchestratorSchemaTasksGenerationUpdateEvent,Ut as getAgentOrchestratorStepProgrammerEvent,Ft as getAgentOrchestratorStepSavedProgramRunnerEvent,wt as getAgentOrchestratorStepUiProgrammerEvent,O as getAgentOrchestratorStepUpdateEvent,C as getAgentOrchestratorUpdateEvent,xt as getAgentOrchestratorWikiExplorerCompletedEvent,ht as getAgentOrchestratorWikiExplorerStartedEvent,B as getAgentOrchestratorWikiExplorerUpdateEvent,ft as getAgentOrchestratorWikiInfoGeneratedEvent,st as getAgentPlanGenerationStartedEvent,dt as getAgentPlanStepGeneratedEvent,It as getAgentPlanningDecisionCompletedEvent,Mt as getAgentPlanningDecisionPlanningRequiredEvent,bt as getAgentPlanningDecisionStartedEvent,f as getAgentPlanningDecisionUpdateEvent,gt as getAgentStartingOrchestratorEvent,z as getArtifactMetadata,Q as getThread,Vt as getThreadEventMessageId,A as getThreadEvents,ut as getUserCancelEvent,pt as getUserMessageEvent,se as isInteractionAnalyzing,N as listArtifactMetadataByThreadId,g as listRooms,G as listThreads,K as sendThreadMessage,L as startThread,$ as streamThreadMessageEvents,H 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.24",
4
+ "version": "2.0.0-alpha.25",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Hasura",
7
7
  "homepage": "https://promptql.hasura.io",