@kortix/ui 0.15.10 → 0.15.11
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/_vendor/kortix-shared.js +396 -2
- package/dist/_vendor/shared/app-config.d.ts +6 -30
- package/dist/_vendor/shared/channel-descriptors.d.ts +0 -34
- package/dist/_vendor/shared/channel-header.d.ts +2 -1
- package/dist/_vendor/shared/connector-sections.d.ts +0 -25
- package/dist/_vendor/shared/file-tags.d.ts +2 -1
- package/dist/_vendor/shared/pasted-content.d.ts +0 -4
- package/dist/_vendor/shared/pixel-mark.d.ts +0 -17
- package/dist/_vendor/shared/project-glyphs.d.ts +0 -1
- package/dist/customize/agents/agent-model-view.d.ts +11 -1
- package/dist/customize/agents/agent-model-view.js +12 -1
- package/dist/customize/agents/agent-page.js +19 -6
- package/dist/customize/agents/agent-tabs.d.ts +2 -0
- package/dist/customize/agents/agent-tabs.js +2 -0
- package/dist/customize/connectors/detail/connector-triggers.js +1 -1
- package/dist/customize/connectors/use-agent-access.d.ts +1 -0
- package/dist/customize/sections/component/teams-byo-wizard.js +4 -1
- package/dist/customize/triggers/runtime-triggers.js +13 -2
- package/dist/customize/triggers/schedule/event-trigger-copy.js +1 -1
- package/dist/customize/triggers/schedule/schedule-detail-sheet.js +5 -4
- package/dist/customize/triggers/schedule/then-fields.d.ts +5 -1
- package/dist/customize/triggers/schedule/then-fields.js +23 -3
- package/dist/customize/triggers/schedule/trigger-callouts.js +1 -1
- package/dist/customize/triggers/schedule/trigger-composer-logic.d.ts +27 -0
- package/dist/customize/triggers/schedule/trigger-composer-logic.js +51 -5
- package/dist/customize/triggers/schedule/trigger-composer.js +19 -13
- package/dist/customize/triggers/schedule/trigger-edit-logic.js +25 -5
- package/dist/customize/triggers/schedule/trigger-filter.d.ts +10 -3
- package/dist/customize/triggers/schedule/trigger-filter.js +7 -6
- package/dist/customize/triggers/schedule/trigger-readonly.js +1 -1
- package/dist/customize/triggers/schedule/trigger-runs-panel.js +1 -1
- package/dist/customize/triggers/schedule/when-event.js +1 -1
- package/dist/customize/triggers/schedule/when-schedule.d.ts +5 -1
- package/dist/customize/triggers/schedule/when-schedule.js +16 -1
- package/dist/customize/triggers/schedule-view.js +4 -2
- package/dist/i18n/en.d.ts +49 -0
- package/dist/i18n/en.js +57 -8
- package/dist/internal/layout/project-settings-nav.d.ts +17 -0
- package/dist/internal/layout/project-settings-nav.js +24 -0
- package/dist/internal/lib/capability-tab-routes.d.ts +8 -0
- package/dist/internal/lib/capability-tab-routes.js +11 -0
- package/dist/internal/stores/composer-prefill-store.d.ts +7 -0
- package/dist/internal/stores/composer-prefill-store.js +1 -0
- package/dist/session/actions/session-label.js +2 -2
- package/dist/session/agents/agent-strip.d.ts +10 -5
- package/dist/session/agents/agent-strip.js +40 -12
- package/dist/session/agents/held-messages.d.ts +6 -2
- package/dist/session/agents/held-messages.js +6 -3
- package/dist/session/composer/ComposerCard.js +4 -1
- package/dist/session/composer/agent-selector.d.ts +2 -0
- package/dist/session/composer/agent-selector.js +5 -0
- package/dist/session/composer/composer-chat-input.d.ts +1 -0
- package/dist/session/composer/composer-logic.d.ts +7 -0
- package/dist/session/composer/composer-logic.js +18 -0
- package/dist/session/composer/composer-reset.d.ts +8 -14
- package/dist/session/composer/composer-toolbar.d.ts +3 -1
- package/dist/session/composer/composer-toolbar.js +3 -3
- package/dist/session/composer/composer.d.ts +7 -0
- package/dist/session/composer/composer.js +17 -3
- package/dist/session/composer/editor/composer-editor.js +6 -4
- package/dist/session/header/session-site-header.d.ts +3 -1
- package/dist/session/header/session-site-header.js +3 -2
- package/dist/session/models/connect-model-step.d.ts +29 -0
- package/dist/session/models/connect-model-step.js +50 -0
- package/dist/session/models/use-workspace-model-gate.d.ts +11 -0
- package/dist/session/models/use-workspace-model-gate.js +62 -0
- package/dist/session/models/workspace-model-gate.d.ts +46 -0
- package/dist/session/models/workspace-model-gate.js +66 -0
- package/dist/session/prompts/session-connect-card.d.ts +63 -0
- package/dist/session/prompts/{session-connect-prompt.js → session-connect-card.js} +53 -42
- package/dist/session/thread/session-chat.js +294 -298
- package/dist/session/thread/transcript.d.ts +2 -1
- package/dist/session/thread/transcript.js +7 -3
- package/dist/session/tool/tool-part-renderer.js +7 -2
- package/dist/session/tool/tools/kortix-action-tool.js +10 -2
- package/dist/session/turn/turn-viewport.d.ts +66 -10
- package/dist/session/turn/turn-viewport.js +92 -12
- package/dist/session/turn/user-message.js +7 -5
- package/dist/styles.css +1 -1
- package/dist/test-utils/intl.d.ts +49 -0
- package/dist/workspace/admin/project-admin-dashboard.js +2 -4
- package/dist/workspace/home/existing-repo-setup-prompt.d.ts +5 -8
- package/dist/workspace/home/existing-repo-setup-prompt.js +16 -42
- package/dist/workspace/home/no-agent-home.d.ts +3 -1
- package/dist/workspace/home/no-agent-home.js +2 -2
- package/dist/workspace/layout/project-home.js +16 -9
- package/dist/workspace/sidebar/session-grouping.d.ts +1 -1
- package/dist/workspace/sidebar/session-grouping.js +1 -1
- package/dist/workspace/spaces/space-details-panel.js +2 -2
- package/dist/workspace/spaces/space-triggers.js +2 -2
- package/dist/workspace/spaces/space-view.js +11 -5
- package/package.json +15 -3
- package/dist/session/prompts/session-connect-prompt.d.ts +0 -40
|
@@ -9,9 +9,19 @@
|
|
|
9
9
|
import { type RuntimeAgentConfig } from '@kortix/sdk';
|
|
10
10
|
import { type ReactNode } from 'react';
|
|
11
11
|
type SetRuntime = <K extends keyof RuntimeAgentConfig>(key: K, value: RuntimeAgentConfig[K]) => void;
|
|
12
|
-
|
|
12
|
+
/** A program agent's command (`run`): what each turn runs in place of a model. */
|
|
13
|
+
export interface AgentProgram {
|
|
14
|
+
command: string;
|
|
15
|
+
onChange: (command: string) => void;
|
|
16
|
+
/** `timeout`, a duration (`30m`); undefined follows the default. */
|
|
17
|
+
timeout: string | undefined;
|
|
18
|
+
onTimeoutChange: (timeout: string | undefined) => void;
|
|
19
|
+
}
|
|
20
|
+
export declare function AgentModelView({ oc, setOc, footer, program, }: {
|
|
13
21
|
oc: RuntimeAgentConfig;
|
|
14
22
|
setOc: SetRuntime;
|
|
15
23
|
footer?: ReactNode;
|
|
24
|
+
/** Set for a program agent: the view shows its command instead of the model. */
|
|
25
|
+
program?: AgentProgram;
|
|
16
26
|
}): import("react").JSX.Element;
|
|
17
27
|
export {};
|
|
@@ -21,6 +21,8 @@ import { isSliderAtDefault } from '../sections/view/agent-editor-basics-fields.j
|
|
|
21
21
|
import { EditorSection, EditorSectionStyleProvider, SettingBlock, SettingRow, } from '../sections/view/agent-editor-primitives.js';
|
|
22
22
|
/** The select's value for "no variant": the model decides. */
|
|
23
23
|
const AUTO = '__auto__';
|
|
24
|
+
/** Duration syntax the program timeout field parses (`parseDurationSeconds`), not copy. */
|
|
25
|
+
const TIMEOUT_EXAMPLE = '30m';
|
|
24
26
|
/** A slider that can be unset: `—` and no Reset while it follows the default. */
|
|
25
27
|
function SliderField({ label, help, value, fallback, min, max, step, onChange, }) {
|
|
26
28
|
const t = useI18nTranslations('agentEditor.modelView');
|
|
@@ -52,7 +54,16 @@ function ProviderOptions({ value, onChange, }) {
|
|
|
52
54
|
// The section title names it; the row holds the rule and the field.
|
|
53
55
|
_jsxs("div", { className: "space-y-2.5 px-4 py-3", children: [_jsx("p", { className: "text-muted-foreground text-xs leading-normal text-pretty", children: tTabs('providerOptionsHelp') }), _jsx(Textarea, { "aria-label": tTabs('providerOptions'), value: text, placeholder: JSON.stringify({ reasoning: 'high' }), className: "min-h-20 font-mono text-xs", "aria-invalid": invalid || undefined, onChange: (e) => commit(e.target.value) }), invalid ? _jsx("p", { className: "text-destructive text-xs", children: tTabs('providerOptionsInvalid') }) : null] }));
|
|
54
56
|
}
|
|
55
|
-
|
|
57
|
+
function ProgramView({ program, footer }) {
|
|
58
|
+
const t = useI18nTranslations('agentEditor.modelView');
|
|
59
|
+
return (_jsx(EditorSectionStyleProvider, { value: "panel", children: _jsxs("div", { className: "mx-auto flex w-full max-w-3xl flex-col gap-8", children: [_jsxs(EditorSection, { title: t('programTitle'), lead: true, children: [_jsx(SettingBlock, { label: t('programCommand'), help: t('programHelp'), children: _jsx(Input, { "aria-label": t('programCommand'), value: program.command, spellCheck: false, className: "h-8 font-mono text-xs", onChange: (e) => program.onChange(e.target.value) }) }), _jsx(SettingRow, { label: t('programTimeout'), help: t('programTimeoutHelp'), children: _jsx(Input, { "aria-label": t('programTimeout'), value: program.timeout ?? '', placeholder: TIMEOUT_EXAMPLE, spellCheck: false, className: "h-8 font-mono text-xs", onChange: (e) => program.onTimeoutChange(e.target.value.trim() || undefined) }) })] }), footer] }) }));
|
|
60
|
+
}
|
|
61
|
+
export function AgentModelView({ oc, setOc, footer, program, }) {
|
|
62
|
+
if (program)
|
|
63
|
+
return _jsx(ProgramView, { program: program });
|
|
64
|
+
return _jsx(ModelView, { oc: oc, setOc: setOc, footer: footer });
|
|
65
|
+
}
|
|
66
|
+
function ModelView({ oc, setOc, footer }) {
|
|
56
67
|
const t = useI18nTranslations('agentEditor.modelView');
|
|
57
68
|
const tTabs = useI18nTranslations('agentEditor.tabs');
|
|
58
69
|
const { data: providers } = useRuntimeProviders();
|
|
@@ -278,13 +278,18 @@ function useSaveShortcut(dirty, onSave) {
|
|
|
278
278
|
* can be sent to. People opens the Share dialog, and only for a caller who
|
|
279
279
|
* may manage members (`onPeople`).
|
|
280
280
|
*/
|
|
281
|
-
function useRailGroups(pathname, views, counts, onPeople
|
|
281
|
+
function useRailGroups(pathname, views, counts, onPeople,
|
|
282
|
+
/** A program agent (`run`): its Model row is its Program. */
|
|
283
|
+
program = false) {
|
|
282
284
|
const t = useI18nTranslations('agentEditor.tabs');
|
|
285
|
+
const tModel = useI18nTranslations('agentEditor.modelView');
|
|
283
286
|
const tI18nComplete = useI18nTranslations('hardcodedUi.i18nComplete');
|
|
284
287
|
const catalog = useLocalizedAgentConfigCatalog();
|
|
285
|
-
const labelOf = (key) => key === '
|
|
286
|
-
?
|
|
287
|
-
:
|
|
288
|
+
const labelOf = (key) => key === 'model' && program
|
|
289
|
+
? tModel('programTitle')
|
|
290
|
+
: key === 'subagents'
|
|
291
|
+
? tI18nComplete.raw('agentsListSubagentsTitle')
|
|
292
|
+
: (catalog.sections.find((s) => s.key === key)?.label ?? key);
|
|
288
293
|
const viewRows = (keys) => keys
|
|
289
294
|
.filter((key) => views.includes(key))
|
|
290
295
|
.map((key) => ({ key, label: labelOf(key), href: sectionLocationHref(pathname, key) }));
|
|
@@ -397,6 +402,7 @@ function EditableAgentPage({ projectId, agent, config, initial, renderApps, }) {
|
|
|
397
402
|
const [confirmDiscard, setConfirmDiscard] = useState(false);
|
|
398
403
|
const pathname = useUiPathname();
|
|
399
404
|
const drivesOn = useFeatureFlag(projectId, 'drives').enabled;
|
|
405
|
+
const programAgentsOn = useFeatureFlag(projectId, 'program_agents').enabled;
|
|
400
406
|
const views = useMemo(() => AGENT_CONFIG_SECTIONS.map((s) => s.key).filter((k) => drivesOn || k !== 'drives'), [drivesOn]);
|
|
401
407
|
const location = useAgentLocation(AGENT_TABS, views);
|
|
402
408
|
const share = useShareDialog(location.open === 'share');
|
|
@@ -444,7 +450,7 @@ function EditableAgentPage({ projectId, agent, config, initial, renderApps, }) {
|
|
|
444
450
|
const leaveGuard = useUnsavedChangesGuard(editor.isDirty, pathname);
|
|
445
451
|
useSaveShortcut(editor.isDirty, saveNow);
|
|
446
452
|
const canManageMembers = useCanManageMembers(projectId);
|
|
447
|
-
const railGroups = useRailGroups(pathname, views, facts, canManageMembers ? () => share.setOpen(true) : undefined);
|
|
453
|
+
const railGroups = useRailGroups(pathname, views, facts, canManageMembers ? () => share.setOpen(true) : undefined, programAgentsOn && typeof editor.draft.run === 'string');
|
|
448
454
|
const railItems = railGroups.flatMap((group) => group.items);
|
|
449
455
|
const dirtyItems = useMemo(() => changedItems(editor.draft, editor.baseline), [editor.draft, editor.baseline]);
|
|
450
456
|
const changed = new Intl.ListFormat(locale, { type: 'conjunction' }).format(dirtyItems.map((key) => railItems.find((item) => item.key === key)?.label ?? key));
|
|
@@ -478,7 +484,14 @@ function EditableAgentPage({ projectId, agent, config, initial, renderApps, }) {
|
|
|
478
484
|
// Model is this agent's model only. The project-wide gateway screens
|
|
479
485
|
// (providers, routing, costs, logs) live once, in Project admin.
|
|
480
486
|
if (view === 'model')
|
|
481
|
-
return (_jsx(AgentTabBody, { children: _jsx(AgentModelView, { oc: editor.oc, setOc: editor.setOc, footer: _jsx(ProjectModelsLink, { projectId: projectId })
|
|
487
|
+
return (_jsx(AgentTabBody, { children: _jsx(AgentModelView, { oc: editor.oc, setOc: editor.setOc, footer: _jsx(ProjectModelsLink, { projectId: projectId }), program: programAgentsOn && typeof editor.draft.run === 'string'
|
|
488
|
+
? {
|
|
489
|
+
command: editor.draft.run,
|
|
490
|
+
onChange: (next) => editor.set('run', next),
|
|
491
|
+
timeout: editor.draft.timeout,
|
|
492
|
+
onTimeoutChange: (next) => editor.set('timeout', next),
|
|
493
|
+
}
|
|
494
|
+
: undefined }) }));
|
|
482
495
|
return (_jsx(AgentTabBody, { className: `${view === 'workspace' ? CENTER_COLUMN : RAIL_COLUMN} space-y-5`, children: _jsx(CapabilityShellEmbedProvider, { value: { agentName: agent.name }, children: editorSection(view) }) }));
|
|
483
496
|
}
|
|
484
497
|
case 'triggers':
|
|
@@ -65,6 +65,8 @@ export declare const YAML_KEY_ROW: {
|
|
|
65
65
|
readonly top_p: "model";
|
|
66
66
|
readonly steps: "model";
|
|
67
67
|
readonly options: "model";
|
|
68
|
+
readonly run: "model";
|
|
69
|
+
readonly timeout: "model";
|
|
68
70
|
readonly tools: "tools";
|
|
69
71
|
readonly codemode: "tools";
|
|
70
72
|
readonly context: "tools";
|
|
@@ -50,7 +50,7 @@ export function ConnectorTriggers({ projectId, connector, displayName, }) {
|
|
|
50
50
|
const [creating, setCreating] = useState(false);
|
|
51
51
|
if (isError)
|
|
52
52
|
return null;
|
|
53
|
-
return (_jsxs("section", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx(Label, { children: tI18nComplete.raw('
|
|
53
|
+
return (_jsxs("section", { className: "space-y-2", children: [_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx(Label, { children: tI18nComplete.raw('text458ceb31019b') }), controls.canCreate ? (_jsxs(Button, { size: "sm", variant: "secondary", className: "gap-1.5", onClick: () => setCreating(true), children: [_jsx(PlusIcon, { className: "size-4 shrink-0" }), tI18nComplete.raw('text85a6c98e5584')] })) : null] }), isLoading ? (_jsx(Skeleton, { className: "h-14 rounded-md" })) : rows.length === 0 ? (_jsx("p", { className: "text-muted-foreground text-xs text-pretty", children: tI18nComplete('text974e43358191', {
|
|
54
54
|
name: displayName,
|
|
55
55
|
}) })) : (_jsx("ul", { className: "space-y-2", children: rows.map((trigger) => (_jsxs("li", { className: "bg-popover flex items-center gap-3 rounded-md border px-4 py-2", children: [_jsx(TriggerTile, { trigger: trigger, surface: "bg-popover" }), _jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "flex min-w-0 items-center gap-2", children: [_jsx(Link, { href: adminPath(projectId, `triggers?id=${encodeURIComponent(trigger.slug)}`), className: "min-w-0 truncate text-sm font-medium hover:underline", children: triggerName(trigger) }), _jsx(TriggerStatusBadge, { trigger: trigger })] }), _jsx("span", { className: "text-muted-foreground block truncate text-xs", children: describeWhen(trigger, eventNames) }), trigger.event ? (_jsx("span", { className: "text-muted-foreground block truncate text-xs", children: describeEventSource(trigger.event, tI18nComplete, appIndex) })) : null] })] }, trigger.slug))) })), _jsx(TriggerComposer, { projectId: projectId, open: creating, onOpenChange: setCreating, onCreated: () => setCreating(false), initialKind: "event", initialConnector: { slug: connector.slug, name: displayName } })] }));
|
|
56
56
|
}
|
|
@@ -79,7 +79,10 @@ export function TeamsByoWizard({ projectId, mode, open, onOpenChange, }) {
|
|
|
79
79
|
const [tenantId, setTenantId] = useState('');
|
|
80
80
|
const [error, setError] = useState(null);
|
|
81
81
|
const connect = useConnectTeams();
|
|
82
|
-
|
|
82
|
+
// The wizard stays mounted while closed. Fetch the manifest only on step 3:
|
|
83
|
+
// before connect stores the app id the route answers 409, and an eager
|
|
84
|
+
// fetch put that 409 (plus its retries) on every channels page load.
|
|
85
|
+
const manifest = useTeamsManifest(open && step === 3 ? projectId : null);
|
|
83
86
|
const endpoint = byoMessagingEndpoint(mode?.messagingEndpoint, projectId);
|
|
84
87
|
const steps = [
|
|
85
88
|
{ step: 1, title: tI18nComplete.raw('text7f1b55a356b0') },
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useUnifiedTriggers } from '@kortix/sdk/react';
|
|
4
4
|
import { PlayIcon, TrashIcon } from '@phosphor-icons/react';
|
|
5
|
-
import { useState } from 'react';
|
|
5
|
+
import { useEffect, useRef, useState } from 'react';
|
|
6
6
|
import { useLocale, useTranslations } from '../../i18n/index.js';
|
|
7
7
|
import { relativeTime } from '../../internal/lib/relative-time.js';
|
|
8
8
|
import { Button } from '../../primitives/button.js';
|
|
@@ -14,6 +14,9 @@ import { Label } from '../../primitives/label.js';
|
|
|
14
14
|
import Loading from '../../primitives/loading.js';
|
|
15
15
|
import { Switch } from '../../primitives/switch.js';
|
|
16
16
|
import { errorToast } from '../../primitives/toast.js';
|
|
17
|
+
import { cn } from '../../internal/lib/utils.js';
|
|
18
|
+
import { useUiSearchParams } from '../../providers/ui-provider.js';
|
|
19
|
+
import { readTriggerSheet } from './schedule/trigger-filter.js';
|
|
17
20
|
/** Source labels: the strings the trigger kinds already show, plus the merge. */
|
|
18
21
|
const SOURCE_KEY = {
|
|
19
22
|
schedule: 'textf4830a1dae29',
|
|
@@ -37,6 +40,14 @@ export function RuntimeTriggers({ projectId, agentName = null }) {
|
|
|
37
40
|
const triggers = useUnifiedTriggers(projectId);
|
|
38
41
|
const [deleteTarget, setDeleteTarget] = useState(null);
|
|
39
42
|
const rows = runtimeRowsFor(triggers.data?.triggers ?? [], agentName);
|
|
43
|
+
// `?id=<runtime id>` names one row (a loop's Manage link): mark it and bring it into view once.
|
|
44
|
+
const openId = readTriggerSheet(useUiSearchParams()).slug;
|
|
45
|
+
const openRow = rows.some((a) => a.id === openId) ? openId : null;
|
|
46
|
+
const openRef = useRef(null);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (openRow)
|
|
49
|
+
openRef.current?.scrollIntoView({ block: 'center' });
|
|
50
|
+
}, [openRow]);
|
|
40
51
|
if (rows.length === 0)
|
|
41
52
|
return null;
|
|
42
53
|
const onError = (error) => errorToast(error?.message ?? String(error));
|
|
@@ -48,7 +59,7 @@ export function RuntimeTriggers({ projectId, agentName = null }) {
|
|
|
48
59
|
return (_jsxs("section", { className: "space-y-2 pt-4", children: [_jsxs("div", { className: "space-y-0.5", children: [_jsx(Label, { children: t.raw('text41bec5c0977c') }), _jsx("p", { className: "text-muted-foreground text-xs", children: t.raw('text8898c02a816e') })] }), _jsx("ul", { className: "space-y-2", children: rows.map((a) => {
|
|
49
60
|
const busy = (triggers.update.isPending && triggers.update.variables?.triggerId === a.id) ||
|
|
50
61
|
(triggers.run.isPending && triggers.run.variables?.triggerId === a.id);
|
|
51
|
-
return (_jsxs("li", {
|
|
62
|
+
return (_jsxs("li", { ref: a.id === openRow ? openRef : undefined, "data-trigger-id": a.id, "aria-current": a.id === openRow ? 'true' : undefined, className: cn('flex items-center gap-3 rounded-md border px-4 py-2', a.id === openRow ? 'bg-hover' : 'bg-popover'), children: [_jsxs("div", { className: "min-w-0 flex-1 space-y-0.5", children: [_jsx("p", { className: "text-foreground truncate text-sm font-medium", children: a.name ?? a.prompt }), _jsxs(InlineMeta, { children: [_jsx("span", { children: t.raw(SOURCE_KEY[a.source.type]) }), scheduleText(a.source) ? _jsx("span", { className: "font-mono", children: scheduleText(a.source) }) : null, _jsx("span", { className: "truncate", children: target(a) }), a.state === 'active' && a.next_fire_at ? (_jsxs("span", { children: [t.raw('textb3c0ab96930c'), " ", relativeTime(a.next_fire_at, locale)] })) : null, _jsxs("span", { children: [t.raw('text512a48218ba2'), ' ', a.last_fired_at ? relativeTime(a.last_fired_at, locale) : t.raw('text6300ef800bb8')] })] }), a.last_error ? _jsx("p", { className: "text-destructive truncate text-xs", children: a.last_error }) : null] }), busy ? _jsx(Loading, { className: "size-4 shrink-0" }) : null, _jsx(Switch, { checked: a.state === 'active', disabled: a.state === 'done' || busy, "aria-label": a.state === 'active' ? t.raw('text858e4ba7a29f') : t.raw('textd640c7421da0'), onCheckedChange: (enabled) => triggers.update.mutate({ triggerId: a.id, enabled }, { onError }) }), _jsxs(ButtonGroup, { children: [_jsx(Hint, { label: t.raw('text0991397702fa'), children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": t.raw('text0991397702fa'), disabled: busy, onClick: () => triggers.run.mutate({ triggerId: a.id }, { onError }), children: _jsx(PlayIcon, { className: "size-4 shrink-0" }) }) }), _jsx(Hint, { label: t.raw('texte2d0a54968ea'), children: _jsx(Button, { variant: "ghost", size: "icon", "aria-label": t.raw('texte2d0a54968ea'), onClick: () => setDeleteTarget(a), children: _jsx(TrashIcon, { className: "size-4 shrink-0" }) }) })] })] }, a.id));
|
|
52
63
|
}) }), _jsx(ConfirmDialog, { open: !!deleteTarget, onOpenChange: (next) => {
|
|
53
64
|
if (!next)
|
|
54
65
|
setDeleteTarget(null);
|
|
@@ -15,6 +15,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
15
15
|
* for the project. A viewer who may not update the trigger sees the same facts
|
|
16
16
|
* as one read-only list.
|
|
17
17
|
*/
|
|
18
|
+
import { resolveProgramAgent } from '../../../session/composer/agent-selector.js';
|
|
18
19
|
import { Alert, AlertDescription, AlertTitle } from '../../../primitives/alert.js';
|
|
19
20
|
import { Button } from '../../../primitives/button.js';
|
|
20
21
|
import { ButtonGroup } from '../../../primitives/button-group.js';
|
|
@@ -154,9 +155,9 @@ function SheetPanel({ projectId, trigger, controls, eventsEnabled, onRun, runnin
|
|
|
154
155
|
// (webhooks), ⋯, Run now; one variant (`secondary`) at one height (`h-7`).
|
|
155
156
|
_jsxs(ButtonGroup, { className: "mb-1.5", children: [projectPaused && onResumeAll ? (_jsxs(Button, { size: "xs", variant: "secondary", className: "gap-1.5 text-xs", onClick: onResumeAll, disabled: resumingAll, children: [resumingAll ? _jsx(Loading, { className: "size-3.5 shrink-0" }) : null, t.raw('text43e673c5503d')] })) : controls.canUpdate ? (_jsxs(Button, { size: "xs", variant: "secondary", className: "gap-1.5 text-xs", onClick: () => toggle.mutate(!active), disabled: toggle.isPending, children: [toggle.isPending ? _jsx(Loading, { className: "size-3.5 shrink-0" }) : null, active ? t.raw('text858e4ba7a29f') : t.raw('textd640c7421da0')] })) : null, controls.canFire && trigger.type === 'webhook' ? (_jsx(Button, { size: "xs", variant: "secondary", className: "text-xs", onClick: () => setTestOpen(true), children: t.raw('textb098a09c78aa') })) : null, (controls.canFire && trigger.type !== 'webhook') || controls.canDelete ? (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsx(Button, { size: "icon-sm", variant: "secondary", "aria-label": t.raw('textf8d46c2570e7'), children: _jsx(DotsThreeIcon, { className: "text-muted-foreground size-4 shrink-0" }) }) }), _jsxs(DropdownMenuContent, { align: "end", className: "w-48", children: [controls.canFire && trigger.type !== 'webhook' ? (_jsxs(DropdownMenuItem, { onClick: () => setTestOpen(true), children: [_jsx(BracketsCurlyIcon, {}), t.raw('textb098a09c78aa')] })) : null, controls.canDelete ? (_jsxs(DropdownMenuItem, { variant: "destructive", onClick: onDelete, children: [_jsx(TrashIcon, {}), trigger.type === 'cron'
|
|
156
157
|
? t.raw('textd8d0bd5c5106')
|
|
157
|
-
:
|
|
158
|
-
? t.raw('
|
|
159
|
-
: t.raw('
|
|
158
|
+
: trigger.type === 'webhook'
|
|
159
|
+
? t.raw('text60f85e57e4a7')
|
|
160
|
+
: t.raw('text8043e69a8dd6')] })) : null] })] })) : null, controls.canFire ? (_jsxs(Button, { size: "xs", variant: "secondary", className: "gap-1.5 text-xs", onClick: onRun, disabled: running, children: [running ? (_jsx(SessionDotMatrix, { sessionId: trigger.slug, size: 14, className: "shrink-0" })) : (_jsx(PlayIcon, { weight: "fill", className: "size-2.5 shrink-0" })), t.raw('text0991397702fa')] })) : null] })) : null] })] }), _jsxs(SheetBody, { className: "flex-none items-stretch gap-0 space-y-6 !overflow-visible px-4 pt-5 pb-0", children: [trigger.auto_paused_at ? (_jsxs(Alert, { variant: "warning", children: [_jsx(AlertTitle, { children: tAutoPause(trigger.auto_paused_code === 'billing' ? 'billingTitle' : trigger.auto_paused_code === 'no_usable_model' ? 'modelTitle' : 'title') }), _jsxs(AlertDescription, { children: [_jsx("p", { children: tAutoPause(trigger.auto_paused_code === 'billing'
|
|
160
161
|
? 'billingDescription'
|
|
161
162
|
: trigger.auto_paused_code === 'no_usable_model'
|
|
162
163
|
? 'modelDescription'
|
|
@@ -211,7 +212,7 @@ function SheetForm({ projectId, trigger, canWrite, eventsEnabled, appIndex, even
|
|
|
211
212
|
setBase(server);
|
|
212
213
|
}, [serverKey, server, dirty]);
|
|
213
214
|
const name = draft.nameOverride ?? '';
|
|
214
|
-
const problems = validate(draft, { name, configFields, app, edit: true }, t);
|
|
215
|
+
const problems = validate(draft, { name, configFields, app, edit: true, programAgent: resolveProgramAgent(agents, draft.agent) }, t);
|
|
215
216
|
const shown = showProblems ? problems : [];
|
|
216
217
|
const blockError = (block) => shown.find((p) => p.block === block && !p.field)?.message;
|
|
217
218
|
const configErrors = {
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import { type Agent } from '@kortix/sdk/react';
|
|
2
2
|
import { type PatchDraft } from './composer-parts.js';
|
|
3
3
|
import type { ComposerDraft } from './trigger-composer-logic.js';
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Then: what a fire does. Run an agent (the instruction, which agent, which
|
|
6
|
+
* model), or call one of the project's Apps (`run: { app, path }` in
|
|
7
|
+
* kortix.yaml), which takes the payload and needs no instruction.
|
|
8
|
+
*/
|
|
5
9
|
export declare function ThenFields({ projectId, agents, draft, patch, payloadSchema, error, }: {
|
|
6
10
|
/** The workspace whose servable models the Model picker lists. */
|
|
7
11
|
projectId: string;
|
|
@@ -1,17 +1,33 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Input } from '../../../primitives/input.js';
|
|
3
4
|
import { Label } from '../../../primitives/label.js';
|
|
5
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../../primitives/select.js';
|
|
4
6
|
import { Textarea } from '../../../primitives/textarea.js';
|
|
5
7
|
import { ModelSelector } from '../../../session/models/model-selector.js';
|
|
6
8
|
import { AgentSelector } from '../../../session/composer/session-chat-input.js';
|
|
9
|
+
import { resolveProgramAgent } from '../../../session/composer/agent-selector.js';
|
|
7
10
|
import { useTranslations as useI18nTranslations } from '../../../i18n/index.js';
|
|
8
|
-
import { flattenModels, modelProviderMode, projectLlmCatalogToProviderList, useWorkspaceModelPickerCatalog, } from '@kortix/sdk/react';
|
|
11
|
+
import { flattenModels, modelProviderMode, projectLlmCatalogToProviderList, useProjectApps, useWorkspaceModelPickerCatalog, } from '@kortix/sdk/react';
|
|
9
12
|
import { useMemo, useRef } from 'react';
|
|
10
13
|
import { InlineError } from './composer-parts.js';
|
|
11
14
|
import { PromptVariableHints } from './event-trigger-fields.js';
|
|
12
|
-
|
|
15
|
+
const TARGET_ERROR_ID = 'trigger-target-error';
|
|
16
|
+
/**
|
|
17
|
+
* Then: what a fire does. Run an agent (the instruction, which agent, which
|
|
18
|
+
* model), or call one of the project's Apps (`run: { app, path }` in
|
|
19
|
+
* kortix.yaml), which takes the payload and needs no instruction.
|
|
20
|
+
*/
|
|
13
21
|
export function ThenFields({ projectId, agents, draft, patch, payloadSchema, error, }) {
|
|
14
22
|
const tI18nComplete = useI18nTranslations('hardcodedUi.i18nComplete');
|
|
23
|
+
const tComposer = useI18nTranslations('triggerComposer');
|
|
24
|
+
const callsApp = draft.thenKind === 'app';
|
|
25
|
+
// A program agent (`run`) has no model: the text is its stdin, and empty sends the payload as JSON.
|
|
26
|
+
const programAgent = resolveProgramAgent(agents, draft.agent);
|
|
27
|
+
// A null project id keeps the hook idle: only the App target lists the project's Apps.
|
|
28
|
+
const projectApps = useProjectApps(callsApp ? projectId : null).data ?? [];
|
|
29
|
+
// A saved target whose App is gone still shows its slug, so the form never reads as blank.
|
|
30
|
+
const unknownApp = draft.targetApp && !projectApps.some((app) => app.slug === draft.targetApp);
|
|
15
31
|
const promptRef = useRef(null);
|
|
16
32
|
// The workspace's servable catalog (`GET /workspaces/:id/model-picker`), read
|
|
17
33
|
// by id: a trigger runs outside any session, so the session runtime's
|
|
@@ -32,5 +48,9 @@ export function ThenFields({ projectId, agents, draft, patch, payloadSchema, err
|
|
|
32
48
|
el?.setSelectionRange(at + insert.length, at + insert.length);
|
|
33
49
|
});
|
|
34
50
|
}
|
|
35
|
-
|
|
51
|
+
const kindPicker = (_jsxs(Select, { value: draft.thenKind, onValueChange: (thenKind) => patch({ thenKind: thenKind }), children: [_jsx(SelectTrigger, { "aria-label": tComposer('thenLabel'), className: "w-full cursor-pointer text-sm sm:w-56", children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "agent", className: "cursor-pointer", children: tComposer('thenAgent') }), _jsx(SelectItem, { value: "app", className: "cursor-pointer", children: tComposer('thenApp') })] })] }));
|
|
52
|
+
if (callsApp) {
|
|
53
|
+
return (_jsxs("div", { className: "space-y-3", children: [kindPicker, _jsxs("div", { className: "grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)_7rem]", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "trigger-target-app", className: "text-xs", children: tComposer('appLabel') }), _jsxs(Select, { value: draft.targetApp ?? '', onValueChange: (targetApp) => patch({ targetApp }), children: [_jsx(SelectTrigger, { id: "trigger-target-app", className: "w-full cursor-pointer text-sm", "aria-invalid": error ? true : undefined, "aria-describedby": error ? TARGET_ERROR_ID : undefined, children: _jsx(SelectValue, { placeholder: tComposer('appPlaceholder') }) }), _jsxs(SelectContent, { children: [unknownApp ? (_jsx(SelectItem, { value: draft.targetApp, className: "cursor-pointer", children: draft.targetApp })) : null, projectApps.map((app) => (_jsx(SelectItem, { value: app.slug, className: "cursor-pointer", children: app.name }, app.app_id)))] })] })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "trigger-target-path", className: "text-xs", children: tComposer('targetPath') }), _jsx(Input, { id: "trigger-target-path", size: "xs", value: draft.targetPath, onChange: (e) => patch({ targetPath: e.target.value }), placeholder: "/", maxLength: 2048, className: "font-mono text-sm" })] }), _jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { htmlFor: "trigger-target-method", className: "text-xs", children: tComposer('targetMethod') }), _jsxs(Select, { value: draft.targetMethod, onValueChange: (method) => patch({ targetMethod: method }), children: [_jsx(SelectTrigger, { id: "trigger-target-method", className: "w-full cursor-pointer font-mono text-sm", children: _jsx(SelectValue, {}) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "POST", className: "cursor-pointer font-mono", children: "POST" }), _jsx(SelectItem, { value: "GET", className: "cursor-pointer font-mono", children: "GET" })] })] })] })] }), _jsx(InlineError, { id: TARGET_ERROR_ID, message: error }), _jsx("p", { className: "text-muted-foreground text-xs leading-relaxed text-pretty", children: tComposer('targetHelp') })] }));
|
|
54
|
+
}
|
|
55
|
+
return (_jsxs("div", { className: "space-y-3", children: [kindPicker, _jsxs("div", { className: "space-y-2", children: [_jsx(Textarea, { value: draft.instruction, ref: promptRef, onChange: (e) => patch({ instruction: e.target.value }), "aria-label": tI18nComplete.raw('text112f3ccb1b36'), "aria-invalid": error ? true : undefined, placeholder: programAgent ? tComposer('programInputPlaceholder') : tI18nComplete.raw('text2438ee64fbf9'), rows: 3, className: programAgent ? 'font-mono text-sm leading-relaxed' : 'leading-relaxed' }), _jsx(InlineError, { message: error }), programAgent ? (_jsx("p", { className: "text-muted-foreground text-xs leading-relaxed text-pretty", children: tComposer('programInputHelp') })) : draft.kind === 'event' && draft.eventType ? (_jsx(PromptVariableHints, { payloadSchema: payloadSchema, onInsert: insertVariable })) : (_jsx("p", { className: "text-muted-foreground text-xs leading-relaxed text-pretty", children: tI18nComplete.raw('text03956d4b33dc') }))] }), _jsxs("div", { className: "grid gap-3 sm:grid-cols-2", children: [_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { className: "text-xs", children: tI18nComplete.raw('text11b39c93777e') }), _jsx(AgentSelector, { agents: agents, selectedAgent: draft.agent, appearance: "field", onSelect: (agent) => patch({ agent }) })] }), programAgent ? null : (_jsxs("div", { className: "space-y-1.5", children: [_jsx(Label, { className: "text-xs", children: tI18nComplete.raw('text5e2c614c23f0') }), _jsx(ModelSelector, { models: models, providers: providers, modelsLoading: !catalog, selectedModel: draft.model, unsetLabel: tI18nComplete.raw('text57069bbd0d2e'), appearance: "field", onSelect: (model) => patch({ model }) })] }))] })] }));
|
|
36
56
|
}
|
|
@@ -24,7 +24,7 @@ export function TriggerCallouts({ projectId, trigger, canEditEvent, eventsEnable
|
|
|
24
24
|
const status = event ? describeEventStatus(event, t, apps) : null;
|
|
25
25
|
return (_jsxs(_Fragment, { children: [trigger.last_status === 'failed' ? (_jsxs(Alert, { variant: "destructive", children: [_jsx(AlertTitle, { children: tTriggers('runFailed.label') }), _jsxs(AlertDescription, { children: [trigger.last_error ? `${trigger.last_error} ` : '', tTriggers('runFailed.nextRun')] })] })) : null, event && status && trigger.enabled && !eventsEnabled && event.status === 'error' ? (
|
|
26
26
|
// A designed refusal, not a failure: a person can turn the feature on.
|
|
27
|
-
_jsxs(Alert, { variant: "warning", children: [_jsx(AlertTitle, { children: t.raw('
|
|
27
|
+
_jsxs(Alert, { variant: "warning", children: [_jsx(AlertTitle, { children: t.raw('text27ca9df9dbaa') }), _jsx(AlertDescription, { children: status.detail }), _jsx(AlertActions, { children: _jsx(Button, { asChild: true, size: "sm", variant: "outline", children: _jsx(Link, { href: projectSettingsSectionHref(projectId, 'feature-flags'), children: t.raw('text20a2e59ba129') }) }) })] })) : event && status && trigger.enabled && event.status === 'needs_connection' ? (_jsxs(Alert, { variant: "warning", children: [_jsx(AlertTitle, { children: status.label }), _jsxs(AlertDescription, { children: [status.detail, canConnect ? null : (_jsx("span", { className: "mt-1 block", children: t('textf665dfe82646', { app }) }))] }), canConnect ? (_jsx(AlertActions, { children: _jsxs(Button, { size: "sm", variant: "outline", className: "gap-1.5", disabled: Boolean(connecting), onClick: () => connect({
|
|
28
28
|
app: event.app ?? event.connector,
|
|
29
29
|
name: app,
|
|
30
30
|
connector: event.connector,
|
|
@@ -17,6 +17,11 @@ export interface ComposerDraft {
|
|
|
17
17
|
kind: TriggerKind;
|
|
18
18
|
cron: string;
|
|
19
19
|
runAt: string | null;
|
|
20
|
+
/**
|
|
21
|
+
* A fixed period (`every: 1h` in kortix.yaml) as typed, e.g. `15m`, `1h`,
|
|
22
|
+
* `1d`. Null = a calendar schedule (`cron`) or a one-off (`runAt`).
|
|
23
|
+
*/
|
|
24
|
+
every: string | null;
|
|
20
25
|
timezone: string;
|
|
21
26
|
signingKey: string;
|
|
22
27
|
/** Provider app slug (`gmail`). Null until an app is picked. */
|
|
@@ -38,6 +43,15 @@ export interface ComposerDraft {
|
|
|
38
43
|
appEvent: string;
|
|
39
44
|
/** The branch a merge must land on (kortix.yaml `filter.base`). Empty = any branch. */
|
|
40
45
|
crBase: string;
|
|
46
|
+
/** `agent` runs an agent with the instruction. `app` calls one of the project's Apps (`run: { app, path }`). */
|
|
47
|
+
thenKind: 'agent' | 'app';
|
|
48
|
+
/** The App a fire calls. Null until one is picked. */
|
|
49
|
+
targetApp: string | null;
|
|
50
|
+
/** The HTTP path on that App, starting with `/`. */
|
|
51
|
+
targetPath: string;
|
|
52
|
+
targetMethod: 'POST' | 'GET';
|
|
53
|
+
/** A fixed JSON body saved on the trigger. The form does not edit it; Save keeps it. */
|
|
54
|
+
targetPayload: Record<string, unknown> | null;
|
|
41
55
|
instruction: string;
|
|
42
56
|
agent: string | null;
|
|
43
57
|
model: ModelKey | null;
|
|
@@ -107,6 +121,17 @@ export declare function normalizeSecretName(input: string): string;
|
|
|
107
121
|
export declare function slugify(input: string): string;
|
|
108
122
|
/** The name the field proposes: it follows the When block until the person types one. */
|
|
109
123
|
export declare function autoName(draft: ComposerDraft, tI18nComplete: UiTranslator): string;
|
|
124
|
+
/** The smallest `every` period the API accepts: one minute, the cron floor. */
|
|
125
|
+
export declare const MIN_EVERY_SECONDS = 60;
|
|
126
|
+
/** `15m` → 900. Null when the text is not a period such as `5m`, `1h` or `1d`. */
|
|
127
|
+
export declare function everySeconds(raw: string | null): number | null;
|
|
128
|
+
/** What Create and Save send as `target`: the App, its path and method, and the saved fixed body. */
|
|
129
|
+
export declare function targetInput(draft: Pick<ComposerDraft, 'targetApp' | 'targetPath' | 'targetMethod' | 'targetPayload'>): {
|
|
130
|
+
app: string;
|
|
131
|
+
path: string;
|
|
132
|
+
method: 'POST' | 'GET';
|
|
133
|
+
payload?: Record<string, unknown>;
|
|
134
|
+
} | null;
|
|
110
135
|
export declare function triggerName(draft: ComposerDraft, tI18nComplete: UiTranslator): string;
|
|
111
136
|
/** An event app's source: `source`, or the deprecated `provider` of an older API. */
|
|
112
137
|
export declare const eventAppSource: (app: EventApp) => string;
|
|
@@ -135,6 +160,8 @@ export declare function validate(draft: ComposerDraft, ctx: {
|
|
|
135
160
|
now?: number;
|
|
136
161
|
/** Editing a saved trigger: its app may be missing from the catalog, and a webhook keeps its signing key. */
|
|
137
162
|
edit?: boolean;
|
|
163
|
+
/** The agent runs a program (`run`): an empty instruction sends the payload as JSON. */
|
|
164
|
+
programAgent?: boolean;
|
|
138
165
|
}, tI18nComplete: UiTranslator): ComposerProblem[];
|
|
139
166
|
/**
|
|
140
167
|
* The filter path that names an App event. The API stores an App event
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* testable without rendering.
|
|
6
6
|
*/
|
|
7
7
|
import { accountToWrite, appConnectors, configProblem, defaultEventName, defaultEventPrompt, selectedAccountLabel, } from './event-trigger-copy.js';
|
|
8
|
-
import {
|
|
8
|
+
import { parseDurationSeconds } from '../../../_vendor/kortix-shared.js';
|
|
9
|
+
import { describeCadence, describeEvery, describeOneOff, } from './schedule-copy.js';
|
|
9
10
|
import { conditionNeedsValue, rowsToConditions } from './schedule-fields.js';
|
|
10
11
|
/** The sharing a space implies: a channel thread is project-visible; a DM thread is the viewer's. */
|
|
11
12
|
export function spaceTriggerAccess(kind, viewerId) {
|
|
@@ -41,6 +42,7 @@ export function initialDraft(init) {
|
|
|
41
42
|
kind: init.kind ?? 'cron',
|
|
42
43
|
cron: '0 0 9 * * *',
|
|
43
44
|
runAt: null,
|
|
45
|
+
every: null,
|
|
44
46
|
timezone: 'UTC',
|
|
45
47
|
signingKey: '',
|
|
46
48
|
appSlug: init.appSlug ?? null,
|
|
@@ -52,6 +54,11 @@ export function initialDraft(init) {
|
|
|
52
54
|
kortixApp: null,
|
|
53
55
|
appEvent: '',
|
|
54
56
|
crBase: '',
|
|
57
|
+
thenKind: 'agent',
|
|
58
|
+
targetApp: null,
|
|
59
|
+
targetPath: '/',
|
|
60
|
+
targetMethod: 'POST',
|
|
61
|
+
targetPayload: null,
|
|
55
62
|
instruction: '',
|
|
56
63
|
agent: init.agent ?? null,
|
|
57
64
|
model: null,
|
|
@@ -124,7 +131,34 @@ export function autoName(draft, tI18nComplete) {
|
|
|
124
131
|
const event = appEventName(draft);
|
|
125
132
|
return event ? `${draft.kortixApp}: ${event}` : tI18nComplete('texte9b6dc29c812', { app: draft.kortixApp });
|
|
126
133
|
}
|
|
127
|
-
return
|
|
134
|
+
return describeDraftSchedule(draft);
|
|
135
|
+
}
|
|
136
|
+
/** The schedule as words: a one-off, a fixed period, or the cron's cadence. */
|
|
137
|
+
function describeDraftSchedule(draft) {
|
|
138
|
+
if (draft.runAt)
|
|
139
|
+
return describeOneOff(draft.runAt);
|
|
140
|
+
const every = everySeconds(draft.every);
|
|
141
|
+
if (every !== null)
|
|
142
|
+
return describeEvery(every);
|
|
143
|
+
return describeCadence(draft.cron);
|
|
144
|
+
}
|
|
145
|
+
/** The smallest `every` period the API accepts: one minute, the cron floor. */
|
|
146
|
+
export const MIN_EVERY_SECONDS = 60;
|
|
147
|
+
/** `15m` → 900. Null when the text is not a period such as `5m`, `1h` or `1d`. */
|
|
148
|
+
export function everySeconds(raw) {
|
|
149
|
+
const value = raw?.trim();
|
|
150
|
+
return value ? parseDurationSeconds(value) : null;
|
|
151
|
+
}
|
|
152
|
+
/** What Create and Save send as `target`: the App, its path and method, and the saved fixed body. */
|
|
153
|
+
export function targetInput(draft) {
|
|
154
|
+
if (!draft.targetApp)
|
|
155
|
+
return null;
|
|
156
|
+
return {
|
|
157
|
+
app: draft.targetApp,
|
|
158
|
+
path: draft.targetPath.trim() || '/',
|
|
159
|
+
method: draft.targetMethod,
|
|
160
|
+
...(draft.targetPayload ? { payload: draft.targetPayload } : {}),
|
|
161
|
+
};
|
|
128
162
|
}
|
|
129
163
|
export function triggerName(draft, tI18nComplete) {
|
|
130
164
|
return draft.nameOverride ?? autoName(draft, tI18nComplete);
|
|
@@ -176,8 +210,8 @@ agent, tI18nComplete) {
|
|
|
176
210
|
agent,
|
|
177
211
|
});
|
|
178
212
|
}
|
|
179
|
-
const when = draft.runAt
|
|
180
|
-
?
|
|
213
|
+
const when = draft.runAt || draft.every !== null
|
|
214
|
+
? describeDraftSchedule(draft)
|
|
181
215
|
: `${describeCadence(draft.cron)} (${draft.timezone})`;
|
|
182
216
|
return tI18nComplete('text922ecdf9cffc', { when, agent });
|
|
183
217
|
}
|
|
@@ -211,13 +245,25 @@ export function validate(draft, ctx, tI18nComplete) {
|
|
|
211
245
|
else if (Date.parse(draft.runAt) <= (ctx.now ?? Date.now()))
|
|
212
246
|
add('when', tI18nComplete.raw('textebfef07e2d2b'));
|
|
213
247
|
}
|
|
248
|
+
else if (draft.every !== null) {
|
|
249
|
+
const seconds = everySeconds(draft.every);
|
|
250
|
+
if (seconds === null || seconds < MIN_EVERY_SECONDS)
|
|
251
|
+
add('when', tI18nComplete.raw('text30b9ce09f406'));
|
|
252
|
+
}
|
|
214
253
|
else if (!draft.cron.trim())
|
|
215
254
|
add('when', tI18nComplete.raw('texta1b7270dbe34'));
|
|
216
255
|
}
|
|
217
256
|
else if (draft.kind === 'webhook' && !ctx.edit && !draft.signingKey.trim()) {
|
|
218
257
|
add('when', tI18nComplete.raw('textc10cd37e5462'));
|
|
219
258
|
}
|
|
220
|
-
|
|
259
|
+
// An App target receives the payload, not a prompt: it needs the App and a path instead.
|
|
260
|
+
if (draft.thenKind === 'app') {
|
|
261
|
+
if (!draft.targetApp)
|
|
262
|
+
add('then', tI18nComplete.raw('text28d33d2ad989'));
|
|
263
|
+
else if (!draft.targetPath.trim().startsWith('/'))
|
|
264
|
+
add('then', tI18nComplete.raw('textd777d7805cfa'));
|
|
265
|
+
}
|
|
266
|
+
else if (!draft.instruction.trim() && !ctx.programAgent)
|
|
221
267
|
add('then', tI18nComplete.raw('texte7cd9e292007'));
|
|
222
268
|
if (!ctx.name.trim())
|
|
223
269
|
add('name', tI18nComplete.raw('textb67ba8d96c42'));
|
|
@@ -15,6 +15,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
15
15
|
* panel and links to the fix: no App sends events (Apps), or connector events
|
|
16
16
|
* are off (the beta flag `event_triggers`, Project admin › Feature flags).
|
|
17
17
|
*/
|
|
18
|
+
import { resolveProgramAgent } from '../../../session/composer/agent-selector.js';
|
|
18
19
|
import { Button } from '../../../primitives/button.js';
|
|
19
20
|
import { Alert as BannerAlert, AlertDescription as BannerAlertDescription, AlertActions as BannerAlertActions } from '../../../primitives/alert.js';
|
|
20
21
|
import { Input } from '../../../primitives/input.js';
|
|
@@ -39,7 +40,7 @@ import { appConnectors, describeEventStatus, draftToConfig, eventAppTarget, pars
|
|
|
39
40
|
import { COMPOSER_KINDS, describeCadence, describeOneOff } from './schedule-copy.js';
|
|
40
41
|
import { triggerToastEntity } from './trigger-toast.js';
|
|
41
42
|
import { ThenFields } from './then-fields.js';
|
|
42
|
-
import { runCapFromInput, eventSendingApps, findDraftApp, initialDraft, normalizeSecretName, runCreate, slugify, spaceTriggerAccess, summarize, triggerConnection, triggerFilter, triggerName, validate, withKind, } from './trigger-composer-logic.js';
|
|
43
|
+
import { runCapFromInput, eventSendingApps, findDraftApp, initialDraft, normalizeSecretName, runCreate, slugify, spaceTriggerAccess, summarize, triggerConnection, targetInput, triggerFilter, triggerName, validate, withKind, } from './trigger-composer-logic.js';
|
|
43
44
|
import { PostToField } from './post-to-field.js';
|
|
44
45
|
import { TriggerOptions } from './trigger-options.js';
|
|
45
46
|
import { useEventAppConnect } from './use-event-app-connect.js';
|
|
@@ -135,7 +136,7 @@ function ComposerForm({ projectId, onOpenChange, onCreated, initialAgent = null,
|
|
|
135
136
|
const app = frozenApp ?? liveApp;
|
|
136
137
|
const configFields = useMemo(() => schemaFields(draft.eventType?.config_schema), [draft.eventType]);
|
|
137
138
|
const name = triggerName(draft, tI18nComplete);
|
|
138
|
-
const problems = validate(draft, { name, configFields, app }, tI18nComplete);
|
|
139
|
+
const problems = validate(draft, { name, configFields, app, programAgent: resolveProgramAgent(agents, draft.agent) }, tI18nComplete);
|
|
139
140
|
const shown = showProblems ? problems : [];
|
|
140
141
|
const blockError = (block) => shown.find((p) => p.block === block && !p.field)?.message;
|
|
141
142
|
const configErrors = {
|
|
@@ -210,7 +211,8 @@ function ComposerForm({ projectId, onOpenChange, onCreated, initialAgent = null,
|
|
|
210
211
|
name: trimmedName,
|
|
211
212
|
slug,
|
|
212
213
|
type: draft.kind,
|
|
213
|
-
prompt_template: draft.instruction.trim(),
|
|
214
|
+
prompt_template: draft.thenKind === 'app' ? '' : draft.instruction.trim(),
|
|
215
|
+
...(draft.thenKind === 'app' && targetInput(draft) ? { target: targetInput(draft) } : {}),
|
|
214
216
|
enabled: draft.startActive,
|
|
215
217
|
...(draft.agent ? { agent: draft.agent } : {}),
|
|
216
218
|
...(draft.model ? { model: modelKeyToWire(draft.model) } : {}),
|
|
@@ -226,9 +228,11 @@ function ComposerForm({ projectId, onOpenChange, onCreated, initialAgent = null,
|
|
|
226
228
|
...(draft.mode === 'keyed' ? { session_key: draft.sessionKey.trim() } : {}),
|
|
227
229
|
...(!isCron && filter ? { filter } : {}),
|
|
228
230
|
...(isCron
|
|
229
|
-
? draft.
|
|
230
|
-
? {
|
|
231
|
-
:
|
|
231
|
+
? draft.every !== null
|
|
232
|
+
? { every: draft.every.trim() }
|
|
233
|
+
: draft.runAt
|
|
234
|
+
? { run_at: draft.runAt, timezone: draft.timezone.trim() || 'UTC' }
|
|
235
|
+
: { cron: draft.cron.trim(), timezone: draft.timezone.trim() || 'UTC' }
|
|
232
236
|
: isEvent
|
|
233
237
|
? {
|
|
234
238
|
...triggerConnection(app, draft, added),
|
|
@@ -256,13 +260,15 @@ function ComposerForm({ projectId, onOpenChange, onCreated, initialAgent = null,
|
|
|
256
260
|
: describeCadence(draft.cron.trim())
|
|
257
261
|
: undefined;
|
|
258
262
|
const isChangeRequest = draft.kind === 'change_request';
|
|
259
|
-
successToast(isEvent
|
|
260
|
-
? tI18nComplete.raw('
|
|
261
|
-
:
|
|
262
|
-
? tI18nComplete.raw('
|
|
263
|
-
:
|
|
264
|
-
? tI18nComplete.raw('
|
|
265
|
-
:
|
|
263
|
+
successToast(isEvent
|
|
264
|
+
? tI18nComplete.raw('textd6fa1626e3af')
|
|
265
|
+
: isApp
|
|
266
|
+
? tI18nComplete.raw('text840993da3129')
|
|
267
|
+
: isCron
|
|
268
|
+
? tI18nComplete.raw('text84e98b45ad8b')
|
|
269
|
+
: isChangeRequest
|
|
270
|
+
? tI18nComplete.raw('text80ca527b0d55')
|
|
271
|
+
: tI18nComplete.raw('text20bf63f7b46f'), {
|
|
266
272
|
entity: triggerToastEntity({ name: name.trim(), type: draft.kind }, cadence),
|
|
267
273
|
description: isEvent
|
|
268
274
|
? created?.event
|