|
1 | | -import { type AnyColumn, type SQL, sql } from 'drizzle-orm' |
2 | 1 | import { z } from 'zod' |
3 | | -import { secretMountPolicySchema } from '@/lib/api/contracts/secret-mount-policy' |
4 | 2 | import { hasCopilotResourceAdmission } from '@/lib/mothership/auth/application-delegation' |
5 | 3 | import { COPILOT_REQUEST_MODES } from '@/lib/mothership/constants' |
6 | 4 | import { ChatPayloadSchema } from '@/lib/mothership/generated/protocol' |
| 5 | +import { DURABLE_STREAM_KINDS } from '@/lib/mothership/request/lifecycle/durable-run' |
7 | 6 | import type { CopilotLifecycleOptions } from '@/lib/mothership/request/lifecycle/run' |
8 | | -import type { TurnSecretAuthority } from '@/lib/mothership/secret-mount-policy' |
9 | 7 |
|
10 | 8 | export const BillingAdmissionSchema = z |
11 | 9 | .object({ |
@@ -40,22 +38,6 @@ export function durableResourceAuthoringVersion( |
40 | 38 | return admitted ? RESOURCE_AUTHORING_VERSION : undefined |
41 | 39 | } |
42 | 40 |
|
43 | | -/** |
44 | | - * What a durable turn's recovery restores about its audience. An interactive stream answers a |
45 | | - * person in the chat; an unattended stream (a scheduled job's occurrence) has nobody to answer a |
46 | | - * prompt, so a recovered leg runs it non-interactively too, exactly as it was admitted. |
47 | | - */ |
48 | | -const DURABLE_STREAM_KINDS = ['interactive_stream', 'unattended_stream'] as const |
49 | | -export type DurableStreamKind = (typeof DURABLE_STREAM_KINDS)[number] |
50 | | - |
51 | | -/** A run's saved request context names a durable turn that recovery can take over. */ |
52 | | -export function isDurableStreamRun(requestContext: AnyColumn): SQL { |
53 | | - return sql`${requestContext}->'recovery'->>'kind' IN (${sql.join( |
54 | | - DURABLE_STREAM_KINDS.map((kind) => sql`${kind}`), |
55 | | - sql`, ` |
56 | | - )})` |
57 | | -} |
58 | | - |
59 | 41 | export const StreamRecoveryConfigSchema = z |
60 | 42 | .object({ |
61 | 43 | kind: z.enum(DURABLE_STREAM_KINDS), |
@@ -109,17 +91,3 @@ export async function streamRecoveryConfig( |
109 | 91 | ...(resourceAuthoringVersion ? { resourceAuthoringVersion } : {}), |
110 | 92 | }) |
111 | 93 | } |
112 | | - |
113 | | -const RecordedSecretAuthoritySchema = z.object({ |
114 | | - secretMountPolicy: secretMountPolicySchema, |
115 | | - secretActorUserId: z.string().nullable(), |
116 | | -}) |
117 | | - |
118 | | -/** |
119 | | - * The secret authority a run recorded at admission (`requestContext.secretAuthority`), or |
120 | | - * undefined when it recorded none or garbage. |
121 | | - */ |
122 | | -export function parseRecordedSecretAuthority(value: unknown): TurnSecretAuthority | undefined { |
123 | | - const recorded = RecordedSecretAuthoritySchema.safeParse(value) |
124 | | - return recorded.success ? recorded.data : undefined |
125 | | -} |
0 commit comments