@hasura/promptql 2.0.0-alpha.30 → 2.0.0-alpha.32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -3224,7 +3224,7 @@ declare function streamThreadMessageEvents(client: ApolloClient, threadId: strin
3224
3224
  */
3225
3225
  declare function isInteractionAnalyzing(events: ThreadEvent[], skipAnalysis?: boolean): boolean;
3226
3226
 
3227
- type WikiPageNamespace = "guide" | "regular" | "promptql";
3227
+ type WikiPageNamespace = "guide" | "regular";
3228
3228
  type WikiPage = WikiPageV1 & {
3229
3229
  page_id: string;
3230
3230
  created_at: string;
@@ -3233,6 +3233,8 @@ type WikiPage = WikiPageV1 & {
3233
3233
  type ListWikiPageArgs = {
3234
3234
  project_id?: string;
3235
3235
  namespace?: WikiPageNamespace;
3236
+ query?: string;
3237
+ include_stub?: boolean;
3236
3238
  offset?: number;
3237
3239
  limit?: number;
3238
3240
  order_by?: "created_at" | "last_modified_at" | "page_id";
@@ -3242,6 +3244,10 @@ type ListWikiPageArgs = {
3242
3244
  * List wiki pages of the current project.
3243
3245
  */
3244
3246
  declare function listWikiPages(client: ApolloClient, args: ListWikiPageArgs): Promise<WikiPage[]>;
3247
+ /**
3248
+ * Get wiki page by id.
3249
+ */
3250
+ declare function getWikiPage(client: ApolloClient, project_id: string, namespace: string, id: string): Promise<WikiPage | null | undefined>;
3245
3251
 
3246
3252
  /**
3247
3253
  * A low-level API class for PromptQL.
@@ -3368,9 +3374,13 @@ declare class Wiki {
3368
3374
  private api;
3369
3375
  constructor(api: PromptQLApi);
3370
3376
  /**
3371
- * List PromptQL rooms. The default limit is 10.
3377
+ * List PromptQL wiki pages.
3372
3378
  */
3373
3379
  list(args: ListWikiPageArgs): Promise<WikiPage[]>;
3380
+ /**
3381
+ * Get a PromptQL wiki page by primary keys.
3382
+ */
3383
+ get(namespace: WikiPageNamespace, id: string): Promise<WikiPage | null | undefined>;
3374
3384
  }
3375
3385
 
3376
3386
  /**
@@ -3589,4 +3599,4 @@ declare function getThreadEventMessageId(event: ThreadEvent$1 | undefined): stri
3589
3599
  */
3590
3600
  declare function buildPromptQLUrl(fqdn: string): string;
3591
3601
 
3592
- export { type AgentGeneratedResponse, type AgentLearningUpdate, type AgentLoopAction, type AgentLoopActionLegacy, type AgentLoopActionResult, type AgentLoopActionUpdate, type AgentLoopTerminalAction, type AgentLoopUpdate, type AgentTrigger, type AgentUpdate, type AgentUpdateContent, type ApolloClientOptions, type ArtifactDataPreview, type ArtifactError, type ArtifactErrorV1, type ArtifactId, type ArtifactMetadata, type ArtifactReference, type ArtifactReference1, type ArtifactType, type ArtifactType2, type ArtifactUpdate, type ArtifactUpdate1, type AssumptionFactCheck, type BuildError, type BuildErrorV1, type BuiltUi, type BuiltUi1, CancelAgentMessageMutationVariables, type CheckedAssumption, type CheckedTopic, type CodeBlock, type CodeError, type CodeErrorV1, type CodeExecutionComplete, type CodeOutputAnalysis, type CodeOutputAnalyzed, type ComponentResponse, type ComponentResponse1, type ComponentResponse2, type ComponentResponse3, type ComponentResponse4, type ComponentResponse5, type ConfidenceAnalysis, type ConfidenceAnalysisLlmUsage, type ConfidenceAnalysisUpdate, type ContextExplorerCompleted, type ContextExplorerStarted, type ContextExplorerUpdate, type CopyFileEntry, type CreateRoomArguments, type DataArtifactUpdated, type DataArtifactUpdatedV1, type DecideNextStepsFields, type EventOfKind, type ExecuteProgramRequestData, type ExternalKnowledgeExplorerAttempt, type ExternalKnowledgeExplorerAttempt1, type ExternalKnowledgeSummary, type FactSource, type FederatedWikiName, type GeneratedCode, type GeneratedFile, type GeneratedResponse, type GeneratedUiCode, type GetThreadEventOptions, GetThreadsQueryVariables, type IPromptQLSdk, type InteractionDecision, type InteractionDecisionAccept, type InteractionDecisionDecline, type InteractionDecisionUpdate, type InteractionFinishedEvent, type InteractionFinishedUpdate, type InteractionOutcome, type InteractionOutcomeStatus, type InteractionUpdate, type InternalError, type InternalErrorV1, type InternalUpdate, type InterruptedByTrigger, type KeysOfUnion, type LearningBlockId, type LearningSuggestion, type LearningSuggestionUpdate, type LearningSuggestionUpdateV1, type ListWikiPageArgs, type LlmResponse, type LlmUsage, type LlmUsageEvent, type LlmUsageEventV1, type MessageProcessingStarted, type MessageProcessingUpdate, type NeedsSupportUpdate, type OrchestratorUpdate, Order_By, type OutputEmitted, type OutputEmittedV1, type PipelineProgress, type PipelineProgressV1, type PipelineProgressV2, type PipelineRunStepDetails, type PipelineSourceState, type PlanGenerationStarted, type PlanStepGenerated, type PlanningDecisionCompleted, type PlanningDecisionPlanningRequired, type PlanningDecisionStarted, type PlanningDecisionUpdate, type ProgramExecuteOutcome, type ProgramExecuteUpdate, type ProgramId, type ProgramPackageName, type ProgramRunEvent, type ProgramRunnerAction, type ProgrammerUpdate, type ProjectInfoOutput, PromptQLSdk, type PromptQLSdkOptions, type PromptQlUserId, type PythonRunStepDetails, ROOM_NAME_REGEX, type ResponseGenerationUpdate, type ResponseTruncation, RoomFragment, type RoomVisibilityType, type RunFinished, type RunFinishedOutcome, type RunFinishedV1, type RunProgramRequest, type RunSavedProgramRequest, type RunStarted, type RunStartedV1, type RunStepDetails, type SavedProgramRunnerUpdate, type SavedProgramRunnerUpdateV0, type ScheduledAgentTriggerEventId, type ScheduledAgentTriggerId, type ScheduledAgentTriggerPayload, type ScheduledAgentTriggerPayloadV1, type ScheduledAgentTriggerType, type SchemaContext, type SchemaExplored, type SchemaExplorerCompleted, type SchemaExplorerStarted, type SchemaExplorerUpdate, type SchemaTask, type SchemaTasksGenerationCompleted, type SchemaTasksGenerationStarted, type SchemaTasksGenerationUpdate, type SendMessageToThreadArguments, type SendMessageToThreadOutput, SendThreadMessageMutationVariables, type ServerMetadata, type ShelfActionEvent, type ShelfUpdate, type ShelfUpdateV1, type SkillType, type SocialFeedRatingLlmUsage, 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 StartThreadArguments, StartThreadMutationVariables, type StartThreadOutput, type StartingOrchestrator, type StepExecutionFinished, type StepExecutionFinishedV1, type StepExecutionStarted, type StepExecutionStartedV1, type StepUpdate, type StreamThreadEventOptions, type TargetWikiPage, type TasksGenerated, type Teaching, type TeachingId, type ThreadEvent, type ThreadEvent$1 as ThreadEventData, ThreadFragment, type TransactionId, type TzWrapper, USER_AGENT, type UiBuildFailure, type UiBuildRunStepDetails, type UiMetadata, type UiProgrammerUpdate, type UserCancel, type UserCancelEvent, type UserMessage, type UserMessageEvent, type UserUpload, type VersionedAgentUpdate, type VersionedOrUnversionedAgentUpdate, type Warning, type WikiAuditId, type WikiChange, type WikiContent, type WikiDelta, type WikiExplorerCompleted, type WikiExplorerStarted, type WikiExplorerUpdate, type WikiGenerationUpdate, type WikiInfoGenerated, type WikiLearningSuggestionUpdate, type WikiPage, type WikiPageNamespace, type WikiPagePreview, type WikiPageSearchResult, type WikiPageV1, type WikiSection, type WikiSelectionUpdate, type WikiTitle, buildPromptQLUrl, cancelAgentMessage, createApolloClient, 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, listWikiPages, sendThreadMessage, startThread, streamThreadMessageEvents, subscribeThreadEvents, validateRoomName };
3602
+ export { type AgentGeneratedResponse, type AgentLearningUpdate, type AgentLoopAction, type AgentLoopActionLegacy, type AgentLoopActionResult, type AgentLoopActionUpdate, type AgentLoopTerminalAction, type AgentLoopUpdate, type AgentTrigger, type AgentUpdate, type AgentUpdateContent, type ApolloClientOptions, type ArtifactDataPreview, type ArtifactError, type ArtifactErrorV1, type ArtifactId, type ArtifactMetadata, type ArtifactReference, type ArtifactReference1, type ArtifactType, type ArtifactType2, type ArtifactUpdate, type ArtifactUpdate1, type AssumptionFactCheck, type BuildError, type BuildErrorV1, type BuiltUi, type BuiltUi1, CancelAgentMessageMutationVariables, type CheckedAssumption, type CheckedTopic, type CodeBlock, type CodeError, type CodeErrorV1, type CodeExecutionComplete, type CodeOutputAnalysis, type CodeOutputAnalyzed, type ComponentResponse, type ComponentResponse1, type ComponentResponse2, type ComponentResponse3, type ComponentResponse4, type ComponentResponse5, type ConfidenceAnalysis, type ConfidenceAnalysisLlmUsage, type ConfidenceAnalysisUpdate, type ContextExplorerCompleted, type ContextExplorerStarted, type ContextExplorerUpdate, type CopyFileEntry, type CreateRoomArguments, type DataArtifactUpdated, type DataArtifactUpdatedV1, type DecideNextStepsFields, type EventOfKind, type ExecuteProgramRequestData, type ExternalKnowledgeExplorerAttempt, type ExternalKnowledgeExplorerAttempt1, type ExternalKnowledgeSummary, type FactSource, type FederatedWikiName, type GeneratedCode, type GeneratedFile, type GeneratedResponse, type GeneratedUiCode, type GetThreadEventOptions, GetThreadsQueryVariables, type IPromptQLSdk, type InteractionDecision, type InteractionDecisionAccept, type InteractionDecisionDecline, type InteractionDecisionUpdate, type InteractionFinishedEvent, type InteractionFinishedUpdate, type InteractionOutcome, type InteractionOutcomeStatus, type InteractionUpdate, type InternalError, type InternalErrorV1, type InternalUpdate, type InterruptedByTrigger, type KeysOfUnion, type LearningBlockId, type LearningSuggestion, type LearningSuggestionUpdate, type LearningSuggestionUpdateV1, type ListWikiPageArgs, type LlmResponse, type LlmUsage, type LlmUsageEvent, type LlmUsageEventV1, type MessageProcessingStarted, type MessageProcessingUpdate, type NeedsSupportUpdate, type OrchestratorUpdate, Order_By, type OutputEmitted, type OutputEmittedV1, type PipelineProgress, type PipelineProgressV1, type PipelineProgressV2, type PipelineRunStepDetails, type PipelineSourceState, type PlanGenerationStarted, type PlanStepGenerated, type PlanningDecisionCompleted, type PlanningDecisionPlanningRequired, type PlanningDecisionStarted, type PlanningDecisionUpdate, type ProgramExecuteOutcome, type ProgramExecuteUpdate, type ProgramId, type ProgramPackageName, type ProgramRunEvent, type ProgramRunnerAction, type ProgrammerUpdate, type ProjectInfoOutput, PromptQLSdk, type PromptQLSdkOptions, type PromptQlUserId, type PythonRunStepDetails, ROOM_NAME_REGEX, type ResponseGenerationUpdate, type ResponseTruncation, RoomFragment, type RoomVisibilityType, type RunFinished, type RunFinishedOutcome, type RunFinishedV1, type RunProgramRequest, type RunSavedProgramRequest, type RunStarted, type RunStartedV1, type RunStepDetails, type SavedProgramRunnerUpdate, type SavedProgramRunnerUpdateV0, type ScheduledAgentTriggerEventId, type ScheduledAgentTriggerId, type ScheduledAgentTriggerPayload, type ScheduledAgentTriggerPayloadV1, type ScheduledAgentTriggerType, type SchemaContext, type SchemaExplored, type SchemaExplorerCompleted, type SchemaExplorerStarted, type SchemaExplorerUpdate, type SchemaTask, type SchemaTasksGenerationCompleted, type SchemaTasksGenerationStarted, type SchemaTasksGenerationUpdate, type SendMessageToThreadArguments, type SendMessageToThreadOutput, SendThreadMessageMutationVariables, type ServerMetadata, type ShelfActionEvent, type ShelfUpdate, type ShelfUpdateV1, type SkillType, type SocialFeedRatingLlmUsage, 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 StartThreadArguments, StartThreadMutationVariables, type StartThreadOutput, type StartingOrchestrator, type StepExecutionFinished, type StepExecutionFinishedV1, type StepExecutionStarted, type StepExecutionStartedV1, type StepUpdate, type StreamThreadEventOptions, type TargetWikiPage, type TasksGenerated, type Teaching, type TeachingId, type ThreadEvent, type ThreadEvent$1 as ThreadEventData, ThreadFragment, type TransactionId, type TzWrapper, USER_AGENT, type UiBuildFailure, type UiBuildRunStepDetails, type UiMetadata, type UiProgrammerUpdate, type UserCancel, type UserCancelEvent, type UserMessage, type UserMessageEvent, type UserUpload, type VersionedAgentUpdate, type VersionedOrUnversionedAgentUpdate, type Warning, type WikiAuditId, type WikiChange, type WikiContent, type WikiDelta, type WikiExplorerCompleted, type WikiExplorerStarted, type WikiExplorerUpdate, type WikiGenerationUpdate, type WikiInfoGenerated, type WikiLearningSuggestionUpdate, type WikiPage, type WikiPageNamespace, type WikiPagePreview, type WikiPageSearchResult, type WikiPageV1, type WikiSection, type WikiSelectionUpdate, type WikiTitle, buildPromptQLUrl, cancelAgentMessage, createApolloClient, 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, getWikiPage, isInteractionAnalyzing, listArtifactMetadataByThreadId, listRooms, listThreads, listWikiPages, sendThreadMessage, startThread, streamThreadMessageEvents, subscribeThreadEvents, validateRoomName };
package/dist/index.d.ts CHANGED
@@ -3224,7 +3224,7 @@ declare function streamThreadMessageEvents(client: ApolloClient, threadId: strin
3224
3224
  */
3225
3225
  declare function isInteractionAnalyzing(events: ThreadEvent[], skipAnalysis?: boolean): boolean;
3226
3226
 
3227
- type WikiPageNamespace = "guide" | "regular" | "promptql";
3227
+ type WikiPageNamespace = "guide" | "regular";
3228
3228
  type WikiPage = WikiPageV1 & {
3229
3229
  page_id: string;
3230
3230
  created_at: string;
@@ -3233,6 +3233,8 @@ type WikiPage = WikiPageV1 & {
3233
3233
  type ListWikiPageArgs = {
3234
3234
  project_id?: string;
3235
3235
  namespace?: WikiPageNamespace;
3236
+ query?: string;
3237
+ include_stub?: boolean;
3236
3238
  offset?: number;
3237
3239
  limit?: number;
3238
3240
  order_by?: "created_at" | "last_modified_at" | "page_id";
@@ -3242,6 +3244,10 @@ type ListWikiPageArgs = {
3242
3244
  * List wiki pages of the current project.
3243
3245
  */
3244
3246
  declare function listWikiPages(client: ApolloClient, args: ListWikiPageArgs): Promise<WikiPage[]>;
3247
+ /**
3248
+ * Get wiki page by id.
3249
+ */
3250
+ declare function getWikiPage(client: ApolloClient, project_id: string, namespace: string, id: string): Promise<WikiPage | null | undefined>;
3245
3251
 
3246
3252
  /**
3247
3253
  * A low-level API class for PromptQL.
@@ -3368,9 +3374,13 @@ declare class Wiki {
3368
3374
  private api;
3369
3375
  constructor(api: PromptQLApi);
3370
3376
  /**
3371
- * List PromptQL rooms. The default limit is 10.
3377
+ * List PromptQL wiki pages.
3372
3378
  */
3373
3379
  list(args: ListWikiPageArgs): Promise<WikiPage[]>;
3380
+ /**
3381
+ * Get a PromptQL wiki page by primary keys.
3382
+ */
3383
+ get(namespace: WikiPageNamespace, id: string): Promise<WikiPage | null | undefined>;
3374
3384
  }
3375
3385
 
3376
3386
  /**
@@ -3589,4 +3599,4 @@ declare function getThreadEventMessageId(event: ThreadEvent$1 | undefined): stri
3589
3599
  */
3590
3600
  declare function buildPromptQLUrl(fqdn: string): string;
3591
3601
 
3592
- export { type AgentGeneratedResponse, type AgentLearningUpdate, type AgentLoopAction, type AgentLoopActionLegacy, type AgentLoopActionResult, type AgentLoopActionUpdate, type AgentLoopTerminalAction, type AgentLoopUpdate, type AgentTrigger, type AgentUpdate, type AgentUpdateContent, type ApolloClientOptions, type ArtifactDataPreview, type ArtifactError, type ArtifactErrorV1, type ArtifactId, type ArtifactMetadata, type ArtifactReference, type ArtifactReference1, type ArtifactType, type ArtifactType2, type ArtifactUpdate, type ArtifactUpdate1, type AssumptionFactCheck, type BuildError, type BuildErrorV1, type BuiltUi, type BuiltUi1, CancelAgentMessageMutationVariables, type CheckedAssumption, type CheckedTopic, type CodeBlock, type CodeError, type CodeErrorV1, type CodeExecutionComplete, type CodeOutputAnalysis, type CodeOutputAnalyzed, type ComponentResponse, type ComponentResponse1, type ComponentResponse2, type ComponentResponse3, type ComponentResponse4, type ComponentResponse5, type ConfidenceAnalysis, type ConfidenceAnalysisLlmUsage, type ConfidenceAnalysisUpdate, type ContextExplorerCompleted, type ContextExplorerStarted, type ContextExplorerUpdate, type CopyFileEntry, type CreateRoomArguments, type DataArtifactUpdated, type DataArtifactUpdatedV1, type DecideNextStepsFields, type EventOfKind, type ExecuteProgramRequestData, type ExternalKnowledgeExplorerAttempt, type ExternalKnowledgeExplorerAttempt1, type ExternalKnowledgeSummary, type FactSource, type FederatedWikiName, type GeneratedCode, type GeneratedFile, type GeneratedResponse, type GeneratedUiCode, type GetThreadEventOptions, GetThreadsQueryVariables, type IPromptQLSdk, type InteractionDecision, type InteractionDecisionAccept, type InteractionDecisionDecline, type InteractionDecisionUpdate, type InteractionFinishedEvent, type InteractionFinishedUpdate, type InteractionOutcome, type InteractionOutcomeStatus, type InteractionUpdate, type InternalError, type InternalErrorV1, type InternalUpdate, type InterruptedByTrigger, type KeysOfUnion, type LearningBlockId, type LearningSuggestion, type LearningSuggestionUpdate, type LearningSuggestionUpdateV1, type ListWikiPageArgs, type LlmResponse, type LlmUsage, type LlmUsageEvent, type LlmUsageEventV1, type MessageProcessingStarted, type MessageProcessingUpdate, type NeedsSupportUpdate, type OrchestratorUpdate, Order_By, type OutputEmitted, type OutputEmittedV1, type PipelineProgress, type PipelineProgressV1, type PipelineProgressV2, type PipelineRunStepDetails, type PipelineSourceState, type PlanGenerationStarted, type PlanStepGenerated, type PlanningDecisionCompleted, type PlanningDecisionPlanningRequired, type PlanningDecisionStarted, type PlanningDecisionUpdate, type ProgramExecuteOutcome, type ProgramExecuteUpdate, type ProgramId, type ProgramPackageName, type ProgramRunEvent, type ProgramRunnerAction, type ProgrammerUpdate, type ProjectInfoOutput, PromptQLSdk, type PromptQLSdkOptions, type PromptQlUserId, type PythonRunStepDetails, ROOM_NAME_REGEX, type ResponseGenerationUpdate, type ResponseTruncation, RoomFragment, type RoomVisibilityType, type RunFinished, type RunFinishedOutcome, type RunFinishedV1, type RunProgramRequest, type RunSavedProgramRequest, type RunStarted, type RunStartedV1, type RunStepDetails, type SavedProgramRunnerUpdate, type SavedProgramRunnerUpdateV0, type ScheduledAgentTriggerEventId, type ScheduledAgentTriggerId, type ScheduledAgentTriggerPayload, type ScheduledAgentTriggerPayloadV1, type ScheduledAgentTriggerType, type SchemaContext, type SchemaExplored, type SchemaExplorerCompleted, type SchemaExplorerStarted, type SchemaExplorerUpdate, type SchemaTask, type SchemaTasksGenerationCompleted, type SchemaTasksGenerationStarted, type SchemaTasksGenerationUpdate, type SendMessageToThreadArguments, type SendMessageToThreadOutput, SendThreadMessageMutationVariables, type ServerMetadata, type ShelfActionEvent, type ShelfUpdate, type ShelfUpdateV1, type SkillType, type SocialFeedRatingLlmUsage, 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 StartThreadArguments, StartThreadMutationVariables, type StartThreadOutput, type StartingOrchestrator, type StepExecutionFinished, type StepExecutionFinishedV1, type StepExecutionStarted, type StepExecutionStartedV1, type StepUpdate, type StreamThreadEventOptions, type TargetWikiPage, type TasksGenerated, type Teaching, type TeachingId, type ThreadEvent, type ThreadEvent$1 as ThreadEventData, ThreadFragment, type TransactionId, type TzWrapper, USER_AGENT, type UiBuildFailure, type UiBuildRunStepDetails, type UiMetadata, type UiProgrammerUpdate, type UserCancel, type UserCancelEvent, type UserMessage, type UserMessageEvent, type UserUpload, type VersionedAgentUpdate, type VersionedOrUnversionedAgentUpdate, type Warning, type WikiAuditId, type WikiChange, type WikiContent, type WikiDelta, type WikiExplorerCompleted, type WikiExplorerStarted, type WikiExplorerUpdate, type WikiGenerationUpdate, type WikiInfoGenerated, type WikiLearningSuggestionUpdate, type WikiPage, type WikiPageNamespace, type WikiPagePreview, type WikiPageSearchResult, type WikiPageV1, type WikiSection, type WikiSelectionUpdate, type WikiTitle, buildPromptQLUrl, cancelAgentMessage, createApolloClient, 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, listWikiPages, sendThreadMessage, startThread, streamThreadMessageEvents, subscribeThreadEvents, validateRoomName };
3602
+ export { type AgentGeneratedResponse, type AgentLearningUpdate, type AgentLoopAction, type AgentLoopActionLegacy, type AgentLoopActionResult, type AgentLoopActionUpdate, type AgentLoopTerminalAction, type AgentLoopUpdate, type AgentTrigger, type AgentUpdate, type AgentUpdateContent, type ApolloClientOptions, type ArtifactDataPreview, type ArtifactError, type ArtifactErrorV1, type ArtifactId, type ArtifactMetadata, type ArtifactReference, type ArtifactReference1, type ArtifactType, type ArtifactType2, type ArtifactUpdate, type ArtifactUpdate1, type AssumptionFactCheck, type BuildError, type BuildErrorV1, type BuiltUi, type BuiltUi1, CancelAgentMessageMutationVariables, type CheckedAssumption, type CheckedTopic, type CodeBlock, type CodeError, type CodeErrorV1, type CodeExecutionComplete, type CodeOutputAnalysis, type CodeOutputAnalyzed, type ComponentResponse, type ComponentResponse1, type ComponentResponse2, type ComponentResponse3, type ComponentResponse4, type ComponentResponse5, type ConfidenceAnalysis, type ConfidenceAnalysisLlmUsage, type ConfidenceAnalysisUpdate, type ContextExplorerCompleted, type ContextExplorerStarted, type ContextExplorerUpdate, type CopyFileEntry, type CreateRoomArguments, type DataArtifactUpdated, type DataArtifactUpdatedV1, type DecideNextStepsFields, type EventOfKind, type ExecuteProgramRequestData, type ExternalKnowledgeExplorerAttempt, type ExternalKnowledgeExplorerAttempt1, type ExternalKnowledgeSummary, type FactSource, type FederatedWikiName, type GeneratedCode, type GeneratedFile, type GeneratedResponse, type GeneratedUiCode, type GetThreadEventOptions, GetThreadsQueryVariables, type IPromptQLSdk, type InteractionDecision, type InteractionDecisionAccept, type InteractionDecisionDecline, type InteractionDecisionUpdate, type InteractionFinishedEvent, type InteractionFinishedUpdate, type InteractionOutcome, type InteractionOutcomeStatus, type InteractionUpdate, type InternalError, type InternalErrorV1, type InternalUpdate, type InterruptedByTrigger, type KeysOfUnion, type LearningBlockId, type LearningSuggestion, type LearningSuggestionUpdate, type LearningSuggestionUpdateV1, type ListWikiPageArgs, type LlmResponse, type LlmUsage, type LlmUsageEvent, type LlmUsageEventV1, type MessageProcessingStarted, type MessageProcessingUpdate, type NeedsSupportUpdate, type OrchestratorUpdate, Order_By, type OutputEmitted, type OutputEmittedV1, type PipelineProgress, type PipelineProgressV1, type PipelineProgressV2, type PipelineRunStepDetails, type PipelineSourceState, type PlanGenerationStarted, type PlanStepGenerated, type PlanningDecisionCompleted, type PlanningDecisionPlanningRequired, type PlanningDecisionStarted, type PlanningDecisionUpdate, type ProgramExecuteOutcome, type ProgramExecuteUpdate, type ProgramId, type ProgramPackageName, type ProgramRunEvent, type ProgramRunnerAction, type ProgrammerUpdate, type ProjectInfoOutput, PromptQLSdk, type PromptQLSdkOptions, type PromptQlUserId, type PythonRunStepDetails, ROOM_NAME_REGEX, type ResponseGenerationUpdate, type ResponseTruncation, RoomFragment, type RoomVisibilityType, type RunFinished, type RunFinishedOutcome, type RunFinishedV1, type RunProgramRequest, type RunSavedProgramRequest, type RunStarted, type RunStartedV1, type RunStepDetails, type SavedProgramRunnerUpdate, type SavedProgramRunnerUpdateV0, type ScheduledAgentTriggerEventId, type ScheduledAgentTriggerId, type ScheduledAgentTriggerPayload, type ScheduledAgentTriggerPayloadV1, type ScheduledAgentTriggerType, type SchemaContext, type SchemaExplored, type SchemaExplorerCompleted, type SchemaExplorerStarted, type SchemaExplorerUpdate, type SchemaTask, type SchemaTasksGenerationCompleted, type SchemaTasksGenerationStarted, type SchemaTasksGenerationUpdate, type SendMessageToThreadArguments, type SendMessageToThreadOutput, SendThreadMessageMutationVariables, type ServerMetadata, type ShelfActionEvent, type ShelfUpdate, type ShelfUpdateV1, type SkillType, type SocialFeedRatingLlmUsage, 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 StartThreadArguments, StartThreadMutationVariables, type StartThreadOutput, type StartingOrchestrator, type StepExecutionFinished, type StepExecutionFinishedV1, type StepExecutionStarted, type StepExecutionStartedV1, type StepUpdate, type StreamThreadEventOptions, type TargetWikiPage, type TasksGenerated, type Teaching, type TeachingId, type ThreadEvent, type ThreadEvent$1 as ThreadEventData, ThreadFragment, type TransactionId, type TzWrapper, USER_AGENT, type UiBuildFailure, type UiBuildRunStepDetails, type UiMetadata, type UiProgrammerUpdate, type UserCancel, type UserCancelEvent, type UserMessage, type UserMessageEvent, type UserUpload, type VersionedAgentUpdate, type VersionedOrUnversionedAgentUpdate, type Warning, type WikiAuditId, type WikiChange, type WikiContent, type WikiDelta, type WikiExplorerCompleted, type WikiExplorerStarted, type WikiExplorerUpdate, type WikiGenerationUpdate, type WikiInfoGenerated, type WikiLearningSuggestionUpdate, type WikiPage, type WikiPageNamespace, type WikiPagePreview, type WikiPageSearchResult, type WikiPageV1, type WikiSection, type WikiSelectionUpdate, type WikiTitle, buildPromptQLUrl, cancelAgentMessage, createApolloClient, 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, getWikiPage, isInteractionAnalyzing, listArtifactMetadataByThreadId, listRooms, listThreads, listWikiPages, sendThreadMessage, startThread, streamThreadMessageEvents, subscribeThreadEvents, validateRoomName };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var E=Object.defineProperty;var Ae=Object.getOwnPropertyDescriptor;var he=Object.getOwnPropertyNames;var fe=Object.prototype.hasOwnProperty;var xe=(t,e)=>{for(var a in e)E(t,a,{get:e[a],enumerable:!0})},Be=(t,e,a,_)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of he(e))!fe.call(t,r)&&r!==a&&E(t,r,{get:()=>e[r],enumerable:!(_=Ae(e,r))||_.enumerable});return t};var ve=t=>Be(E({},"__esModule",{value:!0}),t);var ut={};xe(ut,{PromptQLSdk:()=>L,ROOM_NAME_REGEX:()=>oe,USER_AGENT:()=>d,buildPromptQLUrl:()=>Q,cancelAgentMessage:()=>N,createApolloClient:()=>G,createRoom:()=>U,diffThreadEvents:()=>Pe,downloadArtifactData:()=>T,getAgentGeneratedResponse:()=>je,getAgentInteractionDecisionAcceptInteractionEvent:()=>We,getAgentInteractionDecisionDeclineInteractionEvent:()=>Ne,getAgentInteractionFinishedEvent:()=>pt,getAgentMessageProcessingStartedEvent:()=>Ve,getAgentOrchestratorContextExplorerCompletedEvent:()=>Le,getAgentOrchestratorContextExplorerStartedEvent:()=>Qe,getAgentOrchestratorContextExplorerUpdateEvent:()=>c,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent:()=>tt,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent:()=>at,getAgentOrchestratorSchemaExplorerCompletedEvent:()=>et,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent:()=>rt,getAgentOrchestratorSchemaExplorerSchemaExploredEvent:()=>_t,getAgentOrchestratorSchemaExplorerStartedEvent:()=>Ye,getAgentOrchestratorSchemaExplorerUpdateEvent:()=>y,getAgentOrchestratorSchemaTasksGeneratedEvent:()=>Ze,getAgentOrchestratorSchemaTasksGenerationCompletedEvent:()=>Xe,getAgentOrchestratorSchemaTasksGenerationStartedEvent:()=>$e,getAgentOrchestratorSchemaTasksGenerationUpdateEvent:()=>h,getAgentOrchestratorStepProgrammerEvent:()=>nt,getAgentOrchestratorStepSavedProgramRunnerEvent:()=>ot,getAgentOrchestratorStepUiProgrammerEvent:()=>it,getAgentOrchestratorStepUpdateEvent:()=>f,getAgentOrchestratorUpdateEvent:()=>S,getAgentOrchestratorWikiExplorerCompletedEvent:()=>Ke,getAgentOrchestratorWikiExplorerStartedEvent:()=>Je,getAgentOrchestratorWikiExplorerUpdateEvent:()=>A,getAgentOrchestratorWikiInfoGeneratedEvent:()=>He,getAgentPlanGenerationStartedEvent:()=>we,getAgentPlanStepGeneratedEvent:()=>Fe,getAgentPlanningDecisionCompletedEvent:()=>qe,getAgentPlanningDecisionPlanningRequiredEvent:()=>De,getAgentPlanningDecisionStartedEvent:()=>ze,getAgentPlanningDecisionUpdateEvent:()=>g,getAgentStartingOrchestratorEvent:()=>Ge,getArtifactMetadata:()=>R,getThread:()=>j,getThreadEventMessageId:()=>st,getThreadEvents:()=>M,getUserCancelEvent:()=>Ue,getUserMessageEvent:()=>Re,isInteractionAnalyzing:()=>se,listArtifactMetadataByThreadId:()=>P,listRooms:()=>m,listThreads:()=>F,listWikiPages:()=>D,sendThreadMessage:()=>W,startThread:()=>V,streamThreadMessageEvents:()=>q,subscribeThreadEvents:()=>z,validateRoomName:()=>pe});module.exports=ve(ut);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"}}]}}]}}]},K={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"CreateRoom"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"name"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"visibility"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"description"}},type:{kind:"NamedType",name:{kind:"Name",value:"String"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"create_room"},arguments:[{kind:"Argument",name:{kind:"Name",value:"name"},value:{kind:"Variable",name:{kind:"Name",value:"name"}}},{kind:"Argument",name:{kind:"Name",value:"visibility"},value:{kind:"Variable",name:{kind:"Name",value:"visibility"}}},{kind:"Argument",name:{kind:"Name",value:"description"},value:{kind:"Variable",name:{kind:"Name",value:"description"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"room_id"}}]}}]}}]},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"}}]}}]}}]}}]},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"}}]}}]}}]}}]},Z={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ListGuidePages"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_guide_page_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"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_guide_page_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"admin_guide_page"},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:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"page_title"}},{kind:"Field",name:{kind:"Name",value:"details"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"last_modified_at"}}]}}]}}]},Y={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ListPromptqlWikiPages"},variableDefinitions:[{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:"admin_promptql_wiki_order_by"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NamedType",name:{kind:"Name",value:"admin_promptql_wiki_bool_exp"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"admin_promptql_wiki"},arguments:[{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}},{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:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"page_id"}},{kind:"Field",name:{kind:"Name",value:"content"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"last_modified_at"}}]}}]}}]},ee={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"}}]}}]},te={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"}}]}}]}}]},ae={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"}}]}}]}}]},re={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"}}]}}]},_e={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ListWikiPages"},variableDefinitions:[{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"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_wiki_order_by"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_wiki_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"admin_wiki"},arguments:[{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"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}},{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"page_id"}},{kind:"Field",name:{kind:"Name",value:"content"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"last_modified_at"}}]}}]}}]},ne={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 r=="function"?r:fetch)(i,{method:"GET",headers:_});if(n.status!==200){let b=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to download artifact: ${b}`)}return n.body?n.headers.get("Content-Type")?.startsWith("application/json")?n.json():n.text():null}async function P(t,e,a){let _=await t.query({query:X,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 R(t,e,a,_,r){let i=`${t}/promptql-v2/artifacts/${e}/version/${a}/metadata`,n=await(typeof r=="function"?r:fetch)(i,{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()}function m(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?.rooms??[])}function U(t,e){if(!e.name)throw new Error("Room name is required");let a=pe(e.name);if(a)throw new Error(a);return t.mutate({mutation:K,variables:e,fetchPolicy:"no-cache"}).then(_=>{if(!_.data?.create_room?.room_id)throw new Error("expected room_id in response, got null");return _.data?.create_room?.room_id})}var oe=/^[\p{Ll}\p{Lo}\p{N}]+([_-][\p{Ll}\p{Lo}\p{N}]+)*$/u,ie=80,pe=t=>{let e=t.trim();return e.length===0?null:e.length>ie?`Room name must be ${ie} characters or less`:/[^\p{Ll}\p{Lo}\p{N}_-]/u.test(e)?"Only lowercase letters, numbers, hyphens, and underscores are allowed.":/^[_-]|[_-]$/.test(e)?"Room name should not start or end with a hyphen or underscore.":/[-_]{2,}/.test(e)?"Room name should not contain consecutive hyphens or underscores.":oe.test(e)?null:"Room name is invalid. Only lowercase letters, numbers, hyphens, and underscores are allowed."};var s=require("rxjs");function I(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:te,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:ae,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 M(t,e,a){if(!e)throw new Error("threadId is required");let _={thread_id:{_eq:e}};return a&&(a.eventId&&(_.thread_event_id=a.eventId),a.messageId&&(_._or=Ce(a.messageId))),t.query({query:re,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: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 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:ne,variables:{where:_}}).pipe((0,s.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),i={eventId:a?.fromEventId?{_gte:r}:void 0,messageId:a?.messageId},o=a?.pollingInterval&&a?.pollingInterval>0?a.pollingInterval:5;return(0,s.defer)(async()=>{let n=_?{messageId:a?.messageId,eventId:{_gt:_}}:i,p=await M(t,e,n);return p.length>0&&(_=p[p.length-1]?.thread_event_id),p}).pipe((0,s.repeat)({count:a?.timeout&&a.timeout>0?Math.ceil(a.timeout/o):void 0,delay:o*1e3}),(0,s.takeWhile)(n=>se(n,a?.skipAnalysis),!0))}function se(t,e){for(let a=t.length-1;a>=0;a--){let _=t[a];if("UserMessage"in _.event_data)return!0;if(!("AgentMessage"in _.event_data))return!1;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 Ce(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}var ue=["guide","regular"];async function D(t,e){let a=e.namespace||"regular";if(!ue.includes(a))throw new Error(`Invalid namespace. Expected one of: ${ue}`);return a==="guide"?Ee(t,{where:e.project_id?{project_id:{_eq:e.project_id}}:{},limit:e.limit,offset:e.offset,order_by:e.order_by||e.ordering?{[!e.order_by||e.order_by==="page_id"?"id":e.order_by]:e.ordering||"asc"}:void 0}).then(_=>_.map(r=>({page_id:r.id,created_at:r.created_at,last_modified_at:r.last_modified_at,title:r.page_title,details:r.details}))):a==="promptql"?Oe(t,{where:{},limit:e.limit,offset:e.offset,order_by:e.order_by||e.ordering?{[!e.order_by||e.order_by==="page_id"?"id":e.order_by]:e.ordering||"asc"}:void 0}).then(_=>_.map(r=>({page_id:r.page_id,created_at:r.created_at,last_modified_at:r.last_modified_at,...r.content}))):ke(t,{where:e.project_id?{project_id:{_eq:e.project_id}}:{},limit:e.limit,offset:e.offset,order_by:e.order_by||e.ordering?{[e.order_by||"page_id"]:e.ordering||"asc"}:void 0}).then(_=>_.map(r=>({page_id:r.page_id,created_at:r.created_at,last_modified_at:r.last_modified_at,...r.content})))}function ke(t,e){return t.query({query:_e,variables:{...e,where:{...e.where,deleted_at:{_is_null:!0}}},fetchPolicy:"no-cache"}).then(a=>a.data?.admin_wiki??[])}function Oe(t,e){return t.query({query:Y,variables:e,fetchPolicy:"no-cache"}).then(a=>a.data?.admin_promptql_wiki??[])}function Ee(t,e){return t.query({query:Z,variables:{...e,where:{...e.where,deleted_at:{_is_null:!0}}},fetchPolicy:"no-cache"}).then(a=>a.data?.admin_guide_page??[])}function de(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="failure"}function ye(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="success"&&"token"in t}function ce(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 le(t){let a=`${I(t.authHost)||"https://auth.pro.hasura.io"}/ddn/promptql/token`,_={token:"",expiry:new Date(0)},r=t.fetch||fetch,i=async()=>{let o=await r(a,{method:"POST",headers:t.headers});switch(o.status){case 200:{let n=await o.json();if(ye(n))return n;throw new Error("malformed token response")}case 401:{let n=await o.json();throw de(n)?new Error(n?.error||o.statusText):new Error(o.statusText)}default:{let n=await o.text();throw new Error(n)}}};return async()=>{if(_.expiry.getTime()<=Date.now()+1e3){let o=await i(),n=await Te(t.promptqlGraphQLUrl,o.token,t.projectId,r);_.token=n;let p=new Date(o.expiry);if(Number.isNaN(p.getTime())){let b=new Date;b.setHours(1),_.expiry=b}else _.expiry=p}return _.token}}var Te=async(t,e,a,_=fetch)=>{let r=await _(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:"mutation EnrichToken($luxJWT: String!, $projectId: uuid) { enrich_token(luxJWT: $luxJWT, projectId: $projectId) { userDirectoryJWT }}",variables:{luxJWT:e,projectId:a},operationName:"EnrichToken"})});switch(r.status){case 200:{let i=await r.json();if(!ce(i)||!i.data?.enrich_token?.userDirectoryJWT)throw new Error(`malformed promptql token response: ${JSON.stringify(i)}`);return i.data.enrich_token.userDirectoryJWT}default:{let i=await r.text();throw new Error(i)}}};var d="PromptQL TypeScript SDK";var u=require("@apollo/client"),be=require("@apollo/client/link/context"),me=require("@apollo/client/link/subscriptions"),Ie=require("graphql"),Me=require("graphql-ws");var G=t=>{let e=new u.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,Me.createClient)({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),r=new me.GraphQLWsLink(_),i=new be.SetContextLink(({headers:n})=>a(n)),o=u.ApolloLink.split(({operationType:n})=>n===Ie.OperationTypeNode.SUBSCRIPTION,r,i.concat(e));return{client:new u.ApolloClient({link:o,cache:new u.InMemoryCache}),wsClient:_}};function Pe(t,e){if(!e.length)return[];if(!t.length)return e;let a=t[t.length-1];if(!a)return e;let _=BigInt(a.thread_event_id),r=e.length-1;for(;r>=0;r--){let i=e[r];if(BigInt(i?.thread_event_id)<=_)break}return e.slice(r+1)}function Re(t){return"UserMessage"in t?t.UserMessage:null}function Ue(t){return"UserCancel"in t?t.UserCancel:null}function we(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 Fe(t){let e=S(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function je(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 Ve(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 We(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 Ne(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 ze(t){let e=g(t);return!e||!("Started"in e)?null:e.Started}function qe(t){let e=g(t);return!e||!("Completed"in e)?null:e.Completed}function De(t){let e=g(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function Ge(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 Qe(t){let e=c(t);return!e||!("Started"in e)?null:e.Started}function Le(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 Je(t){let e=A(t);return!e||!("Started"in e)?null:e.Started}function Ke(t){let e=A(t);return!e||!("Completed"in e)?null:e.Completed}function He(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 $e(t){let e=h(t);return!e||!("Started"in e)?null:e.Started}function Xe(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 Ye(t){let e=y(t);return!e||!("Started"in e)?null:e.Started}function et(t){let e=y(t);return!e||!("Completed"in e)?null:e.Completed}function tt(t){let e=y(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function at(t){let e=y(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function rt(t){let e=y(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function _t(t){let e=y(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function f(t){let e=S(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function nt(t){let e=f(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function it(t){let e=f(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function ot(t){let e=f(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function pt(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 st(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 x=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=le({promptqlGraphQLUrl:e.promptqlGraphQLUrl,authHost:this.options.authHost,headers:ge(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 }}}"},_=await(typeof this.options.fetch=="function"?this.options.fetch:fetch)(this.controlPlaneUrl,{method:"POST",headers:{...ge(this.options.serviceAccountToken),"User-Agent":d,"Content-Type":"application/json"},body:JSON.stringify(e)});if(_.status!==200){let o=_.body?await _.text():_.statusText;throw new Error(`[${_.status}] failed to get project info: ${o}`)}let r=await _.json();if(!r.data?.ddn_projects?.length)throw new Error("Project not found");let i=r.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:Q(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}}};function ge(t){return{Authorization:`pat ${t}`}}var B=class{api;constructor(e){this.api=e}async listMetadataByThreadId(e){let a=await this.api.getProjectInfo(),_=await this.api.getGraphQLClient();return P(_,a.projectId,e)}async download(e,a){let _=await this.api.getProjectInfo(),r=await this.api.getAuthToken();return T(_.projectHost,e,a,Se(r),this.api.options.fetch)}async getMetadata(e,a){let _=await this.api.getProjectInfo(),r=await this.api.getAuthToken();return R(_.projectHost,e,a,Se(r),this.api.options.fetch)}};function Se(t){return{Authorization:`Bearer ${t}`,"User-Agent":d}}var v=class{api;constructor(e){this.api=e}info(){return this.api.getProjectInfo()}};var C=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 U(a,e)}};var l=require("rxjs");var k=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 M(_,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 O=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return D(a,e)}};var L=class{constructor(e){let a=new x(e);this.api=a,this.thread=new k(a),this.project=new v(a),this.room=new C(a),this.artifact=new B(a),this.wiki=new O(a)}api;thread;project;room;artifact;wiki;close(){this.api.close()}};0&&(module.exports={PromptQLSdk,ROOM_NAME_REGEX,USER_AGENT,buildPromptQLUrl,cancelAgentMessage,createApolloClient,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,listWikiPages,sendThreadMessage,startThread,streamThreadMessageEvents,subscribeThreadEvents,validateRoomName});
1
+ "use strict";var T=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var xe=Object.getOwnPropertyNames;var Be=Object.prototype.hasOwnProperty;var ve=(t,e)=>{for(var a in e)T(t,a,{get:e[a],enumerable:!0})},Ce=(t,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let _ of xe(e))!Be.call(t,_)&&_!==a&&T(t,_,{get:()=>e[_],enumerable:!(r=fe(e,_))||r.enumerable});return t};var ke=t=>Ce(T({},"__esModule",{value:!0}),t);var ut={};ve(ut,{PromptQLSdk:()=>K,ROOM_NAME_REGEX:()=>pe,USER_AGENT:()=>d,buildPromptQLUrl:()=>J,cancelAgentMessage:()=>z,createApolloClient:()=>L,createRoom:()=>w,diffThreadEvents:()=>Pe,downloadArtifactData:()=>P,getAgentGeneratedResponse:()=>je,getAgentInteractionDecisionAcceptInteractionEvent:()=>We,getAgentInteractionDecisionDeclineInteractionEvent:()=>Ne,getAgentInteractionFinishedEvent:()=>pt,getAgentMessageProcessingStartedEvent:()=>Ve,getAgentOrchestratorContextExplorerCompletedEvent:()=>Le,getAgentOrchestratorContextExplorerStartedEvent:()=>Qe,getAgentOrchestratorContextExplorerUpdateEvent:()=>c,getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent:()=>tt,getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent:()=>at,getAgentOrchestratorSchemaExplorerCompletedEvent:()=>et,getAgentOrchestratorSchemaExplorerGeneratedCodeEvent:()=>rt,getAgentOrchestratorSchemaExplorerSchemaExploredEvent:()=>_t,getAgentOrchestratorSchemaExplorerStartedEvent:()=>Ye,getAgentOrchestratorSchemaExplorerUpdateEvent:()=>y,getAgentOrchestratorSchemaTasksGeneratedEvent:()=>Ze,getAgentOrchestratorSchemaTasksGenerationCompletedEvent:()=>Xe,getAgentOrchestratorSchemaTasksGenerationStartedEvent:()=>$e,getAgentOrchestratorSchemaTasksGenerationUpdateEvent:()=>f,getAgentOrchestratorStepProgrammerEvent:()=>nt,getAgentOrchestratorStepSavedProgramRunnerEvent:()=>ot,getAgentOrchestratorStepUiProgrammerEvent:()=>it,getAgentOrchestratorStepUpdateEvent:()=>x,getAgentOrchestratorUpdateEvent:()=>A,getAgentOrchestratorWikiExplorerCompletedEvent:()=>Ke,getAgentOrchestratorWikiExplorerStartedEvent:()=>Je,getAgentOrchestratorWikiExplorerUpdateEvent:()=>h,getAgentOrchestratorWikiInfoGeneratedEvent:()=>He,getAgentPlanGenerationStartedEvent:()=>we,getAgentPlanStepGeneratedEvent:()=>Fe,getAgentPlanningDecisionCompletedEvent:()=>qe,getAgentPlanningDecisionPlanningRequiredEvent:()=>Ge,getAgentPlanningDecisionStartedEvent:()=>ze,getAgentPlanningDecisionUpdateEvent:()=>S,getAgentStartingOrchestratorEvent:()=>De,getArtifactMetadata:()=>U,getThread:()=>V,getThreadEventMessageId:()=>st,getThreadEvents:()=>M,getUserCancelEvent:()=>Ue,getUserMessageEvent:()=>Re,getWikiPage:()=>Q,isInteractionAnalyzing:()=>ue,listArtifactMetadataByThreadId:()=>R,listRooms:()=>m,listThreads:()=>j,listWikiPages:()=>D,sendThreadMessage:()=>N,startThread:()=>W,streamThreadMessageEvents:()=>G,subscribeThreadEvents:()=>q,validateRoomName:()=>se});module.exports=ke(ut);var H={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"}}]}}]}}]},$={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"}}]}}]}}]},X={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"}}]}}]}}]}}]},Y={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"}}]}}]}}]}}]},ee={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ListGuidePages"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_guide_page_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"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_guide_page_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"admin_guide_page"},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:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"page_title"}},{kind:"Field",name:{kind:"Name",value:"details"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"last_modified_at"}}]}}]}}]},te={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"}}]}}]},ae={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"}}]}}]}}]},re={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"}}]}}]}}]},_e={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"}}]}}]},ne={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ListWikiPages"},variableDefinitions:[{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"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_wiki_order_by"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_wiki_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"admin_wiki"},arguments:[{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"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}},{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"page_id"}},{kind:"Field",name:{kind:"Name",value:"content"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"last_modified_at"}}]}}]}}]},ie={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 P(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 b=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to download artifact: ${b}`)}return n.body?n.headers.get("Content-Type")?.startsWith("application/json")?n.json():n.text():null}async function R(t,e,a){let r=await t.query({query:Y,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 U(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()}function m(t,e){return t.query({query:te,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");let a=se(e.name);if(a)throw new Error(a);return t.mutate({mutation:$,variables:e,fetchPolicy:"no-cache"}).then(r=>{if(!r.data?.create_room?.room_id)throw new Error("expected room_id in response, got null");return r.data?.create_room?.room_id})}var pe=/^[\p{Ll}\p{Lo}\p{N}]+([_-][\p{Ll}\p{Lo}\p{N}]+)*$/u,oe=80,se=t=>{let e=t.trim();return e.length===0?null:e.length>oe?`Room name must be ${oe} characters or less`:/[^\p{Ll}\p{Lo}\p{N}_-]/u.test(e)?"Only lowercase letters, numbers, hyphens, and underscores are allowed.":/^[_-]|[_-]$/.test(e)?"Room name should not start or end with a hyphen or underscore.":/[-_]{2,}/.test(e)?"Room name should not contain consecutive hyphens or underscores.":pe.test(e)?null:"Room name is invalid. Only lowercase letters, numbers, hyphens, and underscores are allowed."};var s=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:ae,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:re,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=Oe(a.messageId))),t.query({query:_e,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:X,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:H,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:ie,variables:{where:r}}).pipe((0,s.map)(_=>{if(_.error)throw _.error;return _.data?.thread_events??[]}))}function G(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,s.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,s.repeat)({count:a?.timeout&&a.timeout>0?Math.ceil(a.timeout/o):void 0,delay:o*1e3}),(0,s.takeWhile)(n=>ue(n,a?.skipAnalysis),!0))}function ue(t,e){for(let a=t.length-1;a>=0;a--){let r=t[a];if("UserMessage"in r.event_data)return!0;if(!("AgentMessage"in r.event_data))return!1;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 Oe(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}var g=["guide","regular"];async function D(t,e){let a=e.namespace||"regular";if(!g.includes(a))throw new Error(`Invalid namespace. Expected one of: ${g}`);if(a==="guide"){let r={deleted_at:{_is_null:!0}};return e.project_id&&(r.project_id={_eq:e.project_id}),e.query&&(r.page_title={_ilike:e.query.toLowerCase()}),ye(t,{where:r,limit:e.limit,offset:e.offset,order_by:e.order_by||e.ordering?{[!e.order_by||e.order_by==="page_id"?"id":e.order_by]:e.ordering||"asc"}:void 0})}return de(t,{where:e.project_id?{project_id:{_eq:e.project_id},deleted_at:{_is_null:!0}}:{},limit:e.limit,offset:e.offset,order_by:e.order_by||e.ordering?{[e.order_by||"page_id"]:e.ordering||"asc"}:void 0}).then(r=>Ee(r,e))}async function Q(t,e,a,r){if(a=a||"regular",!g.includes(a))throw new Error(`Invalid namespace. Expected one of: ${g}`);if(!e)throw new Error("project_id is required");if(!r)throw new Error("id is required");if(a==="guide"){let o=await ye(t,{where:{project_id:{_eq:e},id:{_eq:r},deleted_at:{_is_null:!0}},limit:1});return o.length?o[0]:null}let _=await de(t,{where:{project_id:{_eq:e},page_id:{_eq:r},deleted_at:{_is_null:!0}},limit:1});return _.length?_[0]:null}function de(t,e){return t.query({query:ne,variables:e,fetchPolicy:"no-cache"}).then(a=>a.data?.admin_wiki.map(r=>({page_id:r.page_id,created_at:r.created_at,last_modified_at:r.last_modified_at,...r.content}))??[])}function ye(t,e){return t.query({query:ee,variables:e,fetchPolicy:"no-cache"}).then(a=>a.data?.admin_guide_page?.map(r=>({page_id:r.id,created_at:r.created_at,last_modified_at:r.last_modified_at,title:r.page_title,details:r.details}))??[])}function Ee(t,e){if(!t.length||!e.include_stub&&!e.query&&!e.limit&&!e.offset)return t;let a=e.query?.toLowerCase(),r=t.filter(_=>!e.include_stub&&_.stub?!1:!!(!a||_.title.toLowerCase().includes(a)||_.definition&&_.definition.toLowerCase().includes(a)||_.aliases?.length&&_.aliases.some(i=>i.toLowerCase().includes(a))));return e.offset&&r.length&&(r=r.slice(e.offset)),e.limit&&e.limit<r.length&&(r=r.slice(0,e.limit)),r}function ce(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="failure"}function le(t){return t!=null&&typeof t=="object"&&"status"in t&&t.status==="success"&&"token"in t}function be(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 me(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(le(n))return n;throw new Error("malformed token response")}case 401:{let n=await o.json();throw ce(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 Te(t.promptqlGraphQLUrl,o.token,t.projectId,_);r.token=n;let p=new Date(o.expiry);if(Number.isNaN(p.getTime())){let b=new Date;b.setHours(1),r.expiry=b}else r.expiry=p}return r.token}}var Te=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(!be(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)}}};var d="PromptQL TypeScript SDK";var u=require("@apollo/client"),Ie=require("@apollo/client/link/context"),Me=require("@apollo/client/link/subscriptions"),ge=require("graphql"),Se=require("graphql-ws");var L=t=>{let e=new u.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,Se.createClient)({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),_=new Me.GraphQLWsLink(r),i=new Ie.SetContextLink(({headers:n})=>a(n)),o=u.ApolloLink.split(({operationType:n})=>n===ge.OperationTypeNode.SUBSCRIPTION,_,i.concat(e));return{client:new u.ApolloClient({link:o,cache:new u.InMemoryCache}),wsClient:r}};function Pe(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 Re(t){return"UserMessage"in t?t.UserMessage:null}function Ue(t){return"UserCancel"in t?t.UserCancel:null}function we(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 Fe(t){let e=A(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function je(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 Ve(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 We(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 Ne(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 ze(t){let e=S(t);return!e||!("Started"in e)?null:e.Started}function qe(t){let e=S(t);return!e||!("Completed"in e)?null:e.Completed}function Ge(t){let e=S(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function De(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 Qe(t){let e=c(t);return!e||!("Started"in e)?null:e.Started}function Le(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 Je(t){let e=h(t);return!e||!("Started"in e)?null:e.Started}function Ke(t){let e=h(t);return!e||!("Completed"in e)?null:e.Completed}function He(t){let e=h(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function f(t){let e=c(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function $e(t){let e=f(t);return!e||!("Started"in e)?null:e.Started}function Xe(t){let e=f(t);return!e||!("Completed"in e)?null:e.Completed}function Ze(t){let e=f(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 Ye(t){let e=y(t);return!e||!("Started"in e)?null:e.Started}function et(t){let e=y(t);return!e||!("Completed"in e)?null:e.Completed}function tt(t){let e=y(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function at(t){let e=y(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function rt(t){let e=y(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function _t(t){let e=y(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function x(t){let e=A(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function nt(t){let e=x(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function it(t){let e=x(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function ot(t){let e=x(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function pt(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 st(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 J(t){return`https://promptql.${t}/playground-v2-hge/v1/graphql`}var B=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=me({promptqlGraphQLUrl:e.promptqlGraphQLUrl,authHost:this.options.authHost,headers:Ae(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}=L({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:{...Ae(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:J(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}}};function Ae(t){return{Authorization:`pat ${t}`}}var v=class{api;constructor(e){this.api=e}async listMetadataByThreadId(e){let a=await this.api.getProjectInfo(),r=await this.api.getGraphQLClient();return R(r,a.projectId,e)}async download(e,a){let r=await this.api.getProjectInfo(),_=await this.api.getAuthToken();return P(r.projectHost,e,a,he(_),this.api.options.fetch)}async getMetadata(e,a){let r=await this.api.getProjectInfo(),_=await this.api.getAuthToken();return U(r.projectHost,e,a,he(_),this.api.options.fetch)}};function he(t){return{Authorization:`Bearer ${t}`,"User-Agent":d}}var C=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 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(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 O=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=>G(r,e,a)))}};var E=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return D(a,e)}async get(e,a){let r=await this.api.getProjectInfo(),_=await this.api.getGraphQLClient();return Q(_,r.projectId,e,a)}};var K=class{constructor(e){let a=new B(e);this.api=a,this.thread=new O(a),this.project=new C(a),this.room=new k(a),this.artifact=new v(a),this.wiki=new E(a)}api;thread;project;room;artifact;wiki;close(){this.api.close()}};0&&(module.exports={PromptQLSdk,ROOM_NAME_REGEX,USER_AGENT,buildPromptQLUrl,cancelAgentMessage,createApolloClient,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,getWikiPage,isInteractionAnalyzing,listArtifactMetadataByThreadId,listRooms,listThreads,listWikiPages,sendThreadMessage,startThread,streamThreadMessageEvents,subscribeThreadEvents,validateRoomName});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{a as v,b as M,f as C}from"./chunk-YCHA4U67.mjs";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"}}]}}]}}]},O={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:"ListGuidePages"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_guide_page_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"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_guide_page_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"admin_guide_page"},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:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"page_title"}},{kind:"Field",name:{kind:"Name",value:"details"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"last_modified_at"}}]}}]}}]},U={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ListPromptqlWikiPages"},variableDefinitions:[{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:"admin_promptql_wiki_order_by"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NamedType",name:{kind:"Name",value:"admin_promptql_wiki_bool_exp"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"admin_promptql_wiki"},arguments:[{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}},{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:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"page_id"}},{kind:"Field",name:{kind:"Name",value:"content"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"last_modified_at"}}]}}]}}]},w={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"}}]}}]},F={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},j={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},V={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"ordering"}},type:{kind:"NamedType",name:{kind:"Name",value:"order_by"}},defaultValue:{kind:"EnumValue",value:"asc"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"Variable",name:{kind:"Name",value:"ordering"}}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]},W={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ListWikiPages"},variableDefinitions:[{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"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_wiki_order_by"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_wiki_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"admin_wiki"},arguments:[{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"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}},{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"page_id"}},{kind:"Field",name:{kind:"Name",value:"content"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"last_modified_at"}}]}}]}}]},N={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 z(t,e,a,_,r){let i=`${t}/promptql-v2/artifacts/${e}/version/${a}/data`,n=await(typeof r=="function"?r:fetch)(i,{method:"GET",headers:_});if(n.status!==200){let pe=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to download artifact: ${pe}`)}return n.body?n.headers.get("Content-Type")?.startsWith("application/json")?n.json():n.text():null}async function q(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 D(t,e,a,_,r){let i=`${t}/promptql-v2/artifacts/${e}/version/${a}/metadata`,n=await(typeof r=="function"?r:fetch)(i,{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()}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?.rooms??[])}function Q(t,e){if(!e.name)throw new Error("Room name is required");let a=ue(e.name);if(a)throw new Error(a);return t.mutate({mutation:O,variables:e,fetchPolicy:"no-cache"}).then(_=>{if(!_.data?.create_room?.room_id)throw new Error("expected room_id in response, got null");return _.data?.create_room?.room_id})}var se=/^[\p{Ll}\p{Lo}\p{N}]+([_-][\p{Ll}\p{Lo}\p{N}]+)*$/u,G=80,ue=t=>{let e=t.trim();return e.length===0?null:e.length>G?`Room name must be ${G} characters or less`:/[^\p{Ll}\p{Lo}\p{N}_-]/u.test(e)?"Only lowercase letters, numbers, hyphens, and underscores are allowed.":/^[_-]|[_-]$/.test(e)?"Room name should not start or end with a hyphen or underscore.":/[-_]{2,}/.test(e)?"Room name should not contain consecutive hyphens or underscores.":se.test(e)?null:"Room name is invalid. Only lowercase letters, numbers, hyphens, and underscores are allowed."};import{defer as de,map as ye,repeat as ce,takeWhile as le}from"rxjs";function L(t,e){return t.query({query:F,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function K(t,e){if(!e)throw new Error("threadId is required");return t.query({query:j,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function J(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=me(a.messageId))),t.query({query:V,variables:{where:_,limit:a?.limit,ordering:a?.ordering||"asc"},fetchPolicy:"no-cache"}).then(r=>r.data?.thread_events??[])}function H(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 $(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 X(t,e,a){if(!e)throw new Error("threadId is required");M(a);let _={thread_id:{_eq:e}};return a&&(_.thread_event_id={_gte:a}),t.subscribe({query:N,variables:{where:_}}).pipe(ye(r=>{if(r.error)throw r.error;return r.data?.thread_events??[]}))}function Z(t,e,a){if(!e)throw new Error("threadId is required");let _,r=M(a?.fromEventId),i={eventId:a?.fromEventId?{_gte:r}:void 0,messageId:a?.messageId},o=a?.pollingInterval&&a?.pollingInterval>0?a.pollingInterval:5;return de(async()=>{let n=_?{messageId:a?.messageId,eventId:{_gt:_}}:i,p=await S(t,e,n);return p.length>0&&(_=p[p.length-1]?.thread_event_id),p}).pipe(ce({count:a?.timeout&&a.timeout>0?Math.ceil(a.timeout/o):void 0,delay:o*1e3}),le(n=>be(n,a?.skipAnalysis),!0))}function be(t,e){for(let a=t.length-1;a>=0;a--){let _=t[a];if("UserMessage"in _.event_data)return!0;if(!("AgentMessage"in _.event_data))return!1;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 me(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}var Y=["guide","regular"];async function ee(t,e){let a=e.namespace||"regular";if(!Y.includes(a))throw new Error(`Invalid namespace. Expected one of: ${Y}`);return a==="guide"?ge(t,{where:e.project_id?{project_id:{_eq:e.project_id}}:{},limit:e.limit,offset:e.offset,order_by:e.order_by||e.ordering?{[!e.order_by||e.order_by==="page_id"?"id":e.order_by]:e.ordering||"asc"}:void 0}).then(_=>_.map(r=>({page_id:r.id,created_at:r.created_at,last_modified_at:r.last_modified_at,title:r.page_title,details:r.details}))):a==="promptql"?Me(t,{where:{},limit:e.limit,offset:e.offset,order_by:e.order_by||e.ordering?{[!e.order_by||e.order_by==="page_id"?"id":e.order_by]:e.ordering||"asc"}:void 0}).then(_=>_.map(r=>({page_id:r.page_id,created_at:r.created_at,last_modified_at:r.last_modified_at,...r.content}))):Ie(t,{where:e.project_id?{project_id:{_eq:e.project_id}}:{},limit:e.limit,offset:e.offset,order_by:e.order_by||e.ordering?{[e.order_by||"page_id"]:e.ordering||"asc"}:void 0}).then(_=>_.map(r=>({page_id:r.page_id,created_at:r.created_at,last_modified_at:r.last_modified_at,...r.content})))}function Ie(t,e){return t.query({query:W,variables:{...e,where:{...e.where,deleted_at:{_is_null:!0}}},fetchPolicy:"no-cache"}).then(a=>a.data?.admin_wiki??[])}function Me(t,e){return t.query({query:U,variables:e,fetchPolicy:"no-cache"}).then(a=>a.data?.admin_promptql_wiki??[])}function ge(t,e){return t.query({query:R,variables:{...e,where:{...e.where,deleted_at:{_is_null:!0}}},fetchPolicy:"no-cache"}).then(a=>a.data?.admin_guide_page??[])}var s="PromptQL TypeScript SDK";import{ApolloClient as Se,ApolloLink as Ae,HttpLink as he,InMemoryCache as fe}from"@apollo/client";import{SetContextLink as xe}from"@apollo/client/link/context";import{GraphQLWsLink as Be}from"@apollo/client/link/subscriptions";import{OperationTypeNode as ve}from"graphql";import{createClient as Ce}from"graphql-ws";var te=t=>{let e=new he({uri:t.url,fetch:t.fetch,headers:t.headers}),a=async n=>{let p=await t.getAuthToken();return{headers:{"User-Agent":s,...n,Authorization:`Bearer ${p}`}}},_=Ce({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),r=new Be(_),i=new xe(({headers:n})=>a(n)),o=Ae.split(({operationType:n})=>n===ve.SUBSCRIPTION,r,i.concat(e));return{client:new Se({link:o,cache:new fe}),wsClient:_}};function lt(t,e){if(!e.length)return[];if(!t.length)return e;let a=t[t.length-1];if(!a)return e;let _=BigInt(a.thread_event_id),r=e.length-1;for(;r>=0;r--){let i=e[r];if(BigInt(i?.thread_event_id)<=_)break}return e.slice(r+1)}function bt(t){return"UserMessage"in t?t.UserMessage:null}function mt(t){return"UserCancel"in t?t.UserCancel:null}function It(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)||!("PlanGenerationStarted"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function Mt(t){let e=h(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function gt(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 St(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 At(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 ht(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function A(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function ft(t){let e=A(t);return!e||!("Started"in e)?null:e.Started}function xt(t){let e=A(t);return!e||!("Completed"in e)?null:e.Completed}function Bt(t){let e=A(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function vt(t){return!("AgentMessage"in t)||!("StartingOrchestrator"in t.AgentMessage.update)?null:t.AgentMessage.update.StartingOrchestrator}function h(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.OrchestratorUpdate.update}function d(t){let e=h(t);return!e||!("ContextExplorerUpdate"in e)?null:e.ContextExplorerUpdate.update}function Ct(t){let e=d(t);return!e||!("Started"in e)?null:e.Started}function kt(t){let e=d(t);return!e||!("Completed"in e)?null:e.Completed}function f(t){let e=d(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function Ot(t){let e=f(t);return!e||!("Started"in e)?null:e.Started}function Et(t){let e=f(t);return!e||!("Completed"in e)?null:e.Completed}function Tt(t){let e=f(t);return!e||!("WikiInfoGenerated"in e)?null:e.WikiInfoGenerated}function x(t){let e=d(t);return!e||!("SchemaTasksGenerationUpdate"in e)?null:e.SchemaTasksGenerationUpdate.update}function Pt(t){let e=x(t);return!e||!("Started"in e)?null:e.Started}function Rt(t){let e=x(t);return!e||!("Completed"in e)?null:e.Completed}function Ut(t){let e=x(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function u(t){let e=d(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function wt(t){let e=u(t);return!e||!("Started"in e)?null:e.Started}function Ft(t){let e=u(t);return!e||!("Completed"in e)?null:e.Completed}function jt(t){let e=u(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function Vt(t){let e=u(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function Wt(t){let e=u(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function Nt(t){let e=u(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function B(t){let e=h(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function zt(t){let e=B(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function qt(t){let e=B(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function Dt(t){let e=B(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function Gt(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 Qt(t){if(t){if("UserMessage"in t)return t.UserMessage.message_id;if("AgentMessage"in t)return t.AgentMessage.message_id;if("UserTeach"in t)return t.UserTeach.agent_message_id;if("UserCancel"in t)return t.UserCancel.message_id}}function ae(t){return`https://promptql.${t}/playground-v2-hge/v1/graphql`}var y=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?v(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=C({promptqlGraphQLUrl:e.promptqlGraphQLUrl,authHost:this.options.authHost,headers:re(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:_}=te({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 }}}"},_=await(typeof this.options.fetch=="function"?this.options.fetch:fetch)(this.controlPlaneUrl,{method:"POST",headers:{...re(this.options.serviceAccountToken),"User-Agent":s,"Content-Type":"application/json"},body:JSON.stringify(e)});if(_.status!==200){let o=_.body?await _.text():_.statusText;throw new Error(`[${_.status}] failed to get project info: ${o}`)}let r=await _.json();if(!r.data?.ddn_projects?.length)throw new Error("Project not found");let i=r.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:ae(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}}};function re(t){return{Authorization:`pat ${t}`}}var c=class{api;constructor(e){this.api=e}async listMetadataByThreadId(e){let a=await this.api.getProjectInfo(),_=await this.api.getGraphQLClient();return q(_,a.projectId,e)}async download(e,a){let _=await this.api.getProjectInfo(),r=await this.api.getAuthToken();return z(_.projectHost,e,a,_e(r),this.api.options.fetch)}async getMetadata(e,a){let _=await this.api.getProjectInfo(),r=await this.api.getAuthToken();return D(_.projectHost,e,a,_e(r),this.api.options.fetch)}};function _e(t){return{Authorization:`Bearer ${t}`,"User-Agent":s}}var l=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 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(_=>_.length?_[0]??null:null)}async create(e){let a=await this.api.getGraphQLClient();return Q(a,e)}};import{from as ne,switchMap as ie}from"rxjs";var m=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return L(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 K(a,e)}async start(e){let a=await this.api.getProjectInfo(),_=await this.api.getGraphQLClient();return J(_,{...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 H(a,{...e,timezone:e.timezone||this.api.defaultTimezone})}async cancelAgentMessage(e){let a=await this.api.getGraphQLClient();return $(a,e)}subscribeEvents(e,a){return ne(this.api.getGraphQLClient()).pipe(ie(_=>X(_,e,a)))}streamMessageEvents(e,a){return ne(this.api.getGraphQLClient()).pipe(ie(_=>Z(_,e,a)))}};var I=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return ee(a,e)}};var oe=class{constructor(e){let a=new y(e);this.api=a,this.thread=new m(a),this.project=new l(a),this.room=new b(a),this.artifact=new c(a),this.wiki=new I(a)}api;thread;project;room;artifact;wiki;close(){this.api.close()}};export{oe as PromptQLSdk,se as ROOM_NAME_REGEX,s as USER_AGENT,ae as buildPromptQLUrl,$ as cancelAgentMessage,te as createApolloClient,Q as createRoom,lt as diffThreadEvents,z as downloadArtifactData,gt as getAgentGeneratedResponse,At as getAgentInteractionDecisionAcceptInteractionEvent,ht as getAgentInteractionDecisionDeclineInteractionEvent,Gt as getAgentInteractionFinishedEvent,St as getAgentMessageProcessingStartedEvent,kt as getAgentOrchestratorContextExplorerCompletedEvent,Ct as getAgentOrchestratorContextExplorerStartedEvent,d as getAgentOrchestratorContextExplorerUpdateEvent,jt as getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,Vt as getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,Ft as getAgentOrchestratorSchemaExplorerCompletedEvent,Wt as getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,Nt as getAgentOrchestratorSchemaExplorerSchemaExploredEvent,wt as getAgentOrchestratorSchemaExplorerStartedEvent,u as getAgentOrchestratorSchemaExplorerUpdateEvent,Ut as getAgentOrchestratorSchemaTasksGeneratedEvent,Rt as getAgentOrchestratorSchemaTasksGenerationCompletedEvent,Pt as getAgentOrchestratorSchemaTasksGenerationStartedEvent,x as getAgentOrchestratorSchemaTasksGenerationUpdateEvent,zt as getAgentOrchestratorStepProgrammerEvent,Dt as getAgentOrchestratorStepSavedProgramRunnerEvent,qt as getAgentOrchestratorStepUiProgrammerEvent,B as getAgentOrchestratorStepUpdateEvent,h as getAgentOrchestratorUpdateEvent,Et as getAgentOrchestratorWikiExplorerCompletedEvent,Ot as getAgentOrchestratorWikiExplorerStartedEvent,f as getAgentOrchestratorWikiExplorerUpdateEvent,Tt as getAgentOrchestratorWikiInfoGeneratedEvent,It as getAgentPlanGenerationStartedEvent,Mt as getAgentPlanStepGeneratedEvent,xt as getAgentPlanningDecisionCompletedEvent,Bt as getAgentPlanningDecisionPlanningRequiredEvent,ft as getAgentPlanningDecisionStartedEvent,A as getAgentPlanningDecisionUpdateEvent,vt as getAgentStartingOrchestratorEvent,D as getArtifactMetadata,K as getThread,Qt as getThreadEventMessageId,S as getThreadEvents,mt as getUserCancelEvent,bt as getUserMessageEvent,be as isInteractionAnalyzing,q as listArtifactMetadataByThreadId,g as listRooms,L as listThreads,ee as listWikiPages,H as sendThreadMessage,J as startThread,Z as streamThreadMessageEvents,X as subscribeThreadEvents,ue as validateRoomName};
1
+ import{a as C,b as g,f as k}from"./chunk-YCHA4U67.mjs";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"}}]}}]}}]},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:"ListGuidePages"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_guide_page_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"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_guide_page_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"admin_guide_page"},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:"Field",name:{kind:"Name",value:"id"}},{kind:"Field",name:{kind:"Name",value:"page_title"}},{kind:"Field",name:{kind:"Name",value:"details"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"last_modified_at"}}]}}]}}]},w={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"}}]}}]},F={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreads"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"offset"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"threads_v2_order_by"}}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"offset"},value:{kind:"Variable",name:{kind:"Name",value:"offset"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},j={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadById"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"uuid"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"threads_v2_by_pk"},arguments:[{kind:"Argument",name:{kind:"Name",value:"thread_id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"Thread"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"Thread"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"threads_v2"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_id"}},{kind:"Field",name:{kind:"Name",value:"build_id"}},{kind:"Field",name:{kind:"Name",value:"title"}},{kind:"Field",name:{kind:"Name",value:"relevant_event_count"}},{kind:"Field",name:{kind:"Name",value:"visibility"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}},{kind:"Field",name:{kind:"Name",value:"user"},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"promptql_user_id"}},{kind:"Field",name:{kind:"Name",value:"display_name"}},{kind:"Field",name:{kind:"Name",value:"email"}},{kind:"Field",name:{kind:"Name",value:"is_active"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"updated_at"}}]}}]}}]},V={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"GetThreadEvents"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"thread_events_bool_exp"}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"limit"}},type:{kind:"NamedType",name:{kind:"Name",value:"Int"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"ordering"}},type:{kind:"NamedType",name:{kind:"Name",value:"order_by"}},defaultValue:{kind:"EnumValue",value:"asc"}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_events"},arguments:[{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}},{kind:"Argument",name:{kind:"Name",value:"limit"},value:{kind:"Variable",name:{kind:"Name",value:"limit"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"ObjectValue",fields:[{kind:"ObjectField",name:{kind:"Name",value:"thread_event_id"},value:{kind:"Variable",name:{kind:"Name",value:"ordering"}}}]}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"FragmentSpread",name:{kind:"Name",value:"ThreadEvent"}}]}}]}},{kind:"FragmentDefinition",name:{kind:"Name",value:"ThreadEvent"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"thread_events"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"thread_event_id"}},{kind:"Field",name:{kind:"Name",value:"event_data"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"user_id"}}]}}]},W={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"ListWikiPages"},variableDefinitions:[{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"}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"order_by"}},type:{kind:"ListType",type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_wiki_order_by"}}}}},{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"where"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"admin_wiki_bool_exp"}}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"admin_wiki"},arguments:[{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"}}},{kind:"Argument",name:{kind:"Name",value:"order_by"},value:{kind:"Variable",name:{kind:"Name",value:"order_by"}}},{kind:"Argument",name:{kind:"Name",value:"where"},value:{kind:"Variable",name:{kind:"Name",value:"where"}}}],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"page_id"}},{kind:"Field",name:{kind:"Name",value:"content"}},{kind:"Field",name:{kind:"Name",value:"created_at"}},{kind:"Field",name:{kind:"Name",value:"last_modified_at"}}]}}]}}]},N={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 z(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 ue=n.body?await n.text():n.statusText;throw new Error(`[${n.status}] failed to download artifact: ${ue}`)}return n.body?n.headers.get("Content-Type")?.startsWith("application/json")?n.json():n.text():null}async function q(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 G(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()}function S(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?.rooms??[])}function Q(t,e){if(!e.name)throw new Error("Room name is required");let a=ye(e.name);if(a)throw new Error(a);return t.mutate({mutation:E,variables:e,fetchPolicy:"no-cache"}).then(r=>{if(!r.data?.create_room?.room_id)throw new Error("expected room_id in response, got null");return r.data?.create_room?.room_id})}var de=/^[\p{Ll}\p{Lo}\p{N}]+([_-][\p{Ll}\p{Lo}\p{N}]+)*$/u,D=80,ye=t=>{let e=t.trim();return e.length===0?null:e.length>D?`Room name must be ${D} characters or less`:/[^\p{Ll}\p{Lo}\p{N}_-]/u.test(e)?"Only lowercase letters, numbers, hyphens, and underscores are allowed.":/^[_-]|[_-]$/.test(e)?"Room name should not start or end with a hyphen or underscore.":/[-_]{2,}/.test(e)?"Room name should not contain consecutive hyphens or underscores.":de.test(e)?null:"Room name is invalid. Only lowercase letters, numbers, hyphens, and underscores are allowed."};import{defer as ce,map as le,repeat as be,takeWhile as me}from"rxjs";function L(t,e){return t.query({query:F,variables:{...e,limit:e.limit&&e.limit>0?e.limit:10},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2??[])}function K(t,e){if(!e)throw new Error("threadId is required");return t.query({query:j,variables:{id:e},fetchPolicy:"no-cache"}).then(a=>a.data?.threads_v2_by_pk)}function J(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=Me(a.messageId))),t.query({query:V,variables:{where:r,limit:a?.limit,ordering:a?.ordering||"asc"},fetchPolicy:"no-cache"}).then(_=>_.data?.thread_events??[])}function H(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 $(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 X(t,e,a){if(!e)throw new Error("threadId is required");g(a);let r={thread_id:{_eq:e}};return a&&(r.thread_event_id={_gte:a}),t.subscribe({query:N,variables:{where:r}}).pipe(le(_=>{if(_.error)throw _.error;return _.data?.thread_events??[]}))}function Z(t,e,a){if(!e)throw new Error("threadId is required");let r,_=g(a?.fromEventId),i={eventId:a?.fromEventId?{_gte:_}:void 0,messageId:a?.messageId},o=a?.pollingInterval&&a?.pollingInterval>0?a.pollingInterval:5;return ce(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(be({count:a?.timeout&&a.timeout>0?Math.ceil(a.timeout/o):void 0,delay:o*1e3}),me(n=>Ie(n,a?.skipAnalysis),!0))}function Ie(t,e){for(let a=t.length-1;a>=0;a--){let r=t[a];if("UserMessage"in r.event_data)return!0;if(!("AgentMessage"in r.event_data))return!1;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 Me(t){return[{event_data:{_contains:{UserMessage:{message_id:t}}}},{event_data:{_contains:{AgentMessage:{message_id:t}}}},{event_data:{_contains:{UserCancel:{message_id:t}}}}]}var y=["guide","regular"];async function Y(t,e){let a=e.namespace||"regular";if(!y.includes(a))throw new Error(`Invalid namespace. Expected one of: ${y}`);if(a==="guide"){let r={deleted_at:{_is_null:!0}};return e.project_id&&(r.project_id={_eq:e.project_id}),e.query&&(r.page_title={_ilike:e.query.toLowerCase()}),ae(t,{where:r,limit:e.limit,offset:e.offset,order_by:e.order_by||e.ordering?{[!e.order_by||e.order_by==="page_id"?"id":e.order_by]:e.ordering||"asc"}:void 0})}return te(t,{where:e.project_id?{project_id:{_eq:e.project_id},deleted_at:{_is_null:!0}}:{},limit:e.limit,offset:e.offset,order_by:e.order_by||e.ordering?{[e.order_by||"page_id"]:e.ordering||"asc"}:void 0}).then(r=>ge(r,e))}async function ee(t,e,a,r){if(a=a||"regular",!y.includes(a))throw new Error(`Invalid namespace. Expected one of: ${y}`);if(!e)throw new Error("project_id is required");if(!r)throw new Error("id is required");if(a==="guide"){let o=await ae(t,{where:{project_id:{_eq:e},id:{_eq:r},deleted_at:{_is_null:!0}},limit:1});return o.length?o[0]:null}let _=await te(t,{where:{project_id:{_eq:e},page_id:{_eq:r},deleted_at:{_is_null:!0}},limit:1});return _.length?_[0]:null}function te(t,e){return t.query({query:W,variables:e,fetchPolicy:"no-cache"}).then(a=>a.data?.admin_wiki.map(r=>({page_id:r.page_id,created_at:r.created_at,last_modified_at:r.last_modified_at,...r.content}))??[])}function ae(t,e){return t.query({query:U,variables:e,fetchPolicy:"no-cache"}).then(a=>a.data?.admin_guide_page?.map(r=>({page_id:r.id,created_at:r.created_at,last_modified_at:r.last_modified_at,title:r.page_title,details:r.details}))??[])}function ge(t,e){if(!t.length||!e.include_stub&&!e.query&&!e.limit&&!e.offset)return t;let a=e.query?.toLowerCase(),r=t.filter(_=>!e.include_stub&&_.stub?!1:!!(!a||_.title.toLowerCase().includes(a)||_.definition&&_.definition.toLowerCase().includes(a)||_.aliases?.length&&_.aliases.some(i=>i.toLowerCase().includes(a))));return e.offset&&r.length&&(r=r.slice(e.offset)),e.limit&&e.limit<r.length&&(r=r.slice(0,e.limit)),r}var s="PromptQL TypeScript SDK";import{ApolloClient as Se,ApolloLink as Ae,HttpLink as he,InMemoryCache as fe}from"@apollo/client";import{SetContextLink as xe}from"@apollo/client/link/context";import{GraphQLWsLink as Be}from"@apollo/client/link/subscriptions";import{OperationTypeNode as ve}from"graphql";import{createClient as Ce}from"graphql-ws";var re=t=>{let e=new he({uri:t.url,fetch:t.fetch,headers:t.headers}),a=async n=>{let p=await t.getAuthToken();return{headers:{"User-Agent":s,...n,Authorization:`Bearer ${p}`}}},r=Ce({url:t.url,connectionParams:()=>a(t.headers),lazy:!0}),_=new Be(r),i=new xe(({headers:n})=>a(n)),o=Ae.split(({operationType:n})=>n===ve.SUBSCRIPTION,_,i.concat(e));return{client:new Se({link:o,cache:new fe}),wsClient:r}};function dt(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 yt(t){return"UserMessage"in t?t.UserMessage:null}function ct(t){return"UserCancel"in t?t.UserCancel:null}function lt(t){return!("AgentMessage"in t)||!("OrchestratorUpdate"in t.AgentMessage.update)||!("PlanGenerationStarted"in t.AgentMessage.update.OrchestratorUpdate.update)?null:t.AgentMessage.update.OrchestratorUpdate.update.PlanGenerationStarted}function bt(t){let e=f(t);return!e||!("PlanStepGenerated"in e)?null:e.PlanStepGenerated}function mt(t){return"AgentMessage"in t?"content"in t.AgentMessage.update&&"interaction_update"in t.AgentMessage.update.content&&"main_agent"in t.AgentMessage.update.content.interaction_update&&"completed"in t.AgentMessage.update.content.interaction_update.main_agent?{success:!0,message:t.AgentMessage.update.content.interaction_update.main_agent.completed.summary,modified_artifacts:[],generated_at:t.AgentMessage.update.timestamp,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 It(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("ProcessingStarted"in t.AgentMessage.update.MessageProcessingUpdate.update)?null:t.AgentMessage.update.MessageProcessingUpdate.update.ProcessingStarted}function Mt(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("AcceptInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.AcceptInteraction}function gt(t){return!("AgentMessage"in t)||!("MessageProcessingUpdate"in t.AgentMessage.update)||!("InteractionDecision"in t.AgentMessage.update.MessageProcessingUpdate.update)||!("DeclineInteraction"in t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision)?null:t.AgentMessage.update.MessageProcessingUpdate.update.InteractionDecision.decision.DeclineInteraction}function h(t){return!("AgentMessage"in t)||!("PlanningDecisionUpdate"in t.AgentMessage.update)?null:t.AgentMessage.update.PlanningDecisionUpdate.update}function St(t){let e=h(t);return!e||!("Started"in e)?null:e.Started}function At(t){let e=h(t);return!e||!("Completed"in e)?null:e.Completed}function ht(t){let e=h(t);return!e||!("PlanningRequired"in e)?null:e.PlanningRequired}function ft(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 xt(t){let e=d(t);return!e||!("Started"in e)?null:e.Started}function Bt(t){let e=d(t);return!e||!("Completed"in e)?null:e.Completed}function x(t){let e=d(t);return!e||!("WikiExplorerUpdate"in e)?null:e.WikiExplorerUpdate.update}function vt(t){let e=x(t);return!e||!("Started"in e)?null:e.Started}function Ct(t){let e=x(t);return!e||!("Completed"in e)?null:e.Completed}function kt(t){let e=x(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 Ot(t){let e=B(t);return!e||!("Started"in e)?null:e.Started}function Et(t){let e=B(t);return!e||!("Completed"in e)?null:e.Completed}function Tt(t){let e=B(t);return!e||!("TasksGenerated"in e)?null:e.TasksGenerated}function u(t){let e=d(t);return!e||!("SchemaExplorerUpdate"in e)?null:e.SchemaExplorerUpdate.update}function Pt(t){let e=u(t);return!e||!("Started"in e)?null:e.Started}function Rt(t){let e=u(t);return!e||!("Completed"in e)?null:e.Completed}function Ut(t){let e=u(t);return!e||!("CodeExecutionComplete"in e)?null:e.CodeExecutionComplete}function wt(t){let e=u(t);return!e||!("CodeOutputAnalyzed"in e)?null:e.CodeOutputAnalyzed}function Ft(t){let e=u(t);return!e||!("GeneratedCode"in e)?null:e.GeneratedCode}function jt(t){let e=u(t);return!e||!("SchemaExplored"in e)?null:e.SchemaExplored}function v(t){let e=f(t);return!e||!("StepUpdate"in e)?null:e.StepUpdate}function Vt(t){let e=v(t);return!e||!("Programmer"in e.update)?null:e.update.Programmer}function Wt(t){let e=v(t);return!e||!("UiProgrammer"in e.update)?null:e.update.UiProgrammer}function Nt(t){let e=v(t);return!e||!("SavedProgramRunner"in e.update)?null:e.update.SavedProgramRunner}function zt(t){if(!("AgentMessage"in t))return null;if("InteractionFinished"in t.AgentMessage.update){let e=t.AgentMessage.update.InteractionFinished.update;return"Completed"in e?{status:"completed",timestamp:e.Completed.completed_at,warnings:e.Completed.warnings,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 qt(t){if(t){if("UserMessage"in t)return t.UserMessage.message_id;if("AgentMessage"in t)return t.AgentMessage.message_id;if("UserTeach"in t)return t.UserTeach.agent_message_id;if("UserCancel"in t)return t.UserCancel.message_id}}function _e(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?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=k({promptqlGraphQLUrl:e.promptqlGraphQLUrl,authHost:this.options.authHost,headers:ne(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}=re({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:{...ne(this.options.serviceAccountToken),"User-Agent":s,"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:_e(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}}};function ne(t){return{Authorization:`pat ${t}`}}var l=class{api;constructor(e){this.api=e}async listMetadataByThreadId(e){let a=await this.api.getProjectInfo(),r=await this.api.getGraphQLClient();return q(r,a.projectId,e)}async download(e,a){let r=await this.api.getProjectInfo(),_=await this.api.getAuthToken();return z(r.projectHost,e,a,ie(_),this.api.options.fetch)}async getMetadata(e,a){let r=await this.api.getProjectInfo(),_=await this.api.getAuthToken();return G(r.projectHost,e,a,ie(_),this.api.options.fetch)}};function ie(t){return{Authorization:`Bearer ${t}`,"User-Agent":s}}var b=class{api;constructor(e){this.api=e}info(){return this.api.getProjectInfo()}};var m=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return S(a,{...e,limit:e.limit&&e.limit>0?e.limit:10})}async getByName(e){let a=await this.api.getGraphQLClient();return S(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 Q(a,e)}};import{from as oe,switchMap as pe}from"rxjs";var I=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return L(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 K(a,e)}async start(e){let a=await this.api.getProjectInfo(),r=await this.api.getGraphQLClient();return J(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 H(a,{...e,timezone:e.timezone||this.api.defaultTimezone})}async cancelAgentMessage(e){let a=await this.api.getGraphQLClient();return $(a,e)}subscribeEvents(e,a){return oe(this.api.getGraphQLClient()).pipe(pe(r=>X(r,e,a)))}streamMessageEvents(e,a){return oe(this.api.getGraphQLClient()).pipe(pe(r=>Z(r,e,a)))}};var M=class{api;constructor(e){this.api=e}async list(e){let a=await this.api.getGraphQLClient();return Y(a,e)}async get(e,a){let r=await this.api.getProjectInfo(),_=await this.api.getGraphQLClient();return ee(_,r.projectId,e,a)}};var se=class{constructor(e){let a=new c(e);this.api=a,this.thread=new I(a),this.project=new b(a),this.room=new m(a),this.artifact=new l(a),this.wiki=new M(a)}api;thread;project;room;artifact;wiki;close(){this.api.close()}};export{se as PromptQLSdk,de as ROOM_NAME_REGEX,s as USER_AGENT,_e as buildPromptQLUrl,$ as cancelAgentMessage,re as createApolloClient,Q as createRoom,dt as diffThreadEvents,z as downloadArtifactData,mt as getAgentGeneratedResponse,Mt as getAgentInteractionDecisionAcceptInteractionEvent,gt as getAgentInteractionDecisionDeclineInteractionEvent,zt as getAgentInteractionFinishedEvent,It as getAgentMessageProcessingStartedEvent,Bt as getAgentOrchestratorContextExplorerCompletedEvent,xt as getAgentOrchestratorContextExplorerStartedEvent,d as getAgentOrchestratorContextExplorerUpdateEvent,Ut as getAgentOrchestratorSchemaExplorerCodeExecutionCompleteEvent,wt as getAgentOrchestratorSchemaExplorerCodeOutputAnalyzedEvent,Rt as getAgentOrchestratorSchemaExplorerCompletedEvent,Ft as getAgentOrchestratorSchemaExplorerGeneratedCodeEvent,jt as getAgentOrchestratorSchemaExplorerSchemaExploredEvent,Pt as getAgentOrchestratorSchemaExplorerStartedEvent,u as getAgentOrchestratorSchemaExplorerUpdateEvent,Tt as getAgentOrchestratorSchemaTasksGeneratedEvent,Et as getAgentOrchestratorSchemaTasksGenerationCompletedEvent,Ot as getAgentOrchestratorSchemaTasksGenerationStartedEvent,B as getAgentOrchestratorSchemaTasksGenerationUpdateEvent,Vt as getAgentOrchestratorStepProgrammerEvent,Nt as getAgentOrchestratorStepSavedProgramRunnerEvent,Wt as getAgentOrchestratorStepUiProgrammerEvent,v as getAgentOrchestratorStepUpdateEvent,f as getAgentOrchestratorUpdateEvent,Ct as getAgentOrchestratorWikiExplorerCompletedEvent,vt as getAgentOrchestratorWikiExplorerStartedEvent,x as getAgentOrchestratorWikiExplorerUpdateEvent,kt as getAgentOrchestratorWikiInfoGeneratedEvent,lt as getAgentPlanGenerationStartedEvent,bt as getAgentPlanStepGeneratedEvent,At as getAgentPlanningDecisionCompletedEvent,ht as getAgentPlanningDecisionPlanningRequiredEvent,St as getAgentPlanningDecisionStartedEvent,h as getAgentPlanningDecisionUpdateEvent,ft as getAgentStartingOrchestratorEvent,G as getArtifactMetadata,K as getThread,qt as getThreadEventMessageId,A as getThreadEvents,ct as getUserCancelEvent,yt as getUserMessageEvent,ee as getWikiPage,Ie as isInteractionAnalyzing,q as listArtifactMetadataByThreadId,S as listRooms,L as listThreads,Y as listWikiPages,H as sendThreadMessage,J as startThread,Z as streamThreadMessageEvents,X as subscribeThreadEvents,ye as validateRoomName};
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.30",
4
+ "version": "2.0.0-alpha.32",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Hasura",
7
7
  "homepage": "https://promptql.hasura.io",