@wenathlan/extension 1.1.49 → 1.1.50
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/README.md +6 -5
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +878 -5
- package/dist/index.js.map +4 -4
- package/dist/memory.d.ts +34 -1
- package/dist/memory.d.ts.map +1 -1
- package/dist/policy.d.ts +16 -1
- package/dist/policy.d.ts.map +1 -1
- package/dist/protocol.d.ts +68 -0
- package/dist/protocol.d.ts.map +1 -1
- package/dist/types.d.ts +157 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/workflow.d.ts +148 -0
- package/dist/workflow.d.ts.map +1 -0
- package/extension/dist/background.js +1189 -48
- package/extension/dist/background.js.map +4 -4
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/pagebridge.js +2 -2
- package/extension/dist/pagebridge.js.map +2 -2
- package/extension/dist/popup.html +1 -1
- package/extension/dist/popup.js +46 -2
- package/extension/dist/popup.js.map +2 -2
- package/extension/dist/sidepanel.html +1 -1
- package/extension/dist/sidepanel.js +179 -2
- package/extension/dist/sidepanel.js.map +2 -2
- package/extension/manifest.json +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import type { actionrisk, blockinvocation, delaystep, expressiontype, regexrule, runlogentry, steptemplate, variablebinding, variablescope, variablevalue, workflowblock, workflowrecord, workflowrun, workflowstep } from "./types.js";
|
|
2
|
+
import type { stepoutcome } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* Workflow engine for the 1.1.50 family.
|
|
5
|
+
* Every correlated rule for the reviewed step composition lives in this file: the workflow kind list, the step, block and template normalizers, the composition that validates and freezes a step list, the block expansion that hides no step from review, the pre-run validation of kinds, scopes and bindings, the typed scope stack with shadowing, the variable bindings that link step outputs to names, the expression arithmetic with coercion refusals, the regex extraction with honest no match outcomes, the seeded delay jitter, the run loop with per step checkpoints, the single step execution, the pause, resume and cancel transitions and the pure dry run with read only projections.
|
|
6
|
+
* The engine stays pure: every page, browser and storage effect flows through the injected executor so tests run on plain fixtures, and the risk grading flows through the injected risk callback so the policy table stays the single source of truth.
|
|
7
|
+
*/
|
|
8
|
+
/** The workflow kinds of the 1.1.50 family: composition, templates, runs, dry runs, jittered delays, element waits, expressions and variable extraction. */
|
|
9
|
+
export declare const workflowkinds: string[];
|
|
10
|
+
/** The outcome the injected executor returns for one workflow step. */
|
|
11
|
+
export type stepexecution = {
|
|
12
|
+
ok: boolean;
|
|
13
|
+
summary: string;
|
|
14
|
+
details?: Record<string, unknown>;
|
|
15
|
+
};
|
|
16
|
+
/** Normalizes one workflow step: id, kind, label, the optional target, value and JSON options, the output bindings, the inline expression and the inline regex rule. */
|
|
17
|
+
export declare function workflowstepof(value: unknown): workflowstep | undefined;
|
|
18
|
+
/** Normalizes one block invocation: the referenced block name and the human readable label. */
|
|
19
|
+
export declare function blockinvocationof(value: unknown): blockinvocation | undefined;
|
|
20
|
+
/** Normalizes one reusable workflow block: the unique name, the label and the child steps with nested block invocations. */
|
|
21
|
+
export declare function workflowblockof(value: unknown): workflowblock | undefined;
|
|
22
|
+
/** Normalizes one shareable step template: the id, the unique name, the origin, the step and the share time. */
|
|
23
|
+
export declare function steptemplateof(value: unknown): steptemplate | undefined;
|
|
24
|
+
/** The reviewed expression operators of the workflow grammar. */
|
|
25
|
+
export declare const expressionoperators: string[];
|
|
26
|
+
/** Normalizes one reviewed expression: the operands, the operator and the result variable with its result kind. */
|
|
27
|
+
export declare function expressionof(value: unknown): expressiontype | undefined;
|
|
28
|
+
/** Normalizes one reviewed regex rule: the pattern, the flag set and the named capture group list. */
|
|
29
|
+
export declare function regexruleof(value: unknown): regexrule | undefined;
|
|
30
|
+
/** Flattens nested blocks into one executable step list; every flattened step carries the innermost block name so runs highlight the active block. Unknown or cyclic block references are refused. */
|
|
31
|
+
export declare function expandblocks(steps: Array<workflowstep | blockinvocation>, blocks: workflowblock[]): workflowstep[];
|
|
32
|
+
/** Composes one workflow record: validates the name, version, origin grants, steps and blocks, expands every block so no step stays hidden, grades the review risk through the injected risk table and freezes the result. */
|
|
33
|
+
export declare function composeworkflow(input: {
|
|
34
|
+
id?: string;
|
|
35
|
+
name: string;
|
|
36
|
+
version: number;
|
|
37
|
+
origins: string[];
|
|
38
|
+
steps: Array<workflowstep | blockinvocation>;
|
|
39
|
+
blocks?: workflowblock[];
|
|
40
|
+
now: number;
|
|
41
|
+
kindallowed?: (kind: string) => boolean;
|
|
42
|
+
riskof?: (kind: string) => actionrisk;
|
|
43
|
+
}): workflowrecord;
|
|
44
|
+
/** Validates a composed workflow before any run: the expanded step list, every step kind against the injected allowlist, the bindings against earlier steps and every variable reference against the bindings, the inputs and the root scope. */
|
|
45
|
+
export declare function validateworkflow(record: workflowrecord, options?: {
|
|
46
|
+
kindallowed?: (kind: string) => boolean;
|
|
47
|
+
inputs?: string[];
|
|
48
|
+
}): {
|
|
49
|
+
allowed: boolean;
|
|
50
|
+
reason?: string;
|
|
51
|
+
};
|
|
52
|
+
/** Opens one child scope for a block invocation; the parent chain stays intact so resolution walks outward. */
|
|
53
|
+
export declare function pushscope(scopes: variablescope[], name: string, parent?: string): variablescope[];
|
|
54
|
+
/** Closes the newest scope and keeps every parent scope intact. */
|
|
55
|
+
export declare function popscope(scopes: variablescope[]): variablescope[];
|
|
56
|
+
/** Resolves one variable from the nearest scope outward through the parent chain; shadowing follows the newest scope first. */
|
|
57
|
+
export declare function resolvevariable(scopes: variablescope[], name: string): variablevalue | undefined;
|
|
58
|
+
/** Resolves every binding whose source step already produced an outcome into the newest scope; the engine runs this before each step so following steps read fresh values. */
|
|
59
|
+
export declare function bindvariables(scopes: variablescope[], bindings: variablebinding[], outputs: Record<string, stepoutcome>, now: number): {
|
|
60
|
+
scopes: variablescope[];
|
|
61
|
+
produced: string[];
|
|
62
|
+
};
|
|
63
|
+
/** Evaluates one reviewed expression between variables: arithmetic, comparison and logic operators with operand coercion and mismatched operator refusals, resolving references from the nearest scope outward; list operands join only the contains and length operators while every other operator refuses them at coercion. */
|
|
64
|
+
export declare function expressioneval(expression: expressiontype, scopes: variablescope[]): string | number | boolean;
|
|
65
|
+
/** Applies one reviewed regex rule to text and stores the named capture groups as string variables; the no match case is an honest outcome instead of a crash. */
|
|
66
|
+
export declare function regexextract(rule: regexrule, text: string, now: number): {
|
|
67
|
+
matched: boolean;
|
|
68
|
+
variables: variablevalue[];
|
|
69
|
+
};
|
|
70
|
+
/** Plans the element wait polling: how many probe passes fit inside the reviewed timeout window at the reviewed poll interval; a zero timeout or a zero poll interval runs a single immediate probe. */
|
|
71
|
+
export declare function waitelementplan(wait: {
|
|
72
|
+
timeout: number;
|
|
73
|
+
poll: number;
|
|
74
|
+
}): {
|
|
75
|
+
probes: number;
|
|
76
|
+
lastwait: number;
|
|
77
|
+
};
|
|
78
|
+
/** Samples one delay inside the reviewed jitter window from a seeded random source: the window spans base minus half the jitter to base plus half the jitter and never dips below zero. */
|
|
79
|
+
export declare function delayjitter(delay: delaystep, seed: number): number;
|
|
80
|
+
/** Builds one new workflow run: pending state, a zero step cursor and the optional dry run flag. */
|
|
81
|
+
export declare function newworkflowrun(input: {
|
|
82
|
+
id?: string;
|
|
83
|
+
workflowid: string;
|
|
84
|
+
dryrun?: boolean;
|
|
85
|
+
now: number;
|
|
86
|
+
}): workflowrun;
|
|
87
|
+
/** Pauses one running workflow run at its last checkpoint; the cursor keeps the completed steps so a resume continues exactly there. */
|
|
88
|
+
export declare function pauserun(run: workflowrun, now: number): workflowrun;
|
|
89
|
+
/** Cancels one workflow run and records the reviewed reason; done and already cancelled runs stay untouched. */
|
|
90
|
+
export declare function cancelrun(run: workflowrun, reason: string, now: number): workflowrun;
|
|
91
|
+
/** Executes exactly one workflow step outside the run loop: resolves the bindings of earlier steps, evaluates the inline expression and regex rule, interpolates the variable references, dispatches through the injected executor and binds the outcome into the newest scope. */
|
|
92
|
+
export declare function runstep(input: {
|
|
93
|
+
step: workflowstep;
|
|
94
|
+
scopes: variablescope[];
|
|
95
|
+
outputs: Record<string, stepoutcome>;
|
|
96
|
+
execute: (step: workflowstep, context: {
|
|
97
|
+
scopes: variablescope[];
|
|
98
|
+
block?: string;
|
|
99
|
+
}) => Promise<stepexecution>;
|
|
100
|
+
now: number;
|
|
101
|
+
block?: string;
|
|
102
|
+
}): Promise<{
|
|
103
|
+
scopes: variablescope[];
|
|
104
|
+
log: runlogentry;
|
|
105
|
+
output: stepexecution;
|
|
106
|
+
}>;
|
|
107
|
+
/** Advances one workflow run one step at a time: gates the run behind the active session, the approved plan and the origin grants, opens a child scope per block region, checkpoints after every completed step and resumes a paused run from its last checkpoint. */
|
|
108
|
+
export declare function runworkflow(input: {
|
|
109
|
+
record: workflowrecord;
|
|
110
|
+
run: workflowrun;
|
|
111
|
+
scopes?: variablescope[];
|
|
112
|
+
log?: runlogentry[];
|
|
113
|
+
outputs?: Record<string, stepoutcome>;
|
|
114
|
+
execute: (step: workflowstep, context: {
|
|
115
|
+
scopes: variablescope[];
|
|
116
|
+
block?: string;
|
|
117
|
+
}) => Promise<stepexecution>;
|
|
118
|
+
now: number;
|
|
119
|
+
gates?: {
|
|
120
|
+
sessionactive: boolean;
|
|
121
|
+
planapproved: boolean;
|
|
122
|
+
origingranted: (origin: string) => boolean;
|
|
123
|
+
};
|
|
124
|
+
oncheckpoint?: (state: {
|
|
125
|
+
run: workflowrun;
|
|
126
|
+
scopes: variablescope[];
|
|
127
|
+
log: runlogentry[];
|
|
128
|
+
}) => Promise<void> | void;
|
|
129
|
+
}): Promise<{
|
|
130
|
+
run: workflowrun;
|
|
131
|
+
scopes: variablescope[];
|
|
132
|
+
log: runlogentry[];
|
|
133
|
+
outputs: Record<string, stepoutcome>;
|
|
134
|
+
}>;
|
|
135
|
+
/** Evaluates every step of a workflow with no page mutation and no storage write: steps with a read only projection record their would be outcome and every other step is refused in the runlog. */
|
|
136
|
+
export declare function dryrunworkflow(input: {
|
|
137
|
+
record: workflowrecord;
|
|
138
|
+
run: workflowrun;
|
|
139
|
+
scopes?: variablescope[];
|
|
140
|
+
log?: runlogentry[];
|
|
141
|
+
now: number;
|
|
142
|
+
projection: (step: workflowstep) => string | undefined;
|
|
143
|
+
}): {
|
|
144
|
+
run: workflowrun;
|
|
145
|
+
scopes: variablescope[];
|
|
146
|
+
log: runlogentry[];
|
|
147
|
+
};
|
|
148
|
+
//# sourceMappingURL=workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../workflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,EAAE,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,eAAe,EAAgB,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACtP,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C;;;;GAIG;AAEH,4JAA4J;AAC5J,eAAO,MAAM,aAAa,EAAE,MAAM,EAAmH,CAAC;AAEtJ,uEAAuE;AACvE,MAAM,MAAM,aAAa,GAAG;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,CAAC;AAEhG,wKAAwK;AACxK,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,YAAY,GAAG,SAAS,CAiBvE;AAED,+FAA+F;AAC/F,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAM7E;AAED,4HAA4H;AAC5H,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,aAAa,GAAG,SAAS,CAezE;AAED,gHAAgH;AAChH,wBAAgB,cAAc,CAAC,K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