@sema-agent/core 7.45.0 → 7.46.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/CHANGELOG.md +246 -1
- package/dist/agents/extra-tool-names.d.ts +65 -0
- package/dist/agents/extra-tool-names.js +124 -0
- package/dist/agents/subagent.d.ts +17 -5
- package/dist/agents/subagent.js +33 -25
- package/dist/agents/tool-filter.d.ts +17 -1
- package/dist/agents/tool-filter.js +7 -0
- package/dist/core/agent-config-dir.d.ts +20 -0
- package/dist/core/agent-config-dir.js +49 -0
- package/dist/core/allow-entry.d.ts +5 -3
- package/dist/core/allow-entry.js +3 -1
- package/dist/core/ask-origin.js +1 -1
- package/dist/core/checkpoint-store.d.ts +39 -2
- package/dist/core/effective-path-target.d.ts +136 -4
- package/dist/core/effective-path-target.js +110 -2
- package/dist/core/engine-notice.d.ts +5 -0
- package/dist/core/gate-fold.js +3 -0
- package/dist/core/gate-lanes.js +9 -3
- package/dist/core/governance-codes.d.ts +3 -1
- package/dist/core/governance-codes.js +3 -0
- package/dist/core/hooks.d.ts +3 -0
- package/dist/core/path-rule-binding.d.ts +65 -0
- package/dist/core/path-rule-binding.js +99 -0
- package/dist/core/permission-rule-model.d.ts +47 -18
- package/dist/core/permission-rule-model.js +38 -42
- package/dist/core/permission-rule-provider.d.ts +7 -0
- package/dist/core/permission-rule-provider.js +10 -3
- package/dist/core/permission-rule-store.d.ts +8 -0
- package/dist/core/permission-rule-store.js +6 -2
- package/dist/core/permission-rule-sync.js +2 -2
- package/dist/core/permission-rules.d.ts +22 -40
- package/dist/core/permission-rules.js +50 -43
- package/dist/core/runner/child-tree.d.ts +97 -0
- package/dist/core/runner/child-tree.js +104 -0
- package/dist/core/runner/construction-doors.d.ts +5 -0
- package/dist/core/runner/construction-doors.js +6 -0
- package/dist/core/runner/contracts.d.ts +46 -0
- package/dist/core/runner/permission-rule-lanes.d.ts +34 -25
- package/dist/core/runner/permission-rule-lanes.js +18 -12
- package/dist/core/runner/persisted-path-rows.d.ts +31 -7
- package/dist/core/runner/persisted-path-rows.js +31 -12
- package/dist/core/runner/prepare-ask-lane.d.ts +4 -0
- package/dist/core/runner/prepare-ask-lane.js +4 -2
- package/dist/core/runner/prepare-execution-env.d.ts +5 -2
- package/dist/core/runner/prepare-execution-env.js +10 -3
- package/dist/core/runner/prepare-gate-stations.d.ts +3 -0
- package/dist/core/runner/prepare-gate-stations.js +2 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +8 -4
- package/dist/core/runner/prepare-hands-readface.js +6 -6
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -1
- package/dist/core/runner/prepare-inherited-gate.js +8 -2
- package/dist/core/runner/prepare-park-ask.d.ts +3 -0
- package/dist/core/runner/prepare-park-ask.js +5 -3
- package/dist/core/runner/prepare-policy-chain.d.ts +14 -2
- package/dist/core/runner/prepare-policy-chain.js +11 -4
- package/dist/core/runner/prepare-suspend-saga.d.ts +10 -0
- package/dist/core/runner/prepare-suspend-saga.js +7 -1
- package/dist/core/runner/prepare-task.js +37 -18
- package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
- package/dist/core/runner/prepare-workspace-restore.js +1 -0
- package/dist/core/runner/resume-apply.js +17 -3
- package/dist/core/runner/resume-checkpoint-screen.js +13 -0
- package/dist/core/runner/run-leg.js +5 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/sub-agent-deny-lists.d.ts +1 -1
- package/dist/core/runner/write-protection-station.d.ts +3 -2
- package/dist/core/runner/write-protection-station.js +1 -0
- package/dist/core/runner-deps.d.ts +14 -0
- package/dist/core/sensitive-path-policy.d.ts +8 -0
- package/dist/core/sensitive-path-policy.js +18 -2
- package/dist/core/shell-wrapper-projection.d.ts +11 -0
- package/dist/core/shell-wrapper-projection.js +56 -0
- package/dist/core/shell-wrapper-table.d.ts +144 -34
- package/dist/core/shell-wrapper-table.js +40 -20
- package/dist/core/synthetic-read-verdict.d.ts +3 -0
- package/dist/core/synthetic-read-verdict.js +3 -1
- package/dist/core/tool-catalog-entries.d.ts +21 -0
- package/dist/core/tool-catalog-entries.js +9 -0
- package/dist/core/tool-policy.d.ts +30 -8
- package/dist/core/tool-policy.js +9 -7
- package/dist/core/tool-spec.d.ts +3 -2
- package/dist/core/write-protect.d.ts +4 -0
- package/dist/core/write-protect.js +30 -9
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/orchestration/run-spec.js +8 -7
- package/dist/orchestration/workflow.js +1 -1
- package/dist/shell/lex.d.ts +7 -0
- package/dist/shell/lex.js +17 -0
- package/dist/tools/fs/bash-program-position.d.ts +8 -87
- package/dist/tools/fs/bash-program-position.js +33 -69
- package/dist/tools/fs/bash-readonly-classifier.d.ts +17 -444
- package/dist/tools/fs/bash-readonly-classifier.js +169 -1225
- package/dist/tools/fs/index.d.ts +3 -2
- package/dist/tools/fs/program-read-model.d.ts +694 -0
- package/dist/tools/fs/program-read-model.js +1252 -0
- package/dist/tools/fs/program-read-model.rows.d.ts +18 -0
- package/dist/tools/fs/program-read-model.rows.js +613 -0
- package/dist/tools/fs/read-deny-home.d.ts +19 -1
- package/dist/tools/fs/read-deny-home.js +62 -24
- package/dist/tools/fs/read-deny.d.ts +54 -14
- package/dist/tools/fs/read-deny.js +104 -50
- package/dist/tools/fs/removal-targets.d.ts +7 -6
- package/dist/tools/fs/removal-targets.js +22 -22
- package/dist/tools/fs/safety.d.ts +3 -0
- package/dist/tools/fs/safety.js +10 -3
- package/dist/tools/fs/shell-read-argv.d.ts +85 -0
- package/dist/tools/fs/shell-read-argv.js +386 -0
- package/dist/tools/fs/shell-read-bindings.d.ts +273 -0
- package/dist/tools/fs/shell-read-bindings.js +746 -0
- package/dist/tools/fs/shell-read-check.js +23 -15
- package/dist/tools/fs/shell-read-establish.js +79 -5
- package/dist/tools/fs/shell-read-judge.d.ts +11 -1
- package/dist/tools/fs/shell-read-judge.js +9 -1
- package/dist/tools/fs/shell-read-plan.d.ts +31 -7
- package/dist/tools/fs/shell-read-plan.js +299 -393
- package/dist/tools/fs/shell-read-word.d.ts +29 -26
- package/dist/tools/fs/shell-read-word.js +30 -38
- package/dist/tools/fs/shell-read-write-targets.d.ts +15 -64
- package/dist/tools/fs/shell-read-write-targets.js +83 -136
- package/dist/tools/fs/shell-reentry-text.d.ts +38 -6
- package/dist/tools/fs/shell-reentry-text.js +90 -53
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +17 -3
- package/wire-changes/core@7.46.0.json +1522 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE BINDING RULE — which shell names a command text binds, and to what, read off the one lexer's facts and the
|
|
3
|
+
* program read model's roles. A word that expands a name (`"$F"`, `${F}`, a `~` reading `HOME`) names a path only
|
|
4
|
+
* through what the text bound that name to; this module answers "what may `F` hold here", and nothing else.
|
|
5
|
+
*
|
|
6
|
+
* Two halves:
|
|
7
|
+
* · {@link bindingEffectOf} — what ONE segment does to the names: binds a name to a value (an assignment statement, a
|
|
8
|
+
* declaration builtin's `NAME=value`, a `for` list), makes a name unknown (a builtin whose operand role binds a name,
|
|
9
|
+
* an assigning expansion `${N:=…}`, an arithmetic assignment, a code body that runs later), gives a name an ATTRIBUTE
|
|
10
|
+
* (integer, a case change, an array, read-only: a later assignment to it stores something other than its text, or
|
|
11
|
+
* nothing), or makes EVERY name unknown (a name reference, `eval`, `source`, a computed name, an unquoted
|
|
12
|
+
* here-document `${`), and resets every name to the state it starts the text in (a function body: it runs at its
|
|
13
|
+
* call, against that table);
|
|
14
|
+
* · {@link BindingThread} — the effects threaded through the segments the way the plan threads the working directory
|
|
15
|
+
* (`shell-read-plan.ts`): a value bound in a segment that may not have run before a reader (an `&&` / `||` run, a
|
|
16
|
+
* branch, a loop body, a subshell, a pipeline member, a background job) joins the values the name held before
|
|
17
|
+
* instead of replacing them. A function body runs at its call, which the plan does not follow (a function may be
|
|
18
|
+
* called anywhere after its definition): a name the body binds is unreadable to every reader past the body, whatever
|
|
19
|
+
* is assigned to it later, and to every reader in another body — unless the body declared it with a plain `local`.
|
|
20
|
+
* An attribute and a name reference hold for every segment they may RUN before: a later one, one in a function body
|
|
21
|
+
* (it runs at its call), one in the same loop body (a later beat).
|
|
22
|
+
*
|
|
23
|
+
* A name the text does not settle is UNKNOWN, and a word expanding an unknown name stays a word the shell rewrites (its
|
|
24
|
+
* read cannot be established). `HOME` is an ordinary name whose state at the start of a text is the declared home.
|
|
25
|
+
* The shell's own variables (the ones bash sets, holds read-only or evaluates itself) are never bound from text.
|
|
26
|
+
*/
|
|
27
|
+
import { type LexedRedirect, type LexedSegment, type LexedToken, type LexedWord } from "../../shell/lex.js";
|
|
28
|
+
import { type DeclaredAttribute } from "./program-read-model.js";
|
|
29
|
+
/** A value a name may hold: the text it holds, and whether that text is a PATTERN whose matches are the values (a `for`
|
|
30
|
+
* list word the shell globs before the loop binds it). */
|
|
31
|
+
export interface BoundValue {
|
|
32
|
+
readonly spelled: string;
|
|
33
|
+
readonly glob?: true;
|
|
34
|
+
}
|
|
35
|
+
/** What a name holds at one point of a text: its possible values, or `"unknown"`. */
|
|
36
|
+
type NameState = readonly BoundValue[] | "unknown";
|
|
37
|
+
/**
|
|
38
|
+
* The variables bash keeps itself — it sets them (`PWD`, `REPLY`, `OPTARG`, `BASH_REMATCH`, …), holds them read-only
|
|
39
|
+
* (`SHELLOPTS`, `BASHOPTS`, `BASH_VERSINFO`: an assignment to one is refused), or evaluates every value assigned to them
|
|
40
|
+
* as ARITHMETIC (the integer variables: `OPTIND`, `RANDOM`, `LINENO`, `HISTCMD`, `BASHPID`, …; the reference
|
|
41
|
+
* implementation's table of them, `zsh`'s included, is read whole: a member that is not one in this shell costs a
|
|
42
|
+
* question, never a read). Their value is never the text that bound it.
|
|
43
|
+
*/
|
|
44
|
+
export declare const SHELL_INTEGER_VARIABLES: ReadonlySet<string>;
|
|
45
|
+
/** Is this a variable bash keeps itself ({@link SHELL_INTEGER_VARIABLES}, or one it sets)? */
|
|
46
|
+
export declare function shellKeepsName(name: string): boolean;
|
|
47
|
+
/** One binding a segment makes: a name and what it now holds (`unknown` = made unknown). `prefix`: a prefix assignment
|
|
48
|
+
* to a special builtin, which may or may not outlive the command. `loopVar`: a `for` loop's variable, held through
|
|
49
|
+
* its body. */
|
|
50
|
+
export interface Binding {
|
|
51
|
+
readonly name: string;
|
|
52
|
+
readonly state: NameState;
|
|
53
|
+
readonly prefix?: true;
|
|
54
|
+
readonly loopVar?: true;
|
|
55
|
+
/** `local`: a plain `local NAME…` — in a function body the name is the body's own and never leaves it. `unread`: a
|
|
56
|
+
* declaration builtin with an option word (`declare -g`, `local -p`, `local -r`): which scope it binds in is not
|
|
57
|
+
* read, so it is neither the body's own name nor covered by an earlier `local`. */
|
|
58
|
+
readonly scope?: "local" | "unread";
|
|
59
|
+
/** Spellings the name may hold that the deny judge still reads where the name is otherwise unknown (an array's
|
|
60
|
+
* elements: what `${A[k]}` expands to is one of them). */
|
|
61
|
+
readonly floor?: readonly BoundValue[];
|
|
62
|
+
}
|
|
63
|
+
/** An attribute a declaration gives a name — or every name (`name` absent: the declaration computed it): a later
|
|
64
|
+
* assignment to it is evaluated as arithmetic (`integer`), stores a case change or an array element (`transformed`), or
|
|
65
|
+
* is refused (`frozen`) — it binds something other than its text. */
|
|
66
|
+
export interface NameAttribute {
|
|
67
|
+
readonly name?: string;
|
|
68
|
+
readonly kind: Exclude<DeclaredAttribute, "reference" | "unsettled">;
|
|
69
|
+
}
|
|
70
|
+
/** What ONE segment does to the names. `all`: every name made unknown (`unknown`), or reset to its state at the start
|
|
71
|
+
* of the text (`reset` — a function body). `attributes`: the attributes it gives ({@link NameAttribute}). `references`:
|
|
72
|
+
* a name reference was declared — from here on an assignment to any name may write through it, so no name holds what
|
|
73
|
+
* the text assigned. `inFunction`: the builtin assigns only inside a function body (`local`) — outside one bash refuses
|
|
74
|
+
* the command, and its bindings hold nothing the text says. */
|
|
75
|
+
export interface BindingEffect {
|
|
76
|
+
readonly bindings: readonly Binding[];
|
|
77
|
+
readonly all?: "unknown" | "reset";
|
|
78
|
+
readonly attributes?: readonly NameAttribute[];
|
|
79
|
+
readonly references?: true;
|
|
80
|
+
readonly inFunction?: true;
|
|
81
|
+
}
|
|
82
|
+
/** How one value word reads against the table, the earlier assignments of the same segment applied (bash assigns left
|
|
83
|
+
* to right): its possible values, or `unknown`. */
|
|
84
|
+
export type ValueReader = (word: Pick<LexedWord, "pieces">, quoted: boolean, overlay: ReadonlyMap<string, NameState>) => NameState;
|
|
85
|
+
/** The segment's shape the effect needs beside its words: a function definition head was dropped from it. */
|
|
86
|
+
export interface SegmentShape {
|
|
87
|
+
readonly definesFunction: boolean;
|
|
88
|
+
}
|
|
89
|
+
/** The argv projection of a lexed segment: structure that names nothing that runs here is dropped — a subshell
|
|
90
|
+
* parenthesis, a bare `{` / `}`, a function definition's head (`NAME ()`, and `function NAME [()]` with a name of
|
|
91
|
+
* any spelling, {@link dropDefinitionHeads}), a `case` arm's pattern ({@link dropCasePattern}), and the block words
|
|
92
|
+
* at the head. */
|
|
93
|
+
export interface ProjectedSegment extends SegmentShape {
|
|
94
|
+
readonly argv: readonly LexedWord[];
|
|
95
|
+
readonly redirects: readonly LexedRedirect[];
|
|
96
|
+
readonly grouped: boolean;
|
|
97
|
+
}
|
|
98
|
+
export declare function projectSegment(segment: LexedSegment): ProjectedSegment;
|
|
99
|
+
/** A function definition's head names nothing that runs here and is dropped from a segment's tokens, in place:
|
|
100
|
+
* `NAME ( )` ({@link isDefinitionName}), and `function NAME [( )]` — a bare `function` at command position, a name of any
|
|
101
|
+
* spelling. The lexer puts the body's compound command back at command position after the head, so a definition
|
|
102
|
+
* nested in a body is dropped the same way; after a drop the token that moved up is looked at again. Answers where the
|
|
103
|
+
* heads stood: entry `k` counts the heads dropped right before the token now at `k` (the last entry, past the last
|
|
104
|
+
* token, a head whose body opens in a later segment). */
|
|
105
|
+
export declare function dropDefinitionHeads(tokens: LexedToken[]): readonly number[];
|
|
106
|
+
/**
|
|
107
|
+
* What a word holds through the names it refers to — `$NAME`, `${NAME}`, a leading `~` (the value of `HOME`):
|
|
108
|
+
* · `undefined` — it refers to no name (it reads as written);
|
|
109
|
+
* · its values — every combination of the values its names may hold here (a piece the shell globs keeps its written
|
|
110
|
+
* pattern, and the value is then a pattern);
|
|
111
|
+
* · `"unknown"` — a name it refers to is not settled here, it carries an expansion no name answers (a modifier, a
|
|
112
|
+
* substitution, a brace list, `~user`), an UNQUOTED expansion's value is not one word or `IFS` may have changed
|
|
113
|
+
* (`quoted` = the whole word is read as one value: an assignment's value, which is never split), or it would list
|
|
114
|
+
* more than {@link WORD_VALUES_MAX} values.
|
|
115
|
+
* `table.stateOf` is read after `overlay` (the names the same segment bound earlier).
|
|
116
|
+
*/
|
|
117
|
+
export declare function wordValues(word: Pick<LexedWord, "pieces">, table: BindingTable | undefined, quoted: boolean, overlay?: ReadonlyMap<string, NameState>): readonly BoundValue[] | "unknown" | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* The spellings a word the table leaves unknown may still take through the deny floors of the names it refers to
|
|
120
|
+
* ({@link BindingTable.floorOf}) — `${A[k]}`, `${A[@]}`, `$A` reading an array's elements — or through their values where
|
|
121
|
+
* known: for the deny judge alone. Empty where some name it refers to leaves neither.
|
|
122
|
+
*/
|
|
123
|
+
export declare function wordFloorValues(word: Pick<LexedWord, "pieces">, table: BindingTable | undefined): readonly BoundValue[];
|
|
124
|
+
/** What a VALUE word holds (an assignment's value, a `for` list word): {@link wordValues}, or — a word referring to no
|
|
125
|
+
* name — its own text (a word the shell globs is a pattern; one carrying any other expansion holds what the text does
|
|
126
|
+
* not say). */
|
|
127
|
+
export declare function valueOf(word: Pick<LexedWord, "pieces">, table: BindingTable | undefined, quoted: boolean, overlay?: ReadonlyMap<string, NameState>): NameState;
|
|
128
|
+
/**
|
|
129
|
+
* What ONE segment does to the names (see the module header). `argv` = the segment's argv projection (structure
|
|
130
|
+
* dropped); `readValue` folds a value word against the table (a reader that answers `unknown` gives the names alone).
|
|
131
|
+
*/
|
|
132
|
+
export declare function bindingEffectOf(segment: LexedSegment, argv: readonly LexedWord[], shape: SegmentShape, readValue: ValueReader): BindingEffect;
|
|
133
|
+
/**
|
|
134
|
+
* The names an ARITHMETIC text may assign: every identifier in a text that carries an assignment operator (`=` that is no
|
|
135
|
+
* comparison, `+=` and its kin, `++`, `--`) — read whole, not parsed: a name only compared there is made unknown too.
|
|
136
|
+
*/
|
|
137
|
+
export declare function arithmeticAssignedNames(text: string): string[];
|
|
138
|
+
/** The names a text binds anywhere (every segment, every name the binding rule reads), or `all` where it may bind any
|
|
139
|
+
* name — for a body that runs later. Unreadable text binds any. */
|
|
140
|
+
export declare function namesBoundIn(text: string, depth?: number): ReadonlySet<string> | "all";
|
|
141
|
+
/**
|
|
142
|
+
* Does this text bind `HOME` anywhere (or every name)? — the question a reader that spells the declared home for `~` /
|
|
143
|
+
* `$HOME` asks of a text it reads as ONE unit (the read-only classifier's segments). The read station asks the
|
|
144
|
+
* threaded question instead ({@link BindingThread}).
|
|
145
|
+
*/
|
|
146
|
+
export declare function textBindsHome(text: string): boolean;
|
|
147
|
+
/** What a name holds at one point of a text, asked by name ({@link BindingTable.stateOf}). */
|
|
148
|
+
export type NameReader = (name: string) => NameState;
|
|
149
|
+
/** What holds for the names where a nested text starts, given by the text around it: the attributes
|
|
150
|
+
* ({@link NameAttribute}) and whether a name reference was declared — a substitution body starts with what may run
|
|
151
|
+
* before its segment, a text run later or elsewhere (a code body, `eval`'s text, a child shell's `-c`) with all the
|
|
152
|
+
* text around it gives. */
|
|
153
|
+
export interface InheritedNames {
|
|
154
|
+
readonly attributes: readonly NameAttribute[];
|
|
155
|
+
readonly references: boolean;
|
|
156
|
+
}
|
|
157
|
+
/** What the thread answers for one reader: what a name may hold, and whether a name carries the integer attribute. */
|
|
158
|
+
export interface BindingTable {
|
|
159
|
+
stateOf(name: string): NameState;
|
|
160
|
+
/** Values assigned to this name are evaluated as arithmetic. */
|
|
161
|
+
isInteger(name: string): boolean;
|
|
162
|
+
/** The text may have changed `IFS` before this point: an unquoted expansion is split on what the text does not say. */
|
|
163
|
+
readonly ifsTouched: boolean;
|
|
164
|
+
/** `HOME` may hold something other than the declared home here. */
|
|
165
|
+
readonly homeTouched: boolean;
|
|
166
|
+
/** Every spelling any binding of this name before here left for the deny judge alone ({@link Binding.floor}). */
|
|
167
|
+
floorOf(name: string): readonly BoundValue[];
|
|
168
|
+
/** What a substitution body here starts with. */
|
|
169
|
+
readonly inherited: InheritedNames;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* The effects of a text's segments, threaded the way the plan threads its working directory: a reader at segment `j`
|
|
173
|
+
* sees the latest binding of a name, and, where that binding may not have run before `j`, the bindings before it too.
|
|
174
|
+
* A binding is CERTAIN for `j` when no block holding it (a branch, a loop, a group) closes or switches branch between it
|
|
175
|
+
* and `j` — a block it precedes may come and go — its segment is no pipeline member, background job or prefix
|
|
176
|
+
* assignment, and — reached through `&&` / `||` — it lies in `j`'s own `&&` run (`andRunStart`: the same index the
|
|
177
|
+
* working-directory thread reads).
|
|
178
|
+
*
|
|
179
|
+
* A function body runs at its call, and the plan does not follow calls (a function may be called anywhere after its
|
|
180
|
+
* definition — through a wrapper word, `eval`, `trap`, `source`, another function): a name bound in a body is
|
|
181
|
+
* {@link Unreadable} to every reader past the body, a later assignment included, and to every reader in another body;
|
|
182
|
+
* the body's own readers follow its own order. A name the body declares with a plain `local` (before the binding,
|
|
183
|
+
* where the declaration certainly ran) never leaves it.
|
|
184
|
+
*
|
|
185
|
+
* An attribute ({@link NameAttribute}) and a name reference hold for every segment they may RUN before — a later one,
|
|
186
|
+
* one in a function body, one in the same loop body: an assignment there binds something other than its text.
|
|
187
|
+
*/
|
|
188
|
+
export declare class BindingThread {
|
|
189
|
+
private readonly segments;
|
|
190
|
+
/** What each segment binds, its names alone (a value is the reader's to read). */
|
|
191
|
+
private readonly named;
|
|
192
|
+
/** The state a name starts the text in (and is reset to by a function body): the declared home for `HOME`. */
|
|
193
|
+
private readonly initial;
|
|
194
|
+
/** Names any segment of the text binds (a function body run later reads a `HOME` bound anywhere as unknown). */
|
|
195
|
+
private readonly boundAnywhere;
|
|
196
|
+
/** Each loop head's segment and its matching `done`'s. */
|
|
197
|
+
private readonly loops;
|
|
198
|
+
/** `HOME` may already hold something other than the declared home where the text starts (a substitution body
|
|
199
|
+
* inside a text that bound it). */
|
|
200
|
+
private readonly homeStartsTouched;
|
|
201
|
+
private readonly entries;
|
|
202
|
+
/** The attributes the text gives ({@link BindingEffect.attributes}), and where — read off its names alone, before any
|
|
203
|
+
* reader: one given later in the text may run first. */
|
|
204
|
+
private readonly attributesAt;
|
|
205
|
+
/** Names no assignment makes readable again ({@link Unreadable}). */
|
|
206
|
+
private readonly unreadable;
|
|
207
|
+
/** The block nesting each segment moves ({@link blockStructure}). */
|
|
208
|
+
private readonly blocks;
|
|
209
|
+
/** Segments that are a pipeline member or run in the background. */
|
|
210
|
+
private readonly detached;
|
|
211
|
+
constructor(segments: readonly LexedSegment[],
|
|
212
|
+
/** What each segment binds, its names alone (a value is the reader's to read). */
|
|
213
|
+
named: readonly BindingEffect[],
|
|
214
|
+
/** The state a name starts the text in (and is reset to by a function body): the declared home for `HOME`. */
|
|
215
|
+
initial: (name: string) => NameState,
|
|
216
|
+
/** Names any segment of the text binds (a function body run later reads a `HOME` bound anywhere as unknown). */
|
|
217
|
+
boundAnywhere: (name: string) => boolean,
|
|
218
|
+
/** Each loop head's segment and its matching `done`'s. */
|
|
219
|
+
loops: ReadonlyMap<number, number>,
|
|
220
|
+
/** `HOME` may already hold something other than the declared home where the text starts (a substitution body
|
|
221
|
+
* inside a text that bound it). */
|
|
222
|
+
homeStartsTouched?: boolean,
|
|
223
|
+
/** What holds where the text starts: given before its first segment. */
|
|
224
|
+
inherited?: InheritedNames);
|
|
225
|
+
/** What a text nested at segment `j` starts with ({@link InheritedNames}) — `j` absent: a text run later, which every
|
|
226
|
+
* segment may run before. */
|
|
227
|
+
inheritedAt(j?: number): InheritedNames;
|
|
228
|
+
/** What segment `at` makes unreadable: in a function body, the names it binds (unless the body declared them `local`
|
|
229
|
+
* where the declaration certainly ran) — every name where it may bind any; a name reference, every name. */
|
|
230
|
+
private unreadableBy;
|
|
231
|
+
/** May segment `x` run before segment `e` runs (`x` being `e`: before a later run of it): `x` comes first in the text,
|
|
232
|
+
* `e` stands in a function body (the body runs at its call, after any segment, and may run again), or both stand in
|
|
233
|
+
* one loop's body (a later beat runs `x` again first). */
|
|
234
|
+
private mayRunBefore;
|
|
235
|
+
/** Did the body certainly declare this name `local` before segment `at`: an earlier segment of the body, run on its
|
|
236
|
+
* own (no `&&` / `||`, no pipeline member or background job), in a block still open at `at`. */
|
|
237
|
+
private declaredLocal;
|
|
238
|
+
/** Does the block that holds segment `at`'s words stay open (no closing word, no switch of branch) through `j`? */
|
|
239
|
+
private heldThrough;
|
|
240
|
+
/** Apply segment `at`'s effect. `andRun`: the segment was reached through `&&` / `||`. `loopEnd`: for a loop variable,
|
|
241
|
+
* the index of the loop's end. */
|
|
242
|
+
apply(at: number, effect: BindingEffect, andRun: boolean, loopEnd?: number): void;
|
|
243
|
+
/** Has the function body a binding at segment `at` was made in closed by segment `j`? */
|
|
244
|
+
private leftBody;
|
|
245
|
+
/** Make these names unknown from segment `at` on (a loop body that binds them may have run before any of its beats). */
|
|
246
|
+
kill(at: number, names: Iterable<string> | "all"): void;
|
|
247
|
+
/** The table a reader at segment `j` sees; `andRunStart` = the first segment of `j`'s `&&` run. */
|
|
248
|
+
tableAt(j: number, andRunStart: number): BindingTable;
|
|
249
|
+
}
|
|
250
|
+
/** A segment that opens with `((`: an arithmetic command (or a subshell in a subshell — the tokens are the same). */
|
|
251
|
+
export declare function isArithmeticCommand(segment: LexedSegment): boolean;
|
|
252
|
+
/** The `[[` operators whose operands the arithmetic evaluator reads (`[[ x -eq y ]]`; `[` / `test` compare integers
|
|
253
|
+
* without evaluating them). */
|
|
254
|
+
export declare const ARITHMETIC_TEST_OPERATORS: ReadonlySet<string>;
|
|
255
|
+
/** The substitutions a parameter expansion's body hands the arithmetic evaluator: its subscript (`${a[…]}`) and the
|
|
256
|
+
* offset and length of a substring expansion (`${x:off:len}` — the shell expands them, then evaluates them). */
|
|
257
|
+
export declare function parameterBodySubstitutions(name: string, body: string, table: BindingTable | undefined): string[];
|
|
258
|
+
/**
|
|
259
|
+
* The substitutions the shell's ARITHMETIC evaluator runs while it evaluates `text`: every `$(…)`, backquote or process
|
|
260
|
+
* substitution inside an array SUBSCRIPT of it (`a[$(…)]` — quoted or not: the evaluator re-reads the text it is
|
|
261
|
+
* handed), and — for each name the text refers to whose value the table holds — the same of that value (the evaluator
|
|
262
|
+
* evaluates a variable's value as arithmetic too, through any chain of names). A name the table does not settle
|
|
263
|
+
* contributes the literal values its bindings left (an array's elements) and nothing else: any other value is data the
|
|
264
|
+
* text does not hold. A name already on the chain is a cycle (bash refuses
|
|
265
|
+
* it). Each body is shell text the evaluator re-enters; past the reader's budget of values the text itself is handed
|
|
266
|
+
* back as a body, so the segment re-enters text it did not follow (unestablished, never silent).
|
|
267
|
+
*/
|
|
268
|
+
export declare function arithmeticSubstitutions(text: string, table: BindingTable | undefined, chain?: ReadonlySet<string>, budget?: {
|
|
269
|
+
left: number;
|
|
270
|
+
}): string[];
|
|
271
|
+
/** The text of every `[…]` subscript in an arithmetic text (nested brackets balanced; an unclosed one runs to the end). */
|
|
272
|
+
export declare function subscriptsOf(text: string): string[];
|
|
273
|
+
export {};
|