diff --git a/src/lib/sessionSchema/index.ts b/src/lib/sessionSchema/index.ts index ceb5657..4a072f4 100644 --- a/src/lib/sessionSchema/index.ts +++ b/src/lib/sessionSchema/index.ts @@ -97,15 +97,6 @@ export const toPayload = async (server: CoralServer, data: z.output) } satisfies CreateSessionRequest; }; -// export const defaultPayload = { -// groups: [], -// tools: {}, -// sessionRuntimeSettings: { -// ttl: 50000 -// }, -// agents: [] -// } satisfies CreateSessionRequest; - export const defaultProvider = { runtime: 'executable', remote_request: { @@ -139,14 +130,11 @@ export const importFromPayload = (json: string): z.output => { ]; }) ); - const defaultRuntimeSettings = { - ttl: 50000 - }; + return { tools, groups: data.agentGraphRequest.groups ?? [], sessionRuntimeSettings: { - ...defaultRuntimeSettings, ...(data.execution && data.execution.mode === 'immediate' ? data.execution.runtimeSettings : {}) diff --git a/src/lib/sessionSchema/types.ts b/src/lib/sessionSchema/types.ts index 7c88bac..864dd2f 100644 --- a/src/lib/sessionSchema/types.ts +++ b/src/lib/sessionSchema/types.ts @@ -222,7 +222,7 @@ export type CustomTool = z.output; const formSchema = z.object({ sessionRuntimeSettings: z.object({ - ttl: z.number().min(10000).max(15778476000).default(900000) + ttl: z.number().min(10000).max(15778476000).optional() }), sessionBudgetSettings: z.object({ budget: z.number().min(10000).default(100000000), diff --git a/src/routes/(app)/workbench/options/DurationInout.svelte b/src/routes/(app)/workbench/options/DurationInout.svelte new file mode 100644 index 0000000..3bb6032 --- /dev/null +++ b/src/routes/(app)/workbench/options/DurationInout.svelte @@ -0,0 +1,140 @@ + + + + + + Hours + + + onFocusSegment(e, 'h')} + onblur={(e) => onBlurSegment(e, 'h')} + oninput={(e) => (editH = e.currentTarget.value)} + {disabled} + placeholder="0" + maxlength={4} + inputmode="numeric" + type="text" + /> + + + + + Minutes + + + onFocusSegment(e, 'm')} + onblur={(e) => onBlurSegment(e, 'm')} + oninput={(e) => (editM = e.currentTarget.value)} + {disabled} + placeholder="00" + maxlength={2} + inputmode="numeric" + type="text" + /> + + + + + Seconds + + + onFocusSegment(e, 's')} + onblur={(e) => onBlurSegment(e, 's')} + oninput={(e) => (editS = e.currentTarget.value)} + {disabled} + placeholder="00" + maxlength={2} + inputmode="numeric" + type="text" + /> + + diff --git a/src/routes/(app)/workbench/panes/SessionPane.svelte b/src/routes/(app)/workbench/panes/SessionPane.svelte index 9816941..d449b15 100644 --- a/src/routes/(app)/workbench/panes/SessionPane.svelte +++ b/src/routes/(app)/workbench/panes/SessionPane.svelte @@ -29,6 +29,7 @@ import { randomAdjective, randomAnimal } from '$lib/words'; import { getSessionContext } from '$lib/sessionCreatorContext'; import { cn } from '$lib/utils'; + import DurationInout from '../options/DurationInout.svelte'; let ctx = getSessionContext(); @@ -48,7 +49,7 @@ {#if ctx && $formData}
-

Time to live restricts how long a session can remain alive and open for.

+

If specified, the session will never live longer than this duration.

{#snippet children({ props })} @@ -56,30 +57,28 @@ title="Time to live (TTL)" tooltip="Measured in milliseconds, the time to live is the maximum duration the session can last" extra={{ - required: true, type: 'number' }} class="max-w-1/4 min-w-1/4" > Time to live - { + if (totalMilliseconds === 0) { + delete $formData.sessionRuntimeSettings.ttl; + $formData.sessionBudgetSettings = $formData.sessionBudgetSettings; + } else { + $formData.sessionRuntimeSettings.ttl = totalMilliseconds; + } + }} /> {/snippet} - - - Maximum session duration: {formatMsToHHMMSS($formData.sessionRuntimeSettings.ttl ?? 0) ?? - 'HH:MM:SS'} - - + {#if $errors?.sessionRuntimeSettings?.ttl && JSON.stringify($errors.sessionRuntimeSettings?.ttl) !== '{}' && JSON.stringify($errors.sessionRuntimeSettings?.ttl) !== '{}'} {$errors?.sessionRuntimeSettings?.ttl}