@llm4ts/runner 0.1.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/LICENSE +21 -0
- package/README.md +61 -0
- package/dist/Cli.d.ts +5 -0
- package/dist/Cli.d.ts.map +1 -0
- package/dist/Cli.js +36 -0
- package/dist/Cli.js.map +1 -0
- package/dist/CoderPolicy.d.ts +12 -0
- package/dist/CoderPolicy.d.ts.map +1 -0
- package/dist/CoderPolicy.js +59 -0
- package/dist/CoderPolicy.js.map +1 -0
- package/dist/Connectors.d.ts +28 -0
- package/dist/Connectors.d.ts.map +1 -0
- package/dist/Connectors.js +165 -0
- package/dist/Connectors.js.map +1 -0
- package/dist/Doctor.d.ts +4 -0
- package/dist/Doctor.d.ts.map +1 -0
- package/dist/Doctor.js +33 -0
- package/dist/Doctor.js.map +1 -0
- package/dist/FlowArgs.d.ts +34 -0
- package/dist/FlowArgs.d.ts.map +1 -0
- package/dist/FlowArgs.js +136 -0
- package/dist/FlowArgs.js.map +1 -0
- package/dist/FlowRunner.d.ts +48 -0
- package/dist/FlowRunner.d.ts.map +1 -0
- package/dist/FlowRunner.js +97 -0
- package/dist/FlowRunner.js.map +1 -0
- package/dist/McpStdio.d.ts +7 -0
- package/dist/McpStdio.d.ts.map +1 -0
- package/dist/McpStdio.js +19 -0
- package/dist/McpStdio.js.map +1 -0
- package/dist/NodeGeminiCliExecutor.d.ts +7 -0
- package/dist/NodeGeminiCliExecutor.d.ts.map +1 -0
- package/dist/NodeGeminiCliExecutor.js +26 -0
- package/dist/NodeGeminiCliExecutor.js.map +1 -0
- package/dist/NodeHttpClient.d.ts +5 -0
- package/dist/NodeHttpClient.d.ts.map +1 -0
- package/dist/NodeHttpClient.js +109 -0
- package/dist/NodeHttpClient.js.map +1 -0
- package/dist/NodePlainFileStore.d.ts +5 -0
- package/dist/NodePlainFileStore.d.ts.map +1 -0
- package/dist/NodePlainFileStore.js +64 -0
- package/dist/NodePlainFileStore.js.map +1 -0
- package/dist/NodeProcessExecutor.d.ts +5 -0
- package/dist/NodeProcessExecutor.d.ts.map +1 -0
- package/dist/NodeProcessExecutor.js +212 -0
- package/dist/NodeProcessExecutor.js.map +1 -0
- package/dist/NodeRuntime.d.ts +4 -0
- package/dist/NodeRuntime.d.ts.map +1 -0
- package/dist/NodeRuntime.js +11 -0
- package/dist/NodeRuntime.js.map +1 -0
- package/dist/NodeTemporaryFiles.d.ts +5 -0
- package/dist/NodeTemporaryFiles.d.ts.map +1 -0
- package/dist/NodeTemporaryFiles.js +30 -0
- package/dist/NodeTemporaryFiles.js.map +1 -0
- package/dist/NodeWorkspace.d.ts +6 -0
- package/dist/NodeWorkspace.d.ts.map +1 -0
- package/dist/NodeWorkspace.js +231 -0
- package/dist/NodeWorkspace.js.map +1 -0
- package/dist/Package.d.ts +2 -0
- package/dist/Package.d.ts.map +1 -0
- package/dist/Package.js +2 -0
- package/dist/Package.js.map +1 -0
- package/dist/ReviewFingerprint.d.ts +2 -0
- package/dist/ReviewFingerprint.d.ts.map +1 -0
- package/dist/ReviewFingerprint.js +13 -0
- package/dist/ReviewFingerprint.js.map +1 -0
- package/dist/Terminal.d.ts +46 -0
- package/dist/Terminal.d.ts.map +1 -0
- package/dist/Terminal.js +226 -0
- package/dist/Terminal.js.map +1 -0
- package/dist/TerminalInteraction.d.ts +4 -0
- package/dist/TerminalInteraction.d.ts.map +1 -0
- package/dist/TerminalInteraction.js +25 -0
- package/dist/TerminalInteraction.js.map +1 -0
- package/dist/cli-main.d.ts +3 -0
- package/dist/cli-main.d.ts.map +1 -0
- package/dist/cli-main.js +39 -0
- package/dist/cli-main.js.map +1 -0
- package/package.json +74 -0
- package/src/Cli.ts +51 -0
- package/src/CoderPolicy.ts +82 -0
- package/src/Connectors.ts +225 -0
- package/src/Doctor.ts +44 -0
- package/src/FlowArgs.ts +167 -0
- package/src/FlowRunner.ts +220 -0
- package/src/McpStdio.ts +41 -0
- package/src/NodeGeminiCliExecutor.ts +56 -0
- package/src/NodeHttpClient.ts +224 -0
- package/src/NodePlainFileStore.ts +75 -0
- package/src/NodeProcessExecutor.ts +331 -0
- package/src/NodeRuntime.ts +19 -0
- package/src/NodeTemporaryFiles.ts +46 -0
- package/src/NodeWorkspace.ts +282 -0
- package/src/Package.ts +1 -0
- package/src/ReviewFingerprint.ts +13 -0
- package/src/Terminal.ts +329 -0
- package/src/TerminalInteraction.ts +43 -0
- package/src/cli-main.ts +53 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { createInterface } from "node:readline/promises"
|
|
2
|
+
import { stdin, stderr } from "node:process"
|
|
3
|
+
import * as Effect from "effect/Effect"
|
|
4
|
+
import { ProcessError } from "@llm4ts/flow/FlowError"
|
|
5
|
+
import type { ApprovalPolicy, InteractionShape } from "@llm4ts/flow/Interaction"
|
|
6
|
+
import { ApprovalAllowed, ApprovalDenied } from "@llm4ts/flow/Interaction"
|
|
7
|
+
|
|
8
|
+
export const terminalInteraction: InteractionShape = {
|
|
9
|
+
ask: (question) =>
|
|
10
|
+
Effect.acquireUseRelease(
|
|
11
|
+
Effect.sync(() =>
|
|
12
|
+
createInterface({
|
|
13
|
+
input: stdin,
|
|
14
|
+
output: stderr
|
|
15
|
+
})
|
|
16
|
+
),
|
|
17
|
+
(terminal) =>
|
|
18
|
+
Effect.tryPromise({
|
|
19
|
+
try: () => terminal.question(`❓ ${question}\n> `),
|
|
20
|
+
catch: (error) =>
|
|
21
|
+
ProcessError.make({
|
|
22
|
+
message: "terminal input",
|
|
23
|
+
detail: error instanceof Error ? error.message : String(error)
|
|
24
|
+
})
|
|
25
|
+
}),
|
|
26
|
+
(terminal) => Effect.sync(() => terminal.close())
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const terminalApprovalPolicy = (
|
|
31
|
+
interaction: InteractionShape = terminalInteraction
|
|
32
|
+
): ApprovalPolicy => ({
|
|
33
|
+
decide: (toolName, input) =>
|
|
34
|
+
interaction
|
|
35
|
+
.ask(`Allow tool '${toolName}' with input ${JSON.stringify(input)}? [y/N]`)
|
|
36
|
+
.pipe(
|
|
37
|
+
Effect.map((answer) =>
|
|
38
|
+
/^(y|yes)$/iu.test(answer.trim())
|
|
39
|
+
? new ApprovalAllowed()
|
|
40
|
+
: ApprovalDenied.make({ reason: "operator denied" })
|
|
41
|
+
)
|
|
42
|
+
)
|
|
43
|
+
})
|
package/src/cli-main.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { readFileSync } from "node:fs"
|
|
3
|
+
import * as Effect from "effect/Effect"
|
|
4
|
+
import { makeCliProgram } from "./Cli.ts"
|
|
5
|
+
import { makeDoctorProgram } from "./Doctor.ts"
|
|
6
|
+
import { FlowHelp, parseFlowArgs } from "./FlowArgs.ts"
|
|
7
|
+
|
|
8
|
+
const argv = process.argv.slice(2)
|
|
9
|
+
|
|
10
|
+
const packageVersion = (): string => {
|
|
11
|
+
const manifest: unknown = JSON.parse(
|
|
12
|
+
readFileSync(new URL("../package.json", import.meta.url), "utf8")
|
|
13
|
+
)
|
|
14
|
+
return typeof manifest === "object" &&
|
|
15
|
+
manifest !== null &&
|
|
16
|
+
"version" in manifest &&
|
|
17
|
+
typeof manifest.version === "string"
|
|
18
|
+
? manifest.version
|
|
19
|
+
: "unknown"
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const flowProgram = (): Effect.Effect<void> => {
|
|
23
|
+
const parsed = parseFlowArgs(argv)
|
|
24
|
+
if (parsed.ok && parsed.value.help === true) {
|
|
25
|
+
return Effect.sync(() => process.stdout.write(FlowHelp))
|
|
26
|
+
}
|
|
27
|
+
if (parsed.ok && parsed.value.version === true) {
|
|
28
|
+
return Effect.sync(() => process.stdout.write(`${packageVersion()}\n`))
|
|
29
|
+
}
|
|
30
|
+
return makeCliProgram(argv).pipe(
|
|
31
|
+
Effect.match({
|
|
32
|
+
onFailure: (error) => {
|
|
33
|
+
process.stderr.write(`${error.message}\n`)
|
|
34
|
+
return error._tag === "ScriptUsage" ? 2 : 1
|
|
35
|
+
},
|
|
36
|
+
onSuccess: () => 0
|
|
37
|
+
}),
|
|
38
|
+
Effect.flatMap((exitCode) =>
|
|
39
|
+
Effect.sync(() => {
|
|
40
|
+
process.exitCode = exitCode
|
|
41
|
+
})
|
|
42
|
+
)
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const main =
|
|
47
|
+
argv[0] === "doctor"
|
|
48
|
+
? makeDoctorProgram().pipe(
|
|
49
|
+
Effect.flatMap((report) => Effect.sync(() => process.stdout.write(report)))
|
|
50
|
+
)
|
|
51
|
+
: flowProgram()
|
|
52
|
+
|
|
53
|
+
Effect.runFork(main)
|