@sema-agent/core 7.58.0 → 7.59.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 +776 -0
- package/README.md +6 -4
- package/dist/agents/cc-peer-directory.js +8 -8
- package/dist/agents/child-model-seat.d.ts +4 -2
- package/dist/agents/child-model-seat.js +5 -3
- package/dist/agents/peer-directory.d.ts +9 -0
- package/dist/agents/peer-directory.js +6 -2
- package/dist/agents/send-message-tool.js +21 -12
- package/dist/agents/subagent.js +33 -34
- package/dist/brain/anthropic.js +161 -45
- package/dist/brain/errors.d.ts +9 -3
- package/dist/brain/errors.js +7 -1
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +3 -3
- package/dist/brain/openai.js +103 -53
- package/dist/brain/provider-dialect.d.ts +11 -0
- package/dist/brain/provider-dialect.js +5 -2
- package/dist/brain/reasoning-request.js +5 -4
- package/dist/brain/reasoning.d.ts +19 -0
- package/dist/brain/reasoning.js +17 -2
- package/dist/brain/request-route.d.ts +4 -1
- package/dist/brain/request-route.js +4 -1
- package/dist/brain/route-adjudicator.d.ts +84 -18
- package/dist/brain/route-adjudicator.js +87 -21
- package/dist/brain/route-conformance.js +1 -1
- package/dist/brain/stream-engine.js +84 -49
- package/dist/brain/stream-shared.d.ts +30 -0
- package/dist/brain/stream-shared.js +34 -1
- package/dist/brain/timeout.d.ts +62 -5
- package/dist/brain/timeout.js +93 -6
- package/dist/core/account-row.d.ts +61 -0
- package/dist/core/account-row.js +51 -0
- package/dist/core/advisor-verdict.d.ts +2 -1
- package/dist/core/advisor-verdict.js +1 -1
- package/dist/core/allow-entry.d.ts +18 -6
- package/dist/core/allow-entry.js +16 -8
- package/dist/core/approval-object.d.ts +29 -15
- package/dist/core/approval-object.js +47 -19
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/background-agent-store.d.ts +16 -3
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +3 -1
- package/dist/core/checkpoint-store.d.ts +58 -12
- package/dist/core/checkpoint-store.js +18 -6
- package/dist/core/child-clamp-seats.d.ts +29 -0
- package/dist/core/child-clamp-seats.js +56 -1
- package/dist/core/compliance.d.ts +2 -2
- package/dist/core/compliance.js +1 -1
- package/dist/core/effective-path-target.d.ts +8 -2
- package/dist/core/effective-path-target.js +8 -3
- package/dist/core/engine-notice.d.ts +98 -8
- package/dist/core/engine-notice.js +19 -5
- package/dist/core/gate-fold.js +1 -1
- package/dist/core/gate-lanes.js +8 -4
- package/dist/core/gate-outcome.d.ts +32 -3
- package/dist/core/gate-outcome.js +19 -1
- package/dist/core/governance-codes.d.ts +9 -1
- package/dist/core/governance-codes.js +13 -0
- package/dist/core/hooks.d.ts +31 -3
- package/dist/core/hooks.js +5 -6
- package/dist/core/image-admission.d.ts +6 -5
- package/dist/core/image-admission.js +18 -14
- package/dist/core/locked-config.d.ts +5 -2
- package/dist/core/locked-config.js +2 -1
- package/dist/core/mailbox-store.d.ts +45 -1
- package/dist/core/mailbox-store.js +53 -9
- package/dist/core/mcp-failure.d.ts +114 -18
- package/dist/core/mcp-failure.js +63 -5
- package/dist/core/mcp-server-link.d.ts +22 -1
- package/dist/core/mcp-server-link.js +25 -1
- package/dist/core/mcp.d.ts +12 -8
- package/dist/core/mcp.js +42 -25
- package/dist/core/memory-engine/consolidation-driver.d.ts +2 -4
- package/dist/core/memory-engine/consolidation-driver.js +3 -3
- package/dist/core/memory-engine/consolidation.d.ts +4 -0
- package/dist/core/memory-engine/consolidation.js +1 -0
- package/dist/core/memory-engine/delegation-settlement.js +5 -12
- package/dist/core/memory-engine/distiller.js +2 -2
- package/dist/core/memory-engine/dual-root.d.ts +50 -1
- package/dist/core/memory-engine/dual-root.js +44 -1
- package/dist/core/memory-engine/engine.d.ts +67 -14
- package/dist/core/memory-engine/engine.js +384 -212
- package/dist/core/memory-engine/export-bundle.d.ts +23 -0
- package/dist/core/memory-engine/export-bundle.js +23 -4
- package/dist/core/memory-engine/file-backend.d.ts +128 -55
- package/dist/core/memory-engine/file-backend.js +290 -117
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/layout.d.ts +59 -11
- package/dist/core/memory-engine/layout.js +190 -40
- package/dist/core/memory-engine/memory-backend-contract.d.ts +1 -1
- package/dist/core/memory-engine/memory-backend-contract.js +39 -2
- package/dist/core/memory-engine/sync-client.d.ts +9 -1
- package/dist/core/memory-engine/sync-client.js +31 -8
- package/dist/core/memory-engine/sync.d.ts +5 -0
- package/dist/core/memory-engine/types.d.ts +6 -0
- package/dist/core/mods/classic-events.d.ts +5 -1
- package/dist/core/mods/kernel/dispatch.js +2 -1
- package/dist/core/mods/kernel/events.d.ts +2 -1
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/registration.d.ts +4 -0
- package/dist/core/mods/kernel/registration.js +3 -0
- package/dist/core/mods/stations.d.ts +31 -10
- package/dist/core/mods/stations.js +44 -10
- package/dist/core/mods/tool-call.js +1 -1
- package/dist/core/parent-spec-seat.d.ts +8 -3
- package/dist/core/parent-spec-seat.js +2 -0
- package/dist/core/park-selfcheck.js +6 -0
- package/dist/core/peer-seat.d.ts +70 -8
- package/dist/core/peer-seat.js +143 -11
- package/dist/core/permission-rule-consent.js +10 -4
- package/dist/core/permission-rule-model.d.ts +16 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/present-plan-tool.d.ts +11 -3
- package/dist/core/present-plan-tool.js +2 -2
- package/dist/core/resume-startup-cause.js +1 -0
- package/dist/core/rewrite-rejudge.d.ts +1 -0
- package/dist/core/rewrite-rejudge.js +2 -2
- package/dist/core/roles.d.ts +34 -2
- package/dist/core/roles.js +43 -4
- package/dist/core/runner/announce-once-ledger.d.ts +5 -4
- package/dist/core/runner/announce-once-ledger.js +4 -2
- package/dist/core/runner/call-hook-stations.js +2 -2
- package/dist/core/runner/contracts.d.ts +20 -16
- package/dist/core/runner/credential-origin-seat.js +4 -3
- package/dist/core/runner/cwd-alignment-probe.d.ts +20 -0
- package/dist/core/runner/cwd-alignment-probe.js +21 -0
- package/dist/core/runner/decide-continuation.d.ts +2 -2
- package/dist/core/runner/gate-exit.d.ts +12 -4
- package/dist/core/runner/gate-exit.js +10 -7
- package/dist/core/runner/image-removed-seat.d.ts +12 -0
- package/dist/core/runner/image-removed-seat.js +19 -0
- package/dist/core/runner/inline-image.js +1 -1
- package/dist/core/runner/memory-consolidation-driver.js +3 -3
- package/dist/core/runner/park-commit.d.ts +1 -1
- package/dist/core/runner/park-commit.js +3 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +1 -1
- package/dist/core/runner/prepare-ask-lane.js +2 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -5
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -0
- package/dist/core/runner/prepare-config-doors.js +2 -0
- package/dist/core/runner/prepare-context-lane.js +2 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
- package/dist/core/runner/prepare-delegation-surface.js +1 -0
- package/dist/core/runner/prepare-hands-readface.d.ts +4 -0
- package/dist/core/runner/prepare-hands-readface.js +5 -0
- package/dist/core/runner/prepare-inherited-gate.d.ts +1 -3
- package/dist/core/runner/prepare-inherited-gate.js +14 -27
- package/dist/core/runner/prepare-memory.js +10 -17
- package/dist/core/runner/prepare-park-ask.d.ts +1 -1
- package/dist/core/runner/prepare-park-ask.js +2 -1
- package/dist/core/runner/prepare-policy-chain.d.ts +3 -3
- package/dist/core/runner/prepare-policy-chain.js +16 -13
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +1 -1
- package/dist/core/runner/prepare-prompt-inputs.js +8 -19
- package/dist/core/runner/prepare-protocol-tools.js +9 -1
- package/dist/core/runner/prepare-run-refs.d.ts +2 -3
- package/dist/core/runner/prepare-run-refs.js +4 -1
- package/dist/core/runner/prepare-task.js +4 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -1
- package/dist/core/runner/prepare-wiring-manifest.js +2 -1
- package/dist/core/runner/reply-pricing.d.ts +30 -0
- package/dist/core/runner/reply-pricing.js +19 -0
- package/dist/core/runner/resume-admission.js +4 -2
- package/dist/core/runner/resume-apply.js +6 -1
- package/dist/core/runner/resume-policy-outcome.js +5 -5
- package/dist/core/runner/role-seat-defaulted.d.ts +44 -0
- package/dist/core/runner/role-seat-defaulted.js +40 -0
- package/dist/core/runner/run-brain-sinks.js +2 -0
- package/dist/core/runner/run-identity-wiring.d.ts +2 -5
- package/dist/core/runner/run-identity-wiring.js +5 -4
- package/dist/core/runner/run-leg.d.ts +2 -0
- package/dist/core/runner/run-leg.js +37 -28
- package/dist/core/runner/run-stop-and-final-verify.js +2 -2
- package/dist/core/runner/run-terminal-adoption.d.ts +2 -5
- package/dist/core/runner/run-terminal-adoption.js +9 -3
- package/dist/core/runner/run-turn-boundary.js +77 -70
- package/dist/core/runner/runtask.d.ts +1 -1
- package/dist/core/runner/runtask.js +2 -2
- package/dist/core/runner/side-call-account.d.ts +1 -1
- package/dist/core/runner/side-call-account.js +3 -18
- package/dist/core/runner/sub-agent-deny-lists.d.ts +24 -0
- package/dist/core/runner/sub-agent-deny-lists.js +10 -0
- package/dist/core/runner/tool-end-body.js +2 -2
- package/dist/core/runner/tool-occurrence.d.ts +1 -1
- package/dist/core/runner/tool-occurrence.js +2 -2
- package/dist/core/runner/turn-attachments.d.ts +26 -22
- package/dist/core/runner/turn-attachments.js +24 -26
- package/dist/core/runner-deps.d.ts +1 -1
- package/dist/core/secret-env.d.ts +32 -2
- package/dist/core/secret-env.js +65 -3
- package/dist/core/sensitive-path-policy.js +3 -3
- package/dist/core/session-policy-store.d.ts +3 -1
- package/dist/core/session-policy-store.js +13 -9
- package/dist/core/session-store.d.ts +2 -5
- package/dist/core/side-query.d.ts +11 -1
- package/dist/core/side-query.js +9 -0
- package/dist/core/skill-grant-binding.d.ts +31 -2
- package/dist/core/skill-grant-binding.js +31 -1
- package/dist/core/skill-grant.d.ts +8 -5
- package/dist/core/skill-grant.js +6 -6
- package/dist/core/store-contracts/background-agent-store-contract.js +27 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +3 -2
- package/dist/core/store-contracts/mailbox-store-contract.js +31 -1
- package/dist/core/synthetic-read-verdict.js +2 -1
- package/dist/core/task-event.d.ts +32 -8
- package/dist/core/task-notification.js +16 -10
- package/dist/core/task-registry-agent.js +1 -0
- package/dist/core/task-registry-shared.d.ts +5 -0
- package/dist/core/task-spec.d.ts +12 -1
- package/dist/core/terminal-cause.d.ts +10 -0
- package/dist/core/tool-check-reading.d.ts +1 -0
- package/dist/core/tool-check-reading.js +3 -3
- package/dist/core/tool-policy.d.ts +16 -0
- package/dist/core/tool-roster.d.ts +112 -5
- package/dist/core/tool-roster.js +42 -1
- package/dist/core/tool-spec.d.ts +3 -1
- package/dist/core/types.d.ts +2 -2
- package/dist/core/types.js +1 -1
- package/dist/core/user-attachment.js +1 -1
- package/dist/core/wiring-manifest.d.ts +6 -3
- package/dist/engine/compaction/compaction.js +29 -3
- package/dist/engine/execution-env/node-execution-env.d.ts +4 -3
- package/dist/engine/execution-env/node-execution-env.js +9 -12
- package/dist/engine/harness/agent-harness.d.ts +25 -2
- package/dist/engine/harness/agent-harness.js +41 -12
- package/dist/engine/harness/messages.d.ts +3 -1
- package/dist/engine/harness/messages.js +3 -2
- package/dist/engine/harness/types.d.ts +8 -0
- package/dist/engine/llm/rejected-images.d.ts +46 -0
- package/dist/engine/llm/rejected-images.js +54 -0
- package/dist/engine/llm/tool-turns.d.ts +2 -1
- package/dist/engine/llm/types.d.ts +18 -7
- package/dist/engine/loop/agent-loop.d.ts +8 -0
- package/dist/engine/loop/agent-loop.js +52 -15
- package/dist/engine/loop/types.d.ts +3 -1
- package/dist/engine/session/path-to-root.d.ts +38 -0
- package/dist/engine/session/path-to-root.js +39 -0
- package/dist/engine/session/storage-base.js +4 -21
- package/dist/index.d.ts +16 -10
- package/dist/index.js +11 -7
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +1 -0
- package/dist/internal/llm.d.ts +1 -0
- package/dist/orchestration/workflow-observe.d.ts +17 -1
- package/dist/orchestration/workflow-observe.js +20 -0
- package/dist/orchestration/workflow-types.d.ts +32 -7
- package/dist/orchestration/workflow.js +739 -489
- package/dist/shell/counting-pass.d.ts +50 -0
- package/dist/shell/counting-pass.js +502 -0
- package/dist/shell/lex.d.ts +4 -2
- package/dist/shell/lex.js +93 -34
- package/dist/shell/shell-words.d.ts +1 -1
- package/dist/shell/shell-words.js +7 -6
- package/dist/stores/file/mailbox-store.js +6 -10
- package/dist/tools/fs/fs-bash.d.ts +6 -0
- package/dist/tools/fs/fs-bash.js +6 -3
- package/dist/tools/fs/index.js +6 -2
- package/dist/tools/fs/program-read-model.d.ts +13 -0
- package/dist/tools/fs/program-read-model.js +15 -0
- package/dist/tools/fs/program-read-model.rows.js +1 -1
- package/dist/tools/fs/read-deny.d.ts +13 -10
- package/dist/tools/fs/read-deny.js +25 -5
- package/dist/tools/fs/read-floor.d.ts +19 -0
- package/dist/tools/fs/read-floor.js +23 -0
- package/dist/tools/fs/shell-read-check.d.ts +1 -1
- package/dist/tools/fs/shell-read-check.js +2 -1
- package/dist/tools/fs/shell-read-judge.d.ts +16 -8
- package/dist/tools/fs/shell-read-judge.js +10 -6
- package/dist/tools/fs/shell-read-plan.d.ts +6 -1
- package/dist/tools/fs/shell-read-plan.js +22 -15
- package/dist/tools/fs/shell-read-start.js +1 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +15 -1
- package/dist/tools/fs/shell-reentry-text.js +25 -3
- package/dist/tools/monitor.d.ts +4 -0
- package/dist/tools/monitor.js +2 -0
- package/package.json +3 -2
- package/test/export-surface.snapshot.json +87 -1
- package/wire-changes/core-stores-sql@7.59.0.json +29 -0
- package/wire-changes/core@7.59.0.json +2459 -0
- package/wire-changes/mods-kernel@7.59.0.json +29 -0
- package/wire-changes/primitives@7.59.0.json +29 -0
|
@@ -337,16 +337,35 @@ export function ignoreCaseFold(s) {
|
|
|
337
337
|
}
|
|
338
338
|
return out;
|
|
339
339
|
}
|
|
340
|
-
|
|
340
|
+
function composed(s) {
|
|
341
|
+
return /[^\x00-\x7f]/.test(s) ? s.normalize("NFC") : s;
|
|
342
|
+
}
|
|
343
|
+
export const SEGMENT_FOLDS = {
|
|
344
|
+
none: composed,
|
|
345
|
+
ascii: (s) => asciiLower(composed(s)),
|
|
346
|
+
unicode: (s) => ignoreCaseFold(composed(s)),
|
|
347
|
+
};
|
|
341
348
|
function foldSegments(fold, segs) {
|
|
342
349
|
return segs.map((s) => SEGMENT_FOLDS[fold](s));
|
|
343
350
|
}
|
|
351
|
+
const SPELLED_FOLDS = { none: (s) => s, ascii: asciiLower, unicode: ignoreCaseFold };
|
|
352
|
+
function readingsOfViews(fold, views) {
|
|
353
|
+
const out = [];
|
|
354
|
+
for (const segs of views) {
|
|
355
|
+
const twin = foldSegments(fold, segs);
|
|
356
|
+
out.push(twin);
|
|
357
|
+
const spelled = segs.map((s) => SPELLED_FOLDS[fold](s));
|
|
358
|
+
if (spelled.some((s, i) => s !== twin[i]))
|
|
359
|
+
out.push(spelled);
|
|
360
|
+
}
|
|
361
|
+
return out;
|
|
362
|
+
}
|
|
344
363
|
function foldedViewsOf(views) {
|
|
345
364
|
const memo = new Map();
|
|
346
365
|
return (fold) => {
|
|
347
366
|
let folded = memo.get(fold);
|
|
348
367
|
if (folded === undefined)
|
|
349
|
-
memo.set(fold, (folded =
|
|
368
|
+
memo.set(fold, (folded = readingsOfViews(fold, views)));
|
|
350
369
|
return folded;
|
|
351
370
|
};
|
|
352
371
|
}
|
|
@@ -376,12 +395,13 @@ function segmentReadingsOf(path, aliasResolved) {
|
|
|
376
395
|
const known = SEGMENT_READINGS.get(key);
|
|
377
396
|
if (known !== undefined)
|
|
378
397
|
return known;
|
|
379
|
-
const
|
|
398
|
+
const spelledViews = segmentViewsOf(path, aliasResolved ? { aliasResolved } : undefined);
|
|
399
|
+
const views = readingsOfViews("none", spelledViews);
|
|
380
400
|
let folded;
|
|
381
401
|
const readings = {
|
|
382
402
|
views,
|
|
383
|
-
lowered:
|
|
384
|
-
folded: () => (folded ??=
|
|
403
|
+
lowered: readingsOfViews("ascii", spelledViews),
|
|
404
|
+
folded: () => (folded ??= readingsOfViews("unicode", spelledViews)),
|
|
385
405
|
rooted: isAbsoluteForFamily("own", path),
|
|
386
406
|
};
|
|
387
407
|
if (SEGMENT_READINGS.size >= 512)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The byte floor's one adapter: the read-deny table a call judges with, as the {@link ReadFloor} its command
|
|
3
|
+
* start carries to the environment the command runs in.
|
|
4
|
+
*
|
|
5
|
+
* One table, two readers. The shell read station judges what a command NAMES (its operands, its expansions, a
|
|
6
|
+
* recursive read's root — never the tree below a root, the zero-friction reading); the environment judges what a process
|
|
7
|
+
* OPENS. Both read the same rows through the same judgment: this module derives nothing — the rows are the ones the
|
|
8
|
+
* engine's refusals cite (`readDenySeat`) and the judgment is the table's own `matchPath`, read off the table the call
|
|
9
|
+
* is pinned to (`seatForCall`). A floor never loosens the station: what the station refuses never starts.
|
|
10
|
+
*/
|
|
11
|
+
import type { ReadFloor } from "../../internal/harness-types.js";
|
|
12
|
+
import { type ReadDenyMatcher } from "./read-deny.js";
|
|
13
|
+
/** The floor ONE call's command start carries, read off the table that call judges with — `undefined` when the table
|
|
14
|
+
* holds no row (an empty table keeps nothing, and the start then carries no floor: the options are the ones a start
|
|
15
|
+
* took before the floor existed). */
|
|
16
|
+
export type ReadFloorSeat = (toolCallId: string | undefined) => ReadFloor | undefined;
|
|
17
|
+
/** The seat over a face's deny table (the run's, or a library-direct band's own); `undefined` for no table. Built once per
|
|
18
|
+
* mount; each call reads its own pinned table through it. */
|
|
19
|
+
export declare function readFloorSeat(table: ReadDenyMatcher | undefined): ReadFloorSeat | undefined;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { readDenySeat, seatForCall } from "./read-deny.js";
|
|
2
|
+
import { isAbsoluteForFamily } from "./safety.js";
|
|
3
|
+
export function readFloorSeat(table) {
|
|
4
|
+
if (table === undefined)
|
|
5
|
+
return undefined;
|
|
6
|
+
return (toolCallId) => readFloorOf(seatForCall(table, toolCallId));
|
|
7
|
+
}
|
|
8
|
+
function readFloorOf(table) {
|
|
9
|
+
const rows = Object.freeze([...readDenySeat(table).denyEntries]);
|
|
10
|
+
if (rows.length === 0)
|
|
11
|
+
return undefined;
|
|
12
|
+
const denies = (absolutePath) => {
|
|
13
|
+
if (typeof absolutePath !== "string" || !isAbsoluteForFamily("own", absolutePath))
|
|
14
|
+
return rows[0];
|
|
15
|
+
try {
|
|
16
|
+
return table.matchPath(absolutePath)?.pattern ?? null;
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
return rows[0];
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
return Object.freeze({ rows, denies });
|
|
23
|
+
}
|
|
@@ -261,7 +261,7 @@ export interface ShellReadJudgment {
|
|
|
261
261
|
* holding a command, an environment and a boundary gets the decision the gate would reach for them.
|
|
262
262
|
*
|
|
263
263
|
* An ENVIRONMENT question, not a text question: a symlink that leaves the roots, a pattern that expands
|
|
264
|
-
* onto a deny row, a traversal root that
|
|
264
|
+
* onto a deny row, a traversal root that lands elsewhere than it is spelled are answered by `env`, not guessed from the
|
|
265
265
|
* spelling. {@link judgeShellReadLexically} is the no-environment reading and not a substitute — it is
|
|
266
266
|
* LAXER where only a filesystem sees the escape (an in-root symlink pointing out vouches) and answers a
|
|
267
267
|
* pattern on its spelling alone, so the two diverge in both directions.
|
|
@@ -350,7 +350,7 @@ function judgePlan(plan, established, boundary) {
|
|
|
350
350
|
return judgeEstablishedPlan(plan, established.reads, boundary, (n) => {
|
|
351
351
|
const nested = established.nested.get(n);
|
|
352
352
|
return nested === undefined ? { plan: n, segments: [], guards: stationGuards(boundary), writeGuards: writeFaceGuards(boundary) } : judgePlan(n, nested, boundary);
|
|
353
|
-
});
|
|
353
|
+
}, (n) => judgePlan(n, establishShellReadsLexically(n, boundary), boundary));
|
|
354
354
|
}
|
|
355
355
|
async function applyAlsoInside(judged, boundary) {
|
|
356
356
|
const alsoInside = boundary.alsoInside;
|
|
@@ -375,6 +375,7 @@ async function applyAlsoInside(judged, boundary) {
|
|
|
375
375
|
segment: s.segment,
|
|
376
376
|
findings: s.findings.map((f) => (outsideRead(f) && rescued.has(f.read.target) ? { ...f, kind: "none", containment: "inside" } : f)),
|
|
377
377
|
nested: s.nested.map(rewrite),
|
|
378
|
+
printed: s.printed,
|
|
378
379
|
})),
|
|
379
380
|
});
|
|
380
381
|
return rewrite(judged);
|
|
@@ -231,7 +231,7 @@ export interface ShellReadBoundary extends BashReadonlyRootBoundary {
|
|
|
231
231
|
}
|
|
232
232
|
/** How far one candidate got before it was judged. `lexical` = the folded spelling is the judged target
|
|
233
233
|
* (an isolated sandbox, or a resolver that declares no authority and did not answer); `canonical` = the
|
|
234
|
-
* environment resolved it; `expansion` = one path a pattern expanded to
|
|
234
|
+
* environment resolved it; `expansion` = one path a pattern expanded to (a traversal root is never listed below);
|
|
235
235
|
* `unestablishable` = the floor could not say where it lands (`cause` says why). */
|
|
236
236
|
export type ReadEstablishment = "lexical" | "canonical" | "expansion" | "unestablishable";
|
|
237
237
|
export interface EstablishedRead {
|
|
@@ -293,11 +293,14 @@ export interface ReadFinding {
|
|
|
293
293
|
* @contract shell.read_boundary.friction_floor — what this judge answers is a question about TEXT and the
|
|
294
294
|
* FILESYSTEM the command will run in: which files the words of a command may name, resolved against the
|
|
295
295
|
* declared roots, the declared home and the observed working directory, and — where the environment can
|
|
296
|
-
* answer — where those spellings really land (symlinks resolved, patterns expanded
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
296
|
+
* answer — where those spellings really land (symlinks resolved, patterns expanded within a bound). A
|
|
297
|
+
* recursive read's root is one of those words: it is judged by what the command NAMES (the root itself and the
|
|
298
|
+
* placed rows the root contains), never by a tree walked below it. It is not a question about what the
|
|
299
|
+
* process will open. A deployment's containment for what a shell may reach is the `ExecutionEnv` the
|
|
300
|
+
* command runs in (a sandbox, a container, a remote adapter); everything here is the friction floor under
|
|
301
|
+
* that containment, and the read-deny table this station judges with travels to that environment on every
|
|
302
|
+
* command start as `readFloor` (an environment that confines processes keeps it or refuses the start). Under
|
|
303
|
+
* an isolated sandbox the floor is lexical (the sandbox is the boundary and its filesystem is not this
|
|
301
304
|
* process's to resolve). A deny-listed read is REFUSED on every seat; an out-of-root read asks where a
|
|
302
305
|
* person can be asked and is refused where none can; a read the floor cannot establish (an expansion it
|
|
303
306
|
* cannot finish, a spelling the shell rewrites, a working directory it cannot place) is asked or refused
|
|
@@ -330,6 +333,10 @@ export interface JudgedSegment {
|
|
|
330
333
|
readonly segment: ShellReadSegment;
|
|
331
334
|
readonly findings: readonly ReadFinding[];
|
|
332
335
|
readonly nested: readonly JudgedPlan[];
|
|
336
|
+
/** What a literal printer says the segment's shell is fed ({@link ShellReadSegment.printed}), judged on its spelling alone
|
|
337
|
+
* (no environment is asked about a text that may not run): the fold reads its deny hits and nothing else; no other reader
|
|
338
|
+
* of a judged plan reads it. */
|
|
339
|
+
readonly printed: readonly JudgedPlan[];
|
|
333
340
|
}
|
|
334
341
|
export interface JudgedPlan {
|
|
335
342
|
readonly plan: ShellReadPlan;
|
|
@@ -393,11 +400,12 @@ export interface ShellReadFold {
|
|
|
393
400
|
* only RAISE that: the nested text's deny-relation answers count — a deny hit (a refusal is a refusal whatever
|
|
394
401
|
* runs it) and a root that may hold a row no home places — its containment and its other silence do not (an inner
|
|
395
402
|
* `cat inside.txt` vouches nothing about the outer text). A substitution body (`$(…)`, a backtick, `<(…)`) is nested
|
|
396
|
-
* WITHOUT re-entry and folds in full.
|
|
403
|
+
* WITHOUT re-entry and folds in full. What a literal printer says the shell is fed ({@link JudgedSegment.printed}) is a
|
|
404
|
+
* text that may not run at all: its deny HITS count, and nothing else it finds or fails to find does.
|
|
397
405
|
*/
|
|
398
406
|
export declare function foldShellReadFindings(judged: JudgedPlan): ShellReadFold;
|
|
399
407
|
/** Judge every established read of a plan, in place. `establish` runs per segment so a caller can bound it. */
|
|
400
|
-
export declare function judgeEstablishedPlan(plan: ShellReadPlan, established: ReadonlyMap<ShellReadSegment, readonly EstablishedRead[]>, boundary: ShellReadBoundary, nestedOf: (plan: ShellReadPlan) => JudgedPlan): JudgedPlan;
|
|
408
|
+
export declare function judgeEstablishedPlan(plan: ShellReadPlan, established: ReadonlyMap<ShellReadSegment, readonly EstablishedRead[]>, boundary: ShellReadBoundary, nestedOf: (plan: ShellReadPlan) => JudgedPlan, printedOf: (plan: ShellReadPlan) => JudgedPlan): JudgedPlan;
|
|
401
409
|
/** Every finding of a judged plan, flattened (segments and nested plans alike). */
|
|
402
410
|
export declare function allFindings(judged: JudgedPlan): ReadFinding[];
|
|
403
411
|
/** One lexical step up, family-aware. A family ROOT is its own parent — the fixpoint the climb below ends
|
|
@@ -146,12 +146,13 @@ export function foldShellReadFindings(judged) {
|
|
|
146
146
|
if (rank > 0 || (rank === 0 && next.witness?.read.candidate.face === "write" && best.witness?.read.candidate.face !== "write"))
|
|
147
147
|
best = next;
|
|
148
148
|
};
|
|
149
|
-
const walk = (j,
|
|
149
|
+
const walk = (j, reading) => {
|
|
150
|
+
const denyOnly = reading !== "full";
|
|
150
151
|
if (j.plan.unreadable !== undefined && !denyOnly)
|
|
151
152
|
raise({ finding: "unestablishable" });
|
|
152
153
|
for (const s of j.segments) {
|
|
153
154
|
for (const f of s.findings) {
|
|
154
|
-
if (denyOnly && f.kind !== "deny_hit" && f.kind !== "unanswered")
|
|
155
|
+
if (denyOnly && f.kind !== "deny_hit" && (reading === "deny-hit" || f.kind !== "unanswered"))
|
|
155
156
|
continue;
|
|
156
157
|
if (f.kind !== "none")
|
|
157
158
|
raise({ finding: f.kind, witness: f });
|
|
@@ -169,12 +170,13 @@ export function foldShellReadFindings(judged) {
|
|
|
169
170
|
if (move !== undefined && (typeof move.target === "string" || move.target.expands !== false))
|
|
170
171
|
raise({ finding: "unestablishable", declined: s.segment });
|
|
171
172
|
}
|
|
172
|
-
const nestedDenyOnly = denyOnly || s.segment.reentry === "shell";
|
|
173
173
|
for (const n of s.nested)
|
|
174
|
-
walk(n,
|
|
174
|
+
walk(n, reading === "full" && s.segment.reentry !== "shell" ? "full" : reading === "deny-hit" ? "deny-hit" : "deny-relation");
|
|
175
|
+
for (const n of s.printed)
|
|
176
|
+
walk(n, "deny-hit");
|
|
175
177
|
}
|
|
176
178
|
};
|
|
177
|
-
walk(judged,
|
|
179
|
+
walk(judged, "full");
|
|
178
180
|
const unfinished = judged.incomplete?.[0];
|
|
179
181
|
if (unfinished !== undefined && (judged.guards || judged.writeGuards) && SHELL_READ_FINDING_RANK.unanswered > SHELL_READ_FINDING_RANK[best.finding]) {
|
|
180
182
|
unestablished = true;
|
|
@@ -182,13 +184,14 @@ export function foldShellReadFindings(judged) {
|
|
|
182
184
|
}
|
|
183
185
|
return { ...best, ...(unestablished ? { unestablished: true } : {}), ...(unplacedRead ? { unplacedRead: true } : {}), ...(unestablished && reentered.length > 0 ? { reentered } : {}) };
|
|
184
186
|
}
|
|
185
|
-
export function judgeEstablishedPlan(plan, established, boundary, nestedOf) {
|
|
187
|
+
export function judgeEstablishedPlan(plan, established, boundary, nestedOf, printedOf) {
|
|
186
188
|
return {
|
|
187
189
|
plan,
|
|
188
190
|
segments: plan.segments.map((segment) => ({
|
|
189
191
|
segment,
|
|
190
192
|
findings: (established.get(segment) ?? []).map((r) => judgeRead(r, boundary)),
|
|
191
193
|
nested: segment.nested.map(nestedOf),
|
|
194
|
+
printed: (segment.printed ?? []).map(printedOf),
|
|
192
195
|
})),
|
|
193
196
|
guards: stationGuards(boundary),
|
|
194
197
|
writeGuards: writeFaceGuards(boundary),
|
|
@@ -273,6 +276,7 @@ export function rejudge(judged, boundary) {
|
|
|
273
276
|
segment: s.segment,
|
|
274
277
|
findings: s.findings.map((f) => judgeRead(f.read, boundary)),
|
|
275
278
|
nested: s.nested.map((n) => rejudge(n, boundary)),
|
|
279
|
+
printed: s.printed.map((n) => rejudge(n, boundary)),
|
|
276
280
|
})),
|
|
277
281
|
guards: stationGuards(boundary),
|
|
278
282
|
writeGuards: writeFaceGuards(boundary),
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
* · an INTERPRETER's inline program is a shape fact (`reentry:"interpreter"`), never parsed, never a finding;
|
|
23
23
|
* · `<` targets are read candidates, `>`-family targets are write targets (tagged, not read), here-documents
|
|
24
24
|
* and here-strings are data (an UNQUOTED here-document body's substitutions are nested plans) — except to a shell
|
|
25
|
-
* whose argv names no script: what arrives on its standard input is its script, a nested plan where the text spells it
|
|
25
|
+
* whose argv names no script: what arrives on its standard input is its script, a nested plan where the text spells it,
|
|
26
|
+
* a `printed` plan where a literal printer producing it does (`printed`: never what runs — only its deny hits count);
|
|
26
27
|
* · `$(…)`, backticks and `<(…)` bodies are nested plans; a word carrying one cannot be resolved from the text;
|
|
27
28
|
* · the working-directory thread (`shell-read-workdir.ts`) moves the base the LATER segments resolve against, as a
|
|
28
29
|
* candidate SET (`&&` proves a move, nothing else does), and gives `PWD` / `OLDPWD` their values; a loop body with
|
|
@@ -136,6 +137,10 @@ export interface ShellReadSegment {
|
|
|
136
137
|
readonly bases: readonly string[] | "unmodelled";
|
|
137
138
|
/** Substitution bodies, unquoted here-document substitutions, and re-entered shell text, each its own plan. */
|
|
138
139
|
readonly nested: readonly ShellReadPlan[];
|
|
140
|
+
/** Texts a literal printer's words say this segment's shell is fed (a pipe's producer, the body of a `<(…)` script file or
|
|
141
|
+
* of a `< <(…)` input), each its own plan — never a text known to run, so no reader of what runs (`nested`) reads them: the
|
|
142
|
+
* read station judges them on their spelling, and only a deny hit among them counts (it refuses the call). */
|
|
143
|
+
readonly printed?: readonly ShellReadPlan[];
|
|
139
144
|
readonly reach: SegmentReach;
|
|
140
145
|
/** The names a change that can reach this segment touched (`BindingTable.rebound`): any other name still holds what the
|
|
141
146
|
* shell provides here. `all`: any name may have changed. */
|
|
@@ -8,7 +8,7 @@ import { POLL_LOOP_MAX_BEATS, attachedOptionPayloads, resolveOperandLexically, i
|
|
|
8
8
|
import { BLOCK_WORD_NAMES, commandLineOf, commandLineOptionSpellings, declaredAttributes, isDeclarationBuiltin, isInertBuiltin, launcherOptionPathRole, launcherOptionStep, readOptionRole, programLanguageOf, programTextOpensOf, selectedOptions, movesBaseByStack, opensNoOperand, programDelivery, programRow, readArgRoles, runsShellText, } from "./program-read-model.js";
|
|
9
9
|
import { shellWordsOf } from "../../shell/shell-words.js";
|
|
10
10
|
import { isAbsoluteForFamily } from "./safety.js";
|
|
11
|
-
import { codeBodies, launchedInput, reentersShell, reentryText, scriptFileAt, stdinTextsOf } from "./shell-reentry-text.js";
|
|
11
|
+
import { codeBodies, launchedInput, pipedTextOf, printedByProcess, reentersShell, reentryText, scriptFileAt, stdinTextsOf } from "./shell-reentry-text.js";
|
|
12
12
|
import { heldAt, plannedOnce, rebasePlan, startedAt, stdinFeeds } from "./shell-read-start.js";
|
|
13
13
|
import { markStandardDevices } from "./shell-read-device.js";
|
|
14
14
|
export const READ_CANDIDATE_PROVENANCES = Object.freeze([
|
|
@@ -68,7 +68,7 @@ function planText(command, decl, depth, start, from) {
|
|
|
68
68
|
const empty = lexed.segments.map((segment, si) => segmentIsEmpty(segment, projected[si]));
|
|
69
69
|
const facts = projected.map(() => undefined);
|
|
70
70
|
const tables = projected.map(() => undefined);
|
|
71
|
-
const fedAt = stdinFeeds(lexed.segments, start?.stdin ?? [], (si) => [
|
|
71
|
+
const fedAt = stdinFeeds(lexed.segments, start?.stdin ?? [], (si) => [pipedTextOf(lexed.segments[si - 1])]);
|
|
72
72
|
const inheritedFns = new Set([...(start?.exportedFunctions ?? [])].flatMap(([name, body]) => (body === "unread" ? [name] : [])));
|
|
73
73
|
const factsAt = (si, table) => {
|
|
74
74
|
tables[si] ??= table;
|
|
@@ -202,6 +202,7 @@ function planText(command, decl, depth, start, from) {
|
|
|
202
202
|
const moved = readProgramPosition(f.argv).launcherMovesBase;
|
|
203
203
|
const programPlaced = moved ? placedAt("unmodelled", bases !== "unmodelled" ? bases : floor) : withBases;
|
|
204
204
|
const programRead = (c) => (c.provenance === "stdin_redirect" ? withBases(c) : programPlaced(c));
|
|
205
|
+
const placeNested = (n) => (f.elsewhere?.has(n) === true ? n : rebasePlan(n, decl.cwd, moved && f.shellSide?.has(n) !== true ? "unmodelled" : bases, bases === "unmodelled" ? floor : bases));
|
|
205
206
|
segments.push({
|
|
206
207
|
text: f.text,
|
|
207
208
|
connector: f.connector,
|
|
@@ -216,7 +217,8 @@ function planText(command, decl, depth, start, from) {
|
|
|
216
217
|
redirects: f.redirects.map((r) => ({ op: r.op, direction: r.direction, ...(r.fd !== undefined ? { fd: r.fd } : {}), ...(r.target !== undefined ? { target: withBases(r.target) } : {}) })),
|
|
217
218
|
...(move !== undefined ? { baseMove: { target: typeof move.target === "string" ? move.target : withBases(move.target) } } : {}),
|
|
218
219
|
bases,
|
|
219
|
-
nested: f.nested.map(
|
|
220
|
+
nested: f.nested.map(placeNested),
|
|
221
|
+
...(f.printed.length > 0 ? { printed: f.printed.map(placeNested) } : {}),
|
|
220
222
|
reach: reaches[si] ?? { andJoined: false, orBroken: false, moveProvable: false },
|
|
221
223
|
rebound: tables[si]?.rebound ?? "all",
|
|
222
224
|
});
|
|
@@ -310,6 +312,7 @@ function readingFacts(segment, p, decl, reading, nestedPlan, fed, inheritedFns =
|
|
|
310
312
|
}
|
|
311
313
|
function segmentFactsRead(segment, p, decl, table, nestedPlan, fed, toks, inheritedFns = new Set()) {
|
|
312
314
|
const nested = [];
|
|
315
|
+
const printed = [];
|
|
313
316
|
const elsewhere = new Set();
|
|
314
317
|
const ctx = { table, reentered: [], programTextSeen: false };
|
|
315
318
|
const enclosedToo = (e) => [e, ...(e.inner ?? []).flatMap(enclosedToo)];
|
|
@@ -356,6 +359,7 @@ function segmentFactsRead(segment, p, decl, table, nestedPlan, fed, toks, inheri
|
|
|
356
359
|
argv: p.argv,
|
|
357
360
|
redirects,
|
|
358
361
|
nested,
|
|
362
|
+
printed,
|
|
359
363
|
};
|
|
360
364
|
const done = (f) => {
|
|
361
365
|
const reentered = [...new Set(ctx.reentered)];
|
|
@@ -488,8 +492,10 @@ function segmentFactsRead(segment, p, decl, table, nestedPlan, fed, toks, inheri
|
|
|
488
492
|
const reenterShell = (verb, argvs) => {
|
|
489
493
|
const stdin = stdinTextsOf(segment, fed);
|
|
490
494
|
const scripts = new Map();
|
|
491
|
-
const
|
|
492
|
-
|
|
495
|
+
const prints = new Map();
|
|
496
|
+
const into = (to) => (text, at) => { if (text !== undefined)
|
|
497
|
+
to.set(JSON.stringify([text, at]), { ...at, text }); };
|
|
498
|
+
const script = into(scripts), print = into(prints);
|
|
493
499
|
for (const { shell, texts: t, args: a, as } of argvs) {
|
|
494
500
|
const user = as !== undefined ? { as } : {};
|
|
495
501
|
const argvText = [reentryText(shell, t), reentryText(shell, a)];
|
|
@@ -497,20 +503,21 @@ function segmentFactsRead(segment, p, decl, table, nestedPlan, fed, toks, inheri
|
|
|
497
503
|
script(text, { ...user, ...(stdin.length > 0 ? { stdin } : {}) });
|
|
498
504
|
if (argvText.every((text) => text === undefined))
|
|
499
505
|
for (const s of stdin)
|
|
500
|
-
|
|
501
|
-
script(reentryText(shell, t, s.literal), user);
|
|
506
|
+
void (s.literal !== undefined && script(reentryText(shell, t, s.literal), user), s.printed !== undefined && print(reentryText(shell, t, s.printed), user));
|
|
502
507
|
}
|
|
503
|
-
for (const {
|
|
504
|
-
const plan = nestedPlan(text, "now", at);
|
|
505
|
-
nested.push(plan);
|
|
506
|
-
if (at.as?.login === true)
|
|
507
|
-
elsewhere.add(plan);
|
|
508
|
-
}
|
|
509
|
-
for (const { shell, args: a, words } of argvs) {
|
|
508
|
+
for (const { shell, args: a, words, as } of argvs) {
|
|
510
509
|
const at = shell === "source" || shell === "." ? a.findIndex((w) => !w.startsWith("-") || w === "-") : scriptFileAt(shell, a);
|
|
511
510
|
const file = at === undefined ? undefined : words[at];
|
|
512
511
|
if (file !== undefined)
|
|
513
|
-
reads.push(bare(file, "operand"));
|
|
512
|
+
void (reads.push(bare(file, "operand")), print(printedByProcess(file.word), as !== undefined ? { as } : {}));
|
|
513
|
+
}
|
|
514
|
+
for (const [to, plans] of [[scripts, nested], [prints, printed]]) {
|
|
515
|
+
for (const { text, ...at } of to.values()) {
|
|
516
|
+
const plan = nestedPlan(text, "now", at);
|
|
517
|
+
plans.push(plan);
|
|
518
|
+
if (at.as?.login === true)
|
|
519
|
+
elsewhere.add(plan);
|
|
520
|
+
}
|
|
514
521
|
}
|
|
515
522
|
return done({ empty: false, launcherChain, verb, reentry: "shell", declines, reads, moveProvable: false, ...(loopHead !== undefined ? { loopHead } : {}), ...(stdin.length > 0 ? { stdin } : {}), ...(shift !== undefined ? { shift } : {}) });
|
|
516
523
|
};
|
|
@@ -94,6 +94,7 @@ export function rebasePlan(plan, from, to, floor) {
|
|
|
94
94
|
...(s.baseMove !== undefined ? { baseMove: { target: typeof s.baseMove.target === "string" ? s.baseMove.target : moveCandidate(s.baseMove.target) } } : {}),
|
|
95
95
|
bases: s.bases === "unmodelled" || to === "unmodelled" ? "unmodelled" : [...new Set(s.bases.flatMap(moveBase))],
|
|
96
96
|
nested: s.nested.map((n) => rebasePlan(n, from, to, floor)),
|
|
97
|
+
...(s.printed !== undefined ? { printed: s.printed.map((n) => rebasePlan(n, from, to, floor)) } : {}),
|
|
97
98
|
})),
|
|
98
99
|
};
|
|
99
100
|
}
|
|
@@ -136,11 +136,25 @@ export declare function spellLaunched(argv: readonly LexedWord[], args: readonly
|
|
|
136
136
|
export declare function scriptFileAt(basename: string, args: readonly string[]): number | undefined;
|
|
137
137
|
/** One text that may arrive on a segment's standard input: `from` = its source as written (a here-document's body,
|
|
138
138
|
* `<<<WORD`, `<FILE`, `<&N`, the segment the pipe comes from); `literal` = the text, where the command spells it — a
|
|
139
|
-
* here-document or here-string written in the command; never a pipe's text, which a program PRODUCES.
|
|
139
|
+
* here-document or here-string written in the command; never a pipe's text, which a program PRODUCES. `printed` = the
|
|
140
|
+
* text a literal printer producing it spells ({@link printedBy}: the pipe's producer, the body of a `< <(…)`) — what the
|
|
141
|
+
* printer's words say it prints, never what the shell is known to receive: read only for what it refuses. */
|
|
140
142
|
export interface StdinText {
|
|
141
143
|
readonly from: string;
|
|
142
144
|
readonly literal?: string;
|
|
145
|
+
readonly printed?: string;
|
|
143
146
|
}
|
|
147
|
+
/** The text a producer's words say it prints ({@link printedText}): one simple command — no redirection, here-document or
|
|
148
|
+
* group — whose program word and every argument are literal, run by a printer row. `undefined` for any other producer. The
|
|
149
|
+
* reading is no claim about the stream (a function, an alias or a trap of the printer's name, a second writer on it are not
|
|
150
|
+
* read): its one reader refuses by it and never clears by it (`ShellReadSegment.printed`). */
|
|
151
|
+
export declare function printedBy(segment: LexedSegment): string | undefined;
|
|
152
|
+
/** What a pipe hands the segment after it: the producing segment as written, and the text it spells where it is a literal
|
|
153
|
+
* printer ({@link printedBy}). */
|
|
154
|
+
export declare function pipedTextOf(producer: LexedSegment): StdinText;
|
|
155
|
+
/** The text a word that is one process substitution prints, where its body is one literal printer ({@link printedBy}):
|
|
156
|
+
* `<(printf 'X')` — a script file a shell is handed, or the file its standard input is redirected from. */
|
|
157
|
+
export declare function printedByProcess(word: LexedWord): string | undefined;
|
|
144
158
|
/** What may arrive on a segment's standard input: each here-document (its descriptor is not read: every one counts) —
|
|
145
159
|
* its body, literal when quoted or when nothing in it expands — each here-string (literal when its word is), `<` file
|
|
146
160
|
* or `<&` descriptor written to no other descriptor, and what it inherits (`fed`: the pipe it is reached through, the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { literalHeredocBody, literalTextOf } from "../../shell/lex.js";
|
|
1
|
+
import { lexShell, literalHeredocBody, literalTextOf } from "../../shell/lex.js";
|
|
2
2
|
import { programBasename, readProgramPosition } from "./bash-program-position.js";
|
|
3
|
-
import { implementationRejects, implementationsOf, programRow, readArgRoles, selectedOptions, selectedSpellings, targetUserOf } from "./program-read-model.js";
|
|
3
|
+
import { implementationRejects, implementationsOf, printedText, programRow, readArgRoles, selectedOptions, selectedSpellings, targetUserOf } from "./program-read-model.js";
|
|
4
4
|
import { namesStandardInput } from "./safety.js";
|
|
5
5
|
export function codeBodies(basename, args) {
|
|
6
6
|
const row = programRow(basename);
|
|
@@ -240,6 +240,27 @@ function scriptSourceOf(row, args) {
|
|
|
240
240
|
return { stdin: true };
|
|
241
241
|
return { file: first.at, stdin: options.some((e) => e.kind === "option" && e.reading === "speculative") };
|
|
242
242
|
}
|
|
243
|
+
export function printedBy(segment) {
|
|
244
|
+
if (segment.tokens.some((t) => t.kind !== "word"))
|
|
245
|
+
return undefined;
|
|
246
|
+
const argv = segment.tokens.filter((t) => t.kind === "word");
|
|
247
|
+
const pos = readProgramPosition(argv);
|
|
248
|
+
const program = pos.program;
|
|
249
|
+
if (program === undefined || pos.refusal !== undefined || pos.launchers.length > 0 || literalTextOf(argv[program.index].pieces) === undefined)
|
|
250
|
+
return undefined;
|
|
251
|
+
return printedText(programRow(program.basename), argv.slice(program.index + 1).map((w) => literalTextOf(w.pieces)));
|
|
252
|
+
}
|
|
253
|
+
export function pipedTextOf(producer) {
|
|
254
|
+
const printed = printedBy(producer);
|
|
255
|
+
return { from: `${producer.text.trim()} |`, ...(printed !== undefined ? { printed } : {}) };
|
|
256
|
+
}
|
|
257
|
+
export function printedByProcess(word) {
|
|
258
|
+
const e = word.pieces.length === 1 ? word.pieces[0].expansion : undefined;
|
|
259
|
+
if (e?.kind !== "process" || e.body === undefined || !word.raw.startsWith("<("))
|
|
260
|
+
return undefined;
|
|
261
|
+
const lexed = lexShell(e.body);
|
|
262
|
+
return "parseFailure" in lexed || lexed.segments.length !== 1 ? undefined : printedBy(lexed.segments[0]);
|
|
263
|
+
}
|
|
243
264
|
export function stdinTextsOf(segment, fed) {
|
|
244
265
|
const out = [];
|
|
245
266
|
let replacesPipe = false;
|
|
@@ -250,7 +271,8 @@ export function stdinTextsOf(segment, fed) {
|
|
|
250
271
|
}
|
|
251
272
|
else if (t.kind === "redirect" && (t.fd ?? 0) === 0 && (t.op === "<<<" || t.op === "<" || t.op === "<>" || (t.op === "<&" && t.dup !== "-"))) {
|
|
252
273
|
const literal = t.op === "<<<" && t.target !== undefined ? literalTextOf(t.target.pieces) : undefined;
|
|
253
|
-
|
|
274
|
+
const printed = t.op === "<" && t.target !== undefined ? printedByProcess(t.target) : undefined;
|
|
275
|
+
out.push({ from: `${t.op}${t.target?.raw ?? t.dup ?? ""}`, ...(literal !== undefined ? { literal } : {}), ...(printed !== undefined ? { printed } : {}) });
|
|
254
276
|
replacesPipe = true;
|
|
255
277
|
}
|
|
256
278
|
}
|
package/dist/tools/monitor.d.ts
CHANGED
|
@@ -43,6 +43,7 @@ import { type MonitorTimers, type TaskRegistry } from "../core/task-registry.js"
|
|
|
43
43
|
import type { TaskNotificationPayload } from "../core/task-notification.js";
|
|
44
44
|
import type { ToolResultStore } from "../core/tool-result-store.js";
|
|
45
45
|
import type { ShellReadAdmission } from "./fs/shell-read-check.js";
|
|
46
|
+
import type { ReadFloorSeat } from "./fs/read-floor.js";
|
|
46
47
|
export interface MonitorToolOptions {
|
|
47
48
|
registry: TaskRegistry;
|
|
48
49
|
/** Fallbacks when the runtime ctx carries no identity (direct mounts) — same posture as createBashTool. */
|
|
@@ -73,6 +74,9 @@ export interface MonitorToolOptions {
|
|
|
73
74
|
* spawns a shell command too, so what it runs is what the station judged, re-established before the watch
|
|
74
75
|
* spawns. Absent ⇒ no station judged this mount; nothing is re-established. */
|
|
75
76
|
shellReadAdmission?: ShellReadAdmission;
|
|
77
|
+
/** The byte floor's seat (read-floor.ts) — the SAME table the shell faces carry: the watched command's start hands it to
|
|
78
|
+
* the environment. Absent ⇒ the start carries no floor. */
|
|
79
|
+
readFloor?: ReadFloorSeat;
|
|
76
80
|
/** RB-465-b (HRD-PTL-3 残件): spec-level retain (`TaskSpec.retainBackgroundProcesses`) — the task lane of
|
|
77
81
|
* THE retain predicate (`retainsBackgroundProcesses`), OR-composed with the env capability. Read twice,
|
|
78
82
|
* by the same predicate: the persistent-watch receipt's wording, and the row's `retained` mark at
|
package/dist/tools/monitor.js
CHANGED
|
@@ -79,9 +79,11 @@ export function createMonitorTool(env, opts) {
|
|
|
79
79
|
}
|
|
80
80
|
if (ctx.signal?.aborted === true)
|
|
81
81
|
return errorResult("Error (Monitor): the call was cancelled before the watch started.");
|
|
82
|
+
const readFloor = opts.readFloor?.(ctx.toolCallId);
|
|
82
83
|
const spawn = await env.spawnBackground(command, {
|
|
83
84
|
...(opts.cwdRef !== undefined ? { cwd: opts.cwdRef.current } : {}),
|
|
84
85
|
...(spawnTimeoutSec !== undefined ? { timeout: spawnTimeoutSec } : {}),
|
|
86
|
+
...(readFloor !== undefined ? { readFloor } : {}),
|
|
85
87
|
});
|
|
86
88
|
if (!spawn.ok)
|
|
87
89
|
return errorResult(`Error (Monitor): ${spawn.error.message}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sema-agent/core",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.59.0",
|
|
4
4
|
"description": "Stateless, task-oriented AI agent core",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "BUSL-1.1",
|
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
"pretest": "npm run gate:debts",
|
|
56
56
|
"test": "vitest run --exclude \"**/*.local.test.ts\"",
|
|
57
57
|
"test:watch": "vitest",
|
|
58
|
+
"test:affected": "node scripts/affected-tests.mjs",
|
|
58
59
|
"gate:skips": "vitest run --exclude \"**/node_modules/**\" --exclude \"**/*.local.test.ts\" --reporter=default --reporter=json --outputFile.json=.skip-report.json && node scripts/verify-skip-baseline.mjs --report .skip-report.json --full",
|
|
59
60
|
"gate:live": "node scripts/run-live-gate.mjs",
|
|
60
61
|
"smoke": "tsx src/examples/smoke.ts",
|
|
@@ -119,7 +120,7 @@
|
|
|
119
120
|
},
|
|
120
121
|
"dependencies": {
|
|
121
122
|
"@modelcontextprotocol/sdk": "1.30.0",
|
|
122
|
-
"@sema-agent/primitives": "7.
|
|
123
|
+
"@sema-agent/primitives": "7.59.0",
|
|
123
124
|
"typebox": "1.1.39",
|
|
124
125
|
"undici": "7.30.0"
|
|
125
126
|
},
|