@hassangameryt/freeflow 0.5.0 → 0.7.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +2 -2
- package/.codex-plugin/plugin.json +4 -5
- package/README.md +141 -163
- package/capabilities/cognitive-routing/SKILL.md +387 -0
- package/capabilities/context-virtualization/SKILL.md +103 -0
- package/capabilities/conversation-history/SKILL.md +53 -0
- package/command-surface.json +6 -37
- package/hooks/freeflow-runtime-context.mjs +50 -541
- package/hooks/hooks.json +1 -26
- package/hooks/tests/check-runtime-context-hook.sh +114 -308
- package/package.json +27 -17
- package/pi-extension/dist/cognitive-routing/commands.js +96 -0
- package/pi-extension/dist/cognitive-routing/config.js +232 -0
- package/pi-extension/dist/cognitive-routing/controller.js +1292 -0
- package/pi-extension/dist/cognitive-routing/history.js +451 -0
- package/pi-extension/dist/cognitive-routing/host.js +188 -0
- package/pi-extension/dist/cognitive-routing/pi-routing-session.js +414 -0
- package/pi-extension/dist/cognitive-routing/pi-session-control.js +320 -0
- package/pi-extension/dist/cognitive-routing/runtime.js +43 -0
- package/pi-extension/dist/cognitive-routing/tool.js +212 -0
- package/pi-extension/dist/cognitive-routing/types.js +6 -0
- package/pi-extension/dist/context-virtualization/commands.js +89 -0
- package/pi-extension/dist/context-virtualization/projector.js +42 -0
- package/pi-extension/dist/context-virtualization/runtime.js +356 -0
- package/pi-extension/dist/context-virtualization/state.js +57 -0
- package/pi-extension/dist/context-virtualization/types.js +10 -0
- package/pi-extension/dist/conversation-history/passages.js +66 -0
- package/pi-extension/dist/conversation-history/ranking.js +105 -0
- package/pi-extension/dist/conversation-history/runtime.js +226 -0
- package/pi-extension/dist/conversation-history/search.js +56 -0
- package/pi-extension/dist/conversation-history/types.js +1 -0
- package/pi-extension/dist/freeflow-context/resolver.js +120 -0
- package/pi-extension/dist/freeflow-context/runtime.js +80 -0
- package/pi-extension/dist/freeflow-context/source-projector.js +95 -0
- package/pi-extension/dist/freeflow-context/tool.js +308 -0
- package/pi-extension/dist/freeflow-context/types.js +12 -0
- package/pi-extension/dist/freeflow-context/visibility.js +28 -0
- package/pi-extension/dist/index.js +564 -129
- package/pi-extension/dist/runtime/runtime-context.js +357 -470
- package/pi-extension/dist/runtime/runtime-identity.js +5 -0
- package/pi-extension/dist/settings/settings-tui.js +78 -0
- package/pi-extension/dist/settings/settings-ui.js +572 -826
- package/pi-extension/dist/ui/text-component.js +57 -0
- package/pi-extension/src/cognitive-routing/commands.ts +129 -0
- package/pi-extension/src/cognitive-routing/config.ts +303 -0
- package/pi-extension/src/cognitive-routing/controller.ts +1628 -0
- package/pi-extension/src/cognitive-routing/history.ts +650 -0
- package/pi-extension/src/cognitive-routing/host.ts +266 -0
- package/pi-extension/src/cognitive-routing/pi-routing-session.ts +538 -0
- package/pi-extension/src/cognitive-routing/pi-session-control.ts +444 -0
- package/pi-extension/src/cognitive-routing/runtime.ts +57 -0
- package/pi-extension/src/cognitive-routing/tool.ts +273 -0
- package/pi-extension/src/cognitive-routing/types.ts +89 -0
- package/pi-extension/src/context-virtualization/commands.ts +111 -0
- package/pi-extension/src/context-virtualization/projector.ts +62 -0
- package/pi-extension/src/context-virtualization/runtime.ts +406 -0
- package/pi-extension/src/context-virtualization/state.ts +79 -0
- package/pi-extension/src/context-virtualization/types.ts +92 -0
- package/pi-extension/src/conversation-history/passages.ts +81 -0
- package/pi-extension/src/conversation-history/ranking.ts +155 -0
- package/pi-extension/src/conversation-history/runtime.ts +250 -0
- package/pi-extension/src/conversation-history/search.ts +79 -0
- package/pi-extension/src/conversation-history/types.ts +31 -0
- package/pi-extension/src/freeflow-context/resolver.ts +139 -0
- package/pi-extension/src/freeflow-context/runtime.ts +100 -0
- package/pi-extension/src/freeflow-context/source-projector.ts +106 -0
- package/pi-extension/src/freeflow-context/tool.ts +360 -0
- package/pi-extension/src/freeflow-context/types.ts +70 -0
- package/pi-extension/src/freeflow-context/visibility.ts +53 -0
- package/pi-extension/src/index.ts +597 -135
- package/pi-extension/src/runtime/runtime-context.ts +373 -491
- package/pi-extension/src/runtime/runtime-identity.ts +8 -0
- package/pi-extension/src/settings/settings-tui.ts +93 -0
- package/pi-extension/src/settings/settings-ui.ts +679 -910
- package/pi-extension/src/ui/text-component.ts +66 -0
- package/pi-extension/tests/cognitive-routing/commands.test.js +134 -0
- package/pi-extension/tests/cognitive-routing/controller.test.js +1128 -0
- package/pi-extension/tests/cognitive-routing/extension-lifecycle.test.js +1142 -0
- package/pi-extension/tests/cognitive-routing/history.test.js +274 -0
- package/pi-extension/tests/cognitive-routing/host-fixture.js +4 -0
- package/pi-extension/tests/cognitive-routing/host-identity.test.js +63 -0
- package/pi-extension/tests/cognitive-routing/pi-normal-lifecycle.test.js +434 -0
- package/pi-extension/tests/cognitive-routing/pi-session-control.test.js +174 -0
- package/pi-extension/tests/cognitive-routing/pi-session-history.test.js +91 -0
- package/pi-extension/tests/cognitive-routing/profile-resolution.test.js +279 -0
- package/pi-extension/tests/cognitive-routing/tool.test.js +230 -0
- package/pi-extension/tests/context-virtualization/extension.test.js +749 -0
- package/pi-extension/tests/context-virtualization/projector.test.js +110 -0
- package/pi-extension/tests/context-virtualization/runtime.test.js +216 -0
- package/pi-extension/tests/conversation-history/runtime.test.js +98 -0
- package/pi-extension/tests/conversation-history/search.test.js +97 -0
- package/pi-extension/tests/integration/mode-free-core.test.js +218 -0
- package/pi-extension/tests/integration/pi-extension.test.js +532 -3701
- package/pi-extension/tests/integration/prompt-architecture.test.js +350 -0
- package/pi-extension/tests/integration/unaffected-regressions.test.js +411 -0
- package/runtime/prompts/cognitive-routing.md +10 -0
- package/runtime/prompts/context-virtualization.md +3 -0
- package/runtime/prompts/conversation-history.md +3 -0
- package/runtime/prompts/core.md +84 -0
- package/runtime/prompts/interaction-contract.md +11 -0
- package/skills/action-selection/SKILL.md +140 -0
- package/skills/action-selection/references/trajectory-stalls.md +71 -0
- package/skills/bypass/SKILL.md +109 -38
- package/skills/commit-work/SKILL.md +94 -55
- package/skills/commit-work/references/git-state-edges.md +94 -0
- package/skills/commit-work/references/simple-push.md +92 -0
- package/skills/commit-work/references/staging-decisions.md +79 -46
- package/skills/decision-gate/SKILL.md +80 -22
- package/skills/design-for-depth/SKILL.md +206 -60
- package/skills/design-for-depth/references/design-pressure-signals.md +108 -240
- package/skills/design-for-depth/references/interface-design-loop.md +77 -97
- package/skills/design-for-depth/references/module-and-dependency-design.md +147 -0
- package/skills/design-for-depth/references/software-design-philosophy.md +128 -174
- package/skills/design-for-depth/references/state-and-failure-boundaries.md +136 -0
- package/skills/diagnose-failure/SKILL.md +200 -48
- package/skills/diagnose-failure/references/diagnostic-loop-catalog.md +18 -6
- package/skills/diagnose-failure/references/{flaky-and-performance.md → flaky-and-performance-diagnosis.md} +13 -5
- package/skills/discuss/SKILL.md +119 -65
- package/skills/discuss/references/discussion-continuity.md +123 -0
- package/skills/evaluate-skill/SKILL.md +166 -52
- package/skills/evaluate-skill/references/{definition-schema.md → evaluation-definition-schema.md} +43 -3
- package/skills/evaluate-skill/references/evaluation-design.md +56 -30
- package/skills/evaluate-skill/references/execution-and-evidence.md +8 -3
- package/skills/evaluate-skill/references/review-and-revision.md +62 -21
- package/skills/evaluate-skill/scripts/lib/definitions.mjs +114 -3
- package/skills/evaluate-skill/scripts/lib/grade-interaction.mjs +156 -1
- package/skills/evaluate-skill/scripts/lib/grade.mjs +9 -1
- package/skills/evaluate-skill/scripts/lib/pi.mjs +147 -32
- package/skills/evaluate-skill/scripts/lib/rpc.mjs +4 -4
- package/skills/evaluate-skill/scripts/lib/runner.mjs +36 -14
- package/skills/evaluate-skill/scripts/lib/sandbox.mjs +92 -0
- package/skills/evaluate-skill/scripts/pi-guard.mjs +1 -1
- package/skills/evaluate-skill/scripts/pi-observer.mjs +66 -0
- package/skills/evaluate-skill/scripts/skill-eval.mjs +6 -5
- package/skills/execute-work/SKILL.md +99 -57
- package/skills/execute-work/references/code-practices.md +4 -4
- package/skills/execute-work/references/execute-work-edges.md +62 -0
- package/skills/finish-branch/SKILL.md +2 -2
- package/skills/finish-branch/references/integration-options.md +1 -1
- package/skills/handoff/SKILL.md +3 -3
- package/skills/launch-work/SKILL.md +1 -1
- package/skills/launch-work/references/launch-readiness.md +2 -2
- package/skills/migration-work/SKILL.md +2 -2
- package/skills/migration-work/references/migration-lifecycle.md +1 -1
- package/skills/release-work/SKILL.md +1 -1
- package/skills/release-work/references/release-evidence.md +1 -1
- package/skills/review-artifact/SKILL.md +129 -66
- package/skills/review-artifact/references/adjudicate-artifact-review.md +101 -0
- package/skills/review-artifact/references/independent-artifact-reviewer-contract.md +159 -0
- package/skills/review-work/SKILL.md +113 -68
- package/skills/review-work/references/adjudicate-work-review.md +97 -0
- package/skills/review-work/references/independent-work-reviewer-contract.md +139 -0
- package/skills/review-work/references/security-risk-lens.md +18 -16
- package/skills/setup-freeflow/SKILL.md +16 -17
- package/skills/setup-freeflow/references/activation-contract.md +24 -30
- package/skills/setup-freeflow/references/host-setup.md +6 -7
- package/skills/simplify-code/SKILL.md +97 -39
- package/skills/simplify-code/references/simplification-patterns.md +1 -1
- package/skills/tdd/SKILL.md +100 -53
- package/skills/tdd/references/test-design.md +3 -3
- package/skills/track-work/SKILL.md +195 -58
- package/skills/track-work/references/working-record-format.md +515 -0
- package/skills/track-work/scripts/lib/document.mjs +713 -0
- package/skills/track-work/scripts/lib/format.mjs +166 -0
- package/skills/track-work/scripts/lib/store.mjs +233 -0
- package/skills/track-work/scripts/lib/transitions.mjs +790 -0
- package/skills/track-work/scripts/lib/views.mjs +40 -0
- package/skills/track-work/scripts/working-record.mjs +316 -0
- package/skills/verify-work/SKILL.md +57 -19
- package/skills/verify-work/references/browser-runtime-evidence.md +2 -2
- package/skills/verify-work/references/integration-evidence.md +1 -7
- package/skills/verify-work/references/performance-evidence.md +2 -2
- package/skills/workflow/SKILL.md +137 -55
- package/skills/workflow/references/domain-skill-composition.md +26 -40
- package/skills/write-plan/SKILL.md +1 -1
- package/skills/write-skill/SKILL.md +218 -61
- package/skills/write-skill/references/activation-boundaries.md +63 -21
- package/skills/write-skill/references/agent-first-instructions.md +61 -27
- package/skills/write-skill/references/progressive-disclosure.md +97 -33
- package/skills/write-skill/references/skill-dependency-graphs.md +190 -0
- package/capabilities/output-router/SKILL.md +0 -206
- package/capabilities/output-router/references/safety-policy.md +0 -40
- package/capabilities/output-router/references/setup.md +0 -110
- package/pi-extension/dist/output-router/host-producer-identification.js +0 -232
- package/pi-extension/dist/output-router/native-safety-net.js +0 -216
- package/pi-extension/dist/output-router/observed-tool-routing.js +0 -122
- package/pi-extension/dist/output-router/renderers.js +0 -1023
- package/pi-extension/dist/output-router/router-tools.js +0 -554
- package/pi-extension/dist/output-router/schemas.js +0 -383
- package/pi-extension/dist/output-router/status.js +0 -744
- package/pi-extension/dist/output-router/utils.js +0 -502
- package/pi-extension/src/output-router/host-producer-identification.ts +0 -256
- package/pi-extension/src/output-router/native-safety-net.ts +0 -248
- package/pi-extension/src/output-router/observed-tool-routing.ts +0 -134
- package/pi-extension/src/output-router/renderers.ts +0 -1108
- package/pi-extension/src/output-router/router-tools.ts +0 -579
- package/pi-extension/src/output-router/schemas.ts +0 -387
- package/pi-extension/src/output-router/status.ts +0 -791
- package/pi-extension/src/output-router/utils.ts +0 -554
- package/pi-extension/tests/output-router/observed-producers.test.js +0 -132
- package/pi-extension/tests/output-router/search.test.js +0 -722
- package/router/dist/benchmarks/benchmark-harness.d.ts +0 -35
- package/router/dist/benchmarks/benchmark-harness.js +0 -92
- package/router/dist/benchmarks/benchmarks.d.ts +0 -109
- package/router/dist/benchmarks/benchmarks.js +0 -979
- package/router/dist/benchmarks/codex-qa-benchmarks.d.ts +0 -95
- package/router/dist/benchmarks/codex-qa-benchmarks.js +0 -500
- package/router/dist/benchmarks/command-benchmarks.d.ts +0 -143
- package/router/dist/benchmarks/command-benchmarks.js +0 -698
- package/router/dist/benchmarks/context-mode-normalized-benchmarks.d.ts +0 -82
- package/router/dist/benchmarks/context-mode-normalized-benchmarks.js +0 -773
- package/router/dist/benchmarks/context-mode-real-deep-benchmark.d.ts +0 -132
- package/router/dist/benchmarks/context-mode-real-deep-benchmark.js +0 -1380
- package/router/dist/benchmarks/context-saving-baseline.d.ts +0 -60
- package/router/dist/benchmarks/context-saving-baseline.js +0 -470
- package/router/dist/benchmarks/index-benchmarks.d.ts +0 -103
- package/router/dist/benchmarks/index-benchmarks.js +0 -862
- package/router/dist/benchmarks/storage-policy-benchmarks.d.ts +0 -101
- package/router/dist/benchmarks/storage-policy-benchmarks.js +0 -618
- package/router/dist/benchmarks/vault-index-benchmarks.d.ts +0 -56
- package/router/dist/benchmarks/vault-index-benchmarks.js +0 -322
- package/router/dist/config/config.d.ts +0 -103
- package/router/dist/config/config.js +0 -632
- package/router/dist/config/router-contract.d.ts +0 -10
- package/router/dist/config/router-contract.js +0 -54
- package/router/dist/config/schema.d.ts +0 -27
- package/router/dist/config/schema.js +0 -648
- package/router/dist/config/types.d.ts +0 -573
- package/router/dist/config/types.js +0 -41
- package/router/dist/evidence/bounded-evidence.d.ts +0 -40
- package/router/dist/evidence/bounded-evidence.js +0 -323
- package/router/dist/evidence/evidence-range-selector.d.ts +0 -24
- package/router/dist/evidence/evidence-range-selector.js +0 -232
- package/router/dist/evidence/evidence-search.d.ts +0 -27
- package/router/dist/evidence/evidence-search.js +0 -490
- package/router/dist/evidence/evidence.d.ts +0 -38
- package/router/dist/evidence/evidence.js +0 -200
- package/router/dist/evidence/failure-contracts.d.ts +0 -37
- package/router/dist/evidence/failure-contracts.js +0 -166
- package/router/dist/evidence/line-ranges.d.ts +0 -24
- package/router/dist/evidence/line-ranges.js +0 -22
- package/router/dist/experiments/local-index.d.ts +0 -64
- package/router/dist/experiments/local-index.js +0 -581
- package/router/dist/index.d.ts +0 -30
- package/router/dist/index.js +0 -32
- package/router/dist/local/local-traversal.d.ts +0 -18
- package/router/dist/local/local-traversal.js +0 -334
- package/router/dist/processing/engine.d.ts +0 -132
- package/router/dist/processing/engine.js +0 -533
- package/router/dist/processing/reducers.d.ts +0 -280
- package/router/dist/processing/reducers.js +0 -1673
- package/router/dist/processing/renderers.d.ts +0 -31
- package/router/dist/processing/renderers.js +0 -195
- package/router/dist/processing/scripts.d.ts +0 -91
- package/router/dist/processing/scripts.js +0 -386
- package/router/dist/repo/repo-traversal.d.ts +0 -18
- package/router/dist/repo/repo-traversal.js +0 -245
- package/router/dist/routing/observed-reducers.d.ts +0 -41
- package/router/dist/routing/observed-reducers.js +0 -661
- package/router/dist/routing/observed-routing.d.ts +0 -26
- package/router/dist/routing/observed-routing.js +0 -378
- package/router/dist/routing/parsers.d.ts +0 -16
- package/router/dist/routing/parsers.js +0 -521
- package/router/dist/routing/run-filters.d.ts +0 -60
- package/router/dist/routing/run-filters.js +0 -238
- package/router/dist/routing/run-reducers.d.ts +0 -49
- package/router/dist/routing/run-reducers.js +0 -122
- package/router/dist/sandbox/adapter-roots.d.ts +0 -46
- package/router/dist/sandbox/adapter-roots.js +0 -66
- package/router/dist/sandbox/eryx-python-adapter.d.ts +0 -13
- package/router/dist/sandbox/eryx-python-adapter.js +0 -868
- package/router/dist/sandbox/jq-wasm-adapter.d.ts +0 -9
- package/router/dist/sandbox/jq-wasm-adapter.js +0 -429
- package/router/dist/sandbox/quickjs-wasi-adapter.d.ts +0 -13
- package/router/dist/sandbox/quickjs-wasi-adapter.js +0 -384
- package/router/dist/sandbox/script-sandbox.d.ts +0 -134
- package/router/dist/sandbox/script-sandbox.js +0 -337
- package/router/dist/setup/script-transform-adapters.d.ts +0 -32
- package/router/dist/setup/script-transform-adapters.js +0 -278
- package/router/dist/tools/batch.d.ts +0 -33
- package/router/dist/tools/batch.js +0 -586
- package/router/dist/tools/run.d.ts +0 -62
- package/router/dist/tools/run.js +0 -1304
- package/router/dist/tools/search.d.ts +0 -66
- package/router/dist/tools/search.js +0 -1364
- package/router/dist/transform/engine.d.ts +0 -168
- package/router/dist/transform/engine.js +0 -2072
- package/router/dist/vault/vault-index.d.ts +0 -125
- package/router/dist/vault/vault-index.js +0 -416
- package/router/dist/vault/vault.d.ts +0 -138
- package/router/dist/vault/vault.js +0 -630
- package/runtime/interaction-contract.md +0 -16
- package/skills/discuss/references/checkpoints.md +0 -66
- package/skills/execute-work/references/execution-loop.md +0 -77
- package/skills/mode-contract/SKILL.md +0 -104
- package/skills/review-artifact/references/reviewer-prompt.md +0 -148
- package/skills/review-work/references/reviewer-prompt.md +0 -134
- package/skills/track-work/references/working-record-schema.md +0 -378
- package/skills/workflow/references/workflow-loop.md +0 -92
- /package/skills/handoff/references/{templates.md → handoff-templates.md} +0 -0
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { assembleImportantLines, lineEntries } from "../evidence/evidence.js";
|
|
2
|
-
export const RUN_FILTER_STREAMS = ["stdout", "stderr", "combined"];
|
|
3
|
-
export function normalizeRunOutputFilters(input) {
|
|
4
|
-
if (input === undefined || input === null) {
|
|
5
|
-
return { ok: true };
|
|
6
|
-
}
|
|
7
|
-
if (!isRecord(input)) {
|
|
8
|
-
return { ok: false, path: "$.filters", message: "freeflow_run filters must be an object." };
|
|
9
|
-
}
|
|
10
|
-
const filters = {
|
|
11
|
-
include: [],
|
|
12
|
-
exclude: [],
|
|
13
|
-
flags: typeof input.flags === "string" ? input.flags : "",
|
|
14
|
-
};
|
|
15
|
-
if (input.stream !== undefined) {
|
|
16
|
-
if (!isRunFilterStream(input.stream)) {
|
|
17
|
-
return { ok: false, path: "$.filters.stream", message: "filters.stream must be stdout, stderr, or combined." };
|
|
18
|
-
}
|
|
19
|
-
filters.stream = input.stream;
|
|
20
|
-
}
|
|
21
|
-
for (const key of ["include", "exclude"]) {
|
|
22
|
-
const normalized = normalizeStringList(input[key], `$.filters.${key}`);
|
|
23
|
-
if (!normalized.ok) {
|
|
24
|
-
return normalized;
|
|
25
|
-
}
|
|
26
|
-
filters[key] = normalized.values;
|
|
27
|
-
}
|
|
28
|
-
if (!/^(?!.*([gimsu]).*\1)[gimsu]*$/.test(filters.flags)) {
|
|
29
|
-
return {
|
|
30
|
-
ok: false,
|
|
31
|
-
path: "$.filters.flags",
|
|
32
|
-
message: "filters.flags may contain g, i, m, s, or u without duplicates.",
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
for (const key of ["head", "tail", "maxLines", "maxBytes"]) {
|
|
36
|
-
if (input[key] === undefined) {
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
const value = input[key];
|
|
40
|
-
if (typeof value !== "number" || !Number.isInteger(value) || value <= 0) {
|
|
41
|
-
return { ok: false, path: `$.filters.${key}`, message: `${key} must be a positive integer.` };
|
|
42
|
-
}
|
|
43
|
-
filters[key] = value;
|
|
44
|
-
}
|
|
45
|
-
for (const [kind, patterns] of [
|
|
46
|
-
["include", filters.include],
|
|
47
|
-
["exclude", filters.exclude],
|
|
48
|
-
]) {
|
|
49
|
-
for (const pattern of patterns) {
|
|
50
|
-
try {
|
|
51
|
-
new RegExp(pattern, filters.flags);
|
|
52
|
-
} catch (error) {
|
|
53
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
54
|
-
return {
|
|
55
|
-
ok: false,
|
|
56
|
-
path: `$.filters.${kind}`,
|
|
57
|
-
message: `Invalid ${kind} regex ${JSON.stringify(pattern)}: ${message}`,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return { ok: true, filters };
|
|
63
|
-
}
|
|
64
|
-
export function hasRunOutputFilters(filters) {
|
|
65
|
-
return Boolean(
|
|
66
|
-
filters &&
|
|
67
|
-
(filters.stream ||
|
|
68
|
-
filters.include.length > 0 ||
|
|
69
|
-
filters.exclude.length > 0 ||
|
|
70
|
-
filters.head !== undefined ||
|
|
71
|
-
filters.tail !== undefined ||
|
|
72
|
-
filters.maxLines !== undefined ||
|
|
73
|
-
filters.maxBytes !== undefined),
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
export function applyRunOutputFilters(options) {
|
|
77
|
-
const stream = options.filters.stream ?? options.defaultStream;
|
|
78
|
-
const text = streamText(stream, options);
|
|
79
|
-
const sourceEntries = lineEntries(text);
|
|
80
|
-
const includeRegexes = options.filters.include.map((pattern) => new RegExp(pattern, options.filters.flags));
|
|
81
|
-
const excludeRegexes = options.filters.exclude.map((pattern) => new RegExp(pattern, options.filters.flags));
|
|
82
|
-
let selected = sourceEntries.filter((entry) => {
|
|
83
|
-
if (includeRegexes.length > 0 && !includeRegexes.some((regex) => regex.test(entry.line))) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
if (excludeRegexes.some((regex) => regex.test(entry.line))) {
|
|
87
|
-
return false;
|
|
88
|
-
}
|
|
89
|
-
return true;
|
|
90
|
-
});
|
|
91
|
-
selected = applyHeadTail(selected, options.filters.head, options.filters.tail);
|
|
92
|
-
if (options.filters.maxLines !== undefined) {
|
|
93
|
-
selected = selected.slice(0, options.filters.maxLines);
|
|
94
|
-
}
|
|
95
|
-
let fallbackPreservedFailureEvidence = false;
|
|
96
|
-
let evidence;
|
|
97
|
-
if (selected.length === 0 && options.preserveFallbackFailureEvidence && options.fallbackImportantLines?.length) {
|
|
98
|
-
fallbackPreservedFailureEvidence = true;
|
|
99
|
-
evidence = importantLinesAsEvidence(options.fallbackImportantLines, text);
|
|
100
|
-
} else {
|
|
101
|
-
const caps = {};
|
|
102
|
-
const maxLines = options.filters.maxLines ?? options.caps?.maxLines;
|
|
103
|
-
const maxExcerptBytes = options.filters.maxBytes ?? options.caps?.maxExcerptBytes;
|
|
104
|
-
const maxLineBytes = options.filters.maxBytes ?? options.caps?.maxLineBytes;
|
|
105
|
-
if (maxLines !== undefined) {
|
|
106
|
-
caps.maxLines = maxLines;
|
|
107
|
-
}
|
|
108
|
-
if (maxExcerptBytes !== undefined) {
|
|
109
|
-
caps.maxExcerptBytes = maxExcerptBytes;
|
|
110
|
-
}
|
|
111
|
-
if (maxLineBytes !== undefined) {
|
|
112
|
-
caps.maxLineBytes = maxLineBytes;
|
|
113
|
-
}
|
|
114
|
-
evidence = assembleImportantLines({
|
|
115
|
-
stream,
|
|
116
|
-
entries: selected,
|
|
117
|
-
sourceText: text,
|
|
118
|
-
caps,
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
const metadata = {
|
|
122
|
-
stream,
|
|
123
|
-
sourceLines: sourceEntries.length,
|
|
124
|
-
selectedLines: selected.length,
|
|
125
|
-
};
|
|
126
|
-
if (options.filters.include.length > 0) {
|
|
127
|
-
metadata.include = options.filters.include;
|
|
128
|
-
}
|
|
129
|
-
if (options.filters.exclude.length > 0) {
|
|
130
|
-
metadata.exclude = options.filters.exclude;
|
|
131
|
-
}
|
|
132
|
-
if (options.filters.flags) {
|
|
133
|
-
metadata.flags = options.filters.flags;
|
|
134
|
-
}
|
|
135
|
-
if (options.filters.head !== undefined) {
|
|
136
|
-
metadata.head = options.filters.head;
|
|
137
|
-
}
|
|
138
|
-
if (options.filters.tail !== undefined) {
|
|
139
|
-
metadata.tail = options.filters.tail;
|
|
140
|
-
}
|
|
141
|
-
if (options.filters.maxLines !== undefined) {
|
|
142
|
-
metadata.maxLines = options.filters.maxLines;
|
|
143
|
-
}
|
|
144
|
-
if (options.filters.maxBytes !== undefined) {
|
|
145
|
-
metadata.maxBytes = options.filters.maxBytes;
|
|
146
|
-
}
|
|
147
|
-
if (fallbackPreservedFailureEvidence) {
|
|
148
|
-
metadata.fallbackPreservedFailureEvidence = true;
|
|
149
|
-
}
|
|
150
|
-
return {
|
|
151
|
-
stream,
|
|
152
|
-
evidence,
|
|
153
|
-
metadata,
|
|
154
|
-
description: describeRunOutputFilters(metadata),
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
function normalizeStringList(value, path) {
|
|
158
|
-
if (value === undefined) {
|
|
159
|
-
return { ok: true, values: [] };
|
|
160
|
-
}
|
|
161
|
-
const values = typeof value === "string" ? [value] : Array.isArray(value) ? value : undefined;
|
|
162
|
-
if (!values) {
|
|
163
|
-
return { ok: false, path, message: `${path} must be a string or string array.` };
|
|
164
|
-
}
|
|
165
|
-
if (!values.every((item) => typeof item === "string" && item.length > 0)) {
|
|
166
|
-
return { ok: false, path, message: `${path} must contain non-empty strings.` };
|
|
167
|
-
}
|
|
168
|
-
return { ok: true, values: [...values] };
|
|
169
|
-
}
|
|
170
|
-
function isRunFilterStream(value) {
|
|
171
|
-
return typeof value === "string" && RUN_FILTER_STREAMS.includes(value);
|
|
172
|
-
}
|
|
173
|
-
function isRecord(value) {
|
|
174
|
-
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
175
|
-
}
|
|
176
|
-
function streamText(stream, options) {
|
|
177
|
-
if (stream === "stdout") {
|
|
178
|
-
return options.stdout;
|
|
179
|
-
}
|
|
180
|
-
if (stream === "stderr") {
|
|
181
|
-
return options.stderr;
|
|
182
|
-
}
|
|
183
|
-
return options.combined;
|
|
184
|
-
}
|
|
185
|
-
function applyHeadTail(entries, head, tail) {
|
|
186
|
-
if (head === undefined && tail === undefined) {
|
|
187
|
-
return entries;
|
|
188
|
-
}
|
|
189
|
-
if (head !== undefined && tail !== undefined) {
|
|
190
|
-
const byLine = new Map();
|
|
191
|
-
for (const entry of [...entries.slice(0, head), ...entries.slice(Math.max(0, entries.length - tail))]) {
|
|
192
|
-
byLine.set(entry.lineNumber, entry);
|
|
193
|
-
}
|
|
194
|
-
return [...byLine.values()].sort((left, right) => left.lineNumber - right.lineNumber);
|
|
195
|
-
}
|
|
196
|
-
if (head !== undefined) {
|
|
197
|
-
return entries.slice(0, head);
|
|
198
|
-
}
|
|
199
|
-
return entries.slice(Math.max(0, entries.length - tail));
|
|
200
|
-
}
|
|
201
|
-
function importantLinesAsEvidence(importantLines, sourceText) {
|
|
202
|
-
return {
|
|
203
|
-
importantLines: [...importantLines],
|
|
204
|
-
fidelity: "exact",
|
|
205
|
-
compressed: true,
|
|
206
|
-
selectedLineCount: importantLines.length,
|
|
207
|
-
sourceLineCount: lineEntries(sourceText).length,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
export function describeRunOutputFilters(metadata) {
|
|
211
|
-
const parts = [`stream=${metadata.stream}`];
|
|
212
|
-
if (metadata.include?.length) {
|
|
213
|
-
parts.push(`include=${metadata.include.map((pattern) => JSON.stringify(pattern)).join("|")}`);
|
|
214
|
-
}
|
|
215
|
-
if (metadata.exclude?.length) {
|
|
216
|
-
parts.push(`exclude=${metadata.exclude.map((pattern) => JSON.stringify(pattern)).join("|")}`);
|
|
217
|
-
}
|
|
218
|
-
if (metadata.flags) {
|
|
219
|
-
parts.push(`flags=${metadata.flags}`);
|
|
220
|
-
}
|
|
221
|
-
if (metadata.head !== undefined) {
|
|
222
|
-
parts.push(`head=${metadata.head}`);
|
|
223
|
-
}
|
|
224
|
-
if (metadata.tail !== undefined) {
|
|
225
|
-
parts.push(`tail=${metadata.tail}`);
|
|
226
|
-
}
|
|
227
|
-
if (metadata.maxLines !== undefined) {
|
|
228
|
-
parts.push(`maxLines=${metadata.maxLines}`);
|
|
229
|
-
}
|
|
230
|
-
if (metadata.maxBytes !== undefined) {
|
|
231
|
-
parts.push(`maxBytes=${metadata.maxBytes}`);
|
|
232
|
-
}
|
|
233
|
-
parts.push(`selected=${metadata.selectedLines}/${metadata.sourceLines} lines`);
|
|
234
|
-
if (metadata.fallbackPreservedFailureEvidence) {
|
|
235
|
-
parts.push("fallback=failure-evidence");
|
|
236
|
-
}
|
|
237
|
-
return parts.join(" ");
|
|
238
|
-
}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { type ProcessingReducerResult } from "../processing/reducers.js";
|
|
2
|
-
import type {
|
|
3
|
-
CommandParserMetadata,
|
|
4
|
-
ExecutionStatus,
|
|
5
|
-
ImportantLine,
|
|
6
|
-
PreserveMode,
|
|
7
|
-
RouterThresholds,
|
|
8
|
-
} from "../config/types.js";
|
|
9
|
-
export type RunReducerRoute =
|
|
10
|
-
| {
|
|
11
|
-
status: "selected";
|
|
12
|
-
result: ProcessingReducerResult;
|
|
13
|
-
sourceStream: ImportantLine["stream"];
|
|
14
|
-
reason: string;
|
|
15
|
-
}
|
|
16
|
-
| {
|
|
17
|
-
status: "not_selected";
|
|
18
|
-
reason: string;
|
|
19
|
-
};
|
|
20
|
-
export interface SelectRunReducerRouteOptions {
|
|
21
|
-
command: string | readonly string[];
|
|
22
|
-
goal?: string;
|
|
23
|
-
executionStatus: ExecutionStatus;
|
|
24
|
-
stdout: string;
|
|
25
|
-
stderr: string;
|
|
26
|
-
combined: string;
|
|
27
|
-
preserve: PreserveMode;
|
|
28
|
-
thresholds: RouterThresholds;
|
|
29
|
-
hasFilters: boolean;
|
|
30
|
-
hasScriptFilter: boolean;
|
|
31
|
-
}
|
|
32
|
-
export declare function selectRunReducerRoute(options: SelectRunReducerRouteOptions): RunReducerRoute;
|
|
33
|
-
export declare function reducerImportantLines(
|
|
34
|
-
route: Extract<
|
|
35
|
-
RunReducerRoute,
|
|
36
|
-
{
|
|
37
|
-
status: "selected";
|
|
38
|
-
}
|
|
39
|
-
>,
|
|
40
|
-
): ImportantLine[];
|
|
41
|
-
export declare function parserWithReducer(
|
|
42
|
-
parser: CommandParserMetadata,
|
|
43
|
-
route: Extract<
|
|
44
|
-
RunReducerRoute,
|
|
45
|
-
{
|
|
46
|
-
status: "selected";
|
|
47
|
-
}
|
|
48
|
-
>,
|
|
49
|
-
): CommandParserMetadata;
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { byteLength, countLines } from "../evidence/evidence.js";
|
|
2
|
-
import { selectProcessingReducer } from "../processing/reducers.js";
|
|
3
|
-
export function selectRunReducerRoute(options) {
|
|
4
|
-
if (options.preserve === "full") {
|
|
5
|
-
return { status: "not_selected", reason: "preserve=full requires exact command output routing." };
|
|
6
|
-
}
|
|
7
|
-
if (options.executionStatus !== "success") {
|
|
8
|
-
return { status: "not_selected", reason: "command did not succeed; preserve parser-selected failure evidence." };
|
|
9
|
-
}
|
|
10
|
-
if (options.hasFilters) {
|
|
11
|
-
return { status: "not_selected", reason: "declarative filters already define the routed command output." };
|
|
12
|
-
}
|
|
13
|
-
if (options.hasScriptFilter) {
|
|
14
|
-
return { status: "not_selected", reason: "scriptFilter already defines the routed command output." };
|
|
15
|
-
}
|
|
16
|
-
const source = reducerSourceText(options.stdout, options.stderr, options.combined);
|
|
17
|
-
if (source === undefined) {
|
|
18
|
-
return {
|
|
19
|
-
status: "not_selected",
|
|
20
|
-
reason: "mixed stdout/stderr success output stays near-raw to avoid hiding warnings.",
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
const selection = selectProcessingReducer({
|
|
24
|
-
text: source.text,
|
|
25
|
-
...(options.goal !== undefined ? { goal: options.goal } : {}),
|
|
26
|
-
});
|
|
27
|
-
if (selection.status !== "selected") {
|
|
28
|
-
return { status: "not_selected", reason: selection.reason };
|
|
29
|
-
}
|
|
30
|
-
const goalText = (options.goal ?? "").toLowerCase();
|
|
31
|
-
const commandTextValue = commandText(options.command).toLowerCase();
|
|
32
|
-
const outputIsLarge =
|
|
33
|
-
byteLength(source.text) > options.thresholds.largeOutputBytes ||
|
|
34
|
-
countLines(source.text) > options.thresholds.largeOutputLines;
|
|
35
|
-
const intentAllowsReducer = reducerIntentAllowsSelection(goalText, commandTextValue, selection.result.name);
|
|
36
|
-
const largeOutputAllowsReducer = outputIsLarge && reducerLargeOutputAllowsSelection(goalText, selection.result);
|
|
37
|
-
if (!largeOutputAllowsReducer && !intentAllowsReducer) {
|
|
38
|
-
return {
|
|
39
|
-
status: "not_selected",
|
|
40
|
-
reason: `Reducer ${selection.result.name}@${selection.result.version} matched, but neither output size nor reducer-oriented goal/command intent allowed automatic reduction.`,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
status: "selected",
|
|
45
|
-
result: selection.result,
|
|
46
|
-
sourceStream: source.stream,
|
|
47
|
-
reason: `Selected ${selection.result.name}@${selection.result.version} reducer for successful command output (confidence=${selection.result.confidence.toFixed(2)}; ${largeOutputAllowsReducer ? "large output" : "goal/command intent"}).`,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
export function reducerImportantLines(route) {
|
|
51
|
-
return [
|
|
52
|
-
{
|
|
53
|
-
stream: route.sourceStream,
|
|
54
|
-
lines: lineRangeForText(route.result.visibleText),
|
|
55
|
-
excerpt: route.result.visibleText,
|
|
56
|
-
},
|
|
57
|
-
];
|
|
58
|
-
}
|
|
59
|
-
export function parserWithReducer(parser, route) {
|
|
60
|
-
return {
|
|
61
|
-
...parser,
|
|
62
|
-
name: `${parser.name}+reducer:${route.result.name}`,
|
|
63
|
-
confidence: Math.max(parser.confidence, route.result.confidence),
|
|
64
|
-
fidelity: "exact",
|
|
65
|
-
compressed: true,
|
|
66
|
-
counts: {
|
|
67
|
-
...(parser.counts ?? {}),
|
|
68
|
-
reducerFacts: route.result.facts.length,
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
function reducerSourceText(stdout, stderr, combined) {
|
|
73
|
-
if (stdout.length > 0 && stderr.length === 0) {
|
|
74
|
-
return { stream: "stdout", text: stdout };
|
|
75
|
-
}
|
|
76
|
-
if (stderr.length > 0 && stdout.length === 0) {
|
|
77
|
-
return { stream: "stderr", text: stderr };
|
|
78
|
-
}
|
|
79
|
-
if (stdout.length === 0 && stderr.length === 0 && combined.length > 0) {
|
|
80
|
-
return { stream: "combined", text: combined };
|
|
81
|
-
}
|
|
82
|
-
return undefined;
|
|
83
|
-
}
|
|
84
|
-
function reducerIntentAllowsSelection(goalText, commandTextValue, reducerName) {
|
|
85
|
-
switch (reducerName) {
|
|
86
|
-
case "test-output":
|
|
87
|
-
return /\b(test|tests|vitest|jest|pytest)\b/.test(goalText);
|
|
88
|
-
case "diagnostics":
|
|
89
|
-
return /\b(typecheck|type-check|tsc|lint|eslint|diagnostic)\b/.test(goalText);
|
|
90
|
-
case "build-output":
|
|
91
|
-
return /\b(build|compile|bundle|next)\b/.test(goalText);
|
|
92
|
-
case "access-log":
|
|
93
|
-
return /\b(log|logs|access|nginx|apache)\b/.test(goalText);
|
|
94
|
-
case "table":
|
|
95
|
-
return /\b(csv|json|table|analytics)\b/.test(goalText);
|
|
96
|
-
case "mcp-tools":
|
|
97
|
-
return /\b(mcp|tools?|schema|signatures?)\b/.test(goalText);
|
|
98
|
-
case "json-query":
|
|
99
|
-
return /\b(json|github|issues?|labels?|repo|repository|summary|summarize|summarise|analysis|analyze|analyse)\b/.test(
|
|
100
|
-
goalText,
|
|
101
|
-
);
|
|
102
|
-
case "browser-snapshot":
|
|
103
|
-
return /\b(browser|snapshot|playwright|accessibility|dom)\b/.test(goalText);
|
|
104
|
-
case "git-log":
|
|
105
|
-
return /\b(git\s+log|commits?|history|changelog)\b/.test(goalText) || /\bgit\s+log\b/.test(commandTextValue);
|
|
106
|
-
default:
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function reducerLargeOutputAllowsSelection(goalText, result) {
|
|
111
|
-
if (result.name === "json-query") {
|
|
112
|
-
return result.confidence >= 0.8;
|
|
113
|
-
}
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
function lineRangeForText(text) {
|
|
117
|
-
const lines = Math.max(1, countLines(text));
|
|
118
|
-
return `1-${lines}`;
|
|
119
|
-
}
|
|
120
|
-
function commandText(command) {
|
|
121
|
-
return typeof command === "string" ? command : command.join(" ");
|
|
122
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
export declare const SCRIPT_TRANSFORM_ADAPTERS_HOME_ENV = "FREEFLOW_SCRIPT_TRANSFORM_ADAPTERS_HOME";
|
|
2
|
-
export declare const SCRIPT_TRANSFORM_NODE_ENV = "FREEFLOW_SCRIPT_TRANSFORM_NODE";
|
|
3
|
-
export declare const SCRIPT_TRANSFORM_ADAPTER_PACKAGES: {
|
|
4
|
-
readonly javascript: {
|
|
5
|
-
readonly packageName: "quickjs-wasi";
|
|
6
|
-
readonly version: "3.0.1";
|
|
7
|
-
readonly env: "FREEFLOW_QUICKJS_WASI_ROOT";
|
|
8
|
-
};
|
|
9
|
-
readonly jq: {
|
|
10
|
-
readonly packageName: "jq-wasm";
|
|
11
|
-
readonly version: "1.2.0-jq-1.8.2";
|
|
12
|
-
readonly env: "FREEFLOW_JQ_WASM_ROOT";
|
|
13
|
-
};
|
|
14
|
-
readonly python: {
|
|
15
|
-
readonly packageName: "@bsull/eryx";
|
|
16
|
-
readonly version: "0.5.0";
|
|
17
|
-
readonly env: "FREEFLOW_ERYX_ROOT";
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
export declare const SCRIPT_TRANSFORM_SUPPORT_PACKAGES: {
|
|
21
|
-
readonly node: {
|
|
22
|
-
readonly packageName: "node";
|
|
23
|
-
readonly version: "24";
|
|
24
|
-
readonly env: "FREEFLOW_SCRIPT_TRANSFORM_NODE";
|
|
25
|
-
};
|
|
26
|
-
};
|
|
27
|
-
export type ScriptTransformAdapterLanguage = keyof typeof SCRIPT_TRANSFORM_ADAPTER_PACKAGES;
|
|
28
|
-
export interface ScriptTransformAdapterRootCandidate {
|
|
29
|
-
packageRoot: string;
|
|
30
|
-
source: "env" | "global-cache";
|
|
31
|
-
envVar: string;
|
|
32
|
-
}
|
|
33
|
-
export declare function defaultScriptTransformAdaptersHome(env?: NodeJS.ProcessEnv): string;
|
|
34
|
-
export declare function defaultScriptTransformAdapterRoot(
|
|
35
|
-
language: ScriptTransformAdapterLanguage,
|
|
36
|
-
env?: NodeJS.ProcessEnv,
|
|
37
|
-
): string;
|
|
38
|
-
export declare function resolveScriptTransformAdapterRoot(
|
|
39
|
-
language: ScriptTransformAdapterLanguage,
|
|
40
|
-
env?: NodeJS.ProcessEnv,
|
|
41
|
-
): Promise<ScriptTransformAdapterRootCandidate | null>;
|
|
42
|
-
export declare function defaultScriptTransformNodeBinary(env?: NodeJS.ProcessEnv): string;
|
|
43
|
-
export declare function scriptTransformAdapterInstallSpecs(
|
|
44
|
-
languages?: readonly ScriptTransformAdapterLanguage[],
|
|
45
|
-
): string[];
|
|
46
|
-
export declare function scriptTransformAdapterEnvExports(home?: string): Record<string, string>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { access } from "node:fs/promises";
|
|
2
|
-
import { homedir } from "node:os";
|
|
3
|
-
import { join } from "node:path";
|
|
4
|
-
export const SCRIPT_TRANSFORM_ADAPTERS_HOME_ENV = "FREEFLOW_SCRIPT_TRANSFORM_ADAPTERS_HOME";
|
|
5
|
-
export const SCRIPT_TRANSFORM_NODE_ENV = "FREEFLOW_SCRIPT_TRANSFORM_NODE";
|
|
6
|
-
export const SCRIPT_TRANSFORM_ADAPTER_PACKAGES = {
|
|
7
|
-
javascript: { packageName: "quickjs-wasi", version: "3.0.1", env: "FREEFLOW_QUICKJS_WASI_ROOT" },
|
|
8
|
-
jq: { packageName: "jq-wasm", version: "1.2.0-jq-1.8.2", env: "FREEFLOW_JQ_WASM_ROOT" },
|
|
9
|
-
python: { packageName: "@bsull/eryx", version: "0.5.0", env: "FREEFLOW_ERYX_ROOT" },
|
|
10
|
-
};
|
|
11
|
-
export const SCRIPT_TRANSFORM_SUPPORT_PACKAGES = {
|
|
12
|
-
node: { packageName: "node", version: "24", env: SCRIPT_TRANSFORM_NODE_ENV },
|
|
13
|
-
};
|
|
14
|
-
export function defaultScriptTransformAdaptersHome(env = process.env) {
|
|
15
|
-
return env[SCRIPT_TRANSFORM_ADAPTERS_HOME_ENV] || join(homedir(), ".cache", "freeflow-script-adapters");
|
|
16
|
-
}
|
|
17
|
-
export function defaultScriptTransformAdapterRoot(language, env = process.env) {
|
|
18
|
-
const packageName = SCRIPT_TRANSFORM_ADAPTER_PACKAGES[language].packageName;
|
|
19
|
-
return join(defaultScriptTransformAdaptersHome(env), "node_modules", ...packageName.split("/"));
|
|
20
|
-
}
|
|
21
|
-
export async function resolveScriptTransformAdapterRoot(language, env = process.env) {
|
|
22
|
-
const adapter = SCRIPT_TRANSFORM_ADAPTER_PACKAGES[language];
|
|
23
|
-
const explicitRoot = env[adapter.env];
|
|
24
|
-
if (explicitRoot) {
|
|
25
|
-
return { packageRoot: explicitRoot, source: "env", envVar: adapter.env };
|
|
26
|
-
}
|
|
27
|
-
const packageRoot = defaultScriptTransformAdapterRoot(language, env);
|
|
28
|
-
if (await packageRootExists(packageRoot)) {
|
|
29
|
-
return { packageRoot, source: "global-cache", envVar: adapter.env };
|
|
30
|
-
}
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
export function defaultScriptTransformNodeBinary(env = process.env) {
|
|
34
|
-
return (
|
|
35
|
-
env[SCRIPT_TRANSFORM_NODE_ENV] ||
|
|
36
|
-
join(defaultScriptTransformAdaptersHome(env), "node_modules", "node", "bin", "node")
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
export function scriptTransformAdapterInstallSpecs(languages = ["javascript", "jq", "python"]) {
|
|
40
|
-
const specs = languages.map((language) => {
|
|
41
|
-
const adapter = SCRIPT_TRANSFORM_ADAPTER_PACKAGES[language];
|
|
42
|
-
return `${adapter.packageName}@${adapter.version}`;
|
|
43
|
-
});
|
|
44
|
-
if (languages.includes("python")) {
|
|
45
|
-
const node = SCRIPT_TRANSFORM_SUPPORT_PACKAGES.node;
|
|
46
|
-
specs.push(`${node.packageName}@${node.version}`);
|
|
47
|
-
}
|
|
48
|
-
return specs;
|
|
49
|
-
}
|
|
50
|
-
export function scriptTransformAdapterEnvExports(home = defaultScriptTransformAdaptersHome()) {
|
|
51
|
-
return {
|
|
52
|
-
[SCRIPT_TRANSFORM_ADAPTERS_HOME_ENV]: home,
|
|
53
|
-
[SCRIPT_TRANSFORM_ADAPTER_PACKAGES.javascript.env]: join(home, "node_modules", "quickjs-wasi"),
|
|
54
|
-
[SCRIPT_TRANSFORM_ADAPTER_PACKAGES.jq.env]: join(home, "node_modules", "jq-wasm"),
|
|
55
|
-
[SCRIPT_TRANSFORM_ADAPTER_PACKAGES.python.env]: join(home, "node_modules", "@bsull", "eryx"),
|
|
56
|
-
[SCRIPT_TRANSFORM_NODE_ENV]: join(home, "node_modules", "node", "bin", "node"),
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
async function packageRootExists(packageRoot) {
|
|
60
|
-
try {
|
|
61
|
-
await access(join(packageRoot, "package.json"));
|
|
62
|
-
return true;
|
|
63
|
-
} catch {
|
|
64
|
-
return false;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { ScriptSandboxAdapter } from "./script-sandbox.js";
|
|
2
|
-
export declare const ERYX_ROOT_ENV = "FREEFLOW_ERYX_ROOT";
|
|
3
|
-
export interface EryxPythonSandboxAdapterOptions {
|
|
4
|
-
packageRoot: string;
|
|
5
|
-
id?: string;
|
|
6
|
-
version?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare function discoverEryxPythonSandboxAdaptersFromEnv(
|
|
9
|
-
env?: NodeJS.ProcessEnv,
|
|
10
|
-
): Promise<ScriptSandboxAdapter[]>;
|
|
11
|
-
export declare function createEryxPythonSandboxAdapter(
|
|
12
|
-
options: EryxPythonSandboxAdapterOptions,
|
|
13
|
-
): Promise<ScriptSandboxAdapter>;
|