veto-sdk 2.0.0 → 2.2.0
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/browser/index.d.ts +1 -1
- package/dist/browser/index.d.ts.map +1 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/types.d.ts +17 -1
- package/dist/browser/types.d.ts.map +1 -1
- package/dist/browser/veto.d.ts +10 -0
- package/dist/browser/veto.d.ts.map +1 -1
- package/dist/browser/veto.js +68 -4
- package/dist/browser/veto.js.map +1 -1
- package/dist/cli/bin.js +0 -0
- package/dist/cloud/types.d.ts +17 -2
- package/dist/cloud/types.d.ts.map +1 -1
- package/dist/core/events.d.ts +11 -1
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/events.js +4 -0
- package/dist/core/events.js.map +1 -1
- package/dist/core/protect.d.ts +3 -1
- package/dist/core/protect.d.ts.map +1 -1
- package/dist/core/protect.js +14 -4
- package/dist/core/protect.js.map +1 -1
- package/dist/core/veto.d.ts +43 -1
- package/dist/core/veto.d.ts.map +1 -1
- package/dist/core/veto.js +248 -13
- package/dist/core/veto.js.map +1 -1
- package/dist/deterministic/types.d.ts +103 -0
- package/dist/deterministic/types.d.ts.map +1 -1
- package/dist/economic/budget-engine.d.ts +29 -0
- package/dist/economic/budget-engine.d.ts.map +1 -0
- package/dist/economic/budget-engine.js +146 -0
- package/dist/economic/budget-engine.js.map +1 -0
- package/dist/economic/connectors/ap2.d.ts +51 -0
- package/dist/economic/connectors/ap2.d.ts.map +1 -0
- package/dist/economic/connectors/ap2.js +133 -0
- package/dist/economic/connectors/ap2.js.map +1 -0
- package/dist/economic/connectors/index.d.ts +8 -0
- package/dist/economic/connectors/index.d.ts.map +1 -0
- package/dist/economic/connectors/index.js +8 -0
- package/dist/economic/connectors/index.js.map +1 -0
- package/dist/economic/connectors/mpp.d.ts +41 -0
- package/dist/economic/connectors/mpp.d.ts.map +1 -0
- package/dist/economic/connectors/mpp.js +97 -0
- package/dist/economic/connectors/mpp.js.map +1 -0
- package/dist/economic/connectors/x402.d.ts +20 -0
- package/dist/economic/connectors/x402.d.ts.map +1 -0
- package/dist/economic/connectors/x402.js +142 -0
- package/dist/economic/connectors/x402.js.map +1 -0
- package/dist/economic/evaluator.d.ts +77 -0
- package/dist/economic/evaluator.d.ts.map +1 -0
- package/dist/economic/evaluator.js +231 -0
- package/dist/economic/evaluator.js.map +1 -0
- package/dist/economic/index.d.ts +13 -0
- package/dist/economic/index.d.ts.map +1 -0
- package/dist/economic/index.js +15 -0
- package/dist/economic/index.js.map +1 -0
- package/dist/economic/types.d.ts +188 -0
- package/dist/economic/types.d.ts.map +1 -0
- package/dist/economic/types.js +10 -0
- package/dist/economic/types.js.map +1 -0
- package/dist/extractors/content.d.ts +42 -0
- package/dist/extractors/content.d.ts.map +1 -0
- package/dist/extractors/content.js +154 -0
- package/dist/extractors/content.js.map +1 -0
- package/dist/extractors/index.d.ts +7 -0
- package/dist/extractors/index.d.ts.map +1 -0
- package/dist/extractors/index.js +7 -0
- package/dist/extractors/index.js.map +1 -0
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -2
- package/dist/index.js.map +1 -1
- package/dist/policy/generator.d.ts +110 -0
- package/dist/policy/generator.d.ts.map +1 -0
- package/dist/policy/generator.js +463 -0
- package/dist/policy/generator.js.map +1 -0
- package/dist/policy/index.d.ts +7 -0
- package/dist/policy/index.d.ts.map +1 -0
- package/dist/policy/index.js +7 -0
- package/dist/policy/index.js.map +1 -0
- package/dist/providers/adapters.d.ts +27 -0
- package/dist/providers/adapters.d.ts.map +1 -1
- package/dist/providers/adapters.js +58 -0
- package/dist/providers/adapters.js.map +1 -1
- package/dist/rules/index.d.ts +1 -0
- package/dist/rules/index.d.ts.map +1 -1
- package/dist/rules/index.js +1 -0
- package/dist/rules/index.js.map +1 -1
- package/dist/rules/local-evaluator.d.ts +69 -0
- package/dist/rules/local-evaluator.d.ts.map +1 -0
- package/dist/rules/local-evaluator.js +217 -0
- package/dist/rules/local-evaluator.js.map +1 -0
- package/dist/rules/policy-ir-schema.d.ts +109 -0
- package/dist/rules/policy-ir-schema.d.ts.map +1 -1
- package/dist/rules/policy-ir-schema.js +90 -0
- package/dist/rules/policy-ir-schema.js.map +1 -1
- package/dist/rules/policy-packs.d.ts.map +1 -1
- package/dist/rules/policy-packs.js +1 -0
- package/dist/rules/policy-packs.js.map +1 -1
- package/dist/types/config.d.ts +2 -1
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js.map +1 -1
- package/dist/utils/logger.d.ts +38 -2
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +231 -26
- package/dist/utils/logger.js.map +1 -1
- package/package.json +9 -1
- package/packs/economic-agent.yaml +62 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policy generator utilities — NL-to-rule helpers for consumers who bring
|
|
3
|
+
* their own LLM.
|
|
4
|
+
*
|
|
5
|
+
* Provides the system prompt, Zod schema, rule sanitization, and instant
|
|
6
|
+
* generation for well-known patterns. Does NOT include LLM invocation.
|
|
7
|
+
*
|
|
8
|
+
* @module policy/generator
|
|
9
|
+
*/
|
|
10
|
+
import type { Rule } from '../rules/types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Result of policy generation or validation.
|
|
13
|
+
*/
|
|
14
|
+
export interface PolicyGenerationResult {
|
|
15
|
+
success: boolean;
|
|
16
|
+
rules: Rule[];
|
|
17
|
+
explanation: string;
|
|
18
|
+
warnings?: string[];
|
|
19
|
+
error?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Clarification request returned when a policy description is ambiguous.
|
|
23
|
+
*/
|
|
24
|
+
export interface PolicyClarificationRequest {
|
|
25
|
+
explanation: string;
|
|
26
|
+
questions: string[];
|
|
27
|
+
}
|
|
28
|
+
export declare const BROWSER_AGENT_SYSTEM_PROMPT = "You are a security policy compiler for a browser automation agent.\n\nConvert the user's natural-language policy into one or more Veto rules (JSON).\n\n## Rule Schema\n\nEach rule is a JSON object:\n{\n \"id\": string, // kebab-case unique ID (e.g., \"block-expensive-purchases\")\n \"name\": string, // short human-readable name\n \"description\": string, // 1-2 sentence description\n \"enabled\": true,\n \"severity\": \"critical\" | \"high\" | \"medium\" | \"low\" | \"info\",\n \"action\": \"block\" | \"warn\" | \"log\" | \"allow\" | \"require_approval\",\n \"tools\": string[], // which browser actions this applies to (omit for ALL)\n \"conditions\": [ // ALL must match (AND logic)\n { \"field\": string, \"operator\": string, \"value\": any }\n ],\n \"condition_groups\": [ // groups are OR'd; conditions within each group are AND'd\n [ { \"field\": ..., \"operator\": ..., \"value\": ... } ]\n ],\n \"tags\": string[]\n}\n\n## Available Tools (prefix: browser_)\n\nbrowser_clickElement, browser_inputText, browser_goToUrl, browser_searchGoogle,\nbrowser_scrollToPercent, browser_switchTab, browser_openTab, browser_closeTab,\nbrowser_goBack, browser_sendKeys, browser_wait, browser_scrollToText,\nbrowser_selectDropdownOption, browser_getDropdownOptions, browser_cacheContent,\nbrowser_done, browser_scrollToTop, browser_scrollToBottom, browser_nextPage,\nbrowser_previousPage\n\nOmit \"tools\" to apply to ALL actions.\n\n## Available Condition Fields\n\nYou can condition on ANY field in the action's arguments using dot notation.\nThe system provides these built-in fields, but you are not limited to them:\n\n**Page context:**\n- arguments.current_url (string) \u2014 current page URL\n- arguments.page_title (string) \u2014 current page title\n- arguments.action_index (number) \u2014 action sequence number in this task\n- arguments.domain_time_seconds (number) \u2014 cumulative seconds on this domain\n\n**Element context** (for actions targeting a specific page element \u2014 click, input, scroll-to, etc.):\n- arguments.element_context.element_text (string) \u2014 the target element's own text content\n- arguments.element_context.row_text (string) \u2014 ALL visible text in the element's row, list item, card, or containing group. In a spreadsheet, this is the full row (e.g. \"Antler US Fund $160 1/5/2026 2026 II NYC\"). Use this for per-row/per-item policy enforcement.\n- arguments.element_context.tag (string) \u2014 HTML tag of the target element\n- arguments.element_context.xpath (string) \u2014 XPath of the target element\n\n**Element styles** (for actions targeting page elements):\n- arguments.computed_styles.* \u2014 any CSS property (backgroundColor, color, fontSize, display, visibility, opacity, position, zIndex, pointerEvents, fontWeight, textDecoration, overflow, cursor, borderColor)\n\n**Extracted entities** (auto-detected from visible page content):\n- arguments.extracted_entities.prices (number[]) \u2014 prices in any currency\n- arguments.extracted_entities.max_price (number) \u2014 highest price on page\n- arguments.extracted_entities.min_price (number) \u2014 lowest price on page\n- arguments.extracted_entities.emails (string[]) \u2014 email addresses\n- arguments.extracted_entities.phone_numbers (string[]) \u2014 phone numbers (international)\n- arguments.extracted_entities.salary_figures (number[]) \u2014 salary/compensation amounts\n- arguments.extracted_entities.has_salary_figures (boolean)\n- arguments.extracted_entities.equity_percentages (number[]) \u2014 equity/vesting %\n- arguments.extracted_entities.has_equity_info (boolean)\n- arguments.extracted_entities.has_sensitive_pii (boolean) \u2014 any PII detected\n- arguments.extracted_entities.has_credit_cards (boolean) \u2014 credit card numbers detected\n- arguments.extracted_entities.has_gov_ids (boolean) \u2014 government ID patterns detected\n- arguments.extracted_entities.has_api_keys (boolean) \u2014 API keys/secrets detected\n- arguments.extracted_entities.sensitive_terms (string[]) \u2014 categories found: salary, equity, gov_id, credit_card, api_key, email, phone\n\n**Action-specific arguments:**\n- arguments.url \u2014 target URL for navigation\n- arguments.text \u2014 text being typed\n- arguments.query \u2014 search query\n- arguments.index \u2014 target element index\n\nYou can also use any custom field path. Unknown fields resolve to undefined and conditions on them won't match.\n\n## Operators\n\nequals, not_equals, contains, not_contains, starts_with, ends_with, matches,\ngreater_than, less_than, in, not_in, length_greater_than, percent_of,\noutside_hours, within_hours\n\nFor time-based: use \"HH:MM-HH:MM\" format (e.g., \"09:00-17:00\"). Handles overnight ranges.\nYou can use any operator the Veto SDK supports. Unknown operators are passed through to cloud evaluation.\n\n## Action Types\n\n- \"block\" \u2014 prevent the action (hard limit)\n- \"require_approval\" \u2014 pause and ask the human to approve/deny\n- \"warn\" \u2014 log warning but allow\n- \"log\" \u2014 silently log\n- \"allow\" \u2014 explicitly allow (for exceptions)\n\nUse \"block\" for hard safety limits. Use \"require_approval\" when the user wants case-by-case review.\n\n## Rules\n\n1. Rules are evaluated per-action, not per-page\n2. Use \"conditions\" for AND logic, \"condition_groups\" for OR logic\n3. For URL matching, prefer \"contains\" or \"matches\" over \"equals\"\n4. For price thresholds, use \"arguments.extracted_entities.max_price\" with \"greater_than\"\n5. Generate the minimum number of rules needed\n6. For per-row/per-item enforcement (e.g. \"block items in NYC\", \"hide funds from Acme\"), use arguments.element_context.row_text with \"contains\" \u2014 this checks the specific row the agent is interacting with, NOT the entire page\n7. Use extracted_entities for page-wide checks (e.g. \"block when credit cards visible\"). Use element_context for item-level checks (e.g. \"block clicking rows where location is NYC\")\n\n## Output Format\n\nReturn JSON with exactly two fields:\n{\n \"rules\": [ ... ],\n \"explanation\": \"1-3 sentence plain-English explanation\"\n}";
|
|
29
|
+
/**
|
|
30
|
+
* Lazily create and return the Zod schema for policy output validation.
|
|
31
|
+
*
|
|
32
|
+
* Requires `zod` as a peer dependency. Throws if zod is not installed.
|
|
33
|
+
*/
|
|
34
|
+
export declare function getPolicyOutputSchema(): Promise<unknown>;
|
|
35
|
+
/**
|
|
36
|
+
* Sanitize LLM-generated rules into valid SDK Rule objects.
|
|
37
|
+
*
|
|
38
|
+
* Normalizes IDs with `local-nl-` prefix, deduplicates, and passes through
|
|
39
|
+
* unknown operators/tools with warnings (returned in the warnings array).
|
|
40
|
+
*/
|
|
41
|
+
export declare function sanitizeGeneratedRules(parsed: {
|
|
42
|
+
rules: Array<{
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
description?: string | null;
|
|
46
|
+
enabled?: boolean;
|
|
47
|
+
severity: string;
|
|
48
|
+
action: string;
|
|
49
|
+
tools?: string[] | null;
|
|
50
|
+
conditions?: Array<{
|
|
51
|
+
field: string;
|
|
52
|
+
operator: string;
|
|
53
|
+
value?: unknown;
|
|
54
|
+
}> | null;
|
|
55
|
+
condition_groups?: Array<Array<{
|
|
56
|
+
field: string;
|
|
57
|
+
operator: string;
|
|
58
|
+
value?: unknown;
|
|
59
|
+
}>> | null;
|
|
60
|
+
tags?: string[] | null;
|
|
61
|
+
}>;
|
|
62
|
+
}): {
|
|
63
|
+
rules: Rule[];
|
|
64
|
+
warnings: string[];
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Validate raw LLM output against the policy schema and sanitize into Rules.
|
|
68
|
+
*
|
|
69
|
+
* Requires `zod` as a peer dependency.
|
|
70
|
+
*/
|
|
71
|
+
export declare function validatePolicyOutput(raw: unknown): Promise<PolicyGenerationResult>;
|
|
72
|
+
type InstantAction = 'block' | 'require_approval' | 'warn' | 'log';
|
|
73
|
+
interface InstantRuleDef {
|
|
74
|
+
id: string;
|
|
75
|
+
name: string;
|
|
76
|
+
description: string;
|
|
77
|
+
enabled: true;
|
|
78
|
+
severity: 'critical' | 'high';
|
|
79
|
+
action: InstantAction;
|
|
80
|
+
conditions: Array<{
|
|
81
|
+
field: string;
|
|
82
|
+
operator: string;
|
|
83
|
+
value: string | number | boolean;
|
|
84
|
+
}>;
|
|
85
|
+
}
|
|
86
|
+
interface InstantOutput {
|
|
87
|
+
rules: InstantRuleDef[];
|
|
88
|
+
explanation: string;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Zero-latency deterministic rule generation for common intents.
|
|
92
|
+
*
|
|
93
|
+
* Handles credit card shields, PII shields, gov ID shields, API key shields,
|
|
94
|
+
* price limits, and salary info shields. Returns null for anything that
|
|
95
|
+
* needs an LLM.
|
|
96
|
+
*/
|
|
97
|
+
export declare function tryInstantGeneration(input: string): InstantOutput | null;
|
|
98
|
+
/**
|
|
99
|
+
* Detect natural-language policy declarations — standing rules with conditions
|
|
100
|
+
* that should route to policy generation rather than the automation loop.
|
|
101
|
+
*/
|
|
102
|
+
export declare function looksLikePolicyDeclaration(task: string): boolean;
|
|
103
|
+
/**
|
|
104
|
+
* Check if a policy request needs clarification before generation.
|
|
105
|
+
*
|
|
106
|
+
* Returns null if the request is clear enough to proceed.
|
|
107
|
+
*/
|
|
108
|
+
export declare function reviewPolicyRequest(input: string): PolicyClarificationRequest | null;
|
|
109
|
+
export {};
|
|
110
|
+
//# sourceMappingURL=generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/policy/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAiB,MAAM,mBAAmB,CAAC;AAK7D;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAID,eAAO,MAAM,2BAA2B,kjMAkHtC,CAAC;AAiDH;;;;GAIG;AACH,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,OAAO,CAAC,CAwC9D;AAID;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,EAAE;IAAE,KAAK,EAAE,KAAK,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QAAC,UAAU,CAAC,EAAE,KAAK,CAAC;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,QA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,EAAE,MAAM,GAAG,OAAO,CAqBhE;AAYD;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,0BAA0B,GAAG,IAAI,CA2CpF"}
|
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policy generator utilities — NL-to-rule helpers for consumers who bring
|
|
3
|
+
* their own LLM.
|
|
4
|
+
*
|
|
5
|
+
* Provides the system prompt, Zod schema, rule sanitization, and instant
|
|
6
|
+
* generation for well-known patterns. Does NOT include LLM invocation.
|
|
7
|
+
*
|
|
8
|
+
* @module policy/generator
|
|
9
|
+
*/
|
|
10
|
+
// --- System prompt ---
|
|
11
|
+
export const BROWSER_AGENT_SYSTEM_PROMPT = `You are a security policy compiler for a browser automation agent.
|
|
12
|
+
|
|
13
|
+
Convert the user's natural-language policy into one or more Veto rules (JSON).
|
|
14
|
+
|
|
15
|
+
## Rule Schema
|
|
16
|
+
|
|
17
|
+
Each rule is a JSON object:
|
|
18
|
+
{
|
|
19
|
+
"id": string, // kebab-case unique ID (e.g., "block-expensive-purchases")
|
|
20
|
+
"name": string, // short human-readable name
|
|
21
|
+
"description": string, // 1-2 sentence description
|
|
22
|
+
"enabled": true,
|
|
23
|
+
"severity": "critical" | "high" | "medium" | "low" | "info",
|
|
24
|
+
"action": "block" | "warn" | "log" | "allow" | "require_approval",
|
|
25
|
+
"tools": string[], // which browser actions this applies to (omit for ALL)
|
|
26
|
+
"conditions": [ // ALL must match (AND logic)
|
|
27
|
+
{ "field": string, "operator": string, "value": any }
|
|
28
|
+
],
|
|
29
|
+
"condition_groups": [ // groups are OR'd; conditions within each group are AND'd
|
|
30
|
+
[ { "field": ..., "operator": ..., "value": ... } ]
|
|
31
|
+
],
|
|
32
|
+
"tags": string[]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
## Available Tools (prefix: browser_)
|
|
36
|
+
|
|
37
|
+
browser_clickElement, browser_inputText, browser_goToUrl, browser_searchGoogle,
|
|
38
|
+
browser_scrollToPercent, browser_switchTab, browser_openTab, browser_closeTab,
|
|
39
|
+
browser_goBack, browser_sendKeys, browser_wait, browser_scrollToText,
|
|
40
|
+
browser_selectDropdownOption, browser_getDropdownOptions, browser_cacheContent,
|
|
41
|
+
browser_done, browser_scrollToTop, browser_scrollToBottom, browser_nextPage,
|
|
42
|
+
browser_previousPage
|
|
43
|
+
|
|
44
|
+
Omit "tools" to apply to ALL actions.
|
|
45
|
+
|
|
46
|
+
## Available Condition Fields
|
|
47
|
+
|
|
48
|
+
You can condition on ANY field in the action's arguments using dot notation.
|
|
49
|
+
The system provides these built-in fields, but you are not limited to them:
|
|
50
|
+
|
|
51
|
+
**Page context:**
|
|
52
|
+
- arguments.current_url (string) — current page URL
|
|
53
|
+
- arguments.page_title (string) — current page title
|
|
54
|
+
- arguments.action_index (number) — action sequence number in this task
|
|
55
|
+
- arguments.domain_time_seconds (number) — cumulative seconds on this domain
|
|
56
|
+
|
|
57
|
+
**Element context** (for actions targeting a specific page element — click, input, scroll-to, etc.):
|
|
58
|
+
- arguments.element_context.element_text (string) — the target element's own text content
|
|
59
|
+
- arguments.element_context.row_text (string) — ALL visible text in the element's row, list item, card, or containing group. In a spreadsheet, this is the full row (e.g. "Antler US Fund $160 1/5/2026 2026 II NYC"). Use this for per-row/per-item policy enforcement.
|
|
60
|
+
- arguments.element_context.tag (string) — HTML tag of the target element
|
|
61
|
+
- arguments.element_context.xpath (string) — XPath of the target element
|
|
62
|
+
|
|
63
|
+
**Element styles** (for actions targeting page elements):
|
|
64
|
+
- arguments.computed_styles.* — any CSS property (backgroundColor, color, fontSize, display, visibility, opacity, position, zIndex, pointerEvents, fontWeight, textDecoration, overflow, cursor, borderColor)
|
|
65
|
+
|
|
66
|
+
**Extracted entities** (auto-detected from visible page content):
|
|
67
|
+
- arguments.extracted_entities.prices (number[]) — prices in any currency
|
|
68
|
+
- arguments.extracted_entities.max_price (number) — highest price on page
|
|
69
|
+
- arguments.extracted_entities.min_price (number) — lowest price on page
|
|
70
|
+
- arguments.extracted_entities.emails (string[]) — email addresses
|
|
71
|
+
- arguments.extracted_entities.phone_numbers (string[]) — phone numbers (international)
|
|
72
|
+
- arguments.extracted_entities.salary_figures (number[]) — salary/compensation amounts
|
|
73
|
+
- arguments.extracted_entities.has_salary_figures (boolean)
|
|
74
|
+
- arguments.extracted_entities.equity_percentages (number[]) — equity/vesting %
|
|
75
|
+
- arguments.extracted_entities.has_equity_info (boolean)
|
|
76
|
+
- arguments.extracted_entities.has_sensitive_pii (boolean) — any PII detected
|
|
77
|
+
- arguments.extracted_entities.has_credit_cards (boolean) — credit card numbers detected
|
|
78
|
+
- arguments.extracted_entities.has_gov_ids (boolean) — government ID patterns detected
|
|
79
|
+
- arguments.extracted_entities.has_api_keys (boolean) — API keys/secrets detected
|
|
80
|
+
- arguments.extracted_entities.sensitive_terms (string[]) — categories found: salary, equity, gov_id, credit_card, api_key, email, phone
|
|
81
|
+
|
|
82
|
+
**Action-specific arguments:**
|
|
83
|
+
- arguments.url — target URL for navigation
|
|
84
|
+
- arguments.text — text being typed
|
|
85
|
+
- arguments.query — search query
|
|
86
|
+
- arguments.index — target element index
|
|
87
|
+
|
|
88
|
+
You can also use any custom field path. Unknown fields resolve to undefined and conditions on them won't match.
|
|
89
|
+
|
|
90
|
+
## Operators
|
|
91
|
+
|
|
92
|
+
equals, not_equals, contains, not_contains, starts_with, ends_with, matches,
|
|
93
|
+
greater_than, less_than, in, not_in, length_greater_than, percent_of,
|
|
94
|
+
outside_hours, within_hours
|
|
95
|
+
|
|
96
|
+
For time-based: use "HH:MM-HH:MM" format (e.g., "09:00-17:00"). Handles overnight ranges.
|
|
97
|
+
You can use any operator the Veto SDK supports. Unknown operators are passed through to cloud evaluation.
|
|
98
|
+
|
|
99
|
+
## Action Types
|
|
100
|
+
|
|
101
|
+
- "block" — prevent the action (hard limit)
|
|
102
|
+
- "require_approval" — pause and ask the human to approve/deny
|
|
103
|
+
- "warn" — log warning but allow
|
|
104
|
+
- "log" — silently log
|
|
105
|
+
- "allow" — explicitly allow (for exceptions)
|
|
106
|
+
|
|
107
|
+
Use "block" for hard safety limits. Use "require_approval" when the user wants case-by-case review.
|
|
108
|
+
|
|
109
|
+
## Rules
|
|
110
|
+
|
|
111
|
+
1. Rules are evaluated per-action, not per-page
|
|
112
|
+
2. Use "conditions" for AND logic, "condition_groups" for OR logic
|
|
113
|
+
3. For URL matching, prefer "contains" or "matches" over "equals"
|
|
114
|
+
4. For price thresholds, use "arguments.extracted_entities.max_price" with "greater_than"
|
|
115
|
+
5. Generate the minimum number of rules needed
|
|
116
|
+
6. For per-row/per-item enforcement (e.g. "block items in NYC", "hide funds from Acme"), use arguments.element_context.row_text with "contains" — this checks the specific row the agent is interacting with, NOT the entire page
|
|
117
|
+
7. Use extracted_entities for page-wide checks (e.g. "block when credit cards visible"). Use element_context for item-level checks (e.g. "block clicking rows where location is NYC")
|
|
118
|
+
|
|
119
|
+
## Output Format
|
|
120
|
+
|
|
121
|
+
Return JSON with exactly two fields:
|
|
122
|
+
{
|
|
123
|
+
"rules": [ ... ],
|
|
124
|
+
"explanation": "1-3 sentence plain-English explanation"
|
|
125
|
+
}`;
|
|
126
|
+
// --- Operator / tool validation sets ---
|
|
127
|
+
const VALID_OPERATORS = new Set([
|
|
128
|
+
'equals',
|
|
129
|
+
'not_equals',
|
|
130
|
+
'contains',
|
|
131
|
+
'not_contains',
|
|
132
|
+
'starts_with',
|
|
133
|
+
'ends_with',
|
|
134
|
+
'matches',
|
|
135
|
+
'greater_than',
|
|
136
|
+
'less_than',
|
|
137
|
+
'percent_of',
|
|
138
|
+
'length_greater_than',
|
|
139
|
+
'in',
|
|
140
|
+
'not_in',
|
|
141
|
+
'outside_hours',
|
|
142
|
+
'within_hours',
|
|
143
|
+
]);
|
|
144
|
+
const KNOWN_TOOLS = new Set([
|
|
145
|
+
'browser_clickElement',
|
|
146
|
+
'browser_inputText',
|
|
147
|
+
'browser_goToUrl',
|
|
148
|
+
'browser_searchGoogle',
|
|
149
|
+
'browser_scrollToPercent',
|
|
150
|
+
'browser_switchTab',
|
|
151
|
+
'browser_openTab',
|
|
152
|
+
'browser_closeTab',
|
|
153
|
+
'browser_goBack',
|
|
154
|
+
'browser_sendKeys',
|
|
155
|
+
'browser_wait',
|
|
156
|
+
'browser_scrollToText',
|
|
157
|
+
'browser_selectDropdownOption',
|
|
158
|
+
'browser_getDropdownOptions',
|
|
159
|
+
'browser_cacheContent',
|
|
160
|
+
'browser_done',
|
|
161
|
+
'browser_scrollToTop',
|
|
162
|
+
'browser_scrollToBottom',
|
|
163
|
+
'browser_nextPage',
|
|
164
|
+
'browser_previousPage',
|
|
165
|
+
]);
|
|
166
|
+
// --- Zod schema for structured LLM output ---
|
|
167
|
+
let _policyOutputSchema = null;
|
|
168
|
+
/**
|
|
169
|
+
* Lazily create and return the Zod schema for policy output validation.
|
|
170
|
+
*
|
|
171
|
+
* Requires `zod` as a peer dependency. Throws if zod is not installed.
|
|
172
|
+
*/
|
|
173
|
+
export async function getPolicyOutputSchema() {
|
|
174
|
+
if (_policyOutputSchema)
|
|
175
|
+
return _policyOutputSchema;
|
|
176
|
+
const z = await import('zod').catch(() => {
|
|
177
|
+
throw new Error('zod is required for policy schema validation. Install it: npm install zod');
|
|
178
|
+
});
|
|
179
|
+
const conditionValueSchema = z.union([
|
|
180
|
+
z.string(),
|
|
181
|
+
z.number(),
|
|
182
|
+
z.boolean(),
|
|
183
|
+
z.array(z.string()),
|
|
184
|
+
z.array(z.number()),
|
|
185
|
+
]);
|
|
186
|
+
const ruleConditionSchema = z.object({
|
|
187
|
+
field: z.string(),
|
|
188
|
+
operator: z.string(),
|
|
189
|
+
value: conditionValueSchema,
|
|
190
|
+
});
|
|
191
|
+
const generatedRuleSchema = z.object({
|
|
192
|
+
id: z.string(),
|
|
193
|
+
name: z.string(),
|
|
194
|
+
description: z.string().nullable().optional(),
|
|
195
|
+
enabled: z.literal(true).default(true),
|
|
196
|
+
severity: z.enum(['critical', 'high', 'medium', 'low', 'info']),
|
|
197
|
+
action: z.enum(['block', 'warn', 'log', 'allow', 'require_approval']),
|
|
198
|
+
tools: z.array(z.string()).nullable().optional(),
|
|
199
|
+
conditions: z.array(ruleConditionSchema).nullable().optional(),
|
|
200
|
+
condition_groups: z.array(z.array(ruleConditionSchema)).nullable().optional(),
|
|
201
|
+
tags: z.array(z.string()).nullable().optional(),
|
|
202
|
+
});
|
|
203
|
+
_policyOutputSchema = z.object({
|
|
204
|
+
rules: z.array(generatedRuleSchema).min(1),
|
|
205
|
+
explanation: z.string(),
|
|
206
|
+
});
|
|
207
|
+
return _policyOutputSchema;
|
|
208
|
+
}
|
|
209
|
+
// --- Sanitization ---
|
|
210
|
+
/**
|
|
211
|
+
* Sanitize LLM-generated rules into valid SDK Rule objects.
|
|
212
|
+
*
|
|
213
|
+
* Normalizes IDs with `local-nl-` prefix, deduplicates, and passes through
|
|
214
|
+
* unknown operators/tools with warnings (returned in the warnings array).
|
|
215
|
+
*/
|
|
216
|
+
export function sanitizeGeneratedRules(parsed) {
|
|
217
|
+
const seenIds = new Set();
|
|
218
|
+
const warnings = [];
|
|
219
|
+
const rules = parsed.rules.map(r => {
|
|
220
|
+
let id = `local-nl-${r.id.replace(/[^a-z0-9-]/gi, '-').toLowerCase()}`;
|
|
221
|
+
while (seenIds.has(id)) {
|
|
222
|
+
id = `${id}-${Math.random().toString(36).slice(2, 10)}`;
|
|
223
|
+
}
|
|
224
|
+
seenIds.add(id);
|
|
225
|
+
if (r.tools) {
|
|
226
|
+
for (const t of r.tools) {
|
|
227
|
+
if (!KNOWN_TOOLS.has(t)) {
|
|
228
|
+
warnings.push(`Unknown tool "${t}" in rule "${r.name}" — kept (may match future/cloud tools)`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
const toCondition = (c) => {
|
|
233
|
+
if (!VALID_OPERATORS.has(c.operator)) {
|
|
234
|
+
warnings.push(`Unrecognized operator "${c.operator}" in rule "${r.name}" — kept for cloud evaluation`);
|
|
235
|
+
}
|
|
236
|
+
return {
|
|
237
|
+
field: c.field,
|
|
238
|
+
operator: c.operator,
|
|
239
|
+
value: c.value,
|
|
240
|
+
};
|
|
241
|
+
};
|
|
242
|
+
const VALID_SEVERITIES = new Set(['low', 'medium', 'high', 'critical', 'info']);
|
|
243
|
+
const VALID_ACTIONS = new Set(['allow', 'block', 'require_approval', 'warn', 'log']);
|
|
244
|
+
let severity = 'medium';
|
|
245
|
+
if (VALID_SEVERITIES.has(r.severity)) {
|
|
246
|
+
severity = r.severity;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
warnings.push(`Invalid severity "${r.severity}" in rule "${r.name}" — defaulting to "medium"`);
|
|
250
|
+
}
|
|
251
|
+
let action = 'block';
|
|
252
|
+
if (VALID_ACTIONS.has(r.action)) {
|
|
253
|
+
action = r.action;
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
warnings.push(`Invalid action "${r.action}" in rule "${r.name}" — defaulting to "block"`);
|
|
257
|
+
}
|
|
258
|
+
const rule = {
|
|
259
|
+
id,
|
|
260
|
+
name: r.name,
|
|
261
|
+
description: r.description ?? undefined,
|
|
262
|
+
enabled: true,
|
|
263
|
+
severity,
|
|
264
|
+
action,
|
|
265
|
+
tools: r.tools ?? undefined,
|
|
266
|
+
conditions: r.conditions?.map(toCondition),
|
|
267
|
+
condition_groups: r.condition_groups?.map(group => group.map(toCondition)),
|
|
268
|
+
tags: r.tags ?? ['nl-generated'],
|
|
269
|
+
};
|
|
270
|
+
return rule;
|
|
271
|
+
});
|
|
272
|
+
return { rules, warnings };
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Validate raw LLM output against the policy schema and sanitize into Rules.
|
|
276
|
+
*
|
|
277
|
+
* Requires `zod` as a peer dependency.
|
|
278
|
+
*/
|
|
279
|
+
export async function validatePolicyOutput(raw) {
|
|
280
|
+
try {
|
|
281
|
+
const schema = await getPolicyOutputSchema();
|
|
282
|
+
const parsed = schema.parse(raw);
|
|
283
|
+
const { rules, warnings } = sanitizeGeneratedRules(parsed);
|
|
284
|
+
return { success: true, rules, explanation: parsed.explanation, warnings };
|
|
285
|
+
}
|
|
286
|
+
catch (err) {
|
|
287
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
288
|
+
return { success: false, rules: [], explanation: '', error: msg };
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function inferActionFromIntent(input) {
|
|
292
|
+
const lower = input.toLowerCase();
|
|
293
|
+
if (/\b(block|prohibit|deny|prevent|stop|restrict|forbid)/.test(lower))
|
|
294
|
+
return 'block';
|
|
295
|
+
if (/\b(warn|alert|notify|flag)/.test(lower))
|
|
296
|
+
return 'warn';
|
|
297
|
+
if (/\b(ask|approv|confirm|review|check with|permission)/.test(lower))
|
|
298
|
+
return 'require_approval';
|
|
299
|
+
if (/\b(log|track|monitor|record)/.test(lower))
|
|
300
|
+
return 'log';
|
|
301
|
+
return 'block';
|
|
302
|
+
}
|
|
303
|
+
function actionVerb(action) {
|
|
304
|
+
if (action === 'block')
|
|
305
|
+
return 'Blocks';
|
|
306
|
+
if (action === 'require_approval')
|
|
307
|
+
return 'Requires approval for';
|
|
308
|
+
if (action === 'warn')
|
|
309
|
+
return 'Warns about';
|
|
310
|
+
return 'Logs';
|
|
311
|
+
}
|
|
312
|
+
function extractPriceThreshold(input) {
|
|
313
|
+
const match = input.match(/\$\s*([0-9,]+(?:\.[0-9]{1,2})?)/);
|
|
314
|
+
if (match) {
|
|
315
|
+
const price = parseFloat(match[1].replace(/,/g, ''));
|
|
316
|
+
if (isNaN(price))
|
|
317
|
+
return null;
|
|
318
|
+
return price;
|
|
319
|
+
}
|
|
320
|
+
const wordMatch = input.match(/(\d+(?:\.\d{1,2})?)\s*(?:dollars?|usd)/i);
|
|
321
|
+
if (wordMatch) {
|
|
322
|
+
const price = parseFloat(wordMatch[1]);
|
|
323
|
+
if (isNaN(price))
|
|
324
|
+
return null;
|
|
325
|
+
return price;
|
|
326
|
+
}
|
|
327
|
+
return null;
|
|
328
|
+
}
|
|
329
|
+
function instantRule(id, name, description, severity, action, conditions) {
|
|
330
|
+
return { id, name, description, enabled: true, severity, action, conditions };
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Zero-latency deterministic rule generation for common intents.
|
|
334
|
+
*
|
|
335
|
+
* Handles credit card shields, PII shields, gov ID shields, API key shields,
|
|
336
|
+
* price limits, and salary info shields. Returns null for anything that
|
|
337
|
+
* needs an LLM.
|
|
338
|
+
*/
|
|
339
|
+
export function tryInstantGeneration(input) {
|
|
340
|
+
const lower = input.toLowerCase();
|
|
341
|
+
const action = inferActionFromIntent(input);
|
|
342
|
+
const verb = actionVerb(action);
|
|
343
|
+
if (/\bcredit\s*cards?\b|\bcard\s*numbers?\b|\bcc\s*num/i.test(lower)) {
|
|
344
|
+
return {
|
|
345
|
+
rules: [
|
|
346
|
+
instantRule('instant-credit-card-shield', 'Credit Card Shield', 'Prevents actions when credit card numbers are detected on the page', 'critical', action, [{ field: 'arguments.extracted_entities.has_credit_cards', operator: 'equals', value: true }]),
|
|
347
|
+
],
|
|
348
|
+
explanation: `${verb} all browser actions when credit card numbers are detected on the page.`,
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
if (/\b(pii|personal\s*(data|info(rmation)?)|sensitive\s*(data|info))\b/i.test(lower)) {
|
|
352
|
+
return {
|
|
353
|
+
rules: [
|
|
354
|
+
instantRule('instant-pii-shield', 'PII Shield', 'Prevents actions when sensitive personal information is detected', 'critical', action, [{ field: 'arguments.extracted_entities.has_sensitive_pii', operator: 'equals', value: true }]),
|
|
355
|
+
],
|
|
356
|
+
explanation: `${verb} all browser actions when sensitive personal data is detected on the page.`,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
if (/\b(gov(ernment)?\s*id|ssn|social\s*security|passport|driver'?s?\s*licen[sc]e)\b/i.test(lower)) {
|
|
360
|
+
return {
|
|
361
|
+
rules: [
|
|
362
|
+
instantRule('instant-gov-id-shield', 'Government ID Shield', 'Prevents actions when government ID patterns are detected', 'critical', action, [{ field: 'arguments.extracted_entities.has_gov_ids', operator: 'equals', value: true }]),
|
|
363
|
+
],
|
|
364
|
+
explanation: `${verb} all browser actions when government ID patterns (SSN, passport, license numbers) are detected.`,
|
|
365
|
+
};
|
|
366
|
+
}
|
|
367
|
+
if (/\b(api\s*keys?|secret\s*keys?|access\s*tokens?|credentials?)\b/i.test(lower)) {
|
|
368
|
+
return {
|
|
369
|
+
rules: [
|
|
370
|
+
instantRule('instant-api-key-shield', 'API Key Shield', 'Prevents actions when API keys or secrets are detected', 'critical', action, [{ field: 'arguments.extracted_entities.has_api_keys', operator: 'equals', value: true }]),
|
|
371
|
+
],
|
|
372
|
+
explanation: `${verb} all browser actions when API keys or secrets are detected on the page.`,
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
const price = extractPriceThreshold(input);
|
|
376
|
+
if (price !== null && /price|cost|spend|purchas|buy|order|checkout|cart|limit/i.test(lower)) {
|
|
377
|
+
const priceAction = /\b(block|stop|prevent|never|don'?t)\b/i.test(lower)
|
|
378
|
+
? 'block'
|
|
379
|
+
: 'require_approval';
|
|
380
|
+
return {
|
|
381
|
+
rules: [
|
|
382
|
+
instantRule(`instant-price-limit-${price}`, `Price Limit ($${price})`, `Controls actions when prices exceed $${price}`, 'high', priceAction, [{ field: 'arguments.extracted_entities.max_price', operator: 'greater_than', value: price }]),
|
|
383
|
+
],
|
|
384
|
+
explanation: `${actionVerb(priceAction)} actions when the highest price on the page exceeds $${price}.`,
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
if (/\b(salary|salaries|compensation|pay\s*(rate|scale|range)|wage)\b/i.test(lower)) {
|
|
388
|
+
return {
|
|
389
|
+
rules: [
|
|
390
|
+
instantRule('instant-salary-shield', 'Salary Info Shield', 'Prevents actions when salary or compensation data is detected', 'high', action, [{ field: 'arguments.extracted_entities.has_salary_figures', operator: 'equals', value: true }]),
|
|
391
|
+
],
|
|
392
|
+
explanation: `${verb} all browser actions when salary or compensation figures are detected.`,
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
// --- Policy declaration detection ---
|
|
398
|
+
/**
|
|
399
|
+
* Detect natural-language policy declarations — standing rules with conditions
|
|
400
|
+
* that should route to policy generation rather than the automation loop.
|
|
401
|
+
*/
|
|
402
|
+
export function looksLikePolicyDeclaration(task) {
|
|
403
|
+
const t = task.toLowerCase().trim();
|
|
404
|
+
const hasProhibition = /\b(?:don'?t|do\s*not|never)\b/.test(t);
|
|
405
|
+
const hasCondition = /\b(?:unless|until|without|except\s+(?:if|when)|only\s+(?:if|when))\b/.test(t);
|
|
406
|
+
const hasScope = /\b(?:any(?:thing|one|where)?|all|every(?:thing|one|where)?)\b/.test(t);
|
|
407
|
+
if (hasProhibition && hasCondition)
|
|
408
|
+
return true;
|
|
409
|
+
if (hasProhibition && hasScope)
|
|
410
|
+
return true;
|
|
411
|
+
// Imperative "never" at the start is a standing rule, not a one-off instruction.
|
|
412
|
+
// Excludes "never mind".
|
|
413
|
+
if (/^(?:please\s+)?never\b/.test(t) && !/^(?:please\s+)?never\s*mind\b/.test(t))
|
|
414
|
+
return true;
|
|
415
|
+
if (/\b(?:block|deny|restrict|prevent)\b/.test(t) && (hasScope || /\bfrom\s+\w+/.test(t)))
|
|
416
|
+
return true;
|
|
417
|
+
if (/\brequire\s+(?:my\s+)?(?:approval|permission)\b/.test(t))
|
|
418
|
+
return true;
|
|
419
|
+
if (/\b(?:warn|alert)\s+me\b/.test(t) && /\b(?:if|when|before|whenever)\b/.test(t))
|
|
420
|
+
return true;
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
// --- Review / clarification ---
|
|
424
|
+
function hasExplicitDomainList(input) {
|
|
425
|
+
return /\b(x|twitter|reddit|instagram|facebook|tiktok|youtube|linkedin)\.com\b/i.test(input);
|
|
426
|
+
}
|
|
427
|
+
function hasSupportedRedirectFallback(input) {
|
|
428
|
+
return /\b(block only|just block|no redirect|don't redirect|do not redirect|skip redirect)\b/i.test(input);
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Check if a policy request needs clarification before generation.
|
|
432
|
+
*
|
|
433
|
+
* Returns null if the request is clear enough to proceed.
|
|
434
|
+
*/
|
|
435
|
+
export function reviewPolicyRequest(input) {
|
|
436
|
+
const normalizedInput = input.replace(/\s+/g, ' ').trim();
|
|
437
|
+
const lowerInput = normalizedInput.toLowerCase();
|
|
438
|
+
const questions = [];
|
|
439
|
+
const mentionsRedirect = /\bredirect\b|\broute me to\b|\bsend me to\b|\btake me to\b|\bopen my\b|\bopen the\b/.test(lowerInput) &&
|
|
440
|
+
/(task list|todo|to-do|tasks|calendar|planner|inbox)/.test(lowerInput);
|
|
441
|
+
const mentionsSocialCategory = /social media|social tabs|social sites|social apps/.test(lowerInput);
|
|
442
|
+
const mentionsTimeThreshold = /\b\d+\s*(min|mins|minute|minutes|hour|hours|hr|hrs)\b/.test(lowerInput) ||
|
|
443
|
+
/\bmore than\b|\bover\b|\bafter\b/.test(lowerInput);
|
|
444
|
+
const mentionsCrossSiteWindow = /\btoday\b|\bdaily\b|\bacross\b|\ball social\b/.test(lowerInput);
|
|
445
|
+
const acceptsDefaultSocialDomains = /\bdefault\b|\bstandard set\b/.test(lowerInput);
|
|
446
|
+
if (mentionsSocialCategory && !hasExplicitDomainList(normalizedInput) && !acceptsDefaultSocialDomains) {
|
|
447
|
+
questions.push('Which domains should count as social media for this rule? If you want, say "use the default set" and I\'ll use x.com, twitter.com, reddit.com, instagram.com, facebook.com, tiktok.com, youtube.com, and linkedin.com.');
|
|
448
|
+
}
|
|
449
|
+
if (mentionsSocialCategory && mentionsTimeThreshold && mentionsCrossSiteWindow) {
|
|
450
|
+
questions.push('Should that time limit apply per domain (for example 3 minutes on x.com) or across all social sites combined? The current policy engine enforces per-domain time reliably.');
|
|
451
|
+
}
|
|
452
|
+
if (mentionsRedirect && !hasSupportedRedirectFallback(normalizedInput)) {
|
|
453
|
+
questions.push('Veto policies can block, require approval, warn, or log, but they do not perform redirects on their own. Do you want a block-only policy, or a separate follow-up automation? If you want the follow-up flow, what exact task-list URL should be used?');
|
|
454
|
+
}
|
|
455
|
+
if (questions.length === 0) {
|
|
456
|
+
return null;
|
|
457
|
+
}
|
|
458
|
+
return {
|
|
459
|
+
explanation: 'I need a couple of clarifications before I can create this policy without guessing or silently encoding the wrong behavior.',
|
|
460
|
+
questions,
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../src/policy/generator.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA0BH,wBAAwB;AAExB,MAAM,CAAC,MAAM,2BAA2B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkHzC,CAAC;AAEH,0CAA0C;AAE1C,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC;IAC9B,QAAQ;IACR,YAAY;IACZ,UAAU;IACV,cAAc;IACd,aAAa;IACb,WAAW;IACX,SAAS;IACT,cAAc;IACd,WAAW;IACX,YAAY;IACZ,qBAAqB;IACrB,IAAI;IACJ,QAAQ;IACR,eAAe;IACf,cAAc;CACf,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC;IAC1B,sBAAsB;IACtB,mBAAmB;IACnB,iBAAiB;IACjB,sBAAsB;IACtB,yBAAyB;IACzB,mBAAmB;IACnB,iBAAiB;IACjB,kBAAkB;IAClB,gBAAgB;IAChB,kBAAkB;IAClB,cAAc;IACd,sBAAsB;IACtB,8BAA8B;IAC9B,4BAA4B;IAC5B,sBAAsB;IACtB,cAAc;IACd,qBAAqB;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B,GACpB,qFAAqF,CAAC,IAAI,CAAC,UAAU,CAAC;QACtG,qDAAqD,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAEzE,MAAM,sBAAsB,GAAG,mDAAmD,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACpG,MAAM,qBAAqB,GACzB,uDAAuD,CAAC,IAAI,CAAC,UAAU,CAAC;QACxE,kCAAkC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACtD,MAAM,uBAAuB,GAAG,+CAA+C,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjG,MAAM,2BAA2B,GAAG,8BAA8B,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAEpF,IAAI,sBAAsB,IAAI,CAAC,qBAAqB,CAAC,eAAe,CAAC,IAAI,CAAC,2BAA2B,EAAE,CAAC;QACtG,SAAS,CAAC,IAAI,CACZ,wNAAwN,CACzN,CAAC;IACJ,CAAC;IAED,IAAI,sBAAsB,IAAI,qBAAqB,IAAI,uBAAuB,EAAE,CAAC;QAC/E,SAAS,CAAC,IAAI,CACZ,4KAA4K,CAC7K,CAAC;IACJ,CAAC;IAED,IAAI,gBAAgB,IAAI,CAAC,4BAA4B,CAAC,eAAe,CAAC,EAAE,CAAC;QACvE,SAAS,CAAC,IAAI,CACZ,wPAAwP,CACzP,CAAC;IACJ,CAAC;IAED,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,WAAW,EACT,6HAA6H;QAC/H,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policy generation utilities.
|
|
3
|
+
*
|
|
4
|
+
* @module policy
|
|
5
|
+
*/
|
|
6
|
+
export { BROWSER_AGENT_SYSTEM_PROMPT, getPolicyOutputSchema, sanitizeGeneratedRules, validatePolicyOutput, tryInstantGeneration, looksLikePolicyDeclaration, reviewPolicyRequest, type PolicyGenerationResult, type PolicyClarificationRequest, } from './generator.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/policy/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,mBAAmB,EACnB,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,GAChC,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Policy generation utilities.
|
|
3
|
+
*
|
|
4
|
+
* @module policy
|
|
5
|
+
*/
|
|
6
|
+
export { BROWSER_AGENT_SYSTEM_PROMPT, getPolicyOutputSchema, sanitizeGeneratedRules, validatePolicyOutput, tryInstantGeneration, looksLikePolicyDeclaration, reviewPolicyRequest, } from './generator.js';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/policy/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACL,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,oBAAoB,EACpB,0BAA0B,EAC1B,mBAAmB,GAGpB,MAAM,gBAAgB,CAAC"}
|