@sema-agent/core 7.49.4 → 7.50.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 +152 -0
- package/dist/agents/observer.js +3 -10
- package/dist/agents/peer-directory.d.ts +8 -3
- package/dist/agents/peer-directory.js +5 -3
- package/dist/agents/subagent-steps.d.ts +6 -14
- package/dist/agents/subagent-steps.js +3 -17
- package/dist/brain/stream-shared.d.ts +1 -1
- package/dist/core/allow-entry.d.ts +1 -1
- package/dist/core/allow-entry.js +1 -1
- package/dist/core/ask-origin.d.ts +15 -11
- package/dist/core/ask-origin.js +6 -14
- package/dist/core/auto-mode-prompt.js +6 -2
- package/dist/core/checkpoint-store.d.ts +6 -4
- package/dist/core/checkpoint-store.js +1 -1
- package/dist/core/context-edit.d.ts +2 -2
- package/dist/core/decision-receipt.d.ts +2 -2
- package/dist/core/decision-receipt.js +30 -11
- package/dist/core/delegation-frames.d.ts +66 -18
- package/dist/core/delegation-frames.js +22 -0
- package/dist/core/engine-notice.d.ts +7 -5
- package/dist/core/frame-settlement.d.ts +6 -1
- package/dist/core/gate-fold.js +19 -13
- package/dist/core/gate-lanes.js +12 -11
- package/dist/core/gate-outcome.d.ts +2 -2
- package/dist/core/governance-codes.js +2 -0
- package/dist/core/hooks.d.ts +28 -20
- package/dist/core/human-input-projection.js +2 -0
- package/dist/core/lsp-diagnostics.d.ts +3 -0
- package/dist/core/lsp-diagnostics.js +6 -0
- package/dist/core/lsp-session.d.ts +39 -17
- package/dist/core/lsp-session.js +118 -58
- package/dist/core/lsp.d.ts +83 -3
- package/dist/core/lsp.js +146 -16
- package/dist/core/mcp.js +2 -1
- package/dist/core/media-byte-cap.d.ts +14 -0
- package/dist/core/media-byte-cap.js +15 -3
- package/dist/core/memory-engine/consolidation-driver.d.ts +23 -1
- package/dist/core/memory-engine/consolidation-driver.js +54 -6
- package/dist/core/memory-engine/consolidation-write-gate.d.ts +46 -0
- package/dist/core/memory-engine/consolidation-write-gate.js +82 -0
- package/dist/core/memory-engine/consolidation.d.ts +17 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/distiller.d.ts +8 -2
- package/dist/core/memory-engine/distiller.js +8 -6
- package/dist/core/memory-engine/engine.d.ts +37 -4
- package/dist/core/memory-engine/engine.js +127 -38
- package/dist/core/memory-engine/file-backend.d.ts +8 -3
- package/dist/core/memory-engine/file-backend.js +44 -16
- package/dist/core/memory-engine/index.d.ts +2 -2
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/landing-admission.d.ts +65 -0
- package/dist/core/memory-engine/landing-admission.js +68 -0
- package/dist/core/memory-engine/types.d.ts +23 -0
- package/dist/core/mode-policy.d.ts +3 -2
- package/dist/core/mode-policy.js +2 -0
- package/dist/core/permission-rule-model.d.ts +19 -13
- package/dist/core/permission-rule-model.js +7 -4
- package/dist/core/permission-rule-provider.d.ts +11 -0
- package/dist/core/permission-rules.d.ts +1 -1
- package/dist/core/permission-rules.js +5 -2
- package/dist/core/persisted-rule-arms.d.ts +15 -7
- package/dist/core/persisted-rule-arms.js +13 -6
- package/dist/core/posix-mode-face.d.ts +10 -0
- package/dist/core/posix-mode-face.js +3 -0
- package/dist/core/reminder-mint.d.ts +5 -0
- package/dist/core/reminder-mint.js +1 -0
- package/dist/core/retired-keys.d.ts +8 -0
- package/dist/core/retired-keys.js +4 -0
- package/dist/core/rule-lane-reads.d.ts +4 -4
- package/dist/core/rule-lane-reads.js +10 -1
- package/dist/core/runner/construction-doors.d.ts +10 -4
- package/dist/core/runner/construction-doors.js +25 -2
- package/dist/core/runner/contracts.d.ts +20 -3
- package/dist/core/runner/env-capability-census.js +1 -1
- package/dist/core/runner/gate-exit.js +2 -1
- package/dist/core/runner/memory-consolidation-driver.d.ts +6 -4
- package/dist/core/runner/memory-consolidation-driver.js +5 -2
- package/dist/core/runner/memory-consolidation-write-judge.d.ts +17 -0
- package/dist/core/runner/memory-consolidation-write-judge.js +14 -0
- package/dist/core/runner/permission-rule-lanes.d.ts +16 -22
- package/dist/core/runner/permission-rule-lanes.js +13 -43
- package/dist/core/runner/person-path-rows.d.ts +244 -0
- package/dist/core/runner/person-path-rows.js +387 -0
- package/dist/core/runner/prepare-acquire-reconcile.js +8 -1
- package/dist/core/runner/prepare-artifact.d.ts +5 -3
- package/dist/core/runner/prepare-artifact.js +2 -8
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -3
- package/dist/core/runner/prepare-caps-and-workflow.js +1 -1
- package/dist/core/runner/prepare-context-lane.js +2 -2
- package/dist/core/runner/prepare-gate-stations.d.ts +3 -3
- package/dist/core/runner/prepare-gate-stations.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +19 -10
- package/dist/core/runner/prepare-hands-readface.js +57 -43
- package/dist/core/runner/prepare-lsp.d.ts +15 -13
- package/dist/core/runner/prepare-lsp.js +11 -11
- package/dist/core/runner/prepare-policy-chain.d.ts +8 -4
- package/dist/core/runner/prepare-policy-chain.js +6 -7
- package/dist/core/runner/prepare-run-refs.js +1 -1
- package/dist/core/runner/prepare-task.js +24 -16
- package/dist/core/runner/prepare-turn-wiring.d.ts +13 -6
- package/dist/core/runner/prepare-turn-wiring.js +19 -8
- package/dist/core/runner/read-root-grant.d.ts +1 -25
- package/dist/core/runner/read-root-grant.js +1 -17
- package/dist/core/runner/retired-runner-deps.d.ts +2 -2
- package/dist/core/runner/run-brain-sinks.d.ts +1 -5
- package/dist/core/runner/run-brain-sinks.js +2 -4
- package/dist/core/runner/run-harness-handlers.js +5 -4
- package/dist/core/runner/run-identity-wiring.d.ts +4 -4
- package/dist/core/runner/run-identity-wiring.js +10 -1
- package/dist/core/runner/run-leg.d.ts +1 -1
- package/dist/core/runner/run-leg.js +22 -9
- package/dist/core/runner/run-settle-and-teardown.d.ts +0 -4
- package/dist/core/runner/run-settle-and-teardown.js +7 -4
- package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.js +1 -1
- package/dist/core/runner/run-turn-boundary.js +2 -2
- package/dist/core/runner/runtask.js +8 -8
- package/dist/core/runner/session-file-state-replay.d.ts +14 -4
- package/dist/core/runner/session-file-state-replay.js +8 -0
- package/dist/core/runner/stream-steer-verb.js +3 -0
- package/dist/core/runner/tool-end-body.d.ts +5 -4
- package/dist/core/runner/tool-end-body.js +4 -4
- package/dist/core/runner/tool-output-projection.d.ts +6 -4
- package/dist/core/runner/tool-output-projection.js +66 -47
- package/dist/core/runner-deps.d.ts +6 -3
- package/dist/core/shared-memory/types.d.ts +2 -2
- package/dist/core/shell-read-silence.d.ts +23 -0
- package/dist/core/shell-read-silence.js +18 -0
- package/dist/core/synthetic-read-verdict.d.ts +80 -21
- package/dist/core/synthetic-read-verdict.js +89 -18
- package/dist/core/task-event.d.ts +113 -25
- package/dist/core/task-spec.d.ts +44 -0
- package/dist/core/task-tool-shape.d.ts +1 -1
- package/dist/core/tool-catalog-entries.js +16 -2
- package/dist/core/tool-policy.d.ts +25 -15
- package/dist/core/tool-policy.js +9 -13
- package/dist/core/trace.d.ts +3 -2
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-text.d.ts +2 -2
- package/dist/core/user-attachment.d.ts +164 -0
- package/dist/core/user-attachment.js +437 -0
- package/dist/engine/compaction/compaction.js +10 -3
- package/dist/engine/compaction/utils.js +6 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +19 -1
- package/dist/engine/execution-env/node-execution-env.js +127 -1
- package/dist/engine/harness/agent-harness.d.ts +12 -2
- package/dist/engine/harness/agent-harness.js +15 -3
- package/dist/engine/harness/types.d.ts +21 -0
- package/dist/engine/llm/content-block-render.d.ts +15 -0
- package/dist/engine/llm/content-block-render.js +10 -0
- package/dist/engine/llm/index.d.ts +1 -0
- package/dist/engine/llm/index.js +1 -0
- package/dist/engine/llm/types.d.ts +80 -4
- package/dist/engine/llm/types.js +43 -1
- package/dist/engine/session/import-validate.js +2 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +2 -1
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/llm.d.ts +2 -2
- package/dist/internal/llm.js +1 -1
- package/dist/orchestration/workflow.d.ts +4 -5
- package/dist/orchestration/workflow.js +2 -2
- package/dist/prompts/default.d.ts +1 -1
- package/dist/stores/file/permission-rule-store.d.ts +13 -1
- package/dist/stores/file/permission-rule-store.js +40 -21
- package/dist/tools/artifact/artifact-tool.js +1 -1
- package/dist/tools/fs/bash-readonly-classifier.d.ts +1 -1
- package/dist/tools/fs/dir-entries.d.ts +4 -10
- package/dist/tools/fs/dir-entries.js +4 -11
- package/dist/tools/fs/file-read-check.js +3 -3
- package/dist/tools/fs/fs-pdf.js +2 -4
- package/dist/tools/fs/fs-read.d.ts +47 -4
- package/dist/tools/fs/fs-read.js +63 -19
- package/dist/tools/fs/fs-search-tools.d.ts +3 -3
- package/dist/tools/fs/fs-search-tools.js +7 -2
- package/dist/tools/fs/fs-write.d.ts +1 -1
- package/dist/tools/fs/fs-write.js +7 -6
- package/dist/tools/fs/index.d.ts +7 -1
- package/dist/tools/fs/index.js +56 -34
- package/dist/tools/fs/read-deny-home.d.ts +19 -1
- package/dist/tools/fs/read-deny-home.js +32 -22
- package/dist/tools/fs/read-deny.d.ts +14 -0
- package/dist/tools/fs/read-deny.js +8 -0
- package/dist/tools/fs/repo-map.d.ts +3 -2
- package/dist/tools/fs/repo-map.js +11 -3
- package/dist/tools/fs/safety.d.ts +41 -2
- package/dist/tools/fs/safety.js +12 -3
- package/dist/tools/fs/shell-read-check.d.ts +12 -3
- package/dist/tools/fs/shell-read-check.js +28 -15
- package/dist/tools/fs/shell-read-device.d.ts +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +9 -4
- package/dist/tools/fs/shell-read-judge.js +1 -1
- package/dist/tools/loop-tick.d.ts +2 -2
- package/package.json +3 -1
- package/test/export-surface.snapshot.json +39 -1
- package/wire-changes/core@7.49.5.json +104 -0
- package/wire-changes/core@7.50.0.json +1699 -0
- package/dist/core/runner/persisted-path-rows.d.ts +0 -88
- package/dist/core/runner/persisted-path-rows.js +0 -108
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The person's persisted PATH rows as a leg's read face takes them at prepare (the gate's rule lanes read the same store
|
|
3
|
-
* per call).
|
|
4
|
-
*/
|
|
5
|
-
import { type EffectivePermissionRules, type PermissionRuleStoreProvider } from "../permission-rule-provider.js";
|
|
6
|
-
import { type PathRuleBases } from "../permission-rule-model.js";
|
|
7
|
-
import { type BoundPathRule, type HeadLeads } from "../path-rule-binding.js";
|
|
8
|
-
import type { RunnerDeps } from "../runner-deps.js";
|
|
9
|
-
/** The person's persisted PATH rows a leg's read face takes at prepare ({@link persistedPathRowsOf}). */
|
|
10
|
-
export interface PersistedPathRows {
|
|
11
|
-
/** Every live `Read(//dir/**)` allow row's directory (lexical, absolute): a standing yes to reads under it. */
|
|
12
|
-
readonly readDirectories: readonly string[];
|
|
13
|
-
/** Every live face-keyed path DENY row (`Read(...)`, `Edit(...)`), bound at its anchors (a project row at its scope root,
|
|
14
|
-
* the rest at the chain's top leg). */
|
|
15
|
-
readonly denyRows: readonly BoundPathRule[];
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* The person's persisted PATH rows, read ONCE at prepare from the same store query the gate's lanes read per call: a
|
|
19
|
-
* `Read(//dir/**)` allow row is a READ DIRECTORY of the run (the Bash read station, Read / Grep / Glob — one set), and a
|
|
20
|
-
* `Read(...)` / `Edit(...)` deny row joins the run's read / write deny tables (every read face, the shell's file commands
|
|
21
|
-
* and traversals). One read, two directions, so a person's allow row never reaches further than their deny rows: a
|
|
22
|
-
* directory it admits still refuses the paths a deny row names. A row the store gains mid-run applies from the next
|
|
23
|
-
* prepare; the in-flight grant (`readRootGrant`) is the mid-run door. The store not armed, or the anonymous floor ⇒ no
|
|
24
|
-
* rows. A read that failed (or did not answer in time) ⇒ no rows, and a partition the read could not read ⇒ none of ITS
|
|
25
|
-
* rows (the partition that was read contributes its own): what could not be read is skipped for this run's tables — its
|
|
26
|
-
* directories widen nothing and its deny rows judge nothing here — disclosed on the trace and announced to the person
|
|
27
|
-
* (`onUnread`); the next prepare reads again, as it would for a row the store gained mid-run. A deny row is anchored by
|
|
28
|
-
* its scope (`persistedRowAnchors`: a project row at its own scope root, a global / session row at the chain's top leg,
|
|
29
|
-
* `~/` at the top leg's home); one whose pattern needs an anchor the chain does not supply (`~/` with no declared home) is
|
|
30
|
-
* left to the per-call lane and disclosed.
|
|
31
|
-
*/
|
|
32
|
-
export declare function persistedPathRowsOf(cfg: {
|
|
33
|
-
provider: PermissionRuleStoreProvider | undefined;
|
|
34
|
-
localOwnerDeclared: boolean;
|
|
35
|
-
principal: string | undefined;
|
|
36
|
-
sessionId: string;
|
|
37
|
-
/** The leg's own root: which project rows apply to this leg (either spelling of it — {@link projectScopeIdentity}). */
|
|
38
|
-
root: string;
|
|
39
|
-
rootCanonical: string | undefined;
|
|
40
|
-
/** The leg's resolution of locations (a project row's scope root, where it leads). */
|
|
41
|
-
leads: HeadLeads;
|
|
42
|
-
/** The anchors of the global / session rows and of `~/`: the chain's top leg's root and home. */
|
|
43
|
-
chainTop: PathRuleBases;
|
|
44
|
-
onDisclosure: (message: string) => void;
|
|
45
|
-
/** The person is told the store (or the named sources of it) was skipped ({@link ruleStoreUnreadableNotice}). */
|
|
46
|
-
onUnread: (at: "prepare", sources?: EffectivePermissionRules["unreadableSources"]) => void;
|
|
47
|
-
/** The person is told rows were left out ({@link ruleRowsDroppedNotice}). */
|
|
48
|
-
onRowsDropped: (rows: EffectivePermissionRules["droppedRows"]) => void;
|
|
49
|
-
/** The run's cut: a read that has not answered by then (or by the gate's await bound) reads as unreadable. */
|
|
50
|
-
signal?: AbortSignal;
|
|
51
|
-
}): Promise<PersistedPathRows>;
|
|
52
|
-
/**
|
|
53
|
-
* The run's ONE `permission.rule_store_unavailable` notice (audience user): the person's rules — the whole store, or the
|
|
54
|
-
* sources of it whose partition could not be read — were skipped; minted by whichever read found it first (the prepare
|
|
55
|
-
* read of the path rows, or a call's own read on the rule lane), once per run however many reads fail after it (the
|
|
56
|
-
* prepare sentence says a later call may be judged without them too). The trace keeps every read's line.
|
|
57
|
-
*/
|
|
58
|
-
export declare function ruleStoreUnreadableNotice(onNotice: RunnerDeps["onNotice"], ids: {
|
|
59
|
-
readonly sessionId: string;
|
|
60
|
-
readonly runId: string;
|
|
61
|
-
}): (at: "prepare" | "call", sources?: EffectivePermissionRules["unreadableSources"]) => void;
|
|
62
|
-
/**
|
|
63
|
-
* The run's ONE `permission.rule_row_dropped` notice (audience user): the person's store served project-scoped rows whose
|
|
64
|
-
* scope root is not a complete absolute path, left out of the checks; minted by whichever read met them first (the
|
|
65
|
-
* prepare read of the path rows, or a call's own read on the rule lane), once per run. The sentence names no path; the
|
|
66
|
-
* rows (bounded) ride the detail. The trace keeps every read's line.
|
|
67
|
-
*/
|
|
68
|
-
export declare function ruleRowsDroppedNotice(onNotice: RunnerDeps["onNotice"], ids: {
|
|
69
|
-
readonly sessionId: string;
|
|
70
|
-
readonly runId: string;
|
|
71
|
-
}): (rows: EffectivePermissionRules["droppedRows"]) => void;
|
|
72
|
-
/** {@link persistedPathRowsOf} for one task's prepare: only where a read face mounts (hands), disclosed on the run's trace,
|
|
73
|
-
* cut by the run's own signals. `undefined` = nothing to read, returned synchronously: a run with no person's store (or
|
|
74
|
-
* no hands) gains no suspension point on its prepare. */
|
|
75
|
-
export declare function persistedPathRowsOfTask(t: {
|
|
76
|
-
deps: Pick<RunnerDeps, "permissionRuleStore" | "localOwnerRules" | "tracer">;
|
|
77
|
-
principal: string | undefined;
|
|
78
|
-
sessionId: string;
|
|
79
|
-
root: string;
|
|
80
|
-
rootCanonical: string | undefined;
|
|
81
|
-
leads: HeadLeads;
|
|
82
|
-
chainTop: PathRuleBases;
|
|
83
|
-
taskId: string;
|
|
84
|
-
handsEnabled: boolean;
|
|
85
|
-
signals: readonly AbortSignal[];
|
|
86
|
-
onUnread: (at: "prepare", sources?: EffectivePermissionRules["unreadableSources"]) => void;
|
|
87
|
-
onRowsDropped: (rows: EffectivePermissionRules["droppedRows"]) => void;
|
|
88
|
-
}): Promise<PersistedPathRows> | undefined;
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { ownerStoreOf } from "../permission-rule-provider.js";
|
|
2
|
-
import { PATH_RULE_FACES, READ_RULE_TOOL, eligiblePersisted } from "../permission-rule-model.js";
|
|
3
|
-
import { bindPathRules, persistedRowAnchors, projectScopeIdentity } from "../path-rule-binding.js";
|
|
4
|
-
import { inlineUntrusted } from "../untrusted-text.js";
|
|
5
|
-
import { DEFAULT_GATE_AWAIT_TIMEOUT_MS, gateWaitFailureOf, withGateTimeout } from "../gate-bounded-await.js";
|
|
6
|
-
import { thrownText } from "../thrown-value.js";
|
|
7
|
-
import { emitTrace } from "../trace.js";
|
|
8
|
-
import { deliverEngineNotice } from "../engine-notice.js";
|
|
9
|
-
export async function persistedPathRowsOf(cfg) {
|
|
10
|
-
const none = { readDirectories: [], denyRows: [] };
|
|
11
|
-
const provider = cfg.provider;
|
|
12
|
-
if (provider === undefined || !readsPersistedPathRows(provider, cfg.principal, cfg.localOwnerDeclared))
|
|
13
|
-
return none;
|
|
14
|
-
let view;
|
|
15
|
-
try {
|
|
16
|
-
view = await withGateTimeout(ownerStoreOf(provider, cfg.principal, cfg.localOwnerDeclared).effective({ sessionId: cfg.sessionId }), DEFAULT_GATE_AWAIT_TIMEOUT_MS, cfg.signal, "persistedPathRows");
|
|
17
|
-
}
|
|
18
|
-
catch (err) {
|
|
19
|
-
return gateWaitFailureOf(err) === "aborted" ? none : skipped(cfg, thrownText(err));
|
|
20
|
-
}
|
|
21
|
-
if (view.unreadable !== undefined)
|
|
22
|
-
skipped(cfg, view.unreadable, view.unreadableSources);
|
|
23
|
-
cfg.onRowsDropped(view.droppedRows);
|
|
24
|
-
const scopeIdentity = await projectScopeIdentity(view.rules, cfg.rootCanonical, cfg.leads);
|
|
25
|
-
const call = { tool: READ_RULE_TOOL, cwd: cfg.root, sessionId: cfg.sessionId, ...(scopeIdentity !== undefined ? { scopeIdentity } : {}) };
|
|
26
|
-
const readDirectories = [];
|
|
27
|
-
const denySpecs = [];
|
|
28
|
-
for (const rule of view.rules) {
|
|
29
|
-
if (rule.status !== "live")
|
|
30
|
-
continue;
|
|
31
|
-
if (rule.behavior === "allow" && rule.tool === READ_RULE_TOOL && rule.match === "subpath" && eligiblePersisted(rule, call, "allow")) {
|
|
32
|
-
if (!readDirectories.includes(rule.command))
|
|
33
|
-
readDirectories.push(rule.command);
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
const faces = PATH_RULE_FACES[rule.tool]?.deny;
|
|
37
|
-
if (rule.behavior !== "deny" || faces === undefined || (rule.match !== "path" && rule.match !== "subpath") || !eligiblePersisted(rule, { ...call, tool: rule.tool }, "deny"))
|
|
38
|
-
continue;
|
|
39
|
-
denySpecs.push({ parsed: rule, ruleText: rule.rule, faces, rule });
|
|
40
|
-
}
|
|
41
|
-
const denyRows = [];
|
|
42
|
-
for (const row of bindPathRules(denySpecs, (spec) => persistedRowAnchors(spec.rule.scope, cfg.chainTop))) {
|
|
43
|
-
if (row.unanchored !== undefined) {
|
|
44
|
-
cfg.onDisclosure(`the persisted deny rule ${inlineUntrusted(row.rule, 200)} needs a ${row.unanchored.join(" / ")} base this task does not declare — the shell's file commands and the search tools do not judge it on this leg`);
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
denyRows.push(row);
|
|
48
|
-
}
|
|
49
|
-
return { readDirectories, denyRows };
|
|
50
|
-
}
|
|
51
|
-
function skipped(cfg, why, sources) {
|
|
52
|
-
cfg.onDisclosure(`the persisted path rules could not be read at prepare, so this run's read directories and read / write deny tables take none of ${sources !== undefined ? `the ${sourcesWord(sources)} rows` : "their rows"} (the next prepare reads again): ${why}`);
|
|
53
|
-
cfg.onUnread("prepare", sources);
|
|
54
|
-
return { readDirectories: [], denyRows: [] };
|
|
55
|
-
}
|
|
56
|
-
function sourcesWord(sources) {
|
|
57
|
-
return sources.length <= 1 ? sources.join("") : `${sources.slice(0, -1).join(", ")} and ${sources[sources.length - 1]}`;
|
|
58
|
-
}
|
|
59
|
-
const SKIPPED_STORE_SENTENCE = {
|
|
60
|
-
prepare: (which) => `${which} could not be read when this run started, so this run's file and shell checks skip their path rows (Read / Edit deny rows and Read directory rows) — a deny row among them protects nothing on this run. Each call's own rule check reads the rules again (a call whose own read fails too is judged without them), and the next run reads the path rows again.`,
|
|
61
|
-
call: (which) => `${which} could not be read for a call on this run, so that call's own rule check skipped them: none of their allow, ask or deny rows took part in it, and a deny row among them protected nothing there (path rows the run took when it started still apply to its file and shell checks). Every later call reads them again, and they apply again as soon as a read succeeds.`,
|
|
62
|
-
};
|
|
63
|
-
export function ruleStoreUnreadableNotice(onNotice, ids) {
|
|
64
|
-
let sent = false;
|
|
65
|
-
return (at, sources) => {
|
|
66
|
-
if (sent)
|
|
67
|
-
return;
|
|
68
|
-
sent = true;
|
|
69
|
-
const which = sources !== undefined && sources.length > 0 ? `your persisted permission rules from the ${sourcesWord(sources)} sources` : "your persisted permission rules";
|
|
70
|
-
deliverEngineNotice(onNotice, { code: "permission.rule_store_unavailable", message: SKIPPED_STORE_SENTENCE[at](which), detail: { at, sessionId: ids.sessionId, runId: ids.runId } });
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
export function ruleRowsDroppedNotice(onNotice, ids) {
|
|
74
|
-
let sent = false;
|
|
75
|
-
return (rows) => {
|
|
76
|
-
if (sent || rows === undefined || rows.length === 0)
|
|
77
|
-
return;
|
|
78
|
-
sent = true;
|
|
79
|
-
const one = rows.length === 1;
|
|
80
|
-
deliverEngineNotice(onNotice, {
|
|
81
|
-
code: "permission.rule_row_dropped",
|
|
82
|
-
message: `${rows.length} of your persisted permission rule rows ${one ? "is" : "are"} scoped to a project directory that is not written as a complete absolute path, so ${one ? "it takes" : "they take"} no part in this run's checks — a deny or ask row among them protects nothing. Rewrite ${one ? "it" : "them"} with the project's full path, or remove ${one ? "it" : "them"} (this notice's detail names ${one ? "it" : "them"}).`,
|
|
83
|
-
detail: { rows: rows.slice(0, 8).map((r) => ({ rule: inlineUntrusted(r.rule, 200), scopeRoot: inlineUntrusted(r.scopeRoot, 200) })), count: rows.length, sessionId: ids.sessionId, runId: ids.runId },
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
function readsPersistedPathRows(provider, principal, localOwnerDeclared) {
|
|
88
|
-
return provider.partitions.durable && ((principal !== undefined && principal !== "") || localOwnerDeclared);
|
|
89
|
-
}
|
|
90
|
-
export function persistedPathRowsOfTask(t) {
|
|
91
|
-
const provider = t.deps.permissionRuleStore;
|
|
92
|
-
if (!t.handsEnabled || provider === undefined || !readsPersistedPathRows(provider, t.principal, t.deps.localOwnerRules === true))
|
|
93
|
-
return undefined;
|
|
94
|
-
return persistedPathRowsOf({
|
|
95
|
-
provider,
|
|
96
|
-
localOwnerDeclared: t.deps.localOwnerRules === true,
|
|
97
|
-
principal: t.principal,
|
|
98
|
-
sessionId: t.sessionId,
|
|
99
|
-
root: t.root,
|
|
100
|
-
rootCanonical: t.rootCanonical,
|
|
101
|
-
leads: t.leads,
|
|
102
|
-
chainTop: t.chainTop,
|
|
103
|
-
onDisclosure: (message) => emitTrace(t.deps.tracer, () => ({ kind: "permission.rule_store_unreadable", version: 1, taskId: t.taskId, message, ts: Date.now() })),
|
|
104
|
-
onUnread: t.onUnread,
|
|
105
|
-
onRowsDropped: t.onRowsDropped,
|
|
106
|
-
signal: AbortSignal.any([...t.signals]),
|
|
107
|
-
});
|
|
108
|
-
}
|