d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
116 lines
3.5 KiB
TypeScript
116 lines
3.5 KiB
TypeScript
import type { CopilotAsyncToolStatus } from '@sim/db/schema'
|
|
import {
|
|
MothershipStreamV1AsyncToolRecordStatus,
|
|
MothershipStreamV1ToolOutcome,
|
|
} from '@/lib/copilot/generated/mothership-stream-v1'
|
|
|
|
export const ASYNC_TOOL_STATUS = MothershipStreamV1AsyncToolRecordStatus
|
|
|
|
export type AsyncLifecycleStatus =
|
|
| typeof ASYNC_TOOL_STATUS.pending
|
|
| typeof ASYNC_TOOL_STATUS.running
|
|
| typeof ASYNC_TOOL_STATUS.completed
|
|
| typeof ASYNC_TOOL_STATUS.failed
|
|
| typeof ASYNC_TOOL_STATUS.cancelled
|
|
|
|
export type AsyncTerminalStatus =
|
|
| typeof ASYNC_TOOL_STATUS.completed
|
|
| typeof ASYNC_TOOL_STATUS.failed
|
|
| typeof ASYNC_TOOL_STATUS.cancelled
|
|
|
|
/**
|
|
* Confirmation statuses sent on the request-local async tool confirmation channel.
|
|
*
|
|
* `background` is still emitted by the current browser workflow runtime on `pagehide`.
|
|
*/
|
|
export const ASYNC_TOOL_CONFIRMATION_STATUS = {
|
|
background: 'background',
|
|
success: MothershipStreamV1ToolOutcome.success,
|
|
error: MothershipStreamV1ToolOutcome.error,
|
|
cancelled: MothershipStreamV1ToolOutcome.cancelled,
|
|
} as const
|
|
|
|
export type AsyncConfirmationStatus =
|
|
(typeof ASYNC_TOOL_CONFIRMATION_STATUS)[keyof typeof ASYNC_TOOL_CONFIRMATION_STATUS]
|
|
|
|
export type AsyncTerminalConfirmationStatus = AsyncConfirmationStatus
|
|
|
|
export type AsyncConfirmationProgressStatus =
|
|
| typeof ASYNC_TOOL_STATUS.pending
|
|
| typeof ASYNC_TOOL_STATUS.running
|
|
|
|
export type AsyncEphemeralConfirmationStatus = typeof ASYNC_TOOL_CONFIRMATION_STATUS.background
|
|
|
|
export type AsyncConfirmationStateStatus = AsyncConfirmationProgressStatus | AsyncConfirmationStatus
|
|
|
|
export type AsyncPromiseStatus = typeof ASYNC_TOOL_STATUS.running | AsyncTerminalConfirmationStatus
|
|
|
|
export type AsyncCompletionData = unknown
|
|
|
|
export interface AsyncCompletionEnvelope {
|
|
toolCallId: string
|
|
status: AsyncConfirmationStatus
|
|
message?: string
|
|
data?: AsyncCompletionData
|
|
runId?: string
|
|
checkpointId?: string
|
|
executionId?: string
|
|
chatId?: string
|
|
timestamp?: string
|
|
}
|
|
|
|
export type AsyncCompletionSnapshot = Pick<
|
|
AsyncCompletionEnvelope,
|
|
'status' | 'message' | 'data' | 'timestamp'
|
|
>
|
|
|
|
export interface AsyncTerminalCompletionSnapshot extends AsyncCompletionSnapshot {
|
|
status: AsyncTerminalConfirmationStatus
|
|
}
|
|
|
|
export interface AsyncConfirmationState {
|
|
status: AsyncConfirmationStateStatus
|
|
message?: string
|
|
data?: AsyncCompletionData
|
|
timestamp?: string
|
|
}
|
|
|
|
export interface AsyncCompletionSignal {
|
|
status: AsyncPromiseStatus
|
|
message?: string
|
|
data?: AsyncCompletionData
|
|
}
|
|
|
|
export function isTerminalAsyncStatus(
|
|
status: CopilotAsyncToolStatus | AsyncLifecycleStatus | string | null | undefined
|
|
): status is AsyncTerminalStatus {
|
|
return (
|
|
status === ASYNC_TOOL_STATUS.completed ||
|
|
status === ASYNC_TOOL_STATUS.failed ||
|
|
status === ASYNC_TOOL_STATUS.cancelled
|
|
)
|
|
}
|
|
|
|
export function isDeliveredAsyncStatus(
|
|
status: CopilotAsyncToolStatus | string | null | undefined
|
|
): status is typeof ASYNC_TOOL_STATUS.delivered {
|
|
return status === ASYNC_TOOL_STATUS.delivered
|
|
}
|
|
|
|
export function isAsyncTerminalConfirmationStatus(
|
|
status: string | null | undefined
|
|
): status is AsyncTerminalConfirmationStatus {
|
|
return (
|
|
status === ASYNC_TOOL_CONFIRMATION_STATUS.background ||
|
|
status === ASYNC_TOOL_CONFIRMATION_STATUS.success ||
|
|
status === ASYNC_TOOL_CONFIRMATION_STATUS.error ||
|
|
status === ASYNC_TOOL_CONFIRMATION_STATUS.cancelled
|
|
)
|
|
}
|
|
|
|
export function isAsyncEphemeralConfirmationStatus(
|
|
status: string | null | undefined
|
|
): status is AsyncEphemeralConfirmationStatus {
|
|
return status === ASYNC_TOOL_CONFIRMATION_STATUS.background
|
|
}
|