-
Notifications
You must be signed in to change notification settings - Fork 70
sync agent rule #476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
sync agent rule #476
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,13 +3,20 @@ | |
| import Markdown from '$lib/common/markdown/Markdown.svelte'; | ||
| import BotsharpTooltip from '$lib/common/tooltip/BotsharpTooltip.svelte'; | ||
| import Select from '$lib/common/dropdowns/Select.svelte'; | ||
| import { RuleCriteriaMode } from '$lib/helpers/enums'; | ||
|
|
||
| const textLimit = 1024; | ||
|
|
||
| const criteriaModeOptions = [ | ||
| { label: 'LLM', value: RuleCriteriaMode.Llm }, | ||
| { label: 'Python Script', value: RuleCriteriaMode.PythonScript } | ||
| ]; | ||
|
|
||
| /** | ||
| * @type {{ | ||
| * rule: import('$agentTypes').AgentRule, | ||
| * ruleIndex: number, | ||
| * agentId?: string, | ||
| * collapsed?: boolean, | ||
| * ruleOptions?: any[], | ||
| * windowWidth: number, | ||
|
|
@@ -23,6 +30,7 @@ | |
| let { | ||
| rule, | ||
| ruleIndex, | ||
| agentId = '', | ||
| collapsed = true, | ||
| ruleOptions = [], | ||
| windowWidth, | ||
|
|
@@ -35,7 +43,17 @@ | |
|
|
||
| // Code script can only be generated by admins, once a trigger is picked and criteria text exists. | ||
| let canCompile = $derived( | ||
| !!rule.trigger_name && !!rule.config?.criteria?.trim() | ||
| !!rule.trigger_name && !!rule.criteria?.criteria?.trim() | ||
| ); | ||
|
|
||
| // The rule's own mode wins; otherwise the trigger option's mode applies. | ||
| let modePlaceholder = $derived( | ||
| rule.default_mode ? `Trigger default (${rule.default_mode})` : 'Trigger default' | ||
| ); | ||
|
|
||
| // Deep link to the code scripts page, preselected on this agent. | ||
| let codeScriptUrl = $derived( | ||
| agentId ? `/page/agent/code-scripts?agentId=${encodeURIComponent(agentId)}` : '' | ||
| ); | ||
|
|
||
| /** | ||
|
|
@@ -82,15 +100,32 @@ | |
|
|
||
| /** | ||
| * @param {any} e | ||
| * @param {string} field | ||
| */ | ||
| function changeCriteria(e) { | ||
| function changeText(e, field) { | ||
| onchange?.({ | ||
| ruleIdx: ruleIndex, | ||
| field: 'criteria', | ||
| field: field, | ||
| value: e?.target?.value || '' | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * The session token lives in sessionStorage, which a new tab does not get | ||
| * when the link drops the opener (`rel="noopener"`, which `target="_blank"` | ||
| * also implies on its own). Opening through window.open keeps this tab as | ||
| * the opener, so the new tab can pull the session across and skip the login | ||
| * page. Also covers ctrl/cmd-click, which would otherwise take the default | ||
| * opener-less path. | ||
| * @param {any} e | ||
| */ | ||
| function openCodeScripts(e) { | ||
| if (!codeScriptUrl) return; | ||
|
|
||
| e.preventDefault(); | ||
| window.open(codeScriptUrl, '_blank'); | ||
|
Comment on lines
+123
to
+126
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 3. Opener kept for new tab openCodeScripts() uses window.open(url, '_blank') specifically to preserve window.opener for session restoration, which means the opened tab can navigate the opener (reverse-tabnabbing/opener manipulation) if it ever reaches attacker-controlled content. This is a security tradeoff introduced by relying on opener for credential/session transfer. Agent Prompt
|
||
| } | ||
|
|
||
| function compile() { | ||
| oncompile?.({ | ||
| ruleIdx: ruleIndex, | ||
|
|
@@ -159,6 +194,8 @@ | |
| tag={`rule-trigger-${ruleIndex}`} | ||
| containerStyles={'width: 100%;'} | ||
| placeholder={'Select a trigger'} | ||
| searchMode | ||
| searchPlaceholder={'Search triggers'} | ||
| disabled={rule.disabled} | ||
| selectedValues={rule.trigger_name ? [rule.trigger_name] : []} | ||
| options={ruleOptions.filter(o => !!o.name).map(o => ({ label: o.displayName || o.name, value: o.name }))} | ||
|
|
@@ -181,7 +218,65 @@ | |
| <div class="ari-row ari-row-secondary" transition:slide={{ duration: 200 }}> | ||
| <div class="ari-label ari-label-strong"> | ||
| <div class="ari-cell"> | ||
| {'Criteria'} | ||
| {'Message'} | ||
| </div> | ||
| </div> | ||
| <div class="ari-value"> | ||
| <div class="ari-input-wrap ari-cell"> | ||
| <textarea | ||
| class="ari-textarea" | ||
| rows="3" | ||
| maxlength={textLimit} | ||
| placeholder="Message sent to the agent when this rule fires..." | ||
| disabled={rule.disabled} | ||
| value={rule.message || ''} | ||
| oninput={e => changeText(e, 'message')} | ||
| ></textarea> | ||
| </div> | ||
| <div class="ari-delete ari-cell"></div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="ari-row ari-row-secondary" transition:slide={{ duration: 200 }}> | ||
| <div class="ari-label ari-label-strong"> | ||
| <div class="ari-cell"> | ||
| {'Criteria Mode'} | ||
| </div> | ||
| </div> | ||
| <div class="ari-value"> | ||
| <div class="ari-input-wrap ari-cell"> | ||
| <Select | ||
| tag={`rule-criteria-mode-${ruleIndex}`} | ||
| containerStyles={'width: 100%;'} | ||
| placeholder={modePlaceholder} | ||
| disabled={rule.disabled} | ||
| selectedValues={rule.criteria?.mode ? [rule.criteria.mode] : []} | ||
| options={criteriaModeOptions} | ||
| onselect={e => changeRule(e, 'criteria_mode')} | ||
| /> | ||
| </div> | ||
| <div class="ari-delete ari-cell"></div> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div class="ari-row ari-row-secondary" transition:slide={{ duration: 200 }}> | ||
| <div class="ari-label ari-label-strong"> | ||
| <div class="ari-cell"> | ||
| {#if codeScriptUrl} | ||
| <a | ||
| class="ari-label-link" | ||
| href={codeScriptUrl} | ||
| target="_blank" | ||
| title="Open this agent's code scripts" | ||
| onclick={e => openCodeScripts(e)} | ||
| onauxclick={e => { if (e.button === 1) openCodeScripts(e); }} | ||
| > | ||
| <span>{'Criteria Text'}</span> | ||
| <i class="bx bx-link-external" aria-hidden="true"></i> | ||
| </a> | ||
| {:else} | ||
| {'Criteria Text'} | ||
| {/if} | ||
| </div> | ||
| {#if canCompile} | ||
| <div class="ari-cell"> | ||
|
|
@@ -207,8 +302,8 @@ | |
| maxlength={textLimit} | ||
| placeholder="Describe when this rule should trigger..." | ||
| disabled={rule.disabled} | ||
| value={rule.config?.criteria || ''} | ||
| oninput={e => changeCriteria(e)} | ||
| value={rule.criteria?.criteria || ''} | ||
| oninput={e => changeText(e, 'criteria')} | ||
| ></textarea> | ||
| </div> | ||
| <div class="ari-delete ari-cell"></div> | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2. Opener restore is one-shot
🐞 Bug☼ ReliabilityAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools